qwert702/dsh-token-viewer 预览 preview

qwert702/dsh-token-viewer

插件Plugin ⭐ 6 MIT datatoolsweb-ui

Developer tool: live token usage & cost monitoring for DeepSeek Harness - consumed tokens for the current session and across all sessions, read from token-meter projections. No model calls.

编辑导读Editor's Brief

## 核心特性
- TokenDock 在输入框上方条带中显示当前会话的计费输入、输出、缓存命中率和近似上下文占用。
- 侧边栏卡片显示 DeepSeek 账户余额,支持刷新和错误重试,并展示所有会话的总消耗以及可展开的按会话列表。
- 使用统计面板展示来自宿主 usageLog 投影的按请求记录,包括提交时间、模型和四个 token 桶。
- 该面板包含实际消耗总量、请求数、总成本、五张卡片的分项统计、缓存命中率进度条、趋势图、请求日志、按项目统计、按模型统计和范围预设。
- 价格按每 1M tokens 的模型人民币标价计算,区分北京高峰与低谷时段,并对未知模型回退到 V4-Flash 低谷价格。

## 使用场景
- 监控单个 DeepSeek Harness Web 会话的 token 消耗和缓存行为。
- 查看今日、7 天、14 天、30 天或全部时间范围内的历史请求量、成本和 token 趋势。
- 按项目或模型比较消耗,同时检查按请求日志条目。
- 在不向浏览器暴露 API key 的情况下查看 DeepSeek 账户余额。

## 技术细节
- 宿主端位于 lib/index.js,提供 balance 路由以及 modelUsage 和 usageLog 会话投影。
- 浏览器端是 lib/client.js 中的构建产物,并通过 package.json 的 dsh.client 字段发现。
- balance 端点 GET /api/billing/balance 通过 Harness 凭据服务代理 DeepSeek /user/balance,将 API key 保留在服务端。
- 客户端构建脚本通过 vendor 方式引入已安装的 @deepseek-ai/dsh-client-ui-sidebar 包重新生成 lib/client.js,可使用 DSH_SIDEBAR_BUNDLE 或探测 ~/.dsh/profiles。

## 注意事项
- 该插件为只读,不添加提示词内容、工具或 provider 请求。
- 价格数据可来自 GET /api/billing/pricing,或在提供方页面不可达时使用内置 MODEL_PRICING 表。
- 安装需要执行 dsh plugin add qwert702/dsh-token-viewer,重启 harness,并在打开侧边栏 token 用量卡片前刷新网页。

## Core Features
- 3-5 bullets, each grounded.
## Use Cases
- 2-4 typical use cases (only if categories exist) categories data, tools, web-ui exist.
## Technical Details
- 2-4 key implementation points (language, protocol, integration)
## Notes
- 1-3 objective caveats.

Need no H3/H4, no nesting. Use - bullets one sentence each. Need English only. Need word count 250-450 excluding headings. Let's draft around 300 words.

Potential bullets:
Core Features:
- TokenDock displays current-session billed input, output, cache hit rate, and approximate context occupancy in a strip above the composer.
- The sidebar card shows DeepSeek account balance with refresh and error retry, plus aggregate consumption across all sessions and an expandable per-conversation list.
- The usage statistics panel presents per-request records from the host usageLog projection, including commit time, model, and four token buckets.
- The panel includes real consumption totals, request count, total cost, a five-card breakdown, a cache-hit-rate progress bar, trend charts, request log, per-project statistics, and per-model statistics.
- Pricing applies per-model list prices in CNY per 1M tokens, separates Beijing peak and off-peak windows, and falls back to V4-Flash off-peak pricing for unknown models.

Use Cases:
- Monitoring token consumption and cache behavior for individual DeepSeek Harness web sessions.
- Reviewing historical request volume, cost, and token trends across today, 7-day, 14-day, 30-day, or all-time ranges.
- Comparing consumption by project or model while inspecting per-request log entries.
- Checking DeepSeek account balance without exposing the API key to the browser.

Technical Details:
- The host half in lib/index.js provides a balance route and modelUsage and usageLog session projections.
- The browser half is a built bundle in lib/client.js and is discovered through package.json dsh.client.
- The balance endpoint GET /api/billing/balance proxies DeepSeek /user/balance through the harness credentials service.
- The client build script regenerates lib/client.js by vendoring the installed @deepseek-ai/dsh-client-ui-sidebar bundle, using DSH_SIDEBAR_BUNDLE or probing ~/.dsh/profiles.

Notes:
- The plugin is read-only and adds no prompt content, tools, or provider requests.
- Pricing prefers GET /api/billing/pricing when reachable and otherwise uses the built-in MODEL_PRICING table.
- Installation requires dsh plugin add qwert702/dsh-token-viewer, a harness restart, and a web page refresh before opening Token 消耗 in the sidebar.

Need word count. Let's count roughly.
Core Features:
1 TokenDock(1) displays2 current-session3 billed4 input,5 output,6 cache7 hit8 rate,9 and10 approximate11 context12 occupancy13 in14 a15 strip16 above17 the18 composer19. =19
2 The1 sidebar2 card3 shows4 DeepSeek5 account6 balance7 with8 refresh9 and10 error11 retry,12 plus13 aggregate14 consumption15 across16 all17 sessions18 and19 an20 expandable21 per-conversation22 list23. =23
3 The1 usage2 statistics3 panel4 presents5 per-request6 records7 from8 the9 host10 usageLog11 projection,12 including13 commit14 time,15 model,16 and17 four18 token19 buckets20. =20
4 The1 panel2 includes3 real4 consumption5 totals,6 request7 count,8 total9 cost,10 a11 five-card12 breakdown,13 a14 cache-hit-rate15 progress16 bar,17 trend18 charts,19 request20 log,21 per-project22 statistics,23 and24 per-model25 statistics26. =26
5 Pricing1 applies2 per-model3 list4 prices5 in6 CNY7 per8 1M9 tokens,10 separates11 Beijing12 peak13 and14 off-peak15 windows,16 and17 falls18 back19 to20 V4-Flash21 off-peak22 pricing23 for24 unknown25 models26. =26
Core total 114.

Use Cases:
1 Monitoring1 token2 consumption3 and4 cache5 behavior6 for7 individual8 DeepSeek9 Harness10 web11 sessions12. =12
2 Reviewing1 historical2 request3 volume,4 cost,5 and6 token7 trends8 across9 today,10 7-day,11 14-day,12 30-day,13 or14 all-time15 ranges16. =16
3 Comparing1 consumption2 by3 project4 or5 model6 while7 inspecting8 per-request9 log10 entries11. =11
4 Checking1 DeepSeek2 account3 balance4 without5 exposing6 the7 API8 key9 to10 the11 browser12. =12
Use total 51. Running 165.

Technical:
1 The1 host2 half3 in4 lib/index.js5 provides6 a7 balance8 route9 and10 modelUsage11 and12 usageLog13 session14 projections15. =15
2 The1 browser2 half3 is4 a5 built6 bundle7 in8 lib/client.js9 and10 is11 discovered12 through13 package.json14 dsh.client15. =15
3 The1 balance2 endpoint3 GET4 /api/billing/balance5 proxies6 DeepSeek7 /user/balance8 through9 the10 harness11 credentials12 service13. =13 maybe GET and path count? fine.
4 The1 client2 build3 script4 regenerates5 lib/client.js6 by7 vendoring8 the9 installed10 @deepseek-ai/dsh-client-ui-sidebar11 bundle,12 using13 DSH_SIDEBAR_BUNDLE14 or15 probing16 ~/.dsh/profiles17. =17
Tech total 60. Running 225.

Notes:
1 The1 plugin2 is3 read-only4 and5 adds6 no7 prompt8 content,9 tools,10 or11 provider12 requests13. =13
2 Pricing1 prefers2 GET3 /api/billing/pricing4 when5 reachable6 and7 otherwise8 uses9 the10 built-in11 MODEL_PRICING12 table13. =13
3 Installation1 requires2 dsh3 plugin4 add5 qwert702/dsh-token-viewer,6 a7 harness8 restart,9 and10 a11 web12 page13 refresh14 before15 opening16 Token17 消耗18 in19 the20 sidebar21. =21 (Chinese token maybe counts? English only? The README includes Token 消耗. User says English only. Should we avoid Chinese? Could say its sidebar card? But install instruction says open Token 消耗. Since output English only maybe avoid Chinese characters. Use "the Token consumption card"? But exact? Need claims. Could say before opening the sidebar card. Word count: Installation requires dsh plugin add qwert702/dsh-token-viewer, a harness restart, and a web page refresh before opening the sidebar usage card. Count 20. Notes total 46. Total 271. Good.

Need ensure no first person, no praise. Good.
Need maybe categories use cases only if categories exist yes.
Need one sentence each. Yes.
Need no nesting. Good.
Need 250-450 words total not counting headings. 271 okay. But need be careful word count with hyphenated? It's okay. Could be under 250 if counting differs? Let's expand slightly to be safe around 300. Add maybe core feature about range presets? Already in use cases. Could add technical smoke test? Need 2-4 technical points, already 4. Could add notes about TypeScript monorepo source on archive branch? Caveat? Could add note: The TypeScript monorepo source extracted from deepseek-ai/deepseek-harness lives on archive/monorepo-src branch. That's objective. Notes max 3, currently 3. Could replace installation note? Need caveats dependencies limitations. Installation is not caveat maybe. But okay. Could include dependency on harness credentials service? Already technical. Need notes limitations: read-only, pricing fallback, install steps. Fine.

Need ensure "English only" no Chinese. Removed Token 消耗. But README fact includes Chinese card. We can say sidebar usage card.

Need maybe "CC Switch-style"? Could mention faithful port? But no comparison? The rules no comparison? It says objective no comparison. Avoid CC Switch? README mentions. Could mention usage-dashboard method? Might be comparison? Better not. Core features without CC Switch. Range presets resolved like CC Switch? We can say range presets today/7d... without CC Switch. Use cases includes ranges.

Need maybe "provider list price" and peak windows. Good.

Need exact headings. Output only markdown section starting ## Core Features.

Double-check no empty praise: "slim" in README? We didn't use. "faithful" avoided. Good.

Need maybe "billed input (uncached + cache read + cache write)"? We said billed input, output. Could be less detailed. Fine.

Need ensure each bullet one sentence. No semicolon? okay. Each ends period. Bullet with comma okay.

Potential issue: "GET /api/billing/balance" maybe token count but fine. "1M" maybe word. Word count likely >250.

Let's maybe add a couple words to be safe. Core bullet 4: add "range presets"? But already long. Could add Use Cases another? max 4. Technical maybe add smoke test? max 4. Notes max 3. We can expand existing bullets slightly.

Current total 271. If word count excludes punctuation and code tokens? Still likely >250. But to be safe add 30 words. Maybe Core bullet 2 add "and error retry when the host proxy fails" already. Good.
Core bullet 4 add "with hourly or daily trend buckets" maybe. But trend chart details. Let's modify:
"The panel includes real consumption totals, request count, total cost, a five-card breakdown, a cache-hit-rate progress bar, trend charts, request log, per-project statistics, and per-model statistics." 26. Add "range presets" maybe +2. "and range presets" = 28. But range presets in use cases. Could be okay.
Technical bullet 3: "The balance endpoint GET /api/billing/balance proxies DeepSeek /user/balance through the harness credentials service, keeping the API key on the server." Adds 6. Good.
Notes bullet 3: include exact "Token consumption card"? English. "Installation requires dsh plugin add qwert702/dsh-token-viewer, a harness restart, and a web page refresh before opening the sidebar token usage card." Count maybe 22.

Let's recalc with modifications:
Core bullet 4 add "range presets" -> 28. Core total 116.
Tech bullet 3: The1 balance2 endpoint3 GET4 /api/billing/balance5 proxies6 DeepSeek7 /user/balance8 through9 the10 harness11 credentials12 service,13 keeping14 the15 API16 key17 on18 the19 server20. =20 instead of 13 +7 => tech total 67.
Notes bullet 3: Installation1 requires2 dsh3 plugin4 add5 qwert702/dsh-token-viewer,6 a7 harness8 restart,9 and10 a11 web12 page13 refresh14 before15 opening16 the17 sidebar18 token19 usage20 card21. =21 vs 20. Notes total 47.
Total 116+51+67+47=281. Good.

Need maybe "Use Cases" typical only if categories exist. Good.

Check no H3/H4. Good.

Need maybe license? Not required. Could mention MIT? Not in structure? Could technical? But not implementation. Drop.

Need maybe stars? no.

Potential issue: "provider requests" in notes: The plugin adds no prompt content, tools, or provider requests. README says read-only surfaces over host-computed projections plus one balance read; plugin adds no prompt content, tools, or provider requests. Good.

Potential issue: "Pricing prefers GET /api/billing/pricing when reachable and otherwise uses built-in MODEL_PRICING table." README says panel fetches pricing and prefers provider official page when reachable, falling back built-in table. Actually "prefers the provider's official page when reachable" not GET /api/billing/pricing? It says panel also fetches GET /api/billing/pricing and prefers provider's official page when reachable, falling back. Hmm our note may be slightly inaccurate: It fetches GET /api/billing/pricing and prefers provider's official page when reachable? Wait: "the panel also fetches GET /api/billing/pricing and prefers the provider's official page when reachable, falling back to the built-in table otherwise." This is ambiguous: pricing route maybe returns official page? Better to phrase: "Pricing can be fetched from GET /api/billing/pricing, with fallback to the built-in MODEL_PRICING table." But need strict. README: holds current list prices; panel also fetches GET /api/billing/pricing and prefers provider's official page when reachable, falling back to built-in table. Could note: "Pricing data may come from GET /api/billing/pricing or the built-in MODEL_PRICING table when the provider page is unreachable." That's grounded. Let's adjust note 2:
"Pricing data may come from GET /api/billing/pricing or the built-in MODEL_PRICING table when the provider page is unreachable." Count: Pricing1 data2 may3 come4 from5 GET6 /api/billing/pricing7 or8 the9 built-in10 MODEL_PRICING11 table12 when13 the14 provider15 page16 is17 unreachable18. =18 vs 13 +5. Total 286. Good.

Need maybe "provider page" is official page. Good.

Potential issue: "Use Cases: Checking DeepSeek account balance without exposing API key to browser" grounded: API key never leaves server. Good.

Potential issue: Technical bullet 1: "host half in lib/index.js provides balance route + modelUsage / usageLog session projections, ready to load." Good.

Potential issue: Technical bullet 2: "browser half is a built bundle in lib/client.js and is discovered through package.json dsh.client." Good.

Potential issue: Technical bullet 4: "client build script regenerates lib/client.js by vendoring installed @deepseek-ai/dsh-client-ui-sidebar bundle, using DSH_SIDEBAR_BUNDLE or probing ~/.dsh/profiles." Good.

Need maybe no code formatting? Markdown bullets can include code? It says use - bullets. Could include backticks? It's okay but maybe not necessary. Use plain text to avoid word count? Backticks not matter. But maybe avoid backticks? It's markdown. Use lib/index.js? It's okay. But one sentence. Could keep without backticks to be simple. But code names okay.

Need ensure output only markdown section, no preamble. Final should be exactly headings and bullets.

Let's prepare final:
## Core Features
- TokenDock displays current-session billed input, output, cache hit rate, and approximate context occupancy in a strip above the composer.
- The sidebar card shows DeepSeek account balance with refresh and error retry, plus aggregate consumption across all sessions and an expandable per-conversation list.
- The usage statistics panel presents per-request records from the host usageLog projection, including commit time, model, and four token buckets.
- The panel includes real consumption totals, request count, total cost, a five-card breakdown, a cache-hit-rate progress bar, trend charts, request log, per-project statistics, per-model statistics, and range presets.
- Pricing applies per-model list prices in CNY per 1M tokens, separates Beijing peak and off-peak windows, and falls back to V4-Flash off-peak pricing for unknown models.
## Use Cases
- Monitoring token consumption and cache behavior for individual DeepSeek Harness web sessions.
- Reviewing historical request volume, cost, and token trends across today, 7-day, 14-day, 30-day, or all-time ranges.
- Comparing consumption by project or model while inspecting per-request log entries.
- Checking DeepSeek account balance without exposing the API key to the browser.
## Technical Details
- The host half in lib/index.js provides a balance route and modelUsage and usageLog session projections.
- The browser half is a built bundle in lib/client.js and is discovered through package.json dsh.client.
- The balance endpoint GET /api/billing/balance proxies DeepSeek /user/balance through the harness credentials service, keeping the API key on the server.
- The client build script regenerates lib/client.js by vendoring the installed @deepseek-ai/dsh-client-ui-sidebar bundle, using DSH_SIDEBAR_BUNDLE or probing ~/.dsh/profiles.
## Notes
- The plugin is read-only and adds no prompt content, tools, or provider requests.
- Pricing data may come from GET /api/billing/pricing or the built-in MODEL_PRICING table when the provider page is unreachable.
- Installation requires dsh plugin add qwert702/dsh-token-viewer, a harness restart, and a web page refresh before opening the sidebar token usage card.

Need check word count with headings not counted. Let's count final more carefully maybe 287. Good.

Potential issue: "range presets" in core but not explained. It's okay. Could be one sentence.

Potential issue: "provider page" maybe not clear but grounded.

Potential issue: "current-session billed input" maybe README says billed input (uncached

安装Install

dsh plugin --profile web add github:qwert702/dsh-token-viewer

qwert702/dsh-token-viewer 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

上一个 Prev dsh-lsp-actions 下一个 Next dsh-session-deeplink