Skip to content

Repository files navigation

OpenCode Stats logo

OpenCode Stats

Lightweight desktop dashboard for your OpenCode usage — tokens, costs, charts.
Tauri v2 · ~10 MB .exe · ~30 MB RAM · EN/IT

License: MIT Platform: Windows Tauri 2 React 19 CI Release  ·  EN IT

⬇️ Download latest — Windows setup + portable .exe.


OpenCode Stats dashboard


📊 Input/output tokens, cost, cache — daily, weekly, all-time
📈 Line, bar & donut charts, top models, recent sessions, reasoning tokens
🎛️ Per-provider filters, Combined / Split views, brand icons
👤 Customizable profile (photo, name, bio), activity heatmap, light/dark theme
🌍 English + Italian interface
🔒 100% local: read-only DB access, no keys, no auth, no telemetry

Install & release notes

Download OpenCode Stats_*_x64-setup.exe (recommended) or the .msi from Releases. Requires Windows 10/11 x64 with WebView2 (usually preinstalled) and OpenCode used at least once (the app reads its local database).

The app is not code-signed: Windows shows "unknown publisher" — that's expected. On SmartScreen: "More info → Run anyway".

v0.1.12 — verifiable heatmap (per-day hover stats), 32 GiB DB cap, all-time anti-rescan, react-dom alignment fix. v0.1.11 — first release since v0.1.7: reasoning tokens, true all-time, per-period sessions, provider attribution, tests; green CI. v0.1.10 — reasoning tokens, true all-time range, per-period sessions, real provider attribution, unit tests (vitest + cargo). v0.1.9 — security hardening: ECharts stored-XSS guard, stricter CSP, photo allowlist, DB path/size checks; CI least-privilege + Dependabot. v0.1.8 — fixed profile photo upload (valid images wrongly rejected as "over 10 MB"); new GitHub-style token activity heatmap in profile settings. v0.1.7 — Content Security Policy enabled; TypeScript pinned to exact 6.0.3; backend call timeouts; automated CI (frontend + Tauri builds). v0.1.6 — fixed provider-filter crash (backend/frontend field naming mismatch); selection stats hardened against shape drift. v0.1.5 — "OpenCode is not installed" screen with IT/EN switch; readable sub-dollar cost axis; Terzastella publisher + custom installer icons; release build scrubbed of machine paths.

More screenshots
Donut chart view

Donut view (toggle Bars / Pie on the card)


Profile settings

Profile settings (photo, name, bio)

How data works

It reads ~/.local/share/opencode/opencode.db read-only (OPENCODE_DB_PATH override — on Windows: %USERPROFILE%\.local\share\opencode\opencode.db):

  • message.data (JSON: role/providerID/modelID/tokens/cost) → KPIs, daily/weekly, per-provider split
  • session (cost/tokens_* aggregates) → recent sessions list

Providers used through OpenCode (opencode/*, ollama/*, lmstudio/*, llama.cpp/*, …) are filterable with Combined / Split views and stable per-provider colors. Filtered views and recent sessions show period-attributed numbers, which may differ from opencode stats upstream by design.

The app is OpenCode-only: it only reads its database — no API keys, no auth, no external network access at runtime (localhost only). Original files are only ever read. No telemetry of any kind.

Development & build
npm install
npm run tauri dev      # app + hot reload (live data from your opencode.db)

Without Tauri (npm run dev) the UI shows a warning because Rust invokes are unavailable. npm run dev + ?demo opens a demo dataset (also handy for screenshots).

npm run tauri build
# -> src-tauri/target/release/opencode-stats.exe
# -> src-tauri/target/release/bundle/nsis/OpenCode Stats_0.1.12_x64-setup.exe (+ .msi)

For published releases, build with scripts/build-release.ps1 instead: same output, but scrubs build-machine paths from the binary via --remap-path-prefix.

Note: if you change icons or tauri.conf.json and the exe doesn't pick them up, delete src-tauri/target/release/build/opencode-stats-*/ before rebuilding: Tauri's build script (Windows resources/icons) doesn't always re-run on its own and would link stale resources. cargo clean -p alone is not enough.

Project structure & legal
  • src-tauri/src/stats.rs — read-only SQLite queries + db_info/session_list/dashboard/selection_stats commands
  • src/lib/ — api.ts, types.ts, format.ts, profile.ts (localStorage profile), providers.ts (stable provider colors), brand.tsx (provider logos), i18n.ts (EN/IT), demo.ts (?demo dataset)
  • src/App.tsx — dashboard: KPIs, ECharts charts (tokens/cost/per-provider bars+donut), top models, sessions
  • Silent refresh every 30 s (pausable) + refresh on focus, light/dark theme, Daily (14 d) / Weekly (8 wks) / All ranges

Provider icons come from Simple Icons v16.30.0 (CC0, bundled locally — no external loading). Additional marks vectorized from official sources: OpenCode brand (MIT project, also for Zen), Groq logo and Cerebras logo via Wikimedia Commons (referential use: they only identify the token source in your statistics). All trademarks belong to their respective owners.


Italiano

🇮🇹 Versione italiana — English sopra · ⬇️ Download latest

Dashboard desktop leggera (Tauri v2, .exe ~10 MB, ~30 MB RAM) per le statistiche di utilizzo di OpenCode: input/output tokens, costo, viste giornaliere/settimanali/tutto, grafici e tabelle, profilo personalizzabile, interfaccia EN/IT.


Dashboard OpenCode Stats


📊 Token input/output, costi, cache — giornaliero, settimanale, tutto
📈 Grafici linee, barre e torta, top modelli, sessioni recenti, reasoning
🎛️ Filtri per provider, viste Sommati / Singoli, loghi brand
👤 Profilo personalizzabile (foto, nome, bio), heatmap attività, tema chiaro/scuro
🌍 Interfaccia inglese + italiano
🔒 100% locale: sola lettura DB, niente chiavi, niente telemetria

Installazione e note di release

Scarica OpenCode Stats_*_x64-setup.exe (consigliato) o il .msi dalle Release. Richiede Windows 10/11 x64 con WebView2 (di solito già presente) e OpenCode già usato almeno una volta (l'app legge il suo database locale).

L'app non è firmata digitalmente: Windows mostra "autore sconosciuto" — è normale. Su SmartScreen: "Ulteriori informazioni → Esegui comunque".

v0.1.12 — heatmap verificabile (statistiche al passaggio mouse), cap DB 32 GiB, anti-rescan all-time, fix allineamento react-dom. v0.1.11 — prima release dalla v0.1.7: reasoning token, vero all-time, sessioni per-periodo, attribuzione provider, test; CI verde. v0.1.10 — reasoning token, vero all-time, sessioni per-periodo, attribuzione provider reale, unit test (vitest + cargo). v0.1.9 — hardening sicurezza: anti-XSS nei grafici, CSP rafforzata, allowlist foto, controlli path/dimensione DB; CI least-privilege + Dependabot. v0.1.8 — corretto il caricamento della foto profilo (immagini valide scartate come "oltre 10 MB"); nuova heatmap stile GitHub dei token nelle impostazioni profilo. v0.1.7 — Content Security Policy attivata; TypeScript pinnato alla 6.0.3; timeout sulle chiamate backend; CI automatica (build frontend + Tauri). v0.1.6 — corretto il crash alla selezione di un provider (nomi dei campi disallineati tra backend e frontend); statistiche di selezione più robuste. v0.1.5 — schermata "OpenCode non installato" con selettore IT/EN; tacche leggibili sull'asse dei costi sotto il dollaro; publisher Terzastella + icone installer; build release ripulita dai percorsi macchina.

Altri screenshot
Vista torta

Vista torta (toggle Barre / Torta sulla card)


Impostazioni profilo

Pannello impostazioni profilo

Come funzionano i dati

Legge in read-only ~/.local/share/opencode/opencode.db (override con OPENCODE_DB_PATH — su Windows: %USERPROFILE%\.local\share\opencode\opencode.db):

  • message.data (JSON: role/providerID/modelID/tokens/cost) → KPI, daily/weekly, split per provider
  • session (aggregati cost/tokens_*) → lista sessioni recenti

I provider usati via OpenCode (opencode/*, ollama/*, lmstudio/*, llama.cpp/*, …) sono filtrabili con vista Sommati / Singoli e colori stabili per provider. Viste filtrate e sessioni recenti mostrano numeri attribuiti al periodo, che possono differire da opencode stats ufficiale per scelta.

L'app è dedicata a OpenCode: legge solo il suo database, niente chiavi API, niente auth, nessuna rete esterna a runtime (solo localhost). I file originali sono sempre e solo letti. Nessuna telemetria di alcun tipo.

Sviluppo e build
npm install
npm run tauri dev      # app + hot reload (dati live dal tuo opencode.db)

Senza Tauri (npm run dev) l'UI mostra un avviso perché gli invoke Rust non sono disponibili. npm run dev + ?demo apre un dataset dimostrativo (comodo anche per screenshot).

npm run tauri build
# -> src-tauri/target/release/opencode-stats.exe
# -> src-tauri/target/release/bundle/nsis/OpenCode Stats_0.1.12_x64-setup.exe (+ .msi)

Per le release pubblicate, compila invece con scripts/build-release.ps1: stesso output, ma ripulisce i percorsi della macchina di build dal binario via --remap-path-prefix.

Nota: se cambi icone o tauri.conf.json e l'exe non li recepisce, cancella src-tauri/target/release/build/opencode-stats-*/ prima di rebuildare: lo script di build di Tauri (risorse Windows/icons) non sempre si ri-esegue da solo e linkerebbe risorse vecchie. cargo clean -p da solo non basta.

Struttura progetto e note legali
  • src-tauri/src/stats.rs — query SQLite read-only + comandi db_info/session_list/dashboard/selection_stats
  • src/lib/ — api.ts, types.ts, format.ts, profile.ts (profilo in localStorage), providers.ts (colori stabili per provider), brand.tsx (loghi provider), i18n.ts (EN/IT), demo.ts (dataset ?demo)
  • src/App.tsx — dashboard: KPI, grafici ECharts (token/costo/per-provider barre+torta), top modelli, sessioni
  • Refresh silenzioso ogni 30 s (pausabile) + refresh su focus, tema chiaro/scuro, range Giornaliero (14 gg) / Settimanale (8 sett) / Tutto

Le icone dei provider vengono da Simple Icons v16.30.0 (CC0, bundle locale — nessun caricamento esterno). Marchi aggiuntivi vettorializzati dalle fonti ufficiali: OpenCode brand (progetto MIT, anche per Zen), logo Groq e logo Cerebras da Wikimedia Commons (uso referenziale: identificano solo la sorgente dei token nelle tue statistiche). Tutti i marchi citati appartengono ai rispettivi proprietari.

About

Lightweight desktop dashboard for OpenCode token usage and costs (Tauri v2 + React)

Topics

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages