schema

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Build(cmds []registry.Command, version string) Document

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.

func (Document) Filter

func (d Document) Filter(path []string) Document

Filter narrows a document to one command subtree, keeping all top-level metadata. `outplane schema deploy create` should not force an agent to read the entire surface to learn about one command; bounded output applies to the schema too.

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

type OutputContract struct {
	TTY   string `json:"tty"`
	Piped string `json:"piped"`
}

OutputContract is what the tool produces on a terminal versus in a pipe.

type RiskLevel

type RiskLevel struct {
	Name        string `json:"name"`
	Mutating    bool   `json:"mutating"`
	Description string `json:"description"`
}

RiskLevel documents the risk vocabulary, so a harness can build an allowlist from the schema instead of hardcoding our command names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL