fix(plugins): preserve bundled origin when workspace matches bundled root

This commit is contained in:
Vincent Koc
2026-04-04 12:38:33 +09:00
parent 0ad75cffe3
commit b7ec90258b

View File

@@ -319,6 +319,18 @@ function shouldIgnoreScannedDirectory(dirName: string): boolean {
return false;
}
function resolvesToSameDirectory(left?: string, right?: string): boolean {
if (!left || !right) {
return false;
}
const leftRealPath = safeRealpathSync(left);
const rightRealPath = safeRealpathSync(right);
if (leftRealPath && rightRealPath) {
return leftRealPath === rightRealPath;
}
return path.resolve(left) === path.resolve(right);
}
function readPackageManifest(dir: string, rejectHardlinks = true): PackageManifest | null {
const manifestPath = path.join(dir, "package.json");
const opened = openBoundaryFileSync({
@@ -910,7 +922,9 @@ export function discoverOpenClawPlugins(params: {
seen,
});
}
if (roots.workspace && workspaceRoot) {
const workspaceMatchesBundledRoot = resolvesToSameDirectory(workspaceRoot, roots.stock);
if (roots.workspace && workspaceRoot && !workspaceMatchesBundledRoot) {
discoverInDirectory({
dir: workspaceRoot,
origin: "workspace",