Skip to content

feat: add Cursor Agent CLI as new agent provider (Phase 1)#77

Open
cloud1305 wants to merge 3 commits intoDeadWaveWave:mainfrom
cloud1305:feat/cursor-agent-support
Open

feat: add Cursor Agent CLI as new agent provider (Phase 1)#77
cloud1305 wants to merge 3 commits intoDeadWaveWave:mainfrom
cloud1305:feat/cursor-agent-support

Conversation

@cloud1305
Copy link
Copy Markdown

@cloud1305 cloud1305 commented Mar 24, 2026

Summary

Add cursor-agent as the 5th agent provider in OpenCove, integrating the official Cursor Agent CLI (agent command) via PTY-based terminal sessions. This is Phase 1 (PTY-only) of the proposal documented in docs/proposals/cursor-agent-support.md.

Motivation

  • User value: Cursor is one of the most popular AI-native IDEs. Its standalone CLI Agent allows OpenCove users to orchestrate Cursor Agent directly from the canvas workspace.
  • Architecture fit: Cursor's ACP (Agent Client Protocol) aligns well with OpenCove's TerminalSessionState model. Phase 1 uses PTY-only; Phase 2 will leverage ACP for structured state observation.
  • Model ecosystem: Cursor Agent aggregates models from multiple providers, accessible via agent models.

Changes

Phase 1 scope (this PR)

Subsystem Files Description
Type registration agent.ts, agentSettings.ts, providerMeta.ts Add cursor-agent to AgentProviderId, AGENT_PROVIDERS, provider metadata (label, capabilities)
IPC validation normalize.ts Add cursor-agent to the provider whitelist
CLI detection AgentCliAvailability.ts Two-step detection: which agent + agent --help fingerprint (contains "cursor")
Command factory AgentCommandFactory.ts Build CLI args: --yolo, --model, --resume, --continue, prompt
Model service AgentModelService.ts Parse agent models output (id - DisplayName (current) format), ANSI cleanup, cache with TTL, auto-resolve current model for title display
Session stubs SessionFileResolver.ts, SessionTurnStateDetector.ts, SessionLastAssistantMessage.extractors.ts, AgentSessionLocator.ts Explicit null returns to prevent fallthrough into gemini/codex default branches
UI helpers helpers.ts Add cursor-agent to providerTitlePrefix
IPC launch register.ts Auto-resolve default model display name when no model specified

Proposal document

docs/proposals/cursor-agent-support.md — comprehensive design document covering feasibility analysis, architecture, state ownership table, invariants, phased execution plan, risk analysis, and acceptance criteria.

Key design decisions

Decision Choice Rationale
Provider ID cursor-agent (not cursor) Avoid conflict with existing Cursor IDE opener semantics
runtimeObservation none (Phase 1) PTY-only for fast validation; ACP bridge deferred to Phase 2
CLI detection --help fingerprint agent --version output doesn't contain "cursor"; --help output does ("Start the Cursor Agent")
experimental flag true New provider needs opt-in validation before promotion
Default model display Auto-resolve from agent models Query (current) model to show actual model name instead of "default model"

Test coverage

  • Unit tests: 15+ new test cases across 7 spec files covering command factory, model service, session locator, file resolver, state detector, last message extractor, and settings normalization
  • All 421 unit tests pass, 122 test files
  • E2E: 166/176 passed, 9 skipped (platform-specific), 1 pre-existing flaky test (minimap hover opacity — unrelated to this PR)

Verification

  • pnpm pre-commit: lint ✅, format ✅, type-check ✅, unit tests ✅, E2E ✅ (1 pre-existing flaky failure)
  • Manual testing: settings panel shows "Cursor Agent (Experimental)", model list displays correctly, PTY session launches and interacts successfully, window title shows actual current model name

Invariants maintained

  1. All CLI command assembly goes through AgentCommandFactory.buildAgentLaunchCommand — no hardcoded args elsewhere
  2. CLI detection requires two-step verification — which agent alone is insufficient
  3. All session/watcher paths explicitly short-circuit to null — no accidental fallthrough into other providers' logic
  4. TerminalSessionState push path (ptyState IPC channel) remains consistent across all providers
  5. normalizeAgentSettings correctly handles old data without cursor-agent keys via AGENT_PROVIDERS.reduce

Phase 2 roadmap (not in this PR)

  • ACP Bridge (agent acp + JSON-RPC client) for structured state observation
  • session/updateworking/standby mapping
  • session/request_permission → UI approval dialog
  • Remove experimental flag

shihao1 added 3 commits March 25, 2026 11:15
Add a comprehensive proposal document for integrating Cursor Agent CLI
as a new agent provider in OpenCove, leveraging the official ACP
(Agent Client Protocol) for structured session management.

Made-with: Cursor
Register cursor-agent across all provider-aware subsystems:
- Type registration: AgentProviderId, AgentModelCatalogSource, AGENT_PROVIDERS
- Provider metadata: label, capabilities (runtimeObservation: none, experimental)
- CLI availability: two-step detection (which + version fingerprint)
- Command factory: --yolo, --model, --resume, --continue, prompt args
- Model service: parse `agent models` output with cache and fallback
- Session/Watcher stubs: explicit null returns to prevent fallthrough
  into gemini/codex default branches

Made-with: Cursor
- Add cursor-agent to IPC provider whitelist (normalizeProvider)
- Fix CLI detection: use --help instead of --version for fingerprint
- Parse agent models output format (id - DisplayName with ANSI codes)
- Auto-resolve current model display name when no model specified
- Fix provider title prefix fallthrough to codex

Made-with: Cursor
@cloud1305 cloud1305 force-pushed the feat/cursor-agent-support branch from d0715d1 to 4edf8cc Compare March 25, 2026 03:15
@cloud1305 cloud1305 changed the title feat: Cursor Agent CLI provider support proposal feat: add Cursor Agent CLI as new agent provider (Phase 1) Mar 25, 2026
@DeadWaveWave
Copy link
Copy Markdown
Owner

建议在本 PR 完成 Phase 2 的内容,并提供正确运行时的截图验证后再尝试提交

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