preflight

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 19 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 preflight checks the tools the runtime needs on the machine — tmux, git, Claude Code, Codex — the way the person's own login shell finds them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthDirOf

func AuthDirOf(file string) string

AuthDirOf reads `auth_directory` from the machine's runtime config, the folder its chats sign in from.

func Version

func Version(stdout string) *string

Version is the first dotted version number in a tool's output.

Types

type Antigravity

type Antigravity struct {
	Installed  bool               `json:"installed"`
	Version    *string            `json:"version"`
	BinaryPath *string            `json:"binaryPath"`
	LoggedIn   bool               `json:"loggedIn"`
	Uncertain  bool               `json:"uncertain,omitempty"`
	Models     []AntigravityModel `json:"models"`
}

Antigravity keeps authentication evidence separate from executable discovery.

type AntigravityModel

type AntigravityModel struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

AntigravityModel is a model actually reported by agy models.

type Checker

type Checker struct {
	Home string
	// Env is the environment the runtime started with; the login shell gets the person's part of it.
	Env []string
	// Shell is the person's login shell ("" — the account's, else $SHELL, else /bin/bash).
	Shell string
	// AuthDir is the login folder a managed machine keeps Claude's sign-in in ("" — the CLI's own): the chats get it
	// as CLAUDE_SECURESTORAGE_CONFIG_DIR, so the probe asks with it too.
	AuthDir string
	// contains filtered or unexported fields
}

Checker runs the checks and keeps the answer for half a minute.

func New

func New(home string) *Checker

func Shared

func Shared(home string) *Checker

Shared is the process's one Checker of a home: its answers are kept once, not once per part of the runtime that asks (each New has a cache of its own, and each cache started the CLIs again).

func (*Checker) AntigravityStatus

func (c *Checker) AntigravityStatus() Antigravity

AntigravityStatus shares the runtime's minute-cached, bounded native CLI probe.

func (*Checker) Invalidate

func (c *Checker) Invalidate()

Invalidate drops the cached answer and the Codex probe: the next Runtime checks again, even while a check runs.

func (*Checker) LoginCmd added in v0.16.5

func (c *Checker) LoginCmd(ctx context.Context, script string, extraEnv ...string) (*exec.Cmd, error)

LoginCmd is the login shell set up to run an sh script, not yet started: the shell reads the profile, then hands the script to sh. extraEnv (KEY=VALUE) is added to the shell's environment. Whoever starts it decides what its input and output are (RunLogin reads the output; a login in a terminal gives it a terminal).

func (*Checker) LoginShell added in v0.16.16

func (c *Checker) LoginShell() string

LoginShell is the account's shell from the password file, else $SHELL, else /bin/bash.

func (*Checker) Report added in v0.16.5

Report is the machine's preflight for the hub: what the system is, how much disk and memory it has, and which tools are there, with a verdict per concern. It looks again at the tools each time (the answer of Runtime is kept for 30 s).

func (*Checker) RunLogin added in v0.16.5

func (c *Checker) RunLogin(ctx context.Context, script string, extraEnv ...string) (LoginResult, error)

RunLogin runs an sh script in the account's login shell: the shell reads the profile, then hands the script to sh. extraEnv (KEY=VALUE) is added to the shell's environment. The error is for a shell that did not run the script at all, or ran out of time; a script that exits non-zero is a result.

func (*Checker) Runtime

func (c *Checker) Runtime() Result

Runtime is the cached answer, checked again once it is older than 30 seconds; concurrent callers share one check.

func (*Checker) SetAntigravityBinary

func (c *Checker) SetAntigravityBinary(binary string)

SetAntigravityBinary selects the launcher's binary for native probes. Empty uses agy on the login PATH, then ~/.local/bin; an explicit binary never falls back. Shared Checkers drop both cached answers only when the selection changes.

func (*Checker) ShellPath

func (c *Checker) ShellPath() string

ShellPath is the PATH the person's interactive login shell builds, else the runtime's own (getShellPath).

type Claude

type Claude struct {
	Installed  bool    `json:"installed"`
	Version    *string `json:"version"`
	BinaryPath *string `json:"binaryPath"`
	// LoggedIn is what `claude auth status` says (exit 0); a probe that ran out of time counts as signed in, as it
	// does not prove the opposite. A ~/.claude folder says nothing: the CLI makes it on its first start, signed in or not.
	LoggedIn bool `json:"loggedIn"`
	// Unchecked: the runtime's screen reading was not checked against this version (cliversion's table).
	Unchecked bool `json:"unchecked,omitempty"`
}

type Codex

type Codex struct {
	Installed  bool    `json:"installed"`
	Version    *string `json:"version"`
	BinaryPath *string `json:"binaryPath"`
	// LoggedIn is what `codex login status` says (exit 0); a probe that ran out of time counts as signed in, as it
	// does not prove the opposite.
	LoggedIn bool `json:"loggedIn"`
}

type LoginResult added in v0.16.5

type LoginResult struct {
	// Stdout is what the script printed, without what the shell's profile printed before it.
	Stdout string
	// Exit is the script's exit code.
	Exit int
}

LoginResult is a script run through the login shell.

type ReportOptions added in v0.16.5

type ReportOptions struct {
	// WorkDir is the folder whose filesystem the disk numbers are about (the runtime's work folder).
	WorkDir string
	// HubURL is the hub's public address; its Date header is the clock the machine is compared with. "": no clock check.
	HubURL string
	// HTTP fetches the hub's date (nil: http.DefaultClient).
	HTTP *http.Client
	// Now is the clock (nil: time.Now).
	Now func() time.Time

	// The next three are for tests: where /proc/meminfo, the cgroup and os-release live, and a disk probe.
	MeminfoFile, CgroupDir, OSReleaseFile string
	Disk                                  func(path string) (total, free int64, err error)
}

ReportOptions say what a report looks at beyond the tools.

type Result

type Result struct {
	Tmux        Tmux        `json:"tmux"`
	Git         Tool        `json:"git"`
	Claude      Claude      `json:"claude"`
	Codex       Codex       `json:"codex"`
	Antigravity Antigravity `json:"antigravity"`
}

Result is the runtime's preflight answer.

type Tmux

type Tmux struct {
	Tool
	Compatible bool `json:"compatible"`
}

type Tool

type Tool struct {
	Installed bool    `json:"installed"`
	Version   *string `json:"version"`
	// Uncertain: the check ran out of time on a busy machine, the tool was not proven missing.
	Uncertain bool `json:"uncertain,omitempty"`
}

Tool is one tool's state.

Jump to

Keyboard shortcuts

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