diff --git a/src/plugins/discovery.ts b/src/plugins/discovery.ts index 145f1ed2cb1..11e6cf688ea 100644 --- a/src/plugins/discovery.ts +++ b/src/plugins/discovery.ts @@ -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",