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,440 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <workflow id="pm-phase1-knowledge-check" status="pending">
3
+
4
+ <!-- ========== Input Parameters ========== -->
5
+ <block type="input" id="I1" desc="Phase 1 Knowledge Check Input">
6
+ <field name="workspace_path" required="true" type="string" desc="Absolute path to speccrew-workspace root"/>
7
+ <field name="sync_state_bizs_dir" required="true" type="string" desc="Absolute path to knowledges/base/sync-state/knowledge-bizs"/>
8
+ <field name="configs_dir" required="true" type="string" desc="Absolute path to docs/configs directory"/>
9
+ <field name="ide_skills_dir" required="false" type="string" desc="Absolute path to IDE skills directory"/>
10
+ <field name="source_path" required="false" type="string" desc="Project source root from .speccrewrc"/>
11
+ <field name="language" required="false" type="string" desc="User language (auto-detected)"/>
12
+ <field name="user_requirement" required="false" type="string" desc="User requirement text for module matching"/>
13
+ <field name="update_progress_script" required="true" type="string" desc="Absolute path to update-progress.js script"/>
14
+ </block>
15
+
16
+ <!-- ========== Phase 1 Mandatory Rules ========== -->
17
+ <block type="rule" id="P1-R1" level="mandatory" desc="Phase 1 Mandatory Constraints">
18
+ <field name="text">DO NOT manually search directories or construct status reports yourself - MUST dispatch Worker with speccrew-pm-knowledge-detector skill</field>
19
+ <field name="text">DO NOT create features-*.json files manually - ALL features files MUST be generated by scripts via Worker</field>
20
+ <field name="text">DO NOT execute knowledge-base scripts via Bash - ALL script execution MUST happen inside Worker Agents</field>
21
+ <field name="text">Output files MUST go to knowledges/base/sync-state/knowledge-bizs/ - NEVER write to knowledges/techs/*/sync-state/</field>
22
+ </block>
23
+
24
+ <!-- ========== Step 1.1: Knowledge Base Status Detection ========== -->
25
+ <block type="task" id="P1-B1" action="dispatch-to-worker" status="pending" desc="Dispatch knowledge detector worker">
26
+ <field name="agent">speccrew-task-worker</field>
27
+ <field name="skill">speccrew-pm-knowledge-detector</field>
28
+ <field name="context">
29
+ workspace_path: ${workspace_path}
30
+ sync_state_bizs_dir: ${sync_state_bizs_dir}
31
+ configs_dir: ${configs_dir}
32
+ </field>
33
+ <field name="output" var="knowledge_status"/>
34
+ </block>
35
+
36
+ <!-- ========== Step 1.2: Three-Path Gateway ========== -->
37
+ <block type="gateway" id="P1-G1" mode="exclusive" desc="Route based on knowledge status">
38
+
39
+ <!-- ==================== Path A: Full Knowledge ==================== -->
40
+ <!-- System overview and detailed module documentation are available -->
41
+ <branch test="${knowledge_status.status} == 'full'" name="Path A: Full Knowledge">
42
+
43
+ <!-- Load system overview summary via Worker -->
44
+ <block type="task" id="P1A-B1" action="dispatch-to-worker" status="pending" desc="Read system-overview.md summary">
45
+ <field name="agent">speccrew-task-worker</field>
46
+ <field name="skill">speccrew-pm-system-summary-reader</field>
47
+ <field name="context">
48
+ system_overview_path: ${knowledge_status.system_overview_path}
49
+ language: ${language}
50
+ </field>
51
+ <field name="output" var="system_context"/>
52
+ </block>
53
+
54
+ <block type="event" id="P1A-E1" action="log" desc="Log full knowledge path">
55
+ <field name="message">✅ Full knowledge base detected. System overview loaded. Proceeding to Phase 2.</field>
56
+ </block>
57
+ </branch>
58
+
59
+ <!-- ==================== Path B: Lite Knowledge ==================== -->
60
+ <!-- Feature inventory exists but detailed analysis may be incomplete -->
61
+ <branch test="${knowledge_status.status} == 'lite'" name="Path B: Lite Knowledge">
62
+
63
+ <!-- Path B Recovery Check: Check DISPATCH-PROGRESS.json existence -->
64
+ <block type="task" id="P1B-B0" action="check-file" status="pending" desc="Check DISPATCH-PROGRESS.json existence">
65
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
66
+ <field name="output" var="dispatch_progress_exists"/>
67
+ </block>
68
+
69
+ <block type="gateway" id="P1B-G0" mode="exclusive" desc="Recovery checkpoint">
70
+ <!-- Resume from Step 3 if pending tasks exist -->
71
+ <branch test="${dispatch_progress_exists} == true" name="Resume from Step 3">
72
+ <block type="task" id="P1B-B0-READ" action="read-json" status="pending" desc="Read DISPATCH-PROGRESS.json">
73
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
74
+ <field name="output" var="dispatch_progress"/>
75
+ </block>
76
+ <block type="gateway" id="P1B-G0-CHK" mode="exclusive" desc="Check progress status">
77
+ <branch test="${dispatch_progress.pending_count} == 0 AND ${dispatch_progress.completed_count} > 0" name="All Completed">
78
+ <block type="set-variable" id="P1B-V0-SKIP" name="skip_to_step5" value="true"/>
79
+ </branch>
80
+ <branch default="true" name="Has Pending Tasks">
81
+ <block type="set-variable" id="P1B-V0-RESUME" name="resume_from_step3" value="true"/>
82
+ </branch>
83
+ </block>
84
+ </branch>
85
+ <branch default="true" name="Start from Step 1">
86
+ <block type="set-variable" id="P1B-V0-START" name="start_from_step1" value="true"/>
87
+ </branch>
88
+ </block>
89
+
90
+ <!-- ===== Path B Step 1: Module Matching ===== -->
91
+ <block type="gateway" id="P1B-G1" mode="exclusive" desc="Skip matcher if resuming">
92
+ <branch test="${start_from_step1} == true" name="Run Module Matcher">
93
+ <block type="task" id="P1B-B1" action="dispatch-to-worker" status="pending" desc="Dispatch module matcher worker">
94
+ <field name="agent">speccrew-task-worker</field>
95
+ <field name="skill">speccrew-pm-module-matcher</field>
96
+ <field name="context">
97
+ sync_state_bizs_dir: ${sync_state_bizs_dir}
98
+ requirement_text: ${user_requirement}
99
+ language: ${language}
100
+ </field>
101
+ <field name="output" var="matched_modules"/>
102
+ </block>
103
+
104
+ <!-- ===== Path B Step 1.5: Initialize Dispatch Progress ===== -->
105
+ <!-- Save matcher result to temporary file -->
106
+ <block type="task" id="P1B-B1-5-SAVE" action="write-json" status="pending" desc="Save matcher result">
107
+ <field name="path" value="${workspace_path}/knowledges/bizs/.matcher-result.json"/>
108
+ <field name="data" value="${matched_modules}"/>
109
+ </block>
110
+
111
+ <!-- Run dispatch progress initialization script -->
112
+ <block type="task" id="P1B-B1-5-INIT" action="run-script" status="pending" desc="Initialize DISPATCH-PROGRESS.json">
113
+ <field name="command">node "${update_progress_script}" init-knowledge-tasks --file "${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json" --matcher-result "${workspace_path}/knowledges/bizs/.matcher-result.json" --features-dir "${workspace_path}/knowledges/bizs"</field>
114
+ <field name="output" var="init_result"/>
115
+ </block>
116
+
117
+ <!-- HARD GATE: DISPATCH-PROGRESS.json must exist -->
118
+ <block type="rule" id="P1B-R1" level="mandatory" desc="Dispatch Progress Gate">
119
+ <field name="text">HARD GATE: DISPATCH-PROGRESS.json MUST exist before proceeding to Step 2</field>
120
+ <field name="text">DO NOT proceed until file is created and contains tasks</field>
121
+ </block>
122
+ </branch>
123
+ <branch default="true" name="Skip - Resuming"/>
124
+ </block>
125
+
126
+ <!-- ===== Path B Step 2: Generate Analyze Task Plan ===== -->
127
+ <block type="gateway" id="P1B-G2" mode="exclusive" desc="Skip task plan if resuming">
128
+ <branch test="${resume_from_step3} != true AND ${skip_to_step5} != true" name="Generate Task Plans">
129
+ <block type="task" id="P1B-B2" action="read-json" status="pending" desc="Read DISPATCH-PROGRESS.json">
130
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
131
+ <field name="output" var="dispatch_tasks"/>
132
+ </block>
133
+
134
+ <!-- For each matched module, dispatch module-initializer -->
135
+ <block type="loop" id="P1B-L2" mode="sequential" desc="Generate analyze task plans">
136
+ <field name="items" value="${matched_modules.modules}"/>
137
+
138
+ <block type="task" id="P1B-B2-WORKER" action="dispatch-to-worker" status="pending" desc="Execute module initializer">
139
+ <field name="agent">speccrew-task-worker</field>
140
+ <field name="skill">speccrew-pm-module-initializer</field>
141
+ <field name="context">
142
+ source_path: ${source_path}
143
+ module_name: ${item.module_name}
144
+ platform_id: ${item.platform_id}
145
+ platform_type: ${item.platform_type}
146
+ platform_subtype: ${item.platform_subtype}
147
+ tech_stack: ${item.tech_stack}
148
+ features_file: ${sync_state_bizs_dir}/features-${item.platform_id}.json
149
+ output_path: ${workspace_path}/knowledges
150
+ completed_dir: ${sync_state_bizs_dir}/completed
151
+ sourceFile: features-${item.platform_id}.json
152
+ language: ${language}
153
+ workspace_path: ${workspace_path}
154
+ </field>
155
+ </block>
156
+ </block>
157
+ </branch>
158
+ <branch default="true" name="Skip - Resuming"/>
159
+ </block>
160
+
161
+ <!-- ===== Path B Step 3: Execute Feature Analysis (Parallel Dispatch) ===== -->
162
+ <!-- MANDATORY: Process ALL pending tasks without stopping for user confirmation -->
163
+ <block type="rule" id="P1B-R3" level="mandatory" desc="Step 3 Continuous Execution">
164
+ <field name="text">CONTINUOUS EXECUTION: Process ALL pending tasks without stopping for user confirmation</field>
165
+ <field name="text">DO NOT ask "do you want to continue?" mid-way - scope was determined by matcher</field>
166
+ </block>
167
+
168
+ <block type="gateway" id="P1B-G3" mode="exclusive" desc="Skip analysis if all completed">
169
+ <branch test="${skip_to_step5} != true" name="Execute Feature Analysis">
170
+ <block type="task" id="P1B-B3-READ" action="read-json" status="pending" desc="Read current progress">
171
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
172
+ <field name="output" var="analysis_tasks"/>
173
+ </block>
174
+
175
+ <!-- Parallel loop for feature analysis dispatch -->
176
+ <!-- max-concurrency=5 for batch processing -->
177
+ <block type="loop" id="P1B-L3" mode="parallel" max-concurrency="5" desc="Execute feature analysis workers">
178
+ <field name="items" value="${analysis_tasks.tasks[?status=='pending']}"/>
179
+
180
+ <block type="task" id="P1B-B3-WORKER" action="dispatch-to-worker" status="pending" desc="Execute feature analyzer">
181
+ <field name="agent">speccrew-task-worker</field>
182
+ <field name="skill">${item.analyzer_skill}</field>
183
+ <field name="context">
184
+ fileName: ${item.fileName}
185
+ sourcePath: ${source_path}/${item.sourcePath}
186
+ documentPath: ${workspace_path}/${item.documentPath}
187
+ module: ${item.module}
188
+ platform_id: ${item.platform_id}
189
+ platform_type: ${item.platform_type}
190
+ platform_subtype: ${item.platform_subtype}
191
+ tech_stack: ${item.tech_stack}
192
+ language: ${language}
193
+ completed_dir: ${sync_state_bizs_dir}/completed
194
+ sourceFile: features-${item.platform_id}.json
195
+ </field>
196
+ <field name="output" var="analysis_result"/>
197
+ </block>
198
+
199
+ <!-- Update task status after worker completes -->
200
+ <block type="task" id="P1B-B3-UPDATE" action="run-script" status="pending" desc="Update task status">
201
+ <field name="command">node "${update_progress_script}" update-task --file "${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json" --task-id "${item.id}" --status completed</field>
202
+ </block>
203
+ </block>
204
+
205
+ <!-- ===== Path B Step 3.5: Generate Graph Data ===== -->
206
+ <!-- MUST complete before Step 4 - Graph data enriches module summaries -->
207
+ <block type="event" id="P1B-E3-5" action="log" desc="Start graph data generation">
208
+ <field name="message">📊 Generating graph data for completed analyses...</field>
209
+ </block>
210
+
211
+ <!-- Read completed tasks for graph generation -->
212
+ <block type="task" id="P1B-B3-5-READ" action="read-json" status="pending" desc="Read completed tasks">
213
+ <field name="path" value="${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"/>
214
+ <field name="output" var="completed_tasks"/>
215
+ </block>
216
+
217
+ <!-- Parallel graph generation for API analyses -->
218
+ <block type="loop" id="P1B-L3-5-API" mode="parallel" max-concurrency="5" desc="Generate API graph data">
219
+ <field name="items" value="${completed_tasks.tasks[?status=='completed' AND analyzer_skill=='speccrew-knowledge-bizs-api-analyze']}"/>
220
+
221
+ <block type="task" id="P1B-B3-5-API-WORKER" action="dispatch-to-worker" status="pending" desc="Execute API graph generator">
222
+ <field name="agent">speccrew-task-worker</field>
223
+ <field name="skill">speccrew-knowledge-bizs-api-graph</field>
224
+ <field name="context">
225
+ api_analysis_path: ${workspace_path}/${item.documentPath}
226
+ platform_id: ${item.platform_id}
227
+ output_dir: ${sync_state_bizs_dir}/completed
228
+ module: ${item.module}
229
+ fileName: ${item.fileName}
230
+ sourcePath: ${item.sourcePath}
231
+ sourceFile: features-${item.platform_id}.json
232
+ language: ${language}
233
+ subpath: ${item.subpath}
234
+ </field>
235
+ </block>
236
+ </block>
237
+
238
+ <!-- Parallel graph generation for UI analyses -->
239
+ <block type="loop" id="P1B-L3-5-UI" mode="parallel" max-concurrency="5" desc="Generate UI graph data">
240
+ <field name="items" value="${completed_tasks.tasks[?status=='completed' AND analyzer_skill=='speccrew-knowledge-bizs-ui-analyze']}"/>
241
+
242
+ <block type="task" id="P1B-B3-5-UI-WORKER" action="dispatch-to-worker" status="pending" desc="Execute UI graph generator">
243
+ <field name="agent">speccrew-task-worker</field>
244
+ <field name="skill">speccrew-knowledge-bizs-ui-graph</field>
245
+ <field name="context">
246
+ fileName: ${item.fileName}
247
+ sourcePath: ${source_path}/${item.sourcePath}
248
+ documentPath: ${workspace_path}/${item.documentPath}
249
+ module: ${item.module}
250
+ platform_type: ${item.platform_type}
251
+ platform_subtype: ${item.platform_subtype}
252
+ completed_dir: ${sync_state_bizs_dir}/completed
253
+ sourceFile: features-${item.platform_id}.json
254
+ status: success
255
+ analysisNotes: Graph data generation from UI analysis
256
+ language: ${language}
257
+ </field>
258
+ </block>
259
+ </block>
260
+ </branch>
261
+ <branch default="true" name="Skip - Already Completed"/>
262
+ </block>
263
+
264
+ <!-- ===== Path B Step 4: Generate Module Summaries ===== -->
265
+ <block type="task" id="P1B-B4-MODULES" action="read-json" status="pending" desc="Get matched module list">
266
+ <field name="path" value="${workspace_path}/knowledges/bizs/.matcher-result.json"/>
267
+ <field name="output" var="modules_for_summary"/>
268
+ </block>
269
+
270
+ <block type="loop" id="P1B-L4" mode="parallel" max-concurrency="5" desc="Generate module summaries">
271
+ <field name="items" value="${modules_for_summary.modules}"/>
272
+
273
+ <block type="task" id="P1B-B4-WORKER" action="dispatch-to-worker" status="pending" desc="Execute module summarizer">
274
+ <field name="agent">speccrew-task-worker</field>
275
+ <field name="skill">speccrew-knowledge-module-summarize</field>
276
+ <field name="context">
277
+ module_name: ${item.module_name}
278
+ module_path: ${workspace_path}/knowledges/bizs/${item.platform_id}/${item.module_name}
279
+ language: ${language}
280
+ </field>
281
+ </block>
282
+ </block>
283
+
284
+ <!-- ===== Path B Step 5: Update Features Status ===== -->
285
+ <block type="task" id="P1B-B5" action="run-script" status="pending" desc="Update features analyzed status">
286
+ <field name="command">node "${update_progress_script}" update-features-analyzed --features-dir "${sync_state_bizs_dir}" --progress-file "${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json"</field>
287
+ </block>
288
+
289
+ <!-- ===== Path B Step 6: Generate System Overview ===== -->
290
+ <!-- This step MUST complete before Phase 1 exits -->
291
+ <block type="task" id="P1B-B6" action="dispatch-to-worker" status="pending" desc="Generate system overview">
292
+ <field name="agent">speccrew-task-worker</field>
293
+ <field name="skill">speccrew-knowledge-system-summarize</field>
294
+ <field name="context">
295
+ modules_path: ${workspace_path}/knowledges/bizs
296
+ output_path: ${workspace_path}/knowledges/bizs
297
+ language: ${language}
298
+ </field>
299
+ <field name="output" var="system_overview_result"/>
300
+ </block>
301
+
302
+ <!-- ===== Path B Step 7: Cleanup Intermediate Files ===== -->
303
+ <!-- Only execute after confirming Step 6 completed successfully -->
304
+ <block type="rule" id="P1B-R7" level="mandatory" desc="Step 7 Prerequisite">
305
+ <field name="text">Step 6 MUST complete: system-overview.md exists and is non-empty</field>
306
+ <field name="text">All tasks in DISPATCH-PROGRESS.json must have status "completed"</field>
307
+ </block>
308
+
309
+ <block type="task" id="P1B-B7-VERIFY" action="check-file" status="pending" desc="Verify system-overview.md exists">
310
+ <field name="path" value="${workspace_path}/knowledges/bizs/system-overview.md"/>
311
+ <field name="min_size" value="100"/>
312
+ <field name="output" var="overview_exists"/>
313
+ </block>
314
+
315
+ <block type="task" id="P1B-B7" action="run-script" status="pending" desc="Cleanup intermediate files">
316
+ <field name="command">Remove-Item "${workspace_path}/knowledges/bizs/.matcher-result.json" -ErrorAction SilentlyContinue; Remove-Item "${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json" -ErrorAction SilentlyContinue</field>
317
+ </block>
318
+
319
+ <block type="event" id="P1B-E7" action="log" desc="Path B completion">
320
+ <field name="message">✅ Path B complete: Knowledge base initialized. System overview generated.</field>
321
+ </block>
322
+ </branch>
323
+
324
+ <!-- ==================== Path C: No Knowledge ==================== -->
325
+ <!-- No knowledge base exists - trigger lightweight feature inventory scan -->
326
+ <branch test="${knowledge_status.status} == 'none'" name="Path C: No Knowledge">
327
+
328
+ <!-- Mandatory rules for Path C -->
329
+ <block type="rule" id="P1C-R1" level="mandatory" desc="Path C Mandatory Rules">
330
+ <field name="text">DO NOT skip to Phase 2 without running feature inventory - this is AUTOMATIC</field>
331
+ <field name="text">DO NOT ask user whether to run feature inventory - automatic initialization is MANDATORY</field>
332
+ <field name="text">DO NOT run module-initializer here - deep init is scoped by requirement in Path B</field>
333
+ <field name="text">DO NOT expose internal concepts (Stage 0, Stage 1) to user</field>
334
+ </block>
335
+
336
+ <!-- C-Step 1: Notify user -->
337
+ <block type="event" id="P1C-E1" action="log" desc="Inform user about initialization">
338
+ <field name="message">No business knowledge base detected. Scanning project structure to discover available modules...</field>
339
+ </block>
340
+
341
+ <!-- C-Step 2: Dispatch Worker to generate feature inventory -->
342
+ <block type="task" id="P1C-B2" action="dispatch-to-worker" status="pending" desc="Generate feature inventory">
343
+ <field name="agent">speccrew-task-worker</field>
344
+ <field name="skill">speccrew-knowledge-bizs-init-features</field>
345
+ <field name="context">
346
+ workspace_path: ${workspace_path}
347
+ language: ${language}
348
+ sync_state_bizs_dir: ${sync_state_bizs_dir}
349
+ configs_dir: ${configs_dir}
350
+ ide_skills_dir: ${ide_skills_dir}
351
+ </field>
352
+ <field name="output" var="init_features_result"/>
353
+ </block>
354
+
355
+ <!-- C-Step 3: Re-run detector to verify status changed -->
356
+ <block type="task" id="P1C-B3" action="dispatch-to-worker" status="pending" desc="Re-run knowledge detector">
357
+ <field name="agent">speccrew-task-worker</field>
358
+ <field name="skill">speccrew-pm-knowledge-detector</field>
359
+ <field name="context">
360
+ workspace_path: ${workspace_path}
361
+ sync_state_bizs_dir: ${sync_state_bizs_dir}
362
+ configs_dir: ${configs_dir}
363
+ </field>
364
+ <field name="output" var="recheck_status"/>
365
+ </block>
366
+
367
+ <!-- C-Gateway: Check detection result and route accordingly -->
368
+ <block type="gateway" id="P1C-G1" mode="exclusive" desc="Check re-detection result">
369
+
370
+ <!-- If status is now "lite", execute Path B sequence -->
371
+ <branch test="${recheck_status.status} == 'lite'" name="Proceed to Path B">
372
+ <block type="event" id="P1C-E2" action="log" desc="Log transition to Path B">
373
+ <field name="message">✅ Feature inventory generated. Executing Path B for module matching and deep initialization...</field>
374
+ </block>
375
+
376
+ <!-- Execute Path B Step 1: Module Matcher -->
377
+ <block type="task" id="P1C-B-PATHB-1" action="dispatch-to-worker" status="pending" desc="Dispatch module matcher worker">
378
+ <field name="agent">speccrew-task-worker</field>
379
+ <field name="skill">speccrew-pm-module-matcher</field>
380
+ <field name="context">
381
+ sync_state_bizs_dir: ${sync_state_bizs_dir}
382
+ requirement_text: ${user_requirement}
383
+ language: ${language}
384
+ </field>
385
+ <field name="output" var="matched_modules"/>
386
+ </block>
387
+
388
+ <!-- Execute Path B Step 1.5: Initialize Dispatch Progress -->
389
+ <block type="task" id="P1C-B-PATHB-1-5-SAVE" action="write-json" status="pending" desc="Save matcher result">
390
+ <field name="path" value="${workspace_path}/knowledges/bizs/.matcher-result.json"/>
391
+ <field name="data" value="${matched_modules}"/>
392
+ </block>
393
+
394
+ <block type="task" id="P1C-B-PATHB-1-5-INIT" action="run-script" status="pending" desc="Initialize DISPATCH-PROGRESS.json">
395
+ <field name="command">node "${update_progress_script}" init-knowledge-tasks --file "${workspace_path}/knowledges/bizs/DISPATCH-PROGRESS.json" --matcher-result "${workspace_path}/knowledges/bizs/.matcher-result.json" --features-dir "${workspace_path}/knowledges/bizs"</field>
396
+ </block>
397
+
398
+ <!-- Continue with Path B Steps 2-7 inline -->
399
+ <!-- Note: These steps are abbreviated here - full implementation would mirror Path B above -->
400
+ <block type="set-variable" id="P1C-V-STATUS" name="knowledge_status" value="lite"/>
401
+ <block type="set-variable" id="P1C-V-CONTEXT" name="system_context" value="Feature inventory available. Module matching completed."/>
402
+ </branch>
403
+
404
+ <!-- If status is still "none", report error -->
405
+ <branch test="${recheck_status.status} == 'none'" name="Initialization Failed">
406
+ <block type="event" id="P1C-E3" action="error" desc="Report initialization failure">
407
+ <field name="message">❌ Feature inventory generation failed. Unable to initialize knowledge base.</field>
408
+ </block>
409
+ <block type="set-variable" id="P1C-V-FAIL" name="knowledge_status" value="none"/>
410
+ <block type="set-variable" id="P1C-V-FAIL-CTX" name="system_context" value="Knowledge base initialization failed. Proceeding in degraded mode."/>
411
+ </branch>
412
+
413
+ <!-- If status is "full" (rare but possible), use full knowledge path -->
414
+ <branch test="${recheck_status.status} == 'full'" name="Full Knowledge Detected">
415
+ <block type="task" id="P1C-B-FULL" action="dispatch-to-worker" status="pending" desc="Read system-overview.md summary">
416
+ <field name="agent">speccrew-task-worker</field>
417
+ <field name="skill">speccrew-pm-system-summary-reader</field>
418
+ <field name="context">
419
+ system_overview_path: ${recheck_status.system_overview_path}
420
+ language: ${language}
421
+ </field>
422
+ <field name="output" var="system_context"/>
423
+ </block>
424
+ <block type="set-variable" id="P1C-V-FULL" name="knowledge_status" value="full"/>
425
+ </branch>
426
+ </block>
427
+ </branch>
428
+ </block>
429
+
430
+ <!-- ========== Output ========== -->
431
+ <block type="output" id="O1" desc="Phase 1 Knowledge Check Result">
432
+ <field name="knowledge_status" from="${knowledge_status.status}" type="string" desc="full | lite | none"/>
433
+ <field name="system_context" from="${system_context}" type="string" desc="Summary from system-overview.md or module list"/>
434
+ <field name="matched_modules" from="${matched_modules}" type="object" desc="List of modules identified as relevant"/>
435
+ <field name="available_platforms" from="${knowledge_status.available_platforms}" type="array" desc="List of detected platforms"/>
436
+ <field name="module_count" from="${knowledge_status.module_count}" type="number" desc="Total module count"/>
437
+ <field name="features_files" from="${knowledge_status.features_files}" type="array" desc="Generated features file paths"/>
438
+ </block>
439
+
440
+ </workflow>
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: speccrew-pm-phase2-complexity-assess
3
+ description: Complexity assessment and skill routing for PM Phase 2. Validates knowledge initialization completeness, evaluates requirement complexity across 5 dimensions, and routes to appropriate PRD workflow (simple vs full pipeline). Use after Phase 1 knowledge detection completes.
4
+ tools: Read, Grep
5
+ ---
6
+
7
+ # Phase 2: Complexity Assessment & Skill Routing
8
+
9
+ Assess requirement complexity and determine the appropriate skill routing path for PRD generation.
10
+
11
+ ## Trigger Scenarios
12
+
13
+ - "Assess requirement complexity"
14
+ - "Determine PRD workflow path"
15
+ - "Should I use simple or complex PRD workflow?"
16
+ - "Route to appropriate PRD skill"
17
+ - "Check if knowledge initialization is complete"
18
+
19
+ ## User
20
+
21
+ PM Agent (speccrew-product-manager)
22
+
23
+ ## Input
24
+
25
+ | Parameter | Type | Required | Description |
26
+ |-----------|------|----------|-------------|
27
+ | user_requirement | string | Yes | User requirement description or document path |
28
+ | workspace_path | string | Yes | Absolute path to speccrew-workspace root |
29
+ | knowledge_status | object | Yes | Knowledge status from Phase 1 (status, system_overview_path) |
30
+ | language | string | No | Target language for output (auto-detected) |
31
+
32
+ ## Output
33
+
34
+ | Field | Type | Description |
35
+ |-------|------|-------------|
36
+ | complexity_level | string | simple / moderate / complex |
37
+ | route | string | speccrew-pm-requirement-simple or full-pipeline |
38
+ | complexity_details | object | Detailed breakdown of 5-dimension assessment |
39
+ | verification_status | string | Knowledge initialization verification result |
40
+
41
+ ## AgentFlow Definition
42
+
43
+ <!-- @agentflow: workflow.agentflow.xml -->
44
+
45
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `speccrew-workspace/docs/rules/agentflow-spec.md`
46
+
47
+ ## Complexity Assessment Matrix
48
+
49
+ ### 5-Dimension Evaluation
50
+
51
+ | Dimension | Simple | Moderate | Complex |
52
+ |-----------|--------|----------|---------|
53
+ | **Functional Scope** | 1-2 modules, 1-5 features | 2-3 modules, 5-10 features | 3+ modules, 6+ features |
54
+ | **Technical Complexity** | No new tech, 0-2 integrations | 1 new tech, 2-4 integrations | 2+ new techs, 5+ integrations |
55
+ | **Business Rules** | Simple conditions, no state machine | Moderate branching, basic state machine | Complex branching, full state machine |
56
+ | **Data Complexity** | 1-3 entities, simple relationships | 4-6 entities, moderate relationships | 7+ entities, complex relationships |
57
+ | **Team/Time Constraints** | Standard timeline, single team | Moderate constraints | Tight deadline, multiple teams |
58
+
59
+ ### Decision Rules
60
+
61
+ **→ Simple** (ANY of these):
62
+ - Adding/modifying fields on an existing page
63
+ - Minor feature enhancement within 1-2 modules
64
+ - Business logic adjustment
65
+ - Bug fix documentation
66
+ - Scope: ≤ 5 features, ≤ 2 modules
67
+
68
+ **→ Moderate** (ANY of these):
69
+ - 2-3 modules involved
70
+ - 5-10 features expected
71
+ - Some cross-module dependencies
72
+ - Standard new feature development
73
+
74
+ **→ Complex** (ANY of these):
75
+ - New system or major subsystem development
76
+ - Involves 3+ modules
77
+ - Requires 6+ features
78
+ - Needs cross-module dependency management
79
+ - User explicitly requests comprehensive analysis
80
+
81
+ ### Skill Routing
82
+
83
+ | Complexity | Route | Workflow |
84
+ |------------|-------|----------|
85
+ | simple | speccrew-pm-requirement-simple | Single PRD, streamlined 6-step flow |
86
+ | moderate | full-pipeline | clarify → model → analysis (Master-Sub PRD) |
87
+ | complex | full-pipeline | clarify → model → analysis (Master-Sub PRD) |
88
+
89
+ > **Default to Simple when in doubt**. It's easier to escalate from simple to complex than to simplify an over-engineered analysis.
90
+
91
+ ## Checklist
92
+
93
+ - [ ] DISPATCH-PROGRESS.json exists and counts.pending == 0
94
+ - [ ] Knowledge initialization verified complete
95
+ - [ ] User requirement analyzed for module count
96
+ - [ ] Functional scope assessed (modules, features)
97
+ - [ ] Technical complexity evaluated (new tech, integrations)
98
+ - [ ] Business rules complexity determined (conditions, state machine)
99
+ - [ ] Data complexity assessed (entities, relationships)
100
+ - [ ] Team/time constraints considered
101
+ - [ ] Complexity level determined (simple/moderate/complex)
102
+ - [ ] Skill route selected and output
103
+
104
+ ## Key Rules
105
+
106
+ 1. **MANDATORY Verification**: Phase 2.0 knowledge initialization verification CANNOT be skipped
107
+ 2. **Pending Tasks Block**: If `counts.pending > 0`, return to Phase 1 Path B - do NOT proceed
108
+ 3. **Read-Only Assessment**: This skill performs assessment only, no file modifications
109
+ 4. **Escalation Path**: Simple workflow can escalate to complex if scope expands during execution
110
+ 5. **Single Gateway**: Use exclusive gateway for routing decision - only one path selected