跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    QianYuan1437

    Usage Stats

    v0.3.2可观测与分析
    opencode-usage-stats

    An OpenCode plugin that surfaces local usage statistics and reserves a cloud usage API integration.

    GitHub 星标

    0

    月装机量

    737

    近 7 天 13

    综合评分SCORE

    37.0

    生态多维模型

    最近提交

    18 天前

    2026-08-01

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-usage-stats@0.3.2"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    An OpenCode plugin that surfaces local usage statistics (sessions, messages, tokens, cost, model/tool breakdown) and reserves a hook for cloud plan/remaining-quota information once OpenCode exposes a public API for it.

    Install

    Add the plugin to your OpenCode config (opencode.json or ~/.config/opencode/opencode.json):

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-usage-stats"]
    }
    

    OpenCode will install the npm package automatically on startup.

    Use

    The plugin provides both a TUI sidebar panel and a slash command.

    TUI sidebar

    When OpenCode starts, a small Usage panel appears in the right sidebar showing the current session's live stats:

    • Messages
    • Cost
    • Tokens
    • Top model

    It updates automatically as new assistant messages arrive.

    Slash command

    Run the slash command in any session:

    /usage
    

    Or ask the agent:

    Show my OpenCode usage
    

    This returns a markdown summary of all sessions, messages, tokens, cost, model/tool breakdown.

    Configuration

    {
      "plugin": ["opencode-usage-stats"],
      "opencode-usage-stats": {
        "enableCloudApi": false,
        "cloudApiUrl": "https://console.opencode.ai/api/usage",
        "apiKey": ""
      }
    }
    
    • enableCloudApi: When true, the plugin attempts to fetch cloud plan/usage data. Currently this is a placeholder because OpenCode does not expose a public usage API.
    • cloudApiUrl: Reserved URL for the future cloud usage endpoint.
    • apiKey: Reserved API key for the future cloud usage endpoint.

    Data sources

    • C-1 (enabled by default): Aggregates local usage by reading the running OpenCode session list via the OpenCode SDK (client.session.list() / client.session.messages()).
    • C-2 (placeholder): Will call the configured cloud usage API when OpenCode releases a public endpoint. Until then, it is disabled and the plugin reports the limitation.

    Repository

    https://github.com/QianYuan1437/OpenUsage

    License

    MIT