Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .husky/pre-push
100755 → 100644
Empty file.
25 changes: 15 additions & 10 deletions packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export namespace Plugin {
return {
hooks,
input,
subscribed: false,
}
})

Expand All @@ -72,18 +73,22 @@ export namespace Plugin {
}

export async function init() {
const hooks = await state().then((x) => x.hooks)
const pluginState = await state()
const config = await Config.get()
for (const hook of hooks) {
for (const hook of pluginState.hooks) {
await hook.config?.(config)
}
Bus.subscribeAll(async (input) => {
const hooks = await state().then((x) => x.hooks)
for (const hook of hooks) {
hook["event"]?.({
event: input,
})
}
})
// Only subscribe once per plugin instance to prevent duplicate event firing
if (!pluginState.subscribed) {
pluginState.subscribed = true
Bus.subscribeAll(async (input) => {
const hooks = await state().then((x) => x.hooks)
for (const hook of hooks) {
hook["event"]?.({
event: input,
})
}
})
}
}
}