工具与能力
#dsh-plugin
dsh-usage-plugin
DeepSeek Harness native sidebar usage panel: official balance + token usage history from session logs
lurejewel
@lurejewel
⬇ 2
★ 0
main
安装
dsh plugin --profile web add github:lurejewel/dsh-usage-plugin
需要可复现安装时,可在仓库后追加 #commit 固定提交。
DeepSeek Harness native sidebar usage panel: official balance + token usage history from session logs
该插件未提供要点说明,请参考仓库 README。
dsh-plugin
- 安装并启动 DeepSeek Harness:
npx @deepseek-ai/dsh web - 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
- 用 dsh plugins list 确认已安装,必要时重启 Harness 生效
插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。
| 代码仓库 | github.com/lurejewel/dsh-usage-plugin |
| 许可证 | MIT |
| 主要语言 | main |
| 下载量 | 2 |
| GitHub 星标 | 0 |
| 最近推送 | 2026-08-26 |
| 收录日期 | 2026-09-19 |
| 分类 | 工具与能力 |
事实信息来自公开插件目录快照(2026-10-01),介绍文案由本站再加工。
以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。
# dsh-usage-plugin
[](https://www.npmjs.com/package/dsh-usage-plugin) [](https://www.npmjs.com/package/dsh-usage-plugin) [](LICENSE)
A native sidebar usage panel for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web: shows your **official DeepSeek balance** and **token usage history** (today / last 7 days) right in the sidebar, with no separate process and no cross-origin calls.
A trigger button appears at the bottom of the left sidebar, above Settings — full-width with a label when the sidebar is expanded, a compact icon when collapsed. Click it to open the panel: live balance, today's input / output / cache tokens, and a 7-day trend computed from your own session logs.
## Features
- **Official balance** — live query of `api.deepseek.com/user/balance` using the API key DSH already has (`DEEPSEEK_API_KEY` from your credentials), never stored in the browser.
- **Token usage history** — reads your `$DSH_HOME/sessions` logs and aggregates input / output / cache tokens per day (today, totals, daily average, cache hit rate).
- **Sidebar integration** — registers a `sidebar.footer.action` trigger and a `shell.overlay` modal; layout follows the DSH design tokens (light/dark themes included).
- **Zero footprint** — no daemon, no config, no database; data comes from the same DSH installation you already run.
## Requirements
| Requirement | Version |
|---|---|
| DeepSeek Harness | `>= 0.1.0-rc.7` (tested on `0.1.0-rc.7` and `0.1.1-rc.2`) |
| Node.js | `>= 20` |
| pnpm | `>= 10` (for `dsh plugin` installation) |
| API key | an existing `DEEPSEEK_API_KEY` credential (the one DSH already uses) |
## Installation
From anywhere, run:
```sh
dsh plugin --profile web add dsh-usage-plugin
```
That's it — the package declares a `dsh.bundle` patch, so `dsh plugin` automatically mounts it into the profile layer stack. Then:
1. **Restart** `dsh web` (stop and start the process).
2. **Hard refresh** the browser (`Cmd/Ctrl+Shift+R`).
3. Look for the usage icon at the bottom of the left sidebar.
### Alternatives
- **From GitHub**: `dsh plugin --profile web add github:lurejewel/dsh-usage-plugin`
- **From a release tarball**: `dsh plugin --profile web add https://github.com/lurejewel/dsh-usage-plugin/archive/refs/tags/v0.1.1.tar.gz`
- **From a local checkout** (development): run the same command from inside this repo — `dsh plugin --profile web add .`
- **Manual mount on older setups**: add the row below to `~/.dsh/profiles/web/cordis.patch.yml`, then restart:
```yaml
- insert:
- id: dsh-usage-plugin
name: dsh-usage-plugin
```
### Uninstall
```sh
dsh plugin --profile web remove dsh-usage-plugin
```
Then restart `dsh web`.
## How it works
One package, two halves, mounted as a normal Cordis plugin:
```
lib/index.js Host half: same-origin HTTP routes on the DSH web server
lib/client.js Browser half: __ModuleLoader__ bundle served to the web GUI
lib/usage-history.js Session-log reader (zstd frame scan + per-step dedup + daily aggregation)
```
- `GET /api/dsh-usage/balance` — live official balance (server-side call, key never leaves the server).
- `GET /api/dsh-usage/stats?days=N` — balance + usage history; `N` defaults to 7, clamped to 1–90.
Implementation notes worth knowing:
- DSH session logs (`session.jsonl.zstd`) are **multiple concatenated zstd frames** (one frame per persistence batch); the reader scans frame-by-frame instead of assuming a single frame.
- `assistant/message` and `assistant/chunk` events report the **same usage numbers for the same (turn, step)**; the reader de-duplicates by (turn, step) so totals are not double-counted.
- The API key is resolved through DSH's `credentials` service — the same source the DeepSeek provider uses. Nothing is stored in the browser; all calls are same-origin.
## Privacy & security
- The balance call goes from your **server** to `api.deepseek.com`; the API key never enters the browser.
- The panel only reads your own session logs under `$DSH_HOME/sessions`.
- No telemetry, no third-party network calls.
## Development
```sh
npm test # unit tests (frame scan / decode / dedup / 30-day window)
npm run test:client-boot # boot the real client bundle in Node against mock slots
npm run test:standalone # in-process E2E: real cordis + real API + real logs
# (needs a local DSH install with @deepseek-ai packages
# reachable at $DSH_HOME/profiles/node_modules, a
# DEEPSEEK_API_KEY credential, and session logs)
```
`lib/` is the shipped artifact and doubles as readable source (plain ESM, documented).
### Windows helper scripts (optional)
- `scripts/install-local.ps1` — one-click local install (`dsh plugin --profile web add .`).
- `scripts/restart-web.ps1` — restart `dsh web` and run `scripts/verify-install.mjs`.
- `scripts/verify-install.mjs` — post-restart check: stats/balance routes, client bundle, boot manifest.
## License
[MIT](LICENSE)
数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。