loki-mode 11.40.0 → 11.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/lib/efficiency_cost.py +24 -0
  4. package/autonomy/run.sh +21 -9
  5. package/dashboard/__init__.py +1 -1
  6. package/dashboard/server.py +22 -1
  7. package/docs/CLI-REFERENCE.md +1 -1
  8. package/docs/INSTALLATION.md +1 -1
  9. package/loki-ts/data/model-pricing.json +1 -0
  10. package/loki-ts/dist/loki.js +1097 -1097
  11. package/mcp/__init__.py +1 -1
  12. package/package.json +2 -2
  13. package/packages/control-plane/dist/server.js +218 -198
  14. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  15. package/web-app/dist/assets/{AdminPage-p-RKJjMN.js → AdminPage-CNTe8IVe.js} +1 -1
  16. package/web-app/dist/assets/{Avatar-BjoGcPik.js → Avatar-Oq57sqg7.js} +1 -1
  17. package/web-app/dist/assets/{Badge-B1mLd-79.js → Badge-BvBY8P-y.js} +1 -1
  18. package/web-app/dist/assets/{Button-BjhRKQbb.js → Button-DSSiH2mT.js} +1 -1
  19. package/web-app/dist/assets/{CockpitPage-CkSNSL32.js → CockpitPage-yV3PAqni.js} +1 -1
  20. package/web-app/dist/assets/{ComparePage-B0Aw7I9x.js → ComparePage-CUjIe9kH.js} +1 -1
  21. package/web-app/dist/assets/{ErrorBoundary-BcU3oAZ3.js → ErrorBoundary-BkYiI8Mu.js} +1 -1
  22. package/web-app/dist/assets/{EvidenceReceiptPanel-24LwFgFb.js → EvidenceReceiptPanel-B5A_mXte.js} +1 -1
  23. package/web-app/dist/assets/{GitHubIssuesPanel-CGv0HKPi.js → GitHubIssuesPanel-CdSyKuSm.js} +1 -1
  24. package/web-app/dist/assets/{GitHubPRsPanel-BsdNy2C5.js → GitHubPRsPanel-DoFVLY3f.js} +1 -1
  25. package/web-app/dist/assets/{HomePage-DvVbWUZA.js → HomePage-n2dgK5Rf.js} +2 -2
  26. package/web-app/dist/assets/{LoginPage-BNrAxlRi.js → LoginPage-DJf5ppa-.js} +1 -1
  27. package/web-app/dist/assets/{MagicPage-D2QZjEAZ.js → MagicPage-C6oi6n5F.js} +1 -1
  28. package/web-app/dist/assets/{MetricsPage-BOYkm2zk.js → MetricsPage-YKC6H6Hw.js} +1 -1
  29. package/web-app/dist/assets/{NotFoundPage-BD1VPbHa.js → NotFoundPage-D6BNXQ-G.js} +1 -1
  30. package/web-app/dist/assets/{ProjectPage-BdpZdNHa.js → ProjectPage-B-RwFQHZ.js} +3 -3
  31. package/web-app/dist/assets/{ProjectsPage-CLuLEdxd.js → ProjectsPage-CMtwnrAG.js} +1 -1
  32. package/web-app/dist/assets/{SettingsPage-DRJULFEa.js → SettingsPage-CgNwLhM3.js} +1 -1
  33. package/web-app/dist/assets/{ShowcasePage-C99iNlrf.js → ShowcasePage-CV5c9XWv.js} +1 -1
  34. package/web-app/dist/assets/{SystemSettingsPage-D3MbpQIy.js → SystemSettingsPage-DHbtHp0C.js} +1 -1
  35. package/web-app/dist/assets/{TeamsPage-CiGXZLru.js → TeamsPage-rxUHIlyD.js} +1 -1
  36. package/web-app/dist/assets/{TemplatesPage-ggdmWggo.js → TemplatesPage-CVdb9Qsj.js} +1 -1
  37. package/web-app/dist/assets/{TerminalOutput-Bv6B7E5y.js → TerminalOutput-C2DAZrJj.js} +1 -1
  38. package/web-app/dist/assets/{activity-DjGsvCmy.js → activity-DeLfoFEJ.js} +1 -1
  39. package/web-app/dist/assets/{bell-CGnEzRGV.js → bell-BaxCSff-.js} +1 -1
  40. package/web-app/dist/assets/{bot-CgGaaPS2.js → bot-C6g64uwh.js} +1 -1
  41. package/web-app/dist/assets/{check-BcnYM4Ag.js → check-CMqsq_g-.js} +1 -1
  42. package/web-app/dist/assets/{chevron-left-DEzx71XG.js → chevron-left-B8peFCxO.js} +1 -1
  43. package/web-app/dist/assets/{circle-alert-CxHpfqnB.js → circle-alert-DKRYZ5BY.js} +1 -1
  44. package/web-app/dist/assets/{clock-CTMbchNi.js → clock-DsaglF4d.js} +1 -1
  45. package/web-app/dist/assets/{cloud-COPPnmqG.js → cloud-DaM67nCL.js} +1 -1
  46. package/web-app/dist/assets/{code-xml-C7wRH4hG.js → code-xml-X2JDu7al.js} +1 -1
  47. package/web-app/dist/assets/{database-Ck1WjxAG.js → database-DJPDNG4X.js} +1 -1
  48. package/web-app/dist/assets/{dollar-sign-CHpFeeAJ.js → dollar-sign-DNp3Vo1-.js} +1 -1
  49. package/web-app/dist/assets/{file-code-corner-Bvz4JZkM.js → file-code-corner-B7ZQvYMh.js} +1 -1
  50. package/web-app/dist/assets/{file-plus-DgOe1XY8.js → file-plus-D2jPBtwH.js} +1 -1
  51. package/web-app/dist/assets/{globe-Bm3qr09s.js → globe-a2Gz-HSB.js} +1 -1
  52. package/web-app/dist/assets/{hammer-BlUi98hw.js → hammer-DN2g4Uam.js} +1 -1
  53. package/web-app/dist/assets/{index-4BrDzHz3.js → index-BHto0s0M.js} +3 -3
  54. package/web-app/dist/assets/{layers-Cu_pNTwy.js → layers-DMuVpl3G.js} +1 -1
  55. package/web-app/dist/assets/{loader-circle-ClaYSJIg.js → loader-circle-C5neFR9D.js} +1 -1
  56. package/web-app/dist/assets/{lock-DzFMEjL0.js → lock-xna1m06d.js} +1 -1
  57. package/web-app/dist/assets/{package-LfzNPC_L.js → package-exu1H2r0.js} +1 -1
  58. package/web-app/dist/assets/{plus-DLntn3jw.js → plus-DztHgdhn.js} +1 -1
  59. package/web-app/dist/assets/{refresh-cw-DdUJIS6x.js → refresh-cw-B4J0iaBR.js} +1 -1
  60. package/web-app/dist/assets/{rotate-ccw-D878TXBs.js → rotate-ccw-CTJiHtrD.js} +1 -1
  61. package/web-app/dist/assets/{scroll-text-BfS7Hxli.js → scroll-text-CazL9DFq.js} +1 -1
  62. package/web-app/dist/assets/{server-Dz4fXHHH.js → server-BJsl_c5h.js} +1 -1
  63. package/web-app/dist/assets/{shield-alert-2oLnQ56Z.js → shield-alert-LtiNsIbt.js} +1 -1
  64. package/web-app/dist/assets/{thumbs-up-DV9yRc0e.js → thumbs-up-DI18NmBa.js} +1 -1
  65. package/web-app/dist/assets/{trash-2-ATUWTDSk.js → trash-2-CIJXcrLn.js} +1 -1
  66. package/web-app/dist/assets/{trending-down-Cgn1GMMT.js → trending-down-CT0j-eRX.js} +1 -1
  67. package/web-app/dist/assets/{trending-up-CSF6Y_u6.js → trending-up-vP7_4ir4.js} +1 -1
  68. package/web-app/dist/assets/{upload-jOidrbCO.js → upload-CDRPSXFK.js} +1 -1
  69. package/web-app/dist/assets/{usePolling-Iulf494p.js → usePolling-B0gNIaHu.js} +1 -1
  70. package/web-app/dist/assets/{user-Cez6NU6B.js → user-DspAj71O.js} +1 -1
  71. package/web-app/dist/index.html +1 -1
@@ -7895,6 +7895,24 @@ var init_provider_cost = __esm(() => {
7895
7895
  });
7896
7896
 
7897
7897
  // ../../loki-ts/src/providers/model_routes.ts
7898
+ import { readFileSync as readFileSync21 } from "fs";
7899
+ import { dirname as dirname8, resolve as resolve10 } from "path";
7900
+ import { fileURLToPath as fileURLToPath2 } from "url";
7901
+ function inferenceGeoTable() {
7902
+ try {
7903
+ const p = resolve10(dirname8(fileURLToPath2(import.meta.url)), "..", "..", "data", "model-pricing.json");
7904
+ const t = JSON.parse(readFileSync21(p, "utf8")).inference_geo_multipliers;
7905
+ if (t && typeof t === "object")
7906
+ return t;
7907
+ } catch {}
7908
+ return { us: INFERENCE_GEO_US_FALLBACK };
7909
+ }
7910
+ function inferenceGeoMultiplier(env = process.env) {
7911
+ const geo = (env["LOKI_INFERENCE_GEO"] ?? "").trim().toLowerCase();
7912
+ const m = geo ? inferenceGeoTable()[geo] : undefined;
7913
+ return typeof m === "number" && Number.isFinite(m) && m > 0 ? m : 1;
7914
+ }
7915
+ var INFERENCE_GEO_US_FALLBACK = 1.1;
7898
7916
  var init_model_routes = () => {};
7899
7917
 
7900
7918
  // ../../loki-ts/src/engine10/hooks.ts
@@ -7915,7 +7933,7 @@ function routerMode(env = process.env) {
7915
7933
  var routerEnabled = (env = process.env) => routerMode(env) === "on";
7916
7934
 
7917
7935
  // ../../loki-ts/src/engine10/cost.ts
7918
- import { readdirSync as readdirSync11, readFileSync as readFileSync21 } from "fs";
7936
+ import { readdirSync as readdirSync11, readFileSync as readFileSync22 } from "fs";
7919
7937
  import { join as join28 } from "path";
7920
7938
  function routerTelemetryOn(env = process.env) {
7921
7939
  return routerEnabled(env);
@@ -7955,7 +7973,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
7955
7973
  const parsed = new Map;
7956
7974
  for (const iter of iterations) {
7957
7975
  try {
7958
- parsed.set(iter, JSON.parse(readFileSync21(resultCostPath(lokiRoot, iter), "utf8")));
7976
+ parsed.set(iter, JSON.parse(readFileSync22(resultCostPath(lokiRoot, iter), "utf8")));
7959
7977
  } catch {}
7960
7978
  }
7961
7979
  const own = new Set(iterations);
@@ -7964,7 +7982,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
7964
7982
  if (own.has(iter))
7965
7983
  continue;
7966
7984
  try {
7967
- lookup.push({ iter, rec: JSON.parse(readFileSync21(resultCostPath(lokiRoot, iter), "utf8")) });
7985
+ lookup.push({ iter, rec: JSON.parse(readFileSync22(resultCostPath(lokiRoot, iter), "utf8")) });
7968
7986
  } catch {}
7969
7987
  }
7970
7988
  const verdicts = hooks.costRecords?.resumeVerdicts(lookup) ?? { ambiguous: [], separate: [] };
@@ -8087,9 +8105,9 @@ import {
8087
8105
  writeFileSync as writeFileSync11,
8088
8106
  writeSync as writeSync3
8089
8107
  } from "fs";
8090
- import { dirname as dirname8 } from "path";
8108
+ import { dirname as dirname9 } from "path";
8091
8109
  function durableWriteThenRename(target, body) {
8092
- mkdirSync8(dirname8(target), { recursive: true });
8110
+ mkdirSync8(dirname9(target), { recursive: true });
8093
8111
  const tmp = tmpPathFor(target);
8094
8112
  const fd = openSync5(tmp, "w");
8095
8113
  try {
@@ -8104,7 +8122,7 @@ function durableWriteThenRename(target, body) {
8104
8122
  function fsyncParentDir(target) {
8105
8123
  let dfd = null;
8106
8124
  try {
8107
- dfd = openSync5(dirname8(target), "r");
8125
+ dfd = openSync5(dirname9(target), "r");
8108
8126
  fsyncSync2(dfd);
8109
8127
  } catch {} finally {
8110
8128
  if (dfd !== null) {
@@ -8123,7 +8141,7 @@ function tmpPathFor(target) {
8123
8141
  }
8124
8142
  function atomicWriteText(target, body, opts = {}) {
8125
8143
  if (opts.durable === false) {
8126
- mkdirSync8(dirname8(target), { recursive: true });
8144
+ mkdirSync8(dirname9(target), { recursive: true });
8127
8145
  const tmp = tmpPathFor(target);
8128
8146
  writeFileSync11(tmp, body);
8129
8147
  renameSync5(tmp, target);
@@ -8148,7 +8166,7 @@ function isProcessAlive(pid) {
8148
8166
  function tryAcquire(lockFile) {
8149
8167
  let fd = null;
8150
8168
  try {
8151
- mkdirSync8(dirname8(lockFile), { recursive: true });
8169
+ mkdirSync8(dirname9(lockFile), { recursive: true });
8152
8170
  fd = openSync5(lockFile, "wx");
8153
8171
  writeSync3(fd, `${process.pid}
8154
8172
  `);
@@ -8257,32 +8275,32 @@ var init_atomic = __esm(() => {
8257
8275
  });
8258
8276
 
8259
8277
  // ../../loki-ts/src/runner/budget.ts
8260
- import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync12, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "fs";
8261
- import { dirname as dirname9, join as join29, resolve as resolve10 } from "path";
8262
- import { fileURLToPath as fileURLToPath2 } from "url";
8278
+ import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync12, readFileSync as readFileSync23, writeFileSync as writeFileSync12 } from "fs";
8279
+ import { dirname as dirname10, join as join29, resolve as resolve11 } from "path";
8280
+ import { fileURLToPath as fileURLToPath3 } from "url";
8263
8281
  function loadDefaultMaxCostUsd(dataDirs = [["..", "..", "data"], ["..", "data"]]) {
8264
- const here = dirname9(fileURLToPath2(import.meta.url));
8282
+ const here = dirname10(fileURLToPath3(import.meta.url));
8265
8283
  for (const rel of dataDirs) {
8266
8284
  try {
8267
- const j = JSON.parse(readFileSync22(resolve10(here, ...rel, "model-pricing.json"), "utf8"));
8285
+ const j = JSON.parse(readFileSync23(resolve11(here, ...rel, "model-pricing.json"), "utf8"));
8268
8286
  if (typeof j.default_max_cost_usd === "number" && Number.isFinite(j.default_max_cost_usd) && j.default_max_cost_usd > 0)
8269
8287
  return j.default_max_cost_usd;
8270
8288
  } catch {}
8271
8289
  }
8272
8290
  if (!pricingFallbackWarned) {
8273
8291
  pricingFallbackWarned = true;
8274
- process.stderr.write(`loki: warning: model-pricing.json is missing or unreadable (looked in ${dataDirs.map((r) => resolve10(here, ...r)).join(", ")}); using fallback default max cost $${DEFAULT_FALLBACK_USD}
8292
+ process.stderr.write(`loki: warning: model-pricing.json is missing or unreadable (looked in ${dataDirs.map((r) => resolve11(here, ...r)).join(", ")}); using fallback default max cost $${DEFAULT_FALLBACK_USD}
8275
8293
  `);
8276
8294
  }
8277
8295
  return DEFAULT_FALLBACK_USD;
8278
8296
  }
8279
8297
  function _loadPricing() {
8280
8298
  try {
8281
- const moduleDir = dirname9(fileURLToPath2(import.meta.url));
8282
- const jsonPath = resolve10(moduleDir, "..", "..", "data", "model-pricing.json");
8299
+ const moduleDir = dirname10(fileURLToPath3(import.meta.url));
8300
+ const jsonPath = resolve11(moduleDir, "..", "..", "data", "model-pricing.json");
8283
8301
  if (!existsSync17(jsonPath))
8284
8302
  return _FALLBACK_PRICING;
8285
- const raw2 = JSON.parse(readFileSync22(jsonPath, "utf8"));
8303
+ const raw2 = JSON.parse(readFileSync23(jsonPath, "utf8"));
8286
8304
  const pricing2 = raw2["pricing"];
8287
8305
  if (!pricing2 || typeof pricing2 !== "object")
8288
8306
  return _FALLBACK_PRICING;
@@ -8329,8 +8347,9 @@ function exactIdKey(m) {
8329
8347
  }
8330
8348
  return best;
8331
8349
  }
8332
- function calculateCostFromRecords(records) {
8350
+ function calculateCostFromRecords(records, env = process.env) {
8333
8351
  let total = 0;
8352
+ const geo = inferenceGeoMultiplier(env);
8334
8353
  for (const d of records) {
8335
8354
  if (typeof d.cost_usd === "number" && Number.isFinite(d.cost_usd)) {
8336
8355
  total += d.cost_usd;
@@ -8343,13 +8362,14 @@ function calculateCostFromRecords(records) {
8343
8362
  const cWrite = typeof d.cache_creation_tokens === "number" ? d.cache_creation_tokens : 0;
8344
8363
  const readRate = p.cache_read ?? p.input;
8345
8364
  const writeRate = p.cache_write ?? p.input;
8346
- total += inp / 1e6 * p.input + out2 / 1e6 * p.output + cRead / 1e6 * readRate + cWrite / 1e6 * writeRate;
8365
+ total += (inp / 1e6 * p.input + out2 / 1e6 * p.output + cRead / 1e6 * readRate + cWrite / 1e6 * writeRate) * geo;
8347
8366
  }
8348
8367
  return round4(total);
8349
8368
  }
8350
8369
  var DEFAULT_FALLBACK_USD = 100, pricingFallbackWarned = false, _FALLBACK_PRICING, PRICING, DEFAULT_PRICING_KEY = "sonnet", warnedCorruptBudget;
8351
8370
  var init_budget = __esm(() => {
8352
8371
  init_atomic();
8372
+ init_model_routes();
8353
8373
  init_paths();
8354
8374
  init_cost();
8355
8375
  _FALLBACK_PRICING = {
@@ -8591,8 +8611,8 @@ var init_schema = __esm(() => {
8591
8611
  });
8592
8612
 
8593
8613
  // ../../loki-ts/src/runner/router/history_store.ts
8594
- import { existsSync as existsSync19, mkdirSync as mkdirSync10, readFileSync as readFileSync23, renameSync as renameSync6, rmSync as rmSync6, writeFileSync as writeFileSync13 } from "fs";
8595
- import { resolve as resolve11 } from "path";
8614
+ import { existsSync as existsSync19, mkdirSync as mkdirSync10, readFileSync as readFileSync24, renameSync as renameSync6, rmSync as rmSync6, writeFileSync as writeFileSync13 } from "fs";
8615
+ import { resolve as resolve12 } from "path";
8596
8616
  function validRun(v) {
8597
8617
  if (typeof v !== "object" || v === null)
8598
8618
  return false;
@@ -8600,14 +8620,14 @@ function validRun(v) {
8600
8620
  return typeof r["shape"] === "string" && typeof r["executor"] === "string" && EXECUTORS.includes(r["executor"]) && typeof r["verdict"] === "string" && VERDICTS.includes(r["verdict"]) && (r["owner"] === null || typeof r["owner"] === "string" && OWNERS.includes(r["owner"])) && typeof r["escalated"] === "boolean" && typeof r["usd"] === "number" && Number.isFinite(r["usd"]) && typeof r["wallS"] === "number" && Number.isFinite(r["wallS"]);
8601
8621
  }
8602
8622
  function historyPath(key, cacheRoot) {
8603
- return resolve11(repoCacheDir(key, cacheRoot), HISTORY_FILE);
8623
+ return resolve12(repoCacheDir(key, cacheRoot), HISTORY_FILE);
8604
8624
  }
8605
8625
  function readRunHistory(key, cacheRoot) {
8606
8626
  const path = historyPath(key, cacheRoot);
8607
8627
  if (!existsSync19(path))
8608
8628
  return [];
8609
8629
  try {
8610
- const parsed = JSON.parse(readFileSync23(path, "utf8"));
8630
+ const parsed = JSON.parse(readFileSync24(path, "utf8"));
8611
8631
  const runs2 = parsed?.runs;
8612
8632
  return Array.isArray(runs2) ? runs2.filter(validRun) : [];
8613
8633
  } catch {
@@ -8645,8 +8665,8 @@ var init_history_store = __esm(() => {
8645
8665
 
8646
8666
  // ../../loki-ts/src/project_model/gather.ts
8647
8667
  import { createHash as createHash7 } from "crypto";
8648
- import { closeSync as closeSync6, lstatSync as lstatSync7, openSync as openSync6, readFileSync as readFileSync24, readSync as readSync5 } from "fs";
8649
- import { dirname as dirname10, join as join31 } from "path";
8668
+ import { closeSync as closeSync6, lstatSync as lstatSync7, openSync as openSync6, readFileSync as readFileSync25, readSync as readSync5 } from "fs";
8669
+ import { dirname as dirname11, join as join31 } from "path";
8650
8670
  function listShallow(repoDir) {
8651
8671
  try {
8652
8672
  const out2 = safeGit(repoDir, ["ls-files", "-z"], { maxBuffer: 256 * 1024 * 1024 });
@@ -8656,7 +8676,7 @@ function listShallow(repoDir) {
8656
8676
  }
8657
8677
  }
8658
8678
  function shallowDirs(repoDir) {
8659
- return [...new Set(listShallow(repoDir).map((p) => dirname10(p)))].sort();
8679
+ return [...new Set(listShallow(repoDir).map((p) => dirname11(p)))].sort();
8660
8680
  }
8661
8681
  function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
8662
8682
  const h = createHash7("sha256");
@@ -8674,7 +8694,7 @@ function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
8674
8694
  else {
8675
8695
  const abs = join31(repoDir, f);
8676
8696
  const size = lstatSync7(abs).size;
8677
- h.update(size <= GATHER_CAPS.maxHashBytes ? readFileSync24(abs) : `too-large:${size}`);
8697
+ h.update(size <= GATHER_CAPS.maxHashBytes ? readFileSync25(abs) : `too-large:${size}`);
8678
8698
  }
8679
8699
  } catch {
8680
8700
  h.update("missing");
@@ -8731,8 +8751,8 @@ var init_engine_origin = __esm(() => {
8731
8751
  });
8732
8752
 
8733
8753
  // ../../loki-ts/src/runner/router/history.ts
8734
- import { dirname as dirname11, join as join32, resolve as resolve12 } from "path";
8735
- import { fileURLToPath as fileURLToPath3 } from "url";
8754
+ import { dirname as dirname12, join as join32, resolve as resolve13 } from "path";
8755
+ import { fileURLToPath as fileURLToPath4 } from "url";
8736
8756
  function shapeKey(model) {
8737
8757
  if (!model || model.status !== "ok")
8738
8758
  return null;
@@ -8763,7 +8783,7 @@ var init_history = __esm(() => {
8763
8783
  init_cache();
8764
8784
  init_engine_origin();
8765
8785
  init_history_store();
8766
- SHAPE_DEFAULTS_FILE = resolve12(dirname11(fileURLToPath3(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
8786
+ SHAPE_DEFAULTS_FILE = resolve13(dirname12(fileURLToPath4(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
8767
8787
  });
8768
8788
 
8769
8789
  // ../../loki-ts/src/runner/router/unit_model.ts
@@ -8856,7 +8876,7 @@ var init_model_rank = __esm(() => {
8856
8876
  });
8857
8877
 
8858
8878
  // ../../loki-ts/src/engine10/sizing.ts
8859
- import { existsSync as existsSync20, readFileSync as readFileSync25 } from "fs";
8879
+ import { existsSync as existsSync20, readFileSync as readFileSync26 } from "fs";
8860
8880
  import { basename as basename9 } from "path";
8861
8881
  function namedFiles(task, map) {
8862
8882
  return (map?.files ?? []).filter((f) => task.toLowerCase().includes(basename9(f).toLowerCase()));
@@ -8878,7 +8898,7 @@ function sizeTask(task, map, tests) {
8878
8898
  }
8879
8899
  function loadRepoMap(repomapRef) {
8880
8900
  try {
8881
- return repomapRef && existsSync20(repomapRef) ? JSON.parse(readFileSync25(repomapRef, "utf8")) : null;
8901
+ return repomapRef && existsSync20(repomapRef) ? JSON.parse(readFileSync26(repomapRef, "utf8")) : null;
8882
8902
  } catch {
8883
8903
  return null;
8884
8904
  }
@@ -8940,14 +8960,14 @@ var init_model_downgrades = __esm(() => {
8940
8960
  });
8941
8961
 
8942
8962
  // ../../loki-ts/src/project_model/discover.ts
8943
- import { existsSync as existsSync21, mkdirSync as mkdirSync11, readFileSync as readFileSync26, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "fs";
8963
+ import { existsSync as existsSync21, mkdirSync as mkdirSync11, readFileSync as readFileSync27, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "fs";
8944
8964
  import { join as join34 } from "path";
8945
8965
  function projectModelEnabled(env = process.env) {
8946
8966
  return env["LOKI_E10_PROJECT_MODEL"] !== "0";
8947
8967
  }
8948
8968
  function loadCached(repoDir, now2 = Date.now()) {
8949
8969
  try {
8950
- return parseCached(repoDir, JSON.parse(readFileSync26(join34(repoDir, PROJECT_FILE), "utf8")), now2);
8970
+ return parseCached(repoDir, JSON.parse(readFileSync27(join34(repoDir, PROJECT_FILE), "utf8")), now2);
8951
8971
  } catch {
8952
8972
  return null;
8953
8973
  }
@@ -8962,7 +8982,7 @@ function loadCommitted(repoDir) {
8962
8982
  };
8963
8983
  let raw2;
8964
8984
  try {
8965
- raw2 = JSON.parse(readFileSync26(join34(repoDir, PROJECT_FILE), "utf8"));
8985
+ raw2 = JSON.parse(readFileSync27(join34(repoDir, PROJECT_FILE), "utf8"));
8966
8986
  } catch (e) {
8967
8987
  return ignore(`unreadable JSON (${e instanceof Error ? e.message : String(e)})`);
8968
8988
  }
@@ -9103,8 +9123,8 @@ var init_test_file_text = __esm(() => {
9103
9123
  });
9104
9124
 
9105
9125
  // ../../loki-ts/src/engine10/testmap.ts
9106
- import { existsSync as existsSync22, readFileSync as readFileSync27, realpathSync as realpathSync15 } from "fs";
9107
- import { basename as basename11, dirname as dirname12, extname, isAbsolute as isAbsolute2, join as join36, relative, sep as sep10 } from "path";
9126
+ import { existsSync as existsSync22, readFileSync as readFileSync28, realpathSync as realpathSync15 } from "fs";
9127
+ import { basename as basename11, dirname as dirname13, extname, isAbsolute as isAbsolute2, join as join36, relative, sep as sep10 } from "path";
9108
9128
  function projectInterpreter(root) {
9109
9129
  const ve = process.env["VIRTUAL_ENV"], inRepo = (p) => {
9110
9130
  try {
@@ -9127,8 +9147,8 @@ var init_testmap = __esm(() => {
9127
9147
  // ../../loki-ts/src/util/check_result.ts
9128
9148
  import { spawn as spawn7 } from "child_process";
9129
9149
  import { createHash as createHash8 } from "crypto";
9130
- import { existsSync as existsSync23, mkdirSync as mkdirSync12, readFileSync as readFileSync28, realpathSync as realpathSync16, renameSync as renameSync7, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "fs";
9131
- import { basename as basename12, dirname as dirname13, isAbsolute as isAbsolute3, join as join37, relative as relative2 } from "path";
9150
+ import { existsSync as existsSync23, mkdirSync as mkdirSync12, readFileSync as readFileSync29, realpathSync as realpathSync16, renameSync as renameSync7, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "fs";
9151
+ import { basename as basename12, dirname as dirname14, isAbsolute as isAbsolute3, join as join37, relative as relative2 } from "path";
9132
9152
  function plainTestEnv(base = process.env) {
9133
9153
  const e = {};
9134
9154
  for (const [k, v] of Object.entries(tokenFreeEnv(base)))
@@ -9559,7 +9579,7 @@ function publishableWall(repoDir, runDir, o, env = process.env) {
9559
9579
  if (!hit || rel.startsWith("..") || isAbsolute3(rel) || rel.startsWith(".loki/") || !basename12(rel).startsWith("loki_wall_"))
9560
9580
  continue;
9561
9581
  try {
9562
- const bytes = readFileSync28(join37(runDir, "wall", basename12(rel)));
9582
+ const bytes = readFileSync29(join37(runDir, "wall", basename12(rel)));
9563
9583
  if (createHash8("sha256").update(bytes).digest("hex") !== w["sha256"])
9564
9584
  throw new Error("hash");
9565
9585
  out2.files.push({ rel, bytes, cmd: String(hit["cmd"]) });
@@ -9598,7 +9618,7 @@ function diffFiles(repoDir, baseSha, skip) {
9598
9618
  return f;
9599
9619
  let n2 = 0;
9600
9620
  try {
9601
- n2 = readFileSync28(join37(repoDir, path), "utf8").split(`
9621
+ n2 = readFileSync29(join37(repoDir, path), "utf8").split(`
9602
9622
  `).length;
9603
9623
  } catch {}
9604
9624
  return { path, added: n2, deleted: 0, status: "added" };
@@ -9621,7 +9641,7 @@ function diffFiles(repoDir, baseSha, skip) {
9621
9641
  let text2 = added.get(f.path) ?? "";
9622
9642
  if (!text2 && f.status === "added") {
9623
9643
  try {
9624
- text2 = readFileSync28(join37(repoDir, f.path), "utf8");
9644
+ text2 = readFileSync29(join37(repoDir, f.path), "utf8");
9625
9645
  } catch {}
9626
9646
  }
9627
9647
  const rule = criticalRuleFor(f.path, text2, rules);
@@ -9633,7 +9653,7 @@ function diffFiles(repoDir, baseSha, skip) {
9633
9653
  continue;
9634
9654
  try {
9635
9655
  const oldText = f.status === "added" ? "" : safeGit(repoDir, ["show", `${baseSha}:${f.path}`]);
9636
- const newText = readFileSync28(join37(repoDir, f.path), "utf8");
9656
+ const newText = readFileSync29(join37(repoDir, f.path), "utf8");
9637
9657
  const patch = f.status === "added" ? newText.split(`
9638
9658
  `).map((l) => `+${l}`).join(`
9639
9659
  `) : safeGit(repoDir, ["diff", "-U0", baseSha, "--", f.path]);
@@ -9798,13 +9818,13 @@ async function mapPool(items, jobs, fn, stop = () => false) {
9798
9818
  return out2;
9799
9819
  }
9800
9820
  function spawnCollect(cmd, args, o) {
9801
- return new Promise((resolve13) => {
9821
+ return new Promise((resolve14) => {
9802
9822
  let out2 = "", err = "", error = false, done = false;
9803
9823
  const MAX = 1024 * 1024;
9804
9824
  const fin = (status) => {
9805
9825
  if (!done) {
9806
9826
  done = true;
9807
- resolve13({ status: error ? null : status, output: `${out2}
9827
+ resolve14({ status: error ? null : status, output: `${out2}
9808
9828
  ${err}` });
9809
9829
  }
9810
9830
  };
@@ -9860,7 +9880,7 @@ function runnerCmd(t, repoDir) {
9860
9880
  case "npm":
9861
9881
  return ["npm", ["test", "--silent"]];
9862
9882
  case "go":
9863
- return ["go", ["test", "-json", `./${dirname13(t.path)}`]];
9883
+ return ["go", ["test", "-json", `./${dirname14(t.path)}`]];
9864
9884
  case "cargo":
9865
9885
  return ["cargo", ["test"]];
9866
9886
  }
@@ -9916,11 +9936,11 @@ async function publishWall(git, runId, repoDir, files, done) {
9916
9936
  for (const f of files) {
9917
9937
  const abs = join37(repoDir, f.rel);
9918
9938
  try {
9919
- if (!realpathSync16(dirname13(abs)).startsWith(realpathSync16(repoDir)))
9939
+ if (!realpathSync16(dirname14(abs)).startsWith(realpathSync16(repoDir)))
9920
9940
  return false;
9921
9941
  } catch {}
9922
9942
  rmSync8(abs, { force: true });
9923
- mkdirSync12(dirname13(abs), { recursive: true });
9943
+ mkdirSync12(dirname14(abs), { recursive: true });
9924
9944
  writeFileSync15(abs, f.bytes);
9925
9945
  }
9926
9946
  if ((await git(["--literal-pathspecs", "add", "--", ...rels])).code !== 0 || (await git(["--literal-pathspecs", "commit", "-q", "-m", "test: loki acceptance checks (Wall)", "-m", `Loki-Wall-Publish: ${runId}
@@ -9936,7 +9956,7 @@ var NO_TESTS_REASON = "no tests executed", GO_EXIT0_REASON = "test count could n
9936
9956
  `), tailLines = (out2) => out2.split(`
9937
9957
  `).filter((x) => x.trim()).slice(-12), GO_PKG_RE, EXIT_CODED_COUNT = "n/a (exit-coded check, not a test runner)", FRAMEWORK_RE, SCRIPT_RE, isExecutedProof = (c) => c.result === "pass" && typeof c.n === "number" && c.n > 0, hasExecutedProof = (checks) => checks.some(isExecutedProof), LLM_JUDGES, NON_RUNNER, normPath = (p) => p.replace(/^(?:\.\/)+/, ""), hasExogenousProof = (checks, ctx) => checks.some((c) => isExecutedProof(c) && ((p) => p !== "agent_authored" && p !== "llm_judge")(checkProvenance(c.name ?? "", ctx))), SENSITIVE, API, TEST_CFG, RANK2, FILES_MEDIUM = 4, FILES_HIGH = 15, LINES_MEDIUM = 100, LINES_HIGH = 500, RAN_ALWAYS, REVIEWER_ITEM = "one reviewer", PLAN, LOW_SKIPPED, deferredOf = (tier, selected, executed) => (tier === "low" ? LOW_SKIPPED : selected).filter((c) => !RAN_ALWAYS.includes(c) && !executed.includes(c)), DEEP_ITEMS, NOT_SELECTED = "not selected by risk tier: ", MANIFEST_LOCKS, dirOf = (p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "", PKG_DEP_KEYS, PYPROJECT_NONDEP, SEM_RULES, DOC_FILE, readOr = (p) => {
9938
9958
  try {
9939
- return readFileSync28(p, "utf8");
9959
+ return readFileSync29(p, "utf8");
9940
9960
  } catch {
9941
9961
  return null;
9942
9962
  }
@@ -10013,10 +10033,10 @@ var init_check_result = __esm(() => {
10013
10033
 
10014
10034
  // ../../loki-ts/src/util/receipt_signer.ts
10015
10035
  import { createHash as createHash9, randomBytes as randomBytes3, createPrivateKey, createPublicKey as createPublicKey2, generateKeyPairSync, sign, verify as verify2 } from "crypto";
10016
- import { chmodSync as chmodSync4, linkSync, mkdirSync as mkdirSync13, readdirSync as readdirSync14, readFileSync as readFileSync29, renameSync as renameSync8, statSync as statSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync16 } from "fs";
10036
+ import { chmodSync as chmodSync4, linkSync, mkdirSync as mkdirSync13, readdirSync as readdirSync14, readFileSync as readFileSync30, renameSync as renameSync8, statSync as statSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync16 } from "fs";
10017
10037
  import { homedir as homedir8 } from "os";
10018
10038
  import { spawnSync as spawnSync2 } from "child_process";
10019
- import { dirname as dirname14, join as join38 } from "path";
10039
+ import { dirname as dirname15, join as join38 } from "path";
10020
10040
  function canonicalJson(x) {
10021
10041
  const walk = (v) => {
10022
10042
  if (Array.isArray(v))
@@ -10039,9 +10059,9 @@ function loadSigningKey(generate = true) {
10039
10059
  const given = process.env["LOKI_RECEIPT_SIGNING_KEY_FILE"]?.trim();
10040
10060
  const file = given || join38(process.env["HOME"] || homedir8(), ".loki", "keys", RECEIPT_SIGNER_BASENAME);
10041
10061
  try {
10042
- pem = readFileSync29(file);
10062
+ pem = readFileSync30(file);
10043
10063
  if (!given) {
10044
- for (const [f, m] of [[file, 384], [dirname14(file), 448]])
10064
+ for (const [f, m] of [[file, 384], [dirname15(file), 448]])
10045
10065
  if (statSync15(f).mode & 63)
10046
10066
  chmodSync4(f, m);
10047
10067
  }
@@ -10050,8 +10070,8 @@ function loadSigningKey(generate = true) {
10050
10070
  lastProblem = `signing key file unreadable (${e.code ?? "error"})`;
10051
10071
  if (e.code !== "ENOENT" || !generate)
10052
10072
  return null;
10053
- mkdirSync13(dirname14(dirname14(file)), { recursive: true, mode: 448 });
10054
- mkdirSync13(dirname14(file), { recursive: true, mode: 448 });
10073
+ mkdirSync13(dirname15(dirname15(file)), { recursive: true, mode: 448 });
10074
+ mkdirSync13(dirname15(file), { recursive: true, mode: 448 });
10055
10075
  const tmp = `${file}.${randomBytes3(6).toString("hex")}.tmp`;
10056
10076
  writeFileSync16(tmp, generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" }), { flag: "wx", mode: 384 });
10057
10077
  try {
@@ -10062,7 +10082,7 @@ function loadSigningKey(generate = true) {
10062
10082
  } finally {
10063
10083
  unlinkSync5(tmp);
10064
10084
  }
10065
- pem = readFileSync29(file);
10085
+ pem = readFileSync30(file);
10066
10086
  }
10067
10087
  }
10068
10088
  stage = "parse";
@@ -10195,12 +10215,12 @@ var init_stop_restore = __esm(() => {
10195
10215
  });
10196
10216
 
10197
10217
  // ../../loki-ts/src/util/base_guard.ts
10198
- import { existsSync as existsSync24, readdirSync as readdirSync15, readFileSync as readFileSync30, readlinkSync, realpathSync as realpathSync17, symlinkSync } from "fs";
10199
- import { basename as basename13, join as join39, relative as relative3, resolve as resolve13, sep as sep11 } from "path";
10200
- import { fileURLToPath as fileURLToPath4 } from "url";
10218
+ import { existsSync as existsSync24, readdirSync as readdirSync15, readFileSync as readFileSync31, readlinkSync, realpathSync as realpathSync17, symlinkSync } from "fs";
10219
+ import { basename as basename13, join as join39, relative as relative3, resolve as resolve14, sep as sep11 } from "path";
10220
+ import { fileURLToPath as fileURLToPath5 } from "url";
10201
10221
  function insideAny(p, roots) {
10202
10222
  const under = (q) => roots.some((r) => q === r || q.startsWith(r + sep11));
10203
- if (under(resolve13(p)))
10223
+ if (under(resolve14(p)))
10204
10224
  return true;
10205
10225
  try {
10206
10226
  return under(realpathSync17(p));
@@ -10213,12 +10233,12 @@ function namedPaths(file, text2) {
10213
10233
  if (basename13(file) !== "direct_url.json")
10214
10234
  return out2;
10215
10235
  const url = JSON.parse(text2).url;
10216
- return typeof url === "string" && url.startsWith("file:") ? [...out2, fileURLToPath4(url)] : out2;
10236
+ return typeof url === "string" && url.startsWith("file:") ? [...out2, fileURLToPath5(url)] : out2;
10217
10237
  }
10218
10238
  function depsSeeHead(pkgDir, repoDir) {
10219
10239
  let roots;
10220
10240
  try {
10221
- roots = [...new Set([resolve13(repoDir), realpathSync17(repoDir)])];
10241
+ roots = [...new Set([resolve14(repoDir), realpathSync17(repoDir)])];
10222
10242
  } catch {
10223
10243
  return true;
10224
10244
  }
@@ -10229,7 +10249,7 @@ function depsSeeHead(pkgDir, repoDir) {
10229
10249
  return true;
10230
10250
  const p = join39(dir, e.name);
10231
10251
  if (e.isSymbolicLink()) {
10232
- const t = resolve13(dir, readlinkSync(p));
10252
+ const t = resolve14(dir, readlinkSync(p));
10233
10253
  let rt = t;
10234
10254
  try {
10235
10255
  rt = realpathSync17(t);
@@ -10240,7 +10260,7 @@ function depsSeeHead(pkgDir, repoDir) {
10240
10260
  if (walk(p, own))
10241
10261
  return true;
10242
10262
  } else if (REPO_LINK_FILE.test(e.name)) {
10243
- const text2 = readFileSync30(p, "utf8");
10263
+ const text2 = readFileSync31(p, "utf8");
10244
10264
  if (roots.some((r) => text2.includes(r)) || namedPaths(p, text2).some((n2) => insideAny(n2, roots)))
10245
10265
  return true;
10246
10266
  }
@@ -10251,7 +10271,7 @@ function depsSeeHead(pkgDir, repoDir) {
10251
10271
  return ["node_modules", ".venv"].some((d) => {
10252
10272
  try {
10253
10273
  const top = join39(pkgDir, d);
10254
- return walk(top, [...new Set([resolve13(top), realpathSync17(top)])]);
10274
+ return walk(top, [...new Set([resolve14(top), realpathSync17(top)])]);
10255
10275
  } catch (e) {
10256
10276
  if (e.code === "ENOENT")
10257
10277
  return false;
@@ -11151,8 +11171,8 @@ var init_state = __esm(() => {
11151
11171
 
11152
11172
  // ../../loki-ts/src/runner/repo_profile.ts
11153
11173
  import { spawnSync as spawnSync3 } from "child_process";
11154
- import { existsSync as existsSync25, lstatSync as lstatSync10, readFileSync as readFileSync31, mkdirSync as mkdirSync14, readdirSync as readdirSync16, renameSync as renameSync9, rmSync as rmSync9, writeFileSync as writeFileSync17 } from "fs";
11155
- import { basename as basename14, join as join40, resolve as resolve14, isAbsolute as isAbsolute4 } from "path";
11174
+ import { existsSync as existsSync25, lstatSync as lstatSync10, readFileSync as readFileSync32, mkdirSync as mkdirSync14, readdirSync as readdirSync16, renameSync as renameSync9, rmSync as rmSync9, writeFileSync as writeFileSync17 } from "fs";
11175
+ import { basename as basename14, join as join40, resolve as resolve15, isAbsolute as isAbsolute4 } from "path";
11156
11176
  function detectFormatters(repoDir) {
11157
11177
  const out2 = [];
11158
11178
  const has = (...fs2) => fs2.some((f) => existsSync25(join40(repoDir, f)));
@@ -11191,7 +11211,7 @@ function runFormatters(repoDir, files, env) {
11191
11211
  }
11192
11212
  function loadProfile(repoDir) {
11193
11213
  try {
11194
- const p = JSON.parse(readFileSync31(commandProfilePath(repoDir), "utf8"));
11214
+ const p = JSON.parse(readFileSync32(commandProfilePath(repoDir), "utf8"));
11195
11215
  return p?.version === 1 && Array.isArray(p.commands) && p.baseline ? p : null;
11196
11216
  } catch {
11197
11217
  return null;
@@ -11295,7 +11315,7 @@ async function staticPreExisting(tool, prefix, files, io) {
11295
11315
  }
11296
11316
  var commandProfilePath = (repoDir) => join40(repoDir, ".loki", "state", "repo-profile.json"), read = (p) => {
11297
11317
  try {
11298
- return readFileSync31(p, "utf8");
11318
+ return readFileSync32(p, "utf8");
11299
11319
  } catch {
11300
11320
  return "";
11301
11321
  }
@@ -11341,7 +11361,7 @@ var init_context = __esm(() => {
11341
11361
  });
11342
11362
 
11343
11363
  // ../../loki-ts/src/util/steer.ts
11344
- import { appendFileSync as appendFileSync2, closeSync as closeSync8, constants as constants2, fstatSync as fstatSync6, readdirSync as readdirSync17, lstatSync as lstatSync11, mkdirSync as mkdirSync15, linkSync as linkSync2, openSync as openSync8, readFileSync as readFileSync32, readSync as readSync7, renameSync as renameSync10, statSync as statSync16, lutimesSync, rmSync as rmSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18, existsSync as existsSync26 } from "fs";
11364
+ import { appendFileSync as appendFileSync2, closeSync as closeSync8, constants as constants2, fstatSync as fstatSync6, readdirSync as readdirSync17, lstatSync as lstatSync11, mkdirSync as mkdirSync15, linkSync as linkSync2, openSync as openSync8, readFileSync as readFileSync33, readSync as readSync7, renameSync as renameSync10, statSync as statSync16, lutimesSync, rmSync as rmSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18, existsSync as existsSync26 } from "fs";
11345
11365
  import { createHash as createHash10, randomBytes as randomBytes4 } from "crypto";
11346
11366
  import { basename as basename15, join as join41 } from "path";
11347
11367
  function archiveTo(logs, prefix, src, link = linkSync2, onLinked) {
@@ -11559,7 +11579,7 @@ function recordRevisions(repoDir, text2, archived, at) {
11559
11579
  const file = join41(repoDir, ".loki", "intent-revisions.jsonl");
11560
11580
  let last = 0;
11561
11581
  try {
11562
- for (const l of readFileSync32(file, "utf8").split(`
11582
+ for (const l of readFileSync33(file, "utf8").split(`
11563
11583
  `)) {
11564
11584
  try {
11565
11585
  last = Math.max(last, Number(JSON.parse(l).rev) || 0);
@@ -11625,8 +11645,8 @@ var init_steer = __esm(() => {
11625
11645
 
11626
11646
  // ../../loki-ts/src/util/run_outputs.ts
11627
11647
  import { createHash as createHash11 } from "crypto";
11628
- import { existsSync as existsSync27, mkdirSync as mkdirSync16, readdirSync as readdirSync18, readFileSync as readFileSync33, statSync as statSync17, writeFileSync as writeFileSync19 } from "fs";
11629
- import { join as join42, resolve as resolve15 } from "path";
11648
+ import { existsSync as existsSync27, mkdirSync as mkdirSync16, readdirSync as readdirSync18, readFileSync as readFileSync34, statSync as statSync17, writeFileSync as writeFileSync19 } from "fs";
11649
+ import { join as join42, resolve as resolve16 } from "path";
11630
11650
  function intentRevisionsBlock(revs) {
11631
11651
  const r = (revs ?? []).filter((r2) => r2.unapplied !== true).map(({ rev, source, actor, sha: sha2 }) => ({ rev, source, actor, sha: sha2 }));
11632
11652
  return r.length ? { intent_revisions: r } : {};
@@ -11634,11 +11654,11 @@ function intentRevisionsBlock(revs) {
11634
11654
  function seededCorpusBlock(env = process.env) {
11635
11655
  const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join42(REPO_ROOT, "benchmarks", "seeded-defects");
11636
11656
  try {
11637
- const bytes = readFileSync33(join42(dir, "manifest.json")), version2 = createHash11("sha256").update(bytes).digest("hex");
11657
+ const bytes = readFileSync34(join42(dir, "manifest.json")), version2 = createHash11("sha256").update(bytes).digest("hex");
11638
11658
  const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
11639
11659
  let rate = null;
11640
11660
  try {
11641
- const res = JSON.parse(readFileSync33(join42(dir, "results", "wrong-pass.json"), "utf8"));
11661
+ const res = JSON.parse(readFileSync34(join42(dir, "results", "wrong-pass.json"), "utf8"));
11642
11662
  const runs2 = res.manifest_sha256 === version2 && Array.isArray(res.runs) ? res.runs : [];
11643
11663
  const complete = (o) => !!o && Object.keys(o).length === ids.length && ids.every((id) => typeof id === "string" && (o[id] === "SEALED" || o[id] === "NOT_SEALED"));
11644
11664
  const top = runs2.filter((r) => r.setup === "top"), floor = runs2.filter((r) => r.setup === "floor");
@@ -11922,7 +11942,7 @@ var init_registry2 = __esm(() => {
11922
11942
 
11923
11943
  // ../../loki-ts/src/features/receipt_dsse.ts
11924
11944
  import { createPublicKey as createPublicKey3, sign as sign2, verify as verify3 } from "crypto";
11925
- import { readFileSync as readFileSync34 } from "fs";
11945
+ import { readFileSync as readFileSync35 } from "fs";
11926
11946
  function pae(payloadType, body) {
11927
11947
  const t = Buffer.from(payloadType, "utf8");
11928
11948
  return Buffer.concat([Buffer.from(`DSSEv1 ${t.length} `), t, Buffer.from(` ${body.length} `), body]);
@@ -11999,7 +12019,7 @@ function verifyDsseReceipt(env, d) {
11999
12019
  }
12000
12020
  function runIdGuard(receiptPath, runId2) {
12001
12021
  try {
12002
- return envelopeRunIdProblem(JSON.parse(readFileSync34(receiptPath, "utf8")), runId2);
12022
+ return envelopeRunIdProblem(JSON.parse(readFileSync35(receiptPath, "utf8")), runId2);
12003
12023
  } catch {
12004
12024
  return null;
12005
12025
  }
@@ -12128,9 +12148,9 @@ var init_run_cap = __esm(() => {
12128
12148
  });
12129
12149
 
12130
12150
  // ../../loki-ts/src/util/mutation_proof.ts
12131
- import { existsSync as existsSync28, mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync3, readFileSync as readFileSync35, rmSync as rmSync11, symlinkSync as symlinkSync2, writeFileSync as writeFileSync20 } from "fs";
12151
+ import { existsSync as existsSync28, mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync3, readFileSync as readFileSync36, rmSync as rmSync11, symlinkSync as symlinkSync2, writeFileSync as writeFileSync20 } from "fs";
12132
12152
  import { tmpdir as tmpdir4 } from "os";
12133
- import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute6, join as join44, relative as relative5 } from "path";
12153
+ import { basename as basename16, dirname as dirname16, isAbsolute as isAbsolute6, join as join44, relative as relative5 } from "path";
12134
12154
  function mutationProof(i) {
12135
12155
  const rels = i.wallFiles.map((f) => isAbsolute6(f.path) ? relative5(i.repoDir, f.path) : f.path);
12136
12156
  if (rels.length === 0)
@@ -12158,8 +12178,8 @@ function mutationProof(i) {
12158
12178
  const sealed = join44(i.runDir, "wall", basename16(rel)), src = existsSync28(sealed) ? sealed : join44(i.repoDir, rel);
12159
12179
  if (!existsSync28(src))
12160
12180
  return np(`Wall file missing: ${rel}`);
12161
- mkdirSync17(dirname15(join44(wt, rel)), { recursive: true });
12162
- writeFileSync20(join44(wt, rel), readFileSync35(src));
12181
+ mkdirSync17(dirname16(join44(wt, rel)), { recursive: true });
12182
+ writeFileSync20(join44(wt, rel), readFileSync36(src));
12163
12183
  }
12164
12184
  for (const rel of rels) {
12165
12185
  const parts = rel.split("/").slice(0, -1);
@@ -12343,7 +12363,7 @@ var init_shell = __esm(() => {
12343
12363
  });
12344
12364
 
12345
12365
  // ../../loki-ts/src/util/python.ts
12346
- import { accessSync, constants as constants3, existsSync as existsSync29, mkdtempSync as mkdtempSync4, readFileSync as readFileSync36, realpathSync as realpathSync19, rmSync as rmSync12, statSync as statSync18 } from "fs";
12366
+ import { accessSync, constants as constants3, existsSync as existsSync29, mkdtempSync as mkdtempSync4, readFileSync as readFileSync37, realpathSync as realpathSync19, rmSync as rmSync12, statSync as statSync18 } from "fs";
12347
12367
  import { spawnSync as spawnSync4 } from "child_process";
12348
12368
  import { tmpdir as tmpdir5 } from "os";
12349
12369
  async function findPython3() {
@@ -12701,7 +12721,7 @@ var init_wall_manifest = __esm(() => {
12701
12721
 
12702
12722
  // ../../loki-ts/src/features/wall_manifest_wire.ts
12703
12723
  import { createHash as createHash13 } from "crypto";
12704
- import { basename as basename17, dirname as dirname16 } from "path";
12724
+ import { basename as basename17, dirname as dirname17 } from "path";
12705
12725
  function blobEntries(ls) {
12706
12726
  const out2 = [];
12707
12727
  for (const raw2 of ls.toString("latin1").split("\x00")) {
@@ -12731,7 +12751,7 @@ function wallManifestFor(repoDir, tree, task, env = process.env) {
12731
12751
  return null;
12732
12752
  const low = task.toLowerCase().replace(/\\/g, "/");
12733
12753
  const token = (n2) => new RegExp(`(?<![A-Za-z0-9_])${n2.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![A-Za-z0-9_])`).test(low);
12734
- const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(basename17(e.path)) && e.path.includes("/") && token(dirname16(e.path));
12754
+ const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(basename17(e.path)) && e.path.includes("/") && token(dirname17(e.path));
12735
12755
  const matched = all.filter((e) => SOURCE.test(e.path) && (token(basename17(e.path)) || token(e.path) || token(basename17(e.path).replace(/\.[^.]*$/, "")) || dirModule(e)));
12736
12756
  const spans = (p) => [...low.matchAll(new RegExp(`(?<![A-Za-z0-9_])${p.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![A-Za-z0-9_])`, "g"))].map((m) => [m.index, m.index + m[0].length]);
12737
12757
  const occ = new Map(matched.map((e) => [e, spans(e.path)]));
@@ -12793,7 +12813,7 @@ Example: test('name', () => { assert.strictEqual(fn(1), 2); }); Run: node --tes
12793
12813
 
12794
12814
  // ../../loki-ts/src/util/holdout.ts
12795
12815
  import { createHash as createHash14 } from "crypto";
12796
- import { appendFileSync as appendFileSync3, copyFileSync as copyFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync18, readFileSync as readFileSync37, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "fs";
12816
+ import { appendFileSync as appendFileSync3, copyFileSync as copyFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync18, readFileSync as readFileSync38, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "fs";
12797
12817
  import { tmpdir as tmpdir6 } from "os";
12798
12818
  import { basename as basename18, join as join45, relative as relative6 } from "path";
12799
12819
  function wallHoldoutRatio(env = process.env) {
@@ -12828,7 +12848,7 @@ function stashHoldout(o) {
12828
12848
  const files = held.map((name) => {
12829
12849
  copyFileSync2(join45(o.srcDir, name), join45(dir, name));
12830
12850
  rmSync13(join45(o.srcDir, name), { force: true });
12831
- return { name, runner: o.runnerOf(name), sha256: sha2(readFileSync37(join45(dir, name), "utf8")) };
12851
+ return { name, runner: o.runnerOf(name), sha256: sha2(readFileSync38(join45(dir, name), "utf8")) };
12832
12852
  });
12833
12853
  writeFileSync21(join45(dir, MANIFEST), JSON.stringify({ targetDir: o.targetDir, files }));
12834
12854
  return { dir, names: new Set(held) };
@@ -12837,14 +12857,14 @@ function stageHoldout(dir, repoDir) {
12837
12857
  const put = [], tests = [], missing = [];
12838
12858
  let man = null;
12839
12859
  try {
12840
- man = JSON.parse(readFileSync37(join45(dir, MANIFEST), "utf8"));
12860
+ man = JSON.parse(readFileSync38(join45(dir, MANIFEST), "utf8"));
12841
12861
  } catch {}
12842
12862
  if (!man)
12843
12863
  return { tests, missing: [`holdout store unreadable: ${basename18(dir)}`], cleanup: () => {} };
12844
12864
  mkdirSync18(man.targetDir, { recursive: true });
12845
12865
  man.files.forEach((f, i) => {
12846
12866
  const src = join45(dir, f.name);
12847
- if (!existsSync30(src) || sha2(readFileSync37(src, "utf8")) !== f.sha256) {
12867
+ if (!existsSync30(src) || sha2(readFileSync38(src, "utf8")) !== f.sha256) {
12848
12868
  missing.push(`holdout ${i + 1} missing or altered`);
12849
12869
  return;
12850
12870
  }
@@ -13172,8 +13192,8 @@ var init_install = __esm(() => {
13172
13192
  });
13173
13193
 
13174
13194
  // ../../loki-ts/src/features/runner_config.ts
13175
- import { readFileSync as readFileSync38 } from "fs";
13176
- import { dirname as dirname17, join as join48, normalize as normalize2 } from "path";
13195
+ import { readFileSync as readFileSync39 } from "fs";
13196
+ import { dirname as dirname18, join as join48, normalize as normalize2 } from "path";
13177
13197
  function tomlKey2(s, i = 0, eq2 = true) {
13178
13198
  const parts = [], ws = () => {
13179
13199
  while (/\s/.test(s[i] ?? "x"))
@@ -13448,7 +13468,7 @@ function referenced(cfg, text2) {
13448
13468
  if (v && !/[$*]/.test(v))
13449
13469
  raw2.push(v);
13450
13470
  }
13451
- const dir = dirname17(cfg), explicit = ROOT_DIR.exec(text2), roots = [dir];
13471
+ const dir = dirname18(cfg), explicit = ROOT_DIR.exec(text2), roots = [dir];
13452
13472
  if (explicit)
13453
13473
  roots.push("", ...explicit[1] ? [join48(dir, explicit[1])] : []);
13454
13474
  return [...raw2.flatMap((r) => r.startsWith("/") ? [normalize2(r.slice(1))] : roots.map((root) => normalize2(join48(root, r.replace(/^<rootDir>\/?/, ""))))), ...patchedTargets(cfg, text2).map((t) => normalize2(join48(dir, t)))];
@@ -13499,7 +13519,7 @@ function runnerConfigNotes(repoDir, baseSha, head, changed, signal) {
13499
13519
  bad = true;
13500
13520
  }
13501
13521
  if (bad) {
13502
- const dir = dirname17(cfg), loaded = [...ch].find((c) => c !== cfg && (dir === "." || c.startsWith(dir + "/")) && !NON_SOURCE.test(c));
13522
+ const dir = dirname18(cfg), loaded = [...ch].find((c) => c !== cfg && (dir === "." || c.startsWith(dir + "/")) && !NON_SOURCE.test(c));
13503
13523
  if (ch.has(cfg) || loaded)
13504
13524
  notes.add(`runner config unparseable, trust capped: ${cfg}${loaded ? ` (${loaded} changed and may be loaded by it)` : ""}`);
13505
13525
  }
@@ -13531,7 +13551,7 @@ var PKG_KEYS, RAW_CONFIGS, RUNNER_CONFIGS, DEP_MAPS, RUNNER_DEP, LOCAL_SPEC, dep
13531
13551
  }
13532
13552
  }, headText = (dir, f) => {
13533
13553
  try {
13534
- return readFileSync38(join48(dir, f), "utf8");
13554
+ return readFileSync39(join48(dir, f), "utf8");
13535
13555
  } catch {
13536
13556
  return "";
13537
13557
  }
@@ -13571,7 +13591,7 @@ var init_runner_config = __esm(() => {
13571
13591
 
13572
13592
  // ../../loki-ts/src/e10ext/assert_delta.ts
13573
13593
  import { execFileSync as execFileSync4 } from "child_process";
13574
- import { mkdtempSync as mkdtempSync6, readFileSync as readFileSync39, rmSync as rmSync15 } from "fs";
13594
+ import { mkdtempSync as mkdtempSync6, readFileSync as readFileSync40, rmSync as rmSync15 } from "fs";
13575
13595
  import { tmpdir as tmpdir8 } from "os";
13576
13596
  import { join as join49 } from "path";
13577
13597
  import { basename as basename20 } from "path";
@@ -13614,7 +13634,7 @@ function assertDeltaNotes(repoDir, baseSha, headRef, path, task, baseCounts, hea
13614
13634
  return null;
13615
13635
  try {
13616
13636
  const show = (ref) => safeGit(repoDir, ["show", `${ref}:${path}`]);
13617
- const head = headRef ? show(headRef) : readFileSync39(join49(repoDir, path), "utf8");
13637
+ const head = headRef ? show(headRef) : readFileSync40(join49(repoDir, path), "utf8");
13618
13638
  const r = classifyTestEdit(path, show(baseSha), head, task, baseCounts, headCounts);
13619
13639
  return r[0]?.kind === "literal-only" ? r.map((e) => `assertion value changed (not shown to be required by the task): ${e.file}:${e.line} ${e.old} -> ${e.new}`) : null;
13620
13640
  } catch {
@@ -13843,11 +13863,11 @@ var init_wall_owned = __esm(() => {
13843
13863
 
13844
13864
  // ../../loki-ts/src/util/app_probe.ts
13845
13865
  import { spawnSync as spawnSync6 } from "child_process";
13846
- import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as readFileSync40, renameSync as renameSync11, writeFileSync as writeFileSync22 } from "fs";
13866
+ import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as readFileSync41, renameSync as renameSync11, writeFileSync as writeFileSync22 } from "fs";
13847
13867
  import { join as join51 } from "path";
13848
13868
  function readJson4(p) {
13849
13869
  try {
13850
- const v = JSON.parse(readFileSync40(p, "utf8"));
13870
+ const v = JSON.parse(readFileSync41(p, "utf8"));
13851
13871
  return v && typeof v === "object" ? v : null;
13852
13872
  } catch {
13853
13873
  return null;
@@ -13879,7 +13899,7 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
13879
13899
  return { checks, pid, url };
13880
13900
  }
13881
13901
  const ir = Number(m[1]), sr = Number(m[2]), hr = Number(m[3]), noApp = m[4] === "1";
13882
- const pidTxt = existsSync31(join51(dir, "app.pid")) ? readFileSync40(join51(dir, "app.pid"), "utf8").trim() : "";
13902
+ const pidTxt = existsSync31(join51(dir, "app.pid")) ? readFileSync41(join51(dir, "app.pid"), "utf8").trim() : "";
13883
13903
  pid = /^\d+$/.test(pidTxt) && sr >= 0 ? Number(pidTxt) : null;
13884
13904
  const st = readJson4(join51(dir, "state.json"));
13885
13905
  url = typeof st?.["url"] === "string" ? st["url"] : null;
@@ -13956,10 +13976,10 @@ app_runner_stop >/dev/null 2>&1
13956
13976
  });
13957
13977
 
13958
13978
  // ../../loki-ts/src/util/secure_scan.ts
13959
- import { existsSync as existsSync32, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync7, readFileSync as readFileSync41, realpathSync as realpathSync21, rmSync as rmSync16, statSync as statSync19, writeFileSync as writeFileSync23 } from "fs";
13979
+ import { existsSync as existsSync32, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync7, readFileSync as readFileSync42, realpathSync as realpathSync21, rmSync as rmSync16, statSync as statSync19, writeFileSync as writeFileSync23 } from "fs";
13960
13980
  import { randomBytes as randomBytes5 } from "crypto";
13961
13981
  import { tmpdir as tmpdir9 } from "os";
13962
- import { basename as basename21, dirname as dirname18, join as join52, resolve as resolve16, sep as sep12 } from "path";
13982
+ import { basename as basename21, dirname as dirname19, join as join52, resolve as resolve17, sep as sep12 } from "path";
13963
13983
  function fail(error) {
13964
13984
  return { ok: false, findings: [], error };
13965
13985
  }
@@ -14149,7 +14169,7 @@ async function scanAddedLines(repoDir, opts = {}) {
14149
14169
  continue;
14150
14170
  }
14151
14171
  const lines2 = new Map;
14152
- readFileSync41(join52(repoDir, p), "utf8").split(`
14172
+ readFileSync42(join52(repoDir, p), "utf8").split(`
14153
14173
  `).forEach((t, i) => lines2.set(i + 1, t));
14154
14174
  added.set(p, lines2);
14155
14175
  } catch {}
@@ -14158,14 +14178,14 @@ async function scanAddedLines(repoDir, opts = {}) {
14158
14178
  return { ok: true, findings: skipped2 };
14159
14179
  const mirror = mkdtempSync7(join52(tmpdir9(), "loki-secure-added-"));
14160
14180
  try {
14161
- const root = resolve16(mirror) + sep12;
14181
+ const root = resolve17(mirror) + sep12;
14162
14182
  const chunkMap = new Map;
14163
14183
  const chunkRoot = `.loki-chunks-${randomBytes5(6).toString("hex")}`;
14164
14184
  let chunkSeq = 0;
14165
14185
  for (const [p, lines2] of added) {
14166
14186
  if (lines2.size === 0)
14167
14187
  continue;
14168
- const dest = resolve16(mirror, p);
14188
+ const dest = resolve17(mirror, p);
14169
14189
  if (!dest.startsWith(root))
14170
14190
  continue;
14171
14191
  let max = 0;
@@ -14203,11 +14223,11 @@ async function scanAddedLines(repoDir, opts = {}) {
14203
14223
  const whole = chunks.length === 1;
14204
14224
  for (const c of chunks) {
14205
14225
  const rel = whole ? p : join52(chunkRoot, String(chunkSeq++), basename21(p));
14206
- const out2 = whole ? dest : resolve16(mirror, rel);
14226
+ const out2 = whole ? dest : resolve17(mirror, rel);
14207
14227
  if (!out2.startsWith(root))
14208
14228
  break;
14209
14229
  chunkMap.set(rel, { file: p, lines: c.orig });
14210
- mkdirSync20(dirname18(out2), { recursive: true });
14230
+ mkdirSync20(dirname19(out2), { recursive: true });
14211
14231
  writeFileSync23(out2, c.body.join(`
14212
14232
  `) + `
14213
14233
  `);
@@ -14257,8 +14277,8 @@ var init_secure_scan = __esm(() => {
14257
14277
  var init_retry_class = () => {};
14258
14278
 
14259
14279
  // ../../loki-ts/src/project_model/conventions.ts
14260
- import { existsSync as existsSync33, readdirSync as readdirSync19, readFileSync as readFileSync42 } from "fs";
14261
- import { basename as basename22, dirname as dirname19, isAbsolute as isAbsolute9, join as join53, relative as relative9, resolve as resolve17 } from "path";
14280
+ import { existsSync as existsSync33, readdirSync as readdirSync19, readFileSync as readFileSync43 } from "fs";
14281
+ import { basename as basename22, dirname as dirname20, isAbsolute as isAbsolute9, join as join53, relative as relative9, resolve as resolve18 } from "path";
14262
14282
  function parseJsonc(text2) {
14263
14283
  let out2 = "", i = 0;
14264
14284
  while (i < text2.length) {
@@ -14293,7 +14313,7 @@ function moduleOf(file, depth = 0) {
14293
14313
  const ext = typeof j.extends === "string" ? j.extends : null;
14294
14314
  if (!ext || !ext.startsWith("."))
14295
14315
  return null;
14296
- const next = join53(dirname19(file), ext.endsWith(".json") ? ext : `${ext}.json`);
14316
+ const next = join53(dirname20(file), ext.endsWith(".json") ? ext : `${ext}.json`);
14297
14317
  return existsSync33(next) ? moduleOf(next, depth + 1) : null;
14298
14318
  }
14299
14319
  function readPackageConventions(pkgDir, runner = null) {
@@ -14364,8 +14384,8 @@ function nearestPackageRoot(testDir, repoDir, fileName) {
14364
14384
  }
14365
14385
  };
14366
14386
  let pkg = testDir;
14367
- while (pkg !== repoDir && pkg !== dirname19(pkg) && !shaped(pkg))
14368
- pkg = dirname19(pkg);
14387
+ while (pkg !== repoDir && pkg !== dirname20(pkg) && !shaped(pkg))
14388
+ pkg = dirname20(pkg);
14369
14389
  return pkg;
14370
14390
  }
14371
14391
  function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
@@ -14435,7 +14455,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
14435
14455
  return join53(testDir, "__self__");
14436
14456
  const url = /^fileURLToPath\(new URL\((["'])([^"']*)\1\s*,\s*import\.meta\.url\)\)$/.exec(e);
14437
14457
  if (url)
14438
- return resolve17(testDir, url[2]);
14458
+ return resolve18(testDir, url[2]);
14439
14459
  const lit = /^(["'`])((?:\\.|(?!\1)[^\\])*)\1$/.exec(e);
14440
14460
  if (lit)
14441
14461
  return lit[2].includes("${") ? null : lit[2];
@@ -14448,8 +14468,8 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
14448
14468
  if (args.some((a) => a === null))
14449
14469
  return null;
14450
14470
  if (call[1] === "dirname")
14451
- return dirname19(args[0]);
14452
- const out2 = resolve17(...args);
14471
+ return dirname20(args[0]);
14472
+ const out2 = resolve18(...args);
14453
14473
  const first = parts.slice(1).map((a) => /^\s*["'`]([^"'`]*)["'`]\s*$/.exec(a)?.[1]).find((x) => x), viaWalk = !!first && walk.has(parts[0].trim()) && [pkg, repoDir].some((d) => existsSync33(join53(d, first.split("/").filter(Boolean)[0] ?? "\x00")));
14454
14474
  if (report && (viaWalk || !parts.some((a) => walk.has(a.trim()) || taint.has(a.trim())) && (relative9(testDir, out2).startsWith("..") || strayInTestDir(out2))) && parts.some((a) => /^\s*["'`]/.test(a)))
14455
14475
  reports.set(`${ln}|${e}`, { out: out2, rel: relative9(repoDir, out2), tail: viaWalk ? join53(...args.slice(1)) : undefined });
@@ -14512,9 +14532,9 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
14512
14532
  for (let i = 0;i < 64; i++) {
14513
14533
  if (existsSync33(join53(d, r.tail)))
14514
14534
  return true;
14515
- if (d === repoDir || d === dirname19(d))
14535
+ if (d === repoDir || d === dirname20(d))
14516
14536
  return false;
14517
- d = dirname19(d);
14537
+ d = dirname20(d);
14518
14538
  }
14519
14539
  return false;
14520
14540
  };
@@ -14552,7 +14572,7 @@ function phantomReason(miss, repoFiles, testDir = "", pkgRoot = "") {
14552
14572
  }
14553
14573
  var readJson5 = (p) => {
14554
14574
  try {
14555
- const v = parseJsonc(readFileSync42(p, "utf8"));
14575
+ const v = parseJsonc(readFileSync43(p, "utf8"));
14556
14576
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
14557
14577
  } catch {
14558
14578
  return null;
@@ -14591,10 +14611,10 @@ var init_preexisting_dirty = __esm(() => {
14591
14611
  });
14592
14612
 
14593
14613
  // ../../loki-ts/src/e10ext/commit_filter.ts
14594
- import { dirname as dirname20 } from "path";
14614
+ import { dirname as dirname21 } from "path";
14595
14615
  function dropSet(repoDir, staged, preexistingDirty, env = process.env, installCreated) {
14596
14616
  const owned = installOwned(repoDir, installCreated, env), made = installCreated?.files ?? {};
14597
- return staged.concat(untouchedSinceIntake(repoDir, preexistingDirty, env).map((f) => ({ st: "L", f })), staged.filter(({ f }) => owned(f)).map(({ f }) => ({ st: "L", f }))).filter(({ st, f }) => f.startsWith(".loki/") || st === "L" || WALL_FILE.test(f) || st === "A" && !Object.hasOwn(made, f) && !staged.some(({ f: m }) => /(^|\/)(package\.json|pyproject\.toml|requirements\.txt|Cargo\.toml|go\.mod)$/.test(m) && dirname20(m) === dirname20(f)) && /(^|\/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|poetry\.lock|Cargo\.lock|go\.sum)$/.test(f));
14617
+ return staged.concat(untouchedSinceIntake(repoDir, preexistingDirty, env).map((f) => ({ st: "L", f })), staged.filter(({ f }) => owned(f)).map(({ f }) => ({ st: "L", f }))).filter(({ st, f }) => f.startsWith(".loki/") || st === "L" || WALL_FILE.test(f) || st === "A" && !Object.hasOwn(made, f) && !staged.some(({ f: m }) => /(^|\/)(package\.json|pyproject\.toml|requirements\.txt|Cargo\.toml|go\.mod)$/.test(m) && dirname21(m) === dirname21(f)) && /(^|\/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|poetry\.lock|Cargo\.lock|go\.sum)$/.test(f));
14598
14618
  }
14599
14619
  var WALL_FILE, parseStaged = (out2) => out2.split("\x00").reduce((a, t, i, all) => i % 2 === 0 && t ? [...a, { st: t, f: all[i + 1] }] : a, []), formatChanged = (repoDir, staged, dropped2, env = process.env) => runFormatters(repoDir, staged.filter(({ st, f }) => (st === "A" || st === "M") && !dropped2.has(f) && !f.startsWith(".loki/")).map(({ f }) => f), tokenFreeEnv(env));
14600
14620
  var init_commit_filter = __esm(() => {
@@ -14716,9 +14736,9 @@ var init_route_block = __esm(() => {
14716
14736
  // ../../loki-ts/src/features/visual_evidence.ts
14717
14737
  import { spawn as spawn8 } from "child_process";
14718
14738
  import { createHash as createHash15, randomBytes as randomBytes6 } from "crypto";
14719
- import { existsSync as existsSync34, lstatSync as lstatSync12, mkdirSync as mkdirSync21, readdirSync as readdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync24 } from "fs";
14739
+ import { existsSync as existsSync34, lstatSync as lstatSync12, mkdirSync as mkdirSync21, readdirSync as readdirSync20, readFileSync as readFileSync44, writeFileSync as writeFileSync24 } from "fs";
14720
14740
  import { createServer } from "net";
14721
- import { dirname as dirname21, isAbsolute as isAbsolute10, join as join54, normalize as normalize3, relative as relative10, sep as sep13 } from "path";
14741
+ import { dirname as dirname22, isAbsolute as isAbsolute10, join as join54, normalize as normalize3, relative as relative10, sep as sep13 } from "path";
14722
14742
  function routeFor(file) {
14723
14743
  let r = file.replace(/^(?:.*?\/)?(?:app|pages|src|public)\//, "").replace(/^(?:routes|pages)\//, "");
14724
14744
  r = r.replace(/\.(?:html|jsx|tsx|vue|svelte)$/, "").replace(/\/?(?:page|index|\+page)$/, "");
@@ -14795,7 +14815,7 @@ function openapiPaths(repoDir) {
14795
14815
  if (!existsSync34(p))
14796
14816
  continue;
14797
14817
  try {
14798
- const txt = readFileSync43(p, "utf8");
14818
+ const txt = readFileSync44(p, "utf8");
14799
14819
  const paths = f.endsWith(".json") ? Object.keys(JSON.parse(txt).paths ?? {}) : [...txt.matchAll(/^ {2}(\/[^\s:]*):\s*$/gm)].map((m) => m[1]);
14800
14820
  return paths.filter((x) => !x.includes("{")).slice(0, 10);
14801
14821
  } catch {
@@ -14913,14 +14933,14 @@ async function captureVisualEvidence(repoDir, runDir, changed, opts = {}) {
14913
14933
  const subs = ["backend", "frontend"].filter((d) => existsSync34(join54(repoDir, d, "package.json")));
14914
14934
  const has2 = (d) => {
14915
14935
  try {
14916
- return pickScript(JSON.parse(readFileSync43(join54(repoDir, d, "package.json"), "utf8"))) !== null;
14936
+ return pickScript(JSON.parse(readFileSync44(join54(repoDir, d, "package.json"), "utf8"))) !== null;
14917
14937
  } catch {
14918
14938
  return false;
14919
14939
  }
14920
14940
  };
14921
14941
  return skip(noRootReason(subs, subs.filter((d) => !has2(d))));
14922
14942
  }
14923
- script = pickScript(JSON.parse(readFileSync43(pkgPath, "utf8")));
14943
+ script = pickScript(JSON.parse(readFileSync44(pkgPath, "utf8")));
14924
14944
  if (!script)
14925
14945
  return skip("no dev, preview or start script");
14926
14946
  }
@@ -15014,9 +15034,9 @@ async function sealEvidence(repoDir, runDir, o, notProven, signal, emit) {
15014
15034
  function receiptScreensProblem(receiptPath, receipt) {
15015
15035
  if (visualGateEnabled() && typeof receipt["evidence_failed"] === "string")
15016
15036
  return `visual evidence failed (LOKI_VISUAL_GATE=1): ${receipt["evidence_failed"]}`;
15017
- return receipt["evidence_screens"] === undefined ? null : checkScreens(dirname21(receiptPath), receipt["evidence_screens"]);
15037
+ return receipt["evidence_screens"] === undefined ? null : checkScreens(dirname22(receiptPath), receipt["evidence_screens"]);
15018
15038
  }
15019
- var visualEvidenceEnabled = (env = process.env) => env["LOKI_VISUAL_EVIDENCE"] !== "0", visualGateEnabled = (env = process.env) => env["LOKI_VISUAL_GATE"] === "1", PAGE_RE, isPageFile = (p) => PAGE_RE.test(p), screenName = (route) => (route === "/" ? "index" : route.slice(1).replace(/[^A-Za-z0-9._-]+/g, "_")) || "index", sha256File = (p) => createHash15("sha256").update(readFileSync43(p)).digest("hex"), playwrightBin = (repoDir) => {
15039
+ var visualEvidenceEnabled = (env = process.env) => env["LOKI_VISUAL_EVIDENCE"] !== "0", visualGateEnabled = (env = process.env) => env["LOKI_VISUAL_GATE"] === "1", PAGE_RE, isPageFile = (p) => PAGE_RE.test(p), screenName = (route) => (route === "/" ? "index" : route.slice(1).replace(/[^A-Za-z0-9._-]+/g, "_")) || "index", sha256File = (p) => createHash15("sha256").update(readFileSync44(p)).digest("hex"), playwrightBin = (repoDir) => {
15020
15040
  const bin = join54(repoDir, "node_modules", ".bin", "playwright");
15021
15041
  return existsSync34(bin) ? bin : null;
15022
15042
  }, playwrightTestPkg = (repoDir) => {
@@ -15093,15 +15113,15 @@ var init_pr = __esm(() => {
15093
15113
  });
15094
15114
 
15095
15115
  // ../../loki-ts/src/util/pr_lessons.ts
15096
- import { existsSync as existsSync35, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync8, readFileSync as readFileSync44, rmSync as rmSync17, writeFileSync as writeFileSync25 } from "fs";
15097
- import { dirname as dirname22, join as join56 } from "path";
15116
+ import { existsSync as existsSync35, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync8, readFileSync as readFileSync45, rmSync as rmSync17, writeFileSync as writeFileSync25 } from "fs";
15117
+ import { dirname as dirname23, join as join56 } from "path";
15098
15118
  import { createHash as createHash16 } from "crypto";
15099
15119
  function loadLessons(repoDir) {
15100
15120
  const p = lessonsPath(repoDir);
15101
15121
  if (!existsSync35(p))
15102
15122
  return [];
15103
15123
  try {
15104
- const j = JSON.parse(readFileSync44(p, "utf-8"));
15124
+ const j = JSON.parse(readFileSync45(p, "utf-8"));
15105
15125
  return Array.isArray(j.lessons) ? j.lessons : [];
15106
15126
  } catch {
15107
15127
  return [];
@@ -15109,7 +15129,7 @@ function loadLessons(repoDir) {
15109
15129
  }
15110
15130
  function save(repoDir, lessons) {
15111
15131
  const p = lessonsPath(repoDir);
15112
- mkdirSync22(dirname22(p), { recursive: true });
15132
+ mkdirSync22(dirname23(p), { recursive: true });
15113
15133
  atomicWriteJson(p, { version: 2, lessons });
15114
15134
  }
15115
15135
  function appendReceiptFact(repoDir, f, now2 = () => new Date) {
@@ -15169,9 +15189,9 @@ var init_attempts = __esm(() => {
15169
15189
  var init_mcp_config = () => {};
15170
15190
 
15171
15191
  // ../../loki-ts/src/providers/claude_flags.ts
15172
- import { existsSync as existsSync36, readFileSync as readFileSync45 } from "fs";
15173
- import { resolve as resolvePath, dirname as dirname23 } from "path";
15174
- import { fileURLToPath as fileURLToPath5 } from "url";
15192
+ import { existsSync as existsSync36, readFileSync as readFileSync46 } from "fs";
15193
+ import { resolve as resolvePath, dirname as dirname24 } from "path";
15194
+ import { fileURLToPath as fileURLToPath6 } from "url";
15175
15195
  function claudeFlagSupported(flag, helpText) {
15176
15196
  const txt = helpText ?? _claudeHelpCache;
15177
15197
  if (txt === null || txt === undefined) {
@@ -15217,14 +15237,14 @@ function leanReviewerFlags(opts = {}) {
15217
15237
  }
15218
15238
  function designArchetypesText() {
15219
15239
  try {
15220
- const moduleDir = dirname23(fileURLToPath5(import.meta.url));
15240
+ const moduleDir = dirname24(fileURLToPath6(import.meta.url));
15221
15241
  for (const rel of [
15222
15242
  ["..", "..", "..", "references", "design-archetypes.md"],
15223
15243
  ["..", "..", "references", "design-archetypes.md"]
15224
15244
  ]) {
15225
15245
  const p = resolvePath(moduleDir, ...rel);
15226
15246
  if (existsSync36(p))
15227
- return readFileSync45(p, "utf8");
15247
+ return readFileSync46(p, "utf8");
15228
15248
  }
15229
15249
  } catch {}
15230
15250
  return "";
@@ -15300,14 +15320,14 @@ var init_providers = __esm(() => {
15300
15320
  });
15301
15321
 
15302
15322
  // ../../loki-ts/src/runner/router/route_record.ts
15303
- import { existsSync as existsSync37, lstatSync as lstatSync13, mkdirSync as mkdirSync23, readFileSync as readFileSync46, writeFileSync as writeFileSync26 } from "fs";
15323
+ import { existsSync as existsSync37, lstatSync as lstatSync13, mkdirSync as mkdirSync23, readFileSync as readFileSync47, writeFileSync as writeFileSync26 } from "fs";
15304
15324
  import { join as join57 } from "path";
15305
15325
  function loadRouteRecord(runDir) {
15306
15326
  try {
15307
15327
  const p = join57(runDir, ROUTE_RECORD_FILE);
15308
15328
  if (!existsSync37(p) || !lstatSync13(p).isFile())
15309
15329
  return;
15310
- const v = JSON.parse(readFileSync46(p, "utf8"));
15330
+ const v = JSON.parse(readFileSync47(p, "utf8"));
15311
15331
  return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
15312
15332
  } catch {
15313
15333
  return;
@@ -15451,7 +15471,7 @@ __export(exports_deep, {
15451
15471
  });
15452
15472
  import { copyFileSync as copyFileSync3, existsSync as existsSync38, lstatSync as lstatSync14, mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync9, rmSync as rmSync18, writeFileSync as writeFileSync27 } from "fs";
15453
15473
  import { tmpdir as tmpdir10 } from "os";
15454
- import { dirname as dirname24, join as join58 } from "path";
15474
+ import { dirname as dirname25, join as join58 } from "path";
15455
15475
  function sessionCouncil(sessions) {
15456
15476
  return { async run(input, signal) {
15457
15477
  const cwd = mkdtempSync9(join58(tmpdir10(), "loki-deep-council-"));
@@ -15576,7 +15596,7 @@ async function secureScanChanged(repoDir, changed, opts) {
15576
15596
  try {
15577
15597
  for (const f of changed)
15578
15598
  if (existsSync38(join58(repoDir, f)) && lstatSync14(join58(repoDir, f)).isFile()) {
15579
- mkdirSync24(dirname24(join58(dir, f)), { recursive: true });
15599
+ mkdirSync24(dirname25(join58(dir, f)), { recursive: true });
15580
15600
  copyFileSync3(join58(repoDir, f), join58(dir, f));
15581
15601
  }
15582
15602
  return await runSecureScan(dir, { ...opts.secureScanPath ? { scriptPath: opts.secureScanPath } : {}, timeoutMs: 60000 });
@@ -16054,9 +16074,9 @@ ${x}` : c.cmd };
16054
16074
 
16055
16075
  // ../../loki-ts/src/engine10/stages/wall.ts
16056
16076
  import { spawnSync as spawnSync7 } from "child_process";
16057
- import { existsSync as existsSync40, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync11, readFileSync as readFileSync47, readdirSync as readdirSync21, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
16077
+ import { existsSync as existsSync40, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync11, readFileSync as readFileSync48, readdirSync as readdirSync21, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
16058
16078
  import { tmpdir as tmpdir12 } from "os";
16059
- import { dirname as dirname25, join as join60, relative as relative12 } from "path";
16079
+ import { dirname as dirname26, join as join60, relative as relative12 } from "path";
16060
16080
 
16061
16081
  class RealBaseTestRunner {
16062
16082
  api;
@@ -16124,7 +16144,7 @@ function loadTaskText(ctx, fromPrior) {
16124
16144
  const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join60(ctx.runDir, "issue.json");
16125
16145
  if (existsSync40(issueJsonPath)) {
16126
16146
  try {
16127
- const issue = JSON.parse(readFileSync47(issueJsonPath, "utf8"));
16147
+ const issue = JSON.parse(readFileSync48(issueJsonPath, "utf8"));
16128
16148
  const text2 = [issue.title, issue.body].filter((s) => typeof s === "string" && s.length > 0).join(`
16129
16149
 
16130
16150
  `);
@@ -16136,7 +16156,7 @@ function loadTaskText(ctx, fromPrior) {
16136
16156
  }
16137
16157
  function wallTargetDir(repoDir, existingTests) {
16138
16158
  const first = existingTests[0];
16139
- return first ? join60(repoDir, dirname25(first.path)) : join60(repoDir, "tests");
16159
+ return first ? join60(repoDir, dirname26(first.path)) : join60(repoDir, "tests");
16140
16160
  }
16141
16161
  function guessRunner(fileName, runners) {
16142
16162
  if (fileName.endsWith(".py"))
@@ -16191,20 +16211,20 @@ async function wallAuthor(ctx, signal, retry) {
16191
16211
  }
16192
16212
  const planText = typeof prior.plan?.plan === "string" ? prior.plan.plan : null, repoFiles = repoMap?.files ?? [];
16193
16213
  const oor = () => readdirSync21(cwd).filter((f) => f.startsWith(WALL_PREFIX)).flatMap((name) => {
16194
- const text2 = readFileSync47(join60(cwd, name), "utf8"), why = outOfRepoTarget(text2) ?? phantomReason(phantomRepoPaths(text2, name, targetDir, ctx.repoDir, planText), repoFiles, relative12(ctx.repoDir, targetDir), pkg?.root ?? "");
16214
+ const text2 = readFileSync48(join60(cwd, name), "utf8"), why = outOfRepoTarget(text2) ?? phantomReason(phantomRepoPaths(text2, name, targetDir, ctx.repoDir, planText), repoFiles, relative12(ctx.repoDir, targetDir), pkg?.root ?? "");
16195
16215
  return why ? [{ name, why }] : [];
16196
16216
  });
16197
16217
  const bad1 = oor();
16198
16218
  if (bad1.length > 0 && !signal.aborted && !ctx.overCap?.())
16199
16219
  await ctx.sessions.run({ stage: "wall", brief: withStagePrefix(outOfRepoReask("Rewrite these Wall files in place, keeping the same names and acceptance coverage.", bad1)), tier: "development", model, iterationId: `${iterationId}-oor`, limitS: wallLimitS(sz.size), signal, cwd });
16200
- const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync21(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n2) => !oorBad.has(n2) && !conventionViolation(conv2, n2, readFileSync47(join60(cwd, n2), "utf8"))), runnerOf: (n2) => guessRunner(n2, runners) }), generated = all.filter((n2) => !held?.names.has(n2));
16220
+ const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync21(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n2) => !oorBad.has(n2) && !conventionViolation(conv2, n2, readFileSync48(join60(cwd, n2), "utf8"))), runnerOf: (n2) => guessRunner(n2, runners) }), generated = all.filter((n2) => !held?.names.has(n2));
16201
16221
  const sealedDir = join60(ctx.runDir, "wall");
16202
16222
  if (generated.length > 0)
16203
16223
  mkdirSync25(sealedDir, { recursive: true });
16204
16224
  const contents = new Map;
16205
16225
  const discarded = [];
16206
16226
  for (const name of generated) {
16207
- const content = readFileSync47(join60(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
16227
+ const content = readFileSync48(join60(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
16208
16228
  writeFileSync28(join60(sealedDir, name), content, "utf8");
16209
16229
  if (oorWhy)
16210
16230
  discarded.push({ file: name, reason: `${oorWhy}; wall test discarded after one rewrite request` });
@@ -16323,10 +16343,10 @@ var init_wall = __esm(() => {
16323
16343
  });
16324
16344
 
16325
16345
  // ../../loki-ts/src/e10ext/discard.ts
16326
- import { chmodSync as chmodSync5, closeSync as closeSync9, lstatSync as lstatSync15, mkdirSync as mkdirSync26, openSync as openSync9, readFileSync as readFileSync48, realpathSync as realpathSync23, rmdirSync, unlinkSync as unlinkSync7, writeFileSync as writeFileSync29 } from "fs";
16327
- import { dirname as dirname26, join as join61, relative as relative13, sep as sep14 } from "path";
16346
+ import { chmodSync as chmodSync5, closeSync as closeSync9, lstatSync as lstatSync15, mkdirSync as mkdirSync26, openSync as openSync9, readFileSync as readFileSync49, realpathSync as realpathSync23, rmdirSync, unlinkSync as unlinkSync7, writeFileSync as writeFileSync29 } from "fs";
16347
+ import { dirname as dirname27, join as join61, relative as relative13, sep as sep14 } from "path";
16328
16348
  function safeRestore(repoDir, f, want, mode) {
16329
- const root = realpathSync23(repoDir), fp = join61(root, f), rel = relative13(root, dirname26(fp));
16349
+ const root = realpathSync23(repoDir), fp = join61(root, f), rel = relative13(root, dirname27(fp));
16330
16350
  if (rel.startsWith(".."))
16331
16351
  throw new Error("outside repo");
16332
16352
  let cur = root;
@@ -16348,7 +16368,7 @@ function safeRestore(repoDir, f, want, mode) {
16348
16368
  } catch {
16349
16369
  st = null;
16350
16370
  }
16351
- if (st?.isFile() && readFileSync48(fp).equals(want)) {
16371
+ if (st?.isFile() && readFileSync49(fp).equals(want)) {
16352
16372
  chmodSync5(fp, mode);
16353
16373
  return;
16354
16374
  }
@@ -16420,7 +16440,7 @@ var init_discard = __esm(() => {
16420
16440
  });
16421
16441
 
16422
16442
  // ../../loki-ts/src/e10ext/scope.ts
16423
- import { basename as basename24, dirname as dirname27 } from "path";
16443
+ import { basename as basename24, dirname as dirname28 } from "path";
16424
16444
  function contractText(o) {
16425
16445
  const c = o.intake?.contract_snapshot?.contract;
16426
16446
  return Array.isArray(c?.criteria) ? c.criteria.map((x) => typeof x?.text === "string" ? x.text : "").join(`
@@ -16434,8 +16454,8 @@ function outsideScope(o, staged) {
16434
16454
  const text2 = `${plan}
16435
16455
  ${typeof o.intake?.task === "string" ? o.intake.task : ""}
16436
16456
  ${contractText(o)}`, pre = o.intake?.preexisting_dirty ?? {};
16437
- const toks = surfaceTokens(text2), plannedDirs = new Set(rel.map((r) => dirname27(r)).filter((d) => d !== "."));
16438
- return staged.filter(({ st, f }) => st !== "A" && !isTestFile(f) && !Object.hasOwn(pre, f) && !rel.includes(f) && !mentions(text2, f) && !mentions(text2, basename24(f)) && !plannedDirs.has(dirname27(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
16457
+ const toks = surfaceTokens(text2), plannedDirs = new Set(rel.map((r) => dirname28(r)).filter((d) => d !== "."));
16458
+ return staged.filter(({ st, f }) => st !== "A" && !isTestFile(f) && !Object.hasOwn(pre, f) && !rel.includes(f) && !mentions(text2, f) && !mentions(text2, basename24(f)) && !plannedDirs.has(dirname28(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
16439
16459
  }
16440
16460
  function flagOutsideScope(o, staged) {
16441
16461
  const unit = unitFlags(staged, process.env, o.intake?.preexisting_dirty ?? {});
@@ -16450,14 +16470,14 @@ var init_scope2 = __esm(() => {
16450
16470
  });
16451
16471
 
16452
16472
  // ../../loki-ts/src/council/role_agents.ts
16453
- import { existsSync as existsSync41, readdirSync as readdirSync22, readFileSync as readFileSync49 } from "fs";
16473
+ import { existsSync as existsSync41, readdirSync as readdirSync22, readFileSync as readFileSync50 } from "fs";
16454
16474
  import { homedir as homedir9 } from "os";
16455
16475
  import { join as join62 } from "path";
16456
16476
  function agentDirs(repoDir, env = process.env) {
16457
16477
  return [env["LOKI_AGENTS_PROJECT_DIR"] || join62(repoDir, ".loki", "agents"), env["LOKI_AGENTS_USER_DIR"] || join62(env["XDG_CONFIG_HOME"] || join62(homedir9(), ".config"), "loki", "agents")];
16458
16478
  }
16459
16479
  function parseAgent(file, stem2) {
16460
- const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync49(file, "utf8"));
16480
+ const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync50(file, "utf8"));
16461
16481
  if (!m)
16462
16482
  return null;
16463
16483
  const body = m[2].trim();
@@ -16577,14 +16597,14 @@ var init_colors = __esm(() => {
16577
16597
  });
16578
16598
 
16579
16599
  // ../../loki-ts/src/util/run_summary.ts
16580
- import { existsSync as existsSync42, mkdirSync as mkdirSync28, readFileSync as readFileSync50, renameSync as renameSync12, statSync as statSync20, writeFileSync as writeFileSync30 } from "fs";
16600
+ import { existsSync as existsSync42, mkdirSync as mkdirSync28, readFileSync as readFileSync51, renameSync as renameSync12, statSync as statSync20, writeFileSync as writeFileSync30 } from "fs";
16581
16601
  import { join as join64 } from "path";
16582
16602
  function readRiskRecord(repoDir, sinceMs = 0) {
16583
16603
  try {
16584
16604
  const p = join64(repoDir, ".loki", "state", "risk-tier.json");
16585
16605
  if (statSync20(p).mtimeMs < sinceMs)
16586
16606
  return null;
16587
- const r = JSON.parse(readFileSync50(p, "utf8"));
16607
+ const r = JSON.parse(readFileSync51(p, "utf8"));
16588
16608
  return r && typeof r === "object" ? r : null;
16589
16609
  } catch {
16590
16610
  return null;
@@ -16600,7 +16620,7 @@ var init_run_summary = __esm(() => {
16600
16620
  });
16601
16621
 
16602
16622
  // ../../loki-ts/src/engine10/stages/xreview.ts
16603
- import { existsSync as existsSync43, readFileSync as readFileSync51 } from "fs";
16623
+ import { existsSync as existsSync43, readFileSync as readFileSync52 } from "fs";
16604
16624
  import { join as join65 } from "path";
16605
16625
  function minVerdict(verdict, review) {
16606
16626
  const ceiling = review?.level === "block" ? "PARTIAL" : verdict;
@@ -16618,7 +16638,7 @@ function explicitReview(repoDir, env) {
16618
16638
  if (!existsSync43(p))
16619
16639
  continue;
16620
16640
  try {
16621
- const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync51(p, "utf8"));
16641
+ const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync52(p, "utf8"));
16622
16642
  const v = asProvider(m?.[1]);
16623
16643
  if (v)
16624
16644
  return v;
@@ -16813,8 +16833,8 @@ See also: loki cost --detail (what a run ALREADY spent)
16813
16833
  });
16814
16834
 
16815
16835
  // ../../loki-ts/src/features/contract.ts
16816
- import { existsSync as existsSync44, lstatSync as lstatSync16, mkdirSync as mkdirSync29, readFileSync as readFileSync52, rmSync as rmSync21, writeFileSync as writeFileSync31 } from "fs";
16817
- import { dirname as dirname28, join as join66 } from "path";
16836
+ import { existsSync as existsSync44, lstatSync as lstatSync16, mkdirSync as mkdirSync29, readFileSync as readFileSync53, rmSync as rmSync21, writeFileSync as writeFileSync31 } from "fs";
16837
+ import { dirname as dirname29, join as join66 } from "path";
16818
16838
  import { createHash as createHash17 } from "crypto";
16819
16839
  function contractEnabled(env = process.env) {
16820
16840
  return env["LOKI_CONTRACT"] !== "0";
@@ -16862,7 +16882,7 @@ function readContract(repoDir) {
16862
16882
  return { contract: null, notes: ["contract unreadable: too large"], sha256: null };
16863
16883
  let raw2;
16864
16884
  try {
16865
- raw2 = readFileSync52(p);
16885
+ raw2 = readFileSync53(p);
16866
16886
  } catch {
16867
16887
  return { contract: null, notes: ["contract unreadable: read failed"], sha256: null };
16868
16888
  }
@@ -16937,8 +16957,8 @@ var init_contract = __esm(() => {
16937
16957
 
16938
16958
  // ../../loki-ts/src/features/speed/seal_group.ts
16939
16959
  import { createHash as createHash18 } from "crypto";
16940
- import { existsSync as existsSync45, mkdirSync as mkdirSync30, readdirSync as readdirSync23, readFileSync as readFileSync53, renameSync as renameSync13, statSync as statSync21, writeFileSync as writeFileSync32 } from "fs";
16941
- import { dirname as dirname29, join as join67 } from "path";
16960
+ import { existsSync as existsSync45, mkdirSync as mkdirSync30, readdirSync as readdirSync23, readFileSync as readFileSync54, renameSync as renameSync13, statSync as statSync21, writeFileSync as writeFileSync32 } from "fs";
16961
+ import { dirname as dirname30, join as join67 } from "path";
16942
16962
  function sealGroup(runDir, rh) {
16943
16963
  const manifestPath = join67(runDir, "group", "manifest.json");
16944
16964
  if (!existsSync45(manifestPath))
@@ -16968,7 +16988,7 @@ function sealGroup(runDir, rh) {
16968
16988
  const dir = join67(unitsDir(runDir), id), rp = join67(dir, "receipt.json"), ep = join67(dir, "events.jsonl");
16969
16989
  let bytes;
16970
16990
  try {
16971
- bytes = readFileSync53(rp);
16991
+ bytes = readFileSync54(rp);
16972
16992
  } catch {
16973
16993
  return fail2(`unit ${id} sub-receipt missing`);
16974
16994
  }
@@ -16985,7 +17005,7 @@ function sealGroup(runDir, rh) {
16985
17005
  unit_id: id,
16986
17006
  sub_receipt_sha256: sha3(bytes),
16987
17007
  receipt_sha256: sub2["receipt_sha256"],
16988
- events_file_sha256: existsSync45(ep) ? sha3(readFileSync53(ep)) : null,
17008
+ events_file_sha256: existsSync45(ep) ? sha3(readFileSync54(ep)) : null,
16989
17009
  verdict,
16990
17010
  goal: text2(u["goal"], 200),
16991
17011
  files: (Array.isArray(u["files"]) ? u["files"] : []).map((f) => text2(f, 200)).filter(Boolean).slice(0, 50),
@@ -17005,7 +17025,7 @@ function capGroupVerdict(v, g) {
17005
17025
  return !g.allUnitsPass && (v === "VERIFIED" || v === "ALREADY_SATISFIED") ? "PARTIAL" : v;
17006
17026
  }
17007
17027
  async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
17008
- const runDir = dirname29(receiptPath);
17028
+ const runDir = dirname30(receiptPath);
17009
17029
  const signed = isObj10(receipt["verification"]) && typeof receipt["verification"]["jwt"] === "string";
17010
17030
  const bad = (reason) => ({ verdict: "TAMPERED", reason: `group: ${reason}` });
17011
17031
  const g = receipt["group"];
@@ -17029,13 +17049,13 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
17029
17049
  try {
17030
17050
  if (!statSync21(dir).isDirectory())
17031
17051
  return bad(`unit ${id} is not a directory`);
17032
- bytes = readFileSync53(rp);
17052
+ bytes = readFileSync54(rp);
17033
17053
  } catch {
17034
17054
  return bad(`unit ${id} sub-receipt missing`);
17035
17055
  }
17036
17056
  if (sha3(bytes) !== e["sub_receipt_sha256"])
17037
17057
  return bad(`unit ${id} sub-receipt does not match its recorded hash`);
17038
- const evSha = existsSync45(ep) ? sha3(readFileSync53(ep)) : null;
17058
+ const evSha = existsSync45(ep) ? sha3(readFileSync54(ep)) : null;
17039
17059
  if (evSha !== (e["events_file_sha256"] ?? null))
17040
17060
  return bad(`unit ${id} events.jsonl does not match its recorded hash`);
17041
17061
  const sub2 = readJson6(rp);
@@ -17060,7 +17080,7 @@ function compositeVerdict(childVerdicts) {
17060
17080
  }
17061
17081
  var ID_RE, PASSING, sha3 = (b) => createHash18("sha256").update(b).digest("hex"), isObj10 = (v) => v !== null && typeof v === "object" && !Array.isArray(v), text2 = (v, cap) => typeof v === "string" ? v.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : 0, unitsDir = (runDir) => join67(runDir, "group", "units"), readJson6 = (p) => {
17062
17082
  try {
17063
- return JSON.parse(readFileSync53(p, "utf8"));
17083
+ return JSON.parse(readFileSync54(p, "utf8"));
17064
17084
  } catch {
17065
17085
  return;
17066
17086
  }
@@ -17078,7 +17098,7 @@ var init_seal_group = __esm(() => {
17078
17098
  });
17079
17099
 
17080
17100
  // ../../loki-ts/src/supply/supply_guard.ts
17081
- import { existsSync as existsSync46, readFileSync as readFileSync54, statSync as statSync22 } from "fs";
17101
+ import { existsSync as existsSync46, readFileSync as readFileSync55, statSync as statSync22 } from "fs";
17082
17102
  import { basename as basename25, join as join68 } from "path";
17083
17103
  function supplyEnabled(env) {
17084
17104
  return env["LOKI_SUPPLY_GUARD"] !== "0";
@@ -17100,7 +17120,7 @@ function readDeclared(repoDir) {
17100
17120
  try {
17101
17121
  if (statSync22(p).size > MAX_FILE_BYTES)
17102
17122
  return { deps: [], problem: "declaration file too large" };
17103
- const j = JSON.parse(readFileSync54(p, "utf8"));
17123
+ const j = JSON.parse(readFileSync55(p, "utf8"));
17104
17124
  if (!Array.isArray(j))
17105
17125
  return { deps: [], problem: "declaration is not a JSON array" };
17106
17126
  const deps = [];
@@ -17124,7 +17144,7 @@ function readAllowlist(repoDir) {
17124
17144
  if (!existsSync46(p))
17125
17145
  return new Set;
17126
17146
  try {
17127
- return new Set(readFileSync54(p, "utf8").split(`
17147
+ return new Set(readFileSync55(p, "utf8").split(`
17128
17148
  `).map((l) => l.replace(/#.*$/, "").trim()).filter(Boolean));
17129
17149
  } catch {
17130
17150
  return new Set;
@@ -17307,7 +17327,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
17307
17327
  }
17308
17328
  }, PUBLIC_HOSTS, hostOf = (u) => u.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^www\./, "").split(/[/?#\s]/)[0].replace(/^[^@]*@/, "").replace(/:\d+$/, ""), privateUrl = (u) => /[a-z0-9]/i.test(u) && !PUBLIC_HOSTS.has(hostOf(u)), readSmall = (p) => {
17309
17329
  try {
17310
- return statSync22(p).size <= MAX_FILE_BYTES ? readFileSync54(p, "utf8") : "";
17330
+ return statSync22(p).size <= MAX_FILE_BYTES ? readFileSync55(p, "utf8") : "";
17311
17331
  } catch {
17312
17332
  return "";
17313
17333
  }
@@ -17323,7 +17343,7 @@ var init_supply_guard = __esm(() => {
17323
17343
 
17324
17344
  // ../../loki-ts/src/engine10/stages/seal.ts
17325
17345
  import { createHash as createHash19 } from "crypto";
17326
- import { existsSync as existsSync47, readdirSync as readdirSync24, mkdirSync as mkdirSync31, readFileSync as readFileSync55 } from "fs";
17346
+ import { existsSync as existsSync47, readdirSync as readdirSync24, mkdirSync as mkdirSync31, readFileSync as readFileSync56 } from "fs";
17327
17347
  import { basename as basename26, isAbsolute as isAbsolute13, join as join69, relative as relative14 } from "path";
17328
17348
  function receiptSha256(r) {
17329
17349
  const { verification: _v, receipt_sha256: _h, ...body } = r;
@@ -17649,7 +17669,7 @@ var init_seal = __esm(() => {
17649
17669
  provider: ctx.provider,
17650
17670
  model: ctx.model,
17651
17671
  resumed: o.intake?.resumed === true,
17652
- events_sha256: sha2562(existsSync47(eventsPath) ? readFileSync55(eventsPath) : ""),
17672
+ events_sha256: sha2562(existsSync47(eventsPath) ? readFileSync56(eventsPath) : ""),
17653
17673
  ...await sealEvidence(ctx.repoDir, ctx.runDir, o, notProven, signal, ctx.emit),
17654
17674
  log_seal: true,
17655
17675
  toolchain: collectToolchain(),
@@ -17704,14 +17724,14 @@ var init_seal = __esm(() => {
17704
17724
  });
17705
17725
 
17706
17726
  // ../../loki-ts/src/util/composite_seal.ts
17707
- import { existsSync as existsSync48, readFileSync as readFileSync56 } from "fs";
17708
- import { basename as basename27, dirname as dirname31, join as join70 } from "path";
17727
+ import { existsSync as existsSync48, readFileSync as readFileSync57 } from "fs";
17728
+ import { basename as basename27, dirname as dirname32, join as join70 } from "path";
17709
17729
  function logProblem(runDir, integ) {
17710
17730
  if (typeof integ["log_sha256"] !== "string")
17711
17731
  return null;
17712
17732
  let b;
17713
17733
  try {
17714
- b = readFileSync56(join70(runDir, "integration.log"));
17734
+ b = readFileSync57(join70(runDir, "integration.log"));
17715
17735
  } catch {
17716
17736
  return "integration.log is missing but integration.json records its hash";
17717
17737
  }
@@ -17726,7 +17746,7 @@ function integrationProblem(integ) {
17726
17746
  return null;
17727
17747
  }
17728
17748
  async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
17729
- const runDir = dirname31(receiptPath);
17749
+ const runDir = dirname32(receiptPath);
17730
17750
  const signed = isObj10(receipt["verification"]) && typeof receipt["verification"]["jwt"] === "string";
17731
17751
  const bad = (reason) => ({ problem: { verdict: "TAMPERED", reason: `composite: ${reason}` }, verdict: "FAILED" });
17732
17752
  const kids = receipt["children"];
@@ -17734,7 +17754,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
17734
17754
  return bad("body malformed");
17735
17755
  let ibytes;
17736
17756
  try {
17737
- ibytes = readFileSync56(join70(runDir, "integration.json"));
17757
+ ibytes = readFileSync57(join70(runDir, "integration.json"));
17738
17758
  } catch {
17739
17759
  return bad("integration.json missing");
17740
17760
  }
@@ -17778,7 +17798,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
17778
17798
  const rp = join70(runDir, rel);
17779
17799
  let bytes;
17780
17800
  try {
17781
- bytes = readFileSync56(rp);
17801
+ bytes = readFileSync57(rp);
17782
17802
  } catch {
17783
17803
  return bad(`child ${repo} receipt missing`);
17784
17804
  }
@@ -17827,8 +17847,8 @@ var init_keys_cmd = __esm(() => {
17827
17847
  });
17828
17848
 
17829
17849
  // ../../loki-ts/src/engine10/verify_cmd.ts
17830
- import { existsSync as existsSync49, readFileSync as readFileSync57, renameSync as renameSync14, statSync as statSync24, writeFileSync as writeFileSync34 } from "fs";
17831
- import { basename as basename28, dirname as dirname32, join as join71 } from "path";
17850
+ import { existsSync as existsSync49, readFileSync as readFileSync58, renameSync as renameSync14, statSync as statSync24, writeFileSync as writeFileSync34 } from "fs";
17851
+ import { basename as basename28, dirname as dirname33, join as join71 } from "path";
17832
17852
  import { createHash as createHash20, createPublicKey as createPublicKey4, verify as verify4 } from "crypto";
17833
17853
  function pubFor(kid, given) {
17834
17854
  if (given)
@@ -17836,7 +17856,7 @@ function pubFor(kid, given) {
17836
17856
  const active = loadSigningKey(false);
17837
17857
  const pubs = (process.env["LOKI_RECEIPT_RETIRED_PUBKEYS"] ?? "").split(":").map((f) => f.trim()).filter(Boolean).flatMap((f) => {
17838
17858
  try {
17839
- return [createPublicKey4(readFileSync57(f))];
17859
+ return [createPublicKey4(readFileSync58(f))];
17840
17860
  } catch {
17841
17861
  return [];
17842
17862
  }
@@ -17880,10 +17900,10 @@ function checkEventLog(receiptPath, receipt) {
17880
17900
  const claims = st !== null && typeof st === "object" && Object.keys(st).length > 0;
17881
17901
  return claims ? "the receipt records stages but binds the empty-log hash, so no events.jsonl can back it (missing, empty or non-empty); the receipt is forged or was sealed without a log. Re-run the task to produce a fresh receipt" : null;
17882
17902
  }
17883
- const path = join71(dirname32(receiptPath), "events.jsonl");
17903
+ const path = join71(dirname33(receiptPath), "events.jsonl");
17884
17904
  if (!existsSync49(path))
17885
17905
  return "events.jsonl is missing";
17886
- const raw2 = readFileSync57(path, "utf8"), events2 = readEvents(path), lines2 = raw2.split(`
17906
+ const raw2 = readFileSync58(path, "utf8"), events2 = readEvents(path), lines2 = raw2.split(`
17887
17907
  `).filter((l) => l.trim() !== "");
17888
17908
  if (events2.length !== lines2.length || events2.some((e, i) => e.seq !== i))
17889
17909
  return "events.jsonl has a forged, edited or missing line";
@@ -17899,7 +17919,7 @@ function checkEventLog(receiptPath, receipt) {
17899
17919
  return h.digest("hex") === bound ? null : "events.jsonl does not match the hash recorded at seal";
17900
17920
  }
17901
17921
  function checkLogSeal(receiptPath, hash, kid, given) {
17902
- const path = join71(dirname32(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findIndex((e) => e.type === "run.completed");
17922
+ const path = join71(dirname33(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findIndex((e) => e.type === "run.completed");
17903
17923
  if (!events2.some((e) => e.type === "receipt.sealed" && e.data["receipt_sha256"] === hash))
17904
17924
  return { verdict: "TAMPERED", reason: "events.jsonl has no receipt.sealed event for this receipt" };
17905
17925
  if (done < 0)
@@ -17907,7 +17927,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
17907
17927
  const seal = events2[done + 1], d = seal?.type === "log.sealed" ? seal.data : null;
17908
17928
  if (!d)
17909
17929
  return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
17910
- const lines2 = readFileSync57(path, "utf8").split(`
17930
+ const lines2 = readFileSync58(path, "utf8").split(`
17911
17931
  `).filter((l) => l.trim() !== ""), sha4 = createHash20("sha256").update(lines2.slice(0, done + 1).join(`
17912
17932
  `) + `
17913
17933
  `).digest("hex");
@@ -17921,7 +17941,7 @@ async function verifyReceipt(receiptPath, deps = {}) {
17921
17941
  return { verdict: "UNCHECKED", reasons: [`receipt not found: ${receiptPath}`] };
17922
17942
  let receipt;
17923
17943
  try {
17924
- receipt = JSON.parse((deps.read ?? ((p) => readFileSync57(p, "utf8")))(receiptPath));
17944
+ receipt = JSON.parse((deps.read ?? ((p) => readFileSync58(p, "utf8")))(receiptPath));
17925
17945
  } catch {
17926
17946
  return { verdict: "UNCHECKED", reasons: ["receipt.json is not valid JSON"] };
17927
17947
  }
@@ -18010,8 +18030,8 @@ var init_verify_cmd = __esm(() => {
18010
18030
  });
18011
18031
 
18012
18032
  // src/server/app.ts
18013
- import { existsSync as existsSync51, readFileSync as readFileSync60, statSync as statSync25 } from "fs";
18014
- import { join as join74, resolve as resolve18, sep as sep16 } from "path";
18033
+ import { existsSync as existsSync51, readFileSync as readFileSync61, statSync as statSync25 } from "fs";
18034
+ import { join as join74, resolve as resolve19, sep as sep16 } from "path";
18015
18035
 
18016
18036
  // node_modules/hono/dist/request/constants.js
18017
18037
  var GET_MATCH_RESULT = Symbol();
@@ -28322,7 +28342,7 @@ function mount20(ctx) {
28322
28342
  }
28323
28343
 
28324
28344
  // src/server/routes/verify.ts
28325
- import { readFileSync as readFileSync58, realpathSync as realpathSync25 } from "fs";
28345
+ import { readFileSync as readFileSync59, realpathSync as realpathSync25 } from "fs";
28326
28346
  import { createPublicKey as createPublicKey5 } from "crypto";
28327
28347
  import { join as join72, sep as sep15 } from "path";
28328
28348
  init_verify_cmd();
@@ -28374,7 +28394,7 @@ function mount21(ctx) {
28374
28394
  sha4 = r.receiptSha256 ?? null;
28375
28395
  }
28376
28396
  try {
28377
- outcome = outcomeOf(JSON.parse(readFileSync58(file, "utf8")));
28397
+ outcome = outcomeOf(JSON.parse(readFileSync59(file, "utf8")));
28378
28398
  } catch {
28379
28399
  outcome = "UNREADABLE";
28380
28400
  }
@@ -28436,7 +28456,7 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
28436
28456
  }
28437
28457
 
28438
28458
  // src/server/legacy/shim.ts
28439
- import { existsSync as existsSync50, readFileSync as readFileSync59 } from "fs";
28459
+ import { existsSync as existsSync50, readFileSync as readFileSync60 } from "fs";
28440
28460
  import { join as join73 } from "path";
28441
28461
 
28442
28462
  // src/server/legacy/routes.ts
@@ -28818,7 +28838,7 @@ var repoVersion = () => {
28818
28838
  for (const f of [join73(import.meta.dir, "../../../../../VERSION")]) {
28819
28839
  try {
28820
28840
  if (existsSync50(f))
28821
- return readFileSync59(f, "utf8").trim();
28841
+ return readFileSync60(f, "utf8").trim();
28822
28842
  } catch {}
28823
28843
  }
28824
28844
  return "unknown";
@@ -29032,7 +29052,7 @@ function createApp(opts) {
29032
29052
  for (const f of [process.env.LOKI_VERSION_FILE, join74(import.meta.dir, "../../../../VERSION")]) {
29033
29053
  try {
29034
29054
  if (f)
29035
- return readFileSync60(f, "utf8").trim() || "unknown";
29055
+ return readFileSync61(f, "utf8").trim() || "unknown";
29036
29056
  } catch {}
29037
29057
  }
29038
29058
  return "unknown";
@@ -29141,8 +29161,8 @@ function createApp(opts) {
29141
29161
  }
29142
29162
  if (!uiDir || p.startsWith("/v1/"))
29143
29163
  return c.json({ error: "not found" }, 404);
29144
- const root = resolve18(uiDir);
29145
- const f = resolve18(root, `.${p}`);
29164
+ const root = resolve19(uiDir);
29165
+ const f = resolve19(root, `.${p}`);
29146
29166
  if (f.startsWith(root + sep16) && existsSync51(f) && statSync25(f).isFile())
29147
29167
  return new Response(Bun.file(f));
29148
29168
  if (/\.[a-z0-9]+$/i.test(p))