feat(copilot): cross-platform PreToolUse hook via rtk hook (VS Code + Copilot CLI + Windows)#605
Conversation
|
You should have to do windows support too, also his maybe works on vscode copilot integration. I'm planning to add many extensions to the VS Code chat integration. |
|
Also rewrite script should be automated. Maybe adding rust code should fix that |
|
@vrdons Great suggestions — this PR has been expanded to implement exactly what you described. Rust binary instead of bash script ✅ VS Code Copilot Chat support ✅
When Copilot CLI adds The old bash hook also had wrong key casing ( |
|
Can't wait to have this feature ! my premium credits are exploding ! |
Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini rtk-ai#573, Codex rtk-ai#377, OpenClaw rtk-ai#358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
4eeace1 to
1b44eb5
Compare
|
@jeziellopes — Rebased your PR on Changes made during cleanup:
Tested manually:
Ready to merge into |
|
@jeziellopes — Tested the Copilot hook end-to-end on macOS with Copilot CLI 1.0.7: Copilot correctly executed via the RTK hook — output was filtered (compact 4-line format instead of raw git output). The Also verified:
Ready to merge. Thanks for the great contribution — Copilot support was a top request! |
* fix: remove all decorative emojis from CLI output (#687) * fix: remove decorative emojis from CLI output (#511) Replace decorative emojis with plain text to reduce token waste. Keep functional symbols (⚠️ ✓ ❌ ✅ ℹ️) that convey meaning in fewer tokens. Signed-off-by: Patrick Szymkowiak <patrick@rtk.ai> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: remove remaining decorative emojis from find_cmd and formatter Missed in initial emoji cleanup pass: 📁 in find_cmd.rs and parser/formatter.rs Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: remove all decorative emojis from CLI output (#511) Replace emojis with plain text tokens across all production files for better LLM compatibility. Test fixtures and external tool detection patterns (e.g. Black's "All done!") are preserved. Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: remove last decorative emoji from next_cmd.rs Remove ⚡ from Next.js Build header, missed in previous passes. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: remove remaining emojis from gh_cmd.rs and init.rs Replace production emojis: - gh_cmd.rs: 🟣→[merged], ⚪→[unknown]/[pending], ⭐→removed, 🔱→removed - init.rs: ⚪→[--] for "not found" status indicators Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix: remove all checkmark emojis from CLI output Replace ✓ (U+2713) with plain text across 19 files: - "ok ✓" → "ok" (git add/commit/push/pull) - "✓ cargo test: ..." → "cargo test: ..." (all tool summaries) - Preserved ✓ in input detection patterns and test fixtures LLMs cannot interpret emoji semantics; plain text is clearer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> --------- Signed-off-by: Patrick Szymkowiak <patrick@rtk.ai> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app> * feat: OpenClaw plugin for transparent exec rewriting (#358) * feat: add OpenClaw plugin for transparent exec rewriting Adds an OpenClaw plugin that intercepts exec tool calls via the before_tool_call hook and rewrites commands to their RTK equivalents. This is the OpenClaw equivalent of hooks/rtk-rewrite.sh for Claude Code. The plugin: - Registers a before_tool_call hook on the exec tool - Rewrites git, grep, find, ls, gh, docker, kubectl, and test commands - Guards against rewriting piped/compound commands and heredocs - Returns properly typed PluginHookBeforeToolCallResult - Supports enabled/verbose config options Measured savings: 48-87% token reduction on common commands. Files: - openclaw/index.ts — plugin source - openclaw/openclaw.plugin.json — plugin manifest - openclaw/README.md — installation and usage docs * refactor: delegate OpenClaw plugin to rtk rewrite Replace 60+ hardcoded regex rules with a single call to `rtk rewrite`, matching the OpenCode plugin pattern (hooks/opencode-rtk.ts). Benefits: - Zero maintenance: new RTK filters work automatically - Single source of truth: rewrite logic in Rust (src/discover/registry.rs) - 122 → 73 lines, no rule duplication Also: rebase on develop, fix homepage URL, bump version to 1.0.0. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add package.json for npm publishing Enables `openclaw plugins install @rtk-ai/rtk-rewrite` for OpenClaw users. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> --------- Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add Gemini CLI support via rtk init --gemini (#573) - Add `rtk hook gemini` command: native Rust hook processor for Gemini CLI BeforeTool hooks. Reads JSON from stdin, delegates to `rewrite_command()` (single source of truth), outputs Gemini-format JSON response. - Add `--gemini` flag to `rtk init`: installs hook wrapper script, GEMINI.md, and patches ~/.gemini/settings.json with BeforeTool hook entry. - Add `rtk init -g --gemini --uninstall`: clean removal of all Gemini artifacts. - 6 unit tests covering hook format, rewrite delegation, and exclusions. Replaces PR #174 which had too many conflicts after upstream restructuring. Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * feat(init): add Codex CLI support via AGENTS.md + RTK.md workflow (#377) * feat(init): add Codex CLI support via AGENTS.md + RTK.md workflow Add --codex mode to rtk init for Codex CLI integration using AGENTS.md + RTK.md, while keeping the newer develop init/opencode flow intact. Includes Codex install/show/uninstall handling, ASCII status output, stricter flag validation, and expanded tests for Codex AGENTS lifecycle and patch-mode rejection. Signed-off-by: Zacaria <havesomecode@gmail.com> * docs: fix validation metadata Signed-off-by: Zacaria <havesomecode@gmail.com> --------- Signed-off-by: Zacaria <havesomecode@gmail.com> * feat(copilot): add Copilot hook support (VS Code + CLI) (#605) Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini #573, Codex #377, OpenClaw #358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add Cursor Agent support via --agent flag (#595) Add `rtk init -g --agent cursor` to install RTK hooks for Cursor Agent. Cursor's preToolUse hook supports command rewriting via updated_input, functionally identical to Claude Code's PreToolUse. Works with both the Cursor editor and cursor-cli (they share ~/.cursor/hooks.json). Changes: - New `--agent <name>` flag (claude|cursor) on `rtk init`, extensible for future agents. Default is claude (backward compatible). - Cursor hook script (hooks/cursor-rtk-rewrite.sh) outputs Cursor's JSON format: {permission, updated_input} vs Claude's hookSpecificOutput. - `rtk init --show` reports Cursor hook and hooks.json status. - `rtk init -g --uninstall` removes Cursor artifacts. - `rtk discover` notes that Cursor sessions are tracked via `rtk gain` (Cursor transcripts lack structured tool_use/tool_result blocks). - Unit tests for Cursor hooks.json patching, detection, and removal. Made-with: Cursor Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Moisei <1199723+moisei@users.noreply.github.com> * feat: add Windsurf support via rtk init --agent windsurf (#695) (#697) Install RTK rules in .windsurfrules (project-scoped) so Cascade prefixes shell commands with rtk for token savings. Windsurf hooks don't support command rewriting (only blocking), so RTK uses the rules-based approach (like Codex with AGENTS.md). Tested: Windsurf Cascade correctly uses rtk git status after install. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add Cline/Roo Code support via rtk init --agent cline (#701) (#702) Install RTK rules in .clinerules (project-scoped) so Cline prefixes shell commands with rtk for token savings. Same rules-based approach as Windsurf and Codex. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * fix(skill/rtk-triage): increase PR/issue limit to 200 with pagination hint (#717) * fix(skill/rtk-triage): increase PR/issue limit to 200 with pagination hint Raise gh pr list limit from 60 to 200 to match gh's max per call. Add inline comment explaining how to paginate for repos with >200 open PRs. Update threshold warning from >60 to >200 PRs/issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com> * docs(architecture): update module count to 67 (hook_cmd added in #573) hook_cmd.rs was added in feat: add Gemini CLI support (#573) but ARCHITECTURE.md was not updated. Fixes pre-push validation failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com> --------- Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Signed-off-by: Patrick Szymkowiak <patrick@rtk.ai> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app> Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com> Signed-off-by: Zacaria <havesomecode@gmail.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com> Co-authored-by: Alex <a.neyman17@gmail.com> Co-authored-by: Ben Younes <benyounes.ousama@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Zacaria Chtatar <Zacaria@users.noreply.github.com> Co-authored-by: Jeziel Lopes <jeziellcarvalho@gmail.com> Co-authored-by: Moisei Rabinovich <moisei@users.noreply.github.com> Co-authored-by: Moisei <1199723+moisei@users.noreply.github.com> Co-authored-by: Florian BRUNIAUX <florian@bruniaux.com>
Add GitHub Copilot as a target agent for rtk init: - Add `Copilot` variant to `AgentTarget` enum - Add `hooks/copilot-rtk-rules.md` with compact RTK instructions - Add `run_copilot_mode()` that writes `.github/copilot-instructions.md` (idempotent: skips if RTK already detected in the file) - Add `--uninstall --agent copilot` to remove the instructions file - Route `install_copilot` through `init::run()` and `init::uninstall()` Usage: rtk init --agent copilot # install in current project rtk init --uninstall --agent copilot # remove Closes the gap from PR rtk-ai#605 / rtk-ai#704 where rtk hook copilot was added but rtk init had no copilot counterpart. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: jeziellopes <jeziellopes@gmail.com>
Add GitHub Copilot as a target agent for rtk init: - Add `Copilot` variant to `AgentTarget` enum - Add `hooks/copilot-rtk-rules.md` with compact RTK instructions - Add `run_copilot_mode()` that writes `.github/copilot-instructions.md` (idempotent: skips if RTK already detected in the file) - Add `--uninstall --agent copilot` to remove the instructions file - Route `install_copilot` through `init::run()` and `init::uninstall()` Usage: rtk init --agent copilot # install in current project rtk init --uninstall --agent copilot # remove Closes the gap from PR rtk-ai#605 / rtk-ai#704 where rtk hook copilot was added but rtk init had no copilot counterpart. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: jeziellopes <jeziellopes@gmail.com>
Add GitHub Copilot as a target agent for rtk init: - Add `Copilot` variant to `AgentTarget` enum - Add `hooks/copilot-rtk-rules.md` with compact RTK instructions - Add `run_copilot_mode()` that writes `.github/copilot-instructions.md` (idempotent: skips if RTK already detected in the file) - Add `--uninstall --agent copilot` to remove the instructions file - Route `install_copilot` through `init::run()` and `init::uninstall()` Usage: rtk init --agent copilot # install in current project rtk init --uninstall --agent copilot # remove Closes the gap from PR rtk-ai#605 / rtk-ai#704 where rtk hook copilot was added but rtk init had no copilot counterpart. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: jeziellopes <jeziellopes@gmail.com>
- Add Copilot variant to AgentTarget enum - run_copilot_mode(): installs .github/hooks/rtk-rewrite.json AND - uninstall(): removes both files - 5 unit tests with CWD_LOCK mutex serialization Usage: rtk init --agent copilot rtk init --uninstall --agent copilot Closes the gap from PR rtk-ai#605 / rtk-ai#704. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: jeziellopes <jeziellopes@gmail.com>
The events API only covers ~300 events which for active users is ~2 days. PRs authored earlier (like rtk-ai/rtk#605) were beyond the event horizon. Switch to GraphQL pullRequests query: - Requests 100 PRs directly authored by the user (all-time, 1 API call) - Filters out private repos and self-owned repos client-side - Merged first sort preserved via sortContribs() - No more N+1 per-PR REST fetches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Users who ran an earlier rtk init --copilot (from commit rtk-ai#605) ended up with .github/hooks/rtk-rewrite.json containing "command": "rtk hook" (missing subcommand). This causes RTK to log a spurious parse_failure on every Bash tool call, inflating rtk gain --failures stats silently. - rtk init --show: warns when the broken file is detected, with actionable guidance pointing to rtk gain --failures and the fix - rtk init -g --uninstall: removes the broken file as part of standard cleanup (only when command is the broken "rtk hook", leaves a correctly configured "rtk hook copilot" file untouched) Fixes rtk-ai#836
Users who ran an earlier rtk init --copilot (from commit rtk-ai#605) ended up with .github/hooks/rtk-rewrite.json containing "command": "rtk hook" (missing subcommand). This causes RTK to log a spurious parse_failure on every Bash tool call, inflating rtk gain --failures stats silently. - rtk init --show: warns when the broken file is detected, with actionable guidance pointing to rtk gain --failures and the fix - rtk init -g --uninstall: removes the broken file as part of standard cleanup (only when command is the broken "rtk hook", leaves a correctly configured "rtk hook copilot" file untouched) Fixes rtk-ai#836
Users who ran an earlier rtk init --copilot (from commit rtk-ai#605) ended up with .github/hooks/rtk-rewrite.json containing "command": "rtk hook" (missing subcommand). This causes RTK to log a spurious parse_failure on every Bash tool call, inflating rtk gain --failures stats silently. - rtk init --show: warns when the broken file is detected, with actionable guidance pointing to rtk gain --failures and the fix - rtk init -g --uninstall: removes the broken file as part of standard cleanup (only when command is the broken "rtk hook", leaves a correctly configured "rtk hook copilot" file untouched) Fixes rtk-ai#836
The events API only covers ~300 events which for active users is ~2 days. PRs authored earlier (like rtk-ai/rtk#605) were beyond the event horizon. Switch to GraphQL pullRequests query: - Requests 100 PRs directly authored by the user (all-time, 1 API call) - Filters out private repos and self-owned repos client-side - Merged first sort preserved via sortContribs() - No more N+1 per-PR REST fetches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini rtk-ai#573, Codex rtk-ai#377, OpenClaw rtk-ai#358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini rtk-ai#573, Codex rtk-ai#377, OpenClaw rtk-ai#358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini rtk-ai#573, Codex rtk-ai#377, OpenClaw rtk-ai#358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Add `rtk hook copilot` command that handles both VS Code Copilot Chat (updatedInput rewrite) and GitHub Copilot CLI (deny-with-suggestion). - Auto-detects format: snake_case (VS Code) vs camelCase (Copilot CLI) - Delegates to `rtk rewrite` (single source of truth) - 14 hook tests (format detection, rewrite gating, output shape) - .github/hooks/rtk-rewrite.json for repo-scoped hook config - .github/copilot-instructions.md for RTK awareness - Test script: hooks/test-copilot-rtk-rewrite.sh Rebased on develop (includes Gemini rtk-ai#573, Codex rtk-ai#377, OpenClaw rtk-ai#358). Original work by @jeziellopes, cleaned up and rebased by maintainer. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
…v1.0.24+) Before this change, rtk hook copilot responded with a deny-with-suggestion for Copilot CLI sessions, forcing the user to manually re-run the command with the rtk prefix. GitHub Copilot CLI v1.0.24 shipped a fix for copilot-cli#2013: preToolUse hooks now respect hookSpecificOutput.updatedInput and modifiedArgs fields, enabling transparent command rewriting. This commit upgrades handle_copilot_cli() to emit the same hookSpecificOutput envelope already used by the VS Code path, including both updatedInput and modifiedArgs for maximum compatibility. The deny-with-suggestion workaround is removed. Copilot CLI now gets the same transparent rewrite experience as VS Code Copilot Chat. Refs: copilot-cli#2013, rtk PR rtk-ai#605 (predicted this exact change) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…24+) Before this change, rtk hook copilot had two problems: 1. Copilot CLI format used deny-with-suggestion (no updatedInput support) 2. All rewrites triggered an ask confirmation dialog on every command GitHub Copilot CLI v1.0.24 shipped a fix for copilot-cli#2013: preToolUse hooks now respect hookSpecificOutput.updatedInput and modifiedArgs. Changes: - hook_cmd.rs: handle_copilot_cli() now emits hookSpecificOutput with updatedInput + modifiedArgs (both fields for v1.0.24 compatibility) - hook_cmd.rs: default verdict changed from ask to allow for both VS Code and Copilot CLI paths — transparent rewrites auto-approve since the user explicitly installed the hook; explicit ask rules still trigger prompts - .github/hooks/rtk-rewrite.json: fix broken command rtk hook → rtk hook copilot (hook was silently failing with exit 2 on every invocation) - init.rs: success message updated (no longer says deny-with-suggestion) - hooks/README.md: permission model table updated Tested locally with Copilot CLI v1.0.24: all 4 cases pass. 1379 unit tests green. Refs: copilot-cli#2013, rtk PR rtk-ai#605 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…24+) Before this change, rtk hook copilot had two problems: 1. Copilot CLI format used deny-with-suggestion (no updatedInput support) 2. All rewrites triggered an ask confirmation dialog on every command GitHub Copilot CLI v1.0.24 shipped a fix for copilot-cli#2013: preToolUse hooks now respect hookSpecificOutput.updatedInput and modifiedArgs. Changes: - hook_cmd.rs: handle_copilot_cli() now emits hookSpecificOutput with updatedInput + modifiedArgs (both fields for v1.0.24 compatibility) - hook_cmd.rs: default verdict changed from ask to allow for both VS Code and Copilot CLI paths — transparent rewrites auto-approve since the user explicitly installed the hook; explicit ask rules still trigger prompts - .github/hooks/rtk-rewrite.json: fix broken command rtk hook → rtk hook copilot (hook was silently failing with exit 2 on every invocation) - init.rs: success message updated (no longer says deny-with-suggestion) - hooks/README.md: permission model table updated Tested locally with Copilot CLI v1.0.24: all 4 cases pass. 1379 unit tests green. Refs: copilot-cli#2013, rtk PR rtk-ai#605 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #593
What this adds
Cross-platform
PreToolUsehook for GitHub Copilot (VS Code Copilot Chat + Copilot CLI) viartk hook— a native Rust binary. No bash scripts, nojq, works on Windows natively.How it works
rtk hookreadsPreToolUseJSON from stdin, detects the agent format, responds appropriately:VS Code Copilot Chat (
updatedInput— transparent rewrite):GitHub Copilot CLI (deny-with-suggestion — CLI ignores
updatedInputtoday, copilot-cli#2013):When Copilot CLI adds
updatedInputsupport, onlyrtk hookneeds a one-line change.Also fixed
The old
.github/hooks/rtk-rewrite.jsonhad wrong key names (preToolUse→PreToolUse,bash/timeoutSec→command/timeout) that prevented it from loading in VS Code.Measured gains (validated Copilot CLI session)
rtk cargo testrtk cargo clippy --all-targetsrtk git diff HEAD~1rtk gh pr listFiles
src/hook_cmd.rsrtk hooksubcommand (13 unit tests).github/hooks/rtk-rewrite.jsonrtk hookhooks/copilot-rtk-rewrite.shrtk hookhooks/test-copilot-rtk-rewrite.shrtk hookhooks/copilot-rtk-awareness.mdsrc/init.rsREADME.mdCHANGELOG.mdTesting