diff options
| author | Dax Raad <[email protected]> | 2025-08-21 11:22:13 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-08-21 11:22:24 -0400 |
| commit | 4518f96e3dee9cd70209c40fba7444722a9c7020 (patch) | |
| tree | 2c52a1824553aa0241084991f1233df3a694e357 | |
| parent | a9dcbedf99c5f8fd5d170e7f2e699f82c9f27ff1 (diff) | |
| download | opencode-4518f96e3dee9cd70209c40fba7444722a9c7020.tar.gz opencode-4518f96e3dee9cd70209c40fba7444722a9c7020.zip | |
add plugin hook for config
| -rw-r--r-- | packages/opencode/src/cli/bootstrap.ts | 2 | ||||
| -rw-r--r-- | packages/opencode/src/plugin/index.ts | 7 | ||||
| -rw-r--r-- | packages/plugin/src/index.ts | 2 |
3 files changed, 9 insertions, 2 deletions
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<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.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<Hooks> export interface Hooks { event?: (input: { event: Event }) => Promise<void> + config?: (input: Config) => Promise<void> auth?: { provider: string loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>> |
