@inerrata-corporation/errata 2.0.4 → 2.0.5-dev.1868

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/errata.mjs +620 -453
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -911,7 +911,7 @@ function lemma(token) {
911
911
  }
912
912
  return token;
913
913
  }
914
- function tokenize(text, resolve6) {
914
+ function tokenize(text, resolve7) {
915
915
  const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
916
916
  const out2 = /* @__PURE__ */ new Set();
917
917
  for (const raw2 of matches) {
@@ -921,7 +921,7 @@ function tokenize(text, resolve6) {
921
921
  out2.add(token);
922
922
  continue;
923
923
  }
924
- const canonical = resolve6(token);
924
+ const canonical = resolve7(token);
925
925
  out2.add(canonical ?? lemma(token));
926
926
  }
927
927
  return [...out2].sort();
@@ -19674,32 +19674,105 @@ function solutionForProblem(store, problemId) {
19674
19674
  const e = store.outEdges(problemId, ["SOLVED_BY"])[0];
19675
19675
  return e ? e.to : null;
19676
19676
  }
19677
- function anchorProblemToWorkingFile(store, problemId, relPath, workspaceId2, ts, provenance = "edited") {
19677
+ function anchorProblemToWorkingFile(store, problemId, relPath, workspaceId2, ts, provenance = "edited", opts = {}) {
19678
19678
  const p = store.getNode(problemId);
19679
19679
  if (!p || p.label !== "Problem") return false;
19680
19680
  if (!isAnchorableCodePath(relPath)) return false;
19681
19681
  const file2 = resolveFileNode(store, relPath, workspaceId2);
19682
19682
  if (!file2) return false;
19683
19683
  const already = new Set(store.outEdges(problemId, ["ANCHORED_AT"]).map((e) => e.to));
19684
- if (already.has(file2.id)) return true;
19685
- store.mergeEdge({
19686
- id: `edge_${digest({ from: problemId, type: "ANCHORED_AT", to: file2.id })}`.slice(0, 24),
19687
- from: problemId,
19688
- to: file2.id,
19689
- type: "ANCHORED_AT",
19690
- // witnessed = the agent's own declaration, F2-grade; edited = soft heuristic;
19691
- // hint-confirmed = a read-grade hint whose file was later edited while the
19692
- // problem stayed open (AC-hint-upgrade) — same soft tier as edited.
19693
- confidence: provenance === "witnessed" ? 0.4 : 0.3,
19694
- extractionSource: "agent-observed",
19695
- createdAt: ts,
19696
- lastSeenAt: ts,
19697
- navSuccesses: 0,
19698
- navFailures: 0,
19699
- attrs: { provisional: true, captureTime: true, anchorProvenance: provenance }
19700
- });
19684
+ const confidence = provenance === "witnessed" ? 0.4 : 0.3;
19685
+ if (!already.has(file2.id)) {
19686
+ store.mergeEdge({
19687
+ id: `edge_${digest({ from: problemId, type: "ANCHORED_AT", to: file2.id })}`.slice(0, 24),
19688
+ from: problemId,
19689
+ to: file2.id,
19690
+ type: "ANCHORED_AT",
19691
+ confidence,
19692
+ extractionSource: "agent-observed",
19693
+ createdAt: ts,
19694
+ lastSeenAt: ts,
19695
+ navSuccesses: 0,
19696
+ navFailures: 0,
19697
+ attrs: { provisional: true, captureTime: true, anchorProvenance: provenance }
19698
+ });
19699
+ }
19700
+ if (opts.line !== void 0 && opts.fileText !== void 0) {
19701
+ const sym = resolveEnclosingSymbol(store, file2.id, opts.line, opts.fileText);
19702
+ if (sym && !already.has(sym.id)) {
19703
+ store.mergeEdge({
19704
+ id: `edge_${digest({ from: problemId, type: "ANCHORED_AT", to: sym.id })}`.slice(0, 24),
19705
+ from: problemId,
19706
+ to: sym.id,
19707
+ type: "ANCHORED_AT",
19708
+ confidence,
19709
+ extractionSource: "agent-observed",
19710
+ createdAt: ts,
19711
+ lastSeenAt: ts,
19712
+ navSuccesses: 0,
19713
+ navFailures: 0,
19714
+ attrs: {
19715
+ provisional: true,
19716
+ captureTime: true,
19717
+ anchorProvenance: provenance,
19718
+ anchorLine: opts.line,
19719
+ enclosingSymbol: true
19720
+ }
19721
+ });
19722
+ }
19723
+ }
19701
19724
  return true;
19702
19725
  }
19726
+ function resolveEnclosingSymbol(store, fileId, line, fileText) {
19727
+ if (!Number.isFinite(line) || line < 1) return null;
19728
+ const row = Math.floor(line) - 1;
19729
+ const bytes = Buffer.from(fileText, "utf8");
19730
+ const lineStarts = [0];
19731
+ for (let i2 = 0; i2 < bytes.length; i2++) if (bytes[i2] === 10) lineStarts.push(i2 + 1);
19732
+ const rowOf = (byte) => {
19733
+ let lo = 0;
19734
+ let hi = lineStarts.length - 1;
19735
+ while (lo < hi) {
19736
+ const mid = lo + hi + 1 >> 1;
19737
+ if (lineStarts[mid] <= byte) lo = mid;
19738
+ else hi = mid - 1;
19739
+ }
19740
+ return lo;
19741
+ };
19742
+ let best = null;
19743
+ let bestStart = -1;
19744
+ let bestSpan = Number.POSITIVE_INFINITY;
19745
+ const seen = /* @__PURE__ */ new Set([fileId]);
19746
+ let frontier = [fileId];
19747
+ for (let depth = 0; depth < ENCLOSING_WALK_DEPTH && frontier.length > 0; depth++) {
19748
+ const next = [];
19749
+ for (const id of frontier) {
19750
+ for (const e of store.outEdges(id, ["DEFINES"])) {
19751
+ if (seen.has(e.to)) continue;
19752
+ seen.add(e.to);
19753
+ const n = store.getNode(e.to);
19754
+ if (!n) continue;
19755
+ next.push(n.id);
19756
+ if (!ENCLOSING_SYMBOL_KINDS.has(n.label)) continue;
19757
+ const startRow = n.attrs["startRow"];
19758
+ const startByte = n.attrs["startByte"];
19759
+ const endByte = n.attrs["endByte"];
19760
+ if (typeof startRow !== "number" || typeof startByte !== "number" || typeof endByte !== "number") continue;
19761
+ if (startRow < 0 || endByte < startByte) continue;
19762
+ const endRow = rowOf(Math.max(startByte, Math.min(endByte, bytes.length) - 1));
19763
+ if (row < startRow || row > endRow) continue;
19764
+ const span = endByte - startByte;
19765
+ if (startRow > bestStart || startRow === bestStart && span < bestSpan) {
19766
+ best = n;
19767
+ bestStart = startRow;
19768
+ bestSpan = span;
19769
+ }
19770
+ }
19771
+ }
19772
+ frontier = next;
19773
+ }
19774
+ return best;
19775
+ }
19703
19776
  function recordAnchorHint(store, problemId, relPath, provenance, ts) {
19704
19777
  const p = store.getNode(problemId);
19705
19778
  if (!p || p.label !== "Problem") return false;
@@ -19967,7 +20040,7 @@ function priorExposure(store, nodeId, atSeq) {
19967
20040
  if ((n.attrs["evictedCount"] ?? 0) > 0) return "evicted";
19968
20041
  return "unshown";
19969
20042
  }
19970
- var DESIGN_PROMOTE_AT, STATEMENT_ALIAS_CAP, RECURRENCE_DEBOUNCE_MS, PATTERN_DEDUP_COSINE, PATTERN_ALIAS_CAP, DEDUP_STOPWORDS, SAME_ANCHOR_DEDUP_JACCARD, EMPTY_FOLD_REPORT, SAME_ANCHOR_SCOUT_AUTO_COSINE, SAME_ANCHOR_SCOUT_MIN_COSINE, SAME_ANCHOR_NOMINATE_JACCARD, REOPEN_MIN_SOURCES, RECURRENCE_SOURCES_CAP, CITABLE_PRIOR_LABELS, MAX_ANCHOR_FILES, AUTO_MINT_PREFIX, FIX_CANDIDATE_ASK_LIMIT;
20043
+ var DESIGN_PROMOTE_AT, STATEMENT_ALIAS_CAP, RECURRENCE_DEBOUNCE_MS, PATTERN_DEDUP_COSINE, PATTERN_ALIAS_CAP, DEDUP_STOPWORDS, SAME_ANCHOR_DEDUP_JACCARD, EMPTY_FOLD_REPORT, SAME_ANCHOR_SCOUT_AUTO_COSINE, SAME_ANCHOR_SCOUT_MIN_COSINE, SAME_ANCHOR_NOMINATE_JACCARD, REOPEN_MIN_SOURCES, RECURRENCE_SOURCES_CAP, CITABLE_PRIOR_LABELS, MAX_ANCHOR_FILES, ENCLOSING_SYMBOL_KINDS, ENCLOSING_WALK_DEPTH, AUTO_MINT_PREFIX, FIX_CANDIDATE_ASK_LIMIT;
19971
20044
  var init_design_problem = __esm({
19972
20045
  "../../packages/local-graph/src/design-problem.ts"() {
19973
20046
  "use strict";
@@ -20030,6 +20103,19 @@ var init_design_problem = __esm({
20030
20103
  "AntiPattern"
20031
20104
  ]);
20032
20105
  MAX_ANCHOR_FILES = 5;
20106
+ ENCLOSING_SYMBOL_KINDS = /* @__PURE__ */ new Set([
20107
+ "Function",
20108
+ "Class",
20109
+ "Method",
20110
+ "Module",
20111
+ "Interface",
20112
+ "Const",
20113
+ "Enum",
20114
+ "TypeAlias",
20115
+ "Namespace",
20116
+ "Property"
20117
+ ]);
20118
+ ENCLOSING_WALK_DEPTH = 8;
20033
20119
  AUTO_MINT_PREFIX = "addressed by an edit to ";
20034
20120
  FIX_CANDIDATE_ASK_LIMIT = 5;
20035
20121
  }
@@ -23149,6 +23235,7 @@ __export(src_exports2, {
23149
23235
  repairLegacyAnchorsFromStatement: () => repairLegacyAnchorsFromStatement,
23150
23236
  resolveDesignProblemById: () => resolveDesignProblemById,
23151
23237
  resolveDesignProblemByStatement: () => resolveDesignProblemByStatement,
23238
+ resolveEnclosingSymbol: () => resolveEnclosingSymbol,
23152
23239
  resolveFoldCandidates: () => resolveFoldCandidates,
23153
23240
  resolveOsNode: () => resolveOsNode,
23154
23241
  retractDesignProblemById: () => retractDesignProblemById,
@@ -25280,8 +25367,8 @@ var init_config = __esm({
25280
25367
  "use strict";
25281
25368
  init_paths();
25282
25369
  LEGACY_CLOUD_URL = "https://inerrata-gateway.onrender.com";
25283
- DEFAULT_CLOUD_URL = true ? "https://inerrata.dev" : DEV_CLOUD_URL;
25284
- DEFAULT_UPDATE_CHANNEL = true ? "latest" : "dev";
25370
+ DEFAULT_CLOUD_URL = true ? "https://dev.inerrata.dev" : DEV_CLOUD_URL;
25371
+ DEFAULT_UPDATE_CHANNEL = false ? "latest" : "dev";
25285
25372
  }
25286
25373
  });
25287
25374
 
@@ -28165,17 +28252,117 @@ var init_identity2 = __esm({
28165
28252
  }
28166
28253
  });
28167
28254
 
28255
+ // src/git-remote.ts
28256
+ import { existsSync as existsSync8, readFileSync as readFileSync6, statSync } from "node:fs";
28257
+ import { isAbsolute, join as join6, resolve } from "node:path";
28258
+ function resolveGitDir(root) {
28259
+ const dotGit = join6(root, ".git");
28260
+ try {
28261
+ const st = statSync(dotGit);
28262
+ if (st.isDirectory()) return dotGit;
28263
+ const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync6(dotGit, "utf8"));
28264
+ if (!m) return null;
28265
+ const dir = m[1];
28266
+ return isAbsolute(dir) ? dir : resolve(root, dir);
28267
+ } catch {
28268
+ return null;
28269
+ }
28270
+ }
28271
+ function gitConfigPath(gitDir) {
28272
+ const commondirFile = join6(gitDir, "commondir");
28273
+ if (existsSync8(commondirFile)) {
28274
+ const common = readFileSync6(commondirFile, "utf8").trim();
28275
+ const commonDir = isAbsolute(common) ? common : resolve(gitDir, common);
28276
+ return join6(commonDir, "config");
28277
+ }
28278
+ return join6(gitDir, "config");
28279
+ }
28280
+ function readRemotes(root) {
28281
+ const gitDir = resolveGitDir(root);
28282
+ if (!gitDir) return [];
28283
+ const cfgPath = gitConfigPath(gitDir);
28284
+ if (!existsSync8(cfgPath)) return [];
28285
+ let txt;
28286
+ try {
28287
+ txt = readFileSync6(cfgPath, "utf8");
28288
+ } catch {
28289
+ return [];
28290
+ }
28291
+ const out2 = [];
28292
+ const sectionRe = /^\s*\[remote "([^"]+)"\]\s*$([\s\S]*?)(?=^\s*\[|\s*$(?![\s\S]))/gm;
28293
+ for (const m of txt.matchAll(sectionRe)) {
28294
+ const url2 = /^\s*url\s*=\s*(.+?)\s*$/m.exec(m[2])?.[1];
28295
+ if (url2) out2.push({ name: m[1], url: url2 });
28296
+ }
28297
+ return out2;
28298
+ }
28299
+ function detectRepoLocator(root, remote) {
28300
+ const remotes = readRemotes(root);
28301
+ if (remotes.length === 0) return null;
28302
+ const pick2 = remote ? remotes.find((r) => r.name === remote) ?? null : remotes.find((r) => r.name === "origin") ?? (remotes.length === 1 ? remotes[0] : null);
28303
+ return pick2 ? normalizeRepoLocator(pick2.url) : null;
28304
+ }
28305
+ var init_git_remote = __esm({
28306
+ "src/git-remote.ts"() {
28307
+ "use strict";
28308
+ init_src();
28309
+ }
28310
+ });
28311
+
28312
+ // src/checkout-root.ts
28313
+ import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
28314
+ import { basename, dirname as dirname5, isAbsolute as isAbsolute2, join as join7, resolve as resolve2 } from "node:path";
28315
+ function nearestGitRoot(dir) {
28316
+ let cur = resolve2(dir);
28317
+ for (; ; ) {
28318
+ if (existsSync9(join7(cur, ".git"))) return cur;
28319
+ const parent = dirname5(cur);
28320
+ if (parent === cur) return null;
28321
+ cur = parent;
28322
+ }
28323
+ }
28324
+ function mainCheckoutOfWorktree(root) {
28325
+ const gitDir = resolveGitDir(root);
28326
+ if (!gitDir || gitDir === join7(root, ".git")) return null;
28327
+ const commondirFile = join7(gitDir, "commondir");
28328
+ if (!existsSync9(commondirFile)) return null;
28329
+ let common;
28330
+ try {
28331
+ common = readFileSync7(commondirFile, "utf8").trim();
28332
+ } catch {
28333
+ return null;
28334
+ }
28335
+ const commonDir = resolve2(isAbsolute2(common) ? common : resolve2(gitDir, common));
28336
+ if (basename(commonDir) !== ".git") return null;
28337
+ const main2 = dirname5(commonDir);
28338
+ return existsSync9(join7(main2, ".git")) ? main2 : null;
28339
+ }
28340
+ function checkoutRootOf(cwd) {
28341
+ const root = nearestGitRoot(cwd);
28342
+ const main2 = root ? mainCheckoutOfWorktree(root) : null;
28343
+ return main2 ?? resolve2(cwd);
28344
+ }
28345
+ function isLinkedWorktree(root) {
28346
+ return mainCheckoutOfWorktree(root) !== null;
28347
+ }
28348
+ var init_checkout_root = __esm({
28349
+ "src/checkout-root.ts"() {
28350
+ "use strict";
28351
+ init_git_remote();
28352
+ }
28353
+ });
28354
+
28168
28355
  // src/registry.ts
28169
- import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "node:fs";
28170
- import { join as join6 } from "node:path";
28356
+ import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
28357
+ import { join as join8 } from "node:path";
28171
28358
  function registryPath() {
28172
- return process.env["ERRATA_REGISTRY_PATH"] ?? join6(globalDir(), "workspaces.json");
28359
+ return process.env["ERRATA_REGISTRY_PATH"] ?? join8(globalDir(), "workspaces.json");
28173
28360
  }
28174
28361
  function read() {
28175
28362
  const p = registryPath();
28176
- if (!existsSync8(p)) return { version: 1, workspaces: {} };
28363
+ if (!existsSync10(p)) return { version: 1, workspaces: {} };
28177
28364
  try {
28178
- const parsed = JSON.parse(readFileSync6(p, "utf8"));
28365
+ const parsed = JSON.parse(readFileSync8(p, "utf8"));
28179
28366
  return { version: 1, workspaces: parsed.workspaces ?? {} };
28180
28367
  } catch {
28181
28368
  return { version: 1, workspaces: {} };
@@ -28183,9 +28370,9 @@ function read() {
28183
28370
  }
28184
28371
  function registryCorrupt() {
28185
28372
  const p = registryPath();
28186
- if (!existsSync8(p)) return false;
28373
+ if (!existsSync10(p)) return false;
28187
28374
  try {
28188
- JSON.parse(readFileSync6(p, "utf8"));
28375
+ JSON.parse(readFileSync8(p, "utf8"));
28189
28376
  return false;
28190
28377
  } catch {
28191
28378
  return true;
@@ -28196,6 +28383,7 @@ function write(reg) {
28196
28383
  writeFileSync7(registryPath(), JSON.stringify(reg, null, 2), "utf8");
28197
28384
  }
28198
28385
  function registerWorkspace(profile, root, now = Date.now()) {
28386
+ if (isLinkedWorktree(root)) return;
28199
28387
  const reg = read();
28200
28388
  reg.workspaces[profile.id] = {
28201
28389
  ...reg.workspaces[profile.id],
@@ -28234,7 +28422,7 @@ function pruneMissingWorkspaces() {
28234
28422
  const reg = read();
28235
28423
  const removed = [];
28236
28424
  for (const [id, entry] of Object.entries(reg.workspaces)) {
28237
- if (!existsSync8(entry.path)) {
28425
+ if (!existsSync10(entry.path)) {
28238
28426
  removed.push(entry);
28239
28427
  delete reg.workspaces[id];
28240
28428
  }
@@ -28243,13 +28431,13 @@ function pruneMissingWorkspaces() {
28243
28431
  return removed;
28244
28432
  }
28245
28433
  function workspaceStatus(entry) {
28246
- const missing = !existsSync8(entry.path);
28434
+ const missing = !existsSync10(entry.path);
28247
28435
  const lockPath = workspacePaths(entry.path).daemonLock;
28248
28436
  let running = false;
28249
28437
  let webUiUrl = null;
28250
- if (existsSync8(lockPath)) {
28438
+ if (existsSync10(lockPath)) {
28251
28439
  try {
28252
- const lock = JSON.parse(readFileSync6(lockPath, "utf8"));
28440
+ const lock = JSON.parse(readFileSync8(lockPath, "utf8"));
28253
28441
  if (lock.pid && lock.webUiUrl && pidAlive(lock.pid)) {
28254
28442
  running = true;
28255
28443
  webUiUrl = lock.webUiUrl;
@@ -28277,6 +28465,7 @@ var init_registry = __esm({
28277
28465
  "src/registry.ts"() {
28278
28466
  "use strict";
28279
28467
  init_paths();
28468
+ init_checkout_root();
28280
28469
  }
28281
28470
  });
28282
28471
 
@@ -29053,26 +29242,26 @@ function buildFileLexicon(store) {
29053
29242
  for (const n of store.findNodesByLabel("File")) {
29054
29243
  const relPath = typeof n.attrs["relPath"] === "string" && n.attrs["relPath"].length > 0 ? n.attrs["relPath"] : n.description;
29055
29244
  if (!relPath) continue;
29056
- const basename5 = relPath.split("/").pop();
29057
- if (!basename5.includes(".")) continue;
29058
- entries.push({ relPath, basename: basename5 });
29059
- basenameCount.set(basename5, (basenameCount.get(basename5) ?? 0) + 1);
29060
- const stem = basename5.slice(0, basename5.indexOf("."));
29245
+ const basename6 = relPath.split("/").pop();
29246
+ if (!basename6.includes(".")) continue;
29247
+ entries.push({ relPath, basename: basename6 });
29248
+ basenameCount.set(basename6, (basenameCount.get(basename6) ?? 0) + 1);
29249
+ const stem = basename6.slice(0, basename6.indexOf("."));
29061
29250
  if (isBareMatchableStem(stem)) {
29062
29251
  let s = stemRelPaths.get(stem);
29063
29252
  if (!s) stemRelPaths.set(stem, s = /* @__PURE__ */ new Set());
29064
29253
  s.add(relPath);
29065
29254
  }
29066
29255
  }
29067
- for (const { relPath, basename: basename5 } of entries) {
29256
+ for (const { relPath, basename: basename6 } of entries) {
29068
29257
  const entry = { relPath };
29069
- if (relPath !== basename5) byKey.set(relPath, entry);
29070
- const conventional = CONVENTION_FILENAMES.has(basename5) || (basenameCount.get(basename5) ?? 0) >= CONVENTION_BASENAME_MIN_FILES;
29071
- if (!conventional && !byKey.has(basename5)) byKey.set(basename5, entry);
29072
- const list = byBasename.get(basename5);
29258
+ if (relPath !== basename6) byKey.set(relPath, entry);
29259
+ const conventional = CONVENTION_FILENAMES.has(basename6) || (basenameCount.get(basename6) ?? 0) >= CONVENTION_BASENAME_MIN_FILES;
29260
+ if (!conventional && !byKey.has(basename6)) byKey.set(basename6, entry);
29261
+ const list = byBasename.get(basename6);
29073
29262
  if (list) list.push(entry);
29074
- else byBasename.set(basename5, [entry]);
29075
- const stem = basename5.slice(0, basename5.indexOf("."));
29263
+ else byBasename.set(basename6, [entry]);
29264
+ const stem = basename6.slice(0, basename6.indexOf("."));
29076
29265
  if (isBareMatchableStem(stem) && !CONVENTION_STEMS.has(stem) && !byStem.has(stem)) {
29077
29266
  const dirStems = new Set(
29078
29267
  [...stemRelPaths.get(stem) ?? []].map((p) => {
@@ -29089,8 +29278,8 @@ function resolveFileToken(token, lexicon) {
29089
29278
  const exact = lexicon.byKey.get(token);
29090
29279
  if (exact) return exact;
29091
29280
  if (!token.includes("/")) return null;
29092
- const basename5 = token.split("/").pop();
29093
- for (const entry of lexicon.byBasename.get(basename5) ?? []) {
29281
+ const basename6 = token.split("/").pop();
29282
+ for (const entry of lexicon.byBasename.get(basename6) ?? []) {
29094
29283
  if (entry.relPath === token || entry.relPath.endsWith(`/${token}`)) return entry;
29095
29284
  }
29096
29285
  return null;
@@ -29115,9 +29304,9 @@ function fileRolePhrase(relPath, level = 1) {
29115
29304
  return "a source file";
29116
29305
  }
29117
29306
  function isSourceFileToken(token) {
29118
- const basename5 = token.split(/[/\\]/).pop() ?? token;
29119
- if (CONVENTION_FILENAMES.has(basename5)) return false;
29120
- const ext = basename5.split(".").pop();
29307
+ const basename6 = token.split(/[/\\]/).pop() ?? token;
29308
+ if (CONVENTION_FILENAMES.has(basename6)) return false;
29309
+ const ext = basename6.split(".").pop();
29121
29310
  return ext !== void 0 && SOURCE_EXTENSIONS.has(ext.toLowerCase());
29122
29311
  }
29123
29312
  function generalizeFileRefs(text, fileLexicon, level = 1) {
@@ -29702,7 +29891,7 @@ var init_diagnostic_matcher = __esm({
29702
29891
  });
29703
29892
 
29704
29893
  // ../../packages/generalizer/src/generalizer.ts
29705
- import { isAbsolute, join as join7, relative } from "node:path";
29894
+ import { isAbsolute as isAbsolute3, join as join9, relative } from "node:path";
29706
29895
  async function runGeneralizer(opts) {
29707
29896
  const report = {
29708
29897
  eventsProcessed: 0,
@@ -29810,7 +29999,7 @@ function extractDiagnostics(ev) {
29810
29999
  function diagRelPath(file2, cwd, workspaceRoot) {
29811
30000
  const norm = (p) => p.replace(/\\/g, "/");
29812
30001
  if (!workspaceRoot) return norm(file2);
29813
- const abs = isAbsolute(file2) ? file2 : join7(cwd ?? workspaceRoot, file2);
30002
+ const abs = isAbsolute3(file2) ? file2 : join9(cwd ?? workspaceRoot, file2);
29814
30003
  return norm(relative(workspaceRoot, abs));
29815
30004
  }
29816
30005
  function extractErrorSignature(ev) {
@@ -31453,22 +31642,22 @@ var init_src10 = __esm({
31453
31642
 
31454
31643
  // ../../packages/indexer/src/parse-cache.ts
31455
31644
  import { createHash as createHash3 } from "node:crypto";
31456
- import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync7, readdirSync as readdirSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync8 } from "node:fs";
31645
+ import { existsSync as existsSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync9, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync8 } from "node:fs";
31457
31646
  import { homedir as homedir3 } from "node:os";
31458
- import { join as join8 } from "node:path";
31647
+ import { join as join10 } from "node:path";
31459
31648
  function parseCacheDir() {
31460
- return process.env["ERRATA_PARSE_CACHE"] ?? join8(homedir3(), ".errata", "parse-cache");
31649
+ return process.env["ERRATA_PARSE_CACHE"] ?? join10(homedir3(), ".errata", "parse-cache");
31461
31650
  }
31462
31651
  function parseCacheKey(source, providerId) {
31463
31652
  return createHash3("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
31464
31653
  }
31465
31654
  function entryPath(dir, key) {
31466
- return join8(dir, key.slice(0, 2), `${key.slice(2)}.json`);
31655
+ return join10(dir, key.slice(0, 2), `${key.slice(2)}.json`);
31467
31656
  }
31468
31657
  function readParseCache(dir, key) {
31469
31658
  const file2 = entryPath(dir, key);
31470
31659
  try {
31471
- const raw2 = readFileSync7(file2, "utf8");
31660
+ const raw2 = readFileSync9(file2, "utf8");
31472
31661
  const parsed = JSON.parse(raw2);
31473
31662
  if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
31474
31663
  return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
@@ -31487,7 +31676,7 @@ function writeParseCache(dir, key, providerId, value) {
31487
31676
  const body2 = JSON.stringify(envelope);
31488
31677
  if (body2.length > MAX_ENTRY_BYTES) return;
31489
31678
  const file2 = entryPath(dir, key);
31490
- mkdirSync6(join8(dir, key.slice(0, 2)), { recursive: true });
31679
+ mkdirSync6(join10(dir, key.slice(0, 2)), { recursive: true });
31491
31680
  writeFileSync8(file2, body2);
31492
31681
  } catch {
31493
31682
  }
@@ -31497,9 +31686,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
31497
31686
  sweptThisProcess = true;
31498
31687
  let removed = 0;
31499
31688
  try {
31500
- if (!existsSync9(dir)) return 0;
31689
+ if (!existsSync11(dir)) return 0;
31501
31690
  for (const bucket of readdirSync2(dir)) {
31502
- const bucketDir = join8(dir, bucket);
31691
+ const bucketDir = join10(dir, bucket);
31503
31692
  let names;
31504
31693
  try {
31505
31694
  names = readdirSync2(bucketDir);
@@ -31507,9 +31696,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
31507
31696
  continue;
31508
31697
  }
31509
31698
  for (const name2 of names) {
31510
- const file2 = join8(bucketDir, name2);
31699
+ const file2 = join10(bucketDir, name2);
31511
31700
  try {
31512
- if (now - statSync(file2).mtimeMs > ENTRY_TTL_MS) {
31701
+ if (now - statSync2(file2).mtimeMs > ENTRY_TTL_MS) {
31513
31702
  rmSync2(file2, { force: true });
31514
31703
  removed++;
31515
31704
  }
@@ -31755,9 +31944,9 @@ var init_identity3 = __esm({
31755
31944
  });
31756
31945
 
31757
31946
  // ../../packages/indexer/src/pipeline.ts
31758
- import { appendFileSync, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
31947
+ import { appendFileSync, readFileSync as readFileSync10, statSync as statSync3 } from "node:fs";
31759
31948
  import { readdir } from "node:fs/promises";
31760
- import { extname, join as join9, relative as relative2, sep } from "node:path";
31949
+ import { extname, join as join11, relative as relative2, sep } from "node:path";
31761
31950
  import { createHash as createHash4 } from "node:crypto";
31762
31951
  import { execFileSync } from "node:child_process";
31763
31952
  function nowTs() {
@@ -31895,7 +32084,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31895
32084
  for (const rel of [...changedRelPaths]) {
31896
32085
  let h;
31897
32086
  try {
31898
- h = createHash4("sha256").update(readFileSync8(join9(rootPath, rel))).digest("hex");
32087
+ h = createHash4("sha256").update(readFileSync10(join11(rootPath, rel))).digest("hex");
31899
32088
  } catch {
31900
32089
  continue;
31901
32090
  }
@@ -31944,13 +32133,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31944
32133
  let parsedFiles = 0;
31945
32134
  for (const rel of changedRelPaths) {
31946
32135
  if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
31947
- const abs = join9(rootPath, ...rel.split("/"));
32136
+ const abs = join11(rootPath, ...rel.split("/"));
31948
32137
  const ext = extname(abs).toLowerCase();
31949
32138
  const provider = providers.find((p) => p.fileExtensions.includes(ext));
31950
32139
  if (!provider) continue;
31951
32140
  let symbols;
31952
32141
  try {
31953
- symbols = provider.extractSymbols(readFileSync8(abs, "utf8"), abs);
32142
+ symbols = provider.extractSymbols(readFileSync10(abs, "utf8"), abs);
31954
32143
  } catch {
31955
32144
  continue;
31956
32145
  }
@@ -32265,12 +32454,12 @@ async function runIndexer(store, opts) {
32265
32454
  }
32266
32455
  let source;
32267
32456
  try {
32268
- const st = statSync2(f.absPath);
32457
+ const st = statSync3(f.absPath);
32269
32458
  if (st.size > maxBytes) {
32270
32459
  report.filesSkipped++;
32271
32460
  continue;
32272
32461
  }
32273
- source = readFileSync8(f.absPath, "utf8");
32462
+ source = readFileSync10(f.absPath, "utf8");
32274
32463
  } catch {
32275
32464
  report.filesSkipped++;
32276
32465
  continue;
@@ -32342,7 +32531,7 @@ async function runIndexer(store, opts) {
32342
32531
  const depth = fileNode.relPath.split("/").length;
32343
32532
  if (depth !== 3) continue;
32344
32533
  try {
32345
- const pkg = JSON.parse(readFileSync8(fileNode.absPath, "utf8"));
32534
+ const pkg = JSON.parse(readFileSync10(fileNode.absPath, "utf8"));
32346
32535
  if (!pkg.name) continue;
32347
32536
  const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
32348
32537
  const candidates = [
@@ -32730,7 +32919,7 @@ async function scan(root, current, ignores, providers, out2) {
32730
32919
  for (const ent of entries) {
32731
32920
  if (ignores.has(ent.name)) continue;
32732
32921
  if (ent.name.startsWith(".") && ent.name !== ".") continue;
32733
- const abs = join9(current, ent.name);
32922
+ const abs = join11(current, ent.name);
32734
32923
  if (ent.isDirectory()) {
32735
32924
  await scan(root, abs, ignores, providers, out2);
32736
32925
  } else if (ent.isFile()) {
@@ -32739,7 +32928,7 @@ async function scan(root, current, ignores, providers, out2) {
32739
32928
  const rel = relative2(root, abs).split(sep).join("/");
32740
32929
  let size = 0;
32741
32930
  try {
32742
- size = statSync2(abs).size;
32931
+ size = statSync3(abs).size;
32743
32932
  } catch {
32744
32933
  continue;
32745
32934
  }
@@ -32785,10 +32974,10 @@ function gitListFiles(root, ignores, providers) {
32785
32974
  if (rels === null) return null;
32786
32975
  const out2 = [];
32787
32976
  for (const rel of rels) {
32788
- const abs = join9(root, rel);
32977
+ const abs = join11(root, rel);
32789
32978
  let size;
32790
32979
  try {
32791
- size = statSync2(abs).size;
32980
+ size = statSync3(abs).size;
32792
32981
  } catch {
32793
32982
  continue;
32794
32983
  }
@@ -32808,7 +32997,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
32808
32997
  const now = nowTs();
32809
32998
  let contentHash;
32810
32999
  try {
32811
- contentHash = createHash4("sha256").update(readFileSync8(f.absPath)).digest("hex");
33000
+ contentHash = createHash4("sha256").update(readFileSync10(f.absPath)).digest("hex");
32812
33001
  } catch {
32813
33002
  }
32814
33003
  const node2 = {
@@ -33412,13 +33601,13 @@ async function Module2(moduleArg = {}) {
33412
33601
  }
33413
33602
  readAsync = /* @__PURE__ */ __name(async (url2) => {
33414
33603
  if (isFileURI(url2)) {
33415
- return new Promise((resolve6, reject) => {
33604
+ return new Promise((resolve7, reject) => {
33416
33605
  var xhr = new XMLHttpRequest();
33417
33606
  xhr.open("GET", url2, true);
33418
33607
  xhr.responseType = "arraybuffer";
33419
33608
  xhr.onload = () => {
33420
33609
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
33421
- resolve6(xhr.response);
33610
+ resolve7(xhr.response);
33422
33611
  return;
33423
33612
  }
33424
33613
  reject(xhr.status);
@@ -33614,9 +33803,9 @@ async function Module2(moduleArg = {}) {
33614
33803
  __name(receiveInstantiationResult, "receiveInstantiationResult");
33615
33804
  var info2 = getWasmImports();
33616
33805
  if (Module["instantiateWasm"]) {
33617
- return new Promise((resolve6, reject) => {
33806
+ return new Promise((resolve7, reject) => {
33618
33807
  Module["instantiateWasm"](info2, (mod, inst) => {
33619
- resolve6(receiveInstance(mod, inst));
33808
+ resolve7(receiveInstance(mod, inst));
33620
33809
  });
33621
33810
  });
33622
33811
  }
@@ -34947,8 +35136,8 @@ async function Module2(moduleArg = {}) {
34947
35136
  if (runtimeInitialized) {
34948
35137
  moduleRtn = Module;
34949
35138
  } else {
34950
- moduleRtn = new Promise((resolve6, reject) => {
34951
- readyPromiseResolve = resolve6;
35139
+ moduleRtn = new Promise((resolve7, reject) => {
35140
+ readyPromiseResolve = resolve7;
34952
35141
  readyPromiseReject = reject;
34953
35142
  });
34954
35143
  }
@@ -37178,42 +37367,42 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37178
37367
 
37179
37368
  // ../../packages/indexer/src/languages/tree-sitter-loader.ts
37180
37369
  import { fileURLToPath } from "node:url";
37181
- import { dirname as dirname5, join as join10 } from "node:path";
37182
- import { existsSync as existsSync10, readdirSync as readdirSync3 } from "node:fs";
37370
+ import { dirname as dirname6, join as join12 } from "node:path";
37371
+ import { existsSync as existsSync12, readdirSync as readdirSync3 } from "node:fs";
37183
37372
  import { createRequire as createRequire2 } from "node:module";
37184
37373
  function entryDir() {
37185
37374
  try {
37186
37375
  const url2 = import.meta?.url;
37187
37376
  if (typeof url2 === "string" && url2.length > 0) {
37188
- return dirname5(fileURLToPath(url2));
37377
+ return dirname6(fileURLToPath(url2));
37189
37378
  }
37190
37379
  } catch {
37191
37380
  }
37192
- return dirname5(process.execPath);
37381
+ return dirname6(process.execPath);
37193
37382
  }
37194
37383
  function findWasmDir() {
37195
37384
  const here = entryDir();
37196
- const seaWasm = join10(here, "resources", "wasm");
37197
- if (existsSync10(join10(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
37385
+ const seaWasm = join12(here, "resources", "wasm");
37386
+ if (existsSync12(join12(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
37198
37387
  let dir = here;
37199
37388
  for (let i2 = 0; i2 < 6; i2++) {
37200
- const flat = join10(
37389
+ const flat = join12(
37201
37390
  dir,
37202
37391
  "node_modules",
37203
37392
  "@vscode",
37204
37393
  "tree-sitter-wasm",
37205
37394
  "wasm"
37206
37395
  );
37207
- if (existsSync10(join10(flat, "tree-sitter-typescript.wasm"))) return flat;
37208
- dir = dirname5(dir);
37396
+ if (existsSync12(join12(flat, "tree-sitter-typescript.wasm"))) return flat;
37397
+ dir = dirname6(dir);
37209
37398
  }
37210
37399
  let root = here;
37211
37400
  for (let i2 = 0; i2 < 6; i2++) {
37212
- const pnpmDir = join10(root, "node_modules", ".pnpm");
37213
- if (existsSync10(pnpmDir)) {
37401
+ const pnpmDir = join12(root, "node_modules", ".pnpm");
37402
+ if (existsSync12(pnpmDir)) {
37214
37403
  for (const entry of readdirSync3(pnpmDir)) {
37215
37404
  if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
37216
- const candidate = join10(
37405
+ const candidate = join12(
37217
37406
  pnpmDir,
37218
37407
  entry,
37219
37408
  "node_modules",
@@ -37221,13 +37410,13 @@ function findWasmDir() {
37221
37410
  "tree-sitter-wasm",
37222
37411
  "wasm"
37223
37412
  );
37224
- if (existsSync10(join10(candidate, "tree-sitter-typescript.wasm"))) {
37413
+ if (existsSync12(join12(candidate, "tree-sitter-typescript.wasm"))) {
37225
37414
  return candidate;
37226
37415
  }
37227
37416
  }
37228
37417
  }
37229
37418
  }
37230
- root = dirname5(root);
37419
+ root = dirname6(root);
37231
37420
  }
37232
37421
  throw new Error(
37233
37422
  "@vscode/tree-sitter-wasm grammar files not found \u2014 is the package installed?"
@@ -37235,33 +37424,33 @@ function findWasmDir() {
37235
37424
  }
37236
37425
  function findRuntimeDir() {
37237
37426
  const here = entryDir();
37238
- const seaRuntime = join10(here, "resources", "wasm");
37239
- if (existsSync10(join10(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
37427
+ const seaRuntime = join12(here, "resources", "wasm");
37428
+ if (existsSync12(join12(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
37240
37429
  let dir = here;
37241
37430
  for (let i2 = 0; i2 < 6; i2++) {
37242
- const flat = join10(dir, "node_modules", "web-tree-sitter");
37243
- if (existsSync10(join10(flat, "web-tree-sitter.wasm"))) return flat;
37244
- dir = dirname5(dir);
37431
+ const flat = join12(dir, "node_modules", "web-tree-sitter");
37432
+ if (existsSync12(join12(flat, "web-tree-sitter.wasm"))) return flat;
37433
+ dir = dirname6(dir);
37245
37434
  }
37246
37435
  let root = here;
37247
37436
  for (let i2 = 0; i2 < 6; i2++) {
37248
- const pnpmDir = join10(root, "node_modules", ".pnpm");
37249
- if (existsSync10(pnpmDir)) {
37437
+ const pnpmDir = join12(root, "node_modules", ".pnpm");
37438
+ if (existsSync12(pnpmDir)) {
37250
37439
  for (const entry of readdirSync3(pnpmDir)) {
37251
37440
  if (entry.startsWith("web-tree-sitter@")) {
37252
- const candidate = join10(
37441
+ const candidate = join12(
37253
37442
  pnpmDir,
37254
37443
  entry,
37255
37444
  "node_modules",
37256
37445
  "web-tree-sitter"
37257
37446
  );
37258
- if (existsSync10(join10(candidate, "web-tree-sitter.wasm"))) {
37447
+ if (existsSync12(join12(candidate, "web-tree-sitter.wasm"))) {
37259
37448
  return candidate;
37260
37449
  }
37261
37450
  }
37262
37451
  }
37263
37452
  }
37264
- root = dirname5(root);
37453
+ root = dirname6(root);
37265
37454
  }
37266
37455
  throw new Error("web-tree-sitter runtime WASM not found");
37267
37456
  }
@@ -37272,7 +37461,7 @@ async function loadWebTreeSitter() {
37272
37461
  void err2;
37273
37462
  }
37274
37463
  const here = entryDir();
37275
- const seaResourceBase = join10(here, "resources", "_resolve.js");
37464
+ const seaResourceBase = join12(here, "resources", "_resolve.js");
37276
37465
  const resourceRequire = createRequire2(seaResourceBase);
37277
37466
  return resourceRequire("web-tree-sitter");
37278
37467
  }
@@ -37287,9 +37476,9 @@ async function ensureTreeSitterReady() {
37287
37476
  await Parser2.init({
37288
37477
  locateFile: (name2) => {
37289
37478
  if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
37290
- return join10(runtime, name2);
37479
+ return join12(runtime, name2);
37291
37480
  }
37292
- return join10(grammars, name2);
37481
+ return join12(grammars, name2);
37293
37482
  }
37294
37483
  });
37295
37484
  })();
@@ -37301,7 +37490,7 @@ async function loadGrammar(name2) {
37301
37490
  if (cached2) return cached2;
37302
37491
  if (!languageClass) throw new Error("tree-sitter not initialized");
37303
37492
  const grammars = findWasmDir();
37304
- const lang = await languageClass.load(join10(grammars, `${name2}.wasm`));
37493
+ const lang = await languageClass.load(join12(grammars, `${name2}.wasm`));
37305
37494
  grammarCache.set(name2, lang);
37306
37495
  return lang;
37307
37496
  }
@@ -40204,8 +40393,8 @@ var init_src11 = __esm({
40204
40393
 
40205
40394
  // src/reconcile.ts
40206
40395
  import { execFileSync as execFileSync2 } from "node:child_process";
40207
- import { readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
40208
- import { join as join11, relative as relative3, sep as sep2 } from "node:path";
40396
+ import { readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
40397
+ import { join as join13, relative as relative3, sep as sep2 } from "node:path";
40209
40398
  function indexerWouldScan(rel) {
40210
40399
  for (const seg of rel.split(/[\\/]/)) {
40211
40400
  if (seg.length === 0) continue;
@@ -40228,7 +40417,7 @@ function gitSourceFiles(root) {
40228
40417
  const out2 = [];
40229
40418
  for (const rel of stdout.split("\0")) {
40230
40419
  if (!rel || !SOURCE_RE.test(rel) || !indexerWouldScan(rel)) continue;
40231
- const abs = join11(root, rel);
40420
+ const abs = join13(root, rel);
40232
40421
  if (IGNORED.test(abs)) continue;
40233
40422
  out2.push(abs);
40234
40423
  }
@@ -40243,7 +40432,7 @@ function* walkSource(dir) {
40243
40432
  }
40244
40433
  for (const e of entries) {
40245
40434
  const name2 = String(e.name);
40246
- const full = join11(dir, name2);
40435
+ const full = join13(dir, name2);
40247
40436
  if (IGNORED.test(full)) continue;
40248
40437
  if (!indexerWouldScan(name2)) continue;
40249
40438
  if (e.isDirectory()) yield* walkSource(full);
@@ -40262,7 +40451,7 @@ async function findStaleFiles(store, rootPath, workspaceId2) {
40262
40451
  if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
40263
40452
  let mtimeMs;
40264
40453
  try {
40265
- mtimeMs = statSync3(abs).mtimeMs;
40454
+ mtimeMs = statSync4(abs).mtimeMs;
40266
40455
  } catch {
40267
40456
  continue;
40268
40457
  }
@@ -40393,8 +40582,8 @@ __export(mcp_exports, {
40393
40582
  runTool: () => runTool,
40394
40583
  searchGraph: () => searchGraph
40395
40584
  });
40396
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
40397
- import { resolve } from "node:path";
40585
+ import { existsSync as existsSync13, readFileSync as readFileSync11 } from "node:fs";
40586
+ import { resolve as resolve3 } from "node:path";
40398
40587
  function collectEnrichmentPulls(store, opts = {}) {
40399
40588
  const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
40400
40589
  const byEpisode = /* @__PURE__ */ new Map();
@@ -40430,7 +40619,7 @@ function takeEnrichmentNudge(store) {
40430
40619
  ` + items;
40431
40620
  }
40432
40621
  function takeDiscriminatorNudge(path2) {
40433
- if (!path2 || !existsSync11(path2)) return null;
40622
+ if (!path2 || !existsSync13(path2)) return null;
40434
40623
  let shared;
40435
40624
  try {
40436
40625
  shared = openGraphStore({ path: path2 });
@@ -40560,11 +40749,11 @@ function showNode(store, node2, maxLines) {
40560
40749
  const relPath = ownerFilePath(store, node2);
40561
40750
  if (!relPath) return { found: false, reason: "no file owner for node" };
40562
40751
  const workspaceRoot = process.cwd();
40563
- const absPath = resolve(workspaceRoot, relPath);
40564
- if (!existsSync11(absPath)) {
40752
+ const absPath = resolve3(workspaceRoot, relPath);
40753
+ if (!existsSync13(absPath)) {
40565
40754
  return { found: false, reason: `file not found on disk: ${absPath}` };
40566
40755
  }
40567
- const source = readFileSync9(absPath, "utf8");
40756
+ const source = readFileSync11(absPath, "utf8");
40568
40757
  const attrs = node2.attrs;
40569
40758
  let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
40570
40759
  let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
@@ -40790,7 +40979,7 @@ function buildToolContext(workspaceRoot) {
40790
40979
  const base = { switchInstallationProfile: useInstallationProfile };
40791
40980
  try {
40792
40981
  const cfg = loadConfig();
40793
- const entry = workspaceRoot ? workspaceEntryForPath(resolve(workspaceRoot)) : null;
40982
+ const entry = workspaceRoot ? workspaceEntryForPath(resolve3(workspaceRoot)) : null;
40794
40983
  const identity = resolveWorkspaceIdentity(cfg, entry);
40795
40984
  if (identity.invalid) {
40796
40985
  console.error(`[errata mcp] cloud DISABLED for this workspace: ${identity.reason}`);
@@ -41318,7 +41507,7 @@ var init_mcp = __esm({
41318
41507
  const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
41319
41508
  try {
41320
41509
  const path2 = sharedStorePath();
41321
- if (!existsSync11(path2)) return { found: true, ...local };
41510
+ if (!existsSync13(path2)) return { found: true, ...local };
41322
41511
  const shared = openGraphStore({ path: path2 });
41323
41512
  try {
41324
41513
  if (!shared.getNode(id)) return { found: true, ...local };
@@ -41918,7 +42107,7 @@ var init_mcp = __esm({
41918
42107
  inputSchema: { type: "object", properties: {} },
41919
42108
  handler: () => {
41920
42109
  const path2 = sharedStorePath();
41921
- if (!existsSync11(path2)) return { count: 0, pending: [] };
42110
+ if (!existsSync13(path2)) return { count: 0, pending: [] };
41922
42111
  const shared = openGraphStore({ path: path2 });
41923
42112
  try {
41924
42113
  const pending = pendingAbstractions(shared);
@@ -41946,7 +42135,7 @@ var init_mcp = __esm({
41946
42135
  },
41947
42136
  handler: (args2) => {
41948
42137
  const path2 = sharedStorePath();
41949
- if (!existsSync11(path2)) return { count: 0, pending: [] };
42138
+ if (!existsSync13(path2)) return { count: 0, pending: [] };
41950
42139
  const shared = openGraphStore({ path: path2 });
41951
42140
  try {
41952
42141
  const pending = pendingDiscriminators(shared, {
@@ -41990,7 +42179,7 @@ var init_mcp = __esm({
41990
42179
  },
41991
42180
  handler: (args2) => {
41992
42181
  const path2 = sharedStorePath();
41993
- if (!existsSync11(path2)) return { count: 0, routes: [] };
42182
+ if (!existsSync13(path2)) return { count: 0, routes: [] };
41994
42183
  const shared = openGraphStore({ path: path2 });
41995
42184
  try {
41996
42185
  const result = triageOf(shared, {
@@ -42376,7 +42565,7 @@ __export(vfile_exports, {
42376
42565
  segmentsOf: () => segmentsOf
42377
42566
  });
42378
42567
  import { writeFileSync as writeFileSync9 } from "node:fs";
42379
- import { join as join12, resolve as resolve2, sep as sep3 } from "node:path";
42568
+ import { join as join14, resolve as resolve4, sep as sep3 } from "node:path";
42380
42569
  function segmentsOf(rawPath) {
42381
42570
  let p = rawPath.replace(/\\/g, "/");
42382
42571
  p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
@@ -42450,8 +42639,8 @@ async function renderVFile(rawPath, store, ctx = {}) {
42450
42639
  }
42451
42640
  async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
42452
42641
  const segs = segmentsOf(rawPath);
42453
- const gRoot = join12(workspaceRoot, ".errata", "g");
42454
- const abs = resolve2(gRoot, ...segs.length ? segs : ["index"]);
42642
+ const gRoot = join14(workspaceRoot, ".errata", "g");
42643
+ const abs = resolve4(gRoot, ...segs.length ? segs : ["index"]);
42455
42644
  if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
42456
42645
  throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
42457
42646
  }
@@ -49877,25 +50066,25 @@ var init_tool_index = __esm({
49877
50066
 
49878
50067
  // src/outbox.ts
49879
50068
  import {
49880
- existsSync as existsSync12,
50069
+ existsSync as existsSync14,
49881
50070
  readdirSync as readdirSync5,
49882
- readFileSync as readFileSync10,
50071
+ readFileSync as readFileSync12,
49883
50072
  renameSync,
49884
50073
  unlinkSync,
49885
50074
  writeFileSync as writeFileSync10
49886
50075
  } from "node:fs";
49887
- import { join as join13 } from "node:path";
50076
+ import { join as join15 } from "node:path";
49888
50077
  import { createHash as createHash12 } from "node:crypto";
49889
50078
  function enqueueOutbox(paths, payload) {
49890
50079
  ensureDir(paths.outbox);
49891
50080
  const id = createHash12("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
49892
- const file2 = join13(paths.outbox, `${Date.now()}-${id}.json`);
50081
+ const file2 = join15(paths.outbox, `${Date.now()}-${id}.json`);
49893
50082
  writeFileSync10(file2, JSON.stringify(payload, null, 2), "utf8");
49894
50083
  return file2;
49895
50084
  }
49896
50085
  async function flushOutbox(paths, client, store) {
49897
50086
  ensureDir(paths.outbox);
49898
- const entries = existsSync12(paths.outbox) ? readdirSync5(paths.outbox) : [];
50087
+ const entries = existsSync14(paths.outbox) ? readdirSync5(paths.outbox) : [];
49899
50088
  let uploaded = 0;
49900
50089
  let failed = 0;
49901
50090
  const quarantine = (abs, reason) => {
@@ -49906,10 +50095,10 @@ async function flushOutbox(paths, client, store) {
49906
50095
  }
49907
50096
  };
49908
50097
  for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
49909
- const abs = join13(paths.outbox, f);
50098
+ const abs = join15(paths.outbox, f);
49910
50099
  let payload;
49911
50100
  try {
49912
- payload = JSON.parse(readFileSync10(abs, "utf8"));
50101
+ payload = JSON.parse(readFileSync12(abs, "utf8"));
49913
50102
  } catch {
49914
50103
  failed++;
49915
50104
  quarantine(abs, "unparseable JSON");
@@ -49954,7 +50143,7 @@ async function flushOutbox(paths, client, store) {
49954
50143
  }
49955
50144
  }
49956
50145
  }
49957
- const remainingFiles = existsSync12(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
50146
+ const remainingFiles = existsSync14(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
49958
50147
  return { uploaded, failed, remaining: remainingFiles.length };
49959
50148
  }
49960
50149
  var init_outbox = __esm({
@@ -50663,16 +50852,16 @@ __export(witness_ledger_exports, {
50663
50852
  summarizeWitnessLedger: () => summarizeWitnessLedger,
50664
50853
  witnessLedgerPath: () => witnessLedgerPath
50665
50854
  });
50666
- import { appendFileSync as appendFileSync3, existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync19 } from "node:fs";
50667
- import { join as join27 } from "node:path";
50855
+ import { appendFileSync as appendFileSync3, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync19 } from "node:fs";
50856
+ import { join as join28 } from "node:path";
50668
50857
  function witnessLedgerPath(configDir) {
50669
- return join27(configDir, "witness-ledger.jsonl");
50858
+ return join28(configDir, "witness-ledger.jsonl");
50670
50859
  }
50671
50860
  function appendWitnessLedger(configDir, entry) {
50672
50861
  const path2 = witnessLedgerPath(configDir);
50673
50862
  try {
50674
50863
  appendFileSync3(path2, JSON.stringify(entry) + "\n");
50675
- const lines = readFileSync22(path2, "utf8").split("\n").filter(Boolean);
50864
+ const lines = readFileSync23(path2, "utf8").split("\n").filter(Boolean);
50676
50865
  if (lines.length > LEDGER_MAX_LINES) {
50677
50866
  writeFileSync19(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
50678
50867
  }
@@ -50681,9 +50870,9 @@ function appendWitnessLedger(configDir, entry) {
50681
50870
  }
50682
50871
  function readWitnessLedger(configDir) {
50683
50872
  const path2 = witnessLedgerPath(configDir);
50684
- if (!existsSync22(path2)) return [];
50873
+ if (!existsSync23(path2)) return [];
50685
50874
  try {
50686
- return readFileSync22(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
50875
+ return readFileSync23(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
50687
50876
  } catch {
50688
50877
  return [];
50689
50878
  }
@@ -51122,12 +51311,12 @@ var init_report_render = __esm({
51122
51311
 
51123
51312
  // src/cli.ts
51124
51313
  init_src6();
51125
- import { closeSync as closeSync2, existsSync as existsSync30, openSync as openSync2, readFileSync as readFileSync28, renameSync as renameSync4, statSync as statSync7 } from "node:fs";
51126
- import { join as join32, resolve as pathResolve } from "node:path";
51314
+ import { closeSync as closeSync2, existsSync as existsSync31, openSync as openSync2, readFileSync as readFileSync29, renameSync as renameSync4, statSync as statSync7 } from "node:fs";
51315
+ import { join as join33, resolve as pathResolve } from "node:path";
51127
51316
  import { spawn as spawn3 } from "node:child_process";
51128
51317
 
51129
51318
  // src/daemon.ts
51130
- import { existsSync as existsSync24, writeFileSync as writeFileSync21 } from "node:fs";
51319
+ import { existsSync as existsSync25, writeFileSync as writeFileSync21 } from "node:fs";
51131
51320
 
51132
51321
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
51133
51322
  import { createServer as createServerHTTP } from "http";
@@ -51557,7 +51746,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
51557
51746
  });
51558
51747
  if (!chunk) {
51559
51748
  if (i2 === 1) {
51560
- await new Promise((resolve6) => setTimeout(resolve6));
51749
+ await new Promise((resolve7) => setTimeout(resolve7));
51561
51750
  maxReadCount = 3;
51562
51751
  continue;
51563
51752
  }
@@ -51707,8 +51896,8 @@ init_config();
51707
51896
 
51708
51897
  // src/engine.ts
51709
51898
  import { execFileSync as execFileSync3 } from "node:child_process";
51710
- import { existsSync as existsSync23, statSync as statSync6, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync23, writeFileSync as writeFileSync20 } from "node:fs";
51711
- import { join as join28, relative as relative6, sep as sep4 } from "node:path";
51899
+ import { existsSync as existsSync24, statSync as statSync6, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync24, writeFileSync as writeFileSync20 } from "node:fs";
51900
+ import { join as join29, relative as relative6, sep as sep4 } from "node:path";
51712
51901
 
51713
51902
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
51714
51903
  import { stat as statcb } from "fs";
@@ -51863,10 +52052,10 @@ var ReaddirpStream = class extends Readable2 {
51863
52052
  }
51864
52053
  async _formatEntry(dirent, path2) {
51865
52054
  let entry;
51866
- const basename5 = this._isDirent ? dirent.name : dirent;
52055
+ const basename6 = this._isDirent ? dirent.name : dirent;
51867
52056
  try {
51868
- const fullPath = presolve(pjoin(path2, basename5));
51869
- entry = { path: prelative(this._root, fullPath), fullPath, basename: basename5 };
52057
+ const fullPath = presolve(pjoin(path2, basename6));
52058
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename6 };
51870
52059
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
51871
52060
  } catch (err2) {
51872
52061
  this._onError(err2);
@@ -52405,9 +52594,9 @@ var NodeFsHandler = class {
52405
52594
  _watchWithNodeFs(path2, listener) {
52406
52595
  const opts = this.fsw.options;
52407
52596
  const directory = sysPath.dirname(path2);
52408
- const basename5 = sysPath.basename(path2);
52597
+ const basename6 = sysPath.basename(path2);
52409
52598
  const parent = this.fsw._getWatchedDir(directory);
52410
- parent.add(basename5);
52599
+ parent.add(basename6);
52411
52600
  const absolutePath = sysPath.resolve(path2);
52412
52601
  const options = {
52413
52602
  persistent: opts.persistent
@@ -52417,7 +52606,7 @@ var NodeFsHandler = class {
52417
52606
  let closer;
52418
52607
  if (opts.usePolling) {
52419
52608
  const enableBin = opts.interval !== opts.binaryInterval;
52420
- options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
52609
+ options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
52421
52610
  closer = setFsWatchFileListener(path2, absolutePath, options, {
52422
52611
  listener,
52423
52612
  rawEmitter: this.fsw._emitRaw
@@ -52439,11 +52628,11 @@ var NodeFsHandler = class {
52439
52628
  if (this.fsw.closed) {
52440
52629
  return;
52441
52630
  }
52442
- const dirname11 = sysPath.dirname(file2);
52443
- const basename5 = sysPath.basename(file2);
52444
- const parent = this.fsw._getWatchedDir(dirname11);
52631
+ const dirname12 = sysPath.dirname(file2);
52632
+ const basename6 = sysPath.basename(file2);
52633
+ const parent = this.fsw._getWatchedDir(dirname12);
52445
52634
  let prevStats = stats;
52446
- if (parent.has(basename5))
52635
+ if (parent.has(basename6))
52447
52636
  return;
52448
52637
  const listener = async (path2, newStats) => {
52449
52638
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
@@ -52468,9 +52657,9 @@ var NodeFsHandler = class {
52468
52657
  prevStats = newStats2;
52469
52658
  }
52470
52659
  } catch (error48) {
52471
- this.fsw._remove(dirname11, basename5);
52660
+ this.fsw._remove(dirname12, basename6);
52472
52661
  }
52473
- } else if (parent.has(basename5)) {
52662
+ } else if (parent.has(basename6)) {
52474
52663
  const at = newStats.atimeMs;
52475
52664
  const mt = newStats.mtimeMs;
52476
52665
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -52564,7 +52753,7 @@ var NodeFsHandler = class {
52564
52753
  this._addToNodeFs(path2, initialAdd, wh, depth + 1);
52565
52754
  }
52566
52755
  }).on(EV.ERROR, this._boundHandleError);
52567
- return new Promise((resolve6, reject) => {
52756
+ return new Promise((resolve7, reject) => {
52568
52757
  if (!stream)
52569
52758
  return reject();
52570
52759
  stream.once(STR_END, () => {
@@ -52573,7 +52762,7 @@ var NodeFsHandler = class {
52573
52762
  return;
52574
52763
  }
52575
52764
  const wasThrottled = throttler ? throttler.clear() : false;
52576
- resolve6(void 0);
52765
+ resolve7(void 0);
52577
52766
  previous.getChildren().filter((item) => {
52578
52767
  return item !== directory && !current.has(item);
52579
52768
  }).forEach((item) => {
@@ -53656,8 +53845,8 @@ init_src10();
53656
53845
  init_review2();
53657
53846
 
53658
53847
  // src/turn.ts
53659
- import { closeSync, existsSync as existsSync13, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync, statSync as statSync4 } from "node:fs";
53660
- import { basename as basename3, dirname as dirname8, join as join16 } from "node:path";
53848
+ import { closeSync, existsSync as existsSync15, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync, statSync as statSync5 } from "node:fs";
53849
+ import { basename as basename4, dirname as dirname9, join as join18 } from "node:path";
53661
53850
  import { homedir as homedir4 } from "node:os";
53662
53851
  import { createHash as createHash13 } from "node:crypto";
53663
53852
  function readFrom(path2, fromByte, maxBytes) {
@@ -54035,11 +54224,11 @@ function turnsSince(turns, mark) {
54035
54224
  return at >= 0 ? turns.slice(at + 1) : turns;
54036
54225
  }
54037
54226
  function claudeProjectDir(cwd, home = homedir4()) {
54038
- return join16(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
54227
+ return join18(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
54039
54228
  }
54040
54229
  function recentTranscripts(cwd, opts = {}) {
54041
54230
  const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
54042
- if (!existsSync13(dir)) return [];
54231
+ if (!existsSync15(dir)) return [];
54043
54232
  let names;
54044
54233
  try {
54045
54234
  names = readdirSync6(dir);
@@ -54050,23 +54239,23 @@ function recentTranscripts(cwd, opts = {}) {
54050
54239
  const refs = [];
54051
54240
  for (const name2 of names) {
54052
54241
  if (!name2.endsWith(".jsonl")) continue;
54053
- const path2 = join16(dir, name2);
54242
+ const path2 = join18(dir, name2);
54054
54243
  let mtimeMs;
54055
54244
  try {
54056
- mtimeMs = statSync4(path2).mtimeMs;
54245
+ mtimeMs = statSync5(path2).mtimeMs;
54057
54246
  } catch {
54058
54247
  continue;
54059
54248
  }
54060
54249
  if (mtimeMs < since) continue;
54061
- refs.push({ path: path2, sessionId: basename3(name2, ".jsonl"), mtimeMs });
54250
+ refs.push({ path: path2, sessionId: basename4(name2, ".jsonl"), mtimeMs });
54062
54251
  }
54063
54252
  refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
54064
54253
  return opts.limit ? refs.slice(0, opts.limit) : refs;
54065
54254
  }
54066
54255
  function subagentTranscripts(mainTranscriptPath, sessionId) {
54067
54256
  if (!mainTranscriptPath || !sessionId) return [];
54068
- const dir = join16(dirname8(mainTranscriptPath), sessionId, "subagents");
54069
- if (!existsSync13(dir)) return [];
54257
+ const dir = join18(dirname9(mainTranscriptPath), sessionId, "subagents");
54258
+ if (!existsSync15(dir)) return [];
54070
54259
  let names;
54071
54260
  try {
54072
54261
  names = readdirSync6(dir);
@@ -54076,14 +54265,14 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
54076
54265
  const refs = [];
54077
54266
  for (const name2 of names) {
54078
54267
  if (!name2.endsWith(".jsonl")) continue;
54079
- const path2 = join16(dir, name2);
54268
+ const path2 = join18(dir, name2);
54080
54269
  let mtimeMs;
54081
54270
  try {
54082
- mtimeMs = statSync4(path2).mtimeMs;
54271
+ mtimeMs = statSync5(path2).mtimeMs;
54083
54272
  } catch {
54084
54273
  continue;
54085
54274
  }
54086
- refs.push({ path: path2, sessionId: basename3(name2, ".jsonl"), mtimeMs });
54275
+ refs.push({ path: path2, sessionId: basename4(name2, ".jsonl"), mtimeMs });
54087
54276
  }
54088
54277
  refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
54089
54278
  return refs;
@@ -54094,8 +54283,8 @@ function codexSessionRoots(env2 = process.env, home = homedir4()) {
54094
54283
  if (explicit) {
54095
54284
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54096
54285
  }
54097
- if (env2["CODEX_HOME"]) roots.add(join16(env2["CODEX_HOME"], "sessions"));
54098
- roots.add(join16(home, ".codex", "sessions"));
54286
+ if (env2["CODEX_HOME"]) roots.add(join18(env2["CODEX_HOME"], "sessions"));
54287
+ roots.add(join18(home, ".codex", "sessions"));
54099
54288
  return [...roots];
54100
54289
  }
54101
54290
  function readCodexRolloutCwd(path2) {
@@ -54140,7 +54329,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54140
54329
  const limit = opts.limit ?? 25;
54141
54330
  const out2 = [];
54142
54331
  for (const root of codexSessionRoots(opts.env, opts.home)) {
54143
- if (!existsSync13(root)) continue;
54332
+ if (!existsSync15(root)) continue;
54144
54333
  const stack = [{ dir: root, depth: 0 }];
54145
54334
  while (stack.length > 0) {
54146
54335
  const { dir, depth } = stack.pop();
@@ -54151,10 +54340,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54151
54340
  continue;
54152
54341
  }
54153
54342
  for (const name2 of names) {
54154
- const full = join16(dir, name2);
54343
+ const full = join18(dir, name2);
54155
54344
  let st;
54156
54345
  try {
54157
- st = statSync4(full);
54346
+ st = statSync5(full);
54158
54347
  } catch {
54159
54348
  continue;
54160
54349
  }
@@ -54166,7 +54355,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54166
54355
  if (!name2.startsWith("rollout-") || !name2.endsWith(".jsonl")) continue;
54167
54356
  if (st.mtimeMs < sinceMs) continue;
54168
54357
  if (readCodexRolloutCwd(full) !== cwd) continue;
54169
- out2.push({ path: full, sessionId: `codex:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54358
+ out2.push({ path: full, sessionId: `codex:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54170
54359
  }
54171
54360
  }
54172
54361
  }
@@ -54179,8 +54368,8 @@ function geminiSessionRoots(env2 = process.env, home = homedir4()) {
54179
54368
  if (explicit) {
54180
54369
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54181
54370
  }
54182
- if (env2["GEMINI_CLI_HOME"]) roots.add(join16(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
54183
- roots.add(join16(home, ".gemini", "tmp"));
54371
+ if (env2["GEMINI_CLI_HOME"]) roots.add(join18(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
54372
+ roots.add(join18(home, ".gemini", "tmp"));
54184
54373
  return [...roots];
54185
54374
  }
54186
54375
  function geminiProjectHash(cwd) {
@@ -54220,7 +54409,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54220
54409
  const hashes = geminiHashesFor(cwd);
54221
54410
  const out2 = [];
54222
54411
  for (const root of geminiSessionRoots(opts.env, opts.home)) {
54223
- if (!existsSync13(root)) continue;
54412
+ if (!existsSync15(root)) continue;
54224
54413
  let slugs;
54225
54414
  try {
54226
54415
  slugs = readdirSync6(root);
@@ -54228,7 +54417,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54228
54417
  continue;
54229
54418
  }
54230
54419
  for (const slug2 of slugs) {
54231
- const chats = join16(root, slug2, "chats");
54420
+ const chats = join18(root, slug2, "chats");
54232
54421
  let names;
54233
54422
  try {
54234
54423
  names = readdirSync6(chats);
@@ -54237,17 +54426,17 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54237
54426
  }
54238
54427
  for (const name2 of names) {
54239
54428
  if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
54240
- const full = join16(chats, name2);
54429
+ const full = join18(chats, name2);
54241
54430
  let st;
54242
54431
  try {
54243
- st = statSync4(full);
54432
+ st = statSync5(full);
54244
54433
  } catch {
54245
54434
  continue;
54246
54435
  }
54247
54436
  if (!st.isFile() || st.mtimeMs < sinceMs) continue;
54248
54437
  const h = readGeminiTranscriptProjectHash(full);
54249
54438
  if (!h || !hashes.has(h)) continue;
54250
- out2.push({ path: full, sessionId: `gemini:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54439
+ out2.push({ path: full, sessionId: `gemini:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54251
54440
  }
54252
54441
  }
54253
54442
  }
@@ -54260,8 +54449,8 @@ function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
54260
54449
  if (explicit) {
54261
54450
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54262
54451
  }
54263
- if (env2["XDG_DATA_HOME"]) roots.add(join16(env2["XDG_DATA_HOME"], "opencode", "errata"));
54264
- roots.add(join16(home, ".local", "share", "opencode", "errata"));
54452
+ if (env2["XDG_DATA_HOME"]) roots.add(join18(env2["XDG_DATA_HOME"], "opencode", "errata"));
54453
+ roots.add(join18(home, ".local", "share", "opencode", "errata"));
54265
54454
  return [...roots];
54266
54455
  }
54267
54456
  function readOpencodeTranscriptDirectory(path2) {
@@ -54294,7 +54483,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
54294
54483
  }
54295
54484
  const out2 = [];
54296
54485
  for (const root of opencodeSessionRoots(opts.env, opts.home)) {
54297
- if (!existsSync13(root)) continue;
54486
+ if (!existsSync15(root)) continue;
54298
54487
  let names;
54299
54488
  try {
54300
54489
  names = readdirSync6(root);
@@ -54303,17 +54492,17 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
54303
54492
  }
54304
54493
  for (const name2 of names) {
54305
54494
  if (!name2.endsWith(".jsonl")) continue;
54306
- const full = join16(root, name2);
54495
+ const full = join18(root, name2);
54307
54496
  let st;
54308
54497
  try {
54309
- st = statSync4(full);
54498
+ st = statSync5(full);
54310
54499
  } catch {
54311
54500
  continue;
54312
54501
  }
54313
54502
  if (!st.isFile() || st.mtimeMs < sinceMs) continue;
54314
54503
  const dir = readOpencodeTranscriptDirectory(full);
54315
54504
  if (!dir || !(want.has(dir) || want.has(dir.replace(/\/+$/, "")))) continue;
54316
- out2.push({ path: full, sessionId: `opencode:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54505
+ out2.push({ path: full, sessionId: `opencode:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54317
54506
  }
54318
54507
  }
54319
54508
  out2.sort((a, b) => b.mtimeMs - a.mtimeMs);
@@ -54326,7 +54515,7 @@ init_src2();
54326
54515
  init_agent_signals();
54327
54516
  init_tool_index();
54328
54517
  init_src5();
54329
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "node:fs";
54518
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync11 } from "node:fs";
54330
54519
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
54331
54520
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
54332
54521
  var HANDLE_RE = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|prob|claim|err)_[0-9a-f]{6,})/gi;
@@ -54865,7 +55054,7 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
54865
55054
  }
54866
55055
  function readPrimingHandles(path2) {
54867
55056
  try {
54868
- return JSON.parse(readFileSync11(path2, "utf8"));
55057
+ return JSON.parse(readFileSync13(path2, "utf8"));
54869
55058
  } catch {
54870
55059
  return {};
54871
55060
  }
@@ -55340,8 +55529,8 @@ ${conversation}` }]
55340
55529
  // src/constraint-backfill.ts
55341
55530
  init_src5();
55342
55531
  init_src2();
55343
- import { existsSync as existsSync14, readFileSync as readFileSync12, readdirSync as readdirSync7, writeFileSync as writeFileSync12 } from "node:fs";
55344
- import { join as join17 } from "node:path";
55532
+ import { existsSync as existsSync16, readFileSync as readFileSync14, readdirSync as readdirSync7, writeFileSync as writeFileSync12 } from "node:fs";
55533
+ import { join as join19 } from "node:path";
55345
55534
  import { homedir as homedir5 } from "node:os";
55346
55535
  var BACKFILL_VERSION = 1;
55347
55536
  var EMPTY = {
@@ -55355,13 +55544,13 @@ var EMPTY = {
55355
55544
  recoverable: 0
55356
55545
  };
55357
55546
  function markerPath(configDir) {
55358
- return join17(configDir, "constraint-backfill.json");
55547
+ return join19(configDir, "constraint-backfill.json");
55359
55548
  }
55360
55549
  function alreadyDone(configDir) {
55361
55550
  const p = markerPath(configDir);
55362
- if (!existsSync14(p)) return false;
55551
+ if (!existsSync16(p)) return false;
55363
55552
  try {
55364
- const raw2 = JSON.parse(readFileSync12(p, "utf8"));
55553
+ const raw2 = JSON.parse(readFileSync14(p, "utf8"));
55365
55554
  return raw2?.version === BACKFILL_VERSION;
55366
55555
  } catch {
55367
55556
  return false;
@@ -55371,7 +55560,7 @@ function replay(root) {
55371
55560
  const statements = /* @__PURE__ */ new Set();
55372
55561
  const citedByFix = /* @__PURE__ */ new Set();
55373
55562
  const dir = claudeProjectDir(root, homedir5());
55374
- if (!existsSync14(dir)) return { statements, citedByFix };
55563
+ if (!existsSync16(dir)) return { statements, citedByFix };
55375
55564
  let names;
55376
55565
  try {
55377
55566
  names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
@@ -55381,7 +55570,7 @@ function replay(root) {
55381
55570
  for (const f of names) {
55382
55571
  let lines;
55383
55572
  try {
55384
- lines = readFileSync12(join17(dir, f), "utf8").split("\n");
55573
+ lines = readFileSync14(join19(dir, f), "utf8").split("\n");
55385
55574
  } catch {
55386
55575
  continue;
55387
55576
  }
@@ -55508,8 +55697,8 @@ function backfillConstraintKind(store, opts) {
55508
55697
  // src/edge-repair.ts
55509
55698
  init_src();
55510
55699
  init_src5();
55511
- import { existsSync as existsSync15, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "node:fs";
55512
- import { join as join18 } from "node:path";
55700
+ import { existsSync as existsSync17, readFileSync as readFileSync15, writeFileSync as writeFileSync13 } from "node:fs";
55701
+ import { join as join20 } from "node:path";
55513
55702
  function citeEdgeId(from, type, to) {
55514
55703
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
55515
55704
  }
@@ -55524,13 +55713,13 @@ var EMPTY2 = {
55524
55713
  byType: {}
55525
55714
  };
55526
55715
  function markerPath2(configDir) {
55527
- return join18(configDir, "edge-repair.json");
55716
+ return join20(configDir, "edge-repair.json");
55528
55717
  }
55529
55718
  function alreadyDone2(configDir) {
55530
55719
  const p = markerPath2(configDir);
55531
- if (!existsSync15(p)) return false;
55720
+ if (!existsSync17(p)) return false;
55532
55721
  try {
55533
- return JSON.parse(readFileSync13(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
55722
+ return JSON.parse(readFileSync15(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
55534
55723
  } catch {
55535
55724
  return false;
55536
55725
  }
@@ -55593,8 +55782,8 @@ function repairInvalidEdges(store, opts) {
55593
55782
  init_reconcile();
55594
55783
 
55595
55784
  // src/pass-ledger.ts
55596
- import { appendFileSync as appendFileSync2, existsSync as existsSync16, readFileSync as readFileSync14, writeFileSync as writeFileSync14 } from "node:fs";
55597
- import { join as join19 } from "node:path";
55785
+ import { appendFileSync as appendFileSync2, existsSync as existsSync18, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
55786
+ import { join as join21 } from "node:path";
55598
55787
 
55599
55788
  // src/isolate-census.ts
55600
55789
  var live = 0;
@@ -55617,7 +55806,7 @@ var PER_KIND_MAX = 100;
55617
55806
  var TRIM_EVERY = 50;
55618
55807
  var appendsSinceTrim = /* @__PURE__ */ new Map();
55619
55808
  function passLedgerPath(configDir) {
55620
- return join19(configDir, "pass-ledger.jsonl");
55809
+ return join21(configDir, "pass-ledger.jsonl");
55621
55810
  }
55622
55811
  function appendPassLedger(configDir, kind, durationMs, counts) {
55623
55812
  const path2 = passLedgerPath(configDir);
@@ -55646,7 +55835,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
55646
55835
  return;
55647
55836
  }
55648
55837
  appendsSinceTrim.set(path2, 0);
55649
- const lines = readFileSync14(path2, "utf8").split("\n").filter(Boolean);
55838
+ const lines = readFileSync16(path2, "utf8").split("\n").filter(Boolean);
55650
55839
  const keptByKind = /* @__PURE__ */ new Map();
55651
55840
  const kept = [];
55652
55841
  for (let i2 = lines.length - 1; i2 >= 0; i2--) {
@@ -55669,9 +55858,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
55669
55858
  }
55670
55859
  function readPassLedger(configDir) {
55671
55860
  const path2 = passLedgerPath(configDir);
55672
- if (!existsSync16(path2)) return [];
55861
+ if (!existsSync18(path2)) return [];
55673
55862
  try {
55674
- return readFileSync14(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
55863
+ return readFileSync16(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
55675
55864
  (e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
55676
55865
  ).map((e) => ({ ...e, counts: e.counts ?? {} }));
55677
55866
  } catch {
@@ -55954,8 +56143,8 @@ var PassWorker = class {
55954
56143
  const id = this.nextId++;
55955
56144
  try {
55956
56145
  await this.ready;
55957
- return await new Promise((resolve6, reject) => {
55958
- this.pending.set(id, { resolve: resolve6, reject });
56146
+ return await new Promise((resolve7, reject) => {
56147
+ this.pending.set(id, { resolve: resolve7, reject });
55959
56148
  this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
55960
56149
  });
55961
56150
  } finally {
@@ -55989,12 +56178,12 @@ var PassWorker = class {
55989
56178
  });
55990
56179
  noteIsolateSpawned();
55991
56180
  this.worker = worker;
55992
- this.ready = new Promise((resolve6, reject) => {
56181
+ this.ready = new Promise((resolve7, reject) => {
55993
56182
  const onReady = (m) => {
55994
56183
  if (m?.ready) {
55995
56184
  worker.off("message", onReady);
55996
56185
  worker.off("error", onErr);
55997
- resolve6();
56186
+ resolve7();
55998
56187
  }
55999
56188
  };
56000
56189
  const onErr = (err2) => reject(err2);
@@ -56039,11 +56228,11 @@ init_outbox();
56039
56228
  init_src9();
56040
56229
  init_src();
56041
56230
  init_src2();
56042
- import { readFileSync as readFileSync15 } from "node:fs";
56043
- import { join as join20 } from "node:path";
56231
+ import { readFileSync as readFileSync17 } from "node:fs";
56232
+ import { join as join22 } from "node:path";
56044
56233
  function loadClaimIgnorePatterns(workspaceRoot) {
56045
56234
  try {
56046
- return readFileSync15(join20(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
56235
+ return readFileSync17(join22(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
56047
56236
  } catch {
56048
56237
  return [];
56049
56238
  }
@@ -56404,22 +56593,22 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
56404
56593
  }
56405
56594
 
56406
56595
  // src/git-sensor.ts
56407
- import { existsSync as existsSync17, readFileSync as readFileSync16, watch as fsWatch } from "node:fs";
56408
- import { join as join21 } from "node:path";
56596
+ import { existsSync as existsSync19, readFileSync as readFileSync18, watch as fsWatch } from "node:fs";
56597
+ import { join as join23 } from "node:path";
56409
56598
  function readFirstLine(path2) {
56410
56599
  try {
56411
- return readFileSync16(path2, "utf8").split(/\r?\n/, 1)[0].trim();
56600
+ return readFileSync18(path2, "utf8").split(/\r?\n/, 1)[0].trim();
56412
56601
  } catch {
56413
56602
  return null;
56414
56603
  }
56415
56604
  }
56416
56605
  function readGitRefState(gitDir) {
56417
- const head2 = readFirstLine(join21(gitDir, "HEAD"));
56606
+ const head2 = readFirstLine(join23(gitDir, "HEAD"));
56418
56607
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
56419
56608
  const branch = m ? m[1] : null;
56420
56609
  let sha2 = null;
56421
56610
  if (branch) {
56422
- sha2 = readFirstLine(join21(gitDir, "refs", "heads", branch));
56611
+ sha2 = readFirstLine(join23(gitDir, "refs", "heads", branch));
56423
56612
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
56424
56613
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
56425
56614
  sha2 = head2;
@@ -56427,13 +56616,13 @@ function readGitRefState(gitDir) {
56427
56616
  return {
56428
56617
  branch,
56429
56618
  sha: sha2,
56430
- mergeHeadExists: existsSync17(join21(gitDir, "MERGE_HEAD")),
56431
- origHeadExists: existsSync17(join21(gitDir, "ORIG_HEAD"))
56619
+ mergeHeadExists: existsSync19(join23(gitDir, "MERGE_HEAD")),
56620
+ origHeadExists: existsSync19(join23(gitDir, "ORIG_HEAD"))
56432
56621
  };
56433
56622
  }
56434
56623
  function shaFromPackedRefs(gitDir, ref) {
56435
56624
  try {
56436
- for (const line of readFileSync16(join21(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
56625
+ for (const line of readFileSync18(join23(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
56437
56626
  const [sha2, name2] = line.split(/\s+/);
56438
56627
  if (name2 === ref && sha2) return sha2;
56439
56628
  }
@@ -56467,7 +56656,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56467
56656
  const settle = () => {
56468
56657
  if (timer) clearTimeout(timer);
56469
56658
  timer = setTimeout(() => {
56470
- if (existsSync17(join21(gitDir, "index.lock"))) {
56659
+ if (existsSync19(join23(gitDir, "index.lock"))) {
56471
56660
  settle();
56472
56661
  return;
56473
56662
  }
@@ -56478,7 +56667,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56478
56667
  }, debounceMs);
56479
56668
  };
56480
56669
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
56481
- const p = join21(gitDir, sub);
56670
+ const p = join23(gitDir, sub);
56482
56671
  try {
56483
56672
  watchers.push(fsWatch(p, settle));
56484
56673
  } catch {
@@ -56498,7 +56687,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56498
56687
  // src/git-delta.ts
56499
56688
  import { execFile } from "node:child_process";
56500
56689
  function git(repoDir, args2) {
56501
- return new Promise((resolve6, reject) => {
56690
+ return new Promise((resolve7, reject) => {
56502
56691
  execFile(
56503
56692
  "git",
56504
56693
  ["-C", repoDir, ...args2],
@@ -56509,7 +56698,7 @@ function git(repoDir, args2) {
56509
56698
  // git-sensor runs on every commit/checkout.
56510
56699
  windowsHide: true
56511
56700
  },
56512
- (err2, stdout) => err2 ? reject(err2) : resolve6(stdout)
56701
+ (err2, stdout) => err2 ? reject(err2) : resolve7(stdout)
56513
56702
  );
56514
56703
  });
56515
56704
  }
@@ -56703,21 +56892,21 @@ var TelemetryRecorder = class {
56703
56892
 
56704
56893
  // src/skills.ts
56705
56894
  import {
56706
- existsSync as existsSync18,
56895
+ existsSync as existsSync20,
56707
56896
  mkdirSync as mkdirSync7,
56708
- readFileSync as readFileSync17,
56897
+ readFileSync as readFileSync19,
56709
56898
  readdirSync as readdirSync8,
56710
56899
  unlinkSync as unlinkSync2,
56711
56900
  writeFileSync as writeFileSync15
56712
56901
  } from "node:fs";
56713
- import { basename as basename4, join as join22 } from "node:path";
56902
+ import { basename as basename5, join as join24 } from "node:path";
56714
56903
  function skillFileName(id) {
56715
56904
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
56716
56905
  }
56717
56906
  function readSkillManifest(manifestPath) {
56718
- if (!existsSync18(manifestPath)) return [];
56907
+ if (!existsSync20(manifestPath)) return [];
56719
56908
  try {
56720
- const parsed = JSON.parse(readFileSync17(manifestPath, "utf8"));
56909
+ const parsed = JSON.parse(readFileSync19(manifestPath, "utf8"));
56721
56910
  return (parsed.skills ?? []).map((s) => ({
56722
56911
  title: s.title ?? "",
56723
56912
  layer: s.layer ?? "technique",
@@ -56741,7 +56930,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56741
56930
  for (const s of res.skills) {
56742
56931
  const fileName = skillFileName(s.id);
56743
56932
  keep.add(fileName);
56744
- writeFileSync15(join22(paths.skillsDir, fileName), s.markdown, "utf8");
56933
+ writeFileSync15(join24(paths.skillsDir, fileName), s.markdown, "utf8");
56745
56934
  rows.push({
56746
56935
  id: s.id,
56747
56936
  title: s.title,
@@ -56754,7 +56943,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56754
56943
  const fileName = skillFileName(p.id);
56755
56944
  if (keep.has(fileName)) continue;
56756
56945
  keep.add(fileName);
56757
- writeFileSync15(join22(paths.skillsDir, fileName), p.markdown, "utf8");
56946
+ writeFileSync15(join24(paths.skillsDir, fileName), p.markdown, "utf8");
56758
56947
  rows.push({
56759
56948
  id: p.id,
56760
56949
  title: p.title,
@@ -56766,9 +56955,9 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56766
56955
  let pruned = 0;
56767
56956
  for (const f of readdirSync8(paths.skillsDir)) {
56768
56957
  if (!f.endsWith(".md")) continue;
56769
- if (keep.has(basename4(f))) continue;
56958
+ if (keep.has(basename5(f))) continue;
56770
56959
  try {
56771
- unlinkSync2(join22(paths.skillsDir, f));
56960
+ unlinkSync2(join24(paths.skillsDir, f));
56772
56961
  pruned++;
56773
56962
  } catch {
56774
56963
  }
@@ -56786,22 +56975,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56786
56975
  init_src2();
56787
56976
  import {
56788
56977
  cpSync,
56789
- existsSync as existsSync19,
56978
+ existsSync as existsSync21,
56790
56979
  lstatSync,
56791
56980
  mkdirSync as mkdirSync8,
56792
- readFileSync as readFileSync18,
56981
+ readFileSync as readFileSync20,
56793
56982
  readdirSync as readdirSync9,
56794
56983
  rmSync as rmSync3,
56795
56984
  symlinkSync,
56796
56985
  writeFileSync as writeFileSync16
56797
56986
  } from "node:fs";
56798
- import { join as join23 } from "node:path";
56987
+ import { join as join25 } from "node:path";
56799
56988
  var SKILL_NS = "errata-";
56800
56989
  var HARNESS_SKILL_DIRS = [
56801
- { configDir: ".claude", skillsDir: join23(".claude", "skills") },
56990
+ { configDir: ".claude", skillsDir: join25(".claude", "skills") },
56802
56991
  // Cursor adopted the standard; its exact project dir is still moving — kept
56803
56992
  // best-effort and gated on `.cursor/` presence so we never create it blind.
56804
- { configDir: ".cursor", skillsDir: join23(".cursor", "skills") }
56993
+ { configDir: ".cursor", skillsDir: join25(".cursor", "skills") }
56805
56994
  ];
56806
56995
  function skillSlug(title, id) {
56807
56996
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -56846,12 +57035,12 @@ function skillCiteHandle(s) {
56846
57035
  return priorHandle({ id: s.id, description: s.title });
56847
57036
  }
56848
57037
  function reconcileNamespaced(dir, keep) {
56849
- if (!existsSync19(dir)) return 0;
57038
+ if (!existsSync21(dir)) return 0;
56850
57039
  let pruned = 0;
56851
57040
  for (const name2 of readdirSync9(dir)) {
56852
57041
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
56853
57042
  try {
56854
- rmSync3(join23(dir, name2), { recursive: true, force: true });
57043
+ rmSync3(join25(dir, name2), { recursive: true, force: true });
56855
57044
  pruned++;
56856
57045
  } catch {
56857
57046
  }
@@ -56860,7 +57049,7 @@ function reconcileNamespaced(dir, keep) {
56860
57049
  }
56861
57050
  function linkOrCopy(linkPath, target) {
56862
57051
  try {
56863
- if (existsSync19(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
57052
+ if (existsSync21(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
56864
57053
  } catch {
56865
57054
  }
56866
57055
  try {
@@ -56881,7 +57070,7 @@ function safeLstat(p) {
56881
57070
  }
56882
57071
  }
56883
57072
  function emitAndProjectSkills(root, skills) {
56884
- const agentsSkillsDir = join23(root, ".agents", "skills");
57073
+ const agentsSkillsDir = join25(root, ".agents", "skills");
56885
57074
  mkdirSync8(agentsSkillsDir, { recursive: true });
56886
57075
  const slugs = [];
56887
57076
  const keep = /* @__PURE__ */ new Set();
@@ -56889,7 +57078,7 @@ function emitAndProjectSkills(root, skills) {
56889
57078
  for (const s of skills) {
56890
57079
  let body2;
56891
57080
  try {
56892
- body2 = readFileSync18(s.bodyPath, "utf8");
57081
+ body2 = readFileSync20(s.bodyPath, "utf8");
56893
57082
  } catch {
56894
57083
  continue;
56895
57084
  }
@@ -56898,9 +57087,9 @@ function emitAndProjectSkills(root, skills) {
56898
57087
  keep.add(slug2);
56899
57088
  slugs.push(slug2);
56900
57089
  const description = deriveDescription(s.title, s.layer, body2);
56901
- mkdirSync8(join23(agentsSkillsDir, slug2), { recursive: true });
57090
+ mkdirSync8(join25(agentsSkillsDir, slug2), { recursive: true });
56902
57091
  writeFileSync16(
56903
- join23(agentsSkillsDir, slug2, "SKILL.md"),
57092
+ join25(agentsSkillsDir, slug2, "SKILL.md"),
56904
57093
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
56905
57094
  "utf8"
56906
57095
  );
@@ -56909,11 +57098,11 @@ function emitAndProjectSkills(root, skills) {
56909
57098
  reconcileNamespaced(agentsSkillsDir, keep);
56910
57099
  let projected = 0;
56911
57100
  for (const h of HARNESS_SKILL_DIRS) {
56912
- if (!existsSync19(join23(root, h.configDir))) continue;
56913
- const dir = join23(root, h.skillsDir);
57101
+ if (!existsSync21(join25(root, h.configDir))) continue;
57102
+ const dir = join25(root, h.skillsDir);
56914
57103
  mkdirSync8(dir, { recursive: true });
56915
57104
  for (const slug2 of slugs) {
56916
- linkOrCopy(join23(dir, slug2), join23(agentsSkillsDir, slug2));
57105
+ linkOrCopy(join25(dir, slug2), join25(agentsSkillsDir, slug2));
56917
57106
  projected++;
56918
57107
  }
56919
57108
  reconcileNamespaced(dir, keep);
@@ -56922,15 +57111,15 @@ function emitAndProjectSkills(root, skills) {
56922
57111
  return { slugs, emitted, projected };
56923
57112
  }
56924
57113
  function emitInputsFromManifest(erretaDir, manifestPath) {
56925
- if (!existsSync19(manifestPath)) return [];
57114
+ if (!existsSync21(manifestPath)) return [];
56926
57115
  try {
56927
- const parsed = JSON.parse(readFileSync18(manifestPath, "utf8"));
57116
+ const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
56928
57117
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
56929
57118
  id: s.id,
56930
57119
  title: s.title ?? s.id,
56931
57120
  layer: s.layer ?? "technique",
56932
57121
  confidence: s.confidence ?? 0,
56933
- bodyPath: join23(erretaDir, s.file)
57122
+ bodyPath: join25(erretaDir, s.file)
56934
57123
  }));
56935
57124
  } catch {
56936
57125
  return [];
@@ -56944,10 +57133,10 @@ var GITIGNORE_LINES = [
56944
57133
  ".cursor/skills/errata-*/"
56945
57134
  ];
56946
57135
  function ensureSkillGitignore(root) {
56947
- const path2 = join23(root, ".gitignore");
57136
+ const path2 = join25(root, ".gitignore");
56948
57137
  let current = "";
56949
57138
  try {
56950
- current = existsSync19(path2) ? readFileSync18(path2, "utf8") : "";
57139
+ current = existsSync21(path2) ? readFileSync20(path2, "utf8") : "";
56951
57140
  } catch {
56952
57141
  return;
56953
57142
  }
@@ -57051,63 +57240,10 @@ init_paths();
57051
57240
  // src/profile.ts
57052
57241
  init_src2();
57053
57242
  init_paths();
57054
- import { existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync17 } from "node:fs";
57243
+ init_git_remote();
57244
+ import { existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
57055
57245
  import { createHash as createHash14 } from "node:crypto";
57056
- import { join as join25 } from "node:path";
57057
-
57058
- // src/git-remote.ts
57059
- init_src();
57060
- import { existsSync as existsSync20, readFileSync as readFileSync19, statSync as statSync5 } from "node:fs";
57061
- import { isAbsolute as isAbsolute3, join as join24, resolve as resolve5 } from "node:path";
57062
- function resolveGitDir(root) {
57063
- const dotGit = join24(root, ".git");
57064
- try {
57065
- const st = statSync5(dotGit);
57066
- if (st.isDirectory()) return dotGit;
57067
- const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync19(dotGit, "utf8"));
57068
- if (!m) return null;
57069
- const dir = m[1];
57070
- return isAbsolute3(dir) ? dir : resolve5(root, dir);
57071
- } catch {
57072
- return null;
57073
- }
57074
- }
57075
- function gitConfigPath(gitDir) {
57076
- const commondirFile = join24(gitDir, "commondir");
57077
- if (existsSync20(commondirFile)) {
57078
- const common = readFileSync19(commondirFile, "utf8").trim();
57079
- const commonDir = isAbsolute3(common) ? common : resolve5(gitDir, common);
57080
- return join24(commonDir, "config");
57081
- }
57082
- return join24(gitDir, "config");
57083
- }
57084
- function readRemotes(root) {
57085
- const gitDir = resolveGitDir(root);
57086
- if (!gitDir) return [];
57087
- const cfgPath = gitConfigPath(gitDir);
57088
- if (!existsSync20(cfgPath)) return [];
57089
- let txt;
57090
- try {
57091
- txt = readFileSync19(cfgPath, "utf8");
57092
- } catch {
57093
- return [];
57094
- }
57095
- const out2 = [];
57096
- const sectionRe = /^\s*\[remote "([^"]+)"\]\s*$([\s\S]*?)(?=^\s*\[|\s*$(?![\s\S]))/gm;
57097
- for (const m of txt.matchAll(sectionRe)) {
57098
- const url2 = /^\s*url\s*=\s*(.+?)\s*$/m.exec(m[2])?.[1];
57099
- if (url2) out2.push({ name: m[1], url: url2 });
57100
- }
57101
- return out2;
57102
- }
57103
- function detectRepoLocator(root, remote) {
57104
- const remotes = readRemotes(root);
57105
- if (remotes.length === 0) return null;
57106
- const pick2 = remote ? remotes.find((r) => r.name === remote) ?? null : remotes.find((r) => r.name === "origin") ?? (remotes.length === 1 ? remotes[0] : null);
57107
- return pick2 ? normalizeRepoLocator(pick2.url) : null;
57108
- }
57109
-
57110
- // src/profile.ts
57246
+ import { join as join26 } from "node:path";
57111
57247
  function workspaceId(root) {
57112
57248
  return "wp_" + createHash14("sha256").update(root).digest("hex").slice(0, 12);
57113
57249
  }
@@ -57130,8 +57266,8 @@ function refreshRepoLocator(root, profile) {
57130
57266
  }
57131
57267
  function loadProfile(root) {
57132
57268
  const p = workspacePaths(root);
57133
- if (!existsSync21(p.workspaceJson)) return null;
57134
- return JSON.parse(readFileSync20(p.workspaceJson, "utf8"));
57269
+ if (!existsSync22(p.workspaceJson)) return null;
57270
+ return JSON.parse(readFileSync21(p.workspaceJson, "utf8"));
57135
57271
  }
57136
57272
  function saveProfile(root, profile) {
57137
57273
  const p = workspacePaths(root);
@@ -57144,10 +57280,10 @@ function autodetectProfile(root) {
57144
57280
  const p = emptyProfile(id, name2);
57145
57281
  const locator = detectRepoLocator(root);
57146
57282
  if (locator) p.repoLocator = locator;
57147
- const pkgPath = join25(root, "package.json");
57148
- if (existsSync21(pkgPath)) {
57283
+ const pkgPath = join26(root, "package.json");
57284
+ if (existsSync22(pkgPath)) {
57149
57285
  try {
57150
- const pkg = JSON.parse(readFileSync20(pkgPath, "utf8"));
57286
+ const pkg = JSON.parse(readFileSync21(pkgPath, "utf8"));
57151
57287
  p.languages.push("typescript", "javascript");
57152
57288
  const nodeVer = pkg.engines?.node ?? "node";
57153
57289
  p.stack.push(`node@${nodeVer}`);
@@ -57168,10 +57304,10 @@ function autodetectProfile(root) {
57168
57304
  } catch {
57169
57305
  }
57170
57306
  }
57171
- const pyproject = join25(root, "pyproject.toml");
57172
- if (existsSync21(pyproject)) {
57307
+ const pyproject = join26(root, "pyproject.toml");
57308
+ if (existsSync22(pyproject)) {
57173
57309
  try {
57174
- const txt = readFileSync20(pyproject, "utf8");
57310
+ const txt = readFileSync21(pyproject, "utf8");
57175
57311
  const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
57176
57312
  p.languages.push("python");
57177
57313
  p.stack.push(`python@${py ?? "3"}`);
@@ -57182,16 +57318,16 @@ function autodetectProfile(root) {
57182
57318
  } catch {
57183
57319
  }
57184
57320
  }
57185
- const reqs = join25(root, "requirements.txt");
57186
- if (existsSync21(reqs)) {
57321
+ const reqs = join26(root, "requirements.txt");
57322
+ if (existsSync22(reqs)) {
57187
57323
  if (!p.languages.includes("python")) p.languages.push("python");
57188
57324
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
57189
57325
  }
57190
- if (existsSync21(join25(root, "go.mod"))) {
57326
+ if (existsSync22(join26(root, "go.mod"))) {
57191
57327
  p.languages.push("go");
57192
57328
  p.stack.push("go");
57193
57329
  }
57194
- if (existsSync21(join25(root, "Cargo.toml"))) {
57330
+ if (existsSync22(join26(root, "Cargo.toml"))) {
57195
57331
  p.languages.push("rust");
57196
57332
  p.stack.push("rust");
57197
57333
  }
@@ -57201,18 +57337,18 @@ function autodetectProfile(root) {
57201
57337
  }
57202
57338
 
57203
57339
  // src/witness-queue.ts
57204
- import { readFileSync as readFileSync21, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
57205
- import { dirname as dirname9, join as join26 } from "node:path";
57340
+ import { readFileSync as readFileSync22, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
57341
+ import { dirname as dirname10, join as join27 } from "node:path";
57206
57342
  var WITNESS_QUEUE_CAP = 500;
57207
57343
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
57208
57344
  var WITNESS_MAX_ATTEMPTS = 5;
57209
57345
  function witnessQueuePath(workspaceConfigDir) {
57210
- return join26(workspaceConfigDir, "witness-queue.json");
57346
+ return join27(workspaceConfigDir, "witness-queue.json");
57211
57347
  }
57212
57348
  function loadWitnessQueueWithLosses(path2) {
57213
57349
  let raw2;
57214
57350
  try {
57215
- raw2 = JSON.parse(readFileSync21(path2, "utf8"));
57351
+ raw2 = JSON.parse(readFileSync22(path2, "utf8"));
57216
57352
  } catch (err2) {
57217
57353
  const absent = err2?.code === "ENOENT";
57218
57354
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -57225,7 +57361,7 @@ function loadWitnessQueueWithLosses(path2) {
57225
57361
  }
57226
57362
  function saveWitnessQueue(path2, queue) {
57227
57363
  try {
57228
- const tmp = join26(dirname9(path2), `.${Date.now()}.witness-queue.tmp`);
57364
+ const tmp = join27(dirname10(path2), `.${Date.now()}.witness-queue.tmp`);
57229
57365
  writeFileSync18(tmp, JSON.stringify(queue), "utf8");
57230
57366
  renameSync2(tmp, path2);
57231
57367
  } catch {
@@ -57799,7 +57935,7 @@ function createWatchBreaker(deps) {
57799
57935
  }
57800
57936
 
57801
57937
  // src/engine.ts
57802
- var DAEMON_VERSION = true ? "2.0.4" : "2.0.0-alpha.0";
57938
+ var DAEMON_VERSION = true ? "2.0.5-dev.1868" : "2.0.0-alpha.0";
57803
57939
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
57804
57940
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
57805
57941
  var GIT_OP_MUTE_MS = 4e3;
@@ -57810,7 +57946,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
57810
57946
  function appendIdentityAudit(path2, record2, line) {
57811
57947
  if (!record2.accepted && record2.score <= 0) return;
57812
57948
  try {
57813
- if (existsSync23(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
57949
+ if (existsSync24(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
57814
57950
  renameSync3(path2, `${path2}.1`);
57815
57951
  }
57816
57952
  appendFileSync4(path2, line);
@@ -57820,7 +57956,7 @@ function appendIdentityAudit(path2, record2, line) {
57820
57956
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
57821
57957
  function loadTurnCursors(path2) {
57822
57958
  try {
57823
- const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
57959
+ const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
57824
57960
  return new Map(
57825
57961
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
57826
57962
  );
@@ -57830,7 +57966,7 @@ function loadTurnCursors(path2) {
57830
57966
  }
57831
57967
  function loadTurnOffsets(path2) {
57832
57968
  try {
57833
- const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
57969
+ const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
57834
57970
  const out2 = /* @__PURE__ */ new Map();
57835
57971
  for (const [k, v] of Object.entries(raw2)) {
57836
57972
  const off = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -57868,7 +58004,7 @@ function gitSourceWatchTargets(root) {
57868
58004
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
57869
58005
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
57870
58006
  );
57871
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join28(root, d) + sep4));
58007
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join29(root, d) + sep4));
57872
58008
  } catch {
57873
58009
  }
57874
58010
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -57880,19 +58016,19 @@ function gitSourceWatchTargets(root) {
57880
58016
  if (!f.startsWith(prefix)) continue;
57881
58017
  const rest2 = f.slice(prefix.length);
57882
58018
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
57883
- else targets.add(join28(root, f));
58019
+ else targets.add(join29(root, f));
57884
58020
  }
57885
58021
  for (const c of children) {
57886
- if (IGNORED_PATH.test(join28(root, c) + sep4)) continue;
58022
+ if (IGNORED_PATH.test(join29(root, c) + sep4)) continue;
57887
58023
  if (hasIgnoredChild(c)) addUnder(c);
57888
- else targets.add(join28(root, c));
58024
+ else targets.add(join29(root, c));
57889
58025
  }
57890
58026
  };
57891
58027
  addUnder("");
57892
58028
  if (targets.size > 0) return [...targets];
57893
58029
  } catch {
57894
58030
  }
57895
- return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join28(root, String(e.name)) + sep4)).map((e) => join28(root, String(e.name)));
58031
+ return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join29(root, String(e.name)) + sep4)).map((e) => join29(root, String(e.name)));
57896
58032
  }
57897
58033
  function createWorkspaceEngine(opts) {
57898
58034
  const paths = workspacePaths(opts.workspaceRoot);
@@ -58085,7 +58221,7 @@ function createWorkspaceEngine(opts) {
58085
58221
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
58086
58222
  let episodeId2;
58087
58223
  if (srcPaths.length > 0) {
58088
- const abs = srcPaths.map((p) => join28(opts.workspaceRoot, p));
58224
+ const abs = srcPaths.map((p) => join29(opts.workspaceRoot, p));
58089
58225
  try {
58090
58226
  const r = await runReindexPass(
58091
58227
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -58121,8 +58257,8 @@ function createWorkspaceEngine(opts) {
58121
58257
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
58122
58258
  );
58123
58259
  };
58124
- const gitDir = join28(opts.workspaceRoot, ".git");
58125
- if (existsSync23(gitDir)) {
58260
+ const gitDir = join29(opts.workspaceRoot, ".git");
58261
+ if (existsSync24(gitDir)) {
58126
58262
  stopGit = startGitSensor(gitDir, (ev) => {
58127
58263
  void handleGitEvent(ev).catch((err2) => {
58128
58264
  console.warn("[errata] git event handler failed:", err2);
@@ -58303,10 +58439,10 @@ function createWorkspaceEngine(opts) {
58303
58439
  console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
58304
58440
  }
58305
58441
  writeContextFile(opts.workspaceRoot, body2);
58306
- const target = join28(opts.workspaceRoot, "AGENTS.md");
58442
+ const target = join29(opts.workspaceRoot, "AGENTS.md");
58307
58443
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
58308
58444
  if (elicit) {
58309
- writePrimingHandles(join28(paths.configDir, "priming-handles.json"), [
58445
+ writePrimingHandles(join29(paths.configDir, "priming-handles.json"), [
58310
58446
  ...snapshot.recentProblems.map((r) => r.node),
58311
58447
  // Resolved-band handles: the ✓ problem AND its Solution are citable
58312
58448
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -58607,7 +58743,7 @@ function createWorkspaceEngine(opts) {
58607
58743
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
58608
58744
  });
58609
58745
  };
58610
- const turnCursorPath = join28(paths.configDir, "turn-cursors.json");
58746
+ const turnCursorPath = join29(paths.configDir, "turn-cursors.json");
58611
58747
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
58612
58748
  const turnOffset = loadTurnOffsets(turnCursorPath);
58613
58749
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -58662,7 +58798,7 @@ function createWorkspaceEngine(opts) {
58662
58798
  let processedTurns = 0;
58663
58799
  const seqAtStart = store.currentIngestSeq();
58664
58800
  const elicit = isEdgeElicitationEnabled();
58665
- const handleMap = elicit ? readPrimingHandles(join28(paths.configDir, "priming-handles.json")) : {};
58801
+ const handleMap = elicit ? readPrimingHandles(join29(paths.configDir, "priming-handles.json")) : {};
58666
58802
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
58667
58803
  const toRel = (abs) => {
58668
58804
  const p = abs.replace(/\\/g, "/");
@@ -58951,7 +59087,15 @@ function createWorkspaceEngine(opts) {
58951
59087
  if (p.threadId) threads.set(p.threadId, designProblemId(p.statement));
58952
59088
  try {
58953
59089
  if (anchorPath) {
58954
- if (anchorProblemToWorkingFile(store, r.problemId, anchorPath, profile.id, t, anchorProvenance)) {
59090
+ let enclosing = {};
59091
+ if (p.location?.line !== void 0) {
59092
+ try {
59093
+ enclosing = { line: p.location.line, fileText: readFileSync24(join29(opts.workspaceRoot, anchorPath), "utf8") };
59094
+ } catch {
59095
+ enclosing = {};
59096
+ }
59097
+ }
59098
+ if (anchorProblemToWorkingFile(store, r.problemId, anchorPath, profile.id, t, anchorProvenance, enclosing)) {
58955
59099
  deriveContextFromAnchors(store, r.problemId, t);
58956
59100
  }
58957
59101
  } else if (hintPath) {
@@ -59463,7 +59607,7 @@ function createWorkspaceEngine(opts) {
59463
59607
  }
59464
59608
  turns = next.turns;
59465
59609
  nextOffset = next.nextOffset;
59466
- await new Promise((resolve6) => setImmediate(resolve6));
59610
+ await new Promise((resolve7) => setImmediate(resolve7));
59467
59611
  }
59468
59612
  };
59469
59613
  const seenMessageIds = /* @__PURE__ */ new Set();
@@ -59666,7 +59810,7 @@ B: ${b}`,
59666
59810
  try {
59667
59811
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
59668
59812
  emitAndProjectSkills(opts.workspaceRoot, inputs);
59669
- writePrimingHandles(join28(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
59813
+ writePrimingHandles(join29(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
59670
59814
  } catch (err2) {
59671
59815
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
59672
59816
  }
@@ -59959,7 +60103,7 @@ B: ${b}`,
59959
60103
  console.log(
59960
60104
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
59961
60105
  );
59962
- const pending = existsSync23(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
60106
+ const pending = existsSync24(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
59963
60107
  return { uploaded: 0, failed: 0, remaining: pending };
59964
60108
  }
59965
60109
  try {
@@ -60093,7 +60237,7 @@ async function startDaemon(opts) {
60093
60237
  );
60094
60238
  await engine.stop();
60095
60239
  try {
60096
- if (existsSync24(engine.paths.daemonLock)) {
60240
+ if (existsSync25(engine.paths.daemonLock)) {
60097
60241
  }
60098
60242
  } catch {
60099
60243
  }
@@ -60101,9 +60245,9 @@ async function startDaemon(opts) {
60101
60245
  };
60102
60246
  }
60103
60247
  async function listenServer(fetchFn, port) {
60104
- return new Promise((resolve6) => {
60248
+ return new Promise((resolve7) => {
60105
60249
  const server = serve({ fetch: fetchFn, hostname: "127.0.0.1", port }, (info2) => {
60106
- resolve6({ server, port: info2.port });
60250
+ resolve7({ server, port: info2.port });
60107
60251
  });
60108
60252
  });
60109
60253
  }
@@ -60115,7 +60259,7 @@ init_identity2();
60115
60259
  // src/multi.ts
60116
60260
  init_dist();
60117
60261
  init_src5();
60118
- import { existsSync as existsSync29, readFileSync as readFileSync27, unlinkSync as unlinkSync3, writeFileSync as writeFileSync22 } from "node:fs";
60262
+ import { existsSync as existsSync30, readFileSync as readFileSync28, unlinkSync as unlinkSync3, writeFileSync as writeFileSync22 } from "node:fs";
60119
60263
 
60120
60264
  // src/principle-sync.ts
60121
60265
  init_src5();
@@ -60143,8 +60287,8 @@ init_reconcile();
60143
60287
 
60144
60288
  // src/lockfile-auto.ts
60145
60289
  init_src();
60146
- import { existsSync as existsSync25, readFileSync as readFileSync24 } from "node:fs";
60147
- import { join as join29 } from "node:path";
60290
+ import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
60291
+ import { join as join30 } from "node:path";
60148
60292
 
60149
60293
  // src/package-index.ts
60150
60294
  init_src();
@@ -60293,11 +60437,11 @@ function runLockfilePass(opts) {
60293
60437
  { file: "package-lock.json", parse: parsePackageLockJson }
60294
60438
  ];
60295
60439
  for (const c of candidates) {
60296
- const p = join29(opts.root, c.file);
60297
- if (!existsSync25(p)) continue;
60440
+ const p = join30(opts.root, c.file);
60441
+ if (!existsSync26(p)) continue;
60298
60442
  let sbom;
60299
60443
  try {
60300
- sbom = c.parse(readFileSync24(p, "utf8"));
60444
+ sbom = c.parse(readFileSync25(p, "utf8"));
60301
60445
  } catch {
60302
60446
  continue;
60303
60447
  }
@@ -60354,8 +60498,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
60354
60498
  }
60355
60499
 
60356
60500
  // src/public-symbols.ts
60357
- import { readFileSync as readFileSync25, readdirSync as readdirSync11, existsSync as existsSync26 } from "node:fs";
60358
- import { join as join30 } from "node:path";
60501
+ import { readFileSync as readFileSync26, readdirSync as readdirSync11, existsSync as existsSync27 } from "node:fs";
60502
+ import { join as join31 } from "node:path";
60359
60503
  var HEAD_BYTES = 8 * 1024;
60360
60504
  var INDEX_TTL_MS = 10 * 60 * 1e3;
60361
60505
  var MIN_SYMBOL_LEN = 4;
@@ -60388,20 +60532,20 @@ function bindingNames(clause) {
60388
60532
  function internalPackageNames(workspaceRoot) {
60389
60533
  const names = /* @__PURE__ */ new Set();
60390
60534
  const tryRead = (dir) => {
60391
- const pj = join30(dir, "package.json");
60392
- if (!existsSync26(pj)) return;
60535
+ const pj = join31(dir, "package.json");
60536
+ if (!existsSync27(pj)) return;
60393
60537
  try {
60394
- const name2 = JSON.parse(readFileSync25(pj, "utf8")).name;
60538
+ const name2 = JSON.parse(readFileSync26(pj, "utf8")).name;
60395
60539
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
60396
60540
  } catch {
60397
60541
  }
60398
60542
  };
60399
60543
  tryRead(workspaceRoot);
60400
60544
  for (const group of ["packages", "apps"]) {
60401
- const groupDir = join30(workspaceRoot, group);
60402
- if (!existsSync26(groupDir)) continue;
60545
+ const groupDir = join31(workspaceRoot, group);
60546
+ if (!existsSync27(groupDir)) continue;
60403
60547
  try {
60404
- for (const entry of readdirSync11(groupDir)) tryRead(join30(groupDir, entry));
60548
+ for (const entry of readdirSync11(groupDir)) tryRead(join31(groupDir, entry));
60405
60549
  } catch {
60406
60550
  }
60407
60551
  }
@@ -60414,7 +60558,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
60414
60558
  if (cached2 && now - cached2.builtAt < INDEX_TTL_MS) return cached2;
60415
60559
  const readHead = deps.readHead ?? ((absPath) => {
60416
60560
  try {
60417
- return readFileSync25(absPath, "utf8").slice(0, HEAD_BYTES);
60561
+ return readFileSync26(absPath, "utf8").slice(0, HEAD_BYTES);
60418
60562
  } catch {
60419
60563
  return "";
60420
60564
  }
@@ -60434,7 +60578,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
60434
60578
  }
60435
60579
  const symbols = /* @__PURE__ */ new Set();
60436
60580
  for (const rel of files) {
60437
- const head2 = readHead(join30(workspaceRoot, rel));
60581
+ const head2 = readHead(join31(workspaceRoot, rel));
60438
60582
  if (!head2) continue;
60439
60583
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
60440
60584
  re.lastIndex = 0;
@@ -60966,8 +61110,8 @@ var ConsolidateWorker = class {
60966
61110
  const id = this.nextId++;
60967
61111
  try {
60968
61112
  await this.ready;
60969
- return await new Promise((resolve6, reject) => {
60970
- this.pending.set(id, { resolve: resolve6, reject });
61113
+ return await new Promise((resolve7, reject) => {
61114
+ this.pending.set(id, { resolve: resolve7, reject });
60971
61115
  this.worker.postMessage({ ...req, id });
60972
61116
  });
60973
61117
  } finally {
@@ -60996,12 +61140,12 @@ var ConsolidateWorker = class {
60996
61140
  });
60997
61141
  noteIsolateSpawned();
60998
61142
  this.worker = worker;
60999
- this.ready = new Promise((resolve6, reject) => {
61143
+ this.ready = new Promise((resolve7, reject) => {
61000
61144
  const onReady = (m) => {
61001
61145
  if (m?.ready) {
61002
61146
  worker.off("message", onReady);
61003
61147
  worker.off("error", onErr);
61004
- resolve6();
61148
+ resolve7();
61005
61149
  }
61006
61150
  };
61007
61151
  const onErr = (err2) => {
@@ -61046,7 +61190,7 @@ var ConsolidateWorker = class {
61046
61190
  init_paths();
61047
61191
 
61048
61192
  // src/lock.ts
61049
- import { existsSync as existsSync27, readFileSync as readFileSync26 } from "node:fs";
61193
+ import { existsSync as existsSync28, readFileSync as readFileSync27 } from "node:fs";
61050
61194
  function isProcessAlive(pid) {
61051
61195
  if (!pid || pid <= 0) return false;
61052
61196
  try {
@@ -61057,9 +61201,9 @@ function isProcessAlive(pid) {
61057
61201
  }
61058
61202
  }
61059
61203
  function readDaemonLock(lockPath) {
61060
- if (!existsSync27(lockPath)) return null;
61204
+ if (!existsSync28(lockPath)) return null;
61061
61205
  try {
61062
- const lock = JSON.parse(readFileSync26(lockPath, "utf8"));
61206
+ const lock = JSON.parse(readFileSync27(lockPath, "utf8"));
61063
61207
  return typeof lock.pid === "number" ? lock : null;
61064
61208
  } catch {
61065
61209
  return null;
@@ -61187,13 +61331,13 @@ function startUpdatePoller(opts) {
61187
61331
  };
61188
61332
  }
61189
61333
  function runNpmInstall(channel) {
61190
- return new Promise((resolve6) => {
61334
+ return new Promise((resolve7) => {
61191
61335
  const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
61192
61336
  stdio: "inherit",
61193
61337
  shell: true
61194
61338
  });
61195
- child.on("close", (code) => resolve6(code ?? 1));
61196
- child.on("error", () => resolve6(1));
61339
+ child.on("close", (code) => resolve7(code ?? 1));
61340
+ child.on("error", () => resolve7(1));
61197
61341
  });
61198
61342
  }
61199
61343
 
@@ -61347,13 +61491,14 @@ async function reanchorProject(opts) {
61347
61491
  init_registry();
61348
61492
 
61349
61493
  // src/adopt.ts
61350
- import { existsSync as existsSync28 } from "node:fs";
61351
- import { dirname as dirname10, join as join31 } from "node:path";
61494
+ init_git_remote();
61495
+ import { existsSync as existsSync29 } from "node:fs";
61496
+ import { dirname as dirname11, join as join32 } from "node:path";
61352
61497
  function findGitRoot(absPath) {
61353
61498
  let dir = absPath;
61354
61499
  for (let depth = 0; depth < 64; depth++) {
61355
- if (existsSync28(join31(dir, ".git"))) return dir;
61356
- const parent = dirname10(dir);
61500
+ if (existsSync29(join32(dir, ".git"))) return dir;
61501
+ const parent = dirname11(dir);
61357
61502
  if (parent === dir) return null;
61358
61503
  dir = parent;
61359
61504
  }
@@ -61871,10 +62016,6 @@ async function startMultiDaemon(opts = {}) {
61871
62016
  }
61872
62017
  records.push(rec);
61873
62018
  void ambientLinkAll();
61874
- if (!mountedIds.has(rec.id)) {
61875
- mountedIds.add(rec.id);
61876
- app.route(`/ws/${rec.id}`, rec.webApp);
61877
- }
61878
62019
  try {
61879
62020
  writeFileSync22(
61880
62021
  rec.engine.paths.daemonLock,
@@ -61964,11 +62105,13 @@ async function startMultiDaemon(opts = {}) {
61964
62105
  }
61965
62106
  return hit?.count ?? -1;
61966
62107
  };
62108
+ let lastHook = null;
61967
62109
  app.get(
61968
62110
  "/health",
61969
62111
  (c) => c.json({
61970
62112
  ok: true,
61971
62113
  daemonVersion: DAEMON_VERSION,
62114
+ lastHook,
61972
62115
  // What the daemon is DOING, not just what it holds. Without these a
61973
62116
  // pegged daemon is only diagnosable by attaching a CPU profiler to the
61974
62117
  // live process — see watch-census.ts for the incident that proved it.
@@ -61999,6 +62142,7 @@ async function startMultiDaemon(opts = {}) {
61999
62142
  } catch {
62000
62143
  return c.json({ error: "bad-json" }, 400);
62001
62144
  }
62145
+ lastHook = { at: Date.now(), event: typeof body2["hook_event_name"] === "string" ? body2["hook_event_name"] : c.req.path };
62002
62146
  let owner = ownerOf(records, pathInBody(body2));
62003
62147
  if (!owner) {
62004
62148
  const missPath = pathInBody(body2);
@@ -62053,6 +62197,18 @@ async function startMultiDaemon(opts = {}) {
62053
62197
  mountedIds.add(r.id);
62054
62198
  app.route(`/ws/${r.id}`, r.webApp);
62055
62199
  }
62200
+ const dispatchHot = async (c) => {
62201
+ const id = c.req.param("id");
62202
+ const rec = records.find((r) => r.id === id);
62203
+ if (!rec) return c.notFound();
62204
+ const url2 = new URL(c.req.url);
62205
+ url2.pathname = url2.pathname.slice(`/ws/${id}`.length) || "/";
62206
+ const method = c.req.method;
62207
+ const body2 = method === "GET" || method === "HEAD" ? void 0 : await c.req.raw.arrayBuffer();
62208
+ return rec.webApp.fetch(new Request(url2.toString(), { method, headers: c.req.raw.headers, body: body2 }));
62209
+ };
62210
+ app.all("/ws/:id", dispatchHot);
62211
+ app.all("/ws/:id/*", dispatchHot);
62056
62212
  const retireWorkspace = async (rec, reason) => {
62057
62213
  const idx = records.indexOf(rec);
62058
62214
  if (idx === -1) return;
@@ -62074,7 +62230,7 @@ async function startMultiDaemon(opts = {}) {
62074
62230
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
62075
62231
  } catch {
62076
62232
  }
62077
- const reason = retireDecision({ exists: existsSync29(rec.root), lastActiveAt, now });
62233
+ const reason = retireDecision({ exists: existsSync30(rec.root), lastActiveAt, now });
62078
62234
  if (reason) void retireWorkspace(rec, reason);
62079
62235
  }
62080
62236
  };
@@ -62236,7 +62392,7 @@ async function startMultiDaemon(opts = {}) {
62236
62392
  const packageAutoAll = async () => {
62237
62393
  const out2 = /* @__PURE__ */ new Map();
62238
62394
  for (const r of records) {
62239
- await new Promise((resolve6) => setImmediate(resolve6));
62395
+ await new Promise((resolve7) => setImmediate(resolve7));
62240
62396
  const done = markPass(`package-index:${r.entry.name}`);
62241
62397
  try {
62242
62398
  out2.set(
@@ -62830,7 +62986,7 @@ async function startMultiDaemon(opts = {}) {
62830
62986
  clearInterval(codexWake);
62831
62987
  clearTimeout(codexWakeBoot);
62832
62988
  try {
62833
- const cur = readFileSync27(lockPath, "utf8");
62989
+ const cur = readFileSync28(lockPath, "utf8");
62834
62990
  if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
62835
62991
  } catch {
62836
62992
  }
@@ -62878,6 +63034,7 @@ async function startMultiDaemon(opts = {}) {
62878
63034
 
62879
63035
  // src/cli.ts
62880
63036
  init_src5();
63037
+ init_git_remote();
62881
63038
  init_config();
62882
63039
  init_src7();
62883
63040
  init_cloud_auth();
@@ -63037,7 +63194,7 @@ async function loginOAuthDevice(opts) {
63037
63194
  let deviceSession = null;
63038
63195
  let approvedInstallation = null;
63039
63196
  while (Date.now() < deadline) {
63040
- await (opts.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms))))(intervalMs);
63197
+ await (opts.sleep ?? ((ms) => new Promise((resolve7) => setTimeout(resolve7, ms))))(intervalMs);
63041
63198
  const poll = await fetchFn(device.token, {
63042
63199
  method: "POST",
63043
63200
  headers: { "content-type": "application/json", accept: "application/json" },
@@ -63141,7 +63298,7 @@ async function loginOAuthLoopback(opts) {
63141
63298
  const state = randomState();
63142
63299
  const scope = opts.scope ?? DEFAULT_OAUTH_SCOPE;
63143
63300
  const { code, redirectUri, clientId } = await new Promise(
63144
- (resolve6, reject) => {
63301
+ (resolve7, reject) => {
63145
63302
  const server = createServer((req, res) => {
63146
63303
  const u = new URL(req.url ?? "/", "http://127.0.0.1");
63147
63304
  if (u.pathname !== "/callback") {
@@ -63164,7 +63321,7 @@ async function loginOAuthLoopback(opts) {
63164
63321
  res.writeHead(200, { "content-type": "text/html" });
63165
63322
  res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
63166
63323
  server.close();
63167
- resolve6({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
63324
+ resolve7({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
63168
63325
  });
63169
63326
  let activeClientId = oauthClientId();
63170
63327
  server.on("error", reject);
@@ -63405,6 +63562,7 @@ function openInBrowser(url2) {
63405
63562
 
63406
63563
  // src/cli.ts
63407
63564
  init_paths();
63565
+ init_checkout_root();
63408
63566
 
63409
63567
  // src/cli-args.ts
63410
63568
  var BURST_VALUE_FLAGS = /* @__PURE__ */ new Set(["--limit", "--hops", "--max-hops"]);
@@ -63824,7 +63982,7 @@ var exitCleanOnEpipe = (err2) => {
63824
63982
  };
63825
63983
  process.stdout.on("error", exitCleanOnEpipe);
63826
63984
  process.stderr.on("error", exitCleanOnEpipe);
63827
- var ROOT = process.cwd();
63985
+ var ROOT = checkoutRootOf(process.cwd());
63828
63986
  var argv = process.argv.slice(2);
63829
63987
  var cmd = argv[0] ?? "help";
63830
63988
  var rest = argv.slice(1);
@@ -64081,21 +64239,21 @@ async function cmdInit() {
64081
64239
  if (!skipHooks) {
64082
64240
  console.log("");
64083
64241
  console.log("installing harness hooks...");
64084
- const { existsSync: existsSync31 } = await import("node:fs");
64085
- const { join: join33 } = await import("node:path");
64242
+ const { existsSync: existsSync32 } = await import("node:fs");
64243
+ const { join: join34 } = await import("node:path");
64086
64244
  try {
64087
64245
  await installClaudeHooks(port);
64088
64246
  } catch (err2) {
64089
64247
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
64090
64248
  }
64091
- if (existsSync31(join33(ROOT, ".cursor"))) {
64249
+ if (existsSync32(join34(ROOT, ".cursor"))) {
64092
64250
  try {
64093
64251
  await installCursorMcpConfig();
64094
64252
  } catch (err2) {
64095
64253
  console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
64096
64254
  }
64097
64255
  }
64098
- if (existsSync31(join33(ROOT, ".codex"))) {
64256
+ if (existsSync32(join34(ROOT, ".codex"))) {
64099
64257
  try {
64100
64258
  await installCodexHooks(port);
64101
64259
  } catch (err2) {
@@ -64272,9 +64430,9 @@ async function cmdStatus() {
64272
64430
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
64273
64431
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
64274
64432
  }
64275
- console.log(` graph db: ${existsSync30(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
64276
- console.log(` event log: ${existsSync30(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
64277
- if (existsSync30(paths.castalia)) {
64433
+ console.log(` graph db: ${existsSync31(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
64434
+ console.log(` event log: ${existsSync31(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
64435
+ if (existsSync31(paths.castalia)) {
64278
64436
  try {
64279
64437
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
64280
64438
  const store = openGraphStore2({ path: paths.castalia });
@@ -64336,6 +64494,15 @@ async function cmdStatus() {
64336
64494
  const line = watchCensusLine(h.watch);
64337
64495
  if (line) console.log(` watcher: ${line}`);
64338
64496
  }
64497
+ if (h.lastHook !== void 0) {
64498
+ if (h.lastHook === null) {
64499
+ console.log(` hooks: none received since the daemon started`);
64500
+ } else {
64501
+ const min = Math.round((Date.now() - h.lastHook.at) / 6e4);
64502
+ const ago2 = min < 1 ? "just now" : min < 60 ? `${min}m ago` : `${Math.floor(min / 60)}h ${min % 60}m ago`;
64503
+ console.log(` hooks: last received ${ago2} (${h.lastHook.event})`);
64504
+ }
64505
+ }
64339
64506
  }
64340
64507
  } catch {
64341
64508
  }
@@ -65068,11 +65235,11 @@ function cmdInstallationProfile(args2) {
65068
65235
  }
65069
65236
  async function cmdReview() {
65070
65237
  const paths = workspacePaths(ROOT);
65071
- if (!existsSync30(paths.reviewQueue)) {
65238
+ if (!existsSync31(paths.reviewQueue)) {
65072
65239
  console.log("(review queue empty)");
65073
65240
  return;
65074
65241
  }
65075
- const queue = JSON.parse(readFileSync28(paths.reviewQueue, "utf8"));
65242
+ const queue = JSON.parse(readFileSync29(paths.reviewQueue, "utf8"));
65076
65243
  if (queue.length === 0) {
65077
65244
  console.log("(review queue empty)");
65078
65245
  return;
@@ -65743,7 +65910,7 @@ async function gatherRepo(store, ws) {
65743
65910
  };
65744
65911
  }
65745
65912
  async function gatherReportData(generatedAt) {
65746
- const { existsSync: existsSync31 } = await import("node:fs");
65913
+ const { existsSync: existsSync32 } = await import("node:fs");
65747
65914
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
65748
65915
  const cfg = loadConfig();
65749
65916
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -65751,7 +65918,7 @@ async function gatherReportData(generatedAt) {
65751
65918
  for (const ws of listWorkspaces()) {
65752
65919
  if (ws.missing) continue;
65753
65920
  const dbPath = workspacePaths(ws.path).castalia;
65754
- if (!existsSync31(dbPath)) continue;
65921
+ if (!existsSync32(dbPath)) continue;
65755
65922
  let store = null;
65756
65923
  try {
65757
65924
  store = openGraphStore2({ path: dbPath });
@@ -65795,8 +65962,8 @@ async function cmdReport(args2) {
65795
65962
  const outDir = workspacePaths(ROOT).configDir;
65796
65963
  mkdirSync9(outDir, { recursive: true });
65797
65964
  const files = renderReport2(data, { includeFutureVerbs });
65798
- for (const f of files) writeFileSync23(join32(outDir, f.name), f.html, "utf8");
65799
- const indexPath = join32(outDir, "report.html");
65965
+ for (const f of files) writeFileSync23(join33(outDir, f.name), f.html, "utf8");
65966
+ const indexPath = join33(outDir, "report.html");
65800
65967
  console.log(`report \u2192 ${indexPath}`);
65801
65968
  console.log(
65802
65969
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -65916,24 +66083,24 @@ async function cmdInstallHooks(args2) {
65916
66083
  }
65917
66084
  }
65918
66085
  async function installOpencodePlugin(port) {
65919
- const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
65920
- const { join: join33 } = await import("node:path");
65921
- const dir = join33(ROOT, ".opencode", "plugin");
65922
- if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
65923
- const file2 = join33(dir, "inerrata.js");
65924
- if (existsSync31(file2)) {
65925
- const head2 = readFileSync29(file2, "utf8").split("\n")[0] ?? "";
66086
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66087
+ const { join: join34 } = await import("node:path");
66088
+ const dir = join34(ROOT, ".opencode", "plugin");
66089
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66090
+ const file2 = join34(dir, "inerrata.js");
66091
+ if (existsSync32(file2)) {
66092
+ const head2 = readFileSync30(file2, "utf8").split("\n")[0] ?? "";
65926
66093
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
65927
66094
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
65928
66095
  process.exit(2);
65929
66096
  }
65930
66097
  }
65931
66098
  writeFileSync23(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
65932
- const cfgFile = join33(ROOT, "opencode.json");
66099
+ const cfgFile = join34(ROOT, "opencode.json");
65933
66100
  let cfg = { $schema: "https://opencode.ai/config.json" };
65934
- if (existsSync31(cfgFile)) {
66101
+ if (existsSync32(cfgFile)) {
65935
66102
  try {
65936
- cfg = JSON.parse(readFileSync29(cfgFile, "utf8"));
66103
+ cfg = JSON.parse(readFileSync30(cfgFile, "utf8"));
65937
66104
  } catch {
65938
66105
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
65939
66106
  process.exit(2);
@@ -65964,15 +66131,15 @@ function errataMcpInvocation() {
65964
66131
  return { command: cmd2, args: args2 };
65965
66132
  }
65966
66133
  async function installClaudeHooks(port) {
65967
- const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
65968
- const { join: join33 } = await import("node:path");
65969
- const dir = join33(ROOT, ".claude");
65970
- if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
65971
- const file2 = join33(dir, "settings.json");
66134
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66135
+ const { join: join34 } = await import("node:path");
66136
+ const dir = join34(ROOT, ".claude");
66137
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66138
+ const file2 = join34(dir, "settings.json");
65972
66139
  let settings = {};
65973
- if (existsSync31(file2)) {
66140
+ if (existsSync32(file2)) {
65974
66141
  try {
65975
- settings = JSON.parse(readFileSync29(file2, "utf8"));
66142
+ settings = JSON.parse(readFileSync30(file2, "utf8"));
65976
66143
  } catch {
65977
66144
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
65978
66145
  process.exit(2);
@@ -66021,7 +66188,7 @@ async function installClaudeHooks(port) {
66021
66188
  writeFileSync23(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
66022
66189
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
66023
66190
  await installClaudeMcpConfig();
66024
- const claudeMd = join33(ROOT, "CLAUDE.md");
66191
+ const claudeMd = join34(ROOT, "CLAUDE.md");
66025
66192
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
66026
66193
  if (recall.kind === "collision") {
66027
66194
  console.warn(
@@ -66033,15 +66200,15 @@ async function installClaudeHooks(port) {
66033
66200
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
66034
66201
  }
66035
66202
  async function installClaudeMcpConfig() {
66036
- const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
66037
- const { join: join33, dirname: dirname11 } = await import("node:path");
66038
- const file2 = join33(ROOT, ".mcp.json");
66039
- const dir = dirname11(file2);
66040
- if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
66203
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66204
+ const { join: join34, dirname: dirname12 } = await import("node:path");
66205
+ const file2 = join34(ROOT, ".mcp.json");
66206
+ const dir = dirname12(file2);
66207
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66041
66208
  let cfg = {};
66042
- if (existsSync31(file2)) {
66209
+ if (existsSync32(file2)) {
66043
66210
  try {
66044
- cfg = JSON.parse(readFileSync29(file2, "utf8"));
66211
+ cfg = JSON.parse(readFileSync30(file2, "utf8"));
66045
66212
  } catch {
66046
66213
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
66047
66214
  process.exit(2);
@@ -66055,15 +66222,15 @@ async function installClaudeMcpConfig() {
66055
66222
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
66056
66223
  }
66057
66224
  async function installCursorMcpConfig() {
66058
- const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
66059
- const { join: join33 } = await import("node:path");
66060
- const dir = join33(ROOT, ".cursor");
66061
- if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
66062
- const file2 = join33(dir, "mcp.json");
66225
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66226
+ const { join: join34 } = await import("node:path");
66227
+ const dir = join34(ROOT, ".cursor");
66228
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66229
+ const file2 = join34(dir, "mcp.json");
66063
66230
  let cfg = {};
66064
- if (existsSync31(file2)) {
66231
+ if (existsSync32(file2)) {
66065
66232
  try {
66066
- cfg = JSON.parse(readFileSync29(file2, "utf8"));
66233
+ cfg = JSON.parse(readFileSync30(file2, "utf8"));
66067
66234
  } catch {
66068
66235
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
66069
66236
  process.exit(2);
@@ -66079,14 +66246,14 @@ async function installCursorMcpConfig() {
66079
66246
  console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
66080
66247
  }
66081
66248
  async function installCodexHooks(port) {
66082
- const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
66083
- const { join: join33 } = await import("node:path");
66084
- const dir = join33(ROOT, ".codex");
66085
- if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
66086
- const file2 = join33(dir, "config.toml");
66249
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66250
+ const { join: join34 } = await import("node:path");
66251
+ const dir = join34(ROOT, ".codex");
66252
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66253
+ const file2 = join34(dir, "config.toml");
66087
66254
  let existing = "";
66088
- if (existsSync31(file2)) {
66089
- existing = readFileSync29(file2, "utf8");
66255
+ if (existsSync32(file2)) {
66256
+ existing = readFileSync30(file2, "utf8");
66090
66257
  const beginIdx = existing.indexOf(CODEX_HOOKS_BEGIN);
66091
66258
  const endIdx = existing.indexOf(CODEX_HOOKS_END);
66092
66259
  if (beginIdx >= 0 && endIdx > beginIdx) {
@@ -66363,7 +66530,7 @@ async function cmdDash(args2) {
66363
66530
  const hotspotScanMark = /* @__PURE__ */ new Map();
66364
66531
  const HOTSPOT_FANIN = 20;
66365
66532
  const runNightlyPass = async (dueIds) => {
66366
- const yieldToLoop2 = () => new Promise((resolve6) => setImmediate(resolve6));
66533
+ const yieldToLoop2 = () => new Promise((resolve7) => setImmediate(resolve7));
66367
66534
  const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
66368
66535
  const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
66369
66536
  let skillsLearned = 0;
@@ -66441,7 +66608,7 @@ async function cmdDash(args2) {
66441
66608
  await yieldToLoop2();
66442
66609
  try {
66443
66610
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile);
66444
- const res = bleedRules(join32(r.root, ".claude", "rules"), items);
66611
+ const res = bleedRules(join33(r.root, ".claude", "rules"), items);
66445
66612
  if (res.written || res.pruned) {
66446
66613
  console.log(
66447
66614
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")