fix: normalize nested plugin manifests (#3343)

This commit is contained in:
Patrick Erichsen
2026-07-30 23:28:55 -07:00
committed by GitHub
parent 73eb44cd70
commit 110f92a0ef
2 changed files with 27 additions and 1 deletions
@@ -171,6 +171,12 @@ describe("package-inspector-nightly-scan", () => {
path.join(pluginRoot, "openclaw.plugin.json"),
'\uFEFF{"id":"eu-compliance-skill"}\n',
);
const nestedPackageRoot = path.join(pluginRoot, "showmethemoney-skill", "demo-backend");
await mkdir(nestedPackageRoot, { recursive: true });
await writeFile(
path.join(nestedPackageRoot, "package.json"),
'\uFEFF{"name":"stablepay-demo-backend"}\n',
);
await expect(
prepareExtractedPluginRoot(pluginRoot, "npm-pack", "eu-compliance-skill"),
@@ -185,6 +191,9 @@ describe("package-inspector-nightly-scan", () => {
expect(await readFile(path.join(pluginRoot, "openclaw.plugin.json"), "utf8")).toBe(
'{"id":"eu-compliance-skill"}\n',
);
expect(await readFile(path.join(nestedPackageRoot, "package.json"), "utf8")).toBe(
'{"name":"stablepay-demo-backend"}\n',
);
});
it.each([
+18 -1
View File
@@ -376,7 +376,7 @@ export async function prepareExtractedPluginRoot(
if (artifactKind === "legacy-zip") {
await removePosixArchiveMetadata(scanRoot);
}
await readJsonIfExists(path.join(scanRoot, "openclaw.plugin.json"));
await normalizePluginJsonManifests(scanRoot);
await writeSyntheticConfigIfNeeded(scanRoot, packageName);
return scanRoot;
}
@@ -493,6 +493,23 @@ async function writeSyntheticConfigIfNeeded(root: string, packageName: string) {
);
}
async function normalizePluginJsonManifests(root: string): Promise<void> {
const entries = await readdir(root, { withFileTypes: true });
for (const entry of entries) {
const entryPath = path.join(root, entry.name);
if (entry.isDirectory()) {
await normalizePluginJsonManifests(entryPath);
continue;
}
if (
entry.isFile() &&
(entry.name === "package.json" || entry.name === "openclaw.plugin.json")
) {
await readJsonIfExists(entryPath);
}
}
}
async function readJsonIfExists(filePath: string) {
if (!existsSync(filePath)) return null;
const contents = await readFile(filePath, "utf8");