@hublo/sentinel 1.7.0-alpha.27 → 1.7.0-alpha.28

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.
@@ -623,10 +623,10 @@ function nxTargetCommand(cwd, target) {
623
623
  }
624
624
  const entry = project.targets?.[target];
625
625
  if (!entry || entry.executor !== "nx:run-commands") return void 0;
626
- const { command, commands, cwd: targetCwd } = entry.options ?? {};
626
+ const { command: command2, commands, cwd: targetCwd } = entry.options ?? {};
627
627
  const ranInModule = typeof targetCwd === "string" && targetCwd.trim() !== "";
628
- if (typeof command === "string" && command.trim() !== "") {
629
- return { command: command.trim(), ranInModule };
628
+ if (typeof command2 === "string" && command2.trim() !== "") {
629
+ return { command: command2.trim(), ranInModule };
630
630
  }
631
631
  if (Array.isArray(commands)) {
632
632
  const parts = commands.filter((c) => typeof c === "string" && c.trim() !== "");
@@ -634,8 +634,8 @@ function nxTargetCommand(cwd, target) {
634
634
  }
635
635
  return void 0;
636
636
  }
637
- function rootedForScript(command) {
638
- return command.replace(/(^|&&\s*)pnpm exec /g, "$1pnpm --workspace-root exec ");
637
+ function rootedForScript(command2) {
638
+ return command2.replace(/(^|&&\s*)pnpm exec /g, "$1pnpm --workspace-root exec ");
639
639
  }
640
640
  function existingCommand(cwd, target) {
641
641
  const script = moduleScripts(cwd)[target];
@@ -658,8 +658,8 @@ function isSentinelSegment(segment, roleFlag) {
658
658
  return runsSentinel && new RegExp(String.raw`(^|\s)${roleFlag}(\s|$)`).test(segment);
659
659
  }
660
660
  function composeToolScript(existing, options) {
661
- const { command } = options;
662
- if (!existing || existing.trim() === "") return command;
661
+ const { command: command2 } = options;
662
+ if (!existing || existing.trim() === "") return command2;
663
663
  const { roleFlag } = options;
664
664
  const isReplaceable = (segment) => options.replaces(segment) || roleFlag !== void 0 && isSentinelSegment(segment, roleFlag);
665
665
  const parts = existing.split(SEGMENT_SEPARATOR);
@@ -670,7 +670,7 @@ function composeToolScript(existing, options) {
670
670
  if (isSeparatorAt(index) || !isReplaceable(part)) return part;
671
671
  if (replacedOnce) return null;
672
672
  replacedOnce = true;
673
- return options.keepFix && /(^|\s)--fix(\s|$)/.test(part) ? `${command} --fix` : command;
673
+ return options.keepFix && /(^|\s)--fix(\s|$)/.test(part) ? `${command2} --fix` : command2;
674
674
  });
675
675
  const kept = [];
676
676
  for (let index = 0; index < rebuilt.length; index += 1) {
@@ -709,14 +709,14 @@ function appOptions(rest) {
709
709
  const kept = tokens.filter((token, at) => !(at === 0 && DEV_SUBCOMMANDS.has(token)));
710
710
  return kept.join(" ");
711
711
  }
712
- function composeDevScript(existing, command) {
713
- if (existing === void 0 || existing.trim() === "") return command;
712
+ function composeDevScript(existing, command2) {
713
+ if (existing === void 0 || existing.trim() === "") return command2;
714
714
  const chunks = existing.trim().split(CHAIN);
715
715
  const at = chunks.map((chunk) => VITE_TOKEN.test(chunk)).lastIndexOf(true);
716
716
  if (at === -1) return existing;
717
717
  const rest = (chunks[at] ?? "").replace(/^.*?(^|\s|\/)vite(\s|$)/, "");
718
718
  const options = appOptions(rest);
719
- chunks[at] = options === "" ? `${command} --` : `${command} -- ${options}`;
719
+ chunks[at] = options === "" ? `${command2} --` : `${command2} -- ${options}`;
720
720
  return chunks.join(CHAIN);
721
721
  }
722
722
 
@@ -732,9 +732,9 @@ function delegatesToScript(target, scriptName) {
732
732
  if (typeof options !== "object" || options === null || Array.isArray(options)) return false;
733
733
  const declared = options;
734
734
  if (!Object.keys(declared).every((key) => DELEGATION_OPTION_KEYS.has(key))) return false;
735
- const command = declared["command"];
736
- if (typeof command !== "string") return false;
737
- return new RegExp(String.raw`(^|\s)run\s+${scriptName}$`).test(command.trim());
735
+ const command2 = declared["command"];
736
+ if (typeof command2 !== "string") return false;
737
+ return new RegExp(String.raw`(^|\s)run\s+${scriptName}$`).test(command2.trim());
738
738
  }
739
739
  function devScriptIsAdopted(devScript) {
740
740
  return devScript !== void 0 && devScript.includes(SENTINEL_DEV_COMMAND);
@@ -2310,26 +2310,26 @@ function escapeProperty(text) {
2310
2310
  return escapeData(text).replace(/:/g, "%3A").replace(/,/g, "%2C");
2311
2311
  }
2312
2312
  var GITHUB_ANNOTATION_CAP = 10;
2313
- function summaryAnnotation(command, count, level) {
2314
- const what = command === "error" ? "blocking findings" : level === "error" ? "advisory findings" : "findings";
2315
- const message = `${count} ${what} (GitHub shows at most ${GITHUB_ANNOTATION_CAP} ${command} annotations per step): the full list is in the env report, in this step's log, and in env-report/env.md with --output markdown`;
2316
- return `::${command} title=${escapeProperty(`env: ${count} ${what}`)}::${escapeData(message)}`;
2313
+ function summaryAnnotation(command2, count, level) {
2314
+ const what = command2 === "error" ? "blocking findings" : level === "error" ? "advisory findings" : "findings";
2315
+ const message = `${count} ${what} (GitHub shows at most ${GITHUB_ANNOTATION_CAP} ${command2} annotations per step): the full list is in the env report, in this step's log, and in env-report/env.md with --output markdown`;
2316
+ return `::${command2} title=${escapeProperty(`env: ${count} ${what}`)}::${escapeData(message)}`;
2317
2317
  }
2318
2318
  function renderAnnotations(report) {
2319
2319
  if (report.level === "info") return [];
2320
2320
  const annotations = report.findings.filter((entry) => entry.severity !== "info").map((entry) => {
2321
- const command = report.level === "error" && entry.severity === "blocking" ? "error" : "warning";
2321
+ const command2 = report.level === "error" && entry.severity === "blocking" ? "error" : "warning";
2322
2322
  const properties = [
2323
2323
  entry.file === void 0 ? void 0 : `file=${escapeProperty(entry.file)}`,
2324
2324
  entry.line === void 0 ? void 0 : `line=${entry.line}`,
2325
2325
  `title=${escapeProperty(`env rule ${entry.number}: ${entry.rule}`)}`
2326
2326
  ].filter(Boolean);
2327
2327
  const message = `${entry.name}${entry.detail ? ` (${entry.detail})` : ""}: ${RULES[entry.rule].help}`;
2328
- return { command, line: `::${command} ${properties.join(",")}::${escapeData(message)}` };
2328
+ return { command: command2, line: `::${command2} ${properties.join(",")}::${escapeData(message)}` };
2329
2329
  });
2330
- const summaries = ["error", "warning"].flatMap((command) => {
2331
- const count = annotations.filter((entry) => entry.command === command).length;
2332
- return count > GITHUB_ANNOTATION_CAP ? [summaryAnnotation(command, count, report.level)] : [];
2330
+ const summaries = ["error", "warning"].flatMap((command2) => {
2331
+ const count = annotations.filter((entry) => entry.command === command2).length;
2332
+ return count > GITHUB_ANNOTATION_CAP ? [summaryAnnotation(command2, count, report.level)] : [];
2333
2333
  });
2334
2334
  return [...summaries, ...annotations.map((entry) => entry.line)];
2335
2335
  }
@@ -2698,10 +2698,10 @@ function isPrettierSegment(segment) {
2698
2698
  return invokes(segment, "prettier");
2699
2699
  }
2700
2700
  function composeFormatScript(existing, options = {}) {
2701
- const command = options.command ?? SENTINEL_FORMAT_COMMAND;
2701
+ const command2 = options.command ?? SENTINEL_FORMAT_COMMAND;
2702
2702
  const rewritten = composeToolScript(existing, {
2703
2703
  replaces: isPrettierSegment,
2704
- command: options.keepFix === true ? `${command} --fix` : command,
2704
+ command: options.keepFix === true ? `${command2} --fix` : command2,
2705
2705
  roleFlag: options.command === void 0 ? void 0 : "--format"
2706
2706
  });
2707
2707
  return rewritten;
@@ -2709,13 +2709,13 @@ function composeFormatScript(existing, options = {}) {
2709
2709
  function invokesFormat(script) {
2710
2710
  return /--format\b/.test(script) || isPrettierSegment(script);
2711
2711
  }
2712
- function keepsOtherCommands2(script, command) {
2713
- return keepsOtherCommands(script, command ?? SENTINEL_FORMAT_COMMAND);
2712
+ function keepsOtherCommands2(script, command2) {
2713
+ return keepsOtherCommands(script, command2 ?? SENTINEL_FORMAT_COMMAND);
2714
2714
  }
2715
- function writesWhenRewritten(name, command) {
2715
+ function writesWhenRewritten(name, command2) {
2716
2716
  if (/[:-](fix|write)$/.test(name)) return true;
2717
2717
  if (CHECK_SCRIPT_NAMES.has(name) || /[:-]check$/.test(name)) return false;
2718
- return /--write\b/.test(command);
2718
+ return /--write\b/.test(command2);
2719
2719
  }
2720
2720
  var CHECK_SCRIPT_NAMES = /* @__PURE__ */ new Set(["lint", "format", "check", "test", "typecheck", "verify"]);
2721
2721
 
@@ -3242,14 +3242,14 @@ var OxfmtAdapter = class extends BaseAdapter {
3242
3242
  [FORMAT_SCRIPT_NAME]: compose(existingCommand(cwd, FORMAT_SCRIPT_NAME), false),
3243
3243
  [`${FORMAT_SCRIPT_NAME}:fix`]: compose(scripts2[`${FORMAT_SCRIPT_NAME}:fix`], true)
3244
3244
  };
3245
- for (const [name, command] of Object.entries(scripts2)) {
3245
+ for (const [name, command2] of Object.entries(scripts2)) {
3246
3246
  if (name in rewritten) continue;
3247
- const needsRewrite = /\bprettier\b/.test(command) || // ...and, for a self-adopting package, a script already running sentinel FOR FORMAT.
3247
+ const needsRewrite = /\bprettier\b/.test(command2) || // ...and, for a self-adopting package, a script already running sentinel FOR FORMAT.
3248
3248
  // The `--format` check is load-bearing: without it this matched the module's `lint`
3249
3249
  // script too and rewrote it into a second format run.
3250
- ownCommand !== void 0 && /\bsentinel\b/.test(command) && /--format\b/.test(command);
3250
+ ownCommand !== void 0 && /\bsentinel\b/.test(command2) && /--format\b/.test(command2);
3251
3251
  if (!needsRewrite) continue;
3252
- rewritten[name] = compose(command, writesWhenRewritten(name, command));
3252
+ rewritten[name] = compose(command2, writesWhenRewritten(name, command2));
3253
3253
  }
3254
3254
  return this.joinFormatIntoLint(scripts2, rewritten, ownCommand);
3255
3255
  }
@@ -3274,7 +3274,7 @@ var OxfmtAdapter = class extends BaseAdapter {
3274
3274
  * The dedicated `format` / `format:fix` scripts stay, for running the formatter alone.
3275
3275
  */
3276
3276
  joinFormatIntoLint(original, rewritten, selfCommand2) {
3277
- const command = selfCommand2 ?? SENTINEL_FORMAT_COMMAND;
3277
+ const command2 = selfCommand2 ?? SENTINEL_FORMAT_COMMAND;
3278
3278
  for (const [name, keepFix] of [
3279
3279
  ["lint", false],
3280
3280
  ["lint:fix", true]
@@ -3282,7 +3282,7 @@ var OxfmtAdapter = class extends BaseAdapter {
3282
3282
  const script = rewritten[name] ?? original[name];
3283
3283
  if (!script || script.trim() === "") continue;
3284
3284
  if (invokesFormat(script)) continue;
3285
- rewritten[name] = `${script} && ${keepFix ? `${command} --fix` : command}`;
3285
+ rewritten[name] = `${script} && ${keepFix ? `${command2} --fix` : command2}`;
3286
3286
  }
3287
3287
  return rewritten;
3288
3288
  }
@@ -3862,14 +3862,14 @@ function lintScripts(cwd) {
3862
3862
  })
3863
3863
  };
3864
3864
  const ownCommand = selfCommand(cwd, "--run --lint");
3865
- for (const [name, command] of Object.entries(scripts2)) {
3865
+ for (const [name, command2] of Object.entries(scripts2)) {
3866
3866
  if (name === LINT_SCRIPT_NAME) continue;
3867
- const needsRewrite = /\beslint\b/.test(command) || // ...and, for a self-adopting package, a script already running sentinel FOR LINT.
3867
+ const needsRewrite = /\beslint\b/.test(command2) || // ...and, for a self-adopting package, a script already running sentinel FOR LINT.
3868
3868
  // The `--lint` check is load-bearing: without it this matched the module's `format`
3869
3869
  // script too and rewrote it into a second lint run.
3870
- ownCommand !== void 0 && /\bsentinel\b/.test(command) && /--lint\b/.test(command);
3870
+ ownCommand !== void 0 && /\bsentinel\b/.test(command2) && /--lint\b/.test(command2);
3871
3871
  if (!needsRewrite) continue;
3872
- rewritten[name] = composeLintScript(command, { keepFix: true, command: ownCommand });
3872
+ rewritten[name] = composeLintScript(command2, { keepFix: true, command: ownCommand });
3873
3873
  }
3874
3874
  return rewritten;
3875
3875
  }
@@ -4463,14 +4463,14 @@ function registerLint() {
4463
4463
  import { spawnSync as spawnSync7 } from "node:child_process";
4464
4464
  import {
4465
4465
  cpSync as cpSync2,
4466
- existsSync as existsSync24,
4466
+ existsSync as existsSync25,
4467
4467
  mkdirSync as mkdirSync7,
4468
4468
  readdirSync as readdirSync8,
4469
- readFileSync as readFileSync25,
4469
+ readFileSync as readFileSync26,
4470
4470
  rmSync as rmSync4,
4471
4471
  writeFileSync as writeFileSync8
4472
4472
  } from "node:fs";
4473
- import { join as join33, relative as relative6, resolve as resolve7, sep as sep2 } from "node:path";
4473
+ import { join as join34, relative as relative6, resolve as resolve7, sep as sep2 } from "node:path";
4474
4474
 
4475
4475
  // src/roles/static-analysis/workspace/consumers.ts
4476
4476
  import { spawnSync as spawnSync5 } from "node:child_process";
@@ -4697,8 +4697,8 @@ function outsideView(index, workspaceRoot, moduleRoot) {
4697
4697
  }
4698
4698
 
4699
4699
  // src/roles/runtime-analysis/config/checks.ts
4700
- import { existsSync as existsSync17, readFileSync as readFileSync17 } from "node:fs";
4701
- import { join as join24 } from "node:path";
4700
+ import { existsSync as existsSync18, readFileSync as readFileSync18 } from "node:fs";
4701
+ import { join as join25 } from "node:path";
4702
4702
 
4703
4703
  // src/roles/runtime-analysis/config/framework.ts
4704
4704
  import { existsSync as existsSync16, readdirSync as readdirSync3 } from "node:fs";
@@ -4713,9 +4713,69 @@ function framework(dir) {
4713
4713
  return "unknown";
4714
4714
  }
4715
4715
 
4716
+ // src/roles/runtime-analysis/config/server-side.ts
4717
+ import { existsSync as existsSync17, readFileSync as readFileSync17 } from "node:fs";
4718
+ import { join as join24 } from "node:path";
4719
+ var SERVER_ENV_FILE = join24("runtime-analysis", "server.env");
4720
+ var SESSION_FILE = join24("runtime-analysis", "session.json");
4721
+ function parseEnvFile2(text, file = SERVER_ENV_FILE) {
4722
+ const env = {};
4723
+ for (const [at, raw] of text.split("\n").entries()) {
4724
+ const line = raw.trim();
4725
+ if (line === "" || line.startsWith("#")) continue;
4726
+ const equals = line.indexOf("=");
4727
+ if (equals <= 0) throw new Error(`${file}:${at + 1}: expected KEY=VALUE, found "${line}"`);
4728
+ const key = line.slice(0, equals).trim();
4729
+ const value = line.slice(equals + 1).trim();
4730
+ env[key] = /^(["']).*\1$/.test(value) ? value.slice(1, -1) : value;
4731
+ }
4732
+ return env;
4733
+ }
4734
+ function readServerEnv(moduleDir) {
4735
+ const path2 = join24(moduleDir, SERVER_ENV_FILE);
4736
+ return existsSync17(path2) ? parseEnvFile2(readFileSync17(path2, "utf8")) : {};
4737
+ }
4738
+ function serverEnvFor(env, at) {
4739
+ const host = new URL(at).host;
4740
+ return Object.fromEntries(
4741
+ Object.entries(env).map(([key, value]) => [
4742
+ key,
4743
+ value.replaceAll("{origin}", at).replaceAll("{host}", host)
4744
+ ])
4745
+ );
4746
+ }
4747
+ var isText = (value) => typeof value === "string" && value !== "";
4748
+ function readSession(moduleDir) {
4749
+ const path2 = join24(moduleDir, SESSION_FILE);
4750
+ if (!existsSync17(path2)) return void 0;
4751
+ let parsed;
4752
+ try {
4753
+ parsed = JSON.parse(readFileSync17(path2, "utf8"));
4754
+ } catch (error) {
4755
+ throw new Error(`${SESSION_FILE}: ${error instanceof Error ? error.message : String(error)}`, {
4756
+ cause: error
4757
+ });
4758
+ }
4759
+ const session = parsed;
4760
+ const cookies = session?.cookies;
4761
+ if (!Array.isArray(cookies) || cookies.length === 0)
4762
+ throw new Error(`${SESSION_FILE}: "cookies" must list the cookies the browser sends back`);
4763
+ for (const cookie of cookies)
4764
+ if (!isText(cookie?.name) || !isText(cookie?.value))
4765
+ throw new Error(`${SESSION_FILE}: every cookie needs a "name" and a "value"`);
4766
+ const store = session?.store;
4767
+ if (store !== void 0) {
4768
+ if (!isText(store.url) || !store.url.startsWith("redis://"))
4769
+ throw new Error(`${SESSION_FILE}: "store.url" must be a redis://host:port URL`);
4770
+ if (!Array.isArray(store.entries) || store.entries.some((entry) => !isText(entry?.key)))
4771
+ throw new Error(`${SESSION_FILE}: "store.entries" must list { "key", "value" } pairs`);
4772
+ }
4773
+ return { cookies, ...store === void 0 ? {} : { store } };
4774
+ }
4775
+
4716
4776
  // src/roles/runtime-analysis/config/checks.ts
4717
4777
  var isPath = (value) => typeof value === "string" && value.startsWith("/");
4718
- var isText = (value) => typeof value === "string" && value.trim() !== "";
4778
+ var isText2 = (value) => typeof value === "string" && value.trim() !== "";
4719
4779
  var isList = (value) => Array.isArray(value) && value.length > 0;
4720
4780
  var under = (path2, prefix) => path2 === prefix || path2.startsWith(`${prefix}/`);
4721
4781
  var isEnv = (env) => env !== null && typeof env === "object" && !Array.isArray(env) && Object.values(env).every((value) => typeof value === "string");
@@ -4747,23 +4807,39 @@ function checkGateway(front, { byBase, byPrefixes, report }) {
4747
4807
  else if (byBase && isPath(front.basePath) && under(front.ready, front.basePath))
4748
4808
  report("ready", `\`${front.ready}\` is under \`basePath\`: it goes to the app, not the mocks`);
4749
4809
  }
4750
- function checkBuild(front, { report }) {
4751
- if (!isText(front.build?.output)) report("build.output", "missing");
4752
- if (!isText(front.build?.server)) report("build.server", "missing");
4753
- if (!isEnv(front.build?.env) || !Object.keys(front.build.env).length)
4810
+ function checkBuild(front, { moduleDir, report }) {
4811
+ if (!isText2(front.build?.output)) report("build.output", "missing");
4812
+ if (!isText2(front.build?.server)) report("build.server", "missing");
4813
+ let serverEnv = {};
4814
+ try {
4815
+ serverEnv = readServerEnv(moduleDir);
4816
+ } catch (error) {
4817
+ report(SERVER_ENV_FILE, error instanceof Error ? error.message : String(error));
4818
+ }
4819
+ const hasServerEnv = Object.keys(serverEnv).length > 0;
4820
+ if (!isEnv(front.build?.env) || !Object.keys(front.build.env).length && !hasServerEnv)
4754
4821
  report("build.env", "the build variables, an object of strings");
4755
- else if (!Object.values(front.build.env).some((value) => value.includes("{origin}")))
4822
+ else if (![...Object.values(front.build.env), ...Object.values(serverEnv)].some(
4823
+ (value) => value.includes("{origin}")
4824
+ ))
4756
4825
  report(
4757
4826
  "build.env",
4758
- "no variable holds `{origin}`: the app would call a real API, not the mocks"
4827
+ `no variable holds \`{origin}\`, here or in ${SERVER_ENV_FILE}: the app would call a real API, not the mocks`
4759
4828
  );
4760
4829
  }
4830
+ function checkSession(_front, { moduleDir, report }) {
4831
+ try {
4832
+ readSession(moduleDir);
4833
+ } catch (error) {
4834
+ report(SESSION_FILE, error instanceof Error ? error.message : String(error));
4835
+ }
4836
+ }
4761
4837
  function checkApi(front, { moduleDir, byPrefixes, report }) {
4762
4838
  if (!isList(front.api))
4763
4839
  return report("api", "the answers of the calls the screens make, a non-empty list");
4764
4840
  const goesToApp = (path2) => byPrefixes ? !front.mockPrefixes?.some((prefix) => under(path2, prefix)) : isPath(front.basePath) && under(path2, front.basePath);
4765
4841
  for (const [index, entry] of front.api.entries()) {
4766
- const field = `api[${index}]${isText(entry?.path) ? ` (${entry.path})` : ""}`;
4842
+ const field = `api[${index}]${isText2(entry?.path) ? ` (${entry.path})` : ""}`;
4767
4843
  if (entry?.method !== void 0 && !METHODS.includes(entry.method))
4768
4844
  report(field, `\`method\`: one of ${METHODS.join(", ")}`);
4769
4845
  if (!isPath(entry?.path)) report(field, "`path`: a path starting with `/`");
@@ -4771,12 +4847,12 @@ function checkApi(front, { moduleDir, byPrefixes, report }) {
4771
4847
  report(field, "`path` goes to the app, not the mocks: it never answers");
4772
4848
  if (entry?.status !== void 0 && !isStatus(entry.status))
4773
4849
  report(field, "`status`: an HTTP status (200 when left out)");
4774
- if (!isText(entry?.file)) report(field, "`file` missing");
4775
- else if (!existsSync17(join24(moduleDir, entry.file)))
4850
+ if (!isText2(entry?.file)) report(field, "`file` missing");
4851
+ else if (!existsSync18(join25(moduleDir, entry.file)))
4776
4852
  report(field, `\`file\`: no ${entry.file} in the module`);
4777
4853
  else
4778
4854
  try {
4779
- expand(JSON.parse(readFileSync17(join24(moduleDir, entry.file), "utf8")));
4855
+ expand(JSON.parse(readFileSync18(join25(moduleDir, entry.file), "utf8")));
4780
4856
  } catch (failure) {
4781
4857
  report(field, `\`file\` ${entry.file}: ${failure.message}`);
4782
4858
  }
@@ -4789,40 +4865,40 @@ function checkApi(front, { moduleDir, byPrefixes, report }) {
4789
4865
  }
4790
4866
  function checkRouter(front, { inModule, report }) {
4791
4867
  const { tsconfig, shell, routes } = front.router ?? {};
4792
- if (!isText(tsconfig)) report("router.tsconfig", "missing");
4793
- else if (!existsSync17(inModule(tsconfig)))
4868
+ if (!isText2(tsconfig)) report("router.tsconfig", "missing");
4869
+ else if (!existsSync18(inModule(tsconfig)))
4794
4870
  report("router.tsconfig", `no ${tsconfig} in the module`);
4795
4871
  if (!isList(shell))
4796
4872
  report("router.shell", "the app shell files every screen loads, a non-empty list");
4797
4873
  else
4798
4874
  for (const file of shell)
4799
- if (!existsSync17(inModule(file))) report("router.shell", `no ${file} in the module`);
4800
- if (!isText(routes)) report("router.routes", "missing");
4801
- else if (!existsSync17(inModule(join24(routes, "__root.tsx"))))
4875
+ if (!existsSync18(inModule(file))) report("router.shell", `no ${file} in the module`);
4876
+ if (!isText2(routes)) report("router.routes", "missing");
4877
+ else if (!existsSync18(inModule(join25(routes, "__root.tsx"))))
4802
4878
  report("router.routes", `no __root.tsx in ${routes}: not TanStack Router file routes`);
4803
4879
  }
4804
4880
  function isAction(action) {
4805
4881
  if (!action || typeof action !== "object" || Object.keys(action).length !== 1) return false;
4806
4882
  const [[name, arg]] = Object.entries(action);
4807
- if (name === "click" || name === "clickText") return isText(arg);
4883
+ if (name === "click" || name === "clickText") return isText2(arg);
4808
4884
  const typed = arg;
4809
- return name === "type" && isText(typed?.selector) && typeof typed?.text === "string";
4885
+ return name === "type" && isText2(typed?.selector) && typeof typed?.text === "string";
4810
4886
  }
4811
- var isRows = (rows) => isText(rows?.selector) && (Number.isInteger(rows?.count) || Number.isInteger(rows?.min));
4887
+ var isRows = (rows) => isText2(rows?.selector) && (Number.isInteger(rows?.count) || Number.isInteger(rows?.min));
4812
4888
  function checkScreens(front, { inModule, report }) {
4813
4889
  if (!isList(front.screens)) return report("screens", "at least one screen");
4814
4890
  const routes = front.router?.routes;
4815
4891
  const seen = /* @__PURE__ */ new Set();
4816
4892
  for (const [index, screen] of front.screens.entries()) {
4817
- const field = `screens[${index}]${isText(screen?.id) ? ` (${screen.id})` : ""}`;
4818
- if (!isText(screen?.id)) report(field, "`id` missing");
4893
+ const field = `screens[${index}]${isText2(screen?.id) ? ` (${screen.id})` : ""}`;
4894
+ if (!isText2(screen?.id)) report(field, "`id` missing");
4819
4895
  else if (seen.has(screen.id)) report(field, `\`id\` \`${screen.id}\` is used twice`);
4820
4896
  else seen.add(screen.id);
4821
- if (!isText(screen?.route)) report(field, "`route` missing");
4822
- else if (isText(routes) && !existsSync17(inModule(join24(routes, screen.route))))
4897
+ if (!isText2(screen?.route)) report(field, "`route` missing");
4898
+ else if (isText2(routes) && !existsSync18(inModule(join25(routes, screen.route))))
4823
4899
  report(field, `\`route\`: no ${screen.route} in ${routes}`);
4824
4900
  if (!isPath(screen?.path)) report(field, "`path`: a path starting with `/`");
4825
- if (!isList(screen?.expectText) || !screen.expectText.every(isText))
4901
+ if (!isList(screen?.expectText) || !screen.expectText.every(isText2))
4826
4902
  report(field, "`expectText`: a non-empty list of texts the screen shows once opened");
4827
4903
  if (!isAction(screen?.interact))
4828
4904
  report(
@@ -4839,20 +4915,20 @@ function validateRuntimeConfig(front, moduleDir) {
4839
4915
  moduleDir,
4840
4916
  byBase: front.basePath !== void 0,
4841
4917
  byPrefixes: front.mockPrefixes !== void 0,
4842
- inModule: (path2) => join24(moduleDir, path2),
4918
+ inModule: (path2) => join25(moduleDir, path2),
4843
4919
  report: (field, message) => errors.push({ field, message })
4844
4920
  };
4845
4921
  checkIdentity(front, context2);
4846
4922
  if (errors.length) return errors;
4847
- for (const check of [checkGateway, checkBuild, checkApi, checkRouter, checkScreens])
4923
+ for (const check of [checkGateway, checkBuild, checkSession, checkApi, checkRouter, checkScreens])
4848
4924
  check(front, context2);
4849
4925
  return errors;
4850
4926
  }
4851
4927
 
4852
4928
  // src/roles/runtime-analysis/detect/affected.ts
4853
4929
  import { spawnSync as spawnSync6 } from "node:child_process";
4854
- import { existsSync as existsSync18, readFileSync as readFileSync18 } from "node:fs";
4855
- import { dirname as dirname3, join as join25, posix, relative as relative5, resolve as resolve4 } from "node:path";
4930
+ import { existsSync as existsSync19, readFileSync as readFileSync19 } from "node:fs";
4931
+ import { dirname as dirname3, join as join26, posix, relative as relative5, resolve as resolve4 } from "node:path";
4856
4932
  import ts from "typescript";
4857
4933
  var WORKSPACE_INPUTS = /* @__PURE__ */ new Set([
4858
4934
  "package.json",
@@ -4866,14 +4942,14 @@ var WORKSPACE_INPUTS = /* @__PURE__ */ new Set([
4866
4942
  var NOT_BUILT = /^(\.oxlintrc\.json|\.oxfmtrc\.json|oxlint\/|catalog-info\.yaml|Dockerfile|helm_values\/|nginx\/|README\.md|vitest\.config\.ts|\.gitignore|\.env(\.test)?\.example|scripts\/)/;
4867
4943
  var NAMESPACE_LITERAL = /['"`](\w+\.[\w.]+?)['"`:]/g;
4868
4944
  function routeChain(routes, route) {
4869
- const chain = [join25(routes, "__root.tsx")];
4945
+ const chain = [join26(routes, "__root.tsx")];
4870
4946
  const segments = dirname3(route).split("/");
4871
4947
  for (let depth = 1; depth <= segments.length; depth++) {
4872
- const dir = join25(routes, ...segments.slice(0, depth));
4873
- for (const layout of [join25(dir, "route.tsx"), `${dir}.tsx`])
4874
- if (existsSync18(layout)) chain.push(layout);
4948
+ const dir = join26(routes, ...segments.slice(0, depth));
4949
+ for (const layout of [join26(dir, "route.tsx"), `${dir}.tsx`])
4950
+ if (existsSync19(layout)) chain.push(layout);
4875
4951
  }
4876
- return [...chain, join25(routes, route)];
4952
+ return [...chain, join26(routes, route)];
4877
4953
  }
4878
4954
  function shown(workspaceRoot, sha, file) {
4879
4955
  const run = spawnSync6("git", ["show", `${sha}:${file}`], {
@@ -4889,7 +4965,7 @@ function affectedScreens(input) {
4889
4965
  const namespaceOf = (file) => translations !== void 0 && file.startsWith(translations) ? file.slice(translations.length).match(/^[a-z]+\/(\w+\.[\w.]+)\.json$/)?.[1] ?? null : null;
4890
4966
  const readByEveryScreen = (file) => WORKSPACE_INPUTS.has(file) || file.startsWith(`${modulePath}/`) && !file.startsWith(`${modulePath}/src/`) && !NOT_BUILT.test(file.slice(modulePath.length + 1)) || translations !== void 0 && file.startsWith(translations) && !namespaceOf(file);
4891
4967
  const parsed = ts.getParsedCommandLineOfConfigFile(
4892
- join25(root, modulePath, config.router.tsconfig),
4968
+ join26(root, modulePath, config.router.tsconfig),
4893
4969
  {},
4894
4970
  {
4895
4971
  ...ts.sys,
@@ -4914,7 +4990,7 @@ function affectedScreens(input) {
4914
4990
  const erased = (file) => {
4915
4991
  if (!base || !/\.[cm]?tsx?$/.test(file)) return false;
4916
4992
  const before = shown(root, base, file);
4917
- const after = head ? shown(root, head, file) : existsSync18(join25(root, file)) ? readFileSync18(join25(root, file), "utf8") : null;
4993
+ const after = head ? shown(root, head, file) : existsSync19(join26(root, file)) ? readFileSync19(join26(root, file), "utf8") : null;
4918
4994
  return before !== null && after !== null && emitted(file, before) === emitted(file, after);
4919
4995
  };
4920
4996
  const changed = input.changed.filter((file) => !erased(file));
@@ -4923,13 +4999,13 @@ function affectedScreens(input) {
4923
4999
  const namespaces = /* @__PURE__ */ new Set();
4924
5000
  const stack = [...entries];
4925
5001
  for (const entry of entries)
4926
- if (!existsSync18(entry)) throw new Error(`no such entry: ${relative5(root, entry)}`);
5002
+ if (!existsSync19(entry)) throw new Error(`no such entry: ${relative5(root, entry)}`);
4927
5003
  while (stack.length) {
4928
5004
  const file = stack.pop();
4929
5005
  if (seen.has(file)) continue;
4930
5006
  seen.add(file);
4931
5007
  if (!/\.[cm]?[jt]sx?$/.test(file)) continue;
4932
- let text = readFileSync18(file, "utf8");
5008
+ let text = readFileSync19(file, "utf8");
4933
5009
  for (const [, name] of text.matchAll(NAMESPACE_LITERAL)) namespaces.add(name);
4934
5010
  if (/\.[cm]?tsx?$/.test(file) && !file.endsWith(".d.ts"))
4935
5011
  text = ts.transpileModule(text, { fileName: file, compilerOptions: transpile }).outputText;
@@ -4937,14 +5013,14 @@ function affectedScreens(input) {
4937
5013
  if (fileName.endsWith("routeTree.gen")) continue;
4938
5014
  const resolved = ts.resolveModuleName(fileName, file, options, host).resolvedModule;
4939
5015
  const target = resolved?.resolvedFileName ?? (fileName.startsWith(".") ? resolve4(dirname3(file), fileName.replace(/\?.*$/, "")) : null);
4940
- if (target && existsSync18(target) && !target.includes("/node_modules/")) stack.push(target);
5016
+ if (target && existsSync19(target) && !target.includes("/node_modules/")) stack.push(target);
4941
5017
  }
4942
5018
  }
4943
5019
  return { files: new Set([...seen].map((file) => relative5(root, file))), namespaces };
4944
5020
  };
4945
5021
  const reaches = (loaded, file) => loaded.files.has(file) || loaded.namespaces.has(namespaceOf(file));
4946
- const shell = closure(config.router.shell.map((file) => join25(root, modulePath, file)));
4947
- const routes = join25(root, modulePath, config.router.routes);
5022
+ const shell = closure(config.router.shell.map((file) => join26(root, modulePath, file)));
5023
+ const routes = join26(root, modulePath, config.router.routes);
4948
5024
  const everyScreen = changed.find((file) => readByEveryScreen(file) || reaches(shell, file));
4949
5025
  return config.screens.map((screen) => {
4950
5026
  if (everyScreen) return { id: screen.id, measured: true, because: everyScreen };
@@ -5040,7 +5116,7 @@ function detectionMarkdown({
5040
5116
  }
5041
5117
 
5042
5118
  // src/roles/runtime-analysis/measure/browser.ts
5043
- import { existsSync as existsSync19 } from "node:fs";
5119
+ import { existsSync as existsSync20 } from "node:fs";
5044
5120
  var BLOCK_THIRD_PARTIES = "--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1";
5045
5121
  var DEBUGGING_PORT = 9333;
5046
5122
  function findChrome() {
@@ -5048,7 +5124,7 @@ function findChrome() {
5048
5124
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
5049
5125
  "/usr/bin/google-chrome",
5050
5126
  "/usr/bin/google-chrome-stable"
5051
- ].find((candidate) => existsSync19(candidate));
5127
+ ].find((candidate) => existsSync20(candidate));
5052
5128
  }
5053
5129
  async function openBrowser({ chromium, puppeteer }, chromePath, locale) {
5054
5130
  const launched = await chromium.launch({
@@ -5086,33 +5162,33 @@ async function openBrowser({ chromium, puppeteer }, chromePath, locale) {
5086
5162
  // src/roles/runtime-analysis/measure/measure.ts
5087
5163
  import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync7 } from "node:fs";
5088
5164
  import { freemem, loadavg, totalmem } from "node:os";
5089
- import { join as join29, resolve as resolve5 } from "node:path";
5165
+ import { join as join30, resolve as resolve5 } from "node:path";
5090
5166
 
5091
5167
  // src/roles/runtime-analysis/measure/deps.ts
5092
5168
  import { execFileSync as execFileSync2 } from "node:child_process";
5093
5169
  import { createHash } from "node:crypto";
5094
5170
  import {
5095
5171
  cpSync,
5096
- existsSync as existsSync21,
5172
+ existsSync as existsSync22,
5097
5173
  mkdirSync as mkdirSync3,
5098
5174
  readdirSync as readdirSync4,
5099
- readFileSync as readFileSync20,
5175
+ readFileSync as readFileSync21,
5100
5176
  renameSync,
5101
5177
  rmSync as rmSync3
5102
5178
  } from "node:fs";
5103
5179
  import { homedir } from "node:os";
5104
- import { join as join27 } from "node:path";
5180
+ import { join as join28 } from "node:path";
5105
5181
  import { pathToFileURL as pathToFileURL2 } from "node:url";
5106
5182
 
5107
5183
  // src/roles/runtime-analysis/package-root.ts
5108
- import { existsSync as existsSync20, readFileSync as readFileSync19 } from "node:fs";
5109
- import { dirname as dirname4, join as join26 } from "node:path";
5184
+ import { existsSync as existsSync21, readFileSync as readFileSync20 } from "node:fs";
5185
+ import { dirname as dirname4, join as join27 } from "node:path";
5110
5186
  import { fileURLToPath } from "node:url";
5111
5187
  function packageRoot() {
5112
5188
  let dir = dirname4(fileURLToPath(import.meta.url));
5113
5189
  for (; ; ) {
5114
- const manifest = join26(dir, "package.json");
5115
- if (existsSync20(manifest) && JSON.parse(readFileSync19(manifest, "utf8")).name === "@hublo/sentinel")
5190
+ const manifest = join27(dir, "package.json");
5191
+ if (existsSync21(manifest) && JSON.parse(readFileSync20(manifest, "utf8")).name === "@hublo/sentinel")
5116
5192
  return dir;
5117
5193
  const parent = dirname4(dir);
5118
5194
  if (parent === dir) throw new Error("cannot find @hublo/sentinel's own folder");
@@ -5123,32 +5199,32 @@ function packageRoot() {
5123
5199
  // src/roles/runtime-analysis/measure/deps.ts
5124
5200
  var SHIPPED = ["package.json", "package-lock.json", "load.mjs"];
5125
5201
  function shippedDeps() {
5126
- return join27(packageRoot(), "runtime-analysis-deps");
5202
+ return join28(packageRoot(), "runtime-analysis-deps");
5127
5203
  }
5128
5204
  function depsDir(shipped = shippedDeps()) {
5129
- const lock = readFileSync20(join27(shipped, "package-lock.json"));
5205
+ const lock = readFileSync21(join28(shipped, "package-lock.json"));
5130
5206
  const key = createHash("sha256").update(lock).digest("hex").slice(0, 12);
5131
- const cache = process.env.SENTINEL_CACHE_DIR || join27(homedir(), ".cache", "sentinel");
5132
- return join27(cache, "runtime-analysis", key);
5207
+ const cache = process.env.SENTINEL_CACHE_DIR || join28(homedir(), ".cache", "sentinel");
5208
+ return join28(cache, "runtime-analysis", key);
5133
5209
  }
5134
5210
  function installBrowserDeps(say, shipped = shippedDeps()) {
5135
5211
  const dir = depsDir(shipped);
5136
- if (existsSync21(dir)) return dir;
5212
+ if (existsSync22(dir)) return dir;
5137
5213
  const partial = `${dir}.partial-${process.pid}`;
5138
5214
  rmSync3(partial, { recursive: true, force: true });
5139
5215
  mkdirSync3(partial, { recursive: true });
5140
- for (const file of SHIPPED) cpSync(join27(shipped, file), join27(partial, file));
5216
+ for (const file of SHIPPED) cpSync(join28(shipped, file), join28(partial, file));
5141
5217
  say(`installing the measure's browser packages once, into ${dir}`);
5142
5218
  try {
5143
5219
  const args = ["ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund"];
5144
- execFileSync2("npm", [...args, `--logs-dir=${join27(partial, ".npm-logs")}`], {
5220
+ execFileSync2("npm", [...args, `--logs-dir=${join28(partial, ".npm-logs")}`], {
5145
5221
  cwd: partial,
5146
5222
  stdio: ["ignore", "ignore", "pipe"],
5147
5223
  encoding: "utf8"
5148
5224
  });
5149
5225
  } catch (error) {
5150
5226
  const stderr = String(error.stderr ?? error.message);
5151
- const cause = npmCause(stderr, join27(partial, ".npm-logs"));
5227
+ const cause = npmCause(stderr, join28(partial, ".npm-logs"));
5152
5228
  rmSync3(partial, { recursive: true, force: true });
5153
5229
  throw new Error(
5154
5230
  `could not install the measure's browser packages (lighthouse, puppeteer-core, playwright-core) into ${dir}: ${cause}. They come from the npm registry once per sentinel version; in CI, cache the folder named by SENTINEL_CACHE_DIR.`,
@@ -5159,24 +5235,24 @@ function installBrowserDeps(say, shipped = shippedDeps()) {
5159
5235
  renameSync(partial, dir);
5160
5236
  } catch (error) {
5161
5237
  rmSync3(partial, { recursive: true, force: true });
5162
- if (!existsSync21(dir)) throw error;
5238
+ if (!existsSync22(dir)) throw error;
5163
5239
  }
5164
5240
  return dir;
5165
5241
  }
5166
5242
  function npmCause(stderr, logsDir) {
5167
- const logged = existsSync21(logsDir) ? readdirSync4(logsDir).map((file) => readFileSync20(join27(logsDir, file), "utf8")).join("\n") : "";
5243
+ const logged = existsSync22(logsDir) ? readdirSync4(logsDir).map((file) => readFileSync21(join28(logsDir, file), "utf8")).join("\n") : "";
5168
5244
  const unreachable = logged.match(/http fetch \S+ (\S+) attempt \d+ failed with (\w+)/);
5169
5245
  if (unreachable) return `${unreachable[2]} on ${unreachable[1]}`;
5170
5246
  return stderr.trim().split("\n").slice(0, 3).join(" ");
5171
5247
  }
5172
5248
  async function loadBrowserDeps(say) {
5173
5249
  const dir = installBrowserDeps(say);
5174
- return await import(pathToFileURL2(join27(dir, "load.mjs")).href);
5250
+ return await import(pathToFileURL2(join28(dir, "load.mjs")).href);
5175
5251
  }
5176
5252
 
5177
5253
  // src/roles/runtime-analysis/measure/flow.ts
5178
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync21, writeFileSync as writeFileSync6 } from "node:fs";
5179
- import { join as join28 } from "node:path";
5254
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync22, writeFileSync as writeFileSync6 } from "node:fs";
5255
+ import { join as join29 } from "node:path";
5180
5256
 
5181
5257
  // src/roles/runtime-analysis/measure/actions.ts
5182
5258
  async function click(page, selector) {
@@ -5404,8 +5480,19 @@ var METRICS = [
5404
5480
  "secondLcp",
5405
5481
  "secondCls"
5406
5482
  ];
5483
+ function sessionCookies(cookies, origin2) {
5484
+ const { hostname } = new URL(origin2);
5485
+ return cookies.map(({ name, value }) => ({
5486
+ name,
5487
+ value,
5488
+ domain: hostname,
5489
+ path: "/",
5490
+ httpOnly: true,
5491
+ ...name.startsWith("__Secure-") || name.startsWith("__Host-") ? { secure: true } : {}
5492
+ }));
5493
+ }
5407
5494
  function readLog(path2, fromMs, toMs) {
5408
- return readFileSync21(path2, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line)).filter((entry) => {
5495
+ return readFileSync22(path2, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line)).filter((entry) => {
5409
5496
  const at = Date.parse(entry.at);
5410
5497
  return at >= fromMs && at <= toMs;
5411
5498
  });
@@ -5421,11 +5508,11 @@ var pickSettings = (lhr) => ({
5421
5508
  });
5422
5509
  function saveLighthouseImages(navigation, dir, name) {
5423
5510
  const final = navigation.audits["final-screenshot"]?.details?.data;
5424
- if (final) saveImage(join28(dir, `${name}-lighthouse-final.jpg`), final);
5511
+ if (final) saveImage(join29(dir, `${name}-lighthouse-final.jpg`), final);
5425
5512
  const frames = navigation.audits["screenshot-thumbnails"]?.details?.items ?? [];
5426
5513
  for (const [index, frame] of frames.entries())
5427
5514
  saveImage(
5428
- join28(dir, "filmstrip", `${name}-${String(index).padStart(2, "0")}-${frame.timing}ms.jpg`),
5515
+ join29(dir, "filmstrip", `${name}-${String(index).padStart(2, "0")}-${frame.timing}ms.jpg`),
5429
5516
  frame.data
5430
5517
  );
5431
5518
  }
@@ -5446,11 +5533,25 @@ function saveRequests(path2, requests) {
5446
5533
  );
5447
5534
  }
5448
5535
  async function runFlow(input) {
5449
- const { browser, startFlow, config, out, front, ready, screen, variant, origin: origin2, logPath, round: round2 } = input;
5536
+ const {
5537
+ browser,
5538
+ startFlow,
5539
+ config,
5540
+ out,
5541
+ front,
5542
+ ready,
5543
+ screen,
5544
+ variant,
5545
+ origin: origin2,
5546
+ logPath,
5547
+ round: round2,
5548
+ cookies
5549
+ } = input;
5450
5550
  const name = `${variant}-r${round2}`;
5451
- const dir = join28(out, "screens", front, screen.id);
5452
- mkdirSync4(join28(dir, "filmstrip"), { recursive: true });
5551
+ const dir = join29(out, "screens", front, screen.id);
5552
+ mkdirSync4(join29(dir, "filmstrip"), { recursive: true });
5453
5553
  const context2 = await browser.createBrowserContext();
5554
+ if (cookies.length > 0) await context2.setCookie(...sessionCookies(cookies, origin2));
5454
5555
  const page = await context2.newPage();
5455
5556
  const pageEvents = [];
5456
5557
  page.on("error", (error) => pageEvents.push(`crashed: ${error.message}`));
@@ -5466,7 +5567,7 @@ async function runFlow(input) {
5466
5567
  await flow.navigate(`${origin2}${screen.path}`, { name: `${screen.id} navigation` });
5467
5568
  const navigatedAt = Date.now();
5468
5569
  await proveScreen(page, screen, origin2, proofs);
5469
- await page.screenshot({ path: join28(dir, `${name}-navigation.png`) });
5570
+ await page.screenshot({ path: join29(dir, `${name}-navigation.png`) });
5470
5571
  await flow.startTimespan({ name: `${screen.id} interaction` });
5471
5572
  await interact(page, screen.interact).then(
5472
5573
  () => proofs.pass("interaction", "done"),
@@ -5474,14 +5575,14 @@ async function runFlow(input) {
5474
5575
  );
5475
5576
  await page.waitForNetworkIdle({ idleTime: 500, timeout: 1e4 }).catch(() => void 0);
5476
5577
  await flow.endTimespan();
5477
- await page.screenshot({ path: join28(dir, `${name}-interaction.png`) });
5578
+ await page.screenshot({ path: join29(dir, `${name}-interaction.png`) });
5478
5579
  const second = await page.evaluate(
5479
5580
  () => window.__second
5480
5581
  );
5481
5582
  const endedAt = Date.now();
5482
5583
  const result = await flow.createFlowResult();
5483
5584
  const [navigation, interaction] = result.steps.map((step) => step.lhr);
5484
- writeFileSync6(join28(dir, `${name}.html`), await flow.generateReport());
5585
+ writeFileSync6(join29(dir, `${name}.html`), await flow.generateReport());
5485
5586
  saveLighthouseImages(navigation, dir, name);
5486
5587
  const lcpElement = proveLcpElement(navigation, proofs);
5487
5588
  const requests = readLog(logPath, startedAt, endedAt);
@@ -5490,10 +5591,10 @@ async function runFlow(input) {
5490
5591
  proveSecondReading(second, observed, proofs);
5491
5592
  if (har)
5492
5593
  writeFileSync6(
5493
- join28(out, "har", `${variant}-${front}-${screen.id}.har`),
5594
+ join29(out, "har", `${variant}-${front}-${screen.id}.har`),
5494
5595
  JSON.stringify(har(), null, 1)
5495
5596
  );
5496
- saveRequests(join28(out, "requests", `${front}-${screen.id}-${name}.json`), requests);
5597
+ saveRequests(join29(out, "requests", `${front}-${screen.id}-${name}.json`), requests);
5497
5598
  if (pageEvents.length) proofs.fail("page", pageEvents.join(", "));
5498
5599
  await context2.close();
5499
5600
  const audit = (lhr, id) => lhr.audits[id]?.numericValue;
@@ -5567,7 +5668,7 @@ async function measure(options) {
5567
5668
  ...screen,
5568
5669
  key: `${options.front}/${screen.id}`
5569
5670
  }));
5570
- for (const sub of ["screens", "har", "requests"]) mkdirSync5(join29(out, sub), { recursive: true });
5671
+ for (const sub of ["screens", "har", "requests"]) mkdirSync5(join30(out, sub), { recursive: true });
5571
5672
  const { browser, version, close } = await openBrowser(deps, options.chromePath, options.locale);
5572
5673
  const startedAt = Date.now();
5573
5674
  const lateRejections = [];
@@ -5591,7 +5692,8 @@ async function measure(options) {
5591
5692
  variant,
5592
5693
  origin: side.origin,
5593
5694
  logPath: resolve5(side.log),
5594
- round: round2
5695
+ round: round2,
5696
+ cookies: options.cookies ?? []
5595
5697
  };
5596
5698
  const before = machineLoad();
5597
5699
  const result = await runFlow(flow).catch((error) => crashedFlow(flow, error));
@@ -5626,7 +5728,7 @@ async function measure(options) {
5626
5728
  `${result.ok ? "ok " : "FAIL"} ${screen.key} ${variant[0]} r${round2}: LCP ${Math.round(lcp ?? Number.NaN)} ms, CLS ${cls?.toFixed(4)}, INP ${inp ?? "-"} ms, ${result.seconds.flow}s, load ${before.load.toFixed(1)}, free ${before.freeMemoryMb} MB${result.ok ? "" : ` ${failedChecks(result)}`}`
5627
5729
  );
5628
5730
  }
5629
- const save = (file, value, indent = 1) => writeFileSync7(join29(out, file), JSON.stringify(value, null, indent));
5731
+ const save = (file, value, indent = 1) => writeFileSync7(join30(out, file), JSON.stringify(value, null, indent));
5630
5732
  save("runs.json", results);
5631
5733
  save("warmup.json", warmups);
5632
5734
  save(
@@ -5728,8 +5830,53 @@ function parsePhase(toolArgs = []) {
5728
5830
 
5729
5831
  // src/roles/runtime-analysis/serve/serve.ts
5730
5832
  import { spawn } from "node:child_process";
5731
- import { mkdirSync as mkdirSync6, openSync, readdirSync as readdirSync5, readFileSync as readFileSync22 } from "node:fs";
5732
- import { join as join30, resolve as resolve6 } from "node:path";
5833
+ import { mkdirSync as mkdirSync6, openSync, readdirSync as readdirSync5, readFileSync as readFileSync23 } from "node:fs";
5834
+ import { join as join31, resolve as resolve6 } from "node:path";
5835
+
5836
+ // src/roles/runtime-analysis/serve/session-store.ts
5837
+ import { createConnection } from "node:net";
5838
+ function command(...parts) {
5839
+ return `*${parts.length}\r
5840
+ ${parts.map((part) => `$${Buffer.byteLength(part)}\r
5841
+ ${part}\r
5842
+ `).join("")}`;
5843
+ }
5844
+ async function seedStore(store, timeoutMs = 5e3) {
5845
+ const url = new URL(store.url);
5846
+ const host = url.hostname || "127.0.0.1";
5847
+ const port = Number(url.port || 6379);
5848
+ const commands = store.entries.map(
5849
+ ({ key, value }) => command("SET", key, typeof value === "string" ? value : JSON.stringify(value))
5850
+ );
5851
+ if (commands.length === 0) return;
5852
+ await new Promise((done, fail) => {
5853
+ const socket = createConnection({ host, port });
5854
+ let replies = "";
5855
+ const failWith = (reason) => {
5856
+ socket.destroy();
5857
+ fail(
5858
+ new Error(
5859
+ `could not write the session to ${store.url}: ${reason}. Start the store the front's server reads (in the monorepo, \`pnpm redis:start\`), then run again.`
5860
+ )
5861
+ );
5862
+ };
5863
+ socket.setTimeout(timeoutMs, () => failWith(`no answer in ${timeoutMs} ms`));
5864
+ socket.on("error", (error) => failWith(error.message));
5865
+ socket.on("connect", () => socket.write(commands.join("")));
5866
+ socket.on("data", (chunk) => {
5867
+ replies += chunk.toString("utf8");
5868
+ const lines = replies.split("\r\n").filter(Boolean);
5869
+ const refused = lines.find((line) => line.startsWith("-"));
5870
+ if (refused) return failWith(refused.slice(1));
5871
+ if (lines.length >= commands.length) {
5872
+ socket.end();
5873
+ done();
5874
+ }
5875
+ });
5876
+ });
5877
+ }
5878
+
5879
+ // src/roles/runtime-analysis/serve/serve.ts
5733
5880
  var DEFAULT_PORTS = {
5734
5881
  mock: 4199,
5735
5882
  base: { port: 4101, appPort: 4111 },
@@ -5745,7 +5892,7 @@ function buildEnv(config, at) {
5745
5892
  );
5746
5893
  }
5747
5894
  function shippedScript(name) {
5748
- return join30(packageRoot(), "dist", "roles", "runtime-analysis", `${name}.js`);
5895
+ return join31(packageRoot(), "dist", "roles", "runtime-analysis", `${name}.js`);
5749
5896
  }
5750
5897
  async function waitFor(url) {
5751
5898
  for (let attempt = 0; attempt < 120; attempt++) {
@@ -5762,7 +5909,7 @@ async function serve(options) {
5762
5909
  mkdirSync6(logs, { recursive: true });
5763
5910
  const children = [];
5764
5911
  const start = (name, args, cwd = process.cwd(), env = {}) => {
5765
- const log = openSync(join30(logs, `${name}.log`), "w");
5912
+ const log = openSync(join31(logs, `${name}.log`), "w");
5766
5913
  const child = spawn("node", args, {
5767
5914
  cwd,
5768
5915
  env: { ...process.env, ...env },
@@ -5772,6 +5919,9 @@ async function serve(options) {
5772
5919
  if (detached) child.unref();
5773
5920
  children.push(child);
5774
5921
  };
5922
+ const session = readSession(moduleDir);
5923
+ if (session?.store !== void 0) await seedStore(session.store);
5924
+ const serverEnv = readServerEnv(moduleDir);
5775
5925
  start("mock-api", [
5776
5926
  shippedScript("mock-api"),
5777
5927
  "--module",
@@ -5782,6 +5932,8 @@ async function serve(options) {
5782
5932
  for (const [side, dir] of Object.entries(builds)) {
5783
5933
  const { port, appPort } = ports[side];
5784
5934
  start(`app-${side}`, [config.build.server], resolve6(dir), {
5935
+ ...serverEnvFor(serverEnv, origin(side, ports)),
5936
+ // Last, so a `server.env` cannot move the server off the port its gateway forwards to.
5785
5937
  HOST: "127.0.0.1",
5786
5938
  PORT: String(appPort)
5787
5939
  });
@@ -5796,7 +5948,7 @@ async function serve(options) {
5796
5948
  "--mock-port",
5797
5949
  String(ports.mock),
5798
5950
  "--log",
5799
- join30(logs, `requests-${side}.jsonl`)
5951
+ join31(logs, `requests-${side}.jsonl`)
5800
5952
  ]);
5801
5953
  }
5802
5954
  const stop = () => {
@@ -5811,7 +5963,7 @@ async function serve(options) {
5811
5963
  stop();
5812
5964
  for (const file of readdirSync5(logs).filter((name) => name.endsWith(".log")))
5813
5965
  process.stderr.write(`--- ${file}
5814
- ${readFileSync22(join30(logs, file), "utf8")}
5966
+ ${readFileSync23(join31(logs, file), "utf8")}
5815
5967
  `);
5816
5968
  throw error;
5817
5969
  }
@@ -5943,15 +6095,15 @@ function verdictMarkdown(verdict, source, throttling) {
5943
6095
  }
5944
6096
 
5945
6097
  // src/roles/runtime-analysis/verdict/report.ts
5946
- import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync23 } from "node:fs";
5947
- import { join as join31 } from "node:path";
6098
+ import { existsSync as existsSync23, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "node:fs";
6099
+ import { join as join32 } from "node:path";
5948
6100
  var MARKER = "<!-- sentinel-runtime-analysis -->";
5949
6101
  var TITLE = "Frontend Core Web Vitals";
5950
6102
  var minutes = (seconds) => `${Math.floor(seconds / 60)}m${String(Math.round(seconds % 60)).padStart(2, "0")}s`;
5951
6103
  function readNumber(dir, file) {
5952
6104
  if (dir === void 0) return null;
5953
- const path2 = join31(dir, file);
5954
- return existsSync22(path2) ? Number(readFileSync23(path2, "utf8")) : null;
6105
+ const path2 = join32(dir, file);
6106
+ return existsSync23(path2) ? Number(readFileSync24(path2, "utf8")) : null;
5955
6107
  }
5956
6108
  var folded = (summary2, lines) => lines.length ? [`<details><summary>${summary2}</summary>`, "", ...lines, "", "</details>", ""] : [];
5957
6109
  function headline2(input) {
@@ -6011,10 +6163,10 @@ function proofTable(runs) {
6011
6163
  return lines;
6012
6164
  }
6013
6165
  function evidenceOf(evidence) {
6014
- const dirs = existsSync22(evidence) ? readdirSync6(evidence).map((dir) => join31(evidence, dir)) : [];
6166
+ const dirs = existsSync23(evidence) ? readdirSync6(evidence).map((dir) => join32(evidence, dir)) : [];
6015
6167
  const settingsOf = (dir) => {
6016
- const file = join31(dir, "settings.json");
6017
- const text = existsSync22(file) ? readFileSync23(file, "utf8") : "";
6168
+ const file = join32(dir, "settings.json");
6169
+ const text = existsSync23(file) ? readFileSync24(file, "utf8") : "";
6018
6170
  return text ? JSON.parse(text) : null;
6019
6171
  };
6020
6172
  const builtFronts = [
@@ -6023,7 +6175,7 @@ function evidenceOf(evidence) {
6023
6175
  )
6024
6176
  ];
6025
6177
  const buildEvidence = (front) => dirs.find(
6026
- (dir) => settingsOf(dir)?.front === front && existsSync22(join31(dir, "build-base-seconds"))
6178
+ (dir) => settingsOf(dir)?.front === front && existsSync23(join32(dir, "build-base-seconds"))
6027
6179
  );
6028
6180
  return { dirs, settingsOf, builtFronts, buildEvidence };
6029
6181
  }
@@ -6208,13 +6360,13 @@ function noticeMarkdown(input) {
6208
6360
  }
6209
6361
 
6210
6362
  // src/roles/runtime-analysis/verdict/runs.ts
6211
- import { existsSync as existsSync23, readdirSync as readdirSync7, readFileSync as readFileSync24, statSync as statSync6 } from "node:fs";
6212
- import { join as join32 } from "node:path";
6213
- var read = (file) => JSON.parse(readFileSync24(file, "utf8"));
6363
+ import { existsSync as existsSync24, readdirSync as readdirSync7, readFileSync as readFileSync25, statSync as statSync6 } from "node:fs";
6364
+ import { join as join33 } from "node:path";
6365
+ var read = (file) => JSON.parse(readFileSync25(file, "utf8"));
6214
6366
  function readRuns(path2) {
6215
- if (!existsSync23(path2)) return [];
6367
+ if (!existsSync24(path2)) return [];
6216
6368
  if (!statSync6(path2).isDirectory()) return read(path2);
6217
- return readdirSync7(path2).map((dir) => join32(path2, dir, "runs.json")).filter((file) => existsSync23(file)).flatMap(read);
6369
+ return readdirSync7(path2).map((dir) => join33(path2, dir, "runs.json")).filter((file) => existsSync24(file)).flatMap(read);
6218
6370
  }
6219
6371
 
6220
6372
  // src/roles/runtime-analysis/adapters/lighthouse/runtime-analysis.adapter.ts
@@ -6258,7 +6410,7 @@ var RuntimeAnalysisAdapter = class extends BaseAdapter {
6258
6410
  const kind = framework(context2.cwd);
6259
6411
  if (kind !== "React")
6260
6412
  return { operations: [], skipped: `${kind} is out of scope: React frontends only.` };
6261
- const hasConfig = existsSync24(join33(context2.cwd, RUNTIME_CONFIG_FILE));
6413
+ const hasConfig = existsSync25(join34(context2.cwd, RUNTIME_CONFIG_FILE));
6262
6414
  return {
6263
6415
  operations: [
6264
6416
  // A re-init never rewrites a front's config: its screens and mocks are its own.
@@ -6301,7 +6453,7 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6301
6453
  const parsed = parsePhase(ctx.toolArgs);
6302
6454
  if (parsed.phase === "invalid") return this.fail(parsed.reason);
6303
6455
  if (parsed.phase === "detect") return this.detect(ctx, parsed.values);
6304
- if (!existsSync24(join33(ctx.cwd, RUNTIME_CONFIG_FILE))) {
6456
+ if (!existsSync25(join34(ctx.cwd, RUNTIME_CONFIG_FILE))) {
6305
6457
  this.say(`not adopted here; \`sentinel --init --runtime-analysis\` sets it up.`);
6306
6458
  return { ok: true, code: 0, metrics: { adopted: false } };
6307
6459
  }
@@ -6362,9 +6514,9 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6362
6514
  front.invalid = true;
6363
6515
  detection.invalid = { name: ctx.module, errors: checked.problems };
6364
6516
  }
6365
- const out = join33(ctx.cwd, REPORT_DIR3);
6517
+ const out = join34(ctx.cwd, REPORT_DIR3);
6366
6518
  mkdirSync7(out, { recursive: true });
6367
- writeFileSync8(join33(out, "detect.json"), `${JSON.stringify(detection, null, 1)}
6519
+ writeFileSync8(join34(out, "detect.json"), `${JSON.stringify(detection, null, 1)}
6368
6520
  `);
6369
6521
  const measured = detection.screens.filter((screen) => screen.measured).map((screen) => screen.id);
6370
6522
  process.stdout.write(`screens=${measured.join(",")}
@@ -6379,8 +6531,10 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6379
6531
  const unknown = wanted.filter((id) => !config.screens.some((screen) => screen.id === id));
6380
6532
  if (unknown.length)
6381
6533
  return this.fail(`no screen ${unknown.join(", ")} in ${RUNTIME_CONFIG_FILE}`);
6382
- const out = resolve7(ctx.cwd, String(values.out ?? join33(REPORT_DIR3, "evidence")));
6383
- const logs = join33(out, "logs");
6534
+ const out = resolve7(ctx.cwd, String(values.out ?? join34(REPORT_DIR3, "evidence")));
6535
+ const logs = join34(out, "logs");
6536
+ const session = this.session(ctx.cwd);
6537
+ if (typeof session === "string") return this.fail(session);
6384
6538
  const served = await serve({
6385
6539
  config,
6386
6540
  moduleDir: ctx.cwd,
@@ -6397,21 +6551,33 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6397
6551
  ready: config.ready,
6398
6552
  screens: config.screens.filter((screen) => wanted.includes(screen.id)),
6399
6553
  locale: config.locale ?? DEFAULT_LOCALE,
6400
- base: { origin: origin("base"), log: join33(logs, "requests-base.jsonl") },
6401
- head: { origin: origin("head"), log: join33(logs, "requests-head.jsonl") },
6554
+ base: { origin: origin("base"), log: join34(logs, "requests-base.jsonl") },
6555
+ head: { origin: origin("head"), log: join34(logs, "requests-head.jsonl") },
6402
6556
  runs: Number(values.runs),
6403
6557
  out,
6404
- throttling: values.throttling
6558
+ throttling: values.throttling,
6559
+ cookies: session?.cookies
6405
6560
  });
6406
6561
  return { ok: result.ok, code: result.ok ? 0 : 1, metrics: { flows: result.runs.length } };
6407
6562
  } finally {
6408
6563
  served.stop();
6409
6564
  }
6410
6565
  }
6566
+ /**
6567
+ * The front's `runtime-analysis/session.json`, read before anything is built or served: a file
6568
+ * that is wrong is the reason the run stops, said in its own words (a string), not a crash later.
6569
+ */
6570
+ session(cwd) {
6571
+ try {
6572
+ return readSession(cwd);
6573
+ } catch (error) {
6574
+ return error instanceof Error ? error.message : String(error);
6575
+ }
6576
+ }
6411
6577
  /** Judge every measure job's evidence and write the comment, the verdict and the budget. */
6412
6578
  async verdict(ctx, values) {
6413
6579
  const detections = values.detect === void 0 ? [] : readDetections(resolve7(ctx.cwd, String(values.detect)));
6414
- const readJson = (file) => typeof file === "string" && existsSync24(resolve7(ctx.cwd, file)) ? JSON.parse(readFileSync25(resolve7(ctx.cwd, file), "utf8")) : void 0;
6580
+ const readJson = (file) => typeof file === "string" && existsSync25(resolve7(ctx.cwd, file)) ? JSON.parse(readFileSync26(resolve7(ctx.cwd, file), "utf8")) : void 0;
6415
6581
  const detect = detectionMarkdown({
6416
6582
  fronts: detections.map((detection) => detection.front),
6417
6583
  screensOf: Object.fromEntries(
@@ -6434,7 +6600,7 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6434
6600
  invalid: detections.some((detection) => detection.invalid),
6435
6601
  ...runUrl === void 0 ? {} : { runUrl }
6436
6602
  });
6437
- writeFileSync8(join33(out, "runtime-analysis.md"), `${pending}
6603
+ writeFileSync8(join34(out, "runtime-analysis.md"), `${pending}
6438
6604
  `);
6439
6605
  return { ok: true, code: 0, metrics: { pending: true } };
6440
6606
  }
@@ -6471,15 +6637,15 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6471
6637
  } : {}
6472
6638
  };
6473
6639
  const comment = reportMarkdown(input);
6474
- writeFileSync8(join33(out, "runtime-analysis.md"), `${comment}
6640
+ writeFileSync8(join34(out, "runtime-analysis.md"), `${comment}
6475
6641
  `);
6476
6642
  const full = reportMarkdown(input, Number.POSITIVE_INFINITY);
6477
- if (full !== comment) writeFileSync8(join33(out, FULL_REPORT), `${full}
6643
+ if (full !== comment) writeFileSync8(join34(out, FULL_REPORT), `${full}
6478
6644
  `);
6479
6645
  const state = typeof values.state === "string" ? values.state : "open";
6480
6646
  if (verdict.failed && state !== "open")
6481
6647
  writeFileSync8(
6482
- join33(out, "notice.md"),
6648
+ join34(out, "notice.md"),
6483
6649
  `${noticeMarkdown({
6484
6650
  rows: verdict.rows,
6485
6651
  state,
@@ -6489,8 +6655,8 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6489
6655
  })}
6490
6656
  `
6491
6657
  );
6492
- writeFileSync8(join33(out, "verdict.json"), JSON.stringify(verdict, null, 2));
6493
- writeFileSync8(join33(out, "budget.md"), `${budget}
6658
+ writeFileSync8(join34(out, "verdict.json"), JSON.stringify(verdict, null, 2));
6659
+ writeFileSync8(join34(out, "budget.md"), `${budget}
6494
6660
  `);
6495
6661
  process.stdout.write(`${budget}
6496
6662
  `);
@@ -6507,8 +6673,10 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6507
6673
  async local(ctx, config, runs, throttling) {
6508
6674
  const chromePath = findChrome();
6509
6675
  if (!chromePath) return this.fail("no Google Chrome found: set CHROME_PATH");
6510
- const out = join33(ctx.cwd, REPORT_DIR3);
6511
- const build = join33(out, "build");
6676
+ const session = this.session(ctx.cwd);
6677
+ if (typeof session === "string") return this.fail(session);
6678
+ const out = join34(ctx.cwd, REPORT_DIR3);
6679
+ const build = join34(out, "build");
6512
6680
  this.say(
6513
6681
  `building ${ctx.module} with its runtime-analysis variables (placeholders, no secret)...`
6514
6682
  );
@@ -6519,10 +6687,10 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6519
6687
  });
6520
6688
  if (built.status !== 0) return this.fail(`the build failed (exit ${built.status})`);
6521
6689
  rmSync4(out, { recursive: true, force: true });
6522
- cpSync2(join33(ctx.cwd, config.build.output), build, { recursive: true });
6523
- const evidence = join33(out, "evidence", ctx.module);
6524
- const logs = join33(evidence, "logs");
6525
- const log = join33(logs, "requests-base.jsonl");
6690
+ cpSync2(join34(ctx.cwd, config.build.output), build, { recursive: true });
6691
+ const evidence = join34(out, "evidence", ctx.module);
6692
+ const logs = join34(evidence, "logs");
6693
+ const log = join34(logs, "requests-base.jsonl");
6526
6694
  const served = await serve({ config, moduleDir: ctx.cwd, builds: { base: build }, logs });
6527
6695
  try {
6528
6696
  await measure({
@@ -6535,12 +6703,13 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6535
6703
  head: { origin: origin("base"), log },
6536
6704
  runs: Number(runs),
6537
6705
  out: evidence,
6538
- throttling
6706
+ throttling,
6707
+ cookies: session?.cookies
6539
6708
  });
6540
6709
  } finally {
6541
6710
  served.stop();
6542
6711
  }
6543
- return this.verdict(ctx, { evidence: join33(out, "evidence"), throttling, out });
6712
+ return this.verdict(ctx, { evidence: join34(out, "evidence"), throttling, out });
6544
6713
  }
6545
6714
  /**
6546
6715
  * `--report`: what a machine reads about this front, WITHOUT measuring. A measure builds, serves
@@ -6548,7 +6717,7 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6548
6717
  * whether the front is adopted, and whether its config can be measured.
6549
6718
  */
6550
6719
  async report(ctx) {
6551
- if (!existsSync24(join33(ctx.cwd, RUNTIME_CONFIG_FILE)))
6720
+ if (!existsSync25(join34(ctx.cwd, RUNTIME_CONFIG_FILE)))
6552
6721
  return { ok: true, code: 0, metrics: { adopted: false } };
6553
6722
  const checked = await this.configOf(ctx.cwd);
6554
6723
  return "config" in checked ? {
@@ -6565,29 +6734,29 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6565
6734
  screens: checked.config.screens.map((screen) => screen.id)
6566
6735
  } : {
6567
6736
  runner: this.runner,
6568
- configFile: existsSync24(join33(ctx.cwd, RUNTIME_CONFIG_FILE)) ? RUNTIME_CONFIG_FILE : null,
6737
+ configFile: existsSync25(join34(ctx.cwd, RUNTIME_CONFIG_FILE)) ? RUNTIME_CONFIG_FILE : null,
6569
6738
  unreadable: checked.reason
6570
6739
  };
6571
6740
  }
6572
6741
  /** Adopted is "the front has its config", read from disk: a workspace sweep executes nothing. */
6573
6742
  async status(ctx) {
6574
- const adopted = existsSync24(join33(ctx.cwd, RUNTIME_CONFIG_FILE));
6743
+ const adopted = existsSync25(join34(ctx.cwd, RUNTIME_CONFIG_FILE));
6575
6744
  return { adopted, preset: adopted ? ctx.preset : null, conformant: adopted, drift: [] };
6576
6745
  }
6577
6746
  };
6578
6747
  function readAffected(file) {
6579
- if (file === void 0 || !existsSync24(file)) return [];
6580
- const text = readFileSync25(file, "utf8").trim();
6748
+ if (file === void 0 || !existsSync25(file)) return [];
6749
+ const text = readFileSync26(file, "utf8").trim();
6581
6750
  if (text.startsWith("[")) return JSON.parse(text);
6582
6751
  return text.split(/\s+/).filter(Boolean);
6583
6752
  }
6584
6753
  function readDetections(dir) {
6585
- if (!existsSync24(dir)) return [];
6754
+ if (!existsSync25(dir)) return [];
6586
6755
  const files = [
6587
- join33(dir, "detect.json"),
6588
- ...readdirSync8(dir).map((entry) => join33(dir, entry, "detect.json"))
6756
+ join34(dir, "detect.json"),
6757
+ ...readdirSync8(dir).map((entry) => join34(dir, entry, "detect.json"))
6589
6758
  ];
6590
- return files.filter((file) => existsSync24(file)).map((file) => JSON.parse(readFileSync25(file, "utf8")));
6759
+ return files.filter((file) => existsSync25(file)).map((file) => JSON.parse(readFileSync26(file, "utf8")));
6591
6760
  }
6592
6761
 
6593
6762
  // src/roles/runtime-analysis/register.ts
@@ -6598,8 +6767,8 @@ function registerRuntimeAnalysis() {
6598
6767
 
6599
6768
  // src/roles/static-analysis/adapters/jscpd/jscpd.adapter.ts
6600
6769
  import { spawnSync as spawnSync8 } from "node:child_process";
6601
- import { existsSync as existsSync29, mkdirSync as mkdirSync8, readFileSync as readFileSync30, unlinkSync as unlinkSync2, writeFileSync as writeFileSync11 } from "node:fs";
6602
- import { join as join42 } from "node:path";
6770
+ import { existsSync as existsSync30, mkdirSync as mkdirSync8, readFileSync as readFileSync31, unlinkSync as unlinkSync2, writeFileSync as writeFileSync11 } from "node:fs";
6771
+ import { join as join43 } from "node:path";
6603
6772
  import { globSync as globSync5 } from "tinyglobby";
6604
6773
 
6605
6774
  // src/roles/static-analysis/bundle/budgets.ts
@@ -6628,32 +6797,32 @@ function bandFor(valueKb, referenceKb) {
6628
6797
  }
6629
6798
 
6630
6799
  // src/roles/static-analysis/bundle/scan.ts
6631
- import { existsSync as existsSync26, readFileSync as readFileSync27 } from "node:fs";
6632
- import { basename, join as join35 } from "node:path";
6800
+ import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
6801
+ import { basename, join as join36 } from "node:path";
6633
6802
  import { pathToFileURL as pathToFileURL3 } from "node:url";
6634
6803
  import { gzipSync } from "node:zlib";
6635
6804
  import { globSync as globSync2 } from "tinyglobby";
6636
6805
 
6637
6806
  // src/roles/static-analysis/bundle/find-build.ts
6638
- import { existsSync as existsSync25, readFileSync as readFileSync26, statSync as statSync7 } from "node:fs";
6639
- import { join as join34 } from "node:path";
6807
+ import { existsSync as existsSync26, readFileSync as readFileSync27, statSync as statSync7 } from "node:fs";
6808
+ import { join as join35 } from "node:path";
6640
6809
  import { globSync } from "tinyglobby";
6641
6810
  var MANIFEST_GLOB = "server/_tanstack-start-manifest*.mjs";
6642
6811
  function candidateDirs(cwd) {
6643
6812
  const declared = readProjectPackageJson(cwd).nx?.targets?.build?.["outputs"];
6644
- const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) => join34(cwd, token.replace(/^\{projectRoot\}\//, ""))) : [];
6645
- return [...fromDeclaration, join34(cwd, ".output"), join34(cwd, "dist"), join34(cwd, "build")];
6813
+ const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) => join35(cwd, token.replace(/^\{projectRoot\}\//, ""))) : [];
6814
+ return [...fromDeclaration, join35(cwd, ".output"), join35(cwd, "dist"), join35(cwd, "build")];
6646
6815
  }
6647
6816
  function findBuildOutput(cwd) {
6648
6817
  const lookedIn = [];
6649
6818
  for (const dir of candidateDirs(cwd)) {
6650
6819
  lookedIn.push(dir);
6651
- if (!existsSync25(dir)) continue;
6820
+ if (!existsSync26(dir)) continue;
6652
6821
  const found = globSync(MANIFEST_GLOB, { cwd: dir, absolute: true, dot: false });
6653
6822
  if (found.length === 0) continue;
6654
6823
  const manifestPath = found[0];
6655
- const publicDir = join34(dir, "public");
6656
- if (!existsSync25(publicDir)) continue;
6824
+ const publicDir = join35(dir, "public");
6825
+ if (!existsSync26(publicDir)) continue;
6657
6826
  return { manifestPath, publicDir, ...dateOf(dir, manifestPath) };
6658
6827
  }
6659
6828
  const pkg = readProjectPackageJson(cwd);
@@ -6675,10 +6844,10 @@ function findBuildOutput(cwd) {
6675
6844
  };
6676
6845
  }
6677
6846
  function dateOf(dir, manifestPath) {
6678
- const record = join34(dir, "nitro.json");
6679
- if (existsSync25(record)) {
6847
+ const record = join35(dir, "nitro.json");
6848
+ if (existsSync26(record)) {
6680
6849
  try {
6681
- const parsed = JSON.parse(readFileSync26(record, "utf8"));
6850
+ const parsed = JSON.parse(readFileSync27(record, "utf8"));
6682
6851
  if (typeof parsed.date === "string") {
6683
6852
  const date = new Date(parsed.date);
6684
6853
  if (!Number.isNaN(date.getTime())) return { builtAt: date, builtAtFrom: "build record" };
@@ -6704,10 +6873,10 @@ function kindOf(path2) {
6704
6873
  return "other";
6705
6874
  }
6706
6875
  function resolveAnnounced(publicDir, announced) {
6707
- const direct = join35(publicDir, announced);
6708
- if (existsSync26(direct)) return direct;
6709
- const stripped = join35(publicDir, announced.replace(/^\/[^/]+\//, "/"));
6710
- return existsSync26(stripped) ? stripped : void 0;
6876
+ const direct = join36(publicDir, announced);
6877
+ if (existsSync27(direct)) return direct;
6878
+ const stripped = join36(publicDir, announced.replace(/^\/[^/]+\//, "/"));
6879
+ return existsSync27(stripped) ? stripped : void 0;
6711
6880
  }
6712
6881
  function emptyWeight() {
6713
6882
  return { transfer: 0, parsed: 0, files: 0 };
@@ -6743,7 +6912,7 @@ async function scanBundle(cwd) {
6743
6912
  unresolved.push(announced);
6744
6913
  measured.set(announced, void 0);
6745
6914
  } else {
6746
- const buffer = readFileSync27(path2);
6915
+ const buffer = readFileSync28(path2);
6747
6916
  measured.set(announced, {
6748
6917
  parsed: buffer.length,
6749
6918
  transfer: gzipSync(buffer, { level: 9 }).length
@@ -6830,7 +6999,7 @@ function scanDynamicLayer(publicDir, references) {
6830
6999
  })) {
6831
7000
  const name = basename(path2);
6832
7001
  if (referenced.has(name)) continue;
6833
- const buffer = readFileSync27(path2);
7002
+ const buffer = readFileSync28(path2);
6834
7003
  const size = { parsed: buffer.length, transfer: gzipSync(buffer, { level: 9 }).length };
6835
7004
  add(all2, size);
6836
7005
  const group = groupOf(name);
@@ -6858,24 +7027,24 @@ function scanDynamicLayer(publicDir, references) {
6858
7027
  }
6859
7028
 
6860
7029
  // src/roles/static-analysis/sources.ts
6861
- import { readFileSync as readFileSync28 } from "node:fs";
6862
- import { join as join38 } from "node:path";
7030
+ import { readFileSync as readFileSync29 } from "node:fs";
7031
+ import { join as join39 } from "node:path";
6863
7032
  import { parseSync as parseSync3 } from "oxc-parser";
6864
7033
  import { globSync as globSync3 } from "tinyglobby";
6865
7034
 
6866
7035
  // src/roles/static-analysis/adapters/jscpd/tool-config.ts
6867
- import { existsSync as existsSync28, mkdtempSync, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "node:fs";
7036
+ import { existsSync as existsSync29, mkdtempSync, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "node:fs";
6868
7037
  import { tmpdir } from "node:os";
6869
- import { join as join37 } from "node:path";
7038
+ import { join as join38 } from "node:path";
6870
7039
 
6871
7040
  // src/roles/static-analysis/configs/resolve.ts
6872
- import { existsSync as existsSync27 } from "node:fs";
6873
- import { join as join36 } from "node:path";
7041
+ import { existsSync as existsSync28 } from "node:fs";
7042
+ import { join as join37 } from "node:path";
6874
7043
  import { pathToFileURL as pathToFileURL4 } from "node:url";
6875
7044
  var STATIC_CONFIG_FILE = "static-analysis.config.mjs";
6876
7045
  async function loadStaticConfig(cwd) {
6877
- const path2 = join36(cwd, STATIC_CONFIG_FILE);
6878
- if (!existsSync27(path2)) {
7046
+ const path2 = join37(cwd, STATIC_CONFIG_FILE);
7047
+ if (!existsSync28(path2)) {
6879
7048
  return { config: defineStaticAnalysis(), from: null, unreadable: null };
6880
7049
  }
6881
7050
  try {
@@ -6921,7 +7090,7 @@ function exclusions(config, scope = "tests") {
6921
7090
  return [.../* @__PURE__ */ new Set([...config.ignore, ...OWN_ARTEFACTS, ...tests])];
6922
7091
  }
6923
7092
  function measuredRoots(cwd) {
6924
- return existsSync28(join37(cwd, "src")) ? ["src"] : ["."];
7093
+ return existsSync29(join38(cwd, "src")) ? ["src"] : ["."];
6925
7094
  }
6926
7095
  function fileSettings(config, scope, extraEntries = []) {
6927
7096
  return {
@@ -6951,8 +7120,8 @@ function fileSettings(config, scope, extraEntries = []) {
6951
7120
  };
6952
7121
  }
6953
7122
  function duplicationRun(config, paths, scope) {
6954
- const dir = mkdtempSync(join37(tmpdir(), "sentinel-static-"));
6955
- const configPath = join37(dir, "jscpd.json");
7123
+ const dir = mkdtempSync(join38(tmpdir(), "sentinel-static-"));
7124
+ const configPath = join38(dir, "jscpd.json");
6956
7125
  writeFileSync9(configPath, `${JSON.stringify(fileSettings(config, scope), null, 2)}
6957
7126
  `, "utf8");
6958
7127
  const args = [
@@ -6978,8 +7147,8 @@ function duplicationRun(config, paths, scope) {
6978
7147
  return { args, rawReportDir: dir, dispose: () => rmSync5(dir, { force: true, recursive: true }) };
6979
7148
  }
6980
7149
  function deadCodeRun(config, paths, extraEntries = []) {
6981
- const dir = mkdtempSync(join37(tmpdir(), "sentinel-static-"));
6982
- const configPath = join37(dir, "jscpd.json");
7150
+ const dir = mkdtempSync(join38(tmpdir(), "sentinel-static-"));
7151
+ const configPath = join38(dir, "jscpd.json");
6983
7152
  writeFileSync9(
6984
7153
  configPath,
6985
7154
  `${JSON.stringify(fileSettings(config, "dead-code", extraEntries), null, 2)}
@@ -7031,7 +7200,7 @@ function readParsed(cwd, files, passes) {
7031
7200
  function parsedSource(cwd, path2) {
7032
7201
  let text;
7033
7202
  try {
7034
- text = readFileSync28(join38(cwd, path2), "utf8");
7203
+ text = readFileSync29(join39(cwd, path2), "utf8");
7035
7204
  } catch {
7036
7205
  return void 0;
7037
7206
  }
@@ -7218,13 +7387,13 @@ function unreadableNote(coverage) {
7218
7387
  }
7219
7388
 
7220
7389
  // src/roles/static-analysis/excerpt.ts
7221
- import { readFileSync as readFileSync29 } from "node:fs";
7222
- import { join as join40 } from "node:path";
7390
+ import { readFileSync as readFileSync30 } from "node:fs";
7391
+ import { join as join41 } from "node:path";
7223
7392
 
7224
7393
  // src/roles/static-analysis/maintainability/size-rules.ts
7225
7394
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync10 } from "node:fs";
7226
7395
  import { tmpdir as tmpdir2 } from "node:os";
7227
- import { join as join39 } from "node:path";
7396
+ import { join as join40 } from "node:path";
7228
7397
  var GAUGE_THRESHOLDS = {
7229
7398
  // McCabe 1976 says 10, our p90 says 11. The only indicator where two independent candidates agree
7230
7399
  // within one unit, and 94.8% of our functions already sit in the 1-10 band SEI calls low risk.
@@ -7253,7 +7422,7 @@ var GAUGE_THRESHOLDS = {
7253
7422
  "cognitive-complexity": 7
7254
7423
  };
7255
7424
  var COGNITIVE = "cognitive-complexity";
7256
- var cognitivePlugin = () => join39(ownPackageDir(), "plugins", "sonar-cognitive.js");
7425
+ var cognitivePlugin = () => join40(ownPackageDir(), "plugins", "sonar-cognitive.js");
7257
7426
  var CATEGORIES = [
7258
7427
  "correctness",
7259
7428
  "suspicious",
@@ -7285,8 +7454,8 @@ function sizeRulesConfig() {
7285
7454
  };
7286
7455
  }
7287
7456
  function sizeRulesRun(paths, ignore) {
7288
- const dir = mkdtempSync2(join39(tmpdir2(), "sentinel-size-"));
7289
- const configPath = join39(dir, "oxlintrc.json");
7457
+ const dir = mkdtempSync2(join40(tmpdir2(), "sentinel-size-"));
7458
+ const configPath = join40(dir, "oxlintrc.json");
7290
7459
  writeFileSync10(configPath, `${JSON.stringify(sizeRulesConfig(), null, 2)}
7291
7460
  `, "utf8");
7292
7461
  return {
@@ -8744,7 +8913,7 @@ function linesOf(cache, cwd, relative7) {
8744
8913
  if (cache.has(relative7)) return cache.get(relative7);
8745
8914
  let lines;
8746
8915
  try {
8747
- lines = readFileSync29(join40(cwd, relative7), "utf8").split("\n");
8916
+ lines = readFileSync30(join41(cwd, relative7), "utf8").split("\n");
8748
8917
  } catch {
8749
8918
  lines = void 0;
8750
8919
  }
@@ -8976,7 +9145,7 @@ var SCRIPT2 = `(function(){
8976
9145
  })();`;
8977
9146
 
8978
9147
  // src/roles/static-analysis/graph/imports.ts
8979
- import { dirname as dirname5, join as join41 } from "node:path";
9148
+ import { dirname as dirname5, join as join42 } from "node:path";
8980
9149
  var TS_BEHIND_JS = {
8981
9150
  ".js": [".ts", ".tsx"],
8982
9151
  ".mjs": [".mts"],
@@ -9029,7 +9198,7 @@ function specifiersOf(program) {
9029
9198
  }
9030
9199
  function resolveSpecifier2(from, specifier, known) {
9031
9200
  if (!specifier.startsWith(".")) return void 0;
9032
- const base = join41(dirname5(from), specifier);
9201
+ const base = join42(dirname5(from), specifier);
9033
9202
  if (known.has(base)) return base;
9034
9203
  for (const extension of RESOLVABLE_EXTENSIONS) {
9035
9204
  if (known.has(base + extension)) return base + extension;
@@ -9040,7 +9209,7 @@ function resolveSpecifier2(from, specifier, known) {
9040
9209
  if (known.has(swapped)) return swapped;
9041
9210
  }
9042
9211
  for (const extension of RESOLVABLE_EXTENSIONS) {
9043
- const index = join41(base, `index${extension}`);
9212
+ const index = join42(base, `index${extension}`);
9044
9213
  if (known.has(index)) return index;
9045
9214
  }
9046
9215
  return void 0;
@@ -9226,7 +9395,7 @@ var JscpdAdapter = class extends BaseAdapter {
9226
9395
  operations: [
9227
9396
  // `write` and not `merge-json`: this file is code, and the engine's in-place merge is for
9228
9397
  // JSON. A re-init therefore RESTORES the stub, so an existing one is left alone below.
9229
- ...existsSync29(join42(context2.cwd, STATIC_CONFIG_FILE)) ? [] : [{ kind: "write", path: STATIC_CONFIG_FILE, contents: configStub2() }],
9398
+ ...existsSync30(join43(context2.cwd, STATIC_CONFIG_FILE)) ? [] : [{ kind: "write", path: STATIC_CONFIG_FILE, contents: configStub2() }],
9230
9399
  manifestOperation(context2.cwd, scripts()),
9231
9400
  ...nxTargetOperations({ cwd: context2.cwd, targets: targets() })
9232
9401
  // The report directory is ignored ONCE at the workspace root, by `--init`'s workspace prep,
@@ -9476,7 +9645,7 @@ var JscpdAdapter = class extends BaseAdapter {
9476
9645
  const declared = moduleScripts(ctx.cwd);
9477
9646
  const missing = Object.keys(scripts()).filter((name) => !(name in declared));
9478
9647
  const adopted = missing.length < Object.keys(scripts()).length;
9479
- const hasConfig = existsSync29(join42(ctx.cwd, STATIC_CONFIG_FILE));
9648
+ const hasConfig = existsSync30(join43(ctx.cwd, STATIC_CONFIG_FILE));
9480
9649
  return {
9481
9650
  adopted,
9482
9651
  preset: adopted ? ctx.preset : null,
@@ -9568,15 +9737,15 @@ function runDeadCode(jscpd, config, paths, cwd, extraEntries = []) {
9568
9737
  try {
9569
9738
  const ran = runTool(jscpd, args, cwd, "dead-code");
9570
9739
  if (ran.kind !== "ran") return ran;
9571
- const path2 = join42(rawReportDir, RAW_REPORT["dead-code"]);
9572
- if (!existsSync29(path2)) {
9740
+ const path2 = join43(rawReportDir, RAW_REPORT["dead-code"]);
9741
+ if (!existsSync30(path2)) {
9573
9742
  process.stderr.write(
9574
9743
  `sentinel static-analysis(jscpd): the dead-code pass wrote no ${RAW_REPORT["dead-code"]}
9575
9744
  `
9576
9745
  );
9577
9746
  return { kind: "failed", code: 1 };
9578
9747
  }
9579
- const parsed = safeParseDeadCode(readFileSync30(path2, "utf8"));
9748
+ const parsed = safeParseDeadCode(readFileSync31(path2, "utf8"));
9580
9749
  const statistics = parsed?.statistics;
9581
9750
  if (!statistics) {
9582
9751
  process.stderr.write(
@@ -9599,11 +9768,11 @@ function runDeadCode(jscpd, config, paths, cwd, extraEntries = []) {
9599
9768
  }
9600
9769
  }
9601
9770
  function moduleRelative(name, roots, cwd) {
9602
- if (existsSync29(join42(cwd, name))) return name;
9771
+ if (existsSync30(join43(cwd, name))) return name;
9603
9772
  for (const root of roots) {
9604
9773
  if (root === ".") continue;
9605
9774
  const candidate = `${root}/${name}`;
9606
- if (existsSync29(join42(cwd, candidate))) return candidate;
9775
+ if (existsSync30(join43(cwd, candidate))) return candidate;
9607
9776
  }
9608
9777
  return name;
9609
9778
  }
@@ -9612,8 +9781,8 @@ function runDuplication(jscpd, config, paths, scope, cwd) {
9612
9781
  try {
9613
9782
  const ran = runTool(jscpd, args, cwd, scope);
9614
9783
  if (ran.kind !== "ran") return ran;
9615
- const path2 = join42(rawReportDir, RAW_REPORT.duplication);
9616
- const parsed = existsSync29(path2) ? safeParse(readFileSync30(path2, "utf8")) : void 0;
9784
+ const path2 = join43(rawReportDir, RAW_REPORT.duplication);
9785
+ const parsed = existsSync30(path2) ? safeParse(readFileSync31(path2, "utf8")) : void 0;
9617
9786
  const total = parsed?.statistics?.total;
9618
9787
  if (!total) {
9619
9788
  process.stderr.write(
@@ -9782,8 +9951,8 @@ function outsideOf(cwd) {
9782
9951
  function moduleRootsOf(workspaceRoot) {
9783
9952
  const roots = [];
9784
9953
  for (const area of ["apps", "libs"]) {
9785
- const base = join42(workspaceRoot, area);
9786
- if (!existsSync29(base)) continue;
9954
+ const base = join43(workspaceRoot, area);
9955
+ if (!existsSync30(base)) continue;
9787
9956
  for (const entry of globSync5([`${area}/**/package.json`, `${area}/**/project.json`], {
9788
9957
  cwd: workspaceRoot,
9789
9958
  ignore: ["**/node_modules/**"],
@@ -10125,8 +10294,8 @@ var PICTURE_FILE = `${TARGET}-graph.svg`;
10125
10294
  function clearStaleOutputs(cwd, keeping) {
10126
10295
  for (const name of [...Object.values(SHAPE_FILE2), PICTURE_FILE]) {
10127
10296
  if (keeping.has(name)) continue;
10128
- const path2 = join42(cwd, REPORT_DIR, name);
10129
- if (existsSync29(path2)) unlinkSync2(path2);
10297
+ const path2 = join43(cwd, REPORT_DIR, name);
10298
+ if (existsSync30(path2)) unlinkSync2(path2);
10130
10299
  }
10131
10300
  }
10132
10301
  function outputsOf(shapes, graph, coverage) {
@@ -10144,11 +10313,11 @@ function drawsPicture(graph, coverage) {
10144
10313
  async function emit(report, shape, cwd, graph, coverage) {
10145
10314
  if (shape === "console") return [];
10146
10315
  const detailed = shape === "markdown" ? report : withExcerpts(report, cwd);
10147
- mkdirSync8(join42(cwd, REPORT_DIR), { recursive: true });
10316
+ mkdirSync8(join43(cwd, REPORT_DIR), { recursive: true });
10148
10317
  const written = [];
10149
10318
  if (shape === "html" && drawsPicture(graph, coverage)) {
10150
10319
  const drawn = layOut(graph.graph, graph.communityOf);
10151
- const path2 = join42(cwd, REPORT_DIR, PICTURE_FILE);
10320
+ const path2 = join43(cwd, REPORT_DIR, PICTURE_FILE);
10152
10321
  await writeGraphPicture(drawn, path2);
10153
10322
  written.push(`${REPORT_DIR}/${PICTURE_FILE}`);
10154
10323
  detailed.picture = buildExplorer(drawn, graph.communityOf).markup;
@@ -10156,7 +10325,7 @@ async function emit(report, shape, cwd, graph, coverage) {
10156
10325
  const RENDER = { json: renderJson2, html: renderHtml, markdown: renderMarkdown2 };
10157
10326
  const name = SHAPE_FILE2[shape] ?? `${TARGET}.${shape}`;
10158
10327
  const body = RENDER[shape](detailed);
10159
- writeFileSync11(join42(cwd, REPORT_DIR, name), body, "utf8");
10328
+ writeFileSync11(join43(cwd, REPORT_DIR, name), body, "utf8");
10160
10329
  written.unshift(`${REPORT_DIR}/${name}`);
10161
10330
  return written;
10162
10331
  }
@@ -10190,9 +10359,9 @@ function registerTest() {
10190
10359
 
10191
10360
  // src/roles/typescript/adapters/tsc/tsc.adapter.ts
10192
10361
  import { spawnSync as spawnSync9 } from "node:child_process";
10193
- import { existsSync as existsSync30, readFileSync as readFileSync32 } from "node:fs";
10362
+ import { existsSync as existsSync31, readFileSync as readFileSync33 } from "node:fs";
10194
10363
  import { createRequire } from "node:module";
10195
- import { join as join44 } from "node:path";
10364
+ import { join as join45 } from "node:path";
10196
10365
 
10197
10366
  // src/roles/typescript/presets/nest.json
10198
10367
  var nest_default = {
@@ -10377,8 +10546,8 @@ function readTsconfigAdoption(cwd) {
10377
10546
  }
10378
10547
 
10379
10548
  // src/roles/typescript/adapters/tsc/plan.ts
10380
- import { readFileSync as readFileSync31 } from "node:fs";
10381
- import { join as join43 } from "node:path";
10549
+ import { readFileSync as readFileSync32 } from "node:fs";
10550
+ import { join as join44 } from "node:path";
10382
10551
 
10383
10552
  // src/roles/typescript/typecheck-script.ts
10384
10553
  var SENTINEL_TYPECHECK_COMMAND = "sentinel --run --typescript";
@@ -10471,7 +10640,7 @@ function planAdoption(context2) {
10471
10640
  };
10472
10641
  }
10473
10642
  const existing = parseJsonc(
10474
- readFileSync31(join43(context2.cwd, target.path), "utf8"),
10643
+ readFileSync32(join44(context2.cwd, target.path), "utf8"),
10475
10644
  target.path
10476
10645
  );
10477
10646
  const extendsChain = composeExtends(existing.extends, preset);
@@ -10609,7 +10778,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
10609
10778
  let chain;
10610
10779
  try {
10611
10780
  const parsed = parseJsonc(
10612
- readFileSync32(join44(cwd, target.path), "utf8"),
10781
+ readFileSync33(join45(cwd, target.path), "utf8"),
10613
10782
  target.path
10614
10783
  );
10615
10784
  chain = parsed.extends;
@@ -10622,7 +10791,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
10622
10791
  );
10623
10792
  if (preset === void 0) return void 0;
10624
10793
  try {
10625
- createRequire(join44(cwd, "noop.js")).resolve(preset);
10794
+ createRequire(join45(cwd, "noop.js")).resolve(preset);
10626
10795
  return void 0;
10627
10796
  } catch {
10628
10797
  return preset;
@@ -10718,7 +10887,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
10718
10887
  referencedProjects(cwd, config) {
10719
10888
  try {
10720
10889
  const parsed = parseJsonc(
10721
- readFileSync32(join44(cwd, config), "utf8"),
10890
+ readFileSync33(join45(cwd, config), "utf8"),
10722
10891
  config
10723
10892
  );
10724
10893
  const referenced = (parsed.references ?? []).map((reference) => reference.path).filter((path2) => typeof path2 === "string" && path2.length > 0);
@@ -10734,7 +10903,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
10734
10903
  * check.
10735
10904
  */
10736
10905
  typecheckTarget(cwd) {
10737
- if (existsSync30(join44(cwd, "tsconfig.json"))) return "tsconfig.json";
10906
+ if (existsSync31(join45(cwd, "tsconfig.json"))) return "tsconfig.json";
10738
10907
  const target = resolveTsconfigTarget(cwd);
10739
10908
  return target.reason === "none" ? null : target.path;
10740
10909
  }
@@ -10942,7 +11111,7 @@ function replaceLines(current, replacements) {
10942
11111
  }
10943
11112
 
10944
11113
  // src/core/apply-plan.ts
10945
- import { existsSync as existsSync31, readFileSync as readFileSync33, renameSync as renameSync2, rmSync as rmSync7, writeFileSync as writeFileSync12 } from "node:fs";
11114
+ import { existsSync as existsSync32, readFileSync as readFileSync34, renameSync as renameSync2, rmSync as rmSync7, writeFileSync as writeFileSync12 } from "node:fs";
10946
11115
  import { resolve as resolve8, sep as sep3 } from "node:path";
10947
11116
  import { applyEdits, findNodeAtLocation, modify, parseTree } from "jsonc-parser";
10948
11117
  function resolveWithinRoot(cwd, relativePath) {
@@ -10954,7 +11123,7 @@ function resolveWithinRoot(cwd, relativePath) {
10954
11123
  return absolutePath;
10955
11124
  }
10956
11125
  function readIfExists(absolutePath) {
10957
- return existsSync31(absolutePath) ? readFileSync33(absolutePath, "utf8") : void 0;
11126
+ return existsSync32(absolutePath) ? readFileSync34(absolutePath, "utf8") : void 0;
10958
11127
  }
10959
11128
  function* leaves(value, prefix = []) {
10960
11129
  for (const [key, keyValue] of Object.entries(value)) {
@@ -11072,8 +11241,8 @@ function applyPlan(cwd, plan3) {
11072
11241
  }
11073
11242
 
11074
11243
  // src/core/config/preset-evidence.ts
11075
- import { existsSync as existsSync32, readdirSync as readdirSync9, readFileSync as readFileSync34 } from "node:fs";
11076
- import { join as join45 } from "node:path";
11244
+ import { existsSync as existsSync33, readdirSync as readdirSync9, readFileSync as readFileSync35 } from "node:fs";
11245
+ import { join as join46 } from "node:path";
11077
11246
  var PATH_SIGNALS = [
11078
11247
  {
11079
11248
  preset: "nest",
@@ -11107,12 +11276,12 @@ function sourceImports(cwd, pattern) {
11107
11276
  }
11108
11277
  for (const entry of entries) {
11109
11278
  if (entry.isDirectory()) {
11110
- if (!NOT_SCANNED.has(entry.name)) stack.push(join45(dir, entry.name));
11279
+ if (!NOT_SCANNED.has(entry.name)) stack.push(join46(dir, entry.name));
11111
11280
  continue;
11112
11281
  }
11113
11282
  if (!SOURCE_FILE.test(entry.name)) continue;
11114
11283
  try {
11115
- if (pattern.test(readFileSync34(join45(dir, entry.name), "utf8"))) return true;
11284
+ if (pattern.test(readFileSync35(join46(dir, entry.name), "utf8"))) return true;
11116
11285
  } catch {
11117
11286
  continue;
11118
11287
  }
@@ -11121,11 +11290,11 @@ function sourceImports(cwd, pattern) {
11121
11290
  return false;
11122
11291
  }
11123
11292
  function dependencyNames(cwd) {
11124
- const path2 = join45(cwd, "package.json");
11125
- if (!existsSync32(path2)) return [];
11293
+ const path2 = join46(cwd, "package.json");
11294
+ if (!existsSync33(path2)) return [];
11126
11295
  try {
11127
11296
  const manifest = parseJsonc(
11128
- readFileSync34(path2, "utf8"),
11297
+ readFileSync35(path2, "utf8"),
11129
11298
  path2
11130
11299
  );
11131
11300
  return [
@@ -11148,7 +11317,7 @@ function reactTsconfigEvidence(cwd) {
11148
11317
  }
11149
11318
  for (const name of entries) {
11150
11319
  try {
11151
- const config = parseJsonc(readFileSync34(join45(cwd, name), "utf8"), name);
11320
+ const config = parseJsonc(readFileSync35(join46(cwd, name), "utf8"), name);
11152
11321
  if (config.compilerOptions?.jsx !== void 0) return 'its tsconfig sets "jsx"';
11153
11322
  const extended = Array.isArray(config.extends) ? config.extends : config.extends === void 0 ? [] : [config.extends];
11154
11323
  if (extended.some((entry) => entry === REACT_TYPESCRIPT_PRESET)) {