politty 0.4.16 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{arg-registry-MVWOAcvw.d.cts → arg-registry--NRaNFJM.d.cts} +123 -3
  2. package/dist/arg-registry--NRaNFJM.d.cts.map +1 -0
  3. package/dist/{arg-registry-Cd6xnjHa.d.ts → arg-registry-6E0WHOh_.d.ts} +123 -3
  4. package/dist/arg-registry-6E0WHOh_.d.ts.map +1 -0
  5. package/dist/augment.d.cts +1 -1
  6. package/dist/augment.d.ts +1 -1
  7. package/dist/completion/index.cjs +1 -1
  8. package/dist/completion/index.d.cts +3 -2
  9. package/dist/completion/index.d.ts +3 -2
  10. package/dist/completion/index.js +1 -1
  11. package/dist/completion-BA5JMvVG.js +4067 -0
  12. package/dist/completion-BA5JMvVG.js.map +1 -0
  13. package/dist/completion-Cqs1Ja7C.cjs +4169 -0
  14. package/dist/completion-Cqs1Ja7C.cjs.map +1 -0
  15. package/dist/docs/index.cjs +9 -9
  16. package/dist/docs/index.cjs.map +1 -1
  17. package/dist/docs/index.d.cts +1 -1
  18. package/dist/docs/index.d.ts +1 -1
  19. package/dist/docs/index.js +2 -2
  20. package/dist/{index-CPebddth.d.cts → index-DBMfKZ34.d.ts} +135 -15
  21. package/dist/index-DBMfKZ34.d.ts.map +1 -0
  22. package/dist/{index-DR9HLxIP.d.ts → index-DJp8k5Bq.d.cts} +135 -15
  23. package/dist/index-DJp8k5Bq.d.cts.map +1 -0
  24. package/dist/index.cjs +10 -10
  25. package/dist/index.d.cts +3 -3
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +3 -3
  28. package/dist/prompt/clack/index.d.cts +1 -1
  29. package/dist/prompt/clack/index.d.ts +1 -1
  30. package/dist/prompt/index.d.cts +1 -1
  31. package/dist/prompt/index.d.ts +1 -1
  32. package/dist/prompt/inquirer/index.d.cts +1 -1
  33. package/dist/prompt/inquirer/index.d.ts +1 -1
  34. package/dist/{runner-BHeCMEa5.js → runner-BmSEiD9A.js} +12 -9
  35. package/dist/{runner-BHeCMEa5.js.map → runner-BmSEiD9A.js.map} +1 -1
  36. package/dist/{runner-BcyR6Z8r.cjs → runner-CRZ_7Y9i.cjs} +56 -53
  37. package/dist/{runner-BcyR6Z8r.cjs.map → runner-CRZ_7Y9i.cjs.map} +1 -1
  38. package/dist/{subcommand-router-XZBWe8HN.js → schema-extractor-C50R-1re.js} +135 -135
  39. package/dist/schema-extractor-C50R-1re.js.map +1 -0
  40. package/dist/{subcommand-router-DQy0KZU-.cjs → schema-extractor-SLPgBNgZ.cjs} +134 -134
  41. package/dist/schema-extractor-SLPgBNgZ.cjs.map +1 -0
  42. package/package.json +5 -5
  43. package/dist/arg-registry-Cd6xnjHa.d.ts.map +0 -1
  44. package/dist/arg-registry-MVWOAcvw.d.cts.map +0 -1
  45. package/dist/completion-B04iiki9.js +0 -2338
  46. package/dist/completion-B04iiki9.js.map +0 -1
  47. package/dist/completion-BlZxMSeU.cjs +0 -2440
  48. package/dist/completion-BlZxMSeU.cjs.map +0 -1
  49. package/dist/index-CPebddth.d.cts.map +0 -1
  50. package/dist/index-DR9HLxIP.d.ts.map +0 -1
  51. package/dist/subcommand-router-DQy0KZU-.cjs.map +0 -1
  52. package/dist/subcommand-router-XZBWe8HN.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const require_log_collector = require('./log-collector-Cd2_mv87.cjs');
2
- const require_subcommand_router = require('./subcommand-router-DQy0KZU-.cjs');
2
+ const require_schema_extractor = require('./schema-extractor-SLPgBNgZ.cjs');
3
3
  let node_util = require("node:util");
4
4
  let string_width = require("string-width");
5
5
  string_width = require_log_collector.__toESM(string_width, 1);
@@ -19,9 +19,9 @@ function createDualCaseProxy(obj) {
19
19
  get(target, prop, receiver) {
20
20
  if (typeof prop === "string") {
21
21
  if (prop in target) return Reflect.get(target, prop, receiver);
22
- const camel = require_subcommand_router.toCamelCase(prop);
22
+ const camel = require_schema_extractor.toCamelCase(prop);
23
23
  if (camel !== prop && camel in target) return Reflect.get(target, camel, receiver);
24
- const kebab = require_subcommand_router.toKebabCase(prop);
24
+ const kebab = require_schema_extractor.toKebabCase(prop);
25
25
  if (kebab !== prop && kebab in target) return Reflect.get(target, kebab, receiver);
26
26
  }
27
27
  return Reflect.get(target, prop, receiver);
@@ -29,9 +29,9 @@ function createDualCaseProxy(obj) {
29
29
  has(target, prop) {
30
30
  if (typeof prop === "string") {
31
31
  if (prop in target) return true;
32
- const camel = require_subcommand_router.toCamelCase(prop);
32
+ const camel = require_schema_extractor.toCamelCase(prop);
33
33
  if (camel !== prop && camel in target) return true;
34
- const kebab = require_subcommand_router.toKebabCase(prop);
34
+ const kebab = require_schema_extractor.toKebabCase(prop);
35
35
  if (kebab !== prop && kebab in target) return true;
36
36
  }
37
37
  return Reflect.has(target, prop);
@@ -614,7 +614,7 @@ function renderUsageLine(command, context) {
614
614
  const name = buildUsageCommandName(command, context);
615
615
  parts.push(styles.commandName(name));
616
616
  if (context?.globalExtracted?.fields.length) parts.push(styles.placeholder("[global options]"));
617
- const extracted = require_subcommand_router.getExtractedFields(command);
617
+ const extracted = require_schema_extractor.getExtractedFields(command);
618
618
  if (extracted) {
619
619
  const positionals = extracted.fields.filter((a) => a.positional);
620
620
  if (extracted.fields.filter((a) => !a.positional).length > 0) parts.push(styles.placeholder("[options]"));
@@ -634,9 +634,9 @@ function renderOptions(command, descriptions = {}, context) {
634
634
  helpAll: descriptions.helpAll ?? defaultBuiltinDescriptions.helpAll,
635
635
  version: descriptions.version ?? defaultBuiltinDescriptions.version
636
636
  };
637
- const extracted = require_subcommand_router.getExtractedFields(command);
638
- const hasUserDefinedh = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_subcommand_router.getAllAliases(f).includes("h")) ?? false;
639
- const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_subcommand_router.getAllAliases(f).includes("H")) ?? false;
637
+ const extracted = require_schema_extractor.getExtractedFields(command);
638
+ const hasUserDefinedh = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_schema_extractor.getAllAliases(f).includes("h")) ?? false;
639
+ const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_schema_extractor.getAllAliases(f).includes("H")) ?? false;
640
640
  if (hasUserDefinedh) lines.push(formatOption(styles.option("--help"), desc.help));
641
641
  else lines.push(formatOption(`${styles.option("-h")}, ${styles.option("--help")}`, desc.help));
642
642
  if (hasUserDefinedH) lines.push(formatOption(styles.option("--help-all"), desc.helpAll));
@@ -865,7 +865,7 @@ function renderGlobalOptions(globalExtracted) {
865
865
  */
866
866
  function renderSubcommandOptionsCompact(command, indent) {
867
867
  const lines = [];
868
- const extracted = require_subcommand_router.getExtractedFields(command);
868
+ const extracted = require_schema_extractor.getExtractedFields(command);
869
869
  if (extracted) {
870
870
  const options = extracted.fields.filter((a) => !a.positional);
871
871
  for (const opt of options) {
@@ -887,7 +887,7 @@ function renderSubcommandOptionsCompact(command, indent) {
887
887
  function renderSubcommandsWithOptions(subCommands, parentPath, baseIndent) {
888
888
  const lines = [];
889
889
  for (const [name, subCmd] of getVisibleSubcommandEntries(subCommands)) {
890
- const cmd = require_subcommand_router.resolveSubCommandMeta(subCmd);
890
+ const cmd = require_schema_extractor.resolveSubCommandMeta(subCmd);
891
891
  const fullPath = parentPath ? `${parentPath} ${name}` : name;
892
892
  const desc = cmd?.description ?? "";
893
893
  const aliases = cmd?.aliases;
@@ -939,7 +939,7 @@ function generateHelp(command, options) {
939
939
  } else {
940
940
  const subLines = [];
941
941
  for (const [name, subCmd] of Object.entries(visibleSubCommands)) {
942
- const cmd = require_subcommand_router.resolveSubCommandMeta(subCmd);
942
+ const cmd = require_schema_extractor.resolveSubCommandMeta(subCmd);
943
943
  const desc = cmd?.description ?? "";
944
944
  const fullName = currentPath ? `${currentPath} ${name}` : name;
945
945
  const aliases = cmd?.aliases;
@@ -1062,7 +1062,7 @@ function checkCaseVariantCollisions(extracted, commandPath) {
1062
1062
  const errors = [];
1063
1063
  const canonicalMap = /* @__PURE__ */ new Map();
1064
1064
  for (const field of extracted.fields) {
1065
- const camel = require_subcommand_router.toCamelCase(field.name);
1065
+ const camel = require_schema_extractor.toCamelCase(field.name);
1066
1066
  const existing = canonicalMap.get(camel);
1067
1067
  if (existing && existing !== field.name) errors.push({
1068
1068
  commandPath,
@@ -1102,12 +1102,12 @@ function checkDuplicateAliases(extracted, commandPath) {
1102
1102
  seenAliases.set(alias, fieldName);
1103
1103
  };
1104
1104
  for (const field of extracted.fields) {
1105
- const allAliases = require_subcommand_router.getAllAliases(field);
1105
+ const allAliases = require_schema_extractor.getAllAliases(field);
1106
1106
  if (allAliases.length === 0) continue;
1107
1107
  for (const alias of allAliases) {
1108
1108
  registerAlias(alias, field.name, false);
1109
1109
  if (alias.length > 1 && alias.includes("-")) {
1110
- const camelVariant = require_subcommand_router.toCamelCase(alias);
1110
+ const camelVariant = require_schema_extractor.toCamelCase(alias);
1111
1111
  if (camelVariant !== alias && !fieldNames.has(camelVariant)) registerAlias(camelVariant, field.name, true);
1112
1112
  }
1113
1113
  }
@@ -1129,25 +1129,25 @@ function checkDuplicateNegations(extracted, commandPath) {
1129
1129
  for (const field of extracted.fields) {
1130
1130
  claim(field.name, field.name, "field name");
1131
1131
  if (field.name.includes("-")) {
1132
- const camelName = require_subcommand_router.toCamelCase(field.name);
1132
+ const camelName = require_schema_extractor.toCamelCase(field.name);
1133
1133
  if (camelName !== field.name) claim(camelName, field.name, "field name");
1134
1134
  }
1135
1135
  if (field.cliName !== field.name) claim(field.cliName, field.name, "CLI name");
1136
1136
  if (field.cliName.includes("-")) {
1137
- const camelCli = require_subcommand_router.toCamelCase(field.cliName);
1137
+ const camelCli = require_schema_extractor.toCamelCase(field.cliName);
1138
1138
  if (camelCli !== field.cliName) claim(camelCli, field.name, "CLI name");
1139
1139
  }
1140
- for (const alias of require_subcommand_router.getAllAliases(field)) {
1140
+ for (const alias of require_schema_extractor.getAllAliases(field)) {
1141
1141
  claim(alias, field.name, "alias");
1142
1142
  if (alias.length > 1 && alias.includes("-")) {
1143
- const camelVariant = require_subcommand_router.toCamelCase(alias);
1143
+ const camelVariant = require_schema_extractor.toCamelCase(alias);
1144
1144
  if (camelVariant !== alias) claim(camelVariant, field.name, "alias");
1145
1145
  }
1146
1146
  }
1147
1147
  if (field.type === "boolean" && field.negation !== false && typeof field.negation !== "string") {
1148
1148
  const defaultKebab = `no-${field.cliName}`;
1149
1149
  claim(defaultKebab, field.name, "default negation");
1150
- const camelBase = require_subcommand_router.toCamelCase(field.cliName);
1150
+ const camelBase = require_schema_extractor.toCamelCase(field.cliName);
1151
1151
  const defaultCamel = `no${camelBase[0]?.toUpperCase() ?? ""}${camelBase.slice(1)}`;
1152
1152
  if (defaultCamel !== defaultKebab) claim(defaultCamel, field.name, "default negation");
1153
1153
  }
@@ -1181,7 +1181,7 @@ function checkDuplicateNegations(extracted, commandPath) {
1181
1181
  if (typeof field.negation !== "string") continue;
1182
1182
  register(field.negation, field.name, false);
1183
1183
  if (field.negation.includes("-")) {
1184
- const camelVariant = require_subcommand_router.toCamelCase(field.negation);
1184
+ const camelVariant = require_schema_extractor.toCamelCase(field.negation);
1185
1185
  if (camelVariant !== field.negation) register(camelVariant, field.name, true);
1186
1186
  }
1187
1187
  }
@@ -1226,7 +1226,7 @@ function checkReservedAliases(extracted, commandPath) {
1226
1226
  const errors = [];
1227
1227
  for (const field of extracted.fields) {
1228
1228
  if (field.overrideBuiltinAlias === true) continue;
1229
- for (const alias of require_subcommand_router.getAllAliases(field)) if (alias === "h" || alias === "H") errors.push({
1229
+ for (const alias of require_schema_extractor.getAllAliases(field)) if (alias === "h" || alias === "H") errors.push({
1230
1230
  commandPath,
1231
1231
  type: "reserved_alias",
1232
1232
  message: `Alias "${alias}" is reserved for --${alias === "h" ? "help" : "help-all"}.`,
@@ -1297,7 +1297,7 @@ function validateReservedAliases(extracted, _hasSubCommands) {
1297
1297
  if (errors.length > 0) {
1298
1298
  const field = errors[0].field ?? "unknown";
1299
1299
  const found = extracted.fields.find((f) => f.name === field);
1300
- const alias = (found ? require_subcommand_router.getAllAliases(found) : []).find((a) => a === "h" || a === "H") ?? "h";
1300
+ const alias = (found ? require_schema_extractor.getAllAliases(found) : []).find((a) => a === "h" || a === "H") ?? "h";
1301
1301
  throw new ReservedAliasError(`Alias "${alias}" is reserved for --${alias === "h" ? "help" : "help-all"}. To override this, set { overrideBuiltinAlias: true } for "${field}" and keep the alias where it is currently defined (in alias or hiddenAlias).`);
1302
1302
  }
1303
1303
  }
@@ -1337,9 +1337,9 @@ function validateCaseVariantCollisions(extracted) {
1337
1337
  */
1338
1338
  function validateCrossSchemaCollisions(extractedA, extractedB) {
1339
1339
  const canonicalMap = /* @__PURE__ */ new Map();
1340
- for (const field of extractedA.fields) canonicalMap.set(require_subcommand_router.toCamelCase(field.name), field.name);
1340
+ for (const field of extractedA.fields) canonicalMap.set(require_schema_extractor.toCamelCase(field.name), field.name);
1341
1341
  for (const field of extractedB.fields) {
1342
- const camel = require_subcommand_router.toCamelCase(field.name);
1342
+ const camel = require_schema_extractor.toCamelCase(field.name);
1343
1343
  const existing = canonicalMap.get(camel);
1344
1344
  if (existing && existing !== field.name) throw new CaseVariantCollisionError(`Global field "${existing}" and command field "${field.name}" are case variants of each other and would collide.`);
1345
1345
  }
@@ -1368,7 +1368,7 @@ function checkSubCommandAliasConflicts(command, commandPath) {
1368
1368
  const nameToOwner = /* @__PURE__ */ new Map();
1369
1369
  for (const [name] of Object.entries(command.subCommands)) nameToOwner.set(name, name);
1370
1370
  for (const [name, subCmdValue] of Object.entries(command.subCommands)) {
1371
- const resolved = require_subcommand_router.isLazyCommand(subCmdValue) ? subCmdValue.meta : typeof subCmdValue !== "function" ? subCmdValue : null;
1371
+ const resolved = require_schema_extractor.isLazyCommand(subCmdValue) ? subCmdValue.meta : typeof subCmdValue !== "function" ? subCmdValue : null;
1372
1372
  if (!resolved?.aliases) continue;
1373
1373
  const subCommandPath = [...commandPath, name];
1374
1374
  for (const alias of resolved.aliases) {
@@ -1431,12 +1431,12 @@ async function validateCommand(command, options = {}) {
1431
1431
  const errors = [];
1432
1432
  const hasSubCommands = command.subCommands ? Object.keys(command.subCommands).length > 0 : false;
1433
1433
  if (command.args) {
1434
- const extracted = require_subcommand_router.extractFields(command.args);
1434
+ const extracted = require_schema_extractor.extractFields(command.args);
1435
1435
  errors.push(...collectSchemaErrors(extracted, hasSubCommands, commandPath));
1436
1436
  }
1437
1437
  errors.push(...checkSubCommandAliasConflicts(command, commandPath));
1438
1438
  if (command.subCommands) for (const [name, subCmd] of Object.entries(command.subCommands)) {
1439
- const subResult = await validateCommand(await require_subcommand_router.resolveLazyCommand(subCmd), { commandPath: [...commandPath, name] });
1439
+ const subResult = await validateCommand(await require_schema_extractor.resolveLazyCommand(subCmd), { commandPath: [...commandPath, name] });
1440
1440
  if (!subResult.valid) errors.push(...subResult.errors);
1441
1441
  }
1442
1442
  if (errors.length === 0) return { valid: true };
@@ -1619,14 +1619,14 @@ function buildParserOptions(extracted) {
1619
1619
  for (const field of extracted.fields) definedNames.add(field.name);
1620
1620
  for (const field of extracted.fields) {
1621
1621
  if (field.cliName !== field.name) aliasMap.set(field.cliName, field.name);
1622
- for (const alias of require_subcommand_router.getAllAliases(field)) {
1622
+ for (const alias of require_schema_extractor.getAllAliases(field)) {
1623
1623
  aliasMap.set(alias, field.name);
1624
1624
  if (alias.length > 1 && alias.includes("-")) {
1625
- const camelAlias = require_subcommand_router.toCamelCase(alias);
1625
+ const camelAlias = require_schema_extractor.toCamelCase(alias);
1626
1626
  if (camelAlias !== alias && !definedNames.has(camelAlias) && !aliasMap.has(camelAlias)) aliasMap.set(camelAlias, field.name);
1627
1627
  }
1628
1628
  }
1629
- const camelVariant = require_subcommand_router.toCamelCase(field.name);
1629
+ const camelVariant = require_schema_extractor.toCamelCase(field.name);
1630
1630
  if (camelVariant !== field.name && !definedNames.has(camelVariant) && !aliasMap.has(camelVariant)) aliasMap.set(camelVariant, field.name);
1631
1631
  if (field.type === "boolean") booleanFlags.add(field.name);
1632
1632
  if (field.type === "array") arrayFlags.add(field.name);
@@ -1635,7 +1635,7 @@ function buildParserOptions(extracted) {
1635
1635
  if (typeof field.negation === "string") {
1636
1636
  negationMap.set(field.negation, field.name);
1637
1637
  if (field.negation.includes("-")) {
1638
- const camelNegation = require_subcommand_router.toCamelCase(field.negation);
1638
+ const camelNegation = require_schema_extractor.toCamelCase(field.negation);
1639
1639
  if (camelNegation !== field.negation) negationMap.set(camelNegation, field.name);
1640
1640
  }
1641
1641
  }
@@ -1680,7 +1680,7 @@ function mergeWithPositionals(parsed, extracted) {
1680
1680
  function buildGlobalFlagLookup(globalExtracted) {
1681
1681
  const { aliasMap = /* @__PURE__ */ new Map(), booleanFlags = /* @__PURE__ */ new Set(), negationMap = /* @__PURE__ */ new Map(), customNegatedFields = /* @__PURE__ */ new Set() } = buildParserOptions(globalExtracted);
1682
1682
  const shortAliases = /* @__PURE__ */ new Set();
1683
- for (const field of globalExtracted.fields) for (const alias of require_subcommand_router.getAllAliases(field)) if (alias.length === 1) shortAliases.add(alias);
1683
+ for (const field of globalExtracted.fields) for (const alias of require_schema_extractor.getAllAliases(field)) if (alias.length === 1) shortAliases.add(alias);
1684
1684
  return {
1685
1685
  aliasMap,
1686
1686
  booleanFlags,
@@ -1867,7 +1867,7 @@ function findFirstPositional(argv, globalExtracted) {
1867
1867
  * @returns Parse result
1868
1868
  */
1869
1869
  function parseArgs(argv, command, options = {}) {
1870
- const subCommandNameSet = require_subcommand_router.listSubCommandNamesWithAliases(command);
1870
+ const subCommandNameSet = require_schema_extractor.listSubCommandNamesWithAliases(command);
1871
1871
  const subCommandNames = [...subCommandNameSet];
1872
1872
  const hasSubCommands = subCommandNames.length > 0;
1873
1873
  if (hasSubCommands && argv.length > 0) if (options.globalExtracted) {
@@ -1901,7 +1901,7 @@ function parseArgs(argv, command, options = {}) {
1901
1901
  }
1902
1902
  let extracted;
1903
1903
  if (command.args) {
1904
- extracted = require_subcommand_router.extractFields(command.args);
1904
+ extracted = require_schema_extractor.extractFields(command.args);
1905
1905
  if (!options.skipValidation) {
1906
1906
  validateDuplicateFields(extracted);
1907
1907
  validateCaseVariantCollisions(extracted);
@@ -1912,11 +1912,13 @@ function parseArgs(argv, command, options = {}) {
1912
1912
  if (options.globalExtracted) validateCrossSchemaCollisions(options.globalExtracted, extracted);
1913
1913
  }
1914
1914
  }
1915
- const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_subcommand_router.getAllAliases(f).includes("H")) ?? false;
1916
- const hasUserDefinedh = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_subcommand_router.getAllAliases(f).includes("h")) ?? false;
1917
- const helpAllRequested = argv.includes("--help-all") || !hasUserDefinedH && argv.includes("-H");
1918
- const helpRequested = !helpAllRequested && (argv.includes("--help") || !hasUserDefinedh && argv.includes("-h"));
1919
- const versionRequested = argv.includes("--version");
1915
+ const ddIdx = argv.indexOf("--");
1916
+ const flagScanArgv = ddIdx >= 0 ? argv.slice(0, ddIdx) : argv;
1917
+ const hasUserDefinedH = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_schema_extractor.getAllAliases(f).includes("H")) ?? false;
1918
+ const hasUserDefinedh = extracted?.fields.some((f) => f.overrideBuiltinAlias === true && require_schema_extractor.getAllAliases(f).includes("h")) ?? false;
1919
+ const helpAllRequested = flagScanArgv.includes("--help-all") || !hasUserDefinedH && flagScanArgv.includes("-H");
1920
+ const helpRequested = !helpAllRequested && (flagScanArgv.includes("--help") || !hasUserDefinedh && flagScanArgv.includes("-h"));
1921
+ const versionRequested = flagScanArgv.includes("--version");
1920
1922
  if (helpRequested || helpAllRequested || versionRequested) return {
1921
1923
  helpRequested,
1922
1924
  helpAllRequested,
@@ -1961,11 +1963,11 @@ function parseArgs(argv, command, options = {}) {
1961
1963
  const knownFlags = new Set(extracted.fields.map((f) => f.name));
1962
1964
  const knownCliNames = new Set(extracted.fields.map((f) => f.cliName));
1963
1965
  const knownAliases = /* @__PURE__ */ new Set();
1964
- for (const f of extracted.fields) for (const alias of require_subcommand_router.getAllAliases(f)) knownAliases.add(alias);
1966
+ for (const f of extracted.fields) for (const alias of require_schema_extractor.getAllAliases(f)) knownAliases.add(alias);
1965
1967
  if (options.globalExtracted) for (const f of options.globalExtracted.fields) {
1966
1968
  knownFlags.add(f.name);
1967
1969
  knownCliNames.add(f.cliName);
1968
- for (const alias of require_subcommand_router.getAllAliases(f)) knownAliases.add(alias);
1970
+ for (const alias of require_schema_extractor.getAllAliases(f)) knownAliases.add(alias);
1969
1971
  }
1970
1972
  const unknownFlags = [];
1971
1973
  for (const key of Object.keys(parsed.options)) if (!knownFlags.has(key) && !knownCliNames.has(key) && !knownAliases.has(key)) unknownFlags.push(key);
@@ -2305,7 +2307,7 @@ async function runMain(command, options = {}) {
2305
2307
  const argv = process.argv.slice(2);
2306
2308
  let globalExtractedForBypass;
2307
2309
  if (options.globalArgs) try {
2308
- globalExtractedForBypass = require_subcommand_router.extractFields(options.globalArgs);
2310
+ globalExtractedForBypass = require_schema_extractor.extractFields(options.globalArgs);
2309
2311
  } catch {}
2310
2312
  let effectiveOptions = options;
2311
2313
  if (isInternalSubcommandInvocation(command, argv, globalExtractedForBypass)) {
@@ -2376,8 +2378,8 @@ async function runCommandInternal(command, argv, options = {}) {
2376
2378
  };
2377
2379
  if (parseResult.helpRequested || parseResult.helpAllRequested) {
2378
2380
  let hasUnknownSubcommand = false;
2379
- const subCmdNames = require_subcommand_router.listSubCommands(command);
2380
- const allSubCmdNameSet = require_subcommand_router.listSubCommandNamesWithAliases(command);
2381
+ const subCmdNames = require_schema_extractor.listSubCommands(command);
2382
+ const allSubCmdNameSet = require_schema_extractor.listSubCommandNamesWithAliases(command);
2381
2383
  if (subCmdNames.length > 0) {
2382
2384
  const potentialSubCmd = findFirstPositional(argv, context.globalExtracted);
2383
2385
  if (potentialSubCmd && !allSubCmdNameSet.has(potentialSubCmd)) hasUnknownSubcommand = true;
@@ -2435,7 +2437,7 @@ async function runCommandInternal(command, argv, options = {}) {
2435
2437
  for (const flag of parseResult.unknownFlags) logger.error(formatUnknownFlagWarning(flag, knownGlobalFlags));
2436
2438
  }
2437
2439
  }
2438
- const resolved = await require_subcommand_router.resolveSubcommandWithAlias(command, parseResult.subCommand);
2440
+ const resolved = await require_schema_extractor.resolveSubcommandWithAlias(command, parseResult.subCommand);
2439
2441
  if (resolved) {
2440
2442
  const subContext = {
2441
2443
  commandPath: [...context.commandPath ?? [], parseResult.subCommand],
@@ -2453,7 +2455,7 @@ async function runCommandInternal(command, argv, options = {}) {
2453
2455
  });
2454
2456
  }
2455
2457
  }
2456
- if (require_subcommand_router.listSubCommands(command).length > 0 && !parseResult.subCommand && !command.run) {
2458
+ if (require_schema_extractor.listSubCommands(command).length > 0 && !parseResult.subCommand && !command.run) {
2457
2459
  const help = generateHelp(command, {
2458
2460
  showSubcommands: options.showSubcommands ?? true,
2459
2461
  context
@@ -2481,7 +2483,8 @@ async function runCommandInternal(command, argv, options = {}) {
2481
2483
  } else if (unknownKeysMode === "strip") for (const flag of parseResult.unknownFlags) logger.error(formatUnknownFlagWarning(flag, knownFlags));
2482
2484
  }
2483
2485
  let validatedGlobalArgs = {};
2484
- if (options.globalArgs && options._globalExtracted) {
2486
+ const isCompletionInvocation = command.name === "__complete";
2487
+ if (options.globalArgs && options._globalExtracted && !isCompletionInvocation) {
2485
2488
  for (const field of options._globalExtracted.fields) if (field.env && accumulatedGlobalArgs[field.name] === void 0) {
2486
2489
  const envNames = Array.isArray(field.env) ? field.env : [field.env];
2487
2490
  for (const envName of envNames) {
@@ -2510,7 +2513,7 @@ async function runCommandInternal(command, argv, options = {}) {
2510
2513
  }
2511
2514
  if (!command.args) {
2512
2515
  const proxiedGlobalArgs = createDualCaseProxy(validatedGlobalArgs);
2513
- if (options._globalExtracted) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
2516
+ if (options._globalExtracted && !isCompletionInvocation) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
2514
2517
  collector?.stop();
2515
2518
  return await executeLifecycle(command, proxiedGlobalArgs, {
2516
2519
  handleSignals: options.handleSignals,
@@ -2539,8 +2542,8 @@ async function runCommandInternal(command, argv, options = {}) {
2539
2542
  }
2540
2543
  const proxiedCommandArgs = createDualCaseProxy(validationResult.data);
2541
2544
  const proxiedGlobalArgs = createDualCaseProxy(validatedGlobalArgs);
2542
- if (options._globalExtracted) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
2543
- if (parseResult.extractedFields) await runEffects(proxiedCommandArgs, parseResult.extractedFields, proxiedGlobalArgs);
2545
+ if (options._globalExtracted && !isCompletionInvocation) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
2546
+ if (parseResult.extractedFields && !isCompletionInvocation) await runEffects(proxiedCommandArgs, parseResult.extractedFields, proxiedGlobalArgs);
2544
2547
  const mergedArgs = createDualCaseProxy({
2545
2548
  ...proxiedGlobalArgs,
2546
2549
  ...proxiedCommandArgs
@@ -2570,7 +2573,7 @@ async function runCommandInternal(command, argv, options = {}) {
2570
2573
  */
2571
2574
  function extractAndValidateGlobal(options) {
2572
2575
  if (!options.globalArgs) return void 0;
2573
- const extracted = require_subcommand_router.extractFields(options.globalArgs);
2576
+ const extracted = require_schema_extractor.extractFields(options.globalArgs);
2574
2577
  if (!options.skipValidation) {
2575
2578
  validateDuplicateFields(extracted);
2576
2579
  validateCaseVariantCollisions(extracted);
@@ -2758,4 +2761,4 @@ Object.defineProperty(exports, 'validateReservedAliases', {
2758
2761
  return validateReservedAliases;
2759
2762
  }
2760
2763
  });
2761
- //# sourceMappingURL=runner-BcyR6Z8r.cjs.map
2764
+ //# sourceMappingURL=runner-CRZ_7Y9i.cjs.map