mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-11 02:24:49 +08:00
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.
This commit is contained in:
@@ -2678,7 +2678,12 @@ fn run_resume_command(
|
|||||||
Ok(ResumeCommandOutcome {
|
Ok(ResumeCommandOutcome {
|
||||||
session: result.compacted_session,
|
session: result.compacted_session,
|
||||||
message: Some(format_compact_report(removed, kept, skipped)),
|
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 } => {
|
SlashCommand::Clear { confirm } => {
|
||||||
@@ -2688,7 +2693,11 @@ fn run_resume_command(
|
|||||||
message: Some(
|
message: Some(
|
||||||
"clear: confirmation required; rerun with /clear --confirm".to_string(),
|
"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)?;
|
let backup_path = write_session_clear_backup(session, session_path)?;
|
||||||
@@ -2704,7 +2713,13 @@ fn run_resume_command(
|
|||||||
backup_path.display(),
|
backup_path.display(),
|
||||||
session_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 => {
|
SlashCommand::Status => {
|
||||||
|
|||||||
Reference in New Issue
Block a user