Skip to content

feat: Add npx CLI package for Copilot token usage analysis#433

Merged
rajbos merged 9 commits intomainfrom
copilot/create-npx-package-for-token-analysis
Mar 20, 2026
Merged

feat: Add npx CLI package for Copilot token usage analysis#433
rajbos merged 9 commits intomainfrom
copilot/create-npx-package-for-token-analysis

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Standalone CLI (copilot-token-tracker-cli) publishable to npmjs.org that reuses the extension's session discovery, parsing, token estimation, maturity scoring, and usage analysis modules without modifying them.

npx copilot-token-tracker-cli stats --verbose
npx copilot-token-tracker-cli usage --models --cost
npx copilot-token-tracker-cli env
npx copilot-token-tracker-cli fluency --tips

CLI Package (cli/)

  • stats — Files, sessions, chat turns, tokens; breakdown by editor source
  • usage — Token usage by period (today/month/last month/30d) with optional per-model and cost breakdowns
  • environmental — CO₂, water, tree-offset estimates with real-world context comparisons
  • fluency — Copilot Fluency Score across all 6 categories with optional improvement tips
  • VS Code API stubbed via cli/src/vscode-stub.ts so sessionDiscovery.ts and opencode.ts imports resolve cleanly
  • OpenCode DB virtual paths (opencode.db#ses_<id>) handled via dedicated statSessionFile() helper
  • esbuild bundles everything into a single dist/cli.js (~415KB) targeting Node 18+

Root integration

  • Added cli:build, cli:stats, cli:usage, cli:environmental, cli:fluency, cli npm scripts
  • Excluded cli/ from root tsconfig.json to avoid rootDir conflicts

Workflows

  • cli-build.yml — Validates build + all commands on Node 18/20/22, triggered on changes to cli/ or shared source modules
  • cli-publish.ymlworkflow_dispatch with version bump selector (patch/minor/major) and dry-run option; requires NPM_TOKEN secret

Example output

Diagnostics

image

Stats

image

Usage

image

Copilot AI and others added 3 commits March 18, 2026 21:27
…ommands

Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
…s, test validation

Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
@rajbos rajbos marked this pull request as ready for review March 20, 2026 08:06
@rajbos rajbos merged commit 9ece11d into main Mar 20, 2026
18 of 19 checks passed
@rajbos rajbos deleted the copilot/create-npx-package-for-token-analysis branch March 20, 2026 08:09
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.

2 participants