Files
oh-my-opencode/src/features/claude-code-plugin-loader/hook-loader.ts
T
YeonGyu-Kim 94b2d94b2c refactor(claude-code-plugin-loader): split loader.ts into per-type loaders
Extract plugin component loading into dedicated modules:
- discovery.ts: plugin directory detection
- plugin-path-resolver.ts: path resolution logic
- agent-loader.ts, command-loader.ts, hook-loader.ts
- mcp-server-loader.ts, skill-loader.ts
2026-02-08 16:21:37 +09:00

27 lines
861 B
TypeScript

import { existsSync, readFileSync } from "fs"
import { log } from "../../shared/logger"
import type { HooksConfig, LoadedPlugin } from "./types"
import { resolvePluginPaths } from "./plugin-path-resolver"
export function loadPluginHooksConfigs(plugins: LoadedPlugin[]): HooksConfig[] {
const configs: HooksConfig[] = []
for (const plugin of plugins) {
if (!plugin.hooksPath || !existsSync(plugin.hooksPath)) continue
try {
const content = readFileSync(plugin.hooksPath, "utf-8")
let config = JSON.parse(content) as HooksConfig
config = resolvePluginPaths(config, plugin.installPath)
configs.push(config)
log(`Loaded plugin hooks config from ${plugin.name}`, { path: plugin.hooksPath })
} catch (error) {
log(`Failed to load plugin hooks config: ${plugin.hooksPath}`, error)
}
}
return configs
}