Skip to content

Commit f38f415

Browse files
authored
refactor: collapse Format facade (#21980)
1 parent 4341ab8 commit f38f415

3 files changed

Lines changed: 3 additions & 17 deletions

File tree

packages/opencode/src/format/index.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Effect, Layer, Context } from "effect"
22
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
33
import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner"
44
import { InstanceState } from "@/effect/instance-state"
5-
import { makeRuntime } from "@/effect/run-service"
65
import path from "path"
76
import { mergeDeep } from "remeda"
87
import z from "zod"
@@ -193,18 +192,4 @@ export namespace Format {
193192
Layer.provide(Config.defaultLayer),
194193
Layer.provide(CrossSpawnSpawner.defaultLayer),
195194
)
196-
197-
const { runPromise } = makeRuntime(Service, defaultLayer)
198-
199-
export async function init() {
200-
return runPromise((s) => s.init())
201-
}
202-
203-
export async function status() {
204-
return runPromise((s) => s.status())
205-
}
206-
207-
export async function file(filepath: string) {
208-
return runPromise((s) => s.file(filepath))
209-
}
210195
}

packages/opencode/src/project/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function InstanceBootstrap() {
1717
Log.Default.info("bootstrapping", { directory: Instance.directory })
1818
await Plugin.init()
1919
void AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.init()))
20-
Format.init()
20+
void AppRuntime.runPromise(Format.Service.use((svc) => svc.init()))
2121
await LSP.init()
2222
File.init()
2323
FileWatcher.init()

packages/opencode/src/server/instance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { ProviderRoutes } from "./routes/provider"
3030
import { EventRoutes } from "./routes/event"
3131
import { errorHandler } from "./middleware"
3232
import { getMimeType } from "hono/utils/mime"
33+
import { AppRuntime } from "@/effect/app-runtime"
3334

3435
const log = Log.create({ service: "server" })
3536

@@ -277,7 +278,7 @@ export const InstanceRoutes = (upgrade: UpgradeWebSocket, app: Hono = new Hono()
277278
},
278279
}),
279280
async (c) => {
280-
return c.json(await Format.status())
281+
return c.json(await AppRuntime.runPromise(Format.Service.use((svc) => svc.status())))
281282
},
282283
)
283284
.all("/*", async (c) => {

0 commit comments

Comments
 (0)