fix(init): --agent cursor installs Cursor only and creates ~/.cursor#3000
Open
rNoz wants to merge 1 commit into
Open
fix(init): --agent cursor installs Cursor only and creates ~/.cursor#3000rNoz wants to merge 1 commit into
rNoz wants to merge 1 commit into
Conversation
rtk init -g --agent cursor fell through to the shared init path with install_claude derived only from !opencode, so it created RTK.md, CLAUDE.md, and patched settings.json under ~/.claude in addition to patching .cursor/hooks.json. On machines without ~/.claude it failed outright when creating the temp file. Two fixes: - Gate install_claude on the absence of a sibling agent target (Cursor, Windsurf, Cline) so only the default or explicit Claude target installs Claude Code files. - Create ~/.cursor before patching hooks.json; atomic_write places its temp file in the target's parent, which failed on a fresh machine where the directory did not yet exist. Closes rtk-ai#2097
tapheret2
approved these changes
Jul 15, 2026
tapheret2
left a comment
There was a problem hiding this comment.
Review: fix(init): --agent cursor installs Cursor only and creates ~/.cursor
Files: src/hooks/init.rs, src/main.rs, tests/init_agent_cursor_test.rs
Size: +93 / -1
Notes
- Tests/fixtures present — good signal for correctness.
Thanks @rNoz — independent review on the patch.
Author
|
Tested E2E locally with my local rnoz/integration branch. All working as expected. See the capture. Ready for review/merge. |
rNoz
marked this pull request as ready for review
July 15, 2026 18:25
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
Two defects made
rtk init -g --agent cursorfail / pollute the home dir:install_claudederived only from!opencode, so it createdRTK.md,CLAUDE.md, and patchedsettings.jsonunder~/.claudein addition to patching.cursor/hooks.json. On machines without~/.claudeit failed outright:Failed to create temp file in ~/.claude: No such file or directory..claudewrites, the Cursor path still failed on a fresh machine becauseinstall_cursor_hooksnever created~/.cursorbeforeatomic_writeplaced its temp file there.Fixes:
install_claudeon the absence of a sibling agent target (Cursor, Windsurf, Cline), so only the default or an explicit Claude target installs Claude Code files.~/.cursor(non-dry-run) before patchinghooks.json.Root cause
src/main.rs,Commands::Inithandler:install_claude = !opencode. Cursor is the only sibling agent that reaches the shared init path (Windsurf/Cline short-circuit earlier inhooks::init::run), so it incorrectly triggered the Claude install branch.src/hooks/init.rs,install_cursor_hooks: wrotehooks.jsonviaatomic_writewithout ensuring the parent directory exists.Fix
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --all: pass.tests/init_agent_cursor_test.rs:agent_cursor_dry_run_never_touches_claude: asserts dry-run output contains no/.claude/path and does patch/.cursor/.agent_cursor_real_write_creates_no_claude_dir: non-dry-run install in a tempHOME: exits 0, never creates~/.claude, and writes.cursor/hooks.json.default_dry_run_still_installs_claude: regression: default init still installs Claude Code files.cargo test --bin rtk hooks::init: 169 existing init tests pass (no regression).E2E Validation
Tested locally and providing proofs (Screenshot). All working as expected: