providers

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 16 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 providers is the registry of AI coding CLI harnesses lich can run in a session (Claude Code, Codex, Antigravity, opencode, oh-my-pi, Crush, Cursor CLI, Kiro CLI). A provider id doubles as the session kind that spawns it; the terminal resolves the id to a binary, and the settings store keys per-provider overrides on it. Detection reads that override and then scans PATH.

Index

Constants

View Source
const (
	Claude      = "claude"
	Codex       = "codex"
	Antigravity = "antigravity"
	OpenCode    = "opencode"
	OMP         = "omp"
	Crush       = "crush"
	Cursor      = "cursor"
	Kiro        = "kiro"
)

Provider ids. Each id is also the session kind (store column + terminal.Start) that runs the provider. Kept in sync with the window's provider tables (native/cmd/lich-native/providericon.go, spawn_gate.go resumableKinds).

View Source
const (
	// SourcePath: one of the provider's own binaries answered on $PATH.
	SourcePath = "path"
	// SourceSetting: the binary configured in Settings › Providers, which is the
	// one the spawn resolves first.
	SourceSetting = "setting"
)

Where the binary a session would spawn was resolved from. A machine with an agent only lich knows about — reached through the binary setting rather than $PATH — is installed just as much as one that answers `which`, and the two are told apart so Settings can caption the row with which layer won.

View Source
const (
	// CheckOK: the binary resolves and can be executed.
	CheckOK = api.CheckOK
	// CheckEmpty: nothing is configured at this layer, so the next one answers.
	CheckEmpty    = api.CheckEmpty
	CheckNotFound = "not-found"
	// CheckNotExecutable covers a file without the execute bit and a directory
	// — both are "found, cannot be run".
	CheckNotExecutable = "not-executable"
	// CheckHomeShortcut: a leading ~ is a shell convenience. lich spawns the
	// binary directly (internal/terminal/pty_unix.go), so nothing expands it and
	// the path is taken literally.
	CheckHomeShortcut = "home-shortcut"
	// CheckRelative: a relative path is resolved against each session's own
	// working directory, so the same setting means a different binary — or none
	// — per session. Reported rather than resolved: there is no one directory
	// this check could answer for.
	CheckRelative = "relative"
)

A Check's Status. Each failing value names a distinct mistake, because each one is silent today: the session simply refuses to start, and the settings screen that accepted the value says nothing.

View Source
const KiroAgentName = "lich"

KiroAgentName is the agent profile lich installs into Kiro CLI and spawns it with. Kiro keeps its hooks inside an agent config and its built-in `kiro_default` cannot be shadowed by a file, so lich's four reports only reach a Kiro session through an agent of lich's own — written by internal/agentplugin, named on the command line by internal/terminal, and spelled once here so those two cannot drift apart.

View Source
const KiroHomeVar = "KIRO_HOME"

KiroHomeVar is the variable Kiro CLI moves its root with.

View Source
const OpenCode2StandaloneFlag = "--standalone"

OpenCode2StandaloneFlag runs an opencode 2 command on a private server of its own. Without it 2.x attaches to a background service every opencode on the machine shares, which read its config, data home and environment once, when whichever command came first started it (measured on 2.2.5), so a spawn's profile, inline config or MCP server would reach it only by luck.

Variables

View Source
var Registry = []Provider{
	{ID: Claude, Name: "Claude Code", Binaries: []string{"claude"}, Docs: "https://code.claude.com/docs/en/setup"},
	{ID: Codex, Name: "Codex", Binaries: []string{"codex"}, Docs: "https://learn.chatgpt.com/docs/codex/cli"},
	{ID: Antigravity, Name: "Antigravity", Binaries: []string{"agy"}, Docs: "https://antigravity.google/docs/cli/getting-started"},
	{ID: OpenCode, Name: "opencode", Binaries: []string{"opencode"}, Docs: "https://opencode.ai/docs/"},
	{ID: OMP, Name: "oh-my-pi", Binaries: []string{"omp"}, Docs: "https://github.com/can1357/oh-my-pi"},
	{ID: Crush, Name: "Crush", Binaries: []string{"crush"}, Docs: "https://github.com/charmbracelet/crush"},
	{ID: Cursor, Name: "Cursor CLI", Binaries: []string{"cursor-agent"}, Docs: "https://cursor.com/docs/cli/installation"},
	{ID: Kiro, Name: "Kiro CLI", Binaries: []string{"kiro-cli"}, Docs: "https://kiro.dev/docs/cli/installation/"},
}

Registry is every provider lich knows about, in display order. Claude Code is first: it is the default, and the plugin's home. Every one of them resumes a conversation by id (terminal.resumeArgs); all but Cursor CLI also have the companion plugin installed into them (agentplugin.supported) — Cursor runs it anyway, because it executes every Claude Code hook on the machine, which docs/providers/cursor.md names along with what that costs. What still differs per provider is spelled at each of those tables, and AcceptsMCPServer below is the one split this file owns.

Functions

func AcceptsMCPServer

func AcceptsMCPServer(id string) bool

AcceptsMCPServer reports whether a provider can be handed an MCP server at spawn, so lich can register one for a session it spawns without editing config that belongs to the user or to their repository.

Claude Code takes `--mcp-config` with a JSON string; Codex takes `-c` overrides for its `mcp_servers` table; opencode merges the inline config in $OPENCODE_CONFIG_CONTENT over its files. Antigravity, oh-my-pi, Crush and Cursor CLI have no such route — Antigravity keeps MCP behind an `agy mcp` subcommand, Crush's whole flag list is cwd, data-dir, session and debug, and Cursor's `mcp` subcommand only lists, enables and disables what is already in `~/.cursor/mcp.json` (measured on 2026.08.11) — so registering for those means writing config that outlives the spawn, which is what the plugin install does for the ones that can take it.

func CursorAuthDir

func CursorAuthDir(home string) string

CursorAuthDir resolves the directory Cursor CLI keeps its login, `auth.json`, in. It is not the config dir: CURSOR_CONFIG_DIR does not move it, and the rule differs per OS, so with no XDG_CONFIG_HOME on Linux the two part ways (~/.cursor against ~/.config/cursor). Read in the 2026.10.01 bundle, the cli-credentials package's getAuthFilePath (issue #765).

func CursorAuthDirIn

func CursorAuthDirIn(getenv func(string) string, home string) string

CursorAuthDirIn is CursorAuthDir answered against another process's environment. Here the login is xdg-basedir: $XDG_CONFIG_HOME/cursor, else ~/.config/cursor.

func CursorConfigDir

func CursorConfigDir(home string) string

CursorConfigDir resolves Cursor CLI's config directory under home — where it keeps `cli-config.json`, which names the account, and the chats. Its login, `auth.json`, is not here (CursorAuthDir).

It lives here because two packages need the same answer and got two: the sandbox binds this directory into a confined session, and the terminal reads the chats under it to decide whether a conversation can still be resumed. A second copy of the rule had already drifted on whether a relative variable counts.

Cursor is not xdg-basedir, which is the trap: $CURSOR_CONFIG_DIR wins outright, else $XDG_CONFIG_HOME with "cursor" under it — and with neither set it lands on ~/.cursor, never ~/.config/cursor. Reading it the way opencode and Crush are read would name a directory the CLI never writes on a machine with no XDG_CONFIG_HOME, which is most of them. Measured on 2026.08.11.

A relative variable is ignored rather than resolved, both because XDG_CONFIG_HOME is specified that way and because there is nothing to resolve it against: lich's working directory is not the CLI's, so a relative path here names a directory nobody involved would agree on.

It answers for the config dir alone. `~/.cursor` is a second directory the CLI resolves off the home with no variable in the way at all — it holds mcp.json, the per-project transcripts and the CLI state — and a caller that needs the whole picture binds both (internal/sandbox).

func CursorConfigDirIn

func CursorConfigDirIn(getenv func(string) string, home string) string

CursorConfigDirIn is CursorConfigDir answered against another process's environment: internal/quota reads the login a session's own process sees.

func DefaultBinary

func DefaultBinary(id string) string

DefaultBinary returns a provider's preferred executable name, or "" for an unknown id.

func IsOpencode2 added in v0.84.0

func IsOpencode2(bin string) bool

IsOpencode2 reports whether bin, resolved on PATH, is opencode 2 or later, which shares the 1.x binary name, config and database but not its argv. False whenever that cannot be told, which keeps the 1.x argv every opencode before 2.0 accepts.

func KiroAgentPath

func KiroAgentPath() (string, error)

KiroAgentPath is the file that agent lives in, inside Kiro's global agents directory under KiroHome. Resolved here rather than in either caller so the install that writes the file (internal/agentplugin) and the spawn that decides whether to name it (internal/terminal) cannot drift to different paths.

func KiroHome added in v0.78.1

func KiroHome(home string) string

KiroHome resolves Kiro CLI's root under home: $KIRO_HOME when it is set, else ~/.kiro. The root holds the agents lich installs into, the skills, the settings and the conversations (`sessions/cli/<id>.json`), and KIRO_HOME moves all of it (2.21.0, measured against a throwaway home; issue #766). The login is not here: it is in the SQLite store under the data home, which KIRO_HOME leaves where it was.

It lives here because four packages need the same answer — the sandbox binds it, the plugin install writes the agent under it, and the terminal reads the conversations and stats the agent — and each had built ~/.kiro off the home alone, so a user with KIRO_HOME set got no transcript, no cost and no hooks.

A relative variable is ignored rather than resolved, as CursorConfigDir does: lich's working directory is not the CLI's, so a relative path names a directory nobody involved would agree on.

func Known

func Known(id string) bool

Known reports whether id names a registered provider. It guards a provider id that arrives from outside lich — a hook payload — before it is used as one.

func ProbeVersion added in v0.84.0

func ProbeVersion(ctx context.Context, path string) (string, error)

ProbeVersion is Version for a binary already resolved, for a caller that holds no Service: the spawn, which picks an argv by the version it runs.

func SupportsFork

func SupportsFork(id string) bool

SupportsFork reports whether a provider can branch an existing conversation into a second one — the copy carries the history, the original is left untouched — so lich can offer to carry a session's conversation into a new checkout instead of only reopening it where it was.

Three of the eight spell it themselves and lich forks through no other route: Claude Code's `--fork-session` rides its `--resume`, Codex swaps its `resume` subcommand for `fork`, and opencode's `--fork` rides its `--session` (measured on 2.1.261, 0.151.0 and 1.18.23). The other five keep no such verb — oh-my-pi, Crush, Cursor CLI, Kiro CLI and Antigravity offer resume alone — and lich will not forge one: the copy would have to be written into that harness's own private store (two SQLite schemas with triggers, a blob store keyed on the md5 of the checkout, two JSONL formats carrying the id and cwd inside them), none documented, each versioned by its own CLI, and the blast radius of getting one wrong is the user's real history. The card says so at the dead menu item rather than dropping it (SessionForkItem).

Types

type Binary

type Binary = api.ProviderBinary

type Check

type Check = api.BinaryCheck

type CostSource

type CostSource string

CostSource is whose arithmetic a session's dollars in the cost ledger are. Five providers file a figure there and they reach it two ways, which any report summing them has to be able to say: a dollar lich derived and a dollar Crush reported are the same number on screen and not the same claim.

const (
	// CostSourceNone: no dollars at all. Antigravity and Cursor CLI file their
	// conversations where lich has no reader, and Kiro CLI meters spend in
	// credits, not money — and a session running the user's shell was never
	// spawned as a provider, so whatever it ran by hand is on neither rung.
	CostSourceNone CostSource = ""
	// CostSourcePriced: lich prices the conversation itself, from the token
	// counts the provider writes down (internal/pricing).
	CostSourcePriced CostSource = "priced"
	// CostSourceReported: the provider priced its own turns and lich files that
	// figure unchanged — each bills models no table here knows, so a second
	// opinion would only be a second, disagreeing number.
	CostSourceReported CostSource = "reported"
)

func CostSourceOf

func CostSourceOf(id string) CostSource

CostSourceOf says which of the two a provider's spend is, and it is the one answer both the live readout and `lich cost` rely on. The rung is a fact of the provider — what it writes down decides who can price it — so it is answered from the id alone and never recorded per ledger row. docs/providers/ carries what each provider's figure leaves out.

type Detected

type Detected = api.DetectedProvider

type Provider

type Provider struct {
	ID       string
	Name     string
	Binaries []string
	Docs     string
}

Provider is a known harness: a stable id, a display name, the executable names to look for on PATH (in preference order), and the page that documents installing that CLI.

Docs is the page a user who has not got the provider is sent to, so it is the install instructions rather than the product's front door — and it is checked against the live web when it lands (docs/adding-a-provider.md), because a link offered by a "not found" row is worth less than nothing if it 404s.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service detects installed providers. lookPath is injected so tests drive detection without touching the machine.

func New

func New() *Service

New returns a Service that scans the real PATH.

func (*Service) Detect

func (s *Service) Detect(_ context.Context, _ api.None) ([]Detected, error)

Detect returns every known provider with its install state, resolving the binary exactly as a spawn would: the configured one first, then the first candidate found on PATH. The list order matches Registry.

Reading the setting is what keeps a machine whose only agent lives at a path the user typed from reading as a bare machine — the state the empty screen answers with a terminal.

func (*Service) OnPath

func (s *Service) OnPath(ctx context.Context, opts api.ProviderIDOptions) ([]Binary, error)

OnPath lists every distinct executable on $PATH that a provider's binary names resolve to, in $PATH order (so the first one is what Detect picks when no binary is configured), each with its version. Two entries that are the same file (a directory listed twice, two symlinks to one install) count once.

A probe that fails leaves that entry's version empty rather than dropping it: the binary is still there for the spawn to find.

func (*Service) RefreshPath

func (s *Service) RefreshPath(_ context.Context, _ api.None) (api.None, error)

RefreshPath re-reads the login shell's environment and re-pins what it resolved, so the Detect and Verify below answer from what is installed now rather than from what was installed when lich started. It is what lets a re-check recover a machine that installed an agent, git or gh into a directory the launch PATH did not carry, without a relaunch.

It runs under the resolution's own bound (terminal.ReresolveShellEnv), and a shell that does not answer inside it leaves the pin exactly as it is and says so: re-scanning the old PATH would report the same absence as though it were news.

func (*Service) SetConfiguredBin

func (s *Service) SetConfiguredBin(fn func(id string) string)

SetConfiguredBin wires where Detect reads a provider's binary setting from. The settings store cannot be reached from here — it imports this package to key those settings — so main.go hands the reader in, exactly as it does the PATH refresh.

func (*Service) SetPathRefresh

func (s *Service) SetPathRefresh(fn func() error)

SetPathRefresh wires what a re-check re-reads the machine's PATH with. It is one resolution feeding several readers — the process PATH exec.LookPath goes through, the environment a new session inherits, the editor lookup — so main.go owns the applying and this package only asks for it.

func (*Service) Verify

func (s *Service) Verify(_ context.Context, opts api.BinaryOptions) (Check, error)

Verify answers verify over RPC.

func (*Service) Version

func (s *Service) Version(ctx context.Context, opts api.BinaryOptions) (string, error)

Version runs opts.Bin (resolved as Verify resolves it) with `--version` and returns the version it printed. It is the slow half of what Detect answers, kept out of it: a probe boots the whole CLI, and Detect runs on every launch menu.

The probe inherits lich's own environment, PATH pinned from the login shell, so a shim that picks its version from the user's config answers as it would inside a session.

Jump to

Keyboard shortcuts

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