Skip to content

Add Cursor IDE support to interactive installer#52

Draft
matthewhembree wants to merge 11 commits intocolbymchenry:mainfrom
matthewhembree:feature/cursor-support
Draft

Add Cursor IDE support to interactive installer#52
matthewhembree wants to merge 11 commits intocolbymchenry:mainfrom
matthewhembree:feature/cursor-support

Conversation

@matthewhembree
Copy link
Copy Markdown

@matthewhembree matthewhembree commented Mar 6, 2026

Summary

Adds parallel Cursor IDE support to the interactive installer alongside existing Claude Code support, with non-interactive CLI mode and improved defaults.

Key Features:

  • ✅ Multi-IDE selection with checkbox-style input (comma-separated numbers: 1,2)
  • ✅ Automatic detection of installed IDEs (shows "✓ Detected" indicators)
  • ✅ Pre-selects detected IDEs for user convenience
  • ✅ Parallel installation for both Claude Code and Cursor
  • ✅ Proper Cursor configuration format (.cursor/mcp.json and .cursor/rules/codegraph.md)
  • ✅ Non-interactive mode via --ide and --location flags (CI/scripting)
  • ✅ Defaults to local installation; gracefully handles non-interactive shells

Architecture:

  • Separated templates into src/installer/templates/ directory
    • claude-code.ts - Template with section markers for shared CLAUDE.md
    • cursor.ts - Standalone template for dedicated .cursor/rules/codegraph.md
  • IDE-specific config writers in src/installer/config-writer.ts
  • Auto-detection logic in src/installer/prompts.ts
  • isInteractive() guard prevents readline hang in non-TTY environments

Non-Interactive Usage:

codegraph install --ide=claude --location=local
codegraph install --ide=cursor
codegraph install --ide=all --location=local
codegraph install --ide=claude,cursor --location=global

Testing:

  • ✅ 53 tests total — all passing
  • ✅ Tests all IDE combinations: Claude only (global/local), Cursor only, both together
  • ✅ Tests detection scenarios, update scenarios, permissions, and hooks
  • isInteractive() — all TTY combinations
  • promptIDE() non-interactive path — no IDEs, each IDE, both detected
  • promptInstallLocation() non-interactive path — all IDE combinations
  • parseIDEArg() — valid values, case-insensitivity, whitespace, invalid throws, mixed lists
  • validateLocation() — valid values, case-insensitivity, undefined passthrough, invalid throws

Files Modified:

  • src/installer/templates/claude-code.ts (new)
  • src/installer/templates/cursor.ts (new)
  • src/installer/prompts.ts - Added IDE selection, auto-detection, and isInteractive()
  • src/installer/config-writer.ts - Added Cursor writers, renamed hasMcpConfighasClaudeMcpConfig
  • src/installer/index.ts - Parallel installation logic, non-interactive arg parsing
  • src/installer/banner.ts - Updated for multiple IDEs
  • src/bin/codegraph.ts - Added --ide and --location flags to install command
  • __tests__/installer.test.ts - Comprehensive test suite

Configuration Differences:

Aspect Claude Code Cursor
MCP Config .claude.json or ~/.claude.json .cursor/mcp.json (local only)
Instructions .claude/CLAUDE.md (shared, uses markers) .cursor/rules/codegraph.md (dedicated)
Permissions .claude/settings.json N/A (built-in)
Hooks .claude/settings.json N/A
Install Location Global or Local Local only

🤖 Generated with Claude Code

matthewhembree and others added 11 commits March 5, 2026 18:12
## 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>
@matthewhembree matthewhembree force-pushed the feature/cursor-support branch from a3c6e0c to 1b3967d Compare March 6, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant