0
105
近 7 天 21
30.3
生态多维模型
1 个月前
2026-07-05
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@a-r-m-i-n/opencode-openai-usage@0.1.5"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@a-r-m-i-n/opencode-openai-usage@0.1.5"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @a-r-m-i-n/opencode-openai-usageopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin that reads your ChatGPT account usage and shows it in the TUI sidebar and command palette.
The sidebar panel starts expanded and can be collapsed.

What It Does
- fetches usage data from OpenAI Backend API
- reads the OpenCode OpenAI OAuth token from OpenCode's local state
- shows usage windows in the collapsible sidebar
- adds
OpenAI Usage,OpenAI Usage: Toggle Sidebar Display, andOpenAI Usage: Show/Hide Sidebar Sectioncommands to the TUI command list
Screenshots
Command Palette
Shows the OpenAI-specific commands added by the plugin.
OpenAI Usage: opens the detailed usage dialogOpenAI Usage: Toggle Sidebar Display: switches the sidebar between used quota and remaining quotaOpenAI Usage: Show Sidebar Section/OpenAI Usage: Hide Sidebar Section: toggles the sidebar section and persists the setting across restarts

Usage Dialog
Shows the detailed usage summary, including the current usage windows and account details returned by the upstream endpoint.

Sidebar Display Modes
The sidebar can show either used quota or remaining quota.
Used mode:

Left mode:

Requirements
- OpenCode with an OpenAI account connected via OAuth
- Node.js and npm available for installation/build steps
Install From npm
npm install @a-r-m-i-n/opencode-openai-usage
Add the runtime plugin in opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@a-r-m-i-n/opencode-openai-usage"]
}
Add the TUI plugin in tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [["@a-r-m-i-n/opencode-openai-usage/tui", { "invert": false }]]
}
After changing config, quit and restart OpenCode.
TUI Options
The TUI plugin accepts options in tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [["@a-r-m-i-n/opencode-openai-usage/tui", { "invert": true }]]
}
| Option | Default | Description |
|---|---|---|
invert |
false |
Default sidebar mode. false shows used quota like 60% used; true shows remaining quota like 40% left. After the OpenAI Usage: Toggle Sidebar Display command is used, the last selected mode is persisted across restarts. |
Project Structure
src/
index.ts
tui.tsx
lib/openai-usage.ts
.opencode/
plugins/openai-usage.ts
tui/openai-usage.tsx
tui.json
Notes And Limitations
- The plugin depends on OpenCode's locally stored
auth.jsonformat. - The usage endpoint is an internal ChatGPT web endpoint and may change without notice.
- The plugin caches usage data locally in OpenCode's state directory.
- The plugin hides its sidebar panel when OpenCode has no OpenAI OAuth account configured.
- Usage-specific commands are hidden when OpenCode has no OpenAI OAuth account configured, but the sidebar visibility toggle remains available.
- The command summary currently includes the account email returned by the upstream endpoint.
License
MIT