@inerrata-corporation/errata 2.0.22-dev.4277 → 2.0.22-dev.4293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/errata.mjs CHANGED
@@ -29565,6 +29565,78 @@ var init_src7 = __esm({
29565
29565
  }
29566
29566
  });
29567
29567
 
29568
+ // src/owner-only-file.ts
29569
+ import { chmodSync, statSync } from "node:fs";
29570
+ import { execFileSync } from "node:child_process";
29571
+ import { join as join5 } from "node:path";
29572
+ function system32(exe) {
29573
+ return join5(process.env["SystemRoot"] ?? "C:\\Windows", "System32", exe);
29574
+ }
29575
+ function parseWhoamiSid(output) {
29576
+ const match2 = /"(S-1-\d+(?:-\d+)+)"/.exec(output);
29577
+ return match2 ? match2[1] : null;
29578
+ }
29579
+ function windowsAccount() {
29580
+ if (cachedSid !== void 0) return cachedSid;
29581
+ try {
29582
+ const out2 = execFileSync(system32("whoami.exe"), ["/user", "/fo", "csv", "/nh"], {
29583
+ encoding: "utf8",
29584
+ stdio: ["ignore", "pipe", "ignore"],
29585
+ windowsHide: true,
29586
+ timeout: 5e3
29587
+ });
29588
+ const sid = parseWhoamiSid(out2);
29589
+ cachedSid = sid ? `*${sid}` : null;
29590
+ } catch {
29591
+ cachedSid = null;
29592
+ }
29593
+ return cachedSid;
29594
+ }
29595
+ function runIcacls(args2) {
29596
+ execFileSync(system32("icacls.exe"), args2, { stdio: "ignore", windowsHide: true, timeout: 5e3 });
29597
+ }
29598
+ function statIdentity(path3) {
29599
+ try {
29600
+ const stat4 = statSync(path3, { bigint: true });
29601
+ return `${stat4.dev}:${stat4.ino}:${stat4.birthtimeNs}`;
29602
+ } catch {
29603
+ return null;
29604
+ }
29605
+ }
29606
+ function restrictToOwner(path3, deps = defaultDeps) {
29607
+ try {
29608
+ if (deps.platform !== "win32") {
29609
+ deps.chmod(path3, 384);
29610
+ return "chmod";
29611
+ }
29612
+ const identity = deps.fileIdentity(path3);
29613
+ if (identity !== null && restrictedThisProcess.get(path3) === identity) return "acl-cached";
29614
+ const account = deps.account();
29615
+ if (!account) return "skipped";
29616
+ deps.icacls([path3, "/grant:r", `${account}:F`, `${LOCAL_SYSTEM_SID}:F`]);
29617
+ deps.icacls([path3, "/inheritance:r"]);
29618
+ if (identity !== null) restrictedThisProcess.set(path3, identity);
29619
+ return "acl";
29620
+ } catch {
29621
+ return "failed";
29622
+ }
29623
+ }
29624
+ var LOCAL_SYSTEM_SID, cachedSid, defaultDeps, restrictedThisProcess;
29625
+ var init_owner_only_file = __esm({
29626
+ "src/owner-only-file.ts"() {
29627
+ "use strict";
29628
+ LOCAL_SYSTEM_SID = "*S-1-5-18";
29629
+ defaultDeps = {
29630
+ platform: process.platform,
29631
+ chmod: chmodSync,
29632
+ icacls: runIcacls,
29633
+ account: windowsAccount,
29634
+ fileIdentity: statIdentity
29635
+ };
29636
+ restrictedThisProcess = /* @__PURE__ */ new Map();
29637
+ }
29638
+ });
29639
+
29568
29640
  // ../../node_modules/.pnpm/env-paths@3.0.0/node_modules/env-paths/index.js
29569
29641
  import path2 from "node:path";
29570
29642
  import os from "node:os";
@@ -29640,26 +29712,26 @@ __export(paths_exports, {
29640
29712
  workspacePaths: () => workspacePaths
29641
29713
  });
29642
29714
  import { mkdirSync as mkdirSync5 } from "node:fs";
29643
- import { dirname as dirname5, join as join5 } from "node:path";
29715
+ import { dirname as dirname5, join as join6 } from "node:path";
29644
29716
  function globalDir() {
29645
29717
  const p = envPaths("errata", { suffix: "" });
29646
29718
  return p.config;
29647
29719
  }
29648
29720
  function globalConfigPath() {
29649
- return process.env["ERRATA_CONFIG_PATH"] ?? join5(globalDir(), "config.json");
29721
+ return process.env["ERRATA_CONFIG_PATH"] ?? join6(globalDir(), "config.json");
29650
29722
  }
29651
29723
  function daemonLogPath() {
29652
29724
  mkdirSync5(globalDir(), { recursive: true });
29653
- return join5(globalDir(), "daemon.log");
29725
+ return join6(globalDir(), "daemon.log");
29654
29726
  }
29655
29727
  function globalDaemonLock() {
29656
- return process.env["ERRATA_DAEMON_LOCK"] ?? join5(globalDir(), "daemon.lock");
29728
+ return process.env["ERRATA_DAEMON_LOCK"] ?? join6(globalDir(), "daemon.lock");
29657
29729
  }
29658
29730
  function sharedStorePath() {
29659
- return process.env["ERRATA_SHARED_DB"] ?? join5(globalDir(), "shared", "graph.db");
29731
+ return process.env["ERRATA_SHARED_DB"] ?? join6(globalDir(), "shared", "graph.db");
29660
29732
  }
29661
29733
  function workspaceDir(workspaceRoot) {
29662
- return join5(workspaceRoot, ".errata");
29734
+ return join6(workspaceRoot, ".errata");
29663
29735
  }
29664
29736
  function ensureDir(p) {
29665
29737
  mkdirSync5(p, { recursive: true });
@@ -29674,15 +29746,15 @@ function workspacePaths(root) {
29674
29746
  return {
29675
29747
  root,
29676
29748
  configDir: dir,
29677
- workspaceJson: join5(dir, "workspace.json"),
29678
- eventLog: join5(dir, "eventlog.sqlite"),
29679
- castalia: join5(dir, "castalia.db"),
29680
- reviewQueue: join5(dir, "review-queue.json"),
29681
- outbox: join5(dir, "outbox"),
29682
- daemonLock: join5(dir, "daemon.lock"),
29683
- identityAudit: join5(dir, "identity-audit.log"),
29684
- skillsDir: join5(dir, "skills"),
29685
- skillsManifest: join5(dir, "skills.json")
29749
+ workspaceJson: join6(dir, "workspace.json"),
29750
+ eventLog: join6(dir, "eventlog.sqlite"),
29751
+ castalia: join6(dir, "castalia.db"),
29752
+ reviewQueue: join6(dir, "review-queue.json"),
29753
+ outbox: join6(dir, "outbox"),
29754
+ daemonLock: join6(dir, "daemon.lock"),
29755
+ identityAudit: join6(dir, "identity-audit.log"),
29756
+ skillsDir: join6(dir, "skills"),
29757
+ skillsManifest: join6(dir, "skills.json")
29686
29758
  };
29687
29759
  }
29688
29760
  var init_paths = __esm({
@@ -29754,7 +29826,9 @@ function loadConfig() {
29754
29826
  function saveConfig(cfg) {
29755
29827
  ensureDir(globalDir());
29756
29828
  const normalized = snapshotActiveInstallationProfile(cfg);
29757
- writeFileSync5(globalConfigPath(), JSON.stringify(normalized, null, 2), { encoding: "utf8", mode: 384 });
29829
+ const path3 = globalConfigPath();
29830
+ writeFileSync5(path3, JSON.stringify(normalized, null, 2), { encoding: "utf8", mode: 384 });
29831
+ restrictToOwner(path3);
29758
29832
  }
29759
29833
  function profileFromCurrent(cfg, installationId) {
29760
29834
  return {
@@ -29855,6 +29929,7 @@ var LEGACY_CLOUD_URL, DEFAULT_CLOUD_URL, DEFAULT_UPDATE_CHANNEL;
29855
29929
  var init_config = __esm({
29856
29930
  "src/config.ts"() {
29857
29931
  "use strict";
29932
+ init_owner_only_file();
29858
29933
  init_paths();
29859
29934
  LEGACY_CLOUD_URL = "https://inerrata-gateway.onrender.com";
29860
29935
  DEFAULT_CLOUD_URL = true ? "https://dev.inerrata.dev" : DEV_CLOUD_URL;
@@ -32465,7 +32540,7 @@ var init_dist = __esm({
32465
32540
  });
32466
32541
 
32467
32542
  // src/context-baselines.ts
32468
- import { closeSync, openSync, readSync, statSync } from "node:fs";
32543
+ import { closeSync, openSync, readSync, statSync as statSync2 } from "node:fs";
32469
32544
  function deliveryMarker(hash2) {
32470
32545
  return `<!-- errata-context ${hash2.slice(0, 16)} -->`;
32471
32546
  }
@@ -32477,7 +32552,7 @@ function appendedSince(path3, offset, needle) {
32477
32552
  return { found: false, turnRan: false };
32478
32553
  }
32479
32554
  try {
32480
- const size = statSync(path3).size;
32555
+ const size = statSync2(path3).size;
32481
32556
  const keep = Math.max(needle.length, MODEL_TURN.length);
32482
32557
  const buf = Buffer.alloc(CHUNK);
32483
32558
  let carry = "";
@@ -32496,7 +32571,7 @@ function appendedSince(path3, offset, needle) {
32496
32571
  }
32497
32572
  function sizeOf(path3) {
32498
32573
  try {
32499
- return statSync(path3).size;
32574
+ return statSync2(path3).size;
32500
32575
  } catch {
32501
32576
  return 0;
32502
32577
  }
@@ -32720,7 +32795,7 @@ var init_diagnostic_matcher = __esm({
32720
32795
  });
32721
32796
 
32722
32797
  // ../../packages/generalizer/src/generalizer.ts
32723
- import { isAbsolute, join as join6, relative } from "node:path";
32798
+ import { isAbsolute, join as join7, relative } from "node:path";
32724
32799
  async function runGeneralizer(opts) {
32725
32800
  const report = {
32726
32801
  eventsProcessed: 0,
@@ -32828,7 +32903,7 @@ function extractDiagnostics(ev) {
32828
32903
  function diagRelPath(file2, cwd, workspaceRoot) {
32829
32904
  const norm = (p) => p.replace(/\\/g, "/");
32830
32905
  if (!workspaceRoot) return norm(file2);
32831
- const abs = isAbsolute(file2) ? file2 : join6(cwd ?? workspaceRoot, file2);
32906
+ const abs = isAbsolute(file2) ? file2 : join7(cwd ?? workspaceRoot, file2);
32832
32907
  return norm(relative(workspaceRoot, abs));
32833
32908
  }
32834
32909
  function extractErrorSignature(ev) {
@@ -35117,7 +35192,7 @@ var init_recall_card = __esm({
35117
35192
 
35118
35193
  // src/recall-signal.ts
35119
35194
  import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync6 } from "node:fs";
35120
- import { join as join7 } from "node:path";
35195
+ import { join as join8 } from "node:path";
35121
35196
  function live(n) {
35122
35197
  return n != null && n.validTo == null && historyReadPolicy(n, { mode: "passive" }).allow;
35123
35198
  }
@@ -35186,14 +35261,14 @@ function contextCard(store, snapshot) {
35186
35261
  return deliveredCard(store, intent ? `${count} for \u201C${clipIntent(intent)}\u201D` : `${count} in context`, delivered);
35187
35262
  }
35188
35263
  function writeContextCard(root, hash2, card) {
35189
- writeFileSync6(join7(root, ".errata", CONTEXT_CARD_FILE), JSON.stringify({
35264
+ writeFileSync6(join8(root, ".errata", CONTEXT_CARD_FILE), JSON.stringify({
35190
35265
  hash: hash2,
35191
35266
  card,
35192
35267
  line: card && recallCardEnabled() ? renderRecallLine(card) : null
35193
35268
  }));
35194
35269
  }
35195
35270
  function readContextCard(root, hash2) {
35196
- const path3 = join7(root, ".errata", CONTEXT_CARD_FILE);
35271
+ const path3 = join8(root, ".errata", CONTEXT_CARD_FILE);
35197
35272
  if (!existsSync7(path3)) return null;
35198
35273
  try {
35199
35274
  const saved = JSON.parse(readFileSync5(path3, "utf8"));
@@ -35474,12 +35549,12 @@ var init_consent = __esm({
35474
35549
 
35475
35550
  // src/git-remote.ts
35476
35551
  import { spawnSync } from "node:child_process";
35477
- import { existsSync as existsSync10, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
35478
- import { isAbsolute as isAbsolute2, join as join8, resolve as resolve2 } from "node:path";
35552
+ import { existsSync as existsSync10, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
35553
+ import { isAbsolute as isAbsolute2, join as join9, resolve as resolve2 } from "node:path";
35479
35554
  function resolveGitDir(root) {
35480
- const dotGit = join8(root, ".git");
35555
+ const dotGit = join9(root, ".git");
35481
35556
  try {
35482
- const st = statSync2(dotGit);
35557
+ const st = statSync3(dotGit);
35483
35558
  if (st.isDirectory()) return dotGit;
35484
35559
  const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync8(dotGit, "utf8"));
35485
35560
  if (!m) return null;
@@ -35490,13 +35565,13 @@ function resolveGitDir(root) {
35490
35565
  }
35491
35566
  }
35492
35567
  function gitConfigPath(gitDir) {
35493
- const commondirFile = join8(gitDir, "commondir");
35568
+ const commondirFile = join9(gitDir, "commondir");
35494
35569
  if (existsSync10(commondirFile)) {
35495
35570
  const common = readFileSync8(commondirFile, "utf8").trim();
35496
35571
  const commonDir = isAbsolute2(common) ? common : resolve2(gitDir, common);
35497
- return join8(commonDir, "config");
35572
+ return join9(commonDir, "config");
35498
35573
  }
35499
- return join8(gitDir, "config");
35574
+ return join9(gitDir, "config");
35500
35575
  }
35501
35576
  function readRemotes(root) {
35502
35577
  const gitDir = resolveGitDir(root);
@@ -35562,7 +35637,7 @@ var init_git_remote = __esm({
35562
35637
  // src/profile.ts
35563
35638
  import { existsSync as existsSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "node:fs";
35564
35639
  import { createHash as createHash5 } from "node:crypto";
35565
- import { join as join9 } from "node:path";
35640
+ import { join as join10 } from "node:path";
35566
35641
  function workspaceId(root) {
35567
35642
  return "wp_" + createHash5("sha256").update(root).digest("hex").slice(0, 12);
35568
35643
  }
@@ -35599,13 +35674,13 @@ function autodetectProfile(root) {
35599
35674
  const p = emptyProfile(id, name2);
35600
35675
  const locator = detectRepoLocator(root);
35601
35676
  if (locator) p.repoLocator = locator;
35602
- const pkgPath = join9(root, "package.json");
35677
+ const pkgPath = join10(root, "package.json");
35603
35678
  if (existsSync11(pkgPath)) {
35604
35679
  try {
35605
35680
  const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
35606
35681
  const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
35607
35682
  p.languages.push("javascript");
35608
- if (existsSync11(join9(root, "tsconfig.json")) || deps["typescript"]) {
35683
+ if (existsSync11(join10(root, "tsconfig.json")) || deps["typescript"]) {
35609
35684
  p.languages.push("typescript");
35610
35685
  }
35611
35686
  const nodeVer = pkg.engines?.node?.trim();
@@ -35626,7 +35701,7 @@ function autodetectProfile(root) {
35626
35701
  } catch {
35627
35702
  }
35628
35703
  }
35629
- const pyproject = join9(root, "pyproject.toml");
35704
+ const pyproject = join10(root, "pyproject.toml");
35630
35705
  if (existsSync11(pyproject)) {
35631
35706
  try {
35632
35707
  const txt = readFileSync9(pyproject, "utf8");
@@ -35640,16 +35715,16 @@ function autodetectProfile(root) {
35640
35715
  } catch {
35641
35716
  }
35642
35717
  }
35643
- const reqs = join9(root, "requirements.txt");
35718
+ const reqs = join10(root, "requirements.txt");
35644
35719
  if (existsSync11(reqs)) {
35645
35720
  if (!p.languages.includes("python")) p.languages.push("python");
35646
35721
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
35647
35722
  }
35648
- if (existsSync11(join9(root, "go.mod"))) {
35723
+ if (existsSync11(join10(root, "go.mod"))) {
35649
35724
  p.languages.push("go");
35650
35725
  p.stack.push("go");
35651
35726
  }
35652
- if (existsSync11(join9(root, "Cargo.toml"))) {
35727
+ if (existsSync11(join10(root, "Cargo.toml"))) {
35653
35728
  p.languages.push("rust");
35654
35729
  p.stack.push("rust");
35655
35730
  }
@@ -35755,11 +35830,11 @@ var init_identity2 = __esm({
35755
35830
 
35756
35831
  // src/checkout-root.ts
35757
35832
  import { existsSync as existsSync12, readFileSync as readFileSync10 } from "node:fs";
35758
- import { basename as basename3, dirname as dirname7, isAbsolute as isAbsolute3, join as join10, resolve as resolve3 } from "node:path";
35833
+ import { basename as basename3, dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve3 } from "node:path";
35759
35834
  function nearestGitRoot(dir) {
35760
35835
  let cur = resolve3(dir);
35761
35836
  for (; ; ) {
35762
- if (existsSync12(join10(cur, ".git"))) return cur;
35837
+ if (existsSync12(join11(cur, ".git"))) return cur;
35763
35838
  const parent = dirname7(cur);
35764
35839
  if (parent === cur) return null;
35765
35840
  cur = parent;
@@ -35767,8 +35842,8 @@ function nearestGitRoot(dir) {
35767
35842
  }
35768
35843
  function mainCheckoutOfWorktree(root) {
35769
35844
  const gitDir = resolveGitDir(root);
35770
- if (!gitDir || gitDir === join10(root, ".git")) return null;
35771
- const commondirFile = join10(gitDir, "commondir");
35845
+ if (!gitDir || gitDir === join11(root, ".git")) return null;
35846
+ const commondirFile = join11(gitDir, "commondir");
35772
35847
  if (!existsSync12(commondirFile)) return null;
35773
35848
  let common;
35774
35849
  try {
@@ -35779,7 +35854,7 @@ function mainCheckoutOfWorktree(root) {
35779
35854
  const commonDir = resolve3(isAbsolute3(common) ? common : resolve3(gitDir, common));
35780
35855
  if (basename3(commonDir) !== ".git") return null;
35781
35856
  const main2 = dirname7(commonDir);
35782
- return existsSync12(join10(main2, ".git")) ? main2 : null;
35857
+ return existsSync12(join11(main2, ".git")) ? main2 : null;
35783
35858
  }
35784
35859
  function checkoutRootOf(cwd) {
35785
35860
  const root = nearestGitRoot(cwd);
@@ -35797,7 +35872,7 @@ var init_checkout_root = __esm({
35797
35872
  });
35798
35873
 
35799
35874
  // src/process-identity.ts
35800
- import { execFileSync } from "node:child_process";
35875
+ import { execFileSync as execFileSync2 } from "node:child_process";
35801
35876
  import { readFileSync as readFileSync11 } from "node:fs";
35802
35877
  function readProcessIdentity(pid, fresh = false) {
35803
35878
  if (!Number.isSafeInteger(pid) || pid <= 0) return null;
@@ -35805,7 +35880,7 @@ function readProcessIdentity(pid, fresh = false) {
35805
35880
  const cached2 = recent.get(pid);
35806
35881
  if (!fresh && cached2 && Date.now() - cached2.at < 1e3) return cached2.value;
35807
35882
  try {
35808
- const run3 = (bin, args2) => execFileSync(bin, args2, {
35883
+ const run3 = (bin, args2) => execFileSync2(bin, args2, {
35809
35884
  encoding: "utf8",
35810
35885
  windowsHide: true,
35811
35886
  timeout: 3e3,
@@ -35974,9 +36049,9 @@ var init_lock = __esm({
35974
36049
 
35975
36050
  // src/registry.ts
35976
36051
  import { existsSync as existsSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "node:fs";
35977
- import { join as join11 } from "node:path";
36052
+ import { join as join12 } from "node:path";
35978
36053
  function registryPath() {
35979
- return process.env["ERRATA_REGISTRY_PATH"] ?? join11(globalDir(), "workspaces.json");
36054
+ return process.env["ERRATA_REGISTRY_PATH"] ?? join12(globalDir(), "workspaces.json");
35980
36055
  }
35981
36056
  function read() {
35982
36057
  const p = registryPath();
@@ -37794,17 +37869,17 @@ var init_daemon_generalize_client = __esm({
37794
37869
 
37795
37870
  // ../../packages/indexer/src/parse-cache.ts
37796
37871
  import { createHash as createHash6 } from "node:crypto";
37797
- import { existsSync as existsSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync11 } from "node:fs";
37872
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync11 } from "node:fs";
37798
37873
  import { homedir as homedir3 } from "node:os";
37799
- import { join as join12 } from "node:path";
37874
+ import { join as join13 } from "node:path";
37800
37875
  function parseCacheDir() {
37801
- return process.env["ERRATA_PARSE_CACHE"] ?? join12(homedir3(), ".errata", "parse-cache");
37876
+ return process.env["ERRATA_PARSE_CACHE"] ?? join13(homedir3(), ".errata", "parse-cache");
37802
37877
  }
37803
37878
  function parseCacheKey(source, providerId) {
37804
37879
  return createHash6("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
37805
37880
  }
37806
37881
  function entryPath(dir, key) {
37807
- return join12(dir, key.slice(0, 2), `${key.slice(2)}.json`);
37882
+ return join13(dir, key.slice(0, 2), `${key.slice(2)}.json`);
37808
37883
  }
37809
37884
  function readParseCache(dir, key) {
37810
37885
  const file2 = entryPath(dir, key);
@@ -37828,7 +37903,7 @@ function writeParseCache(dir, key, providerId, value) {
37828
37903
  const body2 = JSON.stringify(envelope);
37829
37904
  if (body2.length > MAX_ENTRY_BYTES) return;
37830
37905
  const file2 = entryPath(dir, key);
37831
- mkdirSync6(join12(dir, key.slice(0, 2)), { recursive: true });
37906
+ mkdirSync6(join13(dir, key.slice(0, 2)), { recursive: true });
37832
37907
  writeFileSync11(file2, body2);
37833
37908
  } catch {
37834
37909
  }
@@ -37840,7 +37915,7 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
37840
37915
  try {
37841
37916
  if (!existsSync15(dir)) return 0;
37842
37917
  for (const bucket of readdirSync2(dir)) {
37843
- const bucketDir = join12(dir, bucket);
37918
+ const bucketDir = join13(dir, bucket);
37844
37919
  let names;
37845
37920
  try {
37846
37921
  names = readdirSync2(bucketDir);
@@ -37848,9 +37923,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
37848
37923
  continue;
37849
37924
  }
37850
37925
  for (const name2 of names) {
37851
- const file2 = join12(bucketDir, name2);
37926
+ const file2 = join13(bucketDir, name2);
37852
37927
  try {
37853
- if (now - statSync3(file2).mtimeMs > ENTRY_TTL_MS) {
37928
+ if (now - statSync4(file2).mtimeMs > ENTRY_TTL_MS) {
37854
37929
  rmSync2(file2, { force: true });
37855
37930
  removed++;
37856
37931
  }
@@ -38096,11 +38171,11 @@ var init_identity3 = __esm({
38096
38171
  });
38097
38172
 
38098
38173
  // ../../packages/indexer/src/pipeline.ts
38099
- import { appendFileSync, readFileSync as readFileSync15, statSync as statSync4 } from "node:fs";
38174
+ import { appendFileSync, readFileSync as readFileSync15, statSync as statSync5 } from "node:fs";
38100
38175
  import { readdir } from "node:fs/promises";
38101
- import { extname, join as join13, relative as relative2, sep } from "node:path";
38176
+ import { extname, join as join14, relative as relative2, sep } from "node:path";
38102
38177
  import { createHash as createHash7 } from "node:crypto";
38103
- import { execFileSync as execFileSync2 } from "node:child_process";
38178
+ import { execFileSync as execFileSync3 } from "node:child_process";
38104
38179
  function nowTs() {
38105
38180
  return indexNow ?? Date.now();
38106
38181
  }
@@ -38237,7 +38312,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
38237
38312
  for (const rel of [...changedRelPaths]) {
38238
38313
  let h;
38239
38314
  try {
38240
- h = createHash7("sha256").update(readFileSync15(join13(rootPath, rel))).digest("hex");
38315
+ h = createHash7("sha256").update(readFileSync15(join14(rootPath, rel))).digest("hex");
38241
38316
  } catch {
38242
38317
  continue;
38243
38318
  }
@@ -38286,7 +38361,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
38286
38361
  let parsedFiles = 0;
38287
38362
  for (const rel of changedRelPaths) {
38288
38363
  if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
38289
- const abs = join13(rootPath, ...rel.split("/"));
38364
+ const abs = join14(rootPath, ...rel.split("/"));
38290
38365
  const ext = extname(abs).toLowerCase();
38291
38366
  const provider = providers.find((p) => p.fileExtensions.includes(ext));
38292
38367
  if (!provider) continue;
@@ -38609,7 +38684,7 @@ async function runIndexer(store, opts) {
38609
38684
  }
38610
38685
  let source;
38611
38686
  try {
38612
- const st = statSync4(f.absPath);
38687
+ const st = statSync5(f.absPath);
38613
38688
  if (st.size > maxBytes) {
38614
38689
  report.filesSkipped++;
38615
38690
  continue;
@@ -39074,7 +39149,7 @@ async function scan(root, current, ignores, providers, out2) {
39074
39149
  for (const ent of entries) {
39075
39150
  if (ignores.has(ent.name)) continue;
39076
39151
  if (ent.name.startsWith(".") && ent.name !== ".") continue;
39077
- const abs = join13(current, ent.name);
39152
+ const abs = join14(current, ent.name);
39078
39153
  if (ent.isDirectory()) {
39079
39154
  await scan(root, abs, ignores, providers, out2);
39080
39155
  } else if (ent.isFile()) {
@@ -39084,7 +39159,7 @@ async function scan(root, current, ignores, providers, out2) {
39084
39159
  let size = 0;
39085
39160
  let mtimeMs;
39086
39161
  try {
39087
- const st = statSync4(abs);
39162
+ const st = statSync5(abs);
39088
39163
  size = st.size;
39089
39164
  mtimeMs = st.mtimeMs;
39090
39165
  } catch {
@@ -39104,7 +39179,7 @@ async function scan(root, current, ignores, providers, out2) {
39104
39179
  function gitListRelPaths(root, ignores) {
39105
39180
  let stdout;
39106
39181
  try {
39107
- stdout = execFileSync2(
39182
+ stdout = execFileSync3(
39108
39183
  "git",
39109
39184
  ["-C", root, "ls-files", "--cached", "--others", "--exclude-standard", "-z"],
39110
39185
  {
@@ -39133,11 +39208,11 @@ function gitListFiles(root, ignores, providers) {
39133
39208
  if (rels === null) return null;
39134
39209
  const out2 = [];
39135
39210
  for (const rel of rels) {
39136
- const abs = join13(root, rel);
39211
+ const abs = join14(root, rel);
39137
39212
  let size;
39138
39213
  let mtimeMs;
39139
39214
  try {
39140
- const st = statSync4(abs);
39215
+ const st = statSync5(abs);
39141
39216
  size = st.size;
39142
39217
  mtimeMs = st.mtimeMs;
39143
39218
  } catch {
@@ -43545,7 +43620,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
43545
43620
 
43546
43621
  // ../../packages/indexer/src/languages/tree-sitter-loader.ts
43547
43622
  import { fileURLToPath } from "node:url";
43548
- import { dirname as dirname8, join as join14 } from "node:path";
43623
+ import { dirname as dirname8, join as join15 } from "node:path";
43549
43624
  import { existsSync as existsSync16, readdirSync as readdirSync3 } from "node:fs";
43550
43625
  import { createRequire as createRequire2 } from "node:module";
43551
43626
  function entryDir() {
@@ -43560,27 +43635,27 @@ function entryDir() {
43560
43635
  }
43561
43636
  function findWasmDir() {
43562
43637
  const here = entryDir();
43563
- const seaWasm = join14(here, "resources", "wasm");
43564
- if (existsSync16(join14(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
43638
+ const seaWasm = join15(here, "resources", "wasm");
43639
+ if (existsSync16(join15(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
43565
43640
  let dir = here;
43566
43641
  for (let i2 = 0; i2 < 6; i2++) {
43567
- const flat = join14(
43642
+ const flat = join15(
43568
43643
  dir,
43569
43644
  "node_modules",
43570
43645
  "@vscode",
43571
43646
  "tree-sitter-wasm",
43572
43647
  "wasm"
43573
43648
  );
43574
- if (existsSync16(join14(flat, "tree-sitter-typescript.wasm"))) return flat;
43649
+ if (existsSync16(join15(flat, "tree-sitter-typescript.wasm"))) return flat;
43575
43650
  dir = dirname8(dir);
43576
43651
  }
43577
43652
  let root = here;
43578
43653
  for (let i2 = 0; i2 < 6; i2++) {
43579
- const pnpmDir = join14(root, "node_modules", ".pnpm");
43654
+ const pnpmDir = join15(root, "node_modules", ".pnpm");
43580
43655
  if (existsSync16(pnpmDir)) {
43581
43656
  for (const entry of readdirSync3(pnpmDir)) {
43582
43657
  if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
43583
- const candidate = join14(
43658
+ const candidate = join15(
43584
43659
  pnpmDir,
43585
43660
  entry,
43586
43661
  "node_modules",
@@ -43588,7 +43663,7 @@ function findWasmDir() {
43588
43663
  "tree-sitter-wasm",
43589
43664
  "wasm"
43590
43665
  );
43591
- if (existsSync16(join14(candidate, "tree-sitter-typescript.wasm"))) {
43666
+ if (existsSync16(join15(candidate, "tree-sitter-typescript.wasm"))) {
43592
43667
  return candidate;
43593
43668
  }
43594
43669
  }
@@ -43602,27 +43677,27 @@ function findWasmDir() {
43602
43677
  }
43603
43678
  function findRuntimeDir() {
43604
43679
  const here = entryDir();
43605
- const seaRuntime = join14(here, "resources", "wasm");
43606
- if (existsSync16(join14(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
43680
+ const seaRuntime = join15(here, "resources", "wasm");
43681
+ if (existsSync16(join15(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
43607
43682
  let dir = here;
43608
43683
  for (let i2 = 0; i2 < 6; i2++) {
43609
- const flat = join14(dir, "node_modules", "web-tree-sitter");
43610
- if (existsSync16(join14(flat, "web-tree-sitter.wasm"))) return flat;
43684
+ const flat = join15(dir, "node_modules", "web-tree-sitter");
43685
+ if (existsSync16(join15(flat, "web-tree-sitter.wasm"))) return flat;
43611
43686
  dir = dirname8(dir);
43612
43687
  }
43613
43688
  let root = here;
43614
43689
  for (let i2 = 0; i2 < 6; i2++) {
43615
- const pnpmDir = join14(root, "node_modules", ".pnpm");
43690
+ const pnpmDir = join15(root, "node_modules", ".pnpm");
43616
43691
  if (existsSync16(pnpmDir)) {
43617
43692
  for (const entry of readdirSync3(pnpmDir)) {
43618
43693
  if (entry.startsWith("web-tree-sitter@")) {
43619
- const candidate = join14(
43694
+ const candidate = join15(
43620
43695
  pnpmDir,
43621
43696
  entry,
43622
43697
  "node_modules",
43623
43698
  "web-tree-sitter"
43624
43699
  );
43625
- if (existsSync16(join14(candidate, "web-tree-sitter.wasm"))) {
43700
+ if (existsSync16(join15(candidate, "web-tree-sitter.wasm"))) {
43626
43701
  return candidate;
43627
43702
  }
43628
43703
  }
@@ -43639,7 +43714,7 @@ async function loadWebTreeSitter() {
43639
43714
  void err2;
43640
43715
  }
43641
43716
  const here = entryDir();
43642
- const seaResourceBase = join14(here, "resources", "_resolve.js");
43717
+ const seaResourceBase = join15(here, "resources", "_resolve.js");
43643
43718
  const resourceRequire = createRequire2(seaResourceBase);
43644
43719
  return resourceRequire("web-tree-sitter");
43645
43720
  }
@@ -43654,9 +43729,9 @@ async function ensureTreeSitterReady() {
43654
43729
  await Parser2.init({
43655
43730
  locateFile: (name2) => {
43656
43731
  if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
43657
- return join14(runtime, name2);
43732
+ return join15(runtime, name2);
43658
43733
  }
43659
- return join14(grammars, name2);
43734
+ return join15(grammars, name2);
43660
43735
  }
43661
43736
  });
43662
43737
  })();
@@ -43668,7 +43743,7 @@ async function loadGrammar(name2) {
43668
43743
  if (cached2) return cached2;
43669
43744
  if (!languageClass) throw new Error("tree-sitter not initialized");
43670
43745
  const grammars = findWasmDir();
43671
- const lang = await languageClass.load(join14(grammars, `${name2}.wasm`));
43746
+ const lang = await languageClass.load(join15(grammars, `${name2}.wasm`));
43672
43747
  grammarCache.set(name2, lang);
43673
43748
  return lang;
43674
43749
  }
@@ -46571,9 +46646,9 @@ var init_src11 = __esm({
46571
46646
  });
46572
46647
 
46573
46648
  // src/reconcile.ts
46574
- import { execFileSync as execFileSync3 } from "node:child_process";
46575
- import { readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
46576
- import { join as join15, relative as relative3, sep as sep2 } from "node:path";
46649
+ import { execFileSync as execFileSync4 } from "node:child_process";
46650
+ import { readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
46651
+ import { join as join16, relative as relative3, sep as sep2 } from "node:path";
46577
46652
  function indexerWouldScan(rel) {
46578
46653
  for (const seg of rel.split(/[\\/]/)) {
46579
46654
  if (seg.length === 0) continue;
@@ -46585,7 +46660,7 @@ function indexerWouldScan(rel) {
46585
46660
  function gitSourceFiles(root) {
46586
46661
  let stdout;
46587
46662
  try {
46588
- stdout = execFileSync3(
46663
+ stdout = execFileSync4(
46589
46664
  "git",
46590
46665
  ["-C", root, "ls-files", "--cached", "--others", "--exclude-standard", "-z"],
46591
46666
  { encoding: "utf8", maxBuffer: 128 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
@@ -46596,7 +46671,7 @@ function gitSourceFiles(root) {
46596
46671
  const out2 = [];
46597
46672
  for (const rel of stdout.split("\0")) {
46598
46673
  if (!rel || !SOURCE_RE.test(rel) || !indexerWouldScan(rel)) continue;
46599
- const abs = join15(root, rel);
46674
+ const abs = join16(root, rel);
46600
46675
  if (IGNORED.test(abs)) continue;
46601
46676
  out2.push(abs);
46602
46677
  }
@@ -46611,7 +46686,7 @@ function* walkSource(dir) {
46611
46686
  }
46612
46687
  for (const e of entries) {
46613
46688
  const name2 = String(e.name);
46614
- const full = join15(dir, name2);
46689
+ const full = join16(dir, name2);
46615
46690
  if (IGNORED.test(full)) continue;
46616
46691
  if (!indexerWouldScan(name2)) continue;
46617
46692
  if (e.isDirectory()) yield* walkSource(full);
@@ -46636,7 +46711,7 @@ async function findStaleFiles(store, rootPath, workspaceId2) {
46636
46711
  for (const abs of listSourceFiles(rootPath)) {
46637
46712
  try {
46638
46713
  const rel = relative3(rootPath, abs).split(sep2).join("/");
46639
- pending.push({ abs, id: fileNodeId(workspaceId2, rel), mtimeMs: statSync5(abs).mtimeMs });
46714
+ pending.push({ abs, id: fileNodeId(workspaceId2, rel), mtimeMs: statSync6(abs).mtimeMs });
46640
46715
  } catch {
46641
46716
  }
46642
46717
  if (++scanned % SCAN_YIELD_EVERY === 0) {
@@ -48945,7 +49020,7 @@ __export(vfile_exports, {
48945
49020
  segmentsOf: () => segmentsOf
48946
49021
  });
48947
49022
  import { writeFileSync as writeFileSync12 } from "node:fs";
48948
- import { join as join16, resolve as resolve5, sep as sep3 } from "node:path";
49023
+ import { join as join17, resolve as resolve5, sep as sep3 } from "node:path";
48949
49024
  function segmentsOf(rawPath) {
48950
49025
  let p = rawPath.replace(/\\/g, "/");
48951
49026
  p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
@@ -49019,7 +49094,7 @@ async function renderVFile(rawPath, store, ctx = {}) {
49019
49094
  }
49020
49095
  async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
49021
49096
  const segs = segmentsOf(rawPath);
49022
- const gRoot = join16(workspaceRoot, ".errata", "g");
49097
+ const gRoot = join17(workspaceRoot, ".errata", "g");
49023
49098
  const abs = resolve5(gRoot, ...segs.length ? segs : ["index"]);
49024
49099
  if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
49025
49100
  throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
@@ -56453,12 +56528,12 @@ import {
56453
56528
  unlinkSync as unlinkSync3,
56454
56529
  writeFileSync as writeFileSync13
56455
56530
  } from "node:fs";
56456
- import { join as join17 } from "node:path";
56531
+ import { join as join18 } from "node:path";
56457
56532
  import { createHash as createHash15 } from "node:crypto";
56458
56533
  function enqueueOutbox(paths, payload) {
56459
56534
  ensureDir(paths.outbox);
56460
56535
  const id = createHash15("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
56461
- const file2 = join17(paths.outbox, `${Date.now()}-${id}.json`);
56536
+ const file2 = join18(paths.outbox, `${Date.now()}-${id}.json`);
56462
56537
  writeFileSync13(file2, JSON.stringify(payload, null, 2), "utf8");
56463
56538
  return file2;
56464
56539
  }
@@ -56475,7 +56550,7 @@ async function flushOutbox(paths, client, store) {
56475
56550
  }
56476
56551
  };
56477
56552
  for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
56478
- const abs = join17(paths.outbox, f);
56553
+ const abs = join18(paths.outbox, f);
56479
56554
  let payload;
56480
56555
  try {
56481
56556
  payload = JSON.parse(readFileSync17(abs, "utf8"));
@@ -76360,9 +76435,9 @@ __export(witness_ledger_exports, {
76360
76435
  witnessLedgerPath: () => witnessLedgerPath
76361
76436
  });
76362
76437
  import { appendFileSync as appendFileSync3, existsSync as existsSync27, readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
76363
- import { join as join33 } from "node:path";
76438
+ import { join as join34 } from "node:path";
76364
76439
  function witnessLedgerPath(configDir) {
76365
- return join33(configDir, "witness-ledger.jsonl");
76440
+ return join34(configDir, "witness-ledger.jsonl");
76366
76441
  }
76367
76442
  function appendWitnessLedger(configDir, entry) {
76368
76443
  const path3 = witnessLedgerPath(configDir);
@@ -76818,8 +76893,8 @@ var init_report_render = __esm({
76818
76893
 
76819
76894
  // src/cli.ts
76820
76895
  init_src6();
76821
- import { closeSync as closeSync3, existsSync as existsSync40, openSync as openSync3, readFileSync as readFileSync44, renameSync as renameSync9, statSync as statSync13 } from "node:fs";
76822
- import { join as join51, resolve as pathResolve2 } from "node:path";
76896
+ import { closeSync as closeSync3, existsSync as existsSync40, openSync as openSync3, readFileSync as readFileSync45, renameSync as renameSync9, statSync as statSync15 } from "node:fs";
76897
+ import { join as join53, resolve as pathResolve2 } from "node:path";
76823
76898
  import { spawn as spawn5 } from "node:child_process";
76824
76899
 
76825
76900
  // src/daemon.ts
@@ -77506,9 +77581,9 @@ function knowledgeTag(label, attrs) {
77506
77581
  }
77507
77582
 
77508
77583
  // src/engine.ts
77509
- import { execFileSync as execFileSync5 } from "node:child_process";
77510
- import { existsSync as existsSync28, statSync as statSync9, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync4, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
77511
- import { basename as basename8, join as join35, relative as relative7, sep as sep4 } from "node:path";
77584
+ import { execFileSync as execFileSync6 } from "node:child_process";
77585
+ import { existsSync as existsSync28, statSync as statSync10, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync4, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
77586
+ import { basename as basename8, join as join36, relative as relative7, sep as sep4 } from "node:path";
77512
77587
 
77513
77588
  // src/coalesced-file-pass.ts
77514
77589
  function createCoalescedFilePass(delayMs, run3, onError) {
@@ -77552,8 +77627,8 @@ function createCoalescedFilePass(delayMs, run3, onError) {
77552
77627
 
77553
77628
  // src/source-watcher.ts
77554
77629
  import { EventEmitter as EventEmitter2 } from "node:events";
77555
- import { readdirSync as readdirSync6, statSync as statSync6, watch as watch2 } from "node:fs";
77556
- import { isAbsolute as isAbsolute5, join as join20, relative as relative6 } from "node:path";
77630
+ import { readdirSync as readdirSync6, statSync as statSync7, watch as watch2 } from "node:fs";
77631
+ import { isAbsolute as isAbsolute5, join as join21, relative as relative6 } from "node:path";
77557
77632
 
77558
77633
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
77559
77634
  import { stat as statcb } from "fs";
@@ -79281,13 +79356,13 @@ var NativeSourceWatcher = class extends EventEmitter2 {
79281
79356
  if (this.closed || this.handles.has(target)) return;
79282
79357
  let isDir;
79283
79358
  try {
79284
- isDir = statSync6(target).isDirectory();
79359
+ isDir = statSync7(target).isDirectory();
79285
79360
  } catch {
79286
79361
  return;
79287
79362
  }
79288
79363
  try {
79289
79364
  const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
79290
- const path3 = isDir ? name2 ? join20(target, name2.toString()) : null : target;
79365
+ const path3 = isDir ? name2 ? join21(target, name2.toString()) : null : target;
79291
79366
  if (!path3) {
79292
79367
  this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
79293
79368
  this.scheduleReconcile(target, isDir);
@@ -79340,7 +79415,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
79340
79415
  try {
79341
79416
  for (const entry of readdirSync6(target, { recursive: true, withFileTypes: true })) {
79342
79417
  if (!entry.isFile()) continue;
79343
- const path3 = join20(entry.parentPath, entry.name);
79418
+ const path3 = join21(entry.parentPath, entry.name);
79344
79419
  if (!this.ignored(path3)) files.add(path3);
79345
79420
  }
79346
79421
  } catch {
@@ -79377,7 +79452,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
79377
79452
  if (this.closed) return;
79378
79453
  let isFile;
79379
79454
  try {
79380
- const s = statSync6(path3);
79455
+ const s = statSync7(path3);
79381
79456
  if (s.isDirectory()) return;
79382
79457
  isFile = s.isFile();
79383
79458
  } catch {
@@ -79832,8 +79907,8 @@ init_review2();
79832
79907
 
79833
79908
  // src/turn.ts
79834
79909
  init_checkout_root();
79835
- import { closeSync as closeSync2, existsSync as existsSync19, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync7 } from "node:fs";
79836
- import { basename as basename6, delimiter, dirname as dirname11, join as join21, normalize as normalize3 } from "node:path";
79910
+ import { closeSync as closeSync2, existsSync as existsSync19, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync8 } from "node:fs";
79911
+ import { basename as basename6, delimiter, dirname as dirname11, join as join22, normalize as normalize3 } from "node:path";
79837
79912
  import { homedir as homedir4 } from "node:os";
79838
79913
  import { createHash as createHash16 } from "node:crypto";
79839
79914
  function completeJsonlPrefix(buf) {
@@ -80221,7 +80296,7 @@ function turnsSince(turns, mark) {
80221
80296
  return at >= 0 ? turns.slice(at + 1) : turns;
80222
80297
  }
80223
80298
  function claudeProjectDir(cwd, home = homedir4()) {
80224
- return join21(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
80299
+ return join22(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
80225
80300
  }
80226
80301
  function recentTranscripts(cwd, opts = {}) {
80227
80302
  const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
@@ -80236,10 +80311,10 @@ function recentTranscripts(cwd, opts = {}) {
80236
80311
  const refs = [];
80237
80312
  for (const name2 of names) {
80238
80313
  if (!name2.endsWith(".jsonl")) continue;
80239
- const path3 = join21(dir, name2);
80314
+ const path3 = join22(dir, name2);
80240
80315
  let mtimeMs;
80241
80316
  try {
80242
- mtimeMs = statSync7(path3).mtimeMs;
80317
+ mtimeMs = statSync8(path3).mtimeMs;
80243
80318
  } catch {
80244
80319
  continue;
80245
80320
  }
@@ -80251,7 +80326,7 @@ function recentTranscripts(cwd, opts = {}) {
80251
80326
  }
80252
80327
  function subagentTranscripts(mainTranscriptPath, sessionId) {
80253
80328
  if (!mainTranscriptPath || !sessionId) return [];
80254
- const dir = join21(dirname11(mainTranscriptPath), sessionId, "subagents");
80329
+ const dir = join22(dirname11(mainTranscriptPath), sessionId, "subagents");
80255
80330
  if (!existsSync19(dir)) return [];
80256
80331
  let names;
80257
80332
  try {
@@ -80262,10 +80337,10 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
80262
80337
  const refs = [];
80263
80338
  for (const name2 of names) {
80264
80339
  if (!name2.endsWith(".jsonl")) continue;
80265
- const path3 = join21(dir, name2);
80340
+ const path3 = join22(dir, name2);
80266
80341
  let mtimeMs;
80267
80342
  try {
80268
- mtimeMs = statSync7(path3).mtimeMs;
80343
+ mtimeMs = statSync8(path3).mtimeMs;
80269
80344
  } catch {
80270
80345
  continue;
80271
80346
  }
@@ -80281,8 +80356,8 @@ function splitPathList(value, sep6 = delimiter) {
80281
80356
  function codexSessionRoots(env2 = process.env, home = homedir4()) {
80282
80357
  const roots = /* @__PURE__ */ new Set();
80283
80358
  for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
80284
- if (env2["CODEX_HOME"]) roots.add(join21(env2["CODEX_HOME"], "sessions"));
80285
- roots.add(join21(home, ".codex", "sessions"));
80359
+ if (env2["CODEX_HOME"]) roots.add(join22(env2["CODEX_HOME"], "sessions"));
80360
+ roots.add(join22(home, ".codex", "sessions"));
80286
80361
  return [...roots];
80287
80362
  }
80288
80363
  function readCodexRolloutIdentity(path3) {
@@ -80354,10 +80429,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
80354
80429
  continue;
80355
80430
  }
80356
80431
  for (const name2 of names) {
80357
- const full = join21(dir, name2);
80432
+ const full = join22(dir, name2);
80358
80433
  let st;
80359
80434
  try {
80360
- st = statSync7(full);
80435
+ st = statSync8(full);
80361
80436
  } catch {
80362
80437
  continue;
80363
80438
  }
@@ -80396,8 +80471,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
80396
80471
  function geminiSessionRoots(env2 = process.env, home = homedir4()) {
80397
80472
  const roots = /* @__PURE__ */ new Set();
80398
80473
  for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
80399
- if (env2["GEMINI_CLI_HOME"]) roots.add(join21(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
80400
- roots.add(join21(home, ".gemini", "tmp"));
80474
+ if (env2["GEMINI_CLI_HOME"]) roots.add(join22(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
80475
+ roots.add(join22(home, ".gemini", "tmp"));
80401
80476
  return [...roots];
80402
80477
  }
80403
80478
  function geminiProjectHash(cwd) {
@@ -80445,7 +80520,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
80445
80520
  continue;
80446
80521
  }
80447
80522
  for (const slug2 of slugs) {
80448
- const chats = join21(root, slug2, "chats");
80523
+ const chats = join22(root, slug2, "chats");
80449
80524
  let names;
80450
80525
  try {
80451
80526
  names = readdirSync7(chats);
@@ -80454,10 +80529,10 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
80454
80529
  }
80455
80530
  for (const name2 of names) {
80456
80531
  if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
80457
- const full = join21(chats, name2);
80532
+ const full = join22(chats, name2);
80458
80533
  let st;
80459
80534
  try {
80460
- st = statSync7(full);
80535
+ st = statSync8(full);
80461
80536
  } catch {
80462
80537
  continue;
80463
80538
  }
@@ -80474,8 +80549,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
80474
80549
  function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
80475
80550
  const roots = /* @__PURE__ */ new Set();
80476
80551
  for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
80477
- if (env2["XDG_DATA_HOME"]) roots.add(join21(env2["XDG_DATA_HOME"], "opencode", "errata"));
80478
- roots.add(join21(home, ".local", "share", "opencode", "errata"));
80552
+ if (env2["XDG_DATA_HOME"]) roots.add(join22(env2["XDG_DATA_HOME"], "opencode", "errata"));
80553
+ roots.add(join22(home, ".local", "share", "opencode", "errata"));
80479
80554
  return [...roots];
80480
80555
  }
80481
80556
  function readOpencodeTranscriptDirectory(path3) {
@@ -80517,10 +80592,10 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
80517
80592
  }
80518
80593
  for (const name2 of names) {
80519
80594
  if (!name2.endsWith(".jsonl")) continue;
80520
- const full = join21(root, name2);
80595
+ const full = join22(root, name2);
80521
80596
  let st;
80522
80597
  try {
80523
- st = statSync7(full);
80598
+ st = statSync8(full);
80524
80599
  } catch {
80525
80600
  continue;
80526
80601
  }
@@ -81836,7 +81911,7 @@ ${conversation}` }]
81836
81911
  init_src5();
81837
81912
  init_src2();
81838
81913
  import { existsSync as existsSync20, readFileSync as readFileSync19, readdirSync as readdirSync8, writeFileSync as writeFileSync15 } from "node:fs";
81839
- import { join as join22 } from "node:path";
81914
+ import { join as join23 } from "node:path";
81840
81915
  import { homedir as homedir5 } from "node:os";
81841
81916
  var BACKFILL_VERSION = 1;
81842
81917
  var EMPTY = {
@@ -81850,7 +81925,7 @@ var EMPTY = {
81850
81925
  recoverable: 0
81851
81926
  };
81852
81927
  function markerPath(configDir) {
81853
- return join22(configDir, "constraint-backfill.json");
81928
+ return join23(configDir, "constraint-backfill.json");
81854
81929
  }
81855
81930
  function alreadyDone(configDir) {
81856
81931
  const p = markerPath(configDir);
@@ -81876,7 +81951,7 @@ function replay(root) {
81876
81951
  for (const f of names) {
81877
81952
  let lines;
81878
81953
  try {
81879
- lines = readFileSync19(join22(dir, f), "utf8").split("\n");
81954
+ lines = readFileSync19(join23(dir, f), "utf8").split("\n");
81880
81955
  } catch {
81881
81956
  continue;
81882
81957
  }
@@ -82004,7 +82079,7 @@ function backfillConstraintKind(store, opts) {
82004
82079
  init_src();
82005
82080
  init_src5();
82006
82081
  import { existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync16 } from "node:fs";
82007
- import { join as join23 } from "node:path";
82082
+ import { join as join24 } from "node:path";
82008
82083
  function citeEdgeId(from, type, to) {
82009
82084
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
82010
82085
  }
@@ -82019,7 +82094,7 @@ var EMPTY2 = {
82019
82094
  byType: {}
82020
82095
  };
82021
82096
  function markerPath2(configDir) {
82022
- return join23(configDir, "edge-repair.json");
82097
+ return join24(configDir, "edge-repair.json");
82023
82098
  }
82024
82099
  function alreadyDone2(configDir) {
82025
82100
  const p = markerPath2(configDir);
@@ -82089,7 +82164,7 @@ init_reconcile();
82089
82164
 
82090
82165
  // src/pass-ledger.ts
82091
82166
  import { appendFileSync as appendFileSync2, existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
82092
- import { join as join24 } from "node:path";
82167
+ import { join as join25 } from "node:path";
82093
82168
 
82094
82169
  // src/isolate-census.ts
82095
82170
  var live2 = 0;
@@ -82115,7 +82190,7 @@ var HOUR_MS = 36e5;
82115
82190
  var TRIM_EVERY = 50;
82116
82191
  var appendsSinceTrim = /* @__PURE__ */ new Map();
82117
82192
  function passLedgerPath(configDir) {
82118
- return join24(configDir, "pass-ledger.jsonl");
82193
+ return join25(configDir, "pass-ledger.jsonl");
82119
82194
  }
82120
82195
  function appendPassLedger(configDir, kind, durationMs, counts) {
82121
82196
  const path3 = passLedgerPath(configDir);
@@ -82593,10 +82668,10 @@ init_src10();
82593
82668
  init_src();
82594
82669
  init_src2();
82595
82670
  import { readFileSync as readFileSync22 } from "node:fs";
82596
- import { join as join25 } from "node:path";
82671
+ import { join as join26 } from "node:path";
82597
82672
  function loadClaimIgnorePatterns(workspaceRoot) {
82598
82673
  try {
82599
- return readFileSync22(join25(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
82674
+ return readFileSync22(join26(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
82600
82675
  } catch {
82601
82676
  return [];
82602
82677
  }
@@ -82978,10 +83053,10 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
82978
83053
 
82979
83054
  // src/retrieval-stack.ts
82980
83055
  init_src();
82981
- import { execFileSync as execFileSync4 } from "node:child_process";
82982
- import { existsSync as existsSync23, readFileSync as readFileSync23, statSync as statSync8 } from "node:fs";
83056
+ import { execFileSync as execFileSync5 } from "node:child_process";
83057
+ import { existsSync as existsSync23, readFileSync as readFileSync23, statSync as statSync9 } from "node:fs";
82983
83058
  import { homedir as homedir6 } from "node:os";
82984
- import { join as join26 } from "node:path";
83059
+ import { join as join27 } from "node:path";
82985
83060
  var RETRIEVAL_STACK_CAP = 24;
82986
83061
  var MANIFEST_SCAN_CAP = 400;
82987
83062
  var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
@@ -83278,44 +83353,44 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
83278
83353
  };
83279
83354
  const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
83280
83355
  const home = homedir6();
83281
- const npm = parseNpmrcPolicy(texts(join26(root, ".npmrc"), join26(home, ".npmrc")));
83356
+ const npm = parseNpmrcPolicy(texts(join27(root, ".npmrc"), join27(home, ".npmrc")));
83282
83357
  const blocked = /* @__PURE__ */ new Set();
83283
83358
  if (!npm.defaultPublic) blocked.add("npm");
83284
83359
  if (pypiIndexIsPrivate(
83285
83360
  texts(
83286
- join26(root, "pip.conf"),
83287
- join26(root, "pip.ini"),
83288
- join26(root, "pyproject.toml"),
83289
- join26(root, "requirements.txt"),
83290
- join26(home, ".pip", "pip.conf"),
83291
- join26(home, ".config", "pip", "pip.conf"),
83292
- join26(env2["APPDATA"] ?? home, "pip", "pip.ini")
83361
+ join27(root, "pip.conf"),
83362
+ join27(root, "pip.ini"),
83363
+ join27(root, "pyproject.toml"),
83364
+ join27(root, "requirements.txt"),
83365
+ join27(home, ".pip", "pip.conf"),
83366
+ join27(home, ".config", "pip", "pip.conf"),
83367
+ join27(env2["APPDATA"] ?? home, "pip", "pip.ini")
83293
83368
  )
83294
83369
  )) {
83295
83370
  blocked.add("pypi");
83296
83371
  }
83297
83372
  if (cargoRegistryIsPrivate(
83298
83373
  texts(
83299
- join26(root, ".cargo", "config.toml"),
83300
- join26(root, ".cargo", "config"),
83301
- join26(home, ".cargo", "config.toml"),
83302
- join26(home, ".cargo", "config")
83374
+ join27(root, ".cargo", "config.toml"),
83375
+ join27(root, ".cargo", "config"),
83376
+ join27(home, ".cargo", "config.toml"),
83377
+ join27(home, ".cargo", "config")
83303
83378
  )
83304
83379
  )) {
83305
83380
  blocked.add("cargo");
83306
83381
  }
83307
83382
  if (nugetSourcesArePrivate(
83308
83383
  texts(
83309
- join26(root, "NuGet.config"),
83310
- join26(root, "nuget.config"),
83311
- join26(root, "NuGet.Config"),
83312
- join26(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
83313
- join26(home, ".nuget", "NuGet", "NuGet.Config")
83384
+ join27(root, "NuGet.config"),
83385
+ join27(root, "nuget.config"),
83386
+ join27(root, "NuGet.Config"),
83387
+ join27(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
83388
+ join27(home, ".nuget", "NuGet", "NuGet.Config")
83314
83389
  )
83315
83390
  )) {
83316
83391
  blocked.add("nuget");
83317
83392
  }
83318
- const goEnvFile = env2["GOENV"] ?? join26(env2["APPDATA"] ?? join26(home, ".config"), "go", "env");
83393
+ const goEnvFile = env2["GOENV"] ?? join27(env2["APPDATA"] ?? join27(home, ".config"), "go", "env");
83319
83394
  const goEnvText = read2(goEnvFile) ?? "";
83320
83395
  const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
83321
83396
  (k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
@@ -83326,10 +83401,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
83326
83401
  env2["GONOSUMCHECK"],
83327
83402
  ...fromFile
83328
83403
  ]);
83329
- const gemfiles = texts(join26(root, "Gemfile"));
83404
+ const gemfiles = texts(join27(root, "Gemfile"));
83330
83405
  if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
83331
83406
  if (mavenReposArePrivate(
83332
- texts(join26(root, "pom.xml"), join26(home, ".m2", "settings.xml"))
83407
+ texts(join27(root, "pom.xml"), join27(home, ".m2", "settings.xml"))
83333
83408
  )) {
83334
83409
  blocked.add("maven");
83335
83410
  }
@@ -83496,10 +83571,10 @@ function readDirectDependencies(root) {
83496
83571
  const familiesSeen = /* @__PURE__ */ new Set();
83497
83572
  for (const c of LOCKFILES) {
83498
83573
  if (familiesSeen.has(c.family)) continue;
83499
- const p = join26(root, c.file);
83574
+ const p = join27(root, c.file);
83500
83575
  if (!existsSync23(p)) continue;
83501
83576
  try {
83502
- const s = statSync8(p);
83577
+ const s = statSync9(p);
83503
83578
  stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
83504
83579
  } catch {
83505
83580
  continue;
@@ -83526,7 +83601,7 @@ function readDirectDependencies(root) {
83526
83601
  }
83527
83602
  function manifestPaths(root) {
83528
83603
  try {
83529
- const out2 = execFileSync4("git", ["-C", root, "ls-files", "-z"], {
83604
+ const out2 = execFileSync5("git", ["-C", root, "ls-files", "-z"], {
83530
83605
  encoding: "utf8",
83531
83606
  maxBuffer: 128 * 1024 * 1024,
83532
83607
  windowsHide: true,
@@ -83560,14 +83635,14 @@ function manifestPaths(root) {
83560
83635
  "project.godot"
83561
83636
  ];
83562
83637
  return {
83563
- paths: ROOT_MANIFESTS.filter((f) => existsSync23(join26(root, f))),
83638
+ paths: ROOT_MANIFESTS.filter((f) => existsSync23(join27(root, f))),
83564
83639
  tracked: false,
83565
83640
  truncated: false
83566
83641
  };
83567
83642
  }
83568
83643
  var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
83569
83644
  function rootDeclaresWorkspace(root, texts) {
83570
- if (WORKSPACE_MARKERS.some((f) => existsSync23(join26(root, f)))) return true;
83645
+ if (WORKSPACE_MARKERS.some((f) => existsSync23(join27(root, f)))) return true;
83571
83646
  return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
83572
83647
  }
83573
83648
  var EMPTY_SCAN = { deps: [], self: [], complete: true };
@@ -83581,9 +83656,9 @@ function scanManifests(root) {
83581
83656
  const texts = /* @__PURE__ */ new Map();
83582
83657
  const stamps = [];
83583
83658
  for (const rel of paths) {
83584
- const abs = join26(root, rel);
83659
+ const abs = join27(root, rel);
83585
83660
  try {
83586
- const s = statSync8(abs);
83661
+ const s = statSync9(abs);
83587
83662
  stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
83588
83663
  texts.set(rel, readFileSync23(abs, "utf8"));
83589
83664
  } catch {
@@ -83622,7 +83697,7 @@ function readRetrievalInputs(root, repoLocator) {
83622
83697
 
83623
83698
  // src/git-sensor.ts
83624
83699
  import { existsSync as existsSync24, readFileSync as readFileSync24, watch as fsWatch } from "node:fs";
83625
- import { join as join27 } from "node:path";
83700
+ import { join as join28 } from "node:path";
83626
83701
  function readFirstLine(path3) {
83627
83702
  try {
83628
83703
  return readFileSync24(path3, "utf8").split(/\r?\n/, 1)[0].trim();
@@ -83631,12 +83706,12 @@ function readFirstLine(path3) {
83631
83706
  }
83632
83707
  }
83633
83708
  function readGitRefState(gitDir) {
83634
- const head2 = readFirstLine(join27(gitDir, "HEAD"));
83709
+ const head2 = readFirstLine(join28(gitDir, "HEAD"));
83635
83710
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
83636
83711
  const branch = m ? m[1] : null;
83637
83712
  let sha2 = null;
83638
83713
  if (branch) {
83639
- sha2 = readFirstLine(join27(gitDir, "refs", "heads", branch));
83714
+ sha2 = readFirstLine(join28(gitDir, "refs", "heads", branch));
83640
83715
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
83641
83716
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
83642
83717
  sha2 = head2;
@@ -83644,13 +83719,13 @@ function readGitRefState(gitDir) {
83644
83719
  return {
83645
83720
  branch,
83646
83721
  sha: sha2,
83647
- mergeHeadExists: existsSync24(join27(gitDir, "MERGE_HEAD")),
83648
- origHeadExists: existsSync24(join27(gitDir, "ORIG_HEAD"))
83722
+ mergeHeadExists: existsSync24(join28(gitDir, "MERGE_HEAD")),
83723
+ origHeadExists: existsSync24(join28(gitDir, "ORIG_HEAD"))
83649
83724
  };
83650
83725
  }
83651
83726
  function shaFromPackedRefs(gitDir, ref) {
83652
83727
  try {
83653
- for (const line of readFileSync24(join27(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
83728
+ for (const line of readFileSync24(join28(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
83654
83729
  const [sha2, name2] = line.split(/\s+/);
83655
83730
  if (name2 === ref && sha2) return sha2;
83656
83731
  }
@@ -83684,7 +83759,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
83684
83759
  const settle = () => {
83685
83760
  if (timer) clearTimeout(timer);
83686
83761
  timer = setTimeout(() => {
83687
- if (existsSync24(join27(gitDir, "index.lock"))) {
83762
+ if (existsSync24(join28(gitDir, "index.lock"))) {
83688
83763
  settle();
83689
83764
  return;
83690
83765
  }
@@ -83695,7 +83770,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
83695
83770
  }, debounceMs);
83696
83771
  };
83697
83772
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
83698
- const p = join27(gitDir, sub);
83773
+ const p = join28(gitDir, sub);
83699
83774
  try {
83700
83775
  watchers.push(fsWatch(p, settle));
83701
83776
  } catch {
@@ -83926,7 +84001,7 @@ var TelemetryRecorder = class {
83926
84001
 
83927
84002
  // src/file-activity.ts
83928
84003
  import { readFileSync as readFileSync26 } from "node:fs";
83929
- import { join as join29 } from "node:path";
84004
+ import { join as join30 } from "node:path";
83930
84005
  import { createHash as createHash17 } from "node:crypto";
83931
84006
 
83932
84007
  // ../../packages/privacy/src/patterns/credentials.ts
@@ -84679,7 +84754,7 @@ init_git_remote();
84679
84754
  init_src();
84680
84755
  import { execFile as execFile2 } from "node:child_process";
84681
84756
  import { readFileSync as readFileSync25 } from "node:fs";
84682
- import { join as join28 } from "node:path";
84757
+ import { join as join29 } from "node:path";
84683
84758
  var DEFAULT_MAX_TOKENS = 6e3;
84684
84759
  var FILE_LIST_CAP = 60;
84685
84760
  var DIFF_FILE_CAP = 40;
@@ -84718,7 +84793,7 @@ function pathAllowedByFloor(path3) {
84718
84793
  function loadRepoIgnore(root, extraPatterns = []) {
84719
84794
  let source = "";
84720
84795
  try {
84721
- source = readFileSync25(join28(root, ".errataignore"), "utf8");
84796
+ source = readFileSync25(join29(root, ".errataignore"), "utf8");
84722
84797
  } catch {
84723
84798
  source = "";
84724
84799
  }
@@ -85017,7 +85092,7 @@ function readActivityBranch(root) {
85017
85092
  try {
85018
85093
  const gitDir = resolveGitDir(root);
85019
85094
  if (!gitDir) return null;
85020
- const head2 = readFileSync26(join29(gitDir, "HEAD"), "utf8").trim();
85095
+ const head2 = readFileSync26(join30(gitDir, "HEAD"), "utf8").trim();
85021
85096
  const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
85022
85097
  return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
85023
85098
  } catch {
@@ -85181,7 +85256,7 @@ import {
85181
85256
  unlinkSync as unlinkSync4,
85182
85257
  writeFileSync as writeFileSync18
85183
85258
  } from "node:fs";
85184
- import { basename as basename7, join as join30 } from "node:path";
85259
+ import { basename as basename7, join as join31 } from "node:path";
85185
85260
  function skillFileName(id) {
85186
85261
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
85187
85262
  }
@@ -85212,7 +85287,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
85212
85287
  for (const s of res.skills) {
85213
85288
  const fileName = skillFileName(s.id);
85214
85289
  keep.add(fileName);
85215
- writeFileSync18(join30(paths.skillsDir, fileName), s.markdown, "utf8");
85290
+ writeFileSync18(join31(paths.skillsDir, fileName), s.markdown, "utf8");
85216
85291
  rows.push({
85217
85292
  id: s.id,
85218
85293
  title: s.title,
@@ -85225,7 +85300,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
85225
85300
  const fileName = skillFileName(p.id);
85226
85301
  if (keep.has(fileName)) continue;
85227
85302
  keep.add(fileName);
85228
- writeFileSync18(join30(paths.skillsDir, fileName), p.markdown, "utf8");
85303
+ writeFileSync18(join31(paths.skillsDir, fileName), p.markdown, "utf8");
85229
85304
  rows.push({
85230
85305
  id: p.id,
85231
85306
  title: p.title,
@@ -85239,7 +85314,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
85239
85314
  if (!f.endsWith(".md")) continue;
85240
85315
  if (keep.has(basename7(f))) continue;
85241
85316
  try {
85242
- unlinkSync4(join30(paths.skillsDir, f));
85317
+ unlinkSync4(join31(paths.skillsDir, f));
85243
85318
  pruned++;
85244
85319
  } catch {
85245
85320
  }
@@ -85266,13 +85341,13 @@ import {
85266
85341
  symlinkSync,
85267
85342
  writeFileSync as writeFileSync19
85268
85343
  } from "node:fs";
85269
- import { join as join31 } from "node:path";
85344
+ import { join as join32 } from "node:path";
85270
85345
  var SKILL_NS = "errata-";
85271
85346
  var HARNESS_SKILL_DIRS = [
85272
- { configDir: ".claude", skillsDir: join31(".claude", "skills") },
85347
+ { configDir: ".claude", skillsDir: join32(".claude", "skills") },
85273
85348
  // Cursor adopted the standard; its exact project dir is still moving — kept
85274
85349
  // best-effort and gated on `.cursor/` presence so we never create it blind.
85275
- { configDir: ".cursor", skillsDir: join31(".cursor", "skills") }
85350
+ { configDir: ".cursor", skillsDir: join32(".cursor", "skills") }
85276
85351
  ];
85277
85352
  function skillSlug(title, id) {
85278
85353
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -85322,7 +85397,7 @@ function reconcileNamespaced(dir, keep) {
85322
85397
  for (const name2 of readdirSync10(dir)) {
85323
85398
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
85324
85399
  try {
85325
- rmSync3(join31(dir, name2), { recursive: true, force: true });
85400
+ rmSync3(join32(dir, name2), { recursive: true, force: true });
85326
85401
  pruned++;
85327
85402
  } catch {
85328
85403
  }
@@ -85352,7 +85427,7 @@ function safeLstat(p) {
85352
85427
  }
85353
85428
  }
85354
85429
  function emitAndProjectSkills(root, skills) {
85355
- const agentsSkillsDir = join31(root, ".agents", "skills");
85430
+ const agentsSkillsDir = join32(root, ".agents", "skills");
85356
85431
  mkdirSync8(agentsSkillsDir, { recursive: true });
85357
85432
  const slugs = [];
85358
85433
  const keep = /* @__PURE__ */ new Set();
@@ -85369,9 +85444,9 @@ function emitAndProjectSkills(root, skills) {
85369
85444
  keep.add(slug2);
85370
85445
  slugs.push(slug2);
85371
85446
  const description = deriveDescription(s.title, s.layer, body2);
85372
- mkdirSync8(join31(agentsSkillsDir, slug2), { recursive: true });
85447
+ mkdirSync8(join32(agentsSkillsDir, slug2), { recursive: true });
85373
85448
  writeFileSync19(
85374
- join31(agentsSkillsDir, slug2, "SKILL.md"),
85449
+ join32(agentsSkillsDir, slug2, "SKILL.md"),
85375
85450
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
85376
85451
  "utf8"
85377
85452
  );
@@ -85380,11 +85455,11 @@ function emitAndProjectSkills(root, skills) {
85380
85455
  reconcileNamespaced(agentsSkillsDir, keep);
85381
85456
  let projected = 0;
85382
85457
  for (const h of HARNESS_SKILL_DIRS) {
85383
- if (!existsSync26(join31(root, h.configDir))) continue;
85384
- const dir = join31(root, h.skillsDir);
85458
+ if (!existsSync26(join32(root, h.configDir))) continue;
85459
+ const dir = join32(root, h.skillsDir);
85385
85460
  mkdirSync8(dir, { recursive: true });
85386
85461
  for (const slug2 of slugs) {
85387
- linkOrCopy(join31(dir, slug2), join31(agentsSkillsDir, slug2));
85462
+ linkOrCopy(join32(dir, slug2), join32(agentsSkillsDir, slug2));
85388
85463
  projected++;
85389
85464
  }
85390
85465
  reconcileNamespaced(dir, keep);
@@ -85401,7 +85476,7 @@ function emitInputsFromManifest(erretaDir, manifestPath) {
85401
85476
  title: s.title ?? s.id,
85402
85477
  layer: s.layer ?? "technique",
85403
85478
  confidence: s.confidence ?? 0,
85404
- bodyPath: join31(erretaDir, s.file)
85479
+ bodyPath: join32(erretaDir, s.file)
85405
85480
  }));
85406
85481
  } catch {
85407
85482
  return [];
@@ -85415,7 +85490,7 @@ var GITIGNORE_LINES = [
85415
85490
  ".cursor/skills/errata-*/"
85416
85491
  ];
85417
85492
  function ensureSkillGitignore(root) {
85418
- const path3 = join31(root, ".gitignore");
85493
+ const path3 = join32(root, ".gitignore");
85419
85494
  let current = "";
85420
85495
  try {
85421
85496
  current = existsSync26(path3) ? readFileSync28(path3, "utf8") : "";
@@ -85522,12 +85597,12 @@ init_profile2();
85522
85597
 
85523
85598
  // src/witness-queue.ts
85524
85599
  import { readFileSync as readFileSync29, renameSync as renameSync3, writeFileSync as writeFileSync20 } from "node:fs";
85525
- import { dirname as dirname12, join as join32 } from "node:path";
85600
+ import { dirname as dirname12, join as join33 } from "node:path";
85526
85601
  var WITNESS_QUEUE_CAP = 500;
85527
85602
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
85528
85603
  var WITNESS_MAX_ATTEMPTS = 5;
85529
85604
  function witnessQueuePath(workspaceConfigDir) {
85530
- return join32(workspaceConfigDir, "witness-queue.json");
85605
+ return join33(workspaceConfigDir, "witness-queue.json");
85531
85606
  }
85532
85607
  function loadWitnessQueueWithLosses(path3) {
85533
85608
  let raw2;
@@ -85545,7 +85620,7 @@ function loadWitnessQueueWithLosses(path3) {
85545
85620
  }
85546
85621
  function saveWitnessQueue(path3, queue) {
85547
85622
  try {
85548
- const tmp = join32(dirname12(path3), `.${Date.now()}.witness-queue.tmp`);
85623
+ const tmp = join33(dirname12(path3), `.${Date.now()}.witness-queue.tmp`);
85549
85624
  writeFileSync20(tmp, JSON.stringify(queue), "utf8");
85550
85625
  renameSync3(tmp, path3);
85551
85626
  } catch {
@@ -85856,7 +85931,7 @@ function maybeFlushDigests() {
85856
85931
  // src/liveness-watch.ts
85857
85932
  init_src5();
85858
85933
  import { readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
85859
- import { join as join34 } from "node:path";
85934
+ import { join as join35 } from "node:path";
85860
85935
 
85861
85936
  // src/loop-lag.ts
85862
85937
  var HEARTBEAT_MS = 500;
@@ -85987,7 +86062,7 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
85987
86062
  var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
85988
86063
  var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
85989
86064
  function alarmStatePath(configDir) {
85990
- return join34(configDir, "liveness-alarms.json");
86065
+ return join35(configDir, "liveness-alarms.json");
85991
86066
  }
85992
86067
  function loadAlarmState(path3) {
85993
86068
  try {
@@ -86227,7 +86302,7 @@ function createWatchBreaker(deps) {
86227
86302
  }
86228
86303
 
86229
86304
  // src/engine.ts
86230
- var DAEMON_VERSION = true ? "2.0.22-dev.4277" : "2.0.0-alpha.0";
86305
+ var DAEMON_VERSION = true ? "2.0.22-dev.4293" : "2.0.0-alpha.0";
86231
86306
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
86232
86307
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
86233
86308
  var GIT_OP_MUTE_MS = 4e3;
@@ -86239,7 +86314,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
86239
86314
  function appendIdentityAudit(path3, record2, line) {
86240
86315
  if (!record2.accepted && record2.score <= 0) return;
86241
86316
  try {
86242
- if (existsSync28(path3) && statSync9(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
86317
+ if (existsSync28(path3) && statSync10(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
86243
86318
  renameSync4(path3, `${path3}.1`);
86244
86319
  }
86245
86320
  appendFileSync4(path3, line);
@@ -86282,7 +86357,7 @@ function saveTurnCursors(path3, cursors, offsets) {
86282
86357
  function gitSourceWatchTargets(root) {
86283
86358
  const SOURCE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
86284
86359
  try {
86285
- const lsOut = execFileSync5("git", ["-C", root, "ls-files", "-z"], {
86360
+ const lsOut = execFileSync6("git", ["-C", root, "ls-files", "-z"], {
86286
86361
  encoding: "utf8",
86287
86362
  maxBuffer: 128 * 1024 * 1024,
86288
86363
  windowsHide: true,
@@ -86292,12 +86367,12 @@ function gitSourceWatchTargets(root) {
86292
86367
  if (sourceFiles.length === 0) throw new Error("no tracked source");
86293
86368
  let ignoredDirs = [];
86294
86369
  try {
86295
- const igOut = execFileSync5(
86370
+ const igOut = execFileSync6(
86296
86371
  "git",
86297
86372
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
86298
86373
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
86299
86374
  );
86300
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join35(root, d) + sep4));
86375
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join36(root, d) + sep4));
86301
86376
  } catch {
86302
86377
  }
86303
86378
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -86309,19 +86384,19 @@ function gitSourceWatchTargets(root) {
86309
86384
  if (!f.startsWith(prefix)) continue;
86310
86385
  const rest2 = f.slice(prefix.length);
86311
86386
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
86312
- else targets.add(join35(root, f));
86387
+ else targets.add(join36(root, f));
86313
86388
  }
86314
86389
  for (const c of children) {
86315
- if (IGNORED_PATH.test(join35(root, c) + sep4)) continue;
86390
+ if (IGNORED_PATH.test(join36(root, c) + sep4)) continue;
86316
86391
  if (hasIgnoredChild(c)) addUnder(c);
86317
- else targets.add(join35(root, c));
86392
+ else targets.add(join36(root, c));
86318
86393
  }
86319
86394
  };
86320
86395
  addUnder("");
86321
86396
  if (targets.size > 0) return [...targets];
86322
86397
  } catch {
86323
86398
  }
86324
- return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join35(root, String(e.name)) + sep4)).map((e) => join35(root, String(e.name)));
86399
+ return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join36(root, String(e.name)) + sep4)).map((e) => join36(root, String(e.name)));
86325
86400
  }
86326
86401
  function createWorkspaceEngine(opts) {
86327
86402
  const paths = workspacePaths(opts.workspaceRoot);
@@ -86413,7 +86488,7 @@ function createWorkspaceEngine(opts) {
86413
86488
  }
86414
86489
  let size = 0;
86415
86490
  try {
86416
- size = statSync9(path3).size;
86491
+ size = statSync10(path3).size;
86417
86492
  } catch {
86418
86493
  }
86419
86494
  lastActivityTs = Date.now();
@@ -86520,7 +86595,7 @@ function createWorkspaceEngine(opts) {
86520
86595
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
86521
86596
  let episodeId2;
86522
86597
  if (srcPaths.length > 0) {
86523
- const abs = srcPaths.map((p) => join35(opts.workspaceRoot, p));
86598
+ const abs = srcPaths.map((p) => join36(opts.workspaceRoot, p));
86524
86599
  try {
86525
86600
  const r = await runReindexPass(
86526
86601
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -86556,7 +86631,7 @@ function createWorkspaceEngine(opts) {
86556
86631
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
86557
86632
  );
86558
86633
  };
86559
- const gitDir = join35(opts.workspaceRoot, ".git");
86634
+ const gitDir = join36(opts.workspaceRoot, ".git");
86560
86635
  if (existsSync28(gitDir)) {
86561
86636
  stopGit = startGitSensor(gitDir, (ev) => {
86562
86637
  void handleGitEvent(ev).catch((err2) => {
@@ -86613,7 +86688,7 @@ function createWorkspaceEngine(opts) {
86613
86688
  },
86614
86689
  onAlarms: (alarms) => {
86615
86690
  toastLivenessAlarms(
86616
- sharedAlarmToastGate(join35(globalDir(), "liveness-toasts.json")),
86691
+ sharedAlarmToastGate(join36(globalDir(), "liveness-toasts.json")),
86617
86692
  { root: opts.workspaceRoot, name: profile.name },
86618
86693
  alarms,
86619
86694
  (body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
@@ -86630,7 +86705,7 @@ function createWorkspaceEngine(opts) {
86630
86705
  let subagentBase = null;
86631
86706
  let subagentBaseVersion = 0;
86632
86707
  const subagentRenders = /* @__PURE__ */ new Map();
86633
- const sessions = createSessionRegistry({ originsPath: join35(paths.configDir, "session-origins.json") });
86708
+ const sessions = createSessionRegistry({ originsPath: join36(paths.configDir, "session-origins.json") });
86634
86709
  const sessionRenders = /* @__PURE__ */ new Map();
86635
86710
  const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
86636
86711
  const toolRuns = createToolRunState();
@@ -86722,7 +86797,7 @@ function createWorkspaceEngine(opts) {
86722
86797
  const elicit = isEdgeElicitationEnabled();
86723
86798
  const snapOpts = {
86724
86799
  profile,
86725
- atCommit: readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0,
86800
+ atCommit: readGitRefState(join36(opts.workspaceRoot, ".git")).sha ?? void 0,
86726
86801
  reviewCount: pendingCount(paths),
86727
86802
  reviewUiUrl: opts.reviewUrl(),
86728
86803
  workingFile: workingFiles.mostRecent() ?? void 0,
@@ -86736,7 +86811,7 @@ function createWorkspaceEngine(opts) {
86736
86811
  );
86737
86812
  return null;
86738
86813
  }) : null;
86739
- if (snapOpts.atCommit !== (readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0)) {
86814
+ if (snapOpts.atCommit !== (readGitRefState(join36(opts.workspaceRoot, ".git")).sha ?? void 0)) {
86740
86815
  contextDirty = true;
86741
86816
  return;
86742
86817
  }
@@ -86782,10 +86857,10 @@ function createWorkspaceEngine(opts) {
86782
86857
  } catch (err2) {
86783
86858
  console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
86784
86859
  }
86785
- const target = join35(opts.workspaceRoot, "AGENTS.md");
86860
+ const target = join36(opts.workspaceRoot, "AGENTS.md");
86786
86861
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
86787
86862
  if (elicit) {
86788
- writePrimingHandles(join35(paths.configDir, "priming-handles.json"), [
86863
+ writePrimingHandles(join36(paths.configDir, "priming-handles.json"), [
86789
86864
  ...snapshot.recentProblems.map((r) => r.node),
86790
86865
  // Resolved-band handles: the ✓ problem AND its Solution are citable
86791
86866
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -87093,8 +87168,8 @@ function createWorkspaceEngine(opts) {
87093
87168
  const cached2 = subagentRenders.get(a.agentId);
87094
87169
  if (cached2?.key === key) return cached2.block;
87095
87170
  const elicit = isEdgeElicitationEnabled();
87096
- const handlesPath = join35(paths.configDir, "priming-handles.json");
87097
- const atCommit = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
87171
+ const handlesPath = join36(paths.configDir, "priming-handles.json");
87172
+ const atCommit = readGitRefState(join36(opts.workspaceRoot, ".git")).sha ?? void 0;
87098
87173
  const block = renderSubagentBlock({
87099
87174
  store,
87100
87175
  entry,
@@ -87148,7 +87223,7 @@ function createWorkspaceEngine(opts) {
87148
87223
  const cached2 = sessionRenders.get(sessionId);
87149
87224
  if (cached2?.key === key) return cached2.block;
87150
87225
  const elicit = isEdgeElicitationEnabled();
87151
- const atCommit = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
87226
+ const atCommit = readGitRefState(join36(opts.workspaceRoot, ".git")).sha ?? void 0;
87152
87227
  const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
87153
87228
  delete scoped.workingFile;
87154
87229
  if (workingFile) {
@@ -87189,7 +87264,7 @@ function createWorkspaceEngine(opts) {
87189
87264
  ]
87190
87265
  };
87191
87266
  if (elicit && block.handleNodes.length) {
87192
- writePrimingHandles(join35(paths.configDir, "priming-handles.json"), block.handleNodes);
87267
+ writePrimingHandles(join36(paths.configDir, "priming-handles.json"), block.handleNodes);
87193
87268
  }
87194
87269
  sessionRenders.delete(sessionId);
87195
87270
  sessionRenders.set(sessionId, { key, block });
@@ -87249,7 +87324,7 @@ function createWorkspaceEngine(opts) {
87249
87324
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
87250
87325
  });
87251
87326
  };
87252
- const turnCursorPath = join35(paths.configDir, "turn-cursors.json");
87327
+ const turnCursorPath = join36(paths.configDir, "turn-cursors.json");
87253
87328
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
87254
87329
  const turnOffset = loadTurnOffsets(turnCursorPath);
87255
87330
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -87311,7 +87386,7 @@ function createWorkspaceEngine(opts) {
87311
87386
  let processedTurns = 0;
87312
87387
  const seqAtStart = store.currentIngestSeq();
87313
87388
  const elicit = isEdgeElicitationEnabled();
87314
- const handleMap = elicit ? readPrimingHandles(join35(paths.configDir, "priming-handles.json")) : {};
87389
+ const handleMap = elicit ? readPrimingHandles(join36(paths.configDir, "priming-handles.json")) : {};
87315
87390
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
87316
87391
  const toRel = (abs) => {
87317
87392
  const p = abs.replace(/\\/g, "/");
@@ -87522,7 +87597,7 @@ function createWorkspaceEngine(opts) {
87522
87597
  let anchorReadFailed = false;
87523
87598
  if (p.location) {
87524
87599
  try {
87525
- fileText = readFileSync32(join35(opts.workspaceRoot, p.location.path), "utf8");
87600
+ fileText = readFileSync32(join36(opts.workspaceRoot, p.location.path), "utf8");
87526
87601
  } catch {
87527
87602
  anchorReadFailed = true;
87528
87603
  }
@@ -87684,10 +87759,10 @@ function createWorkspaceEngine(opts) {
87684
87759
  let enclosing = {};
87685
87760
  if (p.location?.line !== void 0) {
87686
87761
  try {
87687
- const headSha = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
87762
+ const headSha = readGitRefState(join36(opts.workspaceRoot, ".git")).sha ?? void 0;
87688
87763
  enclosing = {
87689
87764
  line: p.location.line,
87690
- fileText: readFileSync32(join35(opts.workspaceRoot, anchorPath), "utf8"),
87765
+ fileText: readFileSync32(join36(opts.workspaceRoot, anchorPath), "utf8"),
87691
87766
  ...headSha ? { headSha } : {}
87692
87767
  };
87693
87768
  } catch {
@@ -88526,7 +88601,7 @@ B: ${b}`,
88526
88601
  try {
88527
88602
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
88528
88603
  emitAndProjectSkills(opts.workspaceRoot, inputs);
88529
- writePrimingHandles(join35(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
88604
+ writePrimingHandles(join36(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
88530
88605
  } catch (err2) {
88531
88606
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
88532
88607
  }
@@ -89219,7 +89294,7 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
89219
89294
 
89220
89295
  // src/edge-park.ts
89221
89296
  import { readFileSync as readFileSync33, renameSync as renameSync5, writeFileSync as writeFileSync25 } from "node:fs";
89222
- import { dirname as dirname13, join as join36 } from "node:path";
89297
+ import { dirname as dirname13, join as join37 } from "node:path";
89223
89298
  var EDGE_PARK_CAP = 2e3;
89224
89299
  var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
89225
89300
  var EDGE_PARK_MAX_ATTEMPTS = 6;
@@ -89234,7 +89309,7 @@ function wireEdgeKey(from, type, to) {
89234
89309
  return JSON.stringify([from, type, to]);
89235
89310
  }
89236
89311
  function edgeParkPath(workspaceConfigDir, destinationKey) {
89237
- return join36(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
89312
+ return join37(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
89238
89313
  }
89239
89314
  function loadEdgePark(path3) {
89240
89315
  let raw2;
@@ -89250,7 +89325,7 @@ function loadEdgePark(path3) {
89250
89325
  }
89251
89326
  function saveEdgePark(path3, queue) {
89252
89327
  try {
89253
- const tmp = join36(dirname13(path3), `.${Date.now()}.edge-park.tmp`);
89328
+ const tmp = join37(dirname13(path3), `.${Date.now()}.edge-park.tmp`);
89254
89329
  writeFileSync25(tmp, JSON.stringify(queue), "utf8");
89255
89330
  renameSync5(tmp, path3);
89256
89331
  } catch {
@@ -89594,7 +89669,7 @@ init_reconcile();
89594
89669
  // src/lockfile-auto.ts
89595
89670
  init_src();
89596
89671
  import { existsSync as existsSync30, readFileSync as readFileSync34 } from "node:fs";
89597
- import { join as join37 } from "node:path";
89672
+ import { join as join38 } from "node:path";
89598
89673
 
89599
89674
  // src/package-index.ts
89600
89675
  init_src();
@@ -89746,7 +89821,7 @@ function runLockfilePass(opts) {
89746
89821
  { file: "package-lock.json", parse: parsePackageLockJson }
89747
89822
  ];
89748
89823
  for (const c of candidates) {
89749
- const p = join37(opts.root, c.file);
89824
+ const p = join38(opts.root, c.file);
89750
89825
  if (!existsSync30(p)) continue;
89751
89826
  let sbom;
89752
89827
  try {
@@ -89812,7 +89887,7 @@ init_session_registry();
89812
89887
 
89813
89888
  // src/public-symbols.ts
89814
89889
  import { readFileSync as readFileSync35, readdirSync as readdirSync12, existsSync as existsSync31 } from "node:fs";
89815
- import { join as join38 } from "node:path";
89890
+ import { join as join39 } from "node:path";
89816
89891
  var HEAD_BYTES = 8 * 1024;
89817
89892
  var INDEX_TTL_MS = 10 * 60 * 1e3;
89818
89893
  var MIN_SYMBOL_LEN = 4;
@@ -89845,7 +89920,7 @@ function bindingNames(clause) {
89845
89920
  function internalPackageNames(workspaceRoot) {
89846
89921
  const names = /* @__PURE__ */ new Set();
89847
89922
  const tryRead = (dir) => {
89848
- const pj = join38(dir, "package.json");
89923
+ const pj = join39(dir, "package.json");
89849
89924
  if (!existsSync31(pj)) return;
89850
89925
  try {
89851
89926
  const name2 = JSON.parse(readFileSync35(pj, "utf8")).name;
@@ -89855,10 +89930,10 @@ function internalPackageNames(workspaceRoot) {
89855
89930
  };
89856
89931
  tryRead(workspaceRoot);
89857
89932
  for (const group of ["packages", "apps"]) {
89858
- const groupDir = join38(workspaceRoot, group);
89933
+ const groupDir = join39(workspaceRoot, group);
89859
89934
  if (!existsSync31(groupDir)) continue;
89860
89935
  try {
89861
- for (const entry of readdirSync12(groupDir)) tryRead(join38(groupDir, entry));
89936
+ for (const entry of readdirSync12(groupDir)) tryRead(join39(groupDir, entry));
89862
89937
  } catch {
89863
89938
  }
89864
89939
  }
@@ -89897,7 +89972,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
89897
89972
  }
89898
89973
  const symbols = /* @__PURE__ */ new Set();
89899
89974
  for (const rel of files) {
89900
- const head2 = readHead(join38(workspaceRoot, rel));
89975
+ const head2 = readHead(join39(workspaceRoot, rel));
89901
89976
  if (!head2) continue;
89902
89977
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
89903
89978
  re.lastIndex = 0;
@@ -90882,7 +90957,7 @@ init_config();
90882
90957
 
90883
90958
  // src/update.ts
90884
90959
  import { spawn as spawn2 } from "node:child_process";
90885
- import { isAbsolute as isAbsolute6, join as join39 } from "node:path";
90960
+ import { isAbsolute as isAbsolute6, join as join40 } from "node:path";
90886
90961
  var PACKAGE_NAME = "@inerrata-corporation/errata";
90887
90962
  function parse3(v) {
90888
90963
  const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
@@ -91029,7 +91104,7 @@ async function runInstalledHookRefresh() {
91029
91104
  });
91030
91105
  if (!isAbsolute6(root)) return 1;
91031
91106
  return new Promise((resolve10) => {
91032
- const child = spawn2(process.execPath, [join39(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
91107
+ const child = spawn2(process.execPath, [join40(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
91033
91108
  windowsHide: true,
91034
91109
  stdio: "inherit",
91035
91110
  timeout: 3e4
@@ -91176,11 +91251,11 @@ function landCloudEdge(store, e, from, to) {
91176
91251
 
91177
91252
  // src/causal-edge-queue.ts
91178
91253
  import { readFileSync as readFileSync36, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
91179
- import { dirname as dirname14, join as join40 } from "node:path";
91254
+ import { dirname as dirname14, join as join41 } from "node:path";
91180
91255
  var CAUSAL_EDGE_QUEUE_CAP = 5e3;
91181
91256
  var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
91182
91257
  function causalEdgeQueuePath(workspaceConfigDir) {
91183
- return join40(workspaceConfigDir, "causal-edge-queue.json");
91258
+ return join41(workspaceConfigDir, "causal-edge-queue.json");
91184
91259
  }
91185
91260
  function parkedEdgeKey(e) {
91186
91261
  return `${e.from}|${e.type}|${e.to}`;
@@ -91199,7 +91274,7 @@ function loadCausalEdgeQueue(path3) {
91199
91274
  }
91200
91275
  function saveCausalEdgeQueue(path3, queue) {
91201
91276
  try {
91202
- const tmp = join40(dirname14(path3), `.${Date.now()}.causal-edge-queue.tmp`);
91277
+ const tmp = join41(dirname14(path3), `.${Date.now()}.causal-edge-queue.tmp`);
91203
91278
  writeFileSync26(tmp, JSON.stringify(queue), "utf8");
91204
91279
  renameSync6(tmp, path3);
91205
91280
  } catch {
@@ -91873,7 +91948,7 @@ init_src7();
91873
91948
  init_src();
91874
91949
  import { execFile as execFile6 } from "node:child_process";
91875
91950
  import { readFileSync as readFileSync37 } from "node:fs";
91876
- import { join as join41 } from "node:path";
91951
+ import { join as join42 } from "node:path";
91877
91952
  import { promisify as promisify5 } from "node:util";
91878
91953
 
91879
91954
  // src/history-walk.ts
@@ -92425,7 +92500,7 @@ async function defaultGit(root, args2) {
92425
92500
  function readIgnoreLines(root, profile) {
92426
92501
  let lines = [];
92427
92502
  try {
92428
- lines = readFileSync37(join41(root, ".errataignore"), "utf8").split("\n");
92503
+ lines = readFileSync37(join42(root, ".errataignore"), "utf8").split("\n");
92429
92504
  } catch {
92430
92505
  }
92431
92506
  return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
@@ -93000,9 +93075,9 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
93000
93075
  // src/link-flow.ts
93001
93076
  init_cloud_auth();
93002
93077
  import { createHash as createHash19 } from "node:crypto";
93003
- import { execFileSync as execFileSync6 } from "node:child_process";
93078
+ import { execFileSync as execFileSync7 } from "node:child_process";
93004
93079
  import { existsSync as existsSync32, writeFileSync as writeFileSync27 } from "node:fs";
93005
- import { join as join42 } from "node:path";
93080
+ import { join as join43 } from "node:path";
93006
93081
 
93007
93082
  // src/device-poll.ts
93008
93083
  var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
@@ -93389,7 +93464,7 @@ async function linkThroughConsole(opts) {
93389
93464
  function collectRepoFacts(root) {
93390
93465
  const git3 = (args2) => {
93391
93466
  try {
93392
- return execFileSync6("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
93467
+ return execFileSync7("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
93393
93468
  } catch {
93394
93469
  return null;
93395
93470
  }
@@ -93461,7 +93536,7 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
93461
93536
  delete nextProfile.projectLinkHold;
93462
93537
  let wroteIgnore = false;
93463
93538
  if (decision.writeIgnoreStarter !== false) {
93464
- const target = join42(root, ".errataignore");
93539
+ const target = join43(root, ".errataignore");
93465
93540
  if (!existsSync32(target)) {
93466
93541
  writeFileSync27(target, IGNORE_STARTER, "utf8");
93467
93542
  wroteIgnore = true;
@@ -93477,11 +93552,11 @@ init_registry();
93477
93552
  // src/adopt.ts
93478
93553
  init_git_remote();
93479
93554
  import { existsSync as existsSync33 } from "node:fs";
93480
- import { dirname as dirname15, join as join43 } from "node:path";
93555
+ import { dirname as dirname15, join as join44 } from "node:path";
93481
93556
  function findGitRoot(absPath) {
93482
93557
  let dir = absPath;
93483
93558
  for (let depth = 0; depth < 64; depth++) {
93484
- if (existsSync33(join43(dir, ".git"))) return dir;
93559
+ if (existsSync33(join44(dir, ".git"))) return dir;
93485
93560
  const parent = dirname15(dir);
93486
93561
  if (parent === dir) return null;
93487
93562
  dir = parent;
@@ -96105,15 +96180,15 @@ function shouldUseOAuthLogin(flags2, env2 = process.env) {
96105
96180
  import { spawnSync as spawnSync2 } from "node:child_process";
96106
96181
 
96107
96182
  // src/codex-runtime.ts
96108
- import { readdirSync as readdirSync13, statSync as statSync10 } from "node:fs";
96109
- import { join as join44 } from "node:path";
96183
+ import { readdirSync as readdirSync13, statSync as statSync11 } from "node:fs";
96184
+ import { join as join45 } from "node:path";
96110
96185
  function resolveCodexExecutable(options = {}) {
96111
96186
  const platform = options.platform ?? process.platform;
96112
96187
  const env2 = options.env ?? process.env;
96113
96188
  if (platform !== "win32") return "codex";
96114
96189
  const fileTime = (path3) => {
96115
96190
  try {
96116
- const s = statSync10(path3);
96191
+ const s = statSync11(path3);
96117
96192
  return s.isFile() ? s.mtimeMs : null;
96118
96193
  } catch {
96119
96194
  return null;
@@ -96121,13 +96196,13 @@ function resolveCodexExecutable(options = {}) {
96121
96196
  };
96122
96197
  for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
96123
96198
  if (!dir.trim()) continue;
96124
- const path3 = join44(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
96199
+ const path3 = join45(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
96125
96200
  if (fileTime(path3) !== null) return path3;
96126
96201
  }
96127
96202
  if (!env2["LOCALAPPDATA"]) return "codex";
96128
- const root = join44(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
96203
+ const root = join45(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
96129
96204
  try {
96130
- const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join44(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
96205
+ const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join45(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
96131
96206
  return candidates[0]?.path ?? "codex";
96132
96207
  } catch {
96133
96208
  return "codex";
@@ -96184,6 +96259,7 @@ async function diagnoseInstallation(cfg, dependencies) {
96184
96259
  checks.push(
96185
96260
  credentialType === "none" ? { id: "credential", status: "fail", detail: "No credential is installed" } : { id: "credential", status: "pass", detail: `${credentialType} credential is present` }
96186
96261
  );
96262
+ if (dependencies.credentialHygiene) checks.push(dependencies.credentialHygiene());
96187
96263
  const authorityMatches = !profile || profile.cloudUrl === cfg.cloudUrl && profile.apiKey === cfg.apiKey && profile.accessToken === cfg.accessToken && profile.refreshToken === cfg.refreshToken;
96188
96264
  checks.push(
96189
96265
  authorityMatches ? {
@@ -96264,16 +96340,219 @@ async function diagnoseInstallation(cfg, dependencies) {
96264
96340
  };
96265
96341
  }
96266
96342
 
96343
+ // src/credential-scan.ts
96344
+ import { readFileSync as readFileSync39, statSync as statSync12 } from "node:fs";
96345
+ import { homedir as homedir8 } from "node:os";
96346
+ import { join as join47 } from "node:path";
96347
+
96348
+ // src/claude-statusline.ts
96349
+ import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "node:fs";
96350
+ import { homedir as homedir7 } from "node:os";
96351
+ import { dirname as dirname16, join as join46 } from "node:path";
96352
+ var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
96353
+ import { readFileSync } from 'node:fs';
96354
+
96355
+ try {
96356
+ const port = Number(process.argv[2]);
96357
+ const route = process.argv[3] === 'subagents' ? '/api/statusline/subagents' : '/api/statusline';
96358
+ if (Number.isInteger(port) && port > 0 && port < 65536) {
96359
+ const response = await fetch('http://127.0.0.1:' + port + route, {
96360
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
96361
+ body: readFileSync(0, 'utf8') || '{}', signal: AbortSignal.timeout(800),
96362
+ });
96363
+ if (response.ok) process.stdout.write(await response.text());
96364
+ }
96365
+ } catch { /* An unavailable daemon leaves the status line empty. */ }
96366
+ `;
96367
+ var STATUSLINE_RELAY_FILE = "errata-statusline.mjs";
96368
+ function buildStatusLine(port, nodePath, relayPath) {
96369
+ return { type: "command", command: relayCommand(port, nodePath, relayPath), padding: 0 };
96370
+ }
96371
+ function buildSubagentStatusLine(port, nodePath, relayPath) {
96372
+ return { type: "command", command: `${relayCommand(port, nodePath, relayPath)} subagents` };
96373
+ }
96374
+ function relayCommand(port, nodePath, relayPath) {
96375
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid status line port");
96376
+ const q = (p) => {
96377
+ if (/["$`\r\n]/.test(p)) throw new Error("Unsupported character in status line path");
96378
+ return `"${p.replace(/\\/g, "/")}"`;
96379
+ };
96380
+ return `${q(nodePath)} ${q(relayPath)} ${port}`;
96381
+ }
96382
+ function isErrataStatusLine(value) {
96383
+ return !!value && typeof value === "object" && typeof value["command"] === "string" && value["command"].includes(STATUSLINE_RELAY_FILE);
96384
+ }
96385
+ function removeProjectStatusLine(settings) {
96386
+ let removed = false;
96387
+ for (const key of ["statusLine", "subagentStatusLine"]) {
96388
+ if (!isErrataStatusLine(settings[key])) continue;
96389
+ delete settings[key];
96390
+ removed = true;
96391
+ }
96392
+ return removed;
96393
+ }
96394
+ function isSameInstall(value, relay) {
96395
+ const command = value["command"].replace(/\\/g, "/").toLowerCase();
96396
+ return command.includes(relay.replace(/\\/g, "/").toLowerCase());
96397
+ }
96398
+ function userClaudeSettingsPath() {
96399
+ const base = process.env["CLAUDE_CONFIG_DIR"] ?? join46(homedir7(), ".claude");
96400
+ return join46(base, "settings.json");
96401
+ }
96402
+ function ensureUserStatusLine(opts) {
96403
+ const env2 = opts.env ?? process.env;
96404
+ const off2 = (env2["ERRATA_STATUSLINE"] ?? "").trim().toLowerCase();
96405
+ if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
96406
+ const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
96407
+ let settings = {};
96408
+ if (existsSync35(settingsPath)) {
96409
+ try {
96410
+ const parsed = JSON.parse(readFileSync38(settingsPath, "utf8"));
96411
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
96412
+ settings = parsed;
96413
+ } catch {
96414
+ return "unreadable";
96415
+ }
96416
+ }
96417
+ const relay = join46(opts.relayDir, STATUSLINE_RELAY_FILE);
96418
+ const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
96419
+ const ownMain = keep(settings["statusLine"]);
96420
+ const ownRows = keep(settings["subagentStatusLine"]);
96421
+ if (ownMain && ownRows) return "kept-own";
96422
+ mkdirSync9(opts.relayDir, { recursive: true });
96423
+ if (!existsSync35(relay) || readFileSync38(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
96424
+ writeFileSync29(relay, STATUSLINE_RELAY_SOURCE, "utf8");
96425
+ }
96426
+ const nodePath = opts.nodePath ?? process.execPath;
96427
+ const next = {
96428
+ ...ownMain ? {} : { statusLine: buildStatusLine(opts.port, nodePath, relay) },
96429
+ ...ownRows ? {} : { subagentStatusLine: buildSubagentStatusLine(opts.port, nodePath, relay) }
96430
+ };
96431
+ if (Object.entries(next).every(([k, v]) => JSON.stringify(settings[k]) === JSON.stringify(v))) {
96432
+ return ownMain ? "kept-own" : "unchanged";
96433
+ }
96434
+ Object.assign(settings, next);
96435
+ mkdirSync9(dirname16(settingsPath), { recursive: true });
96436
+ writeFileSync29(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
96437
+ return "installed";
96438
+ }
96439
+ function describeStatusLineOutcome(outcome) {
96440
+ switch (outcome) {
96441
+ case "installed":
96442
+ return "status line: errata recall card in colour (user settings; ERRATA_STATUSLINE=off opts out)";
96443
+ case "unchanged":
96444
+ return "status line: errata recall card already set up";
96445
+ case "kept-own":
96446
+ return "status line: kept your own \u2014 errata's recall card shows inline only";
96447
+ case "disabled":
96448
+ return "status line: skipped (ERRATA_STATUSLINE=off)";
96449
+ case "unreadable":
96450
+ return "status line: skipped \u2014 ~/.claude/settings.json is not valid JSON";
96451
+ }
96452
+ }
96453
+
96454
+ // src/credential-scan.ts
96455
+ var KEY_RE = /(?<![A-Za-z0-9_-])(?:errk_[A-Za-z0-9_-]{32,}|err_[a-f0-9]{6}_[a-f0-9]{32})(?![A-Za-z0-9_-])/;
96456
+ var ENV_ASSIGNMENT_RE = /(?:^|[\s{,"'])INERRATA_API_KEY["']?\s*[:=]\s*["']([^"']*)["']/;
96457
+ function isReference(value) {
96458
+ return value.trim() === "" || /[$<{]/.test(value);
96459
+ }
96460
+ var MAX_SCAN_BYTES = 8 * 1024 * 1024;
96461
+ var MAX_LISTED_FINDINGS = 5;
96462
+ function findCredentialLines(text) {
96463
+ const lines = [];
96464
+ text.split(/\r?\n/).forEach((line, index) => {
96465
+ if (KEY_RE.test(line)) {
96466
+ lines.push(index + 1);
96467
+ return;
96468
+ }
96469
+ const assignment = ENV_ASSIGNMENT_RE.exec(line);
96470
+ if (assignment && !isReference(assignment[1])) lines.push(index + 1);
96471
+ });
96472
+ return lines;
96473
+ }
96474
+ function harnessConfigPaths(root) {
96475
+ const env2 = process.env;
96476
+ const home = homedir8();
96477
+ const codexHome = env2["CODEX_HOME"] || join47(home, ".codex");
96478
+ const geminiHome = join47(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
96479
+ return [
96480
+ // Claude Code: user settings, `claude mcp add` (local/user scope), project.
96481
+ userClaudeSettingsPath(),
96482
+ join47(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
96483
+ join47(root, ".claude", "settings.json"),
96484
+ join47(root, ".claude", "settings.local.json"),
96485
+ join47(root, ".mcp.json"),
96486
+ // Codex
96487
+ join47(codexHome, "config.toml"),
96488
+ join47(root, ".codex", "config.toml"),
96489
+ // Gemini CLI
96490
+ join47(geminiHome, "settings.json"),
96491
+ join47(root, ".gemini", "settings.json"),
96492
+ // Cursor
96493
+ join47(home, ".cursor", "mcp.json"),
96494
+ join47(root, ".cursor", "mcp.json"),
96495
+ // VS Code (user profile mcp.json + workspace)
96496
+ join47(vscodeUserDir(home, env2), "mcp.json"),
96497
+ join47(root, ".vscode", "mcp.json"),
96498
+ // OpenCode (XDG on every platform; the daemon's installer writes the project one)
96499
+ join47(env2["XDG_CONFIG_HOME"] ?? join47(home, ".config"), "opencode", "opencode.json"),
96500
+ join47(root, "opencode.json")
96501
+ ];
96502
+ }
96503
+ function vscodeUserDir(home, env2) {
96504
+ if (process.platform === "win32") return join47(env2["APPDATA"] ?? join47(home, "AppData", "Roaming"), "Code", "User");
96505
+ if (process.platform === "darwin") return join47(home, "Library", "Application Support", "Code", "User");
96506
+ return join47(env2["XDG_CONFIG_HOME"] ?? join47(home, ".config"), "Code", "User");
96507
+ }
96508
+ function scanHarnessConfigs(paths, read2 = readBounded) {
96509
+ const findings = [];
96510
+ let scanned = 0;
96511
+ for (const file2 of new Set(paths)) {
96512
+ const text = read2(file2);
96513
+ if (text === null) continue;
96514
+ scanned++;
96515
+ for (const line of findCredentialLines(text)) findings.push({ file: file2, line });
96516
+ }
96517
+ return { scanned, findings };
96518
+ }
96519
+ function readBounded(path3) {
96520
+ try {
96521
+ const stat4 = statSync12(path3);
96522
+ if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
96523
+ return readFileSync39(path3, "utf8");
96524
+ } catch {
96525
+ return null;
96526
+ }
96527
+ }
96528
+ function credentialHygieneCheck(scan2) {
96529
+ if (scan2.findings.length === 0) {
96530
+ return {
96531
+ id: "credential_hygiene",
96532
+ status: "pass",
96533
+ detail: `No plaintext errata credentials in ${scan2.scanned} harness config file(s)`
96534
+ };
96535
+ }
96536
+ const shown = scan2.findings.slice(0, MAX_LISTED_FINDINGS).map((finding) => `${finding.file}:${finding.line}`);
96537
+ const more = scan2.findings.length - shown.length;
96538
+ const where = shown.join(", ") + (more > 0 ? ` (+${more} more)` : "");
96539
+ return {
96540
+ id: "credential_hygiene",
96541
+ status: "warn",
96542
+ detail: `Plaintext errata credential in ${where} \u2014 remove it, revoke that key in the console, and run errata login (or reference an environment variable set outside committed/synced settings)`
96543
+ };
96544
+ }
96545
+
96267
96546
  // src/codex-doctor.ts
96268
96547
  import { spawn as spawn4 } from "node:child_process";
96269
- import { readFileSync as readFileSync39, statSync as statSync11 } from "node:fs";
96270
- import { join as join46 } from "node:path";
96548
+ import { readFileSync as readFileSync41, statSync as statSync13 } from "node:fs";
96549
+ import { join as join49 } from "node:path";
96271
96550
  import { createInterface } from "node:readline";
96272
96551
 
96273
96552
  // src/codex-hooks.ts
96274
- import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync38, renameSync as renameSync7, unlinkSync as unlinkSync5, writeFileSync as writeFileSync29 } from "node:fs";
96275
- import { homedir as homedir7 } from "node:os";
96276
- import { join as join45 } from "node:path";
96553
+ import { existsSync as existsSync36, mkdirSync as mkdirSync10, readFileSync as readFileSync40, renameSync as renameSync7, unlinkSync as unlinkSync5, writeFileSync as writeFileSync30 } from "node:fs";
96554
+ import { homedir as homedir9 } from "node:os";
96555
+ import { join as join48 } from "node:path";
96277
96556
 
96278
96557
  // src/hook-commands.ts
96279
96558
  function hookCurlCommand(port, path3 = "/api/hook") {
@@ -96477,34 +96756,34 @@ function buildCodexRelaySource(workspaceRoot) {
96477
96756
  init_checkout_root();
96478
96757
  var CODEX_HOOK_REVIEW_HELP = "Codex desktop: Settings > Hooks, select this project, expand each event and Trust the Errata hook. CLI users can use /hooks.";
96479
96758
  function writeRelay(file2, source) {
96480
- if (existsSync35(file2) && readFileSync38(file2, "utf8") === source) return;
96759
+ if (existsSync36(file2) && readFileSync40(file2, "utf8") === source) return;
96481
96760
  const temp = `${file2}.${process.pid}.tmp`;
96482
96761
  try {
96483
- writeFileSync29(temp, source, { encoding: "utf8", mode: 384 });
96762
+ writeFileSync30(temp, source, { encoding: "utf8", mode: 384 });
96484
96763
  renameSync7(temp, file2);
96485
96764
  } finally {
96486
- if (existsSync35(temp)) unlinkSync5(temp);
96765
+ if (existsSync36(temp)) unlinkSync5(temp);
96487
96766
  }
96488
96767
  }
96489
96768
  function refreshCodexRelay(root) {
96490
- const config2 = join45(root, ".codex", "config.toml");
96491
- if (!existsSync35(config2)) return "absent";
96492
- const existing = readFileSync38(config2, "utf8");
96769
+ const config2 = join48(root, ".codex", "config.toml");
96770
+ if (!existsSync36(config2)) return "absent";
96771
+ const existing = readFileSync40(config2, "utf8");
96493
96772
  if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
96494
96773
  replaceCodexHooks(existing, "");
96495
- const relay = join45(root, ".codex", "hooks", "errata-relay.mjs");
96496
- const prior = existsSync35(relay) ? readFileSync38(relay, "utf8") : "";
96774
+ const relay = join48(root, ".codex", "hooks", "errata-relay.mjs");
96775
+ const prior = existsSync36(relay) ? readFileSync40(relay, "utf8") : "";
96497
96776
  if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
96498
96777
  throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
96499
96778
  }
96500
96779
  const source = buildCodexRelaySource(checkoutRootOf(root));
96501
96780
  if (prior === source) return "current";
96502
- mkdirSync9(join45(root, ".codex", "hooks"), { recursive: true });
96781
+ mkdirSync10(join48(root, ".codex", "hooks"), { recursive: true });
96503
96782
  writeRelay(relay, source);
96504
96783
  return "updated";
96505
96784
  }
96506
- function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join45(homedir7(), ".codex")) {
96507
- return existsSync35(join45(root, ".codex")) || existsSync35(codexHome);
96785
+ function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join48(homedir9(), ".codex")) {
96786
+ return existsSync36(join48(root, ".codex")) || existsSync36(codexHome);
96508
96787
  }
96509
96788
  function replaceCodexHooks(existing, block) {
96510
96789
  const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
@@ -96520,14 +96799,14 @@ function replaceCodexHooks(existing, block) {
96520
96799
  return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
96521
96800
  }
96522
96801
  function writeCodexHooks(root, port, nodePath = process.execPath) {
96523
- const dir = join45(root, ".codex");
96524
- const file2 = join45(dir, "config.toml");
96525
- const relay = join45(dir, "hooks", "errata-relay.mjs");
96802
+ const dir = join48(root, ".codex");
96803
+ const file2 = join48(dir, "config.toml");
96804
+ const relay = join48(dir, "hooks", "errata-relay.mjs");
96526
96805
  const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
96527
- const final = replaceCodexHooks(existsSync35(file2) ? readFileSync38(file2, "utf8") : "", block);
96528
- mkdirSync9(join45(dir, "hooks"), { recursive: true });
96806
+ const final = replaceCodexHooks(existsSync36(file2) ? readFileSync40(file2, "utf8") : "", block);
96807
+ mkdirSync10(join48(dir, "hooks"), { recursive: true });
96529
96808
  writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
96530
- if (!existsSync35(file2) || readFileSync38(file2, "utf8") !== final) writeFileSync29(file2, final, "utf8");
96809
+ if (!existsSync36(file2) || readFileSync40(file2, "utf8") !== final) writeFileSync30(file2, final, "utf8");
96531
96810
  return file2;
96532
96811
  }
96533
96812
 
@@ -96536,7 +96815,7 @@ init_checkout_root();
96536
96815
  function inspectCodexRelay(cwd) {
96537
96816
  const root = nearestGitRoot(cwd) ?? cwd;
96538
96817
  try {
96539
- const source = readFileSync39(join46(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
96818
+ const source = readFileSync41(join49(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
96540
96819
  if (source === buildCodexRelaySource(checkoutRootOf(root))) {
96541
96820
  return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
96542
96821
  }
@@ -96547,8 +96826,8 @@ function inspectCodexRelay(cwd) {
96547
96826
  function inspectCodexContext(cwd) {
96548
96827
  const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
96549
96828
  try {
96550
- const file2 = join46(root, ".errata", "context.md");
96551
- if (statSync11(file2).size <= 128 * 1024 && readFileSync39(file2, "utf8").trim()) {
96829
+ const file2 = join49(root, ".errata", "context.md");
96830
+ if (statSync13(file2).size <= 128 * 1024 && readFileSync41(file2, "utf8").trim()) {
96552
96831
  return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
96553
96832
  }
96554
96833
  } catch {
@@ -96726,9 +97005,9 @@ function consolidationGapMs(lastPassMs, policy) {
96726
97005
 
96727
97006
  // src/codex-context-plugin.ts
96728
97007
  import { createHash as createHash20 } from "node:crypto";
96729
- import { cpSync as cpSync2, existsSync as existsSync36, mkdirSync as mkdirSync10, readFileSync as readFileSync40, renameSync as renameSync8, writeFileSync as writeFileSync30 } from "node:fs";
96730
- import { homedir as homedir8 } from "node:os";
96731
- import { join as join47 } from "node:path";
97008
+ import { cpSync as cpSync2, existsSync as existsSync37, mkdirSync as mkdirSync11, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync31 } from "node:fs";
97009
+ import { homedir as homedir10 } from "node:os";
97010
+ import { join as join50 } from "node:path";
96732
97011
  import { fileURLToPath as fileURLToPath2 } from "node:url";
96733
97012
 
96734
97013
  // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
@@ -97426,23 +97705,23 @@ var NAME = "errata-context";
97426
97705
  var PREFIX2 = `./.errata/plugins/${NAME}/`;
97427
97706
  var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
97428
97707
  function readText(file2) {
97429
- return existsSync36(file2) ? readFileSync40(file2, "utf8") : "";
97708
+ return existsSync37(file2) ? readFileSync42(file2, "utf8") : "";
97430
97709
  }
97431
97710
  function writeChanged(file2, content) {
97432
97711
  if (readText(file2) === content) return;
97433
97712
  const temp = `${file2}.${process.pid}.tmp`;
97434
- writeFileSync30(temp, content, "utf8");
97713
+ writeFileSync31(temp, content, "utf8");
97435
97714
  renameSync8(temp, file2);
97436
97715
  }
97437
97716
  function bundledContextPlugin() {
97438
97717
  const packaged = fileURLToPath2(new URL("./resources/context-plugin/", import.meta.url));
97439
- if (existsSync36(join47(packaged, ".codex-plugin/plugin.json"))) return packaged;
97718
+ if (existsSync37(join50(packaged, ".codex-plugin/plugin.json"))) return packaged;
97440
97719
  return fileURLToPath2(new URL("../dist/resources/context-plugin/", import.meta.url));
97441
97720
  }
97442
97721
  function refreshCodexContextPlugin(root) {
97443
- const file2 = join47(root, ".agents", "plugins", "marketplace.json");
97444
- if (!existsSync36(file2)) return false;
97445
- const marketplace = JSON.parse(readFileSync40(file2, "utf8"));
97722
+ const file2 = join50(root, ".agents", "plugins", "marketplace.json");
97723
+ if (!existsSync37(file2)) return false;
97724
+ const marketplace = JSON.parse(readFileSync42(file2, "utf8"));
97446
97725
  const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
97447
97726
  const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
97448
97727
  if (!entry) return false;
@@ -97453,24 +97732,24 @@ function refreshCodexContextPlugin(root) {
97453
97732
  function installCodexContextPlugin(root, options = {}) {
97454
97733
  const bundle = options.bundle ?? bundledContextPlugin();
97455
97734
  const manifest = JSON.parse(
97456
- readFileSync40(join47(bundle, ".codex-plugin/plugin.json"), "utf8")
97735
+ readFileSync42(join50(bundle, ".codex-plugin/plugin.json"), "utf8")
97457
97736
  );
97458
97737
  if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
97459
97738
  throw new Error("Invalid bundled Errata Context manifest.");
97460
97739
  }
97461
- const checksums = readFileSync40(join47(bundle, "SHA256SUMS"), "utf8");
97740
+ const checksums = readFileSync42(join50(bundle, "SHA256SUMS"), "utf8");
97462
97741
  for (const line of checksums.trim().split("\n")) {
97463
97742
  const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
97464
97743
  if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
97465
97744
  throw new Error("Invalid bundled Errata Context checksum manifest.");
97466
97745
  }
97467
- const actual = createHash20("sha256").update(readFileSync40(join47(bundle, match2[2]))).digest("hex");
97746
+ const actual = createHash20("sha256").update(readFileSync42(join50(bundle, match2[2]))).digest("hex");
97468
97747
  if (actual !== match2[1])
97469
97748
  throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
97470
97749
  }
97471
97750
  const release = `${manifest.version}-${createHash20("sha256").update(checksums).digest("hex").slice(0, 12)}`;
97472
- const plugin = join47(root, ".errata", "plugins", NAME, release);
97473
- const marketplaceFile = join47(root, ".agents", "plugins", "marketplace.json");
97751
+ const plugin = join50(root, ".errata", "plugins", NAME, release);
97752
+ const marketplaceFile = join50(root, ".agents", "plugins", "marketplace.json");
97474
97753
  const priorMarketplace = readText(marketplaceFile);
97475
97754
  const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
97476
97755
  name: "errata-local",
@@ -97491,12 +97770,12 @@ function installCodexContextPlugin(root, options = {}) {
97491
97770
  );
97492
97771
  }
97493
97772
  const key = `${NAME}@${marketplace.name}`;
97494
- const configFile = join47(root, ".codex", "config.toml");
97773
+ const configFile = join50(root, ".codex", "config.toml");
97495
97774
  const config2 = readText(configFile);
97496
97775
  const parsed = parse4(config2);
97497
97776
  const plugins = object2(parsed.plugins);
97498
- const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join47(homedir8(), ".codex");
97499
- const globalPlugins = object2(parse4(readText(join47(codexHome, "config.toml"))).plugins);
97777
+ const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join50(homedir10(), ".codex");
97778
+ const globalPlugins = object2(parse4(readText(join50(codexHome, "config.toml"))).plugins);
97500
97779
  const disabledGlobally = Object.entries(globalPlugins).some(
97501
97780
  ([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
97502
97781
  );
@@ -97517,16 +97796,16 @@ enabled = ${enabled}
97517
97796
  category: prior?.category ?? "Productivity"
97518
97797
  };
97519
97798
  marketplace.plugins = [...entries.filter((item2) => item2.name !== NAME), entry];
97520
- mkdirSync10(plugin, { recursive: true });
97799
+ mkdirSync11(plugin, { recursive: true });
97521
97800
  cpSync2(bundle, plugin, { recursive: true });
97522
97801
  writeChanged(
97523
- join47(plugin, ".mcp.json"),
97802
+ join50(plugin, ".mcp.json"),
97524
97803
  JSON.stringify(
97525
97804
  {
97526
97805
  mcpServers: {
97527
97806
  errata_context: {
97528
97807
  command: options.nodePath ?? process.execPath,
97529
- args: [join47(plugin, "dist", "mcp-server.mjs")],
97808
+ args: [join50(plugin, "dist", "mcp-server.mjs")],
97530
97809
  env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
97531
97810
  }
97532
97811
  }
@@ -97535,8 +97814,8 @@ enabled = ${enabled}
97535
97814
  2
97536
97815
  ) + "\n"
97537
97816
  );
97538
- mkdirSync10(join47(root, ".agents", "plugins"), { recursive: true });
97539
- mkdirSync10(join47(root, ".codex"), { recursive: true });
97817
+ mkdirSync11(join50(root, ".agents", "plugins"), { recursive: true });
97818
+ mkdirSync11(join50(root, ".codex"), { recursive: true });
97540
97819
  writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
97541
97820
  writeChanged(configFile, nextConfig);
97542
97821
  return { plugin, enabled, marketplace: marketplaceFile };
@@ -97544,16 +97823,16 @@ enabled = ${enabled}
97544
97823
 
97545
97824
  // src/codex-hook-refresh.ts
97546
97825
  init_checkout_root();
97547
- import { existsSync as existsSync37, readdirSync as readdirSync14, readFileSync as readFileSync41 } from "node:fs";
97548
- import { dirname as dirname16, join as join48, resolve as resolve8 } from "node:path";
97826
+ import { existsSync as existsSync38, readdirSync as readdirSync14, readFileSync as readFileSync43 } from "node:fs";
97827
+ import { dirname as dirname17, join as join51, resolve as resolve8 } from "node:path";
97549
97828
  init_registry();
97550
97829
  function codexHookRoots(roots) {
97551
97830
  const found = new Set(roots.map((root) => resolve8(root)));
97552
97831
  for (const root of [...found]) {
97553
97832
  const main2 = mainCheckoutOfWorktree(root) ?? root;
97554
97833
  found.add(main2);
97555
- const dir = join48(main2, ".git", "worktrees");
97556
- if (!existsSync37(dir)) continue;
97834
+ const dir = join51(main2, ".git", "worktrees");
97835
+ if (!existsSync38(dir)) continue;
97557
97836
  let names;
97558
97837
  try {
97559
97838
  names = readdirSync14(dir);
@@ -97562,7 +97841,7 @@ function codexHookRoots(roots) {
97562
97841
  }
97563
97842
  for (const name2 of names) {
97564
97843
  try {
97565
- const checkout = dirname16(readFileSync41(join48(dir, name2, "gitdir"), "utf8").trim());
97844
+ const checkout = dirname17(readFileSync43(join51(dir, name2, "gitdir"), "utf8").trim());
97566
97845
  if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
97567
97846
  } catch {
97568
97847
  }
@@ -97583,116 +97862,10 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
97583
97862
  return results;
97584
97863
  }
97585
97864
 
97586
- // src/claude-statusline.ts
97587
- import { existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync42, writeFileSync as writeFileSync31 } from "node:fs";
97588
- import { homedir as homedir9 } from "node:os";
97589
- import { dirname as dirname17, join as join49 } from "node:path";
97590
- var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
97591
- import { readFileSync } from 'node:fs';
97592
-
97593
- try {
97594
- const port = Number(process.argv[2]);
97595
- const route = process.argv[3] === 'subagents' ? '/api/statusline/subagents' : '/api/statusline';
97596
- if (Number.isInteger(port) && port > 0 && port < 65536) {
97597
- const response = await fetch('http://127.0.0.1:' + port + route, {
97598
- method: 'POST', headers: { 'Content-Type': 'application/json' },
97599
- body: readFileSync(0, 'utf8') || '{}', signal: AbortSignal.timeout(800),
97600
- });
97601
- if (response.ok) process.stdout.write(await response.text());
97602
- }
97603
- } catch { /* An unavailable daemon leaves the status line empty. */ }
97604
- `;
97605
- var STATUSLINE_RELAY_FILE = "errata-statusline.mjs";
97606
- function buildStatusLine(port, nodePath, relayPath) {
97607
- return { type: "command", command: relayCommand(port, nodePath, relayPath), padding: 0 };
97608
- }
97609
- function buildSubagentStatusLine(port, nodePath, relayPath) {
97610
- return { type: "command", command: `${relayCommand(port, nodePath, relayPath)} subagents` };
97611
- }
97612
- function relayCommand(port, nodePath, relayPath) {
97613
- if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid status line port");
97614
- const q = (p) => {
97615
- if (/["$`\r\n]/.test(p)) throw new Error("Unsupported character in status line path");
97616
- return `"${p.replace(/\\/g, "/")}"`;
97617
- };
97618
- return `${q(nodePath)} ${q(relayPath)} ${port}`;
97619
- }
97620
- function isErrataStatusLine(value) {
97621
- return !!value && typeof value === "object" && typeof value["command"] === "string" && value["command"].includes(STATUSLINE_RELAY_FILE);
97622
- }
97623
- function removeProjectStatusLine(settings) {
97624
- let removed = false;
97625
- for (const key of ["statusLine", "subagentStatusLine"]) {
97626
- if (!isErrataStatusLine(settings[key])) continue;
97627
- delete settings[key];
97628
- removed = true;
97629
- }
97630
- return removed;
97631
- }
97632
- function isSameInstall(value, relay) {
97633
- const command = value["command"].replace(/\\/g, "/").toLowerCase();
97634
- return command.includes(relay.replace(/\\/g, "/").toLowerCase());
97635
- }
97636
- function userClaudeSettingsPath() {
97637
- const base = process.env["CLAUDE_CONFIG_DIR"] ?? join49(homedir9(), ".claude");
97638
- return join49(base, "settings.json");
97639
- }
97640
- function ensureUserStatusLine(opts) {
97641
- const env2 = opts.env ?? process.env;
97642
- const off2 = (env2["ERRATA_STATUSLINE"] ?? "").trim().toLowerCase();
97643
- if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
97644
- const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
97645
- let settings = {};
97646
- if (existsSync38(settingsPath)) {
97647
- try {
97648
- const parsed = JSON.parse(readFileSync42(settingsPath, "utf8"));
97649
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
97650
- settings = parsed;
97651
- } catch {
97652
- return "unreadable";
97653
- }
97654
- }
97655
- const relay = join49(opts.relayDir, STATUSLINE_RELAY_FILE);
97656
- const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
97657
- const ownMain = keep(settings["statusLine"]);
97658
- const ownRows = keep(settings["subagentStatusLine"]);
97659
- if (ownMain && ownRows) return "kept-own";
97660
- mkdirSync11(opts.relayDir, { recursive: true });
97661
- if (!existsSync38(relay) || readFileSync42(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
97662
- writeFileSync31(relay, STATUSLINE_RELAY_SOURCE, "utf8");
97663
- }
97664
- const nodePath = opts.nodePath ?? process.execPath;
97665
- const next = {
97666
- ...ownMain ? {} : { statusLine: buildStatusLine(opts.port, nodePath, relay) },
97667
- ...ownRows ? {} : { subagentStatusLine: buildSubagentStatusLine(opts.port, nodePath, relay) }
97668
- };
97669
- if (Object.entries(next).every(([k, v]) => JSON.stringify(settings[k]) === JSON.stringify(v))) {
97670
- return ownMain ? "kept-own" : "unchanged";
97671
- }
97672
- Object.assign(settings, next);
97673
- mkdirSync11(dirname17(settingsPath), { recursive: true });
97674
- writeFileSync31(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
97675
- return "installed";
97676
- }
97677
- function describeStatusLineOutcome(outcome) {
97678
- switch (outcome) {
97679
- case "installed":
97680
- return "status line: errata recall card in colour (user settings; ERRATA_STATUSLINE=off opts out)";
97681
- case "unchanged":
97682
- return "status line: errata recall card already set up";
97683
- case "kept-own":
97684
- return "status line: kept your own \u2014 errata's recall card shows inline only";
97685
- case "disabled":
97686
- return "status line: skipped (ERRATA_STATUSLINE=off)";
97687
- case "unreadable":
97688
- return "status line: skipped \u2014 ~/.claude/settings.json is not valid JSON";
97689
- }
97690
- }
97691
-
97692
97865
  // src/claude-mods.ts
97693
97866
  import { createHash as createHash21 } from "node:crypto";
97694
- import { cpSync as cpSync3, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync43, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync12, writeFileSync as writeFileSync32 } from "node:fs";
97695
- import { delimiter as delimiter2, dirname as dirname18, join as join50, relative as relative8, resolve as resolve9, sep as sep5 } from "node:path";
97867
+ import { cpSync as cpSync3, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync44, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync14, writeFileSync as writeFileSync32 } from "node:fs";
97868
+ import { delimiter as delimiter2, dirname as dirname18, join as join52, relative as relative8, resolve as resolve9, sep as sep5 } from "node:path";
97696
97869
  import { fileURLToPath as fileURLToPath3 } from "node:url";
97697
97870
  var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
97698
97871
  var HASH_FILE = ".errata-mod-hash";
@@ -97707,9 +97880,9 @@ function isEngineOwned(relPath) {
97707
97880
  function listFiles(root, dir = root) {
97708
97881
  const out2 = [];
97709
97882
  for (const name2 of readdirSync15(dir)) {
97710
- const abs = join50(dir, name2);
97883
+ const abs = join52(dir, name2);
97711
97884
  if (isEngineOwned(relative8(root, abs))) continue;
97712
- if (statSync12(abs).isDirectory()) out2.push(...listFiles(root, abs));
97885
+ if (statSync14(abs).isDirectory()) out2.push(...listFiles(root, abs));
97713
97886
  else out2.push(abs);
97714
97887
  }
97715
97888
  return out2;
@@ -97719,14 +97892,14 @@ function modHash(dir) {
97719
97892
  for (const abs of listFiles(dir).sort()) {
97720
97893
  h.update(relative8(dir, abs).split(sep5).join("/"));
97721
97894
  h.update("\0");
97722
- h.update(readFileSync43(abs));
97895
+ h.update(readFileSync44(abs));
97723
97896
  h.update("\0");
97724
97897
  }
97725
97898
  return h.digest("hex");
97726
97899
  }
97727
97900
  function bundledMods(bundleDir) {
97728
97901
  if (!existsSync39(bundleDir)) return [];
97729
- return readdirSync15(bundleDir).filter((name2) => existsSync39(join50(bundleDir, name2, ".claude-plugin", "plugin.json")));
97902
+ return readdirSync15(bundleDir).filter((name2) => existsSync39(join52(bundleDir, name2, ".claude-plugin", "plugin.json")));
97730
97903
  }
97731
97904
  function sameDir(a, b) {
97732
97905
  const norm = (p) => resolve9(p).replace(/[\\/]+$/, "").toLowerCase();
@@ -97743,7 +97916,7 @@ function off(env2) {
97743
97916
  function readSettings(path3) {
97744
97917
  if (!existsSync39(path3)) return {};
97745
97918
  try {
97746
- const parsed = JSON.parse(readFileSync43(path3, "utf8"));
97919
+ const parsed = JSON.parse(readFileSync44(path3, "utf8"));
97747
97920
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
97748
97921
  return parsed;
97749
97922
  } catch {
@@ -97773,7 +97946,7 @@ function writeSettings(path3, settings) {
97773
97946
  function ensureClaudeMods(opts) {
97774
97947
  const env2 = opts.env ?? process.env;
97775
97948
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
97776
- const modsRoot = join50(opts.installRoot, "claude-mods");
97949
+ const modsRoot = join52(opts.installRoot, "claude-mods");
97777
97950
  if (off(env2)) {
97778
97951
  const settings2 = readSettings(settingsPath);
97779
97952
  if (!settings2) return { kind: "unreadable" };
@@ -97790,11 +97963,11 @@ function ensureClaudeMods(opts) {
97790
97963
  let changed = false;
97791
97964
  const installed = [];
97792
97965
  for (const name2 of names) {
97793
- const src = join50(bundleDir, name2);
97794
- const dest = join50(modsRoot, name2);
97966
+ const src = join52(bundleDir, name2);
97967
+ const dest = join52(modsRoot, name2);
97795
97968
  const hash2 = modHash(src);
97796
- const hashFile = join50(dest, HASH_FILE);
97797
- if (!existsSync39(hashFile) || readFileSync43(hashFile, "utf8") !== hash2) {
97969
+ const hashFile = join52(dest, HASH_FILE);
97970
+ if (!existsSync39(hashFile) || readFileSync44(hashFile, "utf8") !== hash2) {
97798
97971
  rmSync4(dest, { recursive: true, force: true });
97799
97972
  cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative8(src, p)) });
97800
97973
  writeFileSync32(hashFile, hash2, "utf8");
@@ -98218,9 +98391,9 @@ function resolveHookPort(explicit) {
98218
98391
  }
98219
98392
  }
98220
98393
  }
98221
- const settingsPath = join51(ROOT, ".claude", "settings.json");
98394
+ const settingsPath = join53(ROOT, ".claude", "settings.json");
98222
98395
  try {
98223
- if (existsSync40(settingsPath)) return installedHookPort(readFileSync44(settingsPath, "utf8")) ?? 7891;
98396
+ if (existsSync40(settingsPath)) return installedHookPort(readFileSync45(settingsPath, "utf8")) ?? 7891;
98224
98397
  } catch {
98225
98398
  }
98226
98399
  return 7891;
@@ -98246,13 +98419,13 @@ async function cmdInit() {
98246
98419
  console.log("");
98247
98420
  console.log("installing harness hooks...");
98248
98421
  const { existsSync: existsSync41 } = await import("node:fs");
98249
- const { join: join52 } = await import("node:path");
98422
+ const { join: join54 } = await import("node:path");
98250
98423
  try {
98251
98424
  await installClaudeHooks(port);
98252
98425
  } catch (err2) {
98253
98426
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
98254
98427
  }
98255
- if (existsSync41(join52(ROOT, ".cursor"))) {
98428
+ if (existsSync41(join54(ROOT, ".cursor"))) {
98256
98429
  try {
98257
98430
  await installCursorMcpConfig();
98258
98431
  } catch (err2) {
@@ -98754,6 +98927,7 @@ async function cmdDoctor(args2) {
98754
98927
  const lock = readDaemonLock(lockPath);
98755
98928
  return daemonDoctorCheck({ lock, state: daemonLockState(lock, true), selfVersion: DAEMON_VERSION, lockPath });
98756
98929
  },
98930
+ credentialHygiene: () => credentialHygieneCheck(scanHarnessConfigs(harnessConfigPaths(ROOT))),
98757
98931
  inspect: () => inspectCloudEndpoint(cfg.cloudUrl),
98758
98932
  authenticate: async () => {
98759
98933
  const me = await authedCloudClient(cfg).me();
@@ -99474,7 +99648,7 @@ async function cmdReview() {
99474
99648
  console.log("(review queue empty)");
99475
99649
  return;
99476
99650
  }
99477
- const queue = JSON.parse(readFileSync44(paths.reviewQueue, "utf8"));
99651
+ const queue = JSON.parse(readFileSync45(paths.reviewQueue, "utf8"));
99478
99652
  if (queue.length === 0) {
99479
99653
  console.log("(review queue empty)");
99480
99654
  return;
@@ -100226,8 +100400,8 @@ async function cmdReport(args2) {
100226
100400
  const outDir = workspacePaths(ROOT).configDir;
100227
100401
  mkdirSync13(outDir, { recursive: true });
100228
100402
  const files = renderReport2(data, { includeFutureVerbs });
100229
- for (const f of files) writeFileSync33(join51(outDir, f.name), f.html, "utf8");
100230
- const indexPath = join51(outDir, "report.html");
100403
+ for (const f of files) writeFileSync33(join53(outDir, f.name), f.html, "utf8");
100404
+ const indexPath = join53(outDir, "report.html");
100231
100405
  console.log(`report \u2192 ${indexPath}`);
100232
100406
  console.log(
100233
100407
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -100283,7 +100457,7 @@ function spawnDaemonDetached(options = {}) {
100283
100457
  try {
100284
100458
  const logPath = daemonLogPath();
100285
100459
  try {
100286
- if (statSync13(logPath).size > 5 * 1024 * 1024) renameSync9(logPath, `${logPath}.1`);
100460
+ if (statSync15(logPath).size > 5 * 1024 * 1024) renameSync9(logPath, `${logPath}.1`);
100287
100461
  } catch {
100288
100462
  }
100289
100463
  out2 = openSync3(logPath, "a");
@@ -100352,24 +100526,24 @@ async function cmdInstallHooks(args2) {
100352
100526
  }
100353
100527
  }
100354
100528
  async function installOpencodePlugin(port) {
100355
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync45, writeFileSync: writeFileSync33 } = await import("node:fs");
100356
- const { join: join52 } = await import("node:path");
100357
- const dir = join52(ROOT, ".opencode", "plugin");
100529
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync46, writeFileSync: writeFileSync33 } = await import("node:fs");
100530
+ const { join: join54 } = await import("node:path");
100531
+ const dir = join54(ROOT, ".opencode", "plugin");
100358
100532
  if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
100359
- const file2 = join52(dir, "inerrata.js");
100533
+ const file2 = join54(dir, "inerrata.js");
100360
100534
  if (existsSync41(file2)) {
100361
- const head2 = readFileSync45(file2, "utf8").split("\n")[0] ?? "";
100535
+ const head2 = readFileSync46(file2, "utf8").split("\n")[0] ?? "";
100362
100536
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
100363
100537
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
100364
100538
  process.exit(2);
100365
100539
  }
100366
100540
  }
100367
100541
  writeFileSync33(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
100368
- const cfgFile = join52(ROOT, "opencode.json");
100542
+ const cfgFile = join54(ROOT, "opencode.json");
100369
100543
  let cfg = { $schema: "https://opencode.ai/config.json" };
100370
100544
  if (existsSync41(cfgFile)) {
100371
100545
  try {
100372
- cfg = JSON.parse(readFileSync45(cfgFile, "utf8"));
100546
+ cfg = JSON.parse(readFileSync46(cfgFile, "utf8"));
100373
100547
  } catch {
100374
100548
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
100375
100549
  process.exit(2);
@@ -100415,15 +100589,15 @@ function installClaudeMods() {
100415
100589
  }
100416
100590
  }
100417
100591
  async function installClaudeHooks(port) {
100418
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync45, writeFileSync: writeFileSync33 } = await import("node:fs");
100419
- const { join: join52 } = await import("node:path");
100420
- const dir = join52(ROOT, ".claude");
100592
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync46, writeFileSync: writeFileSync33 } = await import("node:fs");
100593
+ const { join: join54 } = await import("node:path");
100594
+ const dir = join54(ROOT, ".claude");
100421
100595
  if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
100422
- const file2 = join52(dir, "settings.json");
100596
+ const file2 = join54(dir, "settings.json");
100423
100597
  let settings = {};
100424
100598
  if (existsSync41(file2)) {
100425
100599
  try {
100426
- settings = JSON.parse(readFileSync45(file2, "utf8"));
100600
+ settings = JSON.parse(readFileSync46(file2, "utf8"));
100427
100601
  } catch {
100428
100602
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
100429
100603
  process.exit(2);
@@ -100477,7 +100651,7 @@ async function installClaudeHooks(port) {
100477
100651
  console.log(` ${ensureStatusLine(port)}`);
100478
100652
  console.log(` ${installClaudeMods().line}`);
100479
100653
  await installClaudeMcpConfig();
100480
- const claudeMd = join52(ROOT, "CLAUDE.md");
100654
+ const claudeMd = join54(ROOT, "CLAUDE.md");
100481
100655
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
100482
100656
  if (recall.kind === "collision") {
100483
100657
  console.warn(
@@ -100489,15 +100663,15 @@ async function installClaudeHooks(port) {
100489
100663
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
100490
100664
  }
100491
100665
  async function installClaudeMcpConfig() {
100492
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync45, writeFileSync: writeFileSync33 } = await import("node:fs");
100493
- const { join: join52, dirname: dirname19 } = await import("node:path");
100494
- const file2 = join52(ROOT, ".mcp.json");
100666
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync46, writeFileSync: writeFileSync33 } = await import("node:fs");
100667
+ const { join: join54, dirname: dirname19 } = await import("node:path");
100668
+ const file2 = join54(ROOT, ".mcp.json");
100495
100669
  const dir = dirname19(file2);
100496
100670
  if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
100497
100671
  let cfg = {};
100498
100672
  if (existsSync41(file2)) {
100499
100673
  try {
100500
- cfg = JSON.parse(readFileSync45(file2, "utf8"));
100674
+ cfg = JSON.parse(readFileSync46(file2, "utf8"));
100501
100675
  } catch {
100502
100676
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
100503
100677
  process.exit(2);
@@ -100511,15 +100685,15 @@ async function installClaudeMcpConfig() {
100511
100685
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
100512
100686
  }
100513
100687
  async function installCursorMcpConfig() {
100514
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync45, writeFileSync: writeFileSync33 } = await import("node:fs");
100515
- const { join: join52 } = await import("node:path");
100516
- const dir = join52(ROOT, ".cursor");
100688
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync46, writeFileSync: writeFileSync33 } = await import("node:fs");
100689
+ const { join: join54 } = await import("node:path");
100690
+ const dir = join54(ROOT, ".cursor");
100517
100691
  if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
100518
- const file2 = join52(dir, "mcp.json");
100692
+ const file2 = join54(dir, "mcp.json");
100519
100693
  let cfg = {};
100520
100694
  if (existsSync41(file2)) {
100521
100695
  try {
100522
- cfg = JSON.parse(readFileSync45(file2, "utf8"));
100696
+ cfg = JSON.parse(readFileSync46(file2, "utf8"));
100523
100697
  } catch {
100524
100698
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
100525
100699
  process.exit(2);
@@ -100538,7 +100712,7 @@ async function installCodexHooks(port) {
100538
100712
  const gitRoot = nearestGitRoot(process.cwd());
100539
100713
  const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
100540
100714
  const file2 = writeCodexHooks(hookRoot, port);
100541
- const instructions = writeManagedBlock(join51(hookRoot, "AGENTS.md"), {
100715
+ const instructions = writeManagedBlock(join53(hookRoot, "AGENTS.md"), {
100542
100716
  body: AGENTS_POINTER_BODY,
100543
100717
  stable: true
100544
100718
  });
@@ -100984,9 +101158,9 @@ async function cmdDash(args2) {
100984
101158
  await yieldToLoop2();
100985
101159
  try {
100986
101160
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
100987
- atCommit: readGitRefState(join51(r.root, ".git")).sha ?? void 0
101161
+ atCommit: readGitRefState(join53(r.root, ".git")).sha ?? void 0
100988
101162
  });
100989
- const res = bleedRules(join51(r.root, ".claude", "rules"), items);
101163
+ const res = bleedRules(join53(r.root, ".claude", "rules"), items);
100990
101164
  if (res.written || res.pruned) {
100991
101165
  console.log(
100992
101166
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")