Skip to content

About

Daily/weekly/monthly + per-model token & cost usage visualizer for Charm's Crush CLI

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

crush-usage

A small CLI that visualizes token and cost usage for Charm's Crush CLI — daily/weekly/monthly breakdowns and a per-model distribution, similar in spirit to ccusage.

$ crushusage
                              Crush usage — Daily
┏━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Date       ┃ Sessions ┃  Input ┃ Output ┃  Total ┃     Cost ┃                        ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2026-07-24 │        9 │ 253.0k │   6.3k │ 259.3k │  $0.3713 │ ████░░░░░░░░░░░░░░░░   │
│ 2026-07-25 │        5 │ 324.6k │   6.2k │ 330.9k │  $1.1265 │ ██████░░░░░░░░░░░░░░   │
└────────────┴──────────┴────────┴────────┴────────┴──────────┴────────────────────────┘

                 Crush usage by model
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Model                               ┃ Share ┃     Cost ┃                        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ xai/grok-4.5                        │ 68.9% │ $54.8569 │ ██████████████░░░░░░   │
│ opencode-zen/deepseek-v4-flash-free │ 19.1% │  $0.1231 │ ████░░░░░░░░░░░░░░░░   │
└─────────────────────────────────────┴───────┴──────────┴────────────────────────┘

How it works

Crush keeps a per-project SQLite database (crush.db) with a sessions table (cumulative prompt_tokens, completion_tokens, cost per session) and a messages table (which model/provider produced each reply). This tool:

  1. Reads $XDG_DATA_HOME/crush/projects.json to find every project Crush has ever touched, and opens each project's crush.db read-only.
  2. For each session, if more than one model was used, splits that session's token/cost totals across the models proportionally to how many assistant replies each model produced in that session.
  3. Aggregates the result by day/week/month and by model.

Caveat: Crush stores usage per session, not per message. In a session that only ever used one model, the numbers are exact. In a session where you switched models mid-conversation, the split above is an approximation (weighted by reply count) — there's no way around this without Crush itself logging per-call token usage.

Requirements

  • uv — the script is a self-contained uv run --script file with inline PEP 723 dependencies (just rich); uv fetches them into an isolated cache on first run.
  • Crush itself, obviously, with some usage history.

Install

curl -fsSL https://raw.githubusercontent.com/XBoy-352/crush-usage/main/crushusage -o ~/.local/bin/crushusage
chmod +x ~/.local/bin/crushusage

(Make sure ~/.local/bin is on your PATH.)

Or just clone the repo and symlink/copy crushusage wherever you like.

Usage

crushusage                  # summary: daily table (last 14 days) + per-model breakdown
crushusage daily [-n N]     # daily table, last N days (default 14)
crushusage weekly [-n N]    # weekly table, last N weeks (default 8)
crushusage monthly [-n N]   # monthly table, last N months (default 6)
crushusage models [-n N]    # per-model breakdown only, top N (default 10)
crushusage value --paid N   # compare list-price value of usage against what you actually paid

crushusage --model grok         # filter to models matching a substring
crushusage --provider hyper     # filter to a specific provider (hyper, xai, opencode-zen, ...)
crushusage --project myrepo     # filter to projects whose path contains a substring
crushusage --since 2026-07-01   # only usage on/after this date
crushusage --until 2026-07-31   # only usage on/before this date
crushusage --json               # dump raw aggregated records as JSON

Checking a provider's "$X of inference for $Y" claim

Some providers (e.g. Charm's Hyper) sell a flat-rate subscription against their own list prices ("$100 of inference for $20/mo"). crushusage value lets you check how much of that you actually used in a given period, using Crush's own cost tracking (which already applies each provider's listed per-token rates, cache discounts included):

crushusage value --provider hyper --paid 20 --since 2026-07-01 --until 2026-07-31

This prints the list-price value of what you consumed vs. what you paid, and the resulting multiplier. Note this only tells you what you used against that period's allowance — a multiplier below the advertised ratio just means you didn't use your full allowance, not that the provider is shortchanging you.

On cache tokens: Crush does not persist a cache-read/cache-creation token split in its local database — it folds cache-creation tokens into the prompt-token count and only uses cache-read tokens transiently (at call time) to compute cost against the provider's discounted rate, then discards the raw count. So this tool can't show a "served from cache" column. It doesn't need to, though: cost (and therefore value) already nets out whatever cache discount the provider applied.

License

MIT

About

Daily/weekly/monthly + per-model token & cost usage visualizer for Charm's Crush CLI

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages