@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,207 @@
1
+ ---
2
+ name: environment-validator
3
+ description: 校验环境知识配置文件的完整性和有效性
4
+ type: skill
5
+ ---
6
+
7
+ # 环境配置校验器
8
+
9
+ ## 定位
10
+
11
+ 校验 `.autospec/environment/` 目录下的环境知识配置文件,确保格式正确、字段完整、内容有效。
12
+
13
+ ---
14
+
15
+ ## 校验范围
16
+
17
+ ### 1. 文件格式校验
18
+
19
+ | 文件类型 | 校验项 |
20
+ |---------|--------|
21
+ | YAML (.yaml, .yml) | 语法正确性、缩进一致性 |
22
+ | JSON (.json) | 语法正确性、编码格式 |
23
+
24
+ ### 2. 必填字段校验
25
+
26
+ **中间件配置** (`env-knowledge/middleware/*.yaml`):
27
+ ```yaml
28
+ apiVersion: autospec/v1 # 必填
29
+ kind: Middleware # 必填
30
+ meta
31
+ name: string # 必填
32
+ version: string # 必填
33
+ spec:
34
+ type: string # 必填
35
+ connection:
36
+ template: string # 必填
37
+ ```
38
+
39
+ **组件配置** (`component-lib/components/*/component.yaml`):
40
+ ```yaml
41
+ apiVersion: autospec/v1 # 必填
42
+ kind: Component # 必填
43
+ metadata:
44
+ name: string # 必填
45
+ version: string # 必填
46
+ spec:
47
+ type: string # 必填
48
+ description: string # 必填
49
+ ```
50
+
51
+ ### 3. 类型一致性校验
52
+
53
+ | 字段 | 期望类型 |
54
+ |------|---------|
55
+ | `metadata.version` | 语义化版本字符串 |
56
+ | `spec.type` | 枚举值 |
57
+ | `spec.configuration.required` | 数组 |
58
+ | `spec.bestPractices` | 数组 |
59
+
60
+ ### 4. 引用完整性校验
61
+
62
+ - 环境变量引用是否存在
63
+ - 文件路径引用是否正确
64
+ - 注册表与实际文件是否一致
65
+
66
+ ---
67
+
68
+ ## 输出格式
69
+
70
+ 校验结果输出:
71
+
72
+ ```json
73
+ {
74
+ "timestamp": "2024-01-15T10:30:00Z",
75
+ "summary": {
76
+ "total": 15,
77
+ "passed": 12,
78
+ "failed": 2,
79
+ "warnings": 3
80
+ },
81
+ "files": [
82
+ {
83
+ "path": "env-knowledge/middleware/redis.yaml",
84
+ "valid": true,
85
+ "errors": [],
86
+ "warnings": [
87
+ {
88
+ "field": "spec.connection.template",
89
+ "message": "连接模板中包含硬编码的主机地址",
90
+ "suggestion": "建议使用环境变量替换"
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "path": "env-knowledge/middleware/mysql.yaml",
96
+ "valid": false,
97
+ "errors": [
98
+ {
99
+ "field": "metadata.version",
100
+ "message": "版本号格式不正确",
101
+ "expected": "语义化版本 (如 1.0.0)",
102
+ "actual": "v1"
103
+ },
104
+ {
105
+ "field": "spec.type",
106
+ "message": "未知的中间件类型",
107
+ "expected": "relational-database, document-database, cache, message-queue, search-engine",
108
+ "actual": "db"
109
+ }
110
+ ],
111
+ "warnings": []
112
+ }
113
+ ]
114
+ }
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 执行步骤
120
+
121
+ ### Step 1: 扫描配置文件
122
+
123
+ ```
124
+ 1. 扫描 .autospec/environment/ 下所有 YAML/JSON 文件
125
+ 2. 跳过隐藏文件和临时文件
126
+ 3. 构建文件列表
127
+ ```
128
+
129
+ ### Step 2: 逐文件校验
130
+
131
+ ```
132
+ 对每个文件:
133
+ 1. 解析文件内容
134
+ 2. 校验文件格式
135
+ 3. 校验必填字段
136
+ 4. 校验类型一致性
137
+ 5. 记录错误和警告
138
+ ```
139
+
140
+ ### Step 3: 注册表校验
141
+
142
+ ```
143
+ 1. 读取 registry.json
144
+ 2. 检查注册的文件是否存在
145
+ 3. 检查文件与注册信息是否一致
146
+ ```
147
+
148
+ ### Step 4: 汇总结果
149
+
150
+ ```
151
+ 1. 统计通过/失败/警告数量
152
+ 2. 输出校验报告
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 校验规则
158
+
159
+ ### 错误级别(必须修复)
160
+
161
+ | 规则 | 说明 |
162
+ |------|------|
163
+ | YAML_SYNTAX | YAML 语法错误 |
164
+ | JSON_SYNTAX | JSON 语法错误 |
165
+ | REQUIRED_FIELD | 缺少必填字段 |
166
+ | INVALID_TYPE | 字段类型不正确 |
167
+ | INVALID_VERSION | 版本号格式不正确 |
168
+ | FILE_NOT_FOUND | 注册表中引用的文件不存在 |
169
+
170
+ ### 警告级别(建议修复)
171
+
172
+ | 规则 | 说明 |
173
+ |------|------|
174
+ | HARDCODED_VALUE | 硬编码值(建议使用环境变量) |
175
+ | MISSING_OPTIONAL | 缺少可选但推荐的字段 |
176
+ | DEPRECATED_FIELD | 使用了已弃用的字段 |
177
+ | EMPTY_SECTION | 空的配置段落 |
178
+ | INCONSISTENT_NAMING | 命名风格不一致 |
179
+
180
+ ---
181
+
182
+ ## 自动修复(可选)
183
+
184
+ 对于某些问题,支持自动修复:
185
+
186
+ | 问题 | 修复方式 |
187
+ |------|---------|
188
+ | 缺少 `apiVersion` | 自动填充 `autospec/v1` |
189
+ | 缺少 `kind` | 根据文件路径推断 |
190
+ | 版本号格式错误 | 尝试转换为语义化版本 |
191
+ | 缩进不一致 | 自动格式化 YAML |
192
+
193
+ ---
194
+
195
+ ## 注意事项
196
+
197
+ 1. **性能考虑**:
198
+ - 大文件分块解析
199
+ - 并行处理多个文件
200
+
201
+ 2. **兼容性**:
202
+ - 支持不同版本的配置格式
203
+ - 向后兼容旧版本字段
204
+
205
+ 3. **扩展性**:
206
+ - 支持自定义校验规则
207
+ - 支持插件扩展
@@ -0,0 +1,234 @@
1
+ # 环境知识生成器
2
+
3
+ ## 功能
4
+
5
+ 根据检测到的中间件/组件,生成完整的环境知识配置。包括连接配置模板、最佳实践建议、反模式警告。
6
+
7
+ ## 触发条件
8
+
9
+ - 检测到新的中间件或组件
10
+ - 需要生成环境知识配置
11
+ - 用户请求添加组件知识
12
+
13
+ ## 输入
14
+
15
+ ```json
16
+ {
17
+ "middleware": {
18
+ "name": "mysql",
19
+ "type": "relational-database",
20
+ "detectedFrom": "依赖检测",
21
+ "usagePatterns": ["检测到的使用模式"]
22
+ },
23
+ "projectContext": {
24
+ "language": "python",
25
+ "framework": "FastAPI",
26
+ "existingKnowledge": "已有的环境知识"
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## 输出
32
+
33
+ ```yaml
34
+ # 环境知识 YAML
35
+ middleware:
36
+ mysql:
37
+ type: relational-database
38
+ description: MySQL 数据库
39
+ connection:
40
+ host: ${MYSQL_HOST}
41
+ port: ${MYSQL_PORT:-3306}
42
+ database: ${MYSQL_DATABASE}
43
+ user: ${MYSQL_USER}
44
+ password: ${MYSQL_PASSWORD}
45
+ codeExamples:
46
+ python: |
47
+ import pymysql
48
+ connection = pymysql.connect(
49
+ host='${MYSQL_HOST}',
50
+ port=3306,
51
+ database='${MYSQL_DATABASE}',
52
+ user='${MYSQL_USER}',
53
+ password='${MYSQL_PASSWORD}'
54
+ )
55
+ bestPractices:
56
+ - 使用连接池管理连接
57
+ - 敏感信息使用环境变量
58
+ - 定期备份
59
+ antiPatterns:
60
+ - 不要在代码中硬编码密码
61
+ - 不要使用 root 用户连接
62
+ envVariables:
63
+ - name: MYSQL_HOST
64
+ required: true
65
+ description: MySQL 服务器地址
66
+ - name: MYSQL_PORT
67
+ required: false
68
+ default: "3306"
69
+ description: MySQL 端口
70
+ ```
71
+
72
+ ## 执行步骤
73
+
74
+ 1. **分析中间件类型**
75
+ - 根据名称和依赖推断类型
76
+ - 确定连接配置模板
77
+
78
+ 2. **生成连接配置**
79
+ - 根据中间件类型选择模板
80
+ - 使用环境变量占位符
81
+
82
+ 3. **生成代码示例**
83
+ - 根据项目语言选择示例
84
+ - 包含最佳实践代码
85
+
86
+ 4. **添加最佳实践**
87
+ - 从知识库检索相关实践
88
+ - 结合项目上下文调整
89
+
90
+ 5. **添加反模式警告**
91
+ - 常见错误模式
92
+ - 安全注意事项
93
+
94
+ ## 中间件类型模板
95
+
96
+ ### relational-database (MySQL, PostgreSQL, etc.)
97
+
98
+ ```yaml
99
+ connection:
100
+ host: ${NAME_HOST}
101
+ port: ${NAME_PORT:-3306}
102
+ database: ${NAME_DATABASE}
103
+ user: ${NAME_USER}
104
+ password: ${NAME_PASSWORD}
105
+ ```
106
+
107
+ ### cache (Redis, Memcached, etc.)
108
+
109
+ ```yaml
110
+ connection:
111
+ host: ${NAME_HOST}
112
+ port: ${NAME_PORT:-6379}
113
+ password: ${NAME_PASSWORD}
114
+ db: ${NAME_DB:-0}
115
+ ```
116
+
117
+ ### queue (Kafka, RabbitMQ, etc.)
118
+
119
+ ```yaml
120
+ connection:
121
+ brokers: ${NAME_BROKERS}
122
+ topic: ${NAME_TOPIC}
123
+ groupId: ${NAME_GROUP_ID}
124
+ ```
125
+
126
+ ### vector-store (ChromaDB, Pinecone, etc.)
127
+
128
+ ```yaml
129
+ connection:
130
+ host: ${NAME_HOST}
131
+ port: ${NAME_PORT}
132
+ apiKey: ${NAME_API_KEY}
133
+ collection: ${NAME_COLLECTION}
134
+ ```
135
+
136
+ ## 最佳实践模板
137
+
138
+ ### 数据库
139
+
140
+ - 使用连接池
141
+ - 配置合理的超时
142
+ - 启用 SSL 连接
143
+ - 定期备份
144
+
145
+ ### 缓存
146
+
147
+ - 设置合理的过期时间
148
+ - 使用序列化
149
+ - 监控命中率
150
+
151
+ ### 消息队列
152
+
153
+ - 配置重试策略
154
+ - 处理死信队列
155
+ - 监控积压
156
+
157
+ ### 向量存储
158
+
159
+ - 选择合适的索引类型
160
+ - 配置合理的 chunk 大小
161
+ - 监控查询延迟
162
+
163
+ ## 反模式模板
164
+
165
+ ### 通用
166
+
167
+ - 硬编码敏感信息
168
+ - 使用默认凭据
169
+ - 忽略错误处理
170
+
171
+ ### 数据库
172
+
173
+ - N+1 查询
174
+ - 缺少索引
175
+ - 大事务
176
+
177
+ ### 缓存
178
+
179
+ - 缓存穿透
180
+ - 缓存雪崩
181
+ - 热点 Key
182
+
183
+ ## 示例
184
+
185
+ ### 输入
186
+
187
+ ```json
188
+ {
189
+ "middleware": {
190
+ "name": "redis",
191
+ "type": "cache"
192
+ },
193
+ "projectContext": {
194
+ "language": "python",
195
+ "framework": "FastAPI"
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### 输出
201
+
202
+ ```yaml
203
+ middleware:
204
+ redis:
205
+ type: cache
206
+ description: Redis 缓存
207
+ connection:
208
+ host: ${REDIS_HOST}
209
+ port: ${REDIS_PORT:-6379}
210
+ password: ${REDIS_PASSWORD}
211
+ db: ${REDIS_DB:-0}
212
+ codeExamples:
213
+ python: |
214
+ import redis
215
+ client = redis.Redis(
216
+ host='${REDIS_HOST}',
217
+ port=6379,
218
+ password='${REDIS_PASSWORD}',
219
+ db=0
220
+ )
221
+ bestPractices:
222
+ - 使用连接池
223
+ - 设置合理的过期时间
224
+ - 使用序列化存储对象
225
+ antiPatterns:
226
+ - 不要存储大对象
227
+ - 不要使用 KEYS 命令
228
+ - 不要忽略缓存失效
229
+ envVariables:
230
+ - name: REDIS_HOST
231
+ required: true
232
+ - name: REDIS_PASSWORD
233
+ required: false
234
+ ```
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: methodology-extractor
3
+ description: 当全流程完成或practice-log积累到5条以上、需要从实践中识别和提取可复用的方法论时触发
4
+ type: produce
5
+ ---
6
+
7
+ ## 定位
8
+ 让方法论从实践中自然生长,而非空想。识别实践中的有效模式和认知,沉淀为可复用的原则和方法论。
9
+
10
+ > 与skill-distiller的区别:distiller提取**可执行的skill**,extractor提取**认知性的方法论**(原则、检查项、决策树)。
11
+
12
+ ## 输入
13
+ - 必须输入:practice-log中状态为"待处理"的条目
14
+ - 可选输入:流程执行记录、人工复盘的讨论内容
15
+
16
+ ## 输出
17
+ - 更新后的methodology文件(principles.md / checklists/ / decision-trees/ / design-philosophy.md)
18
+ - 提取报告(从什么实践提取、更新了哪个文档、新增还是修改)
19
+ - **证据清单**(支撑提取决策的practice-log引用)
20
+
21
+ ## 执行步骤
22
+ 1. 扫描practice-log中"待处理"的条目
23
+ 2. 分析本次实践:哪些做法有效、哪些踩坑
24
+ - 预期产出:有效做法列表 + 踩坑列表
25
+ 3. 与已有methodology对比:是新发现还是已有原则的验证
26
+ - 如果是已有原则的验证 → 增加验证案例引用
27
+ - 如果与已有原则冲突 → 标记待讨论,**不自动覆盖**
28
+ 4. 判断是否可泛化:
29
+ - 只对当前项目有效 → 留在practice-log,标记"仅作案例保留"
30
+ - 普遍适用 → 提取为方法论
31
+ 5. 确定更新目标:
32
+ - 新原则 → 更新 methodology/principles.md
33
+ - 新检查项 → 更新对应 methodology/checklists/
34
+ - 新决策模式 → 创建或更新 methodology/decision-trees/
35
+ - 设计哲学层面的发现 → 更新 methodology/design-philosophy.md
36
+ 6. 执行更新(追加或修改,不删除已有内容除非明确过时)
37
+ 7. 更新practice-log对应条目状态为"已处理"
38
+ 8. **整理证据清单**
39
+
40
+ ## 反模式清单(DP7)
41
+ 1. **空想方法论**:没有实践支撑的方法论。检测:每条方法论必须引用至少1条practice-log
42
+ 2. **过度泛化**:把项目特有的经验强行泛化。检测:判断是否在2+项目中有效
43
+ 3. **自动覆盖冲突**:新发现与已有原则冲突时自动覆盖。检测:冲突必须标记待讨论
44
+ 4. **区分不清**:把可执行的skill混入方法论。检测:方法论是"认知性的",skill是"可执行的"
45
+ 5. **忽略失败案例**:只提取成功经验。检测:踩坑教训同样有提取价值
46
+
47
+ ## 适用场景与边界
48
+ - 适用:全流程完成后的自动扫描、practice-log积累到5条以上时、老板要求复盘时
49
+ - 不适用:提取的是可执行skill(用skill-distiller)、与已有methodology冲突需人工裁决的
50
+
51
+ ## 示例
52
+ **实践**:连续3个项目在设计阶段都因为"没考虑缓存策略"被打回
53
+ **分析**:这是一个普遍适用的设计检查项,不是项目特有的
54
+ **提取**:在 methodology/checklists/design.md 中新增检查项:"缓存策略是否已考虑(适用于有数据读取的场景)"
55
+ **证据**:practice-log #5, #8, #11