stevenx65/dsh-balance-plugin 预览 preview

stevenx65/dsh-balance-plugin

Plugin插件 Native原生 ⭐ 6 MIT Usage & Cost用量与计费

Project Overview项目介绍

This is a native DSH plugin that runs as a Cordis plugin inside the DSH process, built exclusively for the DSH web platform, designed to display DeepSeek official API account balance and aggregated token usage directly in the DSH web sidebar. It automatically pulls balance data by calling DeepSeek’s official GET /user/balance endpoint, and reuses the DSH credentials stored locally at ~/.dsh/.credentials.yaml so users do not need to re-enter their API key. It also aggregates token usage data from DSH’s compressed session logs, and includes a toggle to switch between viewing today’s (Beijing time) or all-time usage statistics, filtered only to the deepseek-official provider.

The simplest way to install the plugin is via the DSH plugin market using the command line: run dsh plugin --profile web add dsh-balance-plugin, then restart the dsh web process and refresh your browser. Once installed, a new balance button will automatically appear at the bottom of the DSH web sidebar, ready for immediate use. For users who prefer manual installation, you can copy the plugin files to your DSH web profile’s node_modules directory and add an entry to the cordis.patch.yml configuration file before restarting DSH, which is useful if you want to modify the source first.

On the Node side, the plugin only uses Node built-in modules, but relies on the zstd CLI tool to decompress DSH’s session logs stored in ~/.dsh/sessions/. It pulls cached input, cache read, output token counts, and model call counts from the session logs to generate accurate usage totals. On the browser side, it relies on the @deepseek-ai/dsh-client-ui-primitives package, which is a peer dependency included by default in DSH 0.1.0-rc.6 and newer, so no extra installation is needed for most users. The plugin automatically adapts to the active DSH light or dark theme, and is released as open source under the permissive MIT license.

这是一款专为DeepSeek Harness(DSH)打造的原生插件,仅面向DSH网页端开发,用于在DSH网页侧边栏(3080端口)底部显示DeepSeek官方API的账号余额和已使用token统计,只统计deepseek-official官方供应商的调用数据。它复用DSH已保存在~/.dsh/.credentials.yaml中的凭证,用户无需手动输入API密钥,支持按当日(北京时间)和全部历史两个维度切换统计。

该插件可以通过DSH内置插件市场直接安装,用户只需执行dsh plugin --profile web add dsh-balance-plugin命令,完成后重启DSH网页服务并刷新浏览器页面,即可在侧边栏底部看到余额按钮。用户也可以手动安装,将项目文件复制到DSH网页配置文件目录后修改对应配置项即可完成安装,操作步骤清晰简单。

Node端依赖zstd命令行工具来解压DSH的会话日志,浏览器端所需的Peer依赖@deepseek-ai/dsh-client-ui-primitives已随DSH 0.1.0-rc.6及以上版本内置,无需额外安装。该插件基于MIT许可证开源,可自动适配DSH的浅色/深色主题,仅统计DeepSeek官方供应商的调用数据。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 6 stars - very few users, little community feedback星标只有 6,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-balance-plugin

把 stevenx65/dsh-balance-plugin 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-balance-plugin

Awesome DSH Plugin

A DeepSeek Harness (dsh) web plugin: shows DeepSeek API balance and token usage at the bottom of the web sidebar (port 3080), with a Today / All-time toggle, filtered by provider (only deepseek-official, ignoring other vendors).

Features

  • 💰 Balance: calls DeepSeek's official GET /user/balance, reusing dsh's credentials (~/.dsh/.credentials.yaml) — no manual key entry
  • 📊 Token usage: reads dsh session logs (session.jsonl.zstd), aggregates by provider
    • Uncached input / cache read / output / model call count
  • 🔄 Today / All-time toggle: today (Beijing time) or full history
  • 🎨 Auto-adapts to light/dark theme

Screenshot

dsh-balance-plugin

Install (from the plugin market)

dsh plugin --profile web add dsh-balance-plugin

Restart dsh web, then refresh the page — a balance button appears at the bottom of the sidebar.

Architecture

Browser (3080 page)
  client.js ──fetch──▶ /dsh-balance/data?scope=today|all
                              │
node side (index.js, inside the dsh process)
  ├── credentials.resolve("DEEPSEEK_API_KEY")  ← reuses dsh's key
  ├── fetch(https://api.deepseek.com/user/balance)
  └── decompress ~/.dsh/sessions/*/*/session.jsonl.zstd
      filter assistant/message rows + provider=deepseek-official
  • index.js: node-side cordis plugin, registers HTTP route /dsh-balance/data
  • client.js: browser-side plugin, injects into sidebar.footer.action (sidebar bottom button + floating panel)
  • package.json: dsh.bundle + dsh.client.platform: "web" + exports["./client"]
  • cordis.patch.yml: bundle patch registering the node entry

Manual install

mkdir -p ~/.dsh/profiles/web/node_modules/dsh-balance-plugin
cp index.js client.js cordis.patch.yml package.json ~/.dsh/profiles/web/node_modules/dsh-balance-plugin/

Then add to ~/.dsh/profiles/web/cordis.patch.yml:

- insert:
    - id: dsh-balance
      name: dsh-balance-plugin

Restart dsh web and refresh the browser.

Dependencies

  • node side: Node built-ins only (node:fs, node:child_process, node:path); requires the zstd CLI for decompressing session logs
  • browser side: @deepseek-ai/dsh-client-ui-primitives (peer dep, ships with dsh 0.1.0-rc.6)

Data source

Session logs at ~/.dsh/sessions/<scope>/<session-id>/session.jsonl.zstd. Each assistant/message row:

{
  "type": "assistant/message",
  "time": 1786635270943,
  "data": {
    "message": { "source": { "kind": "model", "provider": "deepseek-official", "model": "deepseek-v4-pro" } },
    "usage": { "inputTokens": 8702, "outputTokens": 298, "cacheReadTokens": 0 }
  }
}

Pack

npm pack   # produces dsh-balance-plugin-0.1.0.tgz

License

MIT

← 上一个 Prev fujiang-dsh 下一个 Next dsh-wallpaper →