fix(cli): improve guardrail messages

This commit is contained in:
Vincent Koc
2026-05-09 07:48:48 +08:00
parent ebd59f1e01
commit 3500a0bffa
4 changed files with 18 additions and 7 deletions

View File

@@ -128,8 +128,9 @@ describe("ensureConfigReady", () => {
setInvalidSnapshot();
const runtime = await runEnsureConfigReady(["message"]);
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("Config invalid"));
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("config is invalid"));
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("doctor --fix"));
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("config validate"));
expect(runtime.exit).toHaveBeenCalledWith(1);
});

View File

@@ -112,7 +112,7 @@ export async function ensureConfigReady(params: {
const heading = (value: string) => colorize(rich, theme.heading, value);
const commandText = (value: string) => colorize(rich, theme.command, value);
params.runtime.error(heading("Config invalid"));
params.runtime.error(heading("OpenClaw config is invalid"));
params.runtime.error(`${muted("File:")} ${muted(shortenHomePath(snapshot.path))}`);
if (issues.length > 0) {
params.runtime.error(muted("Problem:"));
@@ -124,7 +124,13 @@ export async function ensureConfigReady(params: {
}
params.runtime.error("");
params.runtime.error(
`${muted("Run:")} ${commandText(formatCliCommand("openclaw doctor --fix"))}`,
`${muted("Fix:")} ${commandText(formatCliCommand("openclaw doctor --fix"))}`,
);
params.runtime.error(
`${muted("Inspect:")} ${commandText(formatCliCommand("openclaw config validate"))}`,
);
params.runtime.error(
muted("Status, health, logs, and doctor commands still run with invalid config."),
);
if (!allowInvalid) {
params.runtime.exit(1);