mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 14:04:46 +00:00
fix(cli): keep root help pluginless by default
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { renderRootHelpText } from "./root-help.js";
|
||||
|
||||
const getPluginCliCommandDescriptorsMock = vi.fn(
|
||||
@@ -53,6 +53,10 @@ vi.mock("../../plugins/cli.js", () => ({
|
||||
}));
|
||||
|
||||
describe("root help", () => {
|
||||
beforeEach(() => {
|
||||
getPluginCliCommandDescriptorsMock.mockClear();
|
||||
});
|
||||
|
||||
it("passes isolated config and env through to plugin CLI descriptor loading", async () => {
|
||||
const config = {
|
||||
agents: {
|
||||
@@ -71,11 +75,17 @@ describe("root help", () => {
|
||||
});
|
||||
|
||||
it("includes plugin CLI descriptors alongside core and sub-CLI commands", async () => {
|
||||
const text = await renderRootHelpText();
|
||||
const text = await renderRootHelpText({ includePluginDescriptors: true });
|
||||
|
||||
expect(text).toContain("status");
|
||||
expect(text).toContain("config");
|
||||
expect(text).toContain("matrix");
|
||||
expect(text).toContain("Matrix channel utilities");
|
||||
});
|
||||
|
||||
it("does not load plugin CLI descriptors by default", async () => {
|
||||
await renderRootHelpText();
|
||||
|
||||
expect(getPluginCliCommandDescriptorsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import { getSubCliEntries } from "./subcli-descriptors.js";
|
||||
export type RootHelpRenderOptions = Pick<PluginLoadOptions, "pluginSdkResolution"> & {
|
||||
config?: OpenClawConfig;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
includePluginDescriptors?: boolean;
|
||||
};
|
||||
|
||||
async function buildRootHelpProgram(renderOptions?: RootHelpRenderOptions): Promise<Command> {
|
||||
@@ -25,14 +26,19 @@ async function buildRootHelpProgram(renderOptions?: RootHelpRenderOptions): Prom
|
||||
agentChannelOptions: "",
|
||||
});
|
||||
|
||||
const pluginDescriptors =
|
||||
renderOptions?.includePluginDescriptors === true || renderOptions?.config
|
||||
? await getPluginCliCommandDescriptors(renderOptions.config, renderOptions.env, {
|
||||
pluginSdkResolution: renderOptions.pluginSdkResolution,
|
||||
})
|
||||
: [];
|
||||
|
||||
addCommandDescriptorsToProgram(
|
||||
program,
|
||||
collectUniqueCommandDescriptors([
|
||||
getCoreCliCommandDescriptors(),
|
||||
getSubCliEntries(),
|
||||
await getPluginCliCommandDescriptors(renderOptions?.config, renderOptions?.env, {
|
||||
pluginSdkResolution: renderOptions?.pluginSdkResolution,
|
||||
}),
|
||||
pluginDescriptors,
|
||||
]),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user