Copilot Context ViewerSee exactly what your last GitHub Copilot prompt actually sent to the model — the prompt, the files (and which lines), conversation history, system prompt, tools, token usage, and AI Credits — for both the VS Code Copilot Chat extension and the GitHub Copilot CLI.
Focus & scopeThis beta focuses primarily on the in‑IDE GitHub Copilot Chat experience in VS Code. That's where the extension is most complete: full per‑file line percentages, tool calls/probes, token dashboard, and the diff/highlight view. Support for the GitHub Copilot CLI is included as an early addition (prompts, system prompt, conversation, and exact token/AI‑Credit totals), but it does not yet show file‑level percentages. More improvements are on the way — deeper CLI parity (file/tool‑level context), richer breakdowns, and broader coverage as the underlying log formats allow. Feedback and issues are welcome. What it shows
Supported sources
The view automatically follows whichever surface you used most recently. InstallFrom a
|
| Command | Description |
|---|---|
Copilot Context: Refresh Last Prompt |
Re‑read the log and rebuild the view |
Copilot Context: Enable Copilot Debug Logging |
Turn on debug logging + guide you to set log level |
Copilot Context: Highlight Shared Lines For File |
Pick a file and highlight its shared lines |
Copilot Context: Open Shared Context As Diff |
Pick a file and open the full‑file ↔ shared‑context diff |
Copilot Context: Open Detected Log File |
Open the log file currently being parsed |
Copilot Context: Toggle Demo Mode |
Switch between the sample and real logs |
Settings
| Setting | Default | Description |
|---|---|---|
copilotContextViewer.autoRefresh |
true |
Poll the log and refresh when a new prompt is detected |
copilotContextViewer.autoRefreshIntervalMs |
2500 |
Polling interval (ms) |
copilotContextViewer.demoMode |
false |
Show the built‑in sample instead of real logs |
copilotContextViewer.logPathOverride |
"" |
Point at a specific log file or folder |
copilotContextViewer.highlightColor |
rgba(64,200,120,0.18) |
Color used to highlight shared lines |
What's exact vs estimated
- Exact (read directly from the log): prompt text, model, mode, prompt/cached/output tokens, context window, AI Credits, the per‑file line ranges and percentages, and every tool command/result.
- Estimated (clearly labeled in the UI): the "Tokens by source" split. The logs record only the total prompt tokens, not a per‑source breakdown, so each source is approximated at ~4 chars/token and the gap to the exact total is shown as "Tool definitions + overhead". This is an approximation, not ground truth.
Privacy & security
- Everything stays on your machine. The extension reads local files only and renders them in a local webview. It makes no network requests, sends no telemetry, and uses no
eval/shell execution. - The logs it reads can contain sensitive content (source code, file paths, prompts). Treat the view — and any screenshots of it — accordingly.
- The webview escapes log content and runs under a strict Content‑Security‑Policy (scripts limited to a nonce; no remote code).
How it works
There is no public VS Code API that exposes what Copilot sent to the model. However, Copilot Chat and the Copilot CLI write the assembled request to local debug/session logs. This extension locates the most recent session, parses it, maps file context back onto your workspace files to compute percentages, and presents the result. Formats are undocumented and version‑dependent, so the parser is tolerant and degrades gracefully.
Build from source
npm install
npm run compile # or: npm run watch
npm test # runs the parser regression tests
# press F5 in VS Code to launch an Extension Development Host
Package a .vsix:
npm install -g @vscode/vsce
vsce package # or: vsce package --pre-release
Limitations
- Relies on Copilot's debug logs; fields vary by version. If a format differs, the view shows what it can and notes the rest.
- Some agent modes gather context via tools/memory rather than reading files — in those cases "0 files" is correct, and the context is shown under tool results / history.
- Whole‑file attachments are reported against the file's current line count; edits after the prompt can shift counts.
License
MIT. Provided for educational and reference purposes only, "AS IS", without warranty of any kind.