diff --git a/src/cli/non-clawhub-install-acknowledgement.ts b/src/cli/non-clawhub-install-acknowledgement.ts index 15b48eea641a..6f1ced377a1e 100644 --- a/src/cli/non-clawhub-install-acknowledgement.ts +++ b/src/cli/non-clawhub-install-acknowledgement.ts @@ -8,7 +8,6 @@ import type { RuntimeEnv } from "../runtime.js"; import { promptYesNo } from "./prompt.js"; export { - formatNonClawHubInstallWarning, NON_CLAWHUB_INSTALL_FORCE_FLAG, type NonClawHubInstallSourceClass, } from "../plugins/install-provenance.js"; diff --git a/src/cli/plugin-install-plan.test.ts b/src/cli/plugin-install-plan.test.ts index 5a52d50e39e6..6d219453ee5c 100644 --- a/src/cli/plugin-install-plan.test.ts +++ b/src/cli/plugin-install-plan.test.ts @@ -2,12 +2,14 @@ import { installedPluginRoot } from "openclaw/plugin-sdk/test-fixtures"; import { describe, expect, it, vi } from "vitest"; import { PLUGIN_INSTALL_ERROR_CODE } from "../plugins/install.js"; +import { + resolveCatalogOfficialExternalInstallPlan, + resolveCatalogOfficialExternalNpmPackageTrust, +} from "../plugins/official-external-install-trust.js"; import { resolveBundledInstallPlanForCatalogEntry, resolveBundledInstallPlanBeforeNpm, resolveBundledInstallPlanForNpmFailure, - resolveOfficialExternalInstallPlanBeforeNpm, - resolveOfficialExternalNpmPackageTrust, } from "./plugin-install-plan.js"; describe("plugin install plan helpers", () => { @@ -70,81 +72,39 @@ describe("plugin install plan helpers", () => { }); it("resolves exact official external plugin ids before npm fallback", () => { - const findOfficialExternalPlugin = vi.fn().mockReturnValue({ - pluginId: "brave", - npmSpec: "@openclaw/brave-plugin", - expectedIntegrity: "sha512-brave", - }); + const result = resolveCatalogOfficialExternalInstallPlan("wecom-openclaw-plugin"); - const result = resolveOfficialExternalInstallPlanBeforeNpm({ - rawSpec: "brave", - findOfficialExternalPlugin, - }); - - expect(findOfficialExternalPlugin).toHaveBeenCalledWith("brave"); expect(result).toEqual({ - pluginId: "brave", - npmSpec: "@openclaw/brave-plugin", - expectedIntegrity: "sha512-brave", + pluginId: "wecom-openclaw-plugin", + npmSpec: "@wecom/wecom-openclaw-plugin@2026.5.7", + expectedIntegrity: + "sha512-TCkP9as00WfEhgFWG8YL/rcmaWGIshAki2HQh83nTRccGfVBCoGjrEboTTqq3yDmK9koWTV11zi8u8A4dNtvug==", }); }); it("skips official external plan for explicit npm selectors", () => { - const findOfficialExternalPlugin = vi.fn(); - + expect(resolveCatalogOfficialExternalInstallPlan("wecom-openclaw-plugin@beta")).toBeNull(); expect( - resolveOfficialExternalInstallPlanBeforeNpm({ - rawSpec: "brave@beta", - findOfficialExternalPlugin, - }), + resolveCatalogOfficialExternalInstallPlan("@wecom/wecom-openclaw-plugin@2026.5.7"), ).toBeNull(); - expect( - resolveOfficialExternalInstallPlanBeforeNpm({ - rawSpec: "@openclaw/brave-plugin", - findOfficialExternalPlugin, - }), - ).toBeNull(); - expect(findOfficialExternalPlugin).not.toHaveBeenCalled(); - }); - - it("skips official external plan without an npm install spec", () => { - const result = resolveOfficialExternalInstallPlanBeforeNpm({ - rawSpec: "brave", - findOfficialExternalPlugin: vi.fn().mockReturnValue({ - pluginId: "brave", - }), - }); - - expect(result).toBeNull(); }); it("trusts exact official external npm packages without remapping the spec", () => { - const findOfficialExternalPackage = vi.fn().mockReturnValue({ - pluginId: "discord", - npmSpec: "@openclaw/discord", - }); + const result = resolveCatalogOfficialExternalNpmPackageTrust( + "@wecom/wecom-openclaw-plugin@2026.5.7", + ); - const result = resolveOfficialExternalNpmPackageTrust({ - npmSpec: "@openclaw/discord", - findOfficialExternalPackage, - }); - - expect(findOfficialExternalPackage).toHaveBeenCalledWith("@openclaw/discord"); expect(result).toEqual({ - pluginId: "discord", + pluginId: "wecom-openclaw-plugin", + expectedIntegrity: + "sha512-TCkP9as00WfEhgFWG8YL/rcmaWGIshAki2HQh83nTRccGfVBCoGjrEboTTqq3yDmK9koWTV11zi8u8A4dNtvug==", trustedSourceLinkedOfficialInstall: true, }); }); it("does not trust npm package names outside the official external catalog", () => { - const findOfficialExternalPackage = vi.fn(); + const result = resolveCatalogOfficialExternalNpmPackageTrust("@acme/outside@1.0.0"); - const result = resolveOfficialExternalNpmPackageTrust({ - npmSpec: "brave", - findOfficialExternalPackage, - }); - - expect(findOfficialExternalPackage).toHaveBeenCalledWith("brave"); expect(result).toBeNull(); }); diff --git a/src/cli/plugin-install-plan.ts b/src/cli/plugin-install-plan.ts index ff64ccb087f6..5fa3345208ae 100644 --- a/src/cli/plugin-install-plan.ts +++ b/src/cli/plugin-install-plan.ts @@ -9,11 +9,6 @@ type BundledLookup = (params: { value: string; }) => BundledPluginSource | undefined; -export { - resolveOfficialExternalInstallPlanBeforeNpm, - resolveOfficialExternalNpmPackageTrust, -} from "../plugins/official-external-install-trust.js"; - function isBareNpmPackageName(spec: string): boolean { const trimmed = spec.trim(); return /^[a-z0-9][a-z0-9-._~]*$/.test(trimmed); diff --git a/src/plugins/official-external-install-trust.ts b/src/plugins/official-external-install-trust.ts index 470a61d56b1e..0625477380c7 100644 --- a/src/plugins/official-external-install-trust.ts +++ b/src/plugins/official-external-install-trust.ts @@ -48,7 +48,7 @@ function resolveCatalogInstall(value: string, lookup: "package" | "plugin") { }; } -export function resolveOfficialExternalInstallPlanBeforeNpm(params: { +function resolveOfficialExternalInstallPlanBeforeNpm(params: { rawSpec: string; findOfficialExternalPlugin: OfficialExternalPluginLookup; }): { pluginId: string; npmSpec: string; expectedIntegrity?: string } | null { @@ -67,7 +67,7 @@ export function resolveOfficialExternalInstallPlanBeforeNpm(params: { }; } -export function resolveOfficialExternalNpmPackageTrust(params: { +function resolveOfficialExternalNpmPackageTrust(params: { npmSpec: string; findOfficialExternalPackage: OfficialExternalPackageLookup; }): {