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

@jurci/tui-monthly-usage

v1.0.4

Published

Opencode TUI plugin for tracking daily, weekly, and monthly token usage and model spend in the sidebar

Readme

tui-monthly-usage

An opencode TUI plugin that adds a monthly usage and cost breakdown widget to your sidebar.

Preview

Here is how the widget looks in the opencode sidebar:

OpenCode TUI showing daily, weekly, and monthly costs and per-model token usage in the sidebar

Features

  • Daily & Weekly Totals: Live spend tracking for today and the current week.
  • Monthly Summary: Total cost and token usage for the active calendar month.
  • Model Breakdown: Top models sorted by monthly spend or token count, highest first, with a configurable row count and friendly shortened model names.
  • Local Database Discovery: Uses OpenCode's local data directory and respects OPENCODE_DB overrides.

Requirements

  • sqlite3 CLI version 3.33 or newer installed and available in $PATH (JSON output is required)
  • OpenCode with TUI plugin support

Installation

opencode plugin add @jurci/tui-monthly-usage

Configuration

Add the plugin to ~/.config/opencode/cli.json:

{
  "$schema": "https://opencode.ai/v2/cli.json",
  "plugins": [
    "@jurci/tui-monthly-usage"
  ]
}

To change the model count, ranking, estimated costs, or set a monthly budget, use an options object:

{
  "$schema": "https://opencode.ai/v2/cli.json",
  "plugins": [
    { "package": "@jurci/tui-monthly-usage", "options": { "maxModels": 10, "sortBy": "tokens", "monthlyBudget": 1500 } }
  ]
}
  • maxModels: Non-negative integer. Defaults to 7; 0 hides model rows.
  • sortBy: "cost" (default) or "tokens". The highest value is always first; ties use the other value, then the model name.
  • costMultipliers: Optional provider-to-multiplier map for company discounts or markups. Costs use OpenCode's recorded estimate by default (1). For example, "openai": 0.8 applies a 20% discount to OpenAI rows before totals, rankings, and model costs are calculated. Token counts are unchanged.
  • monthlyBudget: Optional positive USD amount. When set, the heading shows the rounded budget percentage, and the month row compares adjusted tracked spend with the budget. Monthly tokens move to their own row. OpenCode records cost estimates in USD; no currency conversion is performed.
  • Totals always include all models, regardless of the row limit.

Local Development

Build with npm run build, then add the built dist directory to cli.json for local development or testing without publishing to npm:

{
  "$schema": "https://opencode.ai/v2/cli.json",
  "plugins": [
    "/path/to/tui-monthly-usage-plugin/dist"
  ]
}

Quit and restart OpenCode after changing the plugin configuration or rebuilding it.

The widget reads the local database, normally $XDG_DATA_HOME/opencode/opencode.db or ~/.local/share/opencode/opencode.db. OPENCODE_DB can be an absolute path or a path relative to the opencode data directory. For a channel-specific database, set OPENCODE_DB to that database's filename. A remote server's database and an in-memory database cannot be read by this local SQLite subprocess.

Cost and Token Limitations

This widget reports usage recorded by OpenCode in its local database, not your provider's billing statement. By default, its costs are OpenCode's estimates using OpenCode's configured standard model rates; company discounts, negotiated rates, and provider billing adjustments are not detected automatically. Use costMultipliers when you know a provider-specific adjustment. It only includes activity recorded by this local OpenCode installation.

For subscription-based access, such as signing in with a ChatGPT account, monetary costs may be zero or unavailable. $0.00 does not necessarily mean the usage was free. Token counts can still appear when the provider reports them and OpenCode stores them. ChatGPT subscriptions and API usage are billed separately.

The widget does not show subscription fees, remaining plan allowance, or reset times.

With the default cost sorting, zero-cost subscription models may fall below the displayed row limit. Set sortBy to "tokens" or increase maxModels to make them easier to find.

Development

Development requires Node.js, npm, and sqlite3. The build and TUI tests run Bun 1.3.3 through npx.

# Install dependencies
npm install

# Typecheck and build TypeScript to dist/
npm run build

# Run unit and integration tests
npm test

# Run only the TUI rendering test (after building)
npm run test:tui

# Typecheck without emitting
npm run typecheck

License

MIT