dsh-ws-recency 0.29.0 → 0.29.1
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.md +10 -8
- package/client.js +207 -75
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,13 +96,15 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
96
96
|
会话下方统计条上的「用量分析」,或会话「…」菜单 →「Token 消耗统计」:
|
|
97
97
|
|
|
98
98
|
- **真实账单**(每步记录的 usage):步数、输入(未缓存)、缓存命中、输出、合计;
|
|
99
|
-
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs
|
|
100
|
-
- **参数 /
|
|
101
|
-
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58
|
|
102
|
-
- **调用次数**:每条横条右侧带「N
|
|
103
|
-
-
|
|
104
|
-
- **两个 tab
|
|
105
|
-
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token
|
|
99
|
+
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条横条,按占用长度直观对比。**颜色表示工具族**(命令执行 / 文件操作 / 网络检索 / 子代理 / 其它),每族一个固定色、明艳度不随排名变化,工具名下方有族名小字,图上也有族图例;
|
|
100
|
+
- **参数 / 结果两段**:每个工具那条横条拆成「参数」(浅段,模型自己写的命令 / 文件内容)和「结果」(深段,环境返回的内容),一眼看出贵在输入还是贵在输出。图例在图右上角,悬停柱子也会给出具体拆分;
|
|
101
|
+
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58%;
|
|
102
|
+
- **调用次数**:每条横条右侧带「N 次」;图表有一行列头(token / 占比 / 调用)对齐五列;
|
|
103
|
+
- **摘要卡片**:合计(高亮)+ 步数 + 输入(未缓存)+ 缓存命中 + 输出,合计排第一;
|
|
104
|
+
- **两个 tab**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因」分页,打开时记住上次停留的 tab;
|
|
105
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。曲线上的琥珀点标出上下文**涨得最陡的三步**(悬停点或下方那一行,两边一起高亮),下面附一行「第 N 步上下文涨了 X(read 进来 Y)」——「哪一步开始放大」一眼就能看到,不用自己比 96 根柱子。
|
|
106
|
+
|
|
107
|
+
面板底部只有一条口径说明(原来两个 tab 各有一条相同的话)。
|
|
106
108
|
|
|
107
109
|
口径说明:prompt 的 token 是「整段上下文每一步都计费」,没法精确归属到某一条消息,所以「主 agent / 工具」的拆分是按内容长度估算(中文≈1 token/字,英文≈4 字符/token),用来比较占比;**总量是真的**。放大排行里的块大小同样是估算,但账单总量、每步上下文、放大倍数的分母都来自真实 usage。思维链通常不回传给模型,因此不计入放大排行。数据从会话日志算,跨重启也能看。大会话第一次打开约 1–2 秒(29MB 日志实测 1.2 秒),10 秒内重复打开走缓存。
|
|
108
110
|
|
|
@@ -201,7 +203,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
201
203
|
或固定版本的预构建包:
|
|
202
204
|
|
|
203
205
|
```powershell
|
|
204
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.29.
|
|
206
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.29.1/dsh-ws-recency-0.29.1.tgz
|
|
205
207
|
```
|
|
206
208
|
|
|
207
209
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -131,6 +131,8 @@
|
|
|
131
131
|
".wsr-modal-tools{display:flex;align-items:center;gap:8px;flex:none}",
|
|
132
132
|
".wsr-modal-body{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;font-size:12px}",
|
|
133
133
|
".wsr-stats-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}",
|
|
134
|
+
".wsr-stats-card-primary{box-shadow:inset 0 0 0 1px rgba(79,124,255,.45)}",
|
|
135
|
+
".wsr-stats-card-primary .wsr-stats-value{color:#7aa2ff}",
|
|
134
136
|
".wsr-stats-card{background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));border-radius:8px;padding:8px 10px}",
|
|
135
137
|
".wsr-stats-value{font-size:15px;font-weight:600}",
|
|
136
138
|
".wsr-stats-label{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
@@ -234,19 +236,23 @@
|
|
|
234
236
|
".wsr-chart{display:flex;flex-direction:column;gap:6px}",
|
|
235
237
|
".wsr-chart-head{display:flex;align-items:center;justify-content:space-between;gap:10px}",
|
|
236
238
|
".wsr-chart-title{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
237
|
-
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px;align-items:center;gap:8px}",
|
|
238
239
|
".wsr-chart-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}",
|
|
240
|
+
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px 48px;align-items:center;gap:8px}",
|
|
241
|
+
".wsr-chart-family{font-size:10px;color:var(--dsw-alias-label-tertiary);margin-top:-2px}",
|
|
242
|
+
".wsr-family-legend{padding-bottom:4px}",
|
|
239
243
|
".wsr-chart-track{height:8px;border-radius:4px;background:rgba(255,255,255,.06);overflow:hidden;display:flex}",
|
|
240
244
|
".wsr-chart-fill{height:100%;border-radius:0;min-width:0}",
|
|
241
245
|
".wsr-chart-group{display:flex;height:100%;min-width:2px;border-radius:4px;overflow:hidden}",
|
|
242
246
|
".wsr-chart-swatch{width:8px;height:8px;border-radius:2px;background:hsl(217, 88%, 50%)}",
|
|
243
|
-
".wsr-chart-swatch-dim{background:hsl(217,
|
|
247
|
+
".wsr-chart-swatch-dim{background:hsl(217, 32%, 84%)}",
|
|
244
248
|
".wsr-chart-legend{display:flex;flex-wrap:wrap;gap:10px;align-items:center}",
|
|
245
249
|
".wsr-chart-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
246
250
|
".wsr-chart-legend-text{white-space:nowrap}",
|
|
247
251
|
".wsr-chart-value{text-align:right;font-variant-numeric:tabular-nums}",
|
|
248
252
|
".wsr-chart-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
|
|
249
253
|
".wsr-chart-calls{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:10px;font-variant-numeric:tabular-nums}",
|
|
254
|
+
".wsr-chart-headrow{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
255
|
+
".wsr-chart-value-head,.wsr-chart-share-head,.wsr-chart-calls-head{text-align:right}",
|
|
250
256
|
".wsr-stats-details{display:flex;flex-direction:column;gap:8px}",
|
|
251
257
|
".wsr-stats-table{display:flex;flex-direction:column}",
|
|
252
258
|
".wsr-stats-row{display:grid;grid-template-columns:1.4fr .6fr .8fr .8fr .8fr .6fr;gap:6px;padding:6px 4px;border-bottom:.5px solid rgba(255,255,255,.06)}",
|
|
@@ -272,10 +278,14 @@
|
|
|
272
278
|
".wsr-context-chart{display:flex;align-items:flex-end;gap:2px;height:54px;padding-top:4px;border-bottom:.5px solid rgba(255,255,255,.08)}",
|
|
273
279
|
".wsr-context-bar{flex:1;min-width:1px;border-radius:1px 1px 0 0;background:linear-gradient(180deg,rgba(79,124,255,.9),rgba(79,124,255,.3))}",
|
|
274
280
|
".wsr-context-caption{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
275
|
-
".wsr-context-jump{position:relative}",
|
|
276
|
-
".wsr-context-jump-
|
|
281
|
+
".wsr-context-jump{position:relative;cursor:pointer}",
|
|
282
|
+
".wsr-context-jump-hit{position:absolute;left:50%;top:-9px;width:22px;height:22px;margin-left:-11px;display:flex;align-items:center;justify-content:center;border-radius:50%;cursor:pointer}",
|
|
283
|
+
".wsr-context-jump-dot{width:6px;height:6px;border-radius:50%;background:#d99a2b;transition:transform .12s,box-shadow .12s}",
|
|
284
|
+
".wsr-context-jump-hit-hot .wsr-context-jump-dot{transform:scale(1.8);box-shadow:0 0 0 4px rgba(217,154,43,.25)}",
|
|
285
|
+
".wsr-context-jump:hover .wsr-context-bar-inner{filter:brightness(1.15)}",
|
|
277
286
|
".wsr-context-jumps{display:flex;flex-direction:column;gap:2px}",
|
|
278
|
-
".wsr-context-jump-row{font-size:11px;color:var(--dsw-alias-label-secondary)}",
|
|
287
|
+
".wsr-context-jump-row{font-size:11px;color:var(--dsw-alias-label-secondary);padding:1px 4px;border-radius:4px;transition:background .12s,color .12s}",
|
|
288
|
+
".wsr-context-jump-row-hot{background:rgba(217,154,43,.16);color:var(--dsw-alias-label-primary)}",
|
|
279
289
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
280
290
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
281
291
|
".wsr-kind-dot{width:8px;height:8px;border-radius:2px;flex:none}",
|
|
@@ -287,8 +297,8 @@
|
|
|
287
297
|
".wsr-amplified-meta{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
288
298
|
".wsr-amplified-value{text-align:right;font-weight:600;font-variant-numeric:tabular-nums;font-size:12px}",
|
|
289
299
|
".wsr-amplified-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}",
|
|
290
|
-
".wsr-amplified-if{grid-column:1 / -1;font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
291
300
|
".wsr-amplified-empty{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
301
|
+
".wsr-stats-footnote{padding-top:6px;border-top:.5px solid rgba(255,255,255,.06)}",
|
|
292
302
|
".wsr-toggle{width:100%;height:28px;padding:0 12px 0 calc(28px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;font-size:12px}",
|
|
293
303
|
".wsr-toggle:hover{color:var(--dsw-alias-label-secondary)}",
|
|
294
304
|
'[' + STATE_ATTR + '="running"] [class*="_title"]{color:#4f8ef7}',
|
|
@@ -358,12 +368,15 @@
|
|
|
358
368
|
"stats.col.source": "\u6765\u6e90",
|
|
359
369
|
"stats.col.calls": "\u8c03\u7528",
|
|
360
370
|
"stats.callsShort": "{n} 次",
|
|
371
|
+
"stats.col.tokensShort": "token",
|
|
372
|
+
"stats.col.shareShort": "占比",
|
|
361
373
|
"stats.col.args": "\u53c2\u6570",
|
|
362
374
|
"stats.col.results": "\u7ed3\u679c",
|
|
363
375
|
"stats.col.total": "\u4f30\u7b97",
|
|
364
376
|
"stats.col.share": "\u5360\u6bd4",
|
|
365
377
|
"stats.note": "\u5408\u8ba1\u6765\u81ea\u6bcf\u6b65\u8bb0\u5f55\u7684\u771f\u5b9e usage\uff08\u7f13\u5b58\u547d\u4e2d + \u8f93\u5165 + \u8f93\u51fa\uff09\uff1b\u672c\u8868\u6309\u6765\u6e90\u7684\u62c6\u5206\u662f\u6309\u5185\u5bb9\u957f\u5ea6\u4f30\u7b97\uff08\u4e2d\u6587\u7ea6 1 token/\u5b57\uff0c\u82f1\u6587\u7ea6 4 \u5b57\u7b26/token\uff09\uff0c\u7528\u4e8e\u6bd4\u8f83\u5360\u6bd4\uff0c\u4e0d\u662f\u8ba1\u8d39\u53e3\u5f84\u3002",
|
|
366
378
|
"stats.agentDetail": "主 agent 构成:思考 {reasoning} · 回复 {text} · 用户消息 {user} · 系统提示 {system}",
|
|
379
|
+
"stats.split": "输入 {input} · 缓存命中 {cache} · 输出 {output}",
|
|
367
380
|
"stats.diagnose.unmounted": "\n\n(宿主半已加载,但统计路由没挂上——重启应用再试)",
|
|
368
381
|
"stats.diagnose.noHost": "\n\n(宿主半未加载:需要重启应用加载新版本)",
|
|
369
382
|
"menu.move": "移动到工作区…",
|
|
@@ -464,9 +477,16 @@
|
|
|
464
477
|
"archive.workspace": "工作区",
|
|
465
478
|
"move.failed": "移动失败:",
|
|
466
479
|
"stats.chart": "消耗分布",
|
|
480
|
+
"stats.family.shell": "命令执行",
|
|
481
|
+
"stats.family.files": "文件操作",
|
|
482
|
+
"stats.family.web": "网络检索",
|
|
483
|
+
"stats.family.agents": "子代理/协作",
|
|
484
|
+
"stats.family.misc": "其它工具",
|
|
485
|
+
"stats.family.other": "未归类",
|
|
467
486
|
"composer.analysis": "用量分析",
|
|
468
487
|
"stats.legend.args": "参数(模型写的)",
|
|
469
488
|
"stats.legend.results": "结果(环境返回的)",
|
|
489
|
+
"stats.barTooltip": "{name} 共 {total}:参数 {args}({argsShare}),结果 {results}({resultsShare})",
|
|
470
490
|
"stats.argModeNote": "当前把工具参数计入主 agent:每个工具只算返回结果,表格里「参数」列显示为淡色(那些 token 记在主 agent 那一行)。",
|
|
471
491
|
"stats.amplified.title": "放大成本(账单归因)",
|
|
472
492
|
"stats.amplified.summary": "账单 {bill} token;可归因内容经重读放大后占 {share}({attributed})",
|
|
@@ -528,12 +548,15 @@
|
|
|
528
548
|
"stats.col.source": "source",
|
|
529
549
|
"stats.col.calls": "calls",
|
|
530
550
|
"stats.callsShort": "{n}x",
|
|
551
|
+
"stats.col.tokensShort": "tokens",
|
|
552
|
+
"stats.col.shareShort": "share",
|
|
531
553
|
"stats.col.args": "args",
|
|
532
554
|
"stats.col.results": "results",
|
|
533
555
|
"stats.col.total": "estimate",
|
|
534
556
|
"stats.col.share": "share",
|
|
535
557
|
"stats.note": "Totals come from the recorded per-step usage (cache read + input + output). The per-source split is estimated from content length (about 1 token per CJK character, 4 characters per token otherwise) so the shares are comparable, not billable.",
|
|
536
558
|
"stats.agentDetail": "Agent composition: reasoning {reasoning} \u00b7 reply {text} \u00b7 user messages {user} \u00b7 system prompt {system}",
|
|
559
|
+
"stats.split": "input {input} \u00b7 cache hit {cache} \u00b7 output {output}",
|
|
537
560
|
"stats.diagnose.unmounted": "\n\n(the host half is loaded but the statistics route did not mount - restart the app and retry)",
|
|
538
561
|
"stats.diagnose.noHost": "\n\n(the host half is not loaded: restart the app to pick up the new version)",
|
|
539
562
|
"menu.move": "Move to workspace\u2026",
|
|
@@ -633,9 +656,16 @@
|
|
|
633
656
|
"archive.workspace": "workspace",
|
|
634
657
|
"move.failed": "Move failed: ",
|
|
635
658
|
"stats.chart": "Where the tokens went",
|
|
659
|
+
"stats.family.shell": "shell",
|
|
660
|
+
"stats.family.files": "files",
|
|
661
|
+
"stats.family.web": "web",
|
|
662
|
+
"stats.family.agents": "subagents",
|
|
663
|
+
"stats.family.misc": "other tools",
|
|
664
|
+
"stats.family.other": "unclassified",
|
|
636
665
|
"composer.analysis": "Usage analysis",
|
|
637
666
|
"stats.legend.args": "arguments (written by the model)",
|
|
638
667
|
"stats.legend.results": "results (returned by the environment)",
|
|
668
|
+
"stats.barTooltip": "{name}: {total} total - arguments {args} ({argsShare}), results {results} ({resultsShare})",
|
|
639
669
|
"stats.argModeNote": "Tool arguments currently count towards the agent: each tool shows only its results, and the table's \"args\" column is faded because those tokens sit on the agent's row.",
|
|
640
670
|
"stats.amplified.title": "Amplified cost (what the bill pays for)",
|
|
641
671
|
"stats.amplified.summary": "Bill {bill} tokens; attributable content amplifies to {share} ({attributed})",
|
|
@@ -1951,7 +1981,14 @@
|
|
|
1951
1981
|
*/
|
|
1952
1982
|
function chartBar(entry, largest) {
|
|
1953
1983
|
var line = statsDiv("wsr-chart-row");
|
|
1954
|
-
|
|
1984
|
+
var labelCell = statsDiv("wsr-chart-label", entry.name);
|
|
1985
|
+
/* The colour now means a family, so the name cell says which one: a
|
|
1986
|
+
colour without a caption is a riddle, not an encoding. It lives in
|
|
1987
|
+
the name cell so the five-column grid stays intact. */
|
|
1988
|
+
if (typeof entry.family === "string" && entry.family !== "") {
|
|
1989
|
+
labelCell.appendChild(statsDiv("wsr-chart-family", t("stats.family." + entry.family)));
|
|
1990
|
+
}
|
|
1991
|
+
line.appendChild(labelCell);
|
|
1955
1992
|
var track = statsDiv("wsr-chart-track");
|
|
1956
1993
|
var group = statsDiv("wsr-chart-group");
|
|
1957
1994
|
var width = largest > 0 ? (entry.value / largest) * 100 : 0;
|
|
@@ -1963,75 +2000,85 @@
|
|
|
1963
2000
|
if (argsPart > 0) {
|
|
1964
2001
|
var argsSeg = statsDiv("wsr-chart-fill wsr-bar-args");
|
|
1965
2002
|
argsSeg.style.width = argsPart.toFixed(2) + "%";
|
|
1966
|
-
argsSeg.style.background = sourceColorDim(entry.hue
|
|
2003
|
+
argsSeg.style.background = sourceColorDim(entry.hue);
|
|
1967
2004
|
group.appendChild(argsSeg);
|
|
1968
2005
|
}
|
|
1969
2006
|
var resultsSeg = statsDiv("wsr-chart-fill wsr-bar-results");
|
|
1970
2007
|
resultsSeg.style.width = (100 - argsPart).toFixed(2) + "%";
|
|
1971
|
-
resultsSeg.style.background = sourceColor(entry.hue
|
|
2008
|
+
resultsSeg.style.background = sourceColor(entry.hue);
|
|
1972
2009
|
group.appendChild(resultsSeg);
|
|
2010
|
+
/* What the two shades mean, on the thing that has them: the legend is
|
|
2011
|
+
a row away and reads like a second chart header. */
|
|
2012
|
+
if (argsPart > 0) {
|
|
2013
|
+
group.setAttribute("title", t("stats.barTooltip", {
|
|
2014
|
+
name: entry.name,
|
|
2015
|
+
total: formatTokens(entry.value),
|
|
2016
|
+
args: formatTokens(entry.args || 0),
|
|
2017
|
+
argsShare: formatShare((entry.value > 0 ? (entry.args || 0) / entry.value : 0)),
|
|
2018
|
+
results: formatTokens(entry.results || 0),
|
|
2019
|
+
resultsShare: formatShare((entry.value > 0 ? (entry.results || 0) / entry.value : 0)),
|
|
2020
|
+
}));
|
|
2021
|
+
}
|
|
1973
2022
|
track.appendChild(group);
|
|
1974
2023
|
line.appendChild(track);
|
|
1975
2024
|
line.appendChild(statsDiv("wsr-chart-value", formatTokens(entry.value)));
|
|
1976
2025
|
line.appendChild(statsDiv("wsr-chart-share", formatShare(entry.share)));
|
|
1977
2026
|
/* The count the chart cannot draw: a bar says how heavy a source is,
|
|
1978
2027
|
the call count says how often it got there. The details table used to
|
|
1979
|
-
be the only place for it.
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2028
|
+
be the only place for it. It always renders (empty for rows without
|
|
2029
|
+
a count) so the five-column grid stays aligned. */
|
|
2030
|
+
line.appendChild(statsDiv(
|
|
2031
|
+
"wsr-chart-calls",
|
|
2032
|
+
typeof entry.calls === "number" && entry.calls > 0 ? t("stats.callsShort", { n: String(entry.calls) }) : "",
|
|
2033
|
+
));
|
|
1983
2034
|
return line;
|
|
1984
2035
|
}
|
|
1985
2036
|
|
|
1986
2037
|
/**
|
|
1987
|
-
* Colour identity for a source.
|
|
2038
|
+
* Colour identity for a source, by tool family.
|
|
1988
2039
|
*
|
|
1989
|
-
* The
|
|
1990
|
-
*
|
|
1991
|
-
*
|
|
1992
|
-
*
|
|
1993
|
-
*
|
|
2040
|
+
* The colour answers one question - what kind of work is this - so the
|
|
2041
|
+
* hue is the family, not the tool: five named families with a fixed
|
|
2042
|
+
* vividness, and unknown tools fall back to the same neutral instead of a
|
|
2043
|
+
* hash. Ranking no longer modulates anything: a faded tail colour told the
|
|
2044
|
+
* reader nothing they could act on.
|
|
1994
2045
|
*/
|
|
1995
|
-
var
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
subagent: 250, subagent_fork: 250, workflow: 250, spawn_teammate: 250, send_message: 250, wait_agent: 250,
|
|
2002
|
-
ask_user_question: 12, present: 12,
|
|
2003
|
-
skill: 60, create_goal: 60, update_goal: 60,
|
|
2004
|
-
};
|
|
2005
|
-
var TOOL_PREFIX_HUES = [
|
|
2006
|
-
["mcp__", 235],
|
|
2007
|
-
["browser_", 0],
|
|
2008
|
-
["univer_", 175],
|
|
2009
|
-
["weknora_", 300],
|
|
2010
|
-
["job_", 330],
|
|
2011
|
-
["team_", 250],
|
|
2046
|
+
var TOOL_FAMILIES = [
|
|
2047
|
+
{ key: "shell", hue: 32, tools: ["pwsh", "powershell", "shell", "bash", "command", "cmd", "run_code"], prefixes: [] },
|
|
2048
|
+
{ key: "files", hue: 152, tools: ["read", "write", "edit", "grep", "glob", "str_replace_editor", "ls", "delete", "move_file"], prefixes: ["univer_"] },
|
|
2049
|
+
{ key: "web", hue: 205, tools: ["web_fetch", "web_search", "platform_search", "multi_search", "advanced_search", "domain_search", "video_search", "browser_"], prefixes: ["browser_"] },
|
|
2050
|
+
{ key: "agents", hue: 268, tools: ["subagent", "subagent_fork", "workflow", "spawn_teammate", "send_message", "wait_agent", "task"], prefixes: ["team_"] },
|
|
2051
|
+
{ key: "misc", hue: 330, tools: ["todo_write", "todo_read", "todo", "job_output", "job_list", "job_kill", "skill", "create_goal", "update_goal", "ask_user_question", "present", "weknora_"], prefixes: ["job_", "weknora_", "mcp__"] },
|
|
2012
2052
|
];
|
|
2053
|
+
/** The neutral an unknown tool gets: no family, no claim of one. */
|
|
2054
|
+
var TOOL_FAMILY_NEUTRAL = { key: "other", hue: 210 };
|
|
2013
2055
|
|
|
2014
|
-
function
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2056
|
+
function toolFamily(name) {
|
|
2057
|
+
if (typeof name !== "string" || name === "") return TOOL_FAMILY_NEUTRAL;
|
|
2058
|
+
var key = name.toLowerCase();
|
|
2059
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) {
|
|
2060
|
+
var family = TOOL_FAMILIES[i];
|
|
2061
|
+
if (family.tools.indexOf(key) !== -1) return family;
|
|
2062
|
+
for (var p = 0; p < family.prefixes.length; p += 1) {
|
|
2063
|
+
if (key.indexOf(family.prefixes[p]) === 0) return family;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
return TOOL_FAMILY_NEUTRAL;
|
|
2018
2067
|
}
|
|
2019
2068
|
|
|
2020
2069
|
function sourceHue(name) {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
return
|
|
2070
|
+
return toolFamily(name).hue;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/** The hue of a family key, for the legend swatches. */
|
|
2074
|
+
function hueOfFamily(key) {
|
|
2075
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) if (TOOL_FAMILIES[i].key === key) return TOOL_FAMILIES[i].hue;
|
|
2076
|
+
return TOOL_FAMILY_NEUTRAL.hue;
|
|
2028
2077
|
}
|
|
2029
2078
|
|
|
2030
|
-
/**
|
|
2031
|
-
function sourceColor(hue
|
|
2032
|
-
|
|
2033
|
-
var lightness = Math.min(64, 50 + rank * 2);
|
|
2034
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2079
|
+
/** One vividness for every family bar: colour means "which family", not "how big". */
|
|
2080
|
+
function sourceColor(hue) {
|
|
2081
|
+
return "hsl(" + hue + ", 72%, 58%)";
|
|
2035
2082
|
}
|
|
2036
2083
|
|
|
2037
2084
|
/**
|
|
@@ -2039,12 +2086,12 @@
|
|
|
2039
2086
|
*
|
|
2040
2087
|
* It has to be a real colour rather than an opacity: the segment sits on a
|
|
2041
2088
|
* solid bar of the same hue, so a translucent copy of it would composite
|
|
2042
|
-
* back to exactly the same colour and the split would be invisible.
|
|
2089
|
+
* back to exactly the same colour and the split would be invisible. The
|
|
2090
|
+
* gap between the two is deliberately wide - a 20-point lightness step read
|
|
2091
|
+
* as one smudged bar in the reported panel.
|
|
2043
2092
|
*/
|
|
2044
|
-
function sourceColorDim(hue
|
|
2045
|
-
|
|
2046
|
-
var lightness = Math.min(76, 66 + rank * 2);
|
|
2047
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2093
|
+
function sourceColorDim(hue) {
|
|
2094
|
+
return "hsl(" + hue + ", 32%, 84%)";
|
|
2048
2095
|
}
|
|
2049
2096
|
|
|
2050
2097
|
var AMPLIFIED_KIND = {
|
|
@@ -2063,6 +2110,48 @@
|
|
|
2063
2110
|
* block's tokens times the number of later steps that re-read it. The
|
|
2064
2111
|
* host half computes that attribution; this only draws it.
|
|
2065
2112
|
*/
|
|
2113
|
+
/** Chart/list pairs whose jump markers highlight together on hover. */
|
|
2114
|
+
var jumpHoverHosts = [];
|
|
2115
|
+
/** Document-level listener for jump hover; registered once per panel open. */
|
|
2116
|
+
var jumpHoverBound = false;
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Highlight one jump: the bar, its dot and the row that spells it out.
|
|
2120
|
+
*
|
|
2121
|
+
* Both the chart and the list live under the same section, so the pairing
|
|
2122
|
+
* is by `data-wsr-jump*` attributes rather than by DOM position (the chart
|
|
2123
|
+
* is downsampled and a bar may cover several steps).
|
|
2124
|
+
*/
|
|
2125
|
+
function highlightJumpRow(event) {
|
|
2126
|
+
var target = event !== undefined && event.currentTarget !== undefined ? event.currentTarget : null;
|
|
2127
|
+
if (target === null || typeof target.getAttribute !== "function") return;
|
|
2128
|
+
var step = target.getAttribute("data-wsr-jump-hit");
|
|
2129
|
+
if (step === null) return;
|
|
2130
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2131
|
+
var host = jumpHoverHosts[i];
|
|
2132
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2133
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2134
|
+
for (var r = 0; r < rows.length; r += 1) {
|
|
2135
|
+
rows[r].className = "wsr-context-jump-row" + (rows[r].getAttribute("data-wsr-jump-row") === step ? " wsr-context-jump-row-hot" : "");
|
|
2136
|
+
}
|
|
2137
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2138
|
+
for (var h = 0; h < hits.length; h += 1) {
|
|
2139
|
+
hits[h].className = "wsr-context-jump-hit" + (hits[h].getAttribute("data-wsr-jump-hit") === step ? " wsr-context-jump-hit-hot" : "");
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
function clearJumpHighlight() {
|
|
2145
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2146
|
+
var host = jumpHoverHosts[i];
|
|
2147
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2148
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2149
|
+
for (var r = 0; r < rows.length; r += 1) rows[r].className = "wsr-context-jump-row";
|
|
2150
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2151
|
+
for (var h = 0; h < hits.length; h += 1) hits[h].className = "wsr-context-jump-hit";
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2066
2155
|
/** The three steepest rises in the context curve, with the block behind each. */
|
|
2067
2156
|
function contextJumps(amplified) {
|
|
2068
2157
|
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
@@ -2142,8 +2231,15 @@
|
|
|
2142
2231
|
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2143
2232
|
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2144
2233
|
bar.setAttribute("title", jump.label);
|
|
2145
|
-
|
|
2146
|
-
|
|
2234
|
+
/* A hover target that is big enough to hit: a 5px dot on a 3px bar
|
|
2235
|
+
is unraisable without aiming, and the label lives in the row
|
|
2236
|
+
below, so hovering the bar also lifts that row. */
|
|
2237
|
+
var hit = statsDiv("wsr-context-jump-hit");
|
|
2238
|
+
hit.setAttribute("data-wsr-jump-hit", String(jump.step));
|
|
2239
|
+
hit.appendChild(statsDiv("wsr-context-jump-dot"));
|
|
2240
|
+
hit.addEventListener("mouseenter", highlightJumpRow);
|
|
2241
|
+
hit.addEventListener("mouseleave", clearJumpHighlight);
|
|
2242
|
+
bar.appendChild(hit);
|
|
2147
2243
|
} else {
|
|
2148
2244
|
bar.setAttribute("title", t("stats.amplified.point", { step: String(series[j].step), context: formatTokens(series[j].context) }));
|
|
2149
2245
|
}
|
|
@@ -2154,10 +2250,15 @@
|
|
|
2154
2250
|
if (jumps.length > 0) {
|
|
2155
2251
|
var jumpList = statsDiv("wsr-context-jumps");
|
|
2156
2252
|
for (var jl = 0; jl < jumps.length; jl += 1) {
|
|
2157
|
-
|
|
2253
|
+
var jumpRow = statsDiv("wsr-context-jump-row", jumps[jl].label);
|
|
2254
|
+
jumpRow.setAttribute("data-wsr-jump-row", String(jumps[jl].step));
|
|
2255
|
+
jumpList.appendChild(jumpRow);
|
|
2158
2256
|
}
|
|
2159
2257
|
section.appendChild(jumpList);
|
|
2160
2258
|
}
|
|
2259
|
+
/* The rows only make sense while the chart is on screen; hovering a
|
|
2260
|
+
bar or its row lifts both, which is what "挪上去更明显" means here. */
|
|
2261
|
+
jumpHoverHosts.push({ chart: chart, list: section });
|
|
2161
2262
|
|
|
2162
2263
|
var kinds = amplified.byKind || [];
|
|
2163
2264
|
if (kinds.length > 0) {
|
|
@@ -2193,37 +2294,34 @@
|
|
|
2193
2294
|
row.appendChild(main);
|
|
2194
2295
|
row.appendChild(statsDiv("wsr-amplified-value", formatTokens(block.amplified)));
|
|
2195
2296
|
row.appendChild(statsDiv("wsr-amplified-share", formatShare(block.share || 0)));
|
|
2196
|
-
if (Number(block.remaining) > 0 && Number(block.saving) > 0) {
|
|
2197
|
-
row.appendChild(statsDiv("wsr-amplified-if", t("stats.amplified.whatIf", {
|
|
2198
|
-
save: formatTokens(block.saving),
|
|
2199
|
-
share: formatShare(Number(block.saving) / (bill > 0 ? bill : 1)),
|
|
2200
|
-
})));
|
|
2201
|
-
}
|
|
2202
2297
|
list.appendChild(row);
|
|
2203
2298
|
}
|
|
2204
2299
|
section.appendChild(list);
|
|
2205
|
-
section.appendChild(statsDiv("wsr-stats-note", t("stats.amplified.note")));
|
|
2206
2300
|
return section;
|
|
2207
2301
|
}
|
|
2208
2302
|
|
|
2209
2303
|
function renderStats(body, stats) {
|
|
2210
2304
|
body.textContent = "";
|
|
2211
2305
|
while (body.firstChild !== null) body.removeChild(body.firstChild);
|
|
2306
|
+
/* A re-render replaces the DOM the hover handlers pointed at. */
|
|
2307
|
+
jumpHoverHosts.length = 0;
|
|
2212
2308
|
var totals = stats.totals || {};
|
|
2213
2309
|
var estimate = stats.estimate || {};
|
|
2214
2310
|
var agent = estimate.agent || {};
|
|
2215
2311
|
|
|
2312
|
+
/* Five cards as before, bill first: it is the number the rest of the
|
|
2313
|
+
panel explains, so it leads and carries the accent. */
|
|
2216
2314
|
var grid = document.createElement("div");
|
|
2217
2315
|
grid.className = "wsr-stats-grid";
|
|
2218
2316
|
var cards = [
|
|
2219
|
-
[t("stats.
|
|
2220
|
-
[t("stats.
|
|
2221
|
-
[t("stats.
|
|
2222
|
-
[t("stats.
|
|
2223
|
-
[t("stats.
|
|
2317
|
+
[t("stats.total"), formatTokens(totals.totalTokens), true],
|
|
2318
|
+
[t("stats.steps"), formatTokens(stats.steps), false],
|
|
2319
|
+
[t("stats.input"), formatTokens(totals.inputTokens), false],
|
|
2320
|
+
[t("stats.cache"), formatTokens(totals.cacheReadTokens), false],
|
|
2321
|
+
[t("stats.output"), formatTokens(totals.outputTokens), false],
|
|
2224
2322
|
];
|
|
2225
2323
|
for (var i = 0; i < cards.length; i += 1) {
|
|
2226
|
-
var card = statsDiv("wsr-stats-card");
|
|
2324
|
+
var card = statsDiv("wsr-stats-card" + (cards[i][2] === true ? " wsr-stats-card-primary" : ""));
|
|
2227
2325
|
card.appendChild(statsDiv("wsr-stats-value", cards[i][1]));
|
|
2228
2326
|
card.appendChild(statsDiv("wsr-stats-label", cards[i][0]));
|
|
2229
2327
|
grid.appendChild(card);
|
|
@@ -2271,19 +2369,51 @@
|
|
|
2271
2369
|
value: value,
|
|
2272
2370
|
share: shareOf(value),
|
|
2273
2371
|
hue: sourceHue(tool.name),
|
|
2372
|
+
family: toolFamily(tool.name).key,
|
|
2274
2373
|
rank: j + 1,
|
|
2275
2374
|
calls: tool.calls || 0,
|
|
2276
2375
|
args: args,
|
|
2376
|
+
results: results,
|
|
2277
2377
|
split: mode !== "agent" && args > 0 && results > 0,
|
|
2278
2378
|
});
|
|
2279
2379
|
}
|
|
2280
2380
|
|
|
2281
2381
|
/* The picture first: one bar per source, split into args and results. */
|
|
2282
|
-
var chart =
|
|
2382
|
+
var chart = document.createElement("div");
|
|
2383
|
+
chart.className = "wsr-chart";
|
|
2384
|
+
var familyOrder = [];
|
|
2385
|
+
var familySeen = {};
|
|
2386
|
+
for (var f = 0; f < entries.length; f += 1) {
|
|
2387
|
+
var fam = entries[f].family;
|
|
2388
|
+
if (typeof fam === "string" && fam !== "" && familySeen[fam] !== true) {
|
|
2389
|
+
familySeen[fam] = true;
|
|
2390
|
+
familyOrder.push(fam);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
if (familyOrder.length > 0) {
|
|
2394
|
+
var familyLegend = statsDiv("wsr-kind-legend wsr-family-legend");
|
|
2395
|
+
for (var fl = 0; fl < familyOrder.length; fl += 1) {
|
|
2396
|
+
var famItem = statsDiv("wsr-kind");
|
|
2397
|
+
var famDot = statsDiv("wsr-kind-dot");
|
|
2398
|
+
famDot.style.background = sourceColor(hueOfFamily(familyOrder[fl]));
|
|
2399
|
+
famItem.appendChild(famDot);
|
|
2400
|
+
famItem.appendChild(statsDiv("", t("stats.family." + familyOrder[fl])));
|
|
2401
|
+
familyLegend.appendChild(famItem);
|
|
2402
|
+
}
|
|
2403
|
+
chart.appendChild(familyLegend);
|
|
2404
|
+
}
|
|
2283
2405
|
var chartHead = statsDiv("wsr-chart-head");
|
|
2284
2406
|
chartHead.appendChild(statsDiv("wsr-chart-title", t("stats.chart")));
|
|
2285
2407
|
if (mode !== "agent") chartHead.appendChild(chartLegend());
|
|
2286
2408
|
chart.appendChild(chartHead);
|
|
2409
|
+
/* A header row keeps the count column from reading as a stray number. */
|
|
2410
|
+
var callHead = statsDiv("wsr-chart-row wsr-chart-headrow");
|
|
2411
|
+
callHead.appendChild(statsDiv("wsr-chart-label", ""));
|
|
2412
|
+
callHead.appendChild(statsDiv("wsr-chart-track-head", ""));
|
|
2413
|
+
callHead.appendChild(statsDiv("wsr-chart-value-head", t("stats.col.tokensShort")));
|
|
2414
|
+
callHead.appendChild(statsDiv("wsr-chart-share-head", t("stats.col.shareShort")));
|
|
2415
|
+
callHead.appendChild(statsDiv("wsr-chart-calls-head", t("stats.col.calls")));
|
|
2416
|
+
chart.appendChild(callHead);
|
|
2287
2417
|
var largest = 1;
|
|
2288
2418
|
for (var m = 0; m < entries.length; m += 1) if (entries[m].value > largest) largest = entries[m].value;
|
|
2289
2419
|
for (var k = 0; k < entries.length; k += 1) chart.appendChild(chartBar(entries[k], largest));
|
|
@@ -2298,7 +2428,6 @@
|
|
|
2298
2428
|
user: formatTokens(agent.user),
|
|
2299
2429
|
system: formatTokens(agent.system),
|
|
2300
2430
|
})));
|
|
2301
|
-
distributionPanel.appendChild(statsDiv("wsr-stats-note", t("stats.note")));
|
|
2302
2431
|
|
|
2303
2432
|
var tabs = statsDiv("wsr-stats-tabs");
|
|
2304
2433
|
tabs.setAttribute("role", "tablist");
|
|
@@ -2345,6 +2474,9 @@
|
|
|
2345
2474
|
selectTab(initialTab);
|
|
2346
2475
|
body.appendChild(tabs);
|
|
2347
2476
|
body.appendChild(panels);
|
|
2477
|
+
/* One口径 note for the whole dialog: both views are estimates over the
|
|
2478
|
+
same logs, and repeating it under each view crowded out the numbers. */
|
|
2479
|
+
body.appendChild(statsDiv("wsr-stats-note wsr-stats-footnote", t("stats.note")));
|
|
2348
2480
|
}
|
|
2349
2481
|
|
|
2350
2482
|
function openStatsPanel(sessionId) {
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
|
|
|
32
32
|
export const name = "ws-recency";
|
|
33
33
|
|
|
34
34
|
/** Version marker reported by the health route. */
|
|
35
|
-
export const HOST_VERSION = "0.29.
|
|
35
|
+
export const HOST_VERSION = "0.29.1";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, moving a session to another workspace, and a literal content search that jumps to the turn a word was said in.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chyxhtc",
|