@cotal-ai/cli 0.182.0 → 0.182.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.
Files changed (162) hide show
  1. package/dist/command.d.ts.map +1 -1
  2. package/dist/command.js +138 -47
  3. package/dist/command.js.map +1 -1
  4. package/dist/commands/agents.js +5 -5
  5. package/dist/commands/agents.js.map +1 -1
  6. package/dist/commands/backup-maintenance.d.ts.map +1 -1
  7. package/dist/commands/backup-maintenance.js +9 -7
  8. package/dist/commands/backup-maintenance.js.map +1 -1
  9. package/dist/commands/backup.d.ts.map +1 -1
  10. package/dist/commands/backup.js +8 -2
  11. package/dist/commands/backup.js.map +1 -1
  12. package/dist/commands/clean.d.ts.map +1 -1
  13. package/dist/commands/clean.js +8 -2
  14. package/dist/commands/clean.js.map +1 -1
  15. package/dist/commands/ext.d.ts.map +1 -1
  16. package/dist/commands/ext.js +35 -4
  17. package/dist/commands/ext.js.map +1 -1
  18. package/dist/commands/help.js +1 -1
  19. package/dist/commands/help.js.map +1 -1
  20. package/dist/commands/history.d.ts.map +1 -1
  21. package/dist/commands/history.js +5 -1
  22. package/dist/commands/history.js.map +1 -1
  23. package/dist/commands/mint.js +27 -26
  24. package/dist/commands/mint.js.map +1 -1
  25. package/dist/commands/persona.d.ts +2 -2
  26. package/dist/commands/persona.d.ts.map +1 -1
  27. package/dist/commands/persona.js +4 -3
  28. package/dist/commands/persona.js.map +1 -1
  29. package/dist/commands/send.d.ts.map +1 -1
  30. package/dist/commands/send.js +9 -7
  31. package/dist/commands/send.js.map +1 -1
  32. package/dist/commands/service-registry.d.ts +1 -1
  33. package/dist/commands/service-registry.js +1 -1
  34. package/dist/commands/service-registry.js.map +1 -1
  35. package/dist/commands/setup.d.ts.map +1 -1
  36. package/dist/commands/setup.js +38 -14
  37. package/dist/commands/setup.js.map +1 -1
  38. package/dist/commands/spawn-flags.d.ts +1 -1
  39. package/dist/commands/spawn-flags.d.ts.map +1 -1
  40. package/dist/commands/spawn-flags.js +11 -3
  41. package/dist/commands/spawn-flags.js.map +1 -1
  42. package/dist/commands/spawn-managed-launch.js +1 -1
  43. package/dist/commands/spawn-managed-launch.js.map +1 -1
  44. package/dist/commands/stack-down.d.ts.map +1 -1
  45. package/dist/commands/stack-down.js +24 -12
  46. package/dist/commands/stack-down.js.map +1 -1
  47. package/dist/commands/stack-up.d.ts +1 -1
  48. package/dist/commands/stack-up.d.ts.map +1 -1
  49. package/dist/commands/stack-up.js +4 -3
  50. package/dist/commands/stack-up.js.map +1 -1
  51. package/dist/commands/stack-user-auth.d.ts +2 -2
  52. package/dist/commands/stack-user-auth.d.ts.map +1 -1
  53. package/dist/commands/stack-user-auth.js +6 -3
  54. package/dist/commands/stack-user-auth.js.map +1 -1
  55. package/dist/commands/status-health.d.ts +1 -1
  56. package/dist/commands/status-health.d.ts.map +1 -1
  57. package/dist/commands/status-health.js +3 -1
  58. package/dist/commands/status-health.js.map +1 -1
  59. package/dist/commands/status.js +3 -3
  60. package/dist/commands/status.js.map +1 -1
  61. package/dist/commands/team-boot-controller.d.ts.map +1 -1
  62. package/dist/commands/team-boot-controller.js +2 -1
  63. package/dist/commands/team-boot-controller.js.map +1 -1
  64. package/dist/commands/up-foreground-listener.d.ts +20 -0
  65. package/dist/commands/up-foreground-listener.d.ts.map +1 -0
  66. package/dist/commands/up-foreground-listener.js +156 -0
  67. package/dist/commands/up-foreground-listener.js.map +1 -0
  68. package/dist/commands/up-resume.d.ts +1 -1
  69. package/dist/commands/up-resume.d.ts.map +1 -1
  70. package/dist/commands/up-resume.js +12 -5
  71. package/dist/commands/up-resume.js.map +1 -1
  72. package/dist/commands/up.d.ts.map +1 -1
  73. package/dist/commands/up.js +26 -146
  74. package/dist/commands/up.js.map +1 -1
  75. package/dist/commands/update-process.d.ts.map +1 -1
  76. package/dist/commands/update-process.js +11 -8
  77. package/dist/commands/update-process.js.map +1 -1
  78. package/dist/commands/update.js +1 -1
  79. package/dist/console/app.d.ts.map +1 -1
  80. package/dist/console/app.js +2 -1
  81. package/dist/console/app.js.map +1 -1
  82. package/dist/console/mesh.d.ts +1 -1
  83. package/dist/console/mesh.d.ts.map +1 -1
  84. package/dist/console/mesh.js +1 -1
  85. package/dist/console/mesh.js.map +1 -1
  86. package/dist/console/ui/CommandPalette.d.ts +2 -1
  87. package/dist/console/ui/CommandPalette.d.ts.map +1 -1
  88. package/dist/console/ui/CommandPalette.js +4 -4
  89. package/dist/console/ui/CommandPalette.js.map +1 -1
  90. package/dist/help.d.ts +1 -6
  91. package/dist/help.d.ts.map +1 -1
  92. package/dist/help.js +19 -3
  93. package/dist/help.js.map +1 -1
  94. package/dist/index.js +3 -3
  95. package/dist/index.js.map +1 -1
  96. package/dist/lib/choose-target.d.ts.map +1 -1
  97. package/dist/lib/choose-target.js +1 -0
  98. package/dist/lib/choose-target.js.map +1 -1
  99. package/dist/lib/command-path.d.ts +6 -0
  100. package/dist/lib/command-path.d.ts.map +1 -1
  101. package/dist/lib/command-path.js +3 -0
  102. package/dist/lib/command-path.js.map +1 -1
  103. package/dist/lib/completion-scripts.d.ts.map +1 -1
  104. package/dist/lib/completion-scripts.js +1 -1
  105. package/dist/lib/completion-scripts.js.map +1 -1
  106. package/dist/lib/endpoint-errors.d.ts.map +1 -1
  107. package/dist/lib/endpoint-errors.js +17 -2
  108. package/dist/lib/endpoint-errors.js.map +1 -1
  109. package/dist/lib/extension-stage.d.ts.map +1 -1
  110. package/dist/lib/extension-stage.js +8 -6
  111. package/dist/lib/extension-stage.js.map +1 -1
  112. package/dist/lib/foreground-hold.d.ts +2 -2
  113. package/dist/lib/foreground-hold.d.ts.map +1 -1
  114. package/dist/lib/foreground-hold.js +31 -9
  115. package/dist/lib/foreground-hold.js.map +1 -1
  116. package/dist/lib/history-command.d.ts +2 -1
  117. package/dist/lib/history-command.d.ts.map +1 -1
  118. package/dist/lib/history-command.js +4 -2
  119. package/dist/lib/history-command.js.map +1 -1
  120. package/dist/lib/isolated-broker.d.ts.map +1 -1
  121. package/dist/lib/isolated-broker.js +80 -31
  122. package/dist/lib/isolated-broker.js.map +1 -1
  123. package/dist/lib/leading-flags.d.ts +1 -0
  124. package/dist/lib/leading-flags.d.ts.map +1 -1
  125. package/dist/lib/leading-flags.js +5 -2
  126. package/dist/lib/leading-flags.js.map +1 -1
  127. package/dist/lib/npm-invocation.d.ts +13 -9
  128. package/dist/lib/npm-invocation.d.ts.map +1 -1
  129. package/dist/lib/npm-invocation.js +66 -17
  130. package/dist/lib/npm-invocation.js.map +1 -1
  131. package/dist/lib/paths.d.ts +1 -1
  132. package/dist/lib/paths.d.ts.map +1 -1
  133. package/dist/lib/paths.js +3 -3
  134. package/dist/lib/paths.js.map +1 -1
  135. package/dist/lib/persona-files.d.ts.map +1 -1
  136. package/dist/lib/persona-files.js +17 -1
  137. package/dist/lib/persona-files.js.map +1 -1
  138. package/dist/lib/personas.d.ts +3 -4
  139. package/dist/lib/personas.d.ts.map +1 -1
  140. package/dist/lib/personas.js +6 -5
  141. package/dist/lib/personas.js.map +1 -1
  142. package/dist/lib/restore.d.ts +6 -2
  143. package/dist/lib/restore.d.ts.map +1 -1
  144. package/dist/lib/restore.js +18 -11
  145. package/dist/lib/restore.js.map +1 -1
  146. package/dist/lib/service-process.d.ts.map +1 -1
  147. package/dist/lib/service-process.js +4 -1
  148. package/dist/lib/service-process.js.map +1 -1
  149. package/dist/lib/stack-journal.d.ts +2 -2
  150. package/dist/lib/stack-journal.d.ts.map +1 -1
  151. package/dist/lib/stack-journal.js +20 -7
  152. package/dist/lib/stack-journal.js.map +1 -1
  153. package/dist/lib/update-manager-install-linux.d.ts +8 -0
  154. package/dist/lib/update-manager-install-linux.d.ts.map +1 -0
  155. package/dist/lib/update-manager-install-linux.js +128 -0
  156. package/dist/lib/update-manager-install-linux.js.map +1 -0
  157. package/dist/lib/update-managers.d.ts.map +1 -1
  158. package/dist/lib/update-managers.js +2 -1
  159. package/dist/lib/update-managers.js.map +1 -1
  160. package/dist/lib/version.js +3 -3
  161. package/dist/lib/version.js.map +1 -1
  162. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6E,KAAK,OAAO,EAAkC,KAAK,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAmEzL,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAoWlF,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B;;;oCAGgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;gCAE4B;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAkSD,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAUtE;AAsJD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlG"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6E,KAAK,OAAO,EAAkC,KAAK,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAmEzL,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAuWlF,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B;;;oCAGgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;gCAE4B;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAiWD,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAUtE;AA8JD;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlG"}
package/dist/command.js CHANGED
@@ -16,7 +16,7 @@ import { historySetupFailureRecords, membershipSetupFailureRecords, watchSetupFa
16
16
  import { HISTORY_LIMIT_FLAGS } from "./commands/history-limit.js";
17
17
  import { CatalogPreparationError, prepareCatalogCommand } from "./commands/sync.js";
18
18
  import { keepStartupNotice } from "./lib/interrupt-notice.js";
19
- import { metadataPositionals } from "./lib/command-path.js";
19
+ import { metadataPositionals, parserOptions } from "./lib/command-path.js";
20
20
  import { chooseMeshTarget, spaceChoiceRemedy } from "./lib/choose-target.js";
21
21
  import { registryFailure } from "./lib/registry-errors.js";
22
22
  import { FlagValueRefusal } from "./lib/flag-value-refusal.js";
@@ -25,7 +25,7 @@ import { npmProjectDirectory, preserveUpdatePath } from "./lib/npm-invocation.js
25
25
  import { reportLostOutput, writeAllSync } from "./lib/stdout-owner.js";
26
26
  import { shellWord } from "./lib/endpoint-errors.js";
27
27
  import { displayRemedy, hasMovedStackRemedy } from "./lib/self-exec.js";
28
- import { asksForHelp, GLOBAL_FLAG_WORDS, leadingInvocation, OUTPUT_FLAG_WORDS } from "./lib/leading-flags.js";
28
+ import { asksForHelp, GLOBAL_FLAG_WORDS, leadingInvocation, OUTPUT_FLAG_WORDS, TYPOGRAPHIC_OPTION } from "./lib/leading-flags.js";
29
29
  import { takeManagedHandoffCustody } from "./managed-handoff.js";
30
30
  import { nearestWords, LEADING_FLAGS, unknownCommandMessage, unknownSubcommandMessage } from "./lib/nearest-word.js";
31
31
  import { UnusableFile } from "./lib/unusable-file.js";
@@ -98,10 +98,11 @@ async function repeatedGlobalFlag(word, cmd, words, warnings = [], textWords) {
98
98
  ? { message: `--${flag.name} cannot be repeated`, remedy: `use --${flag.name} once` }
99
99
  : missingValue(found, rest, flag)
100
100
  : { message: `Option '${word}' cannot be repeated` };
101
- if (!json)
102
- for (const warning of warnings)
103
- console.error(c.red(`! ${warning.message}`));
104
- return runOperation({ warnings }, () => usageExit(refusal.message, found, json, options.includes("--plain"), refusal.remedy, rest));
101
+ if (found && json && isExtensionStub(found)) {
102
+ return runOperation({ warnings }, () => usageExit(refusal.message, found, json, options.includes("--plain"), refusal.remedy, rest));
103
+ }
104
+ routeCollisionWarnings(warnings, found, rest, false);
105
+ return usageExit(refusal.message, found, json, options.includes("--plain"), refusal.remedy, rest);
105
106
  }
106
107
  /** Whether the invoked mode declares a structured output, so it reports every outcome by the 0 to 5
107
108
  * table: the subcommand `first` selects, else the command's bare form. */
@@ -468,6 +469,15 @@ function streamRefusalArgs(cmd, words) {
468
469
  args.splice(missing.index + 1, 0, "");
469
470
  }
470
471
  }
472
+ /** An unreadable extension surface refuses dispatch, using the known built-in output mode if available. */
473
+ function overlayFailureExit(error, builtin, words, wantsHelp, scope) {
474
+ if (error instanceof CorruptExtensionsManifestError && builtin && !wantsHelp && !takesWordsRaw(builtin) && asksForJson(builtin, words)) {
475
+ const failure = new CommandFailure("refused", "SCHEMA_INVALID", error.diagnosis, { remedy: error.remedy, cause: error });
476
+ failureExit(builtin, failure, true, false, scope, words, streamRefusalArgs(builtin, words));
477
+ }
478
+ stderrLine("✗ ", error.message, c.red);
479
+ process.exit(1);
480
+ }
471
481
  /** A usage error, written by {@link usageRefusal} with the help of the command or subcommand `words`
472
482
  * name when there is one, and with `remedy` under the message when the parser can name one. Exit 1. */
473
483
  function usageExit(message, cmd, json = false, plain = false, remedy, words = []) {
@@ -483,7 +493,7 @@ function usageExit(message, cmd, json = false, plain = false, remedy, words = []
483
493
  /** The refusal for a named or short option typed with a typographic dash pasted from
484
494
  * typeset text, as `\u2013\u2013json`, naming it with hyphens; undefined when `word` is no such option. */
485
495
  function typographicOption(word, names, flags = []) {
486
- const typed = /^[\u2010-\u2015\u2212][-\u2010-\u2015\u2212]*([^=]+)(?:=(.*))?$/su.exec(word);
496
+ const typed = TYPOGRAPHIC_OPTION.exec(word);
487
497
  if (!typed)
488
498
  return undefined;
489
499
  const [, name, value] = typed;
@@ -550,9 +560,6 @@ function misspelledOption(cmd, rest, flagNames) {
550
560
  }
551
561
  return undefined;
552
562
  }
553
- function parserOptions(cmd) {
554
- return Object.fromEntries((cmd.flags ?? []).map(({ name, type, short }) => [name, { type, ...(short ? { short } : {}) }]));
555
- }
556
563
  /** Strip standalone globals, but keep any global where a string option needs its value. */
557
564
  function stripGlobalFlags(cmd, words) {
558
565
  if (takesWordsRaw(cmd))
@@ -570,6 +577,8 @@ function missingValue(cmd, words, flag, beforeSeparator = false) {
570
577
  return { message: `\`run check\` does not take --${flag.name}`, remedy: `run the check without --${flag.name}` };
571
578
  if (cmd.name === "endpoint" && flag.name === "file" && helpPath(cmd, words).path[0] === "check")
572
579
  return { message: "`endpoint check` does not take --file", remedy: "omit --file and keep the contract path" };
580
+ if (cmd.name === "service" && flag.name === "exec" && helpPath(cmd, words).path[0] === "status")
581
+ return { message: "`service status` does not take --exec", remedy: "omit --exec" };
573
582
  if (cmd.name === "history") {
574
583
  const sub = helpPath(cmd, words).path[0];
575
584
  if (sub === "limit" && flag.name === "server")
@@ -577,15 +586,101 @@ function missingValue(cmd, words, flag, beforeSeparator = false) {
577
586
  if (sub === "clear" && HISTORY_LIMIT_FLAGS.some((name) => name === flag.name))
578
587
  return { message: `\`history clear\` does not take --${flag.name}`, remedy: `omit --${flag.name} from this command. Use it with \`history limit\` to change retention` };
579
588
  }
589
+ if (cmd.name === "persona" && flag.name === "subscribe")
590
+ return { message: "--subscribe needs a value", remedy: `write --subscribe <a,b> or --subscribe= for none${beforeSeparator ? " (before --)" : ""}` };
580
591
  return { message: `--${flag.name} needs a value`, remedy: `write --${flag.name} ${flag.value ?? "<value>"}${beforeSeparator ? " before --" : ""}` };
581
592
  }
582
- function switchValueRefusal(flag, cmd, rest = []) {
593
+ function switchValueRefusal(flag, cmd, rest = [], json = false) {
583
594
  const first = cmd && metadataPositionals(cmd, rest).positionals[0]?.value;
584
595
  const acceptsFlag = GLOBAL_FLAG_WORDS.has(flag) || (cmd && (flag === "--plain"
585
- ? (findSubcommand(cmd, first) ?? cmd).outputs?.includes("plain")
596
+ ? !json && (findSubcommand(cmd, first) ?? cmd).outputs?.includes("plain")
586
597
  : structured(cmd, first)));
587
598
  return { message: `${flag} takes no value`, remedy: `omit ${flag}${acceptsFlag ? " or pass it without a value" : ""}` };
588
599
  }
600
+ /** Positional word limit for the separator remedy only, counting subcommand words. Commands with
601
+ * variable or unspecified arity keep their own grammar. */
602
+ function operandLimit(cmd, selected, first, rest) {
603
+ const mode = selected.name;
604
+ const values = () => parseArgs({ args: [...rest], options: parserOptions(cmd), strict: false, allowPositionals: true }).values;
605
+ switch (cmd.name) {
606
+ case "app-identity":
607
+ case "chat":
608
+ case "clean":
609
+ case "describe":
610
+ case "docs":
611
+ case "doctor":
612
+ case "feedback":
613
+ case "manager":
614
+ case "pending":
615
+ case "telemetry": return 1;
616
+ case "backup":
617
+ case "invoke":
618
+ case "persona":
619
+ case "reset":
620
+ case "service-endpoint":
621
+ case "space":
622
+ return 2;
623
+ case "config": return mode === "set" ? 3 : 2;
624
+ case "actor": return mode === "list" ? 1 : mode === "label" ? 3 : 2;
625
+ case "auth": return mode === "grants" || mode === "signer" ? 1 : mode === "inspect" ? 3 : 2;
626
+ case "channel": return mode === "defaults" ? 1 : 2;
627
+ case "daemon": return mode === "name" ? 2 : 1;
628
+ case "endpoint":
629
+ if (mode === "list")
630
+ return 1;
631
+ if (mode === "lease" || mode === "commit")
632
+ return 4;
633
+ if (mode === "work")
634
+ return 3;
635
+ return ["deregister", "invoke", "watch", "session"].includes(mode) ? 3 : 2;
636
+ case "ext": return mode === "root" || mode === "list" ? 1 : mode === "add" || mode === "remove" ? 2 : Infinity;
637
+ case "linear": return mode === "account" ? 2 : ["add", "login", "show", "call", "resource", "prompt"].includes(mode) ? 3 : 2;
638
+ case "meshes": return first === "add" ? 2 : Infinity;
639
+ case "personas":
640
+ case "service":
641
+ case "team": return mode === "list" ? 1 : 2;
642
+ case "run":
643
+ if (mode === "list" || mode === "turns")
644
+ return 1;
645
+ if (mode === "answer" || mode === "amend")
646
+ return 3;
647
+ if (mode === "check")
648
+ return values().file === undefined ? 3 : 2;
649
+ if (mode === "start" && values().file !== undefined)
650
+ return 1;
651
+ return 2;
652
+ case "attach": return values().name === undefined ? 1 : 0;
653
+ case "history": return mode === "clear" || mode === "limit" || !values().dms ? 1 : 0;
654
+ case "input": {
655
+ const { name, text } = values();
656
+ return name !== undefined ? 0 : text !== undefined ? 1 : 2;
657
+ }
658
+ case "login": {
659
+ const { cloud, idp, "migrate-from": migrateFrom } = values();
660
+ return cloud || idp !== undefined || migrateFrom !== undefined ? 0 : 1;
661
+ }
662
+ case "send": {
663
+ const { file, stdin } = values();
664
+ return file !== undefined || stdin ? 0 : 1;
665
+ }
666
+ case "spawn": return values().file === undefined ? 1 : 0;
667
+ case "status": {
668
+ const { all, components, wide, verbose } = values();
669
+ return all || components || wide || verbose ? 0 : 1;
670
+ }
671
+ case "stop": {
672
+ const { self, name } = values();
673
+ return self || name !== undefined ? 0 : 1;
674
+ }
675
+ case "topology": return values().file === undefined ? 2 : 1;
676
+ case "update": {
677
+ const { auto, notify } = values();
678
+ return auto || notify ? 1 : 0;
679
+ }
680
+ case "use": return values().clear ? 0 : 1;
681
+ default: return Infinity;
682
+ }
683
+ }
589
684
  /** A parse error as a refusal. A mistyped option names its spelling. A word that starts with `-`
590
685
  * goes after `--` only where the command has room for an operand and there is no spelling suggestion.
591
686
  * An option value that starts with `-` is written `--name=value`, and an option given with no value,
@@ -612,7 +707,7 @@ function parseRefusal(error, cmd, rest, flagNames, takesOperands, operandsFull)
612
707
  const message = spellings ? `${reason} - did you mean ${spellings}?` : reason;
613
708
  const remedy = cmd.name === "completion" ? "drop the unknown option"
614
709
  : !takesOperands ? undefined : spellings ? `use ${spellings}`
615
- : operandsFull ? "drop the unknown option" : "to pass a word that starts with \"-\", put -- before it";
710
+ : operandsFull() ? "drop the unknown option" : "to pass a word that starts with \"-\", put -- before it";
616
711
  return { message, remedy };
617
712
  }
618
713
  if (error.code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL") {
@@ -679,17 +774,7 @@ function parseOrExit(cmd, rest, noMoreOperands = false) {
679
774
  }
680
775
  const takesOperands = !seed && cmd.positionals !== undefined &&
681
776
  (!cmd.subcommands?.length || cmd.name === "history" || (first !== undefined && findSubcommand(cmd, first) !== undefined));
682
- const operandsFull = noMoreOperands || (cmd.name === "config" && ((selected.name === "set" && positionals.length >= 3)
683
- || ((selected.name === "get" || selected.name === "unset") && positionals.length >= 2)))
684
- || (cmd.name === "docs" && positionals.length >= 1)
685
- || (cmd.name === "ext" && selected.name === "root")
686
- || (cmd.name === "history" && selected.name === "limit")
687
- || (cmd.name === "space" && selected.name === "add" && positionals.length >= 2)
688
- || (cmd.name === "channel" && selected.name === "set" && positionals.length >= 2)
689
- || (cmd.name === "service" && selected !== cmd && (selected.name === "list" || positionals.length >= 2))
690
- || (cmd.name === "team" && ["check", "boot", "deploy"].includes(selected.name) && positionals.length >= 2)
691
- || (cmd.name === "endpoint" && ((selected.name === "check" && positionals.length >= 2)
692
- || (first === "work" && selected.name === "lease" && positionals.length >= 4)));
777
+ const operandsFull = () => noMoreOperands || positionals.length >= operandLimit(cmd, selected, first, rest);
693
778
  const refusal = parseRefusal(e, cmd, rest, seed?.flagNames ?? selected.flagNames, takesOperands, operandsFull);
694
779
  usageExit(refusal.message, cmd, json, plain, refusal.remedy, rest);
695
780
  }
@@ -841,7 +926,7 @@ function helpPath(cmd, rest) {
841
926
  * does, so a mistyped subcommand never gets its group's help. */
842
927
  function printHelpFor(cmd, rest) {
843
928
  const { path, unknown } = helpPath(cmd, rest);
844
- paintFor(process.stdout, () => printHelpPath(cmd, unknown === undefined ? path : [...path, unknown]));
929
+ paintFor(process.stdout, () => printHelpPath(cmd, unknown === undefined ? path : [...path, unknown], undefined, undefined, undefined, rest));
845
930
  }
846
931
  /** A service invocation takes its preset's flags, and `manager <verb>` is `service <verb> manager`.
847
932
  * Preset details can enrich a global flag refusal but cannot replace it. */
@@ -863,22 +948,30 @@ async function serviceSurface(found, words, forRefusal = false) {
863
948
  }
864
949
  }
865
950
  /** Recover the command and output mode for a malformed leading switch without dispatching it. */
866
- async function unknownInvocationExit(commands, word, args, output, beforeSeparator, typed) {
951
+ async function unknownInvocationExit(commands, word, args, output, beforeSeparator, warnings) {
952
+ const typed = typographicOption(word, new Set(LEADING_FLAGS.map((flag) => flag.slice(2))), [
953
+ jsonFlag, { name: "help", short: "h", type: "boolean" }, { name: "version", short: "V", type: "boolean" },
954
+ ]);
867
955
  const equals = word.indexOf("=");
868
956
  const flag = equals === -1 ? word : word.slice(0, equals);
869
957
  const malformedSwitch = equals !== -1 && (GLOBAL_FLAG_WORDS.has(flag) || OUTPUT_FLAG_WORDS.has(flag));
958
+ const textExit = () => {
959
+ routeCollisionWarnings(warnings, undefined, [...output, ...args], false);
960
+ return usageExit(typed?.message ?? unknownCommandMessage(commands, word), undefined, false, false, typed?.remedy);
961
+ };
870
962
  if (!beforeSeparator || (!typed && !malformedSwitch))
871
- usageExit(typed?.message ?? unknownCommandMessage(commands, word), undefined, false, false, typed?.remedy);
963
+ return textExit();
872
964
  const retry = leadingInvocation(args, true);
873
965
  const found = findCommand(commands, retry.word);
874
966
  const words = [...output, ...retry.leading.filter((item) => OUTPUT_FLAG_WORDS.has(item)), ...retry.args];
875
967
  const { cmd, rest } = await serviceSurface(takesWordsRaw(found) ? undefined : found, words, true);
876
968
  const json = cmd !== undefined && asksForJson(cmd, rest);
877
969
  if (typed && !json)
878
- usageExit(typed.message, undefined, false, false, typed.remedy);
970
+ return textExit();
971
+ routeCollisionWarnings(warnings, cmd, rest, false);
879
972
  const end = rest.indexOf("--");
880
973
  const plain = (end === -1 ? rest : rest.slice(0, end)).includes("--plain");
881
- const refusal = typed ?? switchValueRefusal(flag, cmd, rest);
974
+ const refusal = typed ?? switchValueRefusal(flag, cmd, rest, json);
882
975
  return usageExit(refusal.message, cmd, json, plain, refusal.remedy, rest);
883
976
  }
884
977
  function repeatedInvocationExit(repeated, cmd, rest, warnings, commands, tail, output) {
@@ -954,9 +1047,16 @@ async function dispatchCli(registry, argv, opts, scope) {
954
1047
  takeManagedHandoffCustody(process.env, builtin?.name === "spawn");
955
1048
  const docsHelp = isExplicitDocsHelp(registry, builtin, wantsHelp, words);
956
1049
  setInstalledExtensionsEnabled(Boolean(opts.extensions) && !docsHelp);
1050
+ const pendingWarnings = [];
957
1051
  const builtinDuplicate = builtin && duplicate(builtin);
958
- if (builtinDuplicate)
959
- return repeatedGlobalFlag(builtinDuplicate, builtin, ownWords(builtin));
1052
+ if (builtinDuplicate) {
1053
+ try {
1054
+ if (opts.extensions && !docsHelp)
1055
+ overlayExtensions(registry, collisionWarning(pendingWarnings));
1056
+ }
1057
+ catch { /* An unreadable manifest does not replace the argument refusal. */ }
1058
+ return repeatedGlobalFlag(builtinDuplicate, builtin, ownWords(builtin), pendingWarnings);
1059
+ }
960
1060
  if (word === "-v")
961
1061
  usageExit("-v is not the version flag - run `cotal version` or `cotal -V`");
962
1062
  // The built-in check reports an unreadable inventory itself. Do not require that inventory to
@@ -1018,7 +1118,6 @@ async function dispatchCli(registry, argv, opts, scope) {
1018
1118
  }
1019
1119
  }
1020
1120
  }
1021
- const pendingWarnings = [];
1022
1121
  const surface = (warnings) => {
1023
1122
  let commands;
1024
1123
  try {
@@ -1027,7 +1126,8 @@ async function dispatchCli(registry, argv, opts, scope) {
1027
1126
  catch (e) {
1028
1127
  const infrastructureStatus = builtin?.name === "status" && !wantsHelp && !words.includes("--components")
1029
1128
  && metadataPositionals(builtin, words).positionals.length === 0;
1030
- if (((configRead || completionStatus || infrastructureStatus) && e instanceof CorruptExtensionsManifestError) || skipUnreadableConnectorOverlay(e)) {
1129
+ if (((configRead || completionStatus || infrastructureStatus) && e instanceof CorruptExtensionsManifestError)
1130
+ || (infrastructureStatus && isCommandFailure(e) && e.code === "PERMISSION_DENIED") || skipUnreadableConnectorOverlay(e)) {
1031
1131
  // The infrastructure report reads the manifest itself and can name the gap.
1032
1132
  if (infrastructureStatus)
1033
1133
  setInstalledExtensionsEnabled(false);
@@ -1036,9 +1136,7 @@ async function dispatchCli(registry, argv, opts, scope) {
1036
1136
  else {
1037
1137
  if (repeatedLeading)
1038
1138
  usageExit(`Option '${repeatedLeading}' cannot be repeated`);
1039
- // A corrupt extensions manifest must not silently shrink the surface.
1040
- stderrLine("✗ ", e.message, c.red);
1041
- process.exit(1);
1139
+ overlayFailureExit(e, builtin, words, wantsHelp, scope);
1042
1140
  }
1043
1141
  }
1044
1142
  for (const cmd of commands) {
@@ -1060,6 +1158,10 @@ async function dispatchCli(registry, argv, opts, scope) {
1060
1158
  const repeated = duplicate(cmd);
1061
1159
  if (repeated)
1062
1160
  return repeatedInvocationExit(repeated, cmd, rest, pendingWarnings, commands, argv.slice(leading.length), output);
1161
+ // A seeded command can be absent until the first seed installs it. Help and unknown words do not seed.
1162
+ const awaitingSeed = !cmd && word !== undefined && opts.extensions === true && isSeededCommand(word) && !wantsHelp && !skipsSeed(word, rest[0], rest);
1163
+ if (!cmd && word !== undefined && !awaitingSeed)
1164
+ return unknownInvocationExit(commands, word, args, output, argv[leading.length] !== "--", pendingWarnings);
1063
1165
  routeCollisionWarnings(pendingWarnings, cmd, rest, wantsHelp);
1064
1166
  if (word === undefined)
1065
1167
  return paintFor(process.stdout, () => printEntry(commands));
@@ -1080,17 +1182,6 @@ async function dispatchCli(registry, argv, opts, scope) {
1080
1182
  }
1081
1183
  };
1082
1184
  arm();
1083
- // A seeded package's command (`web`) can be absent only because the first seed has not installed
1084
- // it yet, so running it seeds and resolves again. Asking for its help seeds nothing, and any other
1085
- // unknown word is a usage error.
1086
- const awaitingSeed = !cmd && opts.extensions === true && isSeededCommand(word) && !wantsHelp && !skipsSeed(word, rest[0], rest);
1087
- // A leading flag typed with a typographic dash is read as the command word, so it is refused as the
1088
- // same word after the command word is.
1089
- const typed = cmd || awaitingSeed ? undefined : typographicOption(word, new Set(LEADING_FLAGS.map((flag) => flag.slice(2))), [
1090
- jsonFlag, { name: "help", short: "h", type: "boolean" }, { name: "version", short: "V", type: "boolean" },
1091
- ]);
1092
- if (!cmd && !awaitingSeed)
1093
- return unknownInvocationExit(commands, word, args, output, argv[leading.length] !== "--", typed);
1094
1185
  // `cotal <cmd> --help` / `-h` → that command's help, never run it. This intercept also covers
1095
1186
  // rawArgs commands and extension STUBS (cached specs are exactly the display surface) — only
1096
1187
  // `__`-internal ones are exempt, because __complete's argv is ANOTHER command's half-typed