summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/write-file.ts
diff options
context:
space:
mode:
authorConrad Irwin <[email protected]>2025-08-18 16:29:45 -0600
committerGitHub <[email protected]>2025-08-18 22:29:45 +0000
commitfb3ceb0da4e2cd636013c2c36a9c0016c01aa47f (patch)
tree7aa43846dd88bd5acdb8898b0ccd2e685f2d5ece /packages/core/src/tools/write-file.ts
parent4394b6ab4fc86637b07fcd26b9a790c627d1e065 (diff)
Read and write files through Zed (#6169)
Co-authored-by: Agus Zubiaga <[email protected]>
Diffstat (limited to 'packages/core/src/tools/write-file.ts')
-rw-r--r--packages/core/src/tools/write-file.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts
index c889d6a3..57cc4646 100644
--- a/packages/core/src/tools/write-file.ts
+++ b/packages/core/src/tools/write-file.ts
@@ -80,7 +80,9 @@ export async function getCorrectedFileContent(
let correctedContent = proposedContent;
try {
- originalContent = fs.readFileSync(filePath, 'utf8');
+ originalContent = await config
+ .getFileSystemService()
+ .readTextFile(filePath);
fileExists = true; // File exists and was read
} catch (err) {
if (isNodeError(err) && err.code === 'ENOENT') {
@@ -261,7 +263,9 @@ class WriteFileToolInvocation extends BaseToolInvocation<
fs.mkdirSync(dirName, { recursive: true });
}
- fs.writeFileSync(file_path, fileContent, 'utf8');
+ await this.config
+ .getFileSystemService()
+ .writeTextFile(file_path, fileContent);
// Generate diff for display result
const fileName = path.basename(file_path);