From b326e5c0f43c61b7c830637b593a363d34cded10 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 2 May 2026 11:01:54 -0700 Subject: [PATCH] test(plugins): support live clawhub legacy zips --- scripts/e2e/lib/plugins/assertions.mjs | 47 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/scripts/e2e/lib/plugins/assertions.mjs b/scripts/e2e/lib/plugins/assertions.mjs index e8ec17f6ea9..9c27245633b 100644 --- a/scripts/e2e/lib/plugins/assertions.mjs +++ b/scripts/e2e/lib/plugins/assertions.mjs @@ -305,6 +305,29 @@ function assertClawHubExternalInstallContract(installPath) { } } +function assertClawHubArtifactMetadata(record, pluginId) { + if (record.artifactKind === "legacy-zip") { + if (record.artifactFormat !== "zip") { + throw new Error( + `missing ClawHub legacy ZIP artifact metadata for ${pluginId}: ${JSON.stringify(record)}`, + ); + } + return; + } + + if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") { + throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`); + } + if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") { + throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`); + } + if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) { + throw new Error( + `missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`, + ); + } +} + function assertPluginDirDeps() { const sourceDir = process.argv[3]; assertSimplePlugin( @@ -534,17 +557,7 @@ function assertClawHubInstalled() { if (typeof record.installPath !== "string" || record.installPath.length === 0) { throw new Error(`missing ClawHub install path for ${pluginId}`); } - if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") { - throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`); - } - if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") { - throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`); - } - if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) { - throw new Error( - `missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`, - ); - } + assertClawHubArtifactMetadata(record, pluginId); const installPath = record.installPath.replace(/^~(?=$|\/)/u, process.env.HOME); const extensionsRoot = path.join(process.env.HOME, ".openclaw", "extensions"); @@ -554,7 +567,9 @@ function assertClawHubInstalled() { if (!fs.existsSync(installPath)) { throw new Error(`ClawHub install path missing on disk: ${installPath}`); } - assertClawHubExternalInstallContract(installPath); + if (record.artifactKind === "npm-pack") { + assertClawHubExternalInstallContract(installPath); + } fs.writeFileSync("/tmp/plugins-clawhub-install-path.txt", installPath, "utf8"); } @@ -596,10 +611,10 @@ function assertClawHubRemoved() { } function assertClawHubUpdated() { - assertUpdateOutput( - "/tmp/plugins-clawhub-update.log", - `${process.env.CLAWHUB_PLUGIN_ID} already at 0.1.0.`, - ); + const output = fs.readFileSync("/tmp/plugins-clawhub-update.log", "utf8"); + if (!output.includes(`${process.env.CLAWHUB_PLUGIN_ID} already at `)) { + throw new Error(`expected ClawHub update to report already-at version:\n${output}`); + } assertClawHubInstalled(); }