npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@beast-course/opencode-token-tracker

v0.1.0

Published

Local, read-only dashboard and CLI for OpenCode token usage, spend, and budget

Readme

@beast-course/opencode-token-tracker

A local, read-only dashboard and CLI that tracks OpenCode's token usage from OpenCode's own SQLite database. No plugins, no hooks, no cloud.

What it does

Reads ~/.local/share/opencode/opencode.db (read-only, WAL-safe) and shows:

  • Web dashboard (python -m tracker serve) — minimalist dark/light dashboard with a range selector (Daily / Weekly / Monthly / All time), a stacked input/output token chart, and a per-model usage panel. Auto-refreshes every 30s.
  • CLI — summary prints monthly spend/tokens; sessions --csv exports sessions.

Cost is computed from a user-maintained pricing table (the DB's cost column is 0 for free models). Free models (*-free) price at $0 automatically.

Install

pip install -r requirements.txt
pip install -r requirements-dev.txt   # for tests

Python 3.11+.

npm package

The tool also ships as an npm package (the Python code is bundled inside):

npm install -g @beast-course/opencode-token-tracker
tracker summary
tracker serve

Or without installing:

npx @beast-course/opencode-token-tracker summary

The serve command needs the Python web dependencies once:

pip install -r requirements.txt

Set TRACKER_PYTHON to use a specific Python interpreter.

Configure

copy config.example.json config.json   # Windows
cp config.example.json config.json     # Unix

Defaults work out of the box: DB path ~/.local/share/opencode/opencode.db (override with OPENCODE_DB env var), budget $20/month, port 8765. Config schema:

{
  "db_path": "~/.local/share/opencode/opencode.db",
  "budget": { "monthly": 20.0, "currency": "USD", "reset_day": 1 },
  "pricing": {
    "openai/gpt-4o": { "input": 2.50, "output": 10.00, "cache_read": 1.25, "cache_write": 2.50 }
  },
  "server": { "host": "127.0.0.1", "port": 8765 },
  "refresh_seconds": 30
}

Prices are USD per 1M tokens. An explicit entry always wins; a model id ending in -free is free when unpriced; unknown models are flagged unpriced (DB cost used as fallback when positive).

Usage

python -m tracker serve                 # dashboard at http://127.0.0.1:8765
python -m tracker summary               # monthly summary in the terminal
python -m tracker summary --month 2026-07
python -m tracker summary --json
python -m tracker sessions --csv out.csv
python -m tracker serve --port 9000

Budget

Monthly budget with configurable reset day (default 1st). 80% = warning, 100% = exceeded. Month-end projection = spent / elapsed_days * total_days.

Design

Minimalist dashboard, dark + light themes (toggle in the header, persisted), Rubik + JetBrains Mono (vendored woff2, fully offline), hand-rolled SVG charts — no chart library, no build step.

Troubleshooting

  • DB not found — dashboard shows an error banner; set OPENCODE_DB or fix db_path in config.json.
  • Port busy — Port 8765 is in use - try --port 9000.
  • WAL read-only failure — the tool falls back to a snapshot copy of the DB + WAL files in a temp dir.
  • Missing dependency — Missing dependency: fastapi. Run: pip install -r requirements.txt.

Tests

python -m pytest

Roadmap (v2)

  • Message text rendering
  • TUI dashboard
  • Notifications