fix(cli): improve config startup progress

This commit is contained in:
Peter Steinberger
2026-05-17 00:37:03 +01:00
parent c528f36507
commit 12debcb05e
10 changed files with 224 additions and 34 deletions

View File

@@ -168,6 +168,7 @@ describe("registerPreActionHooks", () => {
.option("--json")
.action(() => {});
const config = program.command("config");
config.option("--section <section>");
setCommandJsonMode(config.command("set"), "parse-only")
.argument("<path>")
.argument("<value>")
@@ -313,6 +314,26 @@ describe("registerPreActionHooks", () => {
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
});
it("lets bare config own config validation and plugin loading", async () => {
await runPreAction({
parseArgv: ["config"],
processArgv: ["node", "openclaw", "config"],
});
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
});
it("lets guided config sections own config validation and plugin loading", async () => {
await runPreAction({
parseArgv: ["config"],
processArgv: ["node", "openclaw", "config", "--section", "models"],
});
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
});
it("only allows invalid config for explicit official recovery reinstall requests", async () => {
await runPreAction({
parseArgv: ["plugins", "install", "@openclaw/discord"],

View File

@@ -75,6 +75,10 @@ function isBareParentDefaultHelpInvocation(actionCommand: Command, argv: string[
return primary === actionCommand.name() || actionCommand.aliases().includes(primary);
}
function isGuidedConfigAction(actionCommand: Command): boolean {
return actionCommand.name() === "config" && actionCommand.parent?.parent === undefined;
}
export function registerPreActionHooks(program: Command, programVersion: string) {
program.hook("preAction", async (_thisCommand, actionCommand) => {
setProcessTitleForCommand(actionCommand);
@@ -101,7 +105,7 @@ export function registerPreActionHooks(program: Command, programVersion: string)
if (!verbose) {
process.env.NODE_NO_WARNINGS ??= "1";
}
if (shouldBypassConfigGuardForCommandPath(commandPath)) {
if (shouldBypassConfigGuardForCommandPath(commandPath) || isGuidedConfigAction(actionCommand)) {
return;
}
await ensureCliExecutionBootstrap({