The open source coding agent.
TypeScript
refactor(file): destroy FileWatcher facade (#22091)
Kit Langton824c12c01a9d
diff --git a/packages/opencode/src/effect/bootstrap-runtime.ts b/packages/opencode/src/effect/bootstrap-runtime.tsindex 648f2484e63..78df313e869 100644--- a/packages/opencode/src/effect/bootstrap-runtime.ts+++ b/packages/opencode/src/effect/bootstrap-runtime.ts@@ -1,9 +1,10 @@import { Layer, ManagedRuntime } from "effect"import { memoMap } from "./run-service"+import { FileWatcher } from "@/file/watcher"import { Format } from "@/format"import { ShareNext } from "@/share/share-next"-export const BootstrapLayer = Layer.mergeAll(Format.defaultLayer, ShareNext.defaultLayer)+export const BootstrapLayer = Layer.mergeAll(Format.defaultLayer, ShareNext.defaultLayer, FileWatcher.defaultLayer)export const BootstrapRuntime = ManagedRuntime.make(BootstrapLayer, { memoMap })diff --git a/packages/opencode/src/file/watcher.ts b/packages/opencode/src/file/watcher.tsindex 609543fb06a..8737045c18c 100644--- a/packages/opencode/src/file/watcher.ts+++ b/packages/opencode/src/file/watcher.ts@@ -8,7 +8,6 @@ import z from "zod"import { Bus } from "@/bus"import { BusEvent } from "@/bus/bus-event"import { InstanceState } from "@/effect/instance-state"-import { makeRuntime } from "@/effect/run-service"import { Flag } from "@/flag/flag"import { Git } from "@/git"import { Instance } from "@/project/instance"@@ -161,10 +160,4 @@ export namespace FileWatcher {)export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer), Layer.provide(Git.defaultLayer))-- const { runPromise } = makeRuntime(Service, defaultLayer)-- export function init() {- return runPromise((svc) => svc.init())- }}diff --git a/packages/opencode/src/project/bootstrap.ts b/packages/opencode/src/project/bootstrap.tsindex 9f6f7fa6fac..b7d739fcd0d 100644--- a/packages/opencode/src/project/bootstrap.ts+++ b/packages/opencode/src/project/bootstrap.ts@@ -2,7 +2,6 @@ import { Plugin } from "../plugin"import { Format } from "../format"import { LSP } from "../lsp"import { File } from "../file"-import { FileWatcher } from "../file/watcher"import { Snapshot } from "../snapshot"import { Project } from "./project"import { Vcs } from "./vcs"@@ -11,6 +10,7 @@ import { Command } from "../command"import { Instance } from "./instance"import { Log } from "@/util/log"import { BootstrapRuntime } from "@/effect/bootstrap-runtime"+import { FileWatcher } from "@/file/watcher"import { ShareNext } from "@/share/share-next"export async function InstanceBootstrap() {@@ -20,7 +20,7 @@ export async function InstanceBootstrap() {void BootstrapRuntime.runPromise(Format.Service.use((svc) => svc.init()))await LSP.init()File.init()- FileWatcher.init()+ void BootstrapRuntime.runPromise(FileWatcher.Service.use((svc) => svc.init()))Vcs.init()Snapshot.init()diff --git a/packages/opencode/test/project/vcs.test.ts b/packages/opencode/test/project/vcs.test.tsindex a327f65fab2..1610902af57 100644--- a/packages/opencode/test/project/vcs.test.ts+++ b/packages/opencode/test/project/vcs.test.ts@@ -3,6 +3,7 @@ import { afterEach, describe, expect, test } from "bun:test"import fs from "fs/promises"import path from "path"import { tmpdir } from "../fixture/fixture"+import { AppRuntime } from "../../src/effect/app-runtime"import { FileWatcher } from "../../src/file/watcher"import { Instance } from "../../src/project/instance"import { GlobalBus } from "../../src/bus/global"@@ -19,7 +20,7 @@ async function withVcs(directory: string, body: () => Promise<void>) {return Instance.provide({directory,fn: async () => {- FileWatcher.init()+ void AppRuntime.runPromise(FileWatcher.Service.use((svc) => svc.init()))Vcs.init()await Bun.sleep(500)await body()