From 3ed27d5cba44a71a95a560ec462796e0717f4e35 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 9 Apr 2026 19:33:50 +0900 Subject: [PATCH] fix(cli): emit JSON for /history in --output-format json --resume mode Previously claw --output-format json --resume /history emitted prose text regardless of the output format flag. Now emits structured JSON: {"kind":"history","total":N,"showing":M,"entries":[{"timestamp_ms":...,"text":"..."},...]} Mirrors the parity pattern established in ROADMAP #26 for other resume commands. 159 CLI tests pass, fmt clean. --- rust/crates/rusty-claude-cli/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index e6a2ffd..9505735 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -2760,10 +2760,19 @@ fn run_resume_command( let limit = parse_history_count(count.as_deref()) .map_err(|error| -> Box { error.into() })?; let entries = collect_session_prompt_history(session); + let shown: Vec<_> = entries.iter().rev().take(limit).rev().collect(); Ok(ResumeCommandOutcome { session: session.clone(), message: Some(render_prompt_history_report(&entries, limit)), - json: None, + json: Some(serde_json::json!({ + "kind": "history", + "total": entries.len(), + "showing": shown.len(), + "entries": shown.iter().map(|e| serde_json::json!({ + "timestamp_ms": e.timestamp_ms, + "text": e.text, + })).collect::>(), + })), }) } SlashCommand::Unknown(name) => Err(format_unknown_slash_command(name).into()),