feat: Windows hook support with --windows flag (opt-in Node.js hooks)#727
feat: Windows hook support with --windows flag (opt-in Node.js hooks)#727Pamacea wants to merge 1 commit intortk-ai:developfrom
Conversation
Alternative approach to Windows support: keeps Unix .sh as default and adds optional --windows flag for Node.js hooks. New files: - hooks/rtk-rewrite.cjs: Claude Code Node.js hook - hooks/cursor-rtk-rewrite.cjs: Cursor IDE Node.js hook Changes: - Add --windows flag to Init command - Add REWRITE_HOOK_CJS and CURSOR_REWRITE_HOOK_CJS constants - Modify prepare_hook_paths() to accept use_windows parameter - Modify ensure_hook_installed() for both .sh and .cjs - Modify run_default_mode() and run_hook_only_mode() to pass windows flag - Modify install_cursor_hooks() to support Windows mode - Update tests to include new windows parameter Usage: rtk init -g # Uses .sh (Unix/macOS/Linux) rtk init -g --windows # Uses .cjs (Windows/macOS/Linux) Token savings: 60-90% on all platforms Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
|
@Pamacea please sign the CLA |
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
|
Thanks for contributing @Pamacea — the This is now superseded by the v0.37.x releases: the native binary hook ( |
Summary
Adds Windows support for
rtk initvia an opt-in--windowsflag that installs Node.js hooks instead of shell scripts.Problem
RTK's
rtk initonly worked on Unix (macOS/Linux) because:rtk-rewrite.sh)#[cfg(unix)]guards to block Windowschmod +xandPermissionsExtare Unix-onlyWindows users got this error:
Solution
Conservative approach - keeps existing behavior as default and adds opt-in flag:
New files:
hooks/rtk-rewrite.cjs- Claude Code Node.js hook (cross-platform)hooks/cursor-rtk-rewrite.cjs- Cursor IDE Node.js hook (cross-platform)Changes to
src/init.rs:--windowsflag to Init commandREWRITE_HOOK_CJSandCURSOR_REWRITE_HOOK_CJSconstantsprepare_hook_paths()to acceptuse_windowsparameterensure_hook_installed()to write .cjs whenuse_windows=truerun_default_mode()andrun_hook_only_mode()to pass flag throughinstall_cursor_hooks()to support Windows modewindowsparameterUsage
Key Differences from PR #726
--windowsflag opts inToken Savings
Same 60-90% savings on all platforms (with
--windowsflag).Testing
Checklist
cargo check)cargo test init::)Alternative to PR #726 - Maintainers can choose either:
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com