@vpxa/kb 0.1.13 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. package/README.md +65 -12
  2. package/package.json +14 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -21
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +5 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -28
  6. package/packages/analyzers/dist/dependency-analyzer.js +6 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -9
  8. package/packages/analyzers/dist/diagram-generator.js +2 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -36
  10. package/packages/analyzers/dist/entry-point-analyzer.js +4 -6
  11. package/packages/analyzers/dist/index.d.ts +12 -14
  12. package/packages/analyzers/dist/index.js +1 -1
  13. package/packages/analyzers/dist/knowledge-producer.d.ts +34 -26
  14. package/packages/analyzers/dist/knowledge-producer.js +17 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -11
  16. package/packages/analyzers/dist/pattern-analyzer.js +2 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -13
  18. package/packages/analyzers/dist/regex-call-graph.js +1 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -10
  20. package/packages/analyzers/dist/structure-analyzer.js +2 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +13 -9
  22. package/packages/analyzers/dist/symbol-analyzer.js +9 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -14
  24. package/packages/analyzers/dist/ts-call-graph.js +1 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -80
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +15 -12
  28. package/packages/chunker/dist/call-graph-extractor.js +1 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +16 -4
  30. package/packages/chunker/dist/chunker-factory.js +1 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -5
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -13
  34. package/packages/chunker/dist/code-chunker.js +11 -14
  35. package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
  36. package/packages/chunker/dist/extractors/call-extractor.js +1 -0
  37. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
  38. package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
  39. package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
  40. package/packages/chunker/dist/extractors/import-extractor.js +1 -0
  41. package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
  42. package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
  43. package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
  44. package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
  45. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
  46. package/packages/chunker/dist/extractors/symbol-extractor.js +1 -0
  47. package/packages/chunker/dist/extractors/types.d.ts +36 -0
  48. package/packages/chunker/dist/extractors/types.js +1 -0
  49. package/packages/chunker/dist/generic-chunker.d.ts +14 -11
  50. package/packages/chunker/dist/generic-chunker.js +5 -5
  51. package/packages/chunker/dist/index.d.ts +19 -8
  52. package/packages/chunker/dist/index.js +1 -1
  53. package/packages/chunker/dist/markdown-chunker.d.ts +16 -13
  54. package/packages/chunker/dist/markdown-chunker.js +3 -10
  55. package/packages/chunker/dist/wasm/languages.d.ts +18 -0
  56. package/packages/chunker/dist/wasm/languages.js +1 -0
  57. package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
  58. package/packages/chunker/dist/wasm/query-executor.js +1 -0
  59. package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
  60. package/packages/chunker/dist/wasm/runtime.js +1 -0
  61. package/packages/chunker/dist/wasm/types.d.ts +84 -0
  62. package/packages/chunker/dist/wasm/types.js +1 -0
  63. package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
  64. package/packages/chunker/dist/wasm-chunker.js +6 -0
  65. package/packages/chunker/src/queries/go/calls.scm +11 -0
  66. package/packages/chunker/src/queries/go/entry-points.scm +20 -0
  67. package/packages/chunker/src/queries/go/imports.scm +6 -0
  68. package/packages/chunker/src/queries/go/patterns.scm +25 -0
  69. package/packages/chunker/src/queries/go/symbols.scm +26 -0
  70. package/packages/chunker/src/queries/java/calls.scm +10 -0
  71. package/packages/chunker/src/queries/java/entry-points.scm +27 -0
  72. package/packages/chunker/src/queries/java/imports.scm +11 -0
  73. package/packages/chunker/src/queries/java/patterns.scm +27 -0
  74. package/packages/chunker/src/queries/java/symbols.scm +28 -0
  75. package/packages/chunker/src/queries/javascript/calls.scm +21 -0
  76. package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
  77. package/packages/chunker/src/queries/javascript/imports.scm +32 -0
  78. package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
  79. package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
  80. package/packages/chunker/src/queries/python/calls.scm +11 -0
  81. package/packages/chunker/src/queries/python/entry-points.scm +21 -0
  82. package/packages/chunker/src/queries/python/imports.scm +14 -0
  83. package/packages/chunker/src/queries/python/patterns.scm +25 -0
  84. package/packages/chunker/src/queries/python/symbols.scm +17 -0
  85. package/packages/chunker/src/queries/rust/calls.scm +20 -0
  86. package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
  87. package/packages/chunker/src/queries/rust/imports.scm +26 -0
  88. package/packages/chunker/src/queries/rust/patterns.scm +18 -0
  89. package/packages/chunker/src/queries/rust/symbols.scm +73 -0
  90. package/packages/chunker/src/queries/typescript/calls.scm +21 -0
  91. package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
  92. package/packages/chunker/src/queries/typescript/imports.scm +35 -0
  93. package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
  94. package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
  95. package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
  96. package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
  97. package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
  98. package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
  99. package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
  100. package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
  101. package/packages/chunker/wasm/tree-sitter.wasm +0 -0
  102. package/packages/cli/dist/commands/analyze.d.ts +6 -3
  103. package/packages/cli/dist/commands/analyze.js +2 -3
  104. package/packages/cli/dist/commands/context-cmds.d.ts +6 -3
  105. package/packages/cli/dist/commands/context-cmds.js +1 -1
  106. package/packages/cli/dist/commands/environment.d.ts +6 -3
  107. package/packages/cli/dist/commands/environment.js +1 -2
  108. package/packages/cli/dist/commands/execution.d.ts +6 -3
  109. package/packages/cli/dist/commands/execution.js +1 -1
  110. package/packages/cli/dist/commands/graph.d.ts +6 -3
  111. package/packages/cli/dist/commands/graph.js +5 -6
  112. package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
  113. package/packages/cli/dist/commands/init/adapters.js +1 -0
  114. package/packages/cli/dist/commands/init/config.d.ts +10 -0
  115. package/packages/cli/dist/commands/init/config.js +3 -0
  116. package/packages/cli/dist/commands/init/constants.d.ts +18 -0
  117. package/packages/cli/dist/commands/init/constants.js +1 -0
  118. package/packages/cli/dist/commands/init/curated.d.ts +7 -0
  119. package/packages/cli/dist/commands/init/curated.js +1 -0
  120. package/packages/cli/dist/commands/init/global.d.ts +34 -0
  121. package/packages/cli/dist/commands/init/global.js +5 -0
  122. package/packages/cli/dist/commands/init/index.d.ts +28 -0
  123. package/packages/cli/dist/commands/init/index.js +5 -0
  124. package/packages/cli/dist/commands/init/scaffold.d.ts +23 -0
  125. package/packages/cli/dist/commands/init/scaffold.js +1 -0
  126. package/packages/cli/dist/commands/init/templates.d.ts +9 -0
  127. package/packages/cli/dist/commands/init/templates.js +165 -0
  128. package/packages/cli/dist/commands/knowledge.d.ts +6 -3
  129. package/packages/cli/dist/commands/knowledge.js +1 -1
  130. package/packages/cli/dist/commands/search.d.ts +6 -3
  131. package/packages/cli/dist/commands/search.js +1 -8
  132. package/packages/cli/dist/commands/system.d.ts +6 -3
  133. package/packages/cli/dist/commands/system.js +4 -7
  134. package/packages/cli/dist/commands/workspace.d.ts +6 -3
  135. package/packages/cli/dist/commands/workspace.js +1 -2
  136. package/packages/cli/dist/context.d.ts +7 -5
  137. package/packages/cli/dist/context.js +1 -1
  138. package/packages/cli/dist/helpers.d.ts +51 -48
  139. package/packages/cli/dist/helpers.js +5 -5
  140. package/packages/cli/dist/index.d.ts +4 -2
  141. package/packages/cli/dist/index.js +2 -2
  142. package/packages/cli/dist/kb-init.d.ts +48 -51
  143. package/packages/cli/dist/kb-init.js +1 -1
  144. package/packages/cli/dist/types.d.ts +8 -6
  145. package/packages/cli/dist/types.js +1 -0
  146. package/packages/core/dist/constants.d.ts +58 -34
  147. package/packages/core/dist/constants.js +1 -1
  148. package/packages/core/dist/content-detector.d.ts +8 -8
  149. package/packages/core/dist/content-detector.js +1 -1
  150. package/packages/core/dist/errors.d.ts +15 -13
  151. package/packages/core/dist/errors.js +1 -1
  152. package/packages/core/dist/global-registry.d.ts +62 -0
  153. package/packages/core/dist/global-registry.js +1 -0
  154. package/packages/core/dist/index.d.ts +7 -6
  155. package/packages/core/dist/index.js +1 -1
  156. package/packages/core/dist/logger.d.ts +19 -8
  157. package/packages/core/dist/logger.js +1 -1
  158. package/packages/core/dist/types.d.ts +107 -92
  159. package/packages/core/dist/types.js +1 -0
  160. package/packages/embeddings/dist/embedder.interface.d.ts +22 -20
  161. package/packages/embeddings/dist/embedder.interface.js +1 -0
  162. package/packages/embeddings/dist/index.d.ts +3 -3
  163. package/packages/embeddings/dist/index.js +1 -1
  164. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -23
  165. package/packages/embeddings/dist/onnx-embedder.js +1 -1
  166. package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
  167. package/packages/enterprise-bridge/dist/cache.js +1 -0
  168. package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
  169. package/packages/enterprise-bridge/dist/er-client.js +1 -0
  170. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
  171. package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
  172. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  173. package/packages/enterprise-bridge/dist/index.js +1 -0
  174. package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
  175. package/packages/enterprise-bridge/dist/policy-store.js +1 -0
  176. package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
  177. package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
  178. package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
  179. package/packages/enterprise-bridge/dist/result-merger.js +1 -0
  180. package/packages/enterprise-bridge/dist/types.d.ts +81 -0
  181. package/packages/enterprise-bridge/dist/types.js +1 -0
  182. package/packages/indexer/dist/file-hasher.d.ts +5 -3
  183. package/packages/indexer/dist/file-hasher.js +1 -1
  184. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -21
  185. package/packages/indexer/dist/filesystem-crawler.js +1 -1
  186. package/packages/indexer/dist/graph-extractor.d.ts +9 -13
  187. package/packages/indexer/dist/graph-extractor.js +1 -1
  188. package/packages/indexer/dist/incremental-indexer.d.ts +49 -44
  189. package/packages/indexer/dist/incremental-indexer.js +1 -1
  190. package/packages/indexer/dist/index.d.ts +5 -5
  191. package/packages/indexer/dist/index.js +1 -1
  192. package/packages/server/dist/api.d.ts +3 -8
  193. package/packages/server/dist/api.js +1 -1
  194. package/packages/server/dist/config.d.ts +6 -3
  195. package/packages/server/dist/config.js +1 -1
  196. package/packages/server/dist/cross-workspace.d.ts +43 -0
  197. package/packages/server/dist/cross-workspace.js +1 -0
  198. package/packages/server/dist/curated-manager.d.ts +80 -78
  199. package/packages/server/dist/curated-manager.js +5 -10
  200. package/packages/server/dist/index.d.ts +1 -2
  201. package/packages/server/dist/index.js +1 -1
  202. package/packages/server/dist/replay-interceptor.d.ts +6 -7
  203. package/packages/server/dist/replay-interceptor.js +1 -1
  204. package/packages/server/dist/resources/resources.d.ts +7 -4
  205. package/packages/server/dist/resources/resources.js +2 -2
  206. package/packages/server/dist/server.d.ts +37 -25
  207. package/packages/server/dist/server.js +1 -1
  208. package/packages/server/dist/tools/analyze.tools.d.ts +14 -11
  209. package/packages/server/dist/tools/analyze.tools.js +1 -3
  210. package/packages/server/dist/tools/audit.tool.d.ts +8 -5
  211. package/packages/server/dist/tools/audit.tool.js +1 -4
  212. package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
  213. package/packages/server/dist/tools/bridge.tools.js +15 -0
  214. package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
  215. package/packages/server/dist/tools/evolution.tools.js +5 -0
  216. package/packages/server/dist/tools/forge.tools.d.ts +13 -12
  217. package/packages/server/dist/tools/forge.tools.js +10 -13
  218. package/packages/server/dist/tools/forget.tool.d.ts +7 -4
  219. package/packages/server/dist/tools/forget.tool.js +1 -7
  220. package/packages/server/dist/tools/graph.tool.d.ts +7 -4
  221. package/packages/server/dist/tools/graph.tool.js +4 -5
  222. package/packages/server/dist/tools/list.tool.d.ts +7 -4
  223. package/packages/server/dist/tools/list.tool.js +2 -8
  224. package/packages/server/dist/tools/lookup.tool.d.ts +7 -4
  225. package/packages/server/dist/tools/lookup.tool.js +2 -9
  226. package/packages/server/dist/tools/onboard.tool.d.ts +8 -5
  227. package/packages/server/dist/tools/onboard.tool.js +2 -2
  228. package/packages/server/dist/tools/policy.tools.d.ts +7 -0
  229. package/packages/server/dist/tools/policy.tools.js +2 -0
  230. package/packages/server/dist/tools/produce.tool.d.ts +6 -3
  231. package/packages/server/dist/tools/produce.tool.js +2 -2
  232. package/packages/server/dist/tools/read.tool.d.ts +7 -4
  233. package/packages/server/dist/tools/read.tool.js +2 -6
  234. package/packages/server/dist/tools/reindex.tool.d.ts +10 -7
  235. package/packages/server/dist/tools/reindex.tool.js +3 -2
  236. package/packages/server/dist/tools/remember.tool.d.ts +8 -4
  237. package/packages/server/dist/tools/remember.tool.js +3 -5
  238. package/packages/server/dist/tools/replay.tool.d.ts +6 -3
  239. package/packages/server/dist/tools/replay.tool.js +2 -6
  240. package/packages/server/dist/tools/search.tool.d.ts +10 -5
  241. package/packages/server/dist/tools/search.tool.js +6 -22
  242. package/packages/server/dist/tools/status.tool.d.ts +12 -4
  243. package/packages/server/dist/tools/status.tool.js +2 -3
  244. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -35
  245. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  246. package/packages/server/dist/tools/update.tool.d.ts +7 -4
  247. package/packages/server/dist/tools/update.tool.js +1 -6
  248. package/packages/server/dist/tools/utility.tools.d.ts +15 -15
  249. package/packages/server/dist/tools/utility.tools.js +10 -23
  250. package/packages/server/dist/version-check.d.ts +5 -2
  251. package/packages/server/dist/version-check.js +1 -1
  252. package/packages/store/dist/graph-store.interface.d.ts +89 -87
  253. package/packages/store/dist/graph-store.interface.js +1 -0
  254. package/packages/store/dist/index.d.ts +6 -6
  255. package/packages/store/dist/index.js +1 -1
  256. package/packages/store/dist/lance-store.d.ts +37 -31
  257. package/packages/store/dist/lance-store.js +1 -1
  258. package/packages/store/dist/sqlite-graph-store.d.ts +43 -47
  259. package/packages/store/dist/sqlite-graph-store.js +13 -13
  260. package/packages/store/dist/store-factory.d.ts +11 -8
  261. package/packages/store/dist/store-factory.js +1 -1
  262. package/packages/store/dist/store.interface.d.ts +47 -47
  263. package/packages/store/dist/store.interface.js +1 -0
  264. package/packages/tools/dist/audit.d.ts +61 -62
  265. package/packages/tools/dist/audit.js +4 -5
  266. package/packages/tools/dist/batch.d.ts +20 -18
  267. package/packages/tools/dist/batch.js +1 -1
  268. package/packages/tools/dist/changelog.d.ts +29 -27
  269. package/packages/tools/dist/changelog.js +2 -2
  270. package/packages/tools/dist/check.d.ts +42 -39
  271. package/packages/tools/dist/check.js +2 -2
  272. package/packages/tools/dist/checkpoint.d.ts +17 -15
  273. package/packages/tools/dist/checkpoint.js +1 -2
  274. package/packages/tools/dist/codemod.d.ts +35 -33
  275. package/packages/tools/dist/codemod.js +2 -2
  276. package/packages/tools/dist/compact.d.ts +34 -38
  277. package/packages/tools/dist/compact.js +2 -2
  278. package/packages/tools/dist/data-transform.d.ts +10 -8
  279. package/packages/tools/dist/data-transform.js +1 -1
  280. package/packages/tools/dist/dead-symbols.d.ts +29 -26
  281. package/packages/tools/dist/dead-symbols.js +2 -2
  282. package/packages/tools/dist/delegate.d.ts +26 -24
  283. package/packages/tools/dist/delegate.js +1 -5
  284. package/packages/tools/dist/diff-parse.d.ts +24 -22
  285. package/packages/tools/dist/diff-parse.js +3 -3
  286. package/packages/tools/dist/digest.d.ts +43 -46
  287. package/packages/tools/dist/digest.js +4 -5
  288. package/packages/tools/dist/dogfood-log.d.ts +49 -0
  289. package/packages/tools/dist/dogfood-log.js +2 -0
  290. package/packages/tools/dist/encode.d.ts +11 -9
  291. package/packages/tools/dist/encode.js +1 -1
  292. package/packages/tools/dist/env-info.d.ts +25 -23
  293. package/packages/tools/dist/env-info.js +1 -1
  294. package/packages/tools/dist/eval.d.ts +13 -11
  295. package/packages/tools/dist/eval.js +2 -3
  296. package/packages/tools/dist/evidence-map.d.ts +64 -62
  297. package/packages/tools/dist/evidence-map.js +2 -3
  298. package/packages/tools/dist/file-cache.d.ts +41 -0
  299. package/packages/tools/dist/file-cache.js +3 -0
  300. package/packages/tools/dist/file-summary.d.ts +50 -30
  301. package/packages/tools/dist/file-summary.js +2 -2
  302. package/packages/tools/dist/file-walk.d.ts +6 -4
  303. package/packages/tools/dist/file-walk.js +1 -1
  304. package/packages/tools/dist/find-examples.d.ts +26 -22
  305. package/packages/tools/dist/find-examples.js +3 -3
  306. package/packages/tools/dist/find.d.ts +39 -41
  307. package/packages/tools/dist/find.js +1 -1
  308. package/packages/tools/dist/forge-classify.d.ts +35 -39
  309. package/packages/tools/dist/forge-classify.js +2 -2
  310. package/packages/tools/dist/forge-ground.d.ts +58 -61
  311. package/packages/tools/dist/forge-ground.js +1 -1
  312. package/packages/tools/dist/git-context.d.ts +22 -20
  313. package/packages/tools/dist/git-context.js +3 -3
  314. package/packages/tools/dist/graph-query.d.ts +75 -79
  315. package/packages/tools/dist/graph-query.js +1 -1
  316. package/packages/tools/dist/guide.d.ts +14 -12
  317. package/packages/tools/dist/guide.js +1 -1
  318. package/packages/tools/dist/health.d.ts +13 -11
  319. package/packages/tools/dist/health.js +2 -2
  320. package/packages/tools/dist/http-request.d.ts +20 -18
  321. package/packages/tools/dist/http-request.js +1 -1
  322. package/packages/tools/dist/index.d.ts +55 -53
  323. package/packages/tools/dist/index.js +1 -1
  324. package/packages/tools/dist/lane.d.ts +28 -26
  325. package/packages/tools/dist/lane.js +6 -7
  326. package/packages/tools/dist/measure.d.ts +34 -30
  327. package/packages/tools/dist/measure.js +2 -2
  328. package/packages/tools/dist/onboard.d.ts +29 -27
  329. package/packages/tools/dist/onboard.js +17 -41
  330. package/packages/tools/dist/parse-output.d.ts +48 -46
  331. package/packages/tools/dist/parse-output.js +2 -2
  332. package/packages/tools/dist/path-resolver.d.ts +4 -2
  333. package/packages/tools/dist/path-resolver.js +1 -1
  334. package/packages/tools/dist/process-manager.d.ts +18 -16
  335. package/packages/tools/dist/process-manager.js +1 -1
  336. package/packages/tools/dist/queue.d.ts +28 -26
  337. package/packages/tools/dist/queue.js +1 -2
  338. package/packages/tools/dist/regex-test.d.ts +26 -24
  339. package/packages/tools/dist/regex-test.js +1 -1
  340. package/packages/tools/dist/rename.d.ts +28 -26
  341. package/packages/tools/dist/rename.js +2 -2
  342. package/packages/tools/dist/replay.d.ts +33 -31
  343. package/packages/tools/dist/replay.js +4 -6
  344. package/packages/tools/dist/response-envelope.d.ts +32 -30
  345. package/packages/tools/dist/response-envelope.js +1 -1
  346. package/packages/tools/dist/schema-validate.d.ts +15 -13
  347. package/packages/tools/dist/schema-validate.js +1 -1
  348. package/packages/tools/dist/scope-map.d.ts +45 -48
  349. package/packages/tools/dist/scope-map.js +1 -1
  350. package/packages/tools/dist/snippet.d.ts +26 -25
  351. package/packages/tools/dist/snippet.js +1 -1
  352. package/packages/tools/dist/stash.d.ts +13 -11
  353. package/packages/tools/dist/stash.js +1 -2
  354. package/packages/tools/dist/stratum-card.d.ts +27 -28
  355. package/packages/tools/dist/stratum-card.js +3 -5
  356. package/packages/tools/dist/symbol.d.ts +31 -26
  357. package/packages/tools/dist/symbol.js +3 -3
  358. package/packages/tools/dist/test-run.d.ts +19 -16
  359. package/packages/tools/dist/test-run.js +2 -2
  360. package/packages/tools/dist/text-utils.d.ts +6 -4
  361. package/packages/tools/dist/text-utils.js +2 -2
  362. package/packages/tools/dist/time-utils.d.ts +15 -13
  363. package/packages/tools/dist/time-utils.js +1 -1
  364. package/packages/tools/dist/trace.d.ts +26 -21
  365. package/packages/tools/dist/trace.js +2 -2
  366. package/packages/tools/dist/truncation.d.ts +6 -4
  367. package/packages/tools/dist/truncation.js +6 -13
  368. package/packages/tools/dist/watch.d.ts +28 -26
  369. package/packages/tools/dist/watch.js +1 -1
  370. package/packages/tools/dist/web-fetch.d.ts +35 -33
  371. package/packages/tools/dist/web-fetch.js +6 -12
  372. package/packages/tools/dist/web-search.d.ts +16 -14
  373. package/packages/tools/dist/web-search.js +1 -1
  374. package/packages/tools/dist/workset.d.ts +19 -17
  375. package/packages/tools/dist/workset.js +1 -2
  376. package/packages/tui/dist/App-CYLNJLr6.js +2 -0
  377. package/packages/tui/dist/App.d.ts +11 -6
  378. package/packages/tui/dist/App.js +1 -450
  379. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +2 -0
  380. package/packages/tui/dist/LogPanel-DtMnoyXT.js +3 -0
  381. package/packages/tui/dist/SearchPanel-DREo6zgt.js +2 -0
  382. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +2 -0
  383. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  384. package/packages/tui/dist/devtools-DUyj952l.js +7 -0
  385. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +28 -0
  386. package/packages/tui/dist/index-B9VpfVPP.d.ts +13 -0
  387. package/packages/tui/dist/index.d.ts +3 -19
  388. package/packages/tui/dist/index.js +1 -476
  389. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +316 -0
  390. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -6
  391. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  392. package/packages/tui/dist/panels/LogPanel.d.ts +7 -3
  393. package/packages/tui/dist/panels/LogPanel.js +1 -449
  394. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -8
  395. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  396. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -6
  397. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  398. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +150 -0
  399. package/scaffold/adapters/claude-code.mjs +20 -0
  400. package/scaffold/adapters/copilot.mjs +320 -0
  401. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  402. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +21 -0
  403. package/scaffold/copilot/agents/Documenter.agent.md +42 -0
  404. package/scaffold/copilot/agents/Orchestrator.agent.md +104 -0
  405. package/scaffold/copilot/agents/Planner.agent.md +54 -0
  406. package/scaffold/copilot/agents/Refactor.agent.md +36 -0
  407. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +20 -0
  408. package/scaffold/copilot/agents/Researcher-Beta.agent.md +20 -0
  409. package/scaffold/copilot/agents/Researcher-Delta.agent.md +20 -0
  410. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +20 -0
  411. package/scaffold/definitions/agents.mjs +165 -0
  412. package/scaffold/definitions/bodies.mjs +292 -0
  413. package/scaffold/definitions/hooks.mjs +43 -0
  414. package/scaffold/definitions/models.mjs +56 -0
  415. package/scaffold/definitions/plugins.mjs +24 -0
  416. package/scaffold/definitions/prompts.mjs +145 -0
  417. package/scaffold/definitions/protocols.mjs +322 -0
  418. package/scaffold/definitions/tools.mjs +176 -0
  419. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  420. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
  421. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
  422. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
  423. package/scaffold/general/agents/Debugger.agent.md +31 -0
  424. package/scaffold/general/agents/Documenter.agent.md +42 -0
  425. package/scaffold/general/agents/Explorer.agent.md +50 -0
  426. package/scaffold/general/agents/Frontend.agent.md +29 -0
  427. package/scaffold/general/agents/Implementer.agent.md +31 -0
  428. package/scaffold/general/agents/Orchestrator.agent.md +104 -0
  429. package/scaffold/general/agents/Planner.agent.md +55 -0
  430. package/scaffold/general/agents/README.md +57 -0
  431. package/scaffold/general/agents/Refactor.agent.md +36 -0
  432. package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
  433. package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
  434. package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
  435. package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
  436. package/scaffold/general/agents/Security.agent.md +42 -0
  437. package/scaffold/general/agents/_shared/adr-protocol.md +91 -0
  438. package/scaffold/general/agents/_shared/architect-reviewer-base.md +50 -0
  439. package/scaffold/general/agents/_shared/code-agent-base.md +88 -0
  440. package/scaffold/general/agents/_shared/code-reviewer-base.md +54 -0
  441. package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
  442. package/scaffold/general/agents/_shared/forge-protocol.md +46 -0
  443. package/scaffold/general/agents/_shared/researcher-base.md +61 -0
  444. package/scaffold/general/agents/templates/adr-template.md +27 -0
  445. package/scaffold/general/agents/templates/execution-state.md +25 -0
  446. package/scaffold/general/prompts/ask.prompt.md +20 -0
  447. package/scaffold/general/prompts/debug.prompt.md +25 -0
  448. package/scaffold/general/prompts/design.prompt.md +22 -0
  449. package/scaffold/general/prompts/implement.prompt.md +26 -0
  450. package/scaffold/general/prompts/plan.prompt.md +24 -0
  451. package/scaffold/general/prompts/review.prompt.md +31 -0
  452. package/scaffold/generate.mjs +74 -0
  453. package/skills/adr-skill/SKILL.md +329 -0
  454. package/skills/adr-skill/assets/templates/adr-madr.md +89 -0
  455. package/skills/adr-skill/assets/templates/adr-readme.md +20 -0
  456. package/skills/adr-skill/assets/templates/adr-simple.md +46 -0
  457. package/skills/adr-skill/references/adr-conventions.md +95 -0
  458. package/skills/adr-skill/references/examples.md +193 -0
  459. package/skills/adr-skill/references/review-checklist.md +77 -0
  460. package/skills/adr-skill/references/template-variants.md +52 -0
  461. package/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
  462. package/skills/adr-skill/scripts/new_adr.js +391 -0
  463. package/skills/adr-skill/scripts/set_adr_status.js +169 -0
  464. package/skills/brainstorming/SKILL.md +259 -0
  465. package/skills/brainstorming/scripts/frame-template.html +365 -0
  466. package/skills/brainstorming/scripts/helper.js +216 -0
  467. package/skills/brainstorming/scripts/server.cjs +9 -0
  468. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  469. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  470. package/skills/brainstorming/visual-companion.md +430 -0
  471. package/skills/c4-architecture/SKILL.md +295 -0
  472. package/skills/c4-architecture/references/advanced-patterns.md +552 -0
  473. package/skills/c4-architecture/references/c4-syntax.md +492 -0
  474. package/skills/c4-architecture/references/common-mistakes.md +437 -0
  475. package/skills/knowledge-base/SKILL.md +100 -10
  476. package/skills/lesson-learned/SKILL.md +105 -0
  477. package/skills/lesson-learned/references/anti-patterns.md +55 -0
  478. package/skills/lesson-learned/references/se-principles.md +109 -0
  479. package/skills/requirements-clarity/SKILL.md +324 -0
  480. package/skills/session-handoff/SKILL.md +189 -0
  481. package/skills/session-handoff/references/handoff-template.md +139 -0
  482. package/skills/session-handoff/references/resume-checklist.md +80 -0
  483. package/skills/session-handoff/scripts/check_staleness.js +269 -0
  484. package/skills/session-handoff/scripts/create_handoff.js +299 -0
  485. package/skills/session-handoff/scripts/list_handoffs.js +113 -0
  486. package/skills/session-handoff/scripts/validate_handoff.js +241 -0
  487. package/packages/chunker/dist/treesitter-chunker.d.ts +0 -47
  488. package/packages/chunker/dist/treesitter-chunker.js +0 -8
  489. package/packages/cli/dist/commands/init.d.ts +0 -10
  490. package/packages/cli/dist/commands/init.js +0 -308
@@ -1,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{fanOutSearch as e,openWorkspaceStores as t,resolveWorkspaces as n}from"../cross-workspace.js";import{CONTENT_TYPES as r,computePartitionKey as i,createLogger as a,serializeError as o}from"../../../core/dist/index.js";import{addToWorkset as s,batch as c,check as l,checkpointLatest as u,checkpointList as d,checkpointLoad as f,checkpointSave as p,codemod as m,compact as h,dataTransform as g,delegate as ee,delegateListModels as te,deleteWorkset as ne,diffParse as re,evaluate as ie,fileSummary as ae,find as _,findDeadSymbols as oe,findExamples as se,getWorkset as v,gitContext as y,guide as b,health as x,laneCreate as S,laneDiff as C,laneDiscard as w,laneList as T,laneMerge as E,laneStatus as D,listWorksets as O,parseOutput as k,processList as A,processLogs as j,processStart as M,processStatus as N,processStop as P,queueClear as F,queueCreate as I,queueDelete as L,queueDone as R,queueFail as z,queueGet as B,queueList as V,queueNext as H,queuePush as U,removeFromWorkset as W,rename as G,saveWorkset as K,scopeMap as ce,stashClear as le,stashDelete as ue,stashGet as de,stashList as fe,stashSet as pe,summarizeCheckResult as me,symbol as q,testRun as he,trace as ge,truncateToTokenBudget as J,watchList as _e,watchStart as ve,watchStop as ye,webFetch as be}from"../../../tools/dist/index.js";import{z as Y}from"zod";const X=a(`tools`);function xe(e,t,n){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:r,query:i,max_chars:a,segmentation:s})=>{try{if(!e&&!r)return{content:[{type:`text`,text:`Error: Either "text" or "path" must be provided.`}],isError:!0};let o=await h(t,{text:e,path:r,query:i,maxChars:a,segmentation:s,cache:n});return{content:[{type:`text`,text:[`Compressed ${o.originalChars} ${o.compressedChars} chars (${(o.ratio*100).toFixed(0)}%)`,`Kept ${o.segmentsKept}/${o.segmentsTotal} segments`,``,o.text].join(`
2
+ `)}]}}catch(e){return X.error(`Compact failed`,o(e)),{content:[{type:`text`,text:`Compact failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function Se(e,t,n){e.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(r).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:r,content_type:i,max_tokens:a})=>{try{let o=await ce(t,n,{task:e,maxFiles:r,contentType:i}),s=[`## Scope Map: ${e}`,`Total estimated tokens: ~${o.totalEstimatedTokens}`,``,`### Files (by relevance)`,...o.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`,...o.readingOrder.map((e,t)=>`${t+1}. ${e}`),``,`### Suggested Compact Calls`,`_Estimated compressed total: ~${Math.ceil(o.totalEstimatedTokens/5)} tokens_`,...o.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:a?J(s,a):s}]}}catch(e){return X.error(`Scope map failed`,o(e)),{content:[{type:`text`,text:`Scope map failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function Ce(a,s,c){a.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(r).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.`),workspaces:Y.array(Y.string()).optional().describe(`Cross-workspace search: partition names or folder basenames to include. Use ["*"] for all. Global mode only.`)}},async({query:r,glob:a,pattern:l,limit:u,content_type:d,mode:f,max_tokens:p,workspaces:m})=>{try{if(f===`examples`){if(!r)return{content:[{type:`text`,text:`Error: "query" is required for mode "examples".`}],isError:!0};let e=await se(s,c,{query:r,limit:u,contentType:d}),t=JSON.stringify(e,null,2);return{content:[{type:`text`,text:p?J(t,p):t}]}}let o=await _(s,c,{query:r,glob:a,pattern:l,limit:u,contentType:d}),h=``;if(m&&m.length>0&&r){let a=n(m,i(process.cwd()));if(a.length>0){let{stores:n,closeAll:i}=await t(a);try{let t=await e(n,await s.embedQuery(r),{limit:u,contentType:d});for(let e of t)o.results.push({path:`[${e.workspace}] ${e.record.sourcePath}`,score:e.score,source:`cross-workspace`,lineRange:e.record.startLine?{start:e.record.startLine,end:e.record.endLine}:void 0,preview:e.record.content.slice(0,200)});o.results.sort((e,t)=>t.score-e.score),o.results=o.results.slice(0,u),o.totalFound=o.results.length,h=` + ${a.length} workspace(s)`}finally{await i()}}}if(o.results.length===0)return{content:[{type:`text`,text:`No results found.`}]};let g=[`Found ${o.totalFound} results via ${o.strategies.join(` + `)}${h}`,``,...o.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:p?J(g.join(`
4
+ `),p):g.join(`
5
+ `)}]}}catch(e){return X.error(`Find failed`,o(e)),{content:[{type:`text`,text:`Find failed. Check server logs for details.`}],isError:!0}}})}function we(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=k(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`,o(e)),{content:[{type:`text`,text:`Parse failed. Check server logs for details.`}],isError:!0}}})}function Te(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:n,description:r})=>{try{switch(e){case`save`:{if(!t||!n)throw Error(`name and files required for save`);let e=K(t,n,{description:r});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=v(t);return e?{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}:{content:[{type:`text`,text:`Workset "${t}" not found.`}]}}case`list`:{let e=O();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:ne(t)?`Deleted workset "${t}".`:`Workset "${t}" not found.`}]};case`add`:{if(!t||!n)throw Error(`name and files required for add`);let e=s(t,n);return{content:[{type:`text`,text:`Added to workset "${e.name}": now ${e.files.length} files.`}]}}case`remove`:{if(!t||!n)throw Error(`name and files required for remove`);let e=W(t,n);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`,o(e)),{content:[{type:`text`,text:`Workset operation failed. Check server logs for details.`}],isError:!0}}})}function Ee(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:n,skip_lint:r,detail:i})=>{try{let a=await l({files:e,cwd:t,skipTypes:n,skipLint:r,detail:i===`summary`?`errors`:i});if(i===`summary`){let e=me(a),t=[];if(a.passed)t.push({tool:`test_run`,reason:`Types and lint clean — run tests next`});else{let e=a.tsc.errors[0]?.file??a.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(a,null,2)}]}}catch(e){return X.error(`Check failed`,o(e)),{content:[{type:`text`,text:`Check failed. Check server logs for details.`}],isError:!0}}})}function De(e,t,n){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:r})=>{try{let i=await c(e,async e=>Xe(e,t,n),{concurrency:r});return{content:[{type:`text`,text:JSON.stringify(i,null,2)}]}}catch(e){return X.error(`Batch failed`,o(e)),{content:[{type:`text`,text:`Batch failed. Check server logs for details.`}],isError:!0}}})}function Oe(e,r,a){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`),workspaces:Y.array(Y.string()).optional().describe(`Cross-workspace search: partition names or folder basenames to include. Use ["*"] for all. Global mode only.`)}},async({name:e,limit:s,workspaces:c})=>{try{let o=await q(r,a,{name:e,limit:s});if(c&&c.length>0){let a=n(c,i(process.cwd()));if(a.length>0){let{stores:n,closeAll:i}=await t(a);try{for(let[t,i]of n){let n=await q(r,i,{name:e,limit:s});n.definedIn&&!o.definedIn&&(o.definedIn={...n.definedIn,path:`[${t}] ${n.definedIn.path}`});for(let e of n.referencedIn)o.referencedIn.push({...e,path:`[${t}] ${e.path}`});if(n.importedBy){o.importedBy=o.importedBy??[];for(let e of n.importedBy)o.importedBy.push({...e,path:`[${t}] ${e.path}`})}}}finally{await i()}}}return{content:[{type:`text`,text:Qe(o)}]}}catch(e){return X.error(`Symbol lookup failed`,o(e)),{content:[{type:`text`,text:`Symbol lookup failed. Check server logs for details.`}],isError:!0}}})}function ke(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:n})=>{try{let r=ie({code:e,lang:t,timeout:n});return r.success?{content:[{type:`text`,text:`Eval succeeded in ${r.durationMs}ms\n\n${r.output}`}]}:{content:[{type:`text`,text:`Eval failed in ${r.durationMs}ms: ${r.error??`Unknown error`}`}],isError:!0}}catch(e){return X.error(`Eval failed`,o(e)),{content:[{type:`text`,text:`Eval failed. Check server logs for details.`}],isError:!0}}})}function Ae(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:n})=>{try{let r=await he({files:e,grep:t,cwd:n});return{content:[{type:`text`,text:$e(r)}],isError:!r.passed}}catch(e){return X.error(`Test run failed`,o(e)),{content:[{type:`text`,text:`Test run failed. Check server logs for details.`}],isError:!0}}})}function je(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:n})=>{try{switch(e){case`set`:{if(!t)throw Error(`key required for set`);let e=pe(t,rt(n??``));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=de(t);return{content:[{type:`text`,text:e?JSON.stringify(e,null,2):`Stash entry "${t}" not found.`}]}}case`list`:{let e=fe();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:ue(t)?`Deleted stash entry "${t}".`:`Stash entry "${t}" not found.`}]};case`clear`:{let e=le();return{content:[{type:`text`,text:`Cleared ${e} stash entr${e===1?`y`:`ies`}.`}]}}}}catch(e){return X.error(`Stash operation failed`,o(e)),{content:[{type:`text`,text:`Stash operation failed. Check server logs for details.`}],isError:!0}}})}function Me(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:n})=>{try{return{content:[{type:`text`,text:et(await y({cwd:e,commitCount:t,includeDiff:n}))}]}}catch(e){return X.error(`Git context failed`,o(e)),{content:[{type:`text`,text:`Git context failed. Check server logs for details.`}],isError:!0}}})}function Ne(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:tt(re({diff:e.replace(/\\n/g,`
9
+ `).replace(/\\t/g,` `)}))}]}}catch(e){return X.error(`Diff parse failed`,o(e)),{content:[{type:`text`,text:`Diff parse failed. Check server logs for details.`}],isError:!0}}})}function Pe(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:n,extensions:r,dry_run:i})=>{try{let a=await G({oldName:e,newName:t,rootPath:n,extensions:r,dryRun:i});return{content:[{type:`text`,text:JSON.stringify(a,null,2)}]}}catch(e){return X.error(`Rename failed`,o(e)),{content:[{type:`text`,text:`Rename failed. Check server logs for details.`}],isError:!0}}})}function Fe(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:n})=>{try{let r=await m({rootPath:e,rules:t,dryRun:n});return{content:[{type:`text`,text:JSON.stringify(r,null,2)}]}}catch(e){return X.error(`Codemod failed`,o(e)),{content:[{type:`text`,text:`Codemod failed. Check server logs for details.`}],isError:!0}}})}function Ie(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:nt(await ae({path:e,content:(await t.get(e)).content}))}]}}catch(e){return X.error(`File summary failed`,o(e)),{content:[{type:`text`,text:`File summary failed. Check server logs for details.`}],isError:!0}}})}function Le(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:n,notes:r})=>{try{switch(e){case`save`:if(!t)throw Error(`label required for save`);return{content:[{type:`text`,text:Q(p(t,it(n),{notes:r}))}]};case`load`:{if(!t)throw Error(`label required for load`);let e=f(t);return{content:[{type:`text`,text:e?Q(e):`Checkpoint "${t}" not found.`}]}}case`list`:{let e=d();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=u();return{content:[{type:`text`,text:e?Q(e):`No checkpoints saved.`}]}}}}catch(e){return X.error(`Checkpoint failed`,o(e)),{content:[{type:`text`,text:`Checkpoint failed. Check server logs for details.`}],isError:!0}}})}function Re(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:g({input:e,expression:t}).outputString}]}}catch(e){return X.error(`Data transform failed`,o(e)),{content:[{type:`text`,text:`Data transform failed. Check server logs for details.`}],isError:!0}}})}function ze(e,t,n){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:r,max_depth:i})=>{try{let a=await ge(t,n,{start:e,direction:r,maxDepth:i}),o=[`## Trace: ${a.start}`,`Direction: ${a.direction} | Depth: ${a.depth}`,``];if(a.nodes.length===0)o.push(`No connections found.`);else{let e=a.nodes.filter(e=>e.relationship===`calls`),t=a.nodes.filter(e=>e.relationship===`called-by`),n=a.nodes.filter(e=>e.relationship===`imports`),r=a.nodes.filter(e=>e.relationship===`imported-by`),i=a.nodes.filter(e=>e.relationship===`references`);if(e.length>0){o.push(`### Calls (${e.length})`);for(let t of e){let e=t.scope?` (from ${t.scope}())`:``;o.push(`- ${t.symbol}() ${t.path}:${t.line}${e}`)}o.push(``)}if(t.length>0){o.push(`### Called by (${t.length})`);for(let e of t){let t=e.scope?` in ${e.scope}()`:``;o.push(`- ${e.symbol}()${t} ${e.path}:${e.line}`)}o.push(``)}if(n.length>0){o.push(`### Imports (${n.length})`);for(let e of n)o.push(`- ${e.symbol} ${e.path}:${e.line}`);o.push(``)}if(r.length>0){o.push(`### Imported by (${r.length})`);for(let e of r)o.push(`- ${e.path}:${e.line}`);o.push(``)}if(i.length>0){o.push(`### References (${i.length})`);for(let e of i)o.push(`- ${e.path}:${e.line}`);o.push(``)}}return o.push(`---`,"_Next: `symbol` for definition details | `compact` to read a referenced file | `blast_radius` for impact analysis_"),{content:[{type:`text`,text:o.join(`
11
+ `)}]}}catch(e){return X.error(`Trace failed`,o(e)),{content:[{type:`text`,text:`Trace failed. Check server logs for details.`}],isError:!0}}})}function Be(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:n,args:r,tail:i})=>{try{switch(e){case`start`:if(!t||!n)throw Error(`id and command are required for start`);return{content:[{type:`text`,text:JSON.stringify(M(t,n,r??[]),null,2)}]};case`stop`:if(!t)throw Error(`id is required for stop`);return{content:[{type:`text`,text:JSON.stringify(P(t)??null,null,2)}]};case`status`:if(!t)throw Error(`id is required for status`);return{content:[{type:`text`,text:JSON.stringify(N(t)??null,null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(A(),null,2)}]};case`logs`:if(!t)throw Error(`id is required for logs`);return{content:[{type:`text`,text:JSON.stringify(j(t,i),null,2)}]}}}catch(e){return X.error(`Process action failed`,o(e)),{content:[{type:`text`,text:`Process action failed. Check server logs for details.`}],isError:!0}}})}function Ve(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:n})=>{try{switch(e){case`start`:if(!t)throw Error(`path is required for start`);return{content:[{type:`text`,text:JSON.stringify(ve({path:t}),null,2)}]};case`stop`:if(!n)throw Error(`id is required for stop`);return{content:[{type:`text`,text:JSON.stringify({stopped:ye(n)},null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(_e(),null,2)}]}}}catch(e){return X.error(`Watch action failed`,o(e)),{content:[{type:`text`,text:`Watch action failed. Check server logs for details.`}],isError:!0}}})}function He(e,t,n){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:r})=>{try{let i=await oe(t,n,{rootPath:e,limit:r}),a=[`## Dead Symbol Analysis`,``,`**Exports scanned:** ${i.totalExports}`,`**Dead in source:** ${i.totalDeadSource} (actionable)`,`**Dead in docs:** ${i.totalDeadDocs} (informational — code samples in .md files)`,``];if(i.deadInSource.length>0){a.push(`### Dead in Source (actionable)`);for(let e of i.deadInSource)a.push(`- \`${e.name}\` (${e.kind}) — ${e.path}:${e.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 — not actionable dead code._`);for(let e of i.deadInDocs.slice(0,5))a.push(`- \`${e.name}\` — ${e.path}:${e.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` — no dead symbols found, validate types and lint_"),{content:[{type:`text`,text:a.join(`
12
+ `)}]}}catch(e){return X.error(`Dead symbol scan failed`,o(e)),{content:[{type:`text`,text:`Dead symbol scan failed. Check server logs for details.`}],isError:!0}}})}function Ue(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:n,context:r,temperature:i,timeout:a,action:s})=>{try{if(s===`list_models`){let e=await te();return{content:[{type:`text`,text:JSON.stringify({models:e,count:e.length,_Next:`Use delegate with a model name`},null,2)}]}}let o=await ee({prompt:e,model:t,system:n,context:r,temperature:i,timeout:a});return o.error?{content:[{type:`text`,text:JSON.stringify({error:o.error,model:o.model,durationMs:o.durationMs},null,2)}],isError:!0}:{content:[{type:`text`,text:JSON.stringify({model:o.model,response:o.response,durationMs:o.durationMs,tokenCount:o.tokenCount,_Next:`Use the response in your workflow. stash to save it.`},null,2)}]}}catch(e){return X.error(`Delegate failed`,o(e)),{content:[{type:`text`,text:`Delegate failed. Check server logs for details.`}],isError:!0}}})}function We(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:n})=>{try{switch(e){case`create`:{if(!t)throw Error(`name is required for create`);if(!n||n.length===0)throw Error(`files are required for create`);let e=S(t,n);return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}case`list`:return{content:[{type:`text`,text:JSON.stringify(T(),null,2)}]};case`status`:if(!t)throw Error(`name is required for status`);return{content:[{type:`text`,text:JSON.stringify(D(t),null,2)}]};case`diff`:if(!t)throw Error(`name is required for diff`);return{content:[{type:`text`,text:JSON.stringify(C(t),null,2)}]};case`merge`:if(!t)throw Error(`name is required for merge`);return{content:[{type:`text`,text:JSON.stringify(E(t),null,2)}]};case`discard`:if(!t)throw Error(`name is required for discard`);return{content:[{type:`text`,text:JSON.stringify({discarded:w(t)},null,2)}]}}}catch(e){return X.error(`Lane action failed`,o(e)),{content:[{type:`text`,text:`Lane action failed. Check server logs for details.`}],isError:!0}}})}function Ge(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=x(e);return{content:[{type:`text`,text:JSON.stringify(t,null,2)}]}}catch(e){return X.error(`Health check failed`,o(e)),{content:[{type:`text`,text:`Health check failed. Check server logs for details.`}],isError:!0}}})}function Ke(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:n,id:r,data:i,error:a})=>{try{switch(e){case`create`:if(!t)throw Error(`name is required for create`);return{content:[{type:`text`,text:JSON.stringify(I(t),null,2)}]};case`push`:if(!t)throw Error(`name is required for push`);if(!n)throw Error(`title is required for push`);return{content:[{type:`text`,text:JSON.stringify(U(t,n,i),null,2)}]};case`next`:{if(!t)throw Error(`name is required for next`);let e=H(t);return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}case`done`:if(!t)throw Error(`name is required for done`);if(!r)throw Error(`id is required for done`);return{content:[{type:`text`,text:JSON.stringify(R(t,r),null,2)}]};case`fail`:if(!t)throw Error(`name is required for fail`);if(!r)throw Error(`id is required for fail`);if(!a)throw Error(`error is required for fail`);return{content:[{type:`text`,text:JSON.stringify(z(t,r,a),null,2)}]};case`get`:if(!t)throw Error(`name is required for get`);return{content:[{type:`text`,text:JSON.stringify(B(t),null,2)}]};case`list`:return{content:[{type:`text`,text:JSON.stringify(V(),null,2)}]};case`clear`:if(!t)throw Error(`name is required for clear`);return{content:[{type:`text`,text:JSON.stringify({cleared:F(t)},null,2)}]};case`delete`:if(!t)throw Error(`name is required for delete`);return{content:[{type:`text`,text:JSON.stringify({deleted:L(t)},null,2)}]}}}catch(e){return X.error(`Queue action failed`,o(e)),{content:[{type:`text`,text:`Queue action failed. Check server logs for details.`}],isError:!0}}})}const qe=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(r).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()}),Je=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(r).optional(),cwd:Y.string().optional()}),Ye=Y.object({files:Y.array(Y.string()).optional(),cwd:Y.string().optional(),skip_types:Y.boolean().optional(),skip_lint:Y.boolean().optional()});async function Xe(e,t,n){switch(e.type){case`search`:return Z(t,n,qe.parse(e.args));case`find`:{let r=Je.parse(e.args);if(!r.query&&!r.glob&&!r.pattern)throw Error(`find operation requires query, glob, or pattern`);return _(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=Ye.parse(e.args);return l({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 Z(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 Ze(s,c).slice(0,r)}function Ze(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 Qe(e){let t=[`Symbol: ${e.name}`];if(e.definedIn){let n=`Defined in: ${e.definedIn.path}:${e.definedIn.line} (${e.definedIn.kind})`;e.definedIn.signature&&(n+=`\nSignature: ${e.definedIn.signature}`),t.push(n)}else t.push(`Defined in: not found`);if(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){let e=`scope`in n&&n.scope?` in ${n.scope}()`:``;t.push(` - ${n.path}:${n.line}${e} ${n.context}`)}return t.join(`
13
+ `)}function $e(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(`
14
+ `)}function et(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(`
15
+ `)}function tt(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(`
16
+ `)}function nt(e){let t=[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]`:``}${`signature`in e&&e.signature?` ${e.signature}`:``}`)),``,`Classes (${e.classes.length}):`,...$(e.classes.map(e=>`${e.name} @ line ${e.line}${e.exported?` [exported]`:``}${e.signature?` ${e.signature}`:``}`)),``,`Interfaces (${e.interfaces.length}):`,...$(e.interfaces.map(e=>`${e.name} @ line ${e.line}${`exported`in e&&e.exported?` [exported]`:``}`)),``,`Types (${e.types.length}):`,...$(e.types.map(e=>`${e.name} @ line ${e.line}${`exported`in e&&e.exported?` [exported]`:``}`))];if(`importDetails`in e&&e.importDetails&&e.importDetails.length>0){let n=e.importDetails.filter(e=>e.isExternal).length,r=e.importDetails.length-n;t.push(``,`Import breakdown: ${n} external, ${r} internal`)}if(`callEdges`in e&&e.callEdges&&e.callEdges.length>0){t.push(``,`Call edges (${e.callEdges.length} intra-file):`);for(let n of e.callEdges.slice(0,30))t.push(` - ${n.caller}() ${n.callee}() @ line ${n.line}`);e.callEdges.length>30&&t.push(` - ... ${e.callEdges.length-30} more`)}return t.join(`
17
+ `)}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(`
18
+ `)}function $(e){return e.length===0?[` none`]:e.map(e=>` - ${e}`)}function rt(e){let t=e.trim();if(!t)return``;try{return JSON.parse(t)}catch{return e}}function it(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 at(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:n,max_length:r,include_metadata:i,include_links:a,include_images:s,timeout:c})=>{try{let o=await be({url:e,mode:t,selector:n,maxLength:r,includeMetadata:i,includeLinks:a,includeImages:s,timeout:c}),l=[`## ${o.title||`Web Page`}`,``,o.content];return o.truncated&&l.push(``,`_Original length: ${o.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(`
19
+ `)}]}}catch(e){return X.error(`Web fetch failed`,o(e)),{content:[{type:`text`,text:`Web fetch failed. Check server logs for details.`}],isError:!0}}})}function ot(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=b(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(`
20
+ `)}]}}catch(e){return X.error(`Guide failed`,o(e)),{content:[{type:`text`,text:`Guide failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{De as registerBatchTool,Ee as registerCheckTool,Le as registerCheckpointTool,Fe as registerCodemodTool,xe as registerCompactTool,Re as registerDataTransformTool,He as registerDeadSymbolsTool,Ue as registerDelegateTool,Ne as registerDiffParseTool,ke as registerEvalTool,Ie as registerFileSummaryTool,Ce as registerFindTool,Me as registerGitContextTool,ot as registerGuideTool,Ge as registerHealthTool,We as registerLaneTool,we as registerParseOutputTool,Be as registerProcessTool,Ke as registerQueueTool,Pe as registerRenameTool,Se as registerScopeMapTool,je as registerStashTool,Oe as registerSymbolTool,Ae as registerTestRunTool,ze as registerTraceTool,Ve as registerWatchTool,at as registerWebFetchTool,Te as registerWorksetTool};
@@ -1,4 +1,7 @@
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;
4
- //# sourceMappingURL=update.tool.d.ts.map
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 };
@@ -1,6 +1 @@
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 .ai/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: \`.ai/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};
@@ -1,15 +1,15 @@
1
- /**
2
- * MCP tool registrations for utility tools (web-search, http, regex, encode, etc.)
3
- */
4
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
- export declare function registerWebSearchTool(server: McpServer): void;
6
- export declare function registerHttpTool(server: McpServer): void;
7
- export declare function registerRegexTestTool(server: McpServer): void;
8
- export declare function registerEncodeTool(server: McpServer): void;
9
- export declare function registerMeasureTool(server: McpServer): void;
10
- export declare function registerChangelogTool(server: McpServer): void;
11
- export declare function registerSchemaValidateTool(server: McpServer): void;
12
- export declare function registerSnippetTool(server: McpServer): void;
13
- export declare function registerEnvTool(server: McpServer): void;
14
- export declare function registerTimeTool(server: McpServer): void;
15
- //# sourceMappingURL=utility.tools.d.ts.map
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+
3
+ //#region packages/server/src/tools/utility.tools.d.ts
4
+ declare function registerWebSearchTool(server: McpServer): void;
5
+ declare function registerHttpTool(server: McpServer): void;
6
+ declare function registerRegexTestTool(server: McpServer): void;
7
+ declare function registerEncodeTool(server: McpServer): void;
8
+ declare function registerMeasureTool(server: McpServer): void;
9
+ declare function registerChangelogTool(server: McpServer): void;
10
+ declare function registerSchemaValidateTool(server: McpServer): void;
11
+ declare function registerSnippetTool(server: McpServer): void;
12
+ declare function registerEnvTool(server: McpServer): void;
13
+ declare function registerTimeTool(server: McpServer): void;
14
+ //#endregion
15
+ export { registerChangelogTool, registerEncodeTool, registerEnvTool, registerHttpTool, registerMeasureTool, registerRegexTestTool, registerSchemaValidateTool, registerSnippetTool, registerTimeTool, registerWebSearchTool };
@@ -1,24 +1,11 @@
1
- import{changelog as g,encode as f,envInfo as h,httpRequest as y,measure as x,regexTest as $,schemaValidate as b,snippet as S,timeUtils as v,webSearch as T}from"../../../tools/dist/index.js";import{z as e}from"zod";function _(c){c.registerTool("web_search",{description:"PREFERRED web search \u2014 search the web via DuckDuckGo (no API key). Returns structured results with title, URL, and snippet.",inputSchema:{query:e.string().describe("Search query"),limit:e.number().min(1).max(20).default(5).describe("Max results to return"),site:e.string().optional().describe('Restrict to domain (e.g., "docs.aws.amazon.com")')}},async({query:a,limit:i,site:r})=>{try{const s=await T({query:a,limit:i,site:r}),t=[`## Search: ${s.query}`,""];if(s.results.length===0)t.push("No results found.");else for(const n of s.results)t.push(`### [${n.title}](${n.url})`,n.snippet,"");return t.push("---","_Next: Use `web_fetch` to read any of these pages in full._"),{content:[{type:"text",text:t.join(`
2
- `)}]}}catch(s){return{content:[{type:"text",text:`Web search failed: ${s.message}`}],isError:!0}}})}function M(c){c.registerTool("http",{description:"Make HTTP requests (GET/POST/PUT/PATCH/DELETE/HEAD) for API testing. Returns status, headers, and formatted body with timing info.",inputSchema:{url:e.string().url().describe("Request URL (http/https only)"),method:e.enum(["GET","POST","PUT","PATCH","DELETE","HEAD"]).default("GET").describe("HTTP method"),headers:e.record(e.string(),e.string()).optional().describe("Request headers as key-value pairs"),body:e.string().optional().describe("Request body (for POST/PUT/PATCH)"),timeout:e.number().min(1e3).max(6e4).default(15e3).describe("Timeout in milliseconds")}},async({url:a,method:i,headers:r,body:s,timeout:t})=>{try{const n=await y({url:a,method:i,headers:r,body:s,timeout:t}),o=[`## ${i} ${a}`,"",`**Status:** ${n.status} ${n.statusText}`,`**Time:** ${n.durationMs}ms`,`**Size:** ${n.sizeBytes} bytes`,`**Content-Type:** ${n.contentType}`,"","### Headers","```json",JSON.stringify(n.headers,null,2),"```","","### Body",n.contentType.includes("json")?"```json":"```",n.body,"```"];return n.truncated&&o.push("",`_Response truncated \u2014 total size: ${n.sizeBytes} bytes_`),{content:[{type:"text",text:o.join(`
3
- `)}]}}catch(n){return{content:[{type:"text",text:`HTTP request failed: ${n.message}`}],isError:!0}}})}function R(c){c.registerTool("regex_test",{description:"Test a regex pattern against sample strings. Supports match, replace, and split modes.",inputSchema:{pattern:e.string().describe("Regex pattern (without delimiters)"),flags:e.string().default("").describe("Regex flags (g, i, m, s, etc.)"),test_strings:e.array(e.string()).describe("Strings to test the pattern against"),mode:e.enum(["match","replace","split"]).default("match").describe("Test mode"),replacement:e.string().optional().describe("Replacement string (for replace mode)")}},async({pattern:a,flags:i,test_strings:r,mode:s,replacement:t})=>{const n=$({pattern:a,flags:i,testStrings:r,mode:s,replacement:t});if(!n.valid)return{content:[{type:"text",text:`Invalid regex: ${n.error}`}],isError:!0};const o=[`## Regex: \`/${n.pattern}/${n.flags}\``,"",`Mode: ${s}`,""];for(const d of n.results){if(o.push(`**Input:** \`${d.input}\``),o.push(`**Matched:** ${d.matched}`),d.matches)for(const p of d.matches){const l=p.groups.length>0?` groups: [${p.groups.join(", ")}]`:"";o.push(` - "${p.full}" at index ${p.index}${l}`)}d.replaced!==void 0&&o.push(`**Result:** \`${d.replaced}\``),d.split&&o.push(`**Split:** ${JSON.stringify(d.split)}`),o.push("")}return{content:[{type:"text",text:o.join(`
4
- `)}]}})}function j(c){c.registerTool("encode",{description:"Encode, decode, or hash text. Supports base64, URL encoding, SHA-256, MD5, JWT decode, hex.",inputSchema:{operation:e.enum(["base64_encode","base64_decode","url_encode","url_decode","sha256","md5","jwt_decode","hex_encode","hex_decode"]).describe("Operation to perform"),input:e.string().describe("Input text")}},async({operation:a,input:i})=>{try{const r=f({operation:a,input:i});return{content:[{type:"text",text:`## ${a}
1
+ import{createLogger as e,serializeError as t}from"../../../core/dist/index.js";import{changelog as n,encode as r,envInfo as i,httpRequest as a,measure as o,regexTest as s,schemaValidate as c,snippet as l,timeUtils as u,webSearch as d}from"../../../tools/dist/index.js";import{z as f}from"zod";const p=e(`tools`);function m(e){e.registerTool(`web_search`,{description:`PREFERRED web search search the web via DuckDuckGo (no API key). Returns structured results with title, URL, and snippet.`,inputSchema:{query:f.string().max(2e3).describe(`Search query`),limit:f.number().min(1).max(20).default(5).describe(`Max results to return`),site:f.string().optional().describe(`Restrict to domain (e.g., "docs.aws.amazon.com")`)}},async({query:e,limit:n,site:r})=>{try{let t=await d({query:e,limit:n,site:r}),i=[`## Search: ${t.query}`,``];if(t.results.length===0)i.push(`No results found.`);else for(let e of t.results)i.push(`### [${e.title}](${e.url})`,e.snippet,``);return i.push(`---`,"_Next: Use `web_fetch` to read any of these pages in full._"),{content:[{type:`text`,text:i.join(`
2
+ `)}]}}catch(e){return p.error(`Web search failed`,t(e)),{content:[{type:`text`,text:`Web search failed. Check server logs for details.`}],isError:!0}}})}function h(e){e.registerTool(`http`,{description:`Make HTTP requests (GET/POST/PUT/PATCH/DELETE/HEAD) for API testing. Returns status, headers, and formatted body with timing info.`,inputSchema:{url:f.string().url().describe(`Request URL (http/https only)`),method:f.enum([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`]).default(`GET`).describe(`HTTP method`),headers:f.record(f.string(),f.string()).optional().describe(`Request headers as key-value pairs`),body:f.string().optional().describe(`Request body (for POST/PUT/PATCH)`),timeout:f.number().min(1e3).max(6e4).default(15e3).describe(`Timeout in milliseconds`)}},async({url:e,method:n,headers:r,body:i,timeout:o})=>{try{let t=await a({url:e,method:n,headers:r,body:i,timeout:o}),s=[`## ${n} ${e}`,``,`**Status:** ${t.status} ${t.statusText}`,`**Time:** ${t.durationMs}ms`,`**Size:** ${t.sizeBytes} bytes`,`**Content-Type:** ${t.contentType}`,``,`### Headers`,"```json",JSON.stringify(t.headers,null,2),"```",``,`### Body`,t.contentType.includes(`json`)?"```json":"```",t.body,"```"];return t.truncated&&s.push(``,`_Response truncated total size: ${t.sizeBytes} bytes_`),{content:[{type:`text`,text:s.join(`
3
+ `)}]}}catch(e){return p.error(`HTTP request failed`,t(e)),{content:[{type:`text`,text:`HTTP request failed. Check server logs for details.`}],isError:!0}}})}function g(e){e.registerTool(`regex_test`,{description:`Test a regex pattern against sample strings. Supports match, replace, and split modes.`,inputSchema:{pattern:f.string().max(500).describe(`Regex pattern (without delimiters)`),flags:f.string().max(10).regex(/^[gimsuy]*$/).default(``).describe(`Regex flags (g, i, m, s, etc.)`),test_strings:f.array(f.string().max(1e4)).max(50).describe(`Strings to test the pattern against`),mode:f.enum([`match`,`replace`,`split`]).default(`match`).describe(`Test mode`),replacement:f.string().optional().describe(`Replacement string (for replace mode)`)}},async({pattern:e,flags:t,test_strings:n,mode:r,replacement:i})=>{let a=s({pattern:e,flags:t,testStrings:n,mode:r,replacement:i});if(!a.valid)return{content:[{type:`text`,text:`Invalid regex: ${a.error}`}],isError:!0};let o=[`## Regex: \`/${a.pattern}/${a.flags}\``,``,`Mode: ${r}`,``];for(let e of a.results){if(o.push(`**Input:** \`${e.input}\``),o.push(`**Matched:** ${e.matched}`),e.matches)for(let t of e.matches){let e=t.groups.length>0?` groups: [${t.groups.join(`, `)}]`:``;o.push(` - "${t.full}" at index ${t.index}${e}`)}e.replaced!==void 0&&o.push(`**Result:** \`${e.replaced}\``),e.split&&o.push(`**Split:** ${JSON.stringify(e.split)}`),o.push(``)}return{content:[{type:`text`,text:o.join(`
4
+ `)}]}})}function _(e){e.registerTool(`encode`,{description:`Encode, decode, or hash text. Supports base64, URL encoding, SHA-256, MD5, JWT decode, hex.`,inputSchema:{operation:f.enum([`base64_encode`,`base64_decode`,`url_encode`,`url_decode`,`sha256`,`md5`,`jwt_decode`,`hex_encode`,`hex_decode`]).describe(`Operation to perform`),input:f.string().max(1e6).describe(`Input text`)}},async({operation:e,input:n})=>{try{let t=r({operation:e,input:n});return{content:[{type:`text`,text:`## ${e}\n\n**Input:** \`${n.length>100?`${n.slice(0,100)}...`:n}\`\n**Output:**\n\`\`\`\n${t.output}\n\`\`\``}]}}catch(e){return p.error(`Encode failed`,t(e)),{content:[{type:`text`,text:`Encode failed. Check server logs for details.`}],isError:!0}}})}function v(e){e.registerTool(`measure`,{description:`Measure code complexity, line counts, and function counts for a file or directory. Returns per-file metrics sorted by complexity.`,inputSchema:{path:f.string().describe(`File or directory path to measure`),extensions:f.array(f.string()).optional().describe(`File extensions to include (default: .ts,.tsx,.js,.jsx)`)}},async({path:e,extensions:n})=>{try{let t=await o({path:e,extensions:n}),r=[`## Code Metrics`,``,`**Files:** ${t.summary.totalFiles}`,`**Total lines:** ${t.summary.totalLines} (${t.summary.totalCodeLines} code)`,`**Functions:** ${t.summary.totalFunctions}`,`**Avg complexity:** ${t.summary.avgComplexity}`,`**Max complexity:** ${t.summary.maxComplexity.value} (${t.summary.maxComplexity.file})`,``,`### Top files by complexity`,``,`| File | Lines | Code | Complexity | Cognitive | Functions | Imports |`,`|------|-------|------|------------|-----------|-----------|---------|`];for(let e of t.files.slice(0,20)){let t=e.cognitiveComplexity===void 0?`—`:String(e.cognitiveComplexity);r.push(`| ${e.path} | ${e.lines.total} | ${e.lines.code} | ${e.complexity} | ${t} | ${e.functions} | ${e.imports} |`)}return t.files.length>20&&r.push(``,`_...and ${t.files.length-20} more files_`),{content:[{type:`text`,text:r.join(`
5
+ `)}]}}catch(e){return p.error(`Measure failed`,t(e)),{content:[{type:`text`,text:`Measure failed. Check server logs for details.`}],isError:!0}}})}function y(e){e.registerTool(`changelog`,{description:`Generate a changelog from git history between two refs. Groups by conventional commit type.`,inputSchema:{from:f.string().max(200).describe(`Start ref (tag, SHA, HEAD~N)`),to:f.string().max(200).default(`HEAD`).describe(`End ref (default: HEAD)`),format:f.enum([`grouped`,`chronological`,`per-scope`]).default(`grouped`).describe(`Output format`),include_breaking:f.boolean().default(!0).describe(`Highlight breaking changes`)}},async({from:e,to:r,format:i,include_breaking:a})=>{try{let t=n({from:e,to:r,format:i,includeBreaking:a}),o=`${t.stats.total} commits (${Object.entries(t.stats.types).map(([e,t])=>`${t} ${e}`).join(`, `)})`;return{content:[{type:`text`,text:`${t.markdown}\n---\n_${o}_`}]}}catch(e){return p.error(`Changelog failed`,t(e)),{content:[{type:`text`,text:`Changelog failed. Check server logs for details.`}],isError:!0}}})}function b(e){e.registerTool(`schema_validate`,{description:`Validate JSON data against a JSON Schema. Supports type, required, properties, items, enum, pattern, min/max.`,inputSchema:{data:f.string().max(5e5).describe(`JSON data to validate (as string)`),schema:f.string().max(5e5).describe(`JSON Schema to validate against (as string)`)}},async({data:e,schema:n})=>{try{let t=c({data:JSON.parse(e),schema:JSON.parse(n)});if(t.valid)return{content:[{type:`text`,text:`## Validation: PASSED
5
6
 
6
- **Input:** \`${i.length>100?`${i.slice(0,100)}...`:i}\`
7
- **Output:**
8
- \`\`\`
9
- ${r.output}
10
- \`\`\``}]}}catch(r){return{content:[{type:"text",text:`Encode failed: ${r.message}`}],isError:!0}}})}function O(c){c.registerTool("measure",{description:"Measure code complexity, line counts, and function counts for a file or directory. Returns per-file metrics sorted by complexity.",inputSchema:{path:e.string().describe("File or directory path to measure"),extensions:e.array(e.string()).optional().describe("File extensions to include (default: .ts,.tsx,.js,.jsx)")}},async({path:a,extensions:i})=>{try{const r=x({path:a,extensions:i}),s=["## Code Metrics","",`**Files:** ${r.summary.totalFiles}`,`**Total lines:** ${r.summary.totalLines} (${r.summary.totalCodeLines} code)`,`**Functions:** ${r.summary.totalFunctions}`,`**Avg complexity:** ${r.summary.avgComplexity}`,`**Max complexity:** ${r.summary.maxComplexity.value} (${r.summary.maxComplexity.file})`,"","### Top files by complexity","","| File | Lines | Code | Complexity | Functions | Imports |","|------|-------|------|------------|-----------|---------|"];for(const t of r.files.slice(0,20))s.push(`| ${t.path} | ${t.lines.total} | ${t.lines.code} | ${t.complexity} | ${t.functions} | ${t.imports} |`);return r.files.length>20&&s.push("",`_...and ${r.files.length-20} more files_`),{content:[{type:"text",text:s.join(`
11
- `)}]}}catch(r){return{content:[{type:"text",text:`Measure failed: ${r.message}`}],isError:!0}}})}function P(c){c.registerTool("changelog",{description:"Generate a changelog from git history between two refs. Groups by conventional commit type.",inputSchema:{from:e.string().describe("Start ref (tag, SHA, HEAD~N)"),to:e.string().default("HEAD").describe("End ref (default: HEAD)"),format:e.enum(["grouped","chronological","per-scope"]).default("grouped").describe("Output format"),include_breaking:e.boolean().default(!0).describe("Highlight breaking changes")}},async({from:a,to:i,format:r,include_breaking:s})=>{try{const t=g({from:a,to:i,format:r,includeBreaking:s}),n=`${t.stats.total} commits (${Object.entries(t.stats.types).map(([o,d])=>`${d} ${o}`).join(", ")})`;return{content:[{type:"text",text:`${t.markdown}
12
- ---
13
- _${n}_`}]}}catch(t){return{content:[{type:"text",text:`Changelog failed: ${t.message}`}],isError:!0}}})}function D(c){c.registerTool("schema_validate",{description:"Validate JSON data against a JSON Schema. Supports type, required, properties, items, enum, pattern, min/max.",inputSchema:{data:e.string().describe("JSON data to validate (as string)"),schema:e.string().describe("JSON Schema to validate against (as string)")}},async({data:a,schema:i})=>{try{const r=JSON.parse(a),s=JSON.parse(i),t=b({data:r,schema:s});if(t.valid)return{content:[{type:"text",text:`## Validation: PASSED
14
-
15
- Data matches the schema.`}]};const n=["## Validation: FAILED","",`**${t.errors.length} error(s):**`,""];for(const o of t.errors){const d=o.expected?` (expected: ${o.expected}, got: ${o.received})`:"";n.push(`- \`${o.path}\`: ${o.message}${d}`)}return{content:[{type:"text",text:n.join(`
16
- `)}]}}catch(r){return{content:[{type:"text",text:`Schema validation failed: ${r.message}`}],isError:!0}}})}function k(c){c.registerTool("snippet",{description:"Save, retrieve, search, and manage persistent code snippets/templates.",inputSchema:{action:e.enum(["save","get","list","search","delete"]).describe("Operation to perform"),name:e.string().optional().describe("Snippet name (required for save/get/delete)"),language:e.string().optional().describe("Language tag (for save)"),code:e.string().optional().describe("Code content (for save)"),tags:e.array(e.string()).optional().describe("Tags for categorization (for save)"),query:e.string().optional().describe("Search query (for search)")}},async({action:a,name:i,language:r,code:s,tags:t,query:n})=>{try{const o=S({action:a,name:i,language:r,code:s,tags:t,query:n});if("deleted"in o)return{content:[{type:"text",text:o.deleted?`Snippet "${i}" deleted.`:`Snippet "${i}" not found.`}]};if("snippets"in o){if(o.snippets.length===0)return{content:[{type:"text",text:"No snippets found."}]};const l=["## Snippets",""];for(const u of o.snippets){const m=u.tags.length>0?` [${u.tags.join(", ")}]`:"";l.push(`- **${u.name}** (${u.language})${m}`)}return{content:[{type:"text",text:l.join(`
17
- `)}]}}const d=o,p=d.tags.length>0?`
18
- Tags: ${d.tags.join(", ")}`:"";return{content:[{type:"text",text:`## ${d.name} (${d.language})${p}
19
-
20
- \`\`\`${d.language}
21
- ${d.code}
22
- \`\`\``}]}}catch(o){return{content:[{type:"text",text:`Snippet failed: ${o.message}`}],isError:!0}}})}function A(c){c.registerTool("env",{description:"Get system and runtime environment info. Sensitive env vars are redacted by default.",inputSchema:{include_env:e.boolean().default(!1).describe("Include environment variables"),filter_env:e.string().optional().describe("Filter env vars by name substring"),show_sensitive:e.boolean().default(!1).describe("Show sensitive values (keys, tokens, etc.) \u2014 redacted by default")}},async({include_env:a,filter_env:i,show_sensitive:r})=>{const s=h({includeEnv:a,filterEnv:i,showSensitive:r}),t=["## Environment","",`**Platform:** ${s.system.platform} ${s.system.arch}`,`**OS:** ${s.system.type} ${s.system.release}`,`**Host:** ${s.system.hostname}`,`**CPUs:** ${s.system.cpus}`,`**Memory:** ${s.system.memoryFreeGb}GB free / ${s.system.memoryTotalGb}GB total`,"",`**Node:** ${s.runtime.node}`,`**V8:** ${s.runtime.v8}`,`**CWD:** ${s.cwd}`];if(s.env){t.push("","### Environment Variables","");for(const[n,o]of Object.entries(s.env))t.push(`- \`${n}\`: ${o}`)}return{content:[{type:"text",text:t.join(`
23
- `)}]}})}function H(c){c.registerTool("time",{description:"Parse dates, convert timezones, calculate durations, add time. Supports ISO 8601, unix timestamps, and human-readable formats.",inputSchema:{operation:e.enum(["now","parse","convert","diff","add"]).describe("now: current time | parse: parse a date string | convert: timezone conversion | diff: duration between two dates | add: add duration to date"),input:e.string().optional().describe("Date input (ISO, unix timestamp, or parseable string). For diff: two comma-separated dates"),timezone:e.string().optional().describe('Target timezone (e.g., "America/New_York", "Asia/Tokyo")'),duration:e.string().optional().describe('Duration to add (e.g., "2h30m", "1d", "30s") \u2014 for add operation')}},async({operation:a,input:i,timezone:r,duration:s})=>{try{const t=v({operation:a,input:i,timezone:r,duration:s}),n=[`**${t.output}**`,"",`ISO: ${t.iso}`,`Unix: ${t.unix}`];return t.details&&n.push("","```json",JSON.stringify(t.details,null,2),"```"),{content:[{type:"text",text:n.join(`
24
- `)}]}}catch(t){return{content:[{type:"text",text:`Time failed: ${t.message}`}],isError:!0}}})}export{P as registerChangelogTool,j as registerEncodeTool,A as registerEnvTool,M as registerHttpTool,O as registerMeasureTool,R as registerRegexTestTool,D as registerSchemaValidateTool,k as registerSnippetTool,H as registerTimeTool,_ as registerWebSearchTool};
7
+ Data matches the schema.`}]};let r=[`## Validation: FAILED`,``,`**${t.errors.length} error(s):**`,``];for(let e of t.errors){let t=e.expected?` (expected: ${e.expected}, got: ${e.received})`:``;r.push(`- \`${e.path}\`: ${e.message}${t}`)}return{content:[{type:`text`,text:r.join(`
8
+ `)}]}}catch(e){return p.error(`Schema validation failed`,t(e)),{content:[{type:`text`,text:`Schema validation failed. Check server logs for details.`}],isError:!0}}})}function x(e){e.registerTool(`snippet`,{description:`Save, retrieve, search, and manage persistent code snippets/templates.`,inputSchema:{action:f.enum([`save`,`get`,`list`,`search`,`delete`]).describe(`Operation to perform`),name:f.string().optional().describe(`Snippet name (required for save/get/delete)`),language:f.string().optional().describe(`Language tag (for save)`),code:f.string().max(1e5).optional().describe(`Code content (for save)`),tags:f.array(f.string()).optional().describe(`Tags for categorization (for save)`),query:f.string().optional().describe(`Search query (for search)`)}},async({action:e,name:n,language:r,code:i,tags:a,query:o})=>{try{let t=l({action:e,name:n,language:r,code:i,tags:a,query:o});if(`deleted`in t)return{content:[{type:`text`,text:t.deleted?`Snippet "${n}" deleted.`:`Snippet "${n}" not found.`}]};if(`snippets`in t){if(t.snippets.length===0)return{content:[{type:`text`,text:`No snippets found.`}]};let e=[`## Snippets`,``];for(let n of t.snippets){let t=n.tags.length>0?` [${n.tags.join(`, `)}]`:``;e.push(`- **${n.name}** (${n.language})${t}`)}return{content:[{type:`text`,text:e.join(`
9
+ `)}]}}let s=t,c=s.tags.length>0?`\nTags: ${s.tags.join(`, `)}`:``;return{content:[{type:`text`,text:`## ${s.name} (${s.language})${c}\n\n\`\`\`${s.language}\n${s.code}\n\`\`\``}]}}catch(e){return p.error(`Snippet failed`,t(e)),{content:[{type:`text`,text:`Snippet failed. Check server logs for details.`}],isError:!0}}})}function S(e){e.registerTool(`env`,{description:`Get system and runtime environment info. Sensitive env vars are redacted by default.`,inputSchema:{include_env:f.boolean().default(!1).describe(`Include environment variables`),filter_env:f.string().optional().describe(`Filter env vars by name substring`),show_sensitive:f.boolean().default(!1).describe(`Show sensitive values (keys, tokens, etc.) — redacted by default`)}},async({include_env:e,filter_env:t,show_sensitive:n})=>{let r=i({includeEnv:e,filterEnv:t,showSensitive:n}),a=[`## Environment`,``,`**Platform:** ${r.system.platform} ${r.system.arch}`,`**OS:** ${r.system.type} ${r.system.release}`,`**Host:** ${r.system.hostname}`,`**CPUs:** ${r.system.cpus}`,`**Memory:** ${r.system.memoryFreeGb}GB free / ${r.system.memoryTotalGb}GB total`,``,`**Node:** ${r.runtime.node}`,`**V8:** ${r.runtime.v8}`,`**CWD:** ${r.cwd}`];if(r.env){a.push(``,`### Environment Variables`,``);for(let[e,t]of Object.entries(r.env))a.push(`- \`${e}\`: ${t}`)}return{content:[{type:`text`,text:a.join(`
10
+ `)}]}})}function C(e){e.registerTool(`time`,{description:`Parse dates, convert timezones, calculate durations, add time. Supports ISO 8601, unix timestamps, and human-readable formats.`,inputSchema:{operation:f.enum([`now`,`parse`,`convert`,`diff`,`add`]).describe(`now: current time | parse: parse a date string | convert: timezone conversion | diff: duration between two dates | add: add duration to date`),input:f.string().optional().describe(`Date input (ISO, unix timestamp, or parseable string). For diff: two comma-separated dates`),timezone:f.string().optional().describe(`Target timezone (e.g., "America/New_York", "Asia/Tokyo")`),duration:f.string().optional().describe(`Duration to add (e.g., "2h30m", "1d", "30s") — for add operation`)}},async({operation:e,input:n,timezone:r,duration:i})=>{try{let t=u({operation:e,input:n,timezone:r,duration:i}),a=[`**${t.output}**`,``,`ISO: ${t.iso}`,`Unix: ${t.unix}`];return t.details&&a.push(``,"```json",JSON.stringify(t.details,null,2),"```"),{content:[{type:`text`,text:a.join(`
11
+ `)}]}}catch(e){return p.error(`Time failed`,t(e)),{content:[{type:`text`,text:`Time failed. Check server logs for details.`}],isError:!0}}})}export{y as registerChangelogTool,_ as registerEncodeTool,S as registerEnvTool,h as registerHttpTool,v as registerMeasureTool,g as registerRegexTestTool,b as registerSchemaValidateTool,x as registerSnippetTool,C as registerTimeTool,m as registerWebSearchTool};
@@ -1,10 +1,13 @@
1
+ //#region packages/server/src/version-check.d.ts
1
2
  /**
2
3
  * Non-blocking check for newer @vpxa/kb versions on npm.
3
4
  * Logs a warning to stderr if the running version is outdated.
4
5
  */
6
+ declare function getCurrentVersion(): string;
5
7
  /**
6
8
  * Check for a newer version on npm and log a warning if outdated.
7
9
  * This is fire-and-forget — it never throws and never blocks startup.
8
10
  */
9
- export declare function checkForUpdates(): void;
10
- //# sourceMappingURL=version-check.d.ts.map
11
+ declare function checkForUpdates(): void;
12
+ //#endregion
13
+ export { checkForUpdates, getCurrentVersion };
@@ -1 +1 @@
1
- import{readFileSync as s}from"node:fs";import{dirname as c,resolve as p}from"node:path";import{fileURLToPath as a}from"node:url";const u="@vpxa/kb",m=`https://registry.npmjs.org/${u}/latest`;function f(){const n=c(a(import.meta.url)),r=p(n,"..","..","..","package.json");try{return JSON.parse(s(r,"utf-8")).version??"0.0.0"}catch{return"0.0.0"}}function l(n,r){const t=n.split(".").map(Number),i=r.split(".").map(Number);for(let e=0;e<3;e++){const o=(t[e]??0)-(i[e]??0);if(o!==0)return o>0?1:-1}return 0}function h(){const n=f();fetch(m,{signal:AbortSignal.timeout(5e3)}).then(r=>{if(r.ok)return r.json()}).then(r=>{if(!r||typeof r!="object")return;const t=r.version;t&&l(n,t)<0&&console.error(`[KB] \u26A0 Update available: ${n} \u2192 ${t}. Run \`npx @vpxa/kb@${t} serve\` or update your mcp.json.`)}).catch(()=>{})}export{h as checkForUpdates};
1
+ import{readFileSync as e}from"node:fs";import{dirname as t,resolve as n}from"node:path";import{fileURLToPath as r}from"node:url";import{createLogger as i}from"../../core/dist/index.js";const a=i(`server`);function o(){let i=n(t(r(import.meta.url)),`..`,`..`,`..`,`package.json`);try{return JSON.parse(e(i,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}}function s(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t>0?1:-1}return 0}function c(){let e=o();fetch(`https://registry.npmjs.org/@vpxa/kb/latest`,{signal:AbortSignal.timeout(5e3)}).then(e=>{if(e.ok)return e.json()}).then(t=>{if(!t||typeof t!=`object`)return;let n=t.version;n&&s(e,n)<0&&a.warn(`Update available`,{currentVersion:e,latestVersion:n,updateCommand:`npx @vpxa/kb@${n} serve`,configHint:`update your mcp.json`})}).catch(()=>{})}export{c as checkForUpdates,o as getCurrentVersion};