padrone 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +15 -11
  3. package/dist/{args-D5PNDyNu.mjs → args-Cnq0nwSM.mjs} +91 -41
  4. package/dist/args-Cnq0nwSM.mjs.map +1 -0
  5. package/dist/codegen/index.mjs +4 -4
  6. package/dist/codegen/index.mjs.map +1 -1
  7. package/dist/commands-B_gufyR9.mjs +514 -0
  8. package/dist/commands-B_gufyR9.mjs.map +1 -0
  9. package/dist/{completion.mjs → completion-BEuflbDO.mjs} +12 -82
  10. package/dist/completion-BEuflbDO.mjs.map +1 -0
  11. package/dist/docs/index.d.mts +4 -4
  12. package/dist/docs/index.d.mts.map +1 -1
  13. package/dist/docs/index.mjs +10 -12
  14. package/dist/docs/index.mjs.map +1 -1
  15. package/dist/{errors-BiVrBgi6.mjs → errors-DA4KzK1M.mjs} +26 -3
  16. package/dist/errors-DA4KzK1M.mjs.map +1 -0
  17. package/dist/{formatter-DtHzbP22.d.mts → formatter-DrvhDMrq.d.mts} +3 -3
  18. package/dist/formatter-DrvhDMrq.d.mts.map +1 -0
  19. package/dist/{help-bbmu9-qd.mjs → help-BtxLgrF_.mjs} +190 -43
  20. package/dist/help-BtxLgrF_.mjs.map +1 -0
  21. package/dist/{types-Ch8Mk6Qb.d.mts → index-D6-7dz0l.d.mts} +634 -745
  22. package/dist/index-D6-7dz0l.d.mts.map +1 -0
  23. package/dist/index.d.mts +869 -36
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +3884 -1699
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{mcp-mLWIdUIu.mjs → mcp-6-Jw4Bpq.mjs} +13 -15
  28. package/dist/mcp-6-Jw4Bpq.mjs.map +1 -0
  29. package/dist/{serve-B0u43DK7.mjs → serve-YVTPzBCl.mjs} +12 -14
  30. package/dist/serve-YVTPzBCl.mjs.map +1 -0
  31. package/dist/{stream-BcC146Ud.mjs → stream-DC4H8YTx.mjs} +24 -3
  32. package/dist/stream-DC4H8YTx.mjs.map +1 -0
  33. package/dist/test.d.mts +5 -8
  34. package/dist/test.d.mts.map +1 -1
  35. package/dist/test.mjs +2 -13
  36. package/dist/test.mjs.map +1 -1
  37. package/dist/{update-check-CFX1FV3v.mjs → update-check-CZ2VqjnV.mjs} +16 -17
  38. package/dist/update-check-CZ2VqjnV.mjs.map +1 -0
  39. package/dist/zod.d.mts +2 -2
  40. package/dist/zod.d.mts.map +1 -1
  41. package/dist/zod.mjs +2 -2
  42. package/dist/zod.mjs.map +1 -1
  43. package/package.json +15 -12
  44. package/src/cli/completions.ts +14 -11
  45. package/src/cli/docs.ts +13 -10
  46. package/src/cli/doctor.ts +22 -18
  47. package/src/cli/index.ts +28 -82
  48. package/src/cli/init.ts +10 -7
  49. package/src/cli/link.ts +20 -16
  50. package/src/cli/wrap.ts +14 -11
  51. package/src/codegen/schema-to-code.ts +2 -2
  52. package/src/{args.ts → core/args.ts} +32 -225
  53. package/src/core/commands.ts +373 -0
  54. package/src/core/create.ts +301 -0
  55. package/src/core/default-runtime.ts +239 -0
  56. package/src/{errors.ts → core/errors.ts} +22 -0
  57. package/src/core/exec.ts +259 -0
  58. package/src/core/interceptors.ts +302 -0
  59. package/src/{parse.ts → core/parse.ts} +36 -89
  60. package/src/core/program-methods.ts +301 -0
  61. package/src/core/results.ts +229 -0
  62. package/src/core/runtime.ts +246 -0
  63. package/src/core/validate.ts +247 -0
  64. package/src/docs/index.ts +12 -13
  65. package/src/extension/auto-output.ts +146 -0
  66. package/src/extension/color.ts +38 -0
  67. package/src/extension/completion.ts +49 -0
  68. package/src/extension/config.ts +262 -0
  69. package/src/extension/env.ts +101 -0
  70. package/src/extension/help.ts +192 -0
  71. package/src/extension/index.ts +44 -0
  72. package/src/extension/ink.ts +93 -0
  73. package/src/extension/interactive.ts +106 -0
  74. package/src/extension/logger.ts +262 -0
  75. package/src/extension/man.ts +51 -0
  76. package/src/extension/mcp.ts +52 -0
  77. package/src/extension/progress-renderer.ts +338 -0
  78. package/src/extension/progress.ts +299 -0
  79. package/src/extension/repl.ts +94 -0
  80. package/src/extension/serve.ts +48 -0
  81. package/src/extension/signal.ts +87 -0
  82. package/src/extension/stdin.ts +62 -0
  83. package/src/extension/suggestions.ts +114 -0
  84. package/src/extension/timing.ts +81 -0
  85. package/src/extension/tracing.ts +175 -0
  86. package/src/extension/update-check.ts +77 -0
  87. package/src/extension/utils.ts +51 -0
  88. package/src/extension/version.ts +63 -0
  89. package/src/{completion.ts → feature/completion.ts} +12 -12
  90. package/src/{interactive.ts → feature/interactive.ts} +4 -4
  91. package/src/{mcp.ts → feature/mcp.ts} +12 -15
  92. package/src/{repl-loop.ts → feature/repl-loop.ts} +10 -13
  93. package/src/{serve.ts → feature/serve.ts} +11 -15
  94. package/src/feature/test.ts +262 -0
  95. package/src/{update-check.ts → feature/update-check.ts} +16 -16
  96. package/src/{wrap.ts → feature/wrap.ts} +10 -8
  97. package/src/index.ts +115 -30
  98. package/src/{formatter.ts → output/formatter.ts} +124 -176
  99. package/src/{help.ts → output/help.ts} +22 -8
  100. package/src/output/output-indicator.ts +87 -0
  101. package/src/output/primitives.ts +335 -0
  102. package/src/output/styling.ts +221 -0
  103. package/src/{zod.d.ts → schema/zod.d.ts} +1 -1
  104. package/src/schema/zod.ts +50 -0
  105. package/src/test.ts +2 -276
  106. package/src/types/args-meta.ts +151 -0
  107. package/src/types/builder.ts +718 -0
  108. package/src/types/command.ts +157 -0
  109. package/src/types/index.ts +60 -0
  110. package/src/types/interceptor.ts +296 -0
  111. package/src/types/preferences.ts +83 -0
  112. package/src/types/result.ts +71 -0
  113. package/src/types/schema.ts +19 -0
  114. package/src/util/dotenv.ts +244 -0
  115. package/src/{shell-utils.ts → util/shell-utils.ts} +26 -9
  116. package/src/{stream.ts → util/stream.ts} +27 -1
  117. package/src/{type-helpers.ts → util/type-helpers.ts} +23 -16
  118. package/src/{type-utils.ts → util/type-utils.ts} +71 -33
  119. package/src/util/utils.ts +51 -0
  120. package/src/zod.ts +1 -50
  121. package/dist/args-D5PNDyNu.mjs.map +0 -1
  122. package/dist/chunk-CjcI7cDX.mjs +0 -15
  123. package/dist/command-utils-B1D-HqCd.mjs +0 -1117
  124. package/dist/command-utils-B1D-HqCd.mjs.map +0 -1
  125. package/dist/completion.d.mts +0 -64
  126. package/dist/completion.d.mts.map +0 -1
  127. package/dist/completion.mjs.map +0 -1
  128. package/dist/errors-BiVrBgi6.mjs.map +0 -1
  129. package/dist/formatter-DtHzbP22.d.mts.map +0 -1
  130. package/dist/help-bbmu9-qd.mjs.map +0 -1
  131. package/dist/mcp-mLWIdUIu.mjs.map +0 -1
  132. package/dist/serve-B0u43DK7.mjs.map +0 -1
  133. package/dist/stream-BcC146Ud.mjs.map +0 -1
  134. package/dist/types-Ch8Mk6Qb.d.mts.map +0 -1
  135. package/dist/update-check-CFX1FV3v.mjs.map +0 -1
  136. package/src/command-utils.ts +0 -882
  137. package/src/create.ts +0 -1829
  138. package/src/runtime.ts +0 -497
  139. package/src/types.ts +0 -1291
  140. package/src/utils.ts +0 -140
  141. /package/src/{colorizer.ts → output/colorizer.ts} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,52 +1,121 @@
1
- import { A as Drained, B as REPL_SIGINT, C as PluginShutdownContext, D as WrapConfig, E as PluginValidateResult, F as PadroneProgressIndicator, I as PadroneProgressOptions, L as PadroneRuntime, M as PossibleCommands, N as InteractiveMode, O as WrapResult, P as InteractivePromptConfig, R as PadroneSpinnerConfig, S as PluginParseResult, T as PluginValidateContext, V as PadroneMcpPreferences, _ as PluginErrorContext, a as PadroneActionContext, b as PluginExecuteResult, c as PadroneCommandResult, d as PadronePlugin, f as PadroneProgram, g as PluginBaseContext, h as PadroneSchema, i as AsyncPadroneSchema, j as PickCommandByName, k as UpdateCheckConfig, l as PadroneDrainResult, m as PadroneProgressPrefs, n as AnyPadroneCommand, o as PadroneBuilder, p as PadroneProgressMessage, r as AnyPadroneProgram, s as PadroneCommand, t as AnyPadroneBuilder, u as PadroneParseResult, v as PluginErrorResult, w as PluginStartContext, x as PluginParseContext, y as PluginExecuteContext, z as PadroneSpinnerPreset } from "./types-Ch8Mk6Qb.mjs";
2
- import { a as ColorConfig, i as AnsiStyle, o as ColorTheme, r as HelpInfo, s as colorThemes } from "./formatter-DtHzbP22.mjs";
1
+ import { a as ColorConfig, i as AnsiStyle, n as HelpFormat, o as ColorTheme, r as HelpInfo, s as colorThemes, t as HelpDetail } from "./formatter-DrvhDMrq.mjs";
2
+ import { $ as PadroneProgressIndicator, A as InterceptorShutdownContext, B as WithCommand, C as InterceptorExecuteContext, D as InterceptorParseContext, E as InterceptorMeta, F as PadroneInterceptor, G as WrapResult, H as AsyncPadroneSchema, I as PadroneInterceptorFn, J as InteractiveMode, K as PadroneServePreferences, L as Drained, M as InterceptorValidateContext, N as InterceptorValidateResult, O as InterceptorParseResult, P as PadroneContextInterceptor, Q as PadroneBarConfig, R as PickCommandByName, S as InterceptorErrorResult, T as InterceptorFactory, U as PadroneSchema, V as WithInterceptor, W as WrapConfig, X as PadroneBarAnimation, Y as InteractivePromptConfig, Z as PadroneBarChar, _ as ExtractInterceptorContext, a as PadroneExtension, at as PadroneSpinnerConfig, b as InterceptorDefBuilder, c as PadroneDrainResult, d as AnyPadroneCommand, et as PadroneProgressOptions, f as CommandTypesBase, g as PadroneProgramMeta, h as PadroneCommand, i as PadroneBuilder, it as PadroneSignal, j as InterceptorStartContext, k as InterceptorPhases, l as PadroneParseResult, m as PadroneActionContext, n as AnyPadroneProgram, nt as PadroneProgressUpdate, o as PadroneProgram, ot as PadroneSpinnerPreset, p as GetArgsMeta, q as PadroneMcpPreferences, r as DefineCommand, rt as PadroneRuntime, s as PadroneCommandResult, st as REPL_SIGINT, t as AnyPadroneBuilder, tt as PadroneProgressShow, u as PadroneReplPreferences, v as ExtractInterceptorRequires, w as InterceptorExecuteResult, x as InterceptorErrorContext, y as InterceptorBaseContext, z as PossibleCommands } from "./index-D6-7dz0l.mjs";
3
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
+ import * as _$ink from "ink";
4
5
 
5
- //#region src/command-utils.d.ts
6
+ //#region src/core/commands.d.ts
6
7
  /**
7
- * Brands a schema as async, signaling that its `validate()` may return a Promise.
8
- * When an async-branded schema is passed to `.arguments()`, `.configFile()`, or `.env()`,
9
- * the command's `parse()` and `cli()` will return Promises.
8
+ * Builds a completer function for the REPL from the command tree.
9
+ * Completes command names, subcommand names, option names (--foo), and aliases (-f).
10
+ * Also includes dot-prefixed built-in REPL commands (.exit, .clear, .scope, .help, .history).
11
+ */
12
+ declare function buildReplCompleter(rootCommand: AnyPadroneCommand, builtins: {
13
+ inScope?: boolean;
14
+ }): (line: string) => [string[], string];
15
+ //#endregion
16
+ //#region src/extension/help.d.ts
17
+ type HelpArgs = {
18
+ command?: string[];
19
+ detail?: HelpDetail;
20
+ format?: HelpFormat;
21
+ all?: boolean;
22
+ };
23
+ type HelpCommand = PadroneCommand<'help', '', PadroneSchema<HelpArgs>, string, [], ['h', ''], false>;
24
+ type WithHelp<T> = WithCommand<T, 'help', HelpCommand>;
25
+ /**
26
+ * Extension that adds help support:
27
+ * - `help` command with aliases `h` and `` (empty = executes on root when no subcommand matches)
28
+ * - `--help` / `-h` flags
29
+ * - `<cmd> help` reverse syntax
30
+ * - Default help display when a command has no action
10
31
  *
11
- * @example
32
+ * Usage:
12
33
  * ```ts
13
- * const schema = asyncSchema(z.object({
14
- * name: z.string(),
15
- * }).check(async (data) => {
16
- * // async validation logic
17
- * }));
18
- *
19
- * const program = createPadrone('app')
20
- * .command('greet', (c) => c.arguments(schema).action((args) => args.name));
34
+ * createPadrone('my-cli').extend(padroneHelp())
35
+ * ```
36
+ */
37
+ declare function padroneHelp(): <T extends CommandTypesBase>(builder: T) => WithHelp<T>;
38
+ //#endregion
39
+ //#region src/extension/version.d.ts
40
+ type VersionCommand = PadroneCommand<'version', '', PadroneSchema<void>, string, [], [], false>;
41
+ type WithVersion<T> = WithCommand<T, 'version', VersionCommand>;
42
+ /**
43
+ * Extension that adds version support:
44
+ * - `version` command
45
+ * - `--version` / `-v` / `-V` flags (root command only)
21
46
  *
22
- * // parse() now returns Promise<PadroneParseResult>
23
- * const result = await program.parse('greet --name world');
47
+ * Usage:
48
+ * ```ts
49
+ * createPadrone('my-cli').extend(padroneVersion())
24
50
  * ```
25
51
  */
52
+ declare function padroneVersion(): <T extends CommandTypesBase>(builder: T) => WithVersion<T>;
53
+ //#endregion
54
+ //#region src/core/results.d.ts
55
+ /**
56
+ * Brands a schema as async, signaling that its `validate()` may return a Promise.
57
+ * When an async-branded schema is passed to `.arguments()`, `.configFile()`, or `.env()`,
58
+ * the command's `parse()` and `cli()` will return Promises.
59
+ */
26
60
  declare function asyncSchema<T extends PadroneSchema>(schema: T): T & {
27
61
  '~async': true;
28
62
  };
63
+ //#endregion
64
+ //#region src/core/create.d.ts
29
65
  /**
30
- * Builds a completer function for the REPL from the command tree.
31
- * Completes command names, subcommand names, option names (--foo), and aliases (-f).
32
- * Also includes dot-prefixed built-in REPL commands (.exit, .clear, .scope, .help, .history).
66
+ * Options for configuring which built-in extensions are applied by default.
33
67
  */
34
- declare function buildReplCompleter(rootCommand: AnyPadroneCommand, builtins: {
35
- inScope?: boolean;
36
- }): (line: string) => [string[], string];
37
- //#endregion
38
- //#region src/create.d.ts
39
- declare function createPadrone<TProgramName extends string>(name: TProgramName): PadroneProgram<TProgramName, '', ''>;
40
- //#endregion
41
- //#region src/errors.d.ts
68
+ type PadroneBuiltins = {
69
+ /** Enable `help` command, `--help` / `-h` flags, and default help display. Defaults to `true`. */help?: boolean; /** Enable `version` command and `--version` / `-v` / `-V` flags. Defaults to `true`. */
70
+ version?: boolean; /** Enable `repl` command and `--repl` flag. Defaults to `true`. */
71
+ repl?: boolean; /** Enable `--color` / `--no-color` flag support. Defaults to `true`. */
72
+ color?: boolean; /** Enable "Did you mean?" suggestions for unknown commands and options. Defaults to `true`. */
73
+ suggestions?: boolean; /** Enable signal handling (SIGINT, SIGTERM, SIGHUP). Defaults to `true`. */
74
+ signal?: boolean; /** Enable automatic result output for `cli()`. Defaults to `true`. */
75
+ autoOutput?: boolean; /** Enable stdin piping support. Defaults to `true`. */
76
+ stdin?: boolean; /** Enable interactive prompting for missing arguments. Defaults to `true`. */
77
+ interactive?: boolean;
78
+ };
79
+ type PadroneOptions = {
80
+ builtins?: PadroneBuiltins;
81
+ };
82
+ type DefaultBuiltins = {};
83
+ type BuiltinCommands<B> = [...(B extends {
84
+ help: false;
85
+ } ? [] : [HelpCommand]), ...(B extends {
86
+ version: false;
87
+ } ? [] : [VersionCommand])];
88
+ declare function createPadrone<TProgramName extends string, const TBuiltins extends PadroneBuiltins = DefaultBuiltins>(name: TProgramName, options?: {
89
+ builtins?: TBuiltins;
90
+ }): PadroneProgram<TProgramName, '', '', PadroneSchema<void>, void, BuiltinCommands<TBuiltins>>;
42
91
  /**
43
- * Structured error hierarchy for Padrone CLI framework.
92
+ * Identity helper that contextually types a command builder callback while preserving its full return type.
93
+ * Use this when defining commands in separate files — the parent program retains exact type information
94
+ * about the subcommand's args, result, and nested commands.
44
95
  *
45
- * All Padrone errors extend `PadroneError`, which carries an exit code,
46
- * optional suggestions, and context about which command/phase produced the error.
47
- * This allows callers to distinguish user errors (bad input) from bugs (unexpected throws)
48
- * and to present formatted, actionable error messages.
96
+ * @example
97
+ * ```ts
98
+ * // my-command.ts
99
+ * export const myCommand = defineCommand((c) =>
100
+ * c.arguments(z.object({ name: z.string() }))
101
+ * .action((args) => console.log(args.name))
102
+ * );
103
+ *
104
+ * // cli.ts
105
+ * createPadrone('test').command('my-command', myCommand)
106
+ * ```
107
+ *
108
+ * @example With context
109
+ * ```ts
110
+ * export const myCommand = defineCommand<{ db: Database }>((c) =>
111
+ * c.arguments(z.object({ id: z.string() }))
112
+ * .action((args, ctx) => ctx.context.db.find(args.id))
113
+ * );
114
+ * ```
49
115
  */
116
+ declare function defineCommand<TContext = unknown, TOut extends CommandTypesBase = CommandTypesBase>(fn: (builder: PadroneBuilder<string, string, string, PadroneSchema<void>, void, [], any, false, TContext>) => TOut): typeof fn;
117
+ //#endregion
118
+ //#region src/core/errors.d.ts
50
119
  type PadroneErrorOptions = {
51
120
  /** Process exit code. Defaults to 1. */exitCode?: number; /** Actionable suggestions shown to the user (e.g. "Use --env production"). */
52
121
  suggestions?: string[]; /** The command path that produced the error (e.g. "deploy staging"). */
@@ -138,8 +207,738 @@ declare class ConfigError extends PadroneError {
138
207
  declare class ActionError extends PadroneError {
139
208
  constructor(message: string, options?: PadroneErrorOptions);
140
209
  }
210
+ /**
211
+ * Thrown when command execution is interrupted by a process signal (SIGINT, SIGTERM, SIGHUP).
212
+ * Carries the signal name and the conventional exit code (128 + signal number).
213
+ */
214
+ declare class SignalError extends PadroneError {
215
+ readonly signal: PadroneSignal;
216
+ constructor(signal: PadroneSignal, options?: {
217
+ cause?: unknown;
218
+ });
219
+ }
220
+ //#endregion
221
+ //#region src/core/interceptors.d.ts
222
+ /**
223
+ * Creates a self-contained interceptor value by attaching static metadata to the factory function.
224
+ * The returned value can be passed directly to `.intercept()` or exported from a package.
225
+ *
226
+ * Two-arg form — define metadata and factory in one call:
227
+ * ```ts
228
+ * export const myInterceptor = defineInterceptor(
229
+ * { name: 'my-interceptor', order: 10 },
230
+ * () => ({
231
+ * execute(ctx, next) { return next(); },
232
+ * }),
233
+ * );
234
+ * ```
235
+ *
236
+ * Single-arg form — chain `.requires<T>()` for typed context, then `.factory()`:
237
+ * ```ts
238
+ * export const myInterceptor = defineInterceptor({ name: 'with-db' })
239
+ * .requires<{ db: DB }>()
240
+ * .factory(() => ({
241
+ * execute(ctx, next) {
242
+ * ctx.context.db; // typed!
243
+ * return next();
244
+ * },
245
+ * }));
246
+ * ```
247
+ */
248
+ declare function defineInterceptor<TArgs = unknown, TResult = unknown>(meta: InterceptorMeta, factory: InterceptorFactory<TArgs, TResult>): PadroneInterceptorFn<TArgs, TResult>;
249
+ declare function defineInterceptor(meta: InterceptorMeta): InterceptorDefBuilder;
250
+ //#endregion
251
+ //#region src/output/styling.d.ts
252
+ /**
253
+ * Styling functions for semantic text roles.
254
+ * Used by formatters to apply visual styles (ANSI, HTML, Markdown, etc.)
255
+ * to different types of content.
256
+ */
257
+ type Styler = {
258
+ command: (text: string) => string;
259
+ arg: (text: string) => string;
260
+ type: (text: string) => string;
261
+ description: (text: string) => string;
262
+ label: (text: string) => string;
263
+ section: (text: string) => string;
264
+ meta: (text: string) => string;
265
+ example: (text: string) => string;
266
+ exampleValue: (text: string) => string;
267
+ deprecated: (text: string) => string;
268
+ };
269
+ /**
270
+ * Layout configuration for formatters.
271
+ */
272
+ type LayoutConfig = {
273
+ newline: string;
274
+ indent: (level: number) => string;
275
+ join: (parts: string[]) => string;
276
+ wrapDocument?: (content: string) => string;
277
+ };
278
+ /** Resolved formatting context used by output primitives. */
279
+ type OutputFormat = 'text' | 'ansi' | 'json' | 'markdown' | 'html';
280
+ type OutputContext = {
281
+ format: OutputFormat;
282
+ styler: Styler;
283
+ layout: LayoutConfig;
284
+ terminalWidth?: number;
285
+ };
286
+ //#endregion
287
+ //#region src/output/primitives.d.ts
288
+ type TableOptions = {
289
+ /** Explicit column keys to display (default: infer from first row's keys). */columns?: string[]; /** Column key → display header name mapping. */
290
+ headers?: Record<string, string>; /** Column key → text alignment. */
291
+ align?: Record<string, 'left' | 'right' | 'center'>; /** Maximum column width before truncation. */
292
+ maxColumnWidth?: number; /** Show borders (default: true for ansi/text, false for others). */
293
+ border?: boolean;
294
+ };
295
+ type TreeNode = {
296
+ label: string;
297
+ children?: TreeNode[];
298
+ };
299
+ type TreeOptions = {
300
+ /** Characters per indent level (default: 2). */indent?: number; /** Show tree guide lines (default: true for ansi/text). */
301
+ guides?: boolean;
302
+ };
303
+ type ListItem = string | {
304
+ label: string;
305
+ description?: string;
306
+ };
307
+ type ListOptions = {
308
+ /** Bullet character (default: '•' for ansi, '-' for text). */bullet?: string; /** Use numbered list instead of bullets. */
309
+ numbered?: boolean; /** Indent level (default: 0). */
310
+ indent?: number;
311
+ };
312
+ type KeyValueOptions = {
313
+ /** Separator between key and value (default: ': '). */separator?: string; /** Align values by padding keys to the same width. */
314
+ align?: boolean; /** Key → display label mapping. */
315
+ labels?: Record<string, string>;
316
+ };
317
+ //#endregion
318
+ //#region src/output/output-indicator.d.ts
319
+ /**
320
+ * Runtime output helper injected into action context as `ctx.context.output`.
321
+ * Provides format-aware output primitives (table, tree, list, key-value).
322
+ *
323
+ * Each method renders data using the resolved format (ANSI, text, JSON, markdown, HTML)
324
+ * and writes it to the runtime's output function.
325
+ */
326
+ type PadroneOutputIndicator = {
327
+ /** Render data as a table. */table(data: Record<string, unknown>[], options?: TableOptions): void; /** Render data as a tree. */
328
+ tree(data: TreeNode | TreeNode[], options?: TreeOptions): void; /** Render data as a list. */
329
+ list(data: ListItem[], options?: ListOptions): void; /** Render data as aligned key-value pairs. */
330
+ kv(data: Record<string, unknown>, options?: KeyValueOptions): void; /** Write raw output (same as runtime.output but sets the "already called" flag). */
331
+ raw(...args: unknown[]): void; /** Whether any output method has been called. */
332
+ readonly called: boolean;
333
+ };
334
+ /** Declarative output configuration for a command. */
335
+ type OutputPrimitiveType = 'table' | 'tree' | 'list' | 'kv' | 'json';
336
+ type OutputConfig = OutputPrimitiveType | {
337
+ type: OutputPrimitiveType;
338
+ options?: TableOptions | TreeOptions | ListOptions | KeyValueOptions;
339
+ };
340
+ //#endregion
341
+ //#region src/extension/auto-output.d.ts
342
+ type PadroneAutoOutputOptions = {
343
+ /** Disable auto-output entirely. */disabled?: boolean;
344
+ /**
345
+ * Declarative output format for the command's return value.
346
+ * When set, auto-output formats the return value through the specified primitive
347
+ * instead of passing it raw to `runtime.output`.
348
+ * Ignored when the action calls `ctx.context.output.*` explicitly.
349
+ *
350
+ * ```ts
351
+ * // Format return value as a table
352
+ * c.extend(padroneAutoOutput({ output: 'table' }))
353
+ *
354
+ * // Format with options
355
+ * c.extend(padroneAutoOutput({ output: { type: 'table', options: { border: false } } }))
356
+ * ```
357
+ */
358
+ output?: OutputConfig;
359
+ };
360
+ /**
361
+ * Extension that automatically writes a command's return value to output after execution.
362
+ *
363
+ * - Values are passed directly to the runtime's `output` function (no stringification).
364
+ * - Promises are awaited before output.
365
+ * - Iterators and async iterators are consumed, outputting each yielded value as it arrives.
366
+ * The result is replaced with the collected array so `drain()` still works.
367
+ * - `undefined` and `null` results produce no output.
368
+ *
369
+ * Also injects `ctx.context.output` with format-aware output primitives (table, tree, list, kv).
370
+ * When action handlers use these methods, auto-output skips to avoid double output.
371
+ *
372
+ * Included in the default extensions. Can also be applied per-command:
373
+ * ```ts
374
+ * createPadrone('my-cli')
375
+ * .command('users', (c) =>
376
+ * c.extend(padroneAutoOutput({ output: 'table' }))
377
+ * .action(() => fetchUsers())
378
+ * )
379
+ * ```
380
+ */
381
+ declare function padroneAutoOutput(options?: PadroneAutoOutputOptions): <T extends CommandTypesBase>(builder: T) => T;
382
+ //#endregion
383
+ //#region src/extension/color.d.ts
384
+ /**
385
+ * Extension that handles `--color` / `--no-color` flags:
386
+ * - `--color` or `--color=true` → use default theme
387
+ * - `--color=false` or `--no-color` → disable colors (text format)
388
+ * - `--color=<theme>` → use the named theme
389
+ *
390
+ * Modifies the runtime's format and theme accordingly.
391
+ *
392
+ * Usage:
393
+ * ```ts
394
+ * createPadrone('my-cli').extend(padroneColor())
395
+ * ```
396
+ */
397
+ declare function padroneColor(): <T extends CommandTypesBase>(builder: T) => T;
398
+ //#endregion
399
+ //#region src/extension/completion.d.ts
400
+ type CompletionArgs = {
401
+ shell?: string;
402
+ setup?: boolean;
403
+ };
404
+ type CompletionCommand = PadroneCommand<'completion', '', PadroneSchema<CompletionArgs>, string, [], [], true>;
405
+ type WithCompletion<T> = WithCommand<T, 'completion', CompletionCommand>;
406
+ /**
407
+ * Extension that adds the `completion` command for shell completion script generation.
408
+ *
409
+ * Usage:
410
+ * ```ts
411
+ * createPadrone('my-cli').extend(padroneCompletion())
412
+ * ```
413
+ */
414
+ declare function padroneCompletion(): <T extends CommandTypesBase>(builder: T) => WithCompletion<T>;
415
+ //#endregion
416
+ //#region src/extension/config.d.ts
417
+ type PadroneConfigOptions = {
418
+ /** Config file names to auto-detect (e.g. `['config.json', '.myapprc']`). First found is used. */files?: string | string[]; /** Schema to validate and transform config file data into the args shape. */
419
+ schema?: StandardSchemaV1; /** Disable this extension. */
420
+ disabled?: boolean; /** Whether to add `--config` / `-c` flag support. Defaults to `true`. */
421
+ flag?: boolean; /** Whether subcommands inherit this interceptor. Defaults to `true`. */
422
+ inherit?: boolean;
423
+ /**
424
+ * Search for config files in the user's platform-specific config directory.
425
+ * - `true` — use the program name as the subdirectory (e.g. program `'myapp'` → `~/.config/myapp/`).
426
+ * - `string` — use a custom app name as the subdirectory.
427
+ * - `false` — disable (default).
428
+ *
429
+ * Directories searched (after cwd):
430
+ * - **Linux**: `$XDG_CONFIG_HOME/<app>` or `~/.config/<app>`
431
+ * - **macOS**: `~/Library/Application Support/<app>` (or `$XDG_CONFIG_HOME/<app>` when set)
432
+ * - **Windows**: `%APPDATA%\<app>`
433
+ *
434
+ * Config files found in cwd always take precedence over XDG paths.
435
+ */
436
+ xdg?: string | boolean;
437
+ /**
438
+ * Custom config loader. When provided, replaces the built-in file system loader.
439
+ * Useful for testing or non-CLI environments.
440
+ */
441
+ loadConfig?: (files: string | string[], xdgAppName?: string) => Record<string, unknown> | undefined | Promise<Record<string, unknown> | undefined>;
442
+ };
443
+ /**
444
+ * Extension that handles config file loading, validation, and merging into command arguments.
445
+ *
446
+ * Features:
447
+ * - `--config` / `-c` flag for explicit config file path (can be disabled via `flag: false`)
448
+ * - Auto-detection of config files from a list of candidate names
449
+ * - Optional schema validation and transformation of config data
450
+ * - Directly accesses the file system (gracefully no-ops in non-CLI environments)
451
+ *
452
+ * Config values have the lowest precedence (CLI > stdin > env > config).
453
+ *
454
+ * Not included in the default built-in extensions — must be explicitly added:
455
+ * ```ts
456
+ * createPadrone('my-cli')
457
+ * .extend(padroneConfig({
458
+ * files: ['config.json', '.myapprc'],
459
+ * schema: z.object({ port: z.number(), host: z.string() }),
460
+ * }))
461
+ * ```
462
+ */
463
+ declare function padroneConfig(options?: PadroneConfigOptions): <T extends CommandTypesBase>(builder: T) => T;
464
+ //#endregion
465
+ //#region src/extension/env.d.ts
466
+ type PadroneEnvOptions = {
467
+ /** Env modes to load (e.g. `['production']`). Loads `.env.{mode}` files. */modes?: string[]; /** Whether to load `.env.local` and `.env.{mode}.local` files. @default true */
468
+ local?: boolean; /** Directory to search for `.env` files. @default process.cwd() */
469
+ dir?: string; /** When `true`, file values override `process.env` values. @default false */
470
+ override?: boolean; /** When `false`, the base `.env` (and `.env.local`) files are not loaded. @default true */
471
+ base?: boolean;
472
+ };
473
+ /**
474
+ * Extension that reads environment variables, validates them against a schema,
475
+ * and merges the transformed values into command arguments.
476
+ *
477
+ * Supports loading `.env` files with mode-based overrides and variable expansion.
478
+ *
479
+ * ```ts
480
+ * // Schema only (reads process.env)
481
+ * .extend(padroneEnv(
482
+ * z.object({ PORT: z.string() }).transform(e => ({ port: Number(e.PORT) }))
483
+ * ))
484
+ *
485
+ * // Schema + .env file loading
486
+ * .extend(padroneEnv(
487
+ * z.object({ PORT: z.string() }).transform(e => ({ port: Number(e.PORT) })),
488
+ * { modes: ['production'] }
489
+ * ))
490
+ *
491
+ * // .env file loading only (no schema validation)
492
+ * .extend(padroneEnv({ modes: ['production'] }))
493
+ * ```
494
+ *
495
+ * Env values have lower precedence than CLI args and stdin, but higher than config files.
496
+ */
497
+ declare function padroneEnv(schema: StandardSchemaV1): <T extends CommandTypesBase>(builder: T) => T;
498
+ declare function padroneEnv(schema: StandardSchemaV1, options: PadroneEnvOptions): <T extends CommandTypesBase>(builder: T) => T;
499
+ declare function padroneEnv(options: PadroneEnvOptions): <T extends CommandTypesBase>(builder: T) => T;
500
+ //#endregion
501
+ //#region src/extension/ink.d.ts
502
+ /** Checks whether a value is a React element (JSX) by inspecting its `$$typeof` symbol. */
503
+ declare function isReactElement(value: unknown): boolean;
504
+ type InkOptions = {
505
+ /** Whether to wait for the Ink app to unmount before resolving. Defaults to `true`. */waitUntilExit?: boolean; /** Options forwarded to Ink's `render()`. */
506
+ render?: _$ink.RenderOptions;
507
+ };
508
+ /**
509
+ * Extension that renders React (Ink) components returned from command actions.
510
+ *
511
+ * When a command's action returns a React element (JSX), this extension
512
+ * renders it using Ink instead of passing it to the normal output path.
513
+ *
514
+ * Requires `ink` and `react` as peer dependencies.
515
+ *
516
+ * ```ts
517
+ * import { createPadrone, padroneInk } from 'padrone';
518
+ *
519
+ * const program = createPadrone('my-tui')
520
+ * .extend(padroneInk())
521
+ * .command('dashboard', (c) =>
522
+ * c.action(() => <Dashboard />)
523
+ * );
524
+ * ```
525
+ */
526
+ declare function padroneInk(options?: InkOptions): <T extends CommandTypesBase>(builder: T) => T;
527
+ //#endregion
528
+ //#region src/extension/interactive.d.ts
529
+ /**
530
+ * Extension that handles interactive prompting for missing arguments.
531
+ * Extracts `--interactive` / `-i` flags, resolves effective interactivity,
532
+ * and prompts for missing fields before passing filled args to validation.
533
+ *
534
+ * Usage:
535
+ * ```ts
536
+ * createPadrone('my-cli').extend(padroneInteractive())
537
+ * ```
538
+ */
539
+ declare function padroneInteractive(): <T extends CommandTypesBase>(builder: T) => T;
540
+ //#endregion
541
+ //#region src/extension/logger.d.ts
542
+ /** Log level values ordered by severity. */
543
+ type PadroneLogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
544
+ /** Logger instance injected into the command context. */
545
+ type PadroneLogger = {
546
+ trace: (...args: unknown[]) => void;
547
+ debug: (...args: unknown[]) => void;
548
+ info: (...args: unknown[]) => void;
549
+ warn: (...args: unknown[]) => void;
550
+ error: (...args: unknown[]) => void; /** The current effective log level. */
551
+ level: PadroneLogLevel; /** Create a child logger with a prefix label. */
552
+ child: (label: string) => PadroneLogger;
553
+ };
554
+ /** Configuration for the logger extension. */
555
+ type PadroneLoggerConfig = {
556
+ /** Minimum log level to output. Defaults to `'info'`. */level?: PadroneLogLevel; /** Prefix prepended to every log message. */
557
+ prefix?: string; /** Include timestamps in log output. Defaults to `false`. */
558
+ timestamps?: boolean;
559
+ };
560
+ /** Builder/program type after applying `padroneLogger()`. Adds `{ logger: PadroneLogger }` to the command context. */
561
+ type WithLogger<T> = WithInterceptor<T, {
562
+ logger: PadroneLogger;
563
+ }>;
564
+ /**
565
+ * Extension that injects a structured logger into the command context.
566
+ *
567
+ * The logger respects a configurable log level threshold, supports prefixed
568
+ * child loggers, and routes output through the runtime's `output`/`error`
569
+ * functions so it works in any environment (terminal, test, web).
570
+ *
571
+ * Supports CLI flags for runtime level overrides:
572
+ * - `--trace` → sets level to `trace`
573
+ * - `--verbose` or `--debug` → sets level to `debug`
574
+ * - `--silent` or `--quiet` → sets level to `silent`
575
+ * - `--log-level=<level>` → sets an explicit level (`trace`, `debug`, `info`, `warn`, `error`, `silent`)
576
+ *
577
+ * CLI flags take precedence over the programmatic config.
578
+ *
579
+ * Provides `{ logger: PadroneLogger }` on the command context.
580
+ * Access it in action handlers as `ctx.context.logger`.
581
+ *
582
+ * Usage:
583
+ * ```ts
584
+ * createPadrone('my-cli')
585
+ * .extend(padroneLogger({ level: 'info' }))
586
+ * .command('sync', (c) =>
587
+ * c.action((_args, ctx) => {
588
+ * ctx.context.logger.info('starting sync');
589
+ * const db = ctx.context.logger.child('db');
590
+ * db.debug('connecting...');
591
+ * })
592
+ * )
593
+ * ```
594
+ *
595
+ * Then run:
596
+ * ```sh
597
+ * my-cli sync --verbose # debug level
598
+ * my-cli sync --quiet # silent
599
+ * my-cli sync --log-level=warn
600
+ * ```
601
+ */
602
+ declare function padroneLogger<T extends CommandTypesBase>(config?: PadroneLoggerConfig): (builder: T) => WithLogger<T>;
603
+ //#endregion
604
+ //#region src/extension/man.d.ts
605
+ type ManArgs = {
606
+ setup?: boolean;
607
+ remove?: boolean;
608
+ };
609
+ type ManCommand = PadroneCommand<'man', '', PadroneSchema<ManArgs>, string, [], [], true>;
610
+ type WithMan<T> = WithCommand<T, 'man', ManCommand>;
611
+ /**
612
+ * Extension that adds the `man` command for man page generation.
613
+ *
614
+ * Usage:
615
+ * ```ts
616
+ * createPadrone('my-cli').extend(padroneMan())
617
+ * ```
618
+ */
619
+ declare function padroneMan(): <T extends CommandTypesBase>(builder: T) => WithMan<T>;
620
+ //#endregion
621
+ //#region src/extension/mcp.d.ts
622
+ type McpArgs = {
623
+ transport?: string;
624
+ port?: string;
625
+ host?: string;
626
+ basePath?: string;
627
+ };
628
+ type McpCommand = PadroneCommand<'mcp', '', PadroneSchema<McpArgs>, void, [], [], true>;
629
+ type WithMcp<T> = WithCommand<T, 'mcp', McpCommand>;
630
+ /**
631
+ * Extension that adds the `mcp` command for starting a Model Context Protocol server.
632
+ *
633
+ * Usage:
634
+ * ```ts
635
+ * createPadrone('my-cli').extend(padroneMcp())
636
+ * ```
637
+ */
638
+ declare function padroneMcp(defaults?: PadroneMcpPreferences): <T extends CommandTypesBase>(builder: T) => WithMcp<T>;
639
+ //#endregion
640
+ //#region src/extension/progress-renderer.d.ts
641
+ /** Factory function that creates a `PadroneProgressIndicator`. */
642
+ type PadroneProgressRenderer = (message: string, options?: PadroneProgressOptions) => PadroneProgressIndicator;
643
+ /**
644
+ * Creates a terminal progress indicator (spinner, bar, or both).
645
+ * Returns a no-op indicator in non-TTY/CI environments.
646
+ */
647
+ declare function createTerminalProgress(message: string, options?: PadroneProgressOptions): PadroneProgressIndicator;
648
+ //#endregion
649
+ //#region src/extension/progress.d.ts
650
+ /** A progress message value: a plain string, `null` to suppress, or an object with a message and custom indicator icon. */
651
+ type PadroneProgressMessage = string | null | {
652
+ message?: string | null;
653
+ indicator?: string;
654
+ };
655
+ /** Per-phase message configuration for progress indicators. */
656
+ type PadroneProgressMessages<TRes = unknown> = {
657
+ /** Message shown during async validation. Defaults to `''` (spinner only). */validation?: string; /** Message shown while the command's action is running. */
658
+ progress?: string; /** Message shown when the command succeeds. `null` to suppress. Defaults to the `progress` message. */
659
+ success?: PadroneProgressMessage | ((result: TRes) => PadroneProgressMessage); /** Message shown when the command fails. `null` to suppress. Defaults to the error message. */
660
+ error?: PadroneProgressMessage | ((error: unknown) => PadroneProgressMessage);
661
+ };
662
+ /**
663
+ * Progress indicator configuration with messages, visual options, and renderer.
664
+ */
665
+ type PadroneProgressConfig<TRes = unknown> = {
666
+ /** Per-phase messages. A string sets the `progress` message; an object configures individual phases. */message?: string | PadroneProgressMessages<TRes>; /** Spinner configuration. Default `show` is `'auto'` (visible when bar is not shown). `true` forces spinner to always show (even alongside a bar). */
667
+ spinner?: PadroneSpinnerConfig; /** Enable a progress bar. `true` for defaults (`show: 'always'`), or a `PadroneBarConfig` object. `false` to disable entirely. When omitted, bar defaults to `show: 'auto'`. */
668
+ bar?: boolean | PadroneBarConfig; /** Show elapsed time since the indicator started. Can also be started on demand via `update({ time: true })`. */
669
+ time?: boolean; /** Show estimated time remaining based on progress rate. Requires numeric `update()` calls. */
670
+ eta?: boolean;
671
+ /**
672
+ * Custom renderer factory. Called to create the progress indicator.
673
+ * Defaults to the built-in terminal renderer (`createTerminalProgress`).
674
+ */
675
+ renderer?: PadroneProgressRenderer;
676
+ };
677
+ /**
678
+ * Shared progress defaults that can be provided via context instead of repeating
679
+ * at each call site. Per-instance message fields are excluded — those always come
680
+ * from the constructor argument.
681
+ *
682
+ * Provide via context as `{ progressConfig: PadroneProgressDefaults }`.
683
+ */
684
+ type PadroneProgressDefaults = Pick<PadroneProgressConfig, 'message' | 'spinner' | 'bar' | 'time' | 'eta' | 'renderer'>;
685
+ /** Builder/program type after applying `padroneProgress()`. Adds `{ progress: PadroneProgressIndicator }` to the command context. */
686
+ type WithProgress<T> = WithInterceptor<T, {
687
+ progress: PadroneProgressIndicator;
688
+ }>;
689
+ /**
690
+ * Extension that adds an auto-managed progress indicator to the command pipeline.
691
+ *
692
+ * - `string` — a single message used for all states.
693
+ * - `PadroneProgressConfig` — separate messages for validation, progress, success, and error.
694
+ *
695
+ * The indicator is automatically started before validation, updated at each phase transition,
696
+ * and stopped on success (`.succeed()`) or failure (`.fail()`).
697
+ *
698
+ * Provides `{ progress: PadroneProgressIndicator }` on the command context.
699
+ * Access it in action handlers as `ctx.context.progress`.
700
+ *
701
+ * Uses the built-in terminal renderer by default. Pass a custom `renderer` for non-terminal
702
+ * environments (web UIs, testing, etc).
703
+ *
704
+ * Usage:
705
+ * ```ts
706
+ * createPadrone('my-cli')
707
+ * .command('sync', (c) =>
708
+ * c.extend(padroneProgress('Syncing...'))
709
+ * .action((_args, ctx) => {
710
+ * ctx.context.progress.update('halfway');
711
+ * })
712
+ * )
713
+ * ```
714
+ */
715
+ declare function padroneProgress<T extends CommandTypesBase>(config?: string | PadroneProgressConfig): (builder: T) => WithProgress<T>;
716
+ //#endregion
717
+ //#region src/extension/repl.d.ts
718
+ type ReplArgs = {
719
+ scope?: string;
720
+ };
721
+ type ReplCommand = PadroneCommand<'repl', '', PadroneSchema<ReplArgs>, void, [], [], true>;
722
+ type WithRepl<T> = WithCommand<T, 'repl', ReplCommand>;
723
+ /**
724
+ * Extension that adds REPL support:
725
+ * - `repl` command that starts an interactive REPL
726
+ * - `--repl` flag that starts the REPL from any invocation
727
+ *
728
+ * Usage:
729
+ * ```ts
730
+ * createPadrone('my-cli').extend(padroneRepl())
731
+ * ```
732
+ */
733
+ declare function padroneRepl(defaults?: PadroneReplPreferences & {
734
+ disabled?: boolean;
735
+ }): <T extends CommandTypesBase>(builder: T) => WithRepl<T>;
736
+ //#endregion
737
+ //#region src/extension/serve.d.ts
738
+ type ServeArgs = {
739
+ port?: string;
740
+ host?: string;
741
+ basePath?: string;
742
+ };
743
+ type ServeCommand = PadroneCommand<'serve', '', PadroneSchema<ServeArgs>, void, [], [], true>;
744
+ type WithServe<T> = WithCommand<T, 'serve', ServeCommand>;
745
+ /**
746
+ * Extension that adds the `serve` command for starting a REST HTTP server.
747
+ *
748
+ * Usage:
749
+ * ```ts
750
+ * createPadrone('my-cli').extend(padroneServe())
751
+ * ```
752
+ */
753
+ declare function padroneServe(defaults?: PadroneServePreferences): <T extends CommandTypesBase>(builder: T) => WithServe<T>;
754
+ //#endregion
755
+ //#region src/extension/signal.d.ts
756
+ /**
757
+ * Extension that wires process signal handling (SIGINT, SIGTERM, SIGHUP) into the interceptor lifecycle.
758
+ *
759
+ * - Creates an `AbortController` whose signal is propagated to all downstream phases.
760
+ * - Subscribes to `runtime.onSignal` to forward OS signals to the abort controller.
761
+ * - Implements SIGINT double-tap: two SIGINTs within 2 seconds force-exits the process.
762
+ * - Attaches `signal` and `exitCode` to results and errors when interrupted.
763
+ * - Cleans up the signal subscription on completion or failure.
764
+ *
765
+ * Included in the default extensions. Runs at order `-2000` (outermost).
766
+ */
767
+ declare function padroneSignalHandling(options?: {
768
+ disabled?: boolean;
769
+ }): <T extends CommandTypesBase>(builder: T) => T;
770
+ //#endregion
771
+ //#region src/extension/stdin.d.ts
772
+ /**
773
+ * Extension that reads stdin data into the argument field specified by `meta.stdin`.
774
+ * Included by default via `createPadrone()`.
775
+ *
776
+ * Read mode is inferred from the schema type:
777
+ * - `string` field → reads all stdin as a single string
778
+ * - `string[]` field → reads stdin line-by-line into an array
779
+ * - `AsyncIterable` field → returns a stream for line-by-line async consumption
780
+ *
781
+ * Stdin is only read when piped (not a TTY) and the field wasn't already provided via CLI flags.
782
+ */
783
+ declare function padroneStdin(options?: {
784
+ disabled?: boolean;
785
+ }): <T extends CommandTypesBase>(builder: T) => T;
786
+ //#endregion
787
+ //#region src/extension/suggestions.d.ts
788
+ declare function padroneSuggestions(): <T extends CommandTypesBase>(builder: T) => T;
789
+ //#endregion
790
+ //#region src/extension/timing.d.ts
791
+ interface PadroneTimingOptions {
792
+ /** Enable timing by default without requiring `--time` flag. Default: `false`. */
793
+ enabled?: boolean;
794
+ }
795
+ /**
796
+ * Extension that tracks command execution time.
797
+ *
798
+ * - `--time` / `--timing` → enables timing output
799
+ * - `--no-time` / `--no-timing` → disables timing output
800
+ *
801
+ * Pass `{ enabled: true }` to enable timing by default (can be disabled via `--no-time`).
802
+ *
803
+ * Usage:
804
+ * ```ts
805
+ * // Opt-in via flag
806
+ * createPadrone('my-cli').extend(padroneTiming())
807
+ *
808
+ * // Always on, opt-out via --no-time
809
+ * createPadrone('my-cli').extend(padroneTiming({ enabled: true }))
810
+ * ```
811
+ */
812
+ declare function padroneTiming(options?: PadroneTimingOptions): <T extends CommandTypesBase>(builder: T) => T;
813
+ //#endregion
814
+ //#region src/extension/tracing.d.ts
815
+ /** Minimal subset of OTEL `SpanStatusCode`. */
816
+ type SpanStatusCode = 0 | 1 | 2;
817
+ /** Minimal subset of OTEL `SpanStatus`. */
818
+ type SpanStatus = {
819
+ code: SpanStatusCode;
820
+ message?: string;
821
+ };
822
+ /** Minimal subset of OTEL `Span`. */
823
+ interface OtelSpan {
824
+ setAttribute(key: string, value: string | number | boolean): this;
825
+ addEvent(name: string, attributes?: Record<string, string | number | boolean>): this;
826
+ setStatus(status: SpanStatus): this;
827
+ recordException(error: unknown): this;
828
+ end(): void;
829
+ spanContext(): {
830
+ traceId: string;
831
+ spanId: string;
832
+ };
833
+ }
834
+ /** Minimal subset of OTEL `Tracer`. */
835
+ interface OtelTracer {
836
+ startSpan(name: string): OtelSpan;
837
+ }
838
+ /** Minimal subset of OTEL `TracerProvider`. */
839
+ interface OtelTracerProvider {
840
+ getTracer(name: string, version?: string): OtelTracer;
841
+ }
842
+ /** Tracing handle injected into the command context. */
843
+ type PadroneTracer = {
844
+ /** The underlying OTEL tracer. */tracer: OtelTracer; /** Root span covering the full command execution. */
845
+ rootSpan: OtelSpan; /** Run `fn` inside a child span that is automatically ended when `fn` returns (or rejects). */
846
+ span: <T>(name: string, fn: (span: OtelSpan) => T) => T;
847
+ };
848
+ /** Configuration for the tracing extension. */
849
+ type PadroneTracingConfig = {
850
+ /** OTEL `TracerProvider`. Required — there is no global fallback. */provider: OtelTracerProvider; /** Service / tracer name. Defaults to the CLI program name. */
851
+ serviceName?: string;
852
+ };
853
+ /** Builder/program type after applying `padroneTracing()`. Adds `{ tracing: PadroneTracer }` to the command context. */
854
+ type WithTracing<T> = WithInterceptor<T, {
855
+ tracing: PadroneTracer;
856
+ }>;
857
+ /**
858
+ * Extension that adds OpenTelemetry tracing to command execution.
859
+ *
860
+ * Creates a root span for each command invocation and provides a `PadroneTracer`
861
+ * on the command context for creating child spans in action handlers.
862
+ *
863
+ * When used with `padroneLogger()`, the logger automatically emits span events
864
+ * for each log call — no extra configuration needed. The logger detects the
865
+ * tracing context and bridges log output to span events.
866
+ *
867
+ * Uses minimal OTEL-compatible interfaces — pass any `TracerProvider` that
868
+ * implements `getTracer()`. Works with `@opentelemetry/api` or compatible
869
+ * libraries.
870
+ *
871
+ * Provides `{ tracing: PadroneTracer }` on the command context.
872
+ * Access it in action handlers as `ctx.context.tracing`.
873
+ *
874
+ * Usage:
875
+ * ```ts
876
+ * import { trace } from '@opentelemetry/api';
877
+ *
878
+ * createPadrone('my-cli')
879
+ * .extend(padroneTracing({ provider: trace.getTracerProvider() }))
880
+ * .extend(padroneLogger())
881
+ * .command('deploy', (c) =>
882
+ * c.action((_args, ctx) => {
883
+ * ctx.context.logger.info('deploying'); // also emits a span event
884
+ * ctx.context.tracing.span('build', (span) => {
885
+ * span.setAttribute('target', 'production');
886
+ * });
887
+ * })
888
+ * )
889
+ * ```
890
+ */
891
+ declare function padroneTracing<T extends CommandTypesBase>(config: PadroneTracingConfig): (builder: T) => WithTracing<T>;
892
+ //#endregion
893
+ //#region src/feature/update-check.d.ts
894
+ /**
895
+ * Configuration for the update check feature.
896
+ */
897
+ type UpdateCheckConfig = {
898
+ /**
899
+ * The npm package name to check. Defaults to the program name.
900
+ */
901
+ packageName?: string;
902
+ /**
903
+ * Registry to check for updates.
904
+ * - `'npm'` — checks the npm registry (default)
905
+ * - A URL string — custom registry endpoint that returns JSON with a `version` or `dist-tags.latest` field
906
+ */
907
+ registry?: 'npm' | string;
908
+ /**
909
+ * How often to check for updates. Accepts shorthand like `'1d'`, `'12h'`, `'30m'`.
910
+ * Defaults to `'1d'` (once per day).
911
+ */
912
+ interval?: string;
913
+ /**
914
+ * Path to the cache file for storing the last check timestamp and latest version.
915
+ * Defaults to `~/.config/<programName>-update-check.json`.
916
+ */
917
+ cache?: string;
918
+ /**
919
+ * Environment variable name to disable update checks (e.g. `'MYAPP_NO_UPDATE_CHECK'`).
920
+ * When set to a truthy value, update checks are skipped.
921
+ * Defaults to `'<PROGRAM_NAME>_NO_UPDATE_CHECK'` (uppercased, hyphens to underscores).
922
+ */
923
+ disableEnvVar?: string;
924
+ };
141
925
  //#endregion
142
- //#region src/stream.d.ts
926
+ //#region src/extension/update-check.d.ts
927
+ /**
928
+ * Extension that adds background update checking:
929
+ * - Checks for newer versions on npm (or custom registry) in the background
930
+ * - Shows an update notification after command execution
931
+ * - Respects `--no-update-check` flag to suppress
932
+ *
933
+ * Usage:
934
+ * ```ts
935
+ * createPadrone('my-cli')
936
+ * .extend(padroneUpdateCheck({ packageName: 'my-cli' }))
937
+ * ```
938
+ */
939
+ declare function padroneUpdateCheck(config?: UpdateCheckConfig): <T extends CommandTypesBase>(builder: T) => T;
940
+ //#endregion
941
+ //#region src/util/stream.d.ts
143
942
  interface AsyncStreamMeta {
144
943
  [x: string]: unknown;
145
944
  readonly asyncStream: number;
@@ -167,7 +966,7 @@ interface AsyncStreamMeta {
167
966
  */
168
967
  declare function asyncStream<T = string>(itemSchema?: PadroneSchema<T>): AsyncStreamMeta;
169
968
  //#endregion
170
- //#region src/type-helpers.d.ts
969
+ //#region src/util/type-helpers.d.ts
171
970
  /**
172
971
  * Extracts the input type of the arguments schema from a command.
173
972
  * @example
@@ -184,6 +983,40 @@ type InferArgsInput<T extends AnyPadroneCommand> = T['~types']['argsInput'];
184
983
  * ```
185
984
  */
186
985
  type InferArgsOutput<T extends AnyPadroneCommand> = T['~types']['argsOutput'];
986
+ /**
987
+ * Extracts the user-defined context type from a command (excludes interceptor-provided context).
988
+ * @example
989
+ * ```ts
990
+ * type Ctx = InferContext<typeof myCommand>;
991
+ * ```
992
+ */
993
+ type InferContext<T extends AnyPadroneCommand> = T['~types']['context'];
994
+ /**
995
+ * Extracts the interceptor-provided context type from a command.
996
+ * @example
997
+ * ```ts
998
+ * type Provided = InferContextProvided<typeof myCommand>;
999
+ * ```
1000
+ */
1001
+ type InferContextProvided<T extends AnyPadroneCommand> = T['~types']['contextProvided'];
1002
+ /**
1003
+ * Extracts the context type that a context-providing interceptor injects.
1004
+ * @example
1005
+ * ```ts
1006
+ * type AuthCtx = InferInterceptorContext<typeof withAuth>;
1007
+ * ```
1008
+ */
1009
+ type InferInterceptorContext<T extends PadroneContextInterceptor<any>> = T['~context'];
1010
+ /**
1011
+ * Extracts the required context type from an interceptor with `.requires()`.
1012
+ * @example
1013
+ * ```ts
1014
+ * type Requires = InferInterceptorRequires<typeof withAuth>;
1015
+ * ```
1016
+ */
1017
+ type InferInterceptorRequires<T extends PadroneInterceptorFn & {
1018
+ '~contextRequires': any;
1019
+ }> = T['~contextRequires'] extends ((ctx: infer R) => void) ? R : unknown;
187
1020
  /**
188
1021
  * Gets a command type by its path from a program or command tree.
189
1022
  * Supports both full paths (e.g., "config set") and alias paths.
@@ -201,5 +1034,5 @@ type InferArgsOutput<T extends AnyPadroneCommand> = T['~types']['argsOutput'];
201
1034
  */
202
1035
  type InferCommand<T extends AnyPadroneCommand | AnyPadroneProgram, TPath extends PossibleCommands<T extends AnyPadroneCommand ? [T] : T['~types']['commands'], true, true>> = T extends AnyPadroneProgram ? PickCommandByName<[PadroneCommand<'', '', any, any, T['~types']['commands']>], TPath> : T extends AnyPadroneCommand ? PickCommandByName<[T], TPath> : never;
203
1036
  //#endregion
204
- export { ActionError, type AnsiStyle, type AnyPadroneBuilder, type AnyPadroneCommand, type AnyPadroneProgram, type AsyncPadroneSchema, type AsyncStreamMeta, type ColorConfig, type ColorTheme, ConfigError, type Drained, type HelpInfo, type InferArgsInput, type InferArgsOutput, type InferCommand, type InteractiveMode, type InteractivePromptConfig, type PadroneActionContext, type PadroneBuilder, type PadroneCommand, type PadroneCommandResult, type PadroneDrainResult, PadroneError, type PadroneErrorOptions, type PadroneMcpPreferences, type PadroneParseResult, type PadronePlugin, type PadroneProgram, type PadroneProgressPrefs as PadroneProgressConfig, type PadroneProgressIndicator, type PadroneProgressMessage, type PadroneProgressOptions, type PadroneRuntime, type PadroneSchema, type PadroneSpinnerConfig, type PadroneSpinnerPreset, type PluginBaseContext, type PluginErrorContext, type PluginErrorResult, type PluginExecuteContext, type PluginExecuteResult, type PluginParseContext, type PluginParseResult, type PluginShutdownContext, type PluginStartContext, type PluginValidateContext, type PluginValidateResult, REPL_SIGINT, RoutingError, type UpdateCheckConfig, ValidationError, type WrapConfig, type WrapResult, asyncSchema, asyncStream, buildReplCompleter, colorThemes, createPadrone };
1037
+ export { ActionError, type AnsiStyle, type AnyPadroneBuilder, type AnyPadroneCommand, type AnyPadroneProgram, type AsyncPadroneSchema, type AsyncStreamMeta, type ColorConfig, type ColorTheme, type CommandTypesBase, ConfigError, type DefineCommand, type Drained, type ExtractInterceptorContext, type ExtractInterceptorRequires, type GetArgsMeta, type HelpCommand, type HelpInfo, type InferArgsInput, type InferArgsOutput, type InferCommand, type InferContext, type InferContextProvided, type InferInterceptorContext, type InferInterceptorRequires, type InkOptions, type InteractiveMode, type InteractivePromptConfig, type InterceptorBaseContext, type InterceptorDefBuilder, type InterceptorErrorContext, type InterceptorErrorResult, type InterceptorExecuteContext, type InterceptorExecuteResult, type InterceptorFactory, type InterceptorMeta, type InterceptorParseContext, type InterceptorParseResult, type InterceptorPhases, type InterceptorShutdownContext, type InterceptorStartContext, type InterceptorValidateContext, type InterceptorValidateResult, type KeyValueOptions, type ListItem, type ListOptions, type OtelSpan, type OtelTracer, type OtelTracerProvider, type OutputContext, type OutputFormat, type PadroneActionContext, type PadroneBarAnimation, type PadroneBarChar, type PadroneBarConfig, type PadroneBuilder, type PadroneCommand, type PadroneCommandResult, type PadroneContextInterceptor, type PadroneDrainResult, PadroneError, type PadroneErrorOptions, type PadroneExtension, type PadroneInterceptor, type PadroneInterceptorFn, type PadroneLogLevel, type PadroneLogger, type PadroneLoggerConfig, type PadroneMcpPreferences, type PadroneOptions, type PadroneOutputIndicator, type PadroneParseResult, type PadroneProgram, type PadroneProgramMeta, type PadroneProgressConfig, type PadroneProgressDefaults, type PadroneProgressIndicator, type PadroneProgressMessage, type PadroneProgressMessages, type PadroneProgressOptions, type PadroneProgressRenderer, type PadroneProgressShow, type PadroneProgressUpdate, type PadroneRuntime, type PadroneSchema, type PadroneSignal, type PadroneSpinnerConfig, type PadroneSpinnerPreset, type PadroneTracer, type PadroneTracingConfig, REPL_SIGINT, RoutingError, SignalError, type TableOptions, type TreeNode, type TreeOptions, type UpdateCheckConfig, ValidationError, type VersionCommand, type WithCompletion, type WithHelp, type WithLogger, type WithMan, type WithMcp, type WithProgress, type WithRepl, type WithServe, type WithTracing, type WithVersion, type WrapConfig, type WrapResult, asyncSchema, asyncStream, buildReplCompleter, colorThemes, createPadrone, createTerminalProgress, defineCommand, defineInterceptor, isReactElement, padroneAutoOutput, padroneColor, padroneCompletion, padroneConfig, padroneEnv, padroneHelp, padroneInk, padroneInteractive, padroneLogger, padroneMan, padroneMcp, padroneProgress, padroneRepl, padroneServe, padroneSignalHandling, padroneStdin, padroneSuggestions, padroneTiming, padroneTracing, padroneUpdateCheck, padroneVersion };
205
1038
  //# sourceMappingURL=index.d.mts.map