feat(worker): add Claude CLI preflight on startup

Worker now runs `claude --version` before listening; on non-zero exit
it logs critical and exits with code 1. Skippable via env var
CLAUDEDO_SKIP_CLI_PREFLIGHT=1 for environments without the CLI (tests,
dev). Closes verification step 2 / open.md item 3.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-04-30 14:17:44 +02:00
parent 4c92da55ad
commit df66c4af46
3 changed files with 83 additions and 0 deletions

View File

@@ -141,6 +141,22 @@ app.UseMiddleware<PlanningTokenAuthMiddleware>();
app.MapHub<WorkerHub>("/hub");
app.MapMcp("/mcp");
// Claude CLI preflight: fail fast if the configured binary is unreachable or non-zero.
// Skippable via CLAUDEDO_SKIP_CLI_PREFLIGHT=1 for environments without the CLI (e.g. tests).
if (Environment.GetEnvironmentVariable("CLAUDEDO_SKIP_CLI_PREFLIGHT") != "1")
{
var preflight = await ClaudeCliPreflight.CheckAsync(cfg.ClaudeBin);
if (!preflight.Ok)
{
app.Logger.LogCritical(
"Claude CLI preflight failed (bin: '{Bin}', exit: {Exit}): {Error}. " +
"Fix `claude_bin` in worker.config.json or set CLAUDEDO_SKIP_CLI_PREFLIGHT=1 to bypass.",
cfg.ClaudeBin, preflight.ExitCode, preflight.Error);
Environment.Exit(1);
}
app.Logger.LogInformation("Claude CLI preflight OK: {Version}", preflight.Version);
}
app.Logger.LogInformation("ClaudeDo.Worker listening on http://127.0.0.1:{Port} (db: {Db})",
cfg.SignalRPort, cfg.DbPath);