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,678 @@
1
+ # Business Knowledge Generation Pipeline
2
+
3
+ > **Purpose**: Document the 4-stage pipeline architecture for business knowledge generation, facilitating maintenance and team collaboration
4
+ > **Last Updated**: 2025-03
5
+ > **Related Skills**: `speccrew-knowledge-dispatch`, `speccrew-knowledge-bizs-init`, `speccrew-knowledge-module-analyze`, `speccrew-knowledge-module-summarize`, `speccrew-knowledge-system-summarize`
6
+
7
+ ---
8
+
9
+ ## Architecture Overview
10
+
11
+ The business knowledge generation adopts a **4-stage pipeline** architecture, orchestrated by `speccrew-knowledge-dispatch` to automate the transformation from source code to documentation.
12
+
13
+ ```
14
+ ┌─────────────────────────────────────────────────────────────────────────┐
15
+ │ 4-Stage Pipeline │
16
+ ├─────────┬─────────┬─────────┬─────────┬─────────────────────────────────│
17
+ │Stage 1 │Stage 2 │Stage 3 │Stage 4 │Report │
18
+ │(Single) │(Parallel)│(Parallel)│(Single)│(Single) │
19
+ ├─────────┼─────────┼─────────┼─────────┼─────────────────────────────────│
20
+ │Scan │Analyze │Summarize│System │Generate │
21
+ │Source │Module │Module │Summary │Report │
22
+ │Generate │Extract │Complete │Generate │ │
23
+ │List │Features │Overview │Overview │ │
24
+ └─────────┴─────────┴─────────┴─────────┴─────────────────────────────────│
25
+ │ │ │ │
26
+ modules.json Parallel Parallel SYSTEM- │
27
+ Worker Worker OVERVIEW.md │
28
+ └─────────────────────────────────────────────────────────────────────────┘
29
+ ```
30
+
31
+ ### Pipeline Orchestration
32
+
33
+ When `knowledge_types = "both"`, the bizs pipeline runs in parallel with the techs pipeline from Stage 1. Both pipelines proceed independently through their stages.
34
+
35
+ ---
36
+
37
+ ## Stage Details
38
+
39
+ ### Stage 1: Generate Module List
40
+
41
+ **Execution Mode**: Single Task (1 Worker)
42
+
43
+ **Responsible Skill**: `speccrew-knowledge-bizs-init`
44
+
45
+ **Input**:
46
+ - `source_path`: Source code root directory (default: project root)
47
+ - `output_path`: Task status directory (default: `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/`)
48
+ - `language`: Target language for generated content (e.g., "zh", "en") - **REQUIRED**
49
+
50
+ **Processing Logic**:
51
+ 1. **Determine System Type**: Check for UI indicators (frontend frameworks, page directories) vs API-only systems
52
+ 2. **UI-Based Analysis** (for systems with frontend):
53
+ - Analyze frontend routes and navigation structure
54
+ - Map pages to business modules
55
+ - Extract backend API associations for UI modules
56
+ 3. **API-Based Analysis** (for backend-only systems):
57
+ - Identify API controllers/handlers
58
+ - Group APIs by business domain
59
+ 4. **Extract Module Metadata**: name, code_name, user_value, entry_points, system_type, backend_apis
60
+
61
+ **Platform Naming Convention**:
62
+
63
+ | Concept | Field in modules.json | Example (UniApp) |
64
+ |---------|----------------------|------------------|
65
+ | **Category** | `platform_type` | `mobile` |
66
+ | **Technology** | `platform_subtype` | `uniapp` |
67
+ | **Identifier** | `{platform_type}/{platform_subtype}` | `mobile/uniapp` |
68
+
69
+ **Output**:
70
+ ```
71
+ speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/
72
+ └── modules.json
73
+ ```
74
+
75
+ **modules.json Structure**:
76
+ ```json
77
+ {
78
+ "generated_at": "2024-01-15T10:30:00Z",
79
+ "analysis_method": "ui-based",
80
+ "source_path": "/project",
81
+ "language": "zh",
82
+ "platform_count": 2,
83
+ "platforms": [
84
+ {
85
+ "platform_name": "Web Frontend",
86
+ "platform_type": "web",
87
+ "source_path": "/project/web",
88
+ "tech_stack": ["react", "typescript"],
89
+ "module_count": 4,
90
+ "modules": [
91
+ {
92
+ "name": "Order Management",
93
+ "code_name": "order",
94
+ "user_value": "Handle customer orders from creation to fulfillment",
95
+ "entry_points": [
96
+ "src/pages/orders/index.tsx",
97
+ "src/pages/orders/[id].tsx"
98
+ ],
99
+ "system_type": "ui",
100
+ "backend_apis": [
101
+ "GET /api/orders",
102
+ "POST /api/orders",
103
+ "GET /api/orders/:id"
104
+ ]
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ "platform_name": "Mobile App",
110
+ "platform_type": "mobile",
111
+ "platform_subtype": "flutter",
112
+ "source_path": "/project/mobile",
113
+ "tech_stack": ["flutter", "dart"],
114
+ "module_count": 4,
115
+ "modules": [
116
+ {
117
+ "name": "Order Management",
118
+ "code_name": "order",
119
+ "user_value": "Handle customer orders from creation to fulfillment",
120
+ "entry_points": [
121
+ "lib/pages/orders/list.dart",
122
+ "lib/pages/orders/detail.dart"
123
+ ],
124
+ "system_type": "ui"
125
+ }
126
+ ]
127
+ }
128
+ ]
129
+ }
130
+ ```
131
+
132
+ ---
133
+
134
+ ### Stage 2: Module Analysis
135
+
136
+ **Execution Mode**: Parallel (1 Worker per module)
137
+
138
+ **Responsible Skill**: `speccrew-knowledge-module-analyze`
139
+
140
+ **Input**:
141
+ - `module_name`: Module code_name from modules.json
142
+ - `platform_name`: Platform name (e.g., "Web Frontend", "Mobile App")
143
+ - `platform_type`: Platform type (e.g., "web", "mobile-flutter")
144
+ - `system_type`: Module system type - `"ui"` or `"api"` (from modules.json)
145
+ - `source_path`: Platform-specific source path (from platform.source_path)
146
+ - `tech_stack`: Platform tech stack array
147
+ - `entry_points`: Module entry points (relative file paths)
148
+ - `backend_apis`: Associated backend API endpoints for this module (only when `system_type: "ui"`)
149
+ - `output_path`: Output directory for the module (e.g., `speccrew-workspace/knowledges/bizs/{platform_type}/{module_name}/`)
150
+ - `language`: Target language (e.g., "zh", "en") - **REQUIRED**
151
+
152
+ **Processing Logic**:
153
+ 1. Locate module source files using `entry_points`
154
+ 2. Based on `system_type`, extract different information:
155
+ - **UI-based modules**: Analyze pages, components, state management, user interactions
156
+ - **API-based modules**: Parse controllers, services, entities, public APIs
157
+ 3. Identify features based on granularity rules (Simple/Medium/Complex)
158
+ 4. Generate business flow diagrams (Mermaid) for each API request
159
+ 5. Generate detailed documentation for each feature with source traceability
160
+
161
+ **Feature Granularity Rules**:
162
+
163
+ | Complexity | Criteria | Splitting Strategy | Example |
164
+ |------------|----------|-------------------|---------|
165
+ | Simple | ≤3 API endpoints, no complex business flow | Merge into single document | Data Dictionary Management |
166
+ | Medium | 3-8 API endpoints, independent business scenarios | Split by operation type | User CRUD, User Status Management |
167
+ | Complex | >8 API endpoints, multiple business scenarios | Split by business scenario | Payment Order Management, Payment Security Mechanism |
168
+
169
+ **Output per Module**:
170
+ ```
171
+ speccrew-workspace/knowledges/bizs/{platform_type}/{module_name}/
172
+ ├── {module_name}-overview.md # Initial version (feature list only)
173
+ └── features/
174
+ ├── create-order.md
175
+ ├── list-orders.md
176
+ └── ...
177
+ ```
178
+
179
+ **Parallel Execution Example**:
180
+ ```
181
+ Platform: Web Frontend (web)
182
+ Worker 1: module="order", source="/project/web", output="speccrew-workspace/knowledges/bizs/web/order/"
183
+ Worker 2: module="payment", source="/project/web", output="speccrew-workspace/knowledges/bizs/web/payment/"
184
+
185
+ Platform: Mobile App (mobile-flutter)
186
+ Worker 3: module="order", source="/project/mobile", output="speccrew-workspace/knowledges/bizs/mobile-flutter/order/"
187
+ Worker 4: module="payment", source="/project/mobile", output="speccrew-workspace/knowledges/bizs/mobile-flutter/payment/"
188
+ ```
189
+
190
+ **Status Tracking**:
191
+ ```
192
+ speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/
193
+ └── stage2-status.json
194
+ ```
195
+
196
+ **stage2-status.json Format**:
197
+ ```json
198
+ {
199
+ "generated_at": "2024-01-15T10:30:00Z",
200
+ "stage": "module-analysis",
201
+ "total_modules": 8,
202
+ "completed": 8,
203
+ "failed": 0,
204
+ "platforms": [
205
+ {
206
+ "platform_type": "web",
207
+ "platform_name": "Web Frontend",
208
+ "modules": [
209
+ {
210
+ "module_name": "order",
211
+ "status": "completed",
212
+ "features_count": 5,
213
+ "output_path": "speccrew-workspace/knowledges/bizs/web/order/"
214
+ }
215
+ ]
216
+ }
217
+ ]
218
+ }
219
+ ```
220
+
221
+ ---
222
+
223
+ ### Stage 3: Module Summarize
224
+
225
+ **Execution Mode**: Parallel (1 Worker per module)
226
+
227
+ **Responsible Skill**: `speccrew-knowledge-module-summarize`
228
+
229
+ **Input**:
230
+ - `module_name`: Module code_name from modules.json
231
+ - `module_path`: Path to module directory (e.g., `speccrew-workspace/knowledges/bizs/{platform_type}/{module_name}/`)
232
+ - `language`: Target language (e.g., "zh", "en") - **REQUIRED**
233
+
234
+ **Processing Logic**:
235
+ 1. Read initial {module_name}-overview.md (initial version with feature list)
236
+ 2. Read all features/{feature-name}.md files for this module
237
+ 3. Aggregate entities from all features
238
+ 4. Identify dependencies (internal, external, data)
239
+ 5. Summarize business rules
240
+ 6. Complete all sections of {module_name}-overview.md
241
+
242
+ **Output**:
243
+ ```
244
+ speccrew-workspace/knowledges/bizs/{platform_type}/{module_name}/
245
+ └── {module_name}-overview.md # Complete version
246
+ ```
247
+
248
+ **Completed Content**:
249
+ - Section 1: Module Basic Info (retained)
250
+ - Section 2: Feature List (retained)
251
+ - Section 3: Business Entities (added) - with ER diagram
252
+ - Section 4: Dependencies (added) - internal and external
253
+ - Section 5: Core Flows (added) - cross-feature business flows
254
+ - Section 6: Business Rules (added) - validation and business logic rules
255
+
256
+ **Status Tracking**:
257
+ ```
258
+ speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/
259
+ └── stage3-status.json
260
+ ```
261
+
262
+ **stage3-status.json Format**:
263
+ ```json
264
+ {
265
+ "generated_at": "2024-01-15T10:35:00Z",
266
+ "stage": "module-summarize",
267
+ "total_modules": 8,
268
+ "completed": 8,
269
+ "failed": 0,
270
+ "platforms": [
271
+ {
272
+ "platform_type": "web",
273
+ "platform_name": "Web Frontend",
274
+ "modules": [
275
+ {
276
+ "module_name": "order",
277
+ "status": "completed",
278
+ "overview_file": "speccrew-workspace/knowledges/bizs/web/order/order-overview.md"
279
+ }
280
+ ]
281
+ }
282
+ ]
283
+ }
284
+ ```
285
+
286
+ ---
287
+
288
+ ### Stage 4: System Summarize
289
+
290
+ **Execution Mode**: Single Task (1 Worker)
291
+
292
+ **Responsible Skill**: `speccrew-knowledge-system-summarize`
293
+
294
+ **Input**:
295
+ - `modules_path`: Path to knowledge base directory containing all platform modules (e.g., `speccrew-workspace/knowledges/bizs/`)
296
+ - `output_path`: Output path for system-overview.md (e.g., `speccrew-workspace/knowledges/bizs/`)
297
+ - `language`: Target language (e.g., "zh", "en") - **REQUIRED**
298
+
299
+ **Processing Logic**:
300
+ 1. Discover all {platform_type}/{module_name}/{module_name}-overview.md files
301
+ 2. Read each module overview and extract information
302
+ 3. Build module index table with platform grouping
303
+ 4. Aggregate dependencies from all modules
304
+ 5. Identify business domains
305
+ 6. Identify end-to-end business flows across modules
306
+ 7. Generate complete system-overview.md
307
+
308
+ **Output**:
309
+ ```
310
+ speccrew-workspace/knowledges/bizs/
311
+ └── system-overview.md # Complete system panorama
312
+ ```
313
+
314
+ **Included Content**:
315
+ - Index and Overview (statistics, generation timestamp)
316
+ - System Overview (positioning, target users, deployment type)
317
+ - Module Topology (hierarchy, dependencies, domain grouping)
318
+ - End-to-End Flows (cross-module processes, flow-module mapping matrix)
319
+ - System Boundaries and Integration (external dependencies)
320
+ - Requirement Assessment Guide (references speccrew-pm-requirement-assess skill)
321
+
322
+ ---
323
+
324
+ ## Directory Structure
325
+
326
+ ### Runtime Status Directory
327
+ ```
328
+ speccrew-workspace/
329
+ └── knowledges/
330
+ └── base/
331
+ └── sync-state/
332
+ └── knowledge-bizs/
333
+ ├── modules.json # Stage 1 output
334
+ ├── stage2-status.json # Stage 2 status
335
+ ├── stage3-status.json # Stage 3 status
336
+ └── final-report.json # Final report
337
+ ```
338
+
339
+ ### Generated Documentation Directory
340
+ ```
341
+ speccrew-workspace/
342
+ └── knowledges/
343
+ └── bizs/
344
+ ├── system-overview.md # Generated by Stage 4
345
+ └── {platform_type}/ # e.g., web/, mobile-flutter/
346
+ └── {module_name}/
347
+ ├── {module_name}-overview.md # Generated by Stage 3
348
+ └── features/
349
+ └── {feature-name}.md # Generated by Stage 2
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Worker Dispatch Mechanism
355
+
356
+ ### speccrew-task-worker Invocation
357
+
358
+ The pipeline uses `speccrew-task-worker` Agent for task execution. Leader Agent invokes Workers via the **Task tool** for parallel processing.
359
+
360
+ #### Task Tool Call Format
361
+
362
+ ```yaml
363
+ subagent_type: "speccrew-task-worker"
364
+ description: "Brief task description"
365
+ prompt: |
366
+ skill_path: .speccrew/skills/{skill-name}/SKILL.md
367
+ context:
368
+ param1: value1
369
+ param2: value2
370
+ ...
371
+ ```
372
+
373
+ #### Stage 2 Parallel Dispatch Example
374
+
375
+ ```yaml
376
+ # Worker 1 - Analyze order module (Web Frontend)
377
+ subagent_type: "speccrew-task-worker"
378
+ description: "Analyze order module features"
379
+ prompt: |
380
+ skill_path: .speccrew/skills/speccrew-knowledge-module-analyze/SKILL.md
381
+ context:
382
+ module_name: order
383
+ platform_name: "Web Frontend"
384
+ platform_type: "web"
385
+ system_type: "ui"
386
+ source_path: "/project/web"
387
+ tech_stack: ["react", "typescript"]
388
+ entry_points: ["src/pages/orders/index.tsx", "src/pages/orders/[id].tsx"]
389
+ backend_apis: ["GET /api/orders", "POST /api/orders"]
390
+ output_path: "speccrew-workspace/knowledges/bizs/web/order/"
391
+ language: "zh"
392
+
393
+ # Worker 2 - Analyze payment module (Web Frontend)
394
+ subagent_type: "speccrew-task-worker"
395
+ description: "Analyze payment module features"
396
+ prompt: |
397
+ skill_path: .speccrew/skills/speccrew-knowledge-module-analyze/SKILL.md
398
+ context:
399
+ module_name: payment
400
+ platform_name: "Web Frontend"
401
+ platform_type: "web"
402
+ system_type: "ui"
403
+ source_path: "/project/web"
404
+ tech_stack: ["react", "typescript"]
405
+ entry_points: ["src/pages/payments/index.tsx"]
406
+ backend_apis: ["GET /api/payments", "POST /api/payments"]
407
+ output_path: "speccrew-workspace/knowledges/bizs/web/payment/"
408
+ language: "zh"
409
+
410
+ # ... (more workers for other modules and platforms)
411
+ ```
412
+
413
+ #### Stage 3 Parallel Dispatch Example
414
+
415
+ ```yaml
416
+ # Worker 1 - Summarize order module (Web Frontend)
417
+ subagent_type: "speccrew-task-worker"
418
+ description: "Summarize order module overview"
419
+ prompt: |
420
+ skill_path: .speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md
421
+ context:
422
+ module_name: order
423
+ module_path: "speccrew-workspace/knowledges/bizs/web/order/"
424
+ language: "zh"
425
+
426
+ # Worker 2 - Summarize order module (Mobile App)
427
+ subagent_type: "speccrew-task-worker"
428
+ description: "Summarize order module overview"
429
+ prompt: |
430
+ skill_path: .speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md
431
+ context:
432
+ module_name: order
433
+ module_path: "speccrew-workspace/knowledges/bizs/mobile-flutter/order/"
434
+ language: "zh"
435
+
436
+ # ... (more workers for other modules)
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Dispatcher Responsibilities
442
+
443
+ `speccrew-knowledge-dispatch` is responsible for orchestrating the entire pipeline:
444
+
445
+ ### Core Responsibilities
446
+ 1. **Stage Control**: Ensure stages execute in order (1→2→3→4)
447
+ 2. **Parallel Dispatch**: Stage 2, 3 call multiple Workers in parallel via Task tool
448
+ 3. **Status Tracking**: Record execution status of each task with timestamp
449
+ 4. **Error Handling**: Single task failure does not affect other parallel tasks
450
+ 5. **Result Aggregation**: Generate final execution report
451
+ 6. **Language Propagation**: Pass `language` parameter to all downstream skills
452
+
453
+ ### Dispatch Flow (Full vs Incremental)
454
+
455
+ ```
456
+ 1. Execute Stage 1 (Single Task)
457
+ └─ Invoke 1 Worker with speccrew-knowledge-bizs-init
458
+ └─ Wait for completion ─┐
459
+
460
+ 2. Read latest modules.json│
461
+ IF sync_mode = "full": │
462
+ - Launch Stage 2 in parallel (one Worker per module across all platforms)
463
+ - Invoke N Workers with speccrew-knowledge-module-analyze
464
+ IF sync_mode = "incremental":
465
+ - Use git diff (base_commit vs head_commit) + modules.json to mark modules as NEW / CHANGED / DELETED / UNMODIFIED
466
+ - Launch Stage 2 only for NEW/CHANGED modules
467
+ └─ Wait for all Stage 2 Workers to complete ─┐
468
+
469
+ 3. Generate stage2-status.json with timestamp │
470
+ Launch Stage 3 in parallel │
471
+ IF sync_mode = "full": │
472
+ - Invoke N Workers with speccrew-knowledge-module-summarize (all modules)
473
+ IF sync_mode = "incremental":
474
+ - Invoke Workers only for NEW/CHANGED modules
475
+ └─ Wait for all Stage 3 Workers to complete ─┤
476
+
477
+ 4. Generate stage3-status.json with timestamp │
478
+ Execute Stage 4 (Single Task) │
479
+ └─ Invoke 1 Worker with speccrew-knowledge-system-summarize
480
+ └─ Always rebuild system-overview.md from latest module overviews ─┤
481
+
482
+ 5. Generate unified final report (when knowledge_types = "both", includes techs pipeline results)
483
+ ```
484
+
485
+ ### Parallel Execution with Techs Pipeline
486
+
487
+ When `knowledge_types = "both"`:
488
+
489
+ ```
490
+ Time →
491
+ ─────────────────────────────────────────────────────────────────────────────
492
+
493
+ Bizs Pipeline: [Stage 1] →[Stage 2 Parallel] →[Stage 3 Parallel] →[Stage 4] →[Report]
494
+ │ │ │
495
+ Techs Pipeline: [Stage 1] →[Stage 2 Parallel] →[Stage 3] →[Report]
496
+ │ │
497
+ Both Stage 1s run in parallel
498
+ (independent tasks)
499
+
500
+ ─────────────────────────────────────────────────────────────────────────────
501
+ ```
502
+
503
+ **Execution Rules**:
504
+ 1. **Stage 1 Parallel**: Both bizs-init and techs-init Workers launch simultaneously
505
+ 2. **Independent Progress**: Each pipeline proceeds through its stages independently
506
+ 3. **No Cross-Dependencies**: Bizs and techs pipelines do not depend on each other
507
+ 4. **Unified Final Report**: Generate a combined report after both pipelines complete
508
+
509
+ ---
510
+
511
+ ## Error Handling Strategy
512
+
513
+ | Stage | Failure Impact | Handling Strategy |
514
+ |-------|---------------|-------------------|
515
+ | Stage 1 | Entire pipeline stops | Report error, do not continue (techs pipeline continues if running) |
516
+ | Stage 2 | Single module fails | Continue other modules, record failed module in stage2-status.json |
517
+ | Stage 3 | Single module fails | Continue other modules, record failed module in stage3-status.json |
518
+ | Stage 4 | System summary fails | Abort bizs pipeline if < 50% modules completed successfully |
519
+
520
+ ### Cross-Pipeline Policy
521
+
522
+ - **Pipeline Independence**: Failure in one pipeline does NOT affect the other
523
+ - **Partial Success**: Report success for completed pipeline, failure for the other
524
+ - **Final Report**: Always generate report showing status of both pipelines (if requested)
525
+
526
+ ---
527
+
528
+ ## Usage
529
+
530
+ ### Input Parameters
531
+
532
+ | Parameter | Type | Required | Description |
533
+ |-----------|------|----------|-------------|
534
+ | `source_path` | string | No | Source code root path (default: project root) |
535
+ | `knowledge_types` | string | No | `"bizs"`, `"techs"`, or `"both"` (default: `"both"`) |
536
+ | `output_path` | string | No | Output directory (default: `speccrew-workspace/knowledges/`) |
537
+ | `sync_mode` | string | No | `"full"` or `"incremental"` (default: `"full"`) |
538
+ | `base_commit` | string | No | Git commit hash for incremental mode (comparison base) |
539
+ | `head_commit` | string | No | Git commit hash for incremental mode (current HEAD) |
540
+ | `changed_files` | array | No | Pre-computed list of changed files for incremental mode |
541
+
542
+ ### Trigger Methods
543
+ Invoke through Leader Agent:
544
+ ```
545
+ "Initialize knowledge base"
546
+ "Initialize bizs and techs knowledge base"
547
+ "Generate knowledge from source code"
548
+ "Dispatch knowledge generation tasks"
549
+ ```
550
+
551
+ ### Execution Flow
552
+ 1. Leader Agent identifies intent
553
+ 2. Calls `speccrew-knowledge-dispatch` Skill
554
+ 3. Dispatch executes 4-stage pipeline (or both pipelines if `knowledge_types = "both"`)
555
+ 4. Returns unified execution report
556
+
557
+ ---
558
+
559
+ ## Extensibility Design
560
+
561
+ ### New Module Handling
562
+ When new modules are added to source code:
563
+ 1. Stage 1 automatically recognizes new modules
564
+ 2. Stage 2, 3 automatically create Workers for new modules
565
+ 3. Stage 4 re-aggregates all modules
566
+
567
+ ### Incremental Update with Git (UI + API)
568
+
569
+ For Git-managed projects, the pipeline can run in **incremental mode** to avoid rebuilding the entire knowledge base.
570
+
571
+ **Core idea**: Use `modules.json` as the *business module snapshot*, combine it with `git diff` to identify which modules are affected, and only re-run Stage 2/3 for those modules, while Stage 4 regenerates the system overview.
572
+
573
+ #### 1. Enriched `modules.json` schema
574
+
575
+ Stage 1 (`SpecCrew-knowledge-bizs-init`) produces a richer `modules.json` that becomes the single source of truth for bizs knowledge:
576
+
577
+ - Top-level fields:
578
+ - `generated_at`: ISO timestamp
579
+ - `analysis_method`: `"ui-based"` when any UI platform exists, `"api-based"` when only API platforms
580
+ - `source_path`: Root source path
581
+ - `language`: Documentation language (e.g., `"zh"`, `"en"`)
582
+ - `source_commit`: Git commit hash at generation time (HEAD)
583
+ - `platforms`: Array of platform objects
584
+
585
+ - Platform object:
586
+ - `platform_name`: Human-readable name (e.g., `"Web Frontend"`)
587
+ - `platform_type`: `web`, `mobile-flutter`, `api`, etc.
588
+ - `source_path`: Platform-specific source root
589
+ - `tech_stack`: Languages/frameworks for this platform
590
+ - `module_count`: Number of modules
591
+ - `modules`: Array of module objects
592
+
593
+ - Module object:
594
+ - `name`: Business module name
595
+ - `code_name`: Technical identifier (e.g., `"order"`)
596
+ - `user_value`: What users accomplish with this module
597
+ - `entry_points`: Relative file paths (from `platform.source_path`) to entry point files
598
+ - `system_type`: `"ui"` or `"api"`
599
+ - `backend_apis`: Associated backend API endpoints, **only when** `system_type = "ui"`
600
+
601
+ This schema allows precise mapping from business modules to concrete source files and API endpoints.
602
+
603
+ #### 2. Incremental sync algorithm
604
+
605
+ Given a previous `modules.json` (with `source_commit = BASE_COMMIT`) and the current HEAD commit:
606
+
607
+ 1. **Re-run Stage 1** on current HEAD
608
+ - Invoke `SpecCrew-knowledge-bizs-init` again
609
+ - Produce a new `modules.json` snapshot (with `source_commit = HEAD`)
610
+
611
+ 2. **Compute file-level changes with Git**
612
+ - Outside the Worker environment, run:
613
+ - `git diff --name-only BASE_COMMIT HEAD`
614
+ - Obtain `changed_files` = list of modified/added/deleted files
615
+
616
+ 3. **Map changed files to modules** using the new `modules.json`:
617
+ - For each platform:
618
+ - For each module:
619
+ - Build `Files(module)` =
620
+ - `platform.source_path + entry_points[*]`
621
+ - Optionally, files backing `backend_apis` (e.g., controllers/services)
622
+ - If `Files(module)` intersects `changed_files` │mark module as **CHANGED**
623
+ - If module exists only in new `modules.json` │mark as **NEW**
624
+ - If module exists only in old `modules.json` │mark as **DELETED**
625
+ - Else │**UNMODIFIED**
626
+
627
+ 4. **Drive Stage 2/3 incrementally** via `SpecCrew-knowledge-dispatch`:
628
+ - Stage 2 (Module Analysis):
629
+ - Only dispatch Workers for modules with status **NEW** or **CHANGED**
630
+ - Skip **UNMODIFIED** modules
631
+ - Stage 3 (Module Summarize):
632
+ - 同样只对 **NEW/CHANGED** 模块派发 Worker
633
+
634
+ 5. **Regenerate system overview (Stage 4)**:
635
+ - Always re-run Stage 4 based on the latest set of module overviews
636
+ - This naturally handles **DELETED** modules (they disappear from `system-overview.md`)
637
+
638
+ 6. **Handle deleted modules (optional policy)**:
639
+ - Option A: Delete directories like `knowledge/bizs/{platform_type}/{module_name}/`
640
+ - Option B: Move them into an archive folder (e.g., `knowledge/bizs/_archive/`)
641
+
642
+ #### 3. Dispatch integration (`sync_mode`)
643
+
644
+ `SpecCrew-knowledge-dispatch` can support a `sync_mode` parameter:
645
+
646
+ - `sync_mode: "full"`
647
+ - Run the pipeline as today: Stage 1 │Stage 2 (all modules) │Stage 3 (all modules) │Stage 4.
648
+ - `sync_mode: "incremental"`
649
+ - Assume that the caller has already prepared:
650
+ - `BASE_COMMIT` and `HEAD`
651
+ - `changed_files` via `git diff`
652
+ - Previous and new `modules.json`
653
+ - Dispatch logic uses the algorithm above to:
654
+ - Determine module status (NEW / CHANGED / DELETED / UNMODIFIED)
655
+ - Only dispatch Workers for NEW/CHANGED modules in Stage 2/3
656
+ - Always run Stage 4 to rebuild `system-overview.md`
657
+
658
+ This design keeps the heavy Git operations outside of Worker Agents, while reusing the existing 4-stage pipeline to support both **initial knowledge base generation** and **incremental updates** in a consistent way.
659
+ ---
660
+
661
+ ## Related Documentation
662
+
663
+ | Document | Location | Description |
664
+ |----------|----------|-------------|
665
+ | system-overview-template.md | `.speccrew/skills/SpecCrew-knowledge-bizs-init/templates/` | System panorama template |
666
+ | {name}-overview-template.md | Same as above | Module overview template |
667
+ | {feature-name}-template.md | Same as above | Feature detail template |
668
+ | SpecCrew-pm-requirement-assess | `.speccrew/skills/` | PM requirement assessment Skill |
669
+
670
+ ---
671
+
672
+ ## Maintenance Log
673
+
674
+ | Date | Changes | Owner |
675
+ |------|---------|-------|
676
+ | - | Initial version, 4-stage pipeline design | - |
677
+
678
+