Explorar o código

refactor: migrate src/tool/write.ts from Bun.file() to Filesystem module (#14119)

Dax hai 2 meses
pai
achega
36bc07a5af
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      packages/opencode/src/tool/write.ts

+ 3 - 4
packages/opencode/src/tool/write.ts

@@ -26,9 +26,8 @@ export const WriteTool = Tool.define("write", {
     const filepath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath)
     await assertExternalDirectory(ctx, filepath)
 
-    const file = Bun.file(filepath)
-    const exists = await file.exists()
-    const contentOld = exists ? await file.text() : ""
+    const exists = await Filesystem.exists(filepath)
+    const contentOld = exists ? await Filesystem.readText(filepath) : ""
     if (exists) await FileTime.assert(ctx.sessionID, filepath)
 
     const diff = trimDiff(createTwoFilesPatch(filepath, filepath, contentOld, params.content))
@@ -42,7 +41,7 @@ export const WriteTool = Tool.define("write", {
       },
     })
 
-    await Bun.write(filepath, params.content)
+    await Filesystem.write(filepath, params.content)
     await Bus.publish(File.Event.Edited, {
       file: filepath,
     })