@vybestack/llxprt-code-tools 0.10.0-nightly.260613.1adad3b34

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 (364) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +294 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.d.ts +29 -0
  8. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js +30 -0
  9. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js.map +1 -0
  10. package/dist/src/__tests__/fixtures/key-storage-fixtures.d.ts +39 -0
  11. package/dist/src/__tests__/fixtures/key-storage-fixtures.js +53 -0
  12. package/dist/src/__tests__/fixtures/key-storage-fixtures.js.map +1 -0
  13. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.d.ts +140 -0
  14. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js +157 -0
  15. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js.map +1 -0
  16. package/dist/src/__tests__/red-test-helpers.d.ts +14 -0
  17. package/dist/src/__tests__/red-test-helpers.js +18 -0
  18. package/dist/src/__tests__/red-test-helpers.js.map +1 -0
  19. package/dist/src/formatters/IToolFormatter.d.ts +84 -0
  20. package/dist/src/formatters/IToolFormatter.js +6 -0
  21. package/dist/src/formatters/IToolFormatter.js.map +1 -0
  22. package/dist/src/formatters/ToolFormatter.d.ts +94 -0
  23. package/dist/src/formatters/ToolFormatter.js +379 -0
  24. package/dist/src/formatters/ToolFormatter.js.map +1 -0
  25. package/dist/src/formatters/ToolIdStrategy.d.ts +79 -0
  26. package/dist/src/formatters/ToolIdStrategy.js +173 -0
  27. package/dist/src/formatters/ToolIdStrategy.js.map +1 -0
  28. package/dist/src/formatters/doubleEscapeUtils.d.ts +46 -0
  29. package/dist/src/formatters/doubleEscapeUtils.js +223 -0
  30. package/dist/src/formatters/doubleEscapeUtils.js.map +1 -0
  31. package/dist/src/formatters/index.d.ts +21 -0
  32. package/dist/src/formatters/index.js +12 -0
  33. package/dist/src/formatters/index.js.map +1 -0
  34. package/dist/src/formatters/toolIdNormalization.d.ts +28 -0
  35. package/dist/src/formatters/toolIdNormalization.js +97 -0
  36. package/dist/src/formatters/toolIdNormalization.js.map +1 -0
  37. package/dist/src/formatters/toolNameUtils.d.ts +43 -0
  38. package/dist/src/formatters/toolNameUtils.js +143 -0
  39. package/dist/src/formatters/toolNameUtils.js.map +1 -0
  40. package/dist/src/index.d.ts +88 -0
  41. package/dist/src/index.js +68 -0
  42. package/dist/src/index.js.map +1 -0
  43. package/dist/src/interfaces/IAsyncTaskService.d.ts +57 -0
  44. package/dist/src/interfaces/IAsyncTaskService.js +6 -0
  45. package/dist/src/interfaces/IAsyncTaskService.js.map +1 -0
  46. package/dist/src/interfaces/IIdeService.d.ts +62 -0
  47. package/dist/src/interfaces/IIdeService.js +6 -0
  48. package/dist/src/interfaces/IIdeService.js.map +1 -0
  49. package/dist/src/interfaces/ILspService.d.ts +54 -0
  50. package/dist/src/interfaces/ILspService.js +6 -0
  51. package/dist/src/interfaces/ILspService.js.map +1 -0
  52. package/dist/src/interfaces/IMcpToolService.d.ts +47 -0
  53. package/dist/src/interfaces/IMcpToolService.js +6 -0
  54. package/dist/src/interfaces/IMcpToolService.js.map +1 -0
  55. package/dist/src/interfaces/IPromptRegistryService.d.ts +51 -0
  56. package/dist/src/interfaces/IPromptRegistryService.js +6 -0
  57. package/dist/src/interfaces/IPromptRegistryService.js.map +1 -0
  58. package/dist/src/interfaces/ISettingsService.d.ts +50 -0
  59. package/dist/src/interfaces/ISettingsService.js +6 -0
  60. package/dist/src/interfaces/ISettingsService.js.map +1 -0
  61. package/dist/src/interfaces/IShellExecutionService.d.ts +55 -0
  62. package/dist/src/interfaces/IShellExecutionService.js +6 -0
  63. package/dist/src/interfaces/IShellExecutionService.js.map +1 -0
  64. package/dist/src/interfaces/IShellToolHost.d.ts +176 -0
  65. package/dist/src/interfaces/IShellToolHost.js +6 -0
  66. package/dist/src/interfaces/IShellToolHost.js.map +1 -0
  67. package/dist/src/interfaces/ISkillService.d.ts +69 -0
  68. package/dist/src/interfaces/ISkillService.js +6 -0
  69. package/dist/src/interfaces/ISkillService.js.map +1 -0
  70. package/dist/src/interfaces/IStorageService.d.ts +42 -0
  71. package/dist/src/interfaces/IStorageService.js +6 -0
  72. package/dist/src/interfaces/IStorageService.js.map +1 -0
  73. package/dist/src/interfaces/ISubagentService.d.ts +112 -0
  74. package/dist/src/interfaces/ISubagentService.js +6 -0
  75. package/dist/src/interfaces/ISubagentService.js.map +1 -0
  76. package/dist/src/interfaces/ITaskToolHost.d.ts +185 -0
  77. package/dist/src/interfaces/ITaskToolHost.js +6 -0
  78. package/dist/src/interfaces/ITaskToolHost.js.map +1 -0
  79. package/dist/src/interfaces/ITodoService.d.ts +79 -0
  80. package/dist/src/interfaces/ITodoService.js +6 -0
  81. package/dist/src/interfaces/ITodoService.js.map +1 -0
  82. package/dist/src/interfaces/IToolHost.d.ts +91 -0
  83. package/dist/src/interfaces/IToolHost.js +6 -0
  84. package/dist/src/interfaces/IToolHost.js.map +1 -0
  85. package/dist/src/interfaces/IToolKeyStorage.d.ts +62 -0
  86. package/dist/src/interfaces/IToolKeyStorage.js +6 -0
  87. package/dist/src/interfaces/IToolKeyStorage.js.map +1 -0
  88. package/dist/src/interfaces/IToolMessageBus.d.ts +63 -0
  89. package/dist/src/interfaces/IToolMessageBus.js +6 -0
  90. package/dist/src/interfaces/IToolMessageBus.js.map +1 -0
  91. package/dist/src/interfaces/IToolRegistryHost.d.ts +43 -0
  92. package/dist/src/interfaces/IToolRegistryHost.js +6 -0
  93. package/dist/src/interfaces/IToolRegistryHost.js.map +1 -0
  94. package/dist/src/interfaces/IWebSearchService.d.ts +16 -0
  95. package/dist/src/interfaces/IWebSearchService.js +7 -0
  96. package/dist/src/interfaces/IWebSearchService.js.map +1 -0
  97. package/dist/src/interfaces/index.d.ts +33 -0
  98. package/dist/src/interfaces/index.js +6 -0
  99. package/dist/src/interfaces/index.js.map +1 -0
  100. package/dist/src/tools/activate-skill.d.ts +26 -0
  101. package/dist/src/tools/activate-skill.js +121 -0
  102. package/dist/src/tools/activate-skill.js.map +1 -0
  103. package/dist/src/tools/apply-patch.d.ts +65 -0
  104. package/dist/src/tools/apply-patch.js +528 -0
  105. package/dist/src/tools/apply-patch.js.map +1 -0
  106. package/dist/src/tools/ast-edit/ast-config.d.ts +67 -0
  107. package/dist/src/tools/ast-edit/ast-config.js +72 -0
  108. package/dist/src/tools/ast-edit/ast-config.js.map +1 -0
  109. package/dist/src/tools/ast-edit/ast-edit-invocation.d.ts +40 -0
  110. package/dist/src/tools/ast-edit/ast-edit-invocation.js +410 -0
  111. package/dist/src/tools/ast-edit/ast-edit-invocation.js.map +1 -0
  112. package/dist/src/tools/ast-edit/ast-query-extractor.d.ts +21 -0
  113. package/dist/src/tools/ast-edit/ast-query-extractor.js +178 -0
  114. package/dist/src/tools/ast-edit/ast-query-extractor.js.map +1 -0
  115. package/dist/src/tools/ast-edit/ast-read-file-invocation.d.ts +26 -0
  116. package/dist/src/tools/ast-edit/ast-read-file-invocation.js +149 -0
  117. package/dist/src/tools/ast-edit/ast-read-file-invocation.js.map +1 -0
  118. package/dist/src/tools/ast-edit/constants.d.ts +30 -0
  119. package/dist/src/tools/ast-edit/constants.js +36 -0
  120. package/dist/src/tools/ast-edit/constants.js.map +1 -0
  121. package/dist/src/tools/ast-edit/context-collector.d.ts +25 -0
  122. package/dist/src/tools/ast-edit/context-collector.js +115 -0
  123. package/dist/src/tools/ast-edit/context-collector.js.map +1 -0
  124. package/dist/src/tools/ast-edit/context-optimizer.d.ts +29 -0
  125. package/dist/src/tools/ast-edit/context-optimizer.js +86 -0
  126. package/dist/src/tools/ast-edit/context-optimizer.js.map +1 -0
  127. package/dist/src/tools/ast-edit/cross-file-analyzer.d.ts +41 -0
  128. package/dist/src/tools/ast-edit/cross-file-analyzer.js +294 -0
  129. package/dist/src/tools/ast-edit/cross-file-analyzer.js.map +1 -0
  130. package/dist/src/tools/ast-edit/edit-calculator.d.ts +71 -0
  131. package/dist/src/tools/ast-edit/edit-calculator.js +249 -0
  132. package/dist/src/tools/ast-edit/edit-calculator.js.map +1 -0
  133. package/dist/src/tools/ast-edit/edit-helpers.d.ts +22 -0
  134. package/dist/src/tools/ast-edit/edit-helpers.js +36 -0
  135. package/dist/src/tools/ast-edit/edit-helpers.js.map +1 -0
  136. package/dist/src/tools/ast-edit/language-analysis.d.ts +19 -0
  137. package/dist/src/tools/ast-edit/language-analysis.js +123 -0
  138. package/dist/src/tools/ast-edit/language-analysis.js.map +1 -0
  139. package/dist/src/tools/ast-edit/local-context-analyzer.d.ts +84 -0
  140. package/dist/src/tools/ast-edit/local-context-analyzer.js +267 -0
  141. package/dist/src/tools/ast-edit/local-context-analyzer.js.map +1 -0
  142. package/dist/src/tools/ast-edit/repository-context-provider.d.ts +22 -0
  143. package/dist/src/tools/ast-edit/repository-context-provider.js +139 -0
  144. package/dist/src/tools/ast-edit/repository-context-provider.js.map +1 -0
  145. package/dist/src/tools/ast-edit/types.d.ts +155 -0
  146. package/dist/src/tools/ast-edit/types.js +7 -0
  147. package/dist/src/tools/ast-edit/types.js.map +1 -0
  148. package/dist/src/tools/ast-edit/workspace-context-provider.d.ts +22 -0
  149. package/dist/src/tools/ast-edit/workspace-context-provider.js +39 -0
  150. package/dist/src/tools/ast-edit/workspace-context-provider.js.map +1 -0
  151. package/dist/src/tools/ast-edit.d.ts +43 -0
  152. package/dist/src/tools/ast-edit.js +183 -0
  153. package/dist/src/tools/ast-edit.js.map +1 -0
  154. package/dist/src/tools/ast-grep.d.ts +22 -0
  155. package/dist/src/tools/ast-grep.js +291 -0
  156. package/dist/src/tools/ast-grep.js.map +1 -0
  157. package/dist/src/tools/check-async-tasks.d.ts +46 -0
  158. package/dist/src/tools/check-async-tasks.js +241 -0
  159. package/dist/src/tools/check-async-tasks.js.map +1 -0
  160. package/dist/src/tools/codesearch.d.ts +25 -0
  161. package/dist/src/tools/codesearch.js +153 -0
  162. package/dist/src/tools/codesearch.js.map +1 -0
  163. package/dist/src/tools/delete_line_range.d.ts +41 -0
  164. package/dist/src/tools/delete_line_range.js +238 -0
  165. package/dist/src/tools/delete_line_range.js.map +1 -0
  166. package/dist/src/tools/direct-web-fetch.d.ts +22 -0
  167. package/dist/src/tools/direct-web-fetch.js +215 -0
  168. package/dist/src/tools/direct-web-fetch.js.map +1 -0
  169. package/dist/src/tools/edit-utils.d.ts +53 -0
  170. package/dist/src/tools/edit-utils.js +250 -0
  171. package/dist/src/tools/edit-utils.js.map +1 -0
  172. package/dist/src/tools/edit.d.ts +70 -0
  173. package/dist/src/tools/edit.js +816 -0
  174. package/dist/src/tools/edit.js.map +1 -0
  175. package/dist/src/tools/exa-web-search.d.ts +27 -0
  176. package/dist/src/tools/exa-web-search.js +153 -0
  177. package/dist/src/tools/exa-web-search.js.map +1 -0
  178. package/dist/src/tools/glob.d.ts +55 -0
  179. package/dist/src/tools/glob.js +284 -0
  180. package/dist/src/tools/glob.js.map +1 -0
  181. package/dist/src/tools/google-web-fetch.d.ts +34 -0
  182. package/dist/src/tools/google-web-fetch.js +417 -0
  183. package/dist/src/tools/google-web-fetch.js.map +1 -0
  184. package/dist/src/tools/google-web-search-invocation.d.ts +53 -0
  185. package/dist/src/tools/google-web-search-invocation.js +180 -0
  186. package/dist/src/tools/google-web-search-invocation.js.map +1 -0
  187. package/dist/src/tools/google-web-search.d.ts +16 -0
  188. package/dist/src/tools/google-web-search.js +34 -0
  189. package/dist/src/tools/google-web-search.js.map +1 -0
  190. package/dist/src/tools/grep.d.ts +56 -0
  191. package/dist/src/tools/grep.js +883 -0
  192. package/dist/src/tools/grep.js.map +1 -0
  193. package/dist/src/tools/insert_at_line.d.ts +41 -0
  194. package/dist/src/tools/insert_at_line.js +287 -0
  195. package/dist/src/tools/insert_at_line.js.map +1 -0
  196. package/dist/src/tools/list-subagents.d.ts +31 -0
  197. package/dist/src/tools/list-subagents.js +122 -0
  198. package/dist/src/tools/list-subagents.js.map +1 -0
  199. package/dist/src/tools/ls.d.ts +71 -0
  200. package/dist/src/tools/ls.js +238 -0
  201. package/dist/src/tools/ls.js.map +1 -0
  202. package/dist/src/tools/memoryTool.d.ts +66 -0
  203. package/dist/src/tools/memoryTool.js +435 -0
  204. package/dist/src/tools/memoryTool.js.map +1 -0
  205. package/dist/src/tools/modifiable-tool.d.ts +37 -0
  206. package/dist/src/tools/modifiable-tool.js +120 -0
  207. package/dist/src/tools/modifiable-tool.js.map +1 -0
  208. package/dist/src/tools/read-file.d.ts +49 -0
  209. package/dist/src/tools/read-file.js +279 -0
  210. package/dist/src/tools/read-file.js.map +1 -0
  211. package/dist/src/tools/read-many-files.d.ts +60 -0
  212. package/dist/src/tools/read-many-files.js +529 -0
  213. package/dist/src/tools/read-many-files.js.map +1 -0
  214. package/dist/src/tools/read_line_range.d.ts +47 -0
  215. package/dist/src/tools/read_line_range.js +248 -0
  216. package/dist/src/tools/read_line_range.js.map +1 -0
  217. package/dist/src/tools/ripGrep.d.ts +41 -0
  218. package/dist/src/tools/ripGrep.js +395 -0
  219. package/dist/src/tools/ripGrep.js.map +1 -0
  220. package/dist/src/tools/shell.d.ts +60 -0
  221. package/dist/src/tools/shell.js +735 -0
  222. package/dist/src/tools/shell.js.map +1 -0
  223. package/dist/src/tools/structural-analysis.d.ts +27 -0
  224. package/dist/src/tools/structural-analysis.js +1089 -0
  225. package/dist/src/tools/structural-analysis.js.map +1 -0
  226. package/dist/src/tools/stubs.d.ts +10 -0
  227. package/dist/src/tools/stubs.js +6 -0
  228. package/dist/src/tools/stubs.js.map +1 -0
  229. package/dist/src/tools/task.d.ts +41 -0
  230. package/dist/src/tools/task.js +195 -0
  231. package/dist/src/tools/task.js.map +1 -0
  232. package/dist/src/tools/todo-events.d.ts +22 -0
  233. package/dist/src/tools/todo-events.js +24 -0
  234. package/dist/src/tools/todo-events.js.map +1 -0
  235. package/dist/src/tools/todo-pause.d.ts +29 -0
  236. package/dist/src/tools/todo-pause.js +172 -0
  237. package/dist/src/tools/todo-pause.js.map +1 -0
  238. package/dist/src/tools/todo-read.d.ts +18 -0
  239. package/dist/src/tools/todo-read.js +98 -0
  240. package/dist/src/tools/todo-read.js.map +1 -0
  241. package/dist/src/tools/todo-store.d.ts +35 -0
  242. package/dist/src/tools/todo-store.js +124 -0
  243. package/dist/src/tools/todo-store.js.map +1 -0
  244. package/dist/src/tools/todo-write.d.ts +29 -0
  245. package/dist/src/tools/todo-write.js +366 -0
  246. package/dist/src/tools/todo-write.js.map +1 -0
  247. package/dist/src/tools/tool-registry.d.ts +156 -0
  248. package/dist/src/tools/tool-registry.js +623 -0
  249. package/dist/src/tools/tool-registry.js.map +1 -0
  250. package/dist/src/tools/tools.d.ts +403 -0
  251. package/dist/src/tools/tools.js +519 -0
  252. package/dist/src/tools/tools.js.map +1 -0
  253. package/dist/src/tools/write-file.d.ts +45 -0
  254. package/dist/src/tools/write-file.js +320 -0
  255. package/dist/src/tools/write-file.js.map +1 -0
  256. package/dist/src/types/index.d.ts +17 -0
  257. package/dist/src/types/index.js +9 -0
  258. package/dist/src/types/index.js.map +1 -0
  259. package/dist/src/types/provider-content-types.d.ts +56 -0
  260. package/dist/src/types/provider-content-types.js +6 -0
  261. package/dist/src/types/provider-content-types.js.map +1 -0
  262. package/dist/src/types/todo-schemas.d.ts +263 -0
  263. package/dist/src/types/todo-schemas.js +32 -0
  264. package/dist/src/types/todo-schemas.js.map +1 -0
  265. package/dist/src/types/tool-confirmation-types.d.ts +34 -0
  266. package/dist/src/types/tool-confirmation-types.js +29 -0
  267. package/dist/src/types/tool-confirmation-types.js.map +1 -0
  268. package/dist/src/types/tool-context.d.ts +31 -0
  269. package/dist/src/types/tool-context.js +6 -0
  270. package/dist/src/types/tool-context.js.map +1 -0
  271. package/dist/src/types/tool-error.d.ts +69 -0
  272. package/dist/src/types/tool-error.js +94 -0
  273. package/dist/src/types/tool-error.js.map +1 -0
  274. package/dist/src/types/tool-names.d.ts +57 -0
  275. package/dist/src/types/tool-names.js +64 -0
  276. package/dist/src/types/tool-names.js.map +1 -0
  277. package/dist/src/utils/EmojiFilter.d.ts +134 -0
  278. package/dist/src/utils/EmojiFilter.js +370 -0
  279. package/dist/src/utils/EmojiFilter.js.map +1 -0
  280. package/dist/src/utils/ast-grep-utils.d.ts +42 -0
  281. package/dist/src/utils/ast-grep-utils.js +140 -0
  282. package/dist/src/utils/ast-grep-utils.js.map +1 -0
  283. package/dist/src/utils/debugLogger.d.ts +11 -0
  284. package/dist/src/utils/debugLogger.js +16 -0
  285. package/dist/src/utils/debugLogger.js.map +1 -0
  286. package/dist/src/utils/diffOptions.d.ts +14 -0
  287. package/dist/src/utils/diffOptions.js +46 -0
  288. package/dist/src/utils/diffOptions.js.map +1 -0
  289. package/dist/src/utils/editor.d.ts +39 -0
  290. package/dist/src/utils/editor.js +212 -0
  291. package/dist/src/utils/editor.js.map +1 -0
  292. package/dist/src/utils/ensure-dirs.d.ts +10 -0
  293. package/dist/src/utils/ensure-dirs.js +16 -0
  294. package/dist/src/utils/ensure-dirs.js.map +1 -0
  295. package/dist/src/utils/errors.d.ts +59 -0
  296. package/dist/src/utils/errors.js +178 -0
  297. package/dist/src/utils/errors.js.map +1 -0
  298. package/dist/src/utils/fetch.d.ts +11 -0
  299. package/dist/src/utils/fetch.js +74 -0
  300. package/dist/src/utils/fetch.js.map +1 -0
  301. package/dist/src/utils/fileUtils.d.ts +32 -0
  302. package/dist/src/utils/fileUtils.js +363 -0
  303. package/dist/src/utils/fileUtils.js.map +1 -0
  304. package/dist/src/utils/fuzzy-replacer.d.ts +61 -0
  305. package/dist/src/utils/fuzzy-replacer.js +492 -0
  306. package/dist/src/utils/fuzzy-replacer.js.map +1 -0
  307. package/dist/src/utils/gitLineChanges.d.ts +12 -0
  308. package/dist/src/utils/gitLineChanges.js +171 -0
  309. package/dist/src/utils/gitLineChanges.js.map +1 -0
  310. package/dist/src/utils/gitUtils.d.ts +6 -0
  311. package/dist/src/utils/gitUtils.js +31 -0
  312. package/dist/src/utils/gitUtils.js.map +1 -0
  313. package/dist/src/utils/lsp-diagnostics-helper.d.ts +27 -0
  314. package/dist/src/utils/lsp-diagnostics-helper.js +62 -0
  315. package/dist/src/utils/lsp-diagnostics-helper.js.map +1 -0
  316. package/dist/src/utils/mediaUtils.d.ts +38 -0
  317. package/dist/src/utils/mediaUtils.js +22 -0
  318. package/dist/src/utils/mediaUtils.js.map +1 -0
  319. package/dist/src/utils/pathValidation.d.ts +7 -0
  320. package/dist/src/utils/pathValidation.js +39 -0
  321. package/dist/src/utils/pathValidation.js.map +1 -0
  322. package/dist/src/utils/paths.d.ts +7 -0
  323. package/dist/src/utils/paths.js +158 -0
  324. package/dist/src/utils/paths.js.map +1 -0
  325. package/dist/src/utils/resolveTextSearchTarget.d.ts +17 -0
  326. package/dist/src/utils/resolveTextSearchTarget.js +45 -0
  327. package/dist/src/utils/resolveTextSearchTarget.js.map +1 -0
  328. package/dist/src/utils/retry.d.ts +17 -0
  329. package/dist/src/utils/retry.js +185 -0
  330. package/dist/src/utils/retry.js.map +1 -0
  331. package/dist/src/utils/ripgrepPathResolver.d.ts +23 -0
  332. package/dist/src/utils/ripgrepPathResolver.js +179 -0
  333. package/dist/src/utils/ripgrepPathResolver.js.map +1 -0
  334. package/dist/src/utils/safeJsonStringify.d.ts +9 -0
  335. package/dist/src/utils/safeJsonStringify.js +21 -0
  336. package/dist/src/utils/safeJsonStringify.js.map +1 -0
  337. package/dist/src/utils/schemaValidator.d.ts +13 -0
  338. package/dist/src/utils/schemaValidator.js +275 -0
  339. package/dist/src/utils/schemaValidator.js.map +1 -0
  340. package/dist/src/utils/terminalSerializer.d.ts +33 -0
  341. package/dist/src/utils/terminalSerializer.js +6 -0
  342. package/dist/src/utils/terminalSerializer.js.map +1 -0
  343. package/dist/src/utils/todoContextTracker.d.ts +12 -0
  344. package/dist/src/utils/todoContextTracker.js +28 -0
  345. package/dist/src/utils/todoContextTracker.js.map +1 -0
  346. package/dist/src/utils/todoFormatter.d.ts +24 -0
  347. package/dist/src/utils/todoFormatter.js +157 -0
  348. package/dist/src/utils/todoFormatter.js.map +1 -0
  349. package/dist/src/utils/todoReminderService.d.ts +22 -0
  350. package/dist/src/utils/todoReminderService.js +43 -0
  351. package/dist/src/utils/todoReminderService.js.map +1 -0
  352. package/dist/src/utils/tool-key-storage-facade.d.ts +32 -0
  353. package/dist/src/utils/tool-key-storage-facade.js +56 -0
  354. package/dist/src/utils/tool-key-storage-facade.js.map +1 -0
  355. package/dist/src/utils/tool-key-storage-types.d.ts +56 -0
  356. package/dist/src/utils/tool-key-storage-types.js +56 -0
  357. package/dist/src/utils/tool-key-storage-types.js.map +1 -0
  358. package/dist/src/utils/toolOutputLimiter.d.ts +29 -0
  359. package/dist/src/utils/toolOutputLimiter.js +107 -0
  360. package/dist/src/utils/toolOutputLimiter.js.map +1 -0
  361. package/dist/src/utils/unicodeUtils.d.ts +55 -0
  362. package/dist/src/utils/unicodeUtils.js +129 -0
  363. package/dist/src/utils/unicodeUtils.js.map +1 -0
  364. package/package.json +75 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-context-provider.js","sourceRoot":"","sources":["../../../../src/tools/ast-edit/workspace-context-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,IAAI,CAAC;AAK5C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,cAAsB,EACtB,aAAqB,EACrB,YAAuC,EACvC,YAA+B;IAE/B,MAAM,cAAc,GAAoB,EAAE,CAAC;IAE3C,2CAA2C;IAC3C,yDAAyD;IACzD,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAE7E,0BAA0B;IAC1B,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAChC,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,mBAAmB,CACzD,QAAQ,EACR,WAAW,CACZ,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACpC,CAAC,CAAC,CACH,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Vybestack LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * ## Change Log
7
+ * - 2025-01-19: Performance Optimization (Phase 2)
8
+ * - Disabled eager symbol indexing by default (ENABLE_SYMBOL_INDEXING = false).
9
+ * - Implemented 'Lazy' on-demand `findInFiles` queries with strict limits.
10
+ * - Added `prioritizeSymbolsFromDeclarations` for smarter symbol selection.
11
+ * - Added timeout mechanism and `Promise.allSettled` for fault tolerance.
12
+ * - Added performance metrics logging (duration, memory delta).
13
+ * - Added env-based override: LLXPRT_ENABLE_SYMBOL_INDEXING.
14
+ * - Added MAX_WORKSPACE_FILES guard to prevent OOM in large repos.
15
+ */
16
+ import type { ToolInvocation } from './tools.js';
17
+ import { BaseDeclarativeTool, type ToolResult } from './tools.js';
18
+ import type { IToolHost, ILspService } from '../interfaces/index.js';
19
+ import type { ModifiableDeclarativeTool, ModifyContext } from './modifiable-tool.js';
20
+ import type { EnhancedDeclaration, ASTEditToolParams, ASTReadFileToolParams } from './ast-edit/types.js';
21
+ import { KEYWORDS, COMMENT_PREFIXES, REGEX, LANGUAGE_MAP, JAVASCRIPT_FAMILY_EXTENSIONS } from './ast-edit/constants.js';
22
+ import { applyReplacement } from './ast-edit/edit-helpers.js';
23
+ export type { EnhancedDeclaration, ASTEditToolParams, ASTReadFileToolParams };
24
+ export { KEYWORDS, COMMENT_PREFIXES, REGEX, LANGUAGE_MAP, JAVASCRIPT_FAMILY_EXTENSIONS, };
25
+ export declare class ASTEditTool extends BaseDeclarativeTool<ASTEditToolParams, ToolResult> implements ModifiableDeclarativeTool<ASTEditToolParams> {
26
+ private readonly host;
27
+ private readonly lspService?;
28
+ static readonly Name = "ast_edit";
29
+ private contextCollector;
30
+ static applyReplacement: typeof applyReplacement;
31
+ constructor(host: IToolHost, lspService?: ILspService | undefined);
32
+ protected validateToolParamValues(params: ASTEditToolParams): string | null;
33
+ protected createInvocation(params: ASTEditToolParams): ToolInvocation<ASTEditToolParams, ToolResult>;
34
+ getModifyContext(_: AbortSignal): ModifyContext<ASTEditToolParams>;
35
+ }
36
+ export declare class ASTReadFileTool extends BaseDeclarativeTool<ASTReadFileToolParams, ToolResult> {
37
+ private readonly host;
38
+ static readonly Name = "ast_read_file";
39
+ private contextCollector;
40
+ constructor(host: IToolHost);
41
+ protected validateToolParamValues(params: ASTReadFileToolParams): string | null;
42
+ protected createInvocation(params: ASTReadFileToolParams): ToolInvocation<ASTReadFileToolParams, ToolResult>;
43
+ }
@@ -0,0 +1,183 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Vybestack LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * ## Change Log
7
+ * - 2025-01-19: Performance Optimization (Phase 2)
8
+ * - Disabled eager symbol indexing by default (ENABLE_SYMBOL_INDEXING = false).
9
+ * - Implemented 'Lazy' on-demand `findInFiles` queries with strict limits.
10
+ * - Added `prioritizeSymbolsFromDeclarations` for smarter symbol selection.
11
+ * - Added timeout mechanism and `Promise.allSettled` for fault tolerance.
12
+ * - Added performance metrics logging (duration, memory delta).
13
+ * - Added env-based override: LLXPRT_ENABLE_SYMBOL_INDEXING.
14
+ * - Added MAX_WORKSPACE_FILES guard to prevent OOM in large repos.
15
+ */
16
+ import * as path from 'path';
17
+ import fs from 'fs';
18
+ import { BaseDeclarativeTool, Kind } from './tools.js';
19
+ import { isNodeError } from '../utils/errors.js';
20
+ import { KEYWORDS, COMMENT_PREFIXES, REGEX, LANGUAGE_MAP, JAVASCRIPT_FAMILY_EXTENSIONS, } from './ast-edit/constants.js';
21
+ import { ASTContextCollector } from './ast-edit/context-collector.js';
22
+ import { applyReplacement } from './ast-edit/edit-helpers.js';
23
+ import { ASTEditToolInvocation } from './ast-edit/ast-edit-invocation.js';
24
+ import { ASTReadFileToolInvocation } from './ast-edit/ast-read-file-invocation.js';
25
+ import { validatePathWithinWorkspace } from '../utils/pathValidation.js';
26
+ export { KEYWORDS, COMMENT_PREFIXES, REGEX, LANGUAGE_MAP, JAVASCRIPT_FAMILY_EXTENSIONS, };
27
+ /**
28
+ * Shared validation logic for file path parameters.
29
+ * Used by both ASTEditTool and ASTReadFileTool.
30
+ */
31
+ function validateFilePathParam(host, params) {
32
+ if (!params.file_path) {
33
+ return "The 'file_path' parameter must be non-empty.";
34
+ }
35
+ if (!path.isAbsolute(params.file_path)) {
36
+ return `File path must be absolute: ${params.file_path}`;
37
+ }
38
+ const pathError = validatePathWithinWorkspace(typeof host.getWorkspaceRoots === 'function'
39
+ ? host.getWorkspaceRoots()
40
+ : (host
41
+ .getWorkspaceContext?.()
42
+ .getDirectories?.() ?? [host.getTargetDir()]), params.file_path);
43
+ if (pathError) {
44
+ return pathError;
45
+ }
46
+ return null;
47
+ }
48
+ // ===== ASTEdit Tool Implementation =====
49
+ export class ASTEditTool extends BaseDeclarativeTool {
50
+ host;
51
+ lspService;
52
+ static Name = 'ast_edit';
53
+ contextCollector;
54
+ static applyReplacement = applyReplacement;
55
+ constructor(host, lspService) {
56
+ super(ASTEditTool.Name, 'ASTEdit', `Enhanced edit tool with intelligent context awareness. Performs precise text replacement with validation.
57
+
58
+ Replaces exact text matches in files with comprehensive analysis:
59
+ - AST syntax validation and structure analysis
60
+ - Context-aware suggestions and related code
61
+ - File freshness and safety checks
62
+ - Preview before applying changes
63
+
64
+ **Parameters:**
65
+ - file_path: Absolute path to the file to modify
66
+ - old_string: Text to replace (must match exactly)
67
+ - new_string: Replacement text`, Kind.Edit, {
68
+ properties: {
69
+ file_path: {
70
+ description: "The absolute path to the file to modify. Must start with '/'.",
71
+ type: 'string',
72
+ },
73
+ old_string: {
74
+ description: 'The exact literal text to replace. Must match existing content exactly including whitespace and indentation.',
75
+ type: 'string',
76
+ },
77
+ new_string: {
78
+ description: 'The exact literal text to replace old_string with. Provide the complete replacement text.',
79
+ type: 'string',
80
+ },
81
+ force: {
82
+ type: 'boolean',
83
+ description: 'Internal execution control. Managed automatically.',
84
+ default: false,
85
+ },
86
+ last_modified: {
87
+ type: 'number',
88
+ description: 'Timestamp of the file when last read. Used for concurrency control.',
89
+ },
90
+ },
91
+ required: ['file_path', 'old_string', 'new_string'],
92
+ type: 'object',
93
+ });
94
+ this.host = host;
95
+ this.lspService = lspService;
96
+ this.contextCollector = new ASTContextCollector();
97
+ }
98
+ validateToolParamValues(params) {
99
+ return validateFilePathParam(this.host, params);
100
+ }
101
+ createInvocation(params) {
102
+ return new ASTEditToolInvocation(this.host, params, this.contextCollector, this.lspService);
103
+ }
104
+ getModifyContext(_) {
105
+ return {
106
+ getFilePath: (params) => params.file_path,
107
+ getCurrentContent: async (params) => {
108
+ try {
109
+ return await fs.promises.readFile(params.file_path, 'utf-8');
110
+ }
111
+ catch (err) {
112
+ if (!isNodeError(err) || err.code !== 'ENOENT')
113
+ throw err;
114
+ return '';
115
+ }
116
+ },
117
+ getProposedContent: async (params) => {
118
+ try {
119
+ const currentContent = await fs.promises.readFile(params.file_path, 'utf-8');
120
+ return ASTEditTool.applyReplacement(currentContent, params.old_string, params.new_string, false);
121
+ }
122
+ catch (err) {
123
+ if (!isNodeError(err) || err.code !== 'ENOENT')
124
+ throw err;
125
+ return params.new_string;
126
+ }
127
+ },
128
+ createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => ({
129
+ ...originalParams,
130
+ old_string: oldContent,
131
+ new_string: modifiedProposedContent,
132
+ }),
133
+ };
134
+ }
135
+ }
136
+ // ===== ASTReadFile Tool Implementation =====
137
+ export class ASTReadFileTool extends BaseDeclarativeTool {
138
+ host;
139
+ static Name = 'ast_read_file';
140
+ contextCollector;
141
+ constructor(host) {
142
+ super(ASTReadFileTool.Name, 'ASTReadFile', `Enhanced file reading with AST-inspired context analysis. Reads file content with intelligent context extraction.
143
+
144
+ **Context-Aware Features:**
145
+ - Language detection and AST structure analysis
146
+ - Function/class/variable declaration extraction
147
+ - Relevant code snippet collection
148
+ - Language-specific context information
149
+
150
+ **Parameters:**
151
+ - file_path: Absolute path to the file to read
152
+ - offset: Line number to start reading from (optional)
153
+ - limit: Number of lines to read (optional)`, Kind.Read, {
154
+ properties: {
155
+ file_path: {
156
+ description: "The absolute path to the file to read. Must start with '/'.",
157
+ type: 'string',
158
+ },
159
+ offset: {
160
+ type: 'number',
161
+ description: 'The line number to start reading from (1-based, optional).',
162
+ minimum: 1,
163
+ },
164
+ limit: {
165
+ type: 'number',
166
+ description: 'The number of lines to read (optional).',
167
+ minimum: 1,
168
+ },
169
+ },
170
+ required: ['file_path'],
171
+ type: 'object',
172
+ });
173
+ this.host = host;
174
+ this.contextCollector = new ASTContextCollector();
175
+ }
176
+ validateToolParamValues(params) {
177
+ return validateFilePathParam(this.host, params);
178
+ }
179
+ createInvocation(params) {
180
+ return new ASTReadFileToolInvocation(this.host, params, this.contextCollector);
181
+ }
182
+ }
183
+ //# sourceMappingURL=ast-edit.js.map
@@ -0,0 +1 @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ST structure rather than text matching.
4
+ *
5
+ * @plan PLAN-20260211-ASTGREP.P05
6
+ */
7
+ import { BaseDeclarativeTool, type ToolInvocation, type ToolResult } from './tools.js';
8
+ import type { IToolHost, IToolMessageBus } from '../interfaces/index.js';
9
+ export interface AstGrepToolParams {
10
+ pattern?: string;
11
+ rule?: Record<string, unknown>;
12
+ language?: string;
13
+ path?: string;
14
+ globs?: string[];
15
+ maxResults?: number;
16
+ }
17
+ export declare class AstGrepTool extends BaseDeclarativeTool<AstGrepToolParams, ToolResult> {
18
+ private readonly host;
19
+ static readonly Name = "ast_grep";
20
+ constructor(host: IToolHost, _messageBus?: IToolMessageBus);
21
+ protected createInvocation(params: AstGrepToolParams, messageBus: IToolMessageBus): ToolInvocation<AstGrepToolParams, ToolResult>;
22
+ }
@@ -0,0 +1,291 @@
1
+ /**
2
+ * AST-aware structural code search tool using @ast-grep/napi.
3
+ * Finds code patterns by AST structure rather than text matching.
4
+ *
5
+ * @plan PLAN-20260211-ASTGREP.P05
6
+ */
7
+ /* eslint-disable complexity, sonarjs/cognitive-complexity, max-lines -- Phase 5: legacy core boundary retained while larger decomposition continues. */
8
+ import * as path from 'node:path';
9
+ import { promises as fs, statSync, existsSync } from 'node:fs';
10
+ import FastGlob from 'fast-glob';
11
+ import { BaseDeclarativeTool, BaseToolInvocation, Kind, } from './tools.js';
12
+ import { makeRelative } from '../utils/paths.js';
13
+ import { parse, getAstLanguage, resolveLanguageFromPath, LANGUAGE_MAP, } from '../utils/ast-grep-utils.js';
14
+ const DEFAULT_MAX_RESULTS = 100;
15
+ class AstGrepToolInvocation extends BaseToolInvocation {
16
+ host;
17
+ constructor(host, params, messageBus) {
18
+ super(params, messageBus);
19
+ this.host = host;
20
+ }
21
+ getDescription() {
22
+ const { pattern, rule } = this.params;
23
+ if (pattern)
24
+ return `AST pattern: '${pattern}'`;
25
+ if (rule)
26
+ return `AST rule query`;
27
+ return 'AST search';
28
+ }
29
+ makeError(message) {
30
+ return { llmContent: message, returnDisplay: message };
31
+ }
32
+ async execute(signal) {
33
+ const { pattern, rule, globs, maxResults } = this.params;
34
+ const limit = maxResults ?? DEFAULT_MAX_RESULTS;
35
+ const resolved = this.validateAndResolveParams();
36
+ if (resolved instanceof Object && 'llmContent' in resolved)
37
+ return resolved;
38
+ const { searchPath, isSingleFile, resolvedLang } = resolved;
39
+ try {
40
+ const { allMatches, skippedFiles } = await this.collectMatches(searchPath, isSingleFile, resolvedLang, pattern, rule, globs, signal);
41
+ return this.formatSearchResults(allMatches, skippedFiles, limit, pattern);
42
+ }
43
+ catch (err) {
44
+ const msg = err instanceof Error ? err.message : String(err);
45
+ return this.makeError(`Error searching: ${msg}`);
46
+ }
47
+ }
48
+ validateAndResolveParams() {
49
+ const { pattern, rule, language } = this.params;
50
+ // REQ-ASTGREP-004: exactly one of pattern or rule
51
+ if ((pattern && rule) || (!pattern && !rule)) {
52
+ return this.makeError('Error: Provide exactly one of `pattern` or `rule`, not both and not neither.');
53
+ }
54
+ const targetDir = this.host.getTargetDir();
55
+ let searchPath = this.params.path ?? targetDir;
56
+ if (!path.isAbsolute(searchPath)) {
57
+ searchPath = path.resolve(targetDir, searchPath);
58
+ }
59
+ // REQ-ASTGREP-006: workspace boundary
60
+ const normalizedTarget = targetDir.endsWith(path.sep)
61
+ ? targetDir
62
+ : targetDir + path.sep;
63
+ if (searchPath !== targetDir && !searchPath.startsWith(normalizedTarget)) {
64
+ return this.makeError(`Error: Path "${this.params.path}" resolves outside the workspace root.`);
65
+ }
66
+ let isSingleFile = false;
67
+ try {
68
+ const stats = statSync(searchPath);
69
+ isSingleFile = stats.isFile();
70
+ }
71
+ catch {
72
+ if (!existsSync(searchPath)) {
73
+ return this.makeError(`Error: Path does not exist: ${searchPath}`);
74
+ }
75
+ }
76
+ // REQ-ASTGREP-013: language detection
77
+ let resolvedLang;
78
+ if (language) {
79
+ resolvedLang = getAstLanguage(language);
80
+ if (!resolvedLang) {
81
+ return this.makeError(`Error: Unrecognized language "${language}". Supported: ${Object.keys(LANGUAGE_MAP).join(', ')}`);
82
+ }
83
+ }
84
+ else if (isSingleFile) {
85
+ resolvedLang = resolveLanguageFromPath(searchPath);
86
+ if (!resolvedLang) {
87
+ return this.makeError('Error: Could not detect language from file extension. Please provide a `language` parameter.');
88
+ }
89
+ }
90
+ else {
91
+ return this.makeError('Error: `language` parameter is required when searching a directory.');
92
+ }
93
+ return { searchPath, isSingleFile, resolvedLang };
94
+ }
95
+ async collectMatches(searchPath, isSingleFile, resolvedLang, pattern, rule, globs, signal) {
96
+ const targetDir = this.host.getTargetDir();
97
+ const allMatches = [];
98
+ let skippedFiles = 0;
99
+ if (isSingleFile) {
100
+ const content = await fs.readFile(searchPath, 'utf-8');
101
+ allMatches.push(...this.searchContent(content, resolvedLang, searchPath, targetDir, pattern, rule));
102
+ }
103
+ else {
104
+ const extensions = this.getExtensionsForLanguage(resolvedLang);
105
+ let files = await FastGlob(extensions.map((ext) => `**/*.${ext}`), {
106
+ cwd: searchPath,
107
+ absolute: true,
108
+ dot: false,
109
+ ignore: ['**/node_modules/**', '**/.git/**'],
110
+ });
111
+ files = await this.applyGlobFilters(files, globs, searchPath);
112
+ for (const file of files) {
113
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
114
+ if (signal?.aborted === true)
115
+ break;
116
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
117
+ try {
118
+ const content = await fs.readFile(file, 'utf-8');
119
+ allMatches.push(...this.searchContent(content, resolvedLang, file, targetDir, pattern, rule));
120
+ }
121
+ catch {
122
+ skippedFiles++;
123
+ }
124
+ }
125
+ }
126
+ return { allMatches, skippedFiles };
127
+ }
128
+ async applyGlobFilters(files, globs, searchPath) {
129
+ if (!globs || globs.length === 0)
130
+ return files;
131
+ const includePatterns = globs.filter((g) => !g.startsWith('!'));
132
+ const excludePatterns = globs
133
+ .filter((g) => g.startsWith('!'))
134
+ .map((g) => g.slice(1));
135
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
136
+ if (includePatterns.length > 0) {
137
+ const includeSet = new Set(await FastGlob(includePatterns, { cwd: searchPath, absolute: true }));
138
+ files = files.filter((f) => includeSet.has(f));
139
+ }
140
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
141
+ if (excludePatterns.length > 0) {
142
+ const excludeSet = new Set(await FastGlob(excludePatterns, { cwd: searchPath, absolute: true }));
143
+ files = files.filter((f) => !excludeSet.has(f));
144
+ }
145
+ return files;
146
+ }
147
+ formatSearchResults(allMatches, skippedFiles, limit, pattern) {
148
+ const truncated = allMatches.length > limit;
149
+ const result = {
150
+ matches: allMatches.slice(0, limit),
151
+ truncated,
152
+ skippedFiles: skippedFiles > 0 ? skippedFiles : undefined,
153
+ };
154
+ if (truncated) {
155
+ result.totalMatches = allMatches.length;
156
+ }
157
+ const matchCount = result.matches.length;
158
+ const searchDesc = pattern ? `pattern "${pattern}"` : 'rule query';
159
+ let llmContent = `Found ${matchCount} AST match${matchCount !== 1 ? 'es' : ''} for ${searchDesc}`;
160
+ if (truncated) {
161
+ llmContent += ` (showing ${matchCount} of ${result.totalMatches})`;
162
+ }
163
+ llmContent += ':\n---\n';
164
+ for (const m of result.matches) {
165
+ llmContent += `${m.file}:${m.startLine} [${m.nodeKind}] ${m.text}\n`;
166
+ if (Object.keys(m.metaVariables).length > 0) {
167
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
168
+ for (const [k, v] of Object.entries(m.metaVariables)) {
169
+ llmContent += ` $${k} = ${v}\n`;
170
+ }
171
+ }
172
+ }
173
+ const displayMessage = `Found ${matchCount} AST match${matchCount !== 1 ? 'es' : ''}${truncated ? ' (truncated)' : ''}`;
174
+ return {
175
+ llmContent: llmContent.trim(),
176
+ returnDisplay: displayMessage,
177
+ metadata: result,
178
+ };
179
+ }
180
+ searchContent(content, language, filePath, workspaceRoot, pattern, rule) {
181
+ const root = parse(language, content);
182
+ const sgRoot = root.root();
183
+ const relativePath = makeRelative(filePath, workspaceRoot);
184
+ let nodes;
185
+ if (pattern) {
186
+ nodes = sgRoot.findAll(pattern);
187
+ }
188
+ else if (rule) {
189
+ nodes = sgRoot.findAll({ rule });
190
+ }
191
+ else {
192
+ return [];
193
+ }
194
+ return nodes.map((node) => {
195
+ const range = node.range();
196
+ const metaVariables = {};
197
+ // Extract single metavariables ($NAME patterns, excluding $$$ multi-vars)
198
+ if (pattern) {
199
+ const metaVarNames =
200
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: array default for regex match
201
+ pattern.match(/(?<!\$)\$(?!\$)([A-Z_][A-Z0-9_]*)/g) || [];
202
+ for (const raw of metaVarNames) {
203
+ const name = raw.slice(1); // remove $
204
+ const match = node.getMatch(name);
205
+ if (match) {
206
+ metaVariables[name] = match.text();
207
+ }
208
+ }
209
+ // Extract multi metavariables ($$$NAME patterns)
210
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: array default for regex match
211
+ const multiVarNames = pattern.match(/\$\$\$([A-Z_][A-Z0-9_]*)/g) || [];
212
+ for (const raw of multiVarNames) {
213
+ const name = raw.slice(3); // remove $$$
214
+ const matches = node.getMultipleMatches(name);
215
+ if (matches.length > 0) {
216
+ metaVariables[name] = matches
217
+ .map((m) => m.text())
218
+ .join(', ');
219
+ }
220
+ }
221
+ }
222
+ return {
223
+ file: relativePath,
224
+ startLine: range.start.line + 1,
225
+ startCol: range.start.column,
226
+ endLine: range.end.line + 1,
227
+ endCol: range.end.column,
228
+ text: node.text(),
229
+ nodeKind: String(node.kind()),
230
+ metaVariables,
231
+ };
232
+ });
233
+ }
234
+ getExtensionsForLanguage(lang) {
235
+ const extensions = [];
236
+ for (const [ext, mappedLang] of Object.entries(LANGUAGE_MAP)) {
237
+ if (mappedLang === lang) {
238
+ extensions.push(ext);
239
+ }
240
+ }
241
+ return extensions.length > 0 ? extensions : ['*'];
242
+ }
243
+ }
244
+ export class AstGrepTool extends BaseDeclarativeTool {
245
+ host;
246
+ static Name = 'ast_grep';
247
+ constructor(host, _messageBus) {
248
+ super(AstGrepTool.Name, 'AstGrep', 'Searches for code patterns using AST (Abstract Syntax Tree) structural matching, not text matching. ' +
249
+ 'Use this for finding specific code structures: method calls, class declarations, import patterns, try/catch blocks, etc. ' +
250
+ 'Supports metavariable capture ($VAR for single node, $$$VAR for multiple). ' +
251
+ 'Unlike search_file_content (ripgrep), this tool understands code structure and ignores comments/strings.', Kind.Search, {
252
+ properties: {
253
+ pattern: {
254
+ description: 'AST pattern to search for. Use $VAR for single-node metavariables, $$$VAR for multi-node. ' +
255
+ 'Examples: "$OBJ.foo()", "class $NAME extends $PARENT { $$$BODY }", "try { $$$T } catch ($E) { $$$C }"',
256
+ type: 'string',
257
+ },
258
+ rule: {
259
+ description: 'YAML rule object for complex queries. Fields: kind, has, inside, stopBy, regex. ' +
260
+ 'Use when pattern syntax is insufficient (e.g., matching by AST node kind).',
261
+ type: 'object',
262
+ },
263
+ language: {
264
+ description: 'Programming language: typescript, javascript, python, ruby, go, rust, java, cpp, c, html, css, json. ' +
265
+ 'Required for directory searches. Auto-detected for single files.',
266
+ type: 'string',
267
+ },
268
+ path: {
269
+ description: 'File or directory to search. Defaults to workspace root.',
270
+ type: 'string',
271
+ },
272
+ globs: {
273
+ description: 'Glob patterns to include/exclude files. Prefix with ! to exclude. Example: ["*.ts", "!*.test.ts"]',
274
+ type: 'array',
275
+ items: { type: 'string' },
276
+ },
277
+ maxResults: {
278
+ description: 'Maximum matches to return. Default 100.',
279
+ type: 'number',
280
+ },
281
+ },
282
+ required: [],
283
+ type: 'object',
284
+ });
285
+ this.host = host;
286
+ }
287
+ createInvocation(params, messageBus) {
288
+ return new AstGrepToolInvocation(this.host, params, messageBus);
289
+ }
290
+ }
291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6B;QAE7B,KAAK,CACH,WAAW,CAAC,IAAI,EAChB,SAAS,EACT,sGAAsG;YACpG,2HAA2H;YAC3H,6EAA6E;YAC7E,0GAA0G,EAC5G,IAAI,CAAC,MAAM,EACX;YACE,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,WAAW,EACT,4FAA4F;wBAC5F,uGAAuG;oBACzG,IAAI,EAAE,QAAQ;iBACf;gBACD,IAAI,EAAE;oBACJ,WAAW,EACT,kFAAkF;wBAClF,4EAA4E;oBAC9E,IAAI,EAAE,QAAQ;iBACf;gBACD,QAAQ,EAAE;oBACR,WAAW,EACT,uGAAuG;wBACvG,kEAAkE;oBACpE,IAAI,EAAE,QAAQ;iBACf;gBACD,IAAI,EAAE;oBACJ,WAAW,EACT,0DAA0D;oBAC5D,IAAI,EAAE,QAAQ;iBACf;gBACD,KAAK,EAAE;oBACL,WAAW,EACT,mGAAmG;oBACrG,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC1B;gBACD,UAAU,EAAE;oBACV,WAAW,EAAE,yCAAyC;oBACtD,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,QAAQ;SACf,CACF,CAAC;QAlDe,SAAI,GAAJ,IAAI,CAAW;IAmDlC,CAAC;IAEkB,gBAAgB,CACjC,MAAyB,EACzB,UAA2B;QAE3B,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Vybestack LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @plan PLAN-20260130-ASYNCTASK.P12
8
+ * @plan PLAN-20260130-ASYNCTASK.P14
9
+ * @requirement REQ-ASYNC-005
10
+ */
11
+ import { BaseDeclarativeTool, BaseToolInvocation, type ToolResult } from './tools.js';
12
+ import type { IToolMessageBus } from '../interfaces/IToolMessageBus.js';
13
+ import type { IAsyncTaskService } from '../interfaces/index.js';
14
+ export interface CheckAsyncTasksParams {
15
+ task_id?: string;
16
+ }
17
+ export interface CheckAsyncTasksToolDependencies {
18
+ getAsyncTaskService?: () => IAsyncTaskService | undefined;
19
+ }
20
+ declare class CheckAsyncTasksInvocation extends BaseToolInvocation<CheckAsyncTasksParams, ToolResult> {
21
+ private readonly taskService;
22
+ constructor(params: CheckAsyncTasksParams, taskService: IAsyncTaskService, messageBus: IToolMessageBus);
23
+ getDescription(): string;
24
+ execute(): Promise<ToolResult>;
25
+ private executeList;
26
+ private executePeek;
27
+ private formatTaskDetails;
28
+ private formatDuration;
29
+ private formatTaskDisplay;
30
+ private statusIcon;
31
+ }
32
+ /**
33
+ * Tool that allows querying the status of async tasks.
34
+ * Two modes:
35
+ * - List mode (no task_id): Shows summary of all tasks
36
+ * - Peek mode (with task_id): Shows detailed info for specific task
37
+ */
38
+ export declare class CheckAsyncTasksTool extends BaseDeclarativeTool<CheckAsyncTasksParams, ToolResult> {
39
+ private readonly dependencies;
40
+ static readonly Name = "check_async_tasks";
41
+ constructor(dependencies: CheckAsyncTasksToolDependencies | IAsyncTaskService);
42
+ protected createInvocation(params: CheckAsyncTasksParams, messageBus: IToolMessageBus): CheckAsyncTasksInvocation;
43
+ execute(params: CheckAsyncTasksParams): Promise<ToolResult>;
44
+ protected validateToolParamValues(): string | null;
45
+ }
46
+ export {};