feat(models): add per-model + per-task breakdown command#287
Merged
Conversation
A single dense table of every (provider, model) you have used in the selected period, sorted by cost. Inspired by tokscale's per-model output and ccusage's responsive cli-table3 layout, ported to plain Node with no new runtime dependency. Default view: one row per (provider, model) with a Top Task cell showing the dominant task category and its cost share, e.g. `Coding (42%)`. `--by-task` explodes each model into one row per task type, with provider/model cells blanked on subsequent rows of the same group and a horizontal divider between groups so the sections read as distinct units. Output formats: table (Unicode box-drawn, default), markdown (GitHub-flavored, copy-paste friendly), json, csv. Filters: --period (today/week/30days/month/all, default 30days), --from/--to, --provider, --task, --top, --min-cost, --no-totals. The table renderer auto-sizes every column to its content (no fixed widths leaving trailing whitespace) and drops cache columns as a pair when the terminal is narrow, then input/output, then top-task, in that order. Provider, model, total, and cost stay regardless. Visible-width math uses strip-ansi (already a dependency) so styled cells pad correctly. Cyan headers, yellow totals, dim provider name. The aggregator walks every parsed turn and attributes each assistant call to its (provider, model, task) bucket, computing real input / output / cache_write / cache_read tokens and cost. Output tokens include reasoning. Cached input tokens are folded into cache_read so the column matches what users intuitively expect. 19 fixture-based tests cover aggregation correctness, byTask grouping, taskFilter, topN/minCost filters, reasoning-as-output, all four renderers (table/markdown/json/csv), narrow-terminal column dropping, CSV/markdown escaping, totals row toggle, and visible-width math under styled cells.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
codeburn modelscommand — a dense per-model table sorted by cost, with optional explosion by task type. Inspired by tokscale's per-model view and ccusage's responsive cli-table3 layout, ported to plain Node with no new runtime dependency.What you get
Default view — one row per (provider, model), Top Task column shows the dominant task category and its cost share:
--by-taskexplodes each model into per-task rows; blanked provider/model cells on subsequent rows of the same group; horizontal divider between groups:Filters
--period(today/week/30days/month/all, default30days),--from/--to,--provider,--task,--top,--min-cost,--no-totals.Output formats
table(default) — Unicode box-drawn, auto-sized columns, responsive width.markdown— GitHub-flavored table for paste into PRs/Slack/Notion.json— full data, pipeable throughjq.csv— spreadsheet-ready, repeats provider/model on every row.Responsive width
The renderer auto-sizes every column to its content (no fixed widths leaving trailing whitespace). When the terminal is too narrow to fit the full set, it drops cache columns as a pair, then input/output, then top-task. Provider, model, total, and cost stay regardless.
Verification
npm run buildclean.Files changed
src/models-report.tssrc/cli.tsmodelssubcommand wiring.tests/models-report.test.tsREADME.mdCHANGELOG.mdTest plan
node dist/cli.js modelswith no flags — should show top providers/models for last 30 days.--by-task— should show grouped task explosion.