From 78dca71f3fbb2dffbd0f5a8d7151f2c19c4ad6f2 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 10 Apr 2026 01:31:21 +0900 Subject: [PATCH] fix(cli): JSON parity for /compact and /clear in resume mode /compact now emits: {kind:compact, skipped, removed_messages, kept_messages} /clear now emits: {kind:clear, previous_session_id, new_session_id, backup, session_file} /clear (no --confirm) now emits: {kind:error, error:..., hint:...} Previously both returned json:None and fell through to prose output even in --output-format json --resume mode. 159 CLI tests pass. --- rust/crates/rusty-claude-cli/src/main.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 3b875ee..524c603 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -2678,7 +2678,12 @@ fn run_resume_command( Ok(ResumeCommandOutcome { session: result.compacted_session, message: Some(format_compact_report(removed, kept, skipped)), - json: None, + json: Some(serde_json::json!({ + "kind": "compact", + "skipped": skipped, + "removed_messages": removed, + "kept_messages": kept, + })), }) } SlashCommand::Clear { confirm } => { @@ -2688,7 +2693,11 @@ fn run_resume_command( message: Some( "clear: confirmation required; rerun with /clear --confirm".to_string(), ), - json: None, + json: Some(serde_json::json!({ + "kind": "error", + "error": "confirmation required", + "hint": "rerun with /clear --confirm", + })), }); } let backup_path = write_session_clear_backup(session, session_path)?; @@ -2704,7 +2713,13 @@ fn run_resume_command( backup_path.display(), session_path.display() )), - json: None, + json: Some(serde_json::json!({ + "kind": "clear", + "previous_session_id": previous_session_id, + "new_session_id": new_session_id, + "backup": backup_path.display().to_string(), + "session_file": session_path.display().to_string(), + })), }) } SlashCommand::Status => {