@google/gemini-cli-core 0.1.18 → 0.1.19-nightly.250813.9d023be1

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 (239) hide show
  1. package/README.md +199 -132
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/code_assist/converter.d.ts +3 -2
  6. package/dist/src/code_assist/converter.js +2 -2
  7. package/dist/src/code_assist/converter.js.map +1 -1
  8. package/dist/src/code_assist/converter.test.js +48 -1
  9. package/dist/src/code_assist/converter.test.js.map +1 -1
  10. package/dist/src/code_assist/oauth2.js +1 -1
  11. package/dist/src/code_assist/oauth2.js.map +1 -1
  12. package/dist/src/code_assist/server.test.js +4 -1
  13. package/dist/src/code_assist/server.test.js.map +1 -1
  14. package/dist/src/code_assist/setup.js +4 -4
  15. package/dist/src/code_assist/setup.js.map +1 -1
  16. package/dist/src/config/config.d.ts +19 -3
  17. package/dist/src/config/config.js +29 -10
  18. package/dist/src/config/config.js.map +1 -1
  19. package/dist/src/config/config.test.js +34 -0
  20. package/dist/src/config/config.test.js.map +1 -1
  21. package/dist/src/core/client.d.ts +5 -4
  22. package/dist/src/core/client.js +163 -117
  23. package/dist/src/core/client.js.map +1 -1
  24. package/dist/src/core/client.test.js +282 -37
  25. package/dist/src/core/client.test.js.map +1 -1
  26. package/dist/src/core/contentGenerator.js +3 -2
  27. package/dist/src/core/contentGenerator.js.map +1 -1
  28. package/dist/src/core/contentGenerator.test.js +3 -2
  29. package/dist/src/core/contentGenerator.test.js.map +1 -1
  30. package/dist/src/core/coreToolScheduler.d.ts +21 -8
  31. package/dist/src/core/coreToolScheduler.js +170 -61
  32. package/dist/src/core/coreToolScheduler.js.map +1 -1
  33. package/dist/src/core/coreToolScheduler.test.js +181 -37
  34. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  35. package/dist/src/core/geminiChat.d.ts +7 -6
  36. package/dist/src/core/geminiChat.js +43 -43
  37. package/dist/src/core/geminiChat.js.map +1 -1
  38. package/dist/src/core/logger.d.ts +1 -0
  39. package/dist/src/core/logger.js +18 -0
  40. package/dist/src/core/logger.js.map +1 -1
  41. package/dist/src/core/logger.test.js +29 -0
  42. package/dist/src/core/logger.test.js.map +1 -1
  43. package/dist/src/core/loggingContentGenerator.d.ts +29 -0
  44. package/dist/src/core/loggingContentGenerator.js +97 -0
  45. package/dist/src/core/loggingContentGenerator.js.map +1 -0
  46. package/dist/src/core/nonInteractiveToolExecutor.js +20 -1
  47. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  48. package/dist/src/core/nonInteractiveToolExecutor.test.js +7 -31
  49. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  50. package/dist/src/core/subagent.d.ts +230 -0
  51. package/dist/src/core/subagent.js +447 -0
  52. package/dist/src/core/subagent.js.map +1 -0
  53. package/dist/src/core/subagent.test.d.ts +6 -0
  54. package/dist/src/core/subagent.test.js +515 -0
  55. package/dist/src/core/subagent.test.js.map +1 -0
  56. package/dist/src/core/turn.js +1 -0
  57. package/dist/src/core/turn.js.map +1 -1
  58. package/dist/src/core/turn.test.js +4 -0
  59. package/dist/src/core/turn.test.js.map +1 -1
  60. package/dist/src/ide/detect-ide.d.ts +10 -2
  61. package/dist/src/ide/detect-ide.js +48 -5
  62. package/dist/src/ide/detect-ide.js.map +1 -1
  63. package/dist/src/ide/ide-client.d.ts +20 -1
  64. package/dist/src/ide/ide-client.js +145 -19
  65. package/dist/src/ide/ide-client.js.map +1 -1
  66. package/dist/src/ide/ide-installer.js +1 -26
  67. package/dist/src/ide/ide-installer.js.map +1 -1
  68. package/dist/src/ide/ide-installer.test.js +0 -4
  69. package/dist/src/ide/ide-installer.test.js.map +1 -1
  70. package/dist/src/ide/ideContext.d.ts +95 -0
  71. package/dist/src/ide/ideContext.js +45 -0
  72. package/dist/src/ide/ideContext.js.map +1 -1
  73. package/dist/src/index.d.ts +1 -1
  74. package/dist/src/index.js +1 -1
  75. package/dist/src/index.js.map +1 -1
  76. package/dist/src/mcp/google-auth-provider.js +9 -0
  77. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  78. package/dist/src/mcp/google-auth-provider.test.js +45 -10
  79. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  80. package/dist/src/mocks/msw.d.ts +6 -0
  81. package/dist/src/mocks/msw.js +8 -0
  82. package/dist/src/mocks/msw.js.map +1 -0
  83. package/dist/src/services/loopDetectionService.js +14 -11
  84. package/dist/src/services/loopDetectionService.js.map +1 -1
  85. package/dist/src/services/loopDetectionService.test.js +191 -0
  86. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  87. package/dist/src/services/shellExecutionService.js +29 -9
  88. package/dist/src/services/shellExecutionService.js.map +1 -1
  89. package/dist/src/services/shellExecutionService.test.js +8 -0
  90. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  91. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +48 -6
  92. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +211 -116
  93. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  94. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +6 -0
  95. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +219 -0
  96. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
  97. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +5 -1
  98. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +8 -0
  99. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  100. package/dist/src/telemetry/loggers.test.circular.js +7 -2
  101. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  102. package/dist/src/telemetry/loggers.test.js +7 -2
  103. package/dist/src/telemetry/loggers.test.js.map +1 -1
  104. package/dist/src/telemetry/metrics.d.ts +3 -2
  105. package/dist/src/telemetry/metrics.js +7 -1
  106. package/dist/src/telemetry/metrics.js.map +1 -1
  107. package/dist/src/telemetry/metrics.test.js +50 -0
  108. package/dist/src/telemetry/metrics.test.js.map +1 -1
  109. package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
  110. package/dist/src/telemetry/tool-call-decision.js +29 -0
  111. package/dist/src/telemetry/tool-call-decision.js.map +1 -0
  112. package/dist/src/telemetry/types.d.ts +4 -7
  113. package/dist/src/telemetry/types.js +17 -21
  114. package/dist/src/telemetry/types.js.map +1 -1
  115. package/dist/src/telemetry/uiTelemetry.d.ts +4 -1
  116. package/dist/src/telemetry/uiTelemetry.js +3 -1
  117. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  118. package/dist/src/telemetry/uiTelemetry.test.js +13 -2
  119. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  120. package/dist/src/test-utils/config.d.ts +16 -0
  121. package/dist/src/test-utils/config.js +32 -0
  122. package/dist/src/test-utils/config.js.map +1 -0
  123. package/dist/src/test-utils/tools.d.ts +23 -0
  124. package/dist/src/test-utils/tools.js +41 -0
  125. package/dist/src/test-utils/tools.js.map +1 -0
  126. package/dist/src/tools/diffOptions.d.ts +2 -0
  127. package/dist/src/tools/diffOptions.js +28 -0
  128. package/dist/src/tools/diffOptions.js.map +1 -1
  129. package/dist/src/tools/diffOptions.test.d.ts +6 -0
  130. package/dist/src/tools/diffOptions.test.js +119 -0
  131. package/dist/src/tools/diffOptions.test.js.map +1 -0
  132. package/dist/src/tools/edit.d.ts +9 -33
  133. package/dist/src/tools/edit.js +142 -132
  134. package/dist/src/tools/edit.js.map +1 -1
  135. package/dist/src/tools/edit.test.js +115 -51
  136. package/dist/src/tools/edit.test.js.map +1 -1
  137. package/dist/src/tools/glob.d.ts +3 -10
  138. package/dist/src/tools/glob.js +85 -89
  139. package/dist/src/tools/glob.js.map +1 -1
  140. package/dist/src/tools/glob.test.js +22 -12
  141. package/dist/src/tools/glob.test.js.map +1 -1
  142. package/dist/src/tools/grep.d.ts +3 -35
  143. package/dist/src/tools/grep.js +111 -83
  144. package/dist/src/tools/grep.js.map +1 -1
  145. package/dist/src/tools/grep.test.js +40 -23
  146. package/dist/src/tools/grep.test.js.map +1 -1
  147. package/dist/src/tools/ls.js +8 -9
  148. package/dist/src/tools/ls.js.map +1 -1
  149. package/dist/src/tools/mcp-client.d.ts +14 -3
  150. package/dist/src/tools/mcp-client.js +82 -6
  151. package/dist/src/tools/mcp-client.js.map +1 -1
  152. package/dist/src/tools/mcp-client.test.js +340 -5
  153. package/dist/src/tools/mcp-client.test.js.map +1 -1
  154. package/dist/src/tools/mcp-tool.d.ts +3 -8
  155. package/dist/src/tools/mcp-tool.js +5 -18
  156. package/dist/src/tools/mcp-tool.js.map +1 -1
  157. package/dist/src/tools/memoryTool.d.ts +2 -2
  158. package/dist/src/tools/memoryTool.js +5 -5
  159. package/dist/src/tools/memoryTool.js.map +1 -1
  160. package/dist/src/tools/memoryTool.test.js +10 -1
  161. package/dist/src/tools/memoryTool.test.js.map +1 -1
  162. package/dist/src/tools/modifiable-tool.d.ts +8 -5
  163. package/dist/src/tools/modifiable-tool.js +4 -1
  164. package/dist/src/tools/modifiable-tool.js.map +1 -1
  165. package/dist/src/tools/modifiable-tool.test.js +3 -3
  166. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  167. package/dist/src/tools/read-file.d.ts +4 -6
  168. package/dist/src/tools/read-file.js +92 -45
  169. package/dist/src/tools/read-file.js.map +1 -1
  170. package/dist/src/tools/read-file.test.js +192 -130
  171. package/dist/src/tools/read-file.test.js.map +1 -1
  172. package/dist/src/tools/read-many-files.js +25 -20
  173. package/dist/src/tools/read-many-files.js.map +1 -1
  174. package/dist/src/tools/read-many-files.test.js +22 -11
  175. package/dist/src/tools/read-many-files.test.js.map +1 -1
  176. package/dist/src/tools/shell.js +11 -7
  177. package/dist/src/tools/shell.js.map +1 -1
  178. package/dist/src/tools/shell.test.js +21 -0
  179. package/dist/src/tools/shell.test.js.map +1 -1
  180. package/dist/src/tools/tool-error.d.ts +4 -0
  181. package/dist/src/tools/tool-error.js +4 -0
  182. package/dist/src/tools/tool-error.js.map +1 -1
  183. package/dist/src/tools/tool-registry.d.ts +12 -20
  184. package/dist/src/tools/tool-registry.js +23 -76
  185. package/dist/src/tools/tool-registry.js.map +1 -1
  186. package/dist/src/tools/tool-registry.test.js +19 -192
  187. package/dist/src/tools/tool-registry.test.js.map +1 -1
  188. package/dist/src/tools/tools.d.ts +144 -43
  189. package/dist/src/tools/tools.js +181 -11
  190. package/dist/src/tools/tools.js.map +1 -1
  191. package/dist/src/tools/tools.test.d.ts +6 -0
  192. package/dist/src/tools/tools.test.js +117 -0
  193. package/dist/src/tools/tools.test.js.map +1 -0
  194. package/dist/src/tools/web-fetch.js +3 -4
  195. package/dist/src/tools/web-fetch.js.map +1 -1
  196. package/dist/src/tools/web-search.js +1 -1
  197. package/dist/src/tools/web-search.js.map +1 -1
  198. package/dist/src/tools/write-file.d.ts +6 -2
  199. package/dist/src/tools/write-file.js +84 -20
  200. package/dist/src/tools/write-file.js.map +1 -1
  201. package/dist/src/tools/write-file.test.js +112 -8
  202. package/dist/src/tools/write-file.test.js.map +1 -1
  203. package/dist/src/utils/bfsFileSearch.test.js +28 -56
  204. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  205. package/dist/src/utils/editCorrector.js +8 -9
  206. package/dist/src/utils/editCorrector.js.map +1 -1
  207. package/dist/src/utils/environmentContext.d.ts +21 -0
  208. package/dist/src/utils/environmentContext.js +90 -0
  209. package/dist/src/utils/environmentContext.js.map +1 -0
  210. package/dist/src/utils/environmentContext.test.d.ts +6 -0
  211. package/dist/src/utils/environmentContext.test.js +139 -0
  212. package/dist/src/utils/environmentContext.test.js.map +1 -0
  213. package/dist/src/utils/fileUtils.d.ts +7 -0
  214. package/dist/src/utils/fileUtils.js +15 -12
  215. package/dist/src/utils/fileUtils.js.map +1 -1
  216. package/dist/src/utils/fileUtils.test.js +6 -5
  217. package/dist/src/utils/fileUtils.test.js.map +1 -1
  218. package/dist/src/utils/filesearch/crawlCache.d.ts +1 -1
  219. package/dist/src/utils/filesearch/crawlCache.js +4 -1
  220. package/dist/src/utils/filesearch/crawlCache.js.map +1 -1
  221. package/dist/src/utils/filesearch/crawlCache.test.js +10 -0
  222. package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -1
  223. package/dist/src/utils/filesearch/fileSearch.d.ts +2 -0
  224. package/dist/src/utils/filesearch/fileSearch.js +32 -7
  225. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  226. package/dist/src/utils/filesearch/fileSearch.test.js +139 -0
  227. package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
  228. package/dist/src/utils/memoryDiscovery.js +4 -1
  229. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  230. package/dist/src/utils/nextSpeakerChecker.js +5 -6
  231. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  232. package/dist/src/utils/nextSpeakerChecker.test.js +2 -2
  233. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  234. package/dist/src/utils/schemaValidator.d.ts +1 -8
  235. package/dist/src/utils/schemaValidator.js +1 -32
  236. package/dist/src/utils/schemaValidator.js.map +1 -1
  237. package/dist/tsconfig.tsbuildinfo +1 -1
  238. package/package.json +3 -1
  239. package/dist/google-gemini-cli-core-0.1.17.tgz +0 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, expect, it } from 'vitest';
7
+ import { getDiffStat } from './diffOptions.js';
8
+ describe('getDiffStat', () => {
9
+ const fileName = 'test.txt';
10
+ it('should return 0 for all stats when there are no changes', () => {
11
+ const oldStr = 'line1\nline2\n';
12
+ const aiStr = 'line1\nline2\n';
13
+ const userStr = 'line1\nline2\n';
14
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
15
+ expect(diffStat).toEqual({
16
+ ai_added_lines: 0,
17
+ ai_removed_lines: 0,
18
+ user_added_lines: 0,
19
+ user_removed_lines: 0,
20
+ });
21
+ });
22
+ it('should correctly report AI additions', () => {
23
+ const oldStr = 'line1\nline2\n';
24
+ const aiStr = 'line1\nline2\nline3\n';
25
+ const userStr = 'line1\nline2\nline3\n';
26
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
27
+ expect(diffStat).toEqual({
28
+ ai_added_lines: 1,
29
+ ai_removed_lines: 0,
30
+ user_added_lines: 0,
31
+ user_removed_lines: 0,
32
+ });
33
+ });
34
+ it('should correctly report AI removals', () => {
35
+ const oldStr = 'line1\nline2\nline3\n';
36
+ const aiStr = 'line1\nline3\n';
37
+ const userStr = 'line1\nline3\n';
38
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
39
+ expect(diffStat).toEqual({
40
+ ai_added_lines: 0,
41
+ ai_removed_lines: 1,
42
+ user_added_lines: 0,
43
+ user_removed_lines: 0,
44
+ });
45
+ });
46
+ it('should correctly report AI modifications', () => {
47
+ const oldStr = 'line1\nline2\nline3\n';
48
+ const aiStr = 'line1\nline_two\nline3\n';
49
+ const userStr = 'line1\nline_two\nline3\n';
50
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
51
+ expect(diffStat).toEqual({
52
+ ai_added_lines: 1,
53
+ ai_removed_lines: 1,
54
+ user_added_lines: 0,
55
+ user_removed_lines: 0,
56
+ });
57
+ });
58
+ it('should correctly report user additions', () => {
59
+ const oldStr = 'line1\nline2\n';
60
+ const aiStr = 'line1\nline2\nline3\n';
61
+ const userStr = 'line1\nline2\nline3\nline4\n';
62
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
63
+ expect(diffStat).toEqual({
64
+ ai_added_lines: 1,
65
+ ai_removed_lines: 0,
66
+ user_added_lines: 1,
67
+ user_removed_lines: 0,
68
+ });
69
+ });
70
+ it('should correctly report user removals', () => {
71
+ const oldStr = 'line1\nline2\n';
72
+ const aiStr = 'line1\nline2\nline3\n';
73
+ const userStr = 'line1\nline2\n';
74
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
75
+ expect(diffStat).toEqual({
76
+ ai_added_lines: 1,
77
+ ai_removed_lines: 0,
78
+ user_added_lines: 0,
79
+ user_removed_lines: 1,
80
+ });
81
+ });
82
+ it('should correctly report user modifications', () => {
83
+ const oldStr = 'line1\nline2\n';
84
+ const aiStr = 'line1\nline2\nline3\n';
85
+ const userStr = 'line1\nline2\nline_three\n';
86
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
87
+ expect(diffStat).toEqual({
88
+ ai_added_lines: 1,
89
+ ai_removed_lines: 0,
90
+ user_added_lines: 1,
91
+ user_removed_lines: 1,
92
+ });
93
+ });
94
+ it('should handle complex changes from both AI and user', () => {
95
+ const oldStr = 'line1\nline2\nline3\nline4\n';
96
+ const aiStr = 'line_one\nline2\nline_three\nline4\n';
97
+ const userStr = 'line_one\nline_two\nline_three\nline4\nline5\n';
98
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
99
+ expect(diffStat).toEqual({
100
+ ai_added_lines: 2,
101
+ ai_removed_lines: 2,
102
+ user_added_lines: 2,
103
+ user_removed_lines: 1,
104
+ });
105
+ });
106
+ it('should report a single line modification as one addition and one removal', () => {
107
+ const oldStr = 'hello world';
108
+ const aiStr = 'hello universe';
109
+ const userStr = 'hello universe';
110
+ const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
111
+ expect(diffStat).toEqual({
112
+ ai_added_lines: 1,
113
+ ai_removed_lines: 1,
114
+ user_added_lines: 0,
115
+ user_removed_lines: 0,
116
+ });
117
+ });
118
+ });
119
+ //# sourceMappingURL=diffOptions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diffOptions.test.js","sourceRoot":"","sources":["../../../src/tools/diffOptions.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE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C;IAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,MAAM,GAAG,aAAa,CAAC;QAC7B,MAAM,KAAK,GAAG,gBAAgB,CAAC;QAC/B,MAAM,OAAO,GAAG,gBAAgB,CAAC;QACjC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;YACvB,cAAc,EAAE,CAAC;YACjB,gBAAgB,EAAE,CAAC;YACnB,gBAAgB,EAAE,CAAC;YACnB,kBAAkB,EAAE,CAAC;SACtB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -3,9 +3,10 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { BaseTool, ToolCallConfirmationDetails, ToolLocation, ToolResult } from './tools.js';
6
+ import { BaseDeclarativeTool, ToolInvocation, ToolResult } from './tools.js';
7
7
  import { Config } from '../config/config.js';
8
- import { ModifiableTool, ModifyContext } from './modifiable-tool.js';
8
+ import { ModifiableDeclarativeTool, ModifyContext } from './modifiable-tool.js';
9
+ export declare function applyReplacement(currentContent: string | null, oldString: string, newString: string, isNewFile: boolean): string;
9
10
  /**
10
11
  * Parameters for the Edit tool
11
12
  */
@@ -31,11 +32,15 @@ export interface EditToolParams {
31
32
  * Whether the edit was modified manually by the user.
32
33
  */
33
34
  modified_by_user?: boolean;
35
+ /**
36
+ * Initially proposed string.
37
+ */
38
+ ai_proposed_string?: string;
34
39
  }
35
40
  /**
36
41
  * Implementation of the Edit tool logic
37
42
  */
38
- export declare class EditTool extends BaseTool<EditToolParams, ToolResult> implements ModifiableTool<EditToolParams> {
43
+ export declare class EditTool extends BaseDeclarativeTool<EditToolParams, ToolResult> implements ModifiableDeclarativeTool<EditToolParams> {
39
44
  private readonly config;
40
45
  static readonly Name = "replace";
41
46
  constructor(config: Config);
@@ -45,35 +50,6 @@ export declare class EditTool extends BaseTool<EditToolParams, ToolResult> imple
45
50
  * @returns Error message string or null if valid
46
51
  */
47
52
  validateToolParams(params: EditToolParams): string | null;
48
- /**
49
- * Determines any file locations affected by the tool execution
50
- * @param params Parameters for the tool execution
51
- * @returns A list of such paths
52
- */
53
- toolLocations(params: EditToolParams): ToolLocation[];
54
- private _applyReplacement;
55
- /**
56
- * Calculates the potential outcome of an edit operation.
57
- * @param params Parameters for the edit operation
58
- * @returns An object describing the potential edit outcome
59
- * @throws File system errors if reading the file fails unexpectedly (e.g., permissions)
60
- */
61
- private calculateEdit;
62
- /**
63
- * Handles the confirmation prompt for the Edit tool in the CLI.
64
- * It needs to calculate the diff to show the user.
65
- */
66
- shouldConfirmExecute(params: EditToolParams, abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
67
- getDescription(params: EditToolParams): string;
68
- /**
69
- * Executes the edit operation with the given parameters.
70
- * @param params Parameters for the edit operation
71
- * @returns Result of the edit operation
72
- */
73
- execute(params: EditToolParams, signal: AbortSignal): Promise<ToolResult>;
74
- /**
75
- * Creates parent directories if they don't exist
76
- */
77
- private ensureParentDirectoriesExist;
53
+ protected createInvocation(params: EditToolParams): ToolInvocation<EditToolParams, ToolResult>;
78
54
  getModifyContext(_: AbortSignal): ModifyContext<EditToolParams>;
79
55
  }
@@ -6,99 +6,39 @@
6
6
  import * as fs from 'fs';
7
7
  import * as path from 'path';
8
8
  import * as Diff from 'diff';
9
- import { BaseTool, Icon, ToolConfirmationOutcome, } from './tools.js';
9
+ import { BaseDeclarativeTool, Icon, ToolConfirmationOutcome, } from './tools.js';
10
10
  import { ToolErrorType } from './tool-error.js';
11
- import { Type } from '@google/genai';
12
11
  import { SchemaValidator } from '../utils/schemaValidator.js';
13
12
  import { makeRelative, shortenPath } from '../utils/paths.js';
14
13
  import { isNodeError } from '../utils/errors.js';
15
14
  import { ApprovalMode } from '../config/config.js';
16
15
  import { ensureCorrectEdit } from '../utils/editCorrector.js';
17
- import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
16
+ import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
18
17
  import { ReadFileTool } from './read-file.js';
19
- /**
20
- * Implementation of the Edit tool logic
21
- */
22
- export class EditTool extends BaseTool {
23
- config;
24
- static Name = 'replace';
25
- constructor(config) {
26
- 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 ${ReadFileTool.Name} tool to examine the file's current content before attempting a text replacement.
27
-
28
- The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
29
-
30
- Expectation for required parameters:
31
- 1. \`file_path\` MUST be an absolute path; otherwise an error will be thrown.
32
- 2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
33
- 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.
34
- 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
35
- **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.
36
- **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.`, Icon.Pencil, {
37
- properties: {
38
- file_path: {
39
- description: "The absolute path to the file to modify. Must start with '/'.",
40
- type: Type.STRING,
41
- },
42
- old_string: {
43
- 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.',
44
- type: Type.STRING,
45
- },
46
- new_string: {
47
- description: 'The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.',
48
- type: Type.STRING,
49
- },
50
- expected_replacements: {
51
- type: Type.NUMBER,
52
- description: 'Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.',
53
- minimum: 1,
54
- },
55
- },
56
- required: ['file_path', 'old_string', 'new_string'],
57
- type: Type.OBJECT,
58
- });
59
- this.config = config;
18
+ import { IDEConnectionStatus } from '../ide/ide-client.js';
19
+ export function applyReplacement(currentContent, oldString, newString, isNewFile) {
20
+ if (isNewFile) {
21
+ return newString;
60
22
  }
61
- /**
62
- * Validates the parameters for the Edit tool
63
- * @param params Parameters to validate
64
- * @returns Error message string or null if valid
65
- */
66
- validateToolParams(params) {
67
- const errors = SchemaValidator.validate(this.schema.parameters, params);
68
- if (errors) {
69
- return errors;
70
- }
71
- if (!path.isAbsolute(params.file_path)) {
72
- return `File path must be absolute: ${params.file_path}`;
73
- }
74
- const workspaceContext = this.config.getWorkspaceContext();
75
- if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
76
- const directories = workspaceContext.getDirectories();
77
- return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
78
- }
79
- return null;
23
+ if (currentContent === null) {
24
+ // Should not happen if not a new file, but defensively return empty or newString if oldString is also empty
25
+ return oldString === '' ? newString : '';
80
26
  }
81
- /**
82
- * Determines any file locations affected by the tool execution
83
- * @param params Parameters for the tool execution
84
- * @returns A list of such paths
85
- */
86
- toolLocations(params) {
87
- return [{ path: params.file_path }];
27
+ // If oldString is empty and it's not a new file, do not modify the content.
28
+ if (oldString === '' && !isNewFile) {
29
+ return currentContent;
88
30
  }
89
- _applyReplacement(currentContent, oldString, newString, isNewFile) {
90
- if (isNewFile) {
91
- return newString;
92
- }
93
- if (currentContent === null) {
94
- // Should not happen if not a new file, but defensively return empty or newString if oldString is also empty
95
- return oldString === '' ? newString : '';
96
- }
97
- // If oldString is empty and it's not a new file, do not modify the content.
98
- if (oldString === '' && !isNewFile) {
99
- return currentContent;
100
- }
101
- return currentContent.replaceAll(oldString, newString);
31
+ return currentContent.replaceAll(oldString, newString);
32
+ }
33
+ class EditToolInvocation {
34
+ config;
35
+ params;
36
+ constructor(config, params) {
37
+ this.config = config;
38
+ this.params = params;
39
+ }
40
+ toolLocations() {
41
+ return [{ path: this.params.file_path }];
102
42
  }
103
43
  /**
104
44
  * Calculates the potential outcome of an edit operation.
@@ -185,7 +125,7 @@ Expectation for required parameters:
185
125
  type: ToolErrorType.READ_CONTENT_FAILURE,
186
126
  };
187
127
  }
188
- const newContent = this._applyReplacement(currentContent, finalOldString, finalNewString, isNewFile);
128
+ const newContent = applyReplacement(currentContent, finalOldString, finalNewString, isNewFile);
189
129
  return {
190
130
  currentContent,
191
131
  newContent,
@@ -198,18 +138,13 @@ Expectation for required parameters:
198
138
  * Handles the confirmation prompt for the Edit tool in the CLI.
199
139
  * It needs to calculate the diff to show the user.
200
140
  */
201
- async shouldConfirmExecute(params, abortSignal) {
141
+ async shouldConfirmExecute(abortSignal) {
202
142
  if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
203
143
  return false;
204
144
  }
205
- const validationError = this.validateToolParams(params);
206
- if (validationError) {
207
- console.error(`[EditTool Wrapper] Attempted confirmation with invalid parameters: ${validationError}`);
208
- return false;
209
- }
210
145
  let editData;
211
146
  try {
212
- editData = await this.calculateEdit(params, abortSignal);
147
+ editData = await this.calculateEdit(this.params, abortSignal);
213
148
  }
214
149
  catch (error) {
215
150
  const errorMsg = error instanceof Error ? error.message : String(error);
@@ -220,12 +155,18 @@ Expectation for required parameters:
220
155
  console.log(`Error: ${editData.error.display}`);
221
156
  return false;
222
157
  }
223
- const fileName = path.basename(params.file_path);
158
+ const fileName = path.basename(this.params.file_path);
224
159
  const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
160
+ const ideClient = this.config.getIdeClient();
161
+ const ideConfirmation = this.config.getIdeMode() &&
162
+ ideClient?.getConnectionStatus().status === IDEConnectionStatus.Connected
163
+ ? ideClient.openDiff(this.params.file_path, editData.newContent)
164
+ : undefined;
225
165
  const confirmationDetails = {
226
166
  type: 'edit',
227
- title: `Confirm Edit: ${shortenPath(makeRelative(params.file_path, this.config.getTargetDir()))}`,
167
+ title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
228
168
  fileName,
169
+ filePath: this.params.file_path,
229
170
  fileDiff,
230
171
  originalContent: editData.currentContent,
231
172
  newContent: editData.newContent,
@@ -233,23 +174,30 @@ Expectation for required parameters:
233
174
  if (outcome === ToolConfirmationOutcome.ProceedAlways) {
234
175
  this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
235
176
  }
177
+ if (ideConfirmation) {
178
+ const result = await ideConfirmation;
179
+ if (result.status === 'accepted' && result.content) {
180
+ // TODO(chrstn): See https://github.com/google-gemini/gemini-cli/pull/5618#discussion_r2255413084
181
+ // for info on a possible race condition where the file is modified on disk while being edited.
182
+ this.params.old_string = editData.currentContent ?? '';
183
+ this.params.new_string = result.content;
184
+ }
185
+ }
236
186
  },
187
+ ideConfirmation,
237
188
  };
238
189
  return confirmationDetails;
239
190
  }
240
- getDescription(params) {
241
- if (!params.file_path || !params.old_string || !params.new_string) {
242
- return `Model did not provide valid parameters for edit tool`;
243
- }
244
- const relativePath = makeRelative(params.file_path, this.config.getTargetDir());
245
- if (params.old_string === '') {
191
+ getDescription() {
192
+ const relativePath = makeRelative(this.params.file_path, this.config.getTargetDir());
193
+ if (this.params.old_string === '') {
246
194
  return `Create ${shortenPath(relativePath)}`;
247
195
  }
248
- const oldStringSnippet = params.old_string.split('\n')[0].substring(0, 30) +
249
- (params.old_string.length > 30 ? '...' : '');
250
- const newStringSnippet = params.new_string.split('\n')[0].substring(0, 30) +
251
- (params.new_string.length > 30 ? '...' : '');
252
- if (params.old_string === params.new_string) {
196
+ const oldStringSnippet = this.params.old_string.split('\n')[0].substring(0, 30) +
197
+ (this.params.old_string.length > 30 ? '...' : '');
198
+ const newStringSnippet = this.params.new_string.split('\n')[0].substring(0, 30) +
199
+ (this.params.new_string.length > 30 ? '...' : '');
200
+ if (this.params.old_string === this.params.new_string) {
253
201
  return `No file changes to ${shortenPath(relativePath)}`;
254
202
  }
255
203
  return `${shortenPath(relativePath)}: ${oldStringSnippet} => ${newStringSnippet}`;
@@ -259,21 +207,10 @@ Expectation for required parameters:
259
207
  * @param params Parameters for the edit operation
260
208
  * @returns Result of the edit operation
261
209
  */
262
- async execute(params, signal) {
263
- const validationError = this.validateToolParams(params);
264
- if (validationError) {
265
- return {
266
- llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
267
- returnDisplay: `Error: ${validationError}`,
268
- error: {
269
- message: validationError,
270
- type: ToolErrorType.INVALID_TOOL_PARAMS,
271
- },
272
- };
273
- }
210
+ async execute(signal) {
274
211
  let editData;
275
212
  try {
276
- editData = await this.calculateEdit(params, signal);
213
+ editData = await this.calculateEdit(this.params, signal);
277
214
  }
278
215
  catch (error) {
279
216
  const errorMsg = error instanceof Error ? error.message : String(error);
@@ -297,32 +234,35 @@ Expectation for required parameters:
297
234
  };
298
235
  }
299
236
  try {
300
- this.ensureParentDirectoriesExist(params.file_path);
301
- fs.writeFileSync(params.file_path, editData.newContent, 'utf8');
237
+ this.ensureParentDirectoriesExist(this.params.file_path);
238
+ fs.writeFileSync(this.params.file_path, editData.newContent, 'utf8');
302
239
  let displayResult;
303
240
  if (editData.isNewFile) {
304
- displayResult = `Created ${shortenPath(makeRelative(params.file_path, this.config.getTargetDir()))}`;
241
+ displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
305
242
  }
306
243
  else {
307
244
  // Generate diff for display, even though core logic doesn't technically need it
308
245
  // The CLI wrapper will use this part of the ToolResult
309
- const fileName = path.basename(params.file_path);
246
+ const fileName = path.basename(this.params.file_path);
310
247
  const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
311
248
  editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
249
+ const originallyProposedContent = this.params.ai_proposed_string || this.params.new_string;
250
+ const diffStat = getDiffStat(fileName, editData.currentContent ?? '', originallyProposedContent, this.params.new_string);
312
251
  displayResult = {
313
252
  fileDiff,
314
253
  fileName,
315
254
  originalContent: editData.currentContent,
316
255
  newContent: editData.newContent,
256
+ diffStat,
317
257
  };
318
258
  }
319
259
  const llmSuccessMessageParts = [
320
260
  editData.isNewFile
321
- ? `Created new file: ${params.file_path} with provided content.`
322
- : `Successfully modified file: ${params.file_path} (${editData.occurrences} replacements).`,
261
+ ? `Created new file: ${this.params.file_path} with provided content.`
262
+ : `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
323
263
  ];
324
- if (params.modified_by_user) {
325
- llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${params.new_string}.`);
264
+ if (this.params.modified_by_user) {
265
+ llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
326
266
  }
327
267
  return {
328
268
  llmContent: llmSuccessMessageParts.join(' '),
@@ -350,6 +290,72 @@ Expectation for required parameters:
350
290
  fs.mkdirSync(dirName, { recursive: true });
351
291
  }
352
292
  }
293
+ }
294
+ /**
295
+ * Implementation of the Edit tool logic
296
+ */
297
+ export class EditTool extends BaseDeclarativeTool {
298
+ config;
299
+ static Name = 'replace';
300
+ constructor(config) {
301
+ 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 ${ReadFileTool.Name} tool to examine the file's current content before attempting a text replacement.
302
+
303
+ The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
304
+
305
+ Expectation for required parameters:
306
+ 1. \`file_path\` MUST be an absolute path; otherwise an error will be thrown.
307
+ 2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
308
+ 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.
309
+ 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
310
+ **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.
311
+ **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.`, Icon.Pencil, {
312
+ properties: {
313
+ file_path: {
314
+ description: "The absolute path to the file to modify. Must start with '/'.",
315
+ type: 'string',
316
+ },
317
+ old_string: {
318
+ 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.',
319
+ type: 'string',
320
+ },
321
+ new_string: {
322
+ description: 'The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.',
323
+ type: 'string',
324
+ },
325
+ expected_replacements: {
326
+ type: 'number',
327
+ description: 'Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.',
328
+ minimum: 1,
329
+ },
330
+ },
331
+ required: ['file_path', 'old_string', 'new_string'],
332
+ type: 'object',
333
+ });
334
+ this.config = config;
335
+ }
336
+ /**
337
+ * Validates the parameters for the Edit tool
338
+ * @param params Parameters to validate
339
+ * @returns Error message string or null if valid
340
+ */
341
+ validateToolParams(params) {
342
+ const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
343
+ if (errors) {
344
+ return errors;
345
+ }
346
+ if (!path.isAbsolute(params.file_path)) {
347
+ return `File path must be absolute: ${params.file_path}`;
348
+ }
349
+ const workspaceContext = this.config.getWorkspaceContext();
350
+ if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
351
+ const directories = workspaceContext.getDirectories();
352
+ return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
353
+ }
354
+ return null;
355
+ }
356
+ createInvocation(params) {
357
+ return new EditToolInvocation(this.config, params);
358
+ }
353
359
  getModifyContext(_) {
354
360
  return {
355
361
  getFilePath: (params) => params.file_path,
@@ -366,7 +372,7 @@ Expectation for required parameters:
366
372
  getProposedContent: async (params) => {
367
373
  try {
368
374
  const currentContent = fs.readFileSync(params.file_path, 'utf8');
369
- return this._applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
375
+ return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
370
376
  }
371
377
  catch (err) {
372
378
  if (!isNodeError(err) || err.code !== 'ENOENT')
@@ -374,12 +380,16 @@ Expectation for required parameters:
374
380
  return '';
375
381
  }
376
382
  },
377
- createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => ({
378
- ...originalParams,
379
- old_string: oldContent,
380
- new_string: modifiedProposedContent,
381
- modified_by_user: true,
382
- }),
383
+ createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
384
+ const content = originalParams.new_string;
385
+ return {
386
+ ...originalParams,
387
+ ai_proposed_string: content,
388
+ old_string: oldContent,
389
+ new_string: modifiedProposedContent,
390
+ modified_by_user: true,
391
+ };
392
+ },
383
393
  };
384
394
  }
385
395
  }
@@ -1 +1 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/tools/edit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,QAA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