speccrew 0.7.16 → 0.7.17

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.
@@ -0,0 +1,341 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <workflow id="pm-phase2-complexity-assess" status="pending" version="1.0" desc="Complexity assessment and skill routing for PM Phase 2">
3
+
4
+ <!-- ============================================================
5
+ Input Parameters Definition
6
+ ============================================================ -->
7
+ <block type="input" id="I1" desc="Workflow input parameters">
8
+ <field name="user_requirement" required="true" type="string" desc="User requirement description or document path"/>
9
+ <field name="workspace_path" required="true" type="string" desc="Absolute path to speccrew-workspace root"/>
10
+ <field name="knowledge_status" required="true" type="object" desc="Knowledge status from Phase 1 detection"/>
11
+ <field name="language" required="false" type="string" desc="Target language for output (auto-detected)"/>
12
+ </block>
13
+
14
+ <!-- ============================================================
15
+ Global Constraints
16
+ ============================================================ -->
17
+ <block type="rule" id="R1" level="mandatory" desc="Execution constraints">
18
+ <field name="text">This skill is READ-ONLY - do not modify any files</field>
19
+ <field name="text">Phase 2.0 verification is MANDATORY - cannot be skipped</field>
20
+ <field name="text">If knowledge initialization incomplete, report error and STOP</field>
21
+ </block>
22
+
23
+ <!-- ============================================================
24
+ Phase 2.0: Knowledge Initialization Verification
25
+ ============================================================ -->
26
+ <sequence id="S1" name="Phase 2.0: Knowledge Verification" status="pending" desc="Verify knowledge initialization is complete">
27
+
28
+ <!-- Step 2.0.1: Check DISPATCH-PROGRESS.json exists -->
29
+ <block type="task" id="B1" action="read-file" desc="Check DISPATCH-PROGRESS.json">
30
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
31
+ <field name="on_error">fail</field>
32
+ <field name="output" var="dispatch_progress"/>
33
+ <!-- If file does not exist, Path B Step 1.5 was not executed -->
34
+ </block>
35
+
36
+ <!-- Step 2.0.2: Evaluate dispatch progress content -->
37
+ <block type="gateway" id="G1" mode="exclusive" desc="Verify knowledge initialization status">
38
+
39
+ <!-- Case: File does not exist (checked by on_error above, handled here) -->
40
+ <branch test="${dispatch_progress} == null" name="No Progress File">
41
+ <block type="event" id="E1" action="log" desc="Report missing progress file">
42
+ <field name="message">ERROR: DISPATCH-PROGRESS.json not found. Phase 1 Path B was not executed. Please complete knowledge initialization first.</field>
43
+ </block>
44
+ <block type="output" id="O-ERR1" desc="Error output">
45
+ <field name="status" value="error"/>
46
+ <field name="error_code" value="KNOWLEDGE_INIT_REQUIRED"/>
47
+ <field name="message" value="Knowledge initialization not started. Return to Phase 1 Path B Step 1."/>
48
+ <field name="next_action" value="Dispatch speccrew-pm-module-initializer skill"/>
49
+ </block>
50
+ </branch>
51
+
52
+ <!-- Case: Pending tasks remain -->
53
+ <branch test="${dispatch_progress.counts.pending} > 0" name="Knowledge Incomplete">
54
+ <block type="event" id="E2" action="log" desc="Report incomplete initialization">
55
+ <field name="message">ERROR: Knowledge initialization INCOMPLETE. ${dispatch_progress.counts.pending} tasks pending. Cannot proceed to complexity assessment.</field>
56
+ </block>
57
+ <block type="output" id="O-ERR2" desc="Error output">
58
+ <field name="status" value="error"/>
59
+ <field name="error_code" value="KNOWLEDGE_INIT_INCOMPLETE"/>
60
+ <field name="message" value="Knowledge initialization incomplete. Return to Phase 1 Path B Step 3."/>
61
+ <field name="pending_count" from="${dispatch_progress.counts.pending}"/>
62
+ <field name="pending_modules" from="${dispatch_progress.pending_tasks}"/>
63
+ <field name="next_action" value="Complete pending knowledge tasks before complexity assessment"/>
64
+ </block>
65
+ </branch>
66
+
67
+ <!-- Case: No features to analyze (all already done) -->
68
+ <branch test="${dispatch_progress.counts.total} == 0" name="No Features">
69
+ <block type="event" id="E3" action="log" desc="Report no pending features">
70
+ <field name="message">No features pending analysis. All features already processed. Proceeding to complexity assessment.</field>
71
+ </block>
72
+ <!-- Continue to Phase 2.1 -->
73
+ </branch>
74
+
75
+ <!-- Case: Knowledge initialization complete -->
76
+ <branch test="${dispatch_progress.counts.pending} == 0 AND ${dispatch_progress.counts.completed} > 0" name="Knowledge Complete">
77
+ <block type="event" id="E4" action="log" desc="Report verification passed">
78
+ <field name="message">Knowledge initialization VERIFIED: ${dispatch_progress.counts.completed} features analyzed. Proceeding to complexity assessment.</field>
79
+ </block>
80
+ <!-- Continue to Phase 2.1 -->
81
+ </branch>
82
+ </block>
83
+
84
+ </sequence>
85
+
86
+ <!-- ============================================================
87
+ Phase 2.1: Complexity Assessment
88
+ ============================================================ -->
89
+ <sequence id="S2" name="Phase 2.1: Complexity Assessment" status="pending" desc="Assess requirement complexity across 5 dimensions">
90
+
91
+ <!-- Load knowledge context if available -->
92
+ <block type="task" id="B2" action="read-file" desc="Read system overview if available">
93
+ <field name="path" value="${knowledge_status.system_overview_path}"/>
94
+ <field name="on_error">continue</field>
95
+ <field name="output" var="system_context"/>
96
+ </block>
97
+
98
+ <!-- Analyze user requirement for initial scope estimation -->
99
+ <block type="task" id="B3" action="analyze" desc="Analyze requirement for scope indicators">
100
+ <field name="input" value="${user_requirement}"/>
101
+ <field name="extract">
102
+ - Business problem being solved
103
+ - Entities and processes mentioned
104
+ - Integration requirements
105
+ - Explicit scope indicators (modules, features mentioned)
106
+ </field>
107
+ <field name="output" var="requirement_analysis"/>
108
+ </block>
109
+
110
+ <!-- Dimension 1: Functional Scope Assessment -->
111
+ <block type="task" id="B4" action="analyze" desc="Assess functional scope">
112
+ <field name="input">
113
+ requirement: ${requirement_analysis}
114
+ system_context: ${system_context}
115
+ </field>
116
+ <!-- Functional scope scoring:
117
+ - Count modules mentioned/affected
118
+ - Estimate feature count based on requirement breakdown
119
+ - Simple: 1-2 modules, 1-5 features
120
+ - Moderate: 2-3 modules, 5-10 features
121
+ - Complex: 3+ modules, 6+ features
122
+ -->
123
+ <field name="assess">
124
+ <dimension name="functional_scope">
125
+ <metric var="module_count">Number of modules affected</metric>
126
+ <metric var="feature_count">Estimated number of features</metric>
127
+ <score var="functional_score">simple=1, moderate=2, complex=3</score>
128
+ </dimension>
129
+ </field>
130
+ <field name="output" var="functional_assessment"/>
131
+ </block>
132
+
133
+ <!-- Dimension 2: Technical Complexity Assessment -->
134
+ <block type="task" id="B5" action="analyze" desc="Assess technical complexity">
135
+ <field name="input" value="${requirement_analysis}"/>
136
+ <!-- Technical complexity scoring:
137
+ - New technologies/frameworks introduced
138
+ - Integration points (external APIs, services)
139
+ - Simple: No new tech, 0-2 integrations
140
+ - Moderate: 1 new tech, 2-4 integrations
141
+ - Complex: 2+ new techs, 5+ integrations
142
+ -->
143
+ <field name="assess">
144
+ <dimension name="technical_complexity">
145
+ <metric var="new_tech_count">New technologies to introduce</metric>
146
+ <metric var="integration_count">Integration points required</metric>
147
+ <score var="technical_score">simple=1, moderate=2, complex=3</score>
148
+ </dimension>
149
+ </field>
150
+ <field name="output" var="technical_assessment"/>
151
+ </block>
152
+
153
+ <!-- Dimension 3: Business Rules Complexity Assessment -->
154
+ <block type="task" id="B6" action="analyze" desc="Assess business rules complexity">
155
+ <field name="input" value="${requirement_analysis}"/>
156
+ <!-- Business rules scoring:
157
+ - Conditional branches complexity
158
+ - State machine requirements
159
+ - Simple: Simple conditions, no state machine
160
+ - Moderate: Moderate branching, basic state machine
161
+ - Complex: Complex branching, full state machine
162
+ -->
163
+ <field name="assess">
164
+ <dimension name="business_rules">
165
+ <metric var="condition_branches">Complexity of conditional logic</metric>
166
+ <metric var="state_machine">State machine requirements</metric>
167
+ <score var="business_score">simple=1, moderate=2, complex=3</score>
168
+ </dimension>
169
+ </field>
170
+ <field name="output" var="business_assessment"/>
171
+ </block>
172
+
173
+ <!-- Dimension 4: Data Complexity Assessment -->
174
+ <block type="task" id="B7" action="analyze" desc="Assess data complexity">
175
+ <field name="input">
176
+ requirement: ${requirement_analysis}
177
+ system_context: ${system_context}
178
+ </field>
179
+ <!-- Data complexity scoring:
180
+ - Entity count
181
+ - Relationship complexity
182
+ - Simple: 1-3 entities, simple relationships
183
+ - Moderate: 4-6 entities, moderate relationships
184
+ - Complex: 7+ entities, complex relationships
185
+ -->
186
+ <field name="assess">
187
+ <dimension name="data_complexity">
188
+ <metric var="entity_count">Number of data entities</metric>
189
+ <metric var="relationship_complexity">Relationship complexity level</metric>
190
+ <score var="data_score">simple=1, moderate=2, complex=3</score>
191
+ </dimension>
192
+ </field>
193
+ <field name="output" var="data_assessment"/>
194
+ </block>
195
+
196
+ <!-- Dimension 5: Team/Time Constraints Assessment -->
197
+ <block type="task" id="B8" action="analyze" desc="Assess team and time constraints">
198
+ <field name="input" value="${user_requirement}"/>
199
+ <!-- Team/time scoring:
200
+ - Timeline pressure
201
+ - Team coordination needs
202
+ - Simple: Standard timeline, single team
203
+ - Moderate: Moderate constraints
204
+ - Complex: Tight deadline, multiple teams
205
+ -->
206
+ <field name="assess">
207
+ <dimension name="constraints">
208
+ <metric var="timeline">Timeline constraints</metric>
209
+ <metric var="team_coordination">Team coordination needs</metric>
210
+ <score var="constraint_score">simple=1, moderate=2, complex=3</score>
211
+ </dimension>
212
+ </field>
213
+ <field name="output" var="constraint_assessment"/>
214
+ </block>
215
+
216
+ <!-- Aggregate complexity score and determine level -->
217
+ <block type="task" id="B9" action="compute" desc="Calculate overall complexity level">
218
+ <field name="input">
219
+ functional_score: ${functional_assessment.functional_score}
220
+ technical_score: ${technical_assessment.technical_score}
221
+ business_score: ${business_assessment.business_score}
222
+ data_score: ${data_assessment.data_score}
223
+ constraint_score: ${constraint_assessment.constraint_score}
224
+ </field>
225
+ <!-- Aggregation logic:
226
+ - Sum all dimension scores (min=5, max=15)
227
+ - Simple: total_score <= 7 (mostly 1s, at most one 2)
228
+ - Moderate: total_score 8-11 (mix of 2s)
229
+ - Complex: total_score >= 12 (mostly 2s and 3s)
230
+ -->
231
+ <field name="formula">
232
+ total_score = functional_score + technical_score + business_score + data_score + constraint_score
233
+ IF total_score <= 7: complexity_level = "simple"
234
+ ELSE IF total_score <= 11: complexity_level = "moderate"
235
+ ELSE: complexity_level = "complex"
236
+ </field>
237
+ <field name="output" var="complexity_level"/>
238
+ </block>
239
+
240
+ <!-- Build complexity details object -->
241
+ <block type="task" id="B10" action="assemble" desc="Assemble complexity details">
242
+ <field name="output" var="complexity_details">
243
+ dimensions:
244
+ functional_scope: ${functional_assessment}
245
+ technical_complexity: ${technical_assessment}
246
+ business_rules: ${business_assessment}
247
+ data_complexity: ${data_assessment}
248
+ constraints: ${constraint_assessment}
249
+ total_score: ${total_score}
250
+ decision_factors:
251
+ module_count: ${functional_assessment.module_count}
252
+ feature_count: ${functional_assessment.feature_count}
253
+ new_technologies: ${technical_assessment.new_tech_count}
254
+ integrations: ${technical_assessment.integration_count}
255
+ </field>
256
+ </block>
257
+
258
+ </sequence>
259
+
260
+ <!-- ============================================================
261
+ Phase 2.2: Skill Routing
262
+ ============================================================ -->
263
+ <sequence id="S3" name="Phase 2.2: Skill Routing" status="pending" desc="Route to appropriate PRD workflow">
264
+
265
+ <block type="gateway" id="G2" mode="exclusive" desc="Route based on complexity level">
266
+
267
+ <!-- Simple: Route to simple PRD workflow -->
268
+ <branch test="${complexity_level} == 'simple'" name="Simple Requirement">
269
+ <block type="event" id="E5" action="log" desc="Log simple path selection">
270
+ <field name="message">Assessment: SIMPLE requirement (${functional_assessment.module_count} modules, ${functional_assessment.feature_count} features) → Single PRD workflow</field>
271
+ </block>
272
+ <block type="set-variable" id="V1" name="route" value="speccrew-pm-requirement-simple"/>
273
+ </branch>
274
+
275
+ <!-- Moderate: Route to full pipeline -->
276
+ <branch test="${complexity_level} == 'moderate'" name="Moderate Requirement">
277
+ <block type="event" id="E6" action="log" desc="Log moderate path selection">
278
+ <field name="message">Assessment: MODERATE requirement (${functional_assessment.module_count} modules, ${functional_assessment.feature_count} features) → Full pipeline workflow (clarify → model → analysis)</field>
279
+ </block>
280
+ <block type="set-variable" id="V2" name="route" value="full-pipeline"/>
281
+ </branch>
282
+
283
+ <!-- Complex: Route to full pipeline -->
284
+ <branch test="${complexity_level} == 'complex'" name="Complex Requirement">
285
+ <block type="event" id="E7" action="log" desc="Log complex path selection">
286
+ <field name="message">Assessment: COMPLEX requirement (${functional_assessment.module_count} modules, ${functional_assessment.feature_count} features) → Full pipeline workflow (clarify → model → analysis)</field>
287
+ </block>
288
+ <block type="set-variable" id="V3" name="route" value="full-pipeline"/>
289
+ </branch>
290
+
291
+ </block>
292
+
293
+ <!-- Routing summary for user confirmation if uncertain -->
294
+ <block type="task" id="B11" action="analyze" desc="Check if user confirmation needed">
295
+ <field name="input">
296
+ complexity_level: ${complexity_level}
297
+ module_count: ${functional_assessment.module_count}
298
+ feature_count: ${functional_assessment.feature_count}
299
+ </field>
300
+ <!-- If uncertain about complexity (edge case), set flag for user confirmation -->
301
+ <field name="condition">
302
+ IF complexity_level is borderline OR user_requirement is ambiguous:
303
+ needs_confirmation = true
304
+ ELSE:
305
+ needs_confirmation = false
306
+ </field>
307
+ <field name="output" var="confirmation_needed"/>
308
+ </block>
309
+
310
+ <block type="gateway" id="G3" mode="exclusive" desc="Optional user confirmation">
311
+ <branch test="${confirmation_needed} == true" name="Ask User">
312
+ <block type="event" id="E8" action="confirm" desc="Ask user for routing confirmation">
313
+ <field name="prompt">This requirement seems to involve ${functional_assessment.module_count} modules / ${functional_assessment.feature_count} features. Should I use the streamlined process (single PRD) or the comprehensive process (Master + Sub-PRDs)?</field>
314
+ <field name="options">
315
+ - Streamlined (single PRD)
316
+ - Comprehensive (Master + Sub-PRDs)
317
+ </field>
318
+ </block>
319
+ </branch>
320
+ <branch default="true" name="Auto-proceed"/>
321
+ </block>
322
+
323
+ </sequence>
324
+
325
+ <!-- ============================================================
326
+ Output Results
327
+ ============================================================ -->
328
+ <block type="output" id="O1" desc="Complexity assessment output">
329
+ <field name="status" value="success" type="string" desc="Assessment status"/>
330
+ <field name="complexity_level" from="${complexity_level}" type="string" desc="Overall complexity: simple, moderate, or complex"/>
331
+ <field name="route" from="${route}" type="string" desc="Skill route: speccrew-pm-requirement-simple or full-pipeline"/>
332
+ <field name="complexity_details" from="${complexity_details}" type="object" desc="Detailed 5-dimension assessment"/>
333
+ <field name="verification_status" from="verified" type="string" desc="Knowledge initialization verification status"/>
334
+ <field name="next_steps" type="array" desc="Recommended next steps">
335
+ <item>IF route == 'speccrew-pm-requirement-simple': Invoke speccrew-pm-requirement-simple skill</item>
336
+ <item>IF route == 'full-pipeline': Proceed to Phase 3 (Requirement Clarification) with speccrew-pm-requirement-clarify</item>
337
+ </field>
338
+ <field name="message" value="Phase 2 complexity assessment completed" type="string" desc="Status message"/>
339
+ </block>
340
+
341
+ </workflow>
@@ -0,0 +1,94 @@
1
+ # speccrew-pm-phase5-subprd-dispatch
2
+
3
+ ## Description
4
+
5
+ PM Phase 5 Sub-PRD 批量派遣 Skill。负责将复杂需求拆分后的 Sub-PRD 生成任务批量派遣给 Worker Agents 执行。
6
+
7
+ 本 Skill 是 Master-Sub PRD 工作流的核心编排组件,实现:
8
+ - 从 Master PRD 读取 Dispatch Plan(Sub-PRD 分组信息)
9
+ - 初始化派遣进度追踪文件 DISPATCH-PROGRESS.json
10
+ - 批量并行派遣 Workers 生成各模块 Sub-PRD
11
+ - 失败重试机制(最多 1 次)
12
+ - 结果收集与完整性验证
13
+
14
+ ## Input Parameters
15
+
16
+ | Parameter | Type | Required | Description |
17
+ |-----------|------|----------|-------------|
18
+ | `prd_output` | object | true | Phase 4 PRD 生成输出,包含 master_prd_path、dispatch_plan_path 等 |
19
+ | `iteration_path` | string | true | 当前迭代目录绝对路径 |
20
+ | `language` | string | false | 用户语言(默认 zh) |
21
+ | `workspace_path` | string | true | speccrew-workspace 根目录绝对路径 |
22
+ | `update_progress_script` | string | true | update-progress.js 脚本绝对路径 |
23
+ | `max_concurrent_workers` | number | false | 最大并行 Worker 数(默认 5) |
24
+
25
+ ## Outputs
26
+
27
+ | Output | Type | Description |
28
+ |--------|------|-------------|
29
+ | `dispatch_result` | string | 派遣结果状态:success / partial / failed |
30
+ | `total_subprds` | number | Sub-PRD 总数 |
31
+ | `success_count` | number | 成功生成的 Sub-PRD 数量 |
32
+ | `failure_count` | number | 失败的 Sub-PRD 数量 |
33
+ | `sub_prd_files` | array | 生成的 Sub-PRD 文件路径列表 |
34
+ | `feature_list_path` | string | Feature List 文件路径 |
35
+
36
+ <!-- @agentflow: workflow.agentflow.xml -->
37
+
38
+ ## Checklist
39
+
40
+ ### Step 5.1: 读取 Dispatch Plan
41
+ - [ ] 读取 Master PRD 中的 dispatch-plan(Sub-PRD 分组信息)
42
+ - [ ] 解析 sub_prd_groups 数组
43
+ - [ ] 验证每组包含必需字段:module_id, module_name, module_key, module_scope, module_entities
44
+
45
+ ### Step 5.2: 初始化进度追踪
46
+ - [ ] 创建临时任务定义文件 .tasks-temp.json
47
+ - [ ] 使用 update-progress.js 脚本初始化 DISPATCH-PROGRESS.json
48
+ - [ ] 验证初始化成功(Total: N | Pending: N | Completed: 0)
49
+
50
+ ### Step 5.3: 批量派遣 Workers
51
+ - [ ] 按 5 个一批分组进行并行派遣
52
+ - [ ] 每个 Worker 携带完整 context 参数
53
+ - [ ] 每批完成后更新 DISPATCH-PROGRESS.json
54
+ - [ ] 继续下一批直到所有模块处理完成
55
+
56
+ ### Step 5.4: 失败重试
57
+ - [ ] 检查是否有 failed 状态的任务
58
+ - [ ] 有失败 -> 重试一次(单次重试机制)
59
+ - [ ] 重试后仍有失败 -> 记录并继续
60
+
61
+ ### Step 5.5: 结果收集与验证
62
+ - [ ] 读取最终 DISPATCH-PROGRESS.json
63
+ - [ ] 验证所有 Sub-PRD 文件存在且大小 > 3KB
64
+ - [ ] 生成汇总报告
65
+ - [ ] 更新 checkpoint
66
+ - [ ] 验证 feature list 完整性
67
+
68
+ ### Step 5.6: 用户确认
69
+ - [ ] 等待用户确认 Sub-PRD 生成结果
70
+
71
+ ## Key Rules
72
+
73
+ ### MANDATORY - Worker 派遣规则
74
+ - **ONE Worker per Module** - 每个 Sub-PRD 模块派遣一个独立 Worker
75
+ - **禁止 PM 自行生成** - PM Agent 不得直接生成 Sub-PRD 内容
76
+ - **必须通过 dispatch-to-worker** - 所有 Worker 必须通过 `dispatch-to-worker` action 执行
77
+ - **禁止直接调用 Skill** - 不得直接调用 `speccrew-pm-sub-prd-generate` skill
78
+
79
+ ### MANDATORY - 批处理规则
80
+ - **Batch Size = 5** - 每批最多 5 个并行 Worker
81
+ - **并行派遣** - 同一批次的 Worker 必须同时派遣
82
+ - **顺序等待** - 等待当前批次完成后再派遣下一批
83
+ - **进度更新** - 每个 Worker 完成后立即更新 DISPATCH-PROGRESS.json
84
+
85
+ ### MANDATORY - 进度追踪规则
86
+ - **脚本初始化** - DISPATCH-PROGRESS.json 必须通过 update-progress.js 创建
87
+ - **禁止手动创建** - 不得通过 create_file 或 PowerShell 直接创建进度文件
88
+ - **幂等更新** - 使用 `update-task` 命令更新单个任务状态
89
+
90
+ ### FORBIDDEN - 禁止行为
91
+ - 禁止 PM Agent 直接生成 Sub-PRD 文件
92
+ - 禁止派遣一个 Worker 处理多个模块
93
+ - 禁止跳过 Worker 派遣作为失败后的回退方案
94
+ - 禁止在用户确认前标记 checkpoint 为 passed