





















@@ -73,6 +73,7 @@ export type PluginCandidate = {
7373packageOptionalDependencies?: PluginDependencySpecMap;
7474bundledManifest?: PluginManifest;
7575bundledManifestPath?: string;
76+rawPackageManifest?: PackageManifest;
7677};
77787879export type PluginDiscoveryResult = {
@@ -504,11 +505,25 @@ function readCandidatePackageManifest(params: {
504505origin: PluginOrigin;
505506rejectHardlinks: boolean;
506507rootRealPath?: string;
508+packageManifestCache?: Map<string, PackageManifest | null>;
507509}): PackageManifest | null {
508-if (params.origin === "bundled") {
509-return readTrustedPackageManifest(params.dir);
510+const trustMode =
511+params.origin === "bundled"
512+ ? "trusted"
513+ : params.rejectHardlinks
514+ ? "external-reject"
515+ : "external-allow";
516+const cacheKey = `${trustMode}:${params.rootRealPath ?? path.resolve(params.dir)}`;
517+const cached = params.packageManifestCache?.get(cacheKey);
518+if (cached !== undefined) {
519+return cached;
510520}
511-return readPackageManifest(params.dir, params.rejectHardlinks, params.rootRealPath);
521+const manifest =
522+params.origin === "bundled"
523+ ? readTrustedPackageManifest(params.dir)
524+ : readPackageManifest(params.dir, params.rejectHardlinks, params.rootRealPath);
525+params.packageManifestCache?.set(cacheKey, manifest);
526+return manifest;
512527}
513528514529function deriveIdHint(params: {
@@ -657,6 +672,7 @@ function addCandidate(params: {
657672packageManifest: getPackageManifestMetadata(manifest ?? undefined),
658673packageDependencies: packageDependencies.dependencies,
659674packageOptionalDependencies: packageDependencies.optionalDependencies,
675+rawPackageManifest: manifest ?? undefined,
660676bundledManifest: params.bundledManifest,
661677bundledManifestPath: params.bundledManifestPath,
662678});
@@ -748,6 +764,7 @@ function discoverInDirectory(params: {
748764diagnostics: PluginDiagnostic[];
749765seen: Set<string>;
750766realpathCache: Map<string, string>;
767+packageManifestCache?: Map<string, PackageManifest | null>;
751768recurseDirectories?: boolean;
752769skipDirectories?: Set<string>;
753770visitedDirectories?: Set<string>;
@@ -830,6 +847,7 @@ function discoverInDirectory(params: {
830847origin: params.origin,
831848 rejectHardlinks,
832849 ...(fullPathRealPath !== undefined ? { rootRealPath: fullPathRealPath } : {}),
850+packageManifestCache: params.packageManifestCache,
833851});
834852const extensionResolution = resolvePackageExtensionEntries(manifest ?? undefined);
835853if (
@@ -1016,6 +1034,7 @@ function discoverFromPath(params: {
10161034diagnostics: PluginDiagnostic[];
10171035seen: Set<string>;
10181036realpathCache: Map<string, string>;
1037+packageManifestCache?: Map<string, PackageManifest | null>;
10191038}) {
10201039const resolved = resolveUserPath(params.rawPath, params.env);
10211040if (!fs.existsSync(resolved)) {
@@ -1073,6 +1092,7 @@ function discoverFromPath(params: {
10731092origin: params.origin,
10741093 rejectHardlinks,
10751094 ...(resolvedRealPath !== undefined ? { rootRealPath: resolvedRealPath } : {}),
1095+packageManifestCache: params.packageManifestCache,
10761096});
10771097const extensionResolution = resolvePackageExtensionEntries(manifest ?? undefined);
10781098if (
@@ -1193,6 +1213,7 @@ function discoverFromPath(params: {
11931213diagnostics: params.diagnostics,
11941214seen: params.seen,
11951215realpathCache: params.realpathCache,
1216+packageManifestCache: params.packageManifestCache,
11961217 ...(params.requireBuiltRuntimeEntry !== undefined
11971218 ? { requireBuiltRuntimeEntry: params.requireBuiltRuntimeEntry }
11981219 : {}),
@@ -1220,6 +1241,7 @@ export function discoverOpenClawPlugins(params: {
12201241const result = createDiscoveryResult();
12211242const seen = new Set<string>();
12221243const realpathCache = new Map<string, string>();
1244+const packageManifestCache = new Map<string, PackageManifest | null>();
12231245const extra = params.extraPaths ?? [];
12241246for (const extraPath of extra) {
12251247if (typeof extraPath !== "string") {
@@ -1251,6 +1273,7 @@ export function discoverOpenClawPlugins(params: {
12511273diagnostics: result.diagnostics,
12521274 seen,
12531275 realpathCache,
1276+ packageManifestCache,
12541277});
12551278}
12561279const workspaceMatchesBundledRoot = resolvesToSameDirectory(
@@ -1272,6 +1295,7 @@ export function discoverOpenClawPlugins(params: {
12721295diagnostics: result.diagnostics,
12731296 seen,
12741297 realpathCache,
1298+ packageManifestCache,
12751299});
12761300}
12771301return result;
@@ -1284,6 +1308,7 @@ export function discoverOpenClawPlugins(params: {
12841308const result = createDiscoveryResult();
12851309const seen = new Set<string>();
12861310const realpathCache = new Map<string, string>();
1311+const packageManifestCache = new Map<string, PackageManifest | null>();
12871312for (const sourceOverlayDir of listBundledSourceOverlayDirs({
12881313bundledRoot: roots.stock,
12891314 env,
@@ -1298,6 +1323,7 @@ export function discoverOpenClawPlugins(params: {
12981323diagnostics: result.diagnostics,
12991324 seen,
13001325 realpathCache,
1326+ packageManifestCache,
13011327});
13021328result.diagnostics.push({
13031329level: "warn",
@@ -1324,6 +1350,7 @@ export function discoverOpenClawPlugins(params: {
13241350diagnostics: result.diagnostics,
13251351 seen,
13261352 realpathCache,
1353+ packageManifestCache,
13271354});
13281355}
13291356const sourceCheckoutExtensionsDir = resolveBundledSourceCheckoutExtensionsDir(roots.stock);
@@ -1342,6 +1369,7 @@ export function discoverOpenClawPlugins(params: {
13421369diagnostics: result.diagnostics,
13431370 seen,
13441371 realpathCache,
1372+ packageManifestCache,
13451373skipDirectories: readChildDirectoryNames(roots.stock),
13461374});
13471375}
@@ -1364,6 +1392,7 @@ export function discoverOpenClawPlugins(params: {
13641392diagnostics: result.diagnostics,
13651393 seen,
13661394 realpathCache,
1395+ packageManifestCache,
13671396});
13681397}
13691398// Keep auto-discovered global extensions behind bundled plugins.
@@ -1379,6 +1408,7 @@ export function discoverOpenClawPlugins(params: {
13791408diagnostics: result.diagnostics,
13801409 seen,
13811410 realpathCache,
1411+ packageManifestCache,
13821412});
13831413return result;
13841414},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。