Skip to main content

claude_code_cli_acp/
doctor.rs

1use crate::compat::{claude_probe::ClaudeCli, docs_probe};
2
3pub async fn run(live_docs: bool) -> anyhow::Result<()> {
4    let mut output = String::new();
5    let cli = ClaudeCli::from_env();
6    let report = cli.capability_report().await;
7    push_line(
8        &mut output,
9        format!("Claude executable: {}", cli.executable().display()),
10    );
11    match &report.version {
12        Ok(version) => push_line(&mut output, format!("Claude version: {version}")),
13        Err(err) => push_line(&mut output, format!("Claude version: unavailable ({err})")),
14    }
15    push_line(&mut output, "Required flags:");
16    for flag in &report.required_flags {
17        push_line(
18            &mut output,
19            format!(
20                "  {}: {}",
21                flag.name,
22                if flag.present {
23                    "local-help"
24                } else {
25                    "missing-from-local-help"
26                }
27            ),
28        );
29    }
30    if let Err(err) = &report.local_help {
31        push_line(&mut output, format!("Claude help: unavailable ({err})"));
32    }
33    push_line(
34        &mut output,
35        "Transcript path: ~/.claude/projects/<project>/<session>.jsonl",
36    );
37    push_line(&mut output, "Transcript logging: redacted by default");
38    push_line(&mut output, "ACP readiness: stdio server available");
39    push_line(&mut output, "PTY readiness: portable-pty configured");
40
41    if live_docs {
42        match docs_probe::probe_live().await {
43            Ok(live) => push_line(&mut output, format!("Upstream: {}", live.summary())),
44            Err(err) => push_line(&mut output, format!("Upstream: unavailable ({err})")),
45        }
46    }
47
48    use std::io::Write;
49    std::io::stderr().write_all(output.as_bytes())?;
50    Ok(())
51}
52
53fn push_line(output: &mut String, line: impl std::fmt::Display) {
54    use std::fmt::Write;
55    let _ = writeln!(output, "{line}");
56}