Skip to content

Commit 78dca71

Browse files
committed
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.
1 parent 39a7dd0 commit 78dca71

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

  • rust/crates/rusty-claude-cli/src

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,7 +2678,12 @@ fn run_resume_command(
26782678
Ok(ResumeCommandOutcome {
26792679
session: result.compacted_session,
26802680
message: Some(format_compact_report(removed, kept, skipped)),
2681-
json: None,
2681+
json: Some(serde_json::json!({
2682+
"kind": "compact",
2683+
"skipped": skipped,
2684+
"removed_messages": removed,
2685+
"kept_messages": kept,
2686+
})),
26822687
})
26832688
}
26842689
SlashCommand::Clear { confirm } => {
@@ -2688,7 +2693,11 @@ fn run_resume_command(
26882693
message: Some(
26892694
"clear: confirmation required; rerun with /clear --confirm".to_string(),
26902695
),
2691-
json: None,
2696+
json: Some(serde_json::json!({
2697+
"kind": "error",
2698+
"error": "confirmation required",
2699+
"hint": "rerun with /clear --confirm",
2700+
})),
26922701
});
26932702
}
26942703
let backup_path = write_session_clear_backup(session, session_path)?;
@@ -2704,7 +2713,13 @@ fn run_resume_command(
27042713
backup_path.display(),
27052714
session_path.display()
27062715
)),
2707-
json: None,
2716+
json: Some(serde_json::json!({
2717+
"kind": "clear",
2718+
"previous_session_id": previous_session_id,
2719+
"new_session_id": new_session_id,
2720+
"backup": backup_path.display().to_string(),
2721+
"session_file": session_path.display().to_string(),
2722+
})),
27082723
})
27092724
}
27102725
SlashCommand::Status => {

0 commit comments

Comments
 (0)