fix(cli): validate plugin drift update target

This commit is contained in:
Vincent Koc
2026-06-23 12:10:34 +08:00
parent a45544acf8
commit d41b9b5b25
2 changed files with 17 additions and 1 deletions
+13
View File
@@ -373,4 +373,17 @@ describe("resolvePluginVersionDriftUpdateCommand", () => {
}),
).toBe("openclaw plugins update brave");
});
it("keeps plugin-id updates when the gateway version is not a registry version", () => {
expect(
resolvePluginVersionDriftUpdateCommand({
pluginId: "brave",
installedVersion: "2026.6.9",
gatewayVersion: "unknown",
source: "npm",
packageName: "@openclaw/brave-plugin",
spec: "@openclaw/brave-plugin@2026.6.9",
}),
).toBe("openclaw plugins update brave");
});
});
+4 -1
View File
@@ -38,7 +38,10 @@ function resolveExactNpmPinPackageName(entry: PluginVersionDriftEntry): string |
export function resolvePluginVersionDriftUpdateCommand(entry: PluginVersionDriftEntry): string {
const exactNpmPackageName = resolveExactNpmPinPackageName(entry);
if (exactNpmPackageName) {
return `openclaw plugins update ${exactNpmPackageName}@${entry.gatewayVersion}`;
const exactNpmTarget = `${exactNpmPackageName}@${entry.gatewayVersion}`;
if (parseRegistryNpmSpec(exactNpmTarget)?.selectorKind === "exact-version") {
return `openclaw plugins update ${exactNpmTarget}`;
}
}
return `openclaw plugins update ${entry.pluginId}`;
}