fix(cli): emit JSON for --resume with no command in --output-format json mode

claw --output-format json --resume <session> (no command) was printing:
  'Restored session from <path> (N messages).'
to stdout as prose, regardless of output format.

Now emits:
  {"kind":"restored","session_id":"...","path":"...","message_count":N}

159 CLI tests pass.
This commit is contained in:
YeonGyu-Kim 2026-04-10 06:31:16 +09:00
parent 8dcf10361f
commit 4f670e5513

View File

@ -2256,11 +2256,23 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
};
if commands.is_empty() {
println!(
"Restored session from {} ({} messages).",
resolved_path.display(),
session.messages.len()
);
if output_format == CliOutputFormat::Json {
println!(
"{}",
serde_json::json!({
"kind": "restored",
"session_id": session.session_id,
"path": resolved_path.display().to_string(),
"message_count": session.messages.len(),
})
);
} else {
println!(
"Restored session from {} ({} messages).",
resolved_path.display(),
session.messages.len()
);
}
return;
}