Documentation
¶
Overview ¶
Package tools is abcd's explain-then-install mode (itd-63): the curated registry of the external tools abcd knows, the plain-language explanation a verb gives when it finds one missing, and the one place a confirmed install step is run.
It is a MODE other verbs call, never a surface of its own (the product thinker's decision 3, 2026-09-21): a verb that finds a tool missing asks Explain for what to say and, where it offers the install, hands Install a Confirm function its front door supplies. The package has no transport knowledge — it never reads a terminal and never writes to stdout — so the CLI asks on the terminal, the plugin page asks through the host's question tool, and this code is the same under both (criterion 5).
The trust boundary is Install. What it fetches is fixed data compiled into the binary (release.go): one release download per platform, named by its full URL with its sha256 pinned beside it, never composed from a flag, a repository file or an environment value, and never discovered (brief invariant 7: no version-discovery request exists anywhere in abcd). It runs only after the caller's Confirm returns yes, never in CI, writes nothing until the download has passed its check, and needs no admin rights. See install.go and adr-2610241057124151.
Index ¶
- Variables
- func GuardForms(guard string) []string
- func Known(name string) bool
- func LookPath(name, dir string) (string, error)
- func Missing(cause error, name string, capability Capability) error
- func Names() []string
- func Resolve(name string) (string, error)
- func SwapNetworkForTest(get func(ctx context.Context, url string, limit int64) ([]byte, error), ...) (restore func())
- func WithinTree(p, resolved, guard string) bool
- type Answer
- type Archive
- type Asset
- type Attester
- type Capability
- type Confirm
- type Copy
- type Download
- type Explanation
- type Installed
- type Installer
- type MissingError
- type Plan
- type PlanAction
- type Record
- type Release
- type Removal
- type Requirement
- type Result
- type Route
- type Signer
- type Tool
- type Use
- type VersionRange
Constants ¶
This section is empty.
Variables ¶
var ErrInsideWorkingTree = errors.New("it lies inside the directory abcd runs from or the working tree that directory is in; " +
"a program there is repository content and is never run")
ErrInsideWorkingTree is LookPath's refusal: PATH found the program inside the directory abcd runs from, or inside a working tree that directory lies in, where a program is repository content and is never run.
var ErrLinksDoNotEnd = fmt.Errorf("its links do not end within %d steps", maxWalkLinks)
ErrLinksDoNotEnd is Walk's answer when more than maxWalkLinks links lie on the route, as a loop's do.
var ErrReadOtherwise = errors.New("a link on its way is read otherwise by the system")
ErrReadOtherwise is Walk's answer when its route is not the one a reader of the path and its link texts would take, or does not end where filepath.EvalSymlinks ends.
Functions ¶
func GuardForms ¶
GuardForms is every tree a guard holds a program outside of: the guard itself and each working tree it lies in (gitutil.WorkingTreesAround, the account's own home aside), so a guard naming a subdirectory of a checkout holds the whole checkout, and a submodule's the superproject as well. Each is given as written, cleaned, and at its real location by Walk, the reading every route held to it is in, so a guard under a linked directory (macOS's /var and /tmp) is met in the form a route reaches it. A guard Walk refuses keeps the system's own resolution instead, and one that does not resolve keeps its written form alone.
func LookPath ¶
LookPath is where abcd runs a program it finds by name on PATH: the PATH lookup, held to the in-checkout rule (WithinTree). A result that lies inside dir or the process's working directory, or inside any working tree either lies in, lexically, after symlinks or through any link on its route, is refused with ErrInsideWorkingTree; dir "" holds the working directory alone. PATH is read as it is and never changed, so what the person's own shell runs is untouched. A working directory that cannot be read holds nothing of its own; dir still does.
func Missing ¶
func Missing(cause error, name string, capability Capability) error
Missing wraps cause with the explanation for name as capability uses it.
func Resolve ¶ added in v0.16.0
Resolve is where abcd runs name from: abcd's own recorded copy when there is one, it is intact and its version lies in the range abcd works with, whatever comes first on PATH (the intent's fourth criterion), and otherwise the PATH lookup held to the in-checkout rule (LookPath, from the process's working directory). The record is read only from a home the home rule admits (readRecord), so a home inside a working tree that is not the account's own names no copy and the PATH lookup decides. Every caller that runs a registered tool resolves it here, never by a bare exec.LookPath.
func SwapNetworkForTest ¶ added in v0.16.0
func SwapNetworkForTest(get func(ctx context.Context, url string, limit int64) ([]byte, error), attest Attester) (restore func())
SwapNetworkForTest makes Default download through get and check signed build records through attest, for a test of another package that drives an install to a yes. It returns the restore.
func WithinTree ¶ added in v0.12.0
WithinTree reports whether the program at p, which resolves to resolved after symlinks, lies inside the tree at guard or any working tree guard lies in (GuardForms), judged lexically and after symlink resolution on both sides, and with the location of every link on p's route held to the tree (Walk): a step of its link chain and a directory link in the middle of a folder path alike. It is the one in-checkout judgement for a program: the installer refuses to run what it holds, and ahoy's presence check does not count it as installed. Both p and guard are absolute; the caller has already resolved p. A step that cannot be examined counts as inside, the closed direction; the installer's own checks judge through treeContains instead, which keeps the two apart, so their refusals say which one stopped them.
Types ¶
type Answer ¶
Answer is a caller's reply to the install question: yes or no, and in words how the reply was reached (typed at a terminal, named with a flag, no terminal to ask at), which the result repeats so a no is never silent.
type Asset ¶ added in v0.16.0
type Asset struct {
// URL is the release asset's full https://github.com/<repo>/releases/download/
// address: no "latest", no redirect a release page could move.
URL string
// SHA256 is the asset's digest, copied from the release's published
// checksums file and checked against the downloaded bytes when it was
// pinned. It is the check every download must pass before anything is
// written.
SHA256 string
// Archive is the asset's packaging.
Archive Archive
// Member is the program's path inside the archive.
Member string
}
Asset is one platform's download.
type Attester ¶ added in v0.16.0
Attester checks an asset's build provenance against a Signer, returning the verified signer identity.
type Capability ¶
type Capability string
Capability names what a verb is doing when it finds a tool missing. The same tool is optional for one capability and required for another, so an explanation is always for a (tool, capability) pair.
const ( // TranscriptScan is the secret scan of captured session transcripts in a // repository that has NOT armed gitleaks: the native scanner covers it. TranscriptScan Capability = "transcript-scan" // TranscriptScanArmed is the same scan in a repository that armed gitleaks // in .abcd/config/gitleaks.json: without the binary a release refuses, // while the history store still stores the transcript on the native // scanner and names the gap in its receipt (the 2026-09-25 ruling on // iss-2608291814575788). TranscriptScanArmed Capability = "transcript-scan-armed" // GitHubSettings is every verb that reads or changes the repository's // settings on GitHub (ahoy remote, site setup), which abcd does only // through gh. GitHubSettings Capability = "github-settings" )
type Confirm ¶
type Confirm func(Explanation) Answer
Confirm asks the person whether to run the install the explanation shows. The front door supplies it; a nil Confirm is a no.
type Copy ¶ added in v0.16.0
type Copy struct {
// Path is where it is, in the tilde form.
Path string `json:"path"`
// Version is the version it reports, or "" when it reported none.
Version string `json:"version,omitempty"`
// Compatible reports that Version lies in the range abcd works with.
Compatible bool `json:"compatible"`
// Why says why it is not compatible.
Why string `json:"why,omitempty"`
// Unjudged reports that its version was not read (Installer.PathOnly).
Unjudged bool `json:"unjudged,omitempty"`
// contains filtered or unexported fields
}
Copy is one copy of a tool on the machine.
type Download ¶ added in v0.16.0
type Download struct {
Version string `json:"version"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
// Member is the program's path inside the archive.
Member string `json:"member"`
// Dest is where the program is written, in the tilde form.
Dest string `json:"dest"`
// Checks is how far the download is checked.
Checks string `json:"checks"`
// ChecksumOnly reports a tool whose makers publish no signed build record.
ChecksumOnly bool `json:"checksum_only"`
// contains filtered or unexported fields
}
Download is the checked download an install would make.
type Explanation ¶
type Explanation struct {
Tool string `json:"tool"`
Known bool `json:"known"`
Capability Capability `json:"capability"`
CapabilityName string `json:"capability_name,omitempty"`
Requirement Requirement `json:"requirement,omitempty"`
What string `json:"what,omitempty"`
Homepage string `json:"homepage,omitempty"`
Does string `json:"does,omitempty"`
WithoutIt string `json:"without_it,omitempty"`
NativeDefault string `json:"native_default,omitempty"`
OnDecline string `json:"on_decline,omitempty"`
// Download is the checked download Install would make on this platform:
// the pinned version, its full URL and sha256, where the program goes and
// how far it is checked. nil when the registry names none (an unknown
// tool, or a platform abcd's release holds no download for).
Download *Download `json:"download,omitempty"`
// Plan is what Install found on this machine before it asked: the copy
// already installed and whether it is compatible, and which copy will
// run. Set only on the explanation Install hands its Confirm.
Plan *Plan `json:"plan,omitempty"`
Effects string `json:"effects,omitempty"`
Verify []string `json:"verify,omitempty"`
// RegistryGap is set for a tool the registry does not know: the gap is
// abcd's own, and this names the capture that records it.
RegistryGap string `json:"registry_gap,omitempty"`
}
Explanation is what a verb says when it finds a tool missing (criterion 1): the tool, whether it is optional or required for this capability, what works without it, what it would do, and the exact install step, all from the registry. It is structured so each front door renders it its own way (the plugin page reads it from a verb's --json); Lines is the plain-text rendering every front door shares.
func Explain ¶
func Explain(name string, capability Capability) Explanation
Explain renders the explanation for name as capability uses it, on the running platform, into the running account's bin folder.
func (Explanation) Lines ¶
func (e Explanation) Lines() []string
Lines is the plain-text explanation, one line per part, the first naming the tool and whether it is optional or required.
func (Explanation) ManualText ¶ added in v0.16.0
func (e Explanation) ManualText() string
ManualText is the same install for a person to make by hand: the exact URL, the sha256 to check it against, and where the program goes.
func (Explanation) StepText ¶
func (e Explanation) StepText() string
StepText is the install as a person reads it in the install question, or the reason there is none. It never names a step that needs admin rights.
type Installed ¶ added in v0.16.0
type Installed struct {
// Path is the program's absolute path.
Path string `json:"path"`
// SHA256 is the digest of the bytes abcd wrote there.
SHA256 string `json:"sha256"`
// Version is the pinned release it came from.
Version string `json:"version"`
// AssetSHA256 is the digest of the downloaded archive, which matched the
// pin.
AssetSHA256 string `json:"asset_sha256"`
// Checked is how far the download was checked, as the result said it.
Checked string `json:"checked"`
}
Installed is one copy abcd installed.
type Installer ¶
type Installer struct {
// LookPath resolves a bare program name on the operator's PATH.
LookPath func(string) (string, error)
// Run executes an argv whose argv[0] is already resolved, without a shell.
Run func(context.Context, []string) ([]byte, error)
// Getenv reads the environment (CI detection, PATH, the XDG folders).
Getenv func(string) string
// GOOS and GOARCH select the platform's download.
GOOS, GOARCH string
// Guard is the directory a program abcd runs, and the bin folder it
// writes into, must lie outside: the directory the verb was run from, held
// with every working tree it lies in (GuardForms), so a verb run from a
// subdirectory holds the whole checkout.
Guard string
// Home is the person's home directory: the record lives below it, and
// ~/.local/bin is the default bin folder.
Home string
// Get downloads one URL whole, bounded to limit bytes.
Get func(ctx context.Context, url string, limit int64) ([]byte, error)
// Attest checks a download's signed build record.
Attest Attester
// Release is the pinned release for a registered tool; the registry's by
// default, replaced in tests to point a download at a local server.
Release func(name string) (Release, bool)
// PathOnly makes Plan start no program: a copy the PATH finds counts as
// usable without its version being read. The detection pass the hooks
// run sets it; an install never does.
PathOnly bool
}
Installer installs the registry's tools. Every process-, network- and home-touching seam is a field so the whole decision path is exercised in tests with no network and no real home; Default is the production wiring.
func Default ¶
Default is the production installer for a verb run from guard (its repository root, or its working directory outside one). Inside a test binary its network is the one SwapNetworkForTest installed, and by default none: a test that reaches a yes is refused the download rather than making one, so no test of another package can fetch a real release.
func (*Installer) Install ¶
func (in *Installer) Install(name string, capability Capability, confirm Confirm) Result
Install is the trust boundary. In order, and each refusal writes nothing:
- An unknown tool is refused: nothing is composed from a name.
- CI never installs, and is not asked.
- The plan is made: an intact copy of abcd's own, or a compatible copy installed some other way, is used and nothing is asked or installed; a platform with no download, or a bin folder whose program abcd did not install, is refused.
- The caller's Confirm must return yes; nil is a no.
- The bin folder must lie outside the guarded tree.
- The download is fetched whole, bounded, over https from GitHub alone, and its sha256 must equal the one abcd's release pins.
- A tool whose makers sign their builds must carry a signed build record that verifies against the pinned signer.
- The program is read out of the archive by its exact name.
Only then is the program written, atomically, at the account's own rights; the verify command must then report the pinned version, and the copy is recorded so abcd runs it by its path. A copy that fails the verify, or cannot be recorded, is removed again.
func (*Installer) Plan ¶ added in v0.16.0
Plan decides what to do about name. It never downloads, never writes, and runs only the verify command of a copy PATH already finds, to read its version, and not even that under PathOnly.
abcd's own recorded copy is used only while its version lies in the range abcd works with and is the one abcd's release pins. A copy of abcd's at another version in the range still runs, and the pin is offered as an upgrade over it; one outside the range is not run, and abcd's pinned copy is offered in its place. Either way the download replaces only a copy that is still the bytes abcd wrote (Install).
type MissingError ¶
type MissingError struct {
Cause error
Explanation Explanation
}
MissingError is a verb's refusal for a missing tool with the registry's explanation appended: the refusal stands exactly as it was (its cause stays reachable through errors.Is), and only its message grows to say what the tool is, whether this capability needs it, and the exact install step.
func (*MissingError) Error ¶
func (m *MissingError) Error() string
func (*MissingError) Unwrap ¶
func (m *MissingError) Unwrap() error
type Plan ¶ added in v0.16.0
type Plan struct {
Tool string `json:"tool"`
Action PlanAction `json:"action"`
// Pinned is the version abcd's release fixes.
Pinned string `json:"pinned,omitempty"`
// Compatible is the range of versions abcd works with, as a person reads
// it.
Compatible string `json:"compatible,omitempty"`
// Download is the checked download, when one is offered.
Download *Download `json:"download,omitempty"`
// Existing is the copy PATH finds first, when it is not abcd's own.
Existing *Copy `json:"existing,omitempty"`
// Owned is abcd's own recorded copy, when one is in place.
Owned *Copy `json:"owned,omitempty"`
// Runs says which copy abcd runs, and which the person's shell runs.
Runs string `json:"runs,omitempty"`
// Upgrade reports that the download replaces abcd's own copy, which
// still works, with the version abcd's release pins.
Upgrade bool `json:"upgrade,omitempty"`
// Why says why the tool is unavailable.
Why string `json:"why,omitempty"`
}
Plan is what setup would do about one tool, decided from the disk, the PATH and the version the copy already installed reports, with no network: the core API a setup flow lays out before it asks anything. It prints nothing.
type PlanAction ¶ added in v0.16.0
type PlanAction string
PlanAction is what setup does about one tool.
const ( // UseOwned: abcd's own recorded copy is in place and intact. UseOwned PlanAction = "use-abcd-copy" // UseExisting: a copy installed some other way is compatible, so it is // used and nothing is installed. UseExisting PlanAction = "use-existing" // InstallOwn: no compatible copy is in place, so abcd offers its own. InstallOwn PlanAction = "install" Unavailable PlanAction = "unavailable" )
type Record ¶ added in v0.16.0
type Record struct {
SchemaVersion int `json:"schema_version"`
Tools map[string]Installed `json:"tools"`
}
Record is the installed-tools record.
type Release ¶ added in v0.16.0
type Release struct {
// Repo is the tool's GitHub repository, owner/name.
Repo string
// Version is the pinned release, without its leading v.
Version string
// Assets is the download for each platform abcd supports, keyed
// "<GOOS>/<GOARCH>". A platform with no entry has no install.
Assets map[string]Asset
// Signer is who must have signed the asset's SLSA build provenance, for a
// tool whose makers publish one. nil is a tool that publishes no signed
// build record: its download is checked by checksum only, and every
// explanation and result says so.
Signer *Signer
// Compatible is the range of the tool's versions abcd works with. A copy
// already installed is used, and nothing installed, only when its version
// falls inside it (the intent's third criterion). The pinned Version must
// fall inside it too (TestEveryPinnedReleaseIsCompatible), which is the
// hook a release-time compatibility check moves (iss-2610240959030370).
// The version is read from the output of the tool's Verify argv.
Compatible VersionRange
}
Release is the one build of a tool abcd installs, fixed in abcd's own release (brief invariant 7: "provisioning fetches only a manifest-named, pinned, checksum-verified artifact. No version-discovery request exists anywhere in abcd"). Every field is compiled in: the download URL is spelled out in full, the asset's sha256 is pinned beside it, and nothing about it is read from the network, a flag, a repository file or the environment. A tool therefore updates only when abcd does (dcn-2610240845548776, and the intent's third decision).
type Removal ¶ added in v0.16.0
type Removal struct {
Tool string `json:"tool"`
Path string `json:"path"`
Removed bool `json:"removed"`
Note string `json:"note"`
}
Removal reports what uninstall did with one recorded copy.
func Uninstall ¶ added in v0.16.0
Uninstall removes the copies the record in home names, and only those, and only while each is still the bytes abcd wrote: a file changed since, or replaced by another, is left where it is and said so. The record goes once nothing it names is still abcd's to remove. Nothing else is touched: a copy installed some other way was never recorded, so it is never reached.
type Requirement ¶
type Requirement string
Requirement is whether a capability needs a tool or merely works better with it (adr-22: most dependencies are optional adapters over a native default).
const ( // Optional: the capability runs on its native default without the tool. Optional Requirement = "optional" // Required: the capability cannot run without the tool. Required Requirement = "required" )
type Result ¶
type Result struct {
Tool string `json:"tool"`
// Ready reports that a copy abcd can run is in place: one already
// installed and compatible, abcd's own recorded copy, or the one this
// install wrote and verified.
Ready bool `json:"ready"`
// Ran reports that a download was started.
Ran bool `json:"ran"`
// Installed reports that the checked program was written into the bin
// folder.
Installed bool `json:"installed"`
// Verified reports that the verify command ran the written copy and it
// reported the pinned version.
Verified bool `json:"verified"`
// Declined reports that nobody said yes (a no, no confirmation, CI).
Declined bool `json:"declined"`
// Path is the copy abcd runs, in the tilde form, when Ready.
Path string `json:"path,omitempty"`
// Version is the version of that copy.
Version string `json:"version,omitempty"`
// Checked is how far the download was checked, when one was written.
Checked string `json:"checked,omitempty"`
// ChecksumOnly reports that the download was checked by its pinned sha256
// alone, because its makers publish no signed build record.
ChecksumOnly bool `json:"checksum_only,omitempty"`
// Runs says which copy abcd runs, and which one the person's shell runs.
Runs string `json:"runs,omitempty"`
// Why is the reason nothing was written, or what failed.
Why string `json:"why,omitempty"`
// Output is the bounded tail of the verify command's output on a failure,
// or its first line on success.
Output string `json:"output,omitempty"`
// OnDecline is the capability's standing after a no or a failure.
OnDecline string `json:"on_decline,omitempty"`
// contains filtered or unexported fields
}
Result reports one Install: whether a compatible copy is ready for abcd to run, what was downloaded and how far it was checked, or why nothing was written and what the capability continues on.
type Route ¶
type Route struct {
// Real is the path with every link resolved: the file the system opens.
// When Missing, it is where the system would look: the resolved part of
// the route joined with the parts it did not reach.
Real string
// Links is the location of every link the route passed, in order: the
// directory it lies in, itself resolved, joined with its own name. A
// directory link in the middle of a folder path is one of them as much as
// a link the path ends at.
Links []string
// Dirs is every real directory the route passed through, in the order it
// first reached each, "/" first.
Dirs []string
// Missing is true when a part of the route does not exist, a dangling
// link's target included; the walk stops there, as the system does.
Missing bool
}
Route is how the system reaches a path.
func Walk ¶
Walk resolves the absolute path p the way the system does: from "/", one part at a time, with each prefix examined by Lstat. A link's own location (its directory, already resolved, joined with its name) is recorded, and its target is spliced in where it was reached: an absolute target restarts at "/", a relative one continues from the directory the link lies in. ".." leaves the resolved directory, never the text, and a part after a file that is not a directory is refused as the system refuses it (not a directory).
Two routes are refused as read otherwise (ErrReadOtherwise). One is a ".." that a text places straight after a directory link written in the same text, when the link's target does not lie beside it (d/../x, d -> /elsewhere/sub): the system takes that ".." from where d leads and a reader of the text from where d sits, so the route is not the one its text shows. The other is a route that does not end where filepath.EvalSymlinks(p) ends, or, when the walk stops at a missing part, where EvalSymlinks finds something; the walk is cross-checked against it so that a difference between the two readings refuses rather than admits.
A route with more than 40 links is refused (ErrLinksDoNotEnd). Any other failure to examine a part is the *fs.PathError that says why.
type Signer ¶ added in v0.16.0
type Signer struct {
Repo string // owner/name
Workflow string // path of the signing workflow inside the repository
Ref string // the git ref the signing workflow ran from
}
Signer is a build-provenance policy: the certificate identity a Sigstore bundle over the asset must carry. It is pinned exactly (no prefix match): the repository, the workflow file inside it, and the ref that workflow ran from. The digest is pinned in abcd's own source, so the provenance is not bound to a commit: it proves the pinned bytes were built by the makers' workflow, which a release page edit cannot forge (provenance.go's rationale).
type Tool ¶
type Tool struct {
Name string
What string // what the tool is, plainly
Homepage string // where to read what it is
Uses map[Capability]Use
// Release is the one build of the tool abcd installs: its version, its
// download per platform with the sha256 pinned here, and how far its
// makers let a download be checked (release.go).
Release Release
// Effects is what the install does on the machine and over the network, and
// what it does not.
Effects string
// Verify is the argv that proves the tool runs once installed; argv[0] is
// the tool's name, replaced by the absolute path of the copy being judged.
Verify []string
}
Tool is one registry entry.
type Use ¶
type Use struct {
// Capability is the capability's human name.
Capability string
// Requirement is optional or required, for this capability.
Requirement Requirement
// Does is what abcd uses the tool for here.
Does string
// WithoutIt is what works without the tool (for an optional use, the
// native default; for a required one, what fails and the way back).
WithoutIt string
// NativeDefault is what the capability continues on after a no; empty when
// there is none.
NativeDefault string
// OnDecline is the loud line's tail after a no or a failed install:
// "continuing on <native default>" for an optional use, the standing
// refusal for a required one.
OnDecline string
}
Use is what one capability does with a tool, in the words a person reads.
type VersionRange ¶ added in v0.16.0
VersionRange is [Min, Below): Min inclusive, Below exclusive. Below empty means no upper bound.
func (VersionRange) Contains ¶ added in v0.16.0
func (r VersionRange) Contains(v string) bool
Contains reports whether v lies in the range. A version that does not parse lies in no range.
func (VersionRange) String ¶ added in v0.16.0
func (r VersionRange) String() string
String is the range as a person reads it.