Skip to content

Commit e0773e1

Browse files
LilacLilac
authored andcommitted
fix(plugins): preserve manual exact plugin pins
1 parent 9f63e58 commit e0773e1

3 files changed

Lines changed: 112 additions & 1 deletion

File tree

‎src/cli/plugins-cli.update.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,27 @@ describe("plugins cli update", () => {
210210
expect(updateParams.dangerouslyForceUnsafeInstall).toBe(true);
211211
});
212212

213+
it("does not sync official catalog specs for manual plugin updates", async () => {
214+
const config = createTrackedPluginConfig({
215+
pluginId: "codex",
216+
spec: "@openclaw/[email protected]",
217+
resolvedName: "@openclaw/codex",
218+
});
219+
loadConfig.mockReturnValue(config);
220+
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
221+
updateNpmInstalledPlugins.mockResolvedValue({
222+
config,
223+
changed: false,
224+
outcomes: [],
225+
});
226+
227+
await runPluginsCommand(["plugins", "update", "codex"]);
228+
229+
const updateParams = expectSingleCallParams(updateNpmInstalledPlugins);
230+
expect(updateParams.pluginIds).toEqual(["codex"]);
231+
expect(updateParams.syncOfficialPluginInstalls).toBeUndefined();
232+
});
233+
213234
it("writes updated config when updater reports changes", async () => {
214235
const cfg = {
215236
plugins: {

‎src/cli/plugins-update-command.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export async function runPluginUpdateCommand(params: {
6060
config: cfgWithPluginInstallRecords,
6161
pluginIds: pluginSelection.pluginIds,
6262
specOverrides: pluginSelection.specOverrides,
63-
syncOfficialPluginInstalls: true,
6463
dryRun: params.opts.dryRun,
6564
dangerouslyForceUnsafeInstall: params.opts.dangerouslyForceUnsafeInstall,
6665
logger,

‎src/plugins/update.test.ts‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,97 @@ describe("updateNpmInstalledPlugins", () => {
15301530
});
15311531
});
15321532

1533+
it("preserves exact official npm pins when official install sync is not requested", async () => {
1534+
const installPath = createInstalledPackageDir({
1535+
name: "@openclaw/codex",
1536+
version: "2026.5.28",
1537+
});
1538+
installPluginFromNpmSpecMock.mockResolvedValue(
1539+
createSuccessfulNpmUpdateResult({
1540+
pluginId: "codex",
1541+
targetDir: installPath,
1542+
version: "2026.5.28",
1543+
npmResolution: {
1544+
name: "@openclaw/codex",
1545+
version: "2026.5.28",
1546+
resolvedSpec: "@openclaw/[email protected]",
1547+
},
1548+
}),
1549+
);
1550+
1551+
const result = await updateNpmInstalledPlugins({
1552+
config: createNpmInstallConfig({
1553+
pluginId: "codex",
1554+
spec: "@openclaw/[email protected]",
1555+
installPath,
1556+
resolvedName: "@openclaw/codex",
1557+
resolvedSpec: "@openclaw/[email protected]",
1558+
resolvedVersion: "2026.5.28",
1559+
}),
1560+
pluginIds: ["codex"],
1561+
dryRun: true,
1562+
});
1563+
1564+
expect(npmInstallCall()?.spec).toBe("@openclaw/[email protected]");
1565+
expect(npmInstallCall()?.expectedPluginId).toBe("codex");
1566+
expect(npmInstallCall()?.trustedSourceLinkedOfficialInstall).toBe(true);
1567+
expect(result.changed).toBe(false);
1568+
expectRecordFields(result.outcomes[0], {
1569+
pluginId: "codex",
1570+
status: "unchanged",
1571+
currentVersion: "2026.5.28",
1572+
nextVersion: "2026.5.28",
1573+
});
1574+
});
1575+
1576+
it("reinstalls missing exact official npm pins without official install sync", async () => {
1577+
const extensionsDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-missing-plugin-"));
1578+
tempDirs.push(extensionsDir);
1579+
const installPath = path.join(extensionsDir, "codex");
1580+
installPluginFromNpmSpecMock.mockResolvedValue(
1581+
createSuccessfulNpmUpdateResult({
1582+
pluginId: "codex",
1583+
targetDir: installPath,
1584+
version: "2026.5.28",
1585+
npmResolution: {
1586+
name: "@openclaw/codex",
1587+
version: "2026.5.28",
1588+
resolvedSpec: "@openclaw/[email protected]",
1589+
},
1590+
}),
1591+
);
1592+
1593+
const result = await updateNpmInstalledPlugins({
1594+
config: createNpmInstallConfig({
1595+
pluginId: "codex",
1596+
spec: "@openclaw/[email protected]",
1597+
installPath,
1598+
resolvedName: "@openclaw/codex",
1599+
resolvedSpec: "@openclaw/[email protected]",
1600+
resolvedVersion: "2026.5.28",
1601+
}),
1602+
pluginIds: ["codex"],
1603+
});
1604+
1605+
expect(npmInstallCall()?.spec).toBe("@openclaw/[email protected]");
1606+
expect(npmInstallCall()?.extensionsDir).toBe(extensionsDir);
1607+
expect(runCommandWithTimeoutMock).not.toHaveBeenCalled();
1608+
expectRecordFields(result.config.plugins?.installs?.codex, {
1609+
source: "npm",
1610+
spec: "@openclaw/[email protected]",
1611+
installPath,
1612+
version: "2026.5.28",
1613+
resolvedName: "@openclaw/codex",
1614+
resolvedSpec: "@openclaw/[email protected]",
1615+
resolvedVersion: "2026.5.28",
1616+
});
1617+
expectRecordFields(result.outcomes[0], {
1618+
pluginId: "codex",
1619+
status: "updated",
1620+
nextVersion: "2026.5.28",
1621+
});
1622+
});
1623+
15331624
it("keeps third-party exact pinned npm specs pinned during official install sync", async () => {
15341625
const installPath = createInstalledPackageDir({
15351626
name: "@acme/demo",

0 commit comments

Comments
 (0)