Introduction

In the DeepSeek Harness (DSH) plugin ecosystem, developers often need to track Token consumption in real time and view the balance or quota of various services. The dsh-usage-stats plugin attaches usage statistics and quota monitoring to the bottom of the Web sidebar. Clicking it opens a detail panel, which displays data by three dimensions: model, session, and date.

Plugin Overview

This is a DSH Web plugin used to track Token usage and display balances. It is mounted at the bottom of the sidebar to show today’s usage, and clicking it opens a detail panel for multi-dimensional data viewing.

Core Features

  1. Sidebar Today Statistics
    Displays today’s statistics at the bottom of the sidebar, with adaptive support for both the wide column and the 56px rail.
  2. Detail Panel
    The panel organizes information into five tabs: Overview, Date, Session, Model, and Settings.
  3. Model Statistics Redirection
    Configure rules in the Settings tab to attribute the usage of a specific model from one provider to a specific model under another provider. The Model tab aggregates and displays data according to these rules, while the raw ledger data remains unchanged.
  4. Quota Monitoring
    • OpenCode Go: Displays the remaining quota for the rolling 5-hour period, the current week, and the current month.
    • DeepSeek: Displays multi-currency balances.
    • Z.ai: Displays the rolling 5-hour and weekly percentages, as well as the monthly Web search count.
  5. Session ID Badge
    Displays a session-id badge next to the session title. Hovering over it allows copying. It is enabled by default and can be disabled in the Settings tab.

Installation and Enablement

Use the official command to install the plugin:

dsh plugin --profile web add @xfqz86/dsh-usage-stats

Uninstall command:

dsh plugin --profile web remove @xfqz86/dsh-usage-stats

Configuration and Usage

Settings Location

The settings are located in the “Settings” tab of the detail panel. The configuration is saved in the DSH profile configuration file ~/.dsh/profiles/<profile>/cordis.patch.yml. When switching browsers or devices while logging into the same DSH instance, the preferences remain consistent.

Basic Configuration

Enable quota monitoring (such as DeepSeek balance, OpenCode Go quota, and Z.ai quota) and sidebar display. The quota fetching interval is 5 minutes by default, with a lower limit of 3 minutes.

In the configuration file, modify only the fields that need adjustment. For example, to change the Go quota fetching interval to 10 minutes:

- id: usage-stats
  name: '@xfqz86/dsh-usage-stats'
  config:
    goFetchMinutes: 10

Credential Configuration

The corresponding keys must be configured in the DSH credential center:

  • OpenCode Go: OPENCODE_GO_API_KEY
  • DeepSeek: DEEPSEEK_API_KEY (compatible with DEEPSEEK_APIKEY, DEEPSEEK_API_TOKEN, and DEEPSEEK_TOKEN)
  • Z.ai: ZAI_CODING_CN_API_KEY or ZAI_API_KEY (the former takes priority)

Session ID Badge

By default, a session ID badge is displayed next to the session title. To disable it, turn it off in the “Settings” tab of the detail panel.

Data Storage and Statistical Criteria

Data Storage

Data is stored in SQLite and is located at $DSH_HOME/storages/dsh-usage-stats/ledger.sqlite. On first launch, historical sessions are automatically scanned and imported. Subsequent updates are applied incrementally in real time as events occur, and the data can be restored from the ledger after a restart.

Statistical Criteria

  • Data Source: Records carrying data.usage, including chat calls assistant/message and context compaction calls compaction/summary.
  • Calculation Method:
    • total = input + output + cacheRead + cacheWrite
    • reasoning is listed separately
  • Dimensional Breakdown:
    • The model dimension is derived from provider and model (chat calls use message.source, while compaction calls use the event top level).
    • The session dimension records the title, working directory, creation time, and last active time.
    • Date segmentation is based on local calendar days.
  • Excluded Content: Usage from auxiliary calls, such as automatic session title generation, is not included (only the request is recorded; usage returned by it is not recorded).

Note: This plugin runs with the privileges of the current DSH process. Please review the source code and license before installation.