


























@@ -6,7 +6,7 @@ import {
66loadPluginManifestRegistryForInstalledIndex,
77resolveInstalledManifestRegistryIndexFingerprint,
88} from "./manifest-registry-installed.js";
9-import type { PluginManifestRecord } from "./manifest-registry.js";
9+import { loadPluginManifestRegistry, type PluginManifestRecord } from "./manifest-registry.js";
1010import { resolvePluginControlPlaneFingerprint } from "./plugin-control-plane-context.js";
1111import type {
1212LoadPluginMetadataSnapshotParams,
@@ -47,6 +47,22 @@ function indexesMatch(
4747);
4848}
494950+function normalizeInstalledPluginIndex(index: InstalledPluginIndex): InstalledPluginIndex {
51+return {
52+version: index.version ?? 1,
53+hostContractVersion: index.hostContractVersion ?? "",
54+compatRegistryVersion: index.compatRegistryVersion ?? "",
55+migrationVersion: index.migrationVersion ?? 1,
56+policyHash: index.policyHash ?? "",
57+generatedAtMs: index.generatedAtMs ?? 0,
58+installRecords: index.installRecords ?? {},
59+plugins: index.plugins ?? [],
60+diagnostics: index.diagnostics ?? [],
61+ ...(index.warning ? { warning: index.warning } : {}),
62+ ...(index.refreshReason ? { refreshReason: index.refreshReason } : {}),
63+} as InstalledPluginIndex;
64+}
65+5066export function isPluginMetadataSnapshotCompatible(params: {
5167snapshot: Pick<
5268PluginMetadataSnapshot,
@@ -184,17 +200,30 @@ function loadPluginMetadataSnapshotImpl(
184200env: params.env,
185201 ...(params.preferPersisted !== undefined ? { preferPersisted: params.preferPersisted } : {}),
186202 ...(params.index ? { index: params.index } : {}),
187-});
203+}) ?? {
204+source: "derived" as const,
205+snapshot: { plugins: [] },
206+diagnostics: [],
207+};
188208const registrySnapshotMs = performance.now() - registryStartedAt;
189-const index = registryResult.snapshot;
209+const index = normalizeInstalledPluginIndex(registryResult.snapshot);
190210const manifestStartedAt = performance.now();
191-const manifestRegistry = loadPluginManifestRegistryForInstalledIndex({
192- index,
193-config: params.config,
194-workspaceDir: params.workspaceDir,
195-env: params.env,
196-includeDisabled: true,
197-});
211+const manifestRegistry =
212+index.plugins.length === 0
213+ ? loadPluginManifestRegistry({
214+config: params.config,
215+workspaceDir: params.workspaceDir,
216+env: params.env,
217+diagnostics: index.diagnostics,
218+installRecords: index.installRecords,
219+})
220+ : loadPluginManifestRegistryForInstalledIndex({
221+ index,
222+config: params.config,
223+workspaceDir: params.workspaceDir,
224+env: params.env,
225+includeDisabled: true,
226+});
198227const manifestRegistryMs = performance.now() - manifestStartedAt;
199228const normalizePluginId = createPluginRegistryIdNormalizer(index, { manifestRegistry });
200229const byPluginId = new Map(manifestRegistry.plugins.map((plugin) => [plugin.id, plugin]));
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。