cursor

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 5 Imported by: 0

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

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

func (Provider) Analyze(args []string, _ string, allowJSON bool) agent.Analysis

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

func (Provider) BinCandidates() []string

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) BinEnv

func (Provider) BinEnv() string

func (Provider) Doctor

func (Provider) Doctor(bin string, run agent.RunFunc) agent.DoctorReport

Doctor checks the install with `--version` and authentication with `cursor-agent status`, which reports the logged-in account / API-key state.

func (Provider) Name

func (Provider) Name() string

func (Provider) ParseLine

func (Provider) ParseLine(line string) (agent.Event, bool)

ParseLine normalizes one Cursor stream-json line into an agent.Event.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL