dsh-ws-recency 0.28.0 → 0.29.0
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 +5 -4
- package/client.js +95 -25
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,9 +99,10 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
99
99
|
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条带颜色的横条,按占用长度直观对比;色相由工具身份决定(常用工具人工指定,其余按名字哈希,跨会话稳定),明艳度随占比排名递减;
|
|
100
100
|
- **参数 / 结果两段**:每个工具那条横条拆成「参数」(淡色,模型自己写的命令 / 文件内容)和「结果」(实色,环境返回的内容),一眼看出贵在输入还是贵在输出。图例在图右上角;
|
|
101
101
|
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58%。表格里「参数」列仍在,只是显示为淡色并计入主 agent 那一行;
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
102
|
+
- **调用次数**:每条横条右侧带「N 次」,说明这个来源被调用了多少次(图上看不出次数);
|
|
103
|
+
- **主 agent 拆分**:横条下方一行,给出思考 / 回复 / 用户消息 / 系统提示各占多少;
|
|
104
|
+
- **两个 tab(0.29.0)**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因」分页,打开时记住上次停留的 tab。原先的「明细」表只是把图上的数字再列一遍,已去掉——它独有的调用次数和 agent 拆分分别挪到了横条和图表下方;
|
|
105
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比,以及「压到 20% 可省多少」。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。曲线上的琥珀点标出上下文**涨得最陡的三步**,下面附一行「第 N 步上下文涨了 X(read 进来 Y)」——「哪一步开始放大」一眼就能看到,不用自己比 96 根柱子。
|
|
105
106
|
|
|
106
107
|
口径说明:prompt 的 token 是「整段上下文每一步都计费」,没法精确归属到某一条消息,所以「主 agent / 工具」的拆分是按内容长度估算(中文≈1 token/字,英文≈4 字符/token),用来比较占比;**总量是真的**。放大排行里的块大小同样是估算,但账单总量、每步上下文、放大倍数的分母都来自真实 usage。思维链通常不回传给模型,因此不计入放大排行。数据从会话日志算,跨重启也能看。大会话第一次打开约 1–2 秒(29MB 日志实测 1.2 秒),10 秒内重复打开走缓存。
|
|
107
108
|
|
|
@@ -200,7 +201,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
200
201
|
或固定版本的预构建包:
|
|
201
202
|
|
|
202
203
|
```powershell
|
|
203
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
204
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.29.0/dsh-ws-recency-0.29.0.tgz
|
|
204
205
|
```
|
|
205
206
|
|
|
206
207
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -246,6 +246,7 @@
|
|
|
246
246
|
".wsr-chart-legend-text{white-space:nowrap}",
|
|
247
247
|
".wsr-chart-value{text-align:right;font-variant-numeric:tabular-nums}",
|
|
248
248
|
".wsr-chart-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
|
|
249
|
+
".wsr-chart-calls{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:10px;font-variant-numeric:tabular-nums}",
|
|
249
250
|
".wsr-stats-details{display:flex;flex-direction:column;gap:8px}",
|
|
250
251
|
".wsr-stats-table{display:flex;flex-direction:column}",
|
|
251
252
|
".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)}",
|
|
@@ -271,6 +272,10 @@
|
|
|
271
272
|
".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)}",
|
|
272
273
|
".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))}",
|
|
273
274
|
".wsr-context-caption{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
275
|
+
".wsr-context-jump{position:relative}",
|
|
276
|
+
".wsr-context-jump-dot{position:absolute;left:50%;top:-5px;width:5px;height:5px;margin-left:-2.5px;border-radius:50%;background:#d99a2b}",
|
|
277
|
+
".wsr-context-jumps{display:flex;flex-direction:column;gap:2px}",
|
|
278
|
+
".wsr-context-jump-row{font-size:11px;color:var(--dsw-alias-label-secondary)}",
|
|
274
279
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
275
280
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
276
281
|
".wsr-kind-dot{width:8px;height:8px;border-radius:2px;flex:none}",
|
|
@@ -352,6 +357,7 @@
|
|
|
352
357
|
"stats.agent": "\u4e3b agent",
|
|
353
358
|
"stats.col.source": "\u6765\u6e90",
|
|
354
359
|
"stats.col.calls": "\u8c03\u7528",
|
|
360
|
+
"stats.callsShort": "{n} 次",
|
|
355
361
|
"stats.col.args": "\u53c2\u6570",
|
|
356
362
|
"stats.col.results": "\u7ed3\u679c",
|
|
357
363
|
"stats.col.total": "\u4f30\u7b97",
|
|
@@ -466,6 +472,8 @@
|
|
|
466
472
|
"stats.amplified.summary": "账单 {bill} token;可归因内容经重读放大后占 {share}({attributed})",
|
|
467
473
|
"stats.amplified.contextCaption": "每步上下文(面积≈账单):越早进入的内容被重读越多",
|
|
468
474
|
"stats.amplified.point": "第 {step} 步 · {context}",
|
|
475
|
+
"stats.amplified.jump": "第 {step} 步上下文涨了 {rise}",
|
|
476
|
+
"stats.amplified.jumpFrom": "({name} 进来 {tokens})",
|
|
469
477
|
"stats.amplified.meta": "第 {entry} 步进入 · {tokens} token × {remaining} 次重读",
|
|
470
478
|
"stats.amplified.whatIf": "若压到 20%,可省 {save}({share})",
|
|
471
479
|
"stats.amplified.empty": "没有可归因的放大内容(压缩后或旧日志可能缺失)",
|
|
@@ -519,6 +527,7 @@
|
|
|
519
527
|
"stats.agent": "main agent",
|
|
520
528
|
"stats.col.source": "source",
|
|
521
529
|
"stats.col.calls": "calls",
|
|
530
|
+
"stats.callsShort": "{n}x",
|
|
522
531
|
"stats.col.args": "args",
|
|
523
532
|
"stats.col.results": "results",
|
|
524
533
|
"stats.col.total": "estimate",
|
|
@@ -632,6 +641,8 @@
|
|
|
632
641
|
"stats.amplified.summary": "Bill {bill} tokens; attributable content amplifies to {share} ({attributed})",
|
|
633
642
|
"stats.amplified.contextCaption": "Context per step (area ≈ bill): earlier content is re-read more",
|
|
634
643
|
"stats.amplified.point": "step {step} · {context}",
|
|
644
|
+
"stats.amplified.jump": "step {step} grew by {rise}",
|
|
645
|
+
"stats.amplified.jumpFrom": "({name} brought {tokens})",
|
|
635
646
|
"stats.amplified.meta": "entered at step {entry} · {tokens} tokens × {remaining} re-reads",
|
|
636
647
|
"stats.amplified.whatIf": "at 20%, saves {save} ({share})",
|
|
637
648
|
"stats.amplified.empty": "No amplifiable content (compacted or older logs may lack it)",
|
|
@@ -1963,6 +1974,12 @@
|
|
|
1963
1974
|
line.appendChild(track);
|
|
1964
1975
|
line.appendChild(statsDiv("wsr-chart-value", formatTokens(entry.value)));
|
|
1965
1976
|
line.appendChild(statsDiv("wsr-chart-share", formatShare(entry.share)));
|
|
1977
|
+
/* The count the chart cannot draw: a bar says how heavy a source is,
|
|
1978
|
+
the call count says how often it got there. The details table used to
|
|
1979
|
+
be the only place for it. */
|
|
1980
|
+
if (typeof entry.calls === "number" && entry.calls > 0) {
|
|
1981
|
+
line.appendChild(statsDiv("wsr-chart-calls", t("stats.callsShort", { n: String(entry.calls) })));
|
|
1982
|
+
}
|
|
1966
1983
|
return line;
|
|
1967
1984
|
}
|
|
1968
1985
|
|
|
@@ -2046,6 +2063,49 @@
|
|
|
2046
2063
|
* block's tokens times the number of later steps that re-read it. The
|
|
2047
2064
|
* host half computes that attribution; this only draws it.
|
|
2048
2065
|
*/
|
|
2066
|
+
/** The three steepest rises in the context curve, with the block behind each. */
|
|
2067
|
+
function contextJumps(amplified) {
|
|
2068
|
+
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
2069
|
+
var blocks = Array.isArray(amplified.blocks) ? amplified.blocks : [];
|
|
2070
|
+
var rises = [];
|
|
2071
|
+
for (var i = 1; i < series.length; i += 1) {
|
|
2072
|
+
var rise = Number(series[i].context) - Number(series[i - 1].context);
|
|
2073
|
+
if (rise > 0) rises.push({ step: Number(series[i].step), rise: rise });
|
|
2074
|
+
}
|
|
2075
|
+
rises.sort(function (a, b) { return b.rise - a.rise; });
|
|
2076
|
+
var picked = [];
|
|
2077
|
+
for (var r = 0; r < rises.length && picked.length < 3; r += 1) {
|
|
2078
|
+
var rise2 = rises[r];
|
|
2079
|
+
/* Two markers next to each other would read as one long jump; keep
|
|
2080
|
+
the bars they sit on apart so each mark stays a single step. */
|
|
2081
|
+
var close = false;
|
|
2082
|
+
for (var p = 0; p < picked.length; p += 1) {
|
|
2083
|
+
if (Math.abs(picked[p].step - rise2.step) < Math.max(2, Math.round(series.length / 10))) close = true;
|
|
2084
|
+
}
|
|
2085
|
+
if (close) continue;
|
|
2086
|
+
/* The entering block: the biggest one whose entry step is this one,
|
|
2087
|
+
or (downsampled curves) the last entry at or before it. */
|
|
2088
|
+
var best = null;
|
|
2089
|
+
for (var b = 0; b < blocks.length; b += 1) {
|
|
2090
|
+
var block = blocks[b];
|
|
2091
|
+
if (Number(block.entry) > rise2.step) continue;
|
|
2092
|
+
if (best === null || Number(block.entry) > Number(best.entry)) best = block;
|
|
2093
|
+
}
|
|
2094
|
+
var label = t("stats.amplified.jump", {
|
|
2095
|
+
step: String(rise2.step),
|
|
2096
|
+
rise: formatTokens(rise2.rise),
|
|
2097
|
+
});
|
|
2098
|
+
if (best !== null && Number(best.entry) === rise2.step) {
|
|
2099
|
+
label += " " + t("stats.amplified.jumpFrom", {
|
|
2100
|
+
name: best.kind === "tool" ? String(best.name) : t("stats.agent"),
|
|
2101
|
+
tokens: formatTokens(best.tokens),
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
picked.push({ step: rise2.step, rise: rise2.rise, label: label });
|
|
2105
|
+
}
|
|
2106
|
+
return picked;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2049
2109
|
function buildAmplified(stats) {
|
|
2050
2110
|
var amplified = stats.amplified;
|
|
2051
2111
|
if (amplified === null || amplified === undefined || !Array.isArray(amplified.series)) return null;
|
|
@@ -2067,14 +2127,37 @@
|
|
|
2067
2127
|
if (Number(series[i].context) > largest) largest = Number(series[i].context);
|
|
2068
2128
|
}
|
|
2069
2129
|
var chart = statsDiv("wsr-context-chart");
|
|
2130
|
+
/* Mark the steps where the window grew the most. A single read of a
|
|
2131
|
+
large file shows up here as one tall jump, which is the question the
|
|
2132
|
+
whole amplified view exists to answer, so the jump gets a marker
|
|
2133
|
+
instead of leaving the reader to compare 96 bars by eye. */
|
|
2134
|
+
var jumps = contextJumps(amplified);
|
|
2135
|
+
var jumpByStep = {};
|
|
2136
|
+
for (var jj = 0; jj < jumps.length; jj += 1) jumpByStep[jumps[jj].step] = jumps[jj];
|
|
2070
2137
|
for (var j = 0; j < series.length; j += 1) {
|
|
2071
2138
|
var bar = statsDiv("wsr-context-bar");
|
|
2072
2139
|
bar.style.height = Math.max(2, Math.round((Number(series[j].context) / largest) * 100)) + "%";
|
|
2073
|
-
|
|
2140
|
+
var jump = jumpByStep[Number(series[j].step)];
|
|
2141
|
+
if (jump !== undefined) {
|
|
2142
|
+
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2143
|
+
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2144
|
+
bar.setAttribute("title", jump.label);
|
|
2145
|
+
var marker = statsDiv("wsr-context-jump-dot");
|
|
2146
|
+
bar.appendChild(marker);
|
|
2147
|
+
} else {
|
|
2148
|
+
bar.setAttribute("title", t("stats.amplified.point", { step: String(series[j].step), context: formatTokens(series[j].context) }));
|
|
2149
|
+
}
|
|
2074
2150
|
chart.appendChild(bar);
|
|
2075
2151
|
}
|
|
2076
2152
|
section.appendChild(chart);
|
|
2077
2153
|
section.appendChild(statsDiv("wsr-context-caption", t("stats.amplified.contextCaption")));
|
|
2154
|
+
if (jumps.length > 0) {
|
|
2155
|
+
var jumpList = statsDiv("wsr-context-jumps");
|
|
2156
|
+
for (var jl = 0; jl < jumps.length; jl += 1) {
|
|
2157
|
+
jumpList.appendChild(statsDiv("wsr-context-jump-row", jumps[jl].label));
|
|
2158
|
+
}
|
|
2159
|
+
section.appendChild(jumpList);
|
|
2160
|
+
}
|
|
2078
2161
|
|
|
2079
2162
|
var kinds = amplified.byKind || [];
|
|
2080
2163
|
if (kinds.length > 0) {
|
|
@@ -2189,6 +2272,7 @@
|
|
|
2189
2272
|
share: shareOf(value),
|
|
2190
2273
|
hue: sourceHue(tool.name),
|
|
2191
2274
|
rank: j + 1,
|
|
2275
|
+
calls: tool.calls || 0,
|
|
2192
2276
|
args: args,
|
|
2193
2277
|
split: mode !== "agent" && args > 0 && results > 0,
|
|
2194
2278
|
});
|
|
@@ -2205,33 +2289,16 @@
|
|
|
2205
2289
|
for (var k = 0; k < entries.length; k += 1) chart.appendChild(chartBar(entries[k], largest));
|
|
2206
2290
|
var distributionPanel = statsDiv("wsr-stats-panel");
|
|
2207
2291
|
distributionPanel.appendChild(chart);
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
var table = statsDiv("wsr-stats-table");
|
|
2214
|
-
var head = document.createElement("div");
|
|
2215
|
-
head.className = "wsr-stats-row wsr-stats-head";
|
|
2216
|
-
var columns = ["stats.col.source", "stats.col.calls", "stats.col.args", "stats.col.results", "stats.col.total", "stats.col.share"];
|
|
2217
|
-
for (var n = 0; n < columns.length; n += 1) head.appendChild(statsDiv("wsr-td", t(columns[n])));
|
|
2218
|
-
table.appendChild(head);
|
|
2219
|
-
table.appendChild(statsRow(t("stats.agent"), stats.steps, null, null, agentValue, shareOf(agentValue)));
|
|
2220
|
-
for (var q = 0; q < tools.length; q += 1) {
|
|
2221
|
-
var toolRow = tools[q];
|
|
2222
|
-
var toolArgs = toolRow.args || 0;
|
|
2223
|
-
var toolResults = toolRow.results || 0;
|
|
2224
|
-
var toolValue = mode === "agent" ? toolResults : (toolRow.total || toolArgs + toolResults);
|
|
2225
|
-
table.appendChild(statsRow(toolRow.name, toolRow.calls, toolArgs, toolResults, toolValue, shareOf(toolValue), mode === "agent"));
|
|
2226
|
-
}
|
|
2227
|
-
detailsPanel.appendChild(table);
|
|
2228
|
-
detailsPanel.appendChild(statsDiv("wsr-stats-detail", t("stats.agentDetail", {
|
|
2292
|
+
/* The agent's own split is the one number the bars cannot show: the
|
|
2293
|
+
rows for tools already name their source, so a whole table was
|
|
2294
|
+
repeating the chart. It sits under the chart instead. */
|
|
2295
|
+
distributionPanel.appendChild(statsDiv("wsr-stats-detail", t("stats.agentDetail", {
|
|
2229
2296
|
reasoning: formatTokens(agent.reasoning),
|
|
2230
2297
|
text: formatTokens(agent.text),
|
|
2231
2298
|
user: formatTokens(agent.user),
|
|
2232
2299
|
system: formatTokens(agent.system),
|
|
2233
2300
|
})));
|
|
2234
|
-
|
|
2301
|
+
distributionPanel.appendChild(statsDiv("wsr-stats-note", t("stats.note")));
|
|
2235
2302
|
|
|
2236
2303
|
var tabs = statsDiv("wsr-stats-tabs");
|
|
2237
2304
|
tabs.setAttribute("role", "tablist");
|
|
@@ -2242,7 +2309,7 @@
|
|
|
2242
2309
|
amplifiedPanel.appendChild(amplifiedSection);
|
|
2243
2310
|
defs.push(["amplified", "stats.tab.amplified", amplifiedPanel]);
|
|
2244
2311
|
}
|
|
2245
|
-
defs.
|
|
2312
|
+
if (mode === "agent") defs[0][2].appendChild(statsDiv("wsr-stats-note", t("stats.argModeNote")));
|
|
2246
2313
|
var tabButtons = {};
|
|
2247
2314
|
var selectTab = function (id) {
|
|
2248
2315
|
statsTab = id;
|
|
@@ -2271,7 +2338,10 @@
|
|
|
2271
2338
|
})(defs[d]);
|
|
2272
2339
|
}
|
|
2273
2340
|
var initialTab = statsTab;
|
|
2274
|
-
|
|
2341
|
+
/* A remembered tab may name a view this build no longer has. */
|
|
2342
|
+
var known = false;
|
|
2343
|
+
for (var kt = 0; kt < defs.length; kt += 1) if (defs[kt][0] === initialTab) known = true;
|
|
2344
|
+
if (!known) initialTab = "distribution";
|
|
2275
2345
|
selectTab(initialTab);
|
|
2276
2346
|
body.appendChild(tabs);
|
|
2277
2347
|
body.appendChild(panels);
|
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.
|
|
35
|
+
export const HOST_VERSION = "0.29.0";
|
|
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.
|
|
3
|
+
"version": "0.29.0",
|
|
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",
|