50df6f0d3e
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
24 lines
728 B
TypeScript
24 lines
728 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) 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
|
|
}
|