mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-18 13:30:48 +00:00
CLI: reduce channels add startup memory (#46784)
* CLI: lazy-load channel subcommand handlers * Channels: defer add command dependencies * CLI: skip status JSON plugin preload * CLI: cover status JSON route preload * Status: trim JSON security audit path * Status: update JSON fast-path tests * CLI: cover root help fast path * CLI: fast-path root help * Status: keep JSON security parity * Status: restore JSON security tests * CLI: document status plugin preload * Channels: reuse Telegram account import
This commit is contained in:
@@ -235,6 +235,10 @@ function collectCoreCliCommandNames(predicate?: (command: CoreCliCommandDescript
|
||||
return names;
|
||||
}
|
||||
|
||||
export function getCoreCliCommandDescriptors(): ReadonlyArray<CoreCliCommandDescriptor> {
|
||||
return coreEntries.flatMap((entry) => entry.commands);
|
||||
}
|
||||
|
||||
export function getCoreCliCommandNames(): string[] {
|
||||
return collectCoreCliCommandNames();
|
||||
}
|
||||
|
||||
29
src/cli/program/root-help.ts
Normal file
29
src/cli/program/root-help.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Command } from "commander";
|
||||
import { VERSION } from "../../version.js";
|
||||
import { getCoreCliCommandDescriptors } from "./command-registry.js";
|
||||
import { configureProgramHelp } from "./help.js";
|
||||
import { getSubCliEntries } from "./register.subclis.js";
|
||||
|
||||
function buildRootHelpProgram(): Command {
|
||||
const program = new Command();
|
||||
configureProgramHelp(program, {
|
||||
programVersion: VERSION,
|
||||
channelOptions: [],
|
||||
messageChannelOptions: "",
|
||||
agentChannelOptions: "",
|
||||
});
|
||||
|
||||
for (const command of getCoreCliCommandDescriptors()) {
|
||||
program.command(command.name).description(command.description);
|
||||
}
|
||||
for (const command of getSubCliEntries()) {
|
||||
program.command(command.name).description(command.description);
|
||||
}
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
export function outputRootHelp(): void {
|
||||
const program = buildRootHelpProgram();
|
||||
program.outputHelp();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ describe("program routes", () => {
|
||||
await expect(route?.run(argv)).resolves.toBe(false);
|
||||
}
|
||||
|
||||
it("matches status route and always loads plugins for security parity", () => {
|
||||
it("matches status route and always preloads plugins", () => {
|
||||
const route = expectRoute(["status"]);
|
||||
expect(route?.loadPlugins).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user