diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index 1680ec16b8..6c7ec4cf65 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -928,7 +928,7 @@ class EditToolInvocation : `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`, ]; const snippet = getDiffContextSnippet( - originalContent, + editData.currentContent ?? '', finalContent, 5, ); diff --git a/packages/core/src/tools/ripGrep.ts b/packages/core/src/tools/ripGrep.ts index fcdff05ea5..2b9c3b9f0b 100644 --- a/packages/core/src/tools/ripGrep.ts +++ b/packages/core/src/tools/ripGrep.ts @@ -161,7 +161,6 @@ export interface RipGrepToolParams { interface GrepMatch { filePath: string; absolutePath: string; - absolutePath: string; lineNumber: number; line: string; isContext?: boolean; @@ -329,11 +328,10 @@ class GrepToolInvocation extends BaseToolInvocation< fileMatches[0].absolutePath, 'utf8', ); - fileLines = content.split(/ ? -/); + fileLines = content.split(/\r?\n/); } catch (err) { debugLogger.warn( - \`Failed to read file for context: \${fileMatches[0].absolutePath}\`, + `Failed to read file for context: ${fileMatches[0].absolutePath}`, err, ); } @@ -358,7 +356,9 @@ class GrepToolInvocation extends BaseToolInvocation< }); seenLines.add(i + 1); } else if (i + 1 === match.lineNumber) { - const index = newFileMatches.findIndex(m => m.lineNumber === i + 1); + const index = newFileMatches.findIndex( + (m) => m.lineNumber === i + 1, + ); if (index !== -1) { newFileMatches[index].isContext = false; }