Documentation
¶
Overview ¶
Package schema turns the command registry into a machine-readable document.
`outplane schema` is the entry point for an AI agent. Everything it needs to use the CLI correctly, every command, argument, flag, output field, error code, exit code, risk level and runnable example, comes out of one call.
Three properties are non-negotiable, and each exists for a concrete reason:
- It works with no authentication, no config file and no network. An agent that has to log in before it can discover how to log in is stuck.
- It is deterministic. Same binary, same bytes, every time and on every machine. That is why the registry is a slice and never a map: map iteration order in Go is randomised, and a schema that reorders itself breaks caching and makes diffs useless.
- It is a superset of the published CLI Spec, so a generic tool that knows nothing about Out Plane can still consume it. Our additions ride along as extra properties, which that spec explicitly permits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct {
Name string `json:"name"`
Short string `json:"short,omitempty"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Positional bool `json:"positional,omitempty"`
Variadic bool `json:"variadic,omitempty"`
Repeatable bool `json:"repeatable,omitempty"`
Default string `json:"default,omitempty"`
Enum []string `json:"enum,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Resolves names the resource kind a value identifies, so an agent knows
// that this argument accepts a human-readable name and which list command
// produces valid values.
Resolves string `json:"resolves,omitempty"`
// Discouraged explains why a working option should rarely be used.
Discouraged string `json:"discouraged,omitempty"`
}
Arg covers both positional arguments and flags. They differ in how they are written on a command line, not in what a caller needs to know about them, and collapsing them into one type means an agent has one thing to parse.
type CommandDoc ¶
type CommandDoc struct {
Name string `json:"name"`
Path []string `json:"path"`
Description string `json:"description"`
Aliases []string `json:"aliases,omitempty"`
Mutating bool `json:"mutating"`
Risk string `json:"risk"`
RequiresAuth bool `json:"requires_auth"`
RequiresSession string `json:"requires_session"`
Idempotent bool `json:"idempotent"`
LongRunning bool `json:"long_running,omitempty"`
Streams string `json:"streams,omitempty"`
SupportsDryRun bool `json:"supports_dry_run,omitempty"`
// Output is present only when the command overrides the tool-wide default.
// An undeclared override would be a silent contract violation: the agent
// reads "piped: json" from the top level and gets something else.
Output *OutputContract `json:"output,omitempty"`
APICalls []string `json:"api_calls,omitempty"`
Args []Arg `json:"args,omitempty"`
OutputFields []FieldDoc `json:"output_fields,omitempty"`
// UnsupportedGlobalArgs names global flags this command rejects, with the
// leading dashes so the entries match global_args.
//
// Without it the schema says --team applies everywhere, and an agent
// planning `outplane team use beta --team acme` would be following the
// contract into a usage error. The exclusion is small and the schema is the
// only place an agent can learn it.
UnsupportedGlobalArgs []string `json:"unsupported_global_args,omitempty"`
ErrorCodes []string `json:"error_codes,omitempty"`
ExitCodes []int `json:"exit_codes,omitempty"`
Examples []ExampleDoc `json:"examples,omitempty"`
AutomationNotes []string `json:"automation_notes,omitempty"`
Related []string `json:"related,omitempty"`
DocsURL string `json:"docs_url,omitempty"`
}
CommandDoc is one command as an agent sees it.
type Document ¶
type Document struct {
Clispec string `json:"clispec"`
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
// SchemaVersion is the shape of this document, which changes far less often
// than the CLI itself. An agent pins expectations against this rather than
// against the release version.
SchemaVersion string `json:"schema_version"`
DocsURL string `json:"docs_url"`
// Output declares the default encoding, so a consumer reads the contract
// instead of probing for it.
Output OutputContract `json:"output"`
GlobalArgs []Arg `json:"global_args"`
Errors []ErrorKind `json:"errors"`
RiskLevels []RiskLevel `json:"risk_levels"`
Commands []CommandDoc `json:"commands"`
}
Document is the whole schema. Field order here is the field order in the JSON output, so it is arranged for a human reading it top to bottom.
func Build ¶
Build produces the schema document for the given commands.
It takes the command slice as a parameter rather than reading the package level registry, so it can be tested with a fixture and so the dependency direction stays one way: schema depends on registry, never the reverse.
type ErrorKind ¶
type ErrorKind struct {
Kind string `json:"kind"`
ExitCode int `json:"exit_code"`
Retryable bool `json:"retryable"`
Description string `json:"description"`
}
ErrorKind is one coarse error class. The set is finite and closed: an agent that knows nothing about Out Plane can branch on it exhaustively.
Fine-grained codes such as "app.name_taken" live on individual commands. They carry more meaning but require knowing the product; kinds do not.
type ExampleDoc ¶
type ExampleDoc struct {
Title string `json:"title"`
Command string `json:"command"`
Argv []string `json:"argv"`
Risk string `json:"risk"`
Placeholders map[string]string `json:"placeholders,omitempty"`
OutputSample map[string]any `json:"output_sample,omitempty"`
}
ExampleDoc is a runnable example.
Command is for a human to copy. Argv is for a machine to execute with no shell tokenisation. Placeholders says which literals are stand-ins, so an agent never runs an example that looks real but targets a resource it does not own.
type FieldDoc ¶
type FieldDoc struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
}
FieldDoc is one field of a command's structured output.
type OutputContract ¶
OutputContract is what the tool produces on a terminal versus in a pipe.