Repository navigation
Conversation
3564cf8 to
c8949c2
Compare
558c1ef to
6561990
Compare
|
Any update ? |
|
Can we expect this anytime soon? Anything we can help with? |
|
Also waiting for this. Using RTK only with agent instructions is strictly inferior to the command hook. |
|
Hello @devmasa and everyone Copilot CLI has been udpated on latest release 0.42.3 , now use latest docs from copilot CLI for a correct usage. I'll keep an eye on this PR so we can merge if it still add value to the copilot integration |
|
Thanks @devmasa. I reviewed this against the current Where things stand vs
Please rebase on |
VS Code Copilot Chat sends tool_name: "run_in_terminal" in PreToolUse payloads, but detect_format() only matched "runTerminalCommand", "Bash", and "bash". This caused all commands from VS Code Copilot Chat to fall through to HookFormat::PassThrough (no output), silently disabling the hook. Changes: - Add "run_in_terminal" to the match arm in detect_format() - Merge handle_vscode/handle_copilot_cli into handle_copilot_rewrite() to unify the rewrite logic and reduce duplication - Add CopilotHookOutput enum to separate output format from logic - Add build_copilot_deny_output() helper to centralize deny JSON - Switch VS Code output to deny+suggestion (avoids the updatedInput infinite-loop bug in Copilot Chat; see issue body for details) - Add tests: test_detect_vscode_run_in_terminal, test_copilot_deny_output_vscode_format, test_copilot_deny_output_cli_format Fixes: rtk-ai#1425 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… for Copilot CLI Separate VS Code Copilot Chat and Copilot CLI into distinct HookFormat variants. Copilot CLI v1.0.24+ now gets transparent rewrite via modifiedArgs. VS Code keeps deny+suggestion to avoid the updatedInput infinite-loop bug. Closes rtk-ai#1839 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
6561990 to
d435ead
Compare
- VS Code Copilot Chat: revert deny-with-suggestion to updatedInput transparent rewrite (verified working on VS Code 1.123.0 / Copilot Chat 0.51.0 — no infinite loop observed) - detect_format: narrow VS Code detection to "run_in_terminal" only, confirmed against live payloads (Copilot CLI 1.0.60 uses "bash", VS Code uses "run_in_terminal"; "Bash" belongs to run_claude path) - Copilot CLI: replace bare Deny check with decide_hook_action so unattestable constructs ($(...), backticks, file redirects) are guarded consistently with the VS Code path - Fix .github/hooks/rtk-rewrite.json: "rtk hook" → "rtk hook copilot" Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
d435ead to
0eee969
Compare
Copilot CLI sends camelCase payloads (toolName/toolArgs as JSON string) only when the hook config uses "preToolUse" (camelCase event name). "PreToolUse" (PascalCase) sends snake_case and modifiedArgs is ignored. - detect_format: detect toolName/toolArgs (camelCase) for Copilot CLI; tool_name/tool_input (snake_case) remains for VS Code Copilot Chat - process_copilot_payload: parse toolArgs JSON string, return modifiedArgs with permissionDecision:allow for transparent rewrite - .github/hooks/rtk-rewrite.json: switch to "preToolUse" (required for Copilot CLI) and fix "rtk hook" → "rtk hook copilot" (was broken) - Tests updated to camelCase fixture format; verified working on Copilot CLI 1.0.60 and VS Code 1.123.0 / Copilot Chat 0.51.0 VS Code Copilot Chat always sends snake_case regardless of event name casing, so existing snake_case detection path is unaffected. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- VsCode → SnakeCaseCmd: handles snake_case payloads (tool_name/tool_input) Used by VS Code Copilot Chat (always) and Copilot CLI with "PreToolUse" config Returns hookSpecificOutput.updatedInput — verified working for both hosts - CopilotCli → CamelCaseCmd: handles camelCase payloads (toolName/toolArgs) Used by Copilot CLI with "preToolUse" config (official/recommended) Returns modifiedArgs - detect_format: add "bash" to snake_case branch so Copilot CLI users with "PreToolUse" config also get transparent rewrite via updatedInput Copilot CLI supports both formats; VS Code supports SnakeCaseCmd only. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Thanks @AbdAllahAbdElFattah13 and @anasawad for the manual workaround gist — really helpful for people waiting on this. Thanks for the detailed review, @aeppling. I've rebased on 1. Confirmed still missing from 2. Copilot CLI payload format — the tricky part The payload format that Copilot CLI sends depends entirely on the event name casing in the hook config:
Both paths were verified on Copilot CLI 1.0.60 in this session. The original
// Hook receives (camelCase format):
{"toolName": "bash", "toolArgs": "{\"command\":\"git status\",\"description\":\"...\"}"}
// Hook returns:
{"permissionDecision": "allow", "modifiedArgs": {"command": "rtk git status", "description": "..."}}
// postToolUse confirms:
{"toolName": "bash", "toolArgs": "{\"command\":\"rtk git status\",\"description\":\"...\"}"}
3. With Since both paths now work (camelCase via 4. VS Code Copilot Chat: event name casing doesn't matter for payload format VS Code always sends snake_case payloads regardless of event name casing. The VS Code docs note it converts camelCase event names to PascalCase internally, and all examples use 5. Tested 6. Security parity: unattestable construct guard for Copilot CLI (bonus — happy to revert if out of scope)
Summary of changes
|
|
(Also updated the PR description to reflect the current state of the implementation.) |
|
Hi @aeppling — just following up on this one. I believe I've addressed all the points from your review: run_in_terminal added to detect_format() (the net-new fix) |
|
I hit the same #1425 gap independently and can confirm this PR closes it: on current For what it's worth, if a maintainer wants the minimal change to unblock #1425 independently of the larger format-detection refactor here, the one-liner is just adding matches!(tool_name, "runTerminalCommand" | "run_in_terminal" | "Bash" | "bash")I have that minimal version on my fork ( (Orthogonal note for anyone triaging the Copilot tool-name issues: #2574 covers the JetBrains host — camelCase |
|
Hi! I'm running into this issue in RTK 0.43.0 and noticed this PR appears to address it. Is it still being worked on? I'd be happy to help validate the fix if needed. Thanks! |
|
Thanks for the careful write-up of the two payload shapes. Both halves are on develop already: #3093 (merged 2026-07-26) added the Copilot IDE path for toolName run_in_terminal, and #3212 (merged 2026-08-02) made detect_format recognise run_in_terminal in VS Code Copilot Chat's snake_case payloads, which closed #1425, while transparent rewrite through modifiedArgs landed earlier in 4b0bbf2 and shipped in v0.42.3, which closed #1839. Those merges also reshaped HookFormat into VsCode, CopilotCli and CopilotIde, choosing the format from the payload shape rather than the event name casing, so the rename and the tests around it no longer apply to the current code. One leftover would make a good narrow PR: the repository's own .github/hooks/rtk-rewrite.json still says "rtk hook" with no copilot subcommand and lacks the "version": 1 key that init.rs now writes. Please comment or reopen if something here was missed. |
Summary
[Bug] rtk hook copilotdoes not trigger for VS Code Copilot Chat —"run_in_terminal"not recognized indetect_format()#1425 — Recognizerun_in_terminalfor VS Code Copilot ChatmodifiedArgs/updatedInputfor Copilot CLIWhat changed
The hook payload format depends entirely on the event name casing in the hook config:
"preToolUse"(camelCase)toolName/toolArgs(JSON string)modifiedArgs"PreToolUse"(PascalCase)tool_name/tool_inputhookSpecificOutput.updatedInputBoth paths verified on Copilot CLI 1.0.60 and VS Code 1.123.0 / Copilot Chat 0.51.0.
HookFormatvariants renamed to reflect payload format rather than host:SnakeCaseCmdtool_name: "bash"or"run_in_terminal"hookSpecificOutput.updatedInputCamelCaseCmdtoolName: "bash"+toolArgsmodifiedArgsSnakeCaseCmdcovers both VS Code Copilot Chat (always snake_case) and Copilot CLI with"PreToolUse"config.Bugs fixed in
.github/hooks/rtk-rewrite.json"PreToolUse"→"preToolUse"(PascalCase causedmodifiedArgsto be silently ignored)"rtk hook"→"rtk hook copilot"(missing subcommand made the hook a no-op)Notable findings
updatedInputworks correctly in VS Code 1.123.0 / Copilot Chat 0.51.0 — no infinite loopmodifiedArgsonly works with camelCase"preToolUse"config;hookSpecificOutput.updatedInputonly works with PascalCase"PreToolUse"— the two are not interchangeableTest plan
cargo fmt --all && cargo clippy --all-targets && cargo test— all passed"preToolUse"config):git status→modifiedArgs→rtk git statusexecuted ✓"PreToolUse"config):git status→hookSpecificOutput.updatedInput→rtk git statusexecuted ✓git status→hookSpecificOutput.updatedInput→rtk git statusexecuted, no loop ✓