autosnippet 3.2.21 → 3.3.2

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 (311) hide show
  1. package/dashboard/dist/assets/icons-BJ2mUBi8.js +1 -0
  2. package/dashboard/dist/assets/index-B659K9t5.js +128 -0
  3. package/dashboard/dist/assets/index-NCm40PMD.css +1 -0
  4. package/dashboard/dist/index.html +3 -3
  5. package/dist/bin/cli.d.ts +1 -1
  6. package/dist/bin/cli.js +244 -261
  7. package/dist/lib/agent/context/ExplorationTracker.d.ts +2 -0
  8. package/dist/lib/agent/context/ExplorationTracker.js +21 -3
  9. package/dist/lib/agent/core/ToolExecutionPipeline.d.ts +3 -1
  10. package/dist/lib/agent/core/ToolExecutionPipeline.js +8 -1
  11. package/dist/lib/agent/forge/DynamicComposer.d.ts +58 -0
  12. package/dist/lib/agent/forge/DynamicComposer.js +99 -0
  13. package/dist/lib/agent/forge/SandboxRunner.d.ts +60 -0
  14. package/dist/lib/agent/forge/SandboxRunner.js +251 -0
  15. package/dist/lib/agent/forge/TemporaryToolRegistry.d.ts +76 -0
  16. package/dist/lib/agent/forge/TemporaryToolRegistry.js +154 -0
  17. package/dist/lib/agent/forge/ToolForge.d.ts +92 -0
  18. package/dist/lib/agent/forge/ToolForge.js +239 -0
  19. package/dist/lib/agent/forge/ToolRequirementAnalyzer.d.ts +44 -0
  20. package/dist/lib/agent/forge/ToolRequirementAnalyzer.js +119 -0
  21. package/dist/lib/agent/tools/ToolRegistry.d.ts +2 -0
  22. package/dist/lib/agent/tools/ToolRegistry.js +4 -0
  23. package/dist/lib/agent/tools/composite.js +0 -1
  24. package/dist/lib/agent/tools/index.d.ts +2 -50
  25. package/dist/lib/agent/tools/index.js +2 -3
  26. package/dist/lib/agent/tools/lifecycle.d.ts +1 -58
  27. package/dist/lib/agent/tools/lifecycle.js +2 -75
  28. package/dist/lib/cli/SetupService.d.ts +46 -2
  29. package/dist/lib/cli/SetupService.js +2 -27
  30. package/dist/lib/cli/deploy/FileManifest.d.ts +0 -21
  31. package/dist/lib/cli/deploy/FileManifest.js +0 -11
  32. package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.d.ts +2 -5
  33. package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.js +159 -44
  34. package/dist/lib/core/discovery/index.d.ts +1 -1
  35. package/dist/lib/core/discovery/index.js +2 -2
  36. package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +10 -0
  37. package/dist/lib/domain/knowledge/KnowledgeEntry.js +2 -0
  38. package/dist/lib/domain/knowledge/Lifecycle.d.ts +19 -2
  39. package/dist/lib/domain/knowledge/Lifecycle.js +32 -6
  40. package/dist/lib/domain/knowledge/UnifiedValidator.d.ts +1 -5
  41. package/dist/lib/domain/knowledge/UnifiedValidator.js +7 -44
  42. package/dist/lib/domain/knowledge/values/Stats.d.ts +29 -0
  43. package/dist/lib/domain/knowledge/values/Stats.js +41 -0
  44. package/dist/lib/external/mcp/McpServer.d.ts +19 -38
  45. package/dist/lib/external/mcp/McpServer.js +145 -117
  46. package/dist/lib/external/mcp/autoApproveInjector.js +0 -2
  47. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +26 -1
  48. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +41 -0
  49. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +49 -0
  50. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +3 -0
  51. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +27 -0
  52. package/dist/lib/external/mcp/handlers/bootstrap/skills.js +1 -1
  53. package/dist/lib/external/mcp/handlers/bootstrap-external.js +1 -0
  54. package/dist/lib/external/mcp/handlers/bootstrap-internal.js +2 -0
  55. package/dist/lib/external/mcp/handlers/consolidated.d.ts +116 -6
  56. package/dist/lib/external/mcp/handlers/consolidated.js +251 -71
  57. package/dist/lib/external/mcp/handlers/guard.d.ts +150 -0
  58. package/dist/lib/external/mcp/handlers/guard.js +245 -8
  59. package/dist/lib/external/mcp/handlers/knowledge.d.ts +0 -29
  60. package/dist/lib/external/mcp/handlers/knowledge.js +1 -76
  61. package/dist/lib/external/mcp/handlers/panorama.d.ts +36 -0
  62. package/dist/lib/external/mcp/handlers/panorama.js +156 -0
  63. package/dist/lib/external/mcp/handlers/system.d.ts +2 -54
  64. package/dist/lib/external/mcp/handlers/system.js +3 -113
  65. package/dist/lib/external/mcp/handlers/task.d.ts +13 -24
  66. package/dist/lib/external/mcp/handlers/task.js +217 -557
  67. package/dist/lib/external/mcp/handlers/types.d.ts +91 -8
  68. package/dist/lib/external/mcp/handlers/types.js +18 -1
  69. package/dist/lib/external/mcp/handlers/wiki-external.d.ts +18 -1
  70. package/dist/lib/external/mcp/handlers/wiki-external.js +16 -1
  71. package/dist/lib/external/mcp/tools.d.ts +14 -20
  72. package/dist/lib/external/mcp/tools.js +62 -91
  73. package/dist/lib/http/HttpServer.js +52 -6
  74. package/dist/lib/http/routes/{snippets.d.ts → audit.d.ts} +4 -2
  75. package/dist/lib/http/routes/audit.js +51 -0
  76. package/dist/lib/http/routes/commands.d.ts +1 -1
  77. package/dist/lib/http/routes/commands.js +1 -66
  78. package/dist/lib/http/routes/guardReport.d.ts +10 -0
  79. package/dist/lib/http/routes/guardReport.js +143 -0
  80. package/dist/lib/http/routes/knowledge.js +32 -1
  81. package/dist/lib/http/routes/panorama.d.ts +11 -0
  82. package/dist/lib/http/routes/panorama.js +322 -0
  83. package/dist/lib/http/routes/remote.js +0 -5
  84. package/dist/lib/http/routes/signals.d.ts +10 -0
  85. package/dist/lib/http/routes/signals.js +104 -0
  86. package/dist/lib/http/routes/task.d.ts +2 -3
  87. package/dist/lib/http/routes/task.js +17 -347
  88. package/dist/lib/http/routes/violations.js +1 -1
  89. package/dist/lib/infrastructure/audit/AuditLogger.d.ts +6 -1
  90. package/dist/lib/infrastructure/audit/AuditLogger.js +14 -1
  91. package/dist/lib/infrastructure/database/drizzle/schema.d.ts +181 -583
  92. package/dist/lib/infrastructure/database/drizzle/schema.js +28 -69
  93. package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.d.ts +8 -0
  94. package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.js +43 -0
  95. package/dist/lib/infrastructure/logging/Logger.d.ts +2 -0
  96. package/dist/lib/infrastructure/logging/Logger.js +34 -7
  97. package/dist/lib/infrastructure/monitoring/ErrorTracker.js +3 -1
  98. package/dist/lib/infrastructure/monitoring/PerformanceMonitor.d.ts +2 -2
  99. package/dist/lib/infrastructure/monitoring/PerformanceMonitor.js +12 -10
  100. package/dist/lib/infrastructure/notification/LarkNotifier.d.ts +24 -0
  101. package/dist/lib/infrastructure/notification/LarkNotifier.js +97 -0
  102. package/dist/lib/infrastructure/report/ReportStore.d.ts +45 -0
  103. package/dist/lib/infrastructure/report/ReportStore.js +133 -0
  104. package/dist/lib/infrastructure/signal/SignalAggregator.d.ts +18 -0
  105. package/dist/lib/infrastructure/signal/SignalAggregator.js +84 -0
  106. package/dist/lib/infrastructure/signal/SignalBridge.d.ts +13 -0
  107. package/dist/lib/infrastructure/signal/SignalBridge.js +20 -0
  108. package/dist/lib/infrastructure/signal/SignalBus.d.ts +63 -0
  109. package/dist/lib/infrastructure/signal/SignalBus.js +106 -0
  110. package/dist/lib/infrastructure/signal/SignalTraceWriter.d.ts +36 -0
  111. package/dist/lib/infrastructure/signal/SignalTraceWriter.js +130 -0
  112. package/dist/lib/injection/ServiceContainer.js +6 -0
  113. package/dist/lib/injection/ServiceMap.d.ts +16 -19
  114. package/dist/lib/injection/modules/AgentModule.d.ts +1 -1
  115. package/dist/lib/injection/modules/AgentModule.js +7 -1
  116. package/dist/lib/injection/modules/AppModule.d.ts +3 -4
  117. package/dist/lib/injection/modules/AppModule.js +7 -43
  118. package/dist/lib/injection/modules/GuardModule.js +59 -2
  119. package/dist/lib/injection/modules/InfraModule.d.ts +0 -1
  120. package/dist/lib/injection/modules/InfraModule.js +9 -7
  121. package/dist/lib/injection/modules/KnowledgeModule.js +51 -0
  122. package/dist/lib/injection/modules/PanoramaModule.d.ts +18 -0
  123. package/dist/lib/injection/modules/PanoramaModule.js +76 -0
  124. package/dist/lib/injection/modules/SignalModule.d.ts +10 -0
  125. package/dist/lib/injection/modules/SignalModule.js +84 -0
  126. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +1 -0
  127. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +6 -0
  128. package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +3 -1
  129. package/dist/lib/service/bootstrap/BootstrapTaskManager.js +20 -1
  130. package/dist/lib/service/delivery/AgentInstructionsGenerator.js +4 -5
  131. package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +3 -1
  132. package/dist/lib/service/delivery/CursorDeliveryPipeline.js +13 -10
  133. package/dist/lib/service/delivery/RulesGenerator.js +3 -2
  134. package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +114 -0
  135. package/dist/lib/service/evolution/ConsolidationAdvisor.js +542 -0
  136. package/dist/lib/service/evolution/ContradictionDetector.d.ts +54 -0
  137. package/dist/lib/service/evolution/ContradictionDetector.js +253 -0
  138. package/dist/lib/service/evolution/DecayDetector.d.ts +71 -0
  139. package/dist/lib/service/evolution/DecayDetector.js +244 -0
  140. package/dist/lib/service/evolution/EnhancementSuggester.d.ts +38 -0
  141. package/dist/lib/service/evolution/EnhancementSuggester.js +220 -0
  142. package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +82 -0
  143. package/dist/lib/service/evolution/KnowledgeMetabolism.js +167 -0
  144. package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +53 -0
  145. package/dist/lib/service/evolution/RedundancyAnalyzer.js +210 -0
  146. package/dist/lib/service/evolution/StagingManager.d.ts +57 -0
  147. package/dist/lib/service/evolution/StagingManager.js +201 -0
  148. package/dist/lib/service/guard/ComplianceReporter.d.ts +42 -2
  149. package/dist/lib/service/guard/ComplianceReporter.js +43 -5
  150. package/dist/lib/service/guard/CoverageAnalyzer.d.ts +54 -0
  151. package/dist/lib/service/guard/CoverageAnalyzer.js +149 -0
  152. package/dist/lib/service/guard/GuardCheckEngine.d.ts +55 -1
  153. package/dist/lib/service/guard/GuardCheckEngine.js +508 -15
  154. package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -0
  155. package/dist/lib/service/guard/GuardFeedbackLoop.js +9 -0
  156. package/dist/lib/service/guard/ReverseGuard.d.ts +73 -0
  157. package/dist/lib/service/guard/ReverseGuard.js +256 -0
  158. package/dist/lib/service/guard/RuleLearner.d.ts +12 -0
  159. package/dist/lib/service/guard/RuleLearner.js +38 -0
  160. package/dist/lib/service/guard/UncertaintyCollector.d.ts +83 -0
  161. package/dist/lib/service/guard/UncertaintyCollector.js +149 -0
  162. package/dist/lib/service/guard/ViolationsStore.d.ts +1 -0
  163. package/dist/lib/service/guard/ViolationsStore.js +33 -3
  164. package/dist/lib/service/knowledge/ConfidenceRouter.d.ts +13 -0
  165. package/dist/lib/service/knowledge/ConfidenceRouter.js +14 -0
  166. package/dist/lib/service/knowledge/KnowledgeService.js +22 -4
  167. package/dist/lib/service/module/ModuleService.js +3 -13
  168. package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +27 -0
  169. package/dist/lib/service/panorama/CouplingAnalyzer.js +192 -0
  170. package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +28 -0
  171. package/dist/lib/service/panorama/DimensionAnalyzer.js +320 -0
  172. package/dist/lib/service/panorama/LayerInferrer.d.ts +19 -0
  173. package/dist/lib/service/panorama/LayerInferrer.js +182 -0
  174. package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +24 -0
  175. package/dist/lib/service/panorama/ModuleDiscoverer.js +185 -0
  176. package/dist/lib/service/panorama/PanoramaAggregator.d.ts +29 -0
  177. package/dist/lib/service/panorama/PanoramaAggregator.js +228 -0
  178. package/dist/lib/service/panorama/PanoramaScanner.d.ts +52 -0
  179. package/dist/lib/service/panorama/PanoramaScanner.js +188 -0
  180. package/dist/lib/service/panorama/PanoramaService.d.ts +108 -0
  181. package/dist/lib/service/panorama/PanoramaService.js +220 -0
  182. package/dist/lib/service/panorama/PanoramaTypes.d.ts +134 -0
  183. package/dist/lib/service/panorama/PanoramaTypes.js +6 -0
  184. package/dist/lib/service/panorama/RoleRefiner.d.ts +48 -0
  185. package/dist/lib/service/panorama/RoleRefiner.js +535 -0
  186. package/dist/lib/service/search/MultiSignalRanker.d.ts +1 -0
  187. package/dist/lib/service/search/MultiSignalRanker.js +16 -0
  188. package/dist/lib/service/search/SearchEngine.d.ts +1 -0
  189. package/dist/lib/service/search/SearchEngine.js +9 -1
  190. package/dist/lib/service/search/SearchTypes.d.ts +2 -0
  191. package/dist/lib/service/signal/HitRecorder.d.ts +68 -0
  192. package/dist/lib/service/signal/HitRecorder.js +173 -0
  193. package/dist/lib/service/skills/SignalCollector.d.ts +3 -1
  194. package/dist/lib/service/skills/SignalCollector.js +31 -1
  195. package/dist/lib/service/task/IntentExtractor.d.ts +58 -0
  196. package/dist/lib/service/task/IntentExtractor.js +142 -0
  197. package/dist/lib/service/task/PrimeSearchPipeline.d.ts +54 -0
  198. package/dist/lib/service/task/PrimeSearchPipeline.js +98 -0
  199. package/dist/lib/shared/constants.d.ts +0 -15
  200. package/dist/lib/shared/constants.js +0 -10
  201. package/dist/lib/shared/schemas/config.d.ts +4 -1
  202. package/dist/lib/shared/schemas/config.js +8 -1
  203. package/dist/lib/shared/schemas/mcp-tools.d.ts +41 -96
  204. package/dist/lib/shared/schemas/mcp-tools.js +59 -119
  205. package/dist/scripts/analyze-signals.d.ts +20 -0
  206. package/dist/scripts/analyze-signals.js +155 -0
  207. package/dist/scripts/diagnose-mcp.js +1 -1
  208. package/dist/scripts/release.js +2 -10
  209. package/package.json +4 -19
  210. package/skills/autosnippet-devdocs/SKILL.md +11 -8
  211. package/templates/claude-code/hooks/autosnippet-session.sh +10 -15
  212. package/templates/cursor-hooks/hooks/session-start.sh +1 -1
  213. package/templates/instructions/agent-static.md +2 -1
  214. package/templates/instructions/conventions.md +5 -6
  215. package/templates/recipes-setup/README.md +1 -2
  216. package/dashboard/dist/assets/icons-C1dUryS-.js +0 -1
  217. package/dashboard/dist/assets/index-D0whuycy.css +0 -1
  218. package/dashboard/dist/assets/index-DdvZE4Yd.js +0 -128
  219. package/dist/lib/domain/task/Task.d.ts +0 -140
  220. package/dist/lib/domain/task/Task.js +0 -254
  221. package/dist/lib/domain/task/TaskDependency.d.ts +0 -23
  222. package/dist/lib/domain/task/TaskDependency.js +0 -34
  223. package/dist/lib/domain/task/TaskIdGenerator.d.ts +0 -40
  224. package/dist/lib/domain/task/TaskIdGenerator.js +0 -75
  225. package/dist/lib/domain/task/index.d.ts +0 -4
  226. package/dist/lib/domain/task/index.js +0 -4
  227. package/dist/lib/http/routes/snippets.js +0 -49
  228. package/dist/lib/infrastructure/database/migrations/002_add_tasks.d.ts +0 -11
  229. package/dist/lib/infrastructure/database/migrations/002_add_tasks.js +0 -86
  230. package/dist/lib/platform/ClipboardManager.d.ts +0 -24
  231. package/dist/lib/platform/ClipboardManager.js +0 -142
  232. package/dist/lib/platform/NativeUi.d.ts +0 -53
  233. package/dist/lib/platform/NativeUi.js +0 -284
  234. package/dist/lib/platform/ios/index.d.ts +0 -38
  235. package/dist/lib/platform/ios/index.js +0 -42
  236. package/dist/lib/platform/ios/routes/spm.d.ts +0 -9
  237. package/dist/lib/platform/ios/routes/spm.js +0 -371
  238. package/dist/lib/platform/ios/snippet/PlaceholderConverter.d.ts +0 -21
  239. package/dist/lib/platform/ios/snippet/PlaceholderConverter.js +0 -48
  240. package/dist/lib/platform/ios/snippet/XcodeCodec.d.ts +0 -23
  241. package/dist/lib/platform/ios/snippet/XcodeCodec.js +0 -96
  242. package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +0 -56
  243. package/dist/lib/platform/ios/spm/DependencyGraph.js +0 -195
  244. package/dist/lib/platform/ios/spm/PackageSwiftParser.d.ts +0 -69
  245. package/dist/lib/platform/ios/spm/PackageSwiftParser.js +0 -231
  246. package/dist/lib/platform/ios/spm/PathFinder.d.ts +0 -28
  247. package/dist/lib/platform/ios/spm/PathFinder.js +0 -117
  248. package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +0 -44
  249. package/dist/lib/platform/ios/spm/PolicyEngine.js +0 -79
  250. package/dist/lib/platform/ios/spm/SpmHelper.d.ts +0 -102
  251. package/dist/lib/platform/ios/spm/SpmHelper.js +0 -464
  252. package/dist/lib/platform/ios/xcode/HeaderResolver.d.ts +0 -33
  253. package/dist/lib/platform/ios/xcode/HeaderResolver.js +0 -90
  254. package/dist/lib/platform/ios/xcode/SaveEventFilter.d.ts +0 -66
  255. package/dist/lib/platform/ios/xcode/SaveEventFilter.js +0 -142
  256. package/dist/lib/platform/ios/xcode/XcodeAutomation.d.ts +0 -71
  257. package/dist/lib/platform/ios/xcode/XcodeAutomation.js +0 -327
  258. package/dist/lib/platform/ios/xcode/XcodeImportResolver.d.ts +0 -130
  259. package/dist/lib/platform/ios/xcode/XcodeImportResolver.js +0 -404
  260. package/dist/lib/platform/ios/xcode/XcodeIntegration.d.ts +0 -89
  261. package/dist/lib/platform/ios/xcode/XcodeIntegration.js +0 -588
  262. package/dist/lib/platform/ios/xcode/XcodeWriteUtils.d.ts +0 -99
  263. package/dist/lib/platform/ios/xcode/XcodeWriteUtils.js +0 -190
  264. package/dist/lib/repository/task/TaskRepository.impl.d.ts +0 -171
  265. package/dist/lib/repository/task/TaskRepository.impl.js +0 -347
  266. package/dist/lib/service/automation/ActionPipeline.d.ts +0 -34
  267. package/dist/lib/service/automation/ActionPipeline.js +0 -53
  268. package/dist/lib/service/automation/AutomationOrchestrator.d.ts +0 -86
  269. package/dist/lib/service/automation/AutomationOrchestrator.js +0 -57
  270. package/dist/lib/service/automation/ContextCollector.d.ts +0 -24
  271. package/dist/lib/service/automation/ContextCollector.js +0 -35
  272. package/dist/lib/service/automation/DirectiveDetector.d.ts +0 -51
  273. package/dist/lib/service/automation/DirectiveDetector.js +0 -112
  274. package/dist/lib/service/automation/FileWatcher.d.ts +0 -51
  275. package/dist/lib/service/automation/FileWatcher.js +0 -366
  276. package/dist/lib/service/automation/TriggerResolver.d.ts +0 -36
  277. package/dist/lib/service/automation/TriggerResolver.js +0 -62
  278. package/dist/lib/service/automation/handlers/AlinkHandler.d.ts +0 -7
  279. package/dist/lib/service/automation/handlers/AlinkHandler.js +0 -80
  280. package/dist/lib/service/automation/handlers/CreateHandler.d.ts +0 -11
  281. package/dist/lib/service/automation/handlers/CreateHandler.js +0 -170
  282. package/dist/lib/service/automation/handlers/GuardHandler.d.ts +0 -17
  283. package/dist/lib/service/automation/handlers/GuardHandler.js +0 -218
  284. package/dist/lib/service/automation/handlers/HeaderHandler.d.ts +0 -2
  285. package/dist/lib/service/automation/handlers/HeaderHandler.js +0 -32
  286. package/dist/lib/service/automation/handlers/SearchHandler.d.ts +0 -11
  287. package/dist/lib/service/automation/handlers/SearchHandler.js +0 -278
  288. package/dist/lib/service/snippet/SnippetFactory.d.ts +0 -101
  289. package/dist/lib/service/snippet/SnippetFactory.js +0 -145
  290. package/dist/lib/service/snippet/SnippetInstaller.d.ts +0 -91
  291. package/dist/lib/service/snippet/SnippetInstaller.js +0 -276
  292. package/dist/lib/service/snippet/codecs/SnippetCodec.d.ts +0 -44
  293. package/dist/lib/service/snippet/codecs/SnippetCodec.js +0 -35
  294. package/dist/lib/service/snippet/codecs/VSCodeCodec.d.ts +0 -27
  295. package/dist/lib/service/snippet/codecs/VSCodeCodec.js +0 -82
  296. package/dist/lib/service/task/TaskGraphService.d.ts +0 -222
  297. package/dist/lib/service/task/TaskGraphService.js +0 -597
  298. package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +0 -95
  299. package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -298
  300. package/dist/lib/service/task/TaskReadyEngine.d.ts +0 -84
  301. package/dist/lib/service/task/TaskReadyEngine.js +0 -115
  302. package/dist/scripts/build-native-ui.d.ts +0 -3
  303. package/dist/scripts/build-native-ui.js +0 -62
  304. package/dist/scripts/init-snippets.d.ts +0 -30
  305. package/dist/scripts/init-snippets.js +0 -298
  306. package/dist/scripts/install-full.d.ts +0 -7
  307. package/dist/scripts/install-full.js +0 -38
  308. package/resources/native-ui/README.md +0 -29
  309. package/resources/native-ui/combined-window.swift +0 -494
  310. package/resources/native-ui/main.swift +0 -598
  311. package/scripts/postinstall-safe.mjs +0 -89
@@ -0,0 +1,220 @@
1
+ /**
2
+ * EnhancementSuggester — 使用数据反推增强建议
3
+ *
4
+ * 4 种增强策略:
5
+ * ① Guard 频繁命中但无 coreCode → 建议补充代码示例
6
+ * ② Search 高频命中但 adoptions=0 → 建议改善 usageGuide
7
+ * ③ 同类知识中 authority 偏低 → 建议补充 whenClause
8
+ * ④ 关联 Recipe 已 deprecated → 建议检查引用是否过时
9
+ */
10
+ import Logger from '../../infrastructure/logging/Logger.js';
11
+ /* ────────────────────── Constants ────────────────────── */
12
+ const GUARD_HIT_THRESHOLD = 5;
13
+ const SEARCH_HIT_THRESHOLD = 10;
14
+ const LOW_AUTHORITY_PERCENTILE = 0.25;
15
+ /* ────────────────────── Class ────────────────────── */
16
+ export class EnhancementSuggester {
17
+ #db;
18
+ #signalBus;
19
+ #reportStore;
20
+ #logger = Logger.getInstance();
21
+ constructor(db, options = {}) {
22
+ this.#db = db;
23
+ this.#signalBus = options.signalBus ?? null;
24
+ this.#reportStore = options.reportStore ?? null;
25
+ }
26
+ /**
27
+ * 运行全部 4 种增强策略
28
+ */
29
+ analyzeAll() {
30
+ const suggestions = [
31
+ ...this.#checkMissingCodeExamples(),
32
+ ...this.#checkLowAdoption(),
33
+ ...this.#checkLowAuthority(),
34
+ ...this.#checkDeprecatedReferences(),
35
+ ];
36
+ if (this.#reportStore && suggestions.length > 0) {
37
+ void this.#reportStore.write({
38
+ category: 'analysis',
39
+ type: 'enhancement_suggestions',
40
+ producer: 'EnhancementSuggester',
41
+ data: {
42
+ count: suggestions.length,
43
+ byType: this.#countByType(suggestions),
44
+ },
45
+ timestamp: Date.now(),
46
+ });
47
+ }
48
+ this.#logger.info(`EnhancementSuggester: ${suggestions.length} suggestions generated`);
49
+ return suggestions;
50
+ }
51
+ /* ── Strategy ①: Guard 频繁命中但无 coreCode ── */
52
+ #checkMissingCodeExamples() {
53
+ const rows = this.#db
54
+ .prepare(`SELECT id, title, coreCode, stats
55
+ FROM knowledge_entries
56
+ WHERE lifecycle IN ('active', 'staging') AND kind = 'rule'`)
57
+ .all();
58
+ const suggestions = [];
59
+ for (const row of rows) {
60
+ const hasCode = row.coreCode && row.coreCode.trim().length > 10;
61
+ if (hasCode) {
62
+ continue;
63
+ }
64
+ let stats = {};
65
+ try {
66
+ stats = JSON.parse(row.stats || '{}');
67
+ }
68
+ catch {
69
+ continue;
70
+ }
71
+ const guardHits = stats.guardHits || 0;
72
+ if (guardHits >= GUARD_HIT_THRESHOLD) {
73
+ suggestions.push({
74
+ recipeId: row.id,
75
+ title: row.title,
76
+ type: 'missing_code_example',
77
+ description: `Guard 已命中 ${guardHits} 次但无代码示例,建议补充 coreCode 帮助开发者理解正确用法`,
78
+ priority: guardHits >= GUARD_HIT_THRESHOLD * 3 ? 'high' : 'medium',
79
+ evidence: [`guardHits: ${guardHits}`, 'coreCode: empty'],
80
+ });
81
+ }
82
+ }
83
+ return suggestions;
84
+ }
85
+ /* ── Strategy ②: Search 高频命中但 adoptions=0 ── */
86
+ #checkLowAdoption() {
87
+ const rows = this.#db
88
+ .prepare(`SELECT id, title, stats
89
+ FROM knowledge_entries
90
+ WHERE lifecycle IN ('active', 'staging')`)
91
+ .all();
92
+ const suggestions = [];
93
+ for (const row of rows) {
94
+ let stats = {};
95
+ try {
96
+ stats = JSON.parse(row.stats || '{}');
97
+ }
98
+ catch {
99
+ continue;
100
+ }
101
+ const searchHits = stats.searchHits || 0;
102
+ const adoptions = stats.adoptions || 0;
103
+ if (searchHits >= SEARCH_HIT_THRESHOLD && adoptions === 0) {
104
+ suggestions.push({
105
+ recipeId: row.id,
106
+ title: row.title,
107
+ type: 'low_adoption',
108
+ description: `搜索命中 ${searchHits} 次但采纳为 0,建议改善 usageGuide 或 whenClause 使知识更具可操作性`,
109
+ priority: searchHits >= SEARCH_HIT_THRESHOLD * 3 ? 'high' : 'medium',
110
+ evidence: [`searchHits: ${searchHits}`, `adoptions: ${adoptions}`],
111
+ });
112
+ }
113
+ }
114
+ return suggestions;
115
+ }
116
+ /* ── Strategy ③: 同类知识中 authority 偏低 ── */
117
+ #checkLowAuthority() {
118
+ const rows = this.#db
119
+ .prepare(`SELECT id, title, category, stats
120
+ FROM knowledge_entries
121
+ WHERE lifecycle IN ('active', 'staging')`)
122
+ .all();
123
+ // 按 category 分组计算 authority 分位
124
+ const byCategory = new Map();
125
+ for (const row of rows) {
126
+ let stats = {};
127
+ try {
128
+ stats = JSON.parse(row.stats || '{}');
129
+ }
130
+ catch {
131
+ continue;
132
+ }
133
+ const authority = stats.authority || 0;
134
+ const cat = row.category || 'general';
135
+ if (!byCategory.has(cat)) {
136
+ byCategory.set(cat, []);
137
+ }
138
+ byCategory.get(cat).push({ id: row.id, title: row.title, authority });
139
+ }
140
+ const suggestions = [];
141
+ for (const [category, entries] of byCategory) {
142
+ if (entries.length < 3) {
143
+ continue; // 同类太少,无法比较
144
+ }
145
+ const sorted = entries.sort((a, b) => a.authority - b.authority);
146
+ const cutoff = Math.floor(sorted.length * LOW_AUTHORITY_PERCENTILE);
147
+ for (let i = 0; i < cutoff; i++) {
148
+ const entry = sorted[i];
149
+ suggestions.push({
150
+ recipeId: entry.id,
151
+ title: entry.title,
152
+ type: 'low_authority',
153
+ description: `在 "${category}" 类别中 authority 偏低 (${entry.authority}),建议补充 whenClause 和上下文描述`,
154
+ priority: 'low',
155
+ evidence: [
156
+ `authority: ${entry.authority}`,
157
+ `category: ${category}`,
158
+ `rank: ${i + 1}/${sorted.length}`,
159
+ ],
160
+ });
161
+ }
162
+ }
163
+ return suggestions;
164
+ }
165
+ /* ── Strategy ④: 关联 Recipe 已 deprecated ── */
166
+ #checkDeprecatedReferences() {
167
+ const rows = this.#db
168
+ .prepare(`SELECT id, title, relations
169
+ FROM knowledge_entries
170
+ WHERE lifecycle IN ('active', 'staging')`)
171
+ .all();
172
+ const suggestions = [];
173
+ for (const row of rows) {
174
+ let relations = {};
175
+ try {
176
+ relations = JSON.parse(row.relations || '{}');
177
+ }
178
+ catch {
179
+ continue;
180
+ }
181
+ // 检查 related, depends_on 等关系桶中的 ID
182
+ const relatedIds = [];
183
+ for (const [bucket, ids] of Object.entries(relations)) {
184
+ if (bucket === 'deprecated_by') {
185
+ continue; // 自身的 deprecated_by 不算
186
+ }
187
+ if (Array.isArray(ids)) {
188
+ relatedIds.push(...ids);
189
+ }
190
+ }
191
+ if (relatedIds.length === 0) {
192
+ continue;
193
+ }
194
+ // 批量检查关联条目的 lifecycle
195
+ const placeholders = relatedIds.map(() => '?').join(',');
196
+ const deprecated = this.#db
197
+ .prepare(`SELECT id, title FROM knowledge_entries WHERE id IN (${placeholders}) AND lifecycle = 'deprecated'`)
198
+ .all(...relatedIds);
199
+ for (const dep of deprecated) {
200
+ suggestions.push({
201
+ recipeId: row.id,
202
+ title: row.title,
203
+ type: 'deprecated_reference',
204
+ description: `引用了已废弃的 Recipe "${dep.title}" (${dep.id}),建议检查引用是否过时`,
205
+ priority: 'high',
206
+ evidence: [`referenced: ${dep.id}`, `referenced_title: ${dep.title}`],
207
+ });
208
+ }
209
+ }
210
+ return suggestions;
211
+ }
212
+ /* ── Helpers ── */
213
+ #countByType(suggestions) {
214
+ const counts = {};
215
+ for (const s of suggestions) {
216
+ counts[s.type] = (counts[s.type] || 0) + 1;
217
+ }
218
+ return counts;
219
+ }
220
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * KnowledgeMetabolism — 知识新陈代谢总线
3
+ *
4
+ * 治理总线:编排三种进化策略 (矛盾检测 + 冗余分析 + 衰退检测)
5
+ * 产出 EvolutionProposal,通过 ConfidenceRouter + 状态机 驱动转换。
6
+ *
7
+ * 入口:
8
+ * - runFullCycle() — 完整治理周期(日常定时 / 手动触发)
9
+ * - checkDecay() — 只做衰退扫描
10
+ * - checkContradictions() — 只做矛盾检测
11
+ * - checkRedundancy() — 只做冗余分析
12
+ */
13
+ import type { ReportStore } from '../../infrastructure/report/ReportStore.js';
14
+ import type { SignalBus } from '../../infrastructure/signal/SignalBus.js';
15
+ import type { ContradictionDetector, ContradictionResult } from './ContradictionDetector.js';
16
+ import type { DecayDetector, DecayScoreResult } from './DecayDetector.js';
17
+ import type { RedundancyAnalyzer, RedundancyResult } from './RedundancyAnalyzer.js';
18
+ export type ProposalType = 'merge' | 'enhance' | 'refine_guard' | 'split' | 'deprecate' | 'review';
19
+ export interface EvolutionProposal {
20
+ /** 进化提案类型 */
21
+ type: ProposalType;
22
+ /** 目标 Recipe ID */
23
+ targetRecipeId: string;
24
+ /** 关联 Recipe IDs(合并/矛盾对象) */
25
+ relatedRecipeIds: string[];
26
+ /** 置信度 0-1 */
27
+ confidence: number;
28
+ /** 触发来源 */
29
+ source: 'contradiction' | 'redundancy' | 'decay' | 'enhancement';
30
+ /** 描述 */
31
+ description: string;
32
+ /** 原始信号证据 */
33
+ evidence: string[];
34
+ /** 创建时间 */
35
+ proposedAt: number;
36
+ /** 过期时间 (proposedAt + 7d) */
37
+ expiresAt: number;
38
+ }
39
+ export interface MetabolismReport {
40
+ /** 矛盾检测结果 */
41
+ contradictions: ContradictionResult[];
42
+ /** 冗余分析结果 */
43
+ redundancies: RedundancyResult[];
44
+ /** 衰退评估结果 */
45
+ decayResults: DecayScoreResult[];
46
+ /** 生成的进化提案 */
47
+ proposals: EvolutionProposal[];
48
+ /** 统计摘要 */
49
+ summary: {
50
+ totalScanned: number;
51
+ contradictionCount: number;
52
+ redundancyCount: number;
53
+ decayingCount: number;
54
+ proposalCount: number;
55
+ };
56
+ }
57
+ export declare class KnowledgeMetabolism {
58
+ #private;
59
+ constructor(options: {
60
+ contradictionDetector: ContradictionDetector;
61
+ redundancyAnalyzer: RedundancyAnalyzer;
62
+ decayDetector: DecayDetector;
63
+ signalBus?: SignalBus;
64
+ reportStore?: ReportStore;
65
+ });
66
+ /**
67
+ * 执行完整治理周期
68
+ */
69
+ runFullCycle(): MetabolismReport;
70
+ /**
71
+ * 只执行衰退扫描
72
+ */
73
+ checkDecay(): DecayScoreResult[];
74
+ /**
75
+ * 只执行矛盾检测
76
+ */
77
+ checkContradictions(): ContradictionResult[];
78
+ /**
79
+ * 只执行冗余分析
80
+ */
81
+ checkRedundancy(): RedundancyResult[];
82
+ }
@@ -0,0 +1,167 @@
1
+ /**
2
+ * KnowledgeMetabolism — 知识新陈代谢总线
3
+ *
4
+ * 治理总线:编排三种进化策略 (矛盾检测 + 冗余分析 + 衰退检测)
5
+ * 产出 EvolutionProposal,通过 ConfidenceRouter + 状态机 驱动转换。
6
+ *
7
+ * 入口:
8
+ * - runFullCycle() — 完整治理周期(日常定时 / 手动触发)
9
+ * - checkDecay() — 只做衰退扫描
10
+ * - checkContradictions() — 只做矛盾检测
11
+ * - checkRedundancy() — 只做冗余分析
12
+ */
13
+ import Logger from '../../infrastructure/logging/Logger.js';
14
+ /* ────────────────────── Constants ────────────────────── */
15
+ const PROPOSAL_TTL = 7 * 24 * 60 * 60 * 1000; // 7 days
16
+ /* ────────────────────── Class ────────────────────── */
17
+ export class KnowledgeMetabolism {
18
+ #contradictionDetector;
19
+ #redundancyAnalyzer;
20
+ #decayDetector;
21
+ #signalBus;
22
+ #reportStore;
23
+ #logger = Logger.getInstance();
24
+ #pendingTriggers = [];
25
+ #debounceTimer = null;
26
+ constructor(options) {
27
+ this.#contradictionDetector = options.contradictionDetector;
28
+ this.#redundancyAnalyzer = options.redundancyAnalyzer;
29
+ this.#decayDetector = options.decayDetector;
30
+ this.#signalBus = options.signalBus ?? null;
31
+ this.#reportStore = options.reportStore ?? null;
32
+ // Phase 2: 订阅告警型信号,触发代谢周期
33
+ if (this.#signalBus) {
34
+ this.#signalBus.subscribe('decay|quality|anomaly', (signal) => {
35
+ this.#pendingTriggers.push(signal);
36
+ this.#scheduleMetabolism();
37
+ });
38
+ }
39
+ }
40
+ #scheduleMetabolism() {
41
+ if (this.#debounceTimer) {
42
+ return;
43
+ }
44
+ this.#debounceTimer = setTimeout(() => {
45
+ this.#debounceTimer = null;
46
+ if (this.#pendingTriggers.length > 0) {
47
+ this.runFullCycle();
48
+ this.#pendingTriggers = [];
49
+ }
50
+ }, 30_000);
51
+ }
52
+ /**
53
+ * 执行完整治理周期
54
+ */
55
+ runFullCycle() {
56
+ this.#logger.info('KnowledgeMetabolism: starting full governance cycle');
57
+ // 1. 衰退检测
58
+ const decayResults = this.#decayDetector.scanAll();
59
+ // 2. 矛盾检测
60
+ const contradictions = this.#contradictionDetector.detectAll();
61
+ // 3. 冗余分析
62
+ const redundancies = this.#redundancyAnalyzer.analyzeAll();
63
+ // 4. 生成进化提案
64
+ const proposals = [
65
+ ...this.#proposalsFromContradictions(contradictions),
66
+ ...this.#proposalsFromRedundancies(redundancies),
67
+ ...this.#proposalsFromDecay(decayResults),
68
+ ];
69
+ // 5. 写入治理报告(降级:不再发射 Signal,改为 Report)
70
+ if (this.#reportStore && proposals.length > 0) {
71
+ void this.#reportStore.write({
72
+ category: 'governance',
73
+ type: 'metabolism_cycle',
74
+ producer: 'KnowledgeMetabolism',
75
+ data: {
76
+ proposalCount: proposals.length,
77
+ contradictionCount: contradictions.length,
78
+ redundancyCount: redundancies.length,
79
+ decayingCount: decayResults.filter((d) => d.level !== 'healthy' && d.level !== 'watch')
80
+ .length,
81
+ },
82
+ timestamp: Date.now(),
83
+ });
84
+ }
85
+ const report = {
86
+ contradictions,
87
+ redundancies,
88
+ decayResults,
89
+ proposals,
90
+ summary: {
91
+ totalScanned: decayResults.length,
92
+ contradictionCount: contradictions.length,
93
+ redundancyCount: redundancies.length,
94
+ decayingCount: decayResults.filter((d) => d.level !== 'healthy' && d.level !== 'watch')
95
+ .length,
96
+ proposalCount: proposals.length,
97
+ },
98
+ };
99
+ this.#logger.info(`KnowledgeMetabolism: cycle complete — ${report.summary.proposalCount} proposals generated`);
100
+ return report;
101
+ }
102
+ /**
103
+ * 只执行衰退扫描
104
+ */
105
+ checkDecay() {
106
+ return this.#decayDetector.scanAll();
107
+ }
108
+ /**
109
+ * 只执行矛盾检测
110
+ */
111
+ checkContradictions() {
112
+ return this.#contradictionDetector.detectAll();
113
+ }
114
+ /**
115
+ * 只执行冗余分析
116
+ */
117
+ checkRedundancy() {
118
+ return this.#redundancyAnalyzer.analyzeAll();
119
+ }
120
+ /* ── Proposal Generation ── */
121
+ #proposalsFromContradictions(results) {
122
+ const now = Date.now();
123
+ return results.map((r) => ({
124
+ type: r.type === 'hard' ? 'merge' : 'review',
125
+ targetRecipeId: r.recipeA,
126
+ relatedRecipeIds: [r.recipeB],
127
+ confidence: r.confidence,
128
+ source: 'contradiction',
129
+ description: `${r.type === 'hard' ? 'Hard' : 'Soft'} contradiction detected between recipes`,
130
+ evidence: r.evidence,
131
+ proposedAt: now,
132
+ expiresAt: now + PROPOSAL_TTL,
133
+ }));
134
+ }
135
+ #proposalsFromRedundancies(results) {
136
+ const now = Date.now();
137
+ return results.map((r) => ({
138
+ type: 'merge',
139
+ targetRecipeId: r.recipeA,
140
+ relatedRecipeIds: [r.recipeB],
141
+ confidence: r.similarity,
142
+ source: 'redundancy',
143
+ description: `Redundant content detected (similarity: ${(r.similarity * 100).toFixed(0)}%)`,
144
+ evidence: Object.entries(r.dimensions)
145
+ .filter(([, v]) => v > 0)
146
+ .map(([k, v]) => `${k}: ${(v * 100).toFixed(0)}%`),
147
+ proposedAt: now,
148
+ expiresAt: now + PROPOSAL_TTL,
149
+ }));
150
+ }
151
+ #proposalsFromDecay(results) {
152
+ const now = Date.now();
153
+ return results
154
+ .filter((r) => r.level === 'decaying' || r.level === 'severe' || r.level === 'dead')
155
+ .map((r) => ({
156
+ type: 'deprecate',
157
+ targetRecipeId: r.recipeId,
158
+ relatedRecipeIds: [],
159
+ confidence: Math.max(0.4, 1 - r.decayScore / 100),
160
+ source: 'decay',
161
+ description: `Decay detected: score=${r.decayScore}, level=${r.level}`,
162
+ evidence: r.signals.map((s) => `${s.strategy}: ${s.detail}`),
163
+ proposedAt: now,
164
+ expiresAt: now + PROPOSAL_TTL,
165
+ }));
166
+ }
167
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * RedundancyAnalyzer — 多维冗余检测
3
+ *
4
+ * 从 CandidateAggregator 的标题 Jaccard 扩展到四维内容级相似度:
5
+ * 维度 1: title Jaccard ≥ 0.7
6
+ * 维度 2: doClause + dontClause 文本相似度 ≥ 0.6
7
+ * 维度 3: coreCode 去空白后字符级相似度 ≥ 0.8
8
+ * 维度 4: guard regex 完全相同
9
+ *
10
+ * 综合: weighted_sum(0.2*d1 + 0.3*d2 + 0.3*d3 + 0.2*d4) ≥ 0.65
11
+ */
12
+ import type { ReportStore } from '../../infrastructure/report/ReportStore.js';
13
+ import type { SignalBus } from '../../infrastructure/signal/SignalBus.js';
14
+ interface DatabaseLike {
15
+ prepare(sql: string): {
16
+ all(...params: unknown[]): Record<string, unknown>[];
17
+ };
18
+ }
19
+ export interface RedundancyResult {
20
+ recipeA: string;
21
+ recipeB: string;
22
+ similarity: number;
23
+ dimensions: {
24
+ title: number;
25
+ clause: number;
26
+ code: number;
27
+ guard: number;
28
+ };
29
+ }
30
+ interface RecipeForRedundancy {
31
+ id: string;
32
+ title: string;
33
+ doClause: string | null;
34
+ dontClause: string | null;
35
+ coreCode: string | null;
36
+ guardPattern: string | null;
37
+ }
38
+ export declare class RedundancyAnalyzer {
39
+ #private;
40
+ constructor(db: DatabaseLike, options?: {
41
+ signalBus?: SignalBus;
42
+ reportStore?: ReportStore;
43
+ });
44
+ /**
45
+ * 分析所有 active/staging 条目之间的冗余
46
+ */
47
+ analyzeAll(): RedundancyResult[];
48
+ /**
49
+ * 分析两条 Recipe 的冗余度
50
+ */
51
+ analyzePair(a: RecipeForRedundancy, b: RecipeForRedundancy): RedundancyResult | null;
52
+ }
53
+ export {};