nudojs 1.3.15 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +340 -161
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -21075,19 +21075,36 @@ function mergeGuardInto(list, g) {
21075
21075
  if (grainA !== grainB) prev.grain = "nullish";
21076
21076
  if (prev.memberKey === void 0 && g.memberKey !== void 0) prev.memberKey = g.memberKey;
21077
21077
  }
21078
+ function appendReceiverGuards(test, out) {
21079
+ const facts = [];
21080
+ collectReceiverFacts(test, "both", facts);
21081
+ for (const f of facts) {
21082
+ const prev = out.find((x) => x.name === f.name && x.arm === f.arm);
21083
+ if (!prev) {
21084
+ out.push(f);
21085
+ continue;
21086
+ }
21087
+ const grainA = prev.grain ?? "nullish";
21088
+ const grainB = f.grain ?? "nullish";
21089
+ if (grainA !== grainB) prev.grain = "nullish";
21090
+ if (prev.memberKey === void 0 && f.memberKey !== void 0) prev.memberKey = f.memberKey;
21091
+ }
21092
+ }
21078
21093
  function nullishGuardsOf(test) {
21079
21094
  const t = test;
21080
21095
  if (t?.type === "LogicalExpression" && (t.operator === "||" || t.operator === "&&")) {
21081
21096
  const wantArm = t.operator === "||" ? "alt" : "cons";
21082
- const out = [];
21097
+ const out2 = [];
21083
21098
  for (const g2 of [...nullishGuardsOf(t.left), ...nullishGuardsOf(t.right)]) {
21084
21099
  if (g2.arm !== wantArm) continue;
21085
- mergeGuardInto(out, g2);
21100
+ mergeGuardInto(out2, g2);
21086
21101
  }
21087
- return out;
21102
+ return out2;
21088
21103
  }
21089
21104
  const g = nullishGuardOf(test);
21090
- return g ? [g] : [];
21105
+ const out = g ? [g] : [];
21106
+ appendReceiverGuards(test, out);
21107
+ return out;
21091
21108
  }
21092
21109
  function typeGuardOf(test) {
21093
21110
  const t = test;
@@ -21178,7 +21195,7 @@ function narrowDiscriminantArmThunks(thunk, guards, arm, forkBindingNames) {
21178
21195
  ).join(", ");
21179
21196
  return `((${params}) => ${thunk})(${args})`;
21180
21197
  }
21181
- var TYPEOF_NAMES2, isStrLitNode, typeofArgName, memberGuardTarget, assignGuardTarget, isPrimLitNode;
21198
+ var TYPEOF_NAMES2, isStrLitNode, typeofArgName, memberGuardTarget, assignGuardTarget, methodReceiverTarget, collectReceiverFacts, isPrimLitNode;
21182
21199
  var init_stmt_predicates = __esm({
21183
21200
  "../core/src/algebra/exec/transpile/stmt-predicates.ts"() {
21184
21201
  "use strict";
@@ -21208,9 +21225,17 @@ var init_stmt_predicates = __esm({
21208
21225
  const t = n;
21209
21226
  const m = t?.type === "ChainExpression" ? t.expression : t;
21210
21227
  if (m?.type !== "MemberExpression" && m?.type !== "OptionalMemberExpression") return void 0;
21211
- if (m.computed) return void 0;
21212
21228
  if (m.object?.type !== "Identifier" || !m.object.name) return void 0;
21213
21229
  const p = m.property;
21230
+ if (m.computed) {
21231
+ if (p?.type === "NumericLiteral" && typeof p.value === "number") {
21232
+ return { name: m.object.name, key: String(p.value) };
21233
+ }
21234
+ if (p?.type === "StringLiteral" && typeof p.value === "string" && /^-?\d+$/.test(p.value)) {
21235
+ return { name: m.object.name, key: p.value };
21236
+ }
21237
+ return void 0;
21238
+ }
21214
21239
  const key = p?.type === "Identifier" ? p.name : p?.type === "StringLiteral" && typeof p.value === "string" ? p.value : void 0;
21215
21240
  if (key === void 0) return void 0;
21216
21241
  return { name: m.object.name, key };
@@ -21222,6 +21247,59 @@ var init_stmt_predicates = __esm({
21222
21247
  }
21223
21248
  return void 0;
21224
21249
  };
21250
+ methodReceiverTarget = (callee) => {
21251
+ const c = callee;
21252
+ if (c?.type !== "MemberExpression") return void 0;
21253
+ const o = c.object;
21254
+ if (o?.type === "Identifier" && o.name) return { name: o.name };
21255
+ if (o?.type === "MemberExpression") return memberGuardTarget(o);
21256
+ return void 0;
21257
+ };
21258
+ collectReceiverFacts = (n, ctx2, out) => {
21259
+ if (ctx2 === null || !n || typeof n !== "object") return;
21260
+ const t = n;
21261
+ switch (t.type) {
21262
+ case "LogicalExpression":
21263
+ if (t.operator === "&&" || t.operator === "||") {
21264
+ const rArm = t.operator === "&&" ? "cons" : "alt";
21265
+ collectReceiverFacts(t.left, ctx2, out);
21266
+ collectReceiverFacts(
21267
+ t.right,
21268
+ ctx2 === "both" || ctx2 === rArm ? rArm : null,
21269
+ out
21270
+ );
21271
+ } else if (t.operator === "??") {
21272
+ collectReceiverFacts(t.left, ctx2, out);
21273
+ }
21274
+ return;
21275
+ case "ConditionalExpression":
21276
+ collectReceiverFacts(t.test, ctx2, out);
21277
+ return;
21278
+ case "CallExpression": {
21279
+ const recv = methodReceiverTarget(t.callee);
21280
+ if (recv) {
21281
+ for (const arm of ctx2 === "both" ? ["cons", "alt"] : [ctx2]) {
21282
+ out.push({
21283
+ name: recv.name,
21284
+ arm,
21285
+ grain: "nullish",
21286
+ ...recv.key !== void 0 ? { memberKey: recv.key } : {}
21287
+ });
21288
+ }
21289
+ }
21290
+ collectReceiverFacts(t.callee, ctx2, out);
21291
+ for (const a of t.arguments ?? []) collectReceiverFacts(a, ctx2, out);
21292
+ return;
21293
+ }
21294
+ default:
21295
+ collectReceiverFacts(t.left, ctx2, out);
21296
+ collectReceiverFacts(t.right, ctx2, out);
21297
+ collectReceiverFacts(t.argument, ctx2, out);
21298
+ collectReceiverFacts(t.object, ctx2, out);
21299
+ if (t.computed) collectReceiverFacts(t.property, ctx2, out);
21300
+ return;
21301
+ }
21302
+ };
21225
21303
  isPrimLitNode = (n) => {
21226
21304
  const t = n;
21227
21305
  if (t?.type === "StringLiteral") return typeof t.value === "string";
@@ -32238,10 +32316,32 @@ function execRegexBrand(re, method, args) {
32238
32316
  if (method === "test") {
32239
32317
  return abs({ k: "prim", type: "boolean" }, void 0, void 0, "partial");
32240
32318
  }
32241
- const element = joinAbs(str(), undefAbs());
32242
- const matchAbs = abs({ k: "arr", element }, void 0, void 0, "path");
32243
- const nullAbs3 = abs({ k: "unknown" }, { op: "lit", value: null }, void 0, "exact");
32244
- return joinAbs(nullAbs3, matchAbs);
32319
+ let probe = null;
32320
+ try {
32321
+ probe = new RegExp(`${parts.pat}|`).exec("");
32322
+ } catch {
32323
+ probe = null;
32324
+ }
32325
+ const nullArm = abs({ k: "unknown" }, { op: "lit", value: null }, void 0, "exact");
32326
+ if (!probe) {
32327
+ const element = joinAbs(str(), undefAbs());
32328
+ return joinAbs(nullArm, abs({ k: "arr", element }, void 0, void 0, "path"));
32329
+ }
32330
+ const ng = probe.length - 1;
32331
+ const slots = {
32332
+ "0": { value: str() },
32333
+ length: { value: numLit(probe.length) },
32334
+ index: { value: num() },
32335
+ input: { value: str() }
32336
+ };
32337
+ for (let i = 1; i <= ng; i++) {
32338
+ slots[String(i)] = { value: joinAbs(str(), undefAbs()) };
32339
+ }
32340
+ const groupNames = probe.groups ? Object.keys(probe.groups) : [];
32341
+ slots["groups"] = {
32342
+ value: groupNames.length ? objOf(Object.fromEntries(groupNames.map((n) => [n, { value: joinAbs(str(), undefAbs()) }]))) : undefAbs()
32343
+ };
32344
+ return joinAbs(nullArm, abs({ k: "obj", slots }, void 0, void 0, "path"));
32245
32345
  }
32246
32346
  try {
32247
32347
  return regexExecWithState(re, method, subject).result;
@@ -41455,8 +41555,8 @@ function formatEffectiveInterfaceDisplay(eff) {
41455
41555
  if (eff.returns) s += ` \u2192 ${formatConstraint(eff.returns.constraint)}`;
41456
41556
  return s;
41457
41557
  }
41458
- function formatInterfaceTierLine(source) {
41459
- return `\u25CF interface / ${source}`;
41558
+ function formatInterfaceTierLine(source, active = true) {
41559
+ return `${active ? "\u25CF" : "\u25CB"} contract / ${INTERFACE_SOURCE_ABBR[source]}`;
41460
41560
  }
41461
41561
  function interfaceTierOf(source, fnName, fromFile, opts = {}) {
41462
41562
  if (!localNamedExports(source).has(fnName)) return void 0;
@@ -41470,7 +41570,7 @@ function interfaceTierOf(source, fnName, fromFile, opts = {}) {
41470
41570
  function interfaceSourceOf(source, fnName, fromFile, opts = {}) {
41471
41571
  return interfaceTierOf(source, fnName, fromFile, opts)?.source;
41472
41572
  }
41473
- var MAX_INTERFACE_DIAGS, interfaceDiagChannel, sidecarLoadFailureSlot, MAX_SIDECAR_FP_NODES, LAZY_DISPLAY_DEPTH;
41573
+ var MAX_INTERFACE_DIAGS, interfaceDiagChannel, sidecarLoadFailureSlot, MAX_SIDECAR_FP_NODES, LAZY_DISPLAY_DEPTH, INTERFACE_SOURCE_ABBR;
41474
41574
  var init_interface = __esm({
41475
41575
  "../core/src/algebra/interface.ts"() {
41476
41576
  "use strict";
@@ -41495,6 +41595,11 @@ var init_interface = __esm({
41495
41595
  registerCollectorScopeParticipant((body) => sidecarLoadFailureSlot.runScoped(body));
41496
41596
  MAX_SIDECAR_FP_NODES = 64;
41497
41597
  LAZY_DISPLAY_DEPTH = 2;
41598
+ INTERFACE_SOURCE_ABBR = {
41599
+ handwritten: "hw",
41600
+ generated: "gen",
41601
+ implicit: "imp"
41602
+ };
41498
41603
  }
41499
41604
  });
41500
41605
 
@@ -41718,11 +41823,11 @@ function sidecarSpecsOf(source) {
41718
41823
  (spec) => (spec.startsWith(".") || spec.startsWith("/")) && (spec.endsWith(".nudo.js") || spec.endsWith(".nudo.ts"))
41719
41824
  );
41720
41825
  }
41721
- function loadOrMiss(loadModule, spec, from) {
41826
+ function tryLoadDeps(loadModule, spec, from) {
41722
41827
  try {
41723
- return loadModule(spec, from);
41828
+ return { src: loadModule(spec, from), err: false };
41724
41829
  } catch {
41725
- return void 0;
41830
+ return { src: void 0, err: true };
41726
41831
  }
41727
41832
  }
41728
41833
  function loadModuleDepsFingerprint(source, loadModule, fromFile) {
@@ -41735,16 +41840,35 @@ function loadModuleDepsFingerprint(source, loadModule, fromFile) {
41735
41840
  );
41736
41841
  let n = 0;
41737
41842
  let truncated = false;
41843
+ let readError = false;
41844
+ const load = (spec, from) => {
41845
+ const a = tryLoadDeps(loadModule, spec, from);
41846
+ if (a.err) readError = true;
41847
+ return a;
41848
+ };
41738
41849
  const finish = () => {
41739
41850
  parts.sort();
41740
- return truncated ? { fp: `trunc:${parts.join(",")}`, paths, contents, truncated: true } : { fp: parts.join(","), paths, contents, truncated: false };
41851
+ const prefix2 = truncated ? "trunc:" : readError ? "readerr:" : "";
41852
+ return {
41853
+ fp: `${prefix2}${parts.join(",")}`,
41854
+ paths,
41855
+ contents,
41856
+ truncated,
41857
+ readError
41858
+ };
41741
41859
  };
41742
41860
  const absorbSidecarClosure = (entryFile) => {
41743
41861
  const sidecarPath = sidecarPathOf(entryFile);
41744
41862
  if (seen.has(sidecarPath)) return;
41745
41863
  const sidecarSpec = `./${sidecarPath.slice(sidecarPath.lastIndexOf("/") + 1)}`;
41746
- const sidecarSrc = loadOrMiss(loadModule, sidecarSpec, entryFile);
41747
- if (sidecarSrc === void 0) return;
41864
+ const root = load(sidecarSpec, entryFile);
41865
+ if (root.err) {
41866
+ paths.push(sidecarPath);
41867
+ contents.push({ path: sidecarPath, content: null });
41868
+ return;
41869
+ }
41870
+ if (root.src === void 0) return;
41871
+ const sidecarSrc = root.src;
41748
41872
  if (n >= MAX_LOAD_DEP_NODES) {
41749
41873
  truncated = true;
41750
41874
  return;
@@ -41767,7 +41891,7 @@ function loadModuleDepsFingerprint(source, loadModule, fromFile) {
41767
41891
  if (seen.has(path)) continue;
41768
41892
  seen.add(path);
41769
41893
  n++;
41770
- const src = loadOrMiss(loadModule, cur.spec, cur.from);
41894
+ const src = load(cur.spec, cur.from).src;
41771
41895
  parts.push(`sidecar:${path}=${src === void 0 ? "miss" : hashSource(src)}`);
41772
41896
  paths.push(path);
41773
41897
  contents.push({ path, content: src ?? null });
@@ -41788,7 +41912,7 @@ function loadModuleDepsFingerprint(source, loadModule, fromFile) {
41788
41912
  if (seen.has(path)) continue;
41789
41913
  seen.add(path);
41790
41914
  n++;
41791
- const src = loadOrMiss(loadModule, cur.spec, cur.from);
41915
+ const src = load(cur.spec, cur.from).src;
41792
41916
  parts.push(`${path}=${src === void 0 ? "miss" : hashSource(src)}`);
41793
41917
  paths.push(path);
41794
41918
  contents.push({ path, content: src ?? null });
@@ -42442,7 +42566,7 @@ function loadModuleId(fn2) {
42442
42566
  }
42443
42567
  function refineDepsFingerprint(source, refine) {
42444
42568
  if (!refine?.loadModule || !refine.fromFile) {
42445
- return { fp: "-", paths: [], contents: [], truncated: false };
42569
+ return { fp: "-", paths: [], contents: [], truncated: false, readError: false };
42446
42570
  }
42447
42571
  return loadModuleDepsFingerprint(source, refine.loadModule, refine.fromFile);
42448
42572
  }
@@ -42458,7 +42582,7 @@ function moduleMapId(m) {
42458
42582
  function generalizeMemoKey(fnName, source, opts) {
42459
42583
  const r = opts.refine;
42460
42584
  const budget = opts.budget ?? defaultLeakBudget;
42461
- const deps = opts.depsFp ?? (r ? refineDepsFingerprint(source, r) : { fp: "-", paths: [], contents: [], truncated: false });
42585
+ const deps = opts.depsFp ?? (r ? refineDepsFingerprint(source, r) : { fp: "-", paths: [], contents: [], truncated: false, readError: false });
42462
42586
  const sc = opts.sidecarFp ?? (r?.loadModule && r.fromFile ? sidecarClosureFingerprint(r.fromFile, r) : void 0);
42463
42587
  const scPath = sc !== void 0 && !sc.startsWith("trunc:") && r?.fromFile ? sidecarPathOf(r.fromFile) : void 0;
42464
42588
  const srcPart = generalizeSourceKeyPart(source, fnName, opts.file);
@@ -42476,7 +42600,7 @@ function generalizeMemoKey(fnName, source, opts) {
42476
42600
  return {
42477
42601
  key,
42478
42602
  depPaths: scPath !== void 0 ? [...deps.paths, scPath] : deps.paths,
42479
- truncated: deps.truncated || (sc?.startsWith("trunc:") ?? false)
42603
+ truncated: deps.truncated || deps.readError || (sc?.startsWith("trunc:") ?? false)
42480
42604
  };
42481
42605
  }
42482
42606
  function generalizeMemoGet(key) {
@@ -45677,7 +45801,7 @@ function loadModuleId2(fn2) {
45677
45801
  }
45678
45802
  function checkDepsFingerprint(source, opts) {
45679
45803
  if (!opts.loadModule || !opts.fromFile) {
45680
- return { fp: "-", paths: [], contents: [], truncated: false };
45804
+ return { fp: "-", paths: [], contents: [], truncated: false, readError: false };
45681
45805
  }
45682
45806
  return loadModuleDepsFingerprint(source, opts.loadModule, opts.fromFile);
45683
45807
  }
@@ -46268,7 +46392,9 @@ function checkSourceInScope(filePath, source, phi2, opts) {
46268
46392
  const stable = stableAnalyzeKeySource(source);
46269
46393
  const depsFp = checkDepsFingerprint(stable, callOpts);
46270
46394
  const sidecarFp = callOpts.loadModule && callOpts.fromFile ? sidecarClosureFingerprint(callOpts.fromFile, callOpts) : void 0;
46271
- const allowMemo = useMemo && !depsFp.truncated && !(sidecarFp?.startsWith("trunc:") ?? false);
46395
+ const allowMemo = useMemo && !depsFp.truncated && // 读错误轮键不可信(#135):错误轮报告(nudo:interface-load)与真 miss 轮
46396
+ // (干净)若共享 miss 键会互为跨次陈旧命中——不读也不写 memo
46397
+ !depsFp.readError && !(sidecarFp?.startsWith("trunc:") ?? false);
46272
46398
  if (allowMemo) {
46273
46399
  memoKey = checkMemoKey(filePath, stable, opts, depsFp, sidecarFp);
46274
46400
  const hit = checkMemoGet(memoKey);
@@ -47436,6 +47562,7 @@ __export(src_exports, {
47436
47562
  CONSTRAINT_BUILDER_NAMES: () => CONSTRAINT_BUILDER_NAMES,
47437
47563
  CONSTRAINT_EXPR_RE: () => CONSTRAINT_EXPR_RE,
47438
47564
  DEFAULT_MAX_LOOP_ITERS: () => DEFAULT_MAX_LOOP_ITERS,
47565
+ INTERFACE_SOURCE_ABBR: () => INTERFACE_SOURCE_ABBR,
47439
47566
  MAX_EVAL_CALL_DEPTH: () => MAX_EVAL_CALL_DEPTH,
47440
47567
  MAX_EVAL_TOTAL_CALLS: () => MAX_EVAL_TOTAL_CALLS,
47441
47568
  NudoLoopSignal: () => NudoLoopSignal,
@@ -48058,12 +48185,16 @@ function collectAbsInlays(source, opts) {
48058
48185
  const inlays = [];
48059
48186
  const refineOpts = opts?.loadModule || opts?.fromFile ? {
48060
48187
  ...opts.loadModule ? { loadModule: opts.loadModule } : {},
48061
- ...opts.fromFile ? { fromFile: opts.fromFile } : {}
48188
+ ...opts.fromFile ? { fromFile: opts.fromFile } : {},
48189
+ ...opts.autoBind !== void 0 ? { autoBind: opts.autoBind } : {}
48062
48190
  } : void 0;
48063
48191
  for (const { name, node } of listFunctions(source)) {
48064
48192
  let g;
48065
48193
  try {
48066
- g = generalizeFromAst(name, source, refineOpts ? { refine: refineOpts } : {});
48194
+ g = generalizeFromAst(name, source, {
48195
+ ...refineOpts ? { refine: refineOpts } : {},
48196
+ ...opts?.modules ? { modules: opts.modules } : {}
48197
+ });
48067
48198
  } catch {
48068
48199
  continue;
48069
48200
  }
@@ -49801,7 +49932,7 @@ var init_resolve_npm = __esm({
49801
49932
  });
49802
49933
 
49803
49934
  // ../service/src/load-module.ts
49804
- import { existsSync as existsSync3, statSync as statSync2, readFileSync as readFileSync3 } from "fs";
49935
+ import { statSync as statSync2, readFileSync as readFileSync3 } from "fs";
49805
49936
  import { dirname as dirname3, resolve as resolve2, join as join3 } from "path";
49806
49937
  function moduleResolveCandidates(spec, fromFile) {
49807
49938
  const p = resolve2(dirname3(resolve2(fromFile)), spec);
@@ -49813,18 +49944,21 @@ function moduleResolveCandidates(spec, fromFile) {
49813
49944
  }
49814
49945
  function resolveModuleFile(spec, fromFile) {
49815
49946
  for (const cand of moduleResolveCandidates(spec, fromFile)) {
49816
- if (existsSync3(cand) && !statSync2(cand).isDirectory()) return cand;
49947
+ let st;
49948
+ try {
49949
+ st = statSync2(cand);
49950
+ } catch (e) {
49951
+ const code2 = e?.code;
49952
+ if (code2 === "ENOENT" || code2 === "ENOTDIR" || code2 === "EISDIR") continue;
49953
+ throw new ModuleReadError(cand, e);
49954
+ }
49955
+ if (!st.isDirectory()) return cand;
49817
49956
  }
49818
49957
  return void 0;
49819
49958
  }
49820
49959
  function defaultLoadModule(spec, fromFile) {
49821
49960
  if (!spec.startsWith(".") && !spec.startsWith("/")) return void 0;
49822
- let cand;
49823
- try {
49824
- cand = resolveModuleFile(spec, fromFile);
49825
- } catch {
49826
- return void 0;
49827
- }
49961
+ const cand = resolveModuleFile(spec, fromFile);
49828
49962
  if (!cand) return void 0;
49829
49963
  try {
49830
49964
  return readFileSync3(cand, "utf-8");
@@ -49860,7 +49994,7 @@ var init_load_module = __esm({
49860
49994
  });
49861
49995
 
49862
49996
  // ../service/src/static-imports.ts
49863
- import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
49997
+ import { readFileSync as readFileSync4, existsSync as existsSync3 } from "fs";
49864
49998
  import { resolve as resolve3, dirname as dirname4, join as join4 } from "path";
49865
49999
  function resolveRelative(fromFile, spec) {
49866
50000
  if (!spec.startsWith(".") && !spec.startsWith("/")) return void 0;
@@ -49878,7 +50012,7 @@ function resolveRelative(fromFile, spec) {
49878
50012
  join4(base, "index.mjs"),
49879
50013
  join4(base, "index.ts")
49880
50014
  ]) {
49881
- if (existsSync4(cand)) return cand;
50015
+ if (existsSync3(cand)) return cand;
49882
50016
  }
49883
50017
  return void 0;
49884
50018
  }
@@ -50010,7 +50144,7 @@ function collectStaticImports(entryFile, maxDepth = 8) {
50010
50144
  const { file, depth } = queue.shift();
50011
50145
  if (seen.has(file) || depth > maxDepth) continue;
50012
50146
  seen.add(file);
50013
- if (!existsSync4(file)) continue;
50147
+ if (!existsSync3(file)) continue;
50014
50148
  const source = readFileSync4(file, "utf8");
50015
50149
  const mod2 = analyzeExportsFromSource(file, source);
50016
50150
  graph.set(file, mod2);
@@ -50031,7 +50165,7 @@ var init_static_imports = __esm({
50031
50165
  });
50032
50166
 
50033
50167
  // ../service/src/analyzer-module-load.ts
50034
- import { readFileSync as readFileSync5, existsSync as existsSync5, statSync as statSync3 } from "fs";
50168
+ import { readFileSync as readFileSync5, existsSync as existsSync4, statSync as statSync3 } from "fs";
50035
50169
  import { resolve as resolve4 } from "path";
50036
50170
  function resolveModule(source, fromDir) {
50037
50171
  const extensions = [...MODULE_RESOLVE_EXTS];
@@ -50043,17 +50177,17 @@ function resolveModule(source, fromDir) {
50043
50177
  const basePath = resolve4(fromDir, source);
50044
50178
  for (const ext of ["", ...extensions]) {
50045
50179
  const candidate = basePath + ext;
50046
- if (!existsSync5(candidate)) continue;
50180
+ if (!existsSync4(candidate)) continue;
50047
50181
  if (statSync3(candidate).isDirectory()) {
50048
50182
  let entry = null;
50049
50183
  const pkgPath = resolve4(candidate, "package.json");
50050
- if (existsSync5(pkgPath)) {
50184
+ if (existsSync4(pkgPath)) {
50051
50185
  try {
50052
50186
  const main = JSON.parse(readFileSync5(pkgPath, "utf-8")).main;
50053
50187
  if (typeof main === "string") {
50054
50188
  for (const e of ["", ...extensions]) {
50055
50189
  const p = resolve4(candidate, main + e);
50056
- if (existsSync5(p) && statSync3(p).isFile()) {
50190
+ if (existsSync4(p) && statSync3(p).isFile()) {
50057
50191
  entry = p;
50058
50192
  break;
50059
50193
  }
@@ -50065,7 +50199,7 @@ function resolveModule(source, fromDir) {
50065
50199
  if (!entry) {
50066
50200
  for (const e of ["", ...extensions]) {
50067
50201
  const p = resolve4(candidate, "index" + e);
50068
- if (existsSync5(p) && statSync3(p).isFile()) {
50202
+ if (existsSync4(p) && statSync3(p).isFile()) {
50069
50203
  entry = p;
50070
50204
  break;
50071
50205
  }
@@ -57345,9 +57479,9 @@ function analysisFileCacheKey(filePath, source, activeCases, externalCallRecords
57345
57479
  let noCache = false;
57346
57480
  try {
57347
57481
  const fp = loadModuleDepsFingerprint(source, effectiveLoader, filePath);
57348
- if (fp.truncated) {
57482
+ if (fp.truncated || fp.readError) {
57349
57483
  noCache = true;
57350
- depSeg = `trunc:${fp.paths.length}`;
57484
+ depSeg = `${fp.truncated ? "trunc" : "readerr"}:${fp.paths.length}`;
57351
57485
  } else {
57352
57486
  depSeg = hashSource(fp.fp);
57353
57487
  }
@@ -59707,7 +59841,7 @@ var init_lru_map2 = __esm({
59707
59841
  });
59708
59842
 
59709
59843
  // ../service/src/evaluator/env-loader.ts
59710
- import { readFileSync as readFileSync6, existsSync as existsSync6, statSync as statSync4, mkdirSync, writeFileSync } from "fs";
59844
+ import { readFileSync as readFileSync6, existsSync as existsSync5, statSync as statSync4, mkdirSync, writeFileSync } from "fs";
59711
59845
  import { resolve as resolvePath, join as joinPath } from "path";
59712
59846
  import { pathToFileURL } from "url";
59713
59847
  import { createRequire as createRequire2 } from "module";
@@ -59744,7 +59878,7 @@ function isPathEnvName(name, baseDir) {
59744
59878
  if (name in envFactories) return false;
59745
59879
  if (name.includes("/") || name.startsWith("./") || name.startsWith("../")) return true;
59746
59880
  const resolved = resolvePath(baseDir, name);
59747
- return resolved.endsWith(".ts") && existsSync6(resolved);
59881
+ return resolved.endsWith(".ts") && existsSync5(resolved);
59748
59882
  }
59749
59883
  function rewriteBareImports(text) {
59750
59884
  const require3 = createRequire2(import.meta.url);
@@ -59875,7 +60009,7 @@ async function preloadPathEnvs(envNames, baseDir) {
59875
60009
  for (const name of envNames) {
59876
60010
  if (!isPathEnvName(name, baseDir)) continue;
59877
60011
  const resolved = resolvePath(baseDir, name);
59878
- if (!existsSync6(resolved)) {
60012
+ if (!existsSync5(resolved)) {
59879
60013
  recordPathEnvError(resolved, baseDir, new Error(`path env not found: ${resolved}`));
59880
60014
  continue;
59881
60015
  }
@@ -60125,13 +60259,22 @@ function pkgStatFp(pkgPath) {
60125
60259
  try {
60126
60260
  const st = statSync5(pkgPath);
60127
60261
  return `${st.mtimeMs}:${st.size}`;
60128
- } catch {
60129
- return void 0;
60262
+ } catch (err) {
60263
+ if (err instanceof Error && err.code === "ENOENT") {
60264
+ return void 0;
60265
+ }
60266
+ throw err;
60130
60267
  }
60131
60268
  }
60132
60269
  function projectConfigMemoHit(entry) {
60133
60270
  for (const { pkgPath, fp } of entry.chain) {
60134
- if (pkgStatFp(pkgPath) !== fp) return false;
60271
+ let current;
60272
+ try {
60273
+ current = pkgStatFp(pkgPath);
60274
+ } catch {
60275
+ return false;
60276
+ }
60277
+ if (current !== fp) return false;
60135
60278
  }
60136
60279
  return true;
60137
60280
  }
@@ -60159,7 +60302,18 @@ function findProjectConfig(startDir) {
60159
60302
  if (hit && projectConfigMemoHit(hit)) return hit.result;
60160
60303
  while (dir !== root) {
60161
60304
  const pkgPath = resolve6(dir, "package.json");
60162
- const statFp = pkgStatFp(pkgPath);
60305
+ let statFp;
60306
+ try {
60307
+ statFp = pkgStatFp(pkgPath);
60308
+ } catch (err) {
60309
+ memoEntry.chain.push({ pkgPath, fp: STAT_ERROR_FP });
60310
+ process.stderr?.write?.(
60311
+ `nudo: package.json stat failed at ${pkgPath} (${err instanceof Error ? err.message : String(err)}); project config disabled for this subtree (defaults + env apply)
60312
+ `
60313
+ );
60314
+ applyBForkBudgetFromConfig(null);
60315
+ return memoize(null);
60316
+ }
60163
60317
  memoEntry.chain.push({ pkgPath, fp: statFp });
60164
60318
  if (statFp !== void 0) {
60165
60319
  let pkg;
@@ -60188,7 +60342,7 @@ function findProjectConfig(startDir) {
60188
60342
  applyBForkBudgetFromConfig(null);
60189
60343
  return memoize(null);
60190
60344
  }
60191
- var DEFAULT_ANALYSIS_EXCLUDE, DEFAULT_ANALYSIS_MODE, projectConfigMemo, MAX_PROJECT_CONFIG_MEMO, projectConfigDiskReads;
60345
+ var DEFAULT_ANALYSIS_EXCLUDE, DEFAULT_ANALYSIS_MODE, projectConfigMemo, MAX_PROJECT_CONFIG_MEMO, projectConfigDiskReads, STAT_ERROR_FP;
60192
60346
  var init_config = __esm({
60193
60347
  "../service/src/evaluator/config.ts"() {
60194
60348
  "use strict";
@@ -60203,6 +60357,7 @@ var init_config = __esm({
60203
60357
  projectConfigMemo = /* @__PURE__ */ new Map();
60204
60358
  MAX_PROJECT_CONFIG_MEMO = 128;
60205
60359
  projectConfigDiskReads = 0;
60360
+ STAT_ERROR_FP = "\0stat-error";
60206
60361
  }
60207
60362
  });
60208
60363
 
@@ -274993,7 +275148,7 @@ var init_harvest_dts = __esm({
274993
275148
  });
274994
275149
 
274995
275150
  // ../harvester/src/dts-contract-draft.ts
274996
- import { readFileSync as readFileSync9, existsSync as existsSync7, statSync as statSync7, readdirSync } from "fs";
275151
+ import { readFileSync as readFileSync9, existsSync as existsSync6, statSync as statSync7, readdirSync } from "fs";
274997
275152
  import { basename, dirname as dirname6, join as join5 } from "path";
274998
275153
  function keywordDsl(node) {
274999
275154
  switch (node.kind) {
@@ -275278,7 +275433,7 @@ function readDtsFiles(paths, maxFiles = 16) {
275278
275433
  }
275279
275434
  };
275280
275435
  for (const p of paths) {
275281
- if (!existsSync7(p)) continue;
275436
+ if (!existsSync6(p)) continue;
275282
275437
  const st = statSync7(p);
275283
275438
  if (st.isDirectory()) walk(p, 0);
275284
275439
  else if (/\.d\.ts$/.test(p) || /\.(m)?ts$/.test(p)) {
@@ -275288,7 +275443,7 @@ function readDtsFiles(paths, maxFiles = 16) {
275288
275443
  return out.slice(0, maxFiles);
275289
275444
  }
275290
275445
  function dtsToContractDraft(dtsFiles, label) {
275291
- const files = dtsFiles.filter((f) => existsSync7(f));
275446
+ const files = dtsFiles.filter((f) => existsSync6(f));
275292
275447
  const exports = [];
275293
275448
  let skippedFiles = 0;
275294
275449
  for (const file of files) {
@@ -275344,16 +275499,16 @@ var init_dts_contract_draft = __esm({
275344
275499
  });
275345
275500
 
275346
275501
  // ../harvester/src/harvest-package.ts
275347
- import { existsSync as existsSync8, readdirSync as readdirSync2, statSync as statSync8, readFileSync as readFileSync10 } from "fs";
275502
+ import { existsSync as existsSync7, readdirSync as readdirSync2, statSync as statSync8, readFileSync as readFileSync10 } from "fs";
275348
275503
  import { join as join6, resolve as resolve7, dirname as dirname7, basename as basename2 } from "path";
275349
275504
  function resolvePackageRoot(pkg, fromDir = process.cwd()) {
275350
275505
  let dir = resolve7(fromDir);
275351
275506
  const bare = pkg.replace(/^@/, "").replace(/\//g, "__");
275352
275507
  for (let i = 0; i < 8; i++) {
275353
275508
  const typesPath = join6(dir, "node_modules", "@types", bare);
275354
- if (existsSync8(typesPath)) return typesPath;
275509
+ if (existsSync7(typesPath)) return typesPath;
275355
275510
  const pkgPath = join6(dir, "node_modules", pkg);
275356
- if (existsSync8(pkgPath)) return pkgPath;
275511
+ if (existsSync7(pkgPath)) return pkgPath;
275357
275512
  const parent = resolve7(dir, "..");
275358
275513
  if (parent === dir) break;
275359
275514
  dir = parent;
@@ -275402,13 +275557,13 @@ function collectDtsFiles(root, maxFiles = 8) {
275402
275557
  }
275403
275558
  function entryDtsFromPackageJson(root) {
275404
275559
  const pj = join6(root, "package.json");
275405
- if (!existsSync8(pj)) return void 0;
275560
+ if (!existsSync7(pj)) return void 0;
275406
275561
  try {
275407
275562
  const raw = JSON.parse(readFileSync10(pj, "utf8"));
275408
275563
  const entry = raw.types ?? raw.typings;
275409
275564
  if (typeof entry === "string" && entry.endsWith(".d.ts")) {
275410
275565
  const p = resolve7(root, entry);
275411
- if (existsSync8(p)) {
275566
+ if (existsSync7(p)) {
275412
275567
  const st = statSync8(p);
275413
275568
  if (st.size <= MAX_DTS_BYTES) return p;
275414
275569
  }
@@ -275425,7 +275580,7 @@ function collectDtsFromEntry(entry, maxFiles = 200) {
275425
275580
  const RELATIVE_FROM_REGEX = /\bfrom\s+["'](\.[^"']+)["']/g;
275426
275581
  while (queue.length > 0 && files.length < maxFiles) {
275427
275582
  const current = queue.shift();
275428
- if (seen.has(current) || !existsSync8(current)) continue;
275583
+ if (seen.has(current) || !existsSync7(current)) continue;
275429
275584
  seen.add(current);
275430
275585
  if (!current.endsWith(".d.ts")) continue;
275431
275586
  files.push(current);
@@ -275442,7 +275597,7 @@ function collectDtsFromEntry(entry, maxFiles = 200) {
275442
275597
  for (const match of text.matchAll(RELATIVE_FROM_REGEX)) {
275443
275598
  const base = resolve7(dir, match[1]);
275444
275599
  for (const candidate of [`${base}.d.ts`, join6(base, "index.d.ts")]) {
275445
- if (existsSync8(candidate)) {
275600
+ if (existsSync7(candidate)) {
275446
275601
  queue.push(candidate);
275447
275602
  break;
275448
275603
  }
@@ -275455,10 +275610,10 @@ function harvestPackage(pkg, fromDir, maxFiles = 24) {
275455
275610
  const root = resolvePackageRoot(pkg, fromDir);
275456
275611
  if (!root) return { error: `package not found: ${pkg}` };
275457
275612
  const entry = entryDtsFromPackageJson(root) ?? join6(root, "index.d.ts");
275458
- let dtsFiles = existsSync8(entry) ? collectDtsFromEntry(entry, maxFiles) : [];
275613
+ let dtsFiles = existsSync7(entry) ? collectDtsFromEntry(entry, maxFiles) : [];
275459
275614
  if (dtsFiles.length === 0) {
275460
275615
  const collected = collectDtsFiles(root, maxFiles);
275461
- dtsFiles = entry && existsSync8(entry) && !collected.includes(entry) ? [entry, ...collected.filter((f) => f !== entry)].slice(0, maxFiles) : collected;
275616
+ dtsFiles = entry && existsSync7(entry) && !collected.includes(entry) ? [entry, ...collected.filter((f) => f !== entry)].slice(0, maxFiles) : collected;
275462
275617
  }
275463
275618
  if (dtsFiles.length === 0) {
275464
275619
  return { error: `no .d.ts under ${root}` };
@@ -275770,7 +275925,7 @@ var init_harvest_json = __esm({
275770
275925
 
275771
275926
  // ../harvester/src/harvest-disk.ts
275772
275927
  import { createHash as createHash3 } from "crypto";
275773
- import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync2 } from "fs";
275928
+ import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync2 } from "fs";
275774
275929
  import { homedir } from "os";
275775
275930
  import { join as join7, dirname as dirname8 } from "path";
275776
275931
  function depsCacheRoot() {
@@ -275809,7 +275964,7 @@ function diskPath(root, key) {
275809
275964
  function readHarvestDisk(root, key) {
275810
275965
  try {
275811
275966
  const p = diskPath(root, key);
275812
- if (!existsSync9(p)) return void 0;
275967
+ if (!existsSync8(p)) return void 0;
275813
275968
  const parsed = JSON.parse(readFileSync11(p, "utf8"));
275814
275969
  if (parsed?.abi !== HARVEST_DISK_ABI) return void 0;
275815
275970
  return parsed.value;
@@ -275837,10 +275992,10 @@ function listPackageDts(pkg, fromDir, maxFiles) {
275837
275992
  return void 0;
275838
275993
  }
275839
275994
  })();
275840
- let dtsFiles = entry && existsSync9(entry) ? collectDtsFromEntry(entry, Math.max(maxFiles, 24)) : [];
275995
+ let dtsFiles = entry && existsSync8(entry) ? collectDtsFromEntry(entry, Math.max(maxFiles, 24)) : [];
275841
275996
  if (dtsFiles.length === 0) {
275842
275997
  const collected = collectDtsFiles(root, maxFiles);
275843
- dtsFiles = entry && existsSync9(entry) && !collected.includes(entry) ? [entry, ...collected.filter((f) => f !== entry)].slice(0, maxFiles) : collected;
275998
+ dtsFiles = entry && existsSync8(entry) && !collected.includes(entry) ? [entry, ...collected.filter((f) => f !== entry)].slice(0, maxFiles) : collected;
275844
275999
  }
275845
276000
  if (dtsFiles.length === 0) return null;
275846
276001
  return { root, dtsFiles, pkgVersion: readPkgVersion(root) };
@@ -276181,7 +276336,7 @@ var init_harvest_to_abs = __esm({
276181
276336
  });
276182
276337
 
276183
276338
  // ../harvester/src/harvest-node.ts
276184
- import { existsSync as existsSync10, statSync as statSync9, readFileSync as readFileSync12 } from "fs";
276339
+ import { existsSync as existsSync9, statSync as statSync9, readFileSync as readFileSync12 } from "fs";
276185
276340
  import { join as join8 } from "path";
276186
276341
  function notFoundCacheKey(fromDir) {
276187
276342
  return `not-found|@types/node|${fromDir ?? ""}`;
@@ -276265,7 +276420,7 @@ function harvestNodeTypes(fromDir, maxFiles = HARVEST_NODE_DEFAULT_MAX_FILES, ma
276265
276420
  };
276266
276421
  }
276267
276422
  const root = resolvePackageRoot("@types/node", fromDir) ?? resolvePackageRoot("node", fromDir);
276268
- if (!root || !existsSync10(root)) {
276423
+ if (!root || !existsSync9(root)) {
276269
276424
  const missKey = notFoundCacheKey(fromDir);
276270
276425
  const miss = nodeHarvestCache.get(missKey);
276271
276426
  if (miss) {
@@ -277467,7 +277622,7 @@ function evalCacheSlotKey(filePath, mode) {
277467
277622
  function evalDepKey(source, filePath, loadModule) {
277468
277623
  try {
277469
277624
  const fp = loadModuleDepsFingerprint(source, loadModule ?? defaultLoadModule, filePath);
277470
- if (fp.truncated) return null;
277625
+ if (fp.truncated || fp.readError) return null;
277471
277626
  return hashSource(fp.fp);
277472
277627
  } catch {
277473
277628
  return null;
@@ -278241,7 +278396,7 @@ var init_analyzer_orchestrate_calls = __esm({
278241
278396
  });
278242
278397
 
278243
278398
  // ../service/src/entry-variants.ts
278244
- import { existsSync as existsSync11, readFileSync as readFileSync14 } from "fs";
278399
+ import { existsSync as existsSync10, readFileSync as readFileSync14 } from "fs";
278245
278400
  import { dirname as dirname12, join as join9, resolve as resolve8 } from "path";
278246
278401
  function collectConditionFaces(val) {
278247
278402
  const browser = [];
@@ -278355,7 +278510,7 @@ function findOwningPackage(fromFile) {
278355
278510
  const root = resolve8("/");
278356
278511
  for (; ; ) {
278357
278512
  const pkgPath = join9(dir, "package.json");
278358
- if (existsSync11(pkgPath)) {
278513
+ if (existsSync10(pkgPath)) {
278359
278514
  try {
278360
278515
  const pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
278361
278516
  return { path: pkgPath, dir, pkg };
@@ -278672,7 +278827,7 @@ function computeFnDepSegment(source, loadModule, filePath) {
278672
278827
  let fnDepFailClosed = false;
278673
278828
  try {
278674
278829
  const dfp = loadModuleDepsFingerprint(source, loadModule ?? defaultLoadModule, filePath);
278675
- if (dfp.truncated) {
278830
+ if (dfp.truncated || dfp.readError) {
278676
278831
  fnDepFailClosed = true;
278677
278832
  fnDepSeg = null;
278678
278833
  } else {
@@ -279740,7 +279895,7 @@ var init_target_path = __esm({
279740
279895
 
279741
279896
  // ../service/src/analysis-scope.ts
279742
279897
  import { dirname as dirname16 } from "path";
279743
- import { existsSync as existsSync12 } from "fs";
279898
+ import { existsSync as existsSync11 } from "fs";
279744
279899
  function filterDiagnosticsByLevel(diags, level) {
279745
279900
  if (level === "verbose") return diags;
279746
279901
  if (level === "off") return [];
@@ -279784,7 +279939,7 @@ function shouldAnalyzeFile(filePath, source, config) {
279784
279939
  if (cfg.mode === "directives") return false;
279785
279940
  if (text !== void 0 && hasExport(text)) return true;
279786
279941
  try {
279787
- if (existsSync12(sidecarPathOf(filePath))) return true;
279942
+ if (existsSync11(sidecarPathOf(filePath))) return true;
279788
279943
  } catch {
279789
279944
  }
279790
279945
  return false;
@@ -280090,7 +280245,7 @@ import {
280090
280245
  mkdirSync as mkdirSync3,
280091
280246
  readFileSync as readFileSync15,
280092
280247
  writeFileSync as writeFileSync3,
280093
- existsSync as existsSync13,
280248
+ existsSync as existsSync12,
280094
280249
  rmSync,
280095
280250
  renameSync,
280096
280251
  unlinkSync
@@ -280135,7 +280290,7 @@ function monorepoLogicalPath(posixPath) {
280135
280290
  let dir = dirname17(posixPath);
280136
280291
  let workspacesRoot;
280137
280292
  for (; ; ) {
280138
- if (existsSync13(join10(dir, "pnpm-workspace.yaml")) || existsSync13(join10(dir, "lerna.json"))) {
280293
+ if (existsSync12(join10(dir, "pnpm-workspace.yaml")) || existsSync12(join10(dir, "lerna.json"))) {
280139
280294
  return toPosix(relative3(dir, posixPath)) || void 0;
280140
280295
  }
280141
280296
  if (!workspacesRoot) {
@@ -280258,7 +280413,7 @@ var init_disk_cache = __esm({
280258
280413
  if (!this.enabled || !this.root) return void 0;
280259
280414
  try {
280260
280415
  const p = this.pathFor(key);
280261
- if (!existsSync13(p)) return void 0;
280416
+ if (!existsSync12(p)) return void 0;
280262
280417
  const raw = readFileSync15(p, "utf8");
280263
280418
  const parsed = JSON.parse(raw);
280264
280419
  if (parsed?.abi !== ANALYSIS_ABI) return void 0;
@@ -280280,7 +280435,7 @@ var init_disk_cache = __esm({
280280
280435
  } catch {
280281
280436
  if (tmp) {
280282
280437
  try {
280283
- if (existsSync13(tmp)) unlinkSync(tmp);
280438
+ if (existsSync12(tmp)) unlinkSync(tmp);
280284
280439
  } catch {
280285
280440
  }
280286
280441
  }
@@ -280499,7 +280654,7 @@ import {
280499
280654
  mkdirSync as mkdirSync4,
280500
280655
  readFileSync as readFileSync16,
280501
280656
  writeFileSync as writeFileSync4,
280502
- existsSync as existsSync14,
280657
+ existsSync as existsSync13,
280503
280658
  rmSync as rmSync2,
280504
280659
  renameSync as renameSync2,
280505
280660
  unlinkSync as unlinkSync2
@@ -280688,7 +280843,7 @@ function monorepoLogicalPath2(posixPath) {
280688
280843
  let dir = dirname18(posixPath);
280689
280844
  let workspacesRoot;
280690
280845
  for (; ; ) {
280691
- if (existsSync14(join11(dir, "pnpm-workspace.yaml")) || existsSync14(join11(dir, "lerna.json"))) {
280846
+ if (existsSync13(join11(dir, "pnpm-workspace.yaml")) || existsSync13(join11(dir, "lerna.json"))) {
280692
280847
  return toPosix2(relative4(dir, posixPath)) || void 0;
280693
280848
  }
280694
280849
  if (!workspacesRoot) {
@@ -280784,7 +280939,7 @@ var init_chunk_4TAFH6ZZ = __esm({
280784
280939
  if (!this.enabled || !this.root) return void 0;
280785
280940
  try {
280786
280941
  const p = this.pathFor(key);
280787
- if (!existsSync14(p)) return void 0;
280942
+ if (!existsSync13(p)) return void 0;
280788
280943
  const raw = readFileSync16(p, "utf8");
280789
280944
  const parsed = JSON.parse(raw);
280790
280945
  if (parsed?.abi !== ANALYSIS_ABI2) return void 0;
@@ -280806,7 +280961,7 @@ var init_chunk_4TAFH6ZZ = __esm({
280806
280961
  } catch {
280807
280962
  if (tmp) {
280808
280963
  try {
280809
- if (existsSync14(tmp)) unlinkSync2(tmp);
280964
+ if (existsSync13(tmp)) unlinkSync2(tmp);
280810
280965
  } catch {
280811
280966
  }
280812
280967
  }
@@ -280823,8 +280978,8 @@ var init_chunk_4TAFH6ZZ = __esm({
280823
280978
  }
280824
280979
  });
280825
280980
 
280826
- // ../service/dist/chunk-RKFQ6H4V.js
280827
- import { readFileSync as readFileSync17, existsSync as existsSync15, statSync as statSync11, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
280981
+ // ../service/dist/chunk-EGGGBJDA.js
280982
+ import { readFileSync as readFileSync17, existsSync as existsSync14, statSync as statSync11, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
280828
280983
  import { resolve as resolvePath2, join as joinPath2 } from "path";
280829
280984
  import { pathToFileURL as pathToFileURL2 } from "url";
280830
280985
  import { createRequire as createRequire5 } from "module";
@@ -280883,7 +281038,7 @@ function isPathEnvName2(name, baseDir) {
280883
281038
  if (name in envFactories2) return false;
280884
281039
  if (name.includes("/") || name.startsWith("./") || name.startsWith("../")) return true;
280885
281040
  const resolved = resolvePath2(baseDir, name);
280886
- return resolved.endsWith(".ts") && existsSync15(resolved);
281041
+ return resolved.endsWith(".ts") && existsSync14(resolved);
280887
281042
  }
280888
281043
  function rewriteBareImports2(text) {
280889
281044
  const require22 = createRequire5(import.meta.url);
@@ -280990,7 +281145,7 @@ async function preloadPathEnvs2(envNames, baseDir) {
280990
281145
  for (const name of envNames) {
280991
281146
  if (!isPathEnvName2(name, baseDir)) continue;
280992
281147
  const resolved = resolvePath2(baseDir, name);
280993
- if (!existsSync15(resolved)) {
281148
+ if (!existsSync14(resolved)) {
280994
281149
  recordPathEnvError2(resolved, baseDir, new Error(`path env not found: ${resolved}`));
280995
281150
  continue;
280996
281151
  }
@@ -281160,13 +281315,22 @@ function pkgStatFp2(pkgPath) {
281160
281315
  try {
281161
281316
  const st = statSync22(pkgPath);
281162
281317
  return `${st.mtimeMs}:${st.size}`;
281163
- } catch {
281164
- return void 0;
281318
+ } catch (err) {
281319
+ if (err instanceof Error && err.code === "ENOENT") {
281320
+ return void 0;
281321
+ }
281322
+ throw err;
281165
281323
  }
281166
281324
  }
281167
281325
  function projectConfigMemoHit2(entry) {
281168
281326
  for (const { pkgPath, fp } of entry.chain) {
281169
- if (pkgStatFp2(pkgPath) !== fp) return false;
281327
+ let current;
281328
+ try {
281329
+ current = pkgStatFp2(pkgPath);
281330
+ } catch {
281331
+ return false;
281332
+ }
281333
+ if (current !== fp) return false;
281170
281334
  }
281171
281335
  return true;
281172
281336
  }
@@ -281188,7 +281352,18 @@ function findProjectConfig2(startDir) {
281188
281352
  if (hit && projectConfigMemoHit2(hit)) return hit.result;
281189
281353
  while (dir !== root) {
281190
281354
  const pkgPath = resolve10(dir, "package.json");
281191
- const statFp = pkgStatFp2(pkgPath);
281355
+ let statFp;
281356
+ try {
281357
+ statFp = pkgStatFp2(pkgPath);
281358
+ } catch (err) {
281359
+ memoEntry.chain.push({ pkgPath, fp: STAT_ERROR_FP2 });
281360
+ process.stderr?.write?.(
281361
+ `nudo: package.json stat failed at ${pkgPath} (${err instanceof Error ? err.message : String(err)}); project config disabled for this subtree (defaults + env apply)
281362
+ `
281363
+ );
281364
+ applyBForkBudgetFromConfig2(null);
281365
+ return memoize(null);
281366
+ }
281192
281367
  memoEntry.chain.push({ pkgPath, fp: statFp });
281193
281368
  if (statFp !== void 0) {
281194
281369
  let pkg;
@@ -281359,9 +281534,9 @@ function resolveNpmJsEntryDetailed2(source, fromDir) {
281359
281534
  }
281360
281535
  return { path: tryInsidePkg2(pkgDir, subpath, tryFile), exportsUnresolved: false };
281361
281536
  }
281362
- var BUILTIN_ERROR_CLASSES2, BUILTIN_PROTOTYPE_CLASSES2, numA2, strA2, boolA2, unkA2, undefA2, nullA2, OBJECT_PROTOTYPE_METHODS2, BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS2, BoundedLruMap4, envFactories2, impliedDeps2, PATH_ENV_CACHE_MAX2, PATH_ENV_BY_PATH_MAX2, PATH_ENV_BASE_DIRS_MAX2, pathEnvCache2, pathEnvByPath2, pathEnvBaseDirs2, pathEnvFiles2, pathEnvLoadErrors2, DEFAULT_SESSION_CACHE_LIMITS2, HARD_CAP2, explicit2, fromProject2, DEFAULT_ANALYSIS_EXCLUDE2, DEFAULT_ANALYSIS_MODE2, projectConfigMemo2, MAX_PROJECT_CONFIG_MEMO2, projectConfigDiskReads2, JS_CONDITIONS2;
281363
- var init_chunk_RKFQ6H4V = __esm({
281364
- "../service/dist/chunk-RKFQ6H4V.js"() {
281537
+ var BUILTIN_ERROR_CLASSES2, BUILTIN_PROTOTYPE_CLASSES2, numA2, strA2, boolA2, unkA2, undefA2, nullA2, OBJECT_PROTOTYPE_METHODS2, BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS2, BoundedLruMap4, envFactories2, impliedDeps2, PATH_ENV_CACHE_MAX2, PATH_ENV_BY_PATH_MAX2, PATH_ENV_BASE_DIRS_MAX2, pathEnvCache2, pathEnvByPath2, pathEnvBaseDirs2, pathEnvFiles2, pathEnvLoadErrors2, DEFAULT_SESSION_CACHE_LIMITS2, HARD_CAP2, explicit2, fromProject2, DEFAULT_ANALYSIS_EXCLUDE2, DEFAULT_ANALYSIS_MODE2, projectConfigMemo2, MAX_PROJECT_CONFIG_MEMO2, projectConfigDiskReads2, STAT_ERROR_FP2, JS_CONDITIONS2;
281538
+ var init_chunk_EGGGBJDA = __esm({
281539
+ "../service/dist/chunk-EGGGBJDA.js"() {
281365
281540
  "use strict";
281366
281541
  init_src();
281367
281542
  init_es();
@@ -281638,17 +281813,18 @@ var init_chunk_RKFQ6H4V = __esm({
281638
281813
  projectConfigMemo2 = /* @__PURE__ */ new Map();
281639
281814
  MAX_PROJECT_CONFIG_MEMO2 = 128;
281640
281815
  projectConfigDiskReads2 = 0;
281816
+ STAT_ERROR_FP2 = "\0stat-error";
281641
281817
  JS_CONDITIONS2 = ["node", "require", "import", "default", "browser"];
281642
281818
  }
281643
281819
  });
281644
281820
 
281645
- // ../service/dist/chunk-Z2P52JEO.js
281646
- import { existsSync as existsSync16, statSync as statSync12, readFileSync as readFileSync18 } from "fs";
281821
+ // ../service/dist/chunk-MV2LPYT2.js
281822
+ import { statSync as statSync12, readFileSync as readFileSync18 } from "fs";
281647
281823
  import { dirname as dirname20, resolve as resolve11, join as join13 } from "path";
281648
281824
  import { readFileSync as readFileSync42, statSync as statSync33 } from "fs";
281649
281825
  import { dirname as dirname32 } from "path";
281650
281826
  import { dirname as dirname42 } from "path";
281651
- import { existsSync as existsSync42, readFileSync as readFileSync52 } from "fs";
281827
+ import { existsSync as existsSync32, readFileSync as readFileSync52 } from "fs";
281652
281828
  import { dirname as dirname52, join as join32, resolve as resolve42 } from "path";
281653
281829
  import { dirname as dirname82 } from "path";
281654
281830
  import { realpathSync as realpathSync2 } from "fs";
@@ -281664,18 +281840,21 @@ function moduleResolveCandidates2(spec, fromFile) {
281664
281840
  }
281665
281841
  function resolveModuleFile2(spec, fromFile) {
281666
281842
  for (const cand of moduleResolveCandidates2(spec, fromFile)) {
281667
- if (existsSync16(cand) && !statSync12(cand).isDirectory()) return cand;
281843
+ let st;
281844
+ try {
281845
+ st = statSync12(cand);
281846
+ } catch (e) {
281847
+ const code2 = e?.code;
281848
+ if (code2 === "ENOENT" || code2 === "ENOTDIR" || code2 === "EISDIR") continue;
281849
+ throw new ModuleReadError2(cand, e);
281850
+ }
281851
+ if (!st.isDirectory()) return cand;
281668
281852
  }
281669
281853
  return void 0;
281670
281854
  }
281671
281855
  function defaultLoadModule2(spec, fromFile) {
281672
281856
  if (!spec.startsWith(".") && !spec.startsWith("/")) return void 0;
281673
- let cand;
281674
- try {
281675
- cand = resolveModuleFile2(spec, fromFile);
281676
- } catch {
281677
- return void 0;
281678
- }
281857
+ const cand = resolveModuleFile2(spec, fromFile);
281679
281858
  if (!cand) return void 0;
281680
281859
  try {
281681
281860
  return readFileSync18(cand, "utf-8");
@@ -282106,9 +282285,9 @@ function analysisFileCacheKey2(filePath, source, activeCases, externalCallRecord
282106
282285
  let noCache = false;
282107
282286
  try {
282108
282287
  const fp = loadModuleDepsFingerprint(source, effectiveLoader, filePath);
282109
- if (fp.truncated) {
282288
+ if (fp.truncated || fp.readError) {
282110
282289
  noCache = true;
282111
- depSeg = `trunc:${fp.paths.length}`;
282290
+ depSeg = `${fp.truncated ? "trunc" : "readerr"}:${fp.paths.length}`;
282112
282291
  } else {
282113
282292
  depSeg = hashSource(fp.fp);
282114
282293
  }
@@ -283060,7 +283239,7 @@ function evalCacheSlotKey2(filePath, mode) {
283060
283239
  function evalDepKey2(source, filePath, loadModule) {
283061
283240
  try {
283062
283241
  const fp = loadModuleDepsFingerprint(source, loadModule ?? defaultLoadModule2, filePath);
283063
- if (fp.truncated) return null;
283242
+ if (fp.truncated || fp.readError) return null;
283064
283243
  return hashSource(fp.fp);
283065
283244
  } catch {
283066
283245
  return null;
@@ -283805,7 +283984,7 @@ function findOwningPackage2(fromFile) {
283805
283984
  const root = resolve42("/");
283806
283985
  for (; ; ) {
283807
283986
  const pkgPath = join32(dir, "package.json");
283808
- if (existsSync42(pkgPath)) {
283987
+ if (existsSync32(pkgPath)) {
283809
283988
  try {
283810
283989
  const pkg = JSON.parse(readFileSync52(pkgPath, "utf-8"));
283811
283990
  return { path: pkgPath, dir, pkg };
@@ -284186,7 +284365,7 @@ function computeFnDepSegment2(source, loadModule, filePath) {
284186
284365
  let fnDepFailClosed = false;
284187
284366
  try {
284188
284367
  const dfp = loadModuleDepsFingerprint(source, loadModule ?? defaultLoadModule2, filePath);
284189
- if (dfp.truncated) {
284368
+ if (dfp.truncated || dfp.readError) {
284190
284369
  fnDepFailClosed = true;
284191
284370
  fnDepSeg = null;
284192
284371
  } else {
@@ -285150,10 +285329,10 @@ function analyzeFile2(filePath, source, activeCases, externalCallRecords, loadMo
285150
285329
  });
285151
285330
  }
285152
285331
  var MODULE_RESOLVE_EXTS2, ModuleReadError2, neverAbs2, undefAbs4, MAX_RECORD_TYPE_NODES2, ABS_MODULE_CACHE_MAX2, absModuleCache2, ENV_DEPENDENTS_MAX2, ENV_DEPENDENTS_PER_KEY_MAX2, envDependents2, analysisByFile2, fnAnalysisCache2, envHarvestConflictCollectorSlot2, evalRunByFile2, KNOWN_GLOBALS2, DEFAULT_CALLSITE_BUDGET2, COLLAPSE_LITERAL_THRESHOLD2;
285153
- var init_chunk_Z2P52JEO = __esm({
285154
- "../service/dist/chunk-Z2P52JEO.js"() {
285332
+ var init_chunk_MV2LPYT2 = __esm({
285333
+ "../service/dist/chunk-MV2LPYT2.js"() {
285155
285334
  "use strict";
285156
- init_chunk_RKFQ6H4V();
285335
+ init_chunk_EGGGBJDA();
285157
285336
  init_src2();
285158
285337
  init_src();
285159
285338
  init_src2();
@@ -285311,14 +285490,14 @@ __export(emit_exports, {
285311
285490
  wrapReturnNullable: () => wrapReturnNullable,
285312
285491
  writeInterfaceDraft: () => writeInterfaceDraft
285313
285492
  });
285314
- import { readFileSync as readFileSync19, existsSync as existsSync17 } from "fs";
285493
+ import { readFileSync as readFileSync19, existsSync as existsSync15 } from "fs";
285315
285494
  import { dirname as dirname21, resolve as resolve12 } from "path";
285316
285495
  import { existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync6, renameSync as renameSync3, unlinkSync as unlinkSync3 } from "fs";
285317
285496
  import { basename as basename3, dirname as dirname23, relative as relative6, resolve as resolve23 } from "path";
285318
285497
  import { randomBytes as randomBytes3 } from "crypto";
285319
- import { existsSync as existsSync32, readFileSync as readFileSync33, writeFileSync as writeFileSync22, realpathSync as realpathSync3 } from "fs";
285498
+ import { existsSync as existsSync33, readFileSync as readFileSync33, writeFileSync as writeFileSync22, realpathSync as realpathSync3 } from "fs";
285320
285499
  import { basename as basename22, dirname as dirname33, isAbsolute as isAbsolute5, join as join14, relative as relative23 } from "path";
285321
- import { existsSync as existsSync43, readFileSync as readFileSync43 } from "fs";
285500
+ import { existsSync as existsSync42, readFileSync as readFileSync43 } from "fs";
285322
285501
  import { basename as basename32, dirname as dirname43, relative as relative32, resolve as resolve32 } from "path";
285323
285502
  import { relative as relative42, resolve as resolve43 } from "path";
285324
285503
  import { existsSync as existsSync52, readFileSync as readFileSync53, renameSync as renameSync22, unlinkSync as unlinkSync22, writeFileSync as writeFileSync32 } from "fs";
@@ -285380,7 +285559,7 @@ async function interfaceSurface(filePath, opts = {}) {
285380
285559
  if (autoBind !== false) {
285381
285560
  const openSc = loadModule(`./${sc.slice(sc.lastIndexOf("/") + 1)}`, abs2);
285382
285561
  if (openSc !== void 0) sidecarSource = openSc;
285383
- else if (existsSync17(sc)) sidecarSource = readFileSync19(sc, "utf-8");
285562
+ else if (existsSync15(sc)) sidecarSource = readFileSync19(sc, "utf-8");
285384
285563
  }
285385
285564
  } catch {
285386
285565
  sidecarSource = void 0;
@@ -287186,7 +287365,7 @@ function writeInterfaceDraft(filePath, draftSource, opts = {}) {
287186
287365
  }
287187
287366
  }
287188
287367
  const draftable = opts.draftable !== void 0 ? opts.draftable : opts.entries !== void 0 ? isDraftableEntry(opts.entries) : /export\s+const\s+[\p{ID_Start}$_][\p{ID_Continue}$]*\s*=/u.test(draftSource);
287189
- const prev = existsSync32(draftPath) ? readFileSync33(draftPath, "utf-8") : void 0;
287368
+ const prev = existsSync33(draftPath) ? readFileSync33(draftPath, "utf-8") : void 0;
287190
287369
  const changed = prev !== draftSource;
287191
287370
  const written = !opts.dryRun && changed && draftable;
287192
287371
  if (written) {
@@ -287511,7 +287690,7 @@ function importLocalMap(source, fromFile) {
287511
287690
  const raw = resolve32(base, spec);
287512
287691
  let modulePath = null;
287513
287692
  for (const cand of [raw, `${raw}.js`, `${raw}.ts`, `${raw}.mjs`]) {
287514
- if (existsSync43(cand)) {
287693
+ if (existsSync42(cand)) {
287515
287694
  modulePath = cand;
287516
287695
  break;
287517
287696
  }
@@ -287535,7 +287714,7 @@ function deriveFromRoot(filePath, opts = {}) {
287535
287714
  const autoBind = opts.autoBind ?? interfaceConfig2(findProjectConfig2(dirname43(abs2))?.config).autoBind;
287536
287715
  const loadModule = opts.loadModule ?? defaultLoadModule2;
287537
287716
  const sidecarPath = sidecarPathOf(abs2);
287538
- const sidecarSrc = existsSync43(sidecarPath) && !isNodeModulesPath(sidecarPath) ? readFileSync43(sidecarPath, "utf-8") : "";
287717
+ const sidecarSrc = existsSync42(sidecarPath) && !isNodeModulesPath(sidecarPath) ? readFileSync43(sidecarPath, "utf-8") : "";
287539
287718
  const fnNames = topLevelFnNames(source);
287540
287719
  const roots = [];
287541
287720
  const plans = [];
@@ -287663,7 +287842,7 @@ function deriveOneRoot(plan, source, file, modules, importLocals, label) {
287663
287842
  targetFile = file;
287664
287843
  }
287665
287844
  if (isNodeModulesPath(targetFile)) continue;
287666
- if (!existsSync43(targetFile)) continue;
287845
+ if (!existsSync42(targetFile)) continue;
287667
287846
  const key = `${targetFile}::${targetExport}`;
287668
287847
  let agg = byCallee.get(key);
287669
287848
  if (!agg) {
@@ -289748,8 +289927,8 @@ var init_emit2 = __esm({
289748
289927
  "../service/dist/emit/index.js"() {
289749
289928
  "use strict";
289750
289929
  init_chunk_4TAFH6ZZ();
289751
- init_chunk_Z2P52JEO();
289752
- init_chunk_RKFQ6H4V();
289930
+ init_chunk_MV2LPYT2();
289931
+ init_chunk_EGGGBJDA();
289753
289932
  init_src();
289754
289933
  init_src();
289755
289934
  init_internal();
@@ -290011,7 +290190,7 @@ __export(migrate_exports, {
290011
290190
  stripTsToJs: () => stripTsToJs
290012
290191
  });
290013
290192
  import {
290014
- existsSync as existsSync25,
290193
+ existsSync as existsSync21,
290015
290194
  mkdirSync as mkdirSync7,
290016
290195
  readFileSync as readFileSync28,
290017
290196
  readdirSync as readdirSync4,
@@ -290032,7 +290211,7 @@ function readJson(path) {
290032
290211
  }
290033
290212
  function writeFileAtomic(path, data) {
290034
290213
  const dir = dirname29(path);
290035
- if (!existsSync25(dir)) mkdirSync7(dir, { recursive: true });
290214
+ if (!existsSync21(dir)) mkdirSync7(dir, { recursive: true });
290036
290215
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
290037
290216
  try {
290038
290217
  writeFileSync11(tmp, data, "utf-8");
@@ -290050,7 +290229,7 @@ function writeJson(path, value) {
290050
290229
  `);
290051
290230
  }
290052
290231
  function snapshotFile(path) {
290053
- if (!existsSync25(path)) return { path, kind: "missing" };
290232
+ if (!existsSync21(path)) return { path, kind: "missing" };
290054
290233
  try {
290055
290234
  if (statSync16(path).isFile()) {
290056
290235
  return { path, kind: "file", content: readFileSync28(path, "utf-8") };
@@ -290062,7 +290241,7 @@ function snapshotFile(path) {
290062
290241
  }
290063
290242
  function restoreSnapshot(snap) {
290064
290243
  if (snap.kind === "missing") {
290065
- if (existsSync25(snap.path)) rmSync3(snap.path, { force: true });
290244
+ if (existsSync21(snap.path)) rmSync3(snap.path, { force: true });
290066
290245
  return;
290067
290246
  }
290068
290247
  if (snap.kind === "file") writeFileAtomic(snap.path, snap.content);
@@ -290159,7 +290338,7 @@ function unquoteYamlScalar(s) {
290159
290338
  }
290160
290339
  function parsePnpmWorkspacePackages(root) {
290161
290340
  const yamlPath = join18(root, "pnpm-workspace.yaml");
290162
- if (!existsSync25(yamlPath)) return [];
290341
+ if (!existsSync21(yamlPath)) return [];
290163
290342
  let text;
290164
290343
  try {
290165
290344
  text = readFileSync28(yamlPath, "utf-8");
@@ -290221,17 +290400,17 @@ function packageRoots(root) {
290221
290400
  if (w.startsWith("!")) continue;
290222
290401
  if (w.endsWith("/*") || w.endsWith("/**")) {
290223
290402
  const base = join18(root, w.replace(/\/\*\*?$/, ""));
290224
- if (!existsSync25(base)) continue;
290403
+ if (!existsSync21(base)) continue;
290225
290404
  for (const name of readdirSync4(base)) {
290226
290405
  const p = join18(base, name);
290227
- if (!existsSync25(join18(p, "package.json"))) continue;
290406
+ if (!existsSync21(join18(p, "package.json"))) continue;
290228
290407
  if (seen.has(p)) continue;
290229
290408
  seen.add(p);
290230
290409
  roots.push(p);
290231
290410
  }
290232
290411
  } else {
290233
290412
  const p = join18(root, w);
290234
- if (!existsSync25(join18(p, "package.json"))) continue;
290413
+ if (!existsSync21(join18(p, "package.json"))) continue;
290235
290414
  if (seen.has(p)) continue;
290236
290415
  seen.add(p);
290237
290416
  roots.push(p);
@@ -290459,7 +290638,7 @@ function findWorkflowDir(from) {
290459
290638
  let cur = resolve19(from);
290460
290639
  for (let i = 0; i < 6; i++) {
290461
290640
  const wf = join18(cur, ".github", "workflows");
290462
- if (existsSync25(wf) && statSync16(wf).isDirectory()) return wf;
290641
+ if (existsSync21(wf) && statSync16(wf).isDirectory()) return wf;
290463
290642
  const parent = dirname29(cur);
290464
290643
  if (parent === cur) break;
290465
290644
  cur = parent;
@@ -290505,7 +290684,7 @@ function rewriteWorkflowsNear(from, opts = {}) {
290505
290684
  }
290506
290685
  function resolveMigrateRoot(rootDir) {
290507
290686
  const raw = resolve19(rootDir);
290508
- if (!existsSync25(raw)) {
290687
+ if (!existsSync21(raw)) {
290509
290688
  throw new Error(`not found: ${rootDir}`);
290510
290689
  }
290511
290690
  return statSync16(raw).isDirectory() ? raw : dirname29(raw);
@@ -290529,9 +290708,9 @@ function migrateStatus(rootDir) {
290529
290708
  ...pkg?.devDependencies ?? {}
290530
290709
  };
290531
290710
  const markerPath = join18(r, ".nudo", "migrate-retired.json");
290532
- const retired = existsSync25(markerPath) && statSync16(markerPath).isFile();
290711
+ const retired = existsSync21(markerPath) && statSync16(markerPath).isFile();
290533
290712
  const retiringPath = join18(r, ".nudo", "migrate-retiring.json");
290534
- const retiring = !retired && existsSync25(retiringPath) && statSync16(retiringPath).isFile();
290713
+ const retiring = !retired && existsSync21(retiringPath) && statSync16(retiringPath).isFile();
290535
290714
  const blockers = [];
290536
290715
  if (retiring) {
290537
290716
  blockers.push(
@@ -290552,9 +290731,9 @@ function migrateStatus(rootDir) {
290552
290731
  }
290553
290732
  rows.push({
290554
290733
  root: relative12(process.cwd(), r) || ".",
290555
- packageJson: existsSync25(pkgPath),
290734
+ packageJson: existsSync21(pkgPath),
290556
290735
  typescriptDep: Boolean(deps.typescript),
290557
- tsconfig: existsSync25(join18(r, "tsconfig.json")),
290736
+ tsconfig: existsSync21(join18(r, "tsconfig.json")),
290558
290737
  tscScripts,
290559
290738
  tsFiles,
290560
290739
  tsxFiles,
@@ -290594,7 +290773,7 @@ async function migrateStrip(paths, opts = {}) {
290594
290773
  const files = [];
290595
290774
  for (const p of paths) {
290596
290775
  const abs2 = resolve19(p);
290597
- if (!existsSync25(abs2)) {
290776
+ if (!existsSync21(abs2)) {
290598
290777
  throw new Error(`not found: ${p}`);
290599
290778
  }
290600
290779
  if (statSync16(abs2).isDirectory()) {
@@ -290618,9 +290797,9 @@ async function migrateStrip(paths, opts = {}) {
290618
290797
  const outFile = TSX_EXT.has(ext) ? file.replace(/\.tsx$/i, ".jsx") : file.replace(/\.tsx$/i, ".js").replace(/\.mts$/i, ".mjs").replace(/\.cts$/i, ".cjs").replace(/\.ts$/i, ".js");
290619
290798
  const wouldClobberNonTs = outFile === file && !isStripSource(file);
290620
290799
  if (opts.write && !wouldClobberNonTs) {
290621
- if (opts.backup && existsSync25(file) && !existsSync25(`${file}.bak`)) {
290800
+ if (opts.backup && existsSync21(file) && !existsSync21(`${file}.bak`)) {
290622
290801
  renameSync4(file, `${file}.bak`);
290623
- } else if (opts.backup !== true && existsSync25(file) && extname(file).toLowerCase() !== extname(outFile).toLowerCase()) {
290802
+ } else if (opts.backup !== true && existsSync21(file) && extname(file).toLowerCase() !== extname(outFile).toLowerCase()) {
290624
290803
  }
290625
290804
  writeFileSync11(outFile, code2, "utf-8");
290626
290805
  }
@@ -290630,7 +290809,7 @@ async function migrateStrip(paths, opts = {}) {
290630
290809
  const draft = await draftInterface(outFile, { source: code2, bodyAccesses: true });
290631
290810
  if (draft.draftSource && draft.draftSource.trim().length > 0) {
290632
290811
  const sc = sidecarPathOf(outFile);
290633
- if (!existsSync25(sc)) {
290812
+ if (!existsSync21(sc)) {
290634
290813
  mkdirSync7(dirname29(sc), { recursive: true });
290635
290814
  writeFileSync11(sc, draft.draftSource, "utf-8");
290636
290815
  sidecarDraft = sc;
@@ -290670,7 +290849,7 @@ async function migrateVerify(paths, opts = {}) {
290670
290849
  const files = [];
290671
290850
  for (const p of paths) {
290672
290851
  const abs2 = resolve19(p);
290673
- if (!existsSync25(abs2)) {
290852
+ if (!existsSync21(abs2)) {
290674
290853
  throw new Error(`not found: ${p}`);
290675
290854
  }
290676
290855
  if (statSync16(abs2).isDirectory()) {
@@ -290767,7 +290946,7 @@ function migrateRetire(rootDir, opts = {}) {
290767
290946
  mkdirSync7(markerDir, { recursive: true });
290768
290947
  commitWriteSet(root, ops);
290769
290948
  const retiring = join18(markerDir, "migrate-retiring.json");
290770
- if (existsSync25(retiring)) rmSync3(retiring, { force: true });
290949
+ if (existsSync21(retiring)) rmSync3(retiring, { force: true });
290771
290950
  }
290772
290951
  return {
290773
290952
  root: relative12(process.cwd(), root) || ".",
@@ -290941,13 +291120,13 @@ init_src4();
290941
291120
  init_src2();
290942
291121
  init_emit2();
290943
291122
  init_evaluator_api();
290944
- import { readFileSync as readFileSync21, writeFileSync as writeFileSync7, existsSync as existsSync19 } from "fs";
291123
+ import { readFileSync as readFileSync21, writeFileSync as writeFileSync7, existsSync as existsSync17 } from "fs";
290945
291124
  import { resolve as resolve14, dirname as dirname25, basename as basename6 } from "path";
290946
291125
 
290947
291126
  // src/commands/shared.ts
290948
291127
  init_emit2();
290949
291128
  init_src4();
290950
- import { readFileSync as readFileSync20, existsSync as existsSync18, watch, readdirSync as readdirSync3, statSync as statSync13 } from "fs";
291129
+ import { readFileSync as readFileSync20, existsSync as existsSync16, watch, readdirSync as readdirSync3, statSync as statSync13 } from "fs";
290951
291130
  import { resolve as resolve13, dirname as dirname24, relative as relative7, join as join15, basename as basename5 } from "path";
290952
291131
  function usageError(message, fix) {
290953
291132
  console.error(message);
@@ -290989,7 +291168,7 @@ function collectExternalRecords(sites, errorSink) {
290989
291168
  const records = [];
290990
291169
  for (const site of sites) {
290991
291170
  const sitePath = resolve13(site);
290992
- if (!existsSync18(sitePath)) {
291171
+ if (!existsSync16(sitePath)) {
290993
291172
  const err = {
290994
291173
  path: sitePath,
290995
291174
  code: "nudo:path-missing-callsite",
@@ -291021,7 +291200,7 @@ function collectNudoFiles(dir) {
291021
291200
  }
291022
291201
  function resolveTargetsCollect(path) {
291023
291202
  const resolved = resolve13(path);
291024
- if (!existsSync18(resolved)) {
291203
+ if (!existsSync16(resolved)) {
291025
291204
  return {
291026
291205
  targets: [],
291027
291206
  errors: [
@@ -291073,12 +291252,12 @@ function resolveTargets(path) {
291073
291252
  }
291074
291253
  function startWatch(paths, runOne, label, onRoundStart) {
291075
291254
  const resolvedList = paths.map((p) => resolve13(p));
291076
- const isDir = resolvedList.some((p) => existsSync18(p) && statSync13(p).isDirectory());
291255
+ const isDir = resolvedList.some((p) => existsSync16(p) && statSync13(p).isDirectory());
291077
291256
  const primary = resolvedList[0];
291078
291257
  const getFiles = () => {
291079
291258
  const out = [];
291080
291259
  for (const p of resolvedList) {
291081
- if (!existsSync18(p)) continue;
291260
+ if (!existsSync16(p)) continue;
291082
291261
  if (statSync13(p).isDirectory()) out.push(...collectNudoFiles(p));
291083
291262
  else out.push(p);
291084
291263
  }
@@ -291174,7 +291353,7 @@ function startWatch(paths, runOne, label, onRoundStart) {
291174
291353
  debounceTimer = setTimeout(() => {
291175
291354
  const changedFiles = [...pendingChanged];
291176
291355
  pendingChanged.clear();
291177
- if (changedFiles.some((f) => !existsSync18(f))) getAnalysisSession().clear();
291356
+ if (changedFiles.some((f) => !existsSync16(f))) getAnalysisSession().clear();
291178
291357
  runIncremental(changedFiles).catch(() => {
291179
291358
  });
291180
291359
  }, 200);
@@ -291541,7 +291720,7 @@ async function loadCheckCache(filePath, source, opts) {
291541
291720
  if (autoBind !== false) {
291542
291721
  try {
291543
291722
  const scPath = sidecarPathOf(filePath);
291544
- if (existsSync19(scPath)) sidecarContent = readFileSync21(scPath, "utf-8");
291723
+ if (existsSync17(scPath)) sidecarContent = readFileSync21(scPath, "utf-8");
291545
291724
  } catch {
291546
291725
  sidecarContent = null;
291547
291726
  }
@@ -291812,7 +291991,7 @@ async function runCheckFix(opts) {
291812
291991
  const sidecar = sidecarPathOf(file);
291813
291992
  let sidecarText;
291814
291993
  try {
291815
- sidecarText = existsSync19(sidecar) ? readFileSync21(sidecar, "utf-8") : void 0;
291994
+ sidecarText = existsSync17(sidecar) ? readFileSync21(sidecar, "utf-8") : void 0;
291816
291995
  } catch {
291817
291996
  sidecarText = void 0;
291818
291997
  }
@@ -292430,7 +292609,7 @@ function registerTestCommand(program3) {
292430
292609
  // src/commands/contract.ts
292431
292610
  init_emit2();
292432
292611
  init_src4();
292433
- import { readFileSync as readFileSync25, existsSync as existsSync20, statSync as statSync14, writeFileSync as writeFileSync9, realpathSync as realpathSync4 } from "fs";
292612
+ import { readFileSync as readFileSync25, existsSync as existsSync18, statSync as statSync14, writeFileSync as writeFileSync9, realpathSync as realpathSync4 } from "fs";
292434
292613
  import { resolve as resolve16, dirname as dirname27, relative as relative9, join as join16, basename as basename7, isAbsolute as isAbsolute6 } from "path";
292435
292614
  async function runContractPrint(file, records) {
292436
292615
  const { interfaceSurface: interfaceSurface2 } = await Promise.resolve().then(() => (init_emit2(), emit_exports));
@@ -292460,8 +292639,8 @@ async function runContractFromDts(paths, opts) {
292460
292639
  }
292461
292640
  let label = "dts";
292462
292641
  let dtsFiles = [];
292463
- const fileLike = paths.filter((p) => existsSync20(p));
292464
- const barePkgs = paths.filter((p) => !existsSync20(p));
292642
+ const fileLike = paths.filter((p) => existsSync18(p));
292643
+ const barePkgs = paths.filter((p) => !existsSync18(p));
292465
292644
  for (const p of fileLike) {
292466
292645
  const abs2 = resolve16(p);
292467
292646
  if (statSync14(abs2).isDirectory()) {
@@ -292471,7 +292650,7 @@ async function runContractFromDts(paths, opts) {
292471
292650
  dtsFiles.push(abs2);
292472
292651
  } else {
292473
292652
  const sibling = abs2.replace(/\.[cm]?[jt]sx?$/, ".d.ts");
292474
- if (existsSync20(sibling)) dtsFiles.push(sibling);
292653
+ if (existsSync18(sibling)) dtsFiles.push(sibling);
292475
292654
  }
292476
292655
  }
292477
292656
  for (const pkg of barePkgs) {
@@ -292582,7 +292761,7 @@ async function runContractDraft(file, opts) {
292582
292761
  let dir = dirname27(filePath);
292583
292762
  const fsRoot = resolve16("/");
292584
292763
  while (dir !== fsRoot) {
292585
- if (existsSync20(join16(dir, "package.json"))) {
292764
+ if (existsSync18(join16(dir, "package.json"))) {
292586
292765
  projectRoot = dir;
292587
292766
  break;
292588
292767
  }
@@ -293061,7 +293240,7 @@ function registerExportCommand(program3) {
293061
293240
 
293062
293241
  // src/commands/health.ts
293063
293242
  init_src4();
293064
- import { readFileSync as readFileSync27, existsSync as existsSync24, statSync as statSync15 } from "fs";
293243
+ import { readFileSync as readFileSync27, existsSync as existsSync20, statSync as statSync15 } from "fs";
293065
293244
  import { resolve as resolve18, dirname as dirname28 } from "path";
293066
293245
  async function healthFile(filePath, records) {
293067
293246
  const report = { file: displayPathOf(filePath), functions: 0, entryOnly: 0, uncovered: [] };
@@ -293157,7 +293336,7 @@ async function runHealth(paths, opts) {
293157
293336
  const reports = [];
293158
293337
  for (const p of targetPaths) {
293159
293338
  const abs2 = resolve18(p);
293160
- if (!existsSync24(abs2)) {
293339
+ if (!existsSync20(abs2)) {
293161
293340
  reports.push({ file: displayPathOf(abs2), functions: 0, entryOnly: 0, uncovered: [], error: `File not found: ${displayPathOf(abs2)}` });
293162
293341
  continue;
293163
293342
  }