fix: normalize manifest plugin ids during install

This commit is contained in:
Peter Steinberger
2026-02-24 03:56:27 +00:00
parent a388fbb6c3
commit d76742ff88
2 changed files with 40 additions and 1 deletions

View File

@@ -557,6 +557,43 @@ describe("installPluginFromDir", () => {
),
).toBe(true);
});
it("normalizes scoped manifest ids to unscoped install keys", async () => {
const { pluginDir, extensionsDir } = setupPluginInstallDirs();
fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });
fs.writeFileSync(
path.join(pluginDir, "package.json"),
JSON.stringify({
name: "@openclaw/cognee-openclaw",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.js"] },
}),
"utf-8",
);
fs.writeFileSync(path.join(pluginDir, "dist", "index.js"), "export {};", "utf-8");
fs.writeFileSync(
path.join(pluginDir, "openclaw.plugin.json"),
JSON.stringify({
id: "@team/memory-cognee",
configSchema: { type: "object", properties: {} },
}),
"utf-8",
);
const res = await installPluginFromDir({
dirPath: pluginDir,
extensionsDir,
expectedPluginId: "memory-cognee",
logger: { info: () => {}, warn: () => {} },
});
expect(res.ok).toBe(true);
if (!res.ok) {
return;
}
expect(res.pluginId).toBe("memory-cognee");
expect(res.targetDir).toBe(path.join(extensionsDir, "memory-cognee"));
});
});
describe("installPluginFromNpmSpec", () => {

View File

@@ -158,7 +158,9 @@ async function installPluginFromPackageDir(params: {
// uses the manifest id as the authoritative key, so the config entry must match it.
const ocManifestResult = loadPluginManifest(params.packageDir);
const manifestPluginId =
ocManifestResult.ok && ocManifestResult.manifest.id ? ocManifestResult.manifest.id : undefined;
ocManifestResult.ok && ocManifestResult.manifest.id
? unscopedPackageName(ocManifestResult.manifest.id)
: undefined;
const pluginId = manifestPluginId ?? npmPluginId;
const pluginIdError = validatePluginId(pluginId);