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
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user