1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Generic external-tool detection for the CLI's `healthcheck` command.
//!
//! Centralised here so the `Command::new(<tool>)` probe shell-outs live
//! inside the module-boundaries allow-list
//! (`.claude/rules/module-boundaries.md`). The CLI used to do these probes
//! inline; that put `Command::new` outside the allow-list and counted as a
//! boundary violation.
use io;
use Command;
/// Probe `<name> --version` and report whether the tool ran successfully.
///
/// `Ok(true)` — `<name> --version` ran and exited zero (tool available).
/// `Ok(false)` — `<name>` ran but exited non-zero (installed but failing
/// `--version`; rare, but possible for stub binaries or version-flag
/// mismatches).
/// `Err(_)` — `<name>` could not be spawned (typically `NotFound` —
/// the binary is not on `PATH`). Distinct from `Ok(false)` so callers
/// can log the underlying `io::Error` at trace level. stdout/stderr
/// are silenced so a missing tool doesn't pollute the log.
/// Run `<name> --version` and return the first stdout line trimmed.
///
/// `Ok(Some(line))` — tool ran, exited zero, returns the first stdout
/// line trimmed.
/// `Ok(None)` — tool ran but exited non-zero; no version string to
/// report.
/// `Err(_)` — tool could not be spawned. Distinct from `Ok(None)` so
/// callers can log why the probe itself failed at trace level rather
/// than collapsing every failure to "tool missing".