Skip to main content
D

dsh-token-workbench

dragonestdwolf/dsh-token-workbench

Token usage workbench for token-plan users: folds assistant/message usage from the session log into per-day call-level detail (cross-session responseId dedupe keeps fork/resume copies counted once), converts local volume into plan credits against terms you enter (default 1M tokens = 0.2 credits, caps 600/2500/6000 for day/week/month, optionally scoped to selected channels), and shows a composer-dock readout plus a settings page with per-provider cost table, 7/30d bar and line trends and a rolling six-month heatmap. No credentials are read: the remaining percentage a provider keeps behind its control-plane API is replaced by a clearly labelled local conversion, and reference costs come from the public DeepSeek pricing page.

Install

dsh plugin --profile web add github:dragonestdwolf/dsh-token-workbench

README

dsh-token-workbench

Token usage workbench for DeepSeek Harness (dsh). It reads the model-usage records already present in the session log, keeps a per-day detail store, turns them into tokens / cost / call numbers, and shows them in two places inside the app:

  • Composer dock readout — today's tokens, reference cost and today's plan credits right above the composer, at a glance.
  • Settings page → 「Token 工作台」 — overview card, plan-quota block (day / week / month credits with an inline「口径」editor), per-provider table, 7-day / 30-day trend charts and a rolling six-month heatmap, with paging for the granularity you picked and for the heatmap window.

The plan-quota block converts local token volume into plan credits with the terms you enter (default: 1M tokens = 0.2 credits, caps 600 / 2500 / 6000, all four usage buckets scored). Windows are Beijing natural day / week (Monday 00:00) / month. It is a local estimate — the provider console is the only authority — and it reuses the same fork-deduped call log as the other blocks, so it can only be as complete as what this machine captured.

The「口径」editor also carries a channel filter (统计通道): the block scores either every channel (the default, providers: []) or only the ones you tick — the plan is usually bought on one gateway, so counting a second gateway's local traffic would inflate the percentage. The block title always states the current scope (「全部通道」/「仅 volcano-gateway」), and the dock's credit segment follows the same filter.

Cost is a reference figure: tokens are multiplied by the official DeepSeek price list (peak / off-peak tiers, Beijing time 00:30–08:30 is off-peak). The price list is fetched from the DeepSeek pricing page and cached; when it cannot be fetched, a frozen default list is used and the UI says so.

Install

# from the published package
dsh plugin --profile web add dsh-token-workbench

# or straight from the release tarball
dsh plugin --profile web add https://github.com/dragonestdwolf/dsh-token-workbench/releases/download/v0.1.0/dsh-token-workbench-0.1.0.tgz

dsh plugin is the supported path: it records the package in the profile and applies the dsh.bundle.patch entry (cordis.patch.yml) that inserts the plugin into that profile's layer stack. A bare npm install does not mount anything. It needs a dsh ^0.2.1-rc.0 host with the web (client) platform enabled, then a restart of the app.

Privacy

  • Everything is computed locally from the session logs dsh already writes to your DSH home; the plugin does not upload usage data anywhere.
  • The only outbound request is the pricing page fetch (DeepSeek official pricing), and only to read numbers; if it fails the frozen default applies.
  • No credentials, cookies or API keys are read or stored.

Development

The repository ships a set of local checks. None of them are part of the published package.

npm run check      # syntax-check the three entry points
npm run fixtures   # regenerate the synthetic session-log fixtures
npm run smoke      # Host-half assertions against the synthetic fixtures
npm run probe      # browser harness: client bundle + settings jump
npm run pack:dry   # npm pack --dry-run (what would be published)

node scripts/plan-selfcheck.mjs   # read-only: plan credits from the real store
node scripts/check-alignment.mjs --page client   # layout baseline of the real bundle

scripts/make-fixtures.mjs writes fixtures/:

The fixtures are synthetic. They are generated session logs with invented provider and model names, invented token usage and invented prompt/tool text (synthetic fixture ...). They exist only so the smoke suite can fold real event shapes without shipping anyone's conversation content, and they are excluded from the published package. The generator is deterministic: running it twice produces byte-identical files.

The browser probes (scripts/probe-*.mjs) drive headless Chrome/Chromium ($DSH_CHROME overrides the binary) and load the harness pages from scripts/; those pages resolve React UMD from ?nodeModules= or a checkout-local node_modules ($DSH_NODE_MODULES overrides the lookup). React is a dev-only tool for the harness, never a package dependency.

License

MIT — see LICENSE.

Related plugins