@@ -45,17 +45,35 @@ import { Vcs } from "@/project"
4545import { Worktree } from "@/worktree"
4646import { Pty } from "@/pty"
4747import { Installation } from "@/installation"
48- import { ShareNext } from "@/share"
49- import { SessionShare } from "@/share"
48+ import * as ShareNext from "@/share/share-next"
49+ import * as SessionShare from "@/share/session"
50+ import * as Effect from "effect/Effect"
5051import { Npm } from "@opencode-ai/shared/npm"
5152
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+
5270export const AppLayer = Layer . mergeAll (
5371 Npm . defaultLayer ,
5472 AppFileSystem . defaultLayer ,
5573 Bus . defaultLayer ,
5674 Auth . defaultLayer ,
5775 Account . defaultLayer ,
58- Config . defaultLayer ,
76+ ConfigWithPluginPriority ,
5977 Git . defaultLayer ,
6078 Ripgrep . defaultLayer ,
6179 FileTime . defaultLayer ,
0 commit comments