tokentop agent plugin for GitHub Copilot CLI (GitHub's terminal coding agent). Parses session data, tracks token usage, and provides real-time activity monitoring.
| Capability | Status |
|---|---|
| Session parsing | Yes |
| Credential reading | No |
| Real-time tracking | Yes |
| Multi-provider | No |
This plugin reads GitHub Copilot CLI's local session files from ~/.copilot/session-state/ and process logs from ~/.copilot/logs/ to extract:
- Session metadata (start time, project path, summary)
- Token usage per message (estimated from CompactionProcessor deltas in process logs; real
assistant.usagedata when available) - Model identification from any event's
data.modelfield — no hardcoded model list required - Real-time file watching for live session updates
Copilot CLI marks token-bearing events (assistant.usage, session.shutdown) as ephemeral — they're tracked in-memory for the /usage command but never written to events.jsonl (see copilot-cli#1152). To work around this, the plugin parses CompactionProcessor entries from process logs (~/.copilot/logs/process-*.log), which report the running token count of the conversation context before each model request.
Token estimation uses a priority chain:
- Real usage data —
assistant.usageevents (used automatically if Copilot CLI begins persisting them) - CompactionProcessor deltas — input tokens from the CP entry, output tokens from the delta between consecutive entries
- Content-length fallback —
content.length / 4heuristic (last resort when no process log is available)
Each process log maps 1:1 to a session via the Workspace initialized: {session-uuid} line. The compaction index is built once and cached for 60 seconds.
The plugin identifies models generically by scanning all event types for a data.model field — no hardcoded model names or event types. This means new models (e.g. gpt-5.3-codex) are picked up automatically without code changes. The resolution priority is:
assistant.message→data.modelsession.model_changetimeline (timestamp-based)- Any event with
data.model(e.g.tool.execution_complete) - Process log
Using default model:line 'unknown'
If a user switches models mid-session, each model segment appears as a separate entry — matching the behavior of the Claude Code and OpenCode plugins.
This plugin is bundled with tokentop — no separate install needed. If you need it standalone:
bun add @tokentop/agent-copilot-cli- GitHub Copilot CLI installed (
~/.copilotdirectory must exist) - Bun >= 1.0.0
@tokentop/plugin-sdk^1.3.0 (peer dependency)
| Type | Access | Paths |
|---|---|---|
| Filesystem | Read | ~/.copilot/session-state/, ~/.copilot/logs/ |
bun install
bun run build
bun test
bun run typecheckSee the Contributing Guide. Issues for this plugin should be filed on the main tokentop repo.
MIT