From 0731fc1942e9308b166b2c8c15001bb988c06d53 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 26 Apr 2026 02:07:04 +0100 Subject: [PATCH] test: keep packaged provider setup discoverable --- .../e2e/npm-onboard-channel-agent-docker.sh | 1 + .../shared/plugin-registry-migration.test.ts | 30 +++++++++++++++++++ .../shared/plugin-registry-migration.ts | 3 ++ 3 files changed, 34 insertions(+) diff --git a/scripts/e2e/npm-onboard-channel-agent-docker.sh b/scripts/e2e/npm-onboard-channel-agent-docker.sh index faceb0041fc..ddacdca359c 100644 --- a/scripts/e2e/npm-onboard-channel-agent-docker.sh +++ b/scripts/e2e/npm-onboard-channel-agent-docker.sh @@ -61,6 +61,7 @@ if ! docker run --rm \ -e OPENCLAW_NPM_ONBOARD_CHANNEL="$CHANNEL" \ -e OPENCLAW_CURRENT_PACKAGE_TGZ="$DOCKER_PACKAGE_TGZ" \ -v "$PACKAGE_TGZ:$DOCKER_PACKAGE_TGZ:ro" \ + -v "$ROOT_DIR/scripts/e2e:/app/scripts/e2e:ro" \ -i "$IMAGE_NAME" bash -s >"$run_log" 2>&1 <<'EOF' set -euo pipefail diff --git a/src/commands/doctor/shared/plugin-registry-migration.test.ts b/src/commands/doctor/shared/plugin-registry-migration.test.ts index 7b2d5941889..ebeb58920f4 100644 --- a/src/commands/doctor/shared/plugin-registry-migration.test.ts +++ b/src/commands/doctor/shared/plugin-registry-migration.test.ts @@ -43,6 +43,7 @@ function createCandidate( rootDir: string, id = "demo", origin: PluginCandidate["origin"] = "global", + options: { enabledByDefault?: boolean } = {}, ): PluginCandidate { fs.writeFileSync( path.join(rootDir, "index.ts"), @@ -54,6 +55,7 @@ function createCandidate( JSON.stringify({ id, name: id, + ...(options.enabledByDefault ? { enabledByDefault: true } : {}), configSchema: { type: "object" }, providers: [id], }), @@ -184,6 +186,34 @@ describe("plugin registry install migration", () => { ]); }); + it("keeps enabled-by-default bundled provider plugins discoverable for setup", async () => { + const stateDir = makeTempDir(); + const openaiDir = path.join(stateDir, "plugins", "openai"); + const unusedBundledDir = path.join(stateDir, "plugins", "unused-bundled"); + fs.mkdirSync(openaiDir, { recursive: true }); + fs.mkdirSync(unusedBundledDir, { recursive: true }); + + await expect( + migratePluginRegistryForInstall({ + stateDir, + candidates: [ + createCandidate(openaiDir, "openai", "bundled", { enabledByDefault: true }), + createCandidate(unusedBundledDir, "unused-bundled", "bundled"), + ], + readConfig: async () => ({}), + env: hermeticEnv(), + }), + ).resolves.toMatchObject({ + status: "migrated", + current: { + plugins: [expect.objectContaining({ pluginId: "openai", enabledByDefault: true })], + }, + }); + + const persisted = await readPersistedInstalledPluginIndex({ stateDir }); + expect(persisted?.plugins.map((plugin) => plugin.pluginId)).toEqual(["openai"]); + }); + it("supports dry-run preflight without reading config or writing the registry", async () => { const stateDir = makeTempDir(); const readConfig = vi.fn(async () => ({})); diff --git a/src/commands/doctor/shared/plugin-registry-migration.ts b/src/commands/doctor/shared/plugin-registry-migration.ts index 2f689354a38..292c1e7abab 100644 --- a/src/commands/doctor/shared/plugin-registry-migration.ts +++ b/src/commands/doctor/shared/plugin-registry-migration.ts @@ -226,6 +226,9 @@ export function listMigrationRelevantPluginRecords(params: { if (plugin.origin !== "bundled") { return true; } + if (plugin.enabledByDefault && plugin.contributions.providers.length > 0) { + return true; + } if (installedPluginIds.has(plugin.pluginId) || referencedPluginIds.has(plugin.pluginId)) { return true; }