Skip to content

Support VS Code-compatible Copilot hook payloads#888

Open
peyton-alt wants to merge 4 commits intomainfrom
vscode-copilot-compat
Open

Support VS Code-compatible Copilot hook payloads#888
peyton-alt wants to merge 4 commits intomainfrom
vscode-copilot-compat

Conversation

@peyton-alt
Copy link
Copy Markdown
Contributor

@peyton-alt peyton-alt commented Apr 9, 2026

Summary

VS Code Insiders can auto-load .github/hooks/entire.json, but its Copilot hook payload shape differs slightly from Copilot CLI. Entire was hard-failing on those differences, which surfaced as hook warnings in VS Code.

This change adds compatibility parsing for Copilot-like hook payloads so Entire continues to track sessions and checkpoints when VS Code invokes the same hook file.

What changed

  • added a normalization layer for Copilot hook payloads
  • accepted both numeric and RFC3339 string timestamp
  • accepted both transcriptPath and transcript_path
  • switched Copilot lifecycle parsing to use the normalized envelope
  • added unit coverage for VS Code-shaped payloads
  • added integration coverage for direct copilot-cli hook commands and generated .github/hooks/entire.json commands

Verification

  • go test ./cmd/entire/cli/agent/copilotcli -run 'TestDetectHookHost|TestParseHookEnvelope_AcceptsAlternateTranscriptPathAndTimestampFormats|TestParseHookEvent_.*VSCode|TestParseHookEvent_PassthroughHooks_VSCodePayload_ReturnNil' -count=1
  • go test -tags=integration ./cmd/entire/cli/integration_test -run 'TestCopilotVSCodeHooks_' -count=1
  • mise run test:ci

User impact

  • VS Code should no longer surface schema-mismatch hook warnings for Entire’s Copilot hook file
  • Entire session tracking and checkpointing continue to work through the validated VS Code hook lifecycle path

Note

Medium Risk
Medium risk because it changes how Copilot hook stdin is parsed and how lifecycle events are constructed, which can affect session/checkpoint creation across agents. Behavior is guarded by host detection/validation and covered by new unit + integration tests.

Overview
Adds a normalized Copilot hook envelope (compat.go) that accepts both Copilot CLI and VS Code payload variants (RFC3339 or millis timestamp, transcriptPath or transcript_path) and classifies the payload source.

Refactors CopilotCLIAgent.ParseHookEvent to parse this envelope once, use the provided timestamp (with time.Now() fallback), and silently skip VS Code payloads whose hookEventName is unknown or doesn’t match the invoked hook subcommand.

Expands coverage with new unit tests for host/timestamp parsing and VS Code lifecycle cases, plus new integration tests that run copilot-cli hooks directly and via generated .github/hooks/entire.json commands; updates the integration HookRunner to support agent-specific hooks and running installed shell hook commands.

Reviewed by Cursor Bugbot for commit e0a2c6b. Configure here.

Copilot AI review requested due to automatic review settings April 9, 2026 05:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a compatibility layer so Entire can parse and handle VS Code (Insiders) Copilot hook payloads that differ slightly from Copilot CLI, preventing hard failures and preserving session/checkpoint tracking.

Changes:

  • Introduces a normalized “hook envelope” parser that accepts alternate timestamp and transcript path formats.
  • Updates Copilot CLI lifecycle hook parsing to consume the normalized envelope.
  • Adds unit + integration tests covering VS Code-shaped payloads and generated .github/hooks/entire.json commands.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cmd/entire/cli/integration_test/hooks.go Extends integration hook runner to execute agent-specific hooks and to execute generated shell hook commands.
cmd/entire/cli/integration_test/copilot_vscode_hooks_test.go Adds integration coverage for VS Code-compatible Copilot hook payloads and generated hook commands.
cmd/entire/cli/agent/copilotcli/lifecycle.go Switches Copilot lifecycle parsing to read from a normalized hook envelope (incl. timestamp/transcript variants).
cmd/entire/cli/agent/copilotcli/lifecycle_test.go Adds unit tests for VS Code-shaped payload parsing across lifecycle events and pass-through hooks.
cmd/entire/cli/agent/copilotcli/compat.go Adds hook payload normalization (host detection, alternate keys, timestamp parsing).
cmd/entire/cli/agent/copilotcli/compat_test.go Adds focused unit tests for host detection and envelope parsing of alternate fields.

@peyton-alt peyton-alt force-pushed the vscode-copilot-compat branch 2 times, most recently from e307d71 to 7dbe3a7 Compare April 9, 2026 23:38
peyton-alt and others added 3 commits April 9, 2026 17:11
Entire-Checkpoint: 8a4fafbfc826
Entire-Checkpoint: 73d1f5733517
- Add VS Code hookEventName constants from official docs
- Validate hookEventName matches the invoked CLI hook for VS Code
  payloads; silently skip mismatches instead of processing them
- Fix test fixtures: VS Code sends "Stop" (not "SessionEnd") for both
  agent-stop and session-end hooks
- Strengthen assertNoParseFailure to catch warning text in stderr
- Refactor ParseHookEvent to read envelope once and dispatch to builders

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: b42218d939a1
@peyton-alt peyton-alt force-pushed the vscode-copilot-compat branch from 9f9a5da to b4792a4 Compare April 10, 2026 00:11
@peyton-alt
Copy link
Copy Markdown
Contributor Author

@BugBot review

- Guard parseTimestamp against JSON null and millis==0, both of which
  produced epoch time instead of triggering the time.Now() fallback
- Guard isJSONNumber against null so detectHookHost doesn't misclassify
  null-timestamp payloads as HostCopilotCLI
- Add regression tests for null, zero, and missing timestamp cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: da55307ea9df
@peyton-alt
Copy link
Copy Markdown
Contributor Author

@BugBot review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e0a2c6b. Configure here.

@peyton-alt peyton-alt marked this pull request as ready for review April 10, 2026 00:38
@peyton-alt peyton-alt requested a review from a team as a code owner April 10, 2026 00:38
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