burgee
Every export of burgee, with its signature and doc comment: defineError, ExitCode, isExitCode, ExitCodeValue, defineCommand, defineProgram and 14 more, plus 60 types.
burgee — a command declares itself once; every surface is that declaration read by a different reader.
import { defineError, ExitCode, isExitCode, … } from 'burgee';Functions
camel
--dry-run on the command line reaches the handler as dryRun.
function camel(flag: string): string;| Parameter | Type |
|---|---|
flag | string |
Returns string
checkCommand
The whole door: {@link checkDefinition} — which carries V5's reserved names — and {@link checkEffects }.
function checkCommand(name: string, declared: Declared): void;| Parameter | Type |
|---|---|
name | string |
declared | Declared |
Returns void
checkDefinition
What must be true of a declaration before anything runs (yargs #1198, #887, #1679): a known type, one short alias per command, no two keys that meet on the command line, and none of V5's reserved surfaces.
function checkDefinition(name: string, options: Record<string, OptionSpec>): void;| Parameter | Type |
|---|---|
name | string |
options | Record<string, OptionSpec> |
Returns void
defineCommand
function defineCommand<const S extends OptionSpecs = OptionSpecs, const O extends CommandOutput = CommandOutput, const A extends readonly DeclaredArgument[] = readonly []>(command: Command<S, O, A>): Command<S, O, A>;| Parameter | Type |
|---|---|
command | Command<S, O, A> |
Returns Command<S, O, A>
defineError
function defineError(definition: ErrorDefinition): DefinedErrorClass;| Parameter | Type |
|---|---|
definition | ErrorDefinition |
Returns DefinedErrorClass
defineProgram
A native multi-command program. The manifest it builds is the same one the façades fill.
function defineProgram(program: Program): Manifest;| Parameter | Type |
|---|---|
program | Program |
Returns Manifest
detectAgent
function detectAgent(env: Record<string, string | undefined>, tty: boolean, probes?: readonly AgentProbe[]): Detection;| Parameter | Type |
|---|---|
env | Record<string, string | undefined> |
tty | boolean |
probes (optional) | readonly AgentProbe[] |
Returns Detection
execute
function execute(manifest: Manifest, opts?: RunOptions & {
root?: string[];
from?: 'node' | 'user';
}): Promise<void>;| Parameter | Type |
|---|---|
manifest | Manifest |
opts (optional) | RunOptions & { root?: string[]; from?: 'node' | 'user'; } |
Returns Promise<void>
kebab
dryRun → dry-run; a kebab key stays as it is.
function kebab(name: string): string;| Parameter | Type |
|---|---|
name | string |
Returns string
resolveCommand
M6: which command argv names, or null — the same longest-prefix match execute uses, over the
declared names. An alias is not read here: execute rewrites one to its command's name before it
resolves (aliases.ts, facade-projection-fidelity R5), and that chunk is loaded only on a run, so
this function stays synchronous and off the startup path. Pass the canonical words.
function resolveCommand(manifest: Manifest, argv: readonly string[]): CommandNode | null;| Parameter | Type |
|---|---|
manifest | Manifest |
argv | readonly string[] |
Returns CommandNode \| null
run
The one-file entry: a single command, or a program from defineProgram. Both go
through execute, so there is exactly one code path from argv to exit.
function run<S extends OptionSpecs, A extends readonly DeclaredArgument[] = readonly []>(target: Command<S, CommandOutput, A> | Manifest, opts?: RunOptions): Promise<void>;| Parameter | Type |
|---|---|
target | Command<S, CommandOutput, A> | Manifest |
opts (optional) | RunOptions |
Returns Promise<void>
runCommand
M6: run a command programmatically — the harness's own entry, public. The streams are
captured, the exit recorded; env, cwd and the entry can be injected like execute's.
function runCommand(manifest: Manifest, argv: readonly string[], opts?: Pick<RunOptions, 'env' | 'cwd' | 'entry' | 'stdin' | 'locale'>): Promise<RunResult>;| Parameter | Type |
|---|---|
manifest | Manifest |
argv | readonly string[] |
opts (optional) | Pick<RunOptions, 'env' | 'cwd' | 'entry' | 'stdin' | 'locale'> |
Returns Promise<RunResult>
sharedOptions
Options declared once and spread into each command that takes them (M4): never global,
so --schema stays a tree and each command's help lists them as its own, and the
handler's options type carries them like any other. Every copy is tagged
sharedFrom with the set's name, so the schema says where it came from.
function sharedOptions<const T extends OptionSpecs>(name: string, specs: T): T;| Parameter | Type |
|---|---|
name | string |
specs | T |
Returns T
Classes
AuthError
E6 — the far side said no. Throw this and the run leaves with ExitCode.AUTH.
class AuthError extends Error {
readonly hint?: string | undefined;
readonly fix?: string | undefined;
constructor(message: string, hint?: string | undefined, fix?: string | undefined);
}UsageError
A usage problem the caller can fix, carrying the flag that fixes it (E3).
class UsageError extends Error {
readonly hint?: string | undefined;
constructor(message: string, hint?: string | undefined);
}Constants
AGENT_PROBES
const AGENT_PROBES: readonly AgentProbe[];Interfaces
ActionRequiredSpec
What a caller must do before the command can continue (N11): synthesised into the envelope.
interface ActionRequiredSpec {
/** A short machine-readable reason: `login`, `confirm`, `missing-config` … */
reason: string;
message: string;
/** Runnable commands, each with when to run it; the engine prefixes the program and carries the caller's flags. */
next?: readonly {
command: string;
when: string;
}[];
hint?: string;
}AgentProbe
Agent detection, not just isTTY (N12). An agent may well have a terminal; what it
does not have is a person. FORCE_TTY=1 overrides. AI_AGENT is the generic escape
hatch any agent can set.
interface AgentProbe {
/** Environment variable whose presence names the agent. */
variable: string;
agent: string;
}ArgumentSpec
A positional, as help documents it (yargs #2012).
interface ArgumentSpec {
name: string;
description?: string;
required?: boolean;
variadic?: boolean;
default?: string;
/**
* The values the positional accepts, published as `enum` the way an option's `choices` are
* (facade-projection-fidelity R3), and enforced: the commander façade while parsing, the
* engine before the handler (typed-positionals R3). A string type's alone, as on an option.
*/
choices?: readonly string[];
/**
* What the word is (typed-positionals R1, D-20261012-typed-positionals-shape): `ctx.args`
* carries it as that type, and a word that is not one is a usage error. Absent is `string`.
* `'file'` is a path, where `-` means standard input — handed to the handler as `ctx.stdin` (S4).
*/
type?: 'string' | 'number' | 'integer' | 'boolean' | 'file';
/**
* completion-context R3 — values computed when TAB lands on this positional, called as an
* option's completer is. zsh still offers files for a `type: 'file'` argument.
*/
complete?: Completer;
/** P1 — as an option's: a missing required positional is asked for by the handler's prompt binding (caique's `promptFor`). */
prompt?: PromptDeclaration;
}Command
interface Command<S extends OptionSpecs = OptionSpecs, O extends CommandOutput = CommandOutput, A extends readonly DeclaredArgument[] = readonly []> {
name: string;
/** Other words that run this command, `['s']` for `serve`: listed on it in help, `--schema` and completions, never as commands of their own. */
aliases?: readonly string[];
/**
* Runs when argv names no command at this level (default-command R2): `tool`, or `tool --port 1`
* with only this command's options, and a word as its positional when it declares one and the
* word is near no command's name. One per level; two siblings that both say so are refused.
*/
default?: boolean;
description?: Localised;
/** Shown in command lists instead of the description. */
summary?: Localised;
/** Declared once (S1); the handler's `options` type is derived from it. */
options?: S;
/** Positionals in order, each with its `type` and `choices` (typed-positionals R1); the handler reads them as `args`. */
arguments?: A;
examples?: DeclaredExample[];
/** Heading this command is listed under in its parent's help. */
group?: string;
epilogue?: string;
hidden?: boolean;
/** What replaces this command, e.g. `'deploy'`: shown in help, `--schema` and the warning. `true` alone is refused (D1). */
deprecated?: boolean | string;
/**
* What running it does to the world (N6). Declaring one of the three is what exposes the
* command as an MCP tool (N2); `'withheld'` declares that it is not offered to agents.
*/
effects?: DeclaredEffects;
/** Relationships between options, validated before choices and the handler (S2, S6). */
relations?: readonly Relation[];
/**
* The top-level fields of this command's result (N14). With them, `--json=` lists them
* without running the handler and `--json=a,b` refuses an unknown field before it runs.
* Without them `--json=a,b` still selects, checked against the result's own keys.
*/
fields?: readonly string[];
/**
* clispec-conformance R5 — what the result is and how much of it: `--schema` publishes it as
* `output_kind`, `cardinality` and `stdout_schema`. With a `schema`, `run` must return what it
* describes; without one, anything.
*/
output?: O;
/** Pass positionals past the declared ones to the handler instead of refusing them. */
allowExcess?: boolean;
/** Absent on a group that only holds subcommands. `NoInfer`: the spec fixes S, the handler only reads it. */
run?: (ctx: CommandContext<InferOptions<NoInfer<S>>, InferArgs<NoInfer<A>>>) => Returns<NoInfer<O>>;
/** The handler's module, imported on dispatch only (M2); everything else about the command is declared here. */
load?: () => Promise<LazyModule>;
commands?: AnyCommand[];
}CommandContext
interface CommandContext<O, A = Record<string, unknown>> extends Omit<RunContext, 'options' | 'args'> {
options: O;
/** The declared positionals by name, typed from the declaration (typed-positionals R2). */
args: A;
}CommandNode
interface CommandNode {
path: string[];
/**
* Other words that name this command where its own last path segment would be typed:
* commander's `.alias()`, yargs' `['serve', 's']` (facade-projection-fidelity R5). A field on
* the command, never a second command, so `--schema` and an MCP tool list do not double.
* The engine reads them in `aliases.ts`; a façade dispatches its own.
*/
aliases?: readonly string[];
/** The command that runs when argv names none at its parent's level (default-command R2); one per level. */
default?: boolean;
description?: string;
/** Shown in command lists instead of the description (yargs #1265). */
summary?: string;
options: Record<string, OptionSpec>;
relations?: readonly Relation[];
arguments?: ArgumentSpec[];
examples?: Example[];
/** Heading this command is listed under in its parent's help (yargs #684). */
group?: string;
epilogue?: string;
hidden?: boolean;
deprecated?: boolean | string;
/**
* What running it does to the world, or `'withheld'` (N2, N6). Required on a node that
* runs — `checkCommand` refuses one that omits it — and optional on the type, because a
* group carries no `effects` and the host front-ends build nodes that never reach that
* door: commander and yargs have no notion of effects and their graded suites declare
* none, so a façade's command is withheld in fact and cannot be made to say so.
*/
effects?: DeclaredEffects;
/** The result's top-level fields, as declared (N14); what `--json=` lists. */
fields?: readonly string[];
/** What the result is and how much of it (clispec-conformance R5). */
output?: CommandOutput;
allowExcess?: boolean;
run?: (ctx: RunContext) => unknown;
/**
* The handler's module, imported on dispatch only (M2): the manifest — help, schema,
* completions, MCP tool list — is complete from this node without loading it. A node
* with `load` and no `run` gets a `run` that imports on first call.
*/
load?: () => Promise<LazyModule>;
/** Which plugin contributed this, if any. Declared, never diffed (M3). */
plugin?: string;
}CommandOutput
clispec-conformance R5 — what a command's result is, declared, so --schema can say what
comes back and how much of it before the first call (clispec v0.3's output_kind,
cardinality, stdout_schema and media_type).
interface CommandOutput {
kind?: 'data' | 'stream' | 'opaque';
cardinality?: 'single' | 'bounded' | 'unbounded';
schema?: OutputSchema;
/** `opaque` only: what the bytes are, such as `text/plain`. */
mediaType?: string;
}CompletionContext
completion-context R1 — what a completer is told about the line, beside the partial word. Only what was typed before the cursor: no env, config or default is read on TAB.
interface CompletionContext {
/** The command's path as declared, without the program's own name: `['deploy']`. */
readonly path: readonly string[];
/**
* The options typed before the cursor, coerced the way a run coerces them (numbers, choices,
* Standard Schema) and keyed camelCase. The line is unfinished, so nothing is required and no
* relation is checked, and the option whose value is being completed is not here.
*/
readonly options: Readonly<Record<string, unknown>>;
/** The positionals typed before the cursor, as typed. */
readonly positionals: readonly string[];
/**
* An option whose value failed coercion, as typed, and not in `options` (R2). A repeatable
* option is coerced whole, so one bad element puts every value it was given here, joined by its
* separator (`--level 1 --level x` is `level: '1,x'`).
*/
readonly raw: Readonly<Record<string, string>>;
}DefinedErrorClass
An author-defined error class; exitCode is the code it leaves with.
interface DefinedErrorClass {
new (message: string, options?: DefinedErrorOptions): Error & DefinedErrorOptions;
readonly exitCode: number;
}DefinedErrorOptions
What new takes: the message, and optionally the E3 hint and exact fix.
interface DefinedErrorOptions {
hint?: string;
fix?: string;
}Detection
interface Detection {
/** The agent named by the environment, if any; `AI_AGENT`'s own value when it names one. */
agent?: string;
/**
* stdout is a terminal and no agent is named, or `FORCE_TTY=1`: the output side, which help's
* colour reads. Whether to *ask* is `ctx.interactive`, roundel's rule over stdin and `CI`.
*/
interactive: boolean;
}ErrorDefinition
What an author declares.
interface ErrorDefinition {
/** The class name, shown as the error's `name`. */
name: string;
/** The exit code, 7–125, owned by this class alone. */
code: number;
/**
* clispec-conformance R2 — the word the failure is, snake_case and this class's alone: the
* envelope's `error.kind` and its row in `--schema`'s `errors`. Without one it is the name in
* snake case, less a trailing `Error` (`QuotaExceededError` → `quota_exceeded`).
*/
kind?: string;
/** Whether running the same command again may succeed; `false` unless said (R2). */
retryable?: boolean;
/** What the failure means, for its `errors` row (R2). */
description?: string;
}Example
One example: a single copy-pasteable command line, the description below it (H2).
interface Example {
command: string;
description?: string;
}Hook
interface Hook {
filter?: HookFilter;
/** `parse` may return the argv to use instead; every other stage's return is ignored. */
handler: (ctx: HookContext) => unknown;
}LazyModule
What a lazily loaded command module exports: the handler as run or as the default export (M2).
interface LazyModule {
default?: (ctx: RunContext) => unknown;
run?: (ctx: RunContext) => unknown;
}OptionSpec
interface OptionSpec {
/** `boolean` never consumes a value (S7); `number` rejects NaN and Infinity (S3). */
type: 'string' | 'boolean' | 'number';
/**
* D3 / D-119 — values computed when a person presses TAB: the generated script calls the
* program back (`<program> __complete <words before the cursor> <partial>`) for this option
* and no other. Declaring it is the opt-in; an option without one completes from `choices`, or
* not at all, and never runs the program.
*/
complete?: Completer;
description?: string;
required?: boolean;
short?: string;
default?: string | boolean | number | readonly string[] | readonly number[];
/** Environment variable consulted when the flag is absent (V2). Read from the injected env, never process.env directly. */
env?: string;
/** Allowed values, enforced and shown as `(one of: a, b)` (yargs #1408, #1186). */
choices?: readonly string[];
/** Repeatable, and split on `separator` (`,` unless declared): `--tag a --tag b,c` → `['a', 'b', 'c']` (S8). */
multiple?: boolean;
separator?: string;
/**
* The other options this one requires: `--out --dependsOn force` is a usage error without
* `--force` (S2). Sugar for a `{ implies: [this, other] }` relation per name, and nothing
* else — one engine, one order, one error vocabulary.
*/
dependsOn?: readonly string[];
/**
* The other options this one may not be given with (S2): `{ conflicts: [this, other] }` per
* name. Commander's `.conflicts()`, yargs' `.conflicts()`, Fig's `exclusiveOn`.
*/
exclusive?: readonly string[];
/** `number` only. */
minimum?: number;
maximum?: number;
integer?: boolean;
/** Any Standard Schema, run on the parsed value; its issues become a usage error (S1). */
schema?: StandardSchemaV1;
/** The value's name in help: `--id <dataset-id>` (yargs #833). */
placeholder?: string;
/** `true` renders `(deprecated)`; a string names the replacement: `(deprecated: use --force)` (yargs #2248). */
deprecated?: boolean | string;
hidden?: boolean;
/**
* `boolean` only: whether `--no-<name>` is accepted. Every boolean is negatable unless this
* says `false`. burgee's own parser negates every boolean (see `toParseConfig`); the
* commander façade sets `false` where commander would refuse the negation, so completions
* and `--mcp` never offer or send a flag the parser behind them rejects.
*/
negatable?: boolean;
/** The shared set this option was copied from (M4); `--schema` carries it, help lists the option like any other. */
sharedFrom?: string;
/**
* P1 — the question a person is asked when this option has no value from any source, resolved
* by the handler's prompt binding (caique's `promptFor`, R1). Declaring it moves a missing
* required value's refusal from the engine to that binding, which asks on a terminal and
* refuses, naming the flag, everywhere else; help and `--schema` still say it is required.
* Declare it through `promptFor`, which also keeps the question out of `--schema`: a program
* reading it is never asked. Typed structurally: burgee never imports caique.
*/
prompt?: PromptDeclaration;
}Program
interface Program {
name: string;
version?: string;
description?: Localised;
/** Options read `PREFIX_OPTION_NAME` from the environment unless they name their own variable (V2). */
envPrefix?: string;
/** Characters of `--schema` output above which it is summarised (N13); 48,000 by default. */
schemaBudget?: number;
/**
* Opt into config discovery (V6): `--config <path>` > `NAME_CONFIG` > `./name.config.{json,mjs,js,cjs}`
* > `package.json#name` > the user config directory; `true` uses the program's name.
*/
config?: boolean | {
name: string;
};
/** Shown under `Examples:` in root help; without them, each top-level command's first example is (agent-lint-conformance R6). */
examples?: DeclaredExample[];
/**
* The credential a non-interactive caller supplies, by the environment variable it sets (agent-lint-conformance
* R8). Declared, the program's exit-code contract lists `auth` and names the variable in its advice
* and in an `AuthError`'s default hint; undeclared, the program claims no auth failure at all.
*/
auth?: {
env: string;
};
commands: AnyCommand[];
}PromptDeclaration
caique's PromptSpec, as burgee holds it: a kind and a message, and whatever else the binding reads.
interface PromptDeclaration {
kind: string;
message: string;
[field: string]: unknown;
}RunContext
interface RunContext {
options: Record<string, unknown>;
/**
* The declared positionals by name, typed (typed-positionals R2): a variadic one as an array,
* an absent optional one as its `default`. `positionals` beside it is the words as typed.
*/
args: Record<string, unknown>;
positionals: string[];
passthrough: string[];
/**
* Standard input, present only when a `type: 'file'` argument was given `-` (S4). The
* positional still reads `-`, so a handler checks it the same way it checks a path.
*/
stdin?: NodeJS.ReadableStream;
env: Record<string, string | undefined>;
/** Exit with an E1 code. Unwinds cleanly: the code is honoured and nothing is printed. */
exit: (code: number) => never;
/**
* A person may be asked and be expected to answer (N12): roundel's `interactive()`, the
* family's one rule — a terminal on stdin, no `CI`, no detected agent — or `FORCE_TTY=1`.
*/
interactive: boolean;
/** The agent the environment names, if any (N12). */
agent?: string;
/** Stop and tell the caller what to do instead of blocking on a prompt (N11). */
actionRequired: (spec: ActionRequiredSpec) => never;
/**
* Cleanup that runs on **every** path out of the run (E5): a normal return, `ctx.exit`,
* Ctrl-C, SIGTERM, a terminal closing, an uncaught throw. Returns the function that
* unregisters it, for a command that cleaned up on its own.
*/
onExit: (handler: () => void | Promise<void>, label?: string) => () => void;
/**
* agent-lint-conformance R3 — aborts when the `--timeout` the caller set has passed, with the
* timeout error as its `reason`. Hand it to `fetch`, a child process or anything else that
* takes a signal, so the work stops when the run does. A run without `--timeout` still has one;
* it never aborts.
*/
signal: AbortSignal;
/**
* mcp-current R5 — report how far the command has got: `done` of `total` units, with an
* optional `message`. Inside an `--mcp` tool call whose client sent a `progressToken`, each
* call is a `notifications/progress`; everywhere else it does nothing, so call it
* unconditionally. `flagstaff/progress` reports through it on its own inside such a call.
*/
progress: (done: number, total?: number, message?: string) => void;
/** agent-lint-conformance R2 — the caller passed `--quiet`: draw no progress and print no hints. Data and errors still print. */
quiet: boolean;
/**
* The caller asked for `--json`, and an `--mcp` tool call always does: a machine reads stdout,
* so nobody is there to answer a question (caique R6) and nothing animates (`roundel/policy`'s
* `json` mode). The engine's knowledge, handed on so a handler never sniffs argv for it.
*/
json: boolean;
/**
* The output policy's runtime for this run (`roundel/policy`'s `Runtime`, typed structurally):
* the environment, whether stdout is a terminal, the colour flag the caller typed (`--no-color`,
* `--color=always`; R1) and `quiet` (R2). Spread it into what you hand flagstaff's `hoist` or
* roundel's `colorLevel`, and they decide colour and drawing the way the caller asked.
*/
runtime: {
env: Record<string, string | undefined>;
argv: readonly string[];
isTTY: {
stdout: boolean;
};
quiet: boolean;
};
}RunOptions
interface RunOptions {
argv?: string[];
/** Read by `--mcp`, which serves JSON-RPC over it; its `isTTY` is whether a person may be asked (N12). */
stdin?: NodeJS.ReadableStream;
/** The environment env-bound options read from. Injected by the harness; the process's own otherwise. */
env?: Record<string, string | undefined>;
/** `columns` is read when present, so help wraps to the terminal (H3); `isTTY` decides whether help is coloured (O2). */
stdout?: {
write: (s: string) => unknown;
columns?: number;
isTTY?: boolean;
};
/** `isTTY` decides whether a failure adds its structured line (clispec-conformance R6): absent is a pipe. */
stderr?: {
write: (s: string) => unknown;
isTTY?: boolean;
};
/** Receives the E1 code. The default calls process.exit; an injected one may simply record it. */
exit?: (code: number) => void;
/** Where config discovery starts; the process's own otherwise. */
cwd?: string;
/** The entry file, whose nearest package.json owns the program's version (V4); `process.argv[1]` otherwise. */
entry?: string;
/**
* The language help and refusals speak to a person, ahead of `BURGEE_LOCALE`, `LC_ALL`,
* `LC_MESSAGES` and `LANG` (`localised-human-surfaces` R2). A BCP 47 tag, or `C` for the
* program's own words; a registered plugin's `locales` supplies the translation. Machine
* surfaces never read it (R3).
*/
locale?: string;
}RunResult
interface RunResult {
code: number;
stdout: string;
stderr: string;
}StandardSchemaV1
The Standard Schema interface (standardschema.dev), declared here so any implementation
— zod, valibot, arktype — is accepted as an option's schema without a dependency (S1).
interface StandardSchemaV1<Output = unknown> {
readonly '~standard': {
readonly version: 1;
readonly vendor: string;
readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
};
}Usage
The envelope's error.usage, and what the prose renders.
interface Usage {
/** The command line from the program name: `demo greet [options] <name>`. */
command: string;
/** A runnable command's options, as typed. */
options?: UsageRow[];
/** A group's commands, for a word it does not know. */
commands?: UsageRow[];
/** The command that lists every row, present only when some were left out. */
more?: string;
}UsageRow
interface UsageRow {
/** `--code <value>`, `-n, --name <value>`, or a command word. */
name: string;
description: string;
}Types
AnyCommand
type AnyCommand = Command<any, any, any>;Completer
D3 / D-119 — values computed when a person presses TAB. A completer that takes one parameter is called as it always was; the second is the rest of the line (completion-context R1).
type Completer = (partial: string, context: CompletionContext) => Iterable<string> | Promise<Iterable<string>>;DeclaredArgument
A positional as declared (typed-positionals R1): choices on a string type only, as on an
option, so { type: 'number', choices: [...] } is a type error here and a definition-time
error for a caller TypeScript does not check.
type DeclaredArgument = Omit<ArgumentSpec, 'type' | 'choices'> & ({
type?: 'string';
choices?: readonly string[];
} | {
type: 'number' | 'integer' | 'boolean' | 'file';
choices?: never;
});DeclaredExample
An example as declared: its description may be {@link Localised} (R5).
type DeclaredExample = Omit<Example, 'description'> & {
description?: Localised;
};DeclaredOption
An option as declared: an {@link OptionSpec} whose description may be {@link Localised} (R5).
type DeclaredOption = Omit<OptionSpec, 'description'> & {
description?: Localised;
};Effects
What running a command does to the world (N6). Declared, never inferred: it decides
whether the command is exposed as an MCP tool at all (N2) and generates the tool's
readOnlyHint / idempotentHint / destructiveHint — MCP defaults destructiveHint
to true, so silence is the dangerous reading.
type Effects = 'read_only' | 'idempotent' | 'non_idempotent';InferArgs
The handler's args, derived from the declaration (typed-positionals R2): keyed by name, a
variadic one an array, number and integer a number, boolean a boolean, choices a union,
and | undefined only on an optional one with no default. any stays any, so a list of
commands of different shapes (AnyCommand) still holds each of them.
type InferArgs<A extends readonly DeclaredArgument[]> = 0 extends 1 & A ? any : {
[K in A[number] as K['name']]: K extends {
variadic: true;
} ? ArgValue<K>[] : ArgPresent<K> extends true ? ArgValue<K> : ArgValue<K> | undefined;
};InferOptions
The handler's options, derived from the declaration (S1): choices become a union, multiple an array, number a number.
type InferOptions<S extends Record<string, DeclaredOption>> = {
[K in keyof S]: Present<S[K]> extends true ? Many<S[K], Scalar<S[K]>> : Many<S[K], Scalar<S[K]>> | undefined;
};Localised
localised-human-surfaces R5 — text an author writes in more than one language: one string, or
locale → text with the author's base language first. Help renders the run's locale (the
tag, then its bare language, then the base); --schema, --mcp and every other machine
surface carry the base language and nothing else, because a command's description there is
data a program reads, not prose (R3).
type Localised = string | Readonly<Record<string, string>>;OptionSpecs
type OptionSpecs = Record<string, DeclaredOption>;OutputOf
The TypeScript type a JSON Schema describes, for run's return under output.schema: const,
enum, the scalar types, arrays by items, and objects by properties, with the keys in
required required and the rest optional. Anything it does not read is unknown, so a schema
it cannot follow never refuses a handler.
type OutputOf<J> = J extends {
const: infer C;
} ? C : J extends {
enum: readonly (infer E)[];
} ? E : J extends {
type: 'string';
} ? string : J extends {
type: 'number' | 'integer';
} ? number : J extends {
type: 'boolean';
} ? boolean : J extends {
type: 'null';
} ? null : J extends {
type: 'array';
items: infer I;
} ? OutputOf<I>[] : J extends {
type: 'object';
properties: infer P;
} ? ObjectOf<P, J extends {
required: readonly (infer R)[];
} ? R : never> : unknown;OutputSchema
A JSON Schema, as far as OutputOf reads one: the shape is checked by the type below, and anything else is passed through.
type OutputSchema = Readonly<Record<string, unknown>>;Relation
A relationship between options, validated after parsing and before choices and the
handler (S2, S6). implies takes a second option name, or a predicate over the values.
type Relation = {
exactlyOneOf: readonly string[];
} | {
atLeastOneOf: readonly string[];
} | {
atMostOneOf: readonly string[];
} | {
conflicts: readonly string[];
} | {
implies: readonly [string, string | ((values: Record<string, unknown>) => boolean)];
};StandardResult
type StandardResult<Output> = {
readonly value: Output;
readonly issues?: undefined;
} | {
readonly issues: readonly {
readonly message: string;
}[];
};Re-exported
Documented on the page of the entry point that declares them.
| Export | Kind | Documented in |
|---|---|---|
isExitCode | function | burgee/testing |
Manifest | class | burgee/schema |
ExitCode | const | burgee/testing |
ExitCodeValue | const | burgee/testing |
Candidate | interface | burgee/config |
CommandSchema | interface | burgee/schema |
HelpOptions | interface | burgee/help |
JsonSchema | interface | burgee/schema |
Layers | interface | burgee/config |
Plugin | interface | burgee/plugin |
ProgramSchema | interface | burgee/schema |
Provenance | interface | burgee/config |
Resolution | interface | burgee/config |
SchemaSummary | interface | burgee/schema |
ServeOptions | interface | burgee/mcp |
Tool | interface | burgee/mcp |
ToolAnnotations | interface | burgee/mcp |
HelpTheme | type | burgee/help |
HelpToken | type | burgee/help |
Invoke | type | burgee/mcp |
LocaleMessages | type | burgee/plugin |
Locales | type | burgee/plugin |
Message | type | burgee/plugin |
MessageId | type | burgee/plugin |
PluginErrorCode | type | burgee/plugin |
Source | type | burgee/config |
burgee
A CLI framework built on one declaration: help, --json, --schema, MCP, completions and types are projected from it, with exit codes and fix: lines an agent can act on. No dependency outside the burgee family. Drop-in paths for commander, yargs and meow.
burgee/plugin
Every export of burgee/plugin, with its signature and doc comment: validate, definePlugin, CONTRACT, PluginError, plus 7 types.