File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,31 @@ import { Installation } from "@/installation"
4747import { ShareNext } from "@/share"
4848import { SessionShare } from "@/share"
4949import { Npm } from "@opencode-ai/shared/npm"
50+ import * as Effect from "effect/Effect"
51+
52+ // Adjusts the default Config layer to ensure that plugins are always initialised before
53+ // any other layers read the current config
54+ const PluginPriorityConfigLayer = Layer . unwrap (
55+ Effect . gen ( function * ( ) {
56+ const configSvc = yield * Config . Service
57+ const pluginSvc = yield * Plugin . Service
58+
59+ return Layer . succeed ( Config . Service , {
60+ ...configSvc ,
61+ get : ( ) => Effect . andThen ( pluginSvc . init ( ) , configSvc . get ) ,
62+ getGlobal : ( ) => Effect . andThen ( pluginSvc . init ( ) , configSvc . getGlobal ) ,
63+ getConsoleState : ( ) => Effect . andThen ( pluginSvc . init ( ) , configSvc . getConsoleState ) ,
64+ } )
65+ } ) ,
66+ ) . pipe ( Layer . provideMerge ( Layer . merge ( Plugin . defaultLayer , Config . defaultLayer ) ) )
5067
5168export const AppLayer = Layer . mergeAll (
5269 Npm . defaultLayer ,
5370 AppFileSystem . defaultLayer ,
5471 Bus . defaultLayer ,
5572 Auth . defaultLayer ,
5673 Account . defaultLayer ,
57- Config . defaultLayer ,
74+ PluginPriorityConfigLayer ,
5875 Git . defaultLayer ,
5976 Ripgrep . defaultLayer ,
6077 File . defaultLayer ,
Original file line number Diff line number Diff line change 1- import { Plugin } from "../plugin"
21import { Format } from "../format"
32import { LSP } from "../lsp"
43import { File } from "../file"
@@ -12,14 +11,9 @@ import { Log } from "@/util"
1211import { FileWatcher } from "@/file/watcher"
1312import { ShareNext } from "@/share"
1413import * as Effect from "effect/Effect"
15- import { Config } from "@/config"
1614
1715export const InstanceBootstrap = Effect . gen ( function * ( ) {
1816 Log . Default . info ( "bootstrapping" , { directory : Instance . directory } )
19- // everything depends on config so eager load it for nice traces
20- yield * Config . Service . use ( ( svc ) => svc . get ( ) )
21- // Plugin can mutate config so it has to be initialized before anything else.
22- yield * Plugin . Service . use ( ( svc ) => svc . init ( ) )
2317 yield * Effect . all (
2418 [
2519 LSP . Service ,
You can’t perform that action at this time.
0 commit comments