fix(init): migrate Cursor hooks.json before deleting the legacy hook script - #3570
Open
guyoron1 wants to merge 1 commit into
Open
fix(init): migrate Cursor hooks.json before deleting the legacy hook script#3570guyoron1 wants to merge 1 commit into
guyoron1 wants to merge 1 commit into
Conversation
…script 'rtk init -g --agent cursor' deleted ~/.cursor/hooks/rtk-rewrite.sh and then treated the stale hooks.json entry referencing it as 'RTK hook already present', printing a success message while leaving Cursor with a registered preToolUse hook whose script no longer exists (rtk-ai#3465). - patch_cursor_hooks_json now strips legacy rtk-rewrite.sh entries and registers the 'rtk hook cursor' command in the same atomic write; a legacy entry no longer satisfies the presence check. - The legacy script is deleted only after hooks.json was successfully patched, so a parse failure leaves the working script in place. - The separate remove_legacy_cursor_hooks_json_entries pass (whose swallowed errors caused the dangling reference) is gone.
guyoron1
force-pushed
the
fix/cursor-hook-migration
branch
from
August 15, 2026 07:22
1dd3789 to
03d03ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk init -g --agent cursordeleted~/.cursor/hooks/rtk-rewrite.shfirst and updatedhooks.jsonin a separate, error-swallowed pass;cursor_hook_already_presentthen accepted the stale legacy entry as "RTK hook already present". Net result on any failure of the cleanup pass: a registered Cursor preToolUse hook whose script no longer exists, reported as success (rtk init --agent cursor deletes ~/.cursor/hooks/rtk-rewrite.sh, leaves hooks.json referencing it, and reports success #3465).patch_cursor_hooks_jsonnow strips legacyrtk-rewrite.shentries and registersrtk hook cursorin the same atomic write, and the presence check only accepts the new binary command — a legacy entry can never satisfy it, since its script is about to be deleted.hooks.jsonwas successfully patched, so a parse failure propagates and leaves the still-working script hook in place. The now-redundantremove_legacy_cursor_hooks_json_entriespass is removed.--agent cursoralso running the Claude installer and touching~/.claude/) is the scope of fix(init): keep cursor setup out of claude config #3290 / RTK init want to install in .claude when using another agent #3282 and is not changed here.Test plan
cargo fmt --all --checkcargo clippy --all-targets(no warnings)cargo test— 2661 passed, 8 ignoredtest_patch_cursor_hooks_json_migrates_legacy_entry: a hooks.json referencing the legacy script is rewritten to a singlertk hook cursorentry in one operation. Updatedtest_cursor_hook_already_present_legacy_script*to assert a legacy entry does not count as present.Fixes #3465
🤖 Generated with Claude Code