@vpxa/aikit 0.1.58 → 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 (557) 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 +315 -314
  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/scaffold/general/skills/c4-architecture/SKILL.md +87 -1
  63. package/scaffold/general/skills/c4-architecture/references/html-design-system.md +337 -0
  64. package/scaffold/general/skills/c4-architecture/references/html-template.html +627 -0
  65. package/scaffold/general/skills/present/SKILL.md +180 -0
  66. package/packages/aikit-client/dist/direct-client.d.ts +0 -37
  67. package/packages/aikit-client/dist/direct-client.js +0 -1
  68. package/packages/aikit-client/dist/mcp-client.d.ts +0 -19
  69. package/packages/aikit-client/dist/mcp-client.js +0 -4
  70. package/packages/aikit-client/dist/parsers.d.ts +0 -35
  71. package/packages/aikit-client/dist/parsers.js +0 -2
  72. package/packages/aikit-client/dist/types.d.ts +0 -62
  73. package/packages/aikit-client/dist/types.js +0 -1
  74. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +0 -19
  75. package/packages/analyzers/dist/blast-radius-analyzer.js +0 -6
  76. package/packages/analyzers/dist/dependency-analyzer.d.ts +0 -32
  77. package/packages/analyzers/dist/dependency-analyzer.js +0 -8
  78. package/packages/analyzers/dist/diagram-generator.d.ts +0 -16
  79. package/packages/analyzers/dist/diagram-generator.js +0 -2
  80. package/packages/analyzers/dist/entry-point-analyzer.d.ts +0 -40
  81. package/packages/analyzers/dist/entry-point-analyzer.js +0 -4
  82. package/packages/analyzers/dist/knowledge-producer.d.ts +0 -40
  83. package/packages/analyzers/dist/knowledge-producer.js +0 -26
  84. package/packages/analyzers/dist/pattern-analyzer.d.ts +0 -15
  85. package/packages/analyzers/dist/pattern-analyzer.js +0 -2
  86. package/packages/analyzers/dist/regex-call-graph.d.ts +0 -10
  87. package/packages/analyzers/dist/regex-call-graph.js +0 -1
  88. package/packages/analyzers/dist/structure-analyzer.d.ts +0 -19
  89. package/packages/analyzers/dist/structure-analyzer.js +0 -4
  90. package/packages/analyzers/dist/symbol-analyzer.d.ts +0 -14
  91. package/packages/analyzers/dist/symbol-analyzer.js +0 -9
  92. package/packages/analyzers/dist/ts-call-graph.d.ts +0 -29
  93. package/packages/analyzers/dist/ts-call-graph.js +0 -1
  94. package/packages/analyzers/dist/types.d.ts +0 -110
  95. package/packages/analyzers/dist/types.js +0 -1
  96. package/packages/chunker/dist/call-graph-extractor.d.ts +0 -25
  97. package/packages/chunker/dist/call-graph-extractor.js +0 -1
  98. package/packages/chunker/dist/chunker-factory.d.ts +0 -19
  99. package/packages/chunker/dist/chunker-factory.js +0 -1
  100. package/packages/chunker/dist/chunker.interface.d.ts +0 -13
  101. package/packages/chunker/dist/chunker.interface.js +0 -1
  102. package/packages/chunker/dist/code-chunker.d.ts +0 -17
  103. package/packages/chunker/dist/code-chunker.js +0 -11
  104. package/packages/chunker/dist/extractors/call-extractor.d.ts +0 -24
  105. package/packages/chunker/dist/extractors/call-extractor.js +0 -1
  106. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +0 -14
  107. package/packages/chunker/dist/extractors/entry-point-detector.js +0 -1
  108. package/packages/chunker/dist/extractors/import-extractor.d.ts +0 -14
  109. package/packages/chunker/dist/extractors/import-extractor.js +0 -1
  110. package/packages/chunker/dist/extractors/pattern-detector.d.ts +0 -14
  111. package/packages/chunker/dist/extractors/pattern-detector.js +0 -1
  112. package/packages/chunker/dist/extractors/scope-resolver.d.ts +0 -26
  113. package/packages/chunker/dist/extractors/scope-resolver.js +0 -1
  114. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +0 -14
  115. package/packages/chunker/dist/extractors/symbol-extractor.js +0 -3
  116. package/packages/chunker/dist/extractors/types.d.ts +0 -44
  117. package/packages/chunker/dist/extractors/types.js +0 -1
  118. package/packages/chunker/dist/generic-chunker.d.ts +0 -15
  119. package/packages/chunker/dist/generic-chunker.js +0 -5
  120. package/packages/chunker/dist/markdown-chunker.d.ts +0 -17
  121. package/packages/chunker/dist/markdown-chunker.js +0 -3
  122. package/packages/chunker/dist/wasm/languages.d.ts +0 -18
  123. package/packages/chunker/dist/wasm/languages.js +0 -1
  124. package/packages/chunker/dist/wasm/query-executor.d.ts +0 -70
  125. package/packages/chunker/dist/wasm/query-executor.js +0 -1
  126. package/packages/chunker/dist/wasm/runtime.d.ts +0 -44
  127. package/packages/chunker/dist/wasm/runtime.js +0 -1
  128. package/packages/chunker/dist/wasm/types.d.ts +0 -84
  129. package/packages/chunker/dist/wasm/types.js +0 -1
  130. package/packages/chunker/dist/wasm-chunker.d.ts +0 -23
  131. package/packages/chunker/dist/wasm-chunker.js +0 -6
  132. package/packages/cli/dist/aikit-init.d.ts +0 -59
  133. package/packages/cli/dist/aikit-init.js +0 -1
  134. package/packages/cli/dist/commands/analyze.d.ts +0 -6
  135. package/packages/cli/dist/commands/analyze.js +0 -2
  136. package/packages/cli/dist/commands/context-cmds.d.ts +0 -6
  137. package/packages/cli/dist/commands/context-cmds.js +0 -1
  138. package/packages/cli/dist/commands/environment.d.ts +0 -6
  139. package/packages/cli/dist/commands/environment.js +0 -1
  140. package/packages/cli/dist/commands/execution.d.ts +0 -6
  141. package/packages/cli/dist/commands/execution.js +0 -1
  142. package/packages/cli/dist/commands/flow.d.ts +0 -6
  143. package/packages/cli/dist/commands/flow.js +0 -1
  144. package/packages/cli/dist/commands/graph.d.ts +0 -6
  145. package/packages/cli/dist/commands/graph.js +0 -6
  146. package/packages/cli/dist/commands/init/adapters.d.ts +0 -28
  147. package/packages/cli/dist/commands/init/adapters.js +0 -1
  148. package/packages/cli/dist/commands/init/config.d.ts +0 -10
  149. package/packages/cli/dist/commands/init/config.js +0 -3
  150. package/packages/cli/dist/commands/init/constants.d.ts +0 -46
  151. package/packages/cli/dist/commands/init/curated.d.ts +0 -7
  152. package/packages/cli/dist/commands/init/curated.js +0 -1
  153. package/packages/cli/dist/commands/init/frontmatter.d.ts +0 -79
  154. package/packages/cli/dist/commands/init/frontmatter.js +0 -2
  155. package/packages/cli/dist/commands/init/index.d.ts +0 -36
  156. package/packages/cli/dist/commands/init/index.js +0 -5
  157. package/packages/cli/dist/commands/init/manifest.d.ts +0 -72
  158. package/packages/cli/dist/commands/init/manifest.js +0 -1
  159. package/packages/cli/dist/commands/init/scaffold.d.ts +0 -58
  160. package/packages/cli/dist/commands/init/scaffold.js +0 -1
  161. package/packages/cli/dist/commands/init/templates.d.ts +0 -9
  162. package/packages/cli/dist/commands/init/user.d.ts +0 -61
  163. package/packages/cli/dist/commands/init/user.js +0 -5
  164. package/packages/cli/dist/commands/knowledge.d.ts +0 -6
  165. package/packages/cli/dist/commands/knowledge.js +0 -1
  166. package/packages/cli/dist/commands/search.d.ts +0 -6
  167. package/packages/cli/dist/commands/search.js +0 -1
  168. package/packages/cli/dist/commands/system.d.ts +0 -6
  169. package/packages/cli/dist/commands/system.js +0 -4
  170. package/packages/cli/dist/commands/upgrade.d.ts +0 -6
  171. package/packages/cli/dist/commands/upgrade.js +0 -1
  172. package/packages/cli/dist/commands/workspace.d.ts +0 -6
  173. package/packages/cli/dist/commands/workspace.js +0 -1
  174. package/packages/cli/dist/context.d.ts +0 -7
  175. package/packages/cli/dist/context.js +0 -1
  176. package/packages/cli/dist/helpers.d.ts +0 -55
  177. package/packages/cli/dist/helpers.js +0 -5
  178. package/packages/cli/dist/types.d.ts +0 -9
  179. package/packages/cli/dist/types.js +0 -1
  180. package/packages/core/dist/constants.d.ts +0 -74
  181. package/packages/core/dist/constants.js +0 -1
  182. package/packages/core/dist/content-detector.d.ts +0 -13
  183. package/packages/core/dist/content-detector.js +0 -1
  184. package/packages/core/dist/errors.d.ts +0 -20
  185. package/packages/core/dist/errors.js +0 -1
  186. package/packages/core/dist/global-registry.d.ts +0 -69
  187. package/packages/core/dist/global-registry.js +0 -1
  188. package/packages/core/dist/logger.d.ts +0 -32
  189. package/packages/core/dist/logger.js +0 -1
  190. package/packages/core/dist/types.d.ts +0 -149
  191. package/packages/core/dist/types.js +0 -1
  192. package/packages/dashboard/dist/assets/index-Cdke3KDK.js.map +0 -1
  193. package/packages/elicitation/dist/build.d.ts +0 -14
  194. package/packages/elicitation/dist/build.js +0 -1
  195. package/packages/elicitation/dist/fields.d.ts +0 -32
  196. package/packages/elicitation/dist/fields.js +0 -1
  197. package/packages/elicitation/dist/normalize.d.ts +0 -15
  198. package/packages/elicitation/dist/normalize.js +0 -1
  199. package/packages/elicitation/dist/types.d.ts +0 -88
  200. package/packages/elicitation/dist/types.js +0 -1
  201. package/packages/embeddings/dist/embedder.interface.d.ts +0 -26
  202. package/packages/embeddings/dist/embedder.interface.js +0 -1
  203. package/packages/embeddings/dist/onnx-embedder.d.ts +0 -23
  204. package/packages/embeddings/dist/onnx-embedder.js +0 -1
  205. package/packages/enterprise-bridge/dist/cache.d.ts +0 -28
  206. package/packages/enterprise-bridge/dist/cache.js +0 -1
  207. package/packages/enterprise-bridge/dist/er-client.d.ts +0 -37
  208. package/packages/enterprise-bridge/dist/er-client.js +0 -1
  209. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +0 -62
  210. package/packages/enterprise-bridge/dist/evolution-collector.js +0 -1
  211. package/packages/enterprise-bridge/dist/policy-store.d.ts +0 -45
  212. package/packages/enterprise-bridge/dist/policy-store.js +0 -1
  213. package/packages/enterprise-bridge/dist/push-adapter.d.ts +0 -23
  214. package/packages/enterprise-bridge/dist/push-adapter.js +0 -1
  215. package/packages/enterprise-bridge/dist/result-merger.d.ts +0 -14
  216. package/packages/enterprise-bridge/dist/result-merger.js +0 -1
  217. package/packages/enterprise-bridge/dist/types.d.ts +0 -81
  218. package/packages/enterprise-bridge/dist/types.js +0 -1
  219. package/packages/flows/dist/adapters/claude-plugin.d.ts +0 -25
  220. package/packages/flows/dist/adapters/claude-plugin.js +0 -3
  221. package/packages/flows/dist/adapters/copilot.d.ts +0 -12
  222. package/packages/flows/dist/adapters/copilot.js +0 -1
  223. package/packages/flows/dist/adapters/index.d.ts +0 -12
  224. package/packages/flows/dist/adapters/index.js +0 -1
  225. package/packages/flows/dist/adapters/native.d.ts +0 -10
  226. package/packages/flows/dist/adapters/native.js +0 -1
  227. package/packages/flows/dist/adapters/openspec.d.ts +0 -40
  228. package/packages/flows/dist/adapters/openspec.js +0 -1
  229. package/packages/flows/dist/builtins.d.ts +0 -16
  230. package/packages/flows/dist/builtins.js +0 -1
  231. package/packages/flows/dist/foundation.d.ts +0 -20
  232. package/packages/flows/dist/foundation.js +0 -11
  233. package/packages/flows/dist/git.d.ts +0 -53
  234. package/packages/flows/dist/git.js +0 -2
  235. package/packages/flows/dist/loader.d.ts +0 -13
  236. package/packages/flows/dist/loader.js +0 -2
  237. package/packages/flows/dist/registry.d.ts +0 -23
  238. package/packages/flows/dist/registry.js +0 -1
  239. package/packages/flows/dist/state-machine.d.ts +0 -23
  240. package/packages/flows/dist/state-machine.js +0 -1
  241. package/packages/flows/dist/symlinks.d.ts +0 -17
  242. package/packages/flows/dist/symlinks.js +0 -1
  243. package/packages/flows/dist/types.d.ts +0 -127
  244. package/packages/flows/dist/types.js +0 -1
  245. package/packages/indexer/dist/file-hasher.d.ts +0 -13
  246. package/packages/indexer/dist/file-hasher.js +0 -1
  247. package/packages/indexer/dist/filesystem-crawler.d.ts +0 -29
  248. package/packages/indexer/dist/filesystem-crawler.js +0 -1
  249. package/packages/indexer/dist/graph-extractor.d.ts +0 -22
  250. package/packages/indexer/dist/graph-extractor.js +0 -1
  251. package/packages/indexer/dist/hash-cache.d.ts +0 -24
  252. package/packages/indexer/dist/hash-cache.js +0 -1
  253. package/packages/indexer/dist/incremental-indexer.d.ts +0 -73
  254. package/packages/indexer/dist/incremental-indexer.js +0 -1
  255. package/packages/indexer/dist/smart-index-scheduler.d.ts +0 -47
  256. package/packages/indexer/dist/smart-index-scheduler.js +0 -1
  257. package/packages/server/dist/api.d.ts +0 -3
  258. package/packages/server/dist/api.js +0 -1
  259. package/packages/server/dist/auto-gc.d.ts +0 -30
  260. package/packages/server/dist/auto-gc.js +0 -1
  261. package/packages/server/dist/background-task.d.ts +0 -47
  262. package/packages/server/dist/background-task.js +0 -1
  263. package/packages/server/dist/completions.d.ts +0 -14
  264. package/packages/server/dist/completions.js +0 -1
  265. package/packages/server/dist/compression-interceptor.d.ts +0 -12
  266. package/packages/server/dist/compression-interceptor.js +0 -1
  267. package/packages/server/dist/config.d.ts +0 -16
  268. package/packages/server/dist/cross-workspace.d.ts +0 -43
  269. package/packages/server/dist/cross-workspace.js +0 -1
  270. package/packages/server/dist/curated-manager.d.ts +0 -92
  271. package/packages/server/dist/curated-manager.js +0 -5
  272. package/packages/server/dist/dashboard-static.d.ts +0 -27
  273. package/packages/server/dist/elicitor.d.ts +0 -18
  274. package/packages/server/dist/elicitor.js +0 -1
  275. package/packages/server/dist/idle-timer.d.ts +0 -33
  276. package/packages/server/dist/idle-timer.js +0 -1
  277. package/packages/server/dist/mcp-logging.d.ts +0 -11
  278. package/packages/server/dist/mcp-logging.js +0 -1
  279. package/packages/server/dist/memory-monitor.d.ts +0 -37
  280. package/packages/server/dist/memory-monitor.js +0 -1
  281. package/packages/server/dist/output-schemas.d.ts +0 -244
  282. package/packages/server/dist/output-schemas.js +0 -1
  283. package/packages/server/dist/prompts.d.ts +0 -13
  284. package/packages/server/dist/prompts.js +0 -13
  285. package/packages/server/dist/replay-interceptor.d.ts +0 -23
  286. package/packages/server/dist/replay-interceptor.js +0 -1
  287. package/packages/server/dist/resource-links.d.ts +0 -34
  288. package/packages/server/dist/resource-links.js +0 -1
  289. package/packages/server/dist/resources/curated-resources.d.ts +0 -13
  290. package/packages/server/dist/resources/curated-resources.js +0 -2
  291. package/packages/server/dist/resources/resource-notifier.d.ts +0 -45
  292. package/packages/server/dist/resources/resource-notifier.js +0 -1
  293. package/packages/server/dist/resources/resources.d.ts +0 -8
  294. package/packages/server/dist/resources/resources.js +0 -2
  295. package/packages/server/dist/sampling.d.ts +0 -41
  296. package/packages/server/dist/sampling.js +0 -2
  297. package/packages/server/dist/server.d.ts +0 -63
  298. package/packages/server/dist/server.js +0 -3
  299. package/packages/server/dist/structured-content-guard.d.ts +0 -28
  300. package/packages/server/dist/structured-content-guard.js +0 -1
  301. package/packages/server/dist/task-manager.d.ts +0 -40
  302. package/packages/server/dist/task-manager.js +0 -1
  303. package/packages/server/dist/tool-metadata.d.ts +0 -38
  304. package/packages/server/dist/tool-metadata.js +0 -1
  305. package/packages/server/dist/tool-prefix.d.ts +0 -12
  306. package/packages/server/dist/tool-prefix.js +0 -1
  307. package/packages/server/dist/tool-timeout.d.ts +0 -27
  308. package/packages/server/dist/tool-timeout.js +0 -1
  309. package/packages/server/dist/tools/analyze.tools.d.ts +0 -14
  310. package/packages/server/dist/tools/analyze.tools.js +0 -8
  311. package/packages/server/dist/tools/audit.tool.d.ts +0 -8
  312. package/packages/server/dist/tools/audit.tool.js +0 -1
  313. package/packages/server/dist/tools/brainstorm.tool.d.ts +0 -7
  314. package/packages/server/dist/tools/brainstorm.tool.js +0 -9
  315. package/packages/server/dist/tools/bridge.tools.d.ts +0 -34
  316. package/packages/server/dist/tools/bridge.tools.js +0 -15
  317. package/packages/server/dist/tools/config.tool.d.ts +0 -8
  318. package/packages/server/dist/tools/config.tool.js +0 -12
  319. package/packages/server/dist/tools/context.tools.d.ts +0 -15
  320. package/packages/server/dist/tools/context.tools.js +0 -10
  321. package/packages/server/dist/tools/evolution.tools.d.ts +0 -7
  322. package/packages/server/dist/tools/evolution.tools.js +0 -5
  323. package/packages/server/dist/tools/execution.tools.d.ts +0 -14
  324. package/packages/server/dist/tools/execution.tools.js +0 -4
  325. package/packages/server/dist/tools/flow.tools.d.ts +0 -7
  326. package/packages/server/dist/tools/flow.tools.js +0 -16
  327. package/packages/server/dist/tools/forge.tools.d.ts +0 -13
  328. package/packages/server/dist/tools/forge.tools.js +0 -10
  329. package/packages/server/dist/tools/forget.tool.d.ts +0 -8
  330. package/packages/server/dist/tools/forget.tool.js +0 -1
  331. package/packages/server/dist/tools/graph.tool.d.ts +0 -7
  332. package/packages/server/dist/tools/graph.tool.js +0 -29
  333. package/packages/server/dist/tools/infra.tools.d.ts +0 -10
  334. package/packages/server/dist/tools/infra.tools.js +0 -5
  335. package/packages/server/dist/tools/list.tool.d.ts +0 -7
  336. package/packages/server/dist/tools/list.tool.js +0 -2
  337. package/packages/server/dist/tools/lookup.tool.d.ts +0 -7
  338. package/packages/server/dist/tools/lookup.tool.js +0 -3
  339. package/packages/server/dist/tools/manipulation.tools.d.ts +0 -10
  340. package/packages/server/dist/tools/manipulation.tools.js +0 -4
  341. package/packages/server/dist/tools/onboard.tool.d.ts +0 -12
  342. package/packages/server/dist/tools/onboard.tool.js +0 -2
  343. package/packages/server/dist/tools/persistence.tools.d.ts +0 -10
  344. package/packages/server/dist/tools/persistence.tools.js +0 -5
  345. package/packages/server/dist/tools/policy.tools.d.ts +0 -7
  346. package/packages/server/dist/tools/policy.tools.js +0 -3
  347. package/packages/server/dist/tools/present/browser.d.ts +0 -4
  348. package/packages/server/dist/tools/present/browser.js +0 -93
  349. package/packages/server/dist/tools/present/helpers.d.ts +0 -19
  350. package/packages/server/dist/tools/present/helpers.js +0 -16
  351. package/packages/server/dist/tools/present/html.d.ts +0 -18
  352. package/packages/server/dist/tools/present/html.js +0 -5
  353. package/packages/server/dist/tools/present/index.d.ts +0 -2
  354. package/packages/server/dist/tools/present/index.js +0 -1
  355. package/packages/server/dist/tools/present/markdown.d.ts +0 -32
  356. package/packages/server/dist/tools/present/markdown.js +0 -11
  357. package/packages/server/dist/tools/present/templates.d.ts +0 -14
  358. package/packages/server/dist/tools/present/templates.js +0 -472
  359. package/packages/server/dist/tools/present/tool.d.ts +0 -27
  360. package/packages/server/dist/tools/present/tool.js +0 -39
  361. package/packages/server/dist/tools/present-blocks.d.ts +0 -46
  362. package/packages/server/dist/tools/present-blocks.js +0 -27
  363. package/packages/server/dist/tools/present-charts.d.ts +0 -31
  364. package/packages/server/dist/tools/present-charts.js +0 -34
  365. package/packages/server/dist/tools/present-theme.d.ts +0 -14
  366. package/packages/server/dist/tools/present-theme.js +0 -396
  367. package/packages/server/dist/tools/present-utils.d.ts +0 -11
  368. package/packages/server/dist/tools/present-utils.js +0 -1
  369. package/packages/server/dist/tools/present.tool.d.ts +0 -2
  370. package/packages/server/dist/tools/present.tool.js +0 -1
  371. package/packages/server/dist/tools/produce.tool.d.ts +0 -7
  372. package/packages/server/dist/tools/produce.tool.js +0 -4
  373. package/packages/server/dist/tools/read.tool.d.ts +0 -7
  374. package/packages/server/dist/tools/read.tool.js +0 -2
  375. package/packages/server/dist/tools/reindex.tool.d.ts +0 -11
  376. package/packages/server/dist/tools/reindex.tool.js +0 -9
  377. package/packages/server/dist/tools/remember.tool.d.ts +0 -9
  378. package/packages/server/dist/tools/remember.tool.js +0 -4
  379. package/packages/server/dist/tools/replay.tool.d.ts +0 -6
  380. package/packages/server/dist/tools/replay.tool.js +0 -3
  381. package/packages/server/dist/tools/restore.tool.d.ts +0 -6
  382. package/packages/server/dist/tools/restore.tool.js +0 -3
  383. package/packages/server/dist/tools/search.tool.d.ts +0 -11
  384. package/packages/server/dist/tools/search.tool.js +0 -10
  385. package/packages/server/dist/tools/status.tool.d.ts +0 -28
  386. package/packages/server/dist/tools/status.tool.js +0 -3
  387. package/packages/server/dist/tools/update.tool.d.ts +0 -8
  388. package/packages/server/dist/tools/update.tool.js +0 -1
  389. package/packages/server/dist/tools/utility.tools.d.ts +0 -15
  390. package/packages/server/dist/tools/utility.tools.js +0 -13
  391. package/packages/server/dist/version-check.d.ts +0 -32
  392. package/packages/store/dist/graph-store.interface.d.ts +0 -159
  393. package/packages/store/dist/graph-store.interface.js +0 -1
  394. package/packages/store/dist/lance-store.d.ts +0 -46
  395. package/packages/store/dist/lance-store.js +0 -1
  396. package/packages/store/dist/sqlite-graph-store.d.ts +0 -57
  397. package/packages/store/dist/sqlite-graph-store.js +0 -90
  398. package/packages/store/dist/store-factory.d.ts +0 -12
  399. package/packages/store/dist/store-factory.js +0 -1
  400. package/packages/store/dist/store.interface.d.ts +0 -54
  401. package/packages/store/dist/store.interface.js +0 -1
  402. package/packages/tools/dist/audit.d.ts +0 -65
  403. package/packages/tools/dist/audit.js +0 -6
  404. package/packages/tools/dist/batch.d.ts +0 -23
  405. package/packages/tools/dist/batch.js +0 -1
  406. package/packages/tools/dist/changelog.d.ts +0 -36
  407. package/packages/tools/dist/changelog.js +0 -2
  408. package/packages/tools/dist/check.d.ts +0 -48
  409. package/packages/tools/dist/check.js +0 -2
  410. package/packages/tools/dist/checkpoint.d.ts +0 -19
  411. package/packages/tools/dist/checkpoint.js +0 -1
  412. package/packages/tools/dist/codemod.d.ts +0 -39
  413. package/packages/tools/dist/codemod.js +0 -2
  414. package/packages/tools/dist/compact.d.ts +0 -47
  415. package/packages/tools/dist/compact.js +0 -3
  416. package/packages/tools/dist/compress-output.d.ts +0 -38
  417. package/packages/tools/dist/compress-output.js +0 -1
  418. package/packages/tools/dist/compression/delta-cache.d.ts +0 -29
  419. package/packages/tools/dist/compression/delta-cache.js +0 -1
  420. package/packages/tools/dist/compression/engine.d.ts +0 -34
  421. package/packages/tools/dist/compression/engine.js +0 -4
  422. package/packages/tools/dist/compression/litm.d.ts +0 -20
  423. package/packages/tools/dist/compression/litm.js +0 -1
  424. package/packages/tools/dist/compression/mmr.d.ts +0 -24
  425. package/packages/tools/dist/compression/mmr.js +0 -1
  426. package/packages/tools/dist/compression/rules/docker.d.ts +0 -11
  427. package/packages/tools/dist/compression/rules/docker.js +0 -3
  428. package/packages/tools/dist/compression/rules/generic.d.ts +0 -11
  429. package/packages/tools/dist/compression/rules/generic.js +0 -3
  430. package/packages/tools/dist/compression/rules/git.d.ts +0 -11
  431. package/packages/tools/dist/compression/rules/git.js +0 -3
  432. package/packages/tools/dist/compression/rules/index.d.ts +0 -14
  433. package/packages/tools/dist/compression/rules/index.js +0 -1
  434. package/packages/tools/dist/compression/rules/kubectl.d.ts +0 -11
  435. package/packages/tools/dist/compression/rules/kubectl.js +0 -3
  436. package/packages/tools/dist/compression/rules/lint.d.ts +0 -11
  437. package/packages/tools/dist/compression/rules/lint.js +0 -3
  438. package/packages/tools/dist/compression/rules/npm.d.ts +0 -11
  439. package/packages/tools/dist/compression/rules/npm.js +0 -3
  440. package/packages/tools/dist/compression/rules/test-runner.d.ts +0 -11
  441. package/packages/tools/dist/compression/rules/test-runner.js +0 -3
  442. package/packages/tools/dist/compression/scoring.d.ts +0 -26
  443. package/packages/tools/dist/compression/scoring.js +0 -1
  444. package/packages/tools/dist/compression/types.d.ts +0 -61
  445. package/packages/tools/dist/compression/types.js +0 -1
  446. package/packages/tools/dist/config-extractor.d.ts +0 -9
  447. package/packages/tools/dist/config-extractor.js +0 -7
  448. package/packages/tools/dist/data-transform.d.ts +0 -12
  449. package/packages/tools/dist/data-transform.js +0 -1
  450. package/packages/tools/dist/dead-symbols.d.ts +0 -28
  451. package/packages/tools/dist/dead-symbols.js +0 -2
  452. package/packages/tools/dist/delegate.d.ts +0 -36
  453. package/packages/tools/dist/delegate.js +0 -1
  454. package/packages/tools/dist/diagram-builder.d.ts +0 -9
  455. package/packages/tools/dist/diagram-builder.js +0 -9
  456. package/packages/tools/dist/diff-parse.d.ts +0 -28
  457. package/packages/tools/dist/diff-parse.js +0 -3
  458. package/packages/tools/dist/digest.d.ts +0 -55
  459. package/packages/tools/dist/digest.js +0 -6
  460. package/packages/tools/dist/dogfood-log.d.ts +0 -49
  461. package/packages/tools/dist/dogfood-log.js +0 -2
  462. package/packages/tools/dist/encode.d.ts +0 -16
  463. package/packages/tools/dist/encode.js +0 -1
  464. package/packages/tools/dist/env-info.d.ts +0 -30
  465. package/packages/tools/dist/env-info.js +0 -1
  466. package/packages/tools/dist/eval.d.ts +0 -15
  467. package/packages/tools/dist/eval.js +0 -2
  468. package/packages/tools/dist/evidence-map.d.ts +0 -92
  469. package/packages/tools/dist/evidence-map.js +0 -2
  470. package/packages/tools/dist/file-cache.d.ts +0 -41
  471. package/packages/tools/dist/file-cache.js +0 -3
  472. package/packages/tools/dist/file-summary.d.ts +0 -52
  473. package/packages/tools/dist/file-summary.js +0 -2
  474. package/packages/tools/dist/file-walk.d.ts +0 -6
  475. package/packages/tools/dist/file-walk.js +0 -1
  476. package/packages/tools/dist/find-examples.d.ts +0 -29
  477. package/packages/tools/dist/find-examples.js +0 -3
  478. package/packages/tools/dist/find.d.ts +0 -49
  479. package/packages/tools/dist/find.js +0 -1
  480. package/packages/tools/dist/forge-classify.d.ts +0 -44
  481. package/packages/tools/dist/forge-classify.js +0 -2
  482. package/packages/tools/dist/forge-ground.d.ts +0 -61
  483. package/packages/tools/dist/forge-ground.js +0 -1
  484. package/packages/tools/dist/git-context.d.ts +0 -25
  485. package/packages/tools/dist/git-context.js +0 -3
  486. package/packages/tools/dist/graph-query.d.ts +0 -98
  487. package/packages/tools/dist/graph-query.js +0 -1
  488. package/packages/tools/dist/guide.d.ts +0 -25
  489. package/packages/tools/dist/guide.js +0 -1
  490. package/packages/tools/dist/health.d.ts +0 -16
  491. package/packages/tools/dist/health.js +0 -2
  492. package/packages/tools/dist/http-request.d.ts +0 -25
  493. package/packages/tools/dist/http-request.js +0 -1
  494. package/packages/tools/dist/lane.d.ts +0 -41
  495. package/packages/tools/dist/lane.js +0 -6
  496. package/packages/tools/dist/measure.d.ts +0 -42
  497. package/packages/tools/dist/measure.js +0 -2
  498. package/packages/tools/dist/onboard-utils.d.ts +0 -12
  499. package/packages/tools/dist/onboard-utils.js +0 -1
  500. package/packages/tools/dist/onboard.d.ts +0 -50
  501. package/packages/tools/dist/onboard.js +0 -18
  502. package/packages/tools/dist/parse-output.d.ts +0 -84
  503. package/packages/tools/dist/parse-output.js +0 -2
  504. package/packages/tools/dist/path-resolver.d.ts +0 -14
  505. package/packages/tools/dist/path-resolver.js +0 -1
  506. package/packages/tools/dist/process-manager.d.ts +0 -20
  507. package/packages/tools/dist/process-manager.js +0 -1
  508. package/packages/tools/dist/queue.d.ts +0 -40
  509. package/packages/tools/dist/queue.js +0 -1
  510. package/packages/tools/dist/regex-test.d.ts +0 -33
  511. package/packages/tools/dist/regex-test.js +0 -1
  512. package/packages/tools/dist/regex-utils.d.ts +0 -8
  513. package/packages/tools/dist/regex-utils.js +0 -1
  514. package/packages/tools/dist/rename.d.ts +0 -31
  515. package/packages/tools/dist/rename.js +0 -2
  516. package/packages/tools/dist/replay.d.ts +0 -59
  517. package/packages/tools/dist/replay.js +0 -4
  518. package/packages/tools/dist/response-envelope.d.ts +0 -43
  519. package/packages/tools/dist/response-envelope.js +0 -1
  520. package/packages/tools/dist/restore-points.d.ts +0 -22
  521. package/packages/tools/dist/restore-points.js +0 -1
  522. package/packages/tools/dist/schema-validate.d.ts +0 -25
  523. package/packages/tools/dist/schema-validate.js +0 -1
  524. package/packages/tools/dist/scope-map.d.ts +0 -51
  525. package/packages/tools/dist/scope-map.js +0 -1
  526. package/packages/tools/dist/snippet.d.ts +0 -35
  527. package/packages/tools/dist/snippet.js +0 -1
  528. package/packages/tools/dist/stash.d.ts +0 -14
  529. package/packages/tools/dist/stash.js +0 -1
  530. package/packages/tools/dist/stratum-card.d.ts +0 -30
  531. package/packages/tools/dist/stratum-card.js +0 -4
  532. package/packages/tools/dist/symbol.d.ts +0 -45
  533. package/packages/tools/dist/symbol.js +0 -3
  534. package/packages/tools/dist/synthesis-engine.d.ts +0 -13
  535. package/packages/tools/dist/synthesis-engine.js +0 -6
  536. package/packages/tools/dist/test-run.d.ts +0 -28
  537. package/packages/tools/dist/test-run.js +0 -2
  538. package/packages/tools/dist/text-utils.d.ts +0 -24
  539. package/packages/tools/dist/text-utils.js +0 -2
  540. package/packages/tools/dist/time-utils.d.ts +0 -20
  541. package/packages/tools/dist/time-utils.js +0 -1
  542. package/packages/tools/dist/trace.d.ts +0 -43
  543. package/packages/tools/dist/trace.js +0 -2
  544. package/packages/tools/dist/truncation.d.ts +0 -66
  545. package/packages/tools/dist/truncation.js +0 -11
  546. package/packages/tools/dist/watch.d.ts +0 -32
  547. package/packages/tools/dist/watch.js +0 -1
  548. package/packages/tools/dist/web-fetch.d.ts +0 -47
  549. package/packages/tools/dist/web-fetch.js +0 -8
  550. package/packages/tools/dist/web-search.d.ts +0 -25
  551. package/packages/tools/dist/web-search.js +0 -1
  552. package/packages/tools/dist/workset.d.ts +0 -47
  553. package/packages/tools/dist/workset.js +0 -1
  554. package/scaffold/__tests__/copilot-inline-shared-protocols.test.mjs +0 -39
  555. /package/packages/server/dist/{config.js → config-C5IU9Lau.js} +0 -0
  556. /package/packages/server/dist/{dashboard-static.js → dashboard-static-BfIe0Si1.js} +0 -0
  557. /package/packages/server/dist/{version-check.js → version-check-D4j0Pykd.js} +0 -0
@@ -1,4 +0,0 @@
1
- import{readFile as e,writeFile as t}from"node:fs/promises";import{dirname as n,resolve as r}from"node:path";import{appendFileSync as i,mkdirSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{resolveStateDir as c}from"../../core/dist/index.js";const l=5e3;let u=0;function d(){return r(c(process.cwd()),`replay.jsonl`)}function f(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function p(e){let t=d();a(n(t),{recursive:!0});let r={...e,input:f(e.input,200),output:f(e.output,200)};i(t,`${JSON.stringify(r)}\n`,`utf-8`),u++,u>=100&&(u=0,h().catch(()=>{}))}function m(e={}){let t=d(),n;try{n=o(t,`utf-8`)}catch{return[]}let r=n.trim().split(`
2
- `).filter(Boolean),i=[];for(let e of r)try{i.push(JSON.parse(e))}catch{}if(e.tool&&(i=i.filter(t=>t.tool===e.tool)),e.source&&(i=i.filter(t=>t.source===e.source)),e.since){let t=e.since;i=i.filter(e=>e.ts>=t)}let a=e.last??20;return i.slice(-a)}async function h(){let n=d(),r;try{r=await e(n,`utf-8`)}catch{return 0}let i=r.trim().split(`
3
- `).filter(Boolean);if(i.length<=l)return 0;let a=i.length-l;return await t(n,`${i.slice(-l).join(`
4
- `)}\n`,`utf-8`),a}function g(){let e=d();try{s(e,``,`utf-8`)}catch{}}function _(e,t,n,r){let i=Date.now();return r().then(r=>(p({ts:new Date().toISOString(),source:e,tool:t,input:typeof n==`string`?n:JSON.stringify(n),durationMs:Date.now()-i,status:`ok`,output:typeof r==`string`?r:JSON.stringify(r??``)}),r)).catch(r=>{throw p({ts:new Date().toISOString(),source:e,tool:t,input:typeof n==`string`?n:JSON.stringify(n),durationMs:Date.now()-i,status:`error`,output:r instanceof Error?r.message:String(r)}),r})}export{p as replayAppend,_ as replayCapture,g as replayClear,m as replayList,h as replayTrim};
@@ -1,43 +0,0 @@
1
- //#region packages/tools/src/response-envelope.d.ts
2
- /**
3
- * Standardized response envelope for AI Kit tools (E-009).
4
- * New tools should return KBResponse<T>. Existing tools can adopt gradually.
5
- */
6
- interface KBNextHint {
7
- tool: string;
8
- reason: string;
9
- suggested_args?: Record<string, unknown>;
10
- }
11
- interface KBError {
12
- code: KBErrorCode;
13
- category: 'input' | 'runtime' | 'dependency' | 'timeout' | 'not_found';
14
- retryable: boolean;
15
- message: string;
16
- suggestion?: string;
17
- }
18
- type KBErrorCode = 'SYMBOL_NOT_FOUND' | 'INDEX_STALE' | 'TREE_SITTER_UNAVAILABLE' | 'PARSE_FAILED' | 'BUDGET_EXCEEDED' | 'PATH_NOT_FOUND' | 'EMBEDDING_COLD_START' | 'ANALYSIS_FAILED';
19
- interface KBResponseMeta {
20
- durationMs: number;
21
- tokensEstimate: number;
22
- detail: 'summary' | 'errors' | 'full';
23
- cached: boolean;
24
- truncated: boolean;
25
- caveats?: string[];
26
- }
27
- interface KBResponse<T> {
28
- ok: boolean;
29
- tool: string;
30
- summary: string;
31
- data?: T;
32
- meta: KBResponseMeta;
33
- next?: KBNextHint[];
34
- error?: KBError;
35
- }
36
- /** Create a success response. */
37
- declare function okResponse<T>(tool: string, summary: string, data: T, meta: Partial<KBResponseMeta> & {
38
- durationMs: number;
39
- }, next?: KBNextHint[]): KBResponse<T>;
40
- /** Create an error response. */
41
- declare function errorResponse(tool: string, error: KBError, durationMs: number): KBResponse<never>;
42
- //#endregion
43
- export { KBError, KBErrorCode, KBNextHint, KBResponse, KBResponseMeta, errorResponse, okResponse };
@@ -1 +0,0 @@
1
- import{estimateTokens as e}from"./text-utils.js";function t(t,n,r,i,a){let o=typeof r==`string`?r:JSON.stringify(r);return{ok:!0,tool:t,summary:n,data:r,meta:{durationMs:i.durationMs,tokensEstimate:i.tokensEstimate??e(o),detail:i.detail??`summary`,cached:i.cached??!1,truncated:i.truncated??!1,...i.caveats?.length?{caveats:i.caveats}:{}},next:a}}function n(t,n,r){return{ok:!1,tool:t,summary:n.message,meta:{durationMs:r,tokensEstimate:e(n.message),detail:`summary`,cached:!1,truncated:!1},error:n}}export{n as errorResponse,t as okResponse};
@@ -1,22 +0,0 @@
1
- //#region packages/tools/src/restore-points.d.ts
2
- interface RestorePoint {
3
- id: string;
4
- timestamp: string;
5
- operation: 'codemod' | 'rename' | 'forget';
6
- files: Array<{
7
- path: string;
8
- content: string;
9
- }>;
10
- description: string;
11
- }
12
- /** Create a restore point before a destructive operation */
13
- declare function createRestorePoint(operation: RestorePoint['operation'], files: Array<{
14
- path: string;
15
- content: string;
16
- }>, description: string): string;
17
- /** List all restore points (newest first) */
18
- declare function listRestorePoints(): RestorePoint[];
19
- /** Restore files from a restore point, returns list of restored paths */
20
- declare function restoreFromPoint(id: string): Promise<string[]>;
21
- //#endregion
22
- export { RestorePoint, createRestorePoint, listRestorePoints, restoreFromPoint };
@@ -1 +0,0 @@
1
- import{writeFile as e}from"node:fs/promises";import{dirname as t,join as n}from"node:path";import{existsSync as r,mkdirSync as i,readFileSync as a,readdirSync as o,unlinkSync as s,writeFileSync as c}from"node:fs";import{AIKIT_PATHS as l}from"../../core/dist/index.js";const u=l.restorePoints;function d(){let e=n(process.cwd(),u);return r(e)||i(e,{recursive:!0}),e}function f(e,t,r){let i=d(),a=`${Date.now()}-${e}`,l={id:a,timestamp:new Date().toISOString(),operation:e,files:t,description:r};c(n(i,`${a}.json`),`${JSON.stringify(l,null,2)}\n`,`utf-8`);let u=o(i).filter(e=>e.endsWith(`.json`)).sort();for(;u.length>50;){let e=u.shift();if(!e)break;try{s(n(i,e))}catch{}}return a}function p(){let e=n(process.cwd(),u);return r(e)?o(e).filter(e=>e.endsWith(`.json`)).sort().reverse().map(t=>{try{return JSON.parse(a(n(e,t),`utf-8`))}catch(r){return console.debug(`Skipping corrupt restore point ${n(e,t)}: ${r instanceof Error?r.message:String(r)}`),null}}).filter(e=>e!==null):[]}async function m(o){let s=n(n(process.cwd(),u),`${o}.json`);if(!r(s))throw Error(`Restore point not found: ${o}`);let c=JSON.parse(a(s,`utf-8`)),l=[];for(let n of c.files){let a=t(n.path);r(a)||i(a,{recursive:!0}),await e(n.path,n.content,`utf-8`),l.push(n.path)}return l}export{f as createRestorePoint,p as listRestorePoints,m as restoreFromPoint};
@@ -1,25 +0,0 @@
1
- //#region packages/tools/src/schema-validate.d.ts
2
- /**
3
- * aikit_schema_validate — Validate data against a JSON Schema (core subset).
4
- *
5
- * Supports: type, required, properties, additionalProperties, items,
6
- * enum, const, pattern, minimum, maximum, minLength, maxLength,
7
- * minItems, maxItems.
8
- */
9
- interface SchemaValidateOptions {
10
- data: unknown;
11
- schema: Record<string, unknown>;
12
- }
13
- interface ValidationError {
14
- path: string;
15
- message: string;
16
- expected?: string;
17
- received?: string;
18
- }
19
- interface SchemaValidateResult {
20
- valid: boolean;
21
- errors: ValidationError[];
22
- }
23
- declare function schemaValidate(options: SchemaValidateOptions): SchemaValidateResult;
24
- //#endregion
25
- export { SchemaValidateOptions, SchemaValidateResult, ValidationError, schemaValidate };
@@ -1 +0,0 @@
1
- function e(e){let n=[];return t(e.data,e.schema,`$`,n),{valid:n.length===0,errors:n}}function t(e,i,a,o){if(`type`in i){let t=i.type;if(!n(e,t)){o.push({path:a,message:`Expected type "${t}"`,expected:t,received:r(e)});return}}if(`enum`in i){let t=i.enum;t.some(t=>JSON.stringify(t)===JSON.stringify(e))||o.push({path:a,message:`Must be one of: ${JSON.stringify(t)}`,received:JSON.stringify(e)})}if(`const`in i&&JSON.stringify(e)!==JSON.stringify(i.const)&&o.push({path:a,message:`Must equal ${JSON.stringify(i.const)}`,received:JSON.stringify(e)}),typeof e==`string`&&(`minLength`in i&&e.length<i.minLength&&o.push({path:a,message:`String too short (min: ${i.minLength})`,received:`length ${e.length}`}),`maxLength`in i&&e.length>i.maxLength&&o.push({path:a,message:`String too long (max: ${i.maxLength})`,received:`length ${e.length}`}),`pattern`in i))try{new RegExp(i.pattern).test(e)||o.push({path:a,message:`Does not match pattern: ${i.pattern}`})}catch(e){o.push({path:a,message:`Invalid pattern: ${e instanceof Error?e.message:String(e)}`})}if(typeof e==`number`&&(`minimum`in i&&e<i.minimum&&o.push({path:a,message:`Below minimum (${i.minimum})`,received:String(e)}),`maximum`in i&&e>i.maximum&&o.push({path:a,message:`Above maximum (${i.maximum})`,received:String(e)})),Array.isArray(e)&&(`minItems`in i&&e.length<i.minItems&&o.push({path:a,message:`Too few items (min: ${i.minItems})`,received:`length ${e.length}`}),`maxItems`in i&&e.length>i.maxItems&&o.push({path:a,message:`Too many items (max: ${i.maxItems})`,received:`length ${e.length}`}),`items`in i))for(let n=0;n<e.length;n++)t(e[n],i.items,`${a}[${n}]`,o);if(e&&typeof e==`object`&&!Array.isArray(e)){let n=e;if(`required`in i)for(let e of i.required)e in n||o.push({path:`${a}.${e}`,message:`Required property missing`});if(`properties`in i){let e=i.properties;for(let[r,i]of Object.entries(e))r in n&&t(n[r],i,`${a}.${r}`,o)}if(`additionalProperties`in i&&i.additionalProperties===!1){let e=Object.keys(i.properties??{});for(let t of Object.keys(n))e.includes(t)||o.push({path:`${a}.${t}`,message:`Additional property not allowed`})}}}function n(e,t){switch(t){case`string`:return typeof e==`string`;case`number`:return typeof e==`number`&&!Number.isNaN(e);case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`null`:return e===null;case`array`:return Array.isArray(e);case`object`:return typeof e==`object`&&!!e&&!Array.isArray(e);default:return!0}}function r(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}export{e as schemaValidate};
@@ -1,51 +0,0 @@
1
- import { ContentType, KnowledgeOrigin } from "../../core/dist/index.js";
2
- import { IEmbedder } from "../../embeddings/dist/index.js";
3
- import { IKnowledgeStore } from "../../store/dist/index.js";
4
-
5
- //#region packages/tools/src/scope-map.d.ts
6
- interface ScopeMapOptions {
7
- /** Description of the task to scope */
8
- task: string;
9
- /** Maximum number of files to include (default: 15) */
10
- maxFiles?: number;
11
- /** Group results by directory (default: true) */
12
- groupByDirectory?: boolean;
13
- /** Filter by content type */
14
- contentType?: ContentType;
15
- /** Filter by origin */
16
- origin?: KnowledgeOrigin;
17
- }
18
- interface ScopeMapEntry {
19
- /** File path */
20
- path: string;
21
- /** Why this file is relevant (derived from matched chunks) */
22
- reason: string;
23
- /** Estimated token count (chars / 4 approximation) */
24
- estimatedTokens: number;
25
- /** Relevance score (0-1) */
26
- relevance: number;
27
- /** Line ranges to focus on */
28
- focusRanges: Array<{
29
- start: number;
30
- end: number;
31
- heading?: string;
32
- }>;
33
- }
34
- interface ScopeMapResult {
35
- /** The task that was analyzed */
36
- task: string;
37
- /** Prioritized file list */
38
- files: ScopeMapEntry[];
39
- /** Total estimated tokens across all files */
40
- totalEstimatedTokens: number;
41
- /** Suggested reading order (file paths) */
42
- readingOrder: string[];
43
- /** Suggested compact/file_summary commands to reduce context */
44
- compactCommands: string[];
45
- }
46
- /**
47
- * Generate a task-scoped reading plan.
48
- */
49
- declare function scopeMap(embedder: IEmbedder, store: IKnowledgeStore, options: ScopeMapOptions): Promise<ScopeMapResult>;
50
- //#endregion
51
- export { ScopeMapEntry, ScopeMapOptions, ScopeMapResult, scopeMap };
@@ -1 +0,0 @@
1
- function e(e){return Math.ceil(e.length/4)}async function t(t,n,r){let{task:i,maxFiles:a=15,contentType:o,origin:s}=r,c=await t.embed(i),l={limit:a*3,contentType:o,origin:s},u=await n.search(c,l),d=new Map;for(let e of u){let t=e.record.sourcePath,n=d.get(t);n?(n.chunks.push(e),n.totalChars+=e.record.content.length,n.maxScore=Math.max(n.maxScore,e.score)):d.set(t,{chunks:[e],totalChars:e.record.content.length,maxScore:e.score})}let f=[...d.entries()].sort(([,e],[,t])=>t.maxScore-e.maxScore).slice(0,a).map(([e,{chunks:t,maxScore:n}])=>{let r=t.sort((e,t)=>e.record.startLine-t.record.startLine).map(e=>({start:e.record.startLine,end:e.record.endLine,heading:e.record.headingPath})),i=t.sort((e,t)=>t.score-e.score)[0];return{path:e,reason:i.record.headingPath?`Matches: ${i.record.headingPath}`:`Contains relevant ${i.record.contentType} content`,estimatedTokens:0,relevance:n,focusRanges:r}});for(let t of f){let n=d.get(t.path);n&&(t.estimatedTokens=e(n.chunks.map(e=>e.record.content).join(``)))}let p=f.reduce((e,t)=>e+t.estimatedTokens,0),m=[...f].sort((e,t)=>{let n=e.path.includes(`config`)||e.path.includes(`types`)?-1:0,r=t.path.includes(`config`)||t.path.includes(`types`)?-1:0;return n===r?t.relevance-e.relevance:n-r}).map(e=>e.path),h=[];for(let e of f)e.estimatedTokens<=100?h.push(`aikit_file_summary({ path: "${e.path}" }) → ~${e.estimatedTokens} tokens`):h.push(`aikit_compact({ path: "${e.path}", query: "${i}" }) → ~${Math.ceil(e.estimatedTokens/5)} tokens`);return{task:i,files:f,totalEstimatedTokens:p,readingOrder:m,compactCommands:h}}export{t as scopeMap};
@@ -1,35 +0,0 @@
1
- //#region packages/tools/src/snippet.d.ts
2
- /**
3
- * aikit_snippet — Persistent code template storage with search.
4
- */
5
- interface Snippet {
6
- name: string;
7
- language: string;
8
- code: string;
9
- tags: string[];
10
- created: string;
11
- updated: string;
12
- }
13
- type SnippetAction = 'save' | 'get' | 'list' | 'search' | 'delete';
14
- interface SnippetOptions {
15
- action: SnippetAction;
16
- name?: string;
17
- language?: string;
18
- code?: string;
19
- tags?: string[];
20
- query?: string;
21
- }
22
- type SnippetResult = Snippet | {
23
- snippets: SnippetSummary[];
24
- } | {
25
- deleted: boolean;
26
- };
27
- interface SnippetSummary {
28
- name: string;
29
- language: string;
30
- tags: string[];
31
- updated: string;
32
- }
33
- declare function snippet(options: SnippetOptions): SnippetResult;
34
- //#endregion
35
- export { Snippet, SnippetAction, SnippetOptions, SnippetResult, snippet };
@@ -1 +0,0 @@
1
- import{join as e}from"node:path";import{existsSync as t,mkdirSync as n,readFileSync as r,readdirSync as i,renameSync as a,unlinkSync as o,writeFileSync as s}from"node:fs";import{resolveStateDir as c}from"../../core/dist/index.js";const l=()=>e(c(process.cwd()),`snippets`);function u(){let e=l();return t(e)||n(e,{recursive:!0}),e}function d(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);if(!t)throw Error(`Invalid snippet name`);return t}function f(n){switch(n.action){case`save`:{if(!n.name||!n.code)throw Error(`name and code required for save`);let i=e(u(),`${d(n.name)}.json`),o=null;if(t(i))try{o=JSON.parse(r(i,`utf8`))}catch(e){e?.code!==`ENOENT`&&console.warn(`Corrupt state file ${i}: ${e instanceof Error?e.message:String(e)}`),o=null}let c=new Date().toISOString(),l={name:n.name,language:n.language??`text`,code:n.code,tags:n.tags??[],created:o?.created??c,updated:c},f=`${i}.tmp`;return s(f,JSON.stringify(l,null,2)),a(f,i),l}case`get`:{if(!n.name)throw Error(`name required for get`);let i=e(l(),`${d(n.name)}.json`);if(!t(i))throw Error(`Snippet not found: ${n.name}`);try{return JSON.parse(r(i,`utf8`))}catch(e){throw e?.code!==`ENOENT`&&console.warn(`Corrupt state file ${i}: ${e instanceof Error?e.message:String(e)}`),Error(`Snippet corrupted: ${n.name}`)}}case`list`:{let t=u();return{snippets:i(t).filter(e=>e.endsWith(`.json`)).flatMap(n=>{let i=e(t,n);try{let e=JSON.parse(r(i,`utf8`));return[{name:e.name,language:e.language,tags:e.tags,updated:e.updated}]}catch(e){return e?.code!==`ENOENT`&&console.warn(`Corrupt state file ${i}: ${e instanceof Error?e.message:String(e)}`),[]}})}}case`search`:{if(!n.query)throw Error(`query required for search`);let t=n.query.toLowerCase(),a=u();return{snippets:i(a).filter(e=>e.endsWith(`.json`)).flatMap(t=>{let n=e(a,t);try{return[JSON.parse(r(n,`utf8`))]}catch(e){return e?.code!==`ENOENT`&&console.warn(`Corrupt state file ${n}: ${e instanceof Error?e.message:String(e)}`),[]}}).filter(e=>e.name.toLowerCase().includes(t)||e.tags.some(e=>e.toLowerCase().includes(t))||e.language.toLowerCase().includes(t)||e.code.toLowerCase().includes(t)).map(e=>({name:e.name,language:e.language,tags:e.tags,updated:e.updated}))}}case`delete`:{if(!n.name)throw Error(`name required for delete`);let r=e(l(),`${d(n.name)}.json`);return t(r)?(o(r),{deleted:!0}):{deleted:!1}}default:throw Error(`Unknown action: ${n.action}`)}}export{f as snippet};
@@ -1,14 +0,0 @@
1
- //#region packages/tools/src/stash.d.ts
2
- interface StashEntry {
3
- key: string;
4
- value: unknown;
5
- type: string;
6
- storedAt: string;
7
- }
8
- declare function stashSet(key: string, value: unknown, cwd?: string): StashEntry;
9
- declare function stashGet(key: string, cwd?: string): StashEntry | undefined;
10
- declare function stashList(cwd?: string): StashEntry[];
11
- declare function stashDelete(key: string, cwd?: string): boolean;
12
- declare function stashClear(cwd?: string): number;
13
- //#endregion
14
- export { StashEntry, stashClear, stashDelete, stashGet, stashList, stashSet };
@@ -1 +0,0 @@
1
- import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,renameSync as a,writeFileSync as o}from"node:fs";import{resolveStateDir as s}from"../../core/dist/index.js";function c(e){return t(s(e??process.cwd()),`stash.json`)}function l(e){let t=c(e);if(!n(t))return{};try{let e=i(t,`utf-8`);return JSON.parse(e)}catch(e){return e?.code===`ENOENT`||console.warn(`Corrupt state file ${t}: ${e instanceof Error?e.message:String(e)}`),{}}}function u(t,i){let s=c(i),l=e(s);n(l)||r(l,{recursive:!0});let u=`${s}.tmp`;o(u,`${JSON.stringify(t,null,2)}\n`,`utf-8`),a(u,s)}function d(e,t,n){let r=l(n),i={key:e,value:t,type:typeof t,storedAt:new Date().toISOString()};return r[e]=i,u(r,n),i}function f(e,t){return l(t)[e]}function p(e){return Object.values(l(e))}function m(e,t){let n=l(t);return e in n?(delete n[e],u(n,t),!0):!1}function h(e){let t=l(e),n=Object.keys(t).length;return u({},e),n}export{h as stashClear,m as stashDelete,f as stashGet,p as stashList,d as stashSet};
@@ -1,30 +0,0 @@
1
- import { FileCache } from "./file-cache.js";
2
- import { IEmbedder } from "../../embeddings/dist/index.js";
3
-
4
- //#region packages/tools/src/stratum-card.d.ts
5
- interface StratumCardOptions {
6
- files: string[];
7
- query: string;
8
- tier?: 'T1' | 'T2';
9
- maxContentChars?: number;
10
- /** Optional file cache — avoids redundant reads and eliminates double-read with fileSummary */
11
- cache?: FileCache;
12
- }
13
- interface StratumCard {
14
- path: string;
15
- tier: 'T1' | 'T2';
16
- card: string;
17
- unknowns: string[];
18
- riskTier: 'low' | 'medium' | 'high';
19
- tokenEstimate: number;
20
- originalTokenEstimate: number;
21
- }
22
- interface StratumCardResult {
23
- cards: StratumCard[];
24
- totalTokenEstimate: number;
25
- totalOriginalTokenEstimate: number;
26
- compressionRatio: number;
27
- }
28
- declare function stratumCard(embedder: IEmbedder, options: StratumCardOptions): Promise<StratumCardResult>;
29
- //#endregion
30
- export { StratumCard, StratumCardOptions, StratumCardResult, stratumCard };
@@ -1,4 +0,0 @@
1
- import{cosineSimilarity as e,estimateTokens as t,segment as n}from"./text-utils.js";import{fileSummary as r}from"./file-summary.js";import{readFile as i}from"node:fs/promises";import{basename as a,extname as o,relative as s}from"node:path";async function c(e,n){let{files:a,query:o,tier:s=`T1`,maxContentChars:c=800}=n,{cache:f}=n,h=s===`T2`?await e.embedQuery(o):null,g=await Promise.all(a.map(async n=>{try{let a=f?(await f.get(n)).content:await i(n,`utf-8`),o=t(a);if(a.includes(`\0`))return l(n,s,`binary`,`binary file`,o);if(a.trim().length===0){let e=u({displayPath:d(n),tier:s,role:`empty`,deps:[],exports:[],unknowns:[],riskTier:`low`});return{path:n,tier:s,card:e,unknowns:[],riskTier:`low`,tokenEstimate:t(e),originalTokenEstimate:o}}let g=await r({path:n,content:a}),y=p(n,g),x=m(a,g),S=_(n,g),C=v(g),w=[...new Set(g.exports)].slice(0,5),T=u({displayPath:d(n),tier:s,role:y,deps:C,exports:w,unknowns:x,riskTier:S});if(s===`T2`&&h){let t=await b(e,h,a,c);t.length>0&&(T=`${T}\nCONTEXT:\n${t}`)}return{path:n,tier:s,card:T,unknowns:x,riskTier:S,tokenEstimate:t(T),originalTokenEstimate:o}}catch(e){let t=e.code===`ENOENT`?`file missing`:`unreadable file`;return l(n,s,e.code===`ENOENT`?`missing`:`unreadable`,t,0)}})),y=g.reduce((e,t)=>e+t.tokenEstimate,0),x=g.reduce((e,t)=>e+t.originalTokenEstimate,0);return{cards:g,totalTokenEstimate:y,totalOriginalTokenEstimate:x,compressionRatio:x===0?0:y/x}}function l(e,n,r,i,a){let o=u({displayPath:d(e),tier:n,role:r,deps:[],exports:[],unknowns:[i],riskTier:`low`});return{path:e,tier:n,card:o,unknowns:[i],riskTier:`low`,tokenEstimate:t(o),originalTokenEstimate:a}}function u(e){let{displayPath:t,tier:n,role:r,deps:i,exports:a,unknowns:o,riskTier:s}=e;return[`[${n}: ${t}]`,`ROLE: ${r}`,`DEPS: ${f(i)}`,`EXPORTS: ${f(a)}`,`UNKNOWNS: ${f(o,`; `)}`,`RISK: ${s}`].join(`
2
- `)}function d(e){let t=s(process.cwd(),e).replace(/\\/g,`/`);return!t||t.startsWith(`..`)?a(e):t}function f(e,t=`, `){return e.length>0?e.join(t):`none`}function p(e,t){let n=a(e),r=o(n).toLowerCase();return[`.json`,`.yaml`,`.yml`,`.env`].includes(r)||/config|settings/i.test(n)?`configuration`:/types?\.ts$|\.d\.ts$/i.test(n)?`type-definitions`:/schema/i.test(n)?`schema`:/test|spec/i.test(n)?`test`:/index\.[jt]sx?$/i.test(n)?`barrel-export`:/handler|controller|route/i.test(n)?`entry-point`:/model|entity/i.test(n)?`data-model`:/util|helper/i.test(n)?`utility`:/service|provider/i.test(n)?`service`:t.classes.length>0?`class-module`:t.interfaces.length>2?`type-definitions`:`implementation`}function m(e,t){let n=[],r=new Set;for(let t of e.matchAll(/\/\/\s*(TODO|FIXME|HACK|XXX)\s*:?\s*(.+)?$/gm))h(n,r,`${t[1]}: ${(t[2]??``).trim()}`.trim().replace(/:\s*$/,``));g(e)&&h(n,r,`exported any usage`);for(let e of v(t))h(n,r,`cross-package import: ${e}`);return n.slice(0,3)}function h(e,t,n){e.length>=3||!n||t.has(n)||(t.add(n),e.push(n))}function g(e){return[/export\s+(?:async\s+)?function\s+\w+[^\n{;]*\bany\b/g,/export\s+interface\s+\w+[\s\S]*?\{[\s\S]*?\bany\b[\s\S]*?\}/g,/export\s+type\s+\w+\s*=.*\bany\b/g,/export\s+const\s+\w+[^\n=]*\bany\b/g].some(t=>t.test(e))}function _(e,t){return/auth|token|permission|secret|credential|encrypt/i.test(e)?`high`:/types?\.ts$|schema|contract|\.d\.ts$/i.test(a(e))||t.exports.length>10?`medium`:`low`}function v(e){return e.imports.map(y).filter(e=>!!e).filter(e=>!e.startsWith(`./`)&&!e.startsWith(`../`)).slice(0,3)}function y(e){let t=e.match(/from\s+['"]([^'"]+)['"]/);if(t)return t[1];let n=e.match(/^import\s+['"]([^'"]+)['"]/);return n?n[1]:null}async function b(t,r,i,a){if(a<=0)return``;let o=n(i,`paragraph`);if(o.length===0)return``;let s=await Promise.all(o.map(async(n,i)=>({index:i,text:n,score:e(r,await t.embed(n))}))),c=[],l=0;for(let e of s.sort((e,t)=>t.score-e.score)){let t=a-l;if(t<=0)break;if(e.text.length<=t){c.push({index:e.index,text:e.text}),l+=e.text.length;continue}c.length===0&&(c.push({index:e.index,text:e.text.slice(0,t).trimEnd()}),l=a);break}return c.sort((e,t)=>e.index-t.index).map(e=>e.text).filter(e=>e.length>0).join(`
3
-
4
- `)}export{c as stratumCard};
@@ -1,45 +0,0 @@
1
- import { IEmbedder } from "../../embeddings/dist/index.js";
2
- import { IGraphStore, IKnowledgeStore } from "../../store/dist/index.js";
3
-
4
- //#region packages/tools/src/symbol.d.ts
5
- interface SymbolGraphContext {
6
- /** Module that defines this symbol */
7
- definingModule?: string;
8
- /** Modules that import the file containing this symbol */
9
- importedByModules: string[];
10
- /** Symbols defined in the same module */
11
- siblingSymbols: string[];
12
- }
13
- interface SymbolInfo {
14
- name: string;
15
- definedIn?: {
16
- path: string;
17
- line: number;
18
- kind: string;
19
- signature?: string;
20
- };
21
- importedBy: Array<{
22
- path: string;
23
- line: number;
24
- importStatement: string;
25
- }>;
26
- referencedIn: Array<{
27
- path: string;
28
- line: number;
29
- context: string;
30
- scope?: string;
31
- }>;
32
- /** Graph-derived context (when graph store available) */
33
- graphContext?: SymbolGraphContext;
34
- }
35
- interface SymbolOptions {
36
- /** Symbol name to look up */
37
- name: string;
38
- /** Limit results */
39
- limit?: number;
40
- /** Optional graph store for enriching results */
41
- graphStore?: IGraphStore;
42
- }
43
- declare function symbol(embedder: IEmbedder, store: IKnowledgeStore, options: SymbolOptions): Promise<SymbolInfo>;
44
- //#endregion
45
- export { SymbolGraphContext, SymbolInfo, SymbolOptions, symbol };
@@ -1,3 +0,0 @@
1
- import{escapeRegExp as e}from"./regex-utils.js";import{extname as t}from"node:path";import{SUPPORTED_EXTENSIONS as n,WasmRuntime as r,extractSymbols as i,resolveScopes as a}from"../../chunker/dist/index.js";async function o(o,s,c){let{name:l,limit:u=20,graphStore:d}=c,f=o.embedQuery?.bind(o)??o.embed.bind(o),p=[`export function ${l}`,`export class ${l}`,`export const ${l}`,`export interface ${l}`,`export type ${l}`,`export enum ${l}`].join(` | `),m=await s.search(await f(p),{limit:u*2}),h=RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${e(l)}\\b`,`m`),g;for(let e of m){if(!h.test(e.record.content))continue;let a=e.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??`unknown`;g={path:e.record.sourcePath,line:e.record.startLine,kind:a};let o=t(e.record.sourcePath);if(r.get()&&n.has(o))try{let t=(await i(e.record.content,o,e.record.sourcePath)).find(e=>e.name===l&&e.exported);t&&(g.kind=t.kind,t.signature&&(g.signature=t.signature))}catch{}break}let _=RegExp(`import\\s+.*\\b${e(l)}\\b.*from\\s+`,`m`),v=await s.search(await f(`import ${l} from`),{limit:u*3}),y=[],b=new Set;for(let e of v){let t=e.record.content.split(`
2
- `);for(let n=0;n<t.length;n++){let r=t[n];if(!_.test(r))continue;let i=`${e.record.sourcePath}:${r.trim()}`;b.has(i)||(b.add(i),y.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:r.trim()}))}}let x=RegExp(`\\b${e(l)}\\b`),S=await s.search(await f(l),{limit:u*3}),C=[],w=new Set;for(let e of S){if(C.length>=u)break;if(g&&e.record.sourcePath===g.path)continue;let i=e.record.content.split(`
3
- `);for(let o=0;o<i.length;o++){let s=i[o];if(!x.test(s)||_.test(s))continue;let c=`${e.record.sourcePath}:${e.record.startLine+o}`;if(w.has(c))continue;w.add(c);let l,u=t(e.record.sourcePath);if(r.get()&&n.has(u))try{let t=await a(e.record.content,u,o+1);t.length>0&&(l=t[0].name)}catch{}C.push({path:e.record.sourcePath,line:e.record.startLine+o,context:s.trim().slice(0,120),scope:l});break}}let T;if(d)try{let e={importedByModules:[],siblingSymbols:[]},t=await d.findNodes({namePattern:l});if(t.length>0){let n=t[0];if(n.sourcePath?e.definingModule=n.sourcePath:g&&(e.definingModule=g.path),n.sourcePath){let t=(await d.findNodes({sourcePath:n.sourcePath,type:`module`}))[0];if(t){let n=await d.getNeighbors(t.id,{direction:`incoming`,edgeType:`imports`});for(let t of n.nodes)e.importedByModules.push(t.sourcePath??t.name)}}if(e.definingModule){let t=await d.findNodes({sourcePath:e.definingModule});for(let n of t)n.name!==l&&n.type!==`module`&&e.siblingSymbols.push(`${n.type}:${n.name}`);e.siblingSymbols=e.siblingSymbols.slice(0,15)}}(e.definingModule||e.importedByModules.length>0||e.siblingSymbols.length>0)&&(T=e)}catch{}return{name:l,definedIn:g,importedBy:y.slice(0,u),referencedIn:C.slice(0,u),graphContext:T}}export{o as symbol};
@@ -1,13 +0,0 @@
1
- import { OnboardMode, OnboardStepResult } from "./onboard.js";
2
-
3
- //#region packages/tools/src/synthesis-engine.d.ts
4
- declare function buildSynthesisGuide(steps: OnboardStepResult[], mode: OnboardMode, projectName: string, dataMap: Map<string, Record<string, unknown>>): string;
5
- /**
6
- * Build a compact code-map.md showing module relationships with call edges.
7
- * Uses TypeScript compiler API call graph when available, falls back to
8
- * import-based dependency graph for non-TS projects.
9
- * Designed to be LLM-consumable (~10-50KB).
10
- */
11
- declare function buildCodeMap(dataMap: Map<string, Record<string, unknown>>, projectName: string, callGraph: Map<string, Map<string, string[]>> | null): string;
12
- //#endregion
13
- export { buildCodeMap, buildSynthesisGuide };
@@ -1,6 +0,0 @@
1
- import{getPackageKey as e,isTestPath as t,resolveExtensionlessPath as n}from"./onboard-utils.js";const r={structure:`Project Structure`,dependencies:`Dependencies`,"entry-points":`Entry Points`,symbols:`Symbols`,patterns:`Patterns`,diagram:`C4 Container Diagram`,"code-map":`Code Map (Module Graph)`,"config-values":`Configuration Values`,"synthesis-guide":`Synthesis Guide`};function i(e,t,n,i){let a=[`Analysis baselines for **${n}** have been generated.`];t===`generate`?a.push("Individual results are in the sibling `.md` and `.json` files in this directory.",``):a.push(`Results are stored in the AI Kit vector store.`,``);let o=i.get(`symbols`),s=i.get(`dependencies`),c=i.get(`patterns`),l=i.get(`entry-points`),u=o?.totalCount??0,d=o?.exportedCount??0,f=s?.totalImports??0,p=l?.total??0,m=(c?.patterns??[]).map(e=>e.pattern),h=m.some(e=>e.startsWith(`Spring`)),g=m.includes(`AWS CDK`)||m.includes(`CDK IaC`),_=m.includes(`Maven`),v=m.includes(`Serverless`)||p>3,y=s?.external?Object.keys(s.external):[],b=y.some(e=>[`express`,`fastify`,`next`,`react`,`vitest`,`jest`].includes(e))||f>0,x=y.some(e=>[`turbo`,`lerna`,`nx`].includes(e))||m.includes(`Monorepo`);if(a.push(`### Project Profile`,``),a.push(`- **${u} symbols** (${d} exported), **${f} imports**, **${p} entry ${p===1?`point`:`points`}**`),m.length>0&&a.push(`- **Detected**: ${m.slice(0,8).join(`, `)}`),a.push(``),u===0&&f===0&&p===0)return a.push(`> **Note:** This project appears to be empty or contains no analyzable source code.`,`> Run onboard again after adding source files.`),a.join(`
2
- `);let S=e.filter(e=>e.status===`success`),C=e.filter(e=>e.status===`failed`);a.push(`### Completed Analyses`,``);for(let e of S){let n=r[e.name]??e.name,i=e.output.length>1e3?`${Math.round(e.output.length/1024)}KB`:`${e.output.length}B`;t===`generate`?a.push(`- ✓ [${n}](./${e.name}.md) (${i})`):a.push(`- ✓ ${n} (${i})`)}if(C.length>0){a.push(``,`### Failed Analyses`,``);for(let e of C)a.push(`- ✗ ${e.name}: ${e.error}`)}a.push(``,`### Recommended Reading Order`,``,"1. **Start with** `synthesis-guide.md` (this file) → `entry-points.md` → `patterns.md`","2. **Module graph** via `code-map.md` — cross-package call edges with function names","3. **Architecture** via `diagram.md` (C4 Container) → `dependencies.md`","4. **Browse structure** via `structure.md` for file layout","5. **API surface** via `symbols.md` — file paths + exported symbols (capped at 80KB)","6. **Reference**: `config-values.md` (config reference)",``,`> **Size guidance:** Total output is ~`);let w=S.reduce((e,t)=>e+t.output.length,0)/1024;return a[a.length-1]+=`${Math.round(w)}KB. Focus on code-map.md + entry-points.md + diagram.md (~${Math.round((S.find(e=>e.name===`code-map`)?.output.length??0)/1024+(S.find(e=>e.name===`entry-points`)?.output.length??0)/1024+(S.find(e=>e.name===`diagram`)?.output.length??0)/1024)}KB) for maximum signal-to-token ratio.`,a.push(``,`### Synthesize Knowledge`,``,"Produce the following `aikit_remember` entries:",``),a.push("1. **Architecture Summary** (category: `architecture`)"),x?(a.push(` - Package boundaries, dependency graph between packages`),a.push(` - Shared vs service-specific code`)):v?(a.push(` - Lambda functions, triggers, event flow`),a.push(` - Infrastructure patterns (queues, tables, APIs)`)):h?(a.push(` - Controller → Service → Repository layers`),a.push(` - Spring configuration and profiles`)):(a.push(` - Layer structure, dependency flow`),a.push(` - Key design decisions`)),a.push(``),a.push("2. **Domain Model** (category: `architecture`)"),a.push(` - Key entities/types and their relationships`),a.push(` - Data flow from entry points through processing`),a.push(``),a.push("3. **Conventions** (category: `conventions`)"),a.push(` - Naming patterns, file organization, testing approach`),g&&a.push(` - CDK construct patterns and stack organization`),b&&a.push(` - Build tooling, package manager, module system`),_&&a.push(` - Maven module structure, dependency management`),a.push(``,`### Using AI Kit Tools`,``,`This project has an AI Kit MCP server with tools for search, analysis, memory, and more.`,"`aikit init` has already created `.github/copilot-instructions.md` and `AGENTS.md` with the complete tool reference.","If not, run `npx @vpxa/aikit init` to generate them.",``,`**Workflow pattern — use on every task:**`,``,"```",`aikit_search({ query: "your task keywords" }) # Recall prior decisions`,`aikit_scope_map({ task: "what you are doing" }) # Get a reading plan`,`# ... do the work ...`,`aikit_check({}) # Typecheck + lint`,`aikit_test_run({}) # Run tests`,`aikit_remember({ title: "What I learned", category: "decisions" }) # Persist`,"```"),a.join(`
3
- `)}function a(r,i,a){let o=r.get(`dependencies`),s=r.get(`symbols`),c=r.get(`entry-points`),l=[`## Code Map: ${i}\n`];if(!o&&!s)return l.push(`No dependency or symbol data available.`),l.join(`
4
- `);let u=o?.reverseGraph??{},d=s?.symbols??[],f=c?.entryPoints??[],p=new Map;for(let e of d){if(!e.exported)continue;let n=e.filePath.replace(/\\/g,`/`);if(t(n))continue;let r=p.get(n);r?r.push({name:e.name,kind:e.kind}):p.set(n,[{name:e.name,kind:e.kind}])}let m=new Map;for(let[e,r]of Object.entries(u)){let i=n(e.replace(/\\/g,`/`),p),a=r.map(e=>e.replace(/\\/g,`/`)).filter(e=>!t(e));if(a.length===0)continue;let o=m.get(i);if(o)for(let e of a)o.add(e);else m.set(i,new Set(a))}let h=new Map;for(let e of f)h.set(e.filePath.replace(/\\/g,`/`),{name:e.name,trigger:e.trigger});let g=new Map,_=new Map;if(a)for(let[n,r]of a){if(t(n))continue;let i=e(n);for(let[a,o]of r){if(t(a)||i===e(a))continue;let r=g.get(n);r||(r=new Map,g.set(n,r)),r.set(a,o);let s=_.get(a),c={file:n,symbols:o};s?s.push(c):_.set(a,[c])}}let v=new Set;for(let e of h.keys())v.add(e);for(let e of g.keys())v.add(e);for(let e of _.keys())v.add(e);if(!a)for(let e of p.keys()){let t=m.get(e);t&&t.size>=3&&v.add(e)}let y=new Map;for(let t of v){let n=e(t),r=y.get(n);r?r.push(t):y.set(n,[t])}let b=[...y.entries()].sort((e,t)=>e[0].localeCompare(t[0])),x=a?`AST call graph`:`import analysis`,S=a?`, ${g.size} cross-package callers`:``;l.push(`**${v.size} key modules** (${x}${S})\n`),l.push(`**Legend:** ⚡ Entry point | 📤 Exports | → Calls (outgoing) | ← Called by (incoming) | ➡ Used by (import)
5
- `);for(let[e,n]of b){n.sort(),l.push(`### ${e}/\n`);for(let r of n){let n=p.get(r),i=h.get(r),o=g.get(r),s=_.get(r),c=m.get(r),u=r.startsWith(`${e}/`)?r.slice(e.length+1):r;if(l.push(`**${u}**`),i&&l.push(` ⚡ Entry: \`${i.name}\`${i.trigger?` (${i.trigger})`:``}`),n&&n.length>0){let e=n.slice(0,8).map(e=>`${e.name}`).join(`, `),t=n.length>8?` (+${n.length-8})`:``;l.push(` 📤 ${e}${t}`)}if(o&&o.size>0){let t=[...o.entries()].sort((e,t)=>t[1].length-e[1].length);for(let[n,r]of t.slice(0,4)){let t=n.startsWith(`${e}/`)?n.slice(e.length+1):n;l.push(` → ${t}: ${r.slice(0,5).join(`, `)}${r.length>5?`…`:``}`)}t.length>4&&l.push(` → +${t.length-4} more targets`)}if(s&&s.length>0){for(let t of s.slice(0,4)){let n=t.file.startsWith(`${e}/`)?t.file.slice(e.length+1):t.file;l.push(` ← ${n}: ${t.symbols.slice(0,4).join(`, `)}${t.symbols.length>4?`…`:``}`)}s.length>4&&l.push(` ← +${s.length-4} more callers`)}else if(!a&&c&&c.size>0){let e=[...c].filter(e=>!t(e));e.length<=3?l.push(` ➡ Used by: ${e.join(`, `)}`):l.push(` ➡ Used by: ${e.slice(0,3).join(`, `)} (+${e.length-3} more)`)}l.push(``)}}return l.join(`
6
- `)}export{a as buildCodeMap,i as buildSynthesisGuide};
@@ -1,28 +0,0 @@
1
- import { ParsedTestSummary } from "./parse-output.js";
2
-
3
- //#region packages/tools/src/test-run.d.ts
4
- interface TestRunOptions {
5
- files?: string[];
6
- cwd?: string;
7
- timeout?: number;
8
- grep?: string;
9
- /** Include full raw output in result (default: false to save tokens) */
10
- includeRaw?: boolean;
11
- }
12
- interface TestRunResult {
13
- summary: ParsedTestSummary;
14
- passed: boolean;
15
- raw?: string;
16
- durationMs: number;
17
- }
18
- declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
19
- /**
20
- * Classify non-zero exit codes — some tools use exit code 1 for
21
- * non-error conditions (e.g., grep returns 1 for "no matches").
22
- */
23
- declare function classifyExitCode(exitCode: number, _stdout: string, command?: string): {
24
- isError: boolean;
25
- reason?: string;
26
- };
27
- //#endregion
28
- export { TestRunOptions, TestRunResult, classifyExitCode, testRun };
@@ -1,2 +0,0 @@
1
- import{parseVitest as e}from"./parse-output.js";import{exec as t}from"node:child_process";import{promisify as n}from"node:util";const r=n(t);let i=0;async function a(e={}){if(i>=2)throw Error(`Too many concurrent test runs (max 2). Try again later.`);i++;try{return await o(e)}finally{i--}}async function o(t){let n=t.cwd??process.cwd(),i=t.timeout??6e4,a=Date.now(),o=[`vitest`,`run`,`--reporter=verbose`,`--no-color`];t.files?.length&&o.push(...t.files),t.grep&&o.push(`--testNamePattern`,t.grep);try{let{stdout:s}=await r(`npx ${o.join(` `)}`,{cwd:n,timeout:i}),c=s.toString(),l=e(c);return{summary:l,passed:l.failed===0,...t.includeRaw&&{raw:c},durationMs:Date.now()-a}}catch(n){let r=s(n);return{summary:e(r),passed:!1,...t.includeRaw&&{raw:r},durationMs:Date.now()-a}}}function s(e){let t=e;return[t.stdout?.toString()??``,t.stderr?.toString()??``].filter(Boolean).join(`
2
- `).trim()||t.message||`Test run failed`}function c(e,t,n){if(e===0)return{isError:!1};if(e===1&&n){if(/\b(grep|rg|ripgrep|ag|ack|findstr)\b/i.test(n))return{isError:!1,reason:`grep: no matches (exit 1 is normal)`};if(/\bdiff\b/i.test(n))return{isError:!1,reason:`diff: files differ (exit 1 is normal)`}}return{isError:!0}}export{c as classifyExitCode,a as testRun};
@@ -1,24 +0,0 @@
1
- //#region packages/tools/src/text-utils.d.ts
2
- /**
3
- * Shared text utilities used by compact, digest, stratum-card, and other tools.
4
- */
5
- /**
6
- * Approximate token count from character count (~4 chars/token).
7
- */
8
- declare function estimateTokens(text: string): number;
9
- /**
10
- * Segment text into chunks for scoring.
11
- */
12
- declare function segment(text: string, strategy: 'paragraph' | 'sentence' | 'line'): string[];
13
- /**
14
- * Cosine similarity between two vectors.
15
- */
16
- declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
17
- /**
18
- * Reorder items using "bookend" strategy (Liu et al. 2023 "Lost in the Middle").
19
- * Highest-scoring items placed at start and end positions for better LLM attention.
20
- * Input must already be sorted by score descending.
21
- */
22
- declare function bookendReorder<T>(items: T[]): T[];
23
- //#endregion
24
- export { bookendReorder, cosineSimilarity, estimateTokens, segment };
@@ -1,2 +0,0 @@
1
- function e(e){return Math.ceil(e.length/4)}function t(e,t){switch(t){case`paragraph`:return e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);case`sentence`:return e.split(/(?<=[.!?])\s+/).map(e=>e.trim()).filter(e=>e.length>0);case`line`:return e.split(`
2
- `).map(e=>e.trim()).filter(e=>e.length>0)}}function n(e,t){let n=0,r=0,i=0;for(let a=0;a<e.length;a++)n+=e[a]*t[a],r+=e[a]*e[a],i+=t[a]*t[a];let a=Math.sqrt(r)*Math.sqrt(i);return a===0?0:n/a}function r(e){if(e.length<=2)return e;let t=Array(e.length),n=0,r=e.length-1;for(let i=0;i<e.length;i++)i%2==0?t[n++]=e[i]:t[r--]=e[i];return t}export{r as bookendReorder,n as cosineSimilarity,e as estimateTokens,t as segment};
@@ -1,20 +0,0 @@
1
- //#region packages/tools/src/time-utils.d.ts
2
- /**
3
- * aikit_time — Timezone conversion, date parsing, duration calculation.
4
- */
5
- type TimeOperation = 'now' | 'parse' | 'convert' | 'diff' | 'add';
6
- interface TimeOptions {
7
- operation: TimeOperation;
8
- input?: string;
9
- timezone?: string;
10
- duration?: string;
11
- }
12
- interface TimeResult {
13
- output: string;
14
- iso: string;
15
- unix: number;
16
- details?: Record<string, string | number>;
17
- }
18
- declare function timeUtils(options: TimeOptions): TimeResult;
19
- //#endregion
20
- export { TimeOperation, TimeOptions, TimeResult, timeUtils };
@@ -1 +0,0 @@
1
- function e(e){let{operation:a,input:o,timezone:s}=e;switch(a){case`now`:return n(new Date,s);case`parse`:if(!o)throw Error(`input required for parse`);return n(t(o),s);case`convert`:if(!o)throw Error(`input required for convert`);if(!s)throw Error(`timezone required for convert`);return n(t(o),s);case`diff`:{if(!o)throw Error(`input required for diff (two comma-separated dates)`);let e=o.split(`,`).map(e=>e.trim());if(e.length<2)throw Error(`diff requires two comma-separated dates`);let n=t(e[0]),i=t(e[1]),a=Math.abs(i.getTime()-n.getTime());return{output:r(a),iso:`PT${Math.floor(a/1e3)}S`,unix:a,details:{milliseconds:a,seconds:Math.floor(a/1e3),minutes:Math.floor(a/6e4),hours:Math.floor(a/36e5),days:Math.floor(a/864e5)}}}case`add`:{if(!o)throw Error(`input required for add`);let{duration:r}=e;if(!r)throw Error(`duration required for add (e.g., "2h30m")`);let a=t(o),c=i(r);return n(new Date(a.getTime()+c),s)}default:throw Error(`Unknown operation: ${a}`)}}function t(e){let t=Number(e);if(!Number.isNaN(t))return new Date(t>0xe8d4a51000?t:t*1e3);let n=new Date(e);if(Number.isNaN(n.getTime()))throw Error(`Cannot parse date: ${e}`);return n}function n(e,t){let n=t??`UTC`,r=e.toLocaleString(`en-US`,{timeZone:n,dateStyle:`full`,timeStyle:`long`}),i=new Intl.DateTimeFormat(`en-US`,{timeZone:n,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}).formatToParts(e).reduce((e,t)=>(t.type!==`literal`&&(e[t.type]=Number.parseInt(t.value,10)),e),{});return{output:r,iso:e.toISOString(),unix:Math.floor(e.getTime()/1e3),details:{timezone:n,year:i.year,month:i.month,day:i.day,hour:i.hour===24?0:i.hour,minute:i.minute,second:i.second}}}function r(e){let t=[],n=Math.floor(e/864e5);n&&t.push(`${n}d`);let r=Math.floor(e%864e5/36e5);r&&t.push(`${r}h`);let i=Math.floor(e%36e5/6e4);i&&t.push(`${i}m`);let a=Math.floor(e%6e4/1e3);return(a||t.length===0)&&t.push(`${a}s`),t.join(` `)}function i(e){let t=0,n=e.matchAll(/(\d+)\s*(d|h|m|s|ms)/gi);for(let e of n){let n=Number(e[1]);switch(e[2].toLowerCase()){case`d`:t+=n*864e5;break;case`h`:t+=n*36e5;break;case`m`:t+=n*6e4;break;case`s`:t+=n*1e3;break;case`ms`:t+=n;break}}if(t===0)throw Error(`Cannot parse duration: ${e}`);return t}export{e as timeUtils};
@@ -1,43 +0,0 @@
1
- import { IEmbedder } from "../../embeddings/dist/index.js";
2
- import { IGraphStore, IKnowledgeStore } from "../../store/dist/index.js";
3
-
4
- //#region packages/tools/src/trace.d.ts
5
- interface TraceOptions {
6
- /** Starting point — a symbol or file:line reference */
7
- start: string;
8
- /** Direction */
9
- direction: 'forward' | 'backward' | 'both';
10
- /** Max depth (default: 3) */
11
- maxDepth?: number;
12
- /** Optional graph store for enriching results */
13
- graphStore?: IGraphStore;
14
- }
15
- interface TraceGraphContext {
16
- /** Module that defines the traced symbol */
17
- definingModule?: string;
18
- /** Community/cluster of the traced symbol */
19
- community?: string;
20
- /** Modules that import the file containing this symbol */
21
- importedByModules: string[];
22
- /** Symbols defined in the same module */
23
- siblingSymbols: string[];
24
- }
25
- interface TraceNode {
26
- path: string;
27
- symbol: string;
28
- line: number;
29
- relationship: 'calls' | 'called-by' | 'imports' | 'imported-by' | 'references';
30
- /** The enclosing function/scope where the relationship occurs (AST-powered) */
31
- scope?: string;
32
- }
33
- interface TraceResult {
34
- start: string;
35
- direction: string;
36
- nodes: TraceNode[];
37
- depth: number;
38
- /** Graph-derived context (when graph store available) */
39
- graphContext?: TraceGraphContext;
40
- }
41
- declare function trace(embedder: IEmbedder, store: IKnowledgeStore, options: TraceOptions): Promise<TraceResult>;
42
- //#endregion
43
- export { TraceGraphContext, TraceNode, TraceOptions, TraceResult, trace };
@@ -1,2 +0,0 @@
1
- import{escapeRegExp as e}from"./regex-utils.js";import{readFile as t}from"node:fs/promises";import{extname as n}from"node:path";import{SUPPORTED_EXTENSIONS as r,WasmRuntime as i,extractCalls as a}from"../../chunker/dist/index.js";async function o(t,n,r){let{start:a,direction:o,maxDepth:f=3,graphStore:p}=r,m=[],h=new Set,g=new Set,_=!!i.get(),v=new Map,y=await t.embed(a);if((await n.search(y,{limit:10})).length===0)return{start:a,direction:o,nodes:m,depth:0};let b=[{target:a,depth:0}],x=0;for(;b.length>0;){let r=b.shift();if(!r)break;if(r.depth>=f||h.has(r.target))continue;h.add(r.target);let i=await t.embed(r.target),a=await n.search(i,{limit:20}),s=e(r.target),d=u(r.target);for(let e of a){let t=e.record.sourcePath,n=e.record.content.split(`
2
- `);if(_&&!d){let e=await c(v,t);for(let n of e)o!==`backward`&&n.callerName===r.target&&(l(g,m,{path:t,symbol:n.calleeName,line:n.line,relationship:`calls`,scope:n.callerName}),x=Math.max(x,r.depth+1),b.push({target:n.calleeName,depth:r.depth+1})),o!==`forward`&&n.calleeName===r.target&&(l(g,m,{path:t,symbol:n.callerName,line:n.line,relationship:`called-by`,scope:n.callerName}),x=Math.max(x,r.depth+1),b.push({target:n.callerName,depth:r.depth+1}))}for(let i=0;i<n.length;i+=1){let a=n[i],c=e.record.startLine+i;if(o!==`forward`&&RegExp(d?`from\\s+['"]${s}['"]`:`import\\s+.*\\b${s}\\b.*from\\s+`).test(a)){l(g,m,{path:t,symbol:r.target,line:c,relationship:`imported-by`}),x=Math.max(x,r.depth+1);let e=a.match(/from\s+['"]([^'"]+)['"]/);!d&&e&&b.push({target:e[1],depth:r.depth+1})}o!==`backward`&&(d?RegExp(`from\\s+['"]${s}['"]`).test(a)&&(l(g,m,{path:t,symbol:r.target,line:c,relationship:`imports`}),x=Math.max(x,r.depth+1)):_||RegExp(`\\b${s}\\s*\\(`).test(a)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(a)&&(l(g,m,{path:t,symbol:r.target,line:c,relationship:`calls`}),x=Math.max(x,r.depth+1))),RegExp(d?`['"]${s}['"]`:`\\b${s}\\b`).test(a)&&!/^\s*import\s/.test(a)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(a)&&(l(g,m,{path:t,symbol:r.target,line:c,relationship:`references`}),x=Math.max(x,r.depth+1))}}}let S=p?await s(a,p):void 0;return{start:a,direction:o,nodes:d(m),depth:x,graphContext:S}}async function s(e,t){try{let n=await t.findNodes({namePattern:e,limit:10}),r=n.find(t=>t.name===e&&t.type!==`module`)??n.find(t=>t.name===e)??n[0];if(!r)return;let i={definingModule:r.sourcePath,community:r.community,importedByModules:[],siblingSymbols:[]};try{let e=await t.getSymbol360(r.id);i.community=e.community??i.community,i.definingModule=e.node.sourcePath??i.definingModule}catch{}if(r.sourcePath){let[e]=await t.findNodes({sourcePath:r.sourcePath,type:`module`});e&&(i.importedByModules=f((await t.getNeighbors(e.id,{direction:`incoming`,edgeType:`imports`})).nodes.map(e=>e.sourcePath??e.name)))}return i.definingModule&&(i.siblingSymbols=f((await t.findNodes({sourcePath:i.definingModule,limit:50})).filter(e=>e.name!==r.name&&e.type!==`module`).map(e=>`${e.type}:${e.name}`)).slice(0,15)),i.definingModule||i.community||i.importedByModules.length>0||i.siblingSymbols.length>0?i:void 0}catch{return}}async function c(e,i){let o=e.get(i);if(o)return o;let s=n(i);if(!r.has(s))return e.set(i,[]),[];try{let n=await a(await t(i,`utf-8`),s,i);return e.set(i,n),n}catch{return e.set(i,[]),[]}}function l(e,t,n){let r=`${n.path}:${n.line}:${n.relationship}`;e.has(r)||(e.add(r),t.push(n))}function u(e){return/[./\\]/.test(e)}function d(e){let t=new Set;return e.filter(e=>{let n=`${e.path}:${e.line}:${e.relationship}`;return t.has(n)?!1:(t.add(n),!0)})}function f(e){return[...new Set(e.filter(e=>e.length>0))]}export{o as trace};
@@ -1,66 +0,0 @@
1
- //#region packages/tools/src/truncation.d.ts
2
- /**
3
- * Smart truncation utilities.
4
- *
5
- * Head/tail split: preserves both the beginning (context/setup) and
6
- * end (errors/results/stack traces) of content. Snaps to line boundaries.
7
- */
8
- /** Metadata about truncation for transparency */
9
- interface TruncationMeta {
10
- /** Whether the text was actually truncated */
11
- truncated: boolean;
12
- /** Original character count before truncation */
13
- originalChars: number;
14
- /** Character count after truncation */
15
- truncatedChars: number;
16
- /** Number of lines/paragraphs omitted */
17
- omittedCount: number;
18
- /** Type of truncation applied */
19
- strategy: 'head-tail' | 'paragraph' | 'token-budget' | 'none';
20
- }
21
- /** Result of a truncation operation with metadata */
22
- interface TruncationResult {
23
- /** The truncated text */
24
- text: string;
25
- /** Truncation metadata for transparency */
26
- _meta: TruncationMeta;
27
- }
28
- /**
29
- * Truncate text keeping both head and tail portions.
30
- * Critical for process output where errors appear at the end.
31
- *
32
- * @param text - Full text to truncate
33
- * @param maxLen - Maximum character length
34
- * @param headRatio - Fraction for head portion (default 0.6)
35
- * @returns Truncated text with separator showing omitted line/char count
36
- */
37
- declare function headTailTruncate(text: string, maxLen: number, headRatio?: number): string;
38
- /**
39
- * Truncate at a paragraph boundary near maxLength (head-only).
40
- * Best for web content and markdown where structure is at the top.
41
- */
42
- declare function paragraphTruncate(text: string, maxLen: number): string;
43
- /**
44
- * Truncate text to fit within a token budget.
45
- * Uses ~4 chars/token approximation. Snaps to line boundaries.
46
- *
47
- * @param text - Full text to truncate
48
- * @param maxTokens - Maximum token count
49
- * @returns Original text if within budget, or truncated with notice
50
- */
51
- declare function truncateToTokenBudget(text: string, maxTokens: number): string;
52
- /**
53
- * Head-tail truncation with metadata.
54
- * Same as headTailTruncate but returns a TruncationResult with _meta.
55
- */
56
- declare function headTailTruncateWithMeta(text: string, maxLen: number, headRatio?: number): TruncationResult;
57
- /**
58
- * Paragraph truncation with metadata.
59
- */
60
- declare function paragraphTruncateWithMeta(text: string, maxLen: number): TruncationResult;
61
- /**
62
- * Token-budget truncation with metadata.
63
- */
64
- declare function truncateToTokenBudgetWithMeta(text: string, maxTokens: number): TruncationResult;
65
- //#endregion
66
- export { TruncationMeta, TruncationResult, headTailTruncate, headTailTruncateWithMeta, paragraphTruncate, paragraphTruncateWithMeta, truncateToTokenBudget, truncateToTokenBudgetWithMeta };
@@ -1,11 +0,0 @@
1
- import{estimateTokens as e}from"./text-utils.js";const t=.6;function n(e,n,r=t){if(e.length<=n)return e;let i=Math.max(0,n-120),a=Math.floor(i*r),o=i-a,s=e.slice(0,a),c=s.lastIndexOf(`
2
- `),l=c>0?s.slice(0,c):s,u=e.length-o,d=e.slice(u),f=d.indexOf(`
3
- `),p=f>=0?d.slice(f+1):d,m=e.length-l.length-p.length,h=1,g=l.length,_=e.length-p.length;for(let t=g;t<_;t++)e.charCodeAt(t)===10&&h++;return`${l}\n\n[… ${h} lines / ${(m/1024).toFixed(1)}KB truncated — showing first ${l.split(`
4
- `).length} + last ${p.split(`
5
- `).length} lines]\n\n${p}`}function r(e,t){if(e.length<=t)return e;let n=Math.max(0,t-200),r=e.slice(n,t).lastIndexOf(`
6
-
7
- `),i=r>=0?n+r:t,a=e.slice(0,i).trimEnd(),o=Math.round(i/e.length*100);return`${a}\n\n---\n*[Truncated at ${i.toLocaleString()} chars — ${o}% of original content]*`}function i(e,t){let r=t*4;return e.length<=r?e:n(e,r)}function a(e,r,i=t){if(e.length<=r)return{text:e,_meta:{truncated:!1,originalChars:e.length,truncatedChars:e.length,omittedCount:0,strategy:`none`}};let a=Math.max(0,r-120),o=Math.floor(a*i),s=a-o,c=e.slice(0,o),l=c.lastIndexOf(`
8
- `),u=l>0?c.slice(0,l):c,d=e.length-s,f=e.slice(d),p=f.indexOf(`
9
- `),m=p>=0?f.slice(p+1):f,h=1,g=u.length,_=e.length-m.length;for(let t=g;t<_;t++)e.charCodeAt(t)===10&&h++;let v=n(e,r,i);return{text:v,_meta:{truncated:!0,originalChars:e.length,truncatedChars:v.length,omittedCount:h,strategy:`head-tail`}}}function o(e,t){if(e.length<=t)return{text:e,_meta:{truncated:!1,originalChars:e.length,truncatedChars:e.length,omittedCount:0,strategy:`none`}};let n=Math.max(0,t-200),i=e.slice(n,t).lastIndexOf(`
10
-
11
- `),a=i>=0?n+i:t,o=e.split(/\n\s*\n/),s=e.slice(0,a).trimEnd(),c=s.length===0?0:s.split(/\n\s*\n/).length,l=r(e,t);return{text:l,_meta:{truncated:!0,originalChars:e.length,truncatedChars:l.length,omittedCount:Math.max(0,o.length-c),strategy:`paragraph`}}}function s(t,n){if(e(t)<=n)return{text:t,_meta:{truncated:!1,originalChars:t.length,truncatedChars:t.length,omittedCount:0,strategy:`none`}};let r=a(t,n*4);return{text:r.text,_meta:{...r._meta,strategy:`token-budget`}}}export{n as headTailTruncate,a as headTailTruncateWithMeta,r as paragraphTruncate,o as paragraphTruncateWithMeta,i as truncateToTokenBudget,s as truncateToTokenBudgetWithMeta};