Add Cursor IDE support to interactive installer#51
Open
mschreib28 wants to merge 11 commits into
Open
Conversation
## Summary Added parallel installation support for Cursor IDE alongside Claude Code, allowing users to configure CodeGraph MCP tools for either or both IDEs. ## Key Changes ### IDE Selection - Refactored to checkbox-style selection (comma-separated numbers) - Changed type from `IDE = 'claude' | 'cursor' | 'both'` to `IDE = IDEName[]` - Easy to extend with additional IDEs (VSCode, Zed, etc.) ### Cursor-Specific Implementation - Creates `.cursor/mcp.json` for MCP server configuration - Creates `.cursor/rules/codegraph.md` for AI assistant instructions - Only supports local installation (no global config) ### Architecture Improvements - Separated templates into `src/installer/templates/` directory - `claude-code.ts`: Claude Code template with section markers - `cursor.ts`: Cursor standalone template (no markers needed) - IDE-specific config functions: `hasClaudeMcpConfig()` / `hasCursorMcpConfig()` - Separated install functions: `installForClaude()` / `installForCursor()` ### Files Created - `src/installer/templates/claude-code.ts` - `src/installer/templates/cursor.ts` ### Files Modified - `src/installer/prompts.ts`: Multi-select IDE picker - `src/installer/config-writer.ts`: Cursor config writers - `src/installer/index.ts`: Parallel install orchestration - `src/installer/banner.ts`: Multi-IDE messaging ## Installation Flow 1. User selects IDE(s): `1` (Claude), `2` (Cursor), or `1,2` (both) 2. Choose location: Global or local (Cursor forces local) 3. Configure selected IDEs in parallel 4. Index project if local install 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
## Changes - Detects installed IDEs by checking for config directories - Claude Code: `~/.claude` or `./.claude` - Cursor: `./.cursor` - Shows "✓ Detected" indicator next to installed IDEs - Pre-selects detected IDEs as defaults - Improves UX by automatically suggesting correct configuration ## Example Output ``` Which IDE(s) would you like to configure? (Enter comma-separated numbers, e.g., "1,2" for both) 1) Claude Code ✓ Detected 2) Cursor ✓ Detected Selection [1,2]: ``` ## Benefits - Smarter defaults based on actual installation - Reduces user confusion - Automatically suggests "both" when both IDEs detected - Fallback to Claude Code if nothing detected 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add InstallerTestHelper class for e2e test utilities - Test Claude Code global/local installation - Test Cursor local installation - Test both IDEs installed together - Test update scenarios for both IDEs - Test IDE detection (fresh, after install, independent detection) - Test permissions and hooks for Claude Code - All 20 tests passing (8 existing + 12 new e2e tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add --ide flag to 'install' command for non-interactive installation - Support comma-separated IDE list: --ide=claude,cursor - Support 'all' keyword: --ide=all (installs both IDEs) - Add InstallerOptions interface for programmatic usage - Add parseIDEArg() to validate and parse IDE arguments - Add 4 new tests for non-interactive mode (24 total tests passing) - Update CLI help text with examples Usage examples: codegraph install --ide=claude codegraph install --ide=cursor codegraph install --ide=claude,cursor codegraph install --ide=all 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add --location flag to specify global or local installation - Add validateLocation() to validate location argument - Skip location prompt when --location is provided - Add 4 new tests for location flag (28 total tests passing) - Update CLI help text with location examples Usage examples: codegraph install --ide=claude --location=global codegraph install --ide=claude --location=local codegraph install --ide=all --location=local codegraph install --ide=cursor # Cursor is always local 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changes: - Default installation location changed from global to local - Add isInteractive() to detect TTY (stdin.isTTY && stdout.isTTY) - Non-interactive shells use sensible defaults: - IDE: detected IDEs or 'claude' if none detected - Location: always 'local' - Swap order in prompt: Local (1) is now default, Global (2) - All 28 tests passing Benefits: - Works in CI/CD pipelines without hanging - Works in scripts and automation - Safer default (local doesn't affect other projects) - Explicit --ide and --location flags still override defaults 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add DEFAULT_IDE and DEFAULT_LOCATION constants in prompts.ts - Replace hardcoded 'claude' and 'local' with constants - Makes it easy to change defaults in one place - All 28 tests passing To change defaults in the future, just update: export const DEFAULT_IDE: IDEName = 'claude'; export const DEFAULT_LOCATION: InstallLocation = 'local'; 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update tagline to mention both Claude Code and Cursor - Add IDE selection to installer flow description - Document non-interactive mode with --ide and --location flags - Add note about Cursor Agent mode vs Composer - Update MCP configuration examples to include Cursor - Add examples for all installation combinations - Document TTY auto-detection behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Exports parseIDEArg and validateLocation for direct testability, then adds coverage for isInteractive(), promptIDE/promptInstallLocation non-interactive paths, and all edge cases for IDE/location arg parsing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n\nAdds parallel Cursor IDE support to the interactive installer alongside existing Claude Code support, with non-interactive CLI mode and improved defaults.\n\nKey Features:\n- ✅ Multi-IDE selection with checkbox-style input (comma-separated numbers:
1,2)\n- ✅ Automatic detection of installed IDEs (shows "✓ Detected" indicators)\n- ✅ Pre-selects detected IDEs for user convenience\n- ✅ Parallel installation for both Claude Code and Cursor\n- ✅ Proper Cursor configuration format (.cursor/mcp.jsonand.cursor/rules/codegraph.md)\n- ✅ Non-interactive mode via--ideand--locationflags (CI/scripting)\n- ✅ Defaults to local installation; gracefully handles non-interactive shells\n\nArchitecture:\n- Separated templates intosrc/installer/templates/directory\n -claude-code.ts- Template with section markers for shared CLAUDE.md\n -cursor.ts- Standalone template for dedicated.cursor/rules/codegraph.md\n- IDE-specific config writers insrc/installer/config-writer.ts\n- Auto-detection logic insrc/installer/prompts.ts\n-isInteractive()guard prevents readline hang in non-TTY environments\n\nNon-Interactive Usage:\nbash\ncodegraph install --ide=claude --location=local\ncodegraph install --ide=cursor\ncodegraph install --ide=all --location=local\ncodegraph install --ide=claude,cursor --location=global\n\n\nTesting:\n- ✅ 53 tests total — all passing\n- ✅ Tests all IDE combinations: Claude only (global/local), Cursor only, both together\n- ✅ Tests detection scenarios, update scenarios, permissions, and hooks\n- ✅isInteractive()— all TTY combinations\n- ✅promptIDE()non-interactive path — no IDEs, each IDE, both detected\n- ✅promptInstallLocation()non-interactive path — all IDE combinations\n- ✅parseIDEArg()— valid values, case-insensitivity, whitespace, invalid throws, mixed lists\n- ✅validateLocation()— valid values, case-insensitivity, undefined passthrough, invalid throws\n\nFiles Modified:\n-src/installer/templates/claude-code.ts(new)\n-src/installer/templates/cursor.ts(new)\n-src/installer/prompts.ts- Added IDE selection, auto-detection, andisInteractive()\n-src/installer/config-writer.ts- Added Cursor writers, renamedhasMcpConfig→hasClaudeMcpConfig\n-src/installer/index.ts- Parallel installation logic, non-interactive arg parsing\n-src/installer/banner.ts- Updated for multiple IDEs\n-src/bin/codegraph.ts- Added--ideand--locationflags toinstallcommand\n-__tests__/installer.test.ts- Comprehensive test suite\n\nConfiguration Differences:\n\n| Aspect | Claude Code | Cursor |\n|--------|------------|--------|\n| MCP Config |.claude.jsonor~/.claude.json|.cursor/mcp.json(local only) |\n| Instructions |.claude/CLAUDE.md(shared, uses markers) |.cursor/rules/codegraph.md(dedicated) |\n| Permissions |.claude/settings.json| N/A (built-in) |\n| Hooks |.claude/settings.json| N/A |\n| Install Location | Global or Local | Local only |\n\n🤖 Generated with Claude CodeCopied from colbymchenry/codegraph#52