Skip to content

Commit b7340ec

Browse files
committed
fix(plugins): scope metadata manifest reads
1 parent 3ea20d1 commit b7340ec

4 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/plugins/setup-registry.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ describe("setup-registry getJiti", () => {
207207
);
208208
});
209209

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+
210230
it("skips setup-api loading when config has no relevant migration triggers", () => {
211231
const pluginRoot = makeTempDir();
212232
fs.writeFileSync(path.join(pluginRoot, "setup-api.js"), "export default {};\n", "utf-8");

src/plugins/setup-registry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,14 @@ function loadSetupManifestRegistry(params?: {
380380
config?: OpenClawConfig;
381381
workspaceDir?: string;
382382
env?: NodeJS.ProcessEnv;
383+
pluginIds?: readonly string[];
383384
}) {
384385
const env = params?.env ?? process.env;
385386
return loadPluginManifestRegistryForPluginRegistry({
386387
config: params?.config,
387388
workspaceDir: params?.workspaceDir,
388389
env,
390+
pluginIds: params?.pluginIds,
389391
includeDisabled: true,
390392
});
391393
}
@@ -532,6 +534,7 @@ export function resolvePluginSetupRegistry(params?: {
532534
const manifestRegistry = loadSetupManifestRegistry({
533535
workspaceDir: params?.workspaceDir,
534536
env,
537+
pluginIds: params?.pluginIds,
535538
});
536539

537540
for (const record of manifestRegistry.plugins) {

src/plugins/web-provider-resolution-candidates.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
6262
onlyPluginIds: [],
6363
}),
6464
).toEqual([]);
65+
expect(mocks.loadPluginManifestRegistryForInstalledIndex).not.toHaveBeenCalled();
6566
});
6667

6768
it("keeps runtime fallback for scoped plugins with no declared web candidates", () => {
@@ -72,6 +73,11 @@ describe("resolveManifestDeclaredWebProviderCandidatePluginIds", () => {
7273
onlyPluginIds: ["missing-plugin"],
7374
}),
7475
).toBeUndefined();
76+
expect(mocks.loadPluginManifestRegistryForInstalledIndex).toHaveBeenCalledWith(
77+
expect.objectContaining({
78+
pluginIds: ["missing-plugin"],
79+
}),
80+
);
7581
});
7682

7783
it("derives provider candidates from a single manifest-registry read", () => {

src/plugins/web-provider-resolution-shared.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ function loadInstalledWebProviderManifestRecords(params: {
6363
config?: PluginLoadOptions["config"];
6464
workspaceDir?: string;
6565
env?: PluginLoadOptions["env"];
66+
pluginIds?: readonly string[];
6667
}): readonly PluginManifestRecord[] {
6768
return loadPluginManifestRegistryForPluginRegistry({
6869
config: params.config,
6970
workspaceDir: params.workspaceDir,
7071
env: params.env,
72+
pluginIds: params.pluginIds,
7173
includeDisabled: true,
7274
}).plugins;
7375
}
@@ -82,11 +84,15 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
8284
origin?: PluginManifestRecord["origin"];
8385
}): string[] | undefined {
8486
const scopedPluginIds = normalizePluginIdScope(params.onlyPluginIds);
87+
if (scopedPluginIds?.length === 0) {
88+
return [];
89+
}
8590
const onlyPluginIdSet = createPluginIdScopeSet(scopedPluginIds);
8691
const ids = loadInstalledWebProviderManifestRecords({
8792
config: params.config,
8893
workspaceDir: params.workspaceDir,
8994
env: params.env,
95+
pluginIds: scopedPluginIds,
9096
})
9197
.filter(
9298
(plugin) =>
@@ -99,7 +105,7 @@ export function resolveManifestDeclaredWebProviderCandidatePluginIds(params: {
99105
if (ids.length > 0) {
100106
return ids;
101107
}
102-
return scopedPluginIds?.length === 0 ? [] : undefined;
108+
return undefined;
103109
}
104110

105111
function resolveBundledWebProviderCompatPluginIds(params: {

0 commit comments

Comments
 (0)