返回目录
消息通讯 插件

dsh-usage-meter

HunterCHCL/dsh-usage-meter

simple usage meter to show how much money is consumed. Supports peak and valley charges

Stars
0
Forks
0
Issues
0
更新
9 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:HunterCHCL/dsh-usage-meter

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-usage-meter

English | 中文

Want to see your account balance? Want to know how much a single sentence costs you, without a pile of analytics features? Want to see how much a price hike hits your wallet? This plugin is for you.

It shows your DeepSeek official API balance and the amount spent in the current session in the top-right corner of the interface; hover over the amount to see the details. The price table and peak/off-peak pricing are configurable on the settings page.

UI language: All UI copy follows the language selected in DSH (中文 / English). Switch it live in DSH Settings → General → Language; when unset, it follows your browser language.

Features

  • Session header indicator:

    • Balance: calls the official DeepSeek GET https://api.deepseek.com/user/balance; hidden for non-official APIs / missing key / failed queries.
    • This session: shows the amount used by the current session (CNY, 2 decimals). Hover for details. UI: image
  • Settings page "Balance / Usage": balance details plus pricing settings:

    • A peak/off-peak pricing toggle. When enabled, every request is priced by the time window it occurred in, giving accurate amounts even when a conversation spans peak and off-peak windows.
    • image (Same conversation as above, but with the peak/off-peak toggle on. Pricing the whole conversation with either the peak or the off-peak rate alone would be wrong, because it spans both windows.)
    • Usage is priced by the window at the time the request occurred; only the official API is supported for now. Unmatched models only show token counts, not amounts.

Default pricing

Defaults follow the official price list (CNY per million tokens; peak windows are Beijing time, Monday to Friday 09:00–12:00 and 14:00–18:00; weekends and configured holidays are off-peak all day):

Model Cache hit (off-peak / peak) Cache miss (off-peak / peak) Output (off-peak / peak)
deepseek-v4.1-flash 0.02 / 0.04 1 / 2 4 / 8
deepseek-v4-pro 0.15 / 0.30 4.5 / 9 13.5 / 27
  • With peak pricing off, the off-peak (standard) prices are used for every request.
  • The plugin groups models as deepseek-v4.1-flash and deepseek-v4-pro; session logs using the official ids deepseek-flash, deepseek-v4-flash (and the retired vision id) are priced as Flash.
  • Public holidays can be listed on the settings page (one YYYY-MM-DD per line); those days are off-peak all day, and weekends are always off-peak.

Upgrading from an older version

The first time the Balance / Usage settings page opens after an upgrade, it detects the older stored pricing (whose defaults differ from the current official prices) and asks whether to migrate to the new defaults or keep the current configuration. Migrating replaces the price tables with the new defaults while keeping your peak toggle, windows, and holiday list; keeping retains the current values under the new model names. Either choice is recorded with the pricing version, so the prompt appears once.

Layout

dsh-usage-meter/
  package.json     plugin package declaration
  cordis.patch.yml bundle patch: mounts this plugin as a Cordis host plugin
  host.js          host ESM: TypertRemoteService RPC (balance/usage/pricing)
  client.js        client static module: header pill + settings page (bilingual, follows DSH language)
  install.ps1      one-click install
  uninstall.ps1    one-click uninstall
  README.md        English docs
  README.zh.md     Chinese docs

Install

1. Direct install:

Clone this repo locally, then run its install.ps1:

cd <plugin directory>
powershell -ExecutionPolicy Bypass -File .\install.ps1

The script installs into the profile you are running ($env:DSH_PROFILE, e.g. desktop for the Desktop app or web for dsh web), or the only profile found under $DSH_HOME\profiles.

2. Install via npm:

Run in PowerShell:

dsh plugin --profile web add @hunterchcl/dsh-usage-meter

Requires pnpm and dsh to be installed. Use the profile you actually run (web, desktop, tui). The Desktop app manages its desktop profile itself, so install there through Settings → Plugins → Add plugin instead of the CLI.

3. Local directory / development copy:

Do not install a raw directory link: a linked checkout sits outside the profile, so the Host half cannot resolve the DSH packages it imports (@deepseek-ai/*) and fails with ERR_MODULE_NOT_FOUND for @deepseek-ai/dsh-typert-protocol. Pack a tarball and install that instead:

pnpm pack --pack-destination dist
dsh plugin --profile web add .\dist\dsh-usage-meter-<version>.tgz

On Desktop, install the packed tarball through Settings → Plugins → Add plugin, and restart DSH after replacing the package so the new Host module generation loads.

Uninstall

Run uninstall.ps1:

powershell -ExecutionPolicy Bypass -File .\uninstall.ps1            # keep local data
powershell -ExecutionPolicy Bypass -File .\uninstall.ps1 -RemoveData # also delete usage/pricing data

Or via pnpm:

dsh plugin --profile web remove @hunterchcl/dsh-usage-meter

Notes & Limitations

  • Requires DSH 0.2.x. From DSH 0.2 on, every client Remote descriptor must carry a strict codec with a create() factory; 1.2.3 adds it, so the plugin mounts again instead of silently failing to register its UI slots.
  • Usage is a local estimate (based on persisted usage records in the DSH session event log: assistant/chunk and assistant/message), for reference only — not a platform bill; the DeepSeek Open Platform is authoritative.
  • Opening a session computes its full historical usage (including records from before this plugin was installed), priced by the peak/off-peak window at the time each request occurred. Peak applies only on Beijing-time weekdays (and not on listed holidays); weekends are off-peak.
  • If you later run pnpm install manually in the profile directory, it may clean up local plugin directories not declared in dependencies; if that happens, re-run install.ps1.
  • This project is open source under the MIT license. You may freely distribute and modify it, but must retain the original copyright and license text.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类消息通讯
规则置信度低

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: im。