speccrew 0.6.41 → 0.6.42

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.
@@ -75,18 +75,7 @@ You understand the complete AI engineering closed loop: **speccrew-pm → speccr
75
75
 
76
76
  # Workflow (XML Block Definition)
77
77
 
78
- <!--
79
- == Block Types ==
80
- input : Workflow input parameters (required=mandatory, default=default value)
81
- output : Workflow output results (from=data source variable)
82
- task : Execution action (action: run-skill | run-script | dispatch-to-worker)
83
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
84
- loop : Iterate collection (over=collection, as=current item)
85
- event : Log/confirm/signal (action: log | confirm | signal)
86
- error-handler : Exception handling (try > catch > finally)
87
- checkpoint : Persistence milestone (name=checkpoint name, verify=verification condition)
88
- rule : Constraint declaration (level: forbidden | mandatory | note)
89
- -->
78
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
90
79
 
91
80
  ```xml
92
81
  <workflow id="team-leader-main" status="pending">
@@ -105,18 +105,7 @@ Before executing the workflow, verify the following inputs:
105
105
 
106
106
  ## Workflow
107
107
 
108
- <!--
109
- == Block Types ==
110
- input : Workflow input parameters (required=mandatory, default=default value)
111
- output : Workflow output results (from=data source variable)
112
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
113
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
114
- loop : Iterate over collection (over=collection, as=current item)
115
- event : Log/confirm/signal (action: log | confirm | signal)
116
- error-handler : Exception handling (try > catch > finally)
117
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
118
- rule : Constraint declaration (level: forbidden | mandatory | note)
119
- -->
108
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
120
109
 
121
110
  ```xml
122
111
  <workflow name="api-controller-analysis" version="1.0">
@@ -71,18 +71,7 @@ This skill operates in **strict sequential execution mode**:
71
71
 
72
72
  ## Workflow
73
73
 
74
- <!--
75
- == Block Types ==
76
- input : Workflow input parameters (required=mandatory, default=default value)
77
- output : Workflow output results (from=data source variable)
78
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
79
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
80
- loop : Iterate over collection (over=collection, as=current item)
81
- event : Log/confirm/signal (action: log | confirm | signal)
82
- error-handler : Exception handling (try > catch > finally)
83
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
84
- rule : Constraint declaration (level: forbidden | mandatory | note)
85
- -->
74
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
86
75
 
87
76
  ```xml
88
77
  <workflow name="api-knowledge-graph-construction" version="1.0">
@@ -85,20 +85,7 @@ Stage 4: System Summary
85
85
  ## XML Workflow Definition
86
86
 
87
87
  <workflow id="bizs-dispatch-main" status="pending" version="1.0" desc="bizs knowledge base generation 5-stage pipeline">
88
- <!--
89
- == Block Types ==
90
- input : Workflow input parameters (required=mandatory, default=default value)
91
- output : Workflow output results (from=data source variable)
92
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
93
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
94
- loop : Iterate over collection (over=collection, as=current item)
95
- event : Log/confirm/signal (action: log | confirm | signal)
96
- error-handler : Exception handling (try > catch > finally)
97
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
98
- rule : Constraint declaration (level: forbidden | mandatory | note)
99
- == Field ==
100
- field : Parameter/variable/output (name=param name, var=bind variable, value=value)
101
- -->
88
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
102
89
 
103
90
  <!-- ============================================================
104
91
  Input Parameters Definition
@@ -38,18 +38,7 @@ For each platform, generates:
38
38
 
39
39
  ## Workflow
40
40
 
41
- <!--
42
- == Block Types ==
43
- input : Workflow input parameters (required=mandatory, default=default value)
44
- output : Workflow output results (from=data source variable)
45
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
46
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
47
- loop : Iterate over collection (over=collection, as=current item)
48
- event : Log/confirm/signal (action: log | confirm | signal)
49
- error-handler : Exception handling (try > catch > finally)
50
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
51
- rule : Constraint declaration (level: forbidden | mandatory | note)
52
- -->
41
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
53
42
 
54
43
  <workflow>
55
44
 
@@ -76,18 +76,7 @@ Analyze one specific UI feature from source code, extract business functionality
76
76
 
77
77
  ## Workflow
78
78
 
79
- <!--
80
- == Block Types ==
81
- input : Workflow input parameters (required=mandatory, default=default value)
82
- output : Workflow output results (from=data source variable)
83
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
84
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
85
- loop : Iterate over collection (over=collection, as=current item)
86
- event : Log/confirm/signal (action: log | confirm | signal)
87
- error-handler : Exception handling (try > catch > finally)
88
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
89
- rule : Constraint declaration (level: forbidden | mandatory | note)
90
- -->
79
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
91
80
 
92
81
  ```xml
93
82
  <workflow name="ui-feature-analysis" version="1.0">
@@ -44,18 +44,7 @@ This skill automatically adapts to the user's input language. All documentation
44
44
 
45
45
  ## Workflow
46
46
 
47
- <!--
48
- == Block Types ==
49
- input : Workflow input parameters (required=mandatory, default=default value)
50
- output : Workflow output results (from=data source variable)
51
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
52
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
53
- loop : Iterate over collection (over=collection, as=current item)
54
- event : Log/confirm/signal (action: log | confirm | signal)
55
- error-handler : Exception handling (try > catch > finally)
56
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
57
- rule : Constraint declaration (level: forbidden | mandatory | note)
58
- -->
47
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
59
48
 
60
49
  ```xml
61
50
  <workflow name="ui-knowledge-graph-construction" version="1.0">
@@ -68,18 +68,7 @@ Extract and aggregate **UI design patterns** from bizs pipeline analyzed feature
68
68
 
69
69
  ## Workflow
70
70
 
71
- <!--
72
- == Block Types ==
73
- input : Workflow input parameters (required=mandatory, default=default value)
74
- output : Workflow output results (from=data source variable)
75
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
76
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
77
- loop : Iterate over collection (over=collection, as=current item)
78
- event : Log/confirm/signal (action: log | confirm | signal)
79
- error-handler : Exception handling (try > catch > finally)
80
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
81
- rule : Constraint declaration (level: forbidden | mandatory | note)
82
- -->
71
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
83
72
 
84
73
  <workflow>
85
74
 
@@ -51,18 +51,7 @@ flowchart TD
51
51
  Step6 --> End([End])
52
52
  ```
53
53
 
54
- <!--
55
- == Block Types ==
56
- input : Workflow input parameters (required=mandatory, default=default value)
57
- output : Workflow output results (from=data source variable)
58
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
59
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
60
- loop : Iterate over collection (over=collection, as=current item)
61
- event : Log/confirm/signal (action: log | confirm | signal)
62
- error-handler : Exception handling (try > catch > finally)
63
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
64
- rule : Constraint declaration (level: forbidden | mandatory | note)
65
- -->
54
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
66
55
 
67
56
  <workflow>
68
57
  <!-- Input Block: Define workflow inputs -->
@@ -58,18 +58,7 @@ flowchart TD
58
58
  Step8 --> End([End])
59
59
  ```
60
60
 
61
- <!--
62
- == Block Types ==
63
- input : Workflow input parameters (required=mandatory, default=default value)
64
- output : Workflow output results (from=data source variable)
65
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
66
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
67
- loop : Iterate over collection (over=collection, as=current item)
68
- event : Log/confirm/signal (action: log | confirm | signal)
69
- error-handler : Exception handling (try > catch > finally)
70
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
71
- rule : Constraint declaration (level: forbidden | mandatory | note)
72
- -->
61
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
73
62
 
74
63
  <workflow>
75
64
  <!-- Input Block: Define workflow inputs -->
@@ -104,21 +104,9 @@ Read `speccrew-workspace/docs/configs/platform-mapping.json` for standardized pl
104
104
 
105
105
  ## XML Workflow Definition
106
106
 
107
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
108
+
107
109
  <workflow id="techs-dispatch-main" status="pending" version="1.0" desc="techs knowledge base generation 3-stage pipeline">
108
- <!--
109
- == Block Types ==
110
- input : Workflow input parameters (required=mandatory, default=default value)
111
- output : Workflow output results (from=data source variable)
112
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
113
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
114
- loop : Iterate over collection (over=collection, as=current item)
115
- event : Log/confirm/signal (action: log | confirm | signal)
116
- error-handler : Exception handling (try > catch > finally)
117
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
118
- rule : Constraint declaration (level: forbidden | mandatory | note)
119
- == Field ==
120
- field : Parameter/variable/output (name=param name, var=bind variable, value=value)
121
- -->
122
110
 
123
111
  <!-- ============================================================
124
112
  Input Parameters Definition
@@ -72,18 +72,7 @@ Generate the following documents in `{{output_path}}/`:
72
72
 
73
73
  ## Workflow
74
74
 
75
- <!--
76
- == Block Types Schema ==
77
- input : Workflow input parameters (required=mandatory, default=default value)
78
- output : Workflow output results (from=data source variable)
79
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
80
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
81
- loop : Iterate over collection (over=collection, as=current item)
82
- event : Log/confirm/signal (action: log | confirm | signal)
83
- error-handler : Exception handling (try > catch > finally)
84
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
85
- rule : Constraint declaration (level: forbidden | mandatory | note)
86
- -->
75
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
87
76
 
88
77
  ```xml
89
78
  <workflow name="platform-conventions-generation" version="1.0">
@@ -34,20 +34,7 @@ Worker Agent (speccrew-task-worker)
34
34
  ## XML Workflow Definition
35
35
 
36
36
  <workflow id="techs-quality-check" status="pending" version="1.0" desc="Quality assurance for tech documentation">
37
- <!--
38
- == Block Types ==
39
- input : Workflow input parameters (required=mandatory, default=default value)
40
- output : Workflow output results (from=data source variable)
41
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
42
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
43
- loop : Iterate over collection (over=collection, as=current item)
44
- event : Log/confirm/signal (action: log | confirm | signal)
45
- error-handler : Exception handling (try > catch > finally)
46
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
47
- rule : Constraint declaration (level: forbidden | mandatory | note)
48
- == Field ==
49
- field : Parameter/variable/output (name=param name, var=bind variable, value=value)
50
- -->
37
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
51
38
 
52
39
  <!-- ============================================================
53
40
  Input Parameters Definition
@@ -41,20 +41,7 @@ Worker Agent (speccrew-task-worker)
41
41
  ## XML Workflow Definition
42
42
 
43
43
  <workflow id="techs-ui-style-generate" status="pending" version="1.0" desc="Generate UI style documents for frontend platform">
44
- <!--
45
- == Block Types ==
46
- input : Workflow input parameters (required=mandatory, default=default value)
47
- output : Workflow output results (from=data source variable)
48
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
49
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
50
- loop : Iterate over collection (over=collection, as=current item)
51
- event : Log/confirm/signal (action: log | confirm | signal)
52
- error-handler : Exception handling (try > catch > finally)
53
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
54
- rule : Constraint declaration (level: forbidden | mandatory | note)
55
- == Field ==
56
- field : Parameter/variable/output (name=param name, var=bind variable, value=value)
57
- -->
44
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
58
45
 
59
46
  <!-- ============================================================
60
47
  Input Parameters Definition
@@ -38,18 +38,7 @@ Generate comprehensive technology documentation for a specific platform by analy
38
38
 
39
39
  ## Workflow
40
40
 
41
- <!--
42
- == Block Types ==
43
- input : Workflow input parameters (required=mandatory, default=default value)
44
- output : Workflow output results (from=data source variable)
45
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
46
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
47
- loop : Iterate over collection (over=collection, as=current item)
48
- event : Log/confirm/signal (action: log | confirm | signal)
49
- error-handler : Exception handling (try > catch > finally)
50
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
51
- rule : Constraint declaration (level: forbidden | mandatory | note)
52
- -->
41
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
53
42
 
54
43
  <workflow>
55
44
 
@@ -48,18 +48,7 @@ Worker Agent (speccrew-task-worker)
48
48
 
49
49
  ## Workflow
50
50
 
51
- <!--
52
- == Block Types ==
53
- input : Workflow input parameters (required=mandatory, default=default value)
54
- output : Workflow output results (from=data source variable)
55
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
56
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
57
- loop : Iterate over collection (over=collection, as=current item)
58
- event : Log/confirm/signal (action: log | confirm | signal)
59
- error-handler : Exception handling (try > catch > finally)
60
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
61
- rule : Constraint declaration (level: forbidden | mandatory | note)
62
- -->
51
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
63
52
 
64
53
  <workflow>
65
54
 
@@ -41,18 +41,7 @@ Worker Agent (speccrew-task-worker)
41
41
 
42
42
  ## Workflow
43
43
 
44
- <!--
45
- == Block Types ==
46
- input : Workflow input parameters (required=mandatory, default=default value)
47
- output : Workflow output results (from=data source variable)
48
- task : Execute action (action: run-skill | run-script | dispatch-to-worker)
49
- gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
50
- loop : Iterate over collection (over=collection, as=current item)
51
- event : Log/confirm/signal (action: log | confirm | signal)
52
- error-handler : Exception handling (try > catch > finally)
53
- checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
54
- rule : Constraint declaration (level: forbidden | mandatory | note)
55
- -->
44
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `docs/rules/xml-workflow-spec.md`
56
45
 
57
46
  <workflow>
58
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.6.41",
3
+ "version": "0.6.42",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {
@@ -0,0 +1,340 @@
1
+ # XML Workflow Specification
2
+
3
+ > This document defines the XML Block workflow format used in SpecCrew skill and agent definitions.
4
+ > **MANDATORY**: Any agent or worker that encounters XML `<workflow>` blocks MUST read and understand this specification before execution.
5
+
6
+ ## Execution Model
7
+
8
+ This is a **Blockly-style sequential workflow definition**:
9
+
10
+ - Execute blocks **top-to-bottom in document order** within each `<sequence>`
11
+ - Each `<block>` is one atomic execution unit — complete it fully before moving to the next
12
+ - Do NOT skip, reorder, or selectively execute blocks unless a `<gateway>` directs otherwise
13
+ - Nested blocks within a parent block execute in document order
14
+
15
+ ## Block Types
16
+
17
+ ### input
18
+
19
+ Defines workflow input parameters. MUST be the first block in a workflow.
20
+
21
+ ```xml
22
+ <block type="input" id="I1" desc="Workflow input parameters">
23
+ <field name="source_path" required="true" type="string" desc="Source code root directory"/>
24
+ <field name="platform_id" required="true" type="string" desc="Platform identifier, e.g. web-vue"/>
25
+ <field name="output_dir" required="false" type="string" default="${workspace}/output" desc="Output directory"/>
26
+ </block>
27
+ ```
28
+
29
+ - `required="true"`: Caller MUST provide this parameter
30
+ - `default`: Used when `required="false"` and caller omits the value
31
+ - Input fields automatically become workflow-scoped variables
32
+
33
+ ### output
34
+
35
+ Defines workflow output results. MUST be the last block in a workflow.
36
+
37
+ ```xml
38
+ <block type="output" id="O1" desc="Workflow output results">
39
+ <field name="matched_modules" from="${matcherResult.matched_modules}" type="array" desc="Matched module list"/>
40
+ <field name="execution_path" from="${executionPath}" type="string" desc="Execution path A or B"/>
41
+ </block>
42
+ ```
43
+
44
+ - `from`: Reference to the variable containing the output value
45
+
46
+ ### task
47
+
48
+ Executes an action. The primary execution block.
49
+
50
+ **Action Types:**
51
+
52
+ | Action | Purpose | Required Fields |
53
+ |--------|---------|-----------------|
54
+ | `run-skill` | Invoke a skill | `<field name="skill">` |
55
+ | `run-script` | Execute a command | `<field name="command">` |
56
+ | `dispatch-to-worker` | Delegate to a worker agent | `<field name="agent">` |
57
+ | `analyze` | Perform analysis | Context fields |
58
+ | `generate` | Generate content | Output path |
59
+ | `read-file` | Read file content | `<field name="path">` |
60
+ | `write-file` | Write file content | `<field name="path">`, content |
61
+
62
+ **Examples:**
63
+
64
+ ```xml
65
+ <!-- Run a skill -->
66
+ <block type="task" id="B1" action="run-skill" desc="Execute module matcher skill">
67
+ <field name="skill">speccrew-knowledge-module-matcher</field>
68
+ <field name="source_path" value="${source_path}"/>
69
+ <field name="output" var="matcherResult"/>
70
+ </block>
71
+
72
+ <!-- Run a script -->
73
+ <block type="task" id="B2" action="run-script" desc="Check knowledge directory">
74
+ <field name="command">node scripts/check-knowledge.js --dir ${knowledgeDir}</field>
75
+ <field name="output" var="checkResult"/>
76
+ </block>
77
+
78
+ <!-- Dispatch to worker -->
79
+ <block type="task" id="B3" action="dispatch-to-worker" desc="Dispatch worker for analysis">
80
+ <field name="agent">speccrew-task-worker</field>
81
+ <field name="skill_path">${task.skill_path}/SKILL.md</field>
82
+ <field name="context">{"module": "${task.module}"}</field>
83
+ </block>
84
+ ```
85
+
86
+ ### gateway
87
+
88
+ Conditional branching and guard checks.
89
+
90
+ **Modes:**
91
+
92
+ | Mode | Behavior |
93
+ |------|----------|
94
+ | `exclusive` | Execute ONLY the first matching `<branch>` |
95
+ | `guard` | Continue if `test` passes, otherwise execute `fail-action` |
96
+ | `parallel` | Execute ALL branches concurrently |
97
+
98
+ **Exclusive Gateway:**
99
+
100
+ ```xml
101
+ <block type="gateway" id="G1" mode="exclusive" desc="Select execution path">
102
+ <branch test="${knowledgeStatus.exists} == true" name="Incremental Update">
103
+ <block type="task" action="run-skill" desc="Run incremental sync">...</block>
104
+ </branch>
105
+ <branch test="${knowledgeStatus.exists} == false" name="Full Init">
106
+ <block type="task" action="run-skill" desc="Run full initialization">...</block>
107
+ </branch>
108
+ <branch default="true" name="Fallback">
109
+ <block type="event" action="log" level="error">Unknown state</block>
110
+ </branch>
111
+ </block>
112
+ ```
113
+
114
+ **Guard Gateway:**
115
+
116
+ ```xml
117
+ <block type="gateway" id="G2" mode="guard"
118
+ test="${matcherResult.matched_modules.length} > 0"
119
+ fail-action="stop"
120
+ desc="Validate at least one module matched">
121
+ <field name="message">No modules matched. Check source path and platform config.</field>
122
+ </block>
123
+ ```
124
+
125
+ - `fail-action`: `stop` | `retry` | `skip` | `fallback`
126
+
127
+ **Parallel Gateway:**
128
+
129
+ ```xml
130
+ <block type="gateway" id="G3" mode="parallel" desc="Execute all branches concurrently">
131
+ <branch name="Analyze users">
132
+ <block type="task" action="dispatch-to-worker">...</block>
133
+ </branch>
134
+ <branch name="Analyze orders">
135
+ <block type="task" action="dispatch-to-worker">...</block>
136
+ </branch>
137
+ </block>
138
+ ```
139
+
140
+ ### loop
141
+
142
+ Iterate over a collection.
143
+
144
+ ```xml
145
+ <block type="loop" id="L1" over="${tasks}" as="task"
146
+ parallel="true" max-concurrency="5"
147
+ desc="Process each task">
148
+ <block type="task" action="dispatch-to-worker" desc="Dispatch worker for ${task.name}">
149
+ <field name="agent">speccrew-task-worker</field>
150
+ <field name="skill_path">${task.skill_path}/SKILL.md</field>
151
+ </block>
152
+ </block>
153
+ ```
154
+
155
+ - `over`: Collection variable to iterate (e.g., `${tasks}`)
156
+ - `as`: Variable name for current item (e.g., `task` → use as `${task}`)
157
+ - `parallel="true"`: Execute all iterations concurrently
158
+ - `max-concurrency`: Limit concurrent executions
159
+
160
+ ### event
161
+
162
+ Logging, confirmation, and signaling.
163
+
164
+ ```xml
165
+ <!-- Log event -->
166
+ <block type="event" action="log" level="info" desc="Log progress">
167
+ Processing ${tasks.length} tasks
168
+ </block>
169
+
170
+ <!-- Confirm event (pauses for user input) -->
171
+ <block type="event" action="confirm" title="Confirm modules" type="yesno" desc="Wait for user confirmation">
172
+ <field name="preview">Matched ${matcherResult.matched_modules.length} modules. Continue?</field>
173
+ <on-confirm>
174
+ <field name="confirmed" value="true"/>
175
+ </on-confirm>
176
+ <on-cancel>
177
+ <field name="workflow.status" value="cancelled"/>
178
+ </on-cancel>
179
+ </block>
180
+ ```
181
+
182
+ - `action`: `log` | `confirm` | `signal`
183
+ - `level` (for log): `debug` | `info` | `warn` | `error`
184
+
185
+ ### error-handler
186
+
187
+ Try/catch/finally error handling.
188
+
189
+ ```xml
190
+ <block type="error-handler" id="EH1" desc="Handle worker dispatch errors">
191
+ <try>
192
+ <block type="loop" over="${tasks}" as="task">
193
+ <block type="task" action="dispatch-to-worker">...</block>
194
+ </block>
195
+ </try>
196
+ <catch error-type="timeout">
197
+ <block type="event" action="log" level="error">Timeout: ${error.taskId}</block>
198
+ </catch>
199
+ <catch>
200
+ <block type="event" action="log" level="error">Unexpected: ${error.message}</block>
201
+ </catch>
202
+ <finally>
203
+ <block type="event" action="log" level="info">Batch completed</block>
204
+ </finally>
205
+ </block>
206
+ ```
207
+
208
+ ### checkpoint
209
+
210
+ Persist progress milestone. Supports resume-from-checkpoint.
211
+
212
+ ```xml
213
+ <block type="checkpoint" id="CP1" name="matcher_completed" desc="Module matching done">
214
+ <field name="file" value="${progressFile}"/>
215
+ <field name="verify" value="${matcherResult.matched_modules.length} > 0"/>
216
+ </block>
217
+ ```
218
+
219
+ - `name`: Unique checkpoint identifier for the progress file
220
+ - `verify`: Condition to evaluate; if true, checkpoint is marked as `passed`
221
+ - During resume, skip all blocks until the first non-passed checkpoint
222
+
223
+ ### rule
224
+
225
+ Declare constraints. NOT an action block — these are enforced continuously.
226
+
227
+ **Levels:**
228
+
229
+ | Level | Meaning |
230
+ |-------|---------|
231
+ | `forbidden` | MUST NOT do this. Violation causes immediate stop. |
232
+ | `mandatory` | MUST do this. Required for correctness. |
233
+ | `note` | Guidance hint. Recommended but not enforced. |
234
+
235
+ ```xml
236
+ <!-- FORBIDDEN rules -->
237
+ <block type="rule" id="R1" level="forbidden" desc="Phase 4 constraints">
238
+ <field name="text">DO NOT generate Sub-PRDs yourself — MUST dispatch Workers</field>
239
+ <field name="text">DO NOT use create_file to manually create progress JSON</field>
240
+ <field name="text">DO NOT fabricate timestamps — let scripts generate them</field>
241
+ </block>
242
+
243
+ <!-- MANDATORY rules -->
244
+ <block type="rule" id="R2" level="mandatory" desc="Execution sequence gate">
245
+ <field name="text">MUST execute B2→B3→B4→B5 in order, no skipping</field>
246
+ </block>
247
+ ```
248
+
249
+ **Placement**: Put `<rule>` blocks directly before the steps they govern. This ensures the LLM "sees" the constraint when executing those steps.
250
+
251
+ ## Variable References
252
+
253
+ Use `${variable_name}` syntax throughout block attributes and content.
254
+
255
+ ```xml
256
+ <!-- Simple variable -->
257
+ <field name="platform" value="${platform_id}"/>
258
+
259
+ <!-- Object property -->
260
+ <field name="count" value="${matcherResult.matched_modules.length}"/>
261
+
262
+ <!-- Array index -->
263
+ <field name="first" value="${matcherResult.matched_modules[0].name}"/>
264
+ ```
265
+
266
+ **Built-in Variables:**
267
+
268
+ | Variable | Description |
269
+ |----------|-------------|
270
+ | `${workspace}` | Workspace root directory |
271
+ | `${platform}` | Current platform identifier |
272
+ | `${timestamp}` | Current ISO timestamp |
273
+ | `${workflow.id}` | Current workflow ID |
274
+ | `${workflow.status}` | Current workflow status |
275
+
276
+ ## Common Patterns
277
+
278
+ ### Sequential Pipeline
279
+
280
+ ```xml
281
+ <workflow id="pipeline" status="pending">
282
+ <block type="input" id="I1">...</block>
283
+ <sequence id="S1">
284
+ <block type="task" id="B1" action="run-skill">...</block>
285
+ <block type="task" id="B2" action="run-script">...</block>
286
+ <block type="task" id="B3" action="dispatch-to-worker">...</block>
287
+ </sequence>
288
+ <block type="output" id="O1">...</block>
289
+ </workflow>
290
+ ```
291
+
292
+ ### Conditional Branching
293
+
294
+ ```xml
295
+ <block type="gateway" mode="exclusive" desc="Route based on result">
296
+ <branch test="${result.count} > 10" name="Many items">
297
+ <block type="task" action="run-skill" desc="Batch process">...</block>
298
+ </branch>
299
+ <branch default="true" name="Few items">
300
+ <block type="task" action="run-skill" desc="Single process">...</block>
301
+ </branch>
302
+ </block>
303
+ ```
304
+
305
+ ### Parallel Worker Dispatch
306
+
307
+ ```xml
308
+ <block type="loop" over="${modules}" as="module" parallel="true" max-concurrency="5">
309
+ <block type="task" action="dispatch-to-worker" desc="Analyze ${module.name}">
310
+ <field name="agent">speccrew-analyzer</field>
311
+ <field name="context">{"module": "${module.name}"}</field>
312
+ </block>
313
+ </block>
314
+ ```
315
+
316
+ ### Error Recovery
317
+
318
+ ```xml
319
+ <block type="error-handler" desc="Robust processing">
320
+ <try>
321
+ <block type="task" action="run-skill" desc="Primary operation">...</block>
322
+ </try>
323
+ <catch error-type="timeout">
324
+ <block type="task" action="run-skill" desc="Fallback operation">...</block>
325
+ </catch>
326
+ <finally>
327
+ <block type="checkpoint" name="done" desc="Mark complete">...</block>
328
+ </finally>
329
+ </block>
330
+ ```
331
+
332
+ ## Execution Rules
333
+
334
+ 1. **NEVER skip a block** — execute every block in document order
335
+ 2. **Read `rule` blocks as constraints** — check them continuously during execution
336
+ 3. **`checkpoint` blocks** = persist progress before continuing
337
+ 4. **`gateway mode="exclusive"`** = only execute the first matching branch
338
+ 5. **`loop parallel="true"`** = dispatch all iterations concurrently
339
+ 6. **`rule level="forbidden"`** = immediate stop if violated
340
+ 7. **Input/Output blocks** define the contract — respect required parameters