Back to home@Triple3h

dsh-usage-stats

DSH Web plugin: usage statistics — daily/model tokens, sessions, messages, activity heatmap in a zcode-style panel. DSH Web 插件:侧边栏使用统计面板(按天/按模型 tokens、会话、消息、活跃热力图)。

Stars
0
Language
JavaScript
Created
Aug 19, 2026
Updated
Aug 23, 2026
GitHub repo

Introduction

dsh-usage-stats

English | 中文

GitHub stars GitHub license

A DeepSeek Harness (dsh) Web plugin that adds a Usage stats button above the sidebar settings row, opening a full-page, zcode-style usage dashboard.

Track how you use the harness: tokens by day and by model, sessions, messages, active days, and an activity heatmap — all read from your own session logs, no third-party telemetry.

What you get

  • Time-range switch — last 7 days / last 30 days
  • Six metric cards — token usage, session count, message count, active days, current streak, most-used model (with share)
  • Activity heatmap — 30 full weeks, bucketed into 5 levels by non-zero quantiles
  • Daily token trend — per-model stacked bars (top 6 models + other) with legend
  • Model usage — donut chart + breakdown list (share, tokens)
  • Refresh button (bottom-right); close via Esc or the × (top-right)

Numbers are formatted the zcode way: 10.1亿 / 6178.2万.

How it works

HalfFileRole
hostlib/index.jsHooks the sessionPersistence seam, scans session logs and folds them into daily/per-model summaries (in-memory index: full scan at boot + incremental every 60s); read-only loopback endpoint GET /api/usage-stats/usage?days=N
clientsrc/client.jslib/client.jsRegisters a button in the sidebar.footer.action slot; react-dom portal full-page panel; hand-written SVG/DOM charts, no third-party deps

Event-parsing semantics match TokenLedger (both usage chunks and assistant/message are received, same-(turn,step) samples replace each other, message counts ride on events), but no relay attribution — aggregation is per-model only.

Install (link, development)

npm install
npm run build        # esbuild syntax-check src/client.js → lib/client.js
npm run link-profile # wire into ~/.dsh/profiles/web, then restart dsh web

link-profile does: add a link: dependency to the profile's dependencies, append to dsh.profile.bundles, and run pnpm install in the profile. Then restart dsh web (by convention, no auto-restart).

Verify

After restarting dsh web: a Usage stats row appears above Settings; DevTools console shows [usage-stats] bundle script executing / factory materializing. If the panel 404s or errors, check the host log for usage-stats: serving /api/usage-stats/usage.

Development

npm install
npm run build
npm test             # node test/smoke.mjs — core contract smoke tests for both halves
npm run link-profile

License

MIT