@kjanat/dreamcli 2.5.0 → 3.0.0-rc.10
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 +344 -1
- package/README.md +9 -2
- package/dist/core/cli/dispatch.d.mts +6 -5
- package/dist/core/cli/dispatch.mjs +205 -1
- package/dist/core/cli/help-links.d.mts +0 -1
- package/dist/core/cli/help-links.mjs +41 -1
- package/dist/core/cli/index.d.mts +185 -19
- package/dist/core/cli/index.mjs +945 -1
- package/dist/core/cli/planner.d.mts +32 -6
- package/dist/core/cli/planner.mjs +300 -1
- package/dist/core/cli/plugin.d.mts +1 -1
- package/dist/core/cli/plugin.mjs +41 -1
- package/dist/core/cli/propagate.d.mts +1 -1
- package/dist/core/cli/propagate.mjs +57 -1
- package/dist/core/cli/root-help.d.mts +18 -3
- package/dist/core/cli/root-help.mjs +226 -6
- package/dist/core/cli/root-surface.d.mts +30 -4
- package/dist/core/cli/root-surface.mjs +28 -1
- package/dist/core/cli/runtime-preflight.d.mts +30 -3
- package/dist/core/cli/runtime-preflight.mjs +169 -1
- package/dist/core/completion/index.d.mts +32 -2
- package/dist/core/completion/index.mjs +90 -1
- package/dist/core/completion/shells/bash.d.mts +0 -1
- package/dist/core/completion/shells/bash.mjs +308 -3
- package/dist/core/completion/shells/fish.d.mts +0 -1
- package/dist/core/completion/shells/fish.mjs +162 -2
- package/dist/core/completion/shells/powershell.d.mts +0 -1
- package/dist/core/completion/shells/powershell.mjs +358 -2
- package/dist/core/completion/shells/shared.d.mts +23 -2
- package/dist/core/completion/shells/shared.mjs +176 -1
- package/dist/core/completion/shells/zsh.d.mts +0 -1
- package/dist/core/completion/shells/zsh.mjs +251 -2
- package/dist/core/config/index.d.mts +2 -3
- package/dist/core/config/index.mjs +246 -1
- package/dist/core/config/package-json.d.mts +27 -4
- package/dist/core/config/package-json.mjs +386 -3
- package/dist/core/errors/index.d.mts +3 -3
- package/dist/core/errors/index.mjs +87 -1
- package/dist/core/execution/index.d.mts +0 -1
- package/dist/core/execution/index.mjs +201 -1
- package/dist/core/help/ansi.d.mts +11 -5
- package/dist/core/help/ansi.mjs +121 -2
- package/dist/core/help/index.d.mts +65 -2
- package/dist/core/help/index.mjs +341 -7
- package/dist/core/help/theme.d.mts +68 -0
- package/dist/core/help/theme.mjs +46 -0
- package/dist/core/json-schema/index.d.mts +15 -2
- package/dist/core/json-schema/index.mjs +536 -12
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +22 -5
- package/dist/core/json-schema/meta-descriptions.generated.mjs +102 -28
- package/dist/core/output/activity.d.mts +0 -1
- package/dist/core/output/activity.mjs +452 -1
- package/dist/core/output/bind.mjs +56 -1
- package/dist/core/output/contracts.d.mts +4 -5
- package/dist/core/output/contracts.mjs +57 -1
- package/dist/core/output/display-value.mjs +32 -1
- package/dist/core/output/index.d.mts +21 -1
- package/dist/core/output/index.mjs +442 -2
- package/dist/core/output/renderers.d.mts +0 -1
- package/dist/core/output/renderers.mjs +46 -1
- package/dist/core/output/writer.mjs +12 -1
- package/dist/core/parse/index.d.mts +54 -7
- package/dist/core/parse/index.mjs +727 -1
- package/dist/core/prompt/index.d.mts +12 -4
- package/dist/core/prompt/index.mjs +348 -6
- package/dist/core/resolve/args.d.mts +1 -1
- package/dist/core/resolve/args.mjs +105 -1
- package/dist/core/resolve/coerce.d.mts +1 -1
- package/dist/core/resolve/coerce.mjs +336 -1
- package/dist/core/resolve/config.mjs +19 -1
- package/dist/core/resolve/contracts.d.mts +9 -4
- package/dist/core/resolve/errors.d.mts +0 -1
- package/dist/core/resolve/errors.mjs +140 -2
- package/dist/core/resolve/flags.d.mts +7 -2
- package/dist/core/resolve/flags.mjs +251 -1
- package/dist/core/resolve/index.d.mts +2 -2
- package/dist/core/resolve/index.mjs +85 -1
- package/dist/core/resolve/property.d.mts +6 -2
- package/dist/core/resolve/property.mjs +53 -1
- package/dist/core/schema/activity.d.mts +31 -11
- package/dist/core/schema/arg.d.mts +92 -13
- package/dist/core/schema/arg.mjs +463 -1
- package/dist/core/schema/command.d.mts +29 -7
- package/dist/core/schema/command.mjs +726 -1
- package/dist/core/schema/flag.d.mts +577 -21
- package/dist/core/schema/flag.mjs +705 -1
- package/dist/core/schema/index.d.mts +5 -2
- package/dist/core/schema/middleware.d.mts +4 -3
- package/dist/core/schema/middleware.mjs +41 -1
- package/dist/core/schema/number-constraints.d.mts +96 -0
- package/dist/core/schema/number-constraints.mjs +60 -0
- package/dist/core/schema/prompt.d.mts +21 -3
- package/dist/core/schema/run.d.mts +24 -5
- package/dist/core/schema/string-constraints.d.mts +97 -0
- package/dist/core/schema/string-constraints.mjs +69 -0
- package/dist/core/schema/value-parsers.d.mts +78 -0
- package/dist/core/schema/value-parsers.mjs +142 -0
- package/dist/core/schema-dsl/runtime.mjs +271 -2
- package/dist/core/schema-dsl/to-json-schema.d.mts +0 -1
- package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
- package/dist/core/testkit/index.d.mts +9 -36
- package/dist/core/testkit/index.mjs +83 -1
- package/dist/index.d.mts +12 -6
- package/dist/index.mjs +22 -1
- package/dist/runtime/adapter.d.mts +38 -2
- package/dist/runtime/adapter.mjs +87 -1
- package/dist/runtime/auto.d.mts +2 -3
- package/dist/runtime/auto.mjs +45 -1
- package/dist/runtime/deno.d.mts +24 -5
- package/dist/runtime/deno.mjs +262 -2
- package/dist/runtime/detect.mjs +45 -1
- package/dist/runtime/index.d.mts +3 -4
- package/dist/runtime/node.d.mts +8 -2
- package/dist/runtime/node.mjs +220 -2
- package/dist/runtime/paths.mjs +48 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +6 -1
- package/dist/strings.mjs +22 -1
- package/dist/testkit.d.mts +1 -0
- package/dist/testkit.mjs +5 -1
- package/dist/version.d.mts +7 -3
- package/dist/version.mjs +7 -1
- package/dreamcli.schema.json +36 -7
- package/examples/basic.ts +5 -1
- package/examples/gh/package.json +2 -7
- package/examples/pwsh-demo/package.json +1 -7
- package/examples/pwsh-demo/src/main.test.ts +1 -4
- package/examples/pwsh-demo/src/main.ts +14 -4
- package/examples/transport-launcher.ts +85 -0
- package/package.json +43 -49
- package/dist/runtime/bun.d.mts +0 -28
- package/dist/runtime/bun.mjs +0 -1
- package/dist/runtime/support.d.mts +0 -42
- package/dist/runtime/support.mjs +0 -1
- package/src/core/cli/dispatch.ts +0 -349
- package/src/core/cli/help-links.ts +0 -82
- package/src/core/cli/index.ts +0 -1413
- package/src/core/cli/planner.ts +0 -487
- package/src/core/cli/plugin.ts +0 -117
- package/src/core/cli/propagate.ts +0 -97
- package/src/core/cli/root-help.ts +0 -252
- package/src/core/cli/root-surface.ts +0 -74
- package/src/core/cli/runtime-preflight.ts +0 -438
- package/src/core/completion/index.ts +0 -88
- package/src/core/completion/shells/bash.ts +0 -459
- package/src/core/completion/shells/fish.ts +0 -259
- package/src/core/completion/shells/powershell.ts +0 -439
- package/src/core/completion/shells/shared.ts +0 -283
- package/src/core/completion/shells/zsh.ts +0 -381
- package/src/core/config/index.ts +0 -417
- package/src/core/config/package-json.ts +0 -560
- package/src/core/errors/index.ts +0 -193
- package/src/core/execution/index.ts +0 -268
- package/src/core/help/ansi.ts +0 -144
- package/src/core/help/index.ts +0 -516
- package/src/core/json-schema/index.ts +0 -891
- package/src/core/json-schema/meta-descriptions.generated.ts +0 -185
- package/src/core/output/activity.ts +0 -575
- package/src/core/output/bind.ts +0 -59
- package/src/core/output/contracts.ts +0 -194
- package/src/core/output/display-value.ts +0 -48
- package/src/core/output/index.ts +0 -704
- package/src/core/output/renderers.ts +0 -125
- package/src/core/output/writer.ts +0 -46
- package/src/core/parse/index.ts +0 -681
- package/src/core/prompt/index.ts +0 -583
- package/src/core/resolve/args.ts +0 -144
- package/src/core/resolve/coerce.ts +0 -432
- package/src/core/resolve/config.ts +0 -26
- package/src/core/resolve/contracts.ts +0 -135
- package/src/core/resolve/errors.ts +0 -227
- package/src/core/resolve/flags.ts +0 -255
- package/src/core/resolve/index.ts +0 -108
- package/src/core/resolve/property.ts +0 -99
- package/src/core/schema/activity.ts +0 -240
- package/src/core/schema/arg.ts +0 -719
- package/src/core/schema/command.ts +0 -1498
- package/src/core/schema/flag.ts +0 -801
- package/src/core/schema/index.ts +0 -91
- package/src/core/schema/middleware.ts +0 -171
- package/src/core/schema/prompt.ts +0 -156
- package/src/core/schema/run.ts +0 -198
- package/src/core/schema-dsl/index.ts +0 -109
- package/src/core/schema-dsl/parse.ts +0 -262
- package/src/core/schema-dsl/runtime.ts +0 -609
- package/src/core/schema-dsl/to-json-schema.ts +0 -102
- package/src/core/testkit/index.ts +0 -123
- package/src/index.ts +0 -179
- package/src/runtime/adapter.ts +0 -303
- package/src/runtime/auto.ts +0 -110
- package/src/runtime/bun.ts +0 -55
- package/src/runtime/deno.ts +0 -369
- package/src/runtime/detect.ts +0 -105
- package/src/runtime/index.ts +0 -21
- package/src/runtime/node-builtins.d.ts +0 -27
- package/src/runtime/node.ts +0 -300
- package/src/runtime/paths.ts +0 -64
- package/src/runtime/support.ts +0 -135
- package/src/runtime.ts +0 -31
- package/src/strings.ts +0 -34
- package/src/testkit.ts +0 -25
- package/src/version.ts +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlagSchema } from "../schema/flag.mjs";
|
|
2
2
|
import { CommandSchema } from "../schema/command.mjs";
|
|
3
|
-
|
|
3
|
+
import "../schema/index.mjs";
|
|
4
4
|
//#region src/core/parse/index.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Token discriminated union.
|
|
@@ -58,6 +58,20 @@ declare function tokenize(argv: readonly string[]): readonly Token[];
|
|
|
58
58
|
* @returns `true` if `token` occurs before any `--` separator.
|
|
59
59
|
*/
|
|
60
60
|
declare function includesBeforeSeparator(argv: readonly string[], token: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Remove every occurrence of `token` that appears before the `--` end-of-options
|
|
63
|
+
* separator, leaving post-separator literals untouched.
|
|
64
|
+
*
|
|
65
|
+
* The strip counterpart to {@linkcode includesBeforeSeparator}: root-level flags
|
|
66
|
+
* (`--json`) are stripped before dispatch/parse so the command schema never sees
|
|
67
|
+
* them, but a literal after `--` (`-- --json`) must reach the command unchanged.
|
|
68
|
+
*
|
|
69
|
+
* @param argv - Raw argument strings.
|
|
70
|
+
* @param token - Exact flag token to strip (e.g. `--json`).
|
|
71
|
+
* @returns A new argv with pre-separator occurrences of `token` removed, or the
|
|
72
|
+
* original reference when `token` does not occur before the separator.
|
|
73
|
+
*/
|
|
74
|
+
declare function stripBeforeSeparator(argv: readonly string[], token: string): readonly string[];
|
|
61
75
|
/**
|
|
62
76
|
* Raw parsed values before resolution (defaults, env, config, etc.).
|
|
63
77
|
*
|
|
@@ -70,15 +84,47 @@ interface ParseResult {
|
|
|
70
84
|
/** Positional arg values keyed by arg name. */
|
|
71
85
|
readonly args: Readonly<Record<string, unknown>>;
|
|
72
86
|
}
|
|
87
|
+
/** Options accepted by {@link parse} and {@link buildFlagLookup}. */
|
|
88
|
+
interface ParseOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Accept the kebab↔camel counterpart spelling of each flag name/alias
|
|
91
|
+
* (`--doThis` for a flag named `do-this`, and vice versa). Automatically
|
|
92
|
+
* disabled per spelling pair when a command explicitly defines both.
|
|
93
|
+
*
|
|
94
|
+
* @defaultValue `true`
|
|
95
|
+
*/
|
|
96
|
+
readonly caseParity?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/** `do-this` → `doThis`. Returns the input unchanged when nothing converts. */
|
|
99
|
+
declare function kebabToCamel(name: string): string;
|
|
100
|
+
/** `doThis` → `do-this`. Returns the input unchanged when nothing converts. */
|
|
101
|
+
declare function camelToKebab(name: string): string;
|
|
102
|
+
/** One resolvable spelling in the flag lookup map. */
|
|
103
|
+
interface FlagLookupEntry {
|
|
104
|
+
/** Canonical flag name (the key in the command's flag record). */
|
|
105
|
+
readonly name: string;
|
|
106
|
+
/** The flag's schema. */
|
|
107
|
+
readonly schema: FlagSchema;
|
|
108
|
+
/** This spelling is the flag's negated form (`--no-foo`) — parses to `false`. */
|
|
109
|
+
readonly negated: boolean;
|
|
110
|
+
/** This spelling is a case-parity counterpart, not a declared spelling. */
|
|
111
|
+
readonly parity: boolean;
|
|
112
|
+
}
|
|
73
113
|
/**
|
|
74
|
-
* Build a map from flag
|
|
114
|
+
* Build a map from flag spelling → {@link FlagLookupEntry}.
|
|
75
115
|
*
|
|
76
|
-
*
|
|
116
|
+
* Covers canonical names, aliases (long + single-char), negated spellings of
|
|
117
|
+
* `.negatable()` booleans, and — unless `caseParity` is `false` — the
|
|
118
|
+
* kebab↔camel counterpart of every declared spelling. Counterparts never
|
|
119
|
+
* override declared spellings: when a command defines both `do-this` and
|
|
120
|
+
* `doThis` explicitly, each spelling exact-matches its own flag and no
|
|
121
|
+
* parity entries are added for the pair.
|
|
77
122
|
*
|
|
78
123
|
* @param flags - Flag schemas keyed by canonical name
|
|
79
|
-
* @
|
|
124
|
+
* @param options - Parity toggle (see {@link ParseOptions})
|
|
125
|
+
* @returns Lookup map covering all resolvable spellings
|
|
80
126
|
*/
|
|
81
|
-
declare function buildFlagLookup(flags: Readonly<Record<string, FlagSchema
|
|
127
|
+
declare function buildFlagLookup(flags: Readonly<Record<string, FlagSchema>>, options?: ParseOptions): ReadonlyMap<string, FlagLookupEntry>;
|
|
82
128
|
/**
|
|
83
129
|
* Whether a flag kind expects a value argument (vs. being a bare boolean).
|
|
84
130
|
*
|
|
@@ -95,6 +141,7 @@ declare function flagExpectsValue(schema: FlagSchema): boolean;
|
|
|
95
141
|
*
|
|
96
142
|
* @param schema - The command schema to parse against
|
|
97
143
|
* @param argv - Raw argv strings (NOT including the command name itself)
|
|
144
|
+
* @param options - Parser behavior toggles (see {@link ParseOptions})
|
|
98
145
|
* @returns Parsed flag and arg values
|
|
99
146
|
* @throws ParseError for unknown flags, missing values, type mismatches
|
|
100
147
|
*
|
|
@@ -104,6 +151,6 @@ declare function flagExpectsValue(schema: FlagSchema): boolean;
|
|
|
104
151
|
* // => { args: { target: 'production' }, flags: { force: true } }
|
|
105
152
|
* ```
|
|
106
153
|
*/
|
|
107
|
-
declare function parse(schema: CommandSchema, argv: readonly string[]): ParseResult;
|
|
154
|
+
declare function parse(schema: CommandSchema, argv: readonly string[], options?: ParseOptions): ParseResult;
|
|
108
155
|
//#endregion
|
|
109
|
-
export { type ParseResult, type Token, buildFlagLookup, flagExpectsValue, includesBeforeSeparator, parse, tokenize };
|
|
156
|
+
export { type FlagLookupEntry, type ParseOptions, type ParseResult, type Token, buildFlagLookup, camelToKebab, flagExpectsValue, includesBeforeSeparator, kebabToCamel, parse, stripBeforeSeparator, tokenize };
|