Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(models): add per-model + per-task breakdown command#287

Merged
iamtoruk merged 1 commit into
mainfrom
feat/models-report
May 10, 2026
Merged

feat(models): add per-model + per-task breakdown command#287
iamtoruk merged 1 commit into
mainfrom
feat/models-report

Conversation

@iamtoruk
Copy link
Copy Markdown
Member

Summary

Adds a new codeburn models command — 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:

┌──────────┬───────────────┬────────────────────┬────────┬────────┬─────────┬──────────┐
│ Provider │ Model         │ Top Task           │  Input │ Output │   Total │     Cost │
├──────────┼───────────────┼────────────────────┼────────┼────────┼─────────┼──────────┤
│ Claude   │ Opus 4.6      │ Coding (42%)       │ 327.3K │  11.0M │ 3322.4M │ $2331.46 │
│ Codex    │ GPT-5.5       │ Conversation (58%) │  30.5M │   4.0M │ 2712.5M │  $941.66 │
└──────────┴───────────────┴────────────────────┴────────┴────────┴─────────┴──────────┘

--by-task explodes each model into per-task rows; blanked provider/model cells on subsequent rows of the same group; horizontal divider between groups:

│ Claude       │ Opus 4.6 │ Coding      │   46.3K │     3.7M │   1589.8M │   $978.89 │
│              │          │ Delegation  │   44.2K │     1.9M │    511.0M │   $357.00 │
│              │          │ Exploration │   96.8K │     1.6M │    377.8M │   $324.86 │
├──────────────┼──────────┼─────────────┼─────────┼──────────┼───────────┼───────────┤
│ Claude       │ Opus 4.7 │ Coding      │   33.2K │     2.4M │   1131.2M │   $685.27 │

Filters

--period (today/week/30days/month/all, default 30days), --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 through jq.
  • 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

  • 42 test files, 577 tests passing locally (19 new tests for this feature).
  • npm run build clean.
  • Live-tested against ~30 days of real session data across Claude / Codex / OpenCode.
  • Verified responsive degradation at 70/100/180 cols.
  • All four output formats (table / markdown / json / csv) render correctly.

Files changed

File Purpose
src/models-report.ts Aggregator + four renderers (table/markdown/json/csv).
src/cli.ts New models subcommand wiring.
tests/models-report.test.ts 19 fixture-based tests.
README.md Usage examples.
CHANGELOG.md Unreleased entry.

Test plan

  • Run node dist/cli.js models with no flags — should show top providers/models for last 30 days.
  • Run with --by-task — should show grouped task explosion.
  • Try each format flag.
  • Resize terminal narrower; columns should drop cleanly.

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.
@iamtoruk iamtoruk merged commit b4ed98c into main May 10, 2026
3 checks passed
@iamtoruk iamtoruk deleted the feat/models-report branch May 10, 2026 03:45
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.

1 participant