Repository navigation
Description
Part of #240. Builds on #242 and #241. Packaging: #227 (VS Code/Copilot row). CI: the existing secfoo GitHub Action (action.yml, #108).
What GitHub Copilot offers (checked against the docs on 2026-12-03)
Sources: Hooks reference, Use hooks, VS Code hooks, Plugins, Customize the agent environment.
-
One hook system across Copilot CLI, VS Code agent mode, the GitHub Copilot app and Copilot cloud agent. JetBrains support was not confirmed; check it.
-
Config:
.github/hooks/*.json(repo),~/.copilot/hooks/(user, or$COPILOT_HOME/hooks/), inlinehooksin.github/copilot/settings.json, pluginhooks.json, policy files (CLI only). Copilot also reads.claude/settings.json. -
Format:
{"version": 1, "hooks": {"preToolUse": [{"type": "command", "bash": "…", "powershell": "…", "timeoutSec": 30}]}}The CLI also accepts
exec+args(no shell). Use that wherever supported. DefaulttimeoutSecis 30. -
Events (camelCase):
preToolUse:permissionDecisionallow|deny|ask.askbecomes deny in the cloud agent. Non-zero exit denies, but timeouts fail open.postToolUse:additionalContext, cannot undo.agentStop/subagentStop:decision: "block"forces another turn, with a cap of 8.- Also
sessionStart,sessionEnd,errorOccurred. - PascalCase names select a VS Code-compatible snake_case payload. Pick one form and test it.
-
Cloud agent:
- Reads hooks only from
.github/hooks/*.jsonon the default branch. - Setup runs from
.github/workflows/copilot-setup-steps.yml. The job must be namedcopilot-setup-steps. Runners are Ubuntu x64 or Windows only, and the maximum timeout is 59 min. - By default only GitHub and Copilot hostnames are reachable, so a portal push fails unless an admin allowlists the portal host.
- Reads hooks only from
-
Plugins: Agent Plugins 1.0
plugin.json. Hooks live incom.github.copilot/hooks/hooks.json, skills inskills/<name>/SKILL.md, MCP servers inmcp.json. Distribution is through amarketplace.json; the built-in marketplace isawesome-copilot.
Recipe mapping
| Recipe | Copilot event | Behaviour |
|---|---|---|
commit-guard |
preToolUse on the shell tool |
permissionDecision: "deny" + reason. Set timeoutSec above the recipe budget, because the 30 s default fails open |
turn-review |
agentStop |
decision: "block" with findings, loop-guarded (#242) |
dependency-watch etc. |
postToolUse |
Start in the background. Return additionalContext only when a result is ready |
session-brief |
sessionStart → additionalContext |
|
| PR review | Not a hook: the existing secfoo GitHub Action on pull_request |
Already reports through CI. Document it as the PR path for Copilot cloud agent PRs |
Reporting from the cloud agent
The sandbox is ephemeral, so an outbox entry is lost when the session ends. Options, in order:
- Document that admins add the portal host to the Copilot firewall allowlist, and give the key to the agent as an Agents secret, installing secfoo in
copilot-setup-steps.yml. - When the portal is unreachable, have
secfoo hooksay so in the agent output. The PR then goes through the GitHub Action, which reports from CI. - Optionally write the run summary into the PR description so nothing is silently lost.
Run IDs must line up so the portal can join the agent's run with the CI run (use trigger.session_ref).
Gotchas
- Copilot reads
.claude/settings.json, so a Claude Code recipe enabled at project scope also fires in Copilot. Host detection and de-duplication fromsecfoo hook+secfoo automations: one tested entrypoint for every AI tool, recipes enabled on the fly #242 must handle it. Decide whethersecfoo automations enable --tool copilotshould skip writing when the Claude file already covers it. secfoo's owncopilotadapter runscopilot … --allow-all-toolsfor nested reviews. Hooks may fire there, so the recursion guard is mandatory. Verify it with the real CLI (an adapter recording already exists intests/fixtures/agents/copilot/).
Tasks
-
hosts/copilot.py+ fixtures forpreToolUse,postToolUse,agentStop,sessionStart(CLI and VS Code payload forms) -
enablewrites.github/hooks/secfoo.jsonor the user dir; preferexec/args -
copilot-setup-steps.ymlexample installing secfoo, plus firewall/allowlist docs - Plugin hooks generated for the Agent Plugins 1.0 layout (Plugins for other agent platforms: MCP Registry, VS Code/Copilot, Gemini CLI, Codex, Windsurf, Zed, JetBrains and more #227)
- Verification row: CLI, VS Code and cloud agent versions; portal shows
trigger.host = "copilot"
Done when
The recipes work in Copilot CLI and VS Code. Cloud-agent reporting works with an allowlisted portal, or the documented fallback via the Action applies. Double-firing with Claude configs is tested.
Activity