dsh-token-usage-panel: Viewing Token Usage in DSH Settings

Preface

When developing agents or handling long sessions with DeepSeek Harness (DSH), tokens become scattered across multiple requests and sessions. To check “how much was used today,” “which days were particularly expensive,” or “how much a specific session consumed,” the common practices are to check the service provider’s dashboard or write custom scripts to scan logs under $DSH_HOME/sessions/. The former requires switching away from DSH, while the latter has high maintenance costs.

dsh-token-usage-panel is a community-maintained client plugin (by Jun-Jun-Gao, MIT License) that adds a Token Usage page to the DSH Settings: featuring a daily heatmap, a trend for the last 30 days, per-session details, and optional cost estimation. Data is read exclusively from local session logs; no data is uploaded to the network.

What is this

The plugin’s full name is dsh-token-usage-panel, categorized as a Client-side plugin: The Host side scans and aggregates session usage, while the Browser side renders the UI within the settings panel.
Maintenance Repository: Jun-Jun-Gao/dsh-token-usage-panel; Community Directory: skillhub entry (an independent site with no official affiliation to DeepSeek or Quantilla/Hithink).

Core Features

The following documents the capabilities available in the panel, all of which can be used directly in Settings → Token Usage after installation.

Today’s Consumption: Displays the total amount for the current day, color-coded by “Output / Uncached Input / Cache Hit.” If unit prices are configured in Cost Estimation, it also displays the estimated daily cost.

Metrics Grid: Last 7 days, last 30 days, cumulative total, active days, consecutive usage days, and cache hit rate.

Daily Consumption Heatmap: Covers the last 53 weeks, styled similar to a GitHub contribution graph; darker colors indicate higher consumption for that day. Hover to view the breakdown of the four token types for that day; click a cell to expand the session distribution for that day.

Last 30 Days Trend: A stacked bar chart of Output, Uncached Input, and Cache Hits, with grid lines and peak scales.

Session Details: Supports sorting and search; narrow panels automatically streamline columns, while wide panels additionally display Workspace, Cache Hits, and 30-day mini-bars.

Summary Dimensions: Summarized by Model and by Workspace.

Cost Estimation: Auto-converts to currency after filling in unit prices (CNY / million tokens); prices are saved only in the local browser (localStorage). If left blank, amounts are not displayed.

The interface utilizes DSH design variables (--dsw-alias-*) and automatically adapts to Light/Dark themes; the panel width adjusts to the settings page. The documentation states that the 53-week heatmap remains fully visible even at approximately 590px width.

Statistical Criteria

The plugin aggregates data from the usage field of every assistant/message entry in DSH session logs. The documentation explains the meaning of the fields as follows:

Field Meaning
Uncached Input Prompt tokens billed at the input rate
Cache Hit The portion that hits the prompt cache
Output Tokens generated by the model (including Chain of Thought)
Total The sum of the above items, consistent with the service provider’s dashboard total

Due to multi-turn conversations resending context, the “Total” is often dominated by cache hits; the panel lists “Uncached Input + Output” separately to facilitate viewing the parts that actually affect billing.

The heatmap is archived by local timezone natural days; colors are divided into 4 levels based on “Day Consumption / Historical Single Day Max.”

Installation and Activation

DeepSeek Harness (Web or Desktop version) must be installed, and the dsh command must be usable. After installation, the bundle is enabled automatically; if the panel does not appear, refresh the page once.

  1. Open DSH sidebar Plugins → Install.
  2. Enter:
github:Jun-Jun-Gao/dsh-token-usage-panel

Method B: Command Line

# 1) Install to your profile (desktop as an example; Web version is usually web)
dsh plugin --profile desktop add github:Jun-Jun-Gao/dsh-token-usage-panel

# 2) Select it as a layer (bundle) for the profile
#    Edit $DSH_HOME/profiles/desktop/package.json, and add to dsh.profile.bundles:
#      "dsh-token-usage-panel"

Step 2 is equivalent to checking the bundle in the “Plugins” page; after modification, DSH can hot-reload or you can restart the application to apply changes.

The documentation also provides Method C (local link and cordis.patch.yml) for development and debugging; for daily installation, use A or B.

Typical Usage

  1. Open DSH Settings, select Token Usage on the left.
  2. View Today’s Consumption and the Metrics Grid; use the Heatmap to find high-consumption days, click cells to view the session distribution for that day.
  3. Filter by model, workspace, or keyword in “Last 30 Days Trend” and “Session Details.”
  4. When amounts are needed, fill in the four unit price types in Cost Estimation (CNY / million tokens); leave blank if not needed. Clicking “Clear” removes locally saved prices.
  5. The panel refreshes automatically every 30 seconds, or you can manually click “Refresh”; ongoing sessions are included in the statistics.

The Host provides a read-only interface which can be used for self-checking during development (replace <dsh-web-port> with your local port):

curl -s http://127.0.0.1:<dsh-web-port>/token-usage/health
curl -s http://127.0.0.1:<dsh-web-port>/token-usage/data | head -c 300

How it Works (Brief)

The Host side lib/index.js scans $DSH_HOME/sessions/**/session*.jsonl.zstd, aggregates into “per day / per session,” and registers the read-only route GET /token-usage/data. The logs are multi-frame zstd; the Host slices frames by magic number and decompresses them frame by frame without relying on external zstd commands; parsing results are incrementally cached by file size and mtime. The client lib/client.js registers settings.section, fetches data, and renders it; cost estimation writes to localStorage. The plugin does not register model-visible capabilities, so the model cannot see this panel.

Scenarios and Cautions

Suitable For: Users running long-term sessions in DSH who wish to view usage trends, session proportions, and rough costs locally without exporting logs to third parties.

Compatibility: The development and verification environment was DSH 0.2.0-rc.2 (Electron 44 / Node 24.18) Web GUI and Desktop version. The package does not declare @deepseek-ai/dsh* peerDependencies; if issues occur with newer versions, please open an issue on GitHub with your DSH version attached. Extension points include settings.section, ctx.locale, ctx.webServer.register.

Security & Permissions: The plugin reads the local session directory with the permissions of the current DSH process; it is recommended to browse the Repository Source Code and the MIT License before installation. This is a community plugin, not an official release; the directory page skillhub is an independent ecosystem site.

Uninstall:

dsh plugin --profile desktop remove dsh-token-usage-panel
# And remove "dsh-token-usage-panel" from dsh.profile.bundles in the profile's package.json

Conclusion

dsh-token-usage-panel integrates Token statistics into DSH Settings: Heatmap, Trends, Session Details, and optional Cost Estimation, all without data leaving the local machine. The installation identifier is github:Jun-Jun-Gao/dsh-token-usage-panel.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye