Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

fix(cli): claw state exits 1 when no worker state file exists

YeonGyu-Kim54269da157d4
diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs
index 4015dd0c..5f04c7b7 100644
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@ -1427,16 +1427,16 @@ fn run_worker_state(output_format: CliOutputFormat) -> Result<(), Box<dyn std::e
let cwd = env::current_dir()?;
let state_path = cwd.join(".claw").join("worker-state.json");
if !state_path.exists() {
- match output_format {
- CliOutputFormat::Text => {
- println!("No worker state file found at {}", state_path.display())
- }
- CliOutputFormat::Json => println!(
- "{}",
- serde_json::json!({"error": "no_state_file", "path": state_path.display().to_string()})
- ),
- }
- return Ok(());
+ // Emit a structured error, then return Err so the process exits 1.
+ // Callers (scripts, CI) need a non-zero exit to detect "no state" without
+ // parsing prose output.
+ // Let the error propagate to main() which will format it correctly
+ // (prose for text mode, JSON envelope for --output-format json).
+ return Err(format!(
+ "no worker state file found at {} — run a worker first",
+ state_path.display()
+ )
+ .into());
}
let raw = std::fs::read_to_string(&state_path)?;
match output_format {