From b565e6e96310c03e81b32caf82894ce89f32fec5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 26 Apr 2026 01:29:47 +0100 Subject: [PATCH] fix(ci): repair plugin registry test lanes --- .../subagent-registry.persistence.test.ts | 4 +-- src/cli/plugins-cli.policy.test.ts | 2 ++ .../channel-setup/plugin-install.test.ts | 1 + src/plugins/loader.ts | 29 ++++++++++++++----- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/agents/subagent-registry.persistence.test.ts b/src/agents/subagent-registry.persistence.test.ts index cbe97c164ca..20a83e60112 100644 --- a/src/agents/subagent-registry.persistence.test.ts +++ b/src/agents/subagent-registry.persistence.test.ts @@ -712,7 +712,7 @@ describe("subagent registry persistence", () => { resetSubagentRegistryForTests({ persist: false }); - const resolved = withEnv({ VITEST: undefined, NODE_ENV: "development" }, () => + const resolved = withEnv({ OPENCLAW_TEST_READ_SUBAGENT_RUNS_FROM_DISK: "1" }, () => getSubagentRunByChildSessionKey(childSessionKey), ); @@ -758,7 +758,7 @@ describe("subagent registry persistence", () => { resetSubagentRegistryForTests({ persist: false }); - const resolved = withEnv({ VITEST: undefined, NODE_ENV: "development" }, () => + const resolved = withEnv({ OPENCLAW_TEST_READ_SUBAGENT_RUNS_FROM_DISK: "1" }, () => getLatestSubagentRunByChildSessionKey(childSessionKey), ); diff --git a/src/cli/plugins-cli.policy.test.ts b/src/cli/plugins-cli.policy.test.ts index 6cd45023bd0..14165bba8dd 100644 --- a/src/cli/plugins-cli.policy.test.ts +++ b/src/cli/plugins-cli.policy.test.ts @@ -33,6 +33,7 @@ describe("plugins cli policy mutations", () => { expect(writeConfigFile).toHaveBeenCalledWith(enabledConfig); expect(refreshPluginRegistry).toHaveBeenCalledWith({ config: enabledConfig, + installRecords: {}, reason: "policy-changed", }); }); @@ -52,6 +53,7 @@ describe("plugins cli policy mutations", () => { expect(nextConfig.plugins?.entries?.alpha?.enabled).toBe(false); expect(refreshPluginRegistry).toHaveBeenCalledWith({ config: nextConfig, + installRecords: {}, reason: "policy-changed", }); }); diff --git a/src/commands/channel-setup/plugin-install.test.ts b/src/commands/channel-setup/plugin-install.test.ts index 84fe0218cbc..949cb286b15 100644 --- a/src/commands/channel-setup/plugin-install.test.ts +++ b/src/commands/channel-setup/plugin-install.test.ts @@ -91,6 +91,7 @@ vi.mock("../../plugins/loader.js", () => ({ const clearPluginDiscoveryCache = vi.fn(); vi.mock("../../plugins/discovery.js", () => ({ clearPluginDiscoveryCache: () => clearPluginDiscoveryCache(), + discoverOpenClawPlugins: () => ({ candidates: [], diagnostics: [] }), })); import fs from "node:fs"; diff --git a/src/plugins/loader.ts b/src/plugins/loader.ts index ec682675ace..36aec8c3888 100644 --- a/src/plugins/loader.ts +++ b/src/plugins/loader.ts @@ -1217,7 +1217,10 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) { const shouldInstallBundledRuntimeDeps = options.installBundledRuntimeDeps !== false; const runtimeSubagentMode = resolveRuntimeSubagentMode(options.runtimeOptions); const coreGatewayMethodNames = Object.keys(options.coreGatewayHandlers ?? {}).toSorted(); - const installRecords = loadInstalledPluginIndexInstallRecordsSync({ env }); + const installRecords = { + ...loadInstalledPluginIndexInstallRecordsSync({ env }), + ...cfg.plugins?.installs, + }; const cacheKey = buildCacheKey({ workspaceDir: options.workspaceDir, plugins: trustNormalized, @@ -1255,6 +1258,7 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) { shouldLoadModules: options.loadModules !== false, shouldInstallBundledRuntimeDeps, runtimeSubagentMode, + installRecords, cacheKey, }; } @@ -2157,6 +2161,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi shouldInstallBundledRuntimeDeps, cacheKey, runtimeSubagentMode, + installRecords, } = resolvePluginLoadCacheContext(options); const logger = options.logger ?? defaultLogger(); const validateOnly = options.mode === "validate"; @@ -2316,6 +2321,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi env, candidates: discovery.candidates, diagnostics: discovery.diagnostics, + installRecords: Object.keys(installRecords).length > 0 ? installRecords : undefined, }); pushDiagnostics(registry.diagnostics, manifestRegistry.diagnostics); warnWhenAllowlistIsOpen({ @@ -3180,12 +3186,20 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi export async function loadOpenClawPluginCliRegistry( options: PluginLoadOptions = {}, ): Promise { - const { env, cfg, normalized, activationSource, autoEnabledReasons, onlyPluginIds, cacheKey } = - resolvePluginLoadCacheContext({ - ...options, - activate: false, - cache: false, - }); + const { + env, + cfg, + normalized, + activationSource, + autoEnabledReasons, + onlyPluginIds, + cacheKey, + installRecords, + } = resolvePluginLoadCacheContext({ + ...options, + activate: false, + cache: false, + }); const logger = options.logger ?? defaultLogger(); const onlyPluginIdSet = createPluginIdScopeSet(onlyPluginIds); const getJiti = createPluginJitiLoader(options); @@ -3209,6 +3223,7 @@ export async function loadOpenClawPluginCliRegistry( env, candidates: discovery.candidates, diagnostics: discovery.diagnostics, + installRecords: Object.keys(installRecords).length > 0 ? installRecords : undefined, }); pushDiagnostics(registry.diagnostics, manifestRegistry.diagnostics); warnWhenAllowlistIsOpen({