speccrew 0.6.68 → 0.7.0

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.
Files changed (134) hide show
  1. package/.speccrew/agents/speccrew-task-worker.md +1 -1
  2. package/.speccrew/agents/speccrew-team-leader.md +336 -189
  3. package/.speccrew/skills/speccrew-agentflow-manager/SKILL.md +161 -0
  4. package/.speccrew/skills/speccrew-agentflow-manager/workflow.agentflow.xml +347 -0
  5. package/.speccrew/skills/speccrew-deploy-build/SKILL.md +3 -56
  6. package/.speccrew/skills/speccrew-deploy-build/workflow.agentflow.xml +125 -0
  7. package/.speccrew/skills/speccrew-deploy-migrate/SKILL.md +3 -64
  8. package/.speccrew/skills/speccrew-deploy-migrate/workflow.agentflow.xml +135 -0
  9. package/.speccrew/skills/speccrew-deploy-smoke-test/SKILL.md +4 -156
  10. package/.speccrew/skills/speccrew-deploy-smoke-test/workflow.agentflow.xml +178 -0
  11. package/.speccrew/skills/speccrew-deploy-startup/SKILL.md +3 -135
  12. package/.speccrew/skills/speccrew-deploy-startup/workflow.agentflow.xml +223 -0
  13. package/.speccrew/skills/speccrew-dev-backend/SKILL.md +10 -2
  14. package/.speccrew/skills/speccrew-dev-backend/workflow.agentflow.xml +254 -0
  15. package/.speccrew/skills/speccrew-dev-desktop-electron/SKILL.md +10 -2
  16. package/.speccrew/skills/speccrew-dev-desktop-electron/workflow.agentflow.xml +259 -0
  17. package/.speccrew/skills/speccrew-dev-desktop-tauri/SKILL.md +10 -2
  18. package/.speccrew/skills/speccrew-dev-desktop-tauri/workflow.agentflow.xml +245 -0
  19. package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +10 -2
  20. package/.speccrew/skills/speccrew-dev-frontend/workflow.agentflow.xml +262 -0
  21. package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +10 -2
  22. package/.speccrew/skills/speccrew-dev-mobile/workflow.agentflow.xml +244 -0
  23. package/.speccrew/skills/speccrew-dev-review-backend/SKILL.md +10 -2
  24. package/.speccrew/skills/speccrew-dev-review-backend/workflow.agentflow.xml +251 -0
  25. package/.speccrew/skills/speccrew-dev-review-desktop/SKILL.md +10 -2
  26. package/.speccrew/skills/speccrew-dev-review-desktop/workflow.agentflow.xml +214 -0
  27. package/.speccrew/skills/speccrew-dev-review-frontend/SKILL.md +10 -2
  28. package/.speccrew/skills/speccrew-dev-review-frontend/workflow.agentflow.xml +213 -0
  29. package/.speccrew/skills/speccrew-dev-review-mobile/SKILL.md +10 -2
  30. package/.speccrew/skills/speccrew-dev-review-mobile/workflow.agentflow.xml +214 -0
  31. package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +7 -1
  32. package/.speccrew/skills/speccrew-fd-api-contract/workflow.agentflow.xml +222 -0
  33. package/.speccrew/skills/speccrew-fd-feature-analyze/SKILL.md +7 -1
  34. package/.speccrew/skills/speccrew-fd-feature-analyze/workflow.agentflow.xml +223 -0
  35. package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +7 -1
  36. package/.speccrew/skills/speccrew-fd-feature-design/workflow.agentflow.xml +322 -0
  37. package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +3 -39
  38. package/.speccrew/skills/speccrew-get-timestamp/workflow.agentflow.xml +43 -0
  39. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +57 -508
  40. package/.speccrew/skills/{speccrew-knowledge-bizs-api-analyze-xml/SKILL.md → speccrew-knowledge-bizs-api-analyze/workflow.agentflow.xml} +1 -154
  41. package/.speccrew/skills/speccrew-knowledge-bizs-api-graph/SKILL.md +73 -283
  42. package/.speccrew/skills/{speccrew-knowledge-bizs-api-graph-xml/SKILL.md → speccrew-knowledge-bizs-api-graph/workflow.agentflow.xml} +0 -298
  43. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +931 -801
  44. package/.speccrew/skills/{speccrew-knowledge-bizs-dispatch-xml/SKILL.md → speccrew-knowledge-bizs-dispatch/workflow.agentflow.xml} +42 -272
  45. package/.speccrew/skills/speccrew-knowledge-bizs-identify-entries/SKILL.md +263 -71
  46. package/.speccrew/skills/{speccrew-knowledge-bizs-identify-entries-xml/SKILL.md → speccrew-knowledge-bizs-identify-entries/workflow.agentflow.xml} +8 -184
  47. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +200 -181
  48. package/.speccrew/skills/{speccrew-knowledge-bizs-init-features-xml/SKILL.md → speccrew-knowledge-bizs-init-features/workflow.agentflow.xml} +7 -134
  49. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +5 -89
  50. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/workflow.agentflow.xml +129 -0
  51. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +454 -326
  52. package/.speccrew/skills/{speccrew-knowledge-bizs-ui-analyze-xml/SKILL.md → speccrew-knowledge-bizs-ui-analyze/workflow.agentflow.xml} +8 -128
  53. package/.speccrew/skills/speccrew-knowledge-bizs-ui-graph/SKILL.md +302 -247
  54. package/.speccrew/skills/{speccrew-knowledge-bizs-ui-graph-xml/SKILL.md → speccrew-knowledge-bizs-ui-graph/workflow.agentflow.xml} +7 -199
  55. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +267 -156
  56. package/.speccrew/skills/{speccrew-knowledge-bizs-ui-style-extract-xml/SKILL.md → speccrew-knowledge-bizs-ui-style-extract/workflow.agentflow.xml} +7 -151
  57. package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +3 -122
  58. package/.speccrew/skills/speccrew-knowledge-graph-query/workflow.agentflow.xml +106 -0
  59. package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +3 -80
  60. package/.speccrew/skills/speccrew-knowledge-graph-write/workflow.agentflow.xml +152 -0
  61. package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +371 -265
  62. package/.speccrew/skills/{speccrew-knowledge-module-summarize-xml/SKILL.md → speccrew-knowledge-module-summarize/workflow.agentflow.xml} +7 -197
  63. package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +45 -333
  64. package/.speccrew/skills/{speccrew-knowledge-system-summarize-xml/SKILL.md → speccrew-knowledge-system-summarize/workflow.agentflow.xml} +0 -177
  65. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +174 -727
  66. package/.speccrew/skills/{speccrew-knowledge-techs-dispatch-xml/SKILL.md → speccrew-knowledge-techs-dispatch/workflow.agentflow.xml} +10 -351
  67. package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +20 -150
  68. package/.speccrew/skills/{speccrew-knowledge-techs-generate-xml/SKILL.md → speccrew-knowledge-techs-generate/workflow.agentflow.xml} +0 -169
  69. package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +75 -587
  70. package/.speccrew/skills/{speccrew-knowledge-techs-generate-conventions-xml/SKILL.md → speccrew-knowledge-techs-generate-conventions/workflow.agentflow.xml} +0 -153
  71. package/.speccrew/skills/speccrew-knowledge-techs-generate-quality/SKILL.md +463 -297
  72. package/.speccrew/skills/{speccrew-knowledge-techs-generate-quality-xml/SKILL.md → speccrew-knowledge-techs-generate-quality/workflow.agentflow.xml} +0 -164
  73. package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +57 -292
  74. package/.speccrew/skills/{speccrew-knowledge-techs-generate-ui-style-xml/SKILL.md → speccrew-knowledge-techs-generate-ui-style/workflow.agentflow.xml} +2 -193
  75. package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +49 -335
  76. package/.speccrew/skills/{speccrew-knowledge-techs-index-xml/SKILL.md → speccrew-knowledge-techs-index/workflow.agentflow.xml} +0 -167
  77. package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +28 -109
  78. package/.speccrew/skills/{speccrew-knowledge-techs-init-xml/SKILL.md → speccrew-knowledge-techs-init/workflow.agentflow.xml} +0 -189
  79. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +3 -487
  80. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/workflow.agentflow.xml +278 -0
  81. package/.speccrew/skills/speccrew-pm-knowledge-detector/SKILL.md +3 -71
  82. package/.speccrew/skills/speccrew-pm-knowledge-detector/workflow.agentflow.xml +108 -0
  83. package/.speccrew/skills/speccrew-pm-module-initializer/SKILL.md +3 -107
  84. package/.speccrew/skills/speccrew-pm-module-initializer/workflow.agentflow.xml +139 -0
  85. package/.speccrew/skills/speccrew-pm-module-matcher/SKILL.md +3 -115
  86. package/.speccrew/skills/speccrew-pm-module-matcher/workflow.agentflow.xml +146 -0
  87. package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +3 -343
  88. package/.speccrew/skills/speccrew-pm-requirement-analysis/workflow.agentflow.xml +174 -0
  89. package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +3 -91
  90. package/.speccrew/skills/speccrew-pm-requirement-assess/workflow.agentflow.xml +173 -0
  91. package/.speccrew/skills/speccrew-pm-requirement-clarify/SKILL.md +3 -224
  92. package/.speccrew/skills/speccrew-pm-requirement-clarify/workflow.agentflow.xml +159 -0
  93. package/.speccrew/skills/speccrew-pm-requirement-model/SKILL.md +3 -275
  94. package/.speccrew/skills/speccrew-pm-requirement-model/workflow.agentflow.xml +210 -0
  95. package/.speccrew/skills/speccrew-pm-requirement-simple/SKILL.md +3 -76
  96. package/.speccrew/skills/speccrew-pm-requirement-simple/workflow.agentflow.xml +120 -0
  97. package/.speccrew/skills/speccrew-pm-sub-prd-generate/SKILL.md +7 -1
  98. package/.speccrew/skills/speccrew-pm-sub-prd-generate/workflow.agentflow.xml +218 -0
  99. package/.speccrew/skills/speccrew-sd-backend/SKILL.md +7 -1
  100. package/.speccrew/skills/speccrew-sd-backend/workflow.agentflow.xml +264 -0
  101. package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +7 -1
  102. package/.speccrew/skills/speccrew-sd-desktop/workflow.agentflow.xml +288 -0
  103. package/.speccrew/skills/speccrew-sd-framework-evaluate/SKILL.md +7 -1
  104. package/.speccrew/skills/speccrew-sd-framework-evaluate/workflow.agentflow.xml +235 -0
  105. package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +7 -1
  106. package/.speccrew/skills/speccrew-sd-frontend/workflow.agentflow.xml +299 -0
  107. package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +7 -1
  108. package/.speccrew/skills/speccrew-sd-mobile/workflow.agentflow.xml +301 -0
  109. package/.speccrew/skills/speccrew-test-case-design/SKILL.md +165 -284
  110. package/.speccrew/skills/speccrew-test-case-design/workflow.agentflow.xml +210 -0
  111. package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +204 -324
  112. package/.speccrew/skills/speccrew-test-code-gen/workflow.agentflow.xml +265 -0
  113. package/.speccrew/skills/speccrew-test-reporter/SKILL.md +205 -184
  114. package/.speccrew/skills/speccrew-test-reporter/workflow.agentflow.xml +284 -0
  115. package/.speccrew/skills/speccrew-test-runner/SKILL.md +242 -241
  116. package/.speccrew/skills/speccrew-test-runner/workflow.agentflow.xml +314 -0
  117. package/bin/cli.js +8 -1
  118. package/lib/commands/validate.js +565 -0
  119. package/package.json +1 -1
  120. package/workspace-template/docs/rules/{xml-workflow-spec.md → agentflow-spec.md} +5 -5
  121. package/workspace-template/scripts/validate-agentflow.js +637 -0
  122. package/.speccrew/agents/speccrew-team-leader-xml.md +0 -480
  123. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +0 -99
  124. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +0 -176
  125. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +0 -150
  126. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +0 -106
  127. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +0 -249
  128. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/merge-features.js +0 -300
  129. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +0 -915
  130. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +0 -226
  131. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +0 -34
  132. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +0 -1071
  133. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +0 -26
  134. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +0 -550
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: speccrew-agentflow-manager
3
+ version: 1.0.0
4
+ description: AgentFlow definition management - create, validate, and refine AgentFlow XML files
5
+ tools: Read, Write, Task, Bash
6
+ ---
7
+
8
+ > **⚠️ MANDATORY EXECUTION PROTOCOL — READ BEFORE EXECUTING ANY BLOCK**
9
+ >
10
+ > **Step 1**: Load XML workflow specification: `${workspace_path}/docs/rules/agentflow-spec.md` — this defines all block types and action-to-tool mappings
11
+ >
12
+ > **Step 2**: Execute this SKILL.md's XML workflow **block by block in document order**. For EVERY block, you MUST follow this 3-step cycle:
13
+ >
14
+ > ```
15
+ > 📋 Block [ID] (action=[action]) — [desc]
16
+ > 🔧 Tool: [which IDE tool to call]
17
+ > ✅ Result: [output or status]
18
+ > ```
19
+ >
20
+ > Action-to-tool mapping:
21
+ > - `action="run-script"` → Execute via **Terminal tool** (pass the `<field name="command">` value EXACTLY)
22
+ > - `action="run-skill"` → Invoke via **Skill tool** (pass the `<field name="skill">` value EXACTLY)
23
+ > - `action="read-file"` → Read via **Read tool**
24
+ > - `action="create-file"` → Create via **Write tool** (create_file)
25
+ > - `action="edit-file"` → Edit via **Edit tool** (search_replace)
26
+ > - `action="analyze"` → Perform analysis directly
27
+ > - `action="generate"` → Generate content directly
28
+ > - `action="report"` → Format and output report
29
+ >
30
+ > **Step 3**: Execute ALL blocks sequentially without pausing (only stop at explicit `<event action="confirm">` blocks)
31
+ >
32
+ > **FORBIDDEN**:
33
+ > - Do NOT skip the block announcement format above — every block must be announced before execution
34
+ > - Do NOT run terminal commands as substitute for Skill tool calls
35
+ > - Do NOT skip blocks or improvise your own commands
36
+
37
+ # AgentFlow Manager
38
+
39
+ Manage AgentFlow XML workflow definitions with three operation modes: **create**, **validate**, and **refine**.
40
+
41
+ ## Operation Modes
42
+
43
+ | Mode | Description | Required Parameters |
44
+ |------|-------------|---------------------|
45
+ | `create` | Create new AgentFlow from natural language SOP | `description`, `parameters`, `skill_dir` |
46
+ | `validate` | Validate existing .agentflow.xml file | `target_file` |
47
+ | `refine` | Auto-fix validation errors in existing file | `target_file` |
48
+
49
+ ## Invocation Method
50
+
51
+ **CRITICAL**: This skill is a **utility skill** — it MUST be loaded directly via Skill tool.
52
+
53
+ ```xml
54
+ <block type="task" action="run-skill" desc="Invoke AgentFlow manager">
55
+ <field name="skill">speccrew-agentflow-manager</field>
56
+ <field name="mode">create</field>
57
+ <field name="description">Analyze source code and generate documentation</field>
58
+ <field name="parameters">["source_path", "output_dir"]</field>
59
+ <field name="skill_dir">/path/to/new-skill</field>
60
+ <field name="workspace_path">/path/to/workspace</field>
61
+ </block>
62
+ ```
63
+
64
+ ## Input Parameters
65
+
66
+ | Parameter | Type | Required | Description |
67
+ |-----------|------|----------|-------------|
68
+ | `mode` | string | Yes | Operation mode: `create`, `validate`, or `refine` |
69
+ | `description` | string | (create) | Natural language SOP description |
70
+ | `parameters` | array | (create) | Input parameter names (JSON array) |
71
+ | `target_file` | string | (validate/refine) | Path to .agentflow.xml file to validate/refine |
72
+ | `skill_dir` | string | (create) | Target skill directory path for new AgentFlow |
73
+ | `workspace_path` | string | Yes | Current workspace path |
74
+
75
+ ## Output
76
+
77
+ - **create mode**: Generated `workflow.agentflow.xml` and `SKILL.md` skeleton
78
+ - **validate mode**: Validation report with errors and warnings
79
+ - **refine mode**: Fixed file path and fix summary
80
+
81
+ ---
82
+
83
+ ## AgentFlow Definition
84
+
85
+ <!-- @agentflow: workflow.agentflow.xml -->
86
+
87
+ ---
88
+
89
+ ## Appendix: Reference
90
+
91
+ ### Block Type Quick Reference
92
+
93
+ | Block Type | Purpose | Required Attributes |
94
+ |------------|---------|---------------------|
95
+ | `input` | Define workflow inputs | Must be first block |
96
+ | `output` | Define workflow outputs | Must be last block |
97
+ | `task` | Execute an action | `action` attribute required |
98
+ | `gateway` | Conditional branching | `mode` attribute required |
99
+ | `loop` | Iterate over collection | `over`, `as` attributes required |
100
+ | `checkpoint` | Persist progress | `name` attribute required |
101
+ | `rule` | Declare constraints | `level` attribute required |
102
+ | `event` | Logging/confirmation | `action` attribute required |
103
+ | `error-handler` | Error handling | `try`, `catch` sub-elements |
104
+
105
+ ### Action Types
106
+
107
+ | Action | IDE Tool | Usage |
108
+ |--------|----------|-------|
109
+ | `run-skill` | Skill tool | Invoke another skill |
110
+ | `run-script` | Terminal tool | Execute command/script |
111
+ | `read-file` | Read tool | Read file content |
112
+ | `create-file` | Write tool | Create new file |
113
+ | `edit-file` | Edit tool | Modify existing file |
114
+ | `analyze` | Direct execution | Perform analysis |
115
+ | `generate` | Direct execution | Generate content |
116
+ | `report` | Direct execution | Format and output report |
117
+ | `dispatch-to-worker` | Task tool | Create task for worker |
118
+
119
+ ### Variable Reference Syntax
120
+
121
+ ```xml
122
+ <!-- Simple variable -->
123
+ <field name="path" value="${skill_dir}/workflow.agentflow.xml"/>
124
+
125
+ <!-- Object property -->
126
+ <field name="count" value="${validation_result.errors.length}"/>
127
+
128
+ <!-- Array index -->
129
+ <field name="first" value="${parameters[0]}"/>
130
+
131
+ <!-- In condition -->
132
+ <case condition="${mode} == 'create'" next="B1"/>
133
+ ```
134
+
135
+ ### Checkpoint Verification
136
+
137
+ ```xml
138
+ <block type="checkpoint" id="CP1" name="workflow_created" desc="Verify file was created">
139
+ <field name="file" value="${skill_dir}/workflow.agentflow.xml"/>
140
+ <field name="verify" value="file_exists(${skill_dir}/workflow.agentflow.xml)"/>
141
+ </block>
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Checklist
147
+
148
+ - [ ] XML declaration present: `<?xml version="1.0" encoding="UTF-8"?>`
149
+ - [ ] `<workflow>` root element with id, status, version attributes
150
+ - [ ] `<block type="input">` as first block with all required parameters
151
+ - [ ] `<block type="output">` as last block with result definitions
152
+ - [ ] All block IDs are unique (B1, B2, G1, etc.)
153
+ - [ ] All `next` references point to valid block IDs
154
+ - [ ] All variable references use `${}` syntax
155
+ - [ ] All required fields have `required="true"` attribute
156
+ - [ ] Gateway conditions are valid and cover all cases
157
+ - [ ] Checkpoint verification conditions are valid
158
+
159
+ > **MANDATORY**: All generated AgentFlow XML must strictly comply with the specification in `${workspace_path}/docs/rules/agentflow-spec.md`.
160
+
161
+ <!-- @agentflow: workflow.agentflow.xml -->
@@ -0,0 +1,347 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <workflow id="agentflow-manager-main" status="pending" version="1.0" desc="AgentFlow definition management workflow">
3
+
4
+ <!-- ============================================================
5
+ Input Parameters Definition
6
+ ============================================================ -->
7
+ <block type="input" id="I1" desc="Receive operation mode and parameters">
8
+ <field name="mode" required="true" type="string" desc="Operation mode: create | validate | refine"/>
9
+ <field name="description" required="false" type="string" desc="Natural language SOP description (create mode)"/>
10
+ <field name="parameters" required="false" type="array" desc="Parameter list as JSON array (create mode)"/>
11
+ <field name="target_file" required="false" type="string" desc="Target .agentflow.xml file path (validate/refine mode)"/>
12
+ <field name="skill_dir" required="false" type="string" desc="Target skill directory path (create mode)"/>
13
+ <field name="workspace_path" required="true" type="string" desc="Current workspace path"/>
14
+ </block>
15
+
16
+ <!-- ============================================================
17
+ Global Constraints
18
+ ============================================================ -->
19
+ <block type="rule" id="R1" level="mandatory" desc="Mode validation rules">
20
+ <field name="text">Mode MUST be one of: create, validate, refine</field>
21
+ <field name="text">Create mode requires: description, parameters, skill_dir</field>
22
+ <field name="text">Validate/refine mode requires: target_file</field>
23
+ </block>
24
+
25
+ <block type="rule" id="R2" level="forbidden" desc="Execution constraints">
26
+ <field name="text">DO NOT ask user for confirmation between blocks</field>
27
+ <field name="text">DO NOT skip any block in the workflow</field>
28
+ <field name="text">DO NOT modify files outside of specified target paths</field>
29
+ </block>
30
+
31
+ <!-- ============================================================
32
+ Load AgentFlow Specification
33
+ ============================================================ -->
34
+ <block type="task" id="R1" action="read-file" desc="Load AgentFlow specification">
35
+ <field name="path">${workspace_path}/docs/rules/agentflow-spec.md</field>
36
+ <field name="note">Read and internalize the AgentFlow specification. All generated XML must strictly comply with this spec.</field>
37
+ <field name="output" var="spec_content"/>
38
+ </block>
39
+
40
+ <!-- ============================================================
41
+ Gateway - Route by Mode
42
+ ============================================================ -->
43
+ <block type="gateway" id="G1" mode="exclusive" desc="Route to operation based on mode">
44
+ <branch test="${mode} == 'create'" name="Create Mode">
45
+ <field name="next_sequence">CREATE_SEQ</field>
46
+ </branch>
47
+ <branch test="${mode} == 'validate'" name="Validate Mode">
48
+ <field name="next_sequence">VALIDATE_SEQ</field>
49
+ </branch>
50
+ <branch test="${mode} == 'refine'" name="Refine Mode">
51
+ <field name="next_sequence">REFINE_SEQ</field>
52
+ </branch>
53
+ <branch default="true" name="Invalid Mode">
54
+ <field name="next_sequence">ERROR_SEQ</field>
55
+ </branch>
56
+ </block>
57
+
58
+ <!-- ============================================================
59
+ CREATE MODE SEQUENCE
60
+ ============================================================ -->
61
+ <sequence id="CREATE_SEQ" name="Create Mode" status="pending" desc="Create new AgentFlow from SOP description">
62
+
63
+ <!-- B1: Analyze description and design block structure -->
64
+ <block type="task" id="B1" action="analyze" desc="Analyze SOP description and design block structure">
65
+ <field name="input_description">${description}</field>
66
+ <field name="input_parameters">${parameters}</field>
67
+ <field name="analysis_tasks">
68
+ 1. Extract task steps from natural language description
69
+ 2. Identify required block types (input, task, gateway, loop, output, etc.)
70
+ 3. Design variable passing chain between blocks
71
+ 4. Determine block execution order and dependencies
72
+ 5. Identify checkpoints and error handling needs
73
+ </field>
74
+ <field name="output" var="block_design"/>
75
+ </block>
76
+
77
+ <!-- B2: Generate workflow.agentflow.xml -->
78
+ <block type="task" id="B2" action="generate" desc="Generate workflow.agentflow.xml file">
79
+ <field name="template">agentflow-xml-template</field>
80
+ <field name="block_design">${block_design}</field>
81
+ <field name="parameters">${parameters}</field>
82
+ <field name="output_path">${skill_dir}/workflow.agentflow.xml</field>
83
+ <field name="generation_rules">
84
+ - MUST include XML declaration: <?xml version="1.0" encoding="UTF-8"?>
85
+ - MUST have <workflow> root element with id, status, version attributes
86
+ - MUST start with <block type="input"> for parameter definitions
87
+ - MUST end with <block type="output"> for result definitions
88
+ - All block IDs must be unique and follow pattern: [Type][Number] (e.g., B1, G1, O1)
89
+ - All <case> and <branch> elements must have valid next references
90
+ - Variable references must use ${variable_name} syntax
91
+ </field>
92
+ <field name="output" var="agentflow_content"/>
93
+ </block>
94
+
95
+ <!-- Write workflow.agentflow.xml -->
96
+ <block type="task" id="B2_WRITE" action="create-file" desc="Write workflow.agentflow.xml to disk">
97
+ <field name="path">${skill_dir}/workflow.agentflow.xml</field>
98
+ <field name="content">${agentflow_content}</field>
99
+ <field name="output" var="write_result_b2"/>
100
+ </block>
101
+
102
+ <!-- Checkpoint: Verify workflow file created -->
103
+ <block type="checkpoint" id="CP1" name="workflow_created" desc="Verify workflow.agentflow.xml was created">
104
+ <field name="file">${skill_dir}/workflow.agentflow.xml</field>
105
+ <field name="verify" value="file_exists(${skill_dir}/workflow.agentflow.xml)"/>
106
+ </block>
107
+
108
+ <!-- B3: Generate SKILL.md skeleton -->
109
+ <block type="task" id="B3" action="generate" desc="Generate SKILL.md skeleton">
110
+ <field name="template">skill-md-skeleton</field>
111
+ <field name="skill_name">${skill_dir.split('/').pop()}</field>
112
+ <field name="description">${description}</field>
113
+ <field name="parameters">${parameters}</field>
114
+ <field name="generation_rules">
115
+ - Include skill metadata: name, version, description, tools
116
+ - Include Input Parameters table with all parameters
117
+ - Include Output section
118
+ - Include trigger scenarios section
119
+ - Include AgentFlow reference declaration: <!-- @agentflow: workflow.agentflow.xml -->
120
+ - Follow existing skill format and style
121
+ </field>
122
+ <field name="output" var="skill_md_content"/>
123
+ </block>
124
+
125
+ <!-- Write SKILL.md -->
126
+ <block type="task" id="B3_WRITE" action="create-file" desc="Write SKILL.md to disk">
127
+ <field name="path">${skill_dir}/SKILL.md</field>
128
+ <field name="content">${skill_md_content}</field>
129
+ <field name="output" var="write_result_b3"/>
130
+ </block>
131
+
132
+ <!-- Log completion -->
133
+ <block type="event" id="E1" action="log" level="info" desc="Log create mode completion">
134
+ <field name="message">AgentFlow created successfully:
135
+ - Workflow: ${skill_dir}/workflow.agentflow.xml
136
+ - Skill Doc: ${skill_dir}/SKILL.md</field>
137
+ </block>
138
+
139
+ </sequence>
140
+
141
+ <!-- ============================================================
142
+ VALIDATE MODE SEQUENCE
143
+ ============================================================ -->
144
+ <sequence id="VALIDATE_SEQ" name="Validate Mode" status="pending" desc="Validate existing AgentFlow file">
145
+
146
+ <!-- B4: Run validate-agentflow.js script -->
147
+ <block type="task" id="B4" action="run-script" desc="Run validate-agentflow.js validation script">
148
+ <field name="command">node "${workspace_path}/scripts/validate-agentflow.js" "${target_file}" --format json</field>
149
+ <field name="alt_command_fallback">node -e "
150
+ const fs = require('fs');
151
+ const path = require('path');
152
+ const targetFile = process.argv[1];
153
+ if (!fs.existsSync(targetFile)) {
154
+ console.log(JSON.stringify({valid: false, errors: [{severity: 'error', message: 'File not found: ' + targetFile}], warnings: []}));
155
+ process.exit(1);
156
+ }
157
+ const content = fs.readFileSync(targetFile, 'utf8');
158
+ const errors = [];
159
+ const warnings = [];
160
+ // Basic XML structure validation
161
+ if (!content.includes('<?xml')) warnings.push({severity: 'warning', message: 'Missing XML declaration'});
162
+ if (!content.includes('<workflow')) errors.push({severity: 'error', message: 'Missing <workflow> root element'});
163
+ if (!content.includes('<block type=\"input\"')) errors.push({severity: 'error', message: 'Missing input block'});
164
+ if (!content.includes('<block type=\"output\"')) errors.push({severity: 'error', message: 'Missing output block'});
165
+ // Check for unique IDs
166
+ const idMatches = content.match(/id=\"[^\"]+\"/g) || [];
167
+ const ids = idMatches.map(m => m.replace('id=\"', '').replace('\"', ''));
168
+ const duplicates = ids.filter((item, index) => ids.indexOf(item) !== index);
169
+ if (duplicates.length > 0) errors.push({severity: 'error', message: 'Duplicate block IDs: ' + duplicates.join(', ')});
170
+ console.log(JSON.stringify({valid: errors.length === 0, errors, warnings}));
171
+ " "${target_file}"</field>
172
+ <field name="output" var="validation_json"/>
173
+ </block>
174
+
175
+ <!-- B5: Format and present validation report -->
176
+ <block type="task" id="B5" action="report" desc="Format validation report">
177
+ <field name="input">${validation_json}</field>
178
+ <field name="format">human-readable</field>
179
+ <field name="grouping">severity</field>
180
+ <field name="sections">
181
+ - Summary: valid/invalid status
182
+ - Errors: List all errors with line references if available
183
+ - Warnings: List all warnings with recommendations
184
+ - Fix suggestions: Actionable recommendations for each issue
185
+ </field>
186
+ <field name="output" var="validation_report"/>
187
+ </block>
188
+
189
+ <!-- Log validation result -->
190
+ <block type="event" id="E2" action="log" level="info" desc="Log validation completion">
191
+ <field name="message">Validation complete for: ${target_file}
192
+ ${validation_report.summary}</field>
193
+ </block>
194
+
195
+ </sequence>
196
+
197
+ <!-- ============================================================
198
+ REFINE MODE SEQUENCE
199
+ ============================================================ -->
200
+ <sequence id="REFINE_SEQ" name="Refine Mode" status="pending" desc="Auto-fix validation errors">
201
+
202
+ <!-- B6: Read target file and validation report -->
203
+ <block type="task" id="B6_READ" action="read-file" desc="Read target AgentFlow file">
204
+ <field name="path">${target_file}</field>
205
+ <field name="output" var="target_content"/>
206
+ </block>
207
+
208
+ <!-- Run validation if report not provided -->
209
+ <block type="task" id="B6_VALIDATE" action="run-script" desc="Get validation report">
210
+ <field name="command">node "${workspace_path}/scripts/validate-agentflow.js" "${target_file}" --format json</field>
211
+ <field name="alt_command_fallback">node -e "
212
+ const fs = require('fs');
213
+ const targetFile = process.argv[1];
214
+ if (!fs.existsSync(targetFile)) {
215
+ console.log(JSON.stringify({valid: false, errors: [{severity: 'error', message: 'File not found'}], warnings: []}));
216
+ process.exit(1);
217
+ }
218
+ const content = fs.readFileSync(targetFile, 'utf8');
219
+ const errors = [];
220
+ const warnings = [];
221
+ if (!content.includes('<?xml')) warnings.push({severity: 'warning', line: 1, message: 'Missing XML declaration'});
222
+ if (!content.includes('<workflow')) errors.push({severity: 'error', message: 'Missing <workflow> root element'});
223
+ if (!content.includes('<block type=\"input\"')) errors.push({severity: 'error', message: 'Missing input block'});
224
+ if (!content.includes('<block type=\"output\"')) errors.push({severity: 'error', message: 'Missing output block'});
225
+ console.log(JSON.stringify({valid: errors.length === 0, errors, warnings}));
226
+ " "${target_file}"</field>
227
+ <field name="output" var="validation_result"/>
228
+ </block>
229
+
230
+ <!-- Gateway: Check if fixes needed -->
231
+ <block type="gateway" id="G2" mode="exclusive" desc="Check if fixes are needed">
232
+ <branch test="${validation_result.valid} == true" name="Already Valid">
233
+ <block type="event" id="E3" action="log" level="info" desc="File is already valid">
234
+ <field name="message">No fixes needed - ${target_file} is already valid</field>
235
+ </block>
236
+ <field name="refine_status" value="no_fixes_needed"/>
237
+ </branch>
238
+ <branch test="${validation_result.errors.length} == 0 AND ${validation_result.warnings.length} > 0" name="Warnings Only">
239
+ <block type="event" id="E4" action="log" level="warn" desc="Warnings found">
240
+ <field name="message">Only warnings found - no critical errors to fix</field>
241
+ </block>
242
+ <field name="refine_status" value="warnings_only"/>
243
+ </branch>
244
+ <branch default="true" name="Has Errors">
245
+ <field name="next">B7</field>
246
+ </branch>
247
+ </block>
248
+
249
+ <!-- B7: Apply fixes based on validation errors -->
250
+ <block type="task" id="B7" action="edit-file" desc="Apply fixes to validation errors">
251
+ <field name="target_file">${target_file}</field>
252
+ <field name="current_content">${target_content}</field>
253
+ <field name="errors">${validation_result.errors}</field>
254
+ <field name="fix_rules">
255
+ - Add XML declaration if missing: <?xml version="1.0" encoding="UTF-8"?>
256
+ - Add <workflow> root element if missing with proper attributes
257
+ - Add <block type="input"> at start if missing
258
+ - Add <block type="output"> at end if missing
259
+ - Fix duplicate IDs by appending unique suffixes
260
+ - Fix unclosed tags by adding proper closing elements
261
+ - Fix invalid next references by correcting target IDs
262
+ </field>
263
+ <field name="fix_documentation">Document each fix applied with explanation</field>
264
+ <field name="output" var="fix_result"/>
265
+ </block>
266
+
267
+ <!-- B8: Re-validate after fixes -->
268
+ <block type="task" id="B8" action="run-script" desc="Re-validate after fixes">
269
+ <field name="command">node "${workspace_path}/scripts/validate-agentflow.js" "${target_file}" --format json</field>
270
+ <field name="alt_command_fallback">node -e "
271
+ const fs = require('fs');
272
+ const targetFile = process.argv[1];
273
+ const content = fs.readFileSync(targetFile, 'utf8');
274
+ const errors = [];
275
+ const warnings = [];
276
+ if (!content.includes('<?xml')) warnings.push({severity: 'warning', message: 'Missing XML declaration'});
277
+ if (!content.includes('<workflow')) errors.push({severity: 'error', message: 'Missing <workflow> root element'});
278
+ if (!content.includes('<block type=\"input\"')) errors.push({severity: 'error', message: 'Missing input block'});
279
+ if (!content.includes('<block type=\"output\"')) errors.push({severity: 'error', message: 'Missing output block'});
280
+ console.log(JSON.stringify({valid: errors.length === 0, errors, warnings}));
281
+ " "${target_file}"</field>
282
+ <field name="output" var="revalidation_result"/>
283
+ </block>
284
+
285
+ <!-- Report final status -->
286
+ <block type="task" id="B8_REPORT" action="report" desc="Report refine results">
287
+ <field name="original_errors">${validation_result.errors.length}</field>
288
+ <field name="remaining_errors">${revalidation_result.errors.length}</field>
289
+ <field name="fixes_applied">${fix_result.fixes}</field>
290
+ <field name="output" var="refine_report"/>
291
+ </block>
292
+
293
+ <!-- Log refine result -->
294
+ <block type="event" id="E5" action="log" level="info" desc="Log refine completion">
295
+ <field name="message">Refine complete for: ${target_file}
296
+ ${refine_report.summary}</field>
297
+ </block>
298
+
299
+ </sequence>
300
+
301
+ <!-- ============================================================
302
+ ERROR SEQUENCE (Invalid Mode)
303
+ ============================================================ -->
304
+ <sequence id="ERROR_SEQ" name="Error Sequence" status="pending" desc="Handle invalid mode parameter">
305
+
306
+ <block type="event" id="E_ERR" action="log" level="error" desc="Log invalid mode error">
307
+ <field name="message">ERROR: Invalid mode '${mode}'. Must be one of: create, validate, refine</field>
308
+ </block>
309
+
310
+ <block type="task" id="B_ERR" action="report" desc="Generate error report">
311
+ <field name="error_type">invalid_mode</field>
312
+ <field name="provided_mode">${mode}</field>
313
+ <field name="valid_modes">["create", "validate", "refine"]</field>
314
+ <field name="output" var="error_report"/>
315
+ </block>
316
+
317
+ </sequence>
318
+
319
+ <!-- ============================================================
320
+ Output Results
321
+ ============================================================ -->
322
+ <block type="output" id="O1" desc="AgentFlow manager results">
323
+ <field name="mode" from="${mode}" type="string" desc="Operation mode executed"/>
324
+ <field name="status" from="${workflow.status}" type="string" desc="Workflow execution status"/>
325
+
326
+ <!-- Create mode outputs -->
327
+ <field name="workflow_file" from="${skill_dir}/workflow.agentflow.xml" type="string" desc="Generated workflow file path (create mode)"/>
328
+ <field name="skill_md_file" from="${skill_dir}/SKILL.md" type="string" desc="Generated SKILL.md file path (create mode)"/>
329
+ <field name="block_count" from="${block_design.block_count}" type="number" desc="Number of blocks designed (create mode)"/>
330
+
331
+ <!-- Validate mode outputs -->
332
+ <field name="validation_valid" from="${validation_result.valid}" type="boolean" desc="Validation passed status (validate mode)"/>
333
+ <field name="validation_errors" from="${validation_result.errors}" type="array" desc="Validation errors (validate mode)"/>
334
+ <field name="validation_warnings" from="${validation_result.warnings}" type="array" desc="Validation warnings (validate mode)"/>
335
+ <field name="validation_report" from="${validation_report}" type="string" desc="Formatted validation report (validate mode)"/>
336
+
337
+ <!-- Refine mode outputs -->
338
+ <field name="refine_status" from="${refine_status}" type="string" desc="Refine operation status (refine mode)"/>
339
+ <field name="fixes_applied" from="${fix_result.fixes}" type="array" desc="List of fixes applied (refine mode)"/>
340
+ <field name="remaining_errors" from="${revalidation_result.errors}" type="array" desc="Errors that could not be auto-fixed (refine mode)"/>
341
+ <field name="refine_report" from="${refine_report}" type="string" desc="Formatted refine report (refine mode)"/>
342
+
343
+ <!-- Error mode outputs -->
344
+ <field name="error_report" from="${error_report}" type="string" desc="Error report (error mode)"/>
345
+ </block>
346
+
347
+ </workflow>
@@ -19,64 +19,11 @@ tools: Read, Bash, Glob
19
19
  | `project_root` | Yes | string | Absolute path to the project root directory |
20
20
  | `iteration_path` | Yes | string | Current iteration directory path |
21
21
 
22
- # Workflow
22
+ ## AgentFlow Definition
23
23
 
24
- ## Step 1: Pre-build Check
24
+ <!-- @agentflow: workflow.agentflow.xml -->
25
25
 
26
- Verify prerequisites before executing the build:
27
-
28
- 1. **Verify project_root exists**
29
- - Check directory exists at `project_root`
30
- - If not exists → FAILED with Error Category: DEPENDENCY_MISSING
31
-
32
- 2. **Verify build tool is available**
33
- - Detect build tool from `build_cmd`:
34
- - `mvn` → Run `mvn --version`
35
- - `npm` / `pnpm` / `yarn` → Run `{tool} --version`
36
- - `gradle` → Run `gradle --version`
37
- - `go` → Run `go version`
38
- - If tool not available → FAILED with Error Category: DEPENDENCY_MISSING
39
-
40
- 3. **Check for build config files**
41
- - Maven: `pom.xml` must exist in `project_root`
42
- - Node.js: `package.json` must exist in `project_root`
43
- - Gradle: `build.gradle` or `build.gradle.kts` must exist
44
- - Go: `go.mod` must exist
45
- - If config missing → FAILED with Error Category: VALIDATION_ERROR
46
-
47
- ## Step 2: Execute Build
48
-
49
- Run the build command:
50
-
51
- 1. **Execute build_cmd via Bash**
52
- - Working directory: `project_root`
53
- - Command: `build_cmd`
54
- - Capture stdout and stderr
55
- - Record start time before execution
56
-
57
- 2. **Check exit code**
58
- - Exit code 0 → Continue to Step 3
59
- - Exit code non-zero → FAILED with Error Category: BUILD_FAILURE
60
-
61
- 3. **Calculate build duration**
62
- - Duration = end_time - start_time
63
-
64
- ## Step 3: Verify Build Output
65
-
66
- Check for expected build artifacts:
67
-
68
- 1. **Detect expected artifacts by platform**
69
- - Spring/Maven: `target/*.jar` files
70
- - Node.js: `dist/` or `build/` directory
71
- - Gradle: `build/libs/*.jar`
72
- - Go: Binary executable in project root or `bin/`
73
-
74
- 2. **Verify artifacts exist**
75
- - Use Glob to find expected artifacts
76
- - If no artifacts found → FAILED with Error Category: BUILD_FAILURE
77
-
78
- 3. **Record artifact paths**
79
- - List all generated artifacts with full paths
26
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `speccrew-workspace/docs/rules/agentflow-spec.md`
80
27
 
81
28
  # Task Completion Report
82
29