0
409
近 7 天 8
36.0
生态多维模型
6 天前
2026-09-28
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@davidaayers/opencode-codex-usage-plugin@0.1.2"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@davidaayers/opencode-codex-usage-plugin@0.1.2"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @davidaayers/opencode-codex-usage-pluginOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
An OpenCode TUI sidebar plugin that shows Codex 5-hour and weekly quota usage as compact gauges with reset countdowns.
Codex Usage
5h ███░░░░ week █████▋░
42% · 2h 81% · 7d
This is a maintained fork of zaniluca/opencode-codex-usage-plugin. It keeps the original Codex App/CLI integration and presents the usage data in the gauge style used by the other David Ayers OpenCode plugins.
Features
- Quota gauges — compact eighth-block gauges for the available 5-hour and weekly Codex limits
- Proximity colors — gauge and percentage use the active theme:
success<50% →accent50–74% →warning75–89% →error≥90% - Reset countdowns — short reset times appear beneath each available window
- Compact prompt line — identifies the most constrained window when the sidebar is hidden
- Codex App/CLI support — reads usage through the Codex app-server protocol, sharing a WebSocket-over-Unix server across OpenCode instances
- Live updates — refreshes every 60 seconds and on message/session events
- Silent by design — hidden for non-Codex sessions
Install
opencode plugin --global @davidaayers/opencode-codex-usage-plugin
Or from inside OpenCode: press ctrl+p → "Install Plugin" → @davidaayers/opencode-codex-usage-plugin. Restart OpenCode and the gauges appear once the session uses an OpenAI/Codex model.
From source
OpenCode TUI plugins load from the plugin array in ~/.config/opencode/tui.json (or a project-level tui.json) — not from opencode.jsonc, whose plugin array is server-side only.
// ~/.config/opencode/tui.json
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["file:///absolute/path/to/opencode-codex-usage-plugin/dist/tui.js"],
}
Requirements
Install either Codex App or the Codex CLI. The plugin looks for Codex in common locations and on your PATH.
If your Codex command lives somewhere else, set OPENCODE_CODEX_USAGE_COMMAND:
export OPENCODE_CODEX_USAGE_COMMAND="/path/to/codex"
How It Works
- Usage source: the Codex app-server provides normalized 5-hour and weekly rate-limit windows.
- Rendering: the plugin uses OpenTUI and the active OpenCode theme, with the gauge renderer kept separate from the Codex transport.
- Lifecycle: the Effect-based service reuses or starts a shared Codex app-server over a Unix socket, connects with WebSocket, and falls back to a dedicated stdio server when the shared path is unavailable. It owns request timeouts and connection cleanup.
Development
pnpm install
pnpm check
pnpm test
pnpm build
The published plugin entrypoint is dist/tui.js, generated from src/tui.ts.
Roadmap
Cross-repository follow-up work is tracked in the OpenCode Plugins project.
Changelog
See CHANGELOG.md for release history.
Credits
The Codex integration is forked from zaniluca/opencode-codex-usage-plugin. The gauge presentation is inspired by @davidaayers/opencode-go-usage-plugin and @davidaayers/opencode-context-gauge-plugin.
License
MIT. See the upstream project for the original implementation and attribution.
同类生态推荐
Tui Quota Usage
opencode-tui-quota-usage
OpenCode quota usage sidebar tracker for OpenCode V2 CLI/TUI
Codex Usage
opencode-codex-usage-plugin
OpenCode TUI plugin that shows Codex usage and reset times.
Loopd
@bojackduy/opencode-loopd
Codex-inspired background goal engine for OpenCode — autonomous subagents, engine-driven loop, child worker sessions and modal TUI dashboard. Like Claude Code loop for OpenCode.