feat(init): add Cursor support (rtk init --cursor)#254
Open
sahilmgandhi wants to merge 1 commit intortk-ai:masterfrom
Open
feat(init): add Cursor support (rtk init --cursor)#254sahilmgandhi wants to merge 1 commit intortk-ai:masterfrom
rtk init --cursor)#254sahilmgandhi wants to merge 1 commit intortk-ai:masterfrom
Conversation
1dddf48 to
a9bf559
Compare
7 tasks
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
I find myself switching between Cursor (via the
agentcli) and Claude code. So making this PR to add cursor support and make it generic enough to addcodex, or any other support in the future.rtk init --cursorinstalls RTK for Cursor Agent: hook script (preToolUse for Shell), rules file (rtk.mdc), and hooks.json registrationInitTargetenum and shared helpers (patch_json_registry,ensure_agent_hook_installed) so adding future agents (Codex, OpenCode) requires only a new enum variant + onerun_<agent>_modefunctionRTK_HOOK_MODE=cursor|claudeenv var override for edge casesconflicts_with_allprevents invalid flag combos (--cursor --claude-md,--cursor --hook-only)hooks.json(array, null, wrong types)#[cfg(not(unix))]guard with clear error since hook is bash-onlyChanges
src/init.rsInitTargetenum,run_cursor_mode(),patch_json_registry()(generic JSON patcher shared by Claude + Cursor),ensure_agent_hook_installed()(replaces old Claude-specific duplicate),uninstall_cursor(),show_cursor_config(),prepare_cursor_paths(),insert_cursor_hook_entry()with safe type checks. Windows guard. 6 new tests for Cursor hook detection/removal.src/main.rs--cursorflag withconflicts_with_all, routes toInitTargethooks/rtk-rewrite.shhook_event_name/cursor_version),RTK_HOOK_MODEenv override, dual JSON output format (ClaudehookSpecificOutput.updatedInputvs Cursordecision+updated_input)hooks/rtk-cursor-rules.mdcrtk errcustom rules + exceptions)CHANGELOG.mdCLAUDE.mdREADME.mdTest plan
cargo fmt --allpassescargo clippy --all-targets— no new warningscargo test init::— 30/30 tests pass (6 new for Cursor)cargo test --all— 418/418 tests passrtk init --cursorin a project directoryrtk init --cursor -gfor global installrtk init --cursor --showshows statusrtk init --cursor -g --uninstallremoves artifactsgit status→rtk git statusCloses #213