You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 82c19ec
Browse filesBrowse the repository at this point in the historyBrowse files
Token Goat Test
committed
fix(copilot): wire sessionStart so Copilot CLI is told token-goat exists
sessionStart was the one Copilot event hard-coded to return {} without
calling token-goat. The comment justified it by claiming token-goat has no
internal session_start handler; hooks_session_start.ts has emitted the
command-routing reminder for a long time, and every other harness receives
it. Copilot sessions alone were never told the commands exist.
sessionStart is also the only channel that lands before the model picks its
first read tool, so it is where the reminder has to go. install --copilot
now registers it and the shim returns the handler's context as
{additionalContext}.
Verified live against Copilot CLI 1.0.77 using a canary that appears only in
the reminder: with the hook wired, a session answers "131072,
boundSymbolBody"; with sessionStart removed and nothing else changed, the
same question in the same directory answers ABSENT. An earlier probe that
simply asked whether it knew token-goat was discarded as leading -- the
model invented plausible commands in both arms.
github/copilot-cli#2142 (sessionStart additionalContext discarded) would
have made this dead wiring; it was fixed months before 1.0.77, and its
companion multi-extension overwrite bug hit runtime extension hooks, not
this config-file hooks.json path.
Measured 360 ms once per session against Copilot's 60 s timeout, and stdout
stays pure JSON on every malformed payload, so the fail-closed deny-all
behaviour is unaffected.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,11 @@ All notable changes to Token-Goat are documented in this file. Format follows Ke
4
4
5
5
## [Unreleased]
6
6
7
+
## [2.6.24] - 2026-08-05
8
+
9
+
### Fixed
10
+
- **Copilot CLI now gets the token-goat routing reminder at session start, so it stops forgetting the commands exist.** Copilot was the only supported harness where `sessionStart` was hard-wired to do nothing. The reason given in the code was that token-goat had no session-start handler — untrue for a long time, and the reason Copilot sessions alone were never told token-goat was available. `install --copilot` now registers `sessionStart` and the shim returns the reminder as `additionalContext`. Verified against Copilot CLI 1.0.77 with a canary that appears only in the reminder: wired, a session answers with it; with the hook removed and nothing else changed, the same question in the same directory answers that it has no such note. The upstream bug that would have made this pointless ([github/copilot-cli#2142](https://github.com/github/copilot-cli/issues/2142), `additionalContext` discarded) was fixed months ago, and its companion multi-extension bug never applied to this config-file hook path. If you installed the Copilot bridge before this release, re-run `token-goat install --copilot` and restart Copilot CLI — it caches hook config at session start. See [src/bridges/copilot_cli.ts](src/bridges/copilot_cli.ts), [src/bridges/copilot_cli_install.ts](src/bridges/copilot_cli_install.ts).
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -403,9 +403,9 @@ This writes `.pi/extensions/token-goat.ts` in the current project only. Remove i
403
403
token-goat install --copilot
404
404
```
405
405
406
-
The `--copilot` flag patches Claude Code and registers a Copilot CLI hook config: `~/.copilot/hooks/token-goat.json` (a `{ version, hooks }` file registering `preToolUse`, `postToolUse`, `preCompact`, `agentStop`, `subagentStop`, and `userPromptSubmitted`, per Copilot's own [hooks reference](https://docs.github.com/en/copilot/reference/hooks-reference)) plus the shim script it points at, `~/.copilot/hooks/token-goat-shim.js`. Unlike Codex, Copilot's event names and response schema (`permissionDecision`/`modifiedArgs` for `preToolUse`, `modifiedResult`/`additionalContext` for `postToolUse`, `decision`/`reason` for `agentStop`/`subagentStop`) genuinely differ from Claude Code's, so the shim translates rather than passes through.
406
+
The `--copilot` flag patches Claude Code and registers a Copilot CLI hook config: `~/.copilot/hooks/token-goat.json` (a `{ version, hooks }` file registering `sessionStart`, `preToolUse`, `postToolUse`, `preCompact`, `agentStop`, `subagentStop`, and `userPromptSubmitted`, per Copilot's own [hooks reference](https://docs.github.com/en/copilot/reference/hooks-reference)) plus the shim script it points at, `~/.copilot/hooks/token-goat-shim.js`. Unlike Codex, Copilot's event names and response schema (`permissionDecision`/`modifiedArgs` for `preToolUse`, `modifiedResult`/`additionalContext` for `postToolUse`, `decision`/`reason` for `agentStop`/`subagentStop`) genuinely differ from Claude Code's, so the shim translates rather than passes through.
407
407
408
-
What works: **bash output compression and re-read denial** (`preToolUse` returns `modifiedArgs` or `permissionDecision: "deny"`), **image shrinking and post-edit indexing** (`postToolUse` returns `additionalContext`), and **stop-hallucination logging** (`agentStop`/`subagentStop` map a token-goat `deny` onto `decision: "block"`, everything else onto `decision: "allow"`). `preCompact` and `userPromptSubmitted` are notification-only on real Copilot CLI, per its docs: Copilot never reads a response body for either, so token-goat's compaction manifest and prompt-context hints have no surfacing channel there. The shim still calls through for both so token-goat's internal side effects keep running, but nothing gets injected back into the agent. Copilot's built-in tool names (`view`, `edit`, `create`, `bash`/`powershell`, `web_fetch`, `grep`, `glob`, `memory`, and MCP-server calls) are remapped onto token-goat's internal names where a clear match exists (`view`→Read, `edit`→Edit, `create`→Write, `bash`/`powershell`→Bash, `web_fetch`→WebFetch, `grep`→Grep, `glob`→Glob); `memory`, `task`, `ask_user`, and MCP tool calls pass through unmapped and simply no-op.
408
+
What works: **the command-routing reminder** (`sessionStart` returns `additionalContext`, so Copilot is told token-goat exists before it picks its first read tool — this is the one channel that lands ahead of that decision), **bash output compression and re-read denial** (`preToolUse` returns `modifiedArgs` or `permissionDecision: "deny"`), **image shrinking and post-edit indexing** (`postToolUse` returns `additionalContext`), and **stop-hallucination logging** (`agentStop`/`subagentStop` map a token-goat `deny` onto `decision: "block"`, everything else onto `decision: "allow"`). `preCompact` and `userPromptSubmitted` are notification-only on real Copilot CLI, per its docs: Copilot never reads a response body for either, so token-goat's compaction manifest and prompt-context hints have no surfacing channel there. The shim still calls through for both so token-goat's internal side effects keep running, but nothing gets injected back into the agent. Copilot's built-in tool names (`view`, `edit`, `create`, `bash`/`powershell`, `web_fetch`, `grep`, `glob`, `memory`, and MCP-server calls) are remapped onto token-goat's internal names where a clear match exists (`view`→Read, `edit`→Edit, `create`→Write, `bash`/`powershell`→Bash, `web_fetch`→WebFetch, `grep`→Grep, `glob`→Glob); `memory`, `task`, `ask_user`, and MCP tool calls pass through unmapped and simply no-op.
409
409
410
410
No ambient environment variable documents "this process is running under Copilot CLI" the way Codex/opencode set one, so the shim sets `TOKEN_GOAT_HARNESS_OVERRIDE=copilot_cli` itself before calling `token-goat hook` (same workaround `--pi` uses). Install also writes a token-goat routing block into `~/.copilot/copilot-instructions.md` (the same delimited-block gate written to `~/.claude/CLAUDE.md` and `~/.codex/AGENTS.md`), merged idempotently so any hand-written content outside the markers is preserved byte-for-byte. To install for one project instead of user scope: `token-goat install --copilot --local` (writes `.github/hooks/token-goat.json` and `.github/copilot-instructions.md` in the current project). To remove: `token-goat uninstall --copilot`.
"Copilot CLI has a real 'notification' hook event, but copilot_cli.ts's COPILOT_TO_TG_EVENT deliberately leaves it (and sessionEnd/postToolUseFailure/subagentStart/errorOccurred/permissionRequest) unimplemented rather than guessed at",
113
121
},
114
-
{
115
-
events: ['session_start'],
116
-
reason: 'COPILOT_TO_TG_EVENT has no session-start mapping wired yet -- left unimplemented rather than guessed at',
0 commit comments