padrone 1.7.1 → 1.8.1
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.
- package/CHANGELOG.md +26 -0
- package/README.md +3 -2
- package/dist/{args-Cnq0nwSM.mjs → args-DrCXxXeP.mjs} +20 -4
- package/dist/args-DrCXxXeP.mjs.map +1 -0
- package/dist/codegen/index.mjs +1 -1
- package/dist/{commands-B_gufyR9.mjs → commands-DLR0rFgq.mjs} +2 -2
- package/dist/{commands-B_gufyR9.mjs.map → commands-DLR0rFgq.mjs.map} +1 -1
- package/dist/{completion-BEuflbDO.mjs → completion-UnBKfGuk.mjs} +2 -2
- package/dist/{completion-BEuflbDO.mjs.map → completion-UnBKfGuk.mjs.map} +1 -1
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +2 -2
- package/dist/{formatter-DrvhDMrq.d.mts → formatter-CY3KrOEd.d.mts} +3 -2
- package/dist/formatter-CY3KrOEd.d.mts.map +1 -0
- package/dist/{help-BtxLgrF_.mjs → help-B-ZMYyn-.mjs} +16 -6
- package/dist/help-B-ZMYyn-.mjs.map +1 -0
- package/dist/{index-C0Tab27T.d.mts → index-Guyz-CBm.d.mts} +340 -116
- package/dist/index-Guyz-CBm.d.mts.map +1 -0
- package/dist/index.d.mts +17 -160
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +227 -102
- package/dist/index.mjs.map +1 -1
- package/dist/{mcp-6-Jw4Bpq.mjs → mcp-D6PdtjIs.mjs} +4 -4
- package/dist/{mcp-6-Jw4Bpq.mjs.map → mcp-D6PdtjIs.mjs.map} +1 -1
- package/dist/{serve-YVTPzBCl.mjs → serve-PaCLsNoD.mjs} +4 -4
- package/dist/{serve-YVTPzBCl.mjs.map → serve-PaCLsNoD.mjs.map} +1 -1
- package/dist/test.d.mts +1 -1
- package/dist/zod.d.mts +1 -1
- package/package.json +3 -3
- package/src/core/args.ts +24 -1
- package/src/core/create.ts +21 -14
- package/src/core/exec.ts +87 -46
- package/src/core/interceptors.ts +107 -7
- package/src/core/program-methods.ts +12 -2
- package/src/core/validate.ts +26 -7
- package/src/extension/auto-output.ts +1 -1
- package/src/extension/config.ts +2 -1
- package/src/extension/env.ts +5 -4
- package/src/extension/index.ts +1 -0
- package/src/extension/interactive.ts +2 -1
- package/src/extension/logger.ts +1 -1
- package/src/extension/progress-renderer.ts +3 -0
- package/src/extension/progress.ts +37 -3
- package/src/extension/tracing.ts +1 -1
- package/src/index.ts +6 -1
- package/src/output/formatter.ts +6 -1
- package/src/output/help.ts +15 -3
- package/src/types/args-meta.ts +10 -0
- package/src/types/builder.ts +75 -2
- package/src/types/index.ts +3 -0
- package/src/types/interceptor.ts +26 -12
- package/src/util/type-utils.ts +22 -0
- package/dist/args-Cnq0nwSM.mjs.map +0 -1
- package/dist/formatter-DrvhDMrq.d.mts.map +0 -1
- package/dist/help-BtxLgrF_.mjs.map +0 -1
- package/dist/index-C0Tab27T.d.mts.map +0 -1
package/src/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export type {
|
|
|
38
38
|
PadroneTracer,
|
|
39
39
|
PadroneTracingConfig,
|
|
40
40
|
VersionCommand,
|
|
41
|
+
WithAsync,
|
|
41
42
|
WithCompletion,
|
|
42
43
|
WithHelp,
|
|
43
44
|
WithLogger,
|
|
@@ -79,7 +80,7 @@ export type { UpdateCheckConfig } from './feature/update-check.ts';
|
|
|
79
80
|
export type { WrapConfig, WrapResult } from './feature/wrap.ts';
|
|
80
81
|
export type { AnsiStyle, ColorConfig, ColorTheme } from './output/colorizer.ts';
|
|
81
82
|
export { colorThemes } from './output/colorizer.ts';
|
|
82
|
-
export type { HelpInfo } from './output/formatter.ts';
|
|
83
|
+
export type { HelpDetail, HelpFormat, HelpInfo } from './output/formatter.ts';
|
|
83
84
|
export type { PadroneOutputIndicator } from './output/output-indicator.ts';
|
|
84
85
|
export type { KeyValueOptions, ListItem, ListOptions, TableOptions, TreeNode, TreeOptions } from './output/primitives.ts';
|
|
85
86
|
export type { OutputContext, OutputFormat } from './output/styling.ts';
|
|
@@ -90,6 +91,8 @@ export type {
|
|
|
90
91
|
AsyncPadroneSchema,
|
|
91
92
|
CommandTypesBase,
|
|
92
93
|
DefineCommand,
|
|
94
|
+
DefineCommandBuilder,
|
|
95
|
+
DefineCommandContext,
|
|
93
96
|
ExtractInterceptorContext,
|
|
94
97
|
ExtractInterceptorRequires,
|
|
95
98
|
GetArgsMeta,
|
|
@@ -104,6 +107,7 @@ export type {
|
|
|
104
107
|
InterceptorParseContext,
|
|
105
108
|
InterceptorParseResult,
|
|
106
109
|
InterceptorPhases,
|
|
110
|
+
InterceptorRouteContext,
|
|
107
111
|
InterceptorShutdownContext,
|
|
108
112
|
InterceptorStartContext,
|
|
109
113
|
InterceptorValidateContext,
|
|
@@ -121,6 +125,7 @@ export type {
|
|
|
121
125
|
PadroneProgram,
|
|
122
126
|
PadroneProgramMeta,
|
|
123
127
|
PadroneSchema,
|
|
128
|
+
RegisteredInterceptor,
|
|
124
129
|
} from './types/index.ts';
|
|
125
130
|
export type { AsyncStreamMeta } from './util/stream.ts';
|
|
126
131
|
export { asyncStream } from './util/stream.ts';
|
package/src/output/formatter.ts
CHANGED
|
@@ -58,6 +58,8 @@ export type HelpArgumentInfo = {
|
|
|
58
58
|
variadic?: boolean;
|
|
59
59
|
/** Whether this arg is a boolean (shown as --[no-]arg) */
|
|
60
60
|
negatable?: boolean;
|
|
61
|
+
/** Custom negative keyword(s) that set this arg to false (e.g. `['remote']` for `--remote`) */
|
|
62
|
+
negative?: string[];
|
|
61
63
|
/** Config file key that maps to this arg */
|
|
62
64
|
configKey?: string;
|
|
63
65
|
/** Group name for organizing this option under a labeled section in help output */
|
|
@@ -316,7 +318,10 @@ function createGenericFormatter(styler: Styler, layout: LayoutConfig, showAllBui
|
|
|
316
318
|
const remainingAliases = arg.aliases?.filter((a) => a !== primaryName);
|
|
317
319
|
|
|
318
320
|
const flagsPlain = arg.flags?.length ? arg.flags.map((f) => `-${f}`).join(', ') : '';
|
|
319
|
-
const
|
|
321
|
+
const negPlain = arg.negative?.length ? arg.negative.map((n) => `--${n}`).join(', ') : '';
|
|
322
|
+
const namesPlain = [`--${primaryName}`, ...(remainingAliases?.map((a) => `--${a}`) || []), ...(negPlain ? [negPlain] : [])].join(
|
|
323
|
+
', ',
|
|
324
|
+
);
|
|
320
325
|
const typePlain = arg.type && arg.type !== 'boolean' ? (arg.optional ? `[${arg.type}]` : `<${arg.type}>`) : '';
|
|
321
326
|
|
|
322
327
|
const isDeprecated = !!arg.deprecated;
|
package/src/output/help.ts
CHANGED
|
@@ -128,9 +128,20 @@ function extractArgsInfo(schema: StandardJSONSchemaV1, meta?: PadroneArgsSchemaM
|
|
|
128
128
|
const optMeta = argsMeta?.[key];
|
|
129
129
|
const propType = prop.type as string;
|
|
130
130
|
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
const
|
|
131
|
+
// Resolve custom negative keywords from meta or schema
|
|
132
|
+
const rawNegative = optMeta?.negative ?? prop?.negative;
|
|
133
|
+
const hasCustomNegative = rawNegative !== undefined;
|
|
134
|
+
const negativeList = hasCustomNegative
|
|
135
|
+
? typeof rawNegative === 'string'
|
|
136
|
+
? rawNegative
|
|
137
|
+
? [rawNegative]
|
|
138
|
+
: []
|
|
139
|
+
: Array.from(rawNegative as readonly string[]).filter(Boolean)
|
|
140
|
+
: undefined;
|
|
141
|
+
|
|
142
|
+
// Booleans are negatable unless there's an explicit noArg property,
|
|
143
|
+
// this arg is itself a negation of another arg, or custom negative keywords are set
|
|
144
|
+
const isNegatable = propType === 'boolean' && !hasCustomNegative && !hasExplicitNegation(key) && !isNegationOf(key);
|
|
134
145
|
|
|
135
146
|
result.push({
|
|
136
147
|
name: key,
|
|
@@ -144,6 +155,7 @@ function extractArgsInfo(schema: StandardJSONSchemaV1, meta?: PadroneArgsSchemaM
|
|
|
144
155
|
examples: optMeta?.examples ?? prop?.examples,
|
|
145
156
|
variadic: propType === 'array',
|
|
146
157
|
negatable: isNegatable,
|
|
158
|
+
negative: negativeList?.length ? negativeList : undefined,
|
|
147
159
|
group: optMeta?.group,
|
|
148
160
|
});
|
|
149
161
|
}
|
package/src/types/args-meta.ts
CHANGED
|
@@ -35,6 +35,16 @@ export interface PadroneFieldMeta {
|
|
|
35
35
|
flags?: readonly SingleChar[] | SingleChar;
|
|
36
36
|
/** Multi-character alternative long names. Used with double dash (e.g. `--dry-run` for `--dryRun`). */
|
|
37
37
|
alias?: readonly string[] | string;
|
|
38
|
+
/**
|
|
39
|
+
* Custom negative keyword(s) for boolean options. When provided, `--<keyword>` sets this option to `false`.
|
|
40
|
+
* Disables the default `--no-<option>` negation prefix. Set to `''` or `[]` to only disable the prefix.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* local: z.boolean().default(true).meta({ negative: 'remote' })
|
|
44
|
+
* // --remote sets local to false, --no-local is disabled
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
negative?: readonly string[] | string;
|
|
38
48
|
deprecated?: boolean | string;
|
|
39
49
|
hidden?: boolean;
|
|
40
50
|
examples?: readonly unknown[];
|
package/src/types/builder.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import type { Tool } from 'ai';
|
|
3
|
-
import type { PadroneRuntime } from '../core/runtime.ts';
|
|
3
|
+
import type { PadroneProgressIndicator, PadroneRuntime } from '../core/runtime.ts';
|
|
4
|
+
import type { PadroneLogger } from '../extension/logger.ts';
|
|
5
|
+
import type { PadroneTracer } from '../extension/tracing.ts';
|
|
4
6
|
import type { PadroneMcpPreferences } from '../feature/mcp.ts';
|
|
5
7
|
import type { PadroneServePreferences } from '../feature/serve.ts';
|
|
6
8
|
import type { WrapConfig, WrapResult } from '../feature/wrap.ts';
|
|
@@ -385,6 +387,33 @@ export type PadroneBuilderMethods<
|
|
|
385
387
|
TContext,
|
|
386
388
|
TContextProvided
|
|
387
389
|
>;
|
|
390
|
+
// Overload for defineCommand.requires() branded callbacks — validates context requirements
|
|
391
|
+
<TNameNested extends string, TAliases extends string[] = [], TBuilder extends CommandTypesBase = CommandTypesBase, TReq = unknown>(
|
|
392
|
+
name: TNameNested | readonly [TNameNested, ...TAliases],
|
|
393
|
+
builderFn: ((builder: any) => TBuilder) & { '~contextRequires': (ctx: TReq) => void },
|
|
394
|
+
): TContext & TContextProvided extends TReq
|
|
395
|
+
? BuilderOrProgram<
|
|
396
|
+
TReturn,
|
|
397
|
+
TProgramName,
|
|
398
|
+
TName,
|
|
399
|
+
TParentName,
|
|
400
|
+
TArgs,
|
|
401
|
+
TRes,
|
|
402
|
+
TCommands extends []
|
|
403
|
+
? [WithAliases<TBuilder['~types']['command'], TAliases>]
|
|
404
|
+
: AnyPadroneCommand[] extends TCommands
|
|
405
|
+
? [WithAliases<TBuilder['~types']['command'], TAliases>]
|
|
406
|
+
: ReplaceOrAppendCommand<
|
|
407
|
+
TCommands,
|
|
408
|
+
TNameNested,
|
|
409
|
+
WithAliases<TBuilder['~types']['command'], ResolvedAliases<TCommands, TNameNested, TAliases>>
|
|
410
|
+
>,
|
|
411
|
+
TParentArgs,
|
|
412
|
+
TAsync,
|
|
413
|
+
TContext,
|
|
414
|
+
TContextProvided
|
|
415
|
+
>
|
|
416
|
+
: DefineCommandRequiresError;
|
|
388
417
|
// Fallback overload: accepts DefineCommand-typed callbacks where the builder type is not structurally compatible
|
|
389
418
|
// (e.g., DefineCommand with unknown context used in a parent with specific context)
|
|
390
419
|
<TNameNested extends string, TAliases extends string[] = [], TBuilder extends CommandTypesBase = CommandTypesBase>(
|
|
@@ -723,6 +752,30 @@ export type AnyPadroneProgram = PadroneProgram<string, string, string, any, any,
|
|
|
723
752
|
*/
|
|
724
753
|
export type PadroneExtension<TIn extends CommandTypesBase = CommandTypesBase, TOut extends CommandTypesBase = TIn> = (builder: TIn) => TOut;
|
|
725
754
|
|
|
755
|
+
/**
|
|
756
|
+
* Default context type for commands defined with `defineCommand()`.
|
|
757
|
+
* Includes optional context properties provided by common extensions (logger, tracing, progress).
|
|
758
|
+
*
|
|
759
|
+
* Override globally via module augmentation to add your application's context:
|
|
760
|
+
* ```ts
|
|
761
|
+
* declare module 'padrone' {
|
|
762
|
+
* interface DefineCommandContext {
|
|
763
|
+
* db: Database;
|
|
764
|
+
* }
|
|
765
|
+
* }
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
export interface DefineCommandContext {
|
|
769
|
+
logger?: PadroneLogger;
|
|
770
|
+
tracing?: PadroneTracer;
|
|
771
|
+
progress?: PadroneProgressIndicator;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/** Error brand returned by `.command()` when a `defineCommand.requires()` context requirement is not satisfied. */
|
|
775
|
+
export type DefineCommandRequiresError = {
|
|
776
|
+
readonly '~error': 'Required context not satisfied. Ensure required interceptors are registered on the program.';
|
|
777
|
+
};
|
|
778
|
+
|
|
726
779
|
/**
|
|
727
780
|
* Type for a command builder callback used with `.command()`.
|
|
728
781
|
* Use this when defining commands in separate files where full return type inference isn't needed.
|
|
@@ -741,7 +794,27 @@ export type PadroneExtension<TIn extends CommandTypesBase = CommandTypesBase, TO
|
|
|
741
794
|
* ```
|
|
742
795
|
*/
|
|
743
796
|
export type DefineCommand<TContext = unknown, TParentArgs extends PadroneSchema = PadroneSchema> = (
|
|
744
|
-
builder: PadroneBuilder<string, string, string, PadroneSchema<void>, void, [], TParentArgs, false, TContext>,
|
|
797
|
+
builder: PadroneBuilder<string, string, string, PadroneSchema<void>, void, [], TParentArgs, false, TContext, DefineCommandContext>,
|
|
745
798
|
) => CommandTypesBase;
|
|
746
799
|
|
|
800
|
+
/**
|
|
801
|
+
* Builder returned by `defineCommand()` (no-arg form).
|
|
802
|
+
* Call `.requires<T>()` to declare context dependencies, then `.command()` to provide the builder callback.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```ts
|
|
806
|
+
* const adminCommand = defineCommand()
|
|
807
|
+
* .requires<{ adminDb: AdminDB }>()
|
|
808
|
+
* .define((c) => c.action((_args, ctx) => ctx.context.adminDb.query(...)));
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
export type DefineCommandBuilder<TContextProvided = DefineCommandContext, TBrand = unknown> = {
|
|
812
|
+
/** Declare context types this command requires. Purely type-level — no runtime effect. */
|
|
813
|
+
requires: <TRequires>() => DefineCommandBuilder<DefineCommandContext & TRequires, { '~contextRequires': (ctx: TRequires) => void }>;
|
|
814
|
+
/** Provide the command builder callback. */
|
|
815
|
+
define: <TContext = unknown, TOut extends CommandTypesBase = CommandTypesBase>(
|
|
816
|
+
fn: (builder: PadroneBuilder<string, string, string, PadroneSchema<void>, void, [], any, false, TContext, TContextProvided>) => TOut,
|
|
817
|
+
) => typeof fn & TBrand;
|
|
818
|
+
};
|
|
819
|
+
|
|
747
820
|
type DefaultArgs = Record<string, unknown> | void;
|
package/src/types/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type {
|
|
|
3
3
|
AnyPadroneBuilder,
|
|
4
4
|
AnyPadroneProgram,
|
|
5
5
|
DefineCommand,
|
|
6
|
+
DefineCommandBuilder,
|
|
7
|
+
DefineCommandContext,
|
|
6
8
|
PadroneBuilder,
|
|
7
9
|
PadroneBuilderMethods,
|
|
8
10
|
PadroneExtension,
|
|
@@ -32,6 +34,7 @@ export type {
|
|
|
32
34
|
InterceptorParseContext,
|
|
33
35
|
InterceptorParseResult,
|
|
34
36
|
InterceptorPhases,
|
|
37
|
+
InterceptorRouteContext,
|
|
35
38
|
InterceptorShutdownContext,
|
|
36
39
|
InterceptorStartContext,
|
|
37
40
|
InterceptorValidateContext,
|
package/src/types/interceptor.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { AnyPadroneCommand, PadroneActionContext } from './command.ts';
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
|
|
10
10
|
/** Base context shared across all interceptor phases within a single execution. */
|
|
11
|
-
export type InterceptorBaseContext<TContext =
|
|
11
|
+
export type InterceptorBaseContext<TContext = object> = {
|
|
12
12
|
/** The resolved command for this execution. In the parse phase, this is the root program. */
|
|
13
13
|
command: AnyPadroneCommand;
|
|
14
14
|
/** The raw CLI input string (undefined when invoked without input). */
|
|
@@ -26,7 +26,7 @@ export type InterceptorBaseContext<TContext = unknown> = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/** Context for the parse phase. */
|
|
29
|
-
export type InterceptorParseContext<TContext =
|
|
29
|
+
export type InterceptorParseContext<TContext = object> = InterceptorBaseContext<TContext>;
|
|
30
30
|
|
|
31
31
|
/** Result returned by the parse phase's `next()`. */
|
|
32
32
|
export type InterceptorParseResult = {
|
|
@@ -35,8 +35,16 @@ export type InterceptorParseResult = {
|
|
|
35
35
|
positionalArgs: string[];
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
/** Context for the route phase. Runs after the target command is resolved, before validation. */
|
|
39
|
+
export type InterceptorRouteContext<TContext = object> = InterceptorBaseContext<TContext> & {
|
|
40
|
+
/** Raw named arguments extracted by the parser. */
|
|
41
|
+
rawArgs: Record<string, unknown>;
|
|
42
|
+
/** Positional argument strings extracted by the parser. */
|
|
43
|
+
positionalArgs: string[];
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
/** Context for the validate phase. */
|
|
39
|
-
export type InterceptorValidateContext<TContext =
|
|
47
|
+
export type InterceptorValidateContext<TContext = object> = InterceptorBaseContext<TContext> & {
|
|
40
48
|
/** Raw named arguments extracted by the parser. Mutable — modify before `next()` to inject/override values. */
|
|
41
49
|
rawArgs: Record<string, unknown>;
|
|
42
50
|
/** Positional argument strings extracted by the parser. */
|
|
@@ -54,7 +62,7 @@ export type InterceptorValidateResult<TArgs = unknown> = {
|
|
|
54
62
|
};
|
|
55
63
|
|
|
56
64
|
/** Context for the execute phase. Includes validate context fields (rawArgs, positionalArgs). */
|
|
57
|
-
export type InterceptorExecuteContext<TArgs = unknown, TContext =
|
|
65
|
+
export type InterceptorExecuteContext<TArgs = unknown, TContext = object> = InterceptorValidateContext<TContext> & {
|
|
58
66
|
/** Validated arguments that will be passed to the action. Mutable — modify before `next()` to override. */
|
|
59
67
|
args: TArgs;
|
|
60
68
|
};
|
|
@@ -65,10 +73,10 @@ export type InterceptorExecuteResult<TResult = unknown> = {
|
|
|
65
73
|
};
|
|
66
74
|
|
|
67
75
|
/** Context for the start phase. Runs before parsing, wraps the entire pipeline. */
|
|
68
|
-
export type InterceptorStartContext<TContext =
|
|
76
|
+
export type InterceptorStartContext<TContext = object> = InterceptorBaseContext<TContext>;
|
|
69
77
|
|
|
70
78
|
/** Context for the error phase. Called when the pipeline throws. Includes pipeline state accumulated before the error. */
|
|
71
|
-
export type InterceptorErrorContext<TContext =
|
|
79
|
+
export type InterceptorErrorContext<TContext = object> = InterceptorBaseContext<TContext> & {
|
|
72
80
|
/** The error that was thrown. */
|
|
73
81
|
error: unknown;
|
|
74
82
|
/** Raw named arguments (available if parse completed). */
|
|
@@ -88,7 +96,7 @@ export type InterceptorErrorResult<TResult = unknown> = {
|
|
|
88
96
|
};
|
|
89
97
|
|
|
90
98
|
/** Context for the shutdown phase. Always runs after the pipeline (success or failure). Includes pipeline state accumulated before completion. */
|
|
91
|
-
export type InterceptorShutdownContext<TResult = unknown, TContext =
|
|
99
|
+
export type InterceptorShutdownContext<TResult = unknown, TContext = object> = InterceptorBaseContext<TContext> & {
|
|
92
100
|
/** The error, if the pipeline failed (after error phase processing). */
|
|
93
101
|
error?: unknown;
|
|
94
102
|
/** The pipeline result, if it succeeded. */
|
|
@@ -156,7 +164,7 @@ export type InterceptorMeta = {
|
|
|
156
164
|
* - `TArgs` — the validated arguments type (output of the args schema).
|
|
157
165
|
* - `TResult` — the command's return type.
|
|
158
166
|
*/
|
|
159
|
-
export type InterceptorPhases<TArgs = unknown, TResult = unknown, TContext =
|
|
167
|
+
export type InterceptorPhases<TArgs = unknown, TResult = unknown, TContext = object> = {
|
|
160
168
|
/**
|
|
161
169
|
* Runs before the pipeline (parse → validate → execute). `next()` proceeds to the pipeline.
|
|
162
170
|
* Root interceptors only. Use for startup tasks like telemetry, update checks, or global config loading.
|
|
@@ -164,6 +172,12 @@ export type InterceptorPhases<TArgs = unknown, TResult = unknown, TContext = unk
|
|
|
164
172
|
start?: InterceptorPhaseHandler<InterceptorStartContext<TContext>, unknown>;
|
|
165
173
|
/** Intercepts command routing and raw argument extraction. */
|
|
166
174
|
parse?: InterceptorPhaseHandler<InterceptorParseContext<TContext>, InterceptorParseResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Runs after the target command is resolved (post-parse), before validation.
|
|
177
|
+
* Use for per-command setup: authorization, resource loading, logging, etc.
|
|
178
|
+
* Root and command-level interceptors both participate.
|
|
179
|
+
*/
|
|
180
|
+
route?: InterceptorPhaseHandler<InterceptorRouteContext<TContext>, void>;
|
|
167
181
|
/** Intercepts argument preprocessing and schema validation. Interactive prompting is handled by the interactive extension. */
|
|
168
182
|
validate?: InterceptorPhaseHandler<InterceptorValidateContext<TContext>, InterceptorValidateResult<TArgs>, InterceptorValidateResult>;
|
|
169
183
|
/** Intercepts handler execution. */
|
|
@@ -188,7 +202,7 @@ export type InterceptorPhases<TArgs = unknown, TResult = unknown, TContext = unk
|
|
|
188
202
|
* Factory function that creates phase handlers for an interceptor.
|
|
189
203
|
* Called once per command execution — the closure provides typed, scoped cross-phase state across phases.
|
|
190
204
|
*/
|
|
191
|
-
export type InterceptorFactory<TArgs = unknown, TResult = unknown, TContext =
|
|
205
|
+
export type InterceptorFactory<TArgs = unknown, TResult = unknown, TContext = object> = () => InterceptorPhases<TArgs, TResult, TContext>;
|
|
192
206
|
|
|
193
207
|
/**
|
|
194
208
|
* A self-contained interceptor value: a factory function with static metadata as own properties.
|
|
@@ -198,7 +212,7 @@ export type InterceptorFactory<TArgs = unknown, TResult = unknown, TContext = un
|
|
|
198
212
|
* Also accepted directly by `.intercept()` as the single-argument form.
|
|
199
213
|
* Call `.provides<T>()` to brand it as a context-providing interceptor.
|
|
200
214
|
*/
|
|
201
|
-
export type PadroneInterceptorFn<TArgs = unknown, TResult = unknown, TContext =
|
|
215
|
+
export type PadroneInterceptorFn<TArgs = unknown, TResult = unknown, TContext = object> = InterceptorFactory<TArgs, TResult, TContext> &
|
|
202
216
|
InterceptorMeta & {
|
|
203
217
|
/** Brand this interceptor as providing additional context of type `TProvides`. No-op at runtime; purely a type-level cast. */
|
|
204
218
|
provides: <TProvides>() => PadroneContextInterceptor<TProvides, TArgs, TResult, TContext>;
|
|
@@ -217,7 +231,7 @@ export type PadroneInterceptorFn<TArgs = unknown, TResult = unknown, TContext =
|
|
|
217
231
|
*
|
|
218
232
|
* Create with `defineInterceptor(meta, factory)` or pass `(meta, factory)` directly to `.intercept()`.
|
|
219
233
|
*/
|
|
220
|
-
export type PadroneInterceptor<TArgs = unknown, TResult = unknown, TContext =
|
|
234
|
+
export type PadroneInterceptor<TArgs = unknown, TResult = unknown, TContext = object> = PadroneInterceptorFn<TArgs, TResult, TContext>;
|
|
221
235
|
|
|
222
236
|
/**
|
|
223
237
|
* A context-providing interceptor. Carries a phantom `'~context'` brand declaring what it adds
|
|
@@ -227,7 +241,7 @@ export type PadroneInterceptor<TArgs = unknown, TResult = unknown, TContext = un
|
|
|
227
241
|
* Created by calling `.provides<T>()` on a `PadroneInterceptorFn`.
|
|
228
242
|
* Chain `.requires<T>()` to also declare context dependencies.
|
|
229
243
|
*/
|
|
230
|
-
export type PadroneContextInterceptor<TProvides = unknown, TArgs = unknown, TResult = unknown, TContext =
|
|
244
|
+
export type PadroneContextInterceptor<TProvides = unknown, TArgs = unknown, TResult = unknown, TContext = object> = Omit<
|
|
231
245
|
PadroneInterceptorFn<TArgs, TResult, TContext>,
|
|
232
246
|
'requires'
|
|
233
247
|
> &
|
package/src/util/type-utils.ts
CHANGED
|
@@ -210,6 +210,28 @@ export type WithInterceptor<T, TProvides> = T extends {
|
|
|
210
210
|
: PadroneBuilder<PN, N, PaN, A, R, C, any, AS, CTX, CTXP & TProvides>
|
|
211
211
|
: T;
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Utility type for extensions that force the builder/program into async mode.
|
|
215
|
+
* Sets `TAsync` to `true` while preserving all other type params.
|
|
216
|
+
*/
|
|
217
|
+
export type WithAsync<T> = T extends {
|
|
218
|
+
'~types': {
|
|
219
|
+
programName: infer PN extends string;
|
|
220
|
+
name: infer N extends string;
|
|
221
|
+
parentName: infer PaN extends string;
|
|
222
|
+
argsSchema: infer A extends PadroneSchema;
|
|
223
|
+
result: infer R;
|
|
224
|
+
commands: infer C extends [...AnyPadroneCommand[]];
|
|
225
|
+
async: any;
|
|
226
|
+
context: infer CTX;
|
|
227
|
+
contextProvided: infer CTXP;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
? T extends { run: any }
|
|
231
|
+
? PadroneProgram<PN, N, PaN, A, R, C, any, true, CTX, CTXP>
|
|
232
|
+
: PadroneBuilder<PN, N, PaN, A, R, C, any, true, CTX, CTXP>
|
|
233
|
+
: T;
|
|
234
|
+
|
|
213
235
|
export type PickCommandByName<
|
|
214
236
|
TCommands extends AnyPadroneCommand[],
|
|
215
237
|
TName extends string | AnyPadroneCommand,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args-Cnq0nwSM.mjs","names":[],"sources":["../src/util/shell-utils.ts","../src/core/args.ts"],"sourcesContent":["/**\n * Convert a camelCase string to kebab-case.\n * Returns null if the string has no uppercase letters (no conversion needed).\n */\nexport function camelToKebab(str: string): string | null {\n if (!/[A-Z]/.test(str)) return null;\n return str.replace(/[A-Z]/g, (ch) => `-${ch.toLowerCase()}`);\n}\n\nexport type ShellType = 'bash' | 'zsh' | 'fish' | 'powershell';\n\n/**\n * Detects the current shell from environment variables and process info.\n * @returns The detected shell type, or undefined if unknown\n */\nexport async function detectShell(): Promise<ShellType | undefined> {\n if (typeof process === 'undefined') return undefined;\n\n // Method 1: Check SHELL environment variable (most common)\n const shellEnv = process.env.SHELL || '';\n if (shellEnv.includes('zsh')) return 'zsh';\n if (shellEnv.includes('bash')) return 'bash';\n if (shellEnv.includes('fish')) return 'fish';\n\n // Method 2: Check Windows-specific shells\n if (process.env.PSModulePath || process.env.POWERSHELL_DISTRIBUTION_CHANNEL) {\n return 'powershell';\n }\n\n // Method 3: Check parent process on Unix-like systems\n try {\n const ppid = process.ppid;\n if (ppid) {\n const { execSync } = (await import('node:child_process')) as typeof import('node:child_process');\n const processName = execSync(`ps -p ${ppid} -o comm=`, {\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'ignore'],\n }).trim();\n\n if (processName.includes('zsh')) return 'zsh';\n if (processName.includes('bash')) return 'bash';\n if (processName.includes('fish')) return 'fish';\n }\n } catch {\n // Ignore errors (e.g., ps not available)\n }\n\n return undefined;\n}\n\nexport async function getRcFile(shell: ShellType, home?: string): Promise<string | null> {\n const { homedir } = await import('node:os');\n const { join } = await import('node:path');\n const h = home ?? homedir();\n switch (shell) {\n case 'bash':\n return join(h, '.bashrc');\n case 'zsh':\n return join(h, '.zshrc');\n case 'fish':\n return join(h, '.config', 'fish', 'config.fish');\n case 'powershell':\n return (\n (typeof process !== 'undefined' ? process.env.PROFILE : undefined) ||\n join(h, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1')\n );\n default:\n return null;\n }\n}\n\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Writes a snippet to a shell config file using begin/end markers for idempotency.\n * If a block with the same begin marker exists, it is replaced. Otherwise the snippet is appended.\n */\nexport async function writeToRcFile(\n rcFile: string,\n snippet: string,\n beginMarker: string,\n endMarker: string,\n): Promise<{ file: string; updated: boolean }> {\n const { existsSync, mkdirSync, readFileSync, writeFileSync } = await import('node:fs');\n const { dirname } = await import('node:path');\n const existing = existsSync(rcFile) ? readFileSync(rcFile, 'utf-8') : '';\n\n if (existing.includes(beginMarker)) {\n const pattern = new RegExp(`${escapeRegExp(beginMarker)}[\\\\s\\\\S]*?${escapeRegExp(endMarker)}`);\n writeFileSync(rcFile, existing.replace(pattern, snippet));\n return { file: rcFile, updated: true };\n }\n\n mkdirSync(dirname(rcFile), { recursive: true });\n const separator = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n writeFileSync(rcFile, `${existing}${separator}\\n${snippet}\\n`);\n return { file: rcFile, updated: false };\n}\n","import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';\nimport type { PadroneFieldMeta } from '../types/args-meta.ts';\nimport { camelToKebab } from '../util/shell-utils.ts';\nimport { asyncStreamRegistry } from '../util/stream.ts';\n\nexport type { PadroneArgsSchemaMeta, PadroneFieldMeta, SingleChar, StdinConfig } from '../types/args-meta.ts';\n\n/** Extract the JSON schema from a Standard Schema, returning it as a plain record. */\nexport function getJsonSchema(schema: StandardJSONSchemaV1): Record<string, any> {\n return schema['~standard'].jsonSchema.input({\n target: 'draft-2020-12',\n libraryOptions: { unrepresentable: 'any' },\n }) as Record<string, any>;\n}\n\nfunction getFieldJsonSchema(schema: StandardJSONSchemaV1 | undefined, field: string): Record<string, any> | undefined {\n if (!schema) return undefined;\n try {\n const jsonSchema = getJsonSchema(schema);\n if (jsonSchema.type === 'object' && jsonSchema.properties) return jsonSchema.properties[field];\n } catch {}\n return undefined;\n}\n\n/**\n * Checks if a field in the schema is an array type (e.g. `z.string().array()`).\n */\nexport function isArrayField(schema: StandardJSONSchemaV1 | undefined, field: string): boolean {\n return getFieldJsonSchema(schema, field)?.type === 'array';\n}\n\n/**\n * Checks if a field is an async stream (marked with `asyncStream()` metadata).\n * Returns the item schema if provided, or `true` if it's a plain string stream.\n */\nexport function isAsyncStreamField(schema: StandardJSONSchemaV1 | undefined, field: string): { itemSchema?: StandardSchemaV1 } | false {\n const prop = getFieldJsonSchema(schema, field);\n const asyncStreamId = prop?.asyncStream;\n if (asyncStreamId && asyncStreamRegistry.has(asyncStreamId)) {\n const meta = asyncStreamRegistry.get(asyncStreamId);\n return { itemSchema: meta?.itemSchema };\n }\n\n return false;\n}\n\n/**\n * Parse positional configuration to extract names and variadic info.\n */\nexport function parsePositionalConfig(positional: readonly string[]): { name: string; variadic: boolean }[] {\n return positional.map((p) => {\n const variadic = p.startsWith('...');\n const name = variadic ? p.slice(3) : p;\n return { name, variadic };\n });\n}\n\n/**\n * Result type for extractSchemaMetadata function.\n */\ninterface SchemaMetadataResult {\n /** Single-char flags: maps flag char → full arg name (e.g. `{ v: 'verbose' }`) */\n flags: Record<string, string>;\n /** Multi-char aliases: maps alias → full arg name (e.g. `{ 'dry-run': 'dryRun' }`) */\n aliases: Record<string, string>;\n}\n\nfunction addEntries(target: Record<string, string>, key: string, items: string | readonly string[], filter?: (item: string) => boolean) {\n const list = typeof items === 'string' ? [items] : items;\n for (const item of list) {\n if (typeof item === 'string' && item && item !== key && !(item in target) && (!filter || filter(item))) {\n target[item] = key;\n }\n }\n}\n\n/**\n * Extract all arg metadata from schema and meta in a single pass.\n * Returns flags (single-char, stackable) and aliases (multi-char, long names) separately.\n * When `autoAlias` is true (default), camelCase property names automatically get kebab-case aliases.\n */\nexport function extractSchemaMetadata(\n schema: StandardJSONSchemaV1,\n meta?: Record<string, PadroneFieldMeta | undefined>,\n autoAlias?: boolean,\n): SchemaMetadataResult {\n const flags: Record<string, string> = {};\n const aliases: Record<string, string> = {};\n\n // Extract from meta object\n if (meta) {\n for (const [key, value] of Object.entries(meta)) {\n if (!value) continue;\n\n if (value.flags) {\n addEntries(flags, key, value.flags, (item) => item.length === 1);\n }\n if (value.alias) {\n addEntries(aliases, key, value.alias, (item) => item.length > 1);\n }\n }\n }\n\n // Extract from JSON schema properties\n try {\n const jsonSchema = getJsonSchema(schema) as Record<string, any>;\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n for (const [propertyName, propertySchema] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n if (!propertySchema) continue;\n\n // Extract flags from schema `.meta({ flags: ... })`\n const propFlags = propertySchema.flags;\n if (propFlags) {\n addEntries(flags, propertyName, propFlags, (item) => item.length === 1);\n }\n\n // Extract aliases from schema `.meta({ alias: ... })`\n const propAlias = propertySchema.alias;\n if (propAlias) {\n const list = typeof propAlias === 'string' ? [propAlias] : propAlias;\n if (Array.isArray(list)) {\n addEntries(aliases, propertyName, list, (item) => item.length > 1);\n }\n }\n\n // Auto-generate kebab-case alias for camelCase property names\n if (autoAlias !== false) {\n const kebab = camelToKebab(propertyName);\n if (kebab && !(kebab in aliases)) {\n aliases[kebab] = propertyName;\n }\n }\n }\n }\n } catch {\n // Ignore errors from JSON schema generation\n }\n\n return { flags, aliases };\n}\n\nfunction preprocessMappings(data: Record<string, unknown>, mappings: Record<string, string>): Record<string, unknown> {\n const result = { ...data };\n\n for (const [mappedKey, fullArgName] of Object.entries(mappings)) {\n if (mappedKey in data && mappedKey !== fullArgName) {\n const mappedValue = data[mappedKey];\n // Prefer full arg name if it exists\n if (!(fullArgName in result)) result[fullArgName] = mappedValue;\n delete result[mappedKey];\n }\n }\n\n return result;\n}\n\n/**\n * Apply values to arguments using \"set if not present\" semantics.\n * Existing values take precedence — only fills in undefined or missing keys.\n */\nexport function applyValues(data: Record<string, unknown>, values: Record<string, unknown>): Record<string, unknown> {\n const result = { ...data };\n\n for (const [key, value] of Object.entries(values)) {\n if (key in result && result[key] !== undefined) continue;\n if (value !== undefined) {\n result[key] = value;\n }\n }\n\n return result;\n}\n\n/** Applies flag and alias mappings to raw arguments. */\nexport function preprocessArgs(\n data: Record<string, unknown>,\n ctx: { flags?: Record<string, string>; aliases?: Record<string, string> },\n): Record<string, unknown> {\n let result = { ...data };\n\n if (ctx.flags && Object.keys(ctx.flags).length > 0) {\n result = preprocessMappings(result, ctx.flags);\n }\n if (ctx.aliases && Object.keys(ctx.aliases).length > 0) {\n result = preprocessMappings(result, ctx.aliases);\n }\n\n return result;\n}\n\n/**\n * Auto-coerce CLI string values to match the expected schema types.\n * Handles: string → number, string → boolean for primitive schema fields.\n * Arrays of primitives are also coerced element-wise.\n */\nexport function coerceArgs(data: Record<string, unknown>, schema: StandardJSONSchemaV1): Record<string, unknown> {\n let properties: Record<string, any>;\n try {\n const jsonSchema = getJsonSchema(schema) as Record<string, any>;\n if (jsonSchema.type !== 'object' || !jsonSchema.properties) return data;\n properties = jsonSchema.properties;\n } catch {\n return data;\n }\n\n const result = { ...data };\n\n for (const [key, value] of Object.entries(result)) {\n const prop = properties[key];\n if (!prop) continue;\n\n const targetType = prop.type as string | undefined;\n\n if (targetType === 'number' || targetType === 'integer') {\n if (typeof value === 'string') {\n const num = Number(value);\n if (!Number.isNaN(num)) result[key] = num;\n }\n } else if (targetType === 'boolean') {\n if (typeof value === 'string') {\n const lower = value.toLowerCase();\n if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on') result[key] = true;\n else if (lower === 'false' || lower === '0' || lower === 'no' || lower === 'off') result[key] = false;\n }\n } else if (targetType === 'array') {\n // Coerce single items to array\n const arr = Array.isArray(value) ? value : [value];\n const itemType = prop.items?.type as string | undefined;\n if (itemType === 'number' || itemType === 'integer') {\n result[key] = arr.map((v) => {\n if (typeof v === 'string') {\n const num = Number(v);\n return Number.isNaN(num) ? v : num;\n }\n return v;\n });\n } else if (itemType === 'boolean') {\n result[key] = arr.map((v) => {\n if (typeof v === 'string') {\n const lower = v.toLowerCase();\n if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on') return true;\n if (lower === 'false' || lower === '0' || lower === 'no' || lower === 'off') return false;\n }\n return v;\n });\n } else if (!Array.isArray(value)) {\n result[key] = arr;\n }\n }\n }\n\n return result;\n}\n\n/**\n * Detect unknown keys in the args that don't match any schema property.\n * Returns an array of { key } for each unknown key.\n * Framework-reserved keys (--config, -c) are always allowed.\n */\nexport function detectUnknownArgs(\n data: Record<string, unknown>,\n schema: StandardJSONSchemaV1,\n flags: Record<string, string>,\n aliases: Record<string, string>,\n): { key: string }[] {\n let properties: Record<string, any>;\n let isLoose = false;\n try {\n const jsonSchema = getJsonSchema(schema) as Record<string, any>;\n if (jsonSchema.type !== 'object' || !jsonSchema.properties) return [];\n properties = jsonSchema.properties;\n // If additionalProperties is set (true, {}, or a schema), the schema allows extra keys\n if (jsonSchema.additionalProperties !== undefined && jsonSchema.additionalProperties !== false) isLoose = true;\n } catch {\n return [];\n }\n\n if (isLoose) return [];\n\n const knownKeys = new Set<string>([\n ...Object.keys(properties),\n ...Object.keys(flags),\n ...Object.values(flags),\n ...Object.keys(aliases),\n ...Object.values(aliases),\n ]);\n const unknowns: { key: string }[] = [];\n\n for (const key of Object.keys(data)) {\n if (!knownKeys.has(key)) {\n unknowns.push({ key });\n }\n }\n\n return unknowns;\n}\n"],"mappings":";;;;;;AAIA,SAAgB,aAAa,KAA4B;AACvD,KAAI,CAAC,QAAQ,KAAK,IAAI,CAAE,QAAO;AAC/B,QAAO,IAAI,QAAQ,WAAW,OAAO,IAAI,GAAG,aAAa,GAAG;;;;;;AAS9D,eAAsB,cAA8C;AAClE,KAAI,OAAO,YAAY,YAAa,QAAO,KAAA;CAG3C,MAAM,WAAW,QAAQ,IAAI,SAAS;AACtC,KAAI,SAAS,SAAS,MAAM,CAAE,QAAO;AACrC,KAAI,SAAS,SAAS,OAAO,CAAE,QAAO;AACtC,KAAI,SAAS,SAAS,OAAO,CAAE,QAAO;AAGtC,KAAI,QAAQ,IAAI,gBAAgB,QAAQ,IAAI,gCAC1C,QAAO;AAIT,KAAI;EACF,MAAM,OAAO,QAAQ;AACrB,MAAI,MAAM;GACR,MAAM,EAAE,aAAc,MAAM,OAAO;GACnC,MAAM,cAAc,SAAS,SAAS,KAAK,YAAY;IACrD,UAAU;IACV,OAAO;KAAC;KAAQ;KAAQ;KAAS;IAClC,CAAC,CAAC,MAAM;AAET,OAAI,YAAY,SAAS,MAAM,CAAE,QAAO;AACxC,OAAI,YAAY,SAAS,OAAO,CAAE,QAAO;AACzC,OAAI,YAAY,SAAS,OAAO,CAAE,QAAO;;SAErC;;AAOV,eAAsB,UAAU,OAAkB,MAAuC;CACvF,MA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