@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,435 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
7
+ import * as fs from 'node:fs/promises';
8
+ import * as os from 'node:os';
9
+ import * as path from 'node:path';
10
+ import process from 'node:process';
11
+ import * as Diff from 'diff';
12
+ import { DEFAULT_CREATE_PATCH_OPTIONS } from '../utils/diffOptions.js';
13
+ import { shortenPath } from '../utils/paths.js';
14
+ import { ToolErrorType } from '../types/tool-error.js';
15
+ import { debugLogger as logger } from '../utils/debugLogger.js';
16
+ function tildeifyPath(filePath) {
17
+ const homeDir = os.homedir();
18
+ if (homeDir &&
19
+ (filePath === homeDir || filePath.startsWith(`${homeDir}${path.sep}`))) {
20
+ return `~${filePath.slice(homeDir.length)}`;
21
+ }
22
+ return shortenPath(filePath);
23
+ }
24
+ const memoryToolSchemaData = {
25
+ name: 'save_memory',
26
+ description: 'Saves a specific piece of information or fact to your long-term memory. Use this when the user explicitly asks you to remember something, or when they state a clear, concise fact that seems important to retain for future interactions.',
27
+ parametersJsonSchema: {
28
+ type: 'object',
29
+ properties: {
30
+ fact: {
31
+ type: 'string',
32
+ description: 'The specific fact or piece of information to remember. Should be a clear, self-contained statement.',
33
+ },
34
+ scope: {
35
+ type: 'string',
36
+ enum: ['global', 'project', 'core.global', 'core.project'],
37
+ description: 'Where to save the memory: "global" or "project" (default, saves to project-local .llxprt directory). ' +
38
+ '"core.global" and "core.project" save to the system prompt (.LLXPRT_SYSTEM) — requires model.canSaveCore to be enabled.',
39
+ default: 'project',
40
+ },
41
+ },
42
+ required: ['fact'],
43
+ },
44
+ };
45
+ const memoryToolDescription = `
46
+ Saves a specific piece of information or fact to your long-term memory.
47
+
48
+ Use this tool:
49
+
50
+ - When the user explicitly asks you to remember something (e.g., "Remember that I like pineapple on pizza", "Please save this: my cat's name is Whiskers").
51
+ - When the user states a clear, concise fact about themselves, their preferences, or their environment that seems important for you to retain for future interactions to provide a more personalized and effective assistance.
52
+
53
+ Do NOT use this tool:
54
+
55
+ - To remember conversational context that is only relevant for the current session.
56
+ - To save long, complex, or rambling pieces of text. The fact should be relatively short and to the point.
57
+ - If you are unsure whether the information is a fact worth remembering long-term. If in doubt, you can ask the user, "Should I remember that for you?"
58
+
59
+ ## Parameters
60
+
61
+ - \`fact\` (string, required): The specific fact or piece of information to remember. This should be a clear, self-contained statement. For example, if the user says "My favorite color is blue", the fact would be "My favorite color is blue".
62
+ - \`scope\` (string, optional): Where to save the memory. Defaults to "project".
63
+ - \`"global"\` — saved to the global LLXPRT.md file.
64
+ - \`"project"\` — saved to the project-local .llxprt/LLXPRT.md file.
65
+ - \`"core.global"\` — saved to the global system prompt (.LLXPRT_SYSTEM). Requires \`model.canSaveCore\` to be enabled.
66
+ - \`"core.project"\` — saved to the project system prompt (.LLXPRT_SYSTEM). Requires \`model.canSaveCore\` to be enabled.
67
+ `;
68
+ export const LLXPRT_CONFIG_DIR = '.llxprt';
69
+ // Alias for backward compatibility with gemini-cli code
70
+ export const GEMINI_DIR = LLXPRT_CONFIG_DIR;
71
+ export const DEFAULT_CONTEXT_FILENAME = 'LLXPRT.md';
72
+ export const CORE_MEMORY_FILENAME = '.LLXPRT_SYSTEM';
73
+ export const MEMORY_SECTION_HEADER = '## LLxprt Code Added Memories';
74
+ // This variable will hold the currently configured filename for LLXPRT.md context files.
75
+ // It defaults to DEFAULT_CONTEXT_FILENAME but can be overridden by setLlxprtMdFilename.
76
+ let currentLlxprtMdFilename = DEFAULT_CONTEXT_FILENAME;
77
+ export function setLlxprtMdFilename(newFilename) {
78
+ if (Array.isArray(newFilename)) {
79
+ if (newFilename.length > 0) {
80
+ currentLlxprtMdFilename = newFilename.map((name) => name.trim());
81
+ }
82
+ }
83
+ else if (newFilename && newFilename.trim() !== '') {
84
+ currentLlxprtMdFilename = newFilename.trim();
85
+ }
86
+ }
87
+ export function getCurrentLlxprtMdFilename() {
88
+ if (Array.isArray(currentLlxprtMdFilename)) {
89
+ return currentLlxprtMdFilename[0];
90
+ }
91
+ return currentLlxprtMdFilename;
92
+ }
93
+ export function getAllLlxprtMdFilenames() {
94
+ if (Array.isArray(currentLlxprtMdFilename)) {
95
+ return currentLlxprtMdFilename;
96
+ }
97
+ return [currentLlxprtMdFilename];
98
+ }
99
+ function isCoreScope(scope) {
100
+ return scope === 'core.global' || scope === 'core.project';
101
+ }
102
+ function getDefaultGlobalLlxprtDir() {
103
+ const homeDir = os.homedir();
104
+ if (!homeDir) {
105
+ return path.join(os.tmpdir(), LLXPRT_CONFIG_DIR);
106
+ }
107
+ return path.join(homeDir, LLXPRT_CONFIG_DIR);
108
+ }
109
+ function getGlobalMemoryFilePath(storageService) {
110
+ return path.join(storageService.getLLXPRTDir(), getCurrentLlxprtMdFilename());
111
+ }
112
+ function getProjectMemoryFilePath(workingDir) {
113
+ return path.join(workingDir, LLXPRT_CONFIG_DIR, getCurrentLlxprtMdFilename());
114
+ }
115
+ export function getGlobalCoreMemoryFilePath(storageService) {
116
+ return path.join(storageService?.getLLXPRTDir() ?? getDefaultGlobalLlxprtDir(), CORE_MEMORY_FILENAME);
117
+ }
118
+ export function getProjectCoreMemoryFilePath(workingDir) {
119
+ return path.join(workingDir, LLXPRT_CONFIG_DIR, CORE_MEMORY_FILENAME);
120
+ }
121
+ /**
122
+ * Ensures proper newline separation before appending content.
123
+ */
124
+ function ensureNewlineSeparation(currentContent) {
125
+ if (currentContent.length === 0)
126
+ return '';
127
+ if (currentContent.endsWith('\n\n') || currentContent.endsWith('\r\n\r\n'))
128
+ return '';
129
+ if (currentContent.endsWith('\n') || currentContent.endsWith('\r\n'))
130
+ return '\n';
131
+ return '\n\n';
132
+ }
133
+ /**
134
+ * Computes the new content that would result from adding a memory entry
135
+ */
136
+ function computeNewContent(currentContent, fact) {
137
+ let processedText = fact.trim();
138
+ // eslint-disable-next-line sonarjs/regular-expr -- Static regex reviewed for lint hardening; behavior preserved.
139
+ processedText = processedText.replace(/^(-+\s*)+/, '').trim();
140
+ const newMemoryItem = `- ${processedText}`;
141
+ const headerIndex = currentContent.indexOf(MEMORY_SECTION_HEADER);
142
+ if (headerIndex === -1) {
143
+ // Header not found, append header and then the entry
144
+ const separator = ensureNewlineSeparation(currentContent);
145
+ return (currentContent +
146
+ `${separator}${MEMORY_SECTION_HEADER}\n${newMemoryItem}\n`);
147
+ }
148
+ // Header found, find where to insert the new memory entry
149
+ const startOfSectionContent = headerIndex + MEMORY_SECTION_HEADER.length;
150
+ let endOfSectionIndex = currentContent.indexOf('\n## ', startOfSectionContent);
151
+ if (endOfSectionIndex === -1) {
152
+ endOfSectionIndex = currentContent.length; // End of file
153
+ }
154
+ const beforeSectionMarker = currentContent
155
+ .substring(0, startOfSectionContent)
156
+ .trimEnd();
157
+ let sectionContent = currentContent
158
+ .substring(startOfSectionContent, endOfSectionIndex)
159
+ .trimEnd();
160
+ const afterSectionMarker = currentContent.substring(endOfSectionIndex);
161
+ sectionContent += `\n${newMemoryItem}`;
162
+ return (`${beforeSectionMarker}\n${sectionContent.trimStart()}\n${afterSectionMarker}`.trimEnd() +
163
+ '\n');
164
+ }
165
+ class MemoryToolInvocation extends BaseToolInvocation {
166
+ storageService;
167
+ getWorkingDir;
168
+ static allowlist = new Set();
169
+ constructor(params, messageBus, storageService, getWorkingDir) {
170
+ super(params, messageBus);
171
+ this.storageService = storageService;
172
+ this.getWorkingDir = getWorkingDir;
173
+ }
174
+ setWorkingDir(workingDir) {
175
+ this.getWorkingDir = () => workingDir;
176
+ }
177
+ resolveWorkingDir() {
178
+ return this.getWorkingDir?.();
179
+ }
180
+ getMemoryFilePath() {
181
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: scope is optional string, empty string should fall through to default
182
+ const scope = this.params.scope || 'project';
183
+ const workingDir = this.resolveWorkingDir();
184
+ switch (scope) {
185
+ case 'core.project':
186
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: workingDir is optional string, empty string should fall through to cwd
187
+ return getProjectCoreMemoryFilePath(workingDir || process.cwd());
188
+ case 'core.global':
189
+ return getGlobalCoreMemoryFilePath(this.storageService);
190
+ case 'project':
191
+ if (workingDir) {
192
+ return getProjectMemoryFilePath(workingDir);
193
+ }
194
+ return getGlobalMemoryFilePath(this.storageService);
195
+ case 'global':
196
+ default:
197
+ return getGlobalMemoryFilePath(this.storageService);
198
+ }
199
+ }
200
+ async readMemoryFileContent() {
201
+ try {
202
+ return await this.storageService.readFile(this.getMemoryFilePath());
203
+ }
204
+ catch (err) {
205
+ const error = err;
206
+ if (!(error instanceof Error) || error.code !== 'ENOENT')
207
+ throw err;
208
+ return '';
209
+ }
210
+ }
211
+ getToolName() {
212
+ return MemoryTool.Name;
213
+ }
214
+ getDescription() {
215
+ const memoryFilePath = this.getMemoryFilePath();
216
+ return `in ${tildeifyPath(memoryFilePath)}`;
217
+ }
218
+ async shouldConfirmExecute(_abortSignal) {
219
+ const memoryFilePath = this.getMemoryFilePath();
220
+ const allowlistKey = memoryFilePath;
221
+ if (MemoryToolInvocation.allowlist.has(allowlistKey)) {
222
+ return false;
223
+ }
224
+ const currentContent = await this.readMemoryFileContent();
225
+ const fact = this.params.fact ?? this.params.content ?? '';
226
+ const newContent = computeNewContent(currentContent, fact);
227
+ const fileName = path.basename(memoryFilePath);
228
+ const fileDiff = Diff.createPatch(fileName, currentContent, newContent, 'Current', 'Proposed', DEFAULT_CREATE_PATCH_OPTIONS);
229
+ const confirmationDetails = {
230
+ type: 'edit',
231
+ title: `Confirm Memory Save: ${tildeifyPath(memoryFilePath)}`,
232
+ fileName: memoryFilePath,
233
+ filePath: memoryFilePath,
234
+ fileDiff,
235
+ originalContent: currentContent,
236
+ newContent,
237
+ onConfirm: async (outcome) => {
238
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
239
+ MemoryToolInvocation.allowlist.add(allowlistKey);
240
+ }
241
+ await this.publishPolicyUpdate(outcome);
242
+ },
243
+ };
244
+ return confirmationDetails;
245
+ }
246
+ async execute(_signal) {
247
+ const { modified_by_user, modified_content } = this.params;
248
+ const fact = this.params.fact ?? this.params.content ?? '';
249
+ if (this.params.read === true) {
250
+ const content = await this.readMemoryFileContent();
251
+ return {
252
+ llmContent: content,
253
+ returnDisplay: content,
254
+ };
255
+ }
256
+ const memoryFilePath = this.getMemoryFilePath();
257
+ try {
258
+ if (modified_by_user === true && modified_content !== undefined) {
259
+ // User modified the content in external editor, write it directly
260
+ await this.storageService.ensureDir(path.dirname(memoryFilePath));
261
+ await this.storageService.writeFile(memoryFilePath, modified_content);
262
+ const successMessage = `Okay, I've updated the memory file with your modifications.`;
263
+ return {
264
+ llmContent: JSON.stringify({
265
+ success: true,
266
+ message: successMessage,
267
+ }),
268
+ returnDisplay: successMessage,
269
+ };
270
+ }
271
+ // Use the normal memory entry logic
272
+ await MemoryTool.performAddMemoryEntry(fact, memoryFilePath, {
273
+ readFile: (filePath) => this.storageService.readFile(filePath),
274
+ writeFile: (filePath, data) => this.storageService.writeFile(filePath, data),
275
+ mkdir: async (dirPath) => {
276
+ await this.storageService.ensureDir(dirPath);
277
+ return undefined;
278
+ },
279
+ });
280
+ const successMessage = `Okay, I've remembered that: "${fact}"`;
281
+ return {
282
+ llmContent: JSON.stringify({
283
+ success: true,
284
+ message: successMessage,
285
+ }),
286
+ returnDisplay: successMessage,
287
+ };
288
+ }
289
+ catch (error) {
290
+ const errorMessage = error instanceof Error ? error.message : String(error);
291
+ logger.error(`Error executing save_memory for fact "${fact}": ${errorMessage}`);
292
+ return {
293
+ llmContent: JSON.stringify({
294
+ success: false,
295
+ error: `Failed to save memory. Detail: ${errorMessage}`,
296
+ }),
297
+ returnDisplay: `Error saving memory: ${errorMessage}`,
298
+ error: {
299
+ message: errorMessage,
300
+ type: ToolErrorType.MEMORY_TOOL_EXECUTION_ERROR,
301
+ },
302
+ };
303
+ }
304
+ }
305
+ }
306
+ export class MemoryTool extends BaseDeclarativeTool {
307
+ static Name = memoryToolSchemaData.name;
308
+ storageService;
309
+ settingsService;
310
+ getWorkingDir;
311
+ constructor(dependencies = {
312
+ storageService: {
313
+ getLLXPRTDir: getDefaultGlobalLlxprtDir,
314
+ readFile: (filePath) => fs.readFile(filePath, 'utf-8'),
315
+ writeFile: (filePath, content) => fs.writeFile(filePath, content, 'utf-8'),
316
+ ensureDir: (dirPath) => fs.mkdir(dirPath, { recursive: true }).then(() => undefined),
317
+ },
318
+ }) {
319
+ const resolvedDependencies = 'storageService' in dependencies
320
+ ? dependencies
321
+ : { storageService: dependencies };
322
+ super(MemoryTool.Name, 'SaveMemory', memoryToolDescription, Kind.Think, memoryToolSchemaData.parametersJsonSchema, false, // output is not markdown
323
+ false, // output cannot be updated
324
+ resolvedDependencies.messageBus);
325
+ this.storageService = resolvedDependencies.storageService;
326
+ this.settingsService = resolvedDependencies.settingsService;
327
+ this.getWorkingDir = resolvedDependencies.getWorkingDir;
328
+ }
329
+ validateToolParamValues(params) {
330
+ if (params.read !== true &&
331
+ (params.fact ?? params.content ?? '').trim() === '') {
332
+ return 'Parameter "fact" must be a non-empty string.';
333
+ }
334
+ // Core scopes require model.canSaveCore to be enabled
335
+ if (isCoreScope(params.scope)) {
336
+ try {
337
+ const canSaveCore = this.settingsService?.getSetting('model.canSaveCore');
338
+ if (canSaveCore !== true) {
339
+ return ('Core memory scopes (core.global, core.project) are disabled. ' +
340
+ 'Enable them with: /set model.canSaveCore true\n' +
341
+ 'WARNING: This allows the model to modify your system directives.');
342
+ }
343
+ }
344
+ catch {
345
+ return 'Core memory scopes require model.canSaveCore to be enabled.';
346
+ }
347
+ }
348
+ return null;
349
+ }
350
+ createInvocation(params, messageBus) {
351
+ return new MemoryToolInvocation(params, messageBus, this.storageService, this.getWorkingDir);
352
+ }
353
+ async execute(params) {
354
+ const invocation = this.build({
355
+ ...params,
356
+ fact: params.fact ?? params.content ?? '',
357
+ });
358
+ return invocation.execute(new AbortController().signal);
359
+ }
360
+ static async performAddMemoryEntry(text, memoryFilePath, fsAdapter) {
361
+ try {
362
+ await fsAdapter.mkdir(path.dirname(memoryFilePath), { recursive: true });
363
+ let currentContent = '';
364
+ try {
365
+ currentContent = await fsAdapter.readFile(memoryFilePath, 'utf-8');
366
+ }
367
+ catch {
368
+ // File doesn't exist - currentContent remains empty
369
+ }
370
+ const newContent = computeNewContent(currentContent, text);
371
+ await fsAdapter.writeFile(memoryFilePath, newContent, 'utf-8');
372
+ }
373
+ catch (error) {
374
+ logger.error(`Error adding memory entry to ${memoryFilePath}: ${error instanceof Error ? error.message : String(error)}`);
375
+ throw new Error(`[MemoryTool] Failed to add memory entry: ${error instanceof Error ? error.message : String(error)}`);
376
+ }
377
+ }
378
+ getModifyContext(_abortSignal) {
379
+ const resolvePath = (scope) => {
380
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: scope is optional string, empty string should fall through to default
381
+ const resolvedScope = scope || 'project';
382
+ const workingDir = this.getWorkingDir?.();
383
+ switch (resolvedScope) {
384
+ case 'core.project':
385
+ return getProjectCoreMemoryFilePath(
386
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: getWorkingDir returns string | undefined, empty string should fall through to cwd
387
+ workingDir || process.cwd());
388
+ case 'core.global':
389
+ return getGlobalCoreMemoryFilePath(this.storageService);
390
+ case 'project':
391
+ if (workingDir) {
392
+ return getProjectMemoryFilePath(workingDir);
393
+ }
394
+ return getGlobalMemoryFilePath(this.storageService);
395
+ case 'global':
396
+ default:
397
+ return getGlobalMemoryFilePath(this.storageService);
398
+ }
399
+ };
400
+ return {
401
+ getFilePath: (params) => resolvePath(params.scope),
402
+ getCurrentContent: async (params) => {
403
+ const memoryFilePath = resolvePath(params.scope);
404
+ try {
405
+ return await this.storageService.readFile(memoryFilePath);
406
+ }
407
+ catch (err) {
408
+ const error = err;
409
+ if (!(error instanceof Error) || error.code !== 'ENOENT')
410
+ throw err;
411
+ return '';
412
+ }
413
+ },
414
+ getProposedContent: async (params) => {
415
+ const memoryFilePath = resolvePath(params.scope);
416
+ try {
417
+ const currentContent = await this.storageService.readFile(memoryFilePath);
418
+ return computeNewContent(currentContent, params.fact ?? params.content ?? '');
419
+ }
420
+ catch (err) {
421
+ const error = err;
422
+ if (!(error instanceof Error) || error.code !== 'ENOENT')
423
+ throw err;
424
+ return computeNewContent('', params.fact ?? params.content ?? '');
425
+ }
426
+ },
427
+ createUpdatedParams: (_oldContent, modifiedProposedContent, originalParams) => ({
428
+ ...originalParams,
429
+ modified_by_user: true,
430
+ modified_content: modifiedProposedContent,
431
+ }),
432
+ };
433
+ }
434
+ }
435
+ //# sourceMappingURL=memoryTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryTool.js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,EAAmB,EAAE;gBACtE,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjD,IAAI,CAAC;oBACH,MAAM,cAAc,GAClB,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;oBACrD,OAAO,iBAAiB,CACtB,cAAc,EACd,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,CACpC,CAAC;gBACJ,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,MAAM,KAAK,GAAG,GAAgC,CAAC;oBAC/C,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;wBAAE,MAAM,GAAG,CAAC;oBACpE,OAAO,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;YACD,mBAAmB,EAAE,CACnB,WAAmB,EACnB,uBAA+B,EAC/B,cAAgC,EACd,EAAE,CAAC,CAAC;gBACtB,GAAG,cAAc;gBACjB,gBAAgB,EAAE,IAAI;gBACtB,gBAAgB,EAAE,uBAAuB;aAC1C,CAAC;SACH,CAAC;IACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { type EditorType } from '../utils/editor.js';
7
+ import type { DeclarativeTool } from './tools.js';
8
+ import { type AnyDeclarativeTool, type ToolResult } from './tools.js';
9
+ /**
10
+ * A declarative tool that supports a modify operation.
11
+ */
12
+ export interface ModifiableDeclarativeTool<TParams extends object> extends DeclarativeTool<TParams, ToolResult> {
13
+ getModifyContext(abortSignal: AbortSignal): ModifyContext<TParams>;
14
+ }
15
+ export interface ModifyContext<ToolParams> {
16
+ getFilePath: (params: ToolParams) => string;
17
+ getCurrentContent: (params: ToolParams) => Promise<string>;
18
+ getProposedContent: (params: ToolParams) => Promise<string>;
19
+ createUpdatedParams: (oldContent: string, modifiedProposedContent: string, originalParams: ToolParams) => ToolParams;
20
+ }
21
+ export interface ModifyResult<ToolParams> {
22
+ updatedParams: ToolParams;
23
+ updatedDiff: string;
24
+ }
25
+ export interface ModifyContentOverrides {
26
+ currentContent?: string | null;
27
+ proposedContent?: string;
28
+ }
29
+ /**
30
+ * Type guard to check if a declarative tool is modifiable.
31
+ */
32
+ export declare function isModifiableDeclarativeTool(tool: AnyDeclarativeTool): tool is ModifiableDeclarativeTool<object>;
33
+ /**
34
+ * Triggers an external editor for the user to modify the proposed content,
35
+ * and returns the updated tool parameters and the diff after the user has modified the proposed content.
36
+ */
37
+ export declare function modifyWithEditor<ToolParams>(originalParams: ToolParams, modifyContext: ModifyContext<ToolParams>, editorType: EditorType, _abortSignal: AbortSignal, onEditorClose: () => void, onEditorOpen?: () => void, overrides?: ModifyContentOverrides): Promise<ModifyResult<ToolParams>>;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { openDiff } from '../utils/editor.js';
7
+ import os from 'os';
8
+ import path from 'path';
9
+ import fs from 'fs';
10
+ import * as Diff from 'diff';
11
+ import { DEFAULT_CREATE_PATCH_OPTIONS } from '../utils/diffOptions.js';
12
+ import { isNodeError } from '../utils/errors.js';
13
+ const debugLogger = {
14
+ error: (..._args) => { },
15
+ };
16
+ /**
17
+ * Type guard to check if a declarative tool is modifiable.
18
+ */
19
+ export function isModifiableDeclarativeTool(tool) {
20
+ return 'getModifyContext' in tool;
21
+ }
22
+ function createTempFilesForModify(currentContent, proposedContent, file_path) {
23
+ const diffDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gemini-cli-tool-modify-'));
24
+ try {
25
+ fs.chmodSync(diffDir, 0o700);
26
+ }
27
+ catch (e) {
28
+ debugLogger.error(`Error setting permissions on temp diff directory: ${diffDir}`, e);
29
+ throw e;
30
+ }
31
+ const ext = path.extname(file_path);
32
+ const fileName = path.basename(file_path, ext);
33
+ const timestamp = Date.now();
34
+ const tempOldPath = path.join(diffDir, `gemini-cli-modify-${fileName}-old-${timestamp}${ext}`);
35
+ const tempNewPath = path.join(diffDir, `gemini-cli-modify-${fileName}-new-${timestamp}${ext}`);
36
+ fs.writeFileSync(tempOldPath, currentContent, {
37
+ encoding: 'utf8',
38
+ mode: 0o600,
39
+ });
40
+ fs.writeFileSync(tempNewPath, proposedContent, {
41
+ encoding: 'utf8',
42
+ mode: 0o600,
43
+ });
44
+ return { oldPath: tempOldPath, newPath: tempNewPath, dirPath: diffDir };
45
+ }
46
+ function getUpdatedParams(tmpOldPath, tempNewPath, originalParams, modifyContext) {
47
+ let oldContent = '';
48
+ let newContent = '';
49
+ try {
50
+ oldContent = fs.readFileSync(tmpOldPath, 'utf8');
51
+ }
52
+ catch (err) {
53
+ if (!isNodeError(err) || err.code !== 'ENOENT')
54
+ throw err;
55
+ oldContent = '';
56
+ }
57
+ try {
58
+ newContent = fs.readFileSync(tempNewPath, 'utf8');
59
+ }
60
+ catch (err) {
61
+ if (!isNodeError(err) || err.code !== 'ENOENT')
62
+ throw err;
63
+ newContent = '';
64
+ }
65
+ const updatedParams = modifyContext.createUpdatedParams(oldContent, newContent, originalParams);
66
+ const updatedDiff = Diff.createPatch(path.basename(modifyContext.getFilePath(originalParams)), oldContent, newContent, 'Current', 'Proposed', DEFAULT_CREATE_PATCH_OPTIONS);
67
+ return { updatedParams, updatedDiff };
68
+ }
69
+ function deleteTempFiles(oldPath, newPath, dirPath) {
70
+ try {
71
+ fs.unlinkSync(oldPath);
72
+ }
73
+ catch {
74
+ debugLogger.error(`Error deleting temp diff file: ${oldPath}`);
75
+ }
76
+ try {
77
+ fs.unlinkSync(newPath);
78
+ }
79
+ catch {
80
+ debugLogger.error(`Error deleting temp diff file: ${newPath}`);
81
+ }
82
+ try {
83
+ fs.rmdirSync(dirPath);
84
+ }
85
+ catch {
86
+ debugLogger.error(`Error deleting temp diff directory: ${dirPath}`);
87
+ }
88
+ }
89
+ /**
90
+ * Triggers an external editor for the user to modify the proposed content,
91
+ * and returns the updated tool parameters and the diff after the user has modified the proposed content.
92
+ */
93
+ export async function modifyWithEditor(originalParams, modifyContext, editorType, _abortSignal, onEditorClose, onEditorOpen, overrides) {
94
+ const hasCurrentOverride = overrides !== undefined && 'currentContent' in overrides;
95
+ const hasProposedOverride = overrides !== undefined && 'proposedContent' in overrides;
96
+ const currentContent = hasCurrentOverride
97
+ ? (overrides.currentContent ?? '')
98
+ : await modifyContext.getCurrentContent(originalParams);
99
+ const proposedContent = hasProposedOverride
100
+ ? (overrides.proposedContent ?? '')
101
+ : await modifyContext.getProposedContent(originalParams);
102
+ const { oldPath, newPath, dirPath } = createTempFilesForModify(currentContent, proposedContent, modifyContext.getFilePath(originalParams));
103
+ try {
104
+ if (onEditorOpen) {
105
+ try {
106
+ onEditorOpen();
107
+ }
108
+ catch (error) {
109
+ debugLogger.error('Error in onEditorOpen callback:', error);
110
+ }
111
+ }
112
+ await openDiff(oldPath, newPath, editorType, onEditorClose);
113
+ const result = getUpdatedParams(oldPath, newPath, originalParams, modifyContext);
114
+ return result;
115
+ }
116
+ finally {
117
+ deleteTempFiles(oldPath, newPath, dirPath);
118
+ }
119
+ }
120
+ //# sourceMappingURL=modifiable-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifiable-tool.js","sourceRoot":"","sources":["../../../src/tools/modifiable-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAmB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE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