@vpxa/kb 0.1.13 → 0.1.15

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 (383) hide show
  1. package/README.md +8 -2
  2. package/package.json +10 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -20
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +6 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -27
  6. package/packages/analyzers/dist/dependency-analyzer.js +7 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -8
  8. package/packages/analyzers/dist/diagram-generator.js +3 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -35
  10. package/packages/analyzers/dist/entry-point-analyzer.js +5 -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 +29 -25
  14. package/packages/analyzers/dist/knowledge-producer.js +16 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -10
  16. package/packages/analyzers/dist/pattern-analyzer.js +3 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -12
  18. package/packages/analyzers/dist/regex-call-graph.js +2 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -9
  20. package/packages/analyzers/dist/structure-analyzer.js +3 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +12 -8
  22. package/packages/analyzers/dist/symbol-analyzer.js +8 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -13
  24. package/packages/analyzers/dist/ts-call-graph.js +2 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -79
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +13 -10
  28. package/packages/chunker/dist/call-graph-extractor.js +2 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +6 -2
  30. package/packages/chunker/dist/chunker-factory.js +2 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -4
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -12
  34. package/packages/chunker/dist/code-chunker.js +12 -14
  35. package/packages/chunker/dist/generic-chunker.d.ts +14 -10
  36. package/packages/chunker/dist/generic-chunker.js +6 -5
  37. package/packages/chunker/dist/index.d.ts +8 -8
  38. package/packages/chunker/dist/index.js +1 -1
  39. package/packages/chunker/dist/markdown-chunker.d.ts +16 -12
  40. package/packages/chunker/dist/markdown-chunker.js +4 -10
  41. package/packages/chunker/dist/treesitter-chunker.d.ts +28 -31
  42. package/packages/chunker/dist/treesitter-chunker.js +7 -8
  43. package/packages/cli/dist/commands/analyze.d.ts +6 -2
  44. package/packages/cli/dist/commands/analyze.js +3 -3
  45. package/packages/cli/dist/commands/context-cmds.d.ts +6 -2
  46. package/packages/cli/dist/commands/context-cmds.js +2 -1
  47. package/packages/cli/dist/commands/environment.d.ts +6 -2
  48. package/packages/cli/dist/commands/environment.js +2 -2
  49. package/packages/cli/dist/commands/execution.d.ts +6 -2
  50. package/packages/cli/dist/commands/execution.js +2 -1
  51. package/packages/cli/dist/commands/graph.d.ts +6 -2
  52. package/packages/cli/dist/commands/graph.js +6 -6
  53. package/packages/cli/dist/commands/init/adapters.d.ts +27 -0
  54. package/packages/cli/dist/commands/init/adapters.js +2 -0
  55. package/packages/cli/dist/commands/init/config.d.ts +11 -0
  56. package/packages/cli/dist/commands/init/config.js +4 -0
  57. package/packages/cli/dist/commands/init/curated.d.ts +8 -0
  58. package/packages/cli/dist/commands/init/curated.js +2 -0
  59. package/packages/cli/dist/commands/init/index.d.ts +23 -0
  60. package/packages/cli/dist/commands/init/index.js +3 -0
  61. package/packages/cli/dist/commands/init/scaffold.d.ts +24 -0
  62. package/packages/cli/dist/commands/init/scaffold.js +2 -0
  63. package/packages/cli/dist/commands/init/templates.d.ts +10 -0
  64. package/packages/cli/dist/commands/init/templates.js +302 -0
  65. package/packages/cli/dist/commands/init.d.ts +8 -3
  66. package/packages/cli/dist/commands/init.js +120 -123
  67. package/packages/cli/dist/commands/knowledge.d.ts +6 -2
  68. package/packages/cli/dist/commands/knowledge.js +2 -1
  69. package/packages/cli/dist/commands/search.d.ts +6 -2
  70. package/packages/cli/dist/commands/search.js +2 -8
  71. package/packages/cli/dist/commands/system.d.ts +6 -2
  72. package/packages/cli/dist/commands/system.js +5 -7
  73. package/packages/cli/dist/commands/workspace.d.ts +6 -2
  74. package/packages/cli/dist/commands/workspace.js +2 -2
  75. package/packages/cli/dist/context.d.ts +7 -4
  76. package/packages/cli/dist/context.js +2 -1
  77. package/packages/cli/dist/helpers.d.ts +51 -47
  78. package/packages/cli/dist/helpers.js +6 -5
  79. package/packages/cli/dist/index.d.ts +4 -1
  80. package/packages/cli/dist/index.js +3 -2
  81. package/packages/cli/dist/kb-init.d.ts +48 -50
  82. package/packages/cli/dist/kb-init.js +2 -1
  83. package/packages/cli/dist/types.d.ts +8 -5
  84. package/packages/cli/dist/types.js +1 -0
  85. package/packages/core/dist/constants.d.ts +36 -33
  86. package/packages/core/dist/constants.js +2 -1
  87. package/packages/core/dist/content-detector.d.ts +8 -7
  88. package/packages/core/dist/content-detector.js +2 -1
  89. package/packages/core/dist/errors.d.ts +15 -12
  90. package/packages/core/dist/errors.js +2 -1
  91. package/packages/core/dist/index.d.ts +6 -6
  92. package/packages/core/dist/index.js +1 -1
  93. package/packages/core/dist/logger.d.ts +16 -7
  94. package/packages/core/dist/logger.js +2 -1
  95. package/packages/core/dist/types.d.ts +107 -91
  96. package/packages/core/dist/types.js +2 -0
  97. package/packages/embeddings/dist/embedder.interface.d.ts +22 -19
  98. package/packages/embeddings/dist/embedder.interface.js +1 -0
  99. package/packages/embeddings/dist/index.d.ts +3 -3
  100. package/packages/embeddings/dist/index.js +1 -1
  101. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -22
  102. package/packages/embeddings/dist/onnx-embedder.js +2 -1
  103. package/packages/enterprise-bridge/dist/cache.d.ts +29 -0
  104. package/packages/enterprise-bridge/dist/cache.js +2 -0
  105. package/packages/enterprise-bridge/dist/er-client.d.ts +38 -0
  106. package/packages/enterprise-bridge/dist/er-client.js +2 -0
  107. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +63 -0
  108. package/packages/enterprise-bridge/dist/evolution-collector.js +2 -0
  109. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  110. package/packages/enterprise-bridge/dist/index.js +1 -0
  111. package/packages/enterprise-bridge/dist/policy-store.d.ts +46 -0
  112. package/packages/enterprise-bridge/dist/policy-store.js +2 -0
  113. package/packages/enterprise-bridge/dist/push-adapter.d.ts +24 -0
  114. package/packages/enterprise-bridge/dist/push-adapter.js +2 -0
  115. package/packages/enterprise-bridge/dist/result-merger.d.ts +15 -0
  116. package/packages/enterprise-bridge/dist/result-merger.js +2 -0
  117. package/packages/enterprise-bridge/dist/types.d.ts +82 -0
  118. package/packages/enterprise-bridge/dist/types.js +2 -0
  119. package/packages/indexer/dist/file-hasher.d.ts +5 -2
  120. package/packages/indexer/dist/file-hasher.js +2 -1
  121. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -20
  122. package/packages/indexer/dist/filesystem-crawler.js +2 -1
  123. package/packages/indexer/dist/graph-extractor.d.ts +9 -12
  124. package/packages/indexer/dist/graph-extractor.js +2 -1
  125. package/packages/indexer/dist/incremental-indexer.d.ts +49 -43
  126. package/packages/indexer/dist/incremental-indexer.js +2 -1
  127. package/packages/indexer/dist/index.d.ts +5 -5
  128. package/packages/indexer/dist/index.js +1 -1
  129. package/packages/server/dist/api.d.ts +3 -8
  130. package/packages/server/dist/api.js +1 -1
  131. package/packages/server/dist/config.d.ts +6 -2
  132. package/packages/server/dist/config.js +2 -1
  133. package/packages/server/dist/curated-manager.d.ts +79 -76
  134. package/packages/server/dist/curated-manager.js +6 -10
  135. package/packages/server/dist/index.d.ts +1 -2
  136. package/packages/server/dist/index.js +2 -1
  137. package/packages/server/dist/replay-interceptor.d.ts +6 -6
  138. package/packages/server/dist/replay-interceptor.js +2 -1
  139. package/packages/server/dist/resources/resources.d.ts +7 -3
  140. package/packages/server/dist/resources/resources.js +3 -2
  141. package/packages/server/dist/server.d.ts +34 -24
  142. package/packages/server/dist/server.js +2 -1
  143. package/packages/server/dist/tools/analyze.tools.d.ts +14 -10
  144. package/packages/server/dist/tools/analyze.tools.js +2 -3
  145. package/packages/server/dist/tools/audit.tool.d.ts +8 -4
  146. package/packages/server/dist/tools/audit.tool.js +2 -4
  147. package/packages/server/dist/tools/bridge.tools.d.ts +35 -0
  148. package/packages/server/dist/tools/bridge.tools.js +16 -0
  149. package/packages/server/dist/tools/evolution.tools.d.ts +8 -0
  150. package/packages/server/dist/tools/evolution.tools.js +6 -0
  151. package/packages/server/dist/tools/forge.tools.d.ts +13 -11
  152. package/packages/server/dist/tools/forge.tools.js +11 -13
  153. package/packages/server/dist/tools/forget.tool.d.ts +7 -3
  154. package/packages/server/dist/tools/forget.tool.js +2 -7
  155. package/packages/server/dist/tools/graph.tool.d.ts +7 -3
  156. package/packages/server/dist/tools/graph.tool.js +5 -5
  157. package/packages/server/dist/tools/list.tool.d.ts +7 -3
  158. package/packages/server/dist/tools/list.tool.js +3 -8
  159. package/packages/server/dist/tools/lookup.tool.d.ts +7 -3
  160. package/packages/server/dist/tools/lookup.tool.js +3 -9
  161. package/packages/server/dist/tools/onboard.tool.d.ts +8 -4
  162. package/packages/server/dist/tools/onboard.tool.js +3 -2
  163. package/packages/server/dist/tools/policy.tools.d.ts +8 -0
  164. package/packages/server/dist/tools/policy.tools.js +3 -0
  165. package/packages/server/dist/tools/produce.tool.d.ts +6 -2
  166. package/packages/server/dist/tools/produce.tool.js +3 -2
  167. package/packages/server/dist/tools/read.tool.d.ts +7 -3
  168. package/packages/server/dist/tools/read.tool.js +3 -6
  169. package/packages/server/dist/tools/reindex.tool.d.ts +10 -6
  170. package/packages/server/dist/tools/reindex.tool.js +3 -2
  171. package/packages/server/dist/tools/remember.tool.d.ts +8 -3
  172. package/packages/server/dist/tools/remember.tool.js +4 -5
  173. package/packages/server/dist/tools/replay.tool.d.ts +6 -2
  174. package/packages/server/dist/tools/replay.tool.js +3 -6
  175. package/packages/server/dist/tools/search.tool.d.ts +10 -4
  176. package/packages/server/dist/tools/search.tool.js +7 -22
  177. package/packages/server/dist/tools/status.tool.d.ts +7 -3
  178. package/packages/server/dist/tools/status.tool.js +3 -3
  179. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -34
  180. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  181. package/packages/server/dist/tools/update.tool.d.ts +7 -3
  182. package/packages/server/dist/tools/update.tool.js +2 -6
  183. package/packages/server/dist/tools/utility.tools.d.ts +15 -14
  184. package/packages/server/dist/tools/utility.tools.js +11 -23
  185. package/packages/server/dist/version-check.d.ts +5 -1
  186. package/packages/server/dist/version-check.js +2 -1
  187. package/packages/store/dist/graph-store.interface.d.ts +89 -86
  188. package/packages/store/dist/graph-store.interface.js +1 -0
  189. package/packages/store/dist/index.d.ts +6 -6
  190. package/packages/store/dist/index.js +1 -1
  191. package/packages/store/dist/lance-store.d.ts +37 -30
  192. package/packages/store/dist/lance-store.js +2 -1
  193. package/packages/store/dist/sqlite-graph-store.d.ts +43 -46
  194. package/packages/store/dist/sqlite-graph-store.js +14 -13
  195. package/packages/store/dist/store-factory.d.ts +11 -7
  196. package/packages/store/dist/store-factory.js +2 -1
  197. package/packages/store/dist/store.interface.d.ts +47 -46
  198. package/packages/store/dist/store.interface.js +1 -0
  199. package/packages/tools/dist/audit.d.ts +61 -61
  200. package/packages/tools/dist/audit.js +5 -5
  201. package/packages/tools/dist/batch.d.ts +20 -17
  202. package/packages/tools/dist/batch.js +2 -1
  203. package/packages/tools/dist/changelog.d.ts +29 -26
  204. package/packages/tools/dist/changelog.js +3 -2
  205. package/packages/tools/dist/check.d.ts +42 -38
  206. package/packages/tools/dist/check.js +3 -2
  207. package/packages/tools/dist/checkpoint.d.ts +17 -14
  208. package/packages/tools/dist/checkpoint.js +2 -2
  209. package/packages/tools/dist/codemod.d.ts +35 -32
  210. package/packages/tools/dist/codemod.js +3 -2
  211. package/packages/tools/dist/compact.d.ts +34 -37
  212. package/packages/tools/dist/compact.js +3 -2
  213. package/packages/tools/dist/data-transform.d.ts +10 -7
  214. package/packages/tools/dist/data-transform.js +2 -1
  215. package/packages/tools/dist/dead-symbols.d.ts +29 -25
  216. package/packages/tools/dist/dead-symbols.js +3 -2
  217. package/packages/tools/dist/delegate.d.ts +26 -23
  218. package/packages/tools/dist/delegate.js +2 -5
  219. package/packages/tools/dist/diff-parse.d.ts +24 -21
  220. package/packages/tools/dist/diff-parse.js +4 -3
  221. package/packages/tools/dist/digest.d.ts +43 -45
  222. package/packages/tools/dist/digest.js +5 -5
  223. package/packages/tools/dist/encode.d.ts +11 -8
  224. package/packages/tools/dist/encode.js +2 -1
  225. package/packages/tools/dist/env-info.d.ts +25 -22
  226. package/packages/tools/dist/env-info.js +2 -1
  227. package/packages/tools/dist/eval.d.ts +13 -10
  228. package/packages/tools/dist/eval.js +3 -3
  229. package/packages/tools/dist/evidence-map.d.ts +64 -61
  230. package/packages/tools/dist/evidence-map.js +3 -3
  231. package/packages/tools/dist/file-cache.d.ts +42 -0
  232. package/packages/tools/dist/file-cache.js +4 -0
  233. package/packages/tools/dist/file-summary.d.ts +34 -29
  234. package/packages/tools/dist/file-summary.js +3 -2
  235. package/packages/tools/dist/file-walk.d.ts +6 -3
  236. package/packages/tools/dist/file-walk.js +2 -1
  237. package/packages/tools/dist/find-examples.d.ts +26 -21
  238. package/packages/tools/dist/find-examples.js +4 -3
  239. package/packages/tools/dist/find.d.ts +39 -40
  240. package/packages/tools/dist/find.js +2 -1
  241. package/packages/tools/dist/forge-classify.d.ts +35 -38
  242. package/packages/tools/dist/forge-classify.js +3 -2
  243. package/packages/tools/dist/forge-ground.d.ts +58 -60
  244. package/packages/tools/dist/forge-ground.js +2 -1
  245. package/packages/tools/dist/git-context.d.ts +22 -19
  246. package/packages/tools/dist/git-context.js +4 -3
  247. package/packages/tools/dist/graph-query.d.ts +75 -78
  248. package/packages/tools/dist/graph-query.js +2 -1
  249. package/packages/tools/dist/guide.d.ts +14 -11
  250. package/packages/tools/dist/guide.js +2 -1
  251. package/packages/tools/dist/health.d.ts +13 -10
  252. package/packages/tools/dist/health.js +3 -2
  253. package/packages/tools/dist/http-request.d.ts +20 -17
  254. package/packages/tools/dist/http-request.js +2 -1
  255. package/packages/tools/dist/index.d.ts +54 -53
  256. package/packages/tools/dist/index.js +1 -1
  257. package/packages/tools/dist/lane.d.ts +28 -25
  258. package/packages/tools/dist/lane.js +7 -7
  259. package/packages/tools/dist/measure.d.ts +32 -29
  260. package/packages/tools/dist/measure.js +3 -2
  261. package/packages/tools/dist/onboard.d.ts +29 -26
  262. package/packages/tools/dist/onboard.js +18 -41
  263. package/packages/tools/dist/parse-output.d.ts +48 -45
  264. package/packages/tools/dist/parse-output.js +3 -2
  265. package/packages/tools/dist/path-resolver.d.ts +4 -1
  266. package/packages/tools/dist/path-resolver.js +2 -1
  267. package/packages/tools/dist/process-manager.d.ts +18 -15
  268. package/packages/tools/dist/process-manager.js +2 -1
  269. package/packages/tools/dist/queue.d.ts +28 -25
  270. package/packages/tools/dist/queue.js +2 -2
  271. package/packages/tools/dist/regex-test.d.ts +26 -23
  272. package/packages/tools/dist/regex-test.js +2 -1
  273. package/packages/tools/dist/rename.d.ts +28 -25
  274. package/packages/tools/dist/rename.js +3 -2
  275. package/packages/tools/dist/replay.d.ts +32 -29
  276. package/packages/tools/dist/replay.js +5 -6
  277. package/packages/tools/dist/response-envelope.d.ts +32 -29
  278. package/packages/tools/dist/response-envelope.js +2 -1
  279. package/packages/tools/dist/schema-validate.d.ts +15 -12
  280. package/packages/tools/dist/schema-validate.js +2 -1
  281. package/packages/tools/dist/scope-map.d.ts +45 -47
  282. package/packages/tools/dist/scope-map.js +2 -1
  283. package/packages/tools/dist/snippet.d.ts +26 -24
  284. package/packages/tools/dist/snippet.js +2 -1
  285. package/packages/tools/dist/stash.d.ts +13 -10
  286. package/packages/tools/dist/stash.js +2 -2
  287. package/packages/tools/dist/stratum-card.d.ts +27 -27
  288. package/packages/tools/dist/stratum-card.js +4 -5
  289. package/packages/tools/dist/symbol.d.ts +29 -25
  290. package/packages/tools/dist/symbol.js +4 -3
  291. package/packages/tools/dist/test-run.d.ts +19 -15
  292. package/packages/tools/dist/test-run.js +3 -2
  293. package/packages/tools/dist/text-utils.d.ts +6 -3
  294. package/packages/tools/dist/text-utils.js +3 -2
  295. package/packages/tools/dist/time-utils.d.ts +15 -12
  296. package/packages/tools/dist/time-utils.js +2 -1
  297. package/packages/tools/dist/trace.d.ts +24 -20
  298. package/packages/tools/dist/trace.js +3 -2
  299. package/packages/tools/dist/truncation.d.ts +6 -3
  300. package/packages/tools/dist/truncation.js +8 -14
  301. package/packages/tools/dist/watch.d.ts +28 -25
  302. package/packages/tools/dist/watch.js +2 -1
  303. package/packages/tools/dist/web-fetch.d.ts +35 -32
  304. package/packages/tools/dist/web-fetch.js +7 -12
  305. package/packages/tools/dist/web-search.d.ts +16 -13
  306. package/packages/tools/dist/web-search.js +2 -1
  307. package/packages/tools/dist/workset.d.ts +19 -16
  308. package/packages/tools/dist/workset.js +2 -2
  309. package/packages/tui/dist/App-BAlmxCCw.js +3 -0
  310. package/packages/tui/dist/App.d.ts +11 -5
  311. package/packages/tui/dist/App.js +1 -450
  312. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +3 -0
  313. package/packages/tui/dist/LogPanel-DVB8Sv46.js +4 -0
  314. package/packages/tui/dist/SearchPanel-DREo6zgt.js +3 -0
  315. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +3 -0
  316. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  317. package/packages/tui/dist/devtools-DUyj952l.js +8 -0
  318. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +29 -0
  319. package/packages/tui/dist/index-B9VpfVPP.d.ts +14 -0
  320. package/packages/tui/dist/index.d.ts +3 -19
  321. package/packages/tui/dist/index.js +2 -476
  322. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +317 -0
  323. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -5
  324. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  325. package/packages/tui/dist/panels/LogPanel.d.ts +7 -2
  326. package/packages/tui/dist/panels/LogPanel.js +1 -449
  327. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -7
  328. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  329. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -5
  330. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  331. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +151 -0
  332. package/scaffold/adapters/claude-code.mjs +20 -0
  333. package/scaffold/adapters/copilot.mjs +320 -0
  334. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +14 -0
  335. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +14 -0
  336. package/scaffold/copilot/agents/Code-Reviewer-Alpha.agent.md +12 -0
  337. package/scaffold/copilot/agents/Code-Reviewer-Beta.agent.md +12 -0
  338. package/scaffold/copilot/agents/Debugger.agent.md +31 -0
  339. package/scaffold/copilot/agents/Documenter.agent.md +35 -0
  340. package/scaffold/copilot/agents/Explorer.agent.md +50 -0
  341. package/scaffold/copilot/agents/Frontend.agent.md +29 -0
  342. package/scaffold/copilot/agents/Implementer.agent.md +31 -0
  343. package/scaffold/copilot/agents/Orchestrator.agent.md +96 -0
  344. package/scaffold/copilot/agents/Planner.agent.md +45 -0
  345. package/scaffold/copilot/agents/README.md +57 -0
  346. package/scaffold/copilot/agents/Refactor.agent.md +30 -0
  347. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +12 -0
  348. package/scaffold/copilot/agents/Researcher-Beta.agent.md +12 -0
  349. package/scaffold/copilot/agents/Researcher-Delta.agent.md +12 -0
  350. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +12 -0
  351. package/scaffold/copilot/agents/Security.agent.md +42 -0
  352. package/scaffold/copilot/agents/_shared/adr-protocol.md +91 -0
  353. package/scaffold/copilot/agents/_shared/architect-reviewer-base.md +50 -0
  354. package/scaffold/copilot/agents/_shared/code-agent-base.md +70 -0
  355. package/scaffold/copilot/agents/_shared/code-reviewer-base.md +54 -0
  356. package/scaffold/copilot/agents/_shared/decision-protocol.md +27 -0
  357. package/scaffold/copilot/agents/_shared/forge-protocol.md +46 -0
  358. package/scaffold/copilot/agents/_shared/researcher-base.md +61 -0
  359. package/scaffold/copilot/agents/templates/adr-template.md +27 -0
  360. package/scaffold/copilot/agents/templates/execution-state.md +25 -0
  361. package/scaffold/copilot/prompts/ask.prompt.md +20 -0
  362. package/scaffold/copilot/prompts/debug.prompt.md +25 -0
  363. package/scaffold/copilot/prompts/design.prompt.md +22 -0
  364. package/scaffold/copilot/prompts/implement.prompt.md +26 -0
  365. package/scaffold/copilot/prompts/plan.prompt.md +24 -0
  366. package/scaffold/copilot/prompts/review.prompt.md +31 -0
  367. package/scaffold/definitions/agents.mjs +165 -0
  368. package/scaffold/definitions/bodies.mjs +292 -0
  369. package/scaffold/definitions/hooks.mjs +43 -0
  370. package/scaffold/definitions/models.mjs +56 -0
  371. package/scaffold/definitions/plugins.mjs +24 -0
  372. package/scaffold/definitions/prompts.mjs +145 -0
  373. package/scaffold/definitions/protocols.mjs +322 -0
  374. package/scaffold/definitions/tools.mjs +176 -0
  375. package/scaffold/generate.mjs +74 -0
  376. package/skills/brainstorming/SKILL.md +259 -0
  377. package/skills/brainstorming/scripts/frame-template.html +365 -0
  378. package/skills/brainstorming/scripts/helper.js +216 -0
  379. package/skills/brainstorming/scripts/server.cjs +9 -0
  380. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  381. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  382. package/skills/brainstorming/visual-companion.md +430 -0
  383. package/skills/knowledge-base/SKILL.md +22 -9
@@ -1,41 +1,44 @@
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
+ declare function errorResponse(tool: string, error: KBError, durationMs: number): KBResponse<never>;
42
+ //#endregion
43
+ export { KBError, KBErrorCode, KBNextHint, KBResponse, KBResponseMeta, errorResponse, okResponse };
41
44
  //# sourceMappingURL=response-envelope.d.ts.map
@@ -1 +1,2 @@
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};
2
+ //# sourceMappingURL=response-envelope.js.map
@@ -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,21 @@
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
+ declare function schemaValidate(options: SchemaValidateOptions): SchemaValidateResult;
24
+ //#endregion
25
+ export { SchemaValidateOptions, SchemaValidateResult, ValidationError, schemaValidate };
23
26
  //# sourceMappingURL=schema-validate.d.ts.map
@@ -1 +1,2 @@
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};
2
+ //# sourceMappingURL=schema-validate.js.map
@@ -1,54 +1,52 @@
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>;
49
+ declare function scopeMap(embedder: IEmbedder, store: IKnowledgeStore, options: ScopeMapOptions): Promise<ScopeMapResult>;
50
+ //#endregion
51
+ export { ScopeMapEntry, ScopeMapOptions, ScopeMapResult, scopeMap };
54
52
  //# sourceMappingURL=scope-map.d.ts.map
@@ -1 +1,2 @@
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};
2
+ //# sourceMappingURL=scope-map.js.map
@@ -1,34 +1,36 @@
1
+ //#region packages/tools/src/snippet.d.ts
1
2
  /**
2
3
  * kb_snippet — Persistent code template storage with search.
3
4
  */
4
- export interface Snippet {
5
- name: string;
6
- language: string;
7
- code: string;
8
- tags: string[];
9
- created: string;
10
- updated: string;
5
+ interface Snippet {
6
+ name: string;
7
+ language: string;
8
+ code: string;
9
+ tags: string[];
10
+ created: string;
11
+ updated: string;
11
12
  }
12
- export type SnippetAction = 'save' | 'get' | 'list' | 'search' | 'delete';
13
- export interface SnippetOptions {
14
- action: SnippetAction;
15
- name?: string;
16
- language?: string;
17
- code?: string;
18
- tags?: string[];
19
- query?: string;
13
+ type SnippetAction = 'save' | 'get' | 'list' | 'search' | 'delete';
14
+ interface SnippetOptions {
15
+ action: SnippetAction;
16
+ name?: string;
17
+ language?: string;
18
+ code?: string;
19
+ tags?: string[];
20
+ query?: string;
20
21
  }
21
- export type SnippetResult = Snippet | {
22
- snippets: SnippetSummary[];
22
+ type SnippetResult = Snippet | {
23
+ snippets: SnippetSummary[];
23
24
  } | {
24
- deleted: boolean;
25
+ deleted: boolean;
25
26
  };
26
27
  interface SnippetSummary {
27
- name: string;
28
- language: string;
29
- tags: string[];
30
- updated: string;
28
+ name: string;
29
+ language: string;
30
+ tags: string[];
31
+ updated: string;
31
32
  }
32
- export declare function snippet(options: SnippetOptions): SnippetResult;
33
- export {};
33
+ declare function snippet(options: SnippetOptions): SnippetResult;
34
+ //#endregion
35
+ export { Snippet, SnippetAction, SnippetOptions, SnippetResult, snippet };
34
36
  //# sourceMappingURL=snippet.d.ts.map
@@ -1 +1,2 @@
1
- import{existsSync as p,mkdirSync as f,readdirSync as l,readFileSync as u,unlinkSync as m,writeFileSync as S}from"node:fs";import{join as a}from"node:path";const o=()=>a(process.cwd(),".kb-state","snippets");function d(){const e=o();return p(e)||f(e,{recursive:!0}),e}function g(e){const n=e.replace(/[^a-zA-Z0-9_-]/g,"_");if(!n)throw new Error("Invalid snippet name");return n}function h(e){switch(e.action){case"save":{if(!e.name||!e.code)throw new Error("name and code required for save");const n=d(),s=g(e.name),i=a(n,`${s}.json`),r=p(i)?JSON.parse(u(i,"utf8")):null,t=new Date().toISOString(),c={name:e.name,language:e.language??"text",code:e.code,tags:e.tags??[],created:r?.created??t,updated:t};return S(i,JSON.stringify(c,null,2)),c}case"get":{if(!e.name)throw new Error("name required for get");const n=a(o(),`${g(e.name)}.json`);if(!p(n))throw new Error(`Snippet not found: ${e.name}`);return JSON.parse(u(n,"utf8"))}case"list":{const n=d();return{snippets:l(n).filter(r=>r.endsWith(".json")).map(r=>{const t=JSON.parse(u(a(n,r),"utf8"));return{name:t.name,language:t.language,tags:t.tags,updated:t.updated}})}}case"search":{if(!e.query)throw new Error("query required for search");const n=e.query.toLowerCase(),s=d();return{snippets:l(s).filter(t=>t.endsWith(".json")).map(t=>JSON.parse(u(a(s,t),"utf8"))).filter(t=>t.name.toLowerCase().includes(n)||t.tags.some(c=>c.toLowerCase().includes(n))||t.language.toLowerCase().includes(n)||t.code.toLowerCase().includes(n)).map(t=>({name:t.name,language:t.language,tags:t.tags,updated:t.updated}))}}case"delete":{if(!e.name)throw new Error("name required for delete");const n=a(o(),`${g(e.name)}.json`);return p(n)?(m(n),{deleted:!0}):{deleted:!1}}default:throw new Error(`Unknown action: ${e.action}`)}}export{h as snippet};
1
+ import{join as e}from"node:path";import{existsSync as t,mkdirSync as n,readFileSync as r,readdirSync as i,unlinkSync as a,writeFileSync as o}from"node:fs";const s=()=>e(process.cwd(),`.kb-state`,`snippets`);function c(){let e=s();return t(e)||n(e,{recursive:!0}),e}function l(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);if(!t)throw Error(`Invalid snippet name`);return t}function u(n){switch(n.action){case`save`:{if(!n.name||!n.code)throw Error(`name and code required for save`);let i=e(c(),`${l(n.name)}.json`),a=null;if(t(i))try{a=JSON.parse(r(i,`utf8`))}catch{a=null}let s=new Date().toISOString(),u={name:n.name,language:n.language??`text`,code:n.code,tags:n.tags??[],created:a?.created??s,updated:s};return o(i,JSON.stringify(u,null,2)),u}case`get`:{if(!n.name)throw Error(`name required for get`);let i=e(s(),`${l(n.name)}.json`);if(!t(i))throw Error(`Snippet not found: ${n.name}`);try{return JSON.parse(r(i,`utf8`))}catch{throw Error(`Snippet corrupted: ${n.name}`)}}case`list`:{let t=c();return{snippets:i(t).filter(e=>e.endsWith(`.json`)).flatMap(n=>{try{let i=JSON.parse(r(e(t,n),`utf8`));return[{name:i.name,language:i.language,tags:i.tags,updated:i.updated}]}catch{return[]}})}}case`search`:{if(!n.query)throw Error(`query required for search`);let t=n.query.toLowerCase(),a=c();return{snippets:i(a).filter(e=>e.endsWith(`.json`)).flatMap(t=>{try{return[JSON.parse(r(e(a,t),`utf8`))]}catch{return[]}}).filter(e=>e.name.toLowerCase().includes(t)||e.tags.some(e=>e.toLowerCase().includes(t))||e.language.toLowerCase().includes(t)||e.code.toLowerCase().includes(t)).map(e=>({name:e.name,language:e.language,tags:e.tags,updated:e.updated}))}}case`delete`:{if(!n.name)throw Error(`name required for delete`);let r=e(s(),`${l(n.name)}.json`);return t(r)?(a(r),{deleted:!0}):{deleted:!1}}default:throw Error(`Unknown action: ${n.action}`)}}export{u as snippet};
2
+ //# sourceMappingURL=snippet.js.map
@@ -1,12 +1,15 @@
1
- export interface StashEntry {
2
- key: string;
3
- value: unknown;
4
- type: string;
5
- storedAt: string;
1
+ //#region packages/tools/src/stash.d.ts
2
+ interface StashEntry {
3
+ key: string;
4
+ value: unknown;
5
+ type: string;
6
+ storedAt: string;
6
7
  }
7
- export declare function stashSet(key: string, value: unknown, cwd?: string): StashEntry;
8
- export declare function stashGet(key: string, cwd?: string): StashEntry | undefined;
9
- export declare function stashList(cwd?: string): StashEntry[];
10
- export declare function stashDelete(key: string, cwd?: string): boolean;
11
- export declare function stashClear(cwd?: string): number;
8
+ declare function stashSet(key: string, value: unknown, cwd?: string): StashEntry;
9
+ declare function stashGet(key: string, cwd?: string): StashEntry | undefined;
10
+ declare function stashList(cwd?: string): StashEntry[];
11
+ declare function stashDelete(key: string, cwd?: string): boolean;
12
+ declare function stashClear(cwd?: string): number;
13
+ //#endregion
14
+ export { StashEntry, stashClear, stashDelete, stashGet, stashList, stashSet };
12
15
  //# sourceMappingURL=stash.d.ts.map
@@ -1,2 +1,2 @@
1
- import{existsSync as a,mkdirSync as u,readFileSync as h,writeFileSync as S}from"node:fs";import{dirname as g,resolve as f}from"node:path";const y=".kb-state",p="stash.json";function c(t){const n=t??process.cwd();return f(n,y,p)}function e(t){const n=c(t);if(!a(n))return{};const r=h(n,"utf-8");return JSON.parse(r)}function o(t,n){const r=c(n),s=g(r);a(s)||u(s,{recursive:!0}),S(r,`${JSON.stringify(t,null,2)}
2
- `,"utf-8")}function E(t,n,r){const s=e(r),i={key:t,value:n,type:typeof n,storedAt:new Date().toISOString()};return s[t]=i,o(s,r),i}function m(t,n){return e(n)[t]}function x(t){return Object.values(e(t))}function b(t,n){const r=e(n);return t in r?(delete r[t],o(r,n),!0):!1}function v(t){const n=e(t),r=Object.keys(n).length;return o({},t),r}export{v as stashClear,b as stashDelete,m as stashGet,x as stashList,E as stashSet};
1
+ import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";function o(e){return t(e??process.cwd(),`.kb-state`,`stash.json`)}function s(e){let t=o(e);if(!n(t))return{};try{let e=i(t,`utf-8`);return JSON.parse(e)}catch{return{}}}function c(t,i){let s=o(i),c=e(s);n(c)||r(c,{recursive:!0}),a(s,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function l(e,t,n){let r=s(n),i={key:e,value:t,type:typeof t,storedAt:new Date().toISOString()};return r[e]=i,c(r,n),i}function u(e,t){return s(t)[e]}function d(e){return Object.values(s(e))}function f(e,t){let n=s(t);return e in n?(delete n[e],c(n,t),!0):!1}function p(e){let t=s(e),n=Object.keys(t).length;return c({},e),n}export{p as stashClear,f as stashDelete,u as stashGet,d as stashList,l as stashSet};
2
+ //# sourceMappingURL=stash.js.map
@@ -1,31 +1,31 @@
1
- /**
2
- * kb_stratum_card STRATUM T1/T2 context card generator.
3
- *
4
- * Generates compact context cards from files. T1 = structural metadata only
5
- * (~100 tokens/file). T2 = T1 + compressed content (~300 tokens/file).
6
- * Uses file-summary for structure and embedder for T2 content scoring.
7
- */
8
- import type { IEmbedder } from '@kb/embeddings';
9
- export interface StratumCardOptions {
10
- files: string[];
11
- query: string;
12
- tier?: 'T1' | 'T2';
13
- maxContentChars?: number;
1
+ import { FileCache } from "./file-cache.js";
2
+ import { IEmbedder } from "@kb/embeddings";
3
+
4
+ //#region packages/tools/src/stratum-card.d.ts
5
+ interface StratumCardOptions {
6
+ files: string[];
7
+ query: string;
8
+ tier?: 'T1' | 'T2';
9
+ maxContentChars?: number;
10
+ /** Optional file cache — avoids redundant reads and eliminates double-read with fileSummary */
11
+ cache?: FileCache;
14
12
  }
15
- export interface StratumCard {
16
- path: string;
17
- tier: 'T1' | 'T2';
18
- card: string;
19
- unknowns: string[];
20
- riskTier: 'low' | 'medium' | 'high';
21
- tokenEstimate: number;
22
- originalTokenEstimate: number;
13
+ interface StratumCard {
14
+ path: string;
15
+ tier: 'T1' | 'T2';
16
+ card: string;
17
+ unknowns: string[];
18
+ riskTier: 'low' | 'medium' | 'high';
19
+ tokenEstimate: number;
20
+ originalTokenEstimate: number;
23
21
  }
24
- export interface StratumCardResult {
25
- cards: StratumCard[];
26
- totalTokenEstimate: number;
27
- totalOriginalTokenEstimate: number;
28
- compressionRatio: number;
22
+ interface StratumCardResult {
23
+ cards: StratumCard[];
24
+ totalTokenEstimate: number;
25
+ totalOriginalTokenEstimate: number;
26
+ compressionRatio: number;
29
27
  }
30
- export declare function stratumCard(embedder: IEmbedder, options: StratumCardOptions): Promise<StratumCardResult>;
28
+ declare function stratumCard(embedder: IEmbedder, options: StratumCardOptions): Promise<StratumCardResult>;
29
+ //#endregion
30
+ export { StratumCard, StratumCardOptions, StratumCardResult, stratumCard };
31
31
  //# sourceMappingURL=stratum-card.d.ts.map
@@ -1,6 +1,5 @@
1
- import{readFile as F}from"node:fs/promises";import{basename as h,extname as I,relative as A}from"node:path";import{fileSummary as j}from"./file-summary.js";import{cosineSimilarity as X,estimateTokens as y,segment as D}from"./text-utils.js";const M=800,S=3;async function B(t,e){const{files:r,query:o,tier:n="T1",maxContentChars:m=M}=e,u=n==="T2"?await t.embedQuery(o):null,l=await Promise.all(r.map(async i=>{try{const c=await F(i,"utf-8"),p=y(c);if(c.includes("\0"))return C(i,n,"binary","binary file",p);if(c.trim().length===0){const g=x({displayPath:T(i),tier:n,role:"empty",deps:[],exports:[],unknowns:[],riskTier:"low"});return{path:i,tier:n,card:g,unknowns:[],riskTier:"low",tokenEstimate:y(g),originalTokenEstimate:p}}const d=await j({path:i}),N=U(i,d),E=W(c,d),w=_(i,d),O=$(d),R=[...new Set(d.exports)].slice(0,5);let f=x({displayPath:T(i),tier:n,role:N,deps:O,exports:R,unknowns:E,riskTier:w});if(n==="T2"&&u){const g=await v(t,u,c,m);g.length>0&&(f=`${f}
2
- CONTEXT:
3
- ${g}`)}return{path:i,tier:n,card:f,unknowns:E,riskTier:w,tokenEstimate:y(f),originalTokenEstimate:p}}catch(c){const p=c.code==="ENOENT"?"file missing":"unreadable file",d=c.code==="ENOENT"?"missing":"unreadable";return C(i,n,d,p,0)}})),s=l.reduce((i,c)=>i+c.tokenEstimate,0),a=l.reduce((i,c)=>i+c.originalTokenEstimate,0);return{cards:l,totalTokenEstimate:s,totalOriginalTokenEstimate:a,compressionRatio:a===0?0:s/a}}function C(t,e,r,o,n){const m=x({displayPath:T(t),tier:e,role:r,deps:[],exports:[],unknowns:[o],riskTier:"low"});return{path:t,tier:e,card:m,unknowns:[o],riskTier:"low",tokenEstimate:y(m),originalTokenEstimate:n}}function x(t){const{displayPath:e,tier:r,role:o,deps:n,exports:m,unknowns:u,riskTier:l}=t;return[`[${r}: ${e}]`,`ROLE: ${o}`,`DEPS: ${k(n)}`,`EXPORTS: ${k(m)}`,`UNKNOWNS: ${k(u,"; ")}`,`RISK: ${l}`].join(`
4
- `)}function T(t){const e=A(process.cwd(),t).replace(/\\/g,"/");return!e||e.startsWith("..")?h(t):e}function k(t,e=", "){return t.length>0?t.join(e):"none"}function U(t,e){const r=h(t),o=I(r).toLowerCase();return[".json",".yaml",".yml",".env"].includes(o)||/config|settings/i.test(r)?"configuration":/types?\.ts$|\.d\.ts$/i.test(r)?"type-definitions":/schema/i.test(r)?"schema":/test|spec/i.test(r)?"test":/index\.[jt]sx?$/i.test(r)?"barrel-export":/handler|controller|route/i.test(r)?"entry-point":/model|entity/i.test(r)?"data-model":/util|helper/i.test(r)?"utility":/service|provider/i.test(r)?"service":e.classes.length>0?"class-module":e.interfaces.length>2?"type-definitions":"implementation"}function W(t,e){const r=[],o=new Set;for(const n of t.matchAll(/\/\/\s*(TODO|FIXME|HACK|XXX)\s*:?\s*(.+)?$/gm)){const m=`${n[1]}: ${(n[2]??"").trim()}`.trim();b(r,o,m.replace(/:\s*$/,""))}K(t)&&b(r,o,"exported any usage");for(const n of $(e))b(r,o,`cross-package import: ${n}`);return r.slice(0,S)}function b(t,e,r){t.length>=S||!r||e.has(r)||(e.add(r),t.push(r))}function K(t){return[/export\s+(?:async\s+)?function\s+\w+[^\n{;]*\bany\b/g,/export\s+interface\s+\w+[\s\S]*?\{[\s\S]*?\bany\b[\s\S]*?\}/g,/export\s+type\s+\w+\s*=.*\bany\b/g,/export\s+const\s+\w+[^\n=]*\bany\b/g].some(r=>r.test(t))}function _(t,e){return/auth|token|permission|secret|credential|encrypt/i.test(t)?"high":/types?\.ts$|schema|contract|\.d\.ts$/i.test(h(t))||e.exports.length>10?"medium":"low"}function $(t){return t.imports.map(q).filter(e=>!!e).filter(e=>!e.startsWith("./")&&!e.startsWith("../")).slice(0,3)}function q(t){const e=t.match(/from\s+['"]([^'"]+)['"]/);if(e)return e[1];const r=t.match(/^import\s+['"]([^'"]+)['"]/);return r?r[1]:null}async function v(t,e,r,o){if(o<=0)return"";const n=D(r,"paragraph");if(n.length===0)return"";const m=await Promise.all(n.map(async(s,a)=>{const i=await t.embed(s);return{index:a,text:s,score:X(e,i)}})),u=[];let l=0;for(const s of m.sort((a,i)=>i.score-a.score)){const a=o-l;if(a<=0)break;if(s.text.length<=a){u.push({index:s.index,text:s.text}),l+=s.text.length;continue}u.length===0&&(u.push({index:s.index,text:s.text.slice(0,a).trimEnd()}),l=o);break}return u.sort((s,a)=>s.index-a.index).map(s=>s.text).filter(s=>s.length>0).join(`
1
+ import{cosineSimilarity as e,estimateTokens as t,segment as n}from"./text-utils.js";import{fileSummary as r}from"./file-summary.js";import{readFile as i}from"node:fs/promises";import{basename as a,extname as o,relative as s}from"node:path";async function c(e,n){let{files:a,query:o,tier:s=`T1`,maxContentChars:c=800}=n,{cache:f}=n,h=s===`T2`?await e.embedQuery(o):null,g=await Promise.all(a.map(async n=>{try{let a=f?(await f.get(n)).content:await i(n,`utf-8`),o=t(a);if(a.includes(`\0`))return l(n,s,`binary`,`binary file`,o);if(a.trim().length===0){let e=u({displayPath:d(n),tier:s,role:`empty`,deps:[],exports:[],unknowns:[],riskTier:`low`});return{path:n,tier:s,card:e,unknowns:[],riskTier:`low`,tokenEstimate:t(e),originalTokenEstimate:o}}let g=await r({path:n,content:a}),y=p(n,g),x=m(a,g),S=_(n,g),C=v(g),w=[...new Set(g.exports)].slice(0,5),T=u({displayPath:d(n),tier:s,role:y,deps:C,exports:w,unknowns:x,riskTier:S});if(s===`T2`&&h){let t=await b(e,h,a,c);t.length>0&&(T=`${T}\nCONTEXT:\n${t}`)}return{path:n,tier:s,card:T,unknowns:x,riskTier:S,tokenEstimate:t(T),originalTokenEstimate:o}}catch(e){let t=e.code===`ENOENT`?`file missing`:`unreadable file`;return l(n,s,e.code===`ENOENT`?`missing`:`unreadable`,t,0)}})),y=g.reduce((e,t)=>e+t.tokenEstimate,0),x=g.reduce((e,t)=>e+t.originalTokenEstimate,0);return{cards:g,totalTokenEstimate:y,totalOriginalTokenEstimate:x,compressionRatio:x===0?0:y/x}}function l(e,n,r,i,a){let o=u({displayPath:d(e),tier:n,role:r,deps:[],exports:[],unknowns:[i],riskTier:`low`});return{path:e,tier:n,card:o,unknowns:[i],riskTier:`low`,tokenEstimate:t(o),originalTokenEstimate:a}}function u(e){let{displayPath:t,tier:n,role:r,deps:i,exports:a,unknowns:o,riskTier:s}=e;return[`[${n}: ${t}]`,`ROLE: ${r}`,`DEPS: ${f(i)}`,`EXPORTS: ${f(a)}`,`UNKNOWNS: ${f(o,`; `)}`,`RISK: ${s}`].join(`
2
+ `)}function d(e){let t=s(process.cwd(),e).replace(/\\/g,`/`);return!t||t.startsWith(`..`)?a(e):t}function f(e,t=`, `){return e.length>0?e.join(t):`none`}function p(e,t){let n=a(e),r=o(n).toLowerCase();return[`.json`,`.yaml`,`.yml`,`.env`].includes(r)||/config|settings/i.test(n)?`configuration`:/types?\.ts$|\.d\.ts$/i.test(n)?`type-definitions`:/schema/i.test(n)?`schema`:/test|spec/i.test(n)?`test`:/index\.[jt]sx?$/i.test(n)?`barrel-export`:/handler|controller|route/i.test(n)?`entry-point`:/model|entity/i.test(n)?`data-model`:/util|helper/i.test(n)?`utility`:/service|provider/i.test(n)?`service`:t.classes.length>0?`class-module`:t.interfaces.length>2?`type-definitions`:`implementation`}function m(e,t){let n=[],r=new Set;for(let t of e.matchAll(/\/\/\s*(TODO|FIXME|HACK|XXX)\s*:?\s*(.+)?$/gm))h(n,r,`${t[1]}: ${(t[2]??``).trim()}`.trim().replace(/:\s*$/,``));g(e)&&h(n,r,`exported any usage`);for(let e of v(t))h(n,r,`cross-package import: ${e}`);return n.slice(0,3)}function h(e,t,n){e.length>=3||!n||t.has(n)||(t.add(n),e.push(n))}function g(e){return[/export\s+(?:async\s+)?function\s+\w+[^\n{;]*\bany\b/g,/export\s+interface\s+\w+[\s\S]*?\{[\s\S]*?\bany\b[\s\S]*?\}/g,/export\s+type\s+\w+\s*=.*\bany\b/g,/export\s+const\s+\w+[^\n=]*\bany\b/g].some(t=>t.test(e))}function _(e,t){return/auth|token|permission|secret|credential|encrypt/i.test(e)?`high`:/types?\.ts$|schema|contract|\.d\.ts$/i.test(a(e))||t.exports.length>10?`medium`:`low`}function v(e){return e.imports.map(y).filter(e=>!!e).filter(e=>!e.startsWith(`./`)&&!e.startsWith(`../`)).slice(0,3)}function y(e){let t=e.match(/from\s+['"]([^'"]+)['"]/);if(t)return t[1];let n=e.match(/^import\s+['"]([^'"]+)['"]/);return n?n[1]:null}async function b(t,r,i,a){if(a<=0)return``;let o=n(i,`paragraph`);if(o.length===0)return``;let s=await Promise.all(o.map(async(n,i)=>({index:i,text:n,score:e(r,await t.embed(n))}))),c=[],l=0;for(let e of s.sort((e,t)=>t.score-e.score)){let t=a-l;if(t<=0)break;if(e.text.length<=t){c.push({index:e.index,text:e.text}),l+=e.text.length;continue}c.length===0&&(c.push({index:e.index,text:e.text.slice(0,t).trimEnd()}),l=a);break}return c.sort((e,t)=>e.index-t.index).map(e=>e.text).filter(e=>e.length>0).join(`
5
3
 
6
- `)}export{B as stratumCard};
4
+ `)}export{c as stratumCard};
5
+ //# sourceMappingURL=stratum-card.js.map
@@ -1,28 +1,32 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IKnowledgeStore } from '@kb/store';
3
- export interface SymbolInfo {
4
- name: string;
5
- definedIn?: {
6
- path: string;
7
- line: number;
8
- kind: string;
9
- };
10
- importedBy: Array<{
11
- path: string;
12
- line: number;
13
- importStatement: string;
14
- }>;
15
- referencedIn: Array<{
16
- path: string;
17
- line: number;
18
- context: string;
19
- }>;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+
4
+ //#region packages/tools/src/symbol.d.ts
5
+ interface SymbolInfo {
6
+ name: string;
7
+ definedIn?: {
8
+ path: string;
9
+ line: number;
10
+ kind: string;
11
+ };
12
+ importedBy: Array<{
13
+ path: string;
14
+ line: number;
15
+ importStatement: string;
16
+ }>;
17
+ referencedIn: Array<{
18
+ path: string;
19
+ line: number;
20
+ context: string;
21
+ }>;
20
22
  }
21
- export interface SymbolOptions {
22
- /** Symbol name to look up */
23
- name: string;
24
- /** Limit results */
25
- limit?: number;
23
+ interface SymbolOptions {
24
+ /** Symbol name to look up */
25
+ name: string;
26
+ /** Limit results */
27
+ limit?: number;
26
28
  }
27
- export declare function symbol(embedder: IEmbedder, store: IKnowledgeStore, options: SymbolOptions): Promise<SymbolInfo>;
29
+ declare function symbol(embedder: IEmbedder, store: IKnowledgeStore, options: SymbolOptions): Promise<SymbolInfo>;
30
+ //#endregion
31
+ export { SymbolInfo, SymbolOptions, symbol };
28
32
  //# sourceMappingURL=symbol.d.ts.map
@@ -1,3 +1,4 @@
1
- function l(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function P(i,d,h){const{name:t,limit:s=20}=h,m=i.embedQuery?.bind(i)??i.embed.bind(i),g=[`export function ${t}`,`export class ${t}`,`export const ${t}`,`export interface ${t}`,`export type ${t}`,`export enum ${t}`].join(" | "),x=await d.search(await m(g),{limit:s*2}),I=new RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${l(t)}\\b`,"m");let a;for(const e of x){if(!I.test(e.record.content))continue;const r=e.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??"unknown";a={path:e.record.sourcePath,line:e.record.startLine,kind:r};break}const p=new RegExp(`import\\s+.*\\b${l(t)}\\b.*from\\s+`,"m"),$=await d.search(await m(`import ${t} from`),{limit:s*3}),f=[],u=new Set;for(const e of $){const r=e.record.content.split(`
2
- `);for(let n=0;n<r.length;n++){const o=r[n];if(!p.test(o))continue;const c=`${e.record.sourcePath}:${o.trim()}`;u.has(c)||(u.add(c),f.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:o.trim()}))}}const w=new RegExp(`\\b${l(t)}\\b`),S=await d.search(await m(t),{limit:s*3}),y=[],b=new Set;for(const e of S){if(a&&e.record.sourcePath===a.path)continue;const r=e.record.content.split(`
3
- `);for(let n=0;n<r.length;n++){const o=r[n];if(!w.test(o)||p.test(o))continue;const c=`${e.record.sourcePath}:${e.record.startLine+n}`;if(!b.has(c)){b.add(c),y.push({path:e.record.sourcePath,line:e.record.startLine+n,context:o.trim().slice(0,120)});break}}}return{name:t,definedIn:a,importedBy:f.slice(0,s),referencedIn:y.slice(0,s)}}export{P as symbol};
1
+ function e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}async function t(t,n,r){let{name:i,limit:a=20}=r,o=t.embedQuery?.bind(t)??t.embed.bind(t),s=[`export function ${i}`,`export class ${i}`,`export const ${i}`,`export interface ${i}`,`export type ${i}`,`export enum ${i}`].join(` | `),c=await n.search(await o(s),{limit:a*2}),l=RegExp(`^export\\s+(?:default\\s+)?(?:async\\s+)?(?:function|class|const|let|interface|type|enum)\\s+${e(i)}\\b`,`m`),u;for(let e of c){if(!l.test(e.record.content))continue;let t=e.record.content.match(/export\s+(?:default\s+)?(?:async\s+)?(\w+)/)?.[1]??`unknown`;u={path:e.record.sourcePath,line:e.record.startLine,kind:t};break}let d=RegExp(`import\\s+.*\\b${e(i)}\\b.*from\\s+`,`m`),f=await n.search(await o(`import ${i} from`),{limit:a*3}),p=[],m=new Set;for(let e of f){let t=e.record.content.split(`
2
+ `);for(let n=0;n<t.length;n++){let r=t[n];if(!d.test(r))continue;let i=`${e.record.sourcePath}:${r.trim()}`;m.has(i)||(m.add(i),p.push({path:e.record.sourcePath,line:e.record.startLine+n,importStatement:r.trim()}))}}let h=RegExp(`\\b${e(i)}\\b`),g=await n.search(await o(i),{limit:a*3}),_=[],v=new Set;for(let e of g){if(u&&e.record.sourcePath===u.path)continue;let t=e.record.content.split(`
3
+ `);for(let n=0;n<t.length;n++){let r=t[n];if(!h.test(r)||d.test(r))continue;let i=`${e.record.sourcePath}:${e.record.startLine+n}`;if(!v.has(i)){v.add(i),_.push({path:e.record.sourcePath,line:e.record.startLine+n,context:r.trim().slice(0,120)});break}}}return{name:i,definedIn:u,importedBy:p.slice(0,a),referencedIn:_.slice(0,a)}}export{t as symbol};
4
+ //# sourceMappingURL=symbol.js.map
@@ -1,23 +1,27 @@
1
- import { type ParsedTestSummary } from './parse-output.js';
2
- export interface TestRunOptions {
3
- files?: string[];
4
- cwd?: string;
5
- timeout?: number;
6
- grep?: string;
1
+ import { ParsedTestSummary } from "./parse-output.js";
2
+
3
+ //#region packages/tools/src/test-run.d.ts
4
+ interface TestRunOptions {
5
+ files?: string[];
6
+ cwd?: string;
7
+ timeout?: number;
8
+ grep?: string;
7
9
  }
8
- export interface TestRunResult {
9
- summary: ParsedTestSummary;
10
- passed: boolean;
11
- raw: string;
12
- durationMs: number;
10
+ interface TestRunResult {
11
+ summary: ParsedTestSummary;
12
+ passed: boolean;
13
+ raw: string;
14
+ durationMs: number;
13
15
  }
14
- export declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
16
+ declare function testRun(options?: TestRunOptions): Promise<TestRunResult>;
15
17
  /**
16
18
  * Classify non-zero exit codes — some tools use exit code 1 for
17
19
  * non-error conditions (e.g., grep returns 1 for "no matches").
18
20
  */
19
- export declare function classifyExitCode(exitCode: number, _stdout: string, command?: string): {
20
- isError: boolean;
21
- reason?: string;
21
+ declare function classifyExitCode(exitCode: number, _stdout: string, command?: string): {
22
+ isError: boolean;
23
+ reason?: string;
22
24
  };
25
+ //#endregion
26
+ export { TestRunOptions, TestRunResult, classifyExitCode, testRun };
23
27
  //# sourceMappingURL=test-run.d.ts.map
@@ -1,2 +1,3 @@
1
- import{execFile as f}from"node:child_process";import{promisify as c}from"node:util";import{parseVitest as u}from"./parse-output.js";const m=c(f);async function w(r={}){const e=r.cwd??process.cwd(),t=r.timeout??6e4,n=Date.now(),i=["vitest","run","--reporter=verbose"];r.files?.length&&i.push(...r.files),r.grep&&i.push("--testNamePattern",r.grep);try{const{stdout:o}=await m("npx",i,{cwd:e,shell:!0,timeout:t}),s=o.toString(),a=u(s);return{summary:a,passed:a.failed===0,raw:s,durationMs:Date.now()-n}}catch(o){const s=g(o);return{summary:u(s),passed:!1,raw:s,durationMs:Date.now()-n}}}function g(r){const e=r,t=e.stdout?.toString()??"",n=e.stderr?.toString()??"";return[t,n].filter(Boolean).join(`
2
- `).trim()||e.message||"Test run failed"}function y(r,e,t){if(r===0)return{isError:!1};if(r===1&&t){if(/\b(grep|rg|ripgrep|ag|ack|findstr)\b/i.test(t))return{isError:!1,reason:"grep: no matches (exit 1 is normal)"};if(/\bdiff\b/i.test(t))return{isError:!1,reason:"diff: files differ (exit 1 is normal)"}}return{isError:!0}}export{y as classifyExitCode,w as testRun};
1
+ import{parseVitest as e}from"./parse-output.js";import{execFile as t}from"node:child_process";import{promisify as n}from"node:util";const r=n(t);let i=0;async function a(e={}){if(i>=2)throw Error(`Too many concurrent test runs (max 2). Try again later.`);i++;try{return await o(e)}finally{i--}}async function o(t){let n=t.cwd??process.cwd(),i=t.timeout??6e4,a=Date.now(),o=[`vitest`,`run`,`--reporter=verbose`];t.files?.length&&o.push(...t.files),t.grep&&o.push(`--testNamePattern`,t.grep);try{let{stdout:t}=await r(`npx`,o,{cwd:n,shell:!0,timeout:i}),s=t.toString(),c=e(s);return{summary:c,passed:c.failed===0,raw:s,durationMs:Date.now()-a}}catch(t){let n=s(t);return{summary:e(n),passed:!1,raw:n,durationMs:Date.now()-a}}}function s(e){let t=e;return[t.stdout?.toString()??``,t.stderr?.toString()??``].filter(Boolean).join(`
2
+ `).trim()||t.message||`Test run failed`}function c(e,t,n){if(e===0)return{isError:!1};if(e===1&&n){if(/\b(grep|rg|ripgrep|ag|ack|findstr)\b/i.test(n))return{isError:!1,reason:`grep: no matches (exit 1 is normal)`};if(/\bdiff\b/i.test(n))return{isError:!1,reason:`diff: files differ (exit 1 is normal)`}}return{isError:!0}}export{c as classifyExitCode,a as testRun};
3
+ //# sourceMappingURL=test-run.js.map