Skip to content

fix(hook): emit Cursor JSON on early exits - #5373

Open
sanketpatel32 wants to merge 4 commits into
rtk-ai:developfrom
sanketpatel32:fix/hooks-cursor-empty-stdout
Open

sanketpatel32 wants to merge 4 commits into
rtk-ai:developfrom
sanketpatel32:fix/hooks-cursor-empty-stdout

Conversation

@sanketpatel32

Copy link
Copy Markdown

Summary

  • Emit {} on the Cursor hook's jq-missing, rtk-missing, and too-old exits while keeping the existing stderr warnings.
  • Add a Cursor hook regression suite covering those early exits, empty/no-rewrite output, and a rewrite response.
  • Update the shipped-hook guard test for Cursor's JSON-on-all-paths contract.

Fixes #5323

Test plan

  • bash hooks/cursor/test-rtk-rewrite.sh (6 tests passed)
  • shellcheck hooks/cursor/rtk-rewrite.sh hooks/cursor/test-rtk-rewrite.sh
  • cargo fmt --all --check
  • cargo clippy --all-targets
  • cargo test --all
  • bash scripts/check-test-presence.sh origin/develop

Important: All PRs must target the develop branch (not master).

See CONTRIBUTING.md for details.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Kernel-Hunter Kernel-Hunter left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked out the branch and ran bash hooks/cursor/test-rtk-rewrite.sh: all 6 cases pass. I also pointed the same script at the current rtk-rewrite.sh from the base branch through HOOK=, and 5 of the 6 fail there (the three dependency/version exits plus empty command and no rewrite), so the test does catch the missing {}.

I went through every exit 0 in the hook. All 6 now print {} first, and the only other path is the final jq -n rewrite output, so no exit is left without JSON.

One note: the new script isn't referenced from any workflow, so CI won't run it. hooks/claude/test-rtk-rewrite.sh is in the same state, so this matches the existing pattern, but it might be worth wiring both in later.

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.

hooks/cursor/rtk-rewrite.sh writes nothing to stdout on its jq-missing, rtk-missing and too-old exits

3 participants