Go Usage
OpenCode TUI plugin that shows OpenCode Go subscription usage (rolling / weekly / monthly) in the sidebar
0
865
近 7 天 35
37.6
生态多维模型
14 天前
2026-09-21
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pistonex/opencode-go-usage@0.1.4"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pistonex/opencode-go-usage@0.1.4"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @pistonex/opencode-go-usageOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
An OpenCode TUI plugin that shows your OpenCode Go subscription usage in the sidebar: rolling (5 h), weekly and monthly limits, with percent consumed, status and time until each reset.
Data comes from the public API — no scraping:
GET https://opencode.ai/zen/go/v1/usage(Bearer API key of youropencode-goaccount) →rolling,weeklyandmonthlypercent,ok/rate-limitedstatus and reset date.
What it looks like
Rendered in the sidebar.content slot of every session:
┌────────────────────────────────────────┐
│ ⬖ OpenCode Go ▾ │
│ rolling █░░░░░░░ 0% ✓ ↻ 2h │
│ weekly ░░░░░░░░ 4% ✓ ↻ 1h │
│ monthly ████████ 100% ✕ ↻ 9d │
└────────────────────────────────────────┘
Up to 3 rows (rolling / weekly / monthly) with a usage bar, percent and time until reset. Auto-refreshes every 5 minutes (no requests are made while the widget is collapsed). Collapsed, only the header with "▾/▸" remains.
Use Show or hide the OpenCode Go usage panel (palette Ctrl+P, or slash
/opencode-go) to toggle the widget. The state persists across restarts.
Install
Add the package to plugins in your global ~/.config/opencode/opencode.json(c):
{
"plugins": ["@pistonex/opencode-go-usage"]
}
For CLI-only behavior against remote servers, add it to ~/.config/opencode/cli.json
instead:
{
"plugins": ["@pistonex/opencode-go-usage"]
}
Then restart OpenCode.
Requires OpenCode v2 (CLI plugin API).
How it gets the API key
The plugin reads ~/.local/share/opencode/account.json, finds the account with
serviceID === "opencode-go" and uses its credential.key. The key is only
used in memory for the Authorization: Bearer request; it is never printed or
written anywhere.
Language
The plugin is bilingual (ES/EN). Language resolution order:
- The plugin
languageoption ("es"or"en") inopencode.json(c) - A persisted choice (see the slash command below)
- Auto-detected from your environment (
LANG/LC_ALL)
Override it at any time with the slash command:
/opencode-go-lang— toggle ES/EN/opencode-go-lang en//opencode-go-lang es— set a specific language
Options
{
"plugins": [{ "package": "@pistonex/opencode-go-usage", "options": { "language": "en" } }]
}
| Option | Values | Description |
|---|---|---|
language |
es, en |
Force a language, ignoring the rest |
Configuration
Constants live in src/opencode-go-usage.tsx:
USAGE_URL— public usage endpoint (only change if the API changes)REFRESH_MS— refresh interval (default 5 min)FETCH_TIMEOUT_MS— request timeout (default 10 s)
Notes
The Zen balance and the "Use balance" toggle are not exposed by any public OpenCode API (they live in the console's database and are read through browser-session server actions). This plugin shows subscription usage, which is everything the API offers. See docs/RESEARCH.md for the full investigation.
Development
npm install
npm run typecheck
The plugin is a single .tsx file (src/opencode-go-usage.tsx) using the
standard OpenCode v2 CLI plugin contract: Plugin.define({ id, setup }) from
@opencode/plugin/tui, @opentui/solid JSX and theme tokens via
usePlugin().
License
MIT © Tony Pistone
同类生态推荐
Tui Quota Usage
opencode-tui-quota-usage
OpenCode quota usage sidebar tracker for OpenCode V2 CLI/TUI
Usage Report
opencode-usage-report
opencode plugin: /usage command showing subscription quota windows for configured providers
Usage
@1930dev/opencode-usage
Usage tracking, budget percentages and model ranking for opencode — CLI plus a /usage TUI plugin