Skip to content

Commit 2e389b6

Browse files
committed
fix(update): prefer npm during post-core repair
(cherry picked from commit eab57ad)
1 parent f4dc9b1 commit 2e389b6

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

‎src/commands/doctor/shared/missing-configured-plugin-install.test.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,67 @@ describe("repairMissingConfiguredPluginInstalls", () => {
12091209
});
12101210
});
12111211

1212+
it("prefers npm over ClawHub during post-core repair", async () => {
1213+
const npmRoot = makeTempDir();
1214+
const packageDir = path.join(npmRoot, "node_modules", "@openclaw", "whatsapp");
1215+
mocks.resolveDefaultPluginNpmDir.mockReturnValue(npmRoot);
1216+
mocks.listChannelPluginCatalogEntries.mockReturnValue([
1217+
{
1218+
id: "whatsapp",
1219+
pluginId: "whatsapp",
1220+
meta: { label: "WhatsApp" },
1221+
install: {
1222+
clawhubSpec: "clawhub:@openclaw/whatsapp",
1223+
npmSpec: "@openclaw/whatsapp",
1224+
},
1225+
},
1226+
]);
1227+
mocks.installPluginFromClawHub.mockResolvedValue({
1228+
ok: false,
1229+
error: 'Plugin "@openclaw/whatsapp" requires plugin API >=2026.5.18.',
1230+
});
1231+
mocks.installPluginFromNpmSpec.mockResolvedValue({
1232+
ok: true,
1233+
pluginId: "whatsapp",
1234+
targetDir: packageDir,
1235+
version: "1.2.3",
1236+
npmResolution: {
1237+
name: "@openclaw/whatsapp",
1238+
version: "1.2.3",
1239+
resolvedSpec: "@openclaw/[email protected]",
1240+
integrity: "sha512-whatsapp",
1241+
resolvedAt: "2026-05-01T00:00:00.000Z",
1242+
},
1243+
});
1244+
1245+
const { repairMissingConfiguredPluginInstalls } =
1246+
await import("./missing-configured-plugin-install.js");
1247+
const result = await repairMissingConfiguredPluginInstalls({
1248+
cfg: {
1249+
plugins: {
1250+
entries: {
1251+
whatsapp: { enabled: true },
1252+
},
1253+
},
1254+
channels: {
1255+
whatsapp: { enabled: true },
1256+
},
1257+
},
1258+
env: {
1259+
OPENCLAW_UPDATE_POST_CORE_CONVERGENCE: "1",
1260+
},
1261+
});
1262+
1263+
expect(mocks.installPluginFromClawHub).not.toHaveBeenCalled();
1264+
expectRecordFields(mockCallArg(mocks.installPluginFromNpmSpec), {
1265+
spec: expectedNpmInstallSpec("@openclaw/whatsapp"),
1266+
npmDir: npmRoot,
1267+
mode: "install",
1268+
});
1269+
expect(result.warnings).toEqual([]);
1270+
expect(result.records.whatsapp?.installPath).toBe(packageDir);
1271+
});
1272+
12121273
it("repairs missing external payload during post-core convergence even with OPENCLAW_UPDATE_IN_PROGRESS=1", async () => {
12131274
const records = {
12141275
discord: {

‎src/commands/doctor/shared/missing-configured-plugin-install.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ async function repairMissingPluginInstalls(params: {
11351135
configChannel: normalizeUpdateChannel(params.cfg.update?.channel),
11361136
currentVersion: VERSION,
11371137
});
1138-
const preferNpmInstalls = isLegacyPackageUpdateDoctorPass(env);
1138+
const preferNpmInstalls = isLegacyPackageUpdateDoctorPass(env) || isPostCoreConvergencePass(env);
11391139
let nextRecords = records;
11401140

11411141
for (const [pluginId, record] of Object.entries(records)) {

0 commit comments

Comments
 (0)