Sandbox
@Aisland-SJL/dsh-usage

DeepSeek Harness usage dock and balance panel

dsh-usage adds a floating dock to DeepSeek Harness web so you can see balance, today, month, cache hit, and refresh status at a glance. It also opens a configurable panel with seven widgets, including usage logs, a heatmap, and a Claude Code channel comparison.

92 stars13 forksJavaScriptUpdated 17d ago
Who it's for

Builders who use DeepSeek Harness and want their agent usage, balance, and cache stats in one place.

What it delivers

You can check usage and balance without switching away from the Harness web UI.

What it does

Persistent dock

Shows balance, today, month, and cache-hit stats in a small floating dock that stays visible and collapses into a balance pill.

Customizable panel

Lets you pin, collapse, hide, and drag-reorder widgets, with live accent, background, and opacity controls.

Usage widgets

Includes balance, today, this month, cache hit, channel share, usage log, and a 28-day activity heatmap.

Background refresh

Refreshes balance and usage data at startup and every five minutes.

Local-only security

Uses loopback-only JSON endpoints, resolves credentials server-side, and keeps prompts and replies off the wire.

How to get it

  1. 1Requires a DeepSeek Harness web profile (@deepseek-ai/dsh >= 0.1.0-rc.6).
    dsh plugin --profile web add "github:Aisland-SJL/dsh-usage"
  2. 2The normal install declares and installs…
    cd ~/.dsh/profiles/web
    pnpm add @deepseek-ai/dsh-client-ui-primitives@0.1.1-rc.2 --save-exact
  3. 3Restart dsh web, hard-refresh the browser, and the dock appears at the bottom-left.…
    dsh plugin --profile web update dsh-usage
    dsh plugin --profile web remove dsh-usage

README

🌊 dsh-usage

A persistent floating dock, a fully customizable balance / token-usage panel, an activity heatmap, and a dual-channel usage comparison for the DeepSeek Harness Web GUI (dsh web).

README-中文 License

✨ Feature tour

🌊 Persistent dock

Your key numbers stay visible at all times — balance glows green (red only when out of credit), rows are separated by hairlines, and a settings gear plus one-click refresh sit in the corner. When the sidebar collapses, the dock folds into a tiny balance pill.

dsh-usage dock
  • 🟢 Balance — green when healthy, red when drained
  • 📊 Today / Month / Cache hit — glanceable token stats
  • Gear opens the panel · ↻ refresh re-queries instantly
  • 🧲 Mirrors your pins — every change applies immediately

🎛️ Detail panel — all seven widgets

A two-column card layout; every widget has a detail and a compact form, and can be drag-reordered, collapsed, hidden, or pinned.

WidgetWhat it does
💳 BalanceBig number on the left, available / topped-up / granted rows on the right; provider switchable
📊 TodayToday's tokens plus input / output / cache-read breakdown
📈 This monthMonthly tokens plus the same breakdown
🎯 Cache hitToday's and all-time cache hit rates
↔️ Channel shareDSH channel vs Claude Code channel ratio bar
📜 Usage logLast 14 days per-day list, click to drill into per-model detail
🔥 Activity heatmap28-day × 6-band dot grid (dates across, 0–24h down)
dsh-usage panel

🎨 Everything customizable

Accent (presets + color picker), background, and panel opacity are adjustable live. Drag-reorder, pin, collapse, hide — every number presents your way, echoing DeepSeek Harness's "everything is a plugin" spirit.

dsh-usage customizer

At a glance

FeatureNotes
💳Persistent dockPinned compacts always visible; collapses into a balance pill when the sidebar folds
🎨Everything customizableWidgets: pin / collapse / hide / drag-reorder with a dashed placeholder and glide animation; accent, background, opacity; persisted in localStorage
📊Balance & usage panelProvider picker, balance breakdown, today/month totals in k/M/B units, cache hit, usage log with per-model drilldown
🔥Activity heatmapGitHub-style dots: 28 days × 6 four-hour bands with date labels
↔️Channel shareDSH channel vs Claude Code channel (incremental JSONL aggregation of ~/.claude/projects)
🔄Background refreshRefresh at startup, then every 5 minutes: balances, DSH tokens, Claude Code aggregation
🔒Local-only securityThree loopback-only GET endpoints; credentials resolved server-side; upstream forced HTTPS with DNS pinning; Claude logs aggregate numbers only — message text never leaves the machine

UI supports Chinese and English. Credentials come from Harness's ~/.dsh/.credentials.yaml; the plugin never reads, caches, or echoes secrets.

Quick start

Requires a DeepSeek Harness web profile (@deepseek-ai/dsh >= 0.1.0-rc.6).

dsh plugin --profile web add "github:Aisland-SJL/dsh-usage"

The normal install declares and installs @deepseek-ai/dsh-client-ui-primitives@0.1.1-rc.2 as a runtime dependency. If you register a development checkout with link:, install the same exact package in the active profile because linked packages do not populate the profile dependency tree:

cd ~/.dsh/profiles/web
pnpm add @deepseek-ai/dsh-client-ui-primitives@0.1.1-rc.2 --save-exact

Restart dsh web, hard-refresh the browser, and the dock appears at the bottom-left. Update / remove:

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

Credentials

Balance providers read credential references from ~/.dsh/.credentials.yaml:

DEEPSEEK_API_KEY: sk-your-key-here            # official DeepSeek route
OPENROUTER_MANAGEMENT_KEY: sk-or-v1-...       # OpenRouter account (Management Key, not the inference key)
ZAI_API_KEY: your-zai-key                     # Z.ai open platform

Moonshot / Kimi profiles under llm-pi-ai are discovered automatically and reuse their apiKeyEnv. Providers without a public balance API show an explicit "no public balance interface" state — never a guess.

Supported providers

ProviderUpstream endpointDefault credential ref
DeepSeekGET {origin}/user/balanceDEEPSEEK_API_KEY
OpenRouterGET {origin}/api/v1/creditsOPENROUTER_MANAGEMENT_KEY
Moonshot / KimiGET {origin}/v1/users/me/balancepi-ai provider apiKeyEnv
Z.ai / GLMGET {origin}/api/paas/v4/balanceZAI_API_KEY

API

MethodPathResponse
GET/api/usage/providersProvider list, balance scheme, and status summary
GET/api/usage/balance?provider=<id>Unified balance snapshot; refresh=1 forces an upstream query
GET/api/usage/usagePer-day/per-model token aggregates, cache hit rates, 24-hour buckets (days[].hours), and the Claude Code channel (claude)

Non-GET requests get 405, non-loopback callers get 403; every response is JSON with Cache-Control: no-cache.

Development & testing

npm install           # react/react-dom/jsdom for offline tests only
npm run check         # syntax checks for every module and script
npm test              # 83 offline tests: balance schemes, token folding, server boundary, client, e2e flows, Claude aggregation, package contract
npm run test:package # runtime dependency + client inject contract

Tests are fully offline — no network, and the real ~/.dsh is never touched (server tests redirect DSH_HOME to a temp dir). Dry-run the real Claude data: node scripts/validate-claude.mjs.

Privacy & security

  • API keys never enter browser responses, plugin caches, or logs; they are resolved at request time through Harness's credentials seam.
  • Upstream balance queries: HTTPS enforced, DNS pre-resolved and private/loopback ranges rejected, connections pinned to the checked address (DNS-rebinding defense), 1 MiB response cap, 15 s timeout.
  • Usage caches under ~/.dsh/storages/ hold only aggregated token numbers and fold cursors — no prompts, no replies.
  • Claude Code logs are parsed line-by-line and discarded; only aggregated numbers reach the cache.
  • Do not expose these endpoints through a reverse proxy to LAN or the public internet.

Credits

  • Ychris12138/dsh-usage-stats (MIT): reference for balance schemes, token folding semantics, bundle plugin structure, and the security boundary.

License

MIT

Files in the repo

Repository payload12 top-level entries
  • docs
  • lib
  • scripts
  • vendor
  • .gitignore
  • AGENTS.md
  • cordis.patch.yml
  • LICENSE
  • package-lock.json
  • package.json
  • README.md
  • README.zh-CN.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More plugins

Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.

138k
1 add

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

82k
code-yeongyu/
oh-my-openagent

OmO: Just type "mass ulw" keyword with your prompt. Now you are the master of graph engineering.

69k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

94k

Opinionated Oxlint rules for rejecting low-evidence TypeScript and JavaScript patterns

4.3k