Documentation
¶
Overview ¶
Package readiness answers "can this computer run agents yet, and if not, what is the next step?" — the setup checklist of Settings → Computers, Home, `caprock setup`, and the readiness a linked laptop reads through `/v1/m/{id}/v1/setup` (GET /v1/setup, ADR-099).
The owner's first two-computer test (a MacBook driving a Windows PC, 2026-11-20) found a PC without Git and Claude Code that nothing on either screen mentioned, and a laptop that showed the PC linked without saying whether it could do anything. Five items cover the path from a fresh install to "start agents from your laptop": Git, an agent, its sign-in, a project, the link. Each says in a sentence what to do, and the installs and sign-ins carry the command that does it — typed into a shell tab for the user to run, never run by Caprock (ADR-046).
Build is pure: the daemon gathers the facts (files, PATH, the pairing state) and Build words them, so every wording is tested on every OS.
Index ¶
- Constants
- Variables
- func AgentOn(id string, installed bool, chosen map[string]bool) bool
- func GHHosts(goos, home string, getenv func(string) string) string
- func GHSignedIn(hostsPath string, getenv func(string) string) bool
- func GitInstall(goos string) string
- func PathFix(goos, shell string) string
- func ToolInstall(goos, id string, brew bool) string
- type Agent
- type AgentRow
- type Git
- type GitFinder
- type Inputs
- type Item
- type Link
- type OffPath
- type Report
- type Tool
- type ToolFacts
- type ToolFinder
Constants ¶
const ( // OK: done. OK = "ok" // Missing: not done; Detail says what to do, Command does it when there // is one command for it. Missing = "missing" // Unknown: Caprock cannot tell from what it may read (Codex keeping its // sign-in in the system keyring). Offered, never ticked. Unknown = "unknown" // NotNeeded: does not apply on this computer. A client treats it as done. NotNeeded = "not_needed" )
The states of an item.
const ( KeyGit = "git" KeyAgent = "agent" // KeySignIn was the sign-in's own item until the agents became // switches (owner, 2026-11-20): each agent's row carries its sign-in now, // and the item is no longer sent. KeySignIn = "signin" KeyProject = "project" KeyLink = "link" )
The items, in the checklist's order.
const ( StepInstall = "install" StepPath = "path" StepSignIn = "signin" )
The steps an agent's row can be at.
const ( ToolNode = "node" ToolGH = "gh" // ToolGHAuth is the GitHub CLI's sign-in, by device flow: the code is // shown on the laptop (GET /v1/setup/runs). ToolGHAuth = "gh_auth" // ToolBypass is Claude Code's one-time bypass warning, accepted with // POST /v1/claude/bypass-consent (ADR-041). ToolBypass = "bypass" // ToolChrome is Claude in Chrome's "Enabled by default" (`/chrome` in // Claude Code): claudeInChromeDefaultEnabled in its global config. ToolChrome = "chrome_default" )
The tools, in the order the laptop lists them.
const ActionPath = "path"
ActionPath: the agent item's command adds ~/.local/bin to the user's PATH.
const GHLogin = "gh auth login --web --hostname github.com --git-protocol https"
GHLogin signs the GitHub CLI in by device flow: --web asks for no token, --hostname and --git-protocol skip the two questions they answer. gh then asks whether Git should use the sign-in (yes is its default) and waits for Enter before opening a browser; the run answers both (api, setup runs).
Variables ¶
var LocalBin = filepath.Join(".local", "bin")
LocalBin is the folder the agents' native installers use, under home.
Functions ¶
func AgentOn ¶ added in v0.185.1
AgentOn is an agent's switch: the user's choice when there is one (kept in the daemon's settings), else on when it is installed, and Claude Code on on a fresh computer; the rest off.
func GHHosts ¶ added in v0.198.0
GHHosts is the GitHub CLI's hosts.yml, where it records a signed-in host: $GH_CONFIG_DIR, else $XDG_CONFIG_HOME/gh, else %AppData%\GitHub CLI on Windows, else ~/.config/gh (`gh help environment`, GH_CONFIG_DIR).
func GHSignedIn ¶ added in v0.198.0
GHSignedIn reports whether the GitHub CLI holds a sign-in for github.com: a token in the environment it reads (GH_TOKEN, GITHUB_TOKEN), or a `github.com:` host in hosts.yml. Presence only, as ADR-099 reads every sign-in: the line naming the host is all that is looked at, never a token (gh keeps one in the system keyring, or in that file under the host).
func GitInstall ¶
GitInstall is the command that installs Git, "" where there is no single one (Linux: the distribution's package manager).
- Windows: winget's Git for Windows package (Git.Git), the install Claude Code's setup page points at (code.claude.com/docs/en/setup, read 2026-11-20). It asks for an administrator once.
- macOS: the Command Line Tools, which carry Git; macOS opens its own installer window.
func PathFix ¶ added in v0.185.1
PathFix adds ~/.local/bin to the user's PATH for terminals opened from now on, and does nothing when it is there already. Typed into a shell tab and run by the user's Enter, never by Caprock (ADR-046).
- Windows: the user's Path only (never the system's, which needs an administrator), through .NET, which also tells Windows the environment changed so terminals started afterwards see it. PowerShell, the shell tab's shell there; an empty user Path is handled.
- macOS and Linux: one export line appended to the login shell's file — ~/.zshrc for zsh, ~/.bash_profile for bash on macOS, ~/.bashrc for bash elsewhere, ~/.profile for anything else — only when that exact line is not there yet; fish has its own idempotent fish_add_path.
func ToolInstall ¶ added in v0.198.0
ToolInstall is the command that installs tool id here, "" where there is no single one.
Types ¶
type Agent ¶
type Agent struct {
ID string // "claude", "codex"
Label string // "Claude Code", "Codex"
// On is its switch, as AgentOn resolves it.
On bool
Installed bool
// Install is the catalog's install command (ADR-046).
Install string
// SignIn is OK, Missing or Unknown.
SignIn string
// SignInCommand is the agent's own sign-in.
SignInCommand string
// SignInText says what is missing in the agent's own words, for an
// agent whose sign-in is not a subscription file (OpenCode's provider).
SignInText string
// OffPath is the folder the agent was found in when a terminal opened
// now cannot find it there: installed, but not on the user's PATH
// (OffPathDir). "" when it is on the PATH, or the PATH could not be read.
OffPath string
}
Agent is one agent that can run here: Claude Code, Codex, OpenCode, Gemini CLI, Cursor, … — every built-in the catalog can install.
type AgentRow ¶ added in v0.185.1
type AgentRow struct {
ID string `json:"id"`
Label string `json:"label"`
// On is the switch: an agent switched off is grey, not counted, and
// its state is not_needed. Switching changes nothing but the setting.
On bool `json:"on"`
State string `json:"state"`
Detail string `json:"detail"`
// Step is install, path or signin while one is left; Command does it.
Step string `json:"step,omitempty"`
Command string `json:"command,omitempty"`
Action string `json:"action,omitempty"`
}
AgentRow is one agent under the agent item: switched on or off, its own state, and its one next step.
type Git ¶
type Git struct {
Found bool
// Fresh is false when the user's current PATH could not be read, so a Git
// installed after Caprock started may not be seen until it restarts.
Fresh bool
}
Git is what was found of Git.
type GitFinder ¶
type GitFinder struct {
GOOS string
// Dirs is the user's PATH as it is now (userenv.CurrentPath), split.
Dirs []string
// Env reads a variable (ProgramFiles, LOCALAPPDATA on Windows).
Env func(string) string
// IsFile reports whether a path is a regular file. Swapped by tests.
IsFile func(string) bool
}
GitFinder looks for Git without running it. Running `git --version` on a Mac without the Command Line Tools would open Apple's install dialog from a daemon on a timer, so the answer is read from the file system only.
type Inputs ¶
type Inputs struct {
GOOS string
Git Git
Agents []Agent
Projects int
Link Link
// Shell is the login shell's name ("zsh", "bash", "fish"): which file
// PathFix adds to on macOS and Linux.
Shell string
// CloneDir is where the Add project sheet clones by default — the folder
// set as default, else ~/dev — in full, so the project item says where.
CloneDir string
// Tools are the facts for the tools; nil leaves them out.
Tools *ToolFacts
}
Inputs are the facts Build words.
type Item ¶
type Item struct {
Key string `json:"key"`
State string `json:"state"`
Label string `json:"label"`
Detail string `json:"detail"`
// Command fixes it in a terminal: typed into a shell tab, or printed by
// `caprock setup`, never run by Caprock. The link's is a caprock command
// for a computer reached over SSH; its screen has its own buttons.
Command string `json:"command,omitempty"`
// Action says what Command does when it is not an install or a sign-in:
// ActionPath adds the agent's folder to the user's PATH. The button reads
// after it ("Add to PATH").
Action string `json:"action,omitempty"`
// Optional marks an item that never counts as a step left: the
// project. Its state is ok or not_needed, so a reader from before the
// field treats it as done too.
Optional bool `json:"optional,omitempty"`
}
Item is one line of the checklist.
type Link ¶
type Link struct {
// Supported is false in a build that cannot be reached through a relay.
Supported bool
// On: access from anywhere is on.
On bool
// Allowed are the computers allowed here, by name; Waiting those that
// redeemed a link and wait for Allow.
Allowed []string
Waiting []string
}
Link is how this computer stands with the computers that reach it.
type OffPath ¶ added in v0.185.1
type OffPath struct {
GOOS string
Home string
// Dirs is the PATH a terminal opened now gets (userenv.TerminalPath),
// split.
Dirs []string
// IsFile reports whether a path is a regular file. Swapped by tests.
IsFile func(string) bool
}
OffPath finds an agent installed in a well-known folder that is not on the PATH a terminal gets.
type Report ¶
type Report struct {
OS string `json:"os"`
Items []Item `json:"items"`
// Agents are the agent item's rows: every agent Caprock can start that
// has a way to be installed here, or is installed, each with its switch.
Agents []AgentRow `json:"agents,omitempty"`
// Tools are the steps past ready that a linked laptop runs here
// (tools.go, issue #1088): never counted by Ready.
Tools []Tool `json:"tools,omitempty"`
}
Report is GET /v1/setup.
type Tool ¶ added in v0.198.0
type Tool struct {
ID string `json:"id"`
Label string `json:"label"`
State string `json:"state"`
Detail string `json:"detail"`
// Command is what POST /v1/setup/run types and runs in a shell tab
// there; "" when there is no one command (no Homebrew, Linux), or the
// step is not a command (the bypass warning, Chrome's setting).
Command string `json:"command,omitempty"`
}
Tool is one of them, as GET /v1/setup sends it under `tools`.
func BuildTools ¶ added in v0.198.0
BuildTools words the tools.
type ToolFacts ¶ added in v0.198.0
type ToolFacts struct {
Node bool
GH bool
// GHSignedIn: the GitHub CLI holds a sign-in for github.com (GHHosts).
GHSignedIn bool
// Brew: Homebrew is installed (macOS), so `brew install` is the command.
Brew bool
// Claude: Claude Code is installed here; the bypass and Chrome rows are
// about it, and absent without it.
Claude bool
// Bypass: its bypass warning is accepted (hooks.BypassAccepted).
Bypass bool
// Chrome: claudeInChromeDefaultEnabled is true (hooks.ChromeDefault).
Chrome bool
}
ToolFacts are what the daemon found for the tools.
type ToolFinder ¶ added in v0.198.0
type ToolFinder struct {
GOOS string
Dirs []string
Env func(string) string
// IsFile reports whether a path is a regular file. Swapped by tests.
IsFile func(string) bool
}
ToolFinder looks for a program without running it, on the user's PATH as it is now and in its installers' own folders (GitFinder's way).
func (ToolFinder) Found ¶ added in v0.198.0
func (f ToolFinder) Found(id string) bool
Found reports whether tool id (ToolNode, ToolGH, "brew") is installed.