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,23 @@
|
||||
const CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}"
|
||||
|
||||
export function resolvePluginPath(path: string, pluginRoot: string): string {
|
||||
return path.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot)
|
||||
}
|
||||
|
||||
export function resolvePluginPaths<T>(obj: T, pluginRoot: string): T {
|
||||
if (obj === null || obj === undefined) return obj
|
||||
if (typeof obj === "string") {
|
||||
return resolvePluginPath(obj, pluginRoot) as T
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item) => resolvePluginPaths(item, pluginRoot)) as T
|
||||
}
|
||||
if (typeof obj === "object") {
|
||||
const result: Record<string, unknown> = {}
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = resolvePluginPaths(value, pluginRoot)
|
||||
}
|
||||
return result as T
|
||||
}
|
||||
return obj
|
||||
}
|
||||
Reference in New Issue
Block a user