dsh-workplan 2.0.3 → 2.1.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
@@ -1,3 +1,109 @@
1
+ ## 2.1.0 — 2026-11-06
2
+
3
+ **建立主 Agent 与部门人员之间的统一沟通交流格式契约(下发—自检—核验—退回闭环),并保留 2.0.5 草案的规划器 JSON 结构修复。**
4
+
5
+ ### 一、问题与证据链
6
+
7
+ 用户 2026-11-05 在同一会话里连续两次遇到自动分解失败:
8
+
9
+ | # | 事实 | 证据 |
10
+ |---|---|---|
11
+ | 1 | 第一次:`Expected ',' or '}' after property value in JSON at position 12475` | 会话降级消息原文 |
12
+ | 2 | 第二次:规划器 JSON 被 max tokens 截断,旧实现先 `lastIndexOf('}')` 找不到结尾括号,直接判 `NO_JSON` | `src/plan.ts#extractJson` 旧实现 |
13
+ | 3 | 两次都不是「没规划」,而是「规划结果有一个字符的结构瑕疵」 | 降级消息均带 `degraded:true` 与原 JSON 错误 |
14
+
15
+ 2.0.4 修的是**子 Agent 回执**的解析(`repairEvidenceJson`),规划器入口的 `extractJson` 仍是裸 `JSON.parse`,是同一个病根的另一个出口。
16
+
17
+ ### 二、改了什么
18
+
19
+ - **结构修复**:新增 `repairJsonStructure()`——配平未闭合的 `{` `[` `"`、去掉尾逗号、把字符串内的裸换行/制表符/控制符转义。**只修结构,不新增或猜测任何字段值**。
20
+ - **截断修复**:新增 `truncatedCandidates()`——输出被 max tokens 截断时,从尾部逐个丢弃不完整成员(每次都是「本来就残缺、不可用」的内容),最多 24 轮,每轮尝试解析。
21
+ - **不再误判 NO_JSON**:旧实现要求文本里存在结尾 `}`,截断输出因此被判「没有 JSON 对象」;现在只要以 `{` 起头就进入修复流程。
22
+ - **失败仍然如实报错**:修不好照旧抛 `INVALID_JSON`,不静默返回空计划;成功修复时打印一条 warn 日志说明「只补括号/逗号,未改内容」。
23
+
24
+ ### 三、验证
25
+
26
+ - 新增离线自检 10 条,全部通过:合法 JSON、少一个 `}`、少两个 `}]`、尾逗号、字符串内裸换行、截断 70%、截断 55%、代码块包裹、无 JSON(应抛 `NO_JSON`)、纯空白(应抛 `EMPTY_OUTPUT`)。
27
+ - `npm run check`(tsc --noEmit)退出码 0;`npm run build` 重新生成 `lib/`、`dist/`、`client.js`。
28
+ - `npm test` 全套回归见本版本 CI 输出。
29
+
30
+ ### 四、边界(不夸大)
31
+
32
+ - 结构修复无法把「内容本身就错」的 JSON 变成正确内容;它只解决括号/逗号/截断这类机械损伤。
33
+ - 丢弃尾部残缺成员意味着该成员的信息丢失,调用方的 schema 校验仍会拦下缺字段的计划,不会因此产出半成品计划。
34
+
35
+ ### 五、沟通交流格式契约(本次核心)
36
+
37
+ 用户 2026-11-06 的强制要求:派发工作的同时附带一份统一的沟通交流格式要求;部门人员提交结果前依此自查;主 Agent 收到后依同一份格式核验,不合规立刻退回,通知其重新检查格式后全盘重交。
38
+
39
+ | 环节 | 落地位置 | 行为 |
40
+ |---|---|---|
41
+ | 下发 | `src/comm-format.ts#renderCommFormatSpec` → `src/plan.ts#buildChildPrompt` 末尾 | 每个子任务提示都附带 F1–F9 九条格式规范与「提交前自查(强制)」指令 |
42
+ | 自检 | 同上(提示词内强制指令) | 部门人员提交前逐条对照 F1–F9 |
43
+ | 核验 | `src/comm-format.ts#checkCommFormatCompliance` → `src/plan.ts#adjudicateResult` done 路径前 | 主 Agent 用同一份规范逐条核验 F1–F8(F9 为诚信约束,由三阶段门禁与人工复核兜底) |
44
+ | 退回 | `adjudicateResult` 返回 `blockedKind:'comm-format'` + `renderCommFormatRejection` | 不合规即判 blocked,退回通知写明逐条不合规项与修正要求 |
45
+ | 重交 | `src/runtime.ts#executeSubtask` 的 `lastFailure` 注入 | 复位重派时把退回通知作为上次失败原因(`COMM_FORMAT_REJECTED`)随提示词发回,子 Agent 看到具体不合规条目,只补缺口不重做 |
46
+
47
+ 九条规范:F1 证据块标记成对、F2 status 合法、F3 三阶段齐全、F4 pass 必须带证据、F5 验收条数不少于计划、F6 产物条目合法(kind ∈ file/url/note 且 ref 非空)、F7 复盘四项、F8 blocked 必须带 question、F9 不得编造。
48
+
49
+ 设计边界(不夸大):
50
+
51
+ - 只拦 `done` 路径。解析失败、验收缺口、三阶段缺失已被更早的门禁拦下,保留原有更具针对性的诊断,不用格式条目覆盖。
52
+ - `requirePhases:false`(历史回放 / 明确关闭新契约)不追溯否决旧日志里按当时规则合法的 done。
53
+ - F6 只校验「产物声明的合法性」,是否必须交付文件由计划验收标准决定——避免把无文件产物的写作类子任务误判为不合规。
54
+ - F9 不做自动判定:编造检测需要语义理解而非结构校验,把它写成提示词级诚信约束,由三阶段门禁与人工复核承担。
55
+
56
+ ### 六、验证
57
+
58
+ - `npm run check`(tsc --noEmit)退出码 0。
59
+ - `npm test`:578 条用例,pass 578 / fail 0。
60
+ - 新增 `tests/workplan-comm-format.test.ts`:覆盖 F1–F8 逐条拒收、合规放行、退回通知文案、`requirePhases:false` 兼容边界。
61
+ - 既有用例按新契约修订 1 条:`workplan-evidence-contract.test.ts` 的 C-19 由「空证据 pass 降级 unverified 仍算 done」改为「按 F4 退回 blocked/comm-format」——这是用户要求的行为前移,不是放宽。
62
+
63
+ ## 2.0.4 — 2026-11-05
64
+
65
+ **修复「子 Agent 干完活却交不了差」的四条判定缺陷,并给交互式会话收尾加上「放行但留痕」。**
66
+
67
+ ### 一、问题与证据链
68
+
69
+ 用户 2026-11-05 报告:计划里 5 个子 Agent 的产物都已在磁盘上,结果却被判「结果块无法解析」「未提供结构化证据块」,交付门禁反复重开;同一会话里还出现「子任务没完成就先给结论」。
70
+
71
+ 逐条核对子会话原始回执后确认,这不是模型没干活,而是四处判定把「格式瑕疵」当成了「没有证据」:
72
+
73
+ | # | 事实 | 证据 |
74
+ |---|---|---|
75
+ | 1 | 3 份回执**结尾各少一个 `}`**,补一个括号后 `JSON.parse` 立即通过 | 逐字符括号扫描;补后解析成功 |
76
+ | 2 | 2 份回执 JSON 合法,只是**漏写 `WORKPLAN_EVIDENCE` 标记**(放在代码块里) | 旧实现判「未提供证据块」,与事实相反 |
77
+ | 3 | 旧验收只做 `实际文本.includes(声明原文)`,同义改写一律判「没回应」 | `acceptanceCoverage()` |
78
+ | 4 | `reported` 状态没有 `done` 出边,复核已回报的行必撞「非法闭环迁移」 | 状态迁移表 |
79
+ | 5 | 交互式会话 steer 上限 2 次,用尽后静默放行,用户看不到「这次是没做完就收尾」 | `onTurnStopping` |
80
+
81
+ ### 二、改了什么
82
+
83
+ - **回执解析有界修复**:新增 `closeOpenJson` / `lastSafeCut` / `repairEvidenceJson`,只在结构层补括号与截断,不补内容;修不好的仍如实报错,并给出「只保留 status/summary/acceptance/artifacts/needs 后重发」的下一步。
84
+ - **无标记回执可认领**:新增 `rescueEvidenceFromFence()`,仅在缺规定标记时,从代码块中认领「有 `status` 且至少带一个证据字段」的对象;计划载荷、配置片段这类普通 JSON 不会被误认。
85
+ - **验收匹配放宽到语义层**:新增字符二元组 Dice 相似度与否定词一致性校验——同义改写、语序调整算同一条;**删掉「不得」这类否定词,或只抄前半句,仍然判不覆盖**。
86
+ - **状态机补齐**:已回报的行再次交付时保持 `reported`,不再强写 `done`,也不再报非法迁移。
87
+ - **交互式收尾「放行但留痕」(方案 B)**:steer 用尽时不再沉默 `return`,而是把 `releasedIncomplete`(轮次、进度、未完成项)记入计划状态、向会话追加一条 notice、并写一条 warn 日志;三处使用同一组数字。headless 场景维持原有 `WORKPLAN_INCOMPLETE` 硬失败语义。
88
+ - **错误文案分档**:截断、少闭合符、缺标记三种情况给出各自的修复指令,不再统一说「无法解析」。
89
+
90
+ ### 三、验证
91
+
92
+ - 新增 `tests/workplan-user-logic-204.test.ts`:13 条用例覆盖同义改写、部分回应、删否定词、只抄前半句、缺括号、缺标记、误认普通 JSON、已回报复核。其中「删否定词」「只抄前半句」两类假阳性由独立复核子 Agent 用 18 条真实差异对复现后补入。
93
+ - `npm test`:**562 条用例全过,0 失败**。
94
+ - `npm run build` 重新生成 `lib/`、`dist/`、`client.js`,与 `src/` 同步。
95
+ - `npm pack --dry-run` 文件清单核对:不含 `.backups`、`node_modules`、测试临时文件与任何凭证。
96
+
97
+ ### 四、范围说明(重要)
98
+
99
+ 本版本**不含**官方 `@deepseek-ai/dsh-client-ui-chat` 的界面文案改动。那条改动(「已完成,用时 」→「本轮过程已完成,用时 」)落在第三方包内部文件,属官方 DSH 安装目录,不随本包分发;需要的话请按仓库文档中的说明自行替换,或等待上游修复。
100
+
101
+ ### 五、发布
102
+
103
+ - npm:`dsh-workplan@2.0.4`
104
+ - GitHub Release:`v2.0.4`,附 `dsh-workplan-2.0.4.tgz` 制品与 SHA256
105
+ - 索引源(dsh-plugin-catalog 链路):条目 tarball 指向 `v2.0.4` Release,由上游 CI 生成 catalog
106
+
1
107
  ## 2.0.3 — 2026-11-05
2
108
 
3
109
  **修复「官方 `/goal` 目标指令会让 dsh-workplan 自动分解永远不触发」的真实缺陷:goal 第一轮现在作为合法任务入口参与自动分解;已有进行中计划时 goal 轮次绝不抢跑。**
package/README.en.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **Two selling points, one line: a full ISO/IEC 15408:2026 evidence pack you can verify with 5 commands, and a one-command install with zero runtime dependencies.**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-1.13.0-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v1.13.0)
6
+ [![version](https://img.shields.io/badge/version-2.1.0-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.0)
7
7
 
8
8
  Adds "plan first → dispatch real department subagents → watch progress in the sidebar" to **DeepSeek Harness (DSH)**. No app, no DSH source patch, no page replacement.
9
9
 
@@ -80,7 +80,7 @@ The full contract — roles, data shapes, state machine, recovery, and the three
80
80
  ## Install
81
81
 
82
82
  ```bash
83
- dsh plugin --profile web add dsh-workplan@2.0.3
83
+ dsh plugin --profile web add dsh-workplan@2.1.0
84
84
  ```
85
85
 
86
86
  Restart the DSH Web process (or reload the page) so the bundle is picked up.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-2.0.3-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.0.3)
6
+ [![version](https://img.shields.io/badge/version-2.1.0-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.0)
7
7
 
8
8
  给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
9
9
 
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
69
69
  ## 一键安装
70
70
 
71
71
  ```bash
72
- dsh plugin --profile web add dsh-workplan@2.0.3
72
+ dsh plugin --profile web add dsh-workplan@2.1.0
73
73
  ```
74
74
 
75
75
  装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
package/README.zh.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-1.12.3-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v1.12.3)
6
+ [![version](https://img.shields.io/badge/version-2.1.0-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.0)
7
7
 
8
8
  给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
9
9
 
@@ -0,0 +1,47 @@
1
+ # Release record — dsh-workplan 2.0.3 (2026-11-05)
2
+
3
+ ## 1. 变更主题
4
+
5
+ 修复官方 DeepSeek Harness「`/goal` 目标指令」导致自动任务分解永不触发的缺陷。
6
+
7
+ 根因证据链:
8
+
9
+ 1. `/goal <objective>` 只写 goal 领域状态,不产生 `user/message`(`@deepseek-ai/dsh-command-goal` create 分支)。
10
+ 2. goal 自动续跑轮次由 `@deepseek-ai/dsh-goal-round-driver` 以 `source.kind = 'goal'`、`round >= 1` 的 user 消息送达(`renderGoalRoundPrompt` + `createUserMessage`)。
11
+ 3. 2.0.2 的 `src/runtime.ts#humanMessages` 只接受 `source.kind === 'user'` 或省略的消息。
12
+ 4. `src/runtime.ts#maybePlan` 在 `human.length === 0` 时直接返回。
13
+
14
+ 修复:`goalRoundPlanningTask()` 接受 goal 第一轮;进行中计划存在时不抢跑;任务文本优先取 `goals` 服务 objective,其次解析 `<goal_round>` 信封,最后用原文。
15
+
16
+ ## 2. 版本与提交
17
+
18
+ | 项目 | 值 |
19
+ |---|---|
20
+ | package.json version | 2.0.3 |
21
+ | meta.version(src/host.ts) | 2.0.3 |
22
+ | git commit | 7e25f07 |
23
+ | git tag | v2.0.3 |
24
+
25
+ ## 3. 验证
26
+
27
+ - `npm run check`:退出码 0(tsc --noEmit)。
28
+ - `npm test`:553 条用例全过(含新增 `tests/goal-round-planning.test.ts` 7 条)。
29
+ - `npm run build`:`lib/`、`dist/`、`client.js` 与 `src/` 同步;`lib/host.js` 内 version 为 2.0.3。
30
+
31
+ ## 4. 发布渠道
32
+
33
+ | 渠道 | 状态 | 证据 |
34
+ |---|---|---|
35
+ | npm | 已发布 | `npm view dsh-workplan@latest version` → 2.0.3 |
36
+ | GitHub Release | 已发布 | https://github.com/abbaababa/dsh-workplan/releases/tag/v2.0.3 |
37
+ | Release 制品 | 已上传 | `dsh-workplan-2.0.3.tgz` sha256 `e6bdb13f31fde51f7a370abea5f1f734f32d35fd4b8ed7431aae21468dda50df`(本地与下载一致) |
38
+ | 索引源(awesome-dsh-plugin → dsh-plugin-catalog) | PR 待合并 | https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/12316(tarball 已指向 v2.0.3;catalog npm 发版由上游 CI 触发) |
39
+
40
+ ## 5. 复验命令
41
+
42
+ ```bash
43
+ npm view dsh-workplan@latest version
44
+ curl -sIL -o /dev/null -w '%{http_code}\n' \
45
+ https://github.com/abbaababa/dsh-workplan/releases/download/v2.0.3/dsh-workplan-2.0.3.tgz
46
+ curl -s https://raw.githubusercontent.com/awesome-dsh-plugin/awesome-dsh-plugin/main/data/plugins/abbaababa__dsh-workplan.yml | grep tarball
47
+ ```
@@ -0,0 +1,184 @@
1
+ /**
2
+ * [2.1.0] 统一沟通交流格式规范与合规检查(用户 2026-11-06 的强制要求)。
3
+ *
4
+ * 机制闭环:
5
+ * 1. 主 Agent 派发子任务时,在提示词里附带本模块渲染的《沟通交流格式规范》
6
+ * (renderCommFormatSpec),作为双方认可的唯一结果格式契约;
7
+ * 2. 部门人员提交结果前,必须逐条对照规范自查(提示词中有强制自查指令);
8
+ * 3. 主 Agent 收到结果后,由 adjudicateResult 用 checkCommFormatCompliance
9
+ * 按同一份规范逐条核验;不合规即判定 blocked/comm-format,把
10
+ * renderCommFormatRejection 生成的退回通知随下一次激活发回,
11
+ * 通知部门人员重新检查格式后重交。
12
+ *
13
+ * 设计约束:
14
+ * - 本模块只做「格式/结构」核验,不做语义真伪判断(F9 为提示词级诚信约束,
15
+ * 由三阶段门禁与人工复核兜底,这里不自动判);
16
+ * - 规范是纯数据,可序列化进提示词,也可独立校验,版本号随内容变更递增;
17
+ * - 与既有门禁正交:解析失败、验收缺口、三阶段缺失仍由原门禁先拦,
18
+ * 本门禁只负责把「其它门禁都过了、但格式仍不合规」的 done 退回。
19
+ */
20
+ /** 格式规范版本,随规范内容变更递增。 */
21
+ export const COMM_FORMAT_VERSION = 1;
22
+ /**
23
+ * 统一沟通交流格式规范定义(F1-F9,冻结不可变)。
24
+ */
25
+ export const COMM_FORMAT_SPEC = Object.freeze({
26
+ version: COMM_FORMAT_VERSION,
27
+ name: 'dsh-workplan 沟通交流格式规范',
28
+ requirements: Object.freeze([
29
+ Object.freeze({ id: 'F1', category: 'structure',
30
+ description: '结果必须包含结构化证据块:以 <!-- WORKPLAN_EVIDENCE:START --> 开头、<!-- WORKPLAN_EVIDENCE:END --> 结尾,且两块标记成对出现',
31
+ rationale: '没有标记块,主 Agent 无法定位与解析结果,交付门禁无从启动' }),
32
+ Object.freeze({ id: 'F2', category: 'structure',
33
+ description: '证据块必须是合法 JSON 对象,顶层必须含 status 字段,取值只能是 done / blocked / partial',
34
+ rationale: 'status 是交付门禁的入口条件,缺失或非法则无法判定完成与否' }),
35
+ Object.freeze({ id: 'F3', category: 'phases',
36
+ description: '必须包含三阶段证据:phases.planning(问题分析与可执行思路)、phases.execution(实际执行步骤)、phases.verification(逐项验证)',
37
+ rationale: '三阶段是质量闭环的基础,缺任一阶段等于跳过对应质控环节' }),
38
+ Object.freeze({ id: 'F4', category: 'acceptance',
39
+ description: '验收结果必须逐条回应计划的验收标准(A1、A2…),且每条 result=pass 必须附带具体证据(命令输出/文件路径/引用),禁止空证据 pass',
40
+ rationale: '空证据 pass 是自述而非验证,交付门禁只认可证据' }),
41
+ Object.freeze({ id: 'F5', category: 'acceptance',
42
+ description: '验收回应的条数不得少于计划定义的验收标准条数',
43
+ rationale: '少回应一条等于该条验收未做,交付门禁会判为未完成' }),
44
+ Object.freeze({ id: 'F6', category: 'artifacts',
45
+ description: 'artifacts 声明清单中每一项都必须是合法条目:kind 只能取 file / url / note,且 ref 非空;不允许空条目或占位条目',
46
+ rationale: '主 Agent 按 ref 核验交付物;非法条目让核验无从执行。是否必须交付文件由计划验收标准决定,不由本条决定' }),
47
+ Object.freeze({ id: 'F7', category: 'retrospective',
48
+ description: 'phases.verification.retrospective 复盘必须完整:problems、resolutions、prevention 均至少 1 条(detours 没有可写空数组)',
49
+ rationale: '复盘是自我学习闭环的入口,缺失则教训无法写入永久记忆' }),
50
+ Object.freeze({ id: 'F8', category: 'blocked',
51
+ description: '若 status 为 blocked,必须附非空 question 字段写清受阻原因(卡在哪一步、已尝试什么、需要谁决定什么)',
52
+ rationale: '受阻无原因等于主 Agent 不知道卡在哪里,无法给出指示或转派' }),
53
+ Object.freeze({ id: 'F9', category: 'integrity',
54
+ description: '不得编造、虚构或伪造任何证据、文件路径、命令输出或验收结果;无法确认的项目必须写 unverified',
55
+ rationale: '虚假证据一旦通过交付门禁,用户拿到的就是不可信的成品' }),
56
+ ]),
57
+ });
58
+ /**
59
+ * 对子 Agent 的证据块执行沟通交流格式合规检查(F1-F8 自动核验;F9 为诚信约束不自动判)。
60
+ *
61
+ * @param parsed - 已解析的证据块 payload(parseEvidenceBlock 的 payload,可为 null)
62
+ * @param rawOutput - 子 Agent 原始输出全文
63
+ * @param expectedAcceptanceCount - 计划定义的验收标准条数
64
+ */
65
+ export function checkCommFormatCompliance(parsed, rawOutput, expectedAcceptanceCount) {
66
+ const violations = [];
67
+ const text = typeof rawOutput === 'string' ? rawOutput : '';
68
+ // F1: 证据块标记必须成对出现(rescueEvidence 捞到的豁免——主 Agent 已能解析)
69
+ if (!text.includes('WORKPLAN_EVIDENCE:START') || !text.includes('WORKPLAN_EVIDENCE:END')) {
70
+ if (!parsed) {
71
+ violations.push({ ruleId: 'F1', category: 'structure',
72
+ message: '缺少 WORKPLAN_EVIDENCE:START/END 标记块,主 Agent 无法定位与解析结果' });
73
+ }
74
+ }
75
+ if (!parsed || typeof parsed !== 'object') {
76
+ if (violations.length === 0) {
77
+ violations.push({ ruleId: 'F2', category: 'structure', message: '证据块无法解析为 JSON 对象' });
78
+ }
79
+ return { compliant: false, violations, version: COMM_FORMAT_VERSION };
80
+ }
81
+ // F2: status 必填且取值合法
82
+ if (!['done', 'blocked', 'partial'].includes(String(parsed.status ?? ''))) {
83
+ violations.push({ ruleId: 'F2', category: 'structure',
84
+ message: `status 字段缺失或取值非法("${String(parsed.status ?? '')}"),只能是 done / blocked / partial` });
85
+ }
86
+ // F3: 三阶段证据齐全
87
+ const phases = parsed.phases;
88
+ if (!phases || typeof phases !== 'object') {
89
+ violations.push({ ruleId: 'F3', category: 'phases',
90
+ message: '缺少 phases 对象:planning / execution / verification 三阶段证据全部缺失' });
91
+ }
92
+ else {
93
+ const missing = [];
94
+ if (!phases.planning || typeof phases.planning !== 'object')
95
+ missing.push('planning(问题分析与思路)');
96
+ if (!phases.execution || typeof phases.execution !== 'object')
97
+ missing.push('execution(实际执行步骤)');
98
+ if (!phases.verification || typeof phases.verification !== 'object')
99
+ missing.push('verification(逐项验证与复盘)');
100
+ if (missing.length > 0) {
101
+ violations.push({ ruleId: 'F3', category: 'phases', message: `三阶段证据缺失:${missing.join('、')}` });
102
+ }
103
+ }
104
+ // F4: pass 必须带证据
105
+ const acceptance = Array.isArray(parsed.acceptance) ? parsed.acceptance : [];
106
+ const emptyPass = [];
107
+ for (const item of acceptance) {
108
+ if (item && item.result === 'pass' && !String(item.evidence ?? '').trim()) {
109
+ emptyPass.push(String(item.criterion ?? '(未命名验收项)'));
110
+ }
111
+ }
112
+ if (emptyPass.length > 0) {
113
+ violations.push({ ruleId: 'F4', category: 'acceptance',
114
+ message: `以下验收项 result=pass 但未附证据:${emptyPass.slice(0, 5).join('、')};pass 必须附命令输出/文件路径/引用` });
115
+ }
116
+ // F5: 验收条数不得少于计划定义
117
+ if (expectedAcceptanceCount > 0 && acceptance.length < expectedAcceptanceCount) {
118
+ violations.push({ ruleId: 'F5', category: 'acceptance',
119
+ message: `验收回应仅 ${acceptance.length} 条,少于计划定义的 ${expectedAcceptanceCount} 条;须逐条回应 A1、A2…` });
120
+ }
121
+ // F6: 产物声明必须逐条合法(kind 枚举 + ref 非空);是否必须交付文件由计划验收决定,不在此拦
122
+ const artifacts = Array.isArray(parsed.artifacts) ? parsed.artifacts : [];
123
+ const badArtifacts = artifacts.filter((item) => !item || typeof item !== 'object'
124
+ || !['file', 'url', 'note'].includes(String(item.kind ?? ''))
125
+ || String(item.ref ?? '').trim() === '');
126
+ if (badArtifacts.length > 0) {
127
+ violations.push({ ruleId: 'F6', category: 'artifacts',
128
+ message: `artifacts 有 ${badArtifacts.length} 条非法声明:每条必须 kind 取 file/url/note 且 ref 非空,不允许空条目` });
129
+ }
130
+ // F7: 复盘完整(problems/resolutions/prevention 均至少 1 条)
131
+ const retro = phases?.verification?.retrospective;
132
+ if (!retro || typeof retro !== 'object') {
133
+ violations.push({ ruleId: 'F7', category: 'retrospective',
134
+ message: '缺少 phases.verification.retrospective 复盘(problems / detours / resolutions / prevention)' });
135
+ }
136
+ else {
137
+ const missingRetro = [];
138
+ if (!Array.isArray(retro.problems) || retro.problems.length === 0)
139
+ missingRetro.push('problems(遇到的问题,现象+根因)');
140
+ if (!Array.isArray(retro.resolutions) || retro.resolutions.length === 0)
141
+ missingRetro.push('resolutions(最终如何解决)');
142
+ if (!Array.isArray(retro.prevention) || retro.prevention.length === 0)
143
+ missingRetro.push('prevention(防再犯规则)');
144
+ if (missingRetro.length > 0) {
145
+ violations.push({ ruleId: 'F7', category: 'retrospective',
146
+ message: `复盘不完整,缺少:${missingRetro.join('、')},均至少 1 条` });
147
+ }
148
+ }
149
+ // F8: blocked 必须附非空 question
150
+ if (parsed.status === 'blocked' && !String(parsed.question ?? '').trim()) {
151
+ violations.push({ ruleId: 'F8', category: 'blocked',
152
+ message: 'status 为 blocked 但 question 为空:须写清卡在哪一步、已尝试什么、需要谁做什么决定' });
153
+ }
154
+ return { compliant: violations.length === 0, violations, version: COMM_FORMAT_VERSION };
155
+ }
156
+ /**
157
+ * 把格式规范渲染为嵌入子 Agent 提示词的文本。
158
+ * 这是「派发工作时附带统一沟通交流格式要求」的具体实现。
159
+ */
160
+ export function renderCommFormatSpec() {
161
+ const lines = [
162
+ '沟通交流格式规范(v' + String(COMM_FORMAT_VERSION) + ',主 Agent 与部门人员双方认可的结果格式契约):',
163
+ ];
164
+ for (const req of COMM_FORMAT_SPEC.requirements) {
165
+ lines.push(`- 【${req.id}】${req.description}`);
166
+ }
167
+ lines.push('不合规的后果:主 Agent 收到结果后按本规范逐条核验;任一不合规,结果立刻退回,你将收到列明不合规条目的退回通知,须全部修正后重新提交完整结果。');
168
+ return lines.join('\n');
169
+ }
170
+ /**
171
+ * 把合规检查结果渲染为退回通知文本(随下一次激活发回部门人员)。
172
+ */
173
+ export function renderCommFormatRejection(result) {
174
+ if (result.compliant)
175
+ return '';
176
+ const lines = [
177
+ '结果退回:沟通交流格式不合规(规范 v' + String(result.version) + ')。',
178
+ '你的结果未通过以下条目,请逐条修正、重新自查全部 F1-F9 后再提交完整结果(不要只修一条就重交):',
179
+ ];
180
+ for (const v of result.violations) {
181
+ lines.push(`- ${v.ruleId}:${v.message}`);
182
+ }
183
+ return lines.join('\n');
184
+ }
package/lib/host.js CHANGED
@@ -1363,7 +1363,7 @@ export function apply(ctx, config = {}) {
1363
1363
  }
1364
1364
  export const meta = {
1365
1365
  name,
1366
- version: '2.0.3',
1366
+ version: '2.1.0',
1367
1367
  promptOrder: PROMPT_ORDER,
1368
1368
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1369
1369
  };