fix(update): carry candidate plugin API version through doctor

This commit is contained in:
Peter Steinberger
2026-05-20 02:36:28 +01:00
parent 70e51b81cf
commit 6b82eaa2cd
5 changed files with 15 additions and 1 deletions

View File

@@ -2365,12 +2365,21 @@ describe("update-cli", () => {
termination: "exit",
};
});
readPackageVersion.mockImplementation(async (packageRoot: string) => {
const manifest = JSON.parse(
await fs.readFile(path.join(packageRoot, "package.json"), "utf-8"),
) as { version?: string };
return manifest.version ?? "0.0.0";
});
await updateCommand({ yes: true });
const doctorCall = doctorCommandCall();
expect(doctorCall?.[0].slice(1)).toEqual([entryPath, "doctor", "--non-interactive", "--fix"]);
expect(doctorCall?.[1].cwd).toBe(pkgRoot);
expect(
(doctorCall?.[1].env as NodeJS.ProcessEnv | undefined)?.OPENCLAW_COMPATIBILITY_HOST_VERSION,
).toBe("2026.5.14");
expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);
});

View File

@@ -1403,6 +1403,7 @@ async function runPackageInstallUpdate(params: {
const entryPath = await resolveGatewayInstallEntrypoint(verifiedPackageRoot);
if (entryPath) {
await createUpdateConfigSnapshot();
const candidateHostVersion = await readPackageVersion(verifiedPackageRoot);
return await runUpdateStep({
name: `${CLI_NAME} doctor`,
argv: [
@@ -1421,6 +1422,7 @@ async function runPackageInstallUpdate(params: {
OPENCLAW_UPDATE_IN_PROGRESS: "1",
[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV]: "1",
[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV]: "1",
OPENCLAW_COMPATIBILITY_HOST_VERSION: candidateHostVersion,
},
timeoutMs: params.timeoutMs,
progress: params.progress,