DeepSHPlugins
dsh-plugin-ds-balance 项目预览
GITHUB / COMMUNITY PROJECT

dsh-plugin-ds-balance

安全与运维JavaScriptMIT

DeepSeek 余额与逐次调用成本追踪:基于真实 usage 的持久化成本账本,支持官方高峰/低谷定价(北京时间 2),60 秒余额轮询,侧栏底部显示余额与今日消耗。

1 StarsstoryOuO 更新时间 2026-08-26
访问 GitHub 仓库
dsh-plugin-ds-balance 项目预览

项目介绍

中文

DeepSeek 余额与逐次调用成本追踪:基于真实 usage 的持久化成本账本,支持官方高峰/低谷定价(北京时间 2),60 秒余额轮询,侧栏底部显示余额与今日消耗。

English

DeepSeek API balance + per-call cost tracker: durable per-call cost ledger from real usage chunks with official Beijing peak/off-peak (x2) pricing, 60 s balance polling, and a sidebar footer action showing balance and today's spend.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
storyOuO
仓库
storyOuO/dsh-plugin-ds-balance
GitHub Stars
1
Forks
0
开发语言
JavaScript
许可证
MIT
最近推送
2026-08-26
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

53/ 100
维护活跃
90
文档与实用信息
100
生态关注度
9
安装便捷信号
80
项目声明信号
85

近 16 天仍在更新;README 含完整安装与使用说明;关注度尚低(1)。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add github:storyOuO/dsh-plugin-ds-balance

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

ds-balance

A dsh plugin that tracks your DeepSeek API balance and per-call cost live in the sidebar.

It is a dual-face ("双面") dsh plugin built on the standard Cordis extension mechanism — no private dsh APIs:

  • Host half (lib/index.js, Node) wraps the llm/stream waterfall, prices

every successful DeepSeek call from the provider-reported usage chunk into a durable per-call ledger, polls the official balance endpoint, and exposes a JSON snapshot route /api/ds-balance.

  • Client half (lib/client.js, browser) injects an action into the

sidebar.footer.action slot showing balance + today's spend (30 s polling).

Content is DeepSeek-specific: only the deepseek-official provider is priced,
and the balance endpoint / response shape (balance_infos, total_balance)
are DeepSeek's. The mechanism is generic and works in any dsh profile
(dsh web, headless, or this desktop shell).

Features

  • Per-call cost ledger from real usage chunks (durable, JSON under the dsh home).
  • Daily rollover at the host machine's local midnight, with archived

per-day history.

  • DeepSeek official balance polling (every 60 s) with .bak recovery so a torn

write can never wipe the ledger.

  • Peak pricing: off-peak buckets billed ×2 during Beijing peak windows

(Mon–Fri 09:00–12:00 and 14:00–18:00, UTC+8, no DST).

  • Per-model pricing overrides via the loader entry config.

Install

The package declares dsh.bundle, so it installs through the official plugin path (recommended):

npm install ds-balance
dsh plugin --profile web add ds-balance

It can also be wired by name in the profile's cordis.patch.yml (see cordis.patch.yml.example) — the bundle install and the patch wiring are equivalent, and both keep the package resolvable by the bare name ds-balance:

- insert:
    - id: ds-balance
      name: 'ds-balance'
      config:
        pricing:
          deepseek-v4-pro:
            input: 2.0
            cacheRead: 0.5
            cacheWrite: 2.0
            output: 8.0

config.pricing.<model> overrides the default off-peak CNY-per-1M-token buckets. cacheWrite defaults to input when omitted.

Data & troubleshooting

The durable ledger lives at $DSH_HOME/storages/ds-balance.json (default ~/.dsh/storages/ds-balance.json). Each successful DeepSeek call appends one ledger entry; the whole file is replaced atomically and the previous good snapshot is rotated to ds-balance.json.bak, so a torn write can never wipe the history — the plugin falls back to the backup automatically.

SymptomCause / fix
Sidebar shows -- for balanceNo DEEPSEEK_API_KEY in the environment or in $DSH_HOME/.credentials.yaml (refs.DEEPSEEK_API_KEY); the host records balanceError: "no DEEPSEEK_API_KEY".
Balance never refreshesThe balance poll hits api.deepseek.com directly; check your network / proxy. balanceError carries the last failure and the snapshot is marked stale.
Today's spend looks wrongPeak windows bill ×2 (Mon–Fri 09:00–12:00 / 14:00–18:00 Beijing time); check the call time and your per-model config.pricing overrides.
Want a fresh startStop dsh, delete ds-balance.json (and its .bak), restart. History since the last midnight is lost; today's counters reset.

Test

The verification script exercises the host half (pricing, ledger, credentials key resolution, daily history, .bak recovery) with a mocked cordis ctx — no network, no absolute paths:

npm test

License

MIT

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目