@kjanat/dreamcli 3.0.0-rc.2 → 3.0.0-rc.20
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/CHANGELOG.md +374 -1
- package/README.md +3 -3
- package/dist/core/cli/dispatch.d.mts +6 -5
- package/dist/core/cli/dispatch.mjs +7 -16
- package/dist/core/cli/help-links.d.mts +0 -1
- package/dist/core/cli/index.d.mts +213 -16
- package/dist/core/cli/index.mjs +174 -43
- package/dist/core/cli/planner.d.mts +5 -1
- package/dist/core/cli/planner.mjs +19 -13
- package/dist/core/cli/plugin.d.mts +1 -1
- package/dist/core/cli/propagate.d.mts +1 -1
- package/dist/core/cli/root-help.d.mts +2 -1
- package/dist/core/cli/root-help.mjs +45 -22
- package/dist/core/cli/root-surface.d.mts +12 -1
- package/dist/core/cli/root-surface.mjs +2 -1
- package/dist/core/cli/runtime-preflight.d.mts +18 -2
- package/dist/core/cli/runtime-preflight.mjs +10 -7
- package/dist/core/completion/index.d.mts +0 -1
- package/dist/core/completion/index.mjs +1 -1
- package/dist/core/completion/shells/bash.d.mts +0 -1
- package/dist/core/completion/shells/bash.mjs +8 -4
- package/dist/core/completion/shells/fish.d.mts +0 -1
- package/dist/core/completion/shells/fish.mjs +6 -3
- package/dist/core/completion/shells/powershell.d.mts +0 -1
- package/dist/core/completion/shells/powershell.mjs +10 -5
- package/dist/core/completion/shells/shared.d.mts +13 -2
- package/dist/core/completion/shells/shared.mjs +25 -2
- package/dist/core/completion/shells/zsh.d.mts +0 -1
- package/dist/core/completion/shells/zsh.mjs +11 -4
- package/dist/core/config/index.d.mts +44 -14
- package/dist/core/config/index.mjs +57 -18
- package/dist/core/config/package-json.d.mts +28 -4
- package/dist/core/config/package-json.mjs +20 -19
- package/dist/core/errors/index.d.mts +3 -3
- package/dist/core/execution/index.d.mts +0 -1
- package/dist/core/execution/index.mjs +20 -4
- package/dist/core/help/ansi.d.mts +11 -5
- package/dist/core/help/ansi.mjs +15 -16
- package/dist/core/help/index.d.mts +44 -3
- package/dist/core/help/index.mjs +130 -68
- package/dist/core/help/theme.d.mts +68 -0
- package/dist/core/help/theme.mjs +46 -0
- package/dist/core/json-schema/index.d.mts +21 -9
- package/dist/core/json-schema/index.mjs +316 -87
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +55 -38
- package/dist/core/json-schema/meta-descriptions.generated.mjs +14 -5
- package/dist/core/output/activity.d.mts +0 -1
- package/dist/core/output/contracts.d.mts +5 -6
- package/dist/core/output/contracts.mjs +2 -2
- package/dist/core/output/index.d.mts +38 -2
- package/dist/core/output/index.mjs +37 -2
- package/dist/core/output/renderers.d.mts +0 -1
- package/dist/core/parse/index.d.mts +40 -7
- package/dist/core/parse/index.mjs +212 -40
- package/dist/core/prompt/index.d.mts +1 -0
- package/dist/core/resolve/args.d.mts +1 -1
- package/dist/core/resolve/coerce.d.mts +1 -1
- package/dist/core/resolve/coerce.mjs +71 -14
- package/dist/core/resolve/contracts.d.mts +14 -4
- package/dist/core/resolve/errors.d.mts +0 -1
- package/dist/core/resolve/flags.d.mts +9 -2
- package/dist/core/resolve/flags.mjs +78 -6
- package/dist/core/resolve/index.d.mts +2 -2
- package/dist/core/resolve/index.mjs +6 -1
- package/dist/core/resolve/property.d.mts +4 -1
- package/dist/core/resolve/property.mjs +11 -3
- package/dist/core/resolve/standard.d.mts +24 -0
- package/dist/core/resolve/standard.mjs +114 -0
- package/dist/core/schema/activity.d.mts +31 -11
- package/dist/core/schema/arg.d.mts +38 -4
- package/dist/core/schema/arg.mjs +5 -2
- package/dist/core/schema/command.d.mts +57 -13
- package/dist/core/schema/command.mjs +41 -17
- package/dist/core/schema/flag.d.mts +553 -19
- package/dist/core/schema/flag.mjs +261 -5
- package/dist/core/schema/index.d.mts +6 -3
- package/dist/core/schema/middleware.d.mts +4 -3
- package/dist/core/schema/prompt.d.mts +6 -3
- package/dist/core/schema/run.d.mts +27 -1
- package/dist/core/schema/standard.d.mts +100 -0
- package/dist/core/schema/standard.mjs +15 -0
- package/dist/core/schema/string-constraints.d.mts +97 -0
- package/dist/core/schema/string-constraints.mjs +69 -0
- package/dist/core/schema/value-parsers.d.mts +78 -0
- package/dist/core/schema/value-parsers.mjs +142 -0
- package/dist/core/testkit/index.d.mts +0 -31
- package/dist/core/testkit/index.mjs +1 -1
- package/dist/index.d.mts +12 -7
- package/dist/index.mjs +9 -9
- package/dist/runtime/adapter.d.mts +71 -2
- package/dist/runtime/adapter.mjs +11 -1
- package/dist/runtime/auto.d.mts +2 -3
- package/dist/runtime/auto.mjs +4 -5
- package/dist/runtime/deno.d.mts +28 -5
- package/dist/runtime/deno.mjs +49 -1
- package/dist/runtime/index.d.mts +3 -4
- package/dist/runtime/node.d.mts +8 -2
- package/dist/runtime/node.mjs +60 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +2 -3
- package/dist/testkit.d.mts +1 -0
- package/dist/version.d.mts +7 -3
- package/dist/version.mjs +2 -2
- package/dreamcli.schema.json +118 -7
- package/examples/gh/node_modules/typescript/LICENSE +55 -0
- package/examples/gh/node_modules/typescript/NOTICE.txt +436 -0
- package/examples/gh/node_modules/typescript/README.md +49 -0
- package/examples/gh/node_modules/typescript/bin/tsc +2 -0
- package/examples/gh/node_modules/typescript/dist/api/async/api.d.ts +529 -0
- package/examples/gh/node_modules/typescript/dist/api/async/api.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/async/api.js +1657 -0
- package/examples/gh/node_modules/typescript/dist/api/async/api.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/async/client.d.ts +39 -0
- package/examples/gh/node_modules/typescript/dist/api/async/client.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/async/client.js +211 -0
- package/examples/gh/node_modules/typescript/dist/api/async/client.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/async/types.d.ts +310 -0
- package/examples/gh/node_modules/typescript/dist/api/async/types.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/async/types.js +2 -0
- package/examples/gh/node_modules/typescript/dist/api/async/types.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/compilerOptions.d.ts +109 -0
- package/examples/gh/node_modules/typescript/dist/api/compilerOptions.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/compilerOptions.js +2 -0
- package/examples/gh/node_modules/typescript/dist/api/compilerOptions.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/fs.d.ts +23 -0
- package/examples/gh/node_modules/typescript/dist/api/fs.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/fs.js +109 -0
- package/examples/gh/node_modules/typescript/dist/api/fs.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.d.ts +15 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.generated.d.ts +5 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.generated.js +74 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.js +287 -0
- package/examples/gh/node_modules/typescript/dist/api/node/encoder.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/msgpack.d.ts +32 -0
- package/examples/gh/node_modules/typescript/dist/api/node/msgpack.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/msgpack.js +213 -0
- package/examples/gh/node_modules/typescript/dist/api/node/msgpack.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.d.ts +76 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.generated.d.ts +182 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.generated.js +835 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.infrastructure.d.ts +62 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.infrastructure.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.infrastructure.js +122 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.infrastructure.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.js +298 -0
- package/examples/gh/node_modules/typescript/dist/api/node/node.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.d.ts +29 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.generated.d.ts +4 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.generated.js +241 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.js +30 -0
- package/examples/gh/node_modules/typescript/dist/api/node/protocol.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/wtf8.d.ts +6 -0
- package/examples/gh/node_modules/typescript/dist/api/node/wtf8.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/node/wtf8.js +61 -0
- package/examples/gh/node_modules/typescript/dist/api/node/wtf8.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/options.d.ts +32 -0
- package/examples/gh/node_modules/typescript/dist/api/options.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/options.js +11 -0
- package/examples/gh/node_modules/typescript/dist/api/options.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/path.d.ts +110 -0
- package/examples/gh/node_modules/typescript/dist/api/path.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/path.js +508 -0
- package/examples/gh/node_modules/typescript/dist/api/path.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/proto.d.ts +239 -0
- package/examples/gh/node_modules/typescript/dist/api/proto.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/proto.js +37 -0
- package/examples/gh/node_modules/typescript/dist/api/proto.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sourceFileCache.d.ts +79 -0
- package/examples/gh/node_modules/typescript/dist/api/sourceFileCache.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sourceFileCache.js +169 -0
- package/examples/gh/node_modules/typescript/dist/api/sourceFileCache.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/api.d.ts +529 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/api.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/api.js +1665 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/api.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/client.d.ts +30 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/client.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/client.js +124 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/client.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/types.d.ts +310 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/types.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/types.js +2 -0
- package/examples/gh/node_modules/typescript/dist/api/sync/types.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/syncChannel.d.ts +114 -0
- package/examples/gh/node_modules/typescript/dist/api/syncChannel.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/syncChannel.js +508 -0
- package/examples/gh/node_modules/typescript/dist/api/syncChannel.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/timing.d.ts +175 -0
- package/examples/gh/node_modules/typescript/dist/api/timing.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/api/timing.js +149 -0
- package/examples/gh/node_modules/typescript/dist/api/timing.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.d.ts +100 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.generated.d.ts +1161 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.generated.js +4 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.js +7 -0
- package/examples/gh/node_modules/typescript/dist/ast/ast.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/astnav.d.ts +19 -0
- package/examples/gh/node_modules/typescript/dist/ast/astnav.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/astnav.js +596 -0
- package/examples/gh/node_modules/typescript/dist/ast/astnav.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/clone.d.ts +16 -0
- package/examples/gh/node_modules/typescript/dist/ast/clone.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/clone.js +104 -0
- package/examples/gh/node_modules/typescript/dist/ast/clone.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/factory.generated.d.ts +520 -0
- package/examples/gh/node_modules/typescript/dist/ast/factory.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/factory.generated.js +3057 -0
- package/examples/gh/node_modules/typescript/dist/ast/factory.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/index.d.ts +20 -0
- package/examples/gh/node_modules/typescript/dist/ast/index.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/index.js +20 -0
- package/examples/gh/node_modules/typescript/dist/ast/index.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.d.ts +35 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.generated.d.ts +329 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.generated.js +1103 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.js +233 -0
- package/examples/gh/node_modules/typescript/dist/ast/is.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/jsdoc.d.ts +11 -0
- package/examples/gh/node_modules/typescript/dist/ast/jsdoc.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/jsdoc.js +202 -0
- package/examples/gh/node_modules/typescript/dist/ast/jsdoc.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/scanner.d.ts +97 -0
- package/examples/gh/node_modules/typescript/dist/ast/scanner.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/scanner.js +2230 -0
- package/examples/gh/node_modules/typescript/dist/ast/scanner.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/utils.d.ts +17 -0
- package/examples/gh/node_modules/typescript/dist/ast/utils.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/utils.js +67 -0
- package/examples/gh/node_modules/typescript/dist/ast/utils.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.d.ts +14 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.generated.d.ts +50 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.generated.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.generated.js +978 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.generated.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.js +47 -0
- package/examples/gh/node_modules/typescript/dist/ast/visitor.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.enum.d.ts +129 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.enum.js +132 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.js +130 -0
- package/examples/gh/node_modules/typescript/dist/enums/characterCodes.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.enum.d.ts +5 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.enum.js +6 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.js +6 -0
- package/examples/gh/node_modules/typescript/dist/enums/commentDirectiveType.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.enum.d.ts +28 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.enum.js +30 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.js +30 -0
- package/examples/gh/node_modules/typescript/dist/enums/completionItemKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.enum.d.ts +7 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.enum.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/diagnosticCategory.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.enum.d.ts +12 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.enum.js +14 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.js +14 -0
- package/examples/gh/node_modules/typescript/dist/enums/elementFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.enum.d.ts +23 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.enum.js +25 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.js +25 -0
- package/examples/gh/node_modules/typescript/dist/enums/internalSymbolName.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.enum.d.ts +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.enum.js +11 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.js +11 -0
- package/examples/gh/node_modules/typescript/dist/enums/jsxEmit.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.enum.d.ts +5 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.enum.js +6 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.js +6 -0
- package/examples/gh/node_modules/typescript/dist/enums/languageVariant.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.enum.d.ts +42 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.enum.js +44 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.js +44 -0
- package/examples/gh/node_modules/typescript/dist/enums/modifierFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.enum.d.ts +7 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.enum.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleDetectionKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.enum.d.ts +17 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.enum.js +19 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.js +19 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.enum.d.ts +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.enum.js +11 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.js +11 -0
- package/examples/gh/node_modules/typescript/dist/enums/moduleResolutionKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.enum.d.ts +6 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.enum.js +8 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.js +8 -0
- package/examples/gh/node_modules/typescript/dist/enums/newLineKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.enum.d.ts +36 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.enum.js +38 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.js +38 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeBuilderFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.enum.d.ts +44 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.enum.js +46 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.js +46 -0
- package/examples/gh/node_modules/typescript/dist/enums/nodeFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.enum.d.ts +50 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.enum.js +52 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.js +52 -0
- package/examples/gh/node_modules/typescript/dist/enums/objectFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.enum.d.ts +16 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.enum.js +18 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.js +18 -0
- package/examples/gh/node_modules/typescript/dist/enums/outerExpressionKinds.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.enum.d.ts +13 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.enum.js +14 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.js +14 -0
- package/examples/gh/node_modules/typescript/dist/enums/regularExpressionFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.enum.d.ts +11 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.enum.js +12 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.js +12 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.enum.d.ts +17 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.enum.js +18 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.js +18 -0
- package/examples/gh/node_modules/typescript/dist/enums/scriptTarget.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.enum.d.ts +15 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.enum.js +17 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.js +17 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.enum.d.ts +5 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.enum.js +7 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.js +7 -0
- package/examples/gh/node_modules/typescript/dist/enums/signatureKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.enum.d.ts +71 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.enum.js +73 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.js +73 -0
- package/examples/gh/node_modules/typescript/dist/enums/symbolFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.enum.d.ts +389 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.enum.js +391 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.js +391 -0
- package/examples/gh/node_modules/typescript/dist/enums/syntaxKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.enum.d.ts +30 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.enum.js +32 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.js +32 -0
- package/examples/gh/node_modules/typescript/dist/enums/tokenFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.enum.d.ts +76 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.enum.js +78 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.js +78 -0
- package/examples/gh/node_modules/typescript/dist/enums/typeFlags.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.d.ts +2 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.enum.d.ts +7 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.enum.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.enum.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.enum.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.js +9 -0
- package/examples/gh/node_modules/typescript/dist/enums/typePredicateKind.js.map +1 -0
- package/examples/gh/node_modules/typescript/dist/internal/utils.d.ts +23 -0
- package/examples/gh/node_modules/typescript/dist/internal/utils.d.ts.map +1 -0
- package/examples/gh/node_modules/typescript/dist/internal/utils.js +25 -0
- package/examples/gh/node_modules/typescript/dist/internal/utils.js.map +1 -0
- package/examples/gh/node_modules/typescript/lib/getExePath.d.ts +2 -0
- package/examples/gh/node_modules/typescript/lib/getExePath.js +70 -0
- package/examples/gh/node_modules/typescript/lib/tsc.js +28 -0
- package/examples/gh/node_modules/typescript/lib/version.cjs +3 -0
- package/examples/gh/node_modules/typescript/lib/version.d.cts +2 -0
- package/examples/gh/node_modules/typescript/package.json +87 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/License.txt +11 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/README.md +54 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/browser/main.d.ts +17 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/browser/main.js +83 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/browser/ril.d.ts +22 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/browser/ril.js +210 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/api.d.ts +14 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/api.js +87 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/cancellation.js +132 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/connection.d.ts +367 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/connection.js +1271 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/disposable.d.ts +9 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/disposable.js +16 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/encoding.d.ts +52 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/encoding.js +70 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/events.d.ts +39 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/events.js +135 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/is.d.ts +7 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/is.js +34 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/linkedMap.d.ts +55 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/linkedMap.js +412 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageBuffer.d.ts +18 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageBuffer.js +155 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageReader.d.ts +77 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageReader.js +246 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageWriter.d.ts +60 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messageWriter.js +157 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messages.d.ts +369 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/messages.js +436 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/ral.d.ts +74 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/ral.js +23 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/semaphore.d.ts +10 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/semaphore.js +74 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +15 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +77 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/node/main.d.ts +58 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/node/main.js +289 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/node/ril.d.ts +12 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/lib/node/ril.js +163 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/package.json +54 -0
- package/examples/gh/node_modules/typescript/vendor/vscode-jsonrpc/typings/thenable.d.ts +5 -0
- package/examples/gh/package.json +11 -5
- package/examples/gh/src/main.ts +10 -4
- package/examples/pwsh-demo/package.json +1 -1
- package/examples/pwsh-demo/src/main.ts +1 -1
- package/package.json +45 -41
- package/dist/core/schema-dsl/runtime.d.mts +0 -144
- package/dist/core/schema-dsl/runtime.mjs +0 -271
- package/dist/core/schema-dsl/to-json-schema.d.mts +0 -30
- package/dist/core/schema-dsl/to-json-schema.mjs +0 -74
- package/dist/runtime/bun.d.mts +0 -28
- package/dist/runtime/bun.mjs +0 -28
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { describeNumberConstraintViolation, validateNumberConstraints } from "../schema/number-constraints.mjs";
|
|
2
|
-
import { getFlagAliasNames } from "../schema/flag.mjs";
|
|
3
1
|
import { ParseError } from "../errors/index.mjs";
|
|
2
|
+
import { describeNumberConstraintViolation, validateNumberConstraints } from "../schema/number-constraints.mjs";
|
|
3
|
+
import { describeStringConstraintViolation, validateStringConstraints } from "../schema/string-constraints.mjs";
|
|
4
|
+
import { getFlagAliasNames, getFlagNegatedName } from "../schema/flag.mjs";
|
|
4
5
|
//#region src/core/parse/index.ts
|
|
5
6
|
/**
|
|
6
7
|
* Argv tokenization and parsing against command schemas.
|
|
@@ -122,30 +123,117 @@ function stripBeforeSeparator(argv, token) {
|
|
|
122
123
|
const filteredHead = head.filter((arg) => arg !== token);
|
|
123
124
|
return separatorIndex === -1 ? filteredHead : [...filteredHead, ...argv.slice(separatorIndex)];
|
|
124
125
|
}
|
|
126
|
+
/** `do-this` → `doThis`. Returns the input unchanged when nothing converts. */
|
|
127
|
+
function kebabToCamel(name) {
|
|
128
|
+
return name.replace(/-+([a-z0-9])/g, (_match, char) => char.toUpperCase());
|
|
129
|
+
}
|
|
130
|
+
/** `doThis` → `do-this`. Returns the input unchanged when nothing converts. */
|
|
131
|
+
function camelToKebab(name) {
|
|
132
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The kebab↔camel counterpart spelling of a flag name, or `undefined` when
|
|
136
|
+
* the name has none (single-char aliases, single lowercase words).
|
|
137
|
+
*/
|
|
138
|
+
function counterpartSpelling(name) {
|
|
139
|
+
if (name.length < 2) return void 0;
|
|
140
|
+
if (name.includes("-")) {
|
|
141
|
+
const camel = kebabToCamel(name);
|
|
142
|
+
return camel !== name ? camel : void 0;
|
|
143
|
+
}
|
|
144
|
+
const kebab = camelToKebab(name);
|
|
145
|
+
return kebab !== name ? kebab : void 0;
|
|
146
|
+
}
|
|
125
147
|
/**
|
|
126
|
-
* Build a map from flag
|
|
148
|
+
* Build a map from flag spelling → {@link FlagLookupEntry}.
|
|
127
149
|
*
|
|
128
|
-
*
|
|
150
|
+
* Covers canonical names, aliases (long + single-char), negated spellings of
|
|
151
|
+
* `.negatable()` booleans, and — unless `caseParity` is `false` — the
|
|
152
|
+
* kebab↔camel counterpart of every declared spelling. Counterparts never
|
|
153
|
+
* override declared spellings: when a command defines both `do-this` and
|
|
154
|
+
* `doThis` explicitly, each spelling exact-matches its own flag and no
|
|
155
|
+
* parity entries are added for the pair.
|
|
129
156
|
*
|
|
130
157
|
* @param flags - Flag schemas keyed by canonical name
|
|
131
|
-
* @
|
|
158
|
+
* @param options - Parity toggle (see {@link ParseOptions})
|
|
159
|
+
* @returns Lookup map covering all resolvable spellings
|
|
132
160
|
*/
|
|
133
|
-
function buildFlagLookup(flags) {
|
|
161
|
+
function buildFlagLookup(flags, options) {
|
|
134
162
|
const lookup = /* @__PURE__ */ new Map();
|
|
135
163
|
for (const [name, schema] of Object.entries(flags)) {
|
|
136
|
-
lookup.set(name,
|
|
137
|
-
|
|
164
|
+
lookup.set(name, {
|
|
165
|
+
name,
|
|
166
|
+
schema,
|
|
167
|
+
negated: false,
|
|
168
|
+
parity: false
|
|
169
|
+
});
|
|
170
|
+
for (const alias of getFlagAliasNames(schema, { includeHidden: true })) lookup.set(alias, {
|
|
171
|
+
name,
|
|
172
|
+
schema,
|
|
173
|
+
negated: false,
|
|
174
|
+
parity: false
|
|
175
|
+
});
|
|
176
|
+
const negatedName = getFlagNegatedName(name, schema);
|
|
177
|
+
if (negatedName !== void 0) lookup.set(negatedName, {
|
|
178
|
+
name,
|
|
179
|
+
schema,
|
|
180
|
+
negated: true,
|
|
181
|
+
parity: false
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (options?.caseParity !== false) {
|
|
185
|
+
const declared = [...lookup];
|
|
186
|
+
for (const [spelling, entry] of declared) {
|
|
187
|
+
const counterpart = counterpartSpelling(spelling);
|
|
188
|
+
if (counterpart !== void 0 && !lookup.has(counterpart)) lookup.set(counterpart, {
|
|
189
|
+
...entry,
|
|
190
|
+
parity: true
|
|
191
|
+
});
|
|
192
|
+
}
|
|
138
193
|
}
|
|
139
194
|
return lookup;
|
|
140
195
|
}
|
|
141
196
|
/**
|
|
197
|
+
* Record one CLI occurrence of a logical flag and enforce its duplicate
|
|
198
|
+
* policy.
|
|
199
|
+
*
|
|
200
|
+
* @param occurrences - Per-parse accumulator keyed by canonical name
|
|
201
|
+
* @param name - Canonical flag name
|
|
202
|
+
* @param schema - Flag schema (read for {@link FlagSchema.duplicates})
|
|
203
|
+
* @param value - The occurrence's raw value (or the boolean it implies)
|
|
204
|
+
* @param displayName - User-facing spelling for error messages
|
|
205
|
+
* @returns `true` when the occurrence should be applied; `false` when the
|
|
206
|
+
* `'first'` policy suppresses it (the token is still consumed)
|
|
207
|
+
* @throws ParseError `DUPLICATE_FLAG` on a repeat under the `'error'` policy
|
|
208
|
+
*/
|
|
209
|
+
function recordFlagOccurrence(occurrences, name, schema, value, displayName) {
|
|
210
|
+
const record = occurrences.get(name) ?? {
|
|
211
|
+
count: 0,
|
|
212
|
+
values: []
|
|
213
|
+
};
|
|
214
|
+
record.count += 1;
|
|
215
|
+
record.values.push(value);
|
|
216
|
+
occurrences.set(name, record);
|
|
217
|
+
if (record.count === 1) return true;
|
|
218
|
+
if (schema.duplicates === "error") throw new ParseError(`Flag --${name} may only be specified once`, {
|
|
219
|
+
code: "DUPLICATE_FLAG",
|
|
220
|
+
details: {
|
|
221
|
+
flag: name,
|
|
222
|
+
input: displayName,
|
|
223
|
+
count: record.count,
|
|
224
|
+
values: [...record.values]
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return schema.duplicates !== "first";
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
142
230
|
* Whether a flag kind expects a value argument (vs. being a bare boolean).
|
|
143
231
|
*
|
|
144
232
|
* @param schema - Flag schema to check
|
|
145
233
|
* @returns `true` if the flag expects a value token after it
|
|
146
234
|
*/
|
|
147
235
|
function flagExpectsValue(schema) {
|
|
148
|
-
return schema.kind !== "boolean";
|
|
236
|
+
return schema.kind !== "boolean" && schema.kind !== "count";
|
|
149
237
|
}
|
|
150
238
|
/**
|
|
151
239
|
* Coerce a raw string to the flag's declared kind.
|
|
@@ -158,7 +246,22 @@ function flagExpectsValue(schema) {
|
|
|
158
246
|
*/
|
|
159
247
|
function coerceFlagValue(flagName, raw, schema, displayName = `--${flagName}`) {
|
|
160
248
|
switch (schema.kind) {
|
|
161
|
-
case "string":
|
|
249
|
+
case "string": {
|
|
250
|
+
const violation = validateStringConstraints(raw, schema.stringConstraints);
|
|
251
|
+
if (violation !== void 0) throw new ParseError(`Invalid value '${raw}' for flag ${displayName}: ${describeStringConstraintViolation(violation)}`, {
|
|
252
|
+
code: "INVALID_VALUE",
|
|
253
|
+
details: {
|
|
254
|
+
flag: flagName,
|
|
255
|
+
input: displayName,
|
|
256
|
+
value: raw,
|
|
257
|
+
expected: "string",
|
|
258
|
+
constraint: violation.kind,
|
|
259
|
+
..."bound" in violation ? { bound: violation.bound } : {},
|
|
260
|
+
..."pattern" in violation ? { pattern: violation.pattern } : {}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
return raw;
|
|
264
|
+
}
|
|
162
265
|
case "number": {
|
|
163
266
|
const n = Number(raw);
|
|
164
267
|
if (Number.isNaN(n)) throw new ParseError(`Invalid number value '${raw}' for flag ${displayName}`, {
|
|
@@ -236,6 +339,20 @@ function coerceFlagValue(flagName, raw, schema, displayName = `--${flagName}`) {
|
|
|
236
339
|
cause: err
|
|
237
340
|
});
|
|
238
341
|
}
|
|
342
|
+
case "count": {
|
|
343
|
+
const n = raw.trim() === "" ? NaN : Number(raw);
|
|
344
|
+
if (!Number.isInteger(n) || n < 0) throw new ParseError(`Invalid count value '${raw}' for flag ${displayName}. Use a non-negative integer`, {
|
|
345
|
+
code: "INVALID_VALUE",
|
|
346
|
+
details: {
|
|
347
|
+
flag: flagName,
|
|
348
|
+
input: displayName,
|
|
349
|
+
value: raw,
|
|
350
|
+
expected: "count"
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
return n;
|
|
354
|
+
}
|
|
355
|
+
case "keyValue": return parseKeyValuePair(flagName, raw, displayName);
|
|
239
356
|
}
|
|
240
357
|
}
|
|
241
358
|
/**
|
|
@@ -319,6 +436,7 @@ function coerceArgValue(argName, raw, schema) {
|
|
|
319
436
|
*
|
|
320
437
|
* @param schema - The command schema to parse against
|
|
321
438
|
* @param argv - Raw argv strings (NOT including the command name itself)
|
|
439
|
+
* @param options - Parser behavior toggles (see {@link ParseOptions})
|
|
322
440
|
* @returns Parsed flag and arg values
|
|
323
441
|
* @throws ParseError for unknown flags, missing values, type mismatches
|
|
324
442
|
*
|
|
@@ -328,11 +446,12 @@ function coerceArgValue(argName, raw, schema) {
|
|
|
328
446
|
* // => { args: { target: 'production' }, flags: { force: true } }
|
|
329
447
|
* ```
|
|
330
448
|
*/
|
|
331
|
-
function parse(schema, argv) {
|
|
449
|
+
function parse(schema, argv, options) {
|
|
332
450
|
const tokens = tokenize(argv);
|
|
333
|
-
const flagLookup = buildFlagLookup(schema.flags);
|
|
451
|
+
const flagLookup = buildFlagLookup(schema.flags, options);
|
|
334
452
|
const flags = {};
|
|
335
453
|
const positionals = [];
|
|
454
|
+
const occurrences = /* @__PURE__ */ new Map();
|
|
336
455
|
let i = 0;
|
|
337
456
|
while (i < tokens.length) {
|
|
338
457
|
const token = tokens[i];
|
|
@@ -347,10 +466,10 @@ function parse(schema, argv) {
|
|
|
347
466
|
continue;
|
|
348
467
|
}
|
|
349
468
|
if (token.kind === "long-flag") {
|
|
350
|
-
i = parseLongFlag(token, tokens, i, flagLookup, flags);
|
|
469
|
+
i = parseLongFlag(token, tokens, i, flagLookup, flags, occurrences);
|
|
351
470
|
continue;
|
|
352
471
|
}
|
|
353
|
-
i = parseShortFlags(token, tokens, i, flagLookup, flags);
|
|
472
|
+
i = parseShortFlags(token, tokens, i, flagLookup, flags, occurrences);
|
|
354
473
|
}
|
|
355
474
|
return {
|
|
356
475
|
flags,
|
|
@@ -363,11 +482,12 @@ function parse(schema, argv) {
|
|
|
363
482
|
* @param token - Long-flag token to process
|
|
364
483
|
* @param tokens - Full token array (for lookahead)
|
|
365
484
|
* @param startIdx - Current index of `token` in the array
|
|
366
|
-
* @param flagLookup -
|
|
485
|
+
* @param flagLookup - Spelling → {@link FlagLookupEntry} map from {@link buildFlagLookup}
|
|
367
486
|
* @param flags - Mutable accumulator for resolved flag values
|
|
487
|
+
* @param occurrences - Per-parse duplicate-occurrence accumulator
|
|
368
488
|
* @returns Next index to continue parsing from
|
|
369
489
|
*/
|
|
370
|
-
function parseLongFlag(token, tokens, startIdx, flagLookup, flags) {
|
|
490
|
+
function parseLongFlag(token, tokens, startIdx, flagLookup, flags, occurrences) {
|
|
371
491
|
const entry = flagLookup.get(token.name);
|
|
372
492
|
if (!entry) {
|
|
373
493
|
const suggestion = suggestFlag(token.name, flagLookup);
|
|
@@ -380,18 +500,36 @@ function parseLongFlag(token, tokens, startIdx, flagLookup, flags) {
|
|
|
380
500
|
...suggestion ? { suggest: `--${suggestion}` } : {}
|
|
381
501
|
});
|
|
382
502
|
}
|
|
383
|
-
const
|
|
503
|
+
const { name: canonicalName, schema: flagSchema, negated } = entry;
|
|
504
|
+
const displayName = `--${token.name}`;
|
|
505
|
+
if (negated) {
|
|
506
|
+
if (token.value !== void 0) throw new ParseError(`Flag ${displayName} does not take a value`, {
|
|
507
|
+
code: "INVALID_VALUE",
|
|
508
|
+
details: {
|
|
509
|
+
flag: canonicalName,
|
|
510
|
+
input: token.name,
|
|
511
|
+
value: token.value
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, false, displayName)) flags[canonicalName] = false;
|
|
515
|
+
return startIdx + 1;
|
|
516
|
+
}
|
|
384
517
|
if (!flagExpectsValue(flagSchema)) {
|
|
385
|
-
if (token.value !== void 0)
|
|
386
|
-
|
|
518
|
+
if (token.value !== void 0) {
|
|
519
|
+
const coerced = coerceFlagValue(canonicalName, token.value, flagSchema, displayName);
|
|
520
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, coerced, displayName)) flags[canonicalName] = coerced;
|
|
521
|
+
} else if (flagSchema.kind === "count") {
|
|
522
|
+
const existing = flags[canonicalName];
|
|
523
|
+
flags[canonicalName] = (typeof existing === "number" ? existing : 0) + 1;
|
|
524
|
+
} else if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, true, displayName)) flags[canonicalName] = true;
|
|
387
525
|
return startIdx + 1;
|
|
388
526
|
}
|
|
389
527
|
if (token.value !== void 0) {
|
|
390
|
-
setFlagValue(flags, canonicalName, flagSchema, token.value);
|
|
528
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, token.value, displayName)) setFlagValue(flags, canonicalName, flagSchema, token.value);
|
|
391
529
|
return startIdx + 1;
|
|
392
530
|
}
|
|
393
531
|
const nextToken = tokens[startIdx + 1];
|
|
394
|
-
if (nextToken?.kind !== "positional") throw new ParseError(`Flag
|
|
532
|
+
if (nextToken?.kind !== "positional") throw new ParseError(`Flag ${displayName} requires a value`, {
|
|
395
533
|
code: "MISSING_VALUE",
|
|
396
534
|
details: {
|
|
397
535
|
flag: canonicalName,
|
|
@@ -399,7 +537,7 @@ function parseLongFlag(token, tokens, startIdx, flagLookup, flags) {
|
|
|
399
537
|
kind: flagSchema.kind
|
|
400
538
|
}
|
|
401
539
|
});
|
|
402
|
-
setFlagValue(flags, canonicalName, flagSchema, nextToken.value,
|
|
540
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, nextToken.value, displayName)) setFlagValue(flags, canonicalName, flagSchema, nextToken.value, displayName);
|
|
403
541
|
return startIdx + 2;
|
|
404
542
|
}
|
|
405
543
|
/**
|
|
@@ -408,11 +546,12 @@ function parseLongFlag(token, tokens, startIdx, flagLookup, flags) {
|
|
|
408
546
|
* @param token - Short-flags token to expand
|
|
409
547
|
* @param tokens - Full token array (for lookahead)
|
|
410
548
|
* @param startIdx - Current index of `token` in the array
|
|
411
|
-
* @param flagLookup -
|
|
549
|
+
* @param flagLookup - Spelling → {@link FlagLookupEntry} map from {@link buildFlagLookup}
|
|
412
550
|
* @param flags - Mutable accumulator for resolved flag values
|
|
551
|
+
* @param occurrences - Per-parse duplicate-occurrence accumulator
|
|
413
552
|
* @returns Next index to continue parsing from
|
|
414
553
|
*/
|
|
415
|
-
function parseShortFlags(token, tokens, startIdx, flagLookup, flags) {
|
|
554
|
+
function parseShortFlags(token, tokens, startIdx, flagLookup, flags, occurrences) {
|
|
416
555
|
const { chars } = token;
|
|
417
556
|
let nextIdx = startIdx + 1;
|
|
418
557
|
for (let ci = 0; ci < chars.length; ci++) {
|
|
@@ -422,13 +561,18 @@ function parseShortFlags(token, tokens, startIdx, flagLookup, flags) {
|
|
|
422
561
|
code: "UNKNOWN_FLAG",
|
|
423
562
|
details: { flag: ch }
|
|
424
563
|
});
|
|
425
|
-
const
|
|
564
|
+
const { name: canonicalName, schema: flagSchema } = entry;
|
|
565
|
+
const displayName = `-${ch}`;
|
|
426
566
|
if (!flagExpectsValue(flagSchema)) {
|
|
427
|
-
|
|
567
|
+
if (flagSchema.kind === "count") {
|
|
568
|
+
const existing = flags[canonicalName];
|
|
569
|
+
flags[canonicalName] = (typeof existing === "number" ? existing : 0) + 1;
|
|
570
|
+
} else if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, true, displayName)) flags[canonicalName] = true;
|
|
428
571
|
continue;
|
|
429
572
|
}
|
|
430
573
|
if (ci < chars.length - 1) {
|
|
431
|
-
|
|
574
|
+
const inlineValue = chars.slice(ci + 1);
|
|
575
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, inlineValue, displayName)) setFlagValue(flags, canonicalName, flagSchema, inlineValue, displayName);
|
|
432
576
|
break;
|
|
433
577
|
}
|
|
434
578
|
const nextToken = tokens[nextIdx];
|
|
@@ -440,7 +584,7 @@ function parseShortFlags(token, tokens, startIdx, flagLookup, flags) {
|
|
|
440
584
|
kind: flagSchema.kind
|
|
441
585
|
}
|
|
442
586
|
});
|
|
443
|
-
setFlagValue(flags, canonicalName, flagSchema, nextToken.value,
|
|
587
|
+
if (recordFlagOccurrence(occurrences, canonicalName, flagSchema, nextToken.value, displayName)) setFlagValue(flags, canonicalName, flagSchema, nextToken.value, displayName);
|
|
444
588
|
nextIdx++;
|
|
445
589
|
}
|
|
446
590
|
return nextIdx;
|
|
@@ -454,12 +598,42 @@ function parseShortFlags(token, tokens, startIdx, flagLookup, flags) {
|
|
|
454
598
|
* @param rawValue - Raw string value from argv
|
|
455
599
|
*/
|
|
456
600
|
function setFlagValue(flags, name, schema, rawValue, displayName = `--${name}`) {
|
|
457
|
-
const coerced = coerceFlagValue(name, rawValue, schema, displayName);
|
|
458
601
|
if (schema.kind === "array") {
|
|
602
|
+
const coercedParts = (schema.separator !== void 0 ? rawValue.split(schema.separator) : [rawValue]).filter((part) => schema.separator === void 0 || part.length > 0).map((part) => coerceFlagValue(name, part, schema, displayName));
|
|
459
603
|
const existing = flags[name];
|
|
460
|
-
if (Array.isArray(existing)) existing.push(
|
|
461
|
-
else flags[name] =
|
|
462
|
-
|
|
604
|
+
if (Array.isArray(existing)) existing.push(...coercedParts);
|
|
605
|
+
else flags[name] = coercedParts;
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (schema.kind === "keyValue") {
|
|
609
|
+
const pair = parseKeyValuePair(name, rawValue, displayName);
|
|
610
|
+
const existing = flags[name];
|
|
611
|
+
flags[name] = Object.fromEntries([...isPlainRecord(existing) ? Object.entries(existing) : [], pair]);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
flags[name] = coerceFlagValue(name, rawValue, schema, displayName);
|
|
615
|
+
}
|
|
616
|
+
/** Narrow to a mutable string-record accumulator (keyValue flags only ever store these). */
|
|
617
|
+
function isPlainRecord(value) {
|
|
618
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Split a `KEY=VALUE` token at the first `=`.
|
|
622
|
+
*
|
|
623
|
+
* @throws ParseError when the token has no `=` or an empty key.
|
|
624
|
+
*/
|
|
625
|
+
function parseKeyValuePair(flagName, raw, displayName = `--${flagName}`) {
|
|
626
|
+
const eq = raw.indexOf("=");
|
|
627
|
+
if (eq <= 0) throw new ParseError(`Invalid value '${raw}' for flag ${displayName}. Use KEY=VALUE`, {
|
|
628
|
+
code: "INVALID_VALUE",
|
|
629
|
+
details: {
|
|
630
|
+
flag: flagName,
|
|
631
|
+
input: displayName,
|
|
632
|
+
value: raw,
|
|
633
|
+
expected: "key=value"
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
return [raw.slice(0, eq), raw.slice(eq + 1)];
|
|
463
637
|
}
|
|
464
638
|
/**
|
|
465
639
|
* Map positional values to named args based on schema ordering.
|
|
@@ -508,13 +682,11 @@ function suggestFlag(input, lookup) {
|
|
|
508
682
|
let bestName;
|
|
509
683
|
let bestDist = Number.POSITIVE_INFINITY;
|
|
510
684
|
const threshold = Math.max(2, Math.floor(input.length / 2));
|
|
511
|
-
for (const key of lookup
|
|
512
|
-
|
|
513
|
-
if (entry ===
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
if (key.length < 2) continue;
|
|
517
|
-
if (key !== canonicalName && alias?.hidden) continue;
|
|
685
|
+
for (const [key, entry] of lookup) {
|
|
686
|
+
if (key.length < 2 || entry.parity) continue;
|
|
687
|
+
if (entry.negated && entry.schema.negation?.hidden === true) continue;
|
|
688
|
+
const alias = entry.schema.aliases.find((candidate) => candidate.name === key);
|
|
689
|
+
if (key !== entry.name && !entry.negated && alias?.hidden) continue;
|
|
518
690
|
const dist = levenshtein(input, key);
|
|
519
691
|
if (dist < bestDist && dist <= threshold) {
|
|
520
692
|
bestDist = dist;
|
|
@@ -552,4 +724,4 @@ function levenshtein(a, b) {
|
|
|
552
724
|
return row[aLen] ?? 0;
|
|
553
725
|
}
|
|
554
726
|
//#endregion
|
|
555
|
-
export { buildFlagLookup, flagExpectsValue, includesBeforeSeparator, parse, stripBeforeSeparator, tokenize };
|
|
727
|
+
export { buildFlagLookup, camelToKebab, flagExpectsValue, includesBeforeSeparator, kebabToCamel, parse, stripBeforeSeparator, tokenize };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfirmPromptConfig, InputPromptConfig, PromptConfig, PromptResult, SelectChoice } from "../schema/prompt.mjs";
|
|
2
2
|
import { WriteFn } from "../output/writer.mjs";
|
|
3
|
+
import "../output/index.mjs";
|
|
3
4
|
//#region src/core/prompt/index.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* A select prompt config with choices guaranteed non-empty.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeprecationWarning } from "./contracts.mjs";
|
|
2
2
|
import { CommandArgEntry } from "../schema/command.mjs";
|
|
3
|
-
|
|
3
|
+
import "../schema/index.mjs";
|
|
4
4
|
//#region src/core/resolve/args.d.ts
|
|
5
5
|
/** Walk every declared arg through the resolution chain (cli -> stdin -> env -> default), collecting deprecations and throwing aggregated errors. */
|
|
6
6
|
declare function resolveArgs(argEntries: readonly CommandArgEntry[], parsedArgs: Readonly<Record<string, unknown>>, stdinData: string | null | undefined, env: Readonly<Record<string, string | undefined>>, deprecations: DeprecationWarning[]): Readonly<Record<string, unknown>>;
|
|
@@ -2,7 +2,7 @@ import { ArgSchema } from "../schema/arg.mjs";
|
|
|
2
2
|
import { FlagSchema } from "../schema/flag.mjs";
|
|
3
3
|
import { ArgDiagnosticSource, FlagDiagnosticSource } from "./contracts.mjs";
|
|
4
4
|
import { ValidationError } from "../errors/index.mjs";
|
|
5
|
-
|
|
5
|
+
import "../schema/index.mjs";
|
|
6
6
|
//#region src/core/resolve/coerce.d.ts
|
|
7
7
|
type CoerceSource = FlagDiagnosticSource;
|
|
8
8
|
/** Discriminated result of a value coercion attempt — success with the coerced value, or failure with a structured validation error. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { describeNumberConstraintViolation, validateNumberConstraints } from "../schema/number-constraints.mjs";
|
|
2
1
|
import { ValidationError } from "../errors/index.mjs";
|
|
2
|
+
import { describeNumberConstraintViolation, validateNumberConstraints } from "../schema/number-constraints.mjs";
|
|
3
|
+
import { describeStringConstraintViolation, validateStringConstraints } from "../schema/string-constraints.mjs";
|
|
3
4
|
import { toSharedArgPropertySchema, toSharedFlagPropertySchema } from "./property.mjs";
|
|
4
5
|
//#region src/core/resolve/coerce.ts
|
|
5
6
|
function sourceLabel(source) {
|
|
@@ -62,6 +63,36 @@ function finalizeNumber(flagName, source, raw, value, constraints) {
|
|
|
62
63
|
})
|
|
63
64
|
};
|
|
64
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Apply string constraints to an already-string value. Shares the single
|
|
68
|
+
* {@link validateStringConstraints} check used by the parse path, so the two
|
|
69
|
+
* boundaries cannot drift. On violation, returns a `CONSTRAINT_VIOLATED`
|
|
70
|
+
* failure mirroring {@link finalizeNumber}.
|
|
71
|
+
*/
|
|
72
|
+
function finalizeString(flagName, source, value, constraints) {
|
|
73
|
+
const violation = validateStringConstraints(value, constraints);
|
|
74
|
+
if (violation === void 0) return {
|
|
75
|
+
ok: true,
|
|
76
|
+
value
|
|
77
|
+
};
|
|
78
|
+
const reason = describeStringConstraintViolation(violation);
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
error: new ValidationError(`Invalid value '${value}' ${sourceLabel(source)} for flag --${flagName}: ${reason}`, {
|
|
82
|
+
code: "CONSTRAINT_VIOLATED",
|
|
83
|
+
details: {
|
|
84
|
+
flag: flagName,
|
|
85
|
+
...sourceDetails(source),
|
|
86
|
+
value,
|
|
87
|
+
expected: "string",
|
|
88
|
+
constraint: violation.kind,
|
|
89
|
+
..."bound" in violation ? { bound: violation.bound } : {},
|
|
90
|
+
..."pattern" in violation ? { pattern: violation.pattern } : {}
|
|
91
|
+
},
|
|
92
|
+
suggest: source.kind === "env" ? `Set ${source.envVar} to a valid string` : source.kind === "config" ? `Set ${source.configPath} to a valid string in your config` : `Enter a valid value for --${flagName}`
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
}
|
|
65
96
|
/** Coerce a raw value from env/config/prompt into the type declared by a flag schema. */
|
|
66
97
|
function coerceValue(flagName, source, raw, schema) {
|
|
67
98
|
const sharedSchema = toSharedFlagPropertySchema(schema);
|
|
@@ -108,7 +139,7 @@ function coerceValue(flagName, source, raw, schema) {
|
|
|
108
139
|
ok: true,
|
|
109
140
|
value: []
|
|
110
141
|
};
|
|
111
|
-
const parts = raw.split(",");
|
|
142
|
+
const parts = raw.split(schema.separator ?? ",").filter((part) => part.length > 0);
|
|
112
143
|
if (schema.elementSchema) {
|
|
113
144
|
const coerced = [];
|
|
114
145
|
for (const part of parts) {
|
|
@@ -127,24 +158,50 @@ function coerceValue(flagName, source, raw, schema) {
|
|
|
127
158
|
};
|
|
128
159
|
}
|
|
129
160
|
return coercionError(flagName, source, "TYPE_MISMATCH", "array", raw, "Invalid array value", source.kind === "env" ? `Set ${source.envVar} to comma-separated values` : source.kind === "config" ? `Set ${source.configPath} to an array in your config` : `Provide valid values for --${flagName}`);
|
|
161
|
+
case "count": {
|
|
162
|
+
const value = typeof raw === "string" ? raw.trim() === "" ? NaN : Number(raw) : raw;
|
|
163
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0) return {
|
|
164
|
+
ok: true,
|
|
165
|
+
value
|
|
166
|
+
};
|
|
167
|
+
return coercionError(flagName, source, "TYPE_MISMATCH", "count", raw, typeof raw === "string" ? `Invalid count value '${raw}'` : "Invalid count value", source.kind === "env" ? `Set ${source.envVar} to a non-negative integer` : source.kind === "config" ? `Set ${source.configPath} to a non-negative integer in your config` : `Enter a non-negative integer for --${flagName}`);
|
|
168
|
+
}
|
|
169
|
+
case "keyValue":
|
|
170
|
+
if (isStringRecord(raw)) return {
|
|
171
|
+
ok: true,
|
|
172
|
+
value: { ...raw }
|
|
173
|
+
};
|
|
174
|
+
if (typeof raw === "string") {
|
|
175
|
+
if (raw === "") return {
|
|
176
|
+
ok: true,
|
|
177
|
+
value: {}
|
|
178
|
+
};
|
|
179
|
+
const pairs = [];
|
|
180
|
+
for (const pair of raw.split(",").filter((segment) => segment.length > 0)) {
|
|
181
|
+
const eq = pair.indexOf("=");
|
|
182
|
+
if (eq <= 0) return coercionError(flagName, source, "TYPE_MISMATCH", "key=value", raw, `Invalid key-value pair '${pair}'`, source.kind === "env" ? `Set ${source.envVar} to comma-separated KEY=VALUE pairs` : source.kind === "config" ? `Set ${source.configPath} to an object with string values` : `Use KEY=VALUE for --${flagName}`);
|
|
183
|
+
pairs.push([pair.slice(0, eq), pair.slice(eq + 1)]);
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
ok: true,
|
|
187
|
+
value: Object.fromEntries(pairs)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return coercionError(flagName, source, "TYPE_MISMATCH", "key=value", raw, "Invalid key-value value", source.kind === "env" ? `Set ${source.envVar} to comma-separated KEY=VALUE pairs` : source.kind === "config" ? `Set ${source.configPath} to an object with string values` : `Use KEY=VALUE for --${flagName}`);
|
|
130
191
|
}
|
|
131
192
|
throw new Error(`Unreachable flag coercion kind: ${schema.kind}`);
|
|
132
193
|
}
|
|
194
|
+
/** Narrow config-sourced objects to plain string-valued records. */
|
|
195
|
+
function isStringRecord(value) {
|
|
196
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
197
|
+
return Object.values(value).every((entry) => typeof entry === "string");
|
|
198
|
+
}
|
|
133
199
|
function coerceSharedPropertyValue(flagName, source, raw, schema) {
|
|
134
200
|
switch (schema.kind) {
|
|
135
201
|
case "string":
|
|
136
|
-
if (typeof raw === "string") return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
if (source.kind === "prompt") return {
|
|
141
|
-
ok: true,
|
|
142
|
-
value: String(raw)
|
|
143
|
-
};
|
|
144
|
-
if (source.kind === "config" && (typeof raw === "number" || typeof raw === "boolean")) return {
|
|
145
|
-
ok: true,
|
|
146
|
-
value: String(raw)
|
|
147
|
-
};
|
|
202
|
+
if (typeof raw === "string") return finalizeString(flagName, source, raw, schema.stringConstraints);
|
|
203
|
+
if (source.kind === "prompt") return finalizeString(flagName, source, String(raw), schema.stringConstraints);
|
|
204
|
+
if (source.kind === "config" && (typeof raw === "number" || typeof raw === "boolean")) return finalizeString(flagName, source, String(raw), schema.stringConstraints);
|
|
148
205
|
return coercionError(flagName, source, "TYPE_MISMATCH", "string", raw, "Invalid string value", source.kind === "config" ? `Set ${source.configPath} to a string in your config` : `Enter a valid string for --${flagName}`);
|
|
149
206
|
case "number":
|
|
150
207
|
if (typeof raw === "number") {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ParseResult } from "../parse/index.mjs";
|
|
2
1
|
import { PromptEngine } from "../prompt/index.mjs";
|
|
3
2
|
import { CommandSchema } from "../schema/command.mjs";
|
|
4
|
-
|
|
3
|
+
import "../schema/index.mjs";
|
|
4
|
+
import { ParseResult } from "../parse/index.mjs";
|
|
5
5
|
//#region src/core/resolve/contracts.d.ts
|
|
6
6
|
/** Ordered flag resolution stages owned by the resolver. */
|
|
7
|
-
declare const FLAG_RESOLUTION_ORDER: readonly [
|
|
7
|
+
declare const FLAG_RESOLUTION_ORDER: readonly ["cli", "env", "config", "prompt", "default"];
|
|
8
8
|
/** Ordered arg resolution stages owned by the resolver. */
|
|
9
|
-
declare const ARG_RESOLUTION_ORDER: readonly [
|
|
9
|
+
declare const ARG_RESOLUTION_ORDER: readonly ["cli", "stdin", "env", "default"];
|
|
10
10
|
/** Stable flag-source labels for precedence and diagnostics. */
|
|
11
11
|
type FlagResolutionStage = (typeof FLAG_RESOLUTION_ORDER)[number];
|
|
12
12
|
/** Stable arg-source labels for precedence and diagnostics. */
|
|
@@ -48,6 +48,16 @@ interface ResolveOptions {
|
|
|
48
48
|
readonly config?: Readonly<Record<string, unknown>>;
|
|
49
49
|
/** Interactive prompt engine; absent in non-TTY / CI contexts. */
|
|
50
50
|
readonly prompter?: PromptEngine;
|
|
51
|
+
/**
|
|
52
|
+
* Filesystem probe for `flag.path()` checks: what exists at the path, or
|
|
53
|
+
* `null` when nothing does. When absent, path checks are skipped.
|
|
54
|
+
*/
|
|
55
|
+
readonly stat?: (path: string) => Promise<'file' | 'directory' | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Recursive directory creation for `flag.path()` `create` checks. When
|
|
58
|
+
* absent, missing paths are not created and existence rules apply as-is.
|
|
59
|
+
*/
|
|
60
|
+
readonly mkdir?: (path: string) => Promise<void>;
|
|
51
61
|
}
|
|
52
62
|
/** Structured deprecation notice emitted for explicitly sourced values. */
|
|
53
63
|
interface DeprecationWarning {
|
|
@@ -3,10 +3,17 @@ import { FlagKind, FlagSchema } from "../schema/flag.mjs";
|
|
|
3
3
|
import { PromptEngine } from "../prompt/index.mjs";
|
|
4
4
|
import { DeprecationWarning } from "./contracts.mjs";
|
|
5
5
|
import { ErasedInteractiveResolver } from "../schema/command.mjs";
|
|
6
|
-
|
|
7
6
|
//#region src/core/resolve/flags.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Filesystem probe injected by the caller for `flag.path()` checks.
|
|
9
|
+
*
|
|
10
|
+
* Returns what exists at the path, or `null` when nothing does.
|
|
11
|
+
*/
|
|
12
|
+
type StatFn = (path: string) => Promise<'file' | 'directory' | null>;
|
|
13
|
+
/** Recursive directory creation injected by the caller for `flag.path()` `create` checks. */
|
|
14
|
+
type MkdirFn = (path: string) => Promise<void>;
|
|
8
15
|
/** Walk every declared flag through the resolution chain (cli -> env -> config -> prompt -> default), collecting deprecations and throwing aggregated errors. */
|
|
9
|
-
declare function resolveFlags(flagSchemas: Readonly<Record<string, FlagSchema>>, parsedFlags: Readonly<Record<string, unknown>>, env: Readonly<Record<string, string | undefined>>, config: Readonly<Record<string, unknown>>, prompter: PromptEngine | undefined, interactive: ErasedInteractiveResolver | undefined, deprecations: DeprecationWarning[]): Promise<Readonly<Record<string, unknown>>>;
|
|
16
|
+
declare function resolveFlags(flagSchemas: Readonly<Record<string, FlagSchema>>, parsedFlags: Readonly<Record<string, unknown>>, env: Readonly<Record<string, string | undefined>>, config: Readonly<Record<string, unknown>>, prompter: PromptEngine | undefined, interactive: ErasedInteractiveResolver | undefined, deprecations: DeprecationWarning[], stat: StatFn | undefined, mkdir: MkdirFn | undefined): Promise<Readonly<Record<string, unknown>>>;
|
|
10
17
|
/** Maps each flag kind to the prompt kinds that produce compatible values. */
|
|
11
18
|
declare const COMPATIBLE_PROMPT_KINDS: Record<FlagKind, readonly PromptKind[]>;
|
|
12
19
|
//#endregion
|