dsh-usage-overview 1.1.1 → 1.1.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/README.en.md CHANGED
@@ -10,8 +10,8 @@ cache-hit-rate trends, and a per-model breakdown with a stacked day/week chart.
10
10
 
11
11
  ## Features
12
12
 
13
- - **Headline metrics** — total tokens, peak day, longest chat, current and
14
- longest streaks, and prompt-cache hit rate.
13
+ - **Headline metrics** — total tokens, peak day, daily average over active days,
14
+ current and longest streaks, and prompt-cache hit rate.
15
15
  - **Token activity** — a year of daily usage as a Sunday-aligned heatmap with
16
16
  five intensity levels.
17
17
  - **Daily token trend** — one smoothed line per provider route, with a shared
@@ -27,10 +27,6 @@ cache-hit-rate trends, and a per-model breakdown with a stacked day/week chart.
27
27
  - **Light and dark themes** — colours come from DSH theme tokens, including the
28
28
  tooltip's own dark-surface label token.
29
29
 
30
- | Desktop | Phone (390px) |
31
- |---|---|
32
- | ![Desktop](docs/dashboard.png) | ![Phone](docs/dashboard-mobile.png) |
33
-
34
30
  ## Install
35
31
 
36
32
  The plugin is a DSH bundle. It needs a harness build that provides the
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## 功能
12
12
 
13
- - **头部指标**:累计 Token、单日峰值、最长聊天时长、当前/最长连续天数、缓存命中率。
13
+ - **头部指标**:累计 Token、单日峰值、日均 Token(按活跃日)、当前/最长连续天数、缓存命中率。
14
14
  - **Token 活动**:最近一年的每日用量热力图,周日对齐,五级强度。
15
15
  - **每日 Token 趋势**:每个 Provider 路由一条平滑曲线,共享十字准线,图例显示各自合计。
16
16
  - **每日缓存命中率**:按输入 Token 加权的每日命中率;当天没有输入 Token 时留空,不画成 0%。
@@ -21,10 +21,6 @@
21
21
  和图表都会随可用空间连续调整。
22
22
  - **浅色/深色主题**:颜色来自 DSH 主题 Token;提示气泡使用自身深色表面的专用前景色。
23
23
 
24
- | 桌面 | 手机(390px) |
25
- |---|---|
26
- | ![桌面](docs/dashboard.png) | ![手机](docs/dashboard-mobile.png) |
27
-
28
24
  ## 安装
29
25
 
30
26
  本插件是一个 DSH Bundle,需要宿主提供 `webServer` 服务。
package/lib/client.js CHANGED
@@ -88,18 +88,6 @@ window.__ModuleLoader__.load({
88
88
  return `${(value / 100000000).toFixed(1)}亿`;
89
89
  }
90
90
 
91
- function formatDuration(ms) {
92
- if (typeof ms !== 'number' || !Number.isFinite(ms) || ms < 0) return '—';
93
- const seconds = Math.round(ms / 1000);
94
- if (seconds < 60) return `${String(seconds)}秒`;
95
- const minutes = Math.floor(seconds / 60);
96
- if (minutes < 60) return `${String(minutes)}分${String(seconds % 60)}秒`;
97
- const hours = Math.floor(minutes / 60);
98
- if (hours < 24) return `${String(hours)}小时${String(minutes % 60)}分`;
99
- const days = Math.floor(hours / 24);
100
- return `${String(days)}天${String(hours % 24)}小时`;
101
- }
102
-
103
91
  function formatPercent(value) {
104
92
  if (typeof value !== 'number' || !Number.isFinite(value)) return '—';
105
93
  return `${value.toFixed(2)}%`;
@@ -111,7 +99,7 @@ window.__ModuleLoader__.load({
111
99
  const day = String(date.getDate()).padStart(2, '0');
112
100
  return `${String(date.getFullYear())}-${month}-${day}`;
113
101
  }
114
- return { USAGE_SCHEMA_VERSION, PANEL_ID, NS, USAGE_STATS_PATH, RANGE_PRESETS, PROVIDER_SOURCE_LABELS, SERIES_COLORS, TOKEN_BUCKETS, cacheHitRate, isUsageDocument, formatTokens, formatTokensZh, formatDuration, formatPercent, dayKeyOf };
102
+ return { USAGE_SCHEMA_VERSION, PANEL_ID, NS, USAGE_STATS_PATH, RANGE_PRESETS, PROVIDER_SOURCE_LABELS, SERIES_COLORS, TOKEN_BUCKETS, cacheHitRate, isUsageDocument, formatTokens, formatTokensZh, formatPercent, dayKeyOf };
115
103
  })();
116
104
 
117
105
  // ---- src/client/charts.js ----
@@ -422,7 +410,6 @@ window.__ModuleLoader__.load({
422
410
  h(
423
411
  'div',
424
412
  { className: 'dus-heat-legend' },
425
- scrollable ? h('span', { className: 'dus-heat-hint' }, '← 左右滑动 →') : null,
426
413
  h('span', null, '少'),
427
414
  ...[0, 1, 2, 3, 4].map((level) =>
428
415
  h('div', { key: `l-${String(level)}`, className: 'dus-heat-cell', 'data-level': String(level), style: { width: '10px', height: '10px' } }),
@@ -1182,7 +1169,6 @@ window.__ModuleLoader__.load({
1182
1169
  'div',
1183
1170
  { className: 'dus-bars-heading' },
1184
1171
  h('h3', { className: 'dus-bars-title' }, '各模型用量趋势'),
1185
- h('span', { className: 'dus-bars-note' }, '堆叠高度 = Token 总量 · 颜色对应上方模型'),
1186
1172
  ),
1187
1173
  h(
1188
1174
  'div',
@@ -1338,7 +1324,7 @@ window.__ModuleLoader__.load({
1338
1324
  // ---- src/client/dashboard.js ----
1339
1325
  const __m2 = (() => {
1340
1326
  const { createElement: h, useCallback: useCallback, useEffect: useEffect, useMemo: useMemo, useRef: useRef, useState: useState } = require("react");
1341
- const { RANGE_PRESETS: RANGE_PRESETS, USAGE_STATS_PATH: USAGE_STATS_PATH, formatDuration: formatDuration, formatPercent: formatPercent, formatTokensZh: formatTokensZh, isUsageDocument: isUsageDocument } = __m0;
1327
+ const { RANGE_PRESETS: RANGE_PRESETS, USAGE_STATS_PATH: USAGE_STATS_PATH, formatPercent: formatPercent, formatTokensZh: formatTokensZh, isUsageDocument: isUsageDocument } = __m0;
1342
1328
  const { ModelDonut: ModelDonut, ModelUsageChart: ModelUsageChart, TokenCacheRate: TokenCacheRate, TokenHeatmap: TokenHeatmap, TokenTrend: TokenTrend } = __m1;
1343
1329
 
1344
1330
  const POLL_INTERVAL_MS = 30000;
@@ -1600,8 +1586,12 @@ window.__ModuleLoader__.load({
1600
1586
  : `用量最高的一天:${document_.totals.peakDay}`,
1601
1587
  }),
1602
1588
  h(StatCard, {
1603
- value: formatDuration(document_?.totals.longestSessionMs ?? 0),
1604
- label: '最长聊天时长',
1589
+ value: formatTokensZh(document_?.totals.averageTokensPerActiveDay ?? 0),
1590
+ label: '日均 Token 数',
1591
+ title:
1592
+ (document_?.totals.activeDays ?? 0) > 0
1593
+ ? `按 ${String(document_.totals.activeDays)} 个活跃日计算`
1594
+ : '这个范围内还没有用量记录',
1605
1595
  }),
1606
1596
  h(StatCard, {
1607
1597
  value: `${String(document_?.totals.currentStreak ?? 0)} 天`,
@@ -1676,8 +1666,6 @@ window.__ModuleLoader__.load({
1676
1666
  'div',
1677
1667
  { className: 'dus-panel-head' },
1678
1668
  h('h2', { className: 'dus-panel-title' }, '每日平均缓存命中率'),
1679
- h('div', { className: 'dus-head-spacer' }),
1680
- h('span', { className: 'dus-panel-sub' }, `${rangeLabel(rangeId)} · 按输入 token 加权`),
1681
1669
  ),
1682
1670
  h(TokenCacheRate, { days, rangeDays: range }),
1683
1671
  ),
@@ -1689,8 +1677,6 @@ window.__ModuleLoader__.load({
1689
1677
  'div',
1690
1678
  { className: 'dus-panel-head' },
1691
1679
  h('h2', { className: 'dus-panel-title' }, '模型用量'),
1692
- h('div', { className: 'dus-head-spacer' }),
1693
- h('span', { className: 'dus-panel-sub' }, '来源 = 模型接入的提供方'),
1694
1680
  ),
1695
1681
  h(ModelDonut, { models: modelsWithUsage }),
1696
1682
  h(ModelUsageChart, { days, models: modelsWithUsage, rangeDays: range }),
@@ -1898,7 +1884,6 @@ window.__ModuleLoader__.load({
1898
1884
  margin-top: 10px; font-size: 11px; color: var(--dsw-alias-label-secondary);
1899
1885
  }
1900
1886
  .dus-heat-legend .dus-heat-cell { width: 10px; height: 10px; }
1901
- .dus-heat-hint { margin-right: auto; color: var(--dsw-alias-label-secondary); }
1902
1887
 
1903
1888
  .dus-tip {
1904
1889
  position: fixed; z-index: 60; pointer-events: none;
@@ -2035,7 +2020,6 @@ window.__ModuleLoader__.load({
2035
2020
  gap: 4px 10px; min-width: 0; flex: 1 1 200px;
2036
2021
  }
2037
2022
  .dus-bars-title { font-size: 13.5px; font-weight: 600; margin: 0; line-height: 1.3; }
2038
- .dus-bars-note { font-size: 11px; color: var(--dsw-alias-label-secondary); }
2039
2023
  .dus-trend-toggle { margin-left: auto; flex: none; }
2040
2024
  .dus-seg-sm .dus-seg-btn { padding: 3px 10px; font-size: 11px; }
2041
2025
 
package/lib/protocol.js CHANGED
@@ -79,18 +79,6 @@ export function formatTokensZh(value) {
79
79
  return `${(value / 100000000).toFixed(1)}亿`;
80
80
  }
81
81
 
82
- export function formatDuration(ms) {
83
- if (typeof ms !== 'number' || !Number.isFinite(ms) || ms < 0) return '—';
84
- const seconds = Math.round(ms / 1000);
85
- if (seconds < 60) return `${String(seconds)}秒`;
86
- const minutes = Math.floor(seconds / 60);
87
- if (minutes < 60) return `${String(minutes)}分${String(seconds % 60)}秒`;
88
- const hours = Math.floor(minutes / 60);
89
- if (hours < 24) return `${String(hours)}小时${String(minutes % 60)}分`;
90
- const days = Math.floor(hours / 24);
91
- return `${String(days)}天${String(hours % 24)}小时`;
92
- }
93
-
94
82
  export function formatPercent(value) {
95
83
  if (typeof value !== 'number' || !Number.isFinite(value)) return '—';
96
84
  return `${value.toFixed(2)}%`;
package/lib/usage.js CHANGED
@@ -223,7 +223,6 @@ export function buildUsageDocument(sessions, options) {
223
223
 
224
224
  const totals = emptyTotals();
225
225
  let peakSessionTokens = 0;
226
- let longestSessionMs = 0;
227
226
  let turns = 0;
228
227
  let steps = 0;
229
228
 
@@ -241,8 +240,6 @@ export function buildUsageDocument(sessions, options) {
241
240
  const sessionTotal = totalOf(session.totals);
242
241
  if (sessionTotal > peakSessionTokens) peakSessionTokens = sessionTotal;
243
242
  }
244
- const span = session.wallMs ?? session.sessionStats?.llmMs ?? 0;
245
- if (span > longestSessionMs) longestSessionMs = span;
246
243
  turns += session.turns ?? session.sessionStats?.turns ?? 0;
247
244
  steps += session.steps ?? session.sessionStats?.steps ?? 0;
248
245
  }
@@ -348,6 +345,8 @@ export function buildUsageDocument(sessions, options) {
348
345
  const { current: currentStreak, longest: longestStreak } = streaks(activeDays, now);
349
346
 
350
347
  const grandTotal = totalOf(totals);
348
+ const activeDayCount = activeDays.length;
349
+ const averageTokensPerActiveDay = activeDayCount === 0 ? 0 : Math.round(grandTotal / activeDayCount);
351
350
 
352
351
  const peakDay = days.reduce(
353
352
  (best, day) => (day.total > best.total ? { total: day.total, day: day.day } : best),
@@ -371,7 +370,8 @@ export function buildUsageDocument(sessions, options) {
371
370
  peakDayTokens: peakDay.total,
372
371
  peakDay: peakDay.day,
373
372
  peakSessionTokens,
374
- longestSessionMs,
373
+ activeDays: activeDayCount,
374
+ averageTokensPerActiveDay,
375
375
  turns,
376
376
  steps,
377
377
  currentStreak,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-usage-overview",
3
3
  "displayName": "DSH Usage Overview",
4
4
  "description": "A usage overview for DeepSeek Harness: token totals, activity heatmap, daily token and cache trends, and per-model attribution.",
5
- "version": "1.1.1",
5
+ "version": "1.1.3",
6
6
  "icon": "icon.svg",
7
7
  "author": "w-callan-w",
8
8
  "repository": {