39dc62c62a
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
24 lines
750 B
TypeScript
24 lines
750 B
TypeScript
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
|
|
}
|