agentcli

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package agentcli finds the coding-agent CLIs baum runs (Claude Code and Codex), checks their versions against the oldest each backend supports, and keeps the record `baum desktop-setup` writes from the user's terminal.

Some users put an agent on their PATH only in an interactive shell (a version manager set up in ~/.bashrc), which baum cannot start without a terminal, so it finds an older copy or none. The record names the directories the user's terminal found the agents in; baum puts them first on the PATH it uses (WithRecorded), so every lookup of `claude` or `codex`, and the `node` an npm-installed agent starts, finds what the user runs.

Index

Constants

This section is empty.

Variables

View Source
var Agents = []Agent{
	{Slug: "claude-code", Name: "Claude Code", Binary: "claude", Minimum: claude.MinimumVersion},
	{Slug: "codex", Name: "Codex", Binary: "codex", Minimum: codex.MinimumVersion},
}

Agents are the CLIs baum checks, in the order it reports them.

Functions

func Keep

func Keep(ctx context.Context, base string, every time.Duration, changed func(path string))

Keep sets this process's PATH to base with the recorded directories first, now and whenever the record changes, until ctx ends: the daemon keeps running while the user runs `baum desktop-setup`. changed is called after each change the record brings.

func RecordFile

func RecordFile() (string, error)

RecordFile is the record's location: terminal.json beside config.toml.

func Save

func Save(path string, record Record) error

Save replaces the record at path, readable only by the user.

func Supported

func Supported(version, minimum string) bool

Supported reports whether version is minimum or newer. An unreadable version is not supported.

func Version

func Version(ctx context.Context, binary string) (string, error)

Version runs binary --version and returns the first dotted version it prints.

func WithDirs

func WithDirs(path string, dirs []string) string

WithDirs is the PATH value path with dirs first and their other entries removed.

func WithRecorded

func WithRecorded(path string) string

WithRecorded is the PATH value path with the recorded directories first. Without a readable record it is path.

Types

type Agent

type Agent struct {
	// Slug names the agent as `baum hooks` does.
	Slug string
	Name string
	// Binary is the command's name on the PATH.
	Binary string
	// Minimum is the oldest version baum runs.
	Minimum string
}

Agent is a coding-agent CLI baum runs.

func Lookup

func Lookup(slug string) (Agent, bool)

Lookup returns the agent with slug.

type Found

type Found struct {
	Agent string `json:"agent"`
	Name  string `json:"name"`
	// Path is where the PATH lookup found it; empty when it did not.
	Path    string `json:"path,omitempty"`
	Version string `json:"version,omitempty"`
	Minimum string `json:"minimum_version"`
	// Supported is whether Version is Minimum or newer.
	Supported bool `json:"supported"`
	// Error is why the version could not be read.
	Error string `json:"error,omitempty"`
}

Found is what Find learned about an agent on the PATH.

func Find

func Find(ctx context.Context, agent Agent) Found

Find looks agent up on the current PATH and reads its version.

type Record

type Record struct {
	Agents []Recorded `json:"agents"`
}

Record is what `baum desktop-setup` saw on the user's terminal PATH.

func Load

func Load(path string) (Record, error)

Load reads the record at path; a missing file is an empty record.

func NewRecord

func NewRecord(found []Found, path string) Record

NewRecord records the agents Find found on the PATH value path, in that PATH's order, so the recorded directories, put first on another PATH, resolve each agent as the terminal did: one agent's directory may hold an older copy of another, which must not come first unless it did there.

func (Record) Dirs

func (r Record) Dirs() []string

Dirs are the record's directories that still exist, in order, once each.

func (Record) Holds

func (r Record) Holds(path string) bool

Holds reports whether the executable at path is in a recorded directory.

type Recorded

type Recorded struct {
	Agent string `json:"agent"`
	// Path is the executable in Dir.
	Path string `json:"path"`
	// Dir is the PATH directory it was found in, with symbolic links
	// resolved: a version manager's per-shell directory (fnm's
	// fnm_multishells) is gone once that shell exits.
	Dir     string `json:"dir"`
	Version string `json:"version,omitempty"`
}

Recorded is one agent found on the terminal's PATH.

func Recording

func Recording(found Found) (Recorded, bool)

Recording turns what Find learned into a record entry; ok is false when the agent was not found.

Jump to

Keyboard shortcuts

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