@rajat-rastogi/copilot-insights
v0.3.0
Published
Local, read-only intelligence dashboard for GitHub Copilot sessions: API-equivalent cost, budget tracking, code impact, workflow quality, and session trajectories.
Readme
Copilot Insights
Local, read-only cost, budget, code-impact, performance, and workflow intelligence for the GitHub Copilot CLI.
Copilot Insights turns the local events.jsonl transcripts written by the
GitHub Copilot CLI into one private, read-only view of what your sessions
actually delivered. It values token usage at public API rates, reconstructs
code edits, finds churn and correction loops, and measures workflow quality on
normalized units of work, not raw token volume.
No proxy, SDK wrapper, database, or vendor account connection is required. The server binds to localhost and never writes to the Copilot state directory.
Install and run
Prerequisite: Node.js 22 or newer (18+ works; 22+ unlocks full cost, budget, and coaching accuracy).
Run it with a single command, no install required:
npx @rajat-rastogi/copilot-insights@latestThen open http://127.0.0.1:4477.
Prefer a permanent install?
npm install -g @rajat-rastogi/copilot-insights
copilot-insightsEverything runs on your own machine: it reads your local Copilot CLI history
(~/.copilot), binds to localhost only, never uploads anything, and never
writes to the Copilot state directory. If you have not used the Copilot CLI yet,
the dashboard will simply be empty.
Why this exists
Usage pages answer "how many tokens did I use?" They do not answer:
- What code did those tokens buy?
- Which files keep getting reworked across sessions?
- How often do I correct the agent, abandon a run, or wait for its first edit?
- What did my Copilot CLI usage look like valued at API-equivalent prices?
Copilot Insights answers those questions from the data already stored on your machine.
Highlights
Code impact, not token volume
- Reconstructs daily additions and removals from
editandcreatetool payloads (and legacy patch/write formats). - Ranks the files and directories the agent touches most.
- Builds an AI-written-code risk map from repeat sessions, edit count, churn, and changed lines.
- Detects files edited repeatedly within a session or across many sessions.
Cost intelligence and budget
- Prices each recognized model with separate input, output, and cache rates.
- Shows API-equivalent cost per session, per edit, and per 100 changed lines.
- Tracks spend against your per-user budget (a single amount plus a monthly/yearly period, in API-equivalent USD), calendar-to-date, with a burn-rate projection for the period end.
- Surfaces AIU (AI Units) consumed as a tracking metric.
- Reports pricing coverage and leaves unknown models visibly unpriced instead of silently guessing.
Workflow intelligence
- Same-file rework loops.
- Sessions that end without a final assistant response.
- Corrective follow-ups such as "wrong," "undo," or "you missed…".
- Median time from the first user request to the first parseable edit.
- Tool error rate and median tool latency.
Coaching
A dedicated panel of ranked, quantified, evidence-linked recommendations for having more impact and spending fewer tokens for the same result. Opportunities are detected from your own sessions against best-practice thresholds and your own-history outliers, with a trend arrow vs the previous period:
- Efficiency — token/$/AIU reclaimable from correction cycles, abandoned runs, in-session rework, over-long (context-bloated) sessions, high reasoning effort on mechanical tasks, premium models on small edits, and verbose generation.
- Impact — reconnaissance overhead (slow first edit) and files that keep getting re-edited across sessions.
Each card quantifies the estimated opportunity, gives a concrete suggestion, and links to the exact sessions/files behind it. Estimates are directional heuristics (they may overlap), computed entirely from your local data.
Session trajectories and Wrapped
- Complete user, assistant, reasoning, tool, result, duration, and error timeline for every session.
- Reconstructed sub-agent spawn trees and parent/child breadcrumbs.
- Shareable Wrapped slides with tokens, code output, and API-equivalent value.
Supported source
| Source | Auto-discovered location | Notes |
|---|---|---|
| GitHub Copilot CLI | ~/.copilot/session-state/<sessionId>/events.jsonl | Override the root with COPILOT_STATE_DIR or --dir. Sessions are grouped by working directory. |
Each session directory holds a newline-delimited events.jsonl transcript
(session.start, session.model_change, user.message, assistant.message,
tool.execution_start, tool.execution_complete, …) plus a workspace.yaml
whose name is used as the session label.
Run from source
Cloned the repo instead? There are no runtime dependencies and no build step:
npm startOpen http://127.0.0.1:4477.
The default scan covers the last 30 days. Parsed transcripts are cached by file modification time, so refreshes only re-read changed files.
Try it with sample data
No Copilot CLI history yet? Run the bundled, synthetic dataset:
npm run sampleThe sample writes a Copilot-layout state directory to ./sample-data with
sub-agents, create and edit operations, cross-session churn, a correction,
an abandoned trajectory, and a failed tool call. It does not read your local
history.
Command-line options
node server.mjs [options]
--days <n> activity window; default: 30
--all include full discovered history
--dir <path> read one Copilot session-state directory only
--pricing <path> use a custom per-model pricing JSON file
--port <number> localhost port; default: 4477Environment equivalents:
| Variable | Purpose |
|---|---|
| PORT | Server port |
| COPILOT_STATE_DIR | Explicit Copilot session-state directory |
| COPILOT_STORE_DB | Explicit session-store.db for token accounting |
| COPILOT_INSIGHTS_PRICING | Custom pricing table path |
Pricing
pricing.json is an editable table in USD per million tokens.
Each row contains a regular-expression model pattern and input, output,
cacheRead, and optional cacheWrite rates. Patterns match the Copilot CLI's
dot-notation model IDs (for example claude-opus-4.8, claude-sonnet-4.5,
gpt-5.6-sol, gpt-5.3-codex).
Token accounting. The events.jsonl transcript records only output
tokens per assistant turn. The full per-request accounting (input, output, cache
read/write, reasoning) lives in the local Copilot session store
~/.copilot/session-store.db (assistant_usage_events, keyed by session id).
When that store is present and the runtime provides Node's built-in node:sqlite
(Node 22.5+), Copilot Insights reads it and prices sessions cache-aware.
On older Node, or when the store is unavailable, it falls back to an output-only
estimate. Either way, cost is a directional estimate, not an invoice, and a
session with an unknown model stays unpriced and reduces the displayed coverage.
Budget. To track spend against a budget, open Budget setup and enter a single allocation amount plus a period (monthly or yearly) in API-equivalent USD; the other period is pro-rated automatically (÷12 or ×12). The "Cost intelligence & budget" panel then shows, for both this month and this year, calendar-to-date spend vs budget, utilization, remaining, and a linear burn-rate projection for the period end (on track / over), independent of the day-window selector. AIU consumed is shown alongside as a tracking metric. The budget is saved only in your browser (localStorage); set it to 0 to hide the cards. Because the tool reads only your local machine, the budget reflects your own usage.
How impact and workflow signals are calculated
Impact is reconstructed from edit (old_str/new_str) and create
(file_text) tool payloads, plus legacy Write, MultiEdit,
str_replace_editor, and apply_patch formats for portability. A create
payload contains the new content but not a prior version, so its lines are
counted as additions.
| Signal | Definition | |---|---| | Rework loop | Another edit to the same file in the same session | | Churn | Repeat file touches within or across sessions | | Abandoned | A non-live, user-started session ending without a final assistant response | | Correction | A later user message matching an explainable negative-correction phrase | | Time to first edit | First user message to first parseable edit operation |
These are coaching heuristics, not claims about code authorship or correctness. Open a session trajectory to inspect the source events behind a signal.
Sub-agent spawn trees are reconstructed best-effort by linking a task/agent
tool call to a child session whose id appears in the call's arguments or result.
Privacy and security
- The HTTP server listens on
127.0.0.1, not on the public network. - The Copilot state directory is read-only; the dashboard never modifies it.
- Transcript content is served only to the local browser.
- There is no telemetry, cloud database, analytics SDK, or third-party runtime dependency.
Treat your own screenshots and exported API responses as sensitive: session labels, prompts, tool arguments, results, and local file paths may contain private information.
Architecture
~/.copilot/session-state/<id>/events.jsonl ~/.copilot/session-store.db
│ (trajectory: messages, tools, edits) │ (per-request token usage)
▼ ▼
adapters.mjs discovery + normalized session/event model + token enrichment
│
▼
analytics.mjs pricing, edit parsing, risk, scoreboard, workflow signals
│
▼
server.mjs cached read-only API + localhost static server
│
▼
public/ dependency-free HTML, CSS, SVG charts, and JavaScript UIDevelopment
npm test
node --check server.mjs
node --check adapters.mjs
node --check analytics.mjs
node --check public/app.jsThe analytics tests cover the Copilot event parser, edit/create impact,
multi-file patches, cache-aware pricing, code impact, churn, corrections,
rework, latency, abandonment, and explicit handling of unknown models.
