diff options
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index 8d90dfe4..35e828b0 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -125,7 +125,9 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> { | undefined = undefined; try { - currentContent = fs.readFileSync(params.file_path, 'utf8'); + currentContent = await this.config + .getFileSystemService() + .readTextFile(params.file_path); // Normalize line endings to LF for consistent processing. currentContent = currentContent.replace(/\r\n/g, '\n'); fileExists = true; @@ -339,7 +341,9 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> { try { this.ensureParentDirectoriesExist(this.params.file_path); - fs.writeFileSync(this.params.file_path, editData.newContent, 'utf8'); + await this.config + .getFileSystemService() + .writeTextFile(this.params.file_path, editData.newContent); let displayResult: ToolResultDisplay; if (editData.isNewFile) { @@ -504,7 +508,9 @@ Expectation for required parameters: getFilePath: (params: EditToolParams) => params.file_path, getCurrentContent: async (params: EditToolParams): Promise<string> => { try { - return fs.readFileSync(params.file_path, 'utf8'); + return this.config + .getFileSystemService() + .readTextFile(params.file_path); } catch (err) { if (!isNodeError(err) || err.code !== 'ENOENT') throw err; return ''; @@ -512,7 +518,9 @@ Expectation for required parameters: }, getProposedContent: async (params: EditToolParams): Promise<string> => { try { - const currentContent = fs.readFileSync(params.file_path, 'utf8'); + const currentContent = await this.config + .getFileSystemService() + .readTextFile(params.file_path); return applyReplacement( currentContent, params.old_string, |
