DeepSeek Harness Plugin

jkStars/dsh-token-usage-stats

Stars ★ 1 Downloads (30d) 481 Category Usage & Billing Added 2026-09-02 npm dsh-token-usage-stats

DeepSeek-styled cross-session token usage, request count, and tiered cost analytics dashboard.

Install

# from npm (prebuilt)

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

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:jkStars/dsh-token-usage-stats

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

English | 简体中文

DSH web plugin: cross-session token usage, request count, and optional cost analytics (ctx.tokenUsageStats), with a self-contained dashboard page at /token-usage-stats (JSON feed at /api/token-usage-stats) and a sidebar footer entry opening the dashboard in an in-page modal.

Screenshots

Sidebar footer entry — click 「用量统计」 to open the dashboard

Usage entry

Dashboard — today view (cost stack, token trend, breakdown, per-model and top-session tables)

Dashboard - today

Breakdown tooltip (hover a bar for per-category details)

Dashboard - cost tooltip

All-range daily view

Dashboard - all ranges

Note: Only DeepSeek official API costs are currently counted (token usage, request counts, and cost are replayed from local Harness session logs); it does not include API costs from other providers or channels.

Install

dsh plugin --profile web add dsh-token-usage-stats@0.3.7

The package's cordis.patch.yml inserts the plugin row; the browser half loads from the dsh.client manifest. Restart the host (or reload the GUI) after installing.

To update to a newer release:

dsh plugin --profile web add dsh-token-usage-stats@latest

Usage

Open the dashboard from the sidebar footer entry, or browse directly to http://<host>:<port>/token-usage-stats. The page defaults to today's hourly view and offers today / 3-day / 7-day / all ranges, where the 7-day and all ranges show the daily view. It auto-refreshes every 10 seconds. Cost figures appear only when model pricing is configured.

Config

The inserted row accepts config.currency (report cost in this currency) and config.pricing (per-model per-million-token prices). Cost is computed with a peak/off-peak split: peak hours are Beijing time 09:00-12:00 and 14:00-18:00, every other Beijing hour is off-peak; weekends (Beijing Saturday/Sunday) are always off-peak. A model priced with a peak/offpeak pair uses the matching tier by the usage record's time; a model priced with only the four flat keys uses that price at any hour. The default row ships currency: CNY and peak/off-peak pricing for deepseek-v4-flash, deepseek-v4-pro, and deepseek-v4-flash-vision-exp.

Example override in the profile's own cordis.patch.yml:

- patch:
    - id: token-usage-stats
      config:
        currency: USD
        pricing:
          deepseek-v4-flash:
            peak:
              uncachedInputPerMillion: 3.0
              cacheReadPerMillion: 0.10
              cacheWritePerMillion: 0
              outputPerMillion: 9.0
            offpeak:
              uncachedInputPerMillion: 1.5
              cacheReadPerMillion: 0.05
              cacheWritePerMillion: 0
              outputPerMillion: 4.5

Development

pnpm install   # devDependencies link the local deepseek-harness checkout
pnpm run build # tsc -> lib/types, tsdown -> lib/index.js + lib/client.js

The devDependencies resolve the @deepseek-ai/dsh-* type surface through link: entries that expect the harness checkout at ../deepseek-harness relative to this package. Runtime peers are provided by the dsh host, not installed from npm.

Publish

npm run build
npm publish    # runs prepublishOnly (npm run build) automatically

Repository

Issues and pull requests are welcome.

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.