speccrew 0.7.25 → 0.7.27

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.
@@ -112,9 +112,11 @@ When Worker loads a skill (via `skill_name` or `skill_path` parameter):
112
112
  **If `skill_path` or `skill_name` is provided:**
113
113
  1. If `skill_path` is provided, use it directly; otherwise use Skill Discovery
114
114
  2. If Skill file does not exist, immediately report error
115
- 3. If `context` parameters exist, substitute them into placeholders in the Skill
116
- 4. Strictly execute according to the workflow defined in the Skill
117
- 5. Complete the task and output results
115
+ 3. **Read SKILL.md** to understand skill overview, constraints, and templates
116
+ 4. **Read workflow.agentflow.xml** this is the AUTHORITATIVE execution definition
117
+ 5. If `context` parameters exist, substitute them into placeholders
118
+ 6. **Execute blocks defined in workflow.agentflow.xml sequentially** (top-to-bottom, announcing each block)
119
+ 7. Complete the task and output results
118
120
 
119
121
  > 🛑 **CRITICAL — Skill Execution Enforcement**:
120
122
  > - If the Skill specifies script execution via `run_in_terminal` or `Bash` → You MUST execute the script via terminal. DO NOT substitute with manual file creation.
@@ -122,6 +124,23 @@ When Worker loads a skill (via `skill_name` or `skill_path` parameter):
122
124
  > - If the Skill contains MANDATORY/FORBIDDEN constraints → You MUST follow them strictly.
123
125
  > - DO NOT improvise alternative execution paths. If a step fails, report the error — do not attempt workarounds.
124
126
 
127
+ ### MANDATORY: XML Workflow Loading Protocol
128
+
129
+ When executing any Skill that contains `workflow.agentflow.xml`:
130
+
131
+ 1. **SKILL.md is METADATA ONLY** — it provides overview, constraints, and template references. It is NOT the execution plan.
132
+ 2. **workflow.agentflow.xml is the AUTHORITATIVE execution plan** — Worker MUST read this file and execute its blocks in sequential document order.
133
+ 3. **FORBIDDEN**: Starting task execution based solely on SKILL.md without reading workflow.agentflow.xml.
134
+ 4. **FORBIDDEN**: Summarizing or paraphrasing the workflow — execute blocks exactly as defined.
135
+ 5. **FORBIDDEN**: Skipping, reordering, or merging blocks.
136
+
137
+ **Execution sequence:**
138
+ ```
139
+ Read SKILL.md → Read workflow.agentflow.xml → Execute blocks in XML order → Report results
140
+ ```
141
+
142
+ If workflow.agentflow.xml does not exist in the skill directory, fall back to SKILL.md-based execution.
143
+
125
144
  ### XML Workflow Block Announcement Protocol
126
145
 
127
146
  When executing a Skill that uses XML workflow format (`<workflow>` root element), you MUST follow the Block Execution Announcement Protocol defined in `docs/rules/agentflow-spec.md`:
@@ -211,10 +230,14 @@ When the task fails or is blocked, output:
211
230
  **MUST DO:**
212
231
  - If `skill_name` is provided, MUST use Skill Discovery to resolve the full path and strictly follow the Skill definition
213
232
  - If `skill_name` is provided but Skill file does not exist, immediately report error
233
+ - If Skill directory contains workflow.agentflow.xml, MUST read it and execute blocks in sequential order — this is the authoritative execution plan
234
+ - MUST announce each XML block before execution using the Block Announcement Protocol
214
235
  - Only process the single task assigned to the current Worker
215
236
 
216
237
  **MUST NOT DO:**
217
238
  - Do not skip or ignore a provided Skill file
239
+ - Do not execute tasks based solely on SKILL.md when workflow.agentflow.xml exists — the XML workflow is authoritative
240
+ - Do not skip reading workflow.agentflow.xml even if SKILL.md seems sufficient
218
241
  - Do not actively modify code beyond the task scope
219
242
  - Do not overstep to handle other tasks
220
243
  - Do not assume context information not provided
@@ -31,6 +31,12 @@ Applies workspace initialization principles:
31
31
  - Progress tracking via WORKFLOW-PROGRESS.json
32
32
  - Checkpoint recovery for session continuity
33
33
 
34
+ ## Templates Used
35
+
36
+ | Template | Path | Purpose |
37
+ |----------|------|---------|
38
+ | WORKFLOW-PROGRESS | `templates/WORKFLOW-PROGRESS-TEMPLATE.json` | Standard workflow progress tracking with 7 predefined stages |
39
+
34
40
  ## Output Deliverables
35
41
 
36
42
  | Deliverable | Path | Description |
@@ -68,9 +74,15 @@ Applies workspace initialization principles:
68
74
  - Compute all path variables as absolute paths
69
75
  - Check for active iteration before creating new one
70
76
  - Copy requirement document to iteration's 00.docs directory
77
+ - Create EXACTLY two subdirectories: `00.docs/` (original requirement documents) and `01.product-requirement/` (PRD and clarification outputs)
78
+ - Initialize `WORKFLOW-PROGRESS.json` from `WORKFLOW-PROGRESS-TEMPLATE.json` template — stage names MUST match template exactly (01_prd, 02_feature_design, etc.)
71
79
 
72
80
  **Must not do:**
73
81
  - Manually create WORKFLOW-PROGRESS.json via Write/Edit tools
74
82
  - Skip checkpoint recovery check
75
83
  - Use relative paths in Worker dispatches
76
84
  - Create iteration directory without proper naming convention
85
+ - Pre-create directories for later phases (`02.feature-design/`, `03.system-design/`, `04.development/`, `05.deployment/`, `06.system-test/`, `07.delivery/`) — each phase creates its own directory when needed
86
+ - Invent directory names not defined in `workspace-structure.md`
87
+ - Manually write WORKFLOW-PROGRESS.json content — MUST use template + update-progress.js script
88
+ - Invent custom stage names (e.g., phase0_initialization, phase1_requirement_analysis) — use template-defined names only
@@ -0,0 +1,56 @@
1
+ {
2
+ "created_at": "{created_at}",
3
+ "updated_at": "{updated_at}",
4
+ "current_stage": null,
5
+ "stages": {
6
+ "01_prd": {
7
+ "status": "pending",
8
+ "started_at": null,
9
+ "completed_at": null,
10
+ "confirmed_at": null,
11
+ "output": null
12
+ },
13
+ "02_feature_design": {
14
+ "status": "pending",
15
+ "started_at": null,
16
+ "completed_at": null,
17
+ "confirmed_at": null,
18
+ "output": null
19
+ },
20
+ "03_system_design": {
21
+ "status": "pending",
22
+ "started_at": null,
23
+ "completed_at": null,
24
+ "confirmed_at": null,
25
+ "output": null
26
+ },
27
+ "04_development": {
28
+ "status": "pending",
29
+ "started_at": null,
30
+ "completed_at": null,
31
+ "confirmed_at": null,
32
+ "output": null
33
+ },
34
+ "05_deployment": {
35
+ "status": "pending",
36
+ "started_at": null,
37
+ "completed_at": null,
38
+ "confirmed_at": null,
39
+ "output": null
40
+ },
41
+ "06_system_test": {
42
+ "status": "pending",
43
+ "started_at": null,
44
+ "completed_at": null,
45
+ "confirmed_at": null,
46
+ "output": null
47
+ },
48
+ "07_delivery": {
49
+ "status": "pending",
50
+ "started_at": null,
51
+ "completed_at": null,
52
+ "confirmed_at": null,
53
+ "output": null
54
+ }
55
+ }
56
+ }
@@ -19,6 +19,8 @@
19
19
  <field name="text">ALL WORKFLOW-PROGRESS.json operations MUST use update-progress.js script</field>
20
20
  <field name="text">ALL path variables MUST be absolute paths</field>
21
21
  <field name="text">Check for active iteration before creating new one</field>
22
+ <field name="text">Phase 0 MUST create EXACTLY TWO subdirectories: 00.docs and 01.product-requirement</field>
23
+ <field name="text">FORBIDDEN: Pre-creating directories for later phases (02.feature-design, 03.system-design, 04.development, etc.). Each phase creates its own directory when needed.</field>
22
24
  </block>
23
25
 
24
26
  <block type="rule" id="R2" level="forbidden" desc="Phase 0 Forbidden Actions">
@@ -118,7 +120,24 @@
118
120
  <block type="task" id="P0-1-B9" action="run-script" status="pending" desc="Copy requirement document to iteration">
119
121
  <field name="command">Copy-Item "${user_requirement}" "${iteration_path}/00.docs/" -ErrorAction SilentlyContinue</field>
120
122
  </block>
121
-
123
+
124
+ <!-- Step 2.7: Load WORKFLOW-PROGRESS template -->
125
+ <block type="task" id="P0-1-B9A" action="read-file" status="pending" desc="Load WORKFLOW-PROGRESS template">
126
+ <field name="path" value="${skill_path}/templates/WORKFLOW-PROGRESS-TEMPLATE.json"/>
127
+ <field name="output" var="workflow_progress_template"/>
128
+ </block>
129
+
130
+ <!-- Step 2.8: Generate initial WORKFLOW-PROGRESS.json from template -->
131
+ <block type="task" id="P0-1-B9B" action="generate" status="pending" desc="Create WORKFLOW-PROGRESS.json from template">
132
+ <field name="template" value="${workflow_progress_template}"/>
133
+ <field name="output_path" value="${iteration_path}/WORKFLOW-PROGRESS.json"/>
134
+ <field name="vars">
135
+ - created_at: ${current_timestamp}
136
+ - updated_at: ${current_timestamp}
137
+ </field>
138
+ <field name="output" var="workflow_progress_path"/>
139
+ </block>
140
+
122
141
  <!-- Step 0.1.1: Initialize WORKFLOW-PROGRESS.json -->
123
142
  <block type="task" id="P0-1-B10" action="run-script" status="pending" desc="Initialize WORKFLOW-PROGRESS.json via script">
124
143
  <!-- MANDATORY: Use update-progress.js script -->
@@ -35,10 +35,37 @@ Applies ISA-95 Stage 1 (Domain Description) for clarification:
35
35
 
36
36
  ## Templates Used
37
37
 
38
- | Template | Path | Purpose |
39
- |----------|------|---------|
40
- | Clarification Questions | `templates/CLARIFICATION-QUESTIONS-TEMPLATE.md` | Round-based questionnaire for user clarification |
41
- | Clarification Summary | `templates/CLARIFICATION-SUMMARY-TEMPLATE.md` | Final summary document with all Q&A and decisions |
38
+ | Template | Path | When to Load | Purpose |
39
+ |----------|------|-------------|----------|
40
+ | Clarification Questions | `templates/CLARIFICATION-QUESTIONS-TEMPLATE.md` | **Inside Loop L1** (each round) | Round-based questionnaire for user clarification |
41
+ | Clarification Summary | `templates/CLARIFICATION-SUMMARY-TEMPLATE.md` | **After G3 guard passes** (sufficiency_checks_passed == true) | Final summary document with all Q&A and decisions |
42
+
43
+ > **CRITICAL**: These two templates are used in **separate phases**. NEVER load both templates at the same time.
44
+ > - During the clarification loop: ONLY load `CLARIFICATION-QUESTIONS-TEMPLATE.md`
45
+ > - After ALL sufficiency checks pass: ONLY then load `CLARIFICATION-SUMMARY-TEMPLATE.md`
46
+
47
+ ## Execution Flow (MANDATORY sequence)
48
+
49
+ ```
50
+ Step 1: Read requirement document
51
+ Step 2: Read system knowledge (if exists)
52
+ Step 3: Determine complexity mode (simple/complex/auto-detect)
53
+ Step 4: Initialize loop variables
54
+ Step 5: Clarification Loop (both simple and complex modes):
55
+ 5a. Load CLARIFICATION-QUESTIONS-TEMPLATE.md (ONLY this template)
56
+ 5b. Generate .clarification-questions-round-{N}.md from template
57
+ 5c. *** HARD STOP *** Wait for user to answer questions (user-confirm event)
58
+ 5d. Read user's answered questions file
59
+ 5e. Perform sufficiency checks (MUST have real user answers)
60
+ 5f. If checks fail and rounds remain → back to 5a
61
+ 5g. If checks pass → exit loop
62
+ Step 6: Guard Gateway G3 (sufficiency_checks_passed == true required)
63
+ 6a. Load CLARIFICATION-SUMMARY-TEMPLATE.md (ONLY now)
64
+ 6b. Generate .clarification-summary.md from template
65
+ 6c. Checkpoint: clarification complete
66
+ ```
67
+
68
+ > **FORBIDDEN**: Skipping Step 5c (user-confirm), loading summary template during Step 5, or generating summary without user answers.
42
69
 
43
70
  ---
44
71
 
@@ -86,19 +86,58 @@
86
86
  <!-- Step 5: Execute Clarification -->
87
87
  <block type="gateway" id="G2" mode="exclusive" desc="Execute clarification based on mode">
88
88
  <branch test="${complexity} == 'simple'" name="Simple Mode Clarification">
89
- <block type="task" id="B6" action="analyze" desc="Simple mode: 1-3 key questions">
90
- <field name="topics">
91
- - What to change
92
- - What the change is
93
- - Business reason
94
- - Acceptance criteria
89
+ <!-- Simple mode: 1 round of key clarification questions -->
90
+ <block type="rule" id="R-SIMPLE-TEMPLATE" level="mandatory" desc="Simple mode also uses template">
91
+ <field name="text">MANDATORY: Even in simple mode, clarification questions MUST be generated from CLARIFICATION-QUESTIONS-TEMPLATE.md template.</field>
92
+ <field name="text">Simple mode generates 1-3 key questions focusing on: scope, acceptance criteria, and business reason.</field>
93
+ </block>
94
+
95
+ <block type="task" id="B6-load-template" action="read-file" desc="Load clarification questions template for simple mode">
96
+ <field name="path" value="${skill_path}/templates/CLARIFICATION-QUESTIONS-TEMPLATE.md"/>
97
+ <field name="output" var="questions_template"/>
98
+ </block>
99
+
100
+ <block type="task" id="B6" action="generate" desc="Simple mode: generate 1-3 key clarification questions from template">
101
+ <field name="template" value="${questions_template}"/>
102
+ <field name="output_path" value="${iteration_path}/01.product-requirement/.clarification-questions-round-1.md"/>
103
+ <field name="vars">
104
+ - round_number: 1
105
+ - iteration_name: ${iteration_name}
106
+ - date: ${current_date}
107
+ - complexity_level: simple
108
+ - requirement_summary: ${requirement_summary}
95
109
  </field>
96
- <field name="output" var="clarification_qa"/>
110
+ <field name="guidance">Simple mode: generate only 1-3 key questions focusing on scope boundaries, acceptance criteria, and business reason. Remove unused category sections from template.</field>
111
+ <field name="output" var="questions_file"/>
112
+ </block>
113
+
114
+ <block type="rule" id="R-SIMPLE-CONFIRM" level="mandatory" desc="User must answer even in simple mode">
115
+ <field name="text">MANDATORY: User-confirm event below is a HARD STOP. Worker MUST pause and wait for user response.</field>
116
+ </block>
117
+
118
+ <block type="event" id="E-SIMPLE-CONFIRM" action="user-confirm" desc="Wait for user to answer simple clarification questions">
119
+ <field name="prompt">📋 澄清问题已生成 (简单模式): ${questions_file}
120
+
121
+ 请:
122
+ 1. 查看澄清问题文件
123
+ 2. 在文件中填写您的答案
124
+ 3. 填写完成后确认继续</field>
125
+ <field name="skippable" value="false"/>
126
+ </block>
127
+
128
+ <block type="task" id="B6-read-answers" action="read-file" desc="Read user answers for simple mode">
129
+ <field name="path" value="${questions_file}"/>
130
+ <field name="output" var="answered_questions"/>
131
+ </block>
132
+
133
+ <block type="task" id="B6-mark-complete" action="set-var" desc="Mark simple mode clarification as complete">
134
+ <field name="sufficiency_checks_passed" value="true"/>
97
135
  </block>
98
136
  </branch>
99
137
  <branch test="${complexity} == 'complex'" name="Complex Mode Clarification">
100
138
  <!-- Clarification Loop -->
101
139
  <block type="loop" id="L1" condition="sufficiency_checks_passed == false AND round_number <= max_rounds" desc="Clarification rounds until sufficiency">
140
+ <!-- ========== PHASE A: Generate Questions (ONLY questions template loaded here) ========== -->
102
141
  <!-- MANDATORY: Template-based generation rule -->
103
142
  <block type="rule" id="R-TEMPLATE-GENERATION" level="mandatory" desc="Template-based generation is MANDATORY">
104
143
  <field name="text">MANDATORY: Clarification questions MUST be generated by loading the template file and performing variable substitution.</field>
@@ -125,6 +164,7 @@
125
164
  <field name="output" var="questions_file"/>
126
165
  </block>
127
166
 
167
+ <!-- ========== PHASE B: HARD STOP - Wait for User Answers ========== -->
128
168
  <!-- MANDATORY: User confirmation cannot be bypassed -->
129
169
  <block type="rule" id="R-USER-CONFIRM-MANDATORY" level="mandatory" desc="User-confirm events MUST pause Worker execution">
130
170
  <field name="text">MANDATORY: The following user-confirm event is a HARD STOP. Worker MUST pause and present the prompt to user.</field>
@@ -143,6 +183,7 @@
143
183
  <field name="skippable" value="false"/>
144
184
  </block>
145
185
 
186
+ <!-- ========== PHASE C: Read Answers and Check Sufficiency ========== -->
146
187
  <block type="task" id="B8" action="read-file" desc="Read answered questions">
147
188
  <field name="path" value="${questions_file}"/>
148
189
  <field name="output" var="answered_questions"/>
@@ -178,6 +219,16 @@
178
219
  <block type="task" id="B9-increment" action="set-var" desc="Increment round counter">
179
220
  <field name="round_number" value="${round_number + 1}"/>
180
221
  </block>
222
+ <!-- ========== END OF LOOP ITERATION - Summary template is NOT loaded here ========== -->
223
+ </block>
224
+ </branch>
225
+ <branch default="true" name="ERROR: Unknown Complexity">
226
+ <block type="task" id="B-COMPLEXITY-ERROR" action="set-variable" desc="Handle unknown complexity value">
227
+ <field name="error_type">UNKNOWN_COMPLEXITY</field>
228
+ <field name="error_message">Complexity mode could not be determined. Value: ${complexity}. Expected 'simple' or 'complex'.</field>
229
+ </block>
230
+ <block type="event" id="E-COMPLEXITY-ABORT" action="abort" desc="Abort: unknown complexity">
231
+ <field name="message">Cannot proceed: complexity mode is '${complexity}', expected 'simple' or 'complex'.</field>
181
232
  </block>
182
233
  </branch>
183
234
  </block>
@@ -194,6 +245,8 @@
194
245
  <!-- Step 6: Generate .clarification-summary.md (Guarded by G3) -->
195
246
  <block type="gateway" id="G3" mode="exclusive" desc="Guard: Only generate summary if sufficiency checks passed">
196
247
  <branch test="${sufficiency_checks_passed} == true" name="Sufficiency Passed - Generate Summary">
248
+ <!-- ========== SUMMARY GENERATION (Only reached when ALL sufficiency checks passed) ========== -->
249
+ <!-- NOTE: Summary template is loaded HERE, not in the loop above. This is intentional. -->
197
250
  <block type="task" id="B10-load-template" action="read-file" desc="Load summary template">
198
251
  <field name="path" value="${skill_path}/templates/CLARIFICATION-SUMMARY-TEMPLATE.md"/>
199
252
  <field name="output" var="summary_template"/>
@@ -223,10 +276,15 @@
223
276
  <field name="verify" value="file_exists(${summary_path})"/>
224
277
  </block>
225
278
  </branch>
226
- <branch default="true" name="Sufficiency Failed - Exit with Error">
227
- <block type="task" id="B-INSUFFICIENCY-EXIT" action="set-variable" desc="Set error status for insufficient clarification">
228
- <field name="error_type">INSUFFICIENT_CLARIFICATION</field>
229
- <field name="message">Requirement clarification did not achieve sufficiency. Worker exits and returns control to PM Agent.</field>
279
+ <branch default="true" name="Sufficiency Failed - Abort Workflow">
280
+ <block type="rule" id="R-ABORT-RULE" level="mandatory" desc="Abort when sufficiency failed">
281
+ <field name="text">MANDATORY: sufficiency_checks_passed is false. Worker MUST abort workflow immediately.</field>
282
+ <field name="text">DO NOT attempt to generate .clarification-summary.md.</field>
283
+ <field name="text">Return control to PM Agent with error status.</field>
284
+ </block>
285
+ <block type="event" id="E-INSUFFICIENCY-ABORT" action="abort" desc="Abort: sufficiency checks failed after all rounds">
286
+ <field name="message">Requirement clarification did not achieve sufficient clarity after ${round_number - 1} round(s). Returning control to PM Agent for user intervention.</field>
287
+ <field name="error_code">CLARIFICATION_INSUFFICIENT</field>
230
288
  </block>
231
289
  </branch>
232
290
  </block>
@@ -134,7 +134,21 @@
134
134
  <field name="output" var="skill_definition"/>
135
135
  </block>
136
136
  <block type="event" id="E8" action="log" desc="加载技能">📄 Loaded skill: ${resolved_skill_path}</block>
137
+
138
+ <!-- MANDATORY: Load XML Workflow Definition -->
139
+ <block type="rule" id="R-WORKFLOW-FIRST" level="mandatory" desc="XML workflow is the authoritative execution definition">
140
+ <field name="text">MANDATORY: workflow.agentflow.xml is the AUTHORITATIVE execution definition. SKILL.md is supplementary context only.</field>
141
+ <field name="text">Worker MUST read workflow.agentflow.xml BEFORE starting any task execution.</field>
142
+ <field name="text">Worker MUST execute ONLY the blocks defined in workflow.agentflow.xml, in sequential document order.</field>
143
+ <field name="text">FORBIDDEN: Executing tasks based solely on SKILL.md description without reading the XML workflow.</field>
144
+ </block>
137
145
 
146
+ <block type="task" id="T6b" action="read-file" desc="MANDATORY: Read XML workflow definition">
147
+ <field name="path">${skill_path}/workflow.agentflow.xml</field>
148
+ <field name="output" var="skill_workflow_xml"/>
149
+ </block>
150
+ <block type="event" id="E8b" action="log" desc="Loaded XML workflow">📄 Loaded workflow: ${skill_path}/workflow.agentflow.xml — This is the AUTHORITATIVE execution plan. Execute blocks in document order.</block>
151
+
138
152
  <!-- 加载 AgentFlow 规范 -->
139
153
  <block type="task" id="T7" action="read-file" desc="读取 AgentFlow 规范">
140
154
  <field name="path">${workspace_root}/speccrew-workspace/docs/rules/agentflow-spec.md</field>
@@ -143,10 +157,12 @@
143
157
  <block type="event" id="E9" action="log" desc="加载规范">📖 Loaded AgentFlow specification</block>
144
158
 
145
159
  <!-- 执行技能工作流 -->
146
- <block type="task" id="T8" action="run-skill" desc="执行技能工作流">
160
+ <block type="task" id="T8" action="run-skill" desc="Execute skill workflow — follow XML blocks sequentially">
147
161
  <field name="skill">${resolved_skill_path}</field>
148
162
  <field name="context">${context}</field>
149
163
  <field name="skill_path">${skill_path}</field>
164
+ <field name="workflow_xml">${skill_workflow_xml}</field>
165
+ <field name="execution_mode">xml-block-sequential</field>
150
166
  </block>
151
167
  <field name="execution_status" value="success"/>
152
168
  </branch>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.7.25",
3
+ "version": "0.7.27",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {