From b7ec90258bc0b2c8c93c3d989440f5914a9e4dae Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 4 Apr 2026 12:38:33 +0900 Subject: [PATCH] fix(plugins): preserve bundled origin when workspace matches bundled root --- src/plugins/discovery.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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",