Skip to content

feat: add Cursor CLI as AI provider#159

Open
elo-mate wants to merge 1 commit intoTinyAGI:mainfrom
elo-mate:cursor-cli-provider
Open

feat: add Cursor CLI as AI provider#159
elo-mate wants to merge 1 commit intoTinyAGI:mainfrom
elo-mate:cursor-cli-provider

Conversation

@elo-mate
Copy link

@elo-mate elo-mate commented Mar 3, 2026

Summary

Adds the Cursor CLI (agent) as a fourth AI provider, alongside Anthropic (Claude), OpenAI (Codex), and OpenCode.

This lets users leverage their existing Cursor subscription within TinyClaw — useful for teams that already have Cursor Pro/Business seats and want to use them for autonomous agent workflows.

What's included

  • TypeScript integration (src/lib/):

    • types.tsCURSOR_MODEL_IDS mapping and cursor settings type
    • config.tsresolveCursorModel() resolver and auto-detect for cursor provider
    • invoke.ts — Full provider branch: JSON output parsing, --continue session support, --force for non-interactive mode, graceful fallback when no previous session exists
    • agent.ts — Copies AGENTS.md as .cursor/rules/agents.mdc so Cursor agents get the same context as Claude agents, with teammate info kept in sync
  • Shell scripts:

    • tinyclaw.shprovider cursor command for global switching, model display
    • lib/agents.sh — Cursor option in agent add and agent provider menus
    • lib/setup-wizard.sh — Cursor in initial setup and additional agent flows

How it works

The Cursor CLI's non-interactive mode (agent -p "prompt" --output-format json --force) returns a single JSON object with a .result field. The integration:

  1. Resolves model IDs via CURSOR_MODEL_IDS (supports shorthand like sonnet, opus, auto)
  2. Builds args with --model, --workspace, and optionally --continue
  3. Parses the JSON output, falling back to raw text if parsing fails
  4. Handles the "No previous chats found" error by retrying without --continue

Prerequisites

Users need the Cursor CLI installed and authenticated:

curl https://cursor.com/install -fsS | bash
agent login  # or set CURSOR_API_KEY

Test plan

  • TypeScript compiles cleanly (npx tsc --noEmit)
  • tinyclaw setup — select Cursor as provider, verify settings.json
  • tinyclaw agent add — create a Cursor agent, verify provider/model
  • tinyclaw agent provider <id> cursor --model auto — switch existing agent
  • Send a message to a Cursor agent and verify response parsing
  • Verify .cursor/rules/agents.mdc is created in agent workspace
  • Verify --continue works for subsequent messages (session persistence)

Made with Cursor

Add support for the Cursor CLI (`agent`) as a fourth AI provider alongside
Anthropic (Claude), OpenAI (Codex), and OpenCode.

Changes:
- src/lib/types.ts: Add CURSOR_MODEL_IDS mapping and cursor settings type
- src/lib/config.ts: Add resolveCursorModel(), auto-detect cursor provider
- src/lib/invoke.ts: Add cursor provider branch with JSON output parsing,
  --continue session support, and fallback for first-run
- src/lib/agent.ts: Copy AGENTS.md as .cursor/rules/agents.mdc and keep
  teammate info in sync for Cursor workspaces
- tinyclaw.sh: Add cursor case to provider/model display and switching
- lib/agents.sh: Add Cursor to agent add/provider menus with model selection
- lib/setup-wizard.sh: Add Cursor to initial setup and additional agent flows

The Cursor CLI requires installation (`curl https://cursor.com/install -fsS | bash`)
and authentication (`agent login` or CURSOR_API_KEY env var).

Made-with: Cursor
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