loki-mode 11.7.1 → 11.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/lib/backlog.py +37 -2
  4. package/autonomy/lib/chat.sh +3 -2
  5. package/autonomy/loki +1 -1
  6. package/autonomy/trigger-server.py +269 -2
  7. package/autonomy/verify.sh +5 -0
  8. package/completions/loki.bash +2 -2
  9. package/dashboard/__init__.py +1 -1
  10. package/docs/CLI-REFERENCE.md +1 -1
  11. package/docs/INSTALLATION.md +1 -1
  12. package/docs/sentry-intake.md +22 -0
  13. package/docs/v10/D61-SPEED.md +12 -0
  14. package/docs/v10/PROGRESS.md +10 -0
  15. package/loki-ts/dist/loki.js +895 -878
  16. package/mcp/__init__.py +1 -1
  17. package/package.json +2 -2
  18. package/packages/control-plane/dist/server.js +277 -271
  19. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  20. package/web-app/dist/assets/{AdminPage-S3BYeapm.js → AdminPage-BnIg9ilA.js} +1 -1
  21. package/web-app/dist/assets/{Avatar-C1rHwLgn.js → Avatar-0BTVsQ2A.js} +1 -1
  22. package/web-app/dist/assets/{Badge-CzlnN5aQ.js → Badge-Bbq8CXgn.js} +1 -1
  23. package/web-app/dist/assets/{Button-B1w5AeGC.js → Button-CKD4n0ld.js} +1 -1
  24. package/web-app/dist/assets/{CockpitPage-Dyeqjfkc.js → CockpitPage-DJhLNLAz.js} +1 -1
  25. package/web-app/dist/assets/{ComparePage-C6y2GkGR.js → ComparePage-Di2akuII.js} +1 -1
  26. package/web-app/dist/assets/{ErrorBoundary-Dg2fcGkR.js → ErrorBoundary-9lhsYG-z.js} +1 -1
  27. package/web-app/dist/assets/{EvidenceReceiptPanel-CxbyjvTj.js → EvidenceReceiptPanel-CQDGXvDr.js} +1 -1
  28. package/web-app/dist/assets/{GitHubIssuesPanel-Dpys1xDb.js → GitHubIssuesPanel-Y_w2k9Ej.js} +1 -1
  29. package/web-app/dist/assets/{GitHubPRsPanel-CRVjWoFl.js → GitHubPRsPanel-pMSQedCv.js} +1 -1
  30. package/web-app/dist/assets/{HomePage-BKnv-oYw.js → HomePage-CIAkiGdt.js} +2 -2
  31. package/web-app/dist/assets/{LoginPage-BGksmFRd.js → LoginPage-BES4Pk6k.js} +1 -1
  32. package/web-app/dist/assets/{MagicPage-OCvhp16M.js → MagicPage-B154fMhi.js} +1 -1
  33. package/web-app/dist/assets/{MetricsPage-CJOJpXWC.js → MetricsPage-BcNyaiUO.js} +1 -1
  34. package/web-app/dist/assets/{NotFoundPage-C04p3QvN.js → NotFoundPage-D28FqYxG.js} +1 -1
  35. package/web-app/dist/assets/{ProjectPage-BRB8txsY.js → ProjectPage-C_O3u8Jx.js} +3 -3
  36. package/web-app/dist/assets/{ProjectsPage-CoUYeQEh.js → ProjectsPage-uqdahuPA.js} +1 -1
  37. package/web-app/dist/assets/{SettingsPage-BkjmJGfM.js → SettingsPage-DLvVA9OZ.js} +1 -1
  38. package/web-app/dist/assets/{ShowcasePage-B4vU9TjQ.js → ShowcasePage-BAZP8vsm.js} +1 -1
  39. package/web-app/dist/assets/{SystemSettingsPage-Z2jiVsni.js → SystemSettingsPage-DPYZkLWh.js} +1 -1
  40. package/web-app/dist/assets/{TeamsPage-Ulm8SISq.js → TeamsPage-BgSyb5Pd.js} +1 -1
  41. package/web-app/dist/assets/{TemplatesPage-C_7MM6Ey.js → TemplatesPage-D_Jh5VU1.js} +1 -1
  42. package/web-app/dist/assets/{TerminalOutput-Cumd7Tgs.js → TerminalOutput-4v8poDKb.js} +1 -1
  43. package/web-app/dist/assets/{activity-CZAUkbiY.js → activity-CE2b6kdw.js} +1 -1
  44. package/web-app/dist/assets/{bell-BOvSXpEr.js → bell-CxJDlLSR.js} +1 -1
  45. package/web-app/dist/assets/{bot-DOTZxBYj.js → bot-C2WuK4zw.js} +1 -1
  46. package/web-app/dist/assets/{check-BxpE0B5u.js → check-81epVldw.js} +1 -1
  47. package/web-app/dist/assets/{chevron-left-D6KPvBOA.js → chevron-left-B6EXh_3C.js} +1 -1
  48. package/web-app/dist/assets/{circle-alert-Bajq86oe.js → circle-alert-0iqoo-iy.js} +1 -1
  49. package/web-app/dist/assets/{clock-CnlHAVJc.js → clock-CFrBpNUp.js} +1 -1
  50. package/web-app/dist/assets/{cloud-DjaymjwM.js → cloud-BBSFhUT_.js} +1 -1
  51. package/web-app/dist/assets/{code-xml-BADEw2Ld.js → code-xml-BCU2V1rq.js} +1 -1
  52. package/web-app/dist/assets/{database-B4aKb5Cq.js → database-D2hvO52K.js} +1 -1
  53. package/web-app/dist/assets/{dollar-sign-DrldXpja.js → dollar-sign-CXFA9b6T.js} +1 -1
  54. package/web-app/dist/assets/{file-code-corner-DVebDVR-.js → file-code-corner-CqTCEEfS.js} +1 -1
  55. package/web-app/dist/assets/{file-plus-BD-N_-Tl.js → file-plus-DYFbkGbs.js} +1 -1
  56. package/web-app/dist/assets/{globe-C7ieInC-.js → globe-DpYHLobk.js} +1 -1
  57. package/web-app/dist/assets/{hammer-BSugKIji.js → hammer-CZ97SEYo.js} +1 -1
  58. package/web-app/dist/assets/{index-nLQgfvOn.js → index-DzswgpRo.js} +3 -3
  59. package/web-app/dist/assets/{layers-CHXxU2on.js → layers-2Tq0edx4.js} +1 -1
  60. package/web-app/dist/assets/{loader-circle-BEEz0LbD.js → loader-circle-BFP4kUX-.js} +1 -1
  61. package/web-app/dist/assets/{lock-CzQGfcnE.js → lock-DkKdZH4d.js} +1 -1
  62. package/web-app/dist/assets/{package-CcHYQLGd.js → package-ChOGD8yf.js} +1 -1
  63. package/web-app/dist/assets/{plus-DdzgFEXn.js → plus-hggB1o6b.js} +1 -1
  64. package/web-app/dist/assets/{refresh-cw-7x0HbH9Y.js → refresh-cw-DYwVLOeF.js} +1 -1
  65. package/web-app/dist/assets/{rotate-ccw-DBahX1Sp.js → rotate-ccw-CUdY506q.js} +1 -1
  66. package/web-app/dist/assets/{scroll-text-BB8y8a9Z.js → scroll-text-Wvidz5uN.js} +1 -1
  67. package/web-app/dist/assets/{server-CfkbW2MH.js → server-O11QmkCN.js} +1 -1
  68. package/web-app/dist/assets/{shield-alert-DUgD8rBF.js → shield-alert-DXXx27uV.js} +1 -1
  69. package/web-app/dist/assets/{thumbs-up-DGoyY6QC.js → thumbs-up-DF8ivs3A.js} +1 -1
  70. package/web-app/dist/assets/{trash-2-B6xrSUMr.js → trash-2-LA6PW0Nf.js} +1 -1
  71. package/web-app/dist/assets/{trending-down-B6RGKTOx.js → trending-down-Bw_vLKHT.js} +1 -1
  72. package/web-app/dist/assets/{trending-up-B44DCrt1.js → trending-up-tX8motha.js} +1 -1
  73. package/web-app/dist/assets/{upload-4kWm33ZY.js → upload-CxtTWJd2.js} +1 -1
  74. package/web-app/dist/assets/{usePolling-zkUtRQG6.js → usePolling-D-P5Iofq.js} +1 -1
  75. package/web-app/dist/assets/{user-04cEVIe2.js → user-dKTcuUFq.js} +1 -1
  76. package/web-app/dist/index.html +1 -1
@@ -7325,6 +7325,72 @@ var init_paths = __esm(() => {
7325
7325
  REPO_ROOT = findRepoRoot();
7326
7326
  });
7327
7327
 
7328
+ // ../../loki-ts/src/util/receipt_signer.ts
7329
+ import { createHash as createHash6, randomBytes as randomBytes2, createPrivateKey, createPublicKey as createPublicKey2, generateKeyPairSync, sign } from "crypto";
7330
+ import { chmodSync as chmodSync4, linkSync, mkdirSync as mkdirSync5, readFileSync as readFileSync18, statSync as statSync11, unlinkSync as unlinkSync3, writeFileSync as writeFileSync8 } from "fs";
7331
+ import { homedir as homedir8 } from "os";
7332
+ import { dirname as dirname7, join as join26 } from "path";
7333
+ function canonicalJson(x) {
7334
+ const walk = (v) => {
7335
+ if (Array.isArray(v))
7336
+ return `[${v.map(walk).join(",")}]`;
7337
+ if (v !== null && typeof v === "object") {
7338
+ const o = v;
7339
+ return `{${Object.keys(o).filter((k) => o[k] !== undefined).sort().map((k) => `${JSON.stringify(k)}:${walk(o[k])}`).join(",")}}`;
7340
+ }
7341
+ return JSON.stringify(v ?? null);
7342
+ };
7343
+ return walk(x).replace(/[\u0080-\uFFFF]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
7344
+ }
7345
+ function loadSigningKey(generate = true) {
7346
+ try {
7347
+ const inline = process.env["LOKI_RECEIPT_SIGNING_KEY"]?.trim();
7348
+ let pem = inline ?? "";
7349
+ if (!inline) {
7350
+ const given = process.env["LOKI_RECEIPT_SIGNING_KEY_FILE"]?.trim();
7351
+ const file = given || join26(process.env["HOME"] || homedir8(), ".loki", "keys", RECEIPT_SIGNER_BASENAME);
7352
+ try {
7353
+ pem = readFileSync18(file);
7354
+ if (!given) {
7355
+ for (const [f, m] of [[file, 384], [dirname7(file), 448]])
7356
+ if (statSync11(f).mode & 63)
7357
+ chmodSync4(f, m);
7358
+ }
7359
+ } catch (e) {
7360
+ if (e.code !== "ENOENT" || !generate)
7361
+ return null;
7362
+ mkdirSync5(dirname7(dirname7(file)), { recursive: true, mode: 448 });
7363
+ mkdirSync5(dirname7(file), { recursive: true, mode: 448 });
7364
+ const tmp = `${file}.${randomBytes2(6).toString("hex")}.tmp`;
7365
+ writeFileSync8(tmp, generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" }), { flag: "wx", mode: 384 });
7366
+ try {
7367
+ linkSync(tmp, file);
7368
+ } catch (l) {
7369
+ if (l.code !== "EEXIST")
7370
+ throw l;
7371
+ } finally {
7372
+ unlinkSync3(tmp);
7373
+ }
7374
+ pem = readFileSync18(file);
7375
+ }
7376
+ }
7377
+ const k = createPrivateKey(pem);
7378
+ return k.asymmetricKeyType === "ed25519" ? k : null;
7379
+ } catch {
7380
+ return null;
7381
+ }
7382
+ }
7383
+ function signReceipt(runId, hash) {
7384
+ const key = loadSigningKey();
7385
+ if (!key)
7386
+ return { jwt: null, kid: null };
7387
+ const kid = kidOf2(createPublicKey2(key));
7388
+ const input = `${b64u(canonicalJson({ alg: "EdDSA", typ: "JWT", kid }))}.${b64u(canonicalJson({ job_id: runId, run_id: runId, receipt_sha256: hash, iat: Math.floor(Date.now() / 1000) }))}`;
7389
+ return { jwt: `${input}.${b64u(sign(null, Buffer.from(input), key))}`, kid };
7390
+ }
7391
+ var RECEIPT_SIGNER_BASENAME = "receipt-ed25519.pem", b64u = (b) => Buffer.from(b).toString("base64url"), kidOf2 = (pub) => b64u(createHash6("sha256").update(`{"crv":"Ed25519","kty":"OKP","x":"${pub.export({ format: "jwk" }).x}"}`).digest());
7392
+ var init_receipt_signer = () => {};
7393
+
7328
7394
  // ../../loki-ts/src/engine10/registry.ts
7329
7395
  var init_registry = () => {};
7330
7396
 
@@ -7377,7 +7443,7 @@ var init_types = __esm(() => {
7377
7443
  });
7378
7444
 
7379
7445
  // ../../loki-ts/src/util/spec_file.ts
7380
- import { isAbsolute, join as join26, relative } from "path";
7446
+ import { isAbsolute, join as join27, relative } from "path";
7381
7447
  function specReceiptBlock(env) {
7382
7448
  const { LOKI_E10_SPEC_PATH: p, LOKI_E10_SPEC_SHA256: sha2 } = env;
7383
7449
  if (!p || !sha2)
@@ -7388,7 +7454,7 @@ function specReceiptBlock(env) {
7388
7454
  var SPEC_DIR;
7389
7455
  var init_spec_file = __esm(() => {
7390
7456
  init_types();
7391
- SPEC_DIR = join26(".loki", "specs");
7457
+ SPEC_DIR = join27(".loki", "specs");
7392
7458
  });
7393
7459
 
7394
7460
  // ../../loki-ts/src/engine10/pr_body.ts
@@ -7400,14 +7466,14 @@ function aiTrailers(i, env = process.env) {
7400
7466
  var markingOn = (env) => env["LOKI_AI_MARKING"] === "1", clean = (v) => v.replace(/[\u0000-\u001f\u007f\u2028\u2029]+/g, " ").replace(/\s+/g, " ").trim().slice(0, 100) || "unknown";
7401
7467
 
7402
7468
  // ../../loki-ts/src/util/credential_env.ts
7403
- import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, statSync as statSync11, lstatSync as lstatSync4 } from "fs";
7469
+ import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, statSync as statSync12, lstatSync as lstatSync4 } from "fs";
7404
7470
  import { tmpdir as tmpdir3 } from "os";
7405
- import { join as join27 } from "path";
7406
- import { randomBytes as randomBytes2 } from "crypto";
7471
+ import { join as join28 } from "path";
7472
+ import { randomBytes as randomBytes3 } from "crypto";
7407
7473
  function withheldSentinel(fresh = false) {
7408
7474
  if (fresh)
7409
7475
  sentinel = null;
7410
- return sentinel ??= `${SENTINEL_PREFIX}${process.pid}${randomBytes2(8).toString("hex")}INVALID`;
7476
+ return sentinel ??= `${SENTINEL_PREFIX}${process.pid}${randomBytes3(8).toString("hex")}INVALID`;
7411
7477
  }
7412
7478
  function removeConfigDir() {
7413
7479
  if (configDir)
@@ -7421,7 +7487,7 @@ function emptyGhConfigDir(env = process.env) {
7421
7487
  const runTmp = env["LOKI_RUN_TMP"] ?? "";
7422
7488
  const root = runTmp !== "" && isDir(runTmp) ? runTmp : tmpdir3();
7423
7489
  try {
7424
- configDir = mkdtempSync2(join27(root, "loki-gh-config-"));
7490
+ configDir = mkdtempSync2(join28(root, "loki-gh-config-"));
7425
7491
  } catch {
7426
7492
  return null;
7427
7493
  }
@@ -7462,7 +7528,7 @@ function hardenCredentialEnv(env, fresh = false) {
7462
7528
  }
7463
7529
  var GITHUB_TOKEN_VARS, SENTINEL_PREFIX = "ghp_LOKIWITHHELDsentinel", sentinel = null, configDir = null, exitHooked = false, sigtermHooked = false, isDir = (p) => {
7464
7530
  try {
7465
- return !lstatSync4(p).isSymbolicLink() && statSync11(p).isDirectory();
7531
+ return !lstatSync4(p).isSymbolicLink() && statSync12(p).isDirectory();
7466
7532
  } catch {
7467
7533
  return false;
7468
7534
  }
@@ -7588,9 +7654,9 @@ var init_run_cap = __esm(() => {
7588
7654
  });
7589
7655
 
7590
7656
  // ../../loki-ts/src/util/mutation_proof.ts
7591
- import { existsSync as existsSync15, mkdirSync as mkdirSync5, mkdtempSync as mkdtempSync3, readFileSync as readFileSync18, rmSync as rmSync5, symlinkSync, writeFileSync as writeFileSync8 } from "fs";
7657
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync3, readFileSync as readFileSync19, rmSync as rmSync5, symlinkSync, writeFileSync as writeFileSync9 } from "fs";
7592
7658
  import { tmpdir as tmpdir4 } from "os";
7593
- import { basename as basename8, dirname as dirname7, isAbsolute as isAbsolute2, join as join28, relative as relative2 } from "path";
7659
+ import { basename as basename8, dirname as dirname8, isAbsolute as isAbsolute2, join as join29, relative as relative2 } from "path";
7594
7660
  function mutationProof(i) {
7595
7661
  const rels = i.wallFiles.map((f) => isAbsolute2(f.path) ? relative2(i.repoDir, f.path) : f.path);
7596
7662
  if (rels.length === 0)
@@ -7608,25 +7674,25 @@ function mutationProof(i) {
7608
7674
  const deadline = Date.now() + budgetS * 1000, remaining = () => deadline - Date.now();
7609
7675
  let parent = null, wt = null, added = false;
7610
7676
  try {
7611
- parent = mkdtempSync3(join28(tmpdir4(), "loki-mutproof-"));
7612
- wt = join28(parent, "wt");
7677
+ parent = mkdtempSync3(join29(tmpdir4(), "loki-mutproof-"));
7678
+ wt = join29(parent, "wt");
7613
7679
  const add2 = git(i.repoDir, ["worktree", "add", "--detach", wt, i.baseSha], Math.max(1000, Math.min(30000, remaining())));
7614
7680
  added = existsSync15(wt) || add2.status === 0;
7615
7681
  if (add2.status !== 0)
7616
7682
  return np("could not create the base worktree");
7617
7683
  for (const rel of rels) {
7618
- const sealed = join28(i.runDir, "wall", basename8(rel)), src = existsSync15(sealed) ? sealed : join28(i.repoDir, rel);
7684
+ const sealed = join29(i.runDir, "wall", basename8(rel)), src = existsSync15(sealed) ? sealed : join29(i.repoDir, rel);
7619
7685
  if (!existsSync15(src))
7620
7686
  return np(`Wall file missing: ${rel}`);
7621
- mkdirSync5(dirname7(join28(wt, rel)), { recursive: true });
7622
- writeFileSync8(join28(wt, rel), readFileSync18(src));
7687
+ mkdirSync6(dirname8(join29(wt, rel)), { recursive: true });
7688
+ writeFileSync9(join29(wt, rel), readFileSync19(src));
7623
7689
  }
7624
7690
  for (const rel of rels) {
7625
7691
  const parts = rel.split("/").slice(0, -1);
7626
7692
  for (let n2 = 0;n2 <= parts.length; n2++) {
7627
7693
  const anc = parts.slice(0, n2).join("/");
7628
7694
  for (const d of DEP_DIRS) {
7629
- const src = join28(i.repoDir, anc, d), dst = join28(wt, anc, d);
7695
+ const src = join29(i.repoDir, anc, d), dst = join29(wt, anc, d);
7630
7696
  if (existsSync15(src) && !existsSync15(dst)) {
7631
7697
  try {
7632
7698
  symlinkSync(src, dst);
@@ -7823,7 +7889,7 @@ var init_shell = __esm(() => {
7823
7889
  });
7824
7890
 
7825
7891
  // ../../loki-ts/src/util/python.ts
7826
- import { accessSync, constants as constants2, existsSync as existsSync16, statSync as statSync12 } from "fs";
7892
+ import { accessSync, constants as constants2, existsSync as existsSync16, statSync as statSync13 } from "fs";
7827
7893
  import { spawnSync as spawnSync2 } from "child_process";
7828
7894
  import { tmpdir as tmpdir5 } from "os";
7829
7895
  function resolvePython3() {
@@ -7833,7 +7899,7 @@ function resolvePython3() {
7833
7899
  const cand = `${dir}/python3`;
7834
7900
  try {
7835
7901
  accessSync(cand, constants2.X_OK);
7836
- if (statSync12(cand).isFile())
7902
+ if (statSync13(cand).isFile())
7837
7903
  return cand;
7838
7904
  } catch {}
7839
7905
  }
@@ -7960,7 +8026,7 @@ var init_python = __esm(() => {
7960
8026
  init_shell();
7961
8027
  });
7962
8028
 
7963
- // ../../loki-ts/src/features/wall_manifest.ts
8029
+ // ../../loki-ts/src/util/ts_signatures.ts
7964
8030
  function templateEnd(s, i) {
7965
8031
  for (let j = i + 1;j < s.length; ) {
7966
8032
  const c = s[j];
@@ -8686,6 +8752,14 @@ function tsSignatures(src, jsx) {
8686
8752
  }
8687
8753
  return out2;
8688
8754
  }
8755
+ var REGEX_PREV = "(,=:[!&|?{;+-*%~^", isComment = (s, i) => s[i] === "/" && (s[i + 1] === "/" || s[i + 1] === "*"), MODS = "(?:(?:public|private|protected|static|readonly|abstract|async|get|set|declare|override)\\s+)*", MEMBER_GRAMMAR, NOT_MEMBER, RESERVED_AFTER_DECORATOR;
8756
+ var init_ts_signatures = __esm(() => {
8757
+ MEMBER_GRAMMAR = new RegExp(`^(?:@[\\w$.]+(?:\\([^)]*\\))?\\s*)*${MODS}\\*?\\s*(?:[A-Za-z_$][\\w$]*|#[A-Za-z_$][\\w$]*|\\[[^\\]]*\\])\\s*[?!]?\\s*(?:[(<:=]|$)`);
8758
+ NOT_MEMBER = /^(return|const|let|var|if|else|for|while|do|switch|case|default|throw|try|catch|finally|new|await|yield|break|continue|import|export|function|delete|typeof|void)\b/;
8759
+ RESERVED_AFTER_DECORATOR = /^(?:if|else|for|while|do|switch|case|try|catch|finally|return|throw|with|var|let|const|function|new|delete|typeof|void|yield|await|break|continue|import|debugger|instanceof|this|super|null|true|false)(?![\w$])/;
8760
+ });
8761
+
8762
+ // ../../loki-ts/src/features/wall_manifest.ts
8689
8763
  function packageRunner(content) {
8690
8764
  try {
8691
8765
  const pkg = JSON.parse(content);
@@ -8876,21 +8950,19 @@ var MANIFEST_MAX_LINES = 400, MAX_EXAMPLES = 2, EXAMPLE_LINES = 40, MAX_LAYOUT =
8876
8950
  const raw2 = stemOf(m).toLowerCase(), parent = m.split("/").slice(-2, -1)[0];
8877
8951
  return [normStem(raw2), ...["index", "__init__", "mod", "main"].includes(raw2) && parent ? [normStem(parent)] : []];
8878
8952
  }, norm3 = (s) => s.replace(/\r\n?/g, `
8879
- `), stemOf = (p) => (p.split("/").pop() ?? p).replace(/\.[^.]*$/, ""), byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.content < b.content ? -1 : a.content > b.content ? 1 : 0, REGEX_PREV = "(,=:[!&|?{;+-*%~^", isComment = (s, i) => s[i] === "/" && (s[i + 1] === "/" || s[i + 1] === "*"), MODS = "(?:(?:public|private|protected|static|readonly|abstract|async|get|set|declare|override)\\s+)*", MEMBER_GRAMMAR, NOT_MEMBER, RESERVED_AFTER_DECORATOR;
8953
+ `), stemOf = (p) => (p.split("/").pop() ?? p).replace(/\.[^.]*$/, ""), byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.content < b.content ? -1 : a.content > b.content ? 1 : 0;
8880
8954
  var init_wall_manifest = __esm(() => {
8881
8955
  init_python();
8956
+ init_ts_signatures();
8882
8957
  TEST_PATH = /(^|\/)(tests?|__tests__|spec)\/|\.(test|spec)\.[jt]sx?$|(^|\/)test_[^/]*\.py$|_test\.(py|go)$/;
8883
8958
  TEST_FILE = /\.(test|spec)\.[cm]?[jt]sx?$|(^|\/)test_[^/]*\.py$|_test\.py$/;
8884
8959
  EXAMPLE_EXT = /\.(py|[cm]?[jt]sx?)$/;
8885
8960
  GENERIC_STEMS = ["index", "init", "mod", "main"];
8886
- MEMBER_GRAMMAR = new RegExp(`^(?:@[\\w$.]+(?:\\([^)]*\\))?\\s*)*${MODS}\\*?\\s*(?:[A-Za-z_$][\\w$]*|#[A-Za-z_$][\\w$]*|\\[[^\\]]*\\])\\s*[?!]?\\s*(?:[(<:=]|$)`);
8887
- NOT_MEMBER = /^(return|const|let|var|if|else|for|while|do|switch|case|default|throw|try|catch|finally|new|await|yield|break|continue|import|export|function|delete|typeof|void)\b/;
8888
- RESERVED_AFTER_DECORATOR = /^(?:if|else|for|while|do|switch|case|try|catch|finally|return|throw|with|var|let|const|function|new|delete|typeof|void|yield|await|break|continue|import|debugger|instanceof|this|super|null|true|false)(?![\w$])/;
8889
8961
  });
8890
8962
 
8891
8963
  // ../../loki-ts/src/features/wall_manifest_wire.ts
8892
- import { createHash as createHash6 } from "crypto";
8893
- import { basename as basename9, dirname as dirname8 } from "path";
8964
+ import { createHash as createHash7 } from "crypto";
8965
+ import { basename as basename9, dirname as dirname9 } from "path";
8894
8966
  function blobEntries(ls) {
8895
8967
  const out2 = [];
8896
8968
  for (const raw2 of ls.toString("latin1").split("\x00")) {
@@ -8920,7 +8992,7 @@ function wallManifestFor(repoDir, tree, task, env = process.env) {
8920
8992
  return null;
8921
8993
  const low = task.toLowerCase().replace(/\\/g, "/");
8922
8994
  const token = (n2) => new RegExp(`(?<![A-Za-z0-9_])${n2.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![A-Za-z0-9_])`).test(low);
8923
- const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(basename9(e.path)) && e.path.includes("/") && token(dirname8(e.path));
8995
+ const dirModule = (e) => /^(index|__init__|mod|main)\.[^.]+$/.test(basename9(e.path)) && e.path.includes("/") && token(dirname9(e.path));
8924
8996
  const matched = all.filter((e) => SOURCE.test(e.path) && (token(basename9(e.path)) || token(e.path) || token(basename9(e.path).replace(/\.[^.]*$/, "")) || dirModule(e)));
8925
8997
  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]);
8926
8998
  const occ = new Map(matched.map((e) => [e, spans(e.path)]));
@@ -8949,7 +9021,7 @@ function wallManifestFor(repoDir, tree, task, env = process.env) {
8949
9021
  if (at !== cat.length)
8950
9022
  return null;
8951
9023
  const text2 = buildWallManifest([...files, ...listed.map((e) => ({ path: e.path, content: "" }))], named.map((e) => e.path), matched.map((e) => e.path));
8952
- return { text: text2, sha256: createHash6("sha256").update(text2).digest("hex") };
9024
+ return { text: text2, sha256: createHash7("sha256").update(text2).digest("hex") };
8953
9025
  } catch {
8954
9026
  return null;
8955
9027
  }
@@ -8981,12 +9053,12 @@ Example: test('name', () => { assert.strictEqual(fn(1), 2); }); Run: node --tes
8981
9053
  });
8982
9054
 
8983
9055
  // ../../loki-ts/src/engine10/cache.ts
8984
- import { createHash as createHash7 } from "crypto";
8985
- import { existsSync as existsSync17, mkdirSync as mkdirSync6, readFileSync as readFileSync19, writeFileSync as writeFileSync9 } from "fs";
9056
+ import { createHash as createHash8 } from "crypto";
9057
+ import { existsSync as existsSync17, mkdirSync as mkdirSync7, readFileSync as readFileSync20, writeFileSync as writeFileSync10 } from "fs";
8986
9058
  import { resolve as resolve8 } from "path";
8987
9059
  function repoKey(originUrl, repoDir) {
8988
9060
  const basis = originUrl && originUrl.trim() !== "" ? originUrl : resolve8(repoDir);
8989
- return createHash7("sha256").update(basis).digest("hex");
9061
+ return createHash8("sha256").update(basis).digest("hex");
8990
9062
  }
8991
9063
  function defaultCacheRoot() {
8992
9064
  return resolve8(homeLokiDir(), "cache", "v10");
@@ -8998,7 +9070,7 @@ function readJson3(path, isValid = (_v) => true) {
8998
9070
  if (!existsSync17(path))
8999
9071
  return null;
9000
9072
  try {
9001
- const parsed = JSON.parse(readFileSync19(path, "utf8"));
9073
+ const parsed = JSON.parse(readFileSync20(path, "utf8"));
9002
9074
  return isValid(parsed) ? parsed : null;
9003
9075
  } catch {
9004
9076
  return null;
@@ -9048,12 +9120,12 @@ function speedLikelyFiles(task, map, env = process.env) {
9048
9120
  var init_lean_select = () => {};
9049
9121
 
9050
9122
  // ../../loki-ts/src/util/claude_model.ts
9051
- import { readFileSync as readFileSync20 } from "fs";
9123
+ import { readFileSync as readFileSync21 } from "fs";
9052
9124
  import { resolve as resolve9 } from "path";
9053
9125
  function resolveClaudeModel(want) {
9054
9126
  try {
9055
9127
  const path = process.env["LOKI_MODEL_CATALOG"] || resolve9(REPO_ROOT, "providers/model_catalog.json");
9056
- return JSON.parse(readFileSync20(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
9128
+ return JSON.parse(readFileSync21(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
9057
9129
  } catch {
9058
9130
  return want;
9059
9131
  }
@@ -9113,8 +9185,8 @@ function routerMode(env = process.env) {
9113
9185
  var routerEnabled = (env = process.env) => routerMode(env) === "on";
9114
9186
 
9115
9187
  // ../../loki-ts/src/engine10/cost.ts
9116
- import { readdirSync as readdirSync9, readFileSync as readFileSync21 } from "fs";
9117
- import { join as join29 } from "path";
9188
+ import { readdirSync as readdirSync9, readFileSync as readFileSync22 } from "fs";
9189
+ import { join as join30 } from "path";
9118
9190
  function routerTelemetryOn(env = process.env) {
9119
9191
  return routerEnabled(env);
9120
9192
  }
@@ -9122,7 +9194,7 @@ function num3(v) {
9122
9194
  return typeof v === "number" && Number.isFinite(v) ? v : 0;
9123
9195
  }
9124
9196
  function resultCostPath(lokiRoot, iteration) {
9125
- return join29(lokiRoot, "metrics", `result-cost-${iteration}.json`);
9197
+ return join30(lokiRoot, "metrics", `result-cost-${iteration}.json`);
9126
9198
  }
9127
9199
  function sumResultCosts(lokiRoot, iterations, context = []) {
9128
9200
  const out2 = {
@@ -9153,7 +9225,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
9153
9225
  const parsed = new Map;
9154
9226
  for (const iter of iterations) {
9155
9227
  try {
9156
- parsed.set(iter, JSON.parse(readFileSync21(resultCostPath(lokiRoot, iter), "utf8")));
9228
+ parsed.set(iter, JSON.parse(readFileSync22(resultCostPath(lokiRoot, iter), "utf8")));
9157
9229
  } catch {}
9158
9230
  }
9159
9231
  const own = new Set(iterations);
@@ -9162,7 +9234,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
9162
9234
  if (own.has(iter))
9163
9235
  continue;
9164
9236
  try {
9165
- lookup.push({ iter, rec: JSON.parse(readFileSync21(resultCostPath(lokiRoot, iter), "utf8")) });
9237
+ lookup.push({ iter, rec: JSON.parse(readFileSync22(resultCostPath(lokiRoot, iter), "utf8")) });
9166
9238
  } catch {}
9167
9239
  }
9168
9240
  const verdicts = hooks.costRecords?.resumeVerdicts(lookup) ?? { ambiguous: [], separate: [] };
@@ -9267,19 +9339,19 @@ import {
9267
9339
  fstatSync as fstatSync5,
9268
9340
  fsyncSync as fsyncSync2,
9269
9341
  lstatSync as lstatSync6,
9270
- mkdirSync as mkdirSync8,
9342
+ mkdirSync as mkdirSync9,
9271
9343
  openSync as openSync6,
9272
9344
  readSync as readSync5,
9273
9345
  renameSync as renameSync4,
9274
9346
  rmSync as rmSync6,
9275
- statSync as statSync13,
9276
- unlinkSync as unlinkSync3,
9277
- writeFileSync as writeFileSync11,
9347
+ statSync as statSync14,
9348
+ unlinkSync as unlinkSync4,
9349
+ writeFileSync as writeFileSync12,
9278
9350
  writeSync as writeSync3
9279
9351
  } from "fs";
9280
- import { dirname as dirname9 } from "path";
9352
+ import { dirname as dirname10 } from "path";
9281
9353
  function durableWriteThenRename(target, body) {
9282
- mkdirSync8(dirname9(target), { recursive: true });
9354
+ mkdirSync9(dirname10(target), { recursive: true });
9283
9355
  const tmp = tmpPathFor(target);
9284
9356
  const fd = openSync6(tmp, "w");
9285
9357
  try {
@@ -9294,7 +9366,7 @@ function durableWriteThenRename(target, body) {
9294
9366
  function fsyncParentDir(target) {
9295
9367
  let dfd = null;
9296
9368
  try {
9297
- dfd = openSync6(dirname9(target), "r");
9369
+ dfd = openSync6(dirname10(target), "r");
9298
9370
  fsyncSync2(dfd);
9299
9371
  } catch {} finally {
9300
9372
  if (dfd !== null) {
@@ -9317,14 +9389,14 @@ var init_atomic = __esm(() => {
9317
9389
  });
9318
9390
 
9319
9391
  // ../../loki-ts/src/runner/budget.ts
9320
- import { existsSync as existsSync18, mkdirSync as mkdirSync9, readdirSync as readdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "fs";
9321
- import { dirname as dirname10, join as join30, resolve as resolve10 } from "path";
9392
+ import { existsSync as existsSync18, mkdirSync as mkdirSync10, readdirSync as readdirSync10, readFileSync as readFileSync23, writeFileSync as writeFileSync13 } from "fs";
9393
+ import { dirname as dirname11, join as join31, resolve as resolve10 } from "path";
9322
9394
  import { fileURLToPath as fileURLToPath2 } from "url";
9323
9395
  function loadDefaultMaxCostUsd() {
9324
- const here = dirname10(fileURLToPath2(import.meta.url));
9396
+ const here = dirname11(fileURLToPath2(import.meta.url));
9325
9397
  for (const rel of [["..", "..", "data"], ["..", "data"]]) {
9326
9398
  try {
9327
- const j = JSON.parse(readFileSync22(resolve10(here, ...rel, "model-pricing.json"), "utf8"));
9399
+ const j = JSON.parse(readFileSync23(resolve10(here, ...rel, "model-pricing.json"), "utf8"));
9328
9400
  if (typeof j.default_max_cost_usd === "number" && Number.isFinite(j.default_max_cost_usd) && j.default_max_cost_usd > 0)
9329
9401
  return j.default_max_cost_usd;
9330
9402
  } catch {}
@@ -9333,11 +9405,11 @@ function loadDefaultMaxCostUsd() {
9333
9405
  }
9334
9406
  function _loadPricing() {
9335
9407
  try {
9336
- const moduleDir = dirname10(fileURLToPath2(import.meta.url));
9408
+ const moduleDir = dirname11(fileURLToPath2(import.meta.url));
9337
9409
  const jsonPath = resolve10(moduleDir, "..", "..", "data", "model-pricing.json");
9338
9410
  if (!existsSync18(jsonPath))
9339
9411
  return _FALLBACK_PRICING;
9340
- const raw2 = JSON.parse(readFileSync22(jsonPath, "utf8"));
9412
+ const raw2 = JSON.parse(readFileSync23(jsonPath, "utf8"));
9341
9413
  const pricing2 = raw2["pricing"];
9342
9414
  if (!pricing2 || typeof pricing2 !== "object")
9343
9415
  return _FALLBACK_PRICING;
@@ -9467,7 +9539,7 @@ var init_model_rank = __esm(() => {
9467
9539
  });
9468
9540
 
9469
9541
  // ../../loki-ts/src/engine10/sizing.ts
9470
- import { existsSync as existsSync19, readFileSync as readFileSync23 } from "fs";
9542
+ import { existsSync as existsSync19, readFileSync as readFileSync24 } from "fs";
9471
9543
  import { basename as basename10 } from "path";
9472
9544
  function namedFiles(task, map) {
9473
9545
  return (map?.files ?? []).filter((f) => task.toLowerCase().includes(basename10(f).toLowerCase()));
@@ -9489,7 +9561,7 @@ function loadRepoMap(repomapRef) {
9489
9561
  if (!repomapRef || !existsSync19(repomapRef))
9490
9562
  return null;
9491
9563
  try {
9492
- return JSON.parse(readFileSync23(repomapRef, "utf8"));
9564
+ return JSON.parse(readFileSync24(repomapRef, "utf8"));
9493
9565
  } catch {
9494
9566
  return null;
9495
9567
  }
@@ -9520,8 +9592,8 @@ var init_sizing = __esm(() => {
9520
9592
  });
9521
9593
 
9522
9594
  // ../../loki-ts/src/project_model/schema.ts
9523
- import { existsSync as existsSync20, lstatSync as lstatSync7, realpathSync as realpathSync15, statSync as statSync14 } from "fs";
9524
- import { isAbsolute as isAbsolute3, join as join32, normalize, sep as sep9 } from "path";
9595
+ import { existsSync as existsSync20, lstatSync as lstatSync7, realpathSync as realpathSync15, statSync as statSync15 } from "fs";
9596
+ import { isAbsolute as isAbsolute3, join as join33, normalize, sep as sep9 } from "path";
9525
9597
  function safeRel(p) {
9526
9598
  const n2 = normalize(p.trim()).split(sep9).join("/").replace(/\/$/, "");
9527
9599
  if (n2 === "" || isAbsolute3(n2) || n2 === ".." || n2.startsWith("../"))
@@ -9530,7 +9602,7 @@ function safeRel(p) {
9530
9602
  }
9531
9603
  function insideRepo(repoDir, rel) {
9532
9604
  try {
9533
- const real2 = realpathSync15(join32(repoDir, rel));
9605
+ const real2 = realpathSync15(join33(repoDir, rel));
9534
9606
  const base = realpathSync15(repoDir);
9535
9607
  return real2 === base || real2.startsWith(base + sep9);
9536
9608
  } catch {
@@ -9543,8 +9615,8 @@ function checkCitation(repoDir, raw2) {
9543
9615
  const rel = safeRel(raw2.replace(/:\d+(?:-\d+)?$/, ""));
9544
9616
  if (rel === null)
9545
9617
  return `citation "${raw2}" is not a repo-relative path`;
9546
- const abs = join32(repoDir, rel);
9547
- if (!existsSync20(abs) || !statSync14(abs).isFile() || !insideRepo(repoDir, rel))
9618
+ const abs = join33(repoDir, rel);
9619
+ if (!existsSync20(abs) || !statSync15(abs).isFile() || !insideRepo(repoDir, rel))
9548
9620
  return `citation "${raw2}" names a file that does not exist`;
9549
9621
  return null;
9550
9622
  }
@@ -9555,7 +9627,7 @@ function checkFingerprint(repoDir, raw2) {
9555
9627
  if (rel === null)
9556
9628
  return `fingerprint "${raw2}" is not a repo-relative path`;
9557
9629
  try {
9558
- if (!lstatSync7(join32(repoDir, rel)).isFile() || !insideRepo(repoDir, rel))
9630
+ if (!lstatSync7(join33(repoDir, rel)).isFile() || !insideRepo(repoDir, rel))
9559
9631
  return `fingerprint "${raw2}" is not a regular file inside the repo`;
9560
9632
  } catch {
9561
9633
  return `fingerprint "${raw2}" names a file that does not exist`;
@@ -9583,8 +9655,8 @@ function checkDir(repoDir, v, where, errs) {
9583
9655
  errs.push(`${where}: must be a repo-relative directory ("." for the repo root)`);
9584
9656
  return ".";
9585
9657
  }
9586
- const abs = join32(repoDir, rel);
9587
- if (!existsSync20(abs) || !statSync14(abs).isDirectory() || !insideRepo(repoDir, rel))
9658
+ const abs = join33(repoDir, rel);
9659
+ if (!existsSync20(abs) || !statSync15(abs).isDirectory() || !insideRepo(repoDir, rel))
9588
9660
  errs.push(`${where}: directory "${rel}" does not exist`);
9589
9661
  return rel;
9590
9662
  }
@@ -9686,9 +9758,9 @@ var init_schema = __esm(() => {
9686
9758
  });
9687
9759
 
9688
9760
  // ../../loki-ts/src/project_model/gather.ts
9689
- import { createHash as createHash8 } from "crypto";
9690
- import { closeSync as closeSync7, lstatSync as lstatSync8, openSync as openSync7, readFileSync as readFileSync24, readSync as readSync6 } from "fs";
9691
- import { dirname as dirname11, join as join33 } from "path";
9761
+ import { createHash as createHash9 } from "crypto";
9762
+ import { closeSync as closeSync7, lstatSync as lstatSync8, openSync as openSync7, readFileSync as readFileSync25, readSync as readSync6 } from "fs";
9763
+ import { dirname as dirname12, join as join34 } from "path";
9692
9764
  function listShallow(repoDir) {
9693
9765
  try {
9694
9766
  const out2 = safeGit(repoDir, ["ls-files", "-z"], { maxBuffer: 256 * 1024 * 1024 });
@@ -9698,10 +9770,10 @@ function listShallow(repoDir) {
9698
9770
  }
9699
9771
  }
9700
9772
  function shallowDirs(repoDir) {
9701
- return [...new Set(listShallow(repoDir).map((p) => dirname11(p)))].sort();
9773
+ return [...new Set(listShallow(repoDir).map((p) => dirname12(p)))].sort();
9702
9774
  }
9703
9775
  function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
9704
- const h = createHash8("sha256");
9776
+ const h = createHash9("sha256");
9705
9777
  h.update(`${MODEL_REV}
9706
9778
  `);
9707
9779
  if (committedHash !== null)
@@ -9714,9 +9786,9 @@ function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
9714
9786
  if (checkFingerprint(repoDir, f) !== null)
9715
9787
  h.update("invalid");
9716
9788
  else {
9717
- const abs = join33(repoDir, f);
9789
+ const abs = join34(repoDir, f);
9718
9790
  const size = lstatSync8(abs).size;
9719
- h.update(size <= GATHER_CAPS.maxHashBytes ? readFileSync24(abs) : `too-large:${size}`);
9791
+ h.update(size <= GATHER_CAPS.maxHashBytes ? readFileSync25(abs) : `too-large:${size}`);
9720
9792
  }
9721
9793
  } catch {
9722
9794
  h.update("missing");
@@ -9741,7 +9813,7 @@ function committedModelHash(raw2) {
9741
9813
  if (typeof raw2 !== "object" || raw2 === null || Array.isArray(raw2))
9742
9814
  return null;
9743
9815
  const { key: _key, expiresAt: _exp, ...rest } = raw2;
9744
- return createHash8("sha256").update(JSON.stringify(rest)).digest("hex");
9816
+ return createHash9("sha256").update(JSON.stringify(rest)).digest("hex");
9745
9817
  }
9746
9818
  var GATHER_CAPS, depthOf = (p) => p.split("/").length, MODEL_REV = "model-rev:2";
9747
9819
  var init_gather = __esm(() => {
@@ -9759,14 +9831,14 @@ var init_gather = __esm(() => {
9759
9831
  });
9760
9832
 
9761
9833
  // ../../loki-ts/src/project_model/discover.ts
9762
- import { existsSync as existsSync21, mkdirSync as mkdirSync10, readFileSync as readFileSync25, rmSync as rmSync7, writeFileSync as writeFileSync13 } from "fs";
9763
- import { join as join34 } from "path";
9834
+ import { existsSync as existsSync21, mkdirSync as mkdirSync11, readFileSync as readFileSync26, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "fs";
9835
+ import { join as join35 } from "path";
9764
9836
  function projectModelEnabled(env = process.env) {
9765
9837
  return env["LOKI_E10_PROJECT_MODEL"] !== "0";
9766
9838
  }
9767
9839
  function loadCached(repoDir, now2 = Date.now()) {
9768
9840
  try {
9769
- return parseCached(repoDir, JSON.parse(readFileSync25(join34(repoDir, PROJECT_FILE), "utf8")), now2);
9841
+ return parseCached(repoDir, JSON.parse(readFileSync26(join35(repoDir, PROJECT_FILE), "utf8")), now2);
9770
9842
  } catch {
9771
9843
  return null;
9772
9844
  }
@@ -9781,7 +9853,7 @@ function loadCommitted(repoDir) {
9781
9853
  };
9782
9854
  let raw2;
9783
9855
  try {
9784
- raw2 = JSON.parse(readFileSync25(join34(repoDir, PROJECT_FILE), "utf8"));
9856
+ raw2 = JSON.parse(readFileSync26(join35(repoDir, PROJECT_FILE), "utf8"));
9785
9857
  } catch (e) {
9786
9858
  return ignore(`unreadable JSON (${e instanceof Error ? e.message : String(e)})`);
9787
9859
  }
@@ -9854,7 +9926,7 @@ var clean2 = (p) => typeof p === "string" ? posix.normalize(p.replace(/\\/g, "/"
9854
9926
  var init_api = () => {};
9855
9927
 
9856
9928
  // ../../loki-ts/src/project_model/resolve.ts
9857
- import { join as join35 } from "path";
9929
+ import { join as join36 } from "path";
9858
9930
  function loadProjectApi(repoDir, env = process.env) {
9859
9931
  if (!projectModelEnabled(env))
9860
9932
  return null;
@@ -9876,7 +9948,7 @@ function siteFor(api, repoDir, file) {
9876
9948
  const rel = api.relativeToRoot(file);
9877
9949
  if (!pkg || pkg.root === "." || rel === null)
9878
9950
  return null;
9879
- return { pkg, root: pkg.root, cwd: join35(repoDir, pkg.root), file: rel };
9951
+ return { pkg, root: pkg.root, cwd: join36(repoDir, pkg.root), file: rel };
9880
9952
  }
9881
9953
  function groupByPackage(api, repoDir, files) {
9882
9954
  const out2 = new Map;
@@ -9909,9 +9981,9 @@ var init_scope = __esm(() => {
9909
9981
 
9910
9982
  // ../../loki-ts/src/e10ext/assert_delta.ts
9911
9983
  import { execFileSync as execFileSync5 } from "child_process";
9912
- import { mkdtempSync as mkdtempSync4, readFileSync as readFileSync26, rmSync as rmSync8 } from "fs";
9984
+ import { mkdtempSync as mkdtempSync4, readFileSync as readFileSync27, rmSync as rmSync8 } from "fs";
9913
9985
  import { tmpdir as tmpdir6 } from "os";
9914
- import { join as join36 } from "path";
9986
+ import { join as join37 } from "path";
9915
9987
  import { basename as basename11 } from "path";
9916
9988
  function classifyAssertDelta(inp) {
9917
9989
  const f = basename11(inp.path);
@@ -9921,7 +9993,7 @@ function classifyAssertDelta(inp) {
9921
9993
  return WEAKENED;
9922
9994
  let cwd = "";
9923
9995
  try {
9924
- cwd = mkdtempSync4(join36(tmpdir6(), "loki-ad-"));
9996
+ cwd = mkdtempSync4(join37(tmpdir6(), "loki-ad-"));
9925
9997
  const raw2 = execFileSync5("python3", ["-I", "-c", PY], {
9926
9998
  input: JSON.stringify({ path: inp.path, base: inp.base, head: inp.head, task: inp.task }),
9927
9999
  cwd,
@@ -9952,7 +10024,7 @@ function assertDeltaNotes(repoDir, baseSha, headRef, path, task, baseCounts, hea
9952
10024
  return null;
9953
10025
  try {
9954
10026
  const show = (ref) => safeGit(repoDir, ["show", `${ref}:${path}`]);
9955
- const head = headRef ? show(headRef) : readFileSync26(join36(repoDir, path), "utf8");
10027
+ const head = headRef ? show(headRef) : readFileSync27(join37(repoDir, path), "utf8");
9956
10028
  const r = classifyTestEdit(path, show(baseSha), head, task, baseCounts, headCounts);
9957
10029
  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;
9958
10030
  } catch {
@@ -10176,7 +10248,7 @@ var init_runner_errors = __esm(() => {
10176
10248
  });
10177
10249
 
10178
10250
  // ../../loki-ts/src/engine10/testmap.ts
10179
- import { basename as basename12, extname, join as join37, relative as relative3, sep as sep10 } from "path";
10251
+ import { basename as basename12, extname, join as join38, relative as relative3, sep as sep10 } from "path";
10180
10252
  function isTestFile(rel) {
10181
10253
  const name = basename12(rel);
10182
10254
  return JS_TEST_RE.test(name) || PY_TEST_RE.test(name) || GO_TEST_RE.test(name);
@@ -10206,8 +10278,8 @@ var init_testmap = __esm(() => {
10206
10278
  });
10207
10279
 
10208
10280
  // ../../loki-ts/src/util/check_result.ts
10209
- import { mkdirSync as mkdirSync11, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync14 } from "fs";
10210
- import { basename as basename13, join as join38 } from "path";
10281
+ import { mkdirSync as mkdirSync12, readFileSync as readFileSync28, renameSync as renameSync5, writeFileSync as writeFileSync15 } from "fs";
10282
+ import { basename as basename13, join as join39 } from "path";
10211
10283
  function plainTestEnv(base = process.env) {
10212
10284
  const e = {};
10213
10285
  for (const [k, v] of Object.entries(tokenFreeEnv(base)))
@@ -10499,7 +10571,7 @@ function diffFiles(repoDir, baseSha) {
10499
10571
  return f;
10500
10572
  let n2 = 0;
10501
10573
  try {
10502
- n2 = readFileSync27(join38(repoDir, path), "utf8").split(`
10574
+ n2 = readFileSync28(join39(repoDir, path), "utf8").split(`
10503
10575
  `).length;
10504
10576
  } catch {}
10505
10577
  return { path, added: n2, deleted: 0, status: "added" };
@@ -10507,9 +10579,9 @@ function diffFiles(repoDir, baseSha) {
10507
10579
  }
10508
10580
  function recordRisk(repoDir, a) {
10509
10581
  try {
10510
- const dir = join38(repoDir, ".loki", "state"), p = join38(dir, "risk-tier.json");
10511
- mkdirSync11(dir, { recursive: true });
10512
- writeFileSync14(`${p}.tmp`, JSON.stringify(a, null, 2) + `
10582
+ const dir = join39(repoDir, ".loki", "state"), p = join39(dir, "risk-tier.json");
10583
+ mkdirSync12(dir, { recursive: true });
10584
+ writeFileSync15(`${p}.tmp`, JSON.stringify(a, null, 2) + `
10513
10585
  `);
10514
10586
  renameSync5(`${p}.tmp`, p);
10515
10587
  return p;
@@ -10552,10 +10624,10 @@ var init_check_result = __esm(() => {
10552
10624
  import { spawnSync as spawnSync3 } from "child_process";
10553
10625
  import { mkdtempSync as mkdtempSync5, realpathSync as realpathSync16, rmSync as rmSync9 } from "fs";
10554
10626
  import { tmpdir as tmpdir7 } from "os";
10555
- import { basename as basename14, extname as extname2, join as join39 } from "path";
10627
+ import { basename as basename14, extname as extname2, join as join40 } from "path";
10556
10628
  function changedFilesNamed(out2, repoDir, changed) {
10557
10629
  return changed.filter((f) => {
10558
- if (out2.includes(f) || out2.includes(join39(repoDir, f)))
10630
+ if (out2.includes(f) || out2.includes(join40(repoDir, f)))
10559
10631
  return true;
10560
10632
  const segs = f.split("/");
10561
10633
  if (suffixes(segs, 2).some((x) => x !== f && bounded(out2, x, "(?![\\w-])")))
@@ -10666,7 +10738,7 @@ async function loadErrorIsHarnessOwned(i) {
10666
10738
  return false;
10667
10739
  if (i.args.some((a) => changed.includes(a.replace(/^\.\//, ""))))
10668
10740
  return false;
10669
- const dir = mkdtempSync5(join39(tmpdir7(), "e10-loadown-"));
10741
+ const dir = mkdtempSync5(join40(tmpdir7(), "e10-loadown-"));
10670
10742
  const git3 = (args) => {
10671
10743
  safeGit(i.repoDir, args, { stdio: "ignore" });
10672
10744
  };
@@ -10698,7 +10770,7 @@ var init_load_owner = __esm(() => {
10698
10770
  });
10699
10771
 
10700
10772
  // ../../loki-ts/src/util/wall_owned.ts
10701
- import { isAbsolute as isAbsolute4, join as join40, relative as relative4 } from "path";
10773
+ import { isAbsolute as isAbsolute4, join as join41, relative as relative4 } from "path";
10702
10774
  function failingLocations(raw2, cwd, repoDir) {
10703
10775
  const out2 = raw2.replace(ANSI2, "").replace(/\r\n?/g, `
10704
10776
  `), files = new Set;
@@ -10730,7 +10802,7 @@ function failingLocations(raw2, cwd, repoDir) {
10730
10802
  }
10731
10803
  if (errors2 === 0 || located !== errors2)
10732
10804
  return null;
10733
- return [...files].map((f) => relative4(repoDir, isAbsolute4(f) ? f : join40(cwd, f)));
10805
+ return [...files].map((f) => relative4(repoDir, isAbsolute4(f) ? f : join41(cwd, f)));
10734
10806
  }
10735
10807
  function wallOwnedFailure(raw2, cwd, repoDir, wall) {
10736
10808
  const locs = failingLocations(raw2, cwd, repoDir);
@@ -10759,11 +10831,11 @@ var init_state = __esm(() => {
10759
10831
  });
10760
10832
 
10761
10833
  // ../../loki-ts/src/runner/repo_profile.ts
10762
- import { existsSync as existsSync22, readFileSync as readFileSync28, mkdirSync as mkdirSync12, readdirSync as readdirSync11, renameSync as renameSync6, rmSync as rmSync10, writeFileSync as writeFileSync15 } from "fs";
10763
- import { basename as basename15, join as join41, resolve as resolve11, isAbsolute as isAbsolute5 } from "path";
10834
+ import { existsSync as existsSync22, readFileSync as readFileSync29, mkdirSync as mkdirSync13, readdirSync as readdirSync11, renameSync as renameSync6, rmSync as rmSync10, writeFileSync as writeFileSync16 } from "fs";
10835
+ import { basename as basename15, join as join42, resolve as resolve11, isAbsolute as isAbsolute5 } from "path";
10764
10836
  function loadProfile(repoDir) {
10765
10837
  try {
10766
- const p = JSON.parse(readFileSync28(commandProfilePath(repoDir), "utf8"));
10838
+ const p = JSON.parse(readFileSync29(commandProfilePath(repoDir), "utf8"));
10767
10839
  return p?.version === 1 && Array.isArray(p.commands) && p.baseline ? p : null;
10768
10840
  } catch {
10769
10841
  return null;
@@ -10794,7 +10866,7 @@ function attributeFullSuite(repoDir, baseSha, full, blocked, changed) {
10794
10866
  const block = new Set(blocked);
10795
10867
  return attribute(repoDir, baseSha, bad.map((c) => ({ name: c.name, ...c.ids ? { ids: c.ids } : {}, eligible: (c.ids ?? []).every((i) => !block.has(i) && !changed.some((f) => i.includes(f))) })));
10796
10868
  }
10797
- var commandProfilePath = (repoDir) => join41(repoDir, ".loki", "state", "repo-profile.json");
10869
+ var commandProfilePath = (repoDir) => join42(repoDir, ".loki", "state", "repo-profile.json");
10798
10870
  var init_repo_profile = __esm(() => {
10799
10871
  init_failures();
10800
10872
  init_check_result();
@@ -10804,23 +10876,23 @@ var init_repo_profile = __esm(() => {
10804
10876
  });
10805
10877
 
10806
10878
  // ../../loki-ts/src/project_graph.ts
10807
- import { createHash as createHash9 } from "crypto";
10879
+ import { createHash as createHash10 } from "crypto";
10808
10880
  import {
10809
10881
  existsSync as existsSync23,
10810
10882
  readdirSync as readdirSync12,
10811
- readFileSync as readFileSync29,
10812
- statSync as statSync15,
10813
- writeFileSync as writeFileSync16,
10814
- mkdirSync as mkdirSync13
10883
+ readFileSync as readFileSync30,
10884
+ statSync as statSync16,
10885
+ writeFileSync as writeFileSync17,
10886
+ mkdirSync as mkdirSync14
10815
10887
  } from "fs";
10816
- import { basename as basename16, dirname as dirname12, join as join42, resolve as resolve12 } from "path";
10888
+ import { basename as basename16, dirname as dirname13, join as join43, resolve as resolve12 } from "path";
10817
10889
  function readManifest(path) {
10818
10890
  if (!existsSync23(path)) {
10819
10891
  return null;
10820
10892
  }
10821
10893
  let raw2;
10822
10894
  try {
10823
- raw2 = readFileSync29(path, "utf8");
10895
+ raw2 = readFileSync30(path, "utf8");
10824
10896
  } catch {
10825
10897
  return null;
10826
10898
  }
@@ -10872,12 +10944,12 @@ function resolveMembers(rootDir, declared, selfBasename) {
10872
10944
  for (const child of children) {
10873
10945
  if (!matchPattern(name, child))
10874
10946
  continue;
10875
- const full = join42(rootDir, child);
10947
+ const full = join43(rootDir, child);
10876
10948
  if (seen.has(full))
10877
10949
  continue;
10878
10950
  let st;
10879
10951
  try {
10880
- st = statSync15(full);
10952
+ st = statSync16(full);
10881
10953
  } catch {
10882
10954
  continue;
10883
10955
  }
@@ -10889,18 +10961,18 @@ function resolveMembers(rootDir, declared, selfBasename) {
10889
10961
  }
10890
10962
  if (declared.length === 0) {
10891
10963
  for (const child of children) {
10892
- const full = join42(rootDir, child);
10964
+ const full = join43(rootDir, child);
10893
10965
  if (seen.has(full))
10894
10966
  continue;
10895
10967
  let st;
10896
10968
  try {
10897
- st = statSync15(full);
10969
+ st = statSync16(full);
10898
10970
  } catch {
10899
10971
  continue;
10900
10972
  }
10901
10973
  if (!st.isDirectory())
10902
10974
  continue;
10903
- if (!existsSync23(join42(full, ".loki", "app.json")))
10975
+ if (!existsSync23(join43(full, ".loki", "app.json")))
10904
10976
  continue;
10905
10977
  seen.add(full);
10906
10978
  out2.push(full);
@@ -10913,25 +10985,25 @@ function cacheKey(manifestPaths) {
10913
10985
  for (const p of manifestPaths.sort()) {
10914
10986
  let mtime = 0;
10915
10987
  try {
10916
- mtime = statSync15(p).mtimeMs;
10988
+ mtime = statSync16(p).mtimeMs;
10917
10989
  } catch {}
10918
10990
  parts.push(`${p}:${mtime}`);
10919
10991
  }
10920
- return createHash9("sha256").update(parts.join("|")).digest("hex");
10992
+ return createHash10("sha256").update(parts.join("|")).digest("hex");
10921
10993
  }
10922
10994
  function writeCache(targetDir, key, result) {
10923
10995
  try {
10924
- const cacheDir = join42(targetDir, ".loki", "state");
10925
- mkdirSync13(cacheDir, { recursive: true });
10926
- const cachePath = join42(cacheDir, "project-graph.json");
10927
- writeFileSync16(cachePath, JSON.stringify({ key, result }, null, 2), "utf8");
10996
+ const cacheDir = join43(targetDir, ".loki", "state");
10997
+ mkdirSync14(cacheDir, { recursive: true });
10998
+ const cachePath = join43(cacheDir, "project-graph.json");
10999
+ writeFileSync17(cachePath, JSON.stringify({ key, result }, null, 2), "utf8");
10928
11000
  } catch {}
10929
11001
  }
10930
11002
  function discoverProjectGraph(targetDir) {
10931
11003
  const absTarget = resolve12(targetDir);
10932
- const targetManifest = join42(absTarget, ".loki", "app.json");
10933
- const parentDir = dirname12(absTarget);
10934
- const parentManifest = join42(parentDir, ".loki", "app.json");
11004
+ const targetManifest = join43(absTarget, ".loki", "app.json");
11005
+ const parentDir = dirname13(absTarget);
11006
+ const parentManifest = join43(parentDir, ".loki", "app.json");
10935
11007
  const examined = [];
10936
11008
  let chosenManifest = null;
10937
11009
  let chosenRoot = "";
@@ -10951,7 +11023,7 @@ function discoverProjectGraph(targetDir) {
10951
11023
  const members = resolveMembers(chosenRoot, declared, basename16(absTarget));
10952
11024
  const filtered = [];
10953
11025
  for (const m of members) {
10954
- const sibManifestPath = join42(m, ".loki", "app.json");
11026
+ const sibManifestPath = join43(m, ".loki", "app.json");
10955
11027
  if (existsSync23(sibManifestPath)) {
10956
11028
  examined.push(sibManifestPath);
10957
11029
  const sibManifest = readManifest(sibManifestPath);
@@ -11024,15 +11096,15 @@ var init_steer = __esm(() => {
11024
11096
  });
11025
11097
 
11026
11098
  // ../../loki-ts/src/util/pr_lessons.ts
11027
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync30 } from "fs";
11028
- import { dirname as dirname13, join as join43 } from "path";
11029
- import { createHash as createHash10 } from "crypto";
11099
+ import { existsSync as existsSync24, mkdirSync as mkdirSync15, readFileSync as readFileSync31 } from "fs";
11100
+ import { dirname as dirname14, join as join44 } from "path";
11101
+ import { createHash as createHash11 } from "crypto";
11030
11102
  function loadLessons(repoDir) {
11031
11103
  const p = lessonsPath(repoDir);
11032
11104
  if (!existsSync24(p))
11033
11105
  return [];
11034
11106
  try {
11035
- const j = JSON.parse(readFileSync30(p, "utf-8"));
11107
+ const j = JSON.parse(readFileSync31(p, "utf-8"));
11036
11108
  return Array.isArray(j.lessons) ? j.lessons : [];
11037
11109
  } catch {
11038
11110
  return [];
@@ -11040,11 +11112,11 @@ function loadLessons(repoDir) {
11040
11112
  }
11041
11113
  function save(repoDir, lessons) {
11042
11114
  const p = lessonsPath(repoDir);
11043
- mkdirSync14(dirname13(p), { recursive: true });
11115
+ mkdirSync15(dirname14(p), { recursive: true });
11044
11116
  atomicWriteJson(p, { version: 2, lessons });
11045
11117
  }
11046
11118
  function appendReceiptFact(repoDir, f, now2 = () => new Date) {
11047
- const id = `rcp-${createHash10("sha256").update(f.runId).digest("hex").slice(0, 12)}`;
11119
+ const id = `rcp-${createHash11("sha256").update(f.runId).digest("hex").slice(0, 12)}`;
11048
11120
  const lessons = loadLessons(repoDir);
11049
11121
  if (lessons.some((l) => l.id === id))
11050
11122
  return false;
@@ -11074,7 +11146,7 @@ function recordRunVerdict(repoDir, runId, verdict) {
11074
11146
  if (dirty)
11075
11147
  save(repoDir, lessons);
11076
11148
  }
11077
- var lessonsPath = (repoDir) => join43(repoDir, ".loki", "memory", "semantic", "pr-lessons.json"), KINDS;
11149
+ var lessonsPath = (repoDir) => join44(repoDir, ".loki", "memory", "semantic", "pr-lessons.json"), KINDS;
11078
11150
  var init_pr_lessons = __esm(() => {
11079
11151
  init_atomic();
11080
11152
  KINDS = new Set(["pr", "receipt", "ticket", "rejected"]);
@@ -11090,19 +11162,19 @@ var init_model_downgrades = __esm(() => {
11090
11162
  var init_mcp_config = () => {};
11091
11163
 
11092
11164
  // ../../loki-ts/src/providers/claude_flags.ts
11093
- import { existsSync as existsSync25, readFileSync as readFileSync31 } from "fs";
11094
- import { resolve as resolvePath, dirname as dirname14 } from "path";
11165
+ import { existsSync as existsSync25, readFileSync as readFileSync32 } from "fs";
11166
+ import { resolve as resolvePath, dirname as dirname15 } from "path";
11095
11167
  import { fileURLToPath as fileURLToPath3 } from "url";
11096
11168
  function designArchetypesText() {
11097
11169
  try {
11098
- const moduleDir = dirname14(fileURLToPath3(import.meta.url));
11170
+ const moduleDir = dirname15(fileURLToPath3(import.meta.url));
11099
11171
  for (const rel of [
11100
11172
  ["..", "..", "..", "references", "design-archetypes.md"],
11101
11173
  ["..", "..", "references", "design-archetypes.md"]
11102
11174
  ]) {
11103
11175
  const p = resolvePath(moduleDir, ...rel);
11104
11176
  if (existsSync25(p))
11105
- return readFileSync31(p, "utf8");
11177
+ return readFileSync32(p, "utf8");
11106
11178
  }
11107
11179
  } catch {}
11108
11180
  return "";
@@ -11180,14 +11252,14 @@ var init_providers = __esm(() => {
11180
11252
  });
11181
11253
 
11182
11254
  // ../../loki-ts/src/runner/router/route_record.ts
11183
- import { existsSync as existsSync26, lstatSync as lstatSync9, mkdirSync as mkdirSync15, readFileSync as readFileSync32, writeFileSync as writeFileSync17 } from "fs";
11184
- import { join as join44 } from "path";
11255
+ import { existsSync as existsSync26, lstatSync as lstatSync9, mkdirSync as mkdirSync16, readFileSync as readFileSync33, writeFileSync as writeFileSync18 } from "fs";
11256
+ import { join as join45 } from "path";
11185
11257
  function loadRouteRecord(runDir) {
11186
11258
  try {
11187
- const p = join44(runDir, ROUTE_RECORD_FILE);
11259
+ const p = join45(runDir, ROUTE_RECORD_FILE);
11188
11260
  if (!existsSync26(p) || !lstatSync9(p).isFile())
11189
11261
  return;
11190
- const v = JSON.parse(readFileSync32(p, "utf8"));
11262
+ const v = JSON.parse(readFileSync33(p, "utf8"));
11191
11263
  return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
11192
11264
  } catch {
11193
11265
  return;
@@ -11197,7 +11269,7 @@ var ROUTE_RECORD_FILE = "route.json";
11197
11269
  var init_route_record = () => {};
11198
11270
 
11199
11271
  // ../../loki-ts/src/runner/router/history_store.ts
11200
- import { existsSync as existsSync27, mkdirSync as mkdirSync16, readFileSync as readFileSync33, renameSync as renameSync7, rmSync as rmSync11, writeFileSync as writeFileSync18 } from "fs";
11272
+ import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync34, renameSync as renameSync7, rmSync as rmSync11, writeFileSync as writeFileSync19 } from "fs";
11201
11273
  import { resolve as resolve13 } from "path";
11202
11274
  function validRun(v) {
11203
11275
  if (typeof v !== "object" || v === null)
@@ -11213,7 +11285,7 @@ function readRunHistory(key, cacheRoot) {
11213
11285
  if (!existsSync27(path))
11214
11286
  return [];
11215
11287
  try {
11216
- const parsed = JSON.parse(readFileSync33(path, "utf8"));
11288
+ const parsed = JSON.parse(readFileSync34(path, "utf8"));
11217
11289
  const runs2 = parsed?.runs;
11218
11290
  return Array.isArray(runs2) ? runs2.filter(validRun) : [];
11219
11291
  } catch {
@@ -11223,11 +11295,11 @@ function readRunHistory(key, cacheRoot) {
11223
11295
  function appendRunOutcome(key, outcome, cacheRoot) {
11224
11296
  try {
11225
11297
  const runs2 = [...readRunHistory(key, cacheRoot), outcome].slice(-HISTORY_CAP);
11226
- mkdirSync16(repoCacheDir(key, cacheRoot), { recursive: true });
11298
+ mkdirSync17(repoCacheDir(key, cacheRoot), { recursive: true });
11227
11299
  const target = historyPath(key, cacheRoot);
11228
11300
  const tmp = `${target}.${process.pid}.tmp`;
11229
11301
  try {
11230
- writeFileSync18(tmp, JSON.stringify({ runs: runs2 }));
11302
+ writeFileSync19(tmp, JSON.stringify({ runs: runs2 }));
11231
11303
  renameSync7(tmp, target);
11232
11304
  } catch (e) {
11233
11305
  rmSync11(tmp, { force: true, recursive: false });
@@ -11247,7 +11319,7 @@ var init_history_store = __esm(() => {
11247
11319
  });
11248
11320
 
11249
11321
  // ../../loki-ts/src/runner/router/history.ts
11250
- import { dirname as dirname15, join as join45, resolve as resolve14 } from "path";
11322
+ import { dirname as dirname16, join as join46, resolve as resolve14 } from "path";
11251
11323
  import { fileURLToPath as fileURLToPath4 } from "url";
11252
11324
  function shapeKey(model) {
11253
11325
  if (!model || model.status !== "ok")
@@ -11276,7 +11348,7 @@ var init_history = __esm(() => {
11276
11348
  init_discover2();
11277
11349
  init_gather();
11278
11350
  init_history_store();
11279
- SHAPE_DEFAULTS_FILE = resolve14(dirname15(fileURLToPath4(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
11351
+ SHAPE_DEFAULTS_FILE = resolve14(dirname16(fileURLToPath4(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
11280
11352
  });
11281
11353
 
11282
11354
  // ../../loki-ts/src/runner/router/plan_route.ts
@@ -11407,7 +11479,7 @@ var init_worker = __esm(() => {
11407
11479
  });
11408
11480
 
11409
11481
  // ../../loki-ts/src/project_model/package_suite.ts
11410
- import { join as join46 } from "path";
11482
+ import { join as join47 } from "path";
11411
11483
  async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
11412
11484
  const api = loadProjectApi(repoDir);
11413
11485
  if (!isMultiRoot(api))
@@ -11418,7 +11490,7 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
11418
11490
  for (const pkg of withTests) {
11419
11491
  const tc = pkg.commands.test, name = `full suite: ${pkg.name}`, cmd = `(cd ${tc.cwd} && ${tc.cmd})`;
11420
11492
  const started = Date.now();
11421
- const r = await run(["bash", "-c", tc.cmd], { cwd: join46(repoDir, tc.cwd), timeoutMs: opts.timeoutMs, ...opts.path ? { env: { PATH: opts.path } } : {} });
11493
+ const r = await run(["bash", "-c", tc.cmd], { cwd: join47(repoDir, tc.cwd), timeoutMs: opts.timeoutMs, ...opts.path ? { env: { PATH: opts.path } } : {} });
11422
11494
  const duration_s = (Date.now() - started) / 1000;
11423
11495
  if (signal.aborted) {
11424
11496
  checks.push({ name, cmd, result: "not_run", duration_s });
@@ -11427,7 +11499,7 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
11427
11499
  }
11428
11500
  const out2 = `${r.stdout}
11429
11501
  ${r.stderr}`;
11430
- const lr = r.exitCode === 0 || !opts.baseSha ? undefined : await harnessLoadReason({ repoDir, baseSha: opts.baseSha, out: out2, cmd: "bash", args: ["-c", tc.cmd], signal, cwd: join46(repoDir, tc.cwd), ...opts.path ? { env: { PATH: opts.path } } : {} });
11502
+ const lr = r.exitCode === 0 || !opts.baseSha ? undefined : await harnessLoadReason({ repoDir, baseSha: opts.baseSha, out: out2, cmd: "bash", args: ["-c", tc.cmd], signal, cwd: join47(repoDir, tc.cwd), ...opts.path ? { env: { PATH: opts.path } } : {} });
11431
11503
  if (lr) {
11432
11504
  checks.push({ name, cmd, result: "not_run", duration_s });
11433
11505
  notProven.add(`${lr} (${name}; harness-owned)`);
@@ -11460,8 +11532,8 @@ __export(exports_deep, {
11460
11532
  DEFAULT_SECRET_SCAN_SH: () => DEFAULT_SECRET_SCAN_SH,
11461
11533
  DEFAULT_PUSH_SH: () => DEFAULT_PUSH_SH
11462
11534
  });
11463
- import { existsSync as existsSync28, mkdirSync as mkdirSync17, writeFileSync as writeFileSync19 } from "fs";
11464
- import { join as join47 } from "path";
11535
+ import { existsSync as existsSync28, mkdirSync as mkdirSync18, writeFileSync as writeFileSync20 } from "fs";
11536
+ import { join as join48 } from "path";
11465
11537
  async function runFullSuite(ctx, signal, opts, checks, notProven) {
11466
11538
  if (await runPackageSuites(ctx.repoDir, signal, { path: opts.path, timeoutMs: opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS, baseSha: ctx.baseSha }, checks, notProven))
11467
11539
  return;
@@ -11558,7 +11630,7 @@ async function runSecretScan(ctx, changed, opts, checks, notProven) {
11558
11630
  }
11559
11631
  const inline = 'script="$1"; shift; . "$script" || exit 3; hit=0; for f in "$@"; do if _commit_scan_secret_file "$f" || _commit_path_looks_secret "$f"; then printf "%s\\n" "$f"; hit=1; fi; done; exit "$hit"';
11560
11632
  const started = Date.now();
11561
- const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) => join47(ctx.repoDir, f))], { cwd: ctx.repoDir, timeoutMs: 30000 });
11633
+ const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) => join48(ctx.repoDir, f))], { cwd: ctx.repoDir, timeoutMs: 30000 });
11562
11634
  const durationS = (Date.now() - started) / 1000;
11563
11635
  if (r.exitCode === 3) {
11564
11636
  checks.push({ name, cmd: "secret-scan.sh", result: "not_run", duration_s: durationS });
@@ -11598,9 +11670,9 @@ async function postResults(ctx, opts, checks, notProven, statusState) {
11598
11670
  const prUrl = ctx.outputs().pr?.pr_url;
11599
11671
  const prNumber = prUrl ? PR_NUMBER_RE.exec(prUrl)?.[1] : undefined;
11600
11672
  if (prNumber) {
11601
- mkdirSync17(ctx.runDir, { recursive: true });
11602
- const bodyFile = join47(ctx.runDir, "deep-comment.md");
11603
- writeFileSync19(bodyFile, buildCommentBody(checks, notProven, statusState), "utf8");
11673
+ mkdirSync18(ctx.runDir, { recursive: true });
11674
+ const bodyFile = join48(ctx.runDir, "deep-comment.md");
11675
+ writeFileSync20(bodyFile, buildCommentBody(checks, notProven, statusState), "utf8");
11604
11676
  const commentResult = await run(["bash", scriptPath, ...commentArgv(prNumber, bodyFile)], { cwd: ctx.repoDir, env, timeoutMs: 30000 });
11605
11677
  if (commentResult.exitCode !== 0)
11606
11678
  out2.push(`deep comment not posted (engine10-push.sh exit ${commentResult.exitCode})`);
@@ -11652,8 +11724,8 @@ async function runDeep(ctx, signal, opts = {}) {
11652
11724
  const addendumSha256 = sha2562(canonicalJson(addendumBody));
11653
11725
  const sig = signReceipt(`${ctx.runId}-deep`, addendumSha256);
11654
11726
  const addendum = { ...addendumBody, addendum_sha256: addendumSha256, verification: { jwt: sig.jwt, kid: sig.kid } };
11655
- mkdirSync17(ctx.runDir, { recursive: true });
11656
- writeFileSync19(join47(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
11727
+ mkdirSync18(ctx.runDir, { recursive: true });
11728
+ writeFileSync20(join48(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
11657
11729
  `);
11658
11730
  const pushNotProven = await postResults(ctx, opts, checks, notProvenList, statusState);
11659
11731
  const allNotProven = [...notProvenList, ...pushNotProven];
@@ -11698,7 +11770,7 @@ var init_deep = __esm(() => {
11698
11770
  // ../../loki-ts/src/engine10/stages/verify.ts
11699
11771
  import { existsSync as existsSync29, mkdtempSync as mkdtempSync6, realpathSync as realpathSync17, rmSync as rmSync12 } from "fs";
11700
11772
  import { tmpdir as tmpdir8 } from "os";
11701
- import { dirname as dirname16, isAbsolute as isAbsolute6, join as join48, relative as relative5 } from "path";
11773
+ import { dirname as dirname17, isAbsolute as isAbsolute6, join as join49, relative as relative5 } from "path";
11702
11774
  function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
11703
11775
  const inRepo = (p) => {
11704
11776
  try {
@@ -11709,7 +11781,7 @@ function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
11709
11781
  }
11710
11782
  };
11711
11783
  const venvEnv = process.env["VIRTUAL_ENV"];
11712
- const project = [join48(repoDir, ".venv", "bin", bin), join48(repoDir, "venv", "bin", bin), ...venvEnv && inRepo(venvEnv) ? [join48(venvEnv, "bin", bin)] : []].find(existsSync29);
11784
+ const project = [join49(repoDir, ".venv", "bin", bin), join49(repoDir, "venv", "bin", bin), ...venvEnv && inRepo(venvEnv) ? [join49(venvEnv, "bin", bin)] : []].find(existsSync29);
11713
11785
  return project ? [project, "project"] : [Bun.which(fallback) ? fallback : lastResort, "system"];
11714
11786
  }
11715
11787
  function runnerCmd(t, repoDir) {
@@ -11729,7 +11801,7 @@ function runnerCmd(t, repoDir) {
11729
11801
  case "npm":
11730
11802
  return ["npm", ["test", "--silent"]];
11731
11803
  case "go":
11732
- return ["go", ["test", "-json", `./${dirname16(t.path)}`]];
11804
+ return ["go", ["test", "-json", `./${dirname17(t.path)}`]];
11733
11805
  case "cargo":
11734
11806
  return ["cargo", ["test"]];
11735
11807
  }
@@ -11827,7 +11899,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal)
11827
11899
  const sus = pairs.filter(({ c }) => rel.has(c.name) && c.result === "pass");
11828
11900
  if (!(un.some(({ c }) => c.result === "fail" && c.ids?.length) || sus.length) || signal.aborted)
11829
11901
  return out2;
11830
- const dir = mkdtempSync6(join48(tmpdir8(), "e10-base-"));
11902
+ const dir = mkdtempSync6(join49(tmpdir8(), "e10-base-"));
11831
11903
  const git3 = (args) => {
11832
11904
  safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
11833
11905
  };
@@ -11862,7 +11934,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal)
11862
11934
  return out2;
11863
11935
  }
11864
11936
  function isLokiModeRepo(repoDir) {
11865
- return existsSync29(join48(repoDir, "scripts", "select-tests.sh"));
11937
+ return existsSync29(join49(repoDir, "scripts", "select-tests.sh"));
11866
11938
  }
11867
11939
  async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
11868
11940
  const { api, ...runOpts } = opts;
@@ -11879,9 +11951,9 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
11879
11951
  }
11880
11952
  for (const g of groupByPackage(api, ctx.repoDir, changed.filter((f) => /\.(ts|tsx|js|jsx)$/.test(f)))) {
11881
11953
  const sfx = g.root === "." ? "" : `:${g.root}`, co = g.root === "." ? opts : { ...opts, cwd: g.cwd };
11882
- if (existsSync29(join48(g.cwd, "tsconfig.json")))
11954
+ if (existsSync29(join49(g.cwd, "tsconfig.json")))
11883
11955
  await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
11884
- if (ESLINT_CONFIGS.some((f) => existsSync29(join48(g.cwd, f))))
11956
+ if (ESLINT_CONFIGS.some((f) => existsSync29(join49(g.cwd, f))))
11885
11957
  await runCheck(ctx, `lint:eslint${sfx}`, "npx", ["eslint", ...g.rel], signal, checks, { ...co, kind: "static" });
11886
11958
  }
11887
11959
  }
@@ -12013,8 +12085,8 @@ var init_verify = __esm(() => {
12013
12085
  });
12014
12086
 
12015
12087
  // ../../loki-ts/src/project_model/conventions.ts
12016
- import { existsSync as existsSync30, readdirSync as readdirSync13, readFileSync as readFileSync34 } from "fs";
12017
- import { dirname as dirname17, join as join49 } from "path";
12088
+ import { existsSync as existsSync30, readdirSync as readdirSync13, readFileSync as readFileSync35 } from "fs";
12089
+ import { dirname as dirname18, join as join50 } from "path";
12018
12090
  function parseJsonc(text2) {
12019
12091
  let out2 = "", i = 0;
12020
12092
  while (i < text2.length) {
@@ -12049,7 +12121,7 @@ function moduleOf(file, depth = 0) {
12049
12121
  const ext = typeof j.extends === "string" ? j.extends : null;
12050
12122
  if (!ext || !ext.startsWith("."))
12051
12123
  return null;
12052
- const next = join49(dirname17(file), ext.endsWith(".json") ? ext : `${ext}.json`);
12124
+ const next = join50(dirname18(file), ext.endsWith(".json") ? ext : `${ext}.json`);
12053
12125
  return existsSync30(next) ? moduleOf(next, depth + 1) : null;
12054
12126
  }
12055
12127
  function readPackageConventions(pkgDir, runner = null) {
@@ -12061,13 +12133,13 @@ function readPackageConventions(pkgDir, runner = null) {
12061
12133
  }
12062
12134
  let packageType = null, tsModule = null;
12063
12135
  for (const n2 of names) {
12064
- const j = readJson4(join49(pkgDir, n2));
12136
+ const j = readJson4(join50(pkgDir, n2));
12065
12137
  if (!j)
12066
12138
  continue;
12067
12139
  if (packageType === null && typeof j.type === "string" && typeof j.name === "string")
12068
12140
  packageType = j.type;
12069
12141
  if (tsModule === null && j.compilerOptions !== undefined)
12070
- tsModule = moduleOf(join49(pkgDir, n2));
12142
+ tsModule = moduleOf(join50(pkgDir, n2));
12071
12143
  }
12072
12144
  if (packageType === null && tsModule === null)
12073
12145
  return null;
@@ -12089,7 +12161,7 @@ function conventionViolation(c, fileName, content) {
12089
12161
  }
12090
12162
  var readJson4 = (p) => {
12091
12163
  try {
12092
- const v = parseJsonc(readFileSync34(p, "utf8"));
12164
+ const v = parseJsonc(readFileSync35(p, "utf8"));
12093
12165
  return v && typeof v === "object" && !Array.isArray(v) ? v : null;
12094
12166
  } catch {
12095
12167
  return null;
@@ -12099,15 +12171,15 @@ var init_conventions = () => {};
12099
12171
 
12100
12172
  // ../../loki-ts/src/engine10/stages/wall.ts
12101
12173
  import { spawnSync as spawnSync4 } from "child_process";
12102
- import { existsSync as existsSync31, mkdirSync as mkdirSync18, mkdtempSync as mkdtempSync7, readFileSync as readFileSync35, readdirSync as readdirSync14, realpathSync as realpathSync18, rmSync as rmSync13, writeFileSync as writeFileSync20 } from "fs";
12174
+ import { existsSync as existsSync31, mkdirSync as mkdirSync19, mkdtempSync as mkdtempSync7, readFileSync as readFileSync36, readdirSync as readdirSync14, realpathSync as realpathSync18, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "fs";
12103
12175
  import { tmpdir as tmpdir9 } from "os";
12104
- import { dirname as dirname18, isAbsolute as isAbsolute7, join as join50, relative as relative6 } from "path";
12176
+ import { dirname as dirname19, isAbsolute as isAbsolute7, join as join51, relative as relative6 } from "path";
12105
12177
  function pytestCollectionIsRed(output, repoDir) {
12106
12178
  if (/ModuleNotFoundError/.test(output))
12107
12179
  return false;
12108
12180
  const real2 = (p) => {
12109
12181
  try {
12110
- return realpathSync18(isAbsolute7(p) ? p : join50(repoDir, p));
12182
+ return realpathSync18(isAbsolute7(p) ? p : join51(repoDir, p));
12111
12183
  } catch {
12112
12184
  return null;
12113
12185
  }
@@ -12144,7 +12216,7 @@ function pytestCollectionIsRed(output, repoDir) {
12144
12216
  }
12145
12217
  function moduleUnderRepo(repoDir, name) {
12146
12218
  const rel = name.replace(/\./g, "/");
12147
- return existsSync31(join50(repoDir, `${rel}.py`)) || existsSync31(join50(repoDir, rel, "__init__.py"));
12219
+ return existsSync31(join51(repoDir, `${rel}.py`)) || existsSync31(join51(repoDir, rel, "__init__.py"));
12148
12220
  }
12149
12221
  function pytestExit1IsRed(output) {
12150
12222
  if (/^!+ _pytest\.outcomes\.Exit\b/m.test(output))
@@ -12242,10 +12314,10 @@ ${acceptance.map((a) => `Acceptance: ${a}`).join(`
12242
12314
  function loadTaskText(ctx, fromPrior) {
12243
12315
  if (fromPrior)
12244
12316
  return fromPrior;
12245
- const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join50(ctx.runDir, "issue.json");
12317
+ const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join51(ctx.runDir, "issue.json");
12246
12318
  if (existsSync31(issueJsonPath)) {
12247
12319
  try {
12248
- const issue = JSON.parse(readFileSync35(issueJsonPath, "utf8"));
12320
+ const issue = JSON.parse(readFileSync36(issueJsonPath, "utf8"));
12249
12321
  const text2 = [issue.title, issue.body].filter((s) => typeof s === "string" && s.length > 0).join(`
12250
12322
 
12251
12323
  `);
@@ -12257,7 +12329,7 @@ function loadTaskText(ctx, fromPrior) {
12257
12329
  }
12258
12330
  function wallTargetDir(repoDir, existingTests) {
12259
12331
  const first = existingTests[0];
12260
- return first ? join50(repoDir, dirname18(first.path)) : join50(repoDir, "tests");
12332
+ return first ? join51(repoDir, dirname19(first.path)) : join51(repoDir, "tests");
12261
12333
  }
12262
12334
  function guessRunner(fileName, runners) {
12263
12335
  if (fileName.endsWith(".py"))
@@ -12288,11 +12360,11 @@ async function wallAuthor(ctx, signal) {
12288
12360
  const tree = prior.intake?.tree;
12289
12361
  const repomapText = repoMapText(ctx.repoDir, tree, repomapRef, WALL_MAP_MAX_LINES);
12290
12362
  const targetDir = wallTargetDir(ctx.repoDir, existingTests), pkg = loadProjectApi(ctx.repoDir)?.packageOf(`${relative6(ctx.repoDir, targetDir)}/x`);
12291
- const conv2 = readPackageConventions(join50(ctx.repoDir, pkg?.root ?? "."), pkg?.runner ?? null);
12292
- const cwd = mkdtempSync7(join50(tmpdir9(), "loki-e15-wall-"));
12363
+ const conv2 = readPackageConventions(join51(ctx.repoDir, pkg?.root ?? "."), pkg?.runner ?? null);
12364
+ const cwd = mkdtempSync7(join51(tmpdir9(), "loki-e15-wall-"));
12293
12365
  const wm = wallManifestFor(ctx.repoDir, tree, task);
12294
12366
  for (const [n2, c] of [["task.md", task], ["repomap.txt", repomapText], ...wm ? [["wall_manifest.txt", wm.text]] : []])
12295
- writeFileSync20(join50(cwd, n2), c, "utf8");
12367
+ writeFileSync21(join51(cwd, n2), c, "utf8");
12296
12368
  const session = await ctx.sessions.run({
12297
12369
  stage: "wall",
12298
12370
  brief: buildWallBrief(task, repomapText, runners, !!wm, conventionsBrief(conv2), unitSpec()?.acceptance ?? []),
@@ -12308,14 +12380,14 @@ async function wallAuthor(ctx, signal) {
12308
12380
  return done({ status: "failed", data: {}, reason: "wall session aborted, killed, or timed out", killed: true });
12309
12381
  }
12310
12382
  const generated = readdirSync14(cwd).filter((f) => f.startsWith(WALL_PREFIX));
12311
- const sealedDir = join50(ctx.runDir, "wall");
12383
+ const sealedDir = join51(ctx.runDir, "wall");
12312
12384
  if (generated.length > 0)
12313
- mkdirSync18(sealedDir, { recursive: true });
12385
+ mkdirSync19(sealedDir, { recursive: true });
12314
12386
  const contents = new Map;
12315
12387
  const discarded = [];
12316
12388
  for (const name of generated) {
12317
- const content = readFileSync35(join50(cwd, name), "utf8"), bad = conventionViolation(conv2, name, content);
12318
- writeFileSync20(join50(sealedDir, name), content, "utf8");
12389
+ const content = readFileSync36(join51(cwd, name), "utf8"), bad = conventionViolation(conv2, name, content);
12390
+ writeFileSync21(join51(sealedDir, name), content, "utf8");
12319
12391
  if (bad)
12320
12392
  discarded.push({ file: name, reason: `${bad}; wall test did not compile under the package config` });
12321
12393
  else
@@ -12327,7 +12399,7 @@ async function wallAuthor(ctx, signal) {
12327
12399
  function installWall(ctx, a, baseDir, opts = {}) {
12328
12400
  const { generated, contents, discarded, targetDir, runners } = a;
12329
12401
  if (generated.length > 0)
12330
- mkdirSync18(targetDir, { recursive: true });
12402
+ mkdirSync19(targetDir, { recursive: true });
12331
12403
  const sealedFiles = [];
12332
12404
  const readOnlyFiles = [];
12333
12405
  const wallTests = [];
@@ -12335,8 +12407,8 @@ function installWall(ctx, a, baseDir, opts = {}) {
12335
12407
  const content = contents.get(name);
12336
12408
  if (content === undefined)
12337
12409
  continue;
12338
- const dest = join50(targetDir, name), runner = guessRunner(name, runners);
12339
- writeFileSync20(dest, content, "utf8");
12410
+ const dest = join51(targetDir, name), runner = guessRunner(name, runners);
12411
+ writeFileSync21(dest, content, "utf8");
12340
12412
  sealedFiles.push({ path: dest, sha256: sha2562(content) });
12341
12413
  readOnlyFiles.push({ path: dest, content });
12342
12414
  if (runner)
@@ -12345,7 +12417,7 @@ function installWall(ctx, a, baseDir, opts = {}) {
12345
12417
  ctx.emit("wall.sealed", "wall", { files: sealedFiles, ...a.manifestSha256 ? { manifest_sha256: a.manifestSha256 } : {} });
12346
12418
  const baseRunner = opts.baseRunner ?? new RealBaseTestRunner, baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
12347
12419
  for (const t of wallTests) {
12348
- const r = baseRunner.run(baseDir, [t]), abs = join50(ctx.repoDir, t.path);
12420
+ const r = baseRunner.run(baseDir, [t]), abs = join51(ctx.repoDir, t.path);
12349
12421
  baseRun.pass += r.pass;
12350
12422
  baseRun.fail += r.fail;
12351
12423
  baseRun.not_run += r.not_run ?? 0;
@@ -12397,20 +12469,20 @@ var init_wall = __esm(() => {
12397
12469
  });
12398
12470
 
12399
12471
  // ../../loki-ts/src/e10ext/discard.ts
12400
- import { chmodSync as chmodSync4, closeSync as closeSync8, lstatSync as lstatSync10, mkdirSync as mkdirSync19, openSync as openSync8, readFileSync as readFileSync36, realpathSync as realpathSync19, rmdirSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync21 } from "fs";
12401
- import { dirname as dirname19, join as join51, relative as relative7, sep as sep11 } from "path";
12472
+ import { chmodSync as chmodSync5, closeSync as closeSync8, lstatSync as lstatSync10, mkdirSync as mkdirSync20, openSync as openSync8, readFileSync as readFileSync37, realpathSync as realpathSync19, rmdirSync, unlinkSync as unlinkSync5, writeFileSync as writeFileSync22 } from "fs";
12473
+ import { dirname as dirname20, join as join52, relative as relative7, sep as sep11 } from "path";
12402
12474
  function safeRestore(repoDir, f, want, mode) {
12403
- const root = realpathSync19(repoDir), fp = join51(root, f), rel = relative7(root, dirname19(fp));
12475
+ const root = realpathSync19(repoDir), fp = join52(root, f), rel = relative7(root, dirname20(fp));
12404
12476
  if (rel.startsWith(".."))
12405
12477
  throw new Error("outside repo");
12406
12478
  let cur = root;
12407
12479
  for (const part of rel === "" ? [] : rel.split(sep11)) {
12408
- cur = join51(cur, part);
12480
+ cur = join52(cur, part);
12409
12481
  let st2;
12410
12482
  try {
12411
12483
  st2 = lstatSync10(cur);
12412
12484
  } catch {
12413
- mkdirSync19(cur);
12485
+ mkdirSync20(cur);
12414
12486
  continue;
12415
12487
  }
12416
12488
  if (!st2.isDirectory())
@@ -12422,23 +12494,23 @@ function safeRestore(repoDir, f, want, mode) {
12422
12494
  } catch {
12423
12495
  st = null;
12424
12496
  }
12425
- if (st?.isFile() && readFileSync36(fp).equals(want)) {
12426
- chmodSync4(fp, mode);
12497
+ if (st?.isFile() && readFileSync37(fp).equals(want)) {
12498
+ chmodSync5(fp, mode);
12427
12499
  return;
12428
12500
  }
12429
12501
  if (st) {
12430
12502
  if (st.isDirectory())
12431
12503
  rmdirSync(fp);
12432
12504
  else
12433
- unlinkSync4(fp);
12505
+ unlinkSync5(fp);
12434
12506
  }
12435
12507
  const fd = openSync8(fp, "wx", mode);
12436
12508
  try {
12437
- writeFileSync21(fd, want);
12509
+ writeFileSync22(fd, want);
12438
12510
  } finally {
12439
12511
  closeSync8(fd);
12440
12512
  }
12441
- chmodSync4(fp, mode);
12513
+ chmodSync5(fp, mode);
12442
12514
  }
12443
12515
  function alreadySatisfied(o) {
12444
12516
  const b = o.wall?.base_run ?? {};
@@ -12460,7 +12532,7 @@ async function discardIfSatisfied(git3, base, o, staged, keep, repoDir) {
12460
12532
  return { status: "failed", data: {}, reason: "already-satisfied discard failed" };
12461
12533
  const notProven = [];
12462
12534
  for (const [f, v] of Object.entries(o.intake?.preexisting_untracked_blobs ?? {})) {
12463
- const fp = join51(repoDir, f);
12535
+ const fp = join52(repoDir, f);
12464
12536
  try {
12465
12537
  if (v.startsWith("!")) {
12466
12538
  const st = lstatSync10(fp);
@@ -12479,7 +12551,7 @@ async function discardIfSatisfied(git3, base, o, staged, keep, repoDir) {
12479
12551
  try {
12480
12552
  let m = 420;
12481
12553
  try {
12482
- const l = lstatSync10(join51(repoDir, f));
12554
+ const l = lstatSync10(join52(repoDir, f));
12483
12555
  if (l.isFile())
12484
12556
  m = l.mode & 511;
12485
12557
  } catch {}
@@ -12512,9 +12584,9 @@ var init_preexisting_dirty = __esm(() => {
12512
12584
  });
12513
12585
 
12514
12586
  // ../../loki-ts/src/e10ext/commit_filter.ts
12515
- import { dirname as dirname20 } from "path";
12587
+ import { dirname as dirname21 } from "path";
12516
12588
  function dropSet(repoDir, staged, preexistingDirty, env = process.env) {
12517
- return staged.concat(untouchedSinceIntake(repoDir, preexistingDirty, env).map((f) => ({ st: "L", f }))).filter(({ st, f }) => f.startsWith(".loki/") || st === "L" || /(^|\/)loki_wall_[^/]*$/.test(f) || st === "A" && !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));
12589
+ return staged.concat(untouchedSinceIntake(repoDir, preexistingDirty, env).map((f) => ({ st: "L", f }))).filter(({ st, f }) => f.startsWith(".loki/") || st === "L" || /(^|\/)loki_wall_[^/]*$/.test(f) || st === "A" && !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));
12518
12590
  }
12519
12591
  var parseStaged = (out2) => out2.split("\x00").reduce((a, t, i, all) => i % 2 === 0 && t ? [...a, { st: t, f: all[i + 1] }] : a, []);
12520
12592
  var init_commit_filter = __esm(() => {
@@ -12523,7 +12595,7 @@ var init_commit_filter = __esm(() => {
12523
12595
  });
12524
12596
 
12525
12597
  // ../../loki-ts/src/e10ext/scope.ts
12526
- import { basename as basename18, dirname as dirname21 } from "path";
12598
+ import { basename as basename18, dirname as dirname22 } from "path";
12527
12599
  function contractText(o) {
12528
12600
  const c = o.intake?.contract_snapshot?.contract;
12529
12601
  return Array.isArray(c?.criteria) ? c.criteria.map((x) => typeof x?.text === "string" ? x.text : "").join(`
@@ -12537,8 +12609,8 @@ function outsideScope(o, staged) {
12537
12609
  const text2 = `${plan}
12538
12610
  ${typeof o.intake?.task === "string" ? o.intake.task : ""}
12539
12611
  ${contractText(o)}`, pre = o.intake?.preexisting_dirty ?? {};
12540
- const toks = surfaceTokens(text2), plannedDirs = new Set(rel.map((r) => dirname21(r)).filter((d) => d !== "."));
12541
- return staged.filter(({ st, f }) => st !== "A" && !isTestFile(f) && !Object.hasOwn(pre, f) && !rel.includes(f) && !mentions(text2, f) && !mentions(text2, basename18(f)) && !plannedDirs.has(dirname21(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
12612
+ const toks = surfaceTokens(text2), plannedDirs = new Set(rel.map((r) => dirname22(r)).filter((d) => d !== "."));
12613
+ return staged.filter(({ st, f }) => st !== "A" && !isTestFile(f) && !Object.hasOwn(pre, f) && !rel.includes(f) && !mentions(text2, f) && !mentions(text2, basename18(f)) && !plannedDirs.has(dirname22(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
12542
12614
  }
12543
12615
  function flagOutsideScope(o, staged) {
12544
12616
  const unit = unitFlags(staged, process.env, o.intake?.preexisting_dirty ?? {});
@@ -12552,72 +12624,6 @@ var init_scope2 = __esm(() => {
12552
12624
  STOP = new Set(["the", "and", "for", "with", "that", "this", "all", "any", "src", "from", "into", "each", "across", "apply", "add", "use", "make"]);
12553
12625
  });
12554
12626
 
12555
- // ../../loki-ts/src/util/receipt_signer.ts
12556
- import { createHash as createHash11, randomBytes as randomBytes3, createPrivateKey, createPublicKey as createPublicKey2, generateKeyPairSync, sign } from "crypto";
12557
- import { chmodSync as chmodSync5, linkSync, mkdirSync as mkdirSync20, readFileSync as readFileSync37, statSync as statSync16, unlinkSync as unlinkSync5, writeFileSync as writeFileSync22 } from "fs";
12558
- import { homedir as homedir8 } from "os";
12559
- import { dirname as dirname22, join as join52 } from "path";
12560
- function canonicalJson(x) {
12561
- const walk = (v) => {
12562
- if (Array.isArray(v))
12563
- return `[${v.map(walk).join(",")}]`;
12564
- if (v !== null && typeof v === "object") {
12565
- const o = v;
12566
- return `{${Object.keys(o).filter((k) => o[k] !== undefined).sort().map((k) => `${JSON.stringify(k)}:${walk(o[k])}`).join(",")}}`;
12567
- }
12568
- return JSON.stringify(v ?? null);
12569
- };
12570
- return walk(x).replace(/[\u0080-\uFFFF]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
12571
- }
12572
- function loadSigningKey(generate = true) {
12573
- try {
12574
- const inline = process.env["LOKI_RECEIPT_SIGNING_KEY"]?.trim();
12575
- let pem = inline ?? "";
12576
- if (!inline) {
12577
- const given = process.env["LOKI_RECEIPT_SIGNING_KEY_FILE"]?.trim();
12578
- const file = given || join52(process.env["HOME"] || homedir8(), ".loki", "keys", RECEIPT_SIGNER_BASENAME);
12579
- try {
12580
- pem = readFileSync37(file);
12581
- if (!given) {
12582
- for (const [f, m] of [[file, 384], [dirname22(file), 448]])
12583
- if (statSync16(f).mode & 63)
12584
- chmodSync5(f, m);
12585
- }
12586
- } catch (e) {
12587
- if (e.code !== "ENOENT" || !generate)
12588
- return null;
12589
- mkdirSync20(dirname22(dirname22(file)), { recursive: true, mode: 448 });
12590
- mkdirSync20(dirname22(file), { recursive: true, mode: 448 });
12591
- const tmp = `${file}.${randomBytes3(6).toString("hex")}.tmp`;
12592
- writeFileSync22(tmp, generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" }), { flag: "wx", mode: 384 });
12593
- try {
12594
- linkSync(tmp, file);
12595
- } catch (l) {
12596
- if (l.code !== "EEXIST")
12597
- throw l;
12598
- } finally {
12599
- unlinkSync5(tmp);
12600
- }
12601
- pem = readFileSync37(file);
12602
- }
12603
- }
12604
- const k = createPrivateKey(pem);
12605
- return k.asymmetricKeyType === "ed25519" ? k : null;
12606
- } catch {
12607
- return null;
12608
- }
12609
- }
12610
- function signReceipt(runId, hash) {
12611
- const key = loadSigningKey();
12612
- if (!key)
12613
- return { jwt: null, kid: null };
12614
- const kid = kidOf2(createPublicKey2(key));
12615
- const input = `${b64u(canonicalJson({ alg: "EdDSA", typ: "JWT", kid }))}.${b64u(canonicalJson({ job_id: runId, run_id: runId, receipt_sha256: hash, iat: Math.floor(Date.now() / 1000) }))}`;
12616
- return { jwt: `${input}.${b64u(sign(null, Buffer.from(input), key))}`, kid };
12617
- }
12618
- var RECEIPT_SIGNER_BASENAME = "receipt-ed25519.pem", b64u = (b) => Buffer.from(b).toString("base64url"), kidOf2 = (pub) => b64u(createHash11("sha256").update(`{"crv":"Ed25519","kty":"OKP","x":"${pub.export({ format: "jwk" }).x}"}`).digest());
12619
- var init_receipt_signer = () => {};
12620
-
12621
12627
  // ../../loki-ts/src/features/visual_evidence.ts
12622
12628
  import { spawn as spawn7 } from "child_process";
12623
12629
  import { createHash as createHash12, randomBytes as randomBytes4 } from "crypto";
@@ -13343,7 +13349,7 @@ var init_contract = __esm(() => {
13343
13349
 
13344
13350
  // ../../loki-ts/src/features/speed/seal_group.ts
13345
13351
  import { createHash as createHash14 } from "crypto";
13346
- import { existsSync as existsSync36, readdirSync as readdirSync17, readFileSync as readFileSync42, statSync as statSync17 } from "fs";
13352
+ import { existsSync as existsSync36, mkdirSync as mkdirSync23, readdirSync as readdirSync17, readFileSync as readFileSync42, renameSync as renameSync8, statSync as statSync17, writeFileSync as writeFileSync25 } from "fs";
13347
13353
  import { basename as basename19, dirname as dirname25, join as join57 } from "path";
13348
13354
  function sealGroup(runDir, rh) {
13349
13355
  const manifestPath = join57(runDir, "group", "manifest.json");
@@ -13800,7 +13806,7 @@ var init_supply_guard = __esm(() => {
13800
13806
 
13801
13807
  // ../../loki-ts/src/engine10/stages/seal.ts
13802
13808
  import { createHash as createHash15 } from "crypto";
13803
- import { existsSync as existsSync38, readdirSync as readdirSync18, mkdirSync as mkdirSync23, readFileSync as readFileSync44, writeFileSync as writeFileSync25 } from "fs";
13809
+ import { existsSync as existsSync38, readdirSync as readdirSync18, mkdirSync as mkdirSync24, readFileSync as readFileSync44, writeFileSync as writeFileSync26 } from "fs";
13804
13810
  import { basename as basename21, isAbsolute as isAbsolute9, join as join59, relative as relative9 } from "path";
13805
13811
  function sanitizeReason(s) {
13806
13812
  const collapsed = s.replace(/[\x00-\x1f\x7f]+/g, " ").trim();
@@ -14114,11 +14120,11 @@ var init_seal = __esm(() => {
14114
14120
  hash = receiptSha256(body);
14115
14121
  }
14116
14122
  const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
14117
- mkdirSync23(ctx.runDir, { recursive: true });
14123
+ mkdirSync24(ctx.runDir, { recursive: true });
14118
14124
  const path = join59(ctx.runDir, "receipt.json");
14119
- writeFileSync25(path, JSON.stringify(receipt, null, 2) + `
14125
+ writeFileSync26(path, JSON.stringify(receipt, null, 2) + `
14120
14126
  `);
14121
- writeFileSync25(join59(ctx.runDir, "receipt.md"), renderReceiptMd(receipt));
14127
+ writeFileSync26(join59(ctx.runDir, "receipt.md"), renderReceiptMd(receipt));
14122
14128
  recordRun(process.env, ctx.repoDir, ctx.model, verdict, cost.usd, cost.unmetered === true, totalS);
14123
14129
  const signed = sig.jwt !== null;
14124
14130
  const data = { receipt_path: path, receipt_sha256: hash, signed, kid: sig.kid, verdict, not_proven: receipt.not_proven, ...mp ? { mutation_line: mp.line } : {}, ...routeBlock ? { route_line: routePrLine(routeBlock) } : {} };
@@ -14229,7 +14235,7 @@ var init_keys_cmd = __esm(() => {
14229
14235
  });
14230
14236
 
14231
14237
  // ../../loki-ts/src/engine10/verify_cmd.ts
14232
- import { existsSync as existsSync39, readFileSync as readFileSync46, renameSync as renameSync8, statSync as statSync20, writeFileSync as writeFileSync26 } from "fs";
14238
+ import { existsSync as existsSync39, readFileSync as readFileSync46, renameSync as renameSync9, statSync as statSync20, writeFileSync as writeFileSync27 } from "fs";
14233
14239
  import { basename as basename22, dirname as dirname27, join as join60 } from "path";
14234
14240
  import { createHash as createHash16, createPublicKey as createPublicKey4, verify as verify3 } from "crypto";
14235
14241
  function pubFor(kid, given) {
@@ -14321,9 +14327,8 @@ async function verifyReceipt(receiptPath, deps = {}) {
14321
14327
  return verifyCompositeFile(receiptPath, receipt, deps);
14322
14328
  const recorded = receipt["receipt_sha256"];
14323
14329
  const computed = computeReceiptHash(receipt);
14324
- if (typeof recorded !== "string" || recorded !== computed) {
14330
+ if (typeof recorded !== "string" || recorded !== computed)
14325
14331
  return { verdict: "TAMPERED", reasons: [`receipt_sha256 mismatch: recorded ${JSON.stringify(recorded)}, computed ${computed}`] };
14326
- }
14327
14332
  const logProblem = checkEventLog(receiptPath, receipt);
14328
14333
  if (logProblem)
14329
14334
  return { verdict: "TAMPERED", reasons: [logProblem] };
@@ -14383,6 +14388,7 @@ async function verifyCompositeFile(receiptPath, receipt, deps) {
14383
14388
  var computeReceiptHash = (receipt) => receiptSha256(receipt);
14384
14389
  var init_verify_cmd = __esm(() => {
14385
14390
  init_paths();
14391
+ init_receipt_signer();
14386
14392
  init_run_status();
14387
14393
  init_events();
14388
14394
  init_seal();