DeepSeek Harness Plugin

Choi-Peng/dsh-deepseek-balance

Stars ★ 1 Downloads (30d) 1,289 Category Usage & Billing Added 2026-08-17 npm @choi-p/dsh-deepseek-balance

DeepSeek account balance in the dsh web sidebar footer with live config hot reload and an editable Settings → Plugins card.

Install

# from npm (prebuilt)

dsh plugin --profile web add @choi-p/dsh-deepseek-balance

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:Choi-Peng/dsh-deepseek-balance

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

A persistent DeepSeek Harness Cordis plugin that shows your DeepSeek account balance in the sidebar footer, right above the Settings button.

[!NOTE] AI-generated disclaimer: This plugin was generated by AI. It may contain errors, security issues, or behave unexpectedly. Please review the code and test it yourself before use; feel free to submit an issue or PR if you find any problems.

[!IMPORTANT] Compatibility: this release targets dsh ≥ 0.2.1-rc.1 (0.1.x stays on 0.5.x). The host derives the settings form from the entry's exported Config schema through @deepseek-ai/dsh-settings, and the browser reaches the same seam through ctx.configForms (@deepseek-ai/dsh-client-ui-settings).

Features

  • Displays your current DeepSeek account balance at the bottom of the left sidebar, above Settings, auto-refreshing every 60 seconds.
  • Three display modes: CNY only, USD only, or both; per-currency warning thresholds color the readout red below the threshold and yellow below twice it (0 disables the warning).
  • Live config — the values live in the plugin's own row in the profile cordis.patch.yml, read and written by the dsh settings service; saves apply immediately, without restarting dsh web and without remounting the plugin.
  • The settings section is rendered directly on the plugin's own page (Settings → Plugins → Balance Monitor), the same way the CodeBuddy bridge plugin does it; the deepseek-balance row keeps its configure page.
  • Hides automatically when the sidebar is collapsed (rail mode).
  • Reads the API key from the DEEPSEEK_API_KEY environment variable.

Architecture

This is a dual-face Cordis plugin:

Half File Role
Host lib/index.js Exports the schemastery Config (three volatile fields) the settings seam projects into an editable form for this entry, plus /deepseek-balance (proxies the DeepSeek Get User Balance API)
Client lib/client.js Registers the balance readout in the sidebar.footer.action slot (60 s poll), the settings section on the bundle page in plugins.bundle.config keyed by the package name, and the row's configuration page in plugins.row.config keyed @choi-p/dsh-deepseek-balance#deepseek-balance; reads and writes settings through ctx.configForms
Browser (Client half)  --fetch /deepseek-balance-->  Host HTTP route  -->  api.deepseek.com/user/balance
Browser (Client half)  --ctx.configForms-->  remote.settings  -->  the plugin's row in the profile cordis.patch.yml

Since dsh 0.2 a plugin no longer registers a settings namespace of its own: the Config schema a Loader entry exports is projected into a form by the settings service, and writes land in the profile patch document. The browser half reads the same document through ctx.configForms and submits mutate operations, so the sidebar readout and the configuration page share one source of truth — a save reaches both with no plugin-owned HTTP settings proxy and no poll.

Installation

Via plugin-registry

Settings → Plugins → Install, and set the source to @choi-p/dsh-deepseek-balance or github:Choi-Peng/dsh-deepseek-balance.

Manual Installation

dsh plugin --profile web add "github:Choi-Peng/dsh-deepseek-balance"

The package ships its own cordis.patch.yml (dsh.bundle.patch in package.json), which dsh applies automatically when installing the plugin — no need to hand-edit the profile-level cordis.patch.yml. Restart dsh web for it to take effect (plugin discovery is cached per process).

Uninstalling

dsh plugin --profile web remove @choi-p/dsh-deepseek-balance

The bundle mount disappears with the plugin; if you ever wrote the row into the profile-level patch manually, remove it first.

Configuration

Layer Source How it applies
Defaults declared in the Config schema (cny, both thresholds 0) —
Base (bundle) the row config in the plugin bundle's own cordis.patch.yml (dsh.bundle.patch, applied automatically on install) applies with the bundle
User (runtime settings) Save/Reset from Settings → Plugins → Balance Monitor, written by the settings service into this plugin's row in the profile cordis.patch.yml; Reset clears the overrides and falls back to the bundle defaults applies immediately

The effective value is schema defaults → bundle base → user layer, each layer overriding the previous.

The bundle's default config:

- insert:
    - id: deepseek-balance
      name: '@choi-p/dsh-deepseek-balance'
      config:
        displayCurrency: cny   # cny = CNY only | usd = USD only | both (default: cny)
        warningThresholdCny: 0 # CNY warning threshold (0 = disabled); red below it, yellow below 2×
        warningThresholdUsd: 0 # USD warning threshold (0 = disabled); red below it, yellow below 2×

The page exposes displayCurrency (CNY only / USD only / both) and both warning thresholds (number inputs), with Save / Reset-to-defaults. Writes carry the read revision for optimistic concurrency — if the settings changed elsewhere, the page reloads the latest values and tells you. The sidebar readout re-polls the balance every 60 s. Warning rule: balance ≤ threshold turns red, ≤ twice the threshold turns yellow, and a threshold of 0 disables the warning.

The API key is read from the DEEPSEEK_API_KEY environment variable; it is held only by the host half and sent as a Bearer token, never exposed to the browser.

The balance API returns all of the account's currency balances (usually CNY and USD); the sidebar shows the currencies selected by displayCurrency.

Usage

  1. Start dsh web with DEEPSEEK_API_KEY set in the environment — the sidebar footer shows a balance readout above Settings, refreshed every 60 s.
  2. Settings → Plugins → open the Balance Monitor (@choi-p/dsh-deepseek-balance) package page: the plugin info carries a Balance Monitor settings section — pick the displayed currency, set the warning thresholds, and Save. The deepseek-balance row → Configure opens the same form. Changes apply live without restarting dsh web.

Development

# Validate the host half imports cleanly (including the Config schema):
node --input-type=module -e "import('./lib/index.js').then(m => console.log(m.name, typeof m.Config.toJSON))"

# Syntax-check the client bundle:
node -e "new Function(require('fs').readFileSync('lib/client.js', 'utf8'))"

# Inspect how dsh validates this plugin's config:
dsh web --dump-config-schema | grep -A20 config

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.