@kelearns/dsh-token-usage
Token Usage
dsh Web GUI 的令牌使用热力图。通过 DSH 的公共持久化服务读取会话历史记录,并通过官方插件机制挂载。
插件会安装到这里;不确定时保持 web。
npx -y @deepseek-ai/dsh plugin --profile web add @kelearns/dsh-token-usage@0.2.0


@kelearns/dsh-token-usage
dsh Web GUI 的令牌使用热力图。通过 DSH 的公共持久化服务读取会话历史记录,并通过官方插件机制挂载。
插件会安装到这里;不确定时保持 web。
npx -y @deepseek-ai/dsh plugin --profile web add @kelearns/dsh-token-usage@0.2.0




Token Usage 以 @kelearns/dsh-token-usage 发布,当前版本为 0.2.0。Plugin Hub 会校验它的 manifest,并保存精确安装来源,便于复现安装结果。
Token usage heatmap for the DeepSeek Harness (dsh) web GUI — a GitHub-style
contribution graph for daily / weekly / cumulative token consumption, with a
summary bubble, hover details, and activity insights. Mounted through the
official dsh plugin mechanism (dsh plugin add) — no dsh source changes.
Targets the DSH 0.2.0-rc.2 API surface.
A "Token Activity" entry appears in the settings sidebar.
Daily heatmap — dark theme, English (12-month window)
Daily token usage heatmap, dark theme, EnglishThree views — dark theme, English
| Daily | Weekly | Cumulative |
|---|---|---|
| Daily view | Weekly view | Cumulative view |
Light theme & Chinese UI
| Light (English) | 深色主题(简体中文) |
|---|---|
| Light theme, English | Dark theme, Chinese |
SessionPersistence service, not JSONL files;Requires pnpm on PATH:
npm install -g pnpm
From npm (recommended):
dsh plugin --profile web add @kelearns/dsh-token-usage
Listed in awesome-dsh-plugin curated registry; also searchable as
token-usagein the Plugin Market tab of dsh settings (dsh-market).
Local development install (run from this repository's root — link:.
resolves to the current directory):
dsh plugin --profile web add link:.
Remove:
dsh plugin --profile web remove @kelearns/dsh-token-usage
The installer reads
cordis.patch.yml(thedsh.bundle.patchmanifest field) and applies the plugin row automatically — no manual patch editing. Restart dsh web to activate.
$DSH_HOME/profiles/web/node_modules/@kelearns/dsh-token-usage;$DSH_HOME/profiles/web/cordis.patch.yml (idempotent):- insert:
- id: dsh-token-usage
name: '@kelearns/dsh-token-usage'
The plugin uses ctx.sessionPersistence.list() and read-only session handles.
DSH selects and migrates the current logical session format before exposing
events, so the plugin does not depend on filenames, compression, or the
configured persistence backend.
Successful model calls contribute assistant/message.data.usage; failed or
retried calls contribute the latest usage chunk in assistant/attempt.data.stream.
Compaction model calls contribute compaction/summary.data.usage when present;
released assistant/chunk usage events are also understood. Embedded stream
timestamps are used when available, with the settlement event time as fallback.
Total tokens are input + output + cache-read + cache-write tokens; DSH reports
these four counts as disjoint fields, while reasoning tokens are an output
subset. Insights also read request/header and tool/call; their averages use
days and months with reported usage.
Per-session folds are cached by DSH's opaque persistence revision. A scan re-reads only changed sessions. To bound work, it scans at most the 20,000 most recently created sessions and reports when older sessions were omitted.
The cumulative heatmap maps weekly totals within the selected 3 / 6 / 12-month window to one shared staircase: the first active week's exact cumulative value is the 1-cell baseline and the latest week's value is the 7-cell target, with each week's increase limited to one cell. The latest week can therefore remain below 7. Hover details still show the exact all-history cumulative token total through the hovered date.
| Method | Path | Description |
|---|---|---|
| GET | /dsh-token-usage/stats | Full statistics: { totals, stats, insights, today, days:[{d,i,o,c,w,a}], scan } |
| POST | /dsh-token-usage/refresh | Force cache invalidation and rescan |
| GET | /dsh-token-usage/status | Cache / last scan state |
- insert:
- id: dsh-token-usage
name: '@kelearns/dsh-token-usage'
config:
refreshIntervalMinutes: 5 # background rescan interval (default 5)
node test/mock.test.mjs # synthetic full pipeline
node test/layout-algo.mjs # layout algorithm matrix
scan.errors;SessionPersistence.list() is unpaginated; this plugin caps each scan at the 20,000 most recently created sessions and shows a warning when it does;sessionPersistence service to be mounted in the Web profile.MIT