diff --git a/cursor-rules-cli/src/installer.py b/cursor-rules-cli/src/installer.py index afbb289..381f751 100644 --- a/cursor-rules-cli/src/installer.py +++ b/cursor-rules-cli/src/installer.py @@ -1,7 +1,7 @@ """ Installer module for installing MDC rule files. -This module handles installing the downloaded MDC rule files to the user's +This module handles installing the downloaded MDC rule files to the project's .cursor/rules directory. """ @@ -21,12 +21,12 @@ def install_rules( backup: bool = True, ) -> Dict[str, List]: """ - Install downloaded MDC rule files to the .cursor/rules directory. + Install downloaded MDC rule files to the project's .cursor/rules directory. Args: rules: List of rule metadata with local file paths force: Whether to overwrite existing rules - cursor_dir: Path to .cursor directory (defaults to ~/.cursor) + cursor_dir: Path to .cursor directory (defaults to ./.cursor in current directory) backup: Whether to backup existing rules Returns: @@ -41,9 +41,9 @@ def install_rules( logger.warning("No rules to install") return result - # Determine .cursor directory + # Determine .cursor directory - use project local directory if cursor_dir is None: - cursor_dir = Path.home() / ".cursor" + cursor_dir = Path.cwd() / ".cursor" # Create rules directory if it doesn't exist rules_dir = cursor_dir / "rules" @@ -99,7 +99,7 @@ def install_rules( def create_backup(rules_dir: Path) -> Optional[Path]: """ - Create a backup of existing rules. + Create a backup of existing rules in the project directory. Args: rules_dir: Path to .cursor/rules directory @@ -108,7 +108,8 @@ def create_backup(rules_dir: Path) -> Optional[Path]: Path to backup directory or None if failed """ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - backup_dir = rules_dir.parent / f"rules_backup_{timestamp}" + # Keep backups in the project directory under .cursor/backups + backup_dir = rules_dir.parent / "backups" / f"rules_backup_{timestamp}" try: # Create backup directory @@ -128,14 +129,14 @@ def list_installed_rules(cursor_dir: Optional[Path] = None) -> List[Dict[str, An List installed MDC rule files. Args: - cursor_dir: Path to .cursor directory (defaults to ~/.cursor) + cursor_dir: Path to .cursor directory (defaults to ./.cursor in current directory) Returns: List of installed rule metadata """ - # Determine .cursor directory + # Determine .cursor directory - use project local directory if cursor_dir is None: - cursor_dir = Path.home() / ".cursor" + cursor_dir = Path.cwd() / ".cursor" rules_dir = cursor_dir / "rules" diff --git a/cursor-rules-cli/src/utils.py b/cursor-rules-cli/src/utils.py index 67ac066..61b7b96 100644 --- a/cursor-rules-cli/src/utils.py +++ b/cursor-rules-cli/src/utils.py @@ -66,19 +66,19 @@ def calculate_content_hash(content: str) -> str: def get_cursor_dir() -> Path: """ - Get the path to the .cursor directory. + Get the path to the project's .cursor directory. Returns: - Path to the .cursor directory + Path to the project's .cursor directory """ - return Path.home() / ".cursor" + return Path.cwd() / ".cursor" def get_rules_dir() -> Path: """ - Get the path to the .cursor/rules directory. + Get the path to the project's .cursor/rules directory. Returns: - Path to the .cursor/rules directory + Path to the project's .cursor/rules directory """ return get_cursor_dir() / "rules" @@ -87,7 +87,7 @@ def get_config_file() -> Path: Get the path to the configuration file. Returns: - Path to the configuration file + Path to the configuration file in the project's .cursor directory """ return get_cursor_dir() / "rules-cli-config.json"