Skip to content

Commit 5e3dc80

Browse files
authored
refactor: collapse command facade (#21981)
1 parent d84cc33 commit 5e3dc80

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

packages/opencode/src/command/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BusEvent } from "@/bus/bus-event"
22
import { InstanceState } from "@/effect/instance-state"
3-
import { makeRuntime } from "@/effect/run-service"
43
import type { InstanceContext } from "@/project/instance"
54
import { SessionID, MessageID } from "@/session/schema"
65
import { Effect, Layer, Context } from "effect"
@@ -189,10 +188,4 @@ export namespace Command {
189188
Layer.provide(MCP.defaultLayer),
190189
Layer.provide(Skill.defaultLayer),
191190
)
192-
193-
const { runPromise } = makeRuntime(Service, defaultLayer)
194-
195-
export async function list() {
196-
return runPromise((svc) => svc.list())
197-
}
198191
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Layer, ManagedRuntime } from "effect"
2+
import { memoMap } from "./run-service"
3+
4+
import { Format } from "@/format"
5+
import { ShareNext } from "@/share/share-next"
6+
7+
export const BootstrapLayer = Layer.mergeAll(Format.defaultLayer, ShareNext.defaultLayer)
8+
9+
export const BootstrapRuntime = ManagedRuntime.make(BootstrapLayer, { memoMap })

packages/opencode/src/project/bootstrap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { Bus } from "../bus"
1010
import { Command } from "../command"
1111
import { Instance } from "./instance"
1212
import { Log } from "@/util/log"
13-
import { AppRuntime } from "@/effect/app-runtime"
13+
import { BootstrapRuntime } from "@/effect/bootstrap-runtime"
1414
import { ShareNext } from "@/share/share-next"
1515

1616
export async function InstanceBootstrap() {
1717
Log.Default.info("bootstrapping", { directory: Instance.directory })
1818
await Plugin.init()
19-
void AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.init()))
20-
void AppRuntime.runPromise(Format.Service.use((svc) => svc.init()))
19+
void BootstrapRuntime.runPromise(ShareNext.Service.use((svc) => svc.init()))
20+
void BootstrapRuntime.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const InstanceRoutes = (upgrade: UpgradeWebSocket, app: Hono = new Hono()
191191
},
192192
}),
193193
async (c) => {
194-
const commands = await Command.list()
194+
const commands = await AppRuntime.runPromise(Command.Service.use((svc) => svc.list()))
195195
return c.json(commands)
196196
},
197197
)

0 commit comments

Comments
 (0)