1
602
近 7 天 67
39.4
生态多维模型
8 天前
2026-09-26
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-quota-sidebar@0.3.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-quota-sidebar@0.3.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-quota-sidebarOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode V2 sidebar plugin: month-to-date tokens/cost, OpenCode Go quota (rolling 5h / weekly / monthly) with reset countdowns, and the Zen credit balance.
USAGE · Sep 2026
in 2.4M
out 415.3K
cache 232.1M
cost $1.74
QUOTA SPEND
5h 3% ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 2h17m
week 2% ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 1d5h
month 1% ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 23d23h
credit $8.29
Setup
Install the plugin (OpenCode V2):
opencode plugin add opencode-quota-sidebarOr add it to the global
~/.config/opencode/cli.jsonyourself:{ "plugins": ["opencode-quota-sidebar"] }Connect the OpenCode Go provider so the quota bars have data:
opencode auth login # choose OpenCode GoSign in to the Zen console once for the credit balance, from the TUI:
/quota-loginRestart OpenCode.
From a local checkout
cd /path/to/opencode-quota-sidebar
npm install && npm run build
Then point cli.json at the checkout:
{
"plugins": ["file:///absolute/path/to/opencode-quota-sidebar"]
}
What OpenCode must provide
| Sidebar data | Required | Where it comes from |
|---|---|---|
| Tokens + cost | connected server | client.session.stats for the calendar month — no setup |
| Go quota | OpenCode Go API key | OPENCODE_GO_API_KEY / OPENCODE_API_KEY, else the opencode-go credential in ~/.local/share/opencode/opencode.db (written by opencode auth login), else a legacy auth.json in ~/.local/share/opencode/ or ~/.config/opencode/ |
| Zen credits | OpenCode Console session | /quota-login (device-code flow), token stored in $XDG_STATE_HOME/opencode/quota-sidebar/auth.json — default ~/.local/state/opencode/quota-sidebar/auth.json |
Notes:
- If the Go provider is already connected, no key configuration is needed.
- Before
/quota-loginthe row readscredit login; if the session is revoked it readscredit re-login. - Signing out: delete the token file above (or remove the plugin). The OAuth
token is stored mode
0600in a0700directory.
Configuration
| Variable | Purpose |
|---|---|
OPENCODE_GO_API_KEY / OPENCODE_API_KEY |
Override the discovered Go key |
QUOTA_POLL_MS |
Refresh interval in ms. Default 300000 (5 min) |
QUOTA_DEBUG |
1 writes diagnostics to opencode-quota-debug.log in the system temp dir (no tokens) |
XDG_STATE_HOME |
Overrides where the console OAuth token file is stored |
Notes
- Refreshes every 5 minutes and ~1.5 s after each assistant turn; reset
countdowns (
2h45m,1d6h,23d23h) tick every 30 seconds. - The usage endpoint reports whole (floored) percentages while the console page rounds raw spend, so a bar can read up to 1% lower than the website.
- Failures degrade gracefully:
usage: error,quota: <reason>,credit login | no access | re-login | unreadable.
Uninstall
npx opencode-quota-sidebar uninstall
or
opencode plugin remove opencode-quota-sidebar
Then delete $XDG_STATE_HOME/opencode/quota-sidebar/
(~/.local/state/opencode/quota-sidebar/).
Security
The plugin ships no credentials and only talks to OpenCode's own endpoints
(opencode.ai, console.opencode.ai) and the connected server. See
SECURITY.md.
License
MIT
同类生态推荐
Tui Quota Usage
opencode-tui-quota-usage
OpenCode quota usage sidebar tracker for OpenCode V2 CLI/TUI
Providers Balances
opencode-providers-balances
OpenCode TUI plugin that shows provider account balances in the session sidebar. Providers are configured entirely in opencode.jsonc.
Sidebar Token Metrics
opencode-sidebar-token-metrics
OpenCode sidebar plugin showing generation speed (tok/s), cache hit rate, and average time-to-first-token (TTFT).