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

opencode-token-spend-bar

v1.0.3

Published

A reusable TUI plugin for OpenCode that displays token spending for MiniMax API, OpenCode Go, and ChatGPT Plus

Readme

OpenCode Token Spend Bar Plugin

A reusable TUI plugin for OpenCode that displays a compact token spending widget in the session sidebar. Track your API costs at a glance without leaving your terminal.

What It Does

The plugin shows a small spending summary in the right sidebar of an active session. It displays month-to-date costs for supported providers, updating as you work. The widget sits in the sidebar_content slot, so it stays near the built-in session context panels.

Supported Providers

| Provider | Display | Currency | Notes | |----------|---------|----------|-------| | MiniMax API | MM | USD | Real cost metadata from OpenCode | | OpenCode Go | OCG | USD | Real cost metadata from OpenCode | | ChatGPT Plus | GPT+ | N/A | Usage-only display |

Only MiniMax, OpenCode Go, and ChatGPT Plus are supported. Other providers are silently ignored.

Current Month Semantics

The widget aggregates data for the current calendar month. When the month changes, the widget automatically rebuilds its cache from OpenCode local history to show fresh data for the new month. Historical months are not displayed.

Installation

Install the plugin in the OpenCode config directory:

cd ~/.config/opencode
npm install opencode-token-spend-bar

The plugin has peer dependencies on OpenCode packages. Your OpenCode installation should provide these automatically. If you see errors about missing peer dependencies, ensure you are running a recent version of OpenCode.

Configuration

Add the plugin to your tui.json configuration file:

{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": [
    [
      "./node_modules/opencode-token-spend-bar/dist/tui.js",
      {}
    ]
  ]
}

This is a TUI plugin, so it should not be added to opencode.json.

A full example configuration:

{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": [
    [
      "./node_modules/opencode-token-spend-bar/dist/tui.js",
      {}
    ]
  ]
}

v1 Limitations

This release has known constraints:

  • Session-only display: The widget appears only in active sessions, not on the home screen
  • No budget alerts: Cost thresholds and notifications are not implemented
  • No remote provider polling: The plugin reads only from OpenCode local storage
  • ChatGPT Plus shows usage only: The plugin displays token counts for ChatGPT Plus but cannot show synthetic currency costs

Troubleshooting

Missing cost rows

If you see a provider row missing from the display, the plugin fell back to usage-only mode because OpenCode has not recorded cost metadata for that provider in the current session. This is normal for providers that do not emit cost events.

Empty data on first run

The widget needs time to aggregate data from OpenCode history. On first install or after a month change, you may see empty or zero values for a few seconds until the aggregation completes. The widget updates automatically once data is available.

Stale cache after month change

When the calendar month changes, the plugin rebuilds its cache from OpenCode local history. This happens automatically. If you notice incorrect data at month boundaries, restarting your session will trigger a fresh aggregation.

Uninstall

To remove the plugin, edit your tui.json and remove the plugin entry:

{
  "plugin": []
}

Then uninstall the package:

cd ~/.config/opencode
npm uninstall opencode-token-spend-bar

Requirements

  • OpenCode CLI with TUI support
  • Node.js 18 or later
  • Peer dependencies: @opencode-ai/plugin, @opencode-ai/sdk, solid-js, @opentui/core, @opentui/solid

License

MIT