Documentation
¶
Overview ¶
Package cursor adapts the Cursor agent CLI (`cursor-agent`, also installed as `agent`) to codexmon's agent contract. A headless review runs `cursor-agent -p "<prompt>"`; codexmon adds `--output-format stream-json`, defaults `--model composer-2.5` (unless the caller picked a model), and parses the newline-delimited event stream:
{"type":"system","subtype":"init","session_id":"...","model":"...","cwd":"..."}
{"type":"user","message":{"role":"user","content":[{"type":"text","text":"..."}]}}
{"type":"tool_call","subtype":"started","call_id":"t1","tool_call":{"readToolCall":{"args":{"path":"a.ts"}}}}
{"type":"tool_call","subtype":"completed","call_id":"t1","tool_call":{"readToolCall":{"args":{...},"result":{...}}}}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Findings: ..."}]}}
{"type":"result","subtype":"success","is_error":false,"result":"Findings: ...","duration_ms":1234}
Cursor exposes no `--output-last-message`-style flag and reports no token usage, so the final answer comes from the `result` event's `result` field (the streamed assistant text is a progressive fallback) and Usage is left nil.
Index ¶
- type Provider
- func (Provider) Analyze(args []string, _ string, allowJSON bool) agent.Analysis
- func (Provider) BinCandidates() []string
- func (Provider) BinEnv() string
- func (Provider) Doctor(bin string, run agent.RunFunc) agent.DoctorReport
- func (Provider) Name() string
- func (Provider) ParseLine(line string) (agent.Event, bool)
- func (Provider) ReviewArgs(spec agent.ReviewSpec) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct{}
Provider drives the Cursor agent CLI.
func (Provider) Analyze ¶
Analyze adds the streaming-JSON flag for a headless (`-p`) run so codexmon can monitor the event stream, unless the caller already chose an output format. It also defaults --model to Composer 2.5 unless the caller specified a model.
Everything at or after Cursor's `--` terminator is prompt text, not options (callers need it for prompts that start with `-`). So injected flags go before the terminator, and existing-flag detection scans only the real options — a literal `--model` sitting inside the prompt must not suppress the default.
func (Provider) BinCandidates ¶
BinCandidates resolves only the unambiguous "cursor-agent" name, which the Cursor installer always provides. The generic "agent" name the installer also drops is intentionally not a fallback — it collides too easily with unrelated binaries on PATH; for a nonstandard install set CODEXMON_CURSOR or --agent-bin.
func (Provider) Doctor ¶
Doctor checks the install with `--version` and authentication with `cursor-agent status`, which reports the logged-in account / API-key state.
func (Provider) ReviewArgs ¶
func (Provider) ReviewArgs(spec agent.ReviewSpec) ([]string, error)
ReviewArgs runs a headless review with a constructed read-only prompt. Print mode (`-p`) is non-interactive, so no approval prompt can stall the run.