dsh-wdx-relief 0.8.0 → 0.9.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/CHANGELOG.md +9 -0
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/client/client.js +246 -19
- package/docs/DETAIL.md +4 -4
- package/docs/DETAIL.zh.md +4 -4
- package/docs/guide.md +8 -7
- package/index.js +23 -6
- package/package.json +1 -1
- package/src/recap.js +203 -10
- package/src/recapHistory.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0 — 2026-11-22
|
|
4
|
+
|
|
5
|
+
- **进度改成按时间窗的思路摘要**:每 10 分钟那条不再拼「运行 cd …」的命令流水,而是从这段时间的思考片段和去掉参数的动作里总结「在解决什么、用了什么思路、推进到哪」。第 1 条覆盖 1–10 分钟,第 2 条累计 1–20 分钟(重点写 11–20 分钟的新进展),以此类推;进度行右侧直接标出累计时间窗。
|
|
6
|
+
- 客户端从事件窗口切出当前时间窗,只把思考片段和去参数的动作(命令、搜索、网页的目标不发送)作为 `digest` 发给 Host;Host 复用摘要模型链生成 1–2 句,模型失败或摘要功能关闭时保留客户端本地摘要。
|
|
7
|
+
- 时间窗按本轮开始换算:常规第 2 条显示「第 1–20 分」、提示模型重点写新增的 11–20;中途回复过或跳档时显示真实覆盖范围。
|
|
8
|
+
- 生成结果里的命令/参数会被过滤,失败时退回本地摘要;旧进度记录没有 `windowMs` 时保持原样显示,不迁移。
|
|
9
|
+
- `recapProgress` 的说明同步改为「用便宜模型写思路」。
|
|
10
|
+
- 顶栏新增 **WDX Relief 入口**:和 wdx-git 的图标并排(`order` 12),点一下直接打开右侧面板;按钮沿用面板的图标和无障碍标签,支持键盘焦点。
|
|
11
|
+
|
|
3
12
|
## 0.8.0 — 2026-11-21
|
|
4
13
|
|
|
5
14
|
- 新增 **实时进度**(默认开启):一轮运行中每 10 分钟没给用户正文回复,就往右侧「会话回顾」记一条进度;工具调用和思考不会重置这个计时,所以一直跑工具也算。输入框上方那一行在第一次超过 10 分钟时自动出现,显示第几轮、最近动作和等待时长。
|
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ A small collection of features that reduce the everyday mental load of using DSH
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- **Next-message prediction**: after a turn, grey text guesses what you'll send next; press <kbd>Tab</kbd> to accept. Typing hides it, <kbd>Esc</kbd> dismisses it.
|
|
11
|
-
- **The line above the input** (on by default): shows turn by turn "what this turn is doing and where it is", always above the composer. **Live progress** appears automatically after the configured interval without a reply to you (10 minutes by default) — tools and reasoning keep running but still count as no reply — and shows the turn number
|
|
12
|
-
- **WDX Relief page** (right sidebar, on by default): appears in the right sidebar's tool list just like WDX Git. It has two tabs and defaults to "Session review" (configurable in settings). "Session review" groups entries by turn: each turn's progress entries and recap sit together, with a collapsible header showing the turn, counts, end time and turn duration; if any of the last N turns (3 by default; configurable under advanced settings) ends on a question or a "next step / you need" line it is marked "Follow up"; finished turns keep that marker while a new turn is running, and the running turn joins the check only after it ends. Switch between Newest first and Oldest first, filter by All / Summaries / Progress / Follow up, refresh every 30 seconds, and confirm before clearing. "Ask aside" stays out of the main context.
|
|
11
|
+
- **The line above the input** (on by default): shows turn by turn "what this turn is doing and where it is", always above the composer. **Live progress** appears automatically after the configured interval without a reply to you (10 minutes by default) — tools and reasoning keep running but still count as no reply — and shows the turn number and waiting time; from then on it records one **idea summary** per interval in Session review: a cheap model writes what this window was solving and how far it got; the action list drops command arguments and command-shaped model output is filtered, with a local summary as fallback. A status chip distinguishes running / no output / done / cancelled from the finished recap. The "›" at the end of the line opens Session review filtered to progress. The semantic recap makes one cheap model call per turn, and the Host generates it at turn end even when the panel is closed or you switched away, so no turn is skipped; the local activity feed makes zero calls. This line never enters the model context. Generated recaps stay in the WDX Relief panel on the right.
|
|
12
|
+
- **WDX Relief page** (right sidebar, on by default): appears in the right sidebar's tool list just like WDX Git, and a matching icon in the session header opens it directly. It has two tabs and defaults to "Session review" (configurable in settings). "Session review" groups entries by turn: each turn's progress entries and recap sit together, with a collapsible header showing the turn, counts, end time and turn duration; if any of the last N turns (3 by default; configurable under advanced settings) ends on a question or a "next step / you need" line it is marked "Follow up"; finished turns keep that marker while a new turn is running, and the running turn joins the check only after it ends. Switch between Newest first and Oldest first, filter by All / Summaries / Progress / Follow up, refresh every 30 seconds, and confirm before clearing. "Ask aside" stays out of the main context.
|
|
13
13
|
- **Ask aside**: the tab's input is a rounded card like the composer, with a model picker for the aside at the bottom (only the model icon when narrow) and a circular send button on the right. The Q&A stays in the panel: it is not written to the session or the command log, does not enter the model context, and does not change the main session's model.
|
|
14
14
|
- **Reply style**: length **short / standard / detailed**; style **default / professional / friendly / blunt / follow my style**; up to 2000 characters of custom instructions.
|
|
15
15
|
- **Action-first** (on by default): result and next step first; one sentence when one suffices; keeps risks, failure conditions, and work you've already authorized.
|
|
@@ -20,7 +20,7 @@ A small collection of features that reduce the everyday mental load of using DSH
|
|
|
20
20
|
|
|
21
21
|
- DSH Web profile; the plugin depends on the `connection`, `sessions`, and `tools` services.
|
|
22
22
|
- A default model configured. Prediction sends the last few turns to the current default model as a prompt; Ask aside uses the current session model by default and can be switched to another model at the bottom of the panel. None of the three writes to the session log or triggers the agent loop; the Follow up marker only reads the current session's recap entries.
|
|
23
|
-
- The semantic recap starts after the first user turn and updates every turn: it tries your configured cheap-model chain first, then picks a cheap model automatically, then falls back to the current default model; on model failure it falls back to a local short concatenation. The activity feed
|
|
23
|
+
- The semantic recap starts after the first user turn and updates every turn: it tries your configured cheap-model chain first, then picks a cheap model automatically, then falls back to the current default model; on model failure it falls back to a local short concatenation. The activity feed makes no model calls; progress summaries and turn recaps use the same model chain and fall back to local text on failure. Progress entries share `$DSH_HOME/wdx-relief/recaps.json` with summaries, one entry per configured interval (10 minutes by default).
|
|
24
24
|
|
|
25
25
|
## Install
|
|
26
26
|
|
package/README.zh.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
## 功能
|
|
9
9
|
|
|
10
10
|
- **输入框下一句预测**:对话结束后用灰字猜你接下来要发的话,<kbd>Tab</kbd> 填入;打字隐藏,<kbd>Esc</kbd> 忽略。
|
|
11
|
-
- **输入框上的一行**(默认开启):逐轮显示「这一轮在做什么、到哪了」,固定放在输入框上方。新增 **实时进度**:一轮运行超过设置的间隔(默认 10
|
|
12
|
-
- **WDX Relief 页面**(右侧栏,默认开启):和 WDX Git
|
|
11
|
+
- **输入框上的一行**(默认开启):逐轮显示「这一轮在做什么、到哪了」,固定放在输入框上方。新增 **实时进度**:一轮运行超过设置的间隔(默认 10 分钟)还没给你回复时自动出现——即使工具一直在跑、一直在思考,只要没回你话就算——显示第几轮和等待时长;之后按同一间隔往「会话回顾」记一条这个时间窗的**思路摘要**——用便宜模型写成「在解决什么、推进到哪」,动作清单不带命令参数、模型输出里的命令也会被过滤;模型失败时退回本地摘要。行尾的「›」直接打开「会话回顾」并筛出进度记录。语义摘要每轮用一次便宜模型,并在轮次结束时由 Host 兜底生成——切走会话、关掉面板、整页刷新都不会漏这一轮;活动流水本地生成、零模型调用。这一行永不进入模型上下文,生成过的摘要会留在右侧 WDX Relief 面板里。
|
|
12
|
+
- **WDX Relief 页面**(右侧栏,默认开启):和 WDX Git 一样出现在右侧栏的工具列表里;顶栏也有一个并排的图标,点一下直接打开面板。页面用两个 Tab:默认「会话回顾」(可在设置里改成旁问);「会话回顾」按轮次分组:同一轮的进度记录和摘要放在一组,组头显示轮次、条数、结束时间和这一轮时长,可折叠;最近 N 轮(默认 3,可在高级设置里改)里如果某轮停在助手提问、或在末尾留了「下一步 / 需要你」这类待办,会标「待跟进」;正在跑的那一轮要等结束才参与判断,已结束的轮次在运行中也保留标记;顶部可按「全部 / 摘要 / 进度 / 待跟进」筛选,支持「最新在前 / 最早在前」,每 30 秒自动刷新,清空前会再确认一次;「旁问」不进入主上下文。
|
|
13
13
|
- **旁问**:Tab 里的输入框和 composer 一样是圆角卡片,底部可以选旁问专用模型(窄的时候只显示模型图标)、右侧圆形按钮发送;问答只留在面板里,不写会话、不写命令日志,也不进入模型上下文,不改变主会话模型。
|
|
14
14
|
- **回复风格**:长度 **短 / 标准 / 详细**;风格 **默认 / 专业 / 亲和 / 直接 / 跟随我的风格**;可加最多 2000 字的自定义指令。
|
|
15
15
|
- **便于行动**(默认开启):先给结果和下一步;能一句说清的不写一段;保留风险、失败条件和已授权该做的工作。
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
- DSH Web profile;插件依赖 `connection`、`sessions` 与 `tools` 服务。
|
|
22
22
|
- 已配置默认模型。预测会把最近几轮对话作为 prompt 发给当前默认模型;旁问默认用当前会话模型,也可以在面板底部切到别的模型;三者都不写入会话日志、不触发 agent loop;「待跟进」标记只读当前会话的摘要记录。
|
|
23
|
-
- 语义摘要从第 1
|
|
23
|
+
- 语义摘要从第 1 轮用户消息后开始、每轮更新,先按你配置的便宜模型链尝试,再自动挑便宜模型,最后退回当前默认模型;模型失败时退回本地短拼接。活动流水不调用模型;进度摘要和语义摘要共用同一条模型链,模型失败时退回本地摘要。进度记录按设置的间隔(默认 10 分钟)一条,和摘要共用 `$DSH_HOME/wdx-relief/recaps.json`。
|
|
24
24
|
|
|
25
25
|
## 安装
|
|
26
26
|
|
package/client/client.js
CHANGED
|
@@ -163,6 +163,7 @@ window.__ModuleLoader__.load({
|
|
|
163
163
|
'@media (hover:hover){.wdxp-row:hover{background:var(--dsw-alias-interactive-bg-hover)}}',
|
|
164
164
|
'.wdxp-row:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color);outline-offset:-1px}',
|
|
165
165
|
'.wdxp-rowText{overflow-wrap:anywhere;white-space:normal;flex:1;min-width:0;font-size:13px;line-height:19px}',
|
|
166
|
+
'.wdxp-rowInterval{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums;flex:none;padding-left:4px;font-size:10px;line-height:19px}',
|
|
166
167
|
'.wdxp-rowMeta{color:var(--dsw-alias-label-caption);white-space:nowrap;font-variant-numeric:tabular-nums;flex:none;font-size:11px;line-height:19px}',
|
|
167
168
|
'.wdxp-note{color:var(--dsw-alias-label-tertiary);align-items:center;gap:6px;margin:2px 0 0;font-size:12px;line-height:18px;display:flex}',
|
|
168
169
|
'.wdxp-link{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:0;padding:0;font:inherit;font-size:12px;line-height:18px;text-decoration:underline;align-self:flex-start;text-align:left}',
|
|
@@ -200,6 +201,14 @@ window.__ModuleLoader__.load({
|
|
|
200
201
|
'.wdxp-skeletonRow{height:38px;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-skeleton)}',
|
|
201
202
|
].join('')
|
|
202
203
|
|
|
204
|
+
// 顶栏入口只挂 4 条规则,不跟着面板一起重复注入整份 CSS。
|
|
205
|
+
var HEADER_CSS = [
|
|
206
|
+
'.wdxr-headerBtn{width:26px;height:26px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background .14s,color .14s}',
|
|
207
|
+
'@media (hover:hover){.wdxr-headerBtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}',
|
|
208
|
+
'.wdxr-headerBtn:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
|
|
209
|
+
'.wdxr-headerBtn svg{display:block}',
|
|
210
|
+
].join('')
|
|
211
|
+
|
|
203
212
|
function PluginStyles(props) {
|
|
204
213
|
var scope = props && props.scope ? ':' + props.scope : ''
|
|
205
214
|
return h('style', { 'data-plugin-css': NS + scope }, CSS)
|
|
@@ -306,6 +315,7 @@ window.__ModuleLoader__.load({
|
|
|
306
315
|
'settings.defaultTab.btw': '旁问',
|
|
307
316
|
'panel.title': 'WDX Relief',
|
|
308
317
|
'panel.guide': '按轮次看进度与摘要,也可以随手旁问',
|
|
318
|
+
'panel.open': '打开 WDX Relief:会话回顾 / 旁问',
|
|
309
319
|
'panel.refresh': '刷新',
|
|
310
320
|
'section.recaps': '会话回顾',
|
|
311
321
|
'panel.recapEmpty': '还没有生成过摘要或进度记录;聊过一轮,或一轮跑久了还没回复时就会出现',
|
|
@@ -351,8 +361,13 @@ window.__ModuleLoader__.load({
|
|
|
351
361
|
'progress.quietLabel': '未回复',
|
|
352
362
|
'progress.elapsedLabel': '总耗时',
|
|
353
363
|
'progress.stepsLabel': '步数',
|
|
354
|
-
'progress.
|
|
355
|
-
'progress.
|
|
364
|
+
'progress.interval': '第 {from}–{to} 分',
|
|
365
|
+
'progress.intervalOne': '第 {minute} 分',
|
|
366
|
+
'progress.intervalLabel': '时间窗',
|
|
367
|
+
'progress.doing': '在{actions}',
|
|
368
|
+
'progress.actions': '本段动作',
|
|
369
|
+
'progress.noOutput': '这段时间没有新输出',
|
|
370
|
+
'progress.command': '运行命令',
|
|
356
371
|
'progress.open': '查看进度',
|
|
357
372
|
'section.btw': '旁问',
|
|
358
373
|
'btw.placeholder': '问点什么…',
|
|
@@ -480,6 +495,7 @@ window.__ModuleLoader__.load({
|
|
|
480
495
|
'settings.defaultTab.btw': 'Aside',
|
|
481
496
|
'panel.title': 'WDX Relief',
|
|
482
497
|
'panel.guide': 'Review per-turn progress and recaps, and ask aside',
|
|
498
|
+
'panel.open': 'Open WDX Relief: session review / aside',
|
|
483
499
|
'panel.refresh': 'Refresh',
|
|
484
500
|
'section.recaps': 'Recaps',
|
|
485
501
|
'panel.recapEmpty': 'No summary or progress yet; one appears after the first turn, or when a turn runs long without replying',
|
|
@@ -525,8 +541,13 @@ window.__ModuleLoader__.load({
|
|
|
525
541
|
'progress.quietLabel': 'No reply yet',
|
|
526
542
|
'progress.elapsedLabel': 'Elapsed',
|
|
527
543
|
'progress.stepsLabel': 'Steps',
|
|
528
|
-
'progress.
|
|
529
|
-
'progress.
|
|
544
|
+
'progress.interval': 'min {from}–{to}',
|
|
545
|
+
'progress.intervalOne': 'min {minute}',
|
|
546
|
+
'progress.intervalLabel': 'Window',
|
|
547
|
+
'progress.doing': 'Working on {actions}',
|
|
548
|
+
'progress.actions': 'Actions',
|
|
549
|
+
'progress.noOutput': 'No new output in this window',
|
|
550
|
+
'progress.command': 'Run command',
|
|
530
551
|
'progress.open': 'View progress',
|
|
531
552
|
'section.btw': 'Aside',
|
|
532
553
|
'btw.placeholder': 'Ask anything…',
|
|
@@ -740,6 +761,33 @@ window.__ModuleLoader__.load({
|
|
|
740
761
|
return (date.getMonth() + 1) + '/' + date.getDate() + ' ' + clock
|
|
741
762
|
}
|
|
742
763
|
|
|
764
|
+
/** 进度条目覆盖的累计时间窗:「第 1–20 分」。旧记录没有 windowMs 时返回空。 */
|
|
765
|
+
function progressIntervalText(item, t) {
|
|
766
|
+
var bucket = Number(item && item.bucket)
|
|
767
|
+
var windowMs = Number(item && item.windowMs)
|
|
768
|
+
var turnStartedAt = Number(item && item.turnStartedAt)
|
|
769
|
+
var windowFromMs = Number(item && item.windowFromMs)
|
|
770
|
+
var windowToMs = Number(item && item.windowToMs)
|
|
771
|
+
|
|
772
|
+
var from = 0
|
|
773
|
+
var to = 0
|
|
774
|
+
var anchor = Number(item && item.anchor)
|
|
775
|
+
if (turnStartedAt > 0 && windowFromMs >= turnStartedAt && windowToMs > windowFromMs) {
|
|
776
|
+
// 时间窗落在本轮里的哪几分钟;中途回复过或跳档时也准确。
|
|
777
|
+
from = Math.max(1, Math.floor((windowFromMs - turnStartedAt) / 60000) + 1)
|
|
778
|
+
to = Math.max(from, Math.ceil((windowToMs - turnStartedAt) / 60000))
|
|
779
|
+
// 从本轮开始就一直没回复:第 2 条按累计口径显示「1–20 分」。
|
|
780
|
+
if (anchor === turnStartedAt) from = 1
|
|
781
|
+
} else if (isFinite(windowMs) && windowMs >= 1000 && isFinite(bucket) && bucket >= 1) {
|
|
782
|
+
var span = Math.max(1, Math.round(windowMs / 60000))
|
|
783
|
+
from = 1
|
|
784
|
+
to = bucket * span
|
|
785
|
+
}
|
|
786
|
+
if (to < 1) return ''
|
|
787
|
+
if (from === to) return trf(t, 'progress.intervalOne', { minute: to }, '第 ' + to + ' 分')
|
|
788
|
+
return trf(t, 'progress.interval', { from: from, to: to }, '第 ' + from + '–' + to + ' 分')
|
|
789
|
+
}
|
|
790
|
+
|
|
743
791
|
// ---------------------------------------------------------- prediction
|
|
744
792
|
|
|
745
793
|
/**
|
|
@@ -1034,6 +1082,13 @@ window.__ModuleLoader__.load({
|
|
|
1034
1082
|
return value.slice(0, maxChars).trim() + '…'
|
|
1035
1083
|
}
|
|
1036
1084
|
|
|
1085
|
+
/** 长思考保留最近的尾部:越靠后越接近当前进展。 */
|
|
1086
|
+
function clipTextTail(text, maxChars) {
|
|
1087
|
+
var value = String(text === undefined || text === null ? '' : text).replace(/\s+/g, ' ').trim()
|
|
1088
|
+
if (value.length <= maxChars) return value
|
|
1089
|
+
return '…' + value.slice(-maxChars).trim()
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1037
1092
|
function baseName(path) {
|
|
1038
1093
|
var value = String(path || '').replace(/[\\/]+$/u, '')
|
|
1039
1094
|
var parts = value.split(/[\\/]/u)
|
|
@@ -1090,6 +1145,8 @@ window.__ModuleLoader__.load({
|
|
|
1090
1145
|
|
|
1091
1146
|
function toolLabel(tool, t) {
|
|
1092
1147
|
if (!tool) return ''
|
|
1148
|
+
// 命令的目标就是脚本参数,活动和进度都只保留「运行命令」。
|
|
1149
|
+
if (tool.verb === 'command') return tr(t, 'progress.command', '运行命令')
|
|
1093
1150
|
var verb = tr(t, 'turn.verb.' + tool.verb, tool.verb === 'other' ? '调用' : tool.verb)
|
|
1094
1151
|
return tool.target ? verb + ' ' + tool.target : verb
|
|
1095
1152
|
}
|
|
@@ -1451,24 +1508,156 @@ window.__ModuleLoader__.load({
|
|
|
1451
1508
|
}
|
|
1452
1509
|
|
|
1453
1510
|
/**
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1511
|
+
* 只看与「当前轮 + 当前时间窗」相交的事件,并把这段时间压成
|
|
1512
|
+
* 叙述摘要的输入:思考片段和去参数的动作。
|
|
1513
|
+
* 命令的目标就是脚本参数,这里只保留动词;读写文件保留文件名。
|
|
1456
1514
|
*/
|
|
1457
|
-
function
|
|
1515
|
+
function collectProgressDigest(entries, view, bucket, windowMs) {
|
|
1516
|
+
var span = Math.max(1, Number(windowMs) || 1)
|
|
1517
|
+
var turn = view && typeof view.turn === 'number' ? view.turn : 0
|
|
1518
|
+
var anchorTime = view && typeof view.lastReplyAt === 'number' ? view.lastReplyAt : 0
|
|
1519
|
+
var from = anchorTime + Math.max(0, bucket - 1) * span
|
|
1520
|
+
var to = anchorTime + bucket * span
|
|
1521
|
+
var empty = { from: from, to: to, windowMs: span, reasoning: '', actions: [] }
|
|
1522
|
+
if (turn === 0) return empty
|
|
1523
|
+
|
|
1524
|
+
var reasoning = ''
|
|
1525
|
+
var actions = []
|
|
1526
|
+
var list = Array.isArray(entries) ? entries : []
|
|
1527
|
+
for (var index = 0; index < list.length; index += 1) {
|
|
1528
|
+
var event = eventOf(list[index])
|
|
1529
|
+
if (!event || eventTurn(event) !== turn) continue
|
|
1530
|
+
var time = typeof event.time === 'number' ? event.time : 0
|
|
1531
|
+
if (time < from || time >= to) continue
|
|
1532
|
+
var data = objectOf(event.data)
|
|
1533
|
+
|
|
1534
|
+
if (event.type === 'assistant/live-chunk') {
|
|
1535
|
+
var chunk = objectOf(data.chunk)
|
|
1536
|
+
if (chunk.type === 'reasoning-delta') reasoning += String(chunk.text || '')
|
|
1537
|
+
continue
|
|
1538
|
+
}
|
|
1539
|
+
if (event.type === 'assistant/message') {
|
|
1540
|
+
var message = objectOf(data.message)
|
|
1541
|
+
var contentReasoning = reasoningFromContent(message.content)
|
|
1542
|
+
if (contentReasoning !== '') {
|
|
1543
|
+
// 同一步可能既有 live-chunk 又有完整 message:忽略空白差异后能互相包含时
|
|
1544
|
+
// 只留更全的一份,不同步骤的思考则追加,不能因为窗口里已有思考就整段丢弃。
|
|
1545
|
+
if (reasoning === '') reasoning = contentReasoning
|
|
1546
|
+
else {
|
|
1547
|
+
var normalizedReasoning = reasoning.replace(/\s+/gu, '')
|
|
1548
|
+
var normalizedContent = contentReasoning.replace(/\s+/gu, '')
|
|
1549
|
+
if (normalizedReasoning.indexOf(normalizedContent) === -1) {
|
|
1550
|
+
reasoning = normalizedContent.indexOf(normalizedReasoning) !== -1
|
|
1551
|
+
? contentReasoning
|
|
1552
|
+
: reasoning + '\n' + contentReasoning
|
|
1553
|
+
} else if (normalizedContent.length > normalizedReasoning.length) {
|
|
1554
|
+
reasoning = contentReasoning
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
continue
|
|
1559
|
+
}
|
|
1560
|
+
if (event.type === 'tool/call') {
|
|
1561
|
+
var described = describeToolCall(data.name, data.arguments)
|
|
1562
|
+
var keepTarget = described.verb !== 'command' && described.verb !== 'search' && described.verb !== 'web'
|
|
1563
|
+
var target = keepTarget ? described.target : ''
|
|
1564
|
+
var found = null
|
|
1565
|
+
for (var actionIndex = 0; actionIndex < actions.length; actionIndex += 1) {
|
|
1566
|
+
if (actions[actionIndex].verb === described.verb && actions[actionIndex].target === target) {
|
|
1567
|
+
found = actions[actionIndex]
|
|
1568
|
+
break
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
if (found === null) actions.push({ verb: described.verb, target: target, count: 1 })
|
|
1572
|
+
else found.count += 1
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return {
|
|
1576
|
+
from: from,
|
|
1577
|
+
to: to,
|
|
1578
|
+
windowMs: span,
|
|
1579
|
+
reasoning: clipTextTail(reasoning, 6000),
|
|
1580
|
+
actions: actions,
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function progressActionLabels(digest, t) {
|
|
1585
|
+
var labels = []
|
|
1586
|
+
var actions = digest && Array.isArray(digest.actions) ? digest.actions : []
|
|
1587
|
+
for (var index = 0; index < actions.length; index += 1) {
|
|
1588
|
+
var action = actions[index]
|
|
1589
|
+
var label = toolLabel({ verb: action.verb, target: action.target }, t)
|
|
1590
|
+
if (label === '') continue
|
|
1591
|
+
if (action.count > 1) label += ' ×' + action.count
|
|
1592
|
+
labels.push(label)
|
|
1593
|
+
}
|
|
1594
|
+
return labels
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/** 本地兜底也要避开命令句,否则模型摘要被拦下后仍会显示脚本参数。 */
|
|
1598
|
+
function containsCommandText(text) {
|
|
1599
|
+
return /\/Users\/|\/home\/|\s--[A-Za-z][\w-]*|`[^`]+`/u.test(String(text || ''))
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/** 模型失败时的本地兜底:思考片段里第一句不含命令的话 > 这段在做什么动作。 */
|
|
1603
|
+
function progressLocalSummary(digest, actions, t) {
|
|
1604
|
+
var reasoning = String((digest && digest.reasoning) || '')
|
|
1605
|
+
.replace(/<[^>]*signature[^>]*>/gu, ' ')
|
|
1606
|
+
.replace(/\s+/gu, ' ')
|
|
1607
|
+
.trim()
|
|
1608
|
+
if (reasoning !== '') {
|
|
1609
|
+
var sentences = reasoning.match(/[^。!?!?]{6,}[。!?!?]/gu) || [reasoning]
|
|
1610
|
+
for (var index = 0; index < sentences.length; index += 1) {
|
|
1611
|
+
if (!containsCommandText(sentences[index])) return clipText(sentences[index], 160)
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
if (actions.length > 0) {
|
|
1615
|
+
return trf(t, 'progress.doing', { actions: actions.slice(0, 3).join('、') }, '在' + actions.slice(0, 3).join('、'))
|
|
1616
|
+
}
|
|
1617
|
+
return tr(t, 'progress.noOutput', '这段时间没有新输出')
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/** DSH 会把当前语言同步到 <html lang>;只区分中英文,和插件字典一致。 */
|
|
1621
|
+
function activeUiLang() {
|
|
1622
|
+
try {
|
|
1623
|
+
var lang = document && document.documentElement ? String(document.documentElement.lang || '') : ''
|
|
1624
|
+
if (lang === '' && typeof navigator !== 'undefined') lang = String(navigator.language || '')
|
|
1625
|
+
if (lang !== '') return lang.toLowerCase().indexOf('zh') === 0 ? 'zh' : 'en'
|
|
1626
|
+
} catch (error) {
|
|
1627
|
+
// 非浏览器环境按中文处理。
|
|
1628
|
+
}
|
|
1629
|
+
return 'zh'
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* 运行中的进度快照:每 `stallMs` 没给用户回复记一条。
|
|
1634
|
+
* 摘要写「这 10 分钟的思路和进展」,不再罗列命令;真正的模型摘要由
|
|
1635
|
+
* Host 的 progress 路由生成,这里只带时间窗和思考片段过去。
|
|
1636
|
+
*/
|
|
1637
|
+
function progressEntryOf(view, settings, t, entries, lang) {
|
|
1458
1638
|
var bucket = Math.max(1, Math.floor(view.quietMs / settings.stallMs))
|
|
1459
|
-
var
|
|
1460
|
-
var
|
|
1461
|
-
var
|
|
1639
|
+
var windowMs = settings.stallMs
|
|
1640
|
+
var digest = collectProgressDigest(entries, view, bucket, windowMs)
|
|
1641
|
+
var actions = progressActionLabels(digest, t)
|
|
1462
1642
|
return {
|
|
1463
1643
|
turn: view.turn,
|
|
1464
1644
|
bucket: bucket,
|
|
1465
1645
|
// 锚点跟着「上一次回复」走:同一次等待、同一个档位只记一条。
|
|
1466
1646
|
anchor: typeof view.lastReplyAt === 'number' ? view.lastReplyAt : 0,
|
|
1467
1647
|
status: 'stalled',
|
|
1468
|
-
summary:
|
|
1469
|
-
activity:
|
|
1648
|
+
summary: progressLocalSummary(digest, actions, t),
|
|
1649
|
+
activity: actions.join(';'),
|
|
1650
|
+
digest: {
|
|
1651
|
+
reasoning: digest.reasoning,
|
|
1652
|
+
actions: actions,
|
|
1653
|
+
},
|
|
1654
|
+
lang: lang === 'en' ? 'en' : 'zh',
|
|
1655
|
+
windowMs: windowMs,
|
|
1656
|
+
windowFromMs: digest.from,
|
|
1657
|
+
windowToMs: digest.to,
|
|
1658
|
+
turnStartedAt: typeof view.startedAt === 'number' ? view.startedAt : 0,
|
|
1470
1659
|
elapsedMs: view.elapsedMs,
|
|
1471
|
-
silenceMs: bucket *
|
|
1660
|
+
silenceMs: bucket * windowMs,
|
|
1472
1661
|
steps: view.steps,
|
|
1473
1662
|
at: Date.now(),
|
|
1474
1663
|
}
|
|
@@ -1597,7 +1786,7 @@ window.__ModuleLoader__.load({
|
|
|
1597
1786
|
var key = view.turn + ':' + view.lastReplyAt + ':' + progressBucket
|
|
1598
1787
|
if (reportedBuckets.current[key] === true) return
|
|
1599
1788
|
reportedBuckets.current[key] = true
|
|
1600
|
-
requestProgress(sessionId, progressEntryOf(view, cfg, t)).catch(function () {
|
|
1789
|
+
requestProgress(sessionId, progressEntryOf(view, cfg, t, entries, activeUiLang())).catch(function () {
|
|
1601
1790
|
// 失败不重试;下一个间隔继续。
|
|
1602
1791
|
})
|
|
1603
1792
|
}, [progressBucket, sessionId, view.turn, view.lastReplyAt])
|
|
@@ -2142,11 +2331,16 @@ window.__ModuleLoader__.load({
|
|
|
2142
2331
|
function progressDetail(item) {
|
|
2143
2332
|
var elapsed = formatDuration(item.elapsedMs, t)
|
|
2144
2333
|
var silence = formatDuration(item.silenceMs, t)
|
|
2334
|
+
var interval = progressIntervalText(item, t)
|
|
2145
2335
|
return h('div', { key: 'detail', className: 'wdxh-detail' }, [
|
|
2146
2336
|
typeof item.turn === 'number' ? h('p', { key: 'turn', className: 'wdxh-line' }, [
|
|
2147
2337
|
h('span', { key: 'label', className: 'wdxh-label' }, tr(t, 'progress.turnLabel', '轮次')),
|
|
2148
2338
|
trf(t, 'progress.turn', { turn: item.turn }, '第 ' + item.turn + ' 轮'),
|
|
2149
2339
|
]) : null,
|
|
2340
|
+
interval !== '' ? h('p', { key: 'interval', className: 'wdxh-line' }, [
|
|
2341
|
+
h('span', { key: 'label', className: 'wdxh-label' }, tr(t, 'progress.intervalLabel', '时间窗')),
|
|
2342
|
+
interval,
|
|
2343
|
+
]) : null,
|
|
2150
2344
|
h('p', { key: 'elapsed', className: 'wdxh-line' }, [
|
|
2151
2345
|
h('span', { key: 'label', className: 'wdxh-label' }, tr(t, 'progress.elapsedLabel', '总耗时')),
|
|
2152
2346
|
elapsed,
|
|
@@ -2160,7 +2354,7 @@ window.__ModuleLoader__.load({
|
|
|
2160
2354
|
String(item.steps),
|
|
2161
2355
|
]) : null,
|
|
2162
2356
|
item.activity ? h('p', { key: 'activity', className: 'wdxh-line' }, [
|
|
2163
|
-
h('span', { key: 'label', className: 'wdxh-label' }, tr(t, 'progress.
|
|
2357
|
+
h('span', { key: 'label', className: 'wdxh-label' }, tr(t, 'progress.actions', '本段动作')),
|
|
2164
2358
|
item.activity,
|
|
2165
2359
|
]) : null,
|
|
2166
2360
|
])
|
|
@@ -2187,6 +2381,7 @@ window.__ModuleLoader__.load({
|
|
|
2187
2381
|
var key = recapItemKey(item)
|
|
2188
2382
|
var open = openKey === key
|
|
2189
2383
|
var isProgress = item.kind === 'progress'
|
|
2384
|
+
var interval = isProgress ? progressIntervalText(item, t) : ''
|
|
2190
2385
|
return h('li', { key: key, className: 'wdxp-item' }, [
|
|
2191
2386
|
h('button', {
|
|
2192
2387
|
key: 'row',
|
|
@@ -2202,6 +2397,7 @@ window.__ModuleLoader__.load({
|
|
|
2202
2397
|
? tr(t, 'panel.recapTagLocal', '本地摘要')
|
|
2203
2398
|
: tr(t, 'panel.recapTagSummary', '摘要'))),
|
|
2204
2399
|
h('span', { key: 'text', className: 'wdxp-rowText' }, item.summary),
|
|
2400
|
+
interval !== '' ? h('span', { key: 'interval', className: 'wdxp-rowInterval' }, interval) : null,
|
|
2205
2401
|
h('span', { key: 'time', className: 'wdxp-rowMeta' }, formatRecapTime(item.at)),
|
|
2206
2402
|
]),
|
|
2207
2403
|
open ? (isProgress ? progressDetail(item) : recapDetail(item)) : null,
|
|
@@ -3338,18 +3534,37 @@ window.__ModuleLoader__.load({
|
|
|
3338
3534
|
|
|
3339
3535
|
var boundT = typeof ctx.locale.bind === 'function' ? ctx.locale.bind(NS) : function (key) { return key }
|
|
3340
3536
|
|
|
3341
|
-
/**
|
|
3342
|
-
function
|
|
3537
|
+
/** 打开右侧 WDX Relief 面板;params 可选,用来落到指定筛选。 */
|
|
3538
|
+
function openReliefTab(params) {
|
|
3343
3539
|
try {
|
|
3344
3540
|
var sidebar = ctx.sidebarRight || (typeof ctx.get === 'function' ? ctx.get('sidebarRight') : undefined)
|
|
3345
3541
|
if (sidebar && typeof sidebar.openTab === 'function') {
|
|
3346
|
-
sidebar.openTab(RELIEF_TAB, { params:
|
|
3542
|
+
sidebar.openTab(RELIEF_TAB, params ? { params: params } : undefined)
|
|
3347
3543
|
}
|
|
3348
3544
|
} catch (error) {
|
|
3349
|
-
console.warn('[wdx-relief] open
|
|
3545
|
+
console.warn('[wdx-relief] open panel failed', error)
|
|
3350
3546
|
}
|
|
3351
3547
|
}
|
|
3352
3548
|
|
|
3549
|
+
/** 从输入框上方那一行跳到「会话回顾」并筛选出进度记录。 */
|
|
3550
|
+
function openProgressTab() {
|
|
3551
|
+
openReliefTab({ wdxReliefTab: 'recaps', wdxRecapFilter: 'progress' })
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
/** 顶栏入口:和 wdx-git 的按钮并排,点一下打开右侧面板。 */
|
|
3555
|
+
function HeaderReliefButton() {
|
|
3556
|
+
var label = boundT('panel.open')
|
|
3557
|
+
return h(React.Fragment, null,
|
|
3558
|
+
h('style', { key: 'wdx-relief-header-css', 'data-plugin-css': NS + ':header' }, HEADER_CSS),
|
|
3559
|
+
h('button', {
|
|
3560
|
+
type: 'button',
|
|
3561
|
+
className: 'wdxr-headerBtn',
|
|
3562
|
+
title: label,
|
|
3563
|
+
'aria-label': label,
|
|
3564
|
+
onClick: function () { openReliefTab() },
|
|
3565
|
+
}, h(ReliefIcon, { size: 16 })))
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3353
3568
|
ctx.effect(function () {
|
|
3354
3569
|
return ctx.sidebarRightTabs.register({
|
|
3355
3570
|
id: RELIEF_TAB,
|
|
@@ -3366,6 +3581,16 @@ window.__ModuleLoader__.load({
|
|
|
3366
3581
|
})
|
|
3367
3582
|
}, 'wdx-relief: sidebar page')
|
|
3368
3583
|
|
|
3584
|
+
// 顶栏按钮:order 12 紧跟在 wdx-git 的 11 后面。
|
|
3585
|
+
ctx.slots.inject('conversation.session.header.utilities', function () {
|
|
3586
|
+
return ctx.slots.register({
|
|
3587
|
+
name: 'conversation.session.header.utilities',
|
|
3588
|
+
id: 'wdx-relief',
|
|
3589
|
+
order: 12,
|
|
3590
|
+
label: function () { return boundT('panel.open') },
|
|
3591
|
+
}, HeaderReliefButton)
|
|
3592
|
+
})
|
|
3593
|
+
|
|
3369
3594
|
ctx.slots.inject('sidebar.right.pane.tab', function () {
|
|
3370
3595
|
return ctx.slots.register({
|
|
3371
3596
|
name: 'sidebar.right.pane.tab',
|
|
@@ -3489,6 +3714,8 @@ window.__ModuleLoader__.load({
|
|
|
3489
3714
|
exports.lineSettings = lineSettings
|
|
3490
3715
|
exports.groupRecapEntries = groupRecapEntries
|
|
3491
3716
|
exports.progressEntryOf = progressEntryOf
|
|
3717
|
+
exports.collectProgressDigest = collectProgressDigest
|
|
3718
|
+
exports.progressIntervalText = progressIntervalText
|
|
3492
3719
|
exports.turnStatusInfo = turnStatusInfo
|
|
3493
3720
|
exports.buildTurnSegments = buildTurnSegments
|
|
3494
3721
|
exports.activityText = activityText
|
package/docs/DETAIL.md
CHANGED
|
@@ -14,7 +14,7 @@ After a turn, grey text in the composer guesses what you are about to send. Pres
|
|
|
14
14
|
|
|
15
15
|
A per-turn line that answers "what is this turn doing, and where is it", always above the composer:
|
|
16
16
|
|
|
17
|
-
- **Live progress** (on by default): after the configured interval without a reply to you (10 minutes by default), the line appears automatically with the turn number
|
|
17
|
+
- **Live progress** (on by default): after the configured interval without a reply to you (10 minutes by default), the line appears automatically with the turn number and waiting time; from then on it records one idea summary per interval in Session review — a cheap model writes what that window was solving and how far it got, with commands and parameters left out, and on failure the client-local summary is kept. Tool calls and reasoning only refresh the "no output" check; they are not replies and do not reset this timer. A status chip — running / no output / done / cancelled — keeps it distinct from the finished recap.
|
|
18
18
|
- **Semantic recap** (on by default): a cheap model summarizes the latest turn every turn. The Host takes the snapshot and generates it at `turn/end`, so a turn is recorded even when the panel is closed, you switched sessions, or the page reloaded; a client request for the same turn shares that one model call.
|
|
19
19
|
- **Activity feed**: generated locally with zero model calls, off by default.
|
|
20
20
|
|
|
@@ -22,9 +22,9 @@ The line never enters the model context; recaps and progress entries are kept in
|
|
|
22
22
|
|
|
23
23
|
### WDX Relief panel
|
|
24
24
|
|
|
25
|
-
A right-sidebar page with two tabs, defaulting to Session review (configurable):
|
|
25
|
+
A right-sidebar page with two tabs, defaulting to Session review (configurable); the session-header icon (next to WDX Git) opens it directly:
|
|
26
26
|
|
|
27
|
-
- **Session review**: entries grouped by turn, with each turn's progress entries and recap together; the collapsible header shows the turn, counts, end time and turn duration. If any of the last N turns (3 by default, configurable under advanced settings) ends on a question or a "next step / you need" line, the group is marked "Follow up" and the filter can show only those turns. Switch between Newest first and Oldest first; filter by All / Summaries / Progress / Follow up; refresh every 30 seconds; confirm before clearing.
|
|
27
|
+
- **Session review**: entries grouped by turn, with each turn's progress entries and recap together; the collapsible header shows the turn, counts, end time and turn duration. If any of the last N turns (3 by default, configurable under advanced settings) ends on a question or a "next step / you need" line, the group is marked "Follow up" and the filter can show only those turns. Switch between Newest first and Oldest first; filter by All / Summaries / Progress / Follow up; refresh every 30 seconds; confirm before clearing. Each progress row shows the cumulative window (the second entry reads "min 1–20"); the idea summary is written by the Host with a cheap model, falling back to the client-local summary when the model fails.
|
|
28
28
|
- **Ask aside**: a composer-style card with its own model picker. The Q&A stays in the panel — not in the session, not in the command log, not in the model context, and it does not change the main session model.
|
|
29
29
|
|
|
30
30
|
### Reply style
|
|
@@ -50,7 +50,7 @@ In the DSH sidebar, go to **Plugins → Add plugin**, enter `dsh-wdx-relief`, th
|
|
|
50
50
|
## Requirements and limits
|
|
51
51
|
|
|
52
52
|
- DSH Web profile; the plugin depends on the `connection`, `sessions`, and `tools` services.
|
|
53
|
-
- A default model must be configured. Prediction, the semantic recap, and Ask aside make model calls; the activity feed
|
|
53
|
+
- A default model must be configured. Prediction, the semantic recap, progress summaries, and Ask aside make model calls; the activity feed and the Follow up marker do not. The tool-call guard is zero-cost until it fires, then costs at most one extra model step (bounded by the correction limit).
|
|
54
54
|
- Reply style is a soft prompt constraint, not a hard length limit.
|
|
55
55
|
- Recaps are stored locally in `$DSH_HOME/wdx-relief/recaps.json` (up to 300 entries); Clear in the panel also drops the current-turn cache, and deleting the file clears the history.
|
|
56
56
|
- Ask aside keeps answers in panel memory only; closing the panel or switching sessions clears them.
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -14,7 +14,7 @@ WDX Relief 降低 DeepSeek Harness 的日常使用摩擦。八个功能,全部
|
|
|
14
14
|
|
|
15
15
|
逐轮显示「这一轮在做什么、到哪了」,固定放在输入框上方:
|
|
16
16
|
|
|
17
|
-
- **实时进度**(默认开启):一轮运行超过设置的间隔(默认 10
|
|
17
|
+
- **实时进度**(默认开启):一轮运行超过设置的间隔(默认 10 分钟)还没给用户回复时自动出现,显示第几轮和等待时长;之后按同一间隔往「会话回顾」记一条这个时间窗的思路摘要(用便宜模型写成,命令参数不进去,失败退回本地摘要)。工具调用、思考只刷新「无新输出」判断,不算回复,不会重置这个计时。「进行中 / 无新输出 / 已完成 / 已取消」状态条和完成后的摘要用不同样式区分。
|
|
18
18
|
- **语义摘要**(默认开启):每轮用一次便宜模型概括最近一轮;快照与生成都在 Host 的 `turn/end` 上完成,面板没开或切走会话也不会漏。
|
|
19
19
|
- **活动流水**:本地生成、零模型调用,默认关闭。
|
|
20
20
|
|
|
@@ -22,9 +22,9 @@ WDX Relief 降低 DeepSeek Harness 的日常使用摩擦。八个功能,全部
|
|
|
22
22
|
|
|
23
23
|
### WDX Relief 页面
|
|
24
24
|
|
|
25
|
-
右侧栏页面,两个 Tab
|
|
25
|
+
右侧栏页面,两个 Tab,默认显示「会话回顾」(可在设置里改成旁问);会话顶栏的图标(紧跟 WDX Git)也能直接打开它:
|
|
26
26
|
|
|
27
|
-
- **会话回顾**:按轮次分组,同一轮的进度记录和摘要放在一起;组头显示轮次、条数、结束时间和这一轮时长,可展开/折叠;最近 N 轮(默认 3,高级设置可改)里如果某轮停在助手提问、或末尾有「下一步 / 需要你」这类待办,组头标「待跟进」,顶部的「待跟进」筛选只看这些轮次。支持「最新在前 / 最早在前」;顶部按「全部 / 摘要 / 进度 / 待跟进」筛选,每 30
|
|
27
|
+
- **会话回顾**:按轮次分组,同一轮的进度记录和摘要放在一起;组头显示轮次、条数、结束时间和这一轮时长,可展开/折叠;最近 N 轮(默认 3,高级设置可改)里如果某轮停在助手提问、或末尾有「下一步 / 需要你」这类待办,组头标「待跟进」,顶部的「待跟进」筛选只看这些轮次。支持「最新在前 / 最早在前」;顶部按「全部 / 摘要 / 进度 / 待跟进」筛选,每 30 秒自动刷新,清空前会再确认一次。进度记录只读本地事件;累计时间窗(第 2 条是「第 1–20 分」)的思路摘要由 Host 用便宜模型写成,模型失败时退回本地摘要。
|
|
28
28
|
- **旁问**:和 composer 一样的圆角卡片,底部可以选旁问专用模型。问答只留在面板里——不写会话、不写命令日志、不进入模型上下文,也不改变主会话模型。
|
|
29
29
|
|
|
30
30
|
### 回复风格
|
|
@@ -50,7 +50,7 @@ WDX Relief 降低 DeepSeek Harness 的日常使用摩擦。八个功能,全部
|
|
|
50
50
|
## 运行要求与限制
|
|
51
51
|
|
|
52
52
|
- DSH Web profile;插件依赖 `connection`、`sessions` 与 `tools` 服务。
|
|
53
|
-
-
|
|
53
|
+
- 需要配置默认模型。预测、语义摘要、进度摘要、旁问会调用模型;活动流水和「待跟进」标记不调用。进度记录按设置的间隔(默认 10 分钟)一条,和摘要共用 `$DSH_HOME/wdx-relief/recaps.json`。工具调用守卫平时零开销,触发时最多多一次模型步(受纠正次数上限约束)。
|
|
54
54
|
- 回复风格是 prompt 软约束,不是硬性长度截断。
|
|
55
55
|
- 摘要存放在本地 `$DSH_HOME/wdx-relief/recaps.json`(最多 300 条);在面板里点「清空」会同时丢掉当轮缓存,直接删除该文件也能清空历史。
|
|
56
56
|
- 旁问回答只存在面板内存里;关闭面板或切换会话即清空。
|
package/docs/guide.md
CHANGED
|
@@ -32,7 +32,7 @@ HMR 生效。
|
|
|
32
32
|
|---|---|---|
|
|
33
33
|
| `enabled` | `true` | 输入框预测开关 |
|
|
34
34
|
| `recap` | `true` | 语义摘要开关:每轮用一次便宜模型写「现在到哪」 |
|
|
35
|
-
| `recapProgress` | `true` | 实时进度开关:按设置的间隔(默认 10
|
|
35
|
+
| `recapProgress` | `true` | 实时进度开关:按设置的间隔(默认 10 分钟)把一条这个时间窗的思路摘要合并进「会话回顾」;用便宜模型写成,失败退回本地摘要 |
|
|
36
36
|
| `recapStallSeconds` | `600` | 进度记录间隔(秒),60–3600 |
|
|
37
37
|
| `pendingTurns` | `3` | 「待跟进」窗口:最近 N 轮,1–20;高级设置 |
|
|
38
38
|
| `recapActivity` | `false` | 活动流水开关:读文件 / 跑命令 / 改代码,本地生成 |
|
|
@@ -94,7 +94,7 @@ bundle 层只声明入口和输入层的开关,其余字段由 schema 默认
|
|
|
94
94
|
| 活动流水 | 同一窗口里的 `tool/call`、`tool/result`、步骤事件 | 本地,零调用 |
|
|
95
95
|
| 语义摘要 | `POST /api/wdx-relief/recap`,Host 用便宜模型概括最近一轮 | 每轮一次便宜模型 |
|
|
96
96
|
|
|
97
|
-
状态条把四种情况分开:进行中(蓝色脉冲点)、无新输出(警示色,超过阈值且连事件都没有)、已完成(灰色对勾)、已取消 / 出错 / 已中断。进度记录看的是「距上一次给用户的正文回复多久」:工具调用和思考不会重置这个计时,所以一直跑工具、一直思考也会在 10
|
|
97
|
+
状态条把四种情况分开:进行中(蓝色脉冲点)、无新输出(警示色,超过阈值且连事件都没有)、已完成(灰色对勾)、已取消 / 出错 / 已中断。进度记录看的是「距上一次给用户的正文回复多久」:工具调用和思考不会重置这个计时,所以一直跑工具、一直思考也会在 10 分钟时记一条这个时间窗的思路摘要。这一行出现后会钉住到本轮结束;状态条仍按实时事件判断,事件恢复后回到「进行中」。普通轮次结束后不会常驻「已完成」:只有生成了语义摘要、开了活动流水、或这一轮曾久到需要提示时才保留完成态。行尾的「›」直接打开右侧栏的「会话回顾」并筛出进度记录。
|
|
98
98
|
|
|
99
99
|
1. 固定注册在 `conversation.input.dock`(输入框上方),不再提供上下位置选项。
|
|
100
100
|
2. 活动流水只读 `ctx.sessions.binding(sessionId).eventSource`;窗口变化时 React
|
|
@@ -122,8 +122,9 @@ bundle 层只声明入口和输入层的开关,其余字段由 schema 默认
|
|
|
122
122
|
右侧 WDX Relief 页面的「会话回顾」Tab 通过 `POST /api/wdx-relief/recaps` 读取;
|
|
123
123
|
Tab 顶部显示条数,可「清空」当前会话的历史(body 带 `clear: true`)。
|
|
124
124
|
重复摘要(重启后同一轮重新生成、文字没变)不会再记一条。
|
|
125
|
-
8. 运行中每 `recapStallSeconds`(默认 600 秒 = 10
|
|
126
|
-
|
|
125
|
+
8. 运行中每 `recapStallSeconds`(默认 600 秒 = 10 分钟)没给用户回复,客户端从事件窗口里取出这个时间窗的
|
|
126
|
+
思考片段和去掉参数的动作,连轮次、总耗时和等待时长一起 `POST /api/wdx-relief/progress`;Host 用便宜模型写成
|
|
127
|
+
一条叙述性进度(在解决什么、推进到哪),失败时保留客户端本地摘要,再追加到同一份 `recaps.json`。
|
|
127
128
|
同一轮同一档只发一次;Host 再按 `(sessionId, turn, anchor, bucket)` 去重,刷新页面也不会重复。
|
|
128
129
|
进度记录和摘要共用「会话回顾」列表,顶部可按「全部 / 摘要 / 进度」筛选,打开期间每 30 秒静默刷新。
|
|
129
130
|
|
|
@@ -146,18 +147,18 @@ bundle 层只声明入口和输入层的开关,其余字段由 schema 默认
|
|
|
146
147
|
|
|
147
148
|
## 右侧栏 WDX Relief 页面
|
|
148
149
|
|
|
149
|
-
插件在右侧栏注册一个独立页面(`sidebarRightTabs.register`,`kind: wdx-relief`),入口和 WDX Git 一样出现在右侧栏的工具列表(`guide.order 35
|
|
150
|
+
插件在右侧栏注册一个独立页面(`sidebarRightTabs.register`,`kind: wdx-relief`),入口和 WDX Git 一样出现在右侧栏的工具列表(`guide.order 35`);会话顶栏还注册一个 26px 的图标(`conversation.session.header.utilities`,`order 12`,紧跟 WDX Git 的 11),点击直接打开这个页面。页面用两个 Tab:「会话回顾」、「旁问」,默认显示「会话回顾」(`defaultTab` 可改为 `btw`)。
|
|
150
151
|
|
|
151
152
|
### 会话回顾、分组与筛选
|
|
152
153
|
|
|
153
154
|
- 按轮次分组:同一轮的进度记录和那一轮的摘要放在一组,组头显示「第 N 轮」、进度/摘要条数、结束时间和这一轮时长(如 10:32 · 30 分)。开始时间由进度记录的 `at - elapsedMs` 反推,摘要只能给出结束时间。
|
|
154
155
|
- 组可以展开 / 折叠;默认展开最新一轮,点击组头切换。旧记录没有 turn 时归到「更早的记录」。
|
|
155
156
|
- 支持「最新在前 / 最早在前」:组和组内记录一起反转;每条记录仍带自己的时间。选「最早在前」时,一轮里的阅读顺序是几次进度在前、摘要收尾。
|
|
156
|
-
- 顶部按「全部 / 摘要 / 进度 /
|
|
157
|
+
- 顶部按「全部 / 摘要 / 进度 / 待跟进」筛选,按钮带当前数量;进度行显示累计时间窗(第 2 条是「第 1–20 分」);展开后是轮次、总耗时、未回复时长、步数和这段动作清单(不带命令参数)。
|
|
157
158
|
- **待跟进**:最近 `pendingTurns` 轮(默认 3,1–20,收在设置页「输入框上的一行 → 高级」)里,如果某轮停在助手提问(摘要记录 `kind: question` 或 `question` 非空),或者回复/摘要以「下一步 / 接下来 / 需要你 / 请你 / 等你」开头,组头标「待跟进」,可用「待跟进」筛选只看这些轮次;正在跑的当前轮不标(它还没结束),已经结束的上一轮即使会话在跑也保留标记。判断用的是事件窗口里的**当前轮次**,不是历史里最大的 turn。这个标记只读当前会话的摘要记录,不扫其他会话、不调用模型。
|
|
158
159
|
- 打开期间每 30 秒静默刷新一次(不闪骨架屏),也可以手动「刷新」;「清空」会先问一次,确认后删掉当前会话的全部摘要和进度记录。
|
|
159
160
|
- 从输入框上方那一行点「›」跳进来时,默认落到「进度」筛选。
|
|
160
|
-
-
|
|
161
|
+
- 进度摘要和语义摘要共用同一条便宜模型链,模型失败时退回本地摘要;两者共用同一份历史,最多 300 条。
|
|
161
162
|
|
|
162
163
|
## 回复风格
|
|
163
164
|
|
package/index.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* 1. 注册认证路由 `POST /api/wdx-relief/predict`,按会话日志生成「下一句输入」;
|
|
6
6
|
* 2. 注册认证路由 `POST /api/wdx-relief/recap`,按最近一轮生成「现在到哪」;
|
|
7
7
|
* 3. 注册认证路由 `POST /api/wdx-relief/recaps` 读取某会话生成过的回顾历史;
|
|
8
|
-
* `POST /api/wdx-relief/progress`
|
|
8
|
+
* `POST /api/wdx-relief/progress` 生成并追加一条按时间窗的进度摘要(和摘要共用一份历史);
|
|
9
9
|
* 4. 注册认证路由 `POST /api/wdx-relief/btw`,回答右侧面板里的旁问;
|
|
10
10
|
* 5. 把所有设置暴露成 volatile Config,供设置页读写并即时生效;
|
|
11
11
|
* 6. 注册 `wdx-relief:reply-style` system prompt section,把回复风格编译成短指令;
|
|
12
12
|
* 7. 挂载工具调用泄漏守卫:调用被写成正文、turn 静默结束时当场检测并在同一轮内纠正重发。
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* 预测、回顾、进度摘要和旁问都走 ctx.llm,不写 session log、不触发 agent loop;
|
|
15
15
|
* 回顾的模型调用直接从服务流式读取,不 append 消息、不注入上下文,
|
|
16
16
|
* 因此输入框上方那一行永远不会进入模型上下文。
|
|
17
17
|
*/
|
|
@@ -52,7 +52,7 @@ export const Config = Schema.object({
|
|
|
52
52
|
recapProgress: Schema.boolean()
|
|
53
53
|
.default(true)
|
|
54
54
|
.volatile()
|
|
55
|
-
.description('
|
|
55
|
+
.description('一轮跑久了还没给用户回复时,按设置的间隔用便宜模型写一条这段时间的思路与进展(默认 10 分钟),失败退回本地摘要;整合进右侧栏的「会话回顾」,不单开 Tab'),
|
|
56
56
|
recapStallSeconds: Schema.number()
|
|
57
57
|
.default(600)
|
|
58
58
|
.volatile()
|
|
@@ -316,7 +316,7 @@ export function apply(ctx, config) {
|
|
|
316
316
|
path: PROGRESS_PATH,
|
|
317
317
|
methods: ['POST'],
|
|
318
318
|
requestBody: 'buffered',
|
|
319
|
-
fetch: (request) => handleRequest(request, (sessionId, signal, body) => {
|
|
319
|
+
fetch: (request) => handleRequest(request, async (sessionId, signal, body) => {
|
|
320
320
|
if (typeof sessionId !== 'string' || sessionId === '') {
|
|
321
321
|
const error = new Error('sessionId is required')
|
|
322
322
|
error.code = 'invalid-params'
|
|
@@ -337,6 +337,18 @@ export function apply(ctx, config) {
|
|
|
337
337
|
error.code = 'invalid-params'
|
|
338
338
|
throw error
|
|
339
339
|
}
|
|
340
|
+
// 页面刷新后客户端可能重发同一档;历史里已有就不再调一次模型。
|
|
341
|
+
const anchor = Number(entry.anchor) || 0
|
|
342
|
+
const duplicate = recapHistory.list(sessionId).some((item) => item.kind === 'progress'
|
|
343
|
+
&& item.turn === turn
|
|
344
|
+
&& (item.anchor || 0) === anchor
|
|
345
|
+
&& item.bucket === bucket)
|
|
346
|
+
if (duplicate) return { appended: false }
|
|
347
|
+
// 新客户端会带一段「这 10 分钟的思考/动作」;有 digest 时让 Host 用便宜模型
|
|
348
|
+
// 写成叙述性进展。模型不可用或摘要功能关闭时保留客户端兜底文案。
|
|
349
|
+
const generated = entry.digest && typeof entry.digest === 'object'
|
|
350
|
+
? await recapService.summarizeProgress(sessionId, entry, request.signal).catch(() => null)
|
|
351
|
+
: null
|
|
340
352
|
return {
|
|
341
353
|
appended: recapHistory.append({
|
|
342
354
|
sessionId,
|
|
@@ -344,13 +356,18 @@ export function apply(ctx, config) {
|
|
|
344
356
|
kind: 'progress',
|
|
345
357
|
turn,
|
|
346
358
|
bucket,
|
|
347
|
-
anchor
|
|
359
|
+
anchor,
|
|
348
360
|
status: entry.status === 'running' ? 'running' : 'stalled',
|
|
349
|
-
summary,
|
|
361
|
+
summary: generated !== null ? generated.summary : summary,
|
|
350
362
|
activity: typeof entry.activity === 'string' ? entry.activity.slice(0, 300) : '',
|
|
351
363
|
elapsedMs: Number(entry.elapsedMs) || 0,
|
|
352
364
|
silenceMs: Number(entry.silenceMs) || 0,
|
|
353
365
|
steps: Number(entry.steps) || 0,
|
|
366
|
+
windowMs: Number(entry.windowMs) || 0,
|
|
367
|
+
windowFromMs: Number(entry.windowFromMs) || 0,
|
|
368
|
+
windowToMs: Number(entry.windowToMs) || 0,
|
|
369
|
+
turnStartedAt: Number(entry.turnStartedAt) || 0,
|
|
370
|
+
generated: generated !== null,
|
|
354
371
|
at: Date.now(),
|
|
355
372
|
}),
|
|
356
373
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-wdx-relief",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Take the friction out of daily DSH work: predicted next messages, a live turn line above the composer, per-turn recaps/progress with follow-up markers, and sidebar side questions that stay out of the model context.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/src/recap.js
CHANGED
|
@@ -57,6 +57,13 @@ function clip(value, maxChars) {
|
|
|
57
57
|
return `${text.slice(0, maxChars).trim()}…`
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/** 保留最近的思考,而不是时间窗开头;长思考里越靠后越接近当前进展。 */
|
|
61
|
+
function clipTail(value, maxChars) {
|
|
62
|
+
const text = String(value ?? '').replace(/\s+/g, ' ').trim()
|
|
63
|
+
if (text.length <= maxChars) return text
|
|
64
|
+
return `…${text.slice(-maxChars).trim()}`
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
/** 去掉标题、列表、引用和强调标记,让一行回顾更像人话。 */
|
|
61
68
|
function stripMarkdown(line) {
|
|
62
69
|
return String(line)
|
|
@@ -422,7 +429,7 @@ export async function resolveModelCandidates({ llm, defaultSelection, chain = ''
|
|
|
422
429
|
return candidates.slice(0, Math.max(1, limit))
|
|
423
430
|
}
|
|
424
431
|
|
|
425
|
-
async function streamOnce({ service, candidate,
|
|
432
|
+
async function streamOnce({ service, candidate, system, prompt, maxWords, signal, timeoutMs }) {
|
|
426
433
|
const controller = new AbortController()
|
|
427
434
|
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
428
435
|
const onAbort = () => controller.abort()
|
|
@@ -436,8 +443,8 @@ async function streamOnce({ service, candidate, recap, maxWords, signal, timeout
|
|
|
436
443
|
const stream = service.stream({
|
|
437
444
|
provider: candidate.provider,
|
|
438
445
|
model: candidate.model,
|
|
439
|
-
system
|
|
440
|
-
messages: [{ role: 'user', content: [{ type: 'text', text:
|
|
446
|
+
system,
|
|
447
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: prompt }] }],
|
|
441
448
|
maxTokens: Math.min(MAX_OUTPUT_TOKENS, Math.max(96, maxWords * 6)),
|
|
442
449
|
temperature: 0.3,
|
|
443
450
|
signal: controller.signal,
|
|
@@ -465,14 +472,14 @@ async function streamOnce({ service, candidate, recap, maxWords, signal, timeout
|
|
|
465
472
|
}
|
|
466
473
|
|
|
467
474
|
/**
|
|
468
|
-
*
|
|
475
|
+
* 按模型链尝试生成一段文字;全部失败返回 null,由调用方退回本地兜底。
|
|
469
476
|
* @returns {Promise<{ text: string, provider: string, model: string }|null>}
|
|
470
477
|
*/
|
|
471
|
-
|
|
478
|
+
async function generateWithChain({ llm, defaultSelection, chain, system, prompt, maxWords, signal, timeoutMs = SUMMARY_TIMEOUT_MS, log = () => {}, acceptSalvage = true }) {
|
|
472
479
|
const service = typeof llm === 'function' ? llm() : llm
|
|
473
480
|
if (!service || typeof service.stream !== 'function') return null
|
|
474
481
|
const candidates = await resolveModelCandidates({ llm: service, defaultSelection, chain })
|
|
475
|
-
// 整条链共享 15
|
|
482
|
+
// 整条链共享 15 秒预算:便宜模型失败时快速换下一个,不让请求拖住。
|
|
476
483
|
const deadline = Date.now() + 15000
|
|
477
484
|
let salvage = null
|
|
478
485
|
for (const candidate of candidates) {
|
|
@@ -481,27 +488,124 @@ export async function generateSummary({ llm, defaultSelection, recap, chain, max
|
|
|
481
488
|
const remaining = deadline - Date.now()
|
|
482
489
|
if (remaining <= 0) break
|
|
483
490
|
try {
|
|
484
|
-
const text = await streamOnce({ service, candidate,
|
|
491
|
+
const text = await streamOnce({ service, candidate, system, prompt, maxWords, signal, timeoutMs: Math.min(timeoutMs, remaining) })
|
|
485
492
|
if (unfinishedEnding(text)) {
|
|
486
493
|
// 模型写了半句就停(「…表前缀已替换,待」):先在同一模型上重试一次。
|
|
487
|
-
log(`[wdx-relief]
|
|
494
|
+
log(`[wdx-relief] model ${candidate.provider}/${candidate.model} returned a half sentence`)
|
|
488
495
|
salvage = { text, provider: candidate.provider, model: candidate.model }
|
|
489
496
|
continue
|
|
490
497
|
}
|
|
491
498
|
return { text, provider: candidate.provider, model: candidate.model }
|
|
492
499
|
} catch (error) {
|
|
493
|
-
log(`[wdx-relief]
|
|
500
|
+
log(`[wdx-relief] model ${candidate.provider}/${candidate.model} failed`, error)
|
|
494
501
|
break
|
|
495
502
|
}
|
|
496
503
|
}
|
|
497
504
|
}
|
|
498
|
-
if (salvage !== null) {
|
|
505
|
+
if (salvage !== null && acceptSalvage) {
|
|
499
506
|
const text = trimUnfinished(salvage.text)
|
|
500
507
|
if (text !== '') return { ...salvage, text }
|
|
501
508
|
}
|
|
502
509
|
return null
|
|
503
510
|
}
|
|
504
511
|
|
|
512
|
+
/**
|
|
513
|
+
* 按链尝试生成摘要;全部失败返回 null,由调用方退回本地拼接。
|
|
514
|
+
* @returns {Promise<{ text: string, provider: string, model: string }|null>}
|
|
515
|
+
*/
|
|
516
|
+
export async function generateSummary({ llm, defaultSelection, recap, chain, maxWords, signal, timeoutMs = SUMMARY_TIMEOUT_MS, log = () => {} }) {
|
|
517
|
+
return generateWithChain({
|
|
518
|
+
llm,
|
|
519
|
+
defaultSelection,
|
|
520
|
+
chain,
|
|
521
|
+
system: buildSummarySystemPrompt(maxWords),
|
|
522
|
+
prompt: buildSummaryPrompt(recap),
|
|
523
|
+
maxWords,
|
|
524
|
+
signal,
|
|
525
|
+
timeoutMs,
|
|
526
|
+
log,
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** 进度摘要的目标长度:一到两句话,中文按字计。 */
|
|
531
|
+
export const DEFAULT_PROGRESS_WORDS = 80
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* 每 10 分钟一条的进度摘要。
|
|
535
|
+
*
|
|
536
|
+
* 输入是这一段时间窗里的思考片段和去参数后的工具动作;
|
|
537
|
+
* 输出叙述这段时间「在解决什么、用什么思路、推进到哪」,不列命令。
|
|
538
|
+
* 英文界面用英文 prompt,避免中文摘要和英文 UI 混在一起。
|
|
539
|
+
*/
|
|
540
|
+
export function buildProgressSystemPrompt(maxWords = DEFAULT_PROGRESS_WORDS, lang = 'zh') {
|
|
541
|
+
if (lang === 'en') {
|
|
542
|
+
return [
|
|
543
|
+
'You are writing the interval progress of an AI coding session that is still running, so someone returning can catch up in three seconds.',
|
|
544
|
+
'The input has the turn goal, reasoning fragments from this window, and tool actions with arguments removed.',
|
|
545
|
+
'Write 1-2 English sentences: what this window was solving, the approach, and how far it got or where it is stuck.',
|
|
546
|
+
'When prior progress is provided, spend half a sentence on the cumulative state and focus on what is new in this window.',
|
|
547
|
+
'Do not list commands, arguments, file paths or tool names; do not copy the reasoning verbatim; do not use "I", "you" or "assistant"; output only that text.',
|
|
548
|
+
`Limit: at most ${maxWords} words.`,
|
|
549
|
+
].join('\n')
|
|
550
|
+
}
|
|
551
|
+
return [
|
|
552
|
+
'你在给一个仍在运行的 AI 编程会话写「这段时间的进展」,帮刚回来的人三秒内接上。',
|
|
553
|
+
'输入包含本轮目标、这段时间的思考片段和去掉参数的工具动作。',
|
|
554
|
+
'输出 1–2 句中文:这段时间在解决什么问题、用了什么思路、推进到哪或卡在哪。',
|
|
555
|
+
'如果给了「此前进展」,用半句点出累计状态,重点写最近这个时间窗的新进展。',
|
|
556
|
+
'不要罗列命令、参数、文件路径或工具名;不要照抄思考原文;不出现「我」「你」「助手」;只输出这段文字。',
|
|
557
|
+
`限制:不超过 ${maxWords} 个字。`,
|
|
558
|
+
].join('\n')
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** @param {{ goal?: string, previous?: string, fromMinute?: number, toMinute?: number, reasoning?: string, actions?: string[] }} progress */
|
|
562
|
+
export function buildProgressPrompt(progress, lang = 'zh') {
|
|
563
|
+
const english = lang === 'en'
|
|
564
|
+
const lines = []
|
|
565
|
+
if (progress.goal) lines.push(english ? `Turn goal: ${clip(progress.goal, 300)}` : `本轮目标:${clip(progress.goal, 300)}`)
|
|
566
|
+
const from = positiveInt(progress.fromMinute, 1)
|
|
567
|
+
const to = positiveInt(progress.toMinute, from)
|
|
568
|
+
const newFrom = Math.min(to, positiveInt(progress.newFromMinute, from))
|
|
569
|
+
if (newFrom > from) {
|
|
570
|
+
lines.push(english
|
|
571
|
+
? `Window: minute ${from}-${to} of this turn; new in minute ${newFrom}-${to}`
|
|
572
|
+
: `时间窗:第 ${from}–${to} 分钟(本条新增第 ${newFrom}–${to} 分钟)`)
|
|
573
|
+
} else {
|
|
574
|
+
lines.push(english
|
|
575
|
+
? `Window: minute ${from}-${to} of this turn (cumulative to minute ${to})`
|
|
576
|
+
: `时间窗:第 ${from}–${to} 分钟(本轮累计到第 ${to} 分钟)`)
|
|
577
|
+
}
|
|
578
|
+
if (progress.previous) lines.push(english ? `Prior progress: ${clip(progress.previous, 240)}` : `此前进展:${clip(progress.previous, 240)}`)
|
|
579
|
+
if (progress.reasoning) lines.push(english ? `Reasoning fragments:\n${clipTail(progress.reasoning, 3000)}` : `思考片段:\n${clipTail(progress.reasoning, 3000)}`)
|
|
580
|
+
const actions = Array.isArray(progress.actions)
|
|
581
|
+
? progress.actions.filter((item) => typeof item === 'string' && item !== '').slice(0, 12)
|
|
582
|
+
: []
|
|
583
|
+
if (actions.length > 0) lines.push(english ? `Actions: ${actions.join('; ')}` : `动作:${actions.join(';')}`)
|
|
584
|
+
return lines.join('\n')
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** 生成结果里出现命令特征时丢弃,宁可用本地叙述也不把脚本参数带回面板。 */
|
|
588
|
+
const COMMAND_LOOKING_RE = /\/Users\/|\/home\/|\s--[A-Za-z][\w-]*|`[^`]+`|(?:^|\s)(?:cd|npm|pnpm|yarn|git|node|python3?|bash|curl|rg|grep|sed|cat)\s+[A-Za-z0-9._~-]*[./][A-Za-z0-9./_~-]*/u
|
|
589
|
+
|
|
590
|
+
export function looksLikeCommand(text) {
|
|
591
|
+
return typeof text === 'string' && COMMAND_LOOKING_RE.test(text)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export async function generateProgressSummary({ llm, defaultSelection, progress, chain, lang = 'zh', signal, timeoutMs = SUMMARY_TIMEOUT_MS, log = () => {}, maxWords = DEFAULT_PROGRESS_WORDS }) {
|
|
595
|
+
return generateWithChain({
|
|
596
|
+
llm,
|
|
597
|
+
defaultSelection,
|
|
598
|
+
chain,
|
|
599
|
+
system: buildProgressSystemPrompt(maxWords, lang),
|
|
600
|
+
prompt: buildProgressPrompt(progress, lang),
|
|
601
|
+
maxWords,
|
|
602
|
+
signal,
|
|
603
|
+
timeoutMs,
|
|
604
|
+
log,
|
|
605
|
+
acceptSalvage: false,
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
|
|
505
609
|
function recapKey(turn, recap) {
|
|
506
610
|
return [String(turn), recap.user ?? '', recap.assistant ?? '', recap.question ?? ''].join('\u0000')
|
|
507
611
|
}
|
|
@@ -683,6 +787,95 @@ export function createRecapService({ config, sessions, llm, defaultSelection, hi
|
|
|
683
787
|
return generateFrom(sessionId, session, turn, recap, signal, settings)
|
|
684
788
|
},
|
|
685
789
|
|
|
790
|
+
/**
|
|
791
|
+
* 运行中每 10 分钟的进度摘要:只读这一段时间窗的思考/动作和目标,
|
|
792
|
+
* 生成叙述性进展;模型不可用或功能关闭时返回 null,由路由用客户端兜底。
|
|
793
|
+
*/
|
|
794
|
+
async summarizeProgress(sessionId, entry, signal) {
|
|
795
|
+
const settings = readRecapConfig(config)
|
|
796
|
+
if (!settings.enabled) return null
|
|
797
|
+
const digest = entry && entry.digest && typeof entry.digest === 'object' ? entry.digest : null
|
|
798
|
+
if (digest === null) return null
|
|
799
|
+
// 这段时间既没有思考也没有动作时,模型只能编泛泛的话;保留本地「没有新输出」。
|
|
800
|
+
const reasoning = typeof digest.reasoning === 'string' ? digest.reasoning.trim() : ''
|
|
801
|
+
const actions = Array.isArray(digest.actions) ? digest.actions.filter((item) => typeof item === 'string' && item !== '') : []
|
|
802
|
+
if (reasoning === '' && actions.length === 0) return null
|
|
803
|
+
|
|
804
|
+
const session = sessions.get(sessionId)
|
|
805
|
+
if (session === undefined) return null
|
|
806
|
+
|
|
807
|
+
let goal = ''
|
|
808
|
+
try {
|
|
809
|
+
const recap = buildRecap(session.deriveMessages())
|
|
810
|
+
goal = recap && typeof recap.user === 'string' ? recap.user : ''
|
|
811
|
+
} catch {
|
|
812
|
+
goal = ''
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const bucket = positiveInt(Number(entry.bucket), 1)
|
|
816
|
+
const windowMs = positiveInt(Number(entry.windowMs), 600000)
|
|
817
|
+
const turnStartedAt = positiveInt(Number(entry.turnStartedAt), 0)
|
|
818
|
+
const windowFromMs = positiveInt(Number(entry.windowFromMs), 0)
|
|
819
|
+
const windowToMs = positiveInt(Number(entry.windowToMs), 0)
|
|
820
|
+
// 时间窗按「本轮开始」换算成分钟,跳档或中途回复后标签仍准确。
|
|
821
|
+
const anchor = Number(entry.anchor) || 0
|
|
822
|
+
let fromMinute
|
|
823
|
+
let newFromMinute
|
|
824
|
+
let toMinute
|
|
825
|
+
if (turnStartedAt > 0 && windowFromMs >= turnStartedAt && windowToMs > windowFromMs) {
|
|
826
|
+
newFromMinute = Math.max(1, Math.floor((windowFromMs - turnStartedAt) / 60000) + 1)
|
|
827
|
+
toMinute = Math.max(newFromMinute, Math.ceil((windowToMs - turnStartedAt) / 60000))
|
|
828
|
+
// 从本轮开始一直没回复:显示累计「1–20 分」,但提示模型重点写新增的 11–20。
|
|
829
|
+
fromMinute = anchor === turnStartedAt ? 1 : newFromMinute
|
|
830
|
+
} else {
|
|
831
|
+
const spanMinutes = Math.max(1, Math.round(windowMs / 60000))
|
|
832
|
+
newFromMinute = bucket > 1 ? (bucket - 1) * spanMinutes + 1 : 1
|
|
833
|
+
fromMinute = newFromMinute
|
|
834
|
+
toMinute = bucket * spanMinutes
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// 同一轮、同一次等待的上一条进度,用来点出累计状态;旧格式的进度
|
|
838
|
+
// 摘要里可能还是命令流水,不喂给模型。
|
|
839
|
+
let previous = ''
|
|
840
|
+
if (history) {
|
|
841
|
+
try {
|
|
842
|
+
const prior = history.list(sessionId).find((item) => item.kind === 'progress'
|
|
843
|
+
&& item.sessionId === sessionId
|
|
844
|
+
&& item.turn === entry.turn
|
|
845
|
+
&& (item.anchor || 0) === (Number(entry.anchor) || 0)
|
|
846
|
+
&& item.bucket < bucket
|
|
847
|
+
&& item.windowMs > 0)
|
|
848
|
+
if (prior && typeof prior.summary === 'string') previous = prior.summary
|
|
849
|
+
} catch {
|
|
850
|
+
previous = ''
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const generated = await generateProgressSummary({
|
|
855
|
+
llm,
|
|
856
|
+
defaultSelection,
|
|
857
|
+
progress: {
|
|
858
|
+
goal,
|
|
859
|
+
previous,
|
|
860
|
+
fromMinute,
|
|
861
|
+
newFromMinute,
|
|
862
|
+
toMinute,
|
|
863
|
+
reasoning,
|
|
864
|
+
actions,
|
|
865
|
+
},
|
|
866
|
+
lang: entry.lang === 'en' ? 'en' : 'zh',
|
|
867
|
+
chain: settings.chain,
|
|
868
|
+
signal,
|
|
869
|
+
log,
|
|
870
|
+
})
|
|
871
|
+
if (generated === null) return null
|
|
872
|
+
if (looksLikeCommand(generated.text)) {
|
|
873
|
+
log('[wdx-relief] progress summary looks like a command; keeping the local summary')
|
|
874
|
+
return null
|
|
875
|
+
}
|
|
876
|
+
return { summary: generated.text, provider: generated.provider, model: generated.model }
|
|
877
|
+
},
|
|
878
|
+
|
|
686
879
|
/** 测试 / 会话销毁时清理缓存。 */
|
|
687
880
|
clear(sessionId) {
|
|
688
881
|
if (sessionId === undefined) cache.clear()
|
package/src/recapHistory.js
CHANGED
|
@@ -81,6 +81,11 @@ export function createRecapHistory({ file, maxEntries = MAX_ENTRIES, log = () =>
|
|
|
81
81
|
elapsedMs: nonNegative(entry.elapsedMs),
|
|
82
82
|
silenceMs: nonNegative(entry.silenceMs),
|
|
83
83
|
steps: nonNegative(entry.steps),
|
|
84
|
+
windowMs: nonNegative(entry.windowMs),
|
|
85
|
+
windowFromMs: nonNegative(entry.windowFromMs),
|
|
86
|
+
windowToMs: nonNegative(entry.windowToMs),
|
|
87
|
+
turnStartedAt: nonNegative(entry.turnStartedAt),
|
|
88
|
+
generated: entry.generated === true,
|
|
84
89
|
})
|
|
85
90
|
while (list.length > maxEntries) list.shift()
|
|
86
91
|
save()
|