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.5.0

Published

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

Readme

opencode-tokenwatch

English · 简体中文

Sidebar

OpenCode CLI 的实时 Token 用量统计、缓存分析与性能指标插件。

功能

  • 侧边栏面板 — 会话级与按模型的实时统计(请求数、Token、缓存、成本)
  • 缓存命中率 — 按模型实时追踪,带趋势指示器(↑/↓)与全局加权总计
  • 性能指标 — TTFT / TPS / 端到端延迟,含 P50/P95/P99 延迟分位数
  • Token 分布 — 按角色(system / user / tool / output)分解用量占比
  • 成本追踪 — 按模型实时显示请求成本(需 provider 返回计费数据)
  • 错误率统计 — 识别并统计失败请求,实时计算错误率
  • /usage 命令 — HTML 报告 → JSON 导出 → 文本报告 → 设置
  • HTML 报告 — 交互式 ECharts 仪表盘:Token 趋势、性能对比、TPS 排名、错误率分析,自动在浏览器打开
  • 持久化统计 — 性能指标永久累积写入独立文件,历史数据不受会话重置影响
  • 多级折叠 — 面板、模型、子区块均可折叠,状态持久化
  • 语言切换 — 中英双语,跟随系统或手动切换

安装

npm install opencode-tokenwatch

opencode.jsonopencode.jsonc 中添加:

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

配置

在 OpenCode TUI 中输入 /usage设置,可交互式开关各显示项和切换界面语言,配置自动持久化,无需手动编辑配置文件。

用法

在 OpenCode TUI 中输入 /usage,选择:

  • HTML 报告 — 选择日期范围,生成仪表盘并在浏览器打开
  • JSON 导出 — 导出完整用量数据至 ~/.opencode/reports/
  • 文本报告 — 导出 Markdown 格式至 ~/.opencode/reports/
  • 设置 — 开关侧边栏显示项、切换语言

数据文件

| 文件 | 路径 | 说明 | |------|------|------| | JSONL 日志 | ~/.opencode/tokenwatch.jsonl | 原始请求日志 | | 聚合统计 | ~/.opencode/tokenwatch-stats.json | 持久化性能统计 | | 报告输出 | ~/.opencode/reports/ | HTML / JSON / Markdown 报告 |

系统要求

  • OpenCode CLI(支持 opencode db 命令)
  • Node.js 18+

构建

npm install
npm run build

相关项目

许可

MIT