The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
refactor(harness): extract shared executable-detection helper
Claude09b3ffa06dc8
diff --git a/cli/beacon/internal/endpoint/harness/copilot.go b/cli/beacon/internal/endpoint/harness/copilot.goindex 6ed917a6..70304ada 100644--- a/cli/beacon/internal/endpoint/harness/copilot.go+++ b/cli/beacon/internal/endpoint/harness/copilot.go@@ -3,7 +3,6 @@ package harnessimport ("net/url""os"- "os/exec""path/filepath""strings")@@ -14,12 +13,7 @@ func DiscoverCopilotCLI() Harness {func discoverCopilotCLI(expectedEndpoint string) Harness {h := Harness{Name: "copilot_cli", DisplayName: "GitHub Copilot CLI", Capability: "otel_env"}- path, err := exec.LookPath("copilot")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "copilot")home, _ := os.UserHomeDir()if !h.Detected && fileExists(filepath.Join(home, ".copilot", "config.json")) {h.Detected = truediff --git a/cli/beacon/internal/endpoint/harness/gemini.go b/cli/beacon/internal/endpoint/harness/gemini.goindex 369100bd..4d34dce7 100644--- a/cli/beacon/internal/endpoint/harness/gemini.go+++ b/cli/beacon/internal/endpoint/harness/gemini.go@@ -4,19 +4,13 @@ import ("encoding/json""fmt""os"- "os/exec""path/filepath""strings")func DiscoverGemini() Harness {h := Harness{Name: "gemini_cli", DisplayName: "Gemini CLI", Capability: "otel_config"}- path, err := exec.LookPath("gemini")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "gemini")home, _ := os.UserHomeDir()h.ConfigPath = filepath.Join(home, ".gemini", "settings.json")if fileExists(h.ConfigPath) {diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.goindex 0b0b28e4..c9560fa7 100644--- a/cli/beacon/internal/endpoint/harness/harness.go+++ b/cli/beacon/internal/endpoint/harness/harness.go@@ -66,15 +66,7 @@ func DiscoverAll() []Harness {func DiscoverAntigravity() Harness {h := Harness{Name: "antigravity_cli", DisplayName: "Antigravity CLI", Capability: "hooks"}- for _, name := range []string{"antigravity", "antigravity-cli"} {- path, err := exec.LookPath(name)- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- break- }- }+ detectExecutable(&h, "antigravity", "antigravity-cli")home, _ := os.UserHomeDir()userConfig := filepath.Join(home, ".gemini", "config", "hooks.json")projectConfig := filepath.Join(".agents", "hooks.json")@@ -98,12 +90,7 @@ func DiscoverAntigravity() Harness {func DiscoverClaude() Harness {h := Harness{Name: "claude_code", DisplayName: "Claude Code", Capability: "otel_env"}- path, err := exec.LookPath("claude")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "claude")home, _ := os.UserHomeDir()userConfig := filepath.Join(home, ".claude", "settings.json")managedConfig := "/Library/Application Support/ClaudeCode/managed-settings.json"@@ -130,12 +117,7 @@ func DiscoverClaude() Harness {func DiscoverCodex() Harness {h := Harness{Name: "codex_cli", DisplayName: "Codex CLI", Capability: "otel_config"}- path, err := exec.LookPath("codex")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "codex")home, _ := os.UserHomeDir()h.ConfigPath = filepath.Join(home, ".codex", "config.toml")if fileExists(h.ConfigPath) {@@ -151,12 +133,7 @@ func DiscoverCodex() Harness {func DiscoverFactory() Harness {h := Harness{Name: "factory", DisplayName: "Factory Droid", Capability: "otel_env"}- path, err := exec.LookPath("droid")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "droid")home, _ := os.UserHomeDir()h.ConfigPath = factoryProfilePath(home)if fileExists(h.ConfigPath) {@@ -172,12 +149,7 @@ func DiscoverFactory() Harness {func DiscoverOpenCode() Harness {h := Harness{Name: "opencode", DisplayName: "opencode", Capability: "plugin"}- path, err := exec.LookPath("opencode")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "opencode")home, _ := os.UserHomeDir()pluginPath := filepath.Join(home, ".config", "opencode", "plugins", "beacon.ts")h.ConfigPath = pluginPath@@ -202,12 +174,7 @@ func DiscoverOpenCode() Harness {func DiscoverHermes() Harness {h := Harness{Name: "hermes", DisplayName: "Hermes Agent", Capability: "hooks"}- path, err := exec.LookPath("hermes")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "hermes")home, _ := os.UserHomeDir()h.ConfigPath = filepath.Join(home, ".hermes", "config.yaml")if !h.Detected && dirExists(filepath.Join(home, ".hermes")) {@@ -226,12 +193,7 @@ func DiscoverHermes() Harness {func DiscoverCursor() Harness {h := Harness{Name: "cursor", DisplayName: "Cursor", Capability: "hooks"}- path, err := exec.LookPath("cursor")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "cursor")home, _ := os.UserHomeDir()h.ConfigPath = filepath.Join(home, ".cursor", "hooks.json")if !h.Detected && dirExists(filepath.Join(home, ".cursor")) {@@ -255,12 +217,7 @@ func DiscoverCursor() Harness {func DiscoverDevin() Harness {h := Harness{Name: "devin-cli", DisplayName: "Devin CLI", Capability: "hooks"}- path, err := exec.LookPath("devin")- if err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "devin")home, _ := os.UserHomeDir()userConfig := filepath.Join(home, ".config", "devin", "config.json")projectConfig := filepath.Join(".devin", "hooks.v1.json")@@ -725,6 +682,21 @@ func factoryProfilePath(home string) string {}}+// detectExecutable looks up each candidate command name on PATH and, on the+// first match, marks the harness detected and records its executable path and+// version. Names are tried in order.+func detectExecutable(h *Harness, names ...string) {+ for _, name := range names {+ path, err := exec.LookPath(name)+ if err == nil {+ h.Detected = true+ h.ExecutablePath = path+ h.Version = commandVersion(path)+ return+ }+ }+}+func commandVersion(path string) string {ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)defer cancel()diff --git a/cli/beacon/internal/endpoint/harness/vscode.go b/cli/beacon/internal/endpoint/harness/vscode.goindex 4fcd6ec0..e4a5bf99 100644--- a/cli/beacon/internal/endpoint/harness/vscode.go+++ b/cli/beacon/internal/endpoint/harness/vscode.go@@ -5,7 +5,6 @@ import ("fmt""net/url""os"- "os/exec""path/filepath""runtime""strings"@@ -28,11 +27,7 @@ func DiscoverVSCode() Harness {func discoverVSCode(expectedEndpoint string) Harness {h := Harness{Name: VSCodeName, DisplayName: "VS Code", Capability: "otel_hooks"}- if path, err := exec.LookPath("code"); err == nil {- h.Detected = true- h.ExecutablePath = path- h.Version = commandVersion(path)- }+ detectExecutable(&h, "code")settingsPath, err := VSCodeUserSettingsPath()if err == nil {h.ConfigPath = settingsPath