Skip to content

feat(copilot): capture Copilot sessions from VS Code agent hooks (Preview)#1459

Open
Soph wants to merge 5 commits into
mainfrom
copilot-vscode-hooks
Open

feat(copilot): capture Copilot sessions from VS Code agent hooks (Preview)#1459
Soph wants to merge 5 commits into
mainfrom
copilot-vscode-hooks

Conversation

@Soph

@Soph Soph commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

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/*.json and reads Copilot CLI configs by converting lowerCamelCase event names to PascalCase (userPromptSubmittedUserPromptSubmitted, agentStopAgentStop). Those converted names are not real VS Code events, so the capture-critical turn hooks never fire from entire.json inside VS Code.

The events whose converted names do line up with a real VS Code event (sessionStart, subagentStop, preToolUse, postToolUse) are already delivered from entire.json. So the new .github/hooks/entire-vscode.json registers only the two that don't round-trip:

VS Code event Entire verb Lifecycle
UserPromptSubmit user-prompt-submitted TurnStart
Stop agent-stop TurnEnd → checkpoint

VS Code uses the command field (not bash); the shared entire hooks copilot-cli <verb> handlers already parse both payload shapes (see compat.go).

Changes

  • hooks.go (from gist): InstallHooks / UninstallHooks now also manage the VS Code file; AreHooksInstalled considers 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 deletes entire-vscode.json when nothing user-owned remains.
  • vscode_hooks_test.go (new): fresh install, idempotency, force reinstall, user-hook preservation, file deletion when empty, and end-to-end InstallHooks/UninstallHooks coverage.
  • README.md / AGENT.md (from gist): docs.

Testing

  • mise run fmt && mise run lint — clean
  • mise 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 disable flow as Copilot CLI, without changing how CLI hooks in entire.json work.

New hook file .github/hooks/entire-vscode.json registers only UserPromptSubmit and Stop with VS Code’s command field (not CLI bash), because VS Code’s PascalCase mapping from CLI event names never fires the turn hooks from entire.json. Other lifecycle events still come from entire.json inside 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.go calls 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.go covers idempotency, force reinstall, user-hook preservation, and end-to-end InstallHooks / UninstallHooks.

Reviewed by Cursor Bugbot for commit 5a07d35. Configure here.

Copilot AI review requested due to automatic review settings June 18, 2026 08:42
@Soph Soph requested a review from a team as a code owner June 18, 2026 08:42

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks.go
Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks.go
Comment thread cmd/entire/cli/agent/copilotcli/hooks.go
Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks_test.go Outdated
Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks_test.go
Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks_test.go
Comment thread cmd/entire/cli/agent/copilotcli/vscode_hooks_test.go
Soph and others added 3 commits June 18, 2026 11:07
…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
@Soph Soph force-pushed the copilot-vscode-hooks branch from eb51e1f to ae4bf07 Compare June 18, 2026 09:07
Soph and others added 2 commits June 18, 2026 11:38
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants