style: trim facade fallback comment noise

This commit is contained in:
Ayaan Zaidi
2026-04-06 08:07:38 +05:30
parent 072e0795f8
commit 332e7d9d7b
2 changed files with 0 additions and 35 deletions

View File

@@ -267,15 +267,9 @@ describe("plugin-sdk facade runtime", () => {
});
it("resolves a globally-installed plugin whose rootDir basename matches the dirName", () => {
// Simulate a global-only installation: the bundled plugins directory does
// NOT contain the target plugin, but a global extensions directory does.
// The facade module location resolver should fall through to the registry-
// based lookup and find the module inside the global rootDir.
const emptyBundled = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-facade-empty-bundled-"));
tempDirs.push(emptyBundled);
// Create a state dir whose "extensions" sub-directory acts as the global
// plugin root (resolveConfigDir(env) + "/extensions").
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-facade-state-"));
tempDirs.push(stateDir);
const lineDir = path.join(stateDir, "extensions", "line");
@@ -285,8 +279,6 @@ describe("plugin-sdk facade runtime", () => {
'export const marker = "global-line";\n',
"utf8",
);
// Discovery reads package.json (not openclaw.plugin.json) and looks for
// the "openclaw" key to resolve extension entries.
fs.writeFileSync(
path.join(lineDir, "package.json"),
JSON.stringify({
@@ -299,8 +291,6 @@ describe("plugin-sdk facade runtime", () => {
}),
"utf8",
);
// The plugin manifest (openclaw.plugin.json) is loaded separately by the
// registry builder to populate id, channels, etc.
fs.writeFileSync(
path.join(lineDir, "openclaw.plugin.json"),
JSON.stringify({
@@ -326,8 +316,6 @@ describe("plugin-sdk facade runtime", () => {
},
});
// The plugin should be resolvable via the registry fallback even though
// the bundled plugins directory is empty.
expect(
canLoadActivatedBundledPluginPublicSurface({
dirName: "line",
@@ -337,16 +325,11 @@ describe("plugin-sdk facade runtime", () => {
});
it("resolves a globally-installed plugin with an encoded scoped rootDir basename", () => {
// When a scoped package like @openclaw/line is installed globally, its
// directory name is encoded (e.g. "@openclaw+line"). The rootDir basename
// no longer matches the facade dirName "line", so the resolver must fall
// back to matching by plugin.id or plugin.channels.
const emptyBundled = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-facade-empty-bundled-"));
tempDirs.push(emptyBundled);
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-facade-state-"));
tempDirs.push(stateDir);
// Use the encoded scoped package directory name.
const encodedDir = path.join(stateDir, "extensions", "@openclaw+line");
fs.mkdirSync(encodedDir, { recursive: true });
fs.writeFileSync(
@@ -391,8 +374,6 @@ describe("plugin-sdk facade runtime", () => {
},
});
// The plugin.id fallback must resolve the plugin even though
// path.basename(rootDir) is "@openclaw+line", not "line".
expect(
canLoadActivatedBundledPluginPublicSurface({
dirName: "line",

View File

@@ -75,11 +75,6 @@ function resolveRegistryPluginModuleLocation(params: {
}): { modulePath: string; boundaryRoot: string } | null {
const { config } = getFacadeBoundaryResolvedConfig();
const registry = loadPluginManifestRegistry({ config, cache: true }).plugins;
// Use tiered matching so exact basename/id matches are always preferred over
// loose channel matches. A plugin that merely declares `channels: ["line"]`
// must never shadow the actual LINE plugin whose id is `"line"`. Within each
// tier we iterate all matching records so that a stale first match (e.g. a
// bundled root that lost its artifact) does not shadow a later valid record.
const tiers: Array<(plugin: (typeof registry)[number]) => boolean> = [
(plugin) => plugin.id === params.dirName,
(plugin) => path.basename(plugin.rootDir) === params.dirName,
@@ -90,7 +85,6 @@ function resolveRegistryPluginModuleLocation(params: {
for (const matchFn of tiers) {
for (const record of registry.filter(matchFn)) {
const rootDir = path.resolve(record.rootDir);
// Check for the built artifact first, then probe source extensions.
const builtCandidate = path.join(rootDir, artifactBasename);
if (fs.existsSync(builtCandidate)) {
return { modulePath: builtCandidate, boundaryRoot: rootDir };
@@ -134,8 +128,6 @@ function resolveFacadeModuleLocation(params: {
: OPENCLAW_PACKAGE_ROOT,
};
}
// Bundled directory did not contain the module; fall through to the
// registry-based lookup so globally-installed plugins are reachable.
return resolveRegistryPluginModuleLocation(params);
}
const modulePath = resolveBundledPluginPublicSurfacePath({
@@ -153,8 +145,6 @@ function resolveFacadeModuleLocation(params: {
: OPENCLAW_PACKAGE_ROOT,
};
}
// Bundled directory did not contain the module; fall through to the
// registry-based lookup so globally-installed plugins are reachable.
return resolveRegistryPluginModuleLocation(params);
}
@@ -245,12 +235,6 @@ function resolveBundledPluginManifestRecord(params: {
}
}
// Fallback: match by plugin id first (most semantically precise), then by
// rootDir basename, then by declared channel id (loosest). Globally-installed
// plugins may have a rootDir whose basename differs from the facade dirName
// (e.g. encoded scoped package names), and duplicate-resolution may have
// replaced the bundled record with a global one whose rootDir no longer sits
// under the bundled plugins directory.
return (
registry.find((plugin) => plugin.id === params.dirName) ??
registry.find((plugin) => path.basename(plugin.rootDir) === params.dirName) ??