@javierni/balance-show
Balance & usage card plugin built on the DeepSeek Harness for its Web GUI (not affiliated with DeepSeek): account balance with color tiers, plus live per-conversation token usage and cost (peak/off-peak priced).
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:JavierNier/balance-show说明文档
阅读完整 README ↗@javierni/balance-show
定位说明:本插件是基于 DeepSeek Harness(dsh)开发的余额卡片插件, 不是 DeepSeek 官方余额卡片,与 DeepSeek 平台无隶属关系。它读取的是 当前 harness 里配置的
DEEPSEEK_API_KEY所对应账户的余额。
右下角浮窗卡片显示余额(按档位着色),以及当前对话的实时 token 用量、 缓存命中率与费用(按高峰·低谷分桶计价)。
开发与数据说明
- 完全由 DeepSeek Harness 开发:本插件是 dsh(DeepSeek Harness)生态的
Cordis 插件,宿主半(
lib/index.js)+ 浏览器半(lib/client.js)双面结构, 通过 harness 的credentials/webServer/sessionPersistence等原生服务工作, 不依赖任何第三方运行时包。 - 查询的是安装者自己的账户:插件不内置任何 API Key,运行时从当前 harness
配置的
DEEPSEEK_API_KEY解析——谁装在这台 harness 上,就查询谁的账户余额。 - 价目表按官方价目策展:
lib/pricing.js的价格表策展自 DeepSeek 官方公告 (https://api-docs.deepseek.com/zh-cn/quick_start/pricing/),内置官方政策时间表 (含 2026-08-17 起峰谷定价:高峰 09:00–12:00 / 14:00–18:00,空闲时段半价), 按每条消息的时刻自动选择生效政策。如官方调整价目,需同步更新该文件。 - 计费为本地估算:token 数据来自 harness 会话记录(实时
session/event+ 回放持久化日志),费用按内置价目表本地计算,非 DeepSeek 平台权威账单。
功能
- 余额卡片(
shell.overlay右下角浮窗):余额字体按档位着色 (≥¥50 绿、¥10–50 橙、 如果之前用旧版本安装导致^0.2.x之类范围残留在 profile 的
package.json,需执行
dsh plugin --profile web update @javierni/balance-show让依赖范围重写为最新(插件内点击更新也会自动用add @latest重写范围)。
然后重启 dsh web(新增 bundle 需要启动时扫描),刷新浏览器页面即可看到
右下角卡片。
更新
插件自动检查 npm 线上版本(启动时 + 每 12 小时),右下角卡片底部常驻显示:
更新于 21:00:00 本地版本 v0.3.4 线上版本 v0.3.4
- 版本一致时显示灰色;线上有新版时变橙色,且
线上版本 vX.Y.Z变为可点击。 - 点击
线上版本 vX.Y.Z即通过本机 pnpm(PATH → corepack → npx 自动探测)执行pnpm add @javierni/balance-show@latest完成更新,成功后提示重启dsh web。 - 更新需要本机可调用 pnpm 或 corepack(Windows 上 Node 自带 corepack,一般无需额外安装)。
- 不会自动执行更新——只检查并提示,更新始终由你手动点击触发。
- 各版本改动见
CHANGELOG.md。
安装(本地开发方式)
-
把本包拷贝到 profile 依赖树(必须拷贝而非 junction/symlink:插件自身的 ESM 依赖需从
profiles\node_modules向上解析):Copy-Item -Path "" -Destination "$env:USERPROFILE\.dsh\profiles\node_modules\@javierni\balance-show" -Recurse -Force -
在
$env:USERPROFILE\.dsh\profiles\web\cordis.patch.yml(CLI 版;桌面版为%APPDATA%\dsh-desktop\harness\profiles\web\cordis.patch.yml)的 patch 数组里追加 (新行必须放在- insert:列表里):- insert: - id: balance-show name: '@javierni/balance-show' -
重启 harness(
dsh web),刷新页面。修改源码后需重新拷贝并再次重启。
卸载
删除上述 patch 行与 @javierni 目录(或 dsh plugin --profile web remove @javierni/balance-show),重启。
验证
node plugins/balance-show/scripts/test-balance.mjs # 宿主取数逻辑冒烟测试
curl http://127.0.0.1:3080/balance # 余额路由
curl "http://127.0.0.1:3080/api/session-stats?sessionId=x" # 会话统计路由
License
MIT