Repository navigation
fix(cursor): emit Cursor-contract JSON from managed hooks - #15651
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds shared Cursor event definitions and event-specific response selection. It generates POSIX and Windows managed hook commands and local scripts with protocol fallbacks, environment checks, endpoint refresh, payload forwarding, and stdin draining. Cursor hook installation, status checks, and removal now use the shared generators. The CLI TypeScript configuration includes the new modules. Tests cover normal and empty input, missing scripts, unreachable listeners, fallback output, and Windows execution. Merge Risk: 🟡 Moderate · up to A Windows managed hook can exit before consuming Cursor’s payload on affected paths, risking failed or stalled hook invocations. Merge readiness remains moderate until the stdin-drain behavior is fixed or explicitly accepted by the owner. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The implementation satisfies issue Full details: Out of Scope Changes checkExplanation The changes remain within scope. Production changes, tests, TypeScript configuration, and Windows CI updates directly support Cursor hook response handling, fallback behavior, cross-platform coverage, and remote installation. Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 7 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c5ad64bc-8dca-4018-91e2-83933476b1ef
📒 Files selected for processing (8)
config/tsconfig.cli.jsonsrc/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/installer-utils.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/cursor/hook-events.tssrc/main/cursor/hook-script.tssrc/main/cursor/hook-service.test.tssrc/main/cursor/hook-service.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
STA-4848 Windows QA (dev-mode, not packaged)Verdict: VALIDATED — managed Cursor hooks emit contract JSON on stdout. Windows runner is Empty-profile PR-branch Orca ( Invoked the exact |
|
Codex revision pass complete. I reviewed the implementation, tests, description, issue context, and every PR review/comment from scratch. I kept the product diff unchanged: the per-event Cursor response mapping, event-scoped launcher environment, shared missing-script fallback, local/SSH parity, and registered-command tests are the implementation I would write for #15462. I also replied to the unresolved Windows stdin comment: Non-vacuity proof: I temporarily removed the managed POSIX stdout response and reran the focused suite. It failed as expected: After restoring the PR implementation, the same suite passed with 5 passed / 2 skipped. Final verification:
No product/test edits, empty commit, or push were warranted; the existing PR head is the correct focused fix. |
macOS QA (isolated dev Electron, HEAD
|
Review status: readyFinal reviewed head:
|
|
Review verification — exact head Rebased PR #15651 onto current |
|
QA evidence — exact head The branch was rebased onto current |
Cursor requires JSON on stdout when a hook exits 0. The managed Cursor script POSTed telemetry and printed nothing, so cursor-agent denied every gated tool call with "returned invalid JSON" (#15462). Print the per-event response first on both Windows and POSIX branches (permission events: {"permission":"allow"}; everything else: {}), and give wrapWindowsHookCommand the same missing-script fallbackStdout that POSIX wrap already has so the launchers cannot drift. Co-authored-by: sanshengai <269852131+sanshengai@users.noreply.github.com>
a8bf650 to
f390129
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |


ELI5
Orca's Cursor status hooks reported activity to Orca but printed nothing back to Cursor. Cursor requires JSON on stdout, so every tool call was blocked. The hooks now return the documented allow/neutral JSON while still posting telemetry.
What Changed
{"permission":"allow"}first for Cursor permission events (preToolUse,beforeShellExecution,beforeMCPExecution) and{}for the other subscribed events, on both the Windows and POSIX managed scripts.ORCA_CURSOR_HOOK_RESPONSEon the shared PowerShell/POSIX launchers, and throughfallbackStdoutwhen the managed script is missing.wrapWindowsHookCommandthe samefallbackStdoutoption POSIX wrap already had, so Windows missing-script cannot drift from POSIX.hook-service.tsso the installer stays focused.Why
Blank stdout is not valid Cursor hook output. cursor-agent fails closed with
Hook "..." returned invalid JSON, which blocked every gated tool call whenever Orca agent-status hooks were on (#15462). This is the Cursor-installer sibling of #14825: write the contract JSON first, and keep launcher fallbacks on the shared wrapper.Linked Issue
Fixes #15462
STA-4848
Supersedes #15576
How this supersedes #15576
Carries forward sanshengai's per-event response env +
fallbackStdoutapproach. Differences:wrapWindowsHookCommandfallback so it matches POSIX wrap and cannot drift from the fix(agent-hooks): make the Windows managed hook survive Claude-hooks-compat consumers #14825 launcher.hook-events.ts/hook-script.tsinstead of growinghook-service.ts.hooks.jsoncommand (not installer-intent string checks) for every event, empty stdin, missing script, and a dead listener; Windows also covers cmd.exe and Git Bash like fix(agent-hooks): make the Windows managed hook survive Claude-hooks-compat consumers #14825.origin/main, not the community PR's stale base.Visual Proof
N/A — this changes the hook subprocess protocol, not rendered UI.
Testing
SyntaxError: Unexpected end of JSON input(empty stdout).src/main/cursor/hook-service.test.ts5 passed / 2 skipped (Windows-only).SyntaxError. Restored the fix; tests passed.installer-utils,remote-hook-service-installers, andmanaged-hook-stdin-lifecycle(100 passed / 7 skipped).pnpm typecheckand targetedoxlint/oxfmtclean.skipIfnot win32; CI Windows should exercise it. POSIX proven on macOS.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
:orca_agent_hook_drain_stdinlabel incursor-hook.cmdis intentional after [Bug]: Codex managed hook leaves persistent cmd.exe windows outside Orca on Windows #11549: missing-Orca-env paths mustexit /b 0withoutmore.com. Claude onlygotos that label from the Devin skip. The shared epilogue stays because the cross-agent stdin-lifecycle suite requires it. Not a bug.orca agent hooks offreportingmanagedHooksPresent: falsewhile stale Claude entries remain is a separate defect (getStatus exact-matches the current command). Not in this PR.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author