Skip to content

Commit 7587f2c

Browse files
committed
fix(cli): JSON parity for /memory and /providers in resume mode
Two gaps closed: 1. /memory (resume): json field was None, emitting prose regardless of --output-format json. Now emits: {kind:memory, cwd, instruction_files:N, files:[{path,lines,preview}...]} 2. /providers (resume): had a spec entry but no parse arm, producing the circular 'Unknown slash command: /providers — Did you mean /providers'. Added 'providers' as an alias for 'doctor' in the parse match so /providers dispatches to the same structured diagnostic output. 3. /doctor (resume): also wired json_value() so --output-format json returns the structured doctor report instead of None. Continues ROADMAP #26 resumed-command JSON parity track. 159 CLI tests pass, fmt clean.
1 parent ed42f8f commit 7587f2c

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

rust/crates/commands/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ pub fn validate_slash_command_input(
13201320
"skills" | "skill" => SlashCommand::Skills {
13211321
args: parse_skills_args(remainder.as_deref())?,
13221322
},
1323-
"doctor" => {
1323+
"doctor" | "providers" => {
13241324
validate_no_args(command, &args)?;
13251325
SlashCommand::Doctor
13261326
}

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,7 @@ fn run_resume_command(
27732773
SlashCommand::Memory => Ok(ResumeCommandOutcome {
27742774
session: session.clone(),
27752775
message: Some(render_memory_report()?),
2776-
json: None,
2776+
json: Some(render_memory_json()?),
27772777
}),
27782778
SlashCommand::Init => {
27792779
let message = init_claude_md()?;
@@ -2829,11 +2829,14 @@ fn run_resume_command(
28292829
json: Some(handle_skills_slash_command_json(args.as_deref(), &cwd)?),
28302830
})
28312831
}
2832-
SlashCommand::Doctor => Ok(ResumeCommandOutcome {
2833-
session: session.clone(),
2834-
message: Some(render_doctor_report()?.render()),
2835-
json: None,
2836-
}),
2832+
SlashCommand::Doctor => {
2833+
let report = render_doctor_report()?;
2834+
Ok(ResumeCommandOutcome {
2835+
session: session.clone(),
2836+
message: Some(report.render()),
2837+
json: Some(report.json_value()),
2838+
})
2839+
}
28372840
SlashCommand::Stats => {
28382841
let usage = UsageTracker::from_session(session).cumulative_usage();
28392842
Ok(ResumeCommandOutcome {
@@ -5421,6 +5424,28 @@ fn render_memory_report() -> Result<String, Box<dyn std::error::Error>> {
54215424
))
54225425
}
54235426

5427+
fn render_memory_json() -> Result<serde_json::Value, Box<dyn std::error::Error>> {
5428+
let cwd = env::current_dir()?;
5429+
let project_context = ProjectContext::discover(&cwd, DEFAULT_DATE)?;
5430+
let files: Vec<_> = project_context
5431+
.instruction_files
5432+
.iter()
5433+
.map(|f| {
5434+
json!({
5435+
"path": f.path.display().to_string(),
5436+
"lines": f.content.lines().count(),
5437+
"preview": f.content.lines().next().unwrap_or("").trim(),
5438+
})
5439+
})
5440+
.collect();
5441+
Ok(json!({
5442+
"kind": "memory",
5443+
"cwd": cwd.display().to_string(),
5444+
"instruction_files": files.len(),
5445+
"files": files,
5446+
}))
5447+
}
5448+
54245449
fn init_claude_md() -> Result<String, Box<dyn std::error::Error>> {
54255450
let cwd = env::current_dir()?;
54265451
Ok(initialize_repo(&cwd)?.render())

0 commit comments

Comments
 (0)