Introduction

In the Web GUI of DeepSeek Harness (DSH) (dsh web), developers often need to view two types of information: how many tokens the current session has consumed and what level the context usage is at; and how daily consumption and distribution by model look over the last 30 days.

DSH’s plugin mechanism follows the philosophy of “everything is a plugin.” dsh-token-usage is one of the Token usage display plugins, maintained by AFAP; the community directory is an independent site with no official affiliation with DeepSeek / Huafan.

Below, I will introduce its features, installation methods, and important notes.

What is it

dsh-token-usage is a Token usage display plugin for dsh web. It requires no configuration and does not modify files. It is designed for users who need to view session-level and global token consumption. The plugin license is MIT.

Core Features

Single Session Capsule

Displays the current session’s input, output, and context usage on the right side of the session header. After clicking the capsule, a detailed breakdown of four groups appears: Provider Usage, Context Composition, Context Pressure, and Session Statistics.

Global Consumption Panel

Provides a “Token Stats” button at the bottom of the sidebar. After opening the global panel, it can display daily consumption over the last 30 days, breakdown by model, and daily details. Data comes from session logs, scanned and aggregated in real-time; the panel auto-refreshes every 60 seconds when open.

Data and Runtime Constraints

  • No configuration required.
  • Does not modify any files; the global panel performs a read-only scan of session logs under $DSH_HOME\sessions, without writing, deleting, or altering logs.
  • The host has zero external dependencies, using only Node built-in capabilities and ./stats.js.
  • $DSH_HOME is parsed from the environment variable: $DSH_HOME~/.dsh.
  • The log format is a multi-frame zstd container; the host uses Node 22.22+’s built-in zstdDecompressSync and skips incomplete trailing frames caused by crashes.
  • /api/token-stats is registered with an exact route, accompanied by browser trust fencing (loopback / trustedHosts + same-origin checks), to reject DNS rebinding and cross-site requests.
  • Language follows the interface, with built-in Simplified Chinese and English dictionaries.
  • Aggregated data is cached locally, so repeated opening or restarting dsh does not require re-statistics.

Installation and Enablement

First execute the installation command, then restart dsh web for changes to take effect.

dsh plugin --profile web add github:AFAP/dsh-token-usage

After installation, the plugin is located at:

$DSH_HOME\profiles\web\node_modules\dsh-token-usage

This location is unrelated to the source code repository location.

If you need to install from a local source code directory:

dsh plugin --profile web add "D:\path\to\dsh-token-usage"

Upgrade and uninstall commands are as follows:

dsh plugin --profile web update dsh-token-usage
dsh plugin --profile web remove dsh-token-usage

Typical Usage

  1. Verify successful loading: Open any session and check if the token capsule appears on the right side of the header and if the “Token Stats” button appears at the bottom of the sidebar.

  2. Open the global panel: Click “Token Stats” at the bottom of the sidebar. After the panel opens, it auto-refreshes every 60 seconds, but manual refresh is also available.

  3. View daily distribution: Click on a bar for a specific day to expand the 24-hour usage distribution for that day.

  4. Close the panel: Press Esc or click the overlay to close.

Applicable Scenarios and Notes

Suitable for users running sessions in dsh web and wanting to view current session token usage, context pressure, consumption over the last 30 days, and distribution by model.

The plugin runs with the permissions of the current dsh process. You should check the source code, interface behavior, and license before installing; the license for this plugin is MIT.

The global panel relies on session logs under $DSH_HOME\sessions, and the statistical results are based on these readable session logs.

Links

Directory Page (Independent community site, no official affiliation with DeepSeek or Huafan):
https://www.skillhub.cn/plugins/AFAP/dsh-token-usage

GitHub:
https://github.com/AFAP/dsh-token-usage