poe-code 4.0.28 → 4.0.29

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.
@@ -1169,9 +1169,14 @@ function tokenizeHelpFlags(flags) {
1169
1169
  index = close + 1;
1170
1170
  continue;
1171
1171
  }
1172
- if (flags.startsWith("--", index) || (flags[index] === "-" && flags[index + 1] !== undefined && flags[index + 1] !== "-")) {
1172
+ if (flags.startsWith("--", index) ||
1173
+ (flags[index] === "-" && flags[index + 1] !== undefined && flags[index + 1] !== "-")) {
1173
1174
  let end = index + 1;
1174
- while (end < flags.length && flags[end] !== " " && flags[end] !== "[" && flags[end] !== "]" && flags[end] !== "<") {
1175
+ while (end < flags.length &&
1176
+ flags[end] !== " " &&
1177
+ flags[end] !== "[" &&
1178
+ flags[end] !== "]" &&
1179
+ flags[end] !== "<") {
1175
1180
  end += 1;
1176
1181
  }
1177
1182
  tokens.push({ text: flags.slice(index, end), role: "option" });
@@ -1180,7 +1185,11 @@ function tokenizeHelpFlags(flags) {
1180
1185
  }
1181
1186
  // Enum literals (a|b) or bare words after a flag.
1182
1187
  let end = index + 1;
1183
- while (end < flags.length && flags[end] !== " " && flags[end] !== "[" && flags[end] !== "]" && flags[end] !== "<") {
1188
+ while (end < flags.length &&
1189
+ flags[end] !== " " &&
1190
+ flags[end] !== "[" &&
1191
+ flags[end] !== "]" &&
1192
+ flags[end] !== "<") {
1184
1193
  end += 1;
1185
1194
  }
1186
1195
  const piece = flags.slice(index, end);
@@ -1621,9 +1630,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
1621
1630
  // Positionals are declared optional so resolveParams stays the single owner of argument
1622
1631
  // validation: Commander would otherwise report a missing positional in its own words
1623
1632
  // before prompts, defaults, and presets have had a chance to supply the value.
1624
- command.argument(field.variadicPosition === true
1625
- ? `[${field.displayPath}...]`
1626
- : `[${field.displayPath}]`);
1633
+ command.argument(field.variadicPosition === true ? `[${field.displayPath}...]` : `[${field.displayPath}]`);
1627
1634
  continue;
1628
1635
  }
1629
1636
  for (const option of createOption(field, globalLongOptionFlags)) {
@@ -1869,7 +1876,9 @@ function addGlobalOptions(command, presetsEnabled, controls) {
1869
1876
  }
1870
1877
  if (controls.output) {
1871
1878
  const choices = outputFormatNames(controls);
1872
- options.push(new Option("--output <format>", "Output format.").choices(choices).argParser((value) => {
1879
+ options.push(new Option("--output <format>", "Output format.")
1880
+ .choices(choices)
1881
+ .argParser((value) => {
1873
1882
  if (value === "rich" || value === "md" || value === "json") {
1874
1883
  return value;
1875
1884
  }
@@ -2591,8 +2600,8 @@ function renderCliErrorPattern(pattern, outputEmitter) {
2591
2600
  }
2592
2601
  if (pattern.kind === "definition") {
2593
2602
  logger.error(`Command definition error: ${pattern.error.message}\n` +
2594
- "This is a bug in the generated command definition, not in your command arguments.\n" +
2595
- "Run with --debug for a stack trace.");
2603
+ "This is a bug in the generated command definition, not in your command arguments." +
2604
+ (pattern.debugControlEnabled ? "\nRun with --debug for a stack trace." : ""));
2596
2605
  if (pattern.debugStackMode !== undefined && pattern.error.stack) {
2597
2606
  process.stderr.write(`${formatDebugStack(pattern.error.stack, pattern.debugStackMode)}\n`);
2598
2607
  }
@@ -2602,15 +2611,17 @@ function renderCliErrorPattern(pattern, outputEmitter) {
2602
2611
  if (pattern.kind === "toolcraft-bug") {
2603
2612
  logger.error(`toolcraft hit an internal invariant: ${pattern.error.message}\n` +
2604
2613
  `This is a bug in toolcraft or in the command definition; ` +
2605
- `it cannot be worked around by changing argv. ` +
2606
- `Re-run with --debug for a stack trace and file an issue.`);
2614
+ `it cannot be worked around by changing argv.` +
2615
+ (pattern.debugControlEnabled
2616
+ ? ` Re-run with --debug for a stack trace and file an issue.`
2617
+ : " File an issue."));
2607
2618
  if (pattern.debugStackMode !== undefined && pattern.error.stack) {
2608
2619
  process.stderr.write(`${formatDebugStack(pattern.error.stack, pattern.debugStackMode)}\n`);
2609
2620
  }
2610
2621
  process.exitCode = 1;
2611
2622
  return;
2612
2623
  }
2613
- logger.error(pattern.debugStackMode !== undefined
2624
+ logger.error(pattern.debugStackMode !== undefined || !pattern.debugControlEnabled
2614
2625
  ? pattern.message
2615
2626
  : `${pattern.message} Use --debug for a stack trace.`);
2616
2627
  if (pattern.debugStackMode !== undefined && pattern.stack !== undefined) {
@@ -3600,6 +3611,7 @@ async function handleRunError(error, options) {
3600
3611
  ? {
3601
3612
  kind: "definition",
3602
3613
  error,
3614
+ debugControlEnabled: options.debugControlEnabled,
3603
3615
  debugStackMode: options.debugStackMode
3604
3616
  }
3605
3617
  : options.userErrorPattern === "usage"
@@ -3619,6 +3631,7 @@ async function handleRunError(error, options) {
3619
3631
  renderCliErrorPattern({
3620
3632
  kind: "toolcraft-bug",
3621
3633
  error,
3634
+ debugControlEnabled: options.debugControlEnabled,
3622
3635
  debugStackMode: options.debugStackMode
3623
3636
  }, options.outputEmitter);
3624
3637
  return;
@@ -3663,6 +3676,7 @@ async function handleRunError(error, options) {
3663
3676
  kind: "unexpected",
3664
3677
  message,
3665
3678
  stack: error instanceof Error ? error.stack : undefined,
3679
+ debugControlEnabled: options.debugControlEnabled,
3666
3680
  debugStackMode: options.debugStackMode
3667
3681
  }, options.outputEmitter);
3668
3682
  });
@@ -4021,9 +4035,12 @@ export async function runCLI(roots, options = {}) {
4021
4035
  process.stderr.write(`Saved error report to ${report.displayPath}\n`);
4022
4036
  }
4023
4037
  await handleRunError(error, {
4024
- debugStackMode: resolvedFlags !== undefined
4025
- ? resolveDebugStackMode(resolvedFlags.debug)
4026
- : getDebugStackModeFromArgv(argv),
4038
+ debugControlEnabled: controls.debug,
4039
+ debugStackMode: controls.debug
4040
+ ? resolvedFlags !== undefined
4041
+ ? resolveDebugStackMode(resolvedFlags.debug)
4042
+ : getDebugStackModeFromArgv(argv)
4043
+ : undefined,
4027
4044
  output: resolvedFlags !== undefined
4028
4045
  ? resolveOutput(resolvedFlags)
4029
4046
  : resolveOutputFromArgv(argv, controls.outputFormats),