refactor(core): consolidate filesystem services (#30447)
This commit is contained in:
@@ -2,16 +2,16 @@ import * as path from "path"
|
||||
import { Effect, Schema } from "effect"
|
||||
import * as Tool from "./tool"
|
||||
import { EventV2Bridge } from "@/event-v2-bridge"
|
||||
import { FileWatcher } from "../file/watcher"
|
||||
import { Watcher } from "@opencode-ai/core/filesystem/watcher"
|
||||
import { InstanceState } from "@/effect/instance-state"
|
||||
import { Patch } from "../patch"
|
||||
import { createTwoFilesPatch, diffLines } from "diff"
|
||||
import { assertExternalDirectoryEffect } from "./external-directory"
|
||||
import { trimDiff } from "./edit"
|
||||
import { LSP } from "@/lsp/lsp"
|
||||
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import DESCRIPTION from "./apply_patch.txt"
|
||||
import { File } from "../file"
|
||||
import { FileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { Format } from "../format"
|
||||
import * as Bom from "@/util/bom"
|
||||
|
||||
@@ -23,7 +23,7 @@ export const ApplyPatchTool = Tool.define(
|
||||
"apply_patch",
|
||||
Effect.gen(function* () {
|
||||
const lsp = yield* LSP.Service
|
||||
const afs = yield* AppFileSystem.Service
|
||||
const afs = yield* FSUtil.Service
|
||||
const format = yield* Format.Service
|
||||
const events = yield* EventV2Bridge.Service
|
||||
|
||||
@@ -253,13 +253,13 @@ export const ApplyPatchTool = Tool.define(
|
||||
if (yield* format.file(edited)) {
|
||||
yield* Bom.syncFile(afs, edited, change.bom)
|
||||
}
|
||||
yield* events.publish(File.Event.Edited, { file: edited })
|
||||
yield* events.publish(FileSystem.Event.Edited, { file: edited })
|
||||
}
|
||||
}
|
||||
|
||||
// Publish file change events
|
||||
for (const update of updates) {
|
||||
yield* events.publish(FileWatcher.Event.Updated, update)
|
||||
yield* events.publish(Watcher.Event.Updated, update)
|
||||
}
|
||||
|
||||
// Notify LSP of file changes and collect diagnostics
|
||||
@@ -286,7 +286,7 @@ export const ApplyPatchTool = Tool.define(
|
||||
for (const change of fileChanges) {
|
||||
if (change.type === "delete") continue
|
||||
const target = change.movePath ?? change.filePath
|
||||
const block = LSP.Diagnostic.report(target, diagnostics[AppFileSystem.normalizePath(target)] ?? [])
|
||||
const block = LSP.Diagnostic.report(target, diagnostics[FSUtil.normalizePath(target)] ?? [])
|
||||
if (!block) continue
|
||||
const rel = path.relative(instance.worktree, target).replaceAll("\\", "/")
|
||||
output += `\n\nLSP errors detected in ${rel}, please fix:\n${block}`
|
||||
|
||||
Reference in New Issue
Block a user