dsh-commandcode-quota: DeepSeek Harness Command Code Balance and Quota Dashboard

Preface

When developing or interacting with DeepSeek Harness (DSH), it is critical to monitor your Command Code account balance and the usage of your quota windows (5-hour, weekly, monthly) in real time. The dsh-commandcode-quota plugin addresses this need by rendering a compact status line beneath the DSH Composer, enabling quota monitoring without leaving the main interface.

Plugin Introduction

Maintained by user fuqiancheng, this plugin is a single-account status panel tool.

It does not receive or store API keys in the browser; all credential handling takes place within the local process. The plugin displays the balance on the DSH interface and shows real-time percentage usage for the 5-hour, weekly, and monthly windows. Clicking the status line expands a detailed view containing billing information, token usage, success rates, subscription details, and account information.

Installation and Activation

Basic Installation

Installation from npm is recommended:

dsh plugin add dsh-commandcode-quota

DSH will automatically extend your configuration with the bundled cordis.patch.yml, eliminating the need to manually edit patch files.

Local Development Installation

If installing from a local repository:

dsh plugin add file:/path/to/dsh-commandcode-quota

Manual Installation for Desktop App

Electron desktop applications are managed differently from the web client; the dsh plugin add command does not automatically handle plugin mounting. You must manually create a Junction and edit the configuration file.

  1. Create a Junction
    Run the following command in PowerShell to link the local package to DSH’s shared resolution pool:
   New-Item -ItemType Junction `
     -Path "$env:USERPROFILE\.dsh\profiles\node_modules\dsh-commandcode-quota" `
     -Target "C:\path\to\dsh-commandcode-quota"
  1. Configure the Patch
    Edit ~/.dsh/profiles/<profile>/cordis.patch.yml and add the following content:
   - insert:
       - id: dsh-commandcode-quota
         name: 'dsh-commandcode-quota'
         config:
           apiKeyEnv: COMMANDCODE_API_KEY

Note: The Junction name must exactly match the package name; otherwise, the host will fail to resolve the import.

After installing or modifying plugins, refresh the plugin tree (click refresh on the plugin page or restart the client).

Configuration

The plugin depends on a Command Code API key, which is resolved through DSH’s credential service and is not exposed to the browser.

Configuration Item Default Value Description
apiKeyEnv COMMANDCODE_API_KEY Environment variable name for credential resolution
fallbackEnv — Fallback environment variable name used when the first variable is missing (optional)
baseURL https://api.commandcode.ai Base URL for the Command Code API
timeoutMs 30000 Timeout for a single request (in milliseconds)

Credential files are located at ~/.dsh/.credentials.yaml or can be managed in DSH Settings → Credentials. Never commit files containing credentials to version control.

Features

  1. Status Line Display
    Renders a compact status line beneath the Composer, displaying the available balance and real-time usage percentages for the 5-hour, weekly, and monthly windows.

  2. Expanded Details
    Clicking the status line expands a detailed data panel containing:
    * Used/Limit/Remaining quota and reset time
    * Total spend
    * Token statistics
    * Success rate
    * Subscription status
    * Account information

  3. Security Design
    * Single-account design with no account switcher.
    * The API key is read only into local process memory and is never sent to the browser side.

How It Works

The plugin adopts a “host-client” separation architecture:

  • Host Side: Responsible for resolving credentials, registering a read-only HTTP endpoint, forwarding requests to the Command Code API, and aggregating results into a single payload.
  • Client Side: Injects the status line into DSH’s Dock Slot, periodically polls the host endpoint, and renders based on DSH’s theme tokens to ensure compatibility with light/dark modes.

Data is sourced from four Command Code API endpoints:
* /alpha/billing/credits: Balance and 5-hour/weekly limits
* /alpha/usage/summary: Spend, tokens, and success rate
* /alpha/billing/subscriptions: Subscription status and cycles
* /alpha/whoami: Account information

Error Handling Strategy

The plugin’s behavior during request exceptions is as follows:

  • Parallel Requests: The four API requests are executed in parallel; total latency depends on the slowest request rather than the sum.
  • Retry Mechanism: Connection-layer failures are retried once; timed-out requests are not retried.
  • Cache Fallback: When all requests fail, the panel displays the last successfully fetched data (retained in process memory for 6 hours) and marks it as stale.
  • Error Indication: HTTP 401 (authentication failure) does not use cached data and immediately prompts an error to ensure users can detect key configuration issues.

Notes

  1. Environment Requirements
    * Requires the DeepSeek Harness web client (dsh web) or desktop application to be running.
    * Node.js 20 or higher must be installed locally.
    * A valid Command Code API key is required.

  2. Desktop Application Specifics
    The desktop application does not run the dsh plugin add synchronization logic by default, so you must manually configure the Junction and cordis.patch.yml following the steps in the “Manual Installation for Desktop App” section above.

  3. License
    This plugin is released under the MIT License and is open-source hosted on GitHub. It is recommended to review the source code before installation to ensure it meets your project requirements.

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

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

Xiaoye