feat(cli): add json schema to cli tool (#54523)

Merged via squash.

Prepared head SHA: 39c15ee70d
Co-authored-by: kvokka <15954013+kvokka@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
Mikhail Beliakov
2026-03-26 06:30:32 +07:00
committed by GitHub
parent ab37d8810d
commit fd934a566b
18 changed files with 674 additions and 76 deletions

View File

@@ -178,6 +178,7 @@ describe("registerPreActionHooks", () => {
.command("validate")
.option("--json")
.action(() => {});
config.command("schema").action(() => {});
registerPreActionHooks(program, "9.9.9-test");
return program;
}
@@ -422,6 +423,15 @@ describe("registerPreActionHooks", () => {
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
});
it("bypasses config guard for config schema", async () => {
await runPreAction({
parseArgv: ["config", "schema"],
processArgv: ["node", "openclaw", "config", "schema"],
});
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
});
it("bypasses config guard for backup create", async () => {
await runPreAction({
parseArgv: ["backup", "create"],

View File

@@ -49,9 +49,7 @@ function shouldBypassConfigGuard(commandPath: string[]): boolean {
if (CONFIG_GUARD_BYPASS_COMMANDS.has(primary)) {
return true;
}
// config validate is the explicit validation command; let it render
// validation failures directly without preflight guard output duplication.
if (primary === "config" && secondary === "validate") {
if (primary === "config" && (secondary === "validate" || secondary === "schema")) {
return true;
}
return false;