mirror of
https://github.com/sst/opencode.git
synced 2025-08-23 14:34:08 +00:00
add plugin hook for config
This commit is contained in:
parent
a9dcbedf99
commit
4518f96e3d
3 changed files with 9 additions and 2 deletions
|
@ -8,9 +8,9 @@ import { Snapshot } from "../snapshot"
|
||||||
|
|
||||||
export async function bootstrap<T>(input: App.Input, cb: (app: App.Info) => Promise<T>) {
|
export async function bootstrap<T>(input: App.Input, cb: (app: App.Info) => Promise<T>) {
|
||||||
return App.provide(input, async (app) => {
|
return App.provide(input, async (app) => {
|
||||||
|
await Plugin.init()
|
||||||
Share.init()
|
Share.init()
|
||||||
Format.init()
|
Format.init()
|
||||||
Plugin.init()
|
|
||||||
ConfigHooks.init()
|
ConfigHooks.init()
|
||||||
LSP.init()
|
LSP.init()
|
||||||
Snapshot.init()
|
Snapshot.init()
|
||||||
|
|
|
@ -68,7 +68,12 @@ export namespace Plugin {
|
||||||
return state().then((x) => x.hooks)
|
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) => {
|
Bus.subscribeAll(async (input) => {
|
||||||
const hooks = await state().then((x) => x.hooks)
|
const hooks = await state().then((x) => x.hooks)
|
||||||
for (const hook of hooks) {
|
for (const hook of hooks) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import type {
|
||||||
UserMessage,
|
UserMessage,
|
||||||
Part,
|
Part,
|
||||||
Auth,
|
Auth,
|
||||||
|
Config,
|
||||||
} from "@opencode-ai/sdk"
|
} from "@opencode-ai/sdk"
|
||||||
import type { BunShell } from "./shell"
|
import type { BunShell } from "./shell"
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ export type Plugin = (input: PluginInput) => Promise<Hooks>
|
||||||
|
|
||||||
export interface Hooks {
|
export interface Hooks {
|
||||||
event?: (input: { event: Event }) => Promise<void>
|
event?: (input: { event: Event }) => Promise<void>
|
||||||
|
config?: (input: Config) => Promise<void>
|
||||||
auth?: {
|
auth?: {
|
||||||
provider: string
|
provider: string
|
||||||
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>
|
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue