dsh-spec-collab 0.3.0 → 0.3.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 ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1 — 2026-10-27
4
+
5
+ - Enforce the same Ready admission rules in frontend guidance and the server: require a completed engineering precheck for the current commit, settled reviews and patches, passing readiness checks, and current version confirmations from both roles.
6
+ - Preserve the review session association when a delayed launch resolves after a rejected action restores the collaboration state.
7
+ - Add regression coverage for missing, queued, running, failed and stale prechecks, expired confirmations, pending patches, delayed launches and HTTP admission.
8
+ - Declare the supported host tools package as a runtime peer dependency so a clean installation can load the Host entry point.
9
+ - Keep raw acceptance evidence in Git while excluding it from the npm package; retain product documentation and walkthrough images.
10
+
11
+ Compatibility remains DeepSeek Harness 0.1.1-rc.1. This release does not add support for the newer host API.
package/README.md CHANGED
@@ -7,14 +7,14 @@ DeepSeek Harness 的需求“编辑校样台”,用于把原始需求澄清为
7
7
 
8
8
  产品边界严格止于 Ready Spec,不包含代码实现、测试用例生成、worktree、MR、部署、发布或交付状态管理。
9
9
 
10
- 兼容 DeepSeek Harness `v0.1.1-rc.1`。插件可在局域网 HTTP 地址下运行,不依赖浏览器提供 `crypto.randomUUID`;DSH 精简侧栏仅显示“设置”时,也会正常挂载“需求讨论”入口。
10
+ 当前版本为 `v0.3.1`,兼容 DeepSeek Harness `v0.1.1-rc.1`。插件可在局域网 HTTP 地址下运行,不依赖浏览器提供 `crypto.randomUUID`;DSH 精简侧栏仅显示“设置”时,也会正常挂载“需求讨论”入口。
11
11
 
12
12
  ## 一键安装
13
13
 
14
14
  已有 Node.js 环境时,无需先全局安装 DSH CLI:
15
15
 
16
16
  ```sh
17
- npx -y @deepseek-ai/dsh plugin --profile web add dsh-spec-collab@latest
17
+ npx -y @deepseek-ai/dsh@0.1.1-rc.1 plugin --profile web add dsh-spec-collab@latest
18
18
  ```
19
19
 
20
20
  如果 `dsh` 已在 `PATH` 中,也可以使用简写:
@@ -45,13 +45,33 @@ dsh plugin --profile web update dsh-spec-collab@latest
45
45
  -> 输出 Ready Spec
46
46
  ```
47
47
 
48
- ## 完整演示
48
+ 每个需求固定绑定一个 DSH 工作区和一条 Git 版本链。AI 的审核、评论分析和候选 Patch 都基于明确 commit;产品与研发的确认也绑定 commit。正文变化后,受影响的确认和候选 Patch 会失效,避免拿旧结论证明新版本已经就绪。
49
+
50
+ ## 工作台结构
51
+
52
+ 当前工作台以需求正文为主画布,不再把流程拆成多个相互割裂的页面:
49
53
 
50
- 点击下方截图观看从选择工作区到生成 Ready Spec 的完整 MP4 录屏:
54
+ - 顶部显示需求标题、绑定工作区、当前 commit 和“澄清 / 产品确认 / 产研确认 / 已就绪”四阶段进度。
55
+ - 左侧需求栏提供搜索、阶段/参与者/风险筛选、新建、归档、恢复和删除;收起后正文获得更大空间。
56
+ - 中间正文支持 Markdown 编辑、显式保存、整篇评论、行内批注、原文定位和评论定位;正文上方汇总待回答问题、打开讨论、AI 建议和生效 Decision。
57
+ - 右侧协作栏分为“下一步 / 讨论 / 洞察 / 记录”。“下一步”按当前参与者聚合待办,“记录”集中展示 Decision 与版本历史。
58
+ - “我的工作”和通知跨需求汇总与本人相关的回复、确认、提及、指派及状态变化;服务端通过 SSE 推送变化,多浏览器刷新后仍可继续。
59
+ - 桌面宽屏使用正文与协作栏并排布局;窄屏切换为“需求列表 / 需求正文 / 协作”,并保留键盘导航和正文专注模式。
51
60
 
52
- [![Ready 质量门与最终 Ready Spec](docs/assets/demo-05-ready.png)](docs/assets/spec-collab-walkthrough.mp4)
61
+ ## 角色与责任
62
+
63
+ | 参与者 | 可以做什么 | 不能代替谁 |
64
+ | --- | --- | --- |
65
+ | 产品 | 创建需求、补充来源、回复问题、编辑正文、接受 Patch、记录 Decision、确认产品语义 | 不能代替研发确认技术理解 |
66
+ | 研发 | 评论实现影响、补充技术证据、参与 Decision、确认研发理解 | 不能代替产品决定业务语义 |
67
+ | 产品 AI / 研发 AI | 读取绑定工作区及授权资料、提交结构化问题、分析评论、提出候选 Patch | 不能直接写 Git、确认 commit 或标记 Ready |
68
+ | 匿名访问者 | 查看需求和协作记录 | 首次评论、修改、回复或确认前必须登记花名与责任角色 |
69
+
70
+ ## 完整演示
53
71
 
54
- **[播放 MP4 录屏](docs/assets/spec-collab-walkthrough.mp4)** · **[阅读完整图文教程](docs/usage-walkthrough.md)**
72
+ 下面的图片来自一条全新需求从创建到 Ready Spec 的真实流程,均使用 ego-browser 截取,并在截图前收起 DSH 主侧边栏。
73
+
74
+ **[阅读完整图文教程](docs/usage-walkthrough.md)**
55
75
 
56
76
  <details>
57
77
  <summary>查看完整流程截图</summary>
@@ -60,39 +80,64 @@ dsh plugin --profile web update dsh-spec-collab@latest
60
80
 
61
81
  ![新建需求并选择工作区](docs/assets/demo-01-workspace.png)
62
82
 
63
- ### 2. AI 审核问题和人工回复
83
+ ### 2. AI 问题清单与人工回复
64
84
 
65
85
  ![AI 审核问题和人工回复](docs/assets/demo-02-ai-review.png)
66
86
 
67
- ### 3. 审核并接受候选 Patch
87
+ ### 3. 审核候选 Patch
68
88
 
69
89
  ![审核并接受候选 Patch](docs/assets/demo-03-patches.png)
70
90
 
71
- ### 4. 记录人工 Decision
91
+ ### 4. 查看生效 Decision
92
+
93
+ ![已生效的产品 Decision](docs/assets/demo-04-decisions.png)
94
+
95
+ ### 5. 查看并导出 Ready Spec
72
96
 
73
- ![人工确认的产品 Decision](docs/assets/demo-04-decisions.png)
97
+ ![Ready 质量门与最终 Ready Spec](docs/assets/demo-05-ready.png)
74
98
 
75
99
  </details>
76
100
 
77
- ## 能力
101
+ ## 当前能力(v0.3.1)
102
+
103
+ ### 需求正文与版本
78
104
 
79
105
  - 匿名只读;首次评论、修改、回复、确认前登记 `participant_id + 花名 + 责任角色`。
80
106
  - 原始需求、Markdown PRD、相关链接与代码范围分别记录为来源,不静默混成事实。
81
107
  - 正式正文只存在 `requirements/<id>/spec.md`,每次显式保存生成一个 Git commit。
82
108
  - 保存携带 `baseCommit`;过期或存在外部未提交修改时拒绝覆盖。
109
+ - 本地草稿存入 IndexedDB,异常关闭后可恢复;正式保存仍由 Git commit 承载。
110
+ - 版本历史与 AI Patch 共用结构化行级 diff,未变上下文可折叠;恢复历史会创建新 commit。
111
+ - 需求支持搜索、筛选、归档、恢复和删除;删除同时移除对应正式 Spec 与关联洞察关系。
112
+
113
+ ### AI 审核与候选修改
114
+
83
115
  - `FACT / INFERENCE / ASSUMPTION / TO_VERIFY` 结构化 Review Item;`FACT` 强制可访问且带版本的证据。
84
116
  - 同一需求在同一流程阶段复用一个 DSH AI session;审核、评论分析和追问只追加增量提示,进入下一阶段后再创建新会话。
85
117
  - 每条实质评论提交后自动进入当前阶段 AI 会话,回复必须包含理解、证据或 `TO_VERIFY`、影响章节/AC 和建议处置。
86
118
  - AI 只能提交 Review Item、评论分析和候选 patch;不能写 Git、代替人确认或标记 Ready。
87
119
  - 保存和 patch 接受后自动触发 change review;候选 patch 基于精确 commit,过期自动失效。
120
+
121
+ ### 协作、Decision 与洞察
122
+
88
123
  - Decision、Comment、Confirmation 分离;确认绑定 commit,可按 section/AC 局部失效。
124
+ - 评论支持页面级和行内批注、回复、提及、指派、筛选、解决、重开和深链;正文定位与评论定位使用同一套交互。
125
+ - “我的工作”按待回复、待确认、由我发起等类别跨需求聚合;通知覆盖提及、回复和状态变化。
126
+ - 客户、公司、来源和洞察为独立实体;洞察可关联多个需求、章节或 AC,支持 CSV/Markdown 原子导入和去重。
127
+ - v3 协作账本持久化协作、通知、洞察、统一指标和 AI 阶段会话,并通过 SSE 刷新客户端状态。
128
+
129
+ ### Ready 质量门与交付
130
+
89
131
  - Ready 门检查目标与用户结果、稳定 AC、范围与非范围、业务语义、证据来源、测试约束。
132
+ - 生成 Ready 必须处于产研共审、已绑定工作区,当前 commit 至少有一次已完成的 `engineering-precheck`,且没有当前版本正在排队/运行的审核或待处理候选 Patch。缺失、失败、运行中或旧 commit 的研发预审都不能替代当前版本已完成的预审。
133
+ - 产品与研发必须分别对同一个当前 commit 做有效的整版确认;章节、AC 或 Decision 确认不能替代。正文改版后重新完成当前版本研发预审和双方整版确认。产品二审仍是进入产品确认阶段的准入条件。
134
+ - 前端引导和服务端生成共用 `src/ready-admission.ts`。服务端从 Git 正文重新计算六项内容检查,不信任客户端传入的检查结果。审核完成表示结构化结果已被接受,六项通过主要证明结构与记录满足校验;AI 实际读取、来源原文是否支持陈述及业务语义质量需要工具轨迹与人工复核。
90
135
  - Ready 输出包含 commit SHA、稳定 AC、Decision、来源、非阻塞 Open Questions 和产品/研发确认人。
136
+ - Ready Spec 可直接复制 Markdown、下载 `.md`、复制 commit 或复制分享链接。
91
137
  - Agent 工具:`spec_list`、`spec_read`、`spec_reply`、`spec_submit_review`、`spec_propose_patch`。
92
- - v3 协作账本、插件内通知和 SSE,多浏览器刷新后仍可继续;评论支持页面级/行内、提及、指派、筛选、重开和深链。
93
- - 客户、公司、来源和洞察为独立实体;洞察可关联多个需求、章节或 AC,支持 CSV/Markdown 原子导入和去重。
94
- - 本地草稿存入 IndexedDB,异常关闭后可恢复;正式保存仍由 Git commit 承载。
95
- - 版本历史与 AI patch 共用结构化行级 diff,未变上下文可折叠;恢复历史会创建新 commit。
138
+
139
+ ### 工作区上下文
140
+
96
141
  - 新建需求必须选择一个 DSH 工作区;所有 AI 审核和评论分析 session 固定挂载该工作区,不会落入未分组 session。
97
142
  - 支持默认 AI 上下文与工作区专属上下文合并,统一声明 Skill、MCP server、本地参考文档和 Agent Preset。
98
143
 
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,71 +1,53 @@
1
- # 完整使用演示:从原始需求到 Ready Spec
1
+ # 完整使用演示:从新需求到 Ready Spec
2
2
 
3
- 本演示使用需求“登录页密码显示开关”走完产品初审、产品复审、候选 Patch、人工决策、产品确认、研发预审、研发确认和 Ready 质量门。演示中的所有 AI 操作都绑定到所选 DSH 工作区,人工确认绑定到精确 Git commit。
4
-
5
- [观看完整流程录屏(MP4)](assets/spec-collab-walkthrough.mp4)
3
+ 本页记录 2026-08-27 在真实 DSH 工作台中完成的一次全新流程。演示需求为“演示:需求列表快速复制分享链接”,从新建开始,依次经过产品 AI 初审、人工澄清、候选 Patch、产品确认、Decision、研发检查和 Ready 质量门。所有截图均使用 ego-browser 重新截取,截图前已收起 DSH 主侧边栏。
6
4
 
7
5
  ## 演示需求
8
6
 
9
- > 用户在登录页输入较长密码时,无法确认是否输错。希望在密码输入框右侧增加“显示/隐藏密码”图标:默认隐藏;点击后显示明文,再次点击恢复隐藏;切换时不得清空密码或让输入框失去焦点;键盘用户可操作并获得可读标签。仅改登录页,注册、找回密码和修改密码页不在本次范围。桌面端和移动端都需要支持。
7
+ 目标是在桌面端与窄屏需求列表中增加“复制分享链接”:接收者打开链接后直接看到目标需求;复制失败、需求不存在和访问被拒绝时给出明确反馈。需求同时约束地址结构、隐私字段、归档需求、键盘操作与读屏播报,不扩展现有访问权限,也不涉及短链、二维码或批量复制。
10
8
 
11
- ## 1. 新建需求并选择工作区
9
+ ## 1. 从空白表单新建需求
12
10
 
13
- 点击需求栏右上角的 `+`,填写需求标题、原始需求和来源。项目工作区是必填项;插件不会允许需求进入“未分组”工作区,因为后续 AI 初审、复审和评论分析都需要从这里继承项目的 Skill、MCP、本地参考文档及 Agent Preset。
11
+ 在需求栏中新建需求,填写标题、原始需求和来源,并选择真实项目工作区 `dsh-spec-collab`。工作区是后续 AI 审核读取代码、测试、Git 历史和项目说明的上下文边界;创建后,原始输入形成首个 Git commit。
14
12
 
15
13
  ![新建需求并选择工作区](assets/demo-01-workspace.png)
16
14
 
17
- 创建后,原始输入会立即固定为第一个 Git commit。需求一旦绑定工作区便不能中途切换,避免同一份 Spec 的审核上下文发生漂移。
18
-
19
- ## 2. 运行智能初审并逐项回复
15
+ ## 2. AI 初审,产品逐项澄清
20
16
 
21
- 点击“智能初审”。AI 会按目标、范围、业务语义、验收标准、风险、当前实现、历史冲突和证据等维度生成结构化 Review Item。每条结论都会标注 `FACT`、`INFERENCE`、`ASSUMPTION` 或 `TO_VERIFY`。
17
+ 运行智能初审后,AI 将模糊点拆成可回答的问题。本次实际澄清了四类关键边界:将原始描述重组为完整正式 Spec;分享地址只携带稳定需求 ID;链接默认打开需求正文,不保存页签、滚动位置或侧栏状态;只调整需求列表入口,其他复制链接入口不在范围内。
22
18
 
23
19
  ![AI 审核问题和人工回复](assets/demo-02-ai-review.png)
24
20
 
25
- 处理审核项时遵循以下规则:
26
-
27
- - 有业务结论时选择推荐方案或自行输入,并说明取舍。
28
- - 有固定版本证据时补充来源、版本和证据说明。
29
- - 当前无法核验源码、历史或浏览器矩阵时选择 `TO_VERIFY`,不要把推测写成 `FACT`。
30
- - `接受 AI 建议` 用于无需修改正文即可确认的结论;`修改后接受` 表示仍需等待候选 Patch。
21
+ 回答时应区分事实、推断、假设和待核验内容。当前无法从工作区证明的实现细节保留为 `TO_VERIFY`,不把推测包装为已经确认的事实。
31
22
 
32
- ## 3. 智能复审并接受候选 Patch
23
+ ## 3. 审核并接受候选 Patch
33
24
 
34
- 产品回复完成后运行“智能复审”。AI 会检查回复是否真正覆盖原问题,并生成基于精确 `baseCommit` 的候选 Patch。打开“修改建议”,预览完整候选规范,确认变更范围和 AC 后由人工点击接受。
25
+ AI 根据产品回答生成候选 Patch,人工在写入前检查完整正文、受影响章节和验收标准。本次候选内容补齐了目标与非范围、地址片段规则、剪贴板失败兜底、无效或无权链接语义、七条场景化 AC 及测试约束。
35
26
 
36
27
  ![审核并接受候选 Patch](assets/demo-03-patches.png)
37
28
 
38
- AI 只能提议 Patch,不能直接写 Git。人工接受后插件创建新 commit,并自动触发 change review;基于旧 commit 的候选 Patch 会失效。
39
-
40
- ## 4. 记录 Decision 并确认产品版本
41
-
42
- 对状态生命周期、范围边界或新增 AC 等关键选择,在“确认决策”中记录 Decision。Decision 与普通评论分离,包含结论、理由、确认人及受影响章节或 AC。
29
+ 候选 Patch 绑定精确 `baseCommit`。只有人工接受后才会生成新的 Git commit;正文再次变化时,旧 Patch 与受影响确认会自动失效。
43
30
 
44
- ![人工确认的产品 Decision](assets/demo-04-decisions.png)
31
+ ## 4. 产品确认并记录 Decision
45
32
 
46
- 产品二审无当前版本阻塞项后进入“产品确认”,由产品确认当前 commit。任何后续正文修改都会使受影响的确认失效,必须重新确认。
33
+ 产品检查当前版本后确认 commit,并把关键取舍记录为独立 Decision。本次生效决策为:使用需求级地址片段,只包含编码后的稳定需求 ID,默认打开需求正文;不保存页签、滚动位置或侧栏状态。理由是该方案与工作台已有深链模型一致,同时避免把协作内容或本地路径写入链接。
47
34
 
48
- ## 5. 研发预审、双角色确认和 Ready
35
+ ![已生效的产品 Decision](assets/demo-04-decisions.png)
49
36
 
50
- 进入“产研共审”后运行“研发智能预审”。工程侧重点核验当前实现、共享组件影响、测试落点、浏览器矩阵及历史约束。演示工作区没有目标业务仓库源码,因此相关项被明确保留为非阻塞 `TO_VERIFY`,而不是虚构实现证据。
37
+ Decision 与普通评论分离,保留结论、理由、确认人和生效状态,供后续研发检查与 Ready 输出追溯。
51
38
 
52
- 研发确认与产品确认必须绑定同一个当前 commit。随后点击“生成就绪规范”,只有以下六项全部通过才能生成 Ready Spec:
39
+ ## 5. 研发检查与 Ready 质量门
53
40
 
54
- - 目标与用户结果
55
- - 验收标准
56
- - 范围与非范围
57
- - 业务语义
58
- - 证据来源
59
- - 测试约束
41
+ 进入产研确认后运行研发检查,重点核对现有实现、影响范围、兼容性和测试落点。产品与研发必须确认同一个当前 commit;之后才能检查六项 Ready 门:目标与用户结果、稳定验收标准、范围与非范围、业务语义、证据来源和测试约束。
60
42
 
61
- ![Ready 质量门和最终 Ready Spec](assets/demo-05-ready.png)
43
+ ![Ready 质量门与最终 Ready Spec](assets/demo-05-ready.png)
62
44
 
63
- 本次演示最终生成的 Ready Spec 绑定 commit `ac8182473bf5ce971cec92db9391b3f702867fe8`,产品和研发均确认该版本。历史 Review Item 保留在审核记录中用于审计,但不会继续阻塞新 commit;当前未核验的实现和兼容性问题则进入 Ready Spec 的“非阻塞 Open Questions”。
45
+ 本次 Ready Spec 绑定 commit `233338d6e1a4b1cec758d5348abdff04f76a5a88`,产品确认人为“验收人员”,研发确认为“演示研发”。Ready 输出保留稳定 AC、生效 Decision、来源、非阻塞 Open Questions 以及双方确认人。它是交给研发和开发 AI 的需求合同,不代表代码已经实现、测试已经执行或版本已经发布。
64
46
 
65
- ## 正确使用要点
47
+ ## 使用原则
66
48
 
67
- 1. 新建需求时选择真实项目工作区,先配置好该工作区需要的 Skill、MCP 和参考文档路径。
68
- 2. 把 AI 当作审核者和提议者,不让 AI 代替产品或研发确认。
69
- 3. 每个事实都提供可访问、版本固定的证据;缺证据时使用 `TO_VERIFY`。
70
- 4. 接受 Patch 前检查 `baseCommit`、受影响章节和 AC;正文变化后重新完成必要审核与确认。
71
- 5. 产品和研发必须确认同一个当前 commit,六项质量门通过后再生成 Ready Spec。
49
+ 1. 每条需求从新建开始绑定真实项目工作区,不在不同项目上下文之间复用审核结论。
50
+ 2. AI 负责检查、追问和提出 Patch;写入 Git、确认版本和判定 Ready 始终由人完成。
51
+ 3. 事实必须带可访问且版本固定的证据;证据不足时明确保留 `TO_VERIFY`。
52
+ 4. 接受 Patch 前检查 `baseCommit` 和变更范围;正文变化后重新完成受影响的审核与确认。
53
+ 5. 产品与研发确认同一个 commit,六项质量门全部通过后再输出 Ready Spec。
package/lib/client.js CHANGED
@@ -39348,6 +39348,32 @@ window.__ModuleLoader__.load({
39348
39348
  return snippets;
39349
39349
  }
39350
39350
  //#endregion
39351
+ //#region src/ready-admission.ts
39352
+ function hasCompletedCurrentReview(record, kind) {
39353
+ return record.aiRuns.some((run) => run.commit === record.currentCommit && run.kind === kind && run.status === "completed");
39354
+ }
39355
+ function hasVersionConfirmation(record, role) {
39356
+ return record.confirmations.some((item) => item.commit === record.currentCommit && item.role === role && item.scope === "version" && item.status === "active");
39357
+ }
39358
+ /** Shared by workflow guidance and the authoritative Ready write. Checks must come from the current Git body. */
39359
+ function readyAdmission(record, checks) {
39360
+ const activeRun = record.aiRuns.slice().reverse().find((run) => run.commit === record.currentCommit && (run.status === "queued" || run.status === "running"));
39361
+ const engineeringReviewed = hasCompletedCurrentReview(record, "engineering-precheck");
39362
+ const pendingPatches = record.patches.filter((item) => item.baseCommit === record.currentCommit && item.status === "pending");
39363
+ const failedChecks = checks.filter((check) => !check.passed);
39364
+ const productConfirmed = hasVersionConfirmation(record, "product");
39365
+ const engineeringConfirmed = hasVersionConfirmation(record, "engineering");
39366
+ return {
39367
+ activeRun,
39368
+ engineeringReviewed,
39369
+ pendingPatches,
39370
+ failedChecks,
39371
+ productConfirmed,
39372
+ engineeringConfirmed,
39373
+ error: record.stage !== "joint-review" ? "readiness gate is not satisfied" : !record.workspaceId?.trim() ? "review workspace is required" : activeRun ? "current version review is still running" : !engineeringReviewed ? "engineering precheck is required for the current version" : pendingPatches.length > 0 ? "current version has pending patches" : failedChecks.length > 0 ? "readiness gate is not satisfied" : !productConfirmed || !engineeringConfirmed ? "current version needs product and engineering confirmation" : void 0
39374
+ };
39375
+ }
39376
+ //#endregion
39351
39377
  //#region src/client/workflow.ts
39352
39378
  const reviewIsOpen = (status) => ![
39353
39379
  "resolved",
@@ -39358,14 +39384,9 @@ window.__ModuleLoader__.load({
39358
39384
  const blockers = requirement.reviewItems.filter((item) => item.commit === requirement.currentCommit).filter((item) => item.severity === "blocking" && reviewIsOpen(item.status));
39359
39385
  const productBlockers = blockers.filter((item) => item.status !== "joint-review");
39360
39386
  const unanswered = blockers.filter((item) => item.status === "open");
39361
- const currentPatches = requirement.patches.filter((item) => item.baseCommit === requirement.currentCommit && item.status === "pending");
39362
- const currentRuns = requirement.aiRuns.filter((run) => run.commit === requirement.currentCommit);
39363
- const activeRun = currentRuns.slice().reverse().find((run) => ["queued", "running"].includes(run.status));
39364
- const completed = (kind) => currentRuns.some((run) => run.kind === kind && run.status === "completed");
39365
- const productConfirmed = requirement.confirmations.some((item) => item.commit === requirement.currentCommit && item.role === "product" && item.scope === "version" && item.status === "active");
39366
- const engineeringConfirmed = requirement.confirmations.some((item) => item.commit === requirement.currentCommit && item.role === "engineering" && item.scope === "version" && item.status === "active");
39367
- const failedChecks = requirement.readiness.filter((check) => !check.passed);
39368
- if (!requirement.workspaceId) return {
39387
+ const { activeRun, engineeringReviewed, pendingPatches: currentPatches, failedChecks, productConfirmed, engineeringConfirmed } = readyAdmission(requirement, requirement.readiness);
39388
+ const completed = (kind) => hasCompletedCurrentReview(requirement, kind);
39389
+ if (!requirement.workspaceId?.trim()) return {
39369
39390
  eyebrow: "开始前",
39370
39391
  title: "关联需求所在的项目",
39371
39392
  detail: "AI 会从这个项目读取代码、规范和团队知识,关联后不能中途切换。",
@@ -39454,7 +39475,7 @@ window.__ModuleLoader__.load({
39454
39475
  };
39455
39476
  }
39456
39477
  if (requirement.stage === "joint-review") {
39457
- if (!completed("engineering-precheck")) return {
39478
+ if (!engineeringReviewed) return {
39458
39479
  eyebrow: "产研共审",
39459
39480
  title: "从研发视角检查可实施性",
39460
39481
  detail: "重点检查现有实现、影响范围、兼容性和测试落点。",
@@ -39555,6 +39576,9 @@ window.__ModuleLoader__.load({
39555
39576
  }
39556
39577
  function friendlyActionError(error) {
39557
39578
  return [
39579
+ ["engineering precheck is required for the current version", "需要先完成当前版本的研发检查;正文变更后请重新检查。"],
39580
+ ["current version review is still running", "当前版本的 AI 检查仍在进行,请等待完成后再生成就绪需求。"],
39581
+ ["current version has pending patches", "当前版本还有待审核的正文修改,请先接受或拒绝。"],
39558
39582
  ["product blocking review items remain", "还有阻塞问题未处理,请先完成待澄清事项。"],
39559
39583
  ["product second review is required", "需要先让 AI 根据回复整理并复核正文。"],
39560
39584
  ["product must confirm the current version", "需要产品角色确认当前版本后才能进入产研共审。"],
@@ -46523,265 +46547,265 @@ window.__ModuleLoader__.load({
46523
46547
  document.head.appendChild(tag);
46524
46548
  }
46525
46549
  var workbench_module_css_default = {
46526
- "myWorkSummary": "-kTeaG_myWorkSummary",
46527
- "editorPane": "-kTeaG_editorPane",
46528
- "selectedDecisionOption": "-kTeaG_selectedDecisionOption",
46529
- "diffHeader": "-kTeaG_diffHeader",
46530
- "commentBody": "-kTeaG_commentBody",
46531
- "editorTitle": "-kTeaG_editorTitle",
46532
- "documentAnchorHighlightSelected": "-kTeaG_documentAnchorHighlightSelected",
46533
- "selectionPromptCancel": "-kTeaG_selectionPromptCancel",
46534
- "reviewChecklistBlocking": "-kTeaG_reviewChecklistBlocking",
46535
- "chatError": "-kTeaG_chatError",
46536
- "decisionForm": "-kTeaG_decisionForm",
46537
- "compareColumns": "-kTeaG_compareColumns",
46538
- "selectionPromptSubmit": "-kTeaG_selectionPromptSubmit",
46539
- "reviewDecisionBody": "-kTeaG_reviewDecisionBody",
46540
- "importPreview": "-kTeaG_importPreview",
46541
- "runHistory": "-kTeaG_runHistory",
46542
- "reviewChecklistSettled": "-kTeaG_reviewChecklistSettled",
46543
- "stageDone": "-kTeaG_stageDone",
46544
- "insightActions": "-kTeaG_insightActions",
46545
- "reviewHeader": "-kTeaG_reviewHeader",
46546
- "decisionSection": "-kTeaG_decisionSection",
46550
+ "productName": "-kTeaG_productName",
46547
46551
  "view": "-kTeaG_view",
46548
- "chatMessages": "-kTeaG_chatMessages",
46549
- "insightDialog": "-kTeaG_insightDialog",
46550
- "documentReviewAnchor": "-kTeaG_documentReviewAnchor",
46551
- "stageCurrent": "-kTeaG_stageCurrent",
46552
- "empty": "-kTeaG_empty",
46552
+ "conflictModal": "-kTeaG_conflictModal",
46553
+ "readyPackage": "-kTeaG_readyPackage",
46554
+ "insightFilters": "-kTeaG_insightFilters",
46555
+ "modal": "-kTeaG_modal",
46553
46556
  "myWorkList": "-kTeaG_myWorkList",
46557
+ "conflictHeader": "-kTeaG_conflictHeader",
46558
+ "mobileCollab": "-kTeaG_mobileCollab",
46559
+ "documentCommentAnchor": "-kTeaG_documentCommentAnchor",
46554
46560
  "commentThreadSelected": "-kTeaG_commentThreadSelected",
46555
- "decisionResponse": "-kTeaG_decisionResponse",
46556
- "panelAction": "-kTeaG_panelAction",
46557
- "entry": "-kTeaG_entry",
46558
- "selectedDoc": "-kTeaG_selectedDoc",
46559
- "patchImpact": "-kTeaG_patchImpact",
46560
- "discussionPanel": "-kTeaG_discussionPanel",
46561
- "iconButton": "-kTeaG_iconButton",
46562
- "identity": "-kTeaG_identity",
46563
- "diffActions": "-kTeaG_diffActions",
46564
- "richEditor": "-kTeaG_richEditor",
46561
+ "decisionSection": "-kTeaG_decisionSection",
46562
+ "inlineDecisionOptions": "-kTeaG_inlineDecisionOptions",
46563
+ "reviewDecisionContext": "-kTeaG_reviewDecisionContext",
46564
+ "noticeHidden": "-kTeaG_noticeHidden",
46565
+ "header": "-kTeaG_header",
46566
+ "conflictActions": "-kTeaG_conflictActions",
46567
+ "collabMetricActive": "-kTeaG_collabMetricActive",
46568
+ "tabPanel": "-kTeaG_tabPanel",
46569
+ "selectionPromptHead": "-kTeaG_selectionPromptHead",
46570
+ "summaryInput": "-kTeaG_summaryInput",
46565
46571
  "commentThreadClosed": "-kTeaG_commentThreadClosed",
46566
- "decisionOptions": "-kTeaG_decisionOptions",
46567
- "requirementSearch": "-kTeaG_requirementSearch",
46568
- "resizer": "-kTeaG_resizer",
46569
- "diffAdded": "-kTeaG_diffAdded",
46570
- "historyGroup": "-kTeaG_historyGroup",
46571
- "threadPills": "-kTeaG_threadPills",
46572
- "editorCollabBar": "-kTeaG_editorCollabBar",
46573
- "topActions": "-kTeaG_topActions",
46574
- "saveButton": "-kTeaG_saveButton",
46575
- "activeMode": "-kTeaG_activeMode",
46576
- "commentSourceSelected": "-kTeaG_commentSourceSelected",
46577
- "aiConversation": "-kTeaG_aiConversation",
46578
- "mobileDrawerClose": "-kTeaG_mobileDrawerClose",
46579
- "documentAnchorSelected": "-kTeaG_documentAnchorSelected",
46580
- "resizerHidden": "-kTeaG_resizerHidden",
46581
- "footer": "-kTeaG_footer",
46582
- "compareHead": "-kTeaG_compareHead",
46583
- "grid": "-kTeaG_grid",
46584
- "unsaved": "-kTeaG_unsaved",
46585
- "dialogHead": "-kTeaG_dialogHead",
46586
- "quietButton": "-kTeaG_quietButton",
46587
- "workflowEyebrow": "-kTeaG_workflowEyebrow",
46588
- "reviewCheckStatus": "-kTeaG_reviewCheckStatus",
46572
+ "inlineReviewSource": "-kTeaG_inlineReviewSource",
46573
+ "unreadNotification": "-kTeaG_unreadNotification",
46574
+ "selectionPromptAbove": "-kTeaG_selectionPromptAbove",
46575
+ "panelSummary": "-kTeaG_panelSummary",
46576
+ "reviewCheckBox": "-kTeaG_reviewCheckBox",
46577
+ "replyStack": "-kTeaG_replyStack",
46578
+ "documentReviewHighlight": "-kTeaG_documentReviewHighlight",
46579
+ "badges": "-kTeaG_badges",
46580
+ "reviewChecklist": "-kTeaG_reviewChecklist",
46581
+ "commentThreadHead": "-kTeaG_commentThreadHead",
46589
46582
  "decisionSourceList": "-kTeaG_decisionSourceList",
46583
+ "documentAnchorHighlightSelected": "-kTeaG_documentAnchorHighlightSelected",
46584
+ "quietButton": "-kTeaG_quietButton",
46585
+ "locateSourceButton": "-kTeaG_locateSourceButton",
46586
+ "requirementSearch": "-kTeaG_requirementSearch",
46587
+ "conflictColumns": "-kTeaG_conflictColumns",
46588
+ "commentBody": "-kTeaG_commentBody",
46590
46589
  "documentCommentHighlight": "-kTeaG_documentCommentHighlight",
46591
- "documentReviewAnchorBlocking": "-kTeaG_documentReviewAnchorBlocking",
46590
+ "commentSourceSelected": "-kTeaG_commentSourceSelected",
46591
+ "formErrors": "-kTeaG_formErrors",
46592
+ "dangerText": "-kTeaG_dangerText",
46593
+ "formGrid": "-kTeaG_formGrid",
46594
+ "threadStack": "-kTeaG_threadStack",
46595
+ "threadList": "-kTeaG_threadList",
46596
+ "patchDetails": "-kTeaG_patchDetails",
46597
+ "checkBlocked": "-kTeaG_checkBlocked",
46598
+ "createSummary": "-kTeaG_createSummary",
46599
+ "myWorkButton": "-kTeaG_myWorkButton",
46600
+ "commentThread": "-kTeaG_commentThread",
46601
+ "requirementFilters": "-kTeaG_requirementFilters",
46602
+ "patchImpact": "-kTeaG_patchImpact",
46603
+ "discussionPanel": "-kTeaG_discussionPanel",
46604
+ "contextNav": "-kTeaG_contextNav",
46605
+ "workbench": "-kTeaG_workbench",
46606
+ "richEditorShell": "-kTeaG_richEditorShell",
46592
46607
  "legacyWarning": "-kTeaG_legacyWarning",
46593
- "fileButton": "-kTeaG_fileButton",
46594
- "userMessage": "-kTeaG_userMessage",
46595
- "diffRemoved": "-kTeaG_diffRemoved",
46596
- "execute": "-kTeaG_execute",
46597
- "reviewChecklistAnswered": "-kTeaG_reviewChecklistAnswered",
46608
+ "diffHeader": "-kTeaG_diffHeader",
46609
+ "dialogForm": "-kTeaG_dialogForm",
46610
+ "documentReviewHighlightBlocking": "-kTeaG_documentReviewHighlightBlocking",
46611
+ "versionCompare": "-kTeaG_versionCompare",
46612
+ "aiConversation": "-kTeaG_aiConversation",
46613
+ "run": "-kTeaG_run",
46614
+ "reviewCheckMeta": "-kTeaG_reviewCheckMeta",
46615
+ "replyComposer": "-kTeaG_replyComposer",
46598
46616
  "stage_joint-review": "-kTeaG_stage_joint-review",
46599
- "locateSourceButton": "-kTeaG_locateSourceButton",
46600
- "structuredDiff": "-kTeaG_structuredDiff",
46601
- "threadStack": "-kTeaG_threadStack",
46602
- "collabStateRunning": "-kTeaG_collabStateRunning",
46603
- "versionRow": "-kTeaG_versionRow",
46604
- "mobileSpec": "-kTeaG_mobileSpec",
46605
- "reviewChecklistSelected": "-kTeaG_reviewChecklistSelected",
46606
- "checkIcon": "-kTeaG_checkIcon",
46607
- "conflictDiffs": "-kTeaG_conflictDiffs",
46617
+ "insightCard": "-kTeaG_insightCard",
46618
+ "editorCollabBar": "-kTeaG_editorCollabBar",
46619
+ "patchAccept": "-kTeaG_patchAccept",
46620
+ "reviewCheckCopy": "-kTeaG_reviewCheckCopy",
46621
+ "inlineReviewBody": "-kTeaG_inlineReviewBody",
46622
+ "notificationList": "-kTeaG_notificationList",
46623
+ "insightDialog": "-kTeaG_insightDialog",
46624
+ "emptyPanel": "-kTeaG_emptyPanel",
46625
+ "selectionPrompt": "-kTeaG_selectionPrompt",
46626
+ "commentGlyph": "-kTeaG_commentGlyph",
46627
+ "mobileDocumentsTrigger": "-kTeaG_mobileDocumentsTrigger",
46628
+ "documentButton": "-kTeaG_documentButton",
46629
+ "recordLinkButton": "-kTeaG_recordLinkButton",
46630
+ "reviewChecklistBlocking": "-kTeaG_reviewChecklistBlocking",
46631
+ "requirementMenu": "-kTeaG_requirementMenu",
46632
+ "cardActions": "-kTeaG_cardActions",
46608
46633
  "inlineReviewDetails": "-kTeaG_inlineReviewDetails",
46609
- "checkPassed": "-kTeaG_checkPassed",
46610
- "toolbar": "-kTeaG_toolbar",
46611
- "selectionPromptAbove": "-kTeaG_selectionPromptAbove",
46612
- "titleBlock": "-kTeaG_titleBlock",
46613
- "disabledReason": "-kTeaG_disabledReason",
46614
- "collapseChat": "-kTeaG_collapseChat",
46615
- "collabMetricActive": "-kTeaG_collabMetricActive",
46616
- "stage_product-confirmation": "-kTeaG_stage_product-confirmation",
46617
- "reviewCard": "-kTeaG_reviewCard",
46618
- "notificationButton": "-kTeaG_notificationButton",
46619
- "discussionFilters": "-kTeaG_discussionFilters",
46620
- "inlineDecisionForm": "-kTeaG_inlineDecisionForm",
46621
- "notice": "-kTeaG_notice",
46622
- "conflictDialog": "-kTeaG_conflictDialog",
46634
+ "readyHead": "-kTeaG_readyHead",
46635
+ "decisionResponse": "-kTeaG_decisionResponse",
46636
+ "selectionPromptBelow": "-kTeaG_selectionPromptBelow",
46637
+ "reviewChecklistAnswered": "-kTeaG_reviewChecklistAnswered",
46638
+ "chatMessages": "-kTeaG_chatMessages",
46639
+ "selectedDecisionOption": "-kTeaG_selectedDecisionOption",
46640
+ "activeMode": "-kTeaG_activeMode",
46623
46641
  "inlineReviewHeadActions": "-kTeaG_inlineReviewHeadActions",
46624
- "patchPreview": "-kTeaG_patchPreview",
46625
- "notificationList": "-kTeaG_notificationList",
46626
- "reply": "-kTeaG_reply",
46627
- "taskAssignment": "-kTeaG_taskAssignment",
46628
- "formGrid": "-kTeaG_formGrid",
46629
- "conflictHeader": "-kTeaG_conflictHeader",
46630
- "header": "-kTeaG_header",
46631
- "collabMetricWarn": "-kTeaG_collabMetricWarn",
46632
- "collapseRight": "-kTeaG_collapseRight",
46642
+ "stage_product-confirmation": "-kTeaG_stage_product-confirmation",
46633
46643
  "taskRow": "-kTeaG_taskRow",
46634
- "commentThreadHead": "-kTeaG_commentThreadHead",
46635
- "paneActions": "-kTeaG_paneActions",
46636
- "stickyActions": "-kTeaG_stickyActions",
46637
- "selectionPrompt": "-kTeaG_selectionPrompt",
46638
- "conflictModal": "-kTeaG_conflictModal",
46644
+ "collabMetric": "-kTeaG_collabMetric",
46645
+ "versionRow": "-kTeaG_versionRow",
46646
+ "discussionSummary": "-kTeaG_discussionSummary",
46647
+ "reviewDecisionModal": "-kTeaG_reviewDecisionModal",
46648
+ "editorMeta": "-kTeaG_editorMeta",
46649
+ "decisionSectionHead": "-kTeaG_decisionSectionHead",
46650
+ "notificationButton": "-kTeaG_notificationButton",
46651
+ "dialogSurface": "-kTeaG_dialogSurface",
46639
46652
  "selectionPromptClose": "-kTeaG_selectionPromptClose",
46653
+ "diffContext": "-kTeaG_diffContext",
46654
+ "versionActions": "-kTeaG_versionActions",
46655
+ "checkIcon": "-kTeaG_checkIcon",
46656
+ "collabStateRunning": "-kTeaG_collabStateRunning",
46657
+ "inlineDecisionForm": "-kTeaG_inlineDecisionForm",
46658
+ "runHistory": "-kTeaG_runHistory",
46659
+ "unsaved": "-kTeaG_unsaved",
46640
46660
  "requirementRow": "-kTeaG_requirementRow",
46641
- "replyStack": "-kTeaG_replyStack",
46661
+ "emptyMain": "-kTeaG_emptyMain",
46662
+ "threadHeaderActions": "-kTeaG_threadHeaderActions",
46663
+ "rowMenuButton": "-kTeaG_rowMenuButton",
46642
46664
  "checklist": "-kTeaG_checklist",
46643
- "dialogForm": "-kTeaG_dialogForm",
46644
- "collabMetric": "-kTeaG_collabMetric",
46645
- "mobileDocumentsTrigger": "-kTeaG_mobileDocumentsTrigger",
46646
- "dangerButton": "-kTeaG_dangerButton",
46647
- "checkBlocked": "-kTeaG_checkBlocked",
46648
- "activeContext": "-kTeaG_activeContext",
46649
- "inlineReviewBody": "-kTeaG_inlineReviewBody",
46650
- "reviewAnchorLayer": "-kTeaG_reviewAnchorLayer",
46651
- "selectionPromptHead": "-kTeaG_selectionPromptHead",
46652
- "inlineReviewSource": "-kTeaG_inlineReviewSource",
46653
- "mobileViewSwitch": "-kTeaG_mobileViewSwitch",
46654
- "patchAccept": "-kTeaG_patchAccept",
46655
- "backLabel": "-kTeaG_backLabel",
46656
- "productName": "-kTeaG_productName",
46657
- "taskQueue": "-kTeaG_taskQueue",
46658
- "inlineReviewPrompt": "-kTeaG_inlineReviewPrompt",
46659
- "stage_ready": "-kTeaG_stage_ready",
46660
- "notificationDialog": "-kTeaG_notificationDialog",
46665
+ "compareHead": "-kTeaG_compareHead",
46666
+ "reviewDecisionAside": "-kTeaG_reviewDecisionAside",
46667
+ "grid": "-kTeaG_grid",
46668
+ "userMessage": "-kTeaG_userMessage",
46661
46669
  "commentActions": "-kTeaG_commentActions",
46662
- "filterChecks": "-kTeaG_filterChecks",
46663
- "paneClosed": "-kTeaG_paneClosed",
46664
- "collabBarActions": "-kTeaG_collabBarActions",
46665
- "modal": "-kTeaG_modal",
46666
- "markdownBody": "-kTeaG_markdownBody",
46670
+ "decisionSource": "-kTeaG_decisionSource",
46671
+ "entry": "-kTeaG_entry",
46672
+ "decisionQuestion": "-kTeaG_decisionQuestion",
46673
+ "reviewHeader": "-kTeaG_reviewHeader",
46674
+ "statusDot": "-kTeaG_statusDot",
46675
+ "decisionActions": "-kTeaG_decisionActions",
46676
+ "collapseChat": "-kTeaG_collapseChat",
46677
+ "importPreview": "-kTeaG_importPreview",
46678
+ "conflictDialog": "-kTeaG_conflictDialog",
46679
+ "workflowEyebrow": "-kTeaG_workflowEyebrow",
46680
+ "reviewChecklistRow": "-kTeaG_reviewChecklistRow",
46681
+ "execute": "-kTeaG_execute",
46682
+ "decisionAsideHead": "-kTeaG_decisionAsideHead",
46667
46683
  "decisionEvidenceList": "-kTeaG_decisionEvidenceList",
46668
- "emptyMain": "-kTeaG_emptyMain",
46669
- "primaryNav": "-kTeaG_primaryNav",
46670
- "diffContext": "-kTeaG_diffContext",
46671
- "contextNav": "-kTeaG_contextNav",
46672
- "editorMeta": "-kTeaG_editorMeta",
46684
+ "downstreamReturn": "-kTeaG_downstreamReturn",
46685
+ "documentReviewAnchor": "-kTeaG_documentReviewAnchor",
46686
+ "panelAction": "-kTeaG_panelAction",
46687
+ "mobileSpec": "-kTeaG_mobileSpec",
46688
+ "resizer": "-kTeaG_resizer",
46689
+ "mobileViewSwitch": "-kTeaG_mobileViewSwitch",
46690
+ "stage_ready": "-kTeaG_stage_ready",
46691
+ "versionCopy": "-kTeaG_versionCopy",
46673
46692
  "reviewCheckArrow": "-kTeaG_reviewCheckArrow",
46674
- "threadHeaderActions": "-kTeaG_threadHeaderActions",
46675
- "richEditorShell": "-kTeaG_richEditorShell",
46676
- "runningDot": "-kTeaG_runningDot",
46677
- "reviewDecisionHeader": "-kTeaG_reviewDecisionHeader",
46678
- "workflowFocus": "-kTeaG_workflowFocus",
46679
- "versionCompare": "-kTeaG_versionCompare",
46680
- "entryActive": "-kTeaG_entryActive",
46681
- "emptyPanel": "-kTeaG_emptyPanel",
46682
- "unreadNotification": "-kTeaG_unreadNotification",
46683
- "decisionEvidence": "-kTeaG_decisionEvidence",
46684
- "documents": "-kTeaG_documents",
46685
- "createSummary": "-kTeaG_createSummary",
46686
- "commentThread": "-kTeaG_commentThread",
46687
- "focusMode": "-kTeaG_focusMode",
46688
- "mobileCollab": "-kTeaG_mobileCollab",
46689
- "recordLinkButton": "-kTeaG_recordLinkButton",
46690
- "tabBadge": "-kTeaG_tabBadge",
46691
- "run": "-kTeaG_run",
46692
- "decisionTags": "-kTeaG_decisionTags",
46693
- "versionActions": "-kTeaG_versionActions",
46694
- "review": "-kTeaG_review",
46695
- "readyPackage": "-kTeaG_readyPackage",
46696
- "requirementMenu": "-kTeaG_requirementMenu",
46697
- "documentReviewHighlight": "-kTeaG_documentReviewHighlight",
46698
- "decisionModeHint": "-kTeaG_decisionModeHint",
46699
- "formErrors": "-kTeaG_formErrors",
46693
+ "compareColumns": "-kTeaG_compareColumns",
46700
46694
  "createButton": "-kTeaG_createButton",
46695
+ "editorTitle": "-kTeaG_editorTitle",
46696
+ "resizerHidden": "-kTeaG_resizerHidden",
46697
+ "selectionPromptButtons": "-kTeaG_selectionPromptButtons",
46698
+ "decisionTags": "-kTeaG_decisionTags",
46699
+ "inlineReviewPrompt": "-kTeaG_inlineReviewPrompt",
46700
+ "insightPanel": "-kTeaG_insightPanel",
46701
+ "decisionEvidence": "-kTeaG_decisionEvidence",
46702
+ "entryActive": "-kTeaG_entryActive",
46703
+ "iconButton": "-kTeaG_iconButton",
46701
46704
  "headerActions": "-kTeaG_headerActions",
46702
- "selectionPromptBelow": "-kTeaG_selectionPromptBelow",
46703
- "aiMessage": "-kTeaG_aiMessage",
46704
- "conflictActions": "-kTeaG_conflictActions",
46705
- "chatComposer": "-kTeaG_chatComposer",
46706
- "myWorkButton": "-kTeaG_myWorkButton",
46707
- "emptyAside": "-kTeaG_emptyAside",
46708
- "documentCommentAnchor": "-kTeaG_documentCommentAnchor",
46705
+ "titleBlock": "-kTeaG_titleBlock",
46706
+ "insightScore": "-kTeaG_insightScore",
46707
+ "backLabel": "-kTeaG_backLabel",
46708
+ "topActions": "-kTeaG_topActions",
46709
+ "saveButton": "-kTeaG_saveButton",
46710
+ "diffActions": "-kTeaG_diffActions",
46711
+ "reviewCard": "-kTeaG_reviewCard",
46709
46712
  "inlineReviewQuestion": "-kTeaG_inlineReviewQuestion",
46710
- "mobileDocumentsOpen": "-kTeaG_mobileDocumentsOpen",
46711
- "discussionSummary": "-kTeaG_discussionSummary",
46712
- "selectionPromptActions": "-kTeaG_selectionPromptActions",
46713
- "commentSourceButton": "-kTeaG_commentSourceButton",
46714
- "statusDot": "-kTeaG_statusDot",
46713
+ "selectionPromptCancel": "-kTeaG_selectionPromptCancel",
46714
+ "footer": "-kTeaG_footer",
46715
46715
  "decisionEmpty": "-kTeaG_decisionEmpty",
46716
- "decisionSourceHead": "-kTeaG_decisionSourceHead",
46717
- "reviewChecklist": "-kTeaG_reviewChecklist",
46718
- "diffCollapsed": "-kTeaG_diffCollapsed",
46719
- "panelSummary": "-kTeaG_panelSummary",
46720
- "selectionPromptButtons": "-kTeaG_selectionPromptButtons",
46721
- "dangerText": "-kTeaG_dangerText",
46722
- "reviewChecklistRow": "-kTeaG_reviewChecklistRow",
46723
- "documentReviewHighlightBlocking": "-kTeaG_documentReviewHighlightBlocking",
46724
- "tabPanel": "-kTeaG_tabPanel",
46725
- "reviewCheckBox": "-kTeaG_reviewCheckBox",
46726
- "decisionSource": "-kTeaG_decisionSource",
46727
- "decisionAsideHead": "-kTeaG_decisionAsideHead",
46716
+ "decisionForm": "-kTeaG_decisionForm",
46717
+ "documents": "-kTeaG_documents",
46718
+ "collapseRight": "-kTeaG_collapseRight",
46728
46719
  "editorContext": "-kTeaG_editorContext",
46729
- "stageRail": "-kTeaG_stageRail",
46730
- "paneHead": "-kTeaG_paneHead",
46720
+ "fileButton": "-kTeaG_fileButton",
46721
+ "empty": "-kTeaG_empty",
46722
+ "activeContext": "-kTeaG_activeContext",
46723
+ "inlineReviewActions": "-kTeaG_inlineReviewActions",
46724
+ "documentReviewAnchorSelected": "-kTeaG_documentReviewAnchorSelected",
46725
+ "paneClosed": "-kTeaG_paneClosed",
46731
46726
  "reviewTitle": "-kTeaG_reviewTitle",
46732
- "commentGlyph": "-kTeaG_commentGlyph",
46733
- "versionCopy": "-kTeaG_versionCopy",
46734
- "emptyList": "-kTeaG_emptyList",
46727
+ "mobileDocumentsOpen": "-kTeaG_mobileDocumentsOpen",
46735
46728
  "collabStateSaved": "-kTeaG_collabStateSaved",
46736
- "checkItem": "-kTeaG_checkItem",
46737
- "insightLinks": "-kTeaG_insightLinks",
46738
- "badges": "-kTeaG_badges",
46739
- "reviewDecisionModal": "-kTeaG_reviewDecisionModal",
46740
- "decisionSectionHead": "-kTeaG_decisionSectionHead",
46741
- "noticeHidden": "-kTeaG_noticeHidden",
46742
- "summaryInput": "-kTeaG_summaryInput",
46743
- "workbench": "-kTeaG_workbench",
46729
+ "commentThreadMeta": "-kTeaG_commentThreadMeta",
46730
+ "emptyList": "-kTeaG_emptyList",
46731
+ "stageCurrent": "-kTeaG_stageCurrent",
46732
+ "aiMessage": "-kTeaG_aiMessage",
46733
+ "stickyActions": "-kTeaG_stickyActions",
46734
+ "selectedDoc": "-kTeaG_selectedDoc",
46735
+ "collabBarActions": "-kTeaG_collabBarActions",
46736
+ "editorPane": "-kTeaG_editorPane",
46737
+ "selectionPromptSubmit": "-kTeaG_selectionPromptSubmit",
46738
+ "collabMetricWarn": "-kTeaG_collabMetricWarn",
46744
46739
  "documentAnchorHighlight": "-kTeaG_documentAnchorHighlight",
46745
- "srOnly": "-kTeaG_srOnly",
46746
- "reviewDecisionAside": "-kTeaG_reviewDecisionAside",
46747
- "downstreamReturn": "-kTeaG_downstreamReturn",
46748
- "threadList": "-kTeaG_threadList",
46749
- "reviewDecisionContext": "-kTeaG_reviewDecisionContext",
46750
- "insightPanel": "-kTeaG_insightPanel",
46751
- "checklistMeter": "-kTeaG_checklistMeter",
46752
- "requirementFilters": "-kTeaG_requirementFilters",
46740
+ "commentSourceButton": "-kTeaG_commentSourceButton",
46741
+ "chatError": "-kTeaG_chatError",
46742
+ "checkPassed": "-kTeaG_checkPassed",
46743
+ "decisionSourceHead": "-kTeaG_decisionSourceHead",
46744
+ "taskQueue": "-kTeaG_taskQueue",
46745
+ "decisionModeHint": "-kTeaG_decisionModeHint",
46746
+ "documentAnchorSelected": "-kTeaG_documentAnchorSelected",
46747
+ "disabledReason": "-kTeaG_disabledReason",
46748
+ "diffDialog": "-kTeaG_diffDialog",
46749
+ "reviewAnchorLayer": "-kTeaG_reviewAnchorLayer",
46750
+ "emptyAside": "-kTeaG_emptyAside",
46753
46751
  "summaryField": "-kTeaG_summaryField",
46752
+ "myWorkSummary": "-kTeaG_myWorkSummary",
46753
+ "historyGroup": "-kTeaG_historyGroup",
46754
+ "documentReviewAnchorBlocking": "-kTeaG_documentReviewAnchorBlocking",
46755
+ "srOnly": "-kTeaG_srOnly",
46756
+ "reviewChecklistSelected": "-kTeaG_reviewChecklistSelected",
46757
+ "reviewDecisionBody": "-kTeaG_reviewDecisionBody",
46758
+ "taskAssignment": "-kTeaG_taskAssignment",
46759
+ "insightActions": "-kTeaG_insightActions",
46760
+ "stageDone": "-kTeaG_stageDone",
46761
+ "checkItem": "-kTeaG_checkItem",
46762
+ "editorBody": "-kTeaG_editorBody",
46763
+ "tabBadge": "-kTeaG_tabBadge",
46764
+ "reviewCheckStatus": "-kTeaG_reviewCheckStatus",
46765
+ "paneActions": "-kTeaG_paneActions",
46766
+ "discussionFilters": "-kTeaG_discussionFilters",
46767
+ "notificationDialog": "-kTeaG_notificationDialog",
46754
46768
  "reviewSourceSelected": "-kTeaG_reviewSourceSelected",
46755
- "cardActions": "-kTeaG_cardActions",
46756
- "decisionQuestion": "-kTeaG_decisionQuestion",
46757
- "diffDialog": "-kTeaG_diffDialog",
46769
+ "threadPills": "-kTeaG_threadPills",
46770
+ "reviewDecisionDialog": "-kTeaG_reviewDecisionDialog",
46771
+ "diffCollapsed": "-kTeaG_diffCollapsed",
46772
+ "notice": "-kTeaG_notice",
46773
+ "conflictDiffs": "-kTeaG_conflictDiffs",
46774
+ "workflowFocus": "-kTeaG_workflowFocus",
46775
+ "markdownBody": "-kTeaG_markdownBody",
46758
46776
  "versionPicker": "-kTeaG_versionPicker",
46759
- "decisionActions": "-kTeaG_decisionActions",
46760
- "collabStateDirty": "-kTeaG_collabStateDirty",
46761
- "editorBody": "-kTeaG_editorBody",
46762
- "rowMenuButton": "-kTeaG_rowMenuButton",
46763
- "documentReviewAnchorSelected": "-kTeaG_documentReviewAnchorSelected",
46764
- "conflictColumns": "-kTeaG_conflictColumns",
46765
- "chatToggle": "-kTeaG_chatToggle",
46766
46777
  "inlineReviewHead": "-kTeaG_inlineReviewHead",
46778
+ "reviewDecisionHeader": "-kTeaG_reviewDecisionHeader",
46779
+ "dialogHead": "-kTeaG_dialogHead",
46780
+ "collabStateDirty": "-kTeaG_collabStateDirty",
46767
46781
  "pulse": "-kTeaG_pulse",
46768
- "inlineReviewActions": "-kTeaG_inlineReviewActions",
46769
- "insightCard": "-kTeaG_insightCard",
46770
- "replyComposer": "-kTeaG_replyComposer",
46771
- "documentButton": "-kTeaG_documentButton",
46772
- "readyHead": "-kTeaG_readyHead",
46773
- "commentThreadMeta": "-kTeaG_commentThreadMeta",
46774
- "dialogSurface": "-kTeaG_dialogSurface",
46775
- "reviewCheckMeta": "-kTeaG_reviewCheckMeta",
46776
- "collabBarState": "-kTeaG_collabBarState",
46777
- "patchDetails": "-kTeaG_patchDetails",
46778
- "inlineDecisionOptions": "-kTeaG_inlineDecisionOptions",
46779
- "insightScore": "-kTeaG_insightScore",
46782
+ "paneHead": "-kTeaG_paneHead",
46783
+ "diffAdded": "-kTeaG_diffAdded",
46784
+ "filterChecks": "-kTeaG_filterChecks",
46785
+ "diffRemoved": "-kTeaG_diffRemoved",
46786
+ "richEditor": "-kTeaG_richEditor",
46787
+ "patchPreview": "-kTeaG_patchPreview",
46788
+ "runningDot": "-kTeaG_runningDot",
46780
46789
  "readyPackageHead": "-kTeaG_readyPackageHead",
46781
- "reviewCheckCopy": "-kTeaG_reviewCheckCopy",
46782
- "reviewDecisionDialog": "-kTeaG_reviewDecisionDialog",
46783
- "insightFilters": "-kTeaG_insightFilters",
46784
- "activeFilters": "-kTeaG_activeFilters"
46790
+ "mobileDrawerClose": "-kTeaG_mobileDrawerClose",
46791
+ "checklistMeter": "-kTeaG_checklistMeter",
46792
+ "focusMode": "-kTeaG_focusMode",
46793
+ "stageRail": "-kTeaG_stageRail",
46794
+ "collabBarState": "-kTeaG_collabBarState",
46795
+ "structuredDiff": "-kTeaG_structuredDiff",
46796
+ "identity": "-kTeaG_identity",
46797
+ "reply": "-kTeaG_reply",
46798
+ "chatComposer": "-kTeaG_chatComposer",
46799
+ "decisionOptions": "-kTeaG_decisionOptions",
46800
+ "review": "-kTeaG_review",
46801
+ "insightLinks": "-kTeaG_insightLinks",
46802
+ "dangerButton": "-kTeaG_dangerButton",
46803
+ "reviewChecklistSettled": "-kTeaG_reviewChecklistSettled",
46804
+ "activeFilters": "-kTeaG_activeFilters",
46805
+ "primaryNav": "-kTeaG_primaryNav",
46806
+ "toolbar": "-kTeaG_toolbar",
46807
+ "selectionPromptActions": "-kTeaG_selectionPromptActions",
46808
+ "chatToggle": "-kTeaG_chatToggle"
46785
46809
  };
46786
46810
  //#endregion
46787
46811
  //#region src/client/AccessibleDialog.tsx
package/lib/index.js CHANGED
@@ -482,6 +482,32 @@ function backtrack(trace, left, right) {
482
482
  return result.reverse();
483
483
  }
484
484
  //#endregion
485
+ //#region src/ready-admission.ts
486
+ function hasCompletedCurrentReview(record, kind) {
487
+ return record.aiRuns.some((run) => run.commit === record.currentCommit && run.kind === kind && run.status === "completed");
488
+ }
489
+ function hasVersionConfirmation(record, role) {
490
+ return record.confirmations.some((item) => item.commit === record.currentCommit && item.role === role && item.scope === "version" && item.status === "active");
491
+ }
492
+ /** Shared by workflow guidance and the authoritative Ready write. Checks must come from the current Git body. */
493
+ function readyAdmission(record, checks) {
494
+ const activeRun = record.aiRuns.slice().reverse().find((run) => run.commit === record.currentCommit && (run.status === "queued" || run.status === "running"));
495
+ const engineeringReviewed = hasCompletedCurrentReview(record, "engineering-precheck");
496
+ const pendingPatches = record.patches.filter((item) => item.baseCommit === record.currentCommit && item.status === "pending");
497
+ const failedChecks = checks.filter((check) => !check.passed);
498
+ const productConfirmed = hasVersionConfirmation(record, "product");
499
+ const engineeringConfirmed = hasVersionConfirmation(record, "engineering");
500
+ return {
501
+ activeRun,
502
+ engineeringReviewed,
503
+ pendingPatches,
504
+ failedChecks,
505
+ productConfirmed,
506
+ engineeringConfirmed,
507
+ error: record.stage !== "joint-review" ? "readiness gate is not satisfied" : !record.workspaceId?.trim() ? "review workspace is required" : activeRun ? "current version review is still running" : !engineeringReviewed ? "engineering precheck is required for the current version" : pendingPatches.length > 0 ? "current version has pending patches" : failedChecks.length > 0 ? "readiness gate is not satisfied" : !productConfirmed || !engineeringConfirmed ? "current version needs product and engineering confirmation" : void 0
508
+ };
509
+ }
510
+ //#endregion
485
511
  //#region src/engine.ts
486
512
  const emptyState = () => ({
487
513
  schemaVersion: 3,
@@ -1122,9 +1148,8 @@ var CollaborationEngine = class {
1122
1148
  this.persist();
1123
1149
  } else if (action.kind === "ready.generate") {
1124
1150
  requireHuman(action.participant);
1125
- const checks = readiness(this.versions.read(record.id, record.currentCommit).markdown, record);
1126
- if (record.stage !== "joint-review" || checks.some((check) => !check.passed)) throw new Error("readiness gate is not satisfied");
1127
- if (!hasVersionConfirmation(record, "product") || !hasVersionConfirmation(record, "engineering")) throw new Error("current version needs product and engineering confirmation");
1151
+ const admission = readyAdmission(record, readiness(this.versions.read(record.id, record.currentCommit).markdown, record));
1152
+ if (admission.error) throw new Error(admission.error);
1128
1153
  const markdown = readyMarkdown(this.view(record.id));
1129
1154
  record.readyPackage = {
1130
1155
  requirementId: record.id,
@@ -1441,14 +1466,17 @@ var CollaborationEngine = class {
1441
1466
  run,
1442
1467
  ...existingSession ? { sessionId: existingSession } : {}
1443
1468
  }).then((sessionId) => {
1444
- run.status = "running";
1445
- run.sessionId = sessionId;
1446
- run.updatedAt = Date.now();
1447
- this.rememberStageConversation(record, sessionId, requestedStage, requestedStageCycle);
1469
+ const currentRecord = this.state.requirements.find((item) => item.id === record.id);
1470
+ const currentRun = currentRecord?.aiRuns.find((item) => item.id === run.id);
1471
+ if (currentRecord === void 0 || currentRun === void 0) return;
1472
+ if (currentRun.status === "queued") currentRun.status = "running";
1473
+ currentRun.sessionId = sessionId;
1474
+ currentRun.updatedAt = Date.now();
1475
+ this.rememberStageConversation(currentRecord, sessionId, requestedStage, requestedStageCycle);
1448
1476
  this.persist({
1449
1477
  types: ["ai.status", "metrics.changed"],
1450
- requirementId: record.id,
1451
- objectId: run.id
1478
+ requirementId: currentRecord.id,
1479
+ objectId: currentRun.id
1452
1480
  });
1453
1481
  }, (error) => this.markAiFailure(record.id, run.id, error instanceof Error ? error.message : String(error)));
1454
1482
  }
@@ -1907,9 +1935,6 @@ function actionForReview(item) {
1907
1935
  updatedAt: now
1908
1936
  };
1909
1937
  }
1910
- function hasVersionConfirmation(record, role) {
1911
- return record.confirmations.some((item) => item.role === role && item.scope === "version" && item.commit === record.currentCommit && item.status === "active");
1912
- }
1913
1938
  function enterStage(record, stage) {
1914
1939
  if (record.stage === stage) return;
1915
1940
  record.stage = stage;
@@ -1922,7 +1947,7 @@ function advance(record, participant) {
1922
1947
  "non-blocking-verify",
1923
1948
  "joint-review"
1924
1949
  ].includes(item.status))) throw new Error("product blocking review items remain");
1925
- if (!record.aiRuns.some((run) => run.kind === "product-second" && run.commit === record.currentCommit && run.status === "completed")) throw new Error("product second review is required");
1950
+ if (!hasCompletedCurrentReview(record, "product-second")) throw new Error("product second review is required");
1926
1951
  enterStage(record, "product-confirmation");
1927
1952
  return;
1928
1953
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/client/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAElF,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AACrD,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ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CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAS3E,OAAO,CAAC,UAAU;IA6PlB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,yBAAyB;IAKjC,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,IAAI;CAwBb;AAsRD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,cAAc,EAAE,CAYvF"}
@@ -0,0 +1,14 @@
1
+ import type { ParticipantRole, ReadinessCheck, RequirementRecord, ReviewKind } from './protocol.ts';
2
+ export declare function hasCompletedCurrentReview(record: Pick<RequirementRecord, 'aiRuns' | 'currentCommit'>, kind: ReviewKind): boolean;
3
+ export declare function hasVersionConfirmation(record: Pick<RequirementRecord, 'confirmations' | 'currentCommit'>, role: ParticipantRole): boolean;
4
+ /** Shared by workflow guidance and the authoritative Ready write. Checks must come from the current Git body. */
5
+ export declare function readyAdmission(record: RequirementRecord, checks: ReadinessCheck[]): {
6
+ activeRun: import("./protocol.ts").AiReviewRun | undefined;
7
+ engineeringReviewed: boolean;
8
+ pendingPatches: import("./protocol.ts").CandidatePatch[];
9
+ failedChecks: ReadinessCheck[];
10
+ productConfirmed: boolean;
11
+ engineeringConfirmed: boolean;
12
+ error: string | undefined;
13
+ };
14
+ //# sourceMappingURL=ready-admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ready-admission.d.ts","sourceRoot":"","sources":["../../src/ready-admission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEnG,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAGhI;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAEzI;AAED,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE;;;;;;;;EAgBjF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-spec-collab",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "AI-assisted requirement clarification and Git-backed Spec co-creation for DeepSeek Harness, ending at a human-confirmed Ready Spec.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -46,10 +46,16 @@
46
46
  "files": [
47
47
  "lib",
48
48
  "src",
49
- "docs",
49
+ "docs/*.md",
50
+ "docs/*.csv",
51
+ "docs/assets",
50
52
  "cordis.patch.yml",
51
- "README.md"
53
+ "README.md",
54
+ "CHANGELOG.md"
52
55
  ],
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org"
58
+ },
53
59
  "scripts": {
54
60
  "clean": "node -e \"require('node:fs').rmSync('lib', { recursive: true, force: true })\"",
55
61
  "build": "npm run clean && tsc -p tsconfig.build.json && tsdown",
@@ -89,6 +95,7 @@
89
95
  "vitest": "^3.0.0"
90
96
  },
91
97
  "peerDependencies": {
98
+ "@deepseek-ai/dsh-tools": "0.1.1-rc.1",
92
99
  "react": "^18.2.0",
93
100
  "react-dom": "^18.2.0"
94
101
  },
@@ -1,4 +1,5 @@
1
1
  import type { ParticipantRole, RequirementView, ReviewKind } from '../protocol.ts'
2
+ import { hasCompletedCurrentReview, readyAdmission } from '../ready-admission.ts'
2
3
 
3
4
  export type TaskView = 'review' | 'patches' | 'ready'
4
5
  export type WorkflowCommand =
@@ -27,15 +28,10 @@ export function workflowState(requirement: RequirementView, participantRole: Par
27
28
  const blockers = currentReviews.filter(item => item.severity === 'blocking' && reviewIsOpen(item.status))
28
29
  const productBlockers = blockers.filter(item => item.status !== 'joint-review')
29
30
  const unanswered = blockers.filter(item => item.status === 'open')
30
- const currentPatches = requirement.patches.filter(item => item.baseCommit === requirement.currentCommit && item.status === 'pending')
31
- const currentRuns = requirement.aiRuns.filter(run => run.commit === requirement.currentCommit)
32
- const activeRun = currentRuns.slice().reverse().find(run => ['queued', 'running'].includes(run.status))
33
- const completed = (kind: ReviewKind): boolean => currentRuns.some(run => run.kind === kind && run.status === 'completed')
34
- const productConfirmed = requirement.confirmations.some(item => item.commit === requirement.currentCommit && item.role === 'product' && item.scope === 'version' && item.status === 'active')
35
- const engineeringConfirmed = requirement.confirmations.some(item => item.commit === requirement.currentCommit && item.role === 'engineering' && item.scope === 'version' && item.status === 'active')
36
- const failedChecks = requirement.readiness.filter(check => !check.passed)
31
+ const { activeRun, engineeringReviewed, pendingPatches: currentPatches, failedChecks, productConfirmed, engineeringConfirmed } = readyAdmission(requirement, requirement.readiness)
32
+ const completed = (kind: ReviewKind): boolean => hasCompletedCurrentReview(requirement, kind)
37
33
 
38
- if (!requirement.workspaceId) return {
34
+ if (!requirement.workspaceId?.trim()) return {
39
35
  eyebrow: '开始前', title: '关联需求所在的项目', detail: 'AI 会从这个项目读取代码、规范和团队知识,关联后不能中途切换。',
40
36
  actionLabel: '选择项目', command: { kind: 'bind-workspace' },
41
37
  }
@@ -81,7 +77,7 @@ export function workflowState(requirement: RequirementView, participantRole: Par
81
77
  }
82
78
 
83
79
  if (requirement.stage === 'joint-review') {
84
- if (!completed('engineering-precheck')) return {
80
+ if (!engineeringReviewed) return {
85
81
  eyebrow: '产研共审', title: '从研发视角检查可实施性', detail: '重点检查现有实现、影响范围、兼容性和测试落点。',
86
82
  actionLabel: '开始研发检查', command: { kind: 'request-review', reviewKind: 'engineering-precheck' },
87
83
  }
@@ -125,6 +121,9 @@ export function workflowState(requirement: RequirementView, participantRole: Par
125
121
 
126
122
  export function friendlyActionError(error: string): string {
127
123
  const messages: Array<[string, string]> = [
124
+ ['engineering precheck is required for the current version', '需要先完成当前版本的研发检查;正文变更后请重新检查。'],
125
+ ['current version review is still running', '当前版本的 AI 检查仍在进行,请等待完成后再生成就绪需求。'],
126
+ ['current version has pending patches', '当前版本还有待审核的正文修改,请先接受或拒绝。'],
128
127
  ['product blocking review items remain', '还有阻塞问题未处理,请先完成待澄清事项。'],
129
128
  ['product second review is required', '需要先让 AI 根据回复整理并复核正文。'],
130
129
  ['product must confirm the current version', '需要产品角色确认当前版本后才能进入产研共审。'],
package/src/engine.ts CHANGED
@@ -4,6 +4,7 @@ import { basename, dirname, extname, join } from 'node:path'
4
4
  import { GitRequirementStore, VersionConflictError } from './git-store.ts'
5
5
  import { SCHEMA_VERSION, type ActionItem, type ActionResult, type AiReviewRun, type CandidatePatch, type CollaborationAction, type CollaborationEvent, type CollaborationState, type CommentThread, type FeedbackSource, type Insight, type InsightImportance, type InsightLink, type MyActionItem, type MyItemCategory, type Notification, type ParticipantSnapshot, type ReadinessCheck, type RequirementMetrics, type RequirementRecord, type RequirementSummary, type RequirementVersion, type RequirementView, type ReviewItem, type ReviewKind, type SaveConflict, type StructuredDiff } from './protocol.ts'
6
6
  import { buildStructuredDiff } from './structured-diff.ts'
7
+ import { hasCompletedCurrentReview, hasVersionConfirmation, readyAdmission } from './ready-admission.ts'
7
8
 
8
9
  export interface AiCoordinator {
9
10
  requestReview(input: { requirement: RequirementView; run: AiReviewRun; sessionId?: string }): Promise<string>
@@ -319,9 +320,8 @@ export class CollaborationEngine {
319
320
  advance(record, action.participant); this.persist()
320
321
  } else if (action.kind === 'ready.generate') {
321
322
  requireHuman(action.participant)
322
- const checks = readiness(this.versions.read(record.id, record.currentCommit).markdown, record)
323
- if (record.stage !== 'joint-review' || checks.some(check => !check.passed)) throw new Error('readiness gate is not satisfied')
324
- if (!hasVersionConfirmation(record, 'product') || !hasVersionConfirmation(record, 'engineering')) throw new Error('current version needs product and engineering confirmation')
323
+ const admission = readyAdmission(record, readiness(this.versions.read(record.id, record.currentCommit).markdown, record))
324
+ if (admission.error) throw new Error(admission.error)
325
325
  const markdown = readyMarkdown(this.view(record.id))
326
326
  record.readyPackage = { requirementId: record.id, commit: record.currentCommit, packageHash: createHash('sha256').update(markdown).digest('hex'), generatedAt: now, generatedBy: action.participant, markdown }
327
327
  enterStage(record, 'ready'); this.persist()
@@ -465,7 +465,12 @@ export class CollaborationEngine {
465
465
  const requestedStage = record.stage; const requestedStageCycle = record.stageCycle
466
466
  const existingSession = record.aiConversations.find(item => item.stage === requestedStage && item.stageCycle === requestedStageCycle)?.sessionId
467
467
  void coordinator.requestReview({ requirement: view, run, ...(existingSession ? { sessionId: existingSession } : {}) }).then(sessionId => {
468
- run.status = 'running'; run.sessionId = sessionId; run.updatedAt = Date.now(); this.rememberStageConversation(record, sessionId, requestedStage, requestedStageCycle); this.persist({ types: ['ai.status', 'metrics.changed'], requirementId: record.id, objectId: run.id })
468
+ // Rejected actions restore a cloned state while this launch can still be pending.
469
+ const currentRecord = this.state.requirements.find(item => item.id === record.id)
470
+ const currentRun = currentRecord?.aiRuns.find(item => item.id === run.id)
471
+ if (currentRecord === undefined || currentRun === undefined) return
472
+ if (currentRun.status === 'queued') currentRun.status = 'running'
473
+ currentRun.sessionId = sessionId; currentRun.updatedAt = Date.now(); this.rememberStageConversation(currentRecord, sessionId, requestedStage, requestedStageCycle); this.persist({ types: ['ai.status', 'metrics.changed'], requirementId: currentRecord.id, objectId: currentRun.id })
469
474
  }, error => this.markAiFailure(record.id, run.id, error instanceof Error ? error.message : String(error)))
470
475
  }
471
476
 
@@ -715,7 +720,6 @@ function assertChineseFeedback(...values: string[]): void {
715
720
  }
716
721
  function requireHuman(participant: ParticipantSnapshot): void { if (participant.kind !== 'human') throw new Error('human participant is required') }
717
722
  function actionForReview(item: ReviewItem): ActionItem { const now = Date.now(); return { id: randomUUID(), requirementId: item.requirementId, sourceType: 'review-item', sourceId: item.id, type: 'reply', assigneeRole: item.ownerRole, blocking: item.severity === 'blocking', status: 'pending', dueStage: item.reviewKind.startsWith('product') ? 'product-review' : 'joint-review', createdAt: now, updatedAt: now } }
718
- function hasVersionConfirmation(record: RequirementRecord, role: 'product' | 'engineering'): boolean { return record.confirmations.some(item => item.role === role && item.scope === 'version' && item.commit === record.currentCommit && item.status === 'active') }
719
723
  function enterStage(record: RequirementRecord, stage: RequirementRecord['stage']): void {
720
724
  if (record.stage === stage) return
721
725
  record.stage = stage
@@ -724,7 +728,7 @@ function enterStage(record: RequirementRecord, stage: RequirementRecord['stage']
724
728
  function advance(record: RequirementRecord, participant: ParticipantSnapshot): void {
725
729
  if (record.stage === 'product-review') {
726
730
  if (record.reviewItems.some(item => item.commit === record.currentCommit && item.severity === 'blocking' && !['resolved', 'non-blocking-verify', 'joint-review'].includes(item.status))) throw new Error('product blocking review items remain')
727
- if (!record.aiRuns.some(run => run.kind === 'product-second' && run.commit === record.currentCommit && run.status === 'completed')) throw new Error('product second review is required')
731
+ if (!hasCompletedCurrentReview(record, 'product-second')) throw new Error('product second review is required')
728
732
  enterStage(record, 'product-confirmation'); return
729
733
  }
730
734
  if (record.stage === 'product-confirmation') {
@@ -0,0 +1,29 @@
1
+ import type { ParticipantRole, ReadinessCheck, RequirementRecord, ReviewKind } from './protocol.ts'
2
+
3
+ export function hasCompletedCurrentReview(record: Pick<RequirementRecord, 'aiRuns' | 'currentCommit'>, kind: ReviewKind): boolean {
4
+ // A failed retry does not erase an earlier completed review of this exact body.
5
+ return record.aiRuns.some(run => run.commit === record.currentCommit && run.kind === kind && run.status === 'completed')
6
+ }
7
+
8
+ export function hasVersionConfirmation(record: Pick<RequirementRecord, 'confirmations' | 'currentCommit'>, role: ParticipantRole): boolean {
9
+ return record.confirmations.some(item => item.commit === record.currentCommit && item.role === role && item.scope === 'version' && item.status === 'active')
10
+ }
11
+
12
+ /** Shared by workflow guidance and the authoritative Ready write. Checks must come from the current Git body. */
13
+ export function readyAdmission(record: RequirementRecord, checks: ReadinessCheck[]) {
14
+ const activeRun = record.aiRuns.slice().reverse().find(run => run.commit === record.currentCommit && (run.status === 'queued' || run.status === 'running'))
15
+ const engineeringReviewed = hasCompletedCurrentReview(record, 'engineering-precheck')
16
+ const pendingPatches = record.patches.filter(item => item.baseCommit === record.currentCommit && item.status === 'pending')
17
+ const failedChecks = checks.filter(check => !check.passed)
18
+ const productConfirmed = hasVersionConfirmation(record, 'product')
19
+ const engineeringConfirmed = hasVersionConfirmation(record, 'engineering')
20
+ const error = record.stage !== 'joint-review' ? 'readiness gate is not satisfied'
21
+ : !record.workspaceId?.trim() ? 'review workspace is required'
22
+ : activeRun ? 'current version review is still running'
23
+ : !engineeringReviewed ? 'engineering precheck is required for the current version'
24
+ : pendingPatches.length > 0 ? 'current version has pending patches'
25
+ : failedChecks.length > 0 ? 'readiness gate is not satisfied'
26
+ : !productConfirmed || !engineeringConfirmed ? 'current version needs product and engineering confirmation'
27
+ : undefined
28
+ return { activeRun, engineeringReviewed, pendingPatches, failedChecks, productConfirmed, engineeringConfirmed, error }
29
+ }