mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-26 08:12:13 +00:00
core: move plugin intialisation to config layer override
This commit is contained in:
parent
c57c5315c1
commit
14eacb4019
2 changed files with 18 additions and 7 deletions
|
|
@ -47,6 +47,23 @@ import { Installation } from "@/installation"
|
|||
import { ShareNext } from "@/share"
|
||||
import { SessionShare } from "@/share"
|
||||
import { Npm } from "@opencode-ai/shared/npm"
|
||||
import * as Effect from "effect/Effect"
|
||||
|
||||
// Adjusts the default Config layer to ensure that plugins are always initialised before
|
||||
// any other layers read the current config
|
||||
const PluginPriorityConfigLayer = Layer.unwrap(
|
||||
Effect.gen(function* () {
|
||||
const configSvc = yield* Config.Service
|
||||
const pluginSvc = yield* Plugin.Service
|
||||
|
||||
return Layer.succeed(Config.Service, {
|
||||
...configSvc,
|
||||
get: () => Effect.andThen(pluginSvc.init(), configSvc.get),
|
||||
getGlobal: () => Effect.andThen(pluginSvc.init(), configSvc.getGlobal),
|
||||
getConsoleState: () => Effect.andThen(pluginSvc.init(), configSvc.getConsoleState),
|
||||
})
|
||||
}),
|
||||
).pipe(Layer.provideMerge(Layer.merge(Plugin.defaultLayer, Config.defaultLayer)))
|
||||
|
||||
export const AppLayer = Layer.mergeAll(
|
||||
Npm.defaultLayer,
|
||||
|
|
@ -54,7 +71,7 @@ export const AppLayer = Layer.mergeAll(
|
|||
Bus.defaultLayer,
|
||||
Auth.defaultLayer,
|
||||
Account.defaultLayer,
|
||||
Config.defaultLayer,
|
||||
PluginPriorityConfigLayer,
|
||||
Git.defaultLayer,
|
||||
Ripgrep.defaultLayer,
|
||||
File.defaultLayer,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { Plugin } from "../plugin"
|
||||
import { Format } from "../format"
|
||||
import { LSP } from "../lsp"
|
||||
import { File } from "../file"
|
||||
|
|
@ -12,14 +11,9 @@ import { Log } from "@/util"
|
|||
import { FileWatcher } from "@/file/watcher"
|
||||
import { ShareNext } from "@/share"
|
||||
import * as Effect from "effect/Effect"
|
||||
import { Config } from "@/config"
|
||||
|
||||
export const InstanceBootstrap = Effect.gen(function* () {
|
||||
Log.Default.info("bootstrapping", { directory: Instance.directory })
|
||||
// everything depends on config so eager load it for nice traces
|
||||
yield* Config.Service.use((svc) => svc.get())
|
||||
// Plugin can mutate config so it has to be initialized before anything else.
|
||||
yield* Plugin.Service.use((svc) => svc.init())
|
||||
yield* Effect.all(
|
||||
[
|
||||
LSP.Service,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue