Documentation
¶
Index ¶
- Constants
- Variables
- func CheckoutRoot(ctx context.Context, cwd string) (string, error)
- func PaintRole(s State, text string) string
- func ReadSettingsFile(home string) (raw []byte, why string, err error)
- type Cell
- type Counts
- type Element
- type ElementKey
- type Input
- type Merging
- type MergingState
- type MergingWhose
- type Pair
- type Payload
- type PromptCounts
- type RGB
- type Repo
- type Result
- type Row
- type Settings
- type State
- type Table
- type Thresholds
- type View
Constants ¶
const ( // StateManaged: abcd is here and nobody is waiting. StateManaged = mode.Managed // StateFacilitator: the loop is parked on the facilitator. StateFacilitator = mode.Facilitator // StateProductThinker: the loop is parked on the product thinker. StateProductThinker = mode.ProductThinker )
const ( MergingLabel = "facilitator:" MergingUnread = MergingLabel + " not read" )
MergingLabel opens the merging element, and MergingUnread is the whole of it where the mode was not read: never a mode beside it, and only why where the computer's file could not be read.
const ( ThemeDark = "dark" ThemeLight = "light" )
The two themes.
const ContrastBar = 4.5
ContrastBar is the minimum contrast ratio a presence pair must measure to be allowed to render. See the package comment above for why it sits here.
const RecordRelDir = ".abcd/development"
RecordRelDir is the durable record's root, repo-relative. Its presence is what says a repository has a record to count: without it the two count elements are switched off rather than rendered as zeros nobody means.
const Separator = " "
Separator sits between two parts of the bundled row: one space, never ` · ` (decision 38). The table carries it, and a Row joins with its own table's.
const SettingsFileName = "statusline.json"
SettingsFileName is its leaf name.
const TableNamespace = "statusline"
TableNamespace is the key the table's layers sit under in config.json.
Variables ¶
var ErrNoCheckout = errors.New("statusline: no checkout git will answer for")
ErrNoCheckout is CheckoutRoot's answer for a directory git places in no checkout, or would not answer for.
MergingMode reads facilitator.mode for the repository at root as the status line's row shows it, and a note, masked, for the front door's stderr when a file that declares it was refused. The row calls it inside its git share, so it must ask git nothing.
It is set by the front door (internal/surface/cli, to landing.KeptMerging) rather than called here, because this package cannot import landing: landing reaches ahoy (through embargo, capture and site), and ahoy reads this package, so the import would close a cycle — the same reason MANAGED is the caller's decision. While it is nil the merging element drops silently, with no note: a composition with no reader has nothing it failed to read.
var PromptsRecorded func(ctx context.Context, root string) (PromptCounts, string)
PromptsRecorded reads the prompt counts for the repository at root, and a note, masked, for the front door's stderr when the record was refused. It is called inside the row's git share and must neither block past ctx nor fail the row: whatever it cannot read is zero counts.
It is set by the front door (internal/surface/cli) rather than called here, because the record is the away store's (internal/core/autonomy), which reaches ahoy, and ahoy reads this package: the import would close a cycle, as it would for MergingMode. While it is nil the element drops silently.
var SettingsDisplay = abcdhome.Display(SettingsFileName)
SettingsDisplay names the file in a diagnostic: the tilde form, never the expanded path, so a message a user pastes into a shell works and no diagnostic carries the caller's home path (iss-81, fsutil.RedactHome).
var SettingsRelPath = abcdhome.Rel(SettingsFileName)
SettingsRelPath is the user-level setting, relative to the caller's home.
var Views = []View{ViewProductThinker, ViewFacilitatorHuman, ViewFacilitatorAuto}
Views lists the table's columns in their fixed order.
Functions ¶
func CheckoutRoot ¶ added in v0.13.1
CheckoutRoot is the status line's checkout resolution: git's toplevel for cwd through gitutil.ToplevelContext, which holds the answer to the shape gitutil.Toplevel holds it to, under ctx. It answers the one question the verb asks of gitutil.CheckoutRoot — is there a root, and which — and differs only in being bounded: a context that ends first is returned as its own error (context.DeadlineExceeded, wrapped), never as ErrNoCheckout, so the verb does not mistake a slow git for "not a repository" and run the person's previous command over a checkout abcd manages.
func PaintRole ¶ added in v0.13.1
PaintRole paints text in a role's fixed badge pair, padded with one space of fill on each side as the badge pads its word, so another surface that names the role (the status board's view label, spc-2610031844142274) shows the same colours and no second copy of the hexes exists. A state with no fixed pair returns text unpainted. The caller decides whether the terminal can show it.
func ReadSettingsFile ¶
ReadSettingsFile performs the trust-boundary read of the user-level setting at path. It is the ONE reader of that file: Load reads through it to render the row, and ahoy's install and uninstall steps read through it to record and restore the previous command. The second consumer is why it is exported. `previous_command` is a shell command the harness runs on every refresh, and a reader that took it from a file others can write, or that is not the caller's own, would hand the harness a command somebody else chose — the guard has to be the same guard wherever the file is read, or the weakest reader is the one that runs.
Three outcomes, and the caller phrases the consequence of each:
- (nil, "", nil): there is no file — the ordinary case, not a diagnostic;
- (nil, why, nil): a file is present but is NOT the caller's word — not a regular file, writable by group or others, or owned by another uid — and why says which, as a clause after the file's name ("it is writable by others, ..."). Nothing is read from such a file: a caller that renders substitutes the defaults, a caller that would write refuses;
- (nil, "", err): a file that IS the caller's word cannot be read (over the cap, an I/O error). The error names the file in tilde form.
The guard is the one every home-scoped declaration uses, because it IS that read: fsutil.ReadHomeDeclaration, which opens ~/.abcd.noindex through fsutil.OpenHomeScope (a symlinked ~/.abcd.noindex refused, fsutil.HomeScopeLink's rule) and then judges the file on that descriptor — lstat, the three refusals above, the open, and os.SameFile tying the bytes to the lstat that was judged — under the byte cap. A file renamed into place after any look by path is judged as itself or not read at all, never read on the strength of a judgement made about the file it replaced (iss-2609290656491358).
Types ¶
type Cell ¶
type Cell struct {
Visible bool
Words map[string]string
Stages []string
// Drop is the rank the fit sheds the element at, lower first, ties by
// order; 0 for an unranked part, which is never shed.
Drop int
}
Cell is one element's resolved fields in one view.
type Counts ¶
Counts is the record half: open issues, and intents not yet shipped.
Zero is a fact about the record, not an absence, so a zero count renders. A caller that has no record to count switches the two elements off rather than passing a zero it does not mean.
type Element ¶
type Element struct {
Key ElementKey `json:"key"`
Rendered string `json:"rendered"`
Plain string `json:"plain"`
}
Element is one rendered slot of the row: what it is, how it looks with colour, and how it reads without.
Two forms rather than one because two consumers need different things from the same words. The status verb prints Rendered into a surface that interprets escapes; the `/abcd` board — the fallback where a host has no status surface — prints Plain. Neither invents the text.
type ElementKey ¶
type ElementKey string
ElementKey names one element of the row. The keys are also the names the per-element switches carry in the user-level setting and the entries carry in the table, so a switch and the thing it switches cannot drift apart.
const ( KeyPresence ElementKey = "presence" // KeySession is the session's name (itd-2610111707085098); the bundled // table hides it (decision 40). KeySession ElementKey = "session" KeyReviews ElementKey = "reviews" KeyWaiting ElementKey = "waiting" // KeyPrompts counts the host's approval prompts the hooks recorded as // waiting or refused while nobody was at the terminal // (iss-2611300053442453); absent at zero. KeyPrompts ElementKey = "prompts" KeyBuilds ElementKey = "builds" KeyDecisions ElementKey = "decisions" // KeyCheckout is the approved row's `repo:branch`, which honours the // person's `repo` and `branch` switches as halves (dcn-2611281659321827). KeyCheckout ElementKey = "checkout" KeyRepo ElementKey = "repo" KeyBranch ElementKey = "branch" // KeyMerging names the repository's facilitator.mode, human and auto // alike, and whose setting it is, or says it was not read // (itd-2611252117557299). The bundled table hides it (decision 40). KeyMerging ElementKey = "merging" KeyPR ElementKey = "pr" KeyPRs ElementKey = "prs" KeyModel ElementKey = "model" KeyAgents ElementKey = "agents" KeyContext ElementKey = "context" // KeyUsage is the approved row's usage part, which honours the person's // `five_hour` and `seven_day` switches as its two windows. KeyUsage ElementKey = "usage" KeyFiveHour ElementKey = "five_hour" KeySevenDay ElementKey = "seven_day" KeyIntents ElementKey = "intents" KeyIssues ElementKey = "issues" KeySpend ElementKey = "spend" )
func AskedKeys ¶
func AskedKeys() []ElementKey
AskedKeys are the elements the install asks the person about: every part the bundled table shows in at least one view, after the chip, in the row's order. A key the bundled table hides in every view is not asked, since its answer would change nothing on the bundled row; its switch still parses.
type Input ¶
type Input struct {
State State `json:"state"`
Repo Repo `json:"repo"`
Payload Payload `json:"payload"`
Counts Counts `json:"counts"`
// Merging is the repository's facilitator.mode as the composition knows
// it; MergingUnasked renders no merging element.
Merging Merging `json:"merging"`
// Prompts are the approval prompts recorded for the checkout; zero
// renders no prompts element.
Prompts PromptCounts `json:"prompts"`
// Table is the resolved table the row is drawn from; nil draws the
// bundled table.
Table *Table `json:"-"`
// View is the table's column being drawn; "" draws the facilitator's
// working by hand, the one view step 1 of spc-2611281205023617 draws
// (the view follows the chip from its step 2).
View View `json:"-"`
}
Input is everything renderRow reads.
type Merging ¶
type Merging struct {
State MergingState `json:"state"`
// Whose is whose setting decides the mode; "" with no mode, but for
// WhoseComputerUnread, which says why there is none.
Whose MergingWhose `json:"whose,omitempty"`
// Read is when the reading was made, as the row says it, where the
// default branch is known to have moved since, or cannot be told not to
// have; "" for a reading that still stands.
Read string `json:"read,omitempty"`
}
Merging is what a composition knows of the repository's facilitator.mode.
type MergingState ¶
type MergingState string
MergingState is the mode, or why there is none.
const ( // MergingUnasked: the composition had no reader, or the element is // switched off, so nothing was read and nothing is said. MergingUnasked MergingState = "" // MergingUnknown: a reader was asked and does not know the mode. It is // never drawn as either mode. MergingUnknown MergingState = "unknown" MergingHuman MergingState = "human" MergingAuto MergingState = "auto" )
type MergingWhose ¶
type MergingWhose string
MergingWhose is whose setting decides the mode, as the resolver's layer says: the default branch's committed file (the project's), the computer's file (the person's global setting), neither, the computer's file that could not be read because abcd refused the home, where the resolver's own answer stands, or a HOME that is not the person's own.
const ( WhoseProject MergingWhose = "project" WhoseComputer MergingWhose = "computer" WhoseUnset MergingWhose = "unset" WhoseComputerUnread MergingWhose = "computer-unread" // WhoseNotYourHome is a HOME that is not this account's own, where no // setting of the person's is read on purpose and the project leaves the // mode to each. WhoseNotYourHome MergingWhose = "not-your-home" )
type Payload ¶
type Payload struct {
// Model is the model's display name, falling back to its identifier when
// the harness supplies only that. Hidden runes stripped, then sanitized
// (sourceText).
Model string `json:"model,omitempty"`
// Effort is the payload's `effort.level`, the model's effort detail
// (`[high]`), empty when the harness does not supply it. Hidden runes
// stripped, then sanitized (sourceText).
Effort string `json:"effort,omitempty"`
// Fast is the payload's `fast_mode`, the model part's ` fast` detail.
Fast bool `json:"fast,omitempty"`
// ContextPct is the percentage of the context window in use.
ContextPct *float64 `json:"context_pct,omitempty"`
// FiveHourPct and SevenDayPct are the percentages of the five-hour and
// seven-day usage windows consumed. Either may read above 100.
FiveHourPct *float64 `json:"five_hour_pct,omitempty"`
SevenDayPct *float64 `json:"seven_day_pct,omitempty"`
// Cwd is the directory the harness is standing in: the payload's `cwd`,
// falling back to `workspace.current_dir`, empty when neither is supplied.
// It exists so the status verb can resolve the checkout the HARNESS is in
// rather than the one its own process happens to be in, and it is used for
// filesystem resolution only — never rendered, never echoed, so it is not
// sanitised and its tag keeps it out of every JSON envelope.
Cwd string `json:"-"`
// SessionID is the harness's own identifier for the session, the
// payload's `session_id`, empty when it is not supplied. It exists for one
// use: naming the session's fill file (spc-2610111627213138 step 5), which
// the rules loader keys on its hash. Like Cwd it is never rendered and
// never echoed, so it is not sanitised and its tag keeps it out of every
// JSON envelope.
SessionID string `json:"-"`
// SessionName is the session's title: one the person gave it, or the
// persona name abcd's prompt hook set (itd-2610111707085098). The
// harness supplies it only when the session has one. Sanitized, trimmed
// and cut to maxSessionNameRunes.
SessionName string `json:"session_name,omitempty"`
}
Payload is the parsed harness payload: what the four payload-sourced elements need, and nothing else. A nil pointer, or an empty Model, means the harness did not supply the field.
func ParsePayload ¶
ParsePayload reads the harness's status payload.
It refuses anything that is not a JSON object, the truncated stdin and the empty read included: a front door that mistook those for an empty payload would render a row that silently lost four elements, which is exactly the plausible-wrong-answer failure the drop rule exists to make visible. A caller that wants a row without payload elements passes a zero Payload.
type PromptCounts ¶
PromptCounts are the host's approval prompts the hooks recorded for the checkout while nobody was at the terminal, within the window bare `abcd mode` lists them for: those the host said were waiting for an answer, and those abcd's hook refused.
type Repo ¶
Repo is the repository half of the render's input: the two facts that come from the checkout rather than from the harness or the record.
type Result ¶
Result is what Compose returns: the state the badge reports, the row, and the notes the composition had to make on the way.
Notes are the out-of-band channel the rest of core uses (rules.Resolve, history.Resolve, LoadFrom here): a count the readers could not take is dropped from the row and NAMED, because a row that silently lost an element is exactly the plausible-wrong-answer the drop rule is meant to make visible. Core never prints; the front door puts them on stderr.
func Compose ¶
func Compose(ctx context.Context, root string, p Payload, set Settings, read func(context.Context, string) (Merging, string)) (Result, error)
Compose renders the row for an already-resolved checkout root.
The caller resolves the root (CheckoutRoot, or gitutil.CheckoutRoot) and decides whether the repository is managed before calling; Compose takes the root as given. The state is read from the mode store, and a store that cannot be read — a fourth word, a symlink, a device — is an ERROR rather than a quiet badge, for the reason mode.ReadAt gives: somebody wrote something there, and reporting "nobody is waiting" over it would hide the parked stop the badge exists to show.
The table is the bundled table with the machine's and the repository's config.json over it (loadTableHome), read as two files with no git question; the row draws the facilitator's view working by hand, the view step 1 of spc-2611281205023617 draws for every state (the view follows the chip from its step 2). The merging reader, the prompt reader (PromptsRecorded) and the two counts are asked only for an element that shows.
The branch comes from git: the symbolic ref's short name, or the short sha on a detached HEAD, or nothing (the element drops) when git will not answer. The counts are the record's folder counts (see the package comment), and are switched off in a repository that has no record. The settings are copied before any switch is thrown, so the caller's own Settings are never mutated.
Every git question is bounded by ctx. A git that has not answered when ctx ends is killed and its element drops, exactly as it drops when git will not answer at all, so a slow branch costs the row its branch and nothing else: the badge, the repository and the counts still render (iss-2610050556383525). A stored mode is the exception: it is read only once git says it tracks none of it, and one git cannot be asked about in time is an error, so the row blanks rather than badge a parked stop as managed.
read is the merging element's reader: the board reads facilitator.mode live, as its own line does, where the status verb reads the kept reading (ComposeContext, through MergingMode); nil reads nothing.
type Row ¶
type Row struct {
Elements []Element `json:"elements"`
// contains filtered or unexported fields
}
Row is the composed line: elements in order, ready to join. It is deliberately not a string — a front door that received a string would have to parse it back apart to reuse a part of it, and the board does exactly that.
func (Row) Element ¶
func (r Row) Element(k ElementKey) (Element, bool)
Element returns the element with the given key.
func (Row) Empty ¶
Empty reports whether the row carries nothing at all, which is what an unmanaged repository and a switched-off setting both produce.
type Settings ¶
type Settings struct {
SchemaVersion int `json:"schema_version"`
// Disabled is the off switch: abcd contributes nothing anywhere.
Disabled bool `json:"disabled"`
// Elements switches each element after the badge on or off. The badge is
// element one and is not switchable, so a key for it is ignored.
Elements map[ElementKey]bool `json:"elements"`
// Presence is the presence badge's pair. Held to ContrastBar at read time.
Presence Pair `json:"presence"`
// TextMode renders the row in ASCII alone (decision 9); false by default.
TextMode bool `json:"text_mode"`
// Theme is the terminal's theme the gauges are drawn for, `dark` or
// `light`; `dark` by default (decision 27: a setting, never detection).
Theme string `json:"theme"`
// Links lets the row carry OSC 8 links; true by default.
Links bool `json:"links"`
// PreviousCommand is the status command the harness was pointed at before
// abcd took the row, recorded at install and restored at uninstall. It is
// what makes "managed repositories only" true under a single harness-wide
// setting: outside a managed repository the status verb runs it with the
// same payload, so the user's own line is unchanged everywhere else.
PreviousCommand string `json:"previous_command"`
// Installed reports whether these settings were READ FROM A FILE the caller
// wrote, as against merged over an absent one. It is never serialised: it
// is a fact about the load, not a setting. The set form of the mode verb
// needs it (ac-7): "the host has no status surface" is this being false, or
// Disabled being true, and a load that merged defaults over nothing is
// otherwise indistinguishable from one that read a file holding them.
Installed bool `json:"-"`
}
Settings is the user-level configuration of the row.
func Defaults ¶
func Defaults() Settings
Defaults returns a deep copy of the binary-bundled defaults, safe for the caller to mutate.
func LoadFrom ¶
LoadFrom reads the setting from an explicit home, merges it over the bundled defaults per field, and returns the result together with the notes the read had to make.
The notes are the out-of-band diagnostic channel this codebase already uses for exactly this (rules.Resolve, history.Resolve): core never writes to a stream, so a declaration it declined to honour is RETURNED for the front door to print on stderr. A refusal that printed nothing would be indistinguishable from a setting that was taken.
func (Settings) Enabled ¶
func (s Settings) Enabled(k ElementKey) bool
Enabled reports whether an element renders. The badge always does.
type State ¶
State is what the badge is reporting. It is the stored mode's own type (`.abcd/.work.local/mode`, one line, spc-70): mode OWNS the vocabulary — the three words, their parse and their store — and this package holds only the render's view of it. The alias keeps the render's API and tests in their own words while making the two packages' states the same type by construction, so a state read out of the store reaches renderRow without a conversion that could drift. Importing a type is not touching a store: the render stays pure, and mode never imports this package.
type Table ¶
type Table struct {
Order []ElementKey
Separator string
DetailOrder []string
Thresholds Thresholds
// contains filtered or unexported fields
}
Table is the resolved table the row renders from.
func (*Table) Cell ¶
func (t *Table) Cell(k ElementKey, v View) Cell
Cell returns k's fields in view v; an element the table does not hold is a hidden cell.
func (*Table) DropOrder ¶
func (t *Table) DropOrder(v View) []ElementKey
DropOrder is the order the fit sheds whole elements in in view v: every ranked element, the lowest rank first, ties in the table's order. The unranked parts (the chip, the reviews, waiting and the decisions count) are never in it.
type Thresholds ¶
type Thresholds struct {
ReviewsCount int `json:"reviews_count"`
ReviewsAgeHours int `json:"reviews_age_hours"`
KeyBudgetPct int `json:"key_budget_pct"`
ContextPct int `json:"context_pct"`
UsagePct int `json:"usage_pct"`
Margin int `json:"margin"`
LabelCut int `json:"label_cut"`
}
Thresholds are the figures the elements are judged against.