@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,3 +1,7 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare function registerReplayTool(server: McpServer): void;
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+
3
+ //#region packages/server/src/tools/replay.tool.d.ts
4
+ declare function registerReplayTool(server: McpServer): void;
5
+ //#endregion
6
+ export { registerReplayTool };
3
7
  //# sourceMappingURL=replay.tool.d.ts.map
@@ -1,7 +1,4 @@
1
- import{replayClear as m,replayList as y,replayTrim as d}from"../../../tools/dist/index.js";import{z as o}from"zod";function h(r){r.registerTool("replay",{description:"View or clear the audit trail of recent MCP tool and CLI invocations. Shows tool name, duration, status, and input/output summaries.",inputSchema:{action:o.enum(["list","clear"]).default("list").describe('Action: "list" (default) to view entries, "clear" to wipe the log'),last:o.number().optional().describe("Number of entries to return (default: 20, list only)"),tool:o.string().optional().describe("Filter by tool name (list only)"),source:o.enum(["mcp","cli"]).optional().describe('Filter by source: "mcp" or "cli" (list only)'),since:o.string().optional().describe("ISO timestamp \u2014 only show entries after this time (list only)")}},async({action:n,last:i,tool:s,source:l,since:a})=>{try{if(n==="clear")return m(),{content:[{type:"text",text:"Replay log cleared."}]};const e=y({last:i,tool:s,source:l,since:a});if(e.length===0)return{content:[{type:"text",text:"No replay entries found. Activity is logged when tools are invoked via MCP or CLI."}]};const c=e.map(t=>{const p=t.ts.split("T")[1]?.split(".")[0]??t.ts,u=t.status==="ok"?"\u2713":"\u2717";return`${p} ${u} ${t.tool} (${t.durationMs}ms) [${t.source}]
2
- in: ${t.input}
3
- out: ${t.output}`});return d(),{content:[{type:"text",text:`**Replay Log** (${e.length} entries)
1
+ import{createLogger as e,serializeError as t}from"../../../core/dist/index.js";import{replayClear as n,replayList as r,replayTrim as i}from"../../../tools/dist/index.js";import{z as a}from"zod";const o=e(`tools`);function s(e){e.registerTool(`replay`,{description:`View or clear the audit trail of recent MCP tool and CLI invocations. Shows tool name, duration, status, and input/output summaries.`,inputSchema:{action:a.enum([`list`,`clear`]).default(`list`).describe(`Action: "list" (default) to view entries, "clear" to wipe the log`),last:a.number().optional().describe(`Number of entries to return (default: 20, list only)`),tool:a.string().optional().describe(`Filter by tool name (list only)`),source:a.enum([`mcp`,`cli`]).optional().describe(`Filter by source: "mcp" or "cli" (list only)`),since:a.string().optional().describe(`ISO timestamp only show entries after this time (list only)`)}},async({action:e,last:a,tool:s,source:c,since:l})=>{try{if(e===`clear`)return n(),{content:[{type:`text`,text:`Replay log cleared.`}]};let t=r({last:a,tool:s,source:c,since:l});if(t.length===0)return{content:[{type:`text`,text:`No replay entries found. Activity is logged when tools are invoked via MCP or CLI.`}]};let o=t.map(e=>`${e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts} ${e.status===`ok`?`✓`:`✗`} ${e.tool} (${e.durationMs}ms) [${e.source}]\n in: ${e.input}\n out: ${e.output}`);return i(),{content:[{type:`text`,text:`**Replay Log** (${t.length} entries)\n\n${o.join(`
4
2
 
5
- ${c.join(`
6
-
7
- `)}`}]}}catch(e){return console.error("[KB] Replay failed:",e),{content:[{type:"text",text:`Replay failed: ${e.message}`}],isError:!0}}})}export{h as registerReplayTool};
3
+ `)}`}]}}catch(e){return o.error(`Replay failed`,t(e)),{content:[{type:`text`,text:`Replay failed. Check server logs for details.`}],isError:!0}}})}export{s as registerReplayTool};
4
+ //# sourceMappingURL=replay.tool.js.map
@@ -1,5 +1,11 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IGraphStore, IKnowledgeStore } from '@kb/store';
3
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
- export declare function registerSearchTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore, graphStore?: IGraphStore): void;
1
+ import { BridgeComponents } from "./bridge.tools.js";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { IEmbedder } from "@kb/embeddings";
4
+ import { EvolutionCollector } from "@kb/enterprise-bridge";
5
+ import { IGraphStore, IKnowledgeStore } from "@kb/store";
6
+
7
+ //#region packages/server/src/tools/search.tool.d.ts
8
+ declare function registerSearchTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore, graphStore?: IGraphStore, bridge?: BridgeComponents, evolutionCollector?: EvolutionCollector): void;
9
+ //#endregion
10
+ export { registerSearchTool };
5
11
  //# sourceMappingURL=search.tool.d.ts.map
@@ -1,25 +1,10 @@
1
- import{stat as O}from"node:fs/promises";import{graphAugmentSearch as A,truncateToTokenBudget as D}from"../../../tools/dist/index.js";import{z as g}from"zod";function K(p,y,a=60){const s=new Map;for(let e=0;e<p.length;e++){const n=p[e];s.set(n.record.id,{record:n.record,score:1/(a+e+1)})}for(let e=0;e<y.length;e++){const n=y[e],d=s.get(n.record.id);d?d.score+=1/(a+e+1):s.set(n.record.id,{record:n.record,score:1/(a+e+1)})}return[...s.values()].sort((e,n)=>n.score-e.score).map(({record:e,score:n})=>({record:e,score:n}))}function N(p,y){const a=y.toLowerCase().split(/\s+/).filter(s=>s.length>=2);return a.length<2?p:p.map(s=>{const e=s.record.content.toLowerCase(),n=a.map(i=>{const h=[];let o=e.indexOf(i);for(;o!==-1;)h.push(o),o=e.indexOf(i,o+1);return h});if(n.some(i=>i.length===0))return s;let d=e.length;for(const i of n[0]){let h=i,o=i+a[0].length;for(let f=1;f<n.length;f++){let S=n[f][0],w=Math.abs(S-i);for(let b=1;b<n[f].length;b++){const _=Math.abs(n[f][b]-i);_<w&&(w=_,S=n[f][b])}h=Math.min(h,S),o=Math.max(o,S+a[f].length)}d=Math.min(d,o-h)}const r=1+.25/(1+d/200);return{record:s.record,score:s.score*r}}).sort((s,e)=>e.score-s.score)}function E(p,y,a=8){const s=new Set(y.toLowerCase().split(/\s+/).filter(r=>r.length>=2)),e=new Map,n=p.length;for(const r of p){const i=new Set(r.record.content.split(/[^a-zA-Z0-9_]+/).filter(o=>o.length>=3&&!P.has(o.toLowerCase())));for(const o of i){const f=o.toLowerCase();/[_A-Z]/.test(o)&&e.set(`__id__${f}`,1)}const h=new Set(r.record.content.toLowerCase().split(/[^a-zA-Z0-9_]+/).filter(o=>o.length>=3&&!P.has(o)));for(const o of h)e.set(o,(e.get(o)??0)+1)}const d=[];for(const[r,i]of e){if(r.startsWith("__id__")||s.has(r)||i>n*.8)continue;const h=Math.log(n/i),o=e.has(`__id__${r}`)?1:0,f=r.length>8?.5:0;d.push({term:r,score:h+o+f})}return d.sort((r,i)=>i.score-r.score).slice(0,a).map(r=>r.term)}const P=new Set(["the","and","for","are","but","not","you","all","can","had","her","was","one","our","out","has","have","from","this","that","with","they","been","said","each","which","their","will","other","about","many","then","them","these","some","would","make","like","into","could","time","very","when","come","just","know","take","people","also","back","after","only","more","than","over","such","import","export","const","function","return","true","false","null","undefined","string","number","boolean","void","type","interface"]);async function G(p,y){try{const a=await p.getStats();if(!a.lastIndexedAt)return;const s=new Date(a.lastIndexedAt).getTime(),e=Date.now(),n=[...new Set(y.map(r=>r.record.sourcePath))].slice(0,5);let d=0;for(const r of n)try{(await O(r)).mtimeMs>s&&d++}catch{d++}if(d>0){const r=e-s,i=Math.floor(r/6e4),h=i<1?"<1 min":`${i} min`;return`> \u26A0\uFE0F **Index may be stale** \u2014 ${d} file(s) modified since last index (${h} ago). Use \`reindex\` to refresh.`}}catch{}}function Q(p,y,a,s){p.registerTool("search",{description:"Search the knowledge base with hybrid vector + keyword matching (BM25 + RRF fusion). Best for finding code, docs, and prior decisions. Supports semantic, keyword, and hybrid modes.",inputSchema:{query:g.string().describe("Natural language search query"),limit:g.number().min(1).max(20).default(5).describe("Maximum results to return"),search_mode:g.enum(["hybrid","semantic","keyword"]).default("hybrid").describe("Search strategy: hybrid (vector + FTS + RRF fusion, default), semantic (vector only), keyword (FTS only)"),content_type:g.enum(["markdown","code-typescript","code-javascript","code-python","config-json","config-yaml","config-toml","config-dotenv","infrastructure","documentation","test","script","curated-knowledge","produced-knowledge","other"]).optional().describe("Filter by content type"),source_type:g.enum(["source","documentation","test","config"]).optional().describe('Coarse filter: "source" (code only), "documentation" (md, curated), "test", "config". Overrides content_type if both set.'),origin:g.enum(["indexed","curated","produced"]).optional().describe("Filter by knowledge origin"),category:g.string().optional().describe("Filter by category (e.g., decisions, patterns, conventions)"),tags:g.array(g.string()).optional().describe("Filter by tags (returns results matching ANY of the specified tags)"),min_score:g.number().min(0).max(1).default(.25).describe("Minimum similarity score"),graph_hops:g.number().min(0).max(3).default(0).describe("Number of graph hops to augment results with (0 = no graph context, 1-3 = enrich results with connected entities)"),max_tokens:g.number().min(100).max(5e4).optional().describe("Maximum token budget for the response. When set, output is truncated to fit."),dedup:g.enum(["file","chunk"]).default("chunk").describe('Deduplication mode: "chunk" (default, show all matching chunks) or "file" (collapse chunks from same file into single result with merged line ranges)')}},async({query:e,limit:n,search_mode:d,content_type:r,source_type:i,origin:h,category:o,tags:f,min_score:S,graph_hops:w,max_tokens:b,dedup:_})=>{try{const x={limit:n,minScore:S,contentType:r,sourceType:i,origin:h,category:o,tags:f};let l;if(d==="keyword")l=await a.ftsSearch(e,x),l=l.slice(0,n);else if(d==="semantic"){const u=await y.embedQuery(e);l=await a.search(u,x)}else{const u=await y.embedQuery(e),[c,t]=await Promise.all([a.search(u,{...x,limit:n*2}),a.ftsSearch(e,{...x,limit:n*2}).catch(()=>[])]);l=K(c,t).slice(0,n)}if(l.length>1&&(l=N(l,e)),_==="file"&&l.length>1){const u=new Map;for(const c of l){const t=c.record.sourcePath,m=u.get(t);m?(c.score>m.best.score&&(m.best=c),m.ranges.push({start:c.record.startLine,end:c.record.endLine})):u.set(t,{best:c,ranges:[{start:c.record.startLine,end:c.record.endLine}]})}l=[...u.values()].sort((c,t)=>t.best.score-c.best.score).map(({best:c,ranges:t})=>({record:{...c.record,content:t.length>1?`${c.record.content}
2
-
3
- _Matched ${t.length} sections: ${t.sort((m,k)=>m.start-k.start).map(m=>`L${m.start}-${m.end}`).join(", ")}_`:c.record.content},score:c.score}))}if(l.length===0)return{content:[{type:"text",text:"No results found for the given query."}]};let M,R;if(w>0&&!s&&(R="> **Note:** `graph_hops` was set but no graph store is available. Graph augmentation skipped."),w>0&&s)try{const u=l.map(t=>({recordId:t.record.id,score:t.score,sourcePath:t.record.sourcePath})),c=await A(s,u,{hops:w,maxPerHit:5});M=new Map;for(const t of c)if(t.graphContext.nodes.length>0){const m=t.graphContext.nodes.slice(0,5).map(v=>` - **${v.name}** (${v.type})`).join(`
4
- `),k=t.graphContext.edges.slice(0,5).map(v=>` - ${v.fromId} \u2014[${v.type}]\u2192 ${v.toId}`).join(`
5
- `),j=[`- **Graph Context** (${w} hop${w>1?"s":""}):`];m&&j.push(` Entities:
6
- ${m}`),k&&j.push(` Relationships:
7
- ${k}`),M.set(t.recordId,j.join(`
8
- `))}}catch(u){console.error("[KB] Graph augmentation failed (non-fatal):",u),R="> **Note:** Graph augmentation failed. Results shown without graph context."}const F=l.map((u,c)=>{const t=u.record,m=`### Result ${c+1} (score: ${u.score.toFixed(3)})`,k=[`- **Source**: ${t.sourcePath}`,t.headingPath?`- **Section**: ${t.headingPath}`:null,`- **Type**: ${t.contentType}`,t.startLine?`- **Lines**: ${t.startLine}-${t.endLine}`:null,t.origin!=="indexed"?`- **Origin**: ${t.origin}`:null,t.category?`- **Category**: ${t.category}`:null,t.tags?.length?`- **Tags**: ${t.tags.join(", ")}`:null,M?.get(t.id)??null].filter(Boolean).join(`
9
- `);return`${m}
10
- ${k}
11
-
12
- ${t.content}`}).join(`
1
+ import{stat as e}from"node:fs/promises";import{CONTENT_TYPES as t,KNOWLEDGE_ORIGINS as n,SOURCE_TYPES as r,createLogger as i,serializeError as a}from"../../../core/dist/index.js";import{graphAugmentSearch as o,truncateToTokenBudget as s}from"../../../tools/dist/index.js";import{z as c}from"zod";import{mergeResults as l}from"../../../enterprise-bridge/dist/index.js";const u=i(`tools`);async function d(e,t,n,r,i){if(!e||t>=e.config.fallbackThreshold&&n.length>0)return{results:n,triggered:!1,cacheHit:!1};let o=!1;try{let t=e.cache.get(r);return t?o=!0:(t=await e.client.search(r,i),t.length>0&&e.cache.set(r,t)),t.length>0?{results:l(n,t,i).map(e=>({record:{id:`er:${e.sourcePath}`,content:e.content,sourcePath:e.source===`er`?`[ER] ${e.sourcePath}`:e.sourcePath,startLine:e.startLine??0,endLine:e.endLine??0,contentType:e.contentType??`documentation`,headingPath:e.headingPath,origin:e.source===`er`?`curated`:e.origin??`indexed`,category:e.category,tags:e.tags??[],chunkIndex:0,totalChunks:1,fileHash:``,indexedAt:new Date().toISOString(),version:1},score:e.score})),triggered:!0,cacheHit:o}:{results:n,triggered:!0,cacheHit:o}}catch(e){return u.warn(`ER fallback failed`,a(e)),{results:n,triggered:!0,cacheHit:o}}}function f(e,t,n=60){let r=new Map;for(let t=0;t<e.length;t++){let i=e[t];r.set(i.record.id,{record:i.record,score:1/(n+t+1)})}for(let e=0;e<t.length;e++){let i=t[e],a=r.get(i.record.id);a?a.score+=1/(n+e+1):r.set(i.record.id,{record:i.record,score:1/(n+e+1)})}return[...r.values()].sort((e,t)=>t.score-e.score).map(({record:e,score:t})=>({record:e,score:t}))}function p(e,t){let n=t.toLowerCase().split(/\s+/).filter(e=>e.length>=2);return n.length<2?e:e.map(e=>{let t=e.record.content.toLowerCase(),r=n.map(e=>{let n=[],r=t.indexOf(e);for(;r!==-1;)n.push(r),r=t.indexOf(e,r+1);return n});if(r.some(e=>e.length===0))return e;let i=t.length;for(let e of r[0]){let t=e,a=e+n[0].length;for(let i=1;i<r.length;i++){let o=r[i][0],s=Math.abs(o-e);for(let t=1;t<r[i].length;t++){let n=Math.abs(r[i][t]-e);n<s&&(s=n,o=r[i][t])}t=Math.min(t,o),a=Math.max(a,o+n[i].length)}i=Math.min(i,a-t)}let a=1+.25/(1+i/200);return{record:e.record,score:e.score*a}}).sort((e,t)=>t.score-e.score)}function m(e,t,n=8){let r=new Set(t.toLowerCase().split(/\s+/).filter(e=>e.length>=2)),i=new Map,a=e.length;for(let t of e){let e=new Set(t.record.content.split(/[^a-zA-Z0-9_]+/).filter(e=>e.length>=3&&!h.has(e.toLowerCase())));for(let t of e){let e=t.toLowerCase();/[_A-Z]/.test(t)&&i.set(`__id__${e}`,1)}let n=new Set(t.record.content.toLowerCase().split(/[^a-zA-Z0-9_]+/).filter(e=>e.length>=3&&!h.has(e)));for(let e of n)i.set(e,(i.get(e)??0)+1)}let o=[];for(let[e,t]of i){if(e.startsWith(`__id__`)||r.has(e)||t>a*.8)continue;let n=Math.log(a/t),s=i.has(`__id__${e}`)?1:0,c=e.length>8?.5:0;o.push({term:e,score:n+s+c})}return o.sort((e,t)=>t.score-e.score).slice(0,n).map(e=>e.term)}const h=new Set(`the.and.for.are.but.not.you.all.can.had.her.was.one.our.out.has.have.from.this.that.with.they.been.said.each.which.their.will.other.about.many.then.them.these.some.would.make.like.into.could.time.very.when.come.just.know.take.people.also.back.after.only.more.than.over.such.import.export.const.function.return.true.false.null.undefined.string.number.boolean.void.type.interface`.split(`.`));async function g(t,n){try{let r=await t.getStats();if(!r.lastIndexedAt)return;let i=new Date(r.lastIndexedAt).getTime(),a=Date.now(),o=[...new Set(n.map(e=>e.record.sourcePath))].filter(e=>!e.startsWith(`[ER]`)).slice(0,5);if(o.length===0)return;let s=0;for(let t of o)try{(await e(t)).mtimeMs>i&&s++}catch{s++}if(s>0){let e=a-i,t=Math.floor(e/6e4),n=t<1?`<1 min`:`${t} min`;return`> ⚠️ **Index may be stale** ${s} file(s) modified since last index (${n} ago). Use \`reindex\` to refresh.`}}catch{}}function _(e,i,l,h,_,v){e.registerTool(`search`,{description:`Search the knowledge base with hybrid vector + keyword matching (BM25 + RRF fusion). Best for finding code, docs, and prior decisions. Supports semantic, keyword, and hybrid modes.`,inputSchema:{query:c.string().max(5e3).describe(`Natural language search query`),limit:c.number().min(1).max(20).default(5).describe(`Maximum results to return`),search_mode:c.enum([`hybrid`,`semantic`,`keyword`]).default(`hybrid`).describe(`Search strategy: hybrid (vector + FTS + RRF fusion, default), semantic (vector only), keyword (FTS only)`),content_type:c.enum(t).optional().describe(`Filter by content type`),source_type:c.enum(r).optional().describe(`Coarse filter: "source" (code only), "documentation" (md, curated), "test", "config". Overrides content_type if both set.`),origin:c.enum(n).optional().describe(`Filter by knowledge origin`),category:c.string().optional().describe(`Filter by category (e.g., decisions, patterns, conventions)`),tags:c.array(c.string()).optional().describe(`Filter by tags (returns results matching ANY of the specified tags)`),min_score:c.number().min(0).max(1).default(.25).describe(`Minimum similarity score`),graph_hops:c.number().min(0).max(3).default(0).describe(`Number of graph hops to augment results with (0 = no graph context, 1-3 = enrich results with connected entities)`),max_tokens:c.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`),dedup:c.enum([`file`,`chunk`]).default(`chunk`).describe(`Deduplication mode: "chunk" (default, show all matching chunks) or "file" (collapse chunks from same file into single result with merged line ranges)`)}},async({query:e,limit:t,search_mode:n,content_type:r,source_type:c,origin:y,category:b,tags:x,min_score:S,graph_hops:C,max_tokens:w,dedup:T})=>{try{let E={limit:t,minScore:S,contentType:r,sourceType:c,origin:y,category:b,tags:x},D,O=!1,k=!1;if(n===`keyword`)D=await l.ftsSearch(e,E),D=D.slice(0,t);else if(n===`semantic`){let n=await i.embedQuery(e);D=await l.search(n,E);let r=await d(_,D[0]?.score??0,D,e,t);D=r.results,O=r.triggered,k=r.cacheHit}else{let n=await i.embedQuery(e),[r,a]=await Promise.all([l.search(n,{...E,limit:t*2}),l.ftsSearch(e,{...E,limit:t*2}).catch(()=>[])]);D=f(r,a).slice(0,t);let o=await d(_,r[0]?.score??0,D,e,t);D=o.results,O=o.triggered,k=o.cacheHit}if(v&&v.recordSearch(e,O,k),D.length>1&&(D=p(D,e)),T===`file`&&D.length>1){let e=new Map;for(let t of D){let n=t.record.sourcePath,r=e.get(n);r?(t.score>r.best.score&&(r.best=t),r.ranges.push({start:t.record.startLine,end:t.record.endLine})):e.set(n,{best:t,ranges:[{start:t.record.startLine,end:t.record.endLine}]})}D=[...e.values()].sort((e,t)=>t.best.score-e.best.score).map(({best:e,ranges:t})=>({record:{...e.record,content:t.length>1?`${e.record.content}\n\n_Matched ${t.length} sections: ${t.sort((e,t)=>e.start-t.start).map(e=>`L${e.start}-${e.end}`).join(`, `)}_`:e.record.content},score:e.score}))}if(D.length===0)return{content:[{type:`text`,text:`No results found for the given query.`}]};let A,j;if(C>0&&!h&&(j="> **Note:** `graph_hops` was set but no graph store is available. Graph augmentation skipped."),C>0&&h)try{let e=await o(h,D.map(e=>({recordId:e.record.id,score:e.score,sourcePath:e.record.sourcePath})),{hops:C,maxPerHit:5});A=new Map;for(let t of e)if(t.graphContext.nodes.length>0){let e=t.graphContext.nodes.slice(0,5).map(e=>` - **${e.name}** (${e.type})`).join(`
2
+ `),n=t.graphContext.edges.slice(0,5).map(e=>` - ${e.fromId} —[${e.type}]→ ${e.toId}`).join(`
3
+ `),r=[`- **Graph Context** (${C} hop${C>1?`s`:``}):`];e&&r.push(` Entities:\n${e}`),n&&r.push(` Relationships:\n${n}`),A.set(t.recordId,r.join(`
4
+ `))}}catch(e){u.warn(`Graph augmentation failed`,a(e)),j=`> **Note:** Graph augmentation failed. Results shown without graph context.`}let M=D.map((e,t)=>{let n=e.record;return`${`### Result ${t+1} (score: ${e.score.toFixed(3)})`}\n${[`- **Source**: ${n.sourcePath}`,n.headingPath?`- **Section**: ${n.headingPath}`:null,`- **Type**: ${n.contentType}`,n.startLine?`- **Lines**: ${n.startLine}-${n.endLine}`:null,n.origin===`indexed`?null:`- **Origin**: ${n.origin}`,n.category?`- **Category**: ${n.category}`:null,n.tags?.length?`- **Tags**: ${n.tags.join(`, `)}`:null,A?.get(n.id)??null].filter(Boolean).join(`
5
+ `)}\n\n${n.content}`}).join(`
13
6
 
14
7
  ---
15
8
 
16
- `),I=d==="hybrid"?"hybrid (vector + keyword RRF)":d==="keyword"?"keyword (FTS)":"semantic (vector)",L=E(l,e),B=L.length>0?`
17
- _Distinctive terms: ${L.map(u=>`\`${u}\``).join(", ")}_`:"",C=await G(a,l),$=[];if(l.length===0)$.push("`reindex` \u2014 no results found, index may be stale"),$.push("`find` \u2014 try federated search with glob/regex");else{const u=l[0]?.record.sourcePath;u&&$.push(`\`lookup\` \u2014 see all chunks from \`${u}\``),$.push("`symbol` \u2014 resolve a specific symbol from the results"),$.push("`compact` \u2014 compress a result file for focused reading")}let T=[R?`${R}
18
-
19
- `:"",C?`${C}
20
-
21
- `:"",F,`
22
-
23
- ---
24
- _Search mode: ${I} | ${l.length} results_${B}`,`
25
- _Next: ${$.join(" | ")}_`].join("");return b&&(T=D(T,b)),{content:[{type:"text",text:T}]}}catch(x){return console.error("[KB] Search failed:",x),{content:[{type:"text",text:`Search failed: ${x.message}`}],isError:!0}}})}export{Q as registerSearchTool};
9
+ `),N=n===`hybrid`?`hybrid (vector + keyword RRF)`:n===`keyword`?`keyword (FTS)`:`semantic (vector)`,P=m(D,e),F=P.length>0?`\n_Distinctive terms: ${P.map(e=>`\`${e}\``).join(`, `)}_`:``,I=await g(l,D),L=[];if(D.length===0)L.push("`reindex` — no results found, index may be stale"),L.push("`find` — try federated search with glob/regex");else{let e=D[0]?.record.sourcePath;e&&L.push(`\`lookup\` — see all chunks from \`${e}\``),L.push("`symbol` — resolve a specific symbol from the results"),L.push("`compact` — compress a result file for focused reading")}let R=[j?`${j}\n\n`:``,I?`${I}\n\n`:``,M,`\n\n---\n_Search mode: ${N} | ${D.length} results_${F}`,`\n_Next: ${L.join(` | `)}_`].join(``);return w&&(R=s(R,w)),{content:[{type:`text`,text:R}]}}catch(e){return u.error(`Search failed`,a(e)),{content:[{type:`text`,text:`Search failed. Check server logs for details.`}],isError:!0}}})}export{_ as registerSearchTool};
10
+ //# sourceMappingURL=search.tool.js.map
@@ -1,4 +1,8 @@
1
- import type { IGraphStore, IKnowledgeStore } from '@kb/store';
2
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- export declare function registerStatusTool(server: McpServer, store: IKnowledgeStore, graphStore?: IGraphStore): void;
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { IGraphStore, IKnowledgeStore } from "@kb/store";
3
+
4
+ //#region packages/server/src/tools/status.tool.d.ts
5
+ declare function registerStatusTool(server: McpServer, store: IKnowledgeStore, graphStore?: IGraphStore): void;
6
+ //#endregion
7
+ export { registerStatusTool };
4
8
  //# sourceMappingURL=status.tool.d.ts.map
@@ -1,3 +1,3 @@
1
- import{TreeSitterRuntime as d}from"../../../chunker/dist/index.js";function u(i,n,a){i.registerTool("status",{description:"Get the current status and statistics of the knowledge base index."},async()=>{try{const e=await n.getStats(),r=await n.listSourcePaths(),o=["## Knowledge Base Status","",`- **Total Records**: ${e.totalRecords}`,`- **Total Files**: ${e.totalFiles}`,`- **Last Indexed**: ${e.lastIndexedAt??"Never"}`,"","### Content Types",...Object.entries(e.contentTypeBreakdown).map(([t,s])=>`- ${t}: ${s}`),"","### Indexed Files",...r.slice(0,50).map(t=>`- ${t}`),r.length>50?`
2
- ... and ${r.length-50} more files`:""];if(a)try{const t=await a.getStats();o.push("","### Knowledge Graph",`- **Nodes**: ${t.nodeCount}`,`- **Edges**: ${t.edgeCount}`,...Object.entries(t.nodeTypes).map(([s,c])=>` - ${s}: ${c}`))}catch{o.push("","### Knowledge Graph","- Graph store unavailable")}return o.push("","### Runtime",`- **Tree-sitter**: ${d.get()?"\u2705 Available":"\u26A0 Unavailable (regex fallback)"}`),{content:[{type:"text",text:o.join(`
3
- `)+"\n\n---\n_Next: Use `search` to query indexed content, `graph(stats)` to explore the knowledge graph, or `reindex` to refresh the index._"}]}}catch(e){return console.error("[KB] Status failed:",e),{content:[{type:"text",text:`Status check failed: ${e.message}`}],isError:!0}}})}export{u as registerStatusTool};
1
+ import{TreeSitterRuntime as e}from"../../../chunker/dist/index.js";import{createLogger as t,serializeError as n}from"../../../core/dist/index.js";const r=t(`tools`);function i(t,i,a){t.registerTool(`status`,{description:`Get the current status and statistics of the knowledge base index.`},async()=>{try{let t=await i.getStats(),n=await i.listSourcePaths(),r=[`## Knowledge Base Status`,``,`- **Total Records**: ${t.totalRecords}`,`- **Total Files**: ${t.totalFiles}`,`- **Last Indexed**: ${t.lastIndexedAt??`Never`}`,``,`### Content Types`,...Object.entries(t.contentTypeBreakdown).map(([e,t])=>`- ${e}: ${t}`),``,`### Indexed Files`,...n.slice(0,50).map(e=>`- ${e}`),n.length>50?`\n... and ${n.length-50} more files`:``];if(a)try{let e=await a.getStats();r.push(``,`### Knowledge Graph`,`- **Nodes**: ${e.nodeCount}`,`- **Edges**: ${e.edgeCount}`,...Object.entries(e.nodeTypes).map(([e,t])=>` - ${e}: ${t}`))}catch{r.push(``,`### Knowledge Graph`,`- Graph store unavailable`)}return r.push(``,`### Runtime`,`- **Tree-sitter**: ${e.get()?`✅ Available`:`⚠ Unavailable (regex fallback)`}`),{content:[{type:`text`,text:r.join(`
2
+ `)+"\n\n---\n_Next: Use `search` to query indexed content, `graph(stats)` to explore the knowledge graph, or `reindex` to refresh the index._"}]}}catch(e){return r.error(`Status failed`,n(e)),{content:[{type:`text`,text:`Status check failed. Check server logs for details.`}],isError:!0}}})}export{i as registerStatusTool};
3
+ //# sourceMappingURL=status.tool.js.map
@@ -1,35 +1,37 @@
1
- /**
2
- * MCP tool registrations for @kb/tools capabilities.
3
- */
4
- import type { IEmbedder } from '@kb/embeddings';
5
- import type { IKnowledgeStore } from '@kb/store';
6
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
- export declare function registerCompactTool(server: McpServer, embedder: IEmbedder): void;
8
- export declare function registerScopeMapTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
9
- export declare function registerFindTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
10
- export declare function registerParseOutputTool(server: McpServer): void;
11
- export declare function registerWorksetTool(server: McpServer): void;
12
- export declare function registerCheckTool(server: McpServer): void;
13
- export declare function registerBatchTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
14
- export declare function registerSymbolTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
15
- export declare function registerEvalTool(server: McpServer): void;
16
- export declare function registerTestRunTool(server: McpServer): void;
17
- export declare function registerStashTool(server: McpServer): void;
18
- export declare function registerGitContextTool(server: McpServer): void;
19
- export declare function registerDiffParseTool(server: McpServer): void;
20
- export declare function registerRenameTool(server: McpServer): void;
21
- export declare function registerCodemodTool(server: McpServer): void;
22
- export declare function registerFileSummaryTool(server: McpServer): void;
23
- export declare function registerCheckpointTool(server: McpServer): void;
24
- export declare function registerDataTransformTool(server: McpServer): void;
25
- export declare function registerTraceTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
26
- export declare function registerProcessTool(server: McpServer): void;
27
- export declare function registerWatchTool(server: McpServer): void;
28
- export declare function registerDeadSymbolsTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
29
- export declare function registerDelegateTool(server: McpServer): void;
30
- export declare function registerLaneTool(server: McpServer): void;
31
- export declare function registerHealthTool(server: McpServer): void;
32
- export declare function registerQueueTool(server: McpServer): void;
33
- export declare function registerWebFetchTool(server: McpServer): void;
34
- export declare function registerGuideTool(server: McpServer): void;
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { IEmbedder } from "@kb/embeddings";
3
+ import { IKnowledgeStore } from "@kb/store";
4
+ import { FileCache } from "@kb/tools";
5
+
6
+ //#region packages/server/src/tools/toolkit.tools.d.ts
7
+ declare function registerCompactTool(server: McpServer, embedder: IEmbedder, cache: FileCache): void;
8
+ declare function registerScopeMapTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
9
+ declare function registerFindTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
10
+ declare function registerParseOutputTool(server: McpServer): void;
11
+ declare function registerWorksetTool(server: McpServer): void;
12
+ declare function registerCheckTool(server: McpServer): void;
13
+ declare function registerBatchTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
14
+ declare function registerSymbolTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
15
+ declare function registerEvalTool(server: McpServer): void;
16
+ declare function registerTestRunTool(server: McpServer): void;
17
+ declare function registerStashTool(server: McpServer): void;
18
+ declare function registerGitContextTool(server: McpServer): void;
19
+ declare function registerDiffParseTool(server: McpServer): void;
20
+ declare function registerRenameTool(server: McpServer): void;
21
+ declare function registerCodemodTool(server: McpServer): void;
22
+ declare function registerFileSummaryTool(server: McpServer, cache: FileCache): void;
23
+ declare function registerCheckpointTool(server: McpServer): void;
24
+ declare function registerDataTransformTool(server: McpServer): void;
25
+ declare function registerTraceTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
26
+ declare function registerProcessTool(server: McpServer): void;
27
+ declare function registerWatchTool(server: McpServer): void;
28
+ declare function registerDeadSymbolsTool(server: McpServer, embedder: IEmbedder, store: IKnowledgeStore): void;
29
+ declare function registerDelegateTool(server: McpServer): void;
30
+ declare function registerLaneTool(server: McpServer): void;
31
+ declare function registerHealthTool(server: McpServer): void;
32
+ declare function registerQueueTool(server: McpServer): void;
33
+ declare function registerWebFetchTool(server: McpServer): void;
34
+ declare function registerGuideTool(server: McpServer): void;
35
+ //#endregion
36
+ export { registerBatchTool, registerCheckTool, registerCheckpointTool, registerCodemodTool, registerCompactTool, registerDataTransformTool, registerDeadSymbolsTool, registerDelegateTool, registerDiffParseTool, registerEvalTool, registerFileSummaryTool, registerFindTool, registerGitContextTool, registerGuideTool, registerHealthTool, registerLaneTool, registerParseOutputTool, registerProcessTool, registerQueueTool, registerRenameTool, registerScopeMapTool, registerStashTool, registerSymbolTool, registerTestRunTool, registerTraceTool, registerWatchTool, registerWebFetchTool, registerWorksetTool };
35
37
  //# sourceMappingURL=toolkit.tools.d.ts.map
@@ -1,24 +1,20 @@
1
- import{addToWorkset as S,batch as $,check as x,checkpointLatest as k,checkpointList as v,checkpointLoad as E,checkpointSave as T,codemod as q,compact as _,dataTransform as M,delegate as O,delegateListModels as R,deleteWorkset as N,diffParse as D,evaluate as I,fileSummary as C,find as b,findDeadSymbols as J,findExamples as j,getWorkset as L,gitContext as F,guide as A,health as W,laneCreate as P,laneDiff as U,laneDiscard as B,laneList as K,laneMerge as z,laneStatus as G,listWorksets as Q,parseOutput as H,processList as V,processLogs as X,processStart as Y,processStatus as Z,processStop as ee,queueClear as te,queueCreate as re,queueDelete as ne,queueDone as oe,queueFail as se,queueGet as ie,queueList as ae,queueNext as ce,queuePush as le,removeFromWorkset as de,rename as ue,saveWorkset as pe,scopeMap as fe,stashClear as me,stashDelete as ge,stashGet as he,stashList as ye,stashSet as xe,summarizeCheckResult as be,symbol as we,testRun as Se,trace as $e,truncateToTokenBudget as h,watchList as ke,watchStart as ve,watchStop as Ee,webFetch as Te}from"../../../tools/dist/index.js";import{z as r}from"zod";function Pe(t,o){t.registerTool("compact",{description:"Compress text to relevant sections using embedding similarity (no LLM). Provide either `text` or `path` (server reads the file \u2014 saves a round-trip). Segments by paragraph/sentence/line.",inputSchema:{text:r.string().optional().describe("The text to compress (provide this OR path, not both)"),path:r.string().optional().describe("File path to read server-side \u2014 avoids read_file round-trip + token doubling (provide this OR text)"),query:r.string().describe("Focus query \u2014 what are you trying to understand?"),max_chars:r.number().min(100).max(5e4).default(3e3).describe("Target output size in characters"),segmentation:r.enum(["paragraph","sentence","line"]).default("paragraph").describe("How to split the text for scoring")}},async({text:e,path:n,query:s,max_chars:i,segmentation:a})=>{try{if(!e&&!n)return{content:[{type:"text",text:'Error: Either "text" or "path" must be provided.'}],isError:!0};const c=await _(o,{text:e,path:n,query:s,maxChars:i,segmentation:a});return{content:[{type:"text",text:[`Compressed ${c.originalChars} \u2192 ${c.compressedChars} chars (${(c.ratio*100).toFixed(0)}%)`,`Kept ${c.segmentsKept}/${c.segmentsTotal} segments`,"",c.text].join(`
2
- `)}]}}catch(c){return{content:[{type:"text",text:`Compact failed: ${c.message}`}],isError:!0}}})}function Ue(t,o,e){t.registerTool("scope_map",{description:"Generate a task-scoped reading plan. Given a task description, identifies which files and sections are relevant, with estimated token counts and suggested reading order.",inputSchema:{task:r.string().describe("Description of the task to scope"),max_files:r.number().min(1).max(50).default(15).describe("Maximum files to include"),content_type:r.string().optional().describe("Filter by content type"),max_tokens:r.number().min(100).max(5e4).optional().describe("Maximum token budget for the response. When set, output is truncated to fit.")}},async({task:n,max_files:s,content_type:i,max_tokens:a})=>{try{const c=await fe(o,e,{task:n,maxFiles:s,contentType:i}),d=[`## Scope Map: ${n}`,`Total estimated tokens: ~${c.totalEstimatedTokens}`,"","### Files (by relevance)",...c.files.map((u,f)=>`${f+1}. **${u.path}** (~${u.estimatedTokens} tokens, ${(u.relevance*100).toFixed(0)}% relevant)
3
- ${u.reason}
4
- Focus: ${u.focusRanges.map(p=>`L${p.start}-${p.end}`).join(", ")}`),"","### Suggested Reading Order",...c.readingOrder.map((u,f)=>`${f+1}. ${u}`),"","### Suggested Compact Calls",`_Estimated compressed total: ~${Math.ceil(c.totalEstimatedTokens/5)} tokens_`,...c.compactCommands.map((u,f)=>`${f+1}. ${u}`)].join(`
5
- `)+"\n\n---\n_Next: Use `search` to dive into specific files, or `compact` to compress file contents for context._";return{content:[{type:"text",text:a?h(d,a):d}]}}catch(c){return{content:[{type:"text",text:`Scope map failed: ${c.message}`}],isError:!0}}})}function Be(t,o,e){t.registerTool("find",{description:'Federated search across vector similarity, keyword (FTS), file glob, and regex pattern. Combines strategies, deduplicates, and returns unified results. Use mode "examples" to find real usage examples of a symbol or pattern.',inputSchema:{query:r.string().optional().describe('Semantic/keyword search query (required for mode "examples")'),glob:r.string().optional().describe("File glob pattern (search mode only)"),pattern:r.string().optional().describe("Regex pattern to match in content (search mode only)"),limit:r.number().min(1).max(50).default(10).describe("Max results"),content_type:r.string().optional().describe("Filter by content type"),mode:r.enum(["search","examples"]).default("search").describe('Mode: "search" (default) for federated search, "examples" to find usage examples of a symbol/pattern'),max_tokens:r.number().min(100).max(5e4).optional().describe("Maximum token budget for the response. When set, output is truncated to fit.")}},async({query:n,glob:s,pattern:i,limit:a,content_type:c,mode:l,max_tokens:d})=>{try{if(l==="examples"){if(!n)return{content:[{type:"text",text:'Error: "query" is required for mode "examples".'}],isError:!0};const p=await j(o,e,{query:n,limit:a,contentType:c}),g=JSON.stringify(p,null,2);return{content:[{type:"text",text:d?h(g,d):g}]}}const u=await b(o,e,{query:n,glob:s,pattern:i,limit:a,contentType:c});if(u.results.length===0)return{content:[{type:"text",text:"No results found."}]};const f=[`Found ${u.totalFound} results via ${u.strategies.join(" + ")}`,"",...u.results.map(p=>{const g=p.lineRange?`:${p.lineRange.start}-${p.lineRange.end}`:"",w=p.preview?`
6
- ${p.preview.slice(0,100)}...`:"";return`- [${p.source}] ${p.path}${g} (${(p.score*100).toFixed(0)}%)${w}`})];return{content:[{type:"text",text:d?h(f.join(`
7
- `),d):f.join(`
8
- `)}]}}catch(u){return{content:[{type:"text",text:`Find failed: ${u.message}`}],isError:!0}}})}function Ke(t){t.registerTool("parse_output",{description:"Parse structured data from build tool output. Supports tsc, vitest, biome, and git status. Auto-detects the tool or specify explicitly.",inputSchema:{output:r.string().describe("Raw output text from a build tool"),tool:r.enum(["tsc","vitest","biome","git-status"]).optional().describe("Tool to parse as (auto-detects if omitted)")}},async({output:o,tool:e})=>{try{const n=o.replace(/\\n/g,`
9
- `).replace(/\\t/g," "),s=H(n,e);return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}catch(n){return{content:[{type:"text",text:`Parse failed: ${n.message}`}],isError:!0}}})}function ze(t){t.registerTool("workset",{description:"Manage named file sets (worksets). Save, load, list, add/remove files. Worksets persist across sessions in .kb-state/worksets.json.",inputSchema:{action:r.enum(["save","get","list","delete","add","remove"]).describe("Operation to perform"),name:r.string().optional().describe("Workset name (required for all except list)"),files:r.array(r.string()).optional().describe("File paths (required for save, add, remove)"),description:r.string().optional().describe("Description (for save)")}},async({action:o,name:e,files:n,description:s})=>{try{switch(o){case"save":{if(!e||!n)throw new Error("name and files required for save");const i=pe(e,n,{description:s});return{content:[{type:"text",text:`Saved workset "${i.name}" with ${i.files.length} files.`}]}}case"get":{if(!e)throw new Error("name required for get");const i=L(e);return i?{content:[{type:"text",text:JSON.stringify(i,null,2)}]}:{content:[{type:"text",text:`Workset "${e}" not found.`}]}}case"list":{const i=Q();return i.length===0?{content:[{type:"text",text:"No worksets."}]}:{content:[{type:"text",text:i.map(c=>`- **${c.name}** (${c.files.length} files) \u2014 ${c.description??"no description"}`).join(`
10
- `)}]}}case"delete":{if(!e)throw new Error("name required for delete");return{content:[{type:"text",text:N(e)?`Deleted workset "${e}".`:`Workset "${e}" not found.`}]}}case"add":{if(!e||!n)throw new Error("name and files required for add");const i=S(e,n);return{content:[{type:"text",text:`Added to workset "${i.name}": now ${i.files.length} files.`}]}}case"remove":{if(!e||!n)throw new Error("name and files required for remove");const i=de(e,n);return i?{content:[{type:"text",text:`Removed from workset "${i.name}": now ${i.files.length} files.`}]}:{content:[{type:"text",text:`Workset "${e}" not found.`}]}}}}catch(i){return{content:[{type:"text",text:`Workset operation failed: ${i.message}`}],isError:!0}}})}function Ge(t){t.registerTool("check",{description:'Run incremental typecheck (tsc) and lint (biome) on the project or specific files. Returns structured error and warning lists. Default detail level is "summary" (~300 tokens).',inputSchema:{files:r.array(r.string()).optional().describe("Specific files to check (if omitted, checks all)"),cwd:r.string().optional().describe("Working directory"),skip_types:r.boolean().default(!1).describe("Skip TypeScript typecheck"),skip_lint:r.boolean().default(!1).describe("Skip Biome lint"),detail:r.enum(["summary","errors","full"]).default("summary").describe("Output detail level: summary (default, ~300 tokens \u2014 pass/fail + counts + top errors), errors (parsed error objects), full (includes raw terminal output)")}},async({files:o,cwd:e,skip_types:n,skip_lint:s,detail:i})=>{try{const a=await x({files:o,cwd:e,skipTypes:n,skipLint:s,detail:i==="summary"?"errors":i});if(i==="summary"){const c=be(a),l=[];if(a.passed)l.push({tool:"test_run",reason:"Types and lint clean \u2014 run tests next"});else{const d=a.tsc.errors[0]?.file??a.biome.errors[0]?.file;d&&l.push({tool:"symbol",reason:`Resolve failing symbol in ${d}`,suggested_args:{name:d}}),l.push({tool:"check",reason:"Re-check after fixing errors",suggested_args:{detail:"errors"}})}return{content:[{type:"text",text:JSON.stringify({...c,_next:l},null,2)}]}}return{content:[{type:"text",text:JSON.stringify(a,null,2)}]}}catch(a){return{content:[{type:"text",text:`Check failed: ${a.message}`}],isError:!0}}})}function Qe(t,o,e){t.registerTool("batch",{description:"Execute multiple built-in operations in parallel with concurrency control. Supported operation types: search, find, and check.",inputSchema:{operations:r.array(r.object({id:r.string().describe("Unique ID for this operation"),type:r.enum(["search","find","check"]).describe("Built-in operation type"),args:r.record(r.string(),r.unknown()).describe("Arguments for the operation")})).min(1).describe("Operations to execute"),concurrency:r.number().min(1).max(20).default(4).describe("Max concurrent operations")}},async({operations:n,concurrency:s})=>{try{const i=await $(n,async a=>Oe(a,o,e),{concurrency:s});return{content:[{type:"text",text:JSON.stringify(i,null,2)}]}}catch(i){return{content:[{type:"text",text:`Batch failed: ${i.message}`}],isError:!0}}})}function He(t,o,e){t.registerTool("symbol",{description:"Resolve a symbol: find where it is defined, who imports it, and where it is referenced. Works on TypeScript and JavaScript codebases.",inputSchema:{name:r.string().describe("Symbol name to look up (function, class, type, etc.)"),limit:r.number().min(1).max(50).default(20).describe("Max results per category")}},async({name:n,limit:s})=>{try{const i=await we(o,e,{name:n,limit:s});return{content:[{type:"text",text:De(i)}]}}catch(i){return{content:[{type:"text",text:`Symbol lookup failed: ${i.message}`}],isError:!0}}})}function Ve(t){t.registerTool("eval",{description:"Execute a JavaScript or TypeScript snippet in a constrained VM sandbox with a timeout. Captures console output and returned values.",inputSchema:{code:r.string().describe("Code snippet to execute"),lang:r.enum(["js","ts"]).default("js").optional().describe("Language mode: js executes directly, ts strips common type syntax first"),timeout:r.number().min(1).max(6e4).default(5e3).optional().describe("Execution timeout in milliseconds")}},async({code:o,lang:e,timeout:n})=>{try{const s=I({code:o,lang:e,timeout:n});return s.success?{content:[{type:"text",text:`Eval succeeded in ${s.durationMs}ms
11
-
12
- ${s.output}`}]}:{content:[{type:"text",text:`Eval failed in ${s.durationMs}ms: ${s.error??"Unknown error"}`}],isError:!0}}catch(s){return console.error("[KB] Eval failed:",s),{content:[{type:"text",text:`Eval failed: ${s.message}`}],isError:!0}}})}function Xe(t){t.registerTool("test_run",{description:"Run Vitest for the current project or a subset of files, then return a structured summary of passing and failing tests.",inputSchema:{files:r.array(r.string()).optional().describe("Specific test files or patterns to run"),grep:r.string().optional().describe("Only run tests whose names match this pattern"),cwd:r.string().optional().describe("Working directory for the test run")}},async({files:o,grep:e,cwd:n})=>{try{const s=await Se({files:o,grep:e,cwd:n});return{content:[{type:"text",text:Ie(s)}],isError:!s.passed}}catch(s){return{content:[{type:"text",text:`Test run failed: ${s.message}`}],isError:!0}}})}function Ye(t){t.registerTool("stash",{description:"Persist and retrieve named values in .kb-state/stash.json for intermediate results between tool calls.",inputSchema:{action:r.enum(["set","get","list","delete","clear"]).describe("Operation to perform on the stash"),key:r.string().optional().describe("Entry key for set/get/delete operations"),value:r.string().optional().describe("String or JSON value for set operations")}},async({action:o,key:e,value:n})=>{try{switch(o){case"set":{if(!e)throw new Error("key required for set");const s=xe(e,Le(n??""));return{content:[{type:"text",text:`Stored stash entry "${s.key}" (${s.type}) at ${s.storedAt}.`}]}}case"get":{if(!e)throw new Error("key required for get");const s=he(e);return{content:[{type:"text",text:s?JSON.stringify(s,null,2):`Stash entry "${e}" not found.`}]}}case"list":{const s=ye();return{content:[{type:"text",text:s.length===0?"Stash is empty.":s.map(i=>`- ${i.key} (${i.type}) \u2014 ${i.storedAt}`).join(`
13
- `)}]}}case"delete":{if(!e)throw new Error("key required for delete");return{content:[{type:"text",text:ge(e)?`Deleted stash entry "${e}".`:`Stash entry "${e}" not found.`}]}}case"clear":{const s=me();return{content:[{type:"text",text:`Cleared ${s} stash entr${s===1?"y":"ies"}.`}]}}}}catch(s){return{content:[{type:"text",text:`Stash operation failed: ${s.message}`}],isError:!0}}})}function Ze(t){t.registerTool("git_context",{description:"Summarize the current Git branch, working tree state, recent commits, and optional diff statistics for the repository.",inputSchema:{cwd:r.string().optional().describe("Repository root or working directory"),commit_count:r.number().min(1).max(50).default(5).optional().describe("How many recent commits to include"),include_diff:r.boolean().default(!1).optional().describe("Include diff stat for working tree changes")}},async({cwd:o,commit_count:e,include_diff:n})=>{try{const s=await F({cwd:o,commitCount:e,includeDiff:n});return{content:[{type:"text",text:Ce(s)}]}}catch(s){return{content:[{type:"text",text:`Git context failed: ${s.message}`}],isError:!0}}})}function et(t){t.registerTool("diff_parse",{description:"Parse raw unified diff text into file-level and hunk-level structural changes.",inputSchema:{diff:r.string().describe("Raw unified diff text")}},async({diff:o})=>{try{const e=o.replace(/\\n/g,`
14
- `).replace(/\\t/g," "),n=D({diff:e});return{content:[{type:"text",text:Je(n)}]}}catch(e){return{content:[{type:"text",text:`Diff parse failed: ${e.message}`}],isError:!0}}})}function tt(t){t.registerTool("rename",{description:"Rename a symbol across files using whole-word regex matching for exports, imports, and general usage references.",inputSchema:{old_name:r.string().describe("Existing symbol name to replace"),new_name:r.string().describe("New symbol name to use"),root_path:r.string().describe("Root directory to search within"),extensions:r.array(r.string()).optional().describe("Optional file extensions to include, such as .ts,.tsx,.js,.jsx"),dry_run:r.boolean().default(!0).describe("Preview changes without writing files")}},async({old_name:o,new_name:e,root_path:n,extensions:s,dry_run:i})=>{try{const a=await ue({oldName:o,newName:e,rootPath:n,extensions:s,dryRun:i});return{content:[{type:"text",text:JSON.stringify(a,null,2)}]}}catch(a){return{content:[{type:"text",text:`Rename failed: ${a.message}`}],isError:!0}}})}function rt(t){t.registerTool("codemod",{description:"Apply regex-based codemod rules across files and return structured before/after changes for each affected line.",inputSchema:{root_path:r.string().describe("Root directory to transform within"),rules:r.array(r.object({description:r.string().describe("What the codemod rule does"),pattern:r.string().describe("Regex pattern in string form"),replacement:r.string().describe("Replacement string with optional capture groups")})).min(1).describe("Codemod rules to apply"),dry_run:r.boolean().default(!0).describe("Preview changes without writing files")}},async({root_path:o,rules:e,dry_run:n})=>{try{const s=await q({rootPath:o,rules:e,dryRun:n});return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}catch(s){return{content:[{type:"text",text:`Codemod failed: ${s.message}`}],isError:!0}}})}function nt(t){t.registerTool("file_summary",{description:"Create a concise structural summary of a source file: imports, exports, functions, classes, interfaces, and types.",inputSchema:{path:r.string().describe("Absolute path to the file to summarize")}},async({path:o})=>{try{const e=await C({path:o});return{content:[{type:"text",text:je(e)}]}}catch(e){return{content:[{type:"text",text:`File summary failed: ${e.message}`}],isError:!0}}})}function ot(t){t.registerTool("checkpoint",{description:"Save and restore lightweight session checkpoints in .kb-state/checkpoints for cross-session continuity.",inputSchema:{action:r.enum(["save","load","list","latest"]).describe("Checkpoint action to perform"),label:r.string().optional().describe("Checkpoint label for save, or checkpoint id for load"),data:r.string().optional().describe("JSON object string for save actions"),notes:r.string().optional().describe("Optional notes for save actions")}},async({action:o,label:e,data:n,notes:s})=>{try{switch(o){case"save":{if(!e)throw new Error("label required for save");const i=T(e,Fe(n),{notes:s});return{content:[{type:"text",text:y(i)}]}}case"load":{if(!e)throw new Error("label required for load");const i=E(e);return{content:[{type:"text",text:i?y(i):`Checkpoint "${e}" not found.`}]}}case"list":{const i=v();return{content:[{type:"text",text:i.length===0?"No checkpoints saved.":i.map(a=>`- ${a.id} \u2014 ${a.label} (${a.createdAt})`).join(`
15
- `)}]}}case"latest":{const i=k();return{content:[{type:"text",text:i?y(i):"No checkpoints saved."}]}}}}catch(i){return{content:[{type:"text",text:`Checkpoint failed: ${i.message}`}],isError:!0}}})}function st(t){t.registerTool("data_transform",{description:"Apply small jq-like transforms to JSON input for filtering, projection, grouping, and path extraction.",inputSchema:{input:r.string().describe("Input JSON string"),expression:r.string().describe("Transform expression to apply")}},async({input:o,expression:e})=>{try{return{content:[{type:"text",text:M({input:o,expression:e}).outputString}]}}catch(n){return{content:[{type:"text",text:`Data transform failed: ${n.message}`}],isError:!0}}})}function it(t,o,e){t.registerTool("trace",{description:"Trace data flow through a codebase by following imports, call sites, and references from a starting symbol or file location.",inputSchema:{start:r.string().describe("Starting point \u2014 symbol name or file:line reference"),direction:r.enum(["forward","backward","both"]).describe("Which direction to trace relationships"),max_depth:r.number().min(1).max(10).default(3).optional().describe("Maximum trace depth")}},async({start:n,direction:s,max_depth:i})=>{try{const a=await $e(o,e,{start:n,direction:s,maxDepth:i});return{content:[{type:"text",text:JSON.stringify(a,null,2)}]}}catch(a){return{content:[{type:"text",text:`Trace failed: ${a.message}`}],isError:!0}}})}function at(t){t.registerTool("process",{description:"Start, stop, inspect, list, and tail logs for in-memory managed child processes.",inputSchema:{action:r.enum(["start","stop","status","list","logs"]).describe("Process action to perform"),id:r.string().optional().describe("Managed process ID"),command:r.string().optional().describe("Executable to start"),args:r.array(r.string()).optional().describe("Arguments for start actions"),tail:r.number().min(1).max(500).optional().describe("Log lines to return for logs actions")}},async({action:o,id:e,command:n,args:s,tail:i})=>{try{switch(o){case"start":{if(!e||!n)throw new Error("id and command are required for start");return{content:[{type:"text",text:JSON.stringify(Y(e,n,s??[]),null,2)}]}}case"stop":{if(!e)throw new Error("id is required for stop");return{content:[{type:"text",text:JSON.stringify(ee(e)??null,null,2)}]}}case"status":{if(!e)throw new Error("id is required for status");return{content:[{type:"text",text:JSON.stringify(Z(e)??null,null,2)}]}}case"list":return{content:[{type:"text",text:JSON.stringify(V(),null,2)}]};case"logs":{if(!e)throw new Error("id is required for logs");return{content:[{type:"text",text:JSON.stringify(X(e,i),null,2)}]}}}}catch(a){return{content:[{type:"text",text:`Process action failed: ${a.message}`}],isError:!0}}})}function ct(t){t.registerTool("watch",{description:"Start, stop, and list in-memory filesystem watchers for a directory.",inputSchema:{action:r.enum(["start","stop","list"]).describe("Watch action to perform"),path:r.string().optional().describe("Directory path to watch for start actions"),id:r.string().optional().describe("Watcher ID for stop actions")}},async({action:o,path:e,id:n})=>{try{switch(o){case"start":{if(!e)throw new Error("path is required for start");return{content:[{type:"text",text:JSON.stringify(ve({path:e}),null,2)}]}}case"stop":{if(!n)throw new Error("id is required for stop");return{content:[{type:"text",text:JSON.stringify({stopped:Ee(n)},null,2)}]}}case"list":return{content:[{type:"text",text:JSON.stringify(ke(),null,2)}]}}}catch(s){return{content:[{type:"text",text:`Watch action failed: ${s.message}`}],isError:!0}}})}function lt(t,o,e){t.registerTool("dead_symbols",{description:"Find exported symbols that appear to be unused because they are never imported or re-exported.",inputSchema:{path:r.string().optional().describe("Root path to scope the search (default: cwd)"),limit:r.number().min(1).max(500).default(100).optional().describe("Maximum exported symbols to scan")}},async({path:n,limit:s})=>{try{const i=await J(o,e,{rootPath:n,limit:s}),a=["## Dead Symbol Analysis","",`**Exports scanned:** ${i.totalExports}`,`**Dead in source:** ${i.totalDeadSource} (actionable)`,`**Dead in docs:** ${i.totalDeadDocs} (informational \u2014 code samples in .md files)`,""];if(i.deadInSource.length>0){a.push("### Dead in Source (actionable)");for(const c of i.deadInSource)a.push(`- \`${c.name}\` (${c.kind}) \u2014 ${c.path}:${c.line}`);a.push("")}if(i.deadInDocs.length>0){a.push("### Dead in Docs (informational)"),a.push(`_${i.totalDeadDocs} symbol(s) found only in documentation code samples \u2014 not actionable dead code._`);for(const c of i.deadInDocs.slice(0,5))a.push(`- \`${c.name}\` \u2014 ${c.path}:${c.line}`);i.deadInDocs.length>5&&a.push(`- _... ${i.deadInDocs.length-5} more omitted_`)}return i.totalDeadSource>0?a.push("","---",`_Next: \`codemod\` to remove ${i.totalDeadSource} unused exports | \`symbol\` to verify usage before removing_`):a.push("","---","_Next: `check` \u2014 no dead symbols found, validate types and lint_"),{content:[{type:"text",text:a.join(`
16
- `)}]}}catch(i){return{content:[{type:"text",text:`Dead symbol scan failed: ${i.message}`}],isError:!0}}})}function dt(t){t.registerTool("delegate",{description:"Delegate a subtask to a local Ollama model. Use for summarization, classification, naming, or any task that can offload work from the host agent. Fails fast if Ollama is not running.",inputSchema:{prompt:r.string().describe("The task or question to send to the local model"),model:r.string().optional().describe("Ollama model name (default: first available model)"),system:r.string().optional().describe("System prompt for the model"),context:r.string().optional().describe("Context text to include before the prompt (e.g. file contents)"),temperature:r.number().min(0).max(2).default(.3).optional().describe("Sampling temperature (0=deterministic, default 0.3)"),timeout:r.number().min(1e3).max(6e5).default(12e4).optional().describe("Timeout in milliseconds (default 120000)"),action:r.enum(["generate","list_models"]).default("generate").optional().describe("Action: generate a response or list available models")}},async({prompt:o,model:e,system:n,context:s,temperature:i,timeout:a,action:c})=>{try{if(c==="list_models"){const d=await R();return{content:[{type:"text",text:JSON.stringify({models:d,count:d.length,_Next:"Use delegate with a model name"},null,2)}]}}const l=await O({prompt:o,model:e,system:n,context:s,temperature:i,timeout:a});return l.error?{content:[{type:"text",text:JSON.stringify({error:l.error,model:l.model,durationMs:l.durationMs},null,2)}],isError:!0}:{content:[{type:"text",text:JSON.stringify({model:l.model,response:l.response,durationMs:l.durationMs,tokenCount:l.tokenCount,_Next:"Use the response in your workflow. stash to save it."},null,2)}]}}catch(l){return{content:[{type:"text",text:`Delegate failed: ${l.message}`}],isError:!0}}})}function ut(t){t.registerTool("lane",{description:"Manage verified lanes \u2014 isolated file copies for parallel exploration. Create a lane, make changes, diff, merge back, or discard.",inputSchema:{action:r.enum(["create","list","status","diff","merge","discard"]).describe("Lane action to perform"),name:r.string().optional().describe("Lane name (required for create/status/diff/merge/discard)"),files:r.array(r.string()).optional().describe("File paths to copy into the lane (required for create)")}},async({action:o,name:e,files:n})=>{try{switch(o){case"create":{if(!e)throw new Error("name is required for create");if(!n||n.length===0)throw new Error("files are required for create");const s=P(e,n);return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}case"list":return{content:[{type:"text",text:JSON.stringify(K(),null,2)}]};case"status":{if(!e)throw new Error("name is required for status");return{content:[{type:"text",text:JSON.stringify(G(e),null,2)}]}}case"diff":{if(!e)throw new Error("name is required for diff");return{content:[{type:"text",text:JSON.stringify(U(e),null,2)}]}}case"merge":{if(!e)throw new Error("name is required for merge");return{content:[{type:"text",text:JSON.stringify(z(e),null,2)}]}}case"discard":{if(!e)throw new Error("name is required for discard");return{content:[{type:"text",text:JSON.stringify({discarded:B(e)},null,2)}]}}}}catch(s){return{content:[{type:"text",text:`Lane action failed: ${s.message}`}],isError:!0}}})}function pt(t){t.registerTool("health",{description:"Run project health checks \u2014 verifies package.json, tsconfig, scripts, lockfile, README, LICENSE, .gitignore.",inputSchema:{path:r.string().optional().describe("Root directory to check (defaults to cwd)")}},async({path:o})=>{try{const e=W(o);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:`Health check failed: ${e.message}`}],isError:!0}}})}function ft(t){t.registerTool("queue",{description:"Manage task queues for sequential agent operations. Push items, take next, mark done/failed, list queues.",inputSchema:{action:r.enum(["create","push","next","done","fail","get","list","clear","delete"]).describe("Queue action"),name:r.string().optional().describe("Queue name (required for most actions)"),title:r.string().optional().describe("Item title (required for push)"),id:r.string().optional().describe("Item ID (required for done/fail)"),data:r.unknown().optional().describe("Arbitrary data to attach to a queue item"),error:r.string().optional().describe("Error message (required for fail)")}},async({action:o,name:e,title:n,id:s,data:i,error:a})=>{try{switch(o){case"create":{if(!e)throw new Error("name is required for create");return{content:[{type:"text",text:JSON.stringify(re(e),null,2)}]}}case"push":{if(!e)throw new Error("name is required for push");if(!n)throw new Error("title is required for push");return{content:[{type:"text",text:JSON.stringify(le(e,n,i),null,2)}]}}case"next":{if(!e)throw new Error("name is required for next");const c=ce(e);return{content:[{type:"text",text:JSON.stringify(c,null,2)}]}}case"done":{if(!e)throw new Error("name is required for done");if(!s)throw new Error("id is required for done");return{content:[{type:"text",text:JSON.stringify(oe(e,s),null,2)}]}}case"fail":{if(!e)throw new Error("name is required for fail");if(!s)throw new Error("id is required for fail");if(!a)throw new Error("error is required for fail");return{content:[{type:"text",text:JSON.stringify(se(e,s,a),null,2)}]}}case"get":{if(!e)throw new Error("name is required for get");return{content:[{type:"text",text:JSON.stringify(ie(e),null,2)}]}}case"list":return{content:[{type:"text",text:JSON.stringify(ae(),null,2)}]};case"clear":{if(!e)throw new Error("name is required for clear");return{content:[{type:"text",text:JSON.stringify({cleared:te(e)},null,2)}]}}case"delete":{if(!e)throw new Error("name is required for delete");return{content:[{type:"text",text:JSON.stringify({deleted:ne(e)},null,2)}]}}}}catch(c){return{content:[{type:"text",text:`Queue action failed: ${c.message}`}],isError:!0}}})}const qe=r.object({query:r.string(),limit:r.number().min(1).max(20).default(5).optional(),search_mode:r.enum(["hybrid","semantic","keyword"]).default("hybrid").optional(),content_type:r.string().optional(),origin:r.enum(["indexed","curated","produced"]).optional(),category:r.string().optional(),tags:r.array(r.string()).optional(),min_score:r.number().min(0).max(1).default(.25).optional()}),_e=r.object({query:r.string().optional(),glob:r.string().optional(),pattern:r.string().optional(),limit:r.number().min(1).max(50).default(10).optional(),content_type:r.string().optional(),cwd:r.string().optional()}),Me=r.object({files:r.array(r.string()).optional(),cwd:r.string().optional(),skip_types:r.boolean().optional(),skip_lint:r.boolean().optional()});async function Oe(t,o,e){switch(t.type){case"search":{const n=qe.parse(t.args);return Re(o,e,n)}case"find":{const n=_e.parse(t.args);if(!n.query&&!n.glob&&!n.pattern)throw new Error("find operation requires query, glob, or pattern");return b(o,e,{query:n.query,glob:n.glob,pattern:n.pattern,limit:n.limit,contentType:n.content_type,cwd:n.cwd})}case"check":{const n=Me.parse(t.args);return x({files:n.files,cwd:n.cwd,skipTypes:n.skip_types,skipLint:n.skip_lint})}default:throw new Error(`Unsupported batch operation type: ${t.type}`)}}async function Re(t,o,e){const n=e.limit??5,s={limit:n,minScore:e.min_score??.25,contentType:e.content_type,origin:e.origin,category:e.category,tags:e.tags},i=t.embedQuery?.bind(t)??t.embed.bind(t);if(e.search_mode==="keyword")return(await o.ftsSearch(e.query,s)).slice(0,n);const a=await i(e.query);if(e.search_mode==="semantic")return o.search(a,s);const[c,l]=await Promise.all([o.search(a,{...s,limit:n*2}),o.ftsSearch(e.query,{...s,limit:n*2})]);return Ne(c,l).slice(0,n)}function Ne(t,o,e=60){const n=new Map;for(let s=0;s<t.length;s++){const i=t[s];n.set(i.record.id,{record:i.record,score:1/(e+s+1)})}for(let s=0;s<o.length;s++){const i=o[s],a=n.get(i.record.id);if(a){a.score+=1/(e+s+1);continue}n.set(i.record.id,{record:i.record,score:1/(e+s+1)})}return[...n.values()].sort((s,i)=>i.score-s.score)}function De(t){const o=[`Symbol: ${t.name}`];if(t.definedIn?o.push(`Defined in: ${t.definedIn.path}:${t.definedIn.line} (${t.definedIn.kind})`):o.push("Defined in: not found"),o.push("","Imported by:"),t.importedBy.length===0)o.push(" none");else for(const e of t.importedBy)o.push(` - ${e.path}:${e.line} ${e.importStatement}`);if(o.push("","Referenced in:"),t.referencedIn.length===0)o.push(" none");else for(const e of t.referencedIn)o.push(` - ${e.path}:${e.line} ${e.context}`);return o.join(`
17
- `)}function Ie(t){const o=[`Vitest run: ${t.passed?"passed":"failed"}`,`Duration: ${t.durationMs}ms`,`Passed: ${t.summary.passed}`,`Failed: ${t.summary.failed}`,`Skipped: ${t.summary.skipped}`];t.summary.suites!==void 0&&o.push(`Suites: ${t.summary.suites}`);const e=t.summary.tests.filter(n=>n.status==="fail");if(e.length>0){o.push("","Failed tests:");for(const n of e)o.push(`- ${n.name}${n.file?` (${n.file})`:""}`),n.error&&o.push(` ${n.error}`)}return o.join(`
18
- `)}function Ce(t){const o=[`Branch: ${t.branch}`,`Staged: ${t.status.staged.length}`,...t.status.staged.map(e=>` - ${e}`),`Modified: ${t.status.modified.length}`,...t.status.modified.map(e=>` - ${e}`),`Untracked: ${t.status.untracked.length}`,...t.status.untracked.map(e=>` - ${e}`),"","Recent commits:"];if(t.recentCommits.length===0)o.push(" none");else for(const e of t.recentCommits)o.push(` - ${e.hash} ${e.message}`),o.push(` ${e.author} @ ${e.date}`);return t.diff&&o.push("","Diff stat:",t.diff),o.join(`
19
- `)}function Je(t){if(t.length===0)return"No diff files found.";const o=[];for(const e of t){const n=e.oldPath?` (from ${e.oldPath})`:"";o.push(`${e.path}${n} [${e.status}] +${e.additions} -${e.deletions} (${e.hunks.length} hunks)`);for(const s of e.hunks){const i=s.header?` ${s.header}`:"";o.push(` @@ -${s.oldStart},${s.oldLines} +${s.newStart},${s.newLines} @@${i}`)}}return o.join(`
20
- `)}function je(t){return[t.path,`Language: ${t.language}`,`Lines: ${t.lines}`,`Estimated tokens: ~${t.estimatedTokens}`,"",`Imports (${t.imports.length}):`,...m(t.imports),"",`Exports (${t.exports.length}):`,...m(t.exports),"",`Functions (${t.functions.length}):`,...m(t.functions.map(e=>`${e.name} @ line ${e.line}${e.exported?" [exported]":""}`)),"",`Classes (${t.classes.length}):`,...m(t.classes.map(e=>`${e.name} @ line ${e.line}${e.exported?" [exported]":""}`)),"",`Interfaces (${t.interfaces.length}):`,...m(t.interfaces.map(e=>`${e.name} @ line ${e.line}`)),"",`Types (${t.types.length}):`,...m(t.types.map(e=>`${e.name} @ line ${e.line}`))].join(`
21
- `)}function y(t){const o=[t.id,`Label: ${t.label}`,`Created: ${t.createdAt}`];if(t.notes&&o.push(`Notes: ${t.notes}`),t.files?.length){o.push(`Files: ${t.files.length}`);for(const e of t.files)o.push(` - ${e}`)}return o.push("","Data:",JSON.stringify(t.data,null,2)),o.join(`
22
- `)}function m(t){return t.length===0?[" none"]:t.map(o=>` - ${o}`)}function Le(t){const o=t.trim();if(!o)return"";try{return JSON.parse(o)}catch{return t}}function Fe(t){const o=t?.trim();if(!o)return{};const e=JSON.parse(o);if(!e||typeof e!="object"||Array.isArray(e))throw new Error("data must be a JSON object string");return e}function mt(t){t.registerTool("web_fetch",{description:"PREFERRED web fetcher \u2014 fetch any URL and convert to LLM-optimized markdown. Supports CSS selectors, 4 output modes (markdown/raw/links/outline), smart paragraph-boundary truncation. Strips scripts/styles/nav automatically.",inputSchema:{url:r.string().url().describe("URL to fetch (http/https only)"),mode:r.enum(["markdown","raw","links","outline"]).default("markdown").describe("Output mode: markdown (clean content), raw (HTML), links (extracted URLs), outline (heading hierarchy)"),selector:r.string().optional().describe("CSS selector to extract a specific element instead of auto-detecting main content"),max_length:r.number().min(500).max(1e5).default(15e3).describe("Max characters in output \u2014 truncates at paragraph boundaries"),include_metadata:r.boolean().default(!0).describe("Include page title, description, and URL as a header"),include_links:r.boolean().default(!1).describe("Append extracted links list at the end"),include_images:r.boolean().default(!1).describe("Include image alt texts inline"),timeout:r.number().min(1e3).max(6e4).default(15e3).describe("Request timeout in milliseconds")}},async({url:o,mode:e,selector:n,max_length:s,include_metadata:i,include_links:a,include_images:c,timeout:l})=>{try{const d=await Te({url:o,mode:e,selector:n,maxLength:s,includeMetadata:i,includeLinks:a,includeImages:c,timeout:l}),u=[`## ${d.title||"Web Page"}`,"",d.content];return d.truncated&&u.push("",`_Original length: ${d.originalLength.toLocaleString()} chars_`),u.push("","---","_Next: Use `remember` to save key findings, or `web_fetch` with a `selector` to extract a specific section._"),{content:[{type:"text",text:u.join(`
23
- `)}]}}catch(d){return{content:[{type:"text",text:`Web fetch failed: ${d.message}`}],isError:!0}}})}function gt(t){t.registerTool("guide",{description:"Tool discovery \u2014 given a goal description, recommends which KB tools to use and in what order. Matches against 10 predefined workflows: onboard, audit, bugfix, implement, refactor, search, context, memory, validate, analyze.",inputSchema:{goal:r.string().describe('What you want to accomplish (e.g., "audit this monorepo", "fix a failing test")'),max_recommendations:r.number().min(1).max(10).default(5).describe("Maximum number of tool recommendations")}},async({goal:o,max_recommendations:e})=>{try{const n=A(o,e),s=[`## Recommended Workflow: **${n.workflow}**`,n.description,"","### Tools",...n.tools.map(i=>{const a=i.suggestedArgs?` \u2014 \`${JSON.stringify(i.suggestedArgs)}\``:"";return`${i.order}. **${i.tool}** \u2014 ${i.reason}${a}`})];return n.alternativeWorkflows.length>0&&s.push("",`_Alternative workflows: ${n.alternativeWorkflows.join(", ")}_`),s.push("","---","_Next: Run the first recommended tool, or use `guide` again with a more specific goal._"),{content:[{type:"text",text:s.join(`
24
- `)}]}}catch(n){return{content:[{type:"text",text:`Guide failed: ${n.message}`}],isError:!0}}})}export{Qe as registerBatchTool,Ge as registerCheckTool,ot as registerCheckpointTool,rt as registerCodemodTool,Pe as registerCompactTool,st as registerDataTransformTool,lt as registerDeadSymbolsTool,dt as registerDelegateTool,et as registerDiffParseTool,Ve as registerEvalTool,nt as registerFileSummaryTool,Be as registerFindTool,Ze as registerGitContextTool,gt as registerGuideTool,pt as registerHealthTool,ut as registerLaneTool,Ke as registerParseOutputTool,at as registerProcessTool,ft as registerQueueTool,tt as registerRenameTool,Ue as registerScopeMapTool,Ye as registerStashTool,He as registerSymbolTool,Xe as registerTestRunTool,it as registerTraceTool,ct as registerWatchTool,mt as registerWebFetchTool,ze as registerWorksetTool};
1
+ import{CONTENT_TYPES as e,createLogger as t,serializeError as n}from"../../../core/dist/index.js";import{addToWorkset as r,batch as i,check as a,checkpointLatest as o,checkpointList as s,checkpointLoad as c,checkpointSave as l,codemod as u,compact as d,dataTransform as ee,delegate as te,delegateListModels as ne,deleteWorkset as re,diffParse as ie,evaluate as ae,fileSummary as oe,find as f,findDeadSymbols as p,findExamples as m,getWorkset as h,gitContext as g,guide as _,health as v,laneCreate as y,laneDiff as b,laneDiscard as x,laneList as S,laneMerge as C,laneStatus as w,listWorksets as T,parseOutput as E,processList as D,processLogs as O,processStart as k,processStatus as A,processStop as j,queueClear as M,queueCreate as N,queueDelete as P,queueDone as F,queueFail as I,queueGet as L,queueList as R,queueNext as z,queuePush as B,removeFromWorkset as V,rename as H,saveWorkset as U,scopeMap as W,stashClear as G,stashDelete as K,stashGet as q,stashList as se,stashSet as ce,summarizeCheckResult as le,symbol as ue,testRun as de,trace as fe,truncateToTokenBudget as J,watchList as pe,watchStart as me,watchStop as he,webFetch as ge}from"../../../tools/dist/index.js";import{z as Y}from"zod";const X=t(`tools`);function _e(e,t,r){e.registerTool(`compact`,{description:"Compress text to relevant sections using embedding similarity (no LLM). Provide either `text` or `path` (server reads the file saves a round-trip). Segments by paragraph/sentence/line.",inputSchema:{text:Y.string().optional().describe(`The text to compress (provide this OR path, not both)`),path:Y.string().optional().describe(`File path to read server-side avoids read_file round-trip + token doubling (provide this OR text)`),query:Y.string().describe(`Focus query what are you trying to understand?`),max_chars:Y.number().min(100).max(5e4).default(3e3).describe(`Target output size in characters`),segmentation:Y.enum([`paragraph`,`sentence`,`line`]).default(`paragraph`).describe(`How to split the text for scoring`)}},async({text:e,path:i,query:a,max_chars:o,segmentation:s})=>{try{if(!e&&!i)return{content:[{type:`text`,text:`Error: Either "text" or "path" must be provided.`}],isError:!0};let n=await d(t,{text:e,path:i,query:a,maxChars:o,segmentation:s,cache:r});return{content:[{type:`text`,text:[`Compressed ${n.originalChars} ${n.compressedChars} chars (${(n.ratio*100).toFixed(0)}%)`,`Kept ${n.segmentsKept}/${n.segmentsTotal} segments`,``,n.text].join(`
2
+ `)}]}}catch(e){return X.error(`Compact failed`,n(e)),{content:[{type:`text`,text:`Compact failed. Check server logs for details.`}],isError:!0}}})}function ve(t,r,i){t.registerTool(`scope_map`,{description:`Generate a task-scoped reading plan. Given a task description, identifies which files and sections are relevant, with estimated token counts and suggested reading order.`,inputSchema:{task:Y.string().describe(`Description of the task to scope`),max_files:Y.number().min(1).max(50).default(15).describe(`Maximum files to include`),content_type:Y.enum(e).optional().describe(`Filter by content type`),max_tokens:Y.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`)}},async({task:e,max_files:t,content_type:a,max_tokens:o})=>{try{let n=await W(r,i,{task:e,maxFiles:t,contentType:a}),s=[`## Scope Map: ${e}`,`Total estimated tokens: ~${n.totalEstimatedTokens}`,``,`### Files (by relevance)`,...n.files.map((e,t)=>`${t+1}. **${e.path}** (~${e.estimatedTokens} tokens, ${(e.relevance*100).toFixed(0)}% relevant)\n ${e.reason}\n Focus: ${e.focusRanges.map(e=>`L${e.start}-${e.end}`).join(`, `)}`),``,`### Suggested Reading Order`,...n.readingOrder.map((e,t)=>`${t+1}. ${e}`),``,`### Suggested Compact Calls`,`_Estimated compressed total: ~${Math.ceil(n.totalEstimatedTokens/5)} tokens_`,...n.compactCommands.map((e,t)=>`${t+1}. ${e}`)].join(`
3
+ `)+"\n\n---\n_Next: Use `search` to dive into specific files, or `compact` to compress file contents for context._";return{content:[{type:`text`,text:o?J(s,o):s}]}}catch(e){return X.error(`Scope map failed`,n(e)),{content:[{type:`text`,text:`Scope map failed. Check server logs for details.`}],isError:!0}}})}function ye(t,r,i){t.registerTool(`find`,{description:`Federated search across vector similarity, keyword (FTS), file glob, and regex pattern. Combines strategies, deduplicates, and returns unified results. Use mode "examples" to find real usage examples of a symbol or pattern.`,inputSchema:{query:Y.string().optional().describe(`Semantic/keyword search query (required for mode "examples")`),glob:Y.string().optional().describe(`File glob pattern (search mode only)`),pattern:Y.string().optional().describe(`Regex pattern to match in content (search mode only)`),limit:Y.number().min(1).max(50).default(10).describe(`Max results`),content_type:Y.enum(e).optional().describe(`Filter by content type`),mode:Y.enum([`search`,`examples`]).default(`search`).describe(`Mode: "search" (default) for federated search, "examples" to find usage examples of a symbol/pattern`),max_tokens:Y.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`)}},async({query:e,glob:t,pattern:a,limit:o,content_type:s,mode:c,max_tokens:l})=>{try{if(c===`examples`){if(!e)return{content:[{type:`text`,text:`Error: "query" is required for mode "examples".`}],isError:!0};let t=await m(r,i,{query:e,limit:o,contentType:s}),n=JSON.stringify(t,null,2);return{content:[{type:`text`,text:l?J(n,l):n}]}}let n=await f(r,i,{query:e,glob:t,pattern:a,limit:o,contentType:s});if(n.results.length===0)return{content:[{type:`text`,text:`No results found.`}]};let u=[`Found ${n.totalFound} results via ${n.strategies.join(` + `)}`,``,...n.results.map(e=>{let t=e.lineRange?`:${e.lineRange.start}-${e.lineRange.end}`:``,n=e.preview?`\n ${e.preview.slice(0,100)}...`:``;return`- [${e.source}] ${e.path}${t} (${(e.score*100).toFixed(0)}%)${n}`})];return{content:[{type:`text`,text:l?J(u.join(`
4
+ `),l):u.join(`
5
+ `)}]}}catch(e){return X.error(`Find failed`,n(e)),{content:[{type:`text`,text:`Find failed. Check server logs for details.`}],isError:!0}}})}function be(e){e.registerTool(`parse_output`,{description:`Parse structured data from build tool output. Supports tsc, vitest, biome, and git status. Auto-detects the tool or specify explicitly.`,inputSchema:{output:Y.string().max(5e5).describe(`Raw output text from a build tool`),tool:Y.enum([`tsc`,`vitest`,`biome`,`git-status`]).optional().describe(`Tool to parse as (auto-detects if omitted)`)}},async({output:e,tool:t})=>{try{let n=E(e.replace(/\\n/g,`
6
+ `).replace(/\\t/g,` `),t);return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Parse failed`,n(e)),{content:[{type:`text`,text:`Parse failed. Check server logs for details.`}],isError:!0}}})}function xe(e){e.registerTool(`workset`,{description:`Manage named file sets (worksets). Save, load, list, add/remove files. Worksets persist across sessions in .kb-state/worksets.json.`,inputSchema:{action:Y.enum([`save`,`get`,`list`,`delete`,`add`,`remove`]).describe(`Operation to perform`),name:Y.string().optional().describe(`Workset name (required for all except list)`),files:Y.array(Y.string()).optional().describe(`File paths (required for save, add, remove)`),description:Y.string().optional().describe(`Description (for save)`)}},async({action:e,name:t,files:i,description:a})=>{try{switch(e){case`save`:{if(!t||!i)throw Error(`name and files required for save`);let e=U(t,i,{description:a});return{content:[{type:`text`,text:`Saved workset "${e.name}" with ${e.files.length} files.`}]}}case`get`:{if(!t)throw Error(`name required for get`);let e=h(t);return e?{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}:{content:[{type:`text`,text:`Workset "${t}" not found.`}]}}case`list`:{let e=T();return e.length===0?{content:[{type:`text`,text:`No worksets.`}]}:{content:[{type:`text`,text:e.map(e=>`- **${e.name}** (${e.files.length} files) — ${e.description??`no description`}`).join(`
7
+ `)}]}}case`delete`:if(!t)throw Error(`name required for delete`);return{content:[{type:`text`,text:re(t)?`Deleted workset "${t}".`:`Workset "${t}" not found.`}]};case`add`:{if(!t||!i)throw Error(`name and files required for add`);let e=r(t,i);return{content:[{type:`text`,text:`Added to workset "${e.name}": now ${e.files.length} files.`}]}}case`remove`:{if(!t||!i)throw Error(`name and files required for remove`);let e=V(t,i);return e?{content:[{type:`text`,text:`Removed from workset "${e.name}": now ${e.files.length} files.`}]}:{content:[{type:`text`,text:`Workset "${t}" not found.`}]}}}}catch(e){return X.error(`Workset operation failed`,n(e)),{content:[{type:`text`,text:`Workset operation failed. Check server logs for details.`}],isError:!0}}})}function Se(e){e.registerTool(`check`,{description:`Run incremental typecheck (tsc) and lint (biome) on the project or specific files. Returns structured error and warning lists. Default detail level is "summary" (~300 tokens).`,inputSchema:{files:Y.array(Y.string()).optional().describe(`Specific files to check (if omitted, checks all)`),cwd:Y.string().optional().describe(`Working directory`),skip_types:Y.boolean().default(!1).describe(`Skip TypeScript typecheck`),skip_lint:Y.boolean().default(!1).describe(`Skip Biome lint`),detail:Y.enum([`summary`,`errors`,`full`]).default(`summary`).describe(`Output detail level: summary (default, ~300 tokens — pass/fail + counts + top errors), errors (parsed error objects), full (includes raw terminal output)`)}},async({files:e,cwd:t,skip_types:r,skip_lint:i,detail:o})=>{try{let n=await a({files:e,cwd:t,skipTypes:r,skipLint:i,detail:o===`summary`?`errors`:o});if(o===`summary`){let e=le(n),t=[];if(n.passed)t.push({tool:`test_run`,reason:`Types and lint clean — run tests next`});else{let e=n.tsc.errors[0]?.file??n.biome.errors[0]?.file;e&&t.push({tool:`symbol`,reason:`Resolve failing symbol in ${e}`,suggested_args:{name:e}}),t.push({tool:`check`,reason:`Re-check after fixing errors`,suggested_args:{detail:`errors`}})}return{content:[{type:`text`,text:JSON.stringify({...e,_next:t},null,2)}]}}return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Check failed`,n(e)),{content:[{type:`text`,text:`Check failed. Check server logs for details.`}],isError:!0}}})}function Ce(e,t,r){e.registerTool(`batch`,{description:`Execute multiple built-in operations in parallel with concurrency control. Supported operation types: search, find, and check.`,inputSchema:{operations:Y.array(Y.object({id:Y.string().describe(`Unique ID for this operation`),type:Y.enum([`search`,`find`,`check`]).describe(`Built-in operation type`),args:Y.record(Y.string(),Y.unknown()).describe(`Arguments for the operation`)})).min(1).max(100).describe(`Operations to execute`),concurrency:Y.number().min(1).max(20).default(4).describe(`Max concurrent operations`)}},async({operations:e,concurrency:a})=>{try{let n=await i(e,async e=>Ge(e,t,r),{concurrency:a});return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Batch failed`,n(e)),{content:[{type:`text`,text:`Batch failed. Check server logs for details.`}],isError:!0}}})}function we(e,t,r){e.registerTool(`symbol`,{description:`Resolve a symbol: find where it is defined, who imports it, and where it is referenced. Works on TypeScript and JavaScript codebases.`,inputSchema:{name:Y.string().describe(`Symbol name to look up (function, class, type, etc.)`),limit:Y.number().min(1).max(50).default(20).describe(`Max results per category`)}},async({name:e,limit:i})=>{try{return{content:[{type:`text`,text:Je(await ue(t,r,{name:e,limit:i}))}]}}catch(e){return X.error(`Symbol lookup failed`,n(e)),{content:[{type:`text`,text:`Symbol lookup failed. Check server logs for details.`}],isError:!0}}})}function Te(e){e.registerTool(`eval`,{description:`Execute a JavaScript or TypeScript snippet in a constrained VM sandbox with a timeout. Captures console output and returned values.`,inputSchema:{code:Y.string().max(1e5).describe(`Code snippet to execute`),lang:Y.enum([`js`,`ts`]).default(`js`).optional().describe(`Language mode: js executes directly, ts strips common type syntax first`),timeout:Y.number().min(1).max(6e4).default(5e3).optional().describe(`Execution timeout in milliseconds`)}},async({code:e,lang:t,timeout:r})=>{try{let n=ae({code:e,lang:t,timeout:r});return n.success?{content:[{type:`text`,text:`Eval succeeded in ${n.durationMs}ms\n\n${n.output}`}]}:{content:[{type:`text`,text:`Eval failed in ${n.durationMs}ms: ${n.error??`Unknown error`}`}],isError:!0}}catch(e){return X.error(`Eval failed`,n(e)),{content:[{type:`text`,text:`Eval failed. Check server logs for details.`}],isError:!0}}})}function Ee(e){e.registerTool(`test_run`,{description:`Run Vitest for the current project or a subset of files, then return a structured summary of passing and failing tests.`,inputSchema:{files:Y.array(Y.string()).optional().describe(`Specific test files or patterns to run`),grep:Y.string().optional().describe(`Only run tests whose names match this pattern`),cwd:Y.string().optional().describe(`Working directory for the test run`)}},async({files:e,grep:t,cwd:r})=>{try{let n=await de({files:e,grep:t,cwd:r});return{content:[{type:`text`,text:Ye(n)}],isError:!n.passed}}catch(e){return X.error(`Test run failed`,n(e)),{content:[{type:`text`,text:`Test run failed. Check server logs for details.`}],isError:!0}}})}function De(e){e.registerTool(`stash`,{description:`Persist and retrieve named values in .kb-state/stash.json for intermediate results between tool calls.`,inputSchema:{action:Y.enum([`set`,`get`,`list`,`delete`,`clear`]).describe(`Operation to perform on the stash`),key:Y.string().optional().describe(`Entry key for set/get/delete operations`),value:Y.string().optional().describe(`String or JSON value for set operations`)}},async({action:e,key:t,value:r})=>{try{switch(e){case`set`:{if(!t)throw Error(`key required for set`);let e=ce(t,$e(r??``));return{content:[{type:`text`,text:`Stored stash entry "${e.key}" (${e.type}) at ${e.storedAt}.`}]}}case`get`:{if(!t)throw Error(`key required for get`);let e=q(t);return{content:[{type:`text`,text:e?JSON.stringify(e,null,2):`Stash entry "${t}" not found.`}]}}case`list`:{let e=se();return{content:[{type:`text`,text:e.length===0?`Stash is empty.`:e.map(e=>`- ${e.key} (${e.type}) — ${e.storedAt}`).join(`
8
+ `)}]}}case`delete`:if(!t)throw Error(`key required for delete`);return{content:[{type:`text`,text:K(t)?`Deleted stash entry "${t}".`:`Stash entry "${t}" not found.`}]};case`clear`:{let e=G();return{content:[{type:`text`,text:`Cleared ${e} stash entr${e===1?`y`:`ies`}.`}]}}}}catch(e){return X.error(`Stash operation failed`,n(e)),{content:[{type:`text`,text:`Stash operation failed. Check server logs for details.`}],isError:!0}}})}function Oe(e){e.registerTool(`git_context`,{description:`Summarize the current Git branch, working tree state, recent commits, and optional diff statistics for the repository.`,inputSchema:{cwd:Y.string().optional().describe(`Repository root or working directory`),commit_count:Y.number().min(1).max(50).default(5).optional().describe(`How many recent commits to include`),include_diff:Y.boolean().default(!1).optional().describe(`Include diff stat for working tree changes`)}},async({cwd:e,commit_count:t,include_diff:r})=>{try{return{content:[{type:`text`,text:Xe(await g({cwd:e,commitCount:t,includeDiff:r}))}]}}catch(e){return X.error(`Git context failed`,n(e)),{content:[{type:`text`,text:`Git context failed. Check server logs for details.`}],isError:!0}}})}function ke(e){e.registerTool(`diff_parse`,{description:`Parse raw unified diff text into file-level and hunk-level structural changes.`,inputSchema:{diff:Y.string().max(1e6).describe(`Raw unified diff text`)}},async({diff:e})=>{try{return{content:[{type:`text`,text:Ze(ie({diff:e.replace(/\\n/g,`
9
+ `).replace(/\\t/g,` `)}))}]}}catch(e){return X.error(`Diff parse failed`,n(e)),{content:[{type:`text`,text:`Diff parse failed. Check server logs for details.`}],isError:!0}}})}function Ae(e){e.registerTool(`rename`,{description:`Rename a symbol across files using whole-word regex matching for exports, imports, and general usage references.`,inputSchema:{old_name:Y.string().describe(`Existing symbol name to replace`),new_name:Y.string().describe(`New symbol name to use`),root_path:Y.string().describe(`Root directory to search within`),extensions:Y.array(Y.string()).optional().describe(`Optional file extensions to include, such as .ts,.tsx,.js,.jsx`),dry_run:Y.boolean().default(!0).describe(`Preview changes without writing files`)}},async({old_name:e,new_name:t,root_path:r,extensions:i,dry_run:a})=>{try{let n=await H({oldName:e,newName:t,rootPath:r,extensions:i,dryRun:a});return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Rename failed`,n(e)),{content:[{type:`text`,text:`Rename failed. Check server logs for details.`}],isError:!0}}})}function je(e){e.registerTool(`codemod`,{description:`Apply regex-based codemod rules across files and return structured before/after changes for each affected line.`,inputSchema:{root_path:Y.string().describe(`Root directory to transform within`),rules:Y.array(Y.object({description:Y.string().describe(`What the codemod rule does`),pattern:Y.string().describe(`Regex pattern in string form`),replacement:Y.string().describe(`Replacement string with optional capture groups`)})).min(1).describe(`Codemod rules to apply`),dry_run:Y.boolean().default(!0).describe(`Preview changes without writing files`)}},async({root_path:e,rules:t,dry_run:r})=>{try{let n=await u({rootPath:e,rules:t,dryRun:r});return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Codemod failed`,n(e)),{content:[{type:`text`,text:`Codemod failed. Check server logs for details.`}],isError:!0}}})}function Me(e,t){e.registerTool(`file_summary`,{description:`Create a concise structural summary of a source file: imports, exports, functions, classes, interfaces, and types.`,inputSchema:{path:Y.string().describe(`Absolute path to the file to summarize`)}},async({path:e})=>{try{return{content:[{type:`text`,text:Qe(await oe({path:e,content:(await t.get(e)).content}))}]}}catch(e){return X.error(`File summary failed`,n(e)),{content:[{type:`text`,text:`File summary failed. Check server logs for details.`}],isError:!0}}})}function Ne(e){e.registerTool(`checkpoint`,{description:`Save and restore lightweight session checkpoints in .kb-state/checkpoints for cross-session continuity.`,inputSchema:{action:Y.enum([`save`,`load`,`list`,`latest`]).describe(`Checkpoint action to perform`),label:Y.string().optional().describe(`Checkpoint label for save, or checkpoint id for load`),data:Y.string().max(5e5).optional().describe(`JSON object string for save actions`),notes:Y.string().max(1e4).optional().describe(`Optional notes for save actions`)}},async({action:e,label:t,data:r,notes:i})=>{try{switch(e){case`save`:if(!t)throw Error(`label required for save`);return{content:[{type:`text`,text:Q(l(t,et(r),{notes:i}))}]};case`load`:{if(!t)throw Error(`label required for load`);let e=c(t);return{content:[{type:`text`,text:e?Q(e):`Checkpoint "${t}" not found.`}]}}case`list`:{let e=s();return{content:[{type:`text`,text:e.length===0?`No checkpoints saved.`:e.map(e=>`- ${e.id} ${e.label} (${e.createdAt})`).join(`
10
+ `)}]}}case`latest`:{let e=o();return{content:[{type:`text`,text:e?Q(e):`No checkpoints saved.`}]}}}}catch(e){return X.error(`Checkpoint failed`,n(e)),{content:[{type:`text`,text:`Checkpoint failed. Check server logs for details.`}],isError:!0}}})}function Pe(e){e.registerTool(`data_transform`,{description:`Apply small jq-like transforms to JSON input for filtering, projection, grouping, and path extraction.`,inputSchema:{input:Y.string().max(5e5).describe(`Input JSON string`),expression:Y.string().max(1e4).describe(`Transform expression to apply`)}},async({input:e,expression:t})=>{try{return{content:[{type:`text`,text:ee({input:e,expression:t}).outputString}]}}catch(e){return X.error(`Data transform failed`,n(e)),{content:[{type:`text`,text:`Data transform failed. Check server logs for details.`}],isError:!0}}})}function Fe(e,t,r){e.registerTool(`trace`,{description:`Trace data flow through a codebase by following imports, call sites, and references from a starting symbol or file location.`,inputSchema:{start:Y.string().describe(`Starting point symbol name or file:line reference`),direction:Y.enum([`forward`,`backward`,`both`]).describe(`Which direction to trace relationships`),max_depth:Y.number().min(1).max(10).default(3).optional().describe(`Maximum trace depth`)}},async({start:e,direction:i,max_depth:a})=>{try{let n=await fe(t,r,{start:e,direction:i,maxDepth:a});return{content:[{type:`text`,text:JSON.stringify(n,null,2)}]}}catch(e){return X.error(`Trace failed`,n(e)),{content:[{type:`text`,text:`Trace failed. Check server logs for details.`}],isError:!0}}})}function Ie(e){e.registerTool(`process`,{description:`Start, stop, inspect, list, and tail logs for in-memory managed child processes.`,inputSchema:{action:Y.enum([`start`,`stop`,`status`,`list`,`logs`]).describe(`Process action to perform`),id:Y.string().optional().describe(`Managed process ID`),command:Y.string().optional().describe(`Executable to start`),args:Y.array(Y.string()).optional().describe(`Arguments for start actions`),tail:Y.number().min(1).max(500).optional().describe(`Log lines to return for logs actions`)}},async({action:e,id:t,command:r,args:i,tail:a})=>{try{switch(e){case`start`:if(!t||!r)throw Error(`id and command are required for start`);return{content:[{type:`text`,text:JSON.stringify(k(t,r,i??[]),null,2)}]};case`stop`:if(!t)throw Error(`id is required for stop`);return{content:[{type:`text`,text:JSON.stringify(j(t)??null,null,2)}]};case`status`:if(!t)throw Error(`id is required for status`);return{content:[{type:`text`,text:JSON.stringify(A(t)??null,null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(D(),null,2)}]};case`logs`:if(!t)throw Error(`id is required for logs`);return{content:[{type:`text`,text:JSON.stringify(O(t,a),null,2)}]}}}catch(e){return X.error(`Process action failed`,n(e)),{content:[{type:`text`,text:`Process action failed. Check server logs for details.`}],isError:!0}}})}function Le(e){e.registerTool(`watch`,{description:`Start, stop, and list in-memory filesystem watchers for a directory.`,inputSchema:{action:Y.enum([`start`,`stop`,`list`]).describe(`Watch action to perform`),path:Y.string().optional().describe(`Directory path to watch for start actions`),id:Y.string().optional().describe(`Watcher ID for stop actions`)}},async({action:e,path:t,id:r})=>{try{switch(e){case`start`:if(!t)throw Error(`path is required for start`);return{content:[{type:`text`,text:JSON.stringify(me({path:t}),null,2)}]};case`stop`:if(!r)throw Error(`id is required for stop`);return{content:[{type:`text`,text:JSON.stringify({stopped:he(r)},null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(pe(),null,2)}]}}}catch(e){return X.error(`Watch action failed`,n(e)),{content:[{type:`text`,text:`Watch action failed. Check server logs for details.`}],isError:!0}}})}function Re(e,t,r){e.registerTool(`dead_symbols`,{description:`Find exported symbols that appear to be unused because they are never imported or re-exported.`,inputSchema:{path:Y.string().optional().describe(`Root path to scope the search (default: cwd)`),limit:Y.number().min(1).max(500).default(100).optional().describe(`Maximum exported symbols to scan`)}},async({path:e,limit:i})=>{try{let n=await p(t,r,{rootPath:e,limit:i}),a=[`## Dead Symbol Analysis`,``,`**Exports scanned:** ${n.totalExports}`,`**Dead in source:** ${n.totalDeadSource} (actionable)`,`**Dead in docs:** ${n.totalDeadDocs} (informational code samples in .md files)`,``];if(n.deadInSource.length>0){a.push(`### Dead in Source (actionable)`);for(let e of n.deadInSource)a.push(`- \`${e.name}\` (${e.kind}) ${e.path}:${e.line}`);a.push(``)}if(n.deadInDocs.length>0){a.push(`### Dead in Docs (informational)`),a.push(`_${n.totalDeadDocs} symbol(s) found only in documentation code samples not actionable dead code._`);for(let e of n.deadInDocs.slice(0,5))a.push(`- \`${e.name}\` ${e.path}:${e.line}`);n.deadInDocs.length>5&&a.push(`- _... ${n.deadInDocs.length-5} more omitted_`)}return n.totalDeadSource>0?a.push(``,`---`,`_Next: \`codemod\` to remove ${n.totalDeadSource} unused exports | \`symbol\` to verify usage before removing_`):a.push(``,`---`,"_Next: `check` — no dead symbols found, validate types and lint_"),{content:[{type:`text`,text:a.join(`
11
+ `)}]}}catch(e){return X.error(`Dead symbol scan failed`,n(e)),{content:[{type:`text`,text:`Dead symbol scan failed. Check server logs for details.`}],isError:!0}}})}function ze(e){e.registerTool(`delegate`,{description:`Delegate a subtask to a local Ollama model. Use for summarization, classification, naming, or any task that can offload work from the host agent. Fails fast if Ollama is not running.`,inputSchema:{prompt:Y.string().max(2e5).describe(`The task or question to send to the local model`),model:Y.string().optional().describe(`Ollama model name (default: first available model)`),system:Y.string().optional().describe(`System prompt for the model`),context:Y.string().max(5e5).optional().describe(`Context text to include before the prompt (e.g. file contents)`),temperature:Y.number().min(0).max(2).default(.3).optional().describe(`Sampling temperature (0=deterministic, default 0.3)`),timeout:Y.number().min(1e3).max(6e5).default(12e4).optional().describe(`Timeout in milliseconds (default 120000)`),action:Y.enum([`generate`,`list_models`]).default(`generate`).optional().describe(`Action: generate a response or list available models`)}},async({prompt:e,model:t,system:r,context:i,temperature:a,timeout:o,action:s})=>{try{if(s===`list_models`){let e=await ne();return{content:[{type:`text`,text:JSON.stringify({models:e,count:e.length,_Next:`Use delegate with a model name`},null,2)}]}}let n=await te({prompt:e,model:t,system:r,context:i,temperature:a,timeout:o});return n.error?{content:[{type:`text`,text:JSON.stringify({error:n.error,model:n.model,durationMs:n.durationMs},null,2)}],isError:!0}:{content:[{type:`text`,text:JSON.stringify({model:n.model,response:n.response,durationMs:n.durationMs,tokenCount:n.tokenCount,_Next:`Use the response in your workflow. stash to save it.`},null,2)}]}}catch(e){return X.error(`Delegate failed`,n(e)),{content:[{type:`text`,text:`Delegate failed. Check server logs for details.`}],isError:!0}}})}function Be(e){e.registerTool(`lane`,{description:`Manage verified lanes — isolated file copies for parallel exploration. Create a lane, make changes, diff, merge back, or discard.`,inputSchema:{action:Y.enum([`create`,`list`,`status`,`diff`,`merge`,`discard`]).describe(`Lane action to perform`),name:Y.string().optional().describe(`Lane name (required for create/status/diff/merge/discard)`),files:Y.array(Y.string()).optional().describe(`File paths to copy into the lane (required for create)`)}},async({action:e,name:t,files:r})=>{try{switch(e){case`create`:{if(!t)throw Error(`name is required for create`);if(!r||r.length===0)throw Error(`files are required for create`);let e=y(t,r);return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}case`list`:return{content:[{type:`text`,text:JSON.stringify(S(),null,2)}]};case`status`:if(!t)throw Error(`name is required for status`);return{content:[{type:`text`,text:JSON.stringify(w(t),null,2)}]};case`diff`:if(!t)throw Error(`name is required for diff`);return{content:[{type:`text`,text:JSON.stringify(b(t),null,2)}]};case`merge`:if(!t)throw Error(`name is required for merge`);return{content:[{type:`text`,text:JSON.stringify(C(t),null,2)}]};case`discard`:if(!t)throw Error(`name is required for discard`);return{content:[{type:`text`,text:JSON.stringify({discarded:x(t)},null,2)}]}}}catch(e){return X.error(`Lane action failed`,n(e)),{content:[{type:`text`,text:`Lane action failed. Check server logs for details.`}],isError:!0}}})}function Ve(e){e.registerTool(`health`,{description:`Run project health checks — verifies package.json, tsconfig, scripts, lockfile, README, LICENSE, .gitignore.`,inputSchema:{path:Y.string().optional().describe(`Root directory to check (defaults to cwd)`)}},async({path:e})=>{try{let t=v(e);return{content:[{type:`text`,text:JSON.stringify(t,null,2)}]}}catch(e){return X.error(`Health check failed`,n(e)),{content:[{type:`text`,text:`Health check failed. Check server logs for details.`}],isError:!0}}})}function He(e){e.registerTool(`queue`,{description:`Manage task queues for sequential agent operations. Push items, take next, mark done/failed, list queues.`,inputSchema:{action:Y.enum([`create`,`push`,`next`,`done`,`fail`,`get`,`list`,`clear`,`delete`]).describe(`Queue action`),name:Y.string().optional().describe(`Queue name (required for most actions)`),title:Y.string().optional().describe(`Item title (required for push)`),id:Y.string().optional().describe(`Item ID (required for done/fail)`),data:Y.unknown().optional().describe(`Arbitrary data to attach to a queue item`),error:Y.string().optional().describe(`Error message (required for fail)`)}},async({action:e,name:t,title:r,id:i,data:a,error:o})=>{try{switch(e){case`create`:if(!t)throw Error(`name is required for create`);return{content:[{type:`text`,text:JSON.stringify(N(t),null,2)}]};case`push`:if(!t)throw Error(`name is required for push`);if(!r)throw Error(`title is required for push`);return{content:[{type:`text`,text:JSON.stringify(B(t,r,a),null,2)}]};case`next`:{if(!t)throw Error(`name is required for next`);let e=z(t);return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}case`done`:if(!t)throw Error(`name is required for done`);if(!i)throw Error(`id is required for done`);return{content:[{type:`text`,text:JSON.stringify(F(t,i),null,2)}]};case`fail`:if(!t)throw Error(`name is required for fail`);if(!i)throw Error(`id is required for fail`);if(!o)throw Error(`error is required for fail`);return{content:[{type:`text`,text:JSON.stringify(I(t,i,o),null,2)}]};case`get`:if(!t)throw Error(`name is required for get`);return{content:[{type:`text`,text:JSON.stringify(L(t),null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(R(),null,2)}]};case`clear`:if(!t)throw Error(`name is required for clear`);return{content:[{type:`text`,text:JSON.stringify({cleared:M(t)},null,2)}]};case`delete`:if(!t)throw Error(`name is required for delete`);return{content:[{type:`text`,text:JSON.stringify({deleted:P(t)},null,2)}]}}}catch(e){return X.error(`Queue action failed`,n(e)),{content:[{type:`text`,text:`Queue action failed. Check server logs for details.`}],isError:!0}}})}const Ue=Y.object({query:Y.string(),limit:Y.number().min(1).max(20).default(5).optional(),search_mode:Y.enum([`hybrid`,`semantic`,`keyword`]).default(`hybrid`).optional(),content_type:Y.enum(e).optional(),origin:Y.enum([`indexed`,`curated`,`produced`]).optional(),category:Y.string().optional(),tags:Y.array(Y.string()).optional(),min_score:Y.number().min(0).max(1).default(.25).optional()}),Z=Y.object({query:Y.string().optional(),glob:Y.string().optional(),pattern:Y.string().optional(),limit:Y.number().min(1).max(50).default(10).optional(),content_type:Y.enum(e).optional(),cwd:Y.string().optional()}),We=Y.object({files:Y.array(Y.string()).optional(),cwd:Y.string().optional(),skip_types:Y.boolean().optional(),skip_lint:Y.boolean().optional()});async function Ge(e,t,n){switch(e.type){case`search`:return Ke(t,n,Ue.parse(e.args));case`find`:{let r=Z.parse(e.args);if(!r.query&&!r.glob&&!r.pattern)throw Error(`find operation requires query, glob, or pattern`);return f(t,n,{query:r.query,glob:r.glob,pattern:r.pattern,limit:r.limit,contentType:r.content_type,cwd:r.cwd})}case`check`:{let t=We.parse(e.args);return a({files:t.files,cwd:t.cwd,skipTypes:t.skip_types,skipLint:t.skip_lint})}default:throw Error(`Unsupported batch operation type: ${e.type}`)}}async function Ke(e,t,n){let r=n.limit??5,i={limit:r,minScore:n.min_score??.25,contentType:n.content_type,origin:n.origin,category:n.category,tags:n.tags},a=e.embedQuery?.bind(e)??e.embed.bind(e);if(n.search_mode===`keyword`)return(await t.ftsSearch(n.query,i)).slice(0,r);let o=await a(n.query);if(n.search_mode===`semantic`)return t.search(o,i);let[s,c]=await Promise.all([t.search(o,{...i,limit:r*2}),t.ftsSearch(n.query,{...i,limit:r*2})]);return qe(s,c).slice(0,r)}function qe(e,t,n=60){let r=new Map;for(let t=0;t<e.length;t++){let i=e[t];r.set(i.record.id,{record:i.record,score:1/(n+t+1)})}for(let e=0;e<t.length;e++){let i=t[e],a=r.get(i.record.id);if(a){a.score+=1/(n+e+1);continue}r.set(i.record.id,{record:i.record,score:1/(n+e+1)})}return[...r.values()].sort((e,t)=>t.score-e.score)}function Je(e){let t=[`Symbol: ${e.name}`];if(e.definedIn?t.push(`Defined in: ${e.definedIn.path}:${e.definedIn.line} (${e.definedIn.kind})`):t.push(`Defined in: not found`),t.push(``,`Imported by:`),e.importedBy.length===0)t.push(` none`);else for(let n of e.importedBy)t.push(` - ${n.path}:${n.line} ${n.importStatement}`);if(t.push(``,`Referenced in:`),e.referencedIn.length===0)t.push(` none`);else for(let n of e.referencedIn)t.push(` - ${n.path}:${n.line} ${n.context}`);return t.join(`
12
+ `)}function Ye(e){let t=[`Vitest run: ${e.passed?`passed`:`failed`}`,`Duration: ${e.durationMs}ms`,`Passed: ${e.summary.passed}`,`Failed: ${e.summary.failed}`,`Skipped: ${e.summary.skipped}`];e.summary.suites!==void 0&&t.push(`Suites: ${e.summary.suites}`);let n=e.summary.tests.filter(e=>e.status===`fail`);if(n.length>0){t.push(``,`Failed tests:`);for(let e of n)t.push(`- ${e.name}${e.file?` (${e.file})`:``}`),e.error&&t.push(` ${e.error}`)}return t.join(`
13
+ `)}function Xe(e){let t=[`Branch: ${e.branch}`,`Staged: ${e.status.staged.length}`,...e.status.staged.map(e=>` - ${e}`),`Modified: ${e.status.modified.length}`,...e.status.modified.map(e=>` - ${e}`),`Untracked: ${e.status.untracked.length}`,...e.status.untracked.map(e=>` - ${e}`),``,`Recent commits:`];if(e.recentCommits.length===0)t.push(` none`);else for(let n of e.recentCommits)t.push(` - ${n.hash} ${n.message}`),t.push(` ${n.author} @ ${n.date}`);return e.diff&&t.push(``,`Diff stat:`,e.diff),t.join(`
14
+ `)}function Ze(e){if(e.length===0)return`No diff files found.`;let t=[];for(let n of e){let e=n.oldPath?` (from ${n.oldPath})`:``;t.push(`${n.path}${e} [${n.status}] +${n.additions} -${n.deletions} (${n.hunks.length} hunks)`);for(let e of n.hunks){let n=e.header?` ${e.header}`:``;t.push(` @@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@${n}`)}}return t.join(`
15
+ `)}function Qe(e){return[e.path,`Language: ${e.language}`,`Lines: ${e.lines}`,`Estimated tokens: ~${e.estimatedTokens}`,``,`Imports (${e.imports.length}):`,...$(e.imports),``,`Exports (${e.exports.length}):`,...$(e.exports),``,`Functions (${e.functions.length}):`,...$(e.functions.map(e=>`${e.name} @ line ${e.line}${e.exported?` [exported]`:``}`)),``,`Classes (${e.classes.length}):`,...$(e.classes.map(e=>`${e.name} @ line ${e.line}${e.exported?` [exported]`:``}`)),``,`Interfaces (${e.interfaces.length}):`,...$(e.interfaces.map(e=>`${e.name} @ line ${e.line}`)),``,`Types (${e.types.length}):`,...$(e.types.map(e=>`${e.name} @ line ${e.line}`))].join(`
16
+ `)}function Q(e){let t=[e.id,`Label: ${e.label}`,`Created: ${e.createdAt}`];if(e.notes&&t.push(`Notes: ${e.notes}`),e.files?.length){t.push(`Files: ${e.files.length}`);for(let n of e.files)t.push(` - ${n}`)}return t.push(``,`Data:`,JSON.stringify(e.data,null,2)),t.join(`
17
+ `)}function $(e){return e.length===0?[` none`]:e.map(e=>` - ${e}`)}function $e(e){let t=e.trim();if(!t)return``;try{return JSON.parse(t)}catch{return e}}function et(e){let t=e?.trim();if(!t)return{};let n;try{n=JSON.parse(t)}catch{throw Error(`data must be a valid JSON object string`)}if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`data must be a JSON object string`);return n}function tt(e){e.registerTool(`web_fetch`,{description:`PREFERRED web fetcher — fetch any URL and convert to LLM-optimized markdown. Supports CSS selectors, 4 output modes (markdown/raw/links/outline), smart paragraph-boundary truncation. Strips scripts/styles/nav automatically.`,inputSchema:{url:Y.string().url().describe(`URL to fetch (http/https only)`),mode:Y.enum([`markdown`,`raw`,`links`,`outline`]).default(`markdown`).describe(`Output mode: markdown (clean content), raw (HTML), links (extracted URLs), outline (heading hierarchy)`),selector:Y.string().optional().describe(`CSS selector to extract a specific element instead of auto-detecting main content`),max_length:Y.number().min(500).max(1e5).default(15e3).describe(`Max characters in output — truncates at paragraph boundaries`),include_metadata:Y.boolean().default(!0).describe(`Include page title, description, and URL as a header`),include_links:Y.boolean().default(!1).describe(`Append extracted links list at the end`),include_images:Y.boolean().default(!1).describe(`Include image alt texts inline`),timeout:Y.number().min(1e3).max(6e4).default(15e3).describe(`Request timeout in milliseconds`)}},async({url:e,mode:t,selector:r,max_length:i,include_metadata:a,include_links:o,include_images:s,timeout:c})=>{try{let n=await ge({url:e,mode:t,selector:r,maxLength:i,includeMetadata:a,includeLinks:o,includeImages:s,timeout:c}),l=[`## ${n.title||`Web Page`}`,``,n.content];return n.truncated&&l.push(``,`_Original length: ${n.originalLength.toLocaleString()} chars_`),l.push(``,`---`,"_Next: Use `remember` to save key findings, or `web_fetch` with a `selector` to extract a specific section._"),{content:[{type:`text`,text:l.join(`
18
+ `)}]}}catch(e){return X.error(`Web fetch failed`,n(e)),{content:[{type:`text`,text:`Web fetch failed. Check server logs for details.`}],isError:!0}}})}function nt(e){e.registerTool(`guide`,{description:`Tool discovery — given a goal description, recommends which KB tools to use and in what order. Matches against 10 predefined workflows: onboard, audit, bugfix, implement, refactor, search, context, memory, validate, analyze.`,inputSchema:{goal:Y.string().describe(`What you want to accomplish (e.g., "audit this monorepo", "fix a failing test")`),max_recommendations:Y.number().min(1).max(10).default(5).describe(`Maximum number of tool recommendations`)}},async({goal:e,max_recommendations:t})=>{try{let n=_(e,t),r=[`## Recommended Workflow: **${n.workflow}**`,n.description,``,`### Tools`,...n.tools.map(e=>{let t=e.suggestedArgs?` \`${JSON.stringify(e.suggestedArgs)}\``:``;return`${e.order}. **${e.tool}** ${e.reason}${t}`})];return n.alternativeWorkflows.length>0&&r.push(``,`_Alternative workflows: ${n.alternativeWorkflows.join(`, `)}_`),r.push(``,`---`,"_Next: Run the first recommended tool, or use `guide` again with a more specific goal._"),{content:[{type:`text`,text:r.join(`
19
+ `)}]}}catch(e){return X.error(`Guide failed`,n(e)),{content:[{type:`text`,text:`Guide failed. Check server logs for details.`}],isError:!0}}})}export{Ce as registerBatchTool,Se as registerCheckTool,Ne as registerCheckpointTool,je as registerCodemodTool,_e as registerCompactTool,Pe as registerDataTransformTool,Re as registerDeadSymbolsTool,ze as registerDelegateTool,ke as registerDiffParseTool,Te as registerEvalTool,Me as registerFileSummaryTool,ye as registerFindTool,Oe as registerGitContextTool,nt as registerGuideTool,Ve as registerHealthTool,Be as registerLaneTool,be as registerParseOutputTool,Ie as registerProcessTool,He as registerQueueTool,Ae as registerRenameTool,ve as registerScopeMapTool,De as registerStashTool,we as registerSymbolTool,Ee as registerTestRunTool,Fe as registerTraceTool,Le as registerWatchTool,tt as registerWebFetchTool,xe as registerWorksetTool};
20
+ //# sourceMappingURL=toolkit.tools.js.map
@@ -1,4 +1,8 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { CuratedKnowledgeManager } from '../curated-manager.js';
3
- export declare function registerUpdateTool(server: McpServer, curated: CuratedKnowledgeManager): void;
1
+ import { CuratedKnowledgeManager } from "../curated-manager.js";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+
4
+ //#region packages/server/src/tools/update.tool.d.ts
5
+ declare function registerUpdateTool(server: McpServer, curated: CuratedKnowledgeManager): void;
6
+ //#endregion
7
+ export { registerUpdateTool };
4
8
  //# sourceMappingURL=update.tool.d.ts.map
@@ -1,6 +1,2 @@
1
- import{z as t}from"zod";function d(n,o){n.registerTool("update",{description:"Update an existing curated knowledge entry. Increments version and records the reason in the changelog.",inputSchema:{path:t.string().describe('Relative path within curated/ (e.g., "decisions/use-lancedb.md")'),content:t.string().min(10).describe("New markdown content to replace existing content"),reason:t.string().min(3).describe("Why this update is being made (recorded in changelog)")}},async({path:a,content:s,reason:r})=>{try{const e=await o.update(a,s,r);return{content:[{type:"text",text:`Updated: \`curated/${e.path}\` \u2192 version ${e.version}
2
-
3
- Reason: ${r}
4
-
5
- ---
6
- _Next: Use \`read\` to verify the updated content, or \`search\` to test searchability._`}]}}catch(e){return console.error("[KB] Update failed:",e),{content:[{type:"text",text:`Update failed: ${e.message}`}],isError:!0}}})}export{d as registerUpdateTool};
1
+ import{createLogger as e,serializeError as t}from"../../../core/dist/index.js";import{z as n}from"zod";const r=e(`tools`);function i(e,i){e.registerTool(`update`,{description:`Update an existing curated knowledge entry. Increments version and records the reason in the changelog.`,inputSchema:{path:n.string().describe(`Relative path within curated/ (e.g., "decisions/use-lancedb.md")`),content:n.string().min(10).max(1e5).describe(`New markdown content to replace existing content`),reason:n.string().min(3).max(1e3).describe(`Why this update is being made (recorded in changelog)`)}},async({path:e,content:n,reason:a})=>{try{let t=await i.update(e,n,a);return{content:[{type:`text`,text:`Updated: \`curated/${t.path}\` version ${t.version}\n\nReason: ${a}\n\n---\n_Next: Use \`read\` to verify the updated content, or \`search\` to test searchability._`}]}}catch(e){return r.error(`Update failed`,t(e)),{content:[{type:`text`,text:`Update failed. Check server logs for details.`}],isError:!0}}})}export{i as registerUpdateTool};
2
+ //# sourceMappingURL=update.tool.js.map