Skip to content

Commit 916131b

Browse files
authored
core: move plugin intialisation to config layer override (#22620)
1 parent d2ea670 commit 916131b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

packages/opencode/src/effect/app-runtime.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,31 @@ import { Pty } from "@/pty"
4747
import { Installation } from "@/installation"
4848
import { ShareNext } from "@/share/share-next"
4949
import { SessionShare } from "@/share/session"
50+
import * as Effect from "effect/Effect"
51+
52+
// Adjusts the default Config layer to ensure that plugins are always initialised before
53+
// any other layers read the current config
54+
const ConfigWithPluginPriority = Layer.effect(
55+
Config.Service,
56+
Effect.gen(function* () {
57+
const config = yield* Config.Service
58+
const plugin = yield* Plugin.Service
59+
60+
return {
61+
...config,
62+
get: () => Effect.andThen(plugin.init(), config.get),
63+
getGlobal: () => Effect.andThen(plugin.init(), config.getGlobal),
64+
getConsoleState: () => Effect.andThen(plugin.init(), config.getConsoleState),
65+
}
66+
}),
67+
).pipe(Layer.provide(Layer.merge(Plugin.defaultLayer, Config.defaultLayer)))
5068

5169
export const AppLayer = Layer.mergeAll(
5270
AppFileSystem.defaultLayer,
5371
Bus.defaultLayer,
5472
Auth.defaultLayer,
5573
Account.defaultLayer,
56-
Config.defaultLayer,
74+
ConfigWithPluginPriority,
5775
Git.defaultLayer,
5876
Ripgrep.defaultLayer,
5977
FileTime.defaultLayer,

packages/opencode/src/project/bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import * as Effect from "effect/Effect"
1515

1616
export const InstanceBootstrap = Effect.gen(function* () {
1717
Log.Default.info("bootstrapping", { directory: Instance.directory })
18-
yield* Plugin.Service.use((svc) => svc.init())
1918
yield* Effect.all(
2019
[
2120
LSP.Service,

0 commit comments

Comments
 (0)