expensive 0.2.2

Terminal dashboard for OpenCode token usage and spend
Documentation

expensive

A small terminal dashboard for OpenCode spend.

expensive reads OpenCode's local SQLite database directly and turns the same kind of accounting you get from opencode stats into a live, fast dashboard you can keep open while you work.

What It Shows

  • total cost
  • total tokens
  • input and output tokens
  • cache read and cache write tokens
  • model-level breakdown with message counts, cost, tokens, and share of spend
  • daily, weekly, monthly, and all-time views
  • calendar view for day, week, and month spend

Daily usage defaults to "since 04:00" in your local timezone, which fits the usual late-night coding accounting better than a strict midnight cutoff.

Install

Install the published crate:

cargo install --locked expensive

Development

Install from a local checkout:

cargo install --locked --path .

Or run without installing:

cargo run

Usage

expensive

Controls:

Key / Mouse Action
Tab Next time window, or next calendar scale
Shift+Tab Previous time window, or previous calendar scale
click a top tab Jump to that time window or Calendar
c Open Calendar
arrows / hjkl Move Calendar selection
Enter Open selected Calendar period
h / k Previous period from Calendar detail
j / l Next period from Calendar detail
? Open or close Help
r Refresh now
Esc Back one level; quit from the dashboard
q Quit

By default, expensive refreshes every 60 seconds. The database query is cheap; on the machine this was built on, direct SQLite aggregation was roughly two orders of magnitude faster than parsing opencode stats.

Options

expensive --daily-start 05:00
expensive --week-start sunday
expensive --color-theme ocean
expensive --theme-scope all
expensive --refresh 10
expensive --no-refresh
expensive --db ~/.local/share/opencode/opencode.db

expensive finds the OpenCode database in this order:

  1. --db <path>
  2. OPENCODE_DB_PATH
  3. opencode db path
  4. ~/.local/share/opencode/opencode.db

Config

If present, config is read from:

~/.config/expensive/config.toml

Example:

daily_start = "04:00"
week_start = "monday"
refresh_seconds = 60
auto_refresh = true
color_theme = "aurora"
theme_scope = "calendar"
scope = "all"

Only scope = "all" is supported today.

week_start can be monday or sunday. auto_refresh can be true or false. Themes are aurora, ember, ocean, forest, and graphite. theme_scope = "calendar" applies the theme to the Calendar heatmap only; theme_scope = "all" applies it to the entire TUI.

Notes

The app uses OpenCode's stored assistant message usage fields:

  • cost
  • tokens.input
  • tokens.output
  • tokens.cache.read
  • tokens.cache.write
  • providerID
  • modelID
  • variant

That means totals should track OpenCode's own cost and token accounting without rerunning the slower stats command.

License

MIT