The open source coding agent.
TypeScript
add plugin hook for config
Dax Raad4518f96e3dee
diff --git a/packages/opencode/src/cli/bootstrap.ts b/packages/opencode/src/cli/bootstrap.tsindex 00966502243..9e9448b4c3d 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<T>(input: App.Input, cb: (app: App.Info) => Promise<T>) {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.tsindex e9ca3bf6130..c862e3327e5 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.tsindex a214af1102d..5483607a65f 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<Hooks>export interface Hooks {event?: (input: { event: Event }) => Promise<void>+ config?: (input: Config) => Promise<void>auth?: {provider: stringloader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>