

























@@ -25,6 +25,7 @@ import {
2525runtimeErrors,
2626runtimeLogs,
2727writeConfigFile,
28+writePersistedPluginInstallLedger,
2829} from "./plugins-cli-test-helpers.js";
29303031const CLI_STATE_ROOT = "/tmp/openclaw-state";
@@ -53,22 +54,6 @@ function createEmptyPluginConfig(): OpenClawConfig {
5354} as OpenClawConfig;
5455}
555656-function createClawHubInstalledConfig(params: {
57-pluginId: string;
58-install: Record<string, unknown>;
59-}): OpenClawConfig {
60-const enabledCfg = createEnabledPluginConfig(params.pluginId);
61-return {
62- ...enabledCfg,
63-plugins: {
64- ...enabledCfg.plugins,
65-installs: {
66-[params.pluginId]: params.install,
67-},
68-},
69-} as OpenClawConfig;
70-}
71-7257function createClawHubInstallResult(params: {
7358pluginId: string;
7459packageName: string;
@@ -320,19 +305,6 @@ describe("plugins cli install", () => {
320305},
321306},
322307} as OpenClawConfig;
323-const installedCfg = {
324- ...enabledCfg,
325-plugins: {
326- ...enabledCfg.plugins,
327-installs: {
328-alpha: {
329-source: "marketplace",
330-installPath: cliInstallPath("alpha"),
331-},
332-},
333-},
334-} as OpenClawConfig;
335-336308loadConfig.mockReturnValue(cfg);
337309installPluginFromMarketplace.mockResolvedValue({
338310ok: true,
@@ -345,20 +317,25 @@ describe("plugins cli install", () => {
345317marketplacePlugin: "alpha",
346318});
347319enablePluginInConfig.mockReturnValue({ config: enabledCfg });
348-recordPluginInstall.mockReturnValue(installedCfg);
349320buildPluginDiagnosticsReport.mockReturnValue({
350321plugins: [{ id: "alpha", kind: "provider" }],
351322diagnostics: [],
352323});
353324applyExclusiveSlotSelection.mockReturnValue({
354-config: installedCfg,
325+config: enabledCfg,
355326warnings: ["slot adjusted"],
356327});
357328358329await runPluginsCommand(["plugins", "install", "alpha", "--marketplace", "local/repo"]);
359330360331expect(clearPluginManifestRegistryCache).toHaveBeenCalledTimes(1);
361-expect(writeConfigFile).toHaveBeenCalledWith(installedCfg);
332+expect(writePersistedPluginInstallLedger).toHaveBeenCalledWith({
333+alpha: expect.objectContaining({
334+source: "marketplace",
335+installPath: cliInstallPath("alpha"),
336+}),
337+});
338+expect(writeConfigFile).toHaveBeenCalledWith(enabledCfg);
362339expect(runtimeLogs.some((line) => line.includes("slot adjusted"))).toBe(true);
363340expect(runtimeLogs.some((line) => line.includes("Installed plugin: alpha"))).toBe(true);
364341});
@@ -384,18 +361,6 @@ describe("plugins cli install", () => {
384361},
385362} as OpenClawConfig;
386363const enabledCfg = createEnabledPluginConfig("demo");
387-const installedCfg = createClawHubInstalledConfig({
388-pluginId: "demo",
389-install: {
390-source: "clawhub",
391-spec: "clawhub:demo@1.2.3",
392-installPath: cliInstallPath("demo"),
393-clawhubPackage: "demo",
394-clawhubFamily: "code-plugin",
395-clawhubChannel: "official",
396-},
397-});
398-399364loadConfig.mockReturnValue(cfg);
400365parseClawHubPluginSpec.mockReturnValue({ name: "demo" });
401366installPluginFromClawHub.mockResolvedValue(
@@ -407,9 +372,8 @@ describe("plugins cli install", () => {
407372}),
408373);
409374enablePluginInConfig.mockReturnValue({ config: enabledCfg });
410-recordPluginInstall.mockReturnValue(installedCfg);
411375applyExclusiveSlotSelection.mockReturnValue({
412-config: installedCfg,
376+config: enabledCfg,
413377warnings: [],
414378});
415379@@ -420,18 +384,16 @@ describe("plugins cli install", () => {
420384spec: "clawhub:demo",
421385}),
422386);
423-expect(recordPluginInstall).toHaveBeenCalledWith(
424-enabledCfg,
425-expect.objectContaining({
426-pluginId: "demo",
387+expect(writePersistedPluginInstallLedger).toHaveBeenCalledWith({
388+demo: expect.objectContaining({
427389source: "clawhub",
428390spec: "clawhub:demo@1.2.3",
429391clawhubPackage: "demo",
430392clawhubFamily: "code-plugin",
431393clawhubChannel: "official",
432394}),
433-);
434-expect(writeConfigFile).toHaveBeenCalledWith(installedCfg);
395+});
396+expect(writeConfigFile).toHaveBeenCalledWith(enabledCfg);
435397expect(runtimeLogs.some((line) => line.includes("Installed plugin: demo"))).toBe(true);
436398expect(installPluginFromNpmSpec).not.toHaveBeenCalled();
437399});
@@ -478,16 +440,6 @@ describe("plugins cli install", () => {
478440},
479441} as OpenClawConfig;
480442const enabledCfg = createEnabledPluginConfig("demo");
481-const installedCfg = createClawHubInstalledConfig({
482-pluginId: "demo",
483-install: {
484-source: "clawhub",
485-spec: "clawhub:demo@1.2.3",
486-installPath: cliInstallPath("demo"),
487-clawhubPackage: "demo",
488-},
489-});
490-491443loadConfig.mockReturnValue(cfg);
492444installPluginFromClawHub.mockResolvedValue(
493445createClawHubInstallResult({
@@ -498,9 +450,8 @@ describe("plugins cli install", () => {
498450}),
499451);
500452enablePluginInConfig.mockReturnValue({ config: enabledCfg });
501-recordPluginInstall.mockReturnValue(installedCfg);
502453applyExclusiveSlotSelection.mockReturnValue({
503-config: installedCfg,
454+config: enabledCfg,
504455warnings: [],
505456});
506457@@ -512,7 +463,14 @@ describe("plugins cli install", () => {
512463}),
513464);
514465expect(installPluginFromNpmSpec).not.toHaveBeenCalled();
515-expect(writeConfigFile).toHaveBeenCalledWith(installedCfg);
466+expect(writePersistedPluginInstallLedger).toHaveBeenCalledWith({
467+demo: expect.objectContaining({
468+source: "clawhub",
469+spec: "clawhub:demo@1.2.3",
470+clawhubPackage: "demo",
471+}),
472+});
473+expect(writeConfigFile).toHaveBeenCalledWith(enabledCfg);
516474});
517475518476it("falls back to npm when ClawHub does not have the package", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。