@choi-p/dsh-deepseek-balance

usagetested: passnpmMIT

DeepSeek account balance in the dsh web sidebar footer with live config hot reload and an editable Settings → Plugins card.

下载量 / Downloads
851
依赖体积 / node_modules
0.49 MB
测试时间 / Tested
2026-11-07
DSH 版本 / Version
0.2.2-rc.1

Install

dsh plugin --profile web add @choi-p/dsh-deepseek-balance

Sandbox test results

StageResult
1 install✓
2 list✓
3 mount✓
4 boot—

Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).

README

dsh-deepseek-balance

一个常驻的 DeepSeek Harness Cordis 插件,用于在侧边栏底部、Settings 按钮正上方展示你的 DeepSeek 账户余额。

<p align="center">

<img src="docs/imgs/example.png" alt="账户余额示例" width="240">

</p>

[!NOTE]
AI 生成声明:本插件由 AI 生成,可能存在错误、安全隐患或不符合预期之处,使用前请自行 review 代码并实测;发现任何问题欢迎提交 issue 或 PR 修正。
[!IMPORTANT]
兼容性:本版本面向 dsh ≥ 0.2.1-rc.1(0.1.x 请使用 0.5.x)。

特性

  • 在左侧边栏底部、Settings 上方展示当前 DeepSeek 账户余额,每 60 秒自动刷新。
  • 三种显示模式:仅 CNY、仅 USD、或同时显示两者;可为 CNY/USD 分别配置预警阈值 —— 余额低于阈值显示红色、低于其两倍显示黄色(0 = 禁用预警)。
  • 配置实时生效 —— 设置写在 profile 的 cordis.patch.yml 配置行(由 dsh settings 服务读写),保存后立即生效,无需重启 dsh web,也不会重挂插件。
  • 设置区直接出现在「设置 → 插件 → 余额监控」的插件信息页里(与 CodeBuddy 桥接插件的呈现方式一致);deepseek-balance 行的配置页入口同时保留。
  • 当侧边栏收起(rail 模式)时自动隐藏。
  • 从 DEEPSEEK_API_KEY 环境变量读取 API 密钥。

架构

这是一个双面(dual-face)Cordis 插件:

端 · 文件 · 作用

Host · lib/index.js · 导出 schemastery Config(三个 volatile 字段),dsh 的 settings 缝据此为本插件条目生成可编辑表单;注册 /deepseek-balance(代理 DeepSeek Get User Balance API)

Client · lib/client.js · 在 sidebar.footer.action 槽位注册余额展示(60 秒轮询);在 plugins.bundle.config 槽位以包名 @choi-p/dsh-deepseek-balance 为 key 注册插件信息页的设置区,并在 plugins.row.config 槽位以 @choi-p/dsh-deepseek-balance#deepseek-balance 为 key 注册该插件行的配置页,读写经 ctx.configForms

Browser (Client half)  --fetch /deepseek-balance-->  Host HTTP route  -->  api.deepseek.com/user/balance
Browser (Client half)  --ctx.configForms-->  remote.settings  -->  profile 的 cordis.patch.yml(本插件配置行)

dsh 0.2 起,设置不再由插件自建命名空间:Loader 条目导出的 Config schema 会被 settings 服务(@deepseek-ai/dsh-settings)投影成表单,写入落到 profile 的 patch 文档;浏览器侧通过 ctx.configForms 拿到同一份快照并提交 mutate 操作,因此侧边栏读数与配置页共享同一份数据,保存后即时同步,不再需要插件自建的 HTTP 设置代理。

安装

通过 plugin-registry 安装

设置 → 插件 → 安装,source 填 @choi-p/dsh-deepseek-balance 或者 github:Choi-Peng/dsh-deepseek-balance

手动安装

dsh plugin --profile web add "github:Choi-Peng/dsh-deepseek-balance"

插件包自带 cordis.patch.yml(package.json 中的 dsh.bundle.patch),安装时由 dsh 自动应用 —— 无需手改 profile 层的 cordis.patch.yml。重启 dsh web 后生效(插件发现按进程缓存)。

卸载方式:

dsh plugin --profile web remove @choi-p/dsh-deepseek-balance

bundle 挂载随插件移除自动消失;若曾在 profile 层手动写过该行,需先删掉它。

配置

层 · 来源 · 生效方式

默认值 · Config schema 内置(cny,两个阈值均为 0) · —

部署层(bundle base) · 插件自带 cordis.patch.yml 行内 config(dsh.bundle.patch,安装即自动挂载) · 随 bundle 生效

用户层(运行时设置) · 设置 → 插件 → 余额监控 的保存/重置,经 settings 服务写入 profile 的 cordis.patch.yml 中本插件配置行 · 立即生效;恢复默认 = 清空该行的覆盖值,回落到 bundle 默认

生效值 = schema 默认 → bundle base → 用户层,逐层覆盖。

bundle 默认 config:

- insert:
    - id: deepseek-balance
      name: '@choi-p/dsh-deepseek-balance'
      config:
        displayCurrency: cny   # cny = 仅 CNY | usd = 仅 USD | both = 同时显示(默认 cny)
        warningThresholdCny: 0 # CNY 预警阈值(0 = 禁用);低于显示红色,低于其两倍显示黄色
        warningThresholdUsd: 0 # USD 预警阈值(0 = 禁用);低于显示红色,低于其两倍显示黄色

配置页暴露 displayCurrency(仅 CNY / 仅 USD / CNY 和 USD)以及两个告警阈值(数字输入框),并提供

保存 / 恢复默认值;保存采用 revision 乐观并发,若配置已在别处修改会提示并加载最新值;侧边栏余额展示每 60 秒轮询刷新。预警规则:余额 ≤ 阈值显示红色,≤ 阈值的两倍显示黄色,阈值为 0 时不预警。

API 密钥从 DEEPSEEK_API_KEY 环境变量读取;密钥仅由 host 端持有并以 Bearer 方式随请求发送,不会下发到浏览器。

余额 API 会返回账户的全部币种余额(通常为 CNY 与 USD);侧边栏按 displayCurrency 设置显示对应币种。

使用

1. 在环境变量中设置 DEEPSEEK_API_KEY 后启动 dsh web —— 侧边栏底部、Settings 上方会显示余额读数,每 60 秒自动刷新。

2. 设置 → 插件 → 打开 余额监控(@choi-p/dsh-deepseek-balance)包页,插件信息里直接给出「余额监控」设置区:选择要显示的币种并设置预警阈值,然后保存;也可以进入 deepseek-balance 行 → 配置 打开同一个表单。修改立即生效,无需重启 dsh web。

开发

# 校验 host 半部分可被干净地导入(含 Config schema):
node --input-type=module -e "import('./lib/index.js').then(m => console.log(m.name, typeof m.Config.toJSON))"

# 对 client bundle 做语法检查:
node -e "new Function(require('fs').readFileSync('lib/client.js', 'utf8'))"

# 查看 dsh 对本插件配置的校验结果:
dsh web --dump-config-schema | grep -A20 config

License

MIT

Rendered from the README published on npm. Formatted only, not edited.

Versions

Published on npm::9,最后更新 2026-11-04

Links

GitHub · Homepage · npm

Same category