Skip to content

feat(windows): native auto-rewrite hook support + install.ps1#2484

Open
279814 wants to merge 1 commit into
rtk-ai:developfrom
279814:feat/windows-native-hook-support
Open

feat(windows): native auto-rewrite hook support + install.ps1#2484
279814 wants to merge 1 commit into
rtk-ai:developfrom
279814:feat/windows-native-hook-support

Conversation

@279814

@279814 279814 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Native Windows already runs the auto-rewrite hook today — the Claude Code hook is the platform-agnostic rtk hook claude subcommand, and rtk init -g registers it on Windows with no special-casing. But the docs still tell Windows users that auto-rewrite doesn't work and that they fall back to "CLAUDE.md injection mode". This PR closes that gap and adds a first-class Windows installer.

Why the docs are stale

  • src/hooks/constants.rs: CLAUDE_HOOK_COMMAND = "rtk hook claude" (native Rust, not a shell script).
  • src/hooks/init.rs run_default_mode() calls patch_settings_json_command(CLAUDE_HOOK_COMMAND, ...) on all platforms — there is no cfg!(windows) branch forcing run_claude_md_mode.
  • src/hooks/hook_cmd.rs run_claude() reads stdin JSON / writes stdout JSON and already strips Windows UTF-8 BOMs.

So the "requires a Unix shell → falls back to CLAUDE.md" wording predates the migration to the native subcommand.

Changes

  • install.ps1 (new): PowerShell installer that mirrors install.sh — resolves the latest release via the /releases/latest redirect (API fallback), downloads rtk-x86_64-pc-windows-msvc.zip, installs rtk.exe to %USERPROFILE%\.local\bin, and verifies PATH. Supports $env:RTK_VERSION / $env:RTK_INSTALL_DIR.
  • README.md / INSTALL.md: add a Windows quick-install (irm ... | iex) and rewrite the Windows section so native auto-rewrite is the documented default; WSL is presented as optional.
  • docs/troubleshooting.md, docs/supported-agents.md: replace the outdated fallback guidance with native-hook instructions, and honestly note that the Gemini hook is still a #!/bin/bash wrapper and needs WSL on native Windows until it migrates to rtk hook gemini.

Verification

  • install.ps1 passes [System.Management.Automation.Language.Parser]::ParseFile (no syntax errors).
  • End-to-end on native Windows 11 (PowerShell, no WSL) with the published rtk-x86_64-pc-windows-msvc.zip (v0.42.4):
    • rtk init -grtk init --show reports [ok] Hook: rtk hook claude, existing settings.json keys preserved (deep-merge).
    • echo '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | rtk hook claudeupdatedInput.command = rtk git status.
    • cargo testrtk cargo test; unsupported commands (e.g. htop) pass through unchanged.

Scope / notes

  • Docs + new installer only; no changes to Rust source or behavior.
  • No tests added: install.ps1 is a thin installer with no Rust logic, consistent with the existing untested install.sh. Happy to add a CI lint (e.g. PSScriptAnalyzer) if maintainers want one.
  • Out of scope (follow-up): migrating the Gemini hook from the bash wrapper to a native rtk hook gemini registration so it too works on native Windows.

The Claude Code hook migrated from the `rtk-rewrite.sh` shell script to the
native `rtk hook claude` subcommand, which reads PreToolUse JSON from stdin
and writes the rewritten command to stdout. It runs identically on every
platform, so `rtk init -g` already registers the real auto-rewrite hook on
native Windows (no CLAUDE.md fallback) — but the docs still claimed otherwise.

- add install.ps1: PowerShell installer mirroring install.sh (resolves the
  latest release, downloads rtk-x86_64-pc-windows-msvc.zip, installs rtk.exe
  to %USERPROFILE%\.local\bin, verifies PATH)
- README / INSTALL: add Windows quick-install (irm ... | iex) and rewrite the
  Windows section to describe native auto-rewrite as the default
- docs(troubleshooting, supported-agents): replace the outdated
  "falls back to CLAUDE.md injection" guidance; note Gemini's shell wrapper
  still needs WSL on Windows
@CLAassistant

CLAassistant commented Jun 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants