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.
Files changed (153) hide show
  1. package/.speccrew/agents/speccrew-feature-designer.md +142 -0
  2. package/.speccrew/agents/speccrew-product-manager.md +61 -0
  3. package/.speccrew/agents/speccrew-system-designer.md +200 -0
  4. package/.speccrew/agents/speccrew-system-developer.md +238 -0
  5. package/.speccrew/agents/speccrew-task-worker.md +80 -0
  6. package/.speccrew/agents/speccrew-team-leader.md +92 -0
  7. package/.speccrew/agents/speccrew-test-manager.md +313 -0
  8. package/.speccrew/skills/speccrew-create-agents/SKILL.md +98 -0
  9. package/.speccrew/skills/speccrew-create-agents/templates/agents/designer-agent.md +54 -0
  10. package/.speccrew/skills/speccrew-create-agents/templates/agents/dev-agent.md +79 -0
  11. package/.speccrew/skills/speccrew-create-agents/templates/agents/test-agent.md +80 -0
  12. package/.speccrew/skills/speccrew-dev-backend/SKILL.md +205 -0
  13. package/.speccrew/skills/speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md +118 -0
  14. package/.speccrew/skills/speccrew-dev-desktop/SKILL.md +258 -0
  15. package/.speccrew/skills/speccrew-dev-desktop/templates/TASK-RECORD-TEMPLATE.md +161 -0
  16. package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +202 -0
  17. package/.speccrew/skills/speccrew-dev-frontend/templates/TASK-RECORD-TEMPLATE.md +115 -0
  18. package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +200 -0
  19. package/.speccrew/skills/speccrew-dev-mobile/templates/TASK-RECORD-TEMPLATE.md +125 -0
  20. package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +73 -0
  21. package/.speccrew/skills/speccrew-fd-api-contract/templates/API-CONTRACT-TEMPLATE.md +96 -0
  22. package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +395 -0
  23. package/.speccrew/skills/speccrew-fd-feature-design/templates/FEATURE-SPEC-TEMPLATE.md +387 -0
  24. package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +80 -0
  25. package/.speccrew/skills/speccrew-get-timestamp/scripts/get-timestamp.js +35 -0
  26. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +1116 -0
  27. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md +462 -0
  28. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-JAVA.md +480 -0
  29. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md +464 -0
  30. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md +480 -0
  31. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/MODULE-OVERVIEW-TEMPLATE.md +367 -0
  32. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +667 -0
  33. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +74 -0
  34. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +176 -0
  35. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +150 -0
  36. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +106 -0
  37. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +249 -0
  38. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +848 -0
  39. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +226 -0
  40. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +264 -0
  41. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +34 -0
  42. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +867 -0
  43. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +26 -0
  44. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +165 -0
  45. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/apply-module-mapping.js +208 -0
  46. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/extract-module-summary.js +180 -0
  47. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/reindex-modules.js +358 -0
  48. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +1055 -0
  49. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-DESKTOP.md +303 -0
  50. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-ELECTRON.md +327 -0
  51. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MINIAPP.md +292 -0
  52. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MOBILE.md +281 -0
  53. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI.md +324 -0
  54. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +270 -0
  55. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md +33 -0
  56. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md +33 -0
  57. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md +33 -0
  58. package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +229 -0
  59. package/.speccrew/skills/speccrew-knowledge-graph-query/scripts/graph-query.js +549 -0
  60. package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +181 -0
  61. package/.speccrew/skills/speccrew-knowledge-graph-write/scripts/graph-write.js +651 -0
  62. package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +305 -0
  63. package/.speccrew/skills/speccrew-knowledge-module-summarize/templates/MODULE-OVERVIEW-TEMPLATE.md +400 -0
  64. package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +351 -0
  65. package/.speccrew/skills/speccrew-knowledge-system-summarize/templates/SYSTEM-OVERVIEW-TEMPLATE.md +294 -0
  66. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +683 -0
  67. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +550 -0
  68. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/templates/techs-manifest-EXAMPLE.json +35 -0
  69. package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +1087 -0
  70. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/ARCHITECTURE-TEMPLATE.md +240 -0
  71. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COLOR-SYSTEM-TEMPLATE.md +68 -0
  72. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COMPONENT-LIBRARY-TEMPLATE.md +86 -0
  73. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-BUILD-TEMPLATE.md +466 -0
  74. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DATA-TEMPLATE.md +432 -0
  75. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DESIGN-TEMPLATE.md +1209 -0
  76. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DEV-TEMPLATE.md +1433 -0
  77. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-SYSTEM-TEST-TEMPLATE.md +1052 -0
  78. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-UNIT-TEST-TEMPLATE.md +946 -0
  79. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/INDEX-TEMPLATE.md +29 -0
  80. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-LAYOUTS-TEMPLATE.md +69 -0
  81. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +74 -0
  82. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/TECH-STACK-TEMPLATE.md +232 -0
  83. package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +628 -0
  84. package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +392 -0
  85. package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +489 -0
  86. package/.speccrew/skills/speccrew-knowledge-techs-index/templates/INDEX-TEMPLATE.md +243 -0
  87. package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +269 -0
  88. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +562 -0
  89. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/BUSINESS-COMPONENTS-TEMPLATE.md +171 -0
  90. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMMON-COMPONENTS-TEMPLATE.md +177 -0
  91. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-INDIVIDUAL-TEMPLATE.md +80 -0
  92. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-LIBRARY-TEMPLATE.md +118 -0
  93. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-INDIVIDUAL-TEMPLATE.md +97 -0
  94. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-PATTERNS-TEMPLATE.md +208 -0
  95. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/NAVIGATION-PATTERNS-TEMPLATE.md +157 -0
  96. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-INDIVIDUAL-TEMPLATE.md +123 -0
  97. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +58 -0
  98. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/SPACING-TEMPLATE.md +119 -0
  99. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/STYLE-SYSTEM-TEMPLATE.md +117 -0
  100. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/TYPOGRAPHY-TEMPLATE.md +107 -0
  101. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/UI-STYLE-GUIDE-TEMPLATE.md +171 -0
  102. package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +434 -0
  103. package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/BIZS-MODELING-TEMPLATE.md +332 -0
  104. package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/PRD-TEMPLATE.md +200 -0
  105. package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +195 -0
  106. package/.speccrew/skills/speccrew-project-diagnosis/SKILL.md +208 -0
  107. package/.speccrew/skills/speccrew-project-diagnosis/templates/DIAGNOSIS-REPORT-TEMPLATE.md +202 -0
  108. package/.speccrew/skills/speccrew-sd-backend/SKILL.md +188 -0
  109. package/.speccrew/skills/speccrew-sd-backend/templates/INDEX-TEMPLATE.md +85 -0
  110. package/.speccrew/skills/speccrew-sd-backend/templates/SD-BACKEND-TEMPLATE.md +269 -0
  111. package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +192 -0
  112. package/.speccrew/skills/speccrew-sd-desktop/templates/INDEX-TEMPLATE.md +271 -0
  113. package/.speccrew/skills/speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md +673 -0
  114. package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +176 -0
  115. package/.speccrew/skills/speccrew-sd-frontend/templates/INDEX-TEMPLATE.md +184 -0
  116. package/.speccrew/skills/speccrew-sd-frontend/templates/SD-FRONTEND-TEMPLATE.md +382 -0
  117. package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +189 -0
  118. package/.speccrew/skills/speccrew-sd-mobile/templates/INDEX-TEMPLATE.md +219 -0
  119. package/.speccrew/skills/speccrew-sd-mobile/templates/SD-MOBILE-TEMPLATE.md +534 -0
  120. package/.speccrew/skills/speccrew-test-case-design/SKILL.md +284 -0
  121. package/.speccrew/skills/speccrew-test-case-design/templates/TEST-CASE-DESIGN-TEMPLATE.md +263 -0
  122. package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +313 -0
  123. package/.speccrew/skills/speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md +180 -0
  124. package/.speccrew/skills/speccrew-test-execute/SKILL.md +283 -0
  125. package/.speccrew/skills/speccrew-test-execute/templates/BUG-REPORT-TEMPLATE.md +50 -0
  126. package/.speccrew/skills/speccrew-test-execute/templates/TEST-REPORT-TEMPLATE.md +57 -0
  127. package/.speccrew/skills/speccrew-workflow-diagnose/SKILL.md +155 -0
  128. package/LICENSE +21 -0
  129. package/README.ar.md +318 -0
  130. package/README.en.md +318 -0
  131. package/README.es.md +318 -0
  132. package/README.md +340 -0
  133. package/bin/cli.js +62 -0
  134. package/lib/commands/doctor.js +138 -0
  135. package/lib/commands/init.js +231 -0
  136. package/lib/commands/list.js +114 -0
  137. package/lib/commands/uninstall.js +117 -0
  138. package/lib/commands/update.js +351 -0
  139. package/lib/ide-adapters.js +73 -0
  140. package/lib/utils.js +104 -0
  141. package/package.json +28 -0
  142. package/workspace-template/docs/configs/document-templates.json +667 -0
  143. package/workspace-template/docs/configs/platform-mapping.json +194 -0
  144. package/workspace-template/docs/configs/tech-stack-mappings.json +313 -0
  145. package/workspace-template/docs/configs/validation-rules.json +87 -0
  146. package/workspace-template/docs/rules/mermaid-rule.md +114 -0
  147. 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
  148. package/workspace-template/docs/solutions/agent-knowledge-map.md +238 -0
  149. package/workspace-template/docs/solutions/bizs-knowledge-pipeline.md +678 -0
  150. package/workspace-template/docs/solutions/harness.md +410 -0
  151. package/workspace-template/docs/solutions/knowledge-incremental-sync-spec.md +943 -0
  152. package/workspace-template/docs/solutions/techs-knowledge-pipeline.md +803 -0
  153. package/workspace-template/docs/solutions/workspace-structure.md +318 -0
@@ -0,0 +1,667 @@
1
+ ---
2
+ name: speccrew-knowledge-bizs-dispatch
3
+ description: Dispatch bizs knowledge base generation tasks with 5-stage pipeline. Handles feature inventory, feature analysis with skill routing, graph data writing, module summarization, UI style pattern extraction, and system summary.
4
+ tools: Read, Write, Task, Bash
5
+ ---
6
+
7
+ # Bizs Knowledge Dispatch
8
+
9
+ Orchestrate **bizs knowledge base generation** with a 5-stage pipeline: Feature Inventory → Feature Analysis + Graph Write → Module Summarize → UI Style Pattern Extract → System Summary.
10
+
11
+ ## Language Adaptation
12
+
13
+ **CRITICAL**: All generated documents must match the user's language. Detect the language from the user's input and pass it to all downstream Worker Agents.
14
+
15
+ - User writes in 中文 → Generate Chinese documents, pass `language: "zh"` to workers
16
+ - User writes in English → Generate English documents, pass `language: "en"` to workers
17
+ - User writes in other languages → Use appropriate language code
18
+
19
+ **All downstream skills must receive the `language` parameter and generate content in that language only.**
20
+
21
+ ## Trigger Scenarios
22
+
23
+ - "Initialize bizs knowledge base"
24
+ - "Generate business knowledge from source code"
25
+ - "Dispatch bizs knowledge generation"
26
+ - "Generate knowledge base from src/views directory"
27
+ - "Analyze this subdirectory for knowledge base"
28
+
29
+ ## Input
30
+
31
+ | Variable | Description | Default |
32
+ |----------|-------------|---------|
33
+ | `source_path` | Source code path (can be a subdirectory; auto-detects platform root by traversing upward) | project root |
34
+ | `language` | User's language code (e.g., "zh", "en") | **REQUIRED** |
35
+ | `sync_mode` | `"full"` or `"incremental"` | `"full"` |
36
+ | `base_commit` | (incremental only) Git base commit hash | — |
37
+ | `head_commit` | (incremental only) Git HEAD commit hash | `HEAD` |
38
+ | `changed_files` | (incremental only) Pre-computed changed file list | — |
39
+ | `max_concurrent_workers` | Maximum parallel Worker Agents | `5` |
40
+ | `graph_root` | Graph data output root path | `speccrew-workspace/knowledges/bizs/graph` |
41
+ | `graph_write_script_path` | Path to graph-write script file | `{graph_write_skill_path}/scripts/graph-write.js` |
42
+ | `completed_dir` | Marker file output directory for Worker results | `{sync_state_path}/completed` |
43
+
44
+ > **Note**: Ensure `graph_root` directory exists before first execution. If it does not exist, create it: `mkdir -p "{graph_root}"` (or equivalent on Windows: `New-Item -ItemType Directory -Path "{graph_root}" -Force`).
45
+
46
+ ## Output
47
+
48
+ - Entry directories: `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/entry-dirs-{platform}.json`
49
+ - Feature inventory: `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-{platform}.json`
50
+ - Feature docs: `speccrew-workspace/knowledges/bizs/{platform}/{module}/features/*.md`
51
+ - Module overviews: `speccrew-workspace/knowledges/bizs/{platform}/{module}/*-overview.md`
52
+ - UI style patterns: `speccrew-workspace/knowledges/techs/{platform_id}/ui-style-patterns/` (page-types/, components/, layouts/)
53
+ - System overview: `speccrew-workspace/knowledges/bizs/system-overview.md`
54
+ - Graph data: `speccrew-workspace/knowledges/bizs/graph/`
55
+
56
+ ## Workflow Overview
57
+
58
+ ```mermaid
59
+ flowchart TB
60
+ S0[Pre-processing: Platform Root Detection] --> S0a[Stage 0: Platform Detection]
61
+ S0a --> S1a[Stage 1a: Entry Directory Recognition]
62
+ S1a --> S1b[Stage 1b: Feature Inventory]
63
+ S1b --> S2[Stage 2: Feature Analysis + Graph Write]
64
+ S2 --> S3[Stage 3: Module Summarize]
65
+ S3 --> S3_5[Stage 3.5: UI Style Pattern Extract]
66
+ S3_5 --> S4[Stage 4: System Summary]
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Stage 0: Platform Detection
72
+
73
+ **Objective**: Automatically discover ALL platforms in the project. Do NOT hardcode platform lists.
74
+
75
+ **Detection steps**:
76
+
77
+ 1. **Scan for backend modules**:
78
+ ```
79
+ # Look for all backend module directories
80
+ Get-ChildItem -Path "{project_root}" -Filter "yudao-module-*" -Directory
81
+ # Or for other project structures:
82
+ Get-ChildItem -Path "{project_root}" -Directory | Where-Object { $_.Name -match "^(module-|service-|api-)" }
83
+ ```
84
+ Each discovered module becomes a `backend-{module_name}` platform (e.g., `yudao-module-system` → `backend-system`).
85
+
86
+ 2. **Scan for frontend projects**:
87
+ ```
88
+ # Look for UI/frontend directories
89
+ Get-ChildItem -Path "{project_root}" -Directory | Where-Object { $_.Name -match "ui|frontend|web|app" }
90
+ # Then check each for actual source code (package.json, src/ directory)
91
+ ```
92
+ Classify by tech stack: Vue → `web-vue`, UniApp → `mobile-uniapp`, React → `web-react`, etc.
93
+
94
+ 3. **Validate each platform**:
95
+ - Has actual source code files (not empty placeholder directories)
96
+ - Has a recognizable project structure (package.json for frontend, pom.xml/build.gradle for backend)
97
+
98
+ 4. **Present platform list to user for confirmation** before proceeding to Stage 1a.
99
+
100
+ **Output**: A confirmed list of platforms with:
101
+
102
+ | Platform ID | Source Path | Platform Type | Tech Stack |
103
+ |---|---|---|---|
104
+ | `web-vue` | `yudao-ui/yudao-ui-admin-vue3` | web | vue, vite, element-plus |
105
+ | `backend-system` | `yudao-module-system/src/main/java/.../system` | backend | spring-boot, mybatis-plus |
106
+ | ... | ... | ... | ... |
107
+
108
+ > **CRITICAL**: NEVER hardcode a fixed number of platforms. Always scan the project directory to discover ALL modules. Missing a platform means incomplete knowledge base generation.
109
+
110
+ ---
111
+
112
+ ## Stage 1a: Entry Directory Recognition (LLM-Driven)
113
+
114
+ **Goal**: For each detected platform, use LLM to analyze the source directory tree and identify all entry directories (API controllers for backend, views/pages for frontend), then classify them into business modules.
115
+
116
+ > **IMPORTANT**: This stage is executed **directly by the dispatch agent (Leader)** using LLM analysis capabilities (Read/ListDir/Grep), NOT delegated to a Worker Agent.
117
+
118
+ **Prerequisite**: Stage 0 completed. Platform list confirmed with `platformId`, `sourcePath`, `platformType`, `platformSubtype`, and `techIdentifier` for each platform.
119
+
120
+ **Execution Flow** (for each platform):
121
+
122
+ ### Step 1: Read Directory Tree
123
+
124
+ Use `ListDir` or `Bash(tree)` to read the platform's `sourcePath` directory structure (3 levels deep):
125
+
126
+ ```bash
127
+ # Windows (PowerShell)
128
+ tree /F /A "{sourcePath}" | Select-Object -First 100
129
+
130
+ # Unix/Linux/Mac
131
+ tree -L 3 "{sourcePath}"
132
+ ```
133
+
134
+ ### Step 2: LLM Analysis - Identify Entry Directories
135
+
136
+ Based on the directory tree and technology stack, analyze and identify entry directories:
137
+
138
+ **Backend (Spring/Java/Kotlin)**:
139
+ - Find all directories containing `*Controller.java` or `*Controller.kt` files
140
+ - These are API entry directories
141
+ - Module name = the business package name of the entry directory (e.g., `controller/admin/chat` → module `chat`)
142
+
143
+ **Frontend (Vue/React)**:
144
+ - Find `views/` or `pages/` directories
145
+ - First-level subdirectories under these directories are business modules
146
+ - Each subdirectory is an entry directory (e.g., `views/system/` → module `system`)
147
+
148
+ **Mobile (UniApp)**:
149
+ - Find first-level subdirectories under `pages/`
150
+ - Plus top-level `pages-*` directories (module name = directory name without `pages-` prefix, e.g., `pages-bpm` → module `bpm`)
151
+
152
+ **Mobile (Mini Program)**:
153
+ - Find first-level subdirectories under `pages/` as modules
154
+
155
+ **Exclusion Rules** (directories to ignore):
156
+ - Pure technical directories: `config`, `framework`, `enums`, `exception`, `util`, `utils`, `common`, `constant`, `constants`, `type`, `types`, `dto`, `vo`, `entity`, `model`, `mapper`, `repository`, `dao`, `service`, `impl`
157
+ - Build/output directories: `dist`, `build`, `target`, `out`, `node_modules`
158
+ - Test directories: `test`, `tests`, `spec`, `__tests__`, `e2e`
159
+ - Configuration directories: `.git`, `.idea`, `.vscode`, `.speccrew`
160
+
161
+ **Root Module Handling**:
162
+ - If an entry file is not under any subdirectory (directly under `sourcePath`), assign it to the `_root` module
163
+
164
+ ### Step 3: Generate entry-dirs JSON
165
+
166
+ Output file: `{speccrew-workspace}/knowledges/base/sync-state/knowledge-bizs/entry-dirs-{platformId}.json`
167
+
168
+ **JSON Format**:
169
+ ```json
170
+ {
171
+ "platformId": "backend-ai",
172
+ "platformName": "AI Module Backend",
173
+ "platformType": "backend",
174
+ "platformSubtype": "ai",
175
+ "sourcePath": "yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai",
176
+ "techStack": ["spring-boot", "mybatis-plus"],
177
+ "modules": [
178
+ { "name": "chat", "entryDirs": ["controller/admin/chat"] },
179
+ { "name": "image", "entryDirs": ["controller/admin/image"] },
180
+ { "name": "knowledge", "entryDirs": ["controller/admin/knowledge"] },
181
+ { "name": "_root", "entryDirs": ["controller/admin"] }
182
+ ]
183
+ }
184
+ ```
185
+
186
+ **Field Definitions**:
187
+ - `platformId`: Platform identifier (e.g., `backend-ai`, `web-vue`, `mobile-uniapp`)
188
+ - `platformName`: (Optional) Human-readable platform name. Auto-generated as `{platformType}-{platformSubtype}` if missing
189
+ - `platformType`: (Optional) Platform type: `backend`, `web`, `mobile`, `desktop`. Inferred from platformId if missing
190
+ - `platformSubtype`: (Optional) Platform subtype (e.g., `ai`, `vue`, `uniapp`). Inferred from platformId if missing
191
+ - `sourcePath`: Absolute path to the platform source root
192
+ - `techStack`: (Optional) Array of tech stack names (e.g., `["spring-boot", "mybatis-plus"]`). Default inferred from platformType
193
+ - `modules`: Array of business modules
194
+ - `name`: Module name (business-meaningful, e.g., `chat`, `system`, `order`)
195
+ - `entryDirs`: Array of entry directory paths (relative to `sourcePath`)
196
+
197
+ **Path Rules**:
198
+ - All `entryDirs` paths must be relative to `sourcePath`
199
+ - Use forward slashes `/` as path separators (even on Windows)
200
+ - Do not include leading or trailing slashes
201
+
202
+ ### Step 4: Validation
203
+
204
+ After generating the entry-dirs JSON:
205
+ 1. Verify that `modules` array is not empty
206
+ 2. Verify that each module has at least one entry directory
207
+ 3. Verify that module names are business-meaningful (not technical terms like `config`, `util`)
208
+ 4. If validation fails, re-analyze the directory tree
209
+
210
+ **Error handling**: If entry directory recognition fails for a platform, STOP and report the error with platform details. Do NOT proceed to Stage 1b for that platform.
211
+
212
+ ---
213
+
214
+ ## Stage 1b: Generate Feature Inventory (Direct Execution)
215
+
216
+ **Goal**: Based on the entry-dirs JSON generated in Stage 1a, generate per-platform feature inventory files.
217
+
218
+ > **IMPORTANT**: This stage is executed **directly by the dispatch agent (Leader)**, NOT delegated to a Worker Agent.
219
+ > Worker Agents do not have `run_in_terminal` capability, which is required for script execution.
220
+
221
+ **Prerequisite**: Stage 1a completed. `entry-dirs-{platformId}.json` files exist in `{sync_state_path}/knowledge-bizs/`.
222
+
223
+ **Action** (dispatch executes directly via `run_in_terminal`):
224
+
225
+ 1. **Read platform mapping**: Read `speccrew-workspace/docs/configs/platform-mapping.json` and `tech-stack-mappings.json` for platform configuration
226
+ 2. **Locate the inventory script**: Find `generate-inventory.js` in the `speccrew-knowledge-bizs-init-features` skill's scripts directory:
227
+ - Script location: `{ide_skills_dir}/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js`
228
+ - Where `{ide_skills_dir}` is the IDE-specific skills directory (e.g., `.qoder/skills/`, `.cursor/skills/`, `.vscode/skills/`, `.speccrew/skills/`)
229
+ - Use `ListDir` to locate the script if the exact path is unknown
230
+ 3. **Execute inventory script** for each platform:
231
+ ```
232
+ node "{path_to_generate_inventory_js}" --entryDirsFile "{entry_dirs_file_path}"
233
+ ```
234
+
235
+ **Script Parameters**:
236
+ - `--entryDirsFile`: Path to the `entry-dirs-{platformId}.json` file generated in Stage 1a (required)
237
+
238
+ **Note**: `platformId` and `sourcePath` are read from the entry-dirs JSON file. Platform mapping and output directory are automatically derived by the script.
239
+
240
+ **Optional Parameters**:
241
+ - `--techIdentifier`: Technology identifier for tech-stack lookup (auto-detected from platform mapping if omitted)
242
+ - `--fileExtensions`: Comma-separated list of file extensions to include (e.g., `.java,.kt`)
243
+ - `--excludeDirs`: Additional directories to exclude
244
+
245
+ **Output**:
246
+ - `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-{platformId}.json` — Per-platform feature inventory files
247
+ - Each file contains: platform metadata, modules list, and flat features array with `analyzed` status
248
+
249
+ **Features JSON Structure**:
250
+ ```json
251
+ {
252
+ "platformId": "backend-ai",
253
+ "platformName": "AI Module",
254
+ "platformType": "backend",
255
+ "platformSubtype": "ai",
256
+ "techIdentifier": "spring",
257
+ "sourcePath": "yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai",
258
+ "modules": [
259
+ { "name": "chat", "featureCount": 12 },
260
+ { "name": "image", "featureCount": 8 },
261
+ { "name": "knowledge", "featureCount": 15 }
262
+ ],
263
+ "features": [
264
+ {
265
+ "fileName": "ChatConversationController",
266
+ "sourcePath": "controller/admin/chat/ChatConversationController.java",
267
+ "module": "chat",
268
+ "documentPath": "speccrew-workspace/knowledges/bizs/backend-ai/chat/ChatConversationController.md",
269
+ "platformType": "backend",
270
+ "platformSubtype": "ai",
271
+ "analyzed": false
272
+ }
273
+ ]
274
+ }
275
+ ```
276
+
277
+ **Error handling**: If the script exits with non-zero code, STOP and report the error. Do NOT create workaround scripts.
278
+
279
+ ---
280
+
281
+ ## Stage 2: Feature Analysis (Batch Processing)
282
+
283
+ **Overview**: Process all pending features in batches. Each batch gets a set of features, launches Worker Agents to analyze them, then processes the results.
284
+
285
+ > **Script execution rule**: All script calls in Stage 2 are executed **directly by the dispatch agent** via `run_in_terminal`. Only the analysis tasks are delegated to Worker Agents.
286
+
287
+ #### Execution Flow
288
+
289
+ Repeat the following 3 steps until all features are processed:
290
+
291
+ **Step 0: Ensure completed directory exists (MANDATORY)**
292
+
293
+ Before launching any Workers, you MUST create the `completed_dir` directory using Node.js (cross-platform compatible):
294
+
295
+ ```bash
296
+ node -e "require('fs').mkdirSync('{completed_dir}', {recursive: true}); console.log('completed dir ready')"
297
+ ```
298
+
299
+ > **Note**: Using Node.js ensures cross-platform compatibility (Windows/macOS/Linux).
300
+
301
+ > **⚠️ CRITICAL**: The `completed_dir` MUST be an **absolute path** (e.g., `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed`). Relative paths will cause Worker marker file writes to fail silently.
302
+
303
+ **Step 1: Get Next Batch**
304
+
305
+ 1. **Locate the script**: Find `batch-orchestrator.js` in the `speccrew-knowledge-bizs-dispatch` skill's scripts directory:
306
+ - Script location: `{ide_skills_dir}/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js`
307
+ - Where `{ide_skills_dir}` is the IDE-specific skills directory (e.g., `.qoder/skills/`, `.cursor/skills/`, `.vscode/skills/`, `.speccrew/skills/`)
308
+ - Use `ListDir` to locate the script if the exact path is unknown
309
+
310
+ 2. **Execute get-batch**:
311
+ ```
312
+ node "{path_to_batch_orchestrator_js}" get-batch --syncStatePath "{sync_state_path}" --batchSize 5
313
+ ```
314
+
315
+ - If output `action` is `"done"` → All features processed. Exit Stage 2, proceed to Stage 3.
316
+ - If output `action` is `"process"` → The `batch` array contains features to analyze. Proceed to Step 2.
317
+
318
+ **Step 2: Launch Workers — MUST BE PARALLEL**
319
+
320
+ ⚠️ **CRITICAL**: You MUST launch ALL features in the current batch SIMULTANEOUSLY as parallel Worker Tasks. **FORBIDDEN**: sequential launch (start one Worker, wait, then start next).
321
+
322
+ For each feature in the `batch` array, prepare a Worker Task:
323
+ - **Skill routing** by `platformType`:
324
+ - `"web"`, `"mobile"`, `"desktop"` → `skill_name: speccrew-knowledge-bizs-ui-analyze`
325
+ - `"backend"` → `skill_name: speccrew-knowledge-bizs-api-analyze`
326
+ - **Worker parameters**: Pass all feature fields plus `language`, `completed_dir`, `sourceFile`, `skill_path`
327
+ - **Behavior constraint**: Worker MUST NOT create any temporary scripts. If execution fails, STOP and report error.
328
+
329
+ **Execution sequence**:
330
+ 1. Prepare ALL Worker Tasks first (do NOT launch yet)
331
+ 2. Launch ALL Workers at the SAME TIME in a single batch dispatch
332
+ 3. Wait for ALL Workers to complete before proceeding to Step 3
333
+ 4. Each Worker writes `.done` and `.graph.json` marker files to `completed_dir` upon completion
334
+
335
+ Example: If batch has 5 features → create and launch 5 Worker Tasks simultaneously, NOT one by one.
336
+
337
+ **Worker Task Prompt Format**:
338
+
339
+ ```json
340
+ {
341
+ "skill_name": "speccrew-knowledge-bizs-ui-analyze",
342
+ "instructions": "请分析以下源代码文件,生成详细的功能文档。\n\n⚠️ CRITICAL - Template Fill-in Workflow (MANDATORY):\n1. First, copy the analysis template to documentPath (template structure = document skeleton)\n2. Then fill each Section using search_replace to replace placeholders with actual data\n3. NEVER use create_file to rewrite the entire document — this destroys template structure\n4. NEVER delete or skip any template Section — if no data available, fill with \"N/A\"\n5. NEVER create custom Section structures — use ONLY the template's predefined Sections\n\n要求:\n- 读取源代码文件,理解相关功能接口\n- 生成详细的文档到 documentPath\n- 创建两个标记文件到 completed_dir\n- 使用 {skill_name} 技能完成此任务",
343
+ "context": {
344
+ "fileName": "<feature.fileName>",
345
+ "sourcePath": "<feature.sourcePath>",
346
+ "module": "<feature.module>",
347
+ "documentPath": "<feature.documentPath>",
348
+ "platformType": "<feature.platformType>",
349
+ "platformSubtype": "<feature.platformSubtype>",
350
+ "language": "<user language>",
351
+ "completed_dir": "<completed_dir_absolute_path>",
352
+ "sourceFile": "<feature.sourceFile>"
353
+ }
354
+ }
355
+ ```
356
+
357
+ > **⚠️ CRITICAL - completed_dir must be ABSOLUTE path**: The `completed_dir` parameter passed to Worker MUST be an absolute path (e.g., `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed`), NOT a relative path. Workers do not have context of the dispatch working directory.
358
+
359
+ > ⚠️ **CRITICAL - Marker File Format**:
360
+ > The `.done` file MUST be valid JSON format, NOT plain text.
361
+ >
362
+ > Required `.done` JSON structure:
363
+ > ```json
364
+ > {
365
+ > "fileName": "<class name without extension>",
366
+ > "sourcePath": "<relative source file path>",
367
+ > "sourceFile": "<features JSON filename, e.g. features-backend-ai.json>",
368
+ > "module": "<business module name>",
369
+ > "status": "success|partial|failed",
370
+ > "analysisNotes": "<brief notes>"
371
+ > }
372
+ > ```
373
+ >
374
+ > ❌ **WRONG**: Writing plain text like "COMPLETED" or "Analysis done"
375
+ > ✅ **CORRECT**: Writing valid JSON with all required fields
376
+
377
+ ---
378
+
379
+ ### **CRITICAL - Marker File Naming Convention (STRICT RULES)**
380
+
381
+ **✅ CORRECT Format - MUST USE:**
382
+ ```
383
+ {completed_dir}/{fileName}.done.json ← Completion status marker (JSON format)
384
+ {completed_dir}/{fileName}.graph.json ← Graph data marker (JSON format)
385
+ ```
386
+
387
+ **Examples:**
388
+ - `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.done.json`
389
+ - `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/UserController.graph.json`
390
+
391
+ **❌ WRONG Format - NEVER USE:**
392
+ ```
393
+ {fileName}.completed.json ← WRONG extension
394
+ {fileName}.done ← WRONG extension (missing .json)
395
+ {fileName}.done.txt ← WRONG extension
396
+ {fileName}_done.json ← WRONG separator and extension
397
+ {fileName}-completed.json ← WRONG separator and extension
398
+ ```
399
+
400
+ **❌ WRONG Filename Examples - NEVER USE:**
401
+ - `UserController.completed.json` - WRONG: uses `.completed.json` instead of `.done.json`
402
+ - `UserController.done` - WRONG: uses `.done` instead of `.done.json`
403
+ - `UserController.done.txt` - WRONG: uses `.done.txt` instead of `.done.json`
404
+ - `UserController_done.json` - WRONG: uses underscore and wrong extension
405
+ - `dict-UserController.done.json` - WRONG: has module prefix
406
+ - `system-UserController.done.json` - WRONG: has module prefix
407
+
408
+ ---
409
+
410
+ ### **CRITICAL - Path Format Rules (STRICT RULES)**
411
+
412
+ **Path Variables:**
413
+ - `completed_dir` - Absolute path to marker files directory (passed to Worker)
414
+ - `sourcePath` - Relative path to source file (from features JSON, passed to Worker)
415
+ - `documentPath` - Relative path to generated document (from features JSON, passed to Worker)
416
+
417
+ **Path Format Requirements:**
418
+
419
+ | Field | Format | Example |
420
+ |-------|--------|---------|
421
+ | `sourcePath` in `.done` | Project-root-relative path | `yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java` |
422
+ | `documentPath` in `.done` | Relative path (as-is from input) | `speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md` |
423
+ | `sourcePath` in `.graph.json` nodes | Project-root-relative path | `yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java` |
424
+ | `documentPath` in `.graph.json` nodes | Relative path (as-is from input) | `speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md` |
425
+
426
+ **⚠️ CRITICAL - sourcePath Validation Rules:**
427
+ - `sourcePath` MUST be a project-root-relative path (e.g., `yudao-ui/yudao-ui-admin-uniapp/src/pages/bpm/index.vue`, `yudao-module-system/src/main/java/.../UserController.java`)
428
+ - NEVER use platform-source-relative short paths (e.g., `pages/bpm/index.vue`, `pages-bpm/category/index.vue`, `controller/admin/user/UserController.java`)
429
+ - Exception: `node_modules/` and third-party library paths are kept as-is (e.g., `node_modules/wot-design-uni/components/wd-icon/wd-icon.vue`)
430
+
431
+ **⚠️ CRITICAL - documentPath Rules:**
432
+ - When no corresponding document exists for a component/API, `documentPath` MUST be `"N/A"`
433
+ - NEVER use empty string `""` for `documentPath` — this causes downstream processing issues
434
+
435
+ **⚠️ CRITICAL: NEVER convert relative paths to absolute paths in the JSON content!**
436
+
437
+ **Correct vs Wrong Example:**
438
+ ```json
439
+ // ✅ CORRECT - .done file content:
440
+ {
441
+ "fileName": "UserController",
442
+ "sourcePath": "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java",
443
+ "sourceFile": "features-admin-api.json",
444
+ "module": "system",
445
+ "status": "success",
446
+ "analysisNotes": "Successfully analyzed UserController"
447
+ }
448
+
449
+ // ❌ WRONG - .done file content (DO NOT DO THIS):
450
+ {
451
+ "fileName": "UserController",
452
+ "sourcePath": "d:/dev/project/yudao-module-system/.../UserController.java", ← WRONG: absolute path
453
+ "sourceFile": "features-admin-api.json",
454
+ "module": "system",
455
+ "status": "success"
456
+ }
457
+ ```
458
+
459
+ ---
460
+
461
+ **Marker File Naming Convention Summary:**
462
+
463
+ | Marker Type | File Name Format | Example |
464
+ |-------------|------------------|---------|
465
+ | Completion marker | `{fileName}.done.json` | `index.done.json`, `UserController.done.json`, `AiKnowledgeDocumentCreateListReqVO.done.json` |
466
+ | Graph data | `{fileName}.graph.json` | `index.graph.json`, `UserController.graph.json`, `AiKnowledgeDocumentCreateListReqVO.graph.json` |
467
+
468
+ **Worker Completion Requirements:**
469
+
470
+ - Worker MUST create **both** `.done.json` (JSON) and `.graph.json` (JSON) marker files
471
+ - **Both files must be valid JSON format** — plain text content will cause processing failures
472
+ - Task is considered **incomplete** if either file is missing or contains invalid JSON
473
+ - The `.done.json` file must include all required fields: `fileName`, `sourcePath`, `sourceFile`, `module`, `status`, `analysisNotes`
474
+ - The `.graph.json` file must follow the graph data schema defined in `speccrew-knowledge-graph-write/SKILL.md`
475
+ - **sourcePath and documentPath MUST be relative paths** (as received from features JSON), NEVER convert to absolute paths
476
+ - **documentPath MUST NOT be empty string** — use `"N/A"` when no corresponding document exists
477
+
478
+ **Step 3: Process Batch Results**
479
+
480
+ 1. **Locate the script**: Find `batch-orchestrator.js` in the `speccrew-knowledge-bizs-dispatch` skill's scripts directory:
481
+ - Script location: `{ide_skills_dir}/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js`
482
+ - Where `{ide_skills_dir}` is the IDE-specific skills directory (e.g., `.qoder/skills/`, `.cursor/skills/`, `.vscode/skills/`, `.speccrew/skills/`)
483
+ - Use `ListDir` to locate the script if the exact path is unknown
484
+
485
+ 2. **Execute process-results**:
486
+ ```
487
+ node "{path_to_batch_orchestrator_js}" process-results --syncStatePath "{sync_state_path}" --graphRoot "{graph_root}" --graphWriteScript "{graph_write_script_path}" --platformId "{platformId}"
488
+ ```
489
+
490
+ This script:
491
+ - Scans `.done` files → updates feature status to `completed` in features-*.json
492
+ - Scans `.graph.json` files → writes graph data (nodes + edges) grouped by module
493
+ - Cleans up all marker files
494
+
495
+ After Step 3 completes, return to Step 1.
496
+
497
+ #### Context Recovery (Stateless Design)
498
+
499
+ Dispatch 采用完全无状态的文件驱动设计。如果执行过程中发生上下文压缩或中断:
500
+ - 无需记忆任何批次状态或 Worker 输出
501
+ - 重新执行循环:`get-batch` 会自动从文件状态恢复,跳过已完成和正在处理中的 features
502
+ - `process-results` 会处理所有未清理的标记文件
503
+ - 整个流程可安全重入
504
+
505
+ #### Stage 2 Output
506
+
507
+ - Generated by Workers: Feature documentation at `feature.documentPath` (one .md per feature); marker files (`.done` + `.graph.json`) in `completed_dir`
508
+ - Updated by `process-results`: Each `features-{platform}.json` updated with analysis timestamps and status; graph data written to `speccrew-workspace/knowledges/bizs/graph/`
509
+ - Marker files cleaned up after each batch
510
+
511
+ **Feature Status Flow**: `pending` → `in_progress` → `completed` / `failed`
512
+
513
+ ### Large-Scale Scenario Guidance
514
+
515
+ When dealing with modules containing more than **20 features**, consider the following:
516
+
517
+ - **Single Agent Limit**: A single Worker Agent can reliably process ~20 features per session due to context window constraints. Beyond this, context degradation may cause incomplete document generation.
518
+ - **Multi-Worker Strategy**: For modules with >20 features, dispatch multiple Worker Agents in parallel, each handling a non-overlapping subset of features (e.g., by batch index range).
519
+ - **Resume Support**: The `get-next-batch` script naturally supports resume across sessions — it skips features that already have `.done` files. To resume after a session break, simply restart the Stage 2 loop.
520
+ - **Validation After Completion**: After all features are marked `analyzed=true`, run `process-batch-results` with `--validateDocs --syncStatePath "{sync_state_path}"` to verify document completeness.
521
+
522
+ ---
523
+
524
+ ## Stage 3: Module Summarize (Parallel)
525
+
526
+ **Goal**: Complete each module overview based on feature details.
527
+
528
+ **Prerequisite**: Stage 2 completed for the module (in full or incremental mode).
529
+
530
+ **Action (full mode)**:
531
+ - Read all `features-{platform}.json` files from `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/`
532
+ - For each platform, group features by `module` to identify unique modules
533
+ - For each module, invoke 1 Worker Agent (`speccrew-task-worker.md`) with `skill_name: speccrew-knowledge-module-summarize`
534
+ - Parameters to pass to skill:
535
+ - `module_name`: Module code_name
536
+ - `module_path`: Path to module directory (e.g., `speccrew-workspace/knowledges/bizs/{platform_id}/{module_name}/`)
537
+ - `language`: User's language — **REQUIRED**
538
+ - **Behavior constraint**: Worker MUST NOT create any temporary scripts or workaround files. If execution fails, STOP and report error immediately.
539
+
540
+ Expected Worker Return: `{ "status": "success|failed", "module_name": "...", "output_file": "...-overview.md", "message": "..." }`
541
+
542
+ **Action (incremental mode)**:
543
+ - Reuse module status from Stage 2 (NEW / CHANGED / DELETED / UNMODIFIED).
544
+ - Only dispatch Workers for modules with status **NEW** or **CHANGED**.
545
+
546
+ **Parallel Tasks** (grouped by platform):
547
+ ```
548
+ Platform: Web Frontend (web)
549
+ Worker 1: module="order", module_path="speccrew-workspace/knowledges/bizs/web/order/"
550
+ Worker 2: module="payment", module_path="speccrew-workspace/knowledges/bizs/web/payment/"
551
+
552
+ Platform: Mobile App (mobile-flutter)
553
+ Worker 3: module="order", module_path="speccrew-workspace/knowledges/bizs/mobile-flutter/order/"
554
+ Worker 4: module="payment", module_path="speccrew-workspace/knowledges/bizs/mobile-flutter/payment/"
555
+ ```
556
+
557
+ **Output per Module**:
558
+ - `{{module_name}}-overview.md` (complete version)
559
+
560
+ ---
561
+
562
+ ## Stage 3.5: UI Style Pattern Extract (Parallel by Platform)
563
+
564
+ **Goal**: Extract UI design patterns (page types, component patterns, layout patterns) from analyzed feature documents, aggregating cross-module patterns and outputting to the techs knowledge base `ui-style-patterns/` directory.
565
+
566
+ **Prerequisite**: All Stage 3 tasks completed.
567
+
568
+ **Platform Filter**: Only execute for frontend platforms (platformType = web, mobile, desktop). Backend platforms skip this stage.
569
+
570
+ **Directory Creation**: The `ui-style-extract` skill automatically creates the output directory (`knowledges/techs/{platform_id}/ui-style-patterns/`) if it does not exist. No pre-check required.
571
+
572
+ **Action**:
573
+ - Read all `features-{platform}.json` files
574
+ - Filter platforms where platformType is web/mobile/desktop
575
+ - Determine platform_id (format: `{platformType}-{platformSubtype}`, e.g., `web-vue`, `mobile-uniapp`, `backend-system`)
576
+ - For each qualifying platform, launch 1 Worker Agent (`speccrew-task-worker`) with `skill_name: speccrew-knowledge-bizs-ui-style-extract`
577
+ - Parameters to pass:
578
+ - `platform_id`: Platform identifier
579
+ - `platform_type`: Platform type
580
+ - `feature_docs_path`: Feature document base path for that platform
581
+ - `features_manifest_path`: Path to the corresponding `features-{platform}.json`
582
+ - `module_overviews_path`: **Parent directory** containing all module overview subdirectories for that platform (e.g., `knowledges/bizs/web-vue/`). This directory contains `{module}/module-overview.md` or `{module}/{module}-overview.md` files. **NOT** a specific module directory.
583
+ - `output_path`: `speccrew-workspace/knowledges/techs/{platform_id}/ui-style-patterns/`
584
+ - `language`: User's language
585
+ - **Behavior constraint**: Worker MUST NOT create any temporary scripts or workaround files. If execution fails, STOP and report error immediately.
586
+
587
+ **Cross-Pipeline Output**:
588
+ - This stage writes to techs knowledge base, not bizs knowledge base
589
+ - Output location: `speccrew-workspace/knowledges/techs/{platform_id}/ui-style-patterns/`
590
+ - Subdirectories: `page-types/`, `components/`, `layouts/`
591
+ - `ui-style-guide.md` and `styles/` are managed by techs pipeline, this stage does not modify them
592
+
593
+ **Parallel Tasks**: One Worker per frontend platform, can execute in parallel.
594
+
595
+ **Output per Platform**:
596
+ ```
597
+ speccrew-workspace/knowledges/techs/{platform_id}/ui-style-patterns/
598
+ ├── page-types/
599
+ │ └── {pattern-name}.md
600
+ ├── components/
601
+ │ └── {pattern-name}.md
602
+ └── layouts/
603
+ └── {pattern-name}.md
604
+ ```
605
+
606
+ ---
607
+
608
+ ## Stage 4: System Summarize (Single Task)
609
+
610
+ **Goal**: Generate complete system-overview.md aggregating all platforms and modules.
611
+
612
+ **Prerequisite**: All Stage 3 tasks completed.
613
+
614
+ **Action**:
615
+ - Read all `features-{platform}.json` files from `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/` to get platform structure
616
+ - Invoke 1 Worker Agent (`speccrew-task-worker.md`) with `skill_name: speccrew-knowledge-system-summarize`
617
+ - Parameters to pass to skill:
618
+ - `modules_path`: Path to knowledge base directory containing all platform modules (e.g., `speccrew-workspace/knowledges/bizs/`)
619
+ - `output_path`: Output path for system-overview.md (e.g., `speccrew-workspace/knowledges/bizs/`)
620
+ - `language`: User's language — **REQUIRED**
621
+ - **Behavior constraint**: Worker MUST NOT create any temporary scripts or workaround files. If execution fails, STOP and report error immediately.
622
+
623
+ Expected Worker Return: `{ "status": "success|failed", "output_file": "system-overview.md", "message": "..." }`
624
+
625
+ **Output**:
626
+ - `speccrew-workspace/knowledges/bizs/system-overview.md` (complete with platform index and module hierarchy)
627
+
628
+ ---
629
+
630
+ ## Error Handling
631
+
632
+ | Stage | Failure Scenario | Handling | Retry |
633
+ |-------|-----------------|----------|-------|
634
+ | Stage 1a | Entry directory recognition fails | Abort pipeline, report error with platform details | No retry |
635
+ | Stage 1b | Script execution fails | Abort pipeline, report error | No retry |
636
+ | Stage 2 | Single Worker fails | Mark feature as `failed`, continue other Workers | No auto-retry |
637
+ | Stage 2 | Failure rate > 50% | Abort pipeline, report all failures | — |
638
+ | Stage 3 | Single Worker fails | Skip that module, continue others | Retry once |
639
+ | Stage 3.5 | Continue pipeline even if pattern extraction fails; report warning | — | — |
640
+ | Stage 4 | Worker fails | Abort, preserve all generated content | Retry once |
641
+
642
+ **Failed feature handling**: Features marked as `failed` via `update-feature-status` script retain their error details in `features-{platform}.json` for manual inspection or re-run.
643
+
644
+ ---
645
+
646
+ ## Return
647
+
648
+ After all 5 stages complete, return a summary object to the caller:
649
+
650
+ ```json
651
+ {
652
+ "status": "completed",
653
+ "pipeline": "bizs",
654
+ "stages": {
655
+ "stage1a": { "status": "completed", "platforms": 2, "modules": 12 },
656
+ "stage1b": { "status": "completed", "platforms": 2, "features": 32 },
657
+ "stage2": { "status": "completed", "analyzed": 32, "failed": 0, "graphWritten": 32 },
658
+ "stage3": { "status": "completed", "modules": 8, "failed": 0 },
659
+ "stage3_5": { "status": "completed", "platforms": 2, "patterns": 15 },
660
+ "stage4": { "status": "completed" }
661
+ },
662
+ "output": {
663
+ "system_overview": "speccrew-workspace/knowledges/bizs/system-overview.md",
664
+ "graph_root": "speccrew-workspace/knowledges/bizs/graph/"
665
+ }
666
+ }
667
+ ```