Repository navigation
Description
Summary
rtk hook copilot is a silent no-op inside the JetBrains / IntelliJ GitHub Copilot plugin (CLion, IDEA, Rider, etc., agent mode). The IDE's terminal tool is named run_in_terminal and is delivered in the camelCase payload shape (toolName + toolArgs), which detect_format() only matches when toolName == "bash". As a result the hook fires but never rewrites anything, and rtk gain stays empty.
This is distinct from #1425 / PR #1800: those address the snake_case (tool_name) VS Code Chat path. PR #1800's new CamelCaseCmd branch still only matches toolName == "bash", so it does not fix the JetBrains IDE case.
There is also a second, host-side blocker (see "Host limitation" below) that means transparent modifiedArgs rewriting cannot work in this plugin at all today.
Environment
- rtk 0.42.2
- GitHub Copilot plugin for JetBrains (
github-copilot-intellij, core1.11.0-rc.x), agent mode, on CLion 2026.1, Linux - Hook installed at both
~/.copilot/hooks/rtk-rewrite.jsonand project.github/hooks/rtk-rewrite.json, eventpreToolUse
Hard evidence — the real payload
Captured by tee-ing the hook's stdin to a file. A terminal command from the agent produces:
{
"timestamp": 1781456705251,
"cwd": ".",
"toolName": "run_in_terminal",
"toolArgs": "{\"command\":\" cd /path/to/repo && git --no-pager log --oneline -20\",\"explanation\":\"Show local git history\",\"isBackground\":false}"
}Notes:
toolNameis camelCase and the value isrun_in_terminal, notbash.toolArgsis a JSON-encoded string containingcommand(plusexplanation,isBackgroundwhich must be preserved).- The hook also receives MCP tool calls here, e.g.
"toolName": "io.github.github/github-mcp-server/list_commits"— those should keep passing through.
Reproduce directly against the binary:
$ echo '{"toolName":"run_in_terminal","toolArgs":"{\"command\":\"git --no-pager log --oneline -20\"}"}' | rtk hook copilot
# (no output)
$ echo '{"toolName":"bash","tool_input":{"command":"git --no-pager log --oneline -20"}}' | rtk hook copilot
# also nothing for the snake_case tool_input shape
$ echo '{"tool_name":"bash","tool_input":{"command":"git --no-pager log --oneline -20"}}' | rtk hook copilot
{"hookSpecificOutput":{...,"updatedInput":{"command":"rtk git --no-pager log --oneline -20"}}} # only "bash" works
Root cause (code)
src/hooks/hook_cmd.rs, detect_format() — camelCase branch:
if let Some(tool_name) = v.get("toolName").and_then(|t| t.as_str()) {
if tool_name == "bash" { // <-- JetBrains sends "run_in_terminal"
...
}
return HookFormat::PassThrough;
}run_in_terminal is missing from the camelCase match. (PR #1800 keeps the same tool_name == "bash" condition in CamelCaseCmd, so it remains unfixed there.)
Host limitation — modifiedArgs is ignored in the JetBrains IDE
Even after recognizing run_in_terminal, transparent rewrite won't take effect in this plugin. The IDE agent host (copilot-agent/dist/main.js) invokes the hook and then inspects only permissionDecision:
let o = await ...hook(t, P3, {timestamp, cwd, toolName, toolArgs}, e);
for (let s of o) {
let c = s.output;
if (c && c.permissionDecision === deny)
return { permissionDecision: "deny", permissionDecisionReason: ... };
}modifiedArgs and hookSpecificOutput.updatedInput are never read (0 occurrences in main.js; they exist only in the bundled @github/copilot SDK, which this agent path does not use). So in the JetBrains IDE the only effective hook action is permissionDecision: "deny" (with a reason).
This means a complete fix needs a deny-with-suggestion path for the IDE: deny the raw command and surface the rtk-rewritten command in permissionDecisionReason, letting the model re-issue rtk … (which then passes through). rtk already advertises "deny-with-suggestion" for Copilot CLI, so the mechanism exists.
Suggested fix
- Recognize
run_in_terminal(camelCasetoolName) indetect_format()in addition tobash. - For the JetBrains/IDE case (where
modifiedArgsis ignored), respond withpermissionDecision: "deny"+ apermissionDecisionReasoncontaining the rewritten command, instead of (or in addition to)modifiedArgs. - Optionally cover other IDE tool names defensively. Note that
get_terminal_output(the "read terminal output" tool) carries no command, so it correctly needs no rewrite — onlyrun_in_terminaldoes.
Tool inventory (JetBrains Copilot built-ins, for reference)
run_in_terminal, get_terminal_output, read_file, create_file, insert_edit_into_file, replace_string_in_file, list_dir, file_search, grep_search, semantic_search, run_subagent, open_file, get_errors, ask_questions, validate_cves. Only run_in_terminal runs a shell command.
Activity
pszymkowiak commentedon Jun 14, 2026
🔍 Automated Triage
bughighSummary
rtk hook copilot silently no-ops in JetBrains Copilot plugin because
run_in_terminalis unrecognized in detect_format()'s camelCase branch; complete fix also requires a deny-with-suggestion response path since the IDE host ignores modifiedArgs entirely📁 Relevant files
src/hooks/hook_cmd.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
kreuzerkrieg commentedon Jun 14, 2026
Update: confirmed end-to-end + working PoC fix
Followed up with live testing on CLion 2026.1 (Copilot plugin core
1.11.0-rc.x). Three findings, all verified against the running agent.1. The IDE loads hooks only from
.github/hooks/(not~/.copilot/hooks/)The IntelliJ agent registers exactly one hook source:
There is no global/user hooks dir for the IDE —
~/.copilot/hooks/is Copilot-CLI-only. So a machine-global rtk hook silently does nothing in JetBrains IDEs; it must be committed/placed per-repo under.github/hooks/.2. The real payload uses camelCase
toolName: "run_in_terminal"Captured by tee-ing the hook's stdin:
{"timestamp":...,"cwd":".","toolName":"run_in_terminal", "toolArgs":"{\"command\":\" cd /repo && git --no-pager log --oneline -20\",\"explanation\":\"...\",\"isBackground\":false}"}This hits the camelCase branch of
detect_format(), which only matchedtoolName == "bash"→ no-op. (PR #1800'sCamelCaseCmdkeeps the same== "bash"condition, so it doesn't cover this either.)3. The IDE host honors only top-level
permissionDecision: "deny"modifiedArgs/updatedInputare ignored by the IntelliJ host (0 occurrences inmain.js; only present in the bundled@github/copilotSDK, which this agent path doesn't use). The hook output isJSON.parse(stdout)and onlyoutput.permissionDecision === "deny"is acted upon. So transparent rewrite is impossible here — deny-with-suggestion is the only mechanism that works.PoC fix (proof of concept — verified working)
Implemented locally in
src/hooks/hook_cmd.rs:detect_format()recognizes camelCaserun_in_terminal→ newCopilotIdevariant (camelCasebashstays on the existing CLImodifiedArgspath — no regression).handle_copilot_ide()emits a top-level deny-with-suggestion when a beneficial rewrite exists; stays silent (command runs) for already-rtk, non-rewritable, and MCP tool calls.Added unit tests (detection, deny-with-suggestion, passthrough cases,
bashno-regression); fullhook_cmdsuite passes (82/82).End-to-end verification in CLion
Proof-log of two consecutive
run_in_terminalcalls in one turn:The agent was denied on the raw command, read the suggestion, and re-issued the
rtk …form ~4s later.rtk gainwent from "No tracking data yet" to tracking the commands.Note / open design question
Deny-with-suggestion means each rewritable command is denied once and retried — slightly noisier than transparent rewrite, but it's the only option until the IntelliJ host adds
modifiedArgs/updatedInputsupport. Happy to open a PR with the above if the maintainers are OK with the deny-with-suggestion approach for the IDE path (gated ontoolName == "run_in_terminal", leaving Copilot CLI'sbash→modifiedArgspath untouched).lntutor commentedon Jul 20, 2026
I am working on this against current develop. I will add a dedicated camelCase
run_in_terminalhost path that emits top-level deny-with-suggestion responses, preserve Copilot CLIbashmodifiedArgs behavior, and cover rewrite, deny, defer, and passthrough cases.docs(hooks): clarify CopilotCli schema is now legacy/host-specific, n…
docs(hooks): clarify CopilotCli schema is now legacy/host-specific, n…
docs(hooks): clarify CopilotCli schema is now legacy/host-specific, n…