@kjanat/dreamcli 4.0.0-rc.3 → 4.0.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 (212) hide show
  1. package/README.md +5 -7
  2. package/dist/{runtime/adapter.d.mts → adapter-D0hbBNVB.d.mts} +2 -4
  3. package/dist/completion-D4mz6axB.mjs +6 -0
  4. package/dist/completion.d.mts +90 -0
  5. package/dist/completion.mjs +1 -0
  6. package/dist/config-B9ddC-Kb.mjs +1 -0
  7. package/dist/config.d.mts +2 -0
  8. package/dist/config.mjs +1 -0
  9. package/dist/core-Cp2w8vRq.mjs +17 -0
  10. package/dist/index-BziI2aKc.d.mts +5440 -0
  11. package/dist/index-DOfClfYR.d.mts +370 -0
  12. package/dist/index-DWsnGZlx.d.mts +831 -0
  13. package/dist/{core/cli/index.d.mts → index-DXROeDPC.d.mts} +116 -57
  14. package/dist/index-DndPmT8J.d.mts +275 -0
  15. package/dist/{core/json-schema/index.d.mts → index-DyoaS234.d.mts} +43 -34
  16. package/dist/index.d.mts +190 -41
  17. package/dist/index.mjs +1 -26
  18. package/dist/json-schema-C9SzZ7jY.mjs +52 -0
  19. package/dist/json-schema.d.mts +2 -0
  20. package/dist/json-schema.mjs +1 -0
  21. package/dist/package-json-BgE9YjjQ.mjs +3 -0
  22. package/dist/prompt.d.mts +48 -0
  23. package/dist/prompt.mjs +1 -0
  24. package/dist/rolldown-runtime-G4Kt5YOX.mjs +1 -0
  25. package/dist/runtime.d.mts +2 -6
  26. package/dist/runtime.mjs +1 -6
  27. package/dist/terminal-C8KTXjv5.mjs +6 -0
  28. package/dist/test-prompter-v__jT2yG.mjs +1 -0
  29. package/dist/testkit.d.mts +54 -6
  30. package/dist/testkit.mjs +1 -5
  31. package/dist/version.mjs +1 -7
  32. package/dreamcli.schema.json +697 -538
  33. package/package.json +29 -7
  34. package/skills/cli-creation/SKILL.md +16 -11
  35. package/CHANGELOG.md +0 -1116
  36. package/dist/core/cli/builtins.d.mts +0 -117
  37. package/dist/core/cli/builtins.mjs +0 -135
  38. package/dist/core/cli/compiled.d.mts +0 -66
  39. package/dist/core/cli/compiled.mjs +0 -76
  40. package/dist/core/cli/dispatch.d.mts +0 -115
  41. package/dist/core/cli/dispatch.mjs +0 -205
  42. package/dist/core/cli/help-links.d.mts +0 -27
  43. package/dist/core/cli/help-links.mjs +0 -41
  44. package/dist/core/cli/index.mjs +0 -1271
  45. package/dist/core/cli/planner.d.mts +0 -174
  46. package/dist/core/cli/planner.mjs +0 -323
  47. package/dist/core/cli/plugin.d.mts +0 -94
  48. package/dist/core/cli/plugin.mjs +0 -41
  49. package/dist/core/cli/propagate.d.mts +0 -39
  50. package/dist/core/cli/propagate.mjs +0 -57
  51. package/dist/core/cli/reserved-flags.d.mts +0 -19
  52. package/dist/core/cli/reserved-flags.mjs +0 -158
  53. package/dist/core/cli/root-help.d.mts +0 -53
  54. package/dist/core/cli/root-help.mjs +0 -221
  55. package/dist/core/cli/root-output-flags.d.mts +0 -74
  56. package/dist/core/cli/root-output-flags.mjs +0 -169
  57. package/dist/core/cli/root-surface.d.mts +0 -64
  58. package/dist/core/cli/root-surface.mjs +0 -28
  59. package/dist/core/cli/runtime-preflight.d.mts +0 -213
  60. package/dist/core/cli/runtime-preflight.mjs +0 -221
  61. package/dist/core/completion/index.d.mts +0 -76
  62. package/dist/core/completion/index.mjs +0 -90
  63. package/dist/core/completion/shells/bash.d.mts +0 -23
  64. package/dist/core/completion/shells/bash.mjs +0 -312
  65. package/dist/core/completion/shells/fish.d.mts +0 -19
  66. package/dist/core/completion/shells/fish.mjs +0 -164
  67. package/dist/core/completion/shells/powershell.d.mts +0 -13
  68. package/dist/core/completion/shells/powershell.mjs +0 -360
  69. package/dist/core/completion/shells/shared.d.mts +0 -164
  70. package/dist/core/completion/shells/shared.mjs +0 -147
  71. package/dist/core/completion/shells/zsh.d.mts +0 -23
  72. package/dist/core/completion/shells/zsh.mjs +0 -256
  73. package/dist/core/config/index.d.mts +0 -191
  74. package/dist/core/config/index.mjs +0 -285
  75. package/dist/core/config/package-json.d.mts +0 -179
  76. package/dist/core/config/package-json.mjs +0 -353
  77. package/dist/core/errors/index.d.mts +0 -125
  78. package/dist/core/errors/index.mjs +0 -87
  79. package/dist/core/execution/index.d.mts +0 -61
  80. package/dist/core/execution/index.mjs +0 -220
  81. package/dist/core/help/ansi.d.mts +0 -84
  82. package/dist/core/help/ansi.mjs +0 -121
  83. package/dist/core/help/index.d.mts +0 -149
  84. package/dist/core/help/index.mjs +0 -418
  85. package/dist/core/help/theme.d.mts +0 -86
  86. package/dist/core/help/theme.mjs +0 -69
  87. package/dist/core/json-schema/index.mjs +0 -1008
  88. package/dist/core/json-schema/meta-descriptions.generated.d.mts +0 -274
  89. package/dist/core/json-schema/meta-descriptions.generated.mjs +0 -136
  90. package/dist/core/output/activity.d.mts +0 -193
  91. package/dist/core/output/activity.mjs +0 -452
  92. package/dist/core/output/bind.d.mts +0 -37
  93. package/dist/core/output/bind.mjs +0 -56
  94. package/dist/core/output/contracts.d.mts +0 -82
  95. package/dist/core/output/contracts.mjs +0 -57
  96. package/dist/core/output/display-value.d.mts +0 -19
  97. package/dist/core/output/display-value.mjs +0 -32
  98. package/dist/core/output/index.d.mts +0 -344
  99. package/dist/core/output/index.mjs +0 -514
  100. package/dist/core/output/renderers.d.mts +0 -45
  101. package/dist/core/output/renderers.mjs +0 -46
  102. package/dist/core/output/writer.d.mts +0 -39
  103. package/dist/core/output/writer.mjs +0 -12
  104. package/dist/core/parse/index.d.mts +0 -178
  105. package/dist/core/parse/index.mjs +0 -850
  106. package/dist/core/parse/occurrences.d.mts +0 -90
  107. package/dist/core/parse/occurrences.mjs +0 -114
  108. package/dist/core/prompt/index.d.mts +0 -213
  109. package/dist/core/prompt/index.mjs +0 -348
  110. package/dist/core/read-flags/index.d.mts +0 -150
  111. package/dist/core/read-flags/index.mjs +0 -217
  112. package/dist/core/resolve/args.d.mts +0 -39
  113. package/dist/core/resolve/args.mjs +0 -182
  114. package/dist/core/resolve/coerce.d.mts +0 -79
  115. package/dist/core/resolve/coerce.mjs +0 -900
  116. package/dist/core/resolve/config.d.mts +0 -10
  117. package/dist/core/resolve/config.mjs +0 -19
  118. package/dist/core/resolve/contracts.d.mts +0 -146
  119. package/dist/core/resolve/errors.d.mts +0 -10
  120. package/dist/core/resolve/errors.mjs +0 -148
  121. package/dist/core/resolve/flags.d.mts +0 -74
  122. package/dist/core/resolve/flags.mjs +0 -246
  123. package/dist/core/resolve/index.d.mts +0 -44
  124. package/dist/core/resolve/index.mjs +0 -123
  125. package/dist/core/resolve/path-checks.d.mts +0 -48
  126. package/dist/core/resolve/path-checks.mjs +0 -102
  127. package/dist/core/resolve/redaction.d.mts +0 -13
  128. package/dist/core/resolve/redaction.mjs +0 -14
  129. package/dist/core/resolve/stages.d.mts +0 -86
  130. package/dist/core/resolve/stages.mjs +0 -170
  131. package/dist/core/resolve/standard.d.mts +0 -26
  132. package/dist/core/resolve/standard.mjs +0 -212
  133. package/dist/core/schema/activity.d.mts +0 -189
  134. package/dist/core/schema/arg.d.mts +0 -1461
  135. package/dist/core/schema/arg.mjs +0 -1139
  136. package/dist/core/schema/brand.d.mts +0 -17
  137. package/dist/core/schema/cardinality.d.mts +0 -302
  138. package/dist/core/schema/cardinality.mjs +0 -514
  139. package/dist/core/schema/command.d.mts +0 -1132
  140. package/dist/core/schema/command.mjs +0 -999
  141. package/dist/core/schema/flag.d.mts +0 -1495
  142. package/dist/core/schema/flag.mjs +0 -1207
  143. package/dist/core/schema/index.d.mts +0 -15
  144. package/dist/core/schema/index.mjs +0 -10
  145. package/dist/core/schema/middleware.d.mts +0 -129
  146. package/dist/core/schema/middleware.mjs +0 -41
  147. package/dist/core/schema/number-constraints.d.mts +0 -96
  148. package/dist/core/schema/number-constraints.mjs +0 -60
  149. package/dist/core/schema/prompt.d.mts +0 -135
  150. package/dist/core/schema/provenance.d.mts +0 -99
  151. package/dist/core/schema/provenance.mjs +0 -28
  152. package/dist/core/schema/run.d.mts +0 -211
  153. package/dist/core/schema/source.d.mts +0 -180
  154. package/dist/core/schema/source.mjs +0 -206
  155. package/dist/core/schema/standard.d.mts +0 -100
  156. package/dist/core/schema/standard.mjs +0 -15
  157. package/dist/core/schema/stdin.d.mts +0 -97
  158. package/dist/core/schema/stdin.mjs +0 -91
  159. package/dist/core/schema/string-constraints.d.mts +0 -108
  160. package/dist/core/schema/string-constraints.mjs +0 -86
  161. package/dist/core/schema/value-parsers.d.mts +0 -150
  162. package/dist/core/schema/value-parsers.mjs +0 -160
  163. package/dist/core/schema/value.d.mts +0 -243
  164. package/dist/core/schema/value.mjs +0 -573
  165. package/dist/core/testkit/index.d.mts +0 -63
  166. package/dist/core/testkit/index.mjs +0 -102
  167. package/dist/runtime/adapter.mjs +0 -92
  168. package/dist/runtime/auto.d.mts +0 -25
  169. package/dist/runtime/auto.mjs +0 -45
  170. package/dist/runtime/deno.d.mts +0 -99
  171. package/dist/runtime/deno.mjs +0 -265
  172. package/dist/runtime/detect.d.mts +0 -86
  173. package/dist/runtime/detect.mjs +0 -45
  174. package/dist/runtime/index.d.mts +0 -6
  175. package/dist/runtime/node.d.mts +0 -71
  176. package/dist/runtime/node.mjs +0 -228
  177. package/dist/runtime/paths.d.mts +0 -31
  178. package/dist/runtime/paths.mjs +0 -48
  179. package/dist/strings.d.mts +0 -27
  180. package/dist/strings.mjs +0 -22
  181. package/examples/basic.ts +0 -37
  182. package/examples/flag-types.ts +0 -79
  183. package/examples/gh/package.json +0 -45
  184. package/examples/gh/src/commands/auth.ts +0 -66
  185. package/examples/gh/src/commands/issue.ts +0 -120
  186. package/examples/gh/src/commands/pr.ts +0 -125
  187. package/examples/gh/src/data/issues.yaml +0 -5
  188. package/examples/gh/src/data/issues.yaml.d.ts +0 -17
  189. package/examples/gh/src/data/pull-requests.yaml +0 -7
  190. package/examples/gh/src/data/pull-requests.yaml.d.ts +0 -18
  191. package/examples/gh/src/docs.ts +0 -11
  192. package/examples/gh/src/lib/auth.ts +0 -37
  193. package/examples/gh/src/lib/utils.ts +0 -17
  194. package/examples/gh/src/main.test.ts +0 -307
  195. package/examples/gh/src/main.ts +0 -46
  196. package/examples/help-config.ts +0 -43
  197. package/examples/interactive.ts +0 -67
  198. package/examples/json-mode.ts +0 -95
  199. package/examples/middleware.ts +0 -71
  200. package/examples/multi-command.ts +0 -66
  201. package/examples/output-extras.ts +0 -46
  202. package/examples/parser-control.ts +0 -40
  203. package/examples/pwsh-demo/README.md +0 -40
  204. package/examples/pwsh-demo/package.json +0 -41
  205. package/examples/pwsh-demo/pwsh-demo.cmd +0 -3
  206. package/examples/pwsh-demo/smoke-powershell.ps1 +0 -218
  207. package/examples/pwsh-demo/src/main.test.ts +0 -45
  208. package/examples/pwsh-demo/src/main.ts +0 -140
  209. package/examples/spinner-progress.ts +0 -49
  210. package/examples/standard-schema.ts +0 -45
  211. package/examples/testing.ts +0 -147
  212. package/examples/transport-launcher.ts +0 -85
@@ -1,23 +1,104 @@
1
- import { schemaBrand } from "../schema/brand.mjs";
2
- import { BuiltinMode, BuiltinName, Builtins, BuiltinsConfig } from "./builtins.mjs";
3
- import { HelpThemeFactory } from "../help/theme.mjs";
4
- import { FlagBuilder, FlagConfig } from "../schema/flag.mjs";
5
- import { ArgBuilder, ArgConfig } from "../schema/arg.mjs";
6
- import { Verbosity } from "../output/contracts.mjs";
7
- import { CommandBuilder, CommandDefinition, CommandSchema, Out } from "../schema/command.mjs";
8
- import "../help/index.mjs";
9
- import { CapturedOutput } from "../output/index.mjs";
10
- import { RunOptions, RunResult } from "../schema/run.mjs";
11
- import { ParseOptions } from "../parse/index.mjs";
12
- import { BeforeParseParams, CLIPlugin, CLIPluginHooks, PluginCommandContext, ResolvedCommandParams, plugin } from "./plugin.mjs";
13
- import { CompiledCLI } from "./compiled.mjs";
14
- import { RuntimeAdapter } from "../../runtime/adapter.mjs";
15
- import { PackageJsonData } from "../config/package-json.mjs";
16
- import { HelpLinks } from "./help-links.mjs";
17
- import { CompletionOptions } from "../completion/shells/shared.mjs";
18
- import { Shell } from "../completion/index.mjs";
19
- import { FormatLoader } from "../config/index.mjs";
1
+ import { C as ErasedActionHandler, E as ExecutionStep, G as ArgConfig, Jn as schemaBrand, Ln as HelpThemeFactory, Nt as FlagBuilder, Pt as FlagConfig, U as Verbosity, W as ArgBuilder, _ as CommandDefinition, b as CommandSchema, g as CommandBuilder } from "./index-BziI2aKc.mjs";
2
+ import { H as Builtins, U as BuiltinsConfig, b as ParseOptions, n as RunResult, t as RunOptions, u as CLIPlugin } from "./index-DWsnGZlx.mjs";
3
+ import { n as RuntimeAdapter } from "./adapter-D0hbBNVB.mjs";
4
+ import { h as PackageJsonData, s as FormatLoader } from "./index-DOfClfYR.mjs";
20
5
  import { Colors } from "ansispeck";
6
+ //#region src/core/completion/shells/shared.d.ts
7
+ /**
8
+ * Options for completion script generation.
9
+ *
10
+ * Passed to individual shell generators alongside the CLI schema.
11
+ *
12
+ * These options affect the generated script text, not runtime completion
13
+ * behavior after installation.
14
+ */
15
+ interface CompletionOptions {
16
+ /**
17
+ * Override the generated shell function name prefix.
18
+ *
19
+ * Defaults to the CLI name from the schema. This is mainly useful when
20
+ * embedding multiple generated scripts in the same environment and you want
21
+ * deterministic, collision-free helper names.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * generateCompletion(schema, 'bash', { functionPrefix: 'acme' });
26
+ * ```
27
+ */
28
+ readonly functionPrefix?: string;
29
+ /**
30
+ * Controls which root-level surface shell completion exposes when a
31
+ * default command exists.
32
+ *
33
+ * - `'subcommands'` keeps hybrid CLIs command-centric at the root while
34
+ * still exposing default-command flags for a single visible default
35
+ * command.
36
+ * - `'surface'` exposes the default command's root-usable flags at the
37
+ * root whenever a visible default command exists.
38
+ *
39
+ * @defaultValue `'subcommands'`
40
+ */
41
+ readonly rootMode?: 'subcommands' | 'surface';
42
+ }
43
+ //#endregion
44
+ //#region src/core/completion/shell.d.ts
45
+ /**
46
+ * Supported shell targets for completion script generation.
47
+ *
48
+ * `bash`, `zsh`, `fish`, and `powershell` are implemented today.
49
+ */
50
+ type Shell = 'bash' | 'zsh' | 'fish' | 'powershell';
51
+ /**
52
+ * Implemented shell values as a frozen readonly non-empty tuple.
53
+ *
54
+ * Use this tuple for user-facing validation and shell selection UIs.
55
+ * It intentionally matches the shipped {@link Shell} union exactly so docs,
56
+ * help output, and completion generation advertise the same support surface.
57
+ *
58
+ * @see {@link Shell} for the union type matching these entries.
59
+ */
60
+ declare const SHELLS: Readonly<readonly ['bash', 'zsh', 'fish', 'powershell']>;
61
+ //#endregion
62
+ //#region src/core/cli/compiled.d.ts
63
+ /**
64
+ * Executable form of one registered command.
65
+ */
66
+ interface CompiledCommand {
67
+ /** The very {@linkcode CommandSchema} object the public schema tree holds. */
68
+ readonly schema: CommandSchema;
69
+ /** Action handler, `undefined` for commands that only group subcommands. */
70
+ readonly handler: ErasedActionHandler | undefined;
71
+ /** Derive and middleware steps in registration order. */
72
+ readonly steps: readonly ExecutionStep[];
73
+ /** Nested subcommands, keyed by name and by every alias. */
74
+ readonly subcommands: ReadonlyMap<string, CompiledCommand>;
75
+ }
76
+ /**
77
+ * Executable state of a CLI program.
78
+ */
79
+ interface CompiledCLI {
80
+ /** Top-level commands in registration order. */
81
+ readonly commands: readonly CompiledCommand[];
82
+ /** The default command, `undefined` when none is registered. */
83
+ readonly defaultCommand: CompiledCommand | undefined;
84
+ /** Plugins in registration order. */
85
+ readonly plugins: readonly CLIPlugin[];
86
+ }
87
+ //#endregion
88
+ //#region src/core/cli/help-links.d.ts
89
+ /**
90
+ * OSC 8 hyperlink targets for the root-help header.
91
+ *
92
+ * Set via `CLIBuilder.links()`; fields left `undefined` are derived from
93
+ * manifest metadata when `.manifest()` is active.
94
+ */
95
+ interface HelpLinks {
96
+ /** URL the program name links to (e.g. the repository or homepage). */
97
+ readonly name: string | undefined;
98
+ /** URL the version links to (e.g. the release tag). */
99
+ readonly version: string | undefined;
100
+ }
101
+ //#endregion
21
102
  //#region src/core/cli/index.d.ts
22
103
  /**
23
104
  * Runtime descriptor for the CLI program.
@@ -122,15 +203,21 @@ interface CLISchema {
122
203
  readonly builtins: Builtins;
123
204
  }
124
205
  /**
125
- * Read the compiled state seeded by {@linkcode CLIBuilder._from}.
126
- *
127
- * @param builder - Builder to look up.
128
- * @returns Its compiled execution graph.
129
- * @throws {@linkcode CLIError} `INVALID_BUILDER_STATE` when the builder was not created by `cli()`.
130
- *
131
- * @internal
206
+ * Options for {@link CLIBuilder.completions}: the generator options plus where
207
+ * the built-in completion is exposed.
132
208
  */
133
- declare function compiledStateOf(builder: CLIBuilder): CompiledCLI;
209
+ interface CompletionRegistrationOptions extends CompletionOptions {
210
+ /**
211
+ * Where the built-in shell completion is exposed.
212
+ *
213
+ * - `'command'` registers a `completions` subcommand (the default).
214
+ * - `'flag'` exposes an eager `--completions <shell>` flag on the CLI root
215
+ * instead, keeping the root free of a `completions` subcommand.
216
+ *
217
+ * @defaultValue `'command'`
218
+ */
219
+ readonly as?: 'command' | 'flag';
220
+ }
134
221
  /**
135
222
  * Configuration for the eager `--completions <shell>` flag.
136
223
  *
@@ -450,22 +537,6 @@ interface CLIRunOptions extends CLIExecuteOptions {
450
537
  */
451
538
  readonly adapter?: RuntimeAdapter;
452
539
  }
453
- /**
454
- * CLI execution options extended with the fields `.run()` and dispatch
455
- * populate themselves.
456
- *
457
- * @internal
458
- */
459
- interface InternalCLIExecuteOptions extends CLIExecuteOptions {
460
- /** Output channel override so activity renders to the terminal. */
461
- readonly out?: Out;
462
- /** Capture buffers override paired with `out`. */
463
- readonly captured?: CapturedOutput;
464
- /** CLI plugins registered on the builder. */
465
- readonly plugins?: readonly CLIPlugin[];
466
- /** Built-in flag state from the schema, threaded to the command executor. */
467
- readonly builtins?: BuiltinsConfig;
468
- }
469
540
  /**
470
541
  * Inputs for {@linkcode resolveRenderContext}. Pass the host facts (TTY
471
542
  * status, environment) and any explicit overrides; the resolver applies the
@@ -1022,7 +1093,7 @@ declare class CLIBuilder {
1022
1093
  * .run();
1023
1094
  * ```
1024
1095
  */
1025
- completions(options?: CompletionOptions): CLIBuilder;
1096
+ completions(options?: CompletionRegistrationOptions): CLIBuilder;
1026
1097
  /**
1027
1098
  * Execute the CLI program against explicit argv.
1028
1099
  *
@@ -1053,18 +1124,6 @@ declare class CLIBuilder {
1053
1124
  */
1054
1125
  run(options?: CLIRunOptions): Promise<never>;
1055
1126
  }
1056
- /**
1057
- * Execution body shared by {@linkcode CLIBuilder.execute} and {@linkcode CLIBuilder.run},
1058
- * accepting the framework-populated output channel and plugin fields.
1059
- *
1060
- * @param builder - Builder supplying the schema and compiled command graph.
1061
- * @param argv - Raw argv tokens (NOT including the binary/script path).
1062
- * @param options - Injectable runtime state plus framework-populated fields.
1063
- * @returns Structured result with exit code and captured output.
1064
- *
1065
- * @internal
1066
- */
1067
- declare function executeCLI(builder: CLIBuilder, argv: readonly string[], options?: InternalCLIExecuteOptions): Promise<RunResult>;
1068
1127
  /**
1069
1128
  * CLI-name inference control for {@link ManifestSettings.inferName}.
1070
1129
  *
@@ -1173,4 +1232,4 @@ declare function cli(options: CLIOptions): CLIBuilder;
1173
1232
  */
1174
1233
  declare function isMainModule(meta: ImportMeta): boolean;
1175
1234
  //#endregion
1176
- export { type BeforeParseParams, type BuiltinMode, type BuiltinName, type Builtins, type BuiltinsConfig, CLIBuilder, type CLIDefinition, type CLIExecuteOptions, type CLIOptions, type CLIPlugin, type CLIPluginHooks, type CLIRunOptions, type CLISchema, type CompletionsFlagConfig, type ConfigSettings, type ConfigSettingsDefinition, type DefaultCommandOptions, type HelpConfig, type HelpLinks, type InferNameOption, type ManifestSettings, type PluginCommandContext, type RenderContext, type RenderContextOptions, type ResolvedCommandParams, type ResolvedManifestSettings, cli, compiledStateOf, createCLISchema, executeCLI, isMainModule, plugin, resolveRenderContext };
1235
+ export { SHELLS as C, HelpLinks as S, CompletionOptions as T, ResolvedManifestSettings as _, CLIRunOptions as a, isMainModule as b, CompletionsFlagConfig as c, DefaultCommandOptions as d, HelpConfig as f, RenderContextOptions as g, RenderContext as h, CLIOptions as i, ConfigSettings as l, ManifestSettings as m, CLIDefinition as n, CLISchema as o, InferNameOption as p, CLIExecuteOptions as r, CompletionRegistrationOptions as s, CLIBuilder as t, ConfigSettingsDefinition as u, cli as v, Shell as w, resolveRenderContext as x, createCLISchema as y };
@@ -0,0 +1,275 @@
1
+ import { n as RuntimeAdapter } from "./adapter-D0hbBNVB.mjs";
2
+ //#region src/runtime/detect.d.ts
3
+ /**
4
+ * Auto-detects the current JavaScript runtime environment.
5
+ *
6
+ * Uses `globalThis` feature detection (version globals) to identify
7
+ * the runtime without importing platform-specific modules. This is
8
+ * the recommended approach because each runtime defines a unique
9
+ * global marker:
10
+ *
11
+ * - **Bun:** `globalThis.Bun.version` (string)
12
+ * - **Deno:** `globalThis.Deno.version` (object with `deno` key)
13
+ * - **Node:** `globalThis.process.versions.node` (string)
14
+ *
15
+ * Detection order matters: Bun provides a Node-compatible `process`
16
+ * global, so it must be checked *before* Node to avoid misidentification.
17
+ *
18
+ * @module @kjanat/dreamcli/runtime/detect
19
+ */
20
+ /**
21
+ * Known JavaScript runtime environments.
22
+ *
23
+ * - `'node'` — Node.js
24
+ * - `'bun'` — Bun
25
+ * - `'deno'` — Deno
26
+ * - `'unknown'` — Unrecognized environment
27
+ */
28
+ type Runtime = 'node' | 'bun' | 'deno' | 'unknown';
29
+ /**
30
+ * All known runtime values as a readonly tuple.
31
+ *
32
+ * Useful for validation, iteration, and exhaustiveness checks.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * if (RUNTIMES.includes(value)) {
37
+ * // value is a valid Runtime
38
+ * }
39
+ * ```
40
+ */
41
+ declare const RUNTIMES: readonly ['node', 'bun', 'deno', 'unknown'];
42
+ /**
43
+ * Minimal `globalThis` shape used for runtime detection.
44
+ *
45
+ * Each field is optional — only the present one identifies the runtime.
46
+ * Typed as `unknown` where we only need truthiness; version fields are
47
+ * typed just enough to distinguish runtimes safely.
48
+ */
49
+ interface GlobalForDetect {
50
+ /** Present when running on Bun. */
51
+ readonly Bun?: {
52
+ readonly version?: string;
53
+ };
54
+ /** Present when running on Deno. */
55
+ readonly Deno?: {
56
+ readonly version?: {
57
+ readonly deno?: string;
58
+ };
59
+ };
60
+ /** Present on Node.js (and Bun, which mimics it). */
61
+ readonly process?: {
62
+ readonly versions?: {
63
+ readonly node?: string;
64
+ readonly bun?: string;
65
+ };
66
+ };
67
+ }
68
+ /**
69
+ * Detect the current JavaScript runtime.
70
+ *
71
+ * Uses `globalThis` feature detection to identify the host runtime.
72
+ * Detection order is significant: Bun is checked before Node because
73
+ * Bun exposes a Node-compatible `process` global.
74
+ *
75
+ * @param globals - Override `globalThis` for testing. Production callers
76
+ * should omit this parameter.
77
+ * @returns The detected {@link Runtime} identifier.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const rt = detectRuntime();
82
+ * // rt === 'node' | 'bun' | 'deno' | 'unknown'
83
+ * ```
84
+ */
85
+ declare function detectRuntime(globals?: GlobalForDetect): Runtime;
86
+ //#endregion
87
+ //#region src/runtime/auto.d.ts
88
+ /**
89
+ * Create a runtime adapter for the current environment.
90
+ *
91
+ * Detection order follows {@link detectRuntime}: Bun → Deno → Node → unknown.
92
+ * Only Deno needs a distinct adapter; Bun, Node, and unknown runtimes all use
93
+ * the Node adapter because they expose a Node-compatible `process` global.
94
+ *
95
+ * @param globals - Override `globalThis` for testing. Production callers
96
+ * should omit this parameter.
97
+ * @returns A {@linkcode RuntimeAdapter} for the detected runtime.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { cli } from '@kjanat/dreamcli';
102
+ *
103
+ * // Auto-detects Node/Bun/Deno and creates the right adapter
104
+ * cli('mycli').run(); // uses createAdapter() internally
105
+ * ```
106
+ */
107
+ declare function createAdapter(globals?: GlobalForDetect): RuntimeAdapter;
108
+ //#endregion
109
+ //#region src/runtime/deno.d.ts
110
+ /**
111
+ * Minimal subset of the Deno namespace needed by the adapter.
112
+ *
113
+ * We avoid `@types/deno` to keep the core runtime-agnostic at the type level.
114
+ * This interface declares only what `createDenoAdapter` actually reads.
115
+ *
116
+ * The `env` property is optional because it requires `--allow-env` permission.
117
+ * When permission is denied, the adapter catches the error and falls back to
118
+ * an empty env object.
119
+ */
120
+ interface DenoNamespace {
121
+ /** Build target metadata (OS detection). */
122
+ readonly build: {
123
+ readonly os: 'darwin' | 'linux' | 'android' | 'windows' | 'freebsd' | 'netbsd' | 'aix' | 'solaris' | 'illumos';
124
+ };
125
+ /** Deno version info — used for minimum-version guard. */
126
+ readonly version?: {
127
+ readonly deno?: string;
128
+ };
129
+ /** Raw command-line args (excludes the binary/script — Deno pre-strips them). */
130
+ readonly args: readonly string[];
131
+ /** Environment variable access (requires `--allow-env`). */
132
+ readonly env: {
133
+ /** Get a single env var. Returns `undefined` if unset or permission denied. */
134
+ get(key: string): string | undefined;
135
+ /** Get all env vars as a plain object. Throws on permission denied. */
136
+ toObject(): Record<string, string>;
137
+ };
138
+ /** Current working directory (may throw if `--allow-read` is denied for cwd). */
139
+ cwd(): string;
140
+ /** Standard output — synchronous byte writer with TTY detection. */
141
+ readonly stdout: {
142
+ /** Write raw bytes to stdout synchronously. */
143
+ writeSync(p: Uint8Array): number;
144
+ /** Whether stdout is connected to a TTY. */
145
+ isTerminal(): boolean;
146
+ };
147
+ /** Current console dimensions. */
148
+ consoleSize?(): {
149
+ readonly columns: number;
150
+ readonly rows: number;
151
+ };
152
+ /** Register a native signal listener. */
153
+ addSignalListener?(signal: 'SIGWINCH', listener: () => void): void;
154
+ /** Remove a native signal listener. */
155
+ removeSignalListener?(signal: 'SIGWINCH', listener: () => void): void;
156
+ /** Standard error — synchronous byte writer. */
157
+ readonly stderr: {
158
+ /** Write raw bytes to stderr synchronously. */
159
+ writeSync(p: Uint8Array): number;
160
+ };
161
+ /** Standard input — TTY detection and readable byte stream. */
162
+ readonly stdin: {
163
+ /** Whether stdin is connected to a TTY. */
164
+ isTerminal(): boolean;
165
+ /** Readable stream for stdin bytes. */
166
+ readonly readable: ReadableStream<Uint8Array>;
167
+ };
168
+ /** Exit the process with the given code. */
169
+ exit(code: number): never;
170
+ /** Read a file as UTF-8 text (requires `--allow-read`). */
171
+ readTextFile(path: string): Promise<string>;
172
+ /** Probe a filesystem path (requires `--allow-read`). */
173
+ stat(path: string): Promise<{
174
+ readonly isDirectory: boolean;
175
+ }>;
176
+ /** Create a directory (requires `--allow-write`). */
177
+ mkdir(path: string, options?: {
178
+ readonly recursive?: boolean;
179
+ }): Promise<void>;
180
+ }
181
+ /**
182
+ * Create a runtime adapter backed by the Deno namespace.
183
+ *
184
+ * Reads `Deno.args`, `Deno.env`, `Deno.cwd()`, and wraps Deno's stream-based
185
+ * I/O into the {@linkcode WriteFn}/{@linkcode ReadFn} functions expected by the framework.
186
+ *
187
+ * Unlike Node/Bun, Deno strips the binary and script path from `Deno.args`.
188
+ * The adapter prepends synthetic entries (`['deno', 'run']`) so the argv
189
+ * shape matches the {@linkcode RuntimeAdapter} contract (binary + script + user args).
190
+ *
191
+ * @param ns - Override the Deno namespace (useful for testing the adapter itself).
192
+ * @returns A {@linkcode RuntimeAdapter} backed by Deno's namespace APIs.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { cli } from '@kjanat/dreamcli';
197
+ * import { createDenoAdapter } from '@kjanat/dreamcli/runtime';
198
+ *
199
+ * cli('mycli')
200
+ * .command(deploy)
201
+ * .run({ adapter: createDenoAdapter() });
202
+ * ```
203
+ */
204
+ declare function createDenoAdapter(ns?: DenoNamespace): RuntimeAdapter;
205
+ //#endregion
206
+ //#region src/runtime/node.d.ts
207
+ /**
208
+ * Minimal subset of the Node.js `process` object needed by the adapter.
209
+ *
210
+ * We avoid importing `@types/node` to keep the core runtime-agnostic
211
+ * at the type level. This interface declares only what `createNodeAdapter`
212
+ * actually reads from the global.
213
+ */
214
+ interface NodeProcess {
215
+ /** Raw process arguments (`[binary, script, ...userArgs]`). */
216
+ readonly argv: readonly string[];
217
+ /** Environment variables (values are `undefined` for unset keys). */
218
+ readonly env: Readonly<Record<string, string | undefined>>;
219
+ /** Runtime version strings — used for version-guard checks. */
220
+ readonly versions?: {
221
+ readonly node?: string;
222
+ readonly bun?: string;
223
+ };
224
+ /** Return the current working directory. */
225
+ cwd(): string;
226
+ /** Platform identifier (e.g. `'linux'`, `'darwin'`, `'win32'`). */
227
+ readonly platform: string;
228
+ /** Standard input stream with TTY detection and async iteration. */
229
+ readonly stdin: {
230
+ readonly isTTY?: boolean;
231
+ /** Async iterable for reading all of stdin (used by readStdin). */
232
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
233
+ };
234
+ /** Standard output stream with TTY detection and write. */
235
+ readonly stdout: {
236
+ readonly isTTY?: boolean;
237
+ readonly columns?: number;
238
+ readonly rows?: number;
239
+ getWindowSize?(): readonly [number, number];
240
+ on?(event: 'resize', listener: () => void): unknown;
241
+ off?(event: 'resize', listener: () => void): unknown;
242
+ removeListener?(event: 'resize', listener: () => void): unknown;
243
+ write(data: string): unknown;
244
+ };
245
+ /** Standard error stream with write. */
246
+ readonly stderr: {
247
+ write(data: string): unknown;
248
+ };
249
+ /** Terminate the process with the given exit code. */
250
+ exit(code: number): never;
251
+ }
252
+ /**
253
+ * Create a runtime adapter backed by Node.js `process` globals.
254
+ *
255
+ * Reads `process.argv`, `process.env`, `process.cwd()`, and wraps
256
+ * `process.stdout.write`/`process.stderr.write` as {@linkcode WriteFn} functions.
257
+ *
258
+ * Also works on Bun, which provides a Node-compatible `process` global.
259
+ *
260
+ * @param proc - Override the process object (useful for testing the adapter itself).
261
+ * @returns A {@linkcode RuntimeAdapter} backed by Node.js process state.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * import { cli } from '@kjanat/dreamcli';
266
+ * import { createNodeAdapter } from '@kjanat/dreamcli/runtime/node';
267
+ *
268
+ * cli('mycli')
269
+ * .command(deploy)
270
+ * .run({ adapter: createNodeAdapter() });
271
+ * ```
272
+ */
273
+ declare function createNodeAdapter(proc?: NodeProcess): RuntimeAdapter;
274
+ //#endregion
275
+ export { createAdapter as a, Runtime as c, createDenoAdapter as i, detectRuntime as l, createNodeAdapter as n, GlobalForDetect as o, DenoNamespace as r, RUNTIMES as s, NodeProcess as t };
@@ -1,11 +1,30 @@
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";
6
- import { CommandSchema, ExampleMeta } from "../schema/command.mjs";
7
- import "../schema/index.mjs";
8
- import { CLISchema } from "../cli/index.mjs";
1
+ import { Bt as FlagKind, Pn as NumberConstraints, Q as ArgKind, T as ExampleMeta, Ut as FlagPresence, b as CommandSchema, et as ArgPresence, jt as DuplicatePolicy, kn as PromptKind, vt as DuplicateKeys } from "./index-BziI2aKc.mjs";
2
+ import "./index-DWsnGZlx.mjs";
3
+ import { o as CLISchema } from "./index-DXROeDPC.mjs";
4
+ //#region src/core/json-schema/constants.d.ts
5
+ /**
6
+ * Identifiers of the definition document format.
7
+ *
8
+ * @module dreamcli/core/json-schema/constants
9
+ */
10
+ /**
11
+ * `$schema` URL for definition documents.
12
+ *
13
+ * Self-hosted. The `v1` segment is the definition format version, the value
14
+ * every document reports as `schemaVersion`, so it resolves for every package
15
+ * release that emits `schemaVersion: 1`. Two mirrors carry identical bytes:
16
+ * `./node_modules/@kjanat/dreamcli/dreamcli.schema.json` for offline or
17
+ * local-first workflows, and
18
+ * `https://cdn.jsdelivr.net/npm/@kjanat/dreamcli/dreamcli.schema.json` on the
19
+ * npm CDN.
20
+ */
21
+ declare const DEFINITION_SCHEMA_URL = "https://dreamcli.kjanat.dev/schemas/definition/v1.schema.json";
22
+ /**
23
+ * Version of the definition document format emitted by `generateSchema()`
24
+ * and `generateCommandSchema()` from `@kjanat/dreamcli/json-schema`.
25
+ */
26
+ declare const DEFINITION_SCHEMA_VERSION = 1;
27
+ //#endregion
9
28
  //#region src/core/json-schema/index.d.ts
10
29
  /**
11
30
  * Options for JSON Schema generation.
@@ -38,23 +57,6 @@ interface JsonSchemaOptions {
38
57
  */
39
58
  readonly includePrompts?: boolean;
40
59
  }
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
60
  /**
59
61
  * A usage example inside a definition document.
60
62
  *
@@ -144,13 +146,8 @@ type FlagPathChecksFragmentV1 = {
144
146
  readonly type?: 'file' | 'directory';
145
147
  readonly create?: true;
146
148
  };
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 = {
149
+ /** A collection flag's element fragment, excluding input-level metadata. */
150
+ type FlagElementFragmentV1 = {
154
151
  readonly kind: FlagKind;
155
152
  readonly presence: FlagPresence;
156
153
  readonly defaultValue?: unknown;
@@ -162,7 +159,7 @@ type FlagDefinitionFragmentV1 = {
162
159
  readonly enumValues?: readonly string[];
163
160
  readonly numberConstraints?: NumberConstraints;
164
161
  readonly stringConstraints?: FlagStringConstraintsFragmentV1;
165
- readonly elementSchema?: FlagDefinitionFragmentV1;
162
+ readonly elementSchema?: FlagElementFragmentV1;
166
163
  readonly separator?: string;
167
164
  readonly split?: SourceSplitFragmentV1;
168
165
  readonly duplicateKeys?: DuplicateKeys;
@@ -175,6 +172,16 @@ type FlagDefinitionFragmentV1 = {
175
172
  readonly negation?: FlagNegationFragmentV1;
176
173
  readonly duplicates?: DuplicatePolicy;
177
174
  };
175
+ /**
176
+ * A flag entry inside a definition document.
177
+ *
178
+ * Optional fields appear only when the flag sets them; `defaultValue` appears
179
+ * only for non-sensitive inputs when the value survives a JSON round-trip.
180
+ */
181
+ type FlagDefinitionFragmentV1 = FlagElementFragmentV1 & {
182
+ readonly defaultDescription?: string | false;
183
+ readonly sensitive?: true;
184
+ };
178
185
  /**
179
186
  * The supported value-axis fields of an entries arg's `elementSchema`.
180
187
  *
@@ -204,6 +211,8 @@ type ArgDefinitionFragmentV1 = {
204
211
  readonly variadic?: true;
205
212
  readonly stdin?: StdinBindingFragmentV1;
206
213
  readonly defaultValue?: unknown;
214
+ readonly defaultDescription?: string | false;
215
+ readonly sensitive?: true;
207
216
  readonly description?: string;
208
217
  readonly envVar?: string;
209
218
  readonly configPath?: string;
@@ -387,4 +396,4 @@ declare function generateInputSchema(schema: CLISchema | CommandSchema, options?
387
396
  */
388
397
  declare const definitionMetaSchema: Record<string, unknown>;
389
398
  //#endregion
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 };
399
+ export { definitionMetaSchema as C, DEFINITION_SCHEMA_URL as D, generateSchema as E, DEFINITION_SCHEMA_VERSION as O, StdinBindingFragmentV1 as S, generateInputSchema as T, JsonSchemaOptions as _, CommandDefinitionFragmentV1 as a, SourceSplitFragmentV1 as b, ExampleDefinitionFragmentV1 as c, FlagNegationFragmentV1 as d, FlagPathChecksFragmentV1 as f, InputSchemaProperty as g, InputSchemaDocument as h, CommandDefinitionDocumentV1 as i, FlagDefinitionFragmentV1 as l, InputSchemaBranch as m, ArgElementFragmentV1 as n, DefinitionDocument as o, FlagStringConstraintsFragmentV1 as p, CommandDefinitionDocument as r, DefinitionDocumentV1 as s, ArgDefinitionFragmentV1 as t, FlagElementFragmentV1 as u, PromptChoiceFragmentV1 as v, generateCommandSchema as w, SplitPolicyFragmentV1 as x, PromptDefinitionFragmentV1 as y };