fix: reject unowned CLI roots before plugin load (#76379)

Co-authored-by: Neil <neil@neilofneils.com>
This commit is contained in:
neilofneils404
2026-05-03 15:06:49 -04:00
committed by GitHub
parent a64b30705f
commit 904cbec721
7 changed files with 215 additions and 20 deletions

View File

@@ -407,7 +407,7 @@ describe("registerPluginCliCommands", () => {
expect(mocks.memoryListAction).toHaveBeenCalledTimes(1);
});
it("keeps full CLI loading when primary command planning finds no plugin match", async () => {
it("scopes full CLI loading through CLI metadata when manifest planning finds no plugin match", async () => {
const program = createProgram();
program.exitOverride();
@@ -416,13 +416,28 @@ describe("registerPluginCliCommands", () => {
primary: "memory",
});
expect(mocks.loadOpenClawPluginCliRegistry).toHaveBeenCalled();
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith(
expect.not.objectContaining({
onlyPluginIds: expect.anything(),
expect.objectContaining({
onlyPluginIds: ["memory-core"],
}),
);
});
it("skips full plugin runtime loading when no metadata owns the requested primary", async () => {
const program = createProgram();
program.exitOverride();
await registerPluginCliCommands(program, {} as OpenClawConfig, undefined, undefined, {
mode: "lazy",
primary: "missing-command",
});
expect(mocks.loadOpenClawPluginCliRegistry).toHaveBeenCalled();
expect(mocks.loadOpenClawPlugins).not.toHaveBeenCalled();
expect(program.commands.map((command) => command.name())).not.toContain("missing-command");
});
it("returns null for validated plugin CLI config when the snapshot is invalid", async () => {
mocks.readConfigFileSnapshot.mockResolvedValueOnce({
valid: false,