Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

fix(resume): emit structured JSON for /agents --output-format json (#2987)

YeonGyu-Kim1206f4131d79
diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs
index 61ea906b..1b4acf8f 100644
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@ -3526,10 +3526,10 @@ fn run_resume_command(
Ok(ResumeCommandOutcome {
session: session.clone(),
message: Some(handle_agents_slash_command(args.as_deref(), &cwd)?),
- json: Some(serde_json::json!({
- "kind": "agents",
- "text": handle_agents_slash_command(args.as_deref(), &cwd)?,
- })),
+ json: Some(
+ serde_json::to_value(handle_agents_slash_command_json(args.as_deref(), &cwd)?)
+ .unwrap_or_else(|_| serde_json::json!(null)),
+ ),
})
}
SlashCommand::Skills { args } => {
diff --git a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs
index e5ac08e8..5aaafab2 100644
--- a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs
+++ b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs
@@ -369,6 +369,34 @@ fn resumed_inventory_commands_emit_structured_json_when_requested() {
assert_eq!(skills["action"], "list");
assert!(skills["summary"]["total"].is_number());
assert!(skills["skills"].is_array());
+
+ let agents = assert_json_command_with_env(
+ &root,
+ &[
+ "--output-format",
+ "json",
+ "--resume",
+ session_path.to_str().expect("utf8 session path"),
+ "/agents",
+ ],
+ &[
+ (
+ "CLAW_CONFIG_HOME",
+ config_home.to_str().expect("utf8 config home"),
+ ),
+ ("HOME", home.to_str().expect("utf8 home")),
+ ],
+ );
+ assert_eq!(agents["kind"], "agents");
+ assert_eq!(agents["action"], "list");
+ assert!(
+ agents["agents"].is_array(),
+ "agents field must be a JSON array"
+ );
+ assert!(
+ agents["count"].is_number(),
+ "count must be a number, not a text render"
+ );
}
#[test]