dsh-progress-union 0.8.3 → 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 CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.9.0 (2026-12-04)
6
+
7
+ **feat(ops):计划文档进 ops 原料(以 tasks.md 为纲的细化/问询终于能读到文件);fix(chain):换 provider 时模型跟着走。**
8
+
9
+ 用户拿真板子试了两个问题:① 在侧栏写「是否可以对 `E:\…\.agents\plans\session-exclusion-gate\tasks.md` 任务为纲再细化」,模型回“这属于咨询或讨论性质,并非对当前任务板执行具体操作”;② 链编辑器里换了供应商后,模型栏仍是上一个 provider 的模型名。
10
+
11
+ - **根因(①)不是提示词推诿,是真没喂文件**:本仓早就有 `scanPlan` / `planDirCandidates` / `pickPlanDir` / `parseChecklistMarkdown` / `readCapped` 这一整套原料机器(v0.5.0 起给观察者用),但 ops 三路只把板子清单拼进 prompt。所以本次不另起炉灶,而是把现有机器接过来,并新增 `opsPlanBrief`:它要的是**未完成任务的原文与编号**(`planBrief` 只给 8 行摘要,不够拆),上限 `OPS_PLAN_MAX_LINES=40` / `OPS_PLAN_MAX_CHARS=6000`,已勾选项不再当未完喂入。
12
+ - **点名规则走纯函数** `planSlugFromText`(已导出供单测):只认 `.agents/plans/<slug>/` 形态,反斜杠与正斜杠都吃,不把普通英文词当 slug。点名落空则回退到板子已绑定/自动选的计划(`scanPlan(sid, override)` 新增第二参),**不静默换成别的计划也不抛错**;`planSync=off` 时不注入并报 `reason:'disabled'`(与 `not-found` 区分)。
13
+ - **grounding 必须可见**:三路回执都带 `plan` 元信息,输出区命中时报「已按纲 `<slug>/<file>` · 勾选 done/total · 已列未完 N」、落空/被关时报「本次没拿到计划原料(点名落空或计划面已关)」。否则用户无法区分「没喂文档」与「喂了但答不上」——这正是本次误判发生的地方。
14
+ - **深度排期落在提示词层**:`OPS_REFINE_SYSTEM` 现在要求“有 `<plan>` 段时以其为记录大纲,从未完项导出拆分、按 Phase 顺序排列(依赖先行)、标题前缀标批次”;`OPS_MUTATE_SYSTEM` 以计划原文与编号为准;`OPS_ASK_SYSTEM` 旧说法“using ONLY the checklist”改为“板子清单 + `<plan>` 段”,并明写“不得声称自己读不了文件”。
15
+ - **根因(②)是写面漏字段**:provider 下拉的 `onChange` 只调 `patchRow(index,'provider',…)`,model 原样留着 → 配出 `local-35/deepseek-v4-pro` 这类错配串,调用必失败。新增 `pickProviderRow`:新 provider 清单里还有当前值就保留,否则预填该家第一个模型,拿不到清单则清空(逼重选、不留错值);行内模型清单与预填逻辑共用 `modelsOf`,不留两套口径。
16
+ - **文档修正**:README 里手写 yml 示例的条目 id 原本是 `dsh-progress-union`(npm 包名)—— 宿主按插件 id 取配置补丁,这个错例本轮真实坑过一人的钉定(导致侧栏锁输入),现改为 `progress-union` 并加注释说明。
17
+ - **回归闸**:`test/ops.test.mjs` 新增 5 条(slug 识别、ask 喂入未完项与回执、refine 的段落顺序、planSync=off 照常动作且报 disabled、点名落空回退);`test/settings.test.mjs` 新增「换 provider 必须同时处理 model」;`test/client.test.mjs` 新增 grounding 文案 zh/en 成对。测试 275/275。
18
+
19
+ ## 0.8.4 (2026-12-04)
20
+
21
+ **fix(settings):路由链卡提到设置页第一张;辅助 LLM 的 provider 占位符不再指向不存在的键,未填全时直接告。**
22
+
23
+ 0.8.3 取消折叠后用户仍拿 prime-memory 对比说「差远了」——因为卡虽展开但排在第 4 张,不滚就看不到。同时本轮排查中我自己也被一个占位符误了一次,顺带查出配置面的真问题。
24
+
25
+ - **卡片排序**:「LLM 操作与队列提醒」整块上提为第一张(原顺序 ops 在第 4)。本次主要交付不应要求用户先滚到页底。
26
+ - **占位符修正**:辅助 LLM 的提供方输入框 placeholder 原写的是 `local-35b` —— 宿主注册的键是 `local-35`,`local-35b` 在配置里根本不存在。灰色占位被当成已存值看了两轮(包括我),现改为真实存在的 `deepseek-account` 风格示例(README 同一处错例一并改)。
27
+ - **未填全直接告**:`assistantReady()` 在 `mode=registered` 且 provider 或 model 为空时返回 false,观察者/审查整条静默不跑(L2087/L3308 都是早退)—— 而表单看上去像配好了。现在这种情况在提供方行下方给一条警示(新文案 `setAssistantIncomplete`,zh/en 成对),样式沿用本文件已有的琥珀档位,不发明新令牌。
28
+ - **回归闸**:`test/settings.test.mjs` 新增「路由链卡排第一 + 占位符不误导 + 未填全要给警示」;`test/client.test.mjs` 新增新文案 zh/en 成对闸。测试 268/268。
29
+ - 配置项、路由面、链编辑器行为均无变动;本次只动展示层与文档示例。
30
+
5
31
  ## 0.8.3 (2026-12-04)
6
32
 
7
33
  **fix(ops):路由链卡不再默认折叠 —— 上一版的链编辑器事实上看不见。**
package/README.md CHANGED
@@ -202,13 +202,13 @@ observer:
202
202
 
203
203
  观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"交给一个小模型做审查:
204
204
 
205
- **配置位置:设置 → 进度板**(或插件详情页的同名卡片)。卡内三组可折叠:辅助 LLM / 观察者 / 只读 API;观察者的滞后阈值也在这张卡里。
205
+ **配置位置:设置 → 进度板**(或插件详情页的同名卡片)。卡片从上到下依次是:**LLM 操作与队列提醒**(默认展开,模型路由链就在第一张卡里)、辅助 LLM(监控/审查)、观察者(监控)—— 这三张默认展开;下载感知与工序、官方 todo 同步、只读 API 默认折叠,点头部展开即可。观察者的滞后阈值在「观察者」卡里。
206
206
 
207
207
  ```yaml
208
208
  assistant:
209
209
  mode: '' # '' 关(默认)| 'registered' | 'direct'
210
- provider: local-35b # registered:Settings→模型 里的 provider 名(走宿主 llm.stream,免密钥)
211
- model: qwen2.5-3b # registered/direct 共用的模型 id
210
+ provider: deepseek-account # registered:Settings→模型 里的 provider 名(走宿主 llm.stream,免密钥)
211
+ model: deepseek-v4-pro # registered/direct 共用的模型 id
212
212
  baseUrl: http://127.0.0.1:8000/v1 # direct 专用
213
213
  apiKey: '' # direct 专用;快照只回布尔 hasApiKey
214
214
  authority: both # slots | rounds | both
@@ -342,7 +342,9 @@ npm test # node --test test/*.test.mjs(246 用例,纯 mock ctx,无需宿
342
342
  `ops.fallbacks` 也标了 `.volatile()`(宿主成文规则:数组可以作为 volatile 值,只要在固定对象路径上且外面没包着别的 volatile;`ops` 节本身未标,所以 `ops.fallbacks` 合法)。写入必须走 `scope.mutate` 的叶路径,嵌套组整组铺回仍会被 `settings/rejected` 拒。手写 yml 这条路照常有效(数组本来就只能这么维护),例:
343
343
 
344
344
  ```yaml
345
- - id: dsh-progress-union
345
+ # 条目 id 是宿主注册名(= 本插件的路由基名 progress-union),不是 npm 包名。
346
+ # 写成 dsh-progress-union 会被宿主无视:配置看上去在,实际读不到。
347
+ - id: progress-union
346
348
  name: dsh-progress-union
347
349
  config:
348
350
  ops:
@@ -352,12 +354,20 @@ npm test # node --test test/*.test.mjs(246 用例,纯 mock ctx,无需宿
352
354
  - { provider: strata, model: qwen3.8-flash-iq2_xs }
353
355
  ```
354
356
 
357
+ **v0.9.0:计划文档进 ops 原料 + 换 provider 时模型跟着走。**
358
+
359
+ - **以计划为纲的细化/问询现在真能读到文件**。本仓早就有 `scanPlan` / `parseChecklistMarkdown` 这套原料机器(原本只喂观察者),ops 此前没接——所以用户写「以 `….agents\plans\<slug>\tasks.md` 为纲再细化」时,模型只能答“这是咨询、不执行”,因为它确实只拿到板子清单。现在 refine / mutate / ask 三路都会把**未完成任务的原文与编号**(带 Phase 分组 + `spec` 大纲)作为 `<plan>` 段喂进去,上限 40 行 / 6000 字,已勾选项不再作为未完喂入。
360
+ - **指令里点名即生效**:只认 `.agents/plans/<slug>/…` 形态(反斜杠与正斜杠都吃,不把普通英文词当 slug)。点名落空则回退到板子已绑定/自动选的计划,**不静默换成别的计划也不抛错**;`planSync=off` 时不注入且报 `reason:'disabled'`(与 `not-found` 区分)。
361
+ - **grounding 必须可见**:回执带 `plan` 元信息,输出区在喂成功时报「已按纲 `<slug>/<file>` · 勾选 12/30 · 已列未完 40」、落空时报「本次没拿到计划原料(点名落空或计划面已关)」。不这样用户就无法区分「没喂文档」与「喂了但答不上」。
362
+ - **细化提示词同时要求深度排期**:有 `<plan>` 段时以其为记录大纲,从未完项导出拆分、**按 Phase 顺序排列(依赖先行)**、标题前缀标出批次(如 `Phase 2 · …`),并不主动造计划外的工作。
363
+ - **修一个错配串 bug**:链编辑器里换供应商以前只写 provider、model 原样留着(上一个 provider 的模型名),配出必然调用失败。现在:新 provider 清单里还有当前值就保留,否则**预填该家第一个模型**,拿不到清单则清空(逼重选,不留错值)。
364
+
355
365
  ## 设置页开关(v0.7.5 表单入口,v0.7.6 写面修正,v0.7.7 脏位修正)
356
366
 
357
367
  设置页里的「进度板」分节(宿主把本插件的 composition entry 直接当成一个独立设置节,导航文案 = `setTitle`)现在共 6 组:除原有的辅助 LLM / 观察者 / 官方 todo 同步外,新增两张:
358
368
 
359
369
  - **下载感知与工序**:`download.enabled`(关掉即观察块不出 `⬇` 行、快照 `download.active` 恒为 false)、`download.showSubBar`(不再下发 download 字段)、`download.markBackground`(后台徽标)、`download.ttlMs`(一次下载算「还在跑」的窗口),以及 `toolGloss.enabled` / `toolGloss.softNarrate` / `toolGloss.maxLen`(关掉后「最近动作」逐字退回 0.6.x 的 `name×count`)。
360
- - **LLM 操作与队列提醒**:`ops.enabled`(整块开关)、**模型路由链编辑器**(v0.8.1:主路由 + 有序降级链,行级下拉/增删/排序)与 `notifyMajorChanges`(结构性变更是否落输入队列)。
370
+ - **LLM 操作与队列提醒**(v0.8.3 起取消默认折叠、v0.8.4 起排在本节第一张):`ops.enabled`(整块开关)、**模型路由链编辑器**(v0.8.1:主路由 + 有序降级链,行级下拉/增删/排序;v0.9.0:换 provider 时模型自动预填或清空)与 `notifyMajorChanges`(结构性变更是否落输入队列)。
361
371
 
362
372
  开关类拨完即落盘,数字类进草稿、点「保存」提交。**v0.7.6 前这里全是坏的**:宿主 `ConfigForm.set(field, value)` 只支持**顶层标量**(它把 path 拼成单段 `[field]`),而 `isVolatilePath` 对 `path:["ops"]` 要的是组对象自己带 volatile——本插件按表单生成规则只在**叶子**上标,所以嵌套组的整对象写回一律 `settings/rejected: Config field "ops" is not volatile`(UI 表现为「保存失败」+「有未保存的改动」)。现在嵌套组走 `scope.mutate([{ op:'set', path:[group, key], value }])` 的**叶路径**(老宿主无 `mutate` 时才退回整组 `set`);`test/settings.test.mjs` 把「设置卡实写的每条路径 ∈ volatile 叶子」钉成回归闸。**v0.7.7** 再把脏位改成「草稿值 ≠ 存值」——开关拨完即落盘,快照追平后不该再算未保存(否则「已保存」与「有未保存的改动」会并存,「保存」永远可点、还会重写同值)。
363
373
 
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.8.3"; /* ladder:ver */
27
+ var STAR_VERSION = "0.9.0"; /* 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)。
@@ -442,6 +442,10 @@ window.__ModuleLoader__.load({
442
442
  opsLocalTag: '本地',
443
443
  opsCloudTag: '云端',
444
444
  opsRouteDowngraded: '已降级到链上第 N 条路由',
445
+ opsPlanGrounded: '已按纲:',
446
+ opsPlanPending: '已列未完',
447
+ opsPlanTruncated: '(超限已截断)',
448
+ opsPlanMiss: '本次没拿到计划原料(点名落空或计划面已关):',
445
449
  opsUnconfigured: '未钉定模型路由:三个动作都不会调用模型。请在「设置 → 进度板 → LLM 操作」的路由链里添加主路由与回退行。',
446
450
  setTitle: '进度板',
447
451
  setLlmGroup: '辅助 LLM(监控/审查)',
@@ -456,6 +460,7 @@ window.__ModuleLoader__.load({
456
460
  setModeDirect: '直连端点',
457
461
  setProvider: '提供方',
458
462
  setProviderHint: 'Settings→模型 里的 provider 名(registered 必填)',
463
+ setAssistantIncomplete: '提供方或模型还没填:观察者与审查都不会调用模型 —— 界面看着像已配好,实际没有生效。',
459
464
  setModel: '模型',
460
465
  setBaseUrl: '端点地址',
461
466
  setApiKey: 'API 密钥',
@@ -682,6 +687,10 @@ window.__ModuleLoader__.load({
682
687
  opsLocalTag: 'local',
683
688
  opsCloudTag: 'cloud',
684
689
  opsRouteDowngraded: 'Fell back to chain route N',
690
+ opsPlanGrounded: 'Grounded on plan:',
691
+ opsPlanPending: 'pending listed',
692
+ opsPlanTruncated: '(truncated)',
693
+ opsPlanMiss: 'No plan material this time (named folder missing or plan sync off):',
685
694
  opsUnconfigured: 'No model route pinned: none of the three actions will call a model. Add a primary route and fallback rows under Settings → Progress board → LLM actions.',
686
695
  setTitle: 'Progress board',
687
696
  setLlmGroup: 'Assistant LLM (monitor/audit)',
@@ -696,6 +705,7 @@ window.__ModuleLoader__.load({
696
705
  setModeDirect: 'Direct endpoint',
697
706
  setProvider: 'Provider',
698
707
  setProviderHint: 'Provider name under Settings → Models (required for registered)',
708
+ setAssistantIncomplete: 'Provider or model is still empty: neither the observer nor the audit will call a model. The form looks configured but nothing runs.',
699
709
  setModel: 'Model',
700
710
  setBaseUrl: 'Endpoint URL',
701
711
  setApiKey: 'API key',
@@ -1730,8 +1740,14 @@ window.__ModuleLoader__.load({
1730
1740
  const downgraded = Number(json.routeIndex) > 0
1731
1741
  ? t('opsRouteDowngraded').replace('N', String(Number(json.routeIndex) + 1))
1732
1742
  : ''
1743
+ // v0.9.0:计划原料到底有没有喂进去必须可见 —— 否则用户分不出
1744
+ // 「模型读不到文件」与「模型拿到了但答不上」,也分不清点名落空与命中。
1745
+ const pl = json.plan && typeof json.plan === 'object' ? json.plan : null
1746
+ const grounded = pl && pl.ok && pl.slug
1747
+ ? `${t('opsPlanGrounded')} ${pl.slug}/${pl.file} · ${pl.done}/${pl.total} · ${t('opsPlanPending')} ${Number(pl.listed) || 0}${pl.truncated ? ` ${t('opsPlanTruncated')}` : ''}`
1748
+ : (pl && pl.ok === false && pl.asked ? `${t('opsPlanMiss')} ${pl.asked}` : '')
1733
1749
  const filler = (answer || changed || json.op === 'validate') ? '' : t('opsNoChanges')
1734
- const text = [filler, answer, verdict, retried, downgraded, notes.join('\n'), lines.join('\n')].filter(Boolean).join('\n')
1750
+ const text = [filler, answer, verdict, retried, downgraded, grounded, notes.join('\n'), lines.join('\n')].filter(Boolean).join('\n')
1735
1751
  const kind = v && v.ok !== true ? 'bad' : (notes.length || lines.length ? 'warn' : 'ok')
1736
1752
  return { think, kind, text }
1737
1753
  }
@@ -2473,6 +2489,7 @@ window.__ModuleLoader__.load({
2473
2489
  .dsu-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
2474
2490
  .dsu-chip { font-size: 11px; line-height: 1.6; padding: 1px 9px; border-radius: 999px; background: rgba(47,111,237,.12); color: #2f6fed; white-space: nowrap; }
2475
2491
  .dsu-chip-warn { background: rgba(217,119,6,.14); color: #b45309; }
2492
+ .dsu-warn-line { font-size: 12px; line-height: 1.6; padding: 6px 8px; border-radius: 8px; background: rgba(217,119,6,.10); color: #b45309; }
2476
2493
  .dsu-card { border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.22)); border-radius: 12px; background: var(--dsw-alias-bg-layer-1, rgba(128,128,128,.04)); overflow: hidden; }
2477
2494
  .dsu-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; user-select: none; }
2478
2495
  .dsu-card-head:hover { background: rgba(128,128,128,.06); }
@@ -2694,6 +2711,20 @@ window.__ModuleLoader__.load({
2694
2711
  const patchRow = (index, key, value) => {
2695
2712
  apply(rows.map((row, i) => (i === index ? { ...row, [key]: value } : row)))
2696
2713
  }
2714
+ // 换 provider 时模型必须跟着走(v0.9.0 真机反馈):旧写法只 patch provider,
2715
+ // 上一个 provider 的 model 原样留着,配出 provider/model 错配串,调用必失败。
2716
+ // 清单里还有当前值就保留,否则预填该家第一个;拿不到清单则清空,
2717
+ // 逼用户重选而不是留一个错值。
2718
+ const modelsOf = (providerId) => {
2719
+ const bucket = providers.find((p) => p.id === providerId) || null
2720
+ return bucket && bucket.modelsAvailable === true && Array.isArray(bucket.models) ? bucket.models : []
2721
+ }
2722
+ const pickProviderRow = (index, value) => {
2723
+ const list = modelsOf(value)
2724
+ const held = rows[index].model
2725
+ const nextModel = held && list.some((m) => m.id === held) ? held : (list.length ? list[0].id : '')
2726
+ apply(rows.map((row, i) => (i === index ? { ...row, provider: value, model: nextModel } : row)))
2727
+ }
2697
2728
  // 手输框必须带 onChange:React 对「有 value 没 onChange」的字段当只读处理,
2698
2729
  // 下一次重渲染就把用户刚打的字抹回空串(真机 0.8.1 实测:blur 后读回 value=''、
2699
2730
  // 链也没动)。所以打字只走本地草稿,blur 才提交整链。
@@ -2729,8 +2760,7 @@ window.__ModuleLoader__.load({
2729
2760
  }
2730
2761
 
2731
2762
  const rowEls = rows.map((row, index) => {
2732
- const bucket = providers.find((p) => p.id === row.provider) || null
2733
- const models = bucket && bucket.modelsAvailable === true && Array.isArray(bucket.models) ? bucket.models : []
2763
+ const models = modelsOf(row.provider)
2734
2764
  const manualModel = !models.length
2735
2765
  return h(
2736
2766
  'div',
@@ -2743,7 +2773,7 @@ window.__ModuleLoader__.load({
2743
2773
  className: 'dsu-select',
2744
2774
  value: row.provider,
2745
2775
  disabled,
2746
- onChange: (e) => patchRow(index, 'provider', e.target.value),
2776
+ onChange: (e) => pickProviderRow(index, e.target.value),
2747
2777
  },
2748
2778
  h('option', { key: '__none', value: '' }, t('setOpsChainProvider')), ...optionSet(providers, row.provider, t('setOpsChainUnlisted')),
2749
2779
  )
@@ -3038,13 +3068,36 @@ window.__ModuleLoader__.load({
3038
3068
  h('span', { className: writable ? 'dsu-chip' : 'dsu-chip dsu-chip-warn' }, writable ? t('setLive') : t('setReadOnly')),
3039
3069
  h('span', { className: 'dsu-hint' }, writable ? t('setTopHint') : t('setNoScope')),
3040
3070
  ),
3071
+ h(
3072
+ SettingsCard,
3073
+ { title: t('setOpsGroup'), badge: t('setOpsBadge'), hint: t('setOpsHint') },
3074
+ h(SettingsRow, { label: t('setOpsEnabled') }, switchInput('ops', ops, 'enabled', true)),
3075
+ h(SettingsRow, { label: t('setOpsChain'), hint: t('setOpsChainHint') },
3076
+ h(SettingsChainEditor, {
3077
+ t,
3078
+ ops,
3079
+ writable,
3080
+ busy,
3081
+ onSubmit: commitChain,
3082
+ })),
3083
+ h(SettingsRow, { label: t('setOpsPreferLocal'), hint: t('setOpsPreferLocalHint') }, switchInput('ops', ops, 'preferLocal', true)),
3084
+ h(SettingsRow, { label: t('setNotifyMajor'), hint: t('setNotifyMajorHint') },
3085
+ h(SettingsSwitch, {
3086
+ checked: Object.prototype.hasOwnProperty.call(draft, 'notifyMajorChanges') ? draft.notifyMajorChanges : value.notifyMajorChanges !== false,
3087
+ disabled: !writable || busy,
3088
+ onChange: (v) => { setDraft((prev) => ({ ...prev, notifyMajorChanges: v })); void commit('notifyMajorChanges', v) },
3089
+ })),
3090
+ ),
3041
3091
  h(
3042
3092
  SettingsCard,
3043
3093
  { title: t('setLlmGroup'), badge: t('setLlmBadge'), hint: t('setLlmHint') },
3044
3094
  h(SettingsRow, { label: t('setMode') },
3045
3095
  segmentInput('assistant', assistant, 'mode', '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]])),
3046
3096
  mode === 'registered'
3047
- ? h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') }, textInput('assistant', 'provider', '', 'local-35b'))
3097
+ ? h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') }, textInput('assistant', 'provider', '', 'local-35'))
3098
+ : null,
3099
+ mode === 'registered' && (!String(readField('assistant', 'provider', '')).trim() || !String(readField('assistant', 'model', '')).trim())
3100
+ ? h('div', { className: 'dsu-warn-line' }, t('setAssistantIncomplete'))
3048
3101
  : null,
3049
3102
  h(SettingsRow, { label: t('setModel') }, textInput('assistant', 'model', '', mode === 'direct' ? 'qwen2.5-3b' : 'Qwen3.6-35B-A3B')),
3050
3103
  mode === 'direct' ? h(SettingsRow, { label: t('setBaseUrl') }, textInput('assistant', 'baseUrl', '', 'http://127.0.0.1:8000/v1')) : null,
@@ -3077,26 +3130,6 @@ window.__ModuleLoader__.load({
3077
3130
  h(SettingsRow, { label: t('setGlossNarrate') }, switchInput('toolGloss', toolGloss, 'softNarrate', true)),
3078
3131
  h(SettingsRow, { label: t('setGlossMaxLen') }, numberInput('toolGloss', 'maxLen', 46, 1, '')),
3079
3132
  ),
3080
- h(
3081
- SettingsCard,
3082
- { title: t('setOpsGroup'), badge: t('setOpsBadge'), hint: t('setOpsHint') },
3083
- h(SettingsRow, { label: t('setOpsEnabled') }, switchInput('ops', ops, 'enabled', true)),
3084
- h(SettingsRow, { label: t('setOpsChain'), hint: t('setOpsChainHint') },
3085
- h(SettingsChainEditor, {
3086
- t,
3087
- ops,
3088
- writable,
3089
- busy,
3090
- onSubmit: commitChain,
3091
- })),
3092
- h(SettingsRow, { label: t('setOpsPreferLocal'), hint: t('setOpsPreferLocalHint') }, switchInput('ops', ops, 'preferLocal', true)),
3093
- h(SettingsRow, { label: t('setNotifyMajor'), hint: t('setNotifyMajorHint') },
3094
- h(SettingsSwitch, {
3095
- checked: Object.prototype.hasOwnProperty.call(draft, 'notifyMajorChanges') ? draft.notifyMajorChanges : value.notifyMajorChanges !== false,
3096
- disabled: !writable || busy,
3097
- onChange: (v) => { setDraft((prev) => ({ ...prev, notifyMajorChanges: v })); void commit('notifyMajorChanges', v) },
3098
- })),
3099
- ),
3100
3133
  h(
3101
3134
  SettingsCard,
3102
3135
  { title: t('setTodoGroup'), badge: t('setTodoSync'), hint: t('setTodoHint'), defaultOpen: false },
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
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
@@ -681,6 +681,16 @@ const OPS_MAX_ATTEMPTS = 3
681
681
  // v0.8.1:设置面路由链编辑器的链长上限(含主路由那一行)。客户端截断、
682
682
  // 服务端只读回显,不拿它拒写(配置手写超上限时降级链照旧逐条试)。
683
683
  const OPS_MAX_CHAIN = 6
684
+ // v0.9.0:ops 的计划原料上限(只读)。planBrief 是给观察者的 8 项摘要,
685
+ // 而「以 tasks.md 为纲再细化」需要未完成任务的原文与编号,所以单给一份宽的。
686
+ const OPS_PLAN_MAX_LINES = 40
687
+ const OPS_PLAN_MAX_CHARS = 6000
688
+
689
+ // 从指令文本里认计划目录名:只认 `.agents/plans/<slug>/` 形态,不把普通英文词当 slug。
690
+ function planSlugFromText(text) {
691
+ const m = /\.agents[\\/]+plans[\\/]+([A-Za-z0-9._-]{2,80})(?![A-Za-z0-9._-])/.exec(String(text || ''))
692
+ return m ? m[1] : ''
693
+ }
684
694
  const OPS_KINDS = new Set(['refine', 'mutate', 'ask', 'validate'])
685
695
  const OPS_CHANGE_KINDS = new Set(['add', 'edit', 'remove'])
686
696
  // edit 至少要动这一个字段,否则这条改动落下去什么都没变(模型爱犯的空转)。
@@ -876,6 +886,9 @@ const OPS_STRICT_NOTE = ' Your output is checked line by line before it touches
876
886
  const OPS_REFINE_SYSTEM = 'You refine a user-facing task board so the work is easier to track. '
877
887
  + 'Given the board checklist and an optional focus item, split coarse items into smaller verifiable ones, '
878
888
  + 'give each a concrete title and (when known) current/next text. '
889
+ + 'When a <plan> block is given, it is the outline of record: derive the breakdown from its unfinished tasks, '
890
+ + 'order the result by phase so dependencies come first, and prefix each title with its phase short name so the batch is visible. '
891
+ + 'Never claim you cannot read files: the plan text is already in front of you. '
879
892
  + 'Rules: at most ' + OPS_MAX_CHANGES + ' changes; only ONE item may be doing; keep existing ids when editing; '
880
893
  + 'never invent completed work; never touch items outside the given board. '
881
894
  + 'Output strictly ONE JSON object: '
@@ -883,6 +896,7 @@ const OPS_REFINE_SYSTEM = 'You refine a user-facing task board so the work is ea
883
896
  + ' Respond with the JSON object only — no prose, no code fences.'
884
897
 
885
898
  const OPS_MUTATE_SYSTEM = 'You apply one user instruction to a user-facing task board: add, edit, reorder or remove items. '
899
+ + 'When a <plan> block is given, use its wording and task ids as the source of truth for what you add or edit. '
886
900
  + 'Rules: change only what the instruction asks for; at most ' + OPS_MAX_CHANGES + ' changes; use the ids given in the board for edit/remove; '
887
901
  + 'use "order" (0-based) to reorder; never invent completed work; if the instruction is not actionable on a task board, '
888
902
  + 'return zero changes and say why in the answer. '
@@ -890,15 +904,15 @@ const OPS_MUTATE_SYSTEM = 'You apply one user instruction to a user-facing task
890
904
  + OPS_JSON_SHAPE + '.' + OPS_STRICT_NOTE
891
905
  + ' Respond with the JSON object only — no prose, no code fences.'
892
906
 
893
- const OPS_ASK_SYSTEM = 'You answer ONE short question about a task board, using ONLY the checklist given to you. '
907
+ const OPS_ASK_SYSTEM = 'You answer ONE short question about a task board, using the board checklist and the <plan> block given to you. '
894
908
  + 'You must not change the board: always return an empty changes array. '
895
- + 'If the board does not contain the answer, say so plainly instead of guessing. '
909
+ + 'If neither the board nor the plan block contains the answer, say so plainly instead of guessing; never say you cannot open files. '
896
910
  + 'Answer in the same language as the board, in at most 600 characters. '
897
911
  + 'Output strictly ONE JSON object: {"thinking":"<你凭什么这么答,≤200 字>","changes":[],"answer":"<text>"}. '
898
912
  + 'Respond with the JSON object only — no prose, no code fences.'
899
913
 
900
914
  // 纯解析函数导出(仅供 test/plan.test.mjs 单测;不在 dsh 契约面上,勿在插件间消费)。
901
- export { parseChecklistMarkdown, parseSpecOutline, normalizeStatus, planDirCandidates, pickPlanDir, classifyDownload, parseProgress, unwrapAct, isDownloadItem, describeToolStep, glossCommand, resultDigest, validateBoard, validateProposal, withOpsFeedback, isLocalRouteName, buildOpsChain }
915
+ export { parseChecklistMarkdown, parseSpecOutline, normalizeStatus, planDirCandidates, pickPlanDir, classifyDownload, parseProgress, unwrapAct, isDownloadItem, describeToolStep, glossCommand, resultDigest, validateBoard, validateProposal, withOpsFeedback, isLocalRouteName, buildOpsChain, planSlugFromText }
902
916
 
903
917
  const PROGRESS_POLICY = `## 进度板
904
918
  progress_update 维护用户可见的实时进度板。每项含 title/status/percent/current/next/approach/note。
@@ -3738,6 +3752,14 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3738
3752
  '</progress-board>',
3739
3753
  '',
3740
3754
  ]
3755
+ // v0.9.0:把计划文档当原料喂进来。用户说「以 .agents/plans/<slug>/tasks.md 为纲再细化」
3756
+ // 时,旧版只把板子给模型,模型只能答“这是咨询、不执行”——它真的没拿到文件。
3757
+ const plan = opsPlanBrief(sessionId, question)
3758
+ if (plan.block) {
3759
+ lines.push('')
3760
+ lines.push(plan.block)
3761
+ lines.push('')
3762
+ }
3741
3763
  if (op === 'refine') {
3742
3764
  const target = targetId ? state.items.find((item) => item.id === targetId) : null
3743
3765
  lines.push(target
@@ -3794,11 +3816,11 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3794
3816
  const answer = text(String(proposal.answer || proposal.note || ''), 1200)
3795
3817
  if (op === 'ask') {
3796
3818
  // 问询只回文本:即使模型硬塞了 changes 也不落盘。
3797
- return { ok: true, op, applied: false, changes: [], warnings: [], thinking, attempts: served.attempts, route: served.route, routeIndex: served.index, answer: answer || '(模型未给出回答)' }
3819
+ return { ok: true, op, applied: false, changes: [], warnings: [], thinking, attempts: served.attempts, route: served.route, routeIndex: served.index, plan: plan.meta, answer: answer || '(模型未给出回答)' }
3798
3820
  }
3799
3821
  const mapped = opsChanges(state, proposal)
3800
3822
  if (mapped.length === 0) {
3801
- return { ok: true, op, applied: false, changes: [], warnings: answer ? [] : ['模型未提出可用改动'], thinking, attempts: served.attempts, route: served.route, routeIndex: served.index, answer: answer || '无需改动' }
3823
+ return { ok: true, op, applied: false, changes: [], warnings: answer ? [] : ['模型未提出可用改动'], thinking, attempts: served.attempts, route: served.route, routeIndex: served.index, plan: plan.meta, answer: answer || '无需改动' }
3802
3824
  }
3803
3825
  const result = await applyChanges({ sessionId, changes: mapped, origin: 'ops' })
3804
3826
  const post = validateBoard(result.snapshot.items)
@@ -3812,6 +3834,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3812
3834
  attempts: served.attempts,
3813
3835
  route: served.route,
3814
3836
  routeIndex: served.index,
3837
+ plan: plan.meta,
3815
3838
  // 落盘后的板面体检结论:不再占一个按钮,随每次回答自动跑。
3816
3839
  // 客户端只在「不 ok 或有提醒」时才把它显示出来,顺利通过时不占输出区。
3817
3840
  validation: { ok: post.ok, count: post.count, errors: post.errors, warnings: post.warnings },
@@ -3834,7 +3857,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3834
3857
  const cwdBySession = new Map()
3835
3858
 
3836
3859
  /** 扫描并缓存当前会话的 plan 文档。cwd 拿不到时返回 null(不猜 process.cwd())。 */
3837
- function scanPlan(sid) {
3860
+ function scanPlan(sid, preferredOverride) {
3838
3861
  if (String(cfg.planSync || 'off') === 'off') return null
3839
3862
  let cwd = cwdBySession.get(sid) || ''
3840
3863
  if (!cwd) {
@@ -3844,7 +3867,7 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3844
3867
  }
3845
3868
  if (!cwd) return null
3846
3869
  const state = states.get(sid)
3847
- const preferred = state ? String(state.planSlug || '') : ''
3870
+ const preferred = String(preferredOverride || '') || (state ? String(state.planSlug || '') : '')
3848
3871
  const hit = pickPlanDir(cwd, preferred)
3849
3872
  if (!hit) {
3850
3873
  planCache.delete(sid)
@@ -3910,6 +3933,60 @@ ${reason}。本回合开始前先用 progress_update 处理进度板:用户这
3910
3933
  return `[plan] ${p.slug}:勾选 ${p.counts.done}/${p.counts.total}${phase}${p.truncated ? '(已截断)' : ''}`
3911
3934
  }
3912
3935
 
3936
+ /**
3937
+ * ops 专用的计划原料(v0.9.0)。与 planBrief 的差别:这里要的是**未完成任务的
3938
+ * 原文与编号**(细化要拿它当纲),不是八行摘要。三条约束:
3939
+ * ① 指令点名 `.agents/plans/<slug>/` 时优先用它;点名落空则回退到绑定/自动选,
3940
+ * 并在 meta 里如实报告 asked —— 不静默换成别的计划;
3941
+ * ② 只读,上限 OPS_PLAN_MAX_LINES 行 / OPS_PLAN_MAX_CHARS 字,截断情况写进 meta;
3942
+ * ③ 拿不到就回空 block,动作照常跑(计划面是加强,不是前置条件)。
3943
+ */
3944
+ function opsPlanBrief(sid, instruction) {
3945
+ const asked = planSlugFromText(instruction)
3946
+ let data = asked ? scanPlan(sid, asked) : scanPlan(sid)
3947
+ if (!data && asked) data = scanPlan(sid)
3948
+ if (!data || !data.counts || data.counts.total === 0) {
3949
+ // 原因分开报:计划面被关掉与点名落空是两件不同的事,文案不能混为一谈。
3950
+ const gated = String(cfg.planSync || 'off') === 'off'
3951
+ return { block: '', meta: asked ? { asked, ok: false, reason: gated ? 'disabled' : 'not-found' } : null }
3952
+ }
3953
+ const lines = [`<plan slug="${data.slug}" file="${data.file}">`]
3954
+ lines.push(`勾选:${data.counts.done}/${data.counts.total}(${data.counts.pending} 项未完成)${data.truncated ? '(原文超限已截断)' : ''}`)
3955
+ let emitted = 0
3956
+ let chars = 0
3957
+ let budgetOut = false
3958
+ for (const phase of data.phases) {
3959
+ const pending = phase.tasks.filter((t) => !t.checked)
3960
+ if (!pending.length) continue
3961
+ lines.push(`【${phase.title || '未分组'}】`)
3962
+ for (const t of pending) {
3963
+ if (emitted >= OPS_PLAN_MAX_LINES || chars >= OPS_PLAN_MAX_CHARS) { budgetOut = true; break }
3964
+ const line = `${t.id ? t.id + ' ' : ''}${t.text.slice(0, 160)}`
3965
+ lines.push(line)
3966
+ emitted += 1
3967
+ chars += line.length
3968
+ }
3969
+ if (budgetOut) break
3970
+ }
3971
+ if (budgetOut || emitted < data.counts.pending) lines.push(`(只列前 ${emitted} 项,共 ${data.counts.pending} 项未完)`)
3972
+ if (data.spec && data.spec.length) lines.push(`spec 大纲:${data.spec.slice(0, 12).map((s) => s.title).join(' / ')}`)
3973
+ lines.push('</plan>')
3974
+ return {
3975
+ block: lines.join('\n'),
3976
+ meta: {
3977
+ asked,
3978
+ ok: true,
3979
+ slug: data.slug,
3980
+ file: data.file,
3981
+ done: data.counts.done,
3982
+ total: data.counts.total,
3983
+ pending: data.counts.pending,
3984
+ listed: emitted,
3985
+ truncated: Boolean(data.truncated) || budgetOut,
3986
+ },
3987
+ }
3988
+ }
3989
+
3913
3990
  // ==========================================================================
3914
3991
  // B4. 回勾(planSync='sync' 才启用):板项 done → tasks.md 的 `- [ ]` → `- [x]`
3915
3992
  // 写用户文件是高风险动作,护栏三层:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
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",
@@ -443,6 +443,28 @@ test('v0.8.1:链编辑器文案 zh/en 成对', () => {
443
443
  assert.match(src, /setOpsChainMax: 'Chain capped at N rows/, 'en 链长上限文案要带 N 占位')
444
444
  })
445
445
 
446
+ // v0.8.4:registered 模式下 provider/model 未填时的警示行文案。
447
+ // 这一行专门用来防「界面看着像配好了、实际 assistantReady() 为 false」的误读。
448
+ test('v0.8.4:辅助 LLM 未填全的警示行文案 zh/en 成对', () => {
449
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
450
+ const hits = src.match(/\n\s+setAssistantIncomplete: '[^']+',/g) || []
451
+ assert.equal(hits.length, 2, `setAssistantIncomplete 必须在 zh/en 各出现一次(实得 ${hits.length})`)
452
+ })
453
+
454
+ // v0.9.0:计划原料的 grounding 回报行。这四个键都是输出区直接可见的字,
455
+ // 漏一语就露键名;而 grounding 不回报的话,用户就无法区分「没喂文档」与「喂了答不上」。
456
+ test('v0.9.0:计划 grounding 回报文案 zh/en 成对', () => {
457
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
458
+ for (const k of ['opsPlanGrounded', 'opsPlanPending', 'opsPlanTruncated', 'opsPlanMiss']) {
459
+ const hits = src.match(new RegExp(`\\n\\s+${k}: '[^']+',`, 'g')) || []
460
+ assert.equal(hits.length, 2, `${k} 必须在 zh/en 各出现一次(实得 ${hits.length})`)
461
+ }
462
+ // grounded 行必须拼进输出区,且两种情态(命中/落空)都要有分支
463
+ assert.match(src, /const grounded = pl && pl\.ok && pl\.slug/, '命中计划时要拼 grounding 行')
464
+ assert.match(src, /pl && pl\.ok === false && pl\.asked/, '点名落空/被关时要走 miss 分支')
465
+ assert.match(src, /retried, downgraded, grounded, notes\.join/, 'grounded 必须进输出区的行列表')
466
+ })
467
+
446
468
  test('0.7.0:新增任务 wake 与 R4 落队列互斥,同一次改板队列里只留一条', () => {
447
469
  const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
448
470
  // 真机偏差:面板加两项后 input-traffic 出现两条同文排队条目——客户端 wake 与
package/test/ops.test.mjs CHANGED
@@ -16,7 +16,7 @@ import test from 'node:test'
16
16
 
17
17
  process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
18
18
  const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.mjs')
19
- const { validateBoard, validateProposal, isLocalRouteName, buildOpsChain, withOpsFeedback } = await import('../index.js')
19
+ const { validateBoard, validateProposal, isLocalRouteName, buildOpsChain, withOpsFeedback, planSlugFromText } = await import('../index.js')
20
20
 
21
21
  const OPS = '/progress-union/ops'
22
22
 
@@ -30,13 +30,14 @@ function llmMock(reply, calls) {
30
30
  }
31
31
  }
32
32
 
33
- async function booted({ config = {}, reply = '{}', calls = [], providers = undefined, models = undefined } = {}) {
33
+ async function booted({ config = {}, reply = '{}', calls = [], providers = undefined, models = undefined, cwd = '' } = {}) {
34
34
  const llm = {
35
35
  ...llmMock(reply, calls),
36
36
  ...(providers ? { listProviders: async () => providers } : {}),
37
37
  ...(models ? { listModels: typeof models === 'function' ? models : async () => models } : {}),
38
38
  }
39
39
  const harness = createHarness({
40
+ ...(cwd ? { cwd } : {}),
40
41
  config: {
41
42
  assistant: { mode: 'registered', provider: 'local', model: 'qwen', minIntervalMs: 0 },
42
43
  // v0.8.0:ops 的介入范围 = 白名单。默认钉一条 local/qwen(与 llmMock 对得上),
@@ -550,3 +551,88 @@ test('ops 落盘不重置 stepsSinceModel:催办仍按原步数报滞后', asy
550
551
  assert.equal(r.json.applied, true)
551
552
  assert.match(text(), /synced="4 步前"/, '侧边栏 LLM 操作不算「模型已同步」')
552
553
  })
554
+
555
+ // ── v0.9.0:计划文档进 ops 原料 ────────────────────────────────────
556
+ // 真机反馈:用户写「是否可以对 …\.agents\plans\session-exclusion-gate\tasks.md 任务为纲再细化」,
557
+ // 模型答“这属于咨询、不执行”——它确实只拿到板子清单,没有任何文件面。
558
+ // 本仓早就有 scanPlan/parseChecklistMarkdown 这套原料机器(给观察者用),ops 必须接上。
559
+
560
+ test('planSlugFromText:只认 .agents/plans/<slug>/ 形态,反斜杠与正斜杠都吃', () => {
561
+ assert.equal(planSlugFromText('按 E:\\test\\repo\\.agents\\plans\\session-exclusion-gate\\tasks.md 为纲细化'), 'session-exclusion-gate')
562
+ assert.equal(planSlugFromText('看 /home/me/.agents/plans/demo-plan/checklist.md 的第 3 项'), 'demo-plan')
563
+ assert.equal(planSlugFromText('把「做点事」拆细一点'), '', '普通英文词不得被当 slug')
564
+ assert.equal(planSlugFromText('.agents/plans/ab/tasks.md'), 'ab')
565
+ })
566
+
567
+ function mkOpsPlan() {
568
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'union-ops-plan-'))
569
+ const dir = path.join(cwd, '.agents', 'plans', 'demo-plan')
570
+ fs.mkdirSync(dir, { recursive: true })
571
+ fs.writeFileSync(path.join(dir, 'tasks.md'), '## Phase 1: 做点事\n- [x] t01 第一件事\n- [ ] t02 第二件事\n\n## Phase 2: 收尾\n- [ ] t03 第三件事\n', 'utf8')
572
+ fs.writeFileSync(path.join(dir, 'spec.md'), '# Spec: 演示\n\n## 需求\n- 让 ops 读计划\n', 'utf8')
573
+ return cwd
574
+ }
575
+
576
+ test('v0.9.0:ops ask 把点名的计划未完项喂进助手,并在回执报 grounding', async () => {
577
+ const calls = []
578
+ const cwd = mkOpsPlan()
579
+ const harness = await booted({ cwd, calls, reply: '{"thinking":"按纲","changes":[],"answer":"t02 与 t03 还没做"}' })
580
+ const named = path.join(cwd, '.agents', 'plans', 'demo-plan', 'tasks.md')
581
+ const { status, json } = await ops(harness, { sessionId: SESSION, op: 'ask', question: `按 ${named} 为纲,还剩哪些没做` })
582
+ assert.equal(status, 200, JSON.stringify(json))
583
+ const user = calls[0].messages[0].content[0].text
584
+ assert.ok(user.includes('<plan slug="demo-plan"'), '助手输入必须带计划段')
585
+ assert.ok(user.includes('t02 第二件事') && user.includes('t03 第三件事'), '未完项原文与编号必须进原料')
586
+ assert.ok(!user.includes('t01 第一件事'), '已勾选项不再当未完喂入')
587
+ assert.ok(user.includes('Phase 1: 做点事'), 'Phase 分组要在')
588
+ assert.ok(user.includes('spec 大纲'), 'spec 大纲也要在')
589
+ assert.equal(json.plan.ok, true)
590
+ assert.equal(json.plan.slug, 'demo-plan')
591
+ assert.equal(json.plan.asked, 'demo-plan', '点名要如实回报')
592
+ assert.equal(json.plan.pending, 2)
593
+ assert.equal(json.plan.listed, 2)
594
+ })
595
+
596
+ test('v0.9.0:refine 同样拿到计划段,且指令仍在尾部(模型重尾)', async () => {
597
+ const calls = []
598
+ const cwd = mkOpsPlan()
599
+ const harness = await booted({ cwd, calls, reply: '{"changes":[{"kind":"add","title":"Phase 2 · 拆 t03"}],"answer":"ok"}' })
600
+ const r = await ops(harness, { sessionId: SESSION, op: 'refine', question: `以 ${path.join(cwd, '.agents', 'plans', 'demo-plan', 'tasks.md')} 为纲拆分` })
601
+ assert.equal(r.json.applied, true)
602
+ const user = calls[0].messages[0].content[0].text
603
+ const atPlan = user.indexOf('<plan slug="demo-plan"')
604
+ const atCmd = user.indexOf('用户补充:')
605
+ assert.ok(atPlan > 0, '计划段必须在')
606
+ assert.ok(atCmd > atPlan, `指令要排在计划段之后(plan=${atPlan} cmd=${atCmd})`)
607
+ assert.ok(user.indexOf('<progress-board') < atPlan, '计划段在板子清单之后、指令之前')
608
+ })
609
+
610
+ test('v0.9.0:planSync=off 时不注入计划段,但动作照常并报 reason=disabled', async () => {
611
+ const calls = []
612
+ const cwd = mkOpsPlan()
613
+ const harness = await booted({
614
+ cwd,
615
+ calls,
616
+ config: { planSync: 'off' },
617
+ reply: '{"thinking":"","changes":[],"answer":"ok"}',
618
+ })
619
+ const named = path.join(cwd, '.agents', 'plans', 'demo-plan', 'tasks.md')
620
+ const r = await ops(harness, { sessionId: SESSION, op: 'ask', question: `${named} 还剩什么` })
621
+ assert.equal(r.status, 200, '计划面关掉不能连带把 ops 动作打死')
622
+ assert.ok(!calls[0].messages[0].content[0].text.includes('<plan'), 'off 时不得注入计划段')
623
+ assert.equal(r.json.plan.ok, false)
624
+ assert.equal(r.json.plan.reason, 'disabled', '要区分“被关掉”与“点名落空”')
625
+ assert.equal(r.json.plan.asked, 'demo-plan')
626
+ })
627
+
628
+ test('v0.9.0:点名不存在的 slug 时回退自动选,不静默抛错', async () => {
629
+ const calls = []
630
+ const cwd = mkOpsPlan()
631
+ const harness = await booted({ cwd, calls, reply: '{"thinking":"","changes":[],"answer":"ok"}' })
632
+ const r = await ops(harness, { sessionId: SESSION, op: 'ask', question: `按 ${path.join(cwd, '.agents', 'plans', 'no-such-plan', 'tasks.md')} 细化` })
633
+ assert.equal(r.status, 200)
634
+ const user = calls[0].messages[0].content[0].text
635
+ assert.equal(r.json.plan.asked, 'no-such-plan', '点名原值要留着供面板报信')
636
+ assert.equal(r.json.plan.slug, 'demo-plan', '回退到自动选,不空转')
637
+ assert.ok(user.includes('<plan slug="demo-plan"'), '回退后的原料照样喂')
638
+ })
@@ -195,6 +195,40 @@ test('v0.8.1:路由链编辑器的写面与降级形态', () => {
195
195
  assert.ok(!/setOpsGroup'[^}]*defaultOpen: false/.test(src), 'ops 卡不得再默认折叠,主+fallback 要一眼可见')
196
196
  })
197
197
 
198
+ /**
199
+ * v0.8.4 真机回灌:取消折叠只是第一步——卡仍在第 4 张,不滚就看不到;
200
+ * 而 provider 输入框的占位符写的是宿主并不存在的 `local-35b`,用户会把
201
+ * 灰色占位当已存值(本轮我就误判过一次),而 registered + 空 provider
202
+ * 会让 assistantReady() 直接返回 false,观察者静默不跑。
203
+ */
204
+ test('设置页:路由链卡排第一,且占位符不误导、未填全要给警示', () => {
205
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
206
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
207
+ const iOps = src.indexOf("title: t('setOpsGroup')")
208
+ const iLlm = src.indexOf("title: t('setLlmGroup')")
209
+ const iObs = src.indexOf("title: t('setObserverGroup')")
210
+ assert.ok(iOps > 0 && iOps < iLlm && iLlm < iObs, `渲染顺序必须是 ops→LLM→观察者(实得 ops=${iOps} llm=${iLlm} obs=${iObs})`)
211
+ assert.ok(!src.includes("'local-35b'"), 'provider 占位符不得写宿主不存在的 local-35b')
212
+ assert.match(src, /textInput\('assistant', 'provider', '', 'local-35'\)/, '占位符要用宿主真实注册键 local-35')
213
+ assert.match(src, /mode === 'registered' && \(!String\(readField\('assistant', 'provider', ''\)\)\.trim\(\)/, 'registered 但 provider/model 未填全时必须给警示行')
214
+ assert.match(src, /className: 'dsu-warn-line'/, '警示行要有独立样式(沿用既有琥珀档位,不发明令牌)')
215
+ })
216
+
217
+ /**
218
+ * v0.9.0 真机反馈:换 provider 后 model 仍是上一个 provider 的值,配出
219
+ * provider/model 错配串(调用必失败)。写面闸:provider 的 onChange 不得再走
220
+ * 单字段 patchRow,必须走会同时处理 model 的 pickProviderRow。
221
+ */
222
+ test('链编辑器:换 provider 必须同时处理 model(预填或清空,不得留旧值)', () => {
223
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
224
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
225
+ assert.ok(!/patchRow\(index, 'provider'/.test(src), "provider 切换不得再走单字段 patchRow(会留下上一个 provider 的 model)")
226
+ assert.match(src, /onChange: \(e\) => pickProviderRow\(index, e\.target\.value\)/, 'provider 下拉必须走 pickProviderRow')
227
+ assert.match(src, /const pickProviderRow = \(index, value\) => \{[\s\S]{0,400}?model: nextModel/, 'pickProviderRow 必须同时写 model')
228
+ assert.match(src, /held && list\.some\(\(m\) => m\.id === held\) \? held : \(list\.length \? list\[0\]\.id : ''\)/, '保留条件:新 provider 清单里有则留,否则预填第一个,拿不到清单则清空')
229
+ assert.match(src, /const models = modelsOf\(row\.provider\)/, '行内模型清单与预填逻辑共用同一个源,不能两套口径')
230
+ })
231
+
198
232
  /**
199
233
  * v0.7.7 真机回灌:0.7.6 修好写面后,页脚出现「已保存」与「有未保存的改动」并存
200
234
  * —— 开关拨完即落盘,但乐观草稿仍按「键存在」计脏。脏位必须按值比对。