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:
- The event discriminator is
hook_event_namewith camelCase values (afterFileEdit,afterShellExecution, …) rather than Claude’sPostToolUsenaming. - Cursor exposes a
workspace_rootsarray instead of a singlecwdstring. We useworkspace_roots[0]as the effective CWD. - Shell-command events come as
command/outputpairs rather thantool_input/tool_response. We synthesise aBash-shaped tool call from those so the downstream rule retriever sees a uniformPostToolUseshape 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§
- Cursor
Adapter - Zero-sized marker — no adapter-local state.