@inerrata-corporation/errata 2.0.23-dev.4829 → 2.0.23-dev.4864

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
@@ -980,7 +980,7 @@ function lemma(token) {
980
980
  }
981
981
  return token;
982
982
  }
983
- function tokenize(text, resolve10) {
983
+ function tokenize(text, resolve11) {
984
984
  const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
985
985
  const out2 = /* @__PURE__ */ new Set();
986
986
  for (const raw2 of matches) {
@@ -990,7 +990,7 @@ function tokenize(text, resolve10) {
990
990
  out2.add(token);
991
991
  continue;
992
992
  }
993
- const canonical = resolve10(token);
993
+ const canonical = resolve11(token);
994
994
  out2.add(canonical ?? lemma(token));
995
995
  }
996
996
  return [...out2].sort();
@@ -18892,10 +18892,10 @@ function wmCalibrationCells(store) {
18892
18892
  }
18893
18893
  })();
18894
18894
  for (const n of rows) {
18895
- const live3 = n.validTo === null;
18895
+ const live4 = n.validTo === null;
18896
18896
  const prev = newest.get(n.logicalId);
18897
- if (prev && (prev.live || !live3 && prev.version >= n.version)) continue;
18898
- newest.set(n.logicalId, { version: n.version, live: live3, attrs: n.attrs });
18897
+ if (prev && (prev.live || !live4 && prev.version >= n.version)) continue;
18898
+ newest.set(n.logicalId, { version: n.version, live: live4, attrs: n.attrs });
18899
18899
  }
18900
18900
  for (const { attrs } of newest.values()) {
18901
18901
  const shown = num(attrs["shownCount"]);
@@ -22560,7 +22560,7 @@ CREATE INDEX IF NOT EXISTS nodes_revisit_true ON nodes(valid_from) WHERE json_ty
22560
22560
  return out2;
22561
22561
  }
22562
22562
  liveNodeIds(ids) {
22563
- const live3 = /* @__PURE__ */ new Set();
22563
+ const live4 = /* @__PURE__ */ new Set();
22564
22564
  const CHUNK2 = 900;
22565
22565
  for (let i2 = 0; i2 < ids.length; i2 += CHUNK2) {
22566
22566
  const slice = ids.slice(i2, i2 + CHUNK2);
@@ -22568,9 +22568,9 @@ CREATE INDEX IF NOT EXISTS nodes_revisit_true ON nodes(valid_from) WHERE json_ty
22568
22568
  const rows = this.db.prepare(
22569
22569
  `SELECT id FROM nodes WHERE valid_to IS NULL AND id IN (${slice.map(() => "?").join(",")})`
22570
22570
  ).all(...slice);
22571
- for (const r of rows) live3.add(r.id);
22571
+ for (const r of rows) live4.add(r.id);
22572
22572
  }
22573
- return live3;
22573
+ return live4;
22574
22574
  }
22575
22575
  /**
22576
22576
  * Live edges WITH their endpoint labels and ids, resolved in ONE join.
@@ -22639,9 +22639,9 @@ CREATE INDEX IF NOT EXISTS nodes_revisit_true ON nodes(valid_from) WHERE json_ty
22639
22639
  // the indexer calls freezeNode inside its own store.transaction(). So this
22640
22640
  // method does NOT open a transaction — callers needing atomicity wrap it.
22641
22641
  freezeNode(liveId, t) {
22642
- const live3 = this.getNode(liveId);
22643
- if (!live3) return null;
22644
- const version3 = live3.version ?? 1;
22642
+ const live4 = this.getNode(liveId);
22643
+ if (!live4) return null;
22644
+ const version3 = live4.version ?? 1;
22645
22645
  const frozenId = `${liveId}@v${version3}`;
22646
22646
  if (this.getNode(frozenId)) {
22647
22647
  this.stmts.advanceLive.run({ live_id: liveId, t });
@@ -22791,11 +22791,11 @@ function walk(store, opts) {
22791
22791
  }
22792
22792
  }
22793
22793
  best.delete(seed.id);
22794
- const ranked = [];
22794
+ const ranked2 = [];
22795
22795
  for (const [id, r] of best) {
22796
22796
  const node2 = store.getNode(id);
22797
22797
  if (!node2) continue;
22798
- ranked.push({
22798
+ ranked2.push({
22799
22799
  id,
22800
22800
  label: node2.label,
22801
22801
  description: node2.description,
@@ -22805,11 +22805,11 @@ function walk(store, opts) {
22805
22805
  // product of conductances along best path
22806
22806
  });
22807
22807
  }
22808
- ranked.sort(
22808
+ ranked2.sort(
22809
22809
  (a, b) => b.relevance - a.relevance || a.hops - b.hops
22810
22810
  );
22811
- const truncated = ranked.length > limit;
22812
- return { seedId: seed.id, nodes: ranked.slice(0, limit), truncated };
22811
+ const truncated = ranked2.length > limit;
22812
+ return { seedId: seed.id, nodes: ranked2.slice(0, limit), truncated };
22813
22813
  }
22814
22814
  function findPath(store, opts) {
22815
22815
  const maxHops = opts.maxHops ?? 6;
@@ -24309,7 +24309,7 @@ function ingestDesignProblem(store, flag, opts) {
24309
24309
  ...existing.attrs,
24310
24310
  // An INDEPENDENT source re-deriving a resolved problem marks
24311
24311
  // immediately — that is the strongest recurrence evidence there is.
24312
- ...resolvedUnretracted ? recurAttrs() : {},
24312
+ ...resolvedUnretracted && !opts.replay ? recurAttrs() : {},
24313
24313
  sources: [...sources, opts.source],
24314
24314
  corroborations: corroborations2,
24315
24315
  ...promoted ? { provisional: false } : {},
@@ -24336,7 +24336,11 @@ function ingestDesignProblem(store, flag, opts) {
24336
24336
  lastUpdatedAt: opts.ts
24337
24337
  });
24338
24338
  if (recurredResolved) reopenedFromRegression = maybeReopenFromRegression(store, problemId, opts.ts);
24339
- } else if (resolvedUnretracted && opts.ts - (Number(existing.attrs["recurredAt"]) || 0) > RECURRENCE_DEBOUNCE_MS) {
24339
+ } else if (resolvedUnretracted && !opts.replay && // From the later of the last recurrence and the close itself: before the
24340
+ // first recurrence there is no recurredAt, and measuring from 0 booked the
24341
+ // resolving session's own turn-final restatement — seconds after its fix —
24342
+ // as the problem coming back (15 of 19 recurrences on the arena store).
24343
+ opts.ts - Math.max(Number(existing.attrs["recurredAt"]) || 0, Number(existing.attrs["resolvedAt"]) || 0) > RECURRENCE_DEBOUNCE_MS) {
24340
24344
  store.updateNode(problemId, {
24341
24345
  attrs: { ...existing.attrs, ...recurAttrs() },
24342
24346
  lastUpdatedAt: opts.ts
@@ -24910,8 +24914,8 @@ function anchorNodeToDiff(store, nodeId, expectLabel, changedPaths, workspaceId2
24910
24914
  }
24911
24915
  function solutionForProblem(store, problemId) {
24912
24916
  const sols = store.outEdges(problemId, ["SOLVED_BY"]).map((e) => store.getNode(e.to)).filter((n) => n !== null);
24913
- const live3 = sols.filter((s) => s.validTo == null && !isAutoMinted(s));
24914
- const pick2 = (live3.length > 0 ? live3 : sols).reduce(
24917
+ const live4 = sols.filter((s) => s.validTo == null && !isAutoMinted(s));
24918
+ const pick2 = (live4.length > 0 ? live4 : sols).reduce(
24915
24919
  (best, s) => !best || s.createdAt > best.createdAt ? s : best,
24916
24920
  null
24917
24921
  );
@@ -25659,13 +25663,13 @@ function recallableCorpus(store) {
25659
25663
  let cache2 = bagCache.get(store);
25660
25664
  if (!cache2) bagCache.set(store, cache2 = /* @__PURE__ */ new Map());
25661
25665
  const docs = [];
25662
- const live3 = /* @__PURE__ */ new Set();
25666
+ const live4 = /* @__PURE__ */ new Set();
25663
25667
  for (const row of store.selectNodes({ labels: RECALLABLE, attrs: RECALL_FILTER_KEYS })) {
25664
25668
  if (row.attrs["mergedInto"] !== void 0) continue;
25665
25669
  if (row.label === "Problem" && row.attrs["resolvedAt"] != null && !isConstraintProblem(row)) {
25666
25670
  continue;
25667
25671
  }
25668
- live3.add(row.id);
25672
+ live4.add(row.id);
25669
25673
  let entry = cache2.get(row.id);
25670
25674
  if (!entry || entry.description !== row.description) {
25671
25675
  entry = { description: row.description, bag: retrievalTokens(row.description) };
@@ -25674,7 +25678,7 @@ function recallableCorpus(store) {
25674
25678
  if (entry.bag.length === 0) continue;
25675
25679
  docs.push({ id: row.id, descLength: row.description.length, bag: entry.bag });
25676
25680
  }
25677
- for (const id of cache2.keys()) if (!live3.has(id)) cache2.delete(id);
25681
+ for (const id of cache2.keys()) if (!live4.has(id)) cache2.delete(id);
25678
25682
  return docs;
25679
25683
  }
25680
25684
  var FIELD_LINE, RECALLABLE, MIN_INTENT_TOKENS, DEFAULT_MIN_COVERAGE, RECALL_FILTER_KEYS, bagCache;
@@ -27053,7 +27057,7 @@ function communitySeeds(store, opts = {}) {
27053
27057
  byCommunity.set(cid, l);
27054
27058
  }
27055
27059
  if (byCommunity.size === 0) return [];
27056
- const ranked = [...byCommunity.entries()].map(([cid, mem]) => ({ cid, mem, fresh: Math.max(...mem.map((m) => m.ts)) })).sort((a, b) => b.fresh - a.fresh).slice(0, maxCommunities);
27060
+ const ranked2 = [...byCommunity.entries()].map(([cid, mem]) => ({ cid, mem, fresh: Math.max(...mem.map((m) => m.ts)) })).sort((a, b) => b.fresh - a.fresh).slice(0, maxCommunities);
27057
27061
  const seeds = [];
27058
27062
  const seen = /* @__PURE__ */ new Set();
27059
27063
  const push = (id) => {
@@ -27061,7 +27065,7 @@ function communitySeeds(store, opts = {}) {
27061
27065
  seen.add(id);
27062
27066
  seeds.push(id);
27063
27067
  };
27064
- for (const { mem } of ranked) {
27068
+ for (const { mem } of ranked2) {
27065
27069
  const ordered = [...mem].sort(
27066
27070
  (a, b) => a.pulled === b.pulled ? b.ts - a.ts : a.pulled ? -1 : 1
27067
27071
  );
@@ -31321,12 +31325,12 @@ function hasCloudCredential(cfg) {
31321
31325
  }
31322
31326
  function persistProfileTokens(profileName, t) {
31323
31327
  const current = loadConfig();
31324
- const live3 = current.installationProfiles[profileName];
31325
- if (!live3) return;
31328
+ const live4 = current.installationProfiles[profileName];
31329
+ if (!live4) return;
31326
31330
  current.installationProfiles = {
31327
31331
  ...current.installationProfiles,
31328
31332
  [profileName]: {
31329
- ...live3,
31333
+ ...live4,
31330
31334
  accessToken: t.accessToken,
31331
31335
  ...t.refreshToken ? { refreshToken: t.refreshToken } : {}
31332
31336
  }
@@ -34217,11 +34221,11 @@ function bindCanonicalNeighbors(store, opts) {
34217
34221
  store.outEdges(p.id, ["MATCHES", "INSTANCE_OF", "RELATES_TO"]).map((e) => e.to)
34218
34222
  );
34219
34223
  if (existing.size >= k) continue;
34220
- const ranked = pool.filter(
34224
+ const ranked2 = pool.filter(
34221
34225
  (c) => c.id !== p.id && !existing.has(c.id) && c.embedding.length === p.embedding.length && (c.attrs["embeddingVersion"] ?? "") === (p.attrs["embeddingVersion"] ?? "")
34222
34226
  ).map((c) => ({ c, s: cosine(p.embedding, c.embedding) })).filter((x) => x.s >= CANONICAL_BIND_MIN && x.s < NEMORI_DEDUP_COSINE).sort((a, b) => b.s - a.s);
34223
34227
  const picked = [];
34224
- for (const cand of ranked) {
34228
+ for (const cand of ranked2) {
34225
34229
  if (picked.length + existing.size >= k) break;
34226
34230
  if (picked.some((q) => cosine(q.c.embedding, cand.c.embedding) >= NEMORI_DEDUP_COSINE)) continue;
34227
34231
  picked.push(cand);
@@ -35878,14 +35882,14 @@ function localBurst(store, seedId, opts = {}) {
35878
35882
  }).filter((r) => !gated || r.score > 0).sort((a, b) => b.score - a.score).slice(0, limit);
35879
35883
  }
35880
35884
  function burstFromSeeds(store, seeds, opts = {}) {
35881
- const live3 = seeds.filter((s) => s.weight > 0);
35882
- if (live3.length === 0) return [];
35883
- const { act, hopOf, viaOf } = spreadActivation(store, live3, {
35885
+ const live4 = seeds.filter((s) => s.weight > 0);
35886
+ if (live4.length === 0) return [];
35887
+ const { act, hopOf, viaOf } = spreadActivation(store, live4, {
35884
35888
  maxHops: opts.maxHops ?? 3,
35885
35889
  nodeCap: opts.nodeCap ?? 300,
35886
35890
  accumulate: true
35887
35891
  });
35888
- const seedIds = new Set(live3.map((s) => s.id));
35892
+ const seedIds = new Set(live4.map((s) => s.id));
35889
35893
  const labelOf = store.nodeLabels([...act.keys()]);
35890
35894
  const pool = (keep) => [...act.entries()].filter(([id]) => keep(labelOf.get(id) ?? "")).sort((x, y) => y[1] - x[1]).slice(0, BURST_SCORED_CANDIDATES);
35891
35895
  const isKnowledge = (label) => typeRelevance(label) >= KNOWLEDGE_TYPE_RELEVANCE;
@@ -36579,10 +36583,10 @@ function createSessionRegistry(opts = {}) {
36579
36583
  originSessions: () => [...origins.keys()],
36580
36584
  isOwn: (sessionId, viewer) => sessionId === viewer || parentOf.get(sessionId) === viewer,
36581
36585
  version(nowMs) {
36582
- let live3 = 0;
36583
- for (const id of lastSeen.keys()) if (ownLive(id, nowMs)) live3++;
36584
- if (live3 !== lastLiveCount) {
36585
- lastLiveCount = live3;
36586
+ let live4 = 0;
36587
+ for (const id of lastSeen.keys()) if (ownLive(id, nowMs)) live4++;
36588
+ if (live4 !== lastLiveCount) {
36589
+ lastLiveCount = live4;
36586
36590
  ver++;
36587
36591
  }
36588
36592
  return ver;
@@ -37163,7 +37167,7 @@ async function waitForDaemonExit(lock, timeoutMs, pollMs = 200) {
37163
37167
  for (; ; ) {
37164
37168
  if (daemonLockState(lock, true) === "stale") return true;
37165
37169
  if (Date.now() >= deadline) return false;
37166
- await new Promise((resolve10) => setTimeout(resolve10, pollMs));
37170
+ await new Promise((resolve11) => setTimeout(resolve11, pollMs));
37167
37171
  }
37168
37172
  }
37169
37173
  function releaseOwnLock(lockPath) {
@@ -38079,7 +38083,7 @@ function lazySymbolLexicon(store) {
38079
38083
  const members = /* @__PURE__ */ new Map();
38080
38084
  const docs = /* @__PURE__ */ new Map();
38081
38085
  const entries = /* @__PURE__ */ new Map();
38082
- const member = (name2) => {
38086
+ const member2 = (name2) => {
38083
38087
  if (!members.has(name2)) {
38084
38088
  const hit = isDistinctiveIdentifier(name2) ? store.firstLiveByNameOrQname(labels, name2) : null;
38085
38089
  members.set(name2, hit ? { kind: kindOf.get(hit.label), description: hit.description, qname: hit.qname } : null);
@@ -38100,13 +38104,13 @@ function lazySymbolLexicon(store) {
38100
38104
  }
38101
38105
  return docs.get(name2);
38102
38106
  };
38103
- const isKnown = (tok) => member(tok) !== null;
38107
+ const isKnown = (tok) => member2(tok) !== null;
38104
38108
  let anySymbol;
38105
38109
  return {
38106
38110
  has: isKnown,
38107
38111
  get(name2) {
38108
38112
  if (!entries.has(name2)) {
38109
- const m = member(name2);
38113
+ const m = member2(name2);
38110
38114
  let entry = null;
38111
38115
  if (m) {
38112
38116
  entry = { kind: m.kind };
@@ -39125,17 +39129,17 @@ async function rankHits(store, query, hits, opts = {}) {
39125
39129
  if (p != null && p !== i2 && best[p] > best[i2]) best[i2] = best[p];
39126
39130
  });
39127
39131
  }
39128
- const ranked = hits.map((h, i2) => {
39132
+ const ranked2 = hits.map((h, i2) => {
39129
39133
  const r = rankKnowledge({ ...inputs[i2], ...best[i2] > own[i2] ? { inherited: best[i2] } : {} }, weights);
39130
39134
  return { hit: h, i: i2, r };
39131
39135
  });
39132
- ranked.sort((a, b) => b.r.score - a.r.score || a.i - b.i);
39133
- return ranked.map(({ hit, r }) => ({ ...hit, score: r.score, rank: r.components }));
39136
+ ranked2.sort((a, b) => b.r.score - a.r.score || a.i - b.i);
39137
+ return ranked2.map(({ hit, r }) => ({ ...hit, score: r.score, rank: r.components }));
39134
39138
  }
39135
- function interleaveLanes(ranked, isKnowledge, limit) {
39136
- const lanes = [ranked.filter((r) => isKnowledge(r.label)), ranked.filter((r) => !isKnowledge(r.label))];
39139
+ function interleaveLanes(ranked2, isKnowledge, limit) {
39140
+ const lanes = [ranked2.filter((r) => isKnowledge(r.label)), ranked2.filter((r) => !isKnowledge(r.label))];
39137
39141
  const out2 = [];
39138
- for (let i2 = 0; out2.length < limit && i2 < ranked.length; i2++) {
39142
+ for (let i2 = 0; out2.length < limit && i2 < ranked2.length; i2++) {
39139
39143
  const round2 = lanes.flatMap((lane) => lane[i2] ? [lane[i2]] : []).sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
39140
39144
  for (const hit of round2) if (out2.length < limit) out2.push(hit);
39141
39145
  }
@@ -39149,12 +39153,12 @@ async function rankDualNodes(store, query, nodes, cloudEvidence2) {
39149
39153
  const parent = n.via?.parentId;
39150
39154
  return parent ? { ...n, parentId: parent } : n;
39151
39155
  });
39152
- const ranked = await rankHits(store, query, withParents, cloudEvidence2 ? { cloudEvidence: cloudEvidence2 } : {});
39153
- return ranked.map(({ rank, score: score2, ...n }) => ({ ...n, score: score2, why: rankWhy(rank) }));
39156
+ const ranked2 = await rankHits(store, query, withParents, cloudEvidence2 ? { cloudEvidence: cloudEvidence2 } : {});
39157
+ return ranked2.map(({ rank, score: score2, ...n }) => ({ ...n, score: score2, why: rankWhy(rank) }));
39154
39158
  }
39155
39159
  async function rankSimilarLocal(store, seedText, hits) {
39156
- const ranked = await rankHits(store, seedQuery(seedText), hits.map((h) => ({ ...h, hops: 0 })));
39157
- return ranked.map(({ rank, score: score2, hops: _hops, ...h }) => ({ ...h, score: score2, why: rankWhy(rank) }));
39160
+ const ranked2 = await rankHits(store, seedQuery(seedText), hits.map((h) => ({ ...h, hops: 0 })));
39161
+ return ranked2.map(({ rank, score: score2, hops: _hops, ...h }) => ({ ...h, score: score2, why: rankWhy(rank) }));
39158
39162
  }
39159
39163
  function withCite(records, isKnowledge) {
39160
39164
  return records.map((r) => isKnowledge(String(r["label"])) ? { ...r, cite: String(r["id"]) } : r);
@@ -39176,6 +39180,104 @@ var init_one_search = __esm({
39176
39180
  }
39177
39181
  });
39178
39182
 
39183
+ // src/chain-complete.ts
39184
+ function fixesOf(store, problemId, causes) {
39185
+ const own = store.outEdges(problemId, [...FIX_EDGES]).map((e) => e.to).filter((id) => live2(store, id));
39186
+ if (own.length > 0) return own.map((id) => ({ id }));
39187
+ const borrowed = /* @__PURE__ */ new Map();
39188
+ for (const c of causes) {
39189
+ for (const e of store.inEdges(c, ["CAUSED_BY"])) {
39190
+ if (e.from === problemId || live2(store, e.from)?.label !== "Problem") continue;
39191
+ for (const f of store.outEdges(e.from, [...FIX_EDGES])) if (!borrowed.has(f.to) && live2(store, f.to)) borrowed.set(f.to, e.from);
39192
+ }
39193
+ }
39194
+ return [...borrowed].map(([id, via]) => ({ id, via }));
39195
+ }
39196
+ async function ranked(store, about, ids) {
39197
+ const hits = ids.flatMap(({ id, via }) => {
39198
+ const n = live2(store, id);
39199
+ return n ? [{ id, label: n.label, name: n.description, hops: 0, ...via ? { via } : {} }] : [];
39200
+ });
39201
+ const order = hits.length > 1 ? await rankHits(store, about, hits) : hits;
39202
+ return order.flatMap((h) => member(store, h.id, h.via) ?? []);
39203
+ }
39204
+ async function chainOf(store, problemId) {
39205
+ const p = live2(store, problemId);
39206
+ if (!p || p.label !== "Problem") return void 0;
39207
+ const causes = store.outEdges(problemId, ["CAUSED_BY"]).map((e) => e.to).filter((id) => live2(store, id)?.label === "RootCause");
39208
+ const [cause] = await ranked(store, p.description, causes.map((id) => ({ id })));
39209
+ const fixIds = fixesOf(store, problemId, causes);
39210
+ const [fix, ...rest2] = await ranked(store, [p.description, cause?.text ?? ""].join(" "), fixIds);
39211
+ if (!cause && !fix) return void 0;
39212
+ const alsoFixes = rest2.slice(0, ALSO_FIXES);
39213
+ return {
39214
+ ...cause ? { cause } : {},
39215
+ ...fix ? { fix, fixes: fixIds.length } : {},
39216
+ ...alsoFixes.length > 0 ? { alsoFixes } : {}
39217
+ };
39218
+ }
39219
+ function statementOf(description) {
39220
+ const s = description?.replace(/\s+@\s+\S+\s*$/, "").trim().toLowerCase();
39221
+ return s ? s : void 0;
39222
+ }
39223
+ function searchChainsEnabled(env2 = process.env) {
39224
+ return !/^(0|off|false|no)$/i.test((env2["ERRATA_SEARCH_CHAINS"] ?? "").trim());
39225
+ }
39226
+ async function completeChains(store, hits) {
39227
+ if (!searchChainsEnabled()) return [...hits];
39228
+ const idOf = (h) => String(h.id ?? "");
39229
+ const isProblem = (h) => h.label === "Problem";
39230
+ const chains = /* @__PURE__ */ new Map();
39231
+ for (const h of hits) {
39232
+ if (!isProblem(h)) continue;
39233
+ const c = await chainOf(store, idOf(h));
39234
+ if (c) chains.set(idOf(h), c);
39235
+ }
39236
+ const out2 = [];
39237
+ const shownAt = /* @__PURE__ */ new Map();
39238
+ const statementAt = /* @__PURE__ */ new Map();
39239
+ const carried = /* @__PURE__ */ new Set();
39240
+ for (const h of hits) {
39241
+ const id = idOf(h);
39242
+ if (carried.has(id)) continue;
39243
+ const chain2 = chains.get(id);
39244
+ const owner = chain2?.fix?.via;
39245
+ const statement = isProblem(h) ? statementOf(live2(store, id)?.description) : void 0;
39246
+ let into = owner && shownAt.has(owner) ? shownAt.get(owner) : out2.findIndex((o) => o.chain?.fix?.via === id);
39247
+ if (into < 0 && statement && statementAt.has(statement)) into = statementAt.get(statement);
39248
+ if (into >= 0) {
39249
+ const at = out2[into];
39250
+ const adopt = !at.chain?.fix && chain2?.fix ? { chain: { ...chain2, ...at.chain?.cause ? { cause: at.chain.cause } : {} } } : {};
39251
+ out2[into] = { ...at, ...adopt, alsoReportedAs: [...at.alsoReportedAs ?? [], id] };
39252
+ for (const m of membersOf(chain2)) carried.add(m.id);
39253
+ continue;
39254
+ }
39255
+ if (statement) statementAt.set(statement, out2.length);
39256
+ shownAt.set(id, out2.length);
39257
+ out2.push(chain2 ? { ...h, chain: chain2 } : h);
39258
+ for (const m of membersOf(chain2)) carried.add(m.id);
39259
+ }
39260
+ return out2;
39261
+ }
39262
+ var FIX_EDGES, live2, member, ALSO_FIXES, membersOf;
39263
+ var init_chain_complete = __esm({
39264
+ "src/chain-complete.ts"() {
39265
+ "use strict";
39266
+ init_one_search();
39267
+ FIX_EDGES = ["SOLVED_BY", "FIXED_BY"];
39268
+ live2 = (store, id) => {
39269
+ const n = store.getNode(id);
39270
+ return n && n.validTo == null ? n : null;
39271
+ };
39272
+ member = (store, id, via) => {
39273
+ const n = live2(store, id);
39274
+ return n ? { id, text: n.description, ...via ? { via } : {} } : void 0;
39275
+ };
39276
+ ALSO_FIXES = 2;
39277
+ membersOf = (c) => c ? [c.cause, c.fix, ...c.alsoFixes ?? []].filter((m) => m != null) : [];
39278
+ }
39279
+ });
39280
+
39179
39281
  // src/daemon-generalize-client.ts
39180
39282
  function daemonLoopbackUrl(lockPath = globalDaemonLock()) {
39181
39283
  const url2 = readDaemonLock(lockPath)?.webUiUrl;
@@ -39934,12 +40036,12 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
39934
40036
  if (changedIds.length > 0) {
39935
40037
  store.transaction(() => {
39936
40038
  for (const nid of changedIds) {
39937
- const live3 = store.getNode(nid);
39938
- if (!live3) continue;
39939
- const history = store.nodeHistory(live3.logicalId ?? nid);
40039
+ const live4 = store.getNode(nid);
40040
+ if (!live4) continue;
40041
+ const history = store.nodeHistory(live4.logicalId ?? nid);
39940
40042
  const birth = history[0];
39941
40043
  if (!birth || birth.id === nid) continue;
39942
- const currentSim = live3.attrs["bodySimhash"];
40044
+ const currentSim = live4.attrs["bodySimhash"];
39943
40045
  const birthSim = birth.attrs["bodySimhash"];
39944
40046
  if (!hasForkedDrift(currentSim, birthSim)) continue;
39945
40047
  const forkId = edgeId(nid, "FORKED_FROM", birth.id);
@@ -41249,13 +41351,13 @@ async function Module2(moduleArg = {}) {
41249
41351
  }
41250
41352
  readAsync = /* @__PURE__ */ __name(async (url2) => {
41251
41353
  if (isFileURI(url2)) {
41252
- return new Promise((resolve10, reject) => {
41354
+ return new Promise((resolve11, reject) => {
41253
41355
  var xhr = new XMLHttpRequest();
41254
41356
  xhr.open("GET", url2, true);
41255
41357
  xhr.responseType = "arraybuffer";
41256
41358
  xhr.onload = () => {
41257
41359
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
41258
- resolve10(xhr.response);
41360
+ resolve11(xhr.response);
41259
41361
  return;
41260
41362
  }
41261
41363
  reject(xhr.status);
@@ -41451,9 +41553,9 @@ async function Module2(moduleArg = {}) {
41451
41553
  __name(receiveInstantiationResult, "receiveInstantiationResult");
41452
41554
  var info2 = getWasmImports();
41453
41555
  if (Module["instantiateWasm"]) {
41454
- return new Promise((resolve10, reject) => {
41556
+ return new Promise((resolve11, reject) => {
41455
41557
  Module["instantiateWasm"](info2, (mod, inst) => {
41456
- resolve10(receiveInstance(mod, inst));
41558
+ resolve11(receiveInstance(mod, inst));
41457
41559
  });
41458
41560
  });
41459
41561
  }
@@ -42784,8 +42886,8 @@ async function Module2(moduleArg = {}) {
42784
42886
  if (runtimeInitialized) {
42785
42887
  moduleRtn = Module;
42786
42888
  } else {
42787
- moduleRtn = new Promise((resolve10, reject) => {
42788
- readyPromiseResolve = resolve10;
42889
+ moduleRtn = new Promise((resolve11, reject) => {
42890
+ readyPromiseResolve = resolve11;
42789
42891
  readyPromiseReject = reject;
42790
42892
  });
42791
42893
  }
@@ -48120,7 +48222,7 @@ async function findStaleFiles(store, rootPath, workspaceId2, lineageVerifiedAt)
48120
48222
  }
48121
48223
  if (++scanned % SCAN_YIELD_EVERY === 0) {
48122
48224
  check2();
48123
- await new Promise((resolve10) => setImmediate(resolve10));
48225
+ await new Promise((resolve11) => setImmediate(resolve11));
48124
48226
  }
48125
48227
  }
48126
48228
  check2();
@@ -48165,12 +48267,12 @@ function reapOrphanedFiles(store, rootPath, workspaceId2, ignoreDirs = []) {
48165
48267
  if (listed === null) return { reaped: 0, symbolsClosed: 0, skipped: "no-git-listing" };
48166
48268
  if (listed.length === 0) return { reaped: 0, symbolsClosed: 0, skipped: "empty-listing" };
48167
48269
  const onDisk = new Set(listed);
48168
- const live3 = store.selectNodes({ labels: ["File"], attrs: ["workspaceId", "relPath"] }).filter((f) => f.attrs["workspaceId"] === workspaceId2);
48169
- const orphans = live3.filter((f) => {
48270
+ const live4 = store.selectNodes({ labels: ["File"], attrs: ["workspaceId", "relPath"] }).filter((f) => f.attrs["workspaceId"] === workspaceId2);
48271
+ const orphans = live4.filter((f) => {
48170
48272
  const rel = f.attrs["relPath"];
48171
48273
  return typeof rel === "string" && !onDisk.has(rel);
48172
48274
  });
48173
- const allowance = Math.max(ORPHAN_REAP_MIN_ALLOWANCE, live3.length * ORPHAN_REAP_MAX_FRACTION);
48275
+ const allowance = Math.max(ORPHAN_REAP_MIN_ALLOWANCE, live4.length * ORPHAN_REAP_MAX_FRACTION);
48174
48276
  if (orphans.length > allowance) {
48175
48277
  return {
48176
48278
  reaped: 0,
@@ -48555,17 +48657,17 @@ function searchEntries(query, matches) {
48555
48657
  for (const { m, w } of code) put(m, w);
48556
48658
  return [...seeds.values()].filter((sd) => sd.weight > 0);
48557
48659
  }
48558
- function withoutSymbolInternals(store, ranked) {
48559
- const ids = new Set(ranked.map((r) => r.id));
48660
+ function withoutSymbolInternals(store, ranked2) {
48661
+ const ids = new Set(ranked2.map((r) => r.id));
48560
48662
  const internal = /* @__PURE__ */ new Set();
48561
- for (const r of ranked) {
48663
+ for (const r of ranked2) {
48562
48664
  for (const e of store.inEdges(r.id, ["DEFINES"])) {
48563
48665
  if (!ids.has(e.from)) continue;
48564
48666
  const parent = store.getNode(e.from);
48565
48667
  if (parent && SYMBOL_PARENT_LABELS.has(parent.label)) internal.add(r.id);
48566
48668
  }
48567
48669
  }
48568
- return internal.size > 0 ? ranked.filter((r) => !internal.has(r.id)) : ranked;
48670
+ return internal.size > 0 ? ranked2.filter((r) => !internal.has(r.id)) : ranked2;
48569
48671
  }
48570
48672
  function searchWalkEnabled(env2 = process.env) {
48571
48673
  return !/^(0|off|false|no)$/i.test((env2["ERRATA_SEARCH_WALK"] ?? "").trim());
@@ -48580,11 +48682,11 @@ function searchGraphWalk(store, query, limit) {
48580
48682
  burstFromSeeds(store, searchEntries(query, matches), { limit: limit * 4, typeRelevanceForSeeds: false })
48581
48683
  );
48582
48684
  const lanes = [walked.filter((r) => KNOWLEDGE_LABELS.has(r.node.label)), walked.filter((r) => !KNOWLEDGE_LABELS.has(r.node.label))];
48583
- const ranked = [];
48584
- for (let i2 = 0; ranked.length < limit && i2 < walked.length; i2++) {
48585
- for (const lane of lanes) if (lane[i2] && ranked.length < limit) ranked.push(lane[i2]);
48685
+ const ranked2 = [];
48686
+ for (let i2 = 0; ranked2.length < limit && i2 < walked.length; i2++) {
48687
+ for (const lane of lanes) if (lane[i2] && ranked2.length < limit) ranked2.push(lane[i2]);
48586
48688
  }
48587
- return ranked.map((r) => {
48689
+ return ranked2.map((r) => {
48588
48690
  const m = byId.get(r.id);
48589
48691
  if (m) return { ...toSearchHit(m.node, m.via, m.rg), score: r.score, matched: true };
48590
48692
  const rg = hitState(store, r.node);
@@ -48950,6 +49052,7 @@ var init_mcp = __esm({
48950
49052
  init_identity2();
48951
49053
  init_registry();
48952
49054
  init_dual_augment();
49055
+ init_chain_complete();
48953
49056
  init_one_search();
48954
49057
  init_dual_burst();
48955
49058
  init_twin_index();
@@ -49064,7 +49167,7 @@ var init_mcp = __esm({
49064
49167
  limit
49065
49168
  });
49066
49169
  if (dual.status === "merged") {
49067
- const ranked = await rankHits(
49170
+ const ranked2 = await rankHits(
49068
49171
  store,
49069
49172
  query,
49070
49173
  dual.merged.nodes.map((n) => ({
@@ -49076,17 +49179,12 @@ var init_mcp = __esm({
49076
49179
  })),
49077
49180
  { cloudEvidence: dual.cloudEvidence }
49078
49181
  );
49079
- const chosen = interleaveLanes(ranked, isKnowledge, limit);
49182
+ const chosen = interleaveLanes(ranked2, isKnowledge, limit);
49080
49183
  const why = new Map(chosen.map((n) => [n.id, rankWhy(n.rank)]));
49081
49184
  const formatted = formatDualNodes({ ...dual.merged, nodes: chosen.map(({ rank: _rank, viaText: _via, ...n }) => n) });
49082
- return {
49083
- query,
49084
- collectiveReachable: true,
49085
- collectiveStatus: "merged",
49086
- count: formatted.length,
49087
- corroborated: dual.merged.corroboratedCount,
49088
- collective: dual.merged.collectiveCount,
49089
- results: withLinks(
49185
+ const results = withLinks(
49186
+ store,
49187
+ await completeChains(
49090
49188
  store,
49091
49189
  withCite(
49092
49190
  formatted.map((r) => ({
@@ -49097,9 +49195,18 @@ var init_mcp = __esm({
49097
49195
  isKnowledge
49098
49196
  )
49099
49197
  )
49198
+ );
49199
+ return {
49200
+ query,
49201
+ collectiveReachable: true,
49202
+ collectiveStatus: "merged",
49203
+ count: results.length,
49204
+ corroborated: dual.merged.corroboratedCount,
49205
+ collective: dual.merged.collectiveCount,
49206
+ results
49100
49207
  };
49101
49208
  }
49102
- const local = withLinks(store, await rankLocal());
49209
+ const local = withLinks(store, await completeChains(store, await rankLocal()));
49103
49210
  return {
49104
49211
  query,
49105
49212
  collectiveReachable: dual.status === "empty",
@@ -49109,7 +49216,7 @@ var init_mcp = __esm({
49109
49216
  results: local
49110
49217
  };
49111
49218
  }
49112
- return withLinks(store, await rankLocal());
49219
+ return withLinks(store, await completeChains(store, await rankLocal()));
49113
49220
  }
49114
49221
  },
49115
49222
  {
@@ -49259,7 +49366,7 @@ var init_mcp = __esm({
49259
49366
  if (seedForBurst && seedForBurst.embedding.length === 0) {
49260
49367
  await ensureNodeEmbedded(store, id);
49261
49368
  }
49262
- const ranked = localBurst(store, id, {
49369
+ const ranked2 = localBurst(store, id, {
49263
49370
  // Hold an embeddingless candidate's neutral semantic under the dual-burst
49264
49371
  // cloud cap so unknown local code can't outrank the capped collective (see
49265
49372
  // DUAL_BURST_SEMANTIC_NEUTRAL). No-op for local-only bursts.
@@ -49267,7 +49374,7 @@ var init_mcp = __esm({
49267
49374
  ...args2["maxHops"] != null ? { maxHops: Number(args2["maxHops"]) } : {},
49268
49375
  ...args2["limit"] != null ? { limit: Number(args2["limit"]) } : {}
49269
49376
  });
49270
- const localHits = ranked.map((r) => ({
49377
+ const localHits = ranked2.map((r) => ({
49271
49378
  id: r.id,
49272
49379
  node: { label: r.node.label, description: r.node.description },
49273
49380
  score: r.score,
@@ -49500,8 +49607,8 @@ var init_mcp = __esm({
49500
49607
  if (!ex || node2.hops < ex.hops) merged.set(node2.id, node2);
49501
49608
  }
49502
49609
  }
49503
- const ranked = [...merged.values()].sort((a, b) => b.relevance - a.relevance);
49504
- return { found: true, seedId: id, nodes: ranked.slice(0, limit), truncated: ranked.length > limit };
49610
+ const ranked2 = [...merged.values()].sort((a, b) => b.relevance - a.relevance);
49611
+ return { found: true, seedId: id, nodes: ranked2.slice(0, limit), truncated: ranked2.length > limit };
49505
49612
  }
49506
49613
  },
49507
49614
  {
@@ -49762,8 +49869,8 @@ var init_mcp = __esm({
49762
49869
  };
49763
49870
  }
49764
49871
  const fanIn = store.inDegreeByType([...CODE_REACH_EDGES]);
49765
- const ranked = store.selectNodes({ labels: CODE }).map((n) => ({ id: n.id, label: n.label, name: n.description, fanIn: fanIn.get(n.id) ?? 0 })).sort((a, b) => b.fanIn - a.fanIn).slice(0, limit);
49766
- return { kind: "fan-in", items: ranked };
49872
+ const ranked2 = store.selectNodes({ labels: CODE }).map((n) => ({ id: n.id, label: n.label, name: n.description, fanIn: fanIn.get(n.id) ?? 0 })).sort((a, b) => b.fanIn - a.fanIn).slice(0, limit);
49873
+ return { kind: "fan-in", items: ranked2 };
49767
49874
  }
49768
49875
  },
49769
49876
  {
@@ -50286,8 +50393,8 @@ function formatBurstMd(r, opts) {
50286
50393
  lines.push("legend: \u25A3 local \xB7 \u25CC collective \xB7 \u2713 corroborated");
50287
50394
  lines.push("");
50288
50395
  lines.push(`## neighborhood (${r.results.length})`);
50289
- const ranked = [...r.results].sort((a, b) => b.score - a.score);
50290
- for (const n of ranked) {
50396
+ const ranked2 = [...r.results].sort((a, b) => b.score - a.score);
50397
+ for (const n of ranked2) {
50291
50398
  const usage = n.usageCount != null ? ` \xB7 ${n.usageCount} proj` : "";
50292
50399
  const rel = n.rel ? ` \xB7 ${n.rel}` : "";
50293
50400
  lines.push(
@@ -58288,8 +58395,8 @@ function fileRecall(store, relPath) {
58288
58395
  const priors = priorsForFile(store, relPath);
58289
58396
  if (!priors) return null;
58290
58397
  const pool = [...priors.openProblems, ...priors.constraints, ...priors.related];
58291
- const ranked = rankByRelevance(store, priors.file.id, pool.map((n) => n.id));
58292
- const rank = new Map(ranked.map((r, i2) => [r.id, i2]));
58398
+ const ranked2 = rankByRelevance(store, priors.file.id, pool.map((n) => n.id));
58399
+ const rank = new Map(ranked2.map((r, i2) => [r.id, i2]));
58293
58400
  const byRank = (a, b) => (rank.get(a.id) ?? 0) - (rank.get(b.id) ?? 0);
58294
58401
  priors.openProblems.sort(byRank);
58295
58402
  priors.constraints.sort(byRank);
@@ -58325,8 +58432,8 @@ ${lines.join("\n")}
58325
58432
  function editVerdict(store, relPath) {
58326
58433
  const priors = priorsForFile(store, relPath);
58327
58434
  if (!priors || priors.openProblems.length === 0) return null;
58328
- const ranked = rankByRelevance(store, priors.file.id, priors.openProblems.map((n) => n.id));
58329
- const rank = new Map(ranked.map((r, i2) => [r.id, i2]));
58435
+ const ranked2 = rankByRelevance(store, priors.file.id, priors.openProblems.map((n) => n.id));
58436
+ const rank = new Map(ranked2.map((r, i2) => [r.id, i2]));
58330
58437
  const asked = [...priors.openProblems].sort((a, b) => (rank.get(a.id) ?? 0) - (rank.get(b.id) ?? 0)).slice(0, 3);
58331
58438
  const lines = asked.map(
58332
58439
  (p) => closableByCaller(p) ? recallLine(p, `fixed: ${TAG_EXAMPLE.fix(p.id)} \xB7 not a real problem: retract it (block below) \xB7 still open: say nothing`) : recallLine(p, `another membrane's \u2014 not yours to close: ${TAG_EXAMPLE.confirm(p.id)} it held \xB7 ${TAG_EXAMPLE.refute(p.id)}`)
@@ -58815,7 +58922,7 @@ function buildWebUi(deps) {
58815
58922
  const transcriptPath = String(body2["transcript_path"] ?? "");
58816
58923
  const sessionId = String(body2["session_id"] ?? "");
58817
58924
  if (transcriptPath && deps.onTurn) {
58818
- deps.onTurn({ sessionId, transcriptPath });
58925
+ deps.onTurn({ sessionId, transcriptPath, ...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {} });
58819
58926
  }
58820
58927
  if (body2["hook_event_name"] === "SubagentStop" && typeof body2["agent_id"] === "string" && body2["agent_id"]) {
58821
58928
  deps.onSubagentStop?.(body2["agent_id"]);
@@ -58845,7 +58952,8 @@ function buildWebUi(deps) {
58845
58952
  sessionId,
58846
58953
  text: whole.text,
58847
58954
  ...messageId ? { messageId } : {},
58848
- ...agentId ? { agentId } : {}
58955
+ ...agentId ? { agentId } : {},
58956
+ ...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {}
58849
58957
  });
58850
58958
  }
58851
58959
  return c.json({ ok: true, ...whole === null ? { buffered: true } : {} });
@@ -61514,9 +61622,9 @@ var require_dispatcher_base = __commonJS({
61514
61622
  }
61515
61623
  close(callback) {
61516
61624
  if (callback === void 0) {
61517
- return new Promise((resolve10, reject) => {
61625
+ return new Promise((resolve11, reject) => {
61518
61626
  this.close((err2, data) => {
61519
- return err2 ? reject(err2) : resolve10(data);
61627
+ return err2 ? reject(err2) : resolve11(data);
61520
61628
  });
61521
61629
  });
61522
61630
  }
@@ -61554,12 +61662,12 @@ var require_dispatcher_base = __commonJS({
61554
61662
  err2 = null;
61555
61663
  }
61556
61664
  if (callback === void 0) {
61557
- return new Promise((resolve10, reject) => {
61665
+ return new Promise((resolve11, reject) => {
61558
61666
  this.destroy(err2, (err3, data) => {
61559
61667
  return err3 ? (
61560
61668
  /* istanbul ignore next: should never error */
61561
61669
  reject(err3)
61562
- ) : resolve10(data);
61670
+ ) : resolve11(data);
61563
61671
  });
61564
61672
  });
61565
61673
  }
@@ -63826,8 +63934,8 @@ var require_util2 = __commonJS({
63826
63934
  function createDeferredPromise() {
63827
63935
  let res;
63828
63936
  let rej;
63829
- const promise2 = new Promise((resolve10, reject) => {
63830
- res = resolve10;
63937
+ const promise2 = new Promise((resolve11, reject) => {
63938
+ res = resolve11;
63831
63939
  rej = reject;
63832
63940
  });
63833
63941
  return { promise: promise2, resolve: res, reject: rej };
@@ -65968,12 +66076,12 @@ upgrade: ${upgrade}\r
65968
66076
  cb();
65969
66077
  }
65970
66078
  }
65971
- const waitForDrain = () => new Promise((resolve10, reject) => {
66079
+ const waitForDrain = () => new Promise((resolve11, reject) => {
65972
66080
  assert2(callback === null);
65973
66081
  if (socket[kError]) {
65974
66082
  reject(socket[kError]);
65975
66083
  } else {
65976
- callback = resolve10;
66084
+ callback = resolve11;
65977
66085
  }
65978
66086
  });
65979
66087
  socket.on("close", onDrain).on("drain", onDrain);
@@ -66610,12 +66718,12 @@ var require_client_h2 = __commonJS({
66610
66718
  cb();
66611
66719
  }
66612
66720
  }
66613
- const waitForDrain = () => new Promise((resolve10, reject) => {
66721
+ const waitForDrain = () => new Promise((resolve11, reject) => {
66614
66722
  assert2(callback === null);
66615
66723
  if (socket[kError]) {
66616
66724
  reject(socket[kError]);
66617
66725
  } else {
66618
- callback = resolve10;
66726
+ callback = resolve11;
66619
66727
  }
66620
66728
  });
66621
66729
  h2stream.on("close", onDrain).on("drain", onDrain);
@@ -67092,16 +67200,16 @@ var require_client = __commonJS({
67092
67200
  return this[kNeedDrain] < 2;
67093
67201
  }
67094
67202
  async [kClose]() {
67095
- return new Promise((resolve10) => {
67203
+ return new Promise((resolve11) => {
67096
67204
  if (this[kSize]) {
67097
- this[kClosedResolve] = resolve10;
67205
+ this[kClosedResolve] = resolve11;
67098
67206
  } else {
67099
- resolve10(null);
67207
+ resolve11(null);
67100
67208
  }
67101
67209
  });
67102
67210
  }
67103
67211
  async [kDestroy](err2) {
67104
- return new Promise((resolve10) => {
67212
+ return new Promise((resolve11) => {
67105
67213
  const requests = this[kQueue].splice(this[kPendingIdx]);
67106
67214
  for (let i2 = 0; i2 < requests.length; i2++) {
67107
67215
  const request = requests[i2];
@@ -67112,7 +67220,7 @@ var require_client = __commonJS({
67112
67220
  this[kClosedResolve]();
67113
67221
  this[kClosedResolve] = null;
67114
67222
  }
67115
- resolve10(null);
67223
+ resolve11(null);
67116
67224
  };
67117
67225
  if (this[kHTTPContext]) {
67118
67226
  this[kHTTPContext].destroy(err2, callback);
@@ -67163,7 +67271,7 @@ var require_client = __commonJS({
67163
67271
  });
67164
67272
  }
67165
67273
  try {
67166
- const socket = await new Promise((resolve10, reject) => {
67274
+ const socket = await new Promise((resolve11, reject) => {
67167
67275
  client[kConnector]({
67168
67276
  host,
67169
67277
  hostname: hostname3,
@@ -67175,7 +67283,7 @@ var require_client = __commonJS({
67175
67283
  if (err2) {
67176
67284
  reject(err2);
67177
67285
  } else {
67178
- resolve10(socket2);
67286
+ resolve11(socket2);
67179
67287
  }
67180
67288
  });
67181
67289
  });
@@ -67511,8 +67619,8 @@ var require_pool_base = __commonJS({
67511
67619
  if (this[kQueue].isEmpty()) {
67512
67620
  await Promise.all(this[kClients].map((c) => c.close()));
67513
67621
  } else {
67514
- await new Promise((resolve10) => {
67515
- this[kClosedResolve] = resolve10;
67622
+ await new Promise((resolve11) => {
67623
+ this[kClosedResolve] = resolve11;
67516
67624
  });
67517
67625
  }
67518
67626
  }
@@ -68727,7 +68835,7 @@ var require_readable = __commonJS({
68727
68835
  if (this._readableState.closeEmitted) {
68728
68836
  return null;
68729
68837
  }
68730
- return await new Promise((resolve10, reject) => {
68838
+ return await new Promise((resolve11, reject) => {
68731
68839
  if (this[kContentLength] > limit) {
68732
68840
  this.destroy(new AbortError());
68733
68841
  }
@@ -68740,7 +68848,7 @@ var require_readable = __commonJS({
68740
68848
  if (signal?.aborted) {
68741
68849
  reject(signal.reason ?? new AbortError());
68742
68850
  } else {
68743
- resolve10(null);
68851
+ resolve11(null);
68744
68852
  }
68745
68853
  }).on("error", noop).on("data", function(chunk) {
68746
68854
  limit -= chunk.length;
@@ -68759,7 +68867,7 @@ var require_readable = __commonJS({
68759
68867
  }
68760
68868
  async function consume(stream, type) {
68761
68869
  assert2(!stream[kConsume]);
68762
- return new Promise((resolve10, reject) => {
68870
+ return new Promise((resolve11, reject) => {
68763
68871
  if (isUnusable(stream)) {
68764
68872
  const rState = stream._readableState;
68765
68873
  if (rState.destroyed && rState.closeEmitted === false) {
@@ -68776,7 +68884,7 @@ var require_readable = __commonJS({
68776
68884
  stream[kConsume] = {
68777
68885
  type,
68778
68886
  stream,
68779
- resolve: resolve10,
68887
+ resolve: resolve11,
68780
68888
  reject,
68781
68889
  length: 0,
68782
68890
  body: []
@@ -68846,18 +68954,18 @@ var require_readable = __commonJS({
68846
68954
  return buffer;
68847
68955
  }
68848
68956
  function consumeEnd(consume2) {
68849
- const { type, body: body2, resolve: resolve10, stream, length } = consume2;
68957
+ const { type, body: body2, resolve: resolve11, stream, length } = consume2;
68850
68958
  try {
68851
68959
  if (type === "text") {
68852
- resolve10(chunksDecode(body2, length));
68960
+ resolve11(chunksDecode(body2, length));
68853
68961
  } else if (type === "json") {
68854
- resolve10(JSON.parse(chunksDecode(body2, length)));
68962
+ resolve11(JSON.parse(chunksDecode(body2, length)));
68855
68963
  } else if (type === "arrayBuffer") {
68856
- resolve10(chunksConcat(body2, length).buffer);
68964
+ resolve11(chunksConcat(body2, length).buffer);
68857
68965
  } else if (type === "blob") {
68858
- resolve10(new Blob(body2, { type: stream[kContentType] }));
68966
+ resolve11(new Blob(body2, { type: stream[kContentType] }));
68859
68967
  } else if (type === "bytes") {
68860
- resolve10(chunksConcat(body2, length));
68968
+ resolve11(chunksConcat(body2, length));
68861
68969
  }
68862
68970
  consumeFinish(consume2);
68863
68971
  } catch (err2) {
@@ -69114,9 +69222,9 @@ var require_api_request = __commonJS({
69114
69222
  };
69115
69223
  function request(opts, callback) {
69116
69224
  if (callback === void 0) {
69117
- return new Promise((resolve10, reject) => {
69225
+ return new Promise((resolve11, reject) => {
69118
69226
  request.call(this, opts, (err2, data) => {
69119
- return err2 ? reject(err2) : resolve10(data);
69227
+ return err2 ? reject(err2) : resolve11(data);
69120
69228
  });
69121
69229
  });
69122
69230
  }
@@ -69339,9 +69447,9 @@ var require_api_stream = __commonJS({
69339
69447
  };
69340
69448
  function stream(opts, factory, callback) {
69341
69449
  if (callback === void 0) {
69342
- return new Promise((resolve10, reject) => {
69450
+ return new Promise((resolve11, reject) => {
69343
69451
  stream.call(this, opts, factory, (err2, data) => {
69344
- return err2 ? reject(err2) : resolve10(data);
69452
+ return err2 ? reject(err2) : resolve11(data);
69345
69453
  });
69346
69454
  });
69347
69455
  }
@@ -69626,9 +69734,9 @@ var require_api_upgrade = __commonJS({
69626
69734
  };
69627
69735
  function upgrade(opts, callback) {
69628
69736
  if (callback === void 0) {
69629
- return new Promise((resolve10, reject) => {
69737
+ return new Promise((resolve11, reject) => {
69630
69738
  upgrade.call(this, opts, (err2, data) => {
69631
- return err2 ? reject(err2) : resolve10(data);
69739
+ return err2 ? reject(err2) : resolve11(data);
69632
69740
  });
69633
69741
  });
69634
69742
  }
@@ -69720,9 +69828,9 @@ var require_api_connect = __commonJS({
69720
69828
  };
69721
69829
  function connect(opts, callback) {
69722
69830
  if (callback === void 0) {
69723
- return new Promise((resolve10, reject) => {
69831
+ return new Promise((resolve11, reject) => {
69724
69832
  connect.call(this, opts, (err2, data) => {
69725
- return err2 ? reject(err2) : resolve10(data);
69833
+ return err2 ? reject(err2) : resolve11(data);
69726
69834
  });
69727
69835
  });
69728
69836
  }
@@ -73584,7 +73692,7 @@ var require_fetch = __commonJS({
73584
73692
  function dispatch({ body: body2 }) {
73585
73693
  const url2 = requestCurrentURL(request);
73586
73694
  const agent = fetchParams.controller.dispatcher;
73587
- return new Promise((resolve10, reject) => agent.dispatch(
73695
+ return new Promise((resolve11, reject) => agent.dispatch(
73588
73696
  {
73589
73697
  path: url2.pathname + url2.search,
73590
73698
  origin: url2.origin,
@@ -73660,7 +73768,7 @@ var require_fetch = __commonJS({
73660
73768
  }
73661
73769
  }
73662
73770
  const onError = this.onError.bind(this);
73663
- resolve10({
73771
+ resolve11({
73664
73772
  status,
73665
73773
  statusText,
73666
73774
  headersList,
@@ -73706,7 +73814,7 @@ var require_fetch = __commonJS({
73706
73814
  for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
73707
73815
  headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
73708
73816
  }
73709
- resolve10({
73817
+ resolve11({
73710
73818
  status,
73711
73819
  statusText: STATUS_CODES[status],
73712
73820
  headersList,
@@ -77345,8 +77453,8 @@ var require_util8 = __commonJS({
77345
77453
  return true;
77346
77454
  }
77347
77455
  function delay(ms) {
77348
- return new Promise((resolve10) => {
77349
- setTimeout(resolve10, ms).unref();
77456
+ return new Promise((resolve11) => {
77457
+ setTimeout(resolve11, ms).unref();
77350
77458
  });
77351
77459
  }
77352
77460
  module2.exports = {
@@ -78034,16 +78142,16 @@ __export(witness_ledger_exports, {
78034
78142
  summarizeWitnessLedger: () => summarizeWitnessLedger,
78035
78143
  witnessLedgerPath: () => witnessLedgerPath
78036
78144
  });
78037
- import { appendFileSync as appendFileSync3, existsSync as existsSync27, readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
78038
- import { join as join35 } from "node:path";
78145
+ import { appendFileSync as appendFileSync3, existsSync as existsSync28, readFileSync as readFileSync32, writeFileSync as writeFileSync22 } from "node:fs";
78146
+ import { join as join36 } from "node:path";
78039
78147
  function witnessLedgerPath(configDir) {
78040
- return join35(configDir, "witness-ledger.jsonl");
78148
+ return join36(configDir, "witness-ledger.jsonl");
78041
78149
  }
78042
78150
  function appendWitnessLedger(configDir, entry) {
78043
78151
  const path3 = witnessLedgerPath(configDir);
78044
78152
  try {
78045
78153
  appendFileSync3(path3, JSON.stringify(entry) + "\n");
78046
- const lines = readFileSync31(path3, "utf8").split("\n").filter(Boolean);
78154
+ const lines = readFileSync32(path3, "utf8").split("\n").filter(Boolean);
78047
78155
  if (lines.length > LEDGER_MAX_LINES) {
78048
78156
  writeFileSync22(path3, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
78049
78157
  }
@@ -78052,9 +78160,9 @@ function appendWitnessLedger(configDir, entry) {
78052
78160
  }
78053
78161
  function readWitnessLedger(configDir) {
78054
78162
  const path3 = witnessLedgerPath(configDir);
78055
- if (!existsSync27(path3)) return [];
78163
+ if (!existsSync28(path3)) return [];
78056
78164
  try {
78057
- return readFileSync31(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
78165
+ return readFileSync32(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
78058
78166
  } catch {
78059
78167
  return [];
78060
78168
  }
@@ -78124,11 +78232,11 @@ function isLive2(verb) {
78124
78232
  function nextHtml(n, opts) {
78125
78233
  if (!n) return "";
78126
78234
  const cmd2 = `errata ${n.verb}${n.arg ? " " + n.arg : ""}`;
78127
- const live3 = isLive2(n.verb);
78128
- if (!live3 && !opts.includeFutureVerbs) return "";
78235
+ const live4 = isLive2(n.verb);
78236
+ if (!live4 && !opts.includeFutureVerbs) return "";
78129
78237
  const hint = n.hint ? ` \u2014 ${esc3(n.hint)}` : "";
78130
- const cls = live3 ? "next" : "next soon";
78131
- const tag = live3 ? `<code>${esc3(cmd2)}</code>` : `<span class="vsoon">${esc3(cmd2)} \xB7 soon</span>`;
78238
+ const cls = live4 ? "next" : "next soon";
78239
+ const tag = live4 ? `<code>${esc3(cmd2)}</code>` : `<span class="vsoon">${esc3(cmd2)} \xB7 soon</span>`;
78132
78240
  return `<div class="${cls}">next: ${tag}${hint}</div>`;
78133
78241
  }
78134
78242
  function shell(title, body2) {
@@ -78493,12 +78601,12 @@ var init_report_render = __esm({
78493
78601
 
78494
78602
  // src/cli.ts
78495
78603
  init_src6();
78496
- import { closeSync as closeSync3, existsSync as existsSync40, openSync as openSync3, readFileSync as readFileSync48, renameSync as renameSync10, statSync as statSync16 } from "node:fs";
78497
- import { join as join56, resolve as pathResolve2 } from "node:path";
78604
+ import { closeSync as closeSync3, existsSync as existsSync41, openSync as openSync3, readFileSync as readFileSync49, renameSync as renameSync10, statSync as statSync17 } from "node:fs";
78605
+ import { join as join57, resolve as pathResolve2 } from "node:path";
78498
78606
  import { spawn as spawn5 } from "node:child_process";
78499
78607
 
78500
78608
  // src/daemon.ts
78501
- import { existsSync as existsSync29, writeFileSync as writeFileSync25 } from "node:fs";
78609
+ import { existsSync as existsSync30, writeFileSync as writeFileSync25 } from "node:fs";
78502
78610
 
78503
78611
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.34/node_modules/@hono/node-server/dist/index.mjs
78504
78612
  import { createServer as createServerHTTP } from "http";
@@ -78928,7 +79036,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
78928
79036
  });
78929
79037
  if (!chunk) {
78930
79038
  if (i2 === 1) {
78931
- await new Promise((resolve10) => setTimeout(resolve10));
79039
+ await new Promise((resolve11) => setTimeout(resolve11));
78932
79040
  maxReadCount = 3;
78933
79041
  continue;
78934
79042
  }
@@ -79077,6 +79185,32 @@ init_webui();
79077
79185
  init_config();
79078
79186
  init_lock();
79079
79187
 
79188
+ // src/replay-checkout.ts
79189
+ import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync7 } from "node:fs";
79190
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join19, resolve as resolve6 } from "node:path";
79191
+ var REPLAY_MARKER = "errata-replay";
79192
+ function gitDirOf(cwd) {
79193
+ for (let dir = resolve6(cwd); ; dir = dirname9(dir)) {
79194
+ const dotGit = join19(dir, ".git");
79195
+ if (existsSync19(dotGit)) {
79196
+ try {
79197
+ if (statSync7(dotGit).isDirectory()) return dotGit;
79198
+ const m = /^gitdir:\s*(.+)$/m.exec(readFileSync18(dotGit, "utf8"));
79199
+ if (!m) return null;
79200
+ const target = m[1].trim();
79201
+ return isAbsolute4(target) ? target : resolve6(dir, target);
79202
+ } catch {
79203
+ return null;
79204
+ }
79205
+ }
79206
+ if (dirname9(dir) === dir) return null;
79207
+ }
79208
+ }
79209
+ function isReplayCheckout(cwd) {
79210
+ const gitDir = gitDirOf(cwd);
79211
+ return gitDir != null && existsSync19(join19(gitDir, REPLAY_MARKER));
79212
+ }
79213
+
79080
79214
  // src/activity-feed.ts
79081
79215
  var LABEL_MAX = 120;
79082
79216
  var DEFAULT_TAIL = 20;
@@ -79182,8 +79316,8 @@ function knowledgeTag(label, attrs) {
79182
79316
 
79183
79317
  // src/engine.ts
79184
79318
  import { execFileSync as execFileSync6 } from "node:child_process";
79185
- import { existsSync as existsSync28, statSync as statSync11, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync33, writeFileSync as writeFileSync24 } from "node:fs";
79186
- import { basename as basename8, join as join37, relative as relative6, sep as sep5 } from "node:path";
79319
+ import { existsSync as existsSync29, statSync as statSync12, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync34, writeFileSync as writeFileSync24 } from "node:fs";
79320
+ import { basename as basename8, join as join38, relative as relative6, sep as sep5 } from "node:path";
79187
79321
 
79188
79322
  // src/coalesced-file-pass.ts
79189
79323
  function createCoalescedFilePass(delayMs, run3, onError) {
@@ -79227,8 +79361,8 @@ function createCoalescedFilePass(delayMs, run3, onError) {
79227
79361
 
79228
79362
  // src/source-watcher.ts
79229
79363
  import { EventEmitter as EventEmitter2 } from "node:events";
79230
- import { readdirSync as readdirSync6, statSync as statSync7, watch as watch2 } from "node:fs";
79231
- import { join as join21, sep as sep4 } from "node:path";
79364
+ import { readdirSync as readdirSync6, statSync as statSync8, watch as watch2 } from "node:fs";
79365
+ import { join as join22, sep as sep4 } from "node:path";
79232
79366
 
79233
79367
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
79234
79368
  import { stat as statcb } from "fs";
@@ -79959,9 +80093,9 @@ var NodeFsHandler = class {
79959
80093
  if (this.fsw.closed) {
79960
80094
  return;
79961
80095
  }
79962
- const dirname21 = sysPath.dirname(file2);
80096
+ const dirname22 = sysPath.dirname(file2);
79963
80097
  const basename11 = sysPath.basename(file2);
79964
- const parent = this.fsw._getWatchedDir(dirname21);
80098
+ const parent = this.fsw._getWatchedDir(dirname22);
79965
80099
  let prevStats = stats;
79966
80100
  if (parent.has(basename11))
79967
80101
  return;
@@ -79988,7 +80122,7 @@ var NodeFsHandler = class {
79988
80122
  prevStats = newStats2;
79989
80123
  }
79990
80124
  } catch (error48) {
79991
- this.fsw._remove(dirname21, basename11);
80125
+ this.fsw._remove(dirname22, basename11);
79992
80126
  }
79993
80127
  } else if (parent.has(basename11)) {
79994
80128
  const at = newStats.atimeMs;
@@ -80084,7 +80218,7 @@ var NodeFsHandler = class {
80084
80218
  this._addToNodeFs(path3, initialAdd, wh, depth + 1);
80085
80219
  }
80086
80220
  }).on(EV.ERROR, this._boundHandleError);
80087
- return new Promise((resolve10, reject) => {
80221
+ return new Promise((resolve11, reject) => {
80088
80222
  if (!stream)
80089
80223
  return reject();
80090
80224
  stream.once(STR_END, () => {
@@ -80093,7 +80227,7 @@ var NodeFsHandler = class {
80093
80227
  return;
80094
80228
  }
80095
80229
  const wasThrottled = throttler ? throttler.clear() : false;
80096
- resolve10(void 0);
80230
+ resolve11(void 0);
80097
80231
  previous.getChildren().filter((item2) => {
80098
80232
  return item2 !== directory && !current.has(item2);
80099
80233
  }).forEach((item2) => {
@@ -80958,13 +81092,13 @@ var NativeSourceWatcher = class extends EventEmitter2 {
80958
81092
  if (this.closed || this.handles.has(target)) return;
80959
81093
  let isDir;
80960
81094
  try {
80961
- isDir = statSync7(target).isDirectory();
81095
+ isDir = statSync8(target).isDirectory();
80962
81096
  } catch {
80963
81097
  return;
80964
81098
  }
80965
81099
  try {
80966
81100
  const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
80967
- const path3 = isDir ? name2 ? join21(target, name2.toString()) : null : target;
81101
+ const path3 = isDir ? name2 ? join22(target, name2.toString()) : null : target;
80968
81102
  if (!path3) {
80969
81103
  this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
80970
81104
  this.scheduleReconcile(target, isDir);
@@ -81012,7 +81146,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81012
81146
  const files = /* @__PURE__ */ new Map();
81013
81147
  const add = (path3) => {
81014
81148
  try {
81015
- files.set(path3, signature(statSync7(path3)));
81149
+ files.set(path3, signature(statSync8(path3)));
81016
81150
  } catch {
81017
81151
  }
81018
81152
  };
@@ -81030,7 +81164,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81030
81164
  continue;
81031
81165
  }
81032
81166
  for (const entry of entries) {
81033
- const path3 = join21(dir, entry.name);
81167
+ const path3 = join22(dir, entry.name);
81034
81168
  if (this.ignored(path3)) continue;
81035
81169
  if (entry.isDirectory()) dirs.push(path3);
81036
81170
  else if (entry.isFile()) add(path3);
@@ -81067,7 +81201,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81067
81201
  let isFile;
81068
81202
  let sig;
81069
81203
  try {
81070
- const s = statSync7(path3);
81204
+ const s = statSync8(path3);
81071
81205
  if (s.isDirectory()) return;
81072
81206
  isFile = s.isFile();
81073
81207
  sig = signature(s);
@@ -81341,9 +81475,9 @@ init_src6();
81341
81475
  init_session_registry();
81342
81476
 
81343
81477
  // src/snapshot-reuse.ts
81344
- import { readFileSync as readFileSync18, renameSync as renameSync3, statSync as statSync8, writeFileSync as writeFileSync14 } from "node:fs";
81478
+ import { readFileSync as readFileSync19, renameSync as renameSync3, statSync as statSync9, writeFileSync as writeFileSync14 } from "node:fs";
81345
81479
  import { fileURLToPath as fileURLToPath2 } from "node:url";
81346
- import { dirname as dirname11, join as join22 } from "node:path";
81480
+ import { dirname as dirname12, join as join23 } from "node:path";
81347
81481
  function revisitFlagsUnchanged(store, held, flaggedNow) {
81348
81482
  if (held.anySeq === void 0 || held.revisitIds === void 0 || !store.changedAmong) return false;
81349
81483
  const watched = [.../* @__PURE__ */ new Set([...held.revisitIds, ...flaggedNow])];
@@ -81359,7 +81493,7 @@ function snapshotCodeIdentity(version3) {
81359
81493
  if (codeIdentityMemo === void 0) {
81360
81494
  let built = "unknown";
81361
81495
  try {
81362
- built = String(statSync8(fileURLToPath2(import.meta.url)).mtimeMs);
81496
+ built = String(statSync9(fileURLToPath2(import.meta.url)).mtimeMs);
81363
81497
  } catch {
81364
81498
  }
81365
81499
  codeIdentityMemo = `${version3}@${built}`;
@@ -81367,11 +81501,11 @@ function snapshotCodeIdentity(version3) {
81367
81501
  return codeIdentityMemo;
81368
81502
  }
81369
81503
  function heldSnapshotPath(configDir) {
81370
- return join22(configDir, "snapshot-held.json");
81504
+ return join23(configDir, "snapshot-held.json");
81371
81505
  }
81372
81506
  function loadHeldSnapshot(path3) {
81373
81507
  try {
81374
- const held = JSON.parse(readFileSync18(path3, "utf8"));
81508
+ const held = JSON.parse(readFileSync19(path3, "utf8"));
81375
81509
  return typeof held?.key === "string" && typeof held.at === "number" ? held : null;
81376
81510
  } catch {
81377
81511
  return null;
@@ -81379,7 +81513,7 @@ function loadHeldSnapshot(path3) {
81379
81513
  }
81380
81514
  function saveHeldSnapshot(path3, held) {
81381
81515
  try {
81382
- const tmp = join22(dirname11(path3), `.${process.pid}.snapshot-held.tmp`);
81516
+ const tmp = join23(dirname12(path3), `.${process.pid}.snapshot-held.tmp`);
81383
81517
  writeFileSync14(tmp, JSON.stringify(held));
81384
81518
  renameSync3(tmp, path3);
81385
81519
  } catch {
@@ -81411,8 +81545,8 @@ function createSubagentState() {
81411
81545
  for (const [id, a] of agents) if (nowMs - a.lastSeenMs > SUBAGENT_IDLE_TTL_MS) agents.delete(id);
81412
81546
  while (agents.size > MAX_AGENTS) agents.delete(agents.keys().next().value);
81413
81547
  for (const [sid, list] of pending) {
81414
- const live3 = list.filter((s) => nowMs - s.atMs <= SPAWN_CLAIM_TTL_MS);
81415
- if (live3.length) pending.set(sid, live3);
81548
+ const live4 = list.filter((s) => nowMs - s.atMs <= SPAWN_CLAIM_TTL_MS);
81549
+ if (live4.length) pending.set(sid, live4);
81416
81550
  else pending.delete(sid);
81417
81551
  }
81418
81552
  };
@@ -81494,12 +81628,12 @@ function walkIntent(store, intent, opts) {
81494
81628
  if (out2.length >= opts.limit) return out2;
81495
81629
  const shown = new Set(out2.map((h) => h.node.id));
81496
81630
  const seedIds = new Set(entries.map((h) => h.node.id));
81497
- const ranked = burstFromSeeds(
81631
+ const ranked2 = burstFromSeeds(
81498
81632
  store,
81499
81633
  entries.map((h) => ({ id: h.node.id, label: h.node.label, weight: h.coverage * h.coverage })),
81500
81634
  { limit: opts.limit * 10, typeRelevanceForSeeds: false }
81501
81635
  );
81502
- for (const r of ranked) {
81636
+ for (const r of ranked2) {
81503
81637
  if (out2.length >= opts.limit) break;
81504
81638
  if (shown.has(r.id) || seedIds.has(r.id)) continue;
81505
81639
  const n = r.node;
@@ -81575,8 +81709,8 @@ init_review2();
81575
81709
 
81576
81710
  // src/turn.ts
81577
81711
  init_checkout_root();
81578
- import { closeSync as closeSync2, existsSync as existsSync19, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync9 } from "node:fs";
81579
- import { basename as basename6, delimiter, dirname as dirname12, join as join23, normalize as normalize3 } from "node:path";
81712
+ import { closeSync as closeSync2, existsSync as existsSync20, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
81713
+ import { basename as basename6, delimiter, dirname as dirname13, join as join24, normalize as normalize3 } from "node:path";
81580
81714
  import { homedir as homedir4 } from "node:os";
81581
81715
  import { createHash as createHash16 } from "node:crypto";
81582
81716
  function completeJsonlPrefix(buf) {
@@ -81964,11 +82098,11 @@ function turnsSince(turns, mark) {
81964
82098
  return at >= 0 ? turns.slice(at + 1) : turns;
81965
82099
  }
81966
82100
  function claudeProjectDir(cwd, home = homedir4()) {
81967
- return join23(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
82101
+ return join24(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
81968
82102
  }
81969
82103
  function recentTranscripts(cwd, opts = {}) {
81970
82104
  const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
81971
- if (!existsSync19(dir)) return [];
82105
+ if (!existsSync20(dir)) return [];
81972
82106
  let names;
81973
82107
  try {
81974
82108
  names = readdirSync7(dir);
@@ -81979,10 +82113,10 @@ function recentTranscripts(cwd, opts = {}) {
81979
82113
  const refs = [];
81980
82114
  for (const name2 of names) {
81981
82115
  if (!name2.endsWith(".jsonl")) continue;
81982
- const path3 = join23(dir, name2);
82116
+ const path3 = join24(dir, name2);
81983
82117
  let mtimeMs;
81984
82118
  try {
81985
- mtimeMs = statSync9(path3).mtimeMs;
82119
+ mtimeMs = statSync10(path3).mtimeMs;
81986
82120
  } catch {
81987
82121
  continue;
81988
82122
  }
@@ -81994,8 +82128,8 @@ function recentTranscripts(cwd, opts = {}) {
81994
82128
  }
81995
82129
  function subagentTranscripts(mainTranscriptPath, sessionId) {
81996
82130
  if (!mainTranscriptPath || !sessionId) return [];
81997
- const dir = join23(dirname12(mainTranscriptPath), sessionId, "subagents");
81998
- if (!existsSync19(dir)) return [];
82131
+ const dir = join24(dirname13(mainTranscriptPath), sessionId, "subagents");
82132
+ if (!existsSync20(dir)) return [];
81999
82133
  let names;
82000
82134
  try {
82001
82135
  names = readdirSync7(dir);
@@ -82005,10 +82139,10 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
82005
82139
  const refs = [];
82006
82140
  for (const name2 of names) {
82007
82141
  if (!name2.endsWith(".jsonl")) continue;
82008
- const path3 = join23(dir, name2);
82142
+ const path3 = join24(dir, name2);
82009
82143
  let mtimeMs;
82010
82144
  try {
82011
- mtimeMs = statSync9(path3).mtimeMs;
82145
+ mtimeMs = statSync10(path3).mtimeMs;
82012
82146
  } catch {
82013
82147
  continue;
82014
82148
  }
@@ -82024,8 +82158,8 @@ function splitPathList(value, sep7 = delimiter) {
82024
82158
  function codexSessionRoots(env2 = process.env, home = homedir4()) {
82025
82159
  const roots = /* @__PURE__ */ new Set();
82026
82160
  for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
82027
- if (env2["CODEX_HOME"]) roots.add(join23(env2["CODEX_HOME"], "sessions"));
82028
- roots.add(join23(home, ".codex", "sessions"));
82161
+ if (env2["CODEX_HOME"]) roots.add(join24(env2["CODEX_HOME"], "sessions"));
82162
+ roots.add(join24(home, ".codex", "sessions"));
82029
82163
  return [...roots];
82030
82164
  }
82031
82165
  function readCodexRolloutIdentity(path3) {
@@ -82079,7 +82213,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82079
82213
  const owner = checkoutRootOf(cwd);
82080
82214
  const owners = /* @__PURE__ */ new Map();
82081
82215
  for (const root of codexSessionRoots(opts.env, opts.home)) {
82082
- if (!existsSync19(root)) {
82216
+ if (!existsSync20(root)) {
82083
82217
  codexRolloutActivity.delete(root);
82084
82218
  continue;
82085
82219
  }
@@ -82097,10 +82231,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82097
82231
  continue;
82098
82232
  }
82099
82233
  for (const name2 of names) {
82100
- const full = join23(dir, name2);
82234
+ const full = join24(dir, name2);
82101
82235
  let st;
82102
82236
  try {
82103
- st = statSync9(full);
82237
+ st = statSync10(full);
82104
82238
  } catch {
82105
82239
  continue;
82106
82240
  }
@@ -82139,8 +82273,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82139
82273
  function geminiSessionRoots(env2 = process.env, home = homedir4()) {
82140
82274
  const roots = /* @__PURE__ */ new Set();
82141
82275
  for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
82142
- if (env2["GEMINI_CLI_HOME"]) roots.add(join23(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
82143
- roots.add(join23(home, ".gemini", "tmp"));
82276
+ if (env2["GEMINI_CLI_HOME"]) roots.add(join24(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
82277
+ roots.add(join24(home, ".gemini", "tmp"));
82144
82278
  return [...roots];
82145
82279
  }
82146
82280
  function geminiProjectHash(cwd) {
@@ -82180,7 +82314,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82180
82314
  const hashes = geminiHashesFor(cwd);
82181
82315
  const out2 = [];
82182
82316
  for (const root of geminiSessionRoots(opts.env, opts.home)) {
82183
- if (!existsSync19(root)) continue;
82317
+ if (!existsSync20(root)) continue;
82184
82318
  let slugs;
82185
82319
  try {
82186
82320
  slugs = readdirSync7(root);
@@ -82188,7 +82322,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82188
82322
  continue;
82189
82323
  }
82190
82324
  for (const slug2 of slugs) {
82191
- const chats = join23(root, slug2, "chats");
82325
+ const chats = join24(root, slug2, "chats");
82192
82326
  let names;
82193
82327
  try {
82194
82328
  names = readdirSync7(chats);
@@ -82197,10 +82331,10 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82197
82331
  }
82198
82332
  for (const name2 of names) {
82199
82333
  if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
82200
- const full = join23(chats, name2);
82334
+ const full = join24(chats, name2);
82201
82335
  let st;
82202
82336
  try {
82203
- st = statSync9(full);
82337
+ st = statSync10(full);
82204
82338
  } catch {
82205
82339
  continue;
82206
82340
  }
@@ -82217,8 +82351,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82217
82351
  function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
82218
82352
  const roots = /* @__PURE__ */ new Set();
82219
82353
  for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
82220
- if (env2["XDG_DATA_HOME"]) roots.add(join23(env2["XDG_DATA_HOME"], "opencode", "errata"));
82221
- roots.add(join23(home, ".local", "share", "opencode", "errata"));
82354
+ if (env2["XDG_DATA_HOME"]) roots.add(join24(env2["XDG_DATA_HOME"], "opencode", "errata"));
82355
+ roots.add(join24(home, ".local", "share", "opencode", "errata"));
82222
82356
  return [...roots];
82223
82357
  }
82224
82358
  function readOpencodeTranscriptDirectory(path3) {
@@ -82251,7 +82385,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
82251
82385
  }
82252
82386
  const out2 = [];
82253
82387
  for (const root of opencodeSessionRoots(opts.env, opts.home)) {
82254
- if (!existsSync19(root)) continue;
82388
+ if (!existsSync20(root)) continue;
82255
82389
  let names;
82256
82390
  try {
82257
82391
  names = readdirSync7(root);
@@ -82260,10 +82394,10 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
82260
82394
  }
82261
82395
  for (const name2 of names) {
82262
82396
  if (!name2.endsWith(".jsonl")) continue;
82263
- const full = join23(root, name2);
82397
+ const full = join24(root, name2);
82264
82398
  let st;
82265
82399
  try {
82266
- st = statSync9(full);
82400
+ st = statSync10(full);
82267
82401
  } catch {
82268
82402
  continue;
82269
82403
  }
@@ -82283,7 +82417,7 @@ init_src2();
82283
82417
  init_agent_signals();
82284
82418
  init_tool_index();
82285
82419
  init_src5();
82286
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync15 } from "node:fs";
82420
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
82287
82421
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
82288
82422
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
82289
82423
  var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
@@ -83118,7 +83252,7 @@ function writePrimingHandles(path3, nodes, now = Date.now()) {
83118
83252
  }
83119
83253
  function readPrimingHandles(path3) {
83120
83254
  try {
83121
- return JSON.parse(readFileSync19(path3, "utf8"));
83255
+ return JSON.parse(readFileSync20(path3, "utf8"));
83122
83256
  } catch {
83123
83257
  return {};
83124
83258
  }
@@ -83720,8 +83854,8 @@ ${conversation}` }]
83720
83854
  // src/constraint-backfill.ts
83721
83855
  init_src5();
83722
83856
  init_src2();
83723
- import { existsSync as existsSync20, readFileSync as readFileSync20, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
83724
- import { join as join24 } from "node:path";
83857
+ import { existsSync as existsSync21, readFileSync as readFileSync21, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
83858
+ import { join as join25 } from "node:path";
83725
83859
  import { homedir as homedir5 } from "node:os";
83726
83860
  var BACKFILL_VERSION = 1;
83727
83861
  var EMPTY = {
@@ -83735,13 +83869,13 @@ var EMPTY = {
83735
83869
  recoverable: 0
83736
83870
  };
83737
83871
  function markerPath(configDir) {
83738
- return join24(configDir, "constraint-backfill.json");
83872
+ return join25(configDir, "constraint-backfill.json");
83739
83873
  }
83740
83874
  function alreadyDone(configDir) {
83741
83875
  const p = markerPath(configDir);
83742
- if (!existsSync20(p)) return false;
83876
+ if (!existsSync21(p)) return false;
83743
83877
  try {
83744
- const raw2 = JSON.parse(readFileSync20(p, "utf8"));
83878
+ const raw2 = JSON.parse(readFileSync21(p, "utf8"));
83745
83879
  return raw2?.version === BACKFILL_VERSION;
83746
83880
  } catch {
83747
83881
  return false;
@@ -83751,7 +83885,7 @@ function replay(root) {
83751
83885
  const statements2 = /* @__PURE__ */ new Set();
83752
83886
  const citedByFix = /* @__PURE__ */ new Set();
83753
83887
  const dir = claudeProjectDir(root, homedir5());
83754
- if (!existsSync20(dir)) return { statements: statements2, citedByFix };
83888
+ if (!existsSync21(dir)) return { statements: statements2, citedByFix };
83755
83889
  let names;
83756
83890
  try {
83757
83891
  names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
@@ -83761,7 +83895,7 @@ function replay(root) {
83761
83895
  for (const f of names) {
83762
83896
  let lines;
83763
83897
  try {
83764
- lines = readFileSync20(join24(dir, f), "utf8").split("\n");
83898
+ lines = readFileSync21(join25(dir, f), "utf8").split("\n");
83765
83899
  } catch {
83766
83900
  continue;
83767
83901
  }
@@ -83888,8 +84022,8 @@ function backfillConstraintKind(store, opts) {
83888
84022
  // src/edge-repair.ts
83889
84023
  init_src();
83890
84024
  init_src5();
83891
- import { existsSync as existsSync21, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
83892
- import { join as join25 } from "node:path";
84025
+ import { existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync17 } from "node:fs";
84026
+ import { join as join26 } from "node:path";
83893
84027
  function citeEdgeId(from, type, to) {
83894
84028
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
83895
84029
  }
@@ -83904,13 +84038,13 @@ var EMPTY2 = {
83904
84038
  byType: {}
83905
84039
  };
83906
84040
  function markerPath2(configDir) {
83907
- return join25(configDir, "edge-repair.json");
84041
+ return join26(configDir, "edge-repair.json");
83908
84042
  }
83909
84043
  function alreadyDone2(configDir) {
83910
84044
  const p = markerPath2(configDir);
83911
- if (!existsSync21(p)) return false;
84045
+ if (!existsSync22(p)) return false;
83912
84046
  try {
83913
- return JSON.parse(readFileSync21(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
84047
+ return JSON.parse(readFileSync22(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
83914
84048
  } catch {
83915
84049
  return false;
83916
84050
  }
@@ -83973,23 +84107,23 @@ function repairInvalidEdges(store, opts) {
83973
84107
  init_reconcile();
83974
84108
 
83975
84109
  // src/pass-ledger.ts
83976
- import { appendFileSync as appendFileSync2, existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync18 } from "node:fs";
83977
- import { join as join26 } from "node:path";
84110
+ import { appendFileSync as appendFileSync2, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync18 } from "node:fs";
84111
+ import { join as join27 } from "node:path";
83978
84112
 
83979
84113
  // src/isolate-census.ts
83980
- var live2 = 0;
84114
+ var live3 = 0;
83981
84115
  var spawnedTotal = 0;
83982
84116
  var peak = 0;
83983
84117
  function noteIsolateSpawned() {
83984
- live2 += 1;
84118
+ live3 += 1;
83985
84119
  spawnedTotal += 1;
83986
- if (live2 > peak) peak = live2;
84120
+ if (live3 > peak) peak = live3;
83987
84121
  }
83988
84122
  function noteIsolateExited() {
83989
- if (live2 > 0) live2 -= 1;
84123
+ if (live3 > 0) live3 -= 1;
83990
84124
  }
83991
84125
  function isolateCensus() {
83992
- return { live: live2, spawnedTotal, peak };
84126
+ return { live: live3, spawnedTotal, peak };
83993
84127
  }
83994
84128
 
83995
84129
  // src/io-reads.ts
@@ -84005,7 +84139,7 @@ var HOUR_MS = 36e5;
84005
84139
  var TRIM_EVERY = 50;
84006
84140
  var appendsSinceTrim = /* @__PURE__ */ new Map();
84007
84141
  function passLedgerPath(configDir) {
84008
- return join26(configDir, "pass-ledger.jsonl");
84142
+ return join27(configDir, "pass-ledger.jsonl");
84009
84143
  }
84010
84144
  function appendPassLedger(configDir, kind, durationMs, counts) {
84011
84145
  const path3 = passLedgerPath(configDir);
@@ -84037,7 +84171,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
84037
84171
  return;
84038
84172
  }
84039
84173
  appendsSinceTrim.set(path3, 0);
84040
- const lines = readFileSync22(path3, "utf8").split("\n").filter(Boolean);
84174
+ const lines = readFileSync23(path3, "utf8").split("\n").filter(Boolean);
84041
84175
  const keptByKind = /* @__PURE__ */ new Map();
84042
84176
  const tailHours = /* @__PURE__ */ new Map();
84043
84177
  const tailFloor = Date.now() - LEVEL_TAIL_DAYS * 24 * HOUR_MS;
@@ -84072,9 +84206,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
84072
84206
  }
84073
84207
  function readPassLedger(configDir) {
84074
84208
  const path3 = passLedgerPath(configDir);
84075
- if (!existsSync22(path3)) return [];
84209
+ if (!existsSync23(path3)) return [];
84076
84210
  try {
84077
- return readFileSync22(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
84211
+ return readFileSync23(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
84078
84212
  (e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
84079
84213
  ).map((e) => ({ ...e, counts: e.counts ?? {} }));
84080
84214
  } catch {
@@ -84214,8 +84348,8 @@ function recordEpisode(store, workspaceId2, t, delta, causal) {
84214
84348
  minted++;
84215
84349
  }
84216
84350
  if (s.change === "changed") {
84217
- const live3 = store.getNode(s.nodeId);
84218
- const prev = (live3?.version ?? 2) - 1;
84351
+ const live4 = store.getNode(s.nodeId);
84352
+ const prev = (live4?.version ?? 2) - 1;
84219
84353
  const frozenId = `${s.nodeId}@v${prev}`;
84220
84354
  if (store.getNode(frozenId)) {
84221
84355
  store.mergeEdge(producedEdge(id, frozenId, t));
@@ -84430,8 +84564,8 @@ var PassWorker = class {
84430
84564
  const id = this.nextId++;
84431
84565
  try {
84432
84566
  await this.ready;
84433
- return await new Promise((resolve10, reject) => {
84434
- this.pending.set(id, { resolve: resolve10, reject });
84567
+ return await new Promise((resolve11, reject) => {
84568
+ this.pending.set(id, { resolve: resolve11, reject });
84435
84569
  this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
84436
84570
  });
84437
84571
  } finally {
@@ -84466,12 +84600,12 @@ var PassWorker = class {
84466
84600
  });
84467
84601
  noteIsolateSpawned();
84468
84602
  this.worker = worker;
84469
- this.ready = new Promise((resolve10, reject) => {
84603
+ this.ready = new Promise((resolve11, reject) => {
84470
84604
  const onReady = (m) => {
84471
84605
  if (m?.ready) {
84472
84606
  worker.off("message", onReady);
84473
84607
  worker.off("error", onErr);
84474
- resolve10();
84608
+ resolve11();
84475
84609
  }
84476
84610
  };
84477
84611
  const onErr = (err2) => reject(err2);
@@ -84517,11 +84651,11 @@ init_outbox();
84517
84651
  init_src10();
84518
84652
  init_src();
84519
84653
  init_src2();
84520
- import { readFileSync as readFileSync23 } from "node:fs";
84521
- import { join as join27 } from "node:path";
84654
+ import { readFileSync as readFileSync24 } from "node:fs";
84655
+ import { join as join28 } from "node:path";
84522
84656
  function loadClaimIgnorePatterns(workspaceRoot) {
84523
84657
  try {
84524
- return readFileSync23(join27(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
84658
+ return readFileSync24(join28(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
84525
84659
  } catch {
84526
84660
  return [];
84527
84661
  }
@@ -84904,9 +85038,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
84904
85038
  // src/retrieval-stack.ts
84905
85039
  init_src();
84906
85040
  import { execFileSync as execFileSync5 } from "node:child_process";
84907
- import { existsSync as existsSync23, readFileSync as readFileSync24, statSync as statSync10 } from "node:fs";
85041
+ import { existsSync as existsSync24, readFileSync as readFileSync25, statSync as statSync11 } from "node:fs";
84908
85042
  import { homedir as homedir6 } from "node:os";
84909
- import { join as join28 } from "node:path";
85043
+ import { join as join29 } from "node:path";
84910
85044
  var RETRIEVAL_STACK_CAP = 24;
84911
85045
  var MANIFEST_SCAN_CAP = 400;
84912
85046
  var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
@@ -85196,51 +85330,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
85196
85330
  function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
85197
85331
  const read2 = (p) => {
85198
85332
  try {
85199
- return readFileSync24(p, "utf8");
85333
+ return readFileSync25(p, "utf8");
85200
85334
  } catch {
85201
85335
  return null;
85202
85336
  }
85203
85337
  };
85204
85338
  const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
85205
85339
  const home = homedir6();
85206
- const npm = parseNpmrcPolicy(texts(join28(root, ".npmrc"), join28(home, ".npmrc")));
85340
+ const npm = parseNpmrcPolicy(texts(join29(root, ".npmrc"), join29(home, ".npmrc")));
85207
85341
  const blocked = /* @__PURE__ */ new Set();
85208
85342
  if (!npm.defaultPublic) blocked.add("npm");
85209
85343
  if (pypiIndexIsPrivate(
85210
85344
  texts(
85211
- join28(root, "pip.conf"),
85212
- join28(root, "pip.ini"),
85213
- join28(root, "pyproject.toml"),
85214
- join28(root, "requirements.txt"),
85215
- join28(home, ".pip", "pip.conf"),
85216
- join28(home, ".config", "pip", "pip.conf"),
85217
- join28(env2["APPDATA"] ?? home, "pip", "pip.ini")
85345
+ join29(root, "pip.conf"),
85346
+ join29(root, "pip.ini"),
85347
+ join29(root, "pyproject.toml"),
85348
+ join29(root, "requirements.txt"),
85349
+ join29(home, ".pip", "pip.conf"),
85350
+ join29(home, ".config", "pip", "pip.conf"),
85351
+ join29(env2["APPDATA"] ?? home, "pip", "pip.ini")
85218
85352
  )
85219
85353
  )) {
85220
85354
  blocked.add("pypi");
85221
85355
  }
85222
85356
  if (cargoRegistryIsPrivate(
85223
85357
  texts(
85224
- join28(root, ".cargo", "config.toml"),
85225
- join28(root, ".cargo", "config"),
85226
- join28(home, ".cargo", "config.toml"),
85227
- join28(home, ".cargo", "config")
85358
+ join29(root, ".cargo", "config.toml"),
85359
+ join29(root, ".cargo", "config"),
85360
+ join29(home, ".cargo", "config.toml"),
85361
+ join29(home, ".cargo", "config")
85228
85362
  )
85229
85363
  )) {
85230
85364
  blocked.add("cargo");
85231
85365
  }
85232
85366
  if (nugetSourcesArePrivate(
85233
85367
  texts(
85234
- join28(root, "NuGet.config"),
85235
- join28(root, "nuget.config"),
85236
- join28(root, "NuGet.Config"),
85237
- join28(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
85238
- join28(home, ".nuget", "NuGet", "NuGet.Config")
85368
+ join29(root, "NuGet.config"),
85369
+ join29(root, "nuget.config"),
85370
+ join29(root, "NuGet.Config"),
85371
+ join29(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
85372
+ join29(home, ".nuget", "NuGet", "NuGet.Config")
85239
85373
  )
85240
85374
  )) {
85241
85375
  blocked.add("nuget");
85242
85376
  }
85243
- const goEnvFile = env2["GOENV"] ?? join28(env2["APPDATA"] ?? join28(home, ".config"), "go", "env");
85377
+ const goEnvFile = env2["GOENV"] ?? join29(env2["APPDATA"] ?? join29(home, ".config"), "go", "env");
85244
85378
  const goEnvText = read2(goEnvFile) ?? "";
85245
85379
  const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
85246
85380
  (k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
@@ -85251,10 +85385,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
85251
85385
  env2["GONOSUMCHECK"],
85252
85386
  ...fromFile
85253
85387
  ]);
85254
- const gemfiles = texts(join28(root, "Gemfile"));
85388
+ const gemfiles = texts(join29(root, "Gemfile"));
85255
85389
  if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
85256
85390
  if (mavenReposArePrivate(
85257
- texts(join28(root, "pom.xml"), join28(home, ".m2", "settings.xml"))
85391
+ texts(join29(root, "pom.xml"), join29(home, ".m2", "settings.xml"))
85258
85392
  )) {
85259
85393
  blocked.add("maven");
85260
85394
  }
@@ -85421,10 +85555,10 @@ function readDirectDependencies(root) {
85421
85555
  const familiesSeen = /* @__PURE__ */ new Set();
85422
85556
  for (const c of LOCKFILES) {
85423
85557
  if (familiesSeen.has(c.family)) continue;
85424
- const p = join28(root, c.file);
85425
- if (!existsSync23(p)) continue;
85558
+ const p = join29(root, c.file);
85559
+ if (!existsSync24(p)) continue;
85426
85560
  try {
85427
- const s = statSync10(p);
85561
+ const s = statSync11(p);
85428
85562
  stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
85429
85563
  } catch {
85430
85564
  continue;
@@ -85442,7 +85576,7 @@ function readDirectDependencies(root) {
85442
85576
  const direct = [];
85443
85577
  for (const { c, path: path3 } of found) {
85444
85578
  try {
85445
- direct.push(...c.parse(readFileSync24(path3, "utf8")).direct ?? []);
85579
+ direct.push(...c.parse(readFileSync25(path3, "utf8")).direct ?? []);
85446
85580
  } catch {
85447
85581
  }
85448
85582
  }
@@ -85485,14 +85619,14 @@ function manifestPaths(root) {
85485
85619
  "project.godot"
85486
85620
  ];
85487
85621
  return {
85488
- paths: ROOT_MANIFESTS.filter((f) => existsSync23(join28(root, f))),
85622
+ paths: ROOT_MANIFESTS.filter((f) => existsSync24(join29(root, f))),
85489
85623
  tracked: false,
85490
85624
  truncated: false
85491
85625
  };
85492
85626
  }
85493
85627
  var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
85494
85628
  function rootDeclaresWorkspace(root, texts) {
85495
- if (WORKSPACE_MARKERS.some((f) => existsSync23(join28(root, f)))) return true;
85629
+ if (WORKSPACE_MARKERS.some((f) => existsSync24(join29(root, f)))) return true;
85496
85630
  return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
85497
85631
  }
85498
85632
  var EMPTY_SCAN = { deps: [], self: [], complete: true };
@@ -85506,11 +85640,11 @@ function scanManifests(root) {
85506
85640
  const texts = /* @__PURE__ */ new Map();
85507
85641
  const stamps = [];
85508
85642
  for (const rel of paths) {
85509
- const abs = join28(root, rel);
85643
+ const abs = join29(root, rel);
85510
85644
  try {
85511
- const s = statSync10(abs);
85645
+ const s = statSync11(abs);
85512
85646
  stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
85513
- texts.set(rel, readFileSync24(abs, "utf8"));
85647
+ texts.set(rel, readFileSync25(abs, "utf8"));
85514
85648
  } catch {
85515
85649
  }
85516
85650
  }
@@ -85546,22 +85680,22 @@ function readRetrievalInputs(root, repoLocator) {
85546
85680
  }
85547
85681
 
85548
85682
  // src/git-sensor.ts
85549
- import { existsSync as existsSync24, readFileSync as readFileSync25, watch as fsWatch } from "node:fs";
85550
- import { join as join29 } from "node:path";
85683
+ import { existsSync as existsSync25, readFileSync as readFileSync26, watch as fsWatch } from "node:fs";
85684
+ import { join as join30 } from "node:path";
85551
85685
  function readFirstLine(path3) {
85552
85686
  try {
85553
- return readFileSync25(path3, "utf8").split(/\r?\n/, 1)[0].trim();
85687
+ return readFileSync26(path3, "utf8").split(/\r?\n/, 1)[0].trim();
85554
85688
  } catch {
85555
85689
  return null;
85556
85690
  }
85557
85691
  }
85558
85692
  function readGitRefState(gitDir) {
85559
- const head2 = readFirstLine(join29(gitDir, "HEAD"));
85693
+ const head2 = readFirstLine(join30(gitDir, "HEAD"));
85560
85694
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
85561
85695
  const branch = m ? m[1] : null;
85562
85696
  let sha2 = null;
85563
85697
  if (branch) {
85564
- sha2 = readFirstLine(join29(gitDir, "refs", "heads", branch));
85698
+ sha2 = readFirstLine(join30(gitDir, "refs", "heads", branch));
85565
85699
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
85566
85700
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
85567
85701
  sha2 = head2;
@@ -85569,13 +85703,13 @@ function readGitRefState(gitDir) {
85569
85703
  return {
85570
85704
  branch,
85571
85705
  sha: sha2,
85572
- mergeHeadExists: existsSync24(join29(gitDir, "MERGE_HEAD")),
85573
- origHeadExists: existsSync24(join29(gitDir, "ORIG_HEAD"))
85706
+ mergeHeadExists: existsSync25(join30(gitDir, "MERGE_HEAD")),
85707
+ origHeadExists: existsSync25(join30(gitDir, "ORIG_HEAD"))
85574
85708
  };
85575
85709
  }
85576
85710
  function shaFromPackedRefs(gitDir, ref) {
85577
85711
  try {
85578
- for (const line of readFileSync25(join29(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
85712
+ for (const line of readFileSync26(join30(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
85579
85713
  const [sha2, name2] = line.split(/\s+/);
85580
85714
  if (name2 === ref && sha2) return sha2;
85581
85715
  }
@@ -85609,7 +85743,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85609
85743
  const settle = () => {
85610
85744
  if (timer) clearTimeout(timer);
85611
85745
  timer = setTimeout(() => {
85612
- if (existsSync24(join29(gitDir, "index.lock"))) {
85746
+ if (existsSync25(join30(gitDir, "index.lock"))) {
85613
85747
  settle();
85614
85748
  return;
85615
85749
  }
@@ -85620,7 +85754,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85620
85754
  }, debounceMs);
85621
85755
  };
85622
85756
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
85623
- const p = join29(gitDir, sub);
85757
+ const p = join30(gitDir, sub);
85624
85758
  try {
85625
85759
  watchers.push(fsWatch(p, settle));
85626
85760
  } catch {
@@ -85640,7 +85774,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85640
85774
  // src/git-delta.ts
85641
85775
  import { execFile as execFile2 } from "node:child_process";
85642
85776
  function git(repoDir, args2) {
85643
- return new Promise((resolve10, reject) => {
85777
+ return new Promise((resolve11, reject) => {
85644
85778
  execFile2(
85645
85779
  "git",
85646
85780
  ["-C", repoDir, ...args2],
@@ -85651,7 +85785,7 @@ function git(repoDir, args2) {
85651
85785
  // git-sensor runs on every commit/checkout.
85652
85786
  windowsHide: true
85653
85787
  },
85654
- (err2, stdout) => err2 ? reject(err2) : resolve10(stdout)
85788
+ (err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
85655
85789
  );
85656
85790
  });
85657
85791
  }
@@ -85850,8 +85984,8 @@ var TelemetryRecorder = class {
85850
85984
  };
85851
85985
 
85852
85986
  // src/file-activity.ts
85853
- import { readFileSync as readFileSync27 } from "node:fs";
85854
- import { join as join31 } from "node:path";
85987
+ import { readFileSync as readFileSync28 } from "node:fs";
85988
+ import { join as join32 } from "node:path";
85855
85989
  import { createHash as createHash17 } from "node:crypto";
85856
85990
 
85857
85991
  // ../../packages/privacy/src/patterns/credentials.ts
@@ -86603,8 +86737,8 @@ init_git_remote();
86603
86737
  // src/history-bundle.ts
86604
86738
  init_src();
86605
86739
  import { execFile as execFile3 } from "node:child_process";
86606
- import { readFileSync as readFileSync26 } from "node:fs";
86607
- import { join as join30 } from "node:path";
86740
+ import { readFileSync as readFileSync27 } from "node:fs";
86741
+ import { join as join31 } from "node:path";
86608
86742
  var DEFAULT_MAX_TOKENS = 6e3;
86609
86743
  var FILE_LIST_CAP = 60;
86610
86744
  var DIFF_FILE_CAP = 40;
@@ -86643,7 +86777,7 @@ function pathAllowedByFloor(path3) {
86643
86777
  function loadRepoIgnore(root, extraPatterns = []) {
86644
86778
  let source = "";
86645
86779
  try {
86646
- source = readFileSync26(join30(root, ".errataignore"), "utf8");
86780
+ source = readFileSync27(join31(root, ".errataignore"), "utf8");
86647
86781
  } catch {
86648
86782
  source = "";
86649
86783
  }
@@ -86820,12 +86954,12 @@ function headerPaths(diff) {
86820
86954
  }
86821
86955
  var GIT_MAX_BUFFER = 64 * 1024 * 1024;
86822
86956
  function git2(repoDir, args2, maxBuffer = GIT_MAX_BUFFER) {
86823
- return new Promise((resolve10, reject) => {
86957
+ return new Promise((resolve11, reject) => {
86824
86958
  execFile3(
86825
86959
  "git",
86826
86960
  ["-C", repoDir, ...args2],
86827
86961
  { encoding: "utf8", maxBuffer, windowsHide: true },
86828
- (err2, stdout) => err2 ? reject(err2) : resolve10(stdout)
86962
+ (err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
86829
86963
  );
86830
86964
  });
86831
86965
  }
@@ -86948,7 +87082,7 @@ function readActivityBranch(root) {
86948
87082
  try {
86949
87083
  const gitDir = resolveGitDir(root);
86950
87084
  if (!gitDir) return null;
86951
- const head2 = readFileSync27(join31(gitDir, "HEAD"), "utf8").trim();
87085
+ const head2 = readFileSync28(join32(gitDir, "HEAD"), "utf8").trim();
86952
87086
  const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
86953
87087
  return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
86954
87088
  } catch {
@@ -87105,21 +87239,21 @@ var FileActivityReporter = class {
87105
87239
 
87106
87240
  // src/skills.ts
87107
87241
  import {
87108
- existsSync as existsSync25,
87242
+ existsSync as existsSync26,
87109
87243
  mkdirSync as mkdirSync7,
87110
- readFileSync as readFileSync28,
87244
+ readFileSync as readFileSync29,
87111
87245
  readdirSync as readdirSync9,
87112
87246
  unlinkSync as unlinkSync4,
87113
87247
  writeFileSync as writeFileSync19
87114
87248
  } from "node:fs";
87115
- import { basename as basename7, join as join32 } from "node:path";
87249
+ import { basename as basename7, join as join33 } from "node:path";
87116
87250
  function skillFileName(id) {
87117
87251
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
87118
87252
  }
87119
87253
  function readSkillManifest(manifestPath) {
87120
- if (!existsSync25(manifestPath)) return [];
87254
+ if (!existsSync26(manifestPath)) return [];
87121
87255
  try {
87122
- const parsed = JSON.parse(readFileSync28(manifestPath, "utf8"));
87256
+ const parsed = JSON.parse(readFileSync29(manifestPath, "utf8"));
87123
87257
  return (parsed.skills ?? []).map((s) => ({
87124
87258
  title: s.title ?? "",
87125
87259
  layer: s.layer ?? "technique",
@@ -87143,7 +87277,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87143
87277
  for (const s of res.skills) {
87144
87278
  const fileName = skillFileName(s.id);
87145
87279
  keep.add(fileName);
87146
- writeFileSync19(join32(paths.skillsDir, fileName), s.markdown, "utf8");
87280
+ writeFileSync19(join33(paths.skillsDir, fileName), s.markdown, "utf8");
87147
87281
  rows.push({
87148
87282
  id: s.id,
87149
87283
  title: s.title,
@@ -87156,7 +87290,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87156
87290
  const fileName = skillFileName(p.id);
87157
87291
  if (keep.has(fileName)) continue;
87158
87292
  keep.add(fileName);
87159
- writeFileSync19(join32(paths.skillsDir, fileName), p.markdown, "utf8");
87293
+ writeFileSync19(join33(paths.skillsDir, fileName), p.markdown, "utf8");
87160
87294
  rows.push({
87161
87295
  id: p.id,
87162
87296
  title: p.title,
@@ -87170,7 +87304,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87170
87304
  if (!f.endsWith(".md")) continue;
87171
87305
  if (keep.has(basename7(f))) continue;
87172
87306
  try {
87173
- unlinkSync4(join32(paths.skillsDir, f));
87307
+ unlinkSync4(join33(paths.skillsDir, f));
87174
87308
  pruned++;
87175
87309
  } catch {
87176
87310
  }
@@ -87188,22 +87322,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87188
87322
  init_src2();
87189
87323
  import {
87190
87324
  cpSync,
87191
- existsSync as existsSync26,
87325
+ existsSync as existsSync27,
87192
87326
  lstatSync,
87193
87327
  mkdirSync as mkdirSync8,
87194
- readFileSync as readFileSync29,
87328
+ readFileSync as readFileSync30,
87195
87329
  readdirSync as readdirSync10,
87196
87330
  rmSync as rmSync3,
87197
87331
  symlinkSync,
87198
87332
  writeFileSync as writeFileSync20
87199
87333
  } from "node:fs";
87200
- import { join as join33 } from "node:path";
87334
+ import { join as join34 } from "node:path";
87201
87335
  var SKILL_NS = "errata-";
87202
87336
  var HARNESS_SKILL_DIRS = [
87203
- { configDir: ".claude", skillsDir: join33(".claude", "skills") },
87337
+ { configDir: ".claude", skillsDir: join34(".claude", "skills") },
87204
87338
  // Cursor adopted the standard; its exact project dir is still moving — kept
87205
87339
  // best-effort and gated on `.cursor/` presence so we never create it blind.
87206
- { configDir: ".cursor", skillsDir: join33(".cursor", "skills") }
87340
+ { configDir: ".cursor", skillsDir: join34(".cursor", "skills") }
87207
87341
  ];
87208
87342
  function skillSlug(title, id) {
87209
87343
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -87248,12 +87382,12 @@ function skillCiteHandle(s) {
87248
87382
  return priorHandle({ id: s.id, description: s.title });
87249
87383
  }
87250
87384
  function reconcileNamespaced(dir, keep) {
87251
- if (!existsSync26(dir)) return 0;
87385
+ if (!existsSync27(dir)) return 0;
87252
87386
  let pruned = 0;
87253
87387
  for (const name2 of readdirSync10(dir)) {
87254
87388
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
87255
87389
  try {
87256
- rmSync3(join33(dir, name2), { recursive: true, force: true });
87390
+ rmSync3(join34(dir, name2), { recursive: true, force: true });
87257
87391
  pruned++;
87258
87392
  } catch {
87259
87393
  }
@@ -87262,7 +87396,7 @@ function reconcileNamespaced(dir, keep) {
87262
87396
  }
87263
87397
  function linkOrCopy(linkPath, target) {
87264
87398
  try {
87265
- if (existsSync26(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
87399
+ if (existsSync27(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
87266
87400
  } catch {
87267
87401
  }
87268
87402
  try {
@@ -87283,7 +87417,7 @@ function safeLstat(p) {
87283
87417
  }
87284
87418
  }
87285
87419
  function emitAndProjectSkills(root, skills) {
87286
- const agentsSkillsDir = join33(root, ".agents", "skills");
87420
+ const agentsSkillsDir = join34(root, ".agents", "skills");
87287
87421
  mkdirSync8(agentsSkillsDir, { recursive: true });
87288
87422
  const slugs = [];
87289
87423
  const keep = /* @__PURE__ */ new Set();
@@ -87291,7 +87425,7 @@ function emitAndProjectSkills(root, skills) {
87291
87425
  for (const s of skills) {
87292
87426
  let body2;
87293
87427
  try {
87294
- body2 = readFileSync29(s.bodyPath, "utf8");
87428
+ body2 = readFileSync30(s.bodyPath, "utf8");
87295
87429
  } catch {
87296
87430
  continue;
87297
87431
  }
@@ -87300,9 +87434,9 @@ function emitAndProjectSkills(root, skills) {
87300
87434
  keep.add(slug2);
87301
87435
  slugs.push(slug2);
87302
87436
  const description = deriveDescription(s.title, s.layer, body2);
87303
- mkdirSync8(join33(agentsSkillsDir, slug2), { recursive: true });
87437
+ mkdirSync8(join34(agentsSkillsDir, slug2), { recursive: true });
87304
87438
  writeFileSync20(
87305
- join33(agentsSkillsDir, slug2, "SKILL.md"),
87439
+ join34(agentsSkillsDir, slug2, "SKILL.md"),
87306
87440
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
87307
87441
  "utf8"
87308
87442
  );
@@ -87311,11 +87445,11 @@ function emitAndProjectSkills(root, skills) {
87311
87445
  reconcileNamespaced(agentsSkillsDir, keep);
87312
87446
  let projected = 0;
87313
87447
  for (const h of HARNESS_SKILL_DIRS) {
87314
- if (!existsSync26(join33(root, h.configDir))) continue;
87315
- const dir = join33(root, h.skillsDir);
87448
+ if (!existsSync27(join34(root, h.configDir))) continue;
87449
+ const dir = join34(root, h.skillsDir);
87316
87450
  mkdirSync8(dir, { recursive: true });
87317
87451
  for (const slug2 of slugs) {
87318
- linkOrCopy(join33(dir, slug2), join33(agentsSkillsDir, slug2));
87452
+ linkOrCopy(join34(dir, slug2), join34(agentsSkillsDir, slug2));
87319
87453
  projected++;
87320
87454
  }
87321
87455
  reconcileNamespaced(dir, keep);
@@ -87324,15 +87458,15 @@ function emitAndProjectSkills(root, skills) {
87324
87458
  return { slugs, emitted, projected };
87325
87459
  }
87326
87460
  function emitInputsFromManifest(erretaDir, manifestPath) {
87327
- if (!existsSync26(manifestPath)) return [];
87461
+ if (!existsSync27(manifestPath)) return [];
87328
87462
  try {
87329
- const parsed = JSON.parse(readFileSync29(manifestPath, "utf8"));
87463
+ const parsed = JSON.parse(readFileSync30(manifestPath, "utf8"));
87330
87464
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
87331
87465
  id: s.id,
87332
87466
  title: s.title ?? s.id,
87333
87467
  layer: s.layer ?? "technique",
87334
87468
  confidence: s.confidence ?? 0,
87335
- bodyPath: join33(erretaDir, s.file)
87469
+ bodyPath: join34(erretaDir, s.file)
87336
87470
  }));
87337
87471
  } catch {
87338
87472
  return [];
@@ -87346,10 +87480,10 @@ var GITIGNORE_LINES = [
87346
87480
  ".cursor/skills/errata-*/"
87347
87481
  ];
87348
87482
  function ensureSkillGitignore(root) {
87349
- const path3 = join33(root, ".gitignore");
87483
+ const path3 = join34(root, ".gitignore");
87350
87484
  let current = "";
87351
87485
  try {
87352
- current = existsSync26(path3) ? readFileSync29(path3, "utf8") : "";
87486
+ current = existsSync27(path3) ? readFileSync30(path3, "utf8") : "";
87353
87487
  } catch {
87354
87488
  return;
87355
87489
  }
@@ -87368,7 +87502,7 @@ var INTENT_TTL_MS = 15 * 60 * 1e3;
87368
87502
  function createIntentState(ttlMs = INTENT_TTL_MS) {
87369
87503
  const bySession = /* @__PURE__ */ new Map();
87370
87504
  let recent4 = null;
87371
- const live3 = (s, nowMs) => s !== void 0 && nowMs - s.atMs < ttlMs;
87505
+ const live4 = (s, nowMs) => s !== void 0 && nowMs - s.atMs < ttlMs;
87372
87506
  return {
87373
87507
  set(sessionId, text, nowMs) {
87374
87508
  const trimmed = text.trim();
@@ -87382,7 +87516,7 @@ function createIntentState(ttlMs = INTENT_TTL_MS) {
87382
87516
  },
87383
87517
  get(sessionId, nowMs) {
87384
87518
  const s = bySession.get(sessionId);
87385
- return live3(s, nowMs) ? s.text : void 0;
87519
+ return live4(s, nowMs) ? s.text : void 0;
87386
87520
  },
87387
87521
  mostRecent(nowMs) {
87388
87522
  if (!recent4) return void 0;
@@ -87452,18 +87586,18 @@ init_paths();
87452
87586
  init_profile2();
87453
87587
 
87454
87588
  // src/witness-queue.ts
87455
- import { readFileSync as readFileSync30, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
87456
- import { dirname as dirname13, join as join34 } from "node:path";
87589
+ import { readFileSync as readFileSync31, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
87590
+ import { dirname as dirname14, join as join35 } from "node:path";
87457
87591
  var WITNESS_QUEUE_CAP = 500;
87458
87592
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
87459
87593
  var WITNESS_MAX_ATTEMPTS = 5;
87460
87594
  function witnessQueuePath(workspaceConfigDir) {
87461
- return join34(workspaceConfigDir, "witness-queue.json");
87595
+ return join35(workspaceConfigDir, "witness-queue.json");
87462
87596
  }
87463
87597
  function loadWitnessQueueWithLosses(path3) {
87464
87598
  let raw2;
87465
87599
  try {
87466
- raw2 = JSON.parse(readFileSync30(path3, "utf8"));
87600
+ raw2 = JSON.parse(readFileSync31(path3, "utf8"));
87467
87601
  } catch (err2) {
87468
87602
  const absent = err2?.code === "ENOENT";
87469
87603
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -87476,7 +87610,7 @@ function loadWitnessQueueWithLosses(path3) {
87476
87610
  }
87477
87611
  function saveWitnessQueue(path3, queue) {
87478
87612
  try {
87479
- const tmp = join34(dirname13(path3), `.${Date.now()}.witness-queue.tmp`);
87613
+ const tmp = join35(dirname14(path3), `.${Date.now()}.witness-queue.tmp`);
87480
87614
  writeFileSync21(tmp, JSON.stringify(queue), "utf8");
87481
87615
  renameSync4(tmp, path3);
87482
87616
  } catch {
@@ -87484,17 +87618,17 @@ function saveWitnessQueue(path3, queue) {
87484
87618
  }
87485
87619
  function pruneWitnessQueueWithDispositions(queue, now) {
87486
87620
  const dropped = { expiredTtl: 0, exhaustedAttempts: 0, cappedOverflow: 0 };
87487
- const live3 = [];
87621
+ const live4 = [];
87488
87622
  for (const w of queue) {
87489
87623
  if (now - w.ts >= WITNESS_TTL_MS) dropped.expiredTtl++;
87490
87624
  else if (w.attempts >= WITNESS_MAX_ATTEMPTS) dropped.exhaustedAttempts++;
87491
- else live3.push(w);
87625
+ else live4.push(w);
87492
87626
  }
87493
- if (live3.length > WITNESS_QUEUE_CAP) {
87494
- dropped.cappedOverflow = live3.length - WITNESS_QUEUE_CAP;
87495
- return { queue: live3.slice(live3.length - WITNESS_QUEUE_CAP), dropped };
87627
+ if (live4.length > WITNESS_QUEUE_CAP) {
87628
+ dropped.cappedOverflow = live4.length - WITNESS_QUEUE_CAP;
87629
+ return { queue: live4.slice(live4.length - WITNESS_QUEUE_CAP), dropped };
87496
87630
  }
87497
- return { queue: live3, dropped };
87631
+ return { queue: live4, dropped };
87498
87632
  }
87499
87633
  function enqueueWitnessesWithDispositions(queue, fresh, now) {
87500
87634
  const byKey = new Map(queue.map((w) => [`${w.channel}:${w.witnessKey}`, w]));
@@ -87786,8 +87920,8 @@ function maybeFlushDigests() {
87786
87920
 
87787
87921
  // src/liveness-watch.ts
87788
87922
  init_src5();
87789
- import { readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
87790
- import { join as join36 } from "node:path";
87923
+ import { readFileSync as readFileSync33, writeFileSync as writeFileSync23 } from "node:fs";
87924
+ import { join as join37 } from "node:path";
87791
87925
 
87792
87926
  // src/loop-lag.ts
87793
87927
  var HEARTBEAT_MS = 500;
@@ -87919,11 +88053,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
87919
88053
  var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
87920
88054
  var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
87921
88055
  function alarmStatePath(configDir) {
87922
- return join36(configDir, "liveness-alarms.json");
88056
+ return join37(configDir, "liveness-alarms.json");
87923
88057
  }
87924
88058
  function loadAlarmState(path3) {
87925
88059
  try {
87926
- const raw2 = JSON.parse(readFileSync32(path3, "utf8"));
88060
+ const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
87927
88061
  return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
87928
88062
  } catch {
87929
88063
  return /* @__PURE__ */ new Map();
@@ -88187,7 +88321,7 @@ function createWatchBreaker(deps) {
88187
88321
  }
88188
88322
 
88189
88323
  // src/engine.ts
88190
- var DAEMON_VERSION = true ? "2.0.23-dev.4829" : "2.0.0-alpha.0";
88324
+ var DAEMON_VERSION = true ? "2.0.23-dev.4864" : "2.0.0-alpha.0";
88191
88325
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
88192
88326
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
88193
88327
  var GIT_OP_MUTE_MS = 4e3;
@@ -88199,7 +88333,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
88199
88333
  function appendIdentityAudit(path3, record2, line) {
88200
88334
  if (!record2.accepted && record2.score <= 0) return;
88201
88335
  try {
88202
- if (existsSync28(path3) && statSync11(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
88336
+ if (existsSync29(path3) && statSync12(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
88203
88337
  renameSync5(path3, `${path3}.1`);
88204
88338
  }
88205
88339
  appendFileSync4(path3, line);
@@ -88209,7 +88343,7 @@ function appendIdentityAudit(path3, record2, line) {
88209
88343
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
88210
88344
  function loadTurnCursors(path3) {
88211
88345
  try {
88212
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88346
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88213
88347
  return new Map(
88214
88348
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
88215
88349
  );
@@ -88219,7 +88353,7 @@ function loadTurnCursors(path3) {
88219
88353
  }
88220
88354
  function loadTurnOffsets(path3) {
88221
88355
  try {
88222
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88356
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88223
88357
  const out2 = /* @__PURE__ */ new Map();
88224
88358
  for (const [k, v] of Object.entries(raw2)) {
88225
88359
  const off2 = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -88232,7 +88366,7 @@ function loadTurnOffsets(path3) {
88232
88366
  }
88233
88367
  function loadTurnMoves(path3) {
88234
88368
  try {
88235
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88369
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88236
88370
  const out2 = /* @__PURE__ */ new Map();
88237
88371
  for (const [k, v] of Object.entries(raw2)) {
88238
88372
  const to = typeof v === "object" && v !== null ? v.movedTo : void 0;
@@ -88253,7 +88387,7 @@ function saveTurnCursors(path3, cursors, offsets, moves = /* @__PURE__ */ new Ma
88253
88387
  } catch {
88254
88388
  }
88255
88389
  }
88256
- var turnCursorFile = (configDir) => join37(configDir, "turn-cursors.json");
88390
+ var turnCursorFile = (configDir) => join38(configDir, "turn-cursors.json");
88257
88391
  function turnCursorOnDisk(configDir, sessionId) {
88258
88392
  const path3 = turnCursorFile(configDir);
88259
88393
  const offset = loadTurnOffsets(path3).get(sessionId);
@@ -88285,7 +88419,7 @@ function gitSourceWatchTargets(root) {
88285
88419
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
88286
88420
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
88287
88421
  );
88288
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join37(root, d) + sep5));
88422
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join38(root, d) + sep5));
88289
88423
  } catch {
88290
88424
  }
88291
88425
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -88297,19 +88431,19 @@ function gitSourceWatchTargets(root) {
88297
88431
  if (!f.startsWith(prefix)) continue;
88298
88432
  const rest2 = f.slice(prefix.length);
88299
88433
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
88300
- else targets.add(join37(root, f));
88434
+ else targets.add(join38(root, f));
88301
88435
  }
88302
88436
  for (const c of children) {
88303
- if (IGNORED_PATH.test(join37(root, c) + sep5)) continue;
88437
+ if (IGNORED_PATH.test(join38(root, c) + sep5)) continue;
88304
88438
  if (hasIgnoredChild(c)) addUnder(c);
88305
- else targets.add(join37(root, c));
88439
+ else targets.add(join38(root, c));
88306
88440
  }
88307
88441
  };
88308
88442
  addUnder("");
88309
88443
  if (targets.size > 0) return [...targets];
88310
88444
  } catch {
88311
88445
  }
88312
- return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join37(root, String(e.name)) + sep5)).map((e) => join37(root, String(e.name)));
88446
+ return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join38(root, String(e.name)) + sep5)).map((e) => join38(root, String(e.name)));
88313
88447
  }
88314
88448
  function createWorkspaceEngine(opts) {
88315
88449
  const paths = workspacePaths(opts.workspaceRoot);
@@ -88403,7 +88537,7 @@ function createWorkspaceEngine(opts) {
88403
88537
  }
88404
88538
  let size = 0;
88405
88539
  try {
88406
- size = statSync11(path3).size;
88540
+ size = statSync12(path3).size;
88407
88541
  } catch {
88408
88542
  }
88409
88543
  lastActivityTs = Date.now();
@@ -88511,7 +88645,7 @@ function createWorkspaceEngine(opts) {
88511
88645
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
88512
88646
  let episodeId2;
88513
88647
  if (srcPaths.length > 0) {
88514
- const abs = srcPaths.map((p) => join37(opts.workspaceRoot, p));
88648
+ const abs = srcPaths.map((p) => join38(opts.workspaceRoot, p));
88515
88649
  try {
88516
88650
  const r = await runReindexPass(
88517
88651
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -88547,8 +88681,8 @@ function createWorkspaceEngine(opts) {
88547
88681
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
88548
88682
  );
88549
88683
  };
88550
- const gitDir = join37(opts.workspaceRoot, ".git");
88551
- if (existsSync28(gitDir)) {
88684
+ const gitDir = join38(opts.workspaceRoot, ".git");
88685
+ if (existsSync29(gitDir)) {
88552
88686
  stopGit = startGitSensor(gitDir, (ev) => {
88553
88687
  void handleGitEvent(ev).catch((err2) => {
88554
88688
  console.warn("[errata] git event handler failed:", err2);
@@ -88609,7 +88743,7 @@ function createWorkspaceEngine(opts) {
88609
88743
  },
88610
88744
  onAlarms: (alarms) => {
88611
88745
  toastLivenessAlarms(
88612
- sharedAlarmToastGate(join37(globalDir(), "liveness-toasts.json")),
88746
+ sharedAlarmToastGate(join38(globalDir(), "liveness-toasts.json")),
88613
88747
  { root: opts.workspaceRoot, name: profile.name },
88614
88748
  alarms,
88615
88749
  (body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
@@ -88626,7 +88760,7 @@ function createWorkspaceEngine(opts) {
88626
88760
  let subagentBase = null;
88627
88761
  let subagentBaseVersion = 0;
88628
88762
  const subagentRenders = /* @__PURE__ */ new Map();
88629
- const sessions = createSessionRegistry({ originsPath: join37(paths.configDir, "session-origins.json") });
88763
+ const sessions = createSessionRegistry({ originsPath: join38(paths.configDir, "session-origins.json") });
88630
88764
  const sessionRenders = /* @__PURE__ */ new Map();
88631
88765
  const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
88632
88766
  const supersessionAsks = new SupersessionAsks();
@@ -88731,7 +88865,7 @@ function createWorkspaceEngine(opts) {
88731
88865
  const elicit = isEdgeElicitationEnabled();
88732
88866
  const snapOpts = {
88733
88867
  profile,
88734
- atCommit: readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0,
88868
+ atCommit: readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0,
88735
88869
  reviewCount: pendingCount(paths),
88736
88870
  reviewUiUrl: opts.reviewUrl(),
88737
88871
  workingFile: workingFiles.mostRecent() ?? void 0,
@@ -88771,7 +88905,7 @@ function createWorkspaceEngine(opts) {
88771
88905
  );
88772
88906
  return null;
88773
88907
  }) : null;
88774
- if (snapOpts.atCommit !== (readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0)) {
88908
+ if (snapOpts.atCommit !== (readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0)) {
88775
88909
  contextDirty = true;
88776
88910
  return;
88777
88911
  }
@@ -88817,10 +88951,10 @@ function createWorkspaceEngine(opts) {
88817
88951
  } catch (err2) {
88818
88952
  console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
88819
88953
  }
88820
- const target = join37(opts.workspaceRoot, "AGENTS.md");
88954
+ const target = join38(opts.workspaceRoot, "AGENTS.md");
88821
88955
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
88822
88956
  if (elicit) {
88823
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), [
88957
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), [
88824
88958
  ...snapshot.recentProblems.map((r) => r.node),
88825
88959
  // Resolved-band handles: the ✓ problem AND its Solution are citable
88826
88960
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -89128,8 +89262,8 @@ function createWorkspaceEngine(opts) {
89128
89262
  const cached2 = subagentRenders.get(a.agentId);
89129
89263
  if (cached2?.key === key) return cached2.block;
89130
89264
  const elicit = isEdgeElicitationEnabled();
89131
- const handlesPath = join37(paths.configDir, "priming-handles.json");
89132
- const atCommit = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89265
+ const handlesPath = join38(paths.configDir, "priming-handles.json");
89266
+ const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89133
89267
  const block = renderSubagentBlock({
89134
89268
  store,
89135
89269
  entry,
@@ -89184,7 +89318,7 @@ function createWorkspaceEngine(opts) {
89184
89318
  const cached2 = sessionRenders.get(sessionId);
89185
89319
  if (cached2?.key === key) return cached2.block;
89186
89320
  const elicit = isEdgeElicitationEnabled();
89187
- const atCommit = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89321
+ const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89188
89322
  const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
89189
89323
  delete scoped.workingFile;
89190
89324
  if (workingFile) {
@@ -89228,7 +89362,7 @@ function createWorkspaceEngine(opts) {
89228
89362
  ]
89229
89363
  };
89230
89364
  if (elicit && block.handleNodes.length) {
89231
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), block.handleNodes);
89365
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), block.handleNodes);
89232
89366
  }
89233
89367
  sessionRenders.delete(sessionId);
89234
89368
  sessionRenders.set(sessionId, { key, block });
@@ -89304,7 +89438,15 @@ function createWorkspaceEngine(opts) {
89304
89438
  doneHarvest();
89305
89439
  }
89306
89440
  };
89441
+ const replaySessions = /* @__PURE__ */ new Set();
89442
+ const sessionCwdSeen = /* @__PURE__ */ new Set();
89443
+ const noteSessionCwd = (sessionId, cwd) => {
89444
+ if (!cwd || !sessionId || sessionCwdSeen.has(sessionId)) return;
89445
+ sessionCwdSeen.add(sessionId);
89446
+ if (isReplayCheckout(cwd)) replaySessions.add(sessionId);
89447
+ };
89307
89448
  const harvestTextsInner = async (sessionId, items) => {
89449
+ const replay2 = replaySessions.has(sessionId);
89308
89450
  let minted = 0;
89309
89451
  let tagsSeen = 0;
89310
89452
  let vulnerabilitiesSeen = 0;
@@ -89354,7 +89496,7 @@ function createWorkspaceEngine(opts) {
89354
89496
  let processedTurns = 0;
89355
89497
  const seqAtStart = store.currentIngestSeq();
89356
89498
  const elicit = isEdgeElicitationEnabled();
89357
- const handleMap = elicit ? readPrimingHandles(join37(paths.configDir, "priming-handles.json")) : {};
89499
+ const handleMap = elicit ? readPrimingHandles(join38(paths.configDir, "priming-handles.json")) : {};
89358
89500
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
89359
89501
  const toRel = (abs) => {
89360
89502
  const p = abs.replace(/\\/g, "/");
@@ -89406,7 +89548,8 @@ function createWorkspaceEngine(opts) {
89406
89548
  workspaceId: profile.id,
89407
89549
  source: sessionId,
89408
89550
  ts: t,
89409
- hostHarness: turn.hostHarness
89551
+ hostHarness: turn.hostHarness,
89552
+ replay: replay2
89410
89553
  });
89411
89554
  if (r.created || r.corroborated) minted++;
89412
89555
  else if (r.rejected) tagsRejected++;
@@ -89573,7 +89716,7 @@ function createWorkspaceEngine(opts) {
89573
89716
  let anchorReadFailed = false;
89574
89717
  if (p.location) {
89575
89718
  try {
89576
- fileText = readFileSync33(join37(opts.workspaceRoot, p.location.path), "utf8");
89719
+ fileText = readFileSync34(join38(opts.workspaceRoot, p.location.path), "utf8");
89577
89720
  } catch {
89578
89721
  anchorReadFailed = true;
89579
89722
  }
@@ -89585,7 +89728,7 @@ function createWorkspaceEngine(opts) {
89585
89728
  line: p.location?.line,
89586
89729
  fileText,
89587
89730
  existingId: p.threadId ? threads.get(p.threadId) ?? handleMap[p.threadId]?.id ?? store.getNode(p.threadId)?.id : void 0
89588
- }, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness });
89731
+ }, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness, replay: replay2 });
89589
89732
  let anchorDisposition = p.location ? "unresolved" : "absent";
89590
89733
  if (result.rejected) {
89591
89734
  tagsRejected++;
@@ -89673,13 +89816,14 @@ function createWorkspaceEngine(opts) {
89673
89816
  workspaceId: profile.id,
89674
89817
  source: sessionId,
89675
89818
  ts: t,
89676
- hostHarness: turn.hostHarness
89819
+ hostHarness: turn.hostHarness,
89820
+ replay: replay2
89677
89821
  });
89678
89822
  if (!r.rejected && r.problemId) {
89679
89823
  findingIds.set(p.statement, r.problemId);
89680
89824
  if (p.threadId) threads.set(p.threadId, r.problemId);
89681
89825
  }
89682
- if (r.created && dedupPath) {
89826
+ if (r.created && dedupPath && !replay2) {
89683
89827
  try {
89684
89828
  const closedId = findResolvedAnchorMatch(store, dedupPath, profile.id, p.statement, p.kind);
89685
89829
  const touch = closedId ? markResolvedRecurrence(store, closedId, t, sessionId) : { marked: false, reopened: false };
@@ -89735,10 +89879,10 @@ function createWorkspaceEngine(opts) {
89735
89879
  let enclosing = {};
89736
89880
  if (p.location?.line !== void 0) {
89737
89881
  try {
89738
- const headSha = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89882
+ const headSha = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89739
89883
  enclosing = {
89740
89884
  line: p.location.line,
89741
- fileText: readFileSync33(join37(opts.workspaceRoot, anchorPath), "utf8"),
89885
+ fileText: readFileSync34(join38(opts.workspaceRoot, anchorPath), "utf8"),
89742
89886
  ...headSha ? { headSha } : {}
89743
89887
  };
89744
89888
  } catch {
@@ -90364,11 +90508,12 @@ function createWorkspaceEngine(opts) {
90364
90508
  }
90365
90509
  turns = next.turns;
90366
90510
  nextOffset = next.nextOffset;
90367
- await new Promise((resolve10) => setImmediate(resolve10));
90511
+ await new Promise((resolve11) => setImmediate(resolve11));
90368
90512
  }
90369
90513
  };
90370
90514
  const seenMessageIds = /* @__PURE__ */ new Set();
90371
90515
  const onMessage = (e) => {
90516
+ noteSessionCwd(e.sessionId, e.cwd);
90372
90517
  if (e.messageId) {
90373
90518
  if (seenMessageIds.has(e.messageId)) return;
90374
90519
  seenMessageIds.add(e.messageId);
@@ -90421,6 +90566,7 @@ function createWorkspaceEngine(opts) {
90421
90566
  }
90422
90567
  };
90423
90568
  const onTurn = (e) => {
90569
+ noteSessionCwd(e.sessionId, e.cwd);
90424
90570
  setImmediate(() => void harvestSession(e.sessionId, e.transcriptPath));
90425
90571
  };
90426
90572
  setImmediate(() => {
@@ -90610,7 +90756,7 @@ B: ${b}`,
90610
90756
  try {
90611
90757
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
90612
90758
  emitAndProjectSkills(opts.workspaceRoot, inputs);
90613
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
90759
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
90614
90760
  } catch (err2) {
90615
90761
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
90616
90762
  }
@@ -90977,7 +91123,7 @@ B: ${b}`,
90977
91123
  console.log(
90978
91124
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
90979
91125
  );
90980
- const pending = existsSync28(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
91126
+ const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
90981
91127
  return { uploaded: 0, failed: 0, remaining: pending };
90982
91128
  }
90983
91129
  if (!shipsFromWorkspace(opts.workspaceRoot)) {
@@ -90989,7 +91135,7 @@ B: ${b}`,
90989
91135
  console.log(
90990
91136
  "[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
90991
91137
  );
90992
- const pending = existsSync28(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
91138
+ const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
90993
91139
  return { uploaded: 0, failed: 0, remaining: pending };
90994
91140
  }
90995
91141
  try {
@@ -91166,7 +91312,7 @@ async function startDaemon(opts) {
91166
91312
  );
91167
91313
  await engine.stop();
91168
91314
  try {
91169
- if (existsSync29(engine.paths.daemonLock)) {
91315
+ if (existsSync30(engine.paths.daemonLock)) {
91170
91316
  }
91171
91317
  } catch {
91172
91318
  }
@@ -91174,9 +91320,9 @@ async function startDaemon(opts) {
91174
91320
  };
91175
91321
  }
91176
91322
  async function listenServer(fetchFn, port) {
91177
- return new Promise((resolve10, reject) => {
91323
+ return new Promise((resolve11, reject) => {
91178
91324
  const server = serve({ fetch: withLoopbackGuard(fetchFn), hostname: "127.0.0.1", port }, (info2) => {
91179
- resolve10({ server, port: info2.port });
91325
+ resolve11({ server, port: info2.port });
91180
91326
  });
91181
91327
  server.once(
91182
91328
  "error",
@@ -91367,8 +91513,8 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
91367
91513
  }
91368
91514
 
91369
91515
  // src/edge-park.ts
91370
- import { readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
91371
- import { dirname as dirname14, join as join38 } from "node:path";
91516
+ import { readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
91517
+ import { dirname as dirname15, join as join39 } from "node:path";
91372
91518
  var EDGE_PARK_CAP = 2e3;
91373
91519
  var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
91374
91520
  var EDGE_PARK_MAX_ATTEMPTS = 6;
@@ -91383,12 +91529,12 @@ function wireEdgeKey(from, type, to) {
91383
91529
  return JSON.stringify([from, type, to]);
91384
91530
  }
91385
91531
  function edgeParkPath(workspaceConfigDir, destinationKey) {
91386
- return join38(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
91532
+ return join39(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
91387
91533
  }
91388
91534
  function loadEdgePark(path3) {
91389
91535
  let raw2;
91390
91536
  try {
91391
- raw2 = JSON.parse(readFileSync34(path3, "utf8"));
91537
+ raw2 = JSON.parse(readFileSync35(path3, "utf8"));
91392
91538
  } catch {
91393
91539
  return [];
91394
91540
  }
@@ -91399,7 +91545,7 @@ function loadEdgePark(path3) {
91399
91545
  }
91400
91546
  function saveEdgePark(path3, queue) {
91401
91547
  try {
91402
- const tmp = join38(dirname14(path3), `.${Date.now()}.edge-park.tmp`);
91548
+ const tmp = join39(dirname15(path3), `.${Date.now()}.edge-park.tmp`);
91403
91549
  writeFileSync26(tmp, JSON.stringify(queue), "utf8");
91404
91550
  renameSync6(tmp, path3);
91405
91551
  } catch {
@@ -91558,16 +91704,16 @@ function settleEdgeOutcomes(queue, sent, verdicts, now) {
91558
91704
  if (prior?.state === "parked") counts.edgesReparked++;
91559
91705
  else counts.edgesParked++;
91560
91706
  }
91561
- const live3 = [];
91707
+ const live4 = [];
91562
91708
  for (const e of byKey.values()) {
91563
91709
  if (e.state === "parked" && now - e.ts >= EDGE_PARK_TTL_MS) {
91564
91710
  counts.edgesDroppedExpired++;
91565
91711
  continue;
91566
91712
  }
91567
91713
  if (e.state === "dropped" && now - (e.droppedAt ?? e.ts) >= tombstoneTtl(e)) continue;
91568
- live3.push(e);
91714
+ live4.push(e);
91569
91715
  }
91570
- let next = live3;
91716
+ let next = live4;
91571
91717
  if (next.length > EDGE_PARK_CAP) {
91572
91718
  const over = next.length - EDGE_PARK_CAP;
91573
91719
  const order = [...next].sort((a, b) => (a.state === b.state ? 0 : a.state === "dropped" ? -1 : 1) || a.ts - b.ts);
@@ -91722,8 +91868,8 @@ function invalidateInstanceReceipt(current, destination, failedId, mirrorLegacy)
91722
91868
  // src/multi.ts
91723
91869
  init_dist();
91724
91870
  init_src5();
91725
- import { existsSync as existsSync34, readFileSync as readFileSync40, writeFileSync as writeFileSync29 } from "node:fs";
91726
- import { basename as basename10, dirname as dirname17, join as join47, resolve as pathResolve } from "node:path";
91871
+ import { existsSync as existsSync35, readFileSync as readFileSync41, writeFileSync as writeFileSync29 } from "node:fs";
91872
+ import { basename as basename10, dirname as dirname18, join as join48, resolve as pathResolve } from "node:path";
91727
91873
 
91728
91874
  // src/principle-sync.ts
91729
91875
  init_src5();
@@ -91751,8 +91897,8 @@ init_reconcile();
91751
91897
 
91752
91898
  // src/lockfile-auto.ts
91753
91899
  init_src();
91754
- import { existsSync as existsSync30, readFileSync as readFileSync35 } from "node:fs";
91755
- import { join as join39 } from "node:path";
91900
+ import { existsSync as existsSync31, readFileSync as readFileSync36 } from "node:fs";
91901
+ import { join as join40 } from "node:path";
91756
91902
 
91757
91903
  // src/package-index.ts
91758
91904
  init_src();
@@ -91817,8 +91963,8 @@ function mintPackageGraph(store, sbom, workspaceId2, ts) {
91817
91963
  for (const to of d.dependsOn) {
91818
91964
  if (!minted.has(to)) continue;
91819
91965
  const id = `edge_${digest({ from: d.ref, type: "DEPENDS_ON", to })}`.slice(0, 24);
91820
- const live3 = store.getEdge(id);
91821
- if (live3 && (live3.validTo ?? null) === null) {
91966
+ const live4 = store.getEdge(id);
91967
+ if (live4 && (live4.validTo ?? null) === null) {
91822
91968
  edges++;
91823
91969
  continue;
91824
91970
  }
@@ -91925,11 +92071,11 @@ function runLockfilePass(opts) {
91925
92071
  { file: "package-lock.json", parse: parsePackageLockJson }
91926
92072
  ];
91927
92073
  for (const c of candidates) {
91928
- const p = join39(opts.root, c.file);
91929
- if (!existsSync30(p)) continue;
92074
+ const p = join40(opts.root, c.file);
92075
+ if (!existsSync31(p)) continue;
91930
92076
  let sbom;
91931
92077
  try {
91932
- sbom = c.parse(readFileSync35(p, "utf8"));
92078
+ sbom = c.parse(readFileSync36(p, "utf8"));
91933
92079
  } catch {
91934
92080
  continue;
91935
92081
  }
@@ -91990,8 +92136,8 @@ init_profile2();
91990
92136
  init_session_registry();
91991
92137
 
91992
92138
  // src/public-symbols.ts
91993
- import { readFileSync as readFileSync36, readdirSync as readdirSync12, existsSync as existsSync31 } from "node:fs";
91994
- import { join as join40 } from "node:path";
92139
+ import { readFileSync as readFileSync37, readdirSync as readdirSync12, existsSync as existsSync32 } from "node:fs";
92140
+ import { join as join41 } from "node:path";
91995
92141
  var HEAD_BYTES = 8 * 1024;
91996
92142
  var INDEX_TTL_MS = 10 * 60 * 1e3;
91997
92143
  var MIN_SYMBOL_LEN = 4;
@@ -92024,20 +92170,20 @@ function bindingNames(clause) {
92024
92170
  function internalPackageNames(workspaceRoot) {
92025
92171
  const names = /* @__PURE__ */ new Set();
92026
92172
  const tryRead = (dir) => {
92027
- const pj = join40(dir, "package.json");
92028
- if (!existsSync31(pj)) return;
92173
+ const pj = join41(dir, "package.json");
92174
+ if (!existsSync32(pj)) return;
92029
92175
  try {
92030
- const name2 = JSON.parse(readFileSync36(pj, "utf8")).name;
92176
+ const name2 = JSON.parse(readFileSync37(pj, "utf8")).name;
92031
92177
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
92032
92178
  } catch {
92033
92179
  }
92034
92180
  };
92035
92181
  tryRead(workspaceRoot);
92036
92182
  for (const group of ["packages", "apps"]) {
92037
- const groupDir = join40(workspaceRoot, group);
92038
- if (!existsSync31(groupDir)) continue;
92183
+ const groupDir = join41(workspaceRoot, group);
92184
+ if (!existsSync32(groupDir)) continue;
92039
92185
  try {
92040
- for (const entry of readdirSync12(groupDir)) tryRead(join40(groupDir, entry));
92186
+ for (const entry of readdirSync12(groupDir)) tryRead(join41(groupDir, entry));
92041
92187
  } catch {
92042
92188
  }
92043
92189
  }
@@ -92056,7 +92202,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
92056
92202
  }
92057
92203
  const readHead = deps.readHead ?? ((absPath) => {
92058
92204
  try {
92059
- return readFileSync36(absPath, "utf8").slice(0, HEAD_BYTES);
92205
+ return readFileSync37(absPath, "utf8").slice(0, HEAD_BYTES);
92060
92206
  } catch {
92061
92207
  return "";
92062
92208
  }
@@ -92076,7 +92222,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
92076
92222
  }
92077
92223
  const symbols = /* @__PURE__ */ new Set();
92078
92224
  for (const rel of files) {
92079
- const head2 = readHead(join40(workspaceRoot, rel));
92225
+ const head2 = readHead(join41(workspaceRoot, rel));
92080
92226
  if (!head2) continue;
92081
92227
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
92082
92228
  re.lastIndex = 0;
@@ -92751,8 +92897,8 @@ function cloudWireId(n) {
92751
92897
  function buildCausalEdgeBackfill(store, profile, daemonVersion) {
92752
92898
  const edges = [];
92753
92899
  const seenEdge = /* @__PURE__ */ new Set();
92754
- const live3 = store.selectNodes({ labels: CAUSAL_LABELS, attrs: WIRE_ATTRS });
92755
- const byId = new Map(live3.map((n) => [n.id, n]));
92900
+ const live4 = store.selectNodes({ labels: CAUSAL_LABELS, attrs: WIRE_ATTRS });
92901
+ const byId = new Map(live4.map((n) => [n.id, n]));
92756
92902
  const wireIds = /* @__PURE__ */ new Map();
92757
92903
  const wireIdOf = (id) => {
92758
92904
  if (wireIds.has(id)) return wireIds.get(id);
@@ -92760,7 +92906,7 @@ function buildCausalEdgeBackfill(store, profile, daemonVersion) {
92760
92906
  wireIds.set(id, w);
92761
92907
  return w;
92762
92908
  };
92763
- for (const n of live3) {
92909
+ for (const n of live4) {
92764
92910
  for (const e of store.outEdges(n.id, [...CAUSAL_EDGES2])) {
92765
92911
  if (seenEdge.has(e.id)) continue;
92766
92912
  seenEdge.add(e.id);
@@ -92880,8 +93026,8 @@ var ConsolidateWorker = class {
92880
93026
  const id = this.nextId++;
92881
93027
  try {
92882
93028
  await this.ready;
92883
- return await new Promise((resolve10, reject) => {
92884
- this.pending.set(id, { resolve: resolve10, reject });
93029
+ return await new Promise((resolve11, reject) => {
93030
+ this.pending.set(id, { resolve: resolve11, reject });
92885
93031
  this.worker.postMessage({ ...req, id });
92886
93032
  });
92887
93033
  } finally {
@@ -92911,12 +93057,12 @@ var ConsolidateWorker = class {
92911
93057
  });
92912
93058
  noteIsolateSpawned();
92913
93059
  this.worker = worker;
92914
- this.ready = new Promise((resolve10, reject) => {
93060
+ this.ready = new Promise((resolve11, reject) => {
92915
93061
  const onReady = (m) => {
92916
93062
  if (m?.ready) {
92917
93063
  worker.off("message", onReady);
92918
93064
  worker.off("error", onErr);
92919
- resolve10();
93065
+ resolve11();
92920
93066
  }
92921
93067
  };
92922
93068
  const onErr = (err2) => {
@@ -92974,8 +93120,8 @@ var GeneralizeWorker = class {
92974
93120
  this.touch();
92975
93121
  await this.ready;
92976
93122
  const id = this.nextId++;
92977
- return new Promise((resolve10, reject) => {
92978
- this.pending.set(id, { resolve: resolve10, reject });
93123
+ return new Promise((resolve11, reject) => {
93124
+ this.pending.set(id, { resolve: resolve11, reject });
92979
93125
  const req = { id, castaliaPath, text };
92980
93126
  this.worker.postMessage(req);
92981
93127
  });
@@ -93001,12 +93147,12 @@ var GeneralizeWorker = class {
93001
93147
  });
93002
93148
  noteIsolateSpawned();
93003
93149
  this.worker = worker;
93004
- this.ready = new Promise((resolve10, reject) => {
93150
+ this.ready = new Promise((resolve11, reject) => {
93005
93151
  const onReady = (m) => {
93006
93152
  if (m?.ready) {
93007
93153
  worker.off("message", onReady);
93008
93154
  worker.off("error", onErr);
93009
- resolve10();
93155
+ resolve11();
93010
93156
  }
93011
93157
  };
93012
93158
  const onErr = (err2) => {
@@ -93107,7 +93253,7 @@ init_config();
93107
93253
 
93108
93254
  // src/update.ts
93109
93255
  import { spawn as spawn2 } from "node:child_process";
93110
- import { isAbsolute as isAbsolute5, join as join41 } from "node:path";
93256
+ import { isAbsolute as isAbsolute6, join as join42 } from "node:path";
93111
93257
  var PACKAGE_NAME = "@inerrata-corporation/errata";
93112
93258
  function parse3(v) {
93113
93259
  const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
@@ -93227,17 +93373,17 @@ function startUpdatePoller(opts) {
93227
93373
  };
93228
93374
  }
93229
93375
  function runNpmInstall(channel) {
93230
- return new Promise((resolve10) => {
93376
+ return new Promise((resolve11) => {
93231
93377
  const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
93232
93378
  stdio: "inherit",
93233
93379
  shell: true
93234
93380
  });
93235
- child.on("close", (code) => resolve10(code ?? 1));
93236
- child.on("error", () => resolve10(1));
93381
+ child.on("close", (code) => resolve11(code ?? 1));
93382
+ child.on("error", () => resolve11(1));
93237
93383
  });
93238
93384
  }
93239
93385
  async function runInstalledHookRefresh() {
93240
- const root = await new Promise((resolve10) => {
93386
+ const root = await new Promise((resolve11) => {
93241
93387
  const child = spawn2("npm", ["root", "-g"], {
93242
93388
  shell: true,
93243
93389
  windowsHide: true,
@@ -93249,18 +93395,18 @@ async function runInstalledHookRefresh() {
93249
93395
  output += chunk;
93250
93396
  if (output.length > 32768) child.kill();
93251
93397
  });
93252
- child.on("error", () => resolve10(""));
93253
- child.on("close", (code) => resolve10(code === 0 ? output.trim() : ""));
93398
+ child.on("error", () => resolve11(""));
93399
+ child.on("close", (code) => resolve11(code === 0 ? output.trim() : ""));
93254
93400
  });
93255
- if (!isAbsolute5(root)) return 1;
93256
- return new Promise((resolve10) => {
93257
- const child = spawn2(process.execPath, [join41(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
93401
+ if (!isAbsolute6(root)) return 1;
93402
+ return new Promise((resolve11) => {
93403
+ const child = spawn2(process.execPath, [join42(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
93258
93404
  windowsHide: true,
93259
93405
  stdio: "inherit",
93260
93406
  timeout: 3e4
93261
93407
  });
93262
- child.on("error", () => resolve10(1));
93263
- child.on("close", (code) => resolve10(code ?? 1));
93408
+ child.on("error", () => resolve11(1));
93409
+ child.on("close", (code) => resolve11(code ?? 1));
93264
93410
  });
93265
93411
  }
93266
93412
 
@@ -93275,7 +93421,7 @@ function liveCloudClient(src) {
93275
93421
  let current = null;
93276
93422
  let currentKey = "";
93277
93423
  let checkedAt = -Infinity;
93278
- const resolve10 = () => {
93424
+ const resolve11 = () => {
93279
93425
  const t = now();
93280
93426
  if (current && t - checkedAt < recheckMs) return current;
93281
93427
  checkedAt = t;
@@ -93295,7 +93441,7 @@ function liveCloudClient(src) {
93295
93441
  };
93296
93442
  return new Proxy({}, {
93297
93443
  get(_target, prop) {
93298
- const client = resolve10();
93444
+ const client = resolve11();
93299
93445
  const value = Reflect.get(client, prop, client);
93300
93446
  return typeof value === "function" ? value.bind(client) : value;
93301
93447
  }
@@ -93400,12 +93546,12 @@ function landCloudEdge(store, e, from, to) {
93400
93546
  }
93401
93547
 
93402
93548
  // src/causal-edge-queue.ts
93403
- import { readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
93404
- import { dirname as dirname15, join as join42 } from "node:path";
93549
+ import { readFileSync as readFileSync38, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
93550
+ import { dirname as dirname16, join as join43 } from "node:path";
93405
93551
  var CAUSAL_EDGE_QUEUE_CAP = 5e3;
93406
93552
  var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
93407
93553
  function causalEdgeQueuePath(workspaceConfigDir) {
93408
- return join42(workspaceConfigDir, "causal-edge-queue.json");
93554
+ return join43(workspaceConfigDir, "causal-edge-queue.json");
93409
93555
  }
93410
93556
  function parkedEdgeKey(e) {
93411
93557
  return `${e.from}|${e.type}|${e.to}`;
@@ -93413,7 +93559,7 @@ function parkedEdgeKey(e) {
93413
93559
  function loadCausalEdgeQueue(path3) {
93414
93560
  let raw2;
93415
93561
  try {
93416
- raw2 = JSON.parse(readFileSync37(path3, "utf8"));
93562
+ raw2 = JSON.parse(readFileSync38(path3, "utf8"));
93417
93563
  } catch {
93418
93564
  return [];
93419
93565
  }
@@ -93424,16 +93570,16 @@ function loadCausalEdgeQueue(path3) {
93424
93570
  }
93425
93571
  function saveCausalEdgeQueue(path3, queue) {
93426
93572
  try {
93427
- const tmp = join42(dirname15(path3), `.${Date.now()}.causal-edge-queue.tmp`);
93573
+ const tmp = join43(dirname16(path3), `.${Date.now()}.causal-edge-queue.tmp`);
93428
93574
  writeFileSync27(tmp, JSON.stringify(queue), "utf8");
93429
93575
  renameSync7(tmp, path3);
93430
93576
  } catch {
93431
93577
  }
93432
93578
  }
93433
93579
  function pruneCausalEdgeQueue(queue, now) {
93434
- const live3 = queue.filter((p) => now - p.ts < CAUSAL_EDGE_TTL_MS);
93435
- if (live3.length <= CAUSAL_EDGE_QUEUE_CAP) return live3;
93436
- return [...live3].sort((a, b) => a.ts - b.ts).slice(live3.length - CAUSAL_EDGE_QUEUE_CAP);
93580
+ const live4 = queue.filter((p) => now - p.ts < CAUSAL_EDGE_TTL_MS);
93581
+ if (live4.length <= CAUSAL_EDGE_QUEUE_CAP) return live4;
93582
+ return [...live4].sort((a, b) => a.ts - b.ts).slice(live4.length - CAUSAL_EDGE_QUEUE_CAP);
93437
93583
  }
93438
93584
 
93439
93585
  // src/project-reanchor.ts
@@ -93856,9 +94002,9 @@ init_src11();
93856
94002
  init_src();
93857
94003
  import { execFile as execFile6 } from "node:child_process";
93858
94004
  import { promisify as promisify4 } from "node:util";
93859
- import { extname as extname3, join as join43 } from "node:path";
94005
+ import { extname as extname3, join as join44 } from "node:path";
93860
94006
  import { createHash as createHash19 } from "node:crypto";
93861
- import { readFileSync as readFileSync38 } from "node:fs";
94007
+ import { readFileSync as readFileSync39 } from "node:fs";
93862
94008
 
93863
94009
  // src/history-dependency-snapshot.ts
93864
94010
  init_src();
@@ -93981,7 +94127,7 @@ var Bounded = class extends Map {
93981
94127
  var DEFAULT_GIT = {};
93982
94128
  function readFileSafe(path3) {
93983
94129
  try {
93984
- return readFileSync38(path3, "utf8");
94130
+ return readFileSync39(path3, "utf8");
93985
94131
  } catch {
93986
94132
  return "";
93987
94133
  }
@@ -94012,13 +94158,13 @@ async function syncHistoryRevision(opts) {
94012
94158
  const started2 = Date.now();
94013
94159
  let changed = 0, remaining = false;
94014
94160
  const pages = Math.min(20, Math.max(1, opts.maxPages ?? 10));
94015
- const resolve10 = opts.profile.projectId ? reverseSymbolResolver({ store: opts.store, salt: opts.salt, projectId: opts.profile.projectId }) : async () => null;
94161
+ const resolve11 = opts.profile.projectId ? reverseSymbolResolver({ store: opts.store, salt: opts.salt, projectId: opts.profile.projectId }) : async () => null;
94016
94162
  for (let i2 = 0; i2 < pages; i2++) {
94017
- const result = await syncHistoryRevisionPage(opts, resolve10);
94163
+ const result = await syncHistoryRevisionPage(opts, resolve11);
94018
94164
  changed += result.changed;
94019
94165
  remaining = result.remaining;
94020
94166
  if (!remaining || result.nextBeat || Date.now() - started2 >= (opts.budgetMs ?? 45e3)) break;
94021
- await new Promise((resolve11) => setImmediate(resolve11));
94167
+ await new Promise((resolve12) => setImmediate(resolve12));
94022
94168
  }
94023
94169
  return { changed, remaining };
94024
94170
  })();
@@ -94029,13 +94175,13 @@ async function syncHistoryRevision(opts) {
94029
94175
  if (inFlight.get(opts.root) === work) inFlight.delete(opts.root);
94030
94176
  }
94031
94177
  }
94032
- async function syncHistoryRevisionPage(opts, resolve10) {
94178
+ async function syncHistoryRevisionPage(opts, resolve11) {
94033
94179
  const { root, profile, store, cloud, salt } = opts;
94034
94180
  if (!profile.projectId) return { changed: 0, remaining: false };
94035
94181
  const projectId = profile.projectId;
94036
94182
  const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
94037
94183
  const caches = cachesFor(opts.git ?? DEFAULT_GIT);
94038
- const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join43(root, ".errataignore"))).digest("hex").slice(0, 16);
94184
+ const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join44(root, ".errataignore"))).digest("hex").slice(0, 16);
94039
94185
  const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
94040
94186
  if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
94041
94187
  const oldCursor = profile.historyRevisionCursor;
@@ -94163,7 +94309,7 @@ async function syncHistoryRevisionPage(opts, resolve10) {
94163
94309
  const paths = /* @__PURE__ */ new Set(), symbols = [];
94164
94310
  let partial2 = false;
94165
94311
  for (const anchor of anchors ?? []) {
94166
- const localId = await resolve10(anchor.symbolId), local = localId ? store.getNode(localId) : null;
94312
+ const localId = await resolve11(anchor.symbolId), local = localId ? store.getNode(localId) : null;
94167
94313
  const path3 = local?.attrs["relPath"];
94168
94314
  if (typeof path3 !== "string" || !pathAllowedByFloor(path3) || isPathBlocked(ignore2, path3) || /[\r\n]/.test(path3)) continue;
94169
94315
  paths.add(path3);
@@ -94355,8 +94501,8 @@ ${await git3(["rev-list", "--parents", "-1", from])}`.split("\n").map((row) => r
94355
94501
  init_src7();
94356
94502
  init_src();
94357
94503
  import { execFile as execFile7 } from "node:child_process";
94358
- import { readFileSync as readFileSync39 } from "node:fs";
94359
- import { join as join44 } from "node:path";
94504
+ import { readFileSync as readFileSync40 } from "node:fs";
94505
+ import { join as join45 } from "node:path";
94360
94506
  import { promisify as promisify5 } from "node:util";
94361
94507
 
94362
94508
  // src/history-walk.ts
@@ -94688,7 +94834,7 @@ function narrativeSources(unit, group) {
94688
94834
  if (!group || group.length === 0) return [{ commitSha: unit.sha, text: message(unit).trim() }].filter((s) => s.text.length > 0);
94689
94835
  const members = group.filter((g) => g.groupSha === (unit.groupSha ?? unit.sha)).sort((a, b) => a.subIndex - b.subIndex);
94690
94836
  const source = members.length > 0 ? members : [...group].sort((a, b) => a.subIndex - b.subIndex);
94691
- return source.map((member) => ({ commitSha: member.sha, text: message(member).trim() })).filter((s) => s.text.length > 0);
94837
+ return source.map((member2) => ({ commitSha: member2.sha, text: message(member2).trim() })).filter((s) => s.text.length > 0);
94692
94838
  }
94693
94839
 
94694
94840
  // src/git-batch.ts
@@ -94763,8 +94909,8 @@ var GitBlobReader = class {
94763
94909
  if (this.failed) return Promise.reject(this.failed);
94764
94910
  if (/[\r\n]/.test(spec)) return Promise.resolve(null);
94765
94911
  const proc = this.start();
94766
- return new Promise((resolve10, reject) => {
94767
- this.queue.push({ resolve: resolve10, reject });
94912
+ return new Promise((resolve11, reject) => {
94913
+ this.queue.push({ resolve: resolve11, reject });
94768
94914
  proc.stdin.write(`${spec}
94769
94915
  `);
94770
94916
  });
@@ -94778,14 +94924,14 @@ var GitBlobReader = class {
94778
94924
  const proc = this.proc;
94779
94925
  this.proc = null;
94780
94926
  if (!proc || proc.exitCode !== null) return Promise.resolve();
94781
- return new Promise((resolve10) => {
94927
+ return new Promise((resolve11) => {
94782
94928
  const timer = setTimeout(() => {
94783
94929
  proc.kill();
94784
- resolve10();
94930
+ resolve11();
94785
94931
  }, timeoutMs);
94786
94932
  proc.once("exit", () => {
94787
94933
  clearTimeout(timer);
94788
- resolve10();
94934
+ resolve11();
94789
94935
  });
94790
94936
  proc.stdin.end();
94791
94937
  });
@@ -94915,7 +95061,7 @@ async function defaultGit(root, args2) {
94915
95061
  function readIgnoreLines(root, profile) {
94916
95062
  let lines = [];
94917
95063
  try {
94918
- lines = readFileSync39(join44(root, ".errataignore"), "utf8").split("\n");
95064
+ lines = readFileSync40(join45(root, ".errataignore"), "utf8").split("\n");
94919
95065
  } catch {
94920
95066
  }
94921
95067
  return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
@@ -95495,8 +95641,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
95495
95641
  init_cloud_auth();
95496
95642
  import { createHash as createHash20 } from "node:crypto";
95497
95643
  import { execFileSync as execFileSync7 } from "node:child_process";
95498
- import { existsSync as existsSync32, writeFileSync as writeFileSync28 } from "node:fs";
95499
- import { join as join45 } from "node:path";
95644
+ import { existsSync as existsSync33, writeFileSync as writeFileSync28 } from "node:fs";
95645
+ import { join as join46 } from "node:path";
95500
95646
 
95501
95647
  // src/device-poll.ts
95502
95648
  var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
@@ -95586,7 +95732,7 @@ async function loginOAuthDevice(opts) {
95586
95732
  let deviceSession = null;
95587
95733
  let approvedInstallation = null;
95588
95734
  while (Date.now() < deadline) {
95589
- await (opts.sleep ?? ((ms) => new Promise((resolve10) => setTimeout(resolve10, ms))))(waitMs);
95735
+ await (opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms))))(waitMs);
95590
95736
  waitMs = intervalMs;
95591
95737
  const poll = await fetchDevicePoll(fetchFn, device.token, {
95592
95738
  method: "POST",
@@ -95711,7 +95857,7 @@ async function loginOAuthLoopback(opts) {
95711
95857
  const state = randomState();
95712
95858
  const scope = opts.scope ?? CODE_FLOW_OAUTH_SCOPE;
95713
95859
  const { code, redirectUri, clientId } = await new Promise(
95714
- (resolve10, reject) => {
95860
+ (resolve11, reject) => {
95715
95861
  const server = createServer((req, res) => {
95716
95862
  const u = new URL(req.url ?? "/", "http://127.0.0.1");
95717
95863
  if (u.pathname !== "/callback") {
@@ -95734,7 +95880,7 @@ async function loginOAuthLoopback(opts) {
95734
95880
  res.writeHead(200, { "content-type": "text/html" });
95735
95881
  res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
95736
95882
  server.close();
95737
- resolve10({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
95883
+ resolve11({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
95738
95884
  });
95739
95885
  let activeClientId = oauthClientId();
95740
95886
  server.on("error", reject);
@@ -95833,7 +95979,7 @@ async function linkThroughConsole(opts) {
95833
95979
  const deadline = Date.now() + Math.min(code.expires_in * 1e3, opts.timeoutMs ?? Number.POSITIVE_INFINITY);
95834
95980
  let intervalMs = Math.max(2, code.interval ?? 5) * 1e3;
95835
95981
  let waitMs = intervalMs;
95836
- const sleep = opts.sleep ?? ((ms) => new Promise((resolve10) => setTimeout(resolve10, ms)));
95982
+ const sleep = opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms)));
95837
95983
  while (Date.now() < deadline) {
95838
95984
  await sleep(waitMs);
95839
95985
  waitMs = intervalMs;
@@ -95955,8 +96101,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
95955
96101
  delete nextProfile.projectLinkHold;
95956
96102
  let wroteIgnore = false;
95957
96103
  if (decision.writeIgnoreStarter !== false) {
95958
- const target = join45(root, ".errataignore");
95959
- if (!existsSync32(target)) {
96104
+ const target = join46(root, ".errataignore");
96105
+ if (!existsSync33(target)) {
95960
96106
  writeFileSync28(target, IGNORE_STARTER, "utf8");
95961
96107
  wroteIgnore = true;
95962
96108
  }
@@ -95970,13 +96116,13 @@ init_registry();
95970
96116
 
95971
96117
  // src/adopt.ts
95972
96118
  init_git_remote();
95973
- import { existsSync as existsSync33 } from "node:fs";
95974
- import { dirname as dirname16, join as join46 } from "node:path";
96119
+ import { existsSync as existsSync34 } from "node:fs";
96120
+ import { dirname as dirname17, join as join47 } from "node:path";
95975
96121
  function findGitRoot(absPath) {
95976
96122
  let dir = absPath;
95977
96123
  for (let depth = 0; depth < 64; depth++) {
95978
- if (existsSync33(join46(dir, ".git"))) return dir;
95979
- const parent = dirname16(dir);
96124
+ if (existsSync34(join47(dir, ".git"))) return dir;
96125
+ const parent = dirname17(dir);
95980
96126
  if (parent === dir) return null;
95981
96127
  dir = parent;
95982
96128
  }
@@ -96365,8 +96511,8 @@ function misfiledTarget(roots, home) {
96365
96511
  if (roots.includes(home)) return null;
96366
96512
  const tally = /* @__PURE__ */ new Map();
96367
96513
  for (const r of roots) tally.set(r, (tally.get(r) ?? 0) + 1);
96368
- const ranked = [...tally].sort((a, b) => b[1] - a[1]);
96369
- const [top, next] = ranked;
96514
+ const ranked2 = [...tally].sort((a, b) => b[1] - a[1]);
96515
+ const [top, next] = ranked2;
96370
96516
  if (!top || top[1] < FOCUS_QUORUM || next && next[1] === top[1]) return null;
96371
96517
  return top[0];
96372
96518
  }
@@ -96389,7 +96535,7 @@ function resolveWorkspaceRef(ref, entries, ownerRoot) {
96389
96535
 
96390
96536
  // src/rehome.ts
96391
96537
  init_src2();
96392
- import { isAbsolute as isAbsolute6 } from "node:path";
96538
+ import { isAbsolute as isAbsolute7 } from "node:path";
96393
96539
  function sourcesOf(n) {
96394
96540
  const s = n.attrs["sources"];
96395
96541
  return Array.isArray(s) ? s.filter((x) => typeof x === "string") : [];
@@ -96453,7 +96599,7 @@ function captureWorkPaths(store, home) {
96453
96599
  if (store.outEdges(row.id, ["ANCHORED_AT"]).length > 0) where = home;
96454
96600
  else {
96455
96601
  const hint = row.attrs["anchorHint"];
96456
- if (typeof hint?.path === "string" && hint.path.length > 0) where = isAbsolute6(hint.path) ? hint.path : home;
96602
+ if (typeof hint?.path === "string" && hint.path.length > 0) where = isAbsolute7(hint.path) ? hint.path : home;
96457
96603
  }
96458
96604
  for (const s of sources) {
96459
96605
  const list = out2.get(s) ?? [];
@@ -96618,7 +96764,7 @@ async function startMultiDaemon(opts = {}) {
96618
96764
  };
96619
96765
  const sharedDbPath = sharedStorePath();
96620
96766
  ensureParent(sharedDbPath);
96621
- if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname17(sharedDbPath));
96767
+ if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname18(sharedDbPath));
96622
96768
  await prepareStore(sharedDbPath, process.cwd(), "shared");
96623
96769
  const sharedStore = openGraphStore({ path: sharedDbPath });
96624
96770
  const bundledRun = import.meta.url.endsWith(".mjs");
@@ -96762,7 +96908,7 @@ async function startMultiDaemon(opts = {}) {
96762
96908
  held.push(...quarantined);
96763
96909
  let ignoreFile = "";
96764
96910
  try {
96765
- ignoreFile = readFileSync40(join47(r.root, ".errataignore"), "utf8");
96911
+ ignoreFile = readFileSync41(join48(r.root, ".errataignore"), "utf8");
96766
96912
  } catch {
96767
96913
  }
96768
96914
  const retryInputs = JSON.stringify([
@@ -96830,7 +96976,7 @@ async function startMultiDaemon(opts = {}) {
96830
96976
  const id = entry.id;
96831
96977
  const castaliaPath = workspacePaths(entry.path).castalia;
96832
96978
  ensureParent(castaliaPath);
96833
- excludeFromIndexing(dirname17(castaliaPath));
96979
+ excludeFromIndexing(dirname18(castaliaPath));
96834
96980
  await prepareStore(castaliaPath, entry.path, id);
96835
96981
  if (stopping) throw new Error("daemon stopping");
96836
96982
  const wsIdentity = identityFor(entry);
@@ -97337,10 +97483,10 @@ async function startMultiDaemon(opts = {}) {
97337
97483
  };
97338
97484
  const MISFILED_SWEEP_DELAY_MS = 2 * 6e4;
97339
97485
  const sweepMisfiled = async (rec) => {
97340
- const checkedPath = join47(workspacePaths(rec.root).configDir, "rehome-checked.json");
97486
+ const checkedPath = join48(workspacePaths(rec.root).configDir, "rehome-checked.json");
97341
97487
  let checked;
97342
97488
  try {
97343
- checked = new Set(JSON.parse(readFileSync40(checkedPath, "utf8")));
97489
+ checked = new Set(JSON.parse(readFileSync41(checkedPath, "utf8")));
97344
97490
  } catch {
97345
97491
  checked = /* @__PURE__ */ new Set();
97346
97492
  }
@@ -97459,7 +97605,7 @@ async function startMultiDaemon(opts = {}) {
97459
97605
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
97460
97606
  } catch {
97461
97607
  }
97462
- const reason = retireDecision({ exists: existsSync34(rec.root), lastActiveAt, now });
97608
+ const reason = retireDecision({ exists: existsSync35(rec.root), lastActiveAt, now });
97463
97609
  if (reason) void retireWorkspace(rec, reason);
97464
97610
  }
97465
97611
  };
@@ -97822,7 +97968,7 @@ async function startMultiDaemon(opts = {}) {
97822
97968
  const packageAutoAll = async () => {
97823
97969
  const out2 = /* @__PURE__ */ new Map();
97824
97970
  for (const r of records) {
97825
- await new Promise((resolve10) => setImmediate(resolve10));
97971
+ await new Promise((resolve11) => setImmediate(resolve11));
97826
97972
  const done = markPass(`package-index:${r.entry.name}`);
97827
97973
  try {
97828
97974
  out2.set(
@@ -99086,15 +99232,15 @@ function shouldUseOAuthLogin(flags2, env2 = process.env) {
99086
99232
  import { spawnSync as spawnSync2 } from "node:child_process";
99087
99233
 
99088
99234
  // src/codex-runtime.ts
99089
- import { readdirSync as readdirSync13, statSync as statSync12 } from "node:fs";
99090
- import { join as join48 } from "node:path";
99235
+ import { readdirSync as readdirSync13, statSync as statSync13 } from "node:fs";
99236
+ import { join as join49 } from "node:path";
99091
99237
  function resolveCodexExecutable(options = {}) {
99092
99238
  const platform = options.platform ?? process.platform;
99093
99239
  const env2 = options.env ?? process.env;
99094
99240
  if (platform !== "win32") return "codex";
99095
99241
  const fileTime = (path3) => {
99096
99242
  try {
99097
- const s = statSync12(path3);
99243
+ const s = statSync13(path3);
99098
99244
  return s.isFile() ? s.mtimeMs : null;
99099
99245
  } catch {
99100
99246
  return null;
@@ -99102,13 +99248,13 @@ function resolveCodexExecutable(options = {}) {
99102
99248
  };
99103
99249
  for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
99104
99250
  if (!dir.trim()) continue;
99105
- const path3 = join48(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
99251
+ const path3 = join49(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
99106
99252
  if (fileTime(path3) !== null) return path3;
99107
99253
  }
99108
99254
  if (!env2["LOCALAPPDATA"]) return "codex";
99109
- const root = join48(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
99255
+ const root = join49(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
99110
99256
  try {
99111
- const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join48(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));
99257
+ const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join49(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));
99112
99258
  return candidates[0]?.path ?? "codex";
99113
99259
  } catch {
99114
99260
  return "codex";
@@ -99247,14 +99393,14 @@ async function diagnoseInstallation(cfg, dependencies) {
99247
99393
  }
99248
99394
 
99249
99395
  // src/credential-scan.ts
99250
- import { readFileSync as readFileSync42, statSync as statSync13 } from "node:fs";
99396
+ import { readFileSync as readFileSync43, statSync as statSync14 } from "node:fs";
99251
99397
  import { homedir as homedir8 } from "node:os";
99252
- import { join as join50 } from "node:path";
99398
+ import { join as join51 } from "node:path";
99253
99399
 
99254
99400
  // src/claude-statusline.ts
99255
- import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync41, writeFileSync as writeFileSync30 } from "node:fs";
99401
+ import { existsSync as existsSync36, mkdirSync as mkdirSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync30 } from "node:fs";
99256
99402
  import { homedir as homedir7 } from "node:os";
99257
- import { dirname as dirname18, join as join49 } from "node:path";
99403
+ import { dirname as dirname19, join as join50 } from "node:path";
99258
99404
  var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
99259
99405
  import { readFileSync } from 'node:fs';
99260
99406
 
@@ -99302,8 +99448,8 @@ function isSameInstall(value, relay) {
99302
99448
  return command.includes(relay.replace(/\\/g, "/").toLowerCase());
99303
99449
  }
99304
99450
  function userClaudeSettingsPath() {
99305
- const base = process.env["CLAUDE_CONFIG_DIR"] ?? join49(homedir7(), ".claude");
99306
- return join49(base, "settings.json");
99451
+ const base = process.env["CLAUDE_CONFIG_DIR"] ?? join50(homedir7(), ".claude");
99452
+ return join50(base, "settings.json");
99307
99453
  }
99308
99454
  function ensureUserStatusLine(opts) {
99309
99455
  const env2 = opts.env ?? process.env;
@@ -99311,22 +99457,22 @@ function ensureUserStatusLine(opts) {
99311
99457
  if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
99312
99458
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
99313
99459
  let settings = {};
99314
- if (existsSync35(settingsPath)) {
99460
+ if (existsSync36(settingsPath)) {
99315
99461
  try {
99316
- const parsed = JSON.parse(readFileSync41(settingsPath, "utf8"));
99462
+ const parsed = JSON.parse(readFileSync42(settingsPath, "utf8"));
99317
99463
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
99318
99464
  settings = parsed;
99319
99465
  } catch {
99320
99466
  return "unreadable";
99321
99467
  }
99322
99468
  }
99323
- const relay = join49(opts.relayDir, STATUSLINE_RELAY_FILE);
99469
+ const relay = join50(opts.relayDir, STATUSLINE_RELAY_FILE);
99324
99470
  const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
99325
99471
  const ownMain = keep(settings["statusLine"]);
99326
99472
  const ownRows = keep(settings["subagentStatusLine"]);
99327
99473
  if (ownMain && ownRows) return "kept-own";
99328
99474
  mkdirSync9(opts.relayDir, { recursive: true });
99329
- if (!existsSync35(relay) || readFileSync41(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
99475
+ if (!existsSync36(relay) || readFileSync42(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
99330
99476
  writeFileSync30(relay, STATUSLINE_RELAY_SOURCE, "utf8");
99331
99477
  }
99332
99478
  const nodePath = opts.nodePath ?? process.execPath;
@@ -99338,7 +99484,7 @@ function ensureUserStatusLine(opts) {
99338
99484
  return ownMain ? "kept-own" : "unchanged";
99339
99485
  }
99340
99486
  Object.assign(settings, next);
99341
- mkdirSync9(dirname18(settingsPath), { recursive: true });
99487
+ mkdirSync9(dirname19(settingsPath), { recursive: true });
99342
99488
  writeFileSync30(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
99343
99489
  return "installed";
99344
99490
  }
@@ -99380,36 +99526,36 @@ function findCredentialLines(text) {
99380
99526
  function harnessConfigPaths(root) {
99381
99527
  const env2 = process.env;
99382
99528
  const home = homedir8();
99383
- const codexHome = env2["CODEX_HOME"] || join50(home, ".codex");
99384
- const geminiHome = join50(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
99529
+ const codexHome = env2["CODEX_HOME"] || join51(home, ".codex");
99530
+ const geminiHome = join51(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
99385
99531
  return [
99386
99532
  // Claude Code: user settings, `claude mcp add` (local/user scope), project.
99387
99533
  userClaudeSettingsPath(),
99388
- join50(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
99389
- join50(root, ".claude", "settings.json"),
99390
- join50(root, ".claude", "settings.local.json"),
99391
- join50(root, ".mcp.json"),
99534
+ join51(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
99535
+ join51(root, ".claude", "settings.json"),
99536
+ join51(root, ".claude", "settings.local.json"),
99537
+ join51(root, ".mcp.json"),
99392
99538
  // Codex
99393
- join50(codexHome, "config.toml"),
99394
- join50(root, ".codex", "config.toml"),
99539
+ join51(codexHome, "config.toml"),
99540
+ join51(root, ".codex", "config.toml"),
99395
99541
  // Gemini CLI
99396
- join50(geminiHome, "settings.json"),
99397
- join50(root, ".gemini", "settings.json"),
99542
+ join51(geminiHome, "settings.json"),
99543
+ join51(root, ".gemini", "settings.json"),
99398
99544
  // Cursor
99399
- join50(home, ".cursor", "mcp.json"),
99400
- join50(root, ".cursor", "mcp.json"),
99545
+ join51(home, ".cursor", "mcp.json"),
99546
+ join51(root, ".cursor", "mcp.json"),
99401
99547
  // VS Code (user profile mcp.json + workspace)
99402
- join50(vscodeUserDir(home, env2), "mcp.json"),
99403
- join50(root, ".vscode", "mcp.json"),
99548
+ join51(vscodeUserDir(home, env2), "mcp.json"),
99549
+ join51(root, ".vscode", "mcp.json"),
99404
99550
  // OpenCode (XDG on every platform; the daemon's installer writes the project one)
99405
- join50(env2["XDG_CONFIG_HOME"] ?? join50(home, ".config"), "opencode", "opencode.json"),
99406
- join50(root, "opencode.json")
99551
+ join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "opencode", "opencode.json"),
99552
+ join51(root, "opencode.json")
99407
99553
  ];
99408
99554
  }
99409
99555
  function vscodeUserDir(home, env2) {
99410
- if (process.platform === "win32") return join50(env2["APPDATA"] ?? join50(home, "AppData", "Roaming"), "Code", "User");
99411
- if (process.platform === "darwin") return join50(home, "Library", "Application Support", "Code", "User");
99412
- return join50(env2["XDG_CONFIG_HOME"] ?? join50(home, ".config"), "Code", "User");
99556
+ if (process.platform === "win32") return join51(env2["APPDATA"] ?? join51(home, "AppData", "Roaming"), "Code", "User");
99557
+ if (process.platform === "darwin") return join51(home, "Library", "Application Support", "Code", "User");
99558
+ return join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "Code", "User");
99413
99559
  }
99414
99560
  function scanHarnessConfigs(paths, read2 = readBounded) {
99415
99561
  const findings = [];
@@ -99424,9 +99570,9 @@ function scanHarnessConfigs(paths, read2 = readBounded) {
99424
99570
  }
99425
99571
  function readBounded(path3) {
99426
99572
  try {
99427
- const stat4 = statSync13(path3);
99573
+ const stat4 = statSync14(path3);
99428
99574
  if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
99429
- return readFileSync42(path3, "utf8");
99575
+ return readFileSync43(path3, "utf8");
99430
99576
  } catch {
99431
99577
  return null;
99432
99578
  }
@@ -99451,14 +99597,14 @@ function credentialHygieneCheck(scan2) {
99451
99597
 
99452
99598
  // src/codex-doctor.ts
99453
99599
  import { spawn as spawn4 } from "node:child_process";
99454
- import { readFileSync as readFileSync44, statSync as statSync14 } from "node:fs";
99455
- import { join as join52 } from "node:path";
99600
+ import { readFileSync as readFileSync45, statSync as statSync15 } from "node:fs";
99601
+ import { join as join53 } from "node:path";
99456
99602
  import { createInterface } from "node:readline";
99457
99603
 
99458
99604
  // src/codex-hooks.ts
99459
- import { existsSync as existsSync36, mkdirSync as mkdirSync10, readFileSync as readFileSync43, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
99605
+ import { existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync44, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
99460
99606
  import { homedir as homedir9 } from "node:os";
99461
- import { join as join51 } from "node:path";
99607
+ import { join as join52 } from "node:path";
99462
99608
 
99463
99609
  // src/hook-commands.ts
99464
99610
  function hookCurlCommand(port, path3 = "/api/hook") {
@@ -99670,34 +99816,34 @@ function buildCodexRelaySource(workspaceRoot) {
99670
99816
  init_checkout_root();
99671
99817
  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.";
99672
99818
  function writeRelay(file2, source) {
99673
- if (existsSync36(file2) && readFileSync43(file2, "utf8") === source) return;
99819
+ if (existsSync37(file2) && readFileSync44(file2, "utf8") === source) return;
99674
99820
  const temp = `${file2}.${process.pid}.tmp`;
99675
99821
  try {
99676
99822
  writeFileSync31(temp, source, { encoding: "utf8", mode: 384 });
99677
99823
  renameSync8(temp, file2);
99678
99824
  } finally {
99679
- if (existsSync36(temp)) unlinkSync5(temp);
99825
+ if (existsSync37(temp)) unlinkSync5(temp);
99680
99826
  }
99681
99827
  }
99682
99828
  function refreshCodexRelay(root) {
99683
- const config2 = join51(root, ".codex", "config.toml");
99684
- if (!existsSync36(config2)) return "absent";
99685
- const existing = readFileSync43(config2, "utf8");
99829
+ const config2 = join52(root, ".codex", "config.toml");
99830
+ if (!existsSync37(config2)) return "absent";
99831
+ const existing = readFileSync44(config2, "utf8");
99686
99832
  if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
99687
99833
  replaceCodexHooks(existing, "");
99688
- const relay = join51(root, ".codex", "hooks", "errata-relay.mjs");
99689
- const prior = existsSync36(relay) ? readFileSync43(relay, "utf8") : "";
99834
+ const relay = join52(root, ".codex", "hooks", "errata-relay.mjs");
99835
+ const prior = existsSync37(relay) ? readFileSync44(relay, "utf8") : "";
99690
99836
  if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
99691
99837
  throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
99692
99838
  }
99693
99839
  const source = buildCodexRelaySource(checkoutRootOf(root));
99694
99840
  if (prior === source) return "current";
99695
- mkdirSync10(join51(root, ".codex", "hooks"), { recursive: true });
99841
+ mkdirSync10(join52(root, ".codex", "hooks"), { recursive: true });
99696
99842
  writeRelay(relay, source);
99697
99843
  return "updated";
99698
99844
  }
99699
- function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join51(homedir9(), ".codex")) {
99700
- return existsSync36(join51(root, ".codex")) || existsSync36(codexHome);
99845
+ function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join52(homedir9(), ".codex")) {
99846
+ return existsSync37(join52(root, ".codex")) || existsSync37(codexHome);
99701
99847
  }
99702
99848
  function replaceCodexHooks(existing, block) {
99703
99849
  const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
@@ -99713,14 +99859,14 @@ function replaceCodexHooks(existing, block) {
99713
99859
  return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
99714
99860
  }
99715
99861
  function writeCodexHooks(root, port, nodePath = process.execPath) {
99716
- const dir = join51(root, ".codex");
99717
- const file2 = join51(dir, "config.toml");
99718
- const relay = join51(dir, "hooks", "errata-relay.mjs");
99862
+ const dir = join52(root, ".codex");
99863
+ const file2 = join52(dir, "config.toml");
99864
+ const relay = join52(dir, "hooks", "errata-relay.mjs");
99719
99865
  const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
99720
- const final = replaceCodexHooks(existsSync36(file2) ? readFileSync43(file2, "utf8") : "", block);
99721
- mkdirSync10(join51(dir, "hooks"), { recursive: true });
99866
+ const final = replaceCodexHooks(existsSync37(file2) ? readFileSync44(file2, "utf8") : "", block);
99867
+ mkdirSync10(join52(dir, "hooks"), { recursive: true });
99722
99868
  writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
99723
- if (!existsSync36(file2) || readFileSync43(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
99869
+ if (!existsSync37(file2) || readFileSync44(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
99724
99870
  return file2;
99725
99871
  }
99726
99872
 
@@ -99729,7 +99875,7 @@ init_checkout_root();
99729
99875
  function inspectCodexRelay(cwd) {
99730
99876
  const root = nearestGitRoot(cwd) ?? cwd;
99731
99877
  try {
99732
- const source = readFileSync44(join52(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
99878
+ const source = readFileSync45(join53(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
99733
99879
  if (source === buildCodexRelaySource(checkoutRootOf(root))) {
99734
99880
  return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
99735
99881
  }
@@ -99740,8 +99886,8 @@ function inspectCodexRelay(cwd) {
99740
99886
  function inspectCodexContext(cwd) {
99741
99887
  const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
99742
99888
  try {
99743
- const file2 = join52(root, ".errata", "context.md");
99744
- if (statSync14(file2).size <= 128 * 1024 && readFileSync44(file2, "utf8").trim()) {
99889
+ const file2 = join53(root, ".errata", "context.md");
99890
+ if (statSync15(file2).size <= 128 * 1024 && readFileSync45(file2, "utf8").trim()) {
99745
99891
  return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
99746
99892
  }
99747
99893
  } catch {
@@ -99751,7 +99897,7 @@ function inspectCodexContext(cwd) {
99751
99897
  var CodexRuntimeUnavailableError = class extends Error {
99752
99898
  };
99753
99899
  function readCodexHookState(cwd, options = {}) {
99754
- return new Promise((resolve10, reject) => {
99900
+ return new Promise((resolve11, reject) => {
99755
99901
  const child = spawn4(options.bin ?? resolveCodexExecutable(), options.args ?? ["app-server", "--stdio"], {
99756
99902
  cwd,
99757
99903
  windowsHide: true,
@@ -99772,7 +99918,7 @@ function readCodexHookState(cwd, options = {}) {
99772
99918
  child.once("close", () => {
99773
99919
  clearTimeout(reap);
99774
99920
  if (error48) reject(error48);
99775
- else resolve10({ ...hooks, features });
99921
+ else resolve11({ ...hooks, features });
99776
99922
  });
99777
99923
  child.kill();
99778
99924
  };
@@ -99919,9 +100065,9 @@ function consolidationGapMs(lastPassMs, policy) {
99919
100065
 
99920
100066
  // src/codex-context-plugin.ts
99921
100067
  import { createHash as createHash21 } from "node:crypto";
99922
- import { cpSync as cpSync2, existsSync as existsSync37, mkdirSync as mkdirSync11, readFileSync as readFileSync45, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
100068
+ import { cpSync as cpSync2, existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync46, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
99923
100069
  import { homedir as homedir10 } from "node:os";
99924
- import { join as join53 } from "node:path";
100070
+ import { join as join54 } from "node:path";
99925
100071
  import { fileURLToPath as fileURLToPath3 } from "node:url";
99926
100072
 
99927
100073
  // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
@@ -100619,7 +100765,7 @@ var NAME = "errata-context";
100619
100765
  var PREFIX2 = `./.errata/plugins/${NAME}/`;
100620
100766
  var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
100621
100767
  function readText(file2) {
100622
- return existsSync37(file2) ? readFileSync45(file2, "utf8") : "";
100768
+ return existsSync38(file2) ? readFileSync46(file2, "utf8") : "";
100623
100769
  }
100624
100770
  function writeChanged(file2, content) {
100625
100771
  if (readText(file2) === content) return;
@@ -100629,13 +100775,13 @@ function writeChanged(file2, content) {
100629
100775
  }
100630
100776
  function bundledContextPlugin() {
100631
100777
  const packaged = fileURLToPath3(new URL("./resources/context-plugin/", import.meta.url));
100632
- if (existsSync37(join53(packaged, ".codex-plugin/plugin.json"))) return packaged;
100778
+ if (existsSync38(join54(packaged, ".codex-plugin/plugin.json"))) return packaged;
100633
100779
  return fileURLToPath3(new URL("../dist/resources/context-plugin/", import.meta.url));
100634
100780
  }
100635
100781
  function refreshCodexContextPlugin(root) {
100636
- const file2 = join53(root, ".agents", "plugins", "marketplace.json");
100637
- if (!existsSync37(file2)) return false;
100638
- const marketplace = JSON.parse(readFileSync45(file2, "utf8"));
100782
+ const file2 = join54(root, ".agents", "plugins", "marketplace.json");
100783
+ if (!existsSync38(file2)) return false;
100784
+ const marketplace = JSON.parse(readFileSync46(file2, "utf8"));
100639
100785
  const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
100640
100786
  const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
100641
100787
  if (!entry) return false;
@@ -100646,24 +100792,24 @@ function refreshCodexContextPlugin(root) {
100646
100792
  function installCodexContextPlugin(root, options = {}) {
100647
100793
  const bundle = options.bundle ?? bundledContextPlugin();
100648
100794
  const manifest = JSON.parse(
100649
- readFileSync45(join53(bundle, ".codex-plugin/plugin.json"), "utf8")
100795
+ readFileSync46(join54(bundle, ".codex-plugin/plugin.json"), "utf8")
100650
100796
  );
100651
100797
  if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
100652
100798
  throw new Error("Invalid bundled Errata Context manifest.");
100653
100799
  }
100654
- const checksums = readFileSync45(join53(bundle, "SHA256SUMS"), "utf8");
100800
+ const checksums = readFileSync46(join54(bundle, "SHA256SUMS"), "utf8");
100655
100801
  for (const line of checksums.trim().split("\n")) {
100656
100802
  const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
100657
100803
  if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
100658
100804
  throw new Error("Invalid bundled Errata Context checksum manifest.");
100659
100805
  }
100660
- const actual = createHash21("sha256").update(readFileSync45(join53(bundle, match2[2]))).digest("hex");
100806
+ const actual = createHash21("sha256").update(readFileSync46(join54(bundle, match2[2]))).digest("hex");
100661
100807
  if (actual !== match2[1])
100662
100808
  throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
100663
100809
  }
100664
100810
  const release = `${manifest.version}-${createHash21("sha256").update(checksums).digest("hex").slice(0, 12)}`;
100665
- const plugin = join53(root, ".errata", "plugins", NAME, release);
100666
- const marketplaceFile = join53(root, ".agents", "plugins", "marketplace.json");
100811
+ const plugin = join54(root, ".errata", "plugins", NAME, release);
100812
+ const marketplaceFile = join54(root, ".agents", "plugins", "marketplace.json");
100667
100813
  const priorMarketplace = readText(marketplaceFile);
100668
100814
  const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
100669
100815
  name: "errata-local",
@@ -100684,12 +100830,12 @@ function installCodexContextPlugin(root, options = {}) {
100684
100830
  );
100685
100831
  }
100686
100832
  const key = `${NAME}@${marketplace.name}`;
100687
- const configFile = join53(root, ".codex", "config.toml");
100833
+ const configFile = join54(root, ".codex", "config.toml");
100688
100834
  const config2 = readText(configFile);
100689
100835
  const parsed = parse4(config2);
100690
100836
  const plugins = object2(parsed.plugins);
100691
- const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join53(homedir10(), ".codex");
100692
- const globalPlugins = object2(parse4(readText(join53(codexHome, "config.toml"))).plugins);
100837
+ const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join54(homedir10(), ".codex");
100838
+ const globalPlugins = object2(parse4(readText(join54(codexHome, "config.toml"))).plugins);
100693
100839
  const disabledGlobally = Object.entries(globalPlugins).some(
100694
100840
  ([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
100695
100841
  );
@@ -100713,13 +100859,13 @@ enabled = ${enabled}
100713
100859
  mkdirSync11(plugin, { recursive: true });
100714
100860
  cpSync2(bundle, plugin, { recursive: true });
100715
100861
  writeChanged(
100716
- join53(plugin, ".mcp.json"),
100862
+ join54(plugin, ".mcp.json"),
100717
100863
  JSON.stringify(
100718
100864
  {
100719
100865
  mcpServers: {
100720
100866
  errata_context: {
100721
100867
  command: options.nodePath ?? process.execPath,
100722
- args: [join53(plugin, "dist", "mcp-server.mjs")],
100868
+ args: [join54(plugin, "dist", "mcp-server.mjs")],
100723
100869
  env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
100724
100870
  }
100725
100871
  }
@@ -100728,8 +100874,8 @@ enabled = ${enabled}
100728
100874
  2
100729
100875
  ) + "\n"
100730
100876
  );
100731
- mkdirSync11(join53(root, ".agents", "plugins"), { recursive: true });
100732
- mkdirSync11(join53(root, ".codex"), { recursive: true });
100877
+ mkdirSync11(join54(root, ".agents", "plugins"), { recursive: true });
100878
+ mkdirSync11(join54(root, ".codex"), { recursive: true });
100733
100879
  writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
100734
100880
  writeChanged(configFile, nextConfig);
100735
100881
  return { plugin, enabled, marketplace: marketplaceFile };
@@ -100737,16 +100883,16 @@ enabled = ${enabled}
100737
100883
 
100738
100884
  // src/codex-hook-refresh.ts
100739
100885
  init_checkout_root();
100740
- import { existsSync as existsSync38, readdirSync as readdirSync14, readFileSync as readFileSync46 } from "node:fs";
100741
- import { dirname as dirname19, join as join54, resolve as resolve8 } from "node:path";
100886
+ import { existsSync as existsSync39, readdirSync as readdirSync14, readFileSync as readFileSync47 } from "node:fs";
100887
+ import { dirname as dirname20, join as join55, resolve as resolve9 } from "node:path";
100742
100888
  init_registry();
100743
100889
  function codexHookRoots(roots) {
100744
- const found = new Set(roots.map((root) => resolve8(root)));
100890
+ const found = new Set(roots.map((root) => resolve9(root)));
100745
100891
  for (const root of [...found]) {
100746
100892
  const main2 = mainCheckoutOfWorktree(root) ?? root;
100747
100893
  found.add(main2);
100748
- const dir = join54(main2, ".git", "worktrees");
100749
- if (!existsSync38(dir)) continue;
100894
+ const dir = join55(main2, ".git", "worktrees");
100895
+ if (!existsSync39(dir)) continue;
100750
100896
  let names;
100751
100897
  try {
100752
100898
  names = readdirSync14(dir);
@@ -100755,7 +100901,7 @@ function codexHookRoots(roots) {
100755
100901
  }
100756
100902
  for (const name2 of names) {
100757
100903
  try {
100758
- const checkout = dirname19(readFileSync46(join54(dir, name2, "gitdir"), "utf8").trim());
100904
+ const checkout = dirname20(readFileSync47(join55(dir, name2, "gitdir"), "utf8").trim());
100759
100905
  if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
100760
100906
  } catch {
100761
100907
  }
@@ -100778,8 +100924,8 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
100778
100924
 
100779
100925
  // src/claude-mods.ts
100780
100926
  import { createHash as createHash22 } from "node:crypto";
100781
- import { cpSync as cpSync3, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync47, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync15, writeFileSync as writeFileSync33 } from "node:fs";
100782
- import { delimiter as delimiter2, dirname as dirname20, join as join55, relative as relative7, resolve as resolve9, sep as sep6 } from "node:path";
100927
+ import { cpSync as cpSync3, existsSync as existsSync40, mkdirSync as mkdirSync12, readFileSync as readFileSync48, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync16, writeFileSync as writeFileSync33 } from "node:fs";
100928
+ import { delimiter as delimiter2, dirname as dirname21, join as join56, relative as relative7, resolve as resolve10, sep as sep6 } from "node:path";
100783
100929
  import { fileURLToPath as fileURLToPath4 } from "node:url";
100784
100930
  var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
100785
100931
  var HASH_FILE = ".errata-mod-hash";
@@ -100794,9 +100940,9 @@ function isEngineOwned(relPath) {
100794
100940
  function listFiles(root, dir = root) {
100795
100941
  const out2 = [];
100796
100942
  for (const name2 of readdirSync15(dir)) {
100797
- const abs = join55(dir, name2);
100943
+ const abs = join56(dir, name2);
100798
100944
  if (isEngineOwned(relative7(root, abs))) continue;
100799
- if (statSync15(abs).isDirectory()) out2.push(...listFiles(root, abs));
100945
+ if (statSync16(abs).isDirectory()) out2.push(...listFiles(root, abs));
100800
100946
  else out2.push(abs);
100801
100947
  }
100802
100948
  return out2;
@@ -100806,21 +100952,21 @@ function modHash(dir) {
100806
100952
  for (const abs of listFiles(dir).sort()) {
100807
100953
  h.update(relative7(dir, abs).split(sep6).join("/"));
100808
100954
  h.update("\0");
100809
- h.update(readFileSync47(abs));
100955
+ h.update(readFileSync48(abs));
100810
100956
  h.update("\0");
100811
100957
  }
100812
100958
  return h.digest("hex");
100813
100959
  }
100814
100960
  function bundledMods(bundleDir) {
100815
- if (!existsSync39(bundleDir)) return [];
100816
- return readdirSync15(bundleDir).filter((name2) => existsSync39(join55(bundleDir, name2, ".claude-plugin", "plugin.json")));
100961
+ if (!existsSync40(bundleDir)) return [];
100962
+ return readdirSync15(bundleDir).filter((name2) => existsSync40(join56(bundleDir, name2, ".claude-plugin", "plugin.json")));
100817
100963
  }
100818
100964
  function sameDir(a, b) {
100819
- const norm = (p) => resolve9(p).replace(/[\\/]+$/, "").toLowerCase();
100965
+ const norm = (p) => resolve10(p).replace(/[\\/]+$/, "").toLowerCase();
100820
100966
  return norm(a) === norm(b);
100821
100967
  }
100822
100968
  function isUnder(path3, root) {
100823
- const rel = relative7(resolve9(root), resolve9(path3));
100969
+ const rel = relative7(resolve10(root), resolve10(path3));
100824
100970
  return rel !== "" && !rel.startsWith("..") && !rel.includes(":");
100825
100971
  }
100826
100972
  function off(env2) {
@@ -100828,9 +100974,9 @@ function off(env2) {
100828
100974
  return v === "0" || v === "off" || v === "false" || v === "no";
100829
100975
  }
100830
100976
  function readSettings(path3) {
100831
- if (!existsSync39(path3)) return {};
100977
+ if (!existsSync40(path3)) return {};
100832
100978
  try {
100833
- const parsed = JSON.parse(readFileSync47(path3, "utf8"));
100979
+ const parsed = JSON.parse(readFileSync48(path3, "utf8"));
100834
100980
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
100835
100981
  return parsed;
100836
100982
  } catch {
@@ -100854,13 +101000,13 @@ function currentDirs(settings) {
100854
101000
  return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
100855
101001
  }
100856
101002
  function writeSettings(path3, settings) {
100857
- mkdirSync12(dirname20(path3), { recursive: true });
101003
+ mkdirSync12(dirname21(path3), { recursive: true });
100858
101004
  writeFileSync33(path3, JSON.stringify(settings, null, 2) + "\n", "utf8");
100859
101005
  }
100860
101006
  function ensureClaudeMods(opts) {
100861
101007
  const env2 = opts.env ?? process.env;
100862
101008
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
100863
- const modsRoot = join55(opts.installRoot, "claude-mods");
101009
+ const modsRoot = join56(opts.installRoot, "claude-mods");
100864
101010
  if (off(env2)) {
100865
101011
  const settings2 = readSettings(settingsPath);
100866
101012
  if (!settings2) return { kind: "unreadable" };
@@ -100877,11 +101023,11 @@ function ensureClaudeMods(opts) {
100877
101023
  let changed = false;
100878
101024
  const installed = [];
100879
101025
  for (const name2 of names) {
100880
- const src = join55(bundleDir, name2);
100881
- const dest = join55(modsRoot, name2);
101026
+ const src = join56(bundleDir, name2);
101027
+ const dest = join56(modsRoot, name2);
100882
101028
  const hash2 = modHash(src);
100883
- const hashFile = join55(dest, HASH_FILE);
100884
- if (!existsSync39(hashFile) || readFileSync47(hashFile, "utf8") !== hash2) {
101029
+ const hashFile = join56(dest, HASH_FILE);
101030
+ if (!existsSync40(hashFile) || readFileSync48(hashFile, "utf8") !== hash2) {
100885
101031
  rmSync4(dest, { recursive: true, force: true });
100886
101032
  cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
100887
101033
  writeFileSync33(hashFile, hash2, "utf8");
@@ -101315,9 +101461,9 @@ function resolveHookPort(explicit) {
101315
101461
  }
101316
101462
  }
101317
101463
  }
101318
- const settingsPath = join56(ROOT, ".claude", "settings.json");
101464
+ const settingsPath = join57(ROOT, ".claude", "settings.json");
101319
101465
  try {
101320
- if (existsSync40(settingsPath)) return installedHookPort(readFileSync48(settingsPath, "utf8")) ?? 7891;
101466
+ if (existsSync41(settingsPath)) return installedHookPort(readFileSync49(settingsPath, "utf8")) ?? 7891;
101321
101467
  } catch {
101322
101468
  }
101323
101469
  return 7891;
@@ -101342,14 +101488,14 @@ async function cmdInit() {
101342
101488
  if (!skipHooks) {
101343
101489
  console.log("");
101344
101490
  console.log("installing harness hooks...");
101345
- const { existsSync: existsSync41 } = await import("node:fs");
101346
- const { join: join57 } = await import("node:path");
101491
+ const { existsSync: existsSync42 } = await import("node:fs");
101492
+ const { join: join58 } = await import("node:path");
101347
101493
  try {
101348
101494
  await installClaudeHooks(port);
101349
101495
  } catch (err2) {
101350
101496
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
101351
101497
  }
101352
- if (existsSync41(join57(ROOT, ".cursor"))) {
101498
+ if (existsSync42(join58(ROOT, ".cursor"))) {
101353
101499
  try {
101354
101500
  await installCursorMcpConfig();
101355
101501
  } catch (err2) {
@@ -101564,12 +101710,12 @@ async function cmdStatus() {
101564
101710
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
101565
101711
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
101566
101712
  }
101567
- console.log(` graph db: ${existsSync40(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
101568
- console.log(` event log: ${existsSync40(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
101713
+ console.log(` graph db: ${existsSync41(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
101714
+ console.log(` event log: ${existsSync41(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
101569
101715
  for (const line of captureStatusLines(summarizePassLedger(paths.configDir).get("capture"))) {
101570
101716
  console.log(` capture: ${line}`);
101571
101717
  }
101572
- if (existsSync40(paths.castalia)) {
101718
+ if (existsSync41(paths.castalia)) {
101573
101719
  try {
101574
101720
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
101575
101721
  const store = openGraphStore2({ path: paths.castalia });
@@ -102570,11 +102716,11 @@ async function cmdInstallationProfile(args2) {
102570
102716
  }
102571
102717
  async function cmdReview() {
102572
102718
  const paths = workspacePaths(ROOT);
102573
- if (!existsSync40(paths.reviewQueue)) {
102719
+ if (!existsSync41(paths.reviewQueue)) {
102574
102720
  console.log("(review queue empty)");
102575
102721
  return;
102576
102722
  }
102577
- const queue = JSON.parse(readFileSync48(paths.reviewQueue, "utf8"));
102723
+ const queue = JSON.parse(readFileSync49(paths.reviewQueue, "utf8"));
102578
102724
  if (queue.length === 0) {
102579
102725
  console.log("(review queue empty)");
102580
102726
  return;
@@ -103222,9 +103368,9 @@ async function gatherRepo(store, ws) {
103222
103368
  }
103223
103369
  let hotspots;
103224
103370
  if (byFile.size > 0) {
103225
- const ranked = [...byFile].sort((a, b) => b[1] - a[1]).slice(0, 6);
103226
- const maxC = ranked[0]?.[1] ?? 1;
103227
- hotspots = ranked.map(([file2, c]) => ({
103371
+ const ranked2 = [...byFile].sort((a, b) => b[1] - a[1]).slice(0, 6);
103372
+ const maxC = ranked2[0]?.[1] ?? 1;
103373
+ hotspots = ranked2.map(([file2, c]) => ({
103228
103374
  file: file2.split(/[\\/]/).pop() ?? file2,
103229
103375
  problemCount: c,
103230
103376
  weight: c / maxC,
@@ -103274,7 +103420,7 @@ async function gatherRepo(store, ws) {
103274
103420
  };
103275
103421
  }
103276
103422
  async function gatherReportData(generatedAt) {
103277
- const { existsSync: existsSync41 } = await import("node:fs");
103423
+ const { existsSync: existsSync42 } = await import("node:fs");
103278
103424
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
103279
103425
  const cfg = loadConfig();
103280
103426
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -103282,7 +103428,7 @@ async function gatherReportData(generatedAt) {
103282
103428
  for (const ws of listWorkspaces()) {
103283
103429
  if (ws.missing) continue;
103284
103430
  const dbPath = workspacePaths(ws.path).castalia;
103285
- if (!existsSync41(dbPath)) continue;
103431
+ if (!existsSync42(dbPath)) continue;
103286
103432
  let store = null;
103287
103433
  try {
103288
103434
  store = openGraphStore2({ path: dbPath });
@@ -103326,8 +103472,8 @@ async function cmdReport(args2) {
103326
103472
  const outDir = workspacePaths(ROOT).configDir;
103327
103473
  mkdirSync13(outDir, { recursive: true });
103328
103474
  const files = renderReport2(data, { includeFutureVerbs });
103329
- for (const f of files) writeFileSync34(join56(outDir, f.name), f.html, "utf8");
103330
- const indexPath = join56(outDir, "report.html");
103475
+ for (const f of files) writeFileSync34(join57(outDir, f.name), f.html, "utf8");
103476
+ const indexPath = join57(outDir, "report.html");
103331
103477
  console.log(`report \u2192 ${indexPath}`);
103332
103478
  console.log(
103333
103479
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -103383,7 +103529,7 @@ function spawnDaemonDetached(options = {}) {
103383
103529
  try {
103384
103530
  const logPath = daemonLogPath();
103385
103531
  try {
103386
- if (statSync16(logPath).size > 5 * 1024 * 1024) renameSync10(logPath, `${logPath}.1`);
103532
+ if (statSync17(logPath).size > 5 * 1024 * 1024) renameSync10(logPath, `${logPath}.1`);
103387
103533
  } catch {
103388
103534
  }
103389
103535
  out2 = openSync3(logPath, "a");
@@ -103452,24 +103598,24 @@ async function cmdInstallHooks(args2) {
103452
103598
  }
103453
103599
  }
103454
103600
  async function installOpencodePlugin(port) {
103455
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103456
- const { join: join57 } = await import("node:path");
103457
- const dir = join57(ROOT, ".opencode", "plugin");
103458
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103459
- const file2 = join57(dir, "inerrata.js");
103460
- if (existsSync41(file2)) {
103461
- const head2 = readFileSync49(file2, "utf8").split("\n")[0] ?? "";
103601
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103602
+ const { join: join58 } = await import("node:path");
103603
+ const dir = join58(ROOT, ".opencode", "plugin");
103604
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103605
+ const file2 = join58(dir, "inerrata.js");
103606
+ if (existsSync42(file2)) {
103607
+ const head2 = readFileSync50(file2, "utf8").split("\n")[0] ?? "";
103462
103608
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
103463
103609
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
103464
103610
  process.exit(2);
103465
103611
  }
103466
103612
  }
103467
103613
  writeFileSync34(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
103468
- const cfgFile = join57(ROOT, "opencode.json");
103614
+ const cfgFile = join58(ROOT, "opencode.json");
103469
103615
  let cfg = { $schema: "https://opencode.ai/config.json" };
103470
- if (existsSync41(cfgFile)) {
103616
+ if (existsSync42(cfgFile)) {
103471
103617
  try {
103472
- cfg = JSON.parse(readFileSync49(cfgFile, "utf8"));
103618
+ cfg = JSON.parse(readFileSync50(cfgFile, "utf8"));
103473
103619
  } catch {
103474
103620
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
103475
103621
  process.exit(2);
@@ -103515,15 +103661,15 @@ function installClaudeMods() {
103515
103661
  }
103516
103662
  }
103517
103663
  async function installClaudeHooks(port) {
103518
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103519
- const { join: join57 } = await import("node:path");
103520
- const dir = join57(ROOT, ".claude");
103521
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103522
- const file2 = join57(dir, "settings.json");
103664
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103665
+ const { join: join58 } = await import("node:path");
103666
+ const dir = join58(ROOT, ".claude");
103667
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103668
+ const file2 = join58(dir, "settings.json");
103523
103669
  let settings = {};
103524
- if (existsSync41(file2)) {
103670
+ if (existsSync42(file2)) {
103525
103671
  try {
103526
- settings = JSON.parse(readFileSync49(file2, "utf8"));
103672
+ settings = JSON.parse(readFileSync50(file2, "utf8"));
103527
103673
  } catch {
103528
103674
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103529
103675
  process.exit(2);
@@ -103577,7 +103723,7 @@ async function installClaudeHooks(port) {
103577
103723
  console.log(` ${ensureStatusLine(port)}`);
103578
103724
  console.log(` ${installClaudeMods().line}`);
103579
103725
  await installClaudeMcpConfig();
103580
- const claudeMd = join57(ROOT, "CLAUDE.md");
103726
+ const claudeMd = join58(ROOT, "CLAUDE.md");
103581
103727
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
103582
103728
  if (recall.kind === "collision") {
103583
103729
  console.warn(
@@ -103589,15 +103735,15 @@ async function installClaudeHooks(port) {
103589
103735
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
103590
103736
  }
103591
103737
  async function installClaudeMcpConfig() {
103592
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103593
- const { join: join57, dirname: dirname21 } = await import("node:path");
103594
- const file2 = join57(ROOT, ".mcp.json");
103595
- const dir = dirname21(file2);
103596
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103738
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103739
+ const { join: join58, dirname: dirname22 } = await import("node:path");
103740
+ const file2 = join58(ROOT, ".mcp.json");
103741
+ const dir = dirname22(file2);
103742
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103597
103743
  let cfg = {};
103598
- if (existsSync41(file2)) {
103744
+ if (existsSync42(file2)) {
103599
103745
  try {
103600
- cfg = JSON.parse(readFileSync49(file2, "utf8"));
103746
+ cfg = JSON.parse(readFileSync50(file2, "utf8"));
103601
103747
  } catch {
103602
103748
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103603
103749
  process.exit(2);
@@ -103611,15 +103757,15 @@ async function installClaudeMcpConfig() {
103611
103757
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
103612
103758
  }
103613
103759
  async function installCursorMcpConfig() {
103614
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103615
- const { join: join57 } = await import("node:path");
103616
- const dir = join57(ROOT, ".cursor");
103617
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103618
- const file2 = join57(dir, "mcp.json");
103760
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103761
+ const { join: join58 } = await import("node:path");
103762
+ const dir = join58(ROOT, ".cursor");
103763
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103764
+ const file2 = join58(dir, "mcp.json");
103619
103765
  let cfg = {};
103620
- if (existsSync41(file2)) {
103766
+ if (existsSync42(file2)) {
103621
103767
  try {
103622
- cfg = JSON.parse(readFileSync49(file2, "utf8"));
103768
+ cfg = JSON.parse(readFileSync50(file2, "utf8"));
103623
103769
  } catch {
103624
103770
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103625
103771
  process.exit(2);
@@ -103638,7 +103784,7 @@ async function installCodexHooks(port) {
103638
103784
  const gitRoot = nearestGitRoot(process.cwd());
103639
103785
  const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
103640
103786
  const file2 = writeCodexHooks(hookRoot, port);
103641
- const instructions = writeManagedBlock(join56(hookRoot, "AGENTS.md"), {
103787
+ const instructions = writeManagedBlock(join57(hookRoot, "AGENTS.md"), {
103642
103788
  body: AGENTS_POINTER_BODY,
103643
103789
  stable: true
103644
103790
  });
@@ -104006,7 +104152,7 @@ async function cmdDash(args2) {
104006
104152
  const hotspotScanMark = /* @__PURE__ */ new Map();
104007
104153
  const HOTSPOT_FANIN = 20;
104008
104154
  const runNightlyPass = async (dueIds) => {
104009
- const yieldToLoop2 = () => new Promise((resolve10) => setImmediate(resolve10));
104155
+ const yieldToLoop2 = () => new Promise((resolve11) => setImmediate(resolve11));
104010
104156
  const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
104011
104157
  const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
104012
104158
  let skillsLearned = 0;
@@ -104084,9 +104230,9 @@ async function cmdDash(args2) {
104084
104230
  await yieldToLoop2();
104085
104231
  try {
104086
104232
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
104087
- atCommit: readGitRefState(join56(r.root, ".git")).sha ?? void 0
104233
+ atCommit: readGitRefState(join57(r.root, ".git")).sha ?? void 0
104088
104234
  });
104089
- const res = bleedRules(join56(r.root, ".claude", "rules"), items);
104235
+ const res = bleedRules(join57(r.root, ".claude", "rules"), items);
104090
104236
  if (res.written || res.pruned) {
104091
104237
  console.log(
104092
104238
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")