@vpxa/kb 0.1.13 → 0.1.16

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 (490) hide show
  1. package/README.md +65 -12
  2. package/package.json +14 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -21
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +5 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -28
  6. package/packages/analyzers/dist/dependency-analyzer.js +6 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -9
  8. package/packages/analyzers/dist/diagram-generator.js +2 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -36
  10. package/packages/analyzers/dist/entry-point-analyzer.js +4 -6
  11. package/packages/analyzers/dist/index.d.ts +12 -14
  12. package/packages/analyzers/dist/index.js +1 -1
  13. package/packages/analyzers/dist/knowledge-producer.d.ts +34 -26
  14. package/packages/analyzers/dist/knowledge-producer.js +17 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -11
  16. package/packages/analyzers/dist/pattern-analyzer.js +2 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -13
  18. package/packages/analyzers/dist/regex-call-graph.js +1 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -10
  20. package/packages/analyzers/dist/structure-analyzer.js +2 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +13 -9
  22. package/packages/analyzers/dist/symbol-analyzer.js +9 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -14
  24. package/packages/analyzers/dist/ts-call-graph.js +1 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -80
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +15 -12
  28. package/packages/chunker/dist/call-graph-extractor.js +1 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +16 -4
  30. package/packages/chunker/dist/chunker-factory.js +1 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -5
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -13
  34. package/packages/chunker/dist/code-chunker.js +11 -14
  35. package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
  36. package/packages/chunker/dist/extractors/call-extractor.js +1 -0
  37. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
  38. package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
  39. package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
  40. package/packages/chunker/dist/extractors/import-extractor.js +1 -0
  41. package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
  42. package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
  43. package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
  44. package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
  45. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
  46. package/packages/chunker/dist/extractors/symbol-extractor.js +1 -0
  47. package/packages/chunker/dist/extractors/types.d.ts +36 -0
  48. package/packages/chunker/dist/extractors/types.js +1 -0
  49. package/packages/chunker/dist/generic-chunker.d.ts +14 -11
  50. package/packages/chunker/dist/generic-chunker.js +5 -5
  51. package/packages/chunker/dist/index.d.ts +19 -8
  52. package/packages/chunker/dist/index.js +1 -1
  53. package/packages/chunker/dist/markdown-chunker.d.ts +16 -13
  54. package/packages/chunker/dist/markdown-chunker.js +3 -10
  55. package/packages/chunker/dist/wasm/languages.d.ts +18 -0
  56. package/packages/chunker/dist/wasm/languages.js +1 -0
  57. package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
  58. package/packages/chunker/dist/wasm/query-executor.js +1 -0
  59. package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
  60. package/packages/chunker/dist/wasm/runtime.js +1 -0
  61. package/packages/chunker/dist/wasm/types.d.ts +84 -0
  62. package/packages/chunker/dist/wasm/types.js +1 -0
  63. package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
  64. package/packages/chunker/dist/wasm-chunker.js +6 -0
  65. package/packages/chunker/src/queries/go/calls.scm +11 -0
  66. package/packages/chunker/src/queries/go/entry-points.scm +20 -0
  67. package/packages/chunker/src/queries/go/imports.scm +6 -0
  68. package/packages/chunker/src/queries/go/patterns.scm +25 -0
  69. package/packages/chunker/src/queries/go/symbols.scm +26 -0
  70. package/packages/chunker/src/queries/java/calls.scm +10 -0
  71. package/packages/chunker/src/queries/java/entry-points.scm +27 -0
  72. package/packages/chunker/src/queries/java/imports.scm +11 -0
  73. package/packages/chunker/src/queries/java/patterns.scm +27 -0
  74. package/packages/chunker/src/queries/java/symbols.scm +28 -0
  75. package/packages/chunker/src/queries/javascript/calls.scm +21 -0
  76. package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
  77. package/packages/chunker/src/queries/javascript/imports.scm +32 -0
  78. package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
  79. package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
  80. package/packages/chunker/src/queries/python/calls.scm +11 -0
  81. package/packages/chunker/src/queries/python/entry-points.scm +21 -0
  82. package/packages/chunker/src/queries/python/imports.scm +14 -0
  83. package/packages/chunker/src/queries/python/patterns.scm +25 -0
  84. package/packages/chunker/src/queries/python/symbols.scm +17 -0
  85. package/packages/chunker/src/queries/rust/calls.scm +20 -0
  86. package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
  87. package/packages/chunker/src/queries/rust/imports.scm +26 -0
  88. package/packages/chunker/src/queries/rust/patterns.scm +18 -0
  89. package/packages/chunker/src/queries/rust/symbols.scm +73 -0
  90. package/packages/chunker/src/queries/typescript/calls.scm +21 -0
  91. package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
  92. package/packages/chunker/src/queries/typescript/imports.scm +35 -0
  93. package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
  94. package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
  95. package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
  96. package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
  97. package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
  98. package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
  99. package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
  100. package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
  101. package/packages/chunker/wasm/tree-sitter.wasm +0 -0
  102. package/packages/cli/dist/commands/analyze.d.ts +6 -3
  103. package/packages/cli/dist/commands/analyze.js +2 -3
  104. package/packages/cli/dist/commands/context-cmds.d.ts +6 -3
  105. package/packages/cli/dist/commands/context-cmds.js +1 -1
  106. package/packages/cli/dist/commands/environment.d.ts +6 -3
  107. package/packages/cli/dist/commands/environment.js +1 -2
  108. package/packages/cli/dist/commands/execution.d.ts +6 -3
  109. package/packages/cli/dist/commands/execution.js +1 -1
  110. package/packages/cli/dist/commands/graph.d.ts +6 -3
  111. package/packages/cli/dist/commands/graph.js +5 -6
  112. package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
  113. package/packages/cli/dist/commands/init/adapters.js +1 -0
  114. package/packages/cli/dist/commands/init/config.d.ts +10 -0
  115. package/packages/cli/dist/commands/init/config.js +3 -0
  116. package/packages/cli/dist/commands/init/constants.d.ts +18 -0
  117. package/packages/cli/dist/commands/init/constants.js +1 -0
  118. package/packages/cli/dist/commands/init/curated.d.ts +7 -0
  119. package/packages/cli/dist/commands/init/curated.js +1 -0
  120. package/packages/cli/dist/commands/init/global.d.ts +34 -0
  121. package/packages/cli/dist/commands/init/global.js +5 -0
  122. package/packages/cli/dist/commands/init/index.d.ts +28 -0
  123. package/packages/cli/dist/commands/init/index.js +5 -0
  124. package/packages/cli/dist/commands/init/scaffold.d.ts +23 -0
  125. package/packages/cli/dist/commands/init/scaffold.js +1 -0
  126. package/packages/cli/dist/commands/init/templates.d.ts +9 -0
  127. package/packages/cli/dist/commands/init/templates.js +165 -0
  128. package/packages/cli/dist/commands/knowledge.d.ts +6 -3
  129. package/packages/cli/dist/commands/knowledge.js +1 -1
  130. package/packages/cli/dist/commands/search.d.ts +6 -3
  131. package/packages/cli/dist/commands/search.js +1 -8
  132. package/packages/cli/dist/commands/system.d.ts +6 -3
  133. package/packages/cli/dist/commands/system.js +4 -7
  134. package/packages/cli/dist/commands/workspace.d.ts +6 -3
  135. package/packages/cli/dist/commands/workspace.js +1 -2
  136. package/packages/cli/dist/context.d.ts +7 -5
  137. package/packages/cli/dist/context.js +1 -1
  138. package/packages/cli/dist/helpers.d.ts +51 -48
  139. package/packages/cli/dist/helpers.js +5 -5
  140. package/packages/cli/dist/index.d.ts +4 -2
  141. package/packages/cli/dist/index.js +2 -2
  142. package/packages/cli/dist/kb-init.d.ts +48 -51
  143. package/packages/cli/dist/kb-init.js +1 -1
  144. package/packages/cli/dist/types.d.ts +8 -6
  145. package/packages/cli/dist/types.js +1 -0
  146. package/packages/core/dist/constants.d.ts +58 -34
  147. package/packages/core/dist/constants.js +1 -1
  148. package/packages/core/dist/content-detector.d.ts +8 -8
  149. package/packages/core/dist/content-detector.js +1 -1
  150. package/packages/core/dist/errors.d.ts +15 -13
  151. package/packages/core/dist/errors.js +1 -1
  152. package/packages/core/dist/global-registry.d.ts +62 -0
  153. package/packages/core/dist/global-registry.js +1 -0
  154. package/packages/core/dist/index.d.ts +7 -6
  155. package/packages/core/dist/index.js +1 -1
  156. package/packages/core/dist/logger.d.ts +19 -8
  157. package/packages/core/dist/logger.js +1 -1
  158. package/packages/core/dist/types.d.ts +107 -92
  159. package/packages/core/dist/types.js +1 -0
  160. package/packages/embeddings/dist/embedder.interface.d.ts +22 -20
  161. package/packages/embeddings/dist/embedder.interface.js +1 -0
  162. package/packages/embeddings/dist/index.d.ts +3 -3
  163. package/packages/embeddings/dist/index.js +1 -1
  164. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -23
  165. package/packages/embeddings/dist/onnx-embedder.js +1 -1
  166. package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
  167. package/packages/enterprise-bridge/dist/cache.js +1 -0
  168. package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
  169. package/packages/enterprise-bridge/dist/er-client.js +1 -0
  170. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
  171. package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
  172. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  173. package/packages/enterprise-bridge/dist/index.js +1 -0
  174. package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
  175. package/packages/enterprise-bridge/dist/policy-store.js +1 -0
  176. package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
  177. package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
  178. package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
  179. package/packages/enterprise-bridge/dist/result-merger.js +1 -0
  180. package/packages/enterprise-bridge/dist/types.d.ts +81 -0
  181. package/packages/enterprise-bridge/dist/types.js +1 -0
  182. package/packages/indexer/dist/file-hasher.d.ts +5 -3
  183. package/packages/indexer/dist/file-hasher.js +1 -1
  184. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -21
  185. package/packages/indexer/dist/filesystem-crawler.js +1 -1
  186. package/packages/indexer/dist/graph-extractor.d.ts +9 -13
  187. package/packages/indexer/dist/graph-extractor.js +1 -1
  188. package/packages/indexer/dist/incremental-indexer.d.ts +49 -44
  189. package/packages/indexer/dist/incremental-indexer.js +1 -1
  190. package/packages/indexer/dist/index.d.ts +5 -5
  191. package/packages/indexer/dist/index.js +1 -1
  192. package/packages/server/dist/api.d.ts +3 -8
  193. package/packages/server/dist/api.js +1 -1
  194. package/packages/server/dist/config.d.ts +6 -3
  195. package/packages/server/dist/config.js +1 -1
  196. package/packages/server/dist/cross-workspace.d.ts +43 -0
  197. package/packages/server/dist/cross-workspace.js +1 -0
  198. package/packages/server/dist/curated-manager.d.ts +80 -78
  199. package/packages/server/dist/curated-manager.js +5 -10
  200. package/packages/server/dist/index.d.ts +1 -2
  201. package/packages/server/dist/index.js +1 -1
  202. package/packages/server/dist/replay-interceptor.d.ts +6 -7
  203. package/packages/server/dist/replay-interceptor.js +1 -1
  204. package/packages/server/dist/resources/resources.d.ts +7 -4
  205. package/packages/server/dist/resources/resources.js +2 -2
  206. package/packages/server/dist/server.d.ts +37 -25
  207. package/packages/server/dist/server.js +1 -1
  208. package/packages/server/dist/tools/analyze.tools.d.ts +14 -11
  209. package/packages/server/dist/tools/analyze.tools.js +1 -3
  210. package/packages/server/dist/tools/audit.tool.d.ts +8 -5
  211. package/packages/server/dist/tools/audit.tool.js +1 -4
  212. package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
  213. package/packages/server/dist/tools/bridge.tools.js +15 -0
  214. package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
  215. package/packages/server/dist/tools/evolution.tools.js +5 -0
  216. package/packages/server/dist/tools/forge.tools.d.ts +13 -12
  217. package/packages/server/dist/tools/forge.tools.js +10 -13
  218. package/packages/server/dist/tools/forget.tool.d.ts +7 -4
  219. package/packages/server/dist/tools/forget.tool.js +1 -7
  220. package/packages/server/dist/tools/graph.tool.d.ts +7 -4
  221. package/packages/server/dist/tools/graph.tool.js +4 -5
  222. package/packages/server/dist/tools/list.tool.d.ts +7 -4
  223. package/packages/server/dist/tools/list.tool.js +2 -8
  224. package/packages/server/dist/tools/lookup.tool.d.ts +7 -4
  225. package/packages/server/dist/tools/lookup.tool.js +2 -9
  226. package/packages/server/dist/tools/onboard.tool.d.ts +8 -5
  227. package/packages/server/dist/tools/onboard.tool.js +2 -2
  228. package/packages/server/dist/tools/policy.tools.d.ts +7 -0
  229. package/packages/server/dist/tools/policy.tools.js +2 -0
  230. package/packages/server/dist/tools/produce.tool.d.ts +6 -3
  231. package/packages/server/dist/tools/produce.tool.js +2 -2
  232. package/packages/server/dist/tools/read.tool.d.ts +7 -4
  233. package/packages/server/dist/tools/read.tool.js +2 -6
  234. package/packages/server/dist/tools/reindex.tool.d.ts +10 -7
  235. package/packages/server/dist/tools/reindex.tool.js +3 -2
  236. package/packages/server/dist/tools/remember.tool.d.ts +8 -4
  237. package/packages/server/dist/tools/remember.tool.js +3 -5
  238. package/packages/server/dist/tools/replay.tool.d.ts +6 -3
  239. package/packages/server/dist/tools/replay.tool.js +2 -6
  240. package/packages/server/dist/tools/search.tool.d.ts +10 -5
  241. package/packages/server/dist/tools/search.tool.js +6 -22
  242. package/packages/server/dist/tools/status.tool.d.ts +12 -4
  243. package/packages/server/dist/tools/status.tool.js +2 -3
  244. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -35
  245. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  246. package/packages/server/dist/tools/update.tool.d.ts +7 -4
  247. package/packages/server/dist/tools/update.tool.js +1 -6
  248. package/packages/server/dist/tools/utility.tools.d.ts +15 -15
  249. package/packages/server/dist/tools/utility.tools.js +10 -23
  250. package/packages/server/dist/version-check.d.ts +5 -2
  251. package/packages/server/dist/version-check.js +1 -1
  252. package/packages/store/dist/graph-store.interface.d.ts +89 -87
  253. package/packages/store/dist/graph-store.interface.js +1 -0
  254. package/packages/store/dist/index.d.ts +6 -6
  255. package/packages/store/dist/index.js +1 -1
  256. package/packages/store/dist/lance-store.d.ts +37 -31
  257. package/packages/store/dist/lance-store.js +1 -1
  258. package/packages/store/dist/sqlite-graph-store.d.ts +43 -47
  259. package/packages/store/dist/sqlite-graph-store.js +13 -13
  260. package/packages/store/dist/store-factory.d.ts +11 -8
  261. package/packages/store/dist/store-factory.js +1 -1
  262. package/packages/store/dist/store.interface.d.ts +47 -47
  263. package/packages/store/dist/store.interface.js +1 -0
  264. package/packages/tools/dist/audit.d.ts +61 -62
  265. package/packages/tools/dist/audit.js +4 -5
  266. package/packages/tools/dist/batch.d.ts +20 -18
  267. package/packages/tools/dist/batch.js +1 -1
  268. package/packages/tools/dist/changelog.d.ts +29 -27
  269. package/packages/tools/dist/changelog.js +2 -2
  270. package/packages/tools/dist/check.d.ts +42 -39
  271. package/packages/tools/dist/check.js +2 -2
  272. package/packages/tools/dist/checkpoint.d.ts +17 -15
  273. package/packages/tools/dist/checkpoint.js +1 -2
  274. package/packages/tools/dist/codemod.d.ts +35 -33
  275. package/packages/tools/dist/codemod.js +2 -2
  276. package/packages/tools/dist/compact.d.ts +34 -38
  277. package/packages/tools/dist/compact.js +2 -2
  278. package/packages/tools/dist/data-transform.d.ts +10 -8
  279. package/packages/tools/dist/data-transform.js +1 -1
  280. package/packages/tools/dist/dead-symbols.d.ts +29 -26
  281. package/packages/tools/dist/dead-symbols.js +2 -2
  282. package/packages/tools/dist/delegate.d.ts +26 -24
  283. package/packages/tools/dist/delegate.js +1 -5
  284. package/packages/tools/dist/diff-parse.d.ts +24 -22
  285. package/packages/tools/dist/diff-parse.js +3 -3
  286. package/packages/tools/dist/digest.d.ts +43 -46
  287. package/packages/tools/dist/digest.js +4 -5
  288. package/packages/tools/dist/dogfood-log.d.ts +49 -0
  289. package/packages/tools/dist/dogfood-log.js +2 -0
  290. package/packages/tools/dist/encode.d.ts +11 -9
  291. package/packages/tools/dist/encode.js +1 -1
  292. package/packages/tools/dist/env-info.d.ts +25 -23
  293. package/packages/tools/dist/env-info.js +1 -1
  294. package/packages/tools/dist/eval.d.ts +13 -11
  295. package/packages/tools/dist/eval.js +2 -3
  296. package/packages/tools/dist/evidence-map.d.ts +64 -62
  297. package/packages/tools/dist/evidence-map.js +2 -3
  298. package/packages/tools/dist/file-cache.d.ts +41 -0
  299. package/packages/tools/dist/file-cache.js +3 -0
  300. package/packages/tools/dist/file-summary.d.ts +50 -30
  301. package/packages/tools/dist/file-summary.js +2 -2
  302. package/packages/tools/dist/file-walk.d.ts +6 -4
  303. package/packages/tools/dist/file-walk.js +1 -1
  304. package/packages/tools/dist/find-examples.d.ts +26 -22
  305. package/packages/tools/dist/find-examples.js +3 -3
  306. package/packages/tools/dist/find.d.ts +39 -41
  307. package/packages/tools/dist/find.js +1 -1
  308. package/packages/tools/dist/forge-classify.d.ts +35 -39
  309. package/packages/tools/dist/forge-classify.js +2 -2
  310. package/packages/tools/dist/forge-ground.d.ts +58 -61
  311. package/packages/tools/dist/forge-ground.js +1 -1
  312. package/packages/tools/dist/git-context.d.ts +22 -20
  313. package/packages/tools/dist/git-context.js +3 -3
  314. package/packages/tools/dist/graph-query.d.ts +75 -79
  315. package/packages/tools/dist/graph-query.js +1 -1
  316. package/packages/tools/dist/guide.d.ts +14 -12
  317. package/packages/tools/dist/guide.js +1 -1
  318. package/packages/tools/dist/health.d.ts +13 -11
  319. package/packages/tools/dist/health.js +2 -2
  320. package/packages/tools/dist/http-request.d.ts +20 -18
  321. package/packages/tools/dist/http-request.js +1 -1
  322. package/packages/tools/dist/index.d.ts +55 -53
  323. package/packages/tools/dist/index.js +1 -1
  324. package/packages/tools/dist/lane.d.ts +28 -26
  325. package/packages/tools/dist/lane.js +6 -7
  326. package/packages/tools/dist/measure.d.ts +34 -30
  327. package/packages/tools/dist/measure.js +2 -2
  328. package/packages/tools/dist/onboard.d.ts +29 -27
  329. package/packages/tools/dist/onboard.js +17 -41
  330. package/packages/tools/dist/parse-output.d.ts +48 -46
  331. package/packages/tools/dist/parse-output.js +2 -2
  332. package/packages/tools/dist/path-resolver.d.ts +4 -2
  333. package/packages/tools/dist/path-resolver.js +1 -1
  334. package/packages/tools/dist/process-manager.d.ts +18 -16
  335. package/packages/tools/dist/process-manager.js +1 -1
  336. package/packages/tools/dist/queue.d.ts +28 -26
  337. package/packages/tools/dist/queue.js +1 -2
  338. package/packages/tools/dist/regex-test.d.ts +26 -24
  339. package/packages/tools/dist/regex-test.js +1 -1
  340. package/packages/tools/dist/rename.d.ts +28 -26
  341. package/packages/tools/dist/rename.js +2 -2
  342. package/packages/tools/dist/replay.d.ts +33 -31
  343. package/packages/tools/dist/replay.js +4 -6
  344. package/packages/tools/dist/response-envelope.d.ts +32 -30
  345. package/packages/tools/dist/response-envelope.js +1 -1
  346. package/packages/tools/dist/schema-validate.d.ts +15 -13
  347. package/packages/tools/dist/schema-validate.js +1 -1
  348. package/packages/tools/dist/scope-map.d.ts +45 -48
  349. package/packages/tools/dist/scope-map.js +1 -1
  350. package/packages/tools/dist/snippet.d.ts +26 -25
  351. package/packages/tools/dist/snippet.js +1 -1
  352. package/packages/tools/dist/stash.d.ts +13 -11
  353. package/packages/tools/dist/stash.js +1 -2
  354. package/packages/tools/dist/stratum-card.d.ts +27 -28
  355. package/packages/tools/dist/stratum-card.js +3 -5
  356. package/packages/tools/dist/symbol.d.ts +31 -26
  357. package/packages/tools/dist/symbol.js +3 -3
  358. package/packages/tools/dist/test-run.d.ts +19 -16
  359. package/packages/tools/dist/test-run.js +2 -2
  360. package/packages/tools/dist/text-utils.d.ts +6 -4
  361. package/packages/tools/dist/text-utils.js +2 -2
  362. package/packages/tools/dist/time-utils.d.ts +15 -13
  363. package/packages/tools/dist/time-utils.js +1 -1
  364. package/packages/tools/dist/trace.d.ts +26 -21
  365. package/packages/tools/dist/trace.js +2 -2
  366. package/packages/tools/dist/truncation.d.ts +6 -4
  367. package/packages/tools/dist/truncation.js +6 -13
  368. package/packages/tools/dist/watch.d.ts +28 -26
  369. package/packages/tools/dist/watch.js +1 -1
  370. package/packages/tools/dist/web-fetch.d.ts +35 -33
  371. package/packages/tools/dist/web-fetch.js +6 -12
  372. package/packages/tools/dist/web-search.d.ts +16 -14
  373. package/packages/tools/dist/web-search.js +1 -1
  374. package/packages/tools/dist/workset.d.ts +19 -17
  375. package/packages/tools/dist/workset.js +1 -2
  376. package/packages/tui/dist/App-CYLNJLr6.js +2 -0
  377. package/packages/tui/dist/App.d.ts +11 -6
  378. package/packages/tui/dist/App.js +1 -450
  379. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +2 -0
  380. package/packages/tui/dist/LogPanel-DtMnoyXT.js +3 -0
  381. package/packages/tui/dist/SearchPanel-DREo6zgt.js +2 -0
  382. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +2 -0
  383. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  384. package/packages/tui/dist/devtools-DUyj952l.js +7 -0
  385. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +28 -0
  386. package/packages/tui/dist/index-B9VpfVPP.d.ts +13 -0
  387. package/packages/tui/dist/index.d.ts +3 -19
  388. package/packages/tui/dist/index.js +1 -476
  389. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +316 -0
  390. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -6
  391. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  392. package/packages/tui/dist/panels/LogPanel.d.ts +7 -3
  393. package/packages/tui/dist/panels/LogPanel.js +1 -449
  394. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -8
  395. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  396. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -6
  397. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  398. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +150 -0
  399. package/scaffold/adapters/claude-code.mjs +20 -0
  400. package/scaffold/adapters/copilot.mjs +320 -0
  401. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  402. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +21 -0
  403. package/scaffold/copilot/agents/Documenter.agent.md +42 -0
  404. package/scaffold/copilot/agents/Orchestrator.agent.md +104 -0
  405. package/scaffold/copilot/agents/Planner.agent.md +54 -0
  406. package/scaffold/copilot/agents/Refactor.agent.md +36 -0
  407. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +20 -0
  408. package/scaffold/copilot/agents/Researcher-Beta.agent.md +20 -0
  409. package/scaffold/copilot/agents/Researcher-Delta.agent.md +20 -0
  410. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +20 -0
  411. package/scaffold/definitions/agents.mjs +165 -0
  412. package/scaffold/definitions/bodies.mjs +292 -0
  413. package/scaffold/definitions/hooks.mjs +43 -0
  414. package/scaffold/definitions/models.mjs +56 -0
  415. package/scaffold/definitions/plugins.mjs +24 -0
  416. package/scaffold/definitions/prompts.mjs +145 -0
  417. package/scaffold/definitions/protocols.mjs +322 -0
  418. package/scaffold/definitions/tools.mjs +176 -0
  419. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  420. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
  421. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
  422. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
  423. package/scaffold/general/agents/Debugger.agent.md +31 -0
  424. package/scaffold/general/agents/Documenter.agent.md +42 -0
  425. package/scaffold/general/agents/Explorer.agent.md +50 -0
  426. package/scaffold/general/agents/Frontend.agent.md +29 -0
  427. package/scaffold/general/agents/Implementer.agent.md +31 -0
  428. package/scaffold/general/agents/Orchestrator.agent.md +104 -0
  429. package/scaffold/general/agents/Planner.agent.md +55 -0
  430. package/scaffold/general/agents/README.md +57 -0
  431. package/scaffold/general/agents/Refactor.agent.md +36 -0
  432. package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
  433. package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
  434. package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
  435. package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
  436. package/scaffold/general/agents/Security.agent.md +42 -0
  437. package/scaffold/general/agents/_shared/adr-protocol.md +91 -0
  438. package/scaffold/general/agents/_shared/architect-reviewer-base.md +50 -0
  439. package/scaffold/general/agents/_shared/code-agent-base.md +88 -0
  440. package/scaffold/general/agents/_shared/code-reviewer-base.md +54 -0
  441. package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
  442. package/scaffold/general/agents/_shared/forge-protocol.md +46 -0
  443. package/scaffold/general/agents/_shared/researcher-base.md +61 -0
  444. package/scaffold/general/agents/templates/adr-template.md +27 -0
  445. package/scaffold/general/agents/templates/execution-state.md +25 -0
  446. package/scaffold/general/prompts/ask.prompt.md +20 -0
  447. package/scaffold/general/prompts/debug.prompt.md +25 -0
  448. package/scaffold/general/prompts/design.prompt.md +22 -0
  449. package/scaffold/general/prompts/implement.prompt.md +26 -0
  450. package/scaffold/general/prompts/plan.prompt.md +24 -0
  451. package/scaffold/general/prompts/review.prompt.md +31 -0
  452. package/scaffold/generate.mjs +74 -0
  453. package/skills/adr-skill/SKILL.md +329 -0
  454. package/skills/adr-skill/assets/templates/adr-madr.md +89 -0
  455. package/skills/adr-skill/assets/templates/adr-readme.md +20 -0
  456. package/skills/adr-skill/assets/templates/adr-simple.md +46 -0
  457. package/skills/adr-skill/references/adr-conventions.md +95 -0
  458. package/skills/adr-skill/references/examples.md +193 -0
  459. package/skills/adr-skill/references/review-checklist.md +77 -0
  460. package/skills/adr-skill/references/template-variants.md +52 -0
  461. package/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
  462. package/skills/adr-skill/scripts/new_adr.js +391 -0
  463. package/skills/adr-skill/scripts/set_adr_status.js +169 -0
  464. package/skills/brainstorming/SKILL.md +259 -0
  465. package/skills/brainstorming/scripts/frame-template.html +365 -0
  466. package/skills/brainstorming/scripts/helper.js +216 -0
  467. package/skills/brainstorming/scripts/server.cjs +9 -0
  468. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  469. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  470. package/skills/brainstorming/visual-companion.md +430 -0
  471. package/skills/c4-architecture/SKILL.md +295 -0
  472. package/skills/c4-architecture/references/advanced-patterns.md +552 -0
  473. package/skills/c4-architecture/references/c4-syntax.md +492 -0
  474. package/skills/c4-architecture/references/common-mistakes.md +437 -0
  475. package/skills/knowledge-base/SKILL.md +100 -10
  476. package/skills/lesson-learned/SKILL.md +105 -0
  477. package/skills/lesson-learned/references/anti-patterns.md +55 -0
  478. package/skills/lesson-learned/references/se-principles.md +109 -0
  479. package/skills/requirements-clarity/SKILL.md +324 -0
  480. package/skills/session-handoff/SKILL.md +189 -0
  481. package/skills/session-handoff/references/handoff-template.md +139 -0
  482. package/skills/session-handoff/references/resume-checklist.md +80 -0
  483. package/skills/session-handoff/scripts/check_staleness.js +269 -0
  484. package/skills/session-handoff/scripts/create_handoff.js +299 -0
  485. package/skills/session-handoff/scripts/list_handoffs.js +113 -0
  486. package/skills/session-handoff/scripts/validate_handoff.js +241 -0
  487. package/packages/chunker/dist/treesitter-chunker.d.ts +0 -47
  488. package/packages/chunker/dist/treesitter-chunker.js +0 -8
  489. package/packages/cli/dist/commands/init.d.ts +0 -10
  490. package/packages/cli/dist/commands/init.js +0 -308
@@ -1,34 +1,35 @@
1
+ //#region packages/tools/src/snippet.d.ts
1
2
  /**
2
3
  * kb_snippet — Persistent code template storage with search.
3
4
  */
4
- export interface Snippet {
5
- name: string;
6
- language: string;
7
- code: string;
8
- tags: string[];
9
- created: string;
10
- updated: string;
5
+ interface Snippet {
6
+ name: string;
7
+ language: string;
8
+ code: string;
9
+ tags: string[];
10
+ created: string;
11
+ updated: string;
11
12
  }
12
- export type SnippetAction = 'save' | 'get' | 'list' | 'search' | 'delete';
13
- export interface SnippetOptions {
14
- action: SnippetAction;
15
- name?: string;
16
- language?: string;
17
- code?: string;
18
- tags?: string[];
19
- query?: string;
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;
20
21
  }
21
- export type SnippetResult = Snippet | {
22
- snippets: SnippetSummary[];
22
+ type SnippetResult = Snippet | {
23
+ snippets: SnippetSummary[];
23
24
  } | {
24
- deleted: boolean;
25
+ deleted: boolean;
25
26
  };
26
27
  interface SnippetSummary {
27
- name: string;
28
- language: string;
29
- tags: string[];
30
- updated: string;
28
+ name: string;
29
+ language: string;
30
+ tags: string[];
31
+ updated: string;
31
32
  }
32
- export declare function snippet(options: SnippetOptions): SnippetResult;
33
- export {};
34
- //# sourceMappingURL=snippet.d.ts.map
33
+ declare function snippet(options: SnippetOptions): SnippetResult;
34
+ //#endregion
35
+ export { Snippet, SnippetAction, SnippetOptions, SnippetResult, snippet };
@@ -1 +1 @@
1
- import{existsSync as p,mkdirSync as f,readdirSync as l,readFileSync as u,unlinkSync as m,writeFileSync as S}from"node:fs";import{join as a}from"node:path";const o=()=>a(process.cwd(),".kb-state","snippets");function d(){const e=o();return p(e)||f(e,{recursive:!0}),e}function g(e){const n=e.replace(/[^a-zA-Z0-9_-]/g,"_");if(!n)throw new Error("Invalid snippet name");return n}function h(e){switch(e.action){case"save":{if(!e.name||!e.code)throw new Error("name and code required for save");const n=d(),s=g(e.name),i=a(n,`${s}.json`),r=p(i)?JSON.parse(u(i,"utf8")):null,t=new Date().toISOString(),c={name:e.name,language:e.language??"text",code:e.code,tags:e.tags??[],created:r?.created??t,updated:t};return S(i,JSON.stringify(c,null,2)),c}case"get":{if(!e.name)throw new Error("name required for get");const n=a(o(),`${g(e.name)}.json`);if(!p(n))throw new Error(`Snippet not found: ${e.name}`);return JSON.parse(u(n,"utf8"))}case"list":{const n=d();return{snippets:l(n).filter(r=>r.endsWith(".json")).map(r=>{const t=JSON.parse(u(a(n,r),"utf8"));return{name:t.name,language:t.language,tags:t.tags,updated:t.updated}})}}case"search":{if(!e.query)throw new Error("query required for search");const n=e.query.toLowerCase(),s=d();return{snippets:l(s).filter(t=>t.endsWith(".json")).map(t=>JSON.parse(u(a(s,t),"utf8"))).filter(t=>t.name.toLowerCase().includes(n)||t.tags.some(c=>c.toLowerCase().includes(n))||t.language.toLowerCase().includes(n)||t.code.toLowerCase().includes(n)).map(t=>({name:t.name,language:t.language,tags:t.tags,updated:t.updated}))}}case"delete":{if(!e.name)throw new Error("name required for delete");const n=a(o(),`${g(e.name)}.json`);return p(n)?(m(n),{deleted:!0}):{deleted:!1}}default:throw new Error(`Unknown action: ${e.action}`)}}export{h as snippet};
1
+ import{join as e}from"node:path";import{existsSync as t,mkdirSync as n,readFileSync as r,readdirSync as i,unlinkSync as a,writeFileSync as o}from"node:fs";import{KB_PATHS as s}from"../../core/dist/index.js";const c=()=>e(process.cwd(),s.state,`snippets`);function l(){let e=c();return t(e)||n(e,{recursive:!0}),e}function u(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);if(!t)throw Error(`Invalid snippet name`);return t}function d(n){switch(n.action){case`save`:{if(!n.name||!n.code)throw Error(`name and code required for save`);let i=e(l(),`${u(n.name)}.json`),a=null;if(t(i))try{a=JSON.parse(r(i,`utf8`))}catch{a=null}let s=new Date().toISOString(),c={name:n.name,language:n.language??`text`,code:n.code,tags:n.tags??[],created:a?.created??s,updated:s};return o(i,JSON.stringify(c,null,2)),c}case`get`:{if(!n.name)throw Error(`name required for get`);let i=e(c(),`${u(n.name)}.json`);if(!t(i))throw Error(`Snippet not found: ${n.name}`);try{return JSON.parse(r(i,`utf8`))}catch{throw Error(`Snippet corrupted: ${n.name}`)}}case`list`:{let t=l();return{snippets:i(t).filter(e=>e.endsWith(`.json`)).flatMap(n=>{try{let i=JSON.parse(r(e(t,n),`utf8`));return[{name:i.name,language:i.language,tags:i.tags,updated:i.updated}]}catch{return[]}})}}case`search`:{if(!n.query)throw Error(`query required for search`);let t=n.query.toLowerCase(),a=l();return{snippets:i(a).filter(e=>e.endsWith(`.json`)).flatMap(t=>{try{return[JSON.parse(r(e(a,t),`utf8`))]}catch{return[]}}).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(c(),`${u(n.name)}.json`);return t(r)?(a(r),{deleted:!0}):{deleted:!1}}default:throw Error(`Unknown action: ${n.action}`)}}export{d as snippet};
@@ -1,12 +1,14 @@
1
- export interface StashEntry {
2
- key: string;
3
- value: unknown;
4
- type: string;
5
- storedAt: string;
1
+ //#region packages/tools/src/stash.d.ts
2
+ interface StashEntry {
3
+ key: string;
4
+ value: unknown;
5
+ type: string;
6
+ storedAt: string;
6
7
  }
7
- export declare function stashSet(key: string, value: unknown, cwd?: string): StashEntry;
8
- export declare function stashGet(key: string, cwd?: string): StashEntry | undefined;
9
- export declare function stashList(cwd?: string): StashEntry[];
10
- export declare function stashDelete(key: string, cwd?: string): boolean;
11
- export declare function stashClear(cwd?: string): number;
12
- //# sourceMappingURL=stash.d.ts.map
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,2 +1 @@
1
- import{existsSync as a,mkdirSync as u,readFileSync as h,writeFileSync as S}from"node:fs";import{dirname as g,resolve as f}from"node:path";const y=".kb-state",p="stash.json";function c(t){const n=t??process.cwd();return f(n,y,p)}function e(t){const n=c(t);if(!a(n))return{};const r=h(n,"utf-8");return JSON.parse(r)}function o(t,n){const r=c(n),s=g(r);a(s)||u(s,{recursive:!0}),S(r,`${JSON.stringify(t,null,2)}
2
- `,"utf-8")}function E(t,n,r){const s=e(r),i={key:t,value:n,type:typeof n,storedAt:new Date().toISOString()};return s[t]=i,o(s,r),i}function m(t,n){return e(n)[t]}function x(t){return Object.values(e(t))}function b(t,n){const r=e(n);return t in r?(delete r[t],o(r,n),!0):!1}function v(t){const n=e(t),r=Object.keys(n).length;return o({},t),r}export{v as stashClear,b as stashDelete,m as stashGet,x as stashList,E as stashSet};
1
+ import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{KB_PATHS as o}from"../../core/dist/index.js";const s=o.state;function c(e){return t(e??process.cwd(),s,`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{return{}}}function u(t,i){let o=c(i),s=e(o);n(s)||r(s,{recursive:!0}),a(o,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}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,31 +1,30 @@
1
- /**
2
- * kb_stratum_card STRATUM T1/T2 context card generator.
3
- *
4
- * Generates compact context cards from files. T1 = structural metadata only
5
- * (~100 tokens/file). T2 = T1 + compressed content (~300 tokens/file).
6
- * Uses file-summary for structure and embedder for T2 content scoring.
7
- */
8
- import type { IEmbedder } from '@kb/embeddings';
9
- export interface StratumCardOptions {
10
- files: string[];
11
- query: string;
12
- tier?: 'T1' | 'T2';
13
- maxContentChars?: number;
1
+ import { FileCache } from "./file-cache.js";
2
+ import { IEmbedder } from "@kb/embeddings";
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;
14
12
  }
15
- export interface StratumCard {
16
- path: string;
17
- tier: 'T1' | 'T2';
18
- card: string;
19
- unknowns: string[];
20
- riskTier: 'low' | 'medium' | 'high';
21
- tokenEstimate: number;
22
- originalTokenEstimate: number;
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;
23
21
  }
24
- export interface StratumCardResult {
25
- cards: StratumCard[];
26
- totalTokenEstimate: number;
27
- totalOriginalTokenEstimate: number;
28
- compressionRatio: number;
22
+ interface StratumCardResult {
23
+ cards: StratumCard[];
24
+ totalTokenEstimate: number;
25
+ totalOriginalTokenEstimate: number;
26
+ compressionRatio: number;
29
27
  }
30
- export declare function stratumCard(embedder: IEmbedder, options: StratumCardOptions): Promise<StratumCardResult>;
31
- //# sourceMappingURL=stratum-card.d.ts.map
28
+ declare function stratumCard(embedder: IEmbedder, options: StratumCardOptions): Promise<StratumCardResult>;
29
+ //#endregion
30
+ export { StratumCard, StratumCardOptions, StratumCardResult, stratumCard };
@@ -1,6 +1,4 @@
1
- import{readFile as F}from"node:fs/promises";import{basename as h,extname as I,relative as A}from"node:path";import{fileSummary as j}from"./file-summary.js";import{cosineSimilarity as X,estimateTokens as y,segment as D}from"./text-utils.js";const M=800,S=3;async function B(t,e){const{files:r,query:o,tier:n="T1",maxContentChars:m=M}=e,u=n==="T2"?await t.embedQuery(o):null,l=await Promise.all(r.map(async i=>{try{const c=await F(i,"utf-8"),p=y(c);if(c.includes("\0"))return C(i,n,"binary","binary file",p);if(c.trim().length===0){const g=x({displayPath:T(i),tier:n,role:"empty",deps:[],exports:[],unknowns:[],riskTier:"low"});return{path:i,tier:n,card:g,unknowns:[],riskTier:"low",tokenEstimate:y(g),originalTokenEstimate:p}}const d=await j({path:i}),N=U(i,d),E=W(c,d),w=_(i,d),O=$(d),R=[...new Set(d.exports)].slice(0,5);let f=x({displayPath:T(i),tier:n,role:N,deps:O,exports:R,unknowns:E,riskTier:w});if(n==="T2"&&u){const g=await v(t,u,c,m);g.length>0&&(f=`${f}
2
- CONTEXT:
3
- ${g}`)}return{path:i,tier:n,card:f,unknowns:E,riskTier:w,tokenEstimate:y(f),originalTokenEstimate:p}}catch(c){const p=c.code==="ENOENT"?"file missing":"unreadable file",d=c.code==="ENOENT"?"missing":"unreadable";return C(i,n,d,p,0)}})),s=l.reduce((i,c)=>i+c.tokenEstimate,0),a=l.reduce((i,c)=>i+c.originalTokenEstimate,0);return{cards:l,totalTokenEstimate:s,totalOriginalTokenEstimate:a,compressionRatio:a===0?0:s/a}}function C(t,e,r,o,n){const m=x({displayPath:T(t),tier:e,role:r,deps:[],exports:[],unknowns:[o],riskTier:"low"});return{path:t,tier:e,card:m,unknowns:[o],riskTier:"low",tokenEstimate:y(m),originalTokenEstimate:n}}function x(t){const{displayPath:e,tier:r,role:o,deps:n,exports:m,unknowns:u,riskTier:l}=t;return[`[${r}: ${e}]`,`ROLE: ${o}`,`DEPS: ${k(n)}`,`EXPORTS: ${k(m)}`,`UNKNOWNS: ${k(u,"; ")}`,`RISK: ${l}`].join(`
4
- `)}function T(t){const e=A(process.cwd(),t).replace(/\\/g,"/");return!e||e.startsWith("..")?h(t):e}function k(t,e=", "){return t.length>0?t.join(e):"none"}function U(t,e){const r=h(t),o=I(r).toLowerCase();return[".json",".yaml",".yml",".env"].includes(o)||/config|settings/i.test(r)?"configuration":/types?\.ts$|\.d\.ts$/i.test(r)?"type-definitions":/schema/i.test(r)?"schema":/test|spec/i.test(r)?"test":/index\.[jt]sx?$/i.test(r)?"barrel-export":/handler|controller|route/i.test(r)?"entry-point":/model|entity/i.test(r)?"data-model":/util|helper/i.test(r)?"utility":/service|provider/i.test(r)?"service":e.classes.length>0?"class-module":e.interfaces.length>2?"type-definitions":"implementation"}function W(t,e){const r=[],o=new Set;for(const n of t.matchAll(/\/\/\s*(TODO|FIXME|HACK|XXX)\s*:?\s*(.+)?$/gm)){const m=`${n[1]}: ${(n[2]??"").trim()}`.trim();b(r,o,m.replace(/:\s*$/,""))}K(t)&&b(r,o,"exported any usage");for(const n of $(e))b(r,o,`cross-package import: ${n}`);return r.slice(0,S)}function b(t,e,r){t.length>=S||!r||e.has(r)||(e.add(r),t.push(r))}function K(t){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(r=>r.test(t))}function _(t,e){return/auth|token|permission|secret|credential|encrypt/i.test(t)?"high":/types?\.ts$|schema|contract|\.d\.ts$/i.test(h(t))||e.exports.length>10?"medium":"low"}function $(t){return t.imports.map(q).filter(e=>!!e).filter(e=>!e.startsWith("./")&&!e.startsWith("../")).slice(0,3)}function q(t){const e=t.match(/from\s+['"]([^'"]+)['"]/);if(e)return e[1];const r=t.match(/^import\s+['"]([^'"]+)['"]/);return r?r[1]:null}async function v(t,e,r,o){if(o<=0)return"";const n=D(r,"paragraph");if(n.length===0)return"";const m=await Promise.all(n.map(async(s,a)=>{const i=await t.embed(s);return{index:a,text:s,score:X(e,i)}})),u=[];let l=0;for(const s of m.sort((a,i)=>i.score-a.score)){const a=o-l;if(a<=0)break;if(s.text.length<=a){u.push({index:s.index,text:s.text}),l+=s.text.length;continue}u.length===0&&(u.push({index:s.index,text:s.text.slice(0,a).trimEnd()}),l=o);break}return u.sort((s,a)=>s.index-a.index).map(s=>s.text).filter(s=>s.length>0).join(`
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(`
5
3
 
6
- `)}export{B as stratumCard};
4
+ `)}export{c as stratumCard};
@@ -1,28 +1,33 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IKnowledgeStore } from '@kb/store';
3
- export interface SymbolInfo {
4
- name: string;
5
- definedIn?: {
6
- path: string;
7
- line: number;
8
- kind: string;
9
- };
10
- importedBy: Array<{
11
- path: string;
12
- line: number;
13
- importStatement: string;
14
- }>;
15
- referencedIn: Array<{
16
- path: string;
17
- line: number;
18
- context: string;
19
- }>;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+
4
+ //#region packages/tools/src/symbol.d.ts
5
+ interface SymbolInfo {
6
+ name: string;
7
+ definedIn?: {
8
+ path: string;
9
+ line: number;
10
+ kind: string;
11
+ signature?: string;
12
+ };
13
+ importedBy: Array<{
14
+ path: string;
15
+ line: number;
16
+ importStatement: string;
17
+ }>;
18
+ referencedIn: Array<{
19
+ path: string;
20
+ line: number;
21
+ context: string;
22
+ scope?: string;
23
+ }>;
20
24
  }
21
- export interface SymbolOptions {
22
- /** Symbol name to look up */
23
- name: string;
24
- /** Limit results */
25
- limit?: number;
25
+ interface SymbolOptions {
26
+ /** Symbol name to look up */
27
+ name: string;
28
+ /** Limit results */
29
+ limit?: number;
26
30
  }
27
- export declare function symbol(embedder: IEmbedder, store: IKnowledgeStore, options: SymbolOptions): Promise<SymbolInfo>;
28
- //# sourceMappingURL=symbol.d.ts.map
31
+ declare function symbol(embedder: IEmbedder, store: IKnowledgeStore, options: SymbolOptions): Promise<SymbolInfo>;
32
+ //#endregion
33
+ export { SymbolInfo, SymbolOptions, symbol };
@@ -1,3 +1,3 @@
1
- function l(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function P(i,d,h){const{name:t,limit:s=20}=h,m=i.embedQuery?.bind(i)??i.embed.bind(i),g=[`export function ${t}`,`export class ${t}`,`export const ${t}`,`export interface ${t}`,`export type ${t}`,`export enum ${t}`].join(" | "),x=await d.search(await m(g),{limit:s*2}),I=new RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${l(t)}\\b`,"m");let a;for(const e of x){if(!I.test(e.record.content))continue;const r=e.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??"unknown";a={path:e.record.sourcePath,line:e.record.startLine,kind:r};break}const p=new RegExp(`import\\s+.*\\b${l(t)}\\b.*from\\s+`,"m"),$=await d.search(await m(`import ${t} from`),{limit:s*3}),f=[],u=new Set;for(const e of $){const r=e.record.content.split(`
2
- `);for(let n=0;n<r.length;n++){const o=r[n];if(!p.test(o))continue;const c=`${e.record.sourcePath}:${o.trim()}`;u.has(c)||(u.add(c),f.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:o.trim()}))}}const w=new RegExp(`\\b${l(t)}\\b`),S=await d.search(await m(t),{limit:s*3}),y=[],b=new Set;for(const e of S){if(a&&e.record.sourcePath===a.path)continue;const r=e.record.content.split(`
3
- `);for(let n=0;n<r.length;n++){const o=r[n];if(!w.test(o)||p.test(o))continue;const c=`${e.record.sourcePath}:${e.record.startLine+n}`;if(!b.has(c)){b.add(c),y.push({path:e.record.sourcePath,line:e.record.startLine+n,context:o.trim().slice(0,120)});break}}}return{name:t,definedIn:a,importedBy:f.slice(0,s),referencedIn:y.slice(0,s)}}export{P as symbol};
1
+ import{extname as e}from"node:path";import{SUPPORTED_EXTENSIONS as t,WasmRuntime as n,extractSymbols as r,resolveScopes as i}from"../../chunker/dist/index.js";function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}async function o(o,s,c){let{name:l,limit:u=20}=c,d=o.embedQuery?.bind(o)??o.embed.bind(o),f=[`export function ${l}`,`export class ${l}`,`export const ${l}`,`export interface ${l}`,`export type ${l}`,`export enum ${l}`].join(` | `),p=await s.search(await d(f),{limit:u*2}),m=RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${a(l)}\\b`,`m`),h;for(let i of p){if(!m.test(i.record.content))continue;let a=i.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??`unknown`;h={path:i.record.sourcePath,line:i.record.startLine,kind:a};let o=e(i.record.sourcePath);if(n.get()&&t.has(o))try{let e=(await r(i.record.content,o,i.record.sourcePath)).find(e=>e.name===l&&e.exported);e&&(h.kind=e.kind,e.signature&&(h.signature=e.signature))}catch{}break}let g=RegExp(`import\\s+.*\\b${a(l)}\\b.*from\\s+`,`m`),_=await s.search(await d(`import ${l} from`),{limit:u*3}),v=[],y=new Set;for(let e of _){let t=e.record.content.split(`
2
+ `);for(let n=0;n<t.length;n++){let r=t[n];if(!g.test(r))continue;let i=`${e.record.sourcePath}:${r.trim()}`;y.has(i)||(y.add(i),v.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:r.trim()}))}}let b=RegExp(`\\b${a(l)}\\b`),x=await s.search(await d(l),{limit:u*3}),S=[],C=new Set;for(let r of x){if(h&&r.record.sourcePath===h.path)continue;let a=r.record.content.split(`
3
+ `);for(let o=0;o<a.length;o++){let s=a[o];if(!b.test(s)||g.test(s))continue;let c=`${r.record.sourcePath}:${r.record.startLine+o}`;if(C.has(c))continue;C.add(c);let l,u=e(r.record.sourcePath);if(n.get()&&t.has(u))try{let e=await i(r.record.content,u,o+1);e.length>0&&(l=e[0].name)}catch{}S.push({path:r.record.sourcePath,line:r.record.startLine+o,context:s.trim().slice(0,120),scope:l});break}}return{name:l,definedIn:h,importedBy:v.slice(0,u),referencedIn:S.slice(0,u)}}export{o as symbol};
@@ -1,23 +1,26 @@
1
- import { type ParsedTestSummary } from './parse-output.js';
2
- export interface TestRunOptions {
3
- files?: string[];
4
- cwd?: string;
5
- timeout?: number;
6
- grep?: string;
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;
7
9
  }
8
- export interface TestRunResult {
9
- summary: ParsedTestSummary;
10
- passed: boolean;
11
- raw: string;
12
- durationMs: number;
10
+ interface TestRunResult {
11
+ summary: ParsedTestSummary;
12
+ passed: boolean;
13
+ raw: string;
14
+ durationMs: number;
13
15
  }
14
- export declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
16
+ declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
15
17
  /**
16
18
  * Classify non-zero exit codes — some tools use exit code 1 for
17
19
  * non-error conditions (e.g., grep returns 1 for "no matches").
18
20
  */
19
- export declare function classifyExitCode(exitCode: number, _stdout: string, command?: string): {
20
- isError: boolean;
21
- reason?: string;
21
+ declare function classifyExitCode(exitCode: number, _stdout: string, command?: string): {
22
+ isError: boolean;
23
+ reason?: string;
22
24
  };
23
- //# sourceMappingURL=test-run.d.ts.map
25
+ //#endregion
26
+ export { TestRunOptions, TestRunResult, classifyExitCode, testRun };
@@ -1,2 +1,2 @@
1
- import{execFile as f}from"node:child_process";import{promisify as c}from"node:util";import{parseVitest as u}from"./parse-output.js";const m=c(f);async function w(r={}){const e=r.cwd??process.cwd(),t=r.timeout??6e4,n=Date.now(),i=["vitest","run","--reporter=verbose"];r.files?.length&&i.push(...r.files),r.grep&&i.push("--testNamePattern",r.grep);try{const{stdout:o}=await m("npx",i,{cwd:e,shell:!0,timeout:t}),s=o.toString(),a=u(s);return{summary:a,passed:a.failed===0,raw:s,durationMs:Date.now()-n}}catch(o){const s=g(o);return{summary:u(s),passed:!1,raw:s,durationMs:Date.now()-n}}}function g(r){const e=r,t=e.stdout?.toString()??"",n=e.stderr?.toString()??"";return[t,n].filter(Boolean).join(`
2
- `).trim()||e.message||"Test run failed"}function y(r,e,t){if(r===0)return{isError:!1};if(r===1&&t){if(/\b(grep|rg|ripgrep|ag|ack|findstr)\b/i.test(t))return{isError:!1,reason:"grep: no matches (exit 1 is normal)"};if(/\bdiff\b/i.test(t))return{isError:!1,reason:"diff: files differ (exit 1 is normal)"}}return{isError:!0}}export{y as classifyExitCode,w as testRun};
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:t}=await r(`npx ${o.join(` `)}`,{cwd:n,timeout:i}),s=t.toString(),c=e(s);return{summary:c,passed:c.failed===0,raw:s,durationMs:Date.now()-a}}catch(t){let n=s(t);return{summary:e(n),passed:!1,raw:n,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,16 +1,18 @@
1
+ //#region packages/tools/src/text-utils.d.ts
1
2
  /**
2
3
  * Shared text utilities used by compact, digest, stratum-card, and other tools.
3
4
  */
4
5
  /**
5
6
  * Approximate token count from character count (~4 chars/token).
6
7
  */
7
- export declare function estimateTokens(text: string): number;
8
+ declare function estimateTokens(text: string): number;
8
9
  /**
9
10
  * Segment text into chunks for scoring.
10
11
  */
11
- export declare function segment(text: string, strategy: 'paragraph' | 'sentence' | 'line'): string[];
12
+ declare function segment(text: string, strategy: 'paragraph' | 'sentence' | 'line'): string[];
12
13
  /**
13
14
  * Cosine similarity between two vectors.
14
15
  */
15
- export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
16
- //# sourceMappingURL=text-utils.d.ts.map
16
+ declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
17
+ //#endregion
18
+ export { cosineSimilarity, estimateTokens, segment };
@@ -1,2 +1,2 @@
1
- function a(e){return Math.ceil(e.length/4)}function o(e,n){switch(n){case"paragraph":return e.split(/\n\s*\n/).map(t=>t.trim()).filter(t=>t.length>0);case"sentence":return e.split(/(?<=[.!?])\s+/).map(t=>t.trim()).filter(t=>t.length>0);case"line":return e.split(`
2
- `).map(t=>t.trim()).filter(t=>t.length>0)}}function m(e,n){let t=0,i=0,l=0;for(let r=0;r<e.length;r++)t+=e[r]*n[r],i+=e[r]*e[r],l+=n[r]*n[r];const s=Math.sqrt(i)*Math.sqrt(l);return s===0?0:t/s}export{m as cosineSimilarity,a as estimateTokens,o as segment};
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}export{n as cosineSimilarity,e as estimateTokens,t as segment};
@@ -1,18 +1,20 @@
1
+ //#region packages/tools/src/time-utils.d.ts
1
2
  /**
2
3
  * kb_time — Timezone conversion, date parsing, duration calculation.
3
4
  */
4
- export type TimeOperation = 'now' | 'parse' | 'convert' | 'diff' | 'add';
5
- export interface TimeOptions {
6
- operation: TimeOperation;
7
- input?: string;
8
- timezone?: string;
9
- duration?: string;
5
+ type TimeOperation = 'now' | 'parse' | 'convert' | 'diff' | 'add';
6
+ interface TimeOptions {
7
+ operation: TimeOperation;
8
+ input?: string;
9
+ timezone?: string;
10
+ duration?: string;
10
11
  }
11
- export interface TimeResult {
12
- output: string;
13
- iso: string;
14
- unix: number;
15
- details?: Record<string, string | number>;
12
+ interface TimeResult {
13
+ output: string;
14
+ iso: string;
15
+ unix: number;
16
+ details?: Record<string, string | number>;
16
17
  }
17
- export declare function timeUtils(options: TimeOptions): TimeResult;
18
- //# sourceMappingURL=time-utils.d.ts.map
18
+ declare function timeUtils(options: TimeOptions): TimeResult;
19
+ //#endregion
20
+ export { TimeOperation, TimeOptions, TimeResult, timeUtils };
@@ -1 +1 @@
1
- function h(o){const{operation:e,input:t,timezone:n}=o;switch(e){case"now":return m(new Date,n);case"parse":{if(!t)throw new Error("input required for parse");return m(u(t),n)}case"convert":{if(!t)throw new Error("input required for convert");if(!n)throw new Error("timezone required for convert");return m(u(t),n)}case"diff":{if(!t)throw new Error("input required for diff (two comma-separated dates)");const r=t.split(",").map(c=>c.trim());if(r.length<2)throw new Error("diff requires two comma-separated dates");const i=u(r[0]),a=u(r[1]),s=Math.abs(a.getTime()-i.getTime());return{output:f(s),iso:`PT${Math.floor(s/1e3)}S`,unix:s,details:{milliseconds:s,seconds:Math.floor(s/1e3),minutes:Math.floor(s/6e4),hours:Math.floor(s/36e5),days:Math.floor(s/864e5)}}}case"add":{if(!t)throw new Error("input required for add");const{duration:r}=o;if(!r)throw new Error('duration required for add (e.g., "2h30m")');const i=u(t),a=d(r);return m(new Date(i.getTime()+a),n)}default:throw new Error(`Unknown operation: ${e}`)}}function u(o){const e=Number(o);if(!Number.isNaN(e))return new Date(e>1e12?e:e*1e3);const t=new Date(o);if(Number.isNaN(t.getTime()))throw new Error(`Cannot parse date: ${o}`);return t}function m(o,e){const t=e??"UTC",n=o.toLocaleString("en-US",{timeZone:t,dateStyle:"full",timeStyle:"long"}),r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(o).reduce((i,a)=>(a.type!=="literal"&&(i[a.type]=Number.parseInt(a.value,10)),i),{});return{output:n,iso:o.toISOString(),unix:Math.floor(o.getTime()/1e3),details:{timezone:t,year:r.year,month:r.month,day:r.day,hour:r.hour===24?0:r.hour,minute:r.minute,second:r.second}}}function f(o){const e=[],t=Math.floor(o/864e5);t&&e.push(`${t}d`);const n=Math.floor(o%864e5/36e5);n&&e.push(`${n}h`);const r=Math.floor(o%36e5/6e4);r&&e.push(`${r}m`);const i=Math.floor(o%6e4/1e3);return(i||e.length===0)&&e.push(`${i}s`),e.join(" ")}function d(o){let e=0;const t=o.matchAll(/(\d+)\s*(d|h|m|s|ms)/gi);for(const n of t){const r=Number(n[1]);switch(n[2].toLowerCase()){case"d":e+=r*864e5;break;case"h":e+=r*36e5;break;case"m":e+=r*6e4;break;case"s":e+=r*1e3;break;case"ms":e+=r;break}}if(e===0)throw new Error(`Cannot parse duration: ${o}`);return e}export{h as timeUtils};
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,24 +1,29 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IKnowledgeStore } from '@kb/store';
3
- export interface TraceOptions {
4
- /** Starting point — a symbol or file:line reference */
5
- start: string;
6
- /** Direction */
7
- direction: 'forward' | 'backward' | 'both';
8
- /** Max depth (default: 3) */
9
- maxDepth?: number;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
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;
10
12
  }
11
- export interface TraceNode {
12
- path: string;
13
- symbol: string;
14
- line: number;
15
- relationship: 'calls' | 'called-by' | 'imports' | 'imported-by' | 'references';
13
+ interface TraceNode {
14
+ path: string;
15
+ symbol: string;
16
+ line: number;
17
+ relationship: 'calls' | 'called-by' | 'imports' | 'imported-by' | 'references';
18
+ /** The enclosing function/scope where the relationship occurs (AST-powered) */
19
+ scope?: string;
16
20
  }
17
- export interface TraceResult {
18
- start: string;
19
- direction: string;
20
- nodes: TraceNode[];
21
- depth: number;
21
+ interface TraceResult {
22
+ start: string;
23
+ direction: string;
24
+ nodes: TraceNode[];
25
+ depth: number;
22
26
  }
23
- export declare function trace(embedder: IEmbedder, store: IKnowledgeStore, options: TraceOptions): Promise<TraceResult>;
24
- //# sourceMappingURL=trace.d.ts.map
27
+ declare function trace(embedder: IEmbedder, store: IKnowledgeStore, options: TraceOptions): Promise<TraceResult>;
28
+ //#endregion
29
+ export { TraceNode, TraceOptions, TraceResult, trace };
@@ -1,2 +1,2 @@
1
- async function v(e,a,r){const{start:s,direction:d,maxDepth:T=3}=r,i=[],x=new Set,p=new Set,R=await e.embed(s);if((await a.search(R,{limit:10})).length===0)return{start:s,direction:d,nodes:i,depth:0};const u=[{target:s,depth:0}];let n=0;for(;u.length>0;){const t=u.shift();if(!t)break;if(t.depth>=T||x.has(t.target))continue;x.add(t.target);const N=await e.embed(t.target),P=await a.search(N,{limit:20}),c=E(t.target),l=k(t.target);for(const b of P){const w=b.record.content.split(`
2
- `);for(let h=0;h<w.length;h+=1){const o=w[h],m=b.record.startLine+h,f=b.record.sourcePath;if(d!=="forward"&&(l?new RegExp(`from\\s+['"]${c}['"]`):new RegExp(`import\\s+.*\\b${c}\\b.*from\\s+`)).test(o)){g(p,i,{path:f,symbol:t.target,line:m,relationship:"imported-by"}),n=Math.max(n,t.depth+1);const $=o.match(/from\s+['"]([^'"]+)['"]/);!l&&$&&u.push({target:$[1],depth:t.depth+1})}d!=="backward"&&(l?new RegExp(`from\\s+['"]${c}['"]`).test(o)&&(g(p,i,{path:f,symbol:t.target,line:m,relationship:"imports"}),n=Math.max(n,t.depth+1)):new RegExp(`\\b${c}\\s*\\(`).test(o)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(o)&&(g(p,i,{path:f,symbol:t.target,line:m,relationship:"calls"}),n=Math.max(n,t.depth+1))),(l?new RegExp(`['"]${c}['"]`):new RegExp(`\\b${c}\\b`)).test(o)&&!/^\s*import\s/.test(o)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(o)&&(g(p,i,{path:f,symbol:t.target,line:m,relationship:"references"}),n=Math.max(n,t.depth+1))}}}return{start:s,direction:d,nodes:M(i),depth:n}}function g(e,a,r){const s=`${r.path}:${r.line}:${r.relationship}`;e.has(s)||(e.add(s),a.push(r))}function E(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e){return/[./\\]/.test(e)}function M(e){const a=new Set;return e.filter(r=>{const s=`${r.path}:${r.line}:${r.relationship}`;return a.has(s)?!1:(a.add(s),!0)})}export{v as trace};
1
+ import{readFile as e}from"node:fs/promises";import{extname as t}from"node:path";import{SUPPORTED_EXTENSIONS as n,WasmRuntime as r,extractCalls as i}from"../../chunker/dist/index.js";async function a(e,t,n){let{start:i,direction:a,maxDepth:d=3}=n,f=[],p=new Set,m=new Set,h=!!r.get(),g=new Map,_=await e.embed(i);if((await t.search(_,{limit:10})).length===0)return{start:i,direction:a,nodes:f,depth:0};let v=[{target:i,depth:0}],y=0;for(;v.length>0;){let n=v.shift();if(!n)break;if(n.depth>=d||p.has(n.target))continue;p.add(n.target);let r=await e.embed(n.target),i=await t.search(r,{limit:20}),u=c(n.target),_=l(n.target);for(let e of i){let t=e.record.sourcePath,r=e.record.content.split(`
2
+ `);if(h&&!_){let e=await o(g,t);for(let r of e)a!==`backward`&&r.callerName===n.target&&(s(m,f,{path:t,symbol:r.calleeName,line:r.line,relationship:`calls`,scope:r.callerName}),y=Math.max(y,n.depth+1),v.push({target:r.calleeName,depth:n.depth+1})),a!==`forward`&&r.calleeName===n.target&&(s(m,f,{path:t,symbol:r.callerName,line:r.line,relationship:`called-by`,scope:r.callerName}),y=Math.max(y,n.depth+1),v.push({target:r.callerName,depth:n.depth+1}))}for(let i=0;i<r.length;i+=1){let o=r[i],c=e.record.startLine+i;if(a!==`forward`&&RegExp(_?`from\\s+['"]${u}['"]`:`import\\s+.*\\b${u}\\b.*from\\s+`).test(o)){s(m,f,{path:t,symbol:n.target,line:c,relationship:`imported-by`}),y=Math.max(y,n.depth+1);let e=o.match(/from\s+['"]([^'"]+)['"]/);!_&&e&&v.push({target:e[1],depth:n.depth+1})}a!==`backward`&&(_?RegExp(`from\\s+['"]${u}['"]`).test(o)&&(s(m,f,{path:t,symbol:n.target,line:c,relationship:`imports`}),y=Math.max(y,n.depth+1)):h||RegExp(`\\b${u}\\s*\\(`).test(o)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(o)&&(s(m,f,{path:t,symbol:n.target,line:c,relationship:`calls`}),y=Math.max(y,n.depth+1))),RegExp(_?`['"]${u}['"]`:`\\b${u}\\b`).test(o)&&!/^\s*import\s/.test(o)&&!/^\s*(?:export\s+)?(?:async\s+)?function\s/.test(o)&&(s(m,f,{path:t,symbol:n.target,line:c,relationship:`references`}),y=Math.max(y,n.depth+1))}}}return{start:i,direction:a,nodes:u(f),depth:y}}async function o(r,a){let o=r.get(a);if(o)return o;let s=t(a);if(!n.has(s))return r.set(a,[]),[];try{let t=await i(await e(a,`utf-8`),s,a);return r.set(a,t),t}catch{return r.set(a,[]),[]}}function s(e,t,n){let r=`${n.path}:${n.line}:${n.relationship}`;e.has(r)||(e.add(r),t.push(n))}function c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function l(e){return/[./\\]/.test(e)}function u(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)})}export{a as trace};
@@ -1,3 +1,4 @@
1
+ //#region packages/tools/src/truncation.d.ts
1
2
  /**
2
3
  * Smart truncation utilities.
3
4
  *
@@ -13,12 +14,12 @@
13
14
  * @param headRatio - Fraction for head portion (default 0.6)
14
15
  * @returns Truncated text with separator showing omitted line/char count
15
16
  */
16
- export declare function headTailTruncate(text: string, maxLen: number, headRatio?: number): string;
17
+ declare function headTailTruncate(text: string, maxLen: number, headRatio?: number): string;
17
18
  /**
18
19
  * Truncate at a paragraph boundary near maxLength (head-only).
19
20
  * Best for web content and markdown where structure is at the top.
20
21
  */
21
- export declare function paragraphTruncate(text: string, maxLen: number): string;
22
+ declare function paragraphTruncate(text: string, maxLen: number): string;
22
23
  /**
23
24
  * Truncate text to fit within a token budget.
24
25
  * Uses ~4 chars/token approximation. Snaps to line boundaries.
@@ -27,5 +28,6 @@ export declare function paragraphTruncate(text: string, maxLen: number): string;
27
28
  * @param maxTokens - Maximum token count
28
29
  * @returns Original text if within budget, or truncated with notice
29
30
  */
30
- export declare function truncateToTokenBudget(text: string, maxTokens: number): string;
31
- //# sourceMappingURL=truncation.d.ts.map
31
+ declare function truncateToTokenBudget(text: string, maxTokens: number): string;
32
+ //#endregion
33
+ export { headTailTruncate, paragraphTruncate, truncateToTokenBudget };
@@ -1,14 +1,7 @@
1
- const R=.6;function m(n,t,e=.6){if(n.length<=t)return n;const r=Math.max(0,t-120),o=Math.floor(r*e),a=r-o,s=n.slice(0,o),h=s.lastIndexOf(`
2
- `),i=h>0?s.slice(0,h):s,p=n.length-a,l=n.slice(p),u=l.indexOf(`
3
- `),c=u>=0?l.slice(u+1):l,$=n.length-i.length-c.length;let d=1;const B=i.length,T=n.length-c.length;for(let g=B;g<T;g++)n.charCodeAt(g)===10&&d++;return`${i}
1
+ function e(e,t,n=.6){if(e.length<=t)return e;let r=Math.max(0,t-120),i=Math.floor(r*n),a=r-i,o=e.slice(0,i),s=o.lastIndexOf(`
2
+ `),c=s>0?o.slice(0,s):o,l=e.length-a,u=e.slice(l),d=u.indexOf(`
3
+ `),f=d>=0?u.slice(d+1):u,p=e.length-c.length-f.length,m=1,h=c.length,g=e.length-f.length;for(let t=h;t<g;t++)e.charCodeAt(t)===10&&m++;return`${c}\n\n[… ${m} lines / ${(p/1024).toFixed(1)}KB truncated — showing first ${c.split(`
4
+ `).length} + last ${f.split(`
5
+ `).length} lines]\n\n${f}`}function t(e,t){if(e.length<=t)return e;let n=Math.max(0,t-200),r=e.slice(n,t).lastIndexOf(`
4
6
 
5
- [\u2026 ${d} lines / ${($/1024).toFixed(1)}KB truncated \u2014 showing first ${i.split(`
6
- `).length} + last ${c.split(`
7
- `).length} lines]
8
-
9
- ${c}`}function A(n,t){if(n.length<=t)return n;const e=Math.max(0,t-200),r=n.slice(e,t).lastIndexOf(`
10
-
11
- `),o=r>=0?e+r:t,a=n.slice(0,o).trimEnd(),s=Math.round(o/n.length*100);return`${a}
12
-
13
- ---
14
- *[Truncated at ${o.toLocaleString()} chars \u2014 ${s}% of original content]*`}function C(n,t){const e=t*4;return n.length<=e?n:m(n,e)}export{m as headTailTruncate,A as paragraphTruncate,C as truncateToTokenBudget};
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 n(t,n){let r=n*4;return t.length<=r?t:e(t,r)}export{e as headTailTruncate,t as paragraphTruncate,n as truncateToTokenBudget};