caiyfa/dsh-token-stats

deepseek-harness (dsh) 全局 Token 用量看板插件 —— 一行命令安装,后台常驻增量统计全部会话:按模型/按时间/按会话的用量趋势(分钟·小时·天 × 柱状/堆叠/累计)、红绿异常时点标记与按会话异常分组,子代理消耗自动归并主会话。Global token-usage dashboard for deepseek-harness (dsh) — one-line install, background incremental scan, per-model/session/anomaly analytics. dsh plugin.

项目介绍Project Overview

dsh-token-stats 是 deepseek-harness 的全局 token 用量仪表盘插件,覆盖跨会话、按模型与时间段的消耗统计及异常追踪。适用于需要总览多会话用量或排查失败会话时。注意:安装依赖 Node ≥ 22,且升级 dsh 后需重跑安装器修复链接。

dsh-token-stats is a global token-usage dashboard plugin for deepseek-harness, tracking consumption across sessions by model, time bucket, and session, with anomaly detection. Use it when you need a cross-session overview or to identify failed turns. Note: requires Node ≥ 22; re-run the installer after upgrading dsh to repair links.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add github:caiyfa/dsh-token-stats

caiyfa/dsh-token-stats 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-token-stats

English | 中文

The missing global token-usage dashboard for deepseek-harness (dsh) — one-line install, then open Settings to see per-model, per-time-bucket, and per-session consumption with anomaly tracking.

install dsh platform license

Why

dsh's built-in stats cover only the current session. Total consumption across sessions, per-model breakdowns, which day was heaviest, which sessions failed — none of that exists in the stock UI. This plugin adds all of it, and gets two easy-to-get-wrong things right:

  • Correct attribution: subagent tokens and anomalies roll up along the parentSession chain to their root main session — counts speak in main sessions only, while every subagent token lands on its owner
  • Zero wait: a resident background aggregate (warm-up at start → 60s incremental sweeps → 10min full rescans) means the Settings page always reads hot data

Install

npx github:caiyfa/dsh-token-stats

Restart dsh, open Settings → Token 用量. Done.

  • Requires: dsh (web profile), Node ≥ 22
  • Several profiles: --profile=tui,web; every profile: --profile=all
  • Uninstall: npx github:caiyfa/dsh-token-stats --uninstall
  • After upgrading dsh, re-run the installer once if the plugin fails to load — it repairs the links

What you get

Section Contents
Summary card Uncached input / cache read / cache write / output / reasoning / total / model calls
Per-model table Main-session count, calls, the four token buckets, and totals for each provider / model
Token trend Granularity (minute·24h / hour·7d / day·all, auto-weekly beyond 90 days) × mode (bars / 4-color stacked composition — watch your cache-hit structure evolve / cumulative curve — the budget-burn view); dashed Y contour lines with a peak label, hover for per-bucket detail
Anomaly marks A green/red dot above every time bucket (red = failed turns inside it); click a red dot to focus the main sessions involved
Per-session anomaly groups Collapsible per-main-session list (time + error message), collapsed by default so volume never floods the page

How it works (30-second version)

The host half is a resident background service: it scans every session log, folds each assistant/message's provider-reported usage (bucketed by provider/model) and each turn/end error into minute/hour/day timelines. The client half registers the Settings dashboard above and reads snapshots through dsh's /api gateway. Pure in-memory aggregation — nothing written to disk or session logs, nothing injected into model prompts.

The installer does three things: deploys the package into ~/.dsh; links (junction/symlink, never copies — Remote markers ride a module-scoped WeakMap, so the plugin must share the same physical module instance with dsh) @deepseek-ai/cordis and @deepseek-ai/dsh-typert-protocol from your live dsh install; and appends a marker-delimited idempotent block to the profile's cordis.patch.yml.

Troubleshooting

Symptom Fix
Failed to load plugins ... dsh-token-stats Re-run the installer; if it still fails, DSH_MODULES_DIR=<dsh node_modules> npx github:caiyfa/dsh-token-stats
Section renders but stays empty Check the dsh process log for token-stats: errors
invocation-unavailable: tokenStats/snapshot A peer got copied as a real directory: delete it and re-run the installer

License

MIT

上一个 Prev dsh-human-task 下一个 Next dsh-conversation-minimap