rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:liudiw/dsh-balance
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DeepSeek Harness 插件:在聊天窗口右上角实时显示 DeepSeek 账户余额 与 token 用量,并支持在界面里直接配置凭据。
装一个插件,聊天时随时看到「账户还剩多少钱、本次 / 累计用了多少 token」。
💎 ¥余额 · 本会话/本机累计),一眼看到余额与用量。~/.dsh/.credentials.yaml,0600 权限),任何接口都不回读明文。@deepseek-ai/dsh-web-app 组合即可,不依赖 dsh-worktable)。目标机已有一个 web profile 即可。三种装法任选。
dsh plugin --profile web add https://github.com/liudiw/dsh-balance/releases/latest/download/dsh-balance.tgz
装完重启 dsh web 生效。
若重启后在界面里看不到徽章,先确认 profile 的
dsh.profile.bundles已包含dsh-balance(部分版本的dsh plugin add只装依赖、不自动登记 bundle);没有就手动加一行再重启。
编辑目标机的 web profile package.json:
// <dsh 安装>/profiles/web/package.json
{
"name": "dsh-profile-web",
"private": true,
"dependencies": {
// ...原有依赖...
"dsh-balance": "https://github.com/liudiw/dsh-balance/releases/latest/download/dsh-balance.tgz"
},
"dsh": {
"profile": {
"bundles": [
// ...原有 bundle...
"dsh-balance"
],
"patchReload": "live"
}
}
}
然后在目标机执行:
cd <dsh 安装>/profiles/web
pnpm install
# 重启 dsh web(示例:systemctl restart <你的 dsh-web 服务>,
# 或杀掉旧进程后 cd <harness> && nohup dsh web --no-open &)
⚠️ 若
pnpm install报ERR_PNPM_MISSING_TARBALL_INTEGRITY(URL 依赖命中 pnpm 缓存时 不写integrity):删除pnpm-lock.yaml,把dsh-balance.tgz放到 profile 目录, 依赖改成"dsh-balance": "file:./dsh-balance.tgz"再pnpm install。 (tar 包由npm pack产出。)
dsh plugin --profile web add link:/path/to/dsh-balance # 改代码后重启生效
装完徽章没出现,先对浏览器做一次硬刷新(Ctrl/Cmd+Shift+R)再判断。
💎 徽章 → 下拉底部 ⚙️ 配置凭据。sk-...。copy(localStorage.getItem('userToken')) → 取返回 JSON 的 value 字段粘贴。密钥写入 DSH 凭据库(~/.dsh/.credentials.yaml,0600 权限),任何接口都不回读明文。
| 数据 | 来源 | 说明 |
|---|---|---|
| 账户余额 | api.deepseek.com/user/balance |
官方公开接口,用 DEEPSEEK_API_KEY |
| 本机 token 用量 | DSH 会话日志(assistant/message 的 usage) |
本机所有会话,启动时回放历史 |
| 平台本月用量 | platform.deepseek.com/api/v0/usage/amount |
平台私有接口,需 DEEPSEEK_USER_TOKEN |
| 平台累计用量 | 逐月求和(2024-01 起) | 12h 磁盘缓存 |
未配置 DEEPSEEK_USER_TOKEN 时,插件只显示余额与本机用量(下拉里有「去配置」入口)。
| HTTP | 路径 | 说明 |
|---|---|---|
| GET | /api/balance |
余额 + 本机 / 平台用量快照 |
| GET | /api/balance/config |
两个凭据的配置状态(configured / writable),不含值 |
| POST | /api/balance/config |
写入 {apiKey?, userToken?, unset?: [...]};须带 x-dsh-balance-config: 1 头(跨源页面无法伪造,防 CSRF) |
写接口把值交给 DSH credentials seam(set / unset 落到 ~/.dsh/.credentials.yaml 的 refs:),每轮请求重新解析——保存后无需重启即生效。API Key 若由只读来源(如环境变量)提供,writable: false,界面会提示且拒绝改写。
dsh.profile.bundles 含 dsh-balance。pnpm install 报 ERR_PNPM_MISSING_TARBALL_INTEGRITY:见「方式 B」下的说明,改用本地 file: 依赖。dsh-balance 的依赖无法解析(例如 link: 目标目录被移走 / 改名)。恢复目录或改用 tgz 安装。~/.dsh;有的机器设置了 DSH_HOME(如 ~/.config/dsh),要改那一个。userToken 是否已配置 / 过期,在徽章下拉里重填一次。# 本地开发安装(link 方式,改代码后重启生效)
dsh plugin --profile web add link:/path/to/dsh-balance
node --check lib/index.js && node --check lib/client.js
目录结构:
dsh-balance/
├── package.json # dsh.bundle 声明 + 客户端注入
├── cordis.patch.yml # 插件行
└── lib/
├── index.js # 宿主端:余额 + 用量 + 平台接口 + /api/balance/config
└── client.js # 浏览器端:头部徽章 + 详情下拉 + 凭据配置面板
发布新版本:
npm pack # 产出 dsh-balance-<version>.tgz
cp dsh-balance-<version>.tgz dsh-balance.tgz # 上传用版本无关名(供 latest/download 使用)
gh release create v<version> dsh-balance.tgz --generate-notes
资产用版本无关名
dsh-balance.tgz上传,这样各机器.../releases/latest/download/dsh-balance.tgz永远拿到最新版,安装配置无需改动。
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。