dsh-usage
DSH 插件:统计今日(或指定日期)token 用量与费用,按模型价格与峰谷计费(DeepSeek 峰谷定价);Web 侧栏显示今日费用面板
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗dsh-usage
DSH plugin — today's token usage & cost, priced per model with DeepSeek peak/off-peak (峰谷) billing. Ships a Web sidebar panel (above Settings) plus a
/usagecommand.DSH 插件 — 统计今日(或指定日期)的 token 用量与费用,按模型价格与峰谷计费(DeepSeek 官方峰谷定价)计算。含 Web 左侧栏「今日费用」面板(设置按钮上方)与
/usage命令两种使用方式。
Features / 功能
English
- Scans every session log under
$DSH_HOME/sessions(default~/.dsh/sessions, JSONL / zstd compressed) and folds each model call's usage:- input · cache miss (
inputTokens) - input · cache hit (
cacheReadTokens) - output (
outputTokens; reasoning tokens are part of output and are not billed again)
- input · cache miss (
- Prices per model and splits billing by peak / off-peak windows (DeepSeek peak/valley pricing effective 2026-08-17):
- Peak hours (Beijing time): 09:00–12:00, 14:00–18:00
- Off-peak: all other hours, at half price
- Web sidebar panel: registers the
usageTodaysession projection unit, so each session's "today" usage & cost ridessession.list/session.historyprojectionsto the browser. The client plugin renders a "今日费用" card at the bottom of the sidebar (above the Settings row), aggregated across sessions, auto-refreshing every 20 s (click to refresh). A compact ¥ icon shows when the sidebar is collapsed. - Registers the
/usagecommand (no model turn involved — costs zero tokens).
中文
- 扫描
$DSH_HOME/sessions(默认~/.dsh/sessions)下所有会话日志(JSONL / zstd 压缩),折叠每次模型调用的用量:- 输入 · 缓存未命中(
inputTokens) - 输入 · 缓存命中(
cacheReadTokens) - 输出(
outputTokens,含 reasoning tokens,不再重复计费)
- 输入 · 缓存未命中(
- 按模型归集,并按高峰 / 空闲时段分开计费(DeepSeek 峰谷定价自 2026-08-17 起生效):
- 高峰时段(北京时间):09:00–12:00、14:00–18:00
- 空闲时段:其余时间,价格为高峰的一半
- Web 侧栏面板:注册
usageToday会话投影单元,每个会话「今日」的用量与费用随session.list/session.history的projections下发到浏览器;client 插件在侧栏底部(设置按钮上方)渲染「今日费用」卡片,跨会话汇总、每 20 秒自动刷新,点击可手动刷新。侧栏折叠时显示紧凑的 ¥ 图标。 - 注册
/usage命令(Web 端直接输入),无需模型参与,不消耗 token。
Install / 安装
English
Install into the DSH web profile:
# copy (or symlink) this package to ~/.dsh/profiles/node_modules/dsh-usage/
# 将本包复制(或软链)到 ~/.dsh/profiles/node_modules/dsh-usage/
## Usage / 使用
### Sidebar panel / 侧栏面板
**English**
Bottom-left, above the Settings row:
今日费用 08-17 ¥10.72 空闲 ¥3.22 · 高峰 ¥7.51 输入 327K · 输出 389K
Auto-refreshes every 20 s (data comes from the host-side projection, including cold sessions); click the card to refresh immediately.
**中文**
左下角(设置上方)显示:
今日费用 08-17 ¥10.72 空闲 ¥3.22 · 高峰 ¥7.51 输入 327K · 输出 389K
每 20 秒自动刷新(数据来自宿主端投影,含冷会话);点击卡片立即刷新。
### `/usage` command / 命令
| Command / 命令 | Meaning / 说明 |
|---|---|
| `/usage` | Today (Beijing time) usage & cost / 今日(北京时) |
| `/usage today` | same / 同上 |
| `/usage yesterday` | Yesterday / 昨日 |
| `/usage 2026-08-17` | A specific date / 指定日期 |
| `/usage all` | All history / 全部历史 |
Example output / 示例输出:
📊 DSH Token 用量与费用 统计范围:2026-08-17(Asia/Shanghai,今日) 峰谷计费:高峰 09:00–12:00、14:00–18:00;其余为空闲时段(半价) 会话日志:扫描 2 个,其中 2 个含用量事件
模型/时段 输入未命中 输入命中 输出 费用(CNY) deepseek-v4-flash 空闲(半价) 80,554 26,083,968 108,070 1.91 高峰 179,462 51,227,648 205,075 7.51 小计 260,016 77,311,616 313,145 9.42
合计(今日) ¥9.42 空闲 ¥1.91 · 高峰 ¥7.51
---
### `/usage` command / 命令
| Command / 命令 | Meaning / 说明 |
|---|---|
| `/usage` | Today (Beijing time) usage & cost / 今日(北京时) |
| `/usage today` | same / 同上 |
| `/usage yesterday` | Yesterday / 昨日 |
| `/usage 2026-08-17` | A specific date / 指定日期 |
| `/usage all` | All history / 全部历史 |
Example output / 示例输出:
📊 DSH Token 用量与费用 统计范围:2026-08-17(Asia/Shanghai,今日) 峰谷计费:高峰 09:00–12:00、14:00–18:00;其余为空闲时段(半价) 会话日志:扫描 2 个,其中 2 个含用量事件
模型/时段 输入未命中 输入命中 输出 费用(CNY) deepseek-v4-flash 空闲(半价) 80,554 26,083,968 108,070 1.91 高峰 179,462 51,227,648 205,075 7.51 小计 260,016 77,311,616 313,145 9.42
合计(今日) ¥9.42 空闲 ¥1.91 · 高峰 ¥7.51
---
## Configuration / 配置
All keys are optional; defaults match the official DeepSeek peak/valley pricing (effective 2026-08-17):
| Key / 键 | Type / 类型 | Default / 默认值 | Description / 说明 |
|---|---|---|---|
| `timezone` | `string` | `'Asia/Shanghai'` | Billing timezone (peak hours are Beijing time) / 计费时区(峰谷以北京时间为准) |
| `peakHours` | `[number, number][]` | `[[9,12],[14,18]]` | Peak windows (whole hours, `[start, end)`) / 高峰时段(整点、左闭右开) |
| `priceTable` | `object` | see below / 见下 | Model prices, CNY per million tokens / 模型价格表,元/百万 tokens |
| `sessionsRoot` | `string \| null` | `$DSH_HOME/sessions` | Session log root / 会话日志根目录 |
| `includeWorkspaces` | `'all' \| 'current' \| string[]` | `'all'` | Which workspaces to count (`'current'` = only the current cwd; array = cwd prefix match) / 统计哪些工作区(`'current'` 仅当前 cwd;数组按 cwd 前缀匹配) |
Default price table (CNY per million tokens, `[off-peak, peak]`):
```yaml
priceTable:
deepseek-v4-flash:
inputCacheHit: [0.05, 0.1] # input · cache hit / 输入 · 缓存命中
inputCacheMiss: [1.5, 3.0] # input · cache miss / 输入 · 缓存未命中
output: [4.5, 9.0] # output / 输出
deepseek-v4-pro:
inputCacheHit: [0.15, 0.3]
inputCacheMiss: [4.5, 9.0]
output: [13.5, 27.0]
Prices can change — always check the official DeepSeek pricing page. Override per model via
config.priceTable. Models not in the table still count tokens but are marked unpriced in reports.价格可能变动,请以 DeepSeek API 官方定价页 为准;在
config.priceTable中按模型名覆盖即可。未在表中配置的模型会照常统计 token,费用标记为未计费,并在报告中提示。