dsh-plugin-account-balance
DeepSeek Harness 插件:在输入框底部统计行里显示账号剩余额度,位置紧挨「缓存命中」右边。
A DeepSeek Harness plugin that shows your remaining DeepSeek account balance in the composer dock, right after the cache-hit reading.

图中蓝框圈出的 ¥14.79 就是本插件渲染的格子。金额是充值余额 + 赠金余额按币种合计:悬停显示拆分(充值余额 ¥9.99 · 赠金余额 ¥5.26),点击打开 DeepSeek 平台用量页,页面可见时每 60 秒刷新一次。读不到钱包时显示 -- 并保留这一格,不会让整行跳动。
前提
- DeepSeek Harness 的 Web 界面(
dsh web),profile 里要有conversation.composer.dock这个插槽(官方 web 组装自带)。 - 用 DeepSeek 账号登录。只用 API Key 的组装没有账号态,插件不会显示任何东西。
- 账号要能查到钱包摘要。查不到时显示
--,此时打开设置 → 账号与余额看到的通常也是"前往开放平台查看"——那是账号侧的问题,不是插件。
安装
插件是一个 DSH 插件包(dsh.bundle.patch + dsh.client),仓库里不带构建产物:client.js 是手写的模块装载包,index.js 只提供一个空的宿主半边。
从 Discover 安装
本仓库同时发布了一份插件市场索引(docs/index.json,由 DSH 官方的 market generator 生成)。profile 启用了插件市场(@deepseek-ai/dsh-experimental-plugin-market-bundle)时,把下面这个地址加进 设置 → 插件 → 发现 的索引源,就能在应用内搜到并直接安装:
https://cai-like.com/dsh-plugin-account-balance/index.json
也可以在对话里直接问 Agent:"用 plugin_market 搜一下 account balance" —— plugin_market 是 DSH 内置的工具,读取的就是 profile 里配置的这些索引源。
GitHub Pages 的
cailikelog.github.io/...地址会 301 到上面的自定义域名,而市场抓取把重定向当作失败,所以索引源请用自定义域名这一条。
手工安装
# 1. 装进 profile 的 node_modules
cd ~/.dsh/profiles/web # Windows: C:\Users\<你>\.dsh\profiles\web
pnpm add github:cailikelog/dsh-plugin-account-balance
# 2. 在 profile 的 cordis.patch.yml 里插入一行(文件末尾追加,注意 YAML 数组缩进)
- insert:
- id: dsh-plugin-account-balance:pill
name: dsh-plugin-account-balance
# 3. 重启
dsh
这条 pnpm add github:... 在干净目录里实测过:装上 0.1.0,装进去的 client.js 与仓库里的字节完全一致。
索引是怎么生成的
docs/index.json 由 DSH 仓库里的 market generator 读 market-sources.txt 生成,改完包名/描述/图标后重新生成即可:
pnpm --filter @deepseek-ai/dsh-plugin-market-generator start \
--input market-sources.txt --output docs/index.json \
--title "cailikelog plugins" --description "DeepSeek Harness plugins by cailikelog"
卸载
删掉 cordis.patch.yml 里那三行(- insert: 和下面两行),pnpm remove dsh-plugin-account-balance,重启。
实现要点
- 只占一个槽位:
conversation.composer.dock(列表槽),id为account-balance,order: 2——缓存命中那颗是order: 1。 - 数据走
remote.account:getState()拿登录态和用量页地址,getBalance()拿钱包摘要。不读取、不复制任何凭据,凭据始终留在宿主进程里。 - 注册和读取都挂在
remoteAccess.whenAccess('account/watch')下:对端没有账号访问权限时不会注册这个格子,权限被收回时一并拆除。 - 不依赖其它插件,也不依赖主题包:颜色走
--dsw-*/--dsh-*CSS 变量,样式内联。
已知限制
client.js里的CLIENT_VERSION = '0.2.1-rc.3'会作为x-client-version发给平台。平台若开始校验版本,改这一个常量即可。- 金额用浮点数求和、向下取两位,只用于显示,不参与任何计费。
- 与本仓库
packages/client/ui-settings-account里的AccountBalancePill使用同一个格子 id,不要同时启用两份,后注册的会替换先注册的。
开发
pnpm install
pnpm test # 装载 client.js、跑 apply、断言注册项与渲染结果
test/smoke.cjs 复刻了浏览器装模块的方式:先给出 window.__ModuleLoader__,再执行 client.js,用假 ctx 跑 apply,最后用 React 渲染出那一格。
No comments yet. Be the first to write one.