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

v0.3.0

Published

OpenCode plugin to show your Go plan usage (rolling 5h / weekly / monthly) and reset times from the CLI/TUI

Downloads

52

Readme

opencode-plan-usage

English | 中文

OpenCode 插件:在 TUI 里用 /usage 命令(或让 agent 调用 go_usage 工具)快速查看你的 OpenCode Go 计划用量和重置时间,不用再开浏览器。

功能

| 入口 | 用法 | 效果 | |------|------|------| | TUI 命令 | 在 opencode 输入框敲 /usage 回车 | toast 弹出三个窗口的用量进度条 + 重置时间 | | Agent 工具 | 直接问 agent "查一下 Go 计划用量" | agent 自动调用 go_usage 工具并汇报 |

展示三个配额窗口(三行极简输出):

  • Rolling 5h($12 上限):滚动 5 小时窗口用量
  • Weekly($30 上限):本周用量
  • Monthly($60 上限):本月用量

每行依次显示:进度条 + 百分比 + 重置倒计时(h:mm,小时 3 位右对齐、空格补齐,分钟两位)。

原理

官方已提供正式 API(PR #16513,2026-08-11 合并):

GET https://opencode.ai/zen/go/v1/usage
Authorization: Bearer <opencode-go-api-key>

API key 直接从本地 ~/.local/share/opencode/auth.json 的 opencode-go 条目读取(支持 XDG_DATA_HOME 与 OPENCODE_AUTH_CONTENT 环境变量覆盖),无需浏览器、无需 workspace ID、无需 cookie。

安装

方式一:本地路径(当前方式)

把 package.json 里 exports 指向的目录(本仓库)加入两个配置文件:

server 端(~/.config/opencode/opencode.jsonc):

{
  "plugin": ["/Volumes/SourceCode/vscode/opencode-status"]
}

TUI 端(~/.config/opencode/tui.json):

{
  "plugin": ["/Volumes/SourceCode/vscode/opencode-status"]
}

tui.json 若不存在则新建;两处配置都保留原有的 oh-my-openagent 等已有插件。

方式二:npm 发布

npm publish
# 然后
opencode plugin install opencode-plan-usage

使用

# TUI 内
/usage

# 或直接问 agent
go_usage 工具查一下我的 Go 计划用量

示例输出(toast):

OpenCode Go usage
▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫   0%   4:09
▪▪▪▪▪▪▫▫▫▫▫▫▫▫▫▫▫▫▫▫  32%  20:06
▪▪▪▪▪▪▪▪▪▪▪▫▫▫▫▫▫▫▫▫  53% 383:45

实际效果:

/usage 命令输出

结构

screenshots/
  screen-shot.png   # /usage 命令实际效果截图
src/
  index.js   # 共享逻辑:读 key、调 API、格式化
  tui.js     # TUI 插件:/usage slash command(exports ./tui)
  server.js  # Server 插件:go_usage 工具(exports ./server)

无运行时依赖(@opencode-ai/plugin 仅用于 JSDoc 类型注释),纯 ESM JavaScript,opencode 的 Bun 运行时可直接加载。

已知限制

  • API 端点为官方新特性(2026-08-11 上线),响应结构可能随版本变化
  • 未设置轮询缓存;每次调用实时请求(建议间隔至少数分钟)
  • status: "rate-limited" 时进度条为 100%(极简模式无额外标记,满条即提示限流)