ahoy

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 56 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 ahoy is abcd's install/update engine for `abcd ahoy`. It follows a detect -> contract -> apply architecture: a single detection pass builds an in-memory DetectionResult (the ahoy-state shape) and every sub-verb (install, dry-run, doctor, bare status) is a thin consumer of that one pass. Idempotency is a property of detection, never a version stamp: every check compares actual on-disk/registry state.

The package performs I/O only under a caller-supplied cwd and the user-scope ~/.abcd.noindex/ store (and, on install, an owned PATH copy). It never writes to stdout, never calls os.Exit, and never imports a transport (cobra/MCP), so it is fully testable and reusable across surfaces. Interactive decisions are routed through the injected Prompter seam.

Index

Constants

View Source
const (
	// ArtefactMissingGapID is the gap a repository with no declaration raises.
	ArtefactMissingGapID = "artefact.missing"
	// ArtefactInvalidGapID is the diagnostic for a declaration that is present
	// and wrong. It is the user's data, so install reports it and never
	// overwrites it.
	ArtefactInvalidGapID = "artefact.invalid"
)
View Source
const (
	GuardHookRelPath      = ".githooks/pre-commit"
	GuardMergeHookRelPath = ".githooks/pre-merge-commit"
)

The committed guard's two halves, repo-relative and slash-separated (they are os.Root paths as well as report text).

They are COMMITTED hooks, not .git/hooks copies: .git/hooks is per-clone and untracked, so a guard installed there protects one working copy and no one else's. A clone points git at this directory once (`git config core.hooksPath .githooks`) and every checkout inherits the check.

pre-merge-commit exists because git runs NO pre-commit hook for a merge commit. Without it every name the private layer bans walks into history the moment a branch carrying it is merged, and the guard reports nothing because it was never asked.

View Source
const (
	MismatchGapID     = "git_identity.mismatch"
	UnsetGapID        = "git_identity.unset"
	CommitterGapID    = "git_identity.committer"
	ToolIdentityGapID = "git_identity.tool"
)

The identity gap ids the detector raises and the establish step reads.

View Source
const (
	// HarnessStrayHookGapPrefix keys one gap per abcd hook in the user
	// settings: <prefix>.<Event>, and <prefix>.<Event>.<n> for the n-th entry
	// on one event, so no finding hides another.
	HarnessStrayHookGapPrefix = "harness.stray_hook"
	// StatusLineUntrustedGapID is a status line running an abcd that fails
	// statusLineEntryTrust. A dangling line keeps its own repair gap.
	StatusLineUntrustedGapID = "statusline.untrusted"
)
View Source
const (
	// OracleRoutingMachineGapID is the offer of the machine's routing table.
	OracleRoutingMachineGapID = "oracle_routing.machine_offered"
	// OracleRoutingRepoGapID is the offer of the repository's routing table.
	OracleRoutingRepoGapID = "oracle_routing.repo_offered"
)
View Source
const (
	// ProviderAdapterGapID is the explanation, raised while no provider is
	// configured on this machine.
	ProviderAdapterGapID = "oracle_api.none_configured"
	// ProviderAdapterRefusedGapID names a provider configuration the adapter
	// refuses, so it is never silently unused.
	ProviderAdapterRefusedGapID = "oracle_api.config_refused"
	// ProviderAdapterRouteSkippedGapID names each route the configuration
	// read skipped, one diagnostic per line of its Detail, so a skip is never
	// silent at the bare board.
	ProviderAdapterRouteSkippedGapID = "oracle_api.route_skipped"
)
View Source
const AttributionHookRelPath = guardHooksDirRelPath + "/prepare-commit-msg"

AttributionHookRelPath is the committed prepare-commit-msg hook, repo-relative and slash-separated (an os.Root path as well as report text). It sits beside the name guard's two halves, in the directory a clone points git at once.

View Source
const ConventionsOwnerFileGapID = "conventions.owner_file"

ConventionsOwnerFileGapID is a tool's own conventions file holding the owner's words: a warning, never resolvable, since abcd never touches it.

View Source
const ConventionsRetireGapID = "conventions.retire_offered"

ConventionsRetireGapID is the offer to retire a tool's own conventions file that only repeats AGENTS.md, raised once per such file.

View Source
const DocsLintRootMissingGapID = "docs_lint.root_missing"

DocsLintRootMissingGapID is a roots entry in the repository's docs-lint config that does not resolve (iss-2610100649479892). The documentation check refuses to run while one is listed, so every rule it carries, the banned names included, checks nothing until the entry is fixed. The usual cause is a retired conventions file, CLAUDE.md, still listed after setup removed it or the person did. The gap is one per such entry and report-only: the config is the person's file, and abcd does not edit it.

View Source
const DrainRuleOfferGapID = "drain_rule.offered"

DrainRuleOfferGapID is the offer of the drain eligibility record.

View Source
const FilterRootsIgnoredGapID = "filter_roots.ignored"

FilterRootsIgnoredGapID is the note for a ~/.abcd.noindex/filter-roots file abcd ignored (iss-2610091920437492).

View Source
const HostReachGapID = "conventions.host_reach"

HostReachGapID is a file above the project, or a personal file at its root, that keeps Claude Code from reading AGENTS.md: a warning, never resolvable.

View Source
const HostVersionGapID = "conventions.host_version"

HostVersionGapID is a Claude Code on PATH older than the release that reads AGENTS.md on its own: a warning, never resolvable.

View Source
const OptionalPinGapID = "git_identity.unpinned"

OptionalPinGapID is the one optional gap --yes does not cover. Named here so the front doors can point at it without re-deriving the string.

View Source
const OutboundHookRelPath = guardHooksDirRelPath + "/commit-msg"

OutboundHookRelPath is the committed commit-msg hook that runs `abcd lint outbound` over every commit message, repo-relative and slash-separated. It sits beside the name guard's halves and the attribution prompt, in the directory a clone points git at once.

View Source
const ReadmeOfferGapID = "readme.offered"

ReadmeOfferGapID is the README question, raised while it is unanswered.

View Source
const ReadmePartsChoices = "licence|links|contents|release-badge|build-badge|abcd-badge|none"

ReadmePartsChoices is what --readme-parts takes, as a summary names it.

View Source
const ReadmePromptKey = "readme"

ReadmePromptKey keys Q1; each part's question is keyed ReadmePromptKey + "." + the part's name, as the status line's elements are keyed statusline.<el>.

View Source
const RepoSettingsMirrorRelPath = ".abcd/work/rulesets/repo-settings.json"

RepoSettingsMirrorRelPath is the committed mirror of the repo-object settings abcd manages, repo-relative and slash-separated. It sits beside the branch-ruleset mirror, which covers RULESETS only: the security toggles live behind the separate repository-object API, so a settings change had no source of truth in the tree at all and every claim about it rested on a web console (iss-2608270512210664).

View Source
const SetupLaterValue = "later"

SetupLaterValue is the value recorded when a setup question is answered "decide later". It is never handed to the install: a door answers the prompt with no answer (""), and the install treats that as it treats every unanswered question.

View Source
const (
	StatusLineOfferGapID = "statusline.offered"
)

Gap ids. StatusLineOfferGapID is exported for the front doors, which name the optional gaps --yes leaves for an answered prompt.

View Source
const StoreWorktreeUnlinkedGapID = "store.worktree_unlinked"

StoreWorktreeUnlinkedGapID names a worktree in abcd's worktree store whose repository does not link back to it (iss-2610050728100598). git records a worktree's place in absolute form at both ends: the worktree's .git file names its admin folder in the repository, and that folder's gitdir file names the worktree. Renaming abcd's home moves every worktree without telling the repository, so until `git worktree repair` runs in it, the repository lists the worktree as prunable and a `git worktree prune` there drops its entry. The gap is one per such worktree, report-only: abcd never runs the repair, which writes into the repository's .git, outside its home (the technical facilitator's ruling of 2026-10-04 on iss-2610040147016103).

View Source
const UnverifiedCopyGapID = "symlink.unverified"

UnverifiedCopyGapID is the outstanding work an install reports when the owned PATH copy it found on a cold cache did not verify (iss-2610120955431790).

View Source
const VintageSourceCheckoutTip = "checkout tip"

VintageSourceCheckoutTip is the VintageStatus.Source a dogfood comparison reports — the one reference that is ancestry-guarded and so the one whose staleness may claim a direction (see Staleness).

View Source
const YesStillAsksValues = "--yes approves each kind of change but chooses no value, so the questions below are still asked; " +
	"each names the flag that answers it without asking."

YesStillAsksValues is said once, before the first value question, by a run that approved every kind of change with --yes and still has a value to ask: the approval chooses no value, so the questions below are asked all the same (iss-2609120447486547). The words are core's so every front door says the same thing.

Variables

View Source
var DependencyTools = []string{"gitleaks"}

DependencyTools names the tools detectDependencies checks for, and so the tools `ahoy install --install-tool` can name: the front door refuses any other, since no gap would ever put it to the question.

View Source
var ReleaseTagShape = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$`)

ReleaseTagShape is the accepted release-tag alphabet, one definition for the updater (a tag travels into a URL path there) and for the unseen-update notice below (a tag travels onto a terminal there).

Functions

func EnsureMarker

func EnsureMarker(path string, dryRun bool) (changed bool, err error)

EnsureMarker installs, refreshes, or (dryRun) predicts the CURRENT abcd marker block in the file at path. It NEVER copies foreign prose — only the canonical block travels, so an embark can re-inject the block into a target CLAUDE.md without carrying a lifeboat's authored text. With dryRun it writes nothing and reports whether a real run WOULD change the file (the embark probe path); without it, it performs the write (the embark write path) — one code path, so probe cannot mispredict. changed reports whether the file was/would be written; a symlinked or unwritable target returns a non-nil error and changed=false.

It wraps the existing unexported classify/install machinery: dryRun first asks whether the file's folder can take the files a write creates beside it (markerFolderRefusal, the write's own first check, iss-2610032202263648), then maps classifyMarker(path) → current→(false,nil), missing/outdated→ (true,nil), symlink, unplaceable or unreadable→(false, err); a real run calls installMarkerFile(path) → its error wrapped as (false, err), else (wrote, nil). An unreadable file's refusal is the write's own: the dry run reads it once more for the reason and words it as the write does, with the folder taken out (iss-2610032048280232, iss-2610032202259011).

func GitHubRepo added in v0.11.1

func GitHubRepo(cwd string) (string, error)

GitHubRepo is the owner/name this checkout's origin remote names, under the same github.com-only, plain-name rules the remote apply writes behind. Every verb that writes to the forge resolves its repository here, so there is one answer to "which repository may this write reach".

func HarnessNotice added in v0.13.1

func HarnessNotice() string

HarnessNotice is the session-start line for the harness's user settings: "" when nothing there calls abcd that should not, one line naming the finding and its remedy when there is one, and one line counting them and pointing at `abcd ahoy` when there are several. It reads the settings file, the path-entry record and the plugin's hook manifest — each bounded, none written, no network.

func IsOwnedPathCopy added in v0.8.0

func IsOwnedPathCopy(target string) bool

IsOwnedPathCopy reports whether target is the regular file abcd installed as this machine's PATH entry: ~/.abcd.noindex/path-entry names that very entry and the bytes still hash to the recorded value. It is the exported face of the same predicate `ahoy` classifies with, published for `abcd update`, which needs a proof of ownership that no release deletion can revoke (iss-2609012000222546, and the itd-130 fidelity audit's ac-1 concern (b): the record was re-stamped after a swap but never consulted as a proof before one). It reads two local files and touches no network.

func LowerReleaseMarkCommand added in v0.14.1

func LowerReleaseMarkCommand(tag string) string

LowerReleaseMarkCommand is the one command that lowers the mark on purpose, for a tag: naming the tag is the person's own choice of an older release.

func Managed added in v0.9.0

func Managed(root string) bool

Managed reports whether the checkout rooted at root is one abcd manages: the exact question classify answers with ManagedRepo, exported as a cheap predicate for the two front doors that ask it on every render — the status verb the harness invokes on each refresh, and the bare board (spc-70).

It is classify's strong-signal rule and nothing more: a marker block in CLAUDE.md or AGENTS.md at the root, or registration in the user-level history index by root commit. A bare `.abcd/` is not a managed signal on its own (iss-88), and a plain git checkout is not managed. No new heuristic lives here; TestManagedAgreesWithClassify holds the two to the same answer on every fixture.

What it does NOT do is run the full detection pass. Detect walks PATH, reads the plugin root, probes guard health and the rest, and a status line that paid for that on every keystroke would be a status line people switch off. The marker is read first, because it settles the ordinary managed case with two file reads and no subprocess; git is asked for the root commit only when the marker is absent AND there is an index to look it up in. Zero network, zero writes.

func ManagedContext added in v0.13.1

func ManagedContext(ctx context.Context, root string) (bool, error)

ManagedContext is Managed bound to ctx, for a caller on a deadline (the status verb). The one subprocess it may start — git's root commit, asked only when no marker block answers — runs under ctx and is killed when ctx ends (gitutil.RootCommitContext). A context that ended before git answered is returned as its own error, never as "not managed", so the caller does not mistake a slow git for a checkout abcd does not manage.

func NoHostVersionForTest added in v0.13.0

func NoHostVersionForTest() (restore func())

NoHostVersionForTest makes the version reading find no agent tool, as on a machine with none on PATH, and returns a restore func. It is a test-only seam (in the manner of SetCurrentVintageForTest): a front-door test package runs installs in-process and calls it from its TestMain, so no unit test runs the machine's own agent tool and no test's output depends on its release. Production never calls it.

func OfferGH added in v0.12.0

func OfferGH(guard string, confirm tools.Confirm) (notes []string, ok bool)

OfferGH is the explain-then-install mode for gh at a remote write (itd-63 criterion 2; the product thinker's DQ3 ruling, 2026-09-29: offer to install gh on an explicit yes). With gh on PATH it says nothing. Otherwise it hands the registry's explanation to confirm, which the front door answers yes only for a person at a terminal, and runs the registry's step only on that yes.

ok is true only when gh was installed AND verified; the notes then say what ran. Every other outcome (a no, no one asked, CI, a failed or unverified step) is ok=false with the reason first, then the explanation with the exact command, so the caller refuses loudly and reaches no gh call on a half-done install.

func OldHostVersionForTest added in v0.13.0

func OldHostVersionForTest() (restore func())

OldHostVersionForTest makes the version reading report an agent tool one release below the floor, without running anything, and returns a restore func: the stub a front-door test proves the warning renders with. Production never calls it.

func ParseReadmeParts added in v0.14.0

func ParseReadmeParts(v string) ([]string, error)

ParseReadmeParts reads a --readme-parts value: a comma-separated list of part names, returned once each in the fixed order, or `none`, returned as an empty, non-nil list. An unknown name, an empty one, or none beside a name is refused naming the known names.

func PluginDataDirHazard added in v0.11.1

func PluginDataDirHazard(dataDir, cwd string) string

PluginDataDirHazard is dataDirHazard for a front door that reads the harness data directory itself (the session-start skew notice): the reason dataDir cannot be trusted, or "" when it has the shape the harness always gives it. One check, so the surface and core cannot disagree about which directories are believed.

func PluginRootContaining added in v0.12.0

func PluginRootContaining(path string) (string, bool)

PluginRootContaining reports the plugin root a given path sits inside, by walking the path's ancestors for the plugin layout.

It is the executable-ancestor rung of resolvePluginRoot's ladder on its own: a front door that needs to know WHICH root served the running binary — as distinct from which root this session resolves — asks through the same walk and the same layout check, so it never grows a second notion of what a plugin root is (iss-2609020113012227). A path inside no plugin root — a PATH copy, a `go run` binary — yields false, which a caller reads as "nothing to say" rather than as a negative finding.

func ReadReleaseMark added in v0.14.1

func ReadReleaseMark() (string, bool)

ReadReleaseMark returns the recorded newest release, read through the same home-scoped declaration read as the cache attestation (owned by this uid, writable by no one else, a regular file). Absent, unreadable or malformed reads as no mark.

func RecordReleaseMark added in v0.14.1

func RecordReleaseMark(tag string, lower bool) error

RecordReleaseMark records tag as this machine's newest release. With lower false it only RAISES the mark (a tag at or below the current one changes nothing); with lower true — an explicitly named tag, the person's own choice — it records tag whatever the mark said. The write is atomic and mode 0600 under ~/.abcd.noindex, judged and opened relative to home's descriptor like path-entry.

func RefreshPathEntryDigest

func RefreshPathEntryDigest(target, shaHex string)

RefreshPathEntryDigest re-records the provenance hash for the owned PATH copy after `abcd update` swapped the file at target — the one other verb that legitimately changes those bytes, and only after proving the new content against a published release's own checksums. Without this the entry update just refreshed would classify foreign forever after. A record that does not name target, a malformed digest, or no record at all is a no-op: this refreshes provenance, it never creates it.

func ReleaseOlder added in v0.14.1

func ReleaseOlder(a, b string) bool

ReleaseOlder reports whether release tag a is older than tag b. Two tags of the same core are equal unless only a carries a pre-release suffix. A tag that does not parse is never older: the comparison refuses only on a fact.

func ResolvePluginRoot added in v0.7.1

func ResolvePluginRoot() (string, bool)

ResolvePluginRoot is the exported face of resolvePluginRoot for the front doors: the same ladder (ABCD_PLUGIN_ROOT -> CLAUDE_PLUGIN_ROOT -> executable-ancestor -> recorded path-entry root), the same layout check, so a surface never grows a second notion of where the plugin lives.

func RetiredDocsTarget added in v0.13.0

func RetiredDocsTarget(v string) (explanation string, retired bool)

RetiredDocsTarget reports whether v is a docs.target value setup reads but no longer writes (claude_md, both), and the one explanation every front door shows for it: the detection gap, the install refusal and the --docs-target flag all carry these words, so none restates them (adr-2610030814023326: AGENTS.md is the one conventions file abcd writes). A writable value, and a value abcd never accepted, is not retired and has no explanation.

func SavedDocsTarget added in v0.13.0

func SavedDocsTarget(cwd string) (string, error)

SavedDocsTarget reads the docs.target this project's setup saved in .abcd/config.json under cwd, through the reader setup itself uses (a guarded, size-capped read of a regular file), so another writer of abcd's block — embark — follows the same choice setup made. It returns the value as saved when it is one setup reads (agents_md, skip, or a retired value RetiredDocsTarget explains), and "" when setup reads none: no settings file, no docs.target, or a value outside the set, which detection reports as not set. err is non-nil only when the settings file cannot be read or parsed.

func SetCurrentVintageForTest

func SetCurrentVintageForTest(f func() vintage.Current) (restore func())

SetCurrentVintageForTest overrides the build-vintage seam and returns a restore func. It is a test-only seam (in the manner of this package's history hooks): a go-test binary is itself unstamped, so without an override every install path in a front-door test package would hit the itd-111 unknown-vintage refusal. Front-door test packages, which cannot reach the unexported seam, install a deterministic vintage through this. Production never calls it — it reads the embedded build info.

func SetupAskedBeforeWriting added in v0.13.0

func SetupAskedBeforeWriting(id string) bool

SetupAskedBeforeWriting reports whether the install asks the setup question id before its first write: the adoption and the approvals of each kind of change, which install asks before its first apply step. A stop at one of them leaves the repository untouched; a stop at any other question leaves what the steps before it changed.

func SetupConfirmQuestion added in v0.13.0

func SetupConfirmQuestion(n int, text string) question.Question

SetupConfirmQuestion is the n-th question of setup, Confirm(text) as the shared type: its id the approval's (setupConfirmID; "" for a text setup does not own); the text split into the material and the one plain question it ends on (the last line, or else the last sentence of a text that ends in a question, a line indented by two spaces an item of a list); and the answers yes and "No, leave it", with deciding later declining. Yes points at the material only where there is material: the approval of a kind of change says how many listed changes it writes, or which questions it goes on to (approvalYes), and an approval asked whole makes the change its question names (iss-2610071528375981).

func SetupFixedValues added in v0.13.0

func SetupFixedValues(id string) (values []string, ok bool)

SetupFixedValues returns the values an answers file may give the setup question id when that question's answers are fixed before the run, as SetupValueQuestion and SetupConfirmQuestion build them (the options, then deciding later): a config value's, the house-style question's, a status line element's, and every approval's. ok is false for a question whose answers the run decides (the artefact kind, a conventions file's retirement) or an id setup does not ask.

func SetupHelpedQuestion added in v0.14.0

func SetupHelpedQuestion(n int, h PromptHelp, choices []string, def string) question.Question

SetupHelpedQuestion is the n-th question of setup, PromptHelped(h, choices, def) as the shared type: SetupValueQuestion over the help built for this run, its current setting the question's Now and its example quoted after the material. Its Default is def, so a drawn list starts on the answer an empty answer takes at the stdin door (the README pair, the one question set asked through PromptHelped, keeps its answers in one order whatever the default); no text marks it.

func SetupMachineWide added in v0.13.0

func SetupMachineWide(id string) bool

SetupMachineWide reports whether the setup question id changes the machine rather than the repository: the status line, which every repository on the machine shows, and the machine's routing table. Its answer is recorded in the home's interviews, the rest in the repository's local tier.

func SetupValueQuestion added in v0.13.0

func SetupValueQuestion(n int, cwd, key string, choices []string, def string) question.Question

SetupValueQuestion is the n-th question of setup, Prompt(key, choices, def) as the shared type: the key the id; the material the About of the help HelpIn gives for the repository at cwd (its last sentence the question, where it asks one); the choices the prompt offers as options, in its order, each labelled by its value with core's meaning beneath; the change-later line from ChangeLaterLine; and the decide-later answer, whose meaning says what the install does with no answer. For a config value (a question a flag answers) no answer leaves the value unset, so the gap stays listed; for any other question no answer takes def. A key core has no help for is asked bare.

func StripMarkerBlock

func StripMarkerBlock(content []byte) ([]byte, bool)

StripMarkerBlock returns content with every abcd marker block (a balanced BEGIN…END fence and its surrounding blank lines) removed, and reports whether anything was stripped. Content with no block is returned unchanged. It is the pure, path-free form of removeMarkerFile, exported for the lifeboat packer: carrying a stale marker block into a packed record would plant a dead rules-loader in whatever repo later embarks it, so a verbatim copy is passed through this first. Only a balanced pair is matched, so an unbalanced fence or a literal mention of the delimiter text outside a pair is left intact.

func TakeUnseenUpdate added in v0.12.0

func TakeUnseenUpdate(pluginRoot, cwd string) (from, to string, ok bool)

TakeUnseenUpdate reports the one release swap nobody was told about, and marks it told. It is the ruling CJ1b's single exception to the session check's read-only rule, and the claim it creates is the only write.

An update is announced by whatever performed the swap, when the swap completes: `abcd update` prints update.UpdatedFormat, and hooks/bootstrap.sh leads its success notice with it. The one swap whose output no one reads is the bootstrap salvage the per-prompt, per-command and pre-compaction hooks run with their output discarded (hooks/hooks.json); that run records transition_unseen=yes beside previous_tag in the binary-meta it writes (the cache's, or the plugin root's .binary-meta when there is no data dir), and this is what shows it, once, at the next session start. A swap whose own line was relayed carries no flag, so this shows it never and writes nothing.

The directory the record comes from is an environment value, so it passes dataDirHazard before anything is read from it or written into it, and both tags must have ReleaseTagShape: a record an HTTP redirect filled shows nothing it cannot vouch for. Once is one exclusive create per release (O_CREATE|O_EXCL), so of any number of sessions starting together exactly one takes the claim; a claim path that already exists, or a create that fails for any other reason, reports nothing, because a notice that cannot remember it was shown would repeat every session. Claims for earlier releases are left in place: removing one would be a second write, and each is an empty file.

func WalkConfigValueQuestions added in v0.13.0

func WalkConfigValueQuestions(cwd string, opts InstallOptions, approves func(id string) bool, answer func(key string, choices []string, def string) string) error

WalkConfigValueQuestions puts to answer, writing nothing, the config value questions an install at cwd with opts would ask, in the order it asks them and exactly as far as it would ask them: a value a flag in opts.ValueOverrides gives is not put, and an answer that is not a value setup writes (deciding later included) ends the walk where it ends the install's collection. It is the part of setup's questions settled before the install's first write, so a front door that answers from a file checks the file against it before Install runs, and a value the file leaves unanswered refuses with the repository untouched (iss-2610040025088395). The questions whose asking the run itself decides (the status line's elements, the offers, the artefact kind) are not walked.

Nothing is put when the install would ask no value question: cwd is not a repository, an early refusal ends the install, the adoption is declined, or the settings change (config-change) is not approved. approves answers the adoption ("adopt") where opts.Adopt is unset, and the approval ("approve.config-change") where neither opts.Yes nor opts.ApprovedCategories decides it. The error is Detect's.

Types

type ApplyResult

type ApplyResult struct {
	Category     GapCategory
	GapsResolved []string
	GapsSkipped  []string
	Notes        []string
}

ApplyResult is the outcome of one apply step.

type BanlistHealth

type BanlistHealth struct {
	// Hook and MergeHook are the committed guard's two halves. A merge commit runs
	// NO pre-commit hook, so a repo with only the first half is uncovered for exactly
	// the commit that merges someone else's branch.
	Hook      HookState `json:"hook"`
	MergeHook HookState `json:"merge_hook"`
	// HooksPath is which hooks directory git runs in this clone, judged against the
	// committed one: armed, unarmed, or foreign — a hooks path set outside the
	// clone's local config (a global or system dispatcher) that abcd cannot see
	// into. Foreign is neither verdict, and no surface may advise a local override
	// for it: a local core.hooksPath shadows the dispatcher in this clone and drops
	// whatever else it chains.
	HooksPath HooksPathState `json:"hooks_path"`
	// HooksPathArmed is HooksPath == armed, kept for readers of the boolean. False
	// is not a fault — see HooksPath for whether it is unarmed or unknown — so the
	// surfaces phrase it as an instruction, never as an accusation.
	HooksPathArmed bool `json:"hooks_path_armed"`
	// PublicFamily is the committed layer's state, including the case where it is
	// present and readable but git ignores the file, so CI never sees it.
	PublicFamily PublicFamilyState `json:"public_family"`
	// HookEOLPinned reports whether .gitattributes keeps the committed hooks at LF.
	// Meaningful only where abcd owns the hooks: pinning the EOL of a directory whose
	// contents are someone else's is not abcd's call.
	HookEOLPinned bool `json:"hook_eol_pinned"`
	// HookRetiredVerb reports an abcd-owned pre-commit hook that still runs the
	// sources refresh as `source sync-banlist`, the spelling the verb had before
	// it became library (spc-2610100613109045, decision 13). A binary without
	// that verb makes the hook skip the refresh with one stderr line, so the
	// confidential-name block stops being refreshed with no other sign.
	HookRetiredVerb bool `json:"hook_retired_verb"`
	// PublicConfigIgnored is git's verdict on the config's PATH, whether or not a
	// file is there yet. It is what makes the absent-family gap honest: writing a
	// config into a path git ignores delivers no enforcement, so abcd does not offer
	// to.
	PublicConfigIgnored bool `json:"public_config_ignored"`
	// PublicConfigWritable reports whether scaffolding may create the config here. It
	// is NOT the negation of PublicConfigIgnored: a probe git could not answer is
	// neither ignored nor safe, and it fails closed inside anything repo-shaped.
	PublicConfigWritable bool `json:"public_config_writable"`
	// PrivateStore reports whether THIS MACHINE has opted in. False is the honest
	// "inactive here" state, never silence: an absent store checks nothing, and the
	// guard says so at commit time for the same reason.
	PrivateStore bool `json:"private_store"`
	// PrivateStoreIgnored is git's verdict on the store's path. A present store git
	// would track is one `git add -A` from committing the patterns it exists to keep
	// out of history.
	PrivateStoreIgnored bool `json:"private_store_ignored"`
	// PrivateKeyed, PrivateEntries and PrivateUnparsed are the store's SHAPE, never
	// its content: a format flag and two counts, taken from the shared parser. A line
	// that does not parse stops every commit until it is fixed.
	PrivateKeyed    bool `json:"private_keyed"`
	PrivateEntries  int  `json:"private_entries"`
	PrivateUnparsed int  `json:"private_unparsed"`
	// PrivateUnreadable reports a store that exists and cannot be read for what it
	// is — a damaged format declaration, an unreadable file. The guard refuses every
	// commit in that state, so a status board must not render it as healthy.
	PrivateUnreadable bool `json:"private_unreadable"`
	// Reach is PrivateReachNote, unconditionally.
	Reach string `json:"reach"`
}

BanlistHealth is the two-layer name guard's state in one repo: which of the scaffolded artefacts are there, what shape the private layer is in, and — always — how far it reaches (spc-20 AC7).

Reach is carried in the struct rather than added by a renderer because this report is read on two surfaces at once. A human sees a line; a machine consumer reads the fields. "hook: installed" beside a populated private store reads as "covered" to both of them, and it is not: the guard runs on machines that opted in, for the commits git asks a hook about, and nowhere else. The caveat travels with the state it qualifies.

type ChoiceHelp added in v0.11.1

type ChoiceHelp struct {
	Value   string `json:"value"`
	Meaning string `json:"meaning"`
}

ChoiceHelp explains one answer to an install question in plain language: what choosing it does to the person's repository or machine, and what it asks of them (keys, tools, cost) where it asks anything.

type DetectionResult

type DetectionResult struct {
	FolderKind       FolderKind     `json:"folder_kind"`
	Adopted          *bool          `json:"adopted"` // nil on detect/dry-run
	RootSHA          string         `json:"root_sha"`
	PluginRootStatus string         `json:"plugin_root_status"` // "resolved" | "missing"
	RepoIdentity     RepoIdentity   `json:"repo_identity"`
	Signals          map[string]any `json:"signals"`
	// Guard is the execution-time shell guard's health. It is reported on every
	// pass over a repo, healthy or not: a guard that fails open looks exactly like
	// a working one from inside a session, so the state has to be legible from
	// outside.
	//
	// A POINTER, omitted entirely for an unmanaged folder — like Banlist below and
	// for the same reason: its fields are definite booleans, so a never-computed
	// zero value would serialise four `false` facts (and no detail) that read as "a
	// broken guard" to a consumer that never asked about a repo, in a document that
	// simultaneously reports the plugin root resolved.
	Guard *GuardHealth `json:"guard,omitempty"`
	// Banlist is the two-layer name guard's state. Like Guard it is reported on
	// every pass over a repo — and it carries its own reach, because a private layer
	// that looks installed says nothing about what a pull request is checked against.
	//
	// A POINTER, omitted entirely for an unmanaged folder: the states it reports are
	// named strings ("absent", "foreign") and its ignore flag is warning-polarity, so
	// a zero value would serialise undeclared states and a false that reads as "the
	// store is trackable" to a consumer that never asked about a repo.
	Banlist *BanlistHealth `json:"banlist,omitempty"`
	Gaps    []Gap          `json:"gaps"`
	// Readme is the README question pair as the plugin page relays it, carried
	// by DryRun while the question is open (readme.offered) and omitted
	// otherwise (spc-2610031704338417).
	Readme *ReadmeView `json:"readme,omitempty"`
	// contains filtered or unexported fields
}

DetectionResult is the canonical envelope. dry-run marshals exactly this (with Adopted=nil).

func Detect

func Detect(cwd string) (DetectionResult, error)

Detect runs the full detection pass over cwd and returns the canonical envelope. Total over a normal folder: broken-plugin conditions surface as gaps, never as a hard error. An error is returned only for malformed input.

func DryRun

func DryRun(cwd string) (DetectionResult, error)

DryRun runs Detect and returns the envelope (Adopted=nil). Zero writes.

While the README question is open it also carries the README view (readmeView), which the plugin page relays the question pair from; Detect alone, which the hooks and the status board call, derives no part.

type DoctorReport

type DoctorReport struct {
	Detection DetectionResult `json:"detection"`
	AuditGaps []Gap           `json:"audit_gaps"`
}

DoctorReport is the outcome of Doctor: the detection envelope plus read-only cross-machine reconciliation gaps.

func Doctor

func Doctor(cwd string) (DoctorReport, error)

Doctor runs the detection pass plus a read-only cross-machine audit. Zero writes.

type DogfoodReport

type DogfoodReport struct {
	IsDogfood bool            // cwd is abcd's own source checkout (the binary was built from it)
	Outcome   vintage.Outcome // Fresh (silent) / Stale / Unknown (a dirty rebuild)
	Revision  string          // the binary's embedded revision (full)
	Tip       string          // the checkout tip it should match (full)
}

DogfoodReport is the source-checkout-tip comparison the session-start notice consumes. It is scoped to the dogfood case on purpose: a pinned install in a user's own repo must never be nagged, so IsDogfood gates the whole notice.

func DogfoodStaleness

func DogfoodStaleness(cwd string) DogfoodReport

DogfoodStaleness reports whether the running binary trails the tip of the source checkout it was built from, for the session-start notice. It reads the binary's own build vintage and compares against cwd's HEAD.

type FolderKind

type FolderKind string

FolderKind is the classification of the folder ahoy runs in. There is no workspace layer: abcd manages exactly one kind of folder, a repository.

const (
	// ManagedRepo is a git repo abcd already manages (a strong marker fired).
	ManagedRepo FolderKind = "managed-repo"
	// UnmanagedRepo is a git repo with no abcd markers yet (adoptable).
	UnmanagedRepo FolderKind = "unmanaged-repo"
	// UnmanagedFolder is not a git repo and has no abcd markers.
	UnmanagedFolder FolderKind = "unmanaged-folder"
)

type Gap

type Gap struct {
	ID         string      `json:"id"`
	Category   GapCategory `json:"category"`
	Scope      string      `json:"scope"` // "repo" | "machine"
	Title      string      `json:"title"`
	Detail     string      `json:"detail"`
	FixHint    string      `json:"fix_hint"`
	Required   bool        `json:"required"`   // advisory gaps set false
	Resolvable bool        `json:"resolvable"` // false => diagnostic only
	// Tool is the tool registry's explanation for a dependency gap (itd-63):
	// what the tool is, whether this capability needs it, what works without
	// it, and the exact install step. Absent on every other gap.
	Tool *tools.Explanation `json:"tool,omitempty"`
}

Gap is one detected discrepancy between desired and actual state.

type GapCategory

type GapCategory string

GapCategory groups gaps for the one-approval-per-category apply protocol.

const (
	// SafeAutocreate covers artefacts written without a per-item prompt once
	// the category is approved (the .abcd/ skeleton, history-store dirs).
	SafeAutocreate GapCategory = "safe-autocreate"
	// ConfigChange covers transparent-confirm changes (visibility, symlink).
	ConfigChange GapCategory = "config-change"
	// PluginOwned covers the marker block and the (verify-only) hook manifest.
	PluginOwned GapCategory = "plugin-owned"
	// Dependency covers the external tools a capability uses (itd-63): each gap
	// carries the tool registry's explanation, and a tool is installed only on
	// an answer the front door's confirmation returns, never on the category
	// approval alone.
	Dependency GapCategory = "dependency"
	// UserState covers ~/.abcd.noindex/history registry state (guided, never auto-edited).
	UserState GapCategory = "user-state"
	// StatusLine covers the host harness's status-line wiring (spc-70). Its one
	// gap is advisory and is never written under --yes: the wiring rewrites a
	// harness-wide user setting and takes element choices, so only an answered
	// prompt writes it.
	StatusLine GapCategory = "status-line"
	// OracleRouting covers accepting abcd's proposed model-tier routing table,
	// at the machine and, offered separately, at the repository
	// (itd-2609170822093401). Its gaps are advisory and never written under
	// --yes: a routing table decides which model every delegated step asks
	// for, so only an answered prompt accepts one.
	OracleRouting GapCategory = "oracle-routing"
)
const ConventionsFile GapCategory = "conventions-file"

ConventionsFile covers retiring a tool's own conventions file that only repeats AGENTS.md. Its gap is advisory and never acted on under --yes: the removal is of a file in the person's project, so only an answered question at a terminal removes one.

const DrainRule GapCategory = "drain-rule"

DrainRule covers adding the repository's drain eligibility record.

const Readme GapCategory = "readme"

Readme covers the README parts abcd keeps current. It is never asked as a category: the README question is the consent (open question 5).

type GuardHealth

type GuardHealth struct {
	// PluginRootResolved reports whether the plugin root was found at all. It
	// gates the two checks below: without it the manifest is never opened and the
	// binary is never looked for, so HookInstalled and BinaryReachable carry no
	// information. A report that folded "not checked" into "false" would accuse a
	// plugin install that may be perfectly armed — the state every dev build that
	// runs from source is in.
	PluginRootResolved bool `json:"plugin_root_resolved"`
	// HookInstalled reports whether the plugin's hook manifest declares the
	// pre-tool-use entry that runs the guard. Meaningful only when
	// PluginRootResolved.
	HookInstalled bool `json:"hook_installed"`
	// BinaryReachable reports whether the binary that entry invokes exists and
	// is executable. When it is not, the shim fails open on every command.
	// Meaningful only when PluginRootResolved.
	BinaryReachable bool `json:"binary_reachable"`
	// RegistryLoadable reports whether ANY hazard registry is armed — the
	// bundled defaults, with this repo's .abcd/guard.json merged in when it
	// loads. Since the fail-safe load (iss-2608261551087492) a broken repo file
	// no longer clears this: guard.Load falls back to the bundled defaults, so
	// false here means no registry at all — the only genuinely-unguarded
	// registry state, which the embedded defaults make unreachable in practice.
	// A broken repo layer over an armed bundle is RepoOverridesDropped instead.
	RegistryLoadable bool `json:"registry_loadable"`
	// RepoOverridesDropped reports the fail-safe degraded state: this repo's
	// .abcd/guard.json does not load, so its overrides are dropped while the
	// bundled hazards stay armed. Mild and expected — commands are still
	// checked — but never silent: the broken committed file needs fixing, and
	// hiding it would let a repo's own tightened hazards quietly lapse.
	RepoOverridesDropped bool `json:"repo_overrides_dropped,omitempty"`
	// Disabled reports a deliberately switched-off registry. It is not a fault —
	// .abcd/guard.json is the only route, and a switch-off takes effect only
	// once HEAD carries it (iss-147), so the change is a reviewed commit. A
	// disabled guard that looks armed is exactly the state this report exists
	// to prevent.
	Disabled bool `json:"disabled"`
	// Entries is how many hazards the loaded registry holds, so "loadable" is
	// backed by a number rather than a boolean nobody can check.
	Entries int `json:"entries"`
	// Detail is a one-line human reason when something needs attention; empty
	// when there is nothing to report. It can be non-empty while Healthy() is
	// true: dropped repo overrides leave commands checked but still need fixing.
	Detail string `json:"detail,omitempty"`
}

GuardHealth is the answer to "is the execution-time guard actually on?", split into the three things that can independently be false. It exists because a guard that fails open is indistinguishable from a guard that is working, from inside the session — so the state has to be visible from outside it too (itd-103 AC 1, spc-16 "Fail-open-loud and health").

func (GuardHealth) Healthy

func (g GuardHealth) Healthy() bool

Healthy reports whether commands in a session are actually being checked: the hook runs, the binary it calls exists, and the registry loads.

type HelpedPrompter added in v0.14.0

type HelpedPrompter interface {
	Prompter
	PromptHelped(h PromptHelp, choices []string, def string) string
}

HelpedPrompter is a Prompter that can ask a value question with help built for this run: the question's current setting and an example of what an answer writes here, which the static help cannot hold (PromptHelp's Now, Example and ExampleNone). The README pair asks through it where the prompter implements it, and through Prompt, by the help's key, where it does not (spc-2610031704338417).

type HookState

type HookState string

HookState is what occupies one of the guard's two hook paths.

const (
	HookAbsent    HookState = "absent"
	HookInstalled HookState = "installed"
	// HookForeign is a hook abcd did not write. It is NOT a failure of the repo —
	// a maintainer's own pre-commit hook is legitimate — but it is a state in which
	// nothing checks the banlist, so it can never be reported as installed.
	HookForeign HookState = "foreign"
	// HookUnreadable is a path that exists and cannot be read as a hook (a symlink,
	// a directory, an oversize file). Like GuardHealth's unknown state it asserts
	// nothing it did not check.
	HookUnreadable HookState = "unreadable"
)

type HooksPathState added in v0.13.3

type HooksPathState string

HooksPathState is which hooks directory git runs in a clone, judged against the committed one.

const (
	// HooksPathStateArmed: the effective core.hooksPath resolves to the committed
	// hooks directory, so git runs the guard.
	HooksPathStateArmed HooksPathState = "armed"
	// HooksPathStateUnarmed: the clone's own config sets no hooks path or points it
	// elsewhere, and nothing outside the clone sets one. Arming it locally is the
	// clone's own business.
	HooksPathStateUnarmed HooksPathState = "unarmed"
	// HooksPathStateForeign: no local hooks path, and one set outside the clone's
	// local config (global, system) names some other directory — a dispatcher, as
	// often as not, that may chain to the committed hooks. Whether it does is
	// unknown, and a local override would shadow it.
	HooksPathStateForeign HooksPathState = "foreign"
)

type InstallConfig

type InstallConfig struct {
	Visibility    string // private | public
	DocsTarget    string // claude_md | agents_md | both | skip
	OracleBackend string // host-delegated | native | cli | api | mcp
	ScanDeep      *bool  // nil = unset (gap not emitted)
}

InstallConfig is the four configuration values collected/loaded during install.

type InstallOptions

type InstallOptions struct {
	Adopt              *bool                // --adopt / --refuse-adopt / nil
	Yes                bool                 // approve every resolvable category
	ApprovedCategories map[GapCategory]bool // nil => interactive; explicit => partial subset
	ValueOverrides     map[string]string    // visibility/docs_target/oracle_backend/scan_deep
	// Dev requests the track-latest dogfood mode: the PATH entry becomes a shim
	// that rebuilds abcd from the source tip on every call and execs the fresh
	// binary (failing loudly on a broken build), instead of a symlink to the
	// pinned built binary. --dev.
	Dev bool
	// BinDir is an explicit directory for the PATH entry (--bin-dir), the only
	// way to reach a system-wide location. Empty means the default single-user
	// location (~/.local/bin), or an existing owned install adopted in place.
	// abcd NEVER escalates privileges: a BinDir it cannot write to is a loud
	// error, never a silent skip and never a re-run under sudo.
	BinDir string
	// Attribution opts this repo into the committed prepare-commit-msg prompt that
	// asks every commit to declare whether a tool assisted it. --attribution.
	//
	// Opt-IN, never a default: the hook stamps a convention onto every commit
	// message, which is an opinion a repo adopts rather than one abcd may assume.
	// The choice is PERSISTED (`attribution.hook` in config.json), so a later plain
	// install keeps the hook instead of making the maintainer re-pass the flag to
	// keep something they already chose.
	Attribution bool
	// Outbound is the one outbound switch: it opts this repo into both outbound
	// checks at once, the committed commit-msg hook that runs `abcd lint
	// outbound` over every commit message and the shell guard's check of the
	// title, body and body file a posting gh command hands the forge. --outbound.
	//
	// Opt-IN, never a default: a hook that refuses a commit and a guard that
	// refuses a post each change how work in the repository goes, which is the
	// repository's choice (iss-2609250834251447, iss-2610142210511831). One
	// switch turns on both, by the product thinker's ruling of 2026-10-15
	// (iss-2610152024327989); it replaced --outbound-hook and --outbound-forge.
	// The choice is PERSISTED as `outbound.hook` and `outbound.forge` in
	// config.json, so a later plain install keeps both. On this explicit opt-in
	// alone, install also writes this clone's `git config --local abcd.binary`
	// to the PATH copy whose provenance it verified (iss-2610152024267547).
	Outbound bool
	// AllowStaleBinary overrides the itd-111 staleness refusal: an install run
	// through a binary that is stale against its source tip, or whose vintage
	// cannot be determined, otherwise refuses before any write. The override is
	// the documented escape when a rebuild is not an option. --allow-stale-binary.
	AllowStaleBinary bool
	// ConfirmTool is asked, once per missing tool, whether to run the tool
	// registry's install step (itd-63). The front door supplies it: the CLI
	// asks at a terminal, or answers yes for a tool the person named with
	// --install-tool. Nil is a no for every tool, so a caller that asks nothing
	// installs nothing. The category approval never stands in for it.
	ConfirmTool tools.Confirm
	// ReadmeParts is --readme-parts as given: a comma-separated list of the
	// README parts abcd keeps current, or none; "" is the flag not given. It
	// answers the README question in any run, --yes included, and is stored as
	// readme.parts (readme_apply.go); a value ParseReadmeParts refuses refuses
	// the install before any write.
	ReadmeParts string
	// ApproveDependency answers the dependency category's question yes without
	// asking it: the front door sets it when the person named a tool to
	// install (--install-tool), which is that answer given in advance. Every
	// other category is still asked, or pre-answered, as before.
	ApproveDependency bool
	// VerifyProvenance verifies a release artefact's SLSA build provenance by
	// its sha256, for the release tag the cache attestation names (the
	// provenance must name the commit that tag resolves to), returning the
	// verified signer identity. Promoting the
	// plugin's cached release binary to the PATH copy runs it before anything
	// is written, and any failure refuses (iss-2610120617515834): the cache
	// was checked against checksums.txt from the same release page as the
	// binary, which whoever can change that page can change too. The front
	// door supplies abcd update's own in-process check
	// (update.ReleaseProvenance), one primitive for both verbs; this package
	// cannot import it, because update imports ahoy. Nil refuses every
	// promotion: there is no unverified path.
	VerifyProvenance ProvenanceCheck
}

InstallOptions encodes the non-interactive prompt-protocol flags.

type InstallResult

type InstallResult struct {
	Status string `json:"status"` // already_up_to_date | clean | partial | aborted | refused
	// Warnings names what keeps abcd's rules from reaching an agent tool in
	// this project and only the person can end: a tool's own conventions file
	// holding the person's words, which that tool reads in place of AGENTS.md
	// and abcd never edits or removes, then what hides AGENTS.md from outside
	// the project's own files: a personal file at the root, a file in a folder
	// above it, an old host (host_reach.go) (itd-2610030814013772). Each is one
	// line; a front door prints them first, before the headline.
	Warnings           []string `json:"warnings"`
	Writes             []string `json:"writes"`
	Changes            []string `json:"changes,omitempty"`   // value overwrites an explicit override forced ("visibility: private -> public")
	Remaining          []string `json:"remaining"`           // required+resolvable gap ids left
	DeclinedCategories []string `json:"declined_categories"` // sorted category wire values
	// Notes carries an apply step's loud refusal — a thing abcd deliberately did
	// not do, and why. A refusal that only shows up as a still-open gap reads as a
	// silent failure, so the reason travels with the result.
	Notes []string `json:"notes,omitempty"`
	// OptionalSkipped names the optional gaps a --yes run deliberately did not
	// apply: the advisory git-identity pin, the status-line offer and the two
	// model-tier routing offers (which accept a table only on an answer). --yes
	// approves every resolvable CATEGORY, but it never writes the pin, because
	// the pin captures whatever git identity happens to be configured and an
	// unattended run would canonicalise a sandbox or agent identity; and it never
	// wires the status line, because that rewrites a harness-wide user setting
	// and takes element choices only a prompt can carry. The exclusion is
	// reported rather than assumed: a run that says "already up to date" while
	// leaving optional work on the table has to say so (iss-166).
	OptionalSkipped []string `json:"optional_skipped,omitempty"`
	// Headline says in one plain sentence what the run amounted to, and Summary
	// explains every reported item (each write, each declined kind of change,
	// the required work still outstanding, the optional steps left undone) as
	// what it is, why it matters and what, if anything, to do. They are for
	// the person who ran the install; the fields above stay the exact record
	// (iss-164).
	Headline string        `json:"headline"`
	Summary  []SummaryItem `json:"summary"`
	// contains filtered or unexported fields
}

InstallResult is the outcome of Install.

func Install

func Install(cwd string, opts InstallOptions, p Prompter) (InstallResult, error)

Install runs detect + apply over the approved categories. It is idempotent: a re-run with zero required+resolvable gaps writes nothing and reports "already_up_to_date".

func (InstallResult) ReadmeAwaitsConfig added in v0.14.0

func (r InstallResult) ReadmeAwaitsConfig() bool

ReadmeAwaitsConfig reports whether the run left the README question unanswered with no .abcd/config.json to keep the answer in: until abcd's starter files exist, the question is not asked and --readme-parts is refused, so the way to answer it starts with creating them.

type MarkerReceipt

type MarkerReceipt struct {
	Removed []string `json:"removed"` // relative filenames a block was stripped from
	Skipped []string `json:"skipped"` // relative filenames left untouched
}

MarkerReceipt records the per-target outcome of the uninstall marker removal.

type PromptHelp added in v0.11.1

type PromptHelp struct {
	Key     string       `json:"key"`
	About   string       `json:"about"`
	Choices []ChoiceHelp `json:"choices"`
	// Flag is the install flag that answers this question without asking it,
	// or "" for a question no flag answers. A piped run cannot rely on its
	// answers lining up with the questions, so the flag is the reliable route
	// there, and the question and the gap both name it (iss-2609120447486547).
	Flag string `json:"flag,omitempty"`
	// ChangeLater says where the answer is changed later, for a question no
	// flag answers (a flag's hint takes that place where one exists). It is
	// the question's change-later line, so the material need not repeat it
	// (iss-2610031236155833).
	ChangeLater string `json:"change_later,omitempty"`
	// Now is what holds now, for a question whose current setting differs
	// from run to run, such as a README part (spc-2610031704338417); "" leaves
	// the question's own ("not set").
	Now string `json:"now,omitempty"`
	// Example is the exact lines answering yes writes in this repository, or
	// as many of the first of them as a question can quote within the limits
	// (its rows and the style rules), ExampleLeft how many more it
	// writes, and ExampleNone, where it writes none, the reason. All are per
	// run, read from the project, and terminal-safe as set.
	Example     []string `json:"example,omitempty"`
	ExampleLeft int      `json:"example_left,omitempty"`
	ExampleNone string   `json:"example_none,omitempty"`
}

PromptHelp is the canonical explanation of one value question the install asks through Prompter.Prompt: what is being decided, and what each answer means. It lives in core so every front door renders the same words and none has to invent them (iss-163) — a front door that describes an answer on its own can describe it wrongly, or circularly ("native — uses the native backend").

The prompt itself stays key, choices and default, so a scripted answer stream lines up with the questions as before; the help is looked up by the same key and rendered beside it.

func HelpIn added in v0.13.0

func HelpIn(cwd, key string) (PromptHelp, bool)

HelpIn returns the help for the value question keyed key as the install asks it in the repository at cwd. It is helpFor, except where a fact holds only in some repositories: public visibility's caveat is shown only where .abcd/ holds tracked files, the same evidence the install narrows the public block on. The words stay core's; a front door passes the repository and renders what comes back (iss-2610031236155833). An empty cwd gives the help that is the same in every repository (helpFor).

func (PromptHelp) ChangeLaterLine added in v0.13.0

func (h PromptHelp) ChangeLaterLine() string

ChangeLaterLine is the question's change-later line: the flag hint where a flag answers the question, else ChangeLater, else "".

func (PromptHelp) ExampleIntro added in v0.14.0

func (h PromptHelp) ExampleIntro() string

ExampleIntro is the sentence a question says before its example, or in place of it: that it writes the lines that follow, how many it writes where only the first are shown or none fit, or that it writes nothing and why. "" for a help with no example. Every door says these words, so none composes its own.

func (PromptHelp) FlagHint added in v0.12.0

func (h PromptHelp) FlagHint() string

FlagHint is the sentence naming the flag that answers this question without asking it, or "" when no flag does.

func (PromptHelp) Meaning added in v0.11.1

func (h PromptHelp) Meaning(value string) string

Meaning returns what answering value means, or "" for a value the question does not offer.

type Prompter

type Prompter interface {
	// Confirm asks a yes/no question and returns the answer.
	Confirm(question string) bool
	// Prompt asks the user to pick one of choices, defaulting to def.
	Prompt(key string, choices []string, def string) string
}

Prompter is the interactive seam. The CLI supplies interactive impls; non-interactive modes supply refusing impls that auto-decline rather than block on stdin.

type ProvenanceCheck added in v0.14.1

type ProvenanceCheck func(tag string, digest []byte) (signer string, err error)

ProvenanceCheck verifies a release artefact's build provenance by its sha256 digest, as the build of release tag, and returns the verified signer identity.

type PublicFamilyState

type PublicFamilyState string

PublicFamilyState classifies the public layer's config for detection.

const (
	PublicFamilyPresent PublicFamilyState = "present"
	// PublicFamilyAbsent is no docs-lint config at all — scaffolding writes one.
	PublicFamilyAbsent PublicFamilyState = "absent"
	// PublicFamilyUnusable is a config that parses to no usable banned_tokens array.
	// abcd must not rewrite it: the config gates CI and a contributor owns it.
	PublicFamilyUnusable PublicFamilyState = "unusable"
	// PublicFamilyUnreadable is an I/O fault — an oversize file, a symlink, a
	// permission error. It is reported apart from "unusable" because "add a
	// banned_tokens array" is not the fix for a file nobody can open.
	PublicFamilyUnreadable PublicFamilyState = "unreadable"
	// PublicFamilyIgnored is the contradiction: a readable family in a file git
	// ignores. The layer's whole claim is that it is committed and CI-enforced, and
	// an ignored config is enforced by nobody — most sharply under
	// `visibility: public`, where the abcd fence ignores the whole `.abcd/` namespace
	// and public exposure is the risk the layer exists for.
	PublicFamilyIgnored PublicFamilyState = "ignored"
)

type ReadmePartLeft added in v0.14.0

type ReadmePartLeft struct {
	Part   string `json:"part"`
	Reason string `json:"reason"`
	Line   int    `json:"line"`
}

ReadmePartLeft is one part uninstall left in README.md.

type ReadmePartView added in v0.14.0

type ReadmePartView struct {
	Name    string `json:"name"`
	Offered bool   `json:"offered"`
	Now     string `json:"now"`
	Default string `json:"default"`
	// Example is the exact lines the part would write in this project;
	// Reason, where it would write none, why.
	Example []string `json:"example,omitempty"`
	Reason  string   `json:"reason,omitempty"`
	// contains filtered or unexported fields
}

ReadmePartView is one part as the view carries it. Every string is terminal-safe: an example line and a reason are read from the project.

type ReadmeReceipt added in v0.14.0

type ReadmeReceipt struct {
	Removed []string         `json:"removed"` // parts taken out, their text matching its hash
	Left    []ReadmePartLeft `json:"left"`    // parts left, each with its reason and line
	Deleted bool             `json:"deleted"` // a README.md abcd created, emptied and deleted
	Note    string           `json:"note"`    // the receipt in words, terminal-safe
}

ReadmeReceipt records what uninstall did with README.md's parts.

type ReadmeView added in v0.14.0

type ReadmeView struct {
	// Public is the owner's declaration in abcd's settings (repo.visibility);
	// Declaration, where it is not public, is the one line saying the badges
	// go by it, said above Q2's first tab.
	Public      bool             `json:"public"`
	Declaration string           `json:"declaration,omitempty"`
	Parts       []ReadmePartView `json:"parts"`
	// Asks are Q1 alone, then the offered parts in calls of at most four
	// tabs, each as the shared question type.
	Asks []question.Ask `json:"asks"`
	// contains filtered or unexported fields
}

ReadmeView is the README question as detection carries it while the pair is unanswered, for a front door that relays it: each part, and the questions themselves, built from the same help the terminal asks with.

type RefusingPrompter

type RefusingPrompter struct{}

RefusingPrompter auto-declines every confirm and returns the default for every prompt. It is the safe default for non-interactive callers.

func (RefusingPrompter) Confirm

func (RefusingPrompter) Confirm(string) bool

Confirm always declines.

func (RefusingPrompter) Prompt

func (RefusingPrompter) Prompt(_ string, _ []string, def string) string

Prompt always returns the supplied default.

type RemoteMergeHygiene added in v0.6.8

type RemoteMergeHygiene struct {
	DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
	AllowMergeCommit    *bool `json:"allow_merge_commit,omitempty"`
	AllowSquashMerge    *bool `json:"allow_squash_merge,omitempty"`
	AllowRebaseMerge    *bool `json:"allow_rebase_merge,omitempty"`
}

RemoteMergeHygiene is the repo-object settings that gate MERGE behaviour. abcd mirrors them and does not set them: they encode a maintainer's workflow, not a security posture, and a verb that drove them would be changing how the project merges on the strength of a default nobody chose.

They are here because they had no source of truth in the tree at all (iss-2608270512210664): the branch-ruleset mirror beside this one covers RULESETS, and these live behind the separate repository-object API — so every claim a contribution document made about them rested on a web console. Each is a pointer, omitted when the response does not carry it, because "false" and "the API did not say" are different facts.

type RemoteResult added in v0.6.8

type RemoteResult struct {
	// Repo is the owner/name the verb resolved from this repo's origin remote, and
	// the ONLY repository it acts on. It is reported so a caller can see which
	// repository a write reached before believing the rest of the result.
	Repo string `json:"repo"`
	// Status is one of: already_up_to_date | clean | pending | aborted | opted_out |
	// refused. "aborted" is a confirmation the caller declined; "refused" is a gate
	// abcd itself closed. They are reported apart because only one of them is a
	// decision the caller can revisit by answering differently.
	Status string `json:"status"`
	// Observed is the state GitHub reported before anything was changed.
	Observed RemoteSecurity `json:"observed"`
	// Merge is the merge-hygiene snapshot read in the same request: mirrored, never
	// driven.
	Merge RemoteMergeHygiene `json:"merge_hygiene"`
	// Desired is the state abcd holds this repo to.
	Desired RemoteSecurity `json:"desired"`
	// Changes are the toggles an apply changed — or, from the read, would change.
	Changes []string `json:"changes,omitempty"`
	// Writes are the tree paths this run wrote.
	Writes []string `json:"writes,omitempty"`
	// Notes carry what abcd deliberately did not do, and why. A refusal that shows
	// up only as an unchanged toggle reads as a silent failure, so the reason
	// travels with the result.
	Notes []string `json:"notes,omitempty"`
}

RemoteResult is the outcome of a remote config read or apply.

func RemoteApply added in v0.6.8

func RemoteApply(cwd string, p Prompter, confirmTool tools.Confirm) (RemoteResult, error)

RemoteApply enables GitHub-native secret scanning and secret-scanning push protection on the managed repo this checkout points at, and mirrors the desired state into the tree so a later verify reads the same intent (itd-153).

It answers to adr-44 and invariant 10: a remote write happens only through a dedicated verb the user invokes AND CONFIRMS. Four gates stand before any change leaves the machine — the folder must be a repo abcd manages, the repository must be the one this checkout's own origin names, the config must not carry the opt-out, and the caller must say yes to the specific toggles named — and every one of them refuses or aborts rather than guesses. A nil prompter is the RefusingPrompter, so a caller that forgot the seam gets no write by omission.

The READ comes first and needs no ceremony (adr-44 rule 1: reading remote state is the default), which is also what lets the confirmation name exactly what would change. Then secret scanning, then push protection: GitHub refuses push protection on a repo whose secret scanning is off.

func RemoteRead added in v0.6.8

func RemoteRead(cwd string) (RemoteResult, error)

RemoteRead reports the managed repo's GitHub-native secret-scanning state and what an apply would change. It writes NOTHING — not to the remote, not to the tree — so the bare invocation of the verb it backs holds abcd's convention that looking is never acting.

type RemoteSecurity added in v0.6.8

type RemoteSecurity struct {
	SecretScanning string `json:"secret_scanning"`
	PushProtection string `json:"secret_scanning_push_protection"`
}

RemoteSecurity is the pair of GitHub-native secret-scanning toggles, as observed or as desired. A toggle GitHub did not report reads "unknown", never "disabled": the two demand opposite responses, and reporting an unread state as off would send an operator to enable something that may already be on.

type RepoIdentity

type RepoIdentity struct {
	Name    string `json:"name"`
	Github  string `json:"github"`
	RootSHA string `json:"root_sha"`
}

RepoIdentity is the deterministic identity of the repo under cwd.

type StatusLineReceipt added in v0.9.0

type StatusLineReceipt struct {
	Restored bool   `json:"restored"`
	Note     string `json:"note"`
}

StatusLineReceipt records the outcome of the uninstall status-line restore: whether the harness's status line was handed back to the command recorded before abcd took the row, and — restored or not — why. The note is rendered for a human and carries no home path.

type SummaryItem added in v0.11.1

type SummaryItem struct {
	What   string   `json:"what"`
	Why    string   `json:"why"`
	Action string   `json:"action"`
	Refs   []string `json:"refs,omitempty"`
}

SummaryItem explains one thing an install reports, for the person who ran it rather than for abcd's implementers (iss-164): what it is, why it matters for their work, and what, if anything, they should do. Refs names the exact entries of the result it explains (write paths, category names, step ids), so the plain words and the precise record can always be matched up.

type SymlinkReceipt

type SymlinkReceipt struct {
	Target  string `json:"target"`
	Removed bool   `json:"removed"`
	Note    string `json:"note"`
}

SymlinkReceipt records the outcome of the uninstall symlink removal.

type TerminalPrompter added in v0.11.1

type TerminalPrompter interface {
	Prompter
	AtTerminal() bool
}

TerminalPrompter is a Prompter that can say whether a person is answering at a terminal. A prompter that does not implement it is treated as having no one at a terminal, which is the fail-closed reading.

type UninstallReceipt

type UninstallReceipt struct {
	Marker     MarkerReceipt     `json:"marker"`
	Readme     ReadmeReceipt     `json:"readme"`
	Symlink    SymlinkReceipt    `json:"symlink"`
	StatusLine StatusLineReceipt `json:"status_line"`
}

UninstallReceipt is the outcome of Uninstall.

func Uninstall

func Uninstall(cwd, binDir string) (UninstallReceipt, error)

Uninstall removes the marker block, abcd's README parts, abcd's status line (handed back to the command it replaced) and the owned PATH entry (the spc-35 owned copy plus its provenance record, or a legacy pinned symlink) only. It never mutates hooks.json, and leaves the download cache to the harness's own uninstall. Its one write in the .abcd/ namespace is clearing readme.created from .abcd/config.json once the README.md that record vouches for is gone (uninstallReadme); nothing else there is touched.

binDir names the directory to look in, for the one case detection cannot derive: an install placed by `--bin-dir` in a directory that is not on PATH is invisible to a PATH scan, so uninstall would otherwise orphan it. Empty means the derived location — an abcd-owned entry anywhere on PATH, else the default.

type UpdateTarget

type UpdateTarget struct {
	Path         string           // first `abcd` on PATH ("" when absent)
	ResolvedPath string           // Path with symlinked ancestors/leaf resolved
	Kind         UpdateTargetKind //
	LaterOwned   string           // an abcd-owned entry shadowed behind Path ("" when none)
}

UpdateTarget names the first `abcd` PATH occupant — the binary that actually answers when the user types `abcd` — classified by the same ownership predicate detection and install use (one canonical predicate, iss-345).

func ResolveUpdateTarget

func ResolveUpdateTarget() UpdateTarget

ResolveUpdateTarget classifies the entry `abcd update` would act on. It walks PATH in order — the dispatch is keyed on what actually runs, not on one blessed location — and, when PATH holds nothing, reports the plugin root as the target when the running executable lives there (the plugin-invocation case still deserves the plugin-root refusal, not a "nothing installed" one).

type UpdateTargetKind

type UpdateTargetKind string

UpdateTargetKind classifies the PATH entry `abcd update` would act on. The update verb's dispatch (spc-32) keys on this: only a regular file whose provenance the verb can establish is ever swapped; every other shape is a named refusal, because another mechanism already owns it.

const (
	// UpdateTargetAbsent: no `abcd` anywhere on PATH.
	UpdateTargetAbsent UpdateTargetKind = "absent"
	// UpdateTargetPluginRoot: an owned symlink resolving into the current
	// plugin root — the plugin update owns that binary (itd-108 one-cut
	// coherence), never the update verb.
	UpdateTargetPluginRoot UpdateTargetKind = "plugin-root"
	// UpdateTargetDevShim: the track-latest dev shim — a chosen install mode.
	UpdateTargetDevShim UpdateTargetKind = "dev-shim"
	// UpdateTargetDangling: an abcd-owned entry whose binary is gone (the
	// iss-345 stranded shape included) — `ahoy install` is the heal.
	UpdateTargetDangling UpdateTargetKind = "owned-dangling"
	// UpdateTargetSuperseded: an owned symlink into a sibling plugin-cache
	// vintage the harness has moved past — the binary still exists, so it is
	// not stranded, but it answers an older release than the plugin now holds
	// (iss-2609161805447092). `ahoy install` is the heal.
	UpdateTargetSuperseded UpdateTargetKind = "owned-superseded"
	// UpdateTargetFile: a regular file. Ownership is decided by the update
	// verb's provenance check (digest against a published release), not here.
	UpdateTargetFile UpdateTargetKind = "file"
	// UpdateTargetForeign: a symlink abcd does not own, or an entry that
	// cannot be classified. Never touched.
	UpdateTargetForeign UpdateTargetKind = "foreign"
)

type VintageStatus

type VintageStatus struct {
	Mode     string         // install mode ("dev (tip build)" / "pinned" / "" / shadowed)
	Report   vintage.Report // outcome + current + expected
	Source   string         // reference name: "checkout tip" / "plugin manifest pin"; "" when the current vintage is undeterminable
	RepoRoot string         // the source checkout root, when the tip was the reference
}

VintageStatus is the assembled vintage picture for a repo: the install mode, the comparator's report, and the human name of the reference compared against. It is the single source the `version` and `ahoy` renders, the session-start notice, and the install refusal all consume — one comparison, many renders.

func Vintage

func Vintage(cwd string) VintageStatus

Vintage assembles the running binary's vintage picture for cwd. It resolves the install mode and the plugin root, reads the binary's own build vintage, and picks the applicable disk reference: the source checkout tip when cwd is abcd's own checkout (the dogfood case), otherwise the plugin-cache manifest pin. It never touches the network.

func (VintageStatus) DisplayVintage

func (v VintageStatus) DisplayVintage() string

DisplayVintage renders the vintage for a one-line surface: a short revision for a checkout-tip comparison, the version verbatim for a pinned one, and "unknown" when it could not be determined.

func (VintageStatus) Staleness

func (v VintageStatus) Staleness() string

Staleness renders the comparator verdict in the words a surface prints.

Jump to

Keyboard shortcuts

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