speccrew 0.1.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.
- package/.speccrew/agents/speccrew-feature-designer.md +142 -0
- package/.speccrew/agents/speccrew-product-manager.md +61 -0
- package/.speccrew/agents/speccrew-system-designer.md +200 -0
- package/.speccrew/agents/speccrew-system-developer.md +238 -0
- package/.speccrew/agents/speccrew-task-worker.md +80 -0
- package/.speccrew/agents/speccrew-team-leader.md +92 -0
- package/.speccrew/agents/speccrew-test-manager.md +313 -0
- package/.speccrew/skills/speccrew-create-agents/SKILL.md +98 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/designer-agent.md +54 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/dev-agent.md +79 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/test-agent.md +80 -0
- package/.speccrew/skills/speccrew-dev-backend/SKILL.md +205 -0
- package/.speccrew/skills/speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-dev-desktop/SKILL.md +258 -0
- package/.speccrew/skills/speccrew-dev-desktop/templates/TASK-RECORD-TEMPLATE.md +161 -0
- package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +202 -0
- package/.speccrew/skills/speccrew-dev-frontend/templates/TASK-RECORD-TEMPLATE.md +115 -0
- package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +200 -0
- package/.speccrew/skills/speccrew-dev-mobile/templates/TASK-RECORD-TEMPLATE.md +125 -0
- package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +73 -0
- package/.speccrew/skills/speccrew-fd-api-contract/templates/API-CONTRACT-TEMPLATE.md +96 -0
- package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +395 -0
- package/.speccrew/skills/speccrew-fd-feature-design/templates/FEATURE-SPEC-TEMPLATE.md +387 -0
- package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +80 -0
- package/.speccrew/skills/speccrew-get-timestamp/scripts/get-timestamp.js +35 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +1116 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md +462 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-JAVA.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md +464 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/MODULE-OVERVIEW-TEMPLATE.md +367 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +667 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +176 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +150 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +106 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +249 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +848 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +226 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +264 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +34 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +867 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +26 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +165 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/apply-module-mapping.js +208 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/extract-module-summary.js +180 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/reindex-modules.js +358 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +1055 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-DESKTOP.md +303 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-ELECTRON.md +327 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MINIAPP.md +292 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MOBILE.md +281 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI.md +324 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +270 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +229 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/scripts/graph-query.js +549 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +181 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/scripts/graph-write.js +651 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +305 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/templates/MODULE-OVERVIEW-TEMPLATE.md +400 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +351 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/templates/SYSTEM-OVERVIEW-TEMPLATE.md +294 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +683 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +550 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/templates/techs-manifest-EXAMPLE.json +35 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +1087 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/ARCHITECTURE-TEMPLATE.md +240 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COLOR-SYSTEM-TEMPLATE.md +68 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COMPONENT-LIBRARY-TEMPLATE.md +86 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-BUILD-TEMPLATE.md +466 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DATA-TEMPLATE.md +432 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DESIGN-TEMPLATE.md +1209 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DEV-TEMPLATE.md +1433 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-SYSTEM-TEST-TEMPLATE.md +1052 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-UNIT-TEST-TEMPLATE.md +946 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/INDEX-TEMPLATE.md +29 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-LAYOUTS-TEMPLATE.md +69 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/TECH-STACK-TEMPLATE.md +232 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +628 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +392 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +489 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/templates/INDEX-TEMPLATE.md +243 -0
- package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +269 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +562 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/BUSINESS-COMPONENTS-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMMON-COMPONENTS-TEMPLATE.md +177 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-INDIVIDUAL-TEMPLATE.md +80 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-LIBRARY-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-INDIVIDUAL-TEMPLATE.md +97 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-PATTERNS-TEMPLATE.md +208 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/NAVIGATION-PATTERNS-TEMPLATE.md +157 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-INDIVIDUAL-TEMPLATE.md +123 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +58 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/SPACING-TEMPLATE.md +119 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/STYLE-SYSTEM-TEMPLATE.md +117 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/TYPOGRAPHY-TEMPLATE.md +107 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/UI-STYLE-GUIDE-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +434 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/BIZS-MODELING-TEMPLATE.md +332 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/PRD-TEMPLATE.md +200 -0
- package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +195 -0
- package/.speccrew/skills/speccrew-project-diagnosis/SKILL.md +208 -0
- package/.speccrew/skills/speccrew-project-diagnosis/templates/DIAGNOSIS-REPORT-TEMPLATE.md +202 -0
- package/.speccrew/skills/speccrew-sd-backend/SKILL.md +188 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/INDEX-TEMPLATE.md +85 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/SD-BACKEND-TEMPLATE.md +269 -0
- package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +192 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/INDEX-TEMPLATE.md +271 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md +673 -0
- package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +176 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/INDEX-TEMPLATE.md +184 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/SD-FRONTEND-TEMPLATE.md +382 -0
- package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +189 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/INDEX-TEMPLATE.md +219 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/SD-MOBILE-TEMPLATE.md +534 -0
- package/.speccrew/skills/speccrew-test-case-design/SKILL.md +284 -0
- package/.speccrew/skills/speccrew-test-case-design/templates/TEST-CASE-DESIGN-TEMPLATE.md +263 -0
- package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +313 -0
- package/.speccrew/skills/speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md +180 -0
- package/.speccrew/skills/speccrew-test-execute/SKILL.md +283 -0
- package/.speccrew/skills/speccrew-test-execute/templates/BUG-REPORT-TEMPLATE.md +50 -0
- package/.speccrew/skills/speccrew-test-execute/templates/TEST-REPORT-TEMPLATE.md +57 -0
- package/.speccrew/skills/speccrew-workflow-diagnose/SKILL.md +155 -0
- package/LICENSE +21 -0
- package/README.ar.md +318 -0
- package/README.en.md +318 -0
- package/README.es.md +318 -0
- package/README.md +340 -0
- package/bin/cli.js +62 -0
- package/lib/commands/doctor.js +138 -0
- package/lib/commands/init.js +231 -0
- package/lib/commands/list.js +114 -0
- package/lib/commands/uninstall.js +117 -0
- package/lib/commands/update.js +351 -0
- package/lib/ide-adapters.js +73 -0
- package/lib/utils.js +104 -0
- package/package.json +28 -0
- package/workspace-template/docs/configs/document-templates.json +667 -0
- package/workspace-template/docs/configs/platform-mapping.json +194 -0
- package/workspace-template/docs/configs/tech-stack-mappings.json +313 -0
- package/workspace-template/docs/configs/validation-rules.json +87 -0
- package/workspace-template/docs/rules/mermaid-rule.md +114 -0
- package/workspace-template/docs/solutions/Agent/346/212/200/350/203/275/345/256/232/344/271/211+/351/234/200/346/261/202/346/226/207/346/241/243+UML/344/275/277/347/224/250/346/250/241/346/235/277/357/274/210ISA-95/345/205/255/346/256/265/345/274/217/350/236/215/345/220/210/347/211/210/357/274/211.md +586 -0
- package/workspace-template/docs/solutions/agent-knowledge-map.md +238 -0
- package/workspace-template/docs/solutions/bizs-knowledge-pipeline.md +678 -0
- package/workspace-template/docs/solutions/harness.md +410 -0
- package/workspace-template/docs/solutions/knowledge-incremental-sync-spec.md +943 -0
- package/workspace-template/docs/solutions/techs-knowledge-pipeline.md +803 -0
- package/workspace-template/docs/solutions/workspace-structure.md +318 -0
|
@@ -0,0 +1,1116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: speccrew-knowledge-bizs-api-analyze
|
|
3
|
+
description: Analyze a single API controller from source code to extract business features and generate API documentation. 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
|
|
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 | Directory for completion marker files (`sync_state_path/completed`) | `"speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed"` |
|
|
34
|
+
| `{{sourceFile}}` | string | Source features JSON file name | `"features-admin-api.json"` |
|
|
35
|
+
| `{{language}}` | string | **REQUIRED** - Target language for generated 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
|
+
## 🚫 ABSOLUTE PROHIBITIONS (ZERO TOLERANCE)
|
|
64
|
+
|
|
65
|
+
> **These rules apply to ALL steps. Violation = task failure.**
|
|
66
|
+
|
|
67
|
+
1. **FORBIDDEN: `create_file` for documents** — NEVER use `create_file` to write the analysis document (`{{documentPath}}`). Documents MUST be created by copying the template (Step 5a) then filling sections with `search_replace` (Step 5b). `create_file` produces truncated output on large files.
|
|
68
|
+
|
|
69
|
+
2. **FORBIDDEN: File deletion** — NEVER use `Remove-Item`, `del`, `rm`, `fs.unlinkSync`, or any delete command on generated files. If a file is malformed, fix it with `search_replace`.
|
|
70
|
+
|
|
71
|
+
3. **FORBIDDEN: Full-file rewrite** — NEVER replace the entire document content in a single operation. Always use targeted `search_replace` on specific sections.
|
|
72
|
+
|
|
73
|
+
4. **MANDATORY: Template-first workflow** — Step 5a (copy template) MUST execute before Step 5b (fill sections). Skipping Step 5a and writing content directly is FORBIDDEN.
|
|
74
|
+
|
|
75
|
+
## Output
|
|
76
|
+
|
|
77
|
+
**Generated Files:**
|
|
78
|
+
1. `{{documentPath}}` - Controller documentation file
|
|
79
|
+
2. `{{completed_dir}}/{{fileName}}.done.json` - Completion status marker
|
|
80
|
+
3. `{{completed_dir}}/{{fileName}}.graph.json` - Graph data marker
|
|
81
|
+
|
|
82
|
+
**Return Value:**
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"status": "success|partial|failed",
|
|
86
|
+
"feature": {
|
|
87
|
+
"fileName": "UserController",
|
|
88
|
+
"sourcePath": "yudao-module-system/.../controller/admin/user/UserController.java"
|
|
89
|
+
},
|
|
90
|
+
"platformType": "admin-api",
|
|
91
|
+
"module": "system",
|
|
92
|
+
"featureName": "user-management-api",
|
|
93
|
+
"generatedFile": "speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md",
|
|
94
|
+
"message": "Successfully analyzed UserController with 8 API endpoints"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The return value is used by dispatch to update the feature status in `features-{platform}.json`.
|
|
99
|
+
|
|
100
|
+
## Execution Checklist
|
|
101
|
+
|
|
102
|
+
Before executing the workflow, verify the following inputs:
|
|
103
|
+
|
|
104
|
+
- Controller: `{{fileName}}` (`{{sourcePath}}`)
|
|
105
|
+
- Target: `{{documentPath}}`
|
|
106
|
+
- Language: `{{language}}`
|
|
107
|
+
- Module: `{{module}}`
|
|
108
|
+
- Platform: `{{platform_type}}`/`{{platform_subtype}}`
|
|
109
|
+
|
|
110
|
+
## Workflow
|
|
111
|
+
|
|
112
|
+
```mermaid
|
|
113
|
+
graph TB
|
|
114
|
+
Start([Start]) --> Step1[Step 1 Read Analysis Template]
|
|
115
|
+
Step1 --> Step2[Step 2 Read Controller and Analyze API Structure]
|
|
116
|
+
Step2 --> Step3[Step 3 Extract API Features]
|
|
117
|
+
Step3 --> Step4[Step 4 Find API Consumers]
|
|
118
|
+
Step4 --> Step5a[Step 5a Copy Template to Document Path]
|
|
119
|
+
Step5a --> Step5b[Step 5b Fill Each Section Using search_replace]
|
|
120
|
+
Step5b --> Step6[Step 6 Report Results]
|
|
121
|
+
Step6 --> Step7[Step 7 Write Completion Markers]
|
|
122
|
+
Step7 --> End([End])
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Step 1: Read Analysis Template
|
|
128
|
+
|
|
129
|
+
**Step 1 Status: 🔄 IN PROGRESS**
|
|
130
|
+
|
|
131
|
+
1. **Check Analysis Status:**
|
|
132
|
+
- If `{{analyzed}}` is `true`, output "Step 1 Status: ⏭️ SKIPPED (already analyzed)" and skip to Step 6 with status="skipped"
|
|
133
|
+
- If `{{analyzed}}` is `false`, proceed
|
|
134
|
+
|
|
135
|
+
2. **Read the appropriate template based on tech stack:**
|
|
136
|
+
- Java/Spring Boot: Read `templates/FEATURE-DETAIL-TEMPLATE.md`
|
|
137
|
+
- FastAPI: Read `templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md`
|
|
138
|
+
- .NET: Read `templates/FEATURE-DETAIL-TEMPLATE-NET.md`
|
|
139
|
+
- **Other/Unknown**: Default to `templates/FEATURE-DETAIL-TEMPLATE.md` (generic template)
|
|
140
|
+
|
|
141
|
+
3. **Understand template structure and required information dimensions:**
|
|
142
|
+
- Review all sections in the template
|
|
143
|
+
- Identify what information needs to be extracted from source code
|
|
144
|
+
- Note the expected format for each section
|
|
145
|
+
|
|
146
|
+
**Template Analysis Scope:**
|
|
147
|
+
|
|
148
|
+
| Template Section | Information to Extract | Source |
|
|
149
|
+
|------------------|------------------------|--------|
|
|
150
|
+
| 1. Content Overview | Controller name, document path, source path, description | `{{fileName}}`, `{{documentPath}}`, `{{sourcePath}}` |
|
|
151
|
+
| 2. API Endpoints | All public API methods with HTTP methods and paths | Controller method annotations |
|
|
152
|
+
| 3. Business Flow | Request handling flow: validation → business logic → persistence | Controller → Service → Mapper/Repository |
|
|
153
|
+
| 4. Data Fields | Request DTOs, Response DTOs, Entity fields | DTO classes, Entity classes |
|
|
154
|
+
| 5. References | Services, Mappers, other controllers this controller uses | Field injections, imports |
|
|
155
|
+
| 6. Business Rules | Permission rules, validation rules, business logic rules | Code logic, annotations, comments |
|
|
156
|
+
|
|
157
|
+
**Handling VO/DTO Source Files:**
|
|
158
|
+
If the source file is a VO/DTO class (not a Controller), certain sections may be simplified, but ALL section headers and numbering must still be preserved:
|
|
159
|
+
- Section 2 (API Endpoint Definitions): Note "This is a VO/DTO class containing only data structure definitions, no API endpoints"
|
|
160
|
+
- Section 4 (References): Document fields and their types as the primary content
|
|
161
|
+
- Other sections: Use "N/A" or "Not applicable for VO/DTO classes"
|
|
162
|
+
- NEVER skip sections or reorganize the template structure
|
|
163
|
+
|
|
164
|
+
> ⚠️ CRITICAL: The template defines the EXACT output structure. You MUST:
|
|
165
|
+
> - Generate ALL sections listed in the template, in the SAME order
|
|
166
|
+
> - Fill ALL tables defined in the template (use "N/A" for unavailable data, never skip a table)
|
|
167
|
+
> - Follow the EXACT heading hierarchy and numbering from the template
|
|
168
|
+
> - Do NOT invent your own section structure or reorganize sections
|
|
169
|
+
|
|
170
|
+
**Output:** "Step 1 Status: ✅ COMPLETED - Template loaded, {{sectionCount}} sections identified for analysis"
|
|
171
|
+
|
|
172
|
+
### Step 2: Read Controller and Analyze API Structure
|
|
173
|
+
|
|
174
|
+
**Step 2 Status: 🔄 IN PROGRESS**
|
|
175
|
+
|
|
176
|
+
**Prerequisites:**
|
|
177
|
+
- Template has been loaded and understood from Step 1
|
|
178
|
+
- Controller file is a Java/Kotlin controller file (e.g., `UserController.java`)
|
|
179
|
+
|
|
180
|
+
**Actions:**
|
|
181
|
+
1. **Locate and Read the controller file:**
|
|
182
|
+
- Use `{{sourcePath}}` as the relative file path from project root
|
|
183
|
+
- Read the controller file content
|
|
184
|
+
|
|
185
|
+
2. **Analyze API handler structure based on template guidance:**
|
|
186
|
+
- **Java**: Parse `@RestController`, `@RequestMapping`, `@GetMapping`, etc.
|
|
187
|
+
- **FastAPI**: Parse `@router.get()`, `@router.post()`, Pydantic models
|
|
188
|
+
- **.NET**: Parse `[ApiController]`, `[Route]`, `[HttpGet]`, etc.
|
|
189
|
+
- **Other**: Parse based on common patterns (class/method definitions, decorators, attributes)
|
|
190
|
+
|
|
191
|
+
3. **Identify all public API endpoint methods**
|
|
192
|
+
|
|
193
|
+
4. **Extract method signatures, HTTP methods, and paths**
|
|
194
|
+
|
|
195
|
+
5. **Systematically gather information for EVERY section in the template:**
|
|
196
|
+
- For each template section, identify what source code information is needed
|
|
197
|
+
- If source code doesn't provide enough info for a section, note it for "N/A" filling later
|
|
198
|
+
- Do NOT skip gathering info just because it seems minor
|
|
199
|
+
|
|
200
|
+
**Output:** "Step 2 Status: ✅ COMPLETED - Read {{sourcePath}} ({{lineCount}} lines), Analyzed {{endpointCount}} endpoints, {{serviceCount}} services"
|
|
201
|
+
|
|
202
|
+
### Step 3: Extract API Features
|
|
203
|
+
|
|
204
|
+
**Step 3 Status: 🔄 IN PROGRESS**
|
|
205
|
+
|
|
206
|
+
Each public API endpoint in the controller = one feature.
|
|
207
|
+
|
|
208
|
+
**CRITICAL - Analysis Scope Limitation:**
|
|
209
|
+
|
|
210
|
+
- **ONLY analyze the single controller file specified by `{{sourcePath}}`**
|
|
211
|
+
- **DO NOT analyze or generate documentation for other controllers in the same package**
|
|
212
|
+
- **DO NOT generate separate documents for internal/private methods**
|
|
213
|
+
|
|
214
|
+
**Extraction Guidelines:**
|
|
215
|
+
|
|
216
|
+
- Document ALL public API endpoints with their HTTP methods and paths
|
|
217
|
+
- For **internal service methods**: only record references, do not document as separate features
|
|
218
|
+
- Document business flows for each API endpoint: request validation → business logic → data persistence → response
|
|
219
|
+
- **Generate Mermaid flowcharts following `speccrew-workspace/docs/rules/mermaid-rule.md` guidelines:**
|
|
220
|
+
- Use `graph TB` or `graph LR` syntax (not `flowchart`)
|
|
221
|
+
- No parentheses `()` in node text (e.g., use `validate request` instead of `validate()`)
|
|
222
|
+
- No HTML tags like `<br/>`
|
|
223
|
+
- No `style` definitions
|
|
224
|
+
- No nested `subgraph`
|
|
225
|
+
- No special characters in node text
|
|
226
|
+
- Use `{{language}}` for all extracted content naming
|
|
227
|
+
|
|
228
|
+
**Example Code Analysis:**
|
|
229
|
+
|
|
230
|
+
```java
|
|
231
|
+
// From controller file (UserController.java)
|
|
232
|
+
@RestController
|
|
233
|
+
@RequestMapping("/admin-api/system/user")
|
|
234
|
+
public class UserController {
|
|
235
|
+
|
|
236
|
+
@GetMapping("/page") → Feature: list-users (Paged Query)
|
|
237
|
+
@PostMapping("/create") → Feature: create-user (Create User)
|
|
238
|
+
@PutMapping("/update") → Feature: update-user (Update User)
|
|
239
|
+
@DeleteMapping("/delete/{id}") → Feature: delete-user (Delete User)
|
|
240
|
+
@GetMapping("/get/{id}") → Feature: get-user-detail (Get User Detail)
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**For Each API Feature, Document:**
|
|
245
|
+
|
|
246
|
+
1. **Feature Identification:**
|
|
247
|
+
- Feature name (from endpoint path and HTTP method)
|
|
248
|
+
- API method and path
|
|
249
|
+
- Entry point file path
|
|
250
|
+
|
|
251
|
+
2. **Request/Response Analysis:**
|
|
252
|
+
- Request DTO fields with validation rules
|
|
253
|
+
- Response DTO fields
|
|
254
|
+
- Error response codes
|
|
255
|
+
|
|
256
|
+
3. **Deep Backend Business Flow Analysis** (per API endpoint):
|
|
257
|
+
|
|
258
|
+
**CRITICAL**: Trace the complete call chain based on tech stack:
|
|
259
|
+
|
|
260
|
+
**Java/Spring Boot**: Controller → Service → Mapper → Database
|
|
261
|
+
**FastAPI**: Router → Service → CRUD/Repository → SQLAlchemy Model → Database
|
|
262
|
+
**.NET**: Controller → Service → Repository → EF Core → Database
|
|
263
|
+
|
|
264
|
+
- **API Handler Layer** (Controller/Router):
|
|
265
|
+
- Request receiving and parameter extraction
|
|
266
|
+
- Permission/role validation
|
|
267
|
+
- DTO/Schema validation
|
|
268
|
+
- Service method invocation
|
|
269
|
+
|
|
270
|
+
- **Service Layer** (Business Logic):
|
|
271
|
+
- Business rule validation
|
|
272
|
+
- Data transformation/processing
|
|
273
|
+
- Cross-module service calls (if any)
|
|
274
|
+
- Transaction boundaries
|
|
275
|
+
- Data access layer invocation
|
|
276
|
+
|
|
277
|
+
- **Data Access Layer** (Mapper/CRUD/Repository):
|
|
278
|
+
- SQL operations (SELECT/INSERT/UPDATE/DELETE)
|
|
279
|
+
- Database table names
|
|
280
|
+
- Join conditions and filters
|
|
281
|
+
|
|
282
|
+
- **Database Layer**:
|
|
283
|
+
- Table structure (fields, types, constraints)
|
|
284
|
+
- Index usage
|
|
285
|
+
- Relationships with other tables
|
|
286
|
+
|
|
287
|
+
**MANDATORY Analysis for Template Sections 6-7:**
|
|
288
|
+
- Trace the complete call chain to Service → Mapper/DAO → Database tables
|
|
289
|
+
- Analyze transaction boundaries (methods with @Transactional or equivalent)
|
|
290
|
+
- Analyze database operation types (SELECT/INSERT/UPDATE/DELETE) for each table
|
|
291
|
+
- Identify service dependencies and cross-module calls for Dependency Analysis section
|
|
292
|
+
- Note potential performance considerations (N+1 queries, large batch operations, missing indexes)
|
|
293
|
+
|
|
294
|
+
4. **Business Flow Visualization**:
|
|
295
|
+
- Generate Mermaid flowchart for **each API endpoint**
|
|
296
|
+
- Show complete flow: Request → Controller → Service → Mapper → Database → Response
|
|
297
|
+
- Include detailed business logic steps in Service layer
|
|
298
|
+
- Mark each step with source file reference (Controller/Service/Mapper)
|
|
299
|
+
|
|
300
|
+
5. **Build Graph Data** (per controller):
|
|
301
|
+
|
|
302
|
+
While analyzing the controller, simultaneously extract graph nodes and edges:
|
|
303
|
+
|
|
304
|
+
**Nodes to Extract:**
|
|
305
|
+
|
|
306
|
+
| Node Type | Source | ID Format | Context Fields |
|
|
307
|
+
|-----------|--------|-----------|----------------|
|
|
308
|
+
| `api` | Each public API endpoint | `api-{module}-{name}` | `method`, `path`, `params`, `tables`, `permissions` |
|
|
309
|
+
| `service` | Each injected service | `service-{module}-{name}` | `methods`, `dependencies` |
|
|
310
|
+
| `table` | Each database table accessed | `table-{module}-{tableName}` | `fields`, `indexes`, `engine` |
|
|
311
|
+
| `dto` | Each request/response DTO | `dto-{module}-{name}` | `fields`, `validation` |
|
|
312
|
+
|
|
313
|
+
**Edges to Extract:**
|
|
314
|
+
|
|
315
|
+
| Edge Type | Direction | When to Create |
|
|
316
|
+
|-----------|-----------|----------------|
|
|
317
|
+
| `operates` | api → table | API endpoint reads/writes a database table |
|
|
318
|
+
| `invokes` | api → service | Controller calls a service method |
|
|
319
|
+
| `references` | api → dto | API endpoint uses a request/response DTO |
|
|
320
|
+
| `depends-on` | service → service | Service depends on another service |
|
|
321
|
+
| `maps-to` | dto → table | DO/Entity maps to database table |
|
|
322
|
+
|
|
323
|
+
**Node ID Naming Convention:**
|
|
324
|
+
```
|
|
325
|
+
{type}-{module}-{name}
|
|
326
|
+
Examples:
|
|
327
|
+
api-system-user-list
|
|
328
|
+
api-system-user-create
|
|
329
|
+
service-system-user-service
|
|
330
|
+
table-system-system_user
|
|
331
|
+
dto-system-user-create-req
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**IMPORTANT:**
|
|
335
|
+
- `module` comes from `{{module}}` input variable
|
|
336
|
+
- `name` should be a short, readable slug derived from the entity name
|
|
337
|
+
- Each node must include `sourcePath` and `documentPath` (if applicable)
|
|
338
|
+
- Edge `metadata` should include operation details (method name, SQL operation type, etc.)
|
|
339
|
+
|
|
340
|
+
**Output:** "Step 3 Status: ✅ COMPLETED - Extracted {{endpointCount}} API endpoints, {{flowCount}} business flows, {{nodeCount}} graph nodes, {{edgeCount}} graph edges"
|
|
341
|
+
|
|
342
|
+
### Step 4: Find API Consumers
|
|
343
|
+
|
|
344
|
+
**Step 4 Status: 🔄 IN PROGRESS**
|
|
345
|
+
|
|
346
|
+
Search frontend page files in the codebase to find which pages call the APIs in this controller.
|
|
347
|
+
|
|
348
|
+
**Search Methods:**
|
|
349
|
+
- Search for API client/service calls matching this controller's endpoints
|
|
350
|
+
- Search for imports of the API client class
|
|
351
|
+
- Search for HTTP requests to this controller's base path
|
|
352
|
+
|
|
353
|
+
**For Each Consumer Page, Record:**
|
|
354
|
+
| Field | Description |
|
|
355
|
+
|-------|-------------|
|
|
356
|
+
| Page Name | Name of the page that consumes this API |
|
|
357
|
+
| Function Description | How/why it uses this API (e.g., "Load user list on page init") |
|
|
358
|
+
| Source Path | Relative path to the consumer page source file |
|
|
359
|
+
| Document Path | Path to the consumer page's generated document |
|
|
360
|
+
|
|
361
|
+
**Output:** "Step 4 Status: ✅ COMPLETED - Found {{consumerCount}} API consumers"
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
### Step 5a: Copy Template to Document Path
|
|
366
|
+
|
|
367
|
+
**Step 5a Status: 🔄 IN PROGRESS**
|
|
368
|
+
|
|
369
|
+
Copy the appropriate template to the target document path and replace top-level placeholders.
|
|
370
|
+
|
|
371
|
+
**Template Selection:**
|
|
372
|
+
|
|
373
|
+
| Tech Stack | Template File | Description |
|
|
374
|
+
|------------|---------------|-------------|
|
|
375
|
+
| Java/Spring Boot/MyBatis | `templates/FEATURE-DETAIL-TEMPLATE.md` | Controller → Service → Mapper → Database |
|
|
376
|
+
| Python/FastAPI/SQLAlchemy | `templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md` | Router → Service → CRUD → SQLAlchemy Model |
|
|
377
|
+
| .NET/ASP.NET Core/EF Core | `templates/FEATURE-DETAIL-TEMPLATE-NET.md` | Controller → Service → Repository → EF Core |
|
|
378
|
+
| Other/Unknown | `templates/FEATURE-DETAIL-TEMPLATE.md` | Use as default/generic template |
|
|
379
|
+
|
|
380
|
+
**Actions:**
|
|
381
|
+
|
|
382
|
+
1. **Read the selected template file** based on `{{tech_stack}}`
|
|
383
|
+
|
|
384
|
+
2. **Replace top-level placeholders** with known variables:
|
|
385
|
+
|
|
386
|
+
| Placeholder | Replace With | Source |
|
|
387
|
+
|-------------|--------------|--------|
|
|
388
|
+
| `{Controller}` | `{{fileName}}` | Input variable |
|
|
389
|
+
| `{sourcePath}` | `{{sourcePath}}` | Input variable |
|
|
390
|
+
| `{documentPath}` | `{{documentPath}}` | Input variable |
|
|
391
|
+
| `{module}` | `{{module}}` | Input variable |
|
|
392
|
+
| `[Feature Name]` | `{{fileName}}` | Document title |
|
|
393
|
+
|
|
394
|
+
3. **Create the document file** using `create_file`:
|
|
395
|
+
- Target path: `{{documentPath}}`
|
|
396
|
+
- Content: Template with top-level placeholders replaced
|
|
397
|
+
- Ensure parent directory exists
|
|
398
|
+
|
|
399
|
+
4. **Verify the document skeleton**:
|
|
400
|
+
- Document should now have complete Section 1-10 structure
|
|
401
|
+
- Each section should have placeholder content waiting to be filled
|
|
402
|
+
|
|
403
|
+
**Output:** "Step 5a Status: ✅ COMPLETED - Template copied to {{documentPath}}, ready for section filling"
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
### Step 5b: Fill Each Section Using search_replace
|
|
408
|
+
|
|
409
|
+
**Step 5b Status: 🔄 IN PROGRESS**
|
|
410
|
+
|
|
411
|
+
Fill each section of the document with actual data extracted from source code analysis.
|
|
412
|
+
|
|
413
|
+
> ⚠️ **CRITICAL CONSTRAINTS:**
|
|
414
|
+
> - **禁止使用 create_file 重写整个文档** - 会丢失模板结构
|
|
415
|
+
> - **必须使用 search_replace 逐块替换**
|
|
416
|
+
> - **每个 Section 的标题和编号必须保留**,不得删除或修改
|
|
417
|
+
> - 若某 Section 无对应源码信息,保留 Section 标题,将占位内容替换为 "N/A - No applicable data found in source code"
|
|
418
|
+
|
|
419
|
+
**Section Filling Order:**
|
|
420
|
+
|
|
421
|
+
Fill sections in order (1 → 10), using `search_replace` for each content block.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
#### Section 1: Content Overview
|
|
426
|
+
|
|
427
|
+
**Locate anchor:** `<!-- AI-TAG: OVERVIEW -->`
|
|
428
|
+
|
|
429
|
+
**Fill Basic Information Table:**
|
|
430
|
+
|
|
431
|
+
Replace placeholder rows in the Basic Information table:
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
original: "| Controller Name | {Fill in controller name} |"
|
|
435
|
+
new: "| Controller Name | {{fileName}} |"
|
|
436
|
+
|
|
437
|
+
original: "| Module | {e.g., Order Management Module} |"
|
|
438
|
+
new: "| Module | {{module}} Module |"
|
|
439
|
+
|
|
440
|
+
original: "| Core Function | {1-3 sentences describing core API functionality} |"
|
|
441
|
+
new: "| Core Function | {从源码提取的实际功能描述} |"
|
|
442
|
+
|
|
443
|
+
original: "| Base Path | {e.g., /admin-api/system/user} |"
|
|
444
|
+
new: "| Base Path | {从 @RequestMapping 提取的实际路径} |"
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
**Fill API Scope List:**
|
|
448
|
+
|
|
449
|
+
Replace placeholder list items with actual endpoints:
|
|
450
|
+
|
|
451
|
+
```
|
|
452
|
+
original: "- [ ] {GET /page} - {Description}"
|
|
453
|
+
new: "- [x] GET /page - 分页查询用户列表"
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Repeat for each endpoint discovered in Step 3.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
#### Section 2: API Endpoint Definitions
|
|
461
|
+
|
|
462
|
+
**Locate anchor:** `<!-- AI-TAG: API_ENDPOINTS -->`
|
|
463
|
+
|
|
464
|
+
For each API endpoint found in Step 3, fill the corresponding subsection:
|
|
465
|
+
|
|
466
|
+
**Fill Endpoint Information Table:**
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
original: "| Method | {GET/POST/PUT/DELETE} |"
|
|
470
|
+
new: "| Method | GET |"
|
|
471
|
+
|
|
472
|
+
original: "| Path | {/admin-api/system/user/page} |"
|
|
473
|
+
new: "| Path | /admin-api/system/user/page |"
|
|
474
|
+
|
|
475
|
+
original: "| Description | {Brief description of what this endpoint does} |"
|
|
476
|
+
new: "| Description | 分页查询用户列表 |"
|
|
477
|
+
|
|
478
|
+
original: "| Permission | {Required permission code or role} |"
|
|
479
|
+
new: "| Permission | system:user:query |"
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Fill Request Parameters Table:**
|
|
483
|
+
|
|
484
|
+
Replace placeholder rows with actual parameters:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
original: "| {param1} | {String/Integer/Long} | {Yes/No} | {Description} | {e.g., Length 1-50, Not blank} |"
|
|
488
|
+
new: "| username | String | No | 用户名 | Length 1-50 |"
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Fill Response Data Table:**
|
|
492
|
+
|
|
493
|
+
Replace placeholder rows with actual response fields:
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
original: "| {id} | {Long} | {Record ID} | {No} |"
|
|
497
|
+
new: "| id | Long | 用户ID | No |"
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Fill Error Codes Table:**
|
|
501
|
+
|
|
502
|
+
```
|
|
503
|
+
original: "| {ERR_001} | {Error description} | {When this error occurs} |"
|
|
504
|
+
new: "| 400 | 参数校验失败 | 请求参数不合法 |"
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**Fill Business Flow Mermaid Diagram:**
|
|
508
|
+
|
|
509
|
+
Replace the entire example Mermaid block with actual business flow:
|
|
510
|
+
|
|
511
|
+
```
|
|
512
|
+
original: "```mermaid\ngraph TB\n Start([Request Received]) --> Auth{Permission Check}\n ... (整个示例图)\n```"
|
|
513
|
+
new: "```mermaid\ngraph TB\n Start([请求到达]) --> Auth{权限检查}\n Auth -->|无权限| Err403[返回403]\n ...\n```"
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Fill Flow Step Description Table:**
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
original: "| 1 | Permission Check | Controller | {Controller} | Request + Token | Permission result | Return 403 |"
|
|
520
|
+
new: "| 1 | 权限检查 | Controller | UserController | Request + Token | 权限校验结果 | 返回403 |"
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Fill Detailed Call Chain Table:**
|
|
524
|
+
|
|
525
|
+
```
|
|
526
|
+
original: "| 1 | Controller | {UserController} | {createUser} | Receive request, validate params, call service | [Source]({dynamic_prefix}{controllerSourcePath}) |"
|
|
527
|
+
new: "| 1 | Controller | UserController | createUser | 接收请求,校验参数,调用服务 | [Source](../../../../../yudao-module-system/.../UserController.java) |"
|
|
528
|
+
// 注:dynamic_prefix 需根据文档路径动态计算,示例假设文档在 admin-api/system/user/ (6层)
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
**Fill Database Operations Table:**
|
|
532
|
+
|
|
533
|
+
```
|
|
534
|
+
original: "| {INSERT} | {user} | {INSERT} | {Insert new user record} |"
|
|
535
|
+
new: "| INSERT | system_user | INSERT | 插入新用户记录 |"
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
**Fill Transaction Boundaries Table:**
|
|
539
|
+
|
|
540
|
+
```
|
|
541
|
+
original: "| {UserService.createUser} | {User + UserRole} | {READ_COMMITTED} | {Atomic operation} |"
|
|
542
|
+
new: "| UserService.createUser | system_user + system_user_role | READ_COMMITTED | 原子操作 |"
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
#### Section 3: Data Field Definition
|
|
548
|
+
|
|
549
|
+
**Locate anchor:** `<!-- AI-TAG: DATA_DEFINITION -->`
|
|
550
|
+
|
|
551
|
+
**Fill Database Table Structure:**
|
|
552
|
+
|
|
553
|
+
```
|
|
554
|
+
original: "**Table Name:** {table_name}"
|
|
555
|
+
new: "**Table Name:** system_user"
|
|
556
|
+
|
|
557
|
+
original: "| {id} | {Long} | {BIGINT} | {20} | {No} | {Auto increment} | {PRIMARY KEY} | {PRIMARY} | {Primary key} |"
|
|
558
|
+
new: "| id | Long | BIGINT | 20 | No | Auto increment | PRIMARY KEY | PRIMARY | 主键ID |"
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
**Fill Indexes Table:**
|
|
562
|
+
|
|
563
|
+
```
|
|
564
|
+
original: "| {idx_name} | {INDEX} | {field1} | {Query optimization} |"
|
|
565
|
+
new: "| idx_username | UNIQUE | username | 用户名唯一索引 |"
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
**Fill Relationships Table:**
|
|
569
|
+
|
|
570
|
+
```
|
|
571
|
+
original: "| {related_table} | {One-to-Many} | {this_table.related_id} | {Relationship description} |"
|
|
572
|
+
new: "| system_user_role | One-to-Many | system_user.id = system_user_role.user_id | 用户角色关联 |"
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
#### Section 4: References
|
|
578
|
+
|
|
579
|
+
**Locate anchor:** `<!-- AI-TAG: REFERENCES -->`
|
|
580
|
+
|
|
581
|
+
**Fill Internal Services Table:**
|
|
582
|
+
|
|
583
|
+
```
|
|
584
|
+
original: "| {ServiceName} | {e.g., User business logic} | [Source]({dynamic_prefix}{serviceSourcePath}) |"
|
|
585
|
+
new: "| UserService | 用户业务逻辑处理 | [Source](../../../../../yudao-module-system/.../UserService.java) |"
|
|
586
|
+
// 注:dynamic_prefix 需根据文档路径动态计算
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
**Fill Data Access Layer Table:**
|
|
590
|
+
|
|
591
|
+
```
|
|
592
|
+
original: "| {MapperName} | {EntityName} | {e.g., User CRUD operations} | [Source]({dynamic_prefix}{mapperSourcePath}) |"
|
|
593
|
+
new: "| UserMapper | UserDO | 用户CRUD操作 | [Source](../../../../../yudao-module-system/.../UserMapper.java) |"
|
|
594
|
+
// 注:dynamic_prefix 需根据文档路径动态计算
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
**Fill DTOs and Entities Table:**
|
|
598
|
+
|
|
599
|
+
```
|
|
600
|
+
original: "| {DTOClass} | Request DTO | {e.g., Create user request} | [Source]({dynamic_prefix}{dtoSourcePath}) |"
|
|
601
|
+
new: "| UserCreateReqVO | Request DTO | 创建用户请求 | [Source](../../../../../yudao-module-system/.../UserCreateReqVO.java) |"
|
|
602
|
+
// 注:dynamic_prefix 需根据文档路径动态计算
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**Fill API Consumers Table:**
|
|
606
|
+
|
|
607
|
+
```
|
|
608
|
+
original: "| {PageName} | {e.g., User management list page} | [Source]({dynamic_prefix}{pageSourcePath}) | [Doc]({dynamic_prefix}{pageDocumentPath}) |"
|
|
609
|
+
new: "| 用户管理页面 | 用户列表展示与管理 | [Source](../../../../../yudao-ui-admin/src/views/system/user/index.vue) | [Doc](../../../../../speccrew-workspace/knowledges/bizs/web-vue3/src/views/system/user/index.md) |"
|
|
610
|
+
// 注:dynamic_prefix 需根据文档路径动态计算,Source和Doc链接使用相同的前缀计算方法
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
#### Section 5: Business Rule Constraints
|
|
616
|
+
|
|
617
|
+
**Locate anchor:** `<!-- AI-TAG: BUSINESS_RULES -->`
|
|
618
|
+
|
|
619
|
+
**Fill Permission Rules Table:**
|
|
620
|
+
|
|
621
|
+
```
|
|
622
|
+
original: "| {GET /page} | Have {permission code} permission | Return 403 Forbidden |"
|
|
623
|
+
new: "| GET /page | 需要 system:user:query 权限 | 返回 403 Forbidden |"
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
**Fill Business Logic Rules:**
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
original: "1. **{Rule 1}**: {e.g., User name must be unique across system}"
|
|
630
|
+
new: "1. **用户名唯一性**: 用户名在系统中必须唯一,不能重复"
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
**Fill Validation Rules Table:**
|
|
634
|
+
|
|
635
|
+
```
|
|
636
|
+
original: "| Parameter validation | {Field} cannot be empty | Return 400 Bad Request | ERR_001 |"
|
|
637
|
+
new: "| 参数校验 | 用户名不能为空 | 返回 400 Bad Request | 400 |"
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
#### Section 6: Dependency Analysis
|
|
643
|
+
|
|
644
|
+
**Locate anchor:** `<!-- AI-TAG: DEPENDENCIES -->`
|
|
645
|
+
|
|
646
|
+
**Fill Module Dependencies Table:**
|
|
647
|
+
|
|
648
|
+
```
|
|
649
|
+
original: "| {Module A} | Strong | {Purpose description} | {Impact when unavailable} |"
|
|
650
|
+
new: "| system | Strong | 用户权限校验 | 权限功能不可用 |"
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
**Fill Service Dependencies Mermaid:**
|
|
654
|
+
|
|
655
|
+
Replace example diagram with actual dependencies:
|
|
656
|
+
|
|
657
|
+
```
|
|
658
|
+
original: "```mermaid\ngraph LR\n A[This Feature] --> B[Dependency Service 1]\n ...\n```"
|
|
659
|
+
new: "```mermaid\ngraph LR\n A[UserController] --> B[UserService]\n B --> C[UserMapper]\n ...\n```"
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
**Fill External Dependencies Table:**
|
|
663
|
+
|
|
664
|
+
```
|
|
665
|
+
original: "| {Payment Gateway} | REST API | {Payment processing} | {Queue and retry} |"
|
|
666
|
+
new: "| N/A | N/A | 无外部依赖 | N/A |"
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
---
|
|
670
|
+
|
|
671
|
+
#### Section 7: Performance Considerations
|
|
672
|
+
|
|
673
|
+
**Locate anchor:** `<!-- AI-TAG: PERFORMANCE -->`
|
|
674
|
+
|
|
675
|
+
**Fill Performance Bottlenecks Table:**
|
|
676
|
+
|
|
677
|
+
```
|
|
678
|
+
original: "| {List query} | {Large data volume} | {Add index, pagination} | High |"
|
|
679
|
+
new: "| 分页查询 | 大数据量时性能下降 | 添加索引,强制分页 | High |"
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
**Fill Index Suggestions Table:**
|
|
683
|
+
|
|
684
|
+
```
|
|
685
|
+
original: "| {table_name} | {field1, field2} | {COMPOSITE INDEX} | {Query optimization} |"
|
|
686
|
+
new: "| system_user | username, status | INDEX | 用户名和状态联合查询优化 |"
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
**Fill Caching Strategy Table:**
|
|
690
|
+
|
|
691
|
+
```
|
|
692
|
+
original: "| {User info} | {Redis} | {30 minutes} | {Write-through} |"
|
|
693
|
+
new: "| 用户信息 | Redis | 30 minutes | 写穿透 |"
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
**Fill Transaction Boundaries Table:**
|
|
697
|
+
|
|
698
|
+
```
|
|
699
|
+
original: "| {Create order} | {Order + Details} | {READ_COMMITTED} | {30 seconds} |"
|
|
700
|
+
new: "| 创建用户 | system_user + system_user_role | READ_COMMITTED | 30 seconds |"
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
#### Section 8: Troubleshooting Guide
|
|
706
|
+
|
|
707
|
+
**Locate anchor:** `<!-- AI-TAG: TROUBLESHOOTING -->`
|
|
708
|
+
|
|
709
|
+
**Fill Common Issues Table:**
|
|
710
|
+
|
|
711
|
+
```
|
|
712
|
+
original: "| {Query timeout} | {Missing index} | {Check execution plan} | {Add index} |"
|
|
713
|
+
new: "| 查询超时 | 缺少索引 | 检查执行计划 | 添加索引 |"
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
**Fill Error Code Reference Table:**
|
|
717
|
+
|
|
718
|
+
```
|
|
719
|
+
original: "| ERR_001 | {Required field empty} | {Form submission} | {Check required fields} |"
|
|
720
|
+
new: "| 400 | 参数校验失败 | 表单提交 | 检查必填字段 |"
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
**Fill Key Log Points Table:**
|
|
724
|
+
|
|
725
|
+
```
|
|
726
|
+
original: "| {Service layer} | ERROR | {Exception stack trace} | {Locate error root cause} |"
|
|
727
|
+
new: "| UserService | ERROR | 异常堆栈信息 | 定位错误根因 |"
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
|
|
732
|
+
#### Section 9: Notes and Additional Information
|
|
733
|
+
|
|
734
|
+
**Locate anchor:** `<!-- AI-TAG: ADDITIONAL_NOTES -->`
|
|
735
|
+
|
|
736
|
+
**Fill Pending Confirmations:**
|
|
737
|
+
|
|
738
|
+
```
|
|
739
|
+
original: "- [ ] **{Pending 1}**: {e.g., Whether product category dropdown needs to support fuzzy search}"
|
|
740
|
+
new: "- [ ] **待确认1**: 是否需要支持批量导出用户数据"
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
---
|
|
744
|
+
|
|
745
|
+
#### Section 10: Appendix
|
|
746
|
+
|
|
747
|
+
Fill Best Practices and Configuration Examples based on analysis:
|
|
748
|
+
|
|
749
|
+
```
|
|
750
|
+
original: "- {Best practice 1: e.g., Use batch operations for large datasets}"
|
|
751
|
+
new: "- 批量操作用户时使用事务确保数据一致性"
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
---
|
|
755
|
+
|
|
756
|
+
**Link Format Rules:**
|
|
757
|
+
|
|
758
|
+
❌ **NEVER use `file://` protocol in links** - This breaks Markdown preview
|
|
759
|
+
✅ **ALWAYS use relative paths** - Markdown links work correctly
|
|
760
|
+
|
|
761
|
+
**⚠️ CRITICAL - Dynamic Path Depth Calculation:**
|
|
762
|
+
|
|
763
|
+
文档生成位置深度**不固定**,必须动态计算 `../` 层数:
|
|
764
|
+
|
|
765
|
+
**计算方法:**
|
|
766
|
+
1. 文档路径格式:`speccrew-workspace/knowledges/bizs/{platform_id}/{module_path}/{file}.md`
|
|
767
|
+
2. 计算从文档所在目录到项目根需要的 `../` 层数
|
|
768
|
+
3. 公式:`../` 层数 = 文档路径中目录层级数
|
|
769
|
+
|
|
770
|
+
**示例计算:**
|
|
771
|
+
- 文档路径 `speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md`
|
|
772
|
+
- 拆分:`speccrew-workspace/` + `knowledges/` + `bizs/` + `admin-api/` + `system/` + `user/` = 6层目录
|
|
773
|
+
- 需要:`../../../../../` (6个`../`) 返回项目根
|
|
774
|
+
- 文档路径 `speccrew-workspace/knowledges/bizs/backend-ai/chat/ChatController.md`
|
|
775
|
+
- 拆分:5层目录
|
|
776
|
+
- 需要:`../../../../../` (5个`../`) 返回项目根
|
|
777
|
+
|
|
778
|
+
**Source Traceability Format:**
|
|
779
|
+
- Format: `[Source]({dynamic_prefix}{sourcePath})`
|
|
780
|
+
- 动态前缀:根据 `{{documentPath}}` 计算所需的 `../` 层数
|
|
781
|
+
- 示例(文档在 `speccrew-workspace/knowledges/bizs/admin-api/system/user/`):
|
|
782
|
+
- `[Source](../../../../../yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java)`
|
|
783
|
+
|
|
784
|
+
**Document Link Format:**
|
|
785
|
+
- Format: `[Doc]({dynamic_prefix}{documentPath})`
|
|
786
|
+
- 动态前缀:与 Source Link 使用相同计算方法
|
|
787
|
+
- 示例(文档在 `speccrew-workspace/knowledges/bizs/admin-api/system/user/`):
|
|
788
|
+
- `[Doc](../../../../../speccrew-workspace/knowledges/bizs/web-vue3/src/views/system/user/index.md)`
|
|
789
|
+
|
|
790
|
+
**实现步骤(AI Agent 执行时):**
|
|
791
|
+
1. 获取 `{{documentPath}}` 变量
|
|
792
|
+
2. 提取文档所在目录路径(去除文件名)
|
|
793
|
+
3. 按 `/` 分割目录路径,统计目录层级数 N
|
|
794
|
+
4. 生成 N 个 `../` 作为链接前缀
|
|
795
|
+
5. 组合为完整链接:`[Text]({"../".repeat(N)}{targetPath})`
|
|
796
|
+
|
|
797
|
+
**N/A Handling Rule:**
|
|
798
|
+
If a section has no applicable data from source code:
|
|
799
|
+
1. Keep the section header and structure
|
|
800
|
+
2. Replace placeholder content with: "N/A - No applicable data found in source code"
|
|
801
|
+
3. DO NOT remove the section or change its numbering
|
|
802
|
+
|
|
803
|
+
**Output:** "Step 5b Status: ✅ COMPLETED - All sections filled at {{documentPath}} ({{fileSize}} bytes)"
|
|
804
|
+
|
|
805
|
+
### Step 6: Report Results
|
|
806
|
+
|
|
807
|
+
**Step 6 Status: 🔄 IN PROGRESS**
|
|
808
|
+
|
|
809
|
+
Return analysis result summary to dispatch:
|
|
810
|
+
|
|
811
|
+
```json
|
|
812
|
+
{
|
|
813
|
+
"status": "{{status}}",
|
|
814
|
+
"feature": {
|
|
815
|
+
"fileName": "{{fileName}}",
|
|
816
|
+
"sourcePath": "{{sourcePath}}"
|
|
817
|
+
},
|
|
818
|
+
"platformType": "{{platform_type}}",
|
|
819
|
+
"module": "{{module}}",
|
|
820
|
+
"featureName": "{{feature_name}}",
|
|
821
|
+
"generatedFile": "{{generated_file}}",
|
|
822
|
+
"message": "{{message}}"
|
|
823
|
+
}
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
Or in case of failure:
|
|
827
|
+
|
|
828
|
+
```json
|
|
829
|
+
{
|
|
830
|
+
"status": "{{status}}",
|
|
831
|
+
"feature": {
|
|
832
|
+
"fileName": "{{fileName}}",
|
|
833
|
+
"sourcePath": "{{sourcePath}}"
|
|
834
|
+
},
|
|
835
|
+
"message": "{{message}}"
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
**Output:** "Step 6 Status: ✅ COMPLETED - Analysis {{status}}: {{message}}"
|
|
840
|
+
|
|
841
|
+
---
|
|
842
|
+
|
|
843
|
+
### Step 7: Write Completion Markers
|
|
844
|
+
|
|
845
|
+
**Step 7 Status: 🔄 IN PROGRESS**
|
|
846
|
+
|
|
847
|
+
**⚠️ MANDATORY - This step MUST be executed. The task is NOT complete until marker files are written.**
|
|
848
|
+
|
|
849
|
+
分析完成后,将结果写入标记文件,供 dispatch 批量处理。
|
|
850
|
+
|
|
851
|
+
**Prerequisites:**
|
|
852
|
+
- Step 6 completed successfully
|
|
853
|
+
- `{{completed_dir}}` - Marker files output directory (e.g., `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed`)
|
|
854
|
+
- `{{sourceFile}}` - Source features JSON file name
|
|
855
|
+
|
|
856
|
+
> **ASSUMPTION**: The `completed_dir` directory already exists (pre-created by dispatch Stage 2). If write fails, report error — do NOT attempt to create directories.
|
|
857
|
+
|
|
858
|
+
### Pre-write Checklist (VERIFY before writing each file):
|
|
859
|
+
- [ ] Filename follows `{fileName}` pattern (Java class name only)
|
|
860
|
+
- [ ] File content is valid JSON (not empty)
|
|
861
|
+
- [ ] All required fields are present and non-empty
|
|
862
|
+
- [ ] File is written with UTF-8 encoding
|
|
863
|
+
|
|
864
|
+
**Pre-write Verification (MUST check before writing):**
|
|
865
|
+
- [ ] `.done.json` JSON: `fileName` does NOT contain file extension
|
|
866
|
+
- [ ] `.done.json` JSON: `sourceFile` matches `features-{platform}.json` pattern
|
|
867
|
+
- [ ] `.done.json` JSON: `module` field is present and non-empty
|
|
868
|
+
- [ ] `.graph.json` JSON: root-level `module` field is present (MANDATORY)
|
|
869
|
+
- [ ] `.graph.json` JSON: `nodes` and `edges` are arrays (can be empty)
|
|
870
|
+
- [ ] Both files: valid JSON (no trailing commas, all strings quoted)
|
|
871
|
+
|
|
872
|
+
---
|
|
873
|
+
|
|
874
|
+
### **CRITICAL - Marker File Naming Convention (STRICT RULES)**
|
|
875
|
+
|
|
876
|
+
**✅ CORRECT Format - MUST USE:**
|
|
877
|
+
```
|
|
878
|
+
{completed_dir}/{fileName}.done.json ← Completion status marker (JSON format)
|
|
879
|
+
{completed_dir}/{fileName}.graph.json ← Graph data marker (JSON format)
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
**Examples:**
|
|
883
|
+
- `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.done.json`
|
|
884
|
+
- `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.graph.json`
|
|
885
|
+
|
|
886
|
+
**❌ WRONG Format - NEVER USE:**
|
|
887
|
+
```
|
|
888
|
+
{fileName}.completed.json ← WRONG extension
|
|
889
|
+
{fileName}.done ← WRONG extension (missing .json)
|
|
890
|
+
{fileName}.done.txt ← WRONG extension
|
|
891
|
+
{fileName}_done.json ← WRONG separator and extension
|
|
892
|
+
{fileName}-completed.json ← WRONG separator and extension
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
**❌ WRONG Filename Examples - NEVER USE:**
|
|
896
|
+
- `UserController.completed.json` - WRONG: uses `.completed.json` instead of `.done.json`
|
|
897
|
+
- `UserController.done` - WRONG: uses `.done` instead of `.done.json`
|
|
898
|
+
- `UserController.done.txt` - WRONG: uses `.done.txt` instead of `.done.json`
|
|
899
|
+
- `UserController_done.json` - WRONG: uses underscore and wrong extension
|
|
900
|
+
- `dict-UserController.done.json` - WRONG: has module prefix
|
|
901
|
+
- `system-UserController.done.json` - WRONG: has module prefix
|
|
902
|
+
|
|
903
|
+
---
|
|
904
|
+
|
|
905
|
+
### **CRITICAL - Path Format Rules (STRICT RULES)**
|
|
906
|
+
|
|
907
|
+
**Path Variables:**
|
|
908
|
+
- `{{completed_dir}}` - Absolute path to marker files directory (passed from dispatch)
|
|
909
|
+
- `{{sourcePath}}` - Relative path to source file (from features JSON)
|
|
910
|
+
- `{{documentPath}}` - Relative path to generated document (from features JSON)
|
|
911
|
+
|
|
912
|
+
**Path Format Requirements:**
|
|
913
|
+
|
|
914
|
+
| Field | Format | Example |
|
|
915
|
+
|-------|--------|---------|
|
|
916
|
+
| `sourcePath` in `.done` | Relative path (as-is from input) | `yudao-module-system/.../UserController.java` |
|
|
917
|
+
| `documentPath` in `.done` | Relative path (as-is from input) | `speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md` |
|
|
918
|
+
| `sourcePath` in `.graph.json` nodes | Relative path (as-is from input) | `yudao-module-system/.../UserController.java` |
|
|
919
|
+
| `documentPath` in `.graph.json` nodes | Relative path (as-is from input) | `speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md` |
|
|
920
|
+
|
|
921
|
+
**⚠️ CRITICAL: NEVER convert relative paths to absolute paths in the JSON content!**
|
|
922
|
+
|
|
923
|
+
**Correct vs Wrong Example:**
|
|
924
|
+
```json
|
|
925
|
+
// ✅ CORRECT - .done file content:
|
|
926
|
+
{
|
|
927
|
+
"fileName": "UserController",
|
|
928
|
+
"sourcePath": "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java",
|
|
929
|
+
"sourceFile": "features-admin-api.json",
|
|
930
|
+
"module": "system",
|
|
931
|
+
"status": "success",
|
|
932
|
+
"analysisNotes": "Successfully analyzed UserController"
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// ❌ WRONG - .done file content (DO NOT DO THIS):
|
|
936
|
+
{
|
|
937
|
+
"fileName": "UserController",
|
|
938
|
+
"sourcePath": "d:/dev/project/yudao-module-system/.../UserController.java", ← WRONG: absolute path
|
|
939
|
+
"sourceFile": "features-admin-api.json",
|
|
940
|
+
"module": "system",
|
|
941
|
+
"status": "success"
|
|
942
|
+
}
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
---
|
|
946
|
+
|
|
947
|
+
**1. Write .done.json file (MANDATORY):**
|
|
948
|
+
|
|
949
|
+
> **🚨 CRITICAL - JSON FORMAT MANDATORY**: The `.done.json` file **MUST** be valid JSON. Writing plain text, status messages, or progress updates into this file is **STRICTLY FORBIDDEN**.
|
|
950
|
+
>
|
|
951
|
+
> **❌ FORBIDDEN - NEVER DO THIS:**
|
|
952
|
+
> ```
|
|
953
|
+
> Scanning files...
|
|
954
|
+
> Analysis complete
|
|
955
|
+
> ```
|
|
956
|
+
>
|
|
957
|
+
> **✅ CORRECT - ONLY VALID JSON:**
|
|
958
|
+
> ```json
|
|
959
|
+
> {"fileName": "UserController", "status": "success", ...}
|
|
960
|
+
> ```
|
|
961
|
+
|
|
962
|
+
Use the Write tool to create file at `{{completed_dir}}/{{fileName}}.done.json`:
|
|
963
|
+
|
|
964
|
+
**Full path example:** `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.done.json`
|
|
965
|
+
|
|
966
|
+
**Complete JSON Template (ALL fields required):**
|
|
967
|
+
```json
|
|
968
|
+
{
|
|
969
|
+
"fileName": "{{fileName}}",
|
|
970
|
+
"sourcePath": "{{sourcePath}}",
|
|
971
|
+
"sourceFile": "{{sourceFile}}",
|
|
972
|
+
"module": "{{module}}",
|
|
973
|
+
"documentPath": "{{documentPath}}",
|
|
974
|
+
"status": "{{status}}",
|
|
975
|
+
"analysisNotes": "{{message}}"
|
|
976
|
+
}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
**Field Descriptions:**
|
|
980
|
+
| Field | Required | Description | Example |
|
|
981
|
+
|-------|----------|-------------|---------|
|
|
982
|
+
| `fileName` | ✅ YES | Java class name **WITHOUT extension** | `"UserController"` |
|
|
983
|
+
| `sourcePath` | ✅ YES | Relative path to source file | `"yudao-module-system/.../UserController.java"` |
|
|
984
|
+
| `sourceFile` | ✅ YES | Source features JSON filename | `"features-admin-api.json"` |
|
|
985
|
+
| `module` | ✅ YES | Business module name | `"system"` |
|
|
986
|
+
| `documentPath` | ✅ YES | Path to generated document (same as Step 5a) | `"speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md"` |
|
|
987
|
+
| `status` | ✅ YES | Analysis status | `"success"`, `"partial"`, or `"failed"` |
|
|
988
|
+
| `analysisNotes` | ✅ YES | Summary message | `"Analyzed 8 API endpoints"` |
|
|
989
|
+
|
|
990
|
+
> **⚠️ CRITICAL - fileName Field Rules:**
|
|
991
|
+
> - The `fileName` field MUST contain only the Java class name **WITHOUT file extension**
|
|
992
|
+
> - ✅ CORRECT: `"fileName": "UserController"`
|
|
993
|
+
> - ✅ CORRECT: `"fileName": "AiKnowledgeDocumentCreateListReqVO"`
|
|
994
|
+
> - ❌ WRONG: `"fileName": "UserController.java"` (includes extension)
|
|
995
|
+
> - ❌ WRONG: `"fileName": "UserController.class"` (includes extension)
|
|
996
|
+
|
|
997
|
+
> **⚠️ CRITICAL**: The `sourceFile` field is MANDATORY. It MUST be the features JSON filename (e.g., `features-admin-api.json`). Missing this field will cause pipeline failure.
|
|
998
|
+
|
|
999
|
+
> **⚠️ CRITICAL**: The `documentPath` field is MANDATORY. It MUST match the `{{documentPath}}` variable from Step 5a. This is used to verify the document was created successfully.
|
|
1000
|
+
|
|
1001
|
+
⚠️ **CRITICAL NAMING RULE:** Filename MUST be `{fileName}.done.json`, where `fileName` is the Java class name (e.g., `UserController`, `AiKnowledgeDocumentCreateListReqVO`).
|
|
1002
|
+
- ✅ CORRECT: `UserController.done.json` (using Java class name directly)
|
|
1003
|
+
- ✅ CORRECT: `AiKnowledgeDocumentCreateListReqVO.done.json` (using Java class name directly)
|
|
1004
|
+
- ❌ WRONG: `UserController.done` (missing .json extension)
|
|
1005
|
+
- ❌ WRONG: `dict-UserController.done.json` (using old featureId format)
|
|
1006
|
+
- ❌ WRONG: `system-UserController.done.json` (using module prefix)
|
|
1007
|
+
|
|
1008
|
+
⚠️ **CRITICAL:** The file MUST contain valid JSON content. Empty files or files with only whitespace will cause processing failures.
|
|
1009
|
+
|
|
1010
|
+
**2. Write .graph.json file (MANDATORY):**
|
|
1011
|
+
|
|
1012
|
+
> **⚠️ CRITICAL FORMAT REQUIREMENT**: The `.graph.json` file MUST be valid JSON and **MUST include the root-level `module` field**. Do NOT rely on scripts to infer the module from `.done` file - the `module` field MUST be explicitly present at the root level of `.graph.json`.
|
|
1013
|
+
|
|
1014
|
+
Use the Write tool to create file at `{{completed_dir}}/{{fileName}}.graph.json`:
|
|
1015
|
+
|
|
1016
|
+
**Full path example:** `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.graph.json`
|
|
1017
|
+
|
|
1018
|
+
```json
|
|
1019
|
+
{
|
|
1020
|
+
"module": "{{module}}",
|
|
1021
|
+
"nodes": [
|
|
1022
|
+
{
|
|
1023
|
+
"id": "api-{{module}}-{{endpoint-name}}",
|
|
1024
|
+
"type": "api",
|
|
1025
|
+
"name": "<display name>",
|
|
1026
|
+
"module": "{{module}}",
|
|
1027
|
+
"sourcePath": "{{sourcePath}}",
|
|
1028
|
+
"documentPath": "{{documentPath}}",
|
|
1029
|
+
"description": "..."
|
|
1030
|
+
}
|
|
1031
|
+
],
|
|
1032
|
+
"edges": [
|
|
1033
|
+
{
|
|
1034
|
+
"source": "api-...",
|
|
1035
|
+
"target": "service-... or table-...",
|
|
1036
|
+
"type": "operates|invokes|references|depends-on|maps-to",
|
|
1037
|
+
"metadata": { ... }
|
|
1038
|
+
}
|
|
1039
|
+
]
|
|
1040
|
+
}
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
> **⚠️ CRITICAL - module Field Requirement:**
|
|
1044
|
+
> - The `.graph.json` file **MUST** have a root-level `module` field
|
|
1045
|
+
> - Do NOT assume scripts will fall back to reading from `.done` file
|
|
1046
|
+
> - Missing `module` field will cause the graph merge pipeline to reject this file
|
|
1047
|
+
|
|
1048
|
+
⚠️ **CRITICAL NAMING RULE:** Filename MUST be `{fileName}.graph.json`, where `fileName` is the Java class name (e.g., `UserController`, `AiKnowledgeDocumentCreateListReqVO`).
|
|
1049
|
+
- ✅ CORRECT: `UserController.graph.json` (using Java class name directly)
|
|
1050
|
+
- ✅ CORRECT: `AiKnowledgeDocumentCreateListReqVO.graph.json` (using Java class name directly)
|
|
1051
|
+
- ❌ WRONG: `dict-UserController.graph.json` (using old featureId format)
|
|
1052
|
+
- ❌ WRONG: `system-UserController.graph.json` (using module prefix)
|
|
1053
|
+
|
|
1054
|
+
⚠️ **CRITICAL:** The file MUST contain valid JSON content. Empty files or files with only whitespace will cause processing failures.
|
|
1055
|
+
|
|
1056
|
+
**CRITICAL - API Endpoint Coverage Check:**
|
|
1057
|
+
Before writing the graph.json file, verify:
|
|
1058
|
+
- [ ] ALL public API endpoint methods in the controller are represented as `api` nodes
|
|
1059
|
+
- [ ] Status update endpoints (updateStatus, toggleEnable) are included
|
|
1060
|
+
- [ ] Special operation endpoints (resetPassword, export, import, batch operations) are included
|
|
1061
|
+
- [ ] Each `api` node has proper metadata with HTTP method and path
|
|
1062
|
+
- [ ] No public endpoint method is left without a corresponding node
|
|
1063
|
+
|
|
1064
|
+
**节点类型说明:**
|
|
1065
|
+
- `api`: API端点
|
|
1066
|
+
- `service`: Service类
|
|
1067
|
+
- `table`: 数据库表
|
|
1068
|
+
- `dto`: 数据传输对象
|
|
1069
|
+
|
|
1070
|
+
**Output:** "Step 7 Status: ✅ COMPLETED - Marker files written to {{completed_dir}}"
|
|
1071
|
+
|
|
1072
|
+
**⚠️ IMPORTANT: If this step fails, the dispatch script will NOT be able to process your analysis results. You MUST ensure both marker files are written successfully.**
|
|
1073
|
+
|
|
1074
|
+
## Reference Guides
|
|
1075
|
+
|
|
1076
|
+
### Business Flow Diagram Guidelines
|
|
1077
|
+
|
|
1078
|
+
When generating business flow diagrams in feature documents, follow these principles:
|
|
1079
|
+
|
|
1080
|
+
**Business Flow vs Technical Call Chain:**
|
|
1081
|
+
|
|
1082
|
+
| Aspect | Business Flow (Target) | Technical Call Chain (Avoid) |
|
|
1083
|
+
|--------|----------------------|---------------------------|
|
|
1084
|
+
| Focus | What business operations happen | What technical components are involved |
|
|
1085
|
+
| Audience | Product managers, solution architects | Developers, system architects |
|
|
1086
|
+
| Content | Business rules, data transformations, decisions | Method names, class names, API endpoints |
|
|
1087
|
+
| Example | "Validate inventory → Check permissions → Create order" | "OrderController.create() → OrderService.save()" |
|
|
1088
|
+
|
|
1089
|
+
**Key Principles:**
|
|
1090
|
+
|
|
1091
|
+
1. **One Diagram Per API Request**: Each API call triggered by the frontend should have its own business flow diagram
|
|
1092
|
+
2. **Business Perspective**: Focus on business operations, not technical implementation details
|
|
1093
|
+
3. **Source Traceability**: Add source file references for each business step
|
|
1094
|
+
|
|
1095
|
+
**Diagram Types by Scenario:**
|
|
1096
|
+
|
|
1097
|
+
| Scenario | Diagram Focus | Example Flow |
|
|
1098
|
+
|----------|---------------|--------------|
|
|
1099
|
+
| Page Initialization | Data loading sequence | Page Load → Parameter Fetch → Permission Check → Data Query → Render |
|
|
1100
|
+
| User Action | Operation handling | Click Trigger → Data Validation → Business Check → Data Processing → Result Feedback |
|
|
1101
|
+
| API Endpoint | Backend processing | Permission Check → Data Validation → Business Processing → Data Persistence |
|
|
1102
|
+
|
|
1103
|
+
**For detailed diagram examples and templates, refer to:**
|
|
1104
|
+
- `templates/FEATURE-DETAIL-TEMPLATE.md` - Section 3 (Interaction Flow Description)
|
|
1105
|
+
|
|
1106
|
+
**Common Business Flow Patterns:**
|
|
1107
|
+
|
|
1108
|
+
1. **CRUD Operations:**
|
|
1109
|
+
- Create: Data Validation → Permission Check → Duplicate Check → Data Creation → Related Update → Log Recording
|
|
1110
|
+
- Read: Parameter Parsing → Permission Check → Data Query → Data Assembly → Return Result
|
|
1111
|
+
- Update: Data Validation → Permission Check → Existence Check → Data Update → Related Update → Log Recording
|
|
1112
|
+
- Delete: Permission Check → Existence Check → Dependency Check → Data Deletion → Log Recording
|
|
1113
|
+
|
|
1114
|
+
2. **Approval Workflows:**
|
|
1115
|
+
- Submit Application → Validate Data → Check Process Config → Create Approval Instance → Notify Approver → Record Log
|
|
1116
|
+
|