Documentation
¶
Overview ¶
Package question holds what a question abcd puts to a person may contain: the field limits, written once (Limits, Default), the field view every front door finally shows (Fields), and the limits check (CheckLimits) that refuses a badly built question naming the part, the value, and the limit (spc-2610030944505997; itd-2610030810350727, itd-201).
Nothing else in the tree states a limit. The question check in the guard hook, the GRILL rule text and the interview pages read Default, so changing a limit here changes every statement of it (itd-2610030810350727 criterion A7).
The package is a library: it returns values and never prints. It measures text through internal/textwidth, a pure leaf, and imports nothing that does terminal I/O.
Index ¶
- Constants
- Variables
- func AskingRecall() []string
- func AskingRules(l Limits) []string
- func Matches(filter string, o Option) bool
- func RefusingFinding(f Finding) bool
- type Addressee
- type Ask
- type Block
- type Bound
- type Choice
- type Fields
- type Finding
- type Limits
- type LimitsRefusal
- type List
- type Option
- type Outcome
- type Person
- type Question
- type RowSplit
- type Rule
- type State
- type Store
- type Tab
- type Unread
- type Verdict
Constants ¶
const ( KindParagraph = "paragraph" KindList = "list" )
The kinds a material block takes.
const ( RowsKey = "question.rows" LabelWordsKey = "question.label_words" DescriptionSentencesKey = "question.description_sentences" )
The keys a repository sets in .abcd/config.json, under the question namespace, and that a person's own ~/.abcd.noindex/config.json may set lower (itd-2610301914350541 decisions 1 and 5). Only these three are configurable; every other figure in Limits stays the binary's (decision 2).
const EmDashListItemPattern = "^\\s*(?:[-*+]|[0-9]+\\.)\\s.*\u2014"
EmDashListItemPattern is rule 12's pattern: a line opening a list item that carries an em dash. It is the docs-lint token punctuation/em-dash-in-list-item, whose definition lives in ahoy's docs-lint seed; a test in internal/core/ahoy holds the two equal.
const KnowledgeFloorPage = ".abcd/development/brief/glossary/interview/knowledge-floor.md"
KnowledgeFloorPage is where the knowledge floor is stated in full: a glossary entry in abcd's development record, which every install of the plugin carries under its plugin root (spc-2610030944505997, open question 4, decided (a)). The asking rules point at it in one line rather than restating it (itd-201 decision 5).
const ProductRole = "Product"
ProductRole is the chip role word that names the product thinker. Where no mode names the addressee, a chip carrying it stands in for the mode (rule 9).
const RecommendedRemedy = "" /* 275-byte string literal not displayed */
RecommendedRemedy is rule 8's remedy. It names the cause, so the agent does not loop (itd-201 criterion R6).
const TypedRowLabel = "Type my own answer"
TypedRowLabel is the label of the one option a front door adds to a question with a typed part when the host's question tool takes fewer listed options than the question has (a typed part and decide later alone): it points at the host's free-text row and answers nothing itself, so an interview that receives it asks the question again.
const TypedTextPrefix = "Or type in the row below:"
TypedTextPrefix opens the line of the question text that says what the typed part takes.
Variables ¶
var Bounds = []Bound{ {Key: RowsKey, Floor: 24, Ceiling: 60}, {Key: LabelWordsKey, Floor: 4, Ceiling: 8}, {Key: DescriptionSentencesKey, Floor: 2, Ceiling: 4}, }
Bounds is the one statement of the bounds, in the order Bounded takes its values: rows, label words, description sentences. The floor of each is drawn so that every question the binary composes is admitted whole at it, and the ceiling where the protection would stop protecting (itd-2610301914350541 decision 3):
- question.rows, 24 to 60: the standard screen, up to a full-height terminal on a large display; past it "fits one screen" protects no screen a person has.
- question.label_words, 4 to 8: the longest label the binary composes is four words ("Yes, make the change"); past eight a label wraps at the option measure and reads as a description.
- question.description_sentences, 2 to 4: the longest description the binary composes is two sentences; past four a description holds material, which belongs in the question text.
Nothing else in the tree writes a bound: the resolver's refusal, the loader's note and the generated page sentence render these.
var Default = Limits{ HeaderColumns: 12, ChipRoles: []string{ProductRole, "Tech", "Setup"}, QuestionsPerCall: [2]int{1, 4}, OptionsPerQ: [2]int{2, 4}, LabelWords: 5, MeaningSentences: 2, LaterLabels: []string{"Decide later", "None of these"}, Columns: 80, Rows: 32, HostTextColumns: 76, HostChromeRows: 8, HostOptionColumns: 74, NowPrefix: "Now:", ChangeLaterPrefix: "Change later:", NotApplicable: "not applicable", }
Default is the one statement of every limit.
Functions ¶
func AskingRecall ¶
func AskingRecall() []string
AskingRecall returns the GRILL domain's recall terms, a fresh copy each call.
func AskingRules ¶
AskingRules returns the asking rules every abcd interview follows, the text the GRILL rule domain carries in every repository abcd manages (spc-2610030944505997, "GRILL generated from one Go source"). Every limit it states is filled from l, numbers written as words, so the text and the question check read one statement of each limit (itd-2610030810350727 criterion A7). The text names no record and no source-tree command: it reaches repositories that have neither (itd-201 decision 8).
The register rule, the ask-the-role-first rule and the mode rules open with "In abcd's own interviews": they hold for abcd's command pages, never for another tool's questions in a managed repository (itd-201 decision 10).
func Matches ¶
Matches is the narrowing rule (spc-2610030911534855, "The answer loop"): the typed text, matched case-insensitively as a substring of the option's label or of its value. Empty text matches every option. The plain-Terminal list narrows with it and so does guided connect's session (spc-2610031241482088), so a fragment narrows the same in both places.
func RefusingFinding ¶ added in v0.16.1
RefusingFinding reports whether a finding refuses the call on its own: every rule but the rows limit (iss-2610070637562567).
Types ¶
type Addressee ¶
Addressee is the check's input about whom a question is for. Verbs is the binary's verb list, which the surface reads from its command tree and passes in, so the core holds no copy of it (rule 9).
type Ask ¶
type Ask struct {
Questions []Question `json:"questions"`
}
Ask is what one turn puts to the person: one question, or up to four parts of one thing shown as tabs (itd-2610030810350727 decision 10). It is the structured question both front doors use (spc-2610030911534855, "One question type, defined here first"): abcd draws it in a plain Terminal, and Fields maps it onto the host's question tool.
func Safe ¶
Safe returns a copy of a with every part sanitised for the screen (spc-2610030911534855, "Sanitising before drawing"). Every string in a question is runtime-read: a runner wrote it, a record supplied it, or a model service listed it. Each single-line part (the id, the chip, the ask, every option's and list choice's value, label and meaning, Now, Change later and the typed part's prompt) passes termsafe.Sanitize, so a line break inside a label cannot forge a line; each material block passes termsafe.SanitizeBlock. An injected escape, a C1 control, a bidi override, a zero-width rune or a bare carriage return reaches the screen as a visible '?'. a itself is left unchanged. The drawing (internal/surface/cli/ask) and the AI-written interviews' check (internal/core/interview) both sanitise through it, so what is measured is what is drawn.
func (Ask) Fields ¶
Fields maps the Ask onto the field view the limits are checked on (spc-2610030944505997, "The field view"): the chip to the header; the material's blocks, then the Now: and Change later: lines, then the ask, to the question text; the options (a long list's choices) and then Later to the options; the typed part to the free-text row (Tab.Typed), its prompt said in the text just before the ask. A line the question does not carry is left out, so the limits check names the gap rather than the mapping inventing a value.
type Block ¶
type Block struct {
Kind string `json:"kind"` // KindParagraph or KindList
Text string `json:"text,omitempty"`
Items []string `json:"items,omitempty"`
}
Block is one piece of a question's material: a paragraph, or a list.
type Bound ¶ added in v0.16.1
Bound is the inclusive range a configurable limit may be set to. A limit with no bounds could switch a protection off with a legal value (a thousand rows, or a label the width of a description), so each key has a floor and a ceiling (itd-2610301914350541 decision 3).
type Choice ¶
type Choice struct {
Label string // a few words
Description string // what choosing it means
Preview string // the host's side preview, which abcd's questions never carry (rule 14)
}
Choice is one option of a question, as the host shows it.
type Fields ¶
type Fields struct {
Tabs []Tab
}
Fields is the field view of one call to the host's question tool: one question, or up to four parts of one thing shown as tabs. It is what every front door finally shows, so the limits are checked on it. The guard hook decodes the host's tool input into it (the JSON key names are the host's, so the decoding lives in the surface); the companion's structured question type is mapped onto it by that type's own method.
type Finding ¶
Finding is one broken rule: the question's ordinal (its tab, counted from one; zero is the call as a whole), the part, the rule, the offending value (sanitised and capped, as the mode store's echo is), the limit, and what to do about it.
func Check ¶
Check is the structural check: every question has an id (unique within the Ask), a chip, an ask, a Later option with a value, and options, a list, or a typed part; every option and list choice has a value and a label; values are unique within a question, Later's included; no answer's meaning points at text above a question that carries no material (pointsAbove); an Ask holds as many questions as Default.QuestionsPerCall admits. It returns every finding at once, each naming the question (its tab, counted from one; zero is the Ask as a whole) and the part, and holds no limit of its own: how much each part may hold is CheckLimits's, run on the field view (Fields).
func CheckLimits ¶
CheckLimits holds a call's fields to l and returns every finding at once, so one refusal names every part to fix and the agent fixes them in one retry. It refuses and never rewrites: a rewritten question puts words in the agent's mouth that neither the agent nor the person chose. No finding means the question is admitted.
type Limits ¶
type Limits struct {
HeaderColumns int // 12: the host's header chip
ChipRoles []string // "Product", "Tech", "Setup": the chip's first word
QuestionsPerCall [2]int // 1..4: one question, or up to four tabs
OptionsPerQ [2]int // 2..4, the decide-later option included
LabelWords int // 5
MeaningSentences int // 2: an option's description
LaterLabels []string // "Decide later", "None of these"
Columns int // 80: the narrow window promised
Rows int // 32: one question, or one tab, at Columns
HostTextColumns int // 76: the question text's measure inside the host's frame at Columns
HostChromeRows int // 8: rows the frame draws around a question, the chip included
HostOptionColumns int // 74: the measure of an option's label and description at Columns
NowPrefix string // "Now:"
ChangeLaterPrefix string // "Change later:"
NotApplicable string // "not applicable"
}
Limits is every bound a question's fields are held to. question.Default is the one value the check, the GRILL domain, and the interview pages read (itd-2610030810350727 decision 14, criterion A7).
func Bounded ¶ added in v0.16.1
Bounded is l with its three configurable fields replaced by rows, labelWords and sentences, every other field unchanged. It judges nothing: the resolver holds the values to Bounds before it calls it.
func CeilingsForTest ¶ added in v0.16.1
CeilingsForTest is l at the ceiling of every configurable key (see FloorsForTest).
func FloorsForTest ¶ added in v0.16.1
FloorsForTest is l at the floor of every configurable key, and CeilingsForTest at the ceiling of every one. They are test seams, named so: every question the binary composes is held to FloorsForTest(Default), and every combination of floors and ceilings to the fixed rules.
func (Limits) Configurable ¶ added in v0.16.1
Configurable is l's three configurable figures, in Bounds' order.
type LimitsRefusal ¶ added in v0.16.1
type LimitsRefusal struct {
Key string
Value string
Bounds string
File string
Limit int
LimitFile string
// Reason is the resolver's own refusal, naming the file; the surface
// scrubs it before it is shown.
Reason string
}
LimitsRefusal is a question limit the resolver read and refused: a value outside its bounds, not a whole number, a key the question namespace does not claim, or a personal value looser than the limit in force (itd-2610301914350541 decision 7). While it holds, every question of abcd's is refused and none is checked: nothing falls through to the defaults. The fields are the resolver's; Key, Value, Bounds and File are empty where the refusal names no single key (an unclaimed key is named in Reason alone), and Limit and LimitFile are set only for a personal value that loosens.
type List ¶
type List struct {
Choices []Option `json:"choices"`
}
List is a choice among many (300 models): the question's Options stay empty and the choices live here; the Later option still applies.
type Option ¶
type Option struct {
Value string `json:"value"`
Label string `json:"label"`
Meaning string `json:"meaning"`
}
Option is one answer: the value recorded, a label of a few words, and what choosing it means, with its trade-off.
type Outcome ¶ added in v0.16.1
type Outcome string
Outcome is what the guard hook does with a question-tool call.
const ( // OutcomeAdmit is a question of abcd's with no finding: the hook lets it // run silently and, where the badge shows, marks it open. OutcomeAdmit Outcome = "admit" // OutcomeAdmitWithRowsNote is a question whose only findings are the rows // limit's: the hook shows it and tells the agent afterwards // (iss-2610070637562567). OutcomeAdmitWithRowsNote Outcome = "admit-with-rows-note" // OutcomeRefuse is a question of abcd's with a finding that refuses: the // hook denies the call naming the findings. OutcomeRefuse Outcome = "refuse" // OutcomeRefuseAway is any question while the person is away: the hook // denies it before any rule is read (spc-2610180914469489). OutcomeRefuseAway Outcome = "refuse-away" // OutcomeAdmitUnchecked is a question that is not abcd's: the hook lets it // run unchecked and unmarked. OutcomeAdmitUnchecked Outcome = "admit-unchecked" // OutcomeUnchecked is a question the hook admits on its loud, // non-blocking status because a store the decision needed could not be // read, and the verdict is partial. abcd's question has been checked // (Abcds is set), and only one the gate cannot tell is abcd's runs with // no rule applied. OutcomeUnchecked Outcome = "unchecked" )
The outcomes, decision 3's set.
type Person ¶
type Person int
Person is whom a question is addressed to, as the mode records it.
const ( // Unnamed is no mode naming anyone: a repository abcd does not manage has // no mode store, and a managed mode parks on nobody. The chip's role word // then stands in, since the chip names whom the question is for. Unnamed Person = iota // ProductThinker is the mode naming the product thinker. ProductThinker // Facilitator is the mode naming the technical facilitator. Facilitator )
func ChipPerson ¶ added in v0.16.1
ChipPerson is the person one chip role word names: the product thinker for the Product role, the technical facilitator for every other role (Tech and Setup; the setup interview asks how abcd is installed and run, the facilitator's half).
type Question ¶
type Question struct {
ID string `json:"id"` // stable: a setup key, or the turn's ordinal
Chip string `json:"chip"` // who it is for and which question: "Setup Q1"
Material []Block `json:"material"` // the thing being decided: paragraphs and lists
Ask string `json:"ask"` // the one plain question
Options []Option `json:"options"` // the substantive answers
Later Option `json:"later"` // the way to decide later, always present
Now string `json:"now,omitempty"` // what holds now (itd-2610030810350727 decision 4)
ChangeLater string `json:"change_later,omitempty"` // how to change the answer later (decision 4)
List *List `json:"list,omitempty"` // the long-list variant
// Typed is the prompt for a typed answer: a question with a typed part
// takes any text as its answer besides its options (spc-2610031241482088,
// "The typed part on the question type"). The host's question tool takes
// it in its free-text row, so such a question carries no side preview,
// which would remove that row; the Terminal draws it as one line after
// the options. It counts as one option toward the limits' floor.
Typed string `json:"typed,omitempty"`
// Default is the value of the entry a drawn list's cursor starts on (an
// option's or Later's), so Enter alone takes it; with none, or one no
// entry carries, the cursor starts on the first option. It moves the
// cursor and nothing else: the options keep their order, and no text
// says it (Fields leaves it out), since an answer marked or put first
// would read as recommended.
Default string `json:"default,omitempty"`
}
Question is one question: the thing being decided first, then the one plain question, then the answers and the way to decide later.
type RowSplit ¶ added in v0.16.1
type RowSplit struct {
HeaderAndFrame int `json:"header_and_frame"`
QuestionText int `json:"question_text"`
Options int `json:"options"`
Total int `json:"total"`
}
RowSplit is the row estimate by part: the host's frame with the header's chip row, the question text, and the options with their descriptions, and their sum. The rows finding reports it, so the asker sees which part to cut (iss-2610071538055431), and `abcd guard question` reports it for every tab (spc-2610301917245442), so the drafter copies the check's figures instead of counting by hand.
type Rule ¶
type Rule string
Rule names one of the limits check's rules (spc-2610030944505997, "The limits check"). Each is reported as its own finding.
const ( RuleHeader Rule = "header" // 1: present, within HeaderColumns, in the chip grammar RuleQuestionsPerCall Rule = "questions-per-call" // 2: one to four; more than one is tabs RuleOptions Rule = "options" // 3: two to four, decide-later included RuleLabelWords Rule = "label-words" // 4: at most LabelWords words RuleMeaningSentences Rule = "meaning-sentences" // 5: a description present, at most MeaningSentences RuleDecideLater Rule = "decide-later" // 6: exactly one LaterLabels option, last RuleNoBold Rule = "no-bold" // 7: no ** or __ outside previews RuleNeverRecommended Rule = "never-recommended" // 8: no (Recommended), no star mark RuleRegister Rule = "register" // 9: the product thinker sees no handle or command RuleNowAndChangeLater Rule = "now-and-change-later" // 10: a Now: and a Change later: line, each with a value RuleThingFirst Rule = "thing-first" // 11: material first, the question last RuleEmDashListItem Rule = "em-dash-in-list-item" // 12: no em dash in a list item RuleRows Rule = "rows" // 13: within Rows at Columns RuleNoPreview Rule = "no-preview" // 14: no option carries a side preview )
The rules, in the spec's order, rule 14 appended by the layout intent's decision 20.
const RuleStructure Rule = "structure"
RuleStructure names a structural finding: a part a question cannot be drawn, answered or recorded without. Check reports it; the limits are CheckLimits's.
type State ¶ added in v0.16.1
type State struct {
// Repo is true when the repository root was found, so the away record
// was consulted and the verdict depends on it.
Repo bool
// Away is true while the person's away record holds.
Away bool
// AwayErr is why the away record could not be read safely; it then reads
// as not away.
AwayErr error
// Badge is true in a checkout abcd manages with the local tier, the only
// place a mode store exists.
Badge bool
// Mode is the person the mode names; Unnamed for managed or no store.
Mode Person
// ModeErr is why the mode store could not be read where the badge shows.
ModeErr error
// RootErr is why the repository root could not be found in a tree that
// looks like a checkout, so the mode store was never read.
RootErr error
// Verbs is the binary's verb list, for the register rule.
Verbs []string
// Limits is the question limits in force, as the resolver returned them
// (itd-2610301914350541): the defaults with what the repository's file
// set and the person's own file tightened. Where a layer was unread, and
// where a value was refused, it is the defaults, read then only for the
// header grammar and the rows split. The surface passes it to Decide.
Limits Limits
// LimitsSource is where each figure of Limits came from, one origin per
// key in Bounds' order: "bundled", or the file that set it.
LimitsSource []string
// LimitsRefused is set when a question limit was read and refused.
LimitsRefused *LimitsRefusal
// LimitsErr is why a layer of the question limits could not be read, and
// LimitsFile the file it names; abcd's question is then checked at the
// defaults.
LimitsErr error
LimitsFile string
}
State is what the gate knows about the checkout before it decides: whether the person is away, whom the mode names, whether the badge shows, and the binary's verbs. An Err field set means that store could not be read; its text is the reader's and is the surface's to scrub.
type Store ¶ added in v0.16.1
type Store string
Store names a state store the decision reads.
const ( // StoreAway is the away record: while it holds every question is // refused, so it decides whether any rule is read at all. StoreAway Store = "away" // StoreMode is the waiting-on mode, read where the badge shows: it decides // whether a question without abcd's chip is abcd's and, for one, the // product thinker's register rule. StoreMode Store = "mode" // StoreLimits is the question limits a repository's .abcd/config.json // and the person's own ~/.abcd.noindex/config.json set // (itd-2610301914350541). It is read for abcd's question only; a layer // of it that could not be read leaves abcd's question checked at the // defaults, so the rules it decides are applied, at the wrong figures // for a repository that set its own. StoreLimits Store = "limits" )
The stores.
type Tab ¶
type Tab struct {
Header string // the chip: whom the question is for and which it is
Text string // the material, the Now: and Change later: lines, then the question
Options []Choice // the answers, the decide-later option last
// Typed is the prompt of the question's typed part, taken in the host's
// free-text row: it is no option the host lists, and the limits count it
// as one toward their floor. The host's own input carries none.
Typed string
}
Tab is one question of a call: the four fields the host's question tool takes. A call with one question has one tab.
type Unread ¶ added in v0.16.1
type Unread struct {
Store Store
Err error
Rules []Rule
// File is the file that could not be read, where the store is one: set
// for the question limits.
File string
}
Unread is one store the decision needed and could not read, with why and the rules it therefore could not apply.
type Verdict ¶ added in v0.16.1
type Verdict struct {
Outcome Outcome
// Abcds is true when the question is abcd's: a header in the chip
// grammar, or a mode naming somebody.
Abcds bool
// Chipped is true when a header is in abcd's chip grammar.
Chipped bool
// Findings is every finding of the limits check, in CheckLimits's order;
// empty when no rule was read (away, or not abcd's question).
Findings []Finding
// Addressees is the person each checked tab is for: the chip's role for
// a chipped tab, the mode's person otherwise.
Addressees []Person
// ModeAfter is the mode an admitted question leaves where the badge
// shows: the chip's person for a chipped question, the current mode
// otherwise. ModeChanges is true when it differs from State.Mode
// (decision 15).
ModeAfter Person
ModeChanges bool
// Rows is the row split of every checked tab, in tab order.
Rows []RowSplit
// Partial is true when a store the decision needed could not be read;
// Unread names each one.
Partial bool
Unread []Unread
// DependsOnState is true when another mode or away state could change
// the outcome: a mode set, or the person marked away, between this
// verdict and the ask can turn it (decision 5).
DependsOnState bool
// Refused is the question limit that refused the call, set with the
// refuse outcome and no finding: the configuration, not the draft, is
// what must be fixed (itd-2610301914350541 decision 7).
Refused *LimitsRefusal
}
Verdict is the decision: the hook's outcome, every finding, each tab's addressee, the rows of every checked tab, and what the decision could not read.
func Decide ¶ added in v0.16.1
Decide judges one question-tool call as the guard hook judges it, in the hook's order: the away record first (refuse-away before any limit), then the mode store where the badge shows, then whether the question is abcd's, then the limits. It writes nothing and reads no store: s carries what the surface read, and l is the limits the call is judged at, s.Limits as the surface resolved them.
The question limits' outcome is read only for abcd's question (itd-2610301914350541): another tool's runs unchecked whatever either file says. For abcd's, a refused limit is the refuse outcome with no finding and Refused set, and an unread layer leaves the call checked at l (the defaults, on that path), partial and naming the file, so a configuration that cannot be read never lets a question through unchecked. A mode store that cannot be read is the same for a chipped question: its chip names whom it is for, so it is checked at l, partial and naming the store, and only a question without a chip, which the mode alone could make abcd's, runs unchecked.