bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
Token 注意力管理面板:按任务/日/周/月记录 token 消耗与费用(命中/未命中/输出/推理四桶),支持 DeepSeek 峰谷计价与任务类型识别,并给出换对话、写 hand-off、压缩上下文的建议。
English | 中文说明
Token Check is a token-attention management panel for DeepSeek Harness (DSH). It records every conversation's token usage and estimated cost by task / day / week / month, recognizes task types, and — combined with DeepSeek's peak/off-peak pricing and DSH's context mechanics — tells you when to run a task, whether to switch sessions, and whether to write a hand-off file.
It is not a money-saving tool: it never throttles or cancels requests. It presents facts and advice; you decide.
node:sqlite; no network callsOverview — today's usage, cost, hit rate, attention score, model mix, advice card, and trend
Session card — per-session model breakdown and attention metrics
Tasks — task ledger with Markdown / CSV export
Cost — peak split, cost leverage breakdown, and model comparison
Settings — pricing table, peak hours, and advice thresholds
Once published to npm:
dsh plugin --profile web add dsh-token-attention
Restart DSH, then open Settings → 词元管理 (Token Check). Data is stored at DSH_HOME/token-attention/token_records.db.
npm install && npm run build
Then register the plugin in the web profile (%APPDATA%\dsh-desktop\harness\profiles\web\package.json):
{
"dependencies": { "dsh-token-attention": "link:/path/to/dsh-token-attention" },
"dsh": { "profile": { "bundles": ["...", "dsh-token-attention"] } }
}
Run pnpm install inside profiles\web, restart DSH, and verify:
curl http://127.0.0.1:<port>/token-attention/api/health # → {"ok":true,...}
session/event stream (usage, goal, subagent, compaction, turn) and writes normalized records to SQLite; a startup backfill replays existing sessions with an idempotent last_seq cursor.daily_agg, with a daily full rebuild for correction.session-projection + token-meter + session-stats, the session card reads context occupancy from contextPressure.projectedTokens (compaction-reactive, official capacity) and turn/step/LLM/tool/decode stats from sessionStats (same source as DSH's built-in stats bar); it falls back to its own computation when those units are absent — no extra dependencies.src/shared/advice.ts evaluates context occupancy, turns, hit rate, cost and model mix against your thresholds and suggests concrete actions.Settings are editable in the panel and saved to SQLite:
| Setting | Default |
|---|---|
| Model pricing (¥ / million tokens, off-peak) | flash: hit 0.05 / miss 1.5 / output 4.5 |
| Peak hours (24h, start-inclusive) | 9–12, 14–18 |
| Context-occupancy advice threshold | 70% |
| Turn-count advice threshold | 40 |
| Hit-rate advice threshold | 40% |
npm run typecheck # tsc --noEmit
npm run check # node --check src/client/index.js
npm run build # tsc → dist/
npm run selftest # collection-layer self-test (idempotency / peak pricing / aggregation assertions)
npm pack # build the publish tarball
Uninstall in DSH Settings → Plugins, or remove the dependency and the bundles entry from the profile's package.json. The data directory DSH_HOME\token-attention\ can be deleted manually; dispose cleans up timers and the SQLite connection.
MIT © 2026 Young4ever33