Compare commits

...

2 Commits

Author SHA1 Message Date
Dax
4ee77d927d Merge branch 'dev' into migrate-write-tool 2026-02-18 17:53:43 -05:00
Dax Raad
6c2aa7c0e1 refactor: migrate src/tool/write.ts from Bun.file() to Filesystem module
Replace Bun.file() and Bun.write() usage with Filesystem module:

- Replace Bun.file(filepath).exists() with Filesystem.exists()

- Replace Bun.file(filepath).text() with Filesystem.readText()

- Replace Bun.write() with Filesystem.write()

All 13 tests pass for the write tool.
2026-02-18 10:39:05 -05:00

View File

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