@kjanat/dreamcli 4.0.0-rc.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +5 -7
  2. package/dist/{runtime/adapter.d.mts → adapter-YM5QGi3M.d.mts} +4 -4
  3. package/dist/completion-CUMeOnAz.mjs +6 -0
  4. package/dist/completion.d.mts +90 -0
  5. package/dist/completion.mjs +1 -0
  6. package/dist/config-CrlScpYX.mjs +1 -0
  7. package/dist/config.d.mts +2 -0
  8. package/dist/config.mjs +1 -0
  9. package/dist/core-DvXUolc_.mjs +17 -0
  10. package/dist/{core/json-schema/index.d.mts → index-3l8uj16E.d.mts} +43 -34
  11. package/dist/{core/cli/index.d.mts → index-BAj2y70U.d.mts} +116 -57
  12. package/dist/index-BziI2aKc.d.mts +5440 -0
  13. package/dist/index-Cap0MA2V.d.mts +277 -0
  14. package/dist/index-Cp9kt2t-.d.mts +370 -0
  15. package/dist/index-DWsnGZlx.d.mts +831 -0
  16. package/dist/index.d.mts +190 -41
  17. package/dist/index.mjs +1 -26
  18. package/dist/json-schema-DRlrz_IV.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
package/CHANGELOG.md DELETED
@@ -1,1116 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ### Release checklist
10
-
11
- - [ ] Set the intended version in `package.json` and `deno.json`, add the dated changelog section, and update every comparison link.
12
- - [ ] Update first-party DreamCLI pins in documentation and import-map configuration; do not rewrite versions that belong to transitive lockfile metadata.
13
- - [ ] Run `runner run -s schema:emit version:check ci smoke`.
14
- - [ ] Pack with `bun pm pack --quiet --ignore-scripts` and inspect the tarball's files and version.
15
- - [ ] Confirm generators and formatters leave no unexpected worktree changes.
16
- - [ ] Commit and push the release preparation, then verify the target commit is signed, `master` matches the remote, and every required check is green.
17
- - [ ] Confirm the exact `v<version>` tag does not already exist and npm and JSR do not already contain that version before publishing the GitHub release.
18
-
19
- ## [4.0.0-rc.3] - 2026-09-05
20
-
21
- ### Added
22
-
23
- - Let `flag.*().describe()` and `arg.*().describe()` accept a function that receives the resolved help theme, keeping semantic highlighting inside prose on the framework's color gate. Add `.help({ descriptionTheme })` for scoped role overrides that merge over the global theme (https://github.com/kjanat/dreamcli/issues/93).
24
-
25
- ### Fixed
26
-
27
- - **Published archives exclude generated workspace dependencies and Python bytecode.**\
28
- npm tarballs no longer include nested `node_modules` trees or `__pycache__` files from packaged examples and skills.
29
- - **Completion scripts no longer offer surface-only defaults as named commands** (https://github.com/kjanat/dreamcli/pull/127).\
30
- A command registered with `.default(command)` now exposes its flags only at the root instead of also suggesting a command name that cannot be invoked. Defaults registered with `.default(command, { route: true })` remain available by name in Bash, Zsh, Fish, and PowerShell completions.
31
- - **Explicit hyperlink flags override environment defaults** (https://github.com/kjanat/dreamcli/issues/126).\
32
- `--hyperlinks` now overrides `NO_HYPERLINKS`, while `--no-hyperlinks` overrides `FORCE_HYPERLINKS`. Without an explicit flag, `NO_HYPERLINKS` still wins over `FORCE_HYPERLINKS`.
33
-
34
- ## [4.0.0-rc.2] - 2026-08-17
35
-
36
- ### Fixed
37
-
38
- - **Published testkit declarations accept command builders again** (https://github.com/kjanat/dreamcli/issues/122).\
39
- `runCommand()` now exposes a declaration-safe generic `CommandBuilder` parameter while keeping its execution pipeline type-erased internally. Package builds also compile the public testing example against the emitted declarations so internal-member stripping cannot silently break this contract again.
40
-
41
- ## [4.0.0-rc.1] - 2026-08-12
42
-
43
- ### Added
44
-
45
- - **Handlers can see where each value came from** (https://github.com/kjanat/dreamcli/issues/90).\
46
- `ActionParams`, `DeriveParams`, and `MiddlewareParams` gain `sources`, keyed like `flags` and `args`, holding the full record resolution already produced: `{ stage: 'cli' }`, `{ stage: 'cli', via: 'stdin', trigger: 'dash' }`, `{ stage: 'stdin', via: 'stdin', trigger: 'fallback' }`, `{ stage: 'env', envVar }`, `{ stage: 'config', configPath }`, `{ stage: 'prompt' }`, or `{ stage: 'default' }`. An input that resolved no value has no record. `wasExplicit(record)` derives the explicit-versus-defaulted question from it without dropping `.default()`, which would also drop `defaultValue` from the definition document. `ResolveResult.provenance` carries the same records for a direct `resolve()` caller, and `readFlags()` hands them to a new `onSources` receiver, typed against the definitions record. `ResolutionProvenance`, `ResolutionProvenanceRecord`, `InputSources`, `SourcesOf`, and `wasExplicit` are exported from the package root. The existing `ResolutionProvenance` name continues to describe one input's winning stage; `ResolutionProvenanceRecord` names the complete `ResolveResult.provenance` object.
47
-
48
- - **`arg.keyValue()` takes an element builder** (https://github.com/kjanat/dreamcli/issues/87).\
49
- Entry values used to be strings on the positional surface while `flag.keyValue(element)` gave them a codec. `arg.keyValue(arg.number().int().min(0))` now resolves `mycli scale web=3` to `{ web: 3 }`, with the element's constraints, path checks, and Standard Schema validator applied to every entry, from every source. The element is guarded the same way flags guard theirs: `ArgConfig` gains `elementEligible`, so a builder already described as a positional (`.optional()`, `.env()`, `.stdin()`, `.describe()`, …) is refused in element position at compile time. `ArgSchema` gains `elementSchema`, which serializes into definition documents under the new `ArgElementFragmentV1` shape and the `$defs.argElement` meta-schema definition.
50
-
51
- - **Help names the stdin source.**\
52
- An input that declares `.stdin()` renders `[stdin]` beside the existing `[env: X]`, `[config: y]`, and `[prompt]` annotations, on the flag table and the argument table alike. The narrower triggers say which one applies: `[stdin: '-']` for `{ when: 'dash' }` and `[stdin: when omitted]` for `{ when: 'missing' }`. Completion scripts are unchanged; they carry the plain description.
53
-
54
- - **A dedicated error code for a dash with nothing piped.**\
55
- `ValidationErrorCode` gains `MISSING_STDIN`, which replaces the borrowed `REQUIRED_FLAG` / `REQUIRED_ARG` on the one failure that is neither: a `-` typed beside other occurrences of a collection when the stream is empty. Those two keep their own meaning, a required input no source filled.
56
-
57
- - **A variadic argument reads stdin from its tail.**\
58
- `.stdin()` and `.variadic()` now compose. A `-` among the tail tokens stands for the whole stdin source at that position, so `printf 'x\ny\n' | mycli build a - b` collects `['a', 'x', 'y', 'b']`, and an empty tail under a binding that covers a missing input takes the whole buffer. `arg.keyValue().variadic().stdin()` aggregates entries across the typed tokens and the pipe under its `.duplicateKeys()` policy. Each `-` stands for all of the buffer, so two of them splice it twice, and the stream is still read at most once per invocation. The preflight that decides whether to read stdin counts an empty tail as an absent input, which is what makes `printf 'x\ny\n' | mycli build` reach the fallback stage under `.run()`.
59
-
60
- - **`.stdin({ trim: true })` drops the terminator a pipe appends.**\
61
- Codecs that preserve text terminators, including `string` and `path`, keep the buffer byte for byte by default. `trim` drops one trailing `\n`, `\r\n`, or `\r` from a single value before anything decodes or checks it, so `echo ./dist | mycli clean` satisfies `arg.path({ mustExist: true })`. It applies to both surfaces, to an explicit `-` and to the implicit fallback, and to `readFlags()` and `runCommand()`. Other decoding codecs already remove one framing terminator and are unaffected, so no value ever loses two. A collection's terminators separate its elements, so `.split({ stdin })` still decides those. The binding serializes as `stdin.trim` in definition documents, alongside `when` and `consume`.
62
-
63
- - **Stability policy and a 4.0 upgrade guide**\
64
- The [stability page](https://dreamcli.kjanat.dev/reference/stability) now places every export of the root, `/testkit`, `/runtime`, and `/version` entrypoints in one of thirteen categories, each with the rules it carries into a minor release: sealed framework values, consumer input options, transparent input definitions, implementer ports, externally governed protocols, structural consumer configuration, closed unions and discriminated results, open unions, framework-produced callback payloads, closed constructible DTOs, serialized formats, classes and functions, and internal surface.\
65
- [Upgrading From 3.x To 4.0](https://dreamcli.kjanat.dev/guide/upgrading-v4) walks the breaking changes below with before and after code.
66
-
67
- - **Definition types and normalization factories for flags, args, commands, and the CLI**\
68
- `createFlagSchema()`, `createCommandSchema()`, and `createCLISchema()` join the existing `createArgSchema()`. The flag and arg factories take a plain definition object, or a kind plus that kind's fields; the command and CLI factories take complete definition objects. Each returns the normalized schema; feeding a built schema back in produces a deep-equal schema, and a field belonging to another kind throws `INVALID_SCHEMA`. `createCommandSchema()` normalizes nested flags, args, and subcommands, and `createCLISchema()` normalizes commands and config settings for a description of a program with no execution graph attached.\
69
- Each level ships its definition types: `FlagDefinition`, `FlagDefinitionBase`, `FlagDefinitionByKind`, `FlagDefinitionOverrides`, and the per-kind members `StringFlagDefinition`, `NumberFlagDefinition`, `BooleanFlagDefinition`, `EnumFlagDefinition`, `ArrayFlagDefinition`, `CustomFlagDefinition`, `CountFlagDefinition`, `KeyValueFlagDefinition`; `ArgDefinition`, `ArgDefinitionBase`, `ArgDefinitionByKind`, `ArgDefinitionOverrides`, `StringArgDefinition`, `NumberArgDefinition`, `EnumArgDefinition`, `CustomArgDefinition`; `CommandDefinition` with `CommandArgEntryDefinition`; and `CLIDefinition` with `ConfigSettingsDefinition`.\
70
- All of them are exported from the package root.
71
-
72
- - **`.builtins()` takes `--help`, `--json`, or `--quiet` over to the commands** (https://github.com/kjanat/dreamcli/issues/86).\
73
- A CLI whose `--json` names the document it operates on, whose `-q` means something domain-specific, or whose `--help` is a routable topic browser can now claim the token. `cli('mycli').builtins({ json: 'off' })` releases every spelling that built-in answers to. The root stops reading and stripping it from argv, root help stops listing it under `Global options:`, the `RESERVED_FLAG` guard stops reserving it, and a command may declare it as an ordinary flag that parses and reaches the handler. Releasing `help` also disables command-level `--help`/`-h`, the bare `help` token, the `--help` footer hint, the `Run '<bin> --help' for available commands` suggestion on dispatch errors, and the synthetic `--help` in generated completion scripts. `version` and `completions` have no entry, since `.version()` and `.completions()` are opt-in and a CLI declines those by omission. Every built-in defaults to `'on'`, repeated calls merge with the last mode per built-in winning, and `RunOptions.jsonMode` / `RunOptions.verbosity` keep working regardless, since only argv-driven activation is disabled. The state is normalized onto `CLISchema.builtins` by both `.builtins()` and the `builtins` field of `createCLISchema()`, an invalid mode throws `INVALID_SCHEMA`, and `BuiltinsConfig`, `Builtins`, `BuiltinName`, and `BuiltinMode` are exported from the package root. `runCommand()` from `/testkit` takes the same `builtins` option so a command owning a released flag can be tested; its options type is now `RunCommandOptions`. The `RESERVED_FLAG` error offers `.builtins({ <name>: 'off' })` alongside renaming, and a version discovered by `.manifest()` filesystem walking now runs the same guard at `.run()` time instead of silently shadowing a command's `version` flag. That startup failure is reported the way every other `.run()` startup failure is: the message and its suggestion go to stderr, `--json` puts the serialized error on stdout, and the process exits with the error's exit code rather than rejecting the `.run()` promise.
74
-
75
- - **Definition format v1 — versioned, typed documents**\
76
- `generateSchema()` and `generateCommandSchema()` now emit `schemaVersion: 1`, so a consumer can tell which format it is reading before parsing the rest. Both return typed documents instead of `Record<string, unknown>`: `DefinitionDocumentV1` for a whole CLI, `CommandDefinitionDocumentV1` for a single command, with `DefinitionDocument` and `CommandDefinitionDocument` aliasing the current version. Documents are distinct from the fragments nested inside them. `CommandDefinitionFragmentV1`, `FlagDefinitionFragmentV1`, `ArgDefinitionFragmentV1`, `ExampleDefinitionFragmentV1`, `PromptDefinitionFragmentV1`, `PromptChoiceFragmentV1`, `FlagNegationFragmentV1`, `FlagStringConstraintsFragmentV1`, and `FlagPathChecksFragmentV1` carry no `schemaVersion` and take the version of the document they sit in. `generateInputSchema()` is standard JSON Schema and stays outside the family, typed as `InputSchemaDocument` with `InputSchemaBranch` and `InputSchemaProperty`. Every one of these is exported from the package root, and the returned documents remain assignable to `Record<string, unknown>`. `--help` in `--json` mode serializes through `generateCommandSchema()`, so that output gains `schemaVersion: 1` as its first key.
77
-
78
- - **`readFlags()` evaluates a record of flag builders outside a CLI** (https://github.com/kjanat/dreamcli/issues/107).\
79
- A build script or a small tool that wants typed options without commands, handlers, or output channels hands its flags straight to `readFlags()` and awaits the resolved values, typed by `InferFlags`:
80
-
81
- ```ts
82
- const options = await readFlags({
83
- watch: flag.boolean().alias('w').env('WATCH'),
84
- minify: flag.boolean().env('MINIFY').default(true),
85
- target: flag.enum(['node', 'browser']).env('TARGET').default('node'),
86
- });
87
-
88
- options.watch; // boolean
89
- options.target; // 'node' | 'browser'
90
- ```
91
-
92
- Each object key is the canonical flag name, and evaluation runs through the same command schema, parser, coercion, resolver, and validation a command uses. Aliases, negated spellings, duplicate policy, case parity, unknown-flag rejection, collisions between names, aliases and negated forms, the CLI, stdin, env, config, prompt, default precedence, constraints, Standard Schema validators, and `flag.path()` checks all behave as they do inside `.action()`. `argv`, `env`, `stdinData`, `stat`, and `mkdir` fall back to the detected `RuntimeAdapter`, while `config` and `prompter` stay caller-supplied, since standalone flag reading has no application name to discover a file from and opens no terminal session. `ReadFlagsOptions` extends `ResolveOptions` with `argv`, `adapter`, `parse`, `strict`, `help`, and `onDeprecation`. The adapter is built on the first fact the caller left out, so a call given `argv` and `env` reads nothing from the host unless a `flag.path()` check needs the adapter's filesystem primitives. Failures throw `ParseError` and `ValidationError` instead of exiting, a colliding record, the definition key `__proto__`, and a record whose prototype is replaced (an object-literal `__proto__` key, or `Object.create(base)`, whose inherited definitions are never read) each throw `CLIError` before argv is read, and `.deprecated()` notices reach `onDeprecation` rather than a warning stream, since there is no output channel on this path.
93
-
94
- A pre-separator `--help` or `-h` prints generated help for the record to the adapter's stdout and exits with code 0, with the script named from the adapter's argv in the usage line. The built-in yields to a definition that claims the `help` or `h` spelling through a name, alias, negated form, or case-parity counterpart, and `help: 'off'` removes it entirely; `json` and `quiet` are never reserved, so a record may declare them as ordinary flags. `strict: false` drops undeclared argv content instead of rejecting it: unknown long flags with their inline `=value`, unknown short-group characters, positional arguments, and the `--` separator, while value tokens of declared flags survive under the parser's own consumption rules and misuse of a declared flag keeps its diagnostics.
95
-
96
- Positional arguments are not part of this API, and there is no synchronous variant: prompts, async validators, and filesystem checks make the result a promise. `readFlags`, `ReadFlagsOptions`, and `FlagMap` are exported from the package root, and [Standalone Flag Evaluation](https://dreamcli.kjanat.dev/guide/read-flags) walks the API with the build-script case it was added for.
97
-
98
- - **Purpose-built positional argument kinds and string constraints** (https://github.com/kjanat/dreamcli/issues/87).\
99
- A base URL, an input file, or a cutoff date reads naturally as a positional, and until now the only route was `arg.custom()` re-implementing what `flag.url()` already did. `arg.url(options?)`, `arg.path(options?)`, `arg.date(options?)`, `arg.duration()`, and `arg.bytes()` mirror their flag counterparts: same value types, same option objects (`UrlFlagOptions`, `PathFlagOptions`, `DateFlagOptions`), same parsers. `arg.string()` takes a `StringConstraints` object, and string-kind `ArgBuilder`s carry `.nonEmpty()`, `.minLength()`, `.maxLength()`, and `.pattern()` alongside the numeric `.int()`, `.min()`, `.max()`, and `.finite()` they already had. Both factories run the same parse functions and the same constraint validator, so a value a flag accepts an argument accepts, and a rejection carries the same code and the same reason, differing in the subject: `for flag --x` versus `for argument <x>`.
100
-
101
- String constraints are enforced on CLI parse (`INVALID_VALUE`) and on stdin, env, config, and prompt resolution (`CONSTRAINT_VIOLATED`), both exit code `2`; as with flags, a `.default()` value is checked where it is declared and a violation throws `INVALID_DEFAULT`. `arg.path()` checks run after resolution through the runtime adapter's `stat`/`mkdir`, the same seam `flag.path()` uses, so a piped, env-sourced, config-sourced, prompted, or defaulted path is checked like one typed on the command line. A variadic argument validates every value it collects, path checks included. Argument values sourced from anywhere but argv stay redacted in the message, as in `Invalid value '<redacted>' from stdin for argument <x>` and `Invalid number value '<redacted>' from config deploy.port for argument <x>`, so the flag and argument messages are equivalent apart from their subjects.
102
-
103
- `ArgSchema` and the arg definition types carry `stringConstraints`, `pathChecks`, and `valueHint`. The first two are string-kind gated the way the flag schema gates them. Args serialize `numberConstraints`, `stringConstraints`, `pathChecks`, and `valueHint` into the definition document, which previously emitted none of them, and `generateInputSchema()` now surfaces arg string constraints as `minLength` / `maxLength` / `pattern`. The meta-schema hoists the `numberConstraints`, `stringConstraints`, and `pathChecks` fragments into `$defs` so the flag and arg definitions reference one copy. All of it is additive at `schemaVersion: 1`. Help still renders a positional by its own name rather than its `valueHint`, so `mycli copy <src> <dst>` does not collapse into `<path> <path>`.
104
-
105
- The flag-only surface stays flag-only, and [the arguments guide](https://dreamcli.kjanat.dev/guide/arguments#flag-only-surface) lists it with the reason for each entry. `boolean`, `count`, `negatable`, `alias`, `duplicates`, `separator`, `unique`, and `propagate` are bound to flag syntax; `array` is served by `.variadic()`. `keyValue` merges repeated occurrences into one record, which a positional slot cannot express, and `arg.custom()` with a Standard Schema validator is the documented route. `.config()` and `.prompt()` are no longer among them: both surfaces now declare the same sources, described in the unified source model entry below.
106
-
107
- - **A unified source model — every input uses the same source order**\
108
- Flags and args now declare sources from the same set and resolve declared sources through one ordered chain: `CLI -> stdin -> env -> config -> prompt -> default`. `arg.config(path)` and `arg.prompt(config)` join `arg.env()`, so a positional reads a dotted config key and asks the user exactly as a flag does; the arg prompt table mirrors the flag one (`PromptConfigByArgKind`, `AllowedArgPromptConfig`), and an incompatible pairing throws `CONSTRAINT_VIOLATED` naming `<arg>`. Help annotates a positional with `[config: PATH]` and `[prompt]` beside the `[env: VAR]` it already showed. `flag.string().stdin()` becomes legal on `string`, `number`, `boolean`, `enum`, and `custom` flags, giving `echo hi | mycli send` and `mycli send --body -` the meaning `arg.stdin()` already had. `.stdin()` takes `{ when: 'dash' | 'missing' | 'dash-or-missing', consume: 'exclusive' | 'broadcast' }` on both surfaces, defaulting to `dash-or-missing` and `exclusive`. `StdinBinding`, `StdinOptions`, `StdinWhen`, and `StdinConsume` are exported from the package root, and `StdinBindingFragmentV1` names the serialized form.
109
-
110
- An explicit `-` is CLI-sourced with bytes from stdin and keeps CLI precedence; an absent input takes the stdin fallback stage, which sits ahead of env, so a flag set in the environment still reads a pipe and the pipe wins. The `-` sentinel now survives the parse boundary for every kind, so `flag.number().stdin()` accepts `--port -` where it used to reject `-` as a malformed number. `readFlags()` carries the same contract and reads stdin only through the adapter, only when a declared `.stdin()` flag would actually select it; `runCommand()` feeds the identical path from its `stdinData` option. Stdin is read at most once per invocation, and only when resolution will select it: `when: 'dash'` reads on `-` alone, `when: 'missing'` reads on an absent input alone, and env, config, prompt, and a default never suppress the read.
111
-
112
- One command has one exclusive stdin consumer. Declaring a second stdin input of any kind, flag or arg, throws `DUPLICATE_STDIN_INPUT` on both construction paths; `{ consume: 'broadcast' }` on every stdin input opts into sharing one buffer among them. The definition document carries the binding as `stdin: { when, consume }` on flags and args, with a `stdin` entry in the meta-schema `$defs`, and the arg fragment gains `configPath` and `prompt`.
113
-
114
- - **Cardinality is its own axis, with per-source splitting.**\
115
- How many values an input carries (`one`, `many`, `entries`, `count`) is now decided separately from what each value means, so every source fills a collection by the same rules. `.split({ cli, env, stdin })` on `flag.array()`, `flag.keyValue()`, and the arg builders sets each source's decoding independently: a delimiter or `'whole'` for CLI tokens, a delimiter, `'whole'`, or `{ format: 'json' }` for env values, and `'lines'`, `'whole'`, a delimiter, or `{ format: 'json' }` for the stdin buffer. Defaults are whole CLI tokens (or the `.separator()` delimiter), comma-delimited env values, and line-delimited stdin; a config value stays a native array or object, and a config string decodes under the env policy. JSON is never guessed. `SplitOptions`, `SplitSetting`, `SplitPolicy`, `SplitBinding`, `SourceSplitBinding`, and `SplitFormat` are exported from the package root, and the definition document carries `split` on flag and arg fragments as `SourceSplitFragmentV1` / `SplitPolicyFragmentV1`.
116
-
117
- - **Collections read stdin, and `-` splices into occurrence order.**\
118
- `flag.array()` and `flag.keyValue()` accept `.stdin()`, and a `-` occurrence stands for the whole stdin source at the position it holds: `--tag before --tag - --tag after` over `a\nb\n` resolves to `['before', 'a', 'b', 'after']`. An explicit `-` and the implicit fallback decode identically, entries splice the same way, and the duplicate-key policy applies across the whole spliced order. Broadcast consumers each decode the one shared buffer under their own binding, so a line-split array flag and a JSON key-value flag can read the same pipe.
119
-
120
- - **`.duplicateKeys()` on key-value inputs.**\
121
- `'last'` (the default), `'first'`, or `'error'` decides what a repeated key means, on every source rather than only on repeated CLI occurrences. A repeat under `'error'` reports `CONSTRAINT_VIOLATED` naming the key. `DuplicateKeys` is exported from the package root and the policy is serialized as `duplicateKeys`.
122
-
123
- - **`arg.boolean()` and `arg.keyValue()`.**\
124
- A positional carries no presence semantics, so `arg.boolean()` consumes an explicit `true`/`false` (or `1`/`0`) token through the shared boolean codec, widening to `yes`/`no` and an empty string only for env, config, stdin, and prompt values. `arg.keyValue()` consumes `KEY=VALUE` tokens and resolves to `Record<string, string>`, splitting at the first `=`; the variadic form aggregates the whole tail into one record. `BooleanArgDefinition` and `KeyValueArgDefinition` join the definition types, and `ArgKind` gains `'boolean'` and `'keyValue'`.
125
-
126
- - **Element-level sugar inside collections.**\
127
- Path checks and constraints belong to the element, so `flag.array(flag.path({ mustExist: true }))` checks every collected element and `flag.keyValue(flag.path())` checks every entry value. `flag.keyValue()` takes an optional element builder, and `flag.path()` is now element-eligible.
128
-
129
- - **`.standard()` on both builders, split into element and aggregate validation.**\
130
- A validator declared on an element builder (`flag.array(flag.string().standard(s))`) validates each item or entry value; one declared on a builder that already aggregates (`flag.array(flag.string()).standard(s)`, `arg.string().variadic().standard(s)`) validates the completed array or record after every element passed. Element issues name the element (`--tag[1]`, `--vars.KEY`). Sync and async validators are both awaited, and every source runs the same pipeline.
131
-
132
- - **`.unique()` and `.separator()` on args.**\
133
- A variadic arg deduplicates with the same `SameValueZero` semantics an array flag uses, and splits each positional token on the CLI separator it declares.
134
-
135
- ### Changed
136
-
137
- - **Breaking: flag diagnostics redact every value resolved outside a literal CLI value.**\
138
- A stdin, environment, config, or prompt value that failed to coerce used to be printed and stored under `details.value` on the flag surface, while the argument surface already redacted it. Both surfaces now report `Invalid value '<redacted>' from env API_TOKEN for flag --token: must match /^ghp_/` and omit `value` from `details`. Everything that identifies the failure stays: the input name, the source, the expected type, the constraint that failed with its bound or pattern, the allowed enum values, and a custom parse function's own message. A Standard Schema validator's `CONSTRAINT_VIOLATED` failure follows the same rule: `details.value` is recorded only for a value typed on the command line, and omitted for one a pipe, an explicit `-`, the environment, a config file, or a prompt supplied. A literal CLI value is untouched, since it is already on the user's screen. Every coercion failure now also carries `source: 'env' | 'config' | 'stdin' | 'prompt'` in `details`, which is what labels an issue `[env API_TOKEN]` in an aggregate error and what now gives the argument surface the same label the flag surface had. The `flag.path()` and `arg.path()` filesystem checks read the same rule, so a path a pipe, an explicit `-`, the environment, a config file, a prompt, or a declared default supplied reports `Path '<redacted>' for flag --key does not exist` and omits `value` from `details`; a path typed on the command line is still quoted in full. Every element of a collection of paths is checked and redacted individually.
139
-
140
- - **Breaking: a positional declared after a variadic one is a build error.**\
141
- A variadic argument consumes every remaining positional, so anything registered behind it could never be filled and a second variadic one had nothing left to collect. Both silently produced an argument that stayed empty. `.arg()` and `createCommandSchema()` now throw `INVALID_BUILDER_STATE` (`Argument <target> comes after variadic argument <files>, which consumes every remaining positional`), with the command under `command`, the offending argument under `arg`, and the greedy one under `variadicArg`, so a definition tree names the nested command that declared the pair. Move the variadic argument last.
142
-
143
- - **Breaking: an explicit `-` with nothing piped is an error inside a collection.**\
144
- `--tag a --tag - --tag b` with an empty pipe used to resolve to `['a', 'b']`, dropping the occurrence the user typed. It now fails with `MISSING_STDIN` and the message `No piped stdin for the '-' occurrence of flag --tag`. Occurrences of nothing but `-` are unchanged: they are the whole value, so they still fall through to env, config, prompt, and the default, exactly as an absent input does, and the implicit `when: 'missing'` fallback that simply does not fire stays silent. A scalar `-` falls through for the same reason. Only a collection could be silently shortened, so only a collection errors.
145
-
146
- - **Breaking: the arg collection modifiers require a collection.**\
147
- `createArgSchema('string', { unique: true })` and its siblings used to build, storing a field nothing would read. They now state their requirement to the compiler and throw `INVALID_SCHEMA` from `createArgSchema()`: `separator` and `split` want a variadic argument or `arg.keyValue()`, `unique` a variadic argument of a list kind, and `duplicateKeys` `arg.keyValue()`. The values a schema already stores as its own default, `unique: false` and `duplicateKeys: 'last'`, stay accepted on any kind, so a built `ArgSchema` fed back through the factory round-trips. This mirrors the `array | keyValue` restriction the flag surface already had. Drop the field, or add `variadic: true` alongside it. The matching builder methods are new in 4.0, so only definitions composed as data change.
148
-
149
- - **Breaking: `.stdin()` and `.variadic()` on one argument is now legal.**\
150
- The pairing threw `INVALID_BUILDER_STATE`; the tail-splicing entry under Added describes what it does instead. Code that relied on the throw has nothing to catch.
151
-
152
- - **Breaking: declared defaults are validated.**\
153
- A `.default()` value is already the typed value, so it is validated rather than decoded: the codec's own domain, string and number constraints, element and aggregate Standard Schema validators, the shape the cardinality requires, and the collection rules all apply to it. Purely synchronous violations throw `INVALID_DEFAULT` where the chain declares them, so `flag.string({ minLength: 3 }).default('ab')` and `flag.number().default(Number.POSITIVE_INFINITY)` now fail at construction instead of reaching a handler; a constraint added after the default (`flag.string().default('ab').minLength(3)`) is checked too, as is a validator (`.standard()`). On the definition path, where no compiler stands in the way, the domain check also rejects a default of the wrong primitive type and an `enum` default outside `enumValues`. Asynchronous validators and `flag.path()` filesystem checks stay at resolution time, where command resolution awaits the validator or probes the path. Code relying on a default that violates its own declaration either fixes the default or widens the constraint (`flag.number({ finite: false })` still accepts `Infinity`).
154
-
155
- - **Breaking: `.separator()` sets the CLI delimiter alone.**\
156
- Env and config string values used to inherit it, so `.separator('|')` silently changed how an env var decoded. Env values split on `','` unless `.split({ env })` says otherwise. The stdin buffer splits on line terminators by default; `.split({ stdin })` can select `'whole'`, `'json'`, or a delimiter instead. Config arrays and objects remain native; config strings use the env split policy. `.separator('|')` becomes `.split({ cli: '|', env: '|' })` where the old coupling was intended.
157
-
158
- - **Breaking: `FlagSchema` and `ArgSchema` carry the cardinality axis.**\
159
- `FlagSchema` gains `split`, `duplicateKeys`, and `aggregateStandard`; `ArgSchema` gains `separator`, `split`, `duplicateKeys`, `unique`, and `aggregateStandard`. `elementSchema` and `separator` are valid on `keyValue` as well as `array` flags, `standard` is valid on every kind, `aggregateStandard` only on a kind that aggregates, and `stdin` is valid on scalar and collection kinds. Definition documents serialize the new fields additively at `schemaVersion: 1`, which has not shipped, with `split` and `splitPolicy` entries in the meta-schema `$defs`.
160
-
161
- - **Breaking: `.default()` on a variadic arg takes the array.**\
162
- The type parameter followed the element type, so the only value that compiled was a single element, which is not what a variadic arg resolves to. It now follows `ArgDefaultValue`, the value the arg actually produces: `arg.string().variadic().default(['a', 'b'])`, and a record for `arg.keyValue()`. `ArgDefaultValue` is exported from the package root.
163
-
164
- - **Breaking: `ArgSchema.stdinMode` is now `ArgSchema.stdin`**\
165
- The boolean carried no room for the trigger and sharing modes the unified source model needs, so it is replaced by `stdin: StdinBinding | undefined`. `.stdin()` is unchanged for callers who pass no options and keeps its exact resolution behavior. Code reading the schema directly reads `schema.stdin !== undefined` where `schema.stdinMode` used to be, and a definition passed to `createArgSchema()` or `createCommandSchema()` writes `stdin: {}` instead of `stdinMode: true`. The definition document changes to match: the arg fragment emits `stdin: { when, consume }` in place of `stdinMode: true`, at `schemaVersion: 1`, which has not shipped.
166
-
167
- - **Breaking: `DUPLICATE_STDIN_ARG` is now `DUPLICATE_STDIN_INPUT`**\
168
- The rule covers flags as well as args, and a flag-versus-flag conflict reporting an arg-shaped code would be a lie. The message reads `Only one input may consume stdin exclusively; <name> already consumes stdin`, naming the input that was declared first. `details` names the offending input under `flag` or `arg` and the existing one under `existingFlag` or `existingArg`.
169
-
170
- - **Breaking: stdin values reach non-string codecs without their trailing line terminator**\
171
- The stdin source hands the whole buffer over byte for byte, so `echo hi | mycli` still gives a `string` input `'hi\n'`. Every other codec interprets the text, where a terminator a pipe appended is framing rather than value, so one trailing `\n`, `\r\n`, or `\r` is dropped before decoding. `echo true | mycli` now resolves a boolean input to `true`, `echo 1h30m` to a duration, and `echo eu` to an enum member; all three used to fail. A number input is unaffected, since `Number()` already ignored the terminator. Stdin also stops borrowing the prompt widening table: it accepts exactly what an env value accepts, so the prompt-only `y` and `n` boolean spellings are rejected.
172
-
173
- - **Breaking: a number input rejects blank text instead of reading it as zero.**\
174
- `Number('')` and `Number(' ')` are both `0`, so `PORT= mycli serve`, `printf '\n' | mycli serve`, and a config key holding `""` all resolved a number input to `0` without a word. All three now fail with `TYPE_MISMATCH` and the same `Invalid number value '<redacted>' from …` diagnostic any other unreadable value gets, and `mycli serve --port ''` fails at the parse boundary where it quotes the token. Whitespace around a real number is still ignored, so `' 42 '` and `'42\n'` are unaffected. A `count` flag already guarded this; the number codec now does too. Set the variable, or drop it and let the default apply.
175
-
176
- - **Breaking: `CLISchema.commands` and `CLISchema.defaultCommand` hold `CommandSchema`**\
177
- Both used to hold `ErasedCommand` wrappers carrying the action handler and an `_execute` function. The execution graph now lives beside the schema instead of inside it, so `app.schema.commands[0]` is the command schema itself: read `app.schema.commands[0].name` where `app.schema.commands[0].schema.name` used to be needed. `ErasedCommand` is gone.
178
-
179
- - **Breaking: `CLISchema.plugins` removed**\
180
- Plugins are execution state, not a description of the program, and `.plugin()` no longer writes to the schema. Registration, order, and hook behavior are unchanged.
181
-
182
- - **Breaking: `CLIBuilder` is factory-only**\
183
- Its constructor is private, so `new CLIBuilder(schema)` no longer compiles. Call `cli(name)` or `cli({ ... })`; every builder method still returns a new builder.
184
-
185
- - **Breaking: `CommandSchema.middleware` removed** — the executor builds the handler chain from the builder's ordered execution steps, so registration order, handler identity, and runtime behavior are unchanged. `CommandDefinition` no longer accepts a `middleware` key, and `createCommandSchema()` no longer emits one.
186
-
187
- - **Breaking: `FlagSchema`, `ArgSchema`, and `CommandSchema` are sealed** — all three carry a private brand, so an object literal assembled by hand no longer type-checks where a schema is expected. Call `createFlagSchema()`, `createArgSchema()`, or `createCommandSchema()` with a definition object to obtain one; spreading a built schema keeps the brand, so `{ ...schema, description }` still type-checks. `createSchema()` was renamed to `createFlagSchema()`, which validates its fields against the kind and normalizes a nested `elementSchema`.
188
-
189
- - **Breaking: `createCommandSchema()` validates what the builder validates** — a definition whose flags share a name, an alias, or a negated spelling on one command now throws `FLAG_NAME_COLLISION`, and a flag spelled the same way as one propagated from an ancestor command throws `PROPAGATED_FLAG_COLLISION`. The whole tree is checked, nested subcommands included. Commands built with `command()` already refused these at `.flag()` and `.command()`; a definition composed as data used to build without complaint and then answer the shared spelling with one flag only. Two flags both aliased `v` still parsed under `--verbose` and `--version`, help listed `-v` on both, and `-v` set the second. The arg invariants moved with them, so a definition declaring a positional after a variadic one throws `INVALID_BUILDER_STATE`, and a second stdin-backed input throws `DUPLICATE_STDIN_INPUT`, matching `.arg()`. Previously, both combinations built without complaint. Two stdin-backed args each resolved to the whole of stdin, and a positional behind a variadic one silently never filled. Every arg error names the command in `details`, since a definition tree reaches them at any depth and the arg name alone does not say which command declared it. A flag or arg named `__proto__` now throws `INVALID_SCHEMA` from both the factory and the builder, the check `readFlags()` already applied to its definitions record. The factory and `.arg()` used to accept the key, which sets a prototype rather than an entry, so the flag or the value the user typed disappeared; `.flag()` used to report `FLAG_NAME_COLLISION` against a flag the command never declared. A flag record whose prototype is replaced throws `INVALID_SCHEMA` too, since only its own keys are read: an object-literal `__proto__` key lands there, and so does `Object.create(base)`, whose inherited flags the factory silently dropped. `createCLISchema()` normalizes its commands through the same factory and inherits every check, and `readFlags()` reports the same errors it always did.
190
-
191
- - **Breaking: `CLISchema` and `ConfigSettings` are sealed** — both carry a private brand, so an object literal assembled by hand no longer type-checks where either is expected. Call `cli()` for an executable program or `createCLISchema()` for a description; spreading a built schema keeps the brand, so `{ ...app.schema, name }` still type-checks. `createCLISchema()` throws `INVALID_SCHEMA` on an empty name, which `cli('')` now does too.
192
-
193
- - **Breaking: `createArgSchema()` validates its fields against the kind** — the second parameter is now `ArgDefinitionOverrides<K>` rather than `Partial<ArgSchema>`, so `enumValues` on a `string` arg (and the other kind-scoped fields) stops compiling and throws `INVALID_SCHEMA` at runtime. `enumValues` is required on an `enum` arg. A single definition object (`createArgSchema({ kind: 'enum', enumValues })`) is accepted as well.
194
-
195
- - **Breaking: `Out` gained a required `verbosity` member** — action handlers can read `out.verbosity`, and `resolveRenderContext()` exposes the same `verbosity` decision for custom content built before `.run()` (including `--`-aware `--quiet`/`-q` detection). A hand-rolled `Out` object literal stops compiling until it declares one; migrate to a real channel from the testkit and spy on it instead:
196
-
197
- ```ts
198
- const [out] = createCaptureOutput();
199
- vi.spyOn(out, 'info');
200
- ```
201
-
202
- Do not spread a channel (`{ ...out, info: vi.fn() }`) — its methods are non-enumerable bound copies, so the spread result has none of them.
203
-
204
- - **Breaking: `Out` and `RenderContext` are sealed** — both interfaces now carry a private brand, so implementing or structurally constructing them outside the framework no longer type-checks. They are framework-created, non-exhaustive values: obtain instances from action parameters, `createOutput()`, `createCaptureOutput()`, or `resolveRenderContext()`, and expect new readonly members in minor releases. Helpers that only need a subset can accept `Pick<Out, 'info' | 'status'>`-style capability types.
205
-
206
- - **Breaking: internal execution fields left `RunOptions` and `CLIRunOptions`** — `out`, `captured`, `mergedSchema`, `meta`, and `plugins` were framework-populated fields marked `@internal` yet shipped on the public option types. They now live on unexported internal execution options; code passing them to `runCommand()` or `.execute()` stops compiling. Inject writers via `createCaptureOutput()` options or `OutputOptions.stdout`/ `stderr` instead of replacing the channel wholesale.
207
-
208
- - **Breaking: `.execute()` takes `CLIExecuteOptions`**. The new root export carries the process-free option surface and has no `adapter` member; passing one to `.execute()` stops compiling. `CLIRunOptions` now extends `CLIExecuteOptions` with `adapter`, and `.run()` remains the only method that accepts it.
209
-
210
- - **Breaking: `CommandConfig` and the root `AnyCommandBuilder` export removed**. `CommandConfig` described the builder's type-level accumulator shape but no signature referenced it. `AnyCommandBuilder` is `@internal` erasure machinery that appears only on `CommandBuilder`'s underscore members, so the package root no longer exports the name.
211
-
212
- - **Breaking: the canonical `$schema`/`$id` for definition documents is self-hosted and format-versioned**\
213
- <https://dreamcli.kjanat.dev/schemas/definition/v1.schema.json> replaces the jsDelivr URL in `generateSchema()` output and in `definitionMetaSchema.$id`. The `v1` segment tracks the definition format, so it stays valid for every package release that emits `schemaVersion: 1`, and it is permanent once published. The `@kjanat/dreamcli/schema` subpath and the jsDelivr URL keep serving the same bytes as mirrors. Documents pinned to the old URL still validate against a local copy but no longer match the meta-schema's `$schema` constant.
214
-
215
- - **Breaking: a command flag spelled like a root-owned flag now throws `RESERVED_FLAG` at build time** (https://github.com/kjanat/dreamcli/issues/84).\
216
- The root removes `--json` and `--quiet`/`-q` from argv before dispatch, intercepts `--version`/`-V` once a version is configured, and renders help for `--help`/`-h` before a command's flags are parsed. A command declaring one of those spellings used to build, run, and render help while its flag stayed permanently at its default value. `.command()`, `.default()`, `.version()`, `.manifest(data)`, and `createCLISchema()` now reject it with `CLIError` code `RESERVED_FLAG`, checking each flag's canonical name, its aliases (hidden ones included), and its custom negated spelling (`.negatable({ alias: 'quiet' })`) through the whole nested subcommand tree. The error names the colliding flag and the root flag that shadows it, and suggests renaming, or `out.status()` for output that root `--quiet` suppresses. Near misses such as `jsonOutput` or `quietMode` stay legal, the default `--no-<name>` spelling never collides, and `version`/`V` stay available to a CLI that declares no version.
217
-
218
- - **`--completions` collision detection now covers negated spellings and the definition path.**\
219
- `.negatable({ alias: 'completions' })` and a `createCLISchema()` definition carrying `completionsFlag` both used to build a CLI whose command flag the planner intercepted. Both now throw `CLIError` code `RESERVED_FLAG`, matching what `.completions({ as: 'flag' })` already rejected on the builder.
220
-
221
- ### Removed
222
-
223
- - **Breaking: `.packageJson()`** — deprecated since [2.5](#250---2026-06-28).\
224
- Use `.manifest()`, which defaults to `files: ['package.json']` and accepts the same pre-loaded data object.
225
-
226
- - **Breaking: `.denoJson()`** — deprecated since [2.5](#250---2026-06-28).\
227
- Use `.manifest({ files: ['deno.json', 'deno.jsonc', 'jsr.json'] })`.
228
-
229
- - **Breaking: `ManifestPresetSettings`**\
230
- The settings type of the two removed presets. Use `ManifestSettings`, which adds `files`.
231
-
232
- - **Breaking: `PackageJsonSettings`**\
233
- The deprecated alias for `ResolvedManifestSettings`, the shape stored in `CLISchema.packageJsonSettings`. The schema field itself is unchanged.
234
-
235
- - **Breaking: `discoverPackageJson()`** — deprecated since [2.5](#250---2026-06-28).\
236
- Use `discoverManifest(adapter, { startDir, files: ['package.json'] })`; `files` already defaults to `['package.json']`.
237
-
238
- ### Fixed
239
-
240
- - **A variadic argument could not take the prompt its flag twin takes.** The argument prompt gate read the kind discriminator alone, so `arg.string().variadic().prompt({ kind: 'multiselect' })` was rejected with `Prompt kind 'multiselect' is not compatible with string argument <files>` while `flag.array(flag.string()).prompt({ kind: 'multiselect' })` resolved, and the scalar `input` and `select` kinds the flag surface rejects were accepted, resolving a one-element array. The gate now reads the cardinality: an argument that collects several values takes `multiselect`, and names itself `variadic string argument <files>` when it reports a mismatch. `AllowedArgPromptConfig<C>` follows the same rule, so the compiler agrees.
241
-
242
- - **A collection given a config value of the wrong shape said less on the argument surface.** `flag.array(...).config('p')` over `{ p: 5 }` reported `Invalid array value from config p for flag --tags`; the positional twin reported `Invalid value '<redacted>' from config p for argument <tags>`, naming neither the shape nor a value it actually held. Both surfaces now word it `Invalid array value` / `Invalid object value`, so the byte-for-byte wording rule in [Diagnostics and redaction](https://dreamcli.kjanat.dev/guide/semantics#diagnostics-and-redaction) holds for the collection faults too.
243
-
244
- - **A builder could produce a schema its own factory refuses.** Each modifier states the kinds it belongs to through a `this` constraint, which the compiler enforces and a JavaScript caller does not see, so `flag.string().separator(',')` built a string flag carrying a CLI delimiter and emitted a definition document `createFlagSchema()` then rejected with `INVALID_SCHEMA`. Twelve modifiers on the flag surface and eleven on the argument surface behaved this way. Every builder modifier now runs the same check `createFlagSchema()` / `createArgSchema()` run, so what a builder produces is always a definition the framework reads back. A test calling such a modifier through `@ts-expect-error` and expecting it to build needs `expect(...).toThrow()`.
245
-
246
- - **The normalization factories accepted a kind they have no arm for.** `createFlagSchema('nope')` and `createArgSchema('count')` built a schema whose discriminator is outside `FLAG_KINDS` / `ARG_KINDS`, which every exhaustive `switch (schema.kind)` downstream falls through. The types forbid the call, but a JavaScript caller reached it, and the keyValue prompt gate showed such a schema can reach a shipped diagnostic. Both factories now throw `INVALID_SCHEMA` with `Unknown flag kind 'nope'` / `Unknown arg kind 'count'`, listing the allowed kinds in `details.allowed`, on the two-argument path, the definition path, and a nested `elementSchema`.
247
-
248
- - **`flag.array()` with no element threw a raw `TypeError`.** The factory read `.schema` off the element it was handed, so a JavaScript caller omitting it got `Cannot read properties of undefined` instead of a framework error. It now throws `INVALID_SCHEMA` with `flag.array() requires an element builder`. `flag.keyValue()` and `arg.keyValue()`, whose element is optional, apply the same check to an element that is supplied.
249
-
250
- - **A positional cut a parse function's message at its last colon.** Off argv, the argument surface rebuilt the reason for a failure by scanning the message the flag surface had already written, keeping only the text after the final `": "`. Anything a parse function put before a colon was lost, and a reason whose own tail held a colon was dropped whole: `arg.url({ protocols: ['https'] })` reported `Invalid value '<redacted>' from env ENDPOINT for argument <endpoint>: https`, and `arg.date()` reported no reason at all. `arg.duration()`, `arg.bytes()`, and every `arg.custom()` whose error text carries a colon were affected the same way. Each surface now words its own diagnostic from the value layer's verdict, so the reason reaches the argument surface whole.
251
-
252
- A parse-function failure off argv is also worded the way the flag surface and the command line already word it, so `Failed to parse env ENDPOINT for argument <endpoint>: URL protocol 'http' is not allowed. Allowed: https` replaces the `Invalid value '<redacted>' …` opening, which announced a redaction in the same sentence that printed the parse function's own text. A test asserting the old opening for a non-argv `arg.url()`, `arg.date()`, `arg.duration()`, `arg.bytes()`, or `arg.custom()` message needs the new one.
253
-
254
- - **A positional withheld what a type mismatch expected.** For a value no boolean codec could read, the flag surface reported `Invalid boolean value '<redacted>' …` and suggested `Set VAR to true/false, 1/0, or yes/no`, while the argument surface reported `Invalid value '<redacted>' …` and suggested only `Set VAR to a valid boolean`, which is the question rather than the answer. A string a config object could not fill carried no `expected` field and no suggestion at all on the argument surface. Both now match the flag surface: the message names the type, the details carry `expected`, and the suggestion names what the codec reads.
255
-
256
- - **An argument kind with no compatible prompt was told to use `undefined`.** `createArgSchema({ kind: 'keyValue', prompt: … })` reached the prompt gate, which took the first allowed prompt kind from an empty list and reported `Prompt kind 'input' is not compatible with keyValue argument <vars>. Use 'undefined' instead` with `Change the prompt to { kind: 'undefined' }`. The flag surface already had a branch for a kind that is not promptable at all; both surfaces now share it and report `keyValue arguments are not promptable` with `Remove the prompt config for <vars>`.
257
-
258
- - **A key-value input told the user to write an array.** A config value of the wrong shape for `flag.keyValue()` or `arg.keyValue()` reported `Invalid array value from config c for flag --vars` with `expected: 'array'` and `Set c to an array in your config`, which is not what an entries input accepts and, for a config value that already was an array, not even a change. The fault now carries the shape the cardinality wants: an entries input reads `Invalid object value …` with `expected: 'object'` and `Set c to an object in your config` on the flag surface and `Use KEY=VALUE for <vars>` on the argument surface. A list input is unchanged.
259
-
260
- - **Five types the stability page classified as public were exported from nowhere.** `NodeProcess`, `DenoNamespace`, and `GlobalForDetect` are the host objects `createNodeAdapter()`, `createDenoAdapter()`, and `detectRuntime()` accept, and the page attributes all three to `@kjanat/dreamcli/runtime`, which exported none of them; a caller injecting a host could not name the parameter type. `StringArgElementConfig` and `WithoutArgElementEligibility` sat in the same sentence as `StringElementConfig`, which the root entrypoint does export. All five are now exported, along with the flag-side `WithoutElementEligibility` its argument twin mirrors.
261
-
262
- - **A definition document, its input schema, and help all dropped a default the schema still resolved.** `generateSchema()`, `generateInputSchema()`, and `formatHelp()` each reported a default only for `presence: 'defaulted'`, but resolution uses any `defaultValue` a schema carries, and `createFlagSchema({ kind: 'string', defaultValue: 'dist' })` keeps `presence: 'optional'`. A document emitted from such a schema decoded back to a flag with no default, so a round trip through the format changed behavior; the input schema omitted `default`, and help omitted `(default: dist)` for a flag that does resolve one. All three now report the default whenever the schema carries one, on both surfaces, whatever the presence. Builder-authored schemas are unaffected, since `.default()` sets the defaulted presence.
263
-
264
- Help no longer calls such an input required either. A default binding always produces a value, so neither `REQUIRED_FLAG` nor `REQUIRED_ARG` can fire for a schema carrying a `defaultValue`, yet `flag.string().default('dist').required()` rendered `[required]` and hid its own default while the positional twin rendered `(default: prod)` and still demanded a token as `<target>`. A `defaultValue` now suppresses the `[required]` marker and the angle brackets on both surfaces; an input without one is unchanged.
265
-
266
- - **A duplicate key leaked its text from every non-argv source.** Under `.duplicateKeys('error')`, `Duplicate key 'DB_PASSWORD' from env VARS for flag --vars` quoted the key in the message, in `details.key`, and in `suggest`, whatever source carried it. A key is half of a `KEY=VALUE` pair, so it is value text from that source, and the same pair reported `Invalid key-value pair '<redacted>'` when it failed to split instead. The key is now quoted only for occurrences the user typed on the command line; stdin, env, config, and prompt read `Duplicate key '<redacted>'`, carry no `key` in `details`, and suggest `Set the repeated key once`. Both surfaces follow the rule.
267
-
268
- - **A flag reported a JSON shape fault in the wrong order.** `Invalid JSON value, expected an object from env VARS for flag --vars` put the expectation between the fault and the source that carried it. The flag surface now words it as the argument surface already did: `Invalid JSON value from env VARS for flag --vars, expected an object`.
269
-
270
- - **`ArgElementFragmentV1` was documented as public but exported from nowhere.** `stability.md` classifies it with the other version 1 fragment types and `schema-export.md` names it as the shape of an arg `elementSchema`, but the type never reached `@kjanat/dreamcli`. It is exported now, alongside its siblings.
271
-
272
- - **A default rejected on a vowel-initial kind read `a array`.** The construction-time `INVALID_DEFAULT` message built its subject with a fixed article, so `createFlagSchema('array', …)` and `createFlagSchema('enum', …)` produced `Default value for a array flag` and `Default value for a enum flag`. Both now read `an`.
273
-
274
- - **A duplicate key the user typed said it came from stdin.** Under `.duplicateKeys('error')`, a repeat among CLI occurrences was worded `Duplicate key 'A' from stdin for flag --v`, naming a source the value never had, on a command with no pipe at all. CLI occurrences now name no source (`Duplicate key 'A' for flag --v`), and a key a `-` occurrence spliced in still reads `from stdin`. Each occurrence carries its own source through aggregation, so a collection filled from both names whichever one carried the repeat. `details` no longer claims `source: 'stdin'` for a typed token, and the arg surface follows the same rule with `for argument <vars>`.
275
-
276
- - **`flag.count().stdin()` threw only on the definition path.** The builder method is blocked by its `this` constraint at compile time and `createFlagSchema('count', { stdin: {} })` throws `INVALID_SCHEMA`, but a JavaScript caller reaching the builder got a count flag carrying a stdin binding no stage would ever read. The builder now throws the same error, with the same message and code. In 3.x neither path complained: `createSchema()` stored `stdinMode: true` on a count flag and `.stdin()` did not exist on the count builder at all.
277
-
278
- - **Flags named after `Object.prototype` members were rejected as duplicates** — `.flag('constructor')`, `.flag('toString')`, `.flag('valueOf')`, and every other `Object.prototype` member name failed with a `FLAG_NAME_COLLISION` claiming the command already declared the flag, on commands that declared no flags at all. `collectPropagatedFlags()` read its descendant records the same way, so a propagated flag with one of those names would have stopped at every intermediate subcommand, and `resolveFlags()` read an `.interactive()` resolver's override record the same way, so the inherited method reached the prompt gate as a config and failed the command with `CONSTRAINT_VIOLATED`. `.flag()` refused the name first, so no 3.x CLI ever got that far. Every one of those reads now tests own keys only, so all eleven of those names behave like any other and `createCommandSchema()` accepts the schemas `command()` produces. `__proto__` is the one `Object.prototype` name still rejected, with `INVALID_SCHEMA` on both construction paths, listed under Changed above.
279
-
280
- - **An env var named after an `Object.prototype` member always read as set** — `.env('toString')` on a flag, or on an arg, looked the name up on the env record without checking own keys, so an unset variable resolved to the inherited method and failed coercion instead of falling through to config, prompt, or default. Both lookups now test own keys.
281
-
282
- - **`.run()` never read stdin for an arg named after an `Object.prototype` member** — the precheck that decides whether to read stdin looked the arg name up on the parsed positionals without checking own keys, so an arg such as `.arg('toString', arg.string().stdin())` looked already supplied. `.run()` skipped the read and the command failed with `Missing required argument` however much was piped to it. The lookup now tests own keys. `.execute()` and the testkit take `stdinData` from the caller and were never affected.
283
-
284
- - **`out.table()` printed a native method for a column key named after an `Object.prototype` member** — a column keyed `toString`, `constructor`, or any other member name read the row with a bare lookup, so a row that carried no such key rendered `[Function: toString]` in place of the empty cell every other missing key produces. Dynamic rows typed as `Record<string, unknown>` are the reachable case, including columns inferred from a first row that does carry the key. Both the text renderer and the JSON projection now treat a key that only `Object.prototype` carries as absent. A key held anywhere earlier in the row's prototype chain still renders, so a class getter and an `Object.create(defaults)` fallback reach the table as before.
285
-
286
- - **A Standard Schema validator ran against a native method on a failed resolution** — when a required flag or arg was missing, `resolve()` still ran the Standard Schema pass before rethrowing, over a values record the failed resolver had left empty. The pass read each declared name without checking own keys, so a flag or arg named after an `Object.prototype` member handed its `flag.custom()` / `arg.custom()` validator the inherited method. The user saw a second, invented `CONSTRAINT_VIOLATED` beside the real error. The pass now tests own keys.
287
-
288
- - **Quiet mode leaked spinner and progress output** — activity handles now resolve to no-ops under quiet verbosity, including interactive TTYs and explicit static fallbacks. Consumers can route informational rows through `out.info()` and rely on DreamCLI to suppress the complete presentation layer without reading private output policy state.
289
-
290
- - **`--json=true` and `--quiet=true` failed as unknown flags** (https://github.com/kjanat/dreamcli/issues/85). Both root flags now take a value the way `flag.boolean()` does. `true` and `1` enable, `false` and `0` disable, the last occurrence wins, and an invalid literal fails with the parser's `INVALID_VALUE` error and exit code 2 instead of `Unknown flag`. `--help`, `-h`, and `--version` still render ahead of that error, so a mistyped value never hides the text that documents the flag. Short `-q` keeps its presence-only form, matching short boolean flags at the command level. `runCommand()` from `/testkit` reads the same layer, and tokens after `--` still reach the command untouched.
291
-
292
- ## [3.0.1] - 2026-07-21
293
-
294
- No library code changed; this release ships agent-facing material that was being built but never published.
295
-
296
- ### Added
297
-
298
- - **The `cli-creation` skill now ships in the package** — `skills/` was absent from npm's `files` and JSR's `publish.include`, so consumers installing from either registry never received it.
299
- - **Documentation lookup paths in the `cli-creation` skill** — `deno doc` against JSR (works whether the consumer installed from npm or JSR, including subpaths, `--json`, and `--filter`), plus the site's `llms.txt`, `llms-full.txt`, and `/raw/` markdown endpoints, so API shapes are read from the published package rather than recalled.
300
-
301
- ## [3.0.0] - 2026-07-21
302
-
303
- The stable 3.0.0 release. It ships the code of 3.0.0-rc.20 plus the fix and documentation below; the complete v3 feature record lives in the rc.1 - rc.20 sections that follow. Upgrading from 2.x is covered by the new [upgrade guide](https://dreamcli.kjanat.dev/guide/upgrading-v3).
304
-
305
- ### Fixed
306
-
307
- - **`runCommand()` rejected `--quiet`/`-q`** — the testkit gained the root-flag layer for `--json` in rc.1, but `--quiet` (added in rc.17) was never taught to it, so copying a real `mycli --quiet …` invocation into a test failed with `Unknown flag` (exit 2). Both spellings are now detected before the `--` separator, set quiet verbosity, and are stripped before parsing; a literal post-separator `--quiet` still reaches the command.
308
- - **Mobile documentation hovers** — the twoslash bottom sheet collapsed to a 2px sliver (a transformed popper ancestor became the containing block for the fixed sheet), its backdrop stayed over the page after dismissal, and closing a popup disabled it permanently via an inline `display: none`.
309
-
310
- ### Added
311
-
312
- - **Upgrade guide** — `docs/guide/upgrading-v3.md` documents every 2.5.0 → 3.0.0 breaking and behavioral change with before/after code.
313
- - **Five new examples** covering the v3 surface: `flag-types.ts` (url, path with `create`, date, duration, bytes, count, keyValue, constraints, array separator/unique), `parser-control.ts` (negatable, duplicates, spelling parity), `standard-schema.ts` (Standard Schema v1 interop), `help-config.ts` (themes, `flagOrder`, routable default, JSON help), `output-extras.ts` (`out.color`, hyperlink gating, `setExitCode`).
314
-
315
- ### Changed
316
-
317
- - **Examples modernized** — `basic.ts` uses function-form `.example()`, `json-mode.ts` and `middleware.ts` use `out.status()` and document `--quiet`, `transport-launcher.ts` replaces its hand-rolled port check with declarative numeric constraints.
318
- - **`skills/cli-creation` rewritten for v3** — corrected stale grounding paths (`examples/standalone/`, `apps/docs/` no longer exist), rebuilt the pattern cookbook around the v3 surface with every snippet type-checked against the published types, and modernized the scaffolder templates (function-form examples, declarative numeric constraints instead of hand-clamping, `out.status()`, a `--quiet` test).
319
- - **README refreshed** — the flag-types block lists the full v3 family (dropping the `flag.custom` URL sample that `flag.url()` superseded), the output sample shows `out.status()` / `out.setExitCode()` / `--quiet`, the completions sample covers the eager-flag form and fixes a `completion`/`completions` typo.
320
-
321
- ## [3.0.0-rc.20] - 2026-07-21
322
-
323
- ### Changed
324
-
325
- - **ansispeck `^0.4.1`** — bumped from `^0.2.0` (npm dependency and JSR import map).
326
-
327
- ## [3.0.0-rc.19] - 2026-07-21
328
-
329
- ### Added
330
-
331
- - **Expanded config discovery** (#61) — the default search now covers three scopes, first match wins, no merging:
332
- 1. **Project**: the base directory (default `cwd`) and every ancestor up to the filesystem root, nearest first, each probed for `.{appName}.{ext}`, `{appName}.config.{ext}`, and the new `.config/{appName}.{ext}` convention.
333
- 2. **User**: XDG / AppData as before, plus `~/Library/Application Support/{appName}/config.{ext}` on macOS.
334
- 3. **System**: `/etc/{appName}/config.{ext}` on Linux and macOS.
335
- - **`baseDir` discovery option** — `discoverConfig()` accepts a base directory to anchor the project-scope walk somewhere other than `cwd`.
336
- - **`RuntimeAdapter.userConfigDirs` / `systemConfigDirs`** — optional ordered config roots supplied by the runtime adapters; discovery falls back to `[configDir]` / `[]` when a custom adapter omits them.
337
-
338
- ### Changed
339
-
340
- - **Breaking**: `buildConfigSearchPaths(appName, options)` replaces the positional `(appName, cwd, configDir, loaders?)` signature; options carry `baseDir`, `userConfigDirs`, `systemConfigDirs`, and `loaders`.
341
-
342
- ## [3.0.0-rc.18] - 2026-07-21
343
-
344
- ### Added
345
-
346
- - **`flag.path({ type: 'directory', create: true })`** — creates the directory (recursively) at resolution time when nothing exists at the path. Only available with `type: 'directory'`, enforced at the type level. Creation runs through a new `mkdir` seam: `RuntimeAdapter.mkdir`, overridable via run options, noop in the test adapter, so `src/core` stays process-free.
347
-
348
- ### Fixed
349
-
350
- - **`flag.path({ type, mustExist: false })` rejected missing paths** — the builder recorded the explicit `mustExist: false`, but resolution errored on any missing path whenever path checks were active, making an optional to-be-created path (e.g. an `--outdir` that the command itself creates) impossible to declare. A missing path now passes when `mustExist` is `false`; an existing path is still type-checked.
351
-
352
- ## [3.0.0-rc.17] - 2026-07-20
353
-
354
- ### Added
355
-
356
- - **`out.status()`** — a success/status line channel that writes to **stderr** (stdout stays clean for piping) and is suppressed under quiet verbosity. `info` remains stdout-bound; `warn`/`error` remain always-emitted.
357
- - **Global `--quiet`/`-q` flag** — sets quiet verbosity on every CLI, wired like `--json`: detected and stripped at the root before dispatch (command schemas never see it), honoring the `--` separator so a literal `-q` positional reaches the command unchanged. Listed under root help's `Global options:`.
358
-
359
- ### Fixed
360
-
361
- - **`.run()` misread a post-separator `--json`** — runtime preflight used a naive `includes('--json')`, so `mycli cmd -- --json` entered JSON mode via the adapter path even though `.execute()` correctly treats it as a positional. Preflight now uses the `--`-aware detection.
362
-
363
- ## [3.0.0-rc.16] - 2026-07-20
364
-
365
- ### Added
366
-
367
- - **`resolveRenderContext(argv, options?)`** — pre-`run()` probe returning the output decisions the framework will make for a given argv: `jsonMode` (`--`-aware `--json` detection), `isTTY`, the gated `color` palette, and `isHyperlinkSupported`. Computed with the same composition `.execute()`/ `.run()` feed into the output channel, so content styled before `run()` — banners, hand-rendered help — matches the channel that will actually render, with zero argv re-parsing.
368
- - **`includesBeforeSeparator` / `stripBeforeSeparator`** exported from the package root — the `--`-aware root-flag primitives, for consumers who only need correct flag detection.
369
-
370
- ## [3.0.0-rc.15] - 2026-07-20
371
-
372
- ### Added
373
-
374
- - **Configurable flag order in help** — `.help({ flagOrder })` controls the `Flags:` table order: `'alphabetical'` (default, short-aliased flags first then alphabetical) or `'declaration'` (the order `.flag()` was called). For full control, `.help({ sortFlags: (a, b) => number })` supplies a custom comparator over flag names that wins over `flagOrder`. Both are also accepted at runtime via `execute`/`run` `help` options.
375
-
376
- ## [3.0.0-rc.14] - 2026-07-20
377
-
378
- ### Added
379
-
380
- - **Function-form examples** — `.example()` now accepts a `(meta) => string` builder alongside the literal string. `meta` carries the invoked program `name` (`help.binName`, falling back to the command name) and `version`, resolved at render time, so examples reference the real program name instead of hardcoding it and stay truthful under symlinks, `inheritName`, and `npx x` vs a global install. The thunk resolves in both `--help` text (composing with example highlighting) and `--json`/definition-schema output.
381
- - **`ExampleMeta`** and **`ExampleCommand`** public types for annotating function-form example builders.
382
-
383
- ## [3.0.0-rc.13] - 2026-07-20
384
-
385
- ### Changed
386
-
387
- - **Syntax-highlighted example commands** — the `Examples:` help section now highlights each command per token: the leading binary via `usageBin` (bold) and flag tokens (`-x`, `--long`) via `flag` (cyan), with values left plain. Tokenizing is quote-aware so `--scope './a b'` stays one token, and the existing color gate is respected (identity formatters when `NO_COLOR` or non-TTY), so `stripAnsi(colored)` still equals the plain rendering.
388
-
389
- ## [3.0.0-rc.12] - 2026-07-20
390
-
391
- ### Added
392
-
393
- - **`out.isHyperlinkSupported`** — resolved OSC 8 hyperlink gate on the output channel. Honors `NO_HYPERLINKS`/`FORCE_HYPERLINKS` and the `--no-hyperlinks`/`--hyperlinks` flags, falling back to `isTTY`. Consumers rendering their own `out.color.link(...)` output can gate on it to keep OSC 8 escapes out of piped or opted-out contexts.
394
- - **Standard Schema v1 validation** — `flag.custom(schema)` and `arg.custom(schema)` accept any conforming validator (including callable, sync, and async schemas) with inferred output types and no runtime dependency. Validation runs after source resolution, so argv, env, config, prompt, stdin, and default values behave consistently; array flags and variadic args validate each element.
395
- - **`isMainModule(import.meta)`**: Compatibility helper for consumers whose ambient `ImportMeta` interface omits `main`. Projects with normal Node, Bun, or Deno runtime typings can keep using the conventional `if (import.meta.main)` guard directly.
396
-
397
- ### Changed
398
-
399
- - **`.manifest({ from: import.meta })` compatibility form**: Anchored manifest discovery now also accepts the calling module's complete `import.meta` object and extracts its URL internally. The conventional `{ from: import.meta.url }` form remains supported and preferred when runtime typings expose `url`. Together with `isMainModule(import.meta)`, the new forms avoid global `ImportMeta` augmentation, allowing consumers with an empty ambient `ImportMeta` interface to pass both TypeScript/Deno checks and JSR publish validation.
400
-
401
- ### Removed
402
-
403
- - **Internal schema DSL** — the private template-literal parser, validator, and JSON Schema converter were replaced by direct definition-schema objects, removing roughly 1,500 lines without changing the generated schema.
404
-
405
- ### Fixed
406
-
407
- - **`NO_HYPERLINKS` ignored in the help header** — root-help header hyperlinks gated on raw TTY status, so `NO_HYPERLINKS=1` (and `--no-hyperlinks`) still emitted OSC 8 links in the header. The gate now consults `out.isHyperlinkSupported`, which respects the standard hyperlink overrides.
408
-
409
- ## [3.0.0-rc.11] - 2026-07-15
410
-
411
- ### Fixed
412
-
413
- - **JSR publish** — the Deno import map pinned `ansispeck` below `0.2.0`, so the JSR build resolved an ansispeck whose `createColors` rejected `osc8`'s two-argument call and failed type checking. The map now tracks `^0.2.0` alongside the npm dependency. (rc.10 published to npm only.)
414
-
415
- ## [3.0.0-rc.10] - 2026-07-15
416
-
417
- ### Changed
418
-
419
- - **`osc8()` link text is optional** — it now defaults to the link target, so `osc8('https://x.dev')` renders as a hyperlink displaying its own URL. Terminals without OSC 8 support still show a usable address. Passing an explicit label is unchanged.
420
- - **`osc8()` now delegates to `ansispeck`'s hyperlink constructor** — it emits the **ST** (`ESC \`) terminator instead of **BEL** (`\x07`). Both are valid OSC 8 terminators supported by modern terminals; the rendered link is unchanged. This removes dreamcli's last hand-rolled escape-sequence code.
421
-
422
- ## [3.0.0-rc.9] - 2026-07-11
423
-
424
- ### Added
425
-
426
- - **JSON help** — `--help` with `--json` emits the CLI's definition document (the `generateSchema()` shape, `$schema`-tagged) on stdout instead of help text, for root help, `help <command>`, and `<command> --help` alike. New `generateCommandSchema(schema)` export produces the per-command document.
427
-
428
- ### Changed
429
-
430
- - **`generateSchema()` emits the default command's full definition** — the `defaultCommand` field was a name-only string reference while the default command's flags/args appeared nowhere in the document (it never lists in `commands`). It is now the complete serialized command.
431
-
432
- - **`flag.array()` rejects non-element builders at compile time** — the element position now requires a builder carrying only value-shape settings (kind, constraints, enum values, `parseFn`). Flag-level modifiers (`.alias()`, `.env()`, `.default()`, `.prompt()`, `.describe()`, …) were silently ignored on elements before; passing them is now a type error, as is `flag.path()` / `flag.count()` / `flag.keyValue()` / nested arrays. Type-level only — no runtime behavior change.
433
-
434
- ## [3.0.0-rc.8] - 2026-07-11
435
-
436
- ### Added
437
-
438
- - **Themed help output** — root and per-command help render with a semantic color theme (bold+underlined section titles, cyan literals, dimmed metadata, yellow deprecations) whenever color is enabled, using the same gate as `out.color` (TTY + color support, no `--json`, `NO_COLOR`/`FORCE_COLOR` honored). Piped and JSON output stays byte-clean. Customize via `.help({ theme: (c) => ({ sectionTitle: c.magenta }) })` — the factory receives the gated ansispeck palette and is never invoked when color is off, so custom themes cannot leak escapes. New public types: `HelpTheme`, `HelpThemeFactory`.
439
- - **Negatable booleans** — `flag.boolean().negatable()` accepts `--no-<name>` as `false`. Both spellings are one logical flag (last CLI occurrence wins, shared duplicate policy); the negated spelling is presence-only (`--no-foo=x` errors) and renders as `--[no-]foo` in help. Custom spelling via `{ alias }`, unadvertised via `{ hidden }`. Env/config/prompt/default resolution is unchanged.
440
- - **Duplicate policy** — `.duplicates('last' | 'first' | 'error')` on singleton flags controls repeated CLI occurrences. `'error'` throws `ParseError` code `DUPLICATE_FLAG` with `{ flag, count, values }` details; `'first'` keeps the first value while still consuming later value tokens. Counted per logical flag (aliases + negated + parity spellings); env/config precedence is never a duplicate.
441
- - **`packageRepositoryUrl(pkg, { require: true })`** — narrows the return type to `string`, throwing a `CLIError` (code `INVALID_REPOSITORY`) at the call site when the `repository` field is missing or not a recognisable locator. Removes the `!` assertion for manifests known to carry a valid repository, with the guarantee enforced at runtime rather than assumed.
442
- - **Flag spelling parity (kebab ↔ camel)** — `--doThis` matches a flag named `do-this` and vice versa, for names and long aliases, on by default. Handler keys, help, completions, and suggestions stay canonical. Automatically disabled per pair when both spellings are declared explicitly; globally via `cli('mycli', { flags: { caseParity: false } })` (new `cli(name, options)` overload) or `RunOptions.flags`.
443
-
444
- ### Fixed
445
-
446
- - `execute(argv, { flags })` overrides now reach the planner's dispatch arity scanning, not just command parsing.
447
- - Generated meta-schema descriptions render `@defaultValue` tags as a `Default: <value>` paragraph instead of silently dropping them.
448
-
449
- ## [3.0.0-rc.7] - 2026-07-10
450
-
451
- ### Added
452
-
453
- - **`.derive()` handlers may omit the return** — a validation-only derive with no `return` statement (sync or async) now typechecks; previously `void` / `Promise<void>` failed the `Output` constraint and forced an explicit `return undefined`.
454
- - **String constraints** — `flag.string({ nonEmpty, minLength, maxLength, pattern })` plus chained `.nonEmpty()` / `.minLength()` / `.maxLength()` / `.pattern()`, mirroring the numeric-constraint model. Checked in fixed order (nonEmpty → minLength → maxLength → pattern) at both the CLI parse boundary (`INVALID_VALUE`) and env/config/prompt resolution (`CONSTRAINT_VIOLATED`), and emitted into the exported JSON Schema as `minLength` / `maxLength` / `pattern`.
455
- - **`.separator()` and `.unique()` on array flags** — `.separator(',')` splits each CLI occurrence before element coercion, so `--region us,eu --region ap` works alongside repetition and errors name the offending element. Env/config string values use the same separator (default remains `','`). `.unique()` deduplicates the final resolved array (first-seen order) regardless of source.
456
- - **`flag.url()`** — parses into a `URL`, with optional `{ protocols: ['https'] }` allowlist. Help shows `<url>`.
457
- - **`flag.path()`** — path string with opt-in filesystem checks (`{ mustExist: true }`, `{ type: 'file' | 'directory' }`) validated after resolution through the runtime adapter, so CLI/env/config values are checked identically. `RuntimeAdapter` gained a `stat()` primitive (Node/Bun via `node:fs/promises`, Deno via `Deno.stat`; test adapters default to "nothing exists"), and `RunOptions` / `ResolveOptions` accept a `stat` injection for process-free execution — without one, checks are skipped.
458
- - **`flag.date()`** — strict ISO-8601 → `Date` with optional inclusive `min` / `max` bounds. Rejects lenient `Date.parse` inputs (`'0'`, `'March 5'`) and calendar-invalid dates (`2026-02-31`).
459
- - **`flag.duration()`** — `'30s'`, `'5m'`, `'1.5h'`, `'250ms'`, `'2d'`, compounds (`'1h30m'`), or bare milliseconds → milliseconds.
460
- - **`flag.bytes()`** — `'512mb'`, `'1.5gb'`, `'64kb'` or bare bytes → bytes (binary units, case-insensitive).
461
- - **`flag.count()`** — occurrence counter (`-vvv` → `3`, absent → `0`, explicit `--verbose=2` supported). Takes no value token, not promptable, and joins boolean flags in help (no `<value>` placeholder) and shell completions.
462
- - **`flag.keyValue()`** — repeated `KEY=VALUE` merges into `Record<string, string>` (split at the first `=`, later keys win, unset resolves to `{}`). Env accepts comma-separated pairs; config accepts a plain object. New `'empty-object'` optional fallback joins arrays' `[]` as the kinds that resolve to a value when unset.
463
-
464
- ## [3.0.0-rc.6] - 2026-07-09
465
-
466
- ### Added
467
-
468
- - **Runtime terminal sizing hooks** — `RuntimeAdapter` now exposes `getTerminalSize()` and `onTerminalResize()`. Node/Bun read `process.stdout.getWindowSize()` (falling back to `columns` / `rows`) and subscribe to stdout `resize`; Deno uses native `Deno.consoleSize()` and `SIGWINCH` on non-Windows platforms.
469
-
470
- ### Changed
471
-
472
- - **Help output now fits the live terminal in `.run()`** — root and command help use runtime terminal columns when no explicit `.help({ width })` or runtime `help.width` is provided. Non-TTY or unavailable sizes still fall back to 80, and `.execute()` remains deterministic for tests.
473
-
474
- ## [3.0.0-rc.5] - 2026-07-08
475
-
476
- ### Removed
477
-
478
- - **`createBunAdapter` export** (from `@kjanat/dreamcli/runtime`). Bun exposes a Node-compatible `process`, so the Bun adapter had been a pure passthrough to the Node adapter since the runtime version hard-fail was dropped — it blessed a runtime rather than abstracting distinct I/O. Auto-detection now maps Bun to the Node adapter directly and `src/runtime/bun.ts` is gone. Runtime detection is unchanged: `detectRuntime()` still reports `'bun'` and `RUNTIMES` still lists it. Callers that selected the Bun adapter explicitly should use `createNodeAdapter` (identical behavior) or rely on `createAdapter()` auto-detection (#51).
479
-
480
- ## [3.0.0-rc.4] - 2026-07-06
481
-
482
- ### Added
483
-
484
- - **`.default(cmd, { route: true })`** — expose a default command under its own name as a routable top-level command, in addition to the bare/flags-only root surface. `mycli` and `mycli <name>` then run the same command object, and it is listed in the root `Commands:` section (tagged `(default)`) beside its siblings. Lets CLIs keep both a short root shorthand and an explicit, documented named command without duplicating the builder (#55). Opt-in only — the surface-only default remains the default behavior. With `route: true` the name wins over positional interpretation, so a positional value equal to the command's own name must be passed after `--`.
485
-
486
- ## [3.0.0-rc.3] - 2026-07-06
487
-
488
- ### Added
489
-
490
- - **`@kjanat/dreamcli/version` subpath** — exposes the framework's own build identity as `DREAMCLI_VERSION` and `DREAMCLI_REVISION` (git short SHA) for diagnostics and bug reports. Deliberately a subpath rather than root exports so the constants stay out of root-import IDE completions; both report `'dev'` when running unbundled source.
491
-
492
- ## [3.0.0-rc.2] - 2026-07-06
493
-
494
- ### Added
495
-
496
- - **`out.color` — context-aware ANSI colors** — every handler's `out` now carries a color palette powered by [`ansispeck`](https://github.com/kjanat/ansispeck). Colors auto-enable only when stdout is a TTY, JSON mode is off, and the environment supports color (`NO_COLOR`, `FORCE_COLOR`, `--no-color`, `--color`, `CI` respected); otherwise every formatter is an identity function, so handlers can write `out.log(out.color.green('✔ done'))` unconditionally. `createOutput({ color })` forces the palette on/off (useful for asserting colored output in tests), and the `Colors` type is re-exported from the root entrypoint. First runtime dependency — kept external in `dist` (~1 kB gzipped install).
497
-
498
- ### Changed
499
-
500
- - **npm package now resolves built `dist` on every runtime** — the `bun`/`deno` → `src/*.ts` export conditions are gone and `src` is no longer published to npm (JSR still ships source). Bun and Deno consumers previously loaded raw source where build-time defines never ran, so `version` reported `'dev'`; they now get the same tested output as Node, with the real version. The export map is generated by tsdown at build time instead of hand-maintained.
501
-
502
- ## [3.0.0-rc.1] - 2026-07-02
503
-
504
- ### Added
505
-
506
- - **`.completions({ as: 'flag' })`**\
507
- Expose shell completion as an eager `--completions <shell>` flag on the CLI root instead of a `completions` subcommand. The planner intercepts the flag before dispatch, prints the script, and exits; root help advertises `--completions <bash|zsh|fish|powershell>` in its `Flags:` section. `.completions()` still defaults to `{ as: 'command' }`. Because the eager flag is intercepted before dispatch, the `--completions` name is reserved in flag mode — declaring a command/default flag of that name throws at build time.
508
- - **Shell auto-detection** — `--completions` with no value (flag form) resolves the target shell from the environment: `$SHELL` (parsed as an interpreter path) wins when it names a supported shell, otherwise the presence of `$PSModulePath` selects PowerShell — the reliable signal for `pwsh`, which never sets `$SHELL`.
509
- - **`detectShell(env)` / `normalizeShell(raw)`** — exported helpers behind the detection above; `normalizeShell` accepts bare names, `$SHELL` paths, and the `pwsh`/`powershell` pair.
510
- - **`.help(config)` builder + extended `HelpOptions`** — configure root-help rendering: `inlineDefault`, `showDefaultInCommands`, and `footer` (plus the existing `width` / `hyperlinks`). Builder config is merged under runtime `options.help` (runtime wins).
511
- - **Numeric constraints for number flags and args** — `flag.number()` and `arg.number()` now accept `{ min?, max?, int?, finite? }` (bounds inclusive), and the same constraints compose via chained `.int()` / `.min(n)` / `.max(n)` / `.finite(allow?)` methods (a later call overrides an earlier value, including one set in the options object). The chained methods are compile-time guarded to number-kind builders only. Constraints are enforced identically across the parse path and the env/config/prompt resolution path (order: finite → int → min → max): parse-time (CLI) violations throw `INVALID_VALUE`, while env/config/prompt coercion reports `CONSTRAINT_VIOLATED` (both exit code `2`). They are also surfaced in the exported JSON Schema as `minimum` / `maximum` and `type: "integer"` when `int` is set. `min` / `max` must be finite — a non-finite bound (`Infinity` / `-Infinity` / `NaN`) throws at construction. The resolved TypeScript value type stays `number`.
512
- - **Prompt-level defaults for `confirm` and `input` prompts** — `confirm` prompts accept `default?: boolean` (drives the `(Y/n)` vs `(y/N)` hint and the empty-line result, so a confirm can default to **No**), and `input` prompts accept `default?: string` (shown in the hint as `(default: <value>)` and used when the user presses Enter, skipping `validate`). Precedence among defaults is prompt-level `default` > flag `.default()`. Unset `confirm` default stays backward compatible (`true`).
513
-
514
- ### Changed
515
-
516
- - **BREAKING — the default command is now the root _surface_, not a named subcommand.** `.default(cmd)` registers the command only as the default; it is no longer added to `schema.commands`. Consequences:
517
- - It can no longer be invoked by its own name (`mycli mycmd` does not route to it; the token is treated as input to the default command).
518
- - It is omitted from the root `Commands:` list by default (re-enable with `.help({ showDefaultInCommands: true })`).
519
- - Root `--help` renders the default command's `Arguments:`/`Flags:` inline even when sibling commands exist (previously only when it was the sole command), and a sole default with no subcommands shows its own usage line directly instead of a `[command]` placeholder.
520
- - **`finite` defaults to `true` (behavior change)** — `flag.number()` / `arg.number()` now **reject `Infinity` and `-Infinity`**, which previously passed straight through to handlers (`Number("Infinity")` is not `NaN`). Pass `{ finite: false }` (or `.finite(false)`) to opt back into accepting non-finite values. `NaN` continues to be rejected as before.
521
- - **BREAKING — the runtime no longer hard-fails the host CLI on its version.** Adapter construction previously threw (a bare, uncaught `Error`) when the detected Node/Bun/Deno version was below DreamCLI's declared minimum, crashing the consumer's CLI — including on `--help`. That check is removed: as a dependency the consumer's package manager already enforces the `engines` range at install time (and more softly), and when DreamCLI is bundled/inlined the consumer — not us — owns their CLI's supported-runtime policy. `SUPPORTED_RUNTIMES` and the generated `engines` minimums are unchanged and remain the source of truth for docs and packaging.
522
-
523
- ### Fixed
524
-
525
- - **Empty `input`-prompt answer no longer clobbers a flag's `.default()`** — a flag declared with both `.default(...)` and an `input` prompt previously resolved to `""` when the user submitted an empty line, because empty input was treated as a real answer that short-circuited the default fallback. An empty or blank `input` answer with no prompt-level `default` is now treated as "no answer", so resolution falls through to the flag's `.default()` (or, for a required flag, the standard missing-flag error).
526
-
527
- ### Fixed
528
-
529
- - **Root `--help` now matches consistently with `--version`** (#29) — previously `--help` / `-h` were intercepted at the root only when they were the very first token, while `--version` / `-V` matched anywhere before `--`. A help flag preceded only by flags (e.g. `mycli --verbose --help`) now shows root help, mirroring `mycli --verbose --version`. A help flag that follows a subcommand token still scopes to that subcommand (`mycli deploy --help` → `deploy` help); `--version` remains a global, position-independent flag by design (there is no per-command version). The bare `help` token now triggers root help from the same position as `--help`, and the `--` end-of-options separator is respected for both.
530
- - **Generated `--help` now advertises the active built-in global flags** (#32) — root help renders a `Global options:` block listing `--help, -h` and `--json` (always), `--version, -V` (when a version is set), and `--config <path>` (when `.config()` enabled config discovery). Previously these framework-provided flags were invisible in help even though they worked. `--completions` is unchanged (still advertised via the inline surface when active).
531
- - **Root usage no longer prints the default command's name** — the merged/sole-default usage line rendered `Usage: <bin> <default-name> …`, teaching an invocation that does not route (`.default()` is not a named command, so the token is consumed as the default's first positional). It now renders under the bin name only (`Usage: <bin> [flags] <args>`).
532
- - **`inlineDefault: false` no longer hides a sole default command's interface** — when the default command is the only surface (no visible subcommands and no eager `--completions` flag), root help would collapse to a bare `Usage: <bin> [options]` with no discoverable args/flags. The default is now always rendered inline in that case, since suppressing it leaves no other path to its interface.
533
-
534
- ### Fixed
535
-
536
- - **`runCommand()` now honors a CLI-level `--json` passed in `argv`** — the testkit gained the same root-flag layer as the real CLI: a `--json` before the `--` separator enables JSON mode and is stripped before parsing, instead of failing with `Unknown flag --json` (exit 2). A literal `--json` after `--` still reaches the command unchanged. The existing `{ jsonMode: true }` option keeps working — either source enables JSON mode. Copying a real `mycli --json …` invocation into a test now works verbatim.
537
- - **`createTestPrompter()` now runs an `input` prompt's `validate`** — a queued string answer to an `input` prompt is validated exactly as the terminal prompter does; an answer that fails validation is rejected as a cancellation rather than injected verbatim as the resolved value, so prompt validation is integration-testable through `runCommand(cmd, argv, { answers })`. Non-string answers stay verbatim so downstream coercion paths remain testable.
538
-
539
- ## [2.5.0] - 2026-06-28
540
-
541
- ### Added
542
-
543
- - **`.manifest()` — runtime-agnostic manifest discovery** — discover CLI metadata from any manifest file, not just `package.json`. Pass `files` to choose candidate filenames in priority order (e.g. `['deno.json', 'jsr.json']`); discovery walks up from `cwd` (or `from`) and the nearest manifest directory wins. Files are parsed as JSON with a JSONC fallback, so `package.json`, `deno.json`, `jsr.json`, and `deno.jsonc` all work — including manifests with `//` / block comments or trailing commas (a dependency-free, string-aware strip that leaves `//` inside string values such as URLs untouched).
544
- - **`discoverManifest()`** — the generalized discovery helper behind `.manifest()`, accepting `{ startDir, files }`.
545
- - **Optional scope retention in name inference** — `inferName` now accepts `{ scope: 'keep' | 'strip' }` (and `inferCliName(pkg, { stripScope })`) so a scoped `name` like `@scope/mycli` can be kept verbatim instead of always stripping to `mycli`. Relevant for `deno.json` / `jsr.json`, which have no `bin` field.
546
- - **`.denoJson()`** — deprecated convenience preset for `.manifest({ files: ['deno.json', 'deno.jsonc', 'jsr.json'] })` (see Deprecated below).
547
-
548
- ### Changed
549
-
550
- - **Manifest discovery now requires recognized metadata to count as a hit** — a parseable but metadata-less manifest (`{}`, or one carrying only non-metadata fields such as `dependencies` / `scripts` / `type`, or a config-only `deno.json` with just `tasks` / `imports`) is no longer treated as a match. Discovery now walks up to parent directories and tries the remaining candidate files instead of halting. This also changes the deprecated `discoverPackageJson()` / `.packageJson()`: where a metadata-less `package.json` previously halted the walk-up and resolved to `{}`, the walk-up now continues, so an ancestor's version can surface (relevant in monorepos). Pass pre-loaded `data` or an explicit `from` / `startDir` to pin discovery to one directory.
551
-
552
- ### Deprecated
553
-
554
- - **`.packageJson()`, `.denoJson()`, and `discoverPackageJson()`** — superseded by `.manifest()` / `discoverManifest()`, whose defaults (`['package.json']`) match the old behavior. All still work, delegating to the generalized path.
555
-
556
- ## [2.4.1] - 2026-06-27
557
-
558
- ### Fixed
559
-
560
- - **Destructuring `out` and activity handles** — `Out` methods and the spinner/progress activity handle methods are now bound to their instance, so pulling them off via destructuring (e.g. `const { done } = handle`) no longer breaks `this`-dependent behaviour and cleanup (https://github.com/kjanat/dreamcli/pull/40).
561
-
562
- ## [2.4.0] - 2026-06-23
563
-
564
- ### Added
565
-
566
- - **`out.setExitCode(code)` for normal-output status exits** — command handlers can now request a process exit code without throwing or emitting error-shaped output, covering status/check CLIs that should print their normal report while still signalling degraded state to scripts (https://github.com/kjanat/dreamcli/issues/27).
567
-
568
- ### Fixed
569
-
570
- - **Unknown root commands under no-arg defaults now report `UNKNOWN_COMMAND`** — when a CLI has a `.default()` command with no positional args, an unknown root token no longer falls through to the default parser as an unexpected positional. Defaults that declare positional args still receive those root tokens as before (https://github.com/kjanat/dreamcli/issues/26).
571
-
572
- ### Security
573
-
574
- - **Hardened trailing-separator trimming against polynomial ReDoS** — the home/config path resolution, `package.json` repository-URL normalization, and runtime-binary `basename` helpers previously stripped trailing slashes with backtracking regexes (`/[\\/]+$/`, `/\/+$/`) that CodeQL flagged as polynomial regular expressions (`js/polynomial-redos`). They now route through a shared linear-time `stripTrailing` scan, so adversarial slash-heavy input can no longer trigger quadratic matching. No behavior change for valid inputs.
575
-
576
- ## [2.3.0] - 2026-06-20
577
-
578
- ### Fixed
579
-
580
- - **Command dispatch now respects flag value-arity** — a space-separated value-flag value (e.g. `--source anthropic`) is no longer mistaken for a command name when it collides with a registered command, so the default-command fallback runs as intended (https://github.com/kjanat/dreamcli/issues/25). The command-name scan now skips the token a space-separated value-flag consumes (mirroring the parser's own value-consumption rules); the inline `--source=anthropic` form already worked, and both forms are now consistent.
581
- - **Root `--version`/`--json` interception now respects the `--` end-of-options separator** (https://github.com/kjanat/dreamcli/issues/28). A `--version` or `--json` token after `--` is treated as a literal positional instead of triggering version output or JSON mode.
582
-
583
- ## [2.2.1] - 2026-06-10
584
-
585
- ### Added
586
-
587
- - **`.links()` — OSC 8 hyperlinks in the root-help header** — the program name and version on the first line of root `--help` output can now carry [OSC 8 hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) in supporting terminals (https://github.com/kjanat/dreamcli/issues/20). Pass explicit URLs (`.links({ name, version })`) or call `.links()` with no arguments to derive them from `package.json` metadata when `.packageJson()` is active: the name links to the normalized `repository` URL (falling back to `homepage`), and the version links to the forge release tag (`{repo}/releases/tag/v{version}` on GitHub, `{repo}/-/releases/v{version}` on GitLab). Escapes are emitted only when stdout is a TTY (overridable via the new `help.hyperlinks` option) and only on the header line — usage lines, the `--help` hint, the commands table, `--version` output, and completion scripts stay plain.
588
- - **ANSI/OSC-aware help width helpers** — help padding and wrapping now measure _visible_ width: the shared `padEnd()`/`wrapText()` helpers strip ANSI CSI (colors) and OSC (hyperlink) escape sequences before counting columns, so escape-bearing text no longer mangles `--help` alignment. New public exports `osc8(url, text)` (wrap text in an OSC 8 hyperlink) and `visibleWidth(text)` (escape-aware width measurement) support custom help rendering.
589
- - **`packageRepositoryUrl(pkg)`** — new public helper that normalizes a package's `repository` field to a browsable `https://` URL, handling the locator formats npm accepts (`{ type, url }` object form, `git+`/`.git` affixes, scp-style `git@host:u/r.git`, and the `github:`/`gitlab:`/`bitbucket:`/bare `u/r` shorthands). `PackageJsonData` now also parses the `homepage` and `repository` fields.
590
-
591
- ## [2.2.0] - 2026-06-09
592
-
593
- ### Added
594
-
595
- - **`.packageJson(data)` — pre-loaded metadata** — `CLIBuilder.packageJson()` now accepts an already-imported `package.json` object (e.g. `import pkg from './package.json' with { type: 'json' }`), skipping filesystem discovery entirely. The data is detected via field shape (`name`/`version`/ `description`/`bin`), and its `version`/`description` are merged into the CLI schema at builder time so the data form works in **both** `.run()` and `.execute()` (the filesystem-free path that previously couldn't consume `.packageJson()` at all). Explicit `.version()`/`.description()` still win; an empty `{}` or a settings-shaped object falls through to the settings overload, so this is a non-breaking addition.
596
- - **`.packageJson({ from })` — anchored discovery** — discovery can now be anchored to an explicit location instead of the runtime cwd. Pass `{ from: import.meta.url }` (also accepts path strings, `file:` URL strings, or `URL` instances) so installable CLIs (`npm i -g`, `bunx`, `npx`) report their OWN version from any working directory. `discoverPackageJson(adapter, startDir?)` gained a matching optional anchor parameter.
597
-
598
- ## [2.1.0] - 2026-04-16
599
-
600
- ### Added
601
-
602
- - **Prompt — flag kind compatibility validation** — `FlagBuilder.prompt()` now rejects incompatible prompt/flag combinations at compile time via `AllowedPromptConfig<C>` (e.g., `flag.enum([…]).prompt({ kind: 'multiselect' })` is a TypeScript error). A runtime validation gate in `resolvePromptValueWithConfig()` catches mismatches before the prompter is invoked, throwing a `CONSTRAINT_VIOLATED` `ValidationError` with an actionable `suggest` message.
603
- - **`flagKind` phantom discriminator** — `FlagConfig` now carries a `flagKind` field (phantom — never read at runtime) so the type system can distinguish all six flag kinds. `AllowedPromptConfig` uses an indexed-access map (`PromptConfigByFlagKind`) for union-safe resolution.
604
- - **PowerShell completion playground** — added a Windows-friendly `pwsh-demo` workspace with a `.cmd` launcher, native `Register-ArgumentCompleter` registration, README install steps, and an end-to-end smoke test so PowerShell completions can be exercised outside unit tests.
605
-
606
- ### Changed
607
-
608
- - **Meta-descriptions build** — `scripts/build-meta-descriptions.ts` pipes generated source through `dprint fmt --stdin ts` instead of writing/reading a temp file and formatting in-place.
609
- - **PowerShell install guidance** — current-session docs and generated script headers now use `Out-String | Invoke-Expression`, matching the PowerShell flow that reliably evaluates multiline completion output.
610
- - **Bun support floor** — relaxed the documented and enforced Bun minimum from `>= 1.3.11` to `>= 1.3` across package metadata, runtime support checks, examples, and docs.
611
-
612
- ### Fixed
613
-
614
- - **PowerShell completions** — enum values now complete while the active token is still in progress, stop suggesting flags after `--`, and quote accepted values when spaces or quotes would otherwise produce invalid PowerShell input.
615
- - **PowerShell playground launcher** — fixed the Windows `pwsh-demo.cmd` shim so the example runs reliably from PowerShell and Command Prompt.
616
- - **Package metadata** — moved `vite` from `optionalDependencies` to `devDependencies` so consumer installs do not see it as a runtime dependency.
617
- - **Docs deploy** — remove dead Workers runtime vars (`BUN_VERSION`, `NODE_OPTIONS`) that had no effect on the static assets Worker, and add `html_handling: "drop-trailing-slash"` so clean URLs resolve correctly instead of 404ing on trailing slashes.
618
-
619
- ## [2.0.1] - 2026-04-07
620
-
621
- ### Fixed
622
-
623
- - **Schema URL resolution** — `$schema` in emitted definition documents now points at `dreamcli.schema.json` instead of the `/schema` subpath export, which doesn't resolve on the jsdelivr CDN.
624
- - **GitHub Pages deploy** — use `env` import from `node:process` for env access and set VitePress `base` to `/dreamcli/` so assets and links resolve correctly on GitHub Pages.\
625
- This allows for the old github pages deploy to work as an alternative to the cf workers.
626
- - **Publish pipeline** — split build and publish into separate jobs, run build before pack with `--ignore-scripts` to prevent prepack output from breaking `GITHUB_OUTPUT` parsing, hardcode the npm CDN schema URL instead of the unreliable jsr.io esm.sh path, replace `actions/setup-node` with bun's native registry auth, and switch internal imports to `#dreamcli/*` subpath imports.
627
- - **Package exports map** — moved conditional exports from `publishConfig` into top-level `exports` so local resolution matches what consumers see after install.
628
-
629
- ## [2.0.0] - 2026-04-07
630
-
631
- ### Added
632
-
633
- - **String-literal schema DSL** — added a single-source schema surface that parses definitions at compile time and runtime, then reuses the same model for JSON Schema generation.
634
- - **Published definition schema export** — added `@kjanat/dreamcli/schema` so tooling and docs consumers can import the generated definition schema locally instead of relying on the CDN URL.
635
- - **Fish and PowerShell shell completions** — expanded completion support beyond Bash and Zsh.
636
- - **Source-backed docs surfaces** — added generated API inventory pages, per-entrypoint symbol routes, source-backed example pages with related symbol links, and reference guides for planner, resolver, output, schema, support, migration, troubleshooting, and semantic deltas.
637
- - **`gh-project` workflow helper** — added a DreamCLI-powered project tool for syncing the re-foundation task board and PRD state.
638
-
639
- ### Changed
640
-
641
- - **Package identity and build pipeline** — the package is now published as `@kjanat/dreamcli`, ships ESM-only, emits the definition schema during the tsdown prepare hook, tightens published exports for runtime-specific consumers, and hardens npm, JSR, and docs release checks.
642
- - **Docs app architecture** — VitePress now builds reference and example pages from data loaders instead of static generated files, adds runtime/twoslash settings UI, improves mobile twoslash UX, and copies root artifacts into deployed docs output.
643
- - **Examples and walkthroughs** — the `gh` example grew into a multi-file workspace canary, and the example set now doubles as richer docs source with broader JSDoc coverage and better walkthrough material.
644
-
645
- ### Fixed
646
-
647
- - **Completion and alias handling** — hidden compatibility aliases now parse correctly, Bash and Zsh completion behavior is safer and more consistent, and shell completion edge cases were tightened.
648
- - **Aggregate validation diagnostics** — mixed flag and arg validation failures now surface clearer per-issue labels plus value-source labels such as `env ...` and `stdin`.
649
- - **Schema and docs integration** — schema URLs, generated meta descriptions, twoslash rendering, and source-backed docs pages now build reliably across local, CI, and Cloudflare deploys.
650
- - **CLI and runtime edge cases** — unresolved schema references now fail closed, runtime/support checks were hardened, and several dispatch/output/runtime regressions were corrected.
651
-
652
- ## [1.0.0] - 2026-04-02
653
-
654
- ### Added
655
-
656
- #### Release Automation
657
-
658
- - **GitHub Actions npm publish workflow** (`.github/workflows/publish-npm.yml`) — publishes the package to npm on GitHub release with provenance enabled, bringing npm release automation in line with the existing JSR publish flow.
659
-
660
- #### Canonical Semantics Guide
661
-
662
- - **`docs/guide/semantics.md`** — centralized reference for parser and resolver behavior, including repeated flags, short-flag stacking, `--` separator rules, `--no-*` alias behavior, value-source precedence, non-interactive prompt skipping, propagated-flag masking, and default-command root help/completion semantics.
663
-
664
- #### Plugin Lifecycle Hooks
665
-
666
- - **`plugin(hooks, name?)`** and **`.plugin(definition)`** expose a typed extension surface around command execution.
667
- - **Lifecycle phases** — `beforeParse`, `afterResolve`, `beforeAction`, and `afterAction` let plugins observe or instrument execution without reaching into CLI internals.
668
-
669
- #### `derive()` Command Context
670
-
671
- - **`command(...).derive(handler)`** adds typed command-scoped pre-action context derived from fully resolved flags and args.
672
- - **Derived context merges into `ctx`** so commands can validate once and consume typed values in the action handler.
673
-
674
- #### Schema Export and Validation
675
-
676
- - **`generateInputSchema()`** exports JSON Schema from CLI definitions for machine validation and tooling.
677
- - **Schema export docs and reference coverage** now document export formats, discriminator behavior, and default/hidden command handling.
678
-
679
- #### Runtime Surface and Execution Options
680
-
681
- - **Runtime support matrix and version guards** added around adapter creation.
682
- - **`run()` accepts `jsonMode`** in options, letting callers force structured output without shell-level flags.
683
- - **`out.table()` format and stream overrides** expose finer control over tabular output.
684
-
685
- ### Changed
686
-
687
- - **Docs navigation and entrypoints** — guide pages now link to the canonical semantics guide, the API reference landing page includes quick import guidance and key factories per subpath export, and the VitePress sidebar surfaces the semantics page under the Advanced guide section.
688
- - **Public API surface tightened** — runtime exports were pruned and guarded, explicit `require` conditions were added to package exports, and self-referencing package imports were hardened.
689
- - **Docs and examples expanded** — JSDoc/reference coverage grew across exported symbols, schema export/testing/runtime docs were added, and the `gh` walkthrough became a multi-file example package.
690
- - **CI and packaging hardened** — version-sync checks, supported Node pinning, preview publish verification, and Bun-pack package validation were added around the release surface.
691
-
692
- ### Fixed
693
-
694
- - **Default-command UX** — single-command root help is merged correctly, root completions surface default-command flags, unknown root flags are rejected cleanly, and schema discriminator handling matches the actual default-command surface.
695
- - **Stdin and runtime behavior** — stdin reads defer until dispatch needs them, empty pipes are distinguished from no pipe, and test adapters now match real runtime behavior more closely.
696
- - **Parser/help/completion/output edge cases** — optional array flags resolve to `[]`, variadic help formatting is corrected, bash/zsh completion edge cases are hardened, non-finite JSON values are rejected, and table options are preserved correctly.
697
-
698
- ## [0.9.2] - 2026-03-30
699
-
700
- ### Added
701
-
702
- #### Stdin-Backed Positional Arguments
703
-
704
- - **`ArgBuilder.stdin()`** lets positional args consume piped stdin when no CLI token is provided.
705
- - **`RuntimeAdapter.readStdin()`** adds full stdin reads to the runtime contract across Node, Bun, and Deno adapters.
706
- - **`RunOptions.stdinData` and testkit plumbing** let in-process tests feed stdin-backed commands without touching real process state.
707
- - **Comprehensive stdin coverage** added across schema, resolver, runtime, and testkit tests.
708
-
709
- ### Changed
710
-
711
- - Positional-arg resolution for stdin-enabled args expanded from **CLI → env → default** to **CLI → stdin → env → default**.
712
- - Scripts now separate **`lint`** from **`format`**, so linting no longer doubles as a rewrite step.
713
-
714
- ## [0.9.1] - 2026-03-30
715
-
716
- ### Added
717
-
718
- #### Default Command Support
719
-
720
- - **`CLIBuilder.default(command)`** lets a CLI run a fallback command when no subcommand is specified.
721
- - **Root args and flags flow through the default command** while explicit subcommands still take precedence.
722
-
723
- #### Package.json Auto-Discovery
724
-
725
- - **`CLIBuilder.packageJson(settings?)`** — opt-in builder method that enables automatic `package.json` discovery at `.run()` time. Walks up from `cwd` to find the nearest `package.json` and merges `version` and `description` into the CLI schema. Explicit `.version()` and `.description()` calls always take precedence over discovered values.
726
- - **`PackageJsonSettings.inferName`** — when `true`, infers the CLI binary name from the `bin` key (first key of the object) or the package `name` field (scope stripped). Defaults to `false`.
727
- - **`discoverPackageJson(adapter)`** — pure function that walks up from `adapter.cwd` to find and parse the nearest `package.json`. Returns `PackageJsonData | null`. All I/O flows through the adapter — fully testable with virtual filesystems.
728
- - **`inferCliName(pkg)`** — resolves CLI name from `PackageJsonData` with priority: bin key → scoped name (stripped) → `undefined`.
729
- - **Silent error handling** — malformed JSON, non-object roots, and missing `package.json` all return `null` (not errors). Deno permission denials degrade gracefully via the adapter's existing `readFile` contract.
730
- - **Completions skip** — package.json discovery is skipped for the `completions` subcommand, matching the existing config discovery skip pattern.
731
- - **43 new tests** — `package-json.test.ts` (24 unit tests: walk-up resolution, field extraction, error resilience, Windows path termination) and `cli-package-json.test.ts` (19 integration tests: version/description fill, name inference, precedence, walk-up, completions skip, combined with config, error resilience).
732
-
733
- #### `help` Virtual Subcommand
734
-
735
- - **`BINARY help <command>`** produces the same output as `BINARY <command> --help`. Rewrites argv via recursive `execute()` — no dispatch duplication.
736
- - **Nested support** — `help db migrate` works like `db migrate --help`.
737
- - **Bare `help`** shows root help.
738
- - **Defers to real commands** — if the user registers a command named `help` (or aliased as `help`), it takes priority over the virtual subcommand.
739
- - **`--json` propagation** — `help --json <command>` correctly preserves json mode (help text routes to stderr, stdout reserved for data).
740
- - **10 new tests** across `cli.test.ts` (7), `cli-nesting.test.ts` (2), `cli-json.test.ts` (1).
741
-
742
- #### Arg Environment Variable Resolution
743
-
744
- - **`ArgBuilder.env(varName)`** binds a positional argument to an environment variable. When the CLI value is absent, the resolver reads the env var and coerces the string to the arg's declared kind (passthrough for strings, `Number()` with NaN guard for numbers, `parseFn` invocation for custom args). Resolution order: **CLI → env → default**.
745
- - **`ArgSchema.envVar`** field (`string | undefined`) stores the env var name on the runtime schema descriptor.
746
- - **Env coercion for args** via `coerceArgEnvValue()` in the resolver. Handles `string` (passthrough), `number` (parse + NaN guard), and `custom` (delegates to `parseFn`, wraps thrown errors).
747
- - **`[env: VAR]` annotation** in help output for args with env bindings, matching the existing flag annotation style.
748
- - **Actionable required-arg error hints** — `buildRequiredArgSuggest()` generates suggestions including the env var when configured (e.g. "Provide a value for \<target\> or set DEPLOY_TARGET").
749
- - **16 new tests** — `resolve-arg-env.test.ts` (15 tests covering string/number/custom coercion, CLI > env > default precedence, deprecation warnings, error cases) and 1 help output test for the `[env: VAR]` annotation.
750
-
751
- #### Command Metadata
752
-
753
- - **`CommandMeta`** added to action handlers and middleware, carrying the CLI name, invoked binary, version, and resolved leaf command name.
754
-
755
- #### Documentation Site, README, and Examples
756
-
757
- - **README** added with project pitch, usage, install guidance, and comparison table.
758
- - **Examples directory** added with seven implementation examples.
759
- - **VitePress documentation site** added with concepts, guide, and reference sections.
760
- - **GitHub Pages deploy workflow and sitemap** added for hosted docs.
761
- - **Walkthrough guide** added for a GitHub CLI-style example application.
762
-
763
- ### Changed
764
-
765
- - Completion generation was reorganized into shell-specific generators and the package/tooling surface was refreshed for the `0.9.1` milestone.
766
- - Comprehensive public-facing JSDoc examples were added to the builder APIs.
767
-
768
- ### Fixed
769
-
770
- - Default commands no longer swallow nested unknown-command errors.
771
-
772
- ## [0.9.0] - 2026-02-11
773
-
774
- ### Added
775
-
776
- #### Deno Adapter
777
-
778
- - **`createDenoAdapter(ns?)`** — full `RuntimeAdapter` implementation for Deno. Reads argv from `Deno.args` (prepends synthetic `['deno', 'run']` for parity), env from `Deno.env.toObject()`, cwd from `Deno.cwd()`, stdout/stderr via `TextEncoder` → `Deno.stdout.write`/`Deno.stderr.write`, stdin via `Deno.stdin.readable` stream with line-buffered reader, TTY detection via `isTerminal()`, `readFile` via `Deno.readTextFile`, and homedir/configDir from env vars.
779
- - **Permission-safe** — `PermissionDenied` errors gracefully degrade: env falls back to `{}`, cwd to `/`, readFile to `null`. Non-permission errors propagate.
780
- - **`deno-builtins.d.ts`** — ambient type declarations for `TextEncoder`, `TextDecoder`, and `ReadableStream` (needed because `lib: ["ES2022"]` excludes web platform APIs).
781
- - **`createAdapter()` auto-detection** now handles Deno runtime via `globalThis.Deno` feature probing.
782
- - Re-exported `createDenoAdapter` and `DenoNamespace` from `@kjanat/dreamcli/runtime` subpath.
783
-
784
- #### Cross-Runtime CI
785
-
786
- - **GitHub Actions CI workflow** (`.github/workflows/ci.yml`) — lint+typecheck (Bun), test matrix (Node LTS + Bun stable), Deno smoke test, build with publint+attw.
787
- - **Deno smoke test** (`scripts/deno-smoke-test.ts`) — runs on real Deno runtime after build, exercising `createDenoAdapter()` against actual Deno APIs.
788
-
789
- #### JSR Publishing
790
-
791
- - **`deno.json`** with JSR package config (`@kjanat/dreamcli`), three subpath exports, publish include/exclude rules.
792
- - **GitHub Actions publish workflow** (`.github/workflows/publish-jsr.yml`) — publishes to JSR on GitHub release with OIDC provenance.
793
-
794
- ### Changed
795
-
796
- - **`.ts` import extensions** — all import specifiers switched from `.js` to `.ts` via `allowImportingTsExtensions`. tsconfig updated: `noEmit: true` + `allowImportingTsExtensions: true` replace `declaration`/`declarationMap`/`sourceMap`/`outDir` (all handled by tsdown). Removes the need for Deno's `unstable: ["sloppy-imports"]`.
797
- - `detectRuntime()` updated with Deno detection via `globalThis.Deno?.version?.deno`.
798
- - `createAdapter()` switch now covers `'deno'` case alongside `'node'` and `'bun'`.
799
- - Completion generator: `typeof` check on `globalThis` narrowed to avoid Deno type errors.
800
- - `runtime/deno.ts` expanded from empty stub (~5 lines) to full implementation (~318 lines).
801
- - Test count: 1695 tests across 47 test files (up from 1658 in v0.8.0).
802
-
803
- ## [0.8.0] - 2026-02-11
804
-
805
- ### Breaking
806
-
807
- - **Subpath exports** — single `"."` entry split into `"."`, `"./testkit"`, `"./runtime"`. Test utilities (`runCommand`, `createCaptureOutput`, `createTestPrompter`, `createTestAdapter`, `PROMPT_CANCEL`) moved to `@kjanat/dreamcli/testkit`. Runtime adapters (`createAdapter`, `createNodeAdapter`, `createBunAdapter`, `detectRuntime`, `ExitError`, `RUNTIMES`, `RuntimeAdapter`) moved to `@kjanat/dreamcli/runtime`. `createTestAdapter`/`TestAdapterOptions` exported only from `@kjanat/dreamcli/testkit`.
808
-
809
- ### Added
810
-
811
- #### Spinner & Progress Bar
812
-
813
- - **`out.spinner(text, options?)`** creates a spinner handle for indeterminate progress feedback. Returns a `SpinnerHandle` with `update(text)`, `succeed(text?)`, `fail(text?)`, `stop()`, and `wrap(promise, options?)` for auto-succeed/fail on promise settlement.
814
- - **`out.progress(options)`** creates a progress bar handle. Pass `total` for determinate mode (percentage bar); omit for indeterminate (pulsing animation). Returns a `ProgressHandle` with `increment(n?)`, `update(value)`, `done(text?)`, and `fail(text?)`.
815
- - **Four rendering modes** with automatic dispatch:
816
- - **TTY** — animated braille spinner (80ms frames) and bar rendering with ANSI cursor control. Hides cursor during animation, restores on terminal methods.
817
- - **Static** (`fallback: 'static'`) — plain text at lifecycle boundaries (start, succeed, fail). No ANSI codes. For CI and piped output.
818
- - **Noop** (`fallback: 'silent'`, default) — all methods are no-ops. Silent in non-TTY.
819
- - **JSON mode** — always noop (structured output only).
820
- - **Active handle tracking** — at most one spinner or progress may be active at a time. Creating a new one implicitly stops the previous to avoid garbled terminal output.
821
- - **`ActivityEvent` discriminated union** — 10-variant DU capturing spinner and progress lifecycle events (`spinner:start`, `spinner:update`, `spinner:succeed`, `spinner:fail`, `spinner:stop`, `progress:start`, `progress:increment`, `progress:update`, `progress:done`, `progress:fail`).
822
- - **Testkit capture handles** — `CaptureOutputChannel` subclass overrides `spinner()` and `progress()` to record `ActivityEvent[]` for assertion. `CapturedOutput.activity` array added.
823
- - **New public types** exported from barrel: `ActivityEvent`, `Fallback`, `SpinnerHandle`, `SpinnerOptions`, `ProgressHandle`, `ProgressOptions`.
824
- - **`out.stopActive()`** public method on `Out` to clean up active spinner/progress timers. Prevents process hangs when a handler throws before reaching a terminal method (`stop`, `succeed`, `fail`, `done`). `runCommand()` calls it automatically in a `finally` block; direct `createOutput()` users call it themselves.
825
- - **`progress:increment` activity event** — 10th `ActivityEvent` variant `{ type: 'progress:increment', delta }`. `increment()` now emits this instead of reusing `progress:update`, making capture events unambiguous for testing.
826
-
827
- ### Changed
828
-
829
- - `Out` interface extended with `spinner()` and `progress()` methods.
830
- - `CapturedOutput` extended with `activity: ActivityEvent[]` field.
831
- - `createCaptureOutput` now returns a `CaptureOutputChannel` that records activity events separately from stdout/stderr.
832
- - `FlagParseFn<T>` widened from `(raw: string) => T` to `(raw: unknown) => T`. Config files carry structured JSON data — `parseFn` now receives the raw value directly and is responsible for narrowing. CLI/env still pass strings; config passes the JSON value as-is.
833
- - `Out` interface extended with `stopActive()` method for explicit timer cleanup.
834
- - `ActivityEvent` union widened from 9 to 10 variants (added `progress:increment`).
835
- - `OutputChannel` refactored: activity handle implementations extracted to `activity.ts` (~581 lines), `WriteFn` type and `writeLine` helper extracted to `writer.ts` (~30 lines). `index.ts` reduced from 1156 to 589 lines. No public API changes.
836
- - All activity handle output (static and TTY) now routes to stderr. Previously static mode used a `StaticWriters` pair routing some output to stdout; the dual-writer abstraction is removed.
837
- - `runCommand()` calls `out.stopActive()` in a `finally` block, ensuring timer cleanup on handler exceptions.
838
- - **Resolve coercion unified** — three near-identical functions (`coerceEnvValue` ~105 lines, `coerceConfigValue` ~120 lines, `coercePromptValue` ~120 lines) replaced by single `coerceValue()` using `CoerceSource` discriminated union (`'env' | 'config' | 'prompt'`). Error messages parameterized via `sourceLabel()`/`sourceDetails()`/`coercionError()` helpers. `resolve/index.ts` reduced from ~1115 to ~940 lines.
839
- - **Activity types extracted** — 7 activity/output types (`Fallback`, `SpinnerOptions`, `SpinnerHandle`, `ProgressOptions`, `ProgressHandle`, `ActivityEvent`, `TableColumn`) moved from `schema/command.ts` to `schema/activity.ts` (~150 lines). `command.ts` reduced from 898 to 784 lines.
840
- - **Root help extracted** — `formatRootHelp()` + `padEnd()` + `wrapText()` moved from `cli/index.ts` to `cli/root-help.ts` (~133 lines). Uses structural `CLISchemaLike` interface to avoid circular imports. `cli/index.ts` reduced from 901 to 793 lines.
841
- - **`infer/` stub deleted** — removed empty `src/core/infer/index.ts`.
842
- - **Source files in published package** — `"src"` added to `files` array in package.json.
843
- - **Package manager migrated** — pnpm → bun. `packageManager` set to `bun@1.3.9`.
844
- - **Build config** — `tsdown.config.ts` changed to multi-entry build with `minify: true`.
845
- - Test count: 1658 tests across 46 test files (up from 1518 in v0.7.0).
846
-
847
- ### Fixed
848
-
849
- - `--config=<path>` equals form now correctly parsed and stripped from argv before dispatch.
850
- - Zsh completion: multi-alias flags use all short aliases in the exclusion group, not just the first.
851
- - Bash completion: `escapeForSingleQuote()` sanitizes `compgen -W` words to prevent shell injection.
852
- - Win32 `resolveConfigDir`: strip trailing separator from homedir to avoid doubled backslashes on drive roots (e.g. `C:\`).
853
- - Win32 `resolveConfigDir`: treat empty `APPDATA` as unset, falling back to homedir-based path.
854
- - Win32 `homedir`: add `HOMEDRIVE`+`HOMEPATH` fallback; never use `HOMEPATH` alone.
855
- - Levenshtein distance: replace 2D array with `Uint16Array` rolling buffer, drop defensive `undefined` guards.
856
- - Completions command detection via schema lookup instead of raw `argv[0]` string match.
857
- - Child flag with `propagate: false` correctly masks ancestor's propagated flag of the same name.
858
- - Dispatch: exhaustiveness guard on `subResult` switch in nested command resolution.
859
- - Nested group help: `binName` built from full command path, not just root.
860
- - Config loader: lowercase extensions in `buildExtensionList`/`buildLoaderMap` for case-insensitive matching.
861
- - Empty-string env var fallbacks in runtime adapter treated as unset.
862
- - `ProgressHandle.increment()` was emitting `progress:update` events indistinguishable from `update()` calls. Now emits `progress:increment` with `delta` field.
863
- - **Prompt number coercion** — `coercePromptValue` was missing NaN guard for number flags; now handled by unified `coerceValue()`.
864
-
865
- ## [0.7.0] - 2026-02-10
866
-
867
- ### Added
868
-
869
- #### Subcommand Nesting
870
-
871
- - **`CommandBuilder.command(sub)`** registers nested subcommands, building recursive command trees of unlimited depth. Parent commands store children as type-erased `ErasedCommand` entries — the parent doesn't need the child's generic types.
872
- - **`group(name)`** factory as a semantic alias for `command()`. Communicates intent: groups organise subcommands, leaf commands have actions. A group may also have its own `.action()` (e.g. `git remote` lists remotes, `git remote add` dispatches to a child).
873
- - **`flag.propagate()`** modifier marks a flag for automatic inheritance by all descendant commands. Propagated flags are collected from the ancestor chain at dispatch time. Child commands override a propagated flag by redeclaring the same name — child definition wins completely.
874
- - **Recursive dispatch** in `CLIBuilder.execute()`. Walks argv segments matching command names at each tree level. Handles hybrid commands (action + subcommands): subcommand match takes priority, else falls through to the parent handler. Groups without handlers show help.
875
- - **Nested help** — `formatHelp()` renders a "Commands:" section listing available subcommands for group commands. Usage line adapts to show `<command>` placeholder when subcommands exist.
876
- - **Nested completions** — bash and zsh generators traverse the full command tree depth. Propagated flags included at each nesting level. Bash uses path-keyed case statements; zsh generates per-group helper functions.
877
- - **Scoped "did you mean?"** — typo suggestions search within the current command scope, not the global command list. Help hint shows scoped path (e.g. `Run 'myapp db --help'`).
878
-
879
- ### Changed
880
-
881
- - `CommandSchema` extended with `commands: readonly CommandSchema[]` for nested subcommand schemas.
882
- - `ErasedCommand` extended with `subcommands: ReadonlyMap<string, ErasedCommand>` for dispatch.
883
- - `ErasedCommand` interface moved from `cli/index.ts` to `schema/command.ts` (shared location).
884
- - `FlagSchema` extended with `propagate: boolean` (default `false`).
885
- - `RunOptions` extended with `mergedSchema` internal field for propagated flag injection.
886
- - Dispatch logic extracted to `cli/dispatch.ts` (~285 lines) and flag propagation to `cli/propagate.ts` (~87 lines), reducing `cli/index.ts` by ~220 lines.
887
- - Test count: 1518 tests across 43 test files (up from 1300 in v0.6.0).
888
-
889
- ### Fixed
890
-
891
- - Completion generator no longer recurses into hidden command subtrees.
892
- - Dispatch respects `--` end-of-flags sentinel before command names.
893
-
894
- ## [0.6.0] - 2026-02-10
895
-
896
- ### Added
897
-
898
- #### Config File Discovery
899
-
900
- - **`CLIBuilder.config(appName)`** enables config file discovery with XDG-compliant search paths. Searches `.{app}.json` and `{app}.config.json` in cwd, then `{configDir}/{app}/config.json`. JSON loader built-in.
901
- - **`--config <path>` global flag** overrides config file discovery path. Extracted from argv before command dispatch.
902
- - **`CLIBuilder.configLoader(loader)`** plugin hook for registering custom config format loaders (YAML, TOML, etc.). `configFormat(extensions, parseFn)` convenience factory.
903
-
904
- #### Schema Additions
905
-
906
- - **`flag.custom(parseFn)`** — new flag kind accepting an arbitrary parse function with full return-type inference from `parseFn`. Wired through parser coercion, all three resolve coercions (env, config, prompt), and help formatter.
907
- - **`.deprecated(message?)`** modifier on `FlagBuilder` and `ArgBuilder`. Emits structured `DeprecationWarning` during resolution when a deprecated flag/arg is explicitly provided (CLI, env, config, prompt — not for default fallthrough). Renders `[deprecated]` or `[deprecated: <reason>]` in help text.
908
-
909
- #### RuntimeAdapter Extensions
910
-
911
- - **`readFile`** — async file read returning `null` for ENOENT, throws on other errors. Uses lazy `import('node:fs/promises')`.
912
- - **`homedir`** — computed from env vars (`HOME`/`USERPROFILE`) + `platform`; avoids `node:os`.
913
- - **`configDir`** — `XDG_CONFIG_HOME` on Unix, `APPDATA` on Windows; falls back to `~/.config` or `~\AppData\Roaming`.
914
-
915
- ### Changed
916
-
917
- - `RuntimeAdapter` interface extended with `readFile`, `homedir`, `configDir`.
918
- - `NodeProcess` interface extended with `platform` field.
919
- - `FlagSchema` extended with `parseFn: FlagParseFn<unknown> | undefined`.
920
- - `FlagSchema` extended with `deprecated: string | true | undefined`.
921
- - `ArgSchema` extended with `deprecated: string | true | undefined`.
922
- - `ResolveResult` extended with `warnings: readonly DeprecationWarning[]`.
923
- - `CLISchema` extended with `configSettings` for config file discovery.
924
- - `FlagParseFn<T>`, `DeprecationWarning`, `ConfigResult`, `FormatLoader`, `configFormat` exported from public API.
925
- - Test count: ~1300 tests (up from 1198 in v0.5.0).
926
-
927
- ## [0.5.0] - 2026-02-10
928
-
929
- ### Added
930
-
931
- #### Shell Completions
932
-
933
- - **Bash completion generator** — produces self-contained bash scripts with `COMP_WORDS`/`COMP_CWORD` scanning, per-command case branches with flag and enum value completions, and `complete -F` registration.
934
- - **Zsh completion generator** — produces `#compdef` scripts with `_arguments` flag specs, `_describe` subcommand lists, and enum value completions via `->state` dispatch.
935
- - **`CLIBuilder.completions()`** adds a built-in `completions --shell <bash|zsh>` subcommand that outputs a ready-to-eval completion script. In `--json` mode, emits `{ script }` JSON object. Fish/PowerShell accepted in the enum with descriptive "not yet supported" errors.
936
-
937
- #### Runtime Portability
938
-
939
- - **`detectRuntime()`** via `globalThis` feature detection — identifies Node, Bun, Deno, or unknown. Exported `Runtime` type and `RUNTIMES` constant.
940
- - **`createAdapter()`** auto-detecting adapter factory — calls `detectRuntime()` and returns the appropriate `RuntimeAdapter`. `CLIBuilder.run()` uses it as default when no adapter is provided.
941
- - **Bun adapter** implementing `RuntimeAdapter` by delegating to the Node adapter (Bun's Node-compatible APIs).
942
-
943
- ### Fixed
944
-
945
- - Completion: cross-command enum collision — `collectEnumCases()` scoped per-command to prevent enum values from one command leaking into another's completions.
946
- - Completion: shell injection safety — `quoteShellArg()` escapes `schema.name` and enum values in generated scripts.
947
- - Completion: conditional `--version` — bash generator omits `--version` from completions when `schema.version` is undefined, matching zsh behavior.
948
- - CLI: `--json` mode completions output `{ script }` JSON instead of raw script text.
949
- - CLI: guard against double `.completions()` call.
950
- - Runtime: `NodeProcess` type exported from main barrel.
951
- - Runtime: `@internal` removed from `GlobalForDetect` (contradicted public export).
952
- - Runtime: `createAdapter()` switch uses `default: never` exhaustiveness guard.
953
-
954
- ### Changed
955
-
956
- - Shell completion types, generator stubs, and barrel exports added to `src/core/completion/`.
957
- - Test count: 1198 tests across 35 test files (up from 1010 in v0.4.0).
958
-
959
- ## [0.4.0] - 2026-02-09
960
-
961
- ### Added
962
-
963
- #### Typed Middleware
964
-
965
- - **`middleware<Output>(handler)`** factory creating phantom-branded `Middleware<Output>` values. Handler receives `{ args, flags, ctx, out, next }` — call `next(additions)` to continue the chain with typed context, omit `next()` to short-circuit (auth guards), or await `next()` for wrap-around patterns (timing, try/catch).
966
- - **`CommandBuilder.middleware(m)`** registers middleware in execution order. Each call widens the context type parameter `C` via `WidenContext<C, Output>` intersection — `Record<string, never>` (the default) is replaced entirely on the first call, preventing `never` collapse. Adding middleware drops the current handler (type signature changed).
967
- - **Context type parameter `C`** on `CommandBuilder<F, A, C>`, `ActionParams<F, A, C>`, and `ActionHandler<F, A, C>`. `ctx` in the action handler is `Readonly<C>` — property access is a type error until middleware extends it.
968
- - **Middleware chain execution** (`executeWithMiddleware`) in testkit. Builds a continuation chain from back to front; context accumulates via `{ ...ctx, ...additions }` at each step. Replaces the former `invokeHandler` bridge.
969
-
970
- #### Structured Output
971
-
972
- - **`out.json(value)`** emits `JSON.stringify(value)` to stdout. Always targets stdout regardless of JSON mode. Handlers should prefer this over `out.log(JSON.stringify(...))`.
973
- - **`out.table(rows, columns?)`** renders tabular data. In JSON mode: emits rows as JSON array. In text mode: pretty-prints aligned columns with headers (auto-inferred from first row when `columns` omitted). `TableColumn<T>` descriptor type with `key` and optional `header`.
974
- - **`out.jsonMode`** and **`out.isTTY`** readonly properties on `Out` interface. Handlers check these to skip decorative output (spinners, ANSI codes) when machine-readable output is expected or stdout is piped.
975
- - **`--json` global flag** detection in `CLIBuilder.execute()`. Strips `--json` from argv before command dispatch. CLI-level dispatch errors (unknown command, no action) rendered as JSON when active.
976
- - **`jsonMode`** and **`isTTY`** options on `RunOptions`, `CLIRunOptions`, and `OutputOptions`. `CLIBuilder.run()` auto-sources `isTTY` from `adapter.isTTY`.
977
-
978
- ### Changed
979
-
980
- - `ActionParams<F, A>` → `ActionParams<F, A, C>` with `ctx: Readonly<C>` (was `Readonly<Record<string, unknown>>`).
981
- - `CommandBuilder` carries third type parameter `C` (default `Record<string, never>`). All metadata/builder methods preserve `C` in return type.
982
- - `CommandSchema.middleware` added as `readonly ErasedMiddlewareHandler[]`.
983
- - `Out` interface extended with `json()`, `table()`, `jsonMode`, and `isTTY`.
984
- - `OutputChannel` constructor accepts `isTTY` and `jsonMode` from resolved options. `log`/`info` redirect to stderr writer in JSON mode.
985
- - `runCommand` and `CLIBuilder.execute` error paths render JSON when `jsonMode` active.
986
- - `createCaptureOutput` accepts `jsonMode` and `isTTY` options.
987
- - Test count: 1010 tests across 31 test files (up from 797 in v0.3.0).
988
-
989
- ## [0.3.0] - 2026-02-09
990
-
991
- ### Added
992
-
993
- #### Interactive Prompting
994
-
995
- - **Prompt type definitions** (`PromptConfig`) as a discriminated union with four kinds: `confirm`, `input`, `select`, `multiselect`. Each kind has specialized fields — `InputPromptConfig` supports `placeholder` and `validate`, select/multiselect support `SelectChoice` arrays with optional labels and descriptions.
996
- - **`FlagBuilder.prompt(config)`** metadata modifier for declaring prompt configuration on flags, following the same immutable builder pattern as `.env()` and `.config()`.
997
- - **Prompt engine interface** (`PromptEngine`) with `promptOne(config) → Promise<PromptResult>` as a pluggable renderer seam. `ResolvedPromptConfig` variant guarantees non-empty choices for select/multiselect after merging from `FlagSchema.enumValues`.
998
- - **Built-in terminal prompter** (`createTerminalPrompter(read, write)`) with line-based I/O for confirm (y/n), input (with validation and placeholder), select (numbered list), and multiselect (comma-separated numbers with min/max). All prompts have a `MAX_RETRIES = 10` safety valve.
999
- - **Test prompter** (`createTestPrompter(answers, options?)`) with queue-based answers for deterministic testing. `PROMPT_CANCEL` symbol sentinel for simulating cancellation. `onExhausted: 'throw' | 'cancel'` controls behavior when answer queue is empty.
1000
- - **Prompt resolution in the resolver**. Resolution chain expanded from CLI > env > config > default to CLI > env > config > **prompt** > default. Flags with prompt config and no value from prior sources trigger `prompter.promptOne()`. Cancelled prompts fall through to default/required. Non-interactive mode (no prompter) skips prompts entirely.
1001
- - **`ReadFn`** (`() => Promise<string | null>`) as the minimal stdin abstraction. `null` signals EOF/cancel. `RuntimeAdapter` extended with `stdin: ReadFn` and `stdinIsTTY: boolean`.
1002
- - **Node adapter stdin** wraps `process.stdin` via dynamic `import('node:readline')` with lazy per-call readline interfaces. Minimal `node:readline` type declarations in `node-builtins.d.ts` avoid `@types/node` dependency.
1003
- - **Automatic prompt gating** in `CLIBuilder.run()`: when `stdinIsTTY=true` and no explicit prompter provided, auto-creates `createTerminalPrompter(adapter.stdin, adapter.stderr)`. Prompt output routed to stderr to avoid interfering with piped stdout.
1004
- - **Command-level `.interactive(resolver)`** API on `CommandBuilder`. Resolver receives partially resolved flags (after CLI/env/config), returns `Record<string, PromptConfig | false | undefined>` controlling which flags get prompted. Truthy `PromptConfig` overrides per-flag prompt; `false` explicitly suppresses; absent falls back to per-flag `.prompt()` config.
1005
- - **Testkit `answers` convenience** on `RunOptions`. Accepts `Record<string, TestAnswer>` to auto-create a test prompter. `prompter` field also available for explicit engine injection. `CLIRunOptions` mirrors both fields.
1006
-
1007
- ### Changed
1008
-
1009
- - `resolve()` is now **async** (`Promise<ResolveResult>`). All callers (`runCommand`, `CLIBuilder.execute`, `CLIBuilder.run`) updated to await.
1010
- - Resolution chain expanded from CLI > env > config > default to CLI > env > config > prompt > default.
1011
- - `ResolveOptions` extended with optional `prompter: PromptEngine` field.
1012
- - `RunOptions` extended with `prompter` and `answers` fields.
1013
- - `CLIRunOptions` extended with `prompter` and `answers` fields.
1014
- - `RuntimeAdapter` extended with `stdin: ReadFn` and `stdinIsTTY: boolean`.
1015
- - `createTestAdapter` defaults to EOF-returning stdin and `stdinIsTTY: false`.
1016
- - Test count: 797 tests across 21 test files (up from 599 in v0.2.0).
1017
-
1018
- ## [0.2.0] - 2026-02-09
1019
-
1020
- ### Added
1021
-
1022
- #### Resolution Chain
1023
-
1024
- - **Environment variable resolution** in the resolver. Flags with `.env('VAR')` now resolve from the `env` record after CLI and before default. String, number, boolean (lenient: `true/false/1/0/yes/no`), enum, and array (comma-separated) coercion. Invalid env values produce `ValidationError` with `TYPE_MISMATCH` or `INVALID_ENUM` codes.
1025
- - **Config object resolution** in the resolver. Flags with `.config('dotted.path')` resolve from a plain `Record<string, unknown>` after env and before default. `resolveConfigPath()` walks nested objects segment-by-segment. Config values may already be typed from JSON — coercion is lenient for matching types. Full chain: CLI > env > config > default.
1026
- - **Resolution source annotations** in help text. Flags with env or config declarations now display `[env: VAR]` and `[config: path]` in `formatHelp()` output, ordered between description text and presence indicators.
1027
- - **Actionable required-flag error hints**. When a required flag is missing after full resolution, `ValidationError.suggest` lists all configured sources (e.g. "Provide --region, set DEPLOY_REGION, or add deploy.region to config"). CI-friendly error messages with `envVar`/`configPath` in details.
1028
- - **Env/config wiring through testkit and CLI builder**. `RunOptions` and `CLIRunOptions` accept `env` and `config` fields. `runCommand()` threads them into `resolve()`. `CLIBuilder.run()` auto-sources `adapter.env` when no explicit env option is provided.
1029
-
1030
- ### Changed
1031
-
1032
- - Resolution chain expanded from CLI > default (v0.1) to CLI > env > config > default.
1033
- - `resolve()` now accepts optional `ResolveOptions` parameter with `env` and `config` fields.
1034
- - `ResolveOptions` exported from public API surface.
1035
-
1036
- ## [0.1.0] - 2026-02-09
1037
-
1038
- ### Added
1039
-
1040
- #### Core Framework
1041
-
1042
- - **Structured errors** (`CLIError`, `ParseError`, `ValidationError`) with stable error codes, `toJSON()` serialization, type guard functions (`isCLIError`, `isParseError`, `isValidationError`), and actionable `suggest` hints.
1043
- - **Flag builder** (`flag`) with full type inference for boolean, string, number, enum, and array kinds. Supports `.alias()`, `.default()`, `.required()`, `.describe()`, `.hidden()`, `.deprecated()`, `.env()`, and `.config()` declarations.
1044
- - **Arg builder** (`arg`) with type inference for string, number, custom parse functions, and variadic args. Supports `.default()`, `.required()`, `.optional()`, and `.describe()`.
1045
- - **Command builder** (`command`) with `.flag()`, `.arg()`, `.description()`, `.example()`, `.hidden()`, `.alias()`, and `.action()`. Accumulates phantom types so handler receives fully inferred `flags` and `args`.
1046
- - **Argv parser** with tokenizer (`tokenize`) and schema-aware parser (`parse`). Handles long/short flags, `=` syntax, boolean negation (`--no-*`), flag stacking (`-abc`), `--` separator, and type coercion against the schema.
1047
- - **Resolution chain** (CLI parsed value → schema default). Validates all required flags/args, aggregates multiple errors into a single throw, and provides per-field suggestions.
1048
- - **Auto-generated help text** (`formatHelp`) from command schema, including usage line, description, positional args, flags with types/defaults/aliases, examples section, and subcommand listing.
1049
- - **Output channel** (`createOutput`) with `log`/`info`/`warn`/`error` methods, `WriteFn` abstraction, verbosity levels (normal/quiet), and TTY detection. Includes `createCaptureOutput()` test helper.
1050
- - **Test harness** (`runCommand`) for running commands as pure functions with injected argv, env, and captured output. Returns `RunResult` with `exitCode`, `stdout`, `stderr`, and `error`.
1051
- - **CLI builder** (`cli`) with `.command()` registration, `.version()`, subcommand dispatch, automatic `--help`/`--version` flag handling, and unknown-command error with suggestions.
1052
- - **RuntimeAdapter interface** defining the platform abstraction boundary (argv, env, cwd, stdout/stderr, isTTY, exit). Includes `createTestAdapter()` for injectable test stubs and `ExitError` for testable process exits.
1053
- - **Node.js adapter** (`createNodeAdapter`) wiring `process.argv`, `process.env`, `process.cwd()`, `process.stdout`/`stderr`, and TTY detection.
1054
- - Stub files for Bun adapter, Deno adapter, runtime auto-detection, and shell completion generation.
1055
-
1056
- #### Project Infrastructure
1057
-
1058
- - Project scaffold with `src/` structure, TypeScript strict config, and ESM + CJS dual build via tsdown.
1059
- - Vitest test framework with 464 passing tests across 12 test files.
1060
- - Biome linter and dprint formatter configuration.
1061
- - `@vitest/coverage-v8` for test coverage reporting.
1062
- - `@arethetypeswrong/cli` and `publint` for package quality checks.
1063
- - CI script (`pnpm run ci`) running typecheck, lint, test, and build in sequence.
1064
- - PRD.md with full product requirements document.
1065
- - MIT License.
1066
- - Markdownlint configuration.
1067
-
1068
- [Unreleased]: https://github.com/kjanat/dreamcli/compare/v4.0.0-rc.3...HEAD
1069
- [4.0.0-rc.3]: https://github.com/kjanat/dreamcli/compare/v4.0.0-rc.2...v4.0.0-rc.3
1070
- [4.0.0-rc.2]: https://github.com/kjanat/dreamcli/compare/v4.0.0-rc.1...v4.0.0-rc.2
1071
- [4.0.0-rc.1]: https://github.com/kjanat/dreamcli/compare/v3.0.1...v4.0.0-rc.1
1072
- [3.0.1]: https://github.com/kjanat/dreamcli/compare/v3.0.0...v3.0.1
1073
- [3.0.0]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.20...v3.0.0
1074
- [3.0.0-rc.20]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.19...v3.0.0-rc.20
1075
- [3.0.0-rc.19]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.18...v3.0.0-rc.19
1076
- [3.0.0-rc.18]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.17...v3.0.0-rc.18
1077
- [3.0.0-rc.17]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.16...v3.0.0-rc.17
1078
- [3.0.0-rc.16]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.15...v3.0.0-rc.16
1079
- [3.0.0-rc.15]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.14...v3.0.0-rc.15
1080
- [3.0.0-rc.14]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.13...v3.0.0-rc.14
1081
- [3.0.0-rc.13]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.12...v3.0.0-rc.13
1082
- [3.0.0-rc.12]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.11...v3.0.0-rc.12
1083
- [3.0.0-rc.11]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.10...v3.0.0-rc.11
1084
- [3.0.0-rc.10]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.9...v3.0.0-rc.10
1085
- [3.0.0-rc.9]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.8...v3.0.0-rc.9
1086
- [3.0.0-rc.8]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.7...v3.0.0-rc.8
1087
- [3.0.0-rc.7]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.6...v3.0.0-rc.7
1088
- [3.0.0-rc.6]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.5...v3.0.0-rc.6
1089
- [3.0.0-rc.5]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.4...v3.0.0-rc.5
1090
- [3.0.0-rc.4]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.3...v3.0.0-rc.4
1091
- [3.0.0-rc.3]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.2...v3.0.0-rc.3
1092
- [3.0.0-rc.2]: https://github.com/kjanat/dreamcli/compare/v3.0.0-rc.1...v3.0.0-rc.2
1093
- [3.0.0-rc.1]: https://github.com/kjanat/dreamcli/compare/v2.5.0...v3.0.0-rc.1
1094
- [2.5.0]: https://github.com/kjanat/dreamcli/compare/v2.4.1...v2.5.0
1095
- [2.4.1]: https://github.com/kjanat/dreamcli/compare/v2.4.0...v2.4.1
1096
- [2.4.0]: https://github.com/kjanat/dreamcli/compare/v2.3.0...v2.4.0
1097
- [2.3.0]: https://github.com/kjanat/dreamcli/compare/v2.2.1...v2.3.0
1098
- [2.2.1]: https://github.com/kjanat/dreamcli/compare/v2.2.0...v2.2.1
1099
- [2.2.0]: https://github.com/kjanat/dreamcli/compare/v2.1.0...v2.2.0
1100
- [2.1.0]: https://github.com/kjanat/dreamcli/compare/v2.0.1...v2.1.0
1101
- [2.0.1]: https://github.com/kjanat/dreamcli/compare/v2.0.0...v2.0.1
1102
- [2.0.0]: https://github.com/kjanat/dreamcli/compare/v1.0.0...v2.0.0
1103
- [1.0.0]: https://github.com/kjanat/dreamcli/compare/5b86f72...v1.0.0
1104
- [0.9.2]: https://github.com/kjanat/dreamcli/compare/b26f2d8...5b86f72
1105
- [0.9.1]: https://github.com/kjanat/dreamcli/compare/v0.9.0...b26f2d8
1106
- [0.9.0]: https://github.com/kjanat/dreamcli/compare/v0.8.0...v0.9.0
1107
- [0.8.0]: https://github.com/kjanat/dreamcli/compare/v0.7.0...v0.8.0
1108
- [0.7.0]: https://github.com/kjanat/dreamcli/compare/v0.6.0...v0.7.0
1109
- [0.6.0]: https://github.com/kjanat/dreamcli/compare/v0.5.0...v0.6.0
1110
- [0.5.0]: https://github.com/kjanat/dreamcli/compare/v0.4.0...v0.5.0
1111
- [0.4.0]: https://github.com/kjanat/dreamcli/compare/v0.3.0...v0.4.0
1112
- [0.3.0]: https://github.com/kjanat/dreamcli/compare/v0.2.0...v0.3.0
1113
- [0.2.0]: https://github.com/kjanat/dreamcli/compare/v0.1.0...v0.2.0
1114
- [0.1.0]: https://github.com/kjanat/dreamcli/releases/tag/v0.1.0
1115
-
1116
- <!-- markdownlint-disable-file line-length no-duplicate-heading no-bare-urls -->