Skip to content

Commit c301575

Browse files
fix(update): skip npm package.json check for bundle-format plugins in smoke check
Bundle-format plugins (Claude-plugin layout: .claude-plugin/plugin.json + skills/) ship without package.json. The post-update smoke check treated the missing package.json as a failure, causing 'openclaw update' to exit 1 and leave the gateway unloaded. Detect bundle plugins via clawhubFamily=bundle-plugin or by the presence of .claude-plugin/plugin.json, and validate the bundle manifest instead of requiring npm-style package.json. Fixes #97985 Co-Authored-By: Claude <[email protected]>
1 parent 54b0958 commit c301575

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

‎src/cli/update-cli/plugin-payload-validation.test.ts‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,82 @@ describe("runPluginPayloadSmokeCheck", () => {
461461
]);
462462
});
463463

464+
it("accepts a bundle plugin (clawhubFamily=bundle-plugin) with valid .claude-plugin/plugin.json", async () => {
465+
const dir = path.join(tmpRoot, "feishu-bundle");
466+
await fs.mkdir(path.join(dir, ".claude-plugin"), { recursive: true });
467+
await fs.writeFile(
468+
path.join(dir, ".claude-plugin", "plugin.json"),
469+
JSON.stringify({ name: "feishu", version: "1.0.0" }),
470+
"utf8",
471+
);
472+
const result = await runPluginPayloadSmokeCheck({
473+
records: {
474+
feishu: { source: "clawhub", clawhubFamily: "bundle-plugin", installPath: dir },
475+
},
476+
env: {},
477+
});
478+
expect(result.failures).toEqual([]);
479+
expect(result.checked).toEqual(["feishu"]);
480+
});
481+
482+
it("accepts a bundle plugin detected by .claude-plugin/plugin.json presence", async () => {
483+
const dir = path.join(tmpRoot, "feishu-bundle");
484+
await fs.mkdir(path.join(dir, ".claude-plugin"), { recursive: true });
485+
await fs.writeFile(
486+
path.join(dir, ".claude-plugin", "plugin.json"),
487+
JSON.stringify({ name: "feishu" }),
488+
"utf8",
489+
);
490+
const result = await runPluginPayloadSmokeCheck({
491+
records: {
492+
feishu: { source: "clawhub", installPath: dir },
493+
},
494+
env: {},
495+
});
496+
expect(result.failures).toEqual([]);
497+
expect(result.checked).toEqual(["feishu"]);
498+
});
499+
500+
it("reports a failure for a bundle plugin with missing .claude-plugin/plugin.json", async () => {
501+
const dir = path.join(tmpRoot, "bad-bundle");
502+
await fs.mkdir(dir, { recursive: true });
503+
const result = await runPluginPayloadSmokeCheck({
504+
records: {
505+
bad: { source: "clawhub", clawhubFamily: "bundle-plugin", installPath: dir },
506+
},
507+
env: {},
508+
});
509+
expect(result.failures).toStrictEqual([
510+
{
511+
pluginId: "bad",
512+
installPath: dir,
513+
reason: "missing-package-json",
514+
detail: `.claude-plugin/plugin.json is missing under ${dir}`,
515+
},
516+
]);
517+
});
518+
519+
it("reports a failure for a bundle plugin with unparseable .claude-plugin/plugin.json", async () => {
520+
const dir = path.join(tmpRoot, "bad-bundle");
521+
await fs.mkdir(path.join(dir, ".claude-plugin"), { recursive: true });
522+
await fs.writeFile(path.join(dir, ".claude-plugin", "plugin.json"), "not-json", "utf8");
523+
const result = await runPluginPayloadSmokeCheck({
524+
records: {
525+
bad: { source: "clawhub", clawhubFamily: "bundle-plugin", installPath: dir },
526+
},
527+
env: {},
528+
});
529+
expect(result.failures).toStrictEqual([
530+
{
531+
pluginId: "bad",
532+
installPath: dir,
533+
reason: "invalid-package-json",
534+
detail:
535+
"Could not parse .claude-plugin/plugin.json: Unexpected token 'o', \"not-json\" is not valid JSON",
536+
},
537+
]);
538+
});
539+
464540
it("only checks records whose source is package-tracked (npm/clawhub/git/marketplace)", async () => {
465541
const dir = path.join(tmpRoot, "tracked");
466542
await writePackage(dir, { name: "tracked" }, "module.exports = {};");

‎src/cli/update-cli/plugin-payload-validation.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,37 @@ export async function runPluginPayloadSmokeCheck(params: {
7878
continue;
7979
}
8080

81+
// Bundle-format plugins (Claude-plugin layout: .claude-plugin/plugin.json +
82+
// skills/) ship without package.json. Validate the bundle manifest instead
83+
// of requiring an npm package.json (#97985).
84+
const isBundlePlugin =
85+
record.clawhubFamily === "bundle-plugin" ||
86+
(await safeStat(path.join(installPath, ".claude-plugin", "plugin.json")))?.isFile();
87+
if (isBundlePlugin) {
88+
const bundleManifestPath = path.join(installPath, ".claude-plugin", "plugin.json");
89+
const bundleManifestStat = await safeStat(bundleManifestPath);
90+
if (!bundleManifestStat?.isFile()) {
91+
failures.push({
92+
pluginId,
93+
installPath,
94+
reason: "missing-package-json",
95+
detail: `.claude-plugin/plugin.json is missing under ${installPath}`,
96+
});
97+
continue;
98+
}
99+
try {
100+
JSON.parse(await fs.readFile(bundleManifestPath, "utf8"));
101+
} catch (err) {
102+
failures.push({
103+
pluginId,
104+
installPath,
105+
reason: "invalid-package-json",
106+
detail: `Could not parse .claude-plugin/plugin.json: ${err instanceof Error ? err.message : String(err)}`,
107+
});
108+
}
109+
continue;
110+
}
111+
81112
const packageJsonPath = path.join(installPath, "package.json");
82113
const packageJsonStat = await safeStat(packageJsonPath);
83114
if (!packageJsonStat?.isFile()) {

0 commit comments

Comments
 (0)