padrone 1.5.0 → 1.6.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 (138) hide show
  1. package/CHANGELOG.md +36 -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-CL63UOzt.mjs} +26 -3
  16. package/dist/errors-CL63UOzt.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-B5Kk83of.mjs} +151 -37
  20. package/dist/help-B5Kk83of.mjs.map +1 -0
  21. package/dist/{types-Ch8Mk6Qb.d.mts → index-BaU3X6dY.d.mts} +621 -750
  22. package/dist/index-BaU3X6dY.d.mts.map +1 -0
  23. package/dist/index.d.mts +735 -37
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +3409 -1563
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{mcp-mLWIdUIu.mjs → mcp-BM-d0nZi.mjs} +13 -15
  28. package/dist/mcp-BM-d0nZi.mjs.map +1 -0
  29. package/dist/{serve-B0u43DK7.mjs → serve-Bk0JUlCj.mjs} +12 -14
  30. package/dist/serve-Bk0JUlCj.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 +268 -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 +95 -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 +43 -0
  72. package/src/extension/ink.ts +93 -0
  73. package/src/extension/interactive.ts +106 -0
  74. package/src/extension/logger.ts +214 -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 +111 -30
  98. package/src/{formatter.ts → output/formatter.ts} +131 -31
  99. package/src/{help.ts → output/help.ts} +22 -8
  100. package/src/{zod.d.ts → schema/zod.d.ts} +1 -1
  101. package/src/schema/zod.ts +50 -0
  102. package/src/test.ts +2 -276
  103. package/src/types/args-meta.ts +151 -0
  104. package/src/types/builder.ts +697 -0
  105. package/src/types/command.ts +157 -0
  106. package/src/types/index.ts +59 -0
  107. package/src/types/interceptor.ts +296 -0
  108. package/src/types/preferences.ts +83 -0
  109. package/src/types/result.ts +71 -0
  110. package/src/types/schema.ts +19 -0
  111. package/src/util/dotenv.ts +244 -0
  112. package/src/{shell-utils.ts → util/shell-utils.ts} +26 -9
  113. package/src/{stream.ts → util/stream.ts} +27 -1
  114. package/src/{type-helpers.ts → util/type-helpers.ts} +23 -16
  115. package/src/{type-utils.ts → util/type-utils.ts} +71 -33
  116. package/src/util/utils.ts +51 -0
  117. package/src/zod.ts +1 -50
  118. package/dist/args-D5PNDyNu.mjs.map +0 -1
  119. package/dist/chunk-CjcI7cDX.mjs +0 -15
  120. package/dist/command-utils-B1D-HqCd.mjs +0 -1117
  121. package/dist/command-utils-B1D-HqCd.mjs.map +0 -1
  122. package/dist/completion.d.mts +0 -64
  123. package/dist/completion.d.mts.map +0 -1
  124. package/dist/completion.mjs.map +0 -1
  125. package/dist/errors-BiVrBgi6.mjs.map +0 -1
  126. package/dist/formatter-DtHzbP22.d.mts.map +0 -1
  127. package/dist/help-bbmu9-qd.mjs.map +0 -1
  128. package/dist/mcp-mLWIdUIu.mjs.map +0 -1
  129. package/dist/serve-B0u43DK7.mjs.map +0 -1
  130. package/dist/stream-BcC146Ud.mjs.map +0 -1
  131. package/dist/types-Ch8Mk6Qb.d.mts.map +0 -1
  132. package/dist/update-check-CFX1FV3v.mjs.map +0 -1
  133. package/src/command-utils.ts +0 -882
  134. package/src/create.ts +0 -1829
  135. package/src/runtime.ts +0 -497
  136. package/src/types.ts +0 -1291
  137. package/src/utils.ts +0 -140
  138. /package/src/{colorizer.ts → output/colorizer.ts} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,31 +1,9 @@
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 PadroneProgressOptions, A as InterceptorStartContext, B as WithInterceptor, C as InterceptorExecuteResult, D as InterceptorParseResult, E as InterceptorParseContext, F as PadroneInterceptorFn, G as PadroneServePreferences, H as PadroneSchema, I as Drained, J as InteractivePromptConfig, K as PadroneMcpPreferences, L as PickCommandByName, M as InterceptorValidateResult, N as PadroneContextInterceptor, O as InterceptorPhases, P as PadroneInterceptor, Q as PadroneProgressIndicator, R as PossibleCommands, S as InterceptorExecuteContext, T as InterceptorMeta, U as WrapConfig, V as AsyncPadroneSchema, W as WrapResult, X as PadroneBarChar, Y as PadroneBarAnimation, Z as PadroneBarConfig, _ as ExtractInterceptorRequires, a as PadroneProgram, at as PadroneSpinnerPreset, b as InterceptorErrorContext, c as PadroneParseResult, d as CommandTypesBase, et as PadroneProgressShow, f as GetArgsMeta, g as ExtractInterceptorContext, h as PadroneProgramMeta, i as PadroneExtension, it as PadroneSpinnerConfig, j as InterceptorValidateContext, k as InterceptorShutdownContext, l as PadroneReplPreferences, m as PadroneCommand, n as AnyPadroneProgram, nt as PadroneRuntime, o as PadroneCommandResult, ot as REPL_SIGINT, p as PadroneActionContext, q as InteractiveMode, r as PadroneBuilder, rt as PadroneSignal, s as PadroneDrainResult, t as AnyPadroneBuilder, tt as PadroneProgressUpdate, u as AnyPadroneCommand, v as InterceptorBaseContext, w as InterceptorFactory, x as InterceptorErrorResult, y as InterceptorDefBuilder, z as WithCommand } from "./index-BaU3X6dY.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
- /**
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.
10
- *
11
- * @example
12
- * ```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));
21
- *
22
- * // parse() now returns Promise<PadroneParseResult>
23
- * const result = await program.parse('greet --name world');
24
- * ```
25
- */
26
- declare function asyncSchema<T extends PadroneSchema>(schema: T): T & {
27
- '~async': true;
28
- };
6
+ //#region src/core/commands.d.ts
29
7
  /**
30
8
  * Builds a completer function for the REPL from the command tree.
31
9
  * Completes command names, subcommand names, option names (--foo), and aliases (-f).
@@ -35,18 +13,83 @@ declare function buildReplCompleter(rootCommand: AnyPadroneCommand, builtins: {
35
13
  inScope?: boolean;
36
14
  }): (line: string) => [string[], string];
37
15
  //#endregion
38
- //#region src/create.d.ts
39
- declare function createPadrone<TProgramName extends string>(name: TProgramName): PadroneProgram<TProgramName, '', ''>;
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
31
+ *
32
+ * Usage:
33
+ * ```ts
34
+ * createPadrone('my-cli').extend(padroneHelp())
35
+ * ```
36
+ */
37
+ declare function padroneHelp(): <T extends CommandTypesBase>(builder: T) => WithHelp<T>;
40
38
  //#endregion
41
- //#region src/errors.d.ts
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
42
  /**
43
- * Structured error hierarchy for Padrone CLI framework.
43
+ * Extension that adds version support:
44
+ * - `version` command
45
+ * - `--version` / `-v` / `-V` flags (root command only)
44
46
  *
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.
47
+ * Usage:
48
+ * ```ts
49
+ * createPadrone('my-cli').extend(padroneVersion())
50
+ * ```
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
+ */
60
+ declare function asyncSchema<T extends PadroneSchema>(schema: T): T & {
61
+ '~async': true;
62
+ };
63
+ //#endregion
64
+ //#region src/core/create.d.ts
65
+ /**
66
+ * Options for configuring which built-in extensions are applied by default.
49
67
  */
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>>;
91
+ //#endregion
92
+ //#region src/core/errors.d.ts
50
93
  type PadroneErrorOptions = {
51
94
  /** Process exit code. Defaults to 1. */exitCode?: number; /** Actionable suggestions shown to the user (e.g. "Use --env production"). */
52
95
  suggestions?: string[]; /** The command path that produced the error (e.g. "deploy staging"). */
@@ -138,8 +181,629 @@ declare class ConfigError extends PadroneError {
138
181
  declare class ActionError extends PadroneError {
139
182
  constructor(message: string, options?: PadroneErrorOptions);
140
183
  }
184
+ /**
185
+ * Thrown when command execution is interrupted by a process signal (SIGINT, SIGTERM, SIGHUP).
186
+ * Carries the signal name and the conventional exit code (128 + signal number).
187
+ */
188
+ declare class SignalError extends PadroneError {
189
+ readonly signal: PadroneSignal;
190
+ constructor(signal: PadroneSignal, options?: {
191
+ cause?: unknown;
192
+ });
193
+ }
194
+ //#endregion
195
+ //#region src/core/interceptors.d.ts
196
+ /**
197
+ * Creates a self-contained interceptor value by attaching static metadata to the factory function.
198
+ * The returned value can be passed directly to `.intercept()` or exported from a package.
199
+ *
200
+ * Two-arg form — define metadata and factory in one call:
201
+ * ```ts
202
+ * export const myInterceptor = defineInterceptor(
203
+ * { name: 'my-interceptor', order: 10 },
204
+ * () => ({
205
+ * execute(ctx, next) { return next(); },
206
+ * }),
207
+ * );
208
+ * ```
209
+ *
210
+ * Single-arg form — chain `.requires<T>()` for typed context, then `.factory()`:
211
+ * ```ts
212
+ * export const myInterceptor = defineInterceptor({ name: 'with-db' })
213
+ * .requires<{ db: DB }>()
214
+ * .factory(() => ({
215
+ * execute(ctx, next) {
216
+ * ctx.context.db; // typed!
217
+ * return next();
218
+ * },
219
+ * }));
220
+ * ```
221
+ */
222
+ declare function defineInterceptor<TArgs = unknown, TResult = unknown>(meta: InterceptorMeta, factory: InterceptorFactory<TArgs, TResult>): PadroneInterceptorFn<TArgs, TResult>;
223
+ declare function defineInterceptor(meta: InterceptorMeta): InterceptorDefBuilder;
224
+ //#endregion
225
+ //#region src/extension/auto-output.d.ts
226
+ /**
227
+ * Extension that automatically writes a command's return value to output after execution.
228
+ *
229
+ * - Values are passed directly to the runtime's `output` function (no stringification).
230
+ * - Promises are awaited before output.
231
+ * - Iterators and async iterators are consumed, outputting each yielded value as it arrives.
232
+ * The result is replaced with the collected array so `drain()` still works.
233
+ * - `undefined` and `null` results produce no output.
234
+ *
235
+ * Included in the default extensions. Can also be applied per-command:
236
+ * ```ts
237
+ * createPadrone('my-cli')
238
+ * .command('greet', (c) =>
239
+ * c.extend(padroneAutoOutput())
240
+ * .action(() => 'hello')
241
+ * )
242
+ * ```
243
+ */
244
+ declare function padroneAutoOutput(options?: {
245
+ disabled?: boolean;
246
+ }): <T extends CommandTypesBase>(builder: T) => T;
247
+ //#endregion
248
+ //#region src/extension/color.d.ts
249
+ /**
250
+ * Extension that handles `--color` / `--no-color` flags:
251
+ * - `--color` or `--color=true` → use default theme
252
+ * - `--color=false` or `--no-color` → disable colors (text format)
253
+ * - `--color=<theme>` → use the named theme
254
+ *
255
+ * Modifies the runtime's format and theme accordingly.
256
+ *
257
+ * Usage:
258
+ * ```ts
259
+ * createPadrone('my-cli').extend(padroneColor())
260
+ * ```
261
+ */
262
+ declare function padroneColor(): <T extends CommandTypesBase>(builder: T) => T;
263
+ //#endregion
264
+ //#region src/extension/completion.d.ts
265
+ type CompletionArgs = {
266
+ shell?: string;
267
+ setup?: boolean;
268
+ };
269
+ type CompletionCommand = PadroneCommand<'completion', '', PadroneSchema<CompletionArgs>, string, [], [], true>;
270
+ type WithCompletion<T> = WithCommand<T, 'completion', CompletionCommand>;
271
+ /**
272
+ * Extension that adds the `completion` command for shell completion script generation.
273
+ *
274
+ * Usage:
275
+ * ```ts
276
+ * createPadrone('my-cli').extend(padroneCompletion())
277
+ * ```
278
+ */
279
+ declare function padroneCompletion(): <T extends CommandTypesBase>(builder: T) => WithCompletion<T>;
280
+ //#endregion
281
+ //#region src/extension/config.d.ts
282
+ type PadroneConfigOptions = {
283
+ /** 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. */
284
+ schema?: StandardSchemaV1; /** Disable this extension. */
285
+ disabled?: boolean; /** Whether to add `--config` / `-c` flag support. Defaults to `true`. */
286
+ flag?: boolean; /** Whether subcommands inherit this interceptor. Defaults to `true`. */
287
+ inherit?: boolean;
288
+ /**
289
+ * Search for config files in the user's platform-specific config directory.
290
+ * - `true` — use the program name as the subdirectory (e.g. program `'myapp'` → `~/.config/myapp/`).
291
+ * - `string` — use a custom app name as the subdirectory.
292
+ * - `false` — disable (default).
293
+ *
294
+ * Directories searched (after cwd):
295
+ * - **Linux**: `$XDG_CONFIG_HOME/<app>` or `~/.config/<app>`
296
+ * - **macOS**: `~/Library/Application Support/<app>` (or `$XDG_CONFIG_HOME/<app>` when set)
297
+ * - **Windows**: `%APPDATA%\<app>`
298
+ *
299
+ * Config files found in cwd always take precedence over XDG paths.
300
+ */
301
+ xdg?: string | boolean;
302
+ /**
303
+ * Custom config loader. When provided, replaces the built-in file system loader.
304
+ * Useful for testing or non-CLI environments.
305
+ */
306
+ loadConfig?: (files: string | string[], xdgAppName?: string) => Record<string, unknown> | undefined | Promise<Record<string, unknown> | undefined>;
307
+ };
308
+ /**
309
+ * Extension that handles config file loading, validation, and merging into command arguments.
310
+ *
311
+ * Features:
312
+ * - `--config` / `-c` flag for explicit config file path (can be disabled via `flag: false`)
313
+ * - Auto-detection of config files from a list of candidate names
314
+ * - Optional schema validation and transformation of config data
315
+ * - Directly accesses the file system (gracefully no-ops in non-CLI environments)
316
+ *
317
+ * Config values have the lowest precedence (CLI > stdin > env > config).
318
+ *
319
+ * Not included in the default built-in extensions — must be explicitly added:
320
+ * ```ts
321
+ * createPadrone('my-cli')
322
+ * .extend(padroneConfig({
323
+ * files: ['config.json', '.myapprc'],
324
+ * schema: z.object({ port: z.number(), host: z.string() }),
325
+ * }))
326
+ * ```
327
+ */
328
+ declare function padroneConfig(options?: PadroneConfigOptions): <T extends CommandTypesBase>(builder: T) => T;
329
+ //#endregion
330
+ //#region src/extension/env.d.ts
331
+ type PadroneEnvOptions = {
332
+ /** 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 */
333
+ local?: boolean; /** Directory to search for `.env` files. @default process.cwd() */
334
+ dir?: string; /** When `true`, file values override `process.env` values. @default false */
335
+ override?: boolean; /** When `false`, the base `.env` (and `.env.local`) files are not loaded. @default true */
336
+ base?: boolean;
337
+ };
338
+ /**
339
+ * Extension that reads environment variables, validates them against a schema,
340
+ * and merges the transformed values into command arguments.
341
+ *
342
+ * Supports loading `.env` files with mode-based overrides and variable expansion.
343
+ *
344
+ * ```ts
345
+ * // Schema only (reads process.env)
346
+ * .extend(padroneEnv(
347
+ * z.object({ PORT: z.string() }).transform(e => ({ port: Number(e.PORT) }))
348
+ * ))
349
+ *
350
+ * // Schema + .env file loading
351
+ * .extend(padroneEnv(
352
+ * z.object({ PORT: z.string() }).transform(e => ({ port: Number(e.PORT) })),
353
+ * { modes: ['production'] }
354
+ * ))
355
+ *
356
+ * // .env file loading only (no schema validation)
357
+ * .extend(padroneEnv({ modes: ['production'] }))
358
+ * ```
359
+ *
360
+ * Env values have lower precedence than CLI args and stdin, but higher than config files.
361
+ */
362
+ declare function padroneEnv(schema: StandardSchemaV1): <T extends CommandTypesBase>(builder: T) => T;
363
+ declare function padroneEnv(schema: StandardSchemaV1, options: PadroneEnvOptions): <T extends CommandTypesBase>(builder: T) => T;
364
+ declare function padroneEnv(options: PadroneEnvOptions): <T extends CommandTypesBase>(builder: T) => T;
365
+ //#endregion
366
+ //#region src/extension/ink.d.ts
367
+ /** Checks whether a value is a React element (JSX) by inspecting its `$$typeof` symbol. */
368
+ declare function isReactElement(value: unknown): boolean;
369
+ type InkOptions = {
370
+ /** Whether to wait for the Ink app to unmount before resolving. Defaults to `true`. */waitUntilExit?: boolean; /** Options forwarded to Ink's `render()`. */
371
+ render?: _$ink.RenderOptions;
372
+ };
373
+ /**
374
+ * Extension that renders React (Ink) components returned from command actions.
375
+ *
376
+ * When a command's action returns a React element (JSX), this extension
377
+ * renders it using Ink instead of passing it to the normal output path.
378
+ *
379
+ * Requires `ink` and `react` as peer dependencies.
380
+ *
381
+ * ```ts
382
+ * import { createPadrone, padroneInk } from 'padrone';
383
+ *
384
+ * const program = createPadrone('my-tui')
385
+ * .extend(padroneInk())
386
+ * .command('dashboard', (c) =>
387
+ * c.action(() => <Dashboard />)
388
+ * );
389
+ * ```
390
+ */
391
+ declare function padroneInk(options?: InkOptions): <T extends CommandTypesBase>(builder: T) => T;
392
+ //#endregion
393
+ //#region src/extension/interactive.d.ts
394
+ /**
395
+ * Extension that handles interactive prompting for missing arguments.
396
+ * Extracts `--interactive` / `-i` flags, resolves effective interactivity,
397
+ * and prompts for missing fields before passing filled args to validation.
398
+ *
399
+ * Usage:
400
+ * ```ts
401
+ * createPadrone('my-cli').extend(padroneInteractive())
402
+ * ```
403
+ */
404
+ declare function padroneInteractive(): <T extends CommandTypesBase>(builder: T) => T;
405
+ //#endregion
406
+ //#region src/extension/logger.d.ts
407
+ /** Log level values ordered by severity. */
408
+ type PadroneLogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
409
+ /** Logger instance injected into the command context. */
410
+ type PadroneLogger = {
411
+ trace: (...args: unknown[]) => void;
412
+ debug: (...args: unknown[]) => void;
413
+ info: (...args: unknown[]) => void;
414
+ warn: (...args: unknown[]) => void;
415
+ error: (...args: unknown[]) => void; /** The current effective log level. */
416
+ level: PadroneLogLevel; /** Create a child logger with a prefix label. */
417
+ child: (label: string) => PadroneLogger;
418
+ };
419
+ /** Configuration for the logger extension. */
420
+ type PadroneLoggerConfig = {
421
+ /** Minimum log level to output. Defaults to `'info'`. */level?: PadroneLogLevel; /** Prefix prepended to every log message. */
422
+ prefix?: string; /** Include timestamps in log output. Defaults to `false`. */
423
+ timestamps?: boolean;
424
+ };
425
+ /** Builder/program type after applying `padroneLogger()`. Adds `{ logger: PadroneLogger }` to the command context. */
426
+ type WithLogger<T> = WithInterceptor<T, {
427
+ logger: PadroneLogger;
428
+ }>;
429
+ /**
430
+ * Extension that injects a structured logger into the command context.
431
+ *
432
+ * The logger respects a configurable log level threshold, supports prefixed
433
+ * child loggers, and routes output through the runtime's `output`/`error`
434
+ * functions so it works in any environment (terminal, test, web).
435
+ *
436
+ * Supports CLI flags for runtime level overrides:
437
+ * - `--trace` → sets level to `trace`
438
+ * - `--verbose` or `--debug` → sets level to `debug`
439
+ * - `--silent` or `--quiet` → sets level to `silent`
440
+ * - `--log-level=<level>` → sets an explicit level (`trace`, `debug`, `info`, `warn`, `error`, `silent`)
441
+ *
442
+ * CLI flags take precedence over the programmatic config.
443
+ *
444
+ * Provides `{ logger: PadroneLogger }` on the command context.
445
+ * Access it in action handlers as `ctx.context.logger`.
446
+ *
447
+ * Usage:
448
+ * ```ts
449
+ * createPadrone('my-cli')
450
+ * .extend(padroneLogger({ level: 'info' }))
451
+ * .command('sync', (c) =>
452
+ * c.action((_args, ctx) => {
453
+ * ctx.context.logger.info('starting sync');
454
+ * const db = ctx.context.logger.child('db');
455
+ * db.debug('connecting...');
456
+ * })
457
+ * )
458
+ * ```
459
+ *
460
+ * Then run:
461
+ * ```sh
462
+ * my-cli sync --verbose # debug level
463
+ * my-cli sync --quiet # silent
464
+ * my-cli sync --log-level=warn
465
+ * ```
466
+ */
467
+ declare function padroneLogger<T extends CommandTypesBase>(config?: PadroneLoggerConfig): (builder: T) => WithLogger<T>;
141
468
  //#endregion
142
- //#region src/stream.d.ts
469
+ //#region src/extension/man.d.ts
470
+ type ManArgs = {
471
+ setup?: boolean;
472
+ remove?: boolean;
473
+ };
474
+ type ManCommand = PadroneCommand<'man', '', PadroneSchema<ManArgs>, string, [], [], true>;
475
+ type WithMan<T> = WithCommand<T, 'man', ManCommand>;
476
+ /**
477
+ * Extension that adds the `man` command for man page generation.
478
+ *
479
+ * Usage:
480
+ * ```ts
481
+ * createPadrone('my-cli').extend(padroneMan())
482
+ * ```
483
+ */
484
+ declare function padroneMan(): <T extends CommandTypesBase>(builder: T) => WithMan<T>;
485
+ //#endregion
486
+ //#region src/extension/mcp.d.ts
487
+ type McpArgs = {
488
+ transport?: string;
489
+ port?: string;
490
+ host?: string;
491
+ basePath?: string;
492
+ };
493
+ type McpCommand = PadroneCommand<'mcp', '', PadroneSchema<McpArgs>, void, [], [], true>;
494
+ type WithMcp<T> = WithCommand<T, 'mcp', McpCommand>;
495
+ /**
496
+ * Extension that adds the `mcp` command for starting a Model Context Protocol server.
497
+ *
498
+ * Usage:
499
+ * ```ts
500
+ * createPadrone('my-cli').extend(padroneMcp())
501
+ * ```
502
+ */
503
+ declare function padroneMcp(defaults?: PadroneMcpPreferences): <T extends CommandTypesBase>(builder: T) => WithMcp<T>;
504
+ //#endregion
505
+ //#region src/extension/progress-renderer.d.ts
506
+ /** Factory function that creates a `PadroneProgressIndicator`. */
507
+ type PadroneProgressRenderer = (message: string, options?: PadroneProgressOptions) => PadroneProgressIndicator;
508
+ /**
509
+ * Creates a terminal progress indicator (spinner, bar, or both).
510
+ * Returns a no-op indicator in non-TTY/CI environments.
511
+ */
512
+ declare function createTerminalProgress(message: string, options?: PadroneProgressOptions): PadroneProgressIndicator;
513
+ //#endregion
514
+ //#region src/extension/progress.d.ts
515
+ /** A progress message value: a plain string, `null` to suppress, or an object with a message and custom indicator icon. */
516
+ type PadroneProgressMessage = string | null | {
517
+ message?: string | null;
518
+ indicator?: string;
519
+ };
520
+ /** Per-phase message configuration for progress indicators. */
521
+ type PadroneProgressMessages<TRes = unknown> = {
522
+ /** Message shown during async validation. Defaults to `''` (spinner only). */validation?: string; /** Message shown while the command's action is running. */
523
+ progress?: string; /** Message shown when the command succeeds. `null` to suppress. Defaults to the `progress` message. */
524
+ success?: PadroneProgressMessage | ((result: TRes) => PadroneProgressMessage); /** Message shown when the command fails. `null` to suppress. Defaults to the error message. */
525
+ error?: PadroneProgressMessage | ((error: unknown) => PadroneProgressMessage);
526
+ };
527
+ /**
528
+ * Progress indicator configuration with messages, visual options, and renderer.
529
+ */
530
+ type PadroneProgressConfig<TRes = unknown> = {
531
+ /** 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). */
532
+ 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'`. */
533
+ bar?: boolean | PadroneBarConfig; /** Show elapsed time since the indicator started. Can also be started on demand via `update({ time: true })`. */
534
+ time?: boolean; /** Show estimated time remaining based on progress rate. Requires numeric `update()` calls. */
535
+ eta?: boolean;
536
+ /**
537
+ * Custom renderer factory. Called to create the progress indicator.
538
+ * Defaults to the built-in terminal renderer (`createTerminalProgress`).
539
+ */
540
+ renderer?: PadroneProgressRenderer;
541
+ };
542
+ /**
543
+ * Shared progress defaults that can be provided via context instead of repeating
544
+ * at each call site. Per-instance message fields are excluded — those always come
545
+ * from the constructor argument.
546
+ *
547
+ * Provide via context as `{ progressConfig: PadroneProgressDefaults }`.
548
+ */
549
+ type PadroneProgressDefaults = Pick<PadroneProgressConfig, 'message' | 'spinner' | 'bar' | 'time' | 'eta' | 'renderer'>;
550
+ /** Builder/program type after applying `padroneProgress()`. Adds `{ progress: PadroneProgressIndicator }` to the command context. */
551
+ type WithProgress<T> = WithInterceptor<T, {
552
+ progress: PadroneProgressIndicator;
553
+ }>;
554
+ /**
555
+ * Extension that adds an auto-managed progress indicator to the command pipeline.
556
+ *
557
+ * - `string` — a single message used for all states.
558
+ * - `PadroneProgressConfig` — separate messages for validation, progress, success, and error.
559
+ *
560
+ * The indicator is automatically started before validation, updated at each phase transition,
561
+ * and stopped on success (`.succeed()`) or failure (`.fail()`).
562
+ *
563
+ * Provides `{ progress: PadroneProgressIndicator }` on the command context.
564
+ * Access it in action handlers as `ctx.context.progress`.
565
+ *
566
+ * Uses the built-in terminal renderer by default. Pass a custom `renderer` for non-terminal
567
+ * environments (web UIs, testing, etc).
568
+ *
569
+ * Usage:
570
+ * ```ts
571
+ * createPadrone('my-cli')
572
+ * .command('sync', (c) =>
573
+ * c.extend(padroneProgress('Syncing...'))
574
+ * .action((_args, ctx) => {
575
+ * ctx.context.progress.update('halfway');
576
+ * })
577
+ * )
578
+ * ```
579
+ */
580
+ declare function padroneProgress<T extends CommandTypesBase>(config?: string | PadroneProgressConfig): (builder: T) => WithProgress<T>;
581
+ //#endregion
582
+ //#region src/extension/repl.d.ts
583
+ type ReplArgs = {
584
+ scope?: string;
585
+ };
586
+ type ReplCommand = PadroneCommand<'repl', '', PadroneSchema<ReplArgs>, void, [], [], true>;
587
+ type WithRepl<T> = WithCommand<T, 'repl', ReplCommand>;
588
+ /**
589
+ * Extension that adds REPL support:
590
+ * - `repl` command that starts an interactive REPL
591
+ * - `--repl` flag that starts the REPL from any invocation
592
+ *
593
+ * Usage:
594
+ * ```ts
595
+ * createPadrone('my-cli').extend(padroneRepl())
596
+ * ```
597
+ */
598
+ declare function padroneRepl(defaults?: PadroneReplPreferences & {
599
+ disabled?: boolean;
600
+ }): <T extends CommandTypesBase>(builder: T) => WithRepl<T>;
601
+ //#endregion
602
+ //#region src/extension/serve.d.ts
603
+ type ServeArgs = {
604
+ port?: string;
605
+ host?: string;
606
+ basePath?: string;
607
+ };
608
+ type ServeCommand = PadroneCommand<'serve', '', PadroneSchema<ServeArgs>, void, [], [], true>;
609
+ type WithServe<T> = WithCommand<T, 'serve', ServeCommand>;
610
+ /**
611
+ * Extension that adds the `serve` command for starting a REST HTTP server.
612
+ *
613
+ * Usage:
614
+ * ```ts
615
+ * createPadrone('my-cli').extend(padroneServe())
616
+ * ```
617
+ */
618
+ declare function padroneServe(defaults?: PadroneServePreferences): <T extends CommandTypesBase>(builder: T) => WithServe<T>;
619
+ //#endregion
620
+ //#region src/extension/signal.d.ts
621
+ /**
622
+ * Extension that wires process signal handling (SIGINT, SIGTERM, SIGHUP) into the interceptor lifecycle.
623
+ *
624
+ * - Creates an `AbortController` whose signal is propagated to all downstream phases.
625
+ * - Subscribes to `runtime.onSignal` to forward OS signals to the abort controller.
626
+ * - Implements SIGINT double-tap: two SIGINTs within 2 seconds force-exits the process.
627
+ * - Attaches `signal` and `exitCode` to results and errors when interrupted.
628
+ * - Cleans up the signal subscription on completion or failure.
629
+ *
630
+ * Included in the default extensions. Runs at order `-2000` (outermost).
631
+ */
632
+ declare function padroneSignalHandling(options?: {
633
+ disabled?: boolean;
634
+ }): <T extends CommandTypesBase>(builder: T) => T;
635
+ //#endregion
636
+ //#region src/extension/stdin.d.ts
637
+ /**
638
+ * Extension that reads stdin data into the argument field specified by `meta.stdin`.
639
+ * Included by default via `createPadrone()`.
640
+ *
641
+ * Read mode is inferred from the schema type:
642
+ * - `string` field → reads all stdin as a single string
643
+ * - `string[]` field → reads stdin line-by-line into an array
644
+ * - `AsyncIterable` field → returns a stream for line-by-line async consumption
645
+ *
646
+ * Stdin is only read when piped (not a TTY) and the field wasn't already provided via CLI flags.
647
+ */
648
+ declare function padroneStdin(options?: {
649
+ disabled?: boolean;
650
+ }): <T extends CommandTypesBase>(builder: T) => T;
651
+ //#endregion
652
+ //#region src/extension/suggestions.d.ts
653
+ declare function padroneSuggestions(): <T extends CommandTypesBase>(builder: T) => T;
654
+ //#endregion
655
+ //#region src/extension/timing.d.ts
656
+ interface PadroneTimingOptions {
657
+ /** Enable timing by default without requiring `--time` flag. Default: `false`. */
658
+ enabled?: boolean;
659
+ }
660
+ /**
661
+ * Extension that tracks command execution time.
662
+ *
663
+ * - `--time` / `--timing` → enables timing output
664
+ * - `--no-time` / `--no-timing` → disables timing output
665
+ *
666
+ * Pass `{ enabled: true }` to enable timing by default (can be disabled via `--no-time`).
667
+ *
668
+ * Usage:
669
+ * ```ts
670
+ * // Opt-in via flag
671
+ * createPadrone('my-cli').extend(padroneTiming())
672
+ *
673
+ * // Always on, opt-out via --no-time
674
+ * createPadrone('my-cli').extend(padroneTiming({ enabled: true }))
675
+ * ```
676
+ */
677
+ declare function padroneTiming(options?: PadroneTimingOptions): <T extends CommandTypesBase>(builder: T) => T;
678
+ //#endregion
679
+ //#region src/extension/tracing.d.ts
680
+ /** Minimal subset of OTEL `SpanStatusCode`. */
681
+ type SpanStatusCode = 0 | 1 | 2;
682
+ /** Minimal subset of OTEL `SpanStatus`. */
683
+ type SpanStatus = {
684
+ code: SpanStatusCode;
685
+ message?: string;
686
+ };
687
+ /** Minimal subset of OTEL `Span`. */
688
+ interface OtelSpan {
689
+ setAttribute(key: string, value: string | number | boolean): this;
690
+ addEvent(name: string, attributes?: Record<string, string | number | boolean>): this;
691
+ setStatus(status: SpanStatus): this;
692
+ recordException(error: unknown): this;
693
+ end(): void;
694
+ spanContext(): {
695
+ traceId: string;
696
+ spanId: string;
697
+ };
698
+ }
699
+ /** Minimal subset of OTEL `Tracer`. */
700
+ interface OtelTracer {
701
+ startSpan(name: string): OtelSpan;
702
+ }
703
+ /** Minimal subset of OTEL `TracerProvider`. */
704
+ interface OtelTracerProvider {
705
+ getTracer(name: string, version?: string): OtelTracer;
706
+ }
707
+ /** Tracing handle injected into the command context. */
708
+ type PadroneTracer = {
709
+ /** The underlying OTEL tracer. */tracer: OtelTracer; /** Root span covering the full command execution. */
710
+ rootSpan: OtelSpan; /** Run `fn` inside a child span that is automatically ended when `fn` returns (or rejects). */
711
+ span: <T>(name: string, fn: (span: OtelSpan) => T) => T;
712
+ };
713
+ /** Configuration for the tracing extension. */
714
+ type PadroneTracingConfig = {
715
+ /** OTEL `TracerProvider`. Required — there is no global fallback. */provider: OtelTracerProvider; /** Service / tracer name. Defaults to the CLI program name. */
716
+ serviceName?: string;
717
+ };
718
+ /** Builder/program type after applying `padroneTracing()`. Adds `{ tracing: PadroneTracer }` to the command context. */
719
+ type WithTracing<T> = WithInterceptor<T, {
720
+ tracing: PadroneTracer;
721
+ }>;
722
+ /**
723
+ * Extension that adds OpenTelemetry tracing to command execution.
724
+ *
725
+ * Creates a root span for each command invocation and provides a `PadroneTracer`
726
+ * on the command context for creating child spans in action handlers.
727
+ *
728
+ * When used with `padroneLogger()`, the logger automatically emits span events
729
+ * for each log call — no extra configuration needed. The logger detects the
730
+ * tracing context and bridges log output to span events.
731
+ *
732
+ * Uses minimal OTEL-compatible interfaces — pass any `TracerProvider` that
733
+ * implements `getTracer()`. Works with `@opentelemetry/api` or compatible
734
+ * libraries.
735
+ *
736
+ * Provides `{ tracing: PadroneTracer }` on the command context.
737
+ * Access it in action handlers as `ctx.context.tracing`.
738
+ *
739
+ * Usage:
740
+ * ```ts
741
+ * import { trace } from '@opentelemetry/api';
742
+ *
743
+ * createPadrone('my-cli')
744
+ * .extend(padroneTracing({ provider: trace.getTracerProvider() }))
745
+ * .extend(padroneLogger())
746
+ * .command('deploy', (c) =>
747
+ * c.action((_args, ctx) => {
748
+ * ctx.context.logger.info('deploying'); // also emits a span event
749
+ * ctx.context.tracing.span('build', (span) => {
750
+ * span.setAttribute('target', 'production');
751
+ * });
752
+ * })
753
+ * )
754
+ * ```
755
+ */
756
+ declare function padroneTracing<T extends CommandTypesBase>(config: PadroneTracingConfig): (builder: T) => WithTracing<T>;
757
+ //#endregion
758
+ //#region src/feature/update-check.d.ts
759
+ /**
760
+ * Configuration for the update check feature.
761
+ */
762
+ type UpdateCheckConfig = {
763
+ /**
764
+ * The npm package name to check. Defaults to the program name.
765
+ */
766
+ packageName?: string;
767
+ /**
768
+ * Registry to check for updates.
769
+ * - `'npm'` — checks the npm registry (default)
770
+ * - A URL string — custom registry endpoint that returns JSON with a `version` or `dist-tags.latest` field
771
+ */
772
+ registry?: 'npm' | string;
773
+ /**
774
+ * How often to check for updates. Accepts shorthand like `'1d'`, `'12h'`, `'30m'`.
775
+ * Defaults to `'1d'` (once per day).
776
+ */
777
+ interval?: string;
778
+ /**
779
+ * Path to the cache file for storing the last check timestamp and latest version.
780
+ * Defaults to `~/.config/<programName>-update-check.json`.
781
+ */
782
+ cache?: string;
783
+ /**
784
+ * Environment variable name to disable update checks (e.g. `'MYAPP_NO_UPDATE_CHECK'`).
785
+ * When set to a truthy value, update checks are skipped.
786
+ * Defaults to `'<PROGRAM_NAME>_NO_UPDATE_CHECK'` (uppercased, hyphens to underscores).
787
+ */
788
+ disableEnvVar?: string;
789
+ };
790
+ //#endregion
791
+ //#region src/extension/update-check.d.ts
792
+ /**
793
+ * Extension that adds background update checking:
794
+ * - Checks for newer versions on npm (or custom registry) in the background
795
+ * - Shows an update notification after command execution
796
+ * - Respects `--no-update-check` flag to suppress
797
+ *
798
+ * Usage:
799
+ * ```ts
800
+ * createPadrone('my-cli')
801
+ * .extend(padroneUpdateCheck({ packageName: 'my-cli' }))
802
+ * ```
803
+ */
804
+ declare function padroneUpdateCheck(config?: UpdateCheckConfig): <T extends CommandTypesBase>(builder: T) => T;
805
+ //#endregion
806
+ //#region src/util/stream.d.ts
143
807
  interface AsyncStreamMeta {
144
808
  [x: string]: unknown;
145
809
  readonly asyncStream: number;
@@ -167,7 +831,7 @@ interface AsyncStreamMeta {
167
831
  */
168
832
  declare function asyncStream<T = string>(itemSchema?: PadroneSchema<T>): AsyncStreamMeta;
169
833
  //#endregion
170
- //#region src/type-helpers.d.ts
834
+ //#region src/util/type-helpers.d.ts
171
835
  /**
172
836
  * Extracts the input type of the arguments schema from a command.
173
837
  * @example
@@ -184,6 +848,40 @@ type InferArgsInput<T extends AnyPadroneCommand> = T['~types']['argsInput'];
184
848
  * ```
185
849
  */
186
850
  type InferArgsOutput<T extends AnyPadroneCommand> = T['~types']['argsOutput'];
851
+ /**
852
+ * Extracts the user-defined context type from a command (excludes interceptor-provided context).
853
+ * @example
854
+ * ```ts
855
+ * type Ctx = InferContext<typeof myCommand>;
856
+ * ```
857
+ */
858
+ type InferContext<T extends AnyPadroneCommand> = T['~types']['context'];
859
+ /**
860
+ * Extracts the interceptor-provided context type from a command.
861
+ * @example
862
+ * ```ts
863
+ * type Provided = InferContextProvided<typeof myCommand>;
864
+ * ```
865
+ */
866
+ type InferContextProvided<T extends AnyPadroneCommand> = T['~types']['contextProvided'];
867
+ /**
868
+ * Extracts the context type that a context-providing interceptor injects.
869
+ * @example
870
+ * ```ts
871
+ * type AuthCtx = InferInterceptorContext<typeof withAuth>;
872
+ * ```
873
+ */
874
+ type InferInterceptorContext<T extends PadroneContextInterceptor<any>> = T['~context'];
875
+ /**
876
+ * Extracts the required context type from an interceptor with `.requires()`.
877
+ * @example
878
+ * ```ts
879
+ * type Requires = InferInterceptorRequires<typeof withAuth>;
880
+ * ```
881
+ */
882
+ type InferInterceptorRequires<T extends PadroneInterceptorFn & {
883
+ '~contextRequires': any;
884
+ }> = T['~contextRequires'] extends ((ctx: infer R) => void) ? R : unknown;
187
885
  /**
188
886
  * Gets a command type by its path from a program or command tree.
189
887
  * Supports both full paths (e.g., "config set") and alias paths.
@@ -201,5 +899,5 @@ type InferArgsOutput<T extends AnyPadroneCommand> = T['~types']['argsOutput'];
201
899
  */
202
900
  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
901
  //#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 };
902
+ export { ActionError, type AnsiStyle, type AnyPadroneBuilder, type AnyPadroneCommand, type AnyPadroneProgram, type AsyncPadroneSchema, type AsyncStreamMeta, type ColorConfig, type ColorTheme, type CommandTypesBase, ConfigError, 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 OtelSpan, type OtelTracer, type OtelTracerProvider, 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 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 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, defineInterceptor, isReactElement, padroneAutoOutput, padroneColor, padroneCompletion, padroneConfig, padroneEnv, padroneHelp, padroneInk, padroneInteractive, padroneLogger, padroneMan, padroneMcp, padroneProgress, padroneRepl, padroneServe, padroneSignalHandling, padroneStdin, padroneSuggestions, padroneTiming, padroneTracing, padroneUpdateCheck, padroneVersion };
205
903
  //# sourceMappingURL=index.d.mts.map