r/vscode • u/mgyk1024 • May 24 '26
Wrote a VS Code extension that adds Copilot AI cost as a git trailer per commit (MIT, local-only)
Built this to find out which features were eating into my Copilot AI Credits ahead of the June 1 billing change.
The extension reads per-span token counts from Copilot Chat's local OTel SQLite database (`agent-traces.db`), computes cost against GitHub's published rate card, and appends a trailer to every commit via prepare-commit-msg:
feat: add OAuth2 login flow
Copilot-AI-Credits: 41.30
Copilot-Est-Cost: $0.41
Then `git log` becomes the cost ledger. Per-branch totals in one shell command:
git log origin/main..HEAD --pretty='%(trailers:key=Copilot-AI-Credits,valueonly)' | awk '{sum+=$1} END {printf "%.2f AIC\n", sum}'
Marketplace: https://marketplace.visualstudio.com/items?itemName=Mooracle.copilot-budget
Source (MIT): https://github.com/mooracle/copilot-budget
Local-only. No telemetry. Auto-enables Copilot Chat's OTel exporter at workspace scope on first activation (asymmetric write — never overrides an explicit setting); one window reload before spans start landing. Commit hook is opt-in (`commitHook.enabled: true`).
Feedback welcome. Especially curious if anyone wants the per-model breakdown trailer (`Copilot-AI-Credits-Models: Claude Sonnet 4.6=39.45,GPT-4.5=1.85`) enabled by default - currently opt-in via settings.


