@kjanat/dreamcli 4.0.0-rc.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/{runtime/adapter.d.mts → adapter-D0hbBNVB.d.mts} +2 -4
- package/dist/completion-D4mz6axB.mjs +6 -0
- package/dist/completion.d.mts +90 -0
- package/dist/completion.mjs +1 -0
- package/dist/config-B9ddC-Kb.mjs +1 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +1 -0
- package/dist/core-Cp2w8vRq.mjs +17 -0
- package/dist/index-BziI2aKc.d.mts +5440 -0
- package/dist/index-DOfClfYR.d.mts +370 -0
- package/dist/index-DWsnGZlx.d.mts +831 -0
- package/dist/{core/cli/index.d.mts → index-DXROeDPC.d.mts} +116 -57
- package/dist/index-DndPmT8J.d.mts +275 -0
- package/dist/{core/json-schema/index.d.mts → index-DyoaS234.d.mts} +43 -34
- package/dist/index.d.mts +190 -41
- package/dist/index.mjs +1 -26
- package/dist/json-schema-C9SzZ7jY.mjs +52 -0
- package/dist/json-schema.d.mts +2 -0
- package/dist/json-schema.mjs +1 -0
- package/dist/package-json-BgE9YjjQ.mjs +3 -0
- package/dist/prompt.d.mts +48 -0
- package/dist/prompt.mjs +1 -0
- package/dist/rolldown-runtime-G4Kt5YOX.mjs +1 -0
- package/dist/runtime.d.mts +2 -6
- package/dist/runtime.mjs +1 -6
- package/dist/terminal-C8KTXjv5.mjs +6 -0
- package/dist/test-prompter-v__jT2yG.mjs +1 -0
- package/dist/testkit.d.mts +54 -6
- package/dist/testkit.mjs +1 -5
- package/dist/version.mjs +1 -7
- package/dreamcli.schema.json +697 -538
- package/package.json +29 -7
- package/skills/cli-creation/SKILL.md +16 -11
- package/CHANGELOG.md +0 -1116
- package/dist/core/cli/builtins.d.mts +0 -117
- package/dist/core/cli/builtins.mjs +0 -135
- package/dist/core/cli/compiled.d.mts +0 -66
- package/dist/core/cli/compiled.mjs +0 -76
- package/dist/core/cli/dispatch.d.mts +0 -115
- package/dist/core/cli/dispatch.mjs +0 -205
- package/dist/core/cli/help-links.d.mts +0 -27
- package/dist/core/cli/help-links.mjs +0 -41
- package/dist/core/cli/index.mjs +0 -1271
- package/dist/core/cli/planner.d.mts +0 -174
- package/dist/core/cli/planner.mjs +0 -323
- package/dist/core/cli/plugin.d.mts +0 -94
- package/dist/core/cli/plugin.mjs +0 -41
- package/dist/core/cli/propagate.d.mts +0 -39
- package/dist/core/cli/propagate.mjs +0 -57
- package/dist/core/cli/reserved-flags.d.mts +0 -19
- package/dist/core/cli/reserved-flags.mjs +0 -158
- package/dist/core/cli/root-help.d.mts +0 -53
- package/dist/core/cli/root-help.mjs +0 -221
- package/dist/core/cli/root-output-flags.d.mts +0 -74
- package/dist/core/cli/root-output-flags.mjs +0 -169
- package/dist/core/cli/root-surface.d.mts +0 -64
- package/dist/core/cli/root-surface.mjs +0 -28
- package/dist/core/cli/runtime-preflight.d.mts +0 -213
- package/dist/core/cli/runtime-preflight.mjs +0 -221
- package/dist/core/completion/index.d.mts +0 -76
- package/dist/core/completion/index.mjs +0 -90
- package/dist/core/completion/shells/bash.d.mts +0 -23
- package/dist/core/completion/shells/bash.mjs +0 -312
- package/dist/core/completion/shells/fish.d.mts +0 -19
- package/dist/core/completion/shells/fish.mjs +0 -164
- package/dist/core/completion/shells/powershell.d.mts +0 -13
- package/dist/core/completion/shells/powershell.mjs +0 -360
- package/dist/core/completion/shells/shared.d.mts +0 -164
- package/dist/core/completion/shells/shared.mjs +0 -147
- package/dist/core/completion/shells/zsh.d.mts +0 -23
- package/dist/core/completion/shells/zsh.mjs +0 -256
- package/dist/core/config/index.d.mts +0 -191
- package/dist/core/config/index.mjs +0 -285
- package/dist/core/config/package-json.d.mts +0 -179
- package/dist/core/config/package-json.mjs +0 -353
- package/dist/core/errors/index.d.mts +0 -125
- package/dist/core/errors/index.mjs +0 -87
- package/dist/core/execution/index.d.mts +0 -61
- package/dist/core/execution/index.mjs +0 -220
- package/dist/core/help/ansi.d.mts +0 -84
- package/dist/core/help/ansi.mjs +0 -121
- package/dist/core/help/index.d.mts +0 -149
- package/dist/core/help/index.mjs +0 -418
- package/dist/core/help/theme.d.mts +0 -86
- package/dist/core/help/theme.mjs +0 -69
- package/dist/core/json-schema/index.mjs +0 -1008
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +0 -274
- package/dist/core/json-schema/meta-descriptions.generated.mjs +0 -136
- package/dist/core/output/activity.d.mts +0 -193
- package/dist/core/output/activity.mjs +0 -452
- package/dist/core/output/bind.d.mts +0 -37
- package/dist/core/output/bind.mjs +0 -56
- package/dist/core/output/contracts.d.mts +0 -82
- package/dist/core/output/contracts.mjs +0 -57
- package/dist/core/output/display-value.d.mts +0 -19
- package/dist/core/output/display-value.mjs +0 -32
- package/dist/core/output/index.d.mts +0 -344
- package/dist/core/output/index.mjs +0 -514
- package/dist/core/output/renderers.d.mts +0 -45
- package/dist/core/output/renderers.mjs +0 -46
- package/dist/core/output/writer.d.mts +0 -39
- package/dist/core/output/writer.mjs +0 -12
- package/dist/core/parse/index.d.mts +0 -178
- package/dist/core/parse/index.mjs +0 -850
- package/dist/core/parse/occurrences.d.mts +0 -90
- package/dist/core/parse/occurrences.mjs +0 -114
- package/dist/core/prompt/index.d.mts +0 -213
- package/dist/core/prompt/index.mjs +0 -348
- package/dist/core/read-flags/index.d.mts +0 -150
- package/dist/core/read-flags/index.mjs +0 -217
- package/dist/core/resolve/args.d.mts +0 -39
- package/dist/core/resolve/args.mjs +0 -182
- package/dist/core/resolve/coerce.d.mts +0 -79
- package/dist/core/resolve/coerce.mjs +0 -900
- package/dist/core/resolve/config.d.mts +0 -10
- package/dist/core/resolve/config.mjs +0 -19
- package/dist/core/resolve/contracts.d.mts +0 -146
- package/dist/core/resolve/errors.d.mts +0 -10
- package/dist/core/resolve/errors.mjs +0 -148
- package/dist/core/resolve/flags.d.mts +0 -74
- package/dist/core/resolve/flags.mjs +0 -246
- package/dist/core/resolve/index.d.mts +0 -44
- package/dist/core/resolve/index.mjs +0 -123
- package/dist/core/resolve/path-checks.d.mts +0 -48
- package/dist/core/resolve/path-checks.mjs +0 -102
- package/dist/core/resolve/redaction.d.mts +0 -13
- package/dist/core/resolve/redaction.mjs +0 -14
- package/dist/core/resolve/stages.d.mts +0 -86
- package/dist/core/resolve/stages.mjs +0 -170
- package/dist/core/resolve/standard.d.mts +0 -26
- package/dist/core/resolve/standard.mjs +0 -212
- package/dist/core/schema/activity.d.mts +0 -189
- package/dist/core/schema/arg.d.mts +0 -1461
- package/dist/core/schema/arg.mjs +0 -1139
- package/dist/core/schema/brand.d.mts +0 -17
- package/dist/core/schema/cardinality.d.mts +0 -302
- package/dist/core/schema/cardinality.mjs +0 -514
- package/dist/core/schema/command.d.mts +0 -1132
- package/dist/core/schema/command.mjs +0 -999
- package/dist/core/schema/flag.d.mts +0 -1495
- package/dist/core/schema/flag.mjs +0 -1207
- package/dist/core/schema/index.d.mts +0 -15
- package/dist/core/schema/index.mjs +0 -10
- package/dist/core/schema/middleware.d.mts +0 -129
- package/dist/core/schema/middleware.mjs +0 -41
- package/dist/core/schema/number-constraints.d.mts +0 -96
- package/dist/core/schema/number-constraints.mjs +0 -60
- package/dist/core/schema/prompt.d.mts +0 -135
- package/dist/core/schema/provenance.d.mts +0 -99
- package/dist/core/schema/provenance.mjs +0 -28
- package/dist/core/schema/run.d.mts +0 -211
- package/dist/core/schema/source.d.mts +0 -180
- package/dist/core/schema/source.mjs +0 -206
- package/dist/core/schema/standard.d.mts +0 -100
- package/dist/core/schema/standard.mjs +0 -15
- package/dist/core/schema/stdin.d.mts +0 -97
- package/dist/core/schema/stdin.mjs +0 -91
- package/dist/core/schema/string-constraints.d.mts +0 -108
- package/dist/core/schema/string-constraints.mjs +0 -86
- package/dist/core/schema/value-parsers.d.mts +0 -150
- package/dist/core/schema/value-parsers.mjs +0 -160
- package/dist/core/schema/value.d.mts +0 -243
- package/dist/core/schema/value.mjs +0 -573
- package/dist/core/testkit/index.d.mts +0 -63
- package/dist/core/testkit/index.mjs +0 -102
- package/dist/runtime/adapter.mjs +0 -92
- package/dist/runtime/auto.d.mts +0 -25
- package/dist/runtime/auto.mjs +0 -45
- package/dist/runtime/deno.d.mts +0 -99
- package/dist/runtime/deno.mjs +0 -265
- package/dist/runtime/detect.d.mts +0 -86
- package/dist/runtime/detect.mjs +0 -45
- package/dist/runtime/index.d.mts +0 -6
- package/dist/runtime/node.d.mts +0 -71
- package/dist/runtime/node.mjs +0 -228
- package/dist/runtime/paths.d.mts +0 -31
- package/dist/runtime/paths.mjs +0 -48
- package/dist/strings.d.mts +0 -27
- package/dist/strings.mjs +0 -22
- package/examples/basic.ts +0 -37
- package/examples/flag-types.ts +0 -79
- package/examples/gh/package.json +0 -45
- package/examples/gh/src/commands/auth.ts +0 -66
- package/examples/gh/src/commands/issue.ts +0 -120
- package/examples/gh/src/commands/pr.ts +0 -125
- package/examples/gh/src/data/issues.yaml +0 -5
- package/examples/gh/src/data/issues.yaml.d.ts +0 -17
- package/examples/gh/src/data/pull-requests.yaml +0 -7
- package/examples/gh/src/data/pull-requests.yaml.d.ts +0 -18
- package/examples/gh/src/docs.ts +0 -11
- package/examples/gh/src/lib/auth.ts +0 -37
- package/examples/gh/src/lib/utils.ts +0 -17
- package/examples/gh/src/main.test.ts +0 -307
- package/examples/gh/src/main.ts +0 -46
- package/examples/help-config.ts +0 -43
- package/examples/interactive.ts +0 -67
- package/examples/json-mode.ts +0 -95
- package/examples/middleware.ts +0 -71
- package/examples/multi-command.ts +0 -66
- package/examples/output-extras.ts +0 -46
- package/examples/parser-control.ts +0 -40
- package/examples/pwsh-demo/README.md +0 -40
- package/examples/pwsh-demo/package.json +0 -41
- package/examples/pwsh-demo/pwsh-demo.cmd +0 -3
- package/examples/pwsh-demo/smoke-powershell.ps1 +0 -218
- package/examples/pwsh-demo/src/main.test.ts +0 -45
- package/examples/pwsh-demo/src/main.ts +0 -140
- package/examples/spinner-progress.ts +0 -49
- package/examples/standard-schema.ts +0 -45
- package/examples/testing.ts +0 -147
- package/examples/transport-launcher.ts +0 -85
package/dist/index.d.mts
CHANGED
|
@@ -1,42 +1,191 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { StdinBinding, StdinConsume, StdinOptions, StdinWhen } from "./core/schema/stdin.mjs";
|
|
8
|
-
import { StringConstraintViolation, StringConstraints } from "./core/schema/string-constraints.mjs";
|
|
9
|
-
import { DateFlagOptions, PathChecks, PathFlagOptions, UrlFlagOptions } from "./core/schema/value-parsers.mjs";
|
|
10
|
-
import { ArrayFlagDefinition, BooleanFlagDefinition, CountFlagDefinition, CustomFlagDefinition, DuplicatePolicy, EnumFlagDefinition, FlagBuilder, FlagConfig, FlagDefinition, FlagDefinitionBase, FlagDefinitionByKind, FlagDefinitionOverrides, FlagFactory, FlagKind, FlagNegation, FlagParseFn, FlagPresence, FlagSchema, InferFlag, InferFlags, KeyValueFlagDefinition, NumberFlagDefinition, ResolvedValue, StringElementConfig, StringFlagDefinition, WithPresence, WithoutElementEligibility, createFlagSchema, flag, getFlagNegatedName } from "./core/schema/flag.mjs";
|
|
11
|
-
import { DUPLICATE_KEYS, DuplicateKeys, SPLIT_FORMATS, SourceSplitBinding, SplitBinding, SplitFormat, SplitOptions, SplitPolicy, SplitSetting } from "./core/schema/cardinality.mjs";
|
|
12
|
-
import { ArgBuilder, ArgConfig, ArgDefaultValue, ArgDefinition, ArgDefinitionBase, ArgDefinitionByKind, ArgDefinitionOverrides, ArgFactory, ArgKind, ArgParseFn, ArgPresence, ArgSchema, BooleanArgDefinition, CustomArgDefinition, EnumArgDefinition, InferArg, InferArgs, KeyValueArgDefinition, NumberArgDefinition, ResolvedArgValue, StringArgDefinition, StringArgElementConfig, WithArgPresence, WithVariadic, WithoutArgElementEligibility, arg, createArgSchema } from "./core/schema/arg.mjs";
|
|
13
|
-
import { ActivityEvent, Fallback, ProgressHandle, ProgressOptions, SpinnerHandle, SpinnerOptions, TableColumn, TableFormat, TableOptions, TableStream } from "./core/schema/activity.mjs";
|
|
14
|
-
import { Verbosity } from "./core/output/contracts.mjs";
|
|
15
|
-
import { Middleware, MiddlewareHandler, MiddlewareParams, middleware } from "./core/schema/middleware.mjs";
|
|
16
|
-
import { InputSources, ResolutionProvenance, SourcesOf, wasExplicit } from "./core/schema/provenance.mjs";
|
|
17
|
-
import { ActionHandler, ActionParams, CommandArgEntry, CommandArgEntryDefinition, CommandBuilder, CommandDefinition, CommandExample, CommandMeta, CommandSchema, DeriveHandler, DeriveParams, ExampleCommand, ExampleMeta, InteractiveParams, InteractiveResolver, InteractiveResult, Out, command, createCommandSchema, group, resolveExampleCommand } from "./core/schema/command.mjs";
|
|
18
|
-
import { osc8, visibleWidth } from "./core/help/ansi.mjs";
|
|
19
|
-
import { HelpOptions, formatHelp } from "./core/help/index.mjs";
|
|
20
|
-
import { WriteFn } from "./core/output/writer.mjs";
|
|
21
|
-
import { OutputOptions, createOutput } from "./core/output/index.mjs";
|
|
22
|
-
import { PromptEngine, ReadFn, ResolvedMultiselectPromptConfig, ResolvedPromptConfig, ResolvedSelectPromptConfig, createTerminalPrompter, resolvePromptConfig } from "./core/prompt/index.mjs";
|
|
23
|
-
import { RunResult } from "./core/schema/run.mjs";
|
|
24
|
-
import "./core/schema/index.mjs";
|
|
25
|
-
import { ParseOptions, ParseResult, Token, includesBeforeSeparator, parse, stripBeforeSeparator, tokenize } from "./core/parse/index.mjs";
|
|
26
|
-
import { DeprecationWarning, ResolutionProvenanceRecord, ResolveOptions, ResolveResult } from "./core/resolve/contracts.mjs";
|
|
27
|
-
import { resolve } from "./core/resolve/index.mjs";
|
|
28
|
-
import { BeforeParseParams, CLIPlugin, CLIPluginHooks, PluginCommandContext, ResolvedCommandParams, plugin } from "./core/cli/plugin.mjs";
|
|
29
|
-
import { ManifestDiscoveryOptions, PackageJsonAdapter, PackageJsonData, PackageRepository, PackageRepositoryUrlOptions, discoverManifest, inferCliName, packageRepositoryUrl } from "./core/config/package-json.mjs";
|
|
30
|
-
import { HelpLinks } from "./core/cli/help-links.mjs";
|
|
31
|
-
import { CompletionOptions } from "./core/completion/shells/shared.mjs";
|
|
32
|
-
import { generateBashCompletion } from "./core/completion/shells/bash.mjs";
|
|
33
|
-
import { generateFishCompletion } from "./core/completion/shells/fish.mjs";
|
|
34
|
-
import { generatePowerShellCompletion } from "./core/completion/shells/powershell.mjs";
|
|
35
|
-
import { generateZshCompletion } from "./core/completion/shells/zsh.mjs";
|
|
36
|
-
import { SHELLS, Shell, generateCompletion } from "./core/completion/index.mjs";
|
|
37
|
-
import { ConfigAdapter, ConfigDiscoveryOptions, ConfigDiscoveryResult, ConfigFound, ConfigNotFound, FormatLoader, buildConfigSearchPaths, configFormat, discoverConfig } from "./core/config/index.mjs";
|
|
38
|
-
import { CLIBuilder, CLIDefinition, CLIExecuteOptions, CLIOptions, CLIRunOptions, CLISchema, CompletionsFlagConfig, ConfigSettings, ConfigSettingsDefinition, DefaultCommandOptions, HelpConfig, InferNameOption, ManifestSettings, RenderContext, RenderContextOptions, ResolvedManifestSettings, cli, createCLISchema, isMainModule, resolveRenderContext } from "./core/cli/index.mjs";
|
|
39
|
-
import { ArgDefinitionFragmentV1, ArgElementFragmentV1, CommandDefinitionDocument, CommandDefinitionDocumentV1, CommandDefinitionFragmentV1, DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, DefinitionDocument, DefinitionDocumentV1, ExampleDefinitionFragmentV1, FlagDefinitionFragmentV1, FlagNegationFragmentV1, FlagPathChecksFragmentV1, FlagStringConstraintsFragmentV1, InputSchemaBranch, InputSchemaDocument, InputSchemaProperty, JsonSchemaOptions, PromptChoiceFragmentV1, PromptDefinitionFragmentV1, SourceSplitFragmentV1, SplitPolicyFragmentV1, StdinBindingFragmentV1, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema } from "./core/json-schema/index.mjs";
|
|
40
|
-
import { FlagMap, ReadFlagsOptions, readFlags } from "./core/read-flags/index.mjs";
|
|
1
|
+
import { $ as ArgParseFn, $t as WithoutElementEligibility, A as Out, An as PromptResult, At as DefaultValueOptions, B as MiddlewareHandler, Bn as ProgressHandle, Bt as FlagKind, Cn as StandardSchemaV1Types, Ct as SplitOptions, D as InteractiveParams, Dn as PromptConfig, Dt as BooleanFlagDefinition, En as MultiselectPromptConfig, Et as ArrayFlagDefinition, F as InputSources, Fn as HelpDescription, Ft as FlagDefinition, G as ArgConfig, Gn as TableFormat, Gt as InferFlag, H as middleware, Hn as SpinnerHandle, Ht as FlagParseFn, I as ResolutionProvenance, In as HelpTheme, It as FlagDefinitionBase, J as ArgDefinitionBase, Jt as NumberFlagDefinition, K as ArgDefaultValue, Kn as TableOptions, Kt as InferFlags, L as SourcesOf, Ln as HelpThemeFactory, Lt as FlagDefinitionByKind, M as createCommandSchema, Mn as SelectPromptConfig, Mt as EnumFlagDefinition, N as group, Nn as NumberConstraintViolation, Nt as FlagBuilder, O as InteractiveResolver, On as PromptConfigBase, Ot as CountFlagDefinition, P as resolveExampleCommand, Pn as NumberConstraints, Pt as FlagConfig, Q as ArgKind, Qt as WithPresence, R as wasExplicit, Rn as ActivityEvent, Rt as FlagDefinitionOverrides, S as DeriveParams, Sn as StandardSchemaV1SuccessResult, St as SplitFormat, T as ExampleMeta, Tn as InputPromptConfig, Tt as SplitSetting, U as Verbosity, Un as SpinnerOptions, Ut as FlagPresence, V as MiddlewareParams, Vn as ProgressOptions, Vt as FlagNegation, W as ArgBuilder, Wn as TableColumn, Wt as FlagSchema, X as ArgDefinitionOverrides, Xt as StringElementConfig, Y as ArgDefinitionByKind, Yt as ResolvedValue, Z as ArgFactory, Zt as StringFlagDefinition, _ as CommandDefinition, _n as StandardSchemaV1Issue, _t as DUPLICATE_KEYS, a as WriteFn, an as PathFlagOptions, at as InferArg, b as CommandSchema, bn as StandardSchemaV1Props, bt as SourceSplitBinding, c as ResolvedMultiselectPromptConfig, cn as StringConstraints, ct as NumberArgDefinition, d as resolvePromptConfig, dn as StdinOptions, dt as StringArgElementConfig, en as createFlagSchema, et as ArgPresence, f as ActionHandler, fn as StdinWhen, ft as WithArgPresence, g as CommandBuilder, gn as StandardSchemaV1FailureResult, gt as createArgSchema, h as CommandArgEntryDefinition, hn as StandardSchemaV1, ht as arg, i as createOutput, in as PathChecks, it as EnumArgDefinition, j as command, jn as SelectChoice, jt as DuplicatePolicy, k as InteractiveResult, kn as PromptKind, kt as CustomFlagDefinition, l as ResolvedPromptConfig, ln as StdinBinding, lt as ResolvedArgValue, m as CommandArgEntry, mn as InferStandardOutput, mt as WithoutArgElementEligibility, n as OutputOptions, nn as getFlagNegatedName, nt as BooleanArgDefinition, o as PromptEngine, on as UrlFlagOptions, ot as InferArgs, p as ActionParams, pn as InferStandardInput, pt as WithVariadic, q as ArgDefinition, qn as TableStream, qt as KeyValueFlagDefinition, rn as DateFlagOptions, rt as CustomArgDefinition, s as ReadFn, sn as StringConstraintViolation, st as KeyValueArgDefinition, tn as flag, tt as ArgSchema, u as ResolvedSelectPromptConfig, un as StdinConsume, ut as StringArgDefinition, v as CommandExample, vn as StandardSchemaV1Options, vt as DuplicateKeys, w as ExampleCommand, wn as ConfirmPromptConfig, wt as SplitPolicy, x as DeriveHandler, xn as StandardSchemaV1Result, xt as SplitBinding, y as CommandMeta, yn as StandardSchemaV1PathSegment, yt as SPLIT_FORMATS, z as Middleware, zn as Fallback, zt as FlagFactory } from "./index-BziI2aKc.mjs";
|
|
2
|
+
import { A as ErrorCode, B as BuiltinMode, C as includesBeforeSeparator, D as CLIError, E as tokenize, F as ValidationErrorCode, H as Builtins, I as ValidationErrorOptions, L as isCLIError, M as ParseErrorCode, N as ParseErrorOptions, O as CLIErrorJSON, P as ValidationError, R as isParseError, S as Token, T as stripBeforeSeparator, U as BuiltinsConfig, V as BuiltinName, _ as ResolutionProvenanceRecord, b as ParseOptions, c as formatHelp, d as CLIPluginHooks, f as PluginCommandContext, g as DeprecationWarning, h as resolve, j as ParseError, k as CLIErrorOptions, l as BeforeParseParams, m as plugin, n as RunResult, p as ResolvedCommandParams, s as HelpOptions, u as CLIPlugin, v as ResolveOptions, w as parse, x as ParseResult, y as ResolveResult, z as isValidationError } from "./index-DWsnGZlx.mjs";
|
|
3
|
+
import { C as SHELLS, S as HelpLinks, T as CompletionOptions, _ as ResolvedManifestSettings, a as CLIRunOptions, b as isMainModule, c as CompletionsFlagConfig, d as DefaultCommandOptions, f as HelpConfig, g as RenderContextOptions, h as RenderContext, i as CLIOptions, l as ConfigSettings, m as ManifestSettings, n as CLIDefinition, o as CLISchema, p as InferNameOption, r as CLIExecuteOptions, s as CompletionRegistrationOptions, t as CLIBuilder, u as ConfigSettingsDefinition, v as cli, w as Shell, x as resolveRenderContext, y as createCLISchema } from "./index-DXROeDPC.mjs";
|
|
4
|
+
import { n as RuntimeAdapter } from "./adapter-D0hbBNVB.mjs";
|
|
5
|
+
import { a as ConfigNotFound, d as PackageRepositoryUrlOptions, g as PackageRepository, h as PackageJsonData, i as ConfigFound, m as PackageJsonAdapter, n as ConfigDiscoveryOptions, o as ConfigSearchPathOptions, p as ManifestDiscoveryOptions, r as ConfigDiscoveryResult, s as FormatLoader, t as ConfigAdapter } from "./index-DOfClfYR.mjs";
|
|
6
|
+
import { D as DEFINITION_SCHEMA_URL, O as DEFINITION_SCHEMA_VERSION, S as StdinBindingFragmentV1, _ as JsonSchemaOptions, a as CommandDefinitionFragmentV1, b as SourceSplitFragmentV1, c as ExampleDefinitionFragmentV1, d as FlagNegationFragmentV1, f as FlagPathChecksFragmentV1, g as InputSchemaProperty, h as InputSchemaDocument, i as CommandDefinitionDocumentV1, l as FlagDefinitionFragmentV1, m as InputSchemaBranch, n as ArgElementFragmentV1, o as DefinitionDocument, p as FlagStringConstraintsFragmentV1, r as CommandDefinitionDocument, s as DefinitionDocumentV1, t as ArgDefinitionFragmentV1, u as FlagElementFragmentV1, v as PromptChoiceFragmentV1, x as SplitPolicyFragmentV1, y as PromptDefinitionFragmentV1 } from "./index-DyoaS234.mjs";
|
|
41
7
|
import { Colors } from "ansispeck";
|
|
42
|
-
|
|
8
|
+
//#region src/core/help/ansi.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Measure the visible column width of `text`, ignoring ANSI/OSC escapes.
|
|
11
|
+
*
|
|
12
|
+
* Escape sequences (SGR colors, OSC 8 hyperlinks) occupy zero columns when
|
|
13
|
+
* rendered, so `.length` overcounts whenever they are present. Help
|
|
14
|
+
* formatting uses this for padding and wrapping; exported for custom help
|
|
15
|
+
* renderers that mix colors or links into aligned output.
|
|
16
|
+
*
|
|
17
|
+
* @param text - Text possibly containing terminal escapes.
|
|
18
|
+
* @returns Number of visible characters.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* visibleWidth('plain'); // 5
|
|
23
|
+
* visibleWidth(osc8('https://x.dev', 'x')); // 1
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function visibleWidth(text: string): number;
|
|
27
|
+
/**
|
|
28
|
+
* Wrap `text` in an [OSC 8 hyperlink](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
|
|
29
|
+
* pointing at `url`.
|
|
30
|
+
*
|
|
31
|
+
* Supporting terminals render `text` as a clickable link; others show it
|
|
32
|
+
* plain. `text` defaults to the URL, so an omitted label degrades to a
|
|
33
|
+
* usable address. The framework's help layer decides *whether* to link
|
|
34
|
+
* (`help.hyperlinks`); this always emits when called.
|
|
35
|
+
*
|
|
36
|
+
* @param url - Link target (string or `URL` instance).
|
|
37
|
+
* @param text - Visible link text.
|
|
38
|
+
* @returns The OSC 8 escape sequence wrapping `text`.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* cli('mycli').version(osc8('https://github.com/me/mycli/releases/tag/v1.0.0', '1.0.0'));
|
|
43
|
+
* osc8('https://dreamcli.kjanat.dev'); // linked, displayed as the URL
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function osc8(url: string | URL, text?: string): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/core/read-flags/index.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* A record of flag definitions keyed by canonical flag name.
|
|
51
|
+
*
|
|
52
|
+
* The object key is the `--name` spelling and the key on the resolved record.
|
|
53
|
+
*/
|
|
54
|
+
type FlagMap = Readonly<Record<string, FlagBuilder<FlagConfig>>>;
|
|
55
|
+
/**
|
|
56
|
+
* External state and behavior toggles accepted by {@linkcode readFlags}.
|
|
57
|
+
*
|
|
58
|
+
* Extends {@linkcode ResolveOptions}, so `env`, `config`, `prompter`, `stat`,
|
|
59
|
+
* and `mkdir` carry the meaning they have during command resolution.
|
|
60
|
+
*/
|
|
61
|
+
interface ReadFlagsOptions<F extends FlagMap = FlagMap> extends ResolveOptions {
|
|
62
|
+
/**
|
|
63
|
+
* User arguments only, without the binary and script entries.
|
|
64
|
+
* @defaultValue the runtime adapter's argv past its binary and script entries
|
|
65
|
+
*/
|
|
66
|
+
readonly argv?: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* Runtime source for argv, environment, and filesystem primitives.
|
|
69
|
+
* @defaultValue {@linkcode createAdapter | createAdapter()}, built on the
|
|
70
|
+
* first fact the caller left out
|
|
71
|
+
*/
|
|
72
|
+
readonly adapter?: RuntimeAdapter;
|
|
73
|
+
/**
|
|
74
|
+
* Parser behavior such as kebab/camel case parity.
|
|
75
|
+
* @defaultValue `undefined`, which keeps the parser defaults
|
|
76
|
+
*/
|
|
77
|
+
readonly parse?: ParseOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Reject argv content the definitions do not declare.
|
|
80
|
+
*
|
|
81
|
+
* `false` drops undeclared input from argv before parsing: unknown long
|
|
82
|
+
* flags together with their inline `=value`, unknown characters inside a
|
|
83
|
+
* short group, positional arguments, and the `--` separator, which can only
|
|
84
|
+
* introduce positionals here. A value token of a declared flag is kept by
|
|
85
|
+
* walking the same consumption rules the parser applies. Misuse of a
|
|
86
|
+
* declared flag still fails: a missing value, a bad coercion, or a violated
|
|
87
|
+
* duplicate policy throws in either mode.
|
|
88
|
+
* @defaultValue `true`
|
|
89
|
+
*/
|
|
90
|
+
readonly strict?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The built-in `--help`/`-h` handling.
|
|
93
|
+
*
|
|
94
|
+
* While `'on'`, a pre-separator `--help` or `-h` prints generated help for
|
|
95
|
+
* the definitions to the adapter's stdout and exits the process with
|
|
96
|
+
* code 0. The built-in yields automatically when any definition claims the
|
|
97
|
+
* `help` or `h` spelling through its name, an alias, a negated form, or a
|
|
98
|
+
* case-parity counterpart; those spellings then parse as the definition's
|
|
99
|
+
* own. `'off'` removes the built-in, and the spellings parse like any other
|
|
100
|
+
* token.
|
|
101
|
+
* @defaultValue `'on'`
|
|
102
|
+
*/
|
|
103
|
+
readonly help?: 'on' | 'off';
|
|
104
|
+
/**
|
|
105
|
+
* Receiver for notices produced by `.deprecated()` flags.
|
|
106
|
+
* @defaultValue `undefined`, which drops the notices
|
|
107
|
+
*/
|
|
108
|
+
readonly onDeprecation?: (warning: DeprecationWarning) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Receiver for the provenance of the resolved values, keyed by flag name.
|
|
111
|
+
*
|
|
112
|
+
* Called once with the whole record, before {@linkcode readFlags} returns the
|
|
113
|
+
* values. A flag that resolved no value has no record, so the same reader
|
|
114
|
+
* works for optional flags.
|
|
115
|
+
* @defaultValue `undefined`, which drops the record
|
|
116
|
+
*/
|
|
117
|
+
readonly onSources?: (sources: SourcesOf<F>) => void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Evaluate a record of flag definitions and return the resolved values.
|
|
121
|
+
*
|
|
122
|
+
* The record is compiled into an anonymous command schema with no positional
|
|
123
|
+
* arguments, parsed once, and run through the CLI, env, config, prompt, default
|
|
124
|
+
* resolution chain. Aliases, negated spellings, duplicate policy, case parity,
|
|
125
|
+
* unknown-flag rejection, coercion, constraints, Standard Schema validators, and
|
|
126
|
+
* `flag.path()` checks behave exactly as they do inside a command.
|
|
127
|
+
*
|
|
128
|
+
* A pre-separator `--help` or `-h` prints generated help to the adapter's
|
|
129
|
+
* stdout and exits with code 0, unless {@linkcode ReadFlagsOptions.help} is
|
|
130
|
+
* `'off'` or a definition claims either spelling. With
|
|
131
|
+
* {@linkcode ReadFlagsOptions.strict} set to `false`, undeclared argv content
|
|
132
|
+
* is dropped instead of rejected, so a script can read its own flags out of an
|
|
133
|
+
* argv it shares with another consumer.
|
|
134
|
+
*
|
|
135
|
+
* Anything the caller leaves out comes from the runtime adapter, which is built
|
|
136
|
+
* on first use, so a call given `argv` and `env` reads nothing from the host
|
|
137
|
+
* unless a `flag.path()` check needs the adapter's filesystem primitives.
|
|
138
|
+
* `config` has no application name to discover a file from and stays
|
|
139
|
+
* caller-supplied. `prompter` stays caller-supplied as well, so a `.prompt()`
|
|
140
|
+
* flag with no prompter falls through to its default.
|
|
141
|
+
*
|
|
142
|
+
* @param definitions - Flag builders keyed by canonical flag name.
|
|
143
|
+
* @param options - Injected runtime state and behavior toggles.
|
|
144
|
+
* @returns The resolved flag values, typed from the definitions.
|
|
145
|
+
* @throws {ParseError} For unknown flags, missing values, and bad input.
|
|
146
|
+
* @throws {ValidationError} For missing required flags and failed validators.
|
|
147
|
+
* @throws {CLIError} With code `'FLAG_NAME_COLLISION'` when two definitions share
|
|
148
|
+
* a name, an alias, or a negated spelling.
|
|
149
|
+
* @throws {CLIError} With code `'INVALID_SCHEMA'` for the definition key
|
|
150
|
+
* `__proto__`, which JavaScript cannot carry as a plain record key, and for a
|
|
151
|
+
* definitions record whose prototype is replaced, which hides the entries a
|
|
152
|
+
* key check would read.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { flag, readFlags } from '@kjanat/dreamcli';
|
|
157
|
+
*
|
|
158
|
+
* const options = await readFlags({
|
|
159
|
+
* watch: flag.boolean().alias('w').env('WATCH').default(false),
|
|
160
|
+
* minify: flag.boolean().env('MINIFY').default(true),
|
|
161
|
+
* target: flag.enum(['node', 'browser']).env('TARGET').default('node'),
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* options.watch; // boolean
|
|
165
|
+
* options.minify; // boolean
|
|
166
|
+
* options.target; // 'node' | 'browser'
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const values = await readFlags(
|
|
172
|
+
* { watch: flag.boolean().alias('w').env('WATCH') },
|
|
173
|
+
* { argv: [], env: { WATCH: 'true' } },
|
|
174
|
+
* );
|
|
175
|
+
*
|
|
176
|
+
* values.watch; // true
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* const values = await readFlags(
|
|
182
|
+
* { watch: flag.boolean() },
|
|
183
|
+
* { argv: ['build', '--watch', '--unknown'], env: {}, strict: false },
|
|
184
|
+
* );
|
|
185
|
+
*
|
|
186
|
+
* values.watch; // true, with 'build' and '--unknown' dropped
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function readFlags<const F extends FlagMap>(definitions: F, options?: ReadFlagsOptions<F>): Promise<InferFlags<F>>;
|
|
190
|
+
//#endregion
|
|
191
|
+
export { type ActionHandler, type ActionParams, type ActivityEvent, ArgBuilder, type ArgConfig, type ArgDefaultValue, type ArgDefinition, type ArgDefinitionBase, type ArgDefinitionByKind, type ArgDefinitionFragmentV1, type ArgDefinitionOverrides, type ArgElementFragmentV1, type ArgFactory, type ArgKind, type ArgParseFn, type ArgPresence, type ArgSchema, type ArrayFlagDefinition, type BeforeParseParams, type BooleanArgDefinition, type BooleanFlagDefinition, type BuiltinMode, type BuiltinName, type Builtins, type BuiltinsConfig, CLIBuilder, type CLIDefinition, CLIError, type CLIErrorJSON, type CLIErrorOptions, type CLIExecuteOptions, type CLIOptions, type CLIPlugin, type CLIPluginHooks, type CLIRunOptions, type CLISchema, type Colors, type CommandArgEntry, type CommandArgEntryDefinition, CommandBuilder, type CommandDefinition, type CommandDefinitionDocument, type CommandDefinitionDocumentV1, type CommandDefinitionFragmentV1, type CommandExample, type CommandMeta, type CommandSchema, type CompletionOptions, type CompletionRegistrationOptions, type CompletionsFlagConfig, type ConfigAdapter, type ConfigDiscoveryOptions, type ConfigDiscoveryResult, type ConfigFound, type ConfigNotFound, type ConfigSearchPathOptions, type ConfigSettings, type ConfigSettingsDefinition, type ConfirmPromptConfig, type CountFlagDefinition, type CustomArgDefinition, type CustomFlagDefinition, DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, DUPLICATE_KEYS, type DateFlagOptions, type DefaultCommandOptions, type DefaultValueOptions, type DefinitionDocument, type DefinitionDocumentV1, type DeprecationWarning, type DeriveHandler, type DeriveParams, type DuplicateKeys, type DuplicatePolicy, type EnumArgDefinition, type EnumFlagDefinition, type ErrorCode, type ExampleCommand, type ExampleDefinitionFragmentV1, type ExampleMeta, type Fallback, FlagBuilder, type FlagConfig, type FlagDefinition, type FlagDefinitionBase, type FlagDefinitionByKind, type FlagDefinitionFragmentV1, type FlagDefinitionOverrides, type FlagElementFragmentV1, type FlagFactory, type FlagKind, type FlagMap, type FlagNegation, type FlagNegationFragmentV1, type FlagParseFn, type FlagPathChecksFragmentV1, type FlagPresence, type FlagSchema, type FlagStringConstraintsFragmentV1, type FormatLoader, type HelpConfig, type HelpDescription, type HelpLinks, type HelpOptions, type HelpTheme, type HelpThemeFactory, type InferArg, type InferArgs, type InferFlag, type InferFlags, type InferNameOption, type InferStandardInput, type InferStandardOutput, type InputPromptConfig, type InputSchemaBranch, type InputSchemaDocument, type InputSchemaProperty, type InputSources, type InteractiveParams, type InteractiveResolver, type InteractiveResult, type JsonSchemaOptions, type KeyValueArgDefinition, type KeyValueFlagDefinition, type ManifestDiscoveryOptions, type ManifestSettings, type Middleware, type MiddlewareHandler, type MiddlewareParams, type MultiselectPromptConfig, type NumberArgDefinition, type NumberConstraintViolation, type NumberConstraints, type NumberFlagDefinition, type Out, type OutputOptions, type PackageJsonAdapter, type PackageJsonData, type PackageRepository, type PackageRepositoryUrlOptions, ParseError, type ParseErrorCode, type ParseErrorOptions, type ParseOptions, type ParseResult, type PathChecks, type PathFlagOptions, type PluginCommandContext, type ProgressHandle, type ProgressOptions, type PromptChoiceFragmentV1, type PromptConfig, type PromptConfigBase, type PromptDefinitionFragmentV1, type PromptEngine, type PromptKind, type PromptResult, type ReadFlagsOptions, type ReadFn, type RenderContext, type RenderContextOptions, type ResolutionProvenance, type ResolutionProvenanceRecord, type ResolveOptions, type ResolveResult, type ResolvedArgValue, type ResolvedCommandParams, type ResolvedManifestSettings, type ResolvedMultiselectPromptConfig, type ResolvedPromptConfig, type ResolvedSelectPromptConfig, type ResolvedValue, type RunResult, SHELLS, SPLIT_FORMATS, type SelectChoice, type SelectPromptConfig, type Shell, type SourceSplitBinding, type SourceSplitFragmentV1, type SourcesOf, type SpinnerHandle, type SpinnerOptions, type SplitBinding, type SplitFormat, type SplitOptions, type SplitPolicy, type SplitPolicyFragmentV1, type SplitSetting, type StandardSchemaV1, type StandardSchemaV1FailureResult, type StandardSchemaV1Issue, type StandardSchemaV1Options, type StandardSchemaV1PathSegment, type StandardSchemaV1Props, type StandardSchemaV1Result, type StandardSchemaV1SuccessResult, type StandardSchemaV1Types, type StdinBinding, type StdinBindingFragmentV1, type StdinConsume, type StdinOptions, type StdinWhen, type StringArgDefinition, type StringArgElementConfig, type StringConstraintViolation, type StringConstraints, type StringElementConfig, type StringFlagDefinition, type TableColumn, type TableFormat, type TableOptions, type TableStream, type Token, type UrlFlagOptions, ValidationError, type ValidationErrorCode, type ValidationErrorOptions, type Verbosity, type WithArgPresence, type WithPresence, type WithVariadic, type WithoutArgElementEligibility, type WithoutElementEligibility, type WriteFn, arg, cli, command, createArgSchema, createCLISchema, createCommandSchema, createFlagSchema, createOutput, flag, formatHelp, getFlagNegatedName, group, includesBeforeSeparator, isCLIError, isMainModule, isParseError, isValidationError, middleware, osc8, parse, plugin, readFlags, resolve, resolveExampleCommand, resolvePromptConfig, resolveRenderContext, stripBeforeSeparator, tokenize, visibleWidth, wasExplicit };
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DUPLICATE_KEYS, SPLIT_FORMATS } from "./core/schema/cardinality.mjs";
|
|
3
|
-
import { FlagBuilder, createFlagSchema, flag, getFlagNegatedName } from "./core/schema/flag.mjs";
|
|
4
|
-
import { ArgBuilder, arg, createArgSchema } from "./core/schema/arg.mjs";
|
|
5
|
-
import { CommandBuilder, command, createCommandSchema, group, resolveExampleCommand } from "./core/schema/command.mjs";
|
|
6
|
-
import { middleware } from "./core/schema/middleware.mjs";
|
|
7
|
-
import { wasExplicit } from "./core/schema/provenance.mjs";
|
|
8
|
-
import "./core/schema/index.mjs";
|
|
9
|
-
import { includesBeforeSeparator, parse, stripBeforeSeparator, tokenize } from "./core/parse/index.mjs";
|
|
10
|
-
import { generateBashCompletion } from "./core/completion/shells/bash.mjs";
|
|
11
|
-
import { generateFishCompletion } from "./core/completion/shells/fish.mjs";
|
|
12
|
-
import { generatePowerShellCompletion } from "./core/completion/shells/powershell.mjs";
|
|
13
|
-
import { generateZshCompletion } from "./core/completion/shells/zsh.mjs";
|
|
14
|
-
import { SHELLS, generateCompletion } from "./core/completion/index.mjs";
|
|
15
|
-
import { osc8, visibleWidth } from "./core/help/ansi.mjs";
|
|
16
|
-
import { formatHelp } from "./core/help/index.mjs";
|
|
17
|
-
import { DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema } from "./core/json-schema/index.mjs";
|
|
18
|
-
import { createOutput } from "./core/output/index.mjs";
|
|
19
|
-
import { createTerminalPrompter, resolvePromptConfig } from "./core/prompt/index.mjs";
|
|
20
|
-
import { resolve } from "./core/resolve/index.mjs";
|
|
21
|
-
import { discoverManifest, inferCliName, packageRepositoryUrl } from "./core/config/package-json.mjs";
|
|
22
|
-
import { plugin } from "./core/cli/plugin.mjs";
|
|
23
|
-
import { buildConfigSearchPaths, configFormat, discoverConfig } from "./core/config/index.mjs";
|
|
24
|
-
import { CLIBuilder, cli, createCLISchema, isMainModule, resolveRenderContext } from "./core/cli/index.mjs";
|
|
25
|
-
import { readFlags } from "./core/read-flags/index.mjs";
|
|
26
|
-
export { ArgBuilder, CLIBuilder, CLIError, CommandBuilder, DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, DUPLICATE_KEYS, FlagBuilder, ParseError, SHELLS, SPLIT_FORMATS, ValidationError, arg, buildConfigSearchPaths, cli, command, configFormat, createArgSchema, createCLISchema, createCommandSchema, createFlagSchema, createOutput, createTerminalPrompter, definitionMetaSchema, discoverConfig, discoverManifest, flag, formatHelp, generateBashCompletion, generateCommandSchema, generateCompletion, generateFishCompletion, generateInputSchema, generatePowerShellCompletion, generateSchema, generateZshCompletion, getFlagNegatedName, group, includesBeforeSeparator, inferCliName, isCLIError, isMainModule, isParseError, isValidationError, middleware, osc8, packageRepositoryUrl, parse, plugin, readFlags, resolve, resolveExampleCommand, resolvePromptConfig, resolveRenderContext, stripBeforeSeparator, tokenize, visibleWidth, wasExplicit };
|
|
1
|
+
import{$ as ParseError,B as resolveExampleCommand,D as tokenize,E as stripBeforeSeparator,F as visibleWidth,G as getFlagNegatedName,H as createFlagSchema,I as CommandBuilder,J as createArgSchema,K as ArgBuilder,L as command,M as formatHelp,O as wasExplicit,P as osc8,Q as CLIError,R as createCommandSchema,S as resolvePromptConfig,T as parse,U as flag,V as FlagBuilder,X as SPLIT_FORMATS,Y as DUPLICATE_KEYS,a as DEFINITION_SCHEMA_URL,c as cli,d as resolveRenderContext,et as ValidationError,i as readFlags,it as SHELLS,j as createOutput,k as middleware,l as createCLISchema,nt as isParseError,o as DEFINITION_SCHEMA_VERSION,p as plugin,q as arg,rt as isValidationError,s as CLIBuilder,tt as isCLIError,u as isMainModule,w as includesBeforeSeparator,x as resolve,z as group}from"./core-Cp2w8vRq.mjs";export{ArgBuilder,CLIBuilder,CLIError,CommandBuilder,DEFINITION_SCHEMA_URL,DEFINITION_SCHEMA_VERSION,DUPLICATE_KEYS,FlagBuilder,ParseError,SHELLS,SPLIT_FORMATS,ValidationError,arg,cli,command,createArgSchema,createCLISchema,createCommandSchema,createFlagSchema,createOutput,flag,formatHelp,getFlagNegatedName,group,includesBeforeSeparator,isCLIError,isMainModule,isParseError,isValidationError,middleware,osc8,parse,plugin,readFlags,resolve,resolveExampleCommand,resolvePromptConfig,resolveRenderContext,stripBeforeSeparator,tokenize,visibleWidth,wasExplicit};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import{t as __exportAll}from"./rolldown-runtime-G4Kt5YOX.mjs";import{B as resolveExampleCommand,N as resolvePlainHelpDescription,W as getFlagAliasNames,Y as DUPLICATE_KEYS,a as DEFINITION_SCHEMA_URL}from"./core-Cp2w8vRq.mjs";const definitionMetaSchemaDescriptions={root:{description:`Runtime descriptor for the CLI program.
|
|
2
|
+
|
|
3
|
+
Stores the program name, version, description, and registered command schemas.\\
|
|
4
|
+
Sealed by createCLISchema and rebuilt by each CLIBuilder step.`,properties:{name:{description:`Program name (used in help text, usage lines, and completion scripts).`},version:{description:"Program version (shown by `--version`)."},description:{description:`Program description (shown in root help).`},defaultCommand:{description:`Schema of the default command dispatched when no subcommand matches.
|
|
5
|
+
|
|
6
|
+
When set, the CLI root behaves like a hybrid command group: subcommands
|
|
7
|
+
dispatch by name as usual, but empty argv or flags-only argv falls
|
|
8
|
+
through to this command instead of showing root help.
|
|
9
|
+
|
|
10
|
+
Set via the .default() builder method
|
|
11
|
+
or the \`defaultCommand\` field of CLIDefinition.`},commands:{description:`Schemas of the registered commands, in registration order.`}}},defs:{command:{description:`Runtime descriptor produced by CommandBuilder.
|
|
12
|
+
|
|
13
|
+
Consumers (parser, help generator, CLI dispatcher) read this to
|
|
14
|
+
understand the command's shape — flags, args, aliases, subcommands,
|
|
15
|
+
and interactive resolver.`,properties:{name:{description:"The command name (used for dispatch, e.g. `'deploy'`)."},description:{description:`Human-readable description for help text.`},aliases:{description:`Alternative names for this command.`},hidden:{description:`Whether this command is hidden from help listings.`},examples:{description:`Usage examples for help text.`},flags:{description:`Named flag schemas, keyed by flag name.`},args:{description:`Ordered positional arg entries (name + schema).`},commands:{description:"Nested subcommand schemas (for help rendering and completion).\n\nPure data — no execution closures. Populated by `.command()` on\n`CommandBuilder`. Empty for leaf commands."}}},commandDocument:{description:`A single-command definition document, version 1.
|
|
16
|
+
|
|
17
|
+
Produced by generateCommandSchema. Same shape as a
|
|
18
|
+
CommandDefinitionFragmentV1 plus the \`schemaVersion\` every standalone
|
|
19
|
+
document carries.`,properties:{schemaVersion:{description:"Version of the definition document format emitted by `generateSchema()`\nand `generateCommandSchema()` from `@kjanat/dreamcli/json-schema`."},name:{description:`The command name used for dispatch.`},description:{description:`Human-readable description for help text.`},aliases:{description:`Alternative names accepted for this command.`},hidden:{description:`Whether the command is omitted from help listings.`},examples:{description:`Usage examples attached to the command.`},flags:{description:`Named flag definitions keyed by flag name.`},args:{description:`Positional argument definitions in CLI order.`},commands:{description:`Nested subcommand definitions.`}}},flag:{description:`The runtime descriptor stored inside every FlagBuilder. Consumers (parser,
|
|
20
|
+
help generator, resolution chain) read this to understand the flag's shape
|
|
21
|
+
without touching generics.`,properties:{kind:{description:`What kind of value this flag accepts.`},presence:{description:"Presence describes whether a flag value is guaranteed to exist when the\naction handler runs:\n\n- `'optional'` — not required; unresolved value follows the kind-specific\n optional fallback (`undefined` for most flags, `[]` for arrays)\n- `'required'` — must be supplied; error if missing\n- `'defaulted'` — always present (falls back to default value)"},defaultValue:{description:`Runtime default value (if any).`},aliases:{description:"Short/long aliases (e.g. `[{ name: 'f', hidden: false }]` for `--force`)."},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the flag never reads\nstdin). See StdinBinding."},envVar:{description:`Environment variable name for v0.2+ resolution.`},configPath:{description:"Dotted config path for v0.2+ resolution (e.g. `'deploy.region'`)."},description:{description:`Human-readable description for help text.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`."},prompt:{description:`Interactive prompt configuration for v0.3+ resolution.`},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated flag is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."},propagate:{description:`Whether this flag propagates to subcommands in nested command trees.
|
|
22
|
+
|
|
23
|
+
When \`true\`, the flag is automatically available to all descendant
|
|
24
|
+
commands. A child command that defines a flag with the same name
|
|
25
|
+
shadows the propagated parent flag.
|
|
26
|
+
|
|
27
|
+
Default: \`false\``},negation:{description:"Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation."},duplicates:{description:"How repeated CLI occurrences of a singleton flag combine.\n\n- `'last'` — last occurrence wins (matches historic behavior)\n- `'first'` — first occurrence wins; later ones parse but are ignored\n- `'error'` — a second occurrence is a `ParseError` (`DUPLICATE_FLAG`)\n\nApplies to CLI token occurrences only — env/config/prompt/default\nresolution keeps its precedence semantics and never raises duplicates.\nOccurrences are counted per *logical* flag: aliases and the negated\nspelling all count toward the same flag.\n\nDefault: `'last'`"},defaultDescription:{description:"Human-readable replacement for the default value in help, or `false` to\nomit the default annotation."},sensitive:{description:`Whether values from this input must be kept out of user-facing projections.`}}},flagElement:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`.",properties:{kind:{description:`What kind of value this flag accepts.`},presence:{description:"Presence describes whether a flag value is guaranteed to exist when the\naction handler runs:\n\n- `'optional'` — not required; unresolved value follows the kind-specific\n optional fallback (`undefined` for most flags, `[]` for arrays)\n- `'required'` — must be supplied; error if missing\n- `'defaulted'` — always present (falls back to default value)"},defaultValue:{description:`Runtime default value (if any).`},aliases:{description:"Short/long aliases (e.g. `[{ name: 'f', hidden: false }]` for `--force`)."},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the flag never reads\nstdin). See StdinBinding."},envVar:{description:`Environment variable name for v0.2+ resolution.`},configPath:{description:"Dotted config path for v0.2+ resolution (e.g. `'deploy.region'`)."},description:{description:`Human-readable description for help text.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'array'` or `kind === 'keyValue'`."},prompt:{description:`Interactive prompt configuration for v0.3+ resolution.`},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated flag is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."},propagate:{description:`Whether this flag propagates to subcommands in nested command trees.
|
|
28
|
+
|
|
29
|
+
When \`true\`, the flag is automatically available to all descendant
|
|
30
|
+
commands. A child command that defines a flag with the same name
|
|
31
|
+
shadows the propagated parent flag.
|
|
32
|
+
|
|
33
|
+
Default: \`false\``},negation:{description:"Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation."},duplicates:{description:"How repeated CLI occurrences of a singleton flag combine.\n\n- `'last'` — last occurrence wins (matches historic behavior)\n- `'first'` — first occurrence wins; later ones parse but are ignored\n- `'error'` — a second occurrence is a `ParseError` (`DUPLICATE_FLAG`)\n\nApplies to CLI token occurrences only — env/config/prompt/default\nresolution keeps its precedence semantics and never raises duplicates.\nOccurrences are counted per *logical* flag: aliases and the negated\nspelling all count toward the same flag.\n\nDefault: `'last'`"}}},stdin:{description:`The normalized stdin axis of a flag or an arg.`,properties:{when:{description:`When this input reads the stdin stream.`},consume:{description:`Whether this input consumes the stream alone.`},trim:{description:`Whether one trailing line terminator is dropped from a single value.`}}},negation:{description:`Negation settings for a boolean flag (set by \`.negatable()\`).
|
|
34
|
+
|
|
35
|
+
The negated spelling and the positive form are two spellings of ONE
|
|
36
|
+
logical flag: they share duplicate policy, and the last CLI occurrence
|
|
37
|
+
wins across both. The negated spelling is presence-only — \`--no-foo=x\`
|
|
38
|
+
is rejected.`,properties:{alias:{description:"Explicit negated spelling without the `--` prefix (e.g. `'no-sandbox'`).\n`undefined` synthesizes `no-<flagName>` wherever the flag name is known."},hidden:{description:`Hide the negated spelling from help, completions, and suggestions.`}}},arg:{description:`The runtime descriptor stored inside every ArgBuilder. Consumers (parser,
|
|
39
|
+
help generator) read this to understand the arg's shape without touching
|
|
40
|
+
generics.`,properties:{name:{description:`A named positional argument entry in the command schema.
|
|
41
|
+
|
|
42
|
+
Pairs a user-facing arg name with its ArgSchema descriptor.
|
|
43
|
+
The array ordering in CommandSchema.args determines CLI position.`},kind:{description:`What kind of value this arg accepts.`},presence:{description:"Presence describes whether a positional arg is guaranteed to exist when the\naction handler runs:\n\n- `'required'` — must be supplied; error if missing (default)\n- `'optional'` — may be `undefined` if not supplied\n- `'defaulted'` — always present (falls back to default value)"},variadic:{description:`Whether this arg consumes all remaining positionals.`},stdin:{description:"Stdin binding set by `.stdin()` (`undefined` when the arg never reads\nstdin). See StdinBinding."},defaultValue:{description:`Runtime default value (if any).`},defaultDescription:{description:"Human-readable replacement for the default value in help, or `false` to\nomit the default annotation."},sensitive:{description:`Whether values from this input must be kept out of user-facing projections.`},description:{description:`Human-readable description for help text.`},envVar:{description:`Environment variable name for env resolution.
|
|
44
|
+
|
|
45
|
+
When set and the CLI value is absent, the resolver reads this env var
|
|
46
|
+
and coerces the string to the arg's declared kind.`},configPath:{description:"Dotted config path for config resolution (e.g. `'deploy.region'`)."},prompt:{description:`Interactive prompt configuration.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."},elementSchema:{description:"Element schema when `kind === 'keyValue'`.\n\nDescribes the value of each entry, so `arg.keyValue(arg.number())` decodes\n`A=1` to the number `1`. `undefined` leaves entry values as strings."},deprecated:{description:"Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated arg is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`."}}},argElement:{description:"Element schema when `kind === 'keyValue'`.\n\nDescribes the value of each entry, so `arg.keyValue(arg.number())` decodes\n`A=1` to the number `1`. `undefined` leaves entry values as strings.",properties:{kind:{description:`What kind of value this arg accepts.`},presence:{description:`Entry values are required once their containing key-value argument is present.`},enumValues:{description:"Allowed literal values when `kind === 'enum'`."}}},prompt:{description:"Discriminated union of all prompt configurations.\n\nUse the `kind` field to narrow:\n```ts\nif (config.kind === 'select') {\n config.choices // readonly SelectChoice[] | undefined\n}\n```",properties:{kind:{description:"The kind of interactive prompt to present.\n\n- `'confirm'` — yes/no boolean question\n- `'input'` — free-text string input\n- `'select'` — single selection from a list\n- `'multiselect'` — multiple selections from a list"},message:{description:`The question displayed to the user.`},placeholder:{description:`Placeholder text shown before user types (informational only).`},choices:{description:"Available choices. When omitted for `enum` flags, the enum values\nfrom the flag schema are used automatically."},min:{description:`Minimum number of selections required.
|
|
47
|
+
|
|
48
|
+
Default: \`0\``},max:{description:`Maximum number of selections allowed.
|
|
49
|
+
|
|
50
|
+
Default: \`Infinity\``}}},choice:{description:`A selectable option for SelectPromptConfig and MultiselectPromptConfig prompts.`,properties:{value:{description:`The value returned when this choice is selected.`},label:{description:`Display label shown to the user.
|
|
51
|
+
|
|
52
|
+
Default: value`},description:{description:`Optional description shown alongside the choice.`}}},example:{description:`A single usage example shown in help text.`,properties:{command:{description:"The command invocation (e.g. `'deploy production --force'`)."},description:{description:`Optional description of what this example does.`}}}}};var json_schema_exports=__exportAll({DEFINITION_SCHEMA_URL:()=>DEFINITION_SCHEMA_URL,DEFINITION_SCHEMA_VERSION:()=>1,definitionMetaSchema:()=>definitionMetaSchema,generateCommandSchema:()=>generateCommandSchema,generateInputSchema:()=>generateInputSchema,generateSchema:()=>generateSchema});function resolveOptions(e){return{includeHidden:e?.includeHidden??!0,includePrompts:e?.includePrompts??!0}}const JSON_SCHEMA_DRAFT=`https://json-schema.org/draft/2020-12/schema`;function generateSchema(e,t,n){let r=resolveOptions(t),i=n??{name:e.name,version:e.version},a=e.defaultCommand!==void 0&&(r.includeHidden||!e.defaultCommand.hidden)?serializeCommand(e.defaultCommand,r,i):void 0;return{$schema:DEFINITION_SCHEMA_URL,schemaVersion:1,name:e.name,...e.version===void 0?{}:{version:e.version},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...a===void 0?{}:{defaultCommand:a},commands:e.commands.filter(e=>r.includeHidden||!e.hidden).map(e=>serializeCommand(e,r,i))}}function generateCommandSchema(e,t,n){let r=n??{name:e.name,version:void 0};return{schemaVersion:1,...serializeCommand(e,resolveOptions(t),r)}}function serializeCommand(e,t,n){let r={};for(let[n,i]of Object.entries(e.flags))r[n]=serializeFlag(i,t);return{name:e.name,...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.aliases.length>0?{aliases:[...e.aliases]}:{},...e.hidden?{hidden:!0}:{},...e.examples.length>0?{examples:e.examples.map(e=>serializeExample(e,n))}:{},flags:r,args:e.args.map(e=>serializeArgEntry(e,t)),commands:e.commands.filter(e=>t.includeHidden||!e.hidden).map(e=>serializeCommand(e,t,n))}}function serializeFlag(e,t,n=!1){let r=getFlagAliasNames(e),i=e.stringConstraints,a=e.pathChecks,o=e.negation,s=n||e.sensitive;return{kind:e.kind,presence:e.presence,...!s&&isJsonSerializable(e.defaultValue)?{defaultValue:e.defaultValue}:{},...e.defaultDescription===void 0?{}:{defaultDescription:e.defaultDescription},...e.sensitive?{sensitive:!0}:{},...r.length>0?{aliases:[...r]}:{},...e.stdin===void 0?{}:{stdin:serializeStdin(e.stdin)},...e.envVar===void 0?{}:{envVar:e.envVar},...e.configPath===void 0?{}:{configPath:e.configPath},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...i===void 0?{}:{stringConstraints:serializeStringConstraints(i)},...e.elementSchema===void 0?{}:{elementSchema:serializeFlag(e.elementSchema,t,s)},...e.separator===void 0?{}:{separator:e.separator},...e.split===void 0?{}:{split:serializeSplit(e.split)},...e.duplicateKeys===`last`?{}:{duplicateKeys:e.duplicateKeys},...e.unique?{unique:!0}:{},...a===void 0?{}:{pathChecks:serializePathChecks(a)},...e.valueHint===void 0?{}:{valueHint:e.valueHint},...t.includePrompts&&e.prompt!==void 0?{prompt:serializePrompt(e.prompt)}:{},...e.deprecated===void 0?{}:{deprecated:e.deprecated},...e.propagate?{propagate:!0}:{},...o===void 0?{}:{negation:{...o.alias===void 0?{}:{alias:o.alias},...o.hidden?{hidden:!0}:{}}},...e.duplicates===`last`?{}:{duplicates:e.duplicates}}}function serializeStringConstraints(e){let t=e.pattern;return{...e.nonEmpty===void 0?{}:{nonEmpty:e.nonEmpty},...e.minLength===void 0?{}:{minLength:e.minLength},...e.maxLength===void 0?{}:{maxLength:e.maxLength},...t===void 0?{}:{pattern:{source:t.source,flags:t.flags}}}}function serializePathChecks(e){return{mustExist:e.mustExist,...e.type===void 0?{}:{type:e.type},...e.create?{create:!0}:{}}}function serializeArgEntry(e,t){return{name:e.name,...serializeArgValue(e.schema,t)}}function serializeArgValue(e,t){let n=e.stringConstraints,r=e.pathChecks;return{kind:e.kind,presence:e.presence,...e.variadic?{variadic:!0}:{},...e.stdin===void 0?{}:{stdin:serializeStdin(e.stdin)},...!e.sensitive&&isJsonSerializable(e.defaultValue)?{defaultValue:e.defaultValue}:{},...e.defaultDescription===void 0?{}:{defaultDescription:e.defaultDescription},...e.sensitive?{sensitive:!0}:{},...e.description===void 0?{}:{description:resolvePlainHelpDescription(e.description)},...e.envVar===void 0?{}:{envVar:e.envVar},...e.configPath===void 0?{}:{configPath:e.configPath},...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.elementSchema===void 0?{}:{elementSchema:serializeArgElementValue(e.elementSchema)},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...n===void 0?{}:{stringConstraints:serializeStringConstraints(n)},...r===void 0?{}:{pathChecks:serializePathChecks(r)},...e.valueHint===void 0?{}:{valueHint:e.valueHint},...e.separator===void 0?{}:{separator:e.separator},...e.split===void 0?{}:{split:serializeSplit(e.split)},...e.duplicateKeys===`last`?{}:{duplicateKeys:e.duplicateKeys},...e.unique?{unique:!0}:{},...t.includePrompts&&e.prompt!==void 0?{prompt:serializePrompt(e.prompt)}:{},...e.deprecated===void 0?{}:{deprecated:e.deprecated}}}function serializeArgElementValue(e){if(e.kind===`keyValue`)throw TypeError(`Arg element schema kind 'keyValue' is not supported`);return{kind:e.kind,presence:`required`,...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]},...e.numberConstraints===void 0?{}:{numberConstraints:{...e.numberConstraints}},...e.stringConstraints===void 0?{}:{stringConstraints:serializeStringConstraints(e.stringConstraints)},...e.pathChecks===void 0?{}:{pathChecks:serializePathChecks(e.pathChecks)},...e.valueHint===void 0?{}:{valueHint:e.valueHint}}}function serializeSplit(e){return{...e.env===void 0?{}:{env:{...e.env}},...e.stdin===void 0?{}:{stdin:{...e.stdin}}}}function serializeStdin(e){return{when:e.when,consume:e.consume,trim:e.trim}}function serializePrompt(e){switch(e.kind){case`input`:return{kind:e.kind,message:e.message,...e.placeholder===void 0?{}:{placeholder:e.placeholder}};case`select`:return{kind:e.kind,message:e.message,...e.choices===void 0?{}:{choices:e.choices.map(serializeChoice)}};case`multiselect`:return{kind:e.kind,message:e.message,...e.choices===void 0?{}:{choices:e.choices.map(serializeChoice)},...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max}};case`confirm`:return{kind:e.kind,message:e.message}}}function serializeChoice(e){return{value:e.value,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description}}}function serializeExample(e,t){return{command:resolveExampleCommand(e.command,t),...e.description===void 0?{}:{description:e.description}}}function generateInputSchema(e,t){let n=resolveOptions(t);if(isCommandSchema(e))return{$schema:JSON_SCHEMA_DRAFT,...commandToInputSchema(e)};let r=[];e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.hidden)&&collectInputBranches(e.defaultCommand,``,r,n);for(let t of e.commands)t!==e.defaultCommand&&t.name!==e.defaultCommand?.name&&(n.includeHidden||!t.hidden)&&collectInputBranches(t,``,r,n);let[i]=r;if(r.length===1&&i!==void 0)return{$schema:JSON_SCHEMA_DRAFT,...stripCommandDiscriminator(i)};if(r.length>0){let t=e.defaultCommand!==void 0&&(n.includeHidden||!e.defaultCommand.hidden)?e.defaultCommand.name:void 0,i=t===void 0?r:r.map(e=>getBranchCommandDiscriminator(e)===t?stripCommandDiscriminator(e):e);return{$schema:JSON_SCHEMA_DRAFT,oneOf:i}}return{$schema:JSON_SCHEMA_DRAFT,type:`object`}}function isCommandSchema(e){return`flags`in e&&`args`in e&&`hasAction`in e}function collectInputBranches(e,t,n,r){let i=t?`${t}.${e.name}`:e.name;e.hasAction&&n.push(commandToInputSchema(e,i));for(let t of e.commands)(r.includeHidden||!t.hidden)&&collectInputBranches(t,i,n,r)}function commandToInputSchema(e,t){let n={},r=[];t!==void 0&&(n.command={const:t},r.push(`command`));for(let[t,i]of Object.entries(e.flags))n[t]=flagToJsonSchemaType(i),i.presence===`required`&&r.push(t);for(let t of e.args)n[t.name]=argToJsonSchemaType(t.schema),t.schema.presence===`required`&&r.push(t.name);return{type:`object`,properties:n,additionalProperties:!1,...r.length>0?{required:r}:{}}}function stripCommandDiscriminator(e){let{command:t,...n}=e.properties,r=e.required?.filter(e=>e!==`command`);return{type:e.type,properties:n,additionalProperties:e.additionalProperties,...r!==void 0&&r.length>0?{required:r}:{}}}function getBranchCommandDiscriminator(e){let t=e.properties.command;if(t===void 0)return;let n=t.const;return typeof n==`string`?n:void 0}function stringConstraintsToJsonSchemaProperties(e){let t={},n=e?.nonEmpty===!0?Math.max(e.minLength??1,1):e?.minLength;return n!==void 0&&(t.minLength=n),e?.maxLength!==void 0&&(t.maxLength=e.maxLength),e?.pattern!==void 0&&(t.pattern=e.pattern.source),t}function flagToJsonSchemaType(e,t=!1){let n={},r=t||e.sensitive;switch(e.kind){case`string`:n.type=`string`,Object.assign(n,stringConstraintsToJsonSchemaProperties(e.stringConstraints));break;case`number`:{let t=e.numberConstraints;n.type=t?.int===!0?`integer`:`number`,t?.min!==void 0&&(n.minimum=t.min),t?.max!==void 0&&(n.maximum=t.max);break}case`boolean`:n.type=`boolean`;break;case`enum`:n.type=`string`,e.enumValues!==void 0&&(n.enum=[...e.enumValues]);break;case`array`:n.type=`array`,e.elementSchema!==void 0&&(n.items=flagToJsonSchemaType(e.elementSchema,r));break;case`custom`:break;case`count`:n.type=`integer`,n.minimum=0;break;case`keyValue`:n.type=`object`,n.additionalProperties=e.elementSchema===void 0?{type:`string`}:flagToJsonSchemaType(e.elementSchema,r)}return e.description!==void 0&&(n.description=resolvePlainHelpDescription(e.description)),e.sensitive&&(n.writeOnly=!0),!r&&isJsonSerializable(e.defaultValue)&&(n.default=e.defaultValue),e.deprecated!==void 0&&(n.deprecated=e.deprecated),n}function argToJsonSchemaType(e){let t=argKindToType(e),n=e.variadic&&e.kind!==`keyValue`?{type:`array`,items:t}:{...t};return e.description!==void 0&&(n.description=resolvePlainHelpDescription(e.description)),e.sensitive&&(n.writeOnly=!0),!e.sensitive&&isJsonSerializable(e.defaultValue)&&(n.default=e.defaultValue),e.deprecated!==void 0&&(n.deprecated=e.deprecated),n}function argKindToType(e){switch(e.kind){case`string`:return{type:`string`,...stringConstraintsToJsonSchemaProperties(e.stringConstraints)};case`number`:{let t=e.numberConstraints,n={type:t?.int===!0?`integer`:`number`};return t?.min!==void 0&&(n.minimum=t.min),t?.max!==void 0&&(n.maximum=t.max),n}case`enum`:{let t={type:`string`};return e.enumValues!==void 0&&(t.enum=[...e.enumValues]),t}case`boolean`:return{type:`boolean`};case`keyValue`:return{type:`object`,additionalProperties:e.elementSchema===void 0?{type:`string`}:argKindToType(e.elementSchema)};case`custom`:return{}}}function isJsonSerializable(e,t=new WeakSet){if(e===void 0)return!1;if(e===null)return!0;let n=typeof e;if(n===`string`||n===`boolean`)return!0;if(n===`number`)return Number.isFinite(e);if(n===`function`||n===`symbol`||n===`bigint`)return!1;if(Array.isArray(e)){if(t.has(e))return!1;t.add(e);try{return e.every(e=>isJsonSerializable(e,t))}finally{t.delete(e)}}if(n===`object`){let n=e;if(!isPlainJsonObject(n)||t.has(n))return!1;t.add(n);try{return Object.values(n).every(e=>isJsonSerializable(e,t))}finally{t.delete(n)}}return!1}function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function withDefinitionDescriptions(e,t){let n=e.properties,r=typeof n==`object`&&n&&isPlainJsonObject(n)&&t.properties!==void 0?Object.fromEntries(Object.entries(n).map(([e,n])=>{let r=t.properties?.[e];return r===void 0||typeof n!=`object`||!n||!isPlainJsonObject(n)?[e,n]:[e,withDefinitionDescriptions(n,r)]})):void 0;return{...e,...t.description===void 0?{}:{description:t.description},...r===void 0?{}:{properties:r}}}function withDefinitionMetaSchemaDescriptions(e,t){let n=withDefinitionDescriptions(e,t.root),r=n.$defs;return typeof r!=`object`||!r||!isPlainJsonObject(r)?n:{...n,$defs:Object.fromEntries(Object.entries(r).map(([e,n])=>{let r=t.defs[e];return r===void 0||typeof n!=`object`||!n||!isPlainJsonObject(n)?[e,n]:[e,withDefinitionDescriptions(n,r)]}))}}const commandFragmentProperties={name:{type:`string`},description:{type:`string`},aliases:{type:`array`,items:{type:`string`}},hidden:{const:!0},examples:{type:`array`,items:{$ref:`#/$defs/example`}},flags:{type:`object`,additionalProperties:{$ref:`#/$defs/flag`}},args:{type:`array`,items:{$ref:`#/$defs/arg`}},commands:{type:`array`,items:{$ref:`#/$defs/command`}}},argValueFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`custom`,`keyValue`]},presence:{enum:[`required`,`optional`,`defaulted`]},variadic:{const:!0},stdin:{$ref:`#/$defs/stdin`},defaultValue:{},defaultDescription:{oneOf:[{type:`string`},{const:!1}]},sensitive:{const:!0},description:{type:`string`},envVar:{type:`string`},configPath:{type:`string`},enumValues:{type:`array`,items:{type:`string`}},elementSchema:{$ref:`#/$defs/argElement`},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`},separator:{type:`string`,minLength:1},split:{$ref:`#/$defs/split`},duplicateKeys:{enum:[...DUPLICATE_KEYS]},unique:{const:!0},prompt:{$ref:`#/$defs/prompt`},deprecated:{oneOf:[{type:`string`},{const:!0}]}},argElementFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`custom`]},presence:{const:`required`},enumValues:{type:`array`,items:{type:`string`}},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`}},flagElementFragmentProperties={kind:{enum:[`string`,`number`,`boolean`,`enum`,`array`,`custom`,`count`,`keyValue`]},presence:{enum:[`optional`,`required`,`defaulted`]},defaultValue:{},aliases:{type:`array`,items:{type:`string`}},stdin:{$ref:`#/$defs/stdin`},envVar:{type:`string`},configPath:{type:`string`},description:{type:`string`},enumValues:{type:`array`,items:{type:`string`}},numberConstraints:{$ref:`#/$defs/numberConstraints`},stringConstraints:{$ref:`#/$defs/stringConstraints`},elementSchema:{$ref:`#/$defs/flagElement`},separator:{type:`string`,minLength:1},split:{$ref:`#/$defs/split`},duplicateKeys:{enum:[...DUPLICATE_KEYS]},unique:{const:!0},pathChecks:{$ref:`#/$defs/pathChecks`},valueHint:{type:`string`},prompt:{$ref:`#/$defs/prompt`},deprecated:{oneOf:[{type:`string`},{const:!0}]},propagate:{const:!0},negation:{$ref:`#/$defs/negation`},duplicates:{enum:[`last`,`first`,`error`]}},flagFragmentProperties={...flagElementFragmentProperties,defaultDescription:{oneOf:[{type:`string`},{const:!1}]},sensitive:{const:!0}},definitionMetaSchema=withDefinitionMetaSchemaDescriptions({$schema:JSON_SCHEMA_DRAFT,$id:DEFINITION_SCHEMA_URL,title:`@kjanat/dreamcli definition schema`,description:`Describes the structure of a CLI built with dreamcli — commands, flags, args, types, constraints, env bindings, and prompts.`,type:`object`,additionalProperties:!1,properties:{$schema:{const:DEFINITION_SCHEMA_URL},schemaVersion:{const:1},name:{type:`string`},version:{type:`string`},description:{type:`string`},defaultCommand:{$ref:`#/$defs/command`},commands:{type:`array`,items:{$ref:`#/$defs/command`}}},required:[`$schema`,`schemaVersion`,`name`,`commands`],$defs:{command:{type:`object`,additionalProperties:!1,properties:commandFragmentProperties,required:[`name`,`flags`,`args`,`commands`]},commandDocument:{type:`object`,additionalProperties:!1,properties:{schemaVersion:{const:1},...commandFragmentProperties},required:[`schemaVersion`,`name`,`flags`,`args`,`commands`]},flag:{type:`object`,additionalProperties:!1,properties:flagFragmentProperties,required:[`kind`,`presence`]},flagElement:{type:`object`,additionalProperties:!1,properties:flagElementFragmentProperties,required:[`kind`,`presence`]},stdin:{type:`object`,additionalProperties:!1,properties:{when:{enum:[`dash`,`missing`,`dash-or-missing`]},consume:{enum:[`exclusive`,`broadcast`]},trim:{type:`boolean`}},required:[`when`,`consume`]},split:{type:`object`,additionalProperties:!1,properties:{env:{$ref:`#/$defs/splitPolicy`},stdin:{$ref:`#/$defs/splitPolicy`}}},splitPolicy:{type:`object`,additionalProperties:!1,properties:{format:{enum:[`whole`,`delimiter`,`lines`,`json`]},delimiter:{type:`string`,minLength:1}},required:[`format`],oneOf:[{properties:{format:{const:`delimiter`}},required:[`format`,`delimiter`]},{properties:{format:{enum:[`whole`,`lines`,`json`]}},not:{required:[`delimiter`]}}]},negation:{type:`object`,additionalProperties:!1,properties:{alias:{type:`string`},hidden:{const:!0}}},numberConstraints:{type:`object`,additionalProperties:!1,properties:{min:{type:`number`},max:{type:`number`},int:{type:`boolean`},finite:{type:`boolean`}}},stringConstraints:{type:`object`,additionalProperties:!1,properties:{nonEmpty:{type:`boolean`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},pattern:{type:`object`,additionalProperties:!1,properties:{source:{type:`string`},flags:{type:`string`}},required:[`source`,`flags`]}}},pathChecks:{type:`object`,additionalProperties:!1,properties:{mustExist:{type:`boolean`},type:{enum:[`file`,`directory`]},create:{const:!0}},required:[`mustExist`]},argElement:{type:`object`,additionalProperties:!1,properties:argElementFragmentProperties,required:[`kind`,`presence`]},arg:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`},...argValueFragmentProperties},required:[`name`,`kind`,`presence`],anyOf:[{not:{required:[`elementSchema`]}},{properties:{kind:{const:`keyValue`}},required:[`kind`]}]},prompt:{type:`object`,additionalProperties:!1,properties:{kind:{enum:[`confirm`,`input`,`select`,`multiselect`]},message:{type:`string`},placeholder:{type:`string`},choices:{type:`array`,items:{$ref:`#/$defs/choice`}},min:{type:`integer`},max:{type:`integer`}},required:[`kind`,`message`]},choice:{type:`object`,additionalProperties:!1,properties:{value:{type:`string`},label:{type:`string`},description:{type:`string`}},required:[`value`]},example:{type:`object`,additionalProperties:!1,properties:{command:{type:`string`},description:{type:`string`}},required:[`command`]}}},definitionMetaSchemaDescriptions);export{json_schema_exports as a,generateSchema as i,generateCommandSchema as n,generateInputSchema as r,definitionMetaSchema as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as definitionMetaSchema, D as DEFINITION_SCHEMA_URL, E as generateSchema, O as DEFINITION_SCHEMA_VERSION, S as StdinBindingFragmentV1, T as generateInputSchema, _ as JsonSchemaOptions, a as CommandDefinitionFragmentV1, b as SourceSplitFragmentV1, c as ExampleDefinitionFragmentV1, d as FlagNegationFragmentV1, f as FlagPathChecksFragmentV1, g as InputSchemaProperty, h as InputSchemaDocument, i as CommandDefinitionDocumentV1, l as FlagDefinitionFragmentV1, m as InputSchemaBranch, n as ArgElementFragmentV1, o as DefinitionDocument, p as FlagStringConstraintsFragmentV1, r as CommandDefinitionDocument, s as DefinitionDocumentV1, t as ArgDefinitionFragmentV1, u as FlagElementFragmentV1, v as PromptChoiceFragmentV1, w as generateCommandSchema, x as SplitPolicyFragmentV1, y as PromptDefinitionFragmentV1 } from "./index-DyoaS234.mjs";
|
|
2
|
+
export { type ArgDefinitionFragmentV1, type ArgElementFragmentV1, type CommandDefinitionDocument, type CommandDefinitionDocumentV1, type CommandDefinitionFragmentV1, DEFINITION_SCHEMA_URL, DEFINITION_SCHEMA_VERSION, type DefinitionDocument, type DefinitionDocumentV1, type ExampleDefinitionFragmentV1, type FlagDefinitionFragmentV1, type FlagElementFragmentV1, type FlagNegationFragmentV1, type FlagPathChecksFragmentV1, type FlagStringConstraintsFragmentV1, type InputSchemaBranch, type InputSchemaDocument, type InputSchemaProperty, type JsonSchemaOptions, type PromptChoiceFragmentV1, type PromptDefinitionFragmentV1, type SourceSplitFragmentV1, type SplitPolicyFragmentV1, type StdinBindingFragmentV1, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as DEFINITION_SCHEMA_URL,o as DEFINITION_SCHEMA_VERSION}from"./core-Cp2w8vRq.mjs";import{i as generateSchema,n as generateCommandSchema,r as generateInputSchema,t as definitionMetaSchema}from"./json-schema-C9SzZ7jY.mjs";export{DEFINITION_SCHEMA_URL,DEFINITION_SCHEMA_VERSION,definitionMetaSchema,generateCommandSchema,generateInputSchema,generateSchema};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as __exportAll}from"./rolldown-runtime-G4Kt5YOX.mjs";var package_json_exports=__exportAll({discoverManifest:()=>discoverManifest,inferCliName:()=>inferCliName});function isPlainObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function parentDir(e){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(`\\`),r=Math.max(t,n),i=n>t?`\\`:`/`;if(r<0)return;if(r===0)return e.length>1?i:void 0;let a=e.slice(0,r);if(a.length===2&&a[1]===`:`){let t=`${a}${i}`;return t===e?void 0:t}return a}function joinPath(e,t){let n=e.includes(`\\`)?`\\`:`/`;return e.endsWith(n)?`${e}${t}`:`${e}${n}${t}`}const DEFAULT_MANIFEST_FILES=[`package.json`];function manifestHasMetadata(e){return e.name!==void 0||e.version!==void 0||e.description!==void 0||e.bin!==void 0||e.homepage!==void 0||e.repository!==void 0}async function discoverManifest(e,t={}){let n=t.files??DEFAULT_MANIFEST_FILES,r=t.startDir??e.cwd;for(;r!==void 0;){for(let t of n){let n=null;try{n=await e.readFile(joinPath(r,t))}catch{}if(n!==null){let e=parsePackageJson(n);if(e!==null&&manifestHasMetadata(e))return e}}r=parentDir(r)}return null}function isJsonWhitespace(e){return e===` `||e===` `||e===`
|
|
2
|
+
`||e===`\r`}function stripJsonc(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i]??``;if(n){t+=a,r?r=!1:a===`\\`?r=!0:a===`"`&&(n=!1);continue}if(a===`"`){n=!0,t+=a;continue}if(a===`/`&&e[i+1]===`/`){for(i+=2;i<e.length&&e[i]!==`
|
|
3
|
+
`;)i+=1;--i;continue}if(a===`/`&&e[i+1]===`*`){for(i+=2;i<e.length&&(e[i]!==`*`||e[i+1]!==`/`);)i+=1;i+=1;continue}t+=a}let i=``;n=!1,r=!1;for(let e=0;e<t.length;e+=1){let a=t[e]??``;if(n){i+=a,r?r=!1:a===`\\`?r=!0:a===`"`&&(n=!1);continue}if(a===`"`){n=!0,i+=a;continue}if(a===`,`){let n=e+1;for(;n<t.length&&isJsonWhitespace(t[n]??``);)n+=1;let r=t[n];if(r===`}`||r===`]`)continue}i+=a}return i}function parsePackageJson(e){let t;try{t=JSON.parse(e)}catch{try{t=JSON.parse(stripJsonc(e))}catch{return null}}try{if(!isPlainObject(t))return null;let e=typeof t.name==`string`?t.name:void 0,n=typeof t.version==`string`?t.version:void 0,r=typeof t.description==`string`?t.description:void 0,i=parseBinField(t.bin),a=typeof t.homepage==`string`?t.homepage:void 0,o=parseRepositoryField(t.repository);return{...e===void 0?{}:{name:e},...n===void 0?{}:{version:n},...r===void 0?{}:{description:r},...i===void 0?{}:{bin:i},...a===void 0?{}:{homepage:a},...o===void 0?{}:{repository:o}}}catch{return null}}function parseBinField(e){if(typeof e==`string`)return e;if(!isPlainObject(e))return;let t={};for(let[n,r]of Object.entries(e)){if(typeof r!=`string`)return;t[n]=r}return t}function parseRepositoryField(e){if(typeof e==`string`)return e;if(!isPlainObject(e))return;let t=typeof e.type==`string`?e.type:void 0,n=typeof e.url==`string`?e.url:void 0,r=typeof e.directory==`string`?e.directory:void 0;if(t!==void 0||n!==void 0||r!==void 0)return{...t===void 0?{}:{type:t},...n===void 0?{}:{url:n},...r===void 0?{}:{directory:r}}}function inferCliName(e,t={}){if(typeof e.bin==`object`){let t=Object.keys(e.bin);if(t.length>0&&t[0]!==void 0)return t[0]}if(e.name!==void 0){if(t.stripScope===!1)return e.name;let n=e.name.indexOf(`/`);return n>=0?e.name.slice(n+1):e.name}}export{inferCliName as n,package_json_exports as r,discoverManifest as t};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { a as WriteFn, c as ResolvedMultiselectPromptConfig, d as resolvePromptConfig, l as ResolvedPromptConfig, o as PromptEngine, s as ReadFn, u as ResolvedSelectPromptConfig } from "./index-BziI2aKc.mjs";
|
|
2
|
+
//#region src/core/prompt/terminal.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create a prompt engine backed by line-based terminal I/O.
|
|
5
|
+
*
|
|
6
|
+
* Uses a {@linkcode ReadFn} for input and a {@linkcode WriteFn} for output. This is the
|
|
7
|
+
* built-in renderer — sufficient for most CLI use cases. For richer
|
|
8
|
+
* TUI experiences, users can implement {@linkcode PromptEngine} with a library
|
|
9
|
+
* like `@clack/prompts` or `inquirer`.
|
|
10
|
+
*
|
|
11
|
+
* The prompter does **not** use raw mode — all input is line-based.
|
|
12
|
+
* This keeps the implementation portable across Node, Bun, and Deno
|
|
13
|
+
* without platform-specific stdin configuration.
|
|
14
|
+
*
|
|
15
|
+
* @param read - Line reader function (returns `null` on EOF)
|
|
16
|
+
* @param write - Output writer function
|
|
17
|
+
* @returns A {@linkcode PromptEngine} that prompts via terminal I/O
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createInterface } from 'node:readline';
|
|
22
|
+
*
|
|
23
|
+
* const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
24
|
+
* let closed = false;
|
|
25
|
+
* rl.once('close', () => {
|
|
26
|
+
* closed = true;
|
|
27
|
+
* });
|
|
28
|
+
* const read: ReadFn = () =>
|
|
29
|
+
* new Promise((resolve) => {
|
|
30
|
+
* if (closed) {
|
|
31
|
+
* resolve(null);
|
|
32
|
+
* return;
|
|
33
|
+
* }
|
|
34
|
+
* const onClose = (): void => resolve(null);
|
|
35
|
+
* rl.once('close', onClose);
|
|
36
|
+
* rl.question('', (answer) => {
|
|
37
|
+
* rl.off('close', onClose);
|
|
38
|
+
* resolve(answer);
|
|
39
|
+
* });
|
|
40
|
+
* });
|
|
41
|
+
* const write: WriteFn = (s) => process.stdout.write(s);
|
|
42
|
+
*
|
|
43
|
+
* const prompter = createTerminalPrompter(read, write);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function createTerminalPrompter(read: ReadFn, write: WriteFn): PromptEngine;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { type PromptEngine, type ReadFn, type ResolvedMultiselectPromptConfig, type ResolvedPromptConfig, type ResolvedSelectPromptConfig, createTerminalPrompter, resolvePromptConfig };
|
package/dist/prompt.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as resolvePromptConfig}from"./core-Cp2w8vRq.mjs";import{t as createTerminalPrompter}from"./terminal-C8KTXjv5.mjs";export{createTerminalPrompter,resolvePromptConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __defProp=Object.defineProperty,__exportAll=(e,t)=>{let n={};for(var r in e)__defProp(n,r,{get:e[r],enumerable:!0});return t||__defProp(n,Symbol.toStringTag,{value:`Module`}),n};export{__exportAll as t};
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createAdapter } from "./runtime/auto.mjs";
|
|
4
|
-
import { DenoNamespace, createDenoAdapter } from "./runtime/deno.mjs";
|
|
5
|
-
import { NodeProcess, createNodeAdapter } from "./runtime/node.mjs";
|
|
6
|
-
import "./runtime/index.mjs";
|
|
1
|
+
import { n as RuntimeAdapter, r as TerminalSize, t as ExitError } from "./adapter-D0hbBNVB.mjs";
|
|
2
|
+
import { a as createAdapter, c as Runtime, i as createDenoAdapter, l as detectRuntime, n as createNodeAdapter, o as GlobalForDetect, r as DenoNamespace, s as RUNTIMES, t as NodeProcess } from "./index-DndPmT8J.mjs";
|
|
7
3
|
export { type DenoNamespace, ExitError, type GlobalForDetect, type NodeProcess, RUNTIMES, type Runtime, type RuntimeAdapter, type TerminalSize, createAdapter, createDenoAdapter, createNodeAdapter, detectRuntime };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RUNTIMES, detectRuntime } from "./runtime/detect.mjs";
|
|
3
|
-
import { createNodeAdapter } from "./runtime/node.mjs";
|
|
4
|
-
import { createAdapter } from "./runtime/auto.mjs";
|
|
5
|
-
import { ExitError } from "./runtime/adapter.mjs";
|
|
6
|
-
export { ExitError, RUNTIMES, createAdapter, createDenoAdapter, createNodeAdapter, detectRuntime };
|
|
1
|
+
import{_ as createNodeAdapter,b as createDenoAdapter,g as createAdapter,n as ExitError,v as RUNTIMES,y as detectRuntime}from"./core-Cp2w8vRq.mjs";export{ExitError,RUNTIMES,createAdapter,createDenoAdapter,createNodeAdapter,detectRuntime};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t as __exportAll}from"./rolldown-runtime-G4Kt5YOX.mjs";var terminal_exports=__exportAll({createTerminalPrompter:()=>createTerminalPrompter});function createTerminalPrompter(e,t){return{promptOne(n){switch(n.kind){case`confirm`:return promptConfirm(n,e,t);case`input`:return promptInput(n,e,t);case`select`:return promptSelect(n,e,t);case`multiselect`:return promptMultiselect(n,e,t)}}}}async function promptConfirm(e,t,n){let r=e.default??!0,i=0;for(;i<10;){let a=r?`(Y/n)`:`(y/N)`;n(`${e.message} ${a} `);let o=await t();if(o===null)return{answered:!1};let s=o.trim().toLowerCase();if(s===``)return{answered:!0,value:r};if(s===`y`||s===`yes`)return{answered:!0,value:!0};if(s===`n`||s===`no`)return{answered:!0,value:!1};n(`Please answer y or n.
|
|
2
|
+
`),i+=1}return n(`Too many invalid attempts.
|
|
3
|
+
`),{answered:!1}}async function promptInput(e,t,n){let r=0,i=[];e.placeholder!==void 0&&i.push(e.placeholder),e.default!==void 0&&i.push(`default: ${e.default}`);let a=i.length>0?` (${i.join(`, `)})`:``;for(;r<10;){n(`${e.message}${a}: `);let i=await t();if(i===null)return{answered:!1};let o=i.trim();if(o===``)return e.default===void 0?{answered:!0,value:``}:{answered:!0,value:e.default};if(e.validate!==void 0){let t=e.validate(o);if(t!==!0){n(`${t}\n`),r+=1;continue}}return{answered:!0,value:o}}return n(`Too many invalid attempts.
|
|
4
|
+
`),{answered:!1}}async function promptSelect(e,t,n){let r=0;for(;r<10;){n(`${e.message}\n`);for(let t=0;t<e.choices.length;t+=1){let r=e.choices[t];if(r===void 0)continue;let i=r.label??r.value,a=r.description===void 0?``:` - ${r.description}`;n(` ${t+1}) ${i}${a}\n`)}n(`Enter number: `);let i=await t();if(i===null)return{answered:!1};let a=Number(i.trim());if(Number.isNaN(a)||!Number.isInteger(a)||a<1||a>e.choices.length){n(`Please enter a number between 1 and ${e.choices.length}.\n`),r+=1;continue}let o=e.choices[a-1];if(o===void 0){r+=1;continue}return{answered:!0,value:o.value}}return n(`Too many invalid attempts.
|
|
5
|
+
`),{answered:!1}}async function promptMultiselect(e,t,n){let r=0;for(;r<10;){n(`${e.message}\n`);for(let t=0;t<e.choices.length;t+=1){let r=e.choices[t];if(r===void 0)continue;let i=r.label??r.value,a=r.description===void 0?``:` - ${r.description}`;n(` ${t+1}) ${i}${a}\n`)}n(`Enter numbers separated by commas (e.g. 1,3${e.min===void 0?``:`, min: ${e.min}`}${e.max===void 0?``:`, max: ${e.max}`}): `);let i=await t();if(i===null)return{answered:!1};let a=i.trim();if(a===``){if(e.min!==void 0&&e.min>0){n(`Please select at least ${e.min}.\n`),r+=1;continue}return{answered:!0,value:[]}}let o=a.split(`,`).map(e=>e.trim()),s=[],c=!0;for(let t of o){let r=Number(t);if(Number.isNaN(r)||!Number.isInteger(r)||r<1||r>e.choices.length){n(`Invalid selection '${t}'. Use numbers between 1 and ${e.choices.length}.\n`),c=!1;break}s.push(r)}if(!c){r+=1;continue}let l=[...new Set(s)];if(e.min!==void 0&&l.length<e.min){n(`Please select at least ${e.min}.\n`),r+=1;continue}if(e.max!==void 0&&l.length>e.max){n(`Please select at most ${e.max}.\n`),r+=1;continue}return{answered:!0,value:l.map(t=>e.choices[t-1]?.value??``)}}return n(`Too many invalid attempts.
|
|
6
|
+
`),{answered:!1}}export{terminal_exports as n,createTerminalPrompter as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as __exportAll}from"./rolldown-runtime-G4Kt5YOX.mjs";var test_prompter_exports=__exportAll({PROMPT_CANCEL:()=>PROMPT_CANCEL,createTestPrompter:()=>createTestPrompter});const PROMPT_CANCEL=Symbol.for(`dreamcli.prompt.cancel`);function createTestPrompter(e,t){let n=0;return{promptOne(r){if(n>=e.length)return t?.onExhausted===`cancel`?Promise.resolve({answered:!1}):Promise.reject(Error(`Test prompter exhausted: expected at most ${e.length} prompts, got prompt #${n+1}`));let i=e[n];return n+=1,i===PROMPT_CANCEL||r.kind===`input`&&r.validate!==void 0&&typeof i==`string`&&r.validate(i)!==!0?Promise.resolve({answered:!1}):Promise.resolve({answered:!0,value:i})}}}export{createTestPrompter as n,test_prompter_exports as r,PROMPT_CANCEL as t};
|
package/dist/testkit.d.mts
CHANGED
|
@@ -1,7 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { G as ArgConfig, Nt as FlagBuilder, Pt as FlagConfig, W as ArgBuilder, g as CommandBuilder, r as createCaptureOutput, t as CapturedOutput } from "./index-BziI2aKc.mjs";
|
|
2
|
+
import { U as BuiltinsConfig, a as TestPrompterOptions, i as TestAnswer, n as RunResult, o as createTestPrompter, r as PROMPT_CANCEL, t as RunOptions } from "./index-DWsnGZlx.mjs";
|
|
3
|
+
import { a as createTestAdapter, i as TestAdapterOptions } from "./adapter-D0hbBNVB.mjs";
|
|
4
|
+
import "./index-DndPmT8J.mjs";
|
|
5
|
+
//#region src/core/testkit/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@linkcode runCommand}.
|
|
8
|
+
*
|
|
9
|
+
* Extends {@linkcode RunOptions} with the CLI-root state `runCommand()` mirrors,
|
|
10
|
+
* following the way `CLIRunOptions` extends `CLIExecuteOptions` with the fields
|
|
11
|
+
* only that layer needs.
|
|
12
|
+
*/
|
|
13
|
+
interface RunCommandOptions extends RunOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Which built-in flags the harness mirrors, matching the CLI the command is
|
|
16
|
+
* registered on.
|
|
17
|
+
*
|
|
18
|
+
* A command that owns a released built-in (`cli(...).builtins({ json: 'off' })`
|
|
19
|
+
* plus a `json` flag) must be tested with the same setting, otherwise the
|
|
20
|
+
* harness strips the token before `parse()` sees it.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue every built-in `'on'`, mirroring an unconfigured CLI root
|
|
23
|
+
*/
|
|
24
|
+
readonly builtins?: BuiltinsConfig;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run a command builder against the given argv with injected options.
|
|
28
|
+
*
|
|
29
|
+
* This is the testkit wrapper around the shared executor:
|
|
30
|
+
* 1. Apply the CLI root-flag layer (detect/strip `--json` and `--quiet`/`-q`) so
|
|
31
|
+
* copied real argv works
|
|
32
|
+
* 2. Create or reuse capture output
|
|
33
|
+
* 3. Build standalone schema/meta defaults when CLI dispatch did not
|
|
34
|
+
* 4. Delegate parse -> resolve -> execute to the shared executor
|
|
35
|
+
* 5. Return the structured result with captured buffers
|
|
36
|
+
*
|
|
37
|
+
* Errors are normalized by the shared executor into structured {@linkcode RunResult}s
|
|
38
|
+
* with appropriate exit codes. The function never throws.
|
|
39
|
+
*
|
|
40
|
+
* @param cmd - The command builder (must have an action handler)
|
|
41
|
+
* @param argv - Raw argv strings (NOT including the command name itself).
|
|
42
|
+
* CLI-level `--json` and `--quiet`/`-q` before the `--` separator are honored
|
|
43
|
+
* and stripped here, just like the real CLI root — so `['--json']` enables
|
|
44
|
+
* JSON mode and `['--quiet']` sets quiet verbosity rather than failing as
|
|
45
|
+
* unknown flags. Equivalent to `{ jsonMode: true }` / `{ verbosity: 'quiet' }`.
|
|
46
|
+
* Both accept an explicit value (`--json=false`), and an invalid one fails
|
|
47
|
+
* with the same `INVALID_VALUE` error the CLI root produces. Pass
|
|
48
|
+
* `options.builtins` to mirror a CLI that released one of these tokens to its
|
|
49
|
+
* commands.
|
|
50
|
+
* @param options - Injectable runtime state
|
|
51
|
+
* @returns Structured run result with exit code and captured output
|
|
52
|
+
*/
|
|
53
|
+
declare function runCommand<F extends Record<string, FlagBuilder<FlagConfig>>, A extends Record<string, ArgBuilder<ArgConfig>>, C extends Record<string, unknown> = Record<string, never>>(cmd: CommandBuilder<F, A, C>, argv: readonly string[], options?: RunCommandOptions): Promise<RunResult>;
|
|
54
|
+
//#endregion
|
|
7
55
|
export { type CapturedOutput, PROMPT_CANCEL, type RunCommandOptions, type RunOptions, type RunResult, type TestAdapterOptions, type TestAnswer, type TestPrompterOptions, createCaptureOutput, createTestAdapter, createTestPrompter, runCommand };
|
package/dist/testkit.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PROMPT_CANCEL, createTestPrompter } from "./core/prompt/index.mjs";
|
|
3
|
-
import { createTestAdapter } from "./runtime/adapter.mjs";
|
|
4
|
-
import { runCommand } from "./core/testkit/index.mjs";
|
|
5
|
-
export { PROMPT_CANCEL, createCaptureOutput, createTestAdapter, createTestPrompter, runCommand };
|
|
1
|
+
import{A as createCaptureOutput,r as createTestAdapter,t as runCommand}from"./core-Cp2w8vRq.mjs";import{n as createTestPrompter,t as PROMPT_CANCEL}from"./test-prompter-v__jT2yG.mjs";export{PROMPT_CANCEL,createCaptureOutput,createTestAdapter,createTestPrompter,runCommand};
|