bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
持久化 provider 上报的 Token 用量统计,支持按会话、按模型和按日活跃度查看。
Persistent provider-reported token usage statistics for DeepSeek Harness. The plugin keeps uncached input, cache read, cache write, and output usage in separate buckets, and exposes cumulative, daily, per-session, and per-model views.
| Capability | Description |
|---|---|
| Accurate buckets | Keeps the four provider-reported usage buckets separate. |
| Persistent totals | Stores data in the plugin-owned DSH storage domain. |
| Multiple views | Provides global, session, and provider/model summaries. |
| Daily activity | Tracks local-day token totals and call counts. |
| Built-in settings page | Ships its own Web settings view and heatmap. |
| Safe commits | Counts usage only after a successful completion anchor. |
| Interactive command | Registers /tokens when the commands service is mounted. |
To install this 0.5.0 source before an npm release, replace COMMIT with the full 40-character commit of the reviewed revision:
dsh plugin --profile web add -w github:Mu-scorpio/token-usage-counter#COMMIT
The npm command installs the latest independently published version, which may differ from this checkout:
dsh plugin --profile web add -w dsh-token-usage-counter
dsh web
The Bundle is additive: it mounts only the plugin-owned token-usage-counter entry and leaves the built-in usage accumulator and page enabled.
Version 0.4.0 moves persistence from the shared usage-stats namespace to the plugin-owned dsh-token-usage-counter namespace. Existing 0.3.x totals are not silently migrated because the shared namespace belongs to the built-in plugin; the new counter starts with an independent snapshot after the upgrade.
Version 0.5.0 uses DSH's public storage-domain service for persistent data in
dsh_token_usage_counter, and serves a read-only aggregate snapshot to its
settings page through the existing DSH browser authentication. It does not
write statistics into Profile configuration forms. Legacy plugin-owned
settings data is not copied automatically; persisted session history can
rebuild the counter where the DSH session store still retains that history.
See SECURITY.md for permissions and evidence limits.
From this checkout:
dsh web --patch ./cordis.yml
The local overlay mounts src/index.ts without replacing built-in components. For a manual composition, add only the plugin-owned entry:
- insert:
- id: token-usage-counter
name: './src/index.ts'
Store listing migration details: docs/STORE-REMEDIATION.md.
npm install --ignore-scripts --legacy-peer-deps --no-package-lock
npm run build
npm run verify
Run a packed Bundle against an independently installed official DSH CLI:
npm run test:disposable -- /path/to/dsh/lib/bin.js /path/to/plugin.tgz
The generated host and client bundles are committed under lib.
The plugin listens to the durable session event stream:
The plugin provides ctx.tokenUsageCounter:
ctx.tokenUsageCounter.getSummary()
ctx.tokenUsageCounter.getSession(sessionId)
ctx.tokenUsageCounter.getModel(provider, model)
ctx.tokenUsageCounter.formatSummary()
MIT