@kjanat/dreamcli 4.0.0-rc.3 → 4.1.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.
- package/README.md +5 -7
- package/dist/{runtime/adapter.d.mts → adapter-YM5QGi3M.d.mts} +4 -4
- package/dist/completion-CUMeOnAz.mjs +6 -0
- package/dist/completion.d.mts +90 -0
- package/dist/completion.mjs +1 -0
- package/dist/config-CrlScpYX.mjs +1 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +1 -0
- package/dist/core-DvXUolc_.mjs +17 -0
- package/dist/{core/json-schema/index.d.mts → index-3l8uj16E.d.mts} +43 -34
- package/dist/{core/cli/index.d.mts → index-BAj2y70U.d.mts} +116 -57
- package/dist/index-BziI2aKc.d.mts +5440 -0
- package/dist/index-Cap0MA2V.d.mts +277 -0
- package/dist/index-Cp9kt2t-.d.mts +370 -0
- package/dist/index-DWsnGZlx.d.mts +831 -0
- package/dist/index.d.mts +190 -41
- package/dist/index.mjs +1 -26
- package/dist/json-schema-DRlrz_IV.mjs +52 -0
- package/dist/json-schema.d.mts +2 -0
- package/dist/json-schema.mjs +1 -0
- package/dist/package-json-BgE9YjjQ.mjs +3 -0
- package/dist/prompt.d.mts +48 -0
- package/dist/prompt.mjs +1 -0
- package/dist/rolldown-runtime-G4Kt5YOX.mjs +1 -0
- package/dist/runtime.d.mts +2 -6
- package/dist/runtime.mjs +1 -6
- package/dist/terminal-C8KTXjv5.mjs +6 -0
- package/dist/test-prompter-v__jT2yG.mjs +1 -0
- package/dist/testkit.d.mts +54 -6
- package/dist/testkit.mjs +1 -5
- package/dist/version.mjs +1 -7
- package/dreamcli.schema.json +697 -538
- package/package.json +29 -7
- package/skills/cli-creation/SKILL.md +16 -11
- package/CHANGELOG.md +0 -1116
- package/dist/core/cli/builtins.d.mts +0 -117
- package/dist/core/cli/builtins.mjs +0 -135
- package/dist/core/cli/compiled.d.mts +0 -66
- package/dist/core/cli/compiled.mjs +0 -76
- package/dist/core/cli/dispatch.d.mts +0 -115
- package/dist/core/cli/dispatch.mjs +0 -205
- package/dist/core/cli/help-links.d.mts +0 -27
- package/dist/core/cli/help-links.mjs +0 -41
- package/dist/core/cli/index.mjs +0 -1271
- package/dist/core/cli/planner.d.mts +0 -174
- package/dist/core/cli/planner.mjs +0 -323
- package/dist/core/cli/plugin.d.mts +0 -94
- package/dist/core/cli/plugin.mjs +0 -41
- package/dist/core/cli/propagate.d.mts +0 -39
- package/dist/core/cli/propagate.mjs +0 -57
- package/dist/core/cli/reserved-flags.d.mts +0 -19
- package/dist/core/cli/reserved-flags.mjs +0 -158
- package/dist/core/cli/root-help.d.mts +0 -53
- package/dist/core/cli/root-help.mjs +0 -221
- package/dist/core/cli/root-output-flags.d.mts +0 -74
- package/dist/core/cli/root-output-flags.mjs +0 -169
- package/dist/core/cli/root-surface.d.mts +0 -64
- package/dist/core/cli/root-surface.mjs +0 -28
- package/dist/core/cli/runtime-preflight.d.mts +0 -213
- package/dist/core/cli/runtime-preflight.mjs +0 -221
- package/dist/core/completion/index.d.mts +0 -76
- package/dist/core/completion/index.mjs +0 -90
- package/dist/core/completion/shells/bash.d.mts +0 -23
- package/dist/core/completion/shells/bash.mjs +0 -312
- package/dist/core/completion/shells/fish.d.mts +0 -19
- package/dist/core/completion/shells/fish.mjs +0 -164
- package/dist/core/completion/shells/powershell.d.mts +0 -13
- package/dist/core/completion/shells/powershell.mjs +0 -360
- package/dist/core/completion/shells/shared.d.mts +0 -164
- package/dist/core/completion/shells/shared.mjs +0 -147
- package/dist/core/completion/shells/zsh.d.mts +0 -23
- package/dist/core/completion/shells/zsh.mjs +0 -256
- package/dist/core/config/index.d.mts +0 -191
- package/dist/core/config/index.mjs +0 -285
- package/dist/core/config/package-json.d.mts +0 -179
- package/dist/core/config/package-json.mjs +0 -353
- package/dist/core/errors/index.d.mts +0 -125
- package/dist/core/errors/index.mjs +0 -87
- package/dist/core/execution/index.d.mts +0 -61
- package/dist/core/execution/index.mjs +0 -220
- package/dist/core/help/ansi.d.mts +0 -84
- package/dist/core/help/ansi.mjs +0 -121
- package/dist/core/help/index.d.mts +0 -149
- package/dist/core/help/index.mjs +0 -418
- package/dist/core/help/theme.d.mts +0 -86
- package/dist/core/help/theme.mjs +0 -69
- package/dist/core/json-schema/index.mjs +0 -1008
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +0 -274
- package/dist/core/json-schema/meta-descriptions.generated.mjs +0 -136
- package/dist/core/output/activity.d.mts +0 -193
- package/dist/core/output/activity.mjs +0 -452
- package/dist/core/output/bind.d.mts +0 -37
- package/dist/core/output/bind.mjs +0 -56
- package/dist/core/output/contracts.d.mts +0 -82
- package/dist/core/output/contracts.mjs +0 -57
- package/dist/core/output/display-value.d.mts +0 -19
- package/dist/core/output/display-value.mjs +0 -32
- package/dist/core/output/index.d.mts +0 -344
- package/dist/core/output/index.mjs +0 -514
- package/dist/core/output/renderers.d.mts +0 -45
- package/dist/core/output/renderers.mjs +0 -46
- package/dist/core/output/writer.d.mts +0 -39
- package/dist/core/output/writer.mjs +0 -12
- package/dist/core/parse/index.d.mts +0 -178
- package/dist/core/parse/index.mjs +0 -850
- package/dist/core/parse/occurrences.d.mts +0 -90
- package/dist/core/parse/occurrences.mjs +0 -114
- package/dist/core/prompt/index.d.mts +0 -213
- package/dist/core/prompt/index.mjs +0 -348
- package/dist/core/read-flags/index.d.mts +0 -150
- package/dist/core/read-flags/index.mjs +0 -217
- package/dist/core/resolve/args.d.mts +0 -39
- package/dist/core/resolve/args.mjs +0 -182
- package/dist/core/resolve/coerce.d.mts +0 -79
- package/dist/core/resolve/coerce.mjs +0 -900
- package/dist/core/resolve/config.d.mts +0 -10
- package/dist/core/resolve/config.mjs +0 -19
- package/dist/core/resolve/contracts.d.mts +0 -146
- package/dist/core/resolve/errors.d.mts +0 -10
- package/dist/core/resolve/errors.mjs +0 -148
- package/dist/core/resolve/flags.d.mts +0 -74
- package/dist/core/resolve/flags.mjs +0 -246
- package/dist/core/resolve/index.d.mts +0 -44
- package/dist/core/resolve/index.mjs +0 -123
- package/dist/core/resolve/path-checks.d.mts +0 -48
- package/dist/core/resolve/path-checks.mjs +0 -102
- package/dist/core/resolve/redaction.d.mts +0 -13
- package/dist/core/resolve/redaction.mjs +0 -14
- package/dist/core/resolve/stages.d.mts +0 -86
- package/dist/core/resolve/stages.mjs +0 -170
- package/dist/core/resolve/standard.d.mts +0 -26
- package/dist/core/resolve/standard.mjs +0 -212
- package/dist/core/schema/activity.d.mts +0 -189
- package/dist/core/schema/arg.d.mts +0 -1461
- package/dist/core/schema/arg.mjs +0 -1139
- package/dist/core/schema/brand.d.mts +0 -17
- package/dist/core/schema/cardinality.d.mts +0 -302
- package/dist/core/schema/cardinality.mjs +0 -514
- package/dist/core/schema/command.d.mts +0 -1132
- package/dist/core/schema/command.mjs +0 -999
- package/dist/core/schema/flag.d.mts +0 -1495
- package/dist/core/schema/flag.mjs +0 -1207
- package/dist/core/schema/index.d.mts +0 -15
- package/dist/core/schema/index.mjs +0 -10
- package/dist/core/schema/middleware.d.mts +0 -129
- package/dist/core/schema/middleware.mjs +0 -41
- package/dist/core/schema/number-constraints.d.mts +0 -96
- package/dist/core/schema/number-constraints.mjs +0 -60
- package/dist/core/schema/prompt.d.mts +0 -135
- package/dist/core/schema/provenance.d.mts +0 -99
- package/dist/core/schema/provenance.mjs +0 -28
- package/dist/core/schema/run.d.mts +0 -211
- package/dist/core/schema/source.d.mts +0 -180
- package/dist/core/schema/source.mjs +0 -206
- package/dist/core/schema/standard.d.mts +0 -100
- package/dist/core/schema/standard.mjs +0 -15
- package/dist/core/schema/stdin.d.mts +0 -97
- package/dist/core/schema/stdin.mjs +0 -91
- package/dist/core/schema/string-constraints.d.mts +0 -108
- package/dist/core/schema/string-constraints.mjs +0 -86
- package/dist/core/schema/value-parsers.d.mts +0 -150
- package/dist/core/schema/value-parsers.mjs +0 -160
- package/dist/core/schema/value.d.mts +0 -243
- package/dist/core/schema/value.mjs +0 -573
- package/dist/core/testkit/index.d.mts +0 -63
- package/dist/core/testkit/index.mjs +0 -102
- package/dist/runtime/adapter.mjs +0 -92
- package/dist/runtime/auto.d.mts +0 -25
- package/dist/runtime/auto.mjs +0 -45
- package/dist/runtime/deno.d.mts +0 -99
- package/dist/runtime/deno.mjs +0 -265
- package/dist/runtime/detect.d.mts +0 -86
- package/dist/runtime/detect.mjs +0 -45
- package/dist/runtime/index.d.mts +0 -6
- package/dist/runtime/node.d.mts +0 -71
- package/dist/runtime/node.mjs +0 -228
- package/dist/runtime/paths.d.mts +0 -31
- package/dist/runtime/paths.mjs +0 -48
- package/dist/strings.d.mts +0 -27
- package/dist/strings.mjs +0 -22
- package/examples/basic.ts +0 -37
- package/examples/flag-types.ts +0 -79
- package/examples/gh/package.json +0 -45
- package/examples/gh/src/commands/auth.ts +0 -66
- package/examples/gh/src/commands/issue.ts +0 -120
- package/examples/gh/src/commands/pr.ts +0 -125
- package/examples/gh/src/data/issues.yaml +0 -5
- package/examples/gh/src/data/issues.yaml.d.ts +0 -17
- package/examples/gh/src/data/pull-requests.yaml +0 -7
- package/examples/gh/src/data/pull-requests.yaml.d.ts +0 -18
- package/examples/gh/src/docs.ts +0 -11
- package/examples/gh/src/lib/auth.ts +0 -37
- package/examples/gh/src/lib/utils.ts +0 -17
- package/examples/gh/src/main.test.ts +0 -307
- package/examples/gh/src/main.ts +0 -46
- package/examples/help-config.ts +0 -43
- package/examples/interactive.ts +0 -67
- package/examples/json-mode.ts +0 -95
- package/examples/middleware.ts +0 -71
- package/examples/multi-command.ts +0 -66
- package/examples/output-extras.ts +0 -46
- package/examples/parser-control.ts +0 -40
- package/examples/pwsh-demo/README.md +0 -40
- package/examples/pwsh-demo/package.json +0 -41
- package/examples/pwsh-demo/pwsh-demo.cmd +0 -3
- package/examples/pwsh-demo/smoke-powershell.ps1 +0 -218
- package/examples/pwsh-demo/src/main.test.ts +0 -45
- package/examples/pwsh-demo/src/main.ts +0 -140
- package/examples/spinner-progress.ts +0 -49
- package/examples/standard-schema.ts +0 -45
- package/examples/testing.ts +0 -147
- package/examples/transport-launcher.ts +0 -85
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { FlagSchema } from "../schema/flag.mjs";
|
|
2
|
-
import { CommandSchema } from "../schema/command.mjs";
|
|
3
|
-
import "../schema/index.mjs";
|
|
4
|
-
//#region src/core/parse/index.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Token discriminated union.
|
|
7
|
-
*
|
|
8
|
-
* The tokenizer produces these from raw argv strings. The parser then
|
|
9
|
-
* interprets them against a command schema.
|
|
10
|
-
*/
|
|
11
|
-
type Token = {
|
|
12
|
-
readonly kind: 'long-flag';
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly value: string | undefined;
|
|
15
|
-
} | {
|
|
16
|
-
readonly kind: 'short-flags';
|
|
17
|
-
readonly chars: string;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: 'positional';
|
|
20
|
-
readonly value: string;
|
|
21
|
-
} | {
|
|
22
|
-
readonly kind: 'separator';
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Tokenize raw argv into structured tokens.
|
|
26
|
-
*
|
|
27
|
-
* Low-level utility: most apps should use {@link parse}, `cli().run()`, or
|
|
28
|
-
* `runCommand()` instead of tokenizing manually. Reach for `tokenize()` when
|
|
29
|
-
* building custom tooling such as debuggers, inspectors, or parser tests.
|
|
30
|
-
*
|
|
31
|
-
* Rules:
|
|
32
|
-
* - `--` → separator (everything after is positional)
|
|
33
|
-
* - `--flag` → long flag, no inline value
|
|
34
|
-
* - `--flag=v` → long flag with inline value
|
|
35
|
-
* - `-abc` → short flags (expanded individually by parser)
|
|
36
|
-
* - `-` → positional (convention: stdin placeholder)
|
|
37
|
-
* - everything else → positional
|
|
38
|
-
*
|
|
39
|
-
* @param argv - Raw argument strings to tokenize
|
|
40
|
-
* @returns Ordered token array ready for {@link parse}
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* tokenize(['deploy', '--force', '--region=eu', '-v']);
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
declare function tokenize(argv: readonly string[]): readonly Token[];
|
|
48
|
-
/**
|
|
49
|
-
* Whether `token` appears in argv before the `--` end-of-options separator.
|
|
50
|
-
*
|
|
51
|
-
* Everything at or after the first `--` is a literal positional, so root-level
|
|
52
|
-
* flag interception (`--help` / `--version` / `--json`) must use this instead of
|
|
53
|
-
* a naive `Array.includes()` — otherwise a post-separator literal (`-- --json`)
|
|
54
|
-
* is wrongly treated as the flag.
|
|
55
|
-
*
|
|
56
|
-
* @param argv - Raw argument strings.
|
|
57
|
-
* @param token - Exact flag token to look for (e.g. `--version`).
|
|
58
|
-
* @returns `true` if `token` occurs before any `--` separator.
|
|
59
|
-
*/
|
|
60
|
-
declare function includesBeforeSeparator(argv: readonly string[], token: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Whether argv asks for help before the `--` end-of-options separator.
|
|
63
|
-
*
|
|
64
|
-
* Help renders ahead of flag validation everywhere: a command short-circuits to
|
|
65
|
-
* its help text before `parse()` runs, and the root does the same before
|
|
66
|
-
* dispatch, so a malformed flag value never hides the text explaining the flags.
|
|
67
|
-
*
|
|
68
|
-
* @param argv - Raw argument strings.
|
|
69
|
-
* @returns `true` if `--help` or `-h` occurs before any `--` separator.
|
|
70
|
-
*/
|
|
71
|
-
declare function requestsHelp(argv: readonly string[]): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Remove every occurrence of `token` that appears before the `--` end-of-options
|
|
74
|
-
* separator, leaving post-separator literals untouched.
|
|
75
|
-
*
|
|
76
|
-
* The strip counterpart to {@linkcode includesBeforeSeparator}: root-level flags
|
|
77
|
-
* (`--json`) are stripped before dispatch/parse so the command schema never sees
|
|
78
|
-
* them, but a literal after `--` (`-- --json`) must reach the command unchanged.
|
|
79
|
-
*
|
|
80
|
-
* @param argv - Raw argument strings.
|
|
81
|
-
* @param token - Exact flag token to strip (e.g. `--json`).
|
|
82
|
-
* @returns A new argv with pre-separator occurrences of `token` removed, or the
|
|
83
|
-
* original reference when `token` does not occur before the separator.
|
|
84
|
-
*/
|
|
85
|
-
declare function stripBeforeSeparator(argv: readonly string[], token: string): readonly string[];
|
|
86
|
-
/**
|
|
87
|
-
* Raw parsed values before resolution (defaults, env, config, etc.).
|
|
88
|
-
*
|
|
89
|
-
* Flag values are `unknown` because type coercion happens here but the
|
|
90
|
-
* generic type info lives in the schema builders, not at runtime.
|
|
91
|
-
*/
|
|
92
|
-
interface ParseResult {
|
|
93
|
-
/** Flag values keyed by canonical flag name. */
|
|
94
|
-
readonly flags: Readonly<Record<string, unknown>>;
|
|
95
|
-
/** Positional arg values keyed by arg name. */
|
|
96
|
-
readonly args: Readonly<Record<string, unknown>>;
|
|
97
|
-
}
|
|
98
|
-
/** Options accepted by {@link parse} and {@link buildFlagLookup}. */
|
|
99
|
-
interface ParseOptions {
|
|
100
|
-
/**
|
|
101
|
-
* Accept the kebab↔camel counterpart spelling of each flag name/alias
|
|
102
|
-
* (`--doThis` for a flag named `do-this`, and vice versa). Automatically
|
|
103
|
-
* disabled per spelling pair when a command explicitly defines both.
|
|
104
|
-
*
|
|
105
|
-
* @defaultValue `true`
|
|
106
|
-
*/
|
|
107
|
-
readonly caseParity?: boolean;
|
|
108
|
-
}
|
|
109
|
-
/** `do-this` → `doThis`. Returns the input unchanged when nothing converts. */
|
|
110
|
-
declare function kebabToCamel(name: string): string;
|
|
111
|
-
/** `doThis` → `do-this`. Returns the input unchanged when nothing converts. */
|
|
112
|
-
declare function camelToKebab(name: string): string;
|
|
113
|
-
/** One resolvable spelling in the flag lookup map. */
|
|
114
|
-
interface FlagLookupEntry {
|
|
115
|
-
/** Canonical flag name (the key in the command's flag record). */
|
|
116
|
-
readonly name: string;
|
|
117
|
-
/** The flag's schema. */
|
|
118
|
-
readonly schema: FlagSchema;
|
|
119
|
-
/** This spelling is the flag's negated form (`--no-foo`) — parses to `false`. */
|
|
120
|
-
readonly negated: boolean;
|
|
121
|
-
/** This spelling is a case-parity counterpart, not a declared spelling. */
|
|
122
|
-
readonly parity: boolean;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Build a map from flag spelling → {@link FlagLookupEntry}.
|
|
126
|
-
*
|
|
127
|
-
* Covers canonical names, aliases (long + single-char), negated spellings of
|
|
128
|
-
* `.negatable()` booleans, and — unless `caseParity` is `false` — the
|
|
129
|
-
* kebab↔camel counterpart of every declared spelling. Counterparts never
|
|
130
|
-
* override declared spellings: when a command defines both `do-this` and
|
|
131
|
-
* `doThis` explicitly, each spelling exact-matches its own flag and no
|
|
132
|
-
* parity entries are added for the pair.
|
|
133
|
-
*
|
|
134
|
-
* @param flags - Flag schemas keyed by canonical name
|
|
135
|
-
* @param options - Parity toggle (see {@link ParseOptions})
|
|
136
|
-
* @returns Lookup map covering all resolvable spellings
|
|
137
|
-
*/
|
|
138
|
-
declare function buildFlagLookup(flags: Readonly<Record<string, FlagSchema>>, options?: ParseOptions): ReadonlyMap<string, FlagLookupEntry>;
|
|
139
|
-
/**
|
|
140
|
-
* Whether a flag kind expects a value argument (vs. being a bare boolean).
|
|
141
|
-
*
|
|
142
|
-
* @param schema - Flag schema to check
|
|
143
|
-
* @returns `true` if the flag expects a value token after it
|
|
144
|
-
*/
|
|
145
|
-
declare function flagExpectsValue(schema: FlagSchema): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Coerce one raw CLI token to what the flag's value axis declares.
|
|
148
|
-
*
|
|
149
|
-
* @param flagName - Canonical flag name (for error messages)
|
|
150
|
-
* @param raw - Raw string value from argv
|
|
151
|
-
* @param schema - {@link FlagSchema} declaring the expected kind
|
|
152
|
-
* @param displayName - Spelling the user typed
|
|
153
|
-
* @returns The coerced token: a value, an element, or a `[key, value]` pair
|
|
154
|
-
* @throws ParseError on type mismatch
|
|
155
|
-
*/
|
|
156
|
-
declare function coerceFlagValue(flagName: string, raw: string, schema: FlagSchema, displayName?: string): unknown;
|
|
157
|
-
/**
|
|
158
|
-
* Parse tokenized argv against a command schema.
|
|
159
|
-
*
|
|
160
|
-
* Low-level API: most apps should let `cli()` or `runCommand()` handle parsing
|
|
161
|
-
* automatically. Call `parse()` directly when you need raw parsed values before
|
|
162
|
-
* env/config/default resolution or when writing custom tooling around schemas.
|
|
163
|
-
*
|
|
164
|
-
* @param schema - The command schema to parse against
|
|
165
|
-
* @param argv - Raw argv strings (NOT including the command name itself)
|
|
166
|
-
* @param options - Parser behavior toggles (see {@link ParseOptions})
|
|
167
|
-
* @returns Parsed flag and arg values
|
|
168
|
-
* @throws ParseError for unknown flags, missing values, type mismatches
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```ts
|
|
172
|
-
* const parsed = parse(deploy.schema, ['production', '--force']);
|
|
173
|
-
* // => { args: { target: 'production' }, flags: { force: true } }
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
declare function parse(schema: CommandSchema, argv: readonly string[], options?: ParseOptions): ParseResult;
|
|
177
|
-
//#endregion
|
|
178
|
-
export { type FlagLookupEntry, type ParseOptions, type ParseResult, type Token, buildFlagLookup, camelToKebab, coerceFlagValue, flagExpectsValue, includesBeforeSeparator, kebabToCamel, parse, requestsHelp, stripBeforeSeparator, tokenize };
|