@kaynooo/cli-check 0.18.3 → 0.20.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.
package/dist/errs-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/errs-cli.ts
5
- import process20 from "process";
5
+ import process22 from "process";
6
6
  // ../kit/src/args.ts
7
7
  import process10 from "process";
8
8
  import { parseArgs } from "util";
@@ -461,7 +461,7 @@ function printJson(value) {
461
461
 
462
462
  // ../kit/src/help.ts
463
463
  import process8 from "process";
464
- var OPTIONAL = /\[[^\]]+\]/g;
464
+ var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
465
465
  var USAGE_PREFIX = /^usage:\s*/i;
466
466
  var FULL_STOP = /\.$/;
467
467
  function usageLine(usage, colors = paint(process8.stdout)) {
@@ -500,32 +500,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
500
500
  return [];
501
501
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
502
502
  }
503
+ var MAX_INLINE_CHOICES = 24;
503
504
  function optionRows(options, colors = paint(process8.stdout)) {
504
505
  const rows = Object.entries(options).map(([name, option]) => {
505
506
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
506
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
507
+ const choices = option.choices?.join("|");
508
+ const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
509
+ const named = inline ? `<${choices}>` : "<value>";
507
510
  const placeholder = option.optional === undefined ? named : `[${named}]`;
508
511
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
509
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
512
+ const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
513
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
510
514
  });
511
515
  const width = Math.max(0, ...rows.map((row) => row.width));
512
516
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
513
517
  }
514
518
 
515
519
  // ../kit/src/text.ts
516
- var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
520
+ var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
517
521
  function stripAnsi(text) {
518
522
  return text.replace(ANSI, "");
519
523
  }
520
524
  function distance(a, b) {
521
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
522
- for (const [i, left] of [...a].entries()) {
525
+ const left = [...a];
526
+ const right = [...b];
527
+ let before = [];
528
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
529
+ for (const [i, x] of left.entries()) {
523
530
  const current = [i + 1];
524
- for (const [j, right] of [...b].entries())
525
- current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
531
+ for (const [j, y] of right.entries()) {
532
+ let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
533
+ if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
534
+ cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
535
+ current.push(cost);
536
+ }
537
+ before = previous;
526
538
  previous = current;
527
539
  }
528
- return previous[b.length] ?? 0;
540
+ return previous[right.length] ?? 0;
529
541
  }
530
542
  function closest(name, names) {
531
543
  const started = names.find((known) => known.startsWith(name));
@@ -930,31 +942,49 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
930
942
  // ../kit/src/cli.ts
931
943
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
932
944
  import { dirname as dirname3, join as join6 } from "path";
933
- import process15 from "process";
945
+ import process16 from "process";
946
+
947
+ // ../kit/src/notify.ts
948
+ import process13 from "process";
949
+ var NOTIFY_AFTER_MS = 1e4;
950
+ var CANCELLED = 130;
951
+ function base64(text) {
952
+ return Buffer.from(text).toString("base64");
953
+ }
954
+ function notification(title, body, env = process13.env) {
955
+ const id = `kit${process13.pid}`;
956
+ 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\\`];
957
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
958
+ }
959
+ function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
960
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
961
+ return;
962
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
963
+ }
934
964
 
935
965
  // ../kit/src/usage.ts
936
966
  import { appendFileSync, mkdirSync } from "fs";
937
967
  import { homedir as homedir4 } from "os";
938
968
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
939
- import process14 from "process";
969
+ import process15 from "process";
940
970
 
941
971
  // ../kit/src/logs.ts
942
972
  import { lstatSync, openSync } from "fs";
943
973
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
944
974
  import { homedir as homedir3, tmpdir } from "os";
945
975
  import { join as join4 } from "path";
946
- import process13 from "process";
976
+ import process14 from "process";
947
977
  var DAY_MS = 24 * 60 * 60 * 1000;
948
978
  var CLI_FOLDER = "kaynooo-cli";
949
979
  function isPrivateDirectory(path) {
950
980
  try {
951
981
  const info = lstatSync(path, { throwIfNoEntry: false });
952
- return info !== undefined && info.isDirectory() && info.uid === (process13.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
982
+ return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
953
983
  } catch {
954
984
  return false;
955
985
  }
956
986
  }
957
- async function privateLogDirectory(name, env = process13.env) {
987
+ async function privateLogDirectory(name, env = process14.env) {
958
988
  const runtime = env.XDG_RUNTIME_DIR;
959
989
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
960
990
  const path = join4(base, name);
@@ -994,14 +1024,14 @@ var usageError;
994
1024
  function noteUsageError(message) {
995
1025
  usageError = message;
996
1026
  }
997
- function stateHome(env = process14.env) {
1027
+ function stateHome(env = process15.env) {
998
1028
  const dir = env.XDG_STATE_HOME;
999
1029
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1000
1030
  }
1001
- function usagePath(env = process14.env) {
1031
+ function usagePath(env = process15.env) {
1002
1032
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1003
1033
  }
1004
- function usageRecorded(env = process14.env) {
1034
+ function usageRecorded(env = process15.env) {
1005
1035
  const off = env.KAYNOOO_CLI_NO_USAGE;
1006
1036
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1007
1037
  }
@@ -1015,7 +1045,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1015
1045
  usageError = undefined;
1016
1046
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1017
1047
  }
1018
- function recordUsage(entry, env = process14.env) {
1048
+ function recordUsage(entry, env = process15.env) {
1019
1049
  if (!usageRecorded(env))
1020
1050
  return;
1021
1051
  try {
@@ -1033,8 +1063,8 @@ var LEVEL_OPTIONS = {
1033
1063
  };
1034
1064
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1035
1065
  function printError(prefix, message, hint, cause) {
1036
- const colors = paint(process15.stderr);
1037
- const styled = takesControlCodes(process15.stderr);
1066
+ const colors = paint(process16.stderr);
1067
+ const styled = takesControlCodes(process16.stderr);
1038
1068
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1039
1069
  const under = (label, text, tint) => text === undefined ? "" : `
1040
1070
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1139,11 +1169,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1139
1169
  return 0;
1140
1170
  }
1141
1171
  let code;
1172
+ const started = performance.now();
1142
1173
  try {
1143
1174
  code = await run(argv);
1144
1175
  } catch (error) {
1145
1176
  code = reportThrown(name, error, redact, wantsJson(argv));
1146
1177
  }
1178
+ notifyEnd(name, code, performance.now() - started);
1147
1179
  if (usage !== false) {
1148
1180
  try {
1149
1181
  recordUsage(usageEntry(name, undefined, argv, code));
@@ -1151,13 +1183,174 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1151
1183
  }
1152
1184
  return code;
1153
1185
  }
1186
+ // ../kit/src/excerpt.ts
1187
+ var BASH_ECHO = /^\$ /;
1188
+ var DURATION2 = / \[[\d.]+m?s\]$/;
1189
+ var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
1190
+ var BUN_TEST_SUMMARY = /^\s*\d+ (?:pass|fail|skip|todo)$|^Ran \d+ tests?/;
1191
+ var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1192
+ var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1193
+ var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1194
+ var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1195
+ var TSC_ERROR = /\berror TS\d+/;
1196
+ var TSC_CONTINUATION = /^\s{2,}\S/;
1197
+ var TSC_FRAME = /^\s*[~^|]/;
1198
+ var TSC_SUMMARY = /^Found \d+ errors?/;
1199
+ var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1200
+ var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1201
+ var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1202
+ var PHPSTAN_NOISE = /^\s*\[OK\]/;
1203
+ var PHP_FAILURES = /^(?:There w(?:as|ere) \d+ (?:failure|error|risky|warning)|\s+(?:FAIL|FAILED)\s+\S|In \S+\.php line \d+:$)/;
1204
+ var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1205
+ var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1206
+ var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1207
+ var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1208
+ var MAX_TESTS = 10;
1209
+ var MAX_LINES = 100;
1210
+ var TAIL = 30;
1211
+ var bunTest = (lines) => {
1212
+ const seen = new Set;
1213
+ const blocks = [];
1214
+ for (const [index, line] of lines.entries()) {
1215
+ const name = line.replace(DURATION2, "");
1216
+ if (!line.startsWith("(fail) ") || seen.has(name))
1217
+ continue;
1218
+ seen.add(name);
1219
+ if (blocks.length < MAX_TESTS)
1220
+ blocks.push(lines.slice(lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1, index + 1).join(`
1221
+ `).trim());
1222
+ }
1223
+ if (blocks.length === 0)
1224
+ return;
1225
+ if (seen.size > MAX_TESTS)
1226
+ blocks.push(`and ${seen.size - MAX_TESTS} more failed tests`);
1227
+ return [...blocks.join(`
1228
+
1229
+ `).split(`
1230
+ `), "", ...lines.filter((line) => BUN_TEST_SUMMARY.test(line)).map((line) => line.trim())];
1231
+ };
1232
+ var bunCheck = (lines) => {
1233
+ const text = lines.join(`
1234
+ `);
1235
+ const blocks = text.match(BUN_CHECK_BLOCK);
1236
+ if (blocks === null)
1237
+ return;
1238
+ const errors = blocks.map((block) => {
1239
+ const { file, line, column, code, message } = bunCheckFields(block);
1240
+ return `${file}:${line}:${column} ${code}: ${message}`;
1241
+ });
1242
+ return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
1243
+ };
1244
+ function bunCheckFields(block) {
1245
+ const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
1246
+ `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
1247
+ return {
1248
+ file: attributes.file ?? "",
1249
+ line: attributes.line ?? "",
1250
+ column: attributes.column ?? "",
1251
+ code: attributes.code ?? "",
1252
+ message: block.replace(BUN_CHECK_SOURCE, "").split(`
1253
+ `).slice(1, -1).join(`
1254
+ `).trim()
1255
+ };
1256
+ }
1257
+ var tsc = (lines) => {
1258
+ const kept = [];
1259
+ let inError = false;
1260
+ for (const line of lines) {
1261
+ if (TSC_ERROR.test(line)) {
1262
+ inError = true;
1263
+ kept.push(line);
1264
+ } else if (TSC_SUMMARY.test(line)) {
1265
+ inError = false;
1266
+ kept.push(line);
1267
+ } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
1268
+ kept.push(line);
1269
+ } else {
1270
+ inError = false;
1271
+ }
1272
+ }
1273
+ return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
1274
+ };
1275
+ var eslint = (lines) => {
1276
+ const kept = [];
1277
+ let file = "";
1278
+ let shown = "";
1279
+ for (const line of lines) {
1280
+ if (ESLINT_PROBLEM.test(line)) {
1281
+ if (file !== shown) {
1282
+ kept.push(file);
1283
+ shown = file;
1284
+ }
1285
+ kept.push(line);
1286
+ } else if (ESLINT_SUMMARY.test(line)) {
1287
+ kept.push(line);
1288
+ } else if (line.trim() !== "") {
1289
+ file = line;
1290
+ }
1291
+ }
1292
+ return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
1293
+ };
1294
+ var phpstan = (lines) => {
1295
+ const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
1296
+ return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
1297
+ };
1298
+ var php = (lines) => {
1299
+ const start = lines.findIndex((line) => PHP_FAILURES.test(line));
1300
+ return start === -1 ? undefined : lines.slice(start);
1301
+ };
1302
+ var vitest = (lines) => {
1303
+ const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
1304
+ return start === -1 ? undefined : lines.slice(start);
1305
+ };
1306
+ var playwright = (lines) => {
1307
+ const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
1308
+ return start === -1 ? undefined : lines.slice(start);
1309
+ };
1310
+ var phpCsFixer = (lines) => {
1311
+ const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
1312
+ return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
1313
+ };
1314
+ var PARSERS = [bunTest, bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan, php];
1315
+ function squeeze(lines) {
1316
+ const out = [];
1317
+ for (const line of lines.map((text) => text.trimEnd())) {
1318
+ if (line !== "" || out.at(-1) !== "")
1319
+ out.push(line);
1320
+ }
1321
+ while (out.at(-1) === "")
1322
+ out.pop();
1323
+ return out;
1324
+ }
1325
+ function cut(shown) {
1326
+ return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
1327
+ `) : shown.join(`
1328
+ `);
1329
+ }
1330
+ function recognised(lines, parsers) {
1331
+ return parsers.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
1332
+ }
1333
+ function failureExcerpt(output) {
1334
+ const lines = stripAnsi(output).split(`
1335
+ `);
1336
+ if (BASH_ECHO.test(lines[0] ?? ""))
1337
+ lines.shift();
1338
+ return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
1339
+ }
1340
+ var LOG_PATTERNS = { BASH_ECHO, DURATION: DURATION2, BOUNDARY, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_CONTINUATION, TSC_FRAME, TSC_SUMMARY, ESLINT_PROBLEM, ESLINT_SUMMARY };
1154
1341
  // ../kit/src/folders.ts
1342
+ import { homedir as homedir5 } from "os";
1343
+ import { join as join7 } from "path";
1344
+ import process17 from "process";
1155
1345
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1156
1346
  function ignoredFolders(extra = [], where = {}) {
1157
1347
  const configured = readUserConfig("config", where).ignore;
1158
1348
  const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1159
1349
  return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1160
1350
  }
1351
+ function cacheFolder({ home = homedir5(), env = process17.env } = {}) {
1352
+ return env.XDG_CACHE_HOME ?? join7(home, ".cache");
1353
+ }
1161
1354
  // ../kit/src/secrets.ts
1162
1355
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1163
1356
  // ../kit/src/sessions.ts
@@ -1165,17 +1358,17 @@ var {Glob } = globalThis.Bun;
1165
1358
  var SESSION_FILES = new Glob("*.json");
1166
1359
  var ACCOUNT_DIRS = new Glob("*/sessions");
1167
1360
  // package.json
1168
- var version = "0.18.3";
1361
+ var version = "0.20.0";
1169
1362
 
1170
1363
  // src/errs.ts
1171
1364
  import { relative as relative2 } from "path";
1172
- import process19 from "process";
1365
+ import process21 from "process";
1173
1366
 
1174
1367
  // src/compose.ts
1175
1368
  import { existsSync as existsSync4 } from "fs";
1176
- import { homedir as homedir5 } from "os";
1177
- import { basename, dirname as dirname4, join as join7, relative, resolve as resolve4 } from "path";
1178
- import process17 from "process";
1369
+ import { homedir as homedir6 } from "os";
1370
+ import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1371
+ import process19 from "process";
1179
1372
 
1180
1373
  // ../kit/src/shell.ts
1181
1374
  var SEPARATORS = new Set([`
@@ -1253,7 +1446,7 @@ function toolWords(program) {
1253
1446
  }
1254
1447
  async function readFiles(dir, names) {
1255
1448
  for (const name of names) {
1256
- const handle = Bun.file(join7(dir, name));
1449
+ const handle = Bun.file(join8(dir, name));
1257
1450
  if (await handle.exists())
1258
1451
  return { name, text: await handle.text() };
1259
1452
  }
@@ -1268,7 +1461,7 @@ async function variables(composeDir) {
1268
1461
  if (match !== null && !line.trimStart().startsWith("#"))
1269
1462
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1270
1463
  }
1271
- for (const [key, value] of Object.entries(process17.env)) {
1464
+ for (const [key, value] of Object.entries(process19.env)) {
1272
1465
  if (value !== undefined)
1273
1466
  env[key] = value;
1274
1467
  }
@@ -1288,7 +1481,7 @@ function interpolate(text, env) {
1288
1481
  function bindSource(source, composeDir, env) {
1289
1482
  const path = interpolate(source, env);
1290
1483
  if (path.startsWith("~"))
1291
- return join7(homedir5(), path.slice(1));
1484
+ return join8(homedir6(), path.slice(1));
1292
1485
  if (path.startsWith("/"))
1293
1486
  return resolve4(path);
1294
1487
  return path.startsWith(".") ? resolve4(composeDir, path) : undefined;
@@ -1335,7 +1528,7 @@ async function composeFiles(composeDir, env) {
1335
1528
  for (const name of listed.split(separator === undefined || separator === "" ? ":" : separator).filter((entry) => entry !== "")) {
1336
1529
  const file = Bun.file(resolve4(composeDir, name));
1337
1530
  if (!await file.exists())
1338
- fail(`COMPOSE_FILE names ${join7(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1531
+ fail(`COMPOSE_FILE names ${join8(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1339
1532
  files.push({ name, text: await file.text() });
1340
1533
  }
1341
1534
  return files;
@@ -1357,7 +1550,7 @@ async function readServices(composeDir) {
1357
1550
  try {
1358
1551
  parsed = parseServices(file.text, composeDir, env);
1359
1552
  } catch (error) {
1360
- fail(`cannot read ${join7(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1553
+ fail(`cannot read ${join8(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1361
1554
  }
1362
1555
  for (const [name, extra] of parsed) {
1363
1556
  const known = services.get(name);
@@ -1369,11 +1562,11 @@ async function readServices(composeDir) {
1369
1562
  function climb(dir) {
1370
1563
  const folders = [dir];
1371
1564
  let current = dir;
1372
- while (!existsSync4(join7(current, ".git")) && dirname4(current) !== current) {
1565
+ while (!existsSync4(join8(current, ".git")) && dirname4(current) !== current) {
1373
1566
  current = dirname4(current);
1374
1567
  folders.push(current);
1375
1568
  }
1376
- return existsSync4(join7(current, ".git")) ? folders : [dir];
1569
+ return existsSync4(join8(current, ".git")) ? folders : [dir];
1377
1570
  }
1378
1571
  function containerPath(service, dir) {
1379
1572
  const holding = service.mounts.filter((mount) => {
@@ -1384,7 +1577,7 @@ function containerPath(service, dir) {
1384
1577
  if (deepest === undefined)
1385
1578
  return;
1386
1579
  const inside = relative(deepest.source, dir);
1387
- return inside === "" ? deepest.target : join7(deepest.target, inside);
1580
+ return inside === "" ? deepest.target : join8(deepest.target, inside);
1388
1581
  }
1389
1582
  var noticed = new Set;
1390
1583
  async function place(dir, program, { service, host } = {}) {
@@ -1404,7 +1597,7 @@ async function place(dir, program, { service, host } = {}) {
1404
1597
  fail(`--in ${service}: no compose project mounts ${dir}`);
1405
1598
  return;
1406
1599
  }
1407
- if (Bun.which("docker", { PATH: process17.env.PATH ?? "" }) === null) {
1600
+ if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1408
1601
  if (service !== undefined)
1409
1602
  fail(`--in ${service}: docker not found`);
1410
1603
  if (!noticed.has(found.composeDir)) {
@@ -1456,7 +1649,7 @@ class Stack {
1456
1649
  }
1457
1650
  static async running(composeDir) {
1458
1651
  try {
1459
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process17.env, timeoutMs: PS_TIMEOUT_MS });
1652
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1460
1653
  if (ran.code !== 0)
1461
1654
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1462
1655
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1739,155 +1932,7 @@ var collectCsFixer = (lines, used) => {
1739
1932
  };
1740
1933
 
1741
1934
  // src/output.ts
1742
- var BASH_ECHO = /^\$ /;
1743
- var DURATION2 = / \[[\d.]+m?s\]$/;
1744
- var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
1745
- var BUN_TEST_SUMMARY = /^\s*\d+ (?:pass|fail|skip|todo)$|^Ran \d+ tests?/;
1746
- var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1747
- var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1748
- var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1749
- var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1750
- var TSC_ERROR = /\berror TS\d+/;
1751
- var TSC_CONTINUATION = /^\s{2,}\S/;
1752
- var TSC_FRAME = /^\s*[~^|]/;
1753
- var TSC_SUMMARY = /^Found \d+ errors?/;
1754
- var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1755
- var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1756
- var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1757
- var PHPSTAN_NOISE = /^\s*\[OK\]/;
1758
- var PHP_FAILURES = /^(?:There w(?:as|ere) \d+ (?:failure|error|risky|warning)|\s+(?:FAIL|FAILED)\s+\S|In \S+\.php line \d+:$)/;
1759
- var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1760
- var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1761
- var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1762
- var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1763
- var MAX_TESTS = 10;
1764
- var MAX_LINES = 100;
1765
- var TAIL = 30;
1766
- var bunTest = (lines) => {
1767
- const seen = new Set;
1768
- const blocks = [];
1769
- for (const [index, line] of lines.entries()) {
1770
- const name = line.replace(DURATION2, "");
1771
- if (!line.startsWith("(fail) ") || seen.has(name))
1772
- continue;
1773
- seen.add(name);
1774
- if (blocks.length < MAX_TESTS)
1775
- blocks.push(lines.slice(lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1, index + 1).join(`
1776
- `).trim());
1777
- }
1778
- if (blocks.length === 0)
1779
- return;
1780
- if (seen.size > MAX_TESTS)
1781
- blocks.push(`and ${seen.size - MAX_TESTS} more failed tests`);
1782
- return [...blocks.join(`
1783
-
1784
- `).split(`
1785
- `), "", ...lines.filter((line) => BUN_TEST_SUMMARY.test(line)).map((line) => line.trim())];
1786
- };
1787
- var bunCheck = (lines) => {
1788
- const text = lines.join(`
1789
- `);
1790
- const blocks = text.match(BUN_CHECK_BLOCK);
1791
- if (blocks === null)
1792
- return;
1793
- const errors = blocks.map((block) => {
1794
- const { file, line, column, code, message } = bunCheckFields(block);
1795
- return `${file}:${line}:${column} ${code}: ${message}`;
1796
- });
1797
- return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
1798
- };
1799
- function bunCheckFields(block) {
1800
- const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
1801
- `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
1802
- return {
1803
- file: attributes.file ?? "",
1804
- line: attributes.line ?? "",
1805
- column: attributes.column ?? "",
1806
- code: attributes.code ?? "",
1807
- message: block.replace(BUN_CHECK_SOURCE, "").split(`
1808
- `).slice(1, -1).join(`
1809
- `).trim()
1810
- };
1811
- }
1812
- var tsc = (lines) => {
1813
- const kept = [];
1814
- let inError = false;
1815
- for (const line of lines) {
1816
- if (TSC_ERROR.test(line)) {
1817
- inError = true;
1818
- kept.push(line);
1819
- } else if (TSC_SUMMARY.test(line)) {
1820
- inError = false;
1821
- kept.push(line);
1822
- } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
1823
- kept.push(line);
1824
- } else {
1825
- inError = false;
1826
- }
1827
- }
1828
- return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
1829
- };
1830
- var eslint = (lines) => {
1831
- const kept = [];
1832
- let file = "";
1833
- let shown = "";
1834
- for (const line of lines) {
1835
- if (ESLINT_PROBLEM.test(line)) {
1836
- if (file !== shown) {
1837
- kept.push(file);
1838
- shown = file;
1839
- }
1840
- kept.push(line);
1841
- } else if (ESLINT_SUMMARY.test(line)) {
1842
- kept.push(line);
1843
- } else if (line.trim() !== "") {
1844
- file = line;
1845
- }
1846
- }
1847
- return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
1848
- };
1849
- var phpstan = (lines) => {
1850
- const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
1851
- return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
1852
- };
1853
- var php = (lines) => {
1854
- const start = lines.findIndex((line) => PHP_FAILURES.test(line));
1855
- return start === -1 ? undefined : lines.slice(start);
1856
- };
1857
- var vitest = (lines) => {
1858
- const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
1859
- return start === -1 ? undefined : lines.slice(start);
1860
- };
1861
- var playwright = (lines) => {
1862
- const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
1863
- return start === -1 ? undefined : lines.slice(start);
1864
- };
1865
- var phpCsFixer = (lines) => {
1866
- const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
1867
- return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
1868
- };
1869
- var PARSERS = [bunTest, bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan, php];
1870
- function squeeze(lines) {
1871
- const out = [];
1872
- for (const line of lines.map((text) => text.trimEnd())) {
1873
- if (line !== "" || out.at(-1) !== "")
1874
- out.push(line);
1875
- }
1876
- while (out.at(-1) === "")
1877
- out.pop();
1878
- return out;
1879
- }
1880
- function failureExcerpt(output) {
1881
- const lines = stripAnsi(output).split(`
1882
- `);
1883
- if (BASH_ECHO.test(lines[0] ?? ""))
1884
- lines.shift();
1885
- const parsed = PARSERS.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
1886
- const shown = squeeze(parsed ?? lines.slice(-TAIL));
1887
- return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
1888
- `) : shown.join(`
1889
- `);
1890
- }
1935
+ var { BASH_ECHO: BASH_ECHO2, DURATION: DURATION3, BOUNDARY: BOUNDARY2, BUN_TEST_SUMMARY: BUN_TEST_SUMMARY2, BUN_CHECK_SUMMARY: BUN_CHECK_SUMMARY2, TSC_CONTINUATION: TSC_CONTINUATION2, TSC_FRAME: TSC_FRAME2, TSC_SUMMARY: TSC_SUMMARY2, ESLINT_PROBLEM: ESLINT_PROBLEM2, ESLINT_SUMMARY: ESLINT_SUMMARY2 } = LOG_PATTERNS;
1891
1936
  var TSC_PLAIN_ERROR = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
1892
1937
  var TSC_PRETTY_ERROR = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
1893
1938
  var TSC_SOURCE_LINE = /^\d+ /;
@@ -1898,9 +1943,13 @@ var BUN_TEST_RECEIVED = /^Received: (.*)$/;
1898
1943
  var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
1899
1944
  var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
1900
1945
  var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
1946
+ var GO_LINTER = /^(.*\S)\s+\(([a-z][\w-]*)\)$/;
1901
1947
  var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
1902
1948
  var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
1903
- var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
1949
+ var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
1950
+ var CONTINUATION = /^\s+\S/;
1951
+ var MAX_CONTINUATION = 20;
1952
+ var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
1904
1953
  var CARGO_NOISE = /^(?:\s+(?:Compiling|Finished|Checking|Fresh|Running|Blocking) |error: (?:aborting due to|could not compile)|warning: .* generated \d+ warnings?|Some errors have detailed explanations|For more information about (?:this|an) error|To learn more, run the command again)/;
1905
1954
  var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
1906
1955
  var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
@@ -1914,9 +1963,11 @@ var PYTEST_FRAME = /^in \S/;
1914
1963
  var PYTEST_SECTION = /^_{3,} .* _{3,}$/;
1915
1964
  var PYTEST_EXCEPTION_END = /[\s:]/;
1916
1965
  var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
1966
+ var GENERIC_LINE = /^(\S[^:]*):(\d+)(?::(\d+))?: (?:fatal )?(error|warning|note): (.*)$/;
1967
+ var GENERIC_RULE = /\s(?:\[([\w-]+)\]|\(([a-z][\w-]*)\))$/;
1917
1968
  var NOISE = /^(?:bun test v|Errors {2}Files$|Ran \d+ tests?|note: |\s*\d+ expect\(\) calls|\s+\d+\s+\S+:\d+$|\s*\d+ errors? and \d+ warnings? potentially fixable)/;
1918
1969
  function isNoise(line) {
1919
- return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
1970
+ return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY2, BUN_CHECK_SUMMARY2, TSC_SUMMARY2, ESLINT_SUMMARY2, BOUNDARY2, BASH_ECHO2, GO_NOISE, CARGO_NOISE, KAY_SUMMARY, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
1920
1971
  }
1921
1972
  var collectBunCheck = (lines, used) => {
1922
1973
  const errors = [];
@@ -1942,11 +1993,11 @@ var collectBunTest = (lines, used) => {
1942
1993
  if (!line.startsWith("(fail) "))
1943
1994
  continue;
1944
1995
  used.add(index);
1945
- const test = line.slice("(fail) ".length).replace(DURATION2, "");
1996
+ const test = line.slice("(fail) ".length).replace(DURATION3, "");
1946
1997
  if (seen.has(test))
1947
1998
  continue;
1948
1999
  seen.add(test);
1949
- const start = lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1;
2000
+ const start = lines.findLastIndex((text, at) => at < index && BOUNDARY2.test(text)) + 1;
1950
2001
  const block = lines.slice(start, index);
1951
2002
  const failure = block.findIndex((text) => text.startsWith("error:"));
1952
2003
  for (let at = start;at < index; at++)
@@ -1983,10 +2034,10 @@ var collectTsc = (lines, used) => {
1983
2034
  pretty = plain === null;
1984
2035
  errors.push(current);
1985
2036
  used.add(index);
1986
- } else if (current !== undefined && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
2037
+ } else if (current !== undefined && TSC_CONTINUATION2.test(line) && !TSC_FRAME2.test(line)) {
1987
2038
  current.message += ` ${line.trim()}`;
1988
2039
  used.add(index);
1989
- } else if (current !== undefined && pretty && (TSC_FRAME.test(line) || TSC_SOURCE_LINE.test(line))) {
2040
+ } else if (current !== undefined && pretty && (TSC_FRAME2.test(line) || TSC_SOURCE_LINE.test(line))) {
1990
2041
  used.add(index);
1991
2042
  } else if (!(pretty && line.trim() === "")) {
1992
2043
  current = undefined;
@@ -2000,7 +2051,7 @@ var collectEslint = (lines, used) => {
2000
2051
  for (const [index, line] of lines.entries()) {
2001
2052
  if (used.has(index))
2002
2053
  continue;
2003
- const match = ESLINT_PROBLEM.test(line) ? ESLINT_FIELDS.exec(line) : null;
2054
+ const match = ESLINT_PROBLEM2.test(line) ? ESLINT_FIELDS.exec(line) : null;
2004
2055
  if (match !== null && file !== undefined) {
2005
2056
  const text = match[4] ?? "";
2006
2057
  const rule = ESLINT_RULE.exec(text);
@@ -2019,25 +2070,33 @@ var collectGo = (lines, used) => {
2019
2070
  const match = used.has(index) ? null : GO_ERROR.exec(line);
2020
2071
  if (match === null)
2021
2072
  continue;
2022
- errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), severity: "error", message: match[4] ?? "" });
2073
+ const linter = GO_LINTER.exec(match[4] ?? "");
2074
+ errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), ...linter === null ? {} : { rule: linter[2] }, severity: "error", message: linter === null ? match[4] ?? "" : linter[1] ?? "" });
2023
2075
  used.add(index);
2024
2076
  }
2025
2077
  return errors;
2026
2078
  };
2079
+ function headerAbove(lines, arrow, used) {
2080
+ let at = arrow - 1;
2081
+ while (at > 0 && arrow - at <= MAX_CONTINUATION && !used.has(at) && CONTINUATION.test(lines[at] ?? "") && !ARROW.test(lines[at] ?? ""))
2082
+ at--;
2083
+ return at;
2084
+ }
2027
2085
  var collectArrowed = (lines, used) => {
2028
2086
  const errors = [];
2029
2087
  for (const [index, line] of lines.entries()) {
2030
2088
  const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
2031
- const header = arrow === null ? null : lines[index - 1] ?? "";
2089
+ const at = arrow === null ? -1 : headerAbove(lines, index, used);
2090
+ const header = at === -1 ? null : lines[at] ?? "";
2032
2091
  const cargo = header === null ? null : CARGO_HEADER.exec(header);
2033
2092
  const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
2034
- if (arrow === null || cargo === null && ruff === null || used.has(index - 1))
2093
+ if (arrow === null || cargo === null && ruff === null || used.has(at))
2035
2094
  continue;
2036
- const [, file, row, column] = arrow;
2037
- const fields = { file: file ?? "", line: Number(row), column: Number(column) };
2038
- errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: "cargo", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
2039
- used.add(index - 1);
2040
- used.add(index);
2095
+ const [, file = "", row, column] = arrow;
2096
+ const fields = { file, line: Number(row), column: Number(column) };
2097
+ errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: file.endsWith(".rs") ? "cargo" : "kay check", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
2098
+ for (let taken = at;taken <= index; taken++)
2099
+ used.add(taken);
2041
2100
  for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
2042
2101
  if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
2043
2102
  break;
@@ -2101,40 +2160,63 @@ var collectPytest = (lines, used) => {
2101
2160
  }
2102
2161
  return errors;
2103
2162
  };
2104
- var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint];
2163
+ var collectGeneric = (lines, used) => {
2164
+ const errors = [];
2165
+ for (const [index, line] of lines.entries()) {
2166
+ const match = used.has(index) ? null : GENERIC_LINE.exec(line);
2167
+ if (match === null)
2168
+ continue;
2169
+ used.add(index);
2170
+ if (match[4] === "note")
2171
+ continue;
2172
+ const text = match[5] ?? "";
2173
+ const ruled = GENERIC_RULE.exec(text);
2174
+ const rule = ruled?.[1] ?? ruled?.[2];
2175
+ errors.push({ tool: "generic", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), rule, severity: match[4] === "warning" ? "warning" : "error", message: ruled === null ? text : text.slice(0, ruled.index).trimEnd() });
2176
+ }
2177
+ return errors;
2178
+ };
2179
+ var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint, collectGeneric];
2105
2180
  function parseErrors(output) {
2106
2181
  const lines = stripAnsi(output).split(`
2107
2182
  `);
2108
- if (BASH_ECHO.test(lines[0] ?? ""))
2183
+ if (BASH_ECHO2.test(lines[0] ?? ""))
2109
2184
  lines.shift();
2110
2185
  const used = new Set;
2111
- const errors = COLLECTORS.flatMap((collect) => collect(lines, used));
2186
+ const seen = new Set;
2187
+ const errors = COLLECTORS.flatMap((collect) => collect(lines, used)).filter((error) => {
2188
+ const key = [error.file, error.line, error.column, error.message, error.test].join("\x00");
2189
+ if (seen.has(key))
2190
+ return false;
2191
+ seen.add(key);
2192
+ return true;
2193
+ });
2112
2194
  const unrecognised = lines.filter((line, index) => !used.has(index) && !isNoise(line)).length;
2113
2195
  return { errors, unrecognised };
2114
2196
  }
2115
2197
 
2116
2198
  // src/run.ts
2117
2199
  import { mkdir as mkdir2, readdir as readdir2, stat as stat2, writeFile } from "fs/promises";
2118
- import { basename as basename2, join as join8 } from "path";
2119
- import process18 from "process";
2200
+ import { basename as basename2, join as join9 } from "path";
2201
+ import process20 from "process";
2120
2202
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
2121
2203
  var RESULTS_FILE = "results.json";
2122
2204
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2123
2205
  async function logDirectory(cwd) {
2124
2206
  const root = await privateLogDirectory("check");
2125
2207
  await sweepLogs(root, LOG_MAX_AGE_MS);
2126
- const path = join8(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process18.pid}`);
2208
+ const path = join9(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2127
2209
  await mkdir2(path, { mode: 448 });
2128
2210
  return path;
2129
2211
  }
2130
- async function lastFailed(cwd) {
2212
+ async function lastResults(cwd) {
2131
2213
  const root = await privateLogDirectory("check");
2132
2214
  const prefix = runPrefix(cwd);
2133
2215
  let latest;
2134
2216
  for (const name of await readdir2(root)) {
2135
2217
  if (!name.startsWith(prefix))
2136
2218
  continue;
2137
- const file = join8(root, name, RESULTS_FILE);
2219
+ const file = join9(root, name, RESULTS_FILE);
2138
2220
  try {
2139
2221
  const { mtimeMs } = await stat2(file);
2140
2222
  if (latest === undefined || mtimeMs > latest.time)
@@ -2143,13 +2225,15 @@ async function lastFailed(cwd) {
2143
2225
  }
2144
2226
  if (latest === undefined)
2145
2227
  return;
2146
- const results = JSON.parse(await Bun.file(latest.file).text());
2147
- return results.filter((result) => !result.ok).map((result) => result.name);
2228
+ return JSON.parse(await Bun.file(latest.file).text());
2229
+ }
2230
+ async function lastFailed(cwd) {
2231
+ return (await lastResults(cwd))?.filter((result) => !result.ok).map((result) => result.name);
2148
2232
  }
2149
2233
  async function saveLog(output) {
2150
2234
  const root = await privateLogDirectory("errs");
2151
2235
  await sweepLogs(root);
2152
- const path = join8(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process18.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2236
+ const path = join9(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2153
2237
  await writeFile(path, output, { mode: 384, flag: "wx" });
2154
2238
  return path;
2155
2239
  }
@@ -2157,7 +2241,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2157
2241
  const started = Date.now();
2158
2242
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2159
2243
  cwd,
2160
- env: { ...process18.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2244
+ env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2161
2245
  ...timeoutMs === undefined ? {} : { timeoutMs },
2162
2246
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2163
2247
  });
@@ -2173,8 +2257,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2173
2257
  return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
2174
2258
  }
2175
2259
  function printOutcome(name, width, command, logFile, outcome) {
2176
- const colors = paint(process18.stdout);
2177
- const path = role("path", process18.stdout);
2260
+ const colors = paint(process20.stdout);
2261
+ const path = role("path", process20.stdout);
2178
2262
  const took = colors.dim(formatDuration(outcome.ms));
2179
2263
  if (outcome.ok) {
2180
2264
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2194,10 +2278,10 @@ var usage2 = `errs [options] [log]
2194
2278
  errs [options] -- <command> [args...]
2195
2279
  errs --in <service> | --host -- <command> [args...]
2196
2280
 
2197
- Prints one \`file:line:col: message (rule)\` line per error found in a tsc, tsgo, vue-tsc, bun check, eslint, keslint, bun test, vitest, playwright (list and line reporters), phpunit, paratest, phpstan (table, raw and json), php-cs-fixer, go (build, vet), cargo (rustc), ruff (concise and full) or pytest log, read from the file given, from stdin (no argument or -), or from the output of the command run after --.
2281
+ Prints one \`file:line:col: message (rule)\` line per error found in a tsc, tsgo, vue-tsc, bun check, kay check, eslint, keslint, bun test, vitest, playwright (list and line reporters), phpunit, paratest, phpstan (table, raw and json), php-cs-fixer, go (build, vet), cargo (rustc), ruff (concise and full) or pytest log, or any line shaped \`file:line[:col]: error|warning: message\` (mypy, gcc, clang, \`shellcheck -f gcc\`, golangci-lint), read from the file given, from stdin (no argument or -), or from the output of the command run after --.
2198
2282
  The lines no format recognised are counted on stderr, never dropped silently, and a command's full output is saved to a log file whose path is printed with that count.
2199
2283
  A command runs inside the docker compose service that bind-mounts the current folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path, with its output read here; a service that is down is never started, the call fails naming it. --in picks the service, --host forces the host.
2200
- --json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff, pytest.`;
2284
+ --json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, kay check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff, pytest, generic. An error repeated with the same file, position and message is printed once.`;
2201
2285
  var EXITS = [[0, "no error was found and the command, if any, passed"], [1, "errors were found or the command failed"], [2, "a usage error"]];
2202
2286
  var options = {
2203
2287
  ...placeOptions,
@@ -2231,7 +2315,7 @@ async function readInput2(command, run, settings, cwd) {
2231
2315
  const held = holdSignals();
2232
2316
  let ran;
2233
2317
  try {
2234
- ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...process19.env, NO_COLOR: "1", FORCE_COLOR: "0" }, onStart: (child) => held.forward(child) });
2318
+ ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0" }, onStart: (child) => held.forward(child) });
2235
2319
  } catch (error) {
2236
2320
  fail(`cannot run ${command[0]}: ${error instanceof Error ? error.message : String(error)}`);
2237
2321
  } finally {
@@ -2239,7 +2323,7 @@ async function readInput2(command, run, settings, cwd) {
2239
2323
  }
2240
2324
  return { text: stripAnsi(ran.text), log: await saveLog(ran.output), code: ran.code };
2241
2325
  }
2242
- async function errs(args, cwd = process19.cwd()) {
2326
+ async function errs(args, cwd = process21.cwd()) {
2243
2327
  const first = args[0];
2244
2328
  const bare = first !== undefined && !first.startsWith("-") && !await Bun.file(first).exists();
2245
2329
  const parsed = parse(bare ? [] : args, usage2, options, { exits: EXITS, rest: true, replaces: "reading raw tsc, eslint, phpunit, phpstan or playwright logs, or grepping a test summary out of them", examples: [["errs -- bun run check", "the type errors of a run"], ["bun test 2>&1 | errs", "the failed tests from stdin"], ["errs -- vendor/bin/phpunit", "each failed PHP test with its file and line"]] });
@@ -2263,4 +2347,4 @@ ${usage2}`);
2263
2347
  }
2264
2348
 
2265
2349
  // src/errs-cli.ts
2266
- process20.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });
2350
+ process22.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });