/** * Recursively substitute ${CLAUDE_PLUGIN_ROOT} and ${OMP_PLUGIN_ROOT} * with the actual plugin root path in strings, arrays, and plain objects. */ // Use concatenation to avoid noTemplateCurlyInString lint rule on literal placeholder names const CLAUDE_VAR = "$" + "{CLAUDE_PLUGIN_ROOT}"; const OMP_VAR = "$" + "{OMP_PLUGIN_ROOT}"; export function substitutePluginRoot(value: T, rootPath: string): T { if (typeof value === "string") { return value.replaceAll(CLAUDE_VAR, rootPath).replaceAll(OMP_VAR, rootPath) as T; } if (Array.isArray(value)) { return value.map(v => substitutePluginRoot(v, rootPath)) as T; } if (value && typeof value === "object") { const result: Record = Object.create(null); for (const [k, v] of Object.entries(value as Record)) { Object.defineProperty(result, k, { value: substitutePluginRoot(v, rootPath), enumerable: true, writable: true, configurable: true, }); } return result as T; } return value; }