detect

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package detect finds ACP agents installed on this computer, so the user picks one instead of typing a command line.

An agent is found in three steps: its executable on the search path (the login shell's PATH and the usual per-user install directories, which an app started from the desktop does not inherit), then the way it speaks ACP (a separate adapter, or its own flag or subcommand, confirmed in its help text), then its version, best effort.

Detection only runs the agents' --help and --version; nothing is installed. An agent that needs an adapter it does not have runs it through npx when npx is present, and otherwise reports the npm package to install.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookPath

func LookPath(path, name string) string

LookPath finds an executable named name in a PATH list, as the system would; "" when there is none.

func Name

func Name(id string) string

Name is the display name of a catalog id, or "" for an unknown one.

func Type

func Type(id string) string

Type is the acp.Config.Type of a catalog id; an unknown one is custom.

func Vars

func Vars(id string, sh Shell, environ []string) map[string]string

Vars are the variables an agent runs with beyond the base environment acp.FilterEnv keeps: the search path, the shared variables and the agent's own, from the login shell, else from environ (os.Environ), and the system proxy when no proxy variable is set. An unknown id, a command the user typed, gets the shared ones. acp.FilterEnv still removes the names it always denies.

Types

type Agent

type Agent struct {
	ID      string // catalog id: claude, codex, grok, gemini, ...
	Name    string
	Type    string // acp.Config.Type
	Command string // absolute path; empty when Missing is set
	Args    []string
	Version string // the agent's own version, when it reports one
	// Fetch is set when Command is npx, which downloads Package the first
	// time the agent starts.
	Fetch bool
	// Package is the npm package of the agent's ACP adapter, when it needs one.
	Package string
	// Missing is set when the agent is installed but its adapter is not,
	// and there is no npx to fetch it: install Package first.
	Missing bool
}

Agent is one ACP agent found on this computer.

func Find

func Find(ctx context.Context, id string) (Agent, bool)

Find detects one agent again, for a saved choice whose executable moved.

func Scan

func Scan(ctx context.Context, refresh bool) []Agent

Scan lists the agents found, in catalog order. refresh reads the login shell again. It blocks for seconds at most; call it off the UI thread.

type Shell

type Shell struct {
	// Path is this process's PATH, then the login shell's, then the usual
	// per-user install directories that exist.
	Path string
	// Env is the login shell's environment, or nil when it could not be read.
	Env map[string]string
	// Proxy is the system proxy setting as proxy variables, used when no
	// proxy variable is set.
	Proxy map[string]string
}

Shell is what an agent needs from the user's environment that an app started from the desktop may not have: the login shell's variables, and the search path.

func LoginShell

func LoginShell(ctx context.Context, refresh bool) Shell

LoginShell reads the login shell once; refresh reads it again. It blocks for seconds at most; call it off the UI thread.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL