fix: block invalid config startup

Co-authored-by: Muhammed Mukhthar CM <mukhtharcm@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-17 10:25:24 +00:00
parent ad360b4d18
commit f8e673cdbc
7 changed files with 164 additions and 17 deletions

View File

@@ -61,6 +61,15 @@ export function registerPreActionHooks(program: Command, programVersion: string)
program.hook("preAction", async (_thisCommand, actionCommand) => {
if (actionCommand.name() === "doctor") return;
const snapshot = await readConfigFileSnapshot();
if (snapshot.exists && !snapshot.valid) {
defaultRuntime.error(`Config invalid at ${snapshot.path}.`);
for (const issue of snapshot.issues) {
defaultRuntime.error(`- ${issue.path || "<root>"}: ${issue.message}`);
}
defaultRuntime.error("Run `clawdbot doctor` to repair, then retry.");
process.exit(1);
}
const cfg = loadConfig();
await autoMigrateLegacyState({ cfg });
});