@vpxa/aikit 0.1.59 → 0.1.60

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 (553) hide show
  1. package/README.md +38 -3
  2. package/package.json +2 -1
  3. package/packages/aikit-client/dist/index.d.ts +146 -4
  4. package/packages/aikit-client/dist/index.js +5 -1
  5. package/packages/analyzers/dist/index.d.ts +309 -11
  6. package/packages/analyzers/dist/index.js +54 -1
  7. package/packages/chunker/dist/index.d.ts +451 -18
  8. package/packages/chunker/dist/index.js +24 -1
  9. package/packages/cli/dist/{commands/init/constants.js → constants-D3v4VDf0.js} +1 -1
  10. package/packages/cli/dist/index.js +15 -2
  11. package/packages/cli/dist/init-D0CiV9PX.js +7 -0
  12. package/packages/cli/dist/scaffold-CJwkHf-q.js +2 -0
  13. package/packages/cli/dist/{commands/init/templates.js → templates-DJ7EC5vw.js} +1 -1
  14. package/packages/cli/dist/user-HmJYNt5b.js +5 -0
  15. package/packages/core/dist/index.d.ts +357 -6
  16. package/packages/core/dist/index.js +1 -1
  17. package/packages/dashboard/dist/assets/{index-Cdke3KDK.js → index-C6D-PCp0.js} +7 -7
  18. package/packages/dashboard/dist/assets/index-C6D-PCp0.js.map +1 -0
  19. package/packages/dashboard/dist/index.html +1 -1
  20. package/packages/elicitation/dist/index.d.ts +139 -4
  21. package/packages/elicitation/dist/index.js +1 -1
  22. package/packages/embeddings/dist/index.d.ts +45 -2
  23. package/packages/embeddings/dist/index.js +1 -1
  24. package/packages/enterprise-bridge/dist/index.d.ts +275 -7
  25. package/packages/enterprise-bridge/dist/index.js +1 -1
  26. package/packages/flows/dist/index.d.ts +345 -12
  27. package/packages/flows/dist/index.js +15 -1
  28. package/packages/indexer/dist/index.d.ts +196 -6
  29. package/packages/indexer/dist/index.js +1 -1
  30. package/packages/present/dist/index.html +314 -313
  31. package/packages/server/dist/curated-manager-DX-_oJg0.js +5 -0
  32. package/packages/server/dist/index.d.ts +139 -1
  33. package/packages/server/dist/index.js +1 -1
  34. package/packages/server/dist/server-eMZ64H9b.js +1274 -0
  35. package/packages/store/dist/index.d.ts +316 -5
  36. package/packages/store/dist/index.js +90 -1
  37. package/packages/store/dist/lance-store-jdHZp-V4.js +1 -0
  38. package/packages/tools/dist/index.d.ts +2161 -61
  39. package/packages/tools/dist/index.js +117 -1
  40. package/packages/tui/dist/{App-CoMyn2kt.js → App-DobfqTPH.js} +1 -1
  41. package/packages/tui/dist/App.d.ts +1 -1
  42. package/packages/tui/dist/App.js +1 -1
  43. package/packages/tui/dist/{LogPanel-CDItCD0E.js → LogPanel-DGeptKim.js} +3 -3
  44. package/packages/tui/dist/hooks/useKBClient.d.ts +1 -1
  45. package/packages/tui/dist/{index-MXJeXmCf.d.ts → index-floZQwfo.d.ts} +2 -1
  46. package/packages/tui/dist/index.d.ts +1 -1
  47. package/packages/tui/dist/index.js +1 -1
  48. package/packages/tui/dist/panels/LogPanel.js +1 -1
  49. package/scaffold/definitions/bodies.mjs +47 -0
  50. package/scaffold/definitions/protocols.mjs +9 -0
  51. package/scaffold/definitions/tools.mjs +15 -0
  52. package/scaffold/general/agents/Debugger.agent.md +9 -0
  53. package/scaffold/general/agents/Documenter.agent.md +9 -0
  54. package/scaffold/general/agents/Frontend.agent.md +9 -0
  55. package/scaffold/general/agents/Implementer.agent.md +9 -0
  56. package/scaffold/general/agents/Orchestrator.agent.md +47 -0
  57. package/scaffold/general/agents/Planner.agent.md +9 -0
  58. package/scaffold/general/agents/Refactor.agent.md +9 -0
  59. package/scaffold/general/agents/Security.agent.md +9 -0
  60. package/scaffold/general/agents/_shared/code-agent-base.md +9 -0
  61. package/scaffold/general/skills/aikit/SKILL.md +71 -7
  62. package/packages/aikit-client/dist/direct-client.d.ts +0 -37
  63. package/packages/aikit-client/dist/direct-client.js +0 -1
  64. package/packages/aikit-client/dist/mcp-client.d.ts +0 -19
  65. package/packages/aikit-client/dist/mcp-client.js +0 -4
  66. package/packages/aikit-client/dist/parsers.d.ts +0 -35
  67. package/packages/aikit-client/dist/parsers.js +0 -2
  68. package/packages/aikit-client/dist/types.d.ts +0 -62
  69. package/packages/aikit-client/dist/types.js +0 -1
  70. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +0 -19
  71. package/packages/analyzers/dist/blast-radius-analyzer.js +0 -6
  72. package/packages/analyzers/dist/dependency-analyzer.d.ts +0 -32
  73. package/packages/analyzers/dist/dependency-analyzer.js +0 -8
  74. package/packages/analyzers/dist/diagram-generator.d.ts +0 -16
  75. package/packages/analyzers/dist/diagram-generator.js +0 -2
  76. package/packages/analyzers/dist/entry-point-analyzer.d.ts +0 -40
  77. package/packages/analyzers/dist/entry-point-analyzer.js +0 -4
  78. package/packages/analyzers/dist/knowledge-producer.d.ts +0 -40
  79. package/packages/analyzers/dist/knowledge-producer.js +0 -26
  80. package/packages/analyzers/dist/pattern-analyzer.d.ts +0 -15
  81. package/packages/analyzers/dist/pattern-analyzer.js +0 -2
  82. package/packages/analyzers/dist/regex-call-graph.d.ts +0 -10
  83. package/packages/analyzers/dist/regex-call-graph.js +0 -1
  84. package/packages/analyzers/dist/structure-analyzer.d.ts +0 -19
  85. package/packages/analyzers/dist/structure-analyzer.js +0 -4
  86. package/packages/analyzers/dist/symbol-analyzer.d.ts +0 -14
  87. package/packages/analyzers/dist/symbol-analyzer.js +0 -9
  88. package/packages/analyzers/dist/ts-call-graph.d.ts +0 -29
  89. package/packages/analyzers/dist/ts-call-graph.js +0 -1
  90. package/packages/analyzers/dist/types.d.ts +0 -110
  91. package/packages/analyzers/dist/types.js +0 -1
  92. package/packages/chunker/dist/call-graph-extractor.d.ts +0 -25
  93. package/packages/chunker/dist/call-graph-extractor.js +0 -1
  94. package/packages/chunker/dist/chunker-factory.d.ts +0 -19
  95. package/packages/chunker/dist/chunker-factory.js +0 -1
  96. package/packages/chunker/dist/chunker.interface.d.ts +0 -13
  97. package/packages/chunker/dist/chunker.interface.js +0 -1
  98. package/packages/chunker/dist/code-chunker.d.ts +0 -17
  99. package/packages/chunker/dist/code-chunker.js +0 -11
  100. package/packages/chunker/dist/extractors/call-extractor.d.ts +0 -24
  101. package/packages/chunker/dist/extractors/call-extractor.js +0 -1
  102. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +0 -14
  103. package/packages/chunker/dist/extractors/entry-point-detector.js +0 -1
  104. package/packages/chunker/dist/extractors/import-extractor.d.ts +0 -14
  105. package/packages/chunker/dist/extractors/import-extractor.js +0 -1
  106. package/packages/chunker/dist/extractors/pattern-detector.d.ts +0 -14
  107. package/packages/chunker/dist/extractors/pattern-detector.js +0 -1
  108. package/packages/chunker/dist/extractors/scope-resolver.d.ts +0 -26
  109. package/packages/chunker/dist/extractors/scope-resolver.js +0 -1
  110. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +0 -14
  111. package/packages/chunker/dist/extractors/symbol-extractor.js +0 -3
  112. package/packages/chunker/dist/extractors/types.d.ts +0 -44
  113. package/packages/chunker/dist/extractors/types.js +0 -1
  114. package/packages/chunker/dist/generic-chunker.d.ts +0 -15
  115. package/packages/chunker/dist/generic-chunker.js +0 -5
  116. package/packages/chunker/dist/markdown-chunker.d.ts +0 -17
  117. package/packages/chunker/dist/markdown-chunker.js +0 -3
  118. package/packages/chunker/dist/wasm/languages.d.ts +0 -18
  119. package/packages/chunker/dist/wasm/languages.js +0 -1
  120. package/packages/chunker/dist/wasm/query-executor.d.ts +0 -70
  121. package/packages/chunker/dist/wasm/query-executor.js +0 -1
  122. package/packages/chunker/dist/wasm/runtime.d.ts +0 -44
  123. package/packages/chunker/dist/wasm/runtime.js +0 -1
  124. package/packages/chunker/dist/wasm/types.d.ts +0 -84
  125. package/packages/chunker/dist/wasm/types.js +0 -1
  126. package/packages/chunker/dist/wasm-chunker.d.ts +0 -23
  127. package/packages/chunker/dist/wasm-chunker.js +0 -6
  128. package/packages/cli/dist/aikit-init.d.ts +0 -59
  129. package/packages/cli/dist/aikit-init.js +0 -1
  130. package/packages/cli/dist/commands/analyze.d.ts +0 -6
  131. package/packages/cli/dist/commands/analyze.js +0 -2
  132. package/packages/cli/dist/commands/context-cmds.d.ts +0 -6
  133. package/packages/cli/dist/commands/context-cmds.js +0 -1
  134. package/packages/cli/dist/commands/environment.d.ts +0 -6
  135. package/packages/cli/dist/commands/environment.js +0 -1
  136. package/packages/cli/dist/commands/execution.d.ts +0 -6
  137. package/packages/cli/dist/commands/execution.js +0 -1
  138. package/packages/cli/dist/commands/flow.d.ts +0 -6
  139. package/packages/cli/dist/commands/flow.js +0 -1
  140. package/packages/cli/dist/commands/graph.d.ts +0 -6
  141. package/packages/cli/dist/commands/graph.js +0 -6
  142. package/packages/cli/dist/commands/init/adapters.d.ts +0 -28
  143. package/packages/cli/dist/commands/init/adapters.js +0 -1
  144. package/packages/cli/dist/commands/init/config.d.ts +0 -10
  145. package/packages/cli/dist/commands/init/config.js +0 -3
  146. package/packages/cli/dist/commands/init/constants.d.ts +0 -46
  147. package/packages/cli/dist/commands/init/curated.d.ts +0 -7
  148. package/packages/cli/dist/commands/init/curated.js +0 -1
  149. package/packages/cli/dist/commands/init/frontmatter.d.ts +0 -79
  150. package/packages/cli/dist/commands/init/frontmatter.js +0 -2
  151. package/packages/cli/dist/commands/init/index.d.ts +0 -36
  152. package/packages/cli/dist/commands/init/index.js +0 -5
  153. package/packages/cli/dist/commands/init/manifest.d.ts +0 -72
  154. package/packages/cli/dist/commands/init/manifest.js +0 -1
  155. package/packages/cli/dist/commands/init/scaffold.d.ts +0 -58
  156. package/packages/cli/dist/commands/init/scaffold.js +0 -1
  157. package/packages/cli/dist/commands/init/templates.d.ts +0 -9
  158. package/packages/cli/dist/commands/init/user.d.ts +0 -61
  159. package/packages/cli/dist/commands/init/user.js +0 -5
  160. package/packages/cli/dist/commands/knowledge.d.ts +0 -6
  161. package/packages/cli/dist/commands/knowledge.js +0 -1
  162. package/packages/cli/dist/commands/search.d.ts +0 -6
  163. package/packages/cli/dist/commands/search.js +0 -1
  164. package/packages/cli/dist/commands/system.d.ts +0 -6
  165. package/packages/cli/dist/commands/system.js +0 -4
  166. package/packages/cli/dist/commands/upgrade.d.ts +0 -6
  167. package/packages/cli/dist/commands/upgrade.js +0 -1
  168. package/packages/cli/dist/commands/workspace.d.ts +0 -6
  169. package/packages/cli/dist/commands/workspace.js +0 -1
  170. package/packages/cli/dist/context.d.ts +0 -7
  171. package/packages/cli/dist/context.js +0 -1
  172. package/packages/cli/dist/helpers.d.ts +0 -55
  173. package/packages/cli/dist/helpers.js +0 -5
  174. package/packages/cli/dist/types.d.ts +0 -9
  175. package/packages/cli/dist/types.js +0 -1
  176. package/packages/core/dist/constants.d.ts +0 -74
  177. package/packages/core/dist/constants.js +0 -1
  178. package/packages/core/dist/content-detector.d.ts +0 -13
  179. package/packages/core/dist/content-detector.js +0 -1
  180. package/packages/core/dist/errors.d.ts +0 -20
  181. package/packages/core/dist/errors.js +0 -1
  182. package/packages/core/dist/global-registry.d.ts +0 -69
  183. package/packages/core/dist/global-registry.js +0 -1
  184. package/packages/core/dist/logger.d.ts +0 -32
  185. package/packages/core/dist/logger.js +0 -1
  186. package/packages/core/dist/types.d.ts +0 -149
  187. package/packages/core/dist/types.js +0 -1
  188. package/packages/dashboard/dist/assets/index-Cdke3KDK.js.map +0 -1
  189. package/packages/elicitation/dist/build.d.ts +0 -14
  190. package/packages/elicitation/dist/build.js +0 -1
  191. package/packages/elicitation/dist/fields.d.ts +0 -32
  192. package/packages/elicitation/dist/fields.js +0 -1
  193. package/packages/elicitation/dist/normalize.d.ts +0 -15
  194. package/packages/elicitation/dist/normalize.js +0 -1
  195. package/packages/elicitation/dist/types.d.ts +0 -88
  196. package/packages/elicitation/dist/types.js +0 -1
  197. package/packages/embeddings/dist/embedder.interface.d.ts +0 -26
  198. package/packages/embeddings/dist/embedder.interface.js +0 -1
  199. package/packages/embeddings/dist/onnx-embedder.d.ts +0 -23
  200. package/packages/embeddings/dist/onnx-embedder.js +0 -1
  201. package/packages/enterprise-bridge/dist/cache.d.ts +0 -28
  202. package/packages/enterprise-bridge/dist/cache.js +0 -1
  203. package/packages/enterprise-bridge/dist/er-client.d.ts +0 -37
  204. package/packages/enterprise-bridge/dist/er-client.js +0 -1
  205. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +0 -62
  206. package/packages/enterprise-bridge/dist/evolution-collector.js +0 -1
  207. package/packages/enterprise-bridge/dist/policy-store.d.ts +0 -45
  208. package/packages/enterprise-bridge/dist/policy-store.js +0 -1
  209. package/packages/enterprise-bridge/dist/push-adapter.d.ts +0 -23
  210. package/packages/enterprise-bridge/dist/push-adapter.js +0 -1
  211. package/packages/enterprise-bridge/dist/result-merger.d.ts +0 -14
  212. package/packages/enterprise-bridge/dist/result-merger.js +0 -1
  213. package/packages/enterprise-bridge/dist/types.d.ts +0 -81
  214. package/packages/enterprise-bridge/dist/types.js +0 -1
  215. package/packages/flows/dist/adapters/claude-plugin.d.ts +0 -25
  216. package/packages/flows/dist/adapters/claude-plugin.js +0 -3
  217. package/packages/flows/dist/adapters/copilot.d.ts +0 -12
  218. package/packages/flows/dist/adapters/copilot.js +0 -1
  219. package/packages/flows/dist/adapters/index.d.ts +0 -12
  220. package/packages/flows/dist/adapters/index.js +0 -1
  221. package/packages/flows/dist/adapters/native.d.ts +0 -10
  222. package/packages/flows/dist/adapters/native.js +0 -1
  223. package/packages/flows/dist/adapters/openspec.d.ts +0 -40
  224. package/packages/flows/dist/adapters/openspec.js +0 -1
  225. package/packages/flows/dist/builtins.d.ts +0 -16
  226. package/packages/flows/dist/builtins.js +0 -1
  227. package/packages/flows/dist/foundation.d.ts +0 -20
  228. package/packages/flows/dist/foundation.js +0 -11
  229. package/packages/flows/dist/git.d.ts +0 -53
  230. package/packages/flows/dist/git.js +0 -2
  231. package/packages/flows/dist/loader.d.ts +0 -13
  232. package/packages/flows/dist/loader.js +0 -2
  233. package/packages/flows/dist/registry.d.ts +0 -23
  234. package/packages/flows/dist/registry.js +0 -1
  235. package/packages/flows/dist/state-machine.d.ts +0 -23
  236. package/packages/flows/dist/state-machine.js +0 -1
  237. package/packages/flows/dist/symlinks.d.ts +0 -17
  238. package/packages/flows/dist/symlinks.js +0 -1
  239. package/packages/flows/dist/types.d.ts +0 -127
  240. package/packages/flows/dist/types.js +0 -1
  241. package/packages/indexer/dist/file-hasher.d.ts +0 -13
  242. package/packages/indexer/dist/file-hasher.js +0 -1
  243. package/packages/indexer/dist/filesystem-crawler.d.ts +0 -29
  244. package/packages/indexer/dist/filesystem-crawler.js +0 -1
  245. package/packages/indexer/dist/graph-extractor.d.ts +0 -22
  246. package/packages/indexer/dist/graph-extractor.js +0 -1
  247. package/packages/indexer/dist/hash-cache.d.ts +0 -24
  248. package/packages/indexer/dist/hash-cache.js +0 -1
  249. package/packages/indexer/dist/incremental-indexer.d.ts +0 -73
  250. package/packages/indexer/dist/incremental-indexer.js +0 -1
  251. package/packages/indexer/dist/smart-index-scheduler.d.ts +0 -47
  252. package/packages/indexer/dist/smart-index-scheduler.js +0 -1
  253. package/packages/server/dist/api.d.ts +0 -3
  254. package/packages/server/dist/api.js +0 -1
  255. package/packages/server/dist/auto-gc.d.ts +0 -30
  256. package/packages/server/dist/auto-gc.js +0 -1
  257. package/packages/server/dist/background-task.d.ts +0 -47
  258. package/packages/server/dist/background-task.js +0 -1
  259. package/packages/server/dist/completions.d.ts +0 -14
  260. package/packages/server/dist/completions.js +0 -1
  261. package/packages/server/dist/compression-interceptor.d.ts +0 -12
  262. package/packages/server/dist/compression-interceptor.js +0 -1
  263. package/packages/server/dist/config.d.ts +0 -16
  264. package/packages/server/dist/cross-workspace.d.ts +0 -43
  265. package/packages/server/dist/cross-workspace.js +0 -1
  266. package/packages/server/dist/curated-manager.d.ts +0 -92
  267. package/packages/server/dist/curated-manager.js +0 -5
  268. package/packages/server/dist/dashboard-static.d.ts +0 -27
  269. package/packages/server/dist/elicitor.d.ts +0 -18
  270. package/packages/server/dist/elicitor.js +0 -1
  271. package/packages/server/dist/idle-timer.d.ts +0 -33
  272. package/packages/server/dist/idle-timer.js +0 -1
  273. package/packages/server/dist/mcp-logging.d.ts +0 -11
  274. package/packages/server/dist/mcp-logging.js +0 -1
  275. package/packages/server/dist/memory-monitor.d.ts +0 -37
  276. package/packages/server/dist/memory-monitor.js +0 -1
  277. package/packages/server/dist/output-schemas.d.ts +0 -244
  278. package/packages/server/dist/output-schemas.js +0 -1
  279. package/packages/server/dist/prompts.d.ts +0 -13
  280. package/packages/server/dist/prompts.js +0 -13
  281. package/packages/server/dist/replay-interceptor.d.ts +0 -23
  282. package/packages/server/dist/replay-interceptor.js +0 -1
  283. package/packages/server/dist/resource-links.d.ts +0 -34
  284. package/packages/server/dist/resource-links.js +0 -1
  285. package/packages/server/dist/resources/curated-resources.d.ts +0 -13
  286. package/packages/server/dist/resources/curated-resources.js +0 -2
  287. package/packages/server/dist/resources/resource-notifier.d.ts +0 -45
  288. package/packages/server/dist/resources/resource-notifier.js +0 -1
  289. package/packages/server/dist/resources/resources.d.ts +0 -8
  290. package/packages/server/dist/resources/resources.js +0 -2
  291. package/packages/server/dist/sampling.d.ts +0 -41
  292. package/packages/server/dist/sampling.js +0 -2
  293. package/packages/server/dist/server.d.ts +0 -63
  294. package/packages/server/dist/server.js +0 -3
  295. package/packages/server/dist/structured-content-guard.d.ts +0 -28
  296. package/packages/server/dist/structured-content-guard.js +0 -1
  297. package/packages/server/dist/task-manager.d.ts +0 -40
  298. package/packages/server/dist/task-manager.js +0 -1
  299. package/packages/server/dist/tool-metadata.d.ts +0 -38
  300. package/packages/server/dist/tool-metadata.js +0 -1
  301. package/packages/server/dist/tool-prefix.d.ts +0 -12
  302. package/packages/server/dist/tool-prefix.js +0 -1
  303. package/packages/server/dist/tool-timeout.d.ts +0 -27
  304. package/packages/server/dist/tool-timeout.js +0 -1
  305. package/packages/server/dist/tools/analyze.tools.d.ts +0 -14
  306. package/packages/server/dist/tools/analyze.tools.js +0 -8
  307. package/packages/server/dist/tools/audit.tool.d.ts +0 -8
  308. package/packages/server/dist/tools/audit.tool.js +0 -1
  309. package/packages/server/dist/tools/brainstorm.tool.d.ts +0 -7
  310. package/packages/server/dist/tools/brainstorm.tool.js +0 -9
  311. package/packages/server/dist/tools/bridge.tools.d.ts +0 -34
  312. package/packages/server/dist/tools/bridge.tools.js +0 -15
  313. package/packages/server/dist/tools/config.tool.d.ts +0 -8
  314. package/packages/server/dist/tools/config.tool.js +0 -12
  315. package/packages/server/dist/tools/context.tools.d.ts +0 -15
  316. package/packages/server/dist/tools/context.tools.js +0 -10
  317. package/packages/server/dist/tools/evolution.tools.d.ts +0 -7
  318. package/packages/server/dist/tools/evolution.tools.js +0 -5
  319. package/packages/server/dist/tools/execution.tools.d.ts +0 -14
  320. package/packages/server/dist/tools/execution.tools.js +0 -4
  321. package/packages/server/dist/tools/flow.tools.d.ts +0 -7
  322. package/packages/server/dist/tools/flow.tools.js +0 -16
  323. package/packages/server/dist/tools/forge.tools.d.ts +0 -13
  324. package/packages/server/dist/tools/forge.tools.js +0 -10
  325. package/packages/server/dist/tools/forget.tool.d.ts +0 -8
  326. package/packages/server/dist/tools/forget.tool.js +0 -1
  327. package/packages/server/dist/tools/graph.tool.d.ts +0 -7
  328. package/packages/server/dist/tools/graph.tool.js +0 -29
  329. package/packages/server/dist/tools/infra.tools.d.ts +0 -10
  330. package/packages/server/dist/tools/infra.tools.js +0 -5
  331. package/packages/server/dist/tools/list.tool.d.ts +0 -7
  332. package/packages/server/dist/tools/list.tool.js +0 -2
  333. package/packages/server/dist/tools/lookup.tool.d.ts +0 -7
  334. package/packages/server/dist/tools/lookup.tool.js +0 -3
  335. package/packages/server/dist/tools/manipulation.tools.d.ts +0 -10
  336. package/packages/server/dist/tools/manipulation.tools.js +0 -4
  337. package/packages/server/dist/tools/onboard.tool.d.ts +0 -12
  338. package/packages/server/dist/tools/onboard.tool.js +0 -2
  339. package/packages/server/dist/tools/persistence.tools.d.ts +0 -10
  340. package/packages/server/dist/tools/persistence.tools.js +0 -5
  341. package/packages/server/dist/tools/policy.tools.d.ts +0 -7
  342. package/packages/server/dist/tools/policy.tools.js +0 -3
  343. package/packages/server/dist/tools/present/browser.d.ts +0 -4
  344. package/packages/server/dist/tools/present/browser.js +0 -93
  345. package/packages/server/dist/tools/present/helpers.d.ts +0 -19
  346. package/packages/server/dist/tools/present/helpers.js +0 -16
  347. package/packages/server/dist/tools/present/html.d.ts +0 -18
  348. package/packages/server/dist/tools/present/html.js +0 -5
  349. package/packages/server/dist/tools/present/index.d.ts +0 -2
  350. package/packages/server/dist/tools/present/index.js +0 -1
  351. package/packages/server/dist/tools/present/markdown.d.ts +0 -32
  352. package/packages/server/dist/tools/present/markdown.js +0 -11
  353. package/packages/server/dist/tools/present/templates.d.ts +0 -14
  354. package/packages/server/dist/tools/present/templates.js +0 -472
  355. package/packages/server/dist/tools/present/tool.d.ts +0 -27
  356. package/packages/server/dist/tools/present/tool.js +0 -39
  357. package/packages/server/dist/tools/present-blocks.d.ts +0 -46
  358. package/packages/server/dist/tools/present-blocks.js +0 -27
  359. package/packages/server/dist/tools/present-charts.d.ts +0 -31
  360. package/packages/server/dist/tools/present-charts.js +0 -34
  361. package/packages/server/dist/tools/present-theme.d.ts +0 -14
  362. package/packages/server/dist/tools/present-theme.js +0 -396
  363. package/packages/server/dist/tools/present-utils.d.ts +0 -11
  364. package/packages/server/dist/tools/present-utils.js +0 -1
  365. package/packages/server/dist/tools/present.tool.d.ts +0 -2
  366. package/packages/server/dist/tools/present.tool.js +0 -1
  367. package/packages/server/dist/tools/produce.tool.d.ts +0 -7
  368. package/packages/server/dist/tools/produce.tool.js +0 -4
  369. package/packages/server/dist/tools/read.tool.d.ts +0 -7
  370. package/packages/server/dist/tools/read.tool.js +0 -2
  371. package/packages/server/dist/tools/reindex.tool.d.ts +0 -11
  372. package/packages/server/dist/tools/reindex.tool.js +0 -9
  373. package/packages/server/dist/tools/remember.tool.d.ts +0 -9
  374. package/packages/server/dist/tools/remember.tool.js +0 -4
  375. package/packages/server/dist/tools/replay.tool.d.ts +0 -6
  376. package/packages/server/dist/tools/replay.tool.js +0 -3
  377. package/packages/server/dist/tools/restore.tool.d.ts +0 -6
  378. package/packages/server/dist/tools/restore.tool.js +0 -3
  379. package/packages/server/dist/tools/search.tool.d.ts +0 -11
  380. package/packages/server/dist/tools/search.tool.js +0 -10
  381. package/packages/server/dist/tools/status.tool.d.ts +0 -28
  382. package/packages/server/dist/tools/status.tool.js +0 -3
  383. package/packages/server/dist/tools/update.tool.d.ts +0 -8
  384. package/packages/server/dist/tools/update.tool.js +0 -1
  385. package/packages/server/dist/tools/utility.tools.d.ts +0 -15
  386. package/packages/server/dist/tools/utility.tools.js +0 -13
  387. package/packages/server/dist/version-check.d.ts +0 -32
  388. package/packages/store/dist/graph-store.interface.d.ts +0 -159
  389. package/packages/store/dist/graph-store.interface.js +0 -1
  390. package/packages/store/dist/lance-store.d.ts +0 -46
  391. package/packages/store/dist/lance-store.js +0 -1
  392. package/packages/store/dist/sqlite-graph-store.d.ts +0 -57
  393. package/packages/store/dist/sqlite-graph-store.js +0 -90
  394. package/packages/store/dist/store-factory.d.ts +0 -12
  395. package/packages/store/dist/store-factory.js +0 -1
  396. package/packages/store/dist/store.interface.d.ts +0 -54
  397. package/packages/store/dist/store.interface.js +0 -1
  398. package/packages/tools/dist/audit.d.ts +0 -65
  399. package/packages/tools/dist/audit.js +0 -6
  400. package/packages/tools/dist/batch.d.ts +0 -23
  401. package/packages/tools/dist/batch.js +0 -1
  402. package/packages/tools/dist/changelog.d.ts +0 -36
  403. package/packages/tools/dist/changelog.js +0 -2
  404. package/packages/tools/dist/check.d.ts +0 -48
  405. package/packages/tools/dist/check.js +0 -2
  406. package/packages/tools/dist/checkpoint.d.ts +0 -19
  407. package/packages/tools/dist/checkpoint.js +0 -1
  408. package/packages/tools/dist/codemod.d.ts +0 -39
  409. package/packages/tools/dist/codemod.js +0 -2
  410. package/packages/tools/dist/compact.d.ts +0 -47
  411. package/packages/tools/dist/compact.js +0 -3
  412. package/packages/tools/dist/compress-output.d.ts +0 -38
  413. package/packages/tools/dist/compress-output.js +0 -1
  414. package/packages/tools/dist/compression/delta-cache.d.ts +0 -29
  415. package/packages/tools/dist/compression/delta-cache.js +0 -1
  416. package/packages/tools/dist/compression/engine.d.ts +0 -34
  417. package/packages/tools/dist/compression/engine.js +0 -4
  418. package/packages/tools/dist/compression/litm.d.ts +0 -20
  419. package/packages/tools/dist/compression/litm.js +0 -1
  420. package/packages/tools/dist/compression/mmr.d.ts +0 -24
  421. package/packages/tools/dist/compression/mmr.js +0 -1
  422. package/packages/tools/dist/compression/rules/docker.d.ts +0 -11
  423. package/packages/tools/dist/compression/rules/docker.js +0 -3
  424. package/packages/tools/dist/compression/rules/generic.d.ts +0 -11
  425. package/packages/tools/dist/compression/rules/generic.js +0 -3
  426. package/packages/tools/dist/compression/rules/git.d.ts +0 -11
  427. package/packages/tools/dist/compression/rules/git.js +0 -3
  428. package/packages/tools/dist/compression/rules/index.d.ts +0 -14
  429. package/packages/tools/dist/compression/rules/index.js +0 -1
  430. package/packages/tools/dist/compression/rules/kubectl.d.ts +0 -11
  431. package/packages/tools/dist/compression/rules/kubectl.js +0 -3
  432. package/packages/tools/dist/compression/rules/lint.d.ts +0 -11
  433. package/packages/tools/dist/compression/rules/lint.js +0 -3
  434. package/packages/tools/dist/compression/rules/npm.d.ts +0 -11
  435. package/packages/tools/dist/compression/rules/npm.js +0 -3
  436. package/packages/tools/dist/compression/rules/test-runner.d.ts +0 -11
  437. package/packages/tools/dist/compression/rules/test-runner.js +0 -3
  438. package/packages/tools/dist/compression/scoring.d.ts +0 -26
  439. package/packages/tools/dist/compression/scoring.js +0 -1
  440. package/packages/tools/dist/compression/types.d.ts +0 -61
  441. package/packages/tools/dist/compression/types.js +0 -1
  442. package/packages/tools/dist/config-extractor.d.ts +0 -9
  443. package/packages/tools/dist/config-extractor.js +0 -7
  444. package/packages/tools/dist/data-transform.d.ts +0 -12
  445. package/packages/tools/dist/data-transform.js +0 -1
  446. package/packages/tools/dist/dead-symbols.d.ts +0 -28
  447. package/packages/tools/dist/dead-symbols.js +0 -2
  448. package/packages/tools/dist/delegate.d.ts +0 -36
  449. package/packages/tools/dist/delegate.js +0 -1
  450. package/packages/tools/dist/diagram-builder.d.ts +0 -9
  451. package/packages/tools/dist/diagram-builder.js +0 -9
  452. package/packages/tools/dist/diff-parse.d.ts +0 -28
  453. package/packages/tools/dist/diff-parse.js +0 -3
  454. package/packages/tools/dist/digest.d.ts +0 -55
  455. package/packages/tools/dist/digest.js +0 -6
  456. package/packages/tools/dist/dogfood-log.d.ts +0 -49
  457. package/packages/tools/dist/dogfood-log.js +0 -2
  458. package/packages/tools/dist/encode.d.ts +0 -16
  459. package/packages/tools/dist/encode.js +0 -1
  460. package/packages/tools/dist/env-info.d.ts +0 -30
  461. package/packages/tools/dist/env-info.js +0 -1
  462. package/packages/tools/dist/eval.d.ts +0 -15
  463. package/packages/tools/dist/eval.js +0 -2
  464. package/packages/tools/dist/evidence-map.d.ts +0 -92
  465. package/packages/tools/dist/evidence-map.js +0 -2
  466. package/packages/tools/dist/file-cache.d.ts +0 -41
  467. package/packages/tools/dist/file-cache.js +0 -3
  468. package/packages/tools/dist/file-summary.d.ts +0 -52
  469. package/packages/tools/dist/file-summary.js +0 -2
  470. package/packages/tools/dist/file-walk.d.ts +0 -6
  471. package/packages/tools/dist/file-walk.js +0 -1
  472. package/packages/tools/dist/find-examples.d.ts +0 -29
  473. package/packages/tools/dist/find-examples.js +0 -3
  474. package/packages/tools/dist/find.d.ts +0 -49
  475. package/packages/tools/dist/find.js +0 -1
  476. package/packages/tools/dist/forge-classify.d.ts +0 -44
  477. package/packages/tools/dist/forge-classify.js +0 -2
  478. package/packages/tools/dist/forge-ground.d.ts +0 -61
  479. package/packages/tools/dist/forge-ground.js +0 -1
  480. package/packages/tools/dist/git-context.d.ts +0 -25
  481. package/packages/tools/dist/git-context.js +0 -3
  482. package/packages/tools/dist/graph-query.d.ts +0 -98
  483. package/packages/tools/dist/graph-query.js +0 -1
  484. package/packages/tools/dist/guide.d.ts +0 -25
  485. package/packages/tools/dist/guide.js +0 -1
  486. package/packages/tools/dist/health.d.ts +0 -16
  487. package/packages/tools/dist/health.js +0 -2
  488. package/packages/tools/dist/http-request.d.ts +0 -25
  489. package/packages/tools/dist/http-request.js +0 -1
  490. package/packages/tools/dist/lane.d.ts +0 -41
  491. package/packages/tools/dist/lane.js +0 -6
  492. package/packages/tools/dist/measure.d.ts +0 -42
  493. package/packages/tools/dist/measure.js +0 -2
  494. package/packages/tools/dist/onboard-utils.d.ts +0 -12
  495. package/packages/tools/dist/onboard-utils.js +0 -1
  496. package/packages/tools/dist/onboard.d.ts +0 -50
  497. package/packages/tools/dist/onboard.js +0 -18
  498. package/packages/tools/dist/parse-output.d.ts +0 -84
  499. package/packages/tools/dist/parse-output.js +0 -2
  500. package/packages/tools/dist/path-resolver.d.ts +0 -14
  501. package/packages/tools/dist/path-resolver.js +0 -1
  502. package/packages/tools/dist/process-manager.d.ts +0 -20
  503. package/packages/tools/dist/process-manager.js +0 -1
  504. package/packages/tools/dist/queue.d.ts +0 -40
  505. package/packages/tools/dist/queue.js +0 -1
  506. package/packages/tools/dist/regex-test.d.ts +0 -33
  507. package/packages/tools/dist/regex-test.js +0 -1
  508. package/packages/tools/dist/regex-utils.d.ts +0 -8
  509. package/packages/tools/dist/regex-utils.js +0 -1
  510. package/packages/tools/dist/rename.d.ts +0 -31
  511. package/packages/tools/dist/rename.js +0 -2
  512. package/packages/tools/dist/replay.d.ts +0 -59
  513. package/packages/tools/dist/replay.js +0 -4
  514. package/packages/tools/dist/response-envelope.d.ts +0 -43
  515. package/packages/tools/dist/response-envelope.js +0 -1
  516. package/packages/tools/dist/restore-points.d.ts +0 -22
  517. package/packages/tools/dist/restore-points.js +0 -1
  518. package/packages/tools/dist/schema-validate.d.ts +0 -25
  519. package/packages/tools/dist/schema-validate.js +0 -1
  520. package/packages/tools/dist/scope-map.d.ts +0 -51
  521. package/packages/tools/dist/scope-map.js +0 -1
  522. package/packages/tools/dist/snippet.d.ts +0 -35
  523. package/packages/tools/dist/snippet.js +0 -1
  524. package/packages/tools/dist/stash.d.ts +0 -14
  525. package/packages/tools/dist/stash.js +0 -1
  526. package/packages/tools/dist/stratum-card.d.ts +0 -30
  527. package/packages/tools/dist/stratum-card.js +0 -4
  528. package/packages/tools/dist/symbol.d.ts +0 -45
  529. package/packages/tools/dist/symbol.js +0 -3
  530. package/packages/tools/dist/synthesis-engine.d.ts +0 -13
  531. package/packages/tools/dist/synthesis-engine.js +0 -6
  532. package/packages/tools/dist/test-run.d.ts +0 -28
  533. package/packages/tools/dist/test-run.js +0 -2
  534. package/packages/tools/dist/text-utils.d.ts +0 -24
  535. package/packages/tools/dist/text-utils.js +0 -2
  536. package/packages/tools/dist/time-utils.d.ts +0 -20
  537. package/packages/tools/dist/time-utils.js +0 -1
  538. package/packages/tools/dist/trace.d.ts +0 -43
  539. package/packages/tools/dist/trace.js +0 -2
  540. package/packages/tools/dist/truncation.d.ts +0 -66
  541. package/packages/tools/dist/truncation.js +0 -11
  542. package/packages/tools/dist/watch.d.ts +0 -32
  543. package/packages/tools/dist/watch.js +0 -1
  544. package/packages/tools/dist/web-fetch.d.ts +0 -47
  545. package/packages/tools/dist/web-fetch.js +0 -8
  546. package/packages/tools/dist/web-search.d.ts +0 -25
  547. package/packages/tools/dist/web-search.js +0 -1
  548. package/packages/tools/dist/workset.d.ts +0 -47
  549. package/packages/tools/dist/workset.js +0 -1
  550. package/scaffold/__tests__/copilot-inline-shared-protocols.test.mjs +0 -39
  551. /package/packages/server/dist/{config.js → config-C5IU9Lau.js} +0 -0
  552. /package/packages/server/dist/{dashboard-static.js → dashboard-static-BfIe0Si1.js} +0 -0
  553. /package/packages/server/dist/{version-check.js → version-check-D4j0Pykd.js} +0 -0
@@ -1 +0,0 @@
1
- import{generateRecordId as e,hashContent as t}from"./file-hasher.js";import{FilesystemCrawler as n}from"./filesystem-crawler.js";import{extractGraph as r}from"./graph-extractor.js";import{AIKIT_PATHS as i,createLogger as a,detectContentType as o,serializeError as s}from"../../core/dist/index.js";import{availableParallelism as c,loadavg as l}from"node:os";import{createChunkerSync as u}from"../../chunker/dist/index.js";const d=a(`indexer`),f=()=>new Promise(e=>setImmediate(e));async function p(e,t,n,r){let i=0;async function a(){for(;i<e.length;){let n=i++;try{await t(e[n])}catch(t){r?.(e[n],t)}n%10==0&&await f()}}await Promise.all(Array.from({length:Math.min(n,e.length)},()=>a()))}function m(e){let t=c(),n=l()[0]/t;return n>1.5?2:n>1?Math.max(2,Math.floor(e/2)):e}const h=Math.max(2,Math.min(4,Math.floor(c()*.5)));var g=class{crawler;indexing=!1;graphStore;hashCache;get isIndexing(){return this.indexing}constructor(e,t){this.embedder=e,this.store=t,this.crawler=new n}setGraphStore(e){this.graphStore=e}setHashCache(e){this.hashCache=e}async index(e,t){if(this.indexing)throw Error(`Indexing is already in progress`);this.indexing=!0;try{return await this.doIndex(e,t,{})}finally{this.indexing=!1}}async getChangedFiles(e){let t=e.indexing.concurrency??h,n=await this.crawlSources(e),{filesToProcess:r}=await this.planIndexWork(n,t,{});return r.map(e=>e.relativePath)}async indexFiles(e,t,n){if(this.indexing)throw Error(`Indexing is already in progress`);this.indexing=!0;try{return await this.doIndexFiles(e,t,n)}finally{this.indexing=!1}}async doIndex(e,t,n={}){let r=Date.now(),i=e.indexing.concurrency??h;t?.({phase:`crawling`,filesTotal:0,filesProcessed:0,chunksTotal:0,chunksProcessed:0});let a=await this.crawlSources(e),{filesToProcess:o,filesSkipped:s,pathsToRemove:c}=await this.planIndexWork(a,i,{skipHashCheck:n.skipHashCheck}),{filesProcessed:l,chunksCreated:u}=await this.processFiles(a,o,i,t,{graphCleared:n.graphCleared}),d=await this.cleanupRemovedFiles(c,i,o.length,l,u,t);return this.hashCache?.flush(),t?.({phase:`done`,filesTotal:o.length,filesProcessed:l,chunksTotal:u,chunksProcessed:u}),{filesProcessed:l,filesSkipped:s,chunksCreated:u,filesRemoved:d,durationMs:Date.now()-r}}async doIndexFiles(e,t,n){let r=Date.now(),i=e.indexing.concurrency??h,a=new Set(t);if(a.size===0)return{filesProcessed:0,filesSkipped:0,chunksCreated:0,filesRemoved:0,durationMs:Date.now()-r};n?.({phase:`crawling`,filesTotal:0,filesProcessed:0,chunksTotal:0,chunksProcessed:0});let o=await this.crawlSources(e),{filesToProcess:s,filesSkipped:c}=await this.planIndexWork(o,i,{requestedPaths:a}),{filesProcessed:l,chunksCreated:u}=await this.processFiles(o,s,i,n,{});return this.hashCache?.flush(),n?.({phase:`done`,filesTotal:s.length,filesProcessed:l,chunksTotal:u,chunksProcessed:u}),{filesProcessed:l,filesSkipped:c,chunksCreated:u,filesRemoved:0,durationMs:Date.now()-r}}async crawlSources(e){return(await Promise.all(e.sources.map(e=>this.crawler.crawl({rootDir:e.path,excludePatterns:e.excludePatterns})))).flat()}async planIndexWork(e,n,r){let i=r.requestedPaths,a=i?e.filter(e=>i.has(e.relativePath)):e;if(r.skipHashCheck)return{filesToProcess:a,filesSkipped:0,pathsToRemove:[]};let o=i?[]:await this.getPathsToRemove(e),c=0,l=[];return await p(a,async e=>{let n=t(e.content);if(this.hashCache){if(this.hashCache.get(e.relativePath)===n){c++;return}}else{let t=await this.store.getBySourcePath(e.relativePath);if(t.length>0&&t[0].fileHash===n){c++;return}}l.push(e)},m(n),(e,t)=>d.error(`Hash check failed`,{sourcePath:e.relativePath,...s(t)})),{filesToProcess:l,filesSkipped:c,pathsToRemove:o}}async getPathsToRemove(e){let t=await this.store.listSourcePaths(),n=new Set(e.map(e=>e.relativePath));return t.filter(e=>!n.has(e)&&!e.startsWith(`${i.aiCurated}/`))}async buildWorkspacePackageMap(e){let t=new Map;for(let n of e)if(n.relativePath.endsWith(`package.json`))try{let e=JSON.parse(n.content);if(typeof e.name!=`string`||e.name.length===0)continue;let r=n.relativePath===`package.json`?``:n.relativePath.replace(/\/package\.json$/,``),i=``;if(typeof e.exports==`string`)i=e.exports;else if(e.exports&&typeof e.exports==`object`){let t=e.exports,n=t[`.`]??t;if(typeof n==`string`)i=n;else if(n&&typeof n==`object`){let e=n,t=e.import??e.module??e.default??e.require;typeof t==`string`&&(i=t)}}!i&&typeof e.module==`string`&&(i=e.module),!i&&typeof e.main==`string`&&(i=e.main);let a=i.replace(/^\.\//,``).replace(/^dist\//,`src/`).replace(/\.(ts|js|mjs|cjs|tsx|jsx)$/,``),o=a?r?`${r}/${a}`:a:r?`${r}/src/index`:`src/index`;t.set(e.name,o)}catch{}return t}async processFiles(n,i,a,c,l={}){let f=0,h=0,g=i.length,_=this.graphStore?await this.buildWorkspacePackageMap(n):void 0,v=[],y=[],b=0,x=[],S=[],C=new Map,w=0,T=async()=>{if(x.length===0)return;let e=x,t=S,n=C;x=[],S=[],C=new Map,w=0,await this.store.upsert(e,t);for(let[e,t]of n)this.hashCache?.set(e,t)},E=async()=>{if(this.graphStore){try{v.length>0&&await this.graphStore.upsertNodes(v),y.length>0&&await this.graphStore.upsertEdges(y)}catch(e){d.warn(`Graph batch flush failed`,s(e))}v=[],y=[],b=0}};return await p(i,async n=>{c?.({phase:`chunking`,filesTotal:g,filesProcessed:f,chunksTotal:h,chunksProcessed:h,currentFile:n.relativePath});let i=o(n.relativePath),a=u(n.extension).chunk(n.content,{sourcePath:n.relativePath,contentType:i});if(a.length===0)return;c?.({phase:`embedding`,filesTotal:g,filesProcessed:f,chunksTotal:h+a.length,chunksProcessed:h,currentFile:n.relativePath});let p=await this.embedder.embedBatch(a.map(e=>e.text)),m=t(n.content),D=a.map((t,r)=>({id:e(n.relativePath,r),content:t.text,sourcePath:t.sourcePath,contentType:t.contentType,headingPath:t.headingPath,chunkIndex:t.chunkIndex,totalChunks:t.totalChunks,startLine:t.startLine,endLine:t.endLine,fileHash:m,indexedAt:new Date().toISOString(),origin:`indexed`,tags:[],version:1}));if(c?.({phase:`storing`,filesTotal:g,filesProcessed:f,chunksTotal:h+a.length,chunksProcessed:h,currentFile:n.relativePath}),x.push(...D),S.push(...p),C.set(n.relativePath,m),w++,w>=20&&await T(),this.graphStore)try{l.graphCleared||await this.graphStore.deleteBySourcePath(n.relativePath);let e=r(n.content,n.relativePath,{workspacePackages:_});e.nodes.length>0&&v.push(...e.nodes),e.edges.length>0&&y.push(...e.edges),b++,b>=50&&await E()}catch(e){d.warn(`Graph extraction failed`,{sourcePath:n.relativePath,...s(e)})}f++,h+=a.length},m(a),(e,t)=>d.error(`Processing failed`,{sourcePath:e.relativePath,...s(t)})),await T(),await E(),{filesProcessed:f,chunksCreated:h}}async cleanupRemovedFiles(e,t,n,r,i,a){if(e.length===0)return 0;let o=0;return a?.({phase:`cleanup`,filesTotal:n,filesProcessed:r,chunksTotal:i,chunksProcessed:i}),await p(e,async e=>{await this.store.deleteBySourcePath(e),this.hashCache?.delete(e),this.graphStore&&await this.graphStore.deleteBySourcePath(e).catch(t=>d.warn(`Graph cleanup failed`,{sourcePath:e,...s(t)})),o++},m(t),(e,t)=>d.error(`Cleanup failed`,{sourcePath:e,...s(t)})),o}async reindexAll(e,t){if(this.indexing)throw Error(`Indexing is already in progress`);this.indexing=!0;try{if(await this.store.dropTable(),this.graphStore)try{let e=await this.graphStore.getStats();e.nodeCount>0&&(await this.graphStore.clear(),d.info(`Graph store cleared`,{nodeCount:e.nodeCount,edgeCount:e.edgeCount}))}catch(e){d.warn(`Graph store clear failed`,s(e))}return await this.doReindex(e,t)}catch(e){throw this.indexing=!1,e}}async doReindex(e,t){try{return await this.doIndex(e,t,{skipHashCheck:!0,graphCleared:!0})}finally{this.indexing=!1}}async getStats(){return this.store.getStats()}};export{g as IncrementalIndexer};
@@ -1,47 +0,0 @@
1
- import { IncrementalIndexer } from "./incremental-indexer.js";
2
- import { KBConfig } from "../../core/dist/index.js";
3
-
4
- //#region packages/indexer/src/smart-index-scheduler.d.ts
5
- /**
6
- * SmartIndexScheduler trickles indexing work over time instead of running
7
- * large idle-triggered indexing passes.
8
- */
9
- declare class SmartIndexScheduler {
10
- private readonly indexer;
11
- private readonly config;
12
- private readonly store?;
13
- private trickleTimer;
14
- private readonly trickleIntervalMs;
15
- private readonly batchSize;
16
- private readonly priorityQueue;
17
- private changedFiles;
18
- private lastRefreshTime;
19
- private refreshing;
20
- constructor(indexer: IncrementalIndexer, config: KBConfig, store?: {
21
- createFtsIndex: () => Promise<void>;
22
- } | undefined);
23
- /** Start the trickle indexing loop. */
24
- start(): void;
25
- /** Stop the scheduler and clear all timers. */
26
- stop(): void;
27
- /**
28
- * Add file paths to the front of the priority queue for near-term indexing.
29
- */
30
- prioritize(...paths: string[]): void;
31
- getState(): {
32
- mode: 'smart';
33
- queueSize: number;
34
- changedFilesSize: number;
35
- intervalMs: number;
36
- batchSize: number;
37
- running: boolean;
38
- };
39
- private readPositiveIntEnv;
40
- private scheduleTick;
41
- private tick;
42
- private getCpuCount;
43
- private pickFiles;
44
- private maybeRefreshChangedFiles;
45
- }
46
- //#endregion
47
- export { SmartIndexScheduler };
@@ -1 +0,0 @@
1
- import{statSync as e}from"node:fs";import{createLogger as t}from"../../core/dist/index.js";import{availableParallelism as n,loadavg as r}from"node:os";const i=t(`smart-index`),a=1.5;var o=class{trickleTimer=null;trickleIntervalMs;batchSize;priorityQueue=[];changedFiles=[];lastRefreshTime=0;refreshing=!1;constructor(e,t,n){this.indexer=e,this.config=t,this.store=n,this.trickleIntervalMs=t.indexing.trickleIntervalMs??this.readPositiveIntEnv(`AIKIT_SMART_TRICKLE_MS`,3e4),this.batchSize=t.indexing.trickleBatchSize??this.readPositiveIntEnv(`AIKIT_SMART_BATCH_SIZE`,1)}start(){this.stop(),i.info(`Smart index scheduler started (trickle mode)`,{intervalMs:this.trickleIntervalMs,batchSize:this.batchSize}),this.scheduleTick()}stop(){this.trickleTimer&&=(clearTimeout(this.trickleTimer),null)}prioritize(...t){let n=[...new Set(t.filter(Boolean))].filter(t=>{try{return!e(t).isDirectory()}catch{return console.debug(`smart-index: skipping non-existent path: ${t}`),!1}});for(let e of n){let t=this.priorityQueue.indexOf(e);t>=0&&this.priorityQueue.splice(t,1)}for(let e of n.reverse())this.priorityQueue.unshift(e);this.priorityQueue.length>500&&(this.priorityQueue.length=500),n.length>0&&i.info(`Files prioritized for trickle indexing`,{added:n.length,queued:this.priorityQueue.length})}getState(){return{mode:`smart`,queueSize:this.priorityQueue.length,changedFilesSize:this.changedFiles.length,intervalMs:this.trickleIntervalMs,batchSize:this.batchSize,running:this.trickleTimer!==null}}readPositiveIntEnv(e,t){let n=Number(process.env[e]);return Number.isFinite(n)&&n>0?n:t}scheduleTick(){this.trickleTimer=setTimeout(()=>void this.tick(),this.trickleIntervalMs),this.trickleTimer.unref&&this.trickleTimer.unref()}async tick(){try{if(this.indexer.isIndexing){i.info(`Skipping trickle tick — indexing already in progress`);return}let e=this.getCpuCount(),t=r()[0];if(e>0&&t/e>a){i.info(`Skipping trickle tick — system load too high`,{load:t.toFixed(2),cpuCount:e,threshold:a});return}let n=await this.pickFiles();if(n.length===0){await this.maybeRefreshChangedFiles();return}i.info(`Trickle indexing tick started`,{count:n.length,files:n});let o=await this.indexer.indexFiles(this.config,n);if(this.store)try{await this.store.createFtsIndex()}catch(e){i.warn(`FTS index rebuild failed after trickle tick`,{error:String(e)})}this.changedFiles=this.changedFiles.filter(e=>!n.includes(e)),i.info(`Trickle indexing tick complete`,{filesProcessed:o.filesProcessed,filesSkipped:o.filesSkipped,chunksCreated:o.chunksCreated})}catch(e){i.error(`Trickle indexing tick failed`,{error:String(e)})}finally{this.scheduleTick()}}getCpuCount(){try{return typeof n==`function`?n():4}catch{return 4}}async pickFiles(){let e=[];for(;e.length<this.batchSize&&this.priorityQueue.length>0;){let t=this.priorityQueue.shift();t&&!e.includes(t)&&e.push(t)}if(e.length<this.batchSize)for(await this.maybeRefreshChangedFiles();e.length<this.batchSize&&this.changedFiles.length>0;){let t=this.changedFiles.shift();t&&!e.includes(t)&&e.push(t)}return e}async maybeRefreshChangedFiles(){let e=Date.now();if(!(this.refreshing||this.changedFiles.length>0&&e-this.lastRefreshTime<6e5)){this.refreshing=!0;try{this.changedFiles=await this.indexer.getChangedFiles(this.config),this.lastRefreshTime=e,this.changedFiles.length>0&&i.info(`Refreshed changed files for trickle indexing`,{count:this.changedFiles.length})}catch(e){i.error(`Failed to refresh changed files for trickle indexing`,{error:String(e)})}finally{this.refreshing=!1}}}};export{o as SmartIndexScheduler};
@@ -1,3 +0,0 @@
1
- import { loadConfig } from "./config.js";
2
- import { KnowledgeBaseComponents, createMcpServer, createServer, initializeKnowledgeBase } from "./server.js";
3
- export { type KnowledgeBaseComponents, createMcpServer, createServer, initializeKnowledgeBase, loadConfig };
@@ -1 +0,0 @@
1
- import{loadConfig as e}from"./config.js";import{createMcpServer as t,createServer as n,initializeKnowledgeBase as r}from"./server.js";export{t as createMcpServer,n as createServer,r as initializeKnowledgeBase,e as loadConfig};
@@ -1,30 +0,0 @@
1
- //#region packages/server/src/auto-gc.d.ts
2
- /**
3
- * P1-13: Self-tuning garbage collection based on p95 latency.
4
- *
5
- * Monitors tool call latency via the replay-interceptor's rolling buffer.
6
- * When p95 exceeds a threshold the system enters "degraded" state and
7
- * triggers progressive GC actions. A cooldown period prevents over-collection.
8
- */
9
- type GcState = 'healthy' | 'warming' | 'degraded';
10
- interface GcStatus {
11
- state: GcState;
12
- p95: number;
13
- lastGcAt: number | null;
14
- gcCount: number;
15
- bufferSize: number;
16
- }
17
- type GcCallback = () => Promise<void>;
18
- /**
19
- * Evaluate the current latency profile and optionally trigger GC.
20
- *
21
- * Call this periodically (e.g. every N tool calls) from the replay interceptor.
22
- * The optional `gcCallback` receives control when a GC cycle is triggered —
23
- * the caller decides *what* to clean up (pruning stale curated entries,
24
- * vacuuming SQLite, removing orphaned graph nodes, etc.).
25
- */
26
- declare function checkAndMaybeGc(gcCallback?: GcCallback): void;
27
- /** Return a snapshot of the GC health state for the status tool. */
28
- declare function getGcStatus(): GcStatus;
29
- //#endregion
30
- export { GcCallback, checkAndMaybeGc, getGcStatus };
@@ -1 +0,0 @@
1
- import{getLatencyBuffer as e}from"./replay-interceptor.js";import{createLogger as t}from"../../core/dist/index.js";const n=t(`auto-gc`);let r=`warming`,i=null,a=0;function o(){let t=[...e()];if(t.length<10)return 0;t.sort((e,t)=>e-t);let n=Math.floor(t.length*.95);return t[Math.min(n,t.length-1)]}function s(e){let t=o();if(t===0){r=`warming`;return}if(t>500){r=`degraded`;let o=Date.now();if(i&&o-i<36e5){n.debug(`GC cooldown active — skipping`,{lastGcAgoMs:o-i});return}i=o,a++,n.warn(`p95 latency exceeds threshold, triggering GC`,{p95:t,cycle:a}),e&&e().catch(e=>n.error(`GC callback failed`,{err:String(e)}))}else t<200&&(r=`healthy`)}function c(){return{state:r,p95:o(),lastGcAt:i,gcCount:a,bufferSize:e().length}}export{s as checkAndMaybeGc,c as getGcStatus};
@@ -1,47 +0,0 @@
1
- //#region packages/server/src/background-task.d.ts
2
- /**
3
- * Background task scheduler — runs heavy operations without blocking MCP request handling.
4
- *
5
- * Instead of worker_threads (which would duplicate ~200 MB+ ONNX models per thread),
6
- * this scheduler:
7
- * 1. Queues tasks and runs them sequentially (prevents OOM from parallel heavy ops)
8
- * 2. Provides `yieldToEventLoop()` that heavy loops can call between iterations to
9
- * keep the MCP JSON-RPC transport responsive
10
- * 3. Tracks running/pending state for status reporting
11
- *
12
- * Why not worker_threads?
13
- * - ONNX WASM model (~200 MB) must be loaded per thread — doubles memory
14
- * - tree-sitter WASM and sql.js WASM cannot be shared across threads
15
- * - The existing adaptive-concurrency indexer already parallelises I/O within the main thread
16
- */
17
- interface BackgroundTask {
18
- name: string;
19
- fn: () => Promise<void>;
20
- }
21
- /**
22
- * Yield control to the event loop so pending I/O (MCP transport, timers)
23
- * can be processed. Call this inside tight loops that would otherwise
24
- * starve the event loop (e.g., embedding 500 chunks in a row).
25
- *
26
- * Cost: ~1 ms per call on most systems — negligible for batch work when
27
- * called every 10-50 iterations.
28
- */
29
- declare function yieldToEventLoop(): Promise<void>;
30
- declare class BackgroundTaskScheduler {
31
- private readonly queue;
32
- private running;
33
- /** Whether a task is currently executing. */
34
- get isRunning(): boolean;
35
- /** Name of the currently running task, or null. */
36
- get currentTask(): string | null;
37
- /** Number of tasks waiting in the queue. */
38
- get pendingCount(): number;
39
- /**
40
- * Enqueue a task. Returns a Promise that resolves when the task completes
41
- * (or rejects if it throws). Tasks run sequentially in FIFO order.
42
- */
43
- schedule(task: BackgroundTask): Promise<void>;
44
- private processQueue;
45
- }
46
- //#endregion
47
- export { BackgroundTask, BackgroundTaskScheduler, yieldToEventLoop };
@@ -1 +0,0 @@
1
- import{createLogger as e}from"../../core/dist/index.js";const t=e(`background-task`);function n(){return new Promise(e=>setImmediate(e))}var r=class{queue=[];running=null;get isRunning(){return this.running!==null}get currentTask(){return this.running}get pendingCount(){return this.queue.length}schedule(e){return new Promise((t,n)=>{this.queue.push({...e,resolve:t,reject:n}),this.running||this.processQueue()})}async processQueue(){for(;this.queue.length>0;){let e=this.queue.shift();if(!e)break;this.running=e.name,t.info(`Background task started`,{task:e.name,pending:this.queue.length});let n=Date.now();try{await e.fn();let r=Date.now()-n;t.info(`Background task completed`,{task:e.name,durationMs:r}),e.resolve()}catch(r){let i=Date.now()-n;t.error(`Background task failed`,{task:e.name,durationMs:i,err:r}),e.reject(r instanceof Error?r:Error(String(r)))}}this.running=null}};export{r as BackgroundTaskScheduler,n as yieldToEventLoop};
@@ -1,14 +0,0 @@
1
- import { CuratedKnowledgeManager } from "./curated-manager.js";
2
- import { IGraphStore, IKnowledgeStore } from "../../store/dist/index.js";
3
-
4
- //#region packages/server/src/completions.d.ts
5
- /** Clear all completion caches (useful for testing). */
6
- declare function clearCompletionCache(): void;
7
- declare function completeCuratedPaths(curated: CuratedKnowledgeManager, partial: string): Promise<string[]>;
8
- declare function completeFilePaths(store: IKnowledgeStore, partial: string): Promise<string[]>;
9
- declare function completeSymbolNames(graphStore: IGraphStore, partial: string): Promise<string[]>;
10
- declare function completeStashKeys(partial: string): string[];
11
- declare function completeWorksetNames(partial: string): string[];
12
- declare function completeCheckpointNames(partial: string): string[];
13
- //#endregion
14
- export { clearCompletionCache, completeCheckpointNames, completeCuratedPaths, completeFilePaths, completeStashKeys, completeSymbolNames, completeWorksetNames };
@@ -1 +0,0 @@
1
- import{checkpointList as e,listWorksets as t,stashList as n}from"../../tools/dist/index.js";const r=3e4,i=new Map;function a(e,t,n){let r=i.get(e);if(r&&Date.now()<r.expires)return Promise.resolve(r.data);let a=n();return Promise.resolve(a).then(n=>(i.set(e,{data:n,expires:Date.now()+t}),n))}function o(){i.clear()}function s(e,t){return a(`curated-paths`,r,async()=>(await e.list()).map(e=>e.path)).then(e=>e.filter(e=>e.toLowerCase().includes(t.toLowerCase())).slice(0,20))}function c(e,t){return a(`file-paths`,r,()=>e.listSourcePaths()).then(e=>e.filter(e=>e.toLowerCase().includes(t.toLowerCase())).slice(0,20))}function l(e,t){return a(`symbol-names`,r,async()=>(await e.findNodes({type:`symbol`,limit:500})).map(e=>e.name)).then(e=>e.filter(e=>e.toLowerCase().includes(t.toLowerCase())).slice(0,20))}function u(e){return n().map(e=>e.key).filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,20)}function d(e){return t().map(e=>e.name).filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,20)}function f(t){return e().map(e=>e.label).filter(e=>e.toLowerCase().includes(t.toLowerCase())).slice(0,20)}export{o as clearCompletionCache,f as completeCheckpointNames,s as completeCuratedPaths,c as completeFilePaths,u as completeStashKeys,l as completeSymbolNames,d as completeWorksetNames};
@@ -1,12 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
-
3
- //#region packages/server/src/compression-interceptor.d.ts
4
- interface CompressionInterceptorOptions {
5
- /** Minimum character count before compression kicks in (default: 4000) */
6
- threshold?: number;
7
- /** Maximum token budget for compressed output (default: 2000) */
8
- tokenBudget?: number;
9
- }
10
- declare function installCompressionInterceptor(server: McpServer, options?: CompressionInterceptorOptions): void;
11
- //#endregion
12
- export { CompressionInterceptorOptions, installCompressionInterceptor };
@@ -1 +0,0 @@
1
- import{compressTerminalOutput as e}from"../../tools/dist/index.js";const t=new Set([`compact`,`digest`,`file_summary`,`stratum_card`,`present`,`web_fetch`,`web_search`]);function n(n,r){let i=r?.threshold??4e3,a=r?.tokenBudget??2e3,o=n.registerTool.bind(n);n.registerTool=(n,r,s)=>t.has(n)?o(n,r,s):o(n,r,async(t,r)=>{let o=await s(t,r);if(!Array.isArray(o.content))return o;let c=0;for(let e of o.content)e.type===`text`&&typeof e.text==`string`&&(c+=e.text.length);if(c<i)return o;let l=o.content.map(t=>{if(t.type!==`text`||typeof t.text!=`string`||t.text.length<i)return t;let r=e({text:t.text,tool:n,tokenBudget:a});return{...t,text:r.text}});return{...o,content:l}})}export{n as installCompressionInterceptor};
@@ -1,16 +0,0 @@
1
- import { KBConfig } from "../../core/dist/index.js";
2
-
3
- //#region packages/server/src/config.d.ts
4
- type IndexMode = NonNullable<KBConfig['indexMode']>;
5
- declare function resolveIndexMode(config: KBConfig): IndexMode;
6
- declare function loadConfig(): KBConfig;
7
- /**
8
- * Re-target an existing config to a new workspace root.
9
- *
10
- * Called after MCP roots are resolved — the initial config was built with
11
- * `process.cwd()` (unknown at user-level), so we re-point source paths,
12
- * store path, and curated path to the actual workspace the IDE has open.
13
- */
14
- declare function reconfigureForWorkspace(config: KBConfig, workspaceRoot: string): void;
15
- //#endregion
16
- export { loadConfig, reconfigureForWorkspace, resolveIndexMode };
@@ -1,43 +0,0 @@
1
- import { RegistryEntry, SearchResult } from "../../core/dist/index.js";
2
- import { IKnowledgeStore, SearchOptions } from "../../store/dist/index.js";
3
-
4
- //#region packages/server/src/cross-workspace.d.ts
5
- interface CrossWorkspaceOptions {
6
- /** Workspace partition names or folder basenames to include. `"*"` means all. */
7
- workspaces: string[];
8
- /** Current workspace partition (excluded from cross-workspace queries to avoid double results) */
9
- currentPartition?: string;
10
- }
11
- /**
12
- * Resolve workspace identifiers to partition entries.
13
- * Accepts partition keys (exact) or folder basenames (fuzzy match).
14
- * Special value `"*"` resolves to all registered workspaces.
15
- */
16
- declare function resolveWorkspaces(identifiers: string[], currentPartition?: string): RegistryEntry[];
17
- /**
18
- * Open temporary read-only store instances for the specified workspace partitions.
19
- * Caller MUST call closeAll() when done.
20
- */
21
- declare function openWorkspaceStores(entries: RegistryEntry[]): Promise<{
22
- stores: Map<string, IKnowledgeStore>;
23
- closeAll: () => Promise<void>;
24
- }>;
25
- /**
26
- * Fan-out a vector search to multiple workspace stores in parallel.
27
- * Returns merged results sorted by score descending, with workspace labels.
28
- */
29
- declare function fanOutSearch(stores: Map<string, IKnowledgeStore>, queryVector: Float32Array, options: SearchOptions & {
30
- limit: number;
31
- }): Promise<Array<SearchResult & {
32
- workspace: string;
33
- }>>;
34
- /**
35
- * Fan-out a full-text search to multiple workspace stores in parallel.
36
- */
37
- declare function fanOutFtsSearch(stores: Map<string, IKnowledgeStore>, query: string, options: SearchOptions & {
38
- limit: number;
39
- }): Promise<Array<SearchResult & {
40
- workspace: string;
41
- }>>;
42
- //#endregion
43
- export { CrossWorkspaceOptions, fanOutFtsSearch, fanOutSearch, openWorkspaceStores, resolveWorkspaces };
@@ -1 +0,0 @@
1
- import{createLogger as e,getPartitionDir as t,isUserInstalled as n,listWorkspaces as r}from"../../core/dist/index.js";import{createStore as i}from"../../store/dist/index.js";const a=e(`cross-workspace`);function o(e,t){if(!n())return[];let i=r();if(i.length===0)return[];if(e.includes(`*`))return t?i.filter(e=>e.partition!==t):i;let a=[];for(let n of e){let e=i.find(e=>e.partition===n);if(e){e.partition!==t&&a.push(e);continue}let r=i.filter(e=>e.partition!==t&&e.partition.replace(/-[a-f0-9]{8}$/,``)===n.toLowerCase());a.push(...r)}let o=new Set;return a.filter(e=>o.has(e.partition)?!1:(o.add(e.partition),!0))}async function s(e){let n=new Map;for(let r of e)try{let e=await i({backend:`lancedb`,path:t(r.partition)});await e.initialize(),n.set(r.partition,e)}catch(e){a.warn(`Failed to open workspace store`,{partition:r.partition,err:e})}return{stores:n,closeAll:async()=>{for(let[,e]of n)try{await e.close()}catch{}}}}async function c(e,t,n){let r=[...e.entries()].map(async([e,r])=>{try{return(await r.search(t,n)).map(t=>({...t,workspace:e}))}catch(t){return a.warn(`Cross-workspace search failed for partition`,{partition:e,err:t}),[]}});return(await Promise.all(r)).flat().sort((e,t)=>t.score-e.score).slice(0,n.limit)}async function l(e,t,n){let r=[...e.entries()].map(async([e,r])=>{try{return(await r.ftsSearch(t,n)).map(t=>({...t,workspace:e}))}catch(t){return a.warn(`Cross-workspace FTS search failed for partition`,{partition:e,err:t}),[]}});return(await Promise.all(r)).flat().sort((e,t)=>t.score-e.score).slice(0,n.limit)}export{l as fanOutFtsSearch,c as fanOutSearch,s as openWorkspaceStores,o as resolveWorkspaces};
@@ -1,92 +0,0 @@
1
- import { IEmbedder } from "../../embeddings/dist/index.js";
2
- import { IKnowledgeStore } from "../../store/dist/index.js";
3
-
4
- //#region packages/server/src/curated-manager.d.ts
5
- type CuratedCategory = string;
6
- interface CuratedEntry {
7
- path: string;
8
- title: string;
9
- category: string;
10
- tags: string[];
11
- version: number;
12
- created: string;
13
- updated: string;
14
- contentPreview: string;
15
- }
16
- interface CuratedFrontmatter {
17
- title: string;
18
- category: string;
19
- tags: string[];
20
- created: string;
21
- updated: string;
22
- version: number;
23
- origin: 'curated';
24
- changelog: Array<{
25
- version: number;
26
- date: string;
27
- reason: string;
28
- }>;
29
- }
30
- /**
31
- * Manages curated knowledge files — the LLM's persistent memory.
32
- * Files are stored as markdown in a .ai/curated/ directory with YAML frontmatter.
33
- */
34
- declare class CuratedKnowledgeManager {
35
- private readonly curatedDir;
36
- private readonly store;
37
- private readonly embedder;
38
- constructor(curatedDir: string, store: IKnowledgeStore, embedder: IEmbedder);
39
- remember(title: string, content: string, category: CuratedCategory, tags?: string[]): Promise<{
40
- path: string;
41
- }>;
42
- update(relativePath: string, newContent: string, reason: string): Promise<{
43
- path: string;
44
- version: number;
45
- }>;
46
- forget(relativePath: string, _reason: string): Promise<{
47
- path: string;
48
- }>;
49
- read(relativePath: string): Promise<CuratedEntry & {
50
- content: string;
51
- }>;
52
- list(filters?: {
53
- category?: CuratedCategory;
54
- tag?: string;
55
- }): Promise<CuratedEntry[]>;
56
- /**
57
- * Re-index all curated files into the vector store.
58
- * Call this after the indexer has run to restore curated vectors
59
- * that may have been lost, or to bulk-sync disk state to vectors.
60
- */
61
- reindexAll(): Promise<{
62
- indexed: number;
63
- errors: string[];
64
- }>;
65
- private indexCuratedFile;
66
- private discoverCategories;
67
- /**
68
- * Normalize and validate a relative path within .ai/curated/.
69
- * Returns the cleaned path (mutates nothing — caller must use the return value).
70
- */
71
- private guardPath;
72
- private validateCategoryName;
73
- private validateContentSize;
74
- private slugify;
75
- /** Return a unique `category/slug.md` path, appending `-2`, `-3`, … on collision. */
76
- private uniqueRelativePath;
77
- private hash;
78
- private hashId;
79
- /**
80
- * Simple YAML frontmatter serializer (no gray-matter dependency).
81
- */
82
- private serializeFile;
83
- /**
84
- * Simple YAML frontmatter parser (no gray-matter dependency).
85
- */
86
- parseFile(raw: string): {
87
- frontmatter: CuratedFrontmatter;
88
- content: string;
89
- };
90
- }
91
- //#endregion
92
- export { CuratedCategory, CuratedEntry, CuratedKnowledgeManager };
@@ -1,5 +0,0 @@
1
- import{dirname as e,isAbsolute as t,join as n}from"node:path";import{createLogger as r,serializeError as i}from"../../core/dist/index.js";import{createHash as a}from"node:crypto";import{mkdir as o,readFile as s,readdir as c,stat as l,unlink as u,writeFile as d}from"node:fs/promises";const f=50*1024,p=r(`server`);var m=class{constructor(e,t,n){this.curatedDir=e,this.store=t,this.embedder=n}async remember(t,r,i,a=[]){this.validateCategoryName(i),this.validateContentSize(r);let s=this.slugify(t),c=await this.uniqueRelativePath(i,s),l=n(this.curatedDir,c),f=new Date().toISOString(),p={title:t,category:i,tags:a,created:f,updated:f,version:1,origin:`curated`,changelog:[{version:1,date:f,reason:`Initial creation`}]},m=this.serializeFile(r,p);await o(e(l),{recursive:!0});try{await d(l,m,{encoding:`utf-8`,flag:`wx`})}catch(e){throw e.code===`EEXIST`?Error(`Concurrent write collision for "${c}" — retry the operation`):e}try{await this.indexCuratedFile(c,r,p)}catch(e){throw await u(l).catch(()=>{}),Error(`Remember failed: wrote file but indexing failed — rolled back. ${e.message}`)}return{path:c}}async update(e,t,r){e=this.guardPath(e),this.validateContentSize(t);let i=n(this.curatedDir,e),a=await s(i,`utf-8`),{frontmatter:o}=this.parseFile(a),c=(o.version??1)+1,l=new Date().toISOString();return o.version=c,o.updated=l,o.changelog=[...o.changelog??[],{version:c,date:l,reason:r}],await d(i,this.serializeFile(t,o),`utf-8`),await this.indexCuratedFile(e,t,o),{path:e,version:c}}async forget(e,t){e=this.guardPath(e),await u(n(this.curatedDir,e));let r=`.ai/curated/${e}`;return await this.store.deleteBySourcePath(r).catch(e=>{p.warn(`File deleted but vector cleanup failed`,{sourcePath:r,...i(e)})}),{path:e}}async read(e){e=this.guardPath(e);let t=await s(n(this.curatedDir,e),`utf-8`),{frontmatter:r,content:i}=this.parseFile(t),a=e.split(`/`)[0];return{path:e,title:r.title??e,category:a,tags:r.tags??[],version:r.version??1,created:r.created??``,updated:r.updated??``,contentPreview:i.slice(0,200),content:i}}async list(e){let t=[],r=e?.category?[e.category]:await this.discoverCategories();for(let i of r){let r=n(this.curatedDir,i);try{let a=await c(r);for(let o of a){if(!o.endsWith(`.md`))continue;let a=await s(n(r,o),`utf-8`),{frontmatter:c,content:l}=this.parseFile(a);e?.tag&&!(c.tags??[]).includes(e.tag)||t.push({path:`${i}/${o}`,title:c.title??o,category:i,tags:c.tags??[],version:c.version??1,created:c.created??``,updated:c.updated??``,contentPreview:l.slice(0,200)})}}catch{}}return t}async reindexAll(){let e=await this.discoverCategories(),t=[],r=[];for(let a of e){let e=n(this.curatedDir,a),o;try{o=(await c(e)).filter(e=>e.endsWith(`.md`))}catch{continue}for(let c of o){let o=`${a}/${c}`,l=n(e,c);try{let e=await s(l,`utf-8`),{frontmatter:t,content:n}=this.parseFile(e);r.push({relativePath:o,content:n,frontmatter:t})}catch(e){p.error(`Failed to read curated file`,{relativePath:o,...i(e)}),t.push(`${o}: read failed`)}}}if(r.length===0)return{indexed:0,errors:t};let a=await this.embedder.embedBatch(r.map(e=>e.content)),o=new Date().toISOString(),l=r.map(e=>{let t=`.ai/curated/${e.relativePath}`;return{id:this.hashId(t,0),content:e.content,sourcePath:t,contentType:`curated-knowledge`,headingPath:e.frontmatter.title,chunkIndex:0,totalChunks:1,startLine:1,endLine:e.content.split(`
2
- `).length,fileHash:this.hash(e.content),indexedAt:o,origin:`curated`,tags:e.frontmatter.tags,category:e.frontmatter.category,version:e.frontmatter.version}});return await this.store.upsert(l,a),{indexed:r.length,errors:t}}async indexCuratedFile(e,t,n){let r=await this.embedder.embed(t),i=`.ai/curated/${e}`,a=new Date().toISOString(),o={id:this.hashId(i,0),content:t,sourcePath:i,contentType:`curated-knowledge`,headingPath:n.title,chunkIndex:0,totalChunks:1,startLine:1,endLine:t.split(`
3
- `).length,fileHash:this.hash(t),indexedAt:a,origin:`curated`,tags:n.tags,category:n.category,version:n.version};await this.store.upsert([o],[r])}async discoverCategories(){try{return(await c(this.curatedDir,{withFileTypes:!0})).filter(e=>e.isDirectory()&&/^[a-z][a-z0-9-]*$/.test(e.name)).map(e=>e.name)}catch{return[]}}guardPath(e){let n=e.replace(/^\.ai\/curated\//,``);if(n.endsWith(`.md`)||(n+=`.md`),n.includes(`..`)||t(n))throw Error(`Invalid path: ${n}. Must be relative within .ai/curated/ directory.`);let r=n.split(`/`)[0];return this.validateCategoryName(r),n}validateCategoryName(e){if(!/^[a-z][a-z0-9-]*$/.test(e))throw Error(`Invalid category name: "${e}". Must be lowercase kebab-case (e.g., "decisions", "api-contracts").`)}validateContentSize(e){if(Buffer.byteLength(e,`utf-8`)>f)throw Error(`Content exceeds maximum size of ${f/1024}KB`)}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,80)}async uniqueRelativePath(e,t){let r=`${e}/${t}.md`,i=n(this.curatedDir,r);try{await l(i)}catch{return r}for(let r=2;r<=100;r++){let i=`${e}/${t}-${r}.md`;try{await l(n(this.curatedDir,i))}catch{return i}}throw Error(`Too many entries with slug "${t}" in category "${e}"`)}hash(e){return a(`sha256`).update(e).digest(`hex`).slice(0,16)}hashId(e,t){return this.hash(`${e}::${t}`)}serializeFile(e,t){return`${[`---`,`title: "${t.title.replace(/"/g,`\\"`)}"`,`category: ${t.category}`,`tags: [${t.tags.map(e=>`"${e}"`).join(`, `)}]`,`created: ${t.created}`,`updated: ${t.updated}`,`version: ${t.version}`,`origin: ${t.origin}`,`changelog:`,...t.changelog.map(e=>` - version: ${e.version}\n date: ${e.date}\n reason: "${e.reason.replace(/"/g,`\\"`)}"`),`---`].join(`
4
- `)}\n\n${e}\n`}parseFile(e){let t=e.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);if(!t)return{frontmatter:{title:`Untitled`,category:`notes`,tags:[],created:``,updated:``,version:1,origin:`curated`,changelog:[]},content:e};let n=t[1],r=t[2].trim(),i={},a=[],o=n.split(`
5
- `),s=!1,c={};for(let e of o){if(/^changelog:\s*$/.test(e)){s=!0;continue}if(s){let t=e.match(/^\s+-\s+version:\s*(\d+)$/);if(t){c.version!=null&&a.push(c),c={version:parseInt(t[1],10)};continue}let n=e.match(/^\s+date:\s*(.+)$/);if(n){c.date=n[1].trim();continue}let r=e.match(/^\s+reason:\s*"?(.*?)"?\s*$/);if(r){c.reason=r[1];continue}/^\w/.test(e)&&(s=!1,c.version!=null&&a.push(c),c={});continue}let t=e.match(/^(\w+):\s*(.*)$/);if(t){let e=t[1],n=t[2];typeof n==`string`&&n.startsWith(`[`)&&n.endsWith(`]`)?n=n.slice(1,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)).filter(e=>e.length>0):typeof n==`string`&&/^\d+$/.test(n)?n=parseInt(n,10):typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1)),i[e]=n}}return c.version!=null&&a.push(c),{frontmatter:{title:i.title??`Untitled`,category:i.category??`notes`,tags:i.tags??[],created:i.created??``,updated:i.updated??``,version:i.version??1,origin:`curated`,changelog:a},content:r}}};export{m as CuratedKnowledgeManager};
@@ -1,27 +0,0 @@
1
- import * as _$express from "express";
2
-
3
- //#region packages/server/src/dashboard-static.d.ts
4
- type DashboardApp = {
5
- get: (path: string, handler: (req: _$express.Request, res: _$express.Response) => void) => void;
6
- };
7
- type DashboardLogger = {
8
- info: (message: string, meta?: Record<string, unknown>) => void;
9
- };
10
- type DashboardRequestResolution = {
11
- kind: 'file';
12
- path: string;
13
- contentType: string;
14
- } | {
15
- kind: 'spa';
16
- path: string;
17
- contentType: 'text/html';
18
- } | {
19
- kind: 'forbidden';
20
- } | {
21
- kind: 'not-found';
22
- };
23
- declare function resolveDashboardDir(baseDir?: string): string;
24
- declare function resolveDashboardRequest(dashboardDir: string, requestPath: string): DashboardRequestResolution;
25
- declare function registerDashboardRoutes(app: DashboardApp, dashboardDir: string, logger: DashboardLogger): boolean;
26
- //#endregion
27
- export { DashboardRequestResolution, registerDashboardRoutes, resolveDashboardDir, resolveDashboardRequest };
@@ -1,18 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { Elicitor } from "../../elicitation/dist/index.js";
3
-
4
- //#region packages/server/src/elicitor.d.ts
5
- /**
6
- * Create an Elicitor backed by the MCP server's elicitInput capability.
7
- *
8
- * All methods degrade gracefully: if the client does not support elicitation,
9
- * they return decline / false / null / [] defaults without throwing.
10
- */
11
- declare function createElicitor(mcpServer: McpServer): Elicitor;
12
- /**
13
- * No-op Elicitor — always returns decline / false / null / [].
14
- * Used when no MCP server is available.
15
- */
16
- declare const noopElicitor: Elicitor;
17
- //#endregion
18
- export { createElicitor, noopElicitor };
@@ -1 +0,0 @@
1
- import{buildFormSchema as e,field as t,normalizeResponse as n}from"../../elicitation/dist/index.js";function r(r){function i(){return!!r.server?.getClientCapabilities?.()?.elicitation}async function a(e,t){if(i())try{let i=await r.server.elicitInput({message:e,requestedSchema:t});return n(i?{action:i.action,content:i.content}:void 0)}catch{return}}return{get available(){return i()},async ask(e){return await a(e.message,e.schema)||{action:`decline`}},async confirm(n){let r=await a(n,e({confirmed:t.confirm(n)}));return r?.action===`accept`&&r.content?.confirmed===!0},async selectOne(n,r){let i=await a(n,e({selection:t.select(`Choose one`,r)}));if(i?.action!==`accept`)return null;let o=i.content?.selection;return typeof o==`string`?o:null},async selectMany(n,r){let i=await a(n,e({selections:t.multi(`Choose one or more`,r)}));if(i?.action!==`accept`)return[];let o=i.content?.selections;return Array.isArray(o)?o:[]},async promptText(n,r){let i=await a(n,e({text:t.text(n,{description:r})}));if(i?.action!==`accept`)return null;let o=i.content?.text;return typeof o==`string`?o:null}}}const i={available:!1,async ask(){return{action:`decline`}},async confirm(){return!1},async selectOne(){return null},async selectMany(){return[]},async promptText(){return null}};export{r as createElicitor,i as noopElicitor};
@@ -1,33 +0,0 @@
1
- //#region packages/server/src/idle-timer.d.ts
2
- /**
3
- * Resource lifecycle manager — tracks tool activity and closes idle resources.
4
- *
5
- * When no tool has been invoked for `idleMs`, the manager calls the registered
6
- * cleanup callbacks. Resources are re-initialised lazily on next tool call.
7
- */
8
- interface IdleTimerOptions {
9
- /** Milliseconds of inactivity before cleanup fires. @default 300_000 */
10
- idleMs?: number;
11
- }
12
- declare class IdleTimer {
13
- private timer;
14
- private readonly cleanupFns;
15
- private readonly idleMs;
16
- private disposed;
17
- /** When true, cleanup is suppressed (e.g. during long-running indexing). */
18
- private _busy;
19
- constructor(opts?: IdleTimerOptions);
20
- /** Mark the server as busy (suppresses idle cleanup while true). */
21
- setBusy(busy: boolean): void;
22
- /** Register a cleanup callback that runs when idle threshold is reached. */
23
- onIdle(fn: () => void | Promise<void>): void;
24
- /** Call this on every tool invocation to reset the idle countdown. */
25
- touch(): void;
26
- /** Cancel the pending idle timer without running cleanup. */
27
- cancel(): void;
28
- /** Stop the timer permanently and release all callbacks. */
29
- dispose(): void;
30
- private runCleanup;
31
- }
32
- //#endregion
33
- export { IdleTimer, IdleTimerOptions };
@@ -1 +0,0 @@
1
- import{createLogger as e}from"../../core/dist/index.js";const t=e(`idle-timer`);var n=class{timer=null;cleanupFns=[];idleMs;disposed=!1;_busy=!1;constructor(e){this.idleMs=e?.idleMs??3e5}setBusy(e){this._busy=e,e?this.cancel():this.touch()}onIdle(e){this.cleanupFns.push(e)}touch(){this.disposed||this._busy||(this.cancel(),this.timer=setTimeout(()=>{this.runCleanup()},this.idleMs),this.timer.unref&&this.timer.unref())}cancel(){this.timer&&=(clearTimeout(this.timer),null)}dispose(){this.cancel(),this.cleanupFns.length=0,this.disposed=!0}async runCleanup(){if(this._busy){t.info(`Skipping idle cleanup — background work in progress`);return}t.info(`Idle for ${this.idleMs/1e3}s — running cleanup`);let e=await Promise.allSettled(this.cleanupFns.map(e=>e()));for(let n of e)n.status===`rejected`&&t.warn(`Idle cleanup callback failed`,{error:String(n.reason)})}};export{n as IdleTimer};
@@ -1,11 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
-
3
- //#region packages/server/src/mcp-logging.d.ts
4
- /**
5
- * Bridge internal logger messages to MCP client via `sendLoggingMessage`.
6
- * Fire-and-forget — never blocks the log caller, never throws.
7
- * Returns a cleanup function to remove the bridge.
8
- */
9
- declare function bridgeMcpLogging(server: McpServer): () => void;
10
- //#endregion
11
- export { bridgeMcpLogging };
@@ -1 +0,0 @@
1
- import{addLogListener as e}from"../../core/dist/index.js";const t={debug:`debug`,info:`info`,warn:`warning`,error:`error`};function n(n){return e(({level:e,component:r,message:i,data:a})=>{try{Promise.resolve(n.sendLoggingMessage({level:t[e],logger:r,data:a?{message:i,...a}:i})).catch(()=>{})}catch{}})}export{n as bridgeMcpLogging};
@@ -1,37 +0,0 @@
1
- //#region packages/server/src/memory-monitor.d.ts
2
- /**
3
- * Memory monitor — periodically checks RSS and logs warnings when thresholds are exceeded.
4
- *
5
- * Also exposes `getRssBytes()` for on-demand checks and a `onPressure` callback
6
- * for triggering cache eviction or GC hints when memory is high.
7
- */
8
- interface MemoryMonitorOptions {
9
- /** RSS bytes above which a warning is logged. @default 4 GB */
10
- warningBytes?: number;
11
- /** RSS bytes above which pressure callbacks fire. @default 8 GB */
12
- criticalBytes?: number;
13
- /** Polling interval in milliseconds. @default 60 000 */
14
- intervalMs?: number;
15
- }
16
- type PressureLevel = 'normal' | 'warning' | 'critical';
17
- declare class MemoryMonitor {
18
- private timer;
19
- private readonly warningBytes;
20
- private readonly criticalBytes;
21
- private readonly intervalMs;
22
- private readonly pressureFns;
23
- private lastLevel;
24
- constructor(opts?: MemoryMonitorOptions);
25
- /** Register a callback for memory pressure events. */
26
- onPressure(fn: (level: PressureLevel, rssBytes: number) => void): void;
27
- /** Start periodic monitoring. */
28
- start(): void;
29
- /** Stop monitoring. */
30
- stop(): void;
31
- /** Return current RSS in bytes. */
32
- getRssBytes(): number;
33
- /** Run a single check. */
34
- check(): PressureLevel;
35
- }
36
- //#endregion
37
- export { MemoryMonitor, MemoryMonitorOptions, PressureLevel };
@@ -1 +0,0 @@
1
- import{createLogger as e}from"../../core/dist/index.js";const t=e(`memory-monitor`);var n=class{timer=null;warningBytes;criticalBytes;intervalMs;pressureFns=[];lastLevel=`normal`;constructor(e){this.warningBytes=e?.warningBytes??4294967296,this.criticalBytes=e?.criticalBytes??8589934592,this.intervalMs=e?.intervalMs??6e4}onPressure(e){this.pressureFns.push(e)}start(){this.timer||(this.timer=setInterval(()=>this.check(),this.intervalMs),this.timer.unref&&this.timer.unref(),t.info(`Memory monitor started`,{warningMB:Math.round(this.warningBytes/1024/1024),criticalMB:Math.round(this.criticalBytes/1024/1024),intervalSec:Math.round(this.intervalMs/1e3)}))}stop(){this.timer&&=(clearInterval(this.timer),null)}getRssBytes(){return process.memoryUsage.rss()}check(){let e=this.getRssBytes(),n=`normal`;if(e>=this.criticalBytes?n=`critical`:e>=this.warningBytes&&(n=`warning`),n!==this.lastLevel||n===`critical`){let r=Math.round(e/1024/1024);n===`critical`?t.warn(`Memory CRITICAL: ${r}MB RSS — consider restarting the server`):n===`warning`?t.warn(`Memory WARNING: ${r}MB RSS`):this.lastLevel!==`normal`&&t.info(`Memory returned to normal: ${r}MB RSS`),this.lastLevel=n}if(n!==`normal`)for(let t of this.pressureFns)try{t(n,e)}catch{}return n===`critical`&&typeof globalThis.gc==`function`&&globalThis.gc(),n}};export{n as MemoryMonitor};