clients

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package clients holds the registry of AI coding agent clients (Claude Code, Codex, Gemini, OpenCode, ...). Each client owns its own install, launch, and configuration logic inside a sub-package; this file provides shared helpers for discovering client binaries on disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindBinary

func FindBinary(name string, extraPaths []string) string

FindBinary returns the resolved path to a client binary. It checks exec.LookPath (i.e. $PATH) first, then the client-supplied extra paths, then general well-known user-local binary directories. Returns "" if the binary cannot be found.

func IsInstalled

func IsInstalled(name string, extraPaths []string) bool

IsInstalled reports whether the named binary can be found on disk.

func Launch

func Launch(spec LaunchSpec) tea.Cmd

Launch returns a tea.Cmd that runs the given spec via tea.ExecProcess and emits menu.ExecDoneMsg when the child exits. If spec.Binary is empty, the command returns immediately with an error.

func Register

func Register(c Client)

Register adds a client to the registry. Intended to be called from a sub-package's init(). Order of registration determines display order.

Types

type Client

type Client interface {
	// Name is the user-visible display name (e.g. "Claude Code").
	Name() string

	// BinaryName is the executable name checked against $PATH. Empty for
	// clients that are not a CLI binary (e.g. desktop apps).
	BinaryName() string

	// CommonPaths returns absolute paths where the binary may live outside
	// of PATH (e.g. "~/.local/bin/claude"). Used as a fallback by
	// FindBinary.
	CommonPaths() []string

	// IsInstalled reports whether the client is available locally. The
	// default implementation is clients.IsInstalled(BinaryName, CommonPaths).
	IsInstalled() bool

	// Install describes how to install the client. May read g for
	// host-dependent setup (e.g. writing platform config before download).
	Install(g *config.Global) InstallPlan

	// Uninstall describes how to uninstall the client.
	Uninstall() UninstallPlan

	// Menu returns the root menu item shown in the client picker. Its
	// Action kicks off the client's own sub-menu flow (provider → backend →
	// model → launch).
	Menu(g *config.Global) menu.MenuItem

	// Replay attempts to re-launch the client using the last-used selection
	// stored in g.LastLaunch. Returns nil if the state is stale (binary
	// missing, provider gone from g.Providers, model no longer listed).
	Replay(g *config.Global) tea.Cmd

	// QuickSelectLabel is the display text for the [0] quick-select row
	// when Replay would succeed.
	QuickSelectLabel(g *config.Global) string
}

Client is one AI coding agent that the launcher can install and launch. Each client lives in its own sub-package and is wholly responsible for its own provider/backend/model flow, env generation, config writing, install and uninstall — all of which are expressed through the MenuItem returned from Menu() plus the InstallPlan / UninstallPlan.

func All

func All(g *config.Global) []Client

All returns every registered client. The g argument is accepted so callers always have the global state at hand; it is not currently used for filtering since every client decides its own menu behavior when invoked.

type InstallPlan

type InstallPlan struct {
	// Hint is shown to the user before confirming; e.g.
	// "curl -fsSL https://claude.ai/install.sh | bash".
	Hint string
	// Run returns the command to execute on confirmation. If nil, the install
	// is manual-only: the TUI shows Hint and does nothing.
	Run func() (*exec.Cmd, error)
}

InstallPlan describes how to install a client.

type LaunchSpec

type LaunchSpec struct {
	// Binary is the absolute path to the executable. Required.
	Binary string
	// Args are appended to the command line after Binary.
	Args []string
	// Env is overlaid on top of os.Environ(). Later keys override earlier
	// ones; within Env, order is unspecified (map).
	Env map[string]string
	// Cleanup runs after the child exits, before the done-msg is emitted.
	// Use it to remove temporary config files.
	Cleanup func()
	// Debug, when true, dumps the resolved Env and Args to stderr before
	// exec (matches the `-debug` flag wiring).
	Debug bool
}

LaunchSpec describes a foreground client-binary launch. The TUI hands control to the child process and regains it when the child exits.

type UninstallPlan

type UninstallPlan struct {
	// Hint is shown to the user before confirming.
	Hint string
	// Run performs the uninstall. If nil, uninstall is disabled.
	Run func() error
}

UninstallPlan describes how to uninstall a client.

Directories

Path Synopsis
Package claudecode is the Claude Code CLI client.
Package claudecode is the Claude Code CLI client.
Package codex is the OpenAI Codex client.
Package codex is the OpenAI Codex client.
Package gemini is the Google Gemini CLI client.
Package gemini is the Google Gemini CLI client.
Package opencode is the OpenCode client.
Package opencode is the OpenCode client.

Jump to

Keyboard shortcuts

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