speccrew 0.6.29 → 0.6.30
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.
- package/.speccrew/agents/speccrew-team-leader-xml.md +415 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze-xml/SKILL.md +643 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-graph-xml/SKILL.md +523 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch-xml/SKILL.md +986 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-identify-entries-xml/SKILL.md +288 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze-xml/SKILL.md +524 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-graph-xml/SKILL.md +343 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract-xml/SKILL.md +385 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize-xml/SKILL.md +473 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize-xml/SKILL.md +572 -0
- package/package.json +1 -1
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: speccrew-knowledge-bizs-api-analyze-xml
|
|
3
|
+
description: Analyze a single API controller from source code to extract business features and generate API documentation using XML Block workflow. Used by Worker Agent in parallel execution during knowledge base initialization Stage 2. Each worker analyzes one API controller file.
|
|
4
|
+
tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# API Feature Analysis - Single Controller (XML Block Workflow)
|
|
8
|
+
|
|
9
|
+
> **CRITICAL CONSTRAINT**: DO NOT create temporary scripts, batch files, or workaround code files (`.py`, `.bat`, `.sh`, `.ps1`, etc.) under any circumstances. If execution encounters errors, STOP and report the exact error. Fixes must be applied to the Skill definition or source scripts — not patched at runtime.
|
|
10
|
+
|
|
11
|
+
Analyze one specific API controller from source code, extract all business features (API endpoints), and generate feature documentation. This skill operates at controller granularity - one worker per controller file.
|
|
12
|
+
|
|
13
|
+
## Trigger Scenarios
|
|
14
|
+
|
|
15
|
+
- "Analyze API controller {fileName} from source code"
|
|
16
|
+
- "Extract API features from controller {fileName}"
|
|
17
|
+
- "Generate documentation for API controller {fileName}"
|
|
18
|
+
- "Analyze API feature from features.json"
|
|
19
|
+
|
|
20
|
+
## Input Variables
|
|
21
|
+
|
|
22
|
+
| Variable | Type | Description | Example |
|
|
23
|
+
|----------|------|-------------|---------|
|
|
24
|
+
| `{{feature}}` | object | Complete feature object from features.json | - |
|
|
25
|
+
| `{{fileName}}` | string | Controller file name | `"UserController"`, `"OrderController"` |
|
|
26
|
+
| `{{sourcePath}}` | string | Relative path to source file | `"yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java"` |
|
|
27
|
+
| `{{documentPath}}` | string | Target path for generated document | `"speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md"` |
|
|
28
|
+
| `{{module}}` | string | Business module name (from feature.module) | `"system"`, `"trade"`, `"_root"` |
|
|
29
|
+
| `{{analyzed}}` | boolean | Analysis status flag | `true` / `false` |
|
|
30
|
+
| `{{platform_type}}` | string | Platform type | `"admin-api"`, `"app-api"` |
|
|
31
|
+
| `{{platform_subtype}}` | string | Platform subtype | `"spring-boot"`, `"java"` |
|
|
32
|
+
| `{{tech_stack}}` | array | Platform tech stack | `["java", "spring-boot", "mybatis-plus"]` |
|
|
33
|
+
| `{{completed_dir}}` | string | Marker files output directory | `"speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed"` |
|
|
34
|
+
| `{{sourceFile}}` | string | Source features JSON file name | `"features-admin-api.json"` |
|
|
35
|
+
| `{{language}}` | string | Target language for content | `"zh"`, `"en"` |
|
|
36
|
+
|
|
37
|
+
## Language Adaptation
|
|
38
|
+
|
|
39
|
+
**CRITICAL**: Generate all content in the language specified by the `{{language}}` parameter.
|
|
40
|
+
|
|
41
|
+
- `{{language}} == "zh"` → Generate all content in 中文
|
|
42
|
+
- `{{language}} == "en"` → Generate all content in English
|
|
43
|
+
- Other languages → Use the specified language
|
|
44
|
+
|
|
45
|
+
**All output content (feature names, descriptions, business rules) must be in the target language only.**
|
|
46
|
+
|
|
47
|
+
## Output Variables
|
|
48
|
+
|
|
49
|
+
| Variable | Type | Description |
|
|
50
|
+
|----------|------|-------------|
|
|
51
|
+
| `{{status}}` | string | Analysis status: `"success"`, `"partial"`, or `"failed"` |
|
|
52
|
+
| `{{feature_name}}` | string | Name of the analyzed controller |
|
|
53
|
+
| `{{generated_file}}` | string | Path to the generated documentation file |
|
|
54
|
+
| `{{message}}` | string | Summary message for status update |
|
|
55
|
+
|
|
56
|
+
## Execution Requirements
|
|
57
|
+
|
|
58
|
+
This skill operates in **strict sequential execution mode**:
|
|
59
|
+
- Execute steps in exact order (Step 1 → Step 2 → ... → Step 7)
|
|
60
|
+
- Output step status after each step completion
|
|
61
|
+
- Do NOT skip any step
|
|
62
|
+
|
|
63
|
+
## Output
|
|
64
|
+
|
|
65
|
+
**Generated Files:**
|
|
66
|
+
1. `{{documentPath}}` - Controller documentation file
|
|
67
|
+
2. `{{completed_dir}}/{module}-{subpath}-{fileName}.done.json` - Completion status marker
|
|
68
|
+
|
|
69
|
+
**Graph Data Generation:**
|
|
70
|
+
Graph data (nodes, edges) construction is handled by `speccrew-knowledge-bizs-api-graph-xml` Skill.
|
|
71
|
+
After completing API analysis, dispatch will invoke the graph skill to generate `.graph.json` files.
|
|
72
|
+
|
|
73
|
+
**See Also:**
|
|
74
|
+
- `speccrew-knowledge-bizs-api-graph-xml` - Constructs knowledge graph data from API analysis results
|
|
75
|
+
|
|
76
|
+
**Return Value:**
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"status": "success|partial|failed",
|
|
80
|
+
"feature": {
|
|
81
|
+
"fileName": "UserController",
|
|
82
|
+
"sourcePath": "yudao-module-system/.../controller/admin/user/UserController.java"
|
|
83
|
+
},
|
|
84
|
+
"platformType": "admin-api",
|
|
85
|
+
"module": "system",
|
|
86
|
+
"featureName": "user-management-api",
|
|
87
|
+
"generatedFile": "speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md",
|
|
88
|
+
"message": "Successfully analyzed UserController with 8 API endpoints"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The return value is used by dispatch to update the feature status in `features-{platform}.json`.
|
|
93
|
+
|
|
94
|
+
## Execution Checklist
|
|
95
|
+
|
|
96
|
+
Before executing the workflow, verify the following inputs:
|
|
97
|
+
|
|
98
|
+
- Controller: `{{fileName}}` (`{{sourcePath}}`)
|
|
99
|
+
- Target: `{{documentPath}}`
|
|
100
|
+
- Language: `{{language}}`
|
|
101
|
+
- Module: `{{module}}`
|
|
102
|
+
- Platform: `{{platform_type}}`/`{{platform_subtype}}`
|
|
103
|
+
- Completed Dir: `{{completed_dir}}`
|
|
104
|
+
- Source File: `{{sourceFile}}`
|
|
105
|
+
|
|
106
|
+
## Workflow
|
|
107
|
+
|
|
108
|
+
<!--
|
|
109
|
+
== Block Types ==
|
|
110
|
+
input : Workflow input parameters (required=mandatory, default=default value)
|
|
111
|
+
output : Workflow output results (from=data source variable)
|
|
112
|
+
task : Execute action (action: run-skill | run-script | dispatch-to-worker)
|
|
113
|
+
gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
|
|
114
|
+
loop : Iterate over collection (over=collection, as=current item)
|
|
115
|
+
event : Log/confirm/signal (action: log | confirm | signal)
|
|
116
|
+
error-handler : Exception handling (try > catch > finally)
|
|
117
|
+
checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
|
|
118
|
+
rule : Constraint declaration (level: forbidden | mandatory | note)
|
|
119
|
+
-->
|
|
120
|
+
|
|
121
|
+
```xml
|
|
122
|
+
<workflow name="api-controller-analysis" version="1.0">
|
|
123
|
+
|
|
124
|
+
<!-- ==================== INPUT PARAMETERS ==================== -->
|
|
125
|
+
<input name="feature" type="object" required="true" description="Complete feature object from features.json"/>
|
|
126
|
+
<input name="fileName" type="string" required="true" description="Controller file name"/>
|
|
127
|
+
<input name="sourcePath" type="string" required="true" description="Relative path to source file"/>
|
|
128
|
+
<input name="documentPath" type="string" required="true" description="Target path for generated document"/>
|
|
129
|
+
<input name="module" type="string" required="true" description="Business module name"/>
|
|
130
|
+
<input name="analyzed" type="boolean" required="true" description="Analysis status flag"/>
|
|
131
|
+
<input name="platform_type" type="string" required="true" description="Platform type: admin-api, app-api"/>
|
|
132
|
+
<input name="platform_subtype" type="string" required="true" description="Platform subtype: spring-boot, java"/>
|
|
133
|
+
<input name="tech_stack" type="array" required="true" description="Platform tech stack"/>
|
|
134
|
+
<input name="completed_dir" type="string" required="true" description="Marker files output directory"/>
|
|
135
|
+
<input name="sourceFile" type="string" required="true" description="Source features JSON file name"/>
|
|
136
|
+
<input name="language" type="string" required="true" description="Target language for content"/>
|
|
137
|
+
|
|
138
|
+
<!-- ==================== CONSTRAINT RULES ==================== -->
|
|
139
|
+
<rule level="forbidden" id="no-create-file-for-docs">
|
|
140
|
+
NEVER use create_file to rewrite entire document. Documents MUST be created by copying template then filling with search_replace.
|
|
141
|
+
</rule>
|
|
142
|
+
<rule level="forbidden" id="no-file-deletion">
|
|
143
|
+
NEVER delete generated files. If a file is malformed, fix it with search_replace.
|
|
144
|
+
</rule>
|
|
145
|
+
<rule level="forbidden" id="no-full-rewrite">
|
|
146
|
+
NEVER rewrite entire document. Always use targeted search_replace on specific sections.
|
|
147
|
+
</rule>
|
|
148
|
+
<rule level="mandatory" id="template-first">
|
|
149
|
+
Template copying (Step 5a) MUST execute before section filling (Step 5b).
|
|
150
|
+
</rule>
|
|
151
|
+
<rule level="mandatory" id="write-both-markers">
|
|
152
|
+
MUST write both .done.json and .graph.json marker files in Step 7.
|
|
153
|
+
</rule>
|
|
154
|
+
<rule level="mandatory" id="marker-naming">
|
|
155
|
+
Marker file names MUST follow pattern: {module}-{subpath}-{fileName}.done.json
|
|
156
|
+
</rule>
|
|
157
|
+
<rule level="mandatory" id="no-extension-in-filename">
|
|
158
|
+
fileName in .done.json MUST NOT include file extension.
|
|
159
|
+
</rule>
|
|
160
|
+
<rule level="mandatory" id="relative-paths-only">
|
|
161
|
+
ALL paths in JSON content MUST be relative, NEVER absolute paths.
|
|
162
|
+
</rule>
|
|
163
|
+
<rule level="mandatory" id="language-compliance">
|
|
164
|
+
ALL content MUST be generated in the language specified by {{language}} parameter.
|
|
165
|
+
</rule>
|
|
166
|
+
|
|
167
|
+
<!-- ==================== STEP 0: CHECK ANALYSIS STATUS ==================== -->
|
|
168
|
+
<gateway name="check-analyzed-status" mode="exclusive">
|
|
169
|
+
<branch condition="{{analyzed}} == true">
|
|
170
|
+
<event action="log" level="info" message="Step 0 Status: SKIPPED (already analyzed)"/>
|
|
171
|
+
<output name="status" value="skipped"/>
|
|
172
|
+
<output name="message" value="Controller already analyzed, skipping"/>
|
|
173
|
+
<checkpoint name="skip-complete" verify="true"/>
|
|
174
|
+
</branch>
|
|
175
|
+
<branch condition="{{analyzed}} == false">
|
|
176
|
+
<event action="log" level="info" message="Step 0 Status: PROCEEDING (analysis required)"/>
|
|
177
|
+
</branch>
|
|
178
|
+
</gateway>
|
|
179
|
+
|
|
180
|
+
<!-- ==================== STEP 1: READ ANALYSIS TEMPLATE ==================== -->
|
|
181
|
+
<task name="step1-read-template" action="run-skill">
|
|
182
|
+
<description>Read the appropriate template based on tech stack</description>
|
|
183
|
+
<parameter name="tech_stack">{{tech_stack}}</parameter>
|
|
184
|
+
<script>
|
|
185
|
+
<!-- Template Selection Logic -->
|
|
186
|
+
<gateway name="template-selection" mode="exclusive">
|
|
187
|
+
<branch condition="{{tech_stack}} contains 'fastapi' OR {{tech_stack}} contains 'python'">
|
|
188
|
+
<output name="templateFile" value="../speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md"/>
|
|
189
|
+
</branch>
|
|
190
|
+
<branch condition="{{tech_stack}} contains 'dotnet' OR {{tech_stack}} contains '.net'">
|
|
191
|
+
<output name="templateFile" value="../speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md"/>
|
|
192
|
+
</branch>
|
|
193
|
+
<branch condition="default">
|
|
194
|
+
<output name="templateFile" value="../speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md"/>
|
|
195
|
+
</branch>
|
|
196
|
+
</gateway>
|
|
197
|
+
|
|
198
|
+
<!-- Read Template Content -->
|
|
199
|
+
<task action="read-file" target="{{templateFile}}">
|
|
200
|
+
<output name="templateContent" from="file.content"/>
|
|
201
|
+
<output name="sectionCount" from="template.sections.count"/>
|
|
202
|
+
</task>
|
|
203
|
+
|
|
204
|
+
<!-- Validate Template Structure -->
|
|
205
|
+
<checkpoint name="template-loaded" verify="{{templateContent}} != null AND {{templateContent}} != ''"/>
|
|
206
|
+
<event action="log" level="info" message="Step 1 Status: COMPLETED - Template loaded, {{sectionCount}} sections identified for analysis"/>
|
|
207
|
+
</script>
|
|
208
|
+
</task>
|
|
209
|
+
|
|
210
|
+
<!-- ==================== STEP 2: READ CONTROLLER AND ANALYZE API STRUCTURE ==================== -->
|
|
211
|
+
<task name="step2-read-controller" action="run-skill">
|
|
212
|
+
<description>Read controller file and analyze API handler structure</description>
|
|
213
|
+
<parameter name="sourcePath">{{sourcePath}}</parameter>
|
|
214
|
+
<parameter name="tech_stack">{{tech_stack}}</parameter>
|
|
215
|
+
<script>
|
|
216
|
+
<!-- Read Source File -->
|
|
217
|
+
<task action="read-file" target="{{sourcePath}}">
|
|
218
|
+
<output name="sourceContent" from="file.content"/>
|
|
219
|
+
<output name="lineCount" from="file.lineCount"/>
|
|
220
|
+
</task>
|
|
221
|
+
|
|
222
|
+
<!-- Analyze API Structure Based on Tech Stack -->
|
|
223
|
+
<gateway name="tech-specific-analysis" mode="exclusive">
|
|
224
|
+
<branch condition="{{tech_stack}} contains 'java' OR {{tech_stack}} contains 'spring'">
|
|
225
|
+
<task action="parse-spring-controller">
|
|
226
|
+
<input name="content">{{sourceContent}}</input>
|
|
227
|
+
<output name="endpoints" from="parser.endpoints"/>
|
|
228
|
+
<output name="endpointCount" from="parser.endpointCount"/>
|
|
229
|
+
<output name="services" from="parser.services"/>
|
|
230
|
+
<output name="serviceCount" from="parser.serviceCount"/>
|
|
231
|
+
</task>
|
|
232
|
+
</branch>
|
|
233
|
+
<branch condition="{{tech_stack}} contains 'fastapi' OR {{tech_stack}} contains 'python'">
|
|
234
|
+
<task action="parse-fastapi-router">
|
|
235
|
+
<input name="content">{{sourceContent}}</input>
|
|
236
|
+
<output name="endpoints" from="parser.endpoints"/>
|
|
237
|
+
<output name="endpointCount" from="parser.endpointCount"/>
|
|
238
|
+
<output name="services" from="parser.services"/>
|
|
239
|
+
<output name="serviceCount" from="parser.serviceCount"/>
|
|
240
|
+
</task>
|
|
241
|
+
</branch>
|
|
242
|
+
<branch condition="{{tech_stack}} contains 'dotnet' OR {{tech_stack}} contains '.net'">
|
|
243
|
+
<task action="parse-dotnet-controller">
|
|
244
|
+
<input name="content">{{sourceContent}}</input>
|
|
245
|
+
<output name="endpoints" from="parser.endpoints"/>
|
|
246
|
+
<output name="endpointCount" from="parser.endpointCount"/>
|
|
247
|
+
<output name="services" from="parser.services"/>
|
|
248
|
+
<output name="serviceCount" from="parser.serviceCount"/>
|
|
249
|
+
</task>
|
|
250
|
+
</branch>
|
|
251
|
+
<branch condition="default">
|
|
252
|
+
<task action="parse-generic-controller">
|
|
253
|
+
<input name="content">{{sourceContent}}</input>
|
|
254
|
+
<output name="endpoints" from="parser.endpoints"/>
|
|
255
|
+
<output name="endpointCount" from="parser.endpointCount"/>
|
|
256
|
+
<output name="services" from="parser.services"/>
|
|
257
|
+
<output name="serviceCount" from="parser.serviceCount"/>
|
|
258
|
+
</task>
|
|
259
|
+
</branch>
|
|
260
|
+
</gateway>
|
|
261
|
+
|
|
262
|
+
<checkpoint name="controller-analyzed" verify="{{sourceContent}} != null"/>
|
|
263
|
+
<event action="log" level="info" message="Step 2 Status: COMPLETED - Read {{sourcePath}} ({{lineCount}} lines), Analyzed {{endpointCount}} endpoints, {{serviceCount}} services"/>
|
|
264
|
+
</script>
|
|
265
|
+
</task>
|
|
266
|
+
|
|
267
|
+
<!-- ==================== STEP 3: EXTRACT API FEATURES ==================== -->
|
|
268
|
+
<task name="step3-extract-features" action="run-skill">
|
|
269
|
+
<description>Extract API features, business flows, and data structures from controller analysis</description>
|
|
270
|
+
<parameter name="endpoints">{{endpoints}}</parameter>
|
|
271
|
+
<parameter name="sourcePath">{{sourcePath}}</parameter>
|
|
272
|
+
<parameter name="language">{{language}}</parameter>
|
|
273
|
+
<script>
|
|
274
|
+
<!-- Read Mermaid Rules -->
|
|
275
|
+
<task action="read-file" target="speccrew-workspace/docs/rules/mermaid-rule.md">
|
|
276
|
+
<output name="mermaidRules" from="file.content"/>
|
|
277
|
+
</task>
|
|
278
|
+
|
|
279
|
+
<!-- Extract Each API Endpoint Details -->
|
|
280
|
+
<loop name="extract-endpoint-details" over="{{endpoints}}" as="endpoint">
|
|
281
|
+
<task action="analyze-endpoint">
|
|
282
|
+
<input name="endpoint">{{endpoint}}</input>
|
|
283
|
+
<input name="tech_stack">{{tech_stack}}</input>
|
|
284
|
+
<output name="requestDTO" from="analysis.requestDTO"/>
|
|
285
|
+
<output name="responseDTO" from="analysis.responseDTO"/>
|
|
286
|
+
<output name="businessFlow" from="analysis.flow"/>
|
|
287
|
+
<output name="validationRules" from="analysis.validations"/>
|
|
288
|
+
</task>
|
|
289
|
+
</loop>
|
|
290
|
+
|
|
291
|
+
<!-- Trace Backend Call Chain -->
|
|
292
|
+
<task action="trace-call-chain">
|
|
293
|
+
<input name="endpoints">{{endpoints}}</input>
|
|
294
|
+
<input name="services">{{services}}</input>
|
|
295
|
+
<input name="tech_stack">{{tech_stack}}</input>
|
|
296
|
+
<output name="callChains" from="trace.chains"/>
|
|
297
|
+
<output name="databaseTables" from="trace.tables"/>
|
|
298
|
+
<output name="transactionBoundaries" from="trace.transactions"/>
|
|
299
|
+
<output name="crossModuleCalls" from="trace.crossModules"/>
|
|
300
|
+
</task>
|
|
301
|
+
|
|
302
|
+
<!-- Generate Mermaid Flowcharts -->
|
|
303
|
+
<task action="generate-flowcharts">
|
|
304
|
+
<input name="endpoints">{{endpoints}}</input>
|
|
305
|
+
<input name="callChains">{{callChains}}</input>
|
|
306
|
+
<input name="mermaidRules">{{mermaidRules}}</input>
|
|
307
|
+
<output name="flowcharts" from="generation.flowcharts"/>
|
|
308
|
+
<output name="flowCount" from="generation.count"/>
|
|
309
|
+
</task>
|
|
310
|
+
|
|
311
|
+
<checkpoint name="features-extracted" verify="{{endpointCount}} > 0"/>
|
|
312
|
+
<event action="log" level="info" message="Step 3 Status: COMPLETED - Extracted {{endpointCount}} API endpoints, {{flowCount}} business flows"/>
|
|
313
|
+
</script>
|
|
314
|
+
</task>
|
|
315
|
+
|
|
316
|
+
<!-- ==================== STEP 4: FIND API CONSUMERS ==================== -->
|
|
317
|
+
<task name="step4-find-consumers" action="run-skill">
|
|
318
|
+
<description>Search frontend page files to find which pages call the APIs in this controller</description>
|
|
319
|
+
<parameter name="endpoints">{{endpoints}}</parameter>
|
|
320
|
+
<parameter name="fileName">{{fileName}}</parameter>
|
|
321
|
+
<script>
|
|
322
|
+
<!-- Search for API Client Calls -->
|
|
323
|
+
<task action="grep-search">
|
|
324
|
+
<input name="pattern">{{fileName}}</input>
|
|
325
|
+
<input name="glob">*.{vue,tsx,jsx,ts,js}</input>
|
|
326
|
+
<output name="clientMatches" from="search.results"/>
|
|
327
|
+
</task>
|
|
328
|
+
|
|
329
|
+
<!-- Search for HTTP Requests to Controller Path -->
|
|
330
|
+
<loop name="search-endpoint-paths" over="{{endpoints}}" as="endpoint">
|
|
331
|
+
<task action="grep-search">
|
|
332
|
+
<input name="pattern">{{endpoint.path}}</input>
|
|
333
|
+
<input name="glob">*.{vue,tsx,jsx,ts,js}</input>
|
|
334
|
+
<output name="pathMatches" from="search.results" accumulate="true"/>
|
|
335
|
+
</task>
|
|
336
|
+
</loop>
|
|
337
|
+
|
|
338
|
+
<!-- Compile Consumer Pages -->
|
|
339
|
+
<task action="compile-consumers">
|
|
340
|
+
<input name="clientMatches">{{clientMatches}}</input>
|
|
341
|
+
<input name="pathMatches">{{pathMatches}}</input>
|
|
342
|
+
<output name="consumerPages" from="compilation.pages"/>
|
|
343
|
+
<output name="consumerCount" from="compilation.count"/>
|
|
344
|
+
</task>
|
|
345
|
+
|
|
346
|
+
<event action="log" level="info" message="Step 4 Status: COMPLETED - Found {{consumerCount}} API consumers"/>
|
|
347
|
+
</script>
|
|
348
|
+
</task>
|
|
349
|
+
|
|
350
|
+
<!-- ==================== STEP 5A: COPY TEMPLATE TO DOCUMENT PATH ==================== -->
|
|
351
|
+
<task name="step5a-copy-template" action="run-skill">
|
|
352
|
+
<description>Copy the appropriate template to the target document path and replace top-level placeholders</description>
|
|
353
|
+
<parameter name="templateContent">{{templateContent}}</parameter>
|
|
354
|
+
<parameter name="documentPath">{{documentPath}}</parameter>
|
|
355
|
+
<parameter name="fileName">{{fileName}}</parameter>
|
|
356
|
+
<parameter name="sourcePath">{{sourcePath}}</parameter>
|
|
357
|
+
<parameter name="module">{{module}}</parameter>
|
|
358
|
+
<script>
|
|
359
|
+
<!-- Replace Top-Level Placeholders -->
|
|
360
|
+
<task action="replace-placeholders">
|
|
361
|
+
<input name="template">{{templateContent}}</input>
|
|
362
|
+
<replacements>
|
|
363
|
+
<replacement from="{Controller}" to="{{fileName}}"/>
|
|
364
|
+
<replacement from="{sourcePath}" to="{{sourcePath}}"/>
|
|
365
|
+
<replacement from="{documentPath}" to="{{documentPath}}"/>
|
|
366
|
+
<replacement from="{module}" to="{{module}}"/>
|
|
367
|
+
<replacement from="[Feature Name]" to="{{fileName}}"/>
|
|
368
|
+
</replacements>
|
|
369
|
+
<output name="documentSkeleton" from="result.content"/>
|
|
370
|
+
</task>
|
|
371
|
+
|
|
372
|
+
<!-- Create Document File -->
|
|
373
|
+
<task action="create-file" target="{{documentPath}}">
|
|
374
|
+
<content>{{documentSkeleton}}</content>
|
|
375
|
+
</task>
|
|
376
|
+
|
|
377
|
+
<!-- Verify Document Skeleton -->
|
|
378
|
+
<task action="verify-structure">
|
|
379
|
+
<input name="documentPath">{{documentPath}}</input>
|
|
380
|
+
<output name="structureValid" from="verification.valid"/>
|
|
381
|
+
</task>
|
|
382
|
+
|
|
383
|
+
<checkpoint name="template-copied" verify="file.exists({{documentPath}}) AND {{structureValid}}"/>
|
|
384
|
+
<event action="log" level="info" message="Step 5a Status: COMPLETED - Template copied to {{documentPath}}, ready for section filling"/>
|
|
385
|
+
</script>
|
|
386
|
+
</task>
|
|
387
|
+
|
|
388
|
+
<!-- ==================== STEP 5B: FILL EACH SECTION USING SEARCH_REPLACE ==================== -->
|
|
389
|
+
<task name="step5b-fill-sections" action="run-skill">
|
|
390
|
+
<description>Fill each section of the document with actual data extracted from source code analysis</description>
|
|
391
|
+
<parameter name="documentPath">{{documentPath}}</parameter>
|
|
392
|
+
<parameter name="endpoints">{{endpoints}}</parameter>
|
|
393
|
+
<parameter name="consumerPages">{{consumerPages}}</parameter>
|
|
394
|
+
<parameter name="callChains">{{callChains}}</parameter>
|
|
395
|
+
<parameter name="flowcharts">{{flowcharts}}</parameter>
|
|
396
|
+
<parameter name="databaseTables">{{databaseTables}}</parameter>
|
|
397
|
+
<parameter name="language">{{language}}</parameter>
|
|
398
|
+
<script>
|
|
399
|
+
<!-- Calculate Dynamic Path Prefix -->
|
|
400
|
+
<task action="calculate-path-prefix">
|
|
401
|
+
<input name="documentPath">{{documentPath}}</input>
|
|
402
|
+
<output name="pathPrefix" from="calculation.prefix"/>
|
|
403
|
+
</task>
|
|
404
|
+
|
|
405
|
+
<!-- Section 1: Content Overview -->
|
|
406
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
407
|
+
<anchor><!-- AI-TAG: OVERVIEW --></anchor>
|
|
408
|
+
<replace>{{overviewContent}}</replace>
|
|
409
|
+
</task>
|
|
410
|
+
|
|
411
|
+
<!-- Section 2: API Endpoints -->
|
|
412
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
413
|
+
<anchor><!-- AI-TAG: API_ENDPOINTS --></anchor>
|
|
414
|
+
<replace>{{endpointDefinitions}}</replace>
|
|
415
|
+
</task>
|
|
416
|
+
|
|
417
|
+
<!-- Section 3: Data Fields -->
|
|
418
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
419
|
+
<anchor><!-- AI-TAG: DATA_DEFINITION --></anchor>
|
|
420
|
+
<replace>{{dataFieldDefinitions}}</replace>
|
|
421
|
+
</task>
|
|
422
|
+
|
|
423
|
+
<!-- Section 4: References -->
|
|
424
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
425
|
+
<anchor><!-- AI-TAG: REFERENCES --></anchor>
|
|
426
|
+
<replace>{{referencesContent}}</replace>
|
|
427
|
+
</task>
|
|
428
|
+
|
|
429
|
+
<!-- Section 5: Business Rules -->
|
|
430
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
431
|
+
<anchor><!-- AI-TAG: BUSINESS_RULES --></anchor>
|
|
432
|
+
<replace>{{businessRulesContent}}</replace>
|
|
433
|
+
</task>
|
|
434
|
+
|
|
435
|
+
<!-- Section 6: Dependencies -->
|
|
436
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
437
|
+
<anchor><!-- AI-TAG: DEPENDENCIES --></anchor>
|
|
438
|
+
<replace>{{dependenciesContent}}</replace>
|
|
439
|
+
</task>
|
|
440
|
+
|
|
441
|
+
<!-- Section 7: Performance -->
|
|
442
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
443
|
+
<anchor><!-- AI-TAG: PERFORMANCE --></anchor>
|
|
444
|
+
<replace>{{performanceContent}}</replace>
|
|
445
|
+
</task>
|
|
446
|
+
|
|
447
|
+
<!-- Section 8: Troubleshooting -->
|
|
448
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
449
|
+
<anchor><!-- AI-TAG: TROUBLESHOOTING --></anchor>
|
|
450
|
+
<replace>{{troubleshootingContent}}</replace>
|
|
451
|
+
</task>
|
|
452
|
+
|
|
453
|
+
<!-- Section 9: Notes -->
|
|
454
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
455
|
+
<anchor><!-- AI-TAG: ADDITIONAL_NOTES --></anchor>
|
|
456
|
+
<replace>{{additionalNotes}}</replace>
|
|
457
|
+
</task>
|
|
458
|
+
|
|
459
|
+
<!-- Section 10: Appendix -->
|
|
460
|
+
<task action="search_replace" target="{{documentPath}}">
|
|
461
|
+
<search>## 10. Appendix.*</search>
|
|
462
|
+
<replace>## 10. Appendix
|
|
463
|
+
|
|
464
|
+
{{appendixContent}}</replace>
|
|
465
|
+
</task>
|
|
466
|
+
|
|
467
|
+
<!-- Get File Size -->
|
|
468
|
+
<task action="get-file-size" target="{{documentPath}}">
|
|
469
|
+
<output name="fileSize" from="file.size"/>
|
|
470
|
+
</task>
|
|
471
|
+
|
|
472
|
+
<checkpoint name="all-sections-filled" verify="all.sections.filled"/>
|
|
473
|
+
<event action="log" level="info" message="Step 5b Status: COMPLETED - All sections filled at {{documentPath}} ({{fileSize}} bytes)"/>
|
|
474
|
+
</script>
|
|
475
|
+
</task>
|
|
476
|
+
|
|
477
|
+
<!-- ==================== STEP 6: REPORT RESULTS ==================== -->
|
|
478
|
+
<task name="step6-report" action="run-skill">
|
|
479
|
+
<description>Return analysis result summary to dispatch</description>
|
|
480
|
+
<script>
|
|
481
|
+
<gateway name="determine-status" mode="exclusive">
|
|
482
|
+
<branch condition="{{endpointCount}} == 0">
|
|
483
|
+
<output name="status" value="failed"/>
|
|
484
|
+
<output name="message" value="No API endpoints found in controller"/>
|
|
485
|
+
</branch>
|
|
486
|
+
<branch condition="{{errors}} != null AND {{errors.length}} > 0">
|
|
487
|
+
<output name="status" value="partial"/>
|
|
488
|
+
<output name="message" value="Analysis completed with {{errors.length}} warnings"/>
|
|
489
|
+
</branch>
|
|
490
|
+
<branch condition="default">
|
|
491
|
+
<output name="status" value="success"/>
|
|
492
|
+
<output name="message" value="Successfully analyzed {{fileName}} with {{endpointCount}} API endpoints"/>
|
|
493
|
+
</branch>
|
|
494
|
+
</gateway>
|
|
495
|
+
|
|
496
|
+
<output name="feature_name" value="{{fileName}}"/>
|
|
497
|
+
<output name="generated_file" value="{{documentPath}}"/>
|
|
498
|
+
|
|
499
|
+
<event action="log" level="info" message="Step 6 Status: COMPLETED - Analysis {{status}}: {{message}}"/>
|
|
500
|
+
</script>
|
|
501
|
+
</task>
|
|
502
|
+
|
|
503
|
+
<!-- ==================== STEP 7: WRITE COMPLETION MARKERS ==================== -->
|
|
504
|
+
<task name="step7-write-markers" action="run-skill">
|
|
505
|
+
<description>Write analysis results to marker files for dispatch batch processing</description>
|
|
506
|
+
<parameter name="completed_dir">{{completed_dir}}</parameter>
|
|
507
|
+
<parameter name="module">{{module}}</parameter>
|
|
508
|
+
<parameter name="sourcePath">{{sourcePath}}</parameter>
|
|
509
|
+
<parameter name="fileName">{{fileName}}</parameter>
|
|
510
|
+
<parameter name="sourceFile">{{sourceFile}}</parameter>
|
|
511
|
+
<parameter name="documentPath">{{documentPath}}</parameter>
|
|
512
|
+
<parameter name="status">{{status}}</parameter>
|
|
513
|
+
<parameter name="message">{{message}}</parameter>
|
|
514
|
+
<script>
|
|
515
|
+
<!-- Calculate Subpath from Source Path -->
|
|
516
|
+
<task action="calculate-subpath">
|
|
517
|
+
<input name="sourcePath">{{sourcePath}}</input>
|
|
518
|
+
<output name="subpath" from="calculation.subpath"/>
|
|
519
|
+
</task>
|
|
520
|
+
|
|
521
|
+
<!-- Generate Marker File Name -->
|
|
522
|
+
<task action="generate-marker-name">
|
|
523
|
+
<input name="module">{{module}}</input>
|
|
524
|
+
<input name="subpath">{{subpath}}</input>
|
|
525
|
+
<input name="fileName">{{fileName}}</input>
|
|
526
|
+
<output name="markerName" from="generation.name"/>
|
|
527
|
+
</task>
|
|
528
|
+
|
|
529
|
+
<!-- Pre-write Verification -->
|
|
530
|
+
<checkpoint name="pre-write-check" verify="{{fileName}} does-not-contain '.' AND {{sourceFile}} matches 'features-*.json'"/>
|
|
531
|
+
|
|
532
|
+
<!-- Write .done.json File -->
|
|
533
|
+
<task action="create-file" target="{{completed_dir}}/{{markerName}}.done.json">
|
|
534
|
+
<content>{
|
|
535
|
+
"fileName": "{{fileName}}",
|
|
536
|
+
"sourcePath": "{{sourcePath}}",
|
|
537
|
+
"sourceFile": "{{sourceFile}}",
|
|
538
|
+
"module": "{{module}}",
|
|
539
|
+
"documentPath": "{{documentPath}}",
|
|
540
|
+
"status": "{{status}}",
|
|
541
|
+
"analysisNotes": "{{message}}"
|
|
542
|
+
}</content>
|
|
543
|
+
</task>
|
|
544
|
+
|
|
545
|
+
<!-- Verify Marker File Written -->
|
|
546
|
+
<checkpoint name="marker-written" verify="file.exists({{completed_dir}}/{{markerName}}.done.json)"/>
|
|
547
|
+
|
|
548
|
+
<!-- Dispatch to Graph Skill for .graph.json -->
|
|
549
|
+
<task name="dispatch-graph-generation" action="dispatch-to-worker">
|
|
550
|
+
<skill>speccrew-knowledge-bizs-api-graph-xml</skill>
|
|
551
|
+
<parameters>
|
|
552
|
+
<parameter name="controllerFile">{{fileName}}</parameter>
|
|
553
|
+
<parameter name="sourcePath">{{sourcePath}}</parameter>
|
|
554
|
+
<parameter name="endpoints">{{endpoints}}</parameter>
|
|
555
|
+
<parameter name="completed_dir">{{completed_dir}}</parameter>
|
|
556
|
+
<parameter name="markerName">{{markerName}}</parameter>
|
|
557
|
+
</parameters>
|
|
558
|
+
</task>
|
|
559
|
+
|
|
560
|
+
<event action="log" level="info" message="Step 7 Status: COMPLETED - Marker file written to {{completed_dir}}"/>
|
|
561
|
+
</script>
|
|
562
|
+
</task>
|
|
563
|
+
|
|
564
|
+
<!-- ==================== FINAL OUTPUT ==================== -->
|
|
565
|
+
<output name="status" from="step6-report.status"/>
|
|
566
|
+
<output name="feature" from="step6-report.feature"/>
|
|
567
|
+
<output name="platformType" from="input.platform_type"/>
|
|
568
|
+
<output name="module" from="input.module"/>
|
|
569
|
+
<output name="featureName" from="step6-report.feature_name"/>
|
|
570
|
+
<output name="generatedFile" from="step6-report.generated_file"/>
|
|
571
|
+
<output name="message" from="step6-report.message"/>
|
|
572
|
+
|
|
573
|
+
<!-- ==================== ERROR HANDLING ==================== -->
|
|
574
|
+
<error-handler>
|
|
575
|
+
<catch type="file-not-found">
|
|
576
|
+
<event action="log" level="error" message="Source file not found: {{sourcePath}}"/>
|
|
577
|
+
<output name="status" value="failed"/>
|
|
578
|
+
<output name="message" value="Source file not found: {{sourcePath}}"/>
|
|
579
|
+
</catch>
|
|
580
|
+
<catch type="template-error">
|
|
581
|
+
<event action="log" level="error" message="Template processing error"/>
|
|
582
|
+
<output name="status" value="failed"/>
|
|
583
|
+
<output name="message" value="Failed to process template"/>
|
|
584
|
+
</catch>
|
|
585
|
+
<catch type="marker-write-error">
|
|
586
|
+
<event action="log" level="error" message="Failed to write marker file: {{error.message}}"/>
|
|
587
|
+
<output name="status" value="failed"/>
|
|
588
|
+
<output name="message" value="Failed to write completion marker"/>
|
|
589
|
+
</catch>
|
|
590
|
+
<catch type="validation-error">
|
|
591
|
+
<event action="log" level="error" message="Validation failed: {{error.message}}"/>
|
|
592
|
+
<output name="status" value="partial"/>
|
|
593
|
+
<output name="message" value="Analysis completed with validation errors"/>
|
|
594
|
+
</catch>
|
|
595
|
+
<finally>
|
|
596
|
+
<event action="log" level="info" message="Workflow execution completed"/>
|
|
597
|
+
</finally>
|
|
598
|
+
</error-handler>
|
|
599
|
+
|
|
600
|
+
</workflow>
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
## Reference Guides
|
|
604
|
+
|
|
605
|
+
### Mermaid Guide
|
|
606
|
+
|
|
607
|
+
When generating Mermaid diagrams, follow compatibility guidelines:
|
|
608
|
+
- Use `graph TB` or `graph LR` syntax (not `flowchart`)
|
|
609
|
+
- No parentheses `()` in node text
|
|
610
|
+
- No HTML tags like `<br/>`
|
|
611
|
+
- No `style` definitions
|
|
612
|
+
|
|
613
|
+
### Business Flow Guidelines
|
|
614
|
+
|
|
615
|
+
- One diagram per API request
|
|
616
|
+
- Focus on business operations
|
|
617
|
+
- Refer to `templates/FEATURE-DETAIL-TEMPLATE.md`
|
|
618
|
+
|
|
619
|
+
## Constraints
|
|
620
|
+
|
|
621
|
+
1. **DO NOT analyze files outside the specified `{{sourcePath}}`**
|
|
622
|
+
2. **DO NOT generate separate documents for internal/private methods**
|
|
623
|
+
3. **All content MUST be in the language specified by `{{language}}`**
|
|
624
|
+
4. **Use `search_replace` for section filling, NEVER rewrite entire document**
|
|
625
|
+
5. **Mermaid diagrams MUST follow the rules in `mermaid-rule.md`**
|
|
626
|
+
6. **All links MUST use relative paths, NEVER `file://` protocol**
|
|
627
|
+
7. **Marker files MUST follow naming convention: `{module}-{subpath}-{fileName}.done.json`**
|
|
628
|
+
8. **fileName in .done.json MUST NOT include file extension**
|
|
629
|
+
9. **ALL paths in JSON MUST be relative, not absolute**
|
|
630
|
+
|
|
631
|
+
## Checklist
|
|
632
|
+
|
|
633
|
+
- [ ] Template file selected based on `{{tech_stack}}`
|
|
634
|
+
- [ ] Template content read successfully
|
|
635
|
+
- [ ] Controller file read and analyzed
|
|
636
|
+
- [ ] API endpoints extracted with business flows
|
|
637
|
+
- [ ] API consumers found
|
|
638
|
+
- [ ] Template copied to document path
|
|
639
|
+
- [ ] All sections filled using search_replace
|
|
640
|
+
- [ ] All content in target language (`{{language}}`)
|
|
641
|
+
- [ ] Results reported in JSON format
|
|
642
|
+
- [ ] .done.json marker file written successfully
|
|
643
|
+
- [ ] .graph.json generation dispatched to graph skill
|