fix: normalize BOM-prefixed plugin manifests (#3342)

This commit is contained in:
Patrick Erichsen
2026-07-30 23:13:21 -07:00
committed by GitHub
parent 43a56d4f76
commit 73eb44cd70
2 changed files with 9 additions and 1 deletions
@@ -160,13 +160,17 @@ describe("package-inspector-nightly-scan", () => {
expect(config.plugin.id).toBe(expectedId);
});
it("accepts a UTF-8 BOM before a downloaded package.json", async () => {
it("accepts a UTF-8 BOM before downloaded plugin manifests", async () => {
const pluginRoot = await mkdtemp(path.join(tmpdir(), "clawhub-inspector-package-json-"));
temporaryRoots.push(pluginRoot);
await writeFile(
path.join(pluginRoot, "package.json"),
'\uFEFF{"name":"eu-compliance-skill","version":"1.0.1"}\n',
);
await writeFile(
path.join(pluginRoot, "openclaw.plugin.json"),
'\uFEFF{"id":"eu-compliance-skill"}\n',
);
await expect(
prepareExtractedPluginRoot(pluginRoot, "npm-pack", "eu-compliance-skill"),
@@ -178,6 +182,9 @@ describe("package-inspector-nightly-scan", () => {
expect(await readFile(path.join(pluginRoot, "package.json"), "utf8")).toBe(
'{"name":"eu-compliance-skill","version":"1.0.1"}\n',
);
expect(await readFile(path.join(pluginRoot, "openclaw.plugin.json"), "utf8")).toBe(
'{"id":"eu-compliance-skill"}\n',
);
});
it.each([
@@ -376,6 +376,7 @@ export async function prepareExtractedPluginRoot(
if (artifactKind === "legacy-zip") {
await removePosixArchiveMetadata(scanRoot);
}
await readJsonIfExists(path.join(scanRoot, "openclaw.plugin.json"));
await writeSyntheticConfigIfNeeded(scanRoot, packageName);
return scanRoot;
}