autosnippet 3.3.5 → 3.3.7

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 (279) hide show
  1. package/dashboard/dist/assets/icons-FHns2ypa.js +1 -0
  2. package/dashboard/dist/assets/index-BRJv5Y3r.js +135 -0
  3. package/dashboard/dist/assets/index-DzoB7kxK.css +1 -0
  4. package/dashboard/dist/index.html +3 -3
  5. package/dist/bin/api-server.js +1 -0
  6. package/dist/bin/cli.d.ts +1 -0
  7. package/dist/bin/cli.js +137 -9
  8. package/dist/lib/agent/AgentFactory.d.ts +0 -17
  9. package/dist/lib/agent/AgentFactory.js +1 -25
  10. package/dist/lib/agent/AgentRuntime.d.ts +2 -2
  11. package/dist/lib/agent/AgentRuntime.js +26 -18
  12. package/dist/lib/agent/capabilities.d.ts +11 -0
  13. package/dist/lib/agent/capabilities.js +29 -5
  14. package/dist/lib/agent/context/ExplorationTracker.js +10 -1
  15. package/dist/lib/agent/context/exploration/ExplorationStrategies.d.ts +2 -0
  16. package/dist/lib/agent/context/exploration/ExplorationStrategies.js +2 -2
  17. package/dist/lib/agent/domain/ChatAgentTasks.js +4 -0
  18. package/dist/lib/agent/domain/insight-analyst.d.ts +47 -3
  19. package/dist/lib/agent/domain/insight-analyst.js +111 -11
  20. package/dist/lib/agent/domain/insight-evolver.d.ts +69 -0
  21. package/dist/lib/agent/domain/insight-evolver.js +230 -0
  22. package/dist/lib/agent/domain/insight-gate.d.ts +42 -0
  23. package/dist/lib/agent/domain/insight-gate.js +41 -0
  24. package/dist/lib/agent/domain/insight-producer.d.ts +27 -2
  25. package/dist/lib/agent/domain/insight-producer.js +60 -5
  26. package/dist/lib/agent/domain/scan-prompts.js +10 -7
  27. package/dist/lib/agent/forced-summary.js +7 -2
  28. package/dist/lib/agent/memory/ActiveContext.d.ts +2 -28
  29. package/dist/lib/agent/memory/MemoryCoordinator.d.ts +2 -2
  30. package/dist/lib/agent/memory/SessionStore.d.ts +6 -12
  31. package/dist/lib/agent/memory/SessionStore.js +9 -15
  32. package/dist/lib/agent/memory/memory-flush-contract.d.ts +49 -0
  33. package/dist/lib/agent/memory/memory-flush-contract.js +16 -0
  34. package/dist/lib/agent/memory/session-store-schema.d.ts +20 -0
  35. package/dist/lib/agent/memory/session-store-schema.js +41 -0
  36. package/dist/lib/agent/presets.d.ts +89 -1
  37. package/dist/lib/agent/presets.js +53 -5
  38. package/dist/lib/agent/tools/_shared.d.ts +7 -15
  39. package/dist/lib/agent/tools/_shared.js +20 -21
  40. package/dist/lib/agent/tools/composite.d.ts +25 -22
  41. package/dist/lib/agent/tools/composite.js +108 -109
  42. package/dist/lib/agent/tools/evolution-tools.d.ts +145 -0
  43. package/dist/lib/agent/tools/evolution-tools.js +161 -0
  44. package/dist/lib/agent/tools/index.d.ts +163 -92
  45. package/dist/lib/agent/tools/index.js +9 -1
  46. package/dist/lib/agent/tools/lifecycle.d.ts +7 -1
  47. package/dist/lib/agent/tools/lifecycle.js +59 -75
  48. package/dist/lib/cli/AiScanService.js +5 -5
  49. package/dist/lib/cli/KnowledgeSyncService.js +1 -1
  50. package/dist/lib/core/AstAnalyzer.d.ts +1 -0
  51. package/dist/lib/core/discovery/ConfigWatcher.d.ts +64 -0
  52. package/dist/lib/core/discovery/ConfigWatcher.js +336 -0
  53. package/dist/lib/core/discovery/CustomConfigDiscoverer.d.ts +30 -0
  54. package/dist/lib/core/discovery/CustomConfigDiscoverer.js +1305 -0
  55. package/dist/lib/core/discovery/DiscovererPreference.d.ts +44 -0
  56. package/dist/lib/core/discovery/DiscovererPreference.js +141 -0
  57. package/dist/lib/core/discovery/DiscovererRegistry.d.ts +10 -1
  58. package/dist/lib/core/discovery/DiscovererRegistry.js +42 -2
  59. package/dist/lib/core/discovery/ProjectDiscoverer.d.ts +19 -0
  60. package/dist/lib/core/discovery/index.d.ts +2 -0
  61. package/dist/lib/core/discovery/index.js +4 -0
  62. package/dist/lib/core/discovery/parsers/CMakeParser.d.ts +32 -0
  63. package/dist/lib/core/discovery/parsers/CMakeParser.js +148 -0
  64. package/dist/lib/core/discovery/parsers/GradleDslParser.d.ts +43 -0
  65. package/dist/lib/core/discovery/parsers/GradleDslParser.js +171 -0
  66. package/dist/lib/core/discovery/parsers/JsonConfigParser.d.ts +45 -0
  67. package/dist/lib/core/discovery/parsers/JsonConfigParser.js +122 -0
  68. package/dist/lib/core/discovery/parsers/RubyDslParser.d.ts +49 -0
  69. package/dist/lib/core/discovery/parsers/RubyDslParser.js +282 -0
  70. package/dist/lib/core/discovery/parsers/StarlarkParser.d.ts +33 -0
  71. package/dist/lib/core/discovery/parsers/StarlarkParser.js +229 -0
  72. package/dist/lib/core/discovery/parsers/YamlConfigParser.d.ts +37 -0
  73. package/dist/lib/core/discovery/parsers/YamlConfigParser.js +212 -0
  74. package/dist/lib/{service/bootstrap/DimensionCopyRegistry.d.ts → domain/dimension/DimensionCopy.d.ts} +2 -2
  75. package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js} +22 -72
  76. package/dist/lib/domain/dimension/DimensionRegistry.d.ts +54 -0
  77. package/dist/lib/domain/dimension/DimensionRegistry.js +620 -0
  78. package/dist/lib/domain/dimension/DimensionSop.d.ts +55 -0
  79. package/dist/lib/domain/dimension/DimensionSop.js +1604 -0
  80. package/dist/lib/domain/dimension/UnifiedDimension.d.ts +61 -0
  81. package/dist/lib/domain/dimension/UnifiedDimension.js +53 -0
  82. package/dist/lib/domain/dimension/index.d.ts +10 -0
  83. package/dist/lib/domain/dimension/index.js +9 -0
  84. package/dist/lib/domain/knowledge/FieldSpec.d.ts +1 -1
  85. package/dist/lib/domain/knowledge/FieldSpec.js +29 -16
  86. package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +40 -112
  87. package/dist/lib/domain/knowledge/KnowledgeEntry.js +44 -9
  88. package/dist/lib/domain/knowledge/KnowledgeRepository.d.ts +1 -0
  89. package/dist/lib/domain/knowledge/KnowledgeRepository.js +3 -0
  90. package/dist/lib/domain/knowledge/Lifecycle.js +1 -1
  91. package/dist/lib/domain/knowledge/StyleGuide.d.ts +1 -1
  92. package/dist/lib/domain/knowledge/StyleGuide.js +1 -1
  93. package/dist/lib/domain/knowledge/UnifiedValidator.js +15 -0
  94. package/dist/lib/external/ai/AiProvider.d.ts +12 -0
  95. package/dist/lib/external/ai/AiProvider.js +24 -0
  96. package/dist/lib/external/ai/AiProviderManager.d.ts +101 -0
  97. package/dist/lib/external/ai/AiProviderManager.js +193 -0
  98. package/dist/lib/external/ai/providers/ClaudeProvider.js +11 -0
  99. package/dist/lib/external/ai/providers/GoogleGeminiProvider.js +18 -0
  100. package/dist/lib/external/ai/providers/MockProvider.d.ts +21 -3
  101. package/dist/lib/external/ai/providers/MockProvider.js +290 -14
  102. package/dist/lib/external/ai/providers/OpenAiProvider.js +16 -0
  103. package/dist/lib/external/lark/LarkTransport.d.ts +5 -1
  104. package/dist/lib/external/lark/LarkTransport.js +10 -2
  105. package/dist/lib/external/mcp/McpServer.js +4 -0
  106. package/dist/lib/external/mcp/handlers/TargetClassifier.d.ts +1 -1
  107. package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.d.ts +8 -16
  108. package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +10 -10
  109. package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.d.ts +7 -0
  110. package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +20 -0
  111. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +52 -132
  112. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +204 -17
  113. package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.d.ts +11 -75
  114. package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.js +40 -191
  115. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.d.ts +13 -78
  116. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +30 -52
  117. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.d.ts +0 -1
  118. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.d.ts +20 -0
  119. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.js +432 -0
  120. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.d.ts +99 -12
  121. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +188 -169
  122. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
  123. package/dist/lib/external/mcp/handlers/bootstrap/refine.js +8 -0
  124. package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.d.ts +46 -0
  125. package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.js +58 -0
  126. package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.d.ts +25 -0
  127. package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.js +47 -0
  128. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +50 -12
  129. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +30 -10
  130. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-text.js +1 -1
  131. package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.d.ts +24 -0
  132. package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.js +14 -0
  133. package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.d.ts +14 -0
  134. package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.js +48 -0
  135. package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.d.ts +21 -0
  136. package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.js +45 -0
  137. package/dist/lib/external/mcp/handlers/bootstrap/shared/skill-generator.d.ts +1 -1
  138. package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.d.ts +27 -0
  139. package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.js +44 -0
  140. package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +23 -10
  141. package/dist/lib/external/mcp/handlers/bootstrap-external.js +41 -51
  142. package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
  143. package/dist/lib/external/mcp/handlers/bootstrap-internal.js +117 -82
  144. package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
  145. package/dist/lib/external/mcp/handlers/consolidated.js +108 -332
  146. package/dist/lib/external/mcp/handlers/dimension-complete-external.js +71 -2
  147. package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
  148. package/dist/lib/external/mcp/handlers/evolve-external.js +229 -0
  149. package/dist/lib/external/mcp/handlers/knowledge.js +30 -5
  150. package/dist/lib/external/mcp/handlers/rescan-external.d.ts +76 -0
  151. package/dist/lib/external/mcp/handlers/rescan-external.js +335 -0
  152. package/dist/lib/external/mcp/handlers/rescan-internal.d.ts +120 -0
  153. package/dist/lib/external/mcp/handlers/rescan-internal.js +359 -0
  154. package/dist/lib/external/mcp/handlers/search.d.ts +6 -5
  155. package/dist/lib/external/mcp/handlers/search.js +6 -5
  156. package/dist/lib/external/mcp/handlers/types.d.ts +2 -1
  157. package/dist/lib/external/mcp/handlers/wiki-external.js +2 -2
  158. package/dist/lib/external/mcp/tools.d.ts +8 -18
  159. package/dist/lib/external/mcp/tools.js +58 -2
  160. package/dist/lib/http/routes/ai.js +111 -30
  161. package/dist/lib/http/routes/candidates.js +11 -4
  162. package/dist/lib/http/routes/commands.js +10 -1
  163. package/dist/lib/http/routes/health.js +11 -0
  164. package/dist/lib/http/routes/knowledge.js +122 -1
  165. package/dist/lib/http/routes/modules.js +52 -3
  166. package/dist/lib/http/routes/panorama.js +16 -4
  167. package/dist/lib/http/routes/recipes.js +7 -0
  168. package/dist/lib/http/utils/routeHelpers.js +2 -1
  169. package/dist/lib/infrastructure/cache/CacheCoordinator.d.ts +41 -0
  170. package/dist/lib/infrastructure/cache/CacheCoordinator.js +105 -0
  171. package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.d.ts +7 -0
  172. package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.js +28 -0
  173. package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +1 -1
  174. package/dist/lib/injection/ServiceContainer.d.ts +6 -5
  175. package/dist/lib/injection/ServiceContainer.js +64 -25
  176. package/dist/lib/injection/ServiceMap.d.ts +10 -1
  177. package/dist/lib/injection/modules/AiModule.d.ts +6 -9
  178. package/dist/lib/injection/modules/AiModule.js +82 -39
  179. package/dist/lib/injection/modules/KnowledgeModule.js +15 -1
  180. package/dist/lib/injection/modules/PanoramaModule.js +1 -1
  181. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +4 -0
  182. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +16 -1
  183. package/dist/lib/service/bootstrap/BootstrapEventEmitter.d.ts +3 -2
  184. package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +1 -1
  185. package/dist/lib/service/bootstrap/DeliveryVerifier.d.ts +51 -0
  186. package/dist/lib/service/bootstrap/DeliveryVerifier.js +163 -0
  187. package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +5 -0
  188. package/dist/lib/service/bootstrap/UiStartupTasks.js +20 -0
  189. package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +54 -0
  190. package/dist/lib/service/bootstrap/bootstrap-event-types.js +10 -0
  191. package/dist/lib/service/cleanup/CleanupService.d.ts +132 -0
  192. package/dist/lib/service/cleanup/CleanupService.js +571 -0
  193. package/dist/lib/service/delivery/AgentInstructionsGenerator.js +39 -43
  194. package/dist/lib/service/delivery/FileProtection.d.ts +20 -0
  195. package/dist/lib/service/delivery/FileProtection.js +54 -0
  196. package/dist/lib/service/delivery/SkillsSyncer.js +16 -21
  197. package/dist/lib/service/evolution/ContentPatcher.d.ts +44 -0
  198. package/dist/lib/service/evolution/ContentPatcher.js +310 -0
  199. package/dist/lib/service/evolution/ProposalExecutor.d.ts +4 -0
  200. package/dist/lib/service/evolution/ProposalExecutor.js +77 -13
  201. package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +64 -0
  202. package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +458 -0
  203. package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +89 -0
  204. package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +492 -0
  205. package/dist/lib/service/evolution/createSupersedeProposal.d.ts +44 -0
  206. package/dist/lib/service/evolution/createSupersedeProposal.js +81 -0
  207. package/dist/lib/service/guard/ComplianceReporter.d.ts +4 -0
  208. package/dist/lib/service/guard/ComplianceReporter.js +51 -0
  209. package/dist/lib/service/guard/GuardCheckEngine.js +5 -4
  210. package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +6 -0
  211. package/dist/lib/service/knowledge/CodeEntityGraph.js +16 -0
  212. package/dist/lib/service/knowledge/ConfidenceRouter.js +1 -1
  213. package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
  214. package/dist/lib/service/knowledge/KnowledgeService.js +67 -14
  215. package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
  216. package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
  217. package/dist/lib/service/module/ModuleService.js +10 -19
  218. package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +10 -1
  219. package/dist/lib/service/panorama/CouplingAnalyzer.js +44 -2
  220. package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +4 -3
  221. package/dist/lib/service/panorama/DimensionAnalyzer.js +40 -151
  222. package/dist/lib/service/panorama/LayerInferrer.d.ts +16 -1
  223. package/dist/lib/service/panorama/LayerInferrer.js +118 -1
  224. package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +9 -0
  225. package/dist/lib/service/panorama/ModuleDiscoverer.js +58 -2
  226. package/dist/lib/service/panorama/PanoramaAggregator.d.ts +6 -2
  227. package/dist/lib/service/panorama/PanoramaAggregator.js +84 -6
  228. package/dist/lib/service/panorama/PanoramaScanner.js +28 -0
  229. package/dist/lib/service/panorama/PanoramaService.js +10 -5
  230. package/dist/lib/service/panorama/PanoramaTypes.d.ts +38 -0
  231. package/dist/lib/service/panorama/RoleRefiner.d.ts +2 -0
  232. package/dist/lib/service/panorama/RoleRefiner.js +41 -0
  233. package/dist/lib/service/panorama/TechStackProfiler.d.ts +13 -0
  234. package/dist/lib/service/panorama/TechStackProfiler.js +191 -0
  235. package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
  236. package/dist/lib/service/search/SearchEngine.d.ts +11 -10
  237. package/dist/lib/service/search/SearchEngine.js +38 -36
  238. package/dist/lib/service/search/SearchTypes.d.ts +14 -8
  239. package/dist/lib/service/search/SearchTypes.js +1 -1
  240. package/dist/lib/service/search/tokenizer.d.ts +1 -1
  241. package/dist/lib/service/search/tokenizer.js +2 -2
  242. package/dist/lib/service/skills/SignalCollector.d.ts +1 -0
  243. package/dist/lib/service/skills/SignalCollector.js +6 -5
  244. package/dist/lib/service/vector/ContextualEnricher.d.ts +1 -0
  245. package/dist/lib/service/vector/ContextualEnricher.js +4 -0
  246. package/dist/lib/shared/LanguageService.js +3 -0
  247. package/dist/lib/shared/developer-identity.d.ts +18 -0
  248. package/dist/lib/shared/developer-identity.js +62 -0
  249. package/dist/lib/shared/schemas/common.d.ts +4 -4
  250. package/dist/lib/shared/schemas/http-requests.d.ts +20 -18
  251. package/dist/lib/shared/schemas/http-requests.js +17 -6
  252. package/dist/lib/shared/schemas/mcp-tools.d.ts +32 -2
  253. package/dist/lib/shared/schemas/mcp-tools.js +38 -0
  254. package/dist/lib/types/evolution.d.ts +135 -0
  255. package/dist/lib/types/evolution.js +6 -0
  256. package/dist/lib/types/graph-shared.d.ts +25 -0
  257. package/dist/lib/types/graph-shared.js +7 -0
  258. package/dist/lib/types/knowledge-wire.d.ts +132 -0
  259. package/dist/lib/types/knowledge-wire.js +7 -0
  260. package/dist/lib/types/project-snapshot-builder.d.ts +19 -0
  261. package/dist/lib/types/project-snapshot-builder.js +189 -0
  262. package/dist/lib/types/project-snapshot.d.ts +399 -0
  263. package/dist/lib/types/project-snapshot.js +17 -0
  264. package/dist/lib/types/search-wire.d.ts +46 -0
  265. package/dist/lib/types/search-wire.js +7 -0
  266. package/dist/lib/types/snapshot-views.d.ts +58 -0
  267. package/dist/lib/types/snapshot-views.js +103 -0
  268. package/package.json +1 -1
  269. package/skills/autosnippet-recipes/SKILL.md +1 -1
  270. package/templates/instructions/agent-static.md +2 -0
  271. package/templates/instructions/conventions.md +3 -1
  272. package/templates/recipes-setup/README.md +2 -2
  273. package/dashboard/dist/assets/icons-BJ2mUBi8.js +0 -1
  274. package/dashboard/dist/assets/index-B659K9t5.js +0 -128
  275. package/dashboard/dist/assets/index-NCm40PMD.css +0 -1
  276. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.d.ts +0 -169
  277. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +0 -727
  278. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.d.ts +0 -370
  279. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +0 -821
@@ -15,42 +15,15 @@
15
15
  * @module handlers/bootstrap-external
16
16
  */
17
17
  import path from 'node:path';
18
+ import { CleanupService } from '#service/cleanup/CleanupService.js';
18
19
  import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
20
+ import { buildProjectSnapshot } from '#types/project-snapshot-builder.js';
21
+ import { toSessionCache } from '#types/snapshot-views.js';
19
22
  import { envelope } from '../envelope.js';
20
- import { BootstrapSessionManager } from './bootstrap/BootstrapSession.js';
21
23
  import { buildMissionBriefing } from './bootstrap/MissionBriefingBuilder.js';
22
24
  import { runAllPhases } from './bootstrap/shared/bootstrap-phases.js';
25
+ import { getOrCreateSessionManager } from './bootstrap/shared/session-helpers.js';
23
26
  import { buildLanguageExtension } from './LanguageExtensions.js';
24
- // ── 进程级 Session 管理器 ─────────────────────────────────
25
- let _sessionManager = null;
26
- /**
27
- * 获取或创建 BootstrapSessionManager
28
- * @param container ServiceContainer
29
- */
30
- function getSessionManager(container) {
31
- // 优先使用容器注册的 (如果已注册)
32
- try {
33
- const mgr = container.get('bootstrapSessionManager');
34
- if (mgr) {
35
- return mgr;
36
- }
37
- }
38
- catch {
39
- /* not registered yet */
40
- }
41
- // 降级为模块级单例
42
- if (!_sessionManager) {
43
- _sessionManager = new BootstrapSessionManager();
44
- }
45
- // 注册到容器,让 submitKnowledgeBatch / consolidated 等 handler 也能访问
46
- try {
47
- container.register('bootstrapSessionManager', () => _sessionManager);
48
- }
49
- catch {
50
- /* already registered or container doesn't support register */
51
- }
52
- return _sessionManager;
53
- }
54
27
  // ── 主入口 ─────────────────────────────────────────────────────
55
28
  /**
56
29
  * bootstrapExternal — 外部 Agent 驱动的一键冷启动
@@ -65,7 +38,17 @@ export async function bootstrapExternal(ctx) {
65
38
  const t0 = Date.now();
66
39
  const projectRoot = resolveProjectRoot(ctx.container);
67
40
  // ═══════════════════════════════════════════════════════════
68
- // Phase 1-4: 共享数据收集管线
41
+ // Step 1: 全量清理 (CleanupService.fullReset)
42
+ // ═══════════════════════════════════════════════════════════
43
+ const db = ctx.container.get('database');
44
+ const cleanupService = new CleanupService({
45
+ projectRoot,
46
+ db,
47
+ logger: ctx.logger,
48
+ });
49
+ const cleanupResult = await cleanupService.fullReset();
50
+ // ═══════════════════════════════════════════════════════════
51
+ // Phase 1-4: 共享数据收集管线(永远全量,无增量检测)
69
52
  // ═══════════════════════════════════════════════════════════
70
53
  const phaseResults = await runAllPhases(projectRoot, ctx, {
71
54
  maxFiles: 500,
@@ -74,7 +57,7 @@ export async function bootstrapExternal(ctx) {
74
57
  summaryPrefix: 'Bootstrap-external scan',
75
58
  clearOldData: true,
76
59
  generateReport: true,
77
- incremental: true,
60
+ incremental: false,
78
61
  });
79
62
  // 空项目 fast-path
80
63
  if (phaseResults.isEmpty) {
@@ -84,12 +67,19 @@ export async function bootstrapExternal(ctx) {
84
67
  meta: { tool: 'autosnippet_bootstrap', responseTimeMs: Date.now() - t0 },
85
68
  });
86
69
  }
87
- const { allFiles, primaryLang, depGraphData, langStats, astProjectSummary, codeEntityResult, callGraphResult, guardAudit, activeDimensions: dimensions, targetsSummary, langProfile, incrementalPlan, } = phaseResults;
70
+ const { allFiles, primaryLang, depGraphData, langStats, astProjectSummary, codeEntityResult, callGraphResult, guardAudit, activeDimensions: dimensions, targetsSummary, localPackageModules, langProfile, } = phaseResults;
71
+ // ── Build immutable ProjectSnapshot ──
72
+ const snapshot = buildProjectSnapshot({
73
+ projectRoot,
74
+ sourceTag: 'bootstrap-external',
75
+ ...phaseResults,
76
+ report: phaseResults.report,
77
+ });
88
78
  // ═══════════════════════════════════════════════════════════
89
79
  // Phase 4: 构建 Mission Briefing
90
80
  // ═══════════════════════════════════════════════════════════
91
81
  // 创建 BootstrapSession
92
- const sessionManager = getSessionManager(ctx.container);
82
+ const sessionManager = getOrCreateSessionManager(ctx.container);
93
83
  const session = sessionManager.createSession({
94
84
  projectRoot,
95
85
  dimensions,
@@ -101,17 +91,7 @@ export async function bootstrapExternal(ctx) {
101
91
  },
102
92
  });
103
93
  // 缓存 Phase 结果供 wiki_plan 复用
104
- session.setPhaseCache({
105
- allFiles,
106
- astProjectSummary,
107
- codeEntityResult,
108
- callGraphResult,
109
- depGraphData,
110
- guardAudit,
111
- langStats,
112
- primaryLang,
113
- targetsSummary,
114
- });
94
+ session.setSnapshotCache(toSessionCache(snapshot));
115
95
  // 构建 projectMeta
116
96
  const projectMeta = {
117
97
  name: path.basename(projectRoot),
@@ -119,7 +99,7 @@ export async function bootstrapExternal(ctx) {
119
99
  secondaryLanguages: langProfile.secondary || [],
120
100
  isMultiLang: langProfile.isMultiLang || false,
121
101
  fileCount: allFiles.length,
122
- projectType: phaseResults.discoverer.id,
102
+ projectType: snapshot.discoverer.id,
123
103
  projectRoot,
124
104
  };
125
105
  // 构建 Mission Briefing
@@ -134,9 +114,9 @@ export async function bootstrapExternal(ctx) {
134
114
  activeDimensions: dimensions,
135
115
  session,
136
116
  languageExtension: buildLanguageExtension(primaryLang), // §7.1
137
- incrementalPlan,
138
117
  languageStats: langStats,
139
- panoramaResult: phaseResults.panoramaResult, // §M1: Phase 1.8 全景数据
118
+ panoramaResult: snapshot.panorama, // §M1: Phase 1.8 全景数据
119
+ localPackageModules, // 本地子包模块信息
140
120
  });
141
121
  // 附加 warnings
142
122
  if (phaseResults.warnings.length > 0) {
@@ -147,7 +127,17 @@ export async function bootstrapExternal(ctx) {
147
127
  `${briefing.meta?.responseSizeKB || '?'}KB — session ${session.id}`);
148
128
  return envelope({
149
129
  success: true,
150
- data: briefing,
130
+ data: {
131
+ cleanup: {
132
+ deletedRecipes: cleanupResult.deletedFiles,
133
+ clearedTables: cleanupResult.clearedTables.length,
134
+ dbCleared: true,
135
+ errors: cleanupResult.errors,
136
+ trash: cleanupResult.trash ?? null,
137
+ purgedTrash: cleanupResult.purgedTrash ?? null,
138
+ },
139
+ ...briefing,
140
+ },
151
141
  message: `⚠️ Bootstrap 仅完成第一步(项目扫描),你必须继续完成全部 ${dimensions.length} 个维度的分析。` +
152
142
  `请立即按 executionPlan.tiers 的顺序,对每个维度执行:` +
153
143
  `(1) 用你的代码阅读能力分析该维度相关文件 → ` +
@@ -164,7 +154,7 @@ export async function bootstrapExternal(ctx) {
164
154
  * 仍然返回该 session(支持新 bootstrap 创建后旧 session 的 dimension_complete 继续工作)。
165
155
  */
166
156
  export function getActiveSession(container, sessionId) {
167
- const mgr = getSessionManager(container);
157
+ const mgr = getOrCreateSessionManager(container);
168
158
  const session = mgr.getSession(sessionId);
169
159
  if (session) {
170
160
  return session;
@@ -64,6 +64,8 @@ interface BootstrapKnowledgeArgs {
64
64
  incremental?: boolean;
65
65
  skipAsyncFill?: boolean;
66
66
  loadSkills?: boolean;
67
+ /** 仅运行指定维度(传维度 id 数组),不传则运行全部活跃维度 */
68
+ dimensions?: string[];
67
69
  [key: string]: unknown;
68
70
  }
69
71
  /**
@@ -46,15 +46,23 @@
46
46
  * bootstrap/dimensions.js ← 7 维度知识提取器(内部 Agent 专用)
47
47
  * bootstrap/projectSkills.js ← Phase 5.5 Project Skill 生成(内部 Agent 专用)
48
48
  */
49
+ import path from 'node:path';
49
50
  import { getInternalAgentRequiredFields } from '#domain/knowledge/FieldSpec.js';
51
+ import { CleanupService } from '#service/cleanup/CleanupService.js';
50
52
  import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
53
+ import { buildProjectSnapshot } from '#types/project-snapshot-builder.js';
54
+ import { toSessionCache } from '#types/snapshot-views.js';
51
55
  import { envelope } from '../envelope.js';
52
56
  import { fillDimensionsV3 } from './bootstrap/pipeline/orchestrator.js';
53
57
  import { bootstrapRefine } from './bootstrap/refine.js';
58
+ import { buildTaskDefs, dispatchPipelineFill, startTaskManagerSession, } from './bootstrap/shared/async-fill-helpers.js';
54
59
  import { runAllPhases } from './bootstrap/shared/bootstrap-phases.js';
55
60
  import { buildInternalNextSteps } from './bootstrap/shared/dimension-text.js';
56
- import { buildLanguageExtension, inferLang } from './LanguageExtensions.js';
57
- import { inferFilePriority, inferTargetRole } from './TargetClassifier.js';
61
+ import { summarizePanorama } from './bootstrap/shared/panorama-utils.js';
62
+ import { getOrCreateSessionManager } from './bootstrap/shared/session-helpers.js';
63
+ import { buildTargetFileMap } from './bootstrap/shared/target-file-map.js';
64
+ import { buildLanguageExtension } from './LanguageExtensions.js';
65
+ import { inferTargetRole } from './TargetClassifier.js';
58
66
  export { bootstrapRefine };
59
67
  /**
60
68
  * bootstrapKnowledge — 一键初始化知识库 (Skill-aware)
@@ -81,6 +89,22 @@ export async function bootstrapKnowledge(ctx, args) {
81
89
  const contentMaxLines = args.contentMaxLines || 120;
82
90
  const skipAsyncFill = args.skipAsyncFill || false;
83
91
  // ═══════════════════════════════════════════════════════════
92
+ // Step 0: 全量清理 (与 bootstrap-external 对齐)
93
+ // 冷启动需要干净的初始状态:清除 DB + 文件系统缓存
94
+ // ═══════════════════════════════════════════════════════════
95
+ const db = ctx.container.get('database');
96
+ const cleanupService = new CleanupService({
97
+ projectRoot,
98
+ db,
99
+ logger: ctx.logger,
100
+ });
101
+ const cleanupResult = await cleanupService.fullReset();
102
+ ctx.logger.info('[Bootstrap-Internal] fullReset complete', {
103
+ tables: cleanupResult.clearedTables.length,
104
+ files: cleanupResult.deletedFiles,
105
+ errors: cleanupResult.errors.length,
106
+ });
107
+ // ═══════════════════════════════════════════════════════════
84
108
  // Phase 1-4: 共享管线(文件收集→AST→依赖→Guard→维度解析)
85
109
  // ═══════════════════════════════════════════════════════════
86
110
  const phaseResults = await runAllPhases(projectRoot, ctx, {
@@ -99,7 +123,20 @@ export async function bootstrapKnowledge(ctx, args) {
99
123
  meta: { tool: 'autosnippet_bootstrap', responseTimeMs: Date.now() - t0 },
100
124
  });
101
125
  }
102
- const { allFiles, allTargets, discoverer, langStats, primaryLang, astProjectSummary, astContext, depGraphData, depEdgesWritten, guardAudit, guardEngine: _guardEngine, activeDimensions, enhancementPackInfo, enhancementPatterns, enhancementGuardRules, langProfile, targetsSummary, incrementalPlan, detectedFrameworks: _detectedFrameworks, warnings: _phaseWarnings, report: phaseReport, } = phaseResults;
126
+ // ═══════════════════════════════════════════════════════════
127
+ // 构建 ProjectSnapshot — 统一数据来源
128
+ // ═══════════════════════════════════════════════════════════
129
+ const snapshot = buildProjectSnapshot({
130
+ projectRoot,
131
+ sourceTag: 'bootstrap',
132
+ ...phaseResults,
133
+ report: phaseResults.report,
134
+ });
135
+ // 从 snapshot 派生局部别名(兼容既有 responseData 构建逻辑)
136
+ const { allFiles, allTargets, discoverer, ast: astProjectSummary, astContext, dependencyGraph: depGraphData, depEdgesWritten, guardAudit, activeDimensions, enhancementPackInfo, enhancementPatterns, enhancementGuardRules, language, targetsSummary, incrementalPlan, codeEntityGraph: codeEntityResult, callGraph: callGraphResult, localPackageModules, warnings: phaseWarnings, phaseReport, } = snapshot;
137
+ const langStats = language.stats;
138
+ const primaryLang = language.primaryLang;
139
+ const langProfile = language;
103
140
  // 构建兼容的 report 对象(保持原有 API 格式)
104
141
  const report = {
105
142
  phases: {
@@ -141,8 +178,10 @@ export async function bootstrapKnowledge(ctx, args) {
141
178
  },
142
179
  callGraph: phaseReport?.phases?.callGraph
143
180
  ? {
144
- entities: phaseReport.phases.callGraph.result?.entitiesUpserted || 0,
145
- edges: phaseReport.phases.callGraph.result?.edgesCreated || 0,
181
+ entities: phaseReport.phases.callGraph.result
182
+ ?.entitiesUpserted || 0,
183
+ edges: phaseReport.phases.callGraph.result
184
+ ?.edgesCreated || 0,
146
185
  ms: phaseReport.phases.callGraph.ms || 0,
147
186
  }
148
187
  : { entities: 0, edges: 0, ms: 0 },
@@ -169,32 +208,24 @@ export async function bootstrapKnowledge(ctx, args) {
169
208
  // ═══════════════════════════════════════════════════════════
170
209
  // Phase 4.5: 构建响应 — filesByTarget + analysisFramework
171
210
  // ═══════════════════════════════════════════════════════════
172
- const targetFileMap = {};
173
- for (const f of allFiles) {
174
- if (!targetFileMap[f.targetName]) {
175
- targetFileMap[f.targetName] = [];
176
- }
177
- const lines = f.content.split('\n');
178
- targetFileMap[f.targetName].push({
179
- name: f.name,
180
- relativePath: f.relativePath,
181
- language: inferLang(f.name),
182
- totalLines: lines.length,
183
- priority: inferFilePriority(f.name),
184
- // content 仅保留在内存中供 Phase 5 异步 pipeline 使用
185
- // MCP 响应不包含文件内容(避免 1MB+ 响应导致 Cursor 无法处理)
186
- content: lines.slice(0, contentMaxLines).join('\n'),
187
- truncated: lines.length > contentMaxLines,
188
- });
189
- }
190
- // 每个 target 内按 priority 排序
191
- for (const tName of Object.keys(targetFileMap)) {
192
- const prio = { high: 0, medium: 1, low: 2 };
193
- targetFileMap[tName].sort((a, b) => (prio[a.priority] || 1) -
194
- (prio[b.priority] || 1));
211
+ const targetFileMap = buildTargetFileMap(allFiles, contentMaxLines, true);
212
+ let dimensions = activeDimensions;
213
+ // 如果调用方指定了维度子集,只保留匹配的维度
214
+ if (args.dimensions?.length) {
215
+ const requestedIds = new Set(args.dimensions);
216
+ dimensions = dimensions.filter((d) => requestedIds.has(d.id));
217
+ ctx.logger.info(`[Bootstrap] Dimension filter: ${dimensions.map((d) => d.id).join(', ')}`);
195
218
  }
196
- const dimensions = activeDimensions;
197
219
  const responseData = {
220
+ // Step 0 清理信息(与 bootstrap-external 对齐)
221
+ cleanup: {
222
+ deletedRecipes: cleanupResult.deletedFiles,
223
+ clearedTables: cleanupResult.clearedTables.length,
224
+ dbCleared: true,
225
+ errors: cleanupResult.errors,
226
+ trash: cleanupResult.trash ?? null,
227
+ purgedTrash: cleanupResult.purgedTrash ?? null,
228
+ },
198
229
  report,
199
230
  targets: targetsSummary ||
200
231
  allTargets.map((t) => {
@@ -269,9 +300,9 @@ export async function bootstrapKnowledge(ctx, args) {
269
300
  astContext: astContext || null,
270
301
  astSummary: astProjectSummary
271
302
  ? {
272
- classes: astProjectSummary.classes.length,
273
- protocols: astProjectSummary.protocols.length,
274
- categories: astProjectSummary.categories.length,
303
+ classes: astProjectSummary.classes?.length || 0,
304
+ protocols: astProjectSummary.protocols?.length || 0,
305
+ categories: astProjectSummary.categories?.length || 0,
275
306
  patterns: Object.keys(astProjectSummary.patternStats || {}),
276
307
  metrics: astProjectSummary.projectMetrics
277
308
  ? {
@@ -292,10 +323,55 @@ export async function bootstrapKnowledge(ctx, args) {
292
323
  guardRules: enhancementGuardRules.length,
293
324
  }
294
325
  : null,
326
+ // 代码实体图谱摘要(与 bootstrap-external 对齐)
327
+ codeEntityGraph: codeEntityResult
328
+ ? {
329
+ totalEntities: codeEntityResult.entityCount || 0,
330
+ totalEdges: codeEntityResult.edgeCount || 0,
331
+ }
332
+ : null,
333
+ // 调用图谱摘要(与 bootstrap-external 对齐)
334
+ callGraph: callGraphResult
335
+ ? {
336
+ entitiesUpserted: callGraphResult.entitiesUpserted || 0,
337
+ edgesCreated: callGraphResult.edgesCreated || 0,
338
+ }
339
+ : null,
340
+ // 全景分析摘要(与 bootstrap-external 对齐)
341
+ panorama: snapshot.panorama ? summarizePanorama(snapshot.panorama) : null,
342
+ // 本地子包模块(与 bootstrap-external mustCoverModules 对齐)
343
+ localPackageModules: localPackageModules.length > 0 ? localPackageModules : null,
344
+ // Phase 1-4 警告(与 bootstrap-external 对齐)
345
+ warnings: phaseWarnings.length > 0 ? phaseWarnings : undefined,
295
346
  // 引导 Agent 下一步操作(共享文本层)
296
347
  nextSteps: buildInternalNextSteps(dimensions),
297
348
  };
298
349
  // ═══════════════════════════════════════════════════════════
350
+ // Phase 4.6: BootstrapSessionManager — 缓存 Phase 结果供 wiki_plan 复用
351
+ // (与 bootstrap-external 对齐)
352
+ // ═══════════════════════════════════════════════════════════
353
+ try {
354
+ const sessionManager = getOrCreateSessionManager(ctx.container);
355
+ const bsSession = sessionManager.createSession({
356
+ projectRoot,
357
+ dimensions: dimensions.map((d) => ({
358
+ ...d,
359
+ skillMeta: d.skillMeta ?? undefined,
360
+ })),
361
+ projectContext: {
362
+ projectName: path.basename(projectRoot),
363
+ primaryLang,
364
+ fileCount: allFiles.length,
365
+ modules: depGraphData?.nodes?.length || 0,
366
+ },
367
+ });
368
+ bsSession.setSnapshotCache(toSessionCache(snapshot));
369
+ responseData.sessionId = bsSession.id;
370
+ }
371
+ catch (e) {
372
+ ctx.logger.warn(`[Bootstrap-Internal] BootstrapSessionManager setup failed (non-blocking): ${e instanceof Error ? e.message : String(e)}`);
373
+ }
374
+ // ═══════════════════════════════════════════════════════════
299
375
  // Phase 5: 创建异步任务 — 骨架先返回,内容后填充
300
376
  //
301
377
  // 策略变更(v5):
@@ -304,65 +380,24 @@ export async function bootstrapKnowledge(ctx, args) {
304
380
  // 前端通过 Socket.io 接收进度更新,卡片 loading → 完成
305
381
  // ═══════════════════════════════════════════════════════════
306
382
  // 构建任务定义列表
307
- const taskDefs = dimensions.map((dim) => ({
308
- id: dim.id,
309
- meta: {
310
- type: dim.skillWorthy ? 'skill' : 'candidate',
311
- dimId: dim.id,
312
- label: dim.label,
313
- skillWorthy: !!dim.skillWorthy,
314
- skillMeta: dim.skillMeta || null,
315
- },
316
- }));
383
+ const taskDefs = buildTaskDefs(dimensions);
317
384
  // 启动 BootstrapTaskManager 会话(通过正式 DI 获取单例)
318
- let bootstrapSession = null;
319
- try {
320
- const taskManager = ctx.container.get('bootstrapTaskManager');
321
- bootstrapSession = taskManager.startSession(taskDefs);
322
- }
323
- catch (e) {
324
- ctx.logger.warn(`[Bootstrap] BootstrapTaskManager init failed (graceful degradation): ${e instanceof Error ? e.message : String(e)}`);
325
- }
385
+ const bootstrapSession = startTaskManagerSession(ctx.container, taskDefs, ctx.logger, 'Bootstrap');
326
386
  // 立即构建骨架响应
327
387
  responseData.bootstrapSession = bootstrapSession ? bootstrapSession.toJSON() : null;
328
388
  responseData.bootstrapCandidates = { created: 0, failed: 0, errors: [], status: 'filling' };
329
389
  responseData.autoSkills = { created: 0, failed: 0, skills: [], errors: [], status: 'filling' };
330
390
  responseData.message = `Bootstrap 骨架已创建: ${allFiles.length} files, ${allTargets.length} targets, ${taskDefs.length} 个维度任务已排队,正在后台逐一填充...`;
331
391
  // ── 异步后台填充(fire-and-forget)──
332
- const fillContext = {
333
- ctx,
334
- dimensions,
335
- allFiles,
336
- targetFileMap,
337
- depGraphData,
338
- guardAudit,
339
- langStats,
340
- primaryLang,
341
- astProjectSummary,
342
- taskManager: (() => {
343
- try {
344
- return ctx.container.get('bootstrapTaskManager');
345
- }
346
- catch {
347
- return null;
348
- }
349
- })(),
350
- sessionId: bootstrapSession?.id || null,
351
- projectRoot,
352
- // v5.0: 增量 Bootstrap 计划
353
- incrementalPlan,
354
- // M1: Phase 1.8 全景数据 → strategyContext.panorama
355
- panoramaResult: phaseResults.panoramaResult,
356
- };
357
- // 使用 setImmediate 避免阻塞 HTTP 响应
358
392
  // skipAsyncFill: CLI 非 --wait 模式跳过异步填充,避免进程退出后 DB 断连
359
393
  if (!skipAsyncFill) {
360
- setImmediate(() => {
361
- ctx.logger.info(`[Bootstrap] Dispatching v3 AI-First pipeline`);
362
- fillDimensionsV3(fillContext).catch((e) => {
363
- ctx.logger.error(`[Bootstrap] Async fill (v3) failed: ${e.message}`);
364
- });
365
- });
394
+ dispatchPipelineFill({
395
+ snapshot,
396
+ ctx: ctx,
397
+ bootstrapSession,
398
+ targetFileMap,
399
+ projectRoot,
400
+ }, dimensions, fillDimensionsV3, 'Bootstrap');
366
401
  }
367
402
  else {
368
403
  ctx.logger.info(`[Bootstrap] Async fill skipped (skipAsyncFill=true)`);
@@ -526,10 +526,10 @@ export declare function consolidatedSkill(ctx: McpContext, args: ConsolidatedSki
526
526
  * 统一提交管线:单条与批量走同一代码路径。
527
527
  *
528
528
  * 流程:
529
- * 1. 解析 items[] → 限流
530
- * 2. 严格校验所有条目(UnifiedValidator)→ valid[] + rejected[]
531
- * 3. 融合分析(ConsolidationAdvisor.analyzeBatch)→ submittable[] + blocked[]
532
- * 4. 提交 submittable → enrich + service.create()
529
+ * 1. 限流
530
+ * 2. V3 字段增强(MCP 特有预处理)
531
+ * 3. RecipeProductionGateway.create() 统一管道
532
+ * 4. Bootstrap session 追踪
533
533
  * 5. 返回统一结果
534
534
  *
535
535
  * 设计原则: