@kjanat/dreamcli 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{index-CuhI1Ynv.d.mts → command-Cq6YZjEH.d.mts} +1693 -1591
  2. package/dist/completion-DCWRvQjQ.mjs +59 -0
  3. package/dist/completion.d.mts +1 -1
  4. package/dist/completion.mjs +1 -1
  5. package/dist/{config-DSh3QJpX.mjs → config-CANc4lsA.mjs} +1 -1
  6. package/dist/config.d.mts +2 -2
  7. package/dist/config.mjs +1 -1
  8. package/dist/core-CPh0FcFg.mjs +25 -0
  9. package/dist/dynamic-xPNS3_vL.mjs +1 -0
  10. package/dist/{index-DIWRV_wp.d.mts → index-8EiEDJfX.d.mts} +33 -7
  11. package/dist/{index-DDhRLoTu.d.mts → index-BZ3jYjyh.d.mts} +12 -3
  12. package/dist/{index-Vjl2_m23.d.mts → index-Bkk86gFg.d.mts} +16 -11
  13. package/dist/{index-aTmg9yfl.d.mts → index-CLg6j-KJ.d.mts} +1 -1
  14. package/dist/{index-CLtWJqwn.d.mts → index-DBepo8jX.d.mts} +23 -4
  15. package/dist/index.d.mts +9 -9
  16. package/dist/index.mjs +1 -1
  17. package/dist/json-schema-DmFJR8c6.mjs +59 -0
  18. package/dist/json-schema.d.mts +1 -1
  19. package/dist/json-schema.mjs +1 -1
  20. package/dist/prompt.d.mts +1 -1
  21. package/dist/prompt.mjs +1 -1
  22. package/dist/runtime.d.mts +2 -2
  23. package/dist/runtime.mjs +1 -1
  24. package/dist/{session-BEKj0yLA.mjs → session-BBRg9p2u.mjs} +1 -1
  25. package/dist/{terminal-Dws_b5UK.mjs → terminal-mINn5p7B.mjs} +1 -1
  26. package/dist/{test-prompter-euLYzWWO.mjs → test-prompter-BI9sA9n7.mjs} +1 -1
  27. package/dist/testkit.d.mts +3 -3
  28. package/dist/testkit.mjs +1 -1
  29. package/dist/version.mjs +1 -1
  30. package/dreamcli.schema.json +175 -0
  31. package/package.json +9 -10
  32. package/dist/completion-B4oRc2Ae.mjs +0 -59
  33. package/dist/core-BZx351-p.mjs +0 -21
  34. package/dist/dynamic-BK2lQF2M.mjs +0 -1
  35. package/dist/json-schema-CYgq_hFu.mjs +0 -59
@@ -1,59 +0,0 @@
1
- import{t as __exportAll}from"./rolldown-runtime-DOYBPklu.mjs";import{F as resolvePlainHelpDescription,X as resolveExampleCommand,a as DEFINITION_SCHEMA_URL,ot as DUPLICATE_KEYS,rt as getFlagAliasNames}from"./core-BZx351-p.mjs";const definitionMetaSchemaDescriptions={root:{description:`Runtime descriptor for the CLI program.
2
-
3
- Stores the program name, version, description, and registered command schemas.\\
4
- Sealed by createCLISchema and rebuilt by each CLIBuilder step.`,properties:{name:{description:`Program name (used in help text, usage lines, and completion scripts).`},version:{description:"Program version (shown by `--version`)."},description:{description:`Program description (shown in root help).`},envPrefix:{description:"CLI-wide environment namespace prepended to every relative env binding\n(`undefined` when none is set). `.env('TOKEN')` reads `<envPrefix>TOKEN`;\na binding declared with `{ absolute: true }` is read as written.\n\nSet via the .envPrefix() builder method\nor the `envPrefix` field of CLIDefinition. Fixed when declared, so\nneither manifest name inference nor an inherited invocation name changes it."},defaultCommand:{description:`Schema of the default command dispatched when no subcommand matches.
5
-
6
- When set, the CLI root behaves like a hybrid command group: subcommands
7
- dispatch by name as usual, but empty argv or flags-only argv falls
8
- through to this command instead of showing root help.
9
-
10
- Set via the .default() builder method
11
- or the \`defaultCommand\` field of CLIDefinition.`},commands:{description:`Schemas of the registered commands, in registration order.`}}},defs:{command:{description:`Runtime descriptor produced by CommandBuilder.
12
-
13
- Consumers (parser, help generator, CLI dispatcher) read this to
14
- understand the command's shape — flags, args, aliases, subcommands,
15
- and interactive resolver.`,properties:{name:{description:"The command name (used for dispatch, e.g. `'deploy'`)."},description:{description:`Human-readable description for help text.`},details:{description:`Longer explanation shown only in this command's help, with paragraphs wrapped to its width.`},aliases:{description:`Alternative names for this command.`},hidden:{description:`Whether this command is hidden from help listings.`},examples:{description:`Usage examples for help text.`},flags:{description:`Named flag schemas, keyed by flag name.`},args:{description:`Ordered positional arg entries (name + schema).`},commands:{description:"Nested subcommand schemas (for help rendering and completion).\n\nPure data — no execution closures. Populated by `.command()` on\n`CommandBuilder`. Empty for leaf commands."}}},commandDocument:{description:`A single-command definition document, version 1.
16
-
17
- Produced by generateCommandSchema. Same shape as a
18
- CommandDefinitionFragmentV1 plus the \`schemaVersion\` every standalone
19
- document carries.`,properties:{schemaVersion:{description:"Version of the definition document format emitted by `generateSchema()`\nand `generateCommandSchema()` from `@kjanat/dreamcli/json-schema`."},envPrefix:{description:"CLI-wide environment namespace prepended to every relative env binding\n(`undefined` when none is set). `.env('TOKEN')` reads `<envPrefix>TOKEN`;\na binding declared with `{ absolute: true }` is read as written.\n\nSet via the .envPrefix() builder method\nor the `envPrefix` field of CLIDefinition. Fixed when declared, so\nneither manifest name inference nor an inherited invocation name changes it."},name:{description:`The command name used for dispatch.`},description:{description:`Human-readable description for help text.`},details:{description:`Longer explanation shown only in this command's help.`},aliases:{description:`Alternative names accepted for this command.`},hidden:{description:`Whether the command is omitted from help listings.`},examples:{description:`Usage examples attached to the command.`},flags:{description:`Named flag definitions keyed by flag name.`},args:{description:`Positional argument definitions in CLI order.`},commands:{description:`Nested subcommand definitions.`}}},flag:{description:`The runtime descriptor stored inside every FlagBuilder. Consumers (parser,
20
- help generator, resolution chain) read this to understand the flag's shape
21
- without touching generics.`,properties:{kind:{description:`What kind of value this flag accepts.`},presence:{description:"Presence describes whether a flag value is guaranteed to exist when the\naction handler runs:\n\n- `'optional'` — not required; unresolved value follows the kind-specific\n optional fallback (`undefined` for most flags, `[]` for arrays)\n- `'required'` — must be supplied; error if missing\n- `'defaulted'` — always present (falls back to default value)"},defaultValue:{description:`Runtime default value (if any).`},aliases:{description:"Short/long aliases (e.g. `[{ name: 'f', hidden: false }]` for `--force`)."},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the flag never reads\nstdin). See StdinBinding."},envVar:{description:`Environment variable name for v0.2+ resolution.`},envIndexed:{description:"Indexed environment family read as the env source, set by `.env()` with an\nIndexedEnvBinding (`undefined` otherwise). A flag declares at most\none env source, so this and FlagSchema.envVar are never both set."},envAbsolute:{description:"Whether the env source is read exactly as written, outside the CLI-wide\nnamespace set by `CLIBuilder.envPrefix()` (set by `.env(…, { absolute:\ntrue })`). Applies to FlagSchema.envVar and\nFlagSchema.envIndexed alike.\n\nDefault: `false`"},configPath:{description:"Dotted config path for v0.2+ resolution (e.g. `'deploy.region'`)."},description:{description:`Human-readable description for help text.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`."},prompt:{description:`Interactive prompt configuration for v0.3+ resolution.`},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated flag is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."},propagate:{description:`Whether this flag propagates to subcommands in nested command trees.
22
-
23
- When \`true\`, the flag is automatically available to all descendant
24
- commands. A child command that defines a flag with the same name
25
- shadows the propagated parent flag.
26
-
27
- Default: \`false\``},negation:{description:"Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation."},duplicates:{description:"How repeated CLI occurrences of a singleton flag combine.\n\n- `'last'` — last occurrence wins (matches historic behavior)\n- `'first'` — first occurrence wins; later ones parse but are ignored\n- `'error'` — a second occurrence is a `ParseError` (`DUPLICATE_FLAG`)\n\nApplies to CLI token occurrences only — env/config/prompt/default\nresolution keeps its precedence semantics and never raises duplicates.\nOccurrences are counted per *logical* flag: aliases and the negated\nspelling all count toward the same flag.\n\nDefault: `'last'`"},defaultDescription:{description:"Human-readable replacement for the default value in help, or `false` to\nomit the default annotation."},sensitive:{description:`Whether values from this input must be kept out of user-facing projections.`}}},flagElement:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`.",properties:{kind:{description:`What kind of value this flag accepts.`},presence:{description:"Presence describes whether a flag value is guaranteed to exist when the\naction handler runs:\n\n- `'optional'` — not required; unresolved value follows the kind-specific\n optional fallback (`undefined` for most flags, `[]` for arrays)\n- `'required'` — must be supplied; error if missing\n- `'defaulted'` — always present (falls back to default value)"},defaultValue:{description:`Runtime default value (if any).`},aliases:{description:"Short/long aliases (e.g. `[{ name: 'f', hidden: false }]` for `--force`)."},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the flag never reads\nstdin). See StdinBinding."},envVar:{description:`Environment variable name for v0.2+ resolution.`},envIndexed:{description:"Indexed environment family read as the env source, set by `.env()` with an\nIndexedEnvBinding (`undefined` otherwise). A flag declares at most\none env source, so this and FlagSchema.envVar are never both set."},envAbsolute:{description:"Whether the env source is read exactly as written, outside the CLI-wide\nnamespace set by `CLIBuilder.envPrefix()` (set by `.env(…, { absolute:\ntrue })`). Applies to FlagSchema.envVar and\nFlagSchema.envIndexed alike.\n\nDefault: `false`"},configPath:{description:"Dotted config path for v0.2+ resolution (e.g. `'deploy.region'`)."},description:{description:`Human-readable description for help text.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`."},prompt:{description:`Interactive prompt configuration for v0.3+ resolution.`},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated flag is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."},propagate:{description:`Whether this flag propagates to subcommands in nested command trees.
28
-
29
- When \`true\`, the flag is automatically available to all descendant
30
- commands. A child command that defines a flag with the same name
31
- shadows the propagated parent flag.
32
-
33
- Default: \`false\``},negation:{description:"Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation."},duplicates:{description:"How repeated CLI occurrences of a singleton flag combine.\n\n- `'last'` — last occurrence wins (matches historic behavior)\n- `'first'` — first occurrence wins; later ones parse but are ignored\n- `'error'` — a second occurrence is a `ParseError` (`DUPLICATE_FLAG`)\n\nApplies to CLI token occurrences only — env/config/prompt/default\nresolution keeps its precedence semantics and never raises duplicates.\nOccurrences are counted per *logical* flag: aliases and the negated\nspelling all count toward the same flag.\n\nDefault: `'last'`"}}},stdin:{description:`The normalized stdin axis of a flag or an arg.`,properties:{when:{description:`When this input reads the stdin stream.`},consume:{description:`Whether this input consumes the stream alone.`},trim:{description:`Whether one trailing line terminator is dropped from a single value.`}}},envIndexed:{description:`A numbered family of environment variables read as one input's env source.
34
-
35
- Pass it to \`.env()\` in place of a variable name. The count variable decides
36
- whether the env stage supplied a value at all, and how many entries it owns;
37
- a declared entry with a missing member is an error, never a fallback to a
38
- later source.`,properties:{count:{description:`Variable holding how many entries the family declares, as a canonical
39
- non-negative integer. When it is unset the env source supplies nothing;
40
- \`0\` supplies an explicit empty list.`},value:{description:"Variable template for one entry, with `{index}` standing for the zero-based index."},fields:{description:"One variable template per record field, each with `{index}` standing for\nthe zero-based index. Every field is required for every declared entry."}}},negation:{description:`Negation settings for a boolean flag (set by \`.negatable()\`).
41
-
42
- The negated spelling and the positive form are two spellings of ONE
43
- logical flag: they share duplicate policy, and the last CLI occurrence
44
- wins across both. The negated spelling is presence-only — \`--no-foo=x\`
45
- is rejected.`,properties:{alias:{description:"Explicit negated spelling without the `--` prefix (e.g. `'no-sandbox'`).\n`undefined` synthesizes `no-<flagName>` wherever the flag name is known."},hidden:{description:`Hide the negated spelling from help, completions, and suggestions.`}}},arg:{description:`The runtime descriptor stored inside every ArgBuilder. Consumers (parser,
46
- help generator) read this to understand the arg's shape without touching
47
- generics.`,properties:{name:{description:`A named positional argument entry in the command schema.
48
-
49
- Pairs a user-facing arg name with its ArgSchema descriptor.
50
- The array ordering in CommandSchema.args determines CLI position.`},kind:{description:`What kind of value this arg accepts.`},presence:{description:"Presence describes whether a positional arg is guaranteed to exist when the\naction handler runs:\n\n- `'required'` — must be supplied; error if missing (default)\n- `'optional'` — may be `undefined` if not supplied\n- `'defaulted'` — always present (falls back to default value)"},variadic:{description:`Whether this arg consumes all remaining positionals.`},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the arg never reads\nstdin). See StdinBinding."},defaultValue:{description:`Runtime default value (if any).`},defaultDescription:{description:"Human-readable replacement for the default value in help, or `false` to\nomit the default annotation."},sensitive:{description:`Whether values from this input must be kept out of user-facing projections.`},description:{description:`Human-readable description for help text.`},envVar:{description:`Environment variable name for env resolution.
51
-
52
- When set and the CLI value is absent, the resolver reads this env var
53
- and coerces the string to the arg's declared kind.`},envIndexed:{description:"Indexed environment family read as the env source, set by `.env()` with an\nIndexedEnvBinding (`undefined` otherwise). An arg declares at most\none env source, so this and ArgSchema.envVar are never both set."},envAbsolute:{description:"Whether the env source is read exactly as written, outside the CLI-wide\nnamespace set by `CLIBuilder.envPrefix()` (set by `.env(…, { absolute:\ntrue })`). Applies to ArgSchema.envVar and\nArgSchema.envIndexed alike.\n\nDefault: `false`"},configPath:{description:"Dotted config path for config resolution (e.g. `'deploy.region'`)."},prompt:{description:`Interactive prompt configuration.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'keyValue'`.\n\nDescribes the value of each entry, so `arg.keyValue(arg.number())` decodes\n`A=1` to the number `1`. `undefined` leaves entry values as strings."},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated arg is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."}}},argElement:{description:"Element schema when `kind === 'keyValue'`.\n\nDescribes the value of each entry, so `arg.keyValue(arg.number())` decodes\n`A=1` to the number `1`. `undefined` leaves entry values as strings.",properties:{kind:{description:`What kind of value this arg accepts.`},presence:{description:`Entry values are required once their containing key-value argument is present.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."}}},prompt:{description:"Discriminated union of all prompt configurations.\n\nUse the `kind` field to narrow:\n```ts\nif (config.kind === 'select') {\n config.choices // readonly SelectChoice[] | undefined\n}\n```",properties:{kind:{description:"The kind of interactive prompt to present.\n\n- `'confirm'` — yes/no boolean question\n- `'input'` — free-text string input\n- `'password'` — hidden text input, preserving whitespace\n- `'select'` — single selection from a list\n- `'multiselect'` — multiple selections from a list"},message:{description:`The question displayed to the user.`},placeholder:{description:`Placeholder text shown before user types (informational only).`},choices:{description:"Available choices. When omitted for `enum` flags, the enum values\nfrom the flag schema are used automatically."},min:{description:`Minimum number of selections required.
54
-
55
- Default: \`0\``},max:{description:`Maximum number of selections allowed.
56
-
57
- Default: \`Infinity\``}}},choice:{description:`A selectable option for SelectPromptConfig and MultiselectPromptConfig prompts.`,properties:{value:{description:`The value returned when this choice is selected.`},label:{description:`Display label shown to the user.
58
-
59
- Default: value`},description:{description:`Optional description shown alongside the choice.`}}},example:{description:`A single usage example shown in help text.`,properties:{command:{description:"The command invocation (e.g. `'deploy production --force'`)."},description:{description:`Optional description of what this example does.`}}}}};var json_schema_exports=/* @__PURE__ */ __exportAll({generateCommandSchema:()=>generateCommandSchema,generateSchema:()=>generateSchema});function resolveOptions(e){return{includeHidden:e?.includeHidden??!0,includePrompts:e?.includePrompts??!0,envPrefix:e?.envPrefix}}const JSON_SCHEMA_DRAFT=`https://json-schema.org/draft/2020-12/schema`;function generateSchema(e,t,n){let r=resolveOptions(t),i=r.envPrefix??e.envPrefix,a=n??{name:e.name,version:e.version},o=e.defaultCommand!==void 0&&(r.includeHidden||!e.defaultCommand.hidden)?serializeCommand(e.defaultCommand,r,a):void 0;return{$schema:DEFINITION_SCHEMA_URL,schemaVersion:1,name:e.name,...e.version===void 0?{}:{version:e.version},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...i===void 0?{}:{envPrefix:i},...o===void 0?{}:{defaultCommand:o},commands:e.commands.filter(e=>r.includeHidden||!e.hidden).map(e=>serializeCommand(e,r,a))}}function generateCommandSchema(e,t,n){let r=n??{name:e.name,version:void 0},i=resolveOptions(t);return{schemaVersion:1,...i.envPrefix===void 0?{}:{envPrefix:i.envPrefix},...serializeCommand(e,i,r)}}function serializeCommand(e,t,n){let r={};for(let[n,i]of Object.entries(e.flags))r[n]=serializeFlag(i,t);return{name:e.name,...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.details===void 0?{}:{details:resolvePlainHelpDescription(e.details)},...e.aliases.length>0?{aliases:[...e.aliases]}:{},...e.hidden?{hidden:!0}:{},...e.examples.length>0?{examples:e.examples.map(e=>serializeExample(e,n))}:{},flags:r,args:e.args.map(e=>serializeArgEntry(e,t)),commands:e.commands.filter(e=>t.includeHidden||!e.hidden).map(e=>serializeCommand(e,t,n))}}function serializeFlag(e,t,n=!1){let r=getFlagAliasNames(e),i=e.stringConstraints,a=e.pathChecks,o=e.negation,s=n||e.sensitive;return{kind:e.kind,presence:e.presence,...!s&&isJsonSerializable(e.defaultValue)?{defaultValue:e.defaultValue}:{},...e.defaultDescription===void 0?{}:{defaultDescription:e.defaultDescription},...e.sensitive?{sensitive:!0}:{},...r.length>0?{aliases:[...r]}:{},...e.stdin===void 0?{}:{stdin:serializeStdin(e.stdin)},...e.envVar===void 0?{}:{envVar:e.envVar},...e.envIndexed===void 0?{}:{envIndexed:serializeEnvIndexed(e.envIndexed)},...e.envAbsolute?{envAbsolute:!0}:{},...e.configPath===void 0?{}:{configPath:e.configPath},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...i===void 0?{}:{stringConstraints:serializeStringConstraints(i)},...e.elementSchema===void 0?{}:{elementSchema:serializeFlag(e.elementSchema,t,s)},...e.separator===void 0?{}:{separator:e.separator},...e.split===void 0?{}:{split:serializeSplit(e.split)},...e.duplicateKeys===`last`?{}:{duplicateKeys:e.duplicateKeys},...e.unique?{unique:!0}:{},...a===void 0?{}:{pathChecks:serializePathChecks(a)},...e.valueHint===void 0?{}:{valueHint:e.valueHint},...t.includePrompts&&e.prompt!==void 0?{prompt:serializePrompt(e.prompt)}:{},...e.deprecated===void 0?{}:{deprecated:e.deprecated},...e.propagate?{propagate:!0}:{},...o===void 0?{}:{negation:{...o.alias===void 0?{}:{alias:o.alias},...o.hidden?{hidden:!0}:{}}},...e.duplicates===`last`?{}:{duplicates:e.duplicates}}}function serializeStringConstraints(e){let t=e.pattern;return{...e.nonEmpty===void 0?{}:{nonEmpty:e.nonEmpty},...e.minLength===void 0?{}:{minLength:e.minLength},...e.maxLength===void 0?{}:{maxLength:e.maxLength},...t===void 0?{}:{pattern:{source:t.source,flags:t.flags}}}}function serializeEnvIndexed(e){return e.fields===void 0?{count:e.count,value:e.value}:{count:e.count,fields:{...e.fields}}}function serializePathChecks(e){return{mustExist:e.mustExist,...e.type===void 0?{}:{type:e.type},...e.create?{create:!0}:{}}}function serializeArgEntry(e,t){return{name:e.name,...serializeArgValue(e.schema,t)}}function serializeArgValue(e,t){let n=e.stringConstraints,r=e.pathChecks;return{kind:e.kind,presence:e.presence,...e.variadic?{variadic:!0}:{},...e.stdin===void 0?{}:{stdin:serializeStdin(e.stdin)},...!e.sensitive&&isJsonSerializable(e.defaultValue)?{defaultValue:e.defaultValue}:{},...e.defaultDescription===void 0?{}:{defaultDescription:e.defaultDescription},...e.sensitive?{sensitive:!0}:{},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.envVar===void 0?{}:{envVar:e.envVar},...e.envIndexed===void 0?{}:{envIndexed:serializeEnvIndexed(e.envIndexed)},...e.envAbsolute?{envAbsolute:!0}:{},...e.configPath===void 0?{}:{configPath:e.configPath},...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.elementSchema===void 0?{}:{elementSchema:serializeArgElementValue(e.elementSchema)},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...n===void 0?{}:{stringConstraints:serializeStringConstraints(n)},...r===void 0?{}:{pathChecks:serializePathChecks(r)},...e.valueHint===void 0?{}:{valueHint:e.valueHint},...e.separator===void 0?{}:{separator:e.separator},...e.split===void 0?{}:{split:serializeSplit(e.split)},...e.duplicateKeys===`last`?{}:{duplicateKeys:e.duplicateKeys},...e.unique?{unique:!0}:{},...t.includePrompts&&e.prompt!==void 0?{prompt:serializePrompt(e.prompt)}:{},...e.deprecated===void 0?{}:{deprecated:e.deprecated}}}function serializeArgElementValue(e){if(e.kind===`keyValue`)throw TypeError(`Arg element schema kind 'keyValue' is not supported`);return{kind:e.kind,presence:`required`,...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...e.stringConstraints===void 0?{}:{stringConstraints:serializeStringConstraints(e.stringConstraints)},...e.pathChecks===void 0?{}:{pathChecks:serializePathChecks(e.pathChecks)},...e.valueHint===void 0?{}:{valueHint:e.valueHint}}}function serializeSplit(e){return{...e.env===void 0?{}:{env:{...e.env}},...e.stdin===void 0?{}:{stdin:{...e.stdin}}}}function serializeStdin(e){return{when:e.when,consume:e.consume,trim:e.trim,...e.argv===!1?{argv:!1}:{}}}function serializePrompt(e){let t={...e.sensitive===!0||e.kind===`password`?{sensitive:!0}:{}};switch(e.kind){case`input`:return{kind:e.kind,message:e.message,...t,...e.empty===void 0?{}:{empty:e.empty},...e.trim===void 0?{}:{trim:e.trim},...e.placeholder===void 0?{}:{placeholder:e.placeholder}};case`password`:return{kind:e.kind,message:e.message,...t,...e.empty===void 0?{}:{empty:e.empty}};case`select`:return{kind:e.kind,message:e.message,...t,...e.choices===void 0?{}:{choices:e.choices.map(serializeChoice)}};case`multiselect`:return{kind:e.kind,message:e.message,...t,...e.choices===void 0?{}:{choices:e.choices.map(serializeChoice)},...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max}};case`confirm`:return{kind:e.kind,message:e.message,...t}}}function serializeChoice(e){return{value:e.value,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description}}}function serializeExample(e,t){return{command:resolveExampleCommand(e.command,t),...e.description===void 0?{}:{description:e.description}}}function generateInputSchema(e,t){let n=resolveOptions(t);if(isCommandSchema(e))return{$schema:JSON_SCHEMA_DRAFT,...commandToInputSchema(e)};let r=[];e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.hidden)&&collectInputBranches(e.defaultCommand,``,r,n);for(let t of e.commands)t!==e.defaultCommand&&t.name!==e.defaultCommand?.name&&(n.includeHidden||!t.hidden)&&collectInputBranches(t,``,r,n);let[i]=r;if(r.length===1&&i!==void 0)return{$schema:JSON_SCHEMA_DRAFT,...stripCommandDiscriminator(i)};if(r.length>0){let t=e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.hidden)?e.defaultCommand.name:void 0,i=t===void 0?r:r.map(e=>getBranchCommandDiscriminator(e)===t?stripCommandDiscriminator(e):e);return{$schema:JSON_SCHEMA_DRAFT,oneOf:i}}return{$schema:JSON_SCHEMA_DRAFT,type:`object`}}function isCommandSchema(e){return`flags`in e&&`args`in e&&`hasAction`in e}function collectInputBranches(e,t,n,r){let i=t?`${t}.${e.name}`:e.name;e.hasAction&&n.push(commandToInputSchema(e,i));for(let t of e.commands)(r.includeHidden||!t.hidden)&&collectInputBranches(t,i,n,r)}function commandToInputSchema(e,t){let n={},r=[];t!==void 0&&(n.command={const:t},r.push(`command`));for(let[t,i]of Object.entries(e.flags))n[t]=flagToJsonSchemaType(i),i.presence===`required`&&r.push(t);for(let t of e.args)n[t.name]=argToJsonSchemaType(t.schema),t.schema.presence===`required`&&r.push(t.name);return{type:`object`,properties:n,additionalProperties:!1,...r.length>0?{required:r}:{}}}function stripCommandDiscriminator(e){let{command:t,...n}=e.properties,r=e.required?.filter(e=>e!==`command`);return{type:e.type,properties:n,additionalProperties:e.additionalProperties,...r!==void 0&&r.length>0?{required:r}:{}}}function getBranchCommandDiscriminator(e){let t=e.properties.command;if(t===void 0)return;let n=t.const;return typeof n==`string`?n:void 0}function stringConstraintsToJsonSchemaProperties(e){let t={},n=e?.nonEmpty===!0?Math.max(e.minLength??1,1):e?.minLength;return n!==void 0&&(t.minLength=n),e?.maxLength!==void 0&&(t.maxLength=e.maxLength),e?.pattern!==void 0&&(t.pattern=e.pattern.source),t}function flagToJsonSchemaType(e,t=!1){let n={},r=t||e.sensitive;switch(e.kind){case`string`:n.type=`string`,Object.assign(n,stringConstraintsToJsonSchemaProperties(e.stringConstraints));break;case`number`:{let t=e.numberConstraints;n.type=t?.int===!0?`integer`:`number`,t?.min!==void 0&&(n.minimum=t.min),t?.max!==void 0&&(n.maximum=t.max);break}case`boolean`:n.type=`boolean`;break;case`enum`:n.type=`string`,e.enumValues!==void 0&&(n.enum=[...e.enumValues]);break;case`array`:n.type=`array`,e.elementSchema!==void 0&&(n.items=flagToJsonSchemaType(e.elementSchema,r));break;case`custom`:break;case`count`:n.type=`integer`,n.minimum=0;break;case`keyValue`:n.type=`object`,n.additionalProperties=e.elementSchema===void 0?{type:`string`}:flagToJsonSchemaType(e.elementSchema,r)}return e.description!==void 0&&(n.description=resolvePlainHelpDescription(e.description)),e.sensitive&&(n.writeOnly=!0),!r&&isJsonSerializable(e.defaultValue)&&(n.default=e.defaultValue),e.deprecated!==void 0&&(n.deprecated=e.deprecated),n}function argToJsonSchemaType(e){let t=argKindToType(e),n=e.variadic&&e.kind!==`keyValue`?{type:`array`,items:t}:{...t};return e.description!==void 0&&(n.description=resolvePlainHelpDescription(e.description)),e.sensitive&&(n.writeOnly=!0),!e.sensitive&&isJsonSerializable(e.defaultValue)&&(n.default=e.defaultValue),e.deprecated!==void 0&&(n.deprecated=e.deprecated),n}function argKindToType(e){switch(e.kind){case`string`:return{type:`string`,...stringConstraintsToJsonSchemaProperties(e.stringConstraints)};case`number`:{let t=e.numberConstraints,n={type:t?.int===!0?`integer`:`number`};return t?.min!==void 0&&(n.minimum=t.min),t?.max!==void 0&&(n.maximum=t.max),n}case`enum`:{let t={type:`string`};return e.enumValues!==void 0&&(t.enum=[...e.enumValues]),t}case`boolean`:return{type:`boolean`};case`keyValue`:return{type:`object`,additionalProperties:e.elementSchema===void 0?{type:`string`}:argKindToType(e.elementSchema)};case`custom`:return{}}}function isJsonSerializable(e,t=/* @__PURE__ */ new WeakSet){if(e===void 0)return!1;if(e===null)return!0;let n=typeof e;if(n===`string`||n===`boolean`)return!0;if(n===`number`)return Number.isFinite(e);if(n===`function`||n===`symbol`||n===`bigint`)return!1;if(Array.isArray(e)){if(t.has(e))return!1;t.add(e);try{return e.every(e=>isJsonSerializable(e,t))}finally{t.delete(e)}}if(n===`object`){let n=e;if(!isPlainJsonObject(n)||t.has(n))return!1;t.add(n);try{return Object.values(n).every(e=>isJsonSerializable(e,t))}finally{t.delete(n)}}return!1}function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function withDefinitionDescriptions(e,t){let n=e.properties,r=typeof n==`object`&&n&&isPlainJsonObject(n)&&t.properties!==void 0?Object.fromEntries(Object.entries(n).map(([e,n])=>{let r=t.properties?.[e];return r===void 0||typeof n!=`object`||!n||!isPlainJsonObject(n)?[e,n]:[e,withDefinitionDescriptions(n,r)]})):void 0;return{...e,...t.description===void 0?{}:{description:t.description},...r===void 0?{}:{properties:r}}}function withDefinitionMetaSchemaDescriptions(e,t){let n=withDefinitionDescriptions(e,t.root),r=n.$defs;return typeof r!=`object`||!r||!isPlainJsonObject(r)?n:{...n,$defs:Object.fromEntries(Object.entries(r).map(([e,n])=>{let r=t.defs[e];return r===void 0||typeof n!=`object`||!n||!isPlainJsonObject(n)?[e,n]:[e,withDefinitionDescriptions(n,r)]}))}}const ENV_PREFIX_PROPERTY={type:`string`,minLength:1,not:{pattern:`[={}]`}},commandFragmentProperties={name:{type:`string`},description:{type:`string`},details:{type:`string`},aliases:{type:`array`,items:{type:`string`}},hidden:{const:!0},examples:{type:`array`,items:{$ref:`#/$defs/example`}},flags:{type:`object`,additionalProperties:{$ref:`#/$defs/flag`}},args:{type:`array`,items:{$ref:`#/$defs/arg`}},commands:{type:`array`,items:{$ref:`#/$defs/command`}}},argValueFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`custom`,`keyValue`]},presence:{enum:[`required`,`optional`,`defaulted`]},variadic:{const:!0},stdin:{$ref:`#/$defs/stdin`},defaultValue:{},defaultDescription:{oneOf:[{type:`string`},{const:!1}]},sensitive:{const:!0},description:{type:`string`},envVar:{type:`string`},envIndexed:{$ref:`#/$defs/envIndexed`},envAbsolute:{const:!0},configPath:{type:`string`},enumValues:{type:`array`,items:{type:`string`}},elementSchema:{$ref:`#/$defs/argElement`},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`},separator:{type:`string`,minLength:1},split:{$ref:`#/$defs/split`},duplicateKeys:{enum:[...DUPLICATE_KEYS]},unique:{const:!0},prompt:{$ref:`#/$defs/prompt`},deprecated:{oneOf:[{type:`string`},{const:!0}]}},argElementFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`custom`]},presence:{const:`required`},enumValues:{type:`array`,items:{type:`string`}},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`}},flagElementFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`array`,`custom`,`count`,`keyValue`]},presence:{enum:[`optional`,`required`,`defaulted`]},defaultValue:{},aliases:{type:`array`,items:{type:`string`}},stdin:{$ref:`#/$defs/stdin`},envVar:{type:`string`},envIndexed:{$ref:`#/$defs/envIndexed`},envAbsolute:{const:!0},configPath:{type:`string`},description:{type:`string`},enumValues:{type:`array`,items:{type:`string`}},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},elementSchema:{$ref:`#/$defs/flagElement`},separator:{type:`string`,minLength:1},split:{$ref:`#/$defs/split`},duplicateKeys:{enum:[...DUPLICATE_KEYS]},unique:{const:!0},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`},prompt:{$ref:`#/$defs/prompt`},deprecated:{oneOf:[{type:`string`},{const:!0}]},propagate:{const:!0},negation:{$ref:`#/$defs/negation`},duplicates:{enum:[`last`,`first`,`error`]}},flagFragmentProperties={...flagElementFragmentProperties,defaultDescription:{oneOf:[{type:`string`},{const:!1}]},sensitive:{const:!0}},definitionMetaSchema=withDefinitionMetaSchemaDescriptions({$schema:JSON_SCHEMA_DRAFT,$id:DEFINITION_SCHEMA_URL,title:`@kjanat/dreamcli definition schema`,description:`Describes the structure of a CLI built with dreamcli — commands, flags, args, types, constraints, env bindings, and prompts.`,type:`object`,additionalProperties:!1,properties:{$schema:{const:DEFINITION_SCHEMA_URL},schemaVersion:{const:1},name:{type:`string`},version:{type:`string`},description:{type:`string`},envPrefix:ENV_PREFIX_PROPERTY,defaultCommand:{$ref:`#/$defs/command`},commands:{type:`array`,items:{$ref:`#/$defs/command`}}},required:[`$schema`,`schemaVersion`,`name`,`commands`],$defs:{command:{type:`object`,additionalProperties:!1,properties:commandFragmentProperties,required:[`name`,`flags`,`args`,`commands`]},commandDocument:{type:`object`,additionalProperties:!1,properties:{schemaVersion:{const:1},envPrefix:ENV_PREFIX_PROPERTY,...commandFragmentProperties},required:[`schemaVersion`,`name`,`flags`,`args`,`commands`]},flag:{type:`object`,additionalProperties:!1,properties:flagFragmentProperties,required:[`kind`,`presence`],not:{required:[`envVar`,`envIndexed`]},dependentSchemas:{envAbsolute:{$ref:`#/$defs/envBound`}}},flagElement:{type:`object`,additionalProperties:!1,properties:flagElementFragmentProperties,required:[`kind`,`presence`]},envBound:{anyOf:[{required:[`envVar`]},{required:[`envIndexed`]}]},envIndexed:{type:`object`,additionalProperties:!1,properties:{count:{type:`string`,minLength:1,not:{pattern:`[{}=]`}},value:{$ref:`#/$defs/envIndexedTemplate`},fields:{type:`object`,minProperties:1,propertyNames:{minLength:1},additionalProperties:{$ref:`#/$defs/envIndexedTemplate`}}},required:[`count`],oneOf:[{required:[`value`],not:{required:[`fields`]}},{required:[`fields`],not:{required:[`value`]}}]},envIndexedTemplate:{type:`string`,pattern:`\\{index\\}`,not:{pattern:`=`}},stdin:{type:`object`,additionalProperties:!1,properties:{when:{enum:[`dash`,`missing`,`dash-or-missing`]},consume:{enum:[`exclusive`,`broadcast`]},trim:{type:`boolean`},argv:{const:!1}},required:[`when`,`consume`]},split:{type:`object`,additionalProperties:!1,properties:{env:{$ref:`#/$defs/splitPolicy`},stdin:{$ref:`#/$defs/splitPolicy`}}},splitPolicy:{type:`object`,additionalProperties:!1,properties:{format:{enum:[`whole`,`delimiter`,`lines`,`json`]},delimiter:{type:`string`,minLength:1}},required:[`format`],oneOf:[{properties:{format:{const:`delimiter`}},required:[`format`,`delimiter`]},{properties:{format:{enum:[`whole`,`lines`,`json`]}},not:{required:[`delimiter`]}}]},negation:{type:`object`,additionalProperties:!1,properties:{alias:{type:`string`},hidden:{const:!0}}},numberConstraints:{type:`object`,additionalProperties:!1,properties:{min:{type:`number`},max:{type:`number`},int:{type:`boolean`},finite:{type:`boolean`}}},stringConstraints:{type:`object`,additionalProperties:!1,properties:{nonEmpty:{type:`boolean`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},pattern:{type:`object`,additionalProperties:!1,properties:{source:{type:`string`},flags:{type:`string`}},required:[`source`,`flags`]}}},pathChecks:{type:`object`,additionalProperties:!1,properties:{mustExist:{type:`boolean`},type:{enum:[`file`,`directory`]},create:{const:!0}},required:[`mustExist`]},argElement:{type:`object`,additionalProperties:!1,properties:argElementFragmentProperties,required:[`kind`,`presence`]},arg:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`},...argValueFragmentProperties},required:[`name`,`kind`,`presence`],anyOf:[{not:{required:[`elementSchema`]}},{properties:{kind:{const:`keyValue`}},required:[`kind`]}],not:{required:[`envVar`,`envIndexed`]},dependentSchemas:{envAbsolute:{$ref:`#/$defs/envBound`}}},prompt:{type:`object`,additionalProperties:!1,properties:{kind:{enum:[`confirm`,`input`,`password`,`select`,`multiselect`]},message:{type:`string`},placeholder:{type:`string`},trim:{type:`boolean`},empty:{enum:[`skip`,`accept`,`retry`]},sensitive:{const:!0},choices:{type:`array`,items:{$ref:`#/$defs/choice`}},min:{type:`integer`},max:{type:`integer`}},required:[`kind`,`message`]},choice:{type:`object`,additionalProperties:!1,properties:{value:{type:`string`},label:{type:`string`},description:{type:`string`}},required:[`value`]},example:{type:`object`,additionalProperties:!1,properties:{command:{type:`string`},description:{type:`string`}},required:[`command`]}}},definitionMetaSchemaDescriptions);export{json_schema_exports as a,generateSchema as i,generateCommandSchema as n,generateInputSchema as r,definitionMetaSchema as t};