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-bar

v0.1.2

Published

OpenCode TUI plugin that shows daily token usage (in/out) and current context-window percentage in the bottom bar

Readme

opencode-token-bar

An opencode TUI plugin that renders a compact, color-coded token-usage line in the bottom bar:

day ↑31.5K ↓12.3K  │ ctx 16%
  • / — total tokens used today, summed across every session and project. (input) = input + cache read + cache write; (output) = output
    • reasoning. Arrows and labels are dimmed; the numbers use the theme's text color.
  • ctx 16% — the current session's context-window usage, using the same formula opencode shows internally: (input + output + reasoning + cache.read + cache.write) / model context limit. Colored by how full the window is — green <60%, yellow <85%, red otherwise.

The bar is shown only while a session is open — it is hidden on the home screen. Colors come from the active opencode theme, so it blends in with the rest of the TUI.

How it works

This is a TUI plugin. It:

  1. Reads today's usage straight from opencode's own database (~/.local/share/opencode/opencode.db, or under $XDG_DATA_HOME). A single aggregate query sums the tokens of every assistant message created today across all sessions and projects — so the bar shows the real daily total immediately, even right after launch.
  2. Subscribes to message.updated to re-query the total as work happens and to compute the current session's context percentage.
  3. Registers an app_bottom slot, rendered only while a session is open.

The daily total rolls over automatically at local midnight. The database is opened read-only; if it can't be read the bar simply shows nothing.

Install

Install it as an opencode TUI plugin:

opencode plugin opencode-token-bar

This adds opencode-token-bar to the plugin array in ~/.config/opencode/tui.json. Restart opencode and the bar appears at the bottom. You can also add it by hand:

{
  "plugin": ["opencode-token-bar"]
}

Develop locally

bun install
bun run build      # -> dist/tui.js
bun test

To run your local build instead of the published package, point the TUI config at the project directory (opencode loads dist/tui.js from the package main):

{
  "plugin": ["/home/you/path/to/opencode-token-bar"]
}

License

MIT © Lilithya <me@lilithya>