@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.
Files changed (202) hide show
  1. package/CHANGELOG.md +344 -1
  2. package/README.md +9 -2
  3. package/dist/core/cli/dispatch.d.mts +6 -5
  4. package/dist/core/cli/dispatch.mjs +205 -1
  5. package/dist/core/cli/help-links.d.mts +0 -1
  6. package/dist/core/cli/help-links.mjs +41 -1
  7. package/dist/core/cli/index.d.mts +185 -19
  8. package/dist/core/cli/index.mjs +945 -1
  9. package/dist/core/cli/planner.d.mts +32 -6
  10. package/dist/core/cli/planner.mjs +300 -1
  11. package/dist/core/cli/plugin.d.mts +1 -1
  12. package/dist/core/cli/plugin.mjs +41 -1
  13. package/dist/core/cli/propagate.d.mts +1 -1
  14. package/dist/core/cli/propagate.mjs +57 -1
  15. package/dist/core/cli/root-help.d.mts +18 -3
  16. package/dist/core/cli/root-help.mjs +226 -6
  17. package/dist/core/cli/root-surface.d.mts +30 -4
  18. package/dist/core/cli/root-surface.mjs +28 -1
  19. package/dist/core/cli/runtime-preflight.d.mts +30 -3
  20. package/dist/core/cli/runtime-preflight.mjs +169 -1
  21. package/dist/core/completion/index.d.mts +32 -2
  22. package/dist/core/completion/index.mjs +90 -1
  23. package/dist/core/completion/shells/bash.d.mts +0 -1
  24. package/dist/core/completion/shells/bash.mjs +308 -3
  25. package/dist/core/completion/shells/fish.d.mts +0 -1
  26. package/dist/core/completion/shells/fish.mjs +162 -2
  27. package/dist/core/completion/shells/powershell.d.mts +0 -1
  28. package/dist/core/completion/shells/powershell.mjs +358 -2
  29. package/dist/core/completion/shells/shared.d.mts +23 -2
  30. package/dist/core/completion/shells/shared.mjs +176 -1
  31. package/dist/core/completion/shells/zsh.d.mts +0 -1
  32. package/dist/core/completion/shells/zsh.mjs +251 -2
  33. package/dist/core/config/index.d.mts +2 -3
  34. package/dist/core/config/index.mjs +246 -1
  35. package/dist/core/config/package-json.d.mts +27 -4
  36. package/dist/core/config/package-json.mjs +386 -3
  37. package/dist/core/errors/index.d.mts +3 -3
  38. package/dist/core/errors/index.mjs +87 -1
  39. package/dist/core/execution/index.d.mts +0 -1
  40. package/dist/core/execution/index.mjs +201 -1
  41. package/dist/core/help/ansi.d.mts +11 -5
  42. package/dist/core/help/ansi.mjs +121 -2
  43. package/dist/core/help/index.d.mts +65 -2
  44. package/dist/core/help/index.mjs +341 -7
  45. package/dist/core/help/theme.d.mts +68 -0
  46. package/dist/core/help/theme.mjs +46 -0
  47. package/dist/core/json-schema/index.d.mts +15 -2
  48. package/dist/core/json-schema/index.mjs +536 -12
  49. package/dist/core/json-schema/meta-descriptions.generated.d.mts +22 -5
  50. package/dist/core/json-schema/meta-descriptions.generated.mjs +102 -28
  51. package/dist/core/output/activity.d.mts +0 -1
  52. package/dist/core/output/activity.mjs +452 -1
  53. package/dist/core/output/bind.mjs +56 -1
  54. package/dist/core/output/contracts.d.mts +4 -5
  55. package/dist/core/output/contracts.mjs +57 -1
  56. package/dist/core/output/display-value.mjs +32 -1
  57. package/dist/core/output/index.d.mts +21 -1
  58. package/dist/core/output/index.mjs +442 -2
  59. package/dist/core/output/renderers.d.mts +0 -1
  60. package/dist/core/output/renderers.mjs +46 -1
  61. package/dist/core/output/writer.mjs +12 -1
  62. package/dist/core/parse/index.d.mts +54 -7
  63. package/dist/core/parse/index.mjs +727 -1
  64. package/dist/core/prompt/index.d.mts +12 -4
  65. package/dist/core/prompt/index.mjs +348 -6
  66. package/dist/core/resolve/args.d.mts +1 -1
  67. package/dist/core/resolve/args.mjs +105 -1
  68. package/dist/core/resolve/coerce.d.mts +1 -1
  69. package/dist/core/resolve/coerce.mjs +336 -1
  70. package/dist/core/resolve/config.mjs +19 -1
  71. package/dist/core/resolve/contracts.d.mts +9 -4
  72. package/dist/core/resolve/errors.d.mts +0 -1
  73. package/dist/core/resolve/errors.mjs +140 -2
  74. package/dist/core/resolve/flags.d.mts +7 -2
  75. package/dist/core/resolve/flags.mjs +251 -1
  76. package/dist/core/resolve/index.d.mts +2 -2
  77. package/dist/core/resolve/index.mjs +85 -1
  78. package/dist/core/resolve/property.d.mts +6 -2
  79. package/dist/core/resolve/property.mjs +53 -1
  80. package/dist/core/schema/activity.d.mts +31 -11
  81. package/dist/core/schema/arg.d.mts +92 -13
  82. package/dist/core/schema/arg.mjs +463 -1
  83. package/dist/core/schema/command.d.mts +29 -7
  84. package/dist/core/schema/command.mjs +726 -1
  85. package/dist/core/schema/flag.d.mts +577 -21
  86. package/dist/core/schema/flag.mjs +705 -1
  87. package/dist/core/schema/index.d.mts +5 -2
  88. package/dist/core/schema/middleware.d.mts +4 -3
  89. package/dist/core/schema/middleware.mjs +41 -1
  90. package/dist/core/schema/number-constraints.d.mts +96 -0
  91. package/dist/core/schema/number-constraints.mjs +60 -0
  92. package/dist/core/schema/prompt.d.mts +21 -3
  93. package/dist/core/schema/run.d.mts +24 -5
  94. package/dist/core/schema/string-constraints.d.mts +97 -0
  95. package/dist/core/schema/string-constraints.mjs +69 -0
  96. package/dist/core/schema/value-parsers.d.mts +78 -0
  97. package/dist/core/schema/value-parsers.mjs +142 -0
  98. package/dist/core/schema-dsl/runtime.mjs +271 -2
  99. package/dist/core/schema-dsl/to-json-schema.d.mts +0 -1
  100. package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
  101. package/dist/core/testkit/index.d.mts +9 -36
  102. package/dist/core/testkit/index.mjs +83 -1
  103. package/dist/index.d.mts +12 -6
  104. package/dist/index.mjs +22 -1
  105. package/dist/runtime/adapter.d.mts +38 -2
  106. package/dist/runtime/adapter.mjs +87 -1
  107. package/dist/runtime/auto.d.mts +2 -3
  108. package/dist/runtime/auto.mjs +45 -1
  109. package/dist/runtime/deno.d.mts +24 -5
  110. package/dist/runtime/deno.mjs +262 -2
  111. package/dist/runtime/detect.mjs +45 -1
  112. package/dist/runtime/index.d.mts +3 -4
  113. package/dist/runtime/node.d.mts +8 -2
  114. package/dist/runtime/node.mjs +220 -2
  115. package/dist/runtime/paths.mjs +48 -1
  116. package/dist/runtime.d.mts +4 -4
  117. package/dist/runtime.mjs +6 -1
  118. package/dist/strings.mjs +22 -1
  119. package/dist/testkit.d.mts +1 -0
  120. package/dist/testkit.mjs +5 -1
  121. package/dist/version.d.mts +7 -3
  122. package/dist/version.mjs +7 -1
  123. package/dreamcli.schema.json +36 -7
  124. package/examples/basic.ts +5 -1
  125. package/examples/gh/package.json +2 -7
  126. package/examples/pwsh-demo/package.json +1 -7
  127. package/examples/pwsh-demo/src/main.test.ts +1 -4
  128. package/examples/pwsh-demo/src/main.ts +14 -4
  129. package/examples/transport-launcher.ts +85 -0
  130. package/package.json +43 -49
  131. package/dist/runtime/bun.d.mts +0 -28
  132. package/dist/runtime/bun.mjs +0 -1
  133. package/dist/runtime/support.d.mts +0 -42
  134. package/dist/runtime/support.mjs +0 -1
  135. package/src/core/cli/dispatch.ts +0 -349
  136. package/src/core/cli/help-links.ts +0 -82
  137. package/src/core/cli/index.ts +0 -1413
  138. package/src/core/cli/planner.ts +0 -487
  139. package/src/core/cli/plugin.ts +0 -117
  140. package/src/core/cli/propagate.ts +0 -97
  141. package/src/core/cli/root-help.ts +0 -252
  142. package/src/core/cli/root-surface.ts +0 -74
  143. package/src/core/cli/runtime-preflight.ts +0 -438
  144. package/src/core/completion/index.ts +0 -88
  145. package/src/core/completion/shells/bash.ts +0 -459
  146. package/src/core/completion/shells/fish.ts +0 -259
  147. package/src/core/completion/shells/powershell.ts +0 -439
  148. package/src/core/completion/shells/shared.ts +0 -283
  149. package/src/core/completion/shells/zsh.ts +0 -381
  150. package/src/core/config/index.ts +0 -417
  151. package/src/core/config/package-json.ts +0 -560
  152. package/src/core/errors/index.ts +0 -193
  153. package/src/core/execution/index.ts +0 -268
  154. package/src/core/help/ansi.ts +0 -144
  155. package/src/core/help/index.ts +0 -516
  156. package/src/core/json-schema/index.ts +0 -891
  157. package/src/core/json-schema/meta-descriptions.generated.ts +0 -185
  158. package/src/core/output/activity.ts +0 -575
  159. package/src/core/output/bind.ts +0 -59
  160. package/src/core/output/contracts.ts +0 -194
  161. package/src/core/output/display-value.ts +0 -48
  162. package/src/core/output/index.ts +0 -704
  163. package/src/core/output/renderers.ts +0 -125
  164. package/src/core/output/writer.ts +0 -46
  165. package/src/core/parse/index.ts +0 -681
  166. package/src/core/prompt/index.ts +0 -583
  167. package/src/core/resolve/args.ts +0 -144
  168. package/src/core/resolve/coerce.ts +0 -432
  169. package/src/core/resolve/config.ts +0 -26
  170. package/src/core/resolve/contracts.ts +0 -135
  171. package/src/core/resolve/errors.ts +0 -227
  172. package/src/core/resolve/flags.ts +0 -255
  173. package/src/core/resolve/index.ts +0 -108
  174. package/src/core/resolve/property.ts +0 -99
  175. package/src/core/schema/activity.ts +0 -240
  176. package/src/core/schema/arg.ts +0 -719
  177. package/src/core/schema/command.ts +0 -1498
  178. package/src/core/schema/flag.ts +0 -801
  179. package/src/core/schema/index.ts +0 -91
  180. package/src/core/schema/middleware.ts +0 -171
  181. package/src/core/schema/prompt.ts +0 -156
  182. package/src/core/schema/run.ts +0 -198
  183. package/src/core/schema-dsl/index.ts +0 -109
  184. package/src/core/schema-dsl/parse.ts +0 -262
  185. package/src/core/schema-dsl/runtime.ts +0 -609
  186. package/src/core/schema-dsl/to-json-schema.ts +0 -102
  187. package/src/core/testkit/index.ts +0 -123
  188. package/src/index.ts +0 -179
  189. package/src/runtime/adapter.ts +0 -303
  190. package/src/runtime/auto.ts +0 -110
  191. package/src/runtime/bun.ts +0 -55
  192. package/src/runtime/deno.ts +0 -369
  193. package/src/runtime/detect.ts +0 -105
  194. package/src/runtime/index.ts +0 -21
  195. package/src/runtime/node-builtins.d.ts +0 -27
  196. package/src/runtime/node.ts +0 -300
  197. package/src/runtime/paths.ts +0 -64
  198. package/src/runtime/support.ts +0 -135
  199. package/src/runtime.ts +0 -31
  200. package/src/strings.ts +0 -34
  201. package/src/testkit.ts +0 -25
  202. package/src/version.ts +0 -20
@@ -1,11 +1,520 @@
1
- import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}from"../schema-dsl/runtime.mjs";import{nodeToJsonSchema as n}from"../schema-dsl/to-json-schema.mjs";import{definitionMetaSchemaDescriptions as r}from"./meta-descriptions.generated.mjs";function i(e){return{includeHidden:e?.includeHidden??!0,includePrompts:e?.includePrompts??!0}}const a=`https://cdn.jsdelivr.net/npm/@kjanat/dreamcli/dreamcli.schema.json`,o=`https://json-schema.org/draft/2020-12/schema`;function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e,t){let n=i(t),r={$schema:a,name:e.name};return e.version!==void 0&&(r.version=e.version),e.description!==void 0&&(r.description=e.description),e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.schema.hidden)&&(r.defaultCommand=e.defaultCommand.schema.name),r.commands=e.commands.filter(e=>n.includeHidden||!e.schema.hidden).map(e=>l(e.schema,n)),r}function l(e,t){let n={name:e.name};e.description!==void 0&&(n.description=e.description),e.aliases.length>0&&(n.aliases=[...e.aliases]),e.hidden&&(n.hidden=!0),e.examples.length>0&&(n.examples=e.examples.map(m));let r={};for(let[n,i]of Object.entries(e.flags))r[n]=u(i,t);return n.flags=r,n.args=e.args.map(d),n.commands=e.commands.filter(e=>t.includeHidden||!e.hidden).map(e=>l(e,t)),n}function u(t,n){let r={kind:t.kind,presence:t.presence};t.presence===`defaulted`&&w(t.defaultValue)&&(r.defaultValue=t.defaultValue);let i=e(t);return i.length>0&&(r.aliases=[...i]),t.envVar!==void 0&&(r.envVar=t.envVar),t.configPath!==void 0&&(r.configPath=t.configPath),t.description!==void 0&&(r.description=t.description),t.enumValues!==void 0&&(r.enumValues=[...t.enumValues]),t.elementSchema!==void 0&&(r.elementSchema=u(t.elementSchema,n)),n.includePrompts&&t.prompt!==void 0&&(r.prompt=f(t.prompt)),t.deprecated!==void 0&&(r.deprecated=t.deprecated),t.propagate&&(r.propagate=!0),r}function d(e){let{name:t,schema:n}=e,r={name:t,kind:n.kind,presence:n.presence};return n.variadic&&(r.variadic=!0),n.stdinMode&&(r.stdinMode=!0),n.presence===`defaulted`&&w(n.defaultValue)&&(r.defaultValue=n.defaultValue),n.description!==void 0&&(r.description=n.description),n.envVar!==void 0&&(r.envVar=n.envVar),n.enumValues!==void 0&&(r.enumValues=[...n.enumValues]),n.deprecated!==void 0&&(r.deprecated=n.deprecated),r}function f(e){let t={kind:e.kind,message:e.message};switch(e.kind){case`input`:e.placeholder!==void 0&&(t.placeholder=e.placeholder);break;case`select`:e.choices!==void 0&&(t.choices=e.choices.map(p));break;case`multiselect`:e.choices!==void 0&&(t.choices=e.choices.map(p)),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max);break;case`confirm`:break}return t}function p(e){let t={value:e.value};return e.label!==void 0&&(t.label=e.label),e.description!==void 0&&(t.description=e.description),t}function m(e){let t={command:e.command};return e.description!==void 0&&(t.description=e.description),t}function h(e,t){let n=i(t);if(g(e))return{$schema:o,...v(e)};let r=[];for(let t of e.commands)!n.includeHidden&&t.schema.hidden||_(t.schema,``,r,n);if(r.length===1)return{$schema:o,...y(r[0]??{})};if(r.length>0){let t=e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.schema.hidden)?e.defaultCommand.schema.name:void 0;return{$schema:o,oneOf:t===void 0?r:r.map(e=>b(e)===t?y(e):e)}}return{$schema:o,type:`object`}}function g(e){return`flags`in e&&`args`in e&&`middleware`in e&&`hasAction`in e}function _(e,t,n,r){let i=t?`${t}.${e.name}`:e.name;e.hasAction&&n.push(v(e,i));for(let t of e.commands)!r.includeHidden&&t.hidden||_(t,i,n,r)}function v(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]=x(i),i.presence===`required`&&r.push(t);for(let t of e.args)n[t.name]=S(t.schema),t.schema.presence===`required`&&r.push(t.name);let i={type:`object`,properties:n,additionalProperties:!1};return r.length>0&&(i.required=r),i}function y(e){let t=e.properties,n=e.required,r=s(t)?{...t}:void 0,i=Array.isArray(n)?n.filter(e=>typeof e==`string`):void 0;r!==void 0&&delete r.command;let a=i?.filter(e=>e!==`command`),o={...e};return r!==void 0&&(o.properties=r),a!==void 0&&a.length>0?o.required=a:delete o.required,o}function b(e){let t=e.properties;if(!s(t))return;let n=t.command;return s(n)&&typeof n.const==`string`?n.const:void 0}function x(e){let t={};switch(e.kind){case`string`:t.type=`string`;break;case`number`:t.type=`number`;break;case`boolean`:t.type=`boolean`;break;case`enum`:t.type=`string`,e.enumValues!==void 0&&(t.enum=[...e.enumValues]);break;case`array`:t.type=`array`,e.elementSchema!==void 0&&(t.items=x(e.elementSchema));break;case`custom`:break}return e.description!==void 0&&(t.description=e.description),e.presence===`defaulted`&&w(e.defaultValue)&&(t.default=e.defaultValue),e.deprecated!==void 0&&(t.deprecated=e.deprecated),t}function S(e){let t=C(e),n=e.variadic?{type:`array`,items:t}:{...t};return e.description!==void 0&&(n.description=e.description),e.presence===`defaulted`&&w(e.defaultValue)&&(n.default=e.defaultValue),e.deprecated!==void 0&&(n.deprecated=e.deprecated),n}function C(e){switch(e.kind){case`string`:return{type:`string`};case`number`:return{type:`number`};case`enum`:{let t={type:`string`};return e.enumValues!==void 0&&(t.enum=[...e.enumValues]),t}case`custom`:return{}}}function w(e,t=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=>w(e,t))}finally{t.delete(e)}}if(n===`object`){let n=e;if(!T(n)||t.has(n))return!1;t.add(n);try{return Object.values(n).every(e=>w(e,t))}finally{t.delete(n)}}return!1}function T(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function E(e){return n(t(e))}function D(e,t){let n=e.properties,r=typeof n==`object`&&n&&T(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||!T(n)?[e,n]:[e,D(n,r)]})):void 0;return{...e,...t.description===void 0?{}:{description:t.description},...r===void 0?{}:{properties:r}}}function O(e,t){let n=D(e,t.root),r=n.$defs;return typeof r!=`object`||!r||!T(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||!T(n)?[e,n]:[e,D(n,r)]}))}}const k=O({$schema:o,$id:a,title:`@kjanat/dreamcli definition schema`,description:`Describes the structure of a CLI built with dreamcli — commands, flags, args, types, constraints, env bindings, and prompts.`,...E(`{
2
- $schema: '${a}';
1
+ import { getFlagAliasNames } from "../schema/flag.mjs";
2
+ import { parseSchema } from "../schema-dsl/runtime.mjs";
3
+ import { nodeToJsonSchema } from "../schema-dsl/to-json-schema.mjs";
4
+ import { definitionMetaSchemaDescriptions } from "./meta-descriptions.generated.mjs";
5
+ //#region src/core/json-schema/index.ts
6
+ /**
7
+ * Apply defaults to optional {@link JsonSchemaOptions}.
8
+ *
9
+ * @param options - User-supplied schema generation options, or `undefined` for all defaults.
10
+ * @returns Fully resolved options with defaults applied.
11
+ */
12
+ function resolveOptions(options) {
13
+ return {
14
+ includeHidden: options?.includeHidden ?? true,
15
+ includePrompts: options?.includePrompts ?? true
16
+ };
17
+ }
18
+ /**
19
+ * `$schema` URL for definition documents.
20
+ *
21
+ * Resolves via the actual file path on the CDN (`dreamcli.schema.json`).
22
+ * For offline or local-first workflows, use
23
+ * `./node_modules/@kjanat/dreamcli/dreamcli.schema.json`.
24
+ */
25
+ const DEFINITION_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@kjanat/dreamcli/dreamcli.schema.json";
26
+ /** Meta-schema URL for JSON Schema draft 2020-12 (input validation). */
27
+ const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
28
+ function isRecord(value) {
29
+ return typeof value === "object" && value !== null && !Array.isArray(value);
30
+ }
31
+ /**
32
+ * Generate a definition metadata document describing the CLI's structure.
33
+ *
34
+ * Walks the full command tree and produces a plain JSON-serializable object
35
+ * representing all commands, subcommands, flags, args, and metadata.
36
+ * Non-serializable runtime values (parse functions, middleware handlers,
37
+ * interactive resolvers) are omitted.
38
+ *
39
+ * @param schema - The CLI schema from `CLIBuilder.schema`.
40
+ * @param options - Generation options.
41
+ * @returns A plain object suitable for `JSON.stringify()`.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const app = cli('myapp').version('1.0.0').command(deploy);
46
+ * const definition = generateSchema(app.schema);
47
+ * writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2));
48
+ * ```
49
+ */
50
+ function generateSchema(schema, options) {
51
+ const opts = resolveOptions(options);
52
+ const result = {
53
+ $schema: DEFINITION_SCHEMA_URL,
54
+ name: schema.name
55
+ };
56
+ if (schema.version !== void 0) result.version = schema.version;
57
+ if (schema.description !== void 0) result.description = schema.description;
58
+ if (schema.defaultCommand !== void 0 && (opts.includeHidden || !schema.defaultCommand.schema.hidden)) result.defaultCommand = serializeCommand(schema.defaultCommand.schema, opts);
59
+ result.commands = schema.commands.filter((cmd) => opts.includeHidden || !cmd.schema.hidden).map((cmd) => serializeCommand(cmd.schema, opts));
60
+ return result;
61
+ }
62
+ /**
63
+ * Generate the definition metadata document for a single command.
64
+ *
65
+ * The per-command counterpart of {@link generateSchema}: the same
66
+ * JSON-serializable shape as one entry of its `commands` array (flags, args,
67
+ * subcommands, examples). Powers `--help` in `--json` mode and is useful for
68
+ * embedding one command's definition into custom tooling.
69
+ *
70
+ * @param schema - The command schema to serialize.
71
+ * @param options - Generation options.
72
+ * @returns A plain object suitable for `JSON.stringify()`.
73
+ */
74
+ function generateCommandSchema(schema, options) {
75
+ return serializeCommand(schema, resolveOptions(options));
76
+ }
77
+ /**
78
+ * Serialize a single {@link CommandSchema} into a plain object.
79
+ *
80
+ * @param schema - The command schema to serialize.
81
+ * @param opts - Resolved generation options (hidden/prompt inclusion).
82
+ * @returns JSON-serializable object representing the command.
83
+ */
84
+ function serializeCommand(schema, opts) {
85
+ const result = { name: schema.name };
86
+ if (schema.description !== void 0) result.description = schema.description;
87
+ if (schema.aliases.length > 0) result.aliases = [...schema.aliases];
88
+ if (schema.hidden) result.hidden = true;
89
+ if (schema.examples.length > 0) result.examples = schema.examples.map(serializeExample);
90
+ const flags = {};
91
+ for (const [name, flagDef] of Object.entries(schema.flags)) flags[name] = serializeFlag(flagDef, opts);
92
+ result.flags = flags;
93
+ result.args = schema.args.map(serializeArgEntry);
94
+ result.commands = schema.commands.filter((cmd) => opts.includeHidden || !cmd.hidden).map((cmd) => serializeCommand(cmd, opts));
95
+ return result;
96
+ }
97
+ /**
98
+ * Serialize a {@link FlagSchema} into a plain object.
99
+ *
100
+ * @param schema - The flag schema to serialize.
101
+ * @param opts - Resolved generation options (prompt inclusion).
102
+ * @returns JSON-serializable object representing the flag.
103
+ */
104
+ function serializeFlag(schema, opts) {
105
+ const result = {
106
+ kind: schema.kind,
107
+ presence: schema.presence
108
+ };
109
+ if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.defaultValue = schema.defaultValue;
110
+ const visibleAliases = getFlagAliasNames(schema);
111
+ if (visibleAliases.length > 0) result.aliases = [...visibleAliases];
112
+ if (schema.envVar !== void 0) result.envVar = schema.envVar;
113
+ if (schema.configPath !== void 0) result.configPath = schema.configPath;
114
+ if (schema.description !== void 0) result.description = schema.description;
115
+ if (schema.enumValues !== void 0) result.enumValues = [...schema.enumValues];
116
+ if (schema.elementSchema !== void 0) result.elementSchema = serializeFlag(schema.elementSchema, opts);
117
+ if (opts.includePrompts && schema.prompt !== void 0) result.prompt = serializePrompt(schema.prompt);
118
+ if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
119
+ if (schema.propagate) result.propagate = true;
120
+ if (schema.negation !== void 0) {
121
+ const negation = {};
122
+ if (schema.negation.alias !== void 0) negation.alias = schema.negation.alias;
123
+ if (schema.negation.hidden) negation.hidden = true;
124
+ result.negation = negation;
125
+ }
126
+ if (schema.duplicates !== "last") result.duplicates = schema.duplicates;
127
+ return result;
128
+ }
129
+ /**
130
+ * Serialize a {@link CommandArgEntry} into a plain object.
131
+ *
132
+ * @param entry - The positional arg entry (name + {@link ArgSchema}).
133
+ * @returns JSON-serializable object representing the arg.
134
+ */
135
+ function serializeArgEntry(entry) {
136
+ const { name, schema } = entry;
137
+ const result = {
138
+ name,
139
+ kind: schema.kind,
140
+ presence: schema.presence
141
+ };
142
+ if (schema.variadic) result.variadic = true;
143
+ if (schema.stdinMode) result.stdinMode = true;
144
+ if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.defaultValue = schema.defaultValue;
145
+ if (schema.description !== void 0) result.description = schema.description;
146
+ if (schema.envVar !== void 0) result.envVar = schema.envVar;
147
+ if (schema.enumValues !== void 0) result.enumValues = [...schema.enumValues];
148
+ if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
149
+ return result;
150
+ }
151
+ /**
152
+ * Serialize a {@link PromptConfig} into a plain object.
153
+ *
154
+ * @param prompt - The prompt configuration to serialize.
155
+ * @returns JSON-serializable object representing the prompt.
156
+ */
157
+ function serializePrompt(prompt) {
158
+ const result = {
159
+ kind: prompt.kind,
160
+ message: prompt.message
161
+ };
162
+ switch (prompt.kind) {
163
+ case "input":
164
+ if (prompt.placeholder !== void 0) result.placeholder = prompt.placeholder;
165
+ break;
166
+ case "select":
167
+ if (prompt.choices !== void 0) result.choices = prompt.choices.map(serializeChoice);
168
+ break;
169
+ case "multiselect":
170
+ if (prompt.choices !== void 0) result.choices = prompt.choices.map(serializeChoice);
171
+ if (prompt.min !== void 0) result.min = prompt.min;
172
+ if (prompt.max !== void 0) result.max = prompt.max;
173
+ break;
174
+ case "confirm": break;
175
+ }
176
+ return result;
177
+ }
178
+ /**
179
+ * Serialize a {@link SelectChoice} into a plain object.
180
+ *
181
+ * @param choice - The select/multiselect choice to serialize.
182
+ * @returns JSON-serializable object with value, optional label and description.
183
+ */
184
+ function serializeChoice(choice) {
185
+ const result = { value: choice.value };
186
+ if (choice.label !== void 0) result.label = choice.label;
187
+ if (choice.description !== void 0) result.description = choice.description;
188
+ return result;
189
+ }
190
+ /**
191
+ * Serialize a {@link CommandExample} into a plain object.
192
+ *
193
+ * @param example - The example to serialize.
194
+ * @returns JSON-serializable object with command and optional description.
195
+ */
196
+ function serializeExample(example) {
197
+ const result = { command: example.command };
198
+ if (example.description !== void 0) result.description = example.description;
199
+ return result;
200
+ }
201
+ /**
202
+ * Generate a JSON Schema (draft 2020-12) for validating CLI input as JSON.
203
+ *
204
+ * Accepts either a full {@link CLISchema} (producing a discriminated union
205
+ * across all commands) or a single {@link CommandSchema} (producing a flat
206
+ * object schema for that command's flags and args).
207
+ *
208
+ * **Single command** — produces an object schema where flag/arg names are
209
+ * properties with appropriate JSON Schema types.
210
+ *
211
+ * **Multi-command CLI** — produces a `oneOf` discriminated union with a
212
+ * `command` property identifying each branch. Nested subcommands use
213
+ * dot-delimited paths (e.g. `"deploy.rollback"`).
214
+ *
215
+ * Only commands with action handlers are included (group commands without
216
+ * actions are not directly invocable and are skipped).
217
+ *
218
+ * @param schema - A CLI schema or a single command schema.
219
+ * @param options - Generation options.
220
+ * @returns A JSON Schema object suitable for `JSON.stringify()`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * // Validate a config file against the CLI's input shape
225
+ * const inputSchema = generateInputSchema(app.schema);
226
+ * writeFileSync('input-schema.json', JSON.stringify(inputSchema, null, 2));
227
+ * ```
228
+ */
229
+ function generateInputSchema(schema, options) {
230
+ const opts = resolveOptions(options);
231
+ if (isCommandSchema(schema)) return {
232
+ $schema: JSON_SCHEMA_DRAFT,
233
+ ...commandToInputSchema(schema)
234
+ };
235
+ const branches = [];
236
+ for (const cmd of schema.commands) {
237
+ if (!opts.includeHidden && cmd.schema.hidden) continue;
238
+ collectInputBranches(cmd.schema, "", branches, opts);
239
+ }
240
+ if (branches.length === 1) {
241
+ const branch = stripCommandDiscriminator(branches[0] ?? {});
242
+ return {
243
+ $schema: JSON_SCHEMA_DRAFT,
244
+ ...branch
245
+ };
246
+ }
247
+ if (branches.length > 0) {
248
+ const defaultBranchName = schema.defaultCommand !== void 0 && (opts.includeHidden || !schema.defaultCommand.schema.hidden) ? schema.defaultCommand.schema.name : void 0;
249
+ const normalizedBranches = defaultBranchName !== void 0 ? branches.map((branch) => getBranchCommandDiscriminator(branch) === defaultBranchName ? stripCommandDiscriminator(branch) : branch) : branches;
250
+ return {
251
+ $schema: JSON_SCHEMA_DRAFT,
252
+ oneOf: normalizedBranches
253
+ };
254
+ }
255
+ return {
256
+ $schema: JSON_SCHEMA_DRAFT,
257
+ type: "object"
258
+ };
259
+ }
260
+ /**
261
+ * Discriminate between CLISchema and CommandSchema at runtime.
262
+ *
263
+ * Use a command-only field combination rather than a single shape check:
264
+ * command schemas always carry flags, args, middleware, and hasAction, while
265
+ * the CLI root schema does not expose that execution surface.
266
+ */
267
+ function isCommandSchema(schema) {
268
+ return "flags" in schema && "args" in schema && "middleware" in schema && "hasAction" in schema;
269
+ }
270
+ /** Recursively collect input schema branches for all invocable commands. */
271
+ function collectInputBranches(schema, prefix, branches, opts) {
272
+ const path = prefix ? `${prefix}.${schema.name}` : schema.name;
273
+ if (schema.hasAction) branches.push(commandToInputSchema(schema, path));
274
+ for (const sub of schema.commands) {
275
+ if (!opts.includeHidden && sub.hidden) continue;
276
+ collectInputBranches(sub, path, branches, opts);
277
+ }
278
+ }
279
+ /**
280
+ * Create a JSON Schema object for a single command's flags + args.
281
+ *
282
+ * When `commandPath` is provided, a `command` const discriminator property
283
+ * is added and required (used in multi-command oneOf schemas).
284
+ */
285
+ function commandToInputSchema(schema, commandPath) {
286
+ const properties = {};
287
+ const required = [];
288
+ if (commandPath !== void 0) {
289
+ properties.command = { const: commandPath };
290
+ required.push("command");
291
+ }
292
+ for (const [name, flagDef] of Object.entries(schema.flags)) {
293
+ properties[name] = flagToJsonSchemaType(flagDef);
294
+ if (flagDef.presence === "required") required.push(name);
295
+ }
296
+ for (const entry of schema.args) {
297
+ properties[entry.name] = argToJsonSchemaType(entry.schema);
298
+ if (entry.schema.presence === "required") required.push(entry.name);
299
+ }
300
+ const result = {
301
+ type: "object",
302
+ properties,
303
+ additionalProperties: false
304
+ };
305
+ if (required.length > 0) result.required = required;
306
+ return result;
307
+ }
308
+ /** @internal */
309
+ function stripCommandDiscriminator(branch) {
310
+ const propertiesValue = branch.properties;
311
+ const requiredValue = branch.required;
312
+ const properties = isRecord(propertiesValue) ? { ...propertiesValue } : void 0;
313
+ const required = Array.isArray(requiredValue) ? requiredValue.filter((value) => typeof value === "string") : void 0;
314
+ if (properties !== void 0) delete properties.command;
315
+ const cleanedRequired = required?.filter((value) => value !== "command");
316
+ const result = { ...branch };
317
+ if (properties !== void 0) result.properties = properties;
318
+ if (cleanedRequired !== void 0 && cleanedRequired.length > 0) result.required = cleanedRequired;
319
+ else delete result.required;
320
+ return result;
321
+ }
322
+ function getBranchCommandDiscriminator(branch) {
323
+ const propertiesValue = branch.properties;
324
+ if (!isRecord(propertiesValue)) return;
325
+ const commandValue = propertiesValue.command;
326
+ return isRecord(commandValue) && typeof commandValue.const === "string" ? commandValue.const : void 0;
327
+ }
328
+ function flagToJsonSchemaType(schema) {
329
+ const result = {};
330
+ switch (schema.kind) {
331
+ case "string": {
332
+ result.type = "string";
333
+ const constraints = schema.stringConstraints;
334
+ const minLength = constraints?.nonEmpty === true ? Math.max(constraints.minLength ?? 1, 1) : constraints?.minLength;
335
+ if (minLength !== void 0) result.minLength = minLength;
336
+ if (constraints?.maxLength !== void 0) result.maxLength = constraints.maxLength;
337
+ if (constraints?.pattern !== void 0) result.pattern = constraints.pattern.source;
338
+ break;
339
+ }
340
+ case "number": {
341
+ const constraints = schema.numberConstraints;
342
+ result.type = constraints?.int === true ? "integer" : "number";
343
+ if (constraints?.min !== void 0) result.minimum = constraints.min;
344
+ if (constraints?.max !== void 0) result.maximum = constraints.max;
345
+ break;
346
+ }
347
+ case "boolean":
348
+ result.type = "boolean";
349
+ break;
350
+ case "enum":
351
+ result.type = "string";
352
+ if (schema.enumValues !== void 0) result.enum = [...schema.enumValues];
353
+ break;
354
+ case "array":
355
+ result.type = "array";
356
+ if (schema.elementSchema !== void 0) result.items = flagToJsonSchemaType(schema.elementSchema);
357
+ break;
358
+ case "custom": break;
359
+ case "count":
360
+ result.type = "integer";
361
+ result.minimum = 0;
362
+ break;
363
+ case "keyValue":
364
+ result.type = "object";
365
+ result.additionalProperties = { type: "string" };
366
+ break;
367
+ }
368
+ if (schema.description !== void 0) result.description = schema.description;
369
+ if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.default = schema.defaultValue;
370
+ if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
371
+ return result;
372
+ }
373
+ function argToJsonSchemaType(schema) {
374
+ const kind = argKindToType(schema);
375
+ const result = schema.variadic ? {
376
+ type: "array",
377
+ items: kind
378
+ } : { ...kind };
379
+ if (schema.description !== void 0) result.description = schema.description;
380
+ if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.default = schema.defaultValue;
381
+ if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
382
+ return result;
383
+ }
384
+ /** Map an arg's kind to a JSON Schema type fragment. */
385
+ function argKindToType(schema) {
386
+ switch (schema.kind) {
387
+ case "string": return { type: "string" };
388
+ case "number": {
389
+ const constraints = schema.numberConstraints;
390
+ const result = { type: constraints?.int === true ? "integer" : "number" };
391
+ if (constraints?.min !== void 0) result.minimum = constraints.min;
392
+ if (constraints?.max !== void 0) result.maximum = constraints.max;
393
+ return result;
394
+ }
395
+ case "enum": {
396
+ const result = { type: "string" };
397
+ if (schema.enumValues !== void 0) result.enum = [...schema.enumValues];
398
+ return result;
399
+ }
400
+ case "custom": return {};
401
+ }
402
+ }
403
+ /**
404
+ * Check whether a value can survive a JSON round-trip.
405
+ *
406
+ * Returns `false` for functions, symbols, bigints, non-finite numbers, and
407
+ * objects containing them. Used to guard default-value inclusion in
408
+ * serialized output.
409
+ */
410
+ function isJsonSerializable(value, seen = /* @__PURE__ */ new WeakSet()) {
411
+ if (value === void 0) return false;
412
+ if (value === null) return true;
413
+ const t = typeof value;
414
+ if (t === "string" || t === "boolean") return true;
415
+ if (t === "number") return Number.isFinite(value);
416
+ if (t === "function" || t === "symbol" || t === "bigint") return false;
417
+ if (Array.isArray(value)) {
418
+ if (seen.has(value)) return false;
419
+ seen.add(value);
420
+ try {
421
+ return value.every((entry) => isJsonSerializable(entry, seen));
422
+ } finally {
423
+ seen.delete(value);
424
+ }
425
+ }
426
+ if (t === "object") {
427
+ const objectValue = value;
428
+ if (!isPlainJsonObject(objectValue)) return false;
429
+ if (seen.has(objectValue)) return false;
430
+ seen.add(objectValue);
431
+ try {
432
+ return Object.values(objectValue).every((entry) => isJsonSerializable(entry, seen));
433
+ } finally {
434
+ seen.delete(objectValue);
435
+ }
436
+ }
437
+ return false;
438
+ }
439
+ /**
440
+ * Check whether an object is a plain JSON object.
441
+ *
442
+ * Accepts objects with `Object.prototype` or a null prototype, which are the
443
+ * only object shapes that round-trip through JSON as structural objects.
444
+ *
445
+ * @internal
446
+ */
447
+ function isPlainJsonObject(value) {
448
+ const proto = Object.getPrototypeOf(value);
449
+ return proto === Object.prototype || proto === null;
450
+ }
451
+ /** Convert a DSL string to a JSON Schema object definition. */
452
+ function def(source) {
453
+ return nodeToJsonSchema(parseSchema(source));
454
+ }
455
+ function withDefinitionDescriptions(schema, descriptions) {
456
+ const propertiesValue = schema.properties;
457
+ const describedProperties = typeof propertiesValue === "object" && propertiesValue !== null && isPlainJsonObject(propertiesValue) && descriptions.properties !== void 0 ? Object.fromEntries(Object.entries(propertiesValue).map(([name, propertySchema]) => {
458
+ const propertyDescriptions = descriptions.properties?.[name];
459
+ if (propertyDescriptions === void 0 || typeof propertySchema !== "object" || propertySchema === null || !isPlainJsonObject(propertySchema)) return [name, propertySchema];
460
+ return [name, withDefinitionDescriptions(propertySchema, propertyDescriptions)];
461
+ })) : void 0;
462
+ return {
463
+ ...schema,
464
+ ...descriptions.description !== void 0 ? { description: descriptions.description } : {},
465
+ ...describedProperties !== void 0 ? { properties: describedProperties } : {}
466
+ };
467
+ }
468
+ function withDefinitionMetaSchemaDescriptions(schema, descriptions) {
469
+ const describedRoot = withDefinitionDescriptions(schema, descriptions.root);
470
+ const defsValue = describedRoot.$defs;
471
+ if (typeof defsValue !== "object" || defsValue === null || !isPlainJsonObject(defsValue)) return describedRoot;
472
+ return {
473
+ ...describedRoot,
474
+ $defs: Object.fromEntries(Object.entries(defsValue).map(([name, defSchema]) => {
475
+ const defDescriptions = descriptions.defs[name];
476
+ if (defDescriptions === void 0 || typeof defSchema !== "object" || defSchema === null || !isPlainJsonObject(defSchema)) return [name, defSchema];
477
+ return [name, withDefinitionDescriptions(defSchema, defDescriptions)];
478
+ }))
479
+ };
480
+ }
481
+ /**
482
+ * JSON Schema (draft 2020-12) that validates the output of {@link generateSchema}.
483
+ *
484
+ * Each `$defs` entry is defined once as a schema DSL string — the DSL
485
+ * parser produces a runtime AST, and {@link nodeToJsonSchema} converts
486
+ * that AST to a JSON Schema fragment. No probe fixtures, no override
487
+ * maps, no manually maintained type definitions.
488
+ *
489
+ * Hosted at {@link DEFINITION_SCHEMA_URL} for `$schema` resolution. Also
490
+ * exported so tooling can validate definition documents without a network
491
+ * round-trip.
492
+ *
493
+ * @example
494
+ * ```ts
495
+ * import Ajv from 'ajv/dist/2020';
496
+ * import { definitionMetaSchema, generateSchema } from '@kjanat/dreamcli';
497
+ *
498
+ * const ajv = new Ajv();
499
+ * const validate = ajv.compile(definitionMetaSchema);
500
+ * const valid = validate(generateSchema(myCli.schema));
501
+ * ```
502
+ */
503
+ const definitionMetaSchema = withDefinitionMetaSchemaDescriptions({
504
+ $schema: JSON_SCHEMA_DRAFT,
505
+ $id: DEFINITION_SCHEMA_URL,
506
+ title: "@kjanat/dreamcli definition schema",
507
+ description: "Describes the structure of a CLI built with dreamcli — commands, flags, args, types, constraints, env bindings, and prompts.",
508
+ ...def(`{
509
+ $schema: '${DEFINITION_SCHEMA_URL}';
3
510
  name: string;
4
511
  version?: string;
5
512
  description?: string;
6
- defaultCommand?: string;
513
+ defaultCommand?: @command;
7
514
  commands: @command[]
8
- }`),$defs:{command:E(`{
515
+ }`),
516
+ $defs: {
517
+ command: def(`{
9
518
  name: string;
10
519
  description?: string;
11
520
  aliases?: string[];
@@ -14,8 +523,9 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
14
523
  flags: Record<string, @flag>;
15
524
  args: @arg[];
16
525
  commands: @command[]
17
- }`),flag:E(`{
18
- kind: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'custom';
526
+ }`),
527
+ flag: def(`{
528
+ kind: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'custom' | 'count' | 'keyValue';
19
529
  presence: 'optional' | 'required' | 'defaulted';
20
530
  defaultValue?: unknown;
21
531
  aliases?: string[];
@@ -26,8 +536,15 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
26
536
  elementSchema?: @flag;
27
537
  prompt?: @prompt;
28
538
  deprecated?: string | true;
29
- propagate?: true
30
- }`),arg:E(`{
539
+ propagate?: true;
540
+ negation?: @negation;
541
+ duplicates?: 'last' | 'first' | 'error'
542
+ }`),
543
+ negation: def(`{
544
+ alias?: string;
545
+ hidden?: true
546
+ }`),
547
+ arg: def(`{
31
548
  name: string;
32
549
  kind: 'string' | 'number' | 'enum' | 'custom';
33
550
  presence: 'required' | 'optional' | 'defaulted';
@@ -38,18 +555,25 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
38
555
  envVar?: string;
39
556
  enumValues?: string[];
40
557
  deprecated?: string | true
41
- }`),prompt:E(`{
558
+ }`),
559
+ prompt: def(`{
42
560
  kind: 'confirm' | 'input' | 'select' | 'multiselect';
43
561
  message: string;
44
562
  placeholder?: string;
45
563
  choices?: @choice[];
46
564
  min?: integer;
47
565
  max?: integer
48
- }`),choice:E(`{
566
+ }`),
567
+ choice: def(`{
49
568
  value: string;
50
569
  label?: string;
51
570
  description?: string
52
- }`),example:E(`{
571
+ }`),
572
+ example: def(`{
53
573
  command: string;
54
574
  description?: string
55
- }`)}},r);export{k as definitionMetaSchema,h as generateInputSchema,c as generateSchema};
575
+ }`)
576
+ }
577
+ }, definitionMetaSchemaDescriptions);
578
+ //#endregion
579
+ export { definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };
@@ -92,7 +92,24 @@ declare const definitionMetaSchemaDescriptions: {
92
92
  readonly 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>]`.";
93
93
  };
94
94
  readonly propagate: {
95
- readonly description: "Whether this flag propagates to subcommands in nested command trees.\n\nWhen `true`, the flag is automatically available to all descendant\ncommands. A child command that defines a flag with the same name\nshadows the propagated parent flag.";
95
+ readonly description: "Whether this flag propagates to subcommands in nested command trees.\n\nWhen `true`, the flag is automatically available to all descendant\ncommands. A child command that defines a flag with the same name\nshadows the propagated parent flag.\n\nDefault: `false`";
96
+ };
97
+ readonly negation: {
98
+ readonly description: "Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation.";
99
+ };
100
+ readonly duplicates: {
101
+ readonly 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'`";
102
+ };
103
+ };
104
+ };
105
+ readonly negation: {
106
+ readonly description: "Negation settings for a boolean flag (set by `.negatable()`).\n\nThe negated spelling and the positive form are two spellings of ONE\nlogical flag: they share duplicate policy, and the last CLI occurrence\nwins across both. The negated spelling is presence-only — `--no-foo=x`\nis rejected.";
107
+ readonly properties: {
108
+ readonly alias: {
109
+ readonly description: "Explicit negated spelling without the `--` prefix (e.g. `'no-sandbox'`).\n`undefined` synthesizes `no-<flagName>` wherever the flag name is known.";
110
+ };
111
+ readonly hidden: {
112
+ readonly description: "Hide the negated spelling from help, completions, and suggestions.";
96
113
  };
97
114
  };
98
115
  };
@@ -112,7 +129,7 @@ declare const definitionMetaSchemaDescriptions: {
112
129
  readonly description: "Whether this arg consumes all remaining positionals.";
113
130
  };
114
131
  readonly stdinMode: {
115
- readonly description: "Whether this arg may read from stdin during resolution.";
132
+ readonly description: "Whether this arg may read from stdin during resolution.\n\nDefault: `false`";
116
133
  };
117
134
  readonly defaultValue: {
118
135
  readonly description: "Runtime default value (if any).";
@@ -147,10 +164,10 @@ declare const definitionMetaSchemaDescriptions: {
147
164
  readonly description: "Available choices. When omitted for `enum` flags, the enum values\nfrom the flag schema are used automatically.";
148
165
  };
149
166
  readonly min: {
150
- readonly description: "Minimum number of selections required.";
167
+ readonly description: "Minimum number of selections required.\n\nDefault: `0`";
151
168
  };
152
169
  readonly max: {
153
- readonly description: "Maximum number of selections allowed.";
170
+ readonly description: "Maximum number of selections allowed.\n\nDefault: `Infinity`";
154
171
  };
155
172
  };
156
173
  };
@@ -161,7 +178,7 @@ declare const definitionMetaSchemaDescriptions: {
161
178
  readonly description: "The value returned when this choice is selected.";
162
179
  };
163
180
  readonly label: {
164
- readonly description: "Display label shown to the user.";
181
+ readonly description: "Display label shown to the user.\n\nDefault: value";
165
182
  };
166
183
  readonly description: {
167
184
  readonly description: "Optional description shown alongside the choice.";