Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/doctor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ tokio = { version = "1.0", features = ["rt", "macros"] }
futures = "0.3"
reqwest = { version = "0.13", features = ["blocking", "json"] }
dirs = "6"
wait-timeout = "0.2"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.31", features = ["signal"] }
27 changes: 25 additions & 2 deletions crates/doctor/src/agents.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! AI agent checks and fix command lookup.

use std::path::{Path, PathBuf};
use std::process::Command;

use crate::checks::CLONEFILE_FIX_COMMAND;
use crate::command::{
run_command_with_timeout, CommandError, CommandTimeout, DEFAULT_PROBE_TIMEOUT,
};
use crate::resolve::format_command_output;
use crate::timeout_check::{command_timeout_check, TimeoutCheck};
use crate::types::{
AgentVersionInfo, AuthStatus, CheckStatus, DoctorCheck, FixType, InstallSource, ResolvedBinary,
};
Expand Down Expand Up @@ -303,7 +306,9 @@ pub fn check_single_ai_agent(

if let Some(ref path_str) = resolved_path {
if info.id == "ai-agent-goose" {
match Command::new(path_str).arg("acp").arg("--help").output() {
let mut command = std::process::Command::new(path_str);
command.arg("acp").arg("--help");
match run_command_with_timeout(command, "goose acp --help", DEFAULT_PROBE_TIMEOUT) {
Ok(output) if output.status.success() => {
let raw = format!(
"{header}\n{}\n{}",
Expand Down Expand Up @@ -363,6 +368,20 @@ pub fn check_single_ai_agent(
bridge: None,
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(
info.id,
info.label,
CheckStatus::Fail,
&header,
command,
timeout,
)
.path(resolved_path)
.install_source(bridge_install_source.clone())
.main(version_readout(bridge_install_source.clone()))
.raw_suffix(Some(&search)),
),
Err(e) => DoctorCheck {
id: info.id.to_string(),
label: info.label.to_string(),
Expand Down Expand Up @@ -431,6 +450,10 @@ pub fn check_single_ai_agent(
Some(AuthStatus::Unknown),
Some(format!("$ {cmd}\n(spawn failure: {e})")),
),
ExecOutcome::Timeout { command, timeout } => {
let timeout = CommandTimeout::new(info.label, command, timeout);
(Some(AuthStatus::Unknown), Some(timeout.raw_output()))
}
// Exit 127 means the shell couldn't find the command —
// PATH-shadowed or uninstalled. Not the same as "signed
// out"; report Unknown so the UI doesn't offer a useless
Expand Down
59 changes: 51 additions & 8 deletions crates/doctor/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

use std::process::Command;

use crate::command::{run_command_with_timeout, CommandError, DEFAULT_PROBE_TIMEOUT};
use crate::resolve::format_command_output;
use crate::timeout_check::{command_timeout_check, TimeoutCheck};
use crate::types::{CheckStatus, DoctorCheck, FixType, ResolvedBinary};

/// Fix command for enabling copy-on-write git clones.
Expand Down Expand Up @@ -42,7 +44,9 @@ pub fn check_git(resolved: &ResolvedBinary) -> DoctorCheck {
};
let path_str = git_path.to_string_lossy().to_string();

match Command::new(git_path).arg("--version").output() {
let mut command = Command::new(git_path);
command.arg("--version");
match run_command_with_timeout(command, "git --version", DEFAULT_PROBE_TIMEOUT) {
Ok(output) if output.status.success() => {
let version = String::from_utf8_lossy(&output.stdout).trim().to_string();
let raw = format!(
Expand Down Expand Up @@ -98,6 +102,12 @@ pub fn check_git(resolved: &ResolvedBinary) -> DoctorCheck {
bridge: None,
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(id, label, CheckStatus::Fail, header, command, timeout)
.path(Some(path_str))
.install_source(resolved.install_source.clone())
.raw_suffix(Some(search)),
),
Err(e) => DoctorCheck {
id,
label,
Expand Down Expand Up @@ -155,7 +165,9 @@ pub fn check_gh(resolved: &ResolvedBinary) -> DoctorCheck {
};
let path_str = gh_path.to_string_lossy().to_string();

match Command::new(gh_path).arg("--version").output() {
let mut command = Command::new(gh_path);
command.arg("--version");
match run_command_with_timeout(command, "gh --version", DEFAULT_PROBE_TIMEOUT) {
Ok(output) if output.status.success() => {
let version = String::from_utf8_lossy(&output.stdout);
let first_line = version.lines().next().unwrap_or("gh").trim().to_string();
Expand Down Expand Up @@ -212,6 +224,12 @@ pub fn check_gh(resolved: &ResolvedBinary) -> DoctorCheck {
bridge: None,
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(id, label, CheckStatus::Fail, header, command, timeout)
.path(Some(path_str))
.install_source(resolved.install_source.clone())
.raw_suffix(Some(search)),
),
Err(e) => DoctorCheck {
id,
label,
Expand Down Expand Up @@ -267,7 +285,9 @@ pub fn check_gh_auth(gh: &ResolvedBinary) -> DoctorCheck {
}
};

match Command::new(gh_path).args(["auth", "status"]).output() {
let mut command = Command::new(gh_path);
command.args(["auth", "status"]);
match run_command_with_timeout(command, "gh auth status", DEFAULT_PROBE_TIMEOUT) {
Ok(output) => {
let raw = format!(
"{header}\n{}",
Expand Down Expand Up @@ -324,6 +344,9 @@ pub fn check_gh_auth(gh: &ResolvedBinary) -> DoctorCheck {
}
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(id, label, CheckStatus::Fail, header, command, timeout),
),
Err(e) => DoctorCheck {
id,
label,
Expand Down Expand Up @@ -383,7 +406,9 @@ pub fn check_git_lfs(git: &ResolvedBinary, git_lfs: &ResolvedBinary) -> DoctorCh
}
};

match Command::new(git_path).args(["lfs", "version"]).output() {
let mut command = Command::new(git_path);
command.args(["lfs", "version"]);
match run_command_with_timeout(command, "git lfs version", DEFAULT_PROBE_TIMEOUT) {
Ok(output) if output.status.success() => {
let version = String::from_utf8_lossy(&output.stdout).trim().to_string();
let path = git_lfs
Expand Down Expand Up @@ -443,6 +468,17 @@ pub fn check_git_lfs(git: &ResolvedBinary, git_lfs: &ResolvedBinary) -> DoctorCh
bridge: None,
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(id, label, CheckStatus::Warn, header, command, timeout)
.path(
git_lfs
.path
.as_ref()
.map(|p| p.to_string_lossy().to_string()),
)
.install_source(git_lfs.install_source.clone())
.raw_suffix(Some(search)),
),
Err(e) => DoctorCheck {
id,
label,
Expand Down Expand Up @@ -499,10 +535,13 @@ pub fn check_clonefile(git: &ResolvedBinary) -> DoctorCheck {
}
};

match Command::new(git_path)
.args(["config", "--global", "core.clonefile"])
.output()
{
let mut command = Command::new(git_path);
command.args(["config", "--global", "core.clonefile"]);
match run_command_with_timeout(
command,
"git config --global core.clonefile",
DEFAULT_PROBE_TIMEOUT,
) {
Ok(output) if output.status.success() => {
let raw = format!(
"{header}\n{}",
Expand Down Expand Up @@ -583,6 +622,10 @@ pub fn check_clonefile(git: &ResolvedBinary) -> DoctorCheck {
bridge: None,
}
}
Err(CommandError::Timeout { command, timeout }) => command_timeout_check(
TimeoutCheck::new(id, label, CheckStatus::Warn, header, command, timeout)
.install_source(git.install_source.clone()),
),
Err(e) => DoctorCheck {
id,
label,
Expand Down
Loading