speccrew 0.6.34 → 0.6.37

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,863 @@
1
+ ---
2
+ name: speccrew-knowledge-techs-dispatch-xml
3
+ description: Dispatch techs knowledge base generation tasks with 3-stage pipeline (XML Block version). Handles platform detection, tech document generation, and root index creation.
4
+ tools: Read, Write, Task, Bash
5
+ ---
6
+
7
+ # Techs Knowledge Dispatch (XML Block Version)
8
+
9
+ Orchestrate **techs knowledge base generation** with a 3-stage pipeline using **XML Block system**: Platform Detection → Tech Doc Generation → Root Index.
10
+
11
+ ## Quick Reference — Execution Flow
12
+
13
+ ```
14
+ Stage 1: Platform Detection
15
+ └─ Read techs-manifest.json → Identify platforms & tech stacks
16
+
17
+ Stage 2: Tech Doc Generation (PARALLEL)
18
+ └─ Prepare task plans for techs-generate workers per platform
19
+ └─ After generate workers complete → prepare quality check worker task plans
20
+ └─ Monitor completion markers
21
+
22
+ Stage 2.5: Completion Verification
23
+ └─ Step A: Scan completion markers
24
+ └─ Step B: Verify output integrity
25
+ └─ Step C: Update progress status
26
+
27
+ Stage 3: Root Index Generation
28
+ └─ Generate techs/README.md root index
29
+ └─ Cross-platform consistency check
30
+ ```
31
+
32
+ > **NOTE**: All worker dispatch operations are handled by the calling Agent (Team Leader). This Skill only prepares task plans and monitors completion markers.
33
+
34
+ ## Language Adaptation
35
+
36
+ **CRITICAL**: All generated documents must match the user's language. Detect the language from the user's input and pass it to all downstream Worker Agents.
37
+
38
+ - User writes in 中文 → Generate Chinese documents, pass `language: "zh"` to workers
39
+ - User writes in English → Generate English documents, pass `language: "en"` to workers
40
+ - User writes in other languages → Use appropriate language code
41
+
42
+ **All downstream skills must receive the `language` parameter and generate content in that language only.**
43
+
44
+ ## Trigger Scenarios
45
+
46
+ - "Initialize techs knowledge base"
47
+ - "Generate technology knowledge from source code"
48
+ - "Dispatch techs knowledge generation"
49
+
50
+ ## User
51
+
52
+ Leader Agent (speccrew-team-leader)
53
+
54
+ ## Platform Naming Convention
55
+
56
+ Read `speccrew-workspace/docs/configs/platform-mapping.json` for standardized platform mapping rules.
57
+
58
+ | Concept | techs-init (techs-manifest.json) | Example (UniApp) |
59
+ |---------|----------------------------------|------------------|
60
+ | **Category** | `platform_type` | `mobile` |
61
+ | **Technology** | `framework` | `uniapp` |
62
+ | **Identifier** | `platform_id` | `mobile-uniapp` |
63
+
64
+ ## Input
65
+
66
+ | Variable | Description | Default |
67
+ |----------|-------------|---------|
68
+ | `source_path` | Source code root path | project root |
69
+ | `language` | User's language code (e.g., "zh", "en") | **REQUIRED** |
70
+
71
+ ## Output
72
+
73
+ - Platform manifest: `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/techs-manifest.json`
74
+ - Tech docs: `speccrew-workspace/knowledges/techs/{platform_id}/`
75
+ - Root index: `speccrew-workspace/knowledges/techs/INDEX.md`
76
+ - Status files: `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/stage{N}-status.json`
77
+
78
+ ---
79
+
80
+ ## XML Workflow Definition
81
+
82
+ <workflow id="techs-dispatch-main" status="pending" version="1.0" desc="techs knowledge base generation 3-stage pipeline">
83
+ <!--
84
+ == Block Types ==
85
+ input : Workflow input parameters (required=mandatory, default=default value)
86
+ output : Workflow output results (from=data source variable)
87
+ task : Execute action (action: run-skill | run-script | dispatch-to-worker)
88
+ gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
89
+ loop : Iterate over collection (over=collection, as=current item)
90
+ event : Log/confirm/signal (action: log | confirm | signal)
91
+ error-handler : Exception handling (try > catch > finally)
92
+ checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
93
+ rule : Constraint declaration (level: forbidden | mandatory | note)
94
+ == Field ==
95
+ field : Parameter/variable/output (name=param name, var=bind variable, value=value)
96
+ -->
97
+
98
+ <!-- ============================================================
99
+ Input Parameters Definition
100
+ ============================================================ -->
101
+ <block type="input" id="I1" desc="techs knowledge base generation input parameters">
102
+ <field name="source_path" required="true" type="string" desc="Source code root directory path"/>
103
+ <field name="language" required="true" type="string" desc="User's language code (e.g., zh, en)"/>
104
+ <field name="workspace_path" required="true" type="string" desc="Absolute path to speccrew-workspace directory"/>
105
+ <field name="sync_state_techs_dir" required="true" type="string" desc="Absolute path to knowledges/base/sync-state/knowledge-techs/"/>
106
+ <field name="completed_dir" required="true" type="string" desc="Marker file output directory for Worker results (absolute path required)"/>
107
+ <field name="ide_skills_dir" required="true" type="string" desc="Absolute path to IDE skills directory (e.g., .qoder/skills, .cursor/skills)"/>
108
+ </block>
109
+
110
+ <!-- ============================================================
111
+ Global Continuous Execution Rules
112
+ ============================================================ -->
113
+ <block type="rule" id="GLOBAL-R1" level="forbidden" desc="Continuous execution constraints — NEVER violate">
114
+ <field name="text">DO NOT ask user "Should I continue?" or "How would you like to proceed?" between stages</field>
115
+ <field name="text">DO NOT offer options like "Full execution / Sample execution / Pause" — always execute ALL stages to completion</field>
116
+ <field name="text">DO NOT suggest "Let me split this into batches" or "Let's do this in parts" — process ALL platforms sequentially</field>
117
+ <field name="text">DO NOT pause to list what you plan to do next — just do it</field>
118
+ <field name="text">DO NOT ask for confirmation before generating output files</field>
119
+ <field name="text">DO NOT warn about "large number of files" or "this may take a while" — proceed with generation</field>
120
+ <field name="text">ONLY pause at explicit &lt;event action="confirm"&gt; blocks defined in the workflow</field>
121
+ </block>
122
+
123
+ <!-- ============================================================
124
+ Global Technology Stack Constraints
125
+ ============================================================ -->
126
+ <block type="rule" id="GLOBAL-R-TECHSTACK" level="forbidden" desc="Technology stack constraints — NEVER violate">
127
+ <field name="text">FORBIDDEN: Python, Ruby, Perl, compiled binaries, or any runtime requiring separate installation</field>
128
+ <field name="text">PERMITTED scripting: PowerShell (Windows) and Bash (Linux/Mac) ONLY</field>
129
+ <field name="text">PERMITTED Node.js: ONLY for existing project scripts (e.g., node scripts/update-progress.js)</field>
130
+ <field name="text">For JSON validation use: node -e "JSON.parse(require('fs').readFileSync('file.json','utf8'))"</field>
131
+ <field name="text">For JSON creation use: node -e with inline script, or PowerShell ConvertTo-Json</field>
132
+ <field name="text">DO NOT create temporary .py, .rb, .pl, .bat files — use inline commands via run_in_terminal</field>
133
+ </block>
134
+
135
+ <!-- ============================================================
136
+ Stage 1: Platform Detection (Single Task)
137
+ ============================================================ -->
138
+ <sequence id="S1" name="Stage 1: Platform Detection" status="pending" desc="Scan source code and identify all technology platforms">
139
+
140
+ <block type="rule" id="S1-R1" level="mandatory" desc="Stage 1 mandatory rules">
141
+ <field name="text">MUST read techs-manifest.json to identify platforms and tech stacks</field>
142
+ <field name="text">MUST read platform-mapping.json for standardized platform mapping rules</field>
143
+ </block>
144
+
145
+ <!-- Step 1: Read Configuration -->
146
+ <block type="task" id="S1-B1" action="run-skill" status="pending" desc="Read platform mapping config">
147
+ <field name="skill">speccrew-read-config</field>
148
+ <field name="config_path">${workspace_path}/docs/configs/platform-mapping.json</field>
149
+ <field name="output" var="platform_mapping"/>
150
+ </block>
151
+
152
+ <!-- Step 2: Prepare Task Plan for techs-init -->
153
+ <block type="event" id="S1-E1" action="log" level="info" desc="Prepare techs-init task plan">
154
+ Stage 1: Preparing task plan for speccrew-knowledge-techs-init-xml
155
+ - Source path: ${source_path}
156
+ - Output path: ${sync_state_techs_dir}
157
+ - Language: ${language}
158
+ </block>
159
+
160
+ <!-- Step 3: Prepare task specification -->
161
+ <block type="task" id="S1-B2" action="prepare-task" status="pending" desc="Prepare techs-init task specification">
162
+ <field name="skill_name">speccrew-knowledge-techs-init-xml</field>
163
+ <field name="context">
164
+ <field name="source_path">${source_path}</field>
165
+ <field name="output_path">${sync_state_techs_dir}</field>
166
+ <field name="language">${language}</field>
167
+ </field>
168
+ <field name="output" var="stage1_task"/>
169
+ </block>
170
+
171
+ <!-- Step 4: Monitor completion -->
172
+ <block type="event" id="S1-E2" action="log" level="info" desc="Stage 1 task prepared">
173
+ Stage 1 task plan prepared. Waiting for calling Agent to dispatch.
174
+ Task: speccrew-knowledge-techs-init-xml
175
+ Output: ${sync_state_techs_dir}/techs-manifest.json
176
+ </block>
177
+
178
+ <!-- Step 5: Read manifest after completion -->
179
+ <block type="task" id="S1-B3" action="read-file" status="pending" desc="Read generated techs-manifest.json">
180
+ <field name="file_path">${sync_state_techs_dir}/techs-manifest.json</field>
181
+ <field name="output" var="techs_manifest"/>
182
+ </block>
183
+
184
+ <!-- Step 6: Validate manifest -->
185
+ <block type="gateway" id="S1-G1" mode="guard" test="${techs_manifest.platforms.length} > 0" fail-action="stop" desc="Validate at least one platform detected">
186
+ <field name="message">No platforms detected in techs-manifest.json. Please check source_path and platform-mapping.json.</field>
187
+ </block>
188
+
189
+ <!-- Checkpoint: Platform detection complete -->
190
+ <block type="checkpoint" id="S1-CP1" name="platforms_detected" desc="Platform detection complete">
191
+ <field name="file" value="${sync_state_techs_dir}/stage1-status.json"/>
192
+ <field name="verify" value="${techs_manifest.platforms.length} > 0"/>
193
+ </block>
194
+
195
+ <block type="event" id="S1-E3" action="log" level="info" desc="Report detected platforms">
196
+ Stage 1 complete. Detected ${techs_manifest.platforms.length} platforms: ${techs_manifest.platforms.map(p => p.platform_id).join(', ')}
197
+ </block>
198
+ </sequence>
199
+
200
+ <!-- ============================================================
201
+ Stage 2: Generate Platform Documents (PARALLEL)
202
+ ============================================================ -->
203
+ <sequence id="S2" name="Stage 2: Tech Doc Generation" status="pending" desc="Generate technology documentation for each platform in parallel">
204
+
205
+ <block type="rule" id="S2-R1" level="mandatory" desc="Stage 2 mandatory rules">
206
+ <field name="text">MUST prepare task plans for ALL platforms FIRST, then dispatch ALL workers SIMULTANEOUSLY</field>
207
+ <field name="text">DO NOT finish one platform before starting the next — this wastes time and violates the pipeline design</field>
208
+ <field name="text">The calling Agent MUST use concurrent task dispatch (e.g., dispatch 3 workers in one turn for 3 platforms)</field>
209
+ <field name="text">Sequential platform-by-platform execution is FORBIDDEN</field>
210
+ </block>
211
+
212
+ <block type="rule" id="S2-R2" level="forbidden" desc="Stage 2 forbidden actions">
213
+ <field name="text">DO NOT process platforms sequentially — PARALLEL execution is MANDATORY</field>
214
+ <field name="text">DO NOT wait for one platform to complete before starting another</field>
215
+ <field name="text">DO NOT proceed to Stage 2.5 until ALL workers have completed or failed</field>
216
+ </block>
217
+
218
+ <!-- Step 0: Ensure completed_dir exists -->
219
+ <block type="task" id="S2-B0" action="run-script" status="pending" desc="Ensure completed_dir directory exists">
220
+ <field name="command">node -e "require('fs').mkdirSync('${completed_dir}', {recursive: true}); console.log('completed dir ready')"</field>
221
+ </block>
222
+
223
+ <!-- Step 1: Update manifest status to processing -->
224
+ <block type="loop" id="S2-L1" over="${techs_manifest.platforms}" as="platform" desc="Update each platform status to processing">
225
+ <block type="task" id="S2-B1a" action="run-script" status="pending" desc="Update platform status in manifest">
226
+ <field name="command">node -e "
227
+ const fs = require('fs');
228
+ const manifest = JSON.parse(fs.readFileSync('${sync_state_techs_dir}/techs-manifest.json', 'utf8'));
229
+ const platform = manifest.platforms.find(p => p.platform_id === '${platform.platform_id}');
230
+ if (platform) {
231
+ platform.status = 'processing';
232
+ platform.startedAt = new Date().toISOString();
233
+ platform.workers = platform.workers || {};
234
+ platform.workers.conventions = { status: 'processing' };
235
+ if (['web', 'mobile', 'desktop'].includes(platform.platform_type)) {
236
+ platform.workers.ui_style = { status: 'processing' };
237
+ }
238
+ fs.writeFileSync('${sync_state_techs_dir}/techs-manifest.json', JSON.stringify(manifest, null, 2));
239
+ console.log('Updated ${platform.platform_id} to processing');
240
+ }
241
+ "</field>
242
+ </block>
243
+ </block>
244
+
245
+ <!-- Step 2: Prepare Conventions Worker Task Plans (ALL Platforms) -->
246
+ <block type="event" id="S2-E1" action="log" level="info" desc="Prepare conventions worker tasks">
247
+ Preparing conventions worker task plans for ${techs_manifest.platforms.length} platforms...
248
+ </block>
249
+
250
+ <block type="loop" id="S2-L2" over="${techs_manifest.platforms}" as="platform" desc="Prepare conventions worker task for each platform">
251
+ <block type="task" id="S2-B2" action="prepare-task" status="pending" desc="Prepare conventions worker task specification">
252
+ <field name="skill_name">speccrew-knowledge-techs-generate-conventions-xml</field>
253
+ <field name="context">
254
+ <field name="platform_id">${platform.platform_id}</field>
255
+ <field name="platform_type">${platform.platform_type}</field>
256
+ <field name="framework">${platform.framework}</field>
257
+ <field name="source_path">${platform.source_path}</field>
258
+ <field name="config_files">${platform.config_files}</field>
259
+ <field name="convention_files">${platform.convention_files}</field>
260
+ <field name="output_path">${workspace_path}/knowledges/techs/${platform.platform_id}/</field>
261
+ <field name="completed_dir">${completed_dir}</field>
262
+ <field name="language">${language}</field>
263
+ </field>
264
+ <field name="output" var="conventions_task_${platform.platform_id}"/>
265
+ </block>
266
+ </block>
267
+
268
+ <!-- Step 3: Prepare UI-Style Worker Task Plans (Frontend Platforms ONLY) -->
269
+ <block type="event" id="S2-E2" action="log" level="info" desc="Prepare UI-style worker tasks">
270
+ Preparing UI-style worker task plans for frontend platforms...
271
+ </block>
272
+
273
+ <block type="loop" id="S2-L3" over="${techs_manifest.platforms}" as="platform" desc="Prepare UI-style worker task for frontend platforms">
274
+ <block type="gateway" id="S2-G1" mode="guard" test="${platform.platform_type} IN ['web', 'mobile', 'desktop']" fail-action="skip" desc="Only for frontend platforms">
275
+ <field name="message">Skipping UI-style for backend platform: ${platform.platform_id}</field>
276
+ </block>
277
+ <block type="task" id="S2-B3" action="prepare-task" status="pending" desc="Prepare UI-style worker task specification">
278
+ <field name="skill_name">speccrew-knowledge-techs-generate-ui-style-xml</field>
279
+ <field name="context">
280
+ <field name="platform_id">${platform.platform_id}</field>
281
+ <field name="platform_type">${platform.platform_type}</field>
282
+ <field name="framework">${platform.framework}</field>
283
+ <field name="source_path">${platform.source_path}</field>
284
+ <field name="output_path">${workspace_path}/knowledges/techs/${platform.platform_id}/</field>
285
+ <field name="completed_dir">${completed_dir}</field>
286
+ <field name="language">${language}</field>
287
+ </field>
288
+ <field name="output" var="ui_style_task_${platform.platform_id}"/>
289
+ </block>
290
+ </block>
291
+
292
+ <!-- Step 4: Dispatch ALL Workers in PARALLEL -->
293
+ <block type="event" id="S2-E3" action="log" level="info" desc="Dispatch all workers">
294
+ Dispatching ALL workers in PARALLEL. The calling Agent should dispatch all prepared tasks simultaneously.
295
+ </block>
296
+
297
+ <!-- Step 5: Monitor Completion Markers -->
298
+ <block type="loop" id="S2-L4" over="${techs_manifest.platforms}" as="platform" parallel="true" max-concurrency="${techs_manifest.platforms.length}" desc="Monitor completion markers for each platform">
299
+
300
+ <!-- Check conventions worker marker -->
301
+ <block type="task" id="S2-B4a" action="run-script" status="pending" desc="Check conventions completion marker">
302
+ <field name="command">Test-Path "${completed_dir}/${platform.platform_id}.done-conventions.json"</field>
303
+ <field name="output" var="conventions_done_exists"/>
304
+ </block>
305
+
306
+ <!-- Check UI-style worker marker (frontend only) -->
307
+ <block type="gateway" id="S2-G2" mode="exclusive" desc="Check UI-style marker for frontend">
308
+ <branch test="${platform.platform_type} IN ['web', 'mobile', 'desktop']" name="Frontend platform">
309
+ <block type="task" id="S2-B4b" action="run-script" status="pending" desc="Check UI-style completion marker">
310
+ <field name="command">Test-Path "${completed_dir}/${platform.platform_id}.done-ui-style.json"</field>
311
+ <field name="output" var="ui_style_done_exists"/>
312
+ </block>
313
+ </branch>
314
+ <branch default="true" name="Backend platform">
315
+ <field name="ui_style_done_exists" value="true"/>
316
+ </branch>
317
+ </block>
318
+
319
+ <!-- Read conventions done file -->
320
+ <block type="task" id="S2-B4c" action="read-file" status="pending" desc="Read conventions done file">
321
+ <field name="file_path">${completed_dir}/${platform.platform_id}.done-conventions.json</field>
322
+ <field name="output" var="conventions_done"/>
323
+ </block>
324
+
325
+ <!-- Read UI-style done file (frontend only) -->
326
+ <block type="gateway" id="S2-G3" mode="exclusive" desc="Read UI-style done file">
327
+ <branch test="${platform.platform_type} IN ['web', 'mobile', 'desktop']" name="Frontend platform">
328
+ <block type="task" id="S2-B4d" action="read-file" status="pending" desc="Read UI-style done file">
329
+ <field name="file_path">${completed_dir}/${platform.platform_id}.done-ui-style.json</field>
330
+ <field name="output" var="ui_style_done"/>
331
+ </block>
332
+ </branch>
333
+ <branch default="true" name="Backend platform">
334
+ <field name="ui_style_done" value="{&quot;status&quot;:&quot;skipped&quot;}"/>
335
+ </branch>
336
+ </block>
337
+
338
+ <!-- Prepare Quality Check Worker Task Plans -->
339
+ <block type="gateway" id="S2-G4" mode="guard" test="${conventions_done.status} == 'completed'" fail-action="continue" desc="Prepare quality check for conventions">
340
+ <block type="task" id="S2-B5a" action="prepare-task" status="pending" desc="Prepare conventions quality worker">
341
+ <field name="skill_name">speccrew-knowledge-techs-generate-quality-xml</field>
342
+ <field name="context">
343
+ <field name="platform_dir">${workspace_path}/knowledges/techs/${platform.platform_id}/</field>
344
+ <field name="platform_id">${platform.platform_id}</field>
345
+ <field name="platform_type">${platform.platform_type}</field>
346
+ <field name="source_path">${platform.source_path}</field>
347
+ </field>
348
+ <field name="output" var="quality_conventions_task_${platform.platform_id}"/>
349
+ </block>
350
+ </block>
351
+
352
+ <block type="gateway" id="S2-G5" mode="guard" test="${ui_style_done.status} == 'completed'" fail-action="continue" desc="Prepare quality check for UI-style">
353
+ <block type="task" id="S2-B5b" action="prepare-task" status="pending" desc="Prepare UI-style quality worker">
354
+ <field name="skill_name">speccrew-knowledge-techs-generate-quality-xml</field>
355
+ <field name="context">
356
+ <field name="platform_dir">${workspace_path}/knowledges/techs/${platform.platform_id}/ui-style/</field>
357
+ <field name="platform_id">${platform.platform_id}</field>
358
+ <field name="platform_type">${platform.platform_type}</field>
359
+ <field name="source_path">${platform.source_path}</field>
360
+ </field>
361
+ <field name="output" var="quality_ui_style_task_${platform.platform_id}"/>
362
+ </block>
363
+ </block>
364
+ </block>
365
+
366
+ <!-- Checkpoint: Stage 2 complete -->
367
+ <block type="checkpoint" id="S2-CP1" name="stage2_complete" desc="Tech doc generation complete">
368
+ <field name="file" value="${sync_state_techs_dir}/stage2-status.json"/>
369
+ <field name="verify" value="true"/>
370
+ </block>
371
+
372
+ <block type="event" id="S2-E4" action="log" level="info" desc="Stage 2 complete">
373
+ Stage 2 complete. All platform workers finished.
374
+ </block>
375
+ </sequence>
376
+
377
+ <!-- ============================================================
378
+ Stage 2.5: Completion Verification
379
+ ============================================================ -->
380
+ <sequence id="S2_5" name="Stage 2.5: Completion Verification" status="pending" desc="Verify cross-platform consistency and document completeness before indexing">
381
+
382
+ <block type="rule" id="S2_5-R1" level="mandatory" desc="Stage 2.5 mandatory rules">
383
+ <field name="text">MUST scan ALL completion markers before proceeding</field>
384
+ <field name="text">MUST verify document existence and completeness</field>
385
+ <field name="text">MUST update stage2-status.json with verification results</field>
386
+ </block>
387
+
388
+ <!-- Step A: Scan Completion Markers -->
389
+ <block type="event" id="S2_5-E1" action="log" level="info" desc="Step A: Scan completion markers">
390
+ Stage 2.5 Step A: Scanning completion markers...
391
+ </block>
392
+
393
+ <block type="loop" id="S2_5-L1" over="${techs_manifest.platforms}" as="platform" desc="Scan markers for each platform">
394
+ <block type="task" id="S2_5-B1" action="run-script" status="pending" desc="Check all markers for platform">
395
+ <field name="command">node -e "
396
+ const fs = require('fs');
397
+ const platformId = '${platform.platform_id}';
398
+ const completedDir = '${completed_dir}';
399
+ const platformType = '${platform.platform_type}';
400
+ const isFrontend = ['web', 'mobile', 'desktop'].includes(platformType);
401
+
402
+ const markers = {
403
+ conventions: fs.existsSync(\`\${completedDir}/\${platformId}.done-conventions.json\`),
404
+ ui_style: isFrontend ? fs.existsSync(\`\${completedDir}/\${platformId}.done-ui-style.json\`) : 'skipped',
405
+ quality: fs.existsSync(\`\${completedDir}/\${platformId}.quality-done.json\`)
406
+ };
407
+
408
+ console.log(JSON.stringify(markers));
409
+ "</field>
410
+ <field name="output" var="markers_${platform.platform_id}"/>
411
+ </block>
412
+ </block>
413
+
414
+ <!-- Step B: Verify Output Integrity -->
415
+ <block type="event" id="S2_5-E2" action="log" level="info" desc="Step B: Verify output integrity">
416
+ Stage 2.5 Step B: Verifying output integrity...
417
+ </block>
418
+
419
+ <block type="loop" id="S2_5-L2" over="${techs_manifest.platforms}" as="platform" desc="Verify documents for each platform">
420
+ <block type="task" id="S2_5-B2" action="run-script" status="pending" desc="Check required documents exist">
421
+ <field name="command">node -e "
422
+ const fs = require('fs');
423
+ const path = require('path');
424
+ const platformDir = '${workspace_path}/knowledges/techs/${platform.platform_id}';
425
+ const platformType = '${platform.platform_type}';
426
+ const isFrontend = ['web', 'mobile', 'desktop'].includes(platformType);
427
+
428
+ const requiredDocs = [
429
+ 'INDEX.md', 'tech-stack.md', 'architecture.md',
430
+ 'conventions-design.md', 'conventions-dev.md',
431
+ 'conventions-unit-test.md', 'conventions-system-test.md', 'conventions-build.md'
432
+ ];
433
+
434
+ const results = {
435
+ documents_present: [],
436
+ documents_missing: [],
437
+ ui_style_complete: false
438
+ };
439
+
440
+ requiredDocs.forEach(doc => {
441
+ if (fs.existsSync(path.join(platformDir, doc))) {
442
+ results.documents_present.push(doc);
443
+ } else {
444
+ results.documents_missing.push(doc);
445
+ }
446
+ });
447
+
448
+ if (isFrontend) {
449
+ results.ui_style_complete = fs.existsSync(path.join(platformDir, 'ui-style/ui-style-guide.md'));
450
+ }
451
+
452
+ console.log(JSON.stringify(results));
453
+ "</field>
454
+ <field name="output" var="integrity_${platform.platform_id}"/>
455
+ </block>
456
+ </block>
457
+
458
+ <!-- Step C: Update Progress Status -->
459
+ <block type="event" id="S2_5-E3" action="log" level="info" desc="Step C: Update progress status">
460
+ Stage 2.5 Step C: Updating progress status...
461
+ </block>
462
+
463
+ <block type="task" id="S2_5-B3" action="run-script" status="pending" desc="Generate stage2-status.json">
464
+ <field name="command">node -e "
465
+ const fs = require('fs');
466
+ const timestamp = new Date().toISOString();
467
+
468
+ const status = {
469
+ generated_at: timestamp,
470
+ stage: 'platform-doc-generation',
471
+ total_platforms: ${techs_manifest.platforms.length},
472
+ completed: 0,
473
+ incomplete: 0,
474
+ failed: 0,
475
+ language: '${language}',
476
+ platforms: []
477
+ };
478
+
479
+ // Platform status would be populated here based on marker and integrity checks
480
+ // This is a simplified version - actual implementation would aggregate results
481
+
482
+ fs.writeFileSync('${sync_state_techs_dir}/stage2-status.json', JSON.stringify(status, null, 2));
483
+ console.log('stage2-status.json written');
484
+ "</field>
485
+ </block>
486
+
487
+ <!-- Checkpoint: Stage 2.5 complete -->
488
+ <block type="checkpoint" id="S2_5-CP1" name="stage2_5_complete" desc="Completion verification done">
489
+ <field name="file" value="${sync_state_techs_dir}/stage2-status.json"/>
490
+ <field name="verify" value="true"/>
491
+ </block>
492
+
493
+ <block type="event" id="S2_5-E4" action="log" level="info" desc="Stage 2.5 complete">
494
+ Stage 2.5 complete. Verification results written to stage2-status.json.
495
+ </block>
496
+ </sequence>
497
+
498
+ <!-- ============================================================
499
+ Stage 3: Generate Root Index (Single Task)
500
+ ============================================================ -->
501
+ <sequence id="S3" name="Stage 3: Root Index Generation" status="pending" desc="Generate root INDEX.md aggregating all platform documentation">
502
+
503
+ <block type="rule" id="S3-R1" level="mandatory" desc="Stage 3 mandatory rules">
504
+ <field name="text">MUST read techs-manifest.json to get platform list</field>
505
+ <field name="text">MUST scan each platform directory to detect which documents actually exist</field>
506
+ <field name="text">MUST only include links to documents that actually exist</field>
507
+ </block>
508
+
509
+ <!-- Step 1: Read manifest -->
510
+ <block type="task" id="S3-B1" action="read-file" status="pending" desc="Read techs-manifest.json">
511
+ <field name="file_path">${sync_state_techs_dir}/techs-manifest.json</field>
512
+ <field name="output" var="manifest_for_index"/>
513
+ </block>
514
+
515
+ <!-- Step 2: Prepare Task Plan for techs-index -->
516
+ <block type="event" id="S3-E1" action="log" level="info" desc="Prepare techs-index task plan">
517
+ Stage 3: Preparing task plan for speccrew-knowledge-techs-index-xml
518
+ - Manifest: ${sync_state_techs_dir}/techs-manifest.json
519
+ - Output: ${workspace_path}/knowledges/techs/
520
+ - Language: ${language}
521
+ </block>
522
+
523
+ <!-- Step 3: Prepare task specification -->
524
+ <block type="task" id="S3-B2" action="prepare-task" status="pending" desc="Prepare techs-index task specification">
525
+ <field name="skill_name">speccrew-knowledge-techs-index-xml</field>
526
+ <field name="context">
527
+ <field name="manifest_path">${sync_state_techs_dir}/techs-manifest.json</field>
528
+ <field name="techs_base_path">${workspace_path}/knowledges/techs/</field>
529
+ <field name="output_path">${workspace_path}/knowledges/techs/</field>
530
+ <field name="language">${language}</field>
531
+ </field>
532
+ <field name="output" var="stage3_task"/>
533
+ </block>
534
+
535
+ <!-- Step 4: Monitor completion -->
536
+ <block type="event" id="S3-E2" action="log" level="info" desc="Stage 3 task prepared">
537
+ Stage 3 task plan prepared. Waiting for calling Agent to dispatch.
538
+ Task: speccrew-knowledge-techs-index-xml
539
+ Output: ${workspace_path}/knowledges/techs/INDEX.md
540
+ </block>
541
+
542
+ <!-- Step 5: Generate stage3-status.json -->
543
+ <block type="task" id="S3-B3" action="run-script" status="pending" desc="Generate stage3-status.json">
544
+ <field name="command">node -e "
545
+ const fs = require('fs');
546
+ const timestamp = new Date().toISOString();
547
+
548
+ const status = {
549
+ generated_at: timestamp,
550
+ stage: 'root-index-generation',
551
+ platforms_indexed: ${techs_manifest.platforms.length},
552
+ index_file: '${workspace_path}/knowledges/techs/INDEX.md',
553
+ status: 'completed'
554
+ };
555
+
556
+ fs.writeFileSync('${sync_state_techs_dir}/stage3-status.json', JSON.stringify(status, null, 2));
557
+ console.log('stage3-status.json written');
558
+ "</field>
559
+ </block>
560
+
561
+ <!-- Checkpoint: Stage 3 complete -->
562
+ <block type="checkpoint" id="S3-CP1" name="stage3_complete" desc="Root index generation complete">
563
+ <field name="file" value="${sync_state_techs_dir}/stage3-status.json"/>
564
+ <field name="verify" value="true"/>
565
+ </block>
566
+
567
+ <block type="event" id="S3-E3" action="log" level="info" desc="Stage 3 complete">
568
+ Stage 3 complete. Root INDEX.md generated.
569
+ </block>
570
+ </sequence>
571
+
572
+ <!-- ============================================================
573
+ Output Definition
574
+ ============================================================ -->
575
+ <block type="output" id="O1" desc="Workflow output results">
576
+ <field name="manifest_path" from="${sync_state_techs_dir}/techs-manifest.json"/>
577
+ <field name="root_index" from="${workspace_path}/knowledges/techs/INDEX.md"/>
578
+ <field name="stage1_status" from="${sync_state_techs_dir}/stage1-status.json"/>
579
+ <field name="stage2_status" from="${sync_state_techs_dir}/stage2-status.json"/>
580
+ <field name="stage3_status" from="${sync_state_techs_dir}/stage3-status.json"/>
581
+ </block>
582
+
583
+ </workflow>
584
+
585
+ ---
586
+
587
+ ## Worker Completion Marker Format
588
+
589
+ Each Worker MUST create a completion marker file after generating documents.
590
+
591
+ ### Conventions Worker Done File
592
+
593
+ **File**: `{completed_dir}/{platform_id}.done-conventions.json`
594
+
595
+ **Format**:
596
+ ```json
597
+ {
598
+ "platform_id": "web-vue",
599
+ "worker_type": "conventions",
600
+ "status": "completed",
601
+ "documents_generated": [
602
+ "INDEX.md", "tech-stack.md", "architecture.md",
603
+ "conventions-dev.md", "conventions-design.md",
604
+ "conventions-unit-test.md", "conventions-build.md"
605
+ ],
606
+ "analysis_file": "web-vue.analysis-conventions.json",
607
+ "completed_at": "2024-01-15T10:45:00Z"
608
+ }
609
+ ```
610
+
611
+ ### UI-Style Worker Done File
612
+
613
+ **File**: `{completed_dir}/{platform_id}.done-ui-style.json`
614
+
615
+ **Format**:
616
+ ```json
617
+ {
618
+ "platform_id": "web-vue",
619
+ "worker_type": "ui-style",
620
+ "status": "completed",
621
+ "ui_analysis_level": "full",
622
+ "documents_generated": [
623
+ "ui-style/ui-style-guide.md"
624
+ ],
625
+ "analysis_file": "web-vue.analysis-ui-style.json",
626
+ "completed_at": "2024-01-15T10:45:00Z"
627
+ }
628
+ ```
629
+
630
+ **Status values**:
631
+ - `completed` — All required documents generated successfully
632
+ - `failed` — Critical failure, required documents not generated
633
+
634
+ If a Worker encounters a fatal error, it should still attempt to create the done file with `status: "failed"` and include error details in an `"error"` field.
635
+
636
+ ### Quality Worker Done File
637
+
638
+ **File**: `{completed_dir}/{platform_id}.quality-done.json`
639
+
640
+ **Format**:
641
+ ```json
642
+ {
643
+ "platform_id": "web-vue",
644
+ "worker_type": "quality",
645
+ "status": "completed",
646
+ "quality_score": 85,
647
+ "issues_found": 2,
648
+ "completed_at": "2024-01-15T11:00:00Z"
649
+ }
650
+ ```
651
+
652
+ ---
653
+
654
+ ## Platform Status Tracking Fields
655
+
656
+ Each platform entry in techs-manifest.json includes status tracking fields for monitoring the analysis pipeline progress:
657
+
658
+ | Field | Type | Values | Description |
659
+ |-------|------|--------|-------------|
660
+ | `status` | string | `pending` / `processing` / `completed` / `partial` / `failed` | Current analysis status |
661
+ | `startedAt` | string \| null | ISO 8601 timestamp | When the Worker started analyzing this platform |
662
+ | `completedAt` | string \| null | ISO 8601 timestamp | When the Worker finished analyzing this platform |
663
+ | `analysisLevel` | string \| null | `full` / `minimal` / `reference_only` | Depth of analysis achieved |
664
+ | `topicsCoverage` | number \| null | 0-100 | Percentage of domain topics covered (from analysis.json) |
665
+ | `workers` | object | See below | Per-worker status tracking |
666
+
667
+ **Workers Object Structure:**
668
+ ```json
669
+ {
670
+ "platform_id": "web-vue",
671
+ "status": "completed",
672
+ "workers": {
673
+ "conventions": {
674
+ "status": "completed",
675
+ "skill": "speccrew-knowledge-techs-generate-conventions-xml",
676
+ "done_file": "web-vue.done-conventions.json"
677
+ },
678
+ "ui_style": {
679
+ "status": "completed",
680
+ "skill": "speccrew-knowledge-techs-generate-ui-style-xml",
681
+ "done_file": "web-vue.done-ui-style.json"
682
+ }
683
+ }
684
+ }
685
+ ```
686
+
687
+ For backend platforms, `ui_style.status` is set to `"skipped"`.
688
+
689
+ **Status Lifecycle:**
690
+ ```
691
+ pending → processing → completed
692
+ → partial (conventions OK, ui-style failed)
693
+ → failed
694
+ ```
695
+
696
+ ---
697
+
698
+ ## Output per Platform
699
+
700
+ ```
701
+ speccrew-workspace/knowledges/techs/{platform_id}/
702
+ ├── INDEX.md # Required
703
+ ├── tech-stack.md # Required
704
+ ├── architecture.md # Required
705
+ ├── conventions-design.md # Required
706
+ ├── conventions-dev.md # Required
707
+ ├── conventions-unit-test.md # Required
708
+ ├── conventions-system-test.md # Required
709
+ ├── conventions-build.md # Required
710
+ ├── conventions-data.md # Optional — platform-specific
711
+ └── ui-style/ # Optional — frontend only (web/mobile/desktop)
712
+ ├── ui-style-guide.md # Generated by techs Stage 2
713
+ ├── page-types/ # Populated by bizs pipeline Stage 3.5 (ui-style-extract)
714
+ ├── components/ # Populated by bizs pipeline Stage 3.5 (ui-style-extract)
715
+ ├── layouts/ # Populated by bizs pipeline Stage 3.5 (ui-style-extract)
716
+ └── styles/ # Generated by techs Stage 2
717
+ ```
718
+
719
+ **Cross-Pipeline Note for `ui-style/`**:
720
+ - `ui-style-guide.md` and `styles/` are generated by techs pipeline Stage 2 (technical framework-level style specs)
721
+ - `page-types/`, `components/`, and `layouts/` are populated by bizs pipeline Stage 3.5 (`speccrew-knowledge-bizs-ui-style-extract` skill), which aggregates patterns from analyzed feature documents
722
+ - These two sources are complementary: techs provides framework-level conventions, bizs adds real-page-derived design patterns
723
+ - If bizs pipeline has not been executed, these three subdirectories will be empty
724
+
725
+ **Optional file `conventions-data.md` rules**:
726
+
727
+ | Platform Type | Required? | Notes |
728
+ |----------|-----------|-------|
729
+ | `backend` | Required | ORM specs, data modeling, caching |
730
+ | `web` | Depends | Only if using ORM/data layer (Prisma, TypeORM, etc.) |
731
+ | `mobile` | Optional | Based on tech stack |
732
+ | `desktop` | Optional | Based on tech stack |
733
+
734
+ ---
735
+
736
+ ## Error Handling
737
+
738
+ ### Error Handling Strategy
739
+
740
+ ```
741
+ ON Worker Failure:
742
+ 1. Capture error message from worker_result.error
743
+ 2. Mark platform status as "failed" in stage2-status.json
744
+ 3. Record failed platform_id and error details
745
+ 4. Continue processing other platforms (no retry, fail fast)
746
+ 5. After all workers complete, evaluate overall status:
747
+ - IF all platforms failed → ABORT pipeline
748
+ - IF some platforms succeeded → CONTINUE to Stage 3 with successful platforms only
749
+ ```
750
+
751
+ ### Stage-Level Failure Handling
752
+
753
+ | Stage | Failure Handling |
754
+ |-------|-----------------|
755
+ | Stage 1 | Abort pipeline, report error |
756
+ | Stage 2 | Continue with successful platforms, report failed ones |
757
+ | Stage 2.5 | Continue pipeline, report warnings |
758
+ | Stage 3 | Abort if Stage 2 had critical failures |
759
+
760
+ ### Worker Failure Details
761
+
762
+ **When a Worker Agent fails:**
763
+ - **No automatic retry**: Worker failures are recorded as-is
764
+ - **Partial success accepted**: Pipeline continues if at least one platform succeeds
765
+ - **Error propagation**: Failed platform details are included in stage2-status.json
766
+ - **Stage 3 decision**: Only platforms with status "complete" are included in root INDEX.md
767
+
768
+ ---
769
+
770
+ ## Checklist
771
+
772
+ - [ ] Stage 1: Platform manifest generated with techs-manifest.json
773
+ - [ ] Stage 2: All platforms processed in parallel
774
+ - [ ] Stage 2: `stage2-status.json` generated with all platform results
775
+ - [ ] Stage 3: Root INDEX.md generated with Agent mapping
776
+ - [ ] Stage 3: `stage3-status.json` generated with index info
777
+
778
+ ### Document Completeness Verification
779
+ - [ ] Each platform directory contains required documents: INDEX.md, tech-stack.md, architecture.md, conventions-design.md, conventions-dev.md, conventions-unit-test.md, conventions-system-test.md, conventions-build.md
780
+ - [ ] `conventions-data.md` exists only for appropriate platforms (backend required, others optional)
781
+ - [ ] All documents include file reference blocks (pure Markdown format for VS Code preview compatibility)
782
+ - [ ] All documents include AI-TAG and AI-CONTEXT comments
783
+ - [ ] techs/INDEX.md links only to existing documents
784
+
785
+ ---
786
+
787
+ ## Task Completion Report Format
788
+
789
+ Upon completing all stages, output the following structured report:
790
+
791
+ ```json
792
+ {
793
+ "status": "success | partial | failed",
794
+ "skill": "speccrew-knowledge-techs-dispatch-xml",
795
+ "stages_completed": ["stage_1", "stage_2", "stage_2_5", "stage_3"],
796
+ "stages_failed": [],
797
+ "output_summary": {
798
+ "platforms_processed": ["frontend", "backend"],
799
+ "docs_generated_per_platform": {"frontend": 5, "backend": 4},
800
+ "root_index_generated": true,
801
+ "cross_platform_check_passed": true
802
+ },
803
+ "output_files": [
804
+ "knowledges/techs/{platform}/README.md",
805
+ "knowledges/techs/{platform}/conventions.md",
806
+ "knowledges/techs/README.md"
807
+ ],
808
+ "errors": [],
809
+ "next_steps": ["Review generated tech documentation"]
810
+ }
811
+ ```
812
+
813
+ ---
814
+
815
+ ## Return Value Structure
816
+
817
+ After all 3 stages complete, return a summary object to the caller:
818
+
819
+ ```json
820
+ {
821
+ "status": "completed",
822
+ "pipeline": "techs",
823
+ "stages": {
824
+ "stage1": { "status": "completed", "platforms": 3 },
825
+ "stage2": { "status": "completed", "completed": 3, "failed": 0 },
826
+ "stage3": { "status": "completed" }
827
+ },
828
+ "output": {
829
+ "index": "speccrew-workspace/knowledges/techs/INDEX.md",
830
+ "manifest": "speccrew-workspace/knowledges/base/sync-state/knowledge-techs/techs-manifest.json"
831
+ }
832
+ }
833
+ ```
834
+
835
+ ---
836
+
837
+ ## CONTINUOUS EXECUTION RULES
838
+
839
+ This skill MUST execute all stages continuously without unnecessary interruptions.
840
+
841
+ ### FORBIDDEN Interruptions
842
+
843
+ 1. DO NOT ask user "Should I continue?" after completing a stage
844
+ 2. DO NOT suggest "Let me split this into batches" or "Let's do this in parts"
845
+ 3. DO NOT pause to list what you plan to do next — just do it
846
+ 4. DO NOT ask for confirmation before generating output files
847
+ 5. DO NOT warn about "large number of files" — proceed with generation
848
+ 6. DO NOT offer "Should I proceed with the remaining items?"
849
+ 7. DO NOT present options like "Full execution / Sample execution / Pause"
850
+
851
+ ### When to Pause (ONLY these cases)
852
+
853
+ 1. Explicit `<event action="confirm">` blocks in the workflow (e.g., platform confirmation if needed)
854
+ 2. Ambiguous requirements that genuinely need clarification
855
+ 3. Unrecoverable errors that prevent further progress (failure rate > 50%)
856
+ 4. Security-sensitive operations (e.g., deleting existing files)
857
+
858
+ ### Batch Execution Behavior
859
+
860
+ - When multiple platforms need processing, process ALL of them without asking
861
+ - Use marker files (.done.json) to track progress, enabling resumption if interrupted by context limits
862
+ - If context window is approaching limit, save progress to checkpoint and inform user how to resume
863
+ - NEVER voluntarily stop mid-batch to ask if user wants to continue