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-usage-footer

v0.1.0

Published

Responsive token usage and cache statistics footer for the OpenCode TUI

Readme

opencode-token-usage-footer

English | 简体中文

这是一个响应式 OpenCode TUI 底栏插件,用于显示 Token 总量、缓存命中率、 输入、输出、推理 Token、缓存读写、费用和子会话数量。

环境要求

  • OpenCode 1.18.5 或更高版本
  • 使用 OpenCode TUI

安装

编辑全局 TUI 配置 ~/.config/opencode/tui.json,加入 npm 包:

{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": ["opencode-token-usage-footer"]
}

如果已有其他 TUI 插件,把它追加到现有 plugin 数组中:

{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": [
    "opencode-wlb-quota",
    "opencode-token-usage-footer"
  ]
}

修改配置后完全退出并重新启动 OpenCode。

显示内容

底栏会根据终端宽度自动调整:

  • 窄屏:Token 总量和缓存命中率
  • 中等宽度:输入、输出和费用
  • 宽屏:推理 Token、缓存读写和会话数量

统计范围包含当前会话及其所有子会话和子代理会话。打开会话时,插件会在 相关 OpenCode 事件后刷新,并每两秒轮询一次。

缓存命中率计算方式:

缓存读取 /(未缓存输入 + 缓存读取)

隐私

插件只通过本机 OpenCode TUI API 读取会话统计数据,不会向外部服务发送 数据,也不需要 API Key 或其他凭据。

常见问题

底栏没有显示

  1. 确认正在查看具体会话;首页不会显示统计底栏。
  2. 确认插件配置在 tui.json 中,而不是 opencode.json 中。
  3. 确认 OpenCode 版本不低于 1.18.5。
  4. 修改配置后完全退出并重新启动 OpenCode。

显示 TOK · unavailable

插件暂时无法读取当前会话数据。可以等待下一次自动刷新,或重新进入该会话。

本地开发

npm install
npm run typecheck
npm pack --dry-run

许可证

MIT