"""
Farnsworth Cursor Bridge.
"I can code in the dark!"
Specialized integration for Cursor IDE, leveraging its "Shadow Workspace" and AI features.
"""
from typing import Dict, Any, List
from loguru import logger
import os
class CursorBridge:
def __init__(self):
self.is_cursor = False
def detect_environment(self) -> bool:
"""Check if running within Cursor's environment."""
# Heuristics: Check for specific env vars or processes
self.is_cursor = "CURSOR_AGENT_PORT" in os.environ or os.path.exists(".cursorrules")
if self.is_cursor:
logger.info("Cursor IDE environment detected.")
return self.is_cursor
def generate_cursorrules(self, project_context: str):
"""
Auto-generate a .cursorrules file based on Farnsworth's memory.
This allows Farnsworth to "teach" Cursor about the project.
"""
rules = f"""# Farnsworth Generated Rules
# Project Context:
{project_context}
# Style Guide:
- Use Type Hints
- Follow Google Style Guide
- Use Rich for CLI output
# Architecture:
- Framework: Farnsworth
- State: Nexus Event Bus
"""
with open(".cursorrules", "w") as f:
f.write(rules)
logger.info("Generated .cursorrules based on project memory.")
cursor_bridge = CursorBridge()