diff --git a/packages/opencode/src/cli/bootstrap.ts b/packages/opencode/src/cli/bootstrap.ts index 009665022..9e9448b4c 100644 --- a/packages/opencode/src/cli/bootstrap.ts +++ b/packages/opencode/src/cli/bootstrap.ts @@ -8,9 +8,9 @@ import { Snapshot } from "../snapshot" export async function bootstrap(input: App.Input, cb: (app: App.Info) => Promise) { return App.provide(input, async (app) => { + await Plugin.init() Share.init() Format.init() - Plugin.init() ConfigHooks.init() LSP.init() Snapshot.init() diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index e9ca3bf61..c862e3327 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -68,7 +68,12 @@ export namespace Plugin { return state().then((x) => x.hooks) } - export function init() { + export async function init() { + const hooks = await state().then((x) => x.hooks) + const config = await Config.get() + for (const hook of hooks) { + hook.config?.(config) + } Bus.subscribeAll(async (input) => { const hooks = await state().then((x) => x.hooks) for (const hook of hooks) { diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index a214af110..5483607a6 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -8,6 +8,7 @@ import type { UserMessage, Part, Auth, + Config, } from "@opencode-ai/sdk" import type { BunShell } from "./shell" @@ -20,6 +21,7 @@ export type Plugin = (input: PluginInput) => Promise export interface Hooks { event?: (input: { event: Event }) => Promise + config?: (input: Config) => Promise auth?: { provider: string loader?: (auth: () => Promise, provider: Provider) => Promise>