






















@@ -50,7 +50,11 @@ import {
5050type NormalizedPluginsConfig,
5151} from "./config-state.js";
5252import { isPluginEnabledByDefaultForPlatform } from "./default-enablement.js";
53-import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
53+import {
54+discoverOpenClawPlugins,
55+type PluginCandidate,
56+type PluginDiscoveryResult,
57+} from "./discovery.js";
5458import { shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js";
5559import { getGlobalHookRunner, initializeGlobalHookRunner } from "./hook-runner-global.js";
5660import { toSafeImportPath } from "./import-specifier.js";
@@ -198,6 +202,14 @@ export type PluginLoadOptions = {
198202loadModules?: boolean;
199203throwOnLoadError?: boolean;
200204manifestRegistry?: PluginManifestRegistry;
205+/**
206+ * Pre-computed plugin discovery result. When supplied, internal calls to
207+ * `discoverOpenClawPlugins` are skipped. Callers in the same startup flow
208+ * can compute one discovery result and share it across loader entry points
209+ * to eliminate redundant filesystem walks. Ignored when `manifestRegistry`
210+ * is also provided (the registry already implies a discovery snapshot).
211+ */
212+discovery?: PluginDiscoveryResult;
201213};
202214203215function detailPluginStartupTrace(
@@ -1690,12 +1702,13 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
16901702candidates: createPluginCandidatesFromManifestRegistry(suppliedManifestRegistry),
16911703diagnostics: [] as PluginDiagnostic[],
16921704}
1693- : discoverOpenClawPlugins({
1705+ : (options.discovery ??
1706+discoverOpenClawPlugins({
16941707workspaceDir: options.workspaceDir,
16951708extraPaths: normalized.loadPaths,
16961709 env,
16971710 installRecords,
1698-});
1711+}));
16991712const manifestRegistry =
17001713suppliedManifestRegistry ??
17011714loadPluginManifestRegistry({
@@ -2559,12 +2572,14 @@ export async function loadOpenClawPluginCliRegistry(
25592572activateGlobalSideEffects: false,
25602573});
256125742562-const discovery = discoverOpenClawPlugins({
2563-workspaceDir: options.workspaceDir,
2564-extraPaths: normalized.loadPaths,
2565- env,
2566- installRecords,
2567-});
2575+const discovery =
2576+options.discovery ??
2577+discoverOpenClawPlugins({
2578+workspaceDir: options.workspaceDir,
2579+extraPaths: normalized.loadPaths,
2580+ env,
2581+ installRecords,
2582+});
25682583const manifestRegistry = loadPluginManifestRegistry({
25692584config: cfg,
25702585workspaceDir: options.workspaceDir,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。