@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 +1 @@
1
- import{spawn as d}from"node:child_process";const t=new Map,p=200;function f(s,r,n=[],c){if(t.has(s))throw new Error(`Process "${s}" is already running. Stop it first.`);const o=d(r,n,{cwd:c?.cwd??process.cwd(),shell:!0,stdio:["ignore","pipe","pipe"]}),e={id:s,command:r,args:n,pid:o.pid??void 0,status:"running",startedAt:new Date().toISOString(),logs:[]},g=i=>{const a=i.toString().split(/\r?\n/).filter(Boolean);e.logs.push(...a),e.logs.length>p&&(e.logs=e.logs.slice(-p))};return o.stdout?.on("data",g),o.stderr?.on("data",g),o.on("exit",i=>{e.status=i===0?"stopped":"error",e.exitCode=i??void 0}),o.on("error",i=>{e.status="error",e.logs.push(`[error] ${i.message}`)}),t.set(s,{proc:o,info:e}),e}function l(s){const r=t.get(s);if(r)return r.proc.kill("SIGTERM"),r.info.status="stopped",t.delete(s),r.info}function M(s){return t.get(s)?.info}function P(){return[...t.values()].map(s=>s.info)}function w(s,r){const n=t.get(s);return n?r?n.info.logs.slice(-r):n.info.logs:[]}export{P as processList,w as processLogs,f as processStart,M as processStatus,l as processStop};
1
+ import{spawn as e}from"node:child_process";const t=new Map;function n(n,r,i=[],a){if(t.has(n))throw Error(`Process "${n}" is already running. Stop it first.`);if(t.size>=20)throw Error(`Too many managed processes (max 20). Stop some first.`);let o=/[;|&`$(){}[\]!<>\\]/,s=[r,...i].join(` `);if(o.test(s))throw Error(`Command contains disallowed shell metacharacters`);let c=e(s,{cwd:a?.cwd??process.cwd(),shell:!0,stdio:[`ignore`,`pipe`,`pipe`]}),l={id:n,command:r,args:i,pid:c.pid??void 0,status:`running`,startedAt:new Date().toISOString(),logs:[]},u=e=>{let t=e.toString().split(/\r?\n/).filter(Boolean);l.logs.push(...t),l.logs.length>200&&(l.logs=l.logs.slice(-200))};return c.stdout?.on(`data`,u),c.stderr?.on(`data`,u),c.on(`exit`,e=>{l.status=e===0?`stopped`:`error`,l.exitCode=e??void 0,setTimeout(()=>t.delete(n),3e4)}),c.on(`error`,e=>{l.status=`error`,l.logs.push(`[error] ${e.message}`)}),t.set(n,{proc:c,info:l}),l}function r(e){let n=t.get(e);if(!n)return;n.proc.kill(`SIGTERM`);let r=setTimeout(()=>{try{n.proc.kill(`SIGKILL`)}catch{}},5e3);return n.proc.once(`exit`,()=>clearTimeout(r)),n.info.status=`stopped`,t.delete(e),n.info}function i(e){return t.get(e)?.info}function a(){return[...t.values()].map(e=>e.info)}function o(e,n){let r=t.get(e);return r?n?r.info.logs.slice(-n):r.info.logs:[]}export{a as processList,o as processLogs,n as processStart,i as processStatus,r as processStop};
@@ -1,38 +1,40 @@
1
- export interface QueueItem {
2
- id: string;
3
- title: string;
4
- status: 'pending' | 'in-progress' | 'done' | 'failed';
5
- data?: unknown;
6
- createdAt: string;
7
- updatedAt: string;
8
- error?: string;
1
+ //#region packages/tools/src/queue.d.ts
2
+ interface QueueItem {
3
+ id: string;
4
+ title: string;
5
+ status: 'pending' | 'in-progress' | 'done' | 'failed';
6
+ data?: unknown;
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ error?: string;
9
10
  }
10
- export interface QueueState {
11
- name: string;
12
- items: QueueItem[];
11
+ interface QueueState {
12
+ name: string;
13
+ items: QueueItem[];
13
14
  }
14
15
  /** Create a new named queue. */
15
- export declare function queueCreate(name: string, cwd?: string): QueueState;
16
+ declare function queueCreate(name: string, cwd?: string): QueueState;
16
17
  /** Push an item onto a queue. Creates the queue if it doesn't exist. */
17
- export declare function queuePush(name: string, title: string, data?: unknown, cwd?: string): QueueItem;
18
+ declare function queuePush(name: string, title: string, data?: unknown, cwd?: string): QueueItem;
18
19
  /** Take the next pending item from a queue and mark it in-progress. */
19
- export declare function queueNext(name: string, cwd?: string): QueueItem | null;
20
+ declare function queueNext(name: string, cwd?: string): QueueItem | null;
20
21
  /** Mark a queue item as done. */
21
- export declare function queueDone(name: string, id: string, cwd?: string): QueueItem;
22
+ declare function queueDone(name: string, id: string, cwd?: string): QueueItem;
22
23
  /** Mark a queue item as failed with an error message. */
23
- export declare function queueFail(name: string, id: string, error: string, cwd?: string): QueueItem;
24
+ declare function queueFail(name: string, id: string, error: string, cwd?: string): QueueItem;
24
25
  /** Get the current state of a queue. */
25
- export declare function queueGet(name: string, cwd?: string): QueueState | null;
26
+ declare function queueGet(name: string, cwd?: string): QueueState | null;
26
27
  /** List all queues with their item counts. */
27
- export declare function queueList(cwd?: string): Array<{
28
- name: string;
29
- pending: number;
30
- done: number;
31
- failed: number;
32
- total: number;
28
+ declare function queueList(cwd?: string): Array<{
29
+ name: string;
30
+ pending: number;
31
+ done: number;
32
+ failed: number;
33
+ total: number;
33
34
  }>;
34
35
  /** Clear completed items from a queue. */
35
- export declare function queueClear(name: string, cwd?: string): number;
36
+ declare function queueClear(name: string, cwd?: string): number;
36
37
  /** Delete a queue entirely. */
37
- export declare function queueDelete(name: string, cwd?: string): boolean;
38
- //# sourceMappingURL=queue.d.ts.map
38
+ declare function queueDelete(name: string, cwd?: string): boolean;
39
+ //#endregion
40
+ export { QueueItem, QueueState, queueClear, queueCreate, queueDelete, queueDone, queueFail, queueGet, queueList, queueNext, queuePush };
@@ -1,2 +1 @@
1
- import{existsSync as a,mkdirSync as c,readFileSync as l,writeFileSync as p}from"node:fs";import{dirname as m,resolve as q}from"node:path";const Q=".kb-state",S="queue.json";function d(e){return q(e??process.cwd(),Q,S)}function o(e){const r=d(e);return a(r)?JSON.parse(l(r,"utf-8")):{}}function g(e,r){const t=d(r),n=m(t);a(n)||c(n,{recursive:!0}),p(t,`${JSON.stringify(e,null,2)}
2
- `,"utf-8")}function h(){return`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`}function I(e,r){const t=o(r);if(t[e])throw new Error(`Queue "${e}" already exists`);const n={name:e,items:[]};return t[e]=n,g(t,r),n}function E(e,r,t,n){const u=o(n);u[e]||(u[e]={name:e,items:[]});const s=new Date().toISOString(),i={id:h(),title:r,status:"pending",data:t,createdAt:s,updatedAt:s};return u[e].items.push(i),g(u,n),i}function $(e,r){const t=o(r),n=t[e];if(!n)throw new Error(`Queue "${e}" does not exist`);const u=n.items.find(s=>s.status==="pending");return u?(u.status="in-progress",u.updatedAt=new Date().toISOString(),g(t,r),u):null}function b(e,r,t){const n=o(t),u=n[e];if(!u)throw new Error(`Queue "${e}" does not exist`);const s=u.items.find(i=>i.id===r);if(!s)throw new Error(`Item "${r}" not found in queue "${e}"`);return s.status="done",s.updatedAt=new Date().toISOString(),g(n,t),s}function A(e,r,t,n){const u=o(n),s=u[e];if(!s)throw new Error(`Queue "${e}" does not exist`);const i=s.items.find(f=>f.id===r);if(!i)throw new Error(`Item "${r}" not found in queue "${e}"`);return i.status="failed",i.error=t,i.updatedAt=new Date().toISOString(),g(u,n),i}function D(e,r){return o(r)[e]??null}function y(e){const r=o(e);return Object.values(r).map(t=>({name:t.name,pending:t.items.filter(n=>n.status==="pending").length,done:t.items.filter(n=>n.status==="done").length,failed:t.items.filter(n=>n.status==="failed").length,total:t.items.length}))}function O(e,r){const t=o(r),n=t[e];if(!n)throw new Error(`Queue "${e}" does not exist`);const u=n.items.length;n.items=n.items.filter(i=>i.status==="pending"||i.status==="in-progress");const s=u-n.items.length;return g(t,r),s}function v(e,r){const t=o(r);return t[e]?(delete t[e],g(t,r),!0):!1}export{O as queueClear,I as queueCreate,v as queueDelete,b as queueDone,A as queueFail,D as queueGet,y as queueList,$ as queueNext,E as queuePush};
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,`queue.json`)}function l(e){let t=c(e);if(!n(t))return{};try{return JSON.parse(i(t,`utf-8`))}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(){return`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`}function f(e,t){let n=l(t);if(n[e])throw Error(`Queue "${e}" already exists`);let r={name:e,items:[]};return n[e]=r,u(n,t),r}function p(e,t,n,r){let i=l(r);i[e]||(i[e]={name:e,items:[]});let a=new Date().toISOString(),o={id:d(),title:t,status:`pending`,data:n,createdAt:a,updatedAt:a};return i[e].items.push(o),u(i,r),o}function m(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.find(e=>e.status===`pending`);return i?(i.status=`in-progress`,i.updatedAt=new Date().toISOString(),u(n,t),i):null}function h(e,t,n){let r=l(n),i=r[e];if(!i)throw Error(`Queue "${e}" does not exist`);let a=i.items.find(e=>e.id===t);if(!a)throw Error(`Item "${t}" not found in queue "${e}"`);return a.status=`done`,a.updatedAt=new Date().toISOString(),u(r,n),a}function g(e,t,n,r){let i=l(r),a=i[e];if(!a)throw Error(`Queue "${e}" does not exist`);let o=a.items.find(e=>e.id===t);if(!o)throw Error(`Item "${t}" not found in queue "${e}"`);return o.status=`failed`,o.error=n,o.updatedAt=new Date().toISOString(),u(i,r),o}function _(e,t){return l(t)[e]??null}function v(e){let t=l(e);return Object.values(t).map(e=>({name:e.name,pending:e.items.filter(e=>e.status===`pending`).length,done:e.items.filter(e=>e.status===`done`).length,failed:e.items.filter(e=>e.status===`failed`).length,total:e.items.length}))}function y(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Queue "${e}" does not exist`);let i=r.items.length;r.items=r.items.filter(e=>e.status===`pending`||e.status===`in-progress`);let a=i-r.items.length;return u(n,t),a}function b(e,t){let n=l(t);return n[e]?(delete n[e],u(n,t),!0):!1}export{y as queueClear,f as queueCreate,b as queueDelete,h as queueDone,g as queueFail,_ as queueGet,v as queueList,m as queueNext,p as queuePush};
@@ -1,31 +1,33 @@
1
+ //#region packages/tools/src/regex-test.d.ts
1
2
  /**
2
3
  * kb_regex_test — Test regex patterns against sample strings.
3
4
  */
4
- export interface RegexTestOptions {
5
- pattern: string;
6
- flags?: string;
7
- testStrings: string[];
8
- mode?: 'match' | 'replace' | 'split';
9
- replacement?: string;
5
+ interface RegexTestOptions {
6
+ pattern: string;
7
+ flags?: string;
8
+ testStrings: string[];
9
+ mode?: 'match' | 'replace' | 'split';
10
+ replacement?: string;
10
11
  }
11
- export interface RegexMatchInfo {
12
- full: string;
13
- groups: (string | undefined)[];
14
- index: number;
12
+ interface RegexMatchInfo {
13
+ full: string;
14
+ groups: (string | undefined)[];
15
+ index: number;
15
16
  }
16
- export interface RegexTestStringResult {
17
- input: string;
18
- matched: boolean;
19
- matches?: RegexMatchInfo[];
20
- replaced?: string;
21
- split?: string[];
17
+ interface RegexTestStringResult {
18
+ input: string;
19
+ matched: boolean;
20
+ matches?: RegexMatchInfo[];
21
+ replaced?: string;
22
+ split?: string[];
22
23
  }
23
- export interface RegexTestResult {
24
- pattern: string;
25
- flags: string;
26
- results: RegexTestStringResult[];
27
- valid: boolean;
28
- error?: string;
24
+ interface RegexTestResult {
25
+ pattern: string;
26
+ flags: string;
27
+ results: RegexTestStringResult[];
28
+ valid: boolean;
29
+ error?: string;
29
30
  }
30
- export declare function regexTest(options: RegexTestOptions): RegexTestResult;
31
- //# sourceMappingURL=regex-test.d.ts.map
31
+ declare function regexTest(options: RegexTestOptions): RegexTestResult;
32
+ //#endregion
33
+ export { RegexMatchInfo, RegexTestOptions, RegexTestResult, RegexTestStringResult, regexTest };
@@ -1 +1 @@
1
- function u(g){const{pattern:r,flags:e="",testStrings:l,mode:c="match",replacement:i=""}=g;try{const s=new RegExp(r,e),o=l.map(t=>{const n=s.test(t);switch(c){case"match":{const p=e.includes("g")?e:`${e}g`,x=[...t.matchAll(new RegExp(r,p))];return{input:t,matched:n,matches:x.map(a=>({full:a[0],groups:[...a.slice(1)],index:a.index??0}))}}case"replace":return{input:t,matched:n,replaced:t.replace(new RegExp(r,e),i)};default:return{input:t,matched:n,split:t.split(new RegExp(r,e))}}});return{pattern:r,flags:e,results:o,valid:!0}}catch(s){return{pattern:r,flags:e,results:[],valid:!1,error:s.message}}}export{u as regexTest};
1
+ function e(e){let{pattern:t,flags:n=``,testStrings:r,mode:i=`match`,replacement:a=``}=e;try{let e=new RegExp(t,n);return{pattern:t,flags:n,results:r.map(r=>{let o=e.test(r);switch(i){case`match`:{let e=n.includes(`g`)?n:`${n}g`;return{input:r,matched:o,matches:[...r.matchAll(new RegExp(t,e))].map(e=>({full:e[0],groups:[...e.slice(1)],index:e.index??0}))}}case`replace`:return{input:r,matched:o,replaced:r.replace(new RegExp(t,n),a)};default:return{input:r,matched:o,split:r.split(new RegExp(t,n))}}}),valid:!0}}catch(e){return{pattern:t,flags:n,results:[],valid:!1,error:e.message}}}export{e as regexTest};
@@ -1,29 +1,31 @@
1
- export interface RenameOptions {
2
- /** Symbol to rename */
3
- oldName: string;
4
- /** New symbol name */
5
- newName: string;
6
- /** Root directory to search in */
7
- rootPath: string;
8
- /** File extensions to process (default: .ts, .tsx, .js, .jsx) */
9
- extensions?: string[];
10
- /** Glob patterns to exclude */
11
- exclude?: string[];
12
- /** Dry run — don't write changes */
13
- dryRun?: boolean;
1
+ //#region packages/tools/src/rename.d.ts
2
+ interface RenameOptions {
3
+ /** Symbol to rename */
4
+ oldName: string;
5
+ /** New symbol name */
6
+ newName: string;
7
+ /** Root directory to search in */
8
+ rootPath: string;
9
+ /** File extensions to process (default: .ts, .tsx, .js, .jsx) */
10
+ extensions?: string[];
11
+ /** Glob patterns to exclude */
12
+ exclude?: string[];
13
+ /** Dry run — don't write changes */
14
+ dryRun?: boolean;
14
15
  }
15
- export interface RenameChange {
16
- path: string;
17
- line: number;
18
- before: string;
19
- after: string;
16
+ interface RenameChange {
17
+ path: string;
18
+ line: number;
19
+ before: string;
20
+ after: string;
20
21
  }
21
- export interface RenameResult {
22
- oldName: string;
23
- newName: string;
24
- changes: RenameChange[];
25
- filesModified: number;
26
- dryRun: boolean;
22
+ interface RenameResult {
23
+ oldName: string;
24
+ newName: string;
25
+ changes: RenameChange[];
26
+ filesModified: number;
27
+ dryRun: boolean;
27
28
  }
28
- export declare function rename(options: RenameOptions): Promise<RenameResult>;
29
- //# sourceMappingURL=rename.d.ts.map
29
+ declare function rename(options: RenameOptions): Promise<RenameResult>;
30
+ //#endregion
31
+ export { RenameChange, RenameOptions, RenameResult, rename };
@@ -1,2 +1,2 @@
1
- import{readFile as x,writeFile as w}from"node:fs/promises";import{relative as N}from"node:path";import{DEFAULT_TOOL_EXTENSIONS as $,walkFiles as b}from"./file-walk.js";function P(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(e){return e.replace(/\\/g,"/")}function E(e){return new RegExp(`(^|[^A-Za-z0-9_$])(${P(e)})(?=[^A-Za-z0-9_$]|$)`,"g")}async function A(e){const{oldName:r,newName:s,rootPath:l,extensions:p=$,exclude:d=[],dryRun:f=!1}=e;if(!r.trim())throw new Error("oldName must not be empty");const g=E(r),h=await b(l,p,d),c=[];let m=0;for(const i of h){const t=(await x(i,"utf-8")).split(/\r?\n/);let u=!1;for(let n=0;n<t.length;n++){const a=t[n];g.lastIndex=0;const o=a.replace(g,(O,R)=>(u=!0,`${R}${s}`));a!==o&&(t[n]=o,c.push({path:C(N(l,i)),line:n+1,before:a,after:o}))}u&&(m+=1,f||await w(i,t.join(`
2
- `),"utf-8"))}return{oldName:r,newName:s,changes:c,filesModified:m,dryRun:f}}export{A as rename};
1
+ import{DEFAULT_TOOL_EXTENSIONS as e,walkFiles as t}from"./file-walk.js";import{readFile as n,writeFile as r}from"node:fs/promises";import{relative as i}from"node:path";function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function o(e){return e.replace(/\\/g,`/`)}function s(e){return RegExp(`(^|[^A-Za-z0-9_$])(${a(e)})(?=[^A-Za-z0-9_$]|$)`,`g`)}async function c(a){let{oldName:c,newName:l,rootPath:u,extensions:d=e,exclude:f=[],dryRun:p=!1}=a;if(!c.trim())throw Error(`oldName must not be empty`);let m=s(c),h=await t(u,d,f),g=[],_=0;for(let e of h){let t=(await n(e,`utf-8`)).split(/\r?\n/),a=!1;for(let n=0;n<t.length;n++){let r=t[n];m.lastIndex=0;let s=r.replace(m,(e,t)=>(a=!0,`${t}${l}`));r!==s&&(t[n]=s,g.push({path:o(i(u,e)),line:n+1,before:r,after:s}))}a&&(_+=1,p||await r(e,t.join(`
2
+ `),`utf-8`))}return{oldName:c,newName:l,changes:g,filesModified:_,dryRun:p}}export{c as rename};
@@ -1,3 +1,4 @@
1
+ //#region packages/tools/src/replay.d.ts
1
2
  /**
2
3
  * Replay — append-only audit trail of tool/CLI invocations.
3
4
  *
@@ -5,52 +6,53 @@
5
6
  * to `.kb-state/replay.jsonl`. Used by `kb replay` CLI, `kb_replay` MCP tool,
6
7
  * and the TUI log panel.
7
8
  */
8
- export interface ReplayEntry {
9
- /** ISO timestamp */
10
- ts: string;
11
- /** Source: 'mcp' | 'cli' */
12
- source: 'mcp' | 'cli';
13
- /** Tool or command name */
14
- tool: string;
15
- /** Redacted input summary (first 200 chars of JSON) */
16
- input: string;
17
- /** Duration in milliseconds */
18
- durationMs: number;
19
- /** Result status */
20
- status: 'ok' | 'error';
21
- /** Short result summary (first 200 chars) */
22
- output: string;
9
+ interface ReplayEntry {
10
+ /** ISO timestamp */
11
+ ts: string;
12
+ /** Source: 'mcp' | 'cli' */
13
+ source: 'mcp' | 'cli';
14
+ /** Tool or command name */
15
+ tool: string;
16
+ /** Redacted input summary (first 200 chars of JSON) */
17
+ input: string;
18
+ /** Duration in milliseconds */
19
+ durationMs: number;
20
+ /** Result status */
21
+ status: 'ok' | 'error';
22
+ /** Short result summary (first 200 chars) */
23
+ output: string;
23
24
  }
24
- export interface ReplayOptions {
25
- /** Max entries to return (default: 20) */
26
- last?: number;
27
- /** Filter by tool name */
28
- tool?: string;
29
- /** Filter by source */
30
- source?: 'mcp' | 'cli';
31
- /** Filter entries after this ISO timestamp */
32
- since?: string;
25
+ interface ReplayOptions {
26
+ /** Max entries to return (default: 20) */
27
+ last?: number;
28
+ /** Filter by tool name */
29
+ tool?: string;
30
+ /** Filter by source */
31
+ source?: 'mcp' | 'cli';
32
+ /** Filter entries after this ISO timestamp */
33
+ since?: string;
33
34
  }
34
35
  /**
35
36
  * Append a replay entry to the audit log.
36
- * Creates the `.kb-state/` directory if it doesn't exist.
37
+ * Creates the state directory if it doesn't exist.
37
38
  */
38
- export declare function replayAppend(entry: ReplayEntry): void;
39
+ declare function replayAppend(entry: ReplayEntry): void;
39
40
  /**
40
41
  * Read replay entries with optional filters.
41
42
  */
42
- export declare function replayList(opts?: ReplayOptions): ReplayEntry[];
43
+ declare function replayList(opts?: ReplayOptions): ReplayEntry[];
43
44
  /**
44
45
  * Trim the replay log to MAX_ENTRIES, keeping the most recent.
45
46
  */
46
- export declare function replayTrim(): number;
47
+ declare function replayTrim(): number;
47
48
  /**
48
49
  * Clear the entire replay log.
49
50
  */
50
- export declare function replayClear(): void;
51
+ declare function replayClear(): void;
51
52
  /**
52
53
  * Helper: create a replay entry from a tool invocation.
53
54
  * Use as a wrapper around tool execution.
54
55
  */
55
- export declare function replayCapture(source: 'mcp' | 'cli', tool: string, input: unknown, fn: () => Promise<unknown>): Promise<unknown>;
56
- //# sourceMappingURL=replay.d.ts.map
56
+ declare function replayCapture(source: 'mcp' | 'cli', tool: string, input: unknown, fn: () => Promise<unknown>): Promise<unknown>;
57
+ //#endregion
58
+ export { ReplayEntry, ReplayOptions, replayAppend, replayCapture, replayClear, replayList, replayTrim };
@@ -1,6 +1,4 @@
1
- import{appendFileSync as m,mkdirSync as S,readFileSync as u,writeFileSync as l}from"node:fs";import{dirname as w,resolve as d}from"node:path";const a=5e3,p=200;function c(){return d(process.cwd(),".kb-state","replay.jsonl")}function f(t,r){return t.length<=r?t:`${t.slice(0,r-1)}\u2026`}function y(t){const r=c();S(w(r),{recursive:!0});const n={...t,input:f(t.input,p),output:f(t.output,p)};m(r,`${JSON.stringify(n)}
2
- `,"utf-8")}function E(t={}){const r=c();let n;try{n=u(r,"utf-8")}catch{return[]}const s=n.trim().split(`
3
- `).filter(Boolean);let e=[];for(const o of s)try{e.push(JSON.parse(o))}catch{}if(t.tool&&(e=e.filter(o=>o.tool===t.tool)),t.source&&(e=e.filter(o=>o.source===t.source)),t.since){const o=t.since;e=e.filter(g=>g.ts>=o)}const i=t.last??20;return e.slice(-i)}function k(){const t=c();let r;try{r=u(t,"utf-8")}catch{return 0}const n=r.trim().split(`
4
- `).filter(Boolean);if(n.length<=a)return 0;const s=n.length-a,e=n.slice(-a);return l(t,`${e.join(`
5
- `)}
6
- `,"utf-8"),s}function O(){const t=c();try{l(t,"","utf-8")}catch{}}function N(t,r,n,s){const e=Date.now();return s().then(i=>(y({ts:new Date().toISOString(),source:t,tool:r,input:typeof n=="string"?n:JSON.stringify(n),durationMs:Date.now()-e,status:"ok",output:typeof i=="string"?i:JSON.stringify(i??"")}),i)).catch(i=>{throw y({ts:new Date().toISOString(),source:t,tool:r,input:typeof n=="string"?n:JSON.stringify(n),durationMs:Date.now()-e,status:"error",output:i instanceof Error?i.message:String(i)}),i})}export{y as replayAppend,N as replayCapture,O as replayClear,E as replayList,k as replayTrim};
1
+ import{dirname as e,resolve as t}from"node:path";import{appendFileSync 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=5e3;let c=0;function l(){return t(process.cwd(),o.state,`replay.jsonl`)}function u(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function d(t){let i=l();r(e(i),{recursive:!0});let a={...t,input:u(t.input,200),output:u(t.output,200)};if(n(i,`${JSON.stringify(a)}\n`,`utf-8`),c++,c>=100){c=0;try{p()}catch{}}}function f(e={}){let t=l(),n;try{n=i(t,`utf-8`)}catch{return[]}let r=n.trim().split(`
2
+ `).filter(Boolean),a=[];for(let e of r)try{a.push(JSON.parse(e))}catch{}if(e.tool&&(a=a.filter(t=>t.tool===e.tool)),e.source&&(a=a.filter(t=>t.source===e.source)),e.since){let t=e.since;a=a.filter(e=>e.ts>=t)}let o=e.last??20;return a.slice(-o)}function p(){let e=l(),t;try{t=i(e,`utf-8`)}catch{return 0}let n=t.trim().split(`
3
+ `).filter(Boolean);if(n.length<=s)return 0;let r=n.length-s;return a(e,`${n.slice(-s).join(`
4
+ `)}\n`,`utf-8`),r}function m(){let e=l();try{a(e,``,`utf-8`)}catch{}}function h(e,t,n,r){let i=Date.now();return r().then(r=>(d({ts:new Date().toISOString(),source:e,tool:t,input:typeof n==`string`?n:JSON.stringify(n),durationMs:Date.now()-i,status:`ok`,output:typeof r==`string`?r:JSON.stringify(r??``)}),r)).catch(r=>{throw d({ts:new Date().toISOString(),source:e,tool:t,input:typeof n==`string`?n:JSON.stringify(n),durationMs:Date.now()-i,status:`error`,output:r instanceof Error?r.message:String(r)}),r})}export{d as replayAppend,h as replayCapture,m as replayClear,f as replayList,p as replayTrim};
@@ -1,41 +1,43 @@
1
+ //#region packages/tools/src/response-envelope.d.ts
1
2
  /**
2
3
  * Standardized response envelope for KB tools (E-009).
3
4
  * New tools should return KBResponse<T>. Existing tools can adopt gradually.
4
5
  */
5
- export interface KBNextHint {
6
- tool: string;
7
- reason: string;
8
- suggested_args?: Record<string, unknown>;
6
+ interface KBNextHint {
7
+ tool: string;
8
+ reason: string;
9
+ suggested_args?: Record<string, unknown>;
9
10
  }
10
- export interface KBError {
11
- code: KBErrorCode;
12
- category: 'input' | 'runtime' | 'dependency' | 'timeout' | 'not_found';
13
- retryable: boolean;
14
- message: string;
15
- suggestion?: string;
11
+ interface KBError {
12
+ code: KBErrorCode;
13
+ category: 'input' | 'runtime' | 'dependency' | 'timeout' | 'not_found';
14
+ retryable: boolean;
15
+ message: string;
16
+ suggestion?: string;
16
17
  }
17
- export type KBErrorCode = 'SYMBOL_NOT_FOUND' | 'INDEX_STALE' | 'TREE_SITTER_UNAVAILABLE' | 'PARSE_FAILED' | 'BUDGET_EXCEEDED' | 'PATH_NOT_FOUND' | 'EMBEDDING_COLD_START' | 'ANALYSIS_FAILED';
18
- export interface KBResponseMeta {
19
- durationMs: number;
20
- tokensEstimate: number;
21
- detail: 'summary' | 'errors' | 'full';
22
- cached: boolean;
23
- truncated: boolean;
24
- caveats?: string[];
18
+ type KBErrorCode = 'SYMBOL_NOT_FOUND' | 'INDEX_STALE' | 'TREE_SITTER_UNAVAILABLE' | 'PARSE_FAILED' | 'BUDGET_EXCEEDED' | 'PATH_NOT_FOUND' | 'EMBEDDING_COLD_START' | 'ANALYSIS_FAILED';
19
+ interface KBResponseMeta {
20
+ durationMs: number;
21
+ tokensEstimate: number;
22
+ detail: 'summary' | 'errors' | 'full';
23
+ cached: boolean;
24
+ truncated: boolean;
25
+ caveats?: string[];
25
26
  }
26
- export interface KBResponse<T> {
27
- ok: boolean;
28
- tool: string;
29
- summary: string;
30
- data?: T;
31
- meta: KBResponseMeta;
32
- next?: KBNextHint[];
33
- error?: KBError;
27
+ interface KBResponse<T> {
28
+ ok: boolean;
29
+ tool: string;
30
+ summary: string;
31
+ data?: T;
32
+ meta: KBResponseMeta;
33
+ next?: KBNextHint[];
34
+ error?: KBError;
34
35
  }
35
36
  /** Create a success response. */
36
- export declare function okResponse<T>(tool: string, summary: string, data: T, meta: Partial<KBResponseMeta> & {
37
- durationMs: number;
37
+ declare function okResponse<T>(tool: string, summary: string, data: T, meta: Partial<KBResponseMeta> & {
38
+ durationMs: number;
38
39
  }, next?: KBNextHint[]): KBResponse<T>;
39
40
  /** Create an error response. */
40
- export declare function errorResponse(tool: string, error: KBError, durationMs: number): KBResponse<never>;
41
- //# sourceMappingURL=response-envelope.d.ts.map
41
+ declare function errorResponse(tool: string, error: KBError, durationMs: number): KBResponse<never>;
42
+ //#endregion
43
+ export { KBError, KBErrorCode, KBNextHint, KBResponse, KBResponseMeta, errorResponse, okResponse };
@@ -1 +1 @@
1
- import{estimateTokens as n}from"./text-utils.js";function u(s,r,t,e,o){const a=typeof t=="string"?t:JSON.stringify(t);return{ok:!0,tool:s,summary:r,data:t,meta:{durationMs:e.durationMs,tokensEstimate:e.tokensEstimate??n(a),detail:e.detail??"summary",cached:e.cached??!1,truncated:e.truncated??!1,...e.caveats?.length?{caveats:e.caveats}:{}},next:o}}function c(s,r,t){return{ok:!1,tool:s,summary:r.message,meta:{durationMs:t,tokensEstimate:n(r.message),detail:"summary",cached:!1,truncated:!1},error:r}}export{c as errorResponse,u as okResponse};
1
+ import{estimateTokens as e}from"./text-utils.js";function t(t,n,r,i,a){let o=typeof r==`string`?r:JSON.stringify(r);return{ok:!0,tool:t,summary:n,data:r,meta:{durationMs:i.durationMs,tokensEstimate:i.tokensEstimate??e(o),detail:i.detail??`summary`,cached:i.cached??!1,truncated:i.truncated??!1,...i.caveats?.length?{caveats:i.caveats}:{}},next:a}}function n(t,n,r){return{ok:!1,tool:t,summary:n.message,meta:{durationMs:r,tokensEstimate:e(n.message),detail:`summary`,cached:!1,truncated:!1},error:n}}export{n as errorResponse,t as okResponse};
@@ -1,3 +1,4 @@
1
+ //#region packages/tools/src/schema-validate.d.ts
1
2
  /**
2
3
  * kb_schema_validate — Validate data against a JSON Schema (core subset).
3
4
  *
@@ -5,19 +6,20 @@
5
6
  * enum, const, pattern, minimum, maximum, minLength, maxLength,
6
7
  * minItems, maxItems.
7
8
  */
8
- export interface SchemaValidateOptions {
9
- data: unknown;
10
- schema: Record<string, unknown>;
9
+ interface SchemaValidateOptions {
10
+ data: unknown;
11
+ schema: Record<string, unknown>;
11
12
  }
12
- export interface ValidationError {
13
- path: string;
14
- message: string;
15
- expected?: string;
16
- received?: string;
13
+ interface ValidationError {
14
+ path: string;
15
+ message: string;
16
+ expected?: string;
17
+ received?: string;
17
18
  }
18
- export interface SchemaValidateResult {
19
- valid: boolean;
20
- errors: ValidationError[];
19
+ interface SchemaValidateResult {
20
+ valid: boolean;
21
+ errors: ValidationError[];
21
22
  }
22
- export declare function schemaValidate(options: SchemaValidateOptions): SchemaValidateResult;
23
- //# sourceMappingURL=schema-validate.d.ts.map
23
+ declare function schemaValidate(options: SchemaValidateOptions): SchemaValidateResult;
24
+ //#endregion
25
+ export { SchemaValidateOptions, SchemaValidateResult, ValidationError, schemaValidate };
@@ -1 +1 @@
1
- function m(e){const n=[];return u(e.data,e.schema,"$",n),{valid:n.length===0,errors:n}}function u(e,n,r,t){if("type"in n){const i=n.type;if(!f(e,i)){t.push({path:r,message:`Expected type "${i}"`,expected:i,received:l(e)});return}}if("enum"in n){const i=n.enum;i.some(o=>JSON.stringify(o)===JSON.stringify(e))||t.push({path:r,message:`Must be one of: ${JSON.stringify(i)}`,received:JSON.stringify(e)})}if("const"in n&&JSON.stringify(e)!==JSON.stringify(n.const)&&t.push({path:r,message:`Must equal ${JSON.stringify(n.const)}`,received:JSON.stringify(e)}),typeof e=="string"&&("minLength"in n&&e.length<n.minLength&&t.push({path:r,message:`String too short (min: ${n.minLength})`,received:`length ${e.length}`}),"maxLength"in n&&e.length>n.maxLength&&t.push({path:r,message:`String too long (max: ${n.maxLength})`,received:`length ${e.length}`}),"pattern"in n&&!new RegExp(n.pattern).test(e)&&t.push({path:r,message:`Does not match pattern: ${n.pattern}`})),typeof e=="number"&&("minimum"in n&&e<n.minimum&&t.push({path:r,message:`Below minimum (${n.minimum})`,received:String(e)}),"maximum"in n&&e>n.maximum&&t.push({path:r,message:`Above maximum (${n.maximum})`,received:String(e)})),Array.isArray(e)&&("minItems"in n&&e.length<n.minItems&&t.push({path:r,message:`Too few items (min: ${n.minItems})`,received:`length ${e.length}`}),"maxItems"in n&&e.length>n.maxItems&&t.push({path:r,message:`Too many items (max: ${n.maxItems})`,received:`length ${e.length}`}),"items"in n))for(let i=0;i<e.length;i++)u(e[i],n.items,`${r}[${i}]`,t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i=e;if("required"in n)for(const o of n.required)o in i||t.push({path:`${r}.${o}`,message:"Required property missing"});if("properties"in n){const o=n.properties;for(const[s,g]of Object.entries(o))s in i&&u(i[s],g,`${r}.${s}`,t)}if("additionalProperties"in n&&n.additionalProperties===!1){const o=Object.keys(n.properties??{});for(const s of Object.keys(i))o.includes(s)||t.push({path:`${r}.${s}`,message:"Additional property not allowed"})}}}function f(e,n){switch(n){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!Number.isNaN(e);case"integer":return typeof e=="number"&&Number.isInteger(e);case"boolean":return typeof e=="boolean";case"null":return e===null;case"array":return Array.isArray(e);case"object":return e!==null&&typeof e=="object"&&!Array.isArray(e);default:return!0}}function l(e){return e===null?"null":Array.isArray(e)?"array":typeof e}export{m as schemaValidate};
1
+ function e(e){let n=[];return t(e.data,e.schema,`$`,n),{valid:n.length===0,errors:n}}function t(e,i,a,o){if(`type`in i){let t=i.type;if(!n(e,t)){o.push({path:a,message:`Expected type "${t}"`,expected:t,received:r(e)});return}}if(`enum`in i){let t=i.enum;t.some(t=>JSON.stringify(t)===JSON.stringify(e))||o.push({path:a,message:`Must be one of: ${JSON.stringify(t)}`,received:JSON.stringify(e)})}if(`const`in i&&JSON.stringify(e)!==JSON.stringify(i.const)&&o.push({path:a,message:`Must equal ${JSON.stringify(i.const)}`,received:JSON.stringify(e)}),typeof e==`string`&&(`minLength`in i&&e.length<i.minLength&&o.push({path:a,message:`String too short (min: ${i.minLength})`,received:`length ${e.length}`}),`maxLength`in i&&e.length>i.maxLength&&o.push({path:a,message:`String too long (max: ${i.maxLength})`,received:`length ${e.length}`}),`pattern`in i&&!new RegExp(i.pattern).test(e)&&o.push({path:a,message:`Does not match pattern: ${i.pattern}`})),typeof e==`number`&&(`minimum`in i&&e<i.minimum&&o.push({path:a,message:`Below minimum (${i.minimum})`,received:String(e)}),`maximum`in i&&e>i.maximum&&o.push({path:a,message:`Above maximum (${i.maximum})`,received:String(e)})),Array.isArray(e)&&(`minItems`in i&&e.length<i.minItems&&o.push({path:a,message:`Too few items (min: ${i.minItems})`,received:`length ${e.length}`}),`maxItems`in i&&e.length>i.maxItems&&o.push({path:a,message:`Too many items (max: ${i.maxItems})`,received:`length ${e.length}`}),`items`in i))for(let n=0;n<e.length;n++)t(e[n],i.items,`${a}[${n}]`,o);if(e&&typeof e==`object`&&!Array.isArray(e)){let n=e;if(`required`in i)for(let e of i.required)e in n||o.push({path:`${a}.${e}`,message:`Required property missing`});if(`properties`in i){let e=i.properties;for(let[r,i]of Object.entries(e))r in n&&t(n[r],i,`${a}.${r}`,o)}if(`additionalProperties`in i&&i.additionalProperties===!1){let e=Object.keys(i.properties??{});for(let t of Object.keys(n))e.includes(t)||o.push({path:`${a}.${t}`,message:`Additional property not allowed`})}}}function n(e,t){switch(t){case`string`:return typeof e==`string`;case`number`:return typeof e==`number`&&!Number.isNaN(e);case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`null`:return e===null;case`array`:return Array.isArray(e);case`object`:return typeof e==`object`&&!!e&&!Array.isArray(e);default:return!0}}function r(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}export{e as schemaValidate};
@@ -1,54 +1,51 @@
1
- /**
2
- * kb_scope_map Task-scoped reading plan generator.
3
- *
4
- * Given a task description, searches the KB to identify which files
5
- * and sections are relevant, then produces a prioritized reading plan
6
- * with estimated token counts.
7
- */
8
- import type { IEmbedder } from '@kb/embeddings';
9
- import type { IKnowledgeStore } from '@kb/store';
10
- export interface ScopeMapOptions {
11
- /** Description of the task to scope */
12
- task: string;
13
- /** Maximum number of files to include (default: 15) */
14
- maxFiles?: number;
15
- /** Group results by directory (default: true) */
16
- groupByDirectory?: boolean;
17
- /** Filter by content type */
18
- contentType?: string;
19
- /** Filter by origin */
20
- origin?: string;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+ import { ContentType, KnowledgeOrigin } from "@kb/core";
4
+
5
+ //#region packages/tools/src/scope-map.d.ts
6
+ interface ScopeMapOptions {
7
+ /** Description of the task to scope */
8
+ task: string;
9
+ /** Maximum number of files to include (default: 15) */
10
+ maxFiles?: number;
11
+ /** Group results by directory (default: true) */
12
+ groupByDirectory?: boolean;
13
+ /** Filter by content type */
14
+ contentType?: ContentType;
15
+ /** Filter by origin */
16
+ origin?: KnowledgeOrigin;
21
17
  }
22
- export interface ScopeMapEntry {
23
- /** File path */
24
- path: string;
25
- /** Why this file is relevant (derived from matched chunks) */
26
- reason: string;
27
- /** Estimated token count (chars / 4 approximation) */
28
- estimatedTokens: number;
29
- /** Relevance score (0-1) */
30
- relevance: number;
31
- /** Line ranges to focus on */
32
- focusRanges: Array<{
33
- start: number;
34
- end: number;
35
- heading?: string;
36
- }>;
18
+ interface ScopeMapEntry {
19
+ /** File path */
20
+ path: string;
21
+ /** Why this file is relevant (derived from matched chunks) */
22
+ reason: string;
23
+ /** Estimated token count (chars / 4 approximation) */
24
+ estimatedTokens: number;
25
+ /** Relevance score (0-1) */
26
+ relevance: number;
27
+ /** Line ranges to focus on */
28
+ focusRanges: Array<{
29
+ start: number;
30
+ end: number;
31
+ heading?: string;
32
+ }>;
37
33
  }
38
- export interface ScopeMapResult {
39
- /** The task that was analyzed */
40
- task: string;
41
- /** Prioritized file list */
42
- files: ScopeMapEntry[];
43
- /** Total estimated tokens across all files */
44
- totalEstimatedTokens: number;
45
- /** Suggested reading order (file paths) */
46
- readingOrder: string[];
47
- /** Suggested compact/file_summary commands to reduce context */
48
- compactCommands: string[];
34
+ interface ScopeMapResult {
35
+ /** The task that was analyzed */
36
+ task: string;
37
+ /** Prioritized file list */
38
+ files: ScopeMapEntry[];
39
+ /** Total estimated tokens across all files */
40
+ totalEstimatedTokens: number;
41
+ /** Suggested reading order (file paths) */
42
+ readingOrder: string[];
43
+ /** Suggested compact/file_summary commands to reduce context */
44
+ compactCommands: string[];
49
45
  }
50
46
  /**
51
47
  * Generate a task-scoped reading plan.
52
48
  */
53
- export declare function scopeMap(embedder: IEmbedder, store: IKnowledgeStore, options: ScopeMapOptions): Promise<ScopeMapResult>;
54
- //# sourceMappingURL=scope-map.d.ts.map
49
+ declare function scopeMap(embedder: IEmbedder, store: IKnowledgeStore, options: ScopeMapOptions): Promise<ScopeMapResult>;
50
+ //#endregion
51
+ export { ScopeMapEntry, ScopeMapOptions, ScopeMapResult, scopeMap };
@@ -1 +1 @@
1
- function C(c){return Math.ceil(c.length/4)}async function E(c,u,l){const{task:i,maxFiles:h=15,contentType:g,origin:f}=l,k=await c.embed(i),S={limit:h*3,contentType:g,origin:f},y=await u.search(k,S),o=new Map;for(const e of y){const t=e.record.sourcePath,n=o.get(t);n?(n.chunks.push(e),n.totalChars+=e.record.content.length,n.maxScore=Math.max(n.maxScore,e.score)):o.set(t,{chunks:[e],totalChars:e.record.content.length,maxScore:e.score})}const s=[...o.entries()].sort(([,e],[,t])=>t.maxScore-e.maxScore).slice(0,h).map(([e,{chunks:t,maxScore:n}])=>{const a=t.sort((r,m)=>r.record.startLine-m.record.startLine).map(r=>({start:r.record.startLine,end:r.record.endLine,heading:r.record.headingPath})),d=t.sort((r,m)=>m.score-r.score)[0],T=d.record.headingPath?`Matches: ${d.record.headingPath}`:`Contains relevant ${d.record.contentType} content`;return{path:e,reason:T,estimatedTokens:0,relevance:n,focusRanges:a}});for(const e of s){const t=o.get(e.path);t&&(e.estimatedTokens=C(t.chunks.map(n=>n.record.content).join("")))}const x=s.reduce((e,t)=>e+t.estimatedTokens,0),b=[...s].sort((e,t)=>{const n=e.path.includes("config")||e.path.includes("types")?-1:0,a=t.path.includes("config")||t.path.includes("types")?-1:0;return n!==a?n-a:t.relevance-e.relevance}).map(e=>e.path),M=100,p=[];for(const e of s)e.estimatedTokens<=M?p.push(`kb_file_summary({ path: "${e.path}" }) \u2192 ~${e.estimatedTokens} tokens`):p.push(`kb_compact({ path: "${e.path}", query: "${i}" }) \u2192 ~${Math.ceil(e.estimatedTokens/5)} tokens`);return{task:i,files:s,totalEstimatedTokens:x,readingOrder:b,compactCommands:p}}export{E as scopeMap};
1
+ function e(e){return Math.ceil(e.length/4)}async function t(t,n,r){let{task:i,maxFiles:a=15,contentType:o,origin:s}=r,c=await t.embed(i),l={limit:a*3,contentType:o,origin:s},u=await n.search(c,l),d=new Map;for(let e of u){let t=e.record.sourcePath,n=d.get(t);n?(n.chunks.push(e),n.totalChars+=e.record.content.length,n.maxScore=Math.max(n.maxScore,e.score)):d.set(t,{chunks:[e],totalChars:e.record.content.length,maxScore:e.score})}let f=[...d.entries()].sort(([,e],[,t])=>t.maxScore-e.maxScore).slice(0,a).map(([e,{chunks:t,maxScore:n}])=>{let r=t.sort((e,t)=>e.record.startLine-t.record.startLine).map(e=>({start:e.record.startLine,end:e.record.endLine,heading:e.record.headingPath})),i=t.sort((e,t)=>t.score-e.score)[0];return{path:e,reason:i.record.headingPath?`Matches: ${i.record.headingPath}`:`Contains relevant ${i.record.contentType} content`,estimatedTokens:0,relevance:n,focusRanges:r}});for(let t of f){let n=d.get(t.path);n&&(t.estimatedTokens=e(n.chunks.map(e=>e.record.content).join(``)))}let p=f.reduce((e,t)=>e+t.estimatedTokens,0),m=[...f].sort((e,t)=>{let n=e.path.includes(`config`)||e.path.includes(`types`)?-1:0,r=t.path.includes(`config`)||t.path.includes(`types`)?-1:0;return n===r?t.relevance-e.relevance:n-r}).map(e=>e.path),h=[];for(let e of f)e.estimatedTokens<=100?h.push(`kb_file_summary({ path: "${e.path}" }) ~${e.estimatedTokens} tokens`):h.push(`kb_compact({ path: "${e.path}", query: "${i}" }) ~${Math.ceil(e.estimatedTokens/5)} tokens`);return{task:i,files:f,totalEstimatedTokens:p,readingOrder:m,compactCommands:h}}export{t as scopeMap};