Files
magpie/internal/agent/bin_local_test.go
T
yetone 80e4856803 agent: an agent's command in ~/.local/bin is found on Linux and macOS too (Xuanwo on X)
Detected asked only magpie's own PATH off Windows. A magpie started from a
desktop launcher has no ~/.local/bin on it, where the official Antigravity
CLI installer puts agy, so the Plugins page said "Antigravity CLI isn't in
Agents: magpie doesn't find it in ~/.gemini/antigravity-cli". binAt now asks
proc.FindTool on every OS (PATH, then ~/.local/bin, npm, bun, Volta, cargo
and the other folders a user's tools live in), as Windows already did and as
CLIMissing already did.

Run: TestDetectedFindsBinInLocalBin on Linux (wsl-run, magpie-desktop): red
with binAt put back to LookPath only, green with the change. On mote:
go test ./internal/agent ./internal/proc ./internal/gui ok, gofmt clean,
go vet for darwin, windows and linux nogui clean.
Not tried: a real agy install on the Linux VM, and the GUI Plugins page.
2026-11-11 18:58:22 +08:00

37 lines
1.0 KiB
Go

package agent
import (
"os"
"path/filepath"
"runtime"
"testing"
"github.com/yetone/magpie/internal/testenv"
)
// Xuanwo on X: the official installer puts agy in ~/.local/bin, which a
// magpie started from a desktop launcher has not on its PATH; Antigravity
// CLI was reported as not found on Linux.
func TestDetectedFindsBinInLocalBin(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("PATH", t.TempDir())
a := &Agent{ID: "agy", Name: "Antigravity CLI", Bin: "magpie-test-agy", Dir: filepath.Join(home, ".gemini", "antigravity-cli"), Path: filepath.Join(home, ".gemini", "antigravity-cli", "settings.json")}
if a.Detected() {
t.Fatal("detected with nothing installed")
}
local := filepath.Join(home, ".local", "bin")
if err := os.MkdirAll(local, 0o755); err != nil {
t.Fatal(err)
}
name := a.Bin
if runtime.GOOS == "windows" {
name += ".exe"
}
testenv.Program(t, filepath.Join(local, name), "#!/bin/sh\n")
if !a.Detected() {
t.Fatal("agy in ~/.local/bin, off PATH, not detected")
}
}