@feiyang666/dsh-usage-plugin 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  ---
10
10
 
11
+ ## v1.9.3 (2026-08-20)
12
+
13
+ - **概览支持日期筛选**:概览 Tab 顶部新增筛选栏,可按「今天 / 近 7 天 / 近 30 天 / 全部」快速切换,或自定义起止日期区间;所有聚合统计(按模型表、服务商 × 模型明细、总计)均按所选范围实时计算,并展示当前范围的记录数与总消耗。
14
+
11
15
  ## v1.9.2 (2026-08-20)
12
16
 
13
17
  > 修复 issue #4:持久化路径随会话工作区漂移,导致历史用量数据"消失/统计为 0",且 UI 显示路径与实际落盘路径不一致。
package/README.md CHANGED
@@ -32,7 +32,7 @@ dsh-usage-plugin is a **usage & cost tracker** plugin in the DeepSeek Harness ec
32
32
 
33
33
  > Supports **Windows / macOS / Linux**: paths are handled per platform (`node:path`), and the folder picker / "reveal in file manager" use each OS's native mechanism (macOS: `osascript` / `open`; Linux: `zenity` / `xdg-open`). Balance query and export do not depend on Windows-only commands.
34
34
 
35
- - **Usage & Cost**: records each model call's token usage and cache hits (input miss / cache hit / cache write / output / reasoning / finish reason), and computes cost using DeepSeek's peak/valley or base pricing (peak hours are automatically priced by Beijing time 09:00–12:00 and 14:00–18:00). Model names come from the actual request parameters, so non-DeepSeek models are shown truthfully instead of "unknown model"; models without an official price are counted as 0. The overview shows a by-model table plus a by-API-provider × model drill-down (each provider grouped with every model's calls and peak/off-peak cost split) and a grand total row.
35
+ - **Usage & Cost**: records each model call's token usage and cache hits (input miss / cache hit / cache write / output / reasoning / finish reason), and computes cost using DeepSeek's peak/valley or base pricing (peak hours are automatically priced by Beijing time 09:00–12:00 and 14:00–18:00). Model names come from the actual request parameters, so non-DeepSeek models are shown truthfully instead of "unknown model"; models without an official price are counted as 0. The overview shows a by-model table plus a by-API-provider × model drill-down (each provider grouped with every model's calls and peak/off-peak cost split) and a grand total row. The overview also supports **date filtering** (Today / Last 7 days / Last 30 days / All, plus a custom start–end range), so the aggregate stats can be scoped to any single day or date range.
36
36
  - **Usage Calendar**: a monthly daily-usage heatmap (colored by cost or call count), hover for details including the peak/off-peak cost split, click a day for its call list and peak/off-peak totals, plus a per-day statistics table with peak cost / off-peak cost / total columns and monthly rollups.
37
37
  - **Cache Hit List**: newest-first, fully scrollable, with quick filters (Today / 7 days / 30 days / All) and custom date ranges; the summary line and footer total split peak vs off-peak consumption with a grand cost total. The list is paginated (100 rows per page), so it stays smooth even with large data volumes.
38
38
  - **Price Table**: the official DeepSeek API price table — base and peak/valley unit prices shown side by side (peak vs off-peak), editable in-panel and persisted to `pricing.json`, with a reset-to-default option.
@@ -259,6 +259,7 @@ pnpm dsh web
259
259
 
260
260
  ## Acknowledgements
261
261
 
262
+ - **[@Martin-soaring-dev](https://github.com/Martin-soaring-dev)**: prepared the plugin for public contribution (packaging, plugin-contract checks, docs & CI) and submitted the contribution branch that became the basis for the open-source releases ([#6](https://github.com/feiyang-dev/dsh-usage-plugin/pull/6)).
262
263
  - **[@mumuer1024](https://github.com/mumuer1024)**: reported and diagnosed the persistence-path drift across workspaces (history "disappearing" / counted as 0) and proposed storing data in a fixed, dedicated directory ([#4](https://github.com/feiyang-dev/dsh-usage-plugin/issues/4)).
263
264
  - **[@liu3734](https://github.com/liu3734)**: reported and diagnosed the Windows-only path handling / spawn issues on macOS (POSIX) and proposed the cross-platform fix ([#1](https://github.com/feiyang-dev/dsh-usage-plugin/issues/1)).
264
265
 
package/README.zh.md CHANGED
@@ -32,7 +32,7 @@ dsh-usage-plugin 是 DeepSeek Harness 生态的**用量与消耗统计插件**
32
32
 
33
33
  > 支持 **Windows / macOS / Linux**:路径按当前平台处理(`node:path`),目录选择与「打开所在目录」均调用系统原生方式(macOS 用 `osascript` / `open`,Linux 用 `zenity` / `xdg-open`),余额查询与导出不依赖 Windows 专用命令。
34
34
 
35
- - **用量与消耗**:记录每次模型调用的 token 用量与缓存命中(输入·未命中 / 缓存命中 / 缓存写入 / 输出 / 推理 / 结束原因),按 DeepSeek 峰谷/基础价格计算消耗(高峰时段自动按北京时间 9:00–12:00、14:00–18:00 计价)。模型名以请求参数为准如实显示(非 DeepSeek 模型不再显示为「未知模型」,无官方价格的模型消耗按 0 统计)。概览含「按模型」表与「按 API 服务商 × 模型」明细表(每个服务商一组,组内列出各模型的调用与高峰/空闲分列消耗),底部有总费用合计。
35
+ - **用量与消耗**:记录每次模型调用的 token 用量与缓存命中(输入·未命中 / 缓存命中 / 缓存写入 / 输出 / 推理 / 结束原因),按 DeepSeek 峰谷/基础价格计算消耗(高峰时段自动按北京时间 9:00–12:00、14:00–18:00 计价)。模型名以请求参数为准如实显示(非 DeepSeek 模型不再显示为「未知模型」,无官方价格的模型消耗按 0 统计)。概览含「按模型」表与「按 API 服务商 × 模型」明细表(每个服务商一组,组内列出各模型的调用与高峰/空闲分列消耗),底部有总费用合计。概览还支持**日期筛选**(今天 / 近 7 天 / 近 30 天 / 全部,外加自定义起止区间),可将聚合统计限定到任意一天或日期范围。
36
36
  - **用量日历**:按月查看每日用量热力图(按消耗或调用数着色),悬停查看详情(含高峰 / 空闲消耗拆分)、点击某天查看当日调用明细与高峰/空闲消耗统计,附本月每日统计表(高峰消耗 / 空闲消耗 / 总消耗分列)与月度汇总。
37
37
  - **缓存命中列表**:最新记录排在最前,支持 今天 / 近7天 / 近30天 / 全部 快捷筛选与自定义起止日期区间,汇总行与表尾合计区分高峰消耗 / 空闲消耗 / 总费用合计;列表分页渲染(每页 100 条),记录量大也不卡顿。
38
38
  - **价格表**:**DeepSeek 官方 API 价格表**,展示基础价与峰谷价(高峰/空闲)单价表,高峰价与空闲价分列展示,支持在面板内直接编辑价格并持久化(数据目录 `pricing.json`),也可一键恢复默认。
@@ -259,6 +259,7 @@ pnpm dsh web
259
259
 
260
260
  ## 致谢
261
261
 
262
+ - **[@Martin-soaring-dev](https://github.com/Martin-soaring-dev)**:筹备了插件开源贡献(打包、插件契约校验、文档与 CI),并提交贡献分支,成为后续开源版本的基础([#6](https://github.com/feiyang-dev/dsh-usage-plugin/pull/6))。
262
263
  - **[@mumuer1024](https://github.com/mumuer1024)**:报告并定位了持久化路径随会话工作区漂移导致历史数据"消失/统计为 0"的问题,提出把数据写到固定专用目录的方案([#4](https://github.com/feiyang-dev/dsh-usage-plugin/issues/4))。
263
264
  - **[@liu3734](https://github.com/liu3734)**:报告并定位 macOS(POSIX)下路径处理与 spawn 的 Windows 专用问题,提出跨平台修复方案([#1](https://github.com/feiyang-dev/dsh-usage-plugin/issues/1))。
264
265
 
package/lib/client.js CHANGED
@@ -409,7 +409,30 @@ window.__ModuleLoader__.load({
409
409
 
410
410
  // ── Overview view ──
411
411
  function OverviewView(props) {
412
- var records = props.records, regime = props.regime;
412
+ var allRecords = props.records, regime = props.regime;
413
+ var presetState = React.useState("all");
414
+ var preset = presetState[0], setPreset = presetState[1];
415
+ var fromState = React.useState("");
416
+ var fromDate = fromState[0], setFromDate = fromState[1];
417
+ var toState = React.useState("");
418
+ var toDate = toState[0], setToDate = toState[1];
419
+
420
+ var nowKey = bjKey(Date.now());
421
+ var fromMs = null, toMs = null;
422
+ if (preset === "today") { fromMs = bjStartMs(nowKey); toMs = Date.now(); }
423
+ else if (preset === "7d") { fromMs = bjStartMs(nowKey) - 6 * 86400000; toMs = Date.now(); }
424
+ else if (preset === "30d") { fromMs = bjStartMs(nowKey) - 29 * 86400000; toMs = Date.now(); }
425
+ else if (preset === "custom") {
426
+ if (fromDate) fromMs = bjStartMs(fromDate);
427
+ if (toDate) toMs = bjStartMs(toDate) + 86400000 - 1;
428
+ }
429
+ var records = [];
430
+ for (var fi = 0; fi < allRecords.length; fi++) {
431
+ var fr = allRecords[fi];
432
+ if (fromMs != null && fr.time < fromMs) continue;
433
+ if (toMs != null && fr.time > toMs) continue;
434
+ records.push(fr);
435
+ }
413
436
  var totalCalls = records.length;
414
437
  var totalHit = 0, totalMiss = 0, totalWrite = 0, totalOut = 0, totalReason = 0, totalCost = 0, peakTotal = 0, offTotal = 0, peakCalls = 0, offCalls = 0;
415
438
  var byModel = {}, byProvider = {}, byProviderModel = {};
@@ -519,7 +542,26 @@ window.__ModuleLoader__.load({
519
542
  el("td", { style: st.tdTotal }, fmtMoney(totalCost))
520
543
  ));
521
544
 
545
+ function presetBtn(k, label) {
546
+ return el("button", { style: preset === k ? st.segBtnOn : st.segBtn, onClick: function () { setPreset(k); } }, label);
547
+ }
548
+ function setCustomFrom(v) { setFromDate(v); setPreset("custom"); }
549
+ function setCustomTo(v) { setToDate(v); setPreset("custom"); }
550
+
522
551
  return el("div", null,
552
+ el("div", { style: st.calBar },
553
+ el("div", { style: st.seg },
554
+ presetBtn("today", "今天"), presetBtn("7d", "近7天"), presetBtn("30d", "近30天"), presetBtn("all", "全部")
555
+ ),
556
+ el("span", { style: st.note }, "自定义区间:"),
557
+ el("input", { type: "date", style: st.dateInput, value: fromDate, onChange: function (e) { setCustomFrom(e.target.value); } }),
558
+ el("span", { style: st.note }, "至"),
559
+ el("input", { type: "date", style: st.dateInput, value: toDate, onChange: function (e) { setCustomTo(e.target.value); } }),
560
+ (fromDate || toDate || preset !== "all") ? el("button", { style: st.btn, onClick: function () { setFromDate(""); setToDate(""); setPreset("all"); } }, "清除筛选") : null
561
+ ),
562
+ el("div", { style: st.note, marginTop: 8 },
563
+ "当前范围:共 " + fmtInt(records.length) + " 条" + (preset === "all" && !fromDate && !toDate ? "(全部记录)" : "") + " · 总消耗 " + fmtMoney(totalCost) + "(" + costHint(regime) + ")"
564
+ ),
523
565
  el("div", { style: st.cards },
524
566
  el(Card, { label: "调用次数", value: fmtInt(totalCalls), hint: "高峰 " + fmtInt(peakCalls) + " · 空闲 " + fmtInt(offCalls) }),
525
567
  el(Card, { label: "输入 · 未命中", value: fmtInt(totalMiss), hint: "token" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feiyang666/dsh-usage-plugin",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "DeepSeek Harness usage & cost tracker plugin: per-call token/cache-hit stats, peak/off-peak billing, DeepSeek balance query, CSV/JSON/PNG export with custom destination, and persistent local storage. Ships a host half plus a web client half in one npm package; installs into a DSH profile as a dsh.bundle with one command (dsh plugin --profile web add @feiyang666/dsh-usage-plugin).",
5
5
  "keywords": [
6
6
  "deepseek",
@@ -21,6 +21,10 @@
21
21
  "url": "git+https://github.com/feiyang-dev/dsh-usage-plugin.git"
22
22
  },
23
23
  "contributors": [
24
+ {
25
+ "name": "Martin-soaring-dev",
26
+ "url": "https://github.com/Martin-soaring-dev"
27
+ },
24
28
  {
25
29
  "name": "liu3734",
26
30
  "url": "https://github.com/liu3734"