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 和評分是快照中的導航訊號。

安裝與排錯 · 專案問題反饋

同類專案