CLI: restore lightweight root help and scoped status plugin preload

This commit is contained in:
Vincent Koc
2026-03-15 17:37:36 -07:00
parent c455cccd3d
commit f87e7be55e
7 changed files with 127 additions and 38 deletions

View File

@@ -149,7 +149,7 @@ describe("registerPreActionHooks", () => {
runtime: runtimeMock,
commandPath: ["status"],
});
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1);
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "channels" });
expect(process.title).toBe("openclaw-status");
vi.clearAllMocks();
@@ -164,7 +164,7 @@ describe("registerPreActionHooks", () => {
runtime: runtimeMock,
commandPath: ["message", "send"],
});
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledTimes(1);
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "all" });
});
it("skips help/version preaction and respects banner opt-out", async () => {

View File

@@ -67,6 +67,10 @@ function loadPluginRegistryModule() {
return pluginRegistryModulePromise;
}
function resolvePluginRegistryScope(commandPath: string[]): "channels" | "all" {
return commandPath[0] === "status" || commandPath[0] === "health" ? "channels" : "all";
}
function getRootCommand(command: Command): Command {
let current = command;
while (current.parent) {
@@ -136,7 +140,7 @@ export function registerPreActionHooks(program: Command, programVersion: string)
// Load plugins for commands that need channel access
if (PLUGIN_REQUIRED_COMMANDS.has(commandPath[0])) {
const { ensurePluginRegistryLoaded } = await loadPluginRegistryModule();
ensurePluginRegistryLoaded();
ensurePluginRegistryLoaded({ scope: resolvePluginRegistryScope(commandPath) });
}
});
}