Skip to content

fix(cursor): return valid JSON from managed hooks - #15576

Closed
sanshengai wants to merge 1 commit into
stablyai:mainfrom
sanshengai:fix/cursor-hook-json-output
Closed

sanshengai wants to merge 1 commit into
stablyai:mainfrom
sanshengai:fix/cursor-hook-json-output

Conversation

@sanshengai

Copy link
Copy Markdown

ELI5

Orca's managed Cursor hooks reported activity but returned no response. Cursor expects hook stdout to be valid JSON, so permission hooks could fail closed and block every tool call. The hooks now return protocol-valid JSON while preserving Orca telemetry.

What Changed

  • Return {"permission":"allow"} for Cursor permission events: preToolUse, beforeShellExecution, and beforeMCPExecution.
  • Return {} for the other subscribed Cursor events.
  • Preserve valid fallback output when a managed script is missing on Windows, POSIX, and SSH installs.
  • Execute generated hook commands in regression tests and parse stdout for all eight events.

Why

Blank stdout is not a valid Cursor hook response and triggered the failure reported in #15462. Passing a constant response through an event-scoped environment variable keeps the original telemetry payload on stdin unchanged.

Linked Issue

Fixes #15462

Visual Proof

N/A — this changes the hook subprocess protocol, not rendered UI.

Testing

  • vitest for hook-service and installer-utils: 62 passed, 7 skipped.
  • Remote installer and timeout regressions: 28 passed, 1 skipped.
  • Generated Windows commands executed for all eight events, both with and without the managed script.
  • pnpm run typecheck:node.
  • Targeted oxlint, oxfmt --check, max-lines ratchet, and git diff --check.

A broader stdin-lifecycle run still reproduces the existing Windows antigravity-hook.cmd EOF race; that file and code path are unchanged by this PR.

AI Disclosure

OpenAI Codex (GPT-5 family) assisted with investigation, implementation, and testing.

Review Notes

  • Security: responses are fixed constants and use the existing shell-quoting paths.
  • Cross-platform: Windows, POSIX, and SSH-generated commands are covered.
  • Backward compatibility: callers that do not specify a Cursor event retain {} as the default response.

Author

@sanshengai

Copy link
Copy Markdown
Author

Closing as superseded by merged #15651, which fixes the same Cursor managed-hook stdout JSON contract on current main.

@sanshengai sanshengai closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor agent-status hooks emit no stdout, causing "returned invalid JSON" and blocking every tool call

1 participant