@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,223 @@
1
+ ---
2
+ description: 查看和管理环境知识模板
3
+ ---
4
+
5
+ # AutoSpec Env Template — 模板管理
6
+
7
+ ## 用户输入
8
+
9
+ ```
10
+ $ARGUMENTS
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 执行指令
16
+
17
+ ### 无参数:显示模板列表
18
+
19
+ **【强制】** 读取模板注册表,显示可用模板:
20
+
21
+ ```
22
+ 📋 环境知识模板列表
23
+
24
+ 名称 来源文件 输出位置
25
+ ---- ---- ----
26
+ middleware middleware-knowledge.md env-knowledge/middleware/{name}.md
27
+ component component-knowledge.md component-lib/components/{name}/component.md
28
+ infrastructure middleware-knowledge.md env-knowledge/infrastructure/{name}.md
29
+
30
+ 使用 /autospec:env-template --show <name> 查看模板详情
31
+ ```
32
+
33
+ ### 参数 --show <name>:显示模板详情
34
+
35
+ **【强制】** 读取并展示指定模板的详细信息:
36
+
37
+ ```
38
+ 📋 模板详情: middleware
39
+
40
+ 来源: knowledge/environment/middleware-knowledge.md
41
+ 输出: .autospec/environment/env-knowledge/middleware/{name}.md
42
+
43
+ 必填章节:
44
+ - 基本信息
45
+ - 环境变量
46
+ - 连接代码模板
47
+
48
+ 可选章节:
49
+ - 最佳实践
50
+ - 反模式清单
51
+ - 健康检查
52
+
53
+ 类型枚举:
54
+ - relational-database: 关系型数据库
55
+ - document-database: 文档数据库
56
+ - cache: 缓存
57
+ - message-queue: 消息队列
58
+ - search-engine: 搜索引擎
59
+ - vector-store: 向量存储
60
+ - object-storage: 对象存储
61
+
62
+ 示例:
63
+ 查看 middleware-knowledge.md 中的 MySQL 示例
64
+ ```
65
+
66
+ ### 参数 --validate:校验知识文件模板合规
67
+
68
+ **【强制】** 校验现有知识文件是否符合模板规范:
69
+
70
+ ```
71
+ 🔍 校验知识文件模板合规
72
+
73
+ 模板加载:
74
+ ✅ template-registry.md
75
+ ✅ middleware-knowledge.md
76
+ ✅ component-knowledge.md
77
+
78
+ 中间件知识:
79
+ ✅ mysql.md
80
+ - 必填章节完整
81
+ - 类型有效: relational-database
82
+ - 环境变量表格完整
83
+ ✅ redis.md
84
+ - 必填章节完整
85
+ - 类型有效: cache
86
+ ⚠️ kafka.md
87
+ - 缺少可选章节: 连接代码模板
88
+ - 类型有效: message-queue
89
+
90
+ 组件知识:
91
+ ✅ auth/component.md
92
+ - 必填章节完整
93
+ - 类型有效: service-component
94
+ ✅ payment/component.md
95
+ - 必填章节完整
96
+ - 类型有效: service-component
97
+
98
+ 总计: 5 文件, 4 完全合规, 1 有警告
99
+ ```
100
+
101
+ ### 参数 --sync:同步模板注册表
102
+
103
+ **【强制】** 将框架模板同步到本地:
104
+
105
+ ```
106
+ 🔄 同步模板注册表
107
+
108
+ 复制: knowledge/environment/template-registry.md
109
+ → .autospec/environment/template-registry.md
110
+
111
+ 缓存模板:
112
+ - middleware-knowledge.md
113
+ - component-knowledge.md
114
+ - detection-patterns.yaml
115
+
116
+ ✅ 同步完成
117
+ ```
118
+
119
+ ### 参数 --example <name>:显示模板示例
120
+
121
+ **【强制】** 显示指定模板的完整示例:
122
+
123
+ ```
124
+ 📝 模板示例: middleware (MySQL)
125
+
126
+ # MySQL 中间件知识
127
+
128
+ ## 基本信息
129
+
130
+ | 字段 | 值 |
131
+ |------|-----|
132
+ | 名称 | mysql |
133
+ | 类型 | relational-database |
134
+ | 默认端口 | 3306 |
135
+ | 知识版本 | v1.0 |
136
+
137
+ ## 环境变量
138
+
139
+ ### 必需变量
140
+
141
+ | 变量名 | 说明 | 示例 |
142
+ |--------|------|------|
143
+ | MYSQL_HOST | 数据库主机地址 | db.example.com |
144
+ | MYSQL_DATABASE | 数据库名称 | myapp_db |
145
+ | MYSQL_USER | 用户名 | app_user |
146
+ | MYSQL_PASSWORD | 密码 | - |
147
+
148
+ ### 可选变量
149
+
150
+ | 变量名 | 默认值 | 说明 |
151
+ |--------|--------|------|
152
+ | MYSQL_PORT | 3306 | 数据库端口 |
153
+ | MYSQL_POOL_SIZE | 10 | 连接池大小 |
154
+
155
+ ## 连接代码模板
156
+
157
+ ### Node.js
158
+
159
+ ```javascript
160
+ const mysql = require('mysql2/promise');
161
+ const pool = mysql.createPool({
162
+ host: process.env.MYSQL_HOST,
163
+ port: process.env.MYSQL_PORT || 3306,
164
+ database: process.env.MYSQL_DATABASE,
165
+ user: process.env.MYSQL_USER,
166
+ password: process.env.MYSQL_PASSWORD,
167
+ });
168
+ ```
169
+
170
+ ### Python
171
+
172
+ ```python
173
+ import pymysql
174
+ pool = pymysql.connect(
175
+ host=os.environ['MYSQL_HOST'],
176
+ port=int(os.environ.get('MYSQL_PORT', 3306)),
177
+ database=os.environ['MYSQL_DATABASE'],
178
+ user=os.environ['MYSQL_USER'],
179
+ password=os.environ['MYSQL_PASSWORD'],
180
+ )
181
+ ```
182
+
183
+ ## 最佳实践
184
+
185
+ 1. 使用连接池,不要在每次请求时创建新连接
186
+ 2. 设置合理的超时时间,避免连接泄漏
187
+ 3. 敏感信息使用环境变量,不要硬编码
188
+
189
+ ## 反模式清单
190
+
191
+ | 反模式 | 风险 | 替代方案 |
192
+ |--------|------|----------|
193
+ | 直接拼接SQL字符串 | SQL注入风险 | 使用参数化查询 |
194
+ | 在代码中硬编码密码 | 安全风险 | 使用环境变量 |
195
+
196
+ ## 健康检查
197
+
198
+ ```bash
199
+ mysqladmin ping -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASSWORD}
200
+ ```
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 产出物
206
+
207
+ - 模板列表展示
208
+ - 模板详情展示
209
+ - 模板合规校验报告
210
+ - 同步后的模板缓存
211
+ - 模板示例展示
212
+
213
+ ---
214
+
215
+ ## 参数说明
216
+
217
+ | 参数 | 说明 |
218
+ |------|------|
219
+ | 无参数 | 显示模板列表 |
220
+ | `--show <name>` | 显示指定模板详情 |
221
+ | `--validate` | 校验知识文件模板合规 |
222
+ | `--sync` | 同步模板注册表到本地 |
223
+ | `--example <name>` | 显示模板示例 |
@@ -0,0 +1,264 @@
1
+ ---
2
+ description: 将本地环境知识变更提交到知识源(Git/在线文档平台/本地文件)
3
+ ---
4
+
5
+ # AutoSpec Env Update — 知识更新提交
6
+
7
+ ## 用户输入
8
+
9
+ ```
10
+ $ARGUMENTS
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 用法
16
+
17
+ ```
18
+ /autospec:env-update [options]
19
+ ```
20
+
21
+ ### Options
22
+
23
+ | 参数 | 说明 |
24
+ |------|------|
25
+ | `--dry-run` | 仅预览变更,不执行提交 |
26
+ | `--source <id>` | 指定更新的知识源(默认:全部) |
27
+ | `--push` | 同时推送到远程(git/在线文档) |
28
+ | `--message <msg>` | 提交消息 |
29
+ | `--force` | 跳过确认(危险操作仍需确认) |
30
+
31
+ ---
32
+
33
+ ## 前置检查
34
+
35
+ **【强制】** 读取知识来源配置:
36
+
37
+ 1. 读取 `.autospec/environment/knowledge-source.json`
38
+ 2. 如不存在,提示用户先执行 `/autospec:env-sync` 导入知识库
39
+ 3. 解析配置的知识源列表
40
+
41
+ ---
42
+
43
+ ## 执行指令
44
+
45
+ ### Step 1: 检测变更
46
+
47
+ 对比本地知识与知识源:
48
+
49
+ 1. **遍历知识源配置**
50
+ - Git 源:对比 commit hash
51
+ - 在线文档源:对比文档更新时间
52
+ - 本地源:对比文件 hash
53
+
54
+ 2. **识别变更类型**
55
+ - 新增:本地有,源中无
56
+ - 修改:内容不一致
57
+ - 删除:本地无,源中有
58
+
59
+ 3. **生成变更列表**
60
+
61
+ ### Step 2: 分类变更
62
+
63
+ **自动变更(无需确认)**:
64
+ - 新增知识文件
65
+ - 非核心知识修改(测试用例、最佳实践等)
66
+
67
+ **需确认变更(重要操作)**:
68
+ - 架构设计文档修改
69
+ - 数据库设计(表结构、索引)修改
70
+ - 接口契约修改
71
+ - 规范文档修改
72
+ - 指南文档修改
73
+
74
+ **危险变更(强制确认)**:
75
+ - 删除操作
76
+
77
+ ### Step 3: 生成变更报告
78
+
79
+ 展示变更详情:
80
+
81
+ ```
82
+ 📝 变更报告
83
+
84
+ 知识源: org-design-templates (Git)
85
+ ================================
86
+
87
+ 自动变更:
88
+ + design-knowledge/product/order-system.md (新增)
89
+ ~ test-knowledge/test-designs/order-test.md (修改)
90
+
91
+ 需确认变更:
92
+ ⚠️ design-knowledge/architecture/order-service.md (修改)
93
+ - 新增订单取消接口
94
+ - 修改订单状态流转图
95
+ ⚠️ design-knowledge/database/order-db.md (修改)
96
+ - 新增 order_cancel_log 表
97
+ - 修改 order 表索引
98
+
99
+ 危险变更:
100
+ ❌ business-knowledge/rules.md (删除规则 BR-05)
101
+
102
+ 知识源: org-docs (在线文档)
103
+ ================================
104
+ ~ standards/coding-style.md (修改)
105
+
106
+ 总计: 6 项变更, 2 项需确认, 1 项危险操作
107
+ ```
108
+
109
+ ### Step 4: 确认变更
110
+
111
+ **自动变更**:直接执行
112
+
113
+ **需确认变更**:
114
+ ```
115
+ ⚠️ 以下变更需要确认:
116
+
117
+ 1. design-knowledge/architecture/order-service.md
118
+ 是否提交?[Y/n]
119
+
120
+ 2. design-knowledge/database/order-db.md
121
+ 是否提交?[Y/n]
122
+ ```
123
+
124
+ **危险变更**:
125
+ ```
126
+ ❌ 危险操作,必须确认:
127
+
128
+ 1. 删除 business-knowledge/rules.md 中的 BR-05
129
+ 此操作不可逆,是否继续?[y/N]
130
+ ```
131
+
132
+ ### Step 5: 执行更新
133
+
134
+ 根据知识源类型执行更新:
135
+
136
+ #### Git 源
137
+
138
+ ```bash
139
+ # 克隆临时目录
140
+ git clone --depth 1 {url} /tmp/autospec-update-{id}
141
+
142
+ # 复制变更文件
143
+ cp -r .autospec/environment/{path}/* /tmp/autospec-update-{id}/{target}/
144
+
145
+ # 提交变更
146
+ cd /tmp/autospec-update-{id}
147
+ git add .
148
+ git commit -m "{message}
149
+
150
+ Co-Authored-By: AutoSpec <autospec@autospec.dev>"
151
+ git push origin {branch}
152
+
153
+ # 记录 commit hash
154
+ ```
155
+
156
+ #### 在线文档源
157
+
158
+ ```bash
159
+ # 使用在线文档 MCP 工具更新文档
160
+ # skylark_doc_update
161
+ ```
162
+
163
+ #### 本地源
164
+
165
+ ```bash
166
+ # 直接复制文件
167
+ cp -r .autospec/environment/{path}/* {target}/
168
+ ```
169
+
170
+ ### Step 6: 更新 knowledge-source.json
171
+
172
+ 更新同步时间和版本信息:
173
+
174
+ ```json
175
+ {
176
+ "sources": [
177
+ {
178
+ "id": "org-design-templates",
179
+ "lastSync": "2026-03-26T12:00:00Z",
180
+ "commitHash": "def456"
181
+ }
182
+ ]
183
+ }
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 产出物
189
+
190
+ - 更新后的知识源文件
191
+ - 更新的 `knowledge-source.json`
192
+ - 变更报告 `.autospec/runtime/env-update-report.json`
193
+
194
+ ---
195
+
196
+ ## 输出结果
197
+
198
+ ```
199
+ ✅ 知识更新提交完成
200
+
201
+ 知识源: org-design-templates
202
+ 推送: git@github.com:org/design-templates.git
203
+ 分支: main
204
+ 提交: def456
205
+
206
+ 变更统计:
207
+ 新增: 2 文件
208
+ 修改: 3 文件
209
+ 删除: 1 文件
210
+
211
+ 知识源: org-yuque-docs
212
+ 更新: standards/coding-style.md (doc_id: 12345)
213
+
214
+ 下一步:
215
+ 1. 检查远程仓库确认变更
216
+ 2. 通知团队成员拉取最新知识
217
+ ```
218
+
219
+ ---
220
+
221
+ ## 错误处理
222
+
223
+ ### 推送失败
224
+
225
+ ```
226
+ ❌ Git 推送失败
227
+
228
+ 原因: 远程有新的提交
229
+ 解决:
230
+ 1. 先拉取远程变更: git pull
231
+ 2. 解决冲突后重新执行: /autospec:env-update --push
232
+ ```
233
+
234
+ ### 权限不足
235
+
236
+ ```
237
+ ❌ 权限不足
238
+
239
+ 原因: 无写入权限
240
+ 解决:
241
+ 1. 检查 Git SSH Key 配置
242
+ 2. 检查在线文档 API Token 权限
243
+ ```
244
+
245
+ ### 冲突处理
246
+
247
+ ```
248
+ ⚠️ 检测到冲突
249
+
250
+ 文件: design-knowledge/architecture/order-service.md
251
+ 本地版本: 新增订单取消接口
252
+ 远程版本: 新增订单退款接口
253
+
254
+ 选择处理方式:
255
+ 1. 保留本地版本
256
+ 2. 保留远程版本
257
+ 3. 手动合并
258
+ ```
259
+
260
+ ---
261
+
262
+ **维护者**: AutoSpec 团队
263
+ **进化分区**: 受控区
264
+ **关联文档**: `knowledge/environment/README.md`, `plugins/commands/autospec:env-sync.md`
@@ -0,0 +1,176 @@
1
+ ---
2
+ description: 验证环境知识配置的完整性和有效性
3
+ ---
4
+
5
+ # AutoSpec Env Validate — 配置校验
6
+
7
+ ## 用户输入
8
+
9
+ ```
10
+ $ARGUMENTS
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 执行指令
16
+
17
+ ### Step 1: 加载模板规范
18
+
19
+ **【强制】** 读取模板注册表和模板文件:
20
+
21
+ 1. **读取模板注册表**
22
+ - 读取 `knowledge/environment/template-registry.md`
23
+ - 获取模板清单、类型枚举、必填章节定义
24
+
25
+ 2. **加载模板文件**
26
+ - 中间件模板:`knowledge/environment/middleware-knowledge.md`
27
+ - 组件模板:`knowledge/environment/component-knowledge.md`
28
+
29
+ ### Step 2: 扫描知识文件
30
+
31
+ 扫描 `.autospec/environment/` 下所有 Markdown 文件:
32
+
33
+ - `env-knowledge/middleware/*.md`
34
+ - `env-knowledge/infrastructure/*.md`
35
+ - `component-lib/components/*/component.md`
36
+
37
+ ### Step 3: 执行校验
38
+
39
+ **【强制】** 对每个文件执行以下校验:
40
+
41
+ #### 3.1 基础校验
42
+
43
+ - Markdown 格式校验
44
+ - 章节标题格式检查
45
+ - 表格格式检查
46
+
47
+ #### 3.2 模板规范校验
48
+
49
+ **中间件文件校验**(参考 middleware-knowledge.md):
50
+
51
+ | 检查项 | 说明 |
52
+ |--------|------|
53
+ | 章节完整性 | 必须包含:基本信息、环境变量、连接代码模板 |
54
+ | 基本信息表格 | 必须包含:名称、类型 |
55
+ | 类型枚举 | 类型必须在预定义枚举中 |
56
+ | 环境变量表格 | 必须包含变量名、说明列 |
57
+
58
+ **组件文件校验**(参考 component-knowledge.md):
59
+
60
+ | 检查项 | 说明 |
61
+ |--------|------|
62
+ | 章节完整性 | 必须包含:基本信息、接口定义、使用示例 |
63
+ | 基本信息表格 | 必须包含:名称、类型、版本 |
64
+ | 类型枚举 | 类型必须在预定义枚举中 |
65
+ | 接口定义 | 必须包含方法名和说明 |
66
+
67
+ #### 3.3 跨文件一致性校验
68
+
69
+ - 环境变量引用一致性
70
+ - 组件依赖完整性
71
+ - 最佳实践引用有效性
72
+
73
+ ### Step 4: 输出结果
74
+
75
+ ```
76
+ 🔍 验证环境知识配置...
77
+
78
+ 模板加载:
79
+ ✅ template-registry.md
80
+ ✅ middleware-knowledge.md
81
+ ✅ component-knowledge.md
82
+
83
+ 总计: {total} 个文件
84
+ 通过: {passed} ✅
85
+ 失败: {failed} ❌
86
+ 警告: {warnings} ⚠️
87
+
88
+ 详细结果:
89
+
90
+ 中间件知识:
91
+ ✅ env-knowledge/middleware/mysql.md
92
+ - 章节完整
93
+ - 类型有效: relational-database
94
+ ✅ env-knowledge/middleware/redis.md
95
+ - 章节完整
96
+ - 类型有效: cache
97
+ ❌ env-knowledge/middleware/kafka.md
98
+ - 缺少必填章节「连接代码模板」
99
+ - 类型无效: queue (应为 message-queue)
100
+
101
+ 组件知识:
102
+ ✅ component-lib/components/auth/component.md
103
+ - 章节完整
104
+ - 类型有效: service-component
105
+ ⚠️ component-lib/components/axios/component.md
106
+ - 缺少可选章节「使用检查清单」
107
+ - 缺少可选章节「最佳实践」
108
+ ```
109
+
110
+ ### Step 5: AI 修复建议(可选)
111
+
112
+ 对校验失败的项目,提供修复建议:
113
+
114
+ 1. **分析错误原因**
115
+ - 章节缺失原因
116
+ - 类型不匹配原因
117
+
118
+ 2. **提供具体修复方案**
119
+ - 补全缺失章节
120
+ - 修正类型值
121
+
122
+ 3. **执行修复**
123
+ - 如用户确认,AI 执行修复
124
+
125
+ ---
126
+
127
+ ## 校验规则参考
128
+
129
+ ### 错误级别(必须修复)
130
+
131
+ | 错误码 | 说明 |
132
+ |--------|------|
133
+ | MISSING_REQUIRED_SECTION | 缺少必填章节 |
134
+ | MISSING_REQUIRED_FIELD | 缺少必填字段 |
135
+ | INVALID_TYPE | 类型不在预定义枚举中 |
136
+ | INVALID_TABLE_FORMAT | 表格格式错误 |
137
+
138
+ ### 警告级别(建议修复)
139
+
140
+ | 警告码 | 说明 |
141
+ |--------|------|
142
+ | MISSING_OPTIONAL_SECTION | 缺少可选章节 |
143
+ | MISSING_OPTIONAL_FIELD | 缺少可选字段 |
144
+ | EMPTY_TABLE | 表格为空 |
145
+ | INCONSISTENT_NAMING | 命名不一致 |
146
+
147
+ ---
148
+
149
+ ## 产出物
150
+
151
+ - 校验报告
152
+ - 修复建议(如有错误)
153
+ - 修复后的文件(如用户确认)
154
+
155
+ ---
156
+
157
+ ## 输出结果示例
158
+
159
+ ```
160
+ ✅ 环境知识校验完成
161
+
162
+ 校验统计:
163
+ 中间件: 5 文件
164
+ ✅ 合规: 4
165
+ ❌ 不合规: 1
166
+ 组件: 3 文件
167
+ ✅ 合规: 2
168
+ ⚠️ 有警告: 1
169
+
170
+ 修复建议:
171
+ kafka.md:
172
+ 1. 添加「连接代码模板」章节
173
+ 2. 修改类型: queue → message-queue
174
+
175
+ 是否执行修复?[Y/n]
176
+ ```