Skip to content

BOFA1ex/cursorCodePlugin

Repository files navigation

CursorCode JetBrains Plugin

A JetBrains IDE plugin that provides seamless integration with Cursor CLI functionality, inspired by the Claude Code plugin architecture but specifically designed for Cursor CLI integration.

Features

🔍 Diff Viewing

  • Open file diffs in the IDE's native diff viewer
  • Review and modify proposed changes from Cursor CLI
  • Syntax highlighting and side-by-side comparison

✂️ Selection Context Sharing

  • Automatically shares the current IDE selection with Cursor CLI
  • Real-time synchronization of cursor position and selected text
  • Provides context-aware assistance from Cursor

📎 File Reference Shortcuts

  • Shortcut: Ctrl+Alt+K (Windows/Linux) or Cmd+Option+K (Mac)
  • Insert file references in format: @File#L1-99
  • Interactive file selector with line range specification
  • Relative path resolution from project root

🔧 Diagnostics Sharing

  • Real-time sharing of IDE diagnostics (errors, warnings)
  • Automatic detection and transmission of squiggly underlines
  • Integration with IDE's code analysis system

Architecture

Core Components

CursorService

  • Main service class managing the plugin lifecycle
  • Handles IDE event listeners (selection, file changes, diagnostics)
  • Coordinates communication with Cursor CLI via MCP

MCPClient

  • Model Context Protocol (MCP) client for communication with Cursor CLI
  • Handles JSON-RPC 2.0 protocol implementation
  • Supports both HTTP and stdio transport methods
  • Asynchronous request/response handling

Actions

  • CursorDiffAction: Triggers diff viewer for Cursor changes
  • FileReferenceAction: Inserts file references with keyboard shortcut

Communication Protocol

The plugin uses the Model Context Protocol (MCP) to communicate with Cursor CLI:

  • Initialization: Establishes connection and capability exchange
  • Selection Updates: Notifies Cursor of current IDE selection
  • Diagnostics Updates: Shares IDE errors/warnings with Cursor
  • Diff Requests: Requests code changes from Cursor CLI

Setup and Installation

Prerequisites

  • JetBrains IDE (IntelliJ IDEA, PyCharm, WebStorm, etc.)
  • Cursor CLI installed and running
  • Java 17 or later

Building the Plugin

# Clone and build
git clone <repository-url>
cd CursorCode
./gradlew build

# The plugin JAR will be generated in build/distributions/

Installation

  1. Build the plugin using Gradle
  2. Go to IDE Settings → Plugins → Install Plugin from Disk
  3. Select the generated JAR file
  4. Restart the IDE

Configuration

  1. Ensure Cursor CLI is running with MCP server enabled
  2. Default MCP endpoint: http://localhost:3000/mcp
  3. The plugin will automatically attempt to connect on startup

Usage

Diff Viewing

  1. Right-click on a file in the editor or project tree
  2. Select "Open Cursor Diff Viewer"
  3. Review changes in the IDE's diff viewer

File References

  1. Position cursor where you want to insert a file reference
  2. Press Ctrl+Alt+K (or Cmd+Option+K on Mac)
  3. Select target file and specify line range
  4. Reference will be inserted in format: @filename.ext#L1-10

Selection Context

  • Simply select text in the editor
  • The plugin automatically shares selection with Cursor CLI
  • No manual action required

Diagnostics Sharing

  • IDE errors and warnings are automatically shared
  • Real-time updates as you type
  • No configuration needed

Technical Details

Dependencies

  • Kotlin 1.9.22
  • IntelliJ Platform SDK 2023.2.5
  • Gson 2.10.1 for JSON processing
  • Java HTTP Client for MCP communication

Supported IDEs

  • IntelliJ IDEA Community/Ultimate
  • PyCharm Professional/Community
  • WebStorm
  • PhpStorm
  • GoLand
  • Android Studio
  • Other JetBrains IDEs

MCP Protocol Support

  • JSON-RPC 2.0 compliant
  • Supports notifications and requests
  • Error handling and timeout management
  • Asynchronous operations

Development

Project Structure

src/main/kotlin/com/maplebreak/cursorcode/
├── CursorService.kt          # Main plugin service
├── MCPClient.kt             # MCP protocol client
├── CursorDiffAction.kt      # Diff viewer action
├── FileReferenceAction.kt   # File reference shortcuts
└── Data classes for selection context and diagnostics

Key Extension Points

  • Project Service for lifecycle management
  • Actions for user interactions
  • Event listeners for IDE state changes

Troubleshooting

Connection Issues

  • Verify Cursor CLI is running on port 3000
  • Check MCP server is enabled in Cursor configuration
  • Review IDE logs for connection errors

Shortcut Conflicts

  • Check for conflicting key mappings in IDE settings
  • Customize shortcuts in Keymap preferences if needed

Performance

  • Plugin uses asynchronous communication to avoid blocking
  • Minimal performance impact on IDE operations

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement changes following the existing architecture
  4. Add tests if applicable
  5. Submit a pull request

License

[Specify your license here]

Support

For issues and feature requests, please use the GitHub issue tracker.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages