feat(copilot): capture Copilot sessions from VS Code agent hooks (Preview)#1459
Open
Soph wants to merge 5 commits into
Open
feat(copilot): capture Copilot sessions from VS Code agent hooks (Preview)#1459Soph wants to merge 5 commits into
Soph wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5a07d35. Configure here.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the existing Copilot CLI hook-capture integration to also capture GitHub Copilot sessions launched via VS Code agent hooks (Preview) by managing an additional VS Code-native hook config file under .github/hooks/.
Changes:
- Add VS Code hook file management (
.github/hooks/entire-vscode.json) for Copilot VS Code agent hooks. - Update Copilot hook install/uninstall/detection to consider the VS Code hook file alongside
entire.json. - Add unit tests and documentation updates covering the new VS Code hook file behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new Copilot (VS Code) hook config location and support statement. |
| cmd/entire/cli/agent/copilotcli/vscode_hooks.go | Implements install/uninstall/detect for the VS Code-native Copilot hook file. |
| cmd/entire/cli/agent/copilotcli/vscode_hooks_test.go | Adds unit tests for VS Code hook file install/uninstall behavior and preservation rules. |
| cmd/entire/cli/agent/copilotcli/hooks.go | Wires VS Code hook file management into existing Copilot CLI hook lifecycle. |
| cmd/entire/cli/agent/copilotcli/AGENT.md | Documents why a separate VS Code hook file is required and how it behaves. |
…view) Copilot in VS Code uses VS Code's agent hooks system, which auto-discovers .github/hooks/*.json but reads Copilot CLI configs by converting lowerCamelCase event names to PascalCase. The capture-critical turn hooks (userPromptSubmitted, agentStop) convert to names that are not real VS Code events, so they never fire from entire.json inside VS Code. InstallHooks now writes a second dedicated file, .github/hooks/entire-vscode.json, registering only the two turn events whose names don't round-trip (UserPromptSubmit -> user-prompt-submitted, Stop -> agent-stop). The other events VS Code does deliver from entire.json are left untouched to avoid double-firing. VS Code uses the "command" field; the shared "entire hooks copilot-cli <verb>" handlers already parse both payload shapes (see compat.go). UninstallHooks removes the Entire entries from the VS Code file and deletes it when nothing user-owned remains; AreHooksInstalled now also considers the VS Code file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 6ed1f960754b
Both callers (installVSCodeHooks, uninstallVSCodeHooks) guarantee a non-nil rawFile before calling, so the guard was unreachable. Document the precondition on the helper instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 953463d49974
- Register both agent-stop AND session-end under VS Code's single "Stop" event. validateVSCodeEvent routes terminal Stop payloads to session-end and rejects them for agent-stop, so registering only agent-stop dropped SessionEnd for VS Code-driven sessions. The non-matching handler no-ops. - Include VS Code hook additions in the count InstallHooks returns, so a fresh entire-vscode.json write is reported as an install rather than "already installed". - On uninstall, preserve unknown top-level fields: only delete entire-vscode.json when no hooks remain AND no user-added top-level keys exist, instead of deleting unconditionally. Updates tests for the two Stop handlers and adds top-level-field preservation coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: a6b05de34ff9
eb51e1f to
ae4bf07
Compare
Verified against VS Code's documented hook schema (https://code.visualstudio.com/docs/copilot/customization/hooks): - Preserve the optional per-entry fields VS Code supports (windows/linux/osx, cwd, env, timeout) so user-authored entries survive a round-trip rewrite instead of being dropped. Note timeout is in seconds and spelled "timeout", not the Copilot CLI's "timeoutSec". - Drop the top-level "version" field: it is not part of the VS Code schema, so a fresh entire-vscode.json is just {"hooks": {...}}. Pre-existing version fields from older builds are still tolerated and treated as non-user so uninstall cleanup keeps working. Updates AGENT.md and adds round-trip coverage for the per-entry fields and the absent version field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 90c6e0de528a
installVSCodeHooks wrote entire-vscode.json on every call. When all managed hooks are already present (count == 0), the rewrite reproduces identical content and can churn a user's formatting on an idempotent `entire enable`. Return early in that case, mirroring InstallHooks's count == 0 path. Under force the canonical verbs are always re-added, so count > 0 there — count == 0 strictly means nothing changed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 9051354dae1e
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

https://entire.io/gh/entireio/cli/trails/601
Summary
Adds capture support for GitHub Copilot sessions driven from VS Code's agent hooks (Preview), on top of the existing Copilot CLI support.
Why a separate hook file
VS Code auto-discovers
.github/hooks/*.jsonand reads Copilot CLI configs by converting lowerCamelCase event names to PascalCase (userPromptSubmitted→UserPromptSubmitted,agentStop→AgentStop). Those converted names are not real VS Code events, so the capture-critical turn hooks never fire fromentire.jsoninside VS Code.The events whose converted names do line up with a real VS Code event (
sessionStart,subagentStop,preToolUse,postToolUse) are already delivered fromentire.json. So the new.github/hooks/entire-vscode.jsonregisters only the two that don't round-trip:UserPromptSubmituser-prompt-submittedStopagent-stopVS Code uses the
commandfield (notbash); the sharedentire hooks copilot-cli <verb>handlers already parse both payload shapes (seecompat.go).Changes
hooks.go(from gist):InstallHooks/UninstallHooksnow also manage the VS Code file;AreHooksInstalledconsiders it too.vscode_hooks.go(new): the install/uninstall/detection implementation. Round-trips unknown fields and event types, removes only Entire-managed entries on uninstall, and deletesentire-vscode.jsonwhen nothing user-owned remains.vscode_hooks_test.go(new): fresh install, idempotency, force reinstall, user-hook preservation, file deletion when empty, and end-to-endInstallHooks/UninstallHookscoverage.README.md/AGENT.md(from gist): docs.Testing
mise run fmt && mise run lint— cleanmise run test— all 6458 unit tests pass🤖 Generated with Claude Code
Note
Low Risk
Scoped to Copilot hook file management under
.github/hooks/with tests; reuses existing copilot-cli hook handlers and payload parsing in compat.go.Overview
Adds GitHub Copilot in VS Code (agent hooks Preview) to the same
entire enable/entire disableflow as Copilot CLI, without changing how CLI hooks inentire.jsonwork.New hook file
.github/hooks/entire-vscode.jsonregisters onlyUserPromptSubmitandStopwith VS Code’scommandfield (not CLIbash), because VS Code’s PascalCase mapping from CLI event names never fires the turn hooks fromentire.json. Other lifecycle events still come fromentire.jsoninside VS Code to avoid double-firing. Install/uninstall preserves user hooks and unknown JSON fields; uninstall deletes the file when only Entire entries remain.hooks.gocalls the new VS Code install/uninstall helpers and treats the VS Code file as part of “hooks installed” detection when the CLI file is missing or unreadable.Docs in README and AGENT.md document the second hook location and Copilot VS Code support.
vscode_hooks_test.gocovers idempotency, force reinstall, user-hook preservation, and end-to-endInstallHooks/UninstallHooks.Reviewed by Cursor Bugbot for commit 5a07d35. Configure here.