Repository navigation
Conversation
guyoron1
force-pushed
the
fix/cursor-hook-migration
branch
from
August 15, 2026 07:22
1dd3789 to
03d03ab
Compare
guyoron1
force-pushed
the
fix/cursor-hook-migration
branch
from
September 21, 2026 12:20
03d03ab to
af45afa
Compare
Contributor
Author
|
Rebased on current develop; two conflicts in The bug is worse on develop than when I wrote this up: an earlier cleanup step ("Remove Cursor legacy hook") deletes the script before |
…script `rtk init -g --agent cursor` deletes ~/.cursor/hooks/rtk-rewrite.sh and then treats 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 is gone. It only ran while the script was still on disk, and the earlier "Remove Cursor legacy hook" cleanup deletes that script first, so the pass never fired and the stale entry always survived. Reapplied on top of develop's `refactor(hooks): split init.rs into per-agent submodules` (5ec8b8c), which moved this logic verbatim into src/hooks/init/cursor.rs before this PR landed. The uninstall path's is_cursor_hook_entry (matches legacy + new command) is left untouched; only the "already present" check is narrowed, via a new is_active_cursor_hook_entry.
guyoron1
force-pushed
the
fix/cursor-hook-migration
branch
from
September 27, 2026 03:36
af45afa to
65800c4
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: 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, so a legacy entry can never satisfy it (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.On current develop the bug is not only still present, it always fires: an earlier unconditional cleanup step ("Remove Cursor legacy hook") deletes the script before
install_cursor_hooksruns, so theif old_hook.exists()block, which held the only call toremove_legacy_cursor_hooks_json_entries, never runs at all. Checked end to end with the real binaries in throwawayHOMEs:Test plan
cargo fmt --all -- --checkcargo clippy --all-targets(0 warnings)cargo test --all(all pass; all 30cursortests pass)test_patch_cursor_hooks_json_migrates_legacy_entry: a hooks.json referencing the legacy script is rewritten to a singlertk hook cursorentry in one operation.test_cursor_hook_already_present_legacy_script*now asserts that a legacy entry does not count as present.Fixes #3465