Hook scripts for recording Morph sessions from Cursor lifecycle events. Canonical location: .cursor/ in your project (so the repo root stays Git-style: only .cursor/, .morph/, .git/). Run morph setup cursor to install them there.
Full setup guide: docs/CURSOR-SETUP.md
| File | Referenced by | Purpose |
|---|---|---|
morph-record-prompt.sh |
.cursor/hooks.json (beforeSubmitPrompt) |
Saves prompt + composer mode to .morph/hooks/pending-<conversation_id>.jsonl |
morph-record-response.sh |
.cursor/hooks.json (afterAgentResponse) |
Parses the agent transcript for structured events (tool calls, file reads/edits, shell commands), builds Run + Trace, calls morph session import |
morph-record-stop.sh |
.cursor/hooks.json (stop) |
Fallback: same structured parsing as response hook; fires if afterAgentResponse didn't |
The copies in this cursor/ directory mirror morph-cli/assets/cursor/hooks/ and are kept for reference when developing Morph.
When transcript_path is available in the Cursor payload (the JSONL file containing the full conversation), the hooks parse it to produce rich structured traces:
tool_useitems (e.g.Read,Grep,Glob) →file_readevents with tool name and pathtool_useitems (e.g.StrReplace,Write) →file_editevents with tool name and pathtool_useitems (e.g.Shell,Task,CallMcpTool) →tool_callevents with tool name and inputtool_resultitems →tool_resultevents- Text parts →
user/assistantevents - Token usage (
input_tokens,output_tokens,cache_read_tokens,cache_write_tokens) → stored inrun.environment.parameters
If transcript_path is unavailable or unreadable, the hooks fall back to pending prompts + response text.
| File | Purpose |
|---|---|
.cursor/hooks.json |
Tells Cursor to run the scripts above on lifecycle events |
.cursor/rules/morph-record.mdc |
Cursor rule for agent-driven recording via morph_record_session |
.cursor/mcp.json |
MCP server config (optional MORPH_WORKSPACE env) |
Hook scripts write diagnostics to .morph/hooks/logs/ and .morph/hooks/debug/. See CURSOR-SETUP.md § Debugging hooks for details.