configchecks

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 9 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 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

View Source
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.

View Source
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.

View Source
const MinTmuxVersion = "3.0"

MinTmuxVersion is the requirement, phrased for the user.

Variables

This section is empty.

Functions

func AddAgentInstructions

func AddAgentInstructions(path string) error

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

func AgentInstructionsFile(env Env, dir string) string

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

func HasAgentInstructions(env Env, path string) bool

HasAgentInstructions reports whether a file already points agents at `sidecar --agents`.

func HomebrewAvailable

func HomebrewAvailable(env Env) bool

HomebrewAvailable reports whether `brew` is on PATH.

func TerminalName

func TerminalName(env Env) string

TerminalName is the display name for the detected terminal, or "" when Sidecar does not recognize it.

func TmuxInstallCommand

func TmuxInstallCommand(env Env) string

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

func TmuxRepairPrefillable(env Env) bool

TmuxRepairPrefillable reports whether the recommended command is safe to prefill into a shell: a real command, and never one that needs sudo.

func TruecolorAvailable

func TruecolorAvailable(env Env) bool

TruecolorAvailable reports whether the terminal advertises 24-bit color.

func TruecolorEvidence

func TruecolorEvidence(env Env) []string

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.

func DefaultEnv

func DefaultEnv() Env

DefaultEnv is the real environment.

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.

const (
	RepairNone              RepairID = ""
	RepairTmux              RepairID = "repair-tmux"
	RepairTerminalColors    RepairID = "repair-terminal-colors"
	RepairAgentInstructions RepairID = "repair-agent-instructions"
	RepairAddProject        RepairID = "repair-add-project"
	RepairConfiguration     RepairID = "repair-configuration"
)

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

func (r Result) Actionable() bool

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

func Run(in Input) Results

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.

func (Results) Get

func (rs Results) Get(id ID) (Result, bool)

Get returns a result by ID.

func (Results) Healthy

func (rs Results) Healthy() Results

Healthy returns the results that are fine, in check order.

func (Results) Problems

func (rs Results) Problems() Results

Problems returns the results that need attention, in check order.

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

type TmuxVersion struct {
	Major, Minor int
	Raw          string
}

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

Jump to

Keyboard shortcuts

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