mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-11 02:24:49 +08:00
fix(cli): emit JSON for /history in --output-format json --resume mode
Previously claw --output-format json --resume <session> /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.
This commit is contained in:
@@ -2760,10 +2760,19 @@ fn run_resume_command(
|
|||||||
let limit = parse_history_count(count.as_deref())
|
let limit = parse_history_count(count.as_deref())
|
||||||
.map_err(|error| -> Box<dyn std::error::Error> { error.into() })?;
|
.map_err(|error| -> Box<dyn std::error::Error> { error.into() })?;
|
||||||
let entries = collect_session_prompt_history(session);
|
let entries = collect_session_prompt_history(session);
|
||||||
|
let shown: Vec<_> = entries.iter().rev().take(limit).rev().collect();
|
||||||
Ok(ResumeCommandOutcome {
|
Ok(ResumeCommandOutcome {
|
||||||
session: session.clone(),
|
session: session.clone(),
|
||||||
message: Some(render_prompt_history_report(&entries, limit)),
|
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::<Vec<_>>(),
|
||||||
|
})),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
SlashCommand::Unknown(name) => Err(format_unknown_slash_command(name).into()),
|
SlashCommand::Unknown(name) => Err(format_unknown_slash_command(name).into()),
|
||||||
|
|||||||
Reference in New Issue
Block a user