@kaynooo/cli-wait 0.10.1 → 0.12.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/dist/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  // src/cli.ts
5
5
  import { existsSync as existsSync6 } from "fs";
6
- import process18 from "process";
6
+ import process20 from "process";
7
7
  // ../kit/src/args.ts
8
8
  import process9 from "process";
9
9
  import { parseArgs } from "util";
@@ -469,24 +469,20 @@ function printJson(value) {
469
469
 
470
470
  // ../kit/src/help.ts
471
471
  import process8 from "process";
472
- var OPTIONAL = /\[[^\]]+\]/g;
472
+ var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
473
473
  var USAGE_PREFIX = /^usage:\s*/i;
474
474
  var FULL_STOP = /\.$/;
475
475
  function usageLine(usage, colors = paint(process8.stdout)) {
476
476
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
477
477
  }
478
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
479
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
478
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
479
+ return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
480
480
  `);
481
481
  }
482
482
  function exitRows(exits, colors = paint(process8.stdout)) {
483
483
  if (exits.length === 0)
484
484
  return [];
485
- const width = Math.max(...exits.map(([code]) => String(code).length));
486
- return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
487
- }
488
- function replacesRows(replaces, colors = paint(process8.stdout)) {
489
- return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
485
+ return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
490
486
  }
491
487
  function wantsHelpJson(env = process8.env) {
492
488
  return env.KIT_HELP === "json";
@@ -512,29 +508,40 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
512
508
  return [];
513
509
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
514
510
  }
511
+ var MAX_INLINE_CHOICES = 24;
515
512
  function optionRows(options, colors = paint(process8.stdout)) {
516
513
  const rows = Object.entries(options).map(([name, option]) => {
517
514
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
518
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
515
+ const choices = option.choices?.join("|");
516
+ const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
517
+ const named = inline ? `<${choices}>` : "<value>";
519
518
  const placeholder = option.optional === undefined ? named : `[${named}]`;
520
519
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
521
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
520
+ const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
521
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
522
522
  });
523
523
  const width = Math.max(0, ...rows.map((row) => row.width));
524
524
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
525
525
  }
526
526
 
527
527
  // ../kit/src/text.ts
528
- var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
529
528
  function distance(a, b) {
530
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
531
- for (const [i, left] of [...a].entries()) {
529
+ const left = [...a];
530
+ const right = [...b];
531
+ let before = [];
532
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
533
+ for (const [i, x] of left.entries()) {
532
534
  const current = [i + 1];
533
- for (const [j, right] of [...b].entries())
534
- current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
535
+ for (const [j, y] of right.entries()) {
536
+ let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
537
+ if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
538
+ cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
539
+ current.push(cost);
540
+ }
541
+ before = previous;
535
542
  previous = current;
536
543
  }
537
- return previous[b.length] ?? 0;
544
+ return previous[right.length] ?? 0;
538
545
  }
539
546
  function closest(name, names) {
540
547
  const started = names.find((known) => known.startsWith(name));
@@ -610,7 +617,7 @@ class Completing {
610
617
  }
611
618
  var completion = { active: false };
612
619
  var OUTPUT_OPTIONS = {
613
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
620
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
614
621
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
615
622
  };
616
623
  function applyOutput(color, plain, env = process9.env) {
@@ -782,12 +789,36 @@ function nearestOption(message, options, allowNegative) {
782
789
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
783
790
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
784
791
  }
792
+ // ../kit/src/argv.ts
793
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
794
+ import { resolve as resolve3 } from "path";
795
+ import process10 from "process";
796
+ function commandLine() {
797
+ try {
798
+ return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
799
+ } catch {
800
+ return;
801
+ }
802
+ }
803
+ function realPath(word) {
804
+ try {
805
+ return realpathSync(resolve3(word));
806
+ } catch {
807
+ return;
808
+ }
809
+ }
810
+ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), script = process10.argv[1]) {
811
+ const target = script === undefined ? undefined : realPath(script) ?? script;
812
+ const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
813
+ const after = at === -1 ? [] : cmdline.slice(at + 1);
814
+ return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
815
+ }
785
816
  // ../kit/src/progress.ts
786
- import process11 from "process";
817
+ import process12 from "process";
787
818
 
788
819
  // ../kit/src/process.ts
789
820
  import { constants } from "os";
790
- import process10 from "process";
821
+ import process11 from "process";
791
822
  var KILL_GRACE_MS = 2000;
792
823
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
793
824
  function exitCodeOf(code, signal) {
@@ -809,7 +840,7 @@ function holdSignals(cleanup) {
809
840
  },
810
841
  release: () => {
811
842
  for (const signal of SIGNALS)
812
- process10.off(signal, onSignal);
843
+ process11.off(signal, onSignal);
813
844
  }
814
845
  };
815
846
  function onSignal(signal) {
@@ -822,10 +853,10 @@ function holdSignals(cleanup) {
822
853
  return;
823
854
  held.release();
824
855
  cleanup(signal);
825
- process10.kill(process10.pid, signal);
856
+ process11.kill(process11.pid, signal);
826
857
  }
827
858
  for (const signal of SIGNALS)
828
- process10.on(signal, onSignal);
859
+ process11.on(signal, onSignal);
829
860
  return held;
830
861
  }
831
862
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -839,7 +870,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
839
870
  return;
840
871
  try {
841
872
  if (grouped)
842
- process10.kill(-proc.pid, killing);
873
+ process11.kill(-proc.pid, killing);
843
874
  else
844
875
  proc.kill(killing);
845
876
  } catch {}
@@ -917,7 +948,7 @@ var RESET_STYLE = `${ESC}[0m`;
917
948
  var CTRL_C = 3;
918
949
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
919
950
  var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
920
- function liveRegion(render, stream = process11.stderr, env = process11.env) {
951
+ function liveRegion(render, stream = process12.stderr, env = process12.env) {
921
952
  if (!takesControlCodes(stream, env))
922
953
  return { redraw: () => {
923
954
  return;
@@ -964,11 +995,11 @@ function liveRegion(render, stream = process11.stderr, env = process11.env) {
964
995
  clear();
965
996
  restore();
966
997
  release();
967
- process11.off("exit", onExit);
998
+ process12.off("exit", onExit);
968
999
  signals.release();
969
1000
  }
970
1001
  timer.unref();
971
- process11.on("exit", onExit);
1002
+ process12.on("exit", onExit);
972
1003
  return {
973
1004
  redraw: draw,
974
1005
  print: (text) => {
@@ -1007,14 +1038,14 @@ function cutToWidth(line, width) {
1007
1038
  return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
1008
1039
  }
1009
1040
  function swallowInput() {
1010
- const input = process11.stdin;
1041
+ const input = process12.stdin;
1011
1042
  if (!input.isTTY)
1012
1043
  return () => {
1013
1044
  return;
1014
1045
  };
1015
1046
  const onData = (data) => {
1016
1047
  if (data.includes(CTRL_C))
1017
- process11.kill(process11.pid, "SIGINT");
1048
+ process12.kill(process12.pid, "SIGINT");
1018
1049
  };
1019
1050
  input.setRawMode(true);
1020
1051
  input.on("data", onData);
@@ -1030,7 +1061,7 @@ function swallowInput() {
1030
1061
  };
1031
1062
  }
1032
1063
  function interceptOutput(clear) {
1033
- const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process11.stdout, "write"], [process11.stderr, "write"]];
1064
+ const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
1034
1065
  const wrapped = targets.map(([target, name]) => {
1035
1066
  const original = Reflect.get(target, name);
1036
1067
  const wrapper = (...args) => {
@@ -1048,33 +1079,111 @@ function interceptOutput(clear) {
1048
1079
  };
1049
1080
  }
1050
1081
  // ../kit/src/cli.ts
1051
- import { readFileSync as readFileSync3, realpathSync } from "fs";
1082
+ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
1052
1083
  import { dirname as dirname3, join as join6 } from "path";
1053
- import process14 from "process";
1084
+ import process16 from "process";
1085
+
1086
+ // ../kit/src/completions.ts
1087
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
1088
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
1089
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1090
+ set -l current (commandline -ct)
1091
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1092
+ if test "$line" = __files__
1093
+ __fish_complete_path $current
1094
+ else
1095
+ echo $line
1096
+ end
1097
+ end
1098
+ end`;
1099
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1100
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1101
+ local -a lines
1102
+ COMPREPLY=()
1103
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1104
+ for line in "\${lines[@]}"; do
1105
+ if [[ $line == __files__ ]]; then
1106
+ COMPREPLY+=($(compgen -f -- "$cur"))
1107
+ else
1108
+ words+="\${line%%$'\\t'*}"$'\\n'
1109
+ fi
1110
+ done
1111
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1112
+ }`;
1113
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1114
+ local line
1115
+ local -a described plain
1116
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1117
+ if [[ $line == __files__ ]]; then
1118
+ _files
1119
+ elif [[ $line == *$'\\t'* ]]; then
1120
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1121
+ else
1122
+ plain+=("$line")
1123
+ fi
1124
+ done
1125
+ (( \${#described} )) && _describe -V value described
1126
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1127
+ return 0
1128
+ }`;
1129
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1130
+ if (shell === "fish")
1131
+ return `${header}
1132
+ ${FISH_FUNCTION}
1133
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1134
+ `).join("")}`;
1135
+ if (shell === "bash")
1136
+ return `${header}
1137
+ ${BASH_FUNCTION}
1138
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1139
+ `;
1140
+ return `${header}
1141
+ ${ZSH_FUNCTION}
1142
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1143
+ `;
1144
+ }
1145
+
1146
+ // ../kit/src/notify.ts
1147
+ import process13 from "process";
1148
+ var NOTIFY_AFTER_MS = 1e4;
1149
+ var CANCELLED = 130;
1150
+ function base64(text) {
1151
+ return Buffer.from(text).toString("base64");
1152
+ }
1153
+ function notification(title, body, env = process13.env) {
1154
+ const id = `kit${process13.pid}`;
1155
+ const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
1156
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
1157
+ }
1158
+ function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
1159
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
1160
+ return;
1161
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
1162
+ }
1054
1163
 
1055
1164
  // ../kit/src/usage.ts
1056
1165
  import { appendFileSync, mkdirSync } from "fs";
1057
1166
  import { homedir as homedir4 } from "os";
1058
1167
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1059
- import process13 from "process";
1168
+ import process15 from "process";
1060
1169
 
1061
1170
  // ../kit/src/logs.ts
1062
1171
  import { lstatSync, openSync } from "fs";
1063
1172
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
1064
1173
  import { homedir as homedir3, tmpdir } from "os";
1065
1174
  import { join as join4 } from "path";
1066
- import process12 from "process";
1175
+ import process14 from "process";
1067
1176
  var DAY_MS = 24 * 60 * 60 * 1000;
1068
1177
  var CLI_FOLDER = "kaynooo-cli";
1069
1178
  function isPrivateDirectory(path) {
1070
1179
  try {
1071
1180
  const info = lstatSync(path, { throwIfNoEntry: false });
1072
- return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1181
+ return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1073
1182
  } catch {
1074
1183
  return false;
1075
1184
  }
1076
1185
  }
1077
- async function privateLogDirectory(name, env = process12.env) {
1186
+ async function privateLogDirectory(name, env = process14.env) {
1078
1187
  const runtime = env.XDG_RUNTIME_DIR;
1079
1188
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1080
1189
  const path = join4(base, name);
@@ -1094,14 +1203,14 @@ var usageError;
1094
1203
  function noteUsageError(message) {
1095
1204
  usageError = message;
1096
1205
  }
1097
- function stateHome(env = process13.env) {
1206
+ function stateHome(env = process15.env) {
1098
1207
  const dir = env.XDG_STATE_HOME;
1099
1208
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1100
1209
  }
1101
- function usagePath(env = process13.env) {
1210
+ function usagePath(env = process15.env) {
1102
1211
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1103
1212
  }
1104
- function usageRecorded(env = process13.env) {
1213
+ function usageRecorded(env = process15.env) {
1105
1214
  const off = env.KAYNOOO_CLI_NO_USAGE;
1106
1215
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1107
1216
  }
@@ -1115,7 +1224,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1115
1224
  usageError = undefined;
1116
1225
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1117
1226
  }
1118
- function recordUsage(entry, env = process13.env) {
1227
+ function recordUsage(entry, env = process15.env) {
1119
1228
  if (!usageRecorded(env))
1120
1229
  return;
1121
1230
  try {
@@ -1131,10 +1240,14 @@ var LEVEL_OPTIONS = {
1131
1240
  ...OUTPUT_OPTIONS,
1132
1241
  help: { type: "boolean", short: "h", description: "show this help" }
1133
1242
  };
1134
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1243
+ var TOP_OPTIONS = {
1244
+ ...LEVEL_OPTIONS,
1245
+ version: { type: "boolean", short: "v", description: "print the version" },
1246
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1247
+ };
1135
1248
  function printError(prefix, message, hint, cause) {
1136
- const colors = paint(process14.stderr);
1137
- const styled = takesControlCodes(process14.stderr);
1249
+ const colors = paint(process16.stderr);
1250
+ const styled = takesControlCodes(process16.stderr);
1138
1251
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1139
1252
  const under = (label, text, tint) => text === undefined ? "" : `
1140
1253
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1178,24 +1291,24 @@ function candidateLine(candidate) {
1178
1291
  }
1179
1292
  function positionalBeingTyped(before, { options, positionals }) {
1180
1293
  const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
1181
- let index = 0;
1294
+ const typed = [];
1182
1295
  let at = 0;
1183
1296
  while (at < before.length) {
1184
1297
  const word = before[at];
1185
1298
  if (word === "--") {
1186
- index += before.length - at - 1;
1299
+ typed.push(...before.slice(at + 1));
1187
1300
  break;
1188
1301
  }
1189
1302
  if (!word.startsWith("-"))
1190
- index++;
1303
+ typed.push(word);
1191
1304
  else if (takesValue(word))
1192
1305
  at++;
1193
1306
  at++;
1194
1307
  }
1195
1308
  const last = positionals.at(-1);
1196
- if (index < positionals.length)
1197
- return positionals[index];
1198
- return last?.replace("]", "").endsWith("...") === true ? last : undefined;
1309
+ if (typed.length < positionals.length)
1310
+ return { name: positionals[typed.length], typed };
1311
+ return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
1199
1312
  }
1200
1313
  async function leafCandidates(run, words) {
1201
1314
  const completing = await completingOf(run);
@@ -1203,23 +1316,40 @@ async function leafCandidates(run, words) {
1203
1316
  return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
1204
1317
  const flag = words.at(-2);
1205
1318
  const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
1319
+ const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
1206
1320
  if (option?.type === "string") {
1207
- const values = option.choices === undefined ? await option.candidates?.() : option.choices;
1321
+ const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
1208
1322
  return values === undefined ? [FILES] : values.map(candidateLine);
1209
1323
  }
1210
- const name = positionalBeingTyped(words.slice(0, -1), completing);
1211
- const values = name === undefined ? undefined : await completing.candidates[name]?.();
1324
+ const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1212
1325
  return values === undefined ? [FILES] : values.map(candidateLine);
1213
1326
  }
1327
+ var COMPLETIONS = "--completions";
1328
+ function flagValue([flag = "", ...rest]) {
1329
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1330
+ }
1331
+ function printCompletionScript(name, args) {
1332
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1333
+ if (shell === undefined || args.length !== 1) {
1334
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1335
+ return 2;
1336
+ }
1337
+ console.log(completionScript(shell, [name]).trimEnd());
1338
+ return 0;
1339
+ }
1214
1340
  async function printCandidates(found) {
1215
1341
  for (const line of await found)
1216
1342
  console.log(line);
1217
1343
  return 0;
1218
1344
  }
1219
1345
  function packageVersion(entry = Bun.main) {
1220
- for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1346
+ let resolved = entry;
1347
+ try {
1348
+ resolved = realpathSync2(entry);
1349
+ } catch {}
1350
+ for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1221
1351
  try {
1222
- const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
1352
+ const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
1223
1353
  if (typeof version === "string")
1224
1354
  return version;
1225
1355
  } catch {}
@@ -1227,19 +1357,23 @@ function packageVersion(entry = Bun.main) {
1227
1357
  return "0.0.0";
1228
1358
  }
1229
1359
  }
1230
- async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
1360
+ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1231
1361
  if (argv[0] === COMPLETE)
1232
1362
  return printCandidates(leafCandidates(run, argv.slice(1)));
1363
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1364
+ return printCompletionScript(name, flagValue(argv));
1233
1365
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1234
1366
  console.log(version ?? packageVersion());
1235
1367
  return 0;
1236
1368
  }
1237
1369
  let code;
1370
+ const started = performance.now();
1238
1371
  try {
1239
1372
  code = await run(argv);
1240
1373
  } catch (error) {
1241
1374
  code = reportThrown(name, error, redact, wantsJson(argv));
1242
1375
  }
1376
+ notifyEnd(name, code, performance.now() - started);
1243
1377
  if (usage !== false) {
1244
1378
  try {
1245
1379
  recordUsage(usageEntry(name, undefined, argv, code));
@@ -1254,15 +1388,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
1254
1388
  // ../kit/src/sessions.ts
1255
1389
  import { homedir as homedir5 } from "os";
1256
1390
  import { join as join7 } from "path";
1257
- import process15 from "process";
1391
+ import process17 from "process";
1258
1392
  var {Glob } = globalThis.Bun;
1259
1393
  var SESSION_FILES = new Glob("*.json");
1260
1394
  var ACCOUNT_DIRS = new Glob("*/sessions");
1261
1395
  async function sessionDirs() {
1262
1396
  const home = homedir5();
1263
1397
  const dirs = new Set([join7(home, ".claude", "sessions")]);
1264
- if (process15.env.CLAUDE_CONFIG_DIR !== undefined)
1265
- dirs.add(join7(process15.env.CLAUDE_CONFIG_DIR, "sessions"));
1398
+ if (process17.env.CLAUDE_CONFIG_DIR !== undefined)
1399
+ dirs.add(join7(process17.env.CLAUDE_CONFIG_DIR, "sessions"));
1266
1400
  try {
1267
1401
  for await (const dir of ACCOUNT_DIRS.scan({ cwd: join7(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1268
1402
  dirs.add(dir);
@@ -1308,7 +1442,7 @@ async function liveSessions() {
1308
1442
  }
1309
1443
  async function currentSession(sessions) {
1310
1444
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1311
- let pid = process15.ppid;
1445
+ let pid = process17.ppid;
1312
1446
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1313
1447
  const session = byPid.get(pid);
1314
1448
  if (session !== undefined)
@@ -1434,20 +1568,67 @@ async function closeWhenConnected(attempt) {
1434
1568
  (await attempt).end();
1435
1569
  } catch {}
1436
1570
  }
1437
- async function urlCheck(url, timeout) {
1571
+ var STATUS_CLASS = /^([1-5])xx$/i;
1572
+ var STATUS_RANGE = /^(\d{3})(?:-(\d{3}))?$/;
1573
+ var BODY_BYTES = 1024 * 1024;
1574
+ function parseStatus(spec) {
1575
+ const tests = [];
1576
+ for (const part of spec.split(",").map((item) => item.trim())) {
1577
+ const klass = STATUS_CLASS.exec(part);
1578
+ const range = STATUS_RANGE.exec(part);
1579
+ if (klass !== null) {
1580
+ const hundred = Number(klass[1]);
1581
+ tests.push((status) => Math.floor(status / 100) === hundred);
1582
+ } else if (range !== null) {
1583
+ const low = Number(range[1]);
1584
+ const high = Number(range[2] ?? range[1]);
1585
+ tests.push((status) => status >= low && status <= high);
1586
+ } else {
1587
+ return;
1588
+ }
1589
+ }
1590
+ return (status) => tests.some((test) => test(status));
1591
+ }
1592
+ async function readBody(response) {
1593
+ const reader = response.body?.getReader();
1594
+ if (reader === undefined)
1595
+ return "";
1596
+ const decoder = new TextDecoder;
1597
+ let text = "";
1598
+ let bytes = 0;
1599
+ while (bytes < BODY_BYTES) {
1600
+ const { done, value } = await reader.read();
1601
+ if (done)
1602
+ break;
1603
+ bytes += value?.length ?? 0;
1604
+ text += decoder.decode(value, { stream: true });
1605
+ }
1606
+ await reader.cancel();
1607
+ return text;
1608
+ }
1609
+ async function urlCheck(url, timeout, expect = {}) {
1438
1610
  try {
1439
- const response = await fetch(url, { signal: AbortSignal.timeout(timeout) });
1440
- await response.body?.cancel();
1441
- return response.ok ? { status: response.status } : { problem: `answered ${response.status}` };
1611
+ const wantsRedirect = expect.status !== undefined && Array.from({ length: 100 }, (_, index) => 300 + index).some(expect.status.test);
1612
+ const response = await fetch(url, { signal: AbortSignal.timeout(timeout), redirect: wantsRedirect ? "manual" : "follow" });
1613
+ const ok = expect.status === undefined ? response.ok : expect.status.test(response.status);
1614
+ if (!ok) {
1615
+ await response.body?.cancel();
1616
+ return { problem: expect.status === undefined ? `answered ${response.status}` : `answered ${response.status}, expected ${expect.status.spec}` };
1617
+ }
1618
+ if (expect.body === undefined) {
1619
+ await response.body?.cancel();
1620
+ return { status: response.status };
1621
+ }
1622
+ return expect.body.test(await readBody(response)) ? { status: response.status } : { problem: `answered ${response.status} but the body does not match ${expect.body}` };
1442
1623
  } catch (error) {
1443
1624
  return { problem: error instanceof Error ? error.message : String(error), isTimeout: error instanceof Error && error.name === "TimeoutError" };
1444
1625
  }
1445
1626
  }
1446
1627
 
1447
1628
  // src/task.ts
1448
- import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync4, statSync as statSync3 } from "fs";
1629
+ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
1449
1630
  import { join as join8 } from "path";
1450
- import process17 from "process";
1631
+ import process19 from "process";
1451
1632
  var EXITED = /(?:^|\n)\[exited with code (-?\d+)\]\n*$/;
1452
1633
  var FAILURE = /\(fail\)|\berror:/i;
1453
1634
  var TASK_ID = /^[\w-]+$/;
@@ -1455,9 +1636,9 @@ var TAIL_BYTES = 256;
1455
1636
  var LONGEST_FAILURES = 30;
1456
1637
  var CARRIAGE_RETURN2 = /\r$/;
1457
1638
  function tasksRoot(env) {
1458
- return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process17.getuid?.() ?? 0}`);
1639
+ return join8(env.CLAUDE_CODE_TMPDIR ?? env.TMPDIR ?? "/tmp", `claude-${process19.getuid?.() ?? 0}`);
1459
1640
  }
1460
- function taskFile(task, env = process17.env) {
1641
+ function taskFile(task, env = process19.env) {
1461
1642
  if (task.includes("/") || task.endsWith(".output"))
1462
1643
  return task;
1463
1644
  if (!TASK_ID.test(task))
@@ -1490,7 +1671,7 @@ async function taskEnd(path, lines) {
1490
1671
  }
1491
1672
  function pidAlive(pid) {
1492
1673
  try {
1493
- process17.kill(pid, 0);
1674
+ process19.kill(pid, 0);
1494
1675
  } catch (error) {
1495
1676
  return error.code === "EPERM";
1496
1677
  }
@@ -1498,7 +1679,7 @@ function pidAlive(pid) {
1498
1679
  }
1499
1680
  function isZombie(pid) {
1500
1681
  try {
1501
- const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
1682
+ const stat = readFileSync5(`/proc/${pid}/stat`, "utf8");
1502
1683
  return stat.slice(stat.lastIndexOf(")") + 2, stat.lastIndexOf(")") + 3) === "Z";
1503
1684
  } catch {
1504
1685
  return false;
@@ -1509,8 +1690,8 @@ function isZombie(pid) {
1509
1690
  var USAGE = `waitfor [options]: waits until a file shows a line, a port listens, a URL answers 2xx, a process exits or a command exits 0
1510
1691
  waitfor task <task id | file>: waits for a Claude Code background task to end (waitfor task --help)
1511
1692
 
1512
- Every condition given must be met, or with --any the first of them to be. A --fail line in --file ends the wait at once. A timeout or a --fail line comes with an excerpt of what it saw last.
1513
- --json prints {met, ms, line} once met or on a --fail line, line being the last --until line or the --fail one as {number, text} (null when none), and the progress lines go to stderr.`;
1693
+ Every condition given must be met, or with --any the first of them to be; --port and --url may be repeated, and --status and --body then apply to every --url. A --fail line in --file ends the wait at once. A timeout or a --fail line comes with an excerpt of what it saw last.
1694
+ --json prints {met, ms, line, conditions} once met or on a --fail line, conditions naming each one met as {name, ms}, line being the last --until line or the --fail one as {number, text} (null when none), and the progress lines go to stderr.`;
1514
1695
  var TASK_USAGE = `waitfor task [options] <task id | file>: waits for a Claude Code background task to end, then prints its exit code, its last lines and the (fail) and error: lines above them
1515
1696
 
1516
1697
  The task is the id a background Bash call returned, or the path of its .output file.
@@ -1528,9 +1709,11 @@ var OPTIONS = {
1528
1709
  file: { type: "string", short: "f", description: "a log file to read, from its start, waiting for it to exist" },
1529
1710
  until: { type: "string", short: "u", description: "a regular expression a line of --file must match" },
1530
1711
  fail: { type: "string", short: "e", description: "a regular expression whose first matching line of --file is a failure" },
1531
- port: { type: "string", short: "p", description: "a TCP port that must accept connections" },
1532
- host: { type: "string", short: "H", description: "the host of --port (127.0.0.1)" },
1533
- url: { type: "string", description: "a URL that must answer 2xx" },
1712
+ port: { type: "string", short: "p", multiple: true, description: "a TCP port that must accept connections, repeatable" },
1713
+ host: { type: "string", short: "H", description: "the host of --port (127.0.0.1 and ::1)" },
1714
+ url: { type: "string", multiple: true, description: "a URL that must answer 2xx (or --status), repeatable" },
1715
+ status: { type: "string", description: "the status a --url must answer instead of 2xx: 301, 200-299, 2xx or a comma list, for every --url" },
1716
+ body: { type: "string", description: "a regular expression the first MiB of a --url body must match, for every --url" },
1534
1717
  pid: { type: "string", description: "a process id that must exit" },
1535
1718
  cmd: { type: "string", short: "c", description: "a shell command that must exit 0, re-run every --interval" },
1536
1719
  interval: { type: "string", description: "how long between two runs of --cmd (1s)" },
@@ -1581,7 +1764,7 @@ async function waitTask(args) {
1581
1764
  const lines = wholeNumber(values.lines, "lines", 20);
1582
1765
  const timeout = duration(values.timeout, "timeout", 5 * 60000);
1583
1766
  const started = Date.now();
1584
- const { dim } = paint(process18.stderr);
1767
+ const { dim } = paint(process20.stderr);
1585
1768
  const region = values.quiet === true ? undefined : liveRegion((spinner) => [`${spinner} task ${task}: still running ${dim(formatElapsed(Date.now() - started))}`]);
1586
1769
  let code;
1587
1770
  try {
@@ -1619,26 +1802,46 @@ async function main(args) {
1619
1802
  fail(`unexpected argument ${positionals[0]}
1620
1803
 
1621
1804
  ${USAGE}`);
1622
- if (values.until === undefined && values.port === undefined && values.url === undefined && values.pid === undefined && values.cmd === undefined)
1805
+ const portTexts = values.port ?? [];
1806
+ const urlTexts = values.url ?? [];
1807
+ if (values.until === undefined && portTexts.length === 0 && urlTexts.length === 0 && values.pid === undefined && values.cmd === undefined)
1623
1808
  fail(`give --until with --file, --port, --url, --pid or --cmd
1624
1809
 
1625
1810
  ${USAGE}`);
1626
1811
  if ((values.until !== undefined || values.fail !== undefined) !== (values.file !== undefined))
1627
1812
  fail("--until and --fail read the --file lines, and --file needs one of them");
1628
- if (values.host !== undefined && values.port === undefined)
1813
+ if (values.host !== undefined && portTexts.length === 0)
1629
1814
  fail("--host goes with --port");
1630
- const conditions = [values.until, values.port, values.url, values.pid, values.cmd].filter((condition) => condition !== undefined).length;
1815
+ if ((values.status !== undefined || values.body !== undefined) && urlTexts.length === 0)
1816
+ fail("--status and --body go with --url");
1817
+ const conditions = [values.until, ...portTexts, ...urlTexts, values.pid, values.cmd].filter((condition) => condition !== undefined).length;
1631
1818
  if (values.any === true && conditions < 2)
1632
1819
  fail("--any needs two or more of --until, --port, --url, --pid and --cmd");
1633
1820
  if (values.interval !== undefined && values.cmd === undefined)
1634
1821
  fail("--interval goes with --cmd");
1635
- const port = values.port === undefined ? undefined : wholeNumber(values.port, "port", 0);
1636
- if (port !== undefined && port > 65535)
1637
- fail(`--port takes a port up to 65535, not ${port}`);
1638
- if (values.url !== undefined && !URL.canParse(values.url))
1639
- fail(`--url ${values.url} is no URL`);
1822
+ const ports = portTexts.map((text) => {
1823
+ const port = wholeNumber(text, "port", 0);
1824
+ if (port > 65535)
1825
+ fail(`--port takes a port up to 65535, not ${port}`);
1826
+ return { name: String(port), port, left: "not checked yet" };
1827
+ });
1828
+ for (const url of urlTexts) {
1829
+ if (!URL.canParse(url))
1830
+ fail(`--url ${url} is no URL`);
1831
+ }
1832
+ const statusTest = values.status === undefined ? undefined : parseStatus(values.status);
1833
+ if (values.status !== undefined && statusTest === undefined)
1834
+ fail(`--status takes a code, a range or a class such as 301, 200-299 or 2xx, not ${values.status}`);
1835
+ const expect = {};
1836
+ if (values.status !== undefined && statusTest !== undefined)
1837
+ expect.status = { test: statusTest, spec: values.status };
1838
+ const body = regex(values.body, "body");
1839
+ if (body !== undefined)
1840
+ expect.body = body;
1841
+ const urls = urlTexts.map((url) => ({ name: url, left: "not checked yet" }));
1842
+ const metAt = [];
1640
1843
  const pid = values.pid === undefined ? undefined : wholeNumber(values.pid, "pid", 0);
1641
- const host = values.host ?? "127.0.0.1";
1844
+ const hosts = values.host === undefined ? ["127.0.0.1", "::1"] : [values.host];
1642
1845
  const interval = duration(values.interval, "interval", 1000);
1643
1846
  const isAny = values.any === true;
1644
1847
  const timeout = duration(values.timeout, "timeout", 5 * 60000);
@@ -1647,18 +1850,16 @@ ${USAGE}`);
1647
1850
  const json = values.json === true;
1648
1851
  const say = json ? console.error : console.log;
1649
1852
  let matched;
1650
- let portLeft = port === undefined ? undefined : "not checked yet";
1651
- let urlLeft = values.url === undefined ? undefined : "not checked yet";
1652
1853
  let isPidLeft = pid !== undefined;
1653
1854
  let cmdLeft = values.cmd === undefined ? undefined : "not run yet";
1654
1855
  let cmdRanAt = 0;
1655
- const { dim } = paint(process18.stderr);
1856
+ const { dim } = paint(process20.stderr);
1656
1857
  const region = values.quiet === true ? undefined : liveRegion((spinner) => {
1657
1858
  const waited = dim(formatElapsed(Date.now() - started));
1658
1859
  const left = [
1659
1860
  watch === undefined || watch.done ? undefined : `${watch.path}: ${watch.exists ? "no --until line yet" : "does not exist yet"}`,
1660
- portLeft === undefined ? undefined : `${host}:${port}: ${portLeft}`,
1661
- urlLeft === undefined ? undefined : `${values.url}: ${urlLeft}`,
1861
+ ...ports.filter((probe) => probe.left !== undefined).map((probe) => `${hosts[0]}:${probe.port}: ${probe.left}`),
1862
+ ...urls.filter((probe) => probe.left !== undefined).map((probe) => `${probe.name}: ${probe.left}`),
1662
1863
  isPidLeft ? `pid ${pid}: still running` : undefined,
1663
1864
  cmdLeft === undefined ? undefined : `\`${values.cmd}\`: ${cmdLeft}`
1664
1865
  ];
@@ -1671,6 +1872,7 @@ ${USAGE}`);
1671
1872
  if (event.kind === "until") {
1672
1873
  say(`${watch.path}:${event.line.number}: ${truncate(event.line.text, WIDTH)}`);
1673
1874
  matched = { number: event.line.number, text: event.line.text };
1875
+ metAt.push({ name: `${watch.path} --until`, ms: Date.now() - started });
1674
1876
  continue;
1675
1877
  }
1676
1878
  problem(`waitfor: ${watch.path}:${event.line.number} matched --fail after ${formatDuration(Date.now() - started)}
@@ -1680,24 +1882,42 @@ ${numbered(event.excerpt, event.line)}`);
1680
1882
  return 1;
1681
1883
  }
1682
1884
  }
1683
- if (port !== undefined && portLeft !== undefined) {
1684
- portLeft = await portProblem(host, port);
1685
- if (portLeft === undefined)
1686
- say(`${host}:${port} listening after ${formatDuration(Date.now() - started)}`);
1885
+ for (const probe of ports) {
1886
+ if (probe.left === undefined)
1887
+ continue;
1888
+ for (const candidate of hosts) {
1889
+ const problem = await portProblem(candidate, probe.port ?? 0);
1890
+ if (candidate === hosts[0])
1891
+ probe.left = problem;
1892
+ if (problem === undefined) {
1893
+ const name = `${candidate.includes(":") ? `[${candidate}]` : candidate}:${probe.port}`;
1894
+ probe.left = undefined;
1895
+ probe.name = name;
1896
+ metAt.push({ name, ms: Date.now() - started });
1897
+ say(`${name} listening after ${formatDuration(Date.now() - started)}`);
1898
+ break;
1899
+ }
1900
+ }
1687
1901
  }
1688
- if (values.url !== undefined && urlLeft !== undefined) {
1902
+ for (const probe of urls) {
1903
+ if (probe.left === undefined)
1904
+ continue;
1689
1905
  const budget = Math.max(1, Math.min(URL_TIMEOUT, started + timeout - Date.now()));
1690
- const check = await urlCheck(values.url, budget);
1691
- const isCutShort = "problem" in check && check.isTimeout === true && budget < URL_TIMEOUT && urlLeft !== "not checked yet";
1906
+ const check = await urlCheck(probe.name, budget, expect);
1907
+ const isCutShort = "problem" in check && check.isTimeout === true && budget < URL_TIMEOUT && probe.left !== "not checked yet";
1692
1908
  if (!isCutShort)
1693
- urlLeft = "problem" in check ? check.problem : undefined;
1694
- if ("status" in check)
1695
- say(`${values.url} answered ${check.status} after ${formatDuration(Date.now() - started)}`);
1909
+ probe.left = "problem" in check ? check.problem : undefined;
1910
+ if ("status" in check) {
1911
+ metAt.push({ name: probe.name, ms: Date.now() - started });
1912
+ say(`${probe.name} answered ${check.status} after ${formatDuration(Date.now() - started)}`);
1913
+ }
1696
1914
  }
1697
1915
  if (pid !== undefined && isPidLeft) {
1698
1916
  isPidLeft = pidAlive(pid);
1699
- if (!isPidLeft)
1917
+ if (!isPidLeft) {
1918
+ metAt.push({ name: `pid ${pid}`, ms: Date.now() - started });
1700
1919
  say(`pid ${pid} exited after ${formatDuration(Date.now() - started)}`);
1920
+ }
1701
1921
  }
1702
1922
  if (values.cmd !== undefined && cmdLeft !== undefined && Date.now() - cmdRanAt >= interval) {
1703
1923
  const budget = Math.max(1, Math.min(CMD_RUN_LIMIT, started + timeout - Date.now()));
@@ -1705,19 +1925,21 @@ ${numbered(event.excerpt, event.line)}`);
1705
1925
  if (!(problem?.startsWith("timed out") === true && budget < CMD_RUN_LIMIT && cmdLeft !== "not run yet"))
1706
1926
  cmdLeft = problem;
1707
1927
  cmdRanAt = Date.now();
1708
- if (cmdLeft === undefined)
1928
+ if (cmdLeft === undefined) {
1929
+ metAt.push({ name: `\`${values.cmd}\``, ms: Date.now() - started });
1709
1930
  say(`\`${values.cmd}\` exited 0 after ${formatDuration(Date.now() - started)}`);
1931
+ }
1710
1932
  }
1711
1933
  const isMet = [
1712
1934
  values.until !== undefined && (watch?.done ?? false),
1713
- port !== undefined && portLeft === undefined,
1714
- values.url !== undefined && urlLeft === undefined,
1935
+ ports.some((probe) => probe.left === undefined),
1936
+ urls.some((probe) => probe.left === undefined),
1715
1937
  pid !== undefined && !isPidLeft,
1716
1938
  values.cmd !== undefined && cmdLeft === undefined
1717
1939
  ];
1718
- if (isAny ? isMet.includes(true) : (watch?.done ?? true) && portLeft === undefined && urlLeft === undefined && !isPidLeft && cmdLeft === undefined) {
1940
+ if (isAny ? isMet.includes(true) : (watch?.done ?? true) && ports.every((probe) => probe.left === undefined) && urls.every((probe) => probe.left === undefined) && !isPidLeft && cmdLeft === undefined) {
1719
1941
  if (json)
1720
- printJson({ met: true, ms: Date.now() - started, line: matched ?? null });
1942
+ printJson({ met: true, ms: Date.now() - started, line: matched ?? null, conditions: metAt });
1721
1943
  return 0;
1722
1944
  }
1723
1945
  if (Date.now() - started >= timeout && !(watch?.failing ?? false))
@@ -1730,10 +1952,14 @@ ${numbered(event.excerpt, event.line)}`);
1730
1952
  const missing = [];
1731
1953
  if (watch !== undefined && !watch.done)
1732
1954
  missing.push(watch.exists ? `no line of ${watch.path} matched --until` : `${watch.path} does not exist`);
1733
- if (portLeft !== undefined)
1734
- missing.push(`${host}:${port} is not listening (${portLeft})`);
1735
- if (urlLeft !== undefined)
1736
- missing.push(`${values.url} ${urlLeft}`);
1955
+ for (const probe of ports) {
1956
+ if (probe.left !== undefined)
1957
+ missing.push(`${hosts[0]}:${probe.port} is not listening (${probe.left})`);
1958
+ }
1959
+ for (const probe of urls) {
1960
+ if (probe.left !== undefined)
1961
+ missing.push(`${probe.name} ${probe.left}`);
1962
+ }
1737
1963
  if (isPidLeft)
1738
1964
  missing.push(`pid ${pid} is still running`);
1739
1965
  if (cmdLeft !== undefined)
@@ -1743,4 +1969,4 @@ ${numbered(event.excerpt, event.line)}`);
1743
1969
  last lines of ${watch?.path}:
1744
1970
  ${numbered(lines)}`}`);
1745
1971
  }
1746
- process18.exitCode = await runMain({ name: "waitfor", run: main });
1972
+ process20.exitCode = await runMain({ name: "waitfor", run: main });