source-kb 0.2.2__py3-none-any.whl

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 (228) hide show
  1. cli/__init__.py +50 -0
  2. cli/__main__.py +5 -0
  3. cli/commands/__init__.py +1 -0
  4. cli/commands/anchor_fix.py +47 -0
  5. cli/commands/diff_doc.py +52 -0
  6. cli/commands/dispatch.py +77 -0
  7. cli/commands/extract.py +72 -0
  8. cli/commands/file_list.py +74 -0
  9. cli/commands/index.py +84 -0
  10. cli/commands/lock.py +89 -0
  11. cli/commands/merge.py +60 -0
  12. cli/commands/merge_delta.py +19 -0
  13. cli/commands/metadata.py +24 -0
  14. cli/commands/pipeline.py +45 -0
  15. cli/commands/post_merge.py +43 -0
  16. cli/commands/query.py +52 -0
  17. cli/commands/render.py +101 -0
  18. cli/commands/scan_repos.py +46 -0
  19. cli/commands/setup.py +94 -0
  20. cli/commands/split.py +196 -0
  21. cli/commands/stale_files.py +98 -0
  22. cli/commands/validate.py +191 -0
  23. core/__init__.py +32 -0
  24. core/config.py +261 -0
  25. core/docs/__init__.py +7 -0
  26. core/docs/section_updater.py +286 -0
  27. core/docs/shared.py +149 -0
  28. core/git.py +294 -0
  29. core/interfaces.py +249 -0
  30. core/monitor/__init__.py +5 -0
  31. core/monitor/progress.py +83 -0
  32. core/monitor/prompt_store.py +49 -0
  33. core/paths.py +141 -0
  34. core/preset.py +237 -0
  35. core/preset_accessors.py +202 -0
  36. core/preset_classify.py +132 -0
  37. core/preset_hooks.py +129 -0
  38. core/preset_profile.py +89 -0
  39. core/prompt/__init__.py +7 -0
  40. core/prompt/__main__.py +147 -0
  41. core/prompt/content.py +320 -0
  42. core/prompt/context_manager.py +164 -0
  43. core/prompt/renderer.py +236 -0
  44. core/prompt/response_parser.py +274 -0
  45. core/prompt/templates.py +357 -0
  46. core/prompt/validate_parity.py +162 -0
  47. core/prompt/variables.py +339 -0
  48. core/rag/__init__.py +22 -0
  49. core/rag/__main__.py +136 -0
  50. core/rag/bm25_index.py +268 -0
  51. core/rag/chunker.py +273 -0
  52. core/rag/embedder.py +151 -0
  53. core/rag/indexer.py +292 -0
  54. core/rag/loader.py +89 -0
  55. core/rag/retriever.py +82 -0
  56. core/skeleton/__init__.py +11 -0
  57. core/skeleton/__main__.py +934 -0
  58. core/skeleton/anchor_fix.py +250 -0
  59. core/skeleton/classify.py +331 -0
  60. core/skeleton/cmd_anchor_fix.py +43 -0
  61. core/skeleton/cmd_diff_doc.py +44 -0
  62. core/skeleton/cmd_lock.py +87 -0
  63. core/skeleton/cmd_merge_delta.py +41 -0
  64. core/skeleton/community.py +233 -0
  65. core/skeleton/dependency_graph.py +306 -0
  66. core/skeleton/diff_doc.py +248 -0
  67. core/skeleton/dispatch.py +273 -0
  68. core/skeleton/dispatch_render.py +319 -0
  69. core/skeleton/dispatch_source.py +111 -0
  70. core/skeleton/extract.py +218 -0
  71. core/skeleton/extract_methods.py +298 -0
  72. core/skeleton/file_list.py +239 -0
  73. core/skeleton/impact.py +278 -0
  74. core/skeleton/jar_download.py +177 -0
  75. core/skeleton/jar_resolver.py +186 -0
  76. core/skeleton/loader.py +162 -0
  77. core/skeleton/merge.py +278 -0
  78. core/skeleton/merge_delta.py +229 -0
  79. core/skeleton/metadata.py +96 -0
  80. core/skeleton/metadata_builders.py +264 -0
  81. core/skeleton/module_dag.py +330 -0
  82. core/skeleton/parsers/__init__.py +71 -0
  83. core/skeleton/parsers/jqassistant.py +300 -0
  84. core/skeleton/parsers/jqassistant_cypher.py +225 -0
  85. core/skeleton/parsers/regex.py +171 -0
  86. core/skeleton/parsers/treesitter.py +324 -0
  87. core/skeleton/parsers/treesitter_java.py +284 -0
  88. core/skeleton/parsers/treesitter_multi.py +289 -0
  89. core/skeleton/pom_parser.py +299 -0
  90. core/skeleton/post_merge.py +295 -0
  91. core/skeleton/post_merge_llm.py +82 -0
  92. core/skeleton/query.py +195 -0
  93. core/skeleton/shard_context.py +177 -0
  94. core/skeleton/split.py +180 -0
  95. core/skeleton/split_cache.py +107 -0
  96. core/skeleton/split_feedback.py +174 -0
  97. core/skeleton/split_plan.py +219 -0
  98. core/skeleton/split_plan_helpers.py +305 -0
  99. core/skeleton/split_plan_llm.py +274 -0
  100. core/utils.py +135 -0
  101. core/validators/__init__.py +65 -0
  102. core/validators/__main__.py +215 -0
  103. core/validators/consistency.py +203 -0
  104. core/validators/coverage.py +171 -0
  105. core/validators/duplicates.py +76 -0
  106. core/validators/engine.py +224 -0
  107. core/validators/links.py +76 -0
  108. core/validators/sampling.py +169 -0
  109. core/validators/structure.py +144 -0
  110. engine/__init__.py +7 -0
  111. engine/assembler.py +231 -0
  112. engine/confirm.py +65 -0
  113. engine/dedup.py +106 -0
  114. engine/main.py +211 -0
  115. engine/pipeline/__init__.py +163 -0
  116. engine/pipeline/recovery.py +250 -0
  117. engine/pipeline/steps/__init__.py +23 -0
  118. engine/pipeline/steps/audit.py +220 -0
  119. engine/pipeline/steps/audit_apply.py +195 -0
  120. engine/pipeline/steps/audit_helpers.py +155 -0
  121. engine/pipeline/steps/classify_llm.py +236 -0
  122. engine/pipeline/steps/classify_prompt.py +223 -0
  123. engine/pipeline/steps/finalize.py +160 -0
  124. engine/pipeline/steps/generate.py +169 -0
  125. engine/pipeline/steps/generate_batch.py +197 -0
  126. engine/pipeline/steps/generate_recovery.py +170 -0
  127. engine/pipeline/steps/llm_plan_split.py +253 -0
  128. engine/pipeline/steps/lock.py +64 -0
  129. engine/pipeline/steps/preflight.py +237 -0
  130. engine/pipeline/steps/preflight_adjust.py +147 -0
  131. engine/pipeline/steps/pregenerate.py +130 -0
  132. engine/pipeline/steps/quality.py +81 -0
  133. engine/pipeline/steps/skeleton.py +149 -0
  134. engine/pipeline/steps/source.py +163 -0
  135. engine/pipeline/steps/sync.py +117 -0
  136. engine/pipeline/steps/sync_finalize.py +237 -0
  137. engine/pipeline/steps/sync_update.py +341 -0
  138. engine/pipelines.py +91 -0
  139. engine/runner.py +335 -0
  140. engine/strategies/__init__.py +86 -0
  141. engine/strategies/api.py +128 -0
  142. engine/strategies/delegated.py +50 -0
  143. engine/strategies/dryrun.py +25 -0
  144. engine/two_phase.py +143 -0
  145. mcp_server/__init__.py +73 -0
  146. mcp_server/__main__.py +5 -0
  147. mcp_server/tools/__init__.py +1 -0
  148. mcp_server/tools/config.py +63 -0
  149. mcp_server/tools/discovery.py +276 -0
  150. mcp_server/tools/generation.py +184 -0
  151. mcp_server/tools/planning.py +144 -0
  152. mcp_server/tools/source.py +175 -0
  153. mcp_server/tools/validation.py +140 -0
  154. mcp_server/tools/workflow.py +166 -0
  155. mcp_server/workflow_loader.py +204 -0
  156. presets/generic/audit_dimensions.md +132 -0
  157. presets/generic/doc_types.yaml +152 -0
  158. presets/generic/preset.yaml +115 -0
  159. presets/java-spring/audit_dimensions.md +228 -0
  160. presets/java-spring/audit_dimensions.yaml +203 -0
  161. presets/java-spring/doc_types.yaml +269 -0
  162. presets/java-spring/hooks.py +122 -0
  163. presets/java-spring/preset.yaml +341 -0
  164. presets/java-spring/templates/README.md +34 -0
  165. presets/java-spring/templates/audit-system.md +15 -0
  166. presets/java-spring/templates/subagent-aop.md +105 -0
  167. presets/java-spring/templates/subagent-api.md +63 -0
  168. presets/java-spring/templates/subagent-architecture.md +111 -0
  169. presets/java-spring/templates/subagent-async-events.md +107 -0
  170. presets/java-spring/templates/subagent-audit-api-contracts.md +40 -0
  171. presets/java-spring/templates/subagent-audit-architecture.md +38 -0
  172. presets/java-spring/templates/subagent-audit-business.md +40 -0
  173. presets/java-spring/templates/subagent-audit-data-models.md +40 -0
  174. presets/java-spring/templates/subagent-business.md +129 -0
  175. presets/java-spring/templates/subagent-caching.md +75 -0
  176. presets/java-spring/templates/subagent-database-access.md +114 -0
  177. presets/java-spring/templates/subagent-enum.md +75 -0
  178. presets/java-spring/templates/subagent-error-handling.md +91 -0
  179. presets/java-spring/templates/subagent-external-integrations.md +80 -0
  180. presets/java-spring/templates/subagent-index.md +122 -0
  181. presets/java-spring/templates/subagent-messaging.md +97 -0
  182. presets/java-spring/templates/subagent-model.md +88 -0
  183. presets/java-spring/templates/subagent-observability.md +91 -0
  184. presets/java-spring/templates/subagent-scheduled.md +81 -0
  185. presets/java-spring/templates/subagent-security.md +102 -0
  186. presets/java-spring/templates/subagent-structure.md +101 -0
  187. presets/java-spring/templates/subagent-sync-section.md +34 -0
  188. presets/java-spring/templates/subagent-utils.md +73 -0
  189. presets/java-spring/templates/sync-system.md +8 -0
  190. presets/java-spring/workflow-extensions.md +112 -0
  191. skills/__init__.py +1 -0
  192. skills/_shared/README.md +30 -0
  193. skills/_shared/doc-coverage-shared.md +134 -0
  194. skills/_shared/doc-quality-standard.md +1058 -0
  195. skills/_shared/doc-subagent-rules.md +762 -0
  196. skills/_shared/windows-compat.md +89 -0
  197. skills/kb-audit/SKILL.md +52 -0
  198. skills/kb-audit/rules.md +88 -0
  199. skills/kb-audit/steps/step-01-prepare.md +75 -0
  200. skills/kb-audit/steps/step-02-audit.md +96 -0
  201. skills/kb-audit/steps/step-03-verify.md +65 -0
  202. skills/kb-audit/steps/step-04-report.md +64 -0
  203. skills/kb-init/SKILL.md +146 -0
  204. skills/kb-init/rules.md +187 -0
  205. skills/kb-init/steps/step-01-scope.md +62 -0
  206. skills/kb-init/steps/step-02-source.md +410 -0
  207. skills/kb-init/steps/step-03-generate.md +307 -0
  208. skills/kb-init/steps/step-04-quality.md +92 -0
  209. skills/kb-init/steps/step-05-finalize.md +132 -0
  210. skills/kb-init/templates/core/execution-modes.md +29 -0
  211. skills/kb-init/templates/core/output-only.md +4 -0
  212. skills/kb-init/templates/core/readwrite.md +33 -0
  213. skills/kb-search/SKILL.md +138 -0
  214. skills/kb-search/rules.md +64 -0
  215. skills/kb-sync/SKILL.md +43 -0
  216. skills/kb-sync/rules.md +70 -0
  217. skills/kb-sync/scripts/rebuild_module.py +91 -0
  218. skills/kb-sync/scripts/scan_repos.py +687 -0
  219. skills/kb-sync/steps/step-01-detect.md +72 -0
  220. skills/kb-sync/steps/step-02-update.md +71 -0
  221. skills/kb-sync/steps/step-03-verify.md +47 -0
  222. skills/kb-sync/steps/step-04-finalize.md +52 -0
  223. source_kb-0.2.2.dist-info/METADATA +194 -0
  224. source_kb-0.2.2.dist-info/RECORD +228 -0
  225. source_kb-0.2.2.dist-info/WHEEL +5 -0
  226. source_kb-0.2.2.dist-info/entry_points.txt +3 -0
  227. source_kb-0.2.2.dist-info/licenses/LICENSE +21 -0
  228. source_kb-0.2.2.dist-info/top_level.txt +6 -0
@@ -0,0 +1,341 @@
1
+ # Java / Spring Boot Preset
2
+ # 适用于 Spring Boot 微服务项目
3
+
4
+ name: "Java / Spring Boot"
5
+ language: "java"
6
+ file_extensions: [".java"]
7
+ test_patterns: ["/test/", "/tests/"]
8
+ generated_patterns: ["/generated/", "/proto/", "/target/"]
9
+
10
+ # ============================================================
11
+ # 解析器配置
12
+ # backend: auto | jqassistant | treesitter | regex
13
+ # auto(默认):按可用性自动选择 jqassistant → treesitter → regex
14
+ # jqassistant:优先使用 jQAssistant 字节码分析,降级到 treesitter → regex
15
+ # treesitter:强制使用 tree-sitter AST 解析
16
+ # regex:强制使用 preset 自带正则解析器
17
+ # ============================================================
18
+ parser:
19
+ backend: "auto"
20
+ jqassistant:
21
+ store_dir: ".jqassistant/store"
22
+ rules_dir: ".jqassistant/rules"
23
+ classes_dir: null # 自动检测 target/classes 或 build/classes/java/main
24
+
25
+ # ============================================================
26
+ # 构建配置(可选)
27
+ # 启用后,在源码拉取阶段自动执行 Maven 编译,生成 .class 文件供 jQAssistant 使用。
28
+ # 不启用时,jQAssistant 会自动降级到 tree-sitter。
29
+ # ============================================================
30
+ build:
31
+ enabled: false # 设为 true 启用自动构建
32
+ tool: "maven" # 构建工具:maven | gradle
33
+ command: "mvn compile -DskipTests -q" # 构建命令
34
+ timeout: 300 # 超时秒数
35
+ settings_file: null # Maven settings.xml 路径(可选,如 "./settings.xml")
36
+ profiles: [] # 激活的 Maven profiles(可选)
37
+
38
+ # ============================================================
39
+ # 文件分类规则(唯一规则源,所有脚本从此读取)
40
+ # 匹配优先级:class_type > class_annotations > method_annotations > field_types > patterns(兜底)
41
+ # 排除机制:exclude_if 条件满足时跳过该分类
42
+ # 优先级机制:同一 affects 目标下,高 priority 分类排斥低 priority 分类
43
+ #
44
+ # patterns 语法说明:
45
+ # - 以 * 开头的模式(如 "*.yml"):glob 匹配,仅匹配文件名(不含路径)
46
+ # - 其他模式(如 "/service/"):子串包含匹配,匹配完整路径(大小写不敏感)
47
+ # - 示例:
48
+ # "/controller/" → 匹配 com/example/controller/OrderController.java ✓
49
+ # "*.yaml" → 匹配 application.yaml ✓,但不匹配 src/main/resources/application.yaml 的路径部分
50
+ # "/api/" → 匹配 com/example/api/v1/UserApi.java ✓
51
+ # ============================================================
52
+ file_classification:
53
+ enum:
54
+ class_type: "enum"
55
+ affects: ["enums-and-constants.md"]
56
+ controller:
57
+ class_annotations: ["@RestController", "@Controller"]
58
+ method_annotations: ["@RequestMapping", "@GetMapping", "@PostMapping", "@PutMapping", "@DeleteMapping", "@PatchMapping"]
59
+ patterns: ["/controller/", "/api/"]
60
+ affects: ["api-contracts.md", "business-logic.md"]
61
+ service:
62
+ class_annotations: ["@Service"]
63
+ patterns: ["/service/", "/biz/"]
64
+ affects: ["business-logic.md"]
65
+ config:
66
+ class_annotations: ["@Configuration"]
67
+ patterns: ["/config/"]
68
+ affects: ["architecture.md"]
69
+ model:
70
+ class_annotations: ["@Entity", "@Table", "@TableName", "@Data"]
71
+ exclude_if:
72
+ has_annotation: ["@Configuration", "@Service", "@Component", "@Aspect", "@RestController", "@Controller"]
73
+ path_contains: ["/config/", "/service/", "/aspect/", "/interceptor/"]
74
+ patterns: ["/domain/", "/entity/", "/dto/", "/vo/", "/param/", "/bo/", "/req/", "/resp/", "/request/", "/response/", "/model/", "/pojo/"]
75
+ affects: ["data-models.md"]
76
+ mapper:
77
+ class_annotations: ["@Mapper", "@Repository"]
78
+ patterns: ["/dao/", "/mapper/", "/repository/"]
79
+ exclude_if:
80
+ matched_by: ["cache"]
81
+ priority: 5
82
+ affects: ["database-access.md"]
83
+ kafka:
84
+ method_annotations: ["@KafkaListener", "@SendTo"]
85
+ patterns: ["/consumer/", "/producer/", "/listener/", "/mq/"]
86
+ affects: ["messaging.md", "business-logic.md"]
87
+ feign:
88
+ class_annotations: ["@FeignClient"]
89
+ annotation_has_url: false
90
+ url_annotation_name: "@FeignClient"
91
+ affects: ["api-contracts.md"]
92
+ feign-external:
93
+ class_annotations: ["@FeignClient"]
94
+ annotation_has_url: true
95
+ url_annotation_name: "@FeignClient"
96
+ affects: ["external-integrations.md"]
97
+ cache:
98
+ method_annotations: ["@Cacheable", "@CacheEvict", "@CachePut"]
99
+ field_types: ["RedisTemplate", "StringRedisTemplate", "RedissonClient", "ValueOperations", "HashOperations", "ListOperations", "SetOperations", "ZSetOperations", "RedisService", "RedisUtil", "RedisHelper", "CacheService", "CacheUtil", "RLock", "RBucket", "RMap"]
100
+ patterns: ["/redis/", "/cache/"]
101
+ priority: 10
102
+ affects: ["caching.md"]
103
+ scheduled:
104
+ class_annotations: ["@EnableScheduling"]
105
+ method_annotations: ["@Scheduled", "@XxlJob", "@QuartzJob"]
106
+ patterns: ["/job/", "/task/", "/schedule/", "/cron/"]
107
+ affects: ["scheduled-tasks.md"]
108
+ error-handling:
109
+ class_annotations: ["@ControllerAdvice", "@RestControllerAdvice"]
110
+ method_annotations: ["@ExceptionHandler"]
111
+ patterns: ["/exception/", "/error/"]
112
+ affects: ["error-handling.md"]
113
+ security:
114
+ class_annotations: ["@EnableWebSecurity", "@EnableGlobalMethodSecurity", "@EnableMethodSecurity"]
115
+ method_annotations: ["@PreAuthorize", "@Secured", "@RolesAllowed"]
116
+ patterns: ["/security/", "/auth/", "/filter/"]
117
+ affects: ["security.md"]
118
+ async-events:
119
+ method_annotations: ["@Async", "@EventListener", "@TransactionalEventListener"]
120
+ patterns: ["/event/", "/async/"]
121
+ exclude_if:
122
+ matched_by: ["kafka"]
123
+ path_contains: ["/consumer/", "/producer/", "/mq/"]
124
+ affects: ["async-and-events.md", "business-logic.md"]
125
+ aop:
126
+ class_annotations: ["@Aspect"]
127
+ method_annotations: ["@Around", "@Before", "@After", "@AfterReturning", "@AfterThrowing"]
128
+ patterns: ["/aspect/", "/interceptor/", "/aop/"]
129
+ affects: ["aop-and-interceptors.md"]
130
+ observability:
131
+ class_annotations: ["@Endpoint", "@RestControllerEndpoint"]
132
+ method_annotations: ["@Counted", "@Timed", "@Observed"]
133
+ field_types: ["MeterRegistry", "Counter", "Timer", "Gauge", "DistributionSummary"]
134
+ patterns: ["/monitor/", "/metrics/", "/health/", "/actuator/", "/observability/", "/tracing/"]
135
+ affects: ["observability.md"]
136
+ constant:
137
+ patterns: ["/constant/", "/constants/"]
138
+ affects: ["enums-and-constants.md"]
139
+ util:
140
+ patterns: ["/util/", "/utils/", "/helper/", "/helpers/", "/tool/", "/tools/"]
141
+ affects: ["utils.md"]
142
+ resource:
143
+ patterns: ["*.yml", "*.yaml", "*.properties", "*.xml", "pom.xml", "build.gradle"]
144
+ affects: ["architecture.md"]
145
+ structure:
146
+ patterns: ["*.java"]
147
+ affects: ["source-tree-analysis.md", "index.md"]
148
+ trigger: "add-delete-only"
149
+
150
+ # ============================================================
151
+ # 模块类型 → 跳过规则
152
+ # ============================================================
153
+ module_types:
154
+ service:
155
+ skip: []
156
+ api-contract:
157
+ skip: ["business-logic.md"]
158
+ detect_patterns: ["*-api", "*/api/"]
159
+ base-lib:
160
+ skip: ["api-contracts.md"]
161
+ detect_patterns: ["*-base", "*-common", "*-core"]
162
+ frontend:
163
+ skip: ["source-tree-analysis.md", "api-contracts.md"]
164
+ detect_patterns: ["*-web", "*-ui", "*-frontend"]
165
+ demo:
166
+ skip: ["*"]
167
+ detect_patterns: ["*-demo", "*-example", "*-sample", "*-third"]
168
+
169
+ # ============================================================
170
+ # 架构检查源
171
+ # =========================================================
172
+ architecture_sources:
173
+ dependencies: "pom.xml"
174
+ config_files:
175
+ - "src/main/resources/application.yml"
176
+ - "src/main/resources/application.yaml"
177
+ - "src/main/resources/bootstrap.yml"
178
+ - "src/main/resources/bootstrap.yaml"
179
+ annotation_patterns:
180
+ feign: "@FeignClient"
181
+ dubbo: "@DubboReference"
182
+ config: "@Configuration"
183
+ enable: "@Enable"
184
+
185
+ # ============================================================
186
+ # 自检关键注解
187
+ # ============================================================
188
+ key_annotations:
189
+ - "Transactional"
190
+ - "Override"
191
+ - "Async"
192
+ - "Scheduled"
193
+ - "KafkaListener"
194
+ - "XxlJob"
195
+ - "PostConstruct"
196
+ - "PreDestroy"
197
+ - "EventListener"
198
+ - "TransactionalEventListener"
199
+ - "Value"
200
+ - "RefreshScope"
201
+ - "SentinelResource"
202
+ - "Cacheable"
203
+ - "CacheEvict"
204
+ - "Retryable"
205
+ - "CircuitBreaker"
206
+ - "Aspect"
207
+ - "Around"
208
+ - "Before"
209
+ - "After"
210
+
211
+ # ============================================================
212
+ # 方法跳过规则(唯一规则源,coverage_check 等脚本从此读取)
213
+ # ============================================================
214
+ skip_method_names:
215
+ - "toString"
216
+ - "hashCode"
217
+ - "equals"
218
+ - "clone"
219
+ - "finalize"
220
+ - "canEqual"
221
+ - "builder"
222
+ - "of"
223
+ - "values"
224
+ - "valueOf"
225
+
226
+ skip_method_prefixes_no_params:
227
+ - "get"
228
+ - "is"
229
+
230
+ skip_method_prefixes_any:
231
+ - "set"
232
+
233
+ # ============================================================
234
+ # 覆盖率配置
235
+ # ============================================================
236
+ coverage_threshold: 0.8
237
+
238
+ # ============================================================
239
+ # 覆盖率统计排除路径(非业务文件,不计入覆盖率)
240
+ # ============================================================
241
+ coverage_skip_patterns:
242
+ - "/config/"
243
+ - "/util/"
244
+ - "/constant/"
245
+ - "/annotation/"
246
+ - "/exception/"
247
+ - "/test/"
248
+ - "/enums/"
249
+
250
+ # ============================================================
251
+ # 进度监控配置
252
+ # ============================================================
253
+ progress:
254
+ heavy_docs: ["business-logic", "architecture", "data-models"]
255
+ light_timeout_min: 5.0
256
+ heavy_timeout_min: 7.5
257
+ spawn_timeout:
258
+ default: 600 # 10 min,兜底
259
+ source-tree-analysis: 480 # 8 min,模板化程度高
260
+ enums-and-constants: 360 # 6 min,结构简单
261
+ data-models: 600 # 10 min
262
+ api-contracts: 480 # 8 min
263
+ architecture: 720 # 12 min,输入多(config+pom+yaml)
264
+ business-logic: 900 # 15 min,最复杂
265
+ messaging: 600 # 10 min
266
+ caching: 480 # 8 min
267
+ scheduled-tasks: 480 # 8 min
268
+ error-handling: 360 # 6 min,结构清晰
269
+ security: 480 # 8 min
270
+ async-and-events: 480 # 8 min,需追踪事件发布/订阅关系
271
+ aop-and-interceptors: 360 # 6 min,结构清晰
272
+ observability: 480 # 8 min,需扫描指标注解和配置
273
+ database-access: 600 # 10 min,SQL 映射分析
274
+ utils: 360 # 6 min
275
+ index: 360 # 6 min,依赖前序文档但自身简单
276
+
277
+ # ============================================================
278
+ # 文档章节校验规则(validate_output.py 使用)
279
+ # must_have: 必须存在的章节关键词(缺失报 error)
280
+ # should_have: 建议存在的章节关键词(缺失报 warning)
281
+ # 每项可以是字符串或字符串列表(列表表示任一匹配即可)
282
+ # ============================================================
283
+ section_checks:
284
+ "business-logic.md":
285
+ must_have: []
286
+ should_have: [["并发控制", "分布式锁", "锁", "并发"]]
287
+ "architecture.md":
288
+ must_have: [["技术栈", "技术选型", "框架", "技术栈概览"]]
289
+ should_have: [["依赖", "Maven", "pom", "依赖清单", "核心依赖", "技术栈概览"], ["中间件", "Redis", "Kafka", "缓存", "中间件集成"], ["配置", "application", "配置管理", "配置项"]]
290
+ "data-models.md":
291
+ must_have: []
292
+ should_have: []
293
+ "index.md":
294
+ must_have: [["模块概览", "模块概述", "模块简介", "模块索引", "基本信息", "模块定位"]]
295
+ should_have: [["文档导航", "导航", "快速检索"], ["接口总览", "接口概览", "API", "核心业务流程", "业务流程速览"]]
296
+ "source-tree-analysis.md":
297
+ must_have: [["目录结构", "文件树", "源码结构", "文件结构", "包结构", "包结构总览"]]
298
+ should_have: []
299
+ "api-contracts.md":
300
+ must_have: []
301
+ should_have: [["接口汇总", "接口总览", "API 汇总", "API 总览"]]
302
+ "caching.md":
303
+ must_have: [["Key", "Cache", "缓存", "Key Pattern", "Cache Name"]]
304
+ should_have: [["TTL", "过期", "缓存策略"]]
305
+ "messaging.md":
306
+ must_have: [["Topic", "topic", "Queue", "queue"]]
307
+ should_have: [["消费", "Consumer", "生产", "Producer"]]
308
+ "database-access.md":
309
+ must_have: [["Mapper", "Repository", "DAO", "数据访问"]]
310
+ should_have: []
311
+ "scheduled-tasks.md":
312
+ must_have: [["任务列表", "定时任务", "Job 清单"]]
313
+ should_have: [["执行频率", "cron", "调度周期"], ["幂等", "重试", "容错"]]
314
+ "error-handling.md":
315
+ must_have: [["异常层次", "异常体系", "Exception"]]
316
+ should_have: [["错误码", "ErrorCode", "状态码"], ["全局处理", "ControllerAdvice", "统一异常"]]
317
+ "security.md":
318
+ must_have: [["认证", "鉴权", "Authentication"]]
319
+ should_have: [["权限模型", "RBAC", "角色"], ["过滤器", "Filter", "拦截"]]
320
+ "async-and-events.md":
321
+ must_have: [["异步方法", "@Async", "异步处理", "异步"]]
322
+ should_have: [["事件", "Event", "EventListener"], ["线程池", "ThreadPool", "Executor"]]
323
+ "aop-and-interceptors.md":
324
+ must_have: [["切面", "Aspect", "AOP"]]
325
+ should_have: [["切点", "Pointcut", "execution"], ["拦截器", "Interceptor", "HandlerInterceptor"]]
326
+ "external-integrations.md":
327
+ must_have: [["集成", "Feign", "外部", "调用"]]
328
+ should_have: []
329
+ "utils.md":
330
+ must_have: []
331
+ should_have: []
332
+
333
+ # ============================================================
334
+ # Audit configuration
335
+ # ============================================================
336
+ audit:
337
+ scale_thresholds:
338
+ single_agent_kb: 50 # Below this (KB): single-agent strategy
339
+ skeleton_kb: 80 # Below this (KB): single-agent+skeleton; above: multi-agent
340
+ max_tokens: 8192 # Max tokens for audit LLM call
341
+ doc_truncate_chars: 50000 # Truncate doc content beyond this for audit prompt
@@ -0,0 +1,34 @@
1
+ # Java Spring Preset Templates
2
+
3
+ This directory contains sub-agent prompt templates specific to the `java-spring` preset.
4
+
5
+ ## Template naming convention
6
+
7
+ Each template is referenced by the `template` field in `doc_types.yaml`:
8
+
9
+ ```yaml
10
+ doc_types:
11
+ caching:
12
+ template: "subagent-caching.md" # → presets/java-spring/templates/subagent-caching.md
13
+ ```
14
+
15
+ ## Template search order
16
+
17
+ When rendering a prompt, the system searches for templates in this order:
18
+
19
+ 1. `presets/{preset}/templates/{template_name}` — preset-specific (this directory)
20
+ 2. `skill/kb-init/templates/{template_name}` — generic fallback
21
+ 3. `skills/kb-init/templates/{template_name}` — legacy fallback
22
+
23
+ ## Shared components
24
+
25
+ Templates can reference shared execution guidance via the `{execution_guidance}` placeholder,
26
+ which is resolved from:
27
+ - `skill/kb-init/templates/core/readwrite.md` (Agent mode)
28
+ - `skill/kb-init/templates/core/output-only.md` (CLI mode)
29
+
30
+ ## Adding a new doc_type
31
+
32
+ 1. Add entry to `doc_types.yaml` with `template: "subagent-{name}.md"`
33
+ 2. Create `presets/java-spring/templates/subagent-{name}.md`
34
+ 3. No code changes needed — the system discovers templates from config
@@ -0,0 +1,15 @@
1
+ You are a knowledge base quality auditor. Compare document content against the source code skeleton and identify inconsistencies.
2
+
3
+ Output format: JSON array, each element contains:
4
+ - dimension: audit dimension name
5
+ - status: "pass" or "fail"
6
+ - detail: issue description (required when status=fail)
7
+ - fix: suggested fix content (optional)
8
+
9
+ Audit dimensions:
10
+ - completeness: classes/methods/fields in skeleton covered in document
11
+ - accuracy: document descriptions match source code
12
+ - freshness: no outdated content (source deleted/renamed but doc not updated)
13
+ - reference_integrity: cross-document reference links are valid
14
+
15
+ Output JSON only, no other text.
@@ -0,0 +1,105 @@
1
+ # 任务:生成 {module_name} 模块的 aop-and-interceptors.md
2
+
3
+ {module_description}
4
+
5
+ {execution_guidance}
6
+
7
+ ## 你必须遵守的规则(违反任何一条即为失败)
8
+
9
+ 1. **禁止编造** — 切点表达式、执行顺序、拦截路径必须从源码验证
10
+ 2. **切面执行顺序必须明确** — @Order 值或实现 Ordered 接口的 getOrder() 返回值
11
+ 3. **切点表达式必须完整** — execution/annotation/within 的完整表达式,不能只写"拦截 Service 层"
12
+ 4. **拦截器链必须有序** — 每个拦截器的注册顺序、匹配路径、preHandle/postHandle 逻辑
13
+
14
+ ## 输出约束
15
+
16
+ - 信息密度优先,避免冗余
17
+ - 确保中文内容完整无截断
18
+
19
+ ## 输入
20
+
21
+ - 骨架 JSON:`{skeleton_path}`({skeleton_size}KB,{skeleton_read_instruction})
22
+ - 源码缓存:`{source_cache_path}`
23
+ - 输出文件:`{output_path}/aop-and-interceptors.md`
24
+
25
+ ## 需要读取的源码文件
26
+
27
+ 根据以下文件清单读取源码文件进行分析:
28
+
29
+ {file_list}
30
+
31
+ ## 文件读取说明
32
+
33
+ 你需要:
34
+ 1. 逐个读取上述文件清单中的源码文件
35
+ 2. 分析文件内容,提取所需信息
36
+ 3. 基于原始源码生成文档,禁止编造
37
+ 4. 验证所有配置参数和数值
38
+
39
+ ## 内容组织
40
+
41
+ ### 1. 切面总览
42
+
43
+ ```markdown
44
+ | 序号 | 切面类 | @Order | 切面类型 | 职责 | 影响范围 |
45
+ |------|--------|--------|---------|------|---------|
46
+ | 1 | LogAspect | 1 | @Around | 接口日志 | Controller 层 |
47
+ ```
48
+
49
+ ### 2. 逐切面详解(每个切面独立小节)
50
+
51
+ 每个切面必须包含:
52
+
53
+ - **切面类名**:完整类名
54
+ - **执行顺序**:@Order 值(数值越小越先执行)
55
+ - **切面类型**:@Around / @Before / @After / @AfterReturning / @AfterThrowing
56
+ - **切点表达式**:完整 @Pointcut 定义
57
+ ```java
58
+ @Pointcut("execution(* com.example.controller..*.*(..))")
59
+ ```
60
+ - **通知逻辑**:编号步骤,从进入到退出的每一步
61
+ - @Around:proceed 前后分别做什么
62
+ - @Before:前置校验/日志/上下文设置
63
+ - @After:清理/日志
64
+ - @AfterReturning:结果处理/缓存写入
65
+ - @AfterThrowing:异常记录/告警/补偿
66
+ - **注入依赖**:切面中使用的 Service/Repository
67
+ - **性能影响**:是否有耗时操作(远程调用、IO)
68
+ - **条件控制**(如有):开关配置、环境限制
69
+
70
+ ### 3. 拦截器链(HandlerInterceptor)
71
+
72
+ ```markdown
73
+ | 顺序 | 拦截器类 | 匹配路径 | 排除路径 | 职责 |
74
+ |------|---------|---------|---------|------|
75
+ ```
76
+
77
+ 每个拦截器必须包含:
78
+ - **注册方式**:WebMvcConfigurer.addInterceptors 中的注册代码
79
+ - **匹配路径**:addPathPatterns
80
+ - **排除路径**:excludePathPatterns
81
+ - **preHandle 逻辑**:编号步骤 + 返回 true/false 的条件
82
+ - **postHandle 逻辑**(如有)
83
+ - **afterCompletion 逻辑**(如有)
84
+
85
+ ### 4. 切面执行顺序图
86
+
87
+ ASCII 图展示请求经过各切面/拦截器的完整链路:
88
+ ```
89
+ Request → Filter → Interceptor.preHandle → Aspect(@Around-before)
90
+ → Controller → Aspect(@Around-after) → Interceptor.postHandle → Response
91
+ ```
92
+
93
+ ### 5. 自定义注解驱动的切面(如有)
94
+
95
+ - 注解定义(@Target, @Retention)
96
+ - 切面如何匹配该注解
97
+ - 使用示例
98
+
99
+ ## 完成后自检清单
100
+
101
+ - [ ] 每个切面有完整切点表达式
102
+ - [ ] 执行顺序(@Order)已标注
103
+ - [ 径已列出
104
+ - [ ] 切面执行顺序图已画
105
+ - [ ] 数值从源码验证
@@ -0,0 +1,63 @@
1
+ # 任务:生成 {module_name} 模块的 api-contracts.md
2
+
3
+ {module_description}
4
+
5
+ {execution_guidance}
6
+
7
+ ## 你必须遵守的规则(违反任何一条即为失败)
8
+
9
+ 1. **禁止编造** — 接口路径、参数、响应结构必须从源码提取
10
+ 2. **每个接口必须完整** — HTTP 方法+路径、请求参数表、响应类型、错误码、Sentinel 资源名
11
+ 3. **VO 字段来源规则** — 本模块有定义→写类名+关键字段摘要(3-5 个)+ 引用 data-models.md;外部 JAR→标注来源
12
+ 4. **只写接口契约,不写业务逻辑** — 业务流程归 business-logic.md
13
+
14
+ ## 本文档不覆盖的内容
15
+
16
+ - 接口背后的业务逻辑和调用链(归 business-logic.md)
17
+ - VO/DTO 的完整字段定义(归 data-models.md)
18
+ - 枚举值的完整列表(归 enums-and-constants.md,本文档只引用)
19
+
20
+ ## 输出约束
21
+
22
+ - 信息密度优先,避免冗余
23
+ - 确保中文内容完整无截断
24
+
25
+ ## 输入
26
+
27
+ - 骨架 JSON:`{skeleton_path}`({skeleton_size}KB,{skeleton_read_instruction})
28
+ - 源码缓存:`{source_cache_path}`
29
+ - 输出文件:`{output_path}/api-contracts.md`
30
+
31
+ ## 需要读取的源码文件
32
+
33
+ {file_list}
34
+
35
+ ## 内容组织
36
+
37
+ 按 Controller 分大章节(外部接口 / 内部接口),每个接口独立小节。
38
+
39
+ ### 每个接口必须包含
40
+
41
+ | # | 内容 | 必需 |
42
+ |---|------|------|
43
+ | 1 | HTTP 方法 + 路径 | ✅ |
44
+ | 2 | 请求参数表(参数名、位置、类型、必填、校验规则) | ✅ |
45
+ | 3 | 响应类型 + 关键字段摘要(3-5 个),引用 data-models.md | ✅ |
46
+ | 4 | 错误码(该接口可能返回的错误码 + 触发条件) | ✅ |
47
+ | 5 | Sentinel 资源名 / 限流配置 | 有则写 |
48
+ | 6 | 响应 JSON 示例 | 复杂接口写,简单 CRUD 不需要 |
49
+
50
+ ### 文档末尾
51
+
52
+ 1. **统一响应结构**:`Result<T>` 的 JSON 示例 + 字段说明
53
+ 2. **接口总览表**:所有接口的 HTTP 方法、URL、说明、类型(外部/内部)
54
+
55
+ > 注意:错误码完整列表归 enums-and-constants.md,本文档只在每个接口下列出该接口特有的错误码。
56
+ > 枚举值定义归 enums-and-constants.md,本文档不重复。
57
+
58
+ ## 完成后自检清单
59
+
60
+ - [ ] 每个接口有完整的请求参数和响应类型
61
+ - [ ] VO 字段用摘要 + 引用,未完整展开
62
+ - [ ] 无枚举值定义章节(已归 enums-and-constants.md)
63
+ - [ ] 末尾有统一响应结构和接口总览表
@@ -0,0 +1,111 @@
1
+ # 任务:生成 {module_name} 模块的 architecture.md
2
+
3
+ {module_description}
4
+
5
+ {execution_guidance}
6
+
7
+ ## 你必须遵守的规则(违反任何一条即为失败)
8
+
9
+ 1. **禁止编造** — 所有内容必须有源码出处,无法确认时写 `⚠️ 待验证`
10
+ 2. **数值验证铁律** — 线程池参数、连接池参数、超时配置 → 必须 Read 源码确认
11
+ 3. **写架构决策,不写配置清单** — 重点是"为什么这样设计"和"组件如何协作",不是配置项的机械罗列
12
+ 4. **中间件只写策略概述** — Redis/Kafka/ES 的详细配置归各专项文档,本文档只写架构层面的策略选择和集成方式
13
+ 5. **禁止越权** — 不创建其他文档文件
14
+
15
+ ## 本文档不覆盖的内容
16
+
17
+ - 缓存 Key 的完整定义和 TTL(归 caching.md)
18
+ - 消息队列 Topic/Consumer 的详细配置(归 messaging.md)
19
+ - Feign 接口的方法级细节(归 external-integrations.md)
20
+ - 业务逻辑流程(归 business-logic.md)
21
+ - pom.xml 依赖的完整列表(低价值,直接看 pom.xml)
22
+
23
+ ## 输出约束
24
+
25
+ - 信息密度优先,避免冗余
26
+ - 确保中文内容完整无截断
27
+
28
+ ## 输入
29
+
30
+ - 源码缓存目录:`{source_cache_path}`
31
+ - 输出文件:`{output_path}/architecture.md`
32
+
33
+ ## 需要读取的源码文件
34
+
35
+ {file_list}
36
+
37
+ ## 必须包含的章节
38
+
39
+ ### 1. 整体架构(必须)
40
+ ASCII 分层架构图(从 HTTP 入口到数据存储),标注每层核心类名和关键中间件。
41
+
42
+ ### 2. 技术栈概览(必须)
43
+ 表格:核心框架和中间件的版本号。只列关键组件(10-15 项),不需要列出所有 Maven 依赖。
44
+
45
+ ### 3. 分层职责(必须)
46
+ 每层 2-3 行说明职责、核心类、关键注解。不需要列出每个类。
47
+
48
+ ### 4. 架构模式与设计决策(必须,本文档最重要的章节)
49
+
50
+ 从源码提炼设计选择,每个决策用以下格式:
51
+
52
+ ```markdown
53
+ #### 💡 [决策名称]
54
+ - **选择**:采用了什么方案
55
+ - **原因**:为什么这样选(从代码结构/注释/配置推断)
56
+ - **权衡**:有什么代价或风险
57
+ ```
58
+
59
+ 常见的设计决策维度:
60
+ - 状态机设计(状态流转图 + 转换条件)
61
+ - 幂等策略(接口级/业务级/消费者级)
62
+ - 并发模型(线程池配置 + 异步边界)
63
+ - 数据一致性方案(最终一致/强一致/补偿)
64
+ - 缓存策略选择(Cache-Aside/Write-Through/Write-Behind)
65
+
66
+ ### 5. 中间件集成概述(必须)
67
+
68
+ 每种中间件 3-5 行概述集成方式和策略选择,详细内容引用专项文档:
69
+
70
+ - **Redis**:使用方式(缓存/分布式锁/消息)、客户端类型、连接池概况 → `详见 [caching.md](./caching.md)`
71
+ - **Kafka**:集群数量、生产/消费模式概述 → `详见 [messaging.md](./messaging.md)`
72
+ - **数据库**:连接池类型、读写分离策略、ORM 框架
73
+ - **ES**(有则写):索引策略、同步方式
74
+
75
+ ### 6. 配置管理(必须)
76
+
77
+ 只列动态配置(Nacos 热更新的配置项),静态配置不需要列出:
78
+
79
+ | 配置项 | 类型 | 默认值 | 说明 | 热更新 |
80
+ |--------|------|--------|------|--------|
81
+
82
+ ### 7. 线程模型(有自定义线程池时必须)
83
+
84
+ | 线程池 Bean | 核心/最大 | 队列类型/容量 | 拒绝策略 | 用途 |
85
+ |------------|----------|-------------|---------|------|
86
+
87
+ ⚠️ 标注无界队列的 OOM 风险。
88
+
89
+ ### 8. 部署架构(有 Dockerfile 时写)
90
+ Docker 基础镜像、JVM 参数、健康检查。2-3 行即可。
91
+
92
+ ### 9. 韧性设计(有 Sentinel/Hystrix/Resilience4j 时必须)
93
+
94
+ 从源码中的限流/熔断/降级注解和配置提取:
95
+
96
+ | 维度 | 策略 | 配置来源 | 关键参数 |
97
+ |------|------|---------|---------|
98
+ | 限流 | Sentinel QPS / 线程数 | @SentinelResource / dashboard | 阈值、降级方法 |
99
+ | 熔断 | 异常比例 / 慢调用比例 | 配置中心 / 代码 | 时间窗口、恢复策略 |
100
+ | 降级 | fallback 方法 | @SentinelResource / @HystrixCommand | 降级逻辑摘要 |
101
+ | 重试 | Spring Retry / 自定义 | @Retryable / 代码 | 次数、间隔、退避策略 |
102
+
103
+ ⚠️ 只列出源码中实际存在的韧性机制,不要编造。无相关注解/配置则跳过本章节。
104
+
105
+ ## 完成后自检清单
106
+
107
+ - [ ] 有分层架构图
108
+ - [ ] 架构模式与设计决策章节有实质内容(不是空话)
109
+ - [ ] 中间件只写策略概述 + 引用链接,未展开配置细节
110
+ - [ ] 无 pom.xml 依赖完整列表
111
+ - [ ] 所有数值从源码验证