0
505
近 7 天 11
36.1
生态多维模型
16 天前
2026-09-18
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zai-quota@1.0.2"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zai-quota@1.0.2"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-zai-quotaOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode TUI plugin that shows your Z.AI coding plan quota (zai-coding-plan) directly in the sidebar: a gauge for the short usage window and one for the plan-level allowance, with live colors as you approach the limits.
Features
- Panel in the session sidebar with one gauge per quota limit:
- Bar (26 cells) filled according to consumption percentage.
- Dynamic colors: green < 70%, yellow 70-89%, red >= 90%.
- Reset countdown per limit (from
nextResetTime). - Usage / allowance numbers, plan level, and last-refresh time in the header.
- Compact
zai:N%chip next to the session prompt input. - Refreshes every minute, on
session.idle, and on demand via the/zai-quotacommand (also in the command palette,ctrl+p). - Colors read from the active OpenCode theme (
api.theme.current.*) — no hardcoded hex values.
Install
OpenCode TUI plugins are not auto-discovered: installing the package only
downloads it — the plugin must also be registered in tui.json. Two ways:
Option 1 — Plugin manager inside OpenCode (recommended)
npm install -g opencode-zai-quota- Open OpenCode, press
ctrl+pand run plugin install (or open the plugin manager and addopencode-zai-quota). - The plugin manager writes the entry to
tui.jsonfor you. Restart OpenCode.
Option 2 — Manual registration
npm install -g opencode-zai-quota- Add the plugin to
~/.config/opencode/tui.json(a project-level.opencode/tui.jsonalso works):
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-zai-quota"]
}
- Restart OpenCode. The
Z.AI PLANpanel appears in the session sidebar and thezai:N%chip next to the prompt input.
Editing
tui.jsonrequires a restart: config is not hot-reloaded. Unknown top-level keys intui.jsonare rejected and will crash startup — keep the shape shown above.
Authentication
The token is read automatically from OpenCode's own credentials
(~/.local/share/opencode/auth.json): the zai-coding-plan entry first, then
zai. If you can chat with a zai-coding-plan model in OpenCode, the widget
works with zero configuration.
Environment fallbacks: ZAI_TOKEN / Z_AI_TOKEN.
Data source
GET https://api.z.ai/api/monitor/usage/quota/limit
Authorization: Bearer <token>
Commands
| Slash command | Palette title | Description |
|---|---|---|
/zai-quota (/zq) |
Z.AI quota: refresh now | Force a refresh and show a toast with the result |
Note
This is a community plugin, not affiliated with Z.AI or OpenCode.
Freeze guard (v1.0.2)
When the Z.AI provider kills a stream with Weekly/Monthly Limit Exhausted, the
turn used to hang in the TUI (looking frozen). The plugin now listens for the
session.error event, shows an error toast with the reset time, refreshes the
gauges, and aborts the stuck turn automatically so the UI unfreezes
immediately. Switch model with /models to keep working until the reset.
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.
Usage Monitor
opencode-usage-monitor
OpenCode TUI sidebar plugin that displays API usage quotas for OpenAI and Z.AI (GLM) providers