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

    Token Usage Chart

    v0.2.9可观测与分析
    @thiagos1lva/opencode-token-usage-chart

    OpenCode TUI plugin for token usage charts

    GitHub 星标

    0

    月装机量

    57

    近 7 天 10

    综合评分SCORE

    23.8

    生态多维模型

    最近提交

    4 个月前

    2026-04-08

    快速安装与配置

    opencode.json

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

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@thiagos1lva/opencode-token-usage-chart@0.2.9"]
    }

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

    An OpenCode TUI plugin that adds a token usage chart view for your sessions.

    Installation

    npm install -g @thiagos1lva/opencode-token-usage-chart
    # or
    bun add -g @thiagos1lva/opencode-token-usage-chart
    

    Usage

    Add the plugin to your tui.json:

    {
      "$schema": "https://opencode.ai/tui.json",
      "plugin": ["@thiagos1lva/opencode-token-usage-chart"]
    }
    

    For global usage, put this in ~/.config/opencode/tui.json.

    For per-project usage, put this in <repo>/tui.json.

    That's it. OpenCode will load the plugin at startup.

    Then open the chart with:

    • Slash command: /token-chart
    • Command palette value: token.usage.chart

    How It Works

    • Registers a TUI route named token-usage and a command /token-chart.
    • Aggregates usage from assistant messages into chart buckets (15min, 30min, hour, day, week, month).
    • Supports dynamic scopes: all, optional workspace, and optional session.
    • Total tokens are calculated as input + output + reasoning + cache.read + cache.write.
    • Includes refresh and diagnostics helpers directly in the chart view.

    Requirements

    • OpenCode with TUI plugin support

    License

    MIT