@machina.ai/cell-cli-core 1.20.2-rc1 → 1.25.0-rc1

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 (898) hide show
  1. package/dist/docs/AFTER_MERGE_PROMPT.md +26 -0
  2. package/dist/docs/CHANGES.md +124 -0
  3. package/dist/docs/api-proxy.md +27 -0
  4. package/dist/docs/architecture.md +80 -0
  5. package/dist/docs/assets/connected_devtools.png +0 -0
  6. package/dist/docs/assets/gemini-screenshot.png +0 -0
  7. package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
  8. package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
  9. package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
  10. package/dist/docs/assets/release_patch.png +0 -0
  11. package/dist/docs/assets/theme-ansi-light.png +0 -0
  12. package/dist/docs/assets/theme-ansi.png +0 -0
  13. package/dist/docs/assets/theme-atom-one.png +0 -0
  14. package/dist/docs/assets/theme-ayu-light.png +0 -0
  15. package/dist/docs/assets/theme-ayu.png +0 -0
  16. package/dist/docs/assets/theme-custom.png +0 -0
  17. package/dist/docs/assets/theme-default-light.png +0 -0
  18. package/dist/docs/assets/theme-default.png +0 -0
  19. package/dist/docs/assets/theme-dracula.png +0 -0
  20. package/dist/docs/assets/theme-github-light.png +0 -0
  21. package/dist/docs/assets/theme-github.png +0 -0
  22. package/dist/docs/assets/theme-google-light.png +0 -0
  23. package/dist/docs/assets/theme-xcode-light.png +0 -0
  24. package/dist/docs/changelogs/index.md +612 -0
  25. package/dist/docs/changelogs/latest.md +153 -0
  26. package/dist/docs/changelogs/preview.md +131 -0
  27. package/dist/docs/changelogs/releases.md +1162 -0
  28. package/dist/docs/cli/authentication.md +3 -0
  29. package/dist/docs/cli/checkpointing.md +94 -0
  30. package/dist/docs/cli/commands.md +357 -0
  31. package/dist/docs/cli/custom-commands.md +315 -0
  32. package/dist/docs/cli/enterprise.md +564 -0
  33. package/dist/docs/cli/gemini-ignore.md +71 -0
  34. package/dist/docs/cli/gemini-md.md +109 -0
  35. package/dist/docs/cli/generation-settings.md +210 -0
  36. package/dist/docs/cli/headless.md +388 -0
  37. package/dist/docs/cli/index.md +63 -0
  38. package/dist/docs/cli/keyboard-shortcuts.md +136 -0
  39. package/dist/docs/cli/model-routing.md +37 -0
  40. package/dist/docs/cli/model.md +62 -0
  41. package/dist/docs/cli/sandbox.md +171 -0
  42. package/dist/docs/cli/session-management.md +158 -0
  43. package/dist/docs/cli/settings.md +148 -0
  44. package/dist/docs/cli/skills.md +188 -0
  45. package/dist/docs/cli/system-prompt.md +94 -0
  46. package/dist/docs/cli/telemetry.md +813 -0
  47. package/dist/docs/cli/themes.md +237 -0
  48. package/dist/docs/cli/token-caching.md +20 -0
  49. package/dist/docs/cli/trusted-folders.md +95 -0
  50. package/dist/docs/cli/tutorials/skills-getting-started.md +124 -0
  51. package/dist/docs/cli/tutorials.md +87 -0
  52. package/dist/docs/cli/uninstall.md +47 -0
  53. package/dist/docs/core/index.md +101 -0
  54. package/dist/docs/core/memport.md +246 -0
  55. package/dist/docs/core/policy-engine.md +268 -0
  56. package/dist/docs/core/tools-api.md +131 -0
  57. package/dist/docs/examples/proxy-script.md +83 -0
  58. package/dist/docs/extensions/extension-releasing.md +183 -0
  59. package/dist/docs/extensions/getting-started-extensions.md +244 -0
  60. package/dist/docs/extensions/index.md +343 -0
  61. package/dist/docs/faq.md +153 -0
  62. package/dist/docs/get-started/authentication.md +321 -0
  63. package/dist/docs/get-started/configuration-v1.md +890 -0
  64. package/dist/docs/get-started/configuration.md +1643 -0
  65. package/dist/docs/get-started/examples.md +218 -0
  66. package/dist/docs/get-started/gemini-3.md +101 -0
  67. package/dist/docs/get-started/index.md +71 -0
  68. package/dist/docs/get-started/installation.md +141 -0
  69. package/dist/docs/hooks/best-practices.md +856 -0
  70. package/dist/docs/hooks/index.md +723 -0
  71. package/dist/docs/hooks/reference.md +178 -0
  72. package/dist/docs/hooks/writing-hooks.md +1044 -0
  73. package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
  74. package/dist/docs/ide-integration/index.md +201 -0
  75. package/dist/docs/index.md +147 -0
  76. package/dist/docs/integration-tests.md +211 -0
  77. package/dist/docs/issue-and-pr-automation.md +134 -0
  78. package/dist/docs/local-development.md +128 -0
  79. package/dist/docs/mcp_integration.md +160 -0
  80. package/dist/docs/mermaid/context.mmd +103 -0
  81. package/dist/docs/mermaid/render-path.mmd +64 -0
  82. package/dist/docs/npm.md +62 -0
  83. package/dist/docs/quota-and-pricing.md +158 -0
  84. package/dist/docs/release-confidence.md +164 -0
  85. package/dist/docs/releases.md +540 -0
  86. package/dist/docs/sidebar.json +301 -0
  87. package/dist/docs/tools/file-system.md +217 -0
  88. package/dist/docs/tools/index.md +95 -0
  89. package/dist/docs/tools/mcp-server.md +1045 -0
  90. package/dist/docs/tools/memory.md +54 -0
  91. package/dist/docs/tools/shell.md +260 -0
  92. package/dist/docs/tools/todos.md +56 -0
  93. package/dist/docs/tools/web-fetch.md +59 -0
  94. package/dist/docs/tools/web-search.md +42 -0
  95. package/dist/docs/tos-privacy.md +96 -0
  96. package/dist/docs/troubleshooting.md +162 -0
  97. package/dist/index.d.ts +1 -1
  98. package/dist/index.js +1 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/package.json +7 -4
  101. package/dist/src/agents/a2a-client-manager.d.ts +82 -0
  102. package/dist/src/agents/a2a-client-manager.js +295 -0
  103. package/dist/src/agents/a2a-client-manager.js.map +1 -0
  104. package/dist/src/agents/a2a-client-manager.test.js +281 -0
  105. package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
  106. package/dist/src/agents/a2aUtils.d.ts +29 -0
  107. package/dist/src/agents/a2aUtils.js +113 -0
  108. package/dist/src/agents/a2aUtils.js.map +1 -0
  109. package/dist/src/agents/a2aUtils.test.js +147 -0
  110. package/dist/src/agents/a2aUtils.test.js.map +1 -0
  111. package/dist/src/agents/agentLoader.d.ts +68 -0
  112. package/dist/src/agents/agentLoader.js +255 -0
  113. package/dist/src/agents/agentLoader.js.map +1 -0
  114. package/dist/src/agents/agentLoader.test.js +307 -0
  115. package/dist/src/agents/agentLoader.test.js.map +1 -0
  116. package/dist/src/agents/cli-help-agent.d.ts +24 -0
  117. package/dist/src/agents/cli-help-agent.js +85 -0
  118. package/dist/src/agents/cli-help-agent.js.map +1 -0
  119. package/dist/src/agents/cli-help-agent.test.d.ts +6 -0
  120. package/dist/src/agents/cli-help-agent.test.js +65 -0
  121. package/dist/src/agents/cli-help-agent.test.js.map +1 -0
  122. package/dist/src/agents/codebase-investigator.d.ts +2 -2
  123. package/dist/src/agents/codebase-investigator.js +14 -8
  124. package/dist/src/agents/codebase-investigator.js.map +1 -1
  125. package/dist/src/agents/delegate-to-agent-tool.d.ts +19 -0
  126. package/dist/src/agents/delegate-to-agent-tool.js +122 -0
  127. package/dist/src/agents/delegate-to-agent-tool.js.map +1 -0
  128. package/dist/src/agents/delegate-to-agent-tool.test.d.ts +6 -0
  129. package/dist/src/agents/delegate-to-agent-tool.test.js +213 -0
  130. package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
  131. package/dist/src/agents/{executor.d.ts → local-executor.d.ts} +5 -11
  132. package/dist/src/agents/{executor.js → local-executor.js} +124 -63
  133. package/dist/src/agents/local-executor.js.map +1 -0
  134. package/dist/src/agents/local-executor.test.d.ts +6 -0
  135. package/dist/src/agents/{executor.test.js → local-executor.test.js} +136 -58
  136. package/dist/src/agents/local-executor.test.js.map +1 -0
  137. package/dist/src/agents/{invocation.d.ts → local-invocation.d.ts} +6 -7
  138. package/dist/src/agents/{invocation.js → local-invocation.js} +9 -10
  139. package/dist/src/agents/local-invocation.js.map +1 -0
  140. package/dist/src/agents/local-invocation.test.d.ts +6 -0
  141. package/dist/src/agents/{invocation.test.js → local-invocation.test.js} +29 -20
  142. package/dist/src/agents/local-invocation.test.js.map +1 -0
  143. package/dist/src/agents/registry.d.ts +37 -1
  144. package/dist/src/agents/registry.js +240 -27
  145. package/dist/src/agents/registry.js.map +1 -1
  146. package/dist/src/agents/registry.test.js +465 -30
  147. package/dist/src/agents/registry.test.js.map +1 -1
  148. package/dist/src/agents/remote-invocation.d.ts +35 -0
  149. package/dist/src/agents/remote-invocation.js +126 -0
  150. package/dist/src/agents/remote-invocation.js.map +1 -0
  151. package/dist/src/agents/remote-invocation.test.d.ts +6 -0
  152. package/dist/src/agents/remote-invocation.test.js +201 -0
  153. package/dist/src/agents/remote-invocation.test.js.map +1 -0
  154. package/dist/src/agents/subagent-tool-wrapper.d.ts +2 -2
  155. package/dist/src/agents/subagent-tool-wrapper.js +11 -6
  156. package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
  157. package/dist/src/agents/subagent-tool-wrapper.test.js +33 -19
  158. package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
  159. package/dist/src/agents/types.d.ts +21 -15
  160. package/dist/src/agents/types.js.map +1 -1
  161. package/dist/src/availability/errorClassification.d.ts +7 -0
  162. package/dist/src/availability/errorClassification.js +20 -0
  163. package/dist/src/availability/errorClassification.js.map +1 -0
  164. package/dist/src/availability/fallbackIntegration.test.d.ts +6 -0
  165. package/dist/src/availability/fallbackIntegration.test.js +58 -0
  166. package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
  167. package/dist/src/availability/modelAvailabilityService.d.ts +3 -1
  168. package/dist/src/availability/modelAvailabilityService.js +3 -0
  169. package/dist/src/availability/modelAvailabilityService.js.map +1 -1
  170. package/dist/src/availability/modelPolicy.d.ts +8 -1
  171. package/dist/src/availability/policyCatalog.d.ts +1 -0
  172. package/dist/src/availability/policyCatalog.js +6 -7
  173. package/dist/src/availability/policyCatalog.js.map +1 -1
  174. package/dist/src/availability/policyCatalog.test.js +2 -2
  175. package/dist/src/availability/policyCatalog.test.js.map +1 -1
  176. package/dist/src/availability/policyHelpers.d.ts +34 -3
  177. package/dist/src/availability/policyHelpers.js +104 -13
  178. package/dist/src/availability/policyHelpers.js.map +1 -1
  179. package/dist/src/availability/policyHelpers.test.js +143 -13
  180. package/dist/src/availability/policyHelpers.test.js.map +1 -1
  181. package/dist/src/availability/testUtils.d.ts +10 -0
  182. package/dist/src/availability/testUtils.js +22 -0
  183. package/dist/src/availability/testUtils.js.map +1 -0
  184. package/dist/src/code_assist/experiments/client_metadata.js +2 -1
  185. package/dist/src/code_assist/experiments/client_metadata.js.map +1 -1
  186. package/dist/src/code_assist/experiments/client_metadata.test.js +7 -10
  187. package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -1
  188. package/dist/src/code_assist/experiments/experiments.d.ts +1 -1
  189. package/dist/src/code_assist/experiments/experiments.js +21 -0
  190. package/dist/src/code_assist/experiments/experiments.js.map +1 -1
  191. package/dist/src/code_assist/experiments/experiments_local.test.d.ts +6 -0
  192. package/dist/src/code_assist/experiments/experiments_local.test.js +110 -0
  193. package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
  194. package/dist/src/code_assist/oauth-credential-storage.js +3 -4
  195. package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
  196. package/dist/src/code_assist/oauth2.d.ts +2 -0
  197. package/dist/src/code_assist/oauth2.js +70 -14
  198. package/dist/src/code_assist/oauth2.js.map +1 -1
  199. package/dist/src/code_assist/oauth2.test.js +224 -22
  200. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  201. package/dist/src/code_assist/server.d.ts +9 -1
  202. package/dist/src/code_assist/server.js +74 -11
  203. package/dist/src/code_assist/server.js.map +1 -1
  204. package/dist/src/code_assist/server.test.js +199 -27
  205. package/dist/src/code_assist/server.test.js.map +1 -1
  206. package/dist/src/code_assist/setup.js +6 -4
  207. package/dist/src/code_assist/setup.js.map +1 -1
  208. package/dist/src/code_assist/setup.test.js +63 -0
  209. package/dist/src/code_assist/setup.test.js.map +1 -1
  210. package/dist/src/code_assist/telemetry.d.ts +14 -0
  211. package/dist/src/code_assist/telemetry.js +157 -0
  212. package/dist/src/code_assist/telemetry.js.map +1 -0
  213. package/dist/src/code_assist/telemetry.test.d.ts +6 -0
  214. package/dist/src/code_assist/telemetry.test.js +301 -0
  215. package/dist/src/code_assist/telemetry.test.js.map +1 -0
  216. package/dist/src/code_assist/types.d.ts +77 -1
  217. package/dist/src/code_assist/types.js +28 -0
  218. package/dist/src/code_assist/types.js.map +1 -1
  219. package/dist/src/commands/init.d.ts +7 -0
  220. package/dist/src/commands/init.js +53 -0
  221. package/dist/src/commands/init.js.map +1 -0
  222. package/dist/src/commands/init.test.d.ts +6 -0
  223. package/dist/src/commands/init.test.js +25 -0
  224. package/dist/src/commands/init.test.js.map +1 -0
  225. package/dist/src/commands/memory.d.ts +11 -0
  226. package/dist/src/commands/memory.js +80 -0
  227. package/dist/src/commands/memory.js.map +1 -0
  228. package/dist/src/commands/memory.test.d.ts +6 -0
  229. package/dist/src/commands/memory.test.js +155 -0
  230. package/dist/src/commands/memory.test.js.map +1 -0
  231. package/dist/src/commands/restore.d.ts +9 -0
  232. package/dist/src/commands/restore.js +46 -0
  233. package/dist/src/commands/restore.js.map +1 -0
  234. package/dist/src/commands/restore.test.d.ts +6 -0
  235. package/dist/src/commands/restore.test.js +137 -0
  236. package/dist/src/commands/restore.test.js.map +1 -0
  237. package/dist/src/commands/types.d.ts +41 -0
  238. package/dist/src/commands/types.js +7 -0
  239. package/dist/src/commands/types.js.map +1 -0
  240. package/dist/src/config/config.d.ts +145 -25
  241. package/dist/src/config/config.js +370 -132
  242. package/dist/src/config/config.js.map +1 -1
  243. package/dist/src/config/config.test.js +416 -50
  244. package/dist/src/config/config.test.js.map +1 -1
  245. package/dist/src/config/defaultModelConfigs.js +21 -0
  246. package/dist/src/config/defaultModelConfigs.js.map +1 -1
  247. package/dist/src/config/flashFallback.test.js +11 -35
  248. package/dist/src/config/flashFallback.test.js.map +1 -1
  249. package/dist/src/config/models.d.ts +36 -15
  250. package/dist/src/config/models.js +89 -28
  251. package/dist/src/config/models.js.map +1 -1
  252. package/dist/src/config/models.test.js +107 -77
  253. package/dist/src/config/models.test.js.map +1 -1
  254. package/dist/src/config/storage.d.ts +5 -0
  255. package/dist/src/config/storage.js +17 -2
  256. package/dist/src/config/storage.js.map +1 -1
  257. package/dist/src/config/storage.test.js +16 -0
  258. package/dist/src/config/storage.test.js.map +1 -1
  259. package/dist/src/confirmation-bus/message-bus.js +3 -1
  260. package/dist/src/confirmation-bus/message-bus.js.map +1 -1
  261. package/dist/src/confirmation-bus/types.d.ts +4 -0
  262. package/dist/src/core/baseLlmClient.d.ts +3 -1
  263. package/dist/src/core/baseLlmClient.js +60 -22
  264. package/dist/src/core/baseLlmClient.js.map +1 -1
  265. package/dist/src/core/baseLlmClient.test.js +177 -7
  266. package/dist/src/core/baseLlmClient.test.js.map +1 -1
  267. package/dist/src/core/client.d.ts +7 -1
  268. package/dist/src/core/client.js +261 -96
  269. package/dist/src/core/client.js.map +1 -1
  270. package/dist/src/core/client.test.js +397 -67
  271. package/dist/src/core/client.test.js.map +1 -1
  272. package/dist/src/core/clientHookTriggers.js +2 -2
  273. package/dist/src/core/clientHookTriggers.js.map +1 -1
  274. package/dist/src/core/contentGenerator.js +6 -4
  275. package/dist/src/core/contentGenerator.js.map +1 -1
  276. package/dist/src/core/contentGenerator.test.js +24 -23
  277. package/dist/src/core/contentGenerator.test.js.map +1 -1
  278. package/dist/src/core/coreToolHookTriggers.d.ts +9 -5
  279. package/dist/src/core/coreToolHookTriggers.js +119 -21
  280. package/dist/src/core/coreToolHookTriggers.js.map +1 -1
  281. package/dist/src/core/coreToolHookTriggers.test.d.ts +6 -0
  282. package/dist/src/core/coreToolHookTriggers.test.js +191 -0
  283. package/dist/src/core/coreToolHookTriggers.test.js.map +1 -0
  284. package/dist/src/core/coreToolScheduler.d.ts +7 -93
  285. package/dist/src/core/coreToolScheduler.js +139 -333
  286. package/dist/src/core/coreToolScheduler.js.map +1 -1
  287. package/dist/src/core/coreToolScheduler.test.js +304 -348
  288. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  289. package/dist/src/core/geminiChat.d.ts +26 -1
  290. package/dist/src/core/geminiChat.js +144 -80
  291. package/dist/src/core/geminiChat.js.map +1 -1
  292. package/dist/src/core/geminiChat.test.js +334 -253
  293. package/dist/src/core/geminiChat.test.js.map +1 -1
  294. package/dist/src/core/geminiChatHookTriggers.d.ts +8 -4
  295. package/dist/src/core/geminiChatHookTriggers.js +34 -12
  296. package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
  297. package/dist/src/core/geminiChatHookTriggers.test.d.ts +6 -0
  298. package/dist/src/core/geminiChatHookTriggers.test.js +153 -0
  299. package/dist/src/core/geminiChatHookTriggers.test.js.map +1 -0
  300. package/dist/src/core/geminiChat_network_retry.test.d.ts +6 -0
  301. package/dist/src/core/geminiChat_network_retry.test.js +196 -0
  302. package/dist/src/core/geminiChat_network_retry.test.js.map +1 -0
  303. package/dist/src/core/logger.js.map +1 -1
  304. package/dist/src/core/loggingContentGenerator.js +19 -2
  305. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  306. package/dist/src/core/loggingContentGenerator.test.js +30 -0
  307. package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
  308. package/dist/src/core/nonInteractiveToolExecutor.test.js +7 -8
  309. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  310. package/dist/src/core/prompts.js +48 -22
  311. package/dist/src/core/prompts.js.map +1 -1
  312. package/dist/src/core/prompts.test.js +66 -11
  313. package/dist/src/core/prompts.test.js.map +1 -1
  314. package/dist/src/core/tokenLimits.js +6 -12
  315. package/dist/src/core/tokenLimits.js.map +1 -1
  316. package/dist/src/core/tokenLimits.test.js +8 -4
  317. package/dist/src/core/tokenLimits.test.js.map +1 -1
  318. package/dist/src/core/turn.d.ts +21 -21
  319. package/dist/src/core/turn.js +32 -22
  320. package/dist/src/core/turn.js.map +1 -1
  321. package/dist/src/core/turn.test.js +79 -5
  322. package/dist/src/core/turn.test.js.map +1 -1
  323. package/dist/src/fallback/handler.js +55 -120
  324. package/dist/src/fallback/handler.js.map +1 -1
  325. package/dist/src/fallback/handler.test.js +115 -288
  326. package/dist/src/fallback/handler.test.js.map +1 -1
  327. package/dist/src/generated/git-commit.d.ts +3 -3
  328. package/dist/src/generated/git-commit.js +3 -3
  329. package/dist/src/hooks/hookAggregator.js +7 -0
  330. package/dist/src/hooks/hookAggregator.js.map +1 -1
  331. package/dist/src/hooks/hookEventHandler.d.ts +9 -5
  332. package/dist/src/hooks/hookEventHandler.js +120 -16
  333. package/dist/src/hooks/hookEventHandler.js.map +1 -1
  334. package/dist/src/hooks/hookEventHandler.test.js +231 -9
  335. package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
  336. package/dist/src/hooks/hookPlanner.d.ts +1 -5
  337. package/dist/src/hooks/hookPlanner.js +2 -7
  338. package/dist/src/hooks/hookPlanner.js.map +1 -1
  339. package/dist/src/hooks/hookPlanner.test.js +62 -2
  340. package/dist/src/hooks/hookPlanner.test.js.map +1 -1
  341. package/dist/src/hooks/hookRegistry.d.ts +6 -18
  342. package/dist/src/hooks/hookRegistry.js +49 -35
  343. package/dist/src/hooks/hookRegistry.js.map +1 -1
  344. package/dist/src/hooks/hookRegistry.test.js +167 -8
  345. package/dist/src/hooks/hookRegistry.test.js.map +1 -1
  346. package/dist/src/hooks/hookRunner.d.ts +5 -3
  347. package/dist/src/hooks/hookRunner.js +68 -18
  348. package/dist/src/hooks/hookRunner.js.map +1 -1
  349. package/dist/src/hooks/hookRunner.test.js +173 -36
  350. package/dist/src/hooks/hookRunner.test.js.map +1 -1
  351. package/dist/src/hooks/hookSystem.d.ts +10 -6
  352. package/dist/src/hooks/hookSystem.js +36 -16
  353. package/dist/src/hooks/hookSystem.js.map +1 -1
  354. package/dist/src/hooks/hookSystem.test.js +123 -18
  355. package/dist/src/hooks/hookSystem.test.js.map +1 -1
  356. package/dist/src/hooks/hookTranslator.js +2 -1
  357. package/dist/src/hooks/hookTranslator.js.map +1 -1
  358. package/dist/src/hooks/index.d.ts +2 -1
  359. package/dist/src/hooks/index.js +1 -0
  360. package/dist/src/hooks/index.js.map +1 -1
  361. package/dist/src/hooks/trustedHooks.d.ts +28 -0
  362. package/dist/src/hooks/trustedHooks.js +90 -0
  363. package/dist/src/hooks/trustedHooks.js.map +1 -0
  364. package/dist/src/hooks/trustedHooks.test.d.ts +6 -0
  365. package/dist/src/hooks/trustedHooks.test.js +154 -0
  366. package/dist/src/hooks/trustedHooks.test.js.map +1 -0
  367. package/dist/src/hooks/types.d.ts +42 -11
  368. package/dist/src/hooks/types.js +31 -42
  369. package/dist/src/hooks/types.js.map +1 -1
  370. package/dist/src/hooks/types.test.js +9 -52
  371. package/dist/src/hooks/types.test.js.map +1 -1
  372. package/dist/src/ide/detect-ide.d.ts +4 -0
  373. package/dist/src/ide/detect-ide.js +7 -2
  374. package/dist/src/ide/detect-ide.js.map +1 -1
  375. package/dist/src/ide/detect-ide.test.js +42 -1
  376. package/dist/src/ide/detect-ide.test.js.map +1 -1
  377. package/dist/src/ide/ide-client.js +6 -1
  378. package/dist/src/ide/ide-client.js.map +1 -1
  379. package/dist/src/ide/ide-installer.js +2 -2
  380. package/dist/src/ide/ide-installer.js.map +1 -1
  381. package/dist/src/ide/ide-installer.test.js +12 -3
  382. package/dist/src/ide/ide-installer.test.js.map +1 -1
  383. package/dist/src/index.d.ts +23 -1
  384. package/dist/src/index.js +25 -2
  385. package/dist/src/index.js.map +1 -1
  386. package/dist/src/mcp/oauth-provider.js +7 -3
  387. package/dist/src/mcp/oauth-provider.js.map +1 -1
  388. package/dist/src/mcp/oauth-provider.test.js +4 -1
  389. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  390. package/dist/src/mcp/oauth-utils.d.ts +8 -1
  391. package/dist/src/mcp/oauth-utils.js +31 -2
  392. package/dist/src/mcp/oauth-utils.js.map +1 -1
  393. package/dist/src/mcp/oauth-utils.test.js +42 -0
  394. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  395. package/dist/src/mcp/token-storage/file-token-storage.js +2 -2
  396. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
  397. package/dist/src/mcp/token-storage/keychain-token-storage.js +1 -1
  398. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
  399. package/dist/src/output/json-formatter.d.ts +2 -2
  400. package/dist/src/output/json-formatter.js +6 -3
  401. package/dist/src/output/json-formatter.js.map +1 -1
  402. package/dist/src/output/json-formatter.test.js +37 -9
  403. package/dist/src/output/json-formatter.test.js.map +1 -1
  404. package/dist/src/output/stream-json-formatter.js +6 -0
  405. package/dist/src/output/stream-json-formatter.js.map +1 -1
  406. package/dist/src/output/stream-json-formatter.test.js +98 -100
  407. package/dist/src/output/stream-json-formatter.test.js.map +1 -1
  408. package/dist/src/output/types.d.ts +3 -0
  409. package/dist/src/output/types.js.map +1 -1
  410. package/dist/src/policy/config.js +140 -15
  411. package/dist/src/policy/config.js.map +1 -1
  412. package/dist/src/policy/config.test.js +24 -2
  413. package/dist/src/policy/config.test.js.map +1 -1
  414. package/dist/src/policy/persistence.test.d.ts +6 -0
  415. package/dist/src/policy/persistence.test.js +154 -0
  416. package/dist/src/policy/persistence.test.js.map +1 -0
  417. package/dist/src/policy/policies/agent.toml +31 -0
  418. package/dist/src/policy/policies/write.toml +5 -0
  419. package/dist/src/policy/policies/yolo.toml +1 -0
  420. package/dist/src/policy/policy-engine.d.ts +14 -1
  421. package/dist/src/policy/policy-engine.js +165 -7
  422. package/dist/src/policy/policy-engine.js.map +1 -1
  423. package/dist/src/policy/policy-engine.test.js +315 -3
  424. package/dist/src/policy/policy-engine.test.js.map +1 -1
  425. package/dist/src/policy/policy-updater.test.d.ts +6 -0
  426. package/dist/src/policy/policy-updater.test.js +116 -0
  427. package/dist/src/policy/policy-updater.test.js.map +1 -0
  428. package/dist/src/policy/shell-safety.test.d.ts +6 -0
  429. package/dist/src/policy/shell-safety.test.js +438 -0
  430. package/dist/src/policy/shell-safety.test.js.map +1 -0
  431. package/dist/src/policy/toml-loader.d.ts +3 -5
  432. package/dist/src/policy/toml-loader.js +43 -60
  433. package/dist/src/policy/toml-loader.js.map +1 -1
  434. package/dist/src/policy/toml-loader.test.js +41 -7
  435. package/dist/src/policy/toml-loader.test.js.map +1 -1
  436. package/dist/src/policy/types.d.ts +25 -0
  437. package/dist/src/policy/utils.d.ts +21 -0
  438. package/dist/src/policy/utils.js +45 -0
  439. package/dist/src/policy/utils.js.map +1 -0
  440. package/dist/src/policy/utils.test.d.ts +6 -0
  441. package/dist/src/policy/utils.test.js +92 -0
  442. package/dist/src/policy/utils.test.js.map +1 -0
  443. package/dist/src/resources/resource-registry.d.ts +30 -0
  444. package/dist/src/resources/resource-registry.js +57 -0
  445. package/dist/src/resources/resource-registry.js.map +1 -0
  446. package/dist/src/resources/resource-registry.test.d.ts +6 -0
  447. package/dist/src/resources/resource-registry.test.js +54 -0
  448. package/dist/src/resources/resource-registry.test.js.map +1 -0
  449. package/dist/src/routing/modelRouterService.js +0 -15
  450. package/dist/src/routing/modelRouterService.js.map +1 -1
  451. package/dist/src/routing/modelRouterService.test.js +0 -62
  452. package/dist/src/routing/modelRouterService.test.js.map +1 -1
  453. package/dist/src/routing/routingStrategy.d.ts +2 -0
  454. package/dist/src/routing/strategies/classifierStrategy.js +10 -21
  455. package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
  456. package/dist/src/routing/strategies/classifierStrategy.test.js +18 -1
  457. package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
  458. package/dist/src/routing/strategies/compositeStrategy.js +4 -2
  459. package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
  460. package/dist/src/routing/strategies/compositeStrategy.test.js +11 -10
  461. package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
  462. package/dist/src/routing/strategies/fallbackStrategy.d.ts +1 -1
  463. package/dist/src/routing/strategies/fallbackStrategy.js +21 -13
  464. package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
  465. package/dist/src/routing/strategies/fallbackStrategy.test.js +76 -39
  466. package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
  467. package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
  468. package/dist/src/routing/strategies/overrideStrategy.js +5 -4
  469. package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
  470. package/dist/src/routing/strategies/overrideStrategy.test.js +14 -0
  471. package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
  472. package/dist/src/safety/checker-runner.js +17 -6
  473. package/dist/src/safety/checker-runner.js.map +1 -1
  474. package/dist/src/scheduler/tool-executor.d.ts +22 -0
  475. package/dist/src/scheduler/tool-executor.js +198 -0
  476. package/dist/src/scheduler/tool-executor.js.map +1 -0
  477. package/dist/src/scheduler/tool-executor.test.d.ts +6 -0
  478. package/dist/src/scheduler/tool-executor.test.js +231 -0
  479. package/dist/src/scheduler/tool-executor.test.js.map +1 -0
  480. package/dist/src/scheduler/tool-modifier.d.ts +23 -0
  481. package/dist/src/scheduler/tool-modifier.js +50 -0
  482. package/dist/src/scheduler/tool-modifier.js.map +1 -0
  483. package/dist/src/scheduler/tool-modifier.test.d.ts +6 -0
  484. package/dist/src/scheduler/tool-modifier.test.js +159 -0
  485. package/dist/src/scheduler/tool-modifier.test.js.map +1 -0
  486. package/dist/src/scheduler/types.d.ts +95 -0
  487. package/dist/src/scheduler/types.js +7 -0
  488. package/dist/src/scheduler/types.js.map +1 -0
  489. package/dist/src/services/chatCompressionService.js +8 -1
  490. package/dist/src/services/chatCompressionService.js.map +1 -1
  491. package/dist/src/services/chatCompressionService.test.js +3 -0
  492. package/dist/src/services/chatCompressionService.test.js.map +1 -1
  493. package/dist/src/services/chatRecordingService.d.ts +21 -1
  494. package/dist/src/services/chatRecordingService.js +57 -2
  495. package/dist/src/services/chatRecordingService.js.map +1 -1
  496. package/dist/src/services/chatRecordingService.test.js +43 -0
  497. package/dist/src/services/chatRecordingService.test.js.map +1 -1
  498. package/dist/src/services/contextManager.d.ts +5 -11
  499. package/dist/src/services/contextManager.js +20 -17
  500. package/dist/src/services/contextManager.js.map +1 -1
  501. package/dist/src/services/contextManager.test.js +40 -41
  502. package/dist/src/services/contextManager.test.js.map +1 -1
  503. package/dist/src/services/environmentSanitization.d.ts +15 -0
  504. package/dist/src/services/environmentSanitization.js +142 -0
  505. package/dist/src/services/environmentSanitization.js.map +1 -0
  506. package/dist/src/services/environmentSanitization.test.d.ts +6 -0
  507. package/dist/src/services/environmentSanitization.test.js +284 -0
  508. package/dist/src/services/environmentSanitization.test.js.map +1 -0
  509. package/dist/src/services/fileSystemService.d.ts +0 -9
  510. package/dist/src/services/fileSystemService.js +0 -11
  511. package/dist/src/services/fileSystemService.js.map +1 -1
  512. package/dist/src/services/gitService.js +15 -1
  513. package/dist/src/services/gitService.js.map +1 -1
  514. package/dist/src/services/gitService.test.js +56 -2
  515. package/dist/src/services/gitService.test.js.map +1 -1
  516. package/dist/src/services/loopDetectionService.js +4 -3
  517. package/dist/src/services/loopDetectionService.js.map +1 -1
  518. package/dist/src/services/loopDetectionService.test.js +14 -8
  519. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  520. package/dist/src/services/modelConfig.golden.test.js +32 -0
  521. package/dist/src/services/modelConfig.golden.test.js.map +1 -1
  522. package/dist/src/services/modelConfig.integration.test.js +3 -3
  523. package/dist/src/services/modelConfig.integration.test.js.map +1 -1
  524. package/dist/src/services/modelConfigService.d.ts +41 -4
  525. package/dist/src/services/modelConfigService.js +135 -75
  526. package/dist/src/services/modelConfigService.js.map +1 -1
  527. package/dist/src/services/modelConfigService.test.js +226 -0
  528. package/dist/src/services/modelConfigService.test.js.map +1 -1
  529. package/dist/src/services/modelConfigServiceTestUtils.d.ts +10 -0
  530. package/dist/src/services/modelConfigServiceTestUtils.js +17 -0
  531. package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
  532. package/dist/src/services/sessionSummaryService.d.ts +28 -0
  533. package/dist/src/services/sessionSummaryService.js +131 -0
  534. package/dist/src/services/sessionSummaryService.js.map +1 -0
  535. package/dist/src/services/sessionSummaryService.test.d.ts +6 -0
  536. package/dist/src/services/sessionSummaryService.test.js +785 -0
  537. package/dist/src/services/sessionSummaryService.test.js.map +1 -0
  538. package/dist/src/services/sessionSummaryUtils.d.ts +16 -0
  539. package/dist/src/services/sessionSummaryUtils.js +129 -0
  540. package/dist/src/services/sessionSummaryUtils.js.map +1 -0
  541. package/dist/src/services/sessionSummaryUtils.test.d.ts +6 -0
  542. package/dist/src/services/sessionSummaryUtils.test.js +137 -0
  543. package/dist/src/services/sessionSummaryUtils.test.js.map +1 -0
  544. package/dist/src/services/shellExecutionService.d.ts +2 -0
  545. package/dist/src/services/shellExecutionService.js +34 -72
  546. package/dist/src/services/shellExecutionService.js.map +1 -1
  547. package/dist/src/services/shellExecutionService.test.js +114 -8
  548. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  549. package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
  550. package/dist/src/services/test-data/resolved-aliases.golden.json +16 -0
  551. package/dist/src/skills/skillLoader.d.ts +31 -0
  552. package/dist/src/skills/skillLoader.js +77 -0
  553. package/dist/src/skills/skillLoader.js.map +1 -0
  554. package/dist/src/skills/skillLoader.test.d.ts +6 -0
  555. package/dist/src/skills/skillLoader.test.js +75 -0
  556. package/dist/src/skills/skillLoader.test.js.map +1 -0
  557. package/dist/src/skills/skillManager.d.ts +69 -0
  558. package/dist/src/skills/skillManager.js +127 -0
  559. package/dist/src/skills/skillManager.js.map +1 -0
  560. package/dist/src/skills/skillManager.test.d.ts +6 -0
  561. package/dist/src/skills/skillManager.test.js +210 -0
  562. package/dist/src/skills/skillManager.test.js.map +1 -0
  563. package/dist/src/telemetry/activity-detector.test.js.map +1 -1
  564. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +19 -9
  565. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +261 -164
  566. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  567. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +223 -27
  568. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  569. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +12 -3
  570. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +26 -5
  571. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  572. package/dist/src/telemetry/config.js +2 -0
  573. package/dist/src/telemetry/config.js.map +1 -1
  574. package/dist/src/telemetry/config.test.js +25 -0
  575. package/dist/src/telemetry/config.test.js.map +1 -1
  576. package/dist/src/telemetry/gcp-exporters.d.ts +4 -3
  577. package/dist/src/telemetry/gcp-exporters.js +8 -4
  578. package/dist/src/telemetry/gcp-exporters.js.map +1 -1
  579. package/dist/src/telemetry/index.d.ts +1 -1
  580. package/dist/src/telemetry/index.js +1 -1
  581. package/dist/src/telemetry/index.js.map +1 -1
  582. package/dist/src/telemetry/loggers.d.ts +4 -3
  583. package/dist/src/telemetry/loggers.js +351 -340
  584. package/dist/src/telemetry/loggers.js.map +1 -1
  585. package/dist/src/telemetry/loggers.test.circular.js +1 -0
  586. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  587. package/dist/src/telemetry/loggers.test.js +71 -15
  588. package/dist/src/telemetry/loggers.test.js.map +1 -1
  589. package/dist/src/telemetry/metrics.test.js.map +1 -1
  590. package/dist/src/telemetry/sdk.d.ts +9 -2
  591. package/dist/src/telemetry/sdk.js +142 -17
  592. package/dist/src/telemetry/sdk.js.map +1 -1
  593. package/dist/src/telemetry/sdk.test.js +130 -28
  594. package/dist/src/telemetry/sdk.test.js.map +1 -1
  595. package/dist/src/telemetry/startupProfiler.js +26 -3
  596. package/dist/src/telemetry/startupProfiler.js.map +1 -1
  597. package/dist/src/telemetry/startupProfiler.test.js +49 -7
  598. package/dist/src/telemetry/startupProfiler.test.js.map +1 -1
  599. package/dist/src/telemetry/telemetry.test.js +10 -3
  600. package/dist/src/telemetry/telemetry.test.js.map +1 -1
  601. package/dist/src/telemetry/trace.js.map +1 -1
  602. package/dist/src/telemetry/types.d.ts +37 -12
  603. package/dist/src/telemetry/types.js +61 -20
  604. package/dist/src/telemetry/types.js.map +1 -1
  605. package/dist/src/telemetry/uiTelemetry.d.ts +1 -0
  606. package/dist/src/telemetry/uiTelemetry.js +2 -0
  607. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  608. package/dist/src/telemetry/uiTelemetry.test.js +4 -0
  609. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  610. package/dist/src/test-utils/mock-message-bus.d.ts +1 -0
  611. package/dist/src/test-utils/mock-message-bus.js +29 -0
  612. package/dist/src/test-utils/mock-message-bus.js.map +1 -1
  613. package/dist/src/test-utils/mock-tool.d.ts +5 -3
  614. package/dist/src/test-utils/mock-tool.js +11 -10
  615. package/dist/src/test-utils/mock-tool.js.map +1 -1
  616. package/dist/src/tools/activate-skill.d.ts +27 -0
  617. package/dist/src/tools/activate-skill.js +133 -0
  618. package/dist/src/tools/activate-skill.js.map +1 -0
  619. package/dist/src/tools/activate-skill.test.d.ts +6 -0
  620. package/dist/src/tools/activate-skill.test.js +113 -0
  621. package/dist/src/tools/activate-skill.test.js.map +1 -0
  622. package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
  623. package/dist/src/tools/confirmation-policy.test.js +143 -0
  624. package/dist/src/tools/confirmation-policy.test.js.map +1 -0
  625. package/dist/src/tools/edit.d.ts +27 -5
  626. package/dist/src/tools/edit.js +460 -136
  627. package/dist/src/tools/edit.js.map +1 -1
  628. package/dist/src/tools/edit.test.js +292 -526
  629. package/dist/src/tools/edit.test.js.map +1 -1
  630. package/dist/src/tools/get-internal-docs.d.ts +27 -0
  631. package/dist/src/tools/get-internal-docs.js +122 -0
  632. package/dist/src/tools/get-internal-docs.js.map +1 -0
  633. package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
  634. package/dist/src/tools/get-internal-docs.test.js +57 -0
  635. package/dist/src/tools/get-internal-docs.test.js.map +1 -0
  636. package/dist/src/tools/glob.d.ts +2 -2
  637. package/dist/src/tools/glob.js +1 -1
  638. package/dist/src/tools/glob.js.map +1 -1
  639. package/dist/src/tools/glob.test.js +2 -1
  640. package/dist/src/tools/glob.test.js.map +1 -1
  641. package/dist/src/tools/grep.d.ts +2 -2
  642. package/dist/src/tools/grep.js +1 -1
  643. package/dist/src/tools/grep.js.map +1 -1
  644. package/dist/src/tools/grep.test.js +5 -4
  645. package/dist/src/tools/grep.test.js.map +1 -1
  646. package/dist/src/tools/ls.d.ts +2 -2
  647. package/dist/src/tools/ls.js +2 -2
  648. package/dist/src/tools/ls.js.map +1 -1
  649. package/dist/src/tools/ls.test.js +2 -1
  650. package/dist/src/tools/ls.test.js.map +1 -1
  651. package/dist/src/tools/mcp-client-manager.d.ts +2 -1
  652. package/dist/src/tools/mcp-client-manager.js +32 -9
  653. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  654. package/dist/src/tools/mcp-client-manager.test.js +41 -10
  655. package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
  656. package/dist/src/tools/mcp-client.d.ts +43 -6
  657. package/dist/src/tools/mcp-client.js +443 -176
  658. package/dist/src/tools/mcp-client.js.map +1 -1
  659. package/dist/src/tools/mcp-client.test.js +664 -39
  660. package/dist/src/tools/mcp-client.test.js.map +1 -1
  661. package/dist/src/tools/mcp-tool.d.ts +20 -5
  662. package/dist/src/tools/mcp-tool.js +21 -8
  663. package/dist/src/tools/mcp-tool.js.map +1 -1
  664. package/dist/src/tools/mcp-tool.test.js +35 -5
  665. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  666. package/dist/src/tools/memoryTool.d.ts +3 -3
  667. package/dist/src/tools/memoryTool.js +3 -4
  668. package/dist/src/tools/memoryTool.js.map +1 -1
  669. package/dist/src/tools/memoryTool.test.js +5 -2
  670. package/dist/src/tools/memoryTool.test.js.map +1 -1
  671. package/dist/src/tools/message-bus-integration.test.js +10 -37
  672. package/dist/src/tools/message-bus-integration.test.js.map +1 -1
  673. package/dist/src/tools/modifiable-tool.js.map +1 -1
  674. package/dist/src/tools/modifiable-tool.test.js +22 -13
  675. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  676. package/dist/src/tools/read-file.d.ts +2 -2
  677. package/dist/src/tools/read-file.js +2 -2
  678. package/dist/src/tools/read-file.js.map +1 -1
  679. package/dist/src/tools/read-file.test.js +3 -2
  680. package/dist/src/tools/read-file.test.js.map +1 -1
  681. package/dist/src/tools/read-many-files.d.ts +2 -2
  682. package/dist/src/tools/read-many-files.js +7 -6
  683. package/dist/src/tools/read-many-files.js.map +1 -1
  684. package/dist/src/tools/read-many-files.test.js +4 -3
  685. package/dist/src/tools/read-many-files.test.js.map +1 -1
  686. package/dist/src/tools/ripGrep.d.ts +3 -2
  687. package/dist/src/tools/ripGrep.js +18 -7
  688. package/dist/src/tools/ripGrep.js.map +1 -1
  689. package/dist/src/tools/ripGrep.test.js +60 -4
  690. package/dist/src/tools/ripGrep.test.js.map +1 -1
  691. package/dist/src/tools/shell.d.ts +5 -7
  692. package/dist/src/tools/shell.js +35 -49
  693. package/dist/src/tools/shell.js.map +1 -1
  694. package/dist/src/tools/shell.test.js +36 -59
  695. package/dist/src/tools/shell.test.js.map +1 -1
  696. package/dist/src/tools/tool-error.d.ts +6 -1
  697. package/dist/src/tools/tool-error.js +6 -0
  698. package/dist/src/tools/tool-error.js.map +1 -1
  699. package/dist/src/tools/tool-names.d.ts +17 -0
  700. package/dist/src/tools/tool-names.js +59 -0
  701. package/dist/src/tools/tool-names.js.map +1 -1
  702. package/dist/src/tools/tool-names.test.d.ts +6 -0
  703. package/dist/src/tools/tool-names.test.js +43 -0
  704. package/dist/src/tools/tool-names.test.js.map +1 -0
  705. package/dist/src/tools/tool-registry.d.ts +11 -7
  706. package/dist/src/tools/tool-registry.js +15 -10
  707. package/dist/src/tools/tool-registry.js.map +1 -1
  708. package/dist/src/tools/tool-registry.test.js +16 -11
  709. package/dist/src/tools/tool-registry.test.js.map +1 -1
  710. package/dist/src/tools/tools.d.ts +27 -6
  711. package/dist/src/tools/tools.js +44 -25
  712. package/dist/src/tools/tools.js.map +1 -1
  713. package/dist/src/tools/tools.test.js +3 -1
  714. package/dist/src/tools/tools.test.js.map +1 -1
  715. package/dist/src/tools/web-fetch.d.ts +2 -2
  716. package/dist/src/tools/web-fetch.js +21 -8
  717. package/dist/src/tools/web-fetch.js.map +1 -1
  718. package/dist/src/tools/web-fetch.test.js +18 -19
  719. package/dist/src/tools/web-fetch.test.js.map +1 -1
  720. package/dist/src/tools/web-search.d.ts +2 -2
  721. package/dist/src/tools/web-search.js +5 -5
  722. package/dist/src/tools/web-search.js.map +1 -1
  723. package/dist/src/tools/web-search.test.js +2 -1
  724. package/dist/src/tools/web-search.test.js.map +1 -1
  725. package/dist/src/tools/write-file.d.ts +2 -2
  726. package/dist/src/tools/write-file.js +14 -6
  727. package/dist/src/tools/write-file.js.map +1 -1
  728. package/dist/src/tools/write-file.test.js +49 -7
  729. package/dist/src/tools/write-file.test.js.map +1 -1
  730. package/dist/src/tools/write-todos.d.ts +2 -2
  731. package/dist/src/tools/write-todos.js +5 -4
  732. package/dist/src/tools/write-todos.js.map +1 -1
  733. package/dist/src/tools/write-todos.test.js +2 -1
  734. package/dist/src/tools/write-todos.test.js.map +1 -1
  735. package/dist/src/utils/apiConversionUtils.d.ts +12 -0
  736. package/dist/src/utils/apiConversionUtils.js +46 -0
  737. package/dist/src/utils/apiConversionUtils.js.map +1 -0
  738. package/dist/src/utils/apiConversionUtils.test.d.ts +6 -0
  739. package/dist/src/utils/apiConversionUtils.test.js +150 -0
  740. package/dist/src/utils/apiConversionUtils.test.js.map +1 -0
  741. package/dist/src/utils/bfsFileSearch.d.ts +8 -0
  742. package/dist/src/utils/bfsFileSearch.js +63 -23
  743. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  744. package/dist/src/utils/bfsFileSearch.test.js +65 -1
  745. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  746. package/dist/src/utils/checkpointUtils.d.ts +82 -0
  747. package/dist/src/utils/checkpointUtils.js +117 -0
  748. package/dist/src/utils/checkpointUtils.js.map +1 -0
  749. package/dist/src/utils/checkpointUtils.test.d.ts +6 -0
  750. package/dist/src/utils/checkpointUtils.test.js +229 -0
  751. package/dist/src/utils/checkpointUtils.test.js.map +1 -0
  752. package/dist/src/utils/debugLogger.d.ts +3 -0
  753. package/dist/src/utils/debugLogger.js +28 -0
  754. package/dist/src/utils/debugLogger.js.map +1 -1
  755. package/dist/src/utils/editCorrector.d.ts +3 -3
  756. package/dist/src/utils/editCorrector.js +27 -10
  757. package/dist/src/utils/editCorrector.js.map +1 -1
  758. package/dist/src/utils/editCorrector.test.js +27 -23
  759. package/dist/src/utils/editCorrector.test.js.map +1 -1
  760. package/dist/src/utils/editor.d.ts +10 -1
  761. package/dist/src/utils/editor.js +48 -19
  762. package/dist/src/utils/editor.js.map +1 -1
  763. package/dist/src/utils/editor.test.js +27 -4
  764. package/dist/src/utils/editor.test.js.map +1 -1
  765. package/dist/src/utils/environmentContext.d.ts +1 -0
  766. package/dist/src/utils/environmentContext.js +4 -0
  767. package/dist/src/utils/environmentContext.js.map +1 -1
  768. package/dist/src/utils/environmentContext.test.js +2 -0
  769. package/dist/src/utils/environmentContext.test.js.map +1 -1
  770. package/dist/src/utils/errorReporting.d.ts +1 -1
  771. package/dist/src/utils/errorReporting.js +13 -12
  772. package/dist/src/utils/errorReporting.js.map +1 -1
  773. package/dist/src/utils/errorReporting.test.js +17 -14
  774. package/dist/src/utils/errorReporting.test.js.map +1 -1
  775. package/dist/src/utils/errors.d.ts +8 -0
  776. package/dist/src/utils/errors.js +39 -2
  777. package/dist/src/utils/errors.js.map +1 -1
  778. package/dist/src/utils/errors.test.d.ts +6 -0
  779. package/dist/src/utils/errors.test.js +155 -0
  780. package/dist/src/utils/errors.test.js.map +1 -0
  781. package/dist/src/utils/events.d.ts +71 -19
  782. package/dist/src/utils/events.js +35 -9
  783. package/dist/src/utils/events.js.map +1 -1
  784. package/dist/src/utils/events.test.js +25 -0
  785. package/dist/src/utils/events.test.js.map +1 -1
  786. package/dist/src/utils/extensionLoader.d.ts +2 -2
  787. package/dist/src/utils/extensionLoader.js +5 -6
  788. package/dist/src/utils/extensionLoader.js.map +1 -1
  789. package/dist/src/utils/extensionLoader.test.js +11 -0
  790. package/dist/src/utils/extensionLoader.test.js.map +1 -1
  791. package/dist/src/utils/fetch.d.ts +1 -1
  792. package/dist/src/utils/fetch.js +3 -3
  793. package/dist/src/utils/fetch.js.map +1 -1
  794. package/dist/src/utils/fileDiffUtils.d.ts +18 -0
  795. package/dist/src/utils/fileDiffUtils.js +37 -0
  796. package/dist/src/utils/fileDiffUtils.js.map +1 -0
  797. package/dist/src/utils/fileDiffUtils.test.d.ts +6 -0
  798. package/dist/src/utils/fileDiffUtils.test.js +84 -0
  799. package/dist/src/utils/fileDiffUtils.test.js.map +1 -0
  800. package/dist/src/utils/fileUtils.d.ts +4 -0
  801. package/dist/src/utils/fileUtils.js +53 -0
  802. package/dist/src/utils/fileUtils.js.map +1 -1
  803. package/dist/src/utils/fileUtils.test.js +127 -1
  804. package/dist/src/utils/fileUtils.test.js.map +1 -1
  805. package/dist/src/utils/filesearch/crawlCache.js.map +1 -1
  806. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  807. package/dist/src/utils/flashFallback.test.js +1 -1
  808. package/dist/src/utils/flashFallback.test.js.map +1 -1
  809. package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
  810. package/dist/src/utils/geminiIgnoreParser.js +20 -0
  811. package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
  812. package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
  813. package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
  814. package/dist/src/utils/generateContentResponseUtilities.d.ts +3 -1
  815. package/dist/src/utils/generateContentResponseUtilities.js +106 -0
  816. package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
  817. package/dist/src/utils/generateContentResponseUtilities.test.js +279 -2
  818. package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
  819. package/dist/src/utils/getFolderStructure.js +7 -2
  820. package/dist/src/utils/getFolderStructure.js.map +1 -1
  821. package/dist/src/utils/gitIgnoreParser.js +9 -10
  822. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  823. package/dist/src/utils/googleErrors.js +31 -18
  824. package/dist/src/utils/googleErrors.js.map +1 -1
  825. package/dist/src/utils/googleErrors.test.js +10 -2
  826. package/dist/src/utils/googleErrors.test.js.map +1 -1
  827. package/dist/src/utils/googleQuotaErrors.d.ts +3 -3
  828. package/dist/src/utils/googleQuotaErrors.js +32 -6
  829. package/dist/src/utils/googleQuotaErrors.js.map +1 -1
  830. package/dist/src/utils/googleQuotaErrors.test.js +94 -2
  831. package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
  832. package/dist/src/utils/installationManager.test.js +11 -3
  833. package/dist/src/utils/installationManager.test.js.map +1 -1
  834. package/dist/src/utils/memoryDiscovery.js +3 -4
  835. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  836. package/dist/src/utils/memoryDiscovery.test.js +12 -1
  837. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  838. package/dist/src/utils/nextSpeakerChecker.test.js +4 -0
  839. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  840. package/dist/src/utils/partUtils.js +1 -1
  841. package/dist/src/utils/partUtils.js.map +1 -1
  842. package/dist/src/utils/pathCorrector.js +12 -2
  843. package/dist/src/utils/pathCorrector.js.map +1 -1
  844. package/dist/src/utils/pathCorrector.test.js +6 -2
  845. package/dist/src/utils/pathCorrector.test.js.map +1 -1
  846. package/dist/src/utils/paths.d.ts +10 -0
  847. package/dist/src/utils/paths.js +20 -1
  848. package/dist/src/utils/paths.js.map +1 -1
  849. package/dist/src/utils/retry.d.ts +12 -0
  850. package/dist/src/utils/retry.js +70 -17
  851. package/dist/src/utils/retry.js.map +1 -1
  852. package/dist/src/utils/retry.test.js +181 -21
  853. package/dist/src/utils/retry.test.js.map +1 -1
  854. package/dist/src/utils/shell-utils.d.ts +16 -47
  855. package/dist/src/utils/shell-utils.js +98 -194
  856. package/dist/src/utils/shell-utils.js.map +1 -1
  857. package/dist/src/utils/shell-utils.test.js +99 -288
  858. package/dist/src/utils/shell-utils.test.js.map +1 -1
  859. package/dist/src/utils/summarizer.test.js +3 -2
  860. package/dist/src/utils/summarizer.test.js.map +1 -1
  861. package/dist/src/utils/terminal.d.ts +4 -0
  862. package/dist/src/utils/terminal.js +12 -0
  863. package/dist/src/utils/terminal.js.map +1 -1
  864. package/dist/src/utils/terminalSerializer.test.js +17 -0
  865. package/dist/src/utils/terminalSerializer.test.js.map +1 -1
  866. package/dist/src/utils/tokenCalculation.js +20 -5
  867. package/dist/src/utils/tokenCalculation.js.map +1 -1
  868. package/dist/src/utils/tokenCalculation.test.js +11 -2
  869. package/dist/src/utils/tokenCalculation.test.js.map +1 -1
  870. package/dist/src/utils/tool-utils.d.ts +9 -0
  871. package/dist/src/utils/tool-utils.js +29 -0
  872. package/dist/src/utils/tool-utils.js.map +1 -1
  873. package/dist/src/utils/tool-utils.test.js +17 -2
  874. package/dist/src/utils/tool-utils.test.js.map +1 -1
  875. package/dist/src/utils/userAccountManager.test.js +5 -5
  876. package/dist/src/utils/userAccountManager.test.js.map +1 -1
  877. package/dist/src/utils/version.d.ts +6 -0
  878. package/dist/src/utils/version.js +15 -0
  879. package/dist/src/utils/version.js.map +1 -0
  880. package/dist/src/utils/version.test.d.ts +6 -0
  881. package/dist/src/utils/version.test.js +39 -0
  882. package/dist/src/utils/version.test.js.map +1 -0
  883. package/dist/src/utils/workspaceContext.test.js +1 -1
  884. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  885. package/dist/tsconfig.tsbuildinfo +1 -1
  886. package/package.json +8 -6
  887. package/dist/src/agents/executor.js.map +0 -1
  888. package/dist/src/agents/executor.test.js.map +0 -1
  889. package/dist/src/agents/invocation.js.map +0 -1
  890. package/dist/src/agents/invocation.test.js.map +0 -1
  891. package/dist/src/tools/smart-edit.d.ts +0 -78
  892. package/dist/src/tools/smart-edit.js +0 -717
  893. package/dist/src/tools/smart-edit.js.map +0 -1
  894. package/dist/src/tools/smart-edit.test.js +0 -592
  895. package/dist/src/tools/smart-edit.test.js.map +0 -1
  896. /package/dist/src/agents/{executor.test.d.ts → a2a-client-manager.test.d.ts} +0 -0
  897. /package/dist/src/agents/{invocation.test.d.ts → a2aUtils.test.d.ts} +0 -0
  898. /package/dist/src/{tools/smart-edit.test.d.ts → agents/agentLoader.test.d.ts} +0 -0
@@ -5,21 +5,23 @@
5
5
  */
6
6
  import * as fs from 'node:fs';
7
7
  import * as path from 'node:path';
8
+ import * as crypto from 'node:crypto';
8
9
  import * as Diff from 'diff';
9
10
  import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
10
11
  import { ToolErrorType } from './tool-error.js';
11
12
  import { makeRelative, shortenPath } from '../utils/paths.js';
12
13
  import { isNodeError } from '../utils/errors.js';
13
14
  import { ApprovalMode } from '../policy/types.js';
14
- import { ensureCorrectEdit } from '../utils/editCorrector.js';
15
15
  import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
16
- import { logFileOperation } from '../telemetry/loggers.js';
17
- import { FileOperationEvent } from '../telemetry/types.js';
18
- import { FileOperation } from '../telemetry/metrics.js';
19
- import { getSpecificMimeType } from '../utils/fileUtils.js';
20
- import { getLanguageFromFilePath } from '../utils/language-detection.js';
16
+ import {} from './modifiable-tool.js';
21
17
  import { IdeClient } from '../ide/ide-client.js';
18
+ import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
22
19
  import { safeLiteralReplace } from '../utils/textUtils.js';
20
+ import { EditStrategyEvent } from '../telemetry/types.js';
21
+ import { logEditStrategy } from '../telemetry/loggers.js';
22
+ import { EditCorrectionEvent } from '../telemetry/types.js';
23
+ import { logEditCorrectionEvent } from '../telemetry/loggers.js';
24
+ import { correctPath } from '../utils/pathCorrector.js';
23
25
  import { EDIT_TOOL_NAME, READ_FILE_TOOL_NAME } from './tool-names.js';
24
26
  import { debugLogger } from '../utils/debugLogger.js';
25
27
  export function applyReplacement(currentContent, oldString, newString, isNewFile) {
@@ -37,16 +39,295 @@ export function applyReplacement(currentContent, oldString, newString, isNewFile
37
39
  // Use intelligent replacement that handles $ sequences safely
38
40
  return safeLiteralReplace(currentContent, oldString, newString);
39
41
  }
42
+ /**
43
+ * Creates a SHA256 hash of the given content.
44
+ * @param content The string content to hash.
45
+ * @returns A hex-encoded hash string.
46
+ */
47
+ function hashContent(content) {
48
+ return crypto.createHash('sha256').update(content).digest('hex');
49
+ }
50
+ function restoreTrailingNewline(originalContent, modifiedContent) {
51
+ const hadTrailingNewline = originalContent.endsWith('\n');
52
+ if (hadTrailingNewline && !modifiedContent.endsWith('\n')) {
53
+ return modifiedContent + '\n';
54
+ }
55
+ else if (!hadTrailingNewline && modifiedContent.endsWith('\n')) {
56
+ return modifiedContent.replace(/\n$/, '');
57
+ }
58
+ return modifiedContent;
59
+ }
60
+ /**
61
+ * Escapes characters with special meaning in regular expressions.
62
+ * @param str The string to escape.
63
+ * @returns The escaped string.
64
+ */
65
+ function escapeRegex(str) {
66
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
67
+ }
68
+ async function calculateExactReplacement(context) {
69
+ const { currentContent, params } = context;
70
+ const { old_string, new_string } = params;
71
+ const normalizedCode = currentContent;
72
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
73
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
74
+ const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
75
+ if (exactOccurrences > 0) {
76
+ let modifiedCode = safeLiteralReplace(normalizedCode, normalizedSearch, normalizedReplace);
77
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
78
+ return {
79
+ newContent: modifiedCode,
80
+ occurrences: exactOccurrences,
81
+ finalOldString: normalizedSearch,
82
+ finalNewString: normalizedReplace,
83
+ };
84
+ }
85
+ return null;
86
+ }
87
+ async function calculateFlexibleReplacement(context) {
88
+ const { currentContent, params } = context;
89
+ const { old_string, new_string } = params;
90
+ const normalizedCode = currentContent;
91
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
92
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
93
+ const sourceLines = normalizedCode.match(/.*(?:\n|$)/g)?.slice(0, -1) ?? [];
94
+ const searchLinesStripped = normalizedSearch
95
+ .split('\n')
96
+ .map((line) => line.trim());
97
+ const replaceLines = normalizedReplace.split('\n');
98
+ let flexibleOccurrences = 0;
99
+ let i = 0;
100
+ while (i <= sourceLines.length - searchLinesStripped.length) {
101
+ const window = sourceLines.slice(i, i + searchLinesStripped.length);
102
+ const windowStripped = window.map((line) => line.trim());
103
+ const isMatch = windowStripped.every((line, index) => line === searchLinesStripped[index]);
104
+ if (isMatch) {
105
+ flexibleOccurrences++;
106
+ const firstLineInMatch = window[0];
107
+ const indentationMatch = firstLineInMatch.match(/^(\s*)/);
108
+ const indentation = indentationMatch ? indentationMatch[1] : '';
109
+ const newBlockWithIndent = replaceLines.map((line) => `${indentation}${line}`);
110
+ sourceLines.splice(i, searchLinesStripped.length, newBlockWithIndent.join('\n'));
111
+ i += replaceLines.length;
112
+ }
113
+ else {
114
+ i++;
115
+ }
116
+ }
117
+ if (flexibleOccurrences > 0) {
118
+ let modifiedCode = sourceLines.join('');
119
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
120
+ return {
121
+ newContent: modifiedCode,
122
+ occurrences: flexibleOccurrences,
123
+ finalOldString: normalizedSearch,
124
+ finalNewString: normalizedReplace,
125
+ };
126
+ }
127
+ return null;
128
+ }
129
+ async function calculateRegexReplacement(context) {
130
+ const { currentContent, params } = context;
131
+ const { old_string, new_string } = params;
132
+ // Normalize line endings for consistent processing.
133
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
134
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
135
+ // This logic is ported from your Python implementation.
136
+ // It builds a flexible, multi-line regex from a search string.
137
+ const delimiters = ['(', ')', ':', '[', ']', '{', '}', '>', '<', '='];
138
+ let processedString = normalizedSearch;
139
+ for (const delim of delimiters) {
140
+ processedString = processedString.split(delim).join(` ${delim} `);
141
+ }
142
+ // Split by any whitespace and remove empty strings.
143
+ const tokens = processedString.split(/\s+/).filter(Boolean);
144
+ if (tokens.length === 0) {
145
+ return null;
146
+ }
147
+ const escapedTokens = tokens.map(escapeRegex);
148
+ // Join tokens with `\s*` to allow for flexible whitespace between them.
149
+ const pattern = escapedTokens.join('\\s*');
150
+ // The final pattern captures leading whitespace (indentation) and then matches the token pattern.
151
+ // 'm' flag enables multi-line mode, so '^' matches the start of any line.
152
+ const finalPattern = `^(\\s*)${pattern}`;
153
+ const flexibleRegex = new RegExp(finalPattern, 'm');
154
+ const match = flexibleRegex.exec(currentContent);
155
+ if (!match) {
156
+ return null;
157
+ }
158
+ const indentation = match[1] || '';
159
+ const newLines = normalizedReplace.split('\n');
160
+ const newBlockWithIndent = newLines
161
+ .map((line) => `${indentation}${line}`)
162
+ .join('\n');
163
+ // Use replace with the regex to substitute the matched content.
164
+ // Since the regex doesn't have the 'g' flag, it will only replace the first occurrence.
165
+ const modifiedCode = currentContent.replace(flexibleRegex, newBlockWithIndent);
166
+ return {
167
+ newContent: restoreTrailingNewline(currentContent, modifiedCode),
168
+ occurrences: 1, // This method is designed to find and replace only the first occurrence.
169
+ finalOldString: normalizedSearch,
170
+ finalNewString: normalizedReplace,
171
+ };
172
+ }
173
+ /**
174
+ * Detects the line ending style of a string.
175
+ * @param content The string content to analyze.
176
+ * @returns '\r\n' for Windows-style, '\n' for Unix-style.
177
+ */
178
+ function detectLineEnding(content) {
179
+ // If a Carriage Return is found, assume Windows-style endings.
180
+ // This is a simple but effective heuristic.
181
+ return content.includes('\r\n') ? '\r\n' : '\n';
182
+ }
183
+ export async function calculateReplacement(config, context) {
184
+ const { currentContent, params } = context;
185
+ const { old_string, new_string } = params;
186
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
187
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
188
+ if (normalizedSearch === '') {
189
+ return {
190
+ newContent: currentContent,
191
+ occurrences: 0,
192
+ finalOldString: normalizedSearch,
193
+ finalNewString: normalizedReplace,
194
+ };
195
+ }
196
+ const exactResult = await calculateExactReplacement(context);
197
+ if (exactResult) {
198
+ const event = new EditStrategyEvent('exact');
199
+ logEditStrategy(config, event);
200
+ return exactResult;
201
+ }
202
+ const flexibleResult = await calculateFlexibleReplacement(context);
203
+ if (flexibleResult) {
204
+ const event = new EditStrategyEvent('flexible');
205
+ logEditStrategy(config, event);
206
+ return flexibleResult;
207
+ }
208
+ const regexResult = await calculateRegexReplacement(context);
209
+ if (regexResult) {
210
+ const event = new EditStrategyEvent('regex');
211
+ logEditStrategy(config, event);
212
+ return regexResult;
213
+ }
214
+ return {
215
+ newContent: currentContent,
216
+ occurrences: 0,
217
+ finalOldString: normalizedSearch,
218
+ finalNewString: normalizedReplace,
219
+ };
220
+ }
221
+ export function getErrorReplaceResult(params, occurrences, expectedReplacements, finalOldString, finalNewString) {
222
+ let error = undefined;
223
+ if (occurrences === 0) {
224
+ error = {
225
+ display: `Failed to edit, could not find the string to replace.`,
226
+ raw: `Failed to edit, 0 occurrences found for old_string (${finalOldString}). Original old_string was (${params.old_string}) in ${params.file_path}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
227
+ type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
228
+ };
229
+ }
230
+ else if (occurrences !== expectedReplacements) {
231
+ const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
232
+ error = {
233
+ display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
234
+ raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
235
+ type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
236
+ };
237
+ }
238
+ else if (finalOldString === finalNewString) {
239
+ error = {
240
+ display: `No changes to apply. The old_string and new_string are identical.`,
241
+ raw: `No changes to apply. The old_string and new_string are identical in file: ${params.file_path}`,
242
+ type: ToolErrorType.EDIT_NO_CHANGE,
243
+ };
244
+ }
245
+ return error;
246
+ }
40
247
  class EditToolInvocation extends BaseToolInvocation {
41
248
  config;
42
- resolvedPath;
43
249
  constructor(config, params, messageBus, toolName, displayName) {
44
250
  super(params, messageBus, toolName, displayName);
45
251
  this.config = config;
46
- this.resolvedPath = path.resolve(this.config.getTargetDir(), this.params.file_path);
47
252
  }
48
253
  toolLocations() {
49
- return [{ path: this.resolvedPath }];
254
+ return [{ path: this.params.file_path }];
255
+ }
256
+ async attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding) {
257
+ // In order to keep from clobbering edits made outside our system,
258
+ // check if the file has been modified since we first read it.
259
+ let errorForLlmEditFixer = initialError.raw;
260
+ let contentForLlmEditFixer = currentContent;
261
+ const initialContentHash = hashContent(currentContent);
262
+ const onDiskContent = await this.config
263
+ .getFileSystemService()
264
+ .readTextFile(params.file_path);
265
+ const onDiskContentHash = hashContent(onDiskContent.replace(/\r\n/g, '\n'));
266
+ if (initialContentHash !== onDiskContentHash) {
267
+ // The file has changed on disk since we first read it.
268
+ // Use the latest content for the correction attempt.
269
+ contentForLlmEditFixer = onDiskContent.replace(/\r\n/g, '\n');
270
+ errorForLlmEditFixer = `The initial edit attempt failed with the following error: "${initialError.raw}". However, the file has been modified by either the user or an external process since that edit attempt. The file content provided to you is the latest version. Please base your correction on this new content.`;
271
+ }
272
+ const fixedEdit = await FixLLMEditWithInstruction(params.instruction ?? 'Apply the requested edit.', params.old_string, params.new_string, errorForLlmEditFixer, contentForLlmEditFixer, this.config.getBaseLlmClient(), abortSignal);
273
+ // If the self-correction attempt timed out, return the original error.
274
+ if (fixedEdit === null) {
275
+ return {
276
+ currentContent: contentForLlmEditFixer,
277
+ newContent: currentContent,
278
+ occurrences: 0,
279
+ isNewFile: false,
280
+ error: initialError,
281
+ originalLineEnding,
282
+ };
283
+ }
284
+ if (fixedEdit.noChangesRequired) {
285
+ return {
286
+ currentContent,
287
+ newContent: currentContent,
288
+ occurrences: 0,
289
+ isNewFile: false,
290
+ error: {
291
+ display: `No changes required. The file already meets the specified conditions.`,
292
+ raw: `A secondary check by an LLM determined that no changes were necessary to fulfill the instruction. Explanation: ${fixedEdit.explanation}. Original error with the parameters given: ${initialError.raw}`,
293
+ type: ToolErrorType.EDIT_NO_CHANGE_LLM_JUDGEMENT,
294
+ },
295
+ originalLineEnding,
296
+ };
297
+ }
298
+ const secondAttemptResult = await calculateReplacement(this.config, {
299
+ params: {
300
+ ...params,
301
+ old_string: fixedEdit.search,
302
+ new_string: fixedEdit.replace,
303
+ },
304
+ currentContent: contentForLlmEditFixer,
305
+ abortSignal,
306
+ });
307
+ const secondError = getErrorReplaceResult(params, secondAttemptResult.occurrences, params.expected_replacements ?? 1, secondAttemptResult.finalOldString, secondAttemptResult.finalNewString);
308
+ if (secondError) {
309
+ // The fix failed, log failure and return the original error
310
+ const event = new EditCorrectionEvent('failure');
311
+ logEditCorrectionEvent(this.config, event);
312
+ return {
313
+ currentContent: contentForLlmEditFixer,
314
+ newContent: currentContent,
315
+ occurrences: 0,
316
+ isNewFile: false,
317
+ error: initialError,
318
+ originalLineEnding,
319
+ };
320
+ }
321
+ const event = new EditCorrectionEvent('success');
322
+ logEditCorrectionEvent(this.config, event);
323
+ return {
324
+ currentContent: contentForLlmEditFixer,
325
+ newContent: secondAttemptResult.newContent,
326
+ occurrences: secondAttemptResult.occurrences,
327
+ isNewFile: false,
328
+ error: undefined,
329
+ originalLineEnding,
330
+ };
50
331
  }
51
332
  /**
52
333
  * Calculates the potential outcome of an edit operation.
@@ -58,100 +339,103 @@ class EditToolInvocation extends BaseToolInvocation {
58
339
  const expectedReplacements = params.expected_replacements ?? 1;
59
340
  let currentContent = null;
60
341
  let fileExists = false;
61
- let isNewFile = false;
62
- let finalNewString = params.new_string;
63
- let finalOldString = params.old_string;
64
- let occurrences = 0;
65
- let error = undefined;
342
+ let originalLineEnding = '\n'; // Default for new files
66
343
  try {
67
344
  currentContent = await this.config
68
345
  .getFileSystemService()
69
- .readTextFile(this.resolvedPath);
70
- // Normalize line endings to LF for consistent processing.
346
+ .readTextFile(params.file_path);
347
+ originalLineEnding = detectLineEnding(currentContent);
71
348
  currentContent = currentContent.replace(/\r\n/g, '\n');
72
349
  fileExists = true;
73
350
  }
74
351
  catch (err) {
75
352
  if (!isNodeError(err) || err.code !== 'ENOENT') {
76
- // Rethrow unexpected FS errors (permissions, etc.)
77
353
  throw err;
78
354
  }
79
355
  fileExists = false;
80
356
  }
81
- if (params.old_string === '' && !fileExists) {
82
- // Creating a new file
83
- isNewFile = true;
357
+ const isNewFile = params.old_string === '' && !fileExists;
358
+ if (isNewFile) {
359
+ return {
360
+ currentContent,
361
+ newContent: params.new_string,
362
+ occurrences: 1,
363
+ isNewFile: true,
364
+ error: undefined,
365
+ originalLineEnding,
366
+ };
84
367
  }
85
- else if (!fileExists) {
86
- // Trying to edit a nonexistent file (and old_string is not empty)
87
- error = {
88
- display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
89
- raw: `File not found: ${this.resolvedPath}`,
90
- type: ToolErrorType.FILE_NOT_FOUND,
368
+ // after this point, it's not a new file/edit
369
+ if (!fileExists) {
370
+ return {
371
+ currentContent,
372
+ newContent: '',
373
+ occurrences: 0,
374
+ isNewFile: false,
375
+ error: {
376
+ display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
377
+ raw: `File not found: ${params.file_path}`,
378
+ type: ToolErrorType.FILE_NOT_FOUND,
379
+ },
380
+ originalLineEnding,
91
381
  };
92
382
  }
93
- else if (currentContent !== null) {
94
- // Editing an existing file
95
- const correctedEdit = await ensureCorrectEdit(this.resolvedPath, currentContent, params, this.config.getGeminiClient(), this.config.getBaseLlmClient(), abortSignal);
96
- finalOldString = correctedEdit.params.old_string;
97
- finalNewString = correctedEdit.params.new_string;
98
- occurrences = correctedEdit.occurrences;
99
- if (params.old_string === '') {
100
- // Error: Trying to create a file that already exists
101
- error = {
383
+ if (currentContent === null) {
384
+ return {
385
+ currentContent,
386
+ newContent: '',
387
+ occurrences: 0,
388
+ isNewFile: false,
389
+ error: {
390
+ display: `Failed to read content of file.`,
391
+ raw: `Failed to read content of existing file: ${params.file_path}`,
392
+ type: ToolErrorType.READ_CONTENT_FAILURE,
393
+ },
394
+ originalLineEnding,
395
+ };
396
+ }
397
+ if (params.old_string === '') {
398
+ return {
399
+ currentContent,
400
+ newContent: currentContent,
401
+ occurrences: 0,
402
+ isNewFile: false,
403
+ error: {
102
404
  display: `Failed to edit. Attempted to create a file that already exists.`,
103
- raw: `File already exists, cannot create: ${this.resolvedPath}`,
405
+ raw: `File already exists, cannot create: ${params.file_path}`,
104
406
  type: ToolErrorType.ATTEMPT_TO_CREATE_EXISTING_FILE,
105
- };
106
- }
107
- else if (occurrences === 0) {
108
- error = {
109
- display: `Failed to edit, could not find the string to replace.`,
110
- raw: `Failed to edit, 0 occurrences found for old_string in ${this.resolvedPath}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
111
- type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
112
- };
113
- }
114
- else if (occurrences !== expectedReplacements) {
115
- const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
116
- error = {
117
- display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
118
- raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${this.resolvedPath}`,
119
- type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
120
- };
121
- }
122
- else if (finalOldString === finalNewString) {
123
- error = {
124
- display: `No changes to apply. The old_string and new_string are identical.`,
125
- raw: `No changes to apply. The old_string and new_string are identical in file: ${this.resolvedPath}`,
126
- type: ToolErrorType.EDIT_NO_CHANGE,
127
- };
128
- }
407
+ },
408
+ originalLineEnding,
409
+ };
129
410
  }
130
- else {
131
- // Should not happen if fileExists and no exception was thrown, but defensively:
132
- error = {
133
- display: `Failed to read content of file.`,
134
- raw: `Failed to read content of existing file: ${this.resolvedPath}`,
135
- type: ToolErrorType.READ_CONTENT_FAILURE,
411
+ const replacementResult = await calculateReplacement(this.config, {
412
+ params,
413
+ currentContent,
414
+ abortSignal,
415
+ });
416
+ const initialError = getErrorReplaceResult(params, replacementResult.occurrences, expectedReplacements, replacementResult.finalOldString, replacementResult.finalNewString);
417
+ if (!initialError) {
418
+ return {
419
+ currentContent,
420
+ newContent: replacementResult.newContent,
421
+ occurrences: replacementResult.occurrences,
422
+ isNewFile: false,
423
+ error: undefined,
424
+ originalLineEnding,
136
425
  };
137
426
  }
138
- const newContent = !error
139
- ? applyReplacement(currentContent, finalOldString, finalNewString, isNewFile)
140
- : (currentContent ?? '');
141
- if (!error && fileExists && currentContent === newContent) {
142
- error = {
143
- display: 'No changes to apply. The new content is identical to the current content.',
144
- raw: `No changes to apply. The new content is identical to the current content in file: ${this.resolvedPath}`,
145
- type: ToolErrorType.EDIT_NO_CHANGE,
427
+ if (this.config.getDisableLLMCorrection()) {
428
+ return {
429
+ currentContent,
430
+ newContent: currentContent,
431
+ occurrences: replacementResult.occurrences,
432
+ isNewFile: false,
433
+ error: initialError,
434
+ originalLineEnding,
146
435
  };
147
436
  }
148
- return {
149
- currentContent,
150
- newContent,
151
- occurrences,
152
- error,
153
- isNewFile,
154
- };
437
+ // If there was an error, try to self-correct.
438
+ return this.attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding);
155
439
  }
156
440
  /**
157
441
  * Handles the confirmation prompt for the Edit tool in the CLI.
@@ -177,24 +461,29 @@ class EditToolInvocation extends BaseToolInvocation {
177
461
  debugLogger.log(`Error: ${editData.error.display}`);
178
462
  return false;
179
463
  }
180
- const fileName = path.basename(this.resolvedPath);
464
+ const fileName = path.basename(this.params.file_path);
181
465
  const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
182
466
  const ideClient = await IdeClient.getInstance();
183
467
  const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled()
184
- ? ideClient.openDiff(this.resolvedPath, editData.newContent)
468
+ ? ideClient.openDiff(this.params.file_path, editData.newContent)
185
469
  : undefined;
186
470
  const confirmationDetails = {
187
471
  type: 'edit',
188
472
  title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
189
473
  fileName,
190
- filePath: this.resolvedPath,
474
+ filePath: this.params.file_path,
191
475
  fileDiff,
192
476
  originalContent: editData.currentContent,
193
477
  newContent: editData.newContent,
194
478
  onConfirm: async (outcome) => {
195
479
  if (outcome === ToolConfirmationOutcome.ProceedAlways) {
480
+ // No need to publish a policy update as the default policy for
481
+ // AUTO_EDIT already reflects always approving edit.
196
482
  this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
197
483
  }
484
+ else {
485
+ await this.publishPolicyUpdate(outcome);
486
+ }
198
487
  if (ideConfirmation) {
199
488
  const result = await ideConfirmation;
200
489
  if (result.status === 'accepted' && result.content) {
@@ -258,34 +547,40 @@ class EditToolInvocation extends BaseToolInvocation {
258
547
  };
259
548
  }
260
549
  try {
261
- this.ensureParentDirectoriesExist(this.resolvedPath);
550
+ this.ensureParentDirectoriesExist(this.params.file_path);
551
+ let finalContent = editData.newContent;
552
+ // Restore original line endings if they were CRLF
553
+ if (!editData.isNewFile && editData.originalLineEnding === '\r\n') {
554
+ finalContent = finalContent.replace(/\n/g, '\r\n');
555
+ }
262
556
  await this.config
263
557
  .getFileSystemService()
264
- .writeTextFile(this.resolvedPath, editData.newContent);
265
- const fileName = path.basename(this.resolvedPath);
266
- const originallyProposedContent = this.params.ai_proposed_content || editData.newContent;
267
- const diffStat = getDiffStat(fileName, editData.currentContent ?? '', originallyProposedContent, editData.newContent);
268
- const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
269
- editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
270
- const displayResult = {
271
- fileDiff,
272
- fileName,
273
- originalContent: editData.currentContent,
274
- newContent: editData.newContent,
275
- diffStat,
276
- };
277
- // Log file operation for telemetry (without diff_stat to avoid double-counting)
278
- const mimetype = getSpecificMimeType(this.resolvedPath);
279
- const programmingLanguage = getLanguageFromFilePath(this.resolvedPath);
280
- const extension = path.extname(this.resolvedPath);
281
- const operation = editData.isNewFile
282
- ? FileOperation.CREATE
283
- : FileOperation.UPDATE;
284
- logFileOperation(this.config, new FileOperationEvent(EDIT_TOOL_NAME, operation, editData.newContent.split('\n').length, mimetype, extension, programmingLanguage));
558
+ .writeTextFile(this.params.file_path, finalContent);
559
+ let displayResult;
560
+ if (editData.isNewFile) {
561
+ displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
562
+ }
563
+ else {
564
+ // Generate diff for display, even though core logic doesn't technically need it
565
+ // The CLI wrapper will use this part of the ToolResult
566
+ const fileName = path.basename(this.params.file_path);
567
+ const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
568
+ editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
569
+ const diffStat = getDiffStat(fileName, editData.currentContent ?? '', editData.newContent, this.params.new_string);
570
+ displayResult = {
571
+ fileDiff,
572
+ fileName,
573
+ filePath: this.params.file_path,
574
+ originalContent: editData.currentContent,
575
+ newContent: editData.newContent,
576
+ diffStat,
577
+ isNewFile: editData.isNewFile,
578
+ };
579
+ }
285
580
  const llmSuccessMessageParts = [
286
581
  editData.isNewFile
287
- ? `Created new file: ${this.resolvedPath} with provided content.`
288
- : `Successfully modified file: ${this.resolvedPath} (${editData.occurrences} replacements).`,
582
+ ? `Created new file: ${this.params.file_path} with provided content.`
583
+ : `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
289
584
  ];
290
585
  if (this.params.modified_by_user) {
291
586
  llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
@@ -325,23 +620,42 @@ export class EditTool extends BaseDeclarativeTool {
325
620
  static Name = EDIT_TOOL_NAME;
326
621
  constructor(config, messageBus) {
327
622
  super(EditTool.Name, 'Edit', `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
328
-
623
+
329
624
  The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
330
-
331
- Expectation for required parameters:
332
- 1. \`file_path\` is the path to the file to modify.
333
- 2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
334
- 3. \`new_string\` MUST be the exact literal text to replace \`old_string\` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic.
335
- 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
336
- **Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
337
- **Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`, Kind.Edit, {
625
+
626
+ Expectation for required parameters:
627
+ 1. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
628
+ 2. \`new_string\` MUST be the exact literal text to replace \`old_string\` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic and that \`old_string\` and \`new_string\` are different.
629
+ 3. \`instruction\` is the detailed instruction of what needs to be changed. It is important to Make it specific and detailed so developers or large language models can understand what needs to be changed and perform the changes on their own if necessary.
630
+ 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
631
+ **Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
632
+ 5. Prefer to break down complex and long changes into multiple smaller atomic calls to this tool. Always check the content of the file after changes or not finding a string to match.
633
+ **Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`, Kind.Edit, {
338
634
  properties: {
339
635
  file_path: {
340
636
  description: 'The path to the file to modify.',
341
637
  type: 'string',
342
638
  },
639
+ instruction: {
640
+ description: `A clear, semantic instruction for the code change, acting as a high-quality prompt for an expert LLM assistant. It must be self-contained and explain the goal of the change.
641
+
642
+ A good instruction should concisely answer:
643
+ 1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
644
+ 2. WHERE should the change happen? (e.g., "...in the 'renderUserProfile' function...")
645
+ 3. WHAT is the high-level change? (e.g., "...add a null check for the 'user' object...")
646
+ 4. WHAT is the desired outcome? (e.g., "...so that it displays a loading spinner instead of crashing.")
647
+
648
+ **GOOD Example:** "In the 'calculateTotal' function, correct the sales tax calculation by updating the 'taxRate' constant from 0.05 to 0.075 to reflect the new regional tax laws."
649
+
650
+ **BAD Examples:**
651
+ - "Change the text." (Too vague)
652
+ - "Fix the bug." (Doesn't explain the bug or the fix)
653
+ - "Replace the line with this new line." (Brittle, just repeats the other parameters)
654
+ `,
655
+ type: 'string',
656
+ },
343
657
  old_string: {
344
- description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. For multiple replacements, specify expected_replacements parameter. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.',
658
+ description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.',
345
659
  type: 'string',
346
660
  },
347
661
  new_string: {
@@ -354,11 +668,10 @@ Expectation for required parameters:
354
668
  minimum: 1,
355
669
  },
356
670
  },
357
- required: ['file_path', 'old_string', 'new_string'],
671
+ required: ['file_path', 'instruction', 'old_string', 'new_string'],
358
672
  type: 'object',
359
- }, true, // isOutputMarkdown
360
- false, // canUpdateOutput
361
- messageBus);
673
+ }, messageBus, true, // isOutputMarkdown
674
+ false);
362
675
  this.config = config;
363
676
  }
364
677
  /**
@@ -370,26 +683,34 @@ Expectation for required parameters:
370
683
  if (!params.file_path) {
371
684
  return "The 'file_path' parameter must be non-empty.";
372
685
  }
373
- const resolvedPath = path.resolve(this.config.getTargetDir(), params.file_path);
686
+ let filePath = params.file_path;
687
+ if (!path.isAbsolute(filePath)) {
688
+ // Attempt to auto-correct to an absolute path
689
+ const result = correctPath(filePath, this.config);
690
+ if (!result.success) {
691
+ return result.error;
692
+ }
693
+ filePath = result.correctedPath;
694
+ }
695
+ params.file_path = filePath;
374
696
  const workspaceContext = this.config.getWorkspaceContext();
375
- if (!workspaceContext.isPathWithinWorkspace(resolvedPath)) {
697
+ if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
376
698
  const directories = workspaceContext.getDirectories();
377
699
  return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
378
700
  }
379
701
  return null;
380
702
  }
381
- createInvocation(params, messageBus, toolName, displayName) {
382
- return new EditToolInvocation(this.config, params, messageBus ?? this.messageBus, toolName ?? this.name, displayName ?? this.displayName);
703
+ createInvocation(params, messageBus) {
704
+ return new EditToolInvocation(this.config, params, messageBus, this.name, this.displayName);
383
705
  }
384
706
  getModifyContext(_) {
385
- const resolvePath = (filePath) => path.resolve(this.config.getTargetDir(), filePath);
386
707
  return {
387
708
  getFilePath: (params) => params.file_path,
388
709
  getCurrentContent: async (params) => {
389
710
  try {
390
711
  return await this.config
391
712
  .getFileSystemService()
392
- .readTextFile(resolvePath(params.file_path));
713
+ .readTextFile(params.file_path);
393
714
  }
394
715
  catch (err) {
395
716
  if (!isNodeError(err) || err.code !== 'ENOENT')
@@ -401,7 +722,7 @@ Expectation for required parameters:
401
722
  try {
402
723
  const currentContent = await this.config
403
724
  .getFileSystemService()
404
- .readTextFile(resolvePath(params.file_path));
725
+ .readTextFile(params.file_path);
405
726
  return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
406
727
  }
407
728
  catch (err) {
@@ -410,13 +731,16 @@ Expectation for required parameters:
410
731
  return '';
411
732
  }
412
733
  },
413
- createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => ({
414
- ...originalParams,
415
- ai_proposed_content: oldContent,
416
- old_string: oldContent,
417
- new_string: modifiedProposedContent,
418
- modified_by_user: true,
419
- }),
734
+ createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
735
+ const content = originalParams.new_string;
736
+ return {
737
+ ...originalParams,
738
+ ai_proposed_content: content,
739
+ old_string: oldContent,
740
+ new_string: modifiedProposedContent,
741
+ modified_by_user: true,
742
+ };
743
+ },
420
744
  };
421
745
  }
422
746
  }