caiyfa/dsh-token-stats ↗★ 1

dsh-token-stats

Global per-model token usage statistics for deepseek-harness (dsh web): background incremental scan over all session logs, Settings UI with multi-granularity trend charts and per-session anomaly groups. 核心用途是提供全局的 Token 消耗统计与趋势分析。适合需要监控整体 API 消耗、排查异常高消耗会话的用户。

패키지
dsh-token-stats
호환성
미검증
버전
1.2.0
라이선스
MIT
최근 업데이트
2026. 8. 15.

같은 패키지 이름의 다른 저장소

설치

검증된 bundle이 없거나 호환성 검사에 실패했습니다. 먼저 저장소 설명을 읽어 주세요. 전체 README 읽기 ↗

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

SectionContents
Summary cardUncached input / cache read / cache write / output / reasoning / total / model calls
Per-model tableMain-session count, calls, the four token buckets, and totals for each provider / model
Token trendGranularity (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 marksA 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 groupsCollapsible 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

SymptomFix
Failed to load plugins ... dsh-token-statsRe-run the installer; if it still fails, DSH_MODULES_DIR= npx github:caiyfa/dsh-token-stats
Section renders but stays emptyCheck the dsh process log for token-stats: errors
invocation-unavailable: tokenStats/snapshotA peer got copied as a real directory: delete it and re-run the installer

License

MIT