Skip to content

feat(copilot-cli): add GitHub Copilot CLI hooks integration#2742

Open
ScottGuymer wants to merge 1 commit into
vectorize-io:mainfrom
ScottGuymer:feature/copilot-cli-hooks-integration
Open

feat(copilot-cli): add GitHub Copilot CLI hooks integration#2742
ScottGuymer wants to merge 1 commit into
vectorize-io:mainfrom
ScottGuymer:feature/copilot-cli-hooks-integration

Conversation

@ScottGuymer

Copy link
Copy Markdown

Summary

Implements #1588 — a new hindsight-integrations/copilot-cli/ package giving GitHub Copilot CLI persistent long-term memory via Hindsight hooks, modeled on the existing hindsight-integrations/cursor-cli/ package.

Hooks

Hook Event Purpose
session_start.py sessionStart Auto-recall — query memories using initialPrompt (or a project-context fallback query), inject as additionalContext
subagent_start.py subagentStart Auto-recall for subagents — every subagent Copilot CLI spawns (explore, task, research, code-review, rubber-duck, security-review, custom agents — not the built-in general-purpose agent, which never fires this hook) gets baseline project memory. Subagent payloads carry no per-invocation task text, so this always uses the fallback query.
agent_stop.py agentStop Auto-retain — reads the transcript, applies a configurable retainEveryNTurns cadence, POSTs to Hindsight (async); caches the transcript path for sessionEnd
session_end.py sessionEnd Final flush — forces a retain using the transcript path cached by the last agentStop, since sessionEnd's payload has no transcript path field of its own

Per-turn recall refresh (userPromptSubmitted/preToolUse) was deliberately skipped — those hooks don't support context injection per the official docs.

Installation

pip install hindsight-copilot-cli
hindsight-copilot-cli install --api-url https://api.hindsight.vectorize.io --api-token your-api-key

Also supports --scope repo for a team-shared .github/hooks/hindsight-copilot-cli.json registration (script install is still per-machine).

Testing

  • 101 unit tests (mocked stdin/stdout/HTTP) covering all four hooks end-to-end, config layering, bank ID derivation, transcript parsing, and install/uninstall for both scopes.
  • uv build && uv sync --frozen && uv run pytest tests -v all green (mirrors the new CI job).
  • ruff check / ruff format --check clean against the shared repo ruff.toml.
  • Verified hook I/O schemas against GitHub's official docs (not assumed) for sessionStart, subagentStart, agentStop, sessionEnd.

Other changes

  • .github/workflows/test.yml — new test-copilot-cli-integration job + path filters, mirroring test-cursor-cli-integration.
  • scripts/release-integration.sh / hindsight-dev/hindsight_dev/generate_changelog.py — registered copilot-cli for the release/changelog tooling.
  • hindsight-docs/src/data/integrations.json + hindsight-docs/docs-integrations/copilot-cli.md — gallery/sidebar entry and docs page (passes check-integrations.mjs).
  • hindsight-integrations/README.md — added a row for Copilot CLI, clarified the existing GitHub Copilot row is VS Code-specific.

Notes / known limitations

  • The transcript file format is a best-effort port of the parsing logic from cursor-cli/claude-code — no live Copilot CLI transcript was available to validate the exact wire format against. Flagged in code comments and the README.
  • uninstall's cleanup of the shared script directory uses an imperfect cwd-based heuristic to detect whether the other install scope is still registered — documented as an accepted v1 limitation (matches an equivalent limitation in cursor-cli).

Closes #1588

Add hindsight-integrations/copilot-cli/, giving GitHub Copilot CLI
persistent long-term memory via Hindsight hooks (see docs.github.com/en/
copilot/how-tos/copilot-cli/customize-copilot/use-hooks). Modeled on the
existing cursor-cli integration.

Hooks:
- sessionStart: recall using initialPrompt (or a cwd-derived fallback
  query), injects additionalContext
- subagentStart: recall for every subagent Copilot CLI spawns (explore,
  task, research, code-review, rubber-duck, security-review, and custom
  agents, not the built-in general-purpose agent, which never fires
  this hook). Subagent payloads carry no per-invocation task text, so
  this always uses the fallback query.
- agentStop: reads the transcript, retains to Hindsight on a configurable
  turn cadence, caches the transcript path for sessionEnd
- sessionEnd: forces a final retain using the transcript path cached from
  the last agentStop, since sessionEnd's own payload has no transcript
  path field

Install via pip install hindsight-copilot-cli, then hindsight-copilot-cli
install (user scope, writes ~/.copilot/hooks/hindsight-copilot-cli.json)
or --scope repo for a team-shared .github/hooks/ registration. Zero
runtime dependencies, hook scripts are pure stdlib Python.

Also wires up CI (test-copilot-cli-integration job), release-integration.sh
and generate_changelog.py registration, and docs gallery/sidebar entry.

Closes vectorize-io#1588
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.

Vscode/GitHub Copilot Integration

1 participant