Usage and cost statistics with peak/off-peak pricing after the 2026-08-17 rate change, a floating summary panel, per-session breakdowns, and a day/week/month/year/all usage heatmap.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:940842546/dsh-usage-billing
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. Only install sources you trust, and pin a commit (github:owner/repo#sha).
README
中文 | English
A build-free dual-face plugin for DeepSeek Harness: tracks every DeepSeek model call across all sessions, bills them by official pricing, and provides charted usage panels on the main UI and the settings page.
Billing: legacy prices before 2026-08-17 00:00 (Beijing time); peak/off-peak pricing after that (peak hours 9:00–12:00 and 14:00–18:00). Price table at the bottom.
Features
- Automatic tracking: listens to
llm/streamand records every model call (input / output / cache hit / cache miss tokens) - Historical backfill: on first start, scans local session logs to rebuild historical usage and cost, with session titles
- Tiered billing: each call falls into "before 8/17 · legacy", "after 8/17 · peak", or "after 8/17 · off-peak" by Beijing time
- Main UI:
- A "用量" button at the sidebar foot → a floating summary panel (total cost, billing-segment ratio, usage heatmap, session Top 5)
- A persistent line under the composer showing the current session usage
- Settings → 用量统计: full details (stat cards, segment ratio, day/week/month/year/all heatmap with instant hover tooltips, per-session Top 8, per-model, recent calls, backfill/clear)
- Dynamic tool
usage_stats: the model can query statistics directly ("how much have I spent?") - Persistence: data is written to
.dsh-usage-stats.jsonunder the write-policy root; survives restarts
Install
Option A: one-line npm install (recommended, prebuilt)
dsh plugin --profile web add dsh-usage-billing
npm package: https://www.npmjs.com/package/dsh-usage-billing
The package auto-mounts at startup through its dsh.bundle.patch (cordis.patch.yml) — no other configuration needed.
⚠ Do not patch official bundles (e.g.
@deepseek-ai/dsh-web-app/cordis.patch.yml) directly, and do not place the plugin inside thenpm-cache\_npxcache (npm reify rebuilds it and leaves dangling links).
A local path works too:
dsh plugin --profile web add <repo path>.
Option B: user patch layer (without touching the profile)
Add the content of the repo-root cordis.patch.yml to:
%USERPROFILE%\.dsh\cordis.patch.yml
- insert:
- id: usage-stats
name: 'dsh-usage-billing'
Data & billing
| Data | Location / notes |
|---|---|
| Stats file | .dsh-usage-stats.json under the write-policy root (usually the user home) |
| Billing zone | Beijing time; rate-change boundary 2026-08-17 00:00 |
| Unit | CNY per million tokens |
Price table (CNY per million tokens):
| Period | Model | Cache hit | Cache miss | Output |
|---|---|---|---|---|
| Before 8/17 | v4-flash | 0.02 | 1 | 2 |
| Before 8/17 | v4-pro | 0.025 | 3 | 6 |
| After 8/17 · off-peak | v4-flash | 0.05 | 1.5 | 4.5 |
| After 8/17 · peak | v4-flash | 0.10 | 3.0 | 9.0 |
| After 8/17 · off-peak | v4-pro | 0.15 | 4.5 | 13.5 |
| After 8/17 · peak | v4-pro | 0.30 | 9.0 | 27.0 |
Reference: DeepSeek API pricing
Structure
.
├── lib/
│ ├── index.js # Host half: llm/stream tracking, billing, backfill, persistence, /usage-stats route, usage_stats tool
│ └── client.js # Client half: main-UI entries + settings panel (window.__ModuleLoader__ bundle, build-free)
├── cordis.patch.yml # Bundle patch declaring the mount row (dsh.bundle.patch mechanism)
├── package.json # exports ("." / "./client" / "./cordis.patch.yml") + dsh.client / dsh.bundle declarations
├── PUBLISH.md # Publishing guide (GitHub / npm / install)
├── LICENSE
└── README.md
FAQ
- Doubled stats: older versions rebuilt without clearing first; since v0.2.0 a
schemaVersionmigration marker triggers a single clean rebuild on restart. - Panel not showing: the client bundle is discovered by the deployment's
clientModulesservice; restart the app and refresh the page after first install. - Two instances at once: the stats file is a shared resource and concurrent writes overwrite each other — keep a single instance.
- Overwritten by upgrades: redeploying the app directory overwrites built-in patch lines and package files; re-run the install step.
License
MIT
Links
More in this category
zhu1090093659/dsh-web-ui#packages/dsh-web-ui-all★ 2775
Plugin and skin collection for the DSH Web UI: task board, Git graph, right-side panel, remote mobile UI, pet, live token stats, and a skin center.
omdsh-dev/DSH-better-sidebar★ 1305
Full sidebar workbench with file rendering and editing, terminal, Git, and subagents; third-party plugins can register new tabs.
ccch1mneyyy/dsh-TUI★ 1293
Claude Code-style full-screen terminal UI: pixel-whale header, live status line, and streaming thought expansion.
omdsh-dev/dsh-at-file★ 225
Codex-style `@file` mentions: search workspace files in the composer and attach their contents to prompts.
huiliyi37/dsh-tianshu-tui★ 174
A terminal UI (TUI) for DeepSeek Harness.
Nagi-ovo/dsh-visualize★ 126
In-conversation generative UI: the model renders interactive HTML cards into the chat stream, with streaming preview and sandboxed rendering.