@vybestack/llxprt-code-core 0.3.4-nightly.250919.5e3f575d → 0.3.4-nightly.250921.fdbf3cd7

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 (132) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/auth/types.d.ts +2 -2
  6. package/dist/src/code_assist/codeAssist.d.ts +9 -2
  7. package/dist/src/code_assist/codeAssist.js +33 -0
  8. package/dist/src/code_assist/codeAssist.js.map +1 -1
  9. package/dist/src/code_assist/oauth2.d.ts +4 -0
  10. package/dist/src/code_assist/oauth2.js +85 -40
  11. package/dist/src/code_assist/oauth2.js.map +1 -1
  12. package/dist/src/config/config.d.ts +11 -1
  13. package/dist/src/config/config.js +41 -8
  14. package/dist/src/config/config.js.map +1 -1
  15. package/dist/src/core/client.d.ts +2 -2
  16. package/dist/src/core/client.js +7 -6
  17. package/dist/src/core/client.js.map +1 -1
  18. package/dist/src/core/contentGenerator.d.ts +2 -2
  19. package/dist/src/core/geminiChat.d.ts +14 -1
  20. package/dist/src/core/geminiChat.js +12 -1
  21. package/dist/src/core/geminiChat.js.map +1 -1
  22. package/dist/src/core/loggingContentGenerator.js +11 -11
  23. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  24. package/dist/src/core/subagent.d.ts +2 -0
  25. package/dist/src/core/subagent.js +13 -3
  26. package/dist/src/core/subagent.js.map +1 -1
  27. package/dist/src/core/turn.d.ts +26 -4
  28. package/dist/src/core/turn.js +64 -3
  29. package/dist/src/core/turn.js.map +1 -1
  30. package/dist/src/filters/EmojiFilter.js +1 -0
  31. package/dist/src/filters/EmojiFilter.js.map +1 -1
  32. package/dist/src/ide/ide-client.d.ts +6 -1
  33. package/dist/src/ide/ide-client.js +20 -2
  34. package/dist/src/ide/ide-client.js.map +1 -1
  35. package/dist/src/ide/ideContext.d.ts +44 -32
  36. package/dist/src/ide/ideContext.js +1 -0
  37. package/dist/src/ide/ideContext.js.map +1 -1
  38. package/dist/src/ide/process-utils.js +49 -33
  39. package/dist/src/ide/process-utils.js.map +1 -1
  40. package/dist/src/index.d.ts +3 -0
  41. package/dist/src/index.js +4 -0
  42. package/dist/src/index.js.map +1 -1
  43. package/dist/src/mcp/file-token-store.d.ts +20 -1
  44. package/dist/src/mcp/file-token-store.js +95 -14
  45. package/dist/src/mcp/file-token-store.js.map +1 -1
  46. package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
  47. package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
  48. package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
  49. package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
  50. package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
  51. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
  52. package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
  53. package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
  54. package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
  55. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
  56. package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
  57. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
  58. package/dist/src/mcp/token-storage/types.d.ts +40 -0
  59. package/dist/src/mcp/token-storage/types.js +11 -0
  60. package/dist/src/mcp/token-storage/types.js.map +1 -0
  61. package/dist/src/providers/anthropic/AnthropicProvider.js +1 -3
  62. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
  63. package/dist/src/providers/tokenizers/OpenAITokenizer.d.ts +1 -0
  64. package/dist/src/providers/tokenizers/OpenAITokenizer.js +3 -1
  65. package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +1 -1
  66. package/dist/src/services/loopDetectionService.d.ts +23 -0
  67. package/dist/src/services/loopDetectionService.js +134 -1
  68. package/dist/src/services/loopDetectionService.js.map +1 -1
  69. package/dist/src/services/shellExecutionService.js +8 -7
  70. package/dist/src/services/shellExecutionService.js.map +1 -1
  71. package/dist/src/telemetry/sdk.js +2 -1
  72. package/dist/src/telemetry/sdk.js.map +1 -1
  73. package/dist/src/telemetry/types.d.ts +12 -0
  74. package/dist/src/telemetry/types.js +19 -0
  75. package/dist/src/telemetry/types.js.map +1 -1
  76. package/dist/src/test-utils/config.d.ts +10 -0
  77. package/dist/src/test-utils/config.js +24 -0
  78. package/dist/src/test-utils/config.js.map +1 -0
  79. package/dist/src/test-utils/index.d.ts +6 -0
  80. package/dist/src/test-utils/index.js +7 -0
  81. package/dist/src/test-utils/index.js.map +1 -0
  82. package/dist/src/test-utils/mock-tool.d.ts +41 -0
  83. package/dist/src/test-utils/mock-tool.js +51 -0
  84. package/dist/src/test-utils/mock-tool.js.map +1 -0
  85. package/dist/src/tools/edit.d.ts +2 -2
  86. package/dist/src/tools/edit.js +20 -30
  87. package/dist/src/tools/edit.js.map +1 -1
  88. package/dist/src/tools/mcp-client-manager.d.ts +8 -6
  89. package/dist/src/tools/mcp-client-manager.js +30 -5
  90. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  91. package/dist/src/tools/mcp-client.d.ts +5 -5
  92. package/dist/src/tools/mcp-client.js +13 -22
  93. package/dist/src/tools/mcp-client.js.map +1 -1
  94. package/dist/src/tools/mcp-tool.d.ts +3 -2
  95. package/dist/src/tools/mcp-tool.js +9 -9
  96. package/dist/src/tools/mcp-tool.js.map +1 -1
  97. package/dist/src/tools/memoryTool.js +5 -33
  98. package/dist/src/tools/memoryTool.js.map +1 -1
  99. package/dist/src/tools/shell.js +6 -3
  100. package/dist/src/tools/shell.js.map +1 -1
  101. package/dist/src/tools/smart-edit.d.ts +73 -0
  102. package/dist/src/tools/smart-edit.js +606 -0
  103. package/dist/src/tools/smart-edit.js.map +1 -0
  104. package/dist/src/tools/tool-registry.d.ts +2 -1
  105. package/dist/src/tools/tool-registry.js +6 -6
  106. package/dist/src/tools/tool-registry.js.map +1 -1
  107. package/dist/src/tools/web-fetch.js +3 -1
  108. package/dist/src/tools/web-fetch.js.map +1 -1
  109. package/dist/src/utils/fileUtils.d.ts +19 -3
  110. package/dist/src/utils/fileUtils.js +139 -28
  111. package/dist/src/utils/fileUtils.js.map +1 -1
  112. package/dist/src/utils/gitIgnoreParser.d.ts +1 -0
  113. package/dist/src/utils/gitIgnoreParser.js +101 -10
  114. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  115. package/dist/src/utils/ide-trust.d.ts +10 -0
  116. package/dist/src/utils/ide-trust.js +14 -0
  117. package/dist/src/utils/ide-trust.js.map +1 -0
  118. package/dist/src/utils/llm-edit-fixer.d.ts +25 -0
  119. package/dist/src/utils/llm-edit-fixer.js +111 -0
  120. package/dist/src/utils/llm-edit-fixer.js.map +1 -0
  121. package/dist/src/utils/memoryDiscovery.d.ts +5 -4
  122. package/dist/src/utils/memoryDiscovery.js +10 -9
  123. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  124. package/dist/src/utils/partUtils.d.ts +1 -2
  125. package/dist/src/utils/partUtils.js +0 -14
  126. package/dist/src/utils/partUtils.js.map +1 -1
  127. package/dist/src/utils/pathReader.d.ts +28 -0
  128. package/dist/src/utils/pathReader.js +47 -0
  129. package/dist/src/utils/pathReader.js.map +1 -0
  130. package/dist/src/utils/summarizer.js +2 -1
  131. package/dist/src/utils/summarizer.js.map +1 -1
  132. package/package.json +3 -3
@@ -0,0 +1,606 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ import * as Diff from 'diff';
9
+ import { BaseDeclarativeTool, Kind, ToolConfirmationOutcome, } from './tools.js';
10
+ import { ToolErrorType } from './tool-error.js';
11
+ import { makeRelative, shortenPath } from '../utils/paths.js';
12
+ import { isNodeError } from '../utils/errors.js';
13
+ import { ApprovalMode } from '../config/config.js';
14
+ import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
15
+ import { ReadFileTool } from './read-file.js';
16
+ import { IDEConnectionStatus } from '../ide/ide-client.js';
17
+ import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
18
+ export function applyReplacement(currentContent, oldString, newString, isNewFile) {
19
+ if (isNewFile) {
20
+ return newString;
21
+ }
22
+ if (currentContent === null) {
23
+ // Should not happen if not a new file, but defensively return empty or newString if oldString is also empty
24
+ return oldString === '' ? newString : '';
25
+ }
26
+ // If oldString is empty and it's not a new file, do not modify the content.
27
+ if (oldString === '' && !isNewFile) {
28
+ return currentContent;
29
+ }
30
+ return currentContent.replaceAll(oldString, newString);
31
+ }
32
+ function restoreTrailingNewline(originalContent, modifiedContent) {
33
+ const hadTrailingNewline = originalContent.endsWith('\n');
34
+ if (hadTrailingNewline && !modifiedContent.endsWith('\n')) {
35
+ return modifiedContent + '\n';
36
+ }
37
+ else if (!hadTrailingNewline && modifiedContent.endsWith('\n')) {
38
+ return modifiedContent.replace(/\n$/, '');
39
+ }
40
+ return modifiedContent;
41
+ }
42
+ async function calculateExactReplacement(context) {
43
+ const { currentContent, params } = context;
44
+ const { old_string, new_string } = params;
45
+ const normalizedCode = currentContent;
46
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
47
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
48
+ const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
49
+ if (exactOccurrences > 0) {
50
+ let modifiedCode = normalizedCode.replaceAll(normalizedSearch, normalizedReplace);
51
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
52
+ return {
53
+ newContent: modifiedCode,
54
+ occurrences: exactOccurrences,
55
+ finalOldString: normalizedSearch,
56
+ finalNewString: normalizedReplace,
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ async function calculateFlexibleReplacement(context) {
62
+ const { currentContent, params } = context;
63
+ const { old_string, new_string } = params;
64
+ const normalizedCode = currentContent;
65
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
66
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
67
+ const sourceLines = normalizedCode.match(/.*(?:\n|$)/g)?.slice(0, -1) ?? [];
68
+ const searchLinesStripped = normalizedSearch
69
+ .split('\n')
70
+ .map((line) => line.trim());
71
+ const replaceLines = normalizedReplace.split('\n');
72
+ let flexibleOccurrences = 0;
73
+ let i = 0;
74
+ while (i <= sourceLines.length - searchLinesStripped.length) {
75
+ const window = sourceLines.slice(i, i + searchLinesStripped.length);
76
+ const windowStripped = window.map((line) => line.trim());
77
+ const isMatch = windowStripped.every((line, index) => line === searchLinesStripped[index]);
78
+ if (isMatch) {
79
+ flexibleOccurrences++;
80
+ const firstLineInMatch = window[0];
81
+ const indentationMatch = firstLineInMatch.match(/^(\s*)/);
82
+ const indentation = indentationMatch ? indentationMatch[1] : '';
83
+ const newBlockWithIndent = replaceLines.map((line) => `${indentation}${line}`);
84
+ sourceLines.splice(i, searchLinesStripped.length, newBlockWithIndent.join('\n'));
85
+ i += replaceLines.length;
86
+ }
87
+ else {
88
+ i++;
89
+ }
90
+ }
91
+ if (flexibleOccurrences > 0) {
92
+ let modifiedCode = sourceLines.join('');
93
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
94
+ return {
95
+ newContent: modifiedCode,
96
+ occurrences: flexibleOccurrences,
97
+ finalOldString: normalizedSearch,
98
+ finalNewString: normalizedReplace,
99
+ };
100
+ }
101
+ return null;
102
+ }
103
+ /**
104
+ * Detects the line ending style of a string.
105
+ * @param content The string content to analyze.
106
+ * @returns '\r\n' for Windows-style, '\n' for Unix-style.
107
+ */
108
+ function detectLineEnding(content) {
109
+ // If a Carriage Return is found, assume Windows-style endings.
110
+ // This is a simple but effective heuristic.
111
+ return content.includes('\r\n') ? '\r\n' : '\n';
112
+ }
113
+ export async function calculateReplacement(context) {
114
+ const { currentContent, params } = context;
115
+ const { old_string, new_string } = params;
116
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
117
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
118
+ if (normalizedSearch === '') {
119
+ return {
120
+ newContent: currentContent,
121
+ occurrences: 0,
122
+ finalOldString: normalizedSearch,
123
+ finalNewString: normalizedReplace,
124
+ };
125
+ }
126
+ const exactResult = await calculateExactReplacement(context);
127
+ if (exactResult) {
128
+ return exactResult;
129
+ }
130
+ const flexibleResult = await calculateFlexibleReplacement(context);
131
+ if (flexibleResult) {
132
+ return flexibleResult;
133
+ }
134
+ return {
135
+ newContent: currentContent,
136
+ occurrences: 0,
137
+ finalOldString: normalizedSearch,
138
+ finalNewString: normalizedReplace,
139
+ };
140
+ }
141
+ export function getErrorReplaceResult(params, occurrences, expectedReplacements, finalOldString, finalNewString) {
142
+ let error = undefined;
143
+ if (occurrences === 0) {
144
+ error = {
145
+ display: `Failed to edit, could not find the string to replace.`,
146
+ 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 ${ReadFileTool.Name} tool to verify.`,
147
+ type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
148
+ };
149
+ }
150
+ else if (occurrences !== expectedReplacements) {
151
+ const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
152
+ error = {
153
+ display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
154
+ raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
155
+ type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
156
+ };
157
+ }
158
+ else if (finalOldString === finalNewString) {
159
+ error = {
160
+ display: `No changes to apply. The old_string and new_string are identical.`,
161
+ raw: `No changes to apply. The old_string and new_string are identical in file: ${params.file_path}`,
162
+ type: ToolErrorType.EDIT_NO_CHANGE,
163
+ };
164
+ }
165
+ return error;
166
+ }
167
+ class EditToolInvocation {
168
+ config;
169
+ params;
170
+ constructor(config, params) {
171
+ this.config = config;
172
+ this.params = params;
173
+ }
174
+ toolLocations() {
175
+ return [{ path: this.params.file_path }];
176
+ }
177
+ async attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding) {
178
+ const fixedEdit = await FixLLMEditWithInstruction(params.instruction, params.old_string, params.new_string, initialError.raw, currentContent, this.config.getGeminiClient(), abortSignal);
179
+ if (fixedEdit.noChangesRequired) {
180
+ return {
181
+ currentContent,
182
+ newContent: currentContent,
183
+ occurrences: 0,
184
+ isNewFile: false,
185
+ error: {
186
+ display: `No changes required. The file already meets the specified conditions.`,
187
+ raw: `A secondary check determined that no changes were necessary to fulfill the instruction. Explanation: ${fixedEdit.explanation}. Original error with the parameters given: ${initialError.raw}`,
188
+ type: ToolErrorType.EDIT_NO_CHANGE,
189
+ },
190
+ originalLineEnding,
191
+ };
192
+ }
193
+ const secondAttemptResult = await calculateReplacement({
194
+ params: {
195
+ ...params,
196
+ old_string: fixedEdit.search,
197
+ new_string: fixedEdit.replace,
198
+ },
199
+ currentContent,
200
+ abortSignal,
201
+ });
202
+ const secondError = getErrorReplaceResult(params, secondAttemptResult.occurrences, 1, // expectedReplacements is always 1 for smart_edit
203
+ secondAttemptResult.finalOldString, secondAttemptResult.finalNewString);
204
+ if (secondError) {
205
+ // The fix failed, return the original error
206
+ return {
207
+ currentContent,
208
+ newContent: currentContent,
209
+ occurrences: 0,
210
+ isNewFile: false,
211
+ error: initialError,
212
+ originalLineEnding,
213
+ };
214
+ }
215
+ return {
216
+ currentContent,
217
+ newContent: secondAttemptResult.newContent,
218
+ occurrences: secondAttemptResult.occurrences,
219
+ isNewFile: false,
220
+ error: undefined,
221
+ originalLineEnding,
222
+ };
223
+ }
224
+ /**
225
+ * Calculates the potential outcome of an edit operation.
226
+ * @param params Parameters for the edit operation
227
+ * @returns An object describing the potential edit outcome
228
+ * @throws File system errors if reading the file fails unexpectedly (e.g., permissions)
229
+ */
230
+ async calculateEdit(params, abortSignal) {
231
+ const expectedReplacements = 1;
232
+ let currentContent = null;
233
+ let fileExists = false;
234
+ let originalLineEnding = '\n'; // Default for new files
235
+ try {
236
+ currentContent = await this.config
237
+ .getFileSystemService()
238
+ .readTextFile(params.file_path);
239
+ originalLineEnding = detectLineEnding(currentContent);
240
+ currentContent = currentContent.replace(/\r\n/g, '\n');
241
+ fileExists = true;
242
+ }
243
+ catch (err) {
244
+ if (!isNodeError(err) || err.code !== 'ENOENT') {
245
+ throw err;
246
+ }
247
+ fileExists = false;
248
+ }
249
+ const isNewFile = params.old_string === '' && !fileExists;
250
+ if (isNewFile) {
251
+ return {
252
+ currentContent,
253
+ newContent: params.new_string,
254
+ occurrences: 1,
255
+ isNewFile: true,
256
+ error: undefined,
257
+ originalLineEnding,
258
+ };
259
+ }
260
+ // after this point, it's not a new file/edit
261
+ if (!fileExists) {
262
+ return {
263
+ currentContent,
264
+ newContent: '',
265
+ occurrences: 0,
266
+ isNewFile: false,
267
+ error: {
268
+ display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
269
+ raw: `File not found: ${params.file_path}`,
270
+ type: ToolErrorType.FILE_NOT_FOUND,
271
+ },
272
+ originalLineEnding,
273
+ };
274
+ }
275
+ if (currentContent === null) {
276
+ return {
277
+ currentContent,
278
+ newContent: '',
279
+ occurrences: 0,
280
+ isNewFile: false,
281
+ error: {
282
+ display: `Failed to read content of file.`,
283
+ raw: `Failed to read content of existing file: ${params.file_path}`,
284
+ type: ToolErrorType.READ_CONTENT_FAILURE,
285
+ },
286
+ originalLineEnding,
287
+ };
288
+ }
289
+ if (params.old_string === '') {
290
+ return {
291
+ currentContent,
292
+ newContent: currentContent,
293
+ occurrences: 0,
294
+ isNewFile: false,
295
+ error: {
296
+ display: `Failed to edit. Attempted to create a file that already exists.`,
297
+ raw: `File already exists, cannot create: ${params.file_path}`,
298
+ type: ToolErrorType.ATTEMPT_TO_CREATE_EXISTING_FILE,
299
+ },
300
+ originalLineEnding,
301
+ };
302
+ }
303
+ const replacementResult = await calculateReplacement({
304
+ params,
305
+ currentContent,
306
+ abortSignal,
307
+ });
308
+ const initialError = getErrorReplaceResult(params, replacementResult.occurrences, expectedReplacements, replacementResult.finalOldString, replacementResult.finalNewString);
309
+ if (!initialError) {
310
+ return {
311
+ currentContent,
312
+ newContent: replacementResult.newContent,
313
+ occurrences: replacementResult.occurrences,
314
+ isNewFile: false,
315
+ error: undefined,
316
+ originalLineEnding,
317
+ };
318
+ }
319
+ // If there was an error, try to self-correct.
320
+ return this.attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding);
321
+ }
322
+ /**
323
+ * Handles the confirmation prompt for the Edit tool in the CLI.
324
+ * It needs to calculate the diff to show the user.
325
+ */
326
+ async shouldConfirmExecute(abortSignal) {
327
+ if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
328
+ return false;
329
+ }
330
+ let editData;
331
+ try {
332
+ editData = await this.calculateEdit(this.params, abortSignal);
333
+ }
334
+ catch (error) {
335
+ const errorMsg = error instanceof Error ? error.message : String(error);
336
+ console.log(`Error preparing edit: ${errorMsg}`);
337
+ return false;
338
+ }
339
+ if (editData.error) {
340
+ console.log(`Error: ${editData.error.display}`);
341
+ return false;
342
+ }
343
+ const fileName = path.basename(this.params.file_path);
344
+ const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
345
+ const ideClient = this.config.getIdeClient();
346
+ const ideConfirmation = this.config.getIdeMode() &&
347
+ ideClient?.getConnectionStatus().status === IDEConnectionStatus.Connected
348
+ ? ideClient.openDiff(this.params.file_path, editData.newContent)
349
+ : undefined;
350
+ const confirmationDetails = {
351
+ type: 'edit',
352
+ title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
353
+ fileName,
354
+ filePath: this.params.file_path,
355
+ fileDiff,
356
+ originalContent: editData.currentContent,
357
+ newContent: editData.newContent,
358
+ onConfirm: async (outcome) => {
359
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
360
+ this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
361
+ }
362
+ if (ideConfirmation) {
363
+ const result = await ideConfirmation;
364
+ if (result.status === 'accepted' && result.content) {
365
+ // TODO(chrstn): See https://github.com/google-gemini/gemini-cli/pull/5618#discussion_r2255413084
366
+ // for info on a possible race condition where the file is modified on disk while being edited.
367
+ this.params.old_string = editData.currentContent ?? '';
368
+ this.params.new_string = result.content;
369
+ }
370
+ }
371
+ },
372
+ ideConfirmation,
373
+ };
374
+ return confirmationDetails;
375
+ }
376
+ getDescription() {
377
+ const relativePath = makeRelative(this.params.file_path, this.config.getTargetDir());
378
+ if (this.params.old_string === '') {
379
+ return `Create ${shortenPath(relativePath)}`;
380
+ }
381
+ const oldStringSnippet = this.params.old_string.split('\n')[0].substring(0, 30) +
382
+ (this.params.old_string.length > 30 ? '...' : '');
383
+ const newStringSnippet = this.params.new_string.split('\n')[0].substring(0, 30) +
384
+ (this.params.new_string.length > 30 ? '...' : '');
385
+ if (this.params.old_string === this.params.new_string) {
386
+ return `No file changes to ${shortenPath(relativePath)}`;
387
+ }
388
+ return `${shortenPath(relativePath)}: ${oldStringSnippet} => ${newStringSnippet}`;
389
+ }
390
+ /**
391
+ * Executes the edit operation with the given parameters.
392
+ * @param params Parameters for the edit operation
393
+ * @returns Result of the edit operation
394
+ */
395
+ async execute(signal) {
396
+ let editData;
397
+ try {
398
+ editData = await this.calculateEdit(this.params, signal);
399
+ }
400
+ catch (error) {
401
+ const errorMsg = error instanceof Error ? error.message : String(error);
402
+ return {
403
+ llmContent: `Error preparing edit: ${errorMsg}`,
404
+ returnDisplay: `Error preparing edit: ${errorMsg}`,
405
+ error: {
406
+ message: errorMsg,
407
+ type: ToolErrorType.EDIT_PREPARATION_FAILURE,
408
+ },
409
+ };
410
+ }
411
+ if (editData.error) {
412
+ return {
413
+ llmContent: editData.error.raw,
414
+ returnDisplay: `Error: ${editData.error.display}`,
415
+ error: {
416
+ message: editData.error.raw,
417
+ type: editData.error.type,
418
+ },
419
+ };
420
+ }
421
+ try {
422
+ this.ensureParentDirectoriesExist(this.params.file_path);
423
+ let finalContent = editData.newContent;
424
+ // Restore original line endings if they were CRLF
425
+ if (!editData.isNewFile && editData.originalLineEnding === '\r\n') {
426
+ finalContent = finalContent.replace(/\n/g, '\r\n');
427
+ }
428
+ await this.config
429
+ .getFileSystemService()
430
+ .writeTextFile(this.params.file_path, finalContent);
431
+ let displayResult;
432
+ if (editData.isNewFile) {
433
+ displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
434
+ }
435
+ else {
436
+ // Generate diff for display, even though core logic doesn't technically need it
437
+ // The CLI wrapper will use this part of the ToolResult
438
+ const fileName = path.basename(this.params.file_path);
439
+ const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
440
+ editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
441
+ const originallyProposedContent = this.params.ai_proposed_string || this.params.new_string;
442
+ const diffStat = getDiffStat(fileName, editData.currentContent ?? '', originallyProposedContent, this.params.new_string);
443
+ displayResult = {
444
+ fileDiff,
445
+ fileName,
446
+ originalContent: editData.currentContent,
447
+ newContent: editData.newContent,
448
+ diffStat,
449
+ };
450
+ }
451
+ const llmSuccessMessageParts = [
452
+ editData.isNewFile
453
+ ? `Created new file: ${this.params.file_path} with provided content.`
454
+ : `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
455
+ ];
456
+ if (this.params.modified_by_user) {
457
+ llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
458
+ }
459
+ return {
460
+ llmContent: llmSuccessMessageParts.join(' '),
461
+ returnDisplay: displayResult,
462
+ };
463
+ }
464
+ catch (error) {
465
+ const errorMsg = error instanceof Error ? error.message : String(error);
466
+ return {
467
+ llmContent: `Error executing edit: ${errorMsg}`,
468
+ returnDisplay: `Error writing file: ${errorMsg}`,
469
+ error: {
470
+ message: errorMsg,
471
+ type: ToolErrorType.FILE_WRITE_FAILURE,
472
+ },
473
+ };
474
+ }
475
+ }
476
+ /**
477
+ * Creates parent directories if they don't exist
478
+ */
479
+ ensureParentDirectoriesExist(filePath) {
480
+ const dirName = path.dirname(filePath);
481
+ if (!fs.existsSync(dirName)) {
482
+ fs.mkdirSync(dirName, { recursive: true });
483
+ }
484
+ }
485
+ }
486
+ /**
487
+ * Implementation of the Edit tool logic
488
+ */
489
+ export class SmartEditTool extends BaseDeclarativeTool {
490
+ config;
491
+ static Name = 'replace';
492
+ constructor(config) {
493
+ super(SmartEditTool.Name, 'Edit', `Replaces text within a file. Replaces a single occurrence. 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.
494
+
495
+ The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
496
+
497
+ Expectation for required parameters:
498
+ 1. \`file_path\` MUST be an absolute path; otherwise an error will be thrown.
499
+ 2. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
500
+ 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 and that \`old_string\` and \`new_string\` are different.
501
+ 4. \`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.
502
+ 5. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
503
+ **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.
504
+ 6. 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.
505
+ **Multiple replacements:** If there are multiple and ambiguous occurences of the \`old_string\` in the file, the tool will also fail.`, Kind.Edit, {
506
+ properties: {
507
+ file_path: {
508
+ description: "The absolute path to the file to modify. Must start with '/'.",
509
+ type: 'string',
510
+ },
511
+ instruction: {
512
+ 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.
513
+
514
+ A good instruction should concisely answer:
515
+ 1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
516
+ 2. WHERE should the change happen? (e.g., "...in the 'renderUserProfile' function...")
517
+ 3. WHAT is the high-level change? (e.g., "...add a null check for the 'user' object...")
518
+ 4. WHAT is the desired outcome? (e.g., "...so that it displays a loading spinner instead of crashing.")
519
+
520
+ **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."
521
+
522
+ **BAD Examples:**
523
+ - "Change the text." (Too vague)
524
+ - "Fix the bug." (Doesn't explain the bug or the fix)
525
+ - "Replace the line with this new line." (Brittle, just repeats the other parameters)
526
+ `,
527
+ type: 'string',
528
+ },
529
+ old_string: {
530
+ description: 'The exact literal text to replace, preferably unescaped. 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.',
531
+ type: 'string',
532
+ },
533
+ new_string: {
534
+ description: 'The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.',
535
+ type: 'string',
536
+ },
537
+ },
538
+ required: ['file_path', 'instruction', 'old_string', 'new_string'],
539
+ type: 'object',
540
+ });
541
+ this.config = config;
542
+ }
543
+ /**
544
+ * Validates the parameters for the Edit tool
545
+ * @param params Parameters to validate
546
+ * @returns Error message string or null if valid
547
+ */
548
+ validateToolParamValues(params) {
549
+ if (!params.file_path) {
550
+ return "The 'file_path' parameter must be non-empty.";
551
+ }
552
+ if (!path.isAbsolute(params.file_path)) {
553
+ return `File path must be absolute: ${params.file_path}`;
554
+ }
555
+ const workspaceContext = this.config.getWorkspaceContext();
556
+ if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
557
+ const directories = workspaceContext.getDirectories();
558
+ return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
559
+ }
560
+ return null;
561
+ }
562
+ createInvocation(params) {
563
+ return new EditToolInvocation(this.config, params);
564
+ }
565
+ getModifyContext(_) {
566
+ return {
567
+ getFilePath: (params) => params.file_path,
568
+ getCurrentContent: async (params) => {
569
+ try {
570
+ return this.config
571
+ .getFileSystemService()
572
+ .readTextFile(params.file_path);
573
+ }
574
+ catch (err) {
575
+ if (!isNodeError(err) || err.code !== 'ENOENT')
576
+ throw err;
577
+ return '';
578
+ }
579
+ },
580
+ getProposedContent: async (params) => {
581
+ try {
582
+ const currentContent = await this.config
583
+ .getFileSystemService()
584
+ .readTextFile(params.file_path);
585
+ return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
586
+ }
587
+ catch (err) {
588
+ if (!isNodeError(err) || err.code !== 'ENOENT')
589
+ throw err;
590
+ return '';
591
+ }
592
+ },
593
+ createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
594
+ const content = originalParams.new_string;
595
+ return {
596
+ ...originalParams,
597
+ ai_proposed_string: content,
598
+ old_string: oldContent,
599
+ new_string: modifiedProposedContent,
600
+ modified_by_user: true,
601
+ };
602
+ },
603
+ };
604
+ }
605
+ }
606
+ //# sourceMappingURL=smart-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-edit.js","sourceRoot":"","sources":["../../../src/tools/smart-edit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,IAAI,EAEJ,uBAAuB,G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,MAAM;yBACrC,oBAAoB,EAAE;yBACtB,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBAClC,OAAO,gBAAgB,CACrB,cAAc,EACd,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,KAAK,EAAE,IAAI,cAAc,KAAK,EAAE,CAClD,CAAC;gBACJ,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;wBAAE,MAAM,GAAG,CAAC;oBAC1D,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YACD,mBAAmB,EAAE,CACnB,UAAkB,EAClB,uBAA+B,EAC/B,cAA8B,EACd,EAAE;gBAClB,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC;gBAC1C,OAAO;oBACL,GAAG,cAAc;oBACjB,kBAAkB,EAAE,OAAO;oBAC3B,UAAU,EAAE,UAAU;oBACtB,UAAU,EAAE,uBAAuB;oBACnC,gBAAgB,EAAE,IAAI;iBACvB,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC"}
@@ -7,6 +7,7 @@ import { FunctionDeclaration } from '@google/genai';
7
7
  import { AnyDeclarativeTool, ToolResult, BaseTool, BaseToolInvocation } from './tools.js';
8
8
  import { ToolContext } from './tool-context.js';
9
9
  import { Config } from '../config/config.js';
10
+ import type { EventEmitter } from 'node:events';
10
11
  type ToolParams = Record<string, unknown>;
11
12
  export declare class DiscoveredTool extends BaseTool<ToolParams, ToolResult> {
12
13
  private readonly config;
@@ -27,7 +28,7 @@ export declare class ToolRegistry {
27
28
  private config;
28
29
  private mcpClientManager;
29
30
  private logger;
30
- constructor(config: Config);
31
+ constructor(config: Config, eventEmitter?: EventEmitter);
31
32
  /**
32
33
  * Registers a tool definition.
33
34
  * @param tool - The tool object containing schema and execution logic.