Skip to content

Report GitHub Copilot usage with --source copilot|all - #2

Merged
Expecho merged 1 commit into
mainfrom
copilot-source
Oct 27, 2026
Merged

Expecho merged 1 commit into
mainfrom
copilot-source

Conversation

@Expecho

@Expecho Expecho commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Adds GitHub Copilot as a second source. A new loader (src/copilot.mjs) reads the Copilot CLI's session logs (~/.copilot/session-state/<id>/events.jsonl). Copilot's agent in VS Code writes them too. The loader produces the same records as the Claude Code loader, so every report works on them, including adoption and recommendations.

node bin/ccreports.mjs --source copilot          # Copilot only
node bin/ccreports.mjs --source all -a -r        # both, side by side

The default stays --source claude, so existing reports don't change. Claude recommendations are identical to main. Session totals differ only by 1-token rounding from the live session's transcript.

How Copilot's logs map onto the reports

  • Tokens: per request from session.usage_record where Copilot logs it (recent versions). Otherwise from the per-run totals in session.shutdown, which count as that many requests and have no context size. Copilot's input count includes cached tokens, so they are subtracted.
  • Cost: what Copilot billed in AI credits (1 AIU = $0.01). Claude models without billed credits are priced at API rates; dotted names like claude-sonnet-4.6 now resolve. GPT and local models without credits show as unpriced. The summary lists premium requests.
  • Tokens per tool: estimated as for Claude Code, then scaled down to at most each session's input, with a matching share of its billed cost.
  • Tools: keep Copilot's names. MCP tools become mcp__<server>__<tool>, and task calls count as subagent launches. -x breaks down powershell / bash commands. PRs are found in gh pr create and create_pull_request output.
  • Recommendations: the same checks, with advice that names Copilot's own levers: copilot-instructions.md / AGENTS.md, custom agents, the explore agent, /compact, plan mode, autopilot. The cheaper-subagent-model check is skipped. With --source all, each product gets its own section.
  • Report skill: knows about --source and the Copilot caveats.

Shared changes

  • aggregate.mjs: uses a record's billed cost when it has one, plus request counts and premium requests.
  • attribution.mjs: tolerates requests whose context size is unknown.
  • adoption.mjs: edit and web flags, Copilot surfaces.
  • report.mjs, formats.mjs: product name in titles, cost note in the HTML header.

Known limits

  • Sessions that never shut down cleanly have no token counts.
  • Older Copilot logs count subagents' tokens as the main session's.
  • The older VS Code chatSessions logs aren't read.

Before release

Check the Copilot advice that couldn't be confirmed from logs: /context, /mcp, .github/skills and .github/agents.

Tests

npm test: 44 pass. test/copilot.test.mjs covers the loader, cost and request aggregation, merging sources, and the Copilot recommendations.

🤖 Generated with Claude Code

A new loader (src/copilot.mjs) reads the Copilot CLI's session logs
(~/.copilot/session-state/<id>/events.jsonl, also written by Copilot's
agent in VS Code) into the same records as the Claude Code loader, so
every report works on them. --source all combines both products; the
default stays claude.

- Tokens: per request from session.usage_record where logged, else the
  per-run totals of session.shutdown (counted as that many requests, with
  no context size). Copilot's input includes cached tokens; they are
  subtracted to match Claude's columns.
- Cost: what Copilot billed in AI credits (1 AIU = $0.01); unbilled Claude
  models are priced at API rates (dotted names like claude-sonnet-4.6 now
  resolve). The summary lists premium requests.
- Tokens per tool are estimated as for Claude Code, then scaled down to at
  most each session's input, and get a matching share of its billed cost.
- Tools keep Copilot's names; MCP tools become mcp__<server>__<tool>, task
  calls are subagent launches, shell commands are broken down, PRs come
  from gh pr create / create_pull_request output.
- Recommendations run the same checks with Copilot's own advice
  (copilot-instructions.md, custom agents, explore agent, /compact, plan
  mode, autopilot); with --source all each product gets its own section.
- The report skill knows about --source and the Copilot caveats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Expecho
Expecho merged commit d3109c1 into main Oct 27, 2026
6 checks passed
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