跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    davidaayers

    Codex Usage

    @davidaayers/opencode-codex-usage-plugin·v0.1.2·界面与主题

    OpenCode TUI plugin that shows Codex quota usage gauges and reset times.

    GitHub 星标

    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"]
    }

    OpenCode 启动时会通过内嵌运行时自动加载 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% → accent 50–74% → warning 75–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.

    同类生态推荐