|
|
@@ -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,
|
|
|
})
|