Documentation
¶
Overview ¶
Package cursor adapts graphmaster to the Cursor editor's agent.
Cursor specifics this adapter encodes:
- Hooks live in ~/.cursor/hooks.json ({"version":1,"hooks":{...}}) and use camelCase native event names (sessionStart, preToolUse, beforeShellExecution, afterFileEdit, ...). Every hook invokes `<bin> hook <canonical-event> --agent cursor`; the native event name travels in the payload's hook_event_name.
- Gating hooks answer {"permission","user_message","agent_message"}. Cursor cannot attach context to an allowed tool call, so context-only decisions degrade to a plain allow/no-op. sessionStart is fire-and-forget: it may add context but never blocks.
- MCP servers are registered in ~/.cursor/mcp.json.
- Cursor has no documented global instruction file (User Rules live in its settings database). The instruction block is written to ~/.cursor/rules/graphmaster.mdc only when ~/.cursor/rules already exists; otherwise the MCP server's own instructions carry the guidance and Notes tells the user how to pin it as a User Rule.
- Cursor also executes Claude Code hooks from ~/.claude/settings.json. IsCursorPayload lets the dispatcher recognize those duplicate calls.
Index ¶
- func IsCursorPayload(payload []byte) bool
- type Adapter
- func (Adapter) Detect(env install.Env) bool
- func (Adapter) InstallPlan(env install.Env, opts adapters.InstallOptions) (install.Plan, error)
- func (Adapter) Name() hookapi.Agent
- func (Adapter) Notes(env install.Env) []string
- func (Adapter) ParseEvent(event hookapi.Event, payload []byte, env []string) (hookapi.HookEvent, error)
- func (Adapter) RenderDecision(ev hookapi.HookEvent, d hookapi.Decision) adapters.HookOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCursorPayload ¶
IsCursorPayload reports whether a hook payload was produced by Cursor, including when Cursor runs Claude Code hooks from ~/.claude/settings.json. The dispatcher uses it to answer such duplicate invocations only once.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements adapters.Agent for Cursor.
func (Adapter) InstallPlan ¶
InstallPlan registers the MCP server, the hooks and (when Cursor's rules directory exists) the instruction block.
func (Adapter) ParseEvent ¶
func (Adapter) ParseEvent(event hookapi.Event, payload []byte, env []string) (hookapi.HookEvent, error)
ParseEvent converts a Cursor hook payload into a neutral event. The payload's hook_event_name decides the shape; event (the CLI argument) is the fallback when the name is missing or unknown.
func (Adapter) RenderDecision ¶
RenderDecision writes d in Cursor's wire format. The exit code is always 0: blocking is expressed only through "permission":"deny", so a no-op or allow can never block, and hooks that cannot block (sessionStart, after-hooks) ignore deny entirely.