dsh-progress-union 0.7.0-rc.3 → 0.7.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/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.7.1 (2026-12-04)
6
+
7
+ **fix(ops):同回合被合并的重大变更也要告知客户端,否则面板 wake 与 R4 提醒还是会在队列里各留一条。**
8
+
9
+ - `maybeNotifyMajorChange` 从布尔改为**三态**:`'sent'`(真的投了一条)/ `'merged'`(同 rev 或同回合已被合并)/ `'none'`(非结构性、关板、开关关掉、无活 agent 或派发失败)。`applyChanges` 相应回传 `notified` 与 **`noticeMerged`** 两个布尔,`/action` 与 `/ops` 回执一并带。
10
+ - 客户端 `mutate()` 的 wake 门控补上第二个条件:`if (addedTitles.length > 0 && body.notified !== true && body.noticeMerged !== true)`。真机实测(0.7.0 钉到沙箱宿主 0.2.2-rc.5):同回合第一次改板只出**一条**黄档 `<progress-major-change rev="4">`(去重生效),但第 2/3 次因 `notified=false` 仍会触发客户端 wake,导致队列里多发一条绿档「我在进度板新增了任务」。本版消除该重复。
11
+ - 行为不变式:`notified=false` 且 `noticeMerged=false` 时客户端 wake **逐字退回 0.6.x**(关板 / 关掉 `notifyMajorChanges` / 无活 agent 均靠这一条兜底,不会让提醒静默消失)。
12
+ - **真机实测口径(不属修复,只记录)**:宿主输入流量面板的黄档 DOM 值是 `data-tier="next"`(标签「插话中」,圆点 `rgb(245,158,11)`),且系统注入的 next 档条目只给「收回排队」(**可撤回、不可就地编辑**),而 `later` 绿档条目(`rgb(34,197,94)`)才有完整的上移/下移/编辑/删除/打断并输入按钮——这是宿主渲染规则,插件侧无法改写。另:工具调用长时间执行时 `agent.status` 可不报 `running`,此时按计划的 idle 分支走 `followup`(绿档)。
13
+ - 测试:`test/major-change-notice.test.mjs` 补 `noticeMerged` 四组断言(首次 false / 同回合 true / 开关关掉 false / 关板 false),`test/ops.test.mjs` 补「同回合第 2 次 ops 改板:`notified=false` + `noticeMerged=true` + 队列仍只一条」,`test/client.test.mjs` 改钉新门控。`npm test` 233 pass / 0 fail。
14
+
15
+ ## 0.7.0 (2026-12-04)
16
+
17
+ **feat(release):下载感知 + 下载子进度条 + 侧边栏 LLM 任务操作 + 重大变更落输入队列 + 工序可解释,五项能力正式转正(rc.1→rc.3 阶梯收口)。**
18
+
19
+ - **R1 下载软感知**:`classifyDownload(name, argsRaw)` 识别 clone/pull/curl/wget/npm/pip/docker 拉取类动作,只进观察块与催办语料,**绝不拦截、不改写工具调用**;`snapshot.download` 携带 `{active,name,target,bytes,elapsedMs,basis,inBackground}`。
20
+ - **R2 下载子进度条**:输入框迷你条在主条下方多一行子条,真值全部来自**自解析 `tool/result` 标准输出**(`parseProgress` 解 `NN%` / `x/y MiB` / Cloning into… / Receiving objects),零跨插件依赖;解不出真值时走 `elapsed` 斜条纹 + 已用时长,**绝不用随机数假扮百分比**。
21
+ - **R3 侧边栏 LLM 任务操作**:`ProgressSidePanel` 内 `LlmOpsBlock`(provider/model 双下拉 + 四按钮)→ `POST /progress-union/ops`,细化拆分/按指令改板/问询/校验四 op 共用一条 `callAssistant → parseProposal → validateBoard → applyChanges(origin:'ops')` 通道;**不新开顶级标签、不注册槽位、零新增依赖**,落盘回执经 `applyRemoteSnapshot` 就地刷板。
22
+ - **R4 重大变更落输入队列**:`maybeNotifyMajorChange` 在 add/remove/order 型结构变更后把提醒递进 inbox——`running` → `agent.steer`(next-step 黄档可见可编辑),空闲 → `agent.followup`;正文裹 `<progress-major-change rev="N">`,同 rev 不重投、同回合只提一次。
23
+ - **R5 工序可解释**:`describeToolStep`/`glossCommand` 规则表(约 70 条命令首词 + 文件类 + `apply_patch` 反推 + `run_code` 递归解 PTC 内层)让观察块「最近动作」行从 `Bash×3` 变成 `Bash 跑测试 → 结果:233 passed`;`toolGloss.enabled=false` 逐字退回 0.6.x 文案。**不注册 act、不挂 tools.guard、不做 autoEventize**,与 dsh-better-tooluse 无任何运行期关系。
24
+ - **0.7.0 收口修复(真机实测偏差)**:面板新增任务后 `dsh-input-traffic` 里出现**两条同文排队条目**——客户端 `wakeAgent` 与 R4 服务端提醒是两条独立通道。`applyChanges` 现在回传 `notified`(`/action` 与 `/ops` 回执一并带上),客户端改为 `if (addedTitles.length > 0 && body.notified !== true)` 才补发 wake,**同一次改板在队列里只留一条**;服务端没落队列(关板/无活 agent/开关关掉)时 wake 行为与 0.6.x 完全一致,不退化。
25
+ - **文档**:README 新增五小节(下载类感知 / 下载子进度条 / 侧边栏 LLM 任务操作 / 重大变更落输入队列 / 工序可解释),逐节写明「与 dsh-better-tooluse 无运行期关系、零新增依赖、不注册 act」。
26
+ - **测试**:五个新文件 `test/download-classify.test.mjs`、`test/parse-progress.test.mjs`、`test/tool-gloss.test.mjs`、`test/ops.test.mjs`、`test/major-change-notice.test.mjs`,加 `test/client.test.mjs` 扩写(源码级契约 + 真调用渲染);`npm test` **233 pass / 0 fail**(0.6.3 基线 165 → +68),零回归。装机侧:沙箱 profile 换钉后产物哈希与仓内一致(LF 归一),`/ops/providers` 返回 2 个 provider,面板四按钮与双下拉实测可用,队列条目可编辑可删除。
27
+
5
28
  ## 0.7.0-rc.3 (2026-12-04)
6
29
 
7
30
  **feat(ops):侧边栏板内 LLM 任务操作(R3)+ 重大变更落输入队列(R4)——不新开顶级标签、零新增依赖。**
package/README.md CHANGED
@@ -268,7 +268,7 @@ assistant:
268
268
  ## 开发与测试
269
269
 
270
270
  ```bash
271
- npm test # node --test test/*.test.mjs(154 用例,纯 mock ctx,无需宿主进程)
271
+ npm test # node --test test/*.test.mjs(233 用例,纯 mock ctx,无需宿主进程)
272
272
  ```
273
273
 
274
274
  ## 冷启动接续(v0.6.2)
@@ -284,3 +284,47 @@ npm test # node --test test/*.test.mjs(154 用例,纯 mock ctx,无需宿
284
284
  ## 面板间距(v0.6.3)
285
285
 
286
286
  黄色提示卡(`.pb-llm`)与「本会话语用量」条不再互相压边:提示卡 `10/12`、用量条 `0/12`、同类块相邻补 `12px`。不变式是 `.pb-side` 内相邻块最小间距 ≥ 8px 且任何 `margin-top` 不为负,`client.test.mjs` 直接断言源码,回归即红。
287
+
288
+ ## 下载类感知(v0.7.0)
289
+
290
+ `classifyDownload(name, argsRaw)` 把「正在等一个网络拉取」这件事识别出来:npm/pnpm/yarn/bun/pip/uv/conda/brew/cargo/go 的 `install|add|i|ci`、`git clone`、`docker pull`、`curl -O`、`wget`、`npx`,以及独立 `&` / `nohup` / `--detach` 的后台线索。**只识别与催办,绝不拦截**:不注册 `tools.guard`、不改写命令、`--dry-run` 段不记、猜不出目标返回 `null`(沿用 `filePathOf` 的「拿不到就不记」纪律,不写「处理中」这类空话)。
291
+
292
+ 识别结果进两条出口:观察块多一行下载事实(动作 · 目标 · 已下字节 · 耗时 · 真值来源),以及 `snapshot.download`(供客户端子条)。配置 `download.enabled=false` 整条链路关闭,`snapshot` 少一个字段,UI 逐字退回 0.6.x。
293
+
294
+ ## 下载子进度条(v0.7.0)
295
+
296
+ 输入框上方的迷你条在主条行之后渲染一行子条,真值全部来自本插件自解析 `tool/result`(`parseProgress` 覆盖 wget/curl 的 `45%` 与 `12.3MB/27.8MB`、pip/uv 单尾单位、git `Receiving objects: 62%`、pnpm `[3/12]`),**零跨插件依赖**。
297
+
298
+ 两档形态严格对应 `basis`:`stdout` / `board` 才画实际填充宽度并显示百分比;只有动作记录(`elapsed`)走 indeterminate 斜条纹 + 已用时长,**绝不拿随机数或驻留 100% 假扮百分比**(用例直接断言「无真值不得写内联 style」)。后台下载追加 warn 色徽标。`@media (prefers-reduced-motion: reduce)` 关闭条纹动画;760px 去左缩进、520px 整行收起;配色全走 `--dsw-alias-*` 宿主令牌,无硬编 hex/rgb。
299
+
300
+ ## 侧边栏 LLM 任务操作(v0.7.0)
301
+
302
+ 侧边栏板内(AddTask 与页脚之间)多一块「LLM 操作」:provider/model 双下拉 + 输入 + 四个按钮,**不新开顶级标签**。
303
+
304
+ - **细化拆分**:让辅助模型按板上现状把一个粗项拆成可交付小步(add/edit)。
305
+ - **按指令改板**:一句自然语言翻成 add/edit/remove/`order` 排序。
306
+ - **问询**:只回文本,模型硬塞 `changes` 也不写板。
307
+ - **校验**:`validateBoard` 纯本地跑,一次 token 都不花;硬错(项数 >60、缺/过长 title、status 非枚举、percent 越界、`done` 但 pct≠100)与 warnings(空板、重复 title、多 doing)分档显示。
308
+
309
+ 选模型口径同 prime-memory:`GET /ops/providers` 读宿主 `llm.listProviders()` 与默认模型选择,宿主没给服务时退回设置页里的 `assistant.provider/model`(下拉显示「沿用设置页」),不报错。落盘走同一条 `callAssistant → parseProposal → applyChanges(origin:'ops')` 通道:改动截 8 条、未知 id 与空 title 丢弃、模型答非 JSON 返 502 且**板 revision 不动**、未配置模型返 400。`origin:'ops'` 不算「主模型刚刚同过步」,催办计时不被侧边栏操作抹平。
310
+
311
+ ## 重大变更落输入队列(v0.7.0)
312
+
313
+ 用户在面板直接改板(或经侧边栏 LLM 操作改板)导致**结构性**变化(add / remove / `order`)时,插件把这件事递到模型的收件队列,而不是等下一次审查才发现板变了:
314
+
315
+ - 回合正在跑 → `agent.steer(msg)`,本回合 nearest step 就消费(在 dsh-input-traffic 里是黄档,可编辑可撤回);空闲 → `agent.followup(msg)`,下一轮消费。
316
+ - 消息 `role:'user'` + `source:{kind:'user', producer:'dsh-progress-union', rev}`,正对 `isHumanSteer` 的采信条件,因此它被当「人插的话」而不是插件自说自话。
317
+ - 正文裹 `<progress-major-change rev="N">`:变更行 + 当前清单 + 「不要按旧顺序推进,动手前先用 progress_update 对账」,模型不必重新拉板。
318
+ - **幂等**:同 `rev` 不重投,同回合只提一次(新回合可再提),所以连续改三次板不会在队列里留三条。`notifyMajorChanges=false`、板未启用、没有活着的 agent 时一条都不发;派发失败只记日志且**不退回 `followup` 补发**,绝不让改板本身失败。
319
+ - **与客户端 wake 不叠加**:面板“新增任务”原本还会另发一条 wake 消息(0.6.x 就有的客户端通道)。`/action` 回执带两个布尔:`notified`(本回合真的投了一条)与 `noticeMerged`(同 rev / 同回合已被合并),**两者任一为真客户端都不再补发** —— 同一次改板在队列里只留一条带 `<progress-major-change>` 的正式提醒;只有服务端压根没递(关板 / 无活 agent / 开关关掉 / 派发失败)时,wake 行为才逐字退回 0.6.x。
320
+ - **黄档靠宿主渲染**:实测(沙箱宿主 0.2.2-rc.5)steer 进去的条目在 `dsh-input-traffic` 里是 `data-tier="next"`、标签「插话中」,但只给「收回排队」(可撤回、不可就地编辑),可编辑的是 `later` 绿档条目;工具长时间执行时 `agent.status` 可以不报 `running`,那一笔就会走 idle 分支的 `followup`(绿档)。插件只决定投递通道,档位外观归宿主。
321
+
322
+ ## 工序可解释(v0.7.0)
323
+
324
+ 三层,全部在本插件内部实现:**不注册 act、不挂 tools.guard、不做 autoEventize**,与 dsh-better-tooluse 没有任何运行期关系(不读它的状态、不共享事件),零新增依赖。
325
+
326
+ 1. **规则表**:`describeToolStep(name, argsRaw)` 把一次工具调用翻成人话。命令型按首段首词二跳分派(`git clone`→克隆仓库、`npm ci && npm test`→按锁文件装依赖、`docker build`→构建镜像),另有约 70 条首词表;文件类只留路径末段;`apply_patch` 从 `*** Update File:` 反推被改文件;`run_code` 递归解 `tools.xxx(`;猜不出退回 `key=value`,全空返回空串。
327
+ 2. **结果回显**:`tool/result` 按 callId 对齐,写 `resultDigest(text, failed)`(≤60 字,区分「结果:」/「失败:」/「失败(无输出)」)。观察块「最近动作」、todo 校对输入、助手审查输入三处统一成 `Bash 跑测试 → 结果:188 passed in 6.4s`。
328
+ 3. **叙述纪律**:systemPrompt 观察块尾部追加一行静态提示「每步工具前用一行写清「▸ <动作> → <本步目的>」」,`toolGloss.softNarrate=false` 可关。不做 pre-step 逐条注入。
329
+
330
+ `toolGloss.enabled=false` 时三处渲染逐字退回 0.6.x 的 `name×count → name` 串。
package/client.js CHANGED
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
24
24
  var REPO_URL = "https://github.com/drscrewdriver/dsh-progress-union";
25
25
  var STAR_NS = "progress-union";
26
26
  var STAR_GEN = "v4"; /* ladder:gen */
27
- var STAR_VERSION = "0.7.0-rc.3"; /* ladder:ver */
27
+ var STAR_VERSION = "0.7.1"; /* ladder:ver */
28
28
  var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
29
29
 
30
30
  // 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
@@ -2742,7 +2742,10 @@ window.__ModuleLoader__.load({
2742
2742
  .filter((change) => change && !change.id && !change.remove && typeof change.title === 'string')
2743
2743
  .map((change) => change.title.trim())
2744
2744
  .filter(Boolean)
2745
- if (addedTitles.length > 0) {
2745
+ if (addedTitles.length > 0 && body.notified !== true && body.noticeMerged !== true) {
2746
+ // v0.7.0 R4:服务端已经把「板结构变了」递进输入队列(notified=true)、或本回合
2747
+ // 已经提醒过被合并(noticeMerged=true)时,客户端不再另发一条 wake
2748
+ // 消息 —— 同一次改板在队列里只留一条。
2746
2749
  props.wakeAgent?.(
2747
2750
  sessionId,
2748
2751
  `我在进度板新增了任务。请按新任务推进。`,
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.7.0-rc.3",
3
+ "version": "0.7.1",
4
4
  "main": "./index.js",
5
5
  "description": "进度结合原型:board 槽位真相源(用户可编辑、diff+ack 增量同步、staleness nudge)× 鲸程时间引擎(step 计数、ETA 三档 board>todo>local>prior、悬浮迷你条),向压缩插件暴露只读三层进度锚点 progressAnchor(board 语义锚 + time 时间锚 + userEdits 未确认改动,service 与 HTTP 双平面),并在 0.6.0 起每回合落一版会话归档(handoff 规则摘要 + 重启注入一次)。",
6
6
  "engines": {
package/index.js CHANGED
@@ -2209,6 +2209,7 @@ export async function apply(ctx, config) {
2209
2209
  for (const change of changes) applyOneChange(working, change, origin, at, records, warnings)
2210
2210
 
2211
2211
  let revisionChanged = false
2212
+ let notice = 'none'
2212
2213
  if (records.length > 0) {
2213
2214
  working.revision += 1
2214
2215
  working.updatedAt = at
@@ -2254,7 +2255,7 @@ export async function apply(ctx, config) {
2254
2255
  // v0.7.0 R4:用户或侧边栏 LLM 操作把板改出了结构性变化 → 落输入队列提醒。
2255
2256
  // 主模型自己写板(origin='agent')不提醒——它知道刚写了什么;观察者自动同步也不提醒。
2256
2257
  if ((origin === 'user' || origin === 'ops') && records.length > 0) {
2257
- try { maybeNotifyMajorChange(sessionId, records, working.revision) } catch (_err) {}
2258
+ try { notice = maybeNotifyMajorChange(sessionId, records, working.revision) } catch (_err) {}
2258
2259
  }
2259
2260
  }
2260
2261
  // 任何 agent 调用(含 changes=[] 确认)都算一次"模型已看板":重置催办计时;
@@ -2270,7 +2271,7 @@ export async function apply(ctx, config) {
2270
2271
  fields: record.fields.map((field) => field.field),
2271
2272
  }
2272
2273
  })
2273
- return { snapshot: publicSnapshot(working), changed: changed.filter(Boolean), warnings }
2274
+ return { snapshot: publicSnapshot(working), changed: changed.filter(Boolean), warnings, notified: notice === 'sent', noticeMerged: notice === 'merged' }
2274
2275
  }
2275
2276
 
2276
2277
  // ==========================================================================
@@ -3200,21 +3201,23 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3200
3201
  }
3201
3202
 
3202
3203
  /**
3203
- * @returns true 表示确实往队列里丢了一条(失败/去重返回 false,绝不抛)。
3204
+ * 三态返回(绝不抛):`'sent'` 确实往队列里丢了一条;`'merged'` 本回合/同 rev 已经
3205
+ * 提醒过了,这一次被有意合并(客户端不该再另发 wake);`'none'` 压根没递(非结构性
3206
+ * / 关板 / 无活 agent / 派发失败)——客户端保留 0.6.x 的 wake 行为。
3204
3207
  */
3205
3208
  function maybeNotifyMajorChange(sid, records, rev) {
3206
- if (!cfg.notifyMajorChanges) return false
3207
- if (!isEnabled(sid)) return false
3209
+ if (!cfg.notifyMajorChanges) return 'none'
3210
+ if (!isEnabled(sid)) return 'none'
3208
3211
  const structural = structuralOf(records)
3209
- if (structural.length === 0) return false
3212
+ if (structural.length === 0) return 'none'
3210
3213
  const revN = Math.trunc(Number(rev) || 0)
3211
- if (revN <= 0) return false
3214
+ if (revN <= 0) return 'none'
3212
3215
  const o = obsOf(sid)
3213
3216
  // 幂等两层:同 rev 不重投(HTTP 重试/重放);同回合只提一次(多改几次合成一条)。
3214
- if (o.noticeRev === revN) return false
3215
- if (o.noticeTurn === o.turnSeq) return false
3217
+ if (o.noticeRev === revN) return 'merged'
3218
+ if (o.noticeTurn === o.turnSeq) return 'merged'
3216
3219
  const agent = liveAgentOf(sid)
3217
- if (!agent) return false
3220
+ if (!agent) return 'none'
3218
3221
  const message = {
3219
3222
  id: `pmc-${revN.toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
3220
3223
  role: 'user',
@@ -3222,7 +3225,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3222
3225
  source: { kind: 'user', producer: 'dsh-progress-union', rev: revN },
3223
3226
  }
3224
3227
  const running = agent.status === 'running' && typeof agent.steer === 'function'
3225
- if (!running && typeof agent.followup !== 'function') return false
3228
+ if (!running && typeof agent.followup !== 'function') return 'none'
3226
3229
  try {
3227
3230
  if (running) agent.steer(message)
3228
3231
  else agent.followup(message)
@@ -3230,13 +3233,13 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3230
3233
  try {
3231
3234
  ctx.logger?.warn?.(`progress-union: major-change notice failed: ${err instanceof Error ? err.message : String(err)}`)
3232
3235
  } catch (_logErr) {}
3233
- return false
3236
+ return 'none'
3234
3237
  }
3235
3238
  o.noticeRev = revN
3236
3239
  o.noticeTurn = o.turnSeq
3237
3240
  o.lastNoticeAt = now()
3238
3241
  o.noticeTier = running ? 'next-step' : 'next-turn'
3239
- return true
3242
+ return 'sent'
3240
3243
  }
3241
3244
 
3242
3245
  // ==========================================================================
@@ -3447,6 +3450,8 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3447
3450
  changes: result.changed,
3448
3451
  warnings: (result.warnings || []).concat(post.errors),
3449
3452
  answer: answer || `已应用 ${result.changed.length} 条改动`,
3453
+ notified: result.notified === true,
3454
+ noticeMerged: result.noticeMerged === true,
3450
3455
  snapshot: result.snapshot,
3451
3456
  }
3452
3457
  }
@@ -5195,7 +5200,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
5195
5200
  expectedRevision: body.expectedRevision,
5196
5201
  ackUserRevision: undefined,
5197
5202
  })
5198
- sendJson(res, 200, { ok: true, ...result.snapshot, changed: result.changed })
5203
+ sendJson(res, 200, { ok: true, ...result.snapshot, changed: result.changed, notified: result.notified === true, noticeMerged: result.noticeMerged === true })
5199
5204
  } catch (error) {
5200
5205
  const status = error && error.statusCode ? error.statusCode : 400
5201
5206
  sendJson(res, status, {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.7.0-rc.3",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎;向压缩插件暴露只读三层进度锚点(service + HTTP 双平面);0.6.0 起每回合落一版会话归档(handoff + 重启注入一次)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org",
9
9
  "access": "public",
10
- "tag": "rc"
10
+ "tag": "latest"
11
11
  },
12
12
  "dependencies": {
13
13
  "@deepseek-ai/schemastery": "~3.18.4"
@@ -357,3 +357,16 @@ test('rc.3:操作块文案 zh/en 成对(本仓 client 只有内联 zh/en 两
357
357
  assert.equal(hits.length, 2, `${k} 必须在 zh/en 各出现一次(实得 ${hits.length})`)
358
358
  }
359
359
  })
360
+
361
+ test('0.7.0:新增任务 wake 与 R4 落队列互斥,同一次改板队列里只留一条', () => {
362
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
363
+ // 真机偏差:面板加两项后 input-traffic 出现两条同文排队条目——客户端 wake 与
364
+ // 服务端 R4 提醒各发一条。门控必须读服务端 notified 回执。
365
+ assert.match(src, /if \(addedTitles\.length > 0 && body\.notified !== true && body\.noticeMerged !== true\) \{/, 'wake 前必须让位给服务端已落队列(或已合并)的提醒')
366
+ const wakeStart = src.indexOf('props.wakeAgent?.(')
367
+ const gateStart = src.lastIndexOf('if (addedTitles.length > 0', wakeStart)
368
+ assert.ok(gateStart > 0 && wakeStart - gateStart < 400, 'wake 调用必须在 notified 门控块内')
369
+ // 门控只在 mutate 的成功分支里,失败分支(throw)不得触发 wake
370
+ const throwAt = src.lastIndexOf('throw new Error(body?.error', wakeStart)
371
+ assert.ok(throwAt < gateStart, '错误分支必须在门控之前退出,不共享 wake 通道')
372
+ })
@@ -42,6 +42,8 @@ test('idle + 用户新增项 → followup 落队列,正文带 <progress-major-
42
42
  const before = await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} }).then((r) => r.json())
43
43
  const out = await userEdit(harness, [{ title: '补下载子条' }], before.revision)
44
44
  assert.equal(out.ok, true)
45
+ assert.equal(out.notified, true, '/action 必须把服务端是否已落队列告知客户端')
46
+ assert.equal(out.noticeMerged, false, '真的投了一条就不能标 merged')
45
47
  assert.equal(harness.followups.length, 1, 'idle 必须走 followup')
46
48
  const msg = harness.followups[0]
47
49
  assert.equal(msg.role, 'user')
@@ -80,9 +82,19 @@ test('只有非结构性改动(current/percent/status)时一条都不发', a
80
82
  test('同回合连续两次结构性改板 → 合并成一条(同 rev 不重投)', async () => {
81
83
  const harness = await booted()
82
84
  let rev = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json().revision
83
- rev = (await userEdit(harness, [{ title: 'A' }], rev)).revision
84
- rev = (await userEdit(harness, [{ title: 'B' }], rev)).revision
85
- rev = (await userEdit(harness, [{ title: 'C' }], rev)).revision
85
+ const first = await userEdit(harness, [{ title: 'A' }], rev)
86
+ assert.equal(first.notified, true, '首次结构性改板必须回执 notified=true,客户端据此不再另发 wake 消息')
87
+ rev = first.revision
88
+ const second = await userEdit(harness, [{ title: 'B' }], rev)
89
+ assert.equal(second.notified, false, '同回合第两次被合并,不得假装已投递')
90
+ // 但必须告知客户端「本回合已经提醒过了」——否则客户端会另发一条 wake,
91
+ // 队列里就同时有 R4 提醒与客户端 wake 两条(真机实测偏差)。
92
+ assert.equal(second.noticeMerged, true, '同回合被合并必须回执 noticeMerged=true')
93
+ rev = second.revision
94
+ const third = await userEdit(harness, [{ title: 'C' }], rev)
95
+ assert.equal(third.notified, false)
96
+ assert.equal(third.noticeMerged, true)
97
+ rev = third.revision
86
98
  assert.equal(harness.followups.length, 1, '同一回合只提一次')
87
99
  // 已发的那条对应第一次的 rev;后续 rev 不再补投
88
100
  assert.equal(harness.followups.filter((m) => m.source && m.source.producer === 'dsh-progress-union').length, 1)
@@ -107,6 +119,8 @@ test('notifyMajorChanges:false 一条都不发(逐字退回 0.6.x 行为)',
107
119
  const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
108
120
  const out = await userEdit(harness, [{ title: '关掉提醒' }], before.revision)
109
121
  assert.equal(out.ok, true, '改板本身必须照常成功')
122
+ assert.equal(out.notified, false, '开关关掉时 notified 必为 false,客户端 wake 行为退回 0.6.x')
123
+ assert.equal(out.noticeMerged, false, '开关关掉不算「已合并」')
110
124
  assert.equal(harness.followups.length + harness.steers.length, 0)
111
125
  })
112
126
 
@@ -116,6 +130,8 @@ test('板未启用(关板)时不发;主模型自己写板(origin=agent
116
130
  const before = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
117
131
  const out = await userEdit(harness, [{ title: '关板后新增' }], before.revision)
118
132
  assert.equal(out.ok, true, '关板后改板本身仍要照常落盘')
133
+ assert.equal(out.notified, false)
134
+ assert.equal(out.noticeMerged, false, '关板是“没递”,不是“已合并”,客户端仍应保留 wake')
119
135
  assert.equal(out.items.some((i) => i.title === '关板后新增'), true)
120
136
  assert.equal(harness.followups.length + harness.steers.length, 0, '关板不该往队列里丢东西')
121
137
 
package/test/ops.test.mjs CHANGED
@@ -164,6 +164,17 @@ test('op=mutate 能把指令翻成删除(只认板上真 id),并触发 R4
164
164
  assert.ok(notice, '结构性变更必须落输入队列')
165
165
  assert.equal(notice.source.kind, 'user', 'isHumanSteer 只认 kind=user')
166
166
  assert.match(notice.content[0].text, /<progress-major-change rev="\d+">/)
167
+ // 回执必须把「已落队列」告知客户端(/ops 与 /action 同一套门控语义)
168
+ assert.equal(r.json.notified, true, 'ops 落盘的结构性变更必须回执 notified=true')
169
+ assert.equal(r.json.noticeMerged, false)
170
+ const before2 = harness.followups.length
171
+ const other = after.items.find((i) => i.title !== '补测试')
172
+ reply = JSON.stringify({ changes: [{ kind: 'remove', id: other.id }] })
173
+ const r2 = await ops(harness, { sessionId: SESSION, op: 'mutate', question: '再删一项' })
174
+ assert.equal(r2.json.applied, true)
175
+ assert.equal(r2.json.notified, false, '同回合第二次 ops 改板被合并,不得假装新投了一条')
176
+ assert.equal(r2.json.noticeMerged, true, '但必须让客户端知道“本回合已经提醒过”,否则它会另发 wake')
177
+ assert.equal(harness.followups.length, before2, '同回合仍只一条队列消息')
167
178
  })
168
179
 
169
180
  test('op=mutate/ask 缺 question、未知 op、缺 sessionId 一律 400', async () => {