-
Notifications
You must be signed in to change notification settings - Fork 2
feat(vscode-copilot): agent hooks for Copilot Chat in VS Code #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
svadrutk
merged 12 commits into
main
from
implement-agenthooks-support-for-vscode-copilot
Sep 2, 2026
+2,028
−132
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
821c73d
feat(vscode-copilot): provider identity, codec delegation, capability…
svadrutk f1e0339
feat(vscode-copilot): one file, two runtimes
svadrutk ad3ad5b
docs(vscode-copilot): quirk registry entries and doc corrections
svadrutk 6fa5611
fix(tools): classify VS Code Copilot Chat tool names
svadrutk ea9d713
test(vscode-copilot): ground-truth fixtures from a live capture session
svadrutk 4d45818
fix(vscode-copilot): address review feedback
svadrutk 0e91037
fix(vscode-copilot): report ignored post-tool context
svadrutk c303db3
fix(vscode-copilot): retain documented post-tool context
svadrutk 60b6a20
fix(vscode-copilot): parse JSONC trailing commas
svadrutk 64a288b
fix(vscode-copilot): decouple codecs and align runtime behavior
svadrutk 1d6441b
refactor(copilot): identify CLI provider explicitly
svadrutk e229673
fix(detection): recognize Claude Code marker
svadrutk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"timestamp":"2026-08-29T17:29:22.255Z","hook_event_name":"PreToolUse","session_id":"a1b2c3d4-e5f6-4a7b-8c9d-000000000001","transcript_path":"/work/vscode/workspaceStorage/0123456789abcdef0123456789abcdef/GitHub.copilot-chat/transcripts/a1b2c3d4-e5f6-4a7b-8c9d-000000000001.jsonl","tool_name":"read_file","tool_input":{"filePath":"/work/repo/README.md","startLine":1,"endLine":80},"tool_use_id":"call_01ABCDEFGHIJKLMNOPQRST__vscode-1700000000000","cwd":"/work/repo"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"timestamp":"2026-08-29T17:29:20.031Z","hook_event_name":"SessionStart","session_id":"a1b2c3d4-e5f6-4a7b-8c9d-000000000001","transcript_path":"/work/vscode/workspaceStorage/0123456789abcdef0123456789abcdef/GitHub.copilot-chat/transcripts/a1b2c3d4-e5f6-4a7b-8c9d-000000000001.jsonl","source":"new","model":"auto","cwd":"/work/repo"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"timestamp":"2026-08-29T17:29:39.042Z","hook_event_name":"Stop","session_id":"a1b2c3d4-e5f6-4a7b-8c9d-000000000001","transcript_path":"/work/vscode/workspaceStorage/0123456789abcdef0123456789abcdef/GitHub.copilot-chat/transcripts/a1b2c3d4-e5f6-4a7b-8c9d-000000000001.jsonl","stop_hook_active":false,"cwd":"/work/repo"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package agenthooks | ||
|
|
||
| import "encoding/json" | ||
|
|
||
| // VS Code Copilot Chat dialect: byte-for-byte the Claude Code wire shape on | ||
| // stdin (snake_case fields, PascalCase event names) and almost the same on | ||
| // stdout, so both edges delegate — decode via decodeClaudeAs, encode via | ||
| // encodeClaude plus the two placement fixups below. | ||
| // | ||
| // Where VS Code reads each field was verified against the extension source | ||
| // rather than the docs (chatHookService.ts, toolCallingLoop.ts, | ||
| // hookResultProcessor.ts); the reference contradicts itself on Stop nesting. | ||
|
|
||
| // encodeVSCode writes encodeClaude's body with the two keys VS Code reads from | ||
| // a different place than Claude Code does: | ||
| // | ||
| // - Stop / SubagentStop: the block verdict rides decision/reason NESTED in | ||
| // hookSpecificOutput (toolCallingLoop reads it there). PostToolUse and | ||
| // UserPromptSubmit keep the top-level placement encodeClaude already uses. | ||
| // - SubagentStart: additionalContext is honored, which Claude Code does not | ||
| // do, so encodeClaude has no case for it. | ||
| // | ||
| // The nested hookEventName must match the invoking hook type: _toHookResult | ||
| // strips the whole hookSpecificOutput when it mismatches (and discards the | ||
| // entire result when a TOP-LEVEL hookEventName mismatches, which is why one is | ||
| // never emitted). base.NativeName is the VS Code name, so it is correct today. | ||
| func encodeVSCode(base *Event, d decisionCore) (wireResponse, error) { | ||
| wire, err := encodeClaude(base, d) | ||
| if err != nil { | ||
| return wireResponse{}, err | ||
| } | ||
| switch base.Kind { | ||
| case KindSubagentStart, KindStop, KindSubagentStop: | ||
| default: | ||
| return wire, nil | ||
| } | ||
|
|
||
| var out map[string]any | ||
| if err := json.Unmarshal(wire.Stdout, &out); err != nil { | ||
| return wireResponse{}, err | ||
| } | ||
| hso, _ := out["hookSpecificOutput"].(map[string]any) | ||
| if hso == nil { | ||
| hso = map[string]any{} | ||
| } | ||
| switch base.Kind { | ||
| case KindSubagentStart: | ||
| if ctx := joinContext(d.context); ctx != "" { | ||
| hso["additionalContext"] = ctx | ||
| } | ||
| case KindStop, KindSubagentStop: | ||
| if v, ok := out["decision"]; ok { | ||
| hso["decision"] = v | ||
| delete(out, "decision") | ||
| if reason, ok := out["reason"]; ok { | ||
| hso["reason"] = reason | ||
| delete(out, "reason") | ||
| } | ||
| } | ||
| } | ||
| if len(hso) == 0 { | ||
| return wire, nil | ||
| } | ||
| hso["hookEventName"] = base.NativeName | ||
| out["hookSpecificOutput"] = hso | ||
|
|
||
| b, err := json.Marshal(out) | ||
| if err != nil { | ||
| return wireResponse{}, err | ||
| } | ||
| return wireResponse{Stdout: b}, nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.