fix(plugins): scope metadata manifest reads · openclaw/openclaw@b7340ec
vincentkoc
·
2026-04-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -207,6 +207,26 @@ describe("setup-registry getJiti", () => {
|
207 | 207 | ); |
208 | 208 | }); |
209 | 209 | |
| 210 | +it("passes explicit plugin id scope into setup manifest reads", () => { |
| 211 | +const pluginRoot = makeTempDir(); |
| 212 | +fs.writeFileSync(path.join(pluginRoot, "setup-api.js"), "export default {};\n", "utf-8"); |
| 213 | +mocks.loadPluginManifestRegistry.mockReturnValue({ |
| 214 | +plugins: [{ id: "test-plugin", rootDir: pluginRoot }], |
| 215 | +diagnostics: [], |
| 216 | +}); |
| 217 | + |
| 218 | +resolvePluginSetupRegistry({ |
| 219 | +pluginIds: ["test-plugin"], |
| 220 | +env: {}, |
| 221 | +}); |
| 222 | + |
| 223 | +expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith( |
| 224 | +expect.objectContaining({ |
| 225 | +pluginIds: ["test-plugin"], |
| 226 | +}), |
| 227 | +); |
| 228 | +}); |
| 229 | + |
210 | 230 | it("skips setup-api loading when config has no relevant migration triggers", () => { |
211 | 231 | const pluginRoot = makeTempDir(); |
212 | 232 | fs.writeFileSync(path.join(pluginRoot, "setup-api.js"), "export default {};\n", "utf-8"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -380,12 +380,14 @@ function loadSetupManifestRegistry(params?: {
|
380 | 380 | config?: OpenClawConfig; |
381 | 381 | workspaceDir?: string; |
382 | 382 | env?: NodeJS.ProcessEnv; |
| 383 | +pluginIds?: readonly string[]; |
383 | 384 | }) { |
384 | 385 | const env = params?.env ?? process.env; |
385 | 386 | return loadPluginManifestRegistryForPluginRegistry({ |
386 | 387 | config: params?.config, |
387 | 388 | workspaceDir: params?.workspaceDir, |
388 | 389 | env, |
| 390 | +pluginIds: params?.pluginIds, |
389 | 391 | includeDisabled: true, |
390 | 392 | }); |
391 | 393 | } |
@@ -532,6 +534,7 @@ export function resolvePluginSetupRegistry(params?: {
|
532 | 534 | const manifestRegistry = loadSetupManifestRegistry({ |
533 | 535 | workspaceDir: params?.workspaceDir, |
534 | 536 | env, |
| 537 | +pluginIds: params?.pluginIds, |
535 | 538 | }); |
536 | 539 | |
537 | 540 | for (const record of manifestRegistry.plugins) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -62,6 +62,7 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
|
62 | 62 | onlyPluginIds: [], |
63 | 63 | }), |
64 | 64 | ).toEqual([]); |
| 65 | +expect(mocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled(); |
65 | 66 | }); |
66 | 67 | |
67 | 68 | it("keeps runtime fallback for scoped plugins with no declared web candidates", () => { |
@@ -72,6 +73,11 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
|
72 | 73 | onlyPluginIds: ["missing-plugin"], |
73 | 74 | }), |
74 | 75 | ).toBeUndefined(); |
| 76 | +expect(mocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith( |
| 77 | +expect.objectContaining({ |
| 78 | +pluginIds: ["missing-plugin"], |
| 79 | +}), |
| 80 | +); |
75 | 81 | }); |
76 | 82 | |
77 | 83 | it("derives provider candidates from a single manifest-registry read", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -63,11 +63,13 @@ function loadInstalledWebProviderManifestRecords(params: {
|
63 | 63 | config?: PluginLoadOptions["config"]; |
64 | 64 | workspaceDir?: string; |
65 | 65 | env?: PluginLoadOptions["env"]; |
| 66 | +pluginIds?: readonly string[]; |
66 | 67 | }): readonly PluginManifestRecord[] { |
67 | 68 | return loadPluginManifestRegistryForPluginRegistry({ |
68 | 69 | config: params.config, |
69 | 70 | workspaceDir: params.workspaceDir, |
70 | 71 | env: params.env, |
| 72 | +pluginIds: params.pluginIds, |
71 | 73 | includeDisabled: true, |
72 | 74 | }).plugins; |
73 | 75 | } |
@@ -82,11 +84,15 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
|
82 | 84 | origin?: PluginManifestRecord["origin"]; |
83 | 85 | }): string[] | undefined { |
84 | 86 | const scopedPluginIds = normalizePluginIdScope(params.onlyPluginIds); |
| 87 | +if (scopedPluginIds?.length === 0) { |
| 88 | +return []; |
| 89 | +} |
85 | 90 | const onlyPluginIdSet = createPluginIdScopeSet(scopedPluginIds); |
86 | 91 | const ids = loadInstalledWebProviderManifestRecords({ |
87 | 92 | config: params.config, |
88 | 93 | workspaceDir: params.workspaceDir, |
89 | 94 | env: params.env, |
| 95 | +pluginIds: scopedPluginIds, |
90 | 96 | }) |
91 | 97 | .filter( |
92 | 98 | (plugin) => |
@@ -99,7 +105,7 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
|
99 | 105 | if (ids.length > 0) { |
100 | 106 | return ids; |
101 | 107 | } |
102 | | -return scopedPluginIds?.length === 0 ? [] : undefined; |
| 108 | +return undefined; |
103 | 109 | } |
104 | 110 | |
105 | 111 | function resolveBundledWebProviderCompatPluginIds(params: { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。