dsh-plugin-token-usage
开发工具 活跃维护

dsh-plugin-token-usage

Hjay1101/dsh-plugin-token-usage

支持日/周/月粒度的Token用量热力统计,可按不同模型拆分展示数据,悬停当日条目有专属标识,只读设计且完全本地运行,无需额外配置即可快速查看使用情况。

1
Stars 标星
0
Forks 分支
1
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
4.2 MB
仓库大小
3 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:Hjay1101/dsh-plugin-token-usage
git clone https://github.com/Hjay1101/dsh-plugin-token-usage.git
git clone git@github.com:Hjay1101/dsh-plugin-token-usage.git
README.md main

dsh-plugin-token-usage

A DeepSeek Harness plugin that read-only scans your local session logs and renders a
GitHub-style token usage heat map with a granularity-linked per-model breakdown —
plus an instant "tokens today" badge on hover. Everything stays on your machine.

demo

中文说明

Features

  • 🔥 GitHub-style heat map: one cell per day for the last 30 days (zero-usage days
    filled), Sunday-first columns, month labels, today outlined; 5-level accent scale
    normalized per view.
  • 🗓 Day / Week / Month switcher: weeks start on Sunday, aligned with grid columns;
    the color scale renormalizes per granularity.
  • 🫧 First-party tooltips: 08-22 · 420M token · 341 requests · 95.9% cache hit,
    left-edge aligned to each cell, shown instantly (delayMs=0), viewport-aware flip.
  • 🧩 Granularity-linked model table: exact in-window aggregation via session×day and
    model×day secondary maps (no approximations), with window totals row and empty state.
  • ⚡ Sidebar hover badge: 1.25亿token today, silent 30s polling, rolls over at
    midnight automatically.
  • 🚿 Zero-usage filtering: models that only produced requests but no real tokens are
    excluded from the breakdown and from request totals.
  • 🌗 Theme-native: every color maps to DSH theme variables (--dsw-alias-*);
    light/dark just work.
  • 🛠 usage_report model tool: ask your agent "how many tokens did I use today?"
    without opening the panel.

Install

Option A (recommended): one command, self-mounting

dsh plugin --profile web add dsh-plugin-token-usage

The package ships its own cordis.patch.yml bundle patch, so the host half (HTTP API +
model tool) activates automatically.

Option B: manual mount

  1. Put this directory into ~/.dsh/profiles/web/node_modules/
    (or pnpm add file: it);

  2. Append to ~/.dsh/profiles/web/cordis.patch.yml:

    - insert:
       - id: token-usage
         name: 'dsh-plugin-token-usage'
         config:
           ttlMs: 15000
  3. Restart DeepSeek Harness.

⚠️ Pick one. If the bundle patch already mounts it, do NOT manually insert the same id —
that would double-load the plugin.

Upgrading from the manual install? If you previously added the insert block above
to your profile, delete it before restarting — with the self-mounting bundle patch
present, the same id would be registered twice and startup crashes with
duplicate loader entry id: token-usage.

Configuration

Key Default Description
ttlMs 15000 Scan result cache duration (ms)
scanTimeoutMs 180000 Per-log decompression timeout (ms)

Usage

  • Web GUI: click the bar-chart icon on the sidebar settings row → usage modal;
    Esc or click the backdrop to close.
  • Chat tool: ask your agent to call usage_report (refresh forces a rescan,
    top caps model rows — default 10, max 50).

Privacy

Read-only parsing of local logs under ~/.dsh/sessions/** (streamed zstd decompression,
8-way concurrency). No network requests, no telemetry, no writes.

License

MIT