mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-11 07:43:47 +00:00
feat(core): reload config on filesystem changes
This commit is contained in:
parent
b04d8d53e6
commit
c9b24ef027
48 changed files with 612 additions and 526 deletions
|
|
@ -12,6 +12,7 @@ import { LSP } from "@/lsp/lsp"
|
|||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import DESCRIPTION from "./apply_patch.txt"
|
||||
import { FileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { FileSystemV1 } from "@opencode-ai/schema/filesystem-v1"
|
||||
import { Format } from "../format"
|
||||
import * as Bom from "@/util/bom"
|
||||
|
||||
|
|
@ -253,7 +254,7 @@ export const ApplyPatchTool = Tool.define(
|
|||
if (yield* format.file(edited)) {
|
||||
yield* Bom.syncFile(afs, edited, change.bom)
|
||||
}
|
||||
yield* events.publish(FileSystem.Event.Edited, { file: edited })
|
||||
yield* events.publish(FileSystemV1.Event.Edited, { file: edited })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { LSP } from "@/lsp/lsp"
|
|||
import { createTwoFilesPatch, diffLines } from "diff"
|
||||
import DESCRIPTION from "./edit.txt"
|
||||
import { FileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { FileSystemV1 } from "@opencode-ai/schema/filesystem-v1"
|
||||
import { Watcher } from "@opencode-ai/core/filesystem/watcher"
|
||||
import { EventV2Bridge } from "@/event-v2-bridge"
|
||||
import { Format } from "../format"
|
||||
|
|
@ -112,7 +113,7 @@ export const EditTool = Tool.define(
|
|||
if (yield* format.file(filePath)) {
|
||||
contentNew = yield* Bom.syncFile(afs, filePath, desiredBom)
|
||||
}
|
||||
yield* events.publish(FileSystem.Event.Edited, { file: filePath })
|
||||
yield* events.publish(FileSystemV1.Event.Edited, { file: filePath })
|
||||
yield* events.publish(Watcher.Event.Updated, {
|
||||
file: filePath,
|
||||
event: "add",
|
||||
|
|
@ -156,7 +157,7 @@ export const EditTool = Tool.define(
|
|||
if (yield* format.file(filePath)) {
|
||||
contentNew = yield* Bom.syncFile(afs, filePath, desiredBom)
|
||||
}
|
||||
yield* events.publish(FileSystem.Event.Edited, { file: filePath })
|
||||
yield* events.publish(FileSystemV1.Event.Edited, { file: filePath })
|
||||
yield* events.publish(Watcher.Event.Updated, {
|
||||
file: filePath,
|
||||
event: "change",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { createTwoFilesPatch } from "diff"
|
|||
import DESCRIPTION from "./write.txt"
|
||||
import { EventV2Bridge } from "@/event-v2-bridge"
|
||||
import { FileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { FileSystemV1 } from "@opencode-ai/schema/filesystem-v1"
|
||||
import { Watcher } from "@opencode-ai/core/filesystem/watcher"
|
||||
import { Format } from "../format"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
|
|
@ -65,7 +66,7 @@ export const WriteTool = Tool.define(
|
|||
if (yield* format.file(filepath)) {
|
||||
yield* Bom.syncFile(fs, filepath, desiredBom)
|
||||
}
|
||||
yield* events.publish(FileSystem.Event.Edited, { file: filepath })
|
||||
yield* events.publish(FileSystemV1.Event.Edited, { file: filepath })
|
||||
yield* events.publish(Watcher.Event.Updated, {
|
||||
file: filepath,
|
||||
event: exists ? "change" : "add",
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ describe("v2 location HttpApi", () => {
|
|||
expect(
|
||||
Schema.decodeUnknownSync(Event)({
|
||||
id: "evt_test",
|
||||
type: "file.watcher.updated",
|
||||
type: "filesystem.changed",
|
||||
location: { directory: "/tmp/project" },
|
||||
data: {},
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue