Skip to content

feat(agents): add cursor adapter#126

Closed
yyovil wants to merge 2 commits into
agents/06-aiderfrom
agents/07-cursor
Closed

feat(agents): add cursor adapter#126
yyovil wants to merge 2 commits into
agents/06-aiderfrom
agents/07-cursor

Conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

Adds the cursor agent adapter, stacking on the existing agent-platform infrastructure. The adapter follows the established pattern of codex and opencode adapters: a Plugin struct wiring up GetLaunchCommand, GetRestoreCommand, SessionInfo, and hook management (GetAgentHooks / UninstallHooks / AreHooksInstalled), all backed by atomic file writes via the shared hookutil package.

  • cursor.go: Resolves the cursor-agent binary (with PATH + well-known locations fallback), builds launch/restore argv with --, --force, and --yolo permission flags, and caches binary resolution behind a mutex.
  • hooks.go: Installs/removes five Cursor native-event hooks into .cursor/hooks.json, preserving unmanaged keys and user-defined entries using the raw-JSON round-trip strategy.
  • activity.go + dispatch.go: Maps the four AO sub-command names to Active, Idle, and WaitingInput activity states and registers the deriver in the dispatch table.

Confidence Score: 5/5

Safe to merge; the cursor adapter is a well-contained addition that follows the established codex/opencode pattern with no changes to shared infrastructure.

All new code is isolated to the cursor package and its two registration call-sites. The hook management, binary resolution, and argv construction are well-tested and structurally identical to the already-shipped codex adapter. No shared logic was modified.

No files require special attention.

Important Files Changed

Filename Overview
backend/internal/adapters/agent/cursor/cursor.go Core adapter: binary resolution, argv construction (with -- sentinel), session info, and mutex-guarded binary caching. Well-structured, mirrors codex pattern.
backend/internal/adapters/agent/cursor/hooks.go Hook install/uninstall/check using raw-JSON round-trip to preserve unmanaged keys. Now uses shared hookutil.AtomicWriteFile instead of a local copy.
backend/internal/adapters/agent/cursor/activity.go Simple switch mapping four AO sub-command names to activity states; clean and well-tested.
backend/internal/adapters/agent/cursor/cursor_test.go Comprehensive table-driven tests covering argv construction, permission modes, restore/session-info edge cases, hook install/uninstall idempotency, and context cancellation.
backend/internal/adapters/agent/activitydispatch/dispatch.go Adds "cursor": cursor.DeriveActivityState to the Derivers map; one-line, mechanical change.
backend/internal/adapters/agent/registry/registry.go Adds cursor.New() to Constructors(); one-line, mechanical change.
backend/internal/daemon/wiring_test.go Adds {domain.HarnessCursor, "cursor"} to the resolver test table; mechanical, expected change.
backend/internal/adapters/agent/cursor/activity_test.go Covers all four mapped events plus unknown/native-name cases; confirms the beforeShellExecution native name is correctly unmapped.

Sequence Diagram

sequenceDiagram
    participant AO as AO Daemon
    participant P as cursor.Plugin
    participant FS as .cursor/hooks.json
    participant CA as cursor-agent

    AO->>P: GetAgentHooks(cfg)
    P->>FS: readCursorHooks (preserve existing)
    P->>FS: atomicWriteFile (merge AO hook commands)

    AO->>P: GetLaunchCommand(LaunchConfig)
    P->>P: cursorBinary() [resolve + cache]
    P-->>AO: ["cursor-agent", "-p", "--output-format", "stream-json", "--trust", "--", prompt]

    AO->>CA: exec argv
    CA-->>FS: fires sessionStart hook
    CA-->>AO: activity: Active

    CA-->>FS: fires beforeShellExecution hook
    CA-->>AO: activity: WaitingInput

    CA-->>FS: fires stop hook
    CA-->>AO: activity: Idle

    AO->>P: GetRestoreCommand(RestoreConfig)
    P-->>AO: ["cursor-agent", "-p", ..., "--resume", agentSessionID]

    AO->>P: UninstallHooks(workspacePath)
    P->>FS: readCursorHooks
    P->>FS: atomicWriteFile (remove AO commands, keep user hooks)
Loading

Reviews (2): Last reviewed commit: "feat(agents): add cursor adapter" | Re-trigger Greptile

Comment thread backend/internal/adapters/agent/cursor/cursor.go
Comment thread backend/internal/adapters/agent/cursor/hooks.go Outdated
Registers the cursor harness, stacked on the agent platform. Includes its own activity deriver.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yyovil yyovil force-pushed the agents/06-aider branch from 0172665 to e37fef8 Compare June 6, 2026 03:31
@yyovil yyovil force-pushed the agents/07-cursor branch from 7bdeb48 to 8eadf7d Compare June 6, 2026 03:31
@harshitsinghbhandari harshitsinghbhandari added this to the rewrite milestone Jun 6, 2026
Registers the qwen harness, stacked on the agent platform. Includes its own activity deriver.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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.

2 participants