refactor: render .list agents and .list skills as comfy-tables
Long agent/skill descriptions wrapped badly in the bullet-list format. Extract a shared asset_table helper (UTF8_FULL + dynamic arrangement, same style as the markdown renderer and .list macros) and use it for the agents, skills, and macros listings. The skills loaded marker keeps its color; comfy-table's custom_styling feature accounts for ANSI sequences in column widths.
This commit is contained in:
@@ -112,6 +112,14 @@ fn print_asset_names(kind: &str, names: &[String]) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn asset_table(header: &[&str]) -> Table {
|
||||||
|
let mut table = Table::new();
|
||||||
|
table.load_preset(UTF8_FULL);
|
||||||
|
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||||
|
table.set_header(header.to_vec());
|
||||||
|
table
|
||||||
|
}
|
||||||
|
|
||||||
fn complete_skills_with_descriptions(names: Vec<String>) -> Vec<(String, Option<String>)> {
|
fn complete_skills_with_descriptions(names: Vec<String>) -> Vec<(String, Option<String>)> {
|
||||||
names
|
names
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -2593,10 +2601,8 @@ impl RequestContext {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table =
|
||||||
table.load_preset(UTF8_FULL);
|
asset_table(&["name", "source", "isolated", "state", "description"]);
|
||||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
|
||||||
table.set_header(vec!["name", "source", "isolated", "state", "description"]);
|
|
||||||
|
|
||||||
for row in &policy.macros {
|
for row in &policy.macros {
|
||||||
let source = macro_source_display(row.source);
|
let source = macro_source_display(row.source);
|
||||||
@@ -2627,15 +2633,13 @@ impl RequestContext {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Agents:");
|
let mut table = asset_table(&["name", "description"]);
|
||||||
for (name, description) in entries {
|
for (name, description) in entries {
|
||||||
if description.is_empty() {
|
table.add_row(vec![name, description]);
|
||||||
println!(" • {name}");
|
|
||||||
} else {
|
|
||||||
println!(" • {name} — {description}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Agents:");
|
||||||
|
println!("{table}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
"skills" => {
|
"skills" => {
|
||||||
@@ -2681,16 +2685,18 @@ impl RequestContext {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Skills:");
|
let mut table = asset_table(&["loaded", "name", "description"]);
|
||||||
for (name, description, loaded) in entries {
|
for (name, description, loaded) in entries {
|
||||||
let marker = if loaded {
|
let marker = if loaded {
|
||||||
"✓".green().bold().to_string()
|
"✓".green().bold().to_string()
|
||||||
} else {
|
} else {
|
||||||
"✗".red().bold().to_string()
|
"✗".red().bold().to_string()
|
||||||
};
|
};
|
||||||
println!(" {marker} {name} — {description}");
|
table.add_row(vec![marker, name, description]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Skills:");
|
||||||
|
println!("{table}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
"tools" => {
|
"tools" => {
|
||||||
|
|||||||
Reference in New Issue
Block a user