Main entry point: - create-hooks.ts, create-tools.ts, create-managers.ts - plugin-interface.ts: plugin interface types - plugin/ directory: plugin lifecycle modules Config handler: - agent-config-handler.ts, command-config-handler.ts - tool-config-handler.ts, mcp-config-handler.ts - provider-config-handler.ts, category-config-resolver.ts - agent-priority-order.ts, prometheus-agent-config-builder.ts - plugin-components-loader.ts
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import type { AvailableSkill } from "../../agents/dynamic-agent-prompt-builder"
|
|
import type { HookName } from "../../config"
|
|
import type { LoadedSkill } from "../../features/opencode-skill-loader/types"
|
|
import type { PluginContext } from "../types"
|
|
|
|
import { createAutoSlashCommandHook, createCategorySkillReminderHook } from "../../hooks"
|
|
import { safeCreateHook } from "../../shared/safe-create-hook"
|
|
|
|
export type SkillHooks = {
|
|
categorySkillReminder: ReturnType<typeof createCategorySkillReminderHook> | null
|
|
autoSlashCommand: ReturnType<typeof createAutoSlashCommandHook> | null
|
|
}
|
|
|
|
export function createSkillHooks(args: {
|
|
ctx: PluginContext
|
|
isHookEnabled: (hookName: HookName) => boolean
|
|
safeHookEnabled: boolean
|
|
mergedSkills: LoadedSkill[]
|
|
availableSkills: AvailableSkill[]
|
|
}): SkillHooks {
|
|
const { ctx, isHookEnabled, safeHookEnabled, mergedSkills, availableSkills } = args
|
|
|
|
const safeHook = <T>(hookName: HookName, factory: () => T): T | null =>
|
|
safeCreateHook(hookName, factory, { enabled: safeHookEnabled })
|
|
|
|
const categorySkillReminder = isHookEnabled("category-skill-reminder")
|
|
? safeHook("category-skill-reminder", () =>
|
|
createCategorySkillReminderHook(ctx, availableSkills))
|
|
: null
|
|
|
|
const autoSlashCommand = isHookEnabled("auto-slash-command")
|
|
? safeHook("auto-slash-command", () =>
|
|
createAutoSlashCommandHook({ skills: mergedSkills }))
|
|
: null
|
|
|
|
return { categorySkillReminder, autoSlashCommand }
|
|
}
|