dsh-usage-overview 1.1.1 → 1.1.2

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
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%。
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 ----
@@ -1338,7 +1326,7 @@ window.__ModuleLoader__.load({
1338
1326
  // ---- src/client/dashboard.js ----
1339
1327
  const __m2 = (() => {
1340
1328
  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;
1329
+ const { RANGE_PRESETS: RANGE_PRESETS, USAGE_STATS_PATH: USAGE_STATS_PATH, formatPercent: formatPercent, formatTokensZh: formatTokensZh, isUsageDocument: isUsageDocument } = __m0;
1342
1330
  const { ModelDonut: ModelDonut, ModelUsageChart: ModelUsageChart, TokenCacheRate: TokenCacheRate, TokenHeatmap: TokenHeatmap, TokenTrend: TokenTrend } = __m1;
1343
1331
 
1344
1332
  const POLL_INTERVAL_MS = 30000;
@@ -1600,8 +1588,12 @@ window.__ModuleLoader__.load({
1600
1588
  : `用量最高的一天:${document_.totals.peakDay}`,
1601
1589
  }),
1602
1590
  h(StatCard, {
1603
- value: formatDuration(document_?.totals.longestSessionMs ?? 0),
1604
- label: '最长聊天时长',
1591
+ value: formatTokensZh(document_?.totals.averageTokensPerActiveDay ?? 0),
1592
+ label: '日均 Token 数',
1593
+ title:
1594
+ (document_?.totals.activeDays ?? 0) > 0
1595
+ ? `按 ${String(document_.totals.activeDays)} 个活跃日计算`
1596
+ : '这个范围内还没有用量记录',
1605
1597
  }),
1606
1598
  h(StatCard, {
1607
1599
  value: `${String(document_?.totals.currentStreak ?? 0)} 天`,
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.2",
6
6
  "icon": "icon.svg",
7
7
  "author": "w-callan-w",
8
8
  "repository": {