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

v0.6.1

Published

Real-time token usage, cache analytics & performance dashboard plugin for OpenCode CLI

Readme

opencode-tokenwatch

English · 简体中文

Sidebar

OpenCode CLI的终端监控插件,在侧边栏实时显示Token用量、缓存命中率与模型响应速度,并支持一键生成网页版可视化用量报表。


主要特性

  • 侧边栏实时看板:会话中随时查看各模型的输入输出Token、预估花费、缓存命中率,以及当前会话的平均首字延迟与生成速率。
  • 缓存命中率与趋势:按模型追踪缓存利用效率,用箭头标注近几次请求的命中率是在上升还是下降。
  • Token构成归类:自动将Token按系统提示词、用户输入、工具调用和模型输出分别统计,清楚定位上下文占用大头。
  • 交互式用量报告:在终端输入 /usage 即可在浏览器中打开ECharts 交互仪表盘,查看历史用量趋势、模型横向对比与失败请求统计;也可一键导出为JSON或Markdown文件。
  • 双版本无缝适配:同时兼容 OpenCode 1.x 与 OpenCode 2(beta),自动识别宿主环境,无需手动切换或调整配置。

安装与配置

1. 安装

在项目中运行:

npm install opencode-tokenwatch

2. 启用插件

在配置文件 opencode.json(或 opencode.jsonc)中添加插件项:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-tokenwatch"]
}

重新打开 OpenCode,侧边栏便会自动载入 TokenWatch 面板。


常用操作

在终端对话框中输入 /usage 即可唤出操作菜单:

  • HTML 报告:选择统计日期范围,在默认浏览器中打开交互式图表。
  • 导出数据:导出结构化 JSON 或 Markdown 报告,默认保存在 ~/.opencode/reports/ 目录下。
  • 设置:在弹出的交互菜单中开关各个显示区块或切换中英文显示。改动会自动保存,不需要手动修改配置文件。

系统要求

  • OpenCode CLI:1.18+ 或 OpenCode 2(@opencode-ai/cli@beta)
  • Node.js:≥ 18.0.0

相关项目


协议

MIT