/** * Walks the Commander program tree and produces a normalized CommandSpec tree * that the bash/zsh/fish completion generators consume. Decoupled from * Commander internals so the generators don't have to know about Option/Argument * classes, just the spec types defined here. */ import type { Command } from "commander"; /** * Caller-injected lookup that maps a (commandPath, option-or-positional) * pair to a dynamic-provider key. The shell completion script later * invokes ` __complete ` at tab-time and the consumer's * provider registry produces the actual values. harn standalone uses * the default no-op lookup (no dynamic completion). */ export type CompletionContextLookup = (key: { commandPath: string; option?: string; positional?: number; }) => string | undefined; export interface CommandSpec { /** Bare command name (e.g., "anthropic", "cost"). */ name: string; /** Full path from root, space-separated (e.g., "anthropic cost"). Empty for the root program. */ path: string; description: string; subcommands: CommandSpec[]; options: OptionSpec[]; positionals: PositionalSpec[]; /** True if this command has the `--help` flag (default for all Commander commands). */ hasHelp: boolean; /** True if this is a hidden command; completion can skip it. */ hidden: boolean; } export interface OptionSpec { /** Long form including `--`, e.g., "--workspace". May be empty if only short form exists. */ long: string; /** Short form including `-`, e.g., "-w". May be empty. */ short: string; description: string; /** True if the option requires a value (e.g., `--workspace `). */ takesValue: boolean; /** Optional static choice list for the value (e.g. `--format json|csv|table`). */ valueChoices?: string[]; /** Optional dynamic-value provider key; completion script calls back via `harn __complete `. */ dynamicProvider?: string; /** True if the option can be repeated. */ variadic: boolean; } export interface PositionalSpec { name: string; description: string; required: boolean; variadic: boolean; valueChoices?: string[]; dynamicProvider?: string; } /** * Walks the Commander program tree and returns the root CommandSpec. * The root represents `harn` itself; its `subcommands` are the top-level * subcommands. */ export declare function walkProgram(program: Command, lookup?: CompletionContextLookup): CommandSpec; /** Flatten the spec tree into a list of (path, spec) entries for code generation. */ export declare function flatten(root: CommandSpec): Array<{ path: string; spec: CommandSpec; }>; //# sourceMappingURL=walk.d.ts.map