@chongyan/autospec 1.0.1

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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +472 -0
  3. package/README.md +476 -0
  4. package/bin/autospec.js +3 -0
  5. package/knowledge/README.md +144 -0
  6. package/knowledge/checklists/code.md +182 -0
  7. package/knowledge/checklists/design.md +196 -0
  8. package/knowledge/checklists/release.md +70 -0
  9. package/knowledge/checklists/requirement.md +169 -0
  10. package/knowledge/checklists/test.md +46 -0
  11. package/knowledge/config/README.en.md +44 -0
  12. package/knowledge/config/README.md +44 -0
  13. package/knowledge/config/role-composition.yaml +98 -0
  14. package/knowledge/config/role-extensions.yaml +140 -0
  15. package/knowledge/config/skill-compositions.yaml +142 -0
  16. package/knowledge/config/team-stage.yaml +95 -0
  17. package/knowledge/config/team-tasks.yaml +139 -0
  18. package/knowledge/config/team-triggers.yaml +198 -0
  19. package/knowledge/config/validation-patterns.yaml +137 -0
  20. package/knowledge/domain/README.md +115 -0
  21. package/knowledge/domain/flows/README.md +194 -0
  22. package/knowledge/domain/glossary.md +143 -0
  23. package/knowledge/domain/rules.md +138 -0
  24. package/knowledge/environment/README.en.md +36 -0
  25. package/knowledge/environment/README.md +87 -0
  26. package/knowledge/environment/component-knowledge.md +316 -0
  27. package/knowledge/environment/detection-patterns.yaml +502 -0
  28. package/knowledge/environment/middleware-knowledge.md +237 -0
  29. package/knowledge/environment/template-registry.md +321 -0
  30. package/knowledge/guides/domain-driven-design.md +345 -0
  31. package/knowledge/guides/knowledge-management.md +369 -0
  32. package/knowledge/guides/requirement-engineering.md +329 -0
  33. package/knowledge/guides/stages/ai-effect-evaluator.md +93 -0
  34. package/knowledge/guides/stages/code-implementer.md +205 -0
  35. package/knowledge/guides/stages/code-reviewer.md +111 -0
  36. package/knowledge/guides/stages/consistency-checker.md +177 -0
  37. package/knowledge/guides/stages/design-planner.md +401 -0
  38. package/knowledge/guides/stages/design-reviewer.md +83 -0
  39. package/knowledge/guides/stages/integration-test-runner.md +105 -0
  40. package/knowledge/guides/stages/release-checker.md +205 -0
  41. package/knowledge/guides/stages/requirement-analyzer.md +195 -0
  42. package/knowledge/guides/stages/requirement-reviewer.md +83 -0
  43. package/knowledge/guides/stages/security-reviewer.md +89 -0
  44. package/knowledge/guides/stages/test-context-analyzer.md +250 -0
  45. package/knowledge/guides/stages/test-generator.md +241 -0
  46. package/knowledge/guides/stages/test-planner.md +183 -0
  47. package/knowledge/guides/stages/test-reviewer.md +76 -0
  48. package/knowledge/guides/stages/unit-test-runner.md +83 -0
  49. package/knowledge/guides/support/ai-agent-analyzer.md +362 -0
  50. package/knowledge/guides/support/ai-anomaly-analyzer.md +213 -0
  51. package/knowledge/guides/support/ai-artifact-evaluator.md +192 -0
  52. package/knowledge/guides/support/ai-capability-analyzer.md +193 -0
  53. package/knowledge/guides/support/ai-component-analyzer.md +169 -0
  54. package/knowledge/guides/support/ai-data-validator.md +276 -0
  55. package/knowledge/guides/support/ai-evaluation-planner.md +374 -0
  56. package/knowledge/guides/support/ai-path-evaluator.md +274 -0
  57. package/knowledge/guides/support/ai-pipeline-evaluator.md +219 -0
  58. package/knowledge/guides/support/ai-rag-analyzer.md +339 -0
  59. package/knowledge/guides/support/ai-task-assessor.md +418 -0
  60. package/knowledge/guides/support/ai-test-diagnostics.md +133 -0
  61. package/knowledge/guides/support/complexity-assessor.md +268 -0
  62. package/knowledge/guides/support/component-discovery.md +183 -0
  63. package/knowledge/guides/support/environment-scanner.md +207 -0
  64. package/knowledge/guides/support/environment-validator.md +207 -0
  65. package/knowledge/guides/support/knowledge-generator.md +234 -0
  66. package/knowledge/guides/support/methodology-extractor.md +55 -0
  67. package/knowledge/guides/support/pipeline-protocol.md +438 -0
  68. package/knowledge/guides/support/practice-logger.md +359 -0
  69. package/knowledge/guides/support/scope-inference.md +174 -0
  70. package/knowledge/guides/support/skill-distiller.md +91 -0
  71. package/knowledge/guides/support/skill-updater.md +45 -0
  72. package/knowledge/guides/support/skill-validator.md +72 -0
  73. package/knowledge/guides/support/team-orchestrator.md +323 -0
  74. package/knowledge/guides/support/tech-stack-analyzer.md +139 -0
  75. package/knowledge/guides/support/test-runner.md +254 -0
  76. package/knowledge/guides/system-design.md +352 -0
  77. package/knowledge/organization/ai-native-team.md +318 -0
  78. package/knowledge/organization/team-metrics.md +228 -0
  79. package/knowledge/principles/constitution.md +134 -0
  80. package/knowledge/principles/core-principles.md +368 -0
  81. package/knowledge/principles/design-philosophy.md +877 -0
  82. package/knowledge/principles/evolution.md +553 -0
  83. package/knowledge/process/01-requirement.md +113 -0
  84. package/knowledge/process/02-design.md +123 -0
  85. package/knowledge/process/03-implementation.md +90 -0
  86. package/knowledge/process/04-review.md +80 -0
  87. package/knowledge/process/05-testing.md +90 -0
  88. package/knowledge/process/06-delivery.md +88 -0
  89. package/knowledge/process/README.en.md +38 -0
  90. package/knowledge/process/README.md +48 -0
  91. package/knowledge/process/ai-sdlc.md +475 -0
  92. package/knowledge/process/overview.md +319 -0
  93. package/knowledge/standards/code-review.md +876 -0
  94. package/knowledge/standards/coding-style.md +940 -0
  95. package/knowledge/standards/data-consistency.md +1085 -0
  96. package/knowledge/standards/document-versioning.md +210 -0
  97. package/knowledge/standards/risk-detection.md +186 -0
  98. package/knowledge/templates/ai-evaluation.md +150 -0
  99. package/knowledge/templates/api-design.md +117 -0
  100. package/knowledge/templates/database-design.md +132 -0
  101. package/knowledge/templates/domain-driven-design.md +321 -0
  102. package/knowledge/templates/product-proposal.md +201 -0
  103. package/knowledge/templates/system-design.md +227 -0
  104. package/knowledge/templates/task-breakdown.md +107 -0
  105. package/knowledge/templates/test-case.md +170 -0
  106. package/package.json +53 -0
  107. package/plugins/.claude-plugin/plugin.json +134 -0
  108. package/plugins/agents/roles/ai-engineer.md +129 -0
  109. package/plugins/agents/roles/backend-engineer.md +165 -0
  110. package/plugins/agents/roles/ceo.md +94 -0
  111. package/plugins/agents/roles/data-engineer.md +135 -0
  112. package/plugins/agents/roles/devops-engineer.md +181 -0
  113. package/plugins/agents/roles/frontend-engineer.md +129 -0
  114. package/plugins/agents/roles/product-owner.md +98 -0
  115. package/plugins/agents/roles/quality-engineer.md +129 -0
  116. package/plugins/agents/roles/security-engineer.md +180 -0
  117. package/plugins/agents/roles/tech-lead.md +97 -0
  118. package/plugins/agents/support/blind-comparator.md +88 -0
  119. package/plugins/agents/support/consistency-checker.md +103 -0
  120. package/plugins/agents/support/failure-diagnostician.md +141 -0
  121. package/plugins/agents/support/independent-reviewer.md +80 -0
  122. package/plugins/agents/support/safety-auditor.md +121 -0
  123. package/plugins/agents/support/skill-benchmarker.md +86 -0
  124. package/plugins/agents/support/skill-forger.md +105 -0
  125. package/plugins/agents/support/stage-gate-evaluator.md +121 -0
  126. package/plugins/agents/support/test-coverage-reviewer.md +73 -0
  127. package/plugins/benchmarks/templates/README.md +44 -0
  128. package/plugins/benchmarks/templates/commands/explore-template.yaml +48 -0
  129. package/plugins/benchmarks/templates/pipeline/agile-template.yaml +84 -0
  130. package/plugins/benchmarks/templates/pipeline/waterfall-template.yaml +106 -0
  131. package/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml +48 -0
  132. package/plugins/commands/README.en.md +96 -0
  133. package/plugins/commands/README.md +96 -0
  134. package/plugins/commands/apply.md +191 -0
  135. package/plugins/commands/archive.md +76 -0
  136. package/plugins/commands/env-export.md +79 -0
  137. package/plugins/commands/env-sync.md +640 -0
  138. package/plugins/commands/env-template.md +223 -0
  139. package/plugins/commands/env-update.md +264 -0
  140. package/plugins/commands/env-validate.md +176 -0
  141. package/plugins/commands/env.md +79 -0
  142. package/plugins/commands/explore.md +76 -0
  143. package/plugins/commands/field-evolve.md +536 -0
  144. package/plugins/commands/memory.md +249 -0
  145. package/plugins/commands/project-evolve.md +821 -0
  146. package/plugins/commands/propose.md +93 -0
  147. package/plugins/commands/review.md +140 -0
  148. package/plugins/commands/run.md +224 -0
  149. package/plugins/commands/status.md +62 -0
  150. package/plugins/commands/validate.md +108 -0
  151. package/plugins/hooks/README.en.md +56 -0
  152. package/plugins/hooks/README.md +56 -0
  153. package/plugins/hooks/ai-project-guard.js +329 -0
  154. package/plugins/hooks/artifact-evaluation-hook.js +237 -0
  155. package/plugins/hooks/constitution-guard.js +211 -0
  156. package/plugins/hooks/environment-autocommit.js +264 -0
  157. package/plugins/hooks/environment-manager.js +778 -0
  158. package/plugins/hooks/execution-tracker.js +354 -0
  159. package/plugins/hooks/frozen-zone-guard.js +140 -0
  160. package/plugins/hooks/layer1-validator.js +423 -0
  161. package/plugins/hooks/lib/artifact-evaluator.js +414 -0
  162. package/plugins/hooks/lib/benchmarks/change-detector.js +390 -0
  163. package/plugins/hooks/lib/benchmarks/evaluator.js +605 -0
  164. package/plugins/hooks/lib/benchmarks/integration-example.js +169 -0
  165. package/plugins/hooks/lib/data-and-ai-detector.js +275 -0
  166. package/plugins/hooks/lib/detection-pattern-loader.js +865 -0
  167. package/plugins/hooks/lib/directory-discovery.js +395 -0
  168. package/plugins/hooks/lib/environment-config-loader.js +341 -0
  169. package/plugins/hooks/lib/environment-detector.js +553 -0
  170. package/plugins/hooks/lib/environment-evolver.js +564 -0
  171. package/plugins/hooks/lib/environment-registry.js +813 -0
  172. package/plugins/hooks/lib/execution-path.js +427 -0
  173. package/plugins/hooks/lib/hook-error-recorder.js +245 -0
  174. package/plugins/hooks/lib/hook-logger.js +538 -0
  175. package/plugins/hooks/lib/hook-runner.js +97 -0
  176. package/plugins/hooks/lib/hook-runner.sh +44 -0
  177. package/plugins/hooks/lib/hook-state-manager.js +480 -0
  178. package/plugins/hooks/lib/memory-extractor.js +377 -0
  179. package/plugins/hooks/lib/memory-manager.js +673 -0
  180. package/plugins/hooks/lib/metrics-analyzer.js +489 -0
  181. package/plugins/hooks/lib/project-evolution/auto-fixer.js +511 -0
  182. package/plugins/hooks/lib/project-evolution/memory-manager.js +346 -0
  183. package/plugins/hooks/lib/project-evolution/pattern-detector.js +476 -0
  184. package/plugins/hooks/lib/project-evolution/semantic-indexer.js +480 -0
  185. package/plugins/hooks/lib/project-structure-detector.js +326 -0
  186. package/plugins/hooks/lib/rollback-tracker.js +346 -0
  187. package/plugins/hooks/lib/source-code-scanner.js +596 -0
  188. package/plugins/hooks/lib/technology-stack-detector.js +374 -0
  189. package/plugins/hooks/lib/test-failure-analyzer.js +375 -0
  190. package/plugins/hooks/lib/test-failure-fixer.js +268 -0
  191. package/plugins/hooks/lib/trace-context.js +277 -0
  192. package/plugins/hooks/lib/validation-patterns.js +415 -0
  193. package/plugins/hooks/memory-sync.js +171 -0
  194. package/plugins/hooks/pipeline-observer.js +413 -0
  195. package/plugins/hooks/scope-sentinel.js +204 -0
  196. package/plugins/hooks/trace-initialization.js +169 -0
  197. package/plugins/memory/templates/code-quality.yaml +149 -0
  198. package/plugins/memory/templates/multi-system.yaml +155 -0
  199. package/plugins/memory/templates/team-habits.yaml +119 -0
  200. package/plugins/memory/templates/testing.yaml +121 -0
  201. package/plugins/skills/README.en.md +47 -0
  202. package/plugins/skills/README.md +104 -0
  203. package/plugins/skills/benchmark-executor/README.md +93 -0
  204. package/plugins/skills/benchmark-executor/SKILL.md +647 -0
  205. package/plugins/skills/benchmark-generator/SKILL.md +349 -0
  206. package/plugins/skills/delivery-stage/SKILL.md +203 -0
  207. package/plugins/skills/design-stage/SKILL.md +216 -0
  208. package/plugins/skills/evolution-process/SKILL.md +291 -0
  209. package/plugins/skills/exploration-phase/SKILL.md +133 -0
  210. package/plugins/skills/implementation-stage/SKILL.md +179 -0
  211. package/plugins/skills/layer1-validation/SKILL.md +79 -0
  212. package/plugins/skills/pending-dashboard/SKILL.md +109 -0
  213. package/plugins/skills/project-evolution/SKILL.md +847 -0
  214. package/plugins/skills/requirement-stage/SKILL.md +183 -0
  215. package/plugins/skills/skill-forge/SKILL.md +223 -0
  216. package/plugins/skills/skill-forge/references/description-guide.md +92 -0
  217. package/plugins/skills/skill-forge/references/quality-rubric.md +104 -0
  218. package/plugins/skills/skill-forge/references/skill-template.md +106 -0
  219. package/plugins/skills/startup-guard/SKILL.md +38 -0
  220. package/plugins/skills/testing-stage/SKILL.md +195 -0
  221. package/scripts/cli/global-init.js +288 -0
  222. package/scripts/cli/global.js +324 -0
  223. package/scripts/cli/index.js +55 -0
  224. package/scripts/cli/init.js +382 -0
  225. package/scripts/cli/list.js +69 -0
  226. package/scripts/cli/org.js +340 -0
  227. package/scripts/cli/update.js +44 -0
  228. package/scripts/config/commands.config.js +145 -0
  229. package/scripts/config/hooks.config.js +197 -0
  230. package/scripts/evolution/evolution-router.js +273 -0
  231. package/scripts/evolution/evolution-signal-collector.js +307 -0
  232. package/scripts/evolution/knowledge-loader.js +346 -0
  233. package/scripts/evolution/marketplace.js +317 -0
  234. package/scripts/evolution/version-manager.js +371 -0
  235. package/scripts/install/agents.js +106 -0
  236. package/scripts/install/commands.js +133 -0
  237. package/scripts/install/constants.js +424 -0
  238. package/scripts/install/hook-logger.js +536 -0
  239. package/scripts/install/hooks.js +110 -0
  240. package/scripts/install/index.js +39 -0
  241. package/scripts/install/skills.js +95 -0
  242. package/scripts/postinstall.js +25 -0
  243. package/scripts/state.js +376 -0
@@ -0,0 +1,418 @@
1
+ ---
2
+ name: ai-task-assessor
3
+ description: AI 评估任务复杂度,动态推荐流程策略
4
+ type: support
5
+ ---
6
+
7
+ ## 定位
8
+
9
+ 替代脚本的复杂度计算,通过理解任务语义进行智能评估,动态推荐流程策略。
10
+
11
+ ## 输入
12
+
13
+ - 必须输入:
14
+ - taskDescription: 任务描述
15
+ - config: 项目配置 (config.json)
16
+ - 可选输入:
17
+ - historicalTasks: 历史相似任务
18
+ - projectContext: 项目上下文
19
+
20
+ ## 输出
21
+
22
+ ```json
23
+ {
24
+ "complexity": "high|medium|low",
25
+ "factors": {
26
+ "scope": {
27
+ "level": "high",
28
+ "reason": "涉及 3 个子系统:后端、前端、AI 模型",
29
+ "score": 8
30
+ },
31
+ "techStack": {
32
+ "level": "medium",
33
+ "reason": "包含 AI 组件,需要效果评测",
34
+ "score": 6
35
+ },
36
+ "integration": {
37
+ "level": "high",
38
+ "reason": "需要对接外部 API 和数据库",
39
+ "score": 7
40
+ },
41
+ "uncertainty": {
42
+ "level": "medium",
43
+ "reason": "需求有部分模糊点需要澄清",
44
+ "score": 5
45
+ },
46
+ "scale": {
47
+ "level": "high",
48
+ "reason": "预估 3 人天,涉及 5+ 功能点",
49
+ "score": 8
50
+ }
51
+ },
52
+ "recommendations": {
53
+ "workflow": "waterfall",
54
+ "roles": ["backend", "frontend", "ai"],
55
+ "checkpoints": ["design-review", "ai-evaluation", "integration-test"],
56
+ "estimatedStages": 6
57
+ },
58
+ "taskDecomposition": {
59
+ "needsDecomposition": true,
60
+ "triggerReasons": [
61
+ "涉及多子系统",
62
+ "预估工作量 > 16 小时",
63
+ "有明确阶段依赖"
64
+ ],
65
+ "decompositionPlan": {
66
+ "strategy": "按系统边界 + 功能模块分层拆解",
67
+ "phases": [
68
+ {
69
+ "id": "P1",
70
+ "name": "AI 效果验证",
71
+ "subsystem": "ai",
72
+ "estimatedHours": 8,
73
+ "tasks": [
74
+ {"id": "T1.1", "name": "准备评测数据集", "hours": 2},
75
+ {"id": "T1.2", "name": "模型训练/调优", "hours": 4},
76
+ {"id": "T1.3", "name": "效果评测验证", "hours": 2}
77
+ ],
78
+ "dependencies": [],
79
+ "parallelizable": false
80
+ },
81
+ {
82
+ "id": "P2",
83
+ "name": "后端 API 开发",
84
+ "subsystem": "backend",
85
+ "estimatedHours": 12,
86
+ "tasks": [
87
+ {"id": "T2.1", "name": "数据模型设计", "hours": 2},
88
+ {"id": "T2.2", "name": "核心接口实现", "hours": 6},
89
+ {"id": "T2.3", "name": "单元测试", "hours": 2},
90
+ {"id": "T2.4", "name": "数据迁移脚本", "hours": 2, "parallel": true}
91
+ ],
92
+ "dependencies": ["P1"],
93
+ "parallelizable": false
94
+ },
95
+ {
96
+ "id": "P3",
97
+ "name": "前端页面开发",
98
+ "subsystem": "frontend",
99
+ "estimatedHours": 6,
100
+ "tasks": [
101
+ {"id": "T3.1", "name": "页面开发", "hours": 4},
102
+ {"id": "T3.2", "name": "接口联调", "hours": 2}
103
+ ],
104
+ "dependencies": ["P2"],
105
+ "parallelizable": true,
106
+ "parallelWith": ["P4"]
107
+ },
108
+ {
109
+ "id": "P4",
110
+ "name": "移动端适配",
111
+ "subsystem": "mobile",
112
+ "estimatedHours": 4,
113
+ "tasks": [
114
+ {"id": "T4.1", "name": "适配开发", "hours": 3},
115
+ {"id": "T4.2", "name": "真机测试", "hours": 1}
116
+ ],
117
+ "dependencies": ["P2"],
118
+ "parallelizable": true,
119
+ "parallelWith": ["P3"]
120
+ }
121
+ ],
122
+ "executionBatches": [
123
+ {"batch": 1, "phases": ["P1"], "reason": "阻塞后续"},
124
+ {"batch": 2, "phases": ["P2"], "reason": "依赖 P1"},
125
+ {"batch": 3, "phases": ["P3", "P4"], "reason": "依赖 P2,可并行"}
126
+ ],
127
+ "decouplingOpportunities": [
128
+ {
129
+ "dependency": "P2 →data→ P3",
130
+ "decouplable": true,
131
+ "method": "API契约定义后,后端实现与前端Mock开发并行",
132
+ "standardArtifact": "OpenAPI Schema",
133
+ "parallelPattern": "契约定义 → 后端实现 ∥ 前端Mock → 联调",
134
+ "integrationCost": "低(接口明确)"
135
+ },
136
+ {
137
+ "dependency": "P1 →data→ P2",
138
+ "decouplable": false,
139
+ "reason": "AI效果验证不达标则后续无意义,必须串行"
140
+ }
141
+ ]
142
+ }
143
+ },
144
+ "risks": [
145
+ {
146
+ "area": "AI 模型效果",
147
+ "risk": "模型效果可能不达标",
148
+ "mitigation": "建议先进行效果验证 POC"
149
+ }
150
+ ],
151
+ "confidence": 0.85
152
+ }
153
+ ```
154
+
155
+ ## 任务拆解触发条件(三视角统一)
156
+
157
+ 任务拆解是一个统一的能力,以下任一条件触发:
158
+
159
+ | 视角 | 触发条件 | 说明 |
160
+ |------|----------|------|
161
+ | **系统边界** | 涉及多子系统 | 需按系统拆分,明确系统间依赖 |
162
+ | **任务规模** | 预估 > 16 小时 | 大任务必须拆为 2-4 小时的子任务 |
163
+ | **阶段依赖** | 有明确阶段约束 | 如 AI 效果验证 → 后端开发 → 前端对接 |
164
+
165
+ **拆解原则**:
166
+ 1. 按 ATOMIC 原则拆分(每个任务 2-4 小时)
167
+ 2. 先按系统边界拆 Phase,再在 Phase 内拆 Task
168
+ 3. 明确标注依赖类型和并行机会
169
+ 4. 输出执行批次,指导并行执行
170
+
171
+ ## 依赖解耦与并行策略
172
+
173
+ ### 依赖类型与解耦可能性
174
+
175
+ | 依赖类型 | 标记 | 可解耦? | 解耦方式 |
176
+ |----------|------|----------|----------|
177
+ | **数据依赖** | `→data` | ✅ 可解耦 | 定义接口协议/数据契约,双方面向标准并行开发 |
178
+ | **逻辑依赖** | `→logic` | ⚠️ 部分可解耦 | 抽象中间层接口,但核心流程仍需串行 |
179
+ | **资源依赖** | `→res` | ❌ 不可解耦 | 共享资源必须串行访问 |
180
+
181
+ ### 面向标准解耦并行
182
+
183
+ **核心思想**:通过提前定义接口协议/数据契约,将"依赖"转化为"面向标准独立开发"。
184
+
185
+ ```
186
+ 传统串行:
187
+ [后端API实现] →data→ [前端开发]
188
+ 后端完成后前端才能开始
189
+
190
+ 面向标准解耦并行:
191
+ [API契约定义] ─┬─→ [后端实现]
192
+ └─→ [前端Mock开发] → [联调验证]
193
+ 契约定义后双方并行,最后联调
194
+ ```
195
+
196
+ **可解耦场景**:
197
+ | 场景 | 标准产出物 | 解耦后并行方式 |
198
+ |------|------------|----------------|
199
+ | 后端↔前端 | API契约(OpenAPI/GraphQL Schema) | 后端实现 ∥ 前端Mock开发 |
200
+ | 后端↔移动端 | API契约 | 后端实现 ∥ 移动端Mock开发 |
201
+ | 数据↔后端 | 数据模型/表结构定义 | 数据管道开发 ∥ 后端接口开发 |
202
+ | AI↔后端 | 模型接口定义(输入输出格式) | 模型训练 ∥ 后端服务开发 |
203
+ | 数据↔数据 | 数据交换格式/Schema | 上游产出定义 ∥ 下游消费开发 |
204
+
205
+ **解耦标记**:
206
+ - `→contract`:通过契约解耦,契约定义后可并行
207
+ - `→mock`:使用Mock数据并行开发,待上游完成后联调
208
+
209
+ **不可解耦场景**(必须串行):
210
+ - 数据库迁移(资源依赖)
211
+ - 配置变更影响多方(资源依赖)
212
+ - 核心业务流程顺序(逻辑依赖,如 创建订单→支付→发货)
213
+ - AI模型效果验证(逻辑依赖,效果不达标则后续无意义)
214
+
215
+ ### 解耦并行判断流程
216
+
217
+ ```
218
+ 1. 识别依赖:A →data→ B
219
+
220
+ 2. 判断可解耦性:
221
+ - 是否有明确的标准产出物可定义?(API契约、数据Schema、接口定义)
222
+ - 下游是否可基于标准产出物独立验证?(Mock测试、Schema校验)
223
+ - 联调成本是否可控?(标准明确则联调成本低)
224
+
225
+ 3. 可解耦时:
226
+ - 先定义标准产出物(契约/Schema)
227
+ - 标记为 A →contract→ B
228
+ - 契约定义后 A实现 ∥ B实现 并行
229
+ - 最后联调验证
230
+
231
+ 4. 不可解耦时:
232
+ - 保持串行 A →data/logic/res→ B
233
+ - 不硬跳过依赖
234
+ ```
235
+
236
+ ## 复杂度评估维度
237
+
238
+ ### 1. 范围复杂度
239
+
240
+ | 因素 | 分数范围 | 说明 |
241
+ |-----|---------|------|
242
+ | 单模块 | 1-3 | 只涉及单个模块 |
243
+ | 多模块 | 4-6 | 涉及多个模块 |
244
+ | 多子系统 | 7-10 | 涉及后端、前端、AI 等多个子系统 |
245
+
246
+ ### 2. 技术复杂度
247
+
248
+ | 因素 | 分数范围 | 说明 |
249
+ |-----|---------|------|
250
+ | 常规技术 | 1-3 | 使用熟悉的框架和工具 |
251
+ | 新技术引入 | 4-6 | 需要引入新技术或框架 |
252
+ | AI/模型组件 | 7-10 | 包含 AI 模型,需要效果评测 |
253
+
254
+ ### 3. 集成复杂度
255
+
256
+ | 因素 | 分数范围 | 说明 |
257
+ |-----|---------|------|
258
+ | 独立功能 | 1-3 | 不依赖外部系统 |
259
+ | 内部集成 | 4-6 | 需要与内部系统集成 |
260
+ | 外部集成 | 7-10 | 需要对接外部 API 或服务 |
261
+
262
+ ### 4. 不确定性
263
+
264
+ | 因素 | 分数范围 | 说明 |
265
+ |-----|---------|------|
266
+ | 需求清晰 | 1-3 | 需求明确,无歧义 |
267
+ | 部分模糊 | 4-6 | 有部分需要澄清的点 |
268
+ | 高度不确定 | 7-10 | 需求模糊,需要探索 |
269
+
270
+ ### 5. 任务规模(新增)
271
+
272
+ | 因素 | 分数范围 | 说明 |
273
+ |-----|---------|------|
274
+ | 小任务 | 1-3 | 预估 < 4 小时,单功能点 |
275
+ | 中任务 | 4-6 | 预估 4-16 小时,多功能点 |
276
+ | 大任务 | 7-10 | 预估 > 16 小时,需拆分为子任务 |
277
+
278
+ **规模判断依据**:
279
+ - 功能点数量:单一功能 vs 多功能组合
280
+ - 代码量预估:单文件 vs 多文件/多模块
281
+ - 依赖复杂度:独立实现 vs 多依赖协调
282
+ - 实施周期:小时级 vs 天级 vs 周级
283
+
284
+ ## 流程策略推荐
285
+
286
+ ### 复杂度级别对应策略
287
+
288
+ | 级别 | 总分范围 | 流程策略 | 人工介入点 |
289
+ |-----|---------|---------|-----------|
290
+ | **low** | 5-15 | 精简流程,可跳过可选阶段 | 仅异常情况 |
291
+ | **medium** | 16-30 | 标准流程 | 阶段确认 |
292
+ | **high** | 31-50 | 完整流程 + 额外审查 | 关键决策点 |
293
+
294
+ ### 工作流推荐
295
+
296
+ | 复杂度 | 推荐工作流 |
297
+ |-------|-----------|
298
+ | low | agile(快速迭代) |
299
+ | medium | waterfall(标准瀑布) |
300
+ | high | waterfall + 额外检查点 |
301
+
302
+ ### 角色推荐
303
+
304
+ 基于任务描述自动识别需要的角色:
305
+
306
+ - 提到 "API"、"后端"、"数据库" → backend
307
+ - 提到 "界面"、"前端"、"页面" → frontend
308
+ - 提到 "AI"、"模型"、"机器学习" → ai
309
+ - 提到 "数据"、"报表"、"ETL"、"数据仓库"、"数据管道" → data
310
+
311
+ ## 执行步骤
312
+
313
+ ### Step 1: 分析任务描述
314
+
315
+ ```
316
+ 1. 提取关键实体和概念
317
+ 2. 识别涉及的技术栈
318
+ 3. 识别涉及的子系统
319
+ 4. 检测不确定性关键词
320
+ ```
321
+
322
+ ### Step 2: 评估各维度
323
+
324
+ ```
325
+ 1. 范围复杂度评估
326
+ 2. 技术复杂度评估
327
+ 3. 集成复杂度评估
328
+ 4. 不确定性评估
329
+ ```
330
+
331
+ ### Step 3: 计算综合复杂度
332
+
333
+ ```
334
+ totalScore = scope + techStack + integration + uncertainty + scale
335
+ complexity = totalScore > 30 ? 'high' : totalScore > 15 ? 'medium' : 'low'
336
+ ```
337
+
338
+ ### Step 4: 生成推荐策略
339
+
340
+ ```
341
+ 1. 推荐工作流
342
+ 2. 推荐角色
343
+ 3. 推荐检查点
344
+ 4. 识别风险
345
+ ```
346
+
347
+ ### Step 5: 评估任务拆解需求(三视角统一)
348
+
349
+ ```
350
+ 1. 判断是否需要拆解(三视角):
351
+ ┌─────────────────────────────────────────────────────────┐
352
+ │ 视角1: 系统边界 → 涉及多子系统?→ 按系统拆 Phase │
353
+ │ 视角2: 任务规模 → 预估 > 16 小时?→ 按功能拆 Task │
354
+ │ 视角3: 阶段依赖 → 有明确阶段约束?→ 按阶段拆分 │
355
+ └─────────────────────────────────────────────────────────┘
356
+ 任一满足 → 需要拆解
357
+
358
+ 2. 制定拆解策略:
359
+ - 多子系统 → 先按系统边界拆 Phase,明确系统间依赖
360
+ - 大任务 → 在 Phase 内按功能模块拆 Task(每任务 2-4h)
361
+ - 有阶段依赖 → 按 AI验证→后端→前端 顺序排列
362
+
363
+ 3. 识别依赖关系:
364
+ - 数据依赖(→data):上游产出作为下游输入
365
+ - 逻辑依赖(→logic):业务流程顺序约束
366
+ - 资源依赖(→res):共享资源需串行访问
367
+
368
+ 4. 识别解耦并行机会:
369
+ - 数据依赖 → 检查是否可定义标准产出物(API契约、数据Schema)
370
+ - 可定义标准 → 标记为 →contract→,契约定义后并行
371
+ - 不可解耦 → 保持串行,不硬跳过
372
+
373
+ 5. 识别原生并行机会:
374
+ - 无共享写入资源 → 可并行
375
+ - 无执行顺序约束 → 可并行
376
+ - 失败互不影响 → 可并行
377
+
378
+ 6. 输出执行批次:
379
+ - 按依赖关系和解耦机会计算执行顺序
380
+ - 标记可并行执行的 Phase/Task
381
+ ```
382
+
383
+ ### Step 6: 输出结果
384
+
385
+ ```
386
+ 输出结构化 JSON,供后续流程使用
387
+ ```
388
+
389
+ ## 与启动门禁的集成
390
+
391
+ 在流程启动时自动调用,结果写入 state.json:
392
+
393
+ ```json
394
+ {
395
+ "taskAssessment": {
396
+ "complexity": "medium",
397
+ "factors": {...},
398
+ "recommendations": {...}
399
+ }
400
+ }
401
+ ```
402
+
403
+ ## 反模式清单 (DP7)
404
+
405
+ 1. **过度评估**:对简单任务也进行复杂分析
406
+ - 检测:任务描述 < 50 字符时使用快速评估
407
+
408
+ 2. **忽略历史**:不考虑历史相似任务
409
+ - 检测:必须检查历史任务库
410
+
411
+ 3. **推荐过于保守**:总是推荐完整流程
412
+ - 检测:low 复杂度任务必须推荐精简流程
413
+
414
+ ## 适用场景
415
+
416
+ - 流程启动时自动触发
417
+ - 手动执行 `/autospec:run --assess`
418
+ - 任务变更时重新评估
@@ -0,0 +1,133 @@
1
+ ---
2
+ name: ai-test-diagnostics
3
+ description: 当测试执行失败或需要评估测试质量时,进行深度分析诊断和质量评估,提供修复建议和改进方向。
4
+ type: ai
5
+ ---
6
+
7
+ ## 定位
8
+
9
+ AI 专用技能。接收测试输出,进行深度分析诊断和质量评估,输出结构化的诊断报告和改进建议。
10
+
11
+ ## 输入
12
+
13
+ - 必须输入:测试执行输出(stdout/stderr)
14
+ - 可选输入:
15
+ - 测试命令
16
+ - 测试覆盖率报告
17
+ - 相关代码文件
18
+ - 项目技术栈信息
19
+ - 代码变更列表
20
+
21
+ ## 输出
22
+
23
+ ```json
24
+ {
25
+ "diagnosis": {
26
+ "summary": "测试失败分析摘要",
27
+ "errorCount": 5,
28
+ "errors": [
29
+ {
30
+ "type": "import",
31
+ "severity": "high",
32
+ "message": "Cannot find module './utils'",
33
+ "file": "src/index.js",
34
+ "line": 3,
35
+ "suggestion": "检查模块路径是否正确,或运行 npm install"
36
+ }
37
+ ],
38
+ "rootCause": {
39
+ "type": "import",
40
+ "confidence": 0.9,
41
+ "description": "主要问题是模块导入路径错误"
42
+ },
43
+ "fixSuggestions": [
44
+ {
45
+ "priority": "high",
46
+ "action": "fix_import",
47
+ "description": "修复导入路径",
48
+ "files": ["src/index.js"]
49
+ }
50
+ ]
51
+ },
52
+ "quality": {
53
+ "score": 75,
54
+ "grade": "B",
55
+ "metrics": {
56
+ "passRate": { "score": 80, "value": "80%" },
57
+ "testCoverage": { "score": 70, "value": "65%" },
58
+ "codeQuality": { "score": 75 },
59
+ "stability": { "score": 80 }
60
+ }
61
+ },
62
+ "improvements": [
63
+ {
64
+ "area": "test_coverage",
65
+ "priority": "high",
66
+ "description": "增加对 utils 模块的测试覆盖",
67
+ "suggestedTests": ["utils/format.test.js"]
68
+ }
69
+ ],
70
+ "testFramework": "vitest",
71
+ "language": "javascript"
72
+ }
73
+ ```
74
+
75
+ ## 执行步骤
76
+
77
+ ### Step 1: 解析测试输出
78
+
79
+ 1. 识别测试框架(vitest/jest/pytest/mocha 等)
80
+ 2. 提取错误信息、文件位置、行号
81
+ 3. 识别错误类型(语法/导入/类型/逻辑/运行时)
82
+ 4. 统计通过/失败数量
83
+
84
+ ### Step 2: 深度诊断
85
+
86
+ 1. **错误分类**:使用 AI 判断错误属于哪类
87
+ 2. **影响评估**:评估错误影响的范围(单文件/多文件/整个模块)
88
+ 3. **根因分析**:分析最可能的根本原因
89
+ 4. **修复优先级**:按影响范围和严重程度排序
90
+
91
+ ### Step 3: 质量评估
92
+
93
+ 1. **通过率分析**:计算测试通过率
94
+ 2. **覆盖率分析**:评估测试覆盖是否充分(如有报告)
95
+ 3. **代码质量**:基于错误模式评估代码质量
96
+ 4. **稳定性**:基于历史数据分析稳定性趋势
97
+
98
+ ### Step 4: 生成建议
99
+
100
+ 1. 针对每个错误给出具体修复建议
101
+ 2. 识别测试覆盖缺口
102
+ 3. 提出具体改进方向
103
+ 4. 优先级排序
104
+
105
+ ### Step 5: 输出综合报告
106
+
107
+ 输出 JSON 格式,包含:
108
+ - 诊断部分:错误统计、根因分析、修复建议
109
+ - 质量部分:质量分数、各维度指标、改进建议
110
+
111
+ ## 规则
112
+
113
+ - 必须输出结构化 JSON 格式
114
+ - 每个错误必须包含:类型、严重程度、文件位置、修复建议
115
+ - 质量分数范围 0-100
116
+ - 等级:A(90+), B(80+), C(70+), D(60+), F(<60)
117
+ - 优先输出可执行的修复命令
118
+ - 识别哪些问题可以自动修复,哪些需要人工介入
119
+
120
+ ## 反模式清单
121
+
122
+ 1. **只报告错误不分析根因**:必须提供根因分析
123
+ 2. **修复建议过于笼统**:必须给出具体可执行的建议
124
+ 3. **忽略测试框架差异**:必须识别并适配不同框架的输出格式
125
+ 4. **质量评估脱离实际**:必须基于实际数据而非猜测
126
+ 5. **改进建议无优先级**:必须按影响和紧急程度排序
127
+
128
+ ## 适用场景
129
+
130
+ - 测试执行失败,需要诊断原因
131
+ - 需要评估测试质量和覆盖率
132
+ - 需要识别代码质量问题和改进方向
133
+ - 持续集成失败,需要快速定位问题