From 7ec6860d9a0242df0a5b0868aaf7f9775c007972 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 9 Apr 2026 22:03:11 +0900 Subject: [PATCH] fix(cli): emit JSON for /config in --output-format json --resume mode /config resumed returned json:None, falling back to prose output even in --output-format json mode. Adds render_config_json() that produces: { "kind": "config", "cwd": "...", "loaded_files": N, "merged_keys": N, "files": [{"path":"...","source":"user|project|local","loaded":true|false}, ...] } Wires it into the SlashCommand::Config resume arm alongside the existing prose render. Continues the resumed-command JSON parity track (ROADMAP #26). 159 CLI tests pass, fmt clean. --- rust/crates/rusty-claude-cli/src/main.rs | 57 +++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index e9aad59..601999b 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -2747,11 +2747,15 @@ fn run_resume_command( json: None, }) } - SlashCommand::Config { section } => Ok(ResumeCommandOutcome { - session: session.clone(), - message: Some(render_config_report(section.as_deref())?), - json: None, - }), + SlashCommand::Config { section } => { + let message = render_config_report(section.as_deref())?; + let json = render_config_json(section.as_deref())?; + Ok(ResumeCommandOutcome { + session: session.clone(), + message: Some(message), + json: Some(json), + }) + } SlashCommand::Mcp { action, target } => { let cwd = env::current_dir()?; let args = match (action.as_deref(), target.as_deref()) { @@ -5335,6 +5339,49 @@ fn render_config_report(section: Option<&str>) -> Result, +) -> Result> { + let cwd = env::current_dir()?; + let loader = ConfigLoader::default_for(&cwd); + let discovered = loader.discover(); + let runtime_config = loader.load()?; + + let loaded_paths: Vec<_> = runtime_config + .loaded_entries() + .iter() + .map(|e| e.path.display().to_string()) + .collect(); + + let files: Vec<_> = discovered + .iter() + .map(|e| { + let source = match e.source { + ConfigSource::User => "user", + ConfigSource::Project => "project", + ConfigSource::Local => "local", + }; + let loaded = runtime_config + .loaded_entries() + .iter() + .any(|le| le.path == e.path); + serde_json::json!({ + "path": e.path.display().to_string(), + "source": source, + "loaded": loaded, + }) + }) + .collect(); + + Ok(serde_json::json!({ + "kind": "config", + "cwd": cwd.display().to_string(), + "loaded_files": loaded_paths.len(), + "merged_keys": runtime_config.merged().len(), + "files": files, + })) +} + fn render_memory_report() -> Result> { let cwd = env::current_dir()?; let project_context = ProjectContext::discover(&cwd, DEFAULT_DATE)?;