|
|
@@ -1,6 +1,8 @@
|
|
|
import { Layer, ManagedRuntime } from "effect"
|
|
|
+import * as Effect from "effect/Effect"
|
|
|
import { attach } from "./run-service"
|
|
|
import * as Observability from "./observability"
|
|
|
+import { memoMap } from "./memo-map"
|
|
|
|
|
|
import { AppFileSystem } from "@opencode-ai/shared/filesystem"
|
|
|
import { Bus } from "@/bus"
|
|
|
@@ -47,7 +49,23 @@ import { Installation } from "@/installation"
|
|
|
import { ShareNext } from "@/share"
|
|
|
import { SessionShare } from "@/share"
|
|
|
import { Npm } from "@/npm"
|
|
|
-import { memoMap } from "./memo-map"
|
|
|
+
|
|
|
+// 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(
|
|
|
Npm.defaultLayer,
|
|
|
@@ -55,7 +73,7 @@ export const AppLayer = Layer.mergeAll(
|
|
|
Bus.defaultLayer,
|
|
|
Auth.defaultLayer,
|
|
|
Account.defaultLayer,
|
|
|
- Config.defaultLayer,
|
|
|
+ ConfigWithPluginPriority,
|
|
|
Git.defaultLayer,
|
|
|
Ripgrep.defaultLayer,
|
|
|
File.defaultLayer,
|