Skip to main content

Module cursor

Module cursor 

Source
Expand description

Cursor hook adapter.

Cursor IDE invokes hooks with a JSON object on stdin whose shape differs from Claude Code’s in three important ways:

  1. The event discriminator is hook_event_name with camelCase values (afterFileEdit, afterShellExecution, …) rather than Claude’s PostToolUse naming.
  2. Cursor exposes a workspace_roots array instead of a single cwd string. We use workspace_roots[0] as the effective CWD.
  3. Shell-command events come as command/output pairs rather than tool_input/tool_response. We synthesise a Bash-shaped tool call from those so the downstream rule retriever sees a uniform PostToolUse shape regardless of origin.

Example stdin (from claude-mem’s cursor adapter reference):

{
  "conversation_id": "...",
  "workspace_roots": ["/path/to/repo"],
  "hook_event_name": "afterFileEdit",
  "tool_name": "Edit",
  "tool_input": { "file_path": "src/foo.rs", "edits": [...] },
  "result_json": { ... }
}

Cursor’s output expectation is minimal — it honours a single { "continue": true|false } flag. For advisory context we include a context string alongside so Cursor’s newer builds can surface it; older Cursor builds just ignore the extra field.

Structs§

CursorAdapter
Zero-sized marker — no adapter-local state.