@@ -48,19 +48,37 @@ import { Worktree } from "@/worktree"
4848import { Pty } from "@/pty"
4949import { PtyTicket } from "@/pty/ticket"
5050import { Installation } from "@/installation"
51+ import * as Effect from "effect/Effect"
5152import { ShareNext } from "@/share/share-next"
5253import { SessionShare } from "@/share/session"
5354import { SyncEvent } from "@/sync"
5455import { Npm } from "@opencode-ai/core/npm"
5556import { memoMap } from "@opencode-ai/core/effect/memo-map"
5657
58+ // Adjusts the default Config layer to ensure that plugins are always initialised before
59+ // any other layers read the current config
60+ const ConfigWithPluginPriority = Layer . effect (
61+ Config . Service ,
62+ Effect . gen ( function * ( ) {
63+ const config = yield * Config . Service
64+ const plugin = yield * Plugin . Service
65+
66+ return {
67+ ...config ,
68+ get : ( ) => Effect . andThen ( plugin . init ( ) , config . get ) ,
69+ getGlobal : ( ) => Effect . andThen ( plugin . init ( ) , config . getGlobal ) ,
70+ getConsoleState : ( ) => Effect . andThen ( plugin . init ( ) , config . getConsoleState ) ,
71+ }
72+ } ) ,
73+ ) . pipe ( Layer . provide ( Layer . merge ( Plugin . defaultLayer , Config . defaultLayer ) ) )
74+
5775export const AppLayer = Layer . mergeAll (
5876 Npm . defaultLayer ,
5977 AppFileSystem . defaultLayer ,
6078 Bus . defaultLayer ,
6179 Auth . defaultLayer ,
6280 Account . defaultLayer ,
63- Config . defaultLayer ,
81+ ConfigWithPluginPriority ,
6482 Git . defaultLayer ,
6583 Ripgrep . defaultLayer ,
6684 File . defaultLayer ,
0 commit comments