feat(headless): enrich context output with decision summary and agent IDs
This commit is contained in:
@@ -1055,8 +1055,20 @@ pub fn context() {
|
||||
.and_then(|d| d["cycle"].as_u64())
|
||||
.unwrap_or(0);
|
||||
|
||||
// Session with last decision summary
|
||||
let last_decision_line = std::fs::read_to_string(&dec_path).ok()
|
||||
.and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())
|
||||
.and_then(|d| d["decision"].as_str().map(|t| {
|
||||
t.lines().filter(|l| !l.starts_with('#') && !l.is_empty()).next()
|
||||
.unwrap_or("").to_string()
|
||||
}))
|
||||
.unwrap_or_default();
|
||||
|
||||
println!("[session]");
|
||||
println!("sessions: {session_count} last_cycle: {cycle}");
|
||||
if !last_decision_line.is_empty() {
|
||||
println!("last: {last_decision_line}");
|
||||
}
|
||||
|
||||
println!("\n[git]");
|
||||
println!("branch: {branch}");
|
||||
@@ -1089,10 +1101,21 @@ pub fn context() {
|
||||
println!("(none)");
|
||||
} else {
|
||||
for a in &agents {
|
||||
let id = a["id"].as_u64().unwrap_or(0);
|
||||
let name = a["name"].as_str().unwrap_or("?");
|
||||
let c = a["conclusion"].as_str().unwrap_or("?");
|
||||
let summary = a["summary"].as_str().unwrap_or("");
|
||||
println!(" {name} [{c}] {summary}");
|
||||
let icon = match c { "success" => "✓", "error" | "stopped" => "✗", _ => "●" };
|
||||
println!(" {icon} {name} [{c}]");
|
||||
// Show first 2 meaningful lines from detail file
|
||||
if let Ok(detail) = std::fs::read_to_string(format!("{STATE_DIR}/{id}.json")) {
|
||||
if let Ok(d) = serde_json::from_str::<serde_json::Value>(&detail) {
|
||||
let result = d["result"].as_str().unwrap_or("");
|
||||
for line in result.lines().filter(|l| !l.is_empty()).take(2) {
|
||||
let short: String = line.chars().take(70).collect();
|
||||
println!(" {short}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1127,7 +1150,7 @@ pub fn context() {
|
||||
if let Ok(entries) = serde_json::from_str::<Vec<serde_json::Value>>(&content) {
|
||||
if !entries.is_empty() {
|
||||
println!("\n[commands]");
|
||||
for e in entries.iter().rev().take(10) {
|
||||
for e in entries.iter().rev().take(3) {
|
||||
let tool = e["tool"].as_str().unwrap_or("?");
|
||||
let cmd = e["command"].as_str().unwrap_or("");
|
||||
let ok = if e["ok"].as_bool() == Some(true) { "✓" } else { "✗" };
|
||||
|
||||
Reference in New Issue
Block a user