Skip to content

feat(copilot): add agentStop/subagentStop hook events and prompt-file agent frontmatter - #1896

Merged
dyoshikawa merged 1 commit into
mainfrom
resolve-scrap-issue-1880-copilot-hooks
Jun 16, 2026
Merged

feat(copilot): add agentStop/subagentStop hook events and prompt-file agent frontmatter#1896
dyoshikawa merged 1 commit into
mainfrom
resolve-scrap-issue-1880-copilot-hooks

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Follow-up on GitHub Copilot upstream updates for the cloud coding-agent target (copilot, .github/hooks/). This does not touch copilotcli, which already mapped these events.

Part A — agentStop / subagentStop hook events

GitHub now documents an eight-event surface for .github/hooks/*.json (sessionStart, sessionEnd, userPromptSubmitted, preToolUse, postToolUse, agentStop, subagentStop, errorOccurred).

  • Added stop and subagentStop to COPILOT_HOOK_EVENTS.
  • Added stop → agentStop and subagentStop → subagentStop to CANONICAL_TO_COPILOT_EVENT_NAMES (the reverse map is derived and auto-updates).
  • subagentStart is intentionally not added — it is not part of the documented cloud-agent surface ( in the matrix).
  • copilot-hooks.ts reads these constants generically, so no adapter logic change was needed.

Part B — prompt-file agent frontmatter

VS Code prompt-file frontmatter now uses agent (ask | agent | plan | custom agent name), replacing the deprecated mode.

  • Added first-class agent: z.optional(z.string()) to CopilotCommandFrontmatterSchema.
  • mode is still accepted for backward compatibility and is migrated to agent on import; when both are present, the explicit agent value wins.
  • agent is preserved on both generate and import via the copilot rulesync section.

Docs & tests

  • Flipped the Copilot column to ✅ for the stop and subagentStop rows in docs/reference/file-formats.md (left subagentStart as ); updated the hook-mapping prose and the commands frontmatter example; re-synced skills/rulesync/.
  • Extended the copilot e2e generate case to assert agentStop, added a dedicated e2e test for stop/subagentStopagentStop/subagentStop.
  • Added round-trip unit tests in copilot-hooks.test.ts (both directions) and copilot-command.test.ts (modeagent migration, explicit-agent precedence, and agent round-trip).

Validation evidence

Verification

pnpm cicheck is fully green (fmt, oxlint, typecheck, 6414 tests across 267 files, cspell, secretlint, skill-docs sync).

Closes #1880

🤖 Generated with Claude Code

… agent frontmatter

Part A: Extend the Copilot cloud coding-agent hook surface (.github/hooks/) to the upstream-documented eight events by mapping canonical `stop` to `agentStop` and `subagentStop` to `subagentStop`. `subagentStart` remains unsupported as it is not part of the documented cloud-agent surface.

Part B: Add first-class `agent` prompt-file frontmatter for Copilot commands (VS Code values ask/agent/plan/custom), keeping the deprecated `mode` accepted and migrating it to `agent` on import (explicit `agent` wins).

Closes #1880

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dyoshikawa
dyoshikawa merged commit 44ddc9c into main Jun 16, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

@dyoshikawa
dyoshikawa deleted the resolve-scrap-issue-1880-copilot-hooks branch June 16, 2026 09:53
@dyoshikawa dyoshikawa mentioned this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up GitHub Copilot upstream updates: agentStop/subagentStop hook events and prompt-file agent frontmatter

2 participants