Documentation
¶
Overview ¶
Package cli provides CLI discovery, version validation, and command building for the Codex CLI binary.
This package provides three main capabilities:
CLI Discovery ¶
The Discoverer interface locates and validates the Codex CLI binary:
discoverer := cli.NewDiscoverer(&cli.Config{
CliPath: "", // Optional explicit path
Logger: slog.Default(),
})
cliPath, err := discoverer.Discover(ctx)
Discovery searches in the following order:
- Explicit path in Config.CliPath (if provided)
- System PATH
- Common installation directories (/usr/local/bin, /usr/bin, ~/.local/bin)
Version Validation ¶
During discovery, the CLI version is validated against MinimumVersion (2.0.0). A warning is logged if the version is below minimum. Version checking can be skipped via Config.SkipVersionCheck or the CODEX_AGENT_SDK_SKIP_VERSION_CHECK environment variable.
Command Building ¶
The package provides functions to build CLI command arguments and environment:
args := cli.BuildExecArgs("prompt", options)
env := cli.BuildEnvironment(options)
Index ¶
Constants ¶
const ( // BinaryName is the name of the Codex CLI binary. BinaryName = "codex" // MinimumVersion is the minimum required Codex CLI version. MinimumVersion = "0.103.0" // VersionCheckTimeout is the timeout for the CLI version check command. VersionCheckTimeout = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func BuildAppServerArgs ¶
BuildAppServerArgs constructs the CLI argument list for `codex app-server`.
func BuildEnvironment ¶
BuildEnvironment constructs the environment variables for the CLI process.
Types ¶
type Command ¶
type Command struct {
// Args are the command line arguments.
Args []string
// Env are the environment variables.
Env []string
}
Command represents the CLI command to execute.
type Config ¶
type Config struct {
// CliPath is an explicit CLI path that skips PATH search.
CliPath string
// SkipVersionCheck skips version validation during discovery.
// Can also be controlled via CODEX_CLI_SKIP_VERSION_CHECK env var.
SkipVersionCheck bool
// Logger is an optional logger for discovery operations.
Logger *slog.Logger
}
Config holds configuration for CLI discovery.
type Discoverer ¶
type Discoverer interface {
// Discover locates the Codex CLI binary and validates its version.
Discover(ctx context.Context) (string, error)
}
Discoverer locates and validates the Codex CLI binary.
func NewDiscoverer ¶
func NewDiscoverer(cfg *Config) Discoverer
NewDiscoverer creates a new CLI discoverer with the given configuration.