Repository navigation
feat: shell completions, config discovery, custom flags, deprecation, and nested subcommand trees (v0.5–v0.7) - #1
Merged
Merged
Conversation
…xport) Removed @internal from GlobalForDetect in detect.ts:58. Type is exported from src/index.ts:125 and used in public function signatures (detectRuntime, createAdapter). Also audited all other @internal tags — found 2 more standalone contradictions (ErasedMiddlewareHandler, ErasedInteractiveResolver) but those are separate scope.
…itch
Added `default: { const _exhaustive: never = runtime; return _exhaustive; }` to createAdapter switch in auto.ts. Compile-time error if new Runtime variant added without handling. Added exhaustiveness test iterating RUNTIMES constant. All 1157 tests pass.
Accept fish/powershell in flag enum so generateCompletion() produces descriptive 'not yet supported' CLIError instead of generic parse error.
…rror messages Expanded .completions() --shell flag enum from ['bash','zsh'] to all Shell values ['bash','zsh','fish','powershell']. Users now get descriptive 'not yet supported' CLIError for unimplemented shells instead of generic parse error. Updated JSDoc, added powershell test, strengthened fish/powershell error assertions. 1159 tests pass.
Added NodeProcess to type exports in src/index.ts barrel. Was the only runtime type missing from public API surface. Used in createNodeAdapter() and createBunAdapter() parameter signatures. All 1159 tests pass, typecheck/lint/format clean.
Added guard at top of .completions() — checks `this.schema.commands.some(c => c.schema.name === 'completions')`, throws CLIError(DUPLICATE_COMMAND) on second call. 3 tests: CLIError type, error code, with other commands. 1162 tests pass, typecheck/lint/format clean.
In --json mode, out.log(script) sent completion script to stderr (log redirects there). Fixed: .completions() action checks out.jsonMode — uses out.json({ script }) for JSON mode, out.log(script) for normal. 4 tests added. 1166 tests pass, typecheck/lint/format clean.
Made bash completion --version conditional on schema.version !== undefined, matching zsh behavior. Fixed both with-commands path (rootFlags variable) and no-commands path (inline compgen string). 3 new unit tests + 3 E2E test updates. 1171 tests pass, typecheck/lint/format clean.
Moved enum case completion inside per-command `case "$subcmd"` branches. `collectEnumCases()` now takes single CommandSchema instead of array — no cross-command dedup. Each command gets its own `case "$prev"` block with only its enum values. 2 tests: cross-command collision (deploy prod/staging vs test unit/e2e), mixed enum/non-enum. Zsh unaffected (already per-command). 1173 tests pass, typecheck/lint/format clean.
This was referenced Apr 2, 2026
Closed
This was referenced Apr 11, 2026
This was referenced Jun 29, 2026
This was referenced Jul 6, 2026
This was referenced Jul 16, 2026
This was referenced Aug 1, 2026
Merged
Merged
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three milestones of framework capability shipped in one branch — 62 files changed, ~11k lines added, 1518 tests passing across 43 test files.
v0.5.0 — Shell Completions & Runtime Adapters
.completions()subcommand with--jsonsupport, duplicate-call guard, and descriptive errors for unimplemented shells (fish/powershell)globalThisfeature probing —detectRuntime()+createAdapter()factoryUNSUPPORTED_RUNTIMEv0.6.0 — Config Discovery, Custom Flags & Deprecation
--config/--config=<path>override (stripped from argv), JSON loader built-in.configLoader()+configFormat()factoryflag.custom(parseFn)with inferred return type — coercion wired through CLI/env/config/prompt;parseFnreceivesunknown(raw JSON from config, string from CLI/env).deprecated()modifier on flags and args — structuredDeprecationWarningobjects in resolve result,[deprecated]annotations in help output,out.warn()emissionreadFile,homedir,configDir(XDG/APPDATA-aware, HOMEDRIVE+HOMEPATH fallback on win32)v0.7.0 — Nested Subcommand Trees
CommandBuilder.command()+group()for recursive command tree definitionflag.propagate()for explicit flag inheritance — ancestor walk with deterministic shadowing (nearest wins, target's own flags override)--handling, remaining-argv preservationformatHelp(), group help with fullbinNamepathErasedCommand,AnyCommandBuilder,eraseBuilderhelperHousekeeping & Review Fixes
package.jsonbumped to 0.7.0, git tags appliedv0.7-subcommand-nesting.md,v0.8-spinner-progress.mdNew Public API Exports
generateCompletion,generateBashCompletion,generateZshCompletion,CompletionOptions,Shell,SHELLSdiscoverConfig,configFormat,buildConfigSearchPaths,ConfigAdapter,FormatLoader,ConfigResultflag.custom(),FlagParseFn,flag.propagate(),.deprecated(),group(),AnyCommandBuilder,ErasedCommandDeprecationWarningdetectRuntime,RUNTIMES,createAdapter,createBunAdapter,NodeProcess,GlobalForDetectStats
feat: Shell completions, config discovery, custom flags, deprecation, and nested subcommand trees
Overview
This PR delivers three major release milestones (v0.5.0–v0.7.0) for the dreamcli TypeScript CLI framework, spanning 62 files with 11,466 additions and 831 deletions. The PR includes 1,518 tests across 43 test files and introduces significant new capabilities for building production-grade CLIs.
Key Features
v0.5.0: Shell Completions & Runtime Detection
.completions()Subcommand: Generators include--jsonoutput mode and output guardsglobalThiswithdetectRuntime(),createAdapter(), and per-runtime adapters (Node, Bun, Deno)UNSUPPORTED_RUNTIMEv0.6.0: Config Discovery, Custom Flags & Deprecation
--configflag override and custom format loadersflag.custom(parseFn)with type inference and coercion across CLI/env/config/prompt sources.deprecated()modifier for flags/args with help annotations andDeprecationWarningemissionsreadFile(),homedir(),configDir()(XDG/APPDATA-aware, with Windows fallbacks)v0.7.0: Nested Subcommand Trees
CommandBuilder.command()and.group()for arbitrary nesting depth.propagate()modifier for explicit flag inheritance with deterministic shadowing across command ancestry--handlingImplementation Highlights
Config System
src/core/config/module withdiscoverConfig(), pluggableFormatLoaderabstraction, and JSON as defaultCLIBuilder.run()with automatic discovery and--configflag support.configLoader()with precedence rulesCompletion System
src/core/completion/withgenerateBashCompletion()andgenerateZshCompletion()generateCompletion()dispatcher; fish/powershell raiseUNSUPPORTED_OPERATIONCommand Dispatch
src/core/cli/dispatch.tsimplementing recursive matching with support for leaf/group commandssrc/core/cli/propagate.tsfor collecting inherited flags with shadowing rulesRuntime Adaptation
src/runtime/modules:auto.ts(auto-detection),detect.ts(runtime identification),bun.ts(Bun adapter)readFile,homedir,configDirType System
ErasedCommand,AnyCommandBuilder,eraseBuilder()for heterogeneous subcommand storagecommands: readonly CommandSchema[]field for schema-level subcommand representationFlagParseFn<T>,ArgParseFn<T>with type inferenceTesting & Quality
1,518 tests across 43 test files with comprehensive coverage of:
End-to-end tests validate nested dispatch, flag propagation shadowing, and multi-level integration
Test helpers updated for new schema fields (
commands,propagate,deprecated,parseFn)Public API Additions
Completion:
generateBashCompletion,generateCompletion,generateZshCompletion,SHELLS,CompletionOptions,ShellConfig:
buildConfigSearchPaths,configFormat,discoverConfig,ConfigAdapter,ConfigDiscoveryOptions,ConfigDiscoveryResult,ConfigFound,ConfigNotFound,FormatLoaderRuntime:
createAdapter,createBunAdapter,detectRuntime,RUNTIMES,GlobalForDetect,RuntimeSchema:
group,ErasedCommand,AnyCommandBuilder,FlagParseFn(withflag.custom<T>()method),.propagate()and.deprecated()modifiers on flags/argsResolve:
DeprecationWarninginResolveResultwith structured deprecation trackingCLI:
.config(),.configLoader(),.completions()builder methods;ConfigSettingstypeDocumentation & Housekeeping
v0.7-subcommand-nesting.md(design, architecture, task breakdown),v0.8-spinner-progress.md(future direction)Breaking Changes
None. All additions are backward-compatible; existing APIs remain stable while new optional features are layered on top.
Fixed Issues
resolveConfigDir()to treat empty APPDATA environment variable as unset on WindowsReview & Merge
PR merged 2026-02-10T20:01:27Z with three review rounds addressing feedback and hardening across all subsystems.