Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

fix(agy): find agy shipped by the Antigravity desktop app on macOS and Linux

Jasonb230662108fc
diff --git a/src-tauri/src/agy_config.rs b/src-tauri/src/agy_config.rs
index 19445f627..eb319fa6c 100644
--- a/src-tauri/src/agy_config.rs
+++ b/src-tauri/src/agy_config.rs
@@ -1090,10 +1090,7 @@ pub(crate) fn real_agy_bin() -> Option<PathBuf> {
let system_dirs: Vec<PathBuf> = if cfg!(windows) {
windows_agy_dirs(dirs::data_local_dir(), &get_home_dir())
} else {
- vec![
- PathBuf::from("/opt/homebrew/bin"),
- PathBuf::from("/usr/local/bin"),
- ]
+ unix_agy_dirs(&get_home_dir())
};
resolve_real_agy(
&path_var,
@@ -1115,6 +1112,16 @@ fn windows_agy_dirs(local_data: Option<PathBuf>, home: &Path) -> Vec<PathBuf> {
dirs
}
+/// macOS / Linux 上不在 PATH 里的安装位置:Homebrew 的 bin;只装了桌面版时 `agy`
+/// 在 `~/.gemini/bin`,桌面版不把它加进 PATH(#10162,与 Windows 的 #10105 同源)。
+fn unix_agy_dirs(home: &Path) -> Vec<PathBuf> {
+ vec![
+ PathBuf::from("/opt/homebrew/bin"),
+ PathBuf::from("/usr/local/bin"),
+ home.join(".gemini").join("bin"),
+ ]
+}
+
fn resolve_real_agy(
path_var: &std::ffi::OsStr,
home: &Path,
@@ -1346,6 +1353,18 @@ mod tests {
assert_eq!(resolve_real_agy(&path, &home, &[], false), None);
}
+ #[test]
+ fn unix_dirs_include_desktop_bin_after_system_dirs() {
+ assert_eq!(
+ unix_agy_dirs(Path::new("/home/me")),
+ vec![
+ PathBuf::from("/opt/homebrew/bin"),
+ PathBuf::from("/usr/local/bin"),
+ PathBuf::from("/home/me/.gemini/bin")
+ ]
+ );
+ }
+
fn patched(patch: &JsonPatch, before: &str) -> Value {
let bytes = patch
.apply(Path::new("settings.json"), Some(before.as_bytes()))
@@ -2156,6 +2175,26 @@ mod integration_tests {
);
}
+ #[test]
+ fn resolver_finds_desktop_only_agy_in_gemini_bin() {
+ // 只装了桌面版:agy 在 ~/.gemini/bin,GUI 的 PATH 里没有(#10162)。
+ let tmp = tempfile::tempdir().unwrap();
+ let home = tmp.path().join("home");
+ let gui_path = std::ffi::OsString::from("/usr/bin:/bin:/usr/sbin:/sbin");
+ let dirs = vec![home.join(".gemini").join("bin")];
+ let desktop = fake_agy(&dirs[0]);
+ assert_eq!(
+ resolve_real_agy(&gui_path, &home, &dirs, false),
+ Some(desktop)
+ );
+ // 另装了 CLI 时官方位置 ~/.local/bin 优先。
+ let local = fake_agy(&home.join(".local/bin"));
+ assert_eq!(
+ resolve_real_agy(&gui_path, &home, &dirs, false),
+ Some(local)
+ );
+ }
+
#[test]
fn resolver_skips_legacy_wrappers_and_non_executables() {
let tmp = tempfile::tempdir().unwrap();
diff --git a/src-tauri/src/commands/tool_discovery.rs b/src-tauri/src/commands/tool_discovery.rs
index c06dad040..765193c04 100644
--- a/src-tauri/src/commands/tool_discovery.rs
+++ b/src-tauri/src/commands/tool_discovery.rs
@@ -588,6 +588,13 @@ pub(super) fn build_tool_search_paths(tool: &str) -> Vec<std::path::PathBuf> {
push_unique_path(&mut search_paths, std::path::PathBuf::from("/usr/bin"));
}
+ #[cfg(not(target_os = "windows"))]
+ if tool == "agy" && !home.as_os_str().is_empty() {
+ // The Antigravity desktop app ships `agy` here without adding it to
+ // PATH (#10162; the Windows counterpart is #10105).
+ push_unique_path(&mut search_paths, home.join(".gemini").join("bin"));
+ }
+
#[cfg(target_os = "windows")]
{
// Official standalone (non-npm) installer locations — belt-and-suspenders
diff --git a/src-tauri/src/commands/tool_discovery/tests.rs b/src-tauri/src/commands/tool_discovery/tests.rs
index 34a73624d..948f9c72e 100644
--- a/src-tauri/src/commands/tool_discovery/tests.rs
+++ b/src-tauri/src/commands/tool_discovery/tests.rs
@@ -744,6 +744,14 @@ mod anchored_upgrade {
assert!(paths.contains(&home.join(".pi").join("agent").join("bin")));
}
+ #[test]
+ fn agy_search_paths_include_desktop_app_bin() {
+ // 只装了 Antigravity 桌面版时 agy 在 ~/.gemini/bin(#10105 / #10162)。
+ let home = crate::config::get_home_dir();
+ let paths = build_tool_search_paths("agy");
+ assert!(paths.contains(&home.join(".gemini").join("bin")));
+ }
+
#[cfg(target_os = "macos")]
#[test]
fn macos_search_paths_include_pnpm_global_bin_dirs() {