Feature request for product/service
Cursor CLI
Describe the request
────────────────────────────────────────
Summary
────────────────────────────────────────
Host runtimes that run Cursor Agent CLI inside terminal panes — notably Herdr (https://herdr.dev/) and the herdrdev/herdr open-source project — can already restore Cursor sessions via sessionStart →
agent --resume <session_id>.
What they cannot do reliably is report the same idle / working / blocked lifecycle that peer agents expose through hooks (for example OpenCode, Kimi, MastraCode: PermissionRequest → blocked,
Stop/Interrupt → idle).
Cursor’s hooks docs already list most of the turn lifecycle:
• sessionStart
• beforeSubmitPrompt
• stop (completed | aborted | error)
• sessionEnd
• preToolUse / postToolUse / postToolUseFailure
The gaps that block host integrations are narrower and implementable:
1. No hook means “the built-in approval / question UI is on screen waiting for a human.”
2. No published, tested matrix of which documented hooks fire in interactive CLI vs agent --print vs IDE.
3. No interrupt contract guaranteeing hosts can leave working after Ctrl+C / Esc mid-turn.
Without (1), hosts fall back to screen scraping. Herdr’s own docs warn that a mistaken idle while an approval dialog is visible is unsafe for automation (automation can type into the approval UI). That
is a product risk for anyone orchestrating Cursor CLI panes — not a Herdr-only wishlist.
────────────────────────────────────────
Why Cursor should do this
────────────────────────────────────────
• Cursor Agent CLI is already treated as a first-class agent in Herdr (detection, session restore, screen manifests). Peer CLIs that expose approval enter/exit hooks get authoritative state; Cursor
stays on brittle screen matching.
• Completing the public hook contract unlocks Herdr, CI orchestrators, observability tools, and any multiplexer — without Cursor shipping a Herdr-specific integration.
• Most of the requested surface is already documented. The ask is one new event, parity + docs, and CI so it doesn’t regress.
────────────────────────────────────────
What works today (Herdr × Cursor)
────────────────────────────────────────
Detect cursor-agent / agent in a pane
→ Yes
Screen-based working / blocked heuristics
→ Yes (fragile; UI string churn)
herdr integration install cursor
→ Yes — sessionStart only → reports session id to Herdr
Resume after Herdr restart
→ Yes — cursor-agent --resume <session_id>
Hook-authoritative idle / working / blocked
→ No (session-only by design until the CLI contract is complete)
Herdr has previously wired fuller lifecycle maps for other agents and removed them when transitions were incomplete (Copilot / Devin / Droid / Qoder). Cursor is in the same “session identity, screen for
state” class until approval-enter is observable.
────────────────────────────────────────
Measured gap on Agent CLI 2026.10.22-27dcf5f
────────────────────────────────────────
Project .cursor/hooks.json logger for:
sessionStart, sessionEnd, beforeSubmitPrompt, preToolUse, postToolUse,
postToolUseFailure, stop, afterAgentResponse, beforeShellExecution
Command:
agent --print --trust --force
(prompt: reply “pong”, no tools)
Results:
sessionStart ........ YES (session_id / conversation_id present)
sessionEnd .......... YES (reason=completed, final_status=completed)
beforeSubmitPrompt .. NO
stop ................ NO
afterAgentResponse .. NO
tool / shell hooks .. NO (no tools in this run)
So even hooks the docs present as core Agent lifecycle events are not delivered on the --print path today. Interactive TUI parity needs an official matrix. Please run the acceptance tests below in CI
rather than taking community word for every interactive edge case.
Related existing forum reports: search for threads on afterAgentResponse / afterAgentThought not firing in headless CLI, and broader “Cursor CLI doesn’t send all events defined in hooks” reports.
────────────────────────────────────────
What is missing vs already documented
────────────────────────────────────────
Turn start / end / session end
Docs: yes (beforeSubmitPrompt, stop, sessionEnd)
Gap: fire reliably in interactive CLI; document --print behavior
Interrupt → leave working
Docs: partially (stop.status=aborted, postToolUseFailure.is_interrupt)
Gap: guarantee on Ctrl+C / Esc in interactive CLI
Approval UI shown (enter blocked)
Docs: no
Gap: new hook (name flexible)
Approval UI resolved
Docs: partially (postToolUse / afterShellExecution /
postToolUseFailure.permission_denied)
Gap: document + guarantee all resolve paths (y / n / skip / Esc)
emit one of those with the same tool_use_id;
add permissionResult only if you can’t
Note: beforeShellExecution returning ask is not a substitute. That is the hook requesting ask, not “Cursor’s built-in approval UI is visible.” It also fires for allowlisted commands that never show UI.
────────────────────────────────────────
Concrete ask (implementable)
────────────────────────────────────────
1. permissionRequest (or equivalent)
Fire when Agent CLI/IDE shows a user-blocking approval or clarifying-question UI.
Payload: conversation_id / session_id, generation_id, tool_name, tool_use_id.
Fire-and-forget is fine.
2. Resolution guarantee
Every outcome (approve / deny / skip / Esc) emits
postToolUse | afterShellExecution, or postToolUseFailure
(failure_type=permission_denied), with the same tool_use_id.
Else add permissionResult.
3. Published hook matrix
Interactive CLI TUI vs agent --print vs IDE Agent Chat,
kept in the Cursor hooks docs (https://cursor.com/docs/hooks).
4. Interactive CLI parity for already-documented hooks
sessionStart, beforeSubmitPrompt, stop, sessionEnd,
preToolUse, postToolUse, postToolUseFailure
5. Interrupt contract
Ctrl+C / Esc mid-turn emits stop{status:"aborted"} and/or
postToolUseFailure{is_interrupt:true} within ~1s.
No later hook implies working until the next beforeSubmitPrompt.
6. session_id == --resume id
On every lifecycle hook, including after resume.
7. CI conformance tests (PTY) for 1–6
So releases can’t silently drop events.
────────────────────────────────────────
Suggested acceptance tests (Cursor CI)
────────────────────────────────────────
T1 Interactive agent in PTY + hooks.json JSONL logger:
submit prompt → sessionStart, beforeSubmitPrompt,
(pre/postToolUse)*, stop{completed}; shared conversation_id.
T2 Same suite on agent --print and IDE → publish the matrix
(document intentional omissions).
T3 Non-allowlisted shell → permissionRequest BEFORE UI accepts input
(tool_name / tool_use_id set).
T4 Resolve y → postToolUse | afterShellExecution, same tool_use_id.
Resolve n / Esc / skip → postToolUseFailure permission_denied
(or documented alt), same id.
T5 Ctrl+C / Esc mid-tool → stop aborted and/or
postToolUseFailure is_interrupt within 1s.
T6 /exit or clean quit → sessionEnd with reason / final_status.
T7 agent --resume $SESSION_ID → sessionStart with same session_id.
────────────────────────────────────────
Out of scope (Herdr / host-side — not asking Cursor)
────────────────────────────────────────
• Herdr only registering sessionStart until the contract above is real
• Herdr screen-manifest idle rules / string matching for Cursor UI
• Herdr policy of not mixing hook working/idle with screen-only blocked
until approval-enter exists
• Requiring the cursor-agent binary name on PATH for resume
────────────────────────────────────────
Why this is enough for Herdr to ship lifecycle parity
────────────────────────────────────────
Once permissionRequest + interactive CLI parity + interrupt guarantees land, Herdr (and others) can install the same style of lifecycle hooks already used for Kimi/MastraCode:
turn/tool hooks → working
approval-enter → blocked
stop / interrupt → idle
…and stop scraping the TUI for automation decisions.