diff options
| author | Brendan Allan <[email protected]> | 2026-04-16 06:44:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-15 22:44:55 +0000 |
| commit | 916131be19893b84f17902825a163a0b67274249 (patch) | |
| tree | e7b28eac0b00d92740b29d6edd6c7931bd1b18dd | |
| parent | d2ea6700aa2e6bdf5d04fe70ba893afbb320adbd (diff) | |
| download | opencode-916131be19893b84f17902825a163a0b67274249.tar.gz opencode-916131be19893b84f17902825a163a0b67274249.zip | |
core: move plugin intialisation to config layer override (#22620)
| -rw-r--r-- | packages/opencode/src/effect/app-runtime.ts | 20 | ||||
| -rw-r--r-- | packages/opencode/src/project/bootstrap.ts | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/packages/opencode/src/effect/app-runtime.ts b/packages/opencode/src/effect/app-runtime.ts index 257922daf..668c89b60 100644 --- a/packages/opencode/src/effect/app-runtime.ts +++ b/packages/opencode/src/effect/app-runtime.ts @@ -47,13 +47,31 @@ import { Pty } from "@/pty" import { Installation } from "@/installation" import { ShareNext } from "@/share/share-next" import { SessionShare } from "@/share/session" +import * as Effect from "effect/Effect" + +// Adjusts the default Config layer to ensure that plugins are always initialised before +// any other layers read the current config +const ConfigWithPluginPriority = Layer.effect( + Config.Service, + Effect.gen(function* () { + const config = yield* Config.Service + const plugin = yield* Plugin.Service + + return { + ...config, + get: () => Effect.andThen(plugin.init(), config.get), + getGlobal: () => Effect.andThen(plugin.init(), config.getGlobal), + getConsoleState: () => Effect.andThen(plugin.init(), config.getConsoleState), + } + }), +).pipe(Layer.provide(Layer.merge(Plugin.defaultLayer, Config.defaultLayer))) export const AppLayer = Layer.mergeAll( AppFileSystem.defaultLayer, Bus.defaultLayer, Auth.defaultLayer, Account.defaultLayer, - Config.defaultLayer, + ConfigWithPluginPriority, Git.defaultLayer, Ripgrep.defaultLayer, FileTime.defaultLayer, diff --git a/packages/opencode/src/project/bootstrap.ts b/packages/opencode/src/project/bootstrap.ts index a1f2a8cb0..0babdfe13 100644 --- a/packages/opencode/src/project/bootstrap.ts +++ b/packages/opencode/src/project/bootstrap.ts @@ -15,7 +15,6 @@ import * as Effect from "effect/Effect" export const InstanceBootstrap = Effect.gen(function* () { Log.Default.info("bootstrapping", { directory: Instance.directory }) - yield* Plugin.Service.use((svc) => svc.init()) yield* Effect.all( [ LSP.Service, |
