|
1 | 1 | import { Layer, ManagedRuntime } from "effect" |
| 2 | +import * as Effect from "effect/Effect" |
2 | 3 | import { attach } from "./run-service" |
3 | 4 | import * as Observability from "@opencode-ai/core/effect/observability" |
4 | 5 |
|
@@ -49,13 +50,30 @@ import { SessionShare } from "@/share/session" |
49 | 50 | import { Npm } from "@opencode-ai/core/npm" |
50 | 51 | import { memoMap } from "@opencode-ai/core/effect/memo-map" |
51 | 52 |
|
| 53 | +// Adjusts the default Config layer to ensure that plugins are always initialised before |
| 54 | +// any other layers read the current config |
| 55 | +const ConfigWithPluginPriority = Layer.effect( |
| 56 | + Config.Service, |
| 57 | + Effect.gen(function* () { |
| 58 | + const config = yield* Config.Service |
| 59 | + const plugin = yield* Plugin.Service |
| 60 | + |
| 61 | + return { |
| 62 | + ...config, |
| 63 | + get: () => Effect.andThen(plugin.init(), config.get), |
| 64 | + getGlobal: () => Effect.andThen(plugin.init(), config.getGlobal), |
| 65 | + getConsoleState: () => Effect.andThen(plugin.init(), config.getConsoleState), |
| 66 | + } |
| 67 | + }), |
| 68 | +).pipe(Layer.provide(Layer.merge(Plugin.defaultLayer, Config.defaultLayer))) |
| 69 | + |
52 | 70 | export const AppLayer = Layer.mergeAll( |
53 | 71 | Npm.defaultLayer, |
54 | 72 | AppFileSystem.defaultLayer, |
55 | 73 | Bus.defaultLayer, |
56 | 74 | Auth.defaultLayer, |
57 | 75 | Account.defaultLayer, |
58 | | - Config.defaultLayer, |
| 76 | + ConfigWithPluginPriority, |
59 | 77 | Git.defaultLayer, |
60 | 78 | Ripgrep.defaultLayer, |
61 | 79 | File.defaultLayer, |
|
0 commit comments