Skip to content

feat: GitHub Copilot CLI adapter#70

Open
arielbk wants to merge 7 commits into
mainfrom
copilot-cli-adapter
Open

feat: GitHub Copilot CLI adapter#70
arielbk wants to merge 7 commits into
mainfrom
copilot-cli-adapter

Conversation

@arielbk

@arielbk arielbk commented Jul 16, 2026

Copy link
Copy Markdown
Owner

What

Add GitHub Copilot CLI as the fourth session tool (copilot), alongside Claude, Codex, and Cursor.

  • Parse Copilot events.jsonl transcripts under ~/.copilot/session-state/<uuid>/ (honoring COPILOT_HOME) into the common transcript shape: title, model, message head/tail, and token totals.
  • Locate live Copilot sessions by walking ancestor PIDs against session-state/<uuid>/inuse.<pid>.lock files, since Copilot exposes no session-id environment variable.
  • Accept Copilot lifecycle hooks (sessionStart / agentStop / subagentStop) with their camelCase payloads, keyed on the sessionId carried in stdin.
  • Ship the integration as part of the Trace plugin — manifest, version-1 hooks JSON, and a Copilot protocol skill resource — installed with copilot plugin install ./plugin (documented in the README).
  • Render Copilot sessions on the board with their own icon and theme token.

Why

Trace already captures Claude, Codex, and Cursor sessions; Copilot CLI sessions were invisible. This brings task binding, transcript rendering, state-freshness checks, and re-entry to Copilot with no manual setup beyond the plugin install.

Implementation details

  • Transcript adapter (packages/core/src/copilot-adapter.ts): reads the append-only events.jsonl, tolerating both data-nested and top-level event fields, and skipping malformed lines. Token totals are output-only — Copilot records no input or cache tokens (outputTokens per assistant.message).
  • Session locator (apps/cli/src/copilot-session.ts): core stays fs/process-free via an injected resolveCopilotSession callback (same pattern as Cursor), wired once in the CLI identity composition root. Copilot identity takes precedence over Cursor cwd-guessing only when Claude/Codex identities are absent.
  • Hooks: every payload carries sessionId + cwd. Copilot ignores command-hook stdout at sessionStart, so the binding nudge rides the prompt-type hook (auto-submitted text). agentStop feeds the payload id into state check's explicit-binding gate.
  • Subagent capture: subagentStop is accepted but intentionally a no-op — no parent/child linkage was observed in the event stream. To be probed empirically during dogfood; a stable relation would enable nested subagent sessions later.
  • No Drizzle migration: the tool column is unconstrained text; the SessionTool enum is TS-only.

Cut from this PR: Windows VDI support (follow-up task), session scan --copilot backfill (Cursor precedent: live capture only), and reading the session-store.db SQLite mirror.

Testing

  • Copilot adapter unit suite — 384 core tests, covering transcript identity, model, message head/tail, output-token totals, and malformed-line handling.
  • Live-locator fake-tree tests — matching ancestors, concurrent sessions, stale locks, and COPILOT_HOME.
  • Hook/stop tests — 40 focused tests asserting registration, freshness, and exit-code behavior equivalent to the Claude hooks.
  • Plugin scaffold checks — manifest, lifecycle hooks, pinned commands, skill resources, and README install command.
  • Typecheck and lint pass on the changed packages.

Remaining before undraft

The end-to-end macOS dogfood (the task's done condition) is still to run: install the plugin per README, bind a task from a real Copilot session, verify board rendering and re-entry, probe subagent linkage, and record the resume invocation + prompt-hook dynamism findings. The full QA runbook lives in the task's copilot-cli-adapter.qa.md.

🤖 Generated with Claude Code

@arielbk
arielbk marked this pull request as ready for review July 16, 2026 14:54
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.

1 participant