fix: add structured command list to top-level help JSON (#325)

Top-level 'claw --output-format json help' now includes a 'commands'
array with name, summary, and resume_supported for each registered
slash command, plus 'total_commands' count.

Generated with https://github.com/Yeachan-Heo/gajae-code
Co-authored-by: Gajae Code <dev@gajae-code.com>
This commit is contained in:
bellman
2026-06-05 06:57:51 +09:00
parent f1a16398fe
commit 2f3120e70a
2 changed files with 25 additions and 10 deletions

View File

@@ -13930,15 +13930,30 @@ fn print_help(output_format: CliOutputFormat) -> Result<(), Box<dyn std::error::
let message = String::from_utf8(buffer)?;
match output_format {
CliOutputFormat::Text => print!("{message}"),
CliOutputFormat::Json => println!(
"{}",
serde_json::to_string_pretty(&json!({
"kind": "help",
"action": "help",
"status": "ok",
"message": message,
}))?
),
CliOutputFormat::Json => {
// #325: include structured command list in top-level help JSON
let commands: Vec<serde_json::Value> = commands::slash_command_specs()
.iter()
.map(|spec| {
serde_json::json!({
"name": spec.name,
"summary": spec.summary,
"resume_supported": spec.resume_supported,
})
})
.collect();
println!(
"{}",
serde_json::to_string_pretty(&json!({
"kind": "help",
"action": "help",
"status": "ok",
"message": message,
"commands": commands,
"total_commands": commands.len(),
}))?
);
}
}
Ok(())
}