politty 0.10.1 → 0.11.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 toiroakr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -19,7 +19,7 @@ From simple scripts to complex CLI tools with subcommands, validation, and auto-
19
19
 
20
20
  ## Requirements
21
21
 
22
- - Node.js >= 18
22
+ - Node.js >= 20.12.0 (excluding 21.0.0 - 21.6.x)
23
23
  - Zod >= 4.2.1
24
24
 
25
25
  ## Installation
@@ -264,7 +264,6 @@ CLI entry point. Handles signals and calls `process.exit()`.
264
264
  ```typescript
265
265
  runMain(command, {
266
266
  version: "1.0.0", // Displayed with --version flag
267
- argv: process.argv, // Custom argv
268
267
  });
269
268
  ```
270
269
 
@@ -57,8 +57,7 @@ interface ResolvedFieldMeta {
57
57
  * help, generated docs, and shell completions.
58
58
  * - `false`: neither the default `--no-<cliName>` nor any custom name is
59
59
  * accepted; the field only responds to the positive flag.
60
- * - `undefined`: the default `--no-<cliName>` is accepted by the parser
61
- * but hidden from help/docs/completions.
60
+ * - `undefined`: no negation form is accepted or shown.
62
61
  *
63
62
  * Only applies to boolean fields; populated as `undefined` otherwise.
64
63
  */
@@ -758,18 +757,17 @@ interface BaseArgMeta<TValue = unknown> {
758
757
  /**
759
758
  * Control the boolean negation option.
760
759
  *
761
- * Boolean fields automatically accept `--no-<cliName>` (and the camelCase
762
- * `--no<Name>` form) to set the value to `false`. By default this form is
763
- * accepted by the parser but hidden from help, generated docs, and shell
764
- * completions. This option lets you customize or expose that behavior:
760
+ * Boolean fields accept `--no-<cliName>` (and the camelCase `--no<Name>`
761
+ * form) to set the value to `false` only when `negation: true` is set.
762
+ * By default no negation form is accepted. This option lets you customize
763
+ * or expose that behavior:
765
764
  *
766
765
  * - `string` — replaces the auto-generated `--no-*` form with a custom
767
766
  * name. The default `--no-*` is no longer recognized.
768
- * - `true` — opt-in to advertising the default `--no-<cliName>` form in
769
- * help, generated docs, and shell completions. Parser behavior is
770
- * unchanged.
771
- * - `false` — disables negation entirely; neither the default `--no-*`
772
- * nor any custom name is accepted.
767
+ * - `true` — enables the default `--no-<cliName>` form and advertises it
768
+ * in help, generated docs, and shell completions.
769
+ * - `false` — disables negation entirely; same as the default, but explicit.
770
+ * Neither the default `--no-*` nor any custom name is accepted.
773
771
  *
774
772
  * String values follow the same naming conventions as `cliName`
775
773
  * (kebab-case is recommended). Only valid on boolean fields; setting
@@ -786,7 +784,7 @@ interface BaseArgMeta<TValue = unknown> {
786
784
  * // Accepts: --cache (true), --disable-cache (false)
787
785
  * // No longer accepts: --no-cache
788
786
  *
789
- * // Expose default `--no-X` in help/docs/completion
787
+ * // Enable default `--no-X` in parsing/help/docs/completion
790
788
  * verbose: arg(z.boolean().default(false), {
791
789
  * negation: true,
792
790
  * })
@@ -941,4 +939,4 @@ declare function arg<T extends z.ZodType>(schema: T): T;
941
939
  declare function arg<T extends z.ZodType, M extends ArgMeta<z.output<T>>>(schema: T, meta: ValidateArgMeta<M, z.output<T>>): T;
942
940
  //#endregion
943
941
  export { toKebabCase as $, LogStream as A, SetupContext as B, Example as C, IsEmpty as D, GlobalSetupContext as E, RunCommandOptions as F, isLazyCommand as G, SubCommandsRecord as H, RunResult as I, ResolvedFieldMeta as J, lazy as K, RunResultFailure as L, MainOptions as M, NonRunnableCommand as N, LogEntry as O, PromptResolver as P, toCamelCase as Q, RunResultSuccess as R, CommandBase as S, GlobalCleanupContext as T, UnknownSubcommandHandler as U, SubCommandValue as V, LazyCommand as W, extractFields as X, UnknownKeysMode as Y, getUnknownKeysMode as Z, AnyCommand as _, EffectContext as a, CollectedLogs as b, arg as c, ResolvedExpandCandidate as d, CompletionDirectiveMask as f, DynamicCompletionResult as g, DynamicCompletionResolver as h, CustomCompletion as i, Logger as j, LogLevel as k, ExpandCandidate as l, DynamicCompletionContext as m, CompletionMeta as n, PromptMeta as o, DynamicCompletionCandidate as p, ExtractedFields as q, CompletionType as r, PromptType as s, ArgMeta as t, ExpandCompletion as u, ArgsSchema as v, GlobalArgs as w, Command as x, CleanupContext as y, RunnableCommand as z };
944
- //# sourceMappingURL=arg-registry-BN3I-XON.d.ts.map
942
+ //# sourceMappingURL=arg-registry-aHbip9Hs.d.ts.map
package/dist/augment.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as ArgMeta } from "./arg-registry-BN3I-XON.js";
1
+ import { t as ArgMeta } from "./arg-registry-aHbip9Hs.js";
2
2
 
3
3
  //#region src/augment.d.ts
4
4
  declare module "zod" {
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { n as runMain } from "./runner-BCMB67GV.js";
2
+ import { n as runMain } from "./runner-DpsAMVta.js";
3
3
  import { t as arg } from "./arg-registry-BeLLAW5-.js";
4
4
  import { n as defineCommand } from "./command-B4yA4LXX.js";
5
- import { p as generateBundledCompletionWorker } from "./completion-DwTFOtQk.js";
5
+ import { p as generateBundledCompletionWorker } from "./completion-Rx2DiNBn.js";
6
6
  import "./index.js";
7
7
  import { z } from "zod";
8
8
 
@@ -1,3 +1,3 @@
1
- import { f as CompletionDirectiveMask, g as DynamicCompletionResult, h as DynamicCompletionResolver, m as DynamicCompletionContext, p as DynamicCompletionCandidate } from "../arg-registry-BN3I-XON.js";
2
- import { A as BundledWorkerOptions, C as CandidateResult, D as CompletionContext, E as generateCandidates, F as CompletionMode, I as CompletionOptions, L as CompletionResult, M as CompletableSubcommand, N as CompletionData, O as CompletionType, P as CompletionGenerator, R as ShellType, S as hasCompleteCommand, T as CompletionDirective, _ as extractCompletionData, a as detectShell, b as formatForShell, c as withCompletionCommand, d as GenerateBundledCompletionWorkerOptions, f as GenerateBundledCompletionWorkerResult, g as validateBundledWorkerFile, h as generateBundledCompletionWorker, i as createRefreshCompletionCommand, j as CompletableOption, k as parseCompletionContext, l as ValueCompletionField, m as defaultBundledWorkerOutputPath, n as createCompletionCommand, o as generateCompletion, p as bundledWorkerShellExtension, r as createCompletionWorkerPathCommand, s as getSupportedShells, t as WithCompletionOptions, u as resolveValueCompletion, v as extractPositionals, w as CompletionCandidate, x as createDynamicCompleteCommand, y as ShellFormatOptions } from "../index-CtRrTVTL.js";
1
+ import { f as CompletionDirectiveMask, g as DynamicCompletionResult, h as DynamicCompletionResolver, m as DynamicCompletionContext, p as DynamicCompletionCandidate } from "../arg-registry-aHbip9Hs.js";
2
+ import { A as BundledWorkerOptions, C as CandidateResult, D as CompletionContext, E as generateCandidates, F as CompletionMode, I as CompletionOptions, L as CompletionResult, M as CompletableSubcommand, N as CompletionData, O as CompletionType, P as CompletionGenerator, R as ShellType, S as hasCompleteCommand, T as CompletionDirective, _ as extractCompletionData, a as detectShell, b as formatForShell, c as withCompletionCommand, d as GenerateBundledCompletionWorkerOptions, f as GenerateBundledCompletionWorkerResult, g as validateBundledWorkerFile, h as generateBundledCompletionWorker, i as createRefreshCompletionCommand, j as CompletableOption, k as parseCompletionContext, l as ValueCompletionField, m as defaultBundledWorkerOutputPath, n as createCompletionCommand, o as generateCompletion, p as bundledWorkerShellExtension, r as createCompletionWorkerPathCommand, s as getSupportedShells, t as WithCompletionOptions, u as resolveValueCompletion, v as extractPositionals, w as CompletionCandidate, x as createDynamicCompleteCommand, y as ShellFormatOptions } from "../index-dRZSB_t3.js";
3
3
  export { type BundledWorkerOptions, type CandidateResult, type CompletableOption, type CompletableSubcommand, type CompletionCandidate, type CompletionContext, type CompletionData, CompletionDirective, type CompletionDirectiveMask, type CompletionGenerator, type CompletionMode, type CompletionOptions, type CompletionResult, type CompletionType, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type ShellFormatOptions, type ShellType, type ValueCompletionField, WithCompletionOptions, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
@@ -1,3 +1,3 @@
1
- import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "../completion-DwTFOtQk.js";
1
+ import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "../completion-Rx2DiNBn.js";
2
2
 
3
3
  export { CompletionDirective, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
@@ -1,6 +1,6 @@
1
1
  import { t as arg } from "./arg-registry-BeLLAW5-.js";
2
2
  import { n as defineCommand } from "./command-B4yA4LXX.js";
3
- import { a as toCamelCase, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-CVHWm23M.js";
3
+ import { a as toCamelCase, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-GEuI_L0X.js";
4
4
  import { z } from "zod";
5
5
  import { execFile, execSync, spawn } from "node:child_process";
6
6
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -316,7 +316,7 @@ function extractOptionsFromSchema(schema) {
316
316
  takesValue: field.type !== "boolean",
317
317
  valueType: field.type,
318
318
  required: field.required,
319
- defaultNegationAccepted: field.type === "boolean" && (field.negation === void 0 || field.negation === true),
319
+ defaultNegationAccepted: field.type === "boolean" && field.negation === true,
320
320
  valueCompletion: resolveRuntimeCompletion(resolveValueCompletion(field))
321
321
  };
322
322
  });
@@ -376,7 +376,13 @@ function parsePreSubGlobals(tokens, globalOptions, globalParsedArgs) {
376
376
  }
377
377
  const parsed = parseOption(word);
378
378
  const opt = findOption(globalOptions, parsed);
379
- if (!opt) break;
379
+ if (!opt) {
380
+ if (isSuppressedDefaultNegation(globalOptions, parsed)) {
381
+ i++;
382
+ continue;
383
+ }
384
+ break;
385
+ }
380
386
  if (opt.takesValue) if (hasInlineValue(word)) {
381
387
  const eqIdx = word.indexOf("=");
382
388
  writeGlobal(opt, word.slice(eqIdx + 1));
@@ -470,7 +476,7 @@ function getSubcommandNames(command) {
470
476
  */
471
477
  function resolveSubcommand(command, name) {
472
478
  if (!command.subCommands) return null;
473
- const sub = command.subCommands[name];
479
+ const sub = Object.hasOwn(command.subCommands, name) ? command.subCommands[name] : void 0;
474
480
  if (sub) return resolveSubCommandMeta(sub);
475
481
  const canonical = resolveSubCommandAlias(command, name);
476
482
  if (canonical) return resolveSubCommandMeta(command.subCommands[canonical]);
@@ -513,20 +519,18 @@ function hasInlineValue(word) {
513
519
  return word.includes("=");
514
520
  }
515
521
  /**
516
- * For boolean options, the runtime parser accepts the implicit
517
- * `--no-<cliName>` (and camelCase `--noCliName`) form unless the user
518
- * opted out via `negation: false` or supplied a custom-string negation
519
- * (which suppresses the default form). Aliases participate too: a
520
- * boolean with `alias: "c"` accepts `--no-c` / `--noC` because the
521
- * runtime resolves the post-`no-` segment through `aliasMap`. Implicit
522
- * negation is LONG-FORM only — `-no-c` is never an accepted negation —
523
- * so callers must say so via `isLong` to prevent a short option from
524
- * being read as a negation.
522
+ * For boolean options, the runtime parser accepts the default
523
+ * `--no-<cliName>` (and camelCase `--noCliName`) form only when the user
524
+ * opts in via `negation: true`. Aliases participate too: a boolean with
525
+ * `alias: "c", negation: true` accepts `--no-c` / `--noC` because the
526
+ * runtime resolves the post-`no-` segment through `aliasMap`. Default
527
+ * negation is LONG-FORM only — `-no-c` is never an accepted negation — so
528
+ * callers must say so via `isLong` to prevent a short option from being read
529
+ * as a negation.
525
530
  */
526
- function isImplicitBooleanNegation(opt, name, isLong) {
531
+ function isDefaultBooleanNegationToken(opt, name, isLong) {
527
532
  if (!isLong) return false;
528
533
  if (opt.valueType !== "boolean") return false;
529
- if (opt.defaultNegationAccepted === false) return false;
530
534
  const candidates = [opt.cliName, ...opt.alias ?? []];
531
535
  for (const c of candidates) {
532
536
  const hyphenated = `no-${c}`;
@@ -535,6 +539,12 @@ function isImplicitBooleanNegation(opt, name, isLong) {
535
539
  }
536
540
  return false;
537
541
  }
542
+ function isImplicitBooleanNegation(opt, name, isLong) {
543
+ return opt.defaultNegationAccepted === true && isDefaultBooleanNegationToken(opt, name, isLong);
544
+ }
545
+ function isSuppressedDefaultNegation(options, parsed) {
546
+ return options.some((opt) => opt.defaultNegationAccepted !== true && isDefaultBooleanNegationToken(opt, parsed.name, parsed.isLong));
547
+ }
538
548
  /** True when `source` is hyphenated and its camelCase form equals `name`. */
539
549
  function matchesCamelCase(source, name) {
540
550
  return source !== void 0 && source.includes("-") && toCamelCase(source) === name;
@@ -561,8 +571,8 @@ function writeOptionValue(target, opt, value, arraysSeenInFrame) {
561
571
  }
562
572
  /**
563
573
  * True when the typed token is the boolean option's negation form — either
564
- * the explicit `negation` name (or its camelCase variant) or the implicit
565
- * `--no-<name>` form. Long-form only; short tokens are never negations.
574
+ * the explicit `negation` name (or its camelCase variant) or the opt-in
575
+ * default `--no-<name>` form. Long-form only; short tokens are never negations.
566
576
  */
567
577
  function isNegationOf(opt, parsed) {
568
578
  if (!parsed.isLong) return false;
@@ -1412,7 +1422,7 @@ function getSubNamesWithAliases(subs) {
1412
1422
  * sibling choices are known.
1413
1423
  */
1414
1424
  function fieldToOption(field, pending) {
1415
- const defaultNegationAccepted = field.type === "boolean" && (field.negation === void 0 || field.negation === true);
1425
+ const defaultNegationAccepted = field.type === "boolean" && field.negation === true;
1416
1426
  const opt = {
1417
1427
  name: field.name,
1418
1428
  cliName: field.cliName,
@@ -5596,4 +5606,4 @@ function maybeSpawnRefresh(argv, ctx) {
5596
5606
 
5597
5607
  //#endregion
5598
5608
  export { CompletionDirective as _, generateCompletion as a, resolveValueCompletion as b, createDynamicCompleteCommand as c, bundledWorkerShellExtension as d, defaultBundledWorkerOutputPath as f, extractPositionals as g, extractCompletionData as h, detectShell as i, hasCompleteCommand as l, validateBundledWorkerFile as m, createCompletionWorkerPathCommand as n, getSupportedShells as o, generateBundledCompletionWorker as p, createRefreshCompletionCommand as r, withCompletionCommand as s, createCompletionCommand as t, formatForShell as u, generateCandidates as v, parseCompletionContext as y };
5599
- //# sourceMappingURL=completion-DwTFOtQk.js.map
5609
+ //# sourceMappingURL=completion-Rx2DiNBn.js.map
@@ -1,4 +1,4 @@
1
- import { C as Example, J as ResolvedFieldMeta, V as SubCommandValue, _ as AnyCommand, q as ExtractedFields, v as ArgsSchema } from "../arg-registry-BN3I-XON.js";
1
+ import { C as Example, J as ResolvedFieldMeta, V as SubCommandValue, _ as AnyCommand, q as ExtractedFields, v as ArgsSchema } from "../arg-registry-aHbip9Hs.js";
2
2
  import { z } from "zod";
3
3
  import * as fs from "node:fs";
4
4
 
@@ -1,4 +1,4 @@
1
- import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-CVHWm23M.js";
1
+ import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-GEuI_L0X.js";
2
2
  import { t as createLogCollector } from "../log-collector-DK32-73m.js";
3
3
  import { z } from "zod";
4
4
  import * as fs from "node:fs";
@@ -919,7 +919,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
919
919
  collector.start();
920
920
  let success = true;
921
921
  try {
922
- const { runCommand } = await import("../runner-BCMB67GV.js").then((n) => n.r);
922
+ const { runCommand } = await import("../runner-DpsAMVta.js").then((n) => n.r);
923
923
  const result = await runCommand(rootCommand, argv);
924
924
  success = result.success;
925
925
  if (!result.success && result.error) console.error(result.error.message);
@@ -1,4 +1,4 @@
1
- import { J as ResolvedFieldMeta, _ as AnyCommand, d as ResolvedExpandCandidate, h as DynamicCompletionResolver, u as ExpandCompletion, v as ArgsSchema, x as Command } from "./arg-registry-BN3I-XON.js";
1
+ import { J as ResolvedFieldMeta, _ as AnyCommand, d as ResolvedExpandCandidate, h as DynamicCompletionResolver, u as ExpandCompletion, v as ArgsSchema, x as Command } from "./arg-registry-aHbip9Hs.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/completion/types.d.ts
@@ -177,12 +177,11 @@ interface CompletableOption {
177
177
  /** Description for the negation option (when distinct from the main description) */
178
178
  negationDescription?: string | undefined;
179
179
  /**
180
- * Whether the runtime parser accepts the implicit `--no-<cliName>` (and
181
- * camelCase) form for this boolean option. False when the user set
182
- * `negation: false` (suppressed) or `negation: <custom name>` (only the
183
- * custom name is accepted). Used by the completion context parser so
184
- * dynamic resolvers see the same `parsedArgs` state the runtime would
185
- * compute.
180
+ * Whether the runtime parser accepts the default `--no-<cliName>` (and
181
+ * camelCase) form for this boolean option. True only when the user set
182
+ * `negation: true`; false when unset, `negation: false`, or
183
+ * `negation: <custom name>`. Used by the completion context parser so
184
+ * dynamic resolvers see the same `parsedArgs` state the runtime would compute.
186
185
  */
187
186
  defaultNegationAccepted?: boolean;
188
187
  /** Description for completion */
@@ -660,4 +659,4 @@ interface WithCompletionOptions {
660
659
  declare function withCompletionCommand<T extends AnyCommand>(command: T, options?: string | WithCompletionOptions): T;
661
660
  //#endregion
662
661
  export { BundledWorkerOptions as A, CandidateResult as C, CompletionContext as D, generateCandidates as E, CompletionMode as F, CompletionOptions as I, CompletionResult as L, CompletableSubcommand as M, CompletionData as N, CompletionType as O, CompletionGenerator as P, ShellType as R, hasCompleteCommand as S, CompletionDirective as T, extractCompletionData as _, detectShell as a, formatForShell as b, withCompletionCommand as c, GenerateBundledCompletionWorkerOptions as d, GenerateBundledCompletionWorkerResult as f, validateBundledWorkerFile as g, generateBundledCompletionWorker as h, createRefreshCompletionCommand as i, CompletableOption as j, parseCompletionContext as k, ValueCompletionField as l, defaultBundledWorkerOutputPath as m, createCompletionCommand as n, generateCompletion as o, bundledWorkerShellExtension as p, createCompletionWorkerPathCommand as r, getSupportedShells as s, WithCompletionOptions as t, resolveValueCompletion as u, extractPositionals as v, CompletionCandidate as w, createDynamicCompleteCommand as x, ShellFormatOptions as y };
663
- //# sourceMappingURL=index-CtRrTVTL.d.ts.map
662
+ //# sourceMappingURL=index-dRZSB_t3.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as toKebabCase, A as LogStream, B as SetupContext, C as Example, D as IsEmpty, E as GlobalSetupContext, F as RunCommandOptions, G as isLazyCommand, H as SubCommandsRecord, I as RunResult, J as ResolvedFieldMeta, K as lazy, L as RunResultFailure, M as MainOptions, N as NonRunnableCommand, O as LogEntry, P as PromptResolver, Q as toCamelCase, R as RunResultSuccess, S as CommandBase, T as GlobalCleanupContext, U as UnknownSubcommandHandler, V as SubCommandValue, W as LazyCommand, X as extractFields, Y as UnknownKeysMode, Z as getUnknownKeysMode, _ as AnyCommand, a as EffectContext, b as CollectedLogs, c as arg, d as ResolvedExpandCandidate, f as CompletionDirectiveMask, g as DynamicCompletionResult, h as DynamicCompletionResolver, i as CustomCompletion, j as Logger, k as LogLevel, l as ExpandCandidate, m as DynamicCompletionContext, n as CompletionMeta, o as PromptMeta, p as DynamicCompletionCandidate, q as ExtractedFields, r as CompletionType, s as PromptType, t as ArgMeta, u as ExpandCompletion, v as ArgsSchema, w as GlobalArgs, x as Command, y as CleanupContext, z as RunnableCommand } from "./arg-registry-BN3I-XON.js";
2
- import { I as CompletionOptions, L as CompletionResult, c as withCompletionCommand, d as GenerateBundledCompletionWorkerOptions, f as GenerateBundledCompletionWorkerResult, h as generateBundledCompletionWorker, o as generateCompletion, t as WithCompletionOptions } from "./index-CtRrTVTL.js";
1
+ import { $ as toKebabCase, A as LogStream, B as SetupContext, C as Example, D as IsEmpty, E as GlobalSetupContext, F as RunCommandOptions, G as isLazyCommand, H as SubCommandsRecord, I as RunResult, J as ResolvedFieldMeta, K as lazy, L as RunResultFailure, M as MainOptions, N as NonRunnableCommand, O as LogEntry, P as PromptResolver, Q as toCamelCase, R as RunResultSuccess, S as CommandBase, T as GlobalCleanupContext, U as UnknownSubcommandHandler, V as SubCommandValue, W as LazyCommand, X as extractFields, Y as UnknownKeysMode, Z as getUnknownKeysMode, _ as AnyCommand, a as EffectContext, b as CollectedLogs, c as arg, d as ResolvedExpandCandidate, f as CompletionDirectiveMask, g as DynamicCompletionResult, h as DynamicCompletionResolver, i as CustomCompletion, j as Logger, k as LogLevel, l as ExpandCandidate, m as DynamicCompletionContext, n as CompletionMeta, o as PromptMeta, p as DynamicCompletionCandidate, q as ExtractedFields, r as CompletionType, s as PromptType, t as ArgMeta, u as ExpandCompletion, v as ArgsSchema, w as GlobalArgs, x as Command, y as CleanupContext, z as RunnableCommand } from "./arg-registry-aHbip9Hs.js";
2
+ import { I as CompletionOptions, L as CompletionResult, c as withCompletionCommand, d as GenerateBundledCompletionWorkerOptions, f as GenerateBundledCompletionWorkerResult, h as generateBundledCompletionWorker, o as generateCompletion, t as WithCompletionOptions } from "./index-dRZSB_t3.js";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/core/case-types.d.ts
@@ -458,11 +458,11 @@ interface ParserOptions {
458
458
  */
459
459
  negationMap?: Map<string, string>;
460
460
  /**
461
- * Canonical field names that have a custom `negation` configured.
462
- * For these fields the default `--no-<name>` / `--no<Name>` negation
463
- * forms are suppressed.
461
+ * Canonical field names whose default `--no-<name>` / `--no<Name>`
462
+ * negation forms are suppressed. When omitted, every field in
463
+ * `booleanFlags` has default negation suppressed.
464
464
  */
465
- customNegatedFields?: Set<string>;
465
+ defaultNegationDisabledFields?: Set<string>;
466
466
  }
467
467
  /**
468
468
  * Parse argv into a flat record
@@ -473,7 +473,7 @@ interface ParserOptions {
473
473
  * - Combined short options: -abc (treated as -a -b -c if all are boolean)
474
474
  * - Positional arguments
475
475
  * - -- to stop parsing options
476
- * - Boolean negation: --no-flag, --noFlag (requires `booleanFlags`)
476
+ * - Boolean negation: --no-flag, --noFlag (requires `booleanFlags` and `negation: true`)
477
477
  *
478
478
  * **Note:** When using negation detection (`--noFlag` / `--no-flag`),
479
479
  * supply `definedNames` so that options whose names happen to start with
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { C as renderMarkdown, S as renderInline, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as createDualCaseProxy, x as generateHelp, y as PositionalConfigError } from "./runner-BCMB67GV.js";
1
+ import { C as renderMarkdown, S as renderInline, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as createDualCaseProxy, x as generateHelp, y as PositionalConfigError } from "./runner-DpsAMVta.js";
2
2
  import { t as arg } from "./arg-registry-BeLLAW5-.js";
3
3
  import { n as defineCommand, t as createDefineCommand } from "./command-B4yA4LXX.js";
4
- import { a as toCamelCase, f as isLazyCommand, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-CVHWm23M.js";
5
- import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DwTFOtQk.js";
4
+ import { a as toCamelCase, f as isLazyCommand, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-GEuI_L0X.js";
5
+ import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-Rx2DiNBn.js";
6
6
  import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-DbDkjdfO.js";
7
7
 
8
8
  export { CaseVariantCollisionError, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, PositionalConfigError, ReservedAliasError, arg, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, withCompletionCommand };
@@ -1,4 +1,4 @@
1
- import { P as PromptResolver } from "../../arg-registry-BN3I-XON.js";
1
+ import { P as PromptResolver } from "../../arg-registry-aHbip9Hs.js";
2
2
 
3
3
  //#region src/prompt/clack/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { J as ResolvedFieldMeta, q as ExtractedFields } from "../arg-registry-BN3I-XON.js";
1
+ import { J as ResolvedFieldMeta, q as ExtractedFields } from "../arg-registry-aHbip9Hs.js";
2
2
 
3
3
  //#region src/prompt/types.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { P as PromptResolver } from "../../arg-registry-BN3I-XON.js";
1
+ import { P as PromptResolver } from "../../arg-registry-aHbip9Hs.js";
2
2
 
3
3
  //#region src/prompt/inquirer/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-CVHWm23M.js";
1
+ import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-GEuI_L0X.js";
2
2
  import { n as emptyLogs, r as mergeLogs, t as createLogCollector } from "./log-collector-DK32-73m.js";
3
3
  import { a as symbols, i as styles } from "./logger-DbDkjdfO.js";
4
4
  import { stripVTControlCharacters } from "node:util";
@@ -1104,7 +1104,7 @@ function checkDuplicateNegations(extracted, commandPath) {
1104
1104
  if (camelVariant !== alias) claim(camelVariant, field.name, "alias");
1105
1105
  }
1106
1106
  }
1107
- if (field.type === "boolean" && field.negation !== false && typeof field.negation !== "string") {
1107
+ if (field.type === "boolean" && field.negation === true) {
1108
1108
  const defaultKebab = `no-${field.cliName}`;
1109
1109
  claim(defaultKebab, field.name, "default negation");
1110
1110
  const camelBase = toCamelCase(field.cliName);
@@ -1443,7 +1443,7 @@ function resolveLongOption(arg, lookup) {
1443
1443
  if (lookup.booleanFlags.has(resolvedName)) {
1444
1444
  const asIsResolved = lookup.aliasMap.get(withoutDashes) ?? withoutDashes;
1445
1445
  if (!lookup.definedNames.has(asIsResolved)) {
1446
- if (lookup.customNegatedFields.has(resolvedName)) return {
1446
+ if (lookup.defaultNegationDisabledFields.has(resolvedName)) return {
1447
1447
  resolvedName,
1448
1448
  withoutDashes,
1449
1449
  isNegated: false,
@@ -1467,7 +1467,7 @@ function resolveLongOption(arg, lookup) {
1467
1467
  if (lookup.booleanFlags.has(resolvedName)) {
1468
1468
  const asIsResolved = lookup.aliasMap.get(withoutDashes) ?? withoutDashes;
1469
1469
  if (!lookup.definedNames.has(asIsResolved)) {
1470
- if (lookup.customNegatedFields.has(resolvedName)) return {
1470
+ if (lookup.defaultNegationDisabledFields.has(resolvedName)) return {
1471
1471
  resolvedName,
1472
1472
  withoutDashes,
1473
1473
  isNegated: false,
@@ -1496,6 +1496,26 @@ function resolveLongOption(arg, lookup) {
1496
1496
  //#endregion
1497
1497
  //#region src/parser/argv-parser.ts
1498
1498
  /**
1499
+ * Coerce a `--flag=value` string to a boolean for boolean-typed flags.
1500
+ * Values other than "true"/"false" are passed through unchanged so
1501
+ * downstream validation reports the invalid input instead of silently
1502
+ * guessing.
1503
+ */
1504
+ function coerceBoolean(value) {
1505
+ if (value === "true") return true;
1506
+ if (value === "false") return false;
1507
+ return value;
1508
+ }
1509
+ /**
1510
+ * Matches tokens that look like a negative number (e.g. "-5", "-5.2", "-.5"),
1511
+ * as opposed to another flag. Used to decide whether a dash-prefixed token
1512
+ * should still be consumed as a value-taking option's value.
1513
+ */
1514
+ const NEGATIVE_NUMBER_PATTERN = /^-\.?\d/;
1515
+ function looksLikeNegativeNumber(value) {
1516
+ return NEGATIVE_NUMBER_PATTERN.test(value);
1517
+ }
1518
+ /**
1499
1519
  * Parse argv into a flat record
1500
1520
  *
1501
1521
  * Supports:
@@ -1504,7 +1524,7 @@ function resolveLongOption(arg, lookup) {
1504
1524
  * - Combined short options: -abc (treated as -a -b -c if all are boolean)
1505
1525
  * - Positional arguments
1506
1526
  * - -- to stop parsing options
1507
- * - Boolean negation: --no-flag, --noFlag (requires `booleanFlags`)
1527
+ * - Boolean negation: --no-flag, --noFlag (requires `booleanFlags` and `negation: true`)
1508
1528
  *
1509
1529
  * **Note:** When using negation detection (`--noFlag` / `--no-flag`),
1510
1530
  * supply `definedNames` so that options whose names happen to start with
@@ -1517,13 +1537,13 @@ function resolveLongOption(arg, lookup) {
1517
1537
  * @returns Parsed arguments
1518
1538
  */
1519
1539
  function parseArgv(argv, options = {}) {
1520
- const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), arrayFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), customNegatedFields = /* @__PURE__ */ new Set() } = options;
1540
+ const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), arrayFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), defaultNegationDisabledFields: configuredDefaultNegationDisabledFields } = options;
1521
1541
  const longOptionLookup = {
1522
1542
  aliasMap,
1523
1543
  booleanFlags,
1524
1544
  definedNames,
1525
1545
  negationMap,
1526
- customNegatedFields
1546
+ defaultNegationDisabledFields: configuredDefaultNegationDisabledFields ?? new Set(booleanFlags)
1527
1547
  };
1528
1548
  const result = {
1529
1549
  options: {},
@@ -1556,6 +1576,11 @@ function parseArgv(argv, options = {}) {
1556
1576
  if (arg.startsWith("--")) {
1557
1577
  const withoutDashes = arg.slice(2);
1558
1578
  const resolution = resolveLongOption(arg, longOptionLookup);
1579
+ if (resolution.isSuppressedNegation) {
1580
+ setOption(resolution.withoutDashes, true);
1581
+ i++;
1582
+ continue;
1583
+ }
1559
1584
  if (resolution.isNegated) {
1560
1585
  setOption(resolution.resolvedName, false);
1561
1586
  i++;
@@ -1563,7 +1588,10 @@ function parseArgv(argv, options = {}) {
1563
1588
  }
1564
1589
  const eqIndex = withoutDashes.indexOf("=");
1565
1590
  if (eqIndex !== -1) {
1566
- setOption(withoutDashes.slice(0, eqIndex), withoutDashes.slice(eqIndex + 1));
1591
+ const name = withoutDashes.slice(0, eqIndex);
1592
+ const value = withoutDashes.slice(eqIndex + 1);
1593
+ const resolvedName = aliasMap.get(name) ?? name;
1594
+ setOption(name, booleanFlags.has(resolvedName) ? coerceBoolean(value) : value);
1567
1595
  i++;
1568
1596
  } else {
1569
1597
  const name = withoutDashes;
@@ -1573,7 +1601,7 @@ function parseArgv(argv, options = {}) {
1573
1601
  i++;
1574
1602
  } else {
1575
1603
  const nextArg = argv[i + 1];
1576
- if (nextArg !== void 0 && !nextArg.startsWith("-")) {
1604
+ if (nextArg !== void 0 && (!nextArg.startsWith("-") || looksLikeNegativeNumber(nextArg))) {
1577
1605
  setOption(name, nextArg);
1578
1606
  i += 2;
1579
1607
  } else {
@@ -1588,7 +1616,10 @@ function parseArgv(argv, options = {}) {
1588
1616
  const withoutDash = arg.slice(1);
1589
1617
  const eqIndex = withoutDash.indexOf("=");
1590
1618
  if (eqIndex !== -1) {
1591
- setOption(withoutDash.slice(0, eqIndex), withoutDash.slice(eqIndex + 1));
1619
+ const name = withoutDash.slice(0, eqIndex);
1620
+ const value = withoutDash.slice(eqIndex + 1);
1621
+ const resolvedName = aliasMap.get(name) ?? name;
1622
+ setOption(name, booleanFlags.has(resolvedName) ? coerceBoolean(value) : value);
1592
1623
  i++;
1593
1624
  } else if (withoutDash.length === 1) {
1594
1625
  const name = withoutDash;
@@ -1598,7 +1629,7 @@ function parseArgv(argv, options = {}) {
1598
1629
  i++;
1599
1630
  } else {
1600
1631
  const nextArg = argv[i + 1];
1601
- if (nextArg !== void 0 && !nextArg.startsWith("-")) {
1632
+ if (nextArg !== void 0 && (!nextArg.startsWith("-") || looksLikeNegativeNumber(nextArg))) {
1602
1633
  setOption(name, nextArg);
1603
1634
  i += 2;
1604
1635
  } else {
@@ -1626,7 +1657,7 @@ function buildParserOptions(extracted) {
1626
1657
  const arrayFlags = /* @__PURE__ */ new Set();
1627
1658
  const definedNames = /* @__PURE__ */ new Set();
1628
1659
  const negationMap = /* @__PURE__ */ new Map();
1629
- const customNegatedFields = /* @__PURE__ */ new Set();
1660
+ const defaultNegationDisabledFields = /* @__PURE__ */ new Set();
1630
1661
  for (const field of extracted.fields) definedNames.add(field.name);
1631
1662
  for (const field of extracted.fields) {
1632
1663
  if (field.cliName !== field.name) aliasMap.set(field.cliName, field.name);
@@ -1641,8 +1672,8 @@ function buildParserOptions(extracted) {
1641
1672
  if (camelVariant !== field.name && !definedNames.has(camelVariant) && !aliasMap.has(camelVariant)) aliasMap.set(camelVariant, field.name);
1642
1673
  if (field.type === "boolean") booleanFlags.add(field.name);
1643
1674
  if (field.type === "array") arrayFlags.add(field.name);
1644
- if (field.type === "boolean" && (typeof field.negation === "string" || field.negation === false)) {
1645
- customNegatedFields.add(field.name);
1675
+ if (field.type === "boolean" && field.negation !== true) {
1676
+ defaultNegationDisabledFields.add(field.name);
1646
1677
  if (typeof field.negation === "string") {
1647
1678
  negationMap.set(field.negation, field.name);
1648
1679
  if (field.negation.includes("-")) {
@@ -1658,7 +1689,7 @@ function buildParserOptions(extracted) {
1658
1689
  arrayFlags,
1659
1690
  definedNames,
1660
1691
  negationMap,
1661
- customNegatedFields
1692
+ defaultNegationDisabledFields
1662
1693
  };
1663
1694
  }
1664
1695
  /**
@@ -1689,7 +1720,7 @@ function mergeWithPositionals(parsed, extracted) {
1689
1720
  * Shared by scanForSubcommand, separateGlobalArgs, and findFirstPositional.
1690
1721
  */
1691
1722
  function buildGlobalFlagLookup(globalExtracted) {
1692
- const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), customNegatedFields = /* @__PURE__ */ new Set() } = buildParserOptions(globalExtracted);
1723
+ const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), definedNames = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), defaultNegationDisabledFields = /* @__PURE__ */ new Set() } = buildParserOptions(globalExtracted);
1693
1724
  const shortAliases = /* @__PURE__ */ new Set();
1694
1725
  for (const field of globalExtracted.fields) for (const alias of getAllAliases(field)) if (alias.length === 1) shortAliases.add(alias);
1695
1726
  return {
@@ -1700,7 +1731,7 @@ function buildGlobalFlagLookup(globalExtracted) {
1700
1731
  cliNames: new Set(globalExtracted.fields.map((f) => f.cliName)),
1701
1732
  aliases: shortAliases,
1702
1733
  negationMap,
1703
- customNegatedFields
1734
+ defaultNegationDisabledFields
1704
1735
  };
1705
1736
  }
1706
1737
  /**
@@ -1708,8 +1739,8 @@ function buildGlobalFlagLookup(globalExtracted) {
1708
1739
  * against global flag lookup. Returns the resolved camelCase name and whether
1709
1740
  * it is a known global flag.
1710
1741
  *
1711
- * `isSuppressedNegation` is true when the token matches a default `--no-X`
1712
- * form that has been suppressed by a custom `negation` on the target field.
1742
+ * `isSuppressedNegation` is true when the token matches a disabled default
1743
+ * `--no-X` form on the target field.
1713
1744
  * The caller may use this to keep argv scanning past such tokens (so a
1714
1745
  * trailing subcommand is still detected) even though they no longer negate.
1715
1746
  */
@@ -1820,7 +1851,7 @@ function scanForSubcommand(argv, subCommandNames, globalExtracted) {
1820
1851
  suppressedTokens
1821
1852
  };
1822
1853
  }
1823
- const BUILTIN_FLAGS = new Set([
1854
+ const BUILTIN_FLAGS = /* @__PURE__ */ new Set([
1824
1855
  "--help",
1825
1856
  "-h",
1826
1857
  "--help-all",
@@ -1840,7 +1871,8 @@ const BUILTIN_FLAGS = new Set([
1840
1871
  * Without globalExtracted, no flag is global, so any leading flag halts the
1841
1872
  * scan and a positional is only found when it precedes every flag.
1842
1873
  */
1843
- function findFirstPositionalIndex(argv, globalExtracted) {
1874
+ function findFirstPositionalIndex(argv, globalExtracted, options = {}) {
1875
+ const stopOnSuppressedNegation = options.stopOnSuppressedNegation === true || globalExtracted?.unknownKeysMode === "strict";
1844
1876
  const lookup = globalExtracted ? buildGlobalFlagLookup(globalExtracted) : {
1845
1877
  aliasMap: /* @__PURE__ */ new Map(),
1846
1878
  booleanFlags: /* @__PURE__ */ new Set(),
@@ -1849,7 +1881,7 @@ function findFirstPositionalIndex(argv, globalExtracted) {
1849
1881
  cliNames: /* @__PURE__ */ new Set(),
1850
1882
  aliases: /* @__PURE__ */ new Set(),
1851
1883
  negationMap: /* @__PURE__ */ new Map(),
1852
- customNegatedFields: /* @__PURE__ */ new Set()
1884
+ defaultNegationDisabledFields: /* @__PURE__ */ new Set()
1853
1885
  };
1854
1886
  for (let i = 0; i < argv.length; i++) {
1855
1887
  const arg = argv[i];
@@ -1861,7 +1893,10 @@ function findFirstPositionalIndex(argv, globalExtracted) {
1861
1893
  if (shouldConsumeValue(arg, resolvedName, isNegated, argv[i + 1], lookup.booleanFlags)) i++;
1862
1894
  continue;
1863
1895
  }
1864
- if (isSuppressedNegation) continue;
1896
+ if (isSuppressedNegation) {
1897
+ if (stopOnSuppressedNegation) return -1;
1898
+ continue;
1899
+ }
1865
1900
  return -1;
1866
1901
  }
1867
1902
  const withoutDash = arg.includes("=") ? arg.slice(1, arg.indexOf("=")) : arg.slice(1);
@@ -1914,6 +1949,7 @@ function parseArgs(argv, command, options = {}) {
1914
1949
  positionals: [],
1915
1950
  rest: [],
1916
1951
  unknownFlags: scanResult.suppressedTokens,
1952
+ unknownGlobalFlags: scanResult.suppressedTokens,
1917
1953
  rawGlobalArgs
1918
1954
  };
1919
1955
  }
@@ -1944,6 +1980,15 @@ function parseArgs(argv, command, options = {}) {
1944
1980
  if (options.globalExtracted) validateCrossSchemaCollisions(options.globalExtracted, extracted);
1945
1981
  }
1946
1982
  }
1983
+ let commandArgv = argv;
1984
+ let rawGlobalArgs;
1985
+ let suppressedGlobalFlags = [];
1986
+ if (options.globalExtracted) {
1987
+ const { separated, globalParsed, suppressedTokens } = separateGlobalArgs(argv, options.globalExtracted, extracted);
1988
+ commandArgv = separated;
1989
+ rawGlobalArgs = globalParsed;
1990
+ suppressedGlobalFlags = suppressedTokens;
1991
+ }
1947
1992
  const ddIdx = argv.indexOf("--");
1948
1993
  const flagScanArgv = ddIdx >= 0 ? argv.slice(0, ddIdx) : argv;
1949
1994
  const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && getAllAliases(f).includes("H")) ?? false;
@@ -1960,15 +2005,10 @@ function parseArgs(argv, command, options = {}) {
1960
2005
  rawArgs: {},
1961
2006
  positionals: [],
1962
2007
  rest: [],
1963
- unknownFlags: []
2008
+ unknownFlags: [],
2009
+ unknownGlobalFlags: suppressedGlobalFlags,
2010
+ rawGlobalArgs
1964
2011
  };
1965
- let commandArgv = argv;
1966
- let rawGlobalArgs;
1967
- if (options.globalExtracted) {
1968
- const { separated, globalParsed } = separateGlobalArgs(argv, options.globalExtracted, extracted);
1969
- commandArgv = separated;
1970
- rawGlobalArgs = globalParsed;
1971
- }
1972
2012
  if (!extracted) {
1973
2013
  const ddIdx = commandArgv.indexOf("--");
1974
2014
  return {
@@ -1981,6 +2021,7 @@ function parseArgs(argv, command, options = {}) {
1981
2021
  positionals: ddIdx >= 0 ? commandArgv.slice(0, ddIdx) : commandArgv,
1982
2022
  rest: ddIdx >= 0 ? commandArgv.slice(ddIdx + 1) : [],
1983
2023
  unknownFlags: [],
2024
+ unknownGlobalFlags: suppressedGlobalFlags,
1984
2025
  rawGlobalArgs
1985
2026
  };
1986
2027
  }
@@ -2018,6 +2059,7 @@ function parseArgs(argv, command, options = {}) {
2018
2059
  positionals: parsed.positionals,
2019
2060
  rest: parsed.rest,
2020
2061
  unknownFlags,
2062
+ unknownGlobalFlags: suppressedGlobalFlags,
2021
2063
  extractedFields: extracted,
2022
2064
  rawGlobalArgs
2023
2065
  };
@@ -2045,9 +2087,21 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
2045
2087
  const lookup = buildGlobalFlagLookup(globalExtracted);
2046
2088
  const localFieldNames = new Set(localExtracted?.fields.map((f) => f.name) ?? []);
2047
2089
  const localCliNames = new Set(localExtracted?.fields.map((f) => f.cliName) ?? []);
2048
- const localAliasMapKeys = localExtracted ? new Set(buildParserOptions(localExtracted).aliasMap?.keys() ?? []) : /* @__PURE__ */ new Set();
2090
+ const localParserOptions = localExtracted ? buildParserOptions(localExtracted) : void 0;
2091
+ const localAliasMapKeys = new Set(localParserOptions?.aliasMap?.keys() ?? []);
2092
+ const localNegationMapKeys = new Set(localParserOptions?.negationMap?.keys() ?? []);
2093
+ const localDefaultNegationKeys = /* @__PURE__ */ new Set();
2094
+ for (const field of localExtracted?.fields ?? []) {
2095
+ if (field.type !== "boolean" || field.negation !== true) continue;
2096
+ for (const name of [field.cliName, ...getAllAliases(field)]) {
2097
+ const kebab = `no-${name}`;
2098
+ localDefaultNegationKeys.add(kebab);
2099
+ localDefaultNegationKeys.add(toCamelCase(kebab));
2100
+ }
2101
+ }
2049
2102
  const globalTokens = [];
2050
2103
  const commandTokens = [];
2104
+ const suppressedTokens = [];
2051
2105
  for (let i = 0; i < argv.length; i++) {
2052
2106
  const arg = argv[i];
2053
2107
  if (arg === "--") {
@@ -2055,13 +2109,17 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
2055
2109
  break;
2056
2110
  }
2057
2111
  if (arg.startsWith("--")) {
2058
- const { resolvedName, withoutDashes, isNegated, isGlobal } = resolveGlobalLongOption(arg, lookup);
2112
+ const { resolvedName, withoutDashes, isNegated, isGlobal, isSuppressedNegation } = resolveGlobalLongOption(arg, lookup);
2059
2113
  const flagName = resolvedName;
2060
- const isLocalCollision = localFieldNames.has(withoutDashes) || localFieldNames.has(flagName) || localCliNames.has(withoutDashes) || localCliNames.has(flagName) || localAliasMapKeys.has(withoutDashes) || localAliasMapKeys.has(flagName);
2114
+ const isLocalCollision = localFieldNames.has(withoutDashes) || localFieldNames.has(flagName) || localCliNames.has(withoutDashes) || localCliNames.has(flagName) || localAliasMapKeys.has(withoutDashes) || localAliasMapKeys.has(flagName) || localNegationMapKeys.has(withoutDashes) || localNegationMapKeys.has(flagName) || localDefaultNegationKeys.has(withoutDashes);
2061
2115
  if (isGlobal && !isLocalCollision) {
2062
2116
  i += collectGlobalFlag(argv, i, resolvedName, isNegated, lookup.booleanFlags, globalTokens) - 1;
2063
2117
  continue;
2064
2118
  }
2119
+ if (isSuppressedNegation && !isLocalCollision) {
2120
+ suppressedTokens.push(arg.includes("=") ? arg.slice(2, arg.indexOf("=")) : arg.slice(2));
2121
+ continue;
2122
+ }
2065
2123
  } else if (arg.startsWith("-") && arg.length > 1) {
2066
2124
  const withoutDash = arg.includes("=") ? arg.slice(1, arg.indexOf("=")) : arg.slice(1);
2067
2125
  if (withoutDash.length === 1) {
@@ -2076,7 +2134,8 @@ function separateGlobalArgs(argv, globalExtracted, localExtracted) {
2076
2134
  }
2077
2135
  return {
2078
2136
  separated: commandTokens,
2079
- globalParsed: parseGlobalArgs(globalTokens, globalExtracted)
2137
+ globalParsed: parseGlobalArgs(globalTokens, globalExtracted),
2138
+ suppressedTokens
2080
2139
  };
2081
2140
  }
2082
2141
 
@@ -2309,7 +2368,7 @@ async function runCommand(command, argv, options = {}) {
2309
2368
  function isInternalSubcommandInvocation(command, argv, globalExtracted) {
2310
2369
  const firstPositional = findFirstPositional(argv, globalExtracted);
2311
2370
  if (!firstPositional || !firstPositional.startsWith("__")) return false;
2312
- return Boolean(command.subCommands?.[firstPositional]);
2371
+ return Object.hasOwn(command.subCommands ?? {}, firstPositional);
2313
2372
  }
2314
2373
  /**
2315
2374
  * Run a CLI command as the main entry point
@@ -2357,7 +2416,7 @@ async function runMain(command, options = {}) {
2357
2416
  if (effectiveOptions.onUnknownSubcommand && !command.run && !isInternalSubcommandInvocation(command, argv, globalExtractedForBypass)) {
2358
2417
  const knownSubCommands = listSubCommandNamesWithAliases(command);
2359
2418
  if (knownSubCommands.size > 0) {
2360
- const positionalIndex = findFirstPositionalIndex(argv, globalExtracted);
2419
+ const positionalIndex = findFirstPositionalIndex(argv, globalExtracted, { stopOnSuppressedNegation: globalExtracted?.unknownKeysMode !== "passthrough" });
2361
2420
  const name = positionalIndex >= 0 ? argv[positionalIndex] : void 0;
2362
2421
  if (name && !knownSubCommands.has(name)) {
2363
2422
  const forwardArgs = argv.slice(positionalIndex + 1);
@@ -2450,7 +2509,7 @@ async function runCommandInternal(command, argv, options = {}) {
2450
2509
  if (options.onUnknownSubcommand && !command.run && nestedCommandPath.length > 0) {
2451
2510
  const knownSubCommands = listSubCommandNamesWithAliases(command);
2452
2511
  if (knownSubCommands.size > 0) {
2453
- const positionalIndex = findFirstPositionalIndex(argv, options._globalExtracted);
2512
+ const positionalIndex = findFirstPositionalIndex(argv, options._globalExtracted, { stopOnSuppressedNegation: options._globalExtracted?.unknownKeysMode !== "passthrough" });
2454
2513
  const name = positionalIndex >= 0 ? argv[positionalIndex] : void 0;
2455
2514
  if (name && !knownSubCommands.has(name)) {
2456
2515
  const forwardArgs = argv.slice(positionalIndex + 1);
@@ -2516,6 +2575,22 @@ async function runCommandInternal(command, argv, options = {}) {
2516
2575
  logs: getCurrentLogs()
2517
2576
  };
2518
2577
  }
2578
+ if (parseResult.unknownGlobalFlags && parseResult.unknownGlobalFlags.length > 0) {
2579
+ const globalMode = context.globalExtracted?.unknownKeysMode ?? "strip";
2580
+ if (globalMode === "strict") {
2581
+ collector?.stop();
2582
+ return {
2583
+ success: false,
2584
+ error: /* @__PURE__ */ new Error(`Unknown flags: ${parseResult.unknownGlobalFlags.join(", ")}`),
2585
+ exitCode: 1,
2586
+ logs: getCurrentLogs()
2587
+ };
2588
+ }
2589
+ if (globalMode === "strip") {
2590
+ const knownGlobalFlags = context.globalExtracted?.fields.map((f) => f.name) ?? [];
2591
+ for (const flag of parseResult.unknownGlobalFlags) logger.error(formatUnknownFlagWarning(flag, knownGlobalFlags));
2592
+ }
2593
+ }
2519
2594
  if (parseResult.versionRequested) {
2520
2595
  const version = context.rootVersion;
2521
2596
  if (version) logger.log(version);
@@ -2528,22 +2603,6 @@ async function runCommandInternal(command, argv, options = {}) {
2528
2603
  };
2529
2604
  }
2530
2605
  if (parseResult.subCommand) {
2531
- if (parseResult.unknownFlags.length > 0) {
2532
- const globalMode = context.globalExtracted?.unknownKeysMode ?? "strip";
2533
- if (globalMode === "strict") {
2534
- collector?.stop();
2535
- return {
2536
- success: false,
2537
- error: /* @__PURE__ */ new Error(`Unknown flags: ${parseResult.unknownFlags.join(", ")}`),
2538
- exitCode: 1,
2539
- logs: getCurrentLogs()
2540
- };
2541
- }
2542
- if (globalMode === "strip") {
2543
- const knownGlobalFlags = context.globalExtracted?.fields.map((f) => f.name) ?? [];
2544
- for (const flag of parseResult.unknownFlags) logger.error(formatUnknownFlagWarning(flag, knownGlobalFlags));
2545
- }
2546
- }
2547
2606
  const resolved = await resolveSubcommandWithAlias(command, parseResult.subCommand);
2548
2607
  if (resolved) {
2549
2608
  const subContext = {
@@ -2727,4 +2786,4 @@ function extractAndValidateGlobal(options) {
2727
2786
 
2728
2787
  //#endregion
2729
2788
  export { renderMarkdown as C, renderInline as S, DuplicateFieldError as _, parseArgv as a, ReservedAliasError as b, validateCommand as c, validateDuplicateFields as d, validateDuplicateNegations as f, DuplicateAliasError as g, CaseVariantCollisionError as h, formatValidationErrors as i, validateCrossSchemaCollisions as l, validateReservedAliases as m, runMain as n, formatCommandValidationErrors as o, validatePositionalConfig as p, runner_exports as r, validateCaseVariantCollisions as s, runCommand as t, validateDuplicateAliases as u, DuplicateNegationError as v, createDualCaseProxy as w, generateHelp as x, PositionalConfigError as y };
2730
- //# sourceMappingURL=runner-BCMB67GV.js.map
2789
+ //# sourceMappingURL=runner-DpsAMVta.js.map
@@ -77,7 +77,7 @@ async function resolveLazyCommand(cmd) {
77
77
  */
78
78
  async function resolveSubcommandWithAlias(command, name) {
79
79
  if (!command.subCommands) return;
80
- const subCmd = command.subCommands[name];
80
+ const subCmd = Object.hasOwn(command.subCommands, name) ? command.subCommands[name] : void 0;
81
81
  if (subCmd) return {
82
82
  command: await resolveLazyCommand(subCmd),
83
83
  aliasFor: void 0
@@ -153,7 +153,7 @@ function getArgMeta(schema) {
153
153
  * Long flag names reserved for built-in handling (parseArgs / scanForSubcommand
154
154
  * intercept these before option parsing), so custom negation names must avoid them.
155
155
  */
156
- const RESERVED_NEGATION_NAMES = new Set([
156
+ const RESERVED_NEGATION_NAMES = /* @__PURE__ */ new Set([
157
157
  "help",
158
158
  "help-all",
159
159
  "version"
@@ -597,4 +597,4 @@ function getExtractedFields(command) {
597
597
 
598
598
  //#endregion
599
599
  export { toCamelCase as a, listSubCommands as c, resolveSubcommandWithAlias as d, isLazyCommand as f, getUnknownKeysMode as i, resolveLazyCommand as l, resolveSubCommandMeta as m, getAllAliases as n, toKebabCase as o, lazy as p, getExtractedFields as r, listSubCommandNamesWithAliases as s, extractFields as t, resolveSubCommandAlias as u };
600
- //# sourceMappingURL=schema-extractor-CVHWm23M.js.map
600
+ //# sourceMappingURL=schema-extractor-GEuI_L0X.js.map
@@ -1,4 +1,4 @@
1
- import { _ as AnyCommand } from "../arg-registry-BN3I-XON.js";
1
+ import { _ as AnyCommand } from "../arg-registry-aHbip9Hs.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/skill/frontmatter.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "politty",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
4
4
  "description": "A lightweight CLI framework inspired by citty with zod v4 registry integration for type-safe metadata management",
5
5
  "keywords": [
6
6
  "argument-parser",
@@ -11,7 +11,7 @@
11
11
  "zod"
12
12
  ],
13
13
  "license": "MIT",
14
- "author": "",
14
+ "author": "toiroakr",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "https://github.com/toiroakr/politty.git"
@@ -68,14 +68,14 @@
68
68
  "@clack/prompts": "1.2.0",
69
69
  "@inquirer/prompts": "8.5.2",
70
70
  "@quansync/fs": "1.0.0",
71
- "@types/node": "25.9.3",
72
- "@typescript/native-preview": "7.0.0-dev.20260617.2",
71
+ "@types/node": "25.9.4",
72
+ "@typescript/native-preview": "7.0.0-dev.20260701.1",
73
73
  "@vitest/coverage-v8": "4.1.9",
74
- "knip": "6.17.1",
74
+ "knip": "6.23.0",
75
75
  "lefthook": "2.1.9",
76
76
  "organize-imports-cli": "1.0.2",
77
- "oxfmt": "0.55.0",
78
- "oxlint": "1.70.0",
77
+ "oxfmt": "0.57.0",
78
+ "oxlint": "1.72.0",
79
79
  "quansync": "1.0.0",
80
80
  "tsdown": "0.22.3",
81
81
  "tsx": "4.22.4",
@@ -97,7 +97,7 @@
97
97
  }
98
98
  },
99
99
  "engines": {
100
- "node": ">=18"
100
+ "node": ">=20.12.0 <21.0.0 || >=21.7.0"
101
101
  },
102
102
  "scripts": {
103
103
  "build": "tsdown",