diff --git a/packages/opencode/src/tool/apply_patch.ts b/packages/opencode/src/tool/apply_patch.ts index c77bf4b5eb..c23c0dd3d0 100644 --- a/packages/opencode/src/tool/apply_patch.ts +++ b/packages/opencode/src/tool/apply_patch.ts @@ -12,6 +12,7 @@ import { trimDiff } from "./edit" import { LSP } from "../lsp" import { Filesystem } from "../util/filesystem" import DESCRIPTION from "./apply_patch.txt" +import { File } from "../file" import { Format } from "../format" const PatchParams = z.object({ @@ -221,6 +222,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", { if (edited) { await Format.file(edited) + Bus.publish(File.Event.Edited, { file: edited }) } } diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts index 106e29d198..554d547d05 100644 --- a/packages/opencode/src/tool/edit.ts +++ b/packages/opencode/src/tool/edit.ts @@ -9,6 +9,7 @@ import { Tool } from "./tool" import { LSP } from "../lsp" import { createTwoFilesPatch, diffLines } from "diff" import DESCRIPTION from "./edit.txt" +import { File } from "../file" import { FileWatcher } from "../file/watcher" import { Bus } from "../bus" import { Format } from "../format" @@ -72,6 +73,7 @@ export const EditTool = Tool.define("edit", { }) await Filesystem.write(filePath, params.newString) await Format.file(filePath) + Bus.publish(File.Event.Edited, { file: filePath }) await Bus.publish(FileWatcher.Event.Updated, { file: filePath, event: existed ? "change" : "add", @@ -107,6 +109,7 @@ export const EditTool = Tool.define("edit", { await Filesystem.write(filePath, contentNew) await Format.file(filePath) + Bus.publish(File.Event.Edited, { file: filePath }) await Bus.publish(FileWatcher.Event.Updated, { file: filePath, event: "change", diff --git a/packages/opencode/src/tool/write.ts b/packages/opencode/src/tool/write.ts index 157f06195e..6b134e5253 100644 --- a/packages/opencode/src/tool/write.ts +++ b/packages/opencode/src/tool/write.ts @@ -5,6 +5,7 @@ import { LSP } from "../lsp" import { createTwoFilesPatch } from "diff" import DESCRIPTION from "./write.txt" import { Bus } from "../bus" +import { File } from "../file" import { FileWatcher } from "../file/watcher" import { Format } from "../format" import { FileTime } from "../file/time" @@ -43,6 +44,7 @@ export const WriteTool = Tool.define("write", { await Filesystem.write(filepath, params.content) await Format.file(filepath) + Bus.publish(File.Event.Edited, { file: filepath }) await Bus.publish(FileWatcher.Event.Updated, { file: filepath, event: exists ? "change" : "add",