dsh-usage-vendor-stats

usageinstall failsnpmMIT

Vendor-based usage dashboard: per-provider token/cache/output KPI, a 53-week heatmap, trend chart with hourly "today" view, model drilldown, cost estimation, CSV export, and health cards (TTFT, generation speed, peak context, error rate).

下载量 / Downloads
1,041
测试时间 / Tested
2026-11-06
DSH 版本 / Version
0.2.2-rc.1

Install

dsh plugin --profile web add dsh-usage-vendor-stats

Sandbox test results

StageResult
1 install✗
2 list—
3 mount—
4 boot—
First error
dsh: initialized profile web at /home/node/.dsh/profiles/web

Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).

README

dsh-usage-vendor-stats

[English](#english) · [中文](#中文)


English

DeepSeek Harness usage statistics plugin: aggregates API usage by vendor (subscription / official API) × KPI, with a GitHub-style calendar heatmap and daily / monthly dashboards.

Distinct from dsh-usage-stats (which aggregates by workspace): this plugin uses the vendor (provider) as the primary dimension, auto-detecting message.source.provider and message.source.model from assistant/message events, and splits KPIs into tokens / cache hits / output / reasoning.

Features

  • Vendor dimension: auto-discovers every vendor used (e.g. huoshan, hebox, deepseek-official, tokenrhythm, opencode), with manual labels for subscription / official API and aliases (persisted to a KV unit under $DSH_HOME/storages).
  • KPI cards: total tokens (input / cache hit / output / reasoning breakdown), cache hit rate, model calls, turns, sessions, vendor count, with a multi-color token composition ratio bar.
  • 53-week heatmap: GitHub-green style, intensity by daily model calls; click a vendor chip to filter; hover for per-vendor and per-token details.
  • Trend line chart: Token / Calls dual-axis trend, per-day by default and per-hour for "today" (hourly aggregation).
  • Vendor model drilldown: click a vendor row to expand its per-model consumption.
  • Daily detail: per-day tokens / cache / output / reasoning / hit rate / turns (last 30 days).
  • Monthly summary: all history aggregated by month.
  • Vendor KPI table: sorted by total tokens, with hit rate, model count, type badge; click a row to drill into models.
  • Time presets: today / 7d / 14d / 30d / 90d / all.
  • Cost estimation: set a per-million-token unit price per vendor to see an estimated fee column.
  • CSV export: export daily / monthly / vendor tables to CSV.
  • Health / performance cards: average TTFT (time to first token), generation speed (t/s), peak context size, request error rate, and total model / tool wall time, aggregated from DSH's sessionStats projection.
  • Range switching, animations, light/dark theme adaptation.

Screenshots

Data source

  • All data comes from DSH durable session logs: assistant/message events carry usage (token accounting) and message.source.{provider,model} (vendor/model provenance).
  • Token accounting (consistent with DSH): inputTokens = uncached input, cacheReadTokens = cached input, outputTokens = output, reasoningTokens = reasoning, cacheWriteTokens = cache write.
  • Cache hit rate = hits / (hits + uncached input) × 100%.
  • History is backfilled automatically on activation; data survives plugin uninstall / restart.

Install

This is a standard DSH community plugin package (declares dsh.bundle manifest + web client half).

From GitHub (recommended)
dsh plugin --profile web add "github:kirigayakazima/dsh-usage-vendor-stats"

Refresh the page after install — no manual config, no restart.

Manual registration (local development)

1. Place this directory anywhere and create a symlink pointing to it under $DSH_HOME/profiles/node_modules/ (use a junction on Windows):

   New-Item -ItemType Junction -Path "$env:DSH_HOME\profiles\node_modules\dsh-usage-vendor-stats" -Target "<absolute path to this dir>"

2. Add a line to $DSH_HOME/profiles/web/cordis.patch.yml:

   - insert:
       - id: usage-vendor-stats
         name: dsh-usage-vendor-stats

The user patch layer hot-reloads: save and refresh the page.

Usage

1. Open Settings (sidebar footer) and find the API Usage Stats page, or click the 📊 Usage Stats entry in the sidebar footer to open the fullscreen panel.

2. Heatmap color = daily call count; click a vendor chip or table row to filter / drill down.

3. In Vendor Management, set each vendor's alias and type (subscription / official API), and optionally a per-million-token unit price for cost estimation.

Architecture

  • Host half (lib/index.js): scans durable session logs and aggregates usage (assistant/message.usage + message.source), listens to session/event for live folding; serves data routes via the webServer service:
  • GET /api/usage-vendor-stats — stats snapshot (vendors / models / daily / monthly / hourly / totals)
  • POST /api/usage-vendor-stats/vendor — set vendor alias, type, and unit price
  • Client half (lib/client.js): window.__ModuleLoader__ factory-format browser bundle, registering the API Usage Stats settings page (settings.section slot), a sidebar footer entry (sidebar.footer.action), and a fullscreen panel (shell.overlay).

Development

  • Editing lib/index.js / lib/client.js takes effect after a page refresh (client bundle loads with the page); host-half changes require a DSH restart.
  • The plugin has no third-party runtime dependencies: the host half uses only Cordis services, the client half only React (provided by the module table).

License

MIT


中文

DeepSeek Harness 用量统计插件:按厂商(订阅 / 官方 API)× KPI 聚合 API 使用量,带 GitHub 风格日历热力图、趋势折线图与日 / 月 / 小时统计看板。

区别于 dsh-usage-stats(按工作区统计):本插件以厂商(provider)为第一维度,自动识别 assistant/message 事件里的 message.source.provider 与 message.source.model,拆分 token / 缓存命中 / 输出 / 推理等 KPI。

功能

  • 厂商维度:自动发现所有使用过的厂商(如 huoshan、hebox、deepseek-official、tokenrhythm、opencode),可手动标记为「订阅 / 官方API」,设置别名(持久化到 $DSH_HOME/storages 的 KV 单元)
  • KPI 卡片:总花费 Token(输入 / 缓存命中 / 输出 / 推理分项)、缓存命中率、模型调用次数、回合数、会话数、厂商数量,附多色 Token 构成比例条
  • 53 周热力图:GitHub 绿色风格,颜色深浅按当日模型调用次数;点击厂商筛选后仅统计该厂商;悬停查看按厂商明细与 Token 明细
  • 趋势折线图:Token / 调用双轴趋势,默认按日;选「今天」时按小时展示(小时级聚合)
  • 厂商模型钻取:点击厂商行展开该厂商的逐模型消耗
  • 每日明细:近 30 天逐日 Token / 缓存 / 输出 / 推理 / 命中率 / 回合
  • 每月汇总:全

…(truncated)

Rendered from the README published on npm. Formatted only, not edited.

Versions

Published on npm::2,最后更新 2026-10-02

Links

GitHub · Homepage · npm

Same category