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

@lenucksi/opencode-usage-pace

v0.2.10

Published

Usage, billed costs and the OpenCode Go allowance in the TUI sidebar, with a burn-pace projection and cache economics.

Readme

opencode-usage-pace

opencode usage pace

See which of your OpenCode accounts is burning the Go allowance — and how soon it runs out — without leaving the TUI.

npm version license last commit

ccusage-style usage for OpenCode v2: a sidebar block that keeps billed cost and the catalog list price in separate columns, one Go block per connected account, and a full-screen page with the daily burn curve, the projected exhaustion day, a per-model table and a per-session cache breakdown.

The sidebar with two Go accounts

Local tokens, the active account's billed row with the catalog list price in a second colour, and one Go block per connected account. The green star marks the account in use.

Why not just the Console page?

  • Two accounts, two allowances. A service-account API key and a device sign-in can be connected at once. Each gets its own Go block, its own billed totals and its own pace; the active one carries a green ★. switch account › flips between them without leaving the TUI.
  • Billed and catalog never mix. The Console says what was charged; the catalog price of this machine's tokens sits next to it in a second colour with a ~, and the two are never added. On a Go subscription the gap is the point.
  • Pace, not just percentage. The block projects when the current slope reaches 100%, and refuses to project from a baseline younger than five minutes or past the reset that would clear it.

If you only want the Go percentages, opencode-go-meter is smaller and forecasts the same thing without the billing half.

Install

Requires OpenCode v2 (opencode --version → 2.x, whose plugins come from @opencode/plugin/tui).

opencode plugin add @lenucksi/opencode-usage-pace
opencode plugin list        # the package must appear before you restart

Restart OpenCode. To configure by hand instead, add it to ~/.config/opencode/opencode.jsonc:

{
  "plugins": ["@lenucksi/opencode-usage-pace"],
}

For hacking on it, clone and point the plugin directory at the checkout — plugins are also discovered from ~/.config/opencode/plugins/<name>/ and need no config entry:

git clone https://github.com/lenucksi/opencode-usage-pace ~/.config/opencode/plugins/opencode-usage-pace

Pick one of the two: a clone and an npm install of the same plugin load it twice, which duplicates the sidebar block and the command-palette entry.

What you need

  • For the local block: nothing. It reads the session database OpenCode already writes.
  • For the billed block, the burn chart and the Go meters: a sign-in to OpenCode Console (or an OpenCode Go subscription), done once with /connect. The plugin reads every integration_id = opencode credential from the databases in the OpenCode data directory (OPENCODE_DATA_DIR/OPENCODE_DB override it) and uses each one with the headers its method needs: a device sign-in (type: oauth) sends its access token plus the org headers, an API key (type: key) sends only the bearer. Both can be connected at once; each gets its own Go block.
  • An API key reads the billed summary, the CSV export and the Go meters. Budgets and the Activity views answer 403 for a key; that is not a defect. 403 and [] both mean "no dollar policy", no cap is drawn, and today's tokens come from the export instead.

Using it

| | | | ------------------------------- | -------------------------------------------------------------------------------- | | Sidebar | One block per account, plus the local token block; each folds on click | | details › | Opens the full page (also: /ccusage, or the palette entry “Usage and billing”) | | switch account › | Opens the account picker; the chosen credential becomes active immediately | | usage models value help | Four sections; models is the catalog, value prices your mix, help explains | | 1 2 3 | Switch the billed range on the page (chips are clickable too) | | esc q | Back to where you came from |

Each Go block folds on its own, and folded it names the most urgent window — weekly 100% rather than the calm rolling 11%. On the page, one tab per account holds its own Billed, Burn, Models, Requests, Projects and Go block; the tab marked with ★ is the account in use. The star only appears while the session's model is served by OpenCode (opencode or opencode-go) — a session on another provider owes no account a star.

The page

The full page with one tab per account

The burn chart with its hatched projection

One tab per account: Billed, Burn, Models, the local provider share and the Go block. The burn chart draws cumulative billed spend for the billing month, fills days the Console omits, extends the last seven-day average to the reset and marks the projected exhaustion day with ┊, and draws every column after it in the warning colour — the overshoot beyond 100 %. A real budget's cap is the ╌ line, never invented for Go.

Models separates the catalog by purpose — coding (chat), embedding, decisions (Jev-style typed answers) and other — and lists context, input/output, cache read, data retention, peak factor and the monthly dollar allowance per plan. Filters exclude training contributors, non-ZDR or above-30/55-day retention, non-free models and the three models the docs list as Global-region only. Retention days come from the Console docs; ? means undocumented, not zero.

Models section

Value prices your token mix of the selected range on every coding model, shows what the cache reads saved and what the current pace still buys, followed by the formula, inputs, assumptions and how to read the table. It needs one honest assumption: which Go plan the account has. Set it per account with the go/go-plus/go-teams chips; go is the default. Embeddings and decisions are excluded because they bill input only and get no Go discount.

Value section

Help maps the sidebar: the element on the left, what it means and where its numbers come from on the right, then About, the sections, keys and the documentation links.

Help section

Click a column header to sort, and click a row to highlight it across every column.

How the numbers are made

Two sources, deliberately apart:

  • Tokens · local — the host's session.stats over the local database, plus a per-provider share from the session table. Only tokens: a Go subscription stores cost = 0 in every message, so a local money column would be a lie. Expanding a range shows the input/output/reasoning/cache split and the provider rows, whose shares are scaled to the exact headline so they add up.
  • Billed · — the Console's /api/usage/summary for the three ranges, labelled with the account it came from. The same row carries ~$x.xx, the catalog list price of this machine's tokens, in a second colour: same row, two measurements, never added.

They disagree, and that disagreement is the point: on a Go subscription the catalog says $115 for a month that bills $48. Showing only one of them hides either your real spend or your real token appetite. A Go model row the Console prices at 0 shows ~$x.xx instead: the catalog list price for those tokens, marked with ~ and never counted as billed.

Models and Value. The catalog comes from the public /inference/go/v1/models; it is the only source of context sizes, peak multipliers and the monthly dollar allowance per plan. Prices are list prices — a subscription bills these tokens at zero — and peak factors are printed, not applied, because they depend on the UTC hour a request runs.

Pace. The three Go meters are shares of their own allowances — the Console documents a 5-hour window at 20% of the monthly allowance, a week at 50% and a month at 100%. The plugin samples each meter on every refresh (persisted, capped at 120 samples) and projects the current slope: 100% in 2h. A projection needs a baseline older than five minutes, is discarded when the window's reset changes underneath it, and is never shown if the limit would land after the reset that clears it. Only a pace that lands within the day outranks the percentage colour.

Burn chart. Cumulative billed spend for the current billing month, drawn from the daily series. Missing days are filled from the calendar (the Console omits days you did not use), the projection extends the last seven-day average to the reset, and ┊ marks the day the pace exhausts the monthly allowance — green before it, amber after. A real budget's cap is drawn as ╌ only when its reset is within two days of the monthly meter; Go has per-model allowances, so no dollar cap is invented for it.

Colours. A five-step pressure scale from theme tokens: green (< 30% used), green-to-yellow (30–50%), yellow (50–70%), orange (70–85%, or a pace that lands within the next 24 hours), red (85% and above, rate-limited, or under an hour left). No grey: two thirds of an allowance is not a neutral state. The percentage carries the usage colour while the projection carries its own and a » when the pace, not the percentage, is what makes the row urgent.

Pace colours

90 % is red on its own; 69 % stays yellow while the projection turns orange and gains » because it reaches the limit in an hour; 34 % is green-yellow with a muted reset.

Data sources

| Purpose | Endpoint | | --------------------------- | ------------------------------------------------------------------- | | Local token totals | host client session.stats (session.stats over the local DB) | | Local per-provider share | local session_v2 table (model, tokens_*, time_updated) | | Billed totals | GET …/api/usage/summary?range=24h\|7d\|30d | | Daily billed series + today | GET …/api/v2/usage/export?range=7d\|30d (CSV) | | Daily series fallback | GET …/api/usage/cost-by-day?range=30d&bucket=day | | Per-model rows | GET …/api/usage/models?range=…&pageSize=100&page=N | | Go allowance | GET https://opencode.ai/inference/go/v1/usage (/zen/… fallback) | | Model catalog (public) | GET https://opencode.ai/inference/go/v1/models | | Workspace budgets | GET …/api/policies/current-budgets (403/[] = no policy) | | Recent requests | GET …/api/request-logs?limit=20 | | Project totals | GET …/api/usage/cost-by-project?range=… |

The Console routes are undocumented apart from the CSV export and can change without notice. The plugin keeps showing the local block and names a real break (format changed, HTTP 5xx) instead of drawing a plausible zero. The documented CSV export is the primary source for the daily series and today, so a key and a device sign-in both work; cost-by-day and /api/usage/summary are fallbacks or the billed source, respectively.

The summary also carries services (web search, agent sandbox and box, with requests and cost but no model tokens) and the models endpoint tags subscription rows. Subscription requests from Claude Code and Codex on a member's own plan count real tokens at $0; they are marked (sub) in the model table instead of being presented as free inference. /api/usage/cost-by-project is not enabled in every workspace; the project section stays hidden when the Console answers anything but 200.

If the local today row ever reads zero while the month's activity already counts today's steps, the plugin retries that window once instead of caching a misleading zero for five minutes. The chevron on each of the local block's today, 7d and 30d rows expands that range's input, output, reasoning and cache read/write counts directly beneath it; one range is open at a time. The headline keeps fresh tokens so cache traffic does not dominate it.

Limits

  • The per-session split is an estimate: token counts are exact, the dollar split is the catalog's share of each category, scaled to what the turns recorded. The Console aggregates by day, model and user — never by session.
  • The per-provider share comes from the session table, so a session that switched models counts towards its last model. The share is scaled to the exact session.stats headline, which keeps the rows adding up but makes the split approximate for very long sessions.
  • The Go plan is an assumption. No endpoint we found reports it, so the Value tab uses the per-account setting (go by default). The percentages are unaffected; only the dollar math changes.
  • Pace needs five minutes of samples before it projects anything; until then you see the reset time.
  • Cache-write tokens are usually zero on Go (OpenAI-style caching does not charge writes). They only become interesting with providers that do, such as direct Anthropic.
  • Budgets and the Activity views are member-only. A machine with only an API key gets the meters, the billed summary and the documented export, but no dollar policy cap.
  • Every *.db in the OpenCode data directory is scanned for credentials; OPENCODE_DATA_DIR and OPENCODE_DB override the location. The plugin never writes to those databases.
  • The type contract for the v2 TUI API is vendored in types/ because that API is not on npm yet; bun check therefore checks against a mirror of packages/plugin/src/tui, not the published package.

When to use something else

  • Only want the Go percentages, nothing about money or cache? opencode-go-usage and opencode-go-meter are smaller and do exactly that; the latter also forecasts where the current pace lands.
  • Want per-project reports rather than a live view? opencode stats --project . --models --cost ships with OpenCode and prints the same local data as a shareable card.
  • Not using Console or Go at all? The local block still works, but the pace and billed halves will stay hidden.

Checks

One command runs everything that has to pass before a commit:

bun install
bun run gate

| Step | What it proves | | ------------ | ------------------------------------------------------------ | | format | bun fmt --check — 120 columns, no semicolons | | types | bun check | | language | no German in tracked files (this repository is English only) | | tests | bun test --coverage, floors at 85% lines and 90% functions | | aislop | WARN=ERR bun x aislop scan, score 80 or better | | gitleaks | no secrets in the commit history | | trufflehog | no verified secrets in the commit history |

bun run verify is the fast loop (types, format, language, tests). bun run secrets:deep additionally reports unverified secret candidates. The gate needs gitleaks and trufflehog on PATH, and fails rather than skipping them.

Tests cover what broke in practice: month arithmetic across month ends, calendar gaps versus the UTC day keys the Console uses, cap selection between budgets on different cycles, pace baselines across a window reset, credential fallback between database files, and malformed payloads. See AGENTS.md for the repository rules.

Status

Early, single-author. Seven Console route families are undocumented; the daily series and today come from the documented CSV export, and the web routes are fallbacks. Every number is read from a file or an endpoint listed above, and an estimate is labelled as one.

License

MIT