export type ParamType = "string" | "number" | "boolean"; export interface ParamDef { type: ParamType; required?: boolean | ((params: Record) => boolean); positional?: number; default?: unknown; description: string; enum?: TEnum; } export type CLIResult = { ok: true; data: unknown; } | { ok: false; code: string; message: string; hint?: string; usage?: string; param?: string; }; export interface CommandFlags { json: boolean; lean: boolean; dryRun: boolean; /** Write-gate token — consumed by mutating commands when ARCS_GUARDED=1. */ token?: string; } /** * Base runtime value implied by `ParamDef.type`. Narrowed to enum literals * when `enum` is present (enum-typed params remain strings at runtime). */ type ParamBaseValue

= P extends { enum: infer E extends readonly string[]; } ? E[number] : P extends { type: "string"; } ? string : P extends { type: "number"; } ? number : P extends { type: "boolean"; } ? boolean : never; /** * A param is "always present" at the handler — i.e. not `T | undefined` — iff * the parser guarantees it via `required: true`, `default`, or a defaulting * coercion (booleans default to `false` when no flag is provided). * * Note: function-form `required` is conservatively treated as optional in the * type, since the runtime check is dynamic. Handlers using conditional-required * params should assert as needed. */ type ParamIsPresent

= P extends { required: true; } ? true : P extends { default: unknown; } ? true : P extends { type: "boolean"; } ? true : false; export type ParsedParamValue

= ParamIsPresent

extends true ? ParamBaseValue

: ParamBaseValue

| undefined; /** * Mapped type that converts a `Record` spec into the runtime * shape produced by the arg parser. Handlers can annotate their `params` * argument with `ParsedParams` (with `as const` or `satisfies`) * to drop redundant `as string | undefined` casts. */ export type ParsedParams> = { [K in keyof T]: ParsedParamValue; }; export interface CommandDef = Record> { path: string; description: string; params: T; mutation?: boolean; errorCodes?: string[]; handler: (params: ParsedParams, flags: CommandFlags) => Promise; } /** * Type-erased view of a CommandDef used by the registry's lookup/listing APIs * and by the generic dispatcher in `index.ts` / `dag-commands.ts`. The dispatcher * receives `Record` from the parser and calls `handler` * uniformly — its handler signature drops type narrowing intentionally so the * parser output is structurally compatible. */ export interface AnyCommandDef { path: string; description: string; params: Record; mutation?: boolean; errorCodes?: string[]; handler: (params: Record, flags: CommandFlags) => Promise; } export declare const ERROR_CODES: { readonly MISSING_PARAM: "missing_param"; readonly INVALID_TYPE: "invalid_type"; readonly INVALID_ENUM: "invalid_enum"; readonly UNKNOWN_FLAG: "unknown_flag"; readonly UNKNOWN_COMMAND: "unknown_command"; readonly PROJECT_NOT_FOUND: "project_not_found"; readonly ENTITY_NOT_FOUND: "entity_not_found"; readonly AMBIGUOUS_ARG: "ambiguous_arg"; readonly CREATE_ERROR: "create_error"; readonly UPDATE_ERROR: "update_error"; readonly DELETE_ERROR: "delete_error"; readonly TRANSITION_ERROR: "transition_error"; }; export declare function defineCommand>(def: CommandDef): void; export declare function getCommand(path: string): AnyCommandDef | undefined; export declare function listCommands(): AnyCommandDef[]; export declare function suggestCommand(input: string): string | undefined; export {}; //# sourceMappingURL=command-registry.d.ts.map