Documentation
¶
Overview ¶
Package cli is abcd's default front door: a Cobra command tree that marshals internal/core results to the terminal (human text or, with --json, machine output). It holds no business logic — every command delegates to core and only formats the result, so an MCP or other front door can expose the same core verbs without duplicating behaviour.
Index ¶
- Constants
- func AskTheBinaryBlock(name, rung string) string
- func CommandFacts() []surface.Facts
- func CommandFactsBlock(facts []surface.Facts, name, rung string) string
- func CommandFactsFiles(facts []surface.Facts) (map[string][]byte, error)
- func EncodeCommandFacts(doc CommandFactsDocument) ([]byte, error)
- func GenerateReference() string
- func GenerateSurface(repoRoot string) ([]byte, error)
- func GuardSurface(repoRoot string) (changelog.SurfaceGuard, error)
- func IdentityGenSource(title, tagline string) []byte
- func InputShapes() ([]surface.InputShape, error)
- func NewRootCommand() *cobra.Command
- func Run(args []string, stdout, stderr io.Writer) int
- func SurfaceChapters(repoRoot string) ([]surface.RegeneratedChapter, error)
- func SurfaceSnapshot(repoRoot string) (surface.Snapshot, error)
- func SyncCommandPage(page []byte, name string, facts []surface.Facts) ([]byte, error)
- type CommandFactsDocument
- type SentencePage
Constants ¶
const ( CommandFactsBegin = "<!-- generated: command-facts -->" AskTheBinaryBegin = "<!-- generated: ask-the-binary -->" GeneratedBeginPrefix = "<!-- generated:" GeneratedEnd = "<!-- /generated -->" )
The markers fencing the two generated blocks of a command page. The end marker is the one every generated block in the repository closes with, and every begin marker opens with GeneratedBeginPrefix, this file's two and asking-sync's alike.
const CommandFactsDir = "docs/reference/cli/commands"
CommandFactsDir is the directory the per-verb JSON files are written to, repo-relative. It sits beside the generated CLI reference and outside commands/, which hosts read as command pages (the spec's first decision).
const CommandPagesDir = "commands"
CommandPagesDir is the plugin's command pages, repo-relative.
const ReferencePagePath = "docs/reference/cli/commands.md"
ReferencePagePath is the committed CLI reference page, relative to the repo root. The generator writes it and the drift test (reference_test.go) diffs the freshly-walked tree against it, so the two agree on one location.
const SurfaceSnapshotPath = surface.SnapshotPath
SurfaceSnapshotPath is the committed compatibility snapshot, relative to the repo root. The generator writes it, the drift test (surface_test.go) diffs the freshly-walked surface against it, and the release guardrail reads the baseline copy of it out of the last release tag — so all three agree on one location, declared once beside the type in internal/core/surface. It sits under the development record rather than under docs/ because it is a release-gate input, not something a reader of the documentation consumes.
const UseWhenCap = 300
UseWhenCap is the most characters a page's use-when text may run to. The longest use-when clause of the deleted pages whose trigger phrases it carries ran to about 200.
Variables ¶
This section is empty.
Functions ¶
func AskTheBinaryBlock ¶ added in v0.17.0
AskTheBinaryBlock is the block that stands straight after a page's H1 heading, from its begin marker through its end marker: one sentence sending the agent to the running binary's `abcd explain` before it fills in an input, spelled with the page's own rung.
func CommandFacts ¶ added in v0.16.1
CommandFacts is every command's facts (spc-2610301431075964 step 1), in canonical order, from a fresh tree that is never executed, for the same reason SurfaceSnapshot builds one.
func CommandFactsBlock ¶ added in v0.17.0
CommandFactsBlock is the block that stands at the end of a page, from its begin marker through its end marker. Its first line names the facts' format version and sends the reader to the running binary where the two disagree. For each command the page covers it lists the usage line, each input with its schema version, and the example. A page whose commands declare no visible flag and read no input gets the first line alone.
func CommandFactsFiles ¶ added in v0.17.0
CommandFactsFiles renders every per-verb JSON file from facts, keyed by its repo-relative path: one file per visible top-level verb holding that verb's visible subtree, and one named for the root holding the root command alone, whose persistent flags every verb inherits. A verb with no plugin page gets its file too.
func EncodeCommandFacts ¶ added in v0.17.0
func EncodeCommandFacts(doc CommandFactsDocument) ([]byte, error)
EncodeCommandFacts encodes a facts document as the derived copies hold it: indented by two spaces, with no HTML escaping, so a usage line's <verb> reads as written, and with a closing newline.
func GenerateReference ¶
func GenerateReference() string
GenerateReference walks the abcd command tree and renders it as a single, deterministic Markdown reference page — the source of truth for docs/reference/cli/commands.md. Hidden commands (the operator-internal `hook` subtree) and the stubs of spellings that moved are omitted, and children are emitted in a stable alphabetical order, so the output depends only on the command tree — never on registration order or the clock. That determinism is what lets a `go test` diff detect drift.
func GenerateSurface ¶
GenerateSurface renders the current surface as the committed artefact's bytes. Both the generator and the drift test call it, so the file that is written and the file that is checked are produced by one code path and can never disagree on formatting.
func GuardSurface ¶
func GuardSurface(repoRoot string) (changelog.SurfaceGuard, error)
GuardSurface runs the release surface guardrail for the repository at repoRoot: it builds the CURRENT compatibility surface from the live command tree and the live manifests, and hands it to the core guardrail, which reads the baseline out of the last release tag and answers whether a narrowing was declared.
This is the split the architecture requires. Building the current surface means walking cobra, which internal/core may not do; judging a break is domain logic, which must not depend on a transport. The front door therefore owns the walk and core owns the verdict, and the dependency points one way only.
It is the entry point the ship flow calls. There is deliberately no `launch ship` verb yet — the write path is a later phase — so today this is reached from tests and from whatever front door composes the cut next; the guardrail itself is complete and does not change when that verb arrives.
func IdentityGenSource ¶
IdentityGenSource is the single template for the generated identity file: the identitygen command writes it, and the drift test regenerates and byte-compares the committed file against it — one source, so the file can drift in neither values nor form (the livery RenderSVG shape).
func InputShapes ¶ added in v0.16.1
func InputShapes() ([]surface.InputShape, error)
InputShapes is every registered input's shape, sorted by command path and flag.
func NewRootCommand ¶
NewRootCommand builds the abcd command tree. Bare `abcd` renders a read-only status board (abcd's convention: bare invocation never mutates); subcommands carry the actions.
func Run ¶
Execute runs the root command; main sets the process exit code on error. Run builds the command tree, executes it against args, and renders any error as a single diagnostic line — the one place that maps a command error to a process exit code, so main stays a thin shell. stdout/stderr are injected so the whole front door (including its error surface) is testable.
func SurfaceChapters ¶ added in v0.10.0
func SurfaceChapters(repoRoot string) ([]surface.RegeneratedChapter, error)
SurfaceChapters regenerates every brief surface chapter's appendix from the live command tree (itd-147). It walks the tree with commandSurface — the walk that builds the compatibility snapshot — so the snapshot and the chapters are derived from one traversal and cannot disagree about what the tree holds. The generator (cmd/abcd-gen-surface) writes each chapter's Want and the drift test compares it with Committed, so both come from this one call.
Which shipped surfaces are host-delegated is read from the record-lint config's surface_coverage host_delegated list, the one place it is declared, so an appendix calls a command host-delegated only when that list does (iss-2609302306003610).
func SurfaceSnapshot ¶
SurfaceSnapshot builds the current compatibility surface: every command in the tree with its flags, plus the declared entries of the two plugin manifests under repoRoot.
It walks the shared NewRootCommand() tree — the one canonical root command, the same one the CLI executes — rather than the Markdown reference walker. GenerateReference emits prose, returns early on hidden commands, and carries no structured requiredness or manifest data; reusing it would bake those blind spots into a compatibility gate. What is shared is the tree, which is the part that must not diverge.
The tree is built fresh here and never executed. Cobra lazily attaches its default `help` and `completion` machinery during execution, so snapshotting an executed tree would record surface that a freshly-built one does not have, and the answer would depend on what else ran first in the process.
func SyncCommandPage ¶ added in v0.17.0
SyncCommandPage returns page with both generated blocks rendered from facts for the page named name, every byte outside the blocks kept. A block that is present is rewritten where it stands, which must be its place: the ask-the-binary block straight after the H1 heading, with nothing but blank lines between, and the command-facts block last, followed by nothing but the closing user-input line. A block that is absent is written into its place. A page with no H1 heading, a block opened twice or never closed (before the page ends, or before another generated block opens), a block out of its place, or a name the tree has no visible verb for is a fault: the generator never guesses.
Types ¶
type CommandFactsDocument ¶ added in v0.17.0
type CommandFactsDocument struct {
FormatVersion int `json:"format_version"`
Commands []surface.Facts `json:"commands"`
}
CommandFactsDocument is the shape of every derived JSON copy of the facts: each per-verb file and `abcd explain --json` for one command. It carries the facts' format version and no binary version, so a file changes only when a fact does.
type SentencePage ¶ added in v0.11.0
SentencePage is one plugin command page: its repo-relative path, the bytes committed, and the bytes it holds once its description is the verb's sentence and the page's use-when text, if it declares one. The generator writes Want where the two differ, and the drift test fails on any page where they do.
func SentencePages ¶ added in v0.11.0
func SentencePages(repoRoot string) ([]SentencePage, error)
SentencePages renders every plugin command page that backs a visible verb of the tree: commands/<verb>.md for each visible top-level verb, and the root's own page, commands/abcd.md. A verb with no page (abcd has verbs no page documents on its own) contributes nothing, and a page with no verb (a page whose work runs in the host) is not this manifest's to rewrite.
A page that exists but carries no frontmatter description is an error naming the page, rather than a description inserted at a guessed position.
Source Files
¶
- agents.go
- ahoy_connect.go
- ahoy_connect_guide.go
- ahoy_credential.go
- ahoy_only_waiting.go
- ahoy_retired_flags.go
- ahoy_worktree.go
- ahoy_worktree_kick.go
- announce.go
- archive.go
- banlist.go
- banner.go
- barerender.go
- board.go
- board_oracle.go
- board_reviews.go
- board_status.go
- board_view.go
- board_width.go
- board_worktrees.go
- brief_appendix.go
- build.go
- checklist.go
- cite.go
- cli.go
- commandfacts.go
- dashboard.go
- decide.go
- diagline.go
- dispatch.go
- docfidelity.go
- drain.go
- drain_drive.go
- drain_drive_signal.go
- drain_drive_update.go
- dryrun.go
- embargo.go
- embark_lessons.go
- explain.go
- guard.go
- guard_allow.go
- guard_approve.go
- guard_branches.go
- guard_hook_output.go
- guard_question.go
- guard_question_verb.go
- helpgroups.go
- history.go
- history_reconstruct.go
- history_recovery.go
- homestop.go
- hook_away.go
- hook_checklist.go
- hook_dogfood.go
- hook_occupancy.go
- hook_permission_request.go
- hook_result.go
- hook_scheduled.go
- hook_session_end.go
- hook_session_name.go
- hook_stop.go
- hook_subagent.go
- ideate.go
- identity.go
- identity_gen.go
- implement.go
- implement_heartbeat.go
- implement_load.go
- implement_load_unix.go
- implement_outage.go
- implement_restart.go
- implement_resume.go
- implement_stop.go
- implement_widen.go
- inputs.go
- intent_consistency.go
- intent_drain.go
- intent_interview.go
- intent_prepass.go
- issuereader.go
- lab.go
- lab_matrix.go
- lab_matrix_copy.go
- lab_matrix_report.go
- land.go
- landings.go
- launch_deep.go
- launch_manifests.go
- launch_preflight.go
- launch_receipts.go
- launch_reland.go
- lint.go
- lint_outbound.go
- match.go
- memory.go
- mode.go
- mode_away.go
- off_profile.go
- peers.go
- pendingref.go
- reading.go
- receipts.go
- recordread_hint.go
- reference.go
- reflect.go
- refusal_codes.go
- relink.go
- report.go
- requirements.go
- reserve.go
- reserve_sweep.go
- route.go
- rules_prompt.go
- scaffold.go
- scribe.go
- sentences.go
- session.go
- setup_interview.go
- ship.go
- site.go
- skew.go
- source.go
- staleness.go
- staleusage.go
- status.go
- statusline.go
- supersededroot.go
- surface.go
- sweep.go
- update.go
- update_news.go
- usage_errors.go
- version.go
- written_interview.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ask draws a question of the shared type (internal/core/question) in a plain Terminal (spc-2610030911534855, itd-2610030810370060): the layout from a question to lines at a width and a colour rung, and the sanitising every part passes before it is measured or drawn.
|
Package ask draws a question of the shared type (internal/core/question) in a plain Terminal (spc-2610030911534855, itd-2610030810370060): the layout from a question to lines at a width and a colour rung, and the sanitising every part passes before it is measured or drawn. |
|
Command identitygen bakes the canonical identity block's title and tagline into a generated Go file (itd-112/spc-41).
|
Command identitygen bakes the canonical identity block's title and tagline into a generated Go file (itd-112/spc-41). |