dsh-spec-collab 0.1.1 → 0.1.3
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/README.md +33 -0
- package/docs/assets/demo-01-workspace.png +0 -0
- package/docs/assets/demo-02-ai-review.png +0 -0
- package/docs/assets/demo-03-patches.png +0 -0
- package/docs/assets/demo-04-decisions.png +0 -0
- package/docs/assets/demo-05-ready.png +0 -0
- package/docs/assets/spec-collab-walkthrough.mp4 +0 -0
- package/docs/usage-walkthrough.md +71 -0
- package/lib/client.js +145 -102
- package/lib/index.js +4 -4
- package/lib/types/client/SpecWorkbench.d.ts.map +1 -1
- package/lib/types/client/api.d.ts.map +1 -1
- package/lib/types/client/browser-uuid.d.ts +7 -0
- package/lib/types/client/browser-uuid.d.ts.map +1 -0
- package/lib/types/client/mount.d.ts.map +1 -1
- package/lib/types/client/sidebar-anchor.d.ts +6 -0
- package/lib/types/client/sidebar-anchor.d.ts.map +1 -0
- package/package.json +9 -8
- package/src/client/SpecWorkbench.tsx +16 -5
- package/src/client/api.ts +2 -1
- package/src/client/browser-uuid.ts +15 -0
- package/src/client/mount.tsx +5 -5
- package/src/client/sidebar-anchor.ts +16 -0
- package/src/engine.ts +4 -4
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ DeepSeek Harness 的独立双面插件,用于把产品的原始需求澄清为
|
|
|
7
7
|
|
|
8
8
|
产品边界严格止于 Ready Spec,不包含代码实现、测试用例生成、worktree、MR、部署、发布或交付状态管理。
|
|
9
9
|
|
|
10
|
+
兼容 DeepSeek Harness `v0.1.1-rc.1`。插件可在局域网 HTTP 地址下运行,不依赖浏览器提供 `crypto.randomUUID`;DSH 精简侧栏仅显示“设置”时,也会正常挂载“需求讨论”入口。
|
|
11
|
+
|
|
10
12
|
## 一键安装
|
|
11
13
|
|
|
12
14
|
已有 Node.js 环境时,无需先全局安装 DSH CLI:
|
|
@@ -27,6 +29,8 @@ dsh plugin --profile web add dsh-spec-collab@latest
|
|
|
27
29
|
dsh plugin --profile web update dsh-spec-collab@latest
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
插件已经内置非安全 HTTP 环境所需的 UUID fallback,不需要通过代理向 HTML 注入 `crypto` polyfill。团队部署仍建议使用 HTTPS,并在 DSH 前配置认证。
|
|
33
|
+
|
|
30
34
|
## 核心流程
|
|
31
35
|
|
|
32
36
|
```text
|
|
@@ -41,6 +45,35 @@ dsh plugin --profile web update dsh-spec-collab@latest
|
|
|
41
45
|
-> 输出 Ready Spec
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
## 完整演示
|
|
49
|
+
|
|
50
|
+
点击下方截图观看从选择工作区到生成 Ready Spec 的完整 MP4 录屏:
|
|
51
|
+
|
|
52
|
+
[](docs/assets/spec-collab-walkthrough.mp4)
|
|
53
|
+
|
|
54
|
+
**[播放 MP4 录屏](docs/assets/spec-collab-walkthrough.mp4)** · **[阅读完整图文教程](docs/usage-walkthrough.md)**
|
|
55
|
+
|
|
56
|
+
<details>
|
|
57
|
+
<summary>查看完整流程截图</summary>
|
|
58
|
+
|
|
59
|
+
### 1. 新建需求并选择工作区
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
### 2. AI 审核问题和人工回复
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
### 3. 审核并接受候选 Patch
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
### 4. 记录人工 Decision
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
</details>
|
|
76
|
+
|
|
44
77
|
## 能力
|
|
45
78
|
|
|
46
79
|
- 匿名只读;首次评论、修改、回复、确认前登记 `participant_id + 花名 + 责任角色`。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 完整使用演示:从原始需求到 Ready Spec
|
|
2
|
+
|
|
3
|
+
本演示使用需求“登录页密码显示开关”走完产品初审、产品复审、候选 Patch、人工决策、产品确认、研发预审、研发确认和 Ready 质量门。演示中的所有 AI 操作都绑定到所选 DSH 工作区,人工确认绑定到精确 Git commit。
|
|
4
|
+
|
|
5
|
+
[观看完整流程录屏(MP4)](assets/spec-collab-walkthrough.mp4)
|
|
6
|
+
|
|
7
|
+
## 演示需求
|
|
8
|
+
|
|
9
|
+
> 用户在登录页输入较长密码时,无法确认是否输错。希望在密码输入框右侧增加“显示/隐藏密码”图标:默认隐藏;点击后显示明文,再次点击恢复隐藏;切换时不得清空密码或让输入框失去焦点;键盘用户可操作并获得可读标签。仅改登录页,注册、找回密码和修改密码页不在本次范围。桌面端和移动端都需要支持。
|
|
10
|
+
|
|
11
|
+
## 1. 新建需求并选择工作区
|
|
12
|
+
|
|
13
|
+
点击需求栏右上角的 `+`,填写需求标题、原始需求和来源。项目工作区是必填项;插件不会允许需求进入“未分组”工作区,因为后续 AI 初审、复审和评论分析都需要从这里继承项目的 Skill、MCP、本地参考文档及 Agent Preset。
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
创建后,原始输入会立即固定为第一个 Git commit。需求一旦绑定工作区便不能中途切换,避免同一份 Spec 的审核上下文发生漂移。
|
|
18
|
+
|
|
19
|
+
## 2. 运行智能初审并逐项回复
|
|
20
|
+
|
|
21
|
+
点击“智能初审”。AI 会按目标、范围、业务语义、验收标准、风险、当前实现、历史冲突和证据等维度生成结构化 Review Item。每条结论都会标注 `FACT`、`INFERENCE`、`ASSUMPTION` 或 `TO_VERIFY`。
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
处理审核项时遵循以下规则:
|
|
26
|
+
|
|
27
|
+
- 有业务结论时选择推荐方案或自行输入,并说明取舍。
|
|
28
|
+
- 有固定版本证据时补充来源、版本和证据说明。
|
|
29
|
+
- 当前无法核验源码、历史或浏览器矩阵时选择 `TO_VERIFY`,不要把推测写成 `FACT`。
|
|
30
|
+
- `接受 AI 建议` 用于无需修改正文即可确认的结论;`修改后接受` 表示仍需等待候选 Patch。
|
|
31
|
+
|
|
32
|
+
## 3. 智能复审并接受候选 Patch
|
|
33
|
+
|
|
34
|
+
产品回复完成后运行“智能复审”。AI 会检查回复是否真正覆盖原问题,并生成基于精确 `baseCommit` 的候选 Patch。打开“修改建议”,预览完整候选规范,确认变更范围和 AC 后由人工点击接受。
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
AI 只能提议 Patch,不能直接写 Git。人工接受后插件创建新 commit,并自动触发 change review;基于旧 commit 的候选 Patch 会失效。
|
|
39
|
+
|
|
40
|
+
## 4. 记录 Decision 并确认产品版本
|
|
41
|
+
|
|
42
|
+
对状态生命周期、范围边界或新增 AC 等关键选择,在“确认决策”中记录 Decision。Decision 与普通评论分离,包含结论、理由、确认人及受影响章节或 AC。
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
产品二审无当前版本阻塞项后进入“产品确认”,由产品确认当前 commit。任何后续正文修改都会使受影响的确认失效,必须重新确认。
|
|
47
|
+
|
|
48
|
+
## 5. 研发预审、双角色确认和 Ready
|
|
49
|
+
|
|
50
|
+
进入“产研共审”后运行“研发智能预审”。工程侧重点核验当前实现、共享组件影响、测试落点、浏览器矩阵及历史约束。演示工作区没有目标业务仓库源码,因此相关项被明确保留为非阻塞 `TO_VERIFY`,而不是虚构实现证据。
|
|
51
|
+
|
|
52
|
+
研发确认与产品确认必须绑定同一个当前 commit。随后点击“生成就绪规范”,只有以下六项全部通过才能生成 Ready Spec:
|
|
53
|
+
|
|
54
|
+
- 目标与用户结果
|
|
55
|
+
- 验收标准
|
|
56
|
+
- 范围与非范围
|
|
57
|
+
- 业务语义
|
|
58
|
+
- 证据来源
|
|
59
|
+
- 测试约束
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
本次演示最终生成的 Ready Spec 绑定 commit `ac8182473bf5ce971cec92db9391b3f702867fe8`,产品和研发均确认该版本。历史 Review Item 保留在审核记录中用于审计,但不会继续阻塞新 commit;当前未核验的实现和兼容性问题则进入 Ready Spec 的“非阻塞 Open Questions”。
|
|
64
|
+
|
|
65
|
+
## 正确使用要点
|
|
66
|
+
|
|
67
|
+
1. 新建需求时选择真实项目工作区,先配置好该工作区需要的 Skill、MCP 和参考文档路径。
|
|
68
|
+
2. 把 AI 当作审核者和提议者,不让 AI 代替产品或研发确认。
|
|
69
|
+
3. 每个事实都提供可访问、版本固定的证据;缺证据时使用 `TO_VERIFY`。
|
|
70
|
+
4. 接受 Patch 前检查 `baseCommit`、受影响章节和 AC;正文变化后重新完成必要审核与确认。
|
|
71
|
+
5. 产品和研发必须确认同一个当前 commit,六项质量门通过后再生成 Ready Spec。
|
package/lib/client.js
CHANGED
|
@@ -42,6 +42,18 @@ window.__ModuleLoader__.load({
|
|
|
42
42
|
//#region src/protocol.ts
|
|
43
43
|
const API_PREFIX = "/api/spec-collab";
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/client/browser-uuid.ts
|
|
46
|
+
function browserUuid(source = globalThis.crypto) {
|
|
47
|
+
if (typeof source?.randomUUID === "function") return source.randomUUID();
|
|
48
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
49
|
+
if (typeof source?.getRandomValues === "function") source.getRandomValues(bytes);
|
|
50
|
+
else for (let index = 0; index < bytes.length; index += 1) bytes[index] = Math.floor(Math.random() * 256);
|
|
51
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
52
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
53
|
+
const hex = [...bytes].map((value) => value.toString(16).padStart(2, "0"));
|
|
54
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
45
57
|
//#region src/client/api.ts
|
|
46
58
|
var SpecApi = class {
|
|
47
59
|
async state() {
|
|
@@ -62,7 +74,7 @@ window.__ModuleLoader__.load({
|
|
|
62
74
|
}
|
|
63
75
|
async action(action) {
|
|
64
76
|
const envelope = {
|
|
65
|
-
requestId:
|
|
77
|
+
requestId: browserUuid(),
|
|
66
78
|
action
|
|
67
79
|
};
|
|
68
80
|
return (await fetch(`${API_PREFIX}/action`, {
|
|
@@ -39153,113 +39165,113 @@ window.__ModuleLoader__.load({
|
|
|
39153
39165
|
document.head.appendChild(tag);
|
|
39154
39166
|
}
|
|
39155
39167
|
var workbench_module_css_default = {
|
|
39156
|
-
"
|
|
39157
|
-
"
|
|
39168
|
+
"documents": "-kTeaG_documents",
|
|
39169
|
+
"review": "-kTeaG_review",
|
|
39170
|
+
"paneClosed": "-kTeaG_paneClosed",
|
|
39171
|
+
"richEditor": "-kTeaG_richEditor",
|
|
39172
|
+
"markdownBody": "-kTeaG_markdownBody",
|
|
39173
|
+
"notice": "-kTeaG_notice",
|
|
39174
|
+
"editorBody": "-kTeaG_editorBody",
|
|
39175
|
+
"collapseChat": "-kTeaG_collapseChat",
|
|
39158
39176
|
"view": "-kTeaG_view",
|
|
39159
|
-
"iconButton": "-kTeaG_iconButton",
|
|
39160
|
-
"chatError": "-kTeaG_chatError",
|
|
39161
|
-
"noticeHidden": "-kTeaG_noticeHidden",
|
|
39162
39177
|
"checklist": "-kTeaG_checklist",
|
|
39163
|
-
"
|
|
39164
|
-
"
|
|
39165
|
-
"
|
|
39166
|
-
"
|
|
39167
|
-
"
|
|
39168
|
-
"
|
|
39169
|
-
"
|
|
39170
|
-
"
|
|
39171
|
-
"
|
|
39178
|
+
"chatMessages": "-kTeaG_chatMessages",
|
|
39179
|
+
"mobileSpec": "-kTeaG_mobileSpec",
|
|
39180
|
+
"identity": "-kTeaG_identity",
|
|
39181
|
+
"resizerHidden": "-kTeaG_resizerHidden",
|
|
39182
|
+
"summaryInput": "-kTeaG_summaryInput",
|
|
39183
|
+
"requirementMenu": "-kTeaG_requirementMenu",
|
|
39184
|
+
"run": "-kTeaG_run",
|
|
39185
|
+
"aiConversation": "-kTeaG_aiConversation",
|
|
39186
|
+
"emptyMain": "-kTeaG_emptyMain",
|
|
39187
|
+
"runHistory": "-kTeaG_runHistory",
|
|
39188
|
+
"titleBlock": "-kTeaG_titleBlock",
|
|
39189
|
+
"grid": "-kTeaG_grid",
|
|
39190
|
+
"quickOptions": "-kTeaG_quickOptions",
|
|
39191
|
+
"documentButton": "-kTeaG_documentButton",
|
|
39192
|
+
"headerActions": "-kTeaG_headerActions",
|
|
39193
|
+
"editorContext": "-kTeaG_editorContext",
|
|
39194
|
+
"tabBadge": "-kTeaG_tabBadge",
|
|
39195
|
+
"workbench": "-kTeaG_workbench",
|
|
39172
39196
|
"activeMode": "-kTeaG_activeMode",
|
|
39173
|
-
"
|
|
39174
|
-
"
|
|
39175
|
-
"
|
|
39197
|
+
"panelSummary": "-kTeaG_panelSummary",
|
|
39198
|
+
"patchDetails": "-kTeaG_patchDetails",
|
|
39199
|
+
"chatError": "-kTeaG_chatError",
|
|
39200
|
+
"humanResponse": "-kTeaG_humanResponse",
|
|
39201
|
+
"responseForm": "-kTeaG_responseForm",
|
|
39202
|
+
"checkItem": "-kTeaG_checkItem",
|
|
39176
39203
|
"itemsPanel": "-kTeaG_itemsPanel",
|
|
39177
|
-
"
|
|
39178
|
-
"
|
|
39179
|
-
"
|
|
39180
|
-
"
|
|
39181
|
-
"
|
|
39182
|
-
"
|
|
39204
|
+
"paneHead": "-kTeaG_paneHead",
|
|
39205
|
+
"versionCompare": "-kTeaG_versionCompare",
|
|
39206
|
+
"reviewTitle": "-kTeaG_reviewTitle",
|
|
39207
|
+
"conflictActions": "-kTeaG_conflictActions",
|
|
39208
|
+
"panelAction": "-kTeaG_panelAction",
|
|
39209
|
+
"editorPane": "-kTeaG_editorPane",
|
|
39183
39210
|
"legacyWarning": "-kTeaG_legacyWarning",
|
|
39184
|
-
"reviewCard": "-kTeaG_reviewCard",
|
|
39185
|
-
"reviewDetails": "-kTeaG_reviewDetails",
|
|
39186
|
-
"header": "-kTeaG_header",
|
|
39187
|
-
"execute": "-kTeaG_execute",
|
|
39188
|
-
"commentAction": "-kTeaG_commentAction",
|
|
39189
|
-
"review": "-kTeaG_review",
|
|
39190
|
-
"tabBadge": "-kTeaG_tabBadge",
|
|
39191
|
-
"paneActions": "-kTeaG_paneActions",
|
|
39192
|
-
"resizer": "-kTeaG_resizer",
|
|
39193
|
-
"requirementMenu": "-kTeaG_requirementMenu",
|
|
39194
|
-
"summaryInput": "-kTeaG_summaryInput",
|
|
39195
|
-
"editorTitle": "-kTeaG_editorTitle",
|
|
39196
|
-
"cardActions": "-kTeaG_cardActions",
|
|
39197
39211
|
"chatToggle": "-kTeaG_chatToggle",
|
|
39198
|
-
"
|
|
39199
|
-
"
|
|
39200
|
-
"
|
|
39201
|
-
"emptyMain": "-kTeaG_emptyMain",
|
|
39202
|
-
"tabbar": "-kTeaG_tabbar",
|
|
39203
|
-
"documents": "-kTeaG_documents",
|
|
39204
|
-
"editorBody": "-kTeaG_editorBody",
|
|
39212
|
+
"commentAction": "-kTeaG_commentAction",
|
|
39213
|
+
"conflictColumns": "-kTeaG_conflictColumns",
|
|
39214
|
+
"requirementRow": "-kTeaG_requirementRow",
|
|
39205
39215
|
"entryActive": "-kTeaG_entryActive",
|
|
39206
|
-
"resizerHidden": "-kTeaG_resizerHidden",
|
|
39207
|
-
"saveButton": "-kTeaG_saveButton",
|
|
39208
|
-
"grid": "-kTeaG_grid",
|
|
39209
|
-
"richEditor": "-kTeaG_richEditor",
|
|
39210
|
-
"run": "-kTeaG_run",
|
|
39211
|
-
"questionField": "-kTeaG_questionField",
|
|
39212
|
-
"conflictModal": "-kTeaG_conflictModal",
|
|
39213
|
-
"conflictDiffs": "-kTeaG_conflictDiffs",
|
|
39214
|
-
"preview": "-kTeaG_preview",
|
|
39215
39216
|
"mobileCollab": "-kTeaG_mobileCollab",
|
|
39216
|
-
"
|
|
39217
|
-
"
|
|
39217
|
+
"decisionForm": "-kTeaG_decisionForm",
|
|
39218
|
+
"tabScroller": "-kTeaG_tabScroller",
|
|
39219
|
+
"iconButton": "-kTeaG_iconButton",
|
|
39218
39220
|
"checkBlocked": "-kTeaG_checkBlocked",
|
|
39219
|
-
"
|
|
39220
|
-
"userMessage": "-kTeaG_userMessage",
|
|
39221
|
-
"humanResponse": "-kTeaG_humanResponse",
|
|
39222
|
-
"badges": "-kTeaG_badges",
|
|
39223
|
-
"reviewField": "-kTeaG_reviewField",
|
|
39224
|
-
"patchDetails": "-kTeaG_patchDetails",
|
|
39225
|
-
"checkIcon": "-kTeaG_checkIcon",
|
|
39226
|
-
"dangerButton": "-kTeaG_dangerButton",
|
|
39227
|
-
"editorPane": "-kTeaG_editorPane",
|
|
39228
|
-
"aiConversation": "-kTeaG_aiConversation",
|
|
39229
|
-
"collapseChat": "-kTeaG_collapseChat",
|
|
39230
|
-
"identity": "-kTeaG_identity",
|
|
39231
|
-
"chatMessages": "-kTeaG_chatMessages",
|
|
39232
|
-
"versionCompare": "-kTeaG_versionCompare",
|
|
39221
|
+
"tabbar": "-kTeaG_tabbar",
|
|
39233
39222
|
"conflictDialog": "-kTeaG_conflictDialog",
|
|
39223
|
+
"conflictModal": "-kTeaG_conflictModal",
|
|
39234
39224
|
"modal": "-kTeaG_modal",
|
|
39225
|
+
"header": "-kTeaG_header",
|
|
39226
|
+
"footer": "-kTeaG_footer",
|
|
39227
|
+
"mobileViewSwitch": "-kTeaG_mobileViewSwitch",
|
|
39228
|
+
"aiMessage": "-kTeaG_aiMessage",
|
|
39229
|
+
"paneActions": "-kTeaG_paneActions",
|
|
39230
|
+
"patchAccept": "-kTeaG_patchAccept",
|
|
39231
|
+
"badges": "-kTeaG_badges",
|
|
39232
|
+
"execute": "-kTeaG_execute",
|
|
39233
|
+
"compareHead": "-kTeaG_compareHead",
|
|
39235
39234
|
"compareColumns": "-kTeaG_compareColumns",
|
|
39236
|
-
"
|
|
39237
|
-
"
|
|
39238
|
-
"
|
|
39239
|
-
"
|
|
39240
|
-
"
|
|
39241
|
-
"
|
|
39242
|
-
"
|
|
39243
|
-
"
|
|
39244
|
-
"
|
|
39235
|
+
"cardActions": "-kTeaG_cardActions",
|
|
39236
|
+
"noticeHidden": "-kTeaG_noticeHidden",
|
|
39237
|
+
"selectedDoc": "-kTeaG_selectedDoc",
|
|
39238
|
+
"readyHead": "-kTeaG_readyHead",
|
|
39239
|
+
"endedReview": "-kTeaG_endedReview",
|
|
39240
|
+
"preview": "-kTeaG_preview",
|
|
39241
|
+
"entry": "-kTeaG_entry",
|
|
39242
|
+
"reply": "-kTeaG_reply",
|
|
39243
|
+
"editorTitle": "-kTeaG_editorTitle",
|
|
39245
39244
|
"checkPassed": "-kTeaG_checkPassed",
|
|
39246
|
-
"
|
|
39247
|
-
"
|
|
39248
|
-
"runHistory": "-kTeaG_runHistory",
|
|
39245
|
+
"selectionPrompt": "-kTeaG_selectionPrompt",
|
|
39246
|
+
"dangerText": "-kTeaG_dangerText",
|
|
39249
39247
|
"threadList": "-kTeaG_threadList",
|
|
39248
|
+
"editorMeta": "-kTeaG_editorMeta",
|
|
39249
|
+
"unsaved": "-kTeaG_unsaved",
|
|
39250
|
+
"pendingReview": "-kTeaG_pendingReview",
|
|
39251
|
+
"toolbar": "-kTeaG_toolbar",
|
|
39252
|
+
"resizer": "-kTeaG_resizer",
|
|
39253
|
+
"dangerButton": "-kTeaG_dangerButton",
|
|
39250
39254
|
"empty": "-kTeaG_empty",
|
|
39251
|
-
"
|
|
39252
|
-
"
|
|
39253
|
-
"
|
|
39254
|
-
"
|
|
39255
|
-
"
|
|
39256
|
-
"
|
|
39257
|
-
"
|
|
39258
|
-
"
|
|
39259
|
-
"
|
|
39260
|
-
"
|
|
39261
|
-
"
|
|
39262
|
-
"
|
|
39255
|
+
"collapseRight": "-kTeaG_collapseRight",
|
|
39256
|
+
"reviewCard": "-kTeaG_reviewCard",
|
|
39257
|
+
"reviewField": "-kTeaG_reviewField",
|
|
39258
|
+
"questionField": "-kTeaG_questionField",
|
|
39259
|
+
"patchPreview": "-kTeaG_patchPreview",
|
|
39260
|
+
"downstreamReturn": "-kTeaG_downstreamReturn",
|
|
39261
|
+
"itemRow": "-kTeaG_itemRow",
|
|
39262
|
+
"missingOptions": "-kTeaG_missingOptions",
|
|
39263
|
+
"reviewDetails": "-kTeaG_reviewDetails",
|
|
39264
|
+
"checkIcon": "-kTeaG_checkIcon",
|
|
39265
|
+
"versionRow": "-kTeaG_versionRow",
|
|
39266
|
+
"conflictHeader": "-kTeaG_conflictHeader",
|
|
39267
|
+
"saveButton": "-kTeaG_saveButton",
|
|
39268
|
+
"userMessage": "-kTeaG_userMessage",
|
|
39269
|
+
"conflictDiffs": "-kTeaG_conflictDiffs",
|
|
39270
|
+
"chatComposer": "-kTeaG_chatComposer",
|
|
39271
|
+
"rowMenuButton": "-kTeaG_rowMenuButton",
|
|
39272
|
+
"newThread": "-kTeaG_newThread",
|
|
39273
|
+
"reviewCardBody": "-kTeaG_reviewCardBody",
|
|
39274
|
+
"evidence": "-kTeaG_evidence"
|
|
39263
39275
|
};
|
|
39264
39276
|
//#endregion
|
|
39265
39277
|
//#region src/client/SpecWorkbench.tsx
|
|
@@ -39282,7 +39294,7 @@ window.__ModuleLoader__.load({
|
|
|
39282
39294
|
] })] });
|
|
39283
39295
|
function newParticipant() {
|
|
39284
39296
|
return {
|
|
39285
|
-
participantId:
|
|
39297
|
+
participantId: browserUuid(),
|
|
39286
39298
|
nickname: "",
|
|
39287
39299
|
role: "product",
|
|
39288
39300
|
kind: "human"
|
|
@@ -39306,6 +39318,16 @@ window.__ModuleLoader__.load({
|
|
|
39306
39318
|
ready: "Ready"
|
|
39307
39319
|
}[stage];
|
|
39308
39320
|
}
|
|
39321
|
+
function currentPendingActions(requirement) {
|
|
39322
|
+
const currentSourceIds = /* @__PURE__ */ new Set([
|
|
39323
|
+
...requirement.reviewItems.filter((item) => item.commit === requirement.currentCommit).map((item) => item.id),
|
|
39324
|
+
...requirement.comments.filter((item) => item.commit === requirement.currentCommit).map((item) => item.id),
|
|
39325
|
+
...requirement.patches.filter((item) => item.baseCommit === requirement.currentCommit).map((item) => item.id),
|
|
39326
|
+
...requirement.decisions.filter((item) => item.commit === requirement.currentCommit).map((item) => item.id),
|
|
39327
|
+
...requirement.confirmations.filter((item) => item.commit === requirement.currentCommit).map((item) => item.id)
|
|
39328
|
+
]);
|
|
39329
|
+
return requirement.actionItems.filter((item) => item.status === "pending" && currentSourceIds.has(item.sourceId));
|
|
39330
|
+
}
|
|
39309
39331
|
const tabLabel = {
|
|
39310
39332
|
review: "审核问题",
|
|
39311
39333
|
discussion: "协作讨论",
|
|
@@ -39630,7 +39652,11 @@ window.__ModuleLoader__.load({
|
|
|
39630
39652
|
" · ",
|
|
39631
39653
|
selected.currentCommit.slice(0, 10),
|
|
39632
39654
|
" · ",
|
|
39633
|
-
selected.reviewItems.filter((item) => item.
|
|
39655
|
+
selected.reviewItems.filter((item) => item.commit === selected.currentCommit && item.severity === "blocking" && ![
|
|
39656
|
+
"resolved",
|
|
39657
|
+
"non-blocking-verify",
|
|
39658
|
+
"joint-review"
|
|
39659
|
+
].includes(item.status)).length,
|
|
39634
39660
|
" 阻塞"
|
|
39635
39661
|
] })]
|
|
39636
39662
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -39717,7 +39743,7 @@ window.__ModuleLoader__.load({
|
|
|
39717
39743
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
39718
39744
|
className: mobilePane === "collab" ? workbench_module_css_default.activeMode : "",
|
|
39719
39745
|
onClick: () => setMobilePane("collab"),
|
|
39720
|
-
children: ["协作处理", selected ? ` · ${selected
|
|
39746
|
+
children: ["协作处理", selected ? ` · ${currentPendingActions(selected).length}` : ""]
|
|
39721
39747
|
})]
|
|
39722
39748
|
}),
|
|
39723
39749
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -39769,7 +39795,7 @@ window.__ModuleLoader__.load({
|
|
|
39769
39795
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
39770
39796
|
className: `${workbench_module_css_default.documentButton} ${item.id === selected?.id ? workbench_module_css_default.selectedDoc : ""}`,
|
|
39771
39797
|
onClick: () => setSelectedId(item.id),
|
|
39772
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: item.archivedAt ? `归档于 ${new Date(item.archivedAt).toLocaleDateString()}` : `${stageLabel(item.stage)} · ${item.
|
|
39798
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: item.archivedAt ? `归档于 ${new Date(item.archivedAt).toLocaleDateString()}` : `${stageLabel(item.stage)} · ${currentPendingActions(item).filter((task) => task.blocking).length} 待办` })]
|
|
39773
39799
|
}),
|
|
39774
39800
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
39775
39801
|
className: workbench_module_css_default.rowMenuButton,
|
|
@@ -40006,7 +40032,7 @@ window.__ModuleLoader__.load({
|
|
|
40006
40032
|
}),
|
|
40007
40033
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
40008
40034
|
className: workbench_module_css_default.footer,
|
|
40009
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Git + Markdown 正式版本 · AI 只提议不确认" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selected ? `${selected
|
|
40035
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Git + Markdown 正式版本 · AI 只提议不确认" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selected ? `${currentPendingActions(selected).length} 当前版本事项 · ${selected.aiRuns.at(-1)?.status ?? "无 AI 任务"}` : "严格止于 Ready Spec" })]
|
|
40010
40036
|
}),
|
|
40011
40037
|
identityOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IdentityDialog, {
|
|
40012
40038
|
value: participant,
|
|
@@ -41192,6 +41218,23 @@ window.__ModuleLoader__.load({
|
|
|
41192
41218
|
});
|
|
41193
41219
|
}
|
|
41194
41220
|
//#endregion
|
|
41221
|
+
//#region src/client/sidebar-anchor.ts
|
|
41222
|
+
function exactTextButton(document, text) {
|
|
41223
|
+
return [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === text);
|
|
41224
|
+
}
|
|
41225
|
+
function findSidebarAnchor(document) {
|
|
41226
|
+
const skillCenter = document.querySelector("button[aria-label=\"技能中心\"]") ?? exactTextButton(document, "技能中心");
|
|
41227
|
+
if (skillCenter !== void 0 && skillCenter !== null) return {
|
|
41228
|
+
element: skillCenter,
|
|
41229
|
+
placement: "after"
|
|
41230
|
+
};
|
|
41231
|
+
const settings = document.querySelector("button[aria-label=\"设置\"]") ?? exactTextButton(document, "设置");
|
|
41232
|
+
if (settings !== void 0 && settings !== null) return {
|
|
41233
|
+
element: settings,
|
|
41234
|
+
placement: "before"
|
|
41235
|
+
};
|
|
41236
|
+
}
|
|
41237
|
+
//#endregion
|
|
41195
41238
|
//#region src/client/mount.tsx
|
|
41196
41239
|
const ACTIVE = "data-dsh-spec-collab-active";
|
|
41197
41240
|
const VIEW = "[data-dsh-spec-collab-view]";
|
|
@@ -41249,17 +41292,17 @@ window.__ModuleLoader__.load({
|
|
|
41249
41292
|
};
|
|
41250
41293
|
const ensure = () => {
|
|
41251
41294
|
if (row?.isConnected) return;
|
|
41252
|
-
const
|
|
41253
|
-
if (
|
|
41295
|
+
const anchor = findSidebarAnchor(document);
|
|
41296
|
+
if (anchor === void 0) return;
|
|
41254
41297
|
row = document.createElement("button");
|
|
41255
41298
|
row.type = "button";
|
|
41256
41299
|
row.dataset.dshSpecCollabEntry = "";
|
|
41257
|
-
row.className = `${
|
|
41300
|
+
row.className = `${anchor.element.className} ${workbench_module_css_default.entry}`;
|
|
41258
41301
|
row.title = "需求讨论";
|
|
41259
41302
|
row.setAttribute("aria-label", "需求讨论");
|
|
41260
41303
|
row.innerHTML = "<span aria-hidden=\"true\">▤</span><span>需求讨论</span>";
|
|
41261
41304
|
row.addEventListener("click", toggle);
|
|
41262
|
-
|
|
41305
|
+
anchor.element[anchor.placement](row);
|
|
41263
41306
|
};
|
|
41264
41307
|
const observer = new MutationObserver(ensure);
|
|
41265
41308
|
observer.observe(document.body, {
|
package/lib/index.js
CHANGED
|
@@ -571,7 +571,7 @@ var CollaborationEngine = class {
|
|
|
571
571
|
body: action.body.trim(),
|
|
572
572
|
createdAt: now
|
|
573
573
|
};
|
|
574
|
-
item.status = action.disposition === "joint-review" ? "joint-review" : action.disposition === "to-verify" ? "non-blocking-verify" : "answered";
|
|
574
|
+
item.status = action.disposition === "joint-review" ? "joint-review" : action.disposition === "to-verify" ? "non-blocking-verify" : action.disposition === "accept" ? "resolved" : "answered";
|
|
575
575
|
item.updatedAt = now;
|
|
576
576
|
record.actionItems.filter((task) => task.sourceId === item.id && task.status === "pending").forEach((task) => {
|
|
577
577
|
task.status = "handled";
|
|
@@ -915,7 +915,7 @@ function hasVersionConfirmation(record, role) {
|
|
|
915
915
|
}
|
|
916
916
|
function advance(record, participant) {
|
|
917
917
|
if (record.stage === "product-review") {
|
|
918
|
-
if (record.reviewItems.some((item) => item.severity === "blocking" && ![
|
|
918
|
+
if (record.reviewItems.some((item) => item.commit === record.currentCommit && item.severity === "blocking" && ![
|
|
919
919
|
"resolved",
|
|
920
920
|
"non-blocking-verify",
|
|
921
921
|
"joint-review"
|
|
@@ -942,7 +942,7 @@ function sections(markdown) {
|
|
|
942
942
|
}
|
|
943
943
|
function acceptance(markdown) {
|
|
944
944
|
const result = /* @__PURE__ */ new Map();
|
|
945
|
-
for (const match of markdown.matchAll(/\*\*(AC-[A-Za-z0-9-]+)
|
|
945
|
+
for (const match of markdown.matchAll(/\*\*(AC-[A-Za-z0-9-]+)(?:\s+[^*]+)?\*\*\s*[::]\s*(.+)/g)) result.set(match[1], match[2].trim());
|
|
946
946
|
return result;
|
|
947
947
|
}
|
|
948
948
|
function changedScopes(before, after) {
|
|
@@ -995,7 +995,7 @@ function readiness(markdown, record) {
|
|
|
995
995
|
const value = sectionMap.get(name)?.replace(/<!--.*?-->/gs, "").trim() ?? "";
|
|
996
996
|
return value.length >= 12 && !/待澄清|待补充|TODO/i.test(value);
|
|
997
997
|
};
|
|
998
|
-
const blockers = record.reviewItems.filter((item) => item.severity === "blocking" && !["resolved", "non-blocking-verify"].includes(item.status)).map((item) => item.statement);
|
|
998
|
+
const blockers = record.reviewItems.filter((item) => item.commit === record.currentCommit && item.severity === "blocking" && !["resolved", "non-blocking-verify"].includes(item.status)).map((item) => item.statement);
|
|
999
999
|
return [
|
|
1000
1000
|
{
|
|
1001
1001
|
key: "goal",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"SpecWorkbench.d.ts","sourceRoot":"","sources":["../../../src/client/SpecWorkbench.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAiCvC,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,+BAyItD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/client/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/client/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAEtO,MAAM,WAAW,WAAW;IAAG,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,mBAAmB,EAAE,CAAC;IAAC,YAAY,EAAE,eAAe,EAAE,CAAA;CAAE;AACvH,qBAAa,OAAO;IACZ,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IAC7B,gBAAgB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAC1D,OAAO,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAClE,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAC3E,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpH,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACrF,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;CACzC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface BrowserCrypto {
|
|
2
|
+
randomUUID?: () => string;
|
|
3
|
+
getRandomValues?: <T extends ArrayBufferView | null>(array: T) => T;
|
|
4
|
+
}
|
|
5
|
+
export declare function browserUuid(source?: BrowserCrypto | undefined): string;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=browser-uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-uuid.d.ts","sourceRoot":"","sources":["../../../src/client/browser-uuid.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,MAAM,MAAM,CAAA;IACzB,eAAe,CAAC,EAAE,CAAC,CAAC,SAAS,eAAe,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;CACpE;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,aAAa,GAAG,SAA6B,GAAG,MAAM,CASzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/client/mount.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/client/mount.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AASvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,IAAI,CAoBvD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAuC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-anchor.d.ts","sourceRoot":"","sources":["../../../src/client/sidebar-anchor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAA;CAC9B;AAMD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS,CAM/E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-spec-collab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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,6 +46,7 @@
|
|
|
46
46
|
"files": [
|
|
47
47
|
"lib",
|
|
48
48
|
"src",
|
|
49
|
+
"docs",
|
|
49
50
|
"cordis.patch.yml",
|
|
50
51
|
"README.md"
|
|
51
52
|
],
|
|
@@ -66,13 +67,13 @@
|
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
69
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
70
|
-
"@deepseek-ai/dsh-client-runtime": "^0.1.
|
|
71
|
-
"@deepseek-ai/dsh-host-apiproxy": "^0.1.
|
|
72
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.
|
|
73
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
74
|
-
"@deepseek-ai/dsh-system-prompt": "^0.1.
|
|
75
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
70
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.1-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-host-apiproxy": "^0.1.1-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-tools": "^0.1.1-rc.1",
|
|
76
77
|
"@types/markdown-it": "^14.1.2",
|
|
77
78
|
"@types/node": "^22.20.0",
|
|
78
79
|
"@types/react": "~18.3.1",
|
|
@@ -5,6 +5,7 @@ import '@toast-ui/editor/dist/i18n/zh-cn'
|
|
|
5
5
|
import { InputRule, inputRules } from 'prosemirror-inputrules'
|
|
6
6
|
import type { CollaborationAction, CommentResolution, MyActionItem, ParticipantRole, ParticipantSnapshot, RequirementStage, RequirementVersion, RequirementView, ReviewKind, ReviewWorkspaceSummary, SaveConflict } from '../protocol.ts'
|
|
7
7
|
import type { SpecApi } from './api.ts'
|
|
8
|
+
import { browserUuid } from './browser-uuid.ts'
|
|
8
9
|
import css from './workbench.module.css'
|
|
9
10
|
|
|
10
11
|
const md = new MarkdownIt({ html: false, linkify: true })
|
|
@@ -21,9 +22,19 @@ const markdownShortcutsPlugin = () => ({ wysiwygPlugins: [() => inputRules({ rul
|
|
|
21
22
|
] })] })
|
|
22
23
|
type SideTab = 'review' | 'discussion' | 'patches' | 'decisions' | 'items' | 'versions' | 'ready'
|
|
23
24
|
type CommentAnchor = { quote: string; prefix: string; suffix: string; heading?: string }
|
|
24
|
-
function newParticipant(): ParticipantSnapshot { return { participantId:
|
|
25
|
+
function newParticipant(): ParticipantSnapshot { return { participantId: browserUuid(), nickname: '', role: 'product', kind: 'human' } }
|
|
25
26
|
function loadParticipant(): ParticipantSnapshot { try { const value = JSON.parse(localStorage.getItem('dsh-spec-collab.participant') ?? '') as ParticipantSnapshot; if (value.participantId) return { ...value, kind: 'human' } } catch {} return newParticipant() }
|
|
26
27
|
function stageLabel(stage: RequirementStage): string { return ({ 'product-review': '产品审核', 'product-confirmation': '产品确认', 'joint-review': '产研共审', ready: 'Ready' })[stage] }
|
|
28
|
+
function currentPendingActions(requirement: RequirementView): RequirementView['actionItems'] {
|
|
29
|
+
const currentSourceIds = new Set([
|
|
30
|
+
...requirement.reviewItems.filter(item => item.commit === requirement.currentCommit).map(item => item.id),
|
|
31
|
+
...requirement.comments.filter(item => item.commit === requirement.currentCommit).map(item => item.id),
|
|
32
|
+
...requirement.patches.filter(item => item.baseCommit === requirement.currentCommit).map(item => item.id),
|
|
33
|
+
...requirement.decisions.filter(item => item.commit === requirement.currentCommit).map(item => item.id),
|
|
34
|
+
...requirement.confirmations.filter(item => item.commit === requirement.currentCommit).map(item => item.id),
|
|
35
|
+
])
|
|
36
|
+
return requirement.actionItems.filter(item => item.status === 'pending' && currentSourceIds.has(item.sourceId))
|
|
37
|
+
}
|
|
27
38
|
const tabLabel: Record<SideTab, string> = { review: '审核问题', discussion: '协作讨论', patches: '修改建议', decisions: '确认决策', items: '我的事项', versions: '版本记录', ready: '完成检查' }
|
|
28
39
|
|
|
29
40
|
export function SpecWorkbench({ api }: { api: SpecApi }) {
|
|
@@ -135,7 +146,7 @@ export function SpecWorkbench({ api }: { api: SpecApi }) {
|
|
|
135
146
|
|
|
136
147
|
return <div className={css.workbench}>
|
|
137
148
|
<header className={css.header}>
|
|
138
|
-
<div className={css.titleBlock}><strong>{selected?.title ?? 'AI 需求澄清与 Spec 共创'}</strong>{selected && <span>{stageLabel(selected.stage)} · {selected.workspaceId ? reviewWorkspaces.find(workspace => workspace.workspaceId === selected.workspaceId)?.title ?? selected.workspaceId : '未绑定工作区'} · {selected.currentCommit.slice(0, 10)} · {selected.reviewItems.filter(item => item.severity === 'blocking' &&
|
|
149
|
+
<div className={css.titleBlock}><strong>{selected?.title ?? 'AI 需求澄清与 Spec 共创'}</strong>{selected && <span>{stageLabel(selected.stage)} · {selected.workspaceId ? reviewWorkspaces.find(workspace => workspace.workspaceId === selected.workspaceId)?.title ?? selected.workspaceId : '未绑定工作区'} · {selected.currentCommit.slice(0, 10)} · {selected.reviewItems.filter(item => item.commit === selected.currentCommit && item.severity === 'blocking' && !['resolved', 'non-blocking-verify', 'joint-review'].includes(item.status)).length} 阻塞</span>}</div>
|
|
139
150
|
<div className={css.headerActions}>
|
|
140
151
|
{selected && !selected.workspaceId && <button onClick={() => { setBindWorkspaceOpen(true); void api.reviewWorkspaces().then(setReviewWorkspaces, error => setNotice(error instanceof Error ? error.message : String(error))) }}>绑定工作区</button>}
|
|
141
152
|
{selected?.stage === 'product-review' && <><button disabled={productFirstRunning || !selected.workspaceId} title={!selected.workspaceId ? '请先绑定工作区' : productFirstRunning ? '初审进行中' : '启动智能初审'} onClick={() => void requestReview('product-first')}>智能初审</button><button disabled={!selected.workspaceId} onClick={() => void requestReview('product-second')}>智能复审</button><button className={css.execute} onClick={() => void advance()}>进入产品确认</button></>}
|
|
@@ -145,9 +156,9 @@ export function SpecWorkbench({ api }: { api: SpecApi }) {
|
|
|
145
156
|
</div>
|
|
146
157
|
</header>
|
|
147
158
|
<div className={notice ? css.notice : css.noticeHidden}>{notice}<button aria-label="关闭" onClick={() => setNotice('')}>×</button></div>
|
|
148
|
-
<div className={css.mobileViewSwitch}><button className={mobilePane === 'spec' ? css.activeMode : ''} onClick={() => setMobilePane('spec')}>规范正文</button><button className={mobilePane === 'collab' ? css.activeMode : ''} onClick={() => setMobilePane('collab')}>协作处理{selected ? ` · ${selected
|
|
159
|
+
<div className={css.mobileViewSwitch}><button className={mobilePane === 'spec' ? css.activeMode : ''} onClick={() => setMobilePane('spec')}>规范正文</button><button className={mobilePane === 'collab' ? css.activeMode : ''} onClick={() => setMobilePane('collab')}>协作处理{selected ? ` · ${currentPendingActions(selected).length}` : ''}</button></div>
|
|
149
160
|
<div className={`${css.grid} ${mobilePane === 'spec' ? css.mobileSpec : css.mobileCollab}`} style={{ '--documents-width': documentsOpen ? `${documentsWidth}px` : '0px', '--documents-handle': documentsOpen ? '6px' : '0px', '--review-width': reviewOpen ? `${reviewWidth}px` : '0px', '--review-handle': reviewOpen ? '6px' : '0px' } as CSSProperties}>
|
|
150
|
-
<aside className={`${css.documents} ${documentsOpen ? '' : css.paneClosed}`}><div className={css.paneHead}><strong>{showArchived ? '已归档需求' : '需求'}</strong><div className={css.paneActions}><button onClick={() => { setShowArchived(value => !value); setSelectedId(undefined); setManageMenuId(undefined) }}>{showArchived ? '进行中' : '已归档'}</button>{!showArchived && <button title="输入原始需求" onClick={() => { setCreateOpen(true); void api.reviewWorkspaces().then(setReviewWorkspaces, error => setNotice(error instanceof Error ? error.message : String(error))) }}>+</button>}<button className={css.iconButton} aria-label="收起需求栏" title="收起需求栏" onClick={() => setDocumentsOpen(false)}>‹</button></div></div><nav>{visibleRequirements.map(item => <div className={css.requirementRow} key={item.id}><button className={`${css.documentButton} ${item.id === selected?.id ? css.selectedDoc : ''}`} onClick={() => setSelectedId(item.id)}><span>{item.title}</span><small>{item.archivedAt ? `归档于 ${new Date(item.archivedAt).toLocaleDateString()}` : `${stageLabel(item.stage)} · ${item.
|
|
161
|
+
<aside className={`${css.documents} ${documentsOpen ? '' : css.paneClosed}`}><div className={css.paneHead}><strong>{showArchived ? '已归档需求' : '需求'}</strong><div className={css.paneActions}><button onClick={() => { setShowArchived(value => !value); setSelectedId(undefined); setManageMenuId(undefined) }}>{showArchived ? '进行中' : '已归档'}</button>{!showArchived && <button title="输入原始需求" onClick={() => { setCreateOpen(true); void api.reviewWorkspaces().then(setReviewWorkspaces, error => setNotice(error instanceof Error ? error.message : String(error))) }}>+</button>}<button className={css.iconButton} aria-label="收起需求栏" title="收起需求栏" onClick={() => setDocumentsOpen(false)}>‹</button></div></div><nav>{visibleRequirements.map(item => <div className={css.requirementRow} key={item.id}><button className={`${css.documentButton} ${item.id === selected?.id ? css.selectedDoc : ''}`} onClick={() => setSelectedId(item.id)}><span>{item.title}</span><small>{item.archivedAt ? `归档于 ${new Date(item.archivedAt).toLocaleDateString()}` : `${stageLabel(item.stage)} · ${currentPendingActions(item).filter(task => task.blocking).length} 待办`}</small></button><button className={css.rowMenuButton} aria-label={`${item.title} 更多操作`} title="更多操作" onClick={() => { setSelectedId(item.id); setManageMenuId(current => current === item.id ? undefined : item.id) }}>…</button>{manageMenuId === item.id && <div className={css.requirementMenu}><button onClick={() => { setManageTargetId(item.id); setRenameTitle(item.title); setRenameOpen(true); setManageMenuId(undefined) }}>重命名</button><button onClick={() => void archiveRequirement(item)}>{item.archivedAt ? '取消归档' : '归档需求'}</button><button className={css.dangerText} onClick={() => { setManageTargetId(item.id); setDeleteOpen(true); setManageMenuId(undefined) }}>删除需求</button></div>}</div>)}</nav>{visibleRequirements.length === 0 && <div className={css.empty}>{showArchived ? '暂无已归档需求' : '暂无进行中的需求'}</div>}</aside>
|
|
151
162
|
<div className={`${css.resizer} ${documentsOpen ? '' : css.resizerHidden}`} role="separator" aria-label="调整需求栏宽度" aria-orientation="vertical" onPointerDown={event => resizePane('documents', event)}/>
|
|
152
163
|
<main className={css.editorPane}>
|
|
153
164
|
<div className={css.toolbar}><div className={css.editorTitle}>{!documentsOpen && <button className={css.iconButton} aria-label="展开需求栏" title="展开需求栏" onClick={() => setDocumentsOpen(true)}>‹</button>}<strong>规范正文</strong></div><div><span className={draft !== selected?.version.markdown ? css.unsaved : css.editorMeta}>{draft !== selected?.version.markdown ? '有未保存修改' : '已保存'} · {draft.split('\n').length} 行</span><input className={css.summaryInput} required aria-label="本次修改说明(必填)" value={summary} onChange={event => setSummary(event.target.value)} placeholder="本次修改说明(必填)"/><button className={css.saveButton} disabled={busy || !selected || draft === selected.version.markdown || !summary.trim()} onClick={() => void save()}>保存新版本</button>{!reviewOpen && <button className={css.iconButton} aria-label="展开协作栏" title="展开协作栏" onClick={() => setReviewOpen(true)}>›</button>}</div></div>
|
|
@@ -160,7 +171,7 @@ export function SpecWorkbench({ api }: { api: SpecApi }) {
|
|
|
160
171
|
<div className={css.threadList}>{selected && sideTab === 'review' && <ReviewPanel requirement={selected} participant={participant} act={act} api={api}/>} {selected && sideTab === 'discussion' && <DiscussionPanel requirement={selected} selection={selection} text={commentText} setText={setCommentText} cancel={() => setSelection(undefined)} submit={addComment} participant={participant} act={act} api={api}/>} {selected && sideTab === 'patches' && <PatchPanel requirement={selected} act={act}/>} {selected && sideTab === 'decisions' && <DecisionPanel requirement={selected} act={act}/>} {selected && sideTab === 'items' && <MyItemsPanel items={currentMyItems} open={item => { setSideTab(item.target.tab); setMobilePane('collab'); window.setTimeout(() => document.getElementById(`spec-object-${item.target.objectId}`)?.scrollIntoView({ block: 'center' }), 100) }}/>} {selected && sideTab === 'versions' && <VersionPanel requirement={selected} api={api}/>} {selected && sideTab === 'ready' && <ReadyPanel requirement={selected} act={act}/>}</div>
|
|
161
172
|
</aside>
|
|
162
173
|
</div>
|
|
163
|
-
<footer className={css.footer}><span>Git + Markdown 正式版本 · AI 只提议不确认</span><span>{selected ? `${selected
|
|
174
|
+
<footer className={css.footer}><span>Git + Markdown 正式版本 · AI 只提议不确认</span><span>{selected ? `${currentPendingActions(selected).length} 当前版本事项 · ${selected.aiRuns.at(-1)?.status ?? '无 AI 任务'}` : '严格止于 Ready Spec'}</span></footer>
|
|
164
175
|
{identityOpen && <IdentityDialog value={participant} {...(boundRole === undefined ? {} : { boundRole })} onChange={setParticipant} close={() => setIdentityOpen(false)}/>} {createOpen && <CreateDialog value={createForm} setValue={setCreateForm} workspaces={reviewWorkspaces} close={() => setCreateOpen(false)} submit={() => void create()} busy={busy}/>} {bindWorkspaceOpen && selected && <WorkspaceDialog value={bindWorkspaceId} setValue={setBindWorkspaceId} workspaces={reviewWorkspaces} close={() => { setBindWorkspaceOpen(false); setBindWorkspaceId('') }} submit={() => void bindWorkspace()} busy={busy}/>} {renameOpen && <RenameDialog title={renameTitle} setTitle={setRenameTitle} close={() => { setRenameOpen(false); setManageTargetId(undefined) }} submit={() => void renameRequirement()} busy={busy}/>} {deleteOpen && manageTarget && <DeleteDialog title={manageTarget.title} close={() => { setDeleteOpen(false); setManageTargetId(undefined) }} submit={() => void deleteRequirement()} busy={busy}/>} {saveConflict && <ConflictDialog conflict={saveConflict} value={mergeDraft} setValue={setMergeDraft} close={() => setSaveConflict(undefined)} busy={busy} submit={() => void act(actor => ({ kind: 'version.save', participant: actor, requirementId: saveConflict.requirementId, baseCommit: saveConflict.currentCommit, markdown: mergeDraft, summary })).then(ok => { if (ok) { setDraft(mergeDraft); setSummary(''); setSaveConflict(undefined); setNotice('冲突已合并并创建新的 Git commit') } })}/>}
|
|
165
176
|
</div>
|
|
166
177
|
}
|
package/src/client/api.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { API_PREFIX, type ActionEnvelope, type ActionResult, type CollaborationAction, type MyActionItem, type ParticipantSnapshot, type RequirementVersion, type RequirementView, type ReviewWorkspaceSummary } from '../protocol.ts'
|
|
2
|
+
import { browserUuid } from './browser-uuid.ts'
|
|
2
3
|
export interface ClientState { revision: number; participants: ParticipantSnapshot[]; requirements: RequirementView[] }
|
|
3
4
|
export class SpecApi {
|
|
4
5
|
async state(): Promise<ClientState> { const response = await fetch(`${API_PREFIX}/state`, { headers: { accept: 'application/json' } }); if (!response.ok) throw new Error(`state request failed (${response.status})`); const state = await response.json() as Partial<ClientState>; return { revision: state.revision ?? 0, participants: state.participants ?? [], requirements: state.requirements ?? [] } }
|
|
5
6
|
async reviewWorkspaces(): Promise<ReviewWorkspaceSummary[]> { const response = await fetch(`${API_PREFIX}/review-workspaces`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; workspaces?: ReviewWorkspaceSummary[]; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载需求工作区失败'); return result.workspaces ?? [] }
|
|
6
|
-
async action(action: CollaborationAction): Promise<ActionResult> { const envelope: ActionEnvelope = { requestId:
|
|
7
|
+
async action(action: CollaborationAction): Promise<ActionResult> { const envelope: ActionEnvelope = { requestId: browserUuid(), action }; const response = await fetch(`${API_PREFIX}/action`, { method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json' }, body: JSON.stringify(envelope) }); return response.json() as Promise<ActionResult> }
|
|
7
8
|
async myItems(participant: ParticipantSnapshot): Promise<MyActionItem[]> { const query = new URLSearchParams({ participantId: participant.participantId, role: participant.role }); const response = await fetch(`${API_PREFIX}/my-items?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; items?: MyActionItem[]; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载我的事项失败'); return result.items ?? [] }
|
|
8
9
|
async version(requirementId: string, commit: string): Promise<RequirementVersion> { const query = new URLSearchParams({ requirementId, commit }); const response = await fetch(`${API_PREFIX}/version?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; version?: RequirementVersion; error?: string }; if (!response.ok || !result.ok || !result.version) throw new Error(result.error ?? '加载历史版本失败'); return result.version }
|
|
9
10
|
async conversation(requirementId: string, sessionId: string): Promise<Array<{ role: 'user' | 'assistant'; text: string }>> { const query = new URLSearchParams({ requirementId, sessionId }); const response = await fetch(`${API_PREFIX}/ai-conversation?${query}`, { headers: { accept: 'application/json' } }); const result = await response.json() as { ok: boolean; messages?: Array<{ role: 'user' | 'assistant'; text: string }>; error?: string }; if (!response.ok || !result.ok) throw new Error(result.error ?? '加载 AI 对话失败'); return result.messages ?? [] }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface BrowserCrypto {
|
|
2
|
+
randomUUID?: () => string
|
|
3
|
+
getRandomValues?: <T extends ArrayBufferView | null>(array: T) => T
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function browserUuid(source: BrowserCrypto | undefined = globalThis.crypto): string {
|
|
7
|
+
if (typeof source?.randomUUID === 'function') return source.randomUUID()
|
|
8
|
+
const bytes = new Uint8Array(16)
|
|
9
|
+
if (typeof source?.getRandomValues === 'function') source.getRandomValues(bytes)
|
|
10
|
+
else for (let index = 0; index < bytes.length; index += 1) bytes[index] = Math.floor(Math.random() * 256)
|
|
11
|
+
bytes[6] = (bytes[6]! & 0x0f) | 0x40
|
|
12
|
+
bytes[8] = (bytes[8]! & 0x3f) | 0x80
|
|
13
|
+
const hex = [...bytes].map(value => value.toString(16).padStart(2, '0'))
|
|
14
|
+
return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10).join('')}`
|
|
15
|
+
}
|
package/src/client/mount.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { createRoot } from 'react-dom/client'
|
|
|
3
3
|
import type { SpecApi } from './api.ts'
|
|
4
4
|
import { SpecWorkbench } from './SpecWorkbench.tsx'
|
|
5
5
|
import css from './workbench.module.css'
|
|
6
|
+
import { findSidebarAnchor } from './sidebar-anchor.ts'
|
|
6
7
|
|
|
7
8
|
const ACTIVE = 'data-dsh-spec-collab-active'
|
|
8
9
|
const VIEW = '[data-dsh-spec-collab-view]'
|
|
@@ -53,18 +54,17 @@ export function mountSidebarEntry(): () => void {
|
|
|
53
54
|
}
|
|
54
55
|
const ensure = (): void => {
|
|
55
56
|
if (row?.isConnected) return
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
if (skillCenter === undefined || skillCenter === null) return
|
|
57
|
+
const anchor = findSidebarAnchor(document)
|
|
58
|
+
if (anchor === undefined) return
|
|
59
59
|
row = document.createElement('button')
|
|
60
60
|
row.type = 'button'
|
|
61
61
|
row.dataset.dshSpecCollabEntry = ''
|
|
62
|
-
row.className = `${
|
|
62
|
+
row.className = `${anchor.element.className} ${css.entry!}`
|
|
63
63
|
row.title = '需求讨论'
|
|
64
64
|
row.setAttribute('aria-label', '需求讨论')
|
|
65
65
|
row.innerHTML = '<span aria-hidden="true">▤</span><span>需求讨论</span>'
|
|
66
66
|
row.addEventListener('click', toggle)
|
|
67
|
-
|
|
67
|
+
anchor.element[anchor.placement](row)
|
|
68
68
|
}
|
|
69
69
|
const observer = new MutationObserver(ensure)
|
|
70
70
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SidebarAnchor {
|
|
2
|
+
element: HTMLButtonElement
|
|
3
|
+
placement: 'before' | 'after'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function exactTextButton(document: Document, text: string): HTMLButtonElement | undefined {
|
|
7
|
+
return [...document.querySelectorAll<HTMLButtonElement>('button')].find(button => button.textContent?.trim() === text)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function findSidebarAnchor(document: Document): SidebarAnchor | undefined {
|
|
11
|
+
const skillCenter = document.querySelector<HTMLButtonElement>('button[aria-label="技能中心"]') ?? exactTextButton(document, '技能中心')
|
|
12
|
+
if (skillCenter !== undefined && skillCenter !== null) return { element: skillCenter, placement: 'after' }
|
|
13
|
+
const settings = document.querySelector<HTMLButtonElement>('button[aria-label="设置"]') ?? exactTextButton(document, '设置')
|
|
14
|
+
if (settings !== undefined && settings !== null) return { element: settings, placement: 'before' }
|
|
15
|
+
return undefined
|
|
16
|
+
}
|
package/src/engine.ts
CHANGED
|
@@ -183,7 +183,7 @@ export class CollaborationEngine {
|
|
|
183
183
|
const item = record.reviewItems.find(candidate => candidate.id === action.reviewItemId)
|
|
184
184
|
if (item === undefined) throw new Error('review item not found')
|
|
185
185
|
item.response = { participant: action.participant, disposition: action.disposition, body: action.body.trim(), createdAt: now }
|
|
186
|
-
item.status = action.disposition === 'joint-review' ? 'joint-review' : action.disposition === 'to-verify' ? 'non-blocking-verify' : 'answered'
|
|
186
|
+
item.status = action.disposition === 'joint-review' ? 'joint-review' : action.disposition === 'to-verify' ? 'non-blocking-verify' : action.disposition === 'accept' ? 'resolved' : 'answered'
|
|
187
187
|
item.updatedAt = now
|
|
188
188
|
record.actionItems.filter(task => task.sourceId === item.id && task.status === 'pending').forEach(task => { task.status = 'handled'; task.updatedAt = now })
|
|
189
189
|
this.persist()
|
|
@@ -319,7 +319,7 @@ function actionForReview(item: ReviewItem): ActionItem { const now = Date.now();
|
|
|
319
319
|
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') }
|
|
320
320
|
function advance(record: RequirementRecord, participant: ParticipantSnapshot): void {
|
|
321
321
|
if (record.stage === 'product-review') {
|
|
322
|
-
if (record.reviewItems.some(item => item.severity === 'blocking' && !['resolved', 'non-blocking-verify', 'joint-review'].includes(item.status))) throw new Error('product blocking review items remain')
|
|
322
|
+
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')
|
|
323
323
|
if (!record.aiRuns.some(run => run.kind === 'product-second' && run.commit === record.currentCommit && run.status === 'completed')) throw new Error('product second review is required')
|
|
324
324
|
record.stage = 'product-confirmation'; return
|
|
325
325
|
}
|
|
@@ -330,7 +330,7 @@ function advance(record: RequirementRecord, participant: ParticipantSnapshot): v
|
|
|
330
330
|
throw new Error('stage cannot advance directly')
|
|
331
331
|
}
|
|
332
332
|
function sections(markdown: string): Map<string, string> { const result = new Map<string, string>(); let heading = ''; for (const line of markdown.split('\n')) { if (/^##\s+/.test(line)) { heading = line.replace(/^##\s+/, '').trim(); result.set(heading, '') } else if (heading) result.set(heading, `${result.get(heading) ?? ''}\n${line}`) } return result }
|
|
333
|
-
function acceptance(markdown: string): Map<string, string> { const result = new Map<string, string>(); for (const match of markdown.matchAll(/\*\*(AC-[A-Za-z0-9-]+)
|
|
333
|
+
function acceptance(markdown: string): Map<string, string> { const result = new Map<string, string>(); for (const match of markdown.matchAll(/\*\*(AC-[A-Za-z0-9-]+)(?:\s+[^*]+)?\*\*\s*[::]\s*(.+)/g)) result.set(match[1]!, match[2]!.trim()); return result }
|
|
334
334
|
function changedScopes(before: string, after: string): { sections: string[]; acceptanceIds: string[] } { const a = sections(before); const b = sections(after); const sectionNames = new Set([...a.keys(), ...b.keys()]); const acA = acceptance(before); const acB = acceptance(after); const acNames = new Set([...acA.keys(), ...acB.keys()]); return { sections: [...sectionNames].filter(key => a.get(key) !== b.get(key)), acceptanceIds: [...acNames].filter(key => acA.get(key) !== acB.get(key)) } }
|
|
335
335
|
function intersects(left: string[], right: string[]): boolean { return left.some(item => right.includes(item)) }
|
|
336
336
|
function invalidateAffected(record: RequirementRecord, changedSections: string[], changedAcceptanceIds: string[]): void {
|
|
@@ -345,7 +345,7 @@ function invalidateAffected(record: RequirementRecord, changedSections: string[]
|
|
|
345
345
|
export function readiness(markdown: string, record: RequirementRecord): ReadinessCheck[] {
|
|
346
346
|
const sectionMap = sections(markdown); const ac = acceptance(markdown)
|
|
347
347
|
const meaningful = (name: string): boolean => { const value = sectionMap.get(name)?.replace(/<!--.*?-->/gs, '').trim() ?? ''; return value.length >= 12 && !/待澄清|待补充|TODO/i.test(value) }
|
|
348
|
-
const blockers = record.reviewItems.filter(item => item.severity === 'blocking' && !['resolved', 'non-blocking-verify'].includes(item.status)).map(item => item.statement)
|
|
348
|
+
const blockers = record.reviewItems.filter(item => item.commit === record.currentCommit && item.severity === 'blocking' && !['resolved', 'non-blocking-verify'].includes(item.status)).map(item => item.statement)
|
|
349
349
|
return [
|
|
350
350
|
{ key: 'goal', passed: meaningful('目标与用户结果'), reasons: meaningful('目标与用户结果') ? [] : ['缺少可观察的目标与用户结果'] },
|
|
351
351
|
{ key: 'acceptance', passed: ac.size > 0 && [...ac.values()].every(value => !/待澄清|待补充|TODO/i.test(value)), reasons: ac.size === 0 ? ['缺少稳定 AC ID 与可判定结果'] : [...ac.values()].some(value => /待澄清|待补充|TODO/i.test(value)) ? ['验收标准仍含占位内容'] : [] },
|