@kjanat/dreamcli 3.0.1 → 4.0.0-rc.2
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 +962 -1
- package/README.md +7 -3
- package/dist/core/cli/builtins.d.mts +47 -0
- package/dist/core/cli/builtins.mjs +135 -0
- package/dist/core/cli/compiled.d.mts +29 -0
- package/dist/core/cli/compiled.mjs +76 -0
- package/dist/core/cli/dispatch.d.mts +9 -85
- package/dist/core/cli/help-links.d.mts +2 -14
- package/dist/core/cli/index.d.mts +282 -101
- package/dist/core/cli/index.mjs +497 -264
- package/dist/core/cli/planner.d.mts +13 -86
- package/dist/core/cli/planner.mjs +47 -30
- package/dist/core/cli/plugin.d.mts +1 -1
- package/dist/core/cli/propagate.mjs +1 -1
- package/dist/core/cli/reserved-flags.d.mts +1 -0
- package/dist/core/cli/reserved-flags.mjs +158 -0
- package/dist/core/cli/root-help.d.mts +1 -47
- package/dist/core/cli/root-help.mjs +37 -47
- package/dist/core/cli/root-output-flags.d.mts +1 -0
- package/dist/core/cli/root-output-flags.mjs +169 -0
- package/dist/core/cli/root-surface.d.mts +1 -68
- package/dist/core/cli/root-surface.mjs +2 -2
- package/dist/core/cli/runtime-preflight.d.mts +1 -199
- package/dist/core/cli/runtime-preflight.mjs +67 -17
- package/dist/core/completion/index.d.mts +2 -2
- package/dist/core/completion/shells/bash.d.mts +0 -1
- package/dist/core/completion/shells/bash.mjs +2 -1
- package/dist/core/completion/shells/fish.d.mts +0 -1
- package/dist/core/completion/shells/fish.mjs +2 -1
- package/dist/core/completion/shells/powershell.d.mts +0 -1
- package/dist/core/completion/shells/powershell.mjs +2 -1
- package/dist/core/completion/shells/shared.d.mts +3 -114
- package/dist/core/completion/shells/shared.mjs +9 -39
- package/dist/core/completion/shells/zsh.d.mts +0 -1
- package/dist/core/completion/shells/zsh.mjs +2 -1
- package/dist/core/config/index.d.mts +3 -3
- package/dist/core/config/index.mjs +2 -2
- package/dist/core/config/package-json.d.mts +2 -33
- package/dist/core/config/package-json.mjs +1 -34
- package/dist/core/errors/index.d.mts +7 -7
- package/dist/core/execution/index.d.mts +1 -48
- package/dist/core/execution/index.mjs +42 -27
- package/dist/core/help/ansi.d.mts +0 -11
- package/dist/core/help/index.d.mts +3 -35
- package/dist/core/help/index.mjs +29 -6
- package/dist/core/help/theme.d.mts +1 -21
- package/dist/core/json-schema/index.d.mts +279 -10
- package/dist/core/json-schema/index.mjs +482 -237
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +79 -7
- package/dist/core/json-schema/meta-descriptions.generated.mjs +40 -6
- package/dist/core/output/activity.d.mts +1 -193
- package/dist/core/output/activity.mjs +1 -1
- package/dist/core/output/bind.d.mts +1 -37
- package/dist/core/output/contracts.d.mts +7 -13
- package/dist/core/output/contracts.mjs +1 -1
- package/dist/core/output/display-value.d.mts +1 -19
- package/dist/core/output/index.d.mts +5 -187
- package/dist/core/output/index.mjs +44 -9
- package/dist/core/output/renderers.d.mts +1 -45
- package/dist/core/output/writer.d.mts +0 -1
- package/dist/core/parse/index.d.mts +27 -5
- package/dist/core/parse/index.mjs +350 -227
- package/dist/core/parse/occurrences.d.mts +89 -0
- package/dist/core/parse/occurrences.mjs +114 -0
- package/dist/core/prompt/index.d.mts +3 -3
- package/dist/core/read-flags/index.d.mts +150 -0
- package/dist/core/read-flags/index.mjs +217 -0
- package/dist/core/resolve/args.d.mts +35 -4
- package/dist/core/resolve/args.mjs +132 -55
- package/dist/core/resolve/coerce.d.mts +66 -9
- package/dist/core/resolve/coerce.mjs +834 -270
- package/dist/core/resolve/config.d.mts +1 -10
- package/dist/core/resolve/contracts.d.mts +67 -44
- package/dist/core/resolve/errors.mjs +29 -21
- package/dist/core/resolve/flags.d.mts +36 -9
- package/dist/core/resolve/flags.mjs +129 -151
- package/dist/core/resolve/index.d.mts +8 -6
- package/dist/core/resolve/index.mjs +51 -18
- package/dist/core/resolve/path-checks.d.mts +47 -0
- package/dist/core/resolve/path-checks.mjs +102 -0
- package/dist/core/resolve/redaction.d.mts +12 -0
- package/dist/core/resolve/redaction.mjs +14 -0
- package/dist/core/resolve/stages.d.mts +85 -0
- package/dist/core/resolve/stages.mjs +170 -0
- package/dist/core/resolve/standard.d.mts +1 -24
- package/dist/core/resolve/standard.mjs +141 -43
- package/dist/core/schema/activity.d.mts +16 -16
- package/dist/core/schema/arg.d.mts +849 -71
- package/dist/core/schema/arg.mjs +727 -54
- package/dist/core/schema/brand.d.mts +17 -0
- package/dist/core/schema/cardinality.d.mts +301 -0
- package/dist/core/schema/cardinality.mjs +514 -0
- package/dist/core/schema/command.d.mts +173 -119
- package/dist/core/schema/command.mjs +305 -42
- package/dist/core/schema/flag.d.mts +515 -173
- package/dist/core/schema/flag.mjs +576 -78
- package/dist/core/schema/index.d.mts +11 -8
- package/dist/core/schema/index.mjs +10 -0
- package/dist/core/schema/middleware.d.mts +15 -12
- package/dist/core/schema/number-constraints.d.mts +5 -5
- package/dist/core/schema/prompt.d.mts +4 -4
- package/dist/core/schema/provenance.d.mts +99 -0
- package/dist/core/schema/provenance.mjs +28 -0
- package/dist/core/schema/run.d.mts +21 -60
- package/dist/core/schema/source.d.mts +179 -0
- package/dist/core/schema/source.mjs +206 -0
- package/dist/core/schema/standard.d.mts +12 -19
- package/dist/core/schema/stdin.d.mts +87 -0
- package/dist/core/schema/stdin.mjs +91 -0
- package/dist/core/schema/string-constraints.d.mts +16 -5
- package/dist/core/schema/string-constraints.mjs +18 -1
- package/dist/core/schema/value-parsers.d.mts +81 -9
- package/dist/core/schema/value-parsers.mjs +19 -1
- package/dist/core/schema/value.d.mts +242 -0
- package/dist/core/schema/value.mjs +573 -0
- package/dist/core/testkit/index.d.mts +30 -3
- package/dist/core/testkit/index.mjs +40 -26
- package/dist/index.d.mts +21 -16
- package/dist/index.mjs +10 -6
- package/dist/runtime/adapter.d.mts +3 -3
- package/dist/runtime/deno.d.mts +3 -3
- package/dist/runtime/detect.d.mts +2 -2
- package/dist/runtime/node.d.mts +3 -3
- package/dist/runtime/paths.d.mts +1 -31
- package/dist/runtime.d.mts +4 -4
- package/dist/strings.d.mts +1 -16
- package/dist/testkit.d.mts +2 -2
- package/dist/testkit.mjs +1 -1
- package/dist/version.d.mts +0 -13
- package/dist/version.mjs +2 -2
- package/dreamcli.schema.json +368 -78
- package/examples/interactive.ts +6 -5
- package/package.json +12 -11
- package/skills/cli-creation/SKILL.md +72 -16
- package/skills/cli-creation/references/pattern-cookbook.md +169 -11
- package/dist/core/resolve/property.d.mts +0 -51
- package/dist/core/resolve/property.mjs +0 -53
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { NumberConstraints } from "../schema/number-constraints.mjs";
|
|
2
|
+
import { PromptKind } from "../schema/prompt.mjs";
|
|
3
|
+
import { DuplicatePolicy, FlagKind, FlagPresence } from "../schema/flag.mjs";
|
|
4
|
+
import { DuplicateKeys } from "../schema/cardinality.mjs";
|
|
5
|
+
import { ArgKind, ArgPresence } from "../schema/arg.mjs";
|
|
1
6
|
import { CommandSchema, ExampleMeta } from "../schema/command.mjs";
|
|
2
7
|
import "../schema/index.mjs";
|
|
3
8
|
import { CLISchema } from "../cli/index.mjs";
|
|
@@ -33,13 +38,274 @@ interface JsonSchemaOptions {
|
|
|
33
38
|
*/
|
|
34
39
|
readonly includePrompts?: boolean;
|
|
35
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* `$schema` URL for definition documents.
|
|
43
|
+
*
|
|
44
|
+
* Self-hosted. The `v1` segment is the definition format version, the value
|
|
45
|
+
* every document reports as `schemaVersion`, so it resolves for every package
|
|
46
|
+
* release that emits `schemaVersion: 1`. Two mirrors carry identical bytes:
|
|
47
|
+
* `./node_modules/@kjanat/dreamcli/dreamcli.schema.json` for offline or
|
|
48
|
+
* local-first workflows, and
|
|
49
|
+
* `https://cdn.jsdelivr.net/npm/@kjanat/dreamcli/dreamcli.schema.json` on the
|
|
50
|
+
* npm CDN.
|
|
51
|
+
*/
|
|
52
|
+
declare const DEFINITION_SCHEMA_URL = "https://dreamcli.kjanat.dev/schemas/definition/v1.schema.json";
|
|
53
|
+
/**
|
|
54
|
+
* Version of the definition document format emitted by {@link generateSchema}
|
|
55
|
+
* and {@link generateCommandSchema}.
|
|
56
|
+
*/
|
|
57
|
+
declare const DEFINITION_SCHEMA_VERSION = 1;
|
|
58
|
+
/**
|
|
59
|
+
* A usage example inside a definition document.
|
|
60
|
+
*
|
|
61
|
+
* Function-form examples are resolved to strings during serialization.
|
|
62
|
+
*/
|
|
63
|
+
type ExampleDefinitionFragmentV1 = {
|
|
64
|
+
readonly command: string;
|
|
65
|
+
readonly description?: string;
|
|
66
|
+
};
|
|
67
|
+
/** A selectable choice of a `select` or `multiselect` prompt fragment. */
|
|
68
|
+
type PromptChoiceFragmentV1 = {
|
|
69
|
+
readonly value: string;
|
|
70
|
+
readonly label?: string;
|
|
71
|
+
readonly description?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Prompt configuration attached to a flag fragment.
|
|
75
|
+
*
|
|
76
|
+
* Validation callbacks are dropped. Only the serializable description of the
|
|
77
|
+
* prompt survives.
|
|
78
|
+
*/
|
|
79
|
+
type PromptDefinitionFragmentV1 = {
|
|
80
|
+
readonly kind: PromptKind;
|
|
81
|
+
readonly message: string;
|
|
82
|
+
readonly placeholder?: string;
|
|
83
|
+
readonly choices?: readonly PromptChoiceFragmentV1[];
|
|
84
|
+
readonly min?: number;
|
|
85
|
+
readonly max?: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Stdin binding of a flag or arg fragment.
|
|
89
|
+
*
|
|
90
|
+
* Every field is always written, so a document states the trigger, the sharing
|
|
91
|
+
* mode, and the trimming without a reader having to know the builder's defaults.
|
|
92
|
+
*/
|
|
93
|
+
type StdinBindingFragmentV1 = {
|
|
94
|
+
readonly when: "dash" | "missing" | "dash-or-missing";
|
|
95
|
+
readonly consume: "exclusive" | "broadcast";
|
|
96
|
+
readonly trim: boolean;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* How one source's text decodes into collection elements.
|
|
100
|
+
*
|
|
101
|
+
* A delimiter carries its own literal; every other format is named alone.
|
|
102
|
+
*/
|
|
103
|
+
type SplitPolicyFragmentV1 = {
|
|
104
|
+
readonly format: "whole";
|
|
105
|
+
} | {
|
|
106
|
+
readonly format: "delimiter";
|
|
107
|
+
readonly delimiter: string;
|
|
108
|
+
} | {
|
|
109
|
+
readonly format: "lines";
|
|
110
|
+
} | {
|
|
111
|
+
readonly format: "json";
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Non-CLI split policies of a collection fragment.
|
|
115
|
+
*
|
|
116
|
+
* The CLI delimiter is the fragment's own `separator`. A source absent here
|
|
117
|
+
* takes its default: comma-delimited for env, line-delimited for stdin.
|
|
118
|
+
*/
|
|
119
|
+
type SourceSplitFragmentV1 = {
|
|
120
|
+
readonly env?: SplitPolicyFragmentV1;
|
|
121
|
+
readonly stdin?: SplitPolicyFragmentV1;
|
|
122
|
+
};
|
|
123
|
+
/** Negated-spelling settings of a boolean flag fragment. */
|
|
124
|
+
type FlagNegationFragmentV1 = {
|
|
125
|
+
readonly alias?: string;
|
|
126
|
+
readonly hidden?: true;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* String constraints of a flag or arg fragment, with the pattern split into
|
|
130
|
+
* source and flags.
|
|
131
|
+
*/
|
|
132
|
+
type FlagStringConstraintsFragmentV1 = {
|
|
133
|
+
readonly nonEmpty?: boolean;
|
|
134
|
+
readonly minLength?: number;
|
|
135
|
+
readonly maxLength?: number;
|
|
136
|
+
readonly pattern?: {
|
|
137
|
+
readonly source: string;
|
|
138
|
+
readonly flags: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/** Filesystem expectations of a flag or arg fragment. */
|
|
142
|
+
type FlagPathChecksFragmentV1 = {
|
|
143
|
+
readonly mustExist: boolean;
|
|
144
|
+
readonly type?: "file" | "directory";
|
|
145
|
+
readonly create?: true;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* A flag entry inside a definition document.
|
|
149
|
+
*
|
|
150
|
+
* Optional fields appear only when the flag sets them; `defaultValue` appears
|
|
151
|
+
* only when the value survives a JSON round-trip.
|
|
152
|
+
*/
|
|
153
|
+
type FlagDefinitionFragmentV1 = {
|
|
154
|
+
readonly kind: FlagKind;
|
|
155
|
+
readonly presence: FlagPresence;
|
|
156
|
+
readonly defaultValue?: unknown;
|
|
157
|
+
readonly aliases?: readonly string[];
|
|
158
|
+
readonly stdin?: StdinBindingFragmentV1;
|
|
159
|
+
readonly envVar?: string;
|
|
160
|
+
readonly configPath?: string;
|
|
161
|
+
readonly description?: string;
|
|
162
|
+
readonly enumValues?: readonly string[];
|
|
163
|
+
readonly numberConstraints?: NumberConstraints;
|
|
164
|
+
readonly stringConstraints?: FlagStringConstraintsFragmentV1;
|
|
165
|
+
readonly elementSchema?: FlagDefinitionFragmentV1;
|
|
166
|
+
readonly separator?: string;
|
|
167
|
+
readonly split?: SourceSplitFragmentV1;
|
|
168
|
+
readonly duplicateKeys?: DuplicateKeys;
|
|
169
|
+
readonly unique?: true;
|
|
170
|
+
readonly pathChecks?: FlagPathChecksFragmentV1;
|
|
171
|
+
readonly valueHint?: string;
|
|
172
|
+
readonly prompt?: PromptDefinitionFragmentV1;
|
|
173
|
+
readonly deprecated?: string | true;
|
|
174
|
+
readonly propagate?: true;
|
|
175
|
+
readonly negation?: FlagNegationFragmentV1;
|
|
176
|
+
readonly duplicates?: DuplicatePolicy;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* The supported value-axis fields of an entries arg's `elementSchema`.
|
|
180
|
+
*
|
|
181
|
+
* Entry values have a codec, constraints, path checks, and a value hint. They
|
|
182
|
+
* do not independently declare sources, presence, metadata, collections, or
|
|
183
|
+
* another key-value layer.
|
|
184
|
+
*/
|
|
185
|
+
type ArgElementFragmentV1 = {
|
|
186
|
+
readonly kind: Exclude<ArgKind, "keyValue">;
|
|
187
|
+
/** Entry values are required once their containing key-value argument is present. */
|
|
188
|
+
readonly presence: "required";
|
|
189
|
+
readonly enumValues?: readonly string[];
|
|
190
|
+
readonly numberConstraints?: NumberConstraints;
|
|
191
|
+
readonly stringConstraints?: FlagStringConstraintsFragmentV1;
|
|
192
|
+
readonly pathChecks?: FlagPathChecksFragmentV1;
|
|
193
|
+
readonly valueHint?: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* A positional arg entry inside a definition document.
|
|
197
|
+
*
|
|
198
|
+
* Array order carries the CLI position.
|
|
199
|
+
*/
|
|
200
|
+
type ArgDefinitionFragmentV1 = {
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly kind: ArgKind;
|
|
203
|
+
readonly presence: ArgPresence;
|
|
204
|
+
readonly variadic?: true;
|
|
205
|
+
readonly stdin?: StdinBindingFragmentV1;
|
|
206
|
+
readonly defaultValue?: unknown;
|
|
207
|
+
readonly description?: string;
|
|
208
|
+
readonly envVar?: string;
|
|
209
|
+
readonly configPath?: string;
|
|
210
|
+
readonly enumValues?: readonly string[];
|
|
211
|
+
readonly elementSchema?: ArgElementFragmentV1;
|
|
212
|
+
readonly numberConstraints?: NumberConstraints;
|
|
213
|
+
readonly stringConstraints?: FlagStringConstraintsFragmentV1;
|
|
214
|
+
readonly pathChecks?: FlagPathChecksFragmentV1;
|
|
215
|
+
readonly valueHint?: string;
|
|
216
|
+
readonly separator?: string;
|
|
217
|
+
readonly split?: SourceSplitFragmentV1;
|
|
218
|
+
readonly duplicateKeys?: DuplicateKeys;
|
|
219
|
+
readonly unique?: true;
|
|
220
|
+
readonly prompt?: PromptDefinitionFragmentV1;
|
|
221
|
+
readonly deprecated?: string | true;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* A command nested inside a definition document.
|
|
225
|
+
*
|
|
226
|
+
* Fragments carry no `schemaVersion`. They inherit the version of the document
|
|
227
|
+
* they sit in. The standalone form is {@link CommandDefinitionDocumentV1}.
|
|
228
|
+
*/
|
|
229
|
+
type CommandDefinitionFragmentV1 = {
|
|
230
|
+
/** The command name used for dispatch. */
|
|
231
|
+
readonly name: string;
|
|
232
|
+
/** Human-readable description for help text. */
|
|
233
|
+
readonly description?: string;
|
|
234
|
+
/** Alternative names accepted for this command. */
|
|
235
|
+
readonly aliases?: readonly string[];
|
|
236
|
+
/** Whether the command is omitted from help listings. */
|
|
237
|
+
readonly hidden?: true;
|
|
238
|
+
/** Usage examples attached to the command. */
|
|
239
|
+
readonly examples?: readonly ExampleDefinitionFragmentV1[];
|
|
240
|
+
/** Named flag definitions keyed by flag name. */
|
|
241
|
+
readonly flags: Readonly<Record<string, FlagDefinitionFragmentV1>>;
|
|
242
|
+
/** Positional argument definitions in CLI order. */
|
|
243
|
+
readonly args: readonly ArgDefinitionFragmentV1[];
|
|
244
|
+
/** Nested subcommand definitions. */
|
|
245
|
+
readonly commands: readonly CommandDefinitionFragmentV1[];
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* A whole-CLI definition document, version 1.
|
|
249
|
+
*
|
|
250
|
+
* Produced by {@link generateSchema}. Validated by {@link definitionMetaSchema}
|
|
251
|
+
* and served at {@link DEFINITION_SCHEMA_URL}.
|
|
252
|
+
*/
|
|
253
|
+
type DefinitionDocumentV1 = {
|
|
254
|
+
readonly $schema: string;
|
|
255
|
+
readonly schemaVersion: 1;
|
|
256
|
+
readonly name: string;
|
|
257
|
+
readonly version?: string;
|
|
258
|
+
readonly description?: string;
|
|
259
|
+
readonly defaultCommand?: CommandDefinitionFragmentV1;
|
|
260
|
+
readonly commands: readonly CommandDefinitionFragmentV1[];
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* A single-command definition document, version 1.
|
|
264
|
+
*
|
|
265
|
+
* Produced by {@link generateCommandSchema}. Same shape as a
|
|
266
|
+
* {@link CommandDefinitionFragmentV1} plus the `schemaVersion` every standalone
|
|
267
|
+
* document carries.
|
|
268
|
+
*/
|
|
269
|
+
type CommandDefinitionDocumentV1 = CommandDefinitionFragmentV1 & {
|
|
270
|
+
/** Definition document format version. */
|
|
271
|
+
readonly schemaVersion: 1;
|
|
272
|
+
};
|
|
273
|
+
/** The current whole-CLI definition document. */
|
|
274
|
+
type DefinitionDocument = DefinitionDocumentV1;
|
|
275
|
+
/** The current single-command definition document. */
|
|
276
|
+
type CommandDefinitionDocument = CommandDefinitionDocumentV1;
|
|
277
|
+
/** A JSON Schema fragment describing one flag or arg as an input property. */
|
|
278
|
+
type InputSchemaProperty = Readonly<Record<string, unknown>>;
|
|
279
|
+
/** The JSON Schema object describing one command's flags and args. */
|
|
280
|
+
type InputSchemaBranch = {
|
|
281
|
+
readonly type: "object";
|
|
282
|
+
readonly properties: Readonly<Record<string, InputSchemaProperty>>;
|
|
283
|
+
readonly additionalProperties: false;
|
|
284
|
+
readonly required?: readonly string[];
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* A JSON Schema (draft 2020-12) document produced by {@link generateInputSchema}.
|
|
288
|
+
*
|
|
289
|
+
* This document sits outside the definition-document family. It holds one
|
|
290
|
+
* branch for a single invocable command, a `oneOf` union for several, and a
|
|
291
|
+
* bare object schema when a CLI has none.
|
|
292
|
+
*/
|
|
293
|
+
type InputSchemaDocument = ({
|
|
294
|
+
readonly $schema: string;
|
|
295
|
+
} & InputSchemaBranch) | {
|
|
296
|
+
readonly $schema: string;
|
|
297
|
+
readonly oneOf: readonly InputSchemaBranch[];
|
|
298
|
+
} | {
|
|
299
|
+
readonly $schema: string;
|
|
300
|
+
readonly type: "object";
|
|
301
|
+
};
|
|
36
302
|
/**
|
|
37
303
|
* Generate a definition metadata document describing the CLI's structure.
|
|
38
304
|
*
|
|
39
305
|
* Walks the full command tree and produces a plain JSON-serializable object
|
|
40
306
|
* representing all commands, subcommands, flags, args, and metadata.
|
|
41
|
-
* Non-serializable runtime values (parse functions,
|
|
42
|
-
*
|
|
307
|
+
* Non-serializable runtime values (parse functions, interactive resolvers)
|
|
308
|
+
* are omitted.
|
|
43
309
|
*
|
|
44
310
|
* @param schema - The CLI schema from `CLIBuilder.schema`.
|
|
45
311
|
* @param options - Generation options.
|
|
@@ -54,22 +320,25 @@ interface JsonSchemaOptions {
|
|
|
54
320
|
* writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2));
|
|
55
321
|
* ```
|
|
56
322
|
*/
|
|
57
|
-
declare function generateSchema(schema: CLISchema, options?: JsonSchemaOptions, meta?: ExampleMeta):
|
|
323
|
+
declare function generateSchema(schema: CLISchema, options?: JsonSchemaOptions, meta?: ExampleMeta): DefinitionDocumentV1;
|
|
58
324
|
/**
|
|
59
325
|
* Generate the definition metadata document for a single command.
|
|
60
326
|
*
|
|
61
|
-
* The per-command counterpart of {@link generateSchema}:
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* embedding one command's definition into
|
|
327
|
+
* The per-command counterpart of {@link generateSchema}: one entry of its
|
|
328
|
+
* `commands` array (flags, args, subcommands, examples), plus the
|
|
329
|
+
* `schemaVersion` every standalone document carries. Powers `--help` in
|
|
330
|
+
* `--json` mode and is useful for embedding one command's definition into
|
|
331
|
+
* custom tooling.
|
|
65
332
|
*
|
|
66
333
|
* @param schema - The command schema to serialize.
|
|
67
334
|
* @param options - Generation options.
|
|
68
335
|
* @param meta - Program name/version for function-form examples; defaults to
|
|
69
336
|
* the command's own name with no version.
|
|
70
337
|
* @returns A plain object suitable for `JSON.stringify()`.
|
|
338
|
+
* @remarks Validate standalone output against
|
|
339
|
+
* `https://dreamcli.kjanat.dev/schemas/definition/v1.schema.json#/$defs/commandDocument`.
|
|
71
340
|
*/
|
|
72
|
-
declare function generateCommandSchema(schema: CommandSchema, options?: JsonSchemaOptions, meta?: ExampleMeta):
|
|
341
|
+
declare function generateCommandSchema(schema: CommandSchema, options?: JsonSchemaOptions, meta?: ExampleMeta): CommandDefinitionDocumentV1;
|
|
73
342
|
/**
|
|
74
343
|
* Generate a JSON Schema (draft 2020-12) for validating CLI input as JSON.
|
|
75
344
|
*
|
|
@@ -98,7 +367,7 @@ declare function generateCommandSchema(schema: CommandSchema, options?: JsonSche
|
|
|
98
367
|
* writeFileSync('input-schema.json', JSON.stringify(inputSchema, null, 2));
|
|
99
368
|
* ```
|
|
100
369
|
*/
|
|
101
|
-
declare function generateInputSchema(schema: CLISchema | CommandSchema, options?: JsonSchemaOptions):
|
|
370
|
+
declare function generateInputSchema(schema: CLISchema | CommandSchema, options?: JsonSchemaOptions): InputSchemaDocument;
|
|
102
371
|
/**
|
|
103
372
|
* JSON Schema (draft 2020-12) that validates the output of {@link generateSchema}.
|
|
104
373
|
*
|
|
@@ -118,4 +387,4 @@ declare function generateInputSchema(schema: CLISchema | CommandSchema, options?
|
|
|
118
387
|
*/
|
|
119
388
|
declare const definitionMetaSchema: Record<string, unknown>;
|
|
120
389
|
//#endregion
|
|
121
|
-
export { type JsonSchemaOptions, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };
|
|
390
|
+
export { type ArgDefinitionFragmentV1, type ArgElementFragmentV1, type CommandDefinitionDocument, type CommandDefinitionDocumentV1, type CommandDefinitionFragmentV1, DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, type DefinitionDocument, type DefinitionDocumentV1, type ExampleDefinitionFragmentV1, type FlagDefinitionFragmentV1, type FlagNegationFragmentV1, type FlagPathChecksFragmentV1, type FlagStringConstraintsFragmentV1, type InputSchemaBranch, type InputSchemaDocument, type InputSchemaProperty, type JsonSchemaOptions, type PromptChoiceFragmentV1, type PromptDefinitionFragmentV1, type SourceSplitFragmentV1, type SplitPolicyFragmentV1, type StdinBindingFragmentV1, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };
|