Help us shape the future of Go! Take the 2026 Go Developer Survey

cursor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCursorPayload

func IsCursorPayload(payload []byte) bool

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

func (Adapter) Detect(env install.Env) bool

Detect reports whether ~/.cursor exists or a cursor binary is on PATH.

func (Adapter) InstallPlan

func (Adapter) InstallPlan(env install.Env, opts adapters.InstallOptions) (install.Plan, error)

InstallPlan registers the MCP server, the hooks and (when Cursor's rules directory exists) the instruction block.

func (Adapter) Name

func (Adapter) Name() hookapi.Agent

Name returns the --agent identifier.

func (Adapter) Notes

func (Adapter) Notes(env install.Env) []string

Notes returns post-install reminders.

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.

Jump to

Keyboard shortcuts

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