Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CommandEcosystem = map[string]string{
"cargo": "rust",
"rustc": "rust",
"rustup": "rust",
"npm": "node",
"npx": "node",
"pnpm": "node",
"yarn": "node",
"node": "node",
"pip": "python",
"pip3": "python",
"poetry": "python",
"uv": "python",
"python": "python",
"go": "go",
"gofmt": "go",
}
CommandEcosystem maps a build command to the ecosystem that provides it. Commands present in every image, such as make and cc, are deliberately absent: they say nothing about which toolchain a recipe needs. CommandEcosystem maps a command to the ecosystem that provides it. Both the planner and the toolchain chooser need this answer, so it has one home.
Functions ¶
func CreatesToken ¶
CreatesToken reports whether a line produces the named path: a redirect target, an -o argument, or an argument to mkdir, touch, cp or mv. The session writer asks this to know which files a step will bring into being.
func DocumentedSettingNames ¶
DocumentedSettingNames collects every environment setting the document mentions, in any context.
func InvokedBinary ¶
InvokedBinary returns the documented binary a line invokes and its first subcommand, or empty strings when the line invokes none. Leading VAR=value prefixes are stepped over, so `KEY=x tool sub` still names the tool, and so are wrappers such as env and xargs, so `env KEY=x tool sub` does too.
func IsSimpleWord ¶
IsSimpleWord reports whether a token is a bare command word.
Types ¶
type Plan ¶
type Plan struct {
// Repo is the repository directory name.
Repo string `json:"repo"`
// Installs are the documented installs run to put the binaries on PATH.
Installs []PlanInstall `json:"installs,omitempty"`
// Binaries are the documented binaries the session installs.
Binaries []string `json:"binaries,omitempty"`
// Packages are Debian packages installed before any step runs.
Packages []string `json:"packages,omitempty"`
// Env is extra environment exported for the whole session.
Env map[string]string `json:"env,omitempty"`
// Fixtures are files written into the workdir before any step runs.
Fixtures []config.Fixture `json:"fixtures,omitempty"`
// Steps are the example blocks in documented order.
Steps []PlanStep `json:"steps,omitempty"`
// Settings are environment names the document mentions anywhere, prose
// and tables included. A tool that fails asking for one of these is
// asking the reader for something the document already told them about.
Settings []string `json:"settings,omitempty"`
// Excluded counts code blocks that are not shell recipes.
Excluded int `json:"excluded,omitempty"`
}
Plan describes how kibble replays one repo's documented examples: which code blocks run, the lines inside them, and the fixtures, packages, and environment the session needs. Every judgment call lives in the plan, so the executor stays deterministic and the plan can be inspected with -plan.
func BuildPlan ¶
func BuildPlan(repo, dir, markdown string, binaries []string, installs []PlanInstall, cfg *config.ExamplesConfig, rec *Recognizer) *Plan
func (*Plan) Merge ¶
Merge folds another document's plan into this one, so a repository's whole documentation tree is replayed in a single session.
Installing the documented tool once per document is what made a large tree unverifiable: the install dominates a session, and multiplying it by the number of pages meant mise could not finish three of its 421. Everything a session needs that is the same for every page, the installs, the binaries, the packages and the environment, is therefore kept once, and only the steps accumulate. Step identifiers are renumbered as they arrive, since each document numbered its own blocks from one and merging them would otherwise produce several b1s in the same session.
type PlanInstall ¶
type PlanInstall struct {
// Cmd is the shell command that performs the install.
Cmd string `json:"cmd"`
// Ecosystem is the toolchain the command needs, empty when it is Go and
// the configured default image already provides it.
Ecosystem string `json:"ecosystem,omitempty"`
// Dir is the directory the install runs from, empty for the session's
// copy of the repository.
Dir string `json:"dir,omitempty"`
// binary is the tool this install is expected to provide. It exists to
// drop alternative installs of the same tool and is not part of output.
Binary string
// Bootstrap installs the package manager itself when the image lacks it.
Bootstrap string
}
PlanInstall is one documented install the session runs before replaying examples, so the binary the examples call is on PATH.
type PlanLine ¶
type PlanLine struct {
// Cmd is the command exactly as the session will run it.
Cmd string `json:"cmd"`
// Skip is why the line does not run; empty means it runs.
Skip string `json:"skip,omitempty"`
// SkipReason is the machine-readable code for Skip, so a consumer can
// filter and audit skip reasons without parsing the human-facing string.
SkipReason verdict.Reason `json:"skipReason,omitempty"`
// Gap marks a Skip whose cause is the document rather than the
// container: the line names something no documented step creates.
Gap bool `json:"gap,omitempty"`
// Need is a file the line reads that the planner saw no earlier line
// create. The session reports whether it exists just before the line
// runs, so a missing file is judged at run time rather than guessed.
Need string `json:"need,omitempty"`
// Unplanned is the location of a code block earlier in the document that
// the plan leaves out, set only alongside Need. That block never runs,
// so it may be what creates the needed file, and a missing file after it
// is not proof of the document's gap.
Unplanned string `json:"unplanned,omitempty"`
// NonzeroOK accepts a nonzero exit as documented behavior.
NonzeroOK bool `json:"nonzeroOk,omitempty"`
// Synthetic names the files kibble fabricated so this line had something
// to read. The document referenced them and never created them, so a pass
// here proves the command accepts kibble's invented input, which is a
// weaker claim than the documented example working.
Synthetic []string `json:"synthetic,omitempty"`
// Line is the 1-based README line the command sits on, 0 when unknown.
Line int `json:"line,omitempty"`
// File is the path a titled code block names when this line writes the
// block's content to it. Documentation sites show a file the reader is to
// create as a block titled with its name, and a later line that reads it
// was never missing it.
File string `json:"file,omitempty"`
// Creates names the paths this line writes, as the planner reads them. A
// later line that finds one missing after this line failed may be missing
// it for that reason alone, which is not the document's gap.
Creates []string `json:"creates,omitempty"`
}
PlanLine is one logical command from a block: a single documented line, or several physical lines joined by a continuation or a heredoc.
type PlanStep ¶
type PlanStep struct {
// ID names the step by its order in the plan, such as b3.
ID string `json:"id"`
// Doc is the document the block came from, relative to the repository
// root. One session now replays every document a repository has, because
// installing the tool once per document made a documentation tree of any
// size unverifiable: mise carries 421 of them and three could not finish.
// The step has to carry its own provenance, since the session no longer
// belongs to a single page.
Doc string `json:"doc,omitempty"`
// Heading is the section heading the block appears under.
Heading string `json:"heading,omitempty"`
// Lines are the logical shell lines of the block.
Lines []PlanLine `json:"lines"`
// Background runs the step behind the session and kills it at the end.
Background bool `json:"background,omitempty"`
// ReadyLog is output that marks a background step ready.
ReadyLog string `json:"readyLog,omitempty"`
}
PlanStep is one documented code block prepared for execution.
type Recognizer ¶
type Recognizer struct {
// Clones reports whether a line clones a repository. A block containing
// one is a build recipe, not an example, so the whole block is dropped.
Clones func(flat string) bool
// Installs reports whether a line installs the documented tool. Such a
// line is skipped on its own; the rest of the block may still be examples.
Installs func(flat string) bool
// Provides returns the binary a line installs when that binary is some
// other tool an example uses, such as ruff after `uv tool install ruff`
// in uv's README. Later lines calling it are examples, not unknown
// commands. It returns empty for every other line.
Provides func(flat string) string
}
BuildPlan turns a README's code blocks into an execution plan for one repo. binaries and modules come from the repo's go-install steps, dir is the local checkout used to resolve file references, and cfg carries the repo's .kibble.yml overrides, if any. Recognizer answers what a documented line is, so the planner can leave install recipes to whatever installs them instead of replaying them as examples. The planner used to hold the patterns itself, which meant the layer deciding what to run also had to know what every ecosystem's install looks like. Asking instead of knowing keeps that knowledge in one place.