Repository navigation
Description
Summary
rtk hook copilot recognizes the native Copilot CLI payload only when
toolName == "bash". On Windows, Copilot CLI names its shell tool
powershell, so detect_format returns PassThrough and the
HookFormat::CopilotCli branch — the one that emits modifiedArgs and
deliberately omits permissionDecision — is never reached.
What answers instead is the Claude-compat PreToolUse entry, which routes to
HookFormat::VsCode and emits permissionDecision: "ask". Since Copilot CLI
1.0.66+ treats that field as authoritative, every rewritten command prompts
(this is #3037), and the allowlist (--allow-tool "shell(rtk:*)",
permissions-config.json) cannot help: only allow/deny short-circuit the
permission flow, ask forces the prompt.
This also explains the Windows limitation documented in the README
("On native Windows (cmd.exe / PowerShell), RTK filters work but the hook does
not auto-rewrite commands") and reported in #2424.
Environment
- RTK: 0.43.0 (official release asset
rtk-x86_64-pc-windows-msvc.zip,
SHA256A715E989BCEBFC208F388CF5ADAAA9953CBF1127B081BC09C4EF02E7D7FEA39F) - Copilot CLI: 1.0.73
- OS: Windows 11 Pro 26200
- Hook file: the one generated by
rtk init -g --copilot
(~/.copilot/hooks/rtk-rewrite.json, declaring bothPreToolUseand
preToolUse)
Evidence
Payload actually delivered to the camelCase preToolUse entry, captured
from a live Copilot CLI session with a logging hook:
{"sessionId":"c1b3f427-...","timestamp":1784807355614,"cwd":"C:\\Windows\\System32",
"toolName":"powershell","toolArgs":"{\"command\":\"rtk gain\",\"description\":\"...\"}"}toolArgs is the JSON-encoded string RTK expects — only toolName differs
(powershell, not bash).
Payload delivered to the PascalCase PreToolUse entry in the same session:
{"hook_event_name":"PreToolUse","session_id":"...","cwd":"C:\\Windows\\System32",
"tool_name":"Bash","tool_input":{"command":"git status --short"}}Resulting behavior, reproducible with the shipped binary:
$ echo '{"toolName":"powershell","toolArgs":"{\"command\":\"git status\"}"}' | rtk hook copilot
# (empty — PassThrough, native path skipped)
$ echo '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | rtk hook copilot
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask",
"permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git status"}}}Root cause
src/hooks/hook_cmd.rs, detect_format:
// Copilot CLI: camelCase keys, toolArgs is a JSON-encoded string
if let Some(tool_name) = v.get("toolName").and_then(|t| t.as_str()) {
if tool_name == "bash" { // ← never true on WindowsSuggested fix
Accept Copilot CLI's Windows shell tool name:
if matches!(tool_name, "bash" | "powershell") {A patch with a regression test (test_detect_copilot_cli_powershell) is
attached / in the linked PR.
Note on interaction with #3037
The two are complementary. With this fix the native path is reached on Windows
and returns modifiedArgs without permissionDecision, but the Claude-compat
PreToolUse entry generated by rtk init still answers ask for the same
tool call. Unless #3037 is fixed as well (or the generated hook file stops
declaring both entries), Windows users keep getting a prompt on every command.
Current workaround
Wrap the hook and rewrite the decision before Copilot sees it:
"command": "rtk hook copilot | sed 's/\"permissionDecision\":\"ask\"/\"permissionDecision\":\"allow\"/'"On Windows the same thing is done from a small PowerShell wrapper, which must
also handle the fact that Windows PowerShell 5.1 prepends a UTF-8 BOM to piped
stdin (RTK already handles that itself — see
test_copilot_bom_prefixed_payload_is_recognized).
Activity
pszymkowiak commentedon Jul 23, 2026
🔍 Automated Triage
bughighSummary
detect_format in src/hooks/hook_cmd.rs only matches toolName == "bash", so Copilot CLI's Windows shell tool ("powershell") falls through to PassThrough/Claude-compat path and never gets the modifiedArgs-only CopilotCli response — fix by matching both "bash" and "powershell".
📁 Relevant files
src/hooks/hook_cmd.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
docs(hooks): confirm PascalCase Bash mapping already covers Windows p…
fix(hook): detect Copilot CLI shell tool on Windows
romain-cureau commentedon Jul 27, 2026
Follow-up after testing on the same Windows box, since one claim above turned out to be wrong.
Still accurate:
detect_formatdoesn't recognizetoolName: "powershell", so the nativeCopilotClibranch is unreachable on Windows. Fix in #3179.Retracted: I wrote that this "explains the Windows limitation documented in the README" and that only the Claude-compat entry answers. The first half is wrong. Copilot CLI fires both registered entries, and the PascalCase one both receives the call (remapped to
tool_name: "Bash") and has itsupdatedInputhonored — verified with a throwaway hook rewritingecho PROBE_INPUT_5521toecho REWRITE_APPLIED_9137; the session printedREWRITE_APPLIED_9137. So the rewrite does work on Windows today, through that path.The user-visible symptom on Windows is therefore the
askprompt fromhandle_vscode(#3037), not a missing rewrite — which is exactly what #3212 fixes at the root. This issue narrows to "detect_formatmisreports what Copilot CLI sends on Windows", and once #3212 lands and users re-runrtk init --copilot, #3179's arm becomes legacy-only. Fine by me if maintainers prefer to close both in favour of #3212.fix(hook): detect Copilot CLI shell tool on Windows
KuSh commentedon Jul 27, 2026
Thanks a lot for the test and confirmation @romain-cureau. This MR will still be of value at least for the users that don't rerun init after an upgrade! I'll merge that one and rebase #3212 after that.
docs(hooks): confirm PascalCase Bash mapping already covers Windows p…
!15338 merge bump-rtk-0.44.1 into main