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
@@ -10,332 +10,212 @@ tools: Read, Write, Glob, Grep
10
10
  - When user explicitly requests test code generation from confirmed test cases
11
11
  - When user asks "Generate test code", "Create test files from test cases"
12
12
 
13
- # Workflow
14
-
15
- ## Absolute Constraints
16
-
17
- > **These rules apply to document generation steps (Step 7). Violation = task failure.**
18
-
19
- 1. **FORBIDDEN: `create_file` for plan document** — NEVER use `create_file` to write the test code plan document. It MUST be created by copying the template then filling sections with `search_replace`.
20
-
21
- 2. **FORBIDDEN: Full-file rewrite** NEVER replace the entire document content in a single operation. Always use targeted `search_replace` on specific sections.
22
-
23
- 3. **MANDATORY: Template-first workflow** — Copy template MUST execute before filling sections.
24
-
25
- 4. **CLARIFICATION: Test source code is NOT template-filled** — Actual test code files in Step 6 are written directly. The template-fill workflow applies ONLY to the Code Plan document in Step 7.
26
-
27
- ## Step 1: Read Test Cases
28
-
29
- Read the confirmed test case document specified by `test_cases_path`:
30
-
31
- 1. **Parse Test Case Matrix**: Extract TC ID, test steps, inputs, expected results
32
- 2. **Statistics**: Count total test cases and distribution by dimension (module, priority, type)
33
- 3. **Extract Test Data**: Identify test data definitions and fixtures required
34
-
35
- ### Test Case Document Structure Expected
36
-
37
- | Section | Content to Extract |
38
- |---------|-------------------|
39
- | Test Case Matrix | TC ID, Description, Steps, Input, Expected Result |
40
- | Test Data | Fixture definitions, test data sets |
41
- | Preconditions | Setup requirements, mock data needs |
42
-
43
- ## Step 2: Read Technical Conventions
44
-
45
- Load platform testing conventions to understand the target test framework:
46
-
47
- ### 2.1 Primary Convention Path
48
-
49
- ```
50
- speccrew-workspace/knowledges/techs/{platform_id}/conventions-system-test.md
51
- ```
52
-
53
- ### 2.2 Unit Test Convention Path (Fallback)
54
-
55
- If `conventions-system-test.md` does not exist or for unit test specifics, read:
56
-
57
- ```
58
- speccrew-workspace/knowledges/techs/{platform_id}/conventions-unit-test.md
13
+ ## AgentFlow Definition
14
+
15
+ <!-- @agentflow: workflow.agentflow.xml -->
16
+
17
+ > **REQUIRED**: Before executing this workflow, read the XML workflow specification: `speccrew-workspace/docs/rules/agentflow-spec.md`
18
+
19
+ ```xml
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <workflow id="test-code-gen-main" status="pending" version="1.0" desc="Generate executable test code from confirmed test case documents">
22
+
23
+ <!-- Input Parameters -->
24
+ <block type="input" id="I1" desc="Workflow input parameters">
25
+ <field name="test_cases_path" required="true" type="string" desc="Path to test cases document"/>
26
+ <field name="system_design_path" required="false" type="string" desc="Path to system design document"/>
27
+ <field name="output_dir" required="true" type="string" desc="Directory for test code output"/>
28
+ <field name="feature_name" required="true" type="string" desc="Feature name for output file naming"/>
29
+ <field name="platform_id" required="true" type="string" desc="Target platform identifier"/>
30
+ <field name="module" required="true" type="string" desc="Module name for file organization"/>
31
+ </block>
32
+
33
+ <!-- Global Constraints -->
34
+ <block type="rule" id="R1" level="forbidden" desc="Document generation constraints">
35
+ <field name="text">NEVER use create_file to write the test code plan document directly</field>
36
+ <field name="text">MUST copy template first, then fill sections with search_replace for plan document</field>
37
+ <field name="text">NEVER replace entire document content in a single operation</field>
38
+ </block>
39
+
40
+ <block type="rule" id="R2" level="mandatory" desc="Template-first workflow for plan document">
41
+ <field name="text">Copy template MUST execute before filling sections for code plan document</field>
42
+ <field name="text">Test source code files are written directly (NOT template-filled)</field>
43
+ </block>
44
+
45
+ <block type="rule" id="R3" level="mandatory" desc="TC ID traceability">
46
+ <field name="text">Every test function MUST have a TC ID comment</field>
47
+ <field name="text">Format: // TC-{MODULE}-{SEQ}: {description}</field>
48
+ </block>
49
+
50
+ <!-- Main Processing Sequence -->
51
+ <sequence id="S1" name="Test Code Generation" status="pending" desc="Generate test code from test cases">
52
+
53
+ <!-- Step 1: Read Test Cases -->
54
+ <block type="task" id="B1" action="read-file" desc="Read confirmed test case document">
55
+ <field name="path" value="${test_cases_path}"/>
56
+ <field name="output" var="test_cases"/>
57
+ </block>
58
+
59
+ <!-- Step 2: Read Technical Conventions -->
60
+ <block type="task" id="B2" action="read-file" desc="Read platform testing conventions">
61
+ <field name="path" value="speccrew-workspace/knowledges/techs/${platform_id}/conventions-system-test.md"/>
62
+ <field name="optional" value="true"/>
63
+ <field name="output" var="system_test_conventions"/>
64
+ </block>
65
+
66
+ <!-- Fallback: Read unit test conventions -->
67
+ <block type="gateway" id="G1" mode="exclusive" desc="Check if system test conventions found">
68
+ <branch test="${system_test_conventions} == null">
69
+ <block type="task" id="B3" action="read-file" desc="Read unit test conventions as fallback">
70
+ <field name="path" value="speccrew-workspace/knowledges/techs/${platform_id}/conventions-unit-test.md"/>
71
+ <field name="optional" value="true"/>
72
+ <field name="output" var="unit_test_conventions"/>
73
+ </block>
74
+ </branch>
75
+ </block>
76
+
77
+ <!-- Step 3: Read System Design (if provided) -->
78
+ <block type="gateway" id="G2" mode="exclusive" desc="Check if system design path is provided">
79
+ <branch test="${system_design_path} != null AND ${system_design_path} != ''">
80
+ <block type="task" id="B4" action="read-file" desc="Read system design document">
81
+ <field name="path" value="${system_design_path}"/>
82
+ <field name="output" var="system_design"/>
83
+ </block>
84
+ </branch>
85
+ </block>
86
+
87
+ <!-- Step 4: Generate Code Plan -->
88
+ <block type="task" id="B5" action="analyze" desc="Determine file grouping strategy">
89
+ <field name="grouping_rules">
90
+ - IF test cases share same module/component THEN group into single test file
91
+ - IF test cases are independent THEN one test file per test case
92
+ - Maximum test cases per file: 10
93
+ - Naming convention: {module-name}.test.{ext} or {module-name}.spec.{ext}
94
+ </field>
95
+ <field name="output" var="file_grouping_strategy"/>
96
+ </block>
97
+
98
+ <block type="task" id="B6" action="analyze" desc="Plan test file structure">
99
+ <field name="analysis_focus">
100
+ - Files per module
101
+ - Single vs multiple files
102
+ - Integration test separation
103
+ </field>
104
+ <field name="output" var="test_file_structure"/>
105
+ </block>
106
+
107
+ <block type="task" id="B7" action="analyze" desc="Plan shared resources">
108
+ <field name="resource_types">
109
+ - Fixtures: Common test data
110
+ - Helpers: Reusable test utilities
111
+ - Mocks: Shared mock definitions
112
+ </field>
113
+ <field name="output" var="shared_resources_plan"/>
114
+ </block>
115
+
116
+ <block type="task" id="B8" action="analyze" desc="Plan mock/stub strategy">
117
+ <field name="dependency_types">
118
+ - Database: Mock repository/DAO or use test database
119
+ - External API: Mock HTTP client or use stub server
120
+ - File System: Mock file operations or use temp directory
121
+ - Message Queue: Mock producer/consumer
122
+ - Cache: Mock cache client or use in-memory cache
123
+ </field>
124
+ <field name="output" var="mock_strategy"/>
125
+ </block>
126
+
127
+ <block type="task" id="B9" action="analyze" desc="Create file-to-testcase mapping">
128
+ <field name="output" var="file_case_mapping"/>
129
+ </block>
130
+
131
+ <!-- Step 5: Checkpoint - Present Code Plan for Confirmation -->
132
+ <block type="task" id="B10" action="generate" desc="Generate code plan summary">
133
+ <field name="output" var="code_plan_summary"/>
134
+ </block>
135
+
136
+ <block type="event" id="E1" action="confirm" title="Confirm Test Code Plan" type="yesno" desc="Wait for user confirmation before generating code">
137
+ <field name="preview" value="${code_plan_summary}"/>
138
+ <on-confirm>
139
+ <field name="confirmed" value="true"/>
140
+ </on-confirm>
141
+ <on-cancel>
142
+ <field name="workflow.status" value="cancelled"/>
143
+ </on-cancel>
144
+ </block>
145
+
146
+ <!-- Step 6: Generate Test Code -->
147
+ <block type="task" id="B11" action="generate" desc="Generate fixtures">
148
+ <field name="output_dir" value="${output_dir}/__fixtures__"/>
149
+ <field name="output" var="fixtures_generated"/>
150
+ </block>
151
+
152
+ <block type="task" id="B12" action="generate" desc="Generate helpers">
153
+ <field name="output_dir" value="${output_dir}/__helpers__"/>
154
+ <field name="output" var="helpers_generated"/>
155
+ </block>
156
+
157
+ <block type="task" id="B13" action="generate" desc="Generate mocks">
158
+ <field name="output_dir" value="${output_dir}/__mocks__"/>
159
+ <field name="output" var="mocks_generated"/>
160
+ </block>
161
+
162
+ <block type="loop" id="L1" over="${file_case_mapping.files}" as="file_mapping" desc="Generate test files">
163
+ <block type="task" id="B14" action="generate" desc="Generate test file ${file_mapping.file_name}">
164
+ <field name="tc_annotation_format">// TC-{MODULE}-{SEQ}: {description}</field>
165
+ <field name="test_structure">Arrange-Act-Assert</field>
166
+ <field name="output_path" value="${output_dir}/${file_mapping.file_name}"/>
167
+ </block>
168
+ </block>
169
+
170
+ <!-- Step 7: Write Code Plan Document -->
171
+ <block type="task" id="B15" action="read-file" desc="Read test code plan template">
172
+ <field name="path" value="speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md"/>
173
+ <field name="output" var="plan_template"/>
174
+ </block>
175
+
176
+ <block type="task" id="B16" action="write-file" desc="Create test code plan document">
177
+ <field name="path" value="${output_dir}/${feature_name}-test-code-plan.md"/>
178
+ <field name="template" value="${plan_template}"/>
179
+ <field name="output" var="plan_document_created"/>
180
+ </block>
181
+
182
+ <block type="task" id="B17" action="edit-file" desc="Fill File-to-TestCase Mapping section">
183
+ <field name="path" value="${output_dir}/${feature_name}-test-code-plan.md"/>
184
+ <field name="section">File-to-TestCase Mapping</field>
185
+ </block>
186
+
187
+ <block type="task" id="B18" action="edit-file" desc="Fill Mock Strategy section">
188
+ <field name="path" value="${output_dir}/${feature_name}-test-code-plan.md"/>
189
+ <field name="section">Mock Strategy</field>
190
+ </block>
191
+
192
+ <block type="task" id="B19" action="edit-file" desc="Fill Shared Resources section">
193
+ <field name="path" value="${output_dir}/${feature_name}-test-code-plan.md"/>
194
+ <field name="section">Shared Resources</field>
195
+ </block>
196
+
197
+ <block type="task" id="B20" action="edit-file" desc="Fill Test File Structure section">
198
+ <field name="path" value="${output_dir}/${feature_name}-test-code-plan.md"/>
199
+ <field name="section">Test File Structure</field>
200
+ </block>
201
+
202
+ <!-- Checkpoint -->
203
+ <block type="checkpoint" id="CP1" name="code-generation-complete" desc="Verify test code generation complete">
204
+ <field name="file" value="${output_dir}/${feature_name}-test-code-plan.md"/>
205
+ </block>
206
+
207
+ </sequence>
208
+
209
+ <!-- Output Results -->
210
+ <block type="output" id="O1" desc="Workflow output results">
211
+ <field name="test_code_plan_path" value="${output_dir}/${feature_name}-test-code-plan.md" type="string" desc="Path to test code plan document"/>
212
+ <field name="test_files" type="array" desc="List of generated test files"/>
213
+ <field name="total_test_cases" type="number" desc="Total number of test cases implemented"/>
214
+ </block>
215
+
216
+ </workflow>
59
217
  ```
60
218
 
61
- ### 2.3 Generic Convention Path (Last Resort)
62
-
63
- If neither conventions file exists, read `conventions-dev.md` and infer:
64
-
65
- | Convention File | Inference Strategy |
66
- |-----------------|-------------------|
67
- | conventions-dev.md | Extract framework from tech stack, infer unit test framework |
68
-
69
- ### 2.4 Information to Extract
70
-
71
- | Item | Purpose |
72
- |------|---------|
73
- | Test Framework | Jest, JUnit, pytest, Mocha, Go test, etc. |
74
- | Test Directory | Where test files should be placed |
75
- | File Naming | Test file naming conventions |
76
- | Mock Strategy | How mocking is handled (jest.mock, unittest.mock, etc.) |
77
- | Assertion Style | expect, assert, should, etc. |
78
- | Fixture Location | Where to place shared fixtures |
79
- | Helper Location | Where to place test helpers |
80
-
81
- ## Step 3: Read System Design
82
-
83
- Read the system design document specified by `system_design_path`:
84
-
85
- ### 3.1 Understand Module Structure
86
-
87
- - Identify module boundaries and responsibilities
88
- - Map test cases to corresponding modules
89
-
90
- ### 3.2 Identify External Dependencies
91
-
92
- For mocking strategy planning:
93
-
94
- | Dependency Type | Mock Approach |
95
- |-----------------|---------------|
96
- | Database | Mock repository/DAO or use test database |
97
- | External API | Mock HTTP client or use stub server |
98
- | File System | Mock file operations or use temp directory |
99
- | Message Queue | Mock producer/consumer |
100
- | Cache | Mock cache client or use in-memory cache |
101
-
102
- ### 3.3 Confirm Interface Signatures
103
-
104
- - Extract function/method signatures from design
105
- - Identify parameter types and return types
106
- - Note any complex data models that need test fixtures
107
-
108
- ## Step 4: Generate Code Plan
109
-
110
- Create a comprehensive test code generation plan:
111
-
112
- ### 4.0 Determine File Grouping Strategy
113
-
114
- Before organizing test files, determine the grouping strategy:
115
-
116
- | Condition | Grouping Strategy |
117
- |-----------|-------------------|
118
- | Test cases share same module/component | Group into single test file |
119
- | Test cases are independent | One test file per test case |
120
- | Test cases span multiple modules | Create separate test files per module |
121
-
122
- **File Grouping Rules:**
123
-
124
- 1. **IF test cases share same module/component THEN** group into single test file
125
- 2. **IF test cases are independent THEN** one test file per test case
126
- 3. **Maximum test cases per file:** 10 (split into multiple files if exceeded)
127
- 4. **Naming convention:** `{module-name}.test.{ext}` or `{module-name}.spec.{ext}`
128
-
129
- ### 4.1 Test File Structure Planning
130
-
131
- Determine how test files are organized:
132
-
133
- | Decision | Consideration |
134
- |----------|---------------|
135
- | Files per Module | Group tests by module or by feature |
136
- | Single vs Multiple | One test file per source file, or split by test type |
137
- | Integration Tests | Separate integration test files if needed |
138
-
139
- ### 4.2 Shared Resources Planning
140
-
141
- | Resource Type | Decision Points |
142
- |---------------|-----------------|
143
- | Fixtures | Common test data (users, products, etc.) |
144
- | Helpers | Reusable test utilities (setup, teardown, assertions) |
145
- | Mocks | Shared mock definitions |
146
-
147
- ### 4.3 Mock/Stub Strategy
148
-
149
- For each external dependency:
150
-
151
- | Dependency | Mock Type | Implementation Approach |
152
- |-----------|-----------|------------------------|
153
- | {dependency_name} | mock/stub/spy | {how to implement} |
154
-
155
- ### 4.4 File-to-TestCase Mapping Table
156
-
157
- | Test File | Test Cases Covered | Description |
158
- |-----------|-------------------|-------------|
159
- | {file_path} | TC-{MOD}-001, TC-{MOD}-002 | {brief description} |
160
-
161
- ## Step 5: Checkpoint - Present Code Plan for Confirmation
162
-
163
- Present the code generation plan to user before generating actual code:
164
-
165
- ### Plan Summary Structure
166
-
167
- ```
168
- Test Code Plan Summary: {feature_name}
169
-
170
- Platform: {platform_id}
171
- Test Framework: {framework}
172
-
173
- Test Cases: {count} total
174
- ├── Module A: {count} cases
175
- ├── Module B: {count} cases
176
- └── Module C: {count} cases
177
-
178
- Test Files: {file_count} files
179
- ├── {file_1}: {case_count} cases
180
- ├── {file_2}: {case_count} cases
181
- └── ...
182
-
183
- Shared Resources:
184
- ├── Fixtures: {count} files
185
- ├── Helpers: {count} files
186
- └── Mocks: {count} modules
187
-
188
- Mock Strategy:
189
- ├── {dependency_1}: {mock_type}
190
- ├── {dependency_2}: {mock_type}
191
- └── ...
192
- ```
193
-
194
- ### Confirmation Questions
195
-
196
- Ask user to confirm:
197
-
198
- 1. Is the test file grouping appropriate?
199
- 2. Is the mock strategy correct for your environment?
200
- 3. Are there any additional shared resources needed?
201
- 4. Should I proceed with code generation?
202
-
203
- **Wait for user confirmation before proceeding to Step 6.**
204
-
205
- ## Step 6: Generate Test Code
206
-
207
- Execute the code plan, generating test files one by one:
208
-
209
- ### 6.1 TC ID Annotation Format
210
-
211
- Every test function/method MUST have a TC ID comment:
212
-
213
- ```javascript
214
- // TC-{MOD}-{SEQ}: {test case description}
215
- test('should validate user input', () => {
216
- // test implementation
217
- });
218
- ```
219
-
220
- **Format Pattern**: `// TC-{MODULE}-{SEQUENCE}: {description}`
221
-
222
- | Component | Format | Example |
223
- |-----------|--------|---------|
224
- | MODULE | 2-4 character module code | USR, ORD, PAY |
225
- | SEQUENCE | 3-digit zero-padded number | 001, 002, 003 |
226
- | description | Brief test case description | User login with valid credentials |
227
-
228
- ### 6.2 Test Code Structure (Arrange-Act-Assert)
229
-
230
- Each test should follow clear structure:
231
-
232
- ```
233
- // TC-{MOD}-{SEQ}: {description}
234
- test('{test name}', () => {
235
- // Arrange - Setup test data and mocks
236
- const input = { ... };
237
- mockDependency.method.mockReturnValue(expectedValue);
238
-
239
- // Act - Execute the function under test
240
- const result = functionUnderTest(input);
241
-
242
- // Assert - Verify the outcome
243
- expect(result).toEqual(expectedOutput);
244
- expect(mockDependency.method).toHaveBeenCalledWith(expectedParams);
245
- });
246
- ```
247
-
248
- ### 6.3 Platform-Specific Conventions
249
-
250
- Follow conventions from `conventions-unit-test.md`:
251
-
252
- | Platform | Convention Examples |
253
- |----------|---------------------|
254
- | Node.js/Jest | `describe`/`test`/`expect`, `jest.mock()` |
255
- | Java/JUnit | `@Test`, `@Mock`, `when().thenReturn()` |
256
- | Python/pytest | `def test_`, `@pytest.fixture`, `mocker.patch` |
257
- | Go | `func TestXxx(t *testing.T)`, `gomock` |
258
-
259
- ### 6.4 Generate Shared Resources
260
-
261
- Create fixtures and helpers:
262
-
263
- **Fixtures** (`__fixtures__` or `fixtures/`):
264
- ```javascript
265
- // users.fixture.js
266
- module.exports = {
267
- validUser: {
268
- id: 'user-001',
269
- username: 'testuser',
270
- email: 'test@example.com'
271
- },
272
- adminUser: {
273
- id: 'admin-001',
274
- username: 'admin',
275
- role: 'ADMIN'
276
- }
277
- };
278
- ```
279
-
280
- **Helpers** (`__helpers__` or `helpers/`):
281
- ```javascript
282
- // test.helpers.js
283
- function createMockResponse(data) {
284
- return {
285
- json: jest.fn().mockReturnValue(data),
286
- status: jest.fn().mockReturnThis()
287
- };
288
- }
289
- module.exports = { createMockResponse };
290
- ```
291
-
292
- ### 6.5 Generation Order
293
-
294
- Generate files in dependency order:
295
-
296
- 1. **Fixtures** - Test data definitions
297
- 2. **Helpers** - Test utilities
298
- 3. **Mocks** - Mock definitions (if separate files)
299
- 4. **Test Files** - Actual test code
300
-
301
- ## Step 7: Write Code Plan Document
302
-
303
- Output the code plan document for traceability:
304
-
305
- ### 7.1 Copy Template to Document Path
306
-
307
- 1. **Read the template**: `templates/TEST-CODE-PLAN-TEMPLATE.md`
308
- 2. **Replace top-level placeholders** (feature name, platform, date, etc.)
309
- 3. **Create the document** using `create_file`:
310
- - Target path: `speccrew-workspace/iterations/{number}-{type}-{name}/06.system-test/code/{platform_id}/[feature]-test-code-plan.md`
311
- - Content: Template with top-level placeholders replaced
312
- 4. **Verify**: Document has complete section structure
313
-
314
- ### 7.2 Fill Each Section Using search_replace
315
-
316
- Fill each section with code plan data from Step 4.
317
-
318
- > ⚠️ **CRITICAL CONSTRAINTS:**
319
- > - **FORBIDDEN: `create_file` to rewrite the entire document**
320
- > - **MUST use `search_replace` to fill each section individually**
321
- > - **All section titles MUST be preserved**
322
-
323
- **Section Filling Guide:**
324
-
325
- | Section | Content Source |
326
- |---------|---------------|
327
- | **File-to-TestCase Mapping** | From Step 4.4 |
328
- | **Mock Strategy** | From Step 4.3 |
329
- | **Shared Resources** | From Step 4.2 |
330
- | **Test File Structure** | From Step 4.1 |
331
-
332
- ### Document Purpose
333
-
334
- - Records file-to-test-case mapping
335
- - Documents mock strategy decisions
336
- - Provides reference for future test maintenance
337
- - Enables traceability from test code to test cases
338
-
339
219
  # Key Rules
340
220
 
341
221
  | Rule | Description |