@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
@@ -0,0 +1,49 @@
1
+ //#region packages/tools/src/dogfood-log.d.ts
2
+ /**
3
+ * kb_dogfood — Review persistent warn/error logs for dogfooding.
4
+ *
5
+ * Reads daily JSONL log files from .kb-state/logs/ and returns a
6
+ * summarized or detailed view of recent issues. Useful for periodic
7
+ * review cycles to identify and fix recurring problems.
8
+ */
9
+ interface DogfoodLogEntry {
10
+ ts: string;
11
+ level: 'warn' | 'error';
12
+ component: string;
13
+ msg: string;
14
+ [key: string]: unknown;
15
+ }
16
+ interface DogfoodLogOptions {
17
+ /** Number of days to look back (default: 7) */
18
+ days?: number;
19
+ /** Filter by level */
20
+ level?: 'warn' | 'error';
21
+ /** Filter by component name */
22
+ component?: string;
23
+ /** Maximum entries to return in detail (default: 50) */
24
+ limit?: number;
25
+ }
26
+ interface DogfoodLogGroupedEntry {
27
+ component: string;
28
+ msg: string;
29
+ level: 'warn' | 'error';
30
+ count: number;
31
+ firstSeen: string;
32
+ lastSeen: string;
33
+ }
34
+ interface DogfoodLogResult {
35
+ /** Total entries found matching filters */
36
+ totalEntries: number;
37
+ /** Unique issue groups (by component + message) */
38
+ groups: DogfoodLogGroupedEntry[];
39
+ /** Most recent entries (up to limit) */
40
+ recent: DogfoodLogEntry[];
41
+ /** Date range covered */
42
+ dateRange: {
43
+ from: string;
44
+ to: string;
45
+ };
46
+ }
47
+ declare function dogfoodLog(options?: DogfoodLogOptions): DogfoodLogResult;
48
+ //#endregion
49
+ export { DogfoodLogEntry, DogfoodLogGroupedEntry, DogfoodLogOptions, DogfoodLogResult, dogfoodLog };
@@ -0,0 +1,2 @@
1
+ import{join as e,resolve as t}from"node:path";import{readFileSync as n,readdirSync as r}from"node:fs";import{KB_PATHS as i}from"../../core/dist/index.js";function a(){return t(process.cwd(),i.logs)}function o(t={}){let{days:i=7,level:o,component:s,limit:c=50}=t,l=a(),u=new Date,d=new Date(u.getTime()-i*864e5).toISOString().slice(0,10),f=u.toISOString().slice(0,10),p;try{p=r(l).filter(e=>e.endsWith(`.jsonl`)&&e.slice(0,10)>=d).sort()}catch{return{totalEntries:0,groups:[],recent:[],dateRange:{from:d,to:f}}}let m=[];for(let t of p)try{let r=n(e(l,t),`utf-8`);for(let e of r.trim().split(`
2
+ `))if(e)try{let t=JSON.parse(e);if(o&&t.level!==o||s&&t.component!==s)continue;m.push(t)}catch{}}catch{}let h=new Map;for(let e of m){let t=`${e.component}::${e.msg}`,n=h.get(t);n?(n.count++,e.ts<n.firstSeen&&(n.firstSeen=e.ts),e.ts>n.lastSeen&&(n.lastSeen=e.ts)):h.set(t,{component:e.component,msg:e.msg,level:e.level,count:1,firstSeen:e.ts,lastSeen:e.ts})}let g=[...h.values()].sort((e,t)=>t.count-e.count),_=m.slice(-c);return{totalEntries:m.length,groups:g,recent:_,dateRange:{from:p.length>0?p[0].slice(0,10):d,to:f}}}export{o as dogfoodLog};
@@ -1,14 +1,16 @@
1
+ //#region packages/tools/src/encode.d.ts
1
2
  /**
2
3
  * kb_encode — Encoding, decoding, and hashing utilities.
3
4
  */
4
- export type EncodeOperation = 'base64_encode' | 'base64_decode' | 'url_encode' | 'url_decode' | 'sha256' | 'md5' | 'jwt_decode' | 'hex_encode' | 'hex_decode';
5
- export interface EncodeOptions {
6
- operation: EncodeOperation;
7
- input: string;
5
+ type EncodeOperation = 'base64_encode' | 'base64_decode' | 'url_encode' | 'url_decode' | 'sha256' | 'md5' | 'jwt_decode' | 'hex_encode' | 'hex_decode';
6
+ interface EncodeOptions {
7
+ operation: EncodeOperation;
8
+ input: string;
8
9
  }
9
- export interface EncodeResult {
10
- output: string;
11
- operation: string;
10
+ interface EncodeResult {
11
+ output: string;
12
+ operation: string;
12
13
  }
13
- export declare function encode(options: EncodeOptions): EncodeResult;
14
- //# sourceMappingURL=encode.d.ts.map
14
+ declare function encode(options: EncodeOptions): EncodeResult;
15
+ //#endregion
16
+ export { EncodeOperation, EncodeOptions, EncodeResult, encode };
@@ -1 +1 @@
1
- import{createHash as n}from"node:crypto";function i(a){const{operation:t,input:o}=a;let e;switch(t){case"base64_encode":e=Buffer.from(o).toString("base64");break;case"base64_decode":e=Buffer.from(o,"base64").toString("utf8");break;case"url_encode":e=encodeURIComponent(o);break;case"url_decode":e=decodeURIComponent(o);break;case"sha256":e=n("sha256").update(o).digest("hex");break;case"md5":e=n("md5").update(o).digest("hex");break;case"jwt_decode":{const r=o.split(".");if(r.length!==3)throw new Error("Invalid JWT: expected 3 dot-separated parts");const d=JSON.parse(Buffer.from(r[0],"base64url").toString()),s=JSON.parse(Buffer.from(r[1],"base64url").toString());e=JSON.stringify({header:d,payload:s},null,2);break}case"hex_encode":e=Buffer.from(o).toString("hex");break;case"hex_decode":e=Buffer.from(o,"hex").toString("utf8");break;default:throw new Error(`Unknown operation: ${t}`)}return{output:e,operation:t}}export{i as encode};
1
+ import{createHash as e}from"node:crypto";function t(t){let{operation:n,input:r}=t,i;switch(n){case`base64_encode`:i=Buffer.from(r).toString(`base64`);break;case`base64_decode`:i=Buffer.from(r,`base64`).toString(`utf8`);break;case`url_encode`:i=encodeURIComponent(r);break;case`url_decode`:i=decodeURIComponent(r);break;case`sha256`:i=e(`sha256`).update(r).digest(`hex`);break;case`md5`:i=e(`md5`).update(r).digest(`hex`);break;case`jwt_decode`:{let e=r.split(`.`);if(e.length!==3)throw Error(`Invalid JWT: expected 3 dot-separated parts`);let t,n;try{t=JSON.parse(Buffer.from(e[0],`base64url`).toString()),n=JSON.parse(Buffer.from(e[1],`base64url`).toString())}catch{throw Error(`Invalid JWT: header or payload is not valid JSON`)}i=JSON.stringify({header:t,payload:n},null,2);break}case`hex_encode`:i=Buffer.from(r).toString(`hex`);break;case`hex_decode`:i=Buffer.from(r,`hex`).toString(`utf8`);break;default:throw Error(`Unknown operation: ${n}`)}return{output:i,operation:n}}export{t as encode};
@@ -1,28 +1,30 @@
1
+ //#region packages/tools/src/env-info.d.ts
1
2
  /**
2
3
  * kb_env — System environment and runtime information.
3
4
  */
4
- export interface EnvInfoOptions {
5
- includeEnv?: boolean;
6
- filterEnv?: string;
7
- showSensitive?: boolean;
5
+ interface EnvInfoOptions {
6
+ includeEnv?: boolean;
7
+ filterEnv?: string;
8
+ showSensitive?: boolean;
8
9
  }
9
- export interface EnvInfoResult {
10
- system: {
11
- platform: string;
12
- arch: string;
13
- release: string;
14
- hostname: string;
15
- type: string;
16
- cpus: number;
17
- memoryTotalGb: number;
18
- memoryFreeGb: number;
19
- };
20
- runtime: {
21
- node: string;
22
- v8: string;
23
- };
24
- cwd: string;
25
- env?: Record<string, string>;
10
+ interface EnvInfoResult {
11
+ system: {
12
+ platform: string;
13
+ arch: string;
14
+ release: string;
15
+ hostname: string;
16
+ type: string;
17
+ cpus: number;
18
+ memoryTotalGb: number;
19
+ memoryFreeGb: number;
20
+ };
21
+ runtime: {
22
+ node: string;
23
+ v8: string;
24
+ };
25
+ cwd: string;
26
+ env?: Record<string, string>;
26
27
  }
27
- export declare function envInfo(options?: EnvInfoOptions): EnvInfoResult;
28
- //# sourceMappingURL=env-info.d.ts.map
28
+ declare function envInfo(options?: EnvInfoOptions): EnvInfoResult;
29
+ //#endregion
30
+ export { EnvInfoOptions, EnvInfoResult, envInfo };
@@ -1 +1 @@
1
- import{arch as m,cpus as l,freemem as f,hostname as p,type as v,platform as u,release as d,totalmem as g}from"node:os";const E=[/key/i,/secret/i,/token/i,/password/i,/passwd/i,/credential/i,/private/i,/certificate/i];function h(o={}){const{includeEnv:i=!1,filterEnv:t,showSensitive:c=!1}=o,s={system:{platform:u(),arch:m(),release:d(),hostname:p(),type:v(),cpus:l().length,memoryTotalGb:Math.round(g()/1024**3*10)/10,memoryFreeGb:Math.round(f()/1024**3*10)/10},runtime:{node:process.versions.node,v8:process.versions.v8},cwd:process.cwd()};if(i){const n={};for(const[e,r]of Object.entries(process.env))r&&(t&&!e.toLowerCase().includes(t.toLowerCase())||(!c&&E.some(a=>a.test(e))?n[e]="[REDACTED]":n[e]=r));s.env=n}return s}export{h as envInfo};
1
+ import{arch as e,cpus as t,freemem as n,hostname as r,platform as i,release as a,totalmem as o,type as s}from"node:os";const c=[/key/i,/secret/i,/token/i,/password/i,/passwd/i,/credential/i,/private/i,/certificate/i];function l(l={}){let{includeEnv:u=!1,filterEnv:d,showSensitive:f=!1}=l,p={system:{platform:i(),arch:e(),release:a(),hostname:r(),type:s(),cpus:t().length,memoryTotalGb:Math.round(o()/1024**3*10)/10,memoryFreeGb:Math.round(n()/1024**3*10)/10},runtime:{node:process.versions.node,v8:process.versions.v8},cwd:process.cwd()};if(u){let e={};for(let[t,n]of Object.entries(process.env))n&&(d&&!t.toLowerCase().includes(d.toLowerCase())||(!f&&c.some(e=>e.test(t))?e[t]=`[REDACTED]`:e[t]=n));p.env=e}return p}export{l as envInfo};
@@ -1,13 +1,15 @@
1
- export interface EvalOptions {
2
- code: string;
3
- lang?: 'js' | 'ts';
4
- timeout?: number;
1
+ //#region packages/tools/src/eval.d.ts
2
+ interface EvalOptions {
3
+ code: string;
4
+ lang?: 'js' | 'ts';
5
+ timeout?: number;
5
6
  }
6
- export interface EvalResult {
7
- success: boolean;
8
- output: string;
9
- error?: string;
10
- durationMs: number;
7
+ interface EvalResult {
8
+ success: boolean;
9
+ output: string;
10
+ error?: string;
11
+ durationMs: number;
11
12
  }
12
- export declare function evaluate(options: EvalOptions): EvalResult;
13
- //# sourceMappingURL=eval.d.ts.map
13
+ declare function evaluate(options: EvalOptions): EvalResult;
14
+ //#endregion
15
+ export { EvalOptions, EvalResult, evaluate };
@@ -1,3 +1,2 @@
1
- import u from"node:vm";function w(e){const{code:o,lang:c="js",timeout:p=5e3}=e,i=Date.now();try{const s=c==="ts"?g(o):o,n=[],l={console:{log:(...t)=>n.push(t.map(String).join(" ")),error:(...t)=>n.push(`[error] ${t.map(String).join(" ")}`),warn:(...t)=>n.push(`[warn] ${t.map(String).join(" ")}`)},setTimeout:void 0,setInterval:void 0,setImmediate:void 0,fetch:void 0,process:void 0,require:void 0,JSON,Math,Date,Array,Object,String,Number,Boolean,Map,Set,RegExp,Error,Promise,parseInt,parseFloat,isNaN,isFinite},d=u.createContext(l,{codeGeneration:{strings:!1,wasm:!1}}),r=u.runInContext(s,d,{timeout:p});return{success:!0,output:n.length>0?n.join(`
2
- `)+(r!==void 0?`
3
- \u2192 ${a(r)}`:""):r!==void 0?a(r):"(no output)",durationMs:Date.now()-i}}catch(s){return{success:!1,output:"",error:s.message,durationMs:Date.now()-i}}}function a(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="object")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function g(e){return e.replace(/^\s*import\s+type\s+.*?;\s*$/gm,"").replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[\s\S]*?^\s*}\s*$/gm,"").replace(/^\s*(?:export\s+)?type\s+\w+\s*=.*?;\s*$/gm,"").replace(/([,(]\s*[A-Za-z_$][\w$]*)\s*:\s*[^,)=\n]+/g,"$1").replace(/\)\s*:\s*[^={\n]+(?=\s*(?:=>|\{))/g,")").replace(/\s+as\s+[A-Za-z_$][\w$<>,[\]|&\s.]*/g,"").replace(/<(?:[A-Za-z_$][\w$]*\s*,?\s*)+>(?=\s*\()/g,"")}export{w as evaluate};
1
+ import e from"node:vm";function t(t){let{code:i,lang:a=`js`,timeout:o=5e3}=t,s=Date.now();try{let t=a===`ts`?r(i):i,c=[],l={console:{log:(...e)=>c.push(e.map(String).join(` `)),error:(...e)=>c.push(`[error] ${e.map(String).join(` `)}`),warn:(...e)=>c.push(`[warn] ${e.map(String).join(` `)}`)},setTimeout:void 0,setInterval:void 0,setImmediate:void 0,fetch:void 0,process:void 0,require:void 0,JSON,Math,Date,Array,Object,String,Number,Boolean,Map,Set,RegExp,Error,Promise,parseInt,parseFloat,isNaN,isFinite},u=e.createContext(l,{codeGeneration:{strings:!1,wasm:!1}}),d=e.runInContext(t,u,{timeout:o});return{success:!0,output:c.length>0?c.join(`
2
+ `)+(d===void 0?``:`\n→ ${n(d)}`):d===void 0?`(no output)`:n(d),durationMs:Date.now()-s}}catch(e){return{success:!1,output:``,error:e.message,durationMs:Date.now()-s}}}function n(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function r(e){return e.replace(/^\s*import\s+type\s+.*?;\s*$/gm,``).replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[\s\S]*?^\s*}\s*$/gm,``).replace(/^\s*(?:export\s+)?type\s+\w+\s*=.*?;\s*$/gm,``).replace(/([,(]\s*[A-Za-z_$][\w$]*)\s*:\s*[^,)=\n]+/g,`$1`).replace(/\)\s*:\s*[^={\n]+(?=\s*(?:=>|\{))/g,`)`).replace(/\s+as\s+[A-Za-z_$][\w$<>,[\]|&\s.]*/g,``).replace(/<(?:[A-Za-z_$][\w$]*\s*,?\s*)+>(?=\s*\()/g,``)}export{t as evaluate};
@@ -1,79 +1,81 @@
1
+ //#region packages/tools/src/evidence-map.d.ts
1
2
  /**
2
3
  * kb_evidence_map — FORGE Evidence Map CRUD + Gate evaluator.
3
4
  *
4
5
  * Structured storage, validation, and gate evaluation for FORGE Evidence Map entries.
5
6
  * Persisted in .kb-state/evidence-maps.json.
6
7
  */
7
- export type EvidenceStatus = 'V' | 'A' | 'U';
8
- export type UnknownType = 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
9
- export type GateDecision = 'YIELD' | 'HOLD' | 'HARD_BLOCK' | 'FORCED_DELIVERY';
10
- export type ForgeTier = 'floor' | 'standard' | 'critical';
11
- export interface EvidenceEntry {
12
- id: number;
13
- claim: string;
14
- status: EvidenceStatus;
15
- receipt: string;
16
- criticalPath: boolean;
17
- unknownType?: UnknownType;
8
+ type EvidenceStatus = 'V' | 'A' | 'U';
9
+ type UnknownType = 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
10
+ type GateDecision = 'YIELD' | 'HOLD' | 'HARD_BLOCK' | 'FORCED_DELIVERY';
11
+ type ForgeTier = 'floor' | 'standard' | 'critical';
12
+ interface EvidenceEntry {
13
+ id: number;
14
+ claim: string;
15
+ status: EvidenceStatus;
16
+ receipt: string;
17
+ criticalPath: boolean;
18
+ unknownType?: UnknownType;
18
19
  }
19
- export interface EvidenceMapState {
20
- taskId: string;
21
- tier: ForgeTier;
22
- entries: EvidenceEntry[];
23
- createdAt: string;
24
- updatedAt: string;
20
+ interface EvidenceMapState {
21
+ taskId: string;
22
+ tier: ForgeTier;
23
+ entries: EvidenceEntry[];
24
+ createdAt: string;
25
+ updatedAt: string;
25
26
  }
26
- export interface GateResult {
27
- decision: GateDecision;
28
- reason: string;
29
- unresolvedCritical: EvidenceEntry[];
30
- warnings: string[];
31
- stats: {
32
- total: number;
33
- verified: number;
34
- assumed: number;
35
- unresolved: number;
36
- };
37
- annotation?: string;
27
+ interface GateResult {
28
+ decision: GateDecision;
29
+ reason: string;
30
+ unresolvedCritical: EvidenceEntry[];
31
+ warnings: string[];
32
+ stats: {
33
+ total: number;
34
+ verified: number;
35
+ assumed: number;
36
+ unresolved: number;
37
+ };
38
+ annotation?: string;
38
39
  }
39
- export type EvidenceMapAction = {
40
- action: 'create';
41
- taskId: string;
42
- tier: ForgeTier;
40
+ type EvidenceMapAction = {
41
+ action: 'create';
42
+ taskId: string;
43
+ tier: ForgeTier;
43
44
  } | {
44
- action: 'add';
45
- taskId: string;
46
- claim: string;
47
- status: EvidenceStatus;
48
- receipt: string;
49
- criticalPath?: boolean;
50
- unknownType?: UnknownType;
45
+ action: 'add';
46
+ taskId: string;
47
+ claim: string;
48
+ status: EvidenceStatus;
49
+ receipt: string;
50
+ criticalPath?: boolean;
51
+ unknownType?: UnknownType;
51
52
  } | {
52
- action: 'update';
53
- taskId: string;
54
- id: number;
55
- status: EvidenceStatus;
56
- receipt: string;
53
+ action: 'update';
54
+ taskId: string;
55
+ id: number;
56
+ status: EvidenceStatus;
57
+ receipt: string;
57
58
  } | {
58
- action: 'get';
59
- taskId: string;
59
+ action: 'get';
60
+ taskId: string;
60
61
  } | {
61
- action: 'gate';
62
- taskId: string;
63
- retryCount?: number;
62
+ action: 'gate';
63
+ taskId: string;
64
+ retryCount?: number;
64
65
  } | {
65
- action: 'list';
66
+ action: 'list';
66
67
  } | {
67
- action: 'delete';
68
- taskId: string;
68
+ action: 'delete';
69
+ taskId: string;
69
70
  };
70
- export interface EvidenceMapResult {
71
- state?: EvidenceMapState;
72
- states?: EvidenceMapState[];
73
- entry?: EvidenceEntry;
74
- gate?: GateResult;
75
- deleted?: boolean;
76
- formattedMap?: string;
71
+ interface EvidenceMapResult {
72
+ state?: EvidenceMapState;
73
+ states?: EvidenceMapState[];
74
+ entry?: EvidenceEntry;
75
+ gate?: GateResult;
76
+ deleted?: boolean;
77
+ formattedMap?: string;
77
78
  }
78
- export declare function evidenceMap(action: EvidenceMapAction, cwd?: string): EvidenceMapResult;
79
- //# sourceMappingURL=evidence-map.d.ts.map
79
+ declare function evidenceMap(action: EvidenceMapAction, cwd?: string): EvidenceMapResult;
80
+ //#endregion
81
+ export { EvidenceEntry, EvidenceMapAction, EvidenceMapResult, EvidenceMapState, EvidenceStatus, ForgeTier, GateDecision, GateResult, UnknownType, evidenceMap };
@@ -1,3 +1,2 @@
1
- import{existsSync as p,mkdirSync as g,readFileSync as m,writeFileSync as v}from"node:fs";import{dirname as E,resolve as y}from"node:path";const h=".kb-state",k="evidence-maps.json";function f(t){const n=t??process.cwd();return y(n,h,k)}function o(t){const n=f(t);if(!p(n))return{};const e=m(n,"utf-8");return JSON.parse(e)}function c(t,n){const e=f(n),r=E(e);p(r)||g(r,{recursive:!0}),v(e,`${JSON.stringify(t,null,2)}
2
- `,"utf-8")}function d(t,n){const e=o(n),r=e[t];if(!r)throw new Error(`Evidence map not found: ${t}`);return{maps:e,state:r}}function S(t){return t.reduce((n,e)=>Math.max(n,e.id),0)+1}function M(t){const n=t.trim();if(!n)throw new Error("Claim is required");if(/\r?\n/.test(n))throw new Error("Claim must be a single line");return n}function u(t){return(t??"").replace(/\r?\n/g," ").replace(/\|/g,"\\|")}function s(t){const n=["| # | Claim | Status | Receipt | Critical | Type |","|---|-------|--------|---------|----------|------|"];for(const e of t.entries)n.push(`| ${e.id} | ${u(e.claim)} | ${e.status} | ${u(e.receipt)} | ${e.criticalPath?"yes":"no"} | ${u(e.unknownType)} |`);return n.join(`
3
- `)}function I(t){return{total:t.length,verified:t.filter(n=>n.status==="V").length,assumed:t.filter(n=>n.status==="A").length,unresolved:t.filter(n=>n.status==="U").length}}function w(t){const n=[];for(const e of t.entries)e.status==="V"&&e.receipt.trim()===""&&n.push("V entry without receipt"),e.status==="A"&&t.tier==="critical"&&e.unknownType==="contract"&&n.push("Assumed contract at Critical tier \u2014 should be Verified");return n}function b(t){return`FORCED DELIVERY annotation: unresolved entries remain -> ${t.filter(r=>r.status==="U").map(r=>`#${r.id} ${r.claim}`).join("; ")}`}function A(t,n=0){const e=t.entries.filter(a=>a.criticalPath&&a.status==="U"),r=w(t),i=I(t.entries);return e.find(a=>a.unknownType==="contract")?{decision:"HARD_BLOCK",reason:"Unresolved contract unknown on critical path",unresolvedCritical:e,warnings:r,stats:i}:e.length>0&&n===0?{decision:"HOLD",reason:"Unresolved critical-path unknown \u2014 retry available",unresolvedCritical:e,warnings:r,stats:i}:e.length>0&&n>=1?{decision:"FORCED_DELIVERY",reason:"Unresolved critical-path unknown after retry",unresolvedCritical:e,warnings:r,stats:i,annotation:b(t.entries)}:{decision:"YIELD",reason:"All critical-path claims satisfy gate rules",unresolvedCritical:[],warnings:r,stats:i}}function D(t,n){switch(t.action){case"create":{const e=o(n),r=new Date().toISOString(),i={taskId:t.taskId,tier:t.tier,entries:[],createdAt:r,updatedAt:r};return e[t.taskId]=i,c(e,n),{state:i,formattedMap:s(i)}}case"add":{const{maps:e,state:r}=d(t.taskId,n),i={id:S(r.entries),claim:M(t.claim),status:t.status,receipt:t.receipt,criticalPath:t.criticalPath??!1,unknownType:t.unknownType};return r.entries.push(i),r.updatedAt=new Date().toISOString(),e[t.taskId]=r,c(e,n),{state:r,entry:i,formattedMap:s(r)}}case"update":{const{maps:e,state:r}=d(t.taskId,n),i=r.entries.find(l=>l.id===t.id);if(!i)throw new Error(`Evidence entry not found: ${t.id}`);return i.status=t.status,i.receipt=t.receipt,r.updatedAt=new Date().toISOString(),e[t.taskId]=r,c(e,n),{state:r,entry:i,formattedMap:s(r)}}case"get":{const{state:e}=d(t.taskId,n);return{state:e,formattedMap:s(e)}}case"gate":{const{state:e}=d(t.taskId,n);return{state:e,gate:A(e,t.retryCount??0),formattedMap:s(e)}}case"list":return{states:Object.values(o(n)).sort((r,i)=>r.createdAt.localeCompare(i.createdAt))};case"delete":{const e=o(n);return t.taskId in e?(delete e[t.taskId],c(e,n),{deleted:!0}):{deleted:!1}}}}export{D as evidenceMap};
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,`evidence-maps.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){let n=l(t),r=n[e];if(!r)throw Error(`Evidence map not found: ${e}`);return{maps:n,state:r}}function f(e){return e.reduce((e,t)=>Math.max(e,t.id),0)+1}function p(e){let t=e.trim();if(!t)throw Error(`Claim is required`);if(/\r?\n/.test(t))throw Error(`Claim must be a single line`);return t}function m(e){return(e??``).replace(/\r?\n/g,` `).replace(/\|/g,`\\|`)}function h(e){let t=[`| # | Claim | Status | Receipt | Critical | Type |`,`|---|-------|--------|---------|----------|------|`];for(let n of e.entries)t.push(`| ${n.id} | ${m(n.claim)} | ${n.status} | ${m(n.receipt)} | ${n.criticalPath?`yes`:`no`} | ${m(n.unknownType)} |`);return t.join(`
2
+ `)}function g(e){return{total:e.length,verified:e.filter(e=>e.status===`V`).length,assumed:e.filter(e=>e.status===`A`).length,unresolved:e.filter(e=>e.status===`U`).length}}function _(e){let t=[];for(let n of e.entries)n.status===`V`&&n.receipt.trim()===``&&t.push(`V entry without receipt`),n.status===`A`&&e.tier===`critical`&&n.unknownType===`contract`&&t.push(`Assumed contract at Critical tier — should be Verified`);return t}function v(e){return`FORCED DELIVERY annotation: unresolved entries remain -> ${e.filter(e=>e.status===`U`).map(e=>`#${e.id} ${e.claim}`).join(`; `)}`}function y(e,t=0){let n=e.entries.filter(e=>e.criticalPath&&e.status===`U`),r=_(e),i=g(e.entries);return n.find(e=>e.unknownType===`contract`)?{decision:`HARD_BLOCK`,reason:`Unresolved contract unknown on critical path`,unresolvedCritical:n,warnings:r,stats:i}:n.length>0&&t===0?{decision:`HOLD`,reason:`Unresolved critical-path unknown retry available`,unresolvedCritical:n,warnings:r,stats:i}:n.length>0&&t>=1?{decision:`FORCED_DELIVERY`,reason:`Unresolved critical-path unknown after retry`,unresolvedCritical:n,warnings:r,stats:i,annotation:v(e.entries)}:{decision:`YIELD`,reason:`All critical-path claims satisfy gate rules`,unresolvedCritical:[],warnings:r,stats:i}}function b(e,t){switch(e.action){case`create`:{let n=l(t),r=new Date().toISOString(),i={taskId:e.taskId,tier:e.tier,entries:[],createdAt:r,updatedAt:r};return n[e.taskId]=i,u(n,t),{state:i,formattedMap:h(i)}}case`add`:{let{maps:n,state:r}=d(e.taskId,t),i={id:f(r.entries),claim:p(e.claim),status:e.status,receipt:e.receipt,criticalPath:e.criticalPath??!1,unknownType:e.unknownType};return r.entries.push(i),r.updatedAt=new Date().toISOString(),n[e.taskId]=r,u(n,t),{state:r,entry:i,formattedMap:h(r)}}case`update`:{let{maps:n,state:r}=d(e.taskId,t),i=r.entries.find(t=>t.id===e.id);if(!i)throw Error(`Evidence entry not found: ${e.id}`);return i.status=e.status,i.receipt=e.receipt,r.updatedAt=new Date().toISOString(),n[e.taskId]=r,u(n,t),{state:r,entry:i,formattedMap:h(r)}}case`get`:{let{state:n}=d(e.taskId,t);return{state:n,formattedMap:h(n)}}case`gate`:{let{state:n}=d(e.taskId,t);return{state:n,gate:y(n,e.retryCount??0),formattedMap:h(n)}}case`list`:return{states:Object.values(l(t)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))};case`delete`:{let n=l(t);return e.taskId in n?(delete n[e.taskId],u(n,t),{deleted:!0}):{deleted:!1}}}}export{b as evidenceMap};
@@ -0,0 +1,41 @@
1
+ //#region packages/tools/src/file-cache.d.ts
2
+ interface FileCacheEntry {
3
+ /** Full file content */
4
+ content: string;
5
+ /** SHA-256 hash of content */
6
+ hash: string;
7
+ /** Line count */
8
+ lines: number;
9
+ /** Estimated token count (~chars/4) */
10
+ estimatedTokens: number;
11
+ /** How many times this file has been requested */
12
+ hitCount: number;
13
+ /** Whether content changed since last read (false on cache hit) */
14
+ changed: boolean;
15
+ }
16
+ interface FileCacheStats {
17
+ totalReads: number;
18
+ cacheHits: number;
19
+ filesTracked: number;
20
+ }
21
+ declare class FileCache {
22
+ private cache;
23
+ private totalReads;
24
+ private cacheHits;
25
+ private static readonly MAX_ENTRIES;
26
+ /**
27
+ * Get file content with deduplication.
28
+ * First call: reads from disk, hashes, caches.
29
+ * Subsequent calls: checks mtime → if unchanged, cache hit (skip read).
30
+ * If mtime changed: re-reads, re-hashes, checks if content actually changed.
31
+ */
32
+ get(filePath: string): Promise<FileCacheEntry>;
33
+ /** Remove a single file from cache. Returns true if it was cached. */
34
+ invalidate(filePath: string): boolean;
35
+ /** Clear all cached files. Returns how many were cleared. */
36
+ clear(): number;
37
+ /** Get cache statistics. */
38
+ stats(): FileCacheStats;
39
+ }
40
+ //#endregion
41
+ export { FileCache, FileCacheEntry, FileCacheStats };
@@ -0,0 +1,3 @@
1
+ import{estimateTokens as e}from"./text-utils.js";import{readFile as t,stat as n}from"node:fs/promises";import{resolve as r}from"node:path";import{createHash as i}from"node:crypto";var a=class i{cache=new Map;totalReads=0;cacheHits=0;static MAX_ENTRIES=500;async get(a){let s=r(a);this.totalReads++;let c=(await n(s)).mtimeMs,l=this.cache.get(s);if(l){if(l.mtimeMs===c)return this.cacheHits++,l.hitCount++,{content:l.content,hash:l.hash,lines:l.lines,estimatedTokens:l.estimatedTokens,hitCount:l.hitCount,changed:!1};let n=await t(s,`utf-8`),r=o(n);if(r===l.hash)return this.cacheHits++,l.hitCount++,l.mtimeMs=c,{content:l.content,hash:l.hash,lines:l.lines,estimatedTokens:l.estimatedTokens,hitCount:l.hitCount,changed:!1};let i=n.split(`
2
+ `).length,a=e(n);return l.content=n,l.hash=r,l.lines=i,l.estimatedTokens=a,l.hitCount++,l.mtimeMs=c,{content:n,hash:r,lines:i,estimatedTokens:a,hitCount:l.hitCount,changed:!0}}let u=await t(s,`utf-8`),d=o(u),f=u.split(`
3
+ `).length,p=e(u);if(this.cache.set(s,{content:u,hash:d,lines:f,estimatedTokens:p,hitCount:1,mtimeMs:c}),this.cache.size>i.MAX_ENTRIES){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}return{content:u,hash:d,lines:f,estimatedTokens:p,hitCount:1,changed:!0}}invalidate(e){return this.cache.delete(r(e))}clear(){let e=this.cache.size;return this.cache.clear(),e}stats(){return{totalReads:this.totalReads,cacheHits:this.cacheHits,filesTracked:this.cache.size}}};function o(e){return i(`sha256`).update(e).digest(`hex`)}export{a as FileCache};
@@ -1,32 +1,52 @@
1
- export interface FileSummaryOptions {
2
- path: string;
3
- previewLines?: number;
1
+ //#region packages/tools/src/file-summary.d.ts
2
+ interface FileSummaryOptions {
3
+ path: string;
4
+ /** Pre-loaded content — skip readFile when provided (e.g., from FileCache) */
5
+ content?: string;
6
+ previewLines?: number;
4
7
  }
5
- export interface FileSummaryResult {
6
- path: string;
7
- lines: number;
8
- language: string;
9
- imports: string[];
10
- exports: string[];
11
- functions: Array<{
12
- name: string;
13
- line: number;
14
- exported: boolean;
15
- }>;
16
- classes: Array<{
17
- name: string;
18
- line: number;
19
- exported: boolean;
20
- }>;
21
- interfaces: Array<{
22
- name: string;
23
- line: number;
24
- }>;
25
- types: Array<{
26
- name: string;
27
- line: number;
28
- }>;
29
- estimatedTokens: number;
8
+ interface FileSummaryResult {
9
+ path: string;
10
+ lines: number;
11
+ language: string;
12
+ imports: string[];
13
+ exports: string[];
14
+ functions: Array<{
15
+ name: string;
16
+ line: number;
17
+ exported: boolean;
18
+ signature?: string;
19
+ }>;
20
+ classes: Array<{
21
+ name: string;
22
+ line: number;
23
+ exported: boolean;
24
+ signature?: string;
25
+ }>;
26
+ interfaces: Array<{
27
+ name: string;
28
+ line: number;
29
+ exported: boolean;
30
+ }>;
31
+ types: Array<{
32
+ name: string;
33
+ line: number;
34
+ exported: boolean;
35
+ }>;
36
+ /** Import details with external/internal classification (AST-powered) */
37
+ importDetails?: Array<{
38
+ source: string;
39
+ specifiers: string[];
40
+ isExternal: boolean;
41
+ }>;
42
+ /** Intra-file call edges showing which functions call which (AST-powered) */
43
+ callEdges?: Array<{
44
+ caller: string;
45
+ callee: string;
46
+ line: number;
47
+ }>;
48
+ estimatedTokens: number;
30
49
  }
31
- export declare function fileSummary(options: FileSummaryOptions): Promise<FileSummaryResult>;
32
- //# sourceMappingURL=file-summary.d.ts.map
50
+ declare function fileSummary(options: FileSummaryOptions): Promise<FileSummaryResult>;
51
+ //#endregion
52
+ export { FileSummaryOptions, FileSummaryResult, fileSummary };
@@ -1,2 +1,2 @@
1
- import{readFile as S}from"node:fs/promises";async function L(i){const{path:r,previewLines:R=3}=i,u=await S(r,"utf-8"),m=u.split(`
2
- `),j=r.split(".").pop()??"",h=[],e=[],o=[],f=[],y=[],g=[];for(let a=0;a<m.length;a+=1){const t=m[a],n=a+1;if(/^import\s+.+/.test(t)){h.push(t.trim());continue}const l=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(l){o.push({name:l[1],line:n,exported:!0}),e.push(l[1]);continue}const x=t.match(/^(?:async\s+)?function\s+(\w+)/);if(x){o.push({name:x[1],line:n,exported:!1});continue}const c=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(c){const s=!!c[1];o.push({name:c[2],line:n,exported:s}),s&&e.push(c[2]);continue}const b=t.match(/^export\s+const\s+(\w+)\s*=/);if(b){e.push(b[1]);continue}const p=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(p){const s=!!p[1];f.push({name:p[2],line:n,exported:s}),s&&e.push(p[2]);continue}const d=t.match(/^(?:export\s+)?interface\s+(\w+)/);if(d){y.push({name:d[1],line:n});continue}const w=t.match(/^(?:export\s+)?type\s+(\w+)/);if(w){g.push({name:w[1],line:n});continue}const F=t.match(/^export\s+\{(.+)\}/);if(F){const s=F[1].split(",").map(M=>M.trim().split(/\s+as\s+/).pop()?.trim()??"").filter(Boolean);e.push(...s)}}return{path:r,lines:m.length,language:v(j),imports:h,exports:e,functions:o,classes:f,interfaces:y,types:g,estimatedTokens:Math.ceil(u.length/4)}}function v(i){return{ts:"typescript",tsx:"typescript-jsx",js:"javascript",jsx:"javascript-jsx",py:"python",rs:"rust",go:"go",java:"java",rb:"ruby",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",css:"css",html:"html",sh:"shell",bash:"shell"}[i]??i}export{L as fileSummary};
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,extractImports as a,extractSymbols as o}from"../../chunker/dist/index.js";async function s(i){let{path:a,previewLines:o=3}=i,s=i.content??await e(a,`utf-8`),u=s.split(`
2
+ `),d=a.split(`.`).pop()??``,f=t(a);return r.get()&&n.has(f)?c(a,s,u,d,f):l(a,s,u,d)}async function c(e,t,n,r,s){let[c,l,d]=await Promise.all([o(t,s,e),a(t,s,e),i(t,s,e).catch(()=>[])]),f=l.map(e=>`import ${e.specifiers.length>0?`{ ${e.specifiers.join(`, `)} }`:`*`} from '${e.source}'`),p=[],m=[],h=[],g=[],_=[];for(let e of c)switch(e.exported&&p.push(e.name),e.kind){case`function`:case`method`:m.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`class`:h.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`interface`:g.push({name:e.name,line:e.line,exported:e.exported});break;case`type`:_.push({name:e.name,line:e.line,exported:e.exported});break}let v=l.map(e=>({source:e.source,specifiers:e.specifiers,isExternal:e.isExternal})),y=d.map(e=>({caller:e.callerName,callee:e.calleeName,line:e.line}));return{path:e,lines:n.length,language:u(r),imports:f,exports:p,functions:m,classes:h,interfaces:g,types:_,importDetails:v,callEdges:y.length>0?y:void 0,estimatedTokens:Math.ceil(t.length/4)}}function l(e,t,n,r){let i=[],a=[],o=[],s=[],c=[],l=[];for(let e=0;e<n.length;e+=1){let t=n[e],r=e+1;if(/^import\s+.+/.test(t)){i.push(t.trim());continue}let u=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(u){o.push({name:u[1],line:r,exported:!0}),a.push(u[1]);continue}let d=t.match(/^(?:async\s+)?function\s+(\w+)/);if(d){o.push({name:d[1],line:r,exported:!1});continue}let f=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(f){let e=!!f[1];o.push({name:f[2],line:r,exported:e}),e&&a.push(f[2]);continue}let p=t.match(/^export\s+const\s+(\w+)\s*=/);if(p){a.push(p[1]);continue}let m=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(m){let e=!!m[1];s.push({name:m[2],line:r,exported:e}),e&&a.push(m[2]);continue}let h=t.match(/^(export\s+)?interface\s+(\w+)/);if(h){let e=!!h[1];c.push({name:h[2],line:r,exported:e}),e&&a.push(h[2]);continue}let g=t.match(/^(export\s+)?type\s+(\w+)/);if(g){let e=!!g[1];l.push({name:g[2],line:r,exported:e}),e&&a.push(g[2]);continue}let _=t.match(/^export\s+\{(.+)\}/);if(_){let e=_[1].split(`,`).map(e=>e.trim().split(/\s+as\s+/).pop()?.trim()??``).filter(Boolean);a.push(...e)}}return{path:e,lines:n.length,language:u(r),imports:i,exports:a,functions:o,classes:s,interfaces:c,types:l,estimatedTokens:Math.ceil(t.length/4)}}function u(e){return{ts:`typescript`,tsx:`typescript-jsx`,js:`javascript`,jsx:`javascript-jsx`,py:`python`,rs:`rust`,go:`go`,java:`java`,rb:`ruby`,md:`markdown`,json:`json`,yaml:`yaml`,yml:`yaml`,css:`css`,html:`html`,sh:`shell`,bash:`shell`}[e]??e}export{s as fileSummary};
@@ -1,4 +1,6 @@
1
- export declare const DEFAULT_TOOL_EXTENSIONS: string[];
2
- export declare function matchesGlobPattern(path: string, pattern: string): boolean;
3
- export declare function walkFiles(rootPath: string, extensions: string[], exclude: string[]): Promise<string[]>;
4
- //# sourceMappingURL=file-walk.d.ts.map
1
+ //#region packages/tools/src/file-walk.d.ts
2
+ declare const DEFAULT_TOOL_EXTENSIONS: string[];
3
+ declare function matchesGlobPattern(path: string, pattern: string): boolean;
4
+ declare function walkFiles(rootPath: string, extensions: string[], exclude: string[]): Promise<string[]>;
5
+ //#endregion
6
+ export { DEFAULT_TOOL_EXTENSIONS, matchesGlobPattern, walkFiles };
@@ -1 +1 @@
1
- import{readdir as p,stat as x}from"node:fs/promises";import{extname as E,join as w,relative as L}from"node:path";const D=[".ts",".tsx",".js",".jsx"],b=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out",".kb-state"]);function g(e){return e.replace(/\\/g,"/")}function S(e){return e.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function f(e,i){const n=g(e),t=g(i).trim();if(!t)return!1;const s=S(t).replace(/\*\*/g,"::DOUBLE_STAR::").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/::DOUBLE_STAR::/g,".*");return new RegExp(`^${s}$`).test(n)}function m(e,i,n){return i.some(t=>f(e,t)?!0:n?f(`${e}/`,t):!1)}async function P(e,i,n){const t=[],s=i.map(r=>r.toLowerCase());async function a(r){const c=await p(r);for(const l of c){if(b.has(l))continue;const o=w(r,l),d=await x(o),u=g(L(e,o));if(d.isDirectory()){m(u,n,!0)||await a(o);continue}m(u,n,!1)||s.includes(E(l).toLowerCase())&&t.push(o)}}return await a(e),t.sort((r,c)=>r.localeCompare(c)),t}export{D as DEFAULT_TOOL_EXTENSIONS,f as matchesGlobPattern,P as walkFiles};
1
+ import{readdir as e,stat as t}from"node:fs/promises";import{extname as n,join as r,relative as i}from"node:path";import{KB_PATHS as a}from"../../core/dist/index.js";const o=[`.ts`,`.tsx`,`.js`,`.jsx`],s=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,a.state]);function c(e){return e.replace(/\\/g,`/`)}function l(e){return e.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}function u(e,t){let n=c(e),r=c(t).trim();if(!r)return!1;let i=l(r).replace(/\*\*/g,`::DOUBLE_STAR::`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(/::DOUBLE_STAR::/g,`.*`);return RegExp(`^${i}$`).test(n)}function d(e,t,n){return t.some(t=>u(e,t)?!0:n?u(`${e}/`,t):!1)}async function f(a,o,l){let u=[],f=o.map(e=>e.toLowerCase());async function p(o){let m=await e(o);for(let e of m){if(s.has(e))continue;let m=r(o,e),h=await t(m),g=c(i(a,m));if(h.isDirectory()){d(g,l,!0)||await p(m);continue}d(g,l,!1)||f.includes(n(e).toLowerCase())&&u.push(m)}}return await p(a),u.sort((e,t)=>e.localeCompare(t)),u}export{o as DEFAULT_TOOL_EXTENSIONS,u as matchesGlobPattern,f as walkFiles};
@@ -1,25 +1,29 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IKnowledgeStore } from '@kb/store';
3
- export interface FindExamplesOptions {
4
- /** Symbol or pattern to find examples of */
5
- query: string;
6
- /** Max examples to return (default: 5) */
7
- limit?: number;
8
- /** Filter by content type */
9
- contentType?: string;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+ import { ContentType } from "@kb/core";
4
+
5
+ //#region packages/tools/src/find-examples.d.ts
6
+ interface FindExamplesOptions {
7
+ /** Symbol or pattern to find examples of */
8
+ query: string;
9
+ /** Max examples to return (default: 5) */
10
+ limit?: number;
11
+ /** Filter by content type */
12
+ contentType?: ContentType;
10
13
  }
11
- export interface Example {
12
- path: string;
13
- startLine: number;
14
- endLine: number;
15
- content: string;
16
- relevance: number;
17
- context: string;
14
+ interface Example {
15
+ path: string;
16
+ startLine: number;
17
+ endLine: number;
18
+ content: string;
19
+ relevance: number;
20
+ context: string;
18
21
  }
19
- export interface FindExamplesResult {
20
- query: string;
21
- examples: Example[];
22
- totalFound: number;
22
+ interface FindExamplesResult {
23
+ query: string;
24
+ examples: Example[];
25
+ totalFound: number;
23
26
  }
24
- export declare function findExamples(embedder: IEmbedder, store: IKnowledgeStore, options: FindExamplesOptions): Promise<FindExamplesResult>;
25
- //# sourceMappingURL=find-examples.d.ts.map
27
+ declare function findExamples(embedder: IEmbedder, store: IKnowledgeStore, options: FindExamplesOptions): Promise<FindExamplesResult>;
28
+ //#endregion
29
+ export { Example, FindExamplesOptions, FindExamplesResult, findExamples };
@@ -1,3 +1,3 @@
1
- async function $(s,l,x){const{query:i,limit:r=5,contentType:u}=x,g=`usage example of ${i}`,f=await s.embed(g),h=await l.search(f,{limit:r*3,contentType:u}),c=new RegExp(`\\b${I(i)}\\b`,"i"),a=h.filter(e=>c.test(e.record.content)),E=a.map(e=>{const t=e.record.content,m=/export\s+(?:async\s+)?(?:function|class|const|interface|type)\s/.test(t),y=/^\s*import\s/m.test(t),p=/(?:^|[\\/])(test|tests|__tests__|spec)(?:[\\/]|$)/i.test(e.record.sourcePath)||/\.(test|spec)\.[jt]sx?$/i.test(e.record.sourcePath);let n=0;m||(n+=.1),y||(n+=.05),p&&(n+=.05);const o=t.split(`
2
- `),d=o.findIndex(F=>c.test(F)),b=Math.max(0,d-2),L=Math.min(o.length,d+5),v=o.slice(b,L).join(`
3
- `);return{path:e.record.sourcePath,startLine:e.record.startLine,endLine:e.record.endLine,content:v||t.slice(0,300),relevance:Math.min(1,e.score+n),context:p?"test":m?"definition":"usage"}}).sort((e,t)=>t.relevance-e.relevance).slice(0,r);return{query:i,examples:E,totalFound:a.length}}function I(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{$ as findExamples};
1
+ async function e(e,n,r){let{query:i,limit:a=5,contentType:o}=r,s=`usage example of ${i}`,c=await e.embed(s),l=await n.search(c,{limit:a*3,contentType:o}),u=RegExp(`\\b${t(i)}\\b`,`i`),d=l.filter(e=>u.test(e.record.content));return{query:i,examples:d.map(e=>{let t=e.record.content,n=/export\s+(?:async\s+)?(?:function|class|const|interface|type)\s/.test(t),r=/^\s*import\s/m.test(t),i=/(?:^|[\\/])(test|tests|__tests__|spec)(?:[\\/]|$)/i.test(e.record.sourcePath)||/\.(test|spec)\.[jt]sx?$/i.test(e.record.sourcePath),a=0;n||(a+=.1),r||(a+=.05),i&&(a+=.05);let o=t.split(`
2
+ `),s=o.findIndex(e=>u.test(e)),c=Math.max(0,s-2),l=Math.min(o.length,s+5),d=o.slice(c,l).join(`
3
+ `);return{path:e.record.sourcePath,startLine:e.record.startLine,endLine:e.record.endLine,content:d||t.slice(0,300),relevance:Math.min(1,e.score+a),context:i?`test`:n?`definition`:`usage`}}).sort((e,t)=>t.relevance-e.relevance).slice(0,a),totalFound:d.length}}function t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}export{e as findExamples};