@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,47 +1,45 @@
1
- /**
2
- * kb_find Federated search across vector similarity, keyword (FTS), and file glob.
3
- *
4
- * Combines multiple search strategies in a single call, deduplicates,
5
- * and returns unified results with source attribution.
6
- */
7
- import type { IEmbedder } from '@kb/embeddings';
8
- import type { IKnowledgeStore } from '@kb/store';
9
- export interface FindOptions {
10
- /** Semantic search query (optional) */
11
- query?: string;
12
- /** File glob pattern (optional) */
13
- glob?: string;
14
- /** Keyword/regex pattern for text search (optional) */
15
- pattern?: string;
16
- /** Max results per strategy (default: 10) */
17
- limit?: number;
18
- /** Filter by content type */
19
- contentType?: string;
20
- /** Working directory for glob resolution (default: cwd) */
21
- cwd?: 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.d.ts
6
+ interface FindOptions {
7
+ /** Semantic search query (optional) */
8
+ query?: string;
9
+ /** File glob pattern (optional) */
10
+ glob?: string;
11
+ /** Keyword/regex pattern for text search (optional) */
12
+ pattern?: string;
13
+ /** Max results per strategy (default: 10) */
14
+ limit?: number;
15
+ /** Filter by content type */
16
+ contentType?: ContentType;
17
+ /** Working directory for glob resolution (default: cwd) */
18
+ cwd?: string;
22
19
  }
23
- export interface FindResult {
24
- /** File path (relative to cwd) */
25
- path: string;
26
- /** How this result was found */
27
- source: 'vector' | 'keyword' | 'glob' | 'pattern';
28
- /** Relevance score (0-1 for vector/keyword, 1 for glob/pattern matches) */
29
- score: number;
30
- /** Line range if from KB search */
31
- lineRange?: {
32
- start: number;
33
- end: number;
34
- };
35
- /** Content preview */
36
- preview?: string;
20
+ interface FindResult {
21
+ /** File path (relative to cwd) */
22
+ path: string;
23
+ /** How this result was found */
24
+ source: 'vector' | 'keyword' | 'glob' | 'pattern';
25
+ /** Relevance score (0-1 for vector/keyword, 1 for glob/pattern matches) */
26
+ score: number;
27
+ /** Line range if from KB search */
28
+ lineRange?: {
29
+ start: number;
30
+ end: number;
31
+ };
32
+ /** Content preview */
33
+ preview?: string;
37
34
  }
38
- export interface FindResults {
39
- results: FindResult[];
40
- strategies: string[];
41
- totalFound: number;
35
+ interface FindResults {
36
+ results: FindResult[];
37
+ strategies: string[];
38
+ totalFound: number;
42
39
  }
43
40
  /**
44
41
  * Run federated search across multiple strategies.
45
42
  */
46
- export declare function find(embedder: IEmbedder, store: IKnowledgeStore, options: FindOptions): Promise<FindResults>;
47
- //# sourceMappingURL=find.d.ts.map
43
+ declare function find(embedder: IEmbedder, store: IKnowledgeStore, options: FindOptions): Promise<FindResults>;
44
+ //#endregion
45
+ export { FindOptions, FindResult, FindResults, find };
@@ -1 +1 @@
1
- async function y(f,u,b){const{query:d,glob:h,pattern:l,limit:i=10,contentType:p,cwd:m=process.cwd()}=b,a=[],n=[],o=new Set;if(d){a.push("vector");const s=await f.embed(d),e={limit:i,contentType:p},t=await u.search(s,e);for(const r of t){const c=`${r.record.sourcePath}:${r.record.startLine}`;o.has(c)||(o.add(c),n.push({path:r.record.sourcePath,source:"vector",score:r.score,lineRange:{start:r.record.startLine,end:r.record.endLine},preview:r.record.content.slice(0,200)}))}}if(d){a.push("keyword");try{const s=await u.ftsSearch(d,{limit:i,contentType:p});for(const e of s){const t=`${e.record.sourcePath}:${e.record.startLine}`;o.has(t)||(o.add(t),n.push({path:e.record.sourcePath,source:"keyword",score:e.score,lineRange:{start:e.record.startLine,end:e.record.endLine},preview:e.record.content.slice(0,200)}))}}catch{}}if(h){a.push("glob");try{const{globSync:s}=await import("node:fs"),e=s(h,{cwd:m}),t=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out",".kb-state",".kb-data"]),r=e.filter(c=>!c.replace(/\\/g,"/").split("/").some(w=>t.has(w)));for(const c of r.slice(0,i)){const g=`glob:${c}`;o.has(g)||(o.add(g),n.push({path:c,source:"glob",score:1}))}}catch{}}if(l){a.push("pattern");try{const s=new RegExp(l,"i"),e=await u.ftsSearch(l,{limit:i*2,contentType:p});for(const t of e)if(s.test(t.record.content)){const r=`${t.record.sourcePath}:${t.record.startLine}`;o.has(r)||(o.add(r),n.push({path:t.record.sourcePath,source:"pattern",score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch{}}return n.sort((s,e)=>e.score-s.score),{results:n.slice(0,i),strategies:a,totalFound:n.length}}export{y as find};
1
+ import{KB_PATHS as e}from"../../core/dist/index.js";async function t(t,n,r){let{query:i,glob:a,pattern:o,limit:s=10,contentType:c,cwd:l=process.cwd()}=r,u=[],d=[],f=new Set;if(i){u.push(`vector`);let e=await t.embed(i),r={limit:s,contentType:c},a=await n.search(e,r);for(let e of a){let t=`${e.record.sourcePath}:${e.record.startLine}`;f.has(t)||(f.add(t),d.push({path:e.record.sourcePath,source:`vector`,score:e.score,lineRange:{start:e.record.startLine,end:e.record.endLine},preview:e.record.content.slice(0,200)}))}}if(i){u.push(`keyword`);try{let e=await n.ftsSearch(i,{limit:s,contentType:c});for(let t of e){let e=`${t.record.sourcePath}:${t.record.startLine}`;f.has(e)||(f.add(e),d.push({path:t.record.sourcePath,source:`keyword`,score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch{}}if(a){u.push(`glob`);try{let{globSync:t}=await import(`node:fs`),n=t(a,{cwd:l,withFileTypes:!1}),r=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,e.state,e.data]),i=n.filter(e=>!e.replace(/\\/g,`/`).split(`/`).some(e=>r.has(e)));for(let e of i.slice(0,s)){let t=`glob:${e}`;f.has(t)||(f.add(t),d.push({path:e,source:`glob`,score:1}))}}catch{}}if(o){u.push(`pattern`);try{let e=new RegExp(o,`i`),t=await n.ftsSearch(o,{limit:s*2,contentType:c});for(let n of t)if(e.test(n.record.content)){let e=`${n.record.sourcePath}:${n.record.startLine}`;f.has(e)||(f.add(e),d.push({path:n.record.sourcePath,source:`pattern`,score:n.score,lineRange:{start:n.record.startLine,end:n.record.endLine},preview:n.record.content.slice(0,200)}))}}catch{}}return d.sort((e,t)=>t.score-e.score),{results:d.slice(0,s),strategies:u,totalFound:d.length}}export{t as find};
@@ -1,44 +1,40 @@
1
- /**
2
- * kb_forge_classify — Automated FORGE tier classification.
3
- *
4
- * Determines Floor/Standard/Critical tier from file analysis.
5
- * Uses path patterns, export scanning, and structural heuristics.
6
- * No LLM needed.
7
- */
8
- import type { ForgeTier } from './evidence-map.js';
9
- export interface ForgeClassifyOptions {
10
- /** Files being modified (absolute or relative paths) */
11
- files: string[];
12
- /** Task description for keyword detection */
13
- task: string;
14
- /** Root path for package boundary detection */
15
- rootPath: string;
1
+ import { ForgeTier } from "./evidence-map.js";
2
+
3
+ //#region packages/tools/src/forge-classify.d.ts
4
+ interface ForgeClassifyOptions {
5
+ /** Files being modified (absolute or relative paths) */
6
+ files: string[];
7
+ /** Task description for keyword detection */
8
+ task: string;
9
+ /** Root path for package boundary detection */
10
+ rootPath: string;
16
11
  }
17
- export interface ClassifyTrigger {
18
- rule: string;
19
- detail: string;
20
- source: 'blast_radius' | 'cross_package' | 'schema_contract' | 'security_auth' | 'task_hint' | 'default';
12
+ interface ClassifyTrigger {
13
+ rule: string;
14
+ detail: string;
15
+ source: 'blast_radius' | 'cross_package' | 'schema_contract' | 'security_auth' | 'task_hint' | 'default';
21
16
  }
22
- export interface TypedUnknownSeed {
23
- description: string;
24
- type: 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
25
- suggestedTool: string;
17
+ interface TypedUnknownSeed {
18
+ description: string;
19
+ type: 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
20
+ suggestedTool: string;
26
21
  }
27
- export interface ForgeClassifyCeremony {
28
- ground: string;
29
- build: string;
30
- break: string;
31
- evidenceMap: string;
32
- gate: string;
22
+ interface ForgeClassifyCeremony {
23
+ ground: string;
24
+ build: string;
25
+ break: string;
26
+ evidenceMap: string;
27
+ gate: string;
33
28
  }
34
- export interface ForgeClassifyResult {
35
- tier: ForgeTier;
36
- triggers: ClassifyTrigger[];
37
- packagesCrossed: string[];
38
- hasSchemaChange: boolean;
39
- hasSecurityPath: boolean;
40
- typedUnknownSeeds: TypedUnknownSeed[];
41
- ceremony: ForgeClassifyCeremony;
29
+ interface ForgeClassifyResult {
30
+ tier: ForgeTier;
31
+ triggers: ClassifyTrigger[];
32
+ packagesCrossed: string[];
33
+ hasSchemaChange: boolean;
34
+ hasSecurityPath: boolean;
35
+ typedUnknownSeeds: TypedUnknownSeed[];
36
+ ceremony: ForgeClassifyCeremony;
42
37
  }
43
- export declare function forgeClassify(options: ForgeClassifyOptions): Promise<ForgeClassifyResult>;
44
- //# sourceMappingURL=forge-classify.d.ts.map
38
+ declare function forgeClassify(options: ForgeClassifyOptions): Promise<ForgeClassifyResult>;
39
+ //#endregion
40
+ export { ClassifyTrigger, ForgeClassifyCeremony, ForgeClassifyOptions, ForgeClassifyResult, TypedUnknownSeed, forgeClassify };
@@ -1,2 +1,2 @@
1
- import{existsSync as g,readdirSync as _,readFileSync as S,statSync as k}from"node:fs";import{dirname as m,extname as C,relative as p,resolve as a}from"node:path";import{fileSummary as w}from"./file-summary.js";const E=1e5,x=200,v=new Set([".ts",".tsx",".js",".jsx",".mts",".cts",".mjs",".cjs"]),A=new Set([".git",".kb-data",".kb-state",".turbo",".yarn","build","coverage","dist","node_modules"]),N=/auth|token|permission|acl|encrypt|secret|credential|jwt|oauth|password/i,R=/\b(hash|sign|verify|bcrypt|jwt|decrypt|secret|password)\b/i,P=/auth|security|permission|encrypt|secret|credential/i,F=/types\.ts$|schema\.ts$|contract\.ts$|\.proto$|openapi|swagger|\.graphql$/i,U=/(?:^|\/)(events|contracts|shared)(?:\/|$)/i,$=/export\s+interface\b|export\s+type\b|export\s+const\s+\w*Schema\w*\s*=\s*z\./i,j=/schema|contract|migration|breaking.change|api.change/i,I=/migration|data.?model|multi.?service|breaking|backward.?compat/i,D={floor:{ground:"Parasitic \u2014 read target file only",build:"Implement directly",break:"Skip",evidenceMap:"Not required",gate:"Self-certify"},standard:{ground:"Scope map + blast radius + constraint seed",build:"TDD \u2014 test first, then implement",break:"Error paths + edge cases",evidenceMap:"3-8 critical-path entries",gate:"YIELD/HOLD evaluation"},critical:{ground:"Full scope map + blast radius + trace + patterns + constraint pack",build:"TDD + contract verification + cross-service validation",break:"Error paths + edge cases + security dimensions + data-flow verification",evidenceMap:"Comprehensive \u2014 all critical-path claims with receipts",gate:"Strict YIELD/HOLD/HARD_BLOCK evaluation"}};async function W(t){const s=a(t.rootPath),r=t.task.trim(),e=t.files.map(c=>a(s,c)),n=[];let i=!1,o=!1;for(const c of e){const f=O(c,s),T=b(c);(N.test(f)||R.test(T)||P.test(r))&&(i=!0),(F.test(f)||U.test(f)||j.test(r)||$.test(T)||await M(c))&&(o=!0)}i&&l(n,{rule:"security-path",detail:"Security/auth path, task, or content matched security heuristics",source:"security_auth"}),o&&l(n,{rule:"schema-contract",detail:"Schema or contract path, task, or export shape matched contract heuristics",source:"schema_contract"});const d=H(e,s);d.affectedFiles>5&&l(n,{rule:"blast-radius-importers",detail:`${d.affectedFiles} affected files via direct import scanning`,source:"blast_radius"});const u=[...new Set(e.map(c=>B(c,s)).filter(c=>!!c))].sort();u.length>=2&&l(n,{rule:"cross-package-boundary",detail:`Files span ${u.length} packages: ${u.join(", ")}`,source:"cross_package"}),I.test(r)&&l(n,{rule:"task-hint-critical",detail:"Task description matched migration or compatibility criticality hints",source:"task_hint"});const y=n.length>0?"critical":e.length===1?"floor":"standard";return{tier:y,triggers:n,packagesCrossed:u,hasSchemaChange:o,hasSecurityPath:i,typedUnknownSeeds:q(n),ceremony:D[y]}}function l(t,s){t.some(r=>r.rule===s.rule&&r.source===s.source)||t.push(s)}function O(t,s){const r=a(s,t),e=p(s,r);return(e&&!e.startsWith("..")?e:r).replace(/\\/g,"/")}function h(t){if(!g(t))return!1;try{return k(t).size<=E}catch{return!1}}function b(t){if(!h(t))return"";try{return S(t,"utf-8").split(/\r?\n/).slice(0,x).join(`
2
- `)}catch{return""}}async function M(t){if(!h(t))return!1;try{const s=await w({path:t}),r=new Set(s.exports);return s.interfaces.some(e=>r.has(e.name))||s.types.some(e=>r.has(e.name))}catch{return!1}}function H(t,s){const r=new Set(t.filter(n=>g(n)));if(r.size===0)return{affectedFiles:t.length,importers:[]};const e=new Set;for(const n of L(s)){if(r.has(n)||!h(n))continue;const i=b(n);if(!i)continue;z(i).some(d=>Y(d,n,r))&&e.add(n)}return{affectedFiles:t.length+e.size,importers:[...e].map(n=>p(s,n).replace(/\\/g,"/"))}}function L(t){const s=[];function r(e){let n=[];try{n=_(e)}catch{return}for(const i of n){if(A.has(i))continue;const o=a(e,i);let d;try{d=k(o)}catch{continue}if(d.isDirectory()){r(o);continue}v.has(C(i).toLowerCase())&&s.push(o)}}return r(t),s}function z(t){const s=new Set,r=/(?:from\s+['"]([^'"]+)['"]|import\s+['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\))/g;for(const e of t.matchAll(r)){const n=e[1]??e[2]??e[3];n&&s.add(n)}return[...s]}function Y(t,s,r){if(!t.startsWith("."))return!1;const e=a(m(s),t);return[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.jsx`,`${e}.mts`,`${e}.cts`,`${e}.mjs`,`${e}.cjs`,a(e,"index.ts"),a(e,"index.tsx"),a(e,"index.js"),a(e,"index.jsx")].some(i=>r.has(i))}function q(t){return t.map(s=>{switch(s.source){case"security_auth":return{description:"Verify auth and security assumptions before yielding",type:"contract",suggestedTool:"kb_search"};case"schema_contract":return{description:"Confirm schema and contract compatibility",type:"contract",suggestedTool:"kb_schema_validate"};case"blast_radius":return{description:"Inspect affected importers before delivery",type:"impact",suggestedTool:"kb_blast_radius"};case"cross_package":return{description:"Assess downstream package impact across boundaries",type:"impact",suggestedTool:"kb_blast_radius"};case"task_hint":return{description:"Check established conventions for migrations or compatibility work",type:"convention",suggestedTool:"kb_find"};default:return{description:"No explicit unknown routing required",type:"freshness",suggestedTool:"kb_lookup"}}})}function B(t,s){let r=m(a(s,t));const e=a(s);for(;r.length>=e.length;){const n=a(r,"package.json");if(g(n))try{return JSON.parse(S(n,"utf-8")).name??p(e,r).replace(/\\/g,"/")}catch{return p(e,r).replace(/\\/g,"/")}const i=m(r);if(i===r)break;r=i}}export{W as forgeClassify};
1
+ import{fileSummary as e}from"./file-summary.js";import{dirname as t,extname as n,relative as r,resolve as i}from"node:path";import{existsSync as a,readFileSync as o,readdirSync as s,statSync as c}from"node:fs";import{KB_PATHS as l}from"../../core/dist/index.js";const u=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.cts`,`.mjs`,`.cjs`]),d=new Set([`.git`,l.data,l.state,`.turbo`,`.yarn`,`build`,`coverage`,`dist`,`node_modules`]),f=/auth|token|permission|acl|encrypt|secret|credential|jwt|oauth|password/i,p=/\b(hash|sign|verify|bcrypt|jwt|decrypt|secret|password)\b/i,m=/auth|security|permission|encrypt|secret|credential/i,h=/types\.ts$|schema\.ts$|contract\.ts$|\.proto$|openapi|swagger|\.graphql$/i,g=/(?:^|\/)(events|contracts|shared)(?:\/|$)/i,_=/export\s+interface\b|export\s+type\b|export\s+const\s+\w*Schema\w*\s*=\s*z\./i,v=/schema|contract|migration|breaking.change|api.change/i,y=/migration|data.?model|multi.?service|breaking|backward.?compat/i,b={floor:{ground:`Parasitic read target file only`,build:`Implement directly`,break:`Skip`,evidenceMap:`Not required`,gate:`Self-certify`},standard:{ground:`Scope map + blast radius + constraint seed`,build:`TDD test first, then implement`,break:`Error paths + edge cases`,evidenceMap:`3-8 critical-path entries`,gate:`YIELD/HOLD evaluation`},critical:{ground:`Full scope map + blast radius + trace + patterns + constraint pack`,build:`TDD + contract verification + cross-service validation`,break:`Error paths + edge cases + security dimensions + data-flow verification`,evidenceMap:`Comprehensive all critical-path claims with receipts`,gate:`Strict YIELD/HOLD/HARD_BLOCK evaluation`}};async function x(e){let t=i(e.rootPath),n=e.task.trim(),r=e.files.map(e=>i(t,e)),a=[],o=!1,s=!1;for(let e of r){let r=C(e,t),i=T(e);(f.test(r)||p.test(i)||m.test(n))&&(o=!0),(h.test(r)||g.test(r)||v.test(n)||_.test(i)||await E(e))&&(s=!0)}o&&S(a,{rule:`security-path`,detail:`Security/auth path, task, or content matched security heuristics`,source:`security_auth`}),s&&S(a,{rule:`schema-contract`,detail:`Schema or contract path, task, or export shape matched contract heuristics`,source:`schema_contract`});let c=D(r,t);c.affectedFiles>5&&S(a,{rule:`blast-radius-importers`,detail:`${c.affectedFiles} affected files via direct import scanning`,source:`blast_radius`});let l=[...new Set(r.map(e=>M(e,t)).filter(e=>!!e))].sort();l.length>=2&&S(a,{rule:`cross-package-boundary`,detail:`Files span ${l.length} packages: ${l.join(`, `)}`,source:`cross_package`}),y.test(n)&&S(a,{rule:`task-hint-critical`,detail:`Task description matched migration or compatibility criticality hints`,source:`task_hint`});let u=a.length>0?`critical`:r.length===1?`floor`:`standard`;return{tier:u,triggers:a,packagesCrossed:l,hasSchemaChange:s,hasSecurityPath:o,typedUnknownSeeds:j(a),ceremony:b[u]}}function S(e,t){e.some(e=>e.rule===t.rule&&e.source===t.source)||e.push(t)}function C(e,t){let n=i(t,e),a=r(t,n);return(a&&!a.startsWith(`..`)?a:n).replace(/\\/g,`/`)}function w(e){if(!a(e))return!1;try{return c(e).size<=1e5}catch{return!1}}function T(e){if(!w(e))return``;try{return o(e,`utf-8`).split(/\r?\n/).slice(0,200).join(`
2
+ `)}catch{return``}}async function E(t){if(!w(t))return!1;try{let n=await e({path:t}),r=new Set(n.exports);return n.interfaces.some(e=>r.has(e.name))||n.types.some(e=>r.has(e.name))}catch{return!1}}function D(e,t){let n=new Set(e.filter(e=>a(e)));if(n.size===0)return{affectedFiles:e.length,importers:[]};let i=new Set;for(let e of O(t)){if(n.has(e)||!w(e))continue;let t=T(e);t&&k(t).some(t=>A(t,e,n))&&i.add(e)}return{affectedFiles:e.length+i.size,importers:[...i].map(e=>r(t,e).replace(/\\/g,`/`))}}function O(e){let t=[];function r(e){let a=[];try{a=s(e)}catch{return}for(let o of a){if(d.has(o))continue;let a=i(e,o),s;try{s=c(a)}catch{continue}if(s.isDirectory()){r(a);continue}u.has(n(o).toLowerCase())&&t.push(a)}}return r(e),t}function k(e){let t=new Set;for(let n of e.matchAll(/(?:from\s+['"]([^'"]+)['"]|import\s+['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\))/g)){let e=n[1]??n[2]??n[3];e&&t.add(e)}return[...t]}function A(e,n,r){if(!e.startsWith(`.`))return!1;let a=i(t(n),e);return[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.jsx`,`${a}.mts`,`${a}.cts`,`${a}.mjs`,`${a}.cjs`,i(a,`index.ts`),i(a,`index.tsx`),i(a,`index.js`),i(a,`index.jsx`)].some(e=>r.has(e))}function j(e){return e.map(e=>{switch(e.source){case`security_auth`:return{description:`Verify auth and security assumptions before yielding`,type:`contract`,suggestedTool:`kb_search`};case`schema_contract`:return{description:`Confirm schema and contract compatibility`,type:`contract`,suggestedTool:`kb_schema_validate`};case`blast_radius`:return{description:`Inspect affected importers before delivery`,type:`impact`,suggestedTool:`kb_blast_radius`};case`cross_package`:return{description:`Assess downstream package impact across boundaries`,type:`impact`,suggestedTool:`kb_blast_radius`};case`task_hint`:return{description:`Check established conventions for migrations or compatibility work`,type:`convention`,suggestedTool:`kb_find`};default:return{description:`No explicit unknown routing required`,type:`freshness`,suggestedTool:`kb_lookup`}}})}function M(e,n){let s=t(i(n,e)),c=i(n);for(;s.length>=c.length;){let e=i(s,`package.json`);if(a(e))try{return JSON.parse(o(e,`utf-8`)).name??r(c,s).replace(/\\/g,`/`)}catch{return r(c,s).replace(/\\/g,`/`)}let n=t(s);if(n===s)break;s=n}}export{x as forgeClassify};
@@ -1,64 +1,61 @@
1
- /**
2
- * kb_forge_ground FORGE Phase 1 (Ground) batch executor.
3
- *
4
- * Executes the complete Ground phase as a single tool call:
5
- * tier classification scope map → typed unknowns → constraint seed → file summaries.
6
- */
7
- import type { IEmbedder } from '@kb/embeddings';
8
- import type { IKnowledgeStore } from '@kb/store';
9
- import { type ForgeTier } from './evidence-map.js';
10
- import { type ClassifyTrigger, type TypedUnknownSeed } from './forge-classify.js';
11
- import { type ScopeMapResult } from './scope-map.js';
12
- export interface ForgeGroundOptions {
13
- /** Task description */
14
- task: string;
15
- /** Target files being modified (absolute paths) */
16
- files: string[];
17
- /** Root path of the codebase */
18
- rootPath: string;
19
- /** Max constraint entries to load (default: 3) */
20
- maxConstraints?: number;
21
- /** Force a specific tier (skip auto-classify) */
22
- forceTier?: ForgeTier;
23
- /** Task ID for evidence map creation (default: auto-generated from task) */
24
- taskId?: string;
1
+ import { ForgeTier } from "./evidence-map.js";
2
+ import { ClassifyTrigger, TypedUnknownSeed } from "./forge-classify.js";
3
+ import { ScopeMapResult } from "./scope-map.js";
4
+ import { IEmbedder } from "@kb/embeddings";
5
+ import { IKnowledgeStore } from "@kb/store";
6
+
7
+ //#region packages/tools/src/forge-ground.d.ts
8
+ interface ForgeGroundOptions {
9
+ /** Task description */
10
+ task: string;
11
+ /** Target files being modified (absolute paths) */
12
+ files: string[];
13
+ /** Root path of the codebase */
14
+ rootPath: string;
15
+ /** Max constraint entries to load (default: 3) */
16
+ maxConstraints?: number;
17
+ /** Force a specific tier (skip auto-classify) */
18
+ forceTier?: ForgeTier;
19
+ /** Task ID for evidence map creation (default: auto-generated from task) */
20
+ taskId?: string;
25
21
  }
26
- export interface ConstraintRef {
27
- source: string;
28
- snippet: string;
29
- relevance: number;
22
+ interface ConstraintRef {
23
+ source: string;
24
+ snippet: string;
25
+ relevance: number;
30
26
  }
31
- export interface ForgeGroundResult {
32
- /** Computed or forced tier */
33
- tier: ForgeTier;
34
- /** Classification triggers (empty if tier was forced) */
35
- classifyTriggers: ClassifyTrigger[];
36
- /** Scope map (relevant files with focus ranges) — null for Floor tier */
37
- scopeMap: ScopeMapResult | null;
38
- /** Typed Unknown Queue seeds */
39
- typedUnknownSeeds: TypedUnknownSeed[];
40
- /** Constraint seed — relevant KB entries from decisions/patterns */
41
- constraints: ConstraintRef[];
42
- /** File summaries for target files */
43
- fileSummaries: Array<{
44
- path: string;
45
- exports: string[];
46
- functions: string[];
47
- lines: number;
48
- error?: string;
49
- }>;
50
- /** Evidence map task ID (created if Standard or Critical) */
51
- evidenceMapTaskId: string | null;
52
- /** Total estimated tokens for this Ground output */
53
- estimatedTokens: number;
54
- /** Ceremony recommendations for this tier */
55
- ceremony: {
56
- ground: string;
57
- build: string;
58
- break: string;
59
- evidenceMap: string;
60
- gate: string;
61
- };
27
+ interface ForgeGroundResult {
28
+ /** Computed or forced tier */
29
+ tier: ForgeTier;
30
+ /** Classification triggers (empty if tier was forced) */
31
+ classifyTriggers: ClassifyTrigger[];
32
+ /** Scope map (relevant files with focus ranges) — null for Floor tier */
33
+ scopeMap: ScopeMapResult | null;
34
+ /** Typed Unknown Queue seeds */
35
+ typedUnknownSeeds: TypedUnknownSeed[];
36
+ /** Constraint seed — relevant KB entries from decisions/patterns */
37
+ constraints: ConstraintRef[];
38
+ /** File summaries for target files */
39
+ fileSummaries: Array<{
40
+ path: string;
41
+ exports: string[];
42
+ functions: string[];
43
+ lines: number;
44
+ error?: string;
45
+ }>;
46
+ /** Evidence map task ID (created if Standard or Critical) */
47
+ evidenceMapTaskId: string | null;
48
+ /** Total estimated tokens for this Ground output */
49
+ estimatedTokens: number;
50
+ /** Ceremony recommendations for this tier */
51
+ ceremony: {
52
+ ground: string;
53
+ build: string;
54
+ break: string;
55
+ evidenceMap: string;
56
+ gate: string;
57
+ };
62
58
  }
63
- export declare function forgeGround(embedder: IEmbedder, store: IKnowledgeStore, options: ForgeGroundOptions): Promise<ForgeGroundResult>;
64
- //# sourceMappingURL=forge-ground.d.ts.map
59
+ declare function forgeGround(embedder: IEmbedder, store: IKnowledgeStore, options: ForgeGroundOptions): Promise<ForgeGroundResult>;
60
+ //#endregion
61
+ export { ConstraintRef, ForgeGroundOptions, ForgeGroundResult, forgeGround };
@@ -1 +1 @@
1
- import{evidenceMap as g}from"./evidence-map.js";import{fileSummary as m}from"./file-summary.js";import{forgeClassify as p}from"./forge-classify.js";import{scopeMap as f}from"./scope-map.js";import{estimateTokens as y}from"./text-utils.js";const S=3,c=200,T={floor:{ground:"Parasitic \u2014 read target file only",build:"Implement directly",break:"Skip",evidenceMap:"Not required",gate:"Self-certify"},standard:{ground:"Scope map + blast radius + constraint seed",build:"TDD \u2014 test first, then implement",break:"Error paths + edge cases",evidenceMap:"3-8 critical-path entries",gate:"YIELD/HOLD evaluation"},critical:{ground:"Full scope map + blast radius + trace + patterns + constraint pack",build:"TDD + contract verification + cross-service validation",break:"Error paths + edge cases + security dimensions + data-flow verification",evidenceMap:"Comprehensive \u2014 all critical-path claims with receipts",gate:"Strict YIELD/HOLD/HARD_BLOCK evaluation"}};async function D(e,r,t){const i=t.maxConstraints??S,n=await k(t),s=await F(t.files);if(n.tier==="floor")return u({tier:n.tier,classifyTriggers:n.classifyTriggers,scopeMap:null,typedUnknownSeeds:n.typedUnknownSeeds,constraints:[],fileSummaries:s,evidenceMapTaskId:null,ceremony:n.ceremony});const[a,o,d]=await Promise.all([R(e,r,t.task,n.tier),w(e,r,t.task,i),h(t.rootPath,t.taskId??C(t.task),n.tier)]);return u({tier:n.tier,classifyTriggers:n.classifyTriggers,scopeMap:a,typedUnknownSeeds:n.typedUnknownSeeds,constraints:o,fileSummaries:s,evidenceMapTaskId:d,ceremony:n.ceremony})}async function k(e){if(e.forceTier)return{tier:e.forceTier,classifyTriggers:[],typedUnknownSeeds:[],ceremony:l(e.forceTier)};try{const r=await p({files:e.files,task:e.task,rootPath:e.rootPath});return{tier:r.tier,classifyTriggers:r.triggers,typedUnknownSeeds:r.typedUnknownSeeds,ceremony:r.ceremony}}catch{return{tier:"standard",classifyTriggers:[],typedUnknownSeeds:[],ceremony:l("standard")}}}async function R(e,r,t,i){try{return await f(e,r,{task:t,maxFiles:i==="critical"?20:10})}catch{return null}}async function w(e,r,t,i){try{const n=`decision pattern convention ${t}`,s=typeof e.embedQuery=="function"?await e.embedQuery(n):await e.embed(n);return(await r.search(s,{limit:i,origin:"curated"})).slice(0,i).map(o=>v(o))}catch{return[]}}async function F(e){return Promise.all(e.map(async r=>b(r)))}async function b(e){try{const r=await m({path:e});return M(r)}catch(r){return{path:e,exports:[],functions:[],lines:0,error:r instanceof Error?r.message:"Unable to summarize file"}}}async function h(e,r,t){try{return g({action:"create",taskId:r,tier:t},e),r}catch{return null}}function v(e){return{source:e.record.sourcePath,snippet:I(e.record.content),relevance:e.score}}function I(e){const r=e.replace(/\s+/g," ").trim();return r.length<=c?r:`${r.slice(0,c-3).trimEnd()}...`}function M(e){return{path:e.path,exports:e.exports,functions:e.functions.map(r=>r.name),lines:e.lines}}function l(e){return{...T[e]}}function u(e){return{...e,estimatedTokens:y(JSON.stringify(e))}}function C(e){const r=e.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/).filter(Boolean).slice(0,5).join("-"),t=Date.now().toString(36);return`${r||"task"}-${t}`}export{D as forgeGround};
1
+ import{estimateTokens as e}from"./text-utils.js";import{evidenceMap as t}from"./evidence-map.js";import{fileSummary as n}from"./file-summary.js";import{forgeClassify as r}from"./forge-classify.js";import{scopeMap as i}from"./scope-map.js";const a={floor:{ground:`Parasitic read target file only`,build:`Implement directly`,break:`Skip`,evidenceMap:`Not required`,gate:`Self-certify`},standard:{ground:`Scope map + blast radius + constraint seed`,build:`TDD test first, then implement`,break:`Error paths + edge cases`,evidenceMap:`3-8 critical-path entries`,gate:`YIELD/HOLD evaluation`},critical:{ground:`Full scope map + blast radius + trace + patterns + constraint pack`,build:`TDD + contract verification + cross-service validation`,break:`Error paths + edge cases + security dimensions + data-flow verification`,evidenceMap:`Comprehensive all critical-path claims with receipts`,gate:`Strict YIELD/HOLD/HARD_BLOCK evaluation`}};async function o(e,t,n){let r=n.maxConstraints??3,i=await s(n),a=await u(n.files);if(i.tier===`floor`)return _({tier:i.tier,classifyTriggers:i.classifyTriggers,scopeMap:null,typedUnknownSeeds:i.typedUnknownSeeds,constraints:[],fileSummaries:a,evidenceMapTaskId:null,ceremony:i.ceremony});let[o,d,p]=await Promise.all([c(e,t,n.task,i.tier),l(e,t,n.task,r),f(n.rootPath,n.taskId??v(n.task),i.tier)]);return _({tier:i.tier,classifyTriggers:i.classifyTriggers,scopeMap:o,typedUnknownSeeds:i.typedUnknownSeeds,constraints:d,fileSummaries:a,evidenceMapTaskId:p,ceremony:i.ceremony})}async function s(e){if(e.forceTier)return{tier:e.forceTier,classifyTriggers:[],typedUnknownSeeds:[],ceremony:g(e.forceTier)};try{let t=await r({files:e.files,task:e.task,rootPath:e.rootPath});return{tier:t.tier,classifyTriggers:t.triggers,typedUnknownSeeds:t.typedUnknownSeeds,ceremony:t.ceremony}}catch{return{tier:`standard`,classifyTriggers:[],typedUnknownSeeds:[],ceremony:g(`standard`)}}}async function c(e,t,n,r){try{return await i(e,t,{task:n,maxFiles:r===`critical`?20:10})}catch{return null}}async function l(e,t,n,r){try{let i=`decision pattern convention ${n}`,a=typeof e.embedQuery==`function`?await e.embedQuery(i):await e.embed(i);return(await t.search(a,{limit:r,origin:`curated`})).slice(0,r).map(e=>p(e))}catch{return[]}}async function u(e){return Promise.all(e.map(async e=>d(e)))}async function d(e){try{return h(await n({path:e}))}catch(t){return{path:e,exports:[],functions:[],lines:0,error:t instanceof Error?t.message:`Unable to summarize file`}}}async function f(e,n,r){try{return t({action:`create`,taskId:n,tier:r},e),n}catch{return null}}function p(e){return{source:e.record.sourcePath,snippet:m(e.record.content),relevance:e.score}}function m(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=200?t:`${t.slice(0,197).trimEnd()}...`}function h(e){return{path:e.path,exports:e.exports,functions:e.functions.map(e=>e.name),lines:e.lines}}function g(e){return{...a[e]}}function _(t){return{...t,estimatedTokens:e(JSON.stringify(t))}}function v(e){let t=e.toLowerCase().replace(/[^a-z0-9\s]/g,` `).split(/\s+/).filter(Boolean).slice(0,5).join(`-`),n=Date.now().toString(36);return`${t||`task`}-${n}`}export{o as forgeGround};
@@ -1,22 +1,24 @@
1
- export interface GitContextOptions {
2
- cwd?: string;
3
- commitCount?: number;
4
- includeDiff?: boolean;
1
+ //#region packages/tools/src/git-context.d.ts
2
+ interface GitContextOptions {
3
+ cwd?: string;
4
+ commitCount?: number;
5
+ includeDiff?: boolean;
5
6
  }
6
- export interface GitContextResult {
7
- branch: string;
8
- status: {
9
- staged: string[];
10
- modified: string[];
11
- untracked: string[];
12
- };
13
- recentCommits: Array<{
14
- hash: string;
15
- message: string;
16
- author: string;
17
- date: string;
18
- }>;
19
- diff?: string;
7
+ interface GitContextResult {
8
+ branch: string;
9
+ status: {
10
+ staged: string[];
11
+ modified: string[];
12
+ untracked: string[];
13
+ };
14
+ recentCommits: Array<{
15
+ hash: string;
16
+ message: string;
17
+ author: string;
18
+ date: string;
19
+ }>;
20
+ diff?: string;
20
21
  }
21
- export declare function gitContext(options?: GitContextOptions): Promise<GitContextResult>;
22
- //# sourceMappingURL=git-context.d.ts.map
22
+ declare function gitContext(options?: GitContextOptions): Promise<GitContextResult>;
23
+ //#endregion
24
+ export { GitContextOptions, GitContextResult, gitContext };
@@ -1,3 +1,3 @@
1
- import{execFile as x}from"node:child_process";import{promisify as w}from"node:util";const C=w(x);async function o(n,t){try{const{stdout:a}=await C("git",n,{cwd:t});return a.toString().trim()}catch{return""}}async function R(n={}){const t=n.cwd??process.cwd(),a=n.commitCount??5,[u,g,l,d]=await Promise.all([o(["rev-parse","--abbrev-ref","HEAD"],t),o(["status","--porcelain"],t),o(["log",`--max-count=${a}`,"--format=%h|%s|%an|%ai"],t),n.includeDiff?o(["diff","--stat","--no-color"],t):Promise.resolve("")]),c=[],f=[],m=[];for(const i of g.split(`
2
- `).filter(Boolean)){const s=i[0],e=i[1],r=i.slice(3).trim();s!==" "&&s!=="?"&&c.push(r),(e==="M"||e==="D")&&f.push(r),s==="?"&&m.push(r)}const p=l.split(`
3
- `).filter(Boolean).map(i=>{const[s,e,r,h]=i.split("|");return{hash:s,message:e,author:r,date:h}});return{branch:u||"unknown",status:{staged:c,modified:f,untracked:m},recentCommits:p,diff:d||void 0}}export{R as gitContext};
1
+ import{execFile as e}from"node:child_process";import{promisify as t}from"node:util";const n=t(e);async function r(e,t){try{let{stdout:r}=await n(`git`,e,{cwd:t,timeout:15e3});return r.toString().trim()}catch{return``}}async function i(e={}){let t=e.cwd??process.cwd(),n=e.commitCount??5,[i,a,o,s]=await Promise.all([r([`rev-parse`,`--abbrev-ref`,`HEAD`],t),r([`status`,`--porcelain`],t),r([`log`,`--max-count=${n}`,`--format=%h|%s|%an|%ai`],t),e.includeDiff?r([`diff`,`--stat`,`--no-color`],t):Promise.resolve(``)]),c=[],l=[],u=[];for(let e of a.split(`
2
+ `).filter(Boolean)){let t=e[0],n=e[1],r=e.slice(3).trim();t!==` `&&t!==`?`&&c.push(r),(n===`M`||n===`D`)&&l.push(r),t===`?`&&u.push(r)}let d=o.split(`
3
+ `).filter(Boolean).map(e=>{let[t,n,r,i]=e.split(`|`);return{hash:t,message:n,author:r,date:i}});return{branch:i||`unknown`,status:{staged:c,modified:l,untracked:u},recentCommits:d,diff:s||void 0}}export{i as gitContext};
@@ -1,89 +1,85 @@
1
- /**
2
- * kb_graph — Knowledge graph query tools.
3
- *
4
- * Query, traverse, and manage the entity-relationship knowledge graph.
5
- * The graph complements vector search with structural reasoning:
6
- * vector search finds similar content, graph traversal finds connected concepts.
7
- */
8
- import type { GraphEdge, GraphNode, GraphStats, GraphTraversalResult, IGraphStore } from '@kb/store';
9
- export interface GraphQueryOptions {
10
- /** Action: query nodes, traverse from a node, get stats, or add data */
11
- action: 'find_nodes' | 'find_edges' | 'neighbors' | 'traverse' | 'stats' | 'add' | 'delete' | 'clear';
12
- /** Node type filter (for find_nodes) */
13
- nodeType?: string;
14
- /** Name pattern (LIKE %pattern%) for find_nodes */
15
- namePattern?: string;
16
- /** Source path filter */
1
+ import { GraphEdge, GraphNode, GraphStats, GraphTraversalResult, IGraphStore } from "@kb/store";
2
+
3
+ //#region packages/tools/src/graph-query.d.ts
4
+ interface GraphQueryOptions {
5
+ /** Action: query nodes, traverse from a node, get stats, or add data */
6
+ action: 'find_nodes' | 'find_edges' | 'neighbors' | 'traverse' | 'stats' | 'add' | 'delete' | 'clear';
7
+ /** Node type filter (for find_nodes) */
8
+ nodeType?: string;
9
+ /** Name pattern (LIKE %pattern%) for find_nodes */
10
+ namePattern?: string;
11
+ /** Source path filter */
12
+ sourcePath?: string;
13
+ /** Node ID for neighbors/traverse/delete */
14
+ nodeId?: string;
15
+ /** Edge type filter */
16
+ edgeType?: string;
17
+ /** From node ID (for find_edges) */
18
+ fromId?: string;
19
+ /** To node ID (for find_edges) */
20
+ toId?: string;
21
+ /** Traversal direction */
22
+ direction?: 'outgoing' | 'incoming' | 'both';
23
+ /** Max traversal depth (default: 2) */
24
+ maxDepth?: number;
25
+ /** Max results (default: 50) */
26
+ limit?: number;
27
+ /** Nodes to add (for action=add) */
28
+ nodes?: Array<{
29
+ id?: string;
30
+ type: string;
31
+ name: string;
32
+ properties?: Record<string, unknown>;
33
+ sourceRecordId?: string;
17
34
  sourcePath?: string;
18
- /** Node ID for neighbors/traverse/delete */
19
- nodeId?: string;
20
- /** Edge type filter */
21
- edgeType?: string;
22
- /** From node ID (for find_edges) */
23
- fromId?: string;
24
- /** To node ID (for find_edges) */
25
- toId?: string;
26
- /** Traversal direction */
27
- direction?: 'outgoing' | 'incoming' | 'both';
28
- /** Max traversal depth (default: 2) */
29
- maxDepth?: number;
30
- /** Max results (default: 50) */
31
- limit?: number;
32
- /** Nodes to add (for action=add) */
33
- nodes?: Array<{
34
- id?: string;
35
- type: string;
36
- name: string;
37
- properties?: Record<string, unknown>;
38
- sourceRecordId?: string;
39
- sourcePath?: string;
40
- }>;
41
- /** Edges to add (for action=add) */
42
- edges?: Array<{
43
- id?: string;
44
- fromId: string;
45
- toId: string;
46
- type: string;
47
- weight?: number;
48
- properties?: Record<string, unknown>;
49
- }>;
35
+ }>;
36
+ /** Edges to add (for action=add) */
37
+ edges?: Array<{
38
+ id?: string;
39
+ fromId: string;
40
+ toId: string;
41
+ type: string;
42
+ weight?: number;
43
+ properties?: Record<string, unknown>;
44
+ }>;
50
45
  }
51
- export interface GraphQueryResult {
52
- action: string;
53
- nodes?: GraphNode[];
54
- edges?: GraphEdge[];
55
- stats?: GraphStats;
56
- nodesAdded?: number;
57
- edgesAdded?: number;
58
- deleted?: number;
59
- summary: string;
46
+ interface GraphQueryResult {
47
+ action: string;
48
+ nodes?: GraphNode[];
49
+ edges?: GraphEdge[];
50
+ stats?: GraphStats;
51
+ nodesAdded?: number;
52
+ edgesAdded?: number;
53
+ deleted?: number;
54
+ summary: string;
60
55
  }
61
- export declare function graphQuery(graphStore: IGraphStore, options: GraphQueryOptions): Promise<GraphQueryResult>;
62
- export interface GraphAugmentOptions {
63
- /** Max graph hops from each vector hit (default: 1) */
64
- hops?: number;
65
- /** Edge type filter for graph expansion */
66
- edgeType?: string;
67
- /** Max graph nodes per vector hit (default: 5) */
68
- maxPerHit?: number;
56
+ declare function graphQuery(graphStore: IGraphStore, options: GraphQueryOptions): Promise<GraphQueryResult>;
57
+ interface GraphAugmentOptions {
58
+ /** Max graph hops from each vector hit (default: 1) */
59
+ hops?: number;
60
+ /** Edge type filter for graph expansion */
61
+ edgeType?: string;
62
+ /** Max graph nodes per vector hit (default: 5) */
63
+ maxPerHit?: number;
69
64
  }
70
- export interface GraphAugmentedResult {
71
- /** Original search result record ID */
72
- recordId: string;
73
- /** Original similarity score */
74
- score: number;
75
- /** Source path of the matched record */
76
- sourcePath: string;
77
- /** Graph nodes connected to this record (via sourceRecordId) */
78
- graphContext: GraphTraversalResult;
65
+ interface GraphAugmentedResult {
66
+ /** Original search result record ID */
67
+ recordId: string;
68
+ /** Original similarity score */
69
+ score: number;
70
+ /** Source path of the matched record */
71
+ sourcePath: string;
72
+ /** Graph nodes connected to this record (via sourceRecordId) */
73
+ graphContext: GraphTraversalResult;
79
74
  }
80
75
  /**
81
76
  * Augment vector search results with graph context.
82
77
  * For each search hit, finds linked graph nodes and traverses their connections.
83
78
  */
84
- export declare function graphAugmentSearch(graphStore: IGraphStore, hits: Array<{
85
- recordId: string;
86
- score: number;
87
- sourcePath: string;
79
+ declare function graphAugmentSearch(graphStore: IGraphStore, hits: Array<{
80
+ recordId: string;
81
+ score: number;
82
+ sourcePath: string;
88
83
  }>, options?: GraphAugmentOptions): Promise<GraphAugmentedResult[]>;
89
- //# sourceMappingURL=graph-query.d.ts.map
84
+ //#endregion
85
+ export { GraphAugmentOptions, GraphAugmentedResult, GraphQueryOptions, GraphQueryResult, graphAugmentSearch, graphQuery };