dsh-usage-stats: A Clear View of Local Token Usage in DSH Settings

Preface

When using DeepSeek Harness (DSH) for chat or coding, tokens are scattered across a large volume of local session logs. The control ledger aggregates by organization, making it difficult to correlate “this round of Chat” with “that round of Code.” If you simply want to view trends locally and split them by scenario and model, you usually have to manually scan $DSH_HOME/sessions for JSONL files. This is labor-intensive and prone to inconsistencies with Harness’s built-in accounting.

Below is an introduction to the community plugin dsh-usage-stats (maintained by ruaibeite). It adds a “Usage” page to the Harness settings panel, deriving figures from existing session logs in a read-only manner. It does not create new prompts, tools, or model calls, nor does it access external services.

What is it

dsh-usage-stats (npm package @ruaibeite/dsh-usage-stats, current version 0.1.0, MIT license) is a DSH client plugin: it injects a Usage navigation item into the settings, aggregates tokens from local session logs, and displays Chat/Code scenarios, daily bar charts, and model tables.

Categorically, it is a client-side plugin (platform: web), mounted to the settings UI via cordis.patch.yml, and communicates with the Host’s local GET route. The numbers on the page all come from logs that Harness would write anyway; the same batch of logs yields consistent folded results.

Core Features

Open the DSH Settings panel and click Usage (English interface is Usage) on the left. Scroll from top to bottom. By default, it stats the last 30 days, switchable between 7 / 30 / 90 days, refreshing immediately upon switching.

Scenario Cards (Chat and Code)
The large number on each card is “Input + Output” (excluding cache, consistent with the reference page). The details are four lines: Non-cached Input, Output, Cache Read, Cache Write; at the bottom is the number of web searches in these sessions. Sessions are only categorized into one scenario: if any code execution tool (e.g., bash, write, edit, apply_patch, etc.) is used, it is recorded as Code, otherwise Chat. Agent Teams tools are still recognized but do not form a separate third card.

Summary Info
There are three items under the subtitle: number of active sessions in the range, number of models, and cache hit rate (cache read ÷ (input + cache read + cache write)).

Daily Tokens
The bar chart can switch between “Scenario / Model”. Scenario mode shows two side-by-side bars per day (Chat / Code); Model mode is a stacked bar, taking the top six models by total volume and adding “Others”. When there is no data in the range, it shows “No usage yet during this period”.

By Model
The table is sorted by “Input + Output” in descending order. Model IDs from the same vendor are merged into one row. Columns include Model, Input + Output, Cache Read, and Share (with a bar and percentage). The footer includes description, last update time, and a Refresh button.

Metrics & Performance
Numbers follow Harness’s own tokenUsage accounting (can be reconciled with $DSH_HOME/storages/session_projcache session by session). The first full scan writes an index to $DSH_HOME/cache/usage-stats/index.json; for hundreds of MB of log libraries, the first scan is about 3–10 seconds, and subsequent incremental updates are usually below 200 ms. The page polls every 10 seconds when visible; the plugin also pre-warms the index in the background after activation. Since service provider bills cover organizations and have different billing metrics, the page clarifies that the total will not match the bill and does not display costs.

The data flow can be summarized as:

$DSH_HOME/sessions/**/session.v4.jsonl.zstd
        │  Read-only scan, decompress zstd frame by frame
        ▼
$DSH_HOME/cache/usage-stats/index.json
        │  Path · size/mtime · scenario · daily token buckets
        ▼
Settings → "Usage"  Cards · Daily Tokens · By Model

The page requests GET /dsh-usage-stats/report?days=7|30|90 and the response includes cache-control: no-store.

Installation & Enablement

The plugin runs with the current DSH process permissions. It is recommended to read the GitHub repository source code and MIT license before installing. The README provides three installation methods:

  1. Plugin Marketplace: Search for dsh-usage-stats or “Usage Statistics” and install with one click.
  2. GitHub Source Code (write to profile):
dsh plugin --profile add github:ruaibeite/dsh-usage-stats
  1. Local Directory (via plugin_manager):
plugin_manager: install_bundle target=/path/to/dsh-usage-stats

cordis.patch.yml comes with the package and generally requires no manual modification of the profile’s patch layer. The browser side takes effect on the next page load; the Host registers the route at startup. If the “Usage” page appears but the report cannot be fetched, restart DSH once. Uninstall can be done via plugin_manager: remove_bundle or from the marketplace, followed by a restart of the desktop app for the Host side to uninstall.

Typical Usage

After installing and restarting (if needed), you can use it by following the steps below without additional configuration files.

  1. Open the DSH Settings panel.
  2. Select Usage / Usage on the left.
  3. The first open shows a skeleton and “Summarizing local sessions…”, wait for the first scan to finish.
  4. Switch the time range using 7 / 30 / 90 days; switch Scenario / Model grouping in the daily chart.
  5. Click Refresh in the footer for immediate recalculation; if it fails, it retains the last numbers and marks it in the footer.

$DSH_HOME defaults to ~/.dsh, but can be pointed to another directory via the DSH_HOME environment variable; the report only includes session logs that still exist in that directory.

Applicability & Notes

Who is it for
Developers who use DSH long-term on their local machine and want to quickly judge if tokens are spent on chat or code, and which models take up a larger proportion. When you need to reconcile with the official bill, the service provider’s bill still takes precedence; this page is for local trends and scenario breakdown.

Privacy & Boundaries
The plugin only reads local session logs and the local index directory and does not send data to external networks; the only “network” aspect is the same-origin GET initiated by the settings page to the DSH host. It does not write sessions or add LLM calls.

Known Limitations (Original README text)
Only statistics current logs under $DSH_HOME; first scan time increases as the library grows; web search counts come from tool names like web_search / web_fetch in logs and are approximate values; Chat / Code are approximate classifications based on tool mapping; daily buckets use the host’s local time zone, and timezone changes will trigger index rebuilding. The page deliberately does not display amounts.

The DeepSeek Harness ecosystem is “everything is a plugin”; the SkillHub directory page is a community site with no official affiliation with DeepSeek / HanHua; please verify the installation source yourself.

Conclusion

dsh-usage-stats folds local session logs that Harness has already recorded into a usage dashboard in settings: Chat/Code cards, daily charts, and model tables; metrics consistent with DSH tokenUsage, fully local and read-only. To install or view screenshots and update notes, visit the directory page and repository:

  • Directory Page: https://www.skillhub.cn/plugins/ruaibeite/dsh-usage-stats
  • GitHub: https://github.com/ruaibeite/dsh-usage-stats
羽毛球分组比赛记分
小程序二维码

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

Xiaoye