Documentation
¶
Overview ¶
Package configchecks answers "is Sidecar ready to work here?" It is the decision layer behind Sidecar Setup and Diagnostics: it inspects the environment and the configuration, and reports what it found, why it matters, and which focused repair route addresses it.
Nothing here renders, and nothing here mutates as a side effect of checking. The one mutation the package offers — adding the Sidecar line to a project's agent instructions — is an explicit call a caller makes only after the user has seen the exact addition and confirmed it.
Every check reaches the outside world through Env, so tests describe an environment instead of arranging one.
Index ¶
- Constants
- func AddAgentInstructions(path string) error
- func AgentInstructionsAddition() string
- func AgentInstructionsFile(env Env, dir string) string
- func HasAgentInstructions(env Env, path string) bool
- func HomebrewAvailable(env Env) bool
- func TerminalName(env Env) string
- func TmuxInstallCommand(env Env) string
- func TmuxRepairPrefillable(env Env) bool
- func TruecolorAvailable(env Env) bool
- func TruecolorEvidence(env Env) []string
- type Env
- type ID
- type Input
- type RepairID
- type Result
- type Results
- type TerminalGuide
- type TmuxVersion
Constants ¶
const ( BadgeFix = "FIX" BadgeAdd = "ADD" BadgeOpen = "OPEN" )
Badge labels the action a row offers. An empty badge is a quiet, healthy row that must not look clickable.
const AgentInstructionLine = "Always check if you are running in Sidecar: run sidecar --agents for capabilities."
AgentInstructionLine is the entire recommended addition. `sidecar --agents` is the canonical, always-current reference, so the project file points at it rather than duplicating guidance that would go stale in every repository that copied it.
const MinTmuxVersion = "3.4"
MinTmuxVersion is the requirement, phrased for the user.
Variables ¶
This section is empty.
Functions ¶
func AddAgentInstructions ¶
AddAgentInstructions inserts the Sidecar line into a project's agent file.
It is never called by a check. A caller reaches it only after showing the user AgentInstructionsAddition and receiving confirmation, and it never overwrites: existing content is preserved and the line is inserted after any YAML frontmatter and the file's opening heading, which is where a reader looking for project instructions starts.
func AgentInstructionsAddition ¶
func AgentInstructionsAddition() string
AgentInstructionsAddition is the exact text a write would add, shown to the user before anything is written. There is nothing else in it: what is reviewed is what lands.
func AgentInstructionsFile ¶
AgentInstructionsFile returns the file the repair would touch: an existing AGENTS.md, else an existing CLAUDE.md, else the AGENTS.md that would be created. It returns "" when there is no project directory.
func HasAgentInstructions ¶
HasAgentInstructions reports whether a file already points agents at `sidecar --agents`.
func HomebrewAvailable ¶
HomebrewAvailable reports whether `brew` is on PATH.
func TerminalName ¶
TerminalName is the display name for the detected terminal, or "" when Sidecar does not recognize it.
func TmuxInstallCommand ¶
TmuxInstallCommand is the command Sidecar recommends for this machine. It is only ever shown or prefilled — never executed by Sidecar, and never with sudo on a machine where Homebrew can do the job without it.
func TmuxRepairPrefillable ¶
TmuxRepairPrefillable reports whether the recommended command is safe to prefill into a shell: a real command, and never one that needs sudo.
func TruecolorAvailable ¶
TruecolorAvailable reports whether the terminal advertises 24-bit color.
func TruecolorEvidence ¶
TruecolorEvidence is what the check observed, as displayable lines. Absent variables are shown as absent: "COLORTERM is not set" is the finding.
Types ¶
type Env ¶
type Env struct {
Getenv func(string) string
LookPath func(string) (string, error)
// Output runs a command and returns its combined stdout.
Output func(name string, args ...string) ([]byte, error)
// ReadFile reads a file. Repair routes share it so a test can describe a
// project's AGENTS.md without writing one.
ReadFile func(string) ([]byte, error)
// Stat reports whether a path exists and what it is.
Stat func(string) (os.FileInfo, error)
GOOS string
}
Env is everything the checks touch outside their own process state. The zero value is unusable; call DefaultEnv and override the pieces a test cares about.
type ID ¶
type ID string
ID names a check. It is the stable key a page looks a result up by.
const ( // CheckProjects is whether Sidecar knows where the user's code lives. CheckProjects ID = "projects" // CheckTmux is tmux availability and version. CheckTmux ID = "tmux" // CheckTerminalColors is 24-bit color capability. CheckTerminalColors ID = "terminal-colors" // CheckAgentInstructions is whether the active project's agent file points // agents at `sidecar --agents`. CheckAgentInstructions ID = "agent-instructions" // CheckConfiguration is whether the config file on disk still reads. CheckConfiguration ID = "configuration" )
type Input ¶
type Input struct {
// Config is the configuration the app is running with. The file on disk is
// re-read separately: the app loaded one at startup, but the file may have
// been edited since.
Config *config.Config
// ConfigPath is the config file to re-read. Empty means config.ConfigPath().
ConfigPath string
// ProjectDir is the active project's directory; empty when there is none.
ProjectDir string
// ProjectName is what to call that project in copy.
ProjectName string
Env Env
}
Input is what a run needs to know about this Sidecar.
type RepairID ¶
type RepairID string
RepairID names the focused route that addresses a problem. It is a plain string rather than a route type so the checks stay independent of the Configuration surface that renders them.
type Result ¶
type Result struct {
ID ID
Title string
OK bool
// Summary is the one-line detail shown beside the title, in either state.
Summary string
// Evidence is what the check actually observed, shown in the repair route
// so a user can see why Sidecar reached its conclusion.
Evidence []string
// Action and ActionDetail are how Sidecar Setup phrases the work when this
// check needs attention.
Action string
ActionDetail string
// Badge is the label on an actionable row; Repair is the route it opens.
Badge string
Repair RepairID
}
Result is one check's finding: its status, the evidence behind it, and the repair that addresses it.
func (Result) Actionable ¶
Actionable reports that this result should render as a control.
type Results ¶
type Results []Result
Results is a run's findings, in check order.
func Run ¶
Run performs every check. It does filesystem and subprocess work, so callers run it inside a tea.Cmd and cache the results — never on a render path.
type TerminalGuide ¶
type TerminalGuide struct {
// Key is the stable identifier for the terminal, or "" for the generic guide.
Key string
// Name is what the user calls it.
Name string
// Steps are the specific instructions, in order.
Steps []string
// Capable marks a terminal that supports truecolor natively, so the fault
// is almost always TERM or a tmux override rather than the emulator.
Capable bool
}
TerminalGuide is what Sidecar can tell a user about their specific terminal. It is a small static table: Sidecar recognizes a terminal or it does not, and when it does not it offers the generic path rather than guessing.
func IdentifyTerminal ¶
func IdentifyTerminal(env Env) (TerminalGuide, bool)
IdentifyTerminal names the terminal emulator Sidecar is running in, using TERM_PROGRAM first and the terminal-specific variables terminals set when it is absent. It returns the generic guide when nothing matches; false says the terminal was not recognized.
func (TerminalGuide) Instructions ¶
func (g TerminalGuide) Instructions() string
Instructions is the copyable form of a guide.
type TmuxVersion ¶
TmuxVersion is a parsed tmux version. Suffixed releases (3.2a) and development builds (next-3.6) reduce to their numeric part.
func ParseTmuxVersion ¶
func ParseTmuxVersion(out string) (TmuxVersion, bool)
ParseTmuxVersion reads the output of `tmux -V`. It reports false for the builds that carry no number at all (`tmux master`, some OpenBSD packages), which callers treat as "installed, version unknown" rather than as a fault.
func (TmuxVersion) AtLeast ¶
func (v TmuxVersion) AtLeast(major, minor int) bool
AtLeast reports whether the version meets a minimum.
func (TmuxVersion) String ¶
func (v TmuxVersion) String() string