From 39c15ee70d04a1721ebafde327b3b95355653fac Mon Sep 17 00:00:00 2001 From: Altay Date: Thu, 26 Mar 2026 02:18:39 +0300 Subject: [PATCH] CLI: use raw JSON writer for config schema --- CHANGELOG.md | 1 + src/cli/config-cli.test.ts | 2 ++ src/cli/config-cli.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d701df9d9d47..bbbe1c3a6271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai - Plugins/runtime: expose `runHeartbeatOnce` in the plugin runtime `system` namespace so plugins can trigger a single heartbeat cycle with an explicit delivery target override (e.g. `heartbeat: { target: "last" }`). (#40299) Thanks @loveyana. - Agents/compaction: surface safeguard-specific cancel reasons and relabel benign manual `/compact` no-op cases as skipped instead of failed. (#51072) Thanks @afurm. - Agents/compaction: preserve the post-compaction AGENTS refresh on stale-usage preflight compaction for both immediate replies and queued followups. (#49479) Thanks @jared596. +- CLI: add `openclaw config schema` to print the generated JSON schema for `openclaw.json`. (#54523) Thanks @kvokka. ### Fixes diff --git a/src/cli/config-cli.test.ts b/src/cli/config-cli.test.ts index 22157d1e9017..667310eb4115 100644 --- a/src/cli/config-cli.test.ts +++ b/src/cli/config-cli.test.ts @@ -453,6 +453,7 @@ describe("config cli", () => { expect(mockExit).not.toHaveBeenCalled(); expect(mockError).not.toHaveBeenCalled(); + expect(defaultRuntime.writeJson).toHaveBeenCalledTimes(1); const raw = mockLog.mock.calls.at(-1)?.[0]; expect(typeof raw).toBe("string"); const payload = JSON.parse(String(raw)) as { @@ -503,6 +504,7 @@ describe("config cli", () => { await runConfigCommand(["config", "schema"]); + expect(defaultRuntime.writeJson).toHaveBeenCalledTimes(1); const payload = JSON.parse(String(mockLog.mock.calls.at(-1)?.[0])) as { properties?: Record; }; diff --git a/src/cli/config-cli.ts b/src/cli/config-cli.ts index f7f8da8271e0..658e988ea5eb 100644 --- a/src/cli/config-cli.ts +++ b/src/cli/config-cli.ts @@ -1213,7 +1213,7 @@ async function buildCliConfigSchema(): Promise> { export async function runConfigSchema(opts: { runtime?: RuntimeEnv } = {}) { const runtime = opts.runtime ?? defaultRuntime; try { - runtime.log(JSON.stringify(await buildCliConfigSchema(), null, 2)); + writeRuntimeJson(runtime, await buildCliConfigSchema()); } catch (err) { runtime.error(danger(`Config schema error: ${String(err)}`)); runtime.exit(1);