A lightweight terminal dashboard that aggregates AI token usage from OpenCode into a local SQLite database. See how much you spend, which models you use most, and how your usage trends over time -- without sending any data anywhere.
AI coding assistants burn tokens in the background. OxideTrack gives you a clear picture of your actual spend across models and projects:
- One dashboard for all your OpenCode usage.
- Runs locally -- your data never leaves your machine.
- Single binary (~3 MB), no runtime dependencies.
- Works over SSH -- plain terminal, no browser needed.
- HTML export for sharing reports (with interactive Chart.js charts).
- Live pricing -- fetches model costs from models.dev on each sync, with a local cache fallback.
OxideTrack only reads token counts, model names, timestamps, and session identifiers from each source. It does not read, store, or transmit:
- Conversation content (prompts or responses)
- File contents from your projects
- API keys or credentials
- Any personally identifiable information
All data stays in a local SQLite file (usage.db) that you own and can
delete at any time. The HTML export is a self-contained static file with no
analytics, tracking, or external requests beyond the Chart.js CDN (pinned to
an exact version for security).
The source code is small enough to audit in an afternoon -- about 3,200 lines of Rust across 11 files.
Requires Rust 1.78 or later.
git clone https://github.com/riyhs/oxidetrack.git
cd oxidetrack
cargo build --releaseThe binary is at target/release/oxtrack (or oxtrack.exe on Windows).
Copy it somewhere on your PATH:
# Linux / macOS
cp target/release/oxtrack ~/.local/bin/
# Windows (PowerShell)
Copy-Item target\release\oxtrack.exe "$env:USERPROFILE\.cargo\bin\"Pre-built binaries for Windows, Linux, and macOS are available on the
Releases page.
Download the archive for your platform and extract oxtrack to your PATH.
# 1. Sync token data from OpenCode (also refreshes pricing from models.dev)
oxtrack sync
# 2. Open the TUI dashboard (this is also the default command)
oxtrack
# 3. Export a 30-day HTML report
oxtrack export --output report.html --days 30On first run, OxideTrack creates a config file and an empty database.
| Command | Description |
|---|---|
oxtrack or oxtrack dashboard |
Open the interactive TUI dashboard |
oxtrack sync |
Pull latest token data and refresh pricing |
oxtrack export -o FILE [-d N] |
Export an HTML report (default: 30 days) |
oxtrack inspect PATH |
Print the schema of a source SQLite database |
| Key | Action |
|---|---|
Tab / Right |
Next tab |
Shift+Tab / Left |
Previous tab |
1 -- 7 |
Jump to tab |
Down / j |
Scroll table down |
Up / k |
Scroll table up |
] or + |
Next time range |
[ or - |
Previous time range |
s |
Sync now |
e |
Export HTML report |
c |
Export CSV |
w |
Save settings (Settings tab) |
Space |
Toggle setting (Settings tab) |
Enter |
Edit field / confirm action (Settings tab) |
? |
Toggle help bar |
q / Esc |
Quit |
The config file is created automatically on first run:
| OS | Path |
|---|---|
| Windows | %APPDATA%\oxidetrack\config.toml |
| Linux | ~/.local/share/oxidetrack/config.toml |
| macOS | ~/Library/Application Support/oxidetrack/config.toml |
[sources]
opencode = true # reads from OpenCode's SQLite DB
# Override auto-discovered DB path if needed:
# opencode_db = "C:\\Users\\you\\AppData\\Roaming\\opencode\\opencode.db"
[projects]
# Map directory prefixes to human-readable project names.
# If no mapping matches, the directory name is used automatically.
"C:\\Users\\you\\dev\\my-saas" = "My SaaS"
"C:\\Users\\you\\dev\\api-service" = "API Service"
[pricing]
# User overrides for model pricing (USD per 1M tokens: [input, output]).
# Models not listed here use live pricing fetched from models.dev,
# falling back to a local cache.
# Add custom or fine-tuned models here:
"my-fine-tuned-model" = [5.0, 15.0]Model costs are fetched automatically from models.dev
each time you run oxtrack sync. The data is cached locally at
<data_dir>/models_cache.json so subsequent runs do not need network access.
Fallback chain:
- Live fetch from
https://models.dev/api.json - Local cache file
- $0.00 for all models until a successful sync populates the cache
User overrides in config.toml [pricing] always take precedence over all three.
OxideTrack auto-discovers these paths. Override them in config if discovery fails or your installation is non-standard.
| Source | Default Path (Windows) |
|---|---|
| OpenCode | %APPDATA%\opencode\opencode.db |
- Pricing refresh -- fetch updated model costs from models.dev and update the local cache.
- Discover -- locate OpenCode's SQLite database.
- Read incrementally -- query only records newer than the last sync timestamp. This keeps syncs fast even with large histories.
- Normalize -- map each record to a common
UsageRecordstruct with source, provider, model, token counts, cost, and timestamp. - Deduplicate -- a unique
session_id(e.g.,opencode:abc123) prevents double-counting if you sync multiple times. - Store -- insert into the local
usage.dbSQLite database in a single transaction.
The dashboard polls no external services. It reads from usage.db and
renders five views:
- Dashboard -- summary stat cards with sparkline trends.
- By Model -- table of token counts and costs per model (with separate input/output cost columns).
- By Provider -- same, grouped by provider (Anthropic, OpenAI, etc.).
- By Project -- same, grouped by project / working directory.
- Timeline -- sparkline charts for daily token volume and cost.
- Sessions -- session-level detail table with duration and model info.
- Settings -- interactive config editor: toggle sources, set export path, add price overrides, reset DB.
Each view supports five time ranges: Today, 7 days, 30 days, 90 days, and 1 year.
oxtrack export generates a self-contained HTML file with interactive
bar charts (via Chart.js) showing token usage and cost by day and model.
Open it in any browser or print to PDF.
If a sync adapter fails with a schema error (e.g., after an OpenCode update), use the inspect command to see the current table layout:
oxtrack inspect "%APPDATA%\opencode\opencode.db"This prints all tables and their columns (no row data is shown). Use the output to update the adapter SQL if needed.
The aggregation database lives at:
| OS | Path |
|---|---|
| Windows | %APPDATA%\oxidetrack\usage.db |
| Linux | ~/.local/share/oxidetrack/usage.db |
| macOS | ~/Library/Application Support/oxidetrack/usage.db |
It is a plain SQLite file. You can query it directly:
sqlite3 ~/.local/share/oxidetrack/usage.db \
"SELECT model, SUM(input_tokens + output_tokens) as tokens, SUM(cost_usd) as cost
FROM usage_records GROUP BY model ORDER BY cost DESC;"To reset all data, simply delete the file. It will be recreated on next sync.
cargo build # debug build
cargo build --release # release build (optimized, stripped)
cargo test # run all tests
cargo clippy --all-targets # lint checks
cargo fmt --check # formatting checksrc/
main.rs CLI entry point (clap)
config.rs Config loading, pricing, project mapping
db.rs SQLite aggregation database (all SQL lives here)
export.rs HTML report builder
pricing.rs models.dev pricing fetch and cache
app.rs TUI application state
sync/
mod.rs sync_all() orchestrator
opencode.rs OpenCode adapter
zed.rs Zed adapter (placeholder -- no token data available)
ui/
mod.rs Terminal setup, event loop, key handling
draw.rs All ratatui rendering (pure -- no I/O)
See docs/ARCHITECTURE.md for detailed data flow
diagrams and design decisions.
Contributions are welcome. Please:
- Run
cargo fmtandcargo clippy --all-targetsbefore submitting. - Add tests for new functionality (co-located
#[cfg(test)] mod tests). - Keep
draw.rspure -- no database calls, no file I/O. - Keep all SQL in
db.rs. - Never store conversation content or file contents in the database.
- OpenCode SQLite sync (incremental, deduplicated)
- TUI dashboard with 7 tabs (Dashboard, By Model, By Provider, By Project, Timeline, Sessions, Settings)
- 5 time ranges (1 day, 7 days, 30 days, 90 days, 1 year)
- Live pricing from models.dev with local cache
- HTML export with interactive Chart.js charts
- CSV export
- Interactive Settings tab (toggle sources, edit export path, add price overrides, reset DB)
- Auto-sync on startup
- Manual sync from TUI (background, non-blocking)
- Schema discovery (
oxtrack inspect) - Cost recalculation (
oxtrack recalc) - Privacy-first (no content, no PII, no telemetry)
- Zed editor sync (waiting for token data in Zed DB)
- PDF export
OxideTrack is not built by the OpenCode team and is not affiliated with OpenCode in any way.
MIT License -- see LICENSE.txt. Copyright (c) 2026 Riyaldi Hasan.
