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

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 +505 -433
  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();
@@ -25280,8 +25280,8 @@ var init_config = __esm({
25280
25280
  "use strict";
25281
25281
  init_paths();
25282
25282
  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";
25283
+ DEFAULT_CLOUD_URL = true ? "https://dev.inerrata.dev" : DEV_CLOUD_URL;
25284
+ DEFAULT_UPDATE_CHANNEL = false ? "latest" : "dev";
25285
25285
  }
25286
25286
  });
25287
25287
 
@@ -28165,17 +28165,117 @@ var init_identity2 = __esm({
28165
28165
  }
28166
28166
  });
28167
28167
 
28168
+ // src/git-remote.ts
28169
+ import { existsSync as existsSync8, readFileSync as readFileSync6, statSync } from "node:fs";
28170
+ import { isAbsolute, join as join6, resolve } from "node:path";
28171
+ function resolveGitDir(root) {
28172
+ const dotGit = join6(root, ".git");
28173
+ try {
28174
+ const st = statSync(dotGit);
28175
+ if (st.isDirectory()) return dotGit;
28176
+ const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync6(dotGit, "utf8"));
28177
+ if (!m) return null;
28178
+ const dir = m[1];
28179
+ return isAbsolute(dir) ? dir : resolve(root, dir);
28180
+ } catch {
28181
+ return null;
28182
+ }
28183
+ }
28184
+ function gitConfigPath(gitDir) {
28185
+ const commondirFile = join6(gitDir, "commondir");
28186
+ if (existsSync8(commondirFile)) {
28187
+ const common = readFileSync6(commondirFile, "utf8").trim();
28188
+ const commonDir = isAbsolute(common) ? common : resolve(gitDir, common);
28189
+ return join6(commonDir, "config");
28190
+ }
28191
+ return join6(gitDir, "config");
28192
+ }
28193
+ function readRemotes(root) {
28194
+ const gitDir = resolveGitDir(root);
28195
+ if (!gitDir) return [];
28196
+ const cfgPath = gitConfigPath(gitDir);
28197
+ if (!existsSync8(cfgPath)) return [];
28198
+ let txt;
28199
+ try {
28200
+ txt = readFileSync6(cfgPath, "utf8");
28201
+ } catch {
28202
+ return [];
28203
+ }
28204
+ const out2 = [];
28205
+ const sectionRe = /^\s*\[remote "([^"]+)"\]\s*$([\s\S]*?)(?=^\s*\[|\s*$(?![\s\S]))/gm;
28206
+ for (const m of txt.matchAll(sectionRe)) {
28207
+ const url2 = /^\s*url\s*=\s*(.+?)\s*$/m.exec(m[2])?.[1];
28208
+ if (url2) out2.push({ name: m[1], url: url2 });
28209
+ }
28210
+ return out2;
28211
+ }
28212
+ function detectRepoLocator(root, remote) {
28213
+ const remotes = readRemotes(root);
28214
+ if (remotes.length === 0) return null;
28215
+ const pick2 = remote ? remotes.find((r) => r.name === remote) ?? null : remotes.find((r) => r.name === "origin") ?? (remotes.length === 1 ? remotes[0] : null);
28216
+ return pick2 ? normalizeRepoLocator(pick2.url) : null;
28217
+ }
28218
+ var init_git_remote = __esm({
28219
+ "src/git-remote.ts"() {
28220
+ "use strict";
28221
+ init_src();
28222
+ }
28223
+ });
28224
+
28225
+ // src/checkout-root.ts
28226
+ import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
28227
+ import { basename, dirname as dirname5, isAbsolute as isAbsolute2, join as join7, resolve as resolve2 } from "node:path";
28228
+ function nearestGitRoot(dir) {
28229
+ let cur = resolve2(dir);
28230
+ for (; ; ) {
28231
+ if (existsSync9(join7(cur, ".git"))) return cur;
28232
+ const parent = dirname5(cur);
28233
+ if (parent === cur) return null;
28234
+ cur = parent;
28235
+ }
28236
+ }
28237
+ function mainCheckoutOfWorktree(root) {
28238
+ const gitDir = resolveGitDir(root);
28239
+ if (!gitDir || gitDir === join7(root, ".git")) return null;
28240
+ const commondirFile = join7(gitDir, "commondir");
28241
+ if (!existsSync9(commondirFile)) return null;
28242
+ let common;
28243
+ try {
28244
+ common = readFileSync7(commondirFile, "utf8").trim();
28245
+ } catch {
28246
+ return null;
28247
+ }
28248
+ const commonDir = resolve2(isAbsolute2(common) ? common : resolve2(gitDir, common));
28249
+ if (basename(commonDir) !== ".git") return null;
28250
+ const main2 = dirname5(commonDir);
28251
+ return existsSync9(join7(main2, ".git")) ? main2 : null;
28252
+ }
28253
+ function checkoutRootOf(cwd) {
28254
+ const root = nearestGitRoot(cwd);
28255
+ const main2 = root ? mainCheckoutOfWorktree(root) : null;
28256
+ return main2 ?? resolve2(cwd);
28257
+ }
28258
+ function isLinkedWorktree(root) {
28259
+ return mainCheckoutOfWorktree(root) !== null;
28260
+ }
28261
+ var init_checkout_root = __esm({
28262
+ "src/checkout-root.ts"() {
28263
+ "use strict";
28264
+ init_git_remote();
28265
+ }
28266
+ });
28267
+
28168
28268
  // 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";
28269
+ import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
28270
+ import { join as join8 } from "node:path";
28171
28271
  function registryPath() {
28172
- return process.env["ERRATA_REGISTRY_PATH"] ?? join6(globalDir(), "workspaces.json");
28272
+ return process.env["ERRATA_REGISTRY_PATH"] ?? join8(globalDir(), "workspaces.json");
28173
28273
  }
28174
28274
  function read() {
28175
28275
  const p = registryPath();
28176
- if (!existsSync8(p)) return { version: 1, workspaces: {} };
28276
+ if (!existsSync10(p)) return { version: 1, workspaces: {} };
28177
28277
  try {
28178
- const parsed = JSON.parse(readFileSync6(p, "utf8"));
28278
+ const parsed = JSON.parse(readFileSync8(p, "utf8"));
28179
28279
  return { version: 1, workspaces: parsed.workspaces ?? {} };
28180
28280
  } catch {
28181
28281
  return { version: 1, workspaces: {} };
@@ -28183,9 +28283,9 @@ function read() {
28183
28283
  }
28184
28284
  function registryCorrupt() {
28185
28285
  const p = registryPath();
28186
- if (!existsSync8(p)) return false;
28286
+ if (!existsSync10(p)) return false;
28187
28287
  try {
28188
- JSON.parse(readFileSync6(p, "utf8"));
28288
+ JSON.parse(readFileSync8(p, "utf8"));
28189
28289
  return false;
28190
28290
  } catch {
28191
28291
  return true;
@@ -28196,6 +28296,7 @@ function write(reg) {
28196
28296
  writeFileSync7(registryPath(), JSON.stringify(reg, null, 2), "utf8");
28197
28297
  }
28198
28298
  function registerWorkspace(profile, root, now = Date.now()) {
28299
+ if (isLinkedWorktree(root)) return;
28199
28300
  const reg = read();
28200
28301
  reg.workspaces[profile.id] = {
28201
28302
  ...reg.workspaces[profile.id],
@@ -28234,7 +28335,7 @@ function pruneMissingWorkspaces() {
28234
28335
  const reg = read();
28235
28336
  const removed = [];
28236
28337
  for (const [id, entry] of Object.entries(reg.workspaces)) {
28237
- if (!existsSync8(entry.path)) {
28338
+ if (!existsSync10(entry.path)) {
28238
28339
  removed.push(entry);
28239
28340
  delete reg.workspaces[id];
28240
28341
  }
@@ -28243,13 +28344,13 @@ function pruneMissingWorkspaces() {
28243
28344
  return removed;
28244
28345
  }
28245
28346
  function workspaceStatus(entry) {
28246
- const missing = !existsSync8(entry.path);
28347
+ const missing = !existsSync10(entry.path);
28247
28348
  const lockPath = workspacePaths(entry.path).daemonLock;
28248
28349
  let running = false;
28249
28350
  let webUiUrl = null;
28250
- if (existsSync8(lockPath)) {
28351
+ if (existsSync10(lockPath)) {
28251
28352
  try {
28252
- const lock = JSON.parse(readFileSync6(lockPath, "utf8"));
28353
+ const lock = JSON.parse(readFileSync8(lockPath, "utf8"));
28253
28354
  if (lock.pid && lock.webUiUrl && pidAlive(lock.pid)) {
28254
28355
  running = true;
28255
28356
  webUiUrl = lock.webUiUrl;
@@ -28277,6 +28378,7 @@ var init_registry = __esm({
28277
28378
  "src/registry.ts"() {
28278
28379
  "use strict";
28279
28380
  init_paths();
28381
+ init_checkout_root();
28280
28382
  }
28281
28383
  });
28282
28384
 
@@ -29053,26 +29155,26 @@ function buildFileLexicon(store) {
29053
29155
  for (const n of store.findNodesByLabel("File")) {
29054
29156
  const relPath = typeof n.attrs["relPath"] === "string" && n.attrs["relPath"].length > 0 ? n.attrs["relPath"] : n.description;
29055
29157
  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("."));
29158
+ const basename6 = relPath.split("/").pop();
29159
+ if (!basename6.includes(".")) continue;
29160
+ entries.push({ relPath, basename: basename6 });
29161
+ basenameCount.set(basename6, (basenameCount.get(basename6) ?? 0) + 1);
29162
+ const stem = basename6.slice(0, basename6.indexOf("."));
29061
29163
  if (isBareMatchableStem(stem)) {
29062
29164
  let s = stemRelPaths.get(stem);
29063
29165
  if (!s) stemRelPaths.set(stem, s = /* @__PURE__ */ new Set());
29064
29166
  s.add(relPath);
29065
29167
  }
29066
29168
  }
29067
- for (const { relPath, basename: basename5 } of entries) {
29169
+ for (const { relPath, basename: basename6 } of entries) {
29068
29170
  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);
29171
+ if (relPath !== basename6) byKey.set(relPath, entry);
29172
+ const conventional = CONVENTION_FILENAMES.has(basename6) || (basenameCount.get(basename6) ?? 0) >= CONVENTION_BASENAME_MIN_FILES;
29173
+ if (!conventional && !byKey.has(basename6)) byKey.set(basename6, entry);
29174
+ const list = byBasename.get(basename6);
29073
29175
  if (list) list.push(entry);
29074
- else byBasename.set(basename5, [entry]);
29075
- const stem = basename5.slice(0, basename5.indexOf("."));
29176
+ else byBasename.set(basename6, [entry]);
29177
+ const stem = basename6.slice(0, basename6.indexOf("."));
29076
29178
  if (isBareMatchableStem(stem) && !CONVENTION_STEMS.has(stem) && !byStem.has(stem)) {
29077
29179
  const dirStems = new Set(
29078
29180
  [...stemRelPaths.get(stem) ?? []].map((p) => {
@@ -29089,8 +29191,8 @@ function resolveFileToken(token, lexicon) {
29089
29191
  const exact = lexicon.byKey.get(token);
29090
29192
  if (exact) return exact;
29091
29193
  if (!token.includes("/")) return null;
29092
- const basename5 = token.split("/").pop();
29093
- for (const entry of lexicon.byBasename.get(basename5) ?? []) {
29194
+ const basename6 = token.split("/").pop();
29195
+ for (const entry of lexicon.byBasename.get(basename6) ?? []) {
29094
29196
  if (entry.relPath === token || entry.relPath.endsWith(`/${token}`)) return entry;
29095
29197
  }
29096
29198
  return null;
@@ -29115,9 +29217,9 @@ function fileRolePhrase(relPath, level = 1) {
29115
29217
  return "a source file";
29116
29218
  }
29117
29219
  function isSourceFileToken(token) {
29118
- const basename5 = token.split(/[/\\]/).pop() ?? token;
29119
- if (CONVENTION_FILENAMES.has(basename5)) return false;
29120
- const ext = basename5.split(".").pop();
29220
+ const basename6 = token.split(/[/\\]/).pop() ?? token;
29221
+ if (CONVENTION_FILENAMES.has(basename6)) return false;
29222
+ const ext = basename6.split(".").pop();
29121
29223
  return ext !== void 0 && SOURCE_EXTENSIONS.has(ext.toLowerCase());
29122
29224
  }
29123
29225
  function generalizeFileRefs(text, fileLexicon, level = 1) {
@@ -29702,7 +29804,7 @@ var init_diagnostic_matcher = __esm({
29702
29804
  });
29703
29805
 
29704
29806
  // ../../packages/generalizer/src/generalizer.ts
29705
- import { isAbsolute, join as join7, relative } from "node:path";
29807
+ import { isAbsolute as isAbsolute3, join as join9, relative } from "node:path";
29706
29808
  async function runGeneralizer(opts) {
29707
29809
  const report = {
29708
29810
  eventsProcessed: 0,
@@ -29810,7 +29912,7 @@ function extractDiagnostics(ev) {
29810
29912
  function diagRelPath(file2, cwd, workspaceRoot) {
29811
29913
  const norm = (p) => p.replace(/\\/g, "/");
29812
29914
  if (!workspaceRoot) return norm(file2);
29813
- const abs = isAbsolute(file2) ? file2 : join7(cwd ?? workspaceRoot, file2);
29915
+ const abs = isAbsolute3(file2) ? file2 : join9(cwd ?? workspaceRoot, file2);
29814
29916
  return norm(relative(workspaceRoot, abs));
29815
29917
  }
29816
29918
  function extractErrorSignature(ev) {
@@ -31453,22 +31555,22 @@ var init_src10 = __esm({
31453
31555
 
31454
31556
  // ../../packages/indexer/src/parse-cache.ts
31455
31557
  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";
31558
+ 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
31559
  import { homedir as homedir3 } from "node:os";
31458
- import { join as join8 } from "node:path";
31560
+ import { join as join10 } from "node:path";
31459
31561
  function parseCacheDir() {
31460
- return process.env["ERRATA_PARSE_CACHE"] ?? join8(homedir3(), ".errata", "parse-cache");
31562
+ return process.env["ERRATA_PARSE_CACHE"] ?? join10(homedir3(), ".errata", "parse-cache");
31461
31563
  }
31462
31564
  function parseCacheKey(source, providerId) {
31463
31565
  return createHash3("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
31464
31566
  }
31465
31567
  function entryPath(dir, key) {
31466
- return join8(dir, key.slice(0, 2), `${key.slice(2)}.json`);
31568
+ return join10(dir, key.slice(0, 2), `${key.slice(2)}.json`);
31467
31569
  }
31468
31570
  function readParseCache(dir, key) {
31469
31571
  const file2 = entryPath(dir, key);
31470
31572
  try {
31471
- const raw2 = readFileSync7(file2, "utf8");
31573
+ const raw2 = readFileSync9(file2, "utf8");
31472
31574
  const parsed = JSON.parse(raw2);
31473
31575
  if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
31474
31576
  return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
@@ -31487,7 +31589,7 @@ function writeParseCache(dir, key, providerId, value) {
31487
31589
  const body2 = JSON.stringify(envelope);
31488
31590
  if (body2.length > MAX_ENTRY_BYTES) return;
31489
31591
  const file2 = entryPath(dir, key);
31490
- mkdirSync6(join8(dir, key.slice(0, 2)), { recursive: true });
31592
+ mkdirSync6(join10(dir, key.slice(0, 2)), { recursive: true });
31491
31593
  writeFileSync8(file2, body2);
31492
31594
  } catch {
31493
31595
  }
@@ -31497,9 +31599,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
31497
31599
  sweptThisProcess = true;
31498
31600
  let removed = 0;
31499
31601
  try {
31500
- if (!existsSync9(dir)) return 0;
31602
+ if (!existsSync11(dir)) return 0;
31501
31603
  for (const bucket of readdirSync2(dir)) {
31502
- const bucketDir = join8(dir, bucket);
31604
+ const bucketDir = join10(dir, bucket);
31503
31605
  let names;
31504
31606
  try {
31505
31607
  names = readdirSync2(bucketDir);
@@ -31507,9 +31609,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
31507
31609
  continue;
31508
31610
  }
31509
31611
  for (const name2 of names) {
31510
- const file2 = join8(bucketDir, name2);
31612
+ const file2 = join10(bucketDir, name2);
31511
31613
  try {
31512
- if (now - statSync(file2).mtimeMs > ENTRY_TTL_MS) {
31614
+ if (now - statSync2(file2).mtimeMs > ENTRY_TTL_MS) {
31513
31615
  rmSync2(file2, { force: true });
31514
31616
  removed++;
31515
31617
  }
@@ -31755,9 +31857,9 @@ var init_identity3 = __esm({
31755
31857
  });
31756
31858
 
31757
31859
  // ../../packages/indexer/src/pipeline.ts
31758
- import { appendFileSync, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
31860
+ import { appendFileSync, readFileSync as readFileSync10, statSync as statSync3 } from "node:fs";
31759
31861
  import { readdir } from "node:fs/promises";
31760
- import { extname, join as join9, relative as relative2, sep } from "node:path";
31862
+ import { extname, join as join11, relative as relative2, sep } from "node:path";
31761
31863
  import { createHash as createHash4 } from "node:crypto";
31762
31864
  import { execFileSync } from "node:child_process";
31763
31865
  function nowTs() {
@@ -31895,7 +31997,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31895
31997
  for (const rel of [...changedRelPaths]) {
31896
31998
  let h;
31897
31999
  try {
31898
- h = createHash4("sha256").update(readFileSync8(join9(rootPath, rel))).digest("hex");
32000
+ h = createHash4("sha256").update(readFileSync10(join11(rootPath, rel))).digest("hex");
31899
32001
  } catch {
31900
32002
  continue;
31901
32003
  }
@@ -31944,13 +32046,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31944
32046
  let parsedFiles = 0;
31945
32047
  for (const rel of changedRelPaths) {
31946
32048
  if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
31947
- const abs = join9(rootPath, ...rel.split("/"));
32049
+ const abs = join11(rootPath, ...rel.split("/"));
31948
32050
  const ext = extname(abs).toLowerCase();
31949
32051
  const provider = providers.find((p) => p.fileExtensions.includes(ext));
31950
32052
  if (!provider) continue;
31951
32053
  let symbols;
31952
32054
  try {
31953
- symbols = provider.extractSymbols(readFileSync8(abs, "utf8"), abs);
32055
+ symbols = provider.extractSymbols(readFileSync10(abs, "utf8"), abs);
31954
32056
  } catch {
31955
32057
  continue;
31956
32058
  }
@@ -32265,12 +32367,12 @@ async function runIndexer(store, opts) {
32265
32367
  }
32266
32368
  let source;
32267
32369
  try {
32268
- const st = statSync2(f.absPath);
32370
+ const st = statSync3(f.absPath);
32269
32371
  if (st.size > maxBytes) {
32270
32372
  report.filesSkipped++;
32271
32373
  continue;
32272
32374
  }
32273
- source = readFileSync8(f.absPath, "utf8");
32375
+ source = readFileSync10(f.absPath, "utf8");
32274
32376
  } catch {
32275
32377
  report.filesSkipped++;
32276
32378
  continue;
@@ -32342,7 +32444,7 @@ async function runIndexer(store, opts) {
32342
32444
  const depth = fileNode.relPath.split("/").length;
32343
32445
  if (depth !== 3) continue;
32344
32446
  try {
32345
- const pkg = JSON.parse(readFileSync8(fileNode.absPath, "utf8"));
32447
+ const pkg = JSON.parse(readFileSync10(fileNode.absPath, "utf8"));
32346
32448
  if (!pkg.name) continue;
32347
32449
  const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
32348
32450
  const candidates = [
@@ -32730,7 +32832,7 @@ async function scan(root, current, ignores, providers, out2) {
32730
32832
  for (const ent of entries) {
32731
32833
  if (ignores.has(ent.name)) continue;
32732
32834
  if (ent.name.startsWith(".") && ent.name !== ".") continue;
32733
- const abs = join9(current, ent.name);
32835
+ const abs = join11(current, ent.name);
32734
32836
  if (ent.isDirectory()) {
32735
32837
  await scan(root, abs, ignores, providers, out2);
32736
32838
  } else if (ent.isFile()) {
@@ -32739,7 +32841,7 @@ async function scan(root, current, ignores, providers, out2) {
32739
32841
  const rel = relative2(root, abs).split(sep).join("/");
32740
32842
  let size = 0;
32741
32843
  try {
32742
- size = statSync2(abs).size;
32844
+ size = statSync3(abs).size;
32743
32845
  } catch {
32744
32846
  continue;
32745
32847
  }
@@ -32785,10 +32887,10 @@ function gitListFiles(root, ignores, providers) {
32785
32887
  if (rels === null) return null;
32786
32888
  const out2 = [];
32787
32889
  for (const rel of rels) {
32788
- const abs = join9(root, rel);
32890
+ const abs = join11(root, rel);
32789
32891
  let size;
32790
32892
  try {
32791
- size = statSync2(abs).size;
32893
+ size = statSync3(abs).size;
32792
32894
  } catch {
32793
32895
  continue;
32794
32896
  }
@@ -32808,7 +32910,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
32808
32910
  const now = nowTs();
32809
32911
  let contentHash;
32810
32912
  try {
32811
- contentHash = createHash4("sha256").update(readFileSync8(f.absPath)).digest("hex");
32913
+ contentHash = createHash4("sha256").update(readFileSync10(f.absPath)).digest("hex");
32812
32914
  } catch {
32813
32915
  }
32814
32916
  const node2 = {
@@ -33412,13 +33514,13 @@ async function Module2(moduleArg = {}) {
33412
33514
  }
33413
33515
  readAsync = /* @__PURE__ */ __name(async (url2) => {
33414
33516
  if (isFileURI(url2)) {
33415
- return new Promise((resolve6, reject) => {
33517
+ return new Promise((resolve7, reject) => {
33416
33518
  var xhr = new XMLHttpRequest();
33417
33519
  xhr.open("GET", url2, true);
33418
33520
  xhr.responseType = "arraybuffer";
33419
33521
  xhr.onload = () => {
33420
33522
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
33421
- resolve6(xhr.response);
33523
+ resolve7(xhr.response);
33422
33524
  return;
33423
33525
  }
33424
33526
  reject(xhr.status);
@@ -33614,9 +33716,9 @@ async function Module2(moduleArg = {}) {
33614
33716
  __name(receiveInstantiationResult, "receiveInstantiationResult");
33615
33717
  var info2 = getWasmImports();
33616
33718
  if (Module["instantiateWasm"]) {
33617
- return new Promise((resolve6, reject) => {
33719
+ return new Promise((resolve7, reject) => {
33618
33720
  Module["instantiateWasm"](info2, (mod, inst) => {
33619
- resolve6(receiveInstance(mod, inst));
33721
+ resolve7(receiveInstance(mod, inst));
33620
33722
  });
33621
33723
  });
33622
33724
  }
@@ -34947,8 +35049,8 @@ async function Module2(moduleArg = {}) {
34947
35049
  if (runtimeInitialized) {
34948
35050
  moduleRtn = Module;
34949
35051
  } else {
34950
- moduleRtn = new Promise((resolve6, reject) => {
34951
- readyPromiseResolve = resolve6;
35052
+ moduleRtn = new Promise((resolve7, reject) => {
35053
+ readyPromiseResolve = resolve7;
34952
35054
  readyPromiseReject = reject;
34953
35055
  });
34954
35056
  }
@@ -37178,42 +37280,42 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37178
37280
 
37179
37281
  // ../../packages/indexer/src/languages/tree-sitter-loader.ts
37180
37282
  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";
37283
+ import { dirname as dirname6, join as join12 } from "node:path";
37284
+ import { existsSync as existsSync12, readdirSync as readdirSync3 } from "node:fs";
37183
37285
  import { createRequire as createRequire2 } from "node:module";
37184
37286
  function entryDir() {
37185
37287
  try {
37186
37288
  const url2 = import.meta?.url;
37187
37289
  if (typeof url2 === "string" && url2.length > 0) {
37188
- return dirname5(fileURLToPath(url2));
37290
+ return dirname6(fileURLToPath(url2));
37189
37291
  }
37190
37292
  } catch {
37191
37293
  }
37192
- return dirname5(process.execPath);
37294
+ return dirname6(process.execPath);
37193
37295
  }
37194
37296
  function findWasmDir() {
37195
37297
  const here = entryDir();
37196
- const seaWasm = join10(here, "resources", "wasm");
37197
- if (existsSync10(join10(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
37298
+ const seaWasm = join12(here, "resources", "wasm");
37299
+ if (existsSync12(join12(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
37198
37300
  let dir = here;
37199
37301
  for (let i2 = 0; i2 < 6; i2++) {
37200
- const flat = join10(
37302
+ const flat = join12(
37201
37303
  dir,
37202
37304
  "node_modules",
37203
37305
  "@vscode",
37204
37306
  "tree-sitter-wasm",
37205
37307
  "wasm"
37206
37308
  );
37207
- if (existsSync10(join10(flat, "tree-sitter-typescript.wasm"))) return flat;
37208
- dir = dirname5(dir);
37309
+ if (existsSync12(join12(flat, "tree-sitter-typescript.wasm"))) return flat;
37310
+ dir = dirname6(dir);
37209
37311
  }
37210
37312
  let root = here;
37211
37313
  for (let i2 = 0; i2 < 6; i2++) {
37212
- const pnpmDir = join10(root, "node_modules", ".pnpm");
37213
- if (existsSync10(pnpmDir)) {
37314
+ const pnpmDir = join12(root, "node_modules", ".pnpm");
37315
+ if (existsSync12(pnpmDir)) {
37214
37316
  for (const entry of readdirSync3(pnpmDir)) {
37215
37317
  if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
37216
- const candidate = join10(
37318
+ const candidate = join12(
37217
37319
  pnpmDir,
37218
37320
  entry,
37219
37321
  "node_modules",
@@ -37221,13 +37323,13 @@ function findWasmDir() {
37221
37323
  "tree-sitter-wasm",
37222
37324
  "wasm"
37223
37325
  );
37224
- if (existsSync10(join10(candidate, "tree-sitter-typescript.wasm"))) {
37326
+ if (existsSync12(join12(candidate, "tree-sitter-typescript.wasm"))) {
37225
37327
  return candidate;
37226
37328
  }
37227
37329
  }
37228
37330
  }
37229
37331
  }
37230
- root = dirname5(root);
37332
+ root = dirname6(root);
37231
37333
  }
37232
37334
  throw new Error(
37233
37335
  "@vscode/tree-sitter-wasm grammar files not found \u2014 is the package installed?"
@@ -37235,33 +37337,33 @@ function findWasmDir() {
37235
37337
  }
37236
37338
  function findRuntimeDir() {
37237
37339
  const here = entryDir();
37238
- const seaRuntime = join10(here, "resources", "wasm");
37239
- if (existsSync10(join10(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
37340
+ const seaRuntime = join12(here, "resources", "wasm");
37341
+ if (existsSync12(join12(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
37240
37342
  let dir = here;
37241
37343
  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);
37344
+ const flat = join12(dir, "node_modules", "web-tree-sitter");
37345
+ if (existsSync12(join12(flat, "web-tree-sitter.wasm"))) return flat;
37346
+ dir = dirname6(dir);
37245
37347
  }
37246
37348
  let root = here;
37247
37349
  for (let i2 = 0; i2 < 6; i2++) {
37248
- const pnpmDir = join10(root, "node_modules", ".pnpm");
37249
- if (existsSync10(pnpmDir)) {
37350
+ const pnpmDir = join12(root, "node_modules", ".pnpm");
37351
+ if (existsSync12(pnpmDir)) {
37250
37352
  for (const entry of readdirSync3(pnpmDir)) {
37251
37353
  if (entry.startsWith("web-tree-sitter@")) {
37252
- const candidate = join10(
37354
+ const candidate = join12(
37253
37355
  pnpmDir,
37254
37356
  entry,
37255
37357
  "node_modules",
37256
37358
  "web-tree-sitter"
37257
37359
  );
37258
- if (existsSync10(join10(candidate, "web-tree-sitter.wasm"))) {
37360
+ if (existsSync12(join12(candidate, "web-tree-sitter.wasm"))) {
37259
37361
  return candidate;
37260
37362
  }
37261
37363
  }
37262
37364
  }
37263
37365
  }
37264
- root = dirname5(root);
37366
+ root = dirname6(root);
37265
37367
  }
37266
37368
  throw new Error("web-tree-sitter runtime WASM not found");
37267
37369
  }
@@ -37272,7 +37374,7 @@ async function loadWebTreeSitter() {
37272
37374
  void err2;
37273
37375
  }
37274
37376
  const here = entryDir();
37275
- const seaResourceBase = join10(here, "resources", "_resolve.js");
37377
+ const seaResourceBase = join12(here, "resources", "_resolve.js");
37276
37378
  const resourceRequire = createRequire2(seaResourceBase);
37277
37379
  return resourceRequire("web-tree-sitter");
37278
37380
  }
@@ -37287,9 +37389,9 @@ async function ensureTreeSitterReady() {
37287
37389
  await Parser2.init({
37288
37390
  locateFile: (name2) => {
37289
37391
  if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
37290
- return join10(runtime, name2);
37392
+ return join12(runtime, name2);
37291
37393
  }
37292
- return join10(grammars, name2);
37394
+ return join12(grammars, name2);
37293
37395
  }
37294
37396
  });
37295
37397
  })();
@@ -37301,7 +37403,7 @@ async function loadGrammar(name2) {
37301
37403
  if (cached2) return cached2;
37302
37404
  if (!languageClass) throw new Error("tree-sitter not initialized");
37303
37405
  const grammars = findWasmDir();
37304
- const lang = await languageClass.load(join10(grammars, `${name2}.wasm`));
37406
+ const lang = await languageClass.load(join12(grammars, `${name2}.wasm`));
37305
37407
  grammarCache.set(name2, lang);
37306
37408
  return lang;
37307
37409
  }
@@ -40204,8 +40306,8 @@ var init_src11 = __esm({
40204
40306
 
40205
40307
  // src/reconcile.ts
40206
40308
  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";
40309
+ import { readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
40310
+ import { join as join13, relative as relative3, sep as sep2 } from "node:path";
40209
40311
  function indexerWouldScan(rel) {
40210
40312
  for (const seg of rel.split(/[\\/]/)) {
40211
40313
  if (seg.length === 0) continue;
@@ -40228,7 +40330,7 @@ function gitSourceFiles(root) {
40228
40330
  const out2 = [];
40229
40331
  for (const rel of stdout.split("\0")) {
40230
40332
  if (!rel || !SOURCE_RE.test(rel) || !indexerWouldScan(rel)) continue;
40231
- const abs = join11(root, rel);
40333
+ const abs = join13(root, rel);
40232
40334
  if (IGNORED.test(abs)) continue;
40233
40335
  out2.push(abs);
40234
40336
  }
@@ -40243,7 +40345,7 @@ function* walkSource(dir) {
40243
40345
  }
40244
40346
  for (const e of entries) {
40245
40347
  const name2 = String(e.name);
40246
- const full = join11(dir, name2);
40348
+ const full = join13(dir, name2);
40247
40349
  if (IGNORED.test(full)) continue;
40248
40350
  if (!indexerWouldScan(name2)) continue;
40249
40351
  if (e.isDirectory()) yield* walkSource(full);
@@ -40262,7 +40364,7 @@ async function findStaleFiles(store, rootPath, workspaceId2) {
40262
40364
  if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
40263
40365
  let mtimeMs;
40264
40366
  try {
40265
- mtimeMs = statSync3(abs).mtimeMs;
40367
+ mtimeMs = statSync4(abs).mtimeMs;
40266
40368
  } catch {
40267
40369
  continue;
40268
40370
  }
@@ -40393,8 +40495,8 @@ __export(mcp_exports, {
40393
40495
  runTool: () => runTool,
40394
40496
  searchGraph: () => searchGraph
40395
40497
  });
40396
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
40397
- import { resolve } from "node:path";
40498
+ import { existsSync as existsSync13, readFileSync as readFileSync11 } from "node:fs";
40499
+ import { resolve as resolve3 } from "node:path";
40398
40500
  function collectEnrichmentPulls(store, opts = {}) {
40399
40501
  const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
40400
40502
  const byEpisode = /* @__PURE__ */ new Map();
@@ -40430,7 +40532,7 @@ function takeEnrichmentNudge(store) {
40430
40532
  ` + items;
40431
40533
  }
40432
40534
  function takeDiscriminatorNudge(path2) {
40433
- if (!path2 || !existsSync11(path2)) return null;
40535
+ if (!path2 || !existsSync13(path2)) return null;
40434
40536
  let shared;
40435
40537
  try {
40436
40538
  shared = openGraphStore({ path: path2 });
@@ -40560,11 +40662,11 @@ function showNode(store, node2, maxLines) {
40560
40662
  const relPath = ownerFilePath(store, node2);
40561
40663
  if (!relPath) return { found: false, reason: "no file owner for node" };
40562
40664
  const workspaceRoot = process.cwd();
40563
- const absPath = resolve(workspaceRoot, relPath);
40564
- if (!existsSync11(absPath)) {
40665
+ const absPath = resolve3(workspaceRoot, relPath);
40666
+ if (!existsSync13(absPath)) {
40565
40667
  return { found: false, reason: `file not found on disk: ${absPath}` };
40566
40668
  }
40567
- const source = readFileSync9(absPath, "utf8");
40669
+ const source = readFileSync11(absPath, "utf8");
40568
40670
  const attrs = node2.attrs;
40569
40671
  let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
40570
40672
  let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
@@ -40790,7 +40892,7 @@ function buildToolContext(workspaceRoot) {
40790
40892
  const base = { switchInstallationProfile: useInstallationProfile };
40791
40893
  try {
40792
40894
  const cfg = loadConfig();
40793
- const entry = workspaceRoot ? workspaceEntryForPath(resolve(workspaceRoot)) : null;
40895
+ const entry = workspaceRoot ? workspaceEntryForPath(resolve3(workspaceRoot)) : null;
40794
40896
  const identity = resolveWorkspaceIdentity(cfg, entry);
40795
40897
  if (identity.invalid) {
40796
40898
  console.error(`[errata mcp] cloud DISABLED for this workspace: ${identity.reason}`);
@@ -41318,7 +41420,7 @@ var init_mcp = __esm({
41318
41420
  const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
41319
41421
  try {
41320
41422
  const path2 = sharedStorePath();
41321
- if (!existsSync11(path2)) return { found: true, ...local };
41423
+ if (!existsSync13(path2)) return { found: true, ...local };
41322
41424
  const shared = openGraphStore({ path: path2 });
41323
41425
  try {
41324
41426
  if (!shared.getNode(id)) return { found: true, ...local };
@@ -41918,7 +42020,7 @@ var init_mcp = __esm({
41918
42020
  inputSchema: { type: "object", properties: {} },
41919
42021
  handler: () => {
41920
42022
  const path2 = sharedStorePath();
41921
- if (!existsSync11(path2)) return { count: 0, pending: [] };
42023
+ if (!existsSync13(path2)) return { count: 0, pending: [] };
41922
42024
  const shared = openGraphStore({ path: path2 });
41923
42025
  try {
41924
42026
  const pending = pendingAbstractions(shared);
@@ -41946,7 +42048,7 @@ var init_mcp = __esm({
41946
42048
  },
41947
42049
  handler: (args2) => {
41948
42050
  const path2 = sharedStorePath();
41949
- if (!existsSync11(path2)) return { count: 0, pending: [] };
42051
+ if (!existsSync13(path2)) return { count: 0, pending: [] };
41950
42052
  const shared = openGraphStore({ path: path2 });
41951
42053
  try {
41952
42054
  const pending = pendingDiscriminators(shared, {
@@ -41990,7 +42092,7 @@ var init_mcp = __esm({
41990
42092
  },
41991
42093
  handler: (args2) => {
41992
42094
  const path2 = sharedStorePath();
41993
- if (!existsSync11(path2)) return { count: 0, routes: [] };
42095
+ if (!existsSync13(path2)) return { count: 0, routes: [] };
41994
42096
  const shared = openGraphStore({ path: path2 });
41995
42097
  try {
41996
42098
  const result = triageOf(shared, {
@@ -42376,7 +42478,7 @@ __export(vfile_exports, {
42376
42478
  segmentsOf: () => segmentsOf
42377
42479
  });
42378
42480
  import { writeFileSync as writeFileSync9 } from "node:fs";
42379
- import { join as join12, resolve as resolve2, sep as sep3 } from "node:path";
42481
+ import { join as join14, resolve as resolve4, sep as sep3 } from "node:path";
42380
42482
  function segmentsOf(rawPath) {
42381
42483
  let p = rawPath.replace(/\\/g, "/");
42382
42484
  p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
@@ -42450,8 +42552,8 @@ async function renderVFile(rawPath, store, ctx = {}) {
42450
42552
  }
42451
42553
  async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
42452
42554
  const segs = segmentsOf(rawPath);
42453
- const gRoot = join12(workspaceRoot, ".errata", "g");
42454
- const abs = resolve2(gRoot, ...segs.length ? segs : ["index"]);
42555
+ const gRoot = join14(workspaceRoot, ".errata", "g");
42556
+ const abs = resolve4(gRoot, ...segs.length ? segs : ["index"]);
42455
42557
  if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
42456
42558
  throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
42457
42559
  }
@@ -49877,25 +49979,25 @@ var init_tool_index = __esm({
49877
49979
 
49878
49980
  // src/outbox.ts
49879
49981
  import {
49880
- existsSync as existsSync12,
49982
+ existsSync as existsSync14,
49881
49983
  readdirSync as readdirSync5,
49882
- readFileSync as readFileSync10,
49984
+ readFileSync as readFileSync12,
49883
49985
  renameSync,
49884
49986
  unlinkSync,
49885
49987
  writeFileSync as writeFileSync10
49886
49988
  } from "node:fs";
49887
- import { join as join13 } from "node:path";
49989
+ import { join as join15 } from "node:path";
49888
49990
  import { createHash as createHash12 } from "node:crypto";
49889
49991
  function enqueueOutbox(paths, payload) {
49890
49992
  ensureDir(paths.outbox);
49891
49993
  const id = createHash12("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
49892
- const file2 = join13(paths.outbox, `${Date.now()}-${id}.json`);
49994
+ const file2 = join15(paths.outbox, `${Date.now()}-${id}.json`);
49893
49995
  writeFileSync10(file2, JSON.stringify(payload, null, 2), "utf8");
49894
49996
  return file2;
49895
49997
  }
49896
49998
  async function flushOutbox(paths, client, store) {
49897
49999
  ensureDir(paths.outbox);
49898
- const entries = existsSync12(paths.outbox) ? readdirSync5(paths.outbox) : [];
50000
+ const entries = existsSync14(paths.outbox) ? readdirSync5(paths.outbox) : [];
49899
50001
  let uploaded = 0;
49900
50002
  let failed = 0;
49901
50003
  const quarantine = (abs, reason) => {
@@ -49906,10 +50008,10 @@ async function flushOutbox(paths, client, store) {
49906
50008
  }
49907
50009
  };
49908
50010
  for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
49909
- const abs = join13(paths.outbox, f);
50011
+ const abs = join15(paths.outbox, f);
49910
50012
  let payload;
49911
50013
  try {
49912
- payload = JSON.parse(readFileSync10(abs, "utf8"));
50014
+ payload = JSON.parse(readFileSync12(abs, "utf8"));
49913
50015
  } catch {
49914
50016
  failed++;
49915
50017
  quarantine(abs, "unparseable JSON");
@@ -49954,7 +50056,7 @@ async function flushOutbox(paths, client, store) {
49954
50056
  }
49955
50057
  }
49956
50058
  }
49957
- const remainingFiles = existsSync12(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
50059
+ const remainingFiles = existsSync14(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
49958
50060
  return { uploaded, failed, remaining: remainingFiles.length };
49959
50061
  }
49960
50062
  var init_outbox = __esm({
@@ -50663,16 +50765,16 @@ __export(witness_ledger_exports, {
50663
50765
  summarizeWitnessLedger: () => summarizeWitnessLedger,
50664
50766
  witnessLedgerPath: () => witnessLedgerPath
50665
50767
  });
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";
50768
+ import { appendFileSync as appendFileSync3, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync19 } from "node:fs";
50769
+ import { join as join28 } from "node:path";
50668
50770
  function witnessLedgerPath(configDir) {
50669
- return join27(configDir, "witness-ledger.jsonl");
50771
+ return join28(configDir, "witness-ledger.jsonl");
50670
50772
  }
50671
50773
  function appendWitnessLedger(configDir, entry) {
50672
50774
  const path2 = witnessLedgerPath(configDir);
50673
50775
  try {
50674
50776
  appendFileSync3(path2, JSON.stringify(entry) + "\n");
50675
- const lines = readFileSync22(path2, "utf8").split("\n").filter(Boolean);
50777
+ const lines = readFileSync23(path2, "utf8").split("\n").filter(Boolean);
50676
50778
  if (lines.length > LEDGER_MAX_LINES) {
50677
50779
  writeFileSync19(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
50678
50780
  }
@@ -50681,9 +50783,9 @@ function appendWitnessLedger(configDir, entry) {
50681
50783
  }
50682
50784
  function readWitnessLedger(configDir) {
50683
50785
  const path2 = witnessLedgerPath(configDir);
50684
- if (!existsSync22(path2)) return [];
50786
+ if (!existsSync23(path2)) return [];
50685
50787
  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");
50788
+ return readFileSync23(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
50687
50789
  } catch {
50688
50790
  return [];
50689
50791
  }
@@ -51122,12 +51224,12 @@ var init_report_render = __esm({
51122
51224
 
51123
51225
  // src/cli.ts
51124
51226
  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";
51227
+ import { closeSync as closeSync2, existsSync as existsSync31, openSync as openSync2, readFileSync as readFileSync29, renameSync as renameSync4, statSync as statSync7 } from "node:fs";
51228
+ import { join as join33, resolve as pathResolve } from "node:path";
51127
51229
  import { spawn as spawn3 } from "node:child_process";
51128
51230
 
51129
51231
  // src/daemon.ts
51130
- import { existsSync as existsSync24, writeFileSync as writeFileSync21 } from "node:fs";
51232
+ import { existsSync as existsSync25, writeFileSync as writeFileSync21 } from "node:fs";
51131
51233
 
51132
51234
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
51133
51235
  import { createServer as createServerHTTP } from "http";
@@ -51557,7 +51659,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
51557
51659
  });
51558
51660
  if (!chunk) {
51559
51661
  if (i2 === 1) {
51560
- await new Promise((resolve6) => setTimeout(resolve6));
51662
+ await new Promise((resolve7) => setTimeout(resolve7));
51561
51663
  maxReadCount = 3;
51562
51664
  continue;
51563
51665
  }
@@ -51707,8 +51809,8 @@ init_config();
51707
51809
 
51708
51810
  // src/engine.ts
51709
51811
  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";
51812
+ 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";
51813
+ import { join as join29, relative as relative6, sep as sep4 } from "node:path";
51712
51814
 
51713
51815
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
51714
51816
  import { stat as statcb } from "fs";
@@ -51863,10 +51965,10 @@ var ReaddirpStream = class extends Readable2 {
51863
51965
  }
51864
51966
  async _formatEntry(dirent, path2) {
51865
51967
  let entry;
51866
- const basename5 = this._isDirent ? dirent.name : dirent;
51968
+ const basename6 = this._isDirent ? dirent.name : dirent;
51867
51969
  try {
51868
- const fullPath = presolve(pjoin(path2, basename5));
51869
- entry = { path: prelative(this._root, fullPath), fullPath, basename: basename5 };
51970
+ const fullPath = presolve(pjoin(path2, basename6));
51971
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename6 };
51870
51972
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
51871
51973
  } catch (err2) {
51872
51974
  this._onError(err2);
@@ -52405,9 +52507,9 @@ var NodeFsHandler = class {
52405
52507
  _watchWithNodeFs(path2, listener) {
52406
52508
  const opts = this.fsw.options;
52407
52509
  const directory = sysPath.dirname(path2);
52408
- const basename5 = sysPath.basename(path2);
52510
+ const basename6 = sysPath.basename(path2);
52409
52511
  const parent = this.fsw._getWatchedDir(directory);
52410
- parent.add(basename5);
52512
+ parent.add(basename6);
52411
52513
  const absolutePath = sysPath.resolve(path2);
52412
52514
  const options = {
52413
52515
  persistent: opts.persistent
@@ -52417,7 +52519,7 @@ var NodeFsHandler = class {
52417
52519
  let closer;
52418
52520
  if (opts.usePolling) {
52419
52521
  const enableBin = opts.interval !== opts.binaryInterval;
52420
- options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
52522
+ options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
52421
52523
  closer = setFsWatchFileListener(path2, absolutePath, options, {
52422
52524
  listener,
52423
52525
  rawEmitter: this.fsw._emitRaw
@@ -52439,11 +52541,11 @@ var NodeFsHandler = class {
52439
52541
  if (this.fsw.closed) {
52440
52542
  return;
52441
52543
  }
52442
- const dirname11 = sysPath.dirname(file2);
52443
- const basename5 = sysPath.basename(file2);
52444
- const parent = this.fsw._getWatchedDir(dirname11);
52544
+ const dirname12 = sysPath.dirname(file2);
52545
+ const basename6 = sysPath.basename(file2);
52546
+ const parent = this.fsw._getWatchedDir(dirname12);
52445
52547
  let prevStats = stats;
52446
- if (parent.has(basename5))
52548
+ if (parent.has(basename6))
52447
52549
  return;
52448
52550
  const listener = async (path2, newStats) => {
52449
52551
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
@@ -52468,9 +52570,9 @@ var NodeFsHandler = class {
52468
52570
  prevStats = newStats2;
52469
52571
  }
52470
52572
  } catch (error48) {
52471
- this.fsw._remove(dirname11, basename5);
52573
+ this.fsw._remove(dirname12, basename6);
52472
52574
  }
52473
- } else if (parent.has(basename5)) {
52575
+ } else if (parent.has(basename6)) {
52474
52576
  const at = newStats.atimeMs;
52475
52577
  const mt = newStats.mtimeMs;
52476
52578
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -52564,7 +52666,7 @@ var NodeFsHandler = class {
52564
52666
  this._addToNodeFs(path2, initialAdd, wh, depth + 1);
52565
52667
  }
52566
52668
  }).on(EV.ERROR, this._boundHandleError);
52567
- return new Promise((resolve6, reject) => {
52669
+ return new Promise((resolve7, reject) => {
52568
52670
  if (!stream)
52569
52671
  return reject();
52570
52672
  stream.once(STR_END, () => {
@@ -52573,7 +52675,7 @@ var NodeFsHandler = class {
52573
52675
  return;
52574
52676
  }
52575
52677
  const wasThrottled = throttler ? throttler.clear() : false;
52576
- resolve6(void 0);
52678
+ resolve7(void 0);
52577
52679
  previous.getChildren().filter((item) => {
52578
52680
  return item !== directory && !current.has(item);
52579
52681
  }).forEach((item) => {
@@ -53656,8 +53758,8 @@ init_src10();
53656
53758
  init_review2();
53657
53759
 
53658
53760
  // 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";
53761
+ import { closeSync, existsSync as existsSync15, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync, statSync as statSync5 } from "node:fs";
53762
+ import { basename as basename4, dirname as dirname9, join as join18 } from "node:path";
53661
53763
  import { homedir as homedir4 } from "node:os";
53662
53764
  import { createHash as createHash13 } from "node:crypto";
53663
53765
  function readFrom(path2, fromByte, maxBytes) {
@@ -54035,11 +54137,11 @@ function turnsSince(turns, mark) {
54035
54137
  return at >= 0 ? turns.slice(at + 1) : turns;
54036
54138
  }
54037
54139
  function claudeProjectDir(cwd, home = homedir4()) {
54038
- return join16(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
54140
+ return join18(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
54039
54141
  }
54040
54142
  function recentTranscripts(cwd, opts = {}) {
54041
54143
  const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
54042
- if (!existsSync13(dir)) return [];
54144
+ if (!existsSync15(dir)) return [];
54043
54145
  let names;
54044
54146
  try {
54045
54147
  names = readdirSync6(dir);
@@ -54050,23 +54152,23 @@ function recentTranscripts(cwd, opts = {}) {
54050
54152
  const refs = [];
54051
54153
  for (const name2 of names) {
54052
54154
  if (!name2.endsWith(".jsonl")) continue;
54053
- const path2 = join16(dir, name2);
54155
+ const path2 = join18(dir, name2);
54054
54156
  let mtimeMs;
54055
54157
  try {
54056
- mtimeMs = statSync4(path2).mtimeMs;
54158
+ mtimeMs = statSync5(path2).mtimeMs;
54057
54159
  } catch {
54058
54160
  continue;
54059
54161
  }
54060
54162
  if (mtimeMs < since) continue;
54061
- refs.push({ path: path2, sessionId: basename3(name2, ".jsonl"), mtimeMs });
54163
+ refs.push({ path: path2, sessionId: basename4(name2, ".jsonl"), mtimeMs });
54062
54164
  }
54063
54165
  refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
54064
54166
  return opts.limit ? refs.slice(0, opts.limit) : refs;
54065
54167
  }
54066
54168
  function subagentTranscripts(mainTranscriptPath, sessionId) {
54067
54169
  if (!mainTranscriptPath || !sessionId) return [];
54068
- const dir = join16(dirname8(mainTranscriptPath), sessionId, "subagents");
54069
- if (!existsSync13(dir)) return [];
54170
+ const dir = join18(dirname9(mainTranscriptPath), sessionId, "subagents");
54171
+ if (!existsSync15(dir)) return [];
54070
54172
  let names;
54071
54173
  try {
54072
54174
  names = readdirSync6(dir);
@@ -54076,14 +54178,14 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
54076
54178
  const refs = [];
54077
54179
  for (const name2 of names) {
54078
54180
  if (!name2.endsWith(".jsonl")) continue;
54079
- const path2 = join16(dir, name2);
54181
+ const path2 = join18(dir, name2);
54080
54182
  let mtimeMs;
54081
54183
  try {
54082
- mtimeMs = statSync4(path2).mtimeMs;
54184
+ mtimeMs = statSync5(path2).mtimeMs;
54083
54185
  } catch {
54084
54186
  continue;
54085
54187
  }
54086
- refs.push({ path: path2, sessionId: basename3(name2, ".jsonl"), mtimeMs });
54188
+ refs.push({ path: path2, sessionId: basename4(name2, ".jsonl"), mtimeMs });
54087
54189
  }
54088
54190
  refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
54089
54191
  return refs;
@@ -54094,8 +54196,8 @@ function codexSessionRoots(env2 = process.env, home = homedir4()) {
54094
54196
  if (explicit) {
54095
54197
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54096
54198
  }
54097
- if (env2["CODEX_HOME"]) roots.add(join16(env2["CODEX_HOME"], "sessions"));
54098
- roots.add(join16(home, ".codex", "sessions"));
54199
+ if (env2["CODEX_HOME"]) roots.add(join18(env2["CODEX_HOME"], "sessions"));
54200
+ roots.add(join18(home, ".codex", "sessions"));
54099
54201
  return [...roots];
54100
54202
  }
54101
54203
  function readCodexRolloutCwd(path2) {
@@ -54140,7 +54242,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54140
54242
  const limit = opts.limit ?? 25;
54141
54243
  const out2 = [];
54142
54244
  for (const root of codexSessionRoots(opts.env, opts.home)) {
54143
- if (!existsSync13(root)) continue;
54245
+ if (!existsSync15(root)) continue;
54144
54246
  const stack = [{ dir: root, depth: 0 }];
54145
54247
  while (stack.length > 0) {
54146
54248
  const { dir, depth } = stack.pop();
@@ -54151,10 +54253,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54151
54253
  continue;
54152
54254
  }
54153
54255
  for (const name2 of names) {
54154
- const full = join16(dir, name2);
54256
+ const full = join18(dir, name2);
54155
54257
  let st;
54156
54258
  try {
54157
- st = statSync4(full);
54259
+ st = statSync5(full);
54158
54260
  } catch {
54159
54261
  continue;
54160
54262
  }
@@ -54166,7 +54268,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
54166
54268
  if (!name2.startsWith("rollout-") || !name2.endsWith(".jsonl")) continue;
54167
54269
  if (st.mtimeMs < sinceMs) continue;
54168
54270
  if (readCodexRolloutCwd(full) !== cwd) continue;
54169
- out2.push({ path: full, sessionId: `codex:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54271
+ out2.push({ path: full, sessionId: `codex:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54170
54272
  }
54171
54273
  }
54172
54274
  }
@@ -54179,8 +54281,8 @@ function geminiSessionRoots(env2 = process.env, home = homedir4()) {
54179
54281
  if (explicit) {
54180
54282
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54181
54283
  }
54182
- if (env2["GEMINI_CLI_HOME"]) roots.add(join16(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
54183
- roots.add(join16(home, ".gemini", "tmp"));
54284
+ if (env2["GEMINI_CLI_HOME"]) roots.add(join18(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
54285
+ roots.add(join18(home, ".gemini", "tmp"));
54184
54286
  return [...roots];
54185
54287
  }
54186
54288
  function geminiProjectHash(cwd) {
@@ -54220,7 +54322,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54220
54322
  const hashes = geminiHashesFor(cwd);
54221
54323
  const out2 = [];
54222
54324
  for (const root of geminiSessionRoots(opts.env, opts.home)) {
54223
- if (!existsSync13(root)) continue;
54325
+ if (!existsSync15(root)) continue;
54224
54326
  let slugs;
54225
54327
  try {
54226
54328
  slugs = readdirSync6(root);
@@ -54228,7 +54330,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54228
54330
  continue;
54229
54331
  }
54230
54332
  for (const slug2 of slugs) {
54231
- const chats = join16(root, slug2, "chats");
54333
+ const chats = join18(root, slug2, "chats");
54232
54334
  let names;
54233
54335
  try {
54234
54336
  names = readdirSync6(chats);
@@ -54237,17 +54339,17 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
54237
54339
  }
54238
54340
  for (const name2 of names) {
54239
54341
  if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
54240
- const full = join16(chats, name2);
54342
+ const full = join18(chats, name2);
54241
54343
  let st;
54242
54344
  try {
54243
- st = statSync4(full);
54345
+ st = statSync5(full);
54244
54346
  } catch {
54245
54347
  continue;
54246
54348
  }
54247
54349
  if (!st.isFile() || st.mtimeMs < sinceMs) continue;
54248
54350
  const h = readGeminiTranscriptProjectHash(full);
54249
54351
  if (!h || !hashes.has(h)) continue;
54250
- out2.push({ path: full, sessionId: `gemini:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54352
+ out2.push({ path: full, sessionId: `gemini:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54251
54353
  }
54252
54354
  }
54253
54355
  }
@@ -54260,8 +54362,8 @@ function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
54260
54362
  if (explicit) {
54261
54363
  for (const d of explicit.split(":")) if (d.trim()) roots.add(d.trim());
54262
54364
  }
54263
- if (env2["XDG_DATA_HOME"]) roots.add(join16(env2["XDG_DATA_HOME"], "opencode", "errata"));
54264
- roots.add(join16(home, ".local", "share", "opencode", "errata"));
54365
+ if (env2["XDG_DATA_HOME"]) roots.add(join18(env2["XDG_DATA_HOME"], "opencode", "errata"));
54366
+ roots.add(join18(home, ".local", "share", "opencode", "errata"));
54265
54367
  return [...roots];
54266
54368
  }
54267
54369
  function readOpencodeTranscriptDirectory(path2) {
@@ -54294,7 +54396,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
54294
54396
  }
54295
54397
  const out2 = [];
54296
54398
  for (const root of opencodeSessionRoots(opts.env, opts.home)) {
54297
- if (!existsSync13(root)) continue;
54399
+ if (!existsSync15(root)) continue;
54298
54400
  let names;
54299
54401
  try {
54300
54402
  names = readdirSync6(root);
@@ -54303,17 +54405,17 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
54303
54405
  }
54304
54406
  for (const name2 of names) {
54305
54407
  if (!name2.endsWith(".jsonl")) continue;
54306
- const full = join16(root, name2);
54408
+ const full = join18(root, name2);
54307
54409
  let st;
54308
54410
  try {
54309
- st = statSync4(full);
54411
+ st = statSync5(full);
54310
54412
  } catch {
54311
54413
  continue;
54312
54414
  }
54313
54415
  if (!st.isFile() || st.mtimeMs < sinceMs) continue;
54314
54416
  const dir = readOpencodeTranscriptDirectory(full);
54315
54417
  if (!dir || !(want.has(dir) || want.has(dir.replace(/\/+$/, "")))) continue;
54316
- out2.push({ path: full, sessionId: `opencode:${basename3(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54418
+ out2.push({ path: full, sessionId: `opencode:${basename4(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
54317
54419
  }
54318
54420
  }
54319
54421
  out2.sort((a, b) => b.mtimeMs - a.mtimeMs);
@@ -54326,7 +54428,7 @@ init_src2();
54326
54428
  init_agent_signals();
54327
54429
  init_tool_index();
54328
54430
  init_src5();
54329
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "node:fs";
54431
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync11 } from "node:fs";
54330
54432
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
54331
54433
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
54332
54434
  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 +54967,7 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
54865
54967
  }
54866
54968
  function readPrimingHandles(path2) {
54867
54969
  try {
54868
- return JSON.parse(readFileSync11(path2, "utf8"));
54970
+ return JSON.parse(readFileSync13(path2, "utf8"));
54869
54971
  } catch {
54870
54972
  return {};
54871
54973
  }
@@ -55340,8 +55442,8 @@ ${conversation}` }]
55340
55442
  // src/constraint-backfill.ts
55341
55443
  init_src5();
55342
55444
  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";
55445
+ import { existsSync as existsSync16, readFileSync as readFileSync14, readdirSync as readdirSync7, writeFileSync as writeFileSync12 } from "node:fs";
55446
+ import { join as join19 } from "node:path";
55345
55447
  import { homedir as homedir5 } from "node:os";
55346
55448
  var BACKFILL_VERSION = 1;
55347
55449
  var EMPTY = {
@@ -55355,13 +55457,13 @@ var EMPTY = {
55355
55457
  recoverable: 0
55356
55458
  };
55357
55459
  function markerPath(configDir) {
55358
- return join17(configDir, "constraint-backfill.json");
55460
+ return join19(configDir, "constraint-backfill.json");
55359
55461
  }
55360
55462
  function alreadyDone(configDir) {
55361
55463
  const p = markerPath(configDir);
55362
- if (!existsSync14(p)) return false;
55464
+ if (!existsSync16(p)) return false;
55363
55465
  try {
55364
- const raw2 = JSON.parse(readFileSync12(p, "utf8"));
55466
+ const raw2 = JSON.parse(readFileSync14(p, "utf8"));
55365
55467
  return raw2?.version === BACKFILL_VERSION;
55366
55468
  } catch {
55367
55469
  return false;
@@ -55371,7 +55473,7 @@ function replay(root) {
55371
55473
  const statements = /* @__PURE__ */ new Set();
55372
55474
  const citedByFix = /* @__PURE__ */ new Set();
55373
55475
  const dir = claudeProjectDir(root, homedir5());
55374
- if (!existsSync14(dir)) return { statements, citedByFix };
55476
+ if (!existsSync16(dir)) return { statements, citedByFix };
55375
55477
  let names;
55376
55478
  try {
55377
55479
  names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
@@ -55381,7 +55483,7 @@ function replay(root) {
55381
55483
  for (const f of names) {
55382
55484
  let lines;
55383
55485
  try {
55384
- lines = readFileSync12(join17(dir, f), "utf8").split("\n");
55486
+ lines = readFileSync14(join19(dir, f), "utf8").split("\n");
55385
55487
  } catch {
55386
55488
  continue;
55387
55489
  }
@@ -55508,8 +55610,8 @@ function backfillConstraintKind(store, opts) {
55508
55610
  // src/edge-repair.ts
55509
55611
  init_src();
55510
55612
  init_src5();
55511
- import { existsSync as existsSync15, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "node:fs";
55512
- import { join as join18 } from "node:path";
55613
+ import { existsSync as existsSync17, readFileSync as readFileSync15, writeFileSync as writeFileSync13 } from "node:fs";
55614
+ import { join as join20 } from "node:path";
55513
55615
  function citeEdgeId(from, type, to) {
55514
55616
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
55515
55617
  }
@@ -55524,13 +55626,13 @@ var EMPTY2 = {
55524
55626
  byType: {}
55525
55627
  };
55526
55628
  function markerPath2(configDir) {
55527
- return join18(configDir, "edge-repair.json");
55629
+ return join20(configDir, "edge-repair.json");
55528
55630
  }
55529
55631
  function alreadyDone2(configDir) {
55530
55632
  const p = markerPath2(configDir);
55531
- if (!existsSync15(p)) return false;
55633
+ if (!existsSync17(p)) return false;
55532
55634
  try {
55533
- return JSON.parse(readFileSync13(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
55635
+ return JSON.parse(readFileSync15(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
55534
55636
  } catch {
55535
55637
  return false;
55536
55638
  }
@@ -55593,8 +55695,8 @@ function repairInvalidEdges(store, opts) {
55593
55695
  init_reconcile();
55594
55696
 
55595
55697
  // 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";
55698
+ import { appendFileSync as appendFileSync2, existsSync as existsSync18, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
55699
+ import { join as join21 } from "node:path";
55598
55700
 
55599
55701
  // src/isolate-census.ts
55600
55702
  var live = 0;
@@ -55617,7 +55719,7 @@ var PER_KIND_MAX = 100;
55617
55719
  var TRIM_EVERY = 50;
55618
55720
  var appendsSinceTrim = /* @__PURE__ */ new Map();
55619
55721
  function passLedgerPath(configDir) {
55620
- return join19(configDir, "pass-ledger.jsonl");
55722
+ return join21(configDir, "pass-ledger.jsonl");
55621
55723
  }
55622
55724
  function appendPassLedger(configDir, kind, durationMs, counts) {
55623
55725
  const path2 = passLedgerPath(configDir);
@@ -55646,7 +55748,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
55646
55748
  return;
55647
55749
  }
55648
55750
  appendsSinceTrim.set(path2, 0);
55649
- const lines = readFileSync14(path2, "utf8").split("\n").filter(Boolean);
55751
+ const lines = readFileSync16(path2, "utf8").split("\n").filter(Boolean);
55650
55752
  const keptByKind = /* @__PURE__ */ new Map();
55651
55753
  const kept = [];
55652
55754
  for (let i2 = lines.length - 1; i2 >= 0; i2--) {
@@ -55669,9 +55771,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
55669
55771
  }
55670
55772
  function readPassLedger(configDir) {
55671
55773
  const path2 = passLedgerPath(configDir);
55672
- if (!existsSync16(path2)) return [];
55774
+ if (!existsSync18(path2)) return [];
55673
55775
  try {
55674
- return readFileSync14(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
55776
+ return readFileSync16(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
55675
55777
  (e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
55676
55778
  ).map((e) => ({ ...e, counts: e.counts ?? {} }));
55677
55779
  } catch {
@@ -55954,8 +56056,8 @@ var PassWorker = class {
55954
56056
  const id = this.nextId++;
55955
56057
  try {
55956
56058
  await this.ready;
55957
- return await new Promise((resolve6, reject) => {
55958
- this.pending.set(id, { resolve: resolve6, reject });
56059
+ return await new Promise((resolve7, reject) => {
56060
+ this.pending.set(id, { resolve: resolve7, reject });
55959
56061
  this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
55960
56062
  });
55961
56063
  } finally {
@@ -55989,12 +56091,12 @@ var PassWorker = class {
55989
56091
  });
55990
56092
  noteIsolateSpawned();
55991
56093
  this.worker = worker;
55992
- this.ready = new Promise((resolve6, reject) => {
56094
+ this.ready = new Promise((resolve7, reject) => {
55993
56095
  const onReady = (m) => {
55994
56096
  if (m?.ready) {
55995
56097
  worker.off("message", onReady);
55996
56098
  worker.off("error", onErr);
55997
- resolve6();
56099
+ resolve7();
55998
56100
  }
55999
56101
  };
56000
56102
  const onErr = (err2) => reject(err2);
@@ -56039,11 +56141,11 @@ init_outbox();
56039
56141
  init_src9();
56040
56142
  init_src();
56041
56143
  init_src2();
56042
- import { readFileSync as readFileSync15 } from "node:fs";
56043
- import { join as join20 } from "node:path";
56144
+ import { readFileSync as readFileSync17 } from "node:fs";
56145
+ import { join as join22 } from "node:path";
56044
56146
  function loadClaimIgnorePatterns(workspaceRoot) {
56045
56147
  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());
56148
+ 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
56149
  } catch {
56048
56150
  return [];
56049
56151
  }
@@ -56404,22 +56506,22 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
56404
56506
  }
56405
56507
 
56406
56508
  // 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";
56509
+ import { existsSync as existsSync19, readFileSync as readFileSync18, watch as fsWatch } from "node:fs";
56510
+ import { join as join23 } from "node:path";
56409
56511
  function readFirstLine(path2) {
56410
56512
  try {
56411
- return readFileSync16(path2, "utf8").split(/\r?\n/, 1)[0].trim();
56513
+ return readFileSync18(path2, "utf8").split(/\r?\n/, 1)[0].trim();
56412
56514
  } catch {
56413
56515
  return null;
56414
56516
  }
56415
56517
  }
56416
56518
  function readGitRefState(gitDir) {
56417
- const head2 = readFirstLine(join21(gitDir, "HEAD"));
56519
+ const head2 = readFirstLine(join23(gitDir, "HEAD"));
56418
56520
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
56419
56521
  const branch = m ? m[1] : null;
56420
56522
  let sha2 = null;
56421
56523
  if (branch) {
56422
- sha2 = readFirstLine(join21(gitDir, "refs", "heads", branch));
56524
+ sha2 = readFirstLine(join23(gitDir, "refs", "heads", branch));
56423
56525
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
56424
56526
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
56425
56527
  sha2 = head2;
@@ -56427,13 +56529,13 @@ function readGitRefState(gitDir) {
56427
56529
  return {
56428
56530
  branch,
56429
56531
  sha: sha2,
56430
- mergeHeadExists: existsSync17(join21(gitDir, "MERGE_HEAD")),
56431
- origHeadExists: existsSync17(join21(gitDir, "ORIG_HEAD"))
56532
+ mergeHeadExists: existsSync19(join23(gitDir, "MERGE_HEAD")),
56533
+ origHeadExists: existsSync19(join23(gitDir, "ORIG_HEAD"))
56432
56534
  };
56433
56535
  }
56434
56536
  function shaFromPackedRefs(gitDir, ref) {
56435
56537
  try {
56436
- for (const line of readFileSync16(join21(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
56538
+ for (const line of readFileSync18(join23(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
56437
56539
  const [sha2, name2] = line.split(/\s+/);
56438
56540
  if (name2 === ref && sha2) return sha2;
56439
56541
  }
@@ -56467,7 +56569,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56467
56569
  const settle = () => {
56468
56570
  if (timer) clearTimeout(timer);
56469
56571
  timer = setTimeout(() => {
56470
- if (existsSync17(join21(gitDir, "index.lock"))) {
56572
+ if (existsSync19(join23(gitDir, "index.lock"))) {
56471
56573
  settle();
56472
56574
  return;
56473
56575
  }
@@ -56478,7 +56580,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56478
56580
  }, debounceMs);
56479
56581
  };
56480
56582
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
56481
- const p = join21(gitDir, sub);
56583
+ const p = join23(gitDir, sub);
56482
56584
  try {
56483
56585
  watchers.push(fsWatch(p, settle));
56484
56586
  } catch {
@@ -56498,7 +56600,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
56498
56600
  // src/git-delta.ts
56499
56601
  import { execFile } from "node:child_process";
56500
56602
  function git(repoDir, args2) {
56501
- return new Promise((resolve6, reject) => {
56603
+ return new Promise((resolve7, reject) => {
56502
56604
  execFile(
56503
56605
  "git",
56504
56606
  ["-C", repoDir, ...args2],
@@ -56509,7 +56611,7 @@ function git(repoDir, args2) {
56509
56611
  // git-sensor runs on every commit/checkout.
56510
56612
  windowsHide: true
56511
56613
  },
56512
- (err2, stdout) => err2 ? reject(err2) : resolve6(stdout)
56614
+ (err2, stdout) => err2 ? reject(err2) : resolve7(stdout)
56513
56615
  );
56514
56616
  });
56515
56617
  }
@@ -56703,21 +56805,21 @@ var TelemetryRecorder = class {
56703
56805
 
56704
56806
  // src/skills.ts
56705
56807
  import {
56706
- existsSync as existsSync18,
56808
+ existsSync as existsSync20,
56707
56809
  mkdirSync as mkdirSync7,
56708
- readFileSync as readFileSync17,
56810
+ readFileSync as readFileSync19,
56709
56811
  readdirSync as readdirSync8,
56710
56812
  unlinkSync as unlinkSync2,
56711
56813
  writeFileSync as writeFileSync15
56712
56814
  } from "node:fs";
56713
- import { basename as basename4, join as join22 } from "node:path";
56815
+ import { basename as basename5, join as join24 } from "node:path";
56714
56816
  function skillFileName(id) {
56715
56817
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
56716
56818
  }
56717
56819
  function readSkillManifest(manifestPath) {
56718
- if (!existsSync18(manifestPath)) return [];
56820
+ if (!existsSync20(manifestPath)) return [];
56719
56821
  try {
56720
- const parsed = JSON.parse(readFileSync17(manifestPath, "utf8"));
56822
+ const parsed = JSON.parse(readFileSync19(manifestPath, "utf8"));
56721
56823
  return (parsed.skills ?? []).map((s) => ({
56722
56824
  title: s.title ?? "",
56723
56825
  layer: s.layer ?? "technique",
@@ -56741,7 +56843,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56741
56843
  for (const s of res.skills) {
56742
56844
  const fileName = skillFileName(s.id);
56743
56845
  keep.add(fileName);
56744
- writeFileSync15(join22(paths.skillsDir, fileName), s.markdown, "utf8");
56846
+ writeFileSync15(join24(paths.skillsDir, fileName), s.markdown, "utf8");
56745
56847
  rows.push({
56746
56848
  id: s.id,
56747
56849
  title: s.title,
@@ -56754,7 +56856,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56754
56856
  const fileName = skillFileName(p.id);
56755
56857
  if (keep.has(fileName)) continue;
56756
56858
  keep.add(fileName);
56757
- writeFileSync15(join22(paths.skillsDir, fileName), p.markdown, "utf8");
56859
+ writeFileSync15(join24(paths.skillsDir, fileName), p.markdown, "utf8");
56758
56860
  rows.push({
56759
56861
  id: p.id,
56760
56862
  title: p.title,
@@ -56766,9 +56868,9 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56766
56868
  let pruned = 0;
56767
56869
  for (const f of readdirSync8(paths.skillsDir)) {
56768
56870
  if (!f.endsWith(".md")) continue;
56769
- if (keep.has(basename4(f))) continue;
56871
+ if (keep.has(basename5(f))) continue;
56770
56872
  try {
56771
- unlinkSync2(join22(paths.skillsDir, f));
56873
+ unlinkSync2(join24(paths.skillsDir, f));
56772
56874
  pruned++;
56773
56875
  } catch {
56774
56876
  }
@@ -56786,22 +56888,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
56786
56888
  init_src2();
56787
56889
  import {
56788
56890
  cpSync,
56789
- existsSync as existsSync19,
56891
+ existsSync as existsSync21,
56790
56892
  lstatSync,
56791
56893
  mkdirSync as mkdirSync8,
56792
- readFileSync as readFileSync18,
56894
+ readFileSync as readFileSync20,
56793
56895
  readdirSync as readdirSync9,
56794
56896
  rmSync as rmSync3,
56795
56897
  symlinkSync,
56796
56898
  writeFileSync as writeFileSync16
56797
56899
  } from "node:fs";
56798
- import { join as join23 } from "node:path";
56900
+ import { join as join25 } from "node:path";
56799
56901
  var SKILL_NS = "errata-";
56800
56902
  var HARNESS_SKILL_DIRS = [
56801
- { configDir: ".claude", skillsDir: join23(".claude", "skills") },
56903
+ { configDir: ".claude", skillsDir: join25(".claude", "skills") },
56802
56904
  // Cursor adopted the standard; its exact project dir is still moving — kept
56803
56905
  // best-effort and gated on `.cursor/` presence so we never create it blind.
56804
- { configDir: ".cursor", skillsDir: join23(".cursor", "skills") }
56906
+ { configDir: ".cursor", skillsDir: join25(".cursor", "skills") }
56805
56907
  ];
56806
56908
  function skillSlug(title, id) {
56807
56909
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -56846,12 +56948,12 @@ function skillCiteHandle(s) {
56846
56948
  return priorHandle({ id: s.id, description: s.title });
56847
56949
  }
56848
56950
  function reconcileNamespaced(dir, keep) {
56849
- if (!existsSync19(dir)) return 0;
56951
+ if (!existsSync21(dir)) return 0;
56850
56952
  let pruned = 0;
56851
56953
  for (const name2 of readdirSync9(dir)) {
56852
56954
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
56853
56955
  try {
56854
- rmSync3(join23(dir, name2), { recursive: true, force: true });
56956
+ rmSync3(join25(dir, name2), { recursive: true, force: true });
56855
56957
  pruned++;
56856
56958
  } catch {
56857
56959
  }
@@ -56860,7 +56962,7 @@ function reconcileNamespaced(dir, keep) {
56860
56962
  }
56861
56963
  function linkOrCopy(linkPath, target) {
56862
56964
  try {
56863
- if (existsSync19(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
56965
+ if (existsSync21(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
56864
56966
  } catch {
56865
56967
  }
56866
56968
  try {
@@ -56881,7 +56983,7 @@ function safeLstat(p) {
56881
56983
  }
56882
56984
  }
56883
56985
  function emitAndProjectSkills(root, skills) {
56884
- const agentsSkillsDir = join23(root, ".agents", "skills");
56986
+ const agentsSkillsDir = join25(root, ".agents", "skills");
56885
56987
  mkdirSync8(agentsSkillsDir, { recursive: true });
56886
56988
  const slugs = [];
56887
56989
  const keep = /* @__PURE__ */ new Set();
@@ -56889,7 +56991,7 @@ function emitAndProjectSkills(root, skills) {
56889
56991
  for (const s of skills) {
56890
56992
  let body2;
56891
56993
  try {
56892
- body2 = readFileSync18(s.bodyPath, "utf8");
56994
+ body2 = readFileSync20(s.bodyPath, "utf8");
56893
56995
  } catch {
56894
56996
  continue;
56895
56997
  }
@@ -56898,9 +57000,9 @@ function emitAndProjectSkills(root, skills) {
56898
57000
  keep.add(slug2);
56899
57001
  slugs.push(slug2);
56900
57002
  const description = deriveDescription(s.title, s.layer, body2);
56901
- mkdirSync8(join23(agentsSkillsDir, slug2), { recursive: true });
57003
+ mkdirSync8(join25(agentsSkillsDir, slug2), { recursive: true });
56902
57004
  writeFileSync16(
56903
- join23(agentsSkillsDir, slug2, "SKILL.md"),
57005
+ join25(agentsSkillsDir, slug2, "SKILL.md"),
56904
57006
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
56905
57007
  "utf8"
56906
57008
  );
@@ -56909,11 +57011,11 @@ function emitAndProjectSkills(root, skills) {
56909
57011
  reconcileNamespaced(agentsSkillsDir, keep);
56910
57012
  let projected = 0;
56911
57013
  for (const h of HARNESS_SKILL_DIRS) {
56912
- if (!existsSync19(join23(root, h.configDir))) continue;
56913
- const dir = join23(root, h.skillsDir);
57014
+ if (!existsSync21(join25(root, h.configDir))) continue;
57015
+ const dir = join25(root, h.skillsDir);
56914
57016
  mkdirSync8(dir, { recursive: true });
56915
57017
  for (const slug2 of slugs) {
56916
- linkOrCopy(join23(dir, slug2), join23(agentsSkillsDir, slug2));
57018
+ linkOrCopy(join25(dir, slug2), join25(agentsSkillsDir, slug2));
56917
57019
  projected++;
56918
57020
  }
56919
57021
  reconcileNamespaced(dir, keep);
@@ -56922,15 +57024,15 @@ function emitAndProjectSkills(root, skills) {
56922
57024
  return { slugs, emitted, projected };
56923
57025
  }
56924
57026
  function emitInputsFromManifest(erretaDir, manifestPath) {
56925
- if (!existsSync19(manifestPath)) return [];
57027
+ if (!existsSync21(manifestPath)) return [];
56926
57028
  try {
56927
- const parsed = JSON.parse(readFileSync18(manifestPath, "utf8"));
57029
+ const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
56928
57030
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
56929
57031
  id: s.id,
56930
57032
  title: s.title ?? s.id,
56931
57033
  layer: s.layer ?? "technique",
56932
57034
  confidence: s.confidence ?? 0,
56933
- bodyPath: join23(erretaDir, s.file)
57035
+ bodyPath: join25(erretaDir, s.file)
56934
57036
  }));
56935
57037
  } catch {
56936
57038
  return [];
@@ -56944,10 +57046,10 @@ var GITIGNORE_LINES = [
56944
57046
  ".cursor/skills/errata-*/"
56945
57047
  ];
56946
57048
  function ensureSkillGitignore(root) {
56947
- const path2 = join23(root, ".gitignore");
57049
+ const path2 = join25(root, ".gitignore");
56948
57050
  let current = "";
56949
57051
  try {
56950
- current = existsSync19(path2) ? readFileSync18(path2, "utf8") : "";
57052
+ current = existsSync21(path2) ? readFileSync20(path2, "utf8") : "";
56951
57053
  } catch {
56952
57054
  return;
56953
57055
  }
@@ -57051,63 +57153,10 @@ init_paths();
57051
57153
  // src/profile.ts
57052
57154
  init_src2();
57053
57155
  init_paths();
57054
- import { existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync17 } from "node:fs";
57156
+ init_git_remote();
57157
+ import { existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
57055
57158
  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
57159
+ import { join as join26 } from "node:path";
57111
57160
  function workspaceId(root) {
57112
57161
  return "wp_" + createHash14("sha256").update(root).digest("hex").slice(0, 12);
57113
57162
  }
@@ -57130,8 +57179,8 @@ function refreshRepoLocator(root, profile) {
57130
57179
  }
57131
57180
  function loadProfile(root) {
57132
57181
  const p = workspacePaths(root);
57133
- if (!existsSync21(p.workspaceJson)) return null;
57134
- return JSON.parse(readFileSync20(p.workspaceJson, "utf8"));
57182
+ if (!existsSync22(p.workspaceJson)) return null;
57183
+ return JSON.parse(readFileSync21(p.workspaceJson, "utf8"));
57135
57184
  }
57136
57185
  function saveProfile(root, profile) {
57137
57186
  const p = workspacePaths(root);
@@ -57144,10 +57193,10 @@ function autodetectProfile(root) {
57144
57193
  const p = emptyProfile(id, name2);
57145
57194
  const locator = detectRepoLocator(root);
57146
57195
  if (locator) p.repoLocator = locator;
57147
- const pkgPath = join25(root, "package.json");
57148
- if (existsSync21(pkgPath)) {
57196
+ const pkgPath = join26(root, "package.json");
57197
+ if (existsSync22(pkgPath)) {
57149
57198
  try {
57150
- const pkg = JSON.parse(readFileSync20(pkgPath, "utf8"));
57199
+ const pkg = JSON.parse(readFileSync21(pkgPath, "utf8"));
57151
57200
  p.languages.push("typescript", "javascript");
57152
57201
  const nodeVer = pkg.engines?.node ?? "node";
57153
57202
  p.stack.push(`node@${nodeVer}`);
@@ -57168,10 +57217,10 @@ function autodetectProfile(root) {
57168
57217
  } catch {
57169
57218
  }
57170
57219
  }
57171
- const pyproject = join25(root, "pyproject.toml");
57172
- if (existsSync21(pyproject)) {
57220
+ const pyproject = join26(root, "pyproject.toml");
57221
+ if (existsSync22(pyproject)) {
57173
57222
  try {
57174
- const txt = readFileSync20(pyproject, "utf8");
57223
+ const txt = readFileSync21(pyproject, "utf8");
57175
57224
  const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
57176
57225
  p.languages.push("python");
57177
57226
  p.stack.push(`python@${py ?? "3"}`);
@@ -57182,16 +57231,16 @@ function autodetectProfile(root) {
57182
57231
  } catch {
57183
57232
  }
57184
57233
  }
57185
- const reqs = join25(root, "requirements.txt");
57186
- if (existsSync21(reqs)) {
57234
+ const reqs = join26(root, "requirements.txt");
57235
+ if (existsSync22(reqs)) {
57187
57236
  if (!p.languages.includes("python")) p.languages.push("python");
57188
57237
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
57189
57238
  }
57190
- if (existsSync21(join25(root, "go.mod"))) {
57239
+ if (existsSync22(join26(root, "go.mod"))) {
57191
57240
  p.languages.push("go");
57192
57241
  p.stack.push("go");
57193
57242
  }
57194
- if (existsSync21(join25(root, "Cargo.toml"))) {
57243
+ if (existsSync22(join26(root, "Cargo.toml"))) {
57195
57244
  p.languages.push("rust");
57196
57245
  p.stack.push("rust");
57197
57246
  }
@@ -57201,18 +57250,18 @@ function autodetectProfile(root) {
57201
57250
  }
57202
57251
 
57203
57252
  // 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";
57253
+ import { readFileSync as readFileSync22, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
57254
+ import { dirname as dirname10, join as join27 } from "node:path";
57206
57255
  var WITNESS_QUEUE_CAP = 500;
57207
57256
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
57208
57257
  var WITNESS_MAX_ATTEMPTS = 5;
57209
57258
  function witnessQueuePath(workspaceConfigDir) {
57210
- return join26(workspaceConfigDir, "witness-queue.json");
57259
+ return join27(workspaceConfigDir, "witness-queue.json");
57211
57260
  }
57212
57261
  function loadWitnessQueueWithLosses(path2) {
57213
57262
  let raw2;
57214
57263
  try {
57215
- raw2 = JSON.parse(readFileSync21(path2, "utf8"));
57264
+ raw2 = JSON.parse(readFileSync22(path2, "utf8"));
57216
57265
  } catch (err2) {
57217
57266
  const absent = err2?.code === "ENOENT";
57218
57267
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -57225,7 +57274,7 @@ function loadWitnessQueueWithLosses(path2) {
57225
57274
  }
57226
57275
  function saveWitnessQueue(path2, queue) {
57227
57276
  try {
57228
- const tmp = join26(dirname9(path2), `.${Date.now()}.witness-queue.tmp`);
57277
+ const tmp = join27(dirname10(path2), `.${Date.now()}.witness-queue.tmp`);
57229
57278
  writeFileSync18(tmp, JSON.stringify(queue), "utf8");
57230
57279
  renameSync2(tmp, path2);
57231
57280
  } catch {
@@ -57799,7 +57848,7 @@ function createWatchBreaker(deps) {
57799
57848
  }
57800
57849
 
57801
57850
  // src/engine.ts
57802
- var DAEMON_VERSION = true ? "2.0.4" : "2.0.0-alpha.0";
57851
+ var DAEMON_VERSION = true ? "2.0.5-dev.1833" : "2.0.0-alpha.0";
57803
57852
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
57804
57853
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
57805
57854
  var GIT_OP_MUTE_MS = 4e3;
@@ -57810,7 +57859,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
57810
57859
  function appendIdentityAudit(path2, record2, line) {
57811
57860
  if (!record2.accepted && record2.score <= 0) return;
57812
57861
  try {
57813
- if (existsSync23(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
57862
+ if (existsSync24(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
57814
57863
  renameSync3(path2, `${path2}.1`);
57815
57864
  }
57816
57865
  appendFileSync4(path2, line);
@@ -57820,7 +57869,7 @@ function appendIdentityAudit(path2, record2, line) {
57820
57869
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
57821
57870
  function loadTurnCursors(path2) {
57822
57871
  try {
57823
- const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
57872
+ const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
57824
57873
  return new Map(
57825
57874
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
57826
57875
  );
@@ -57830,7 +57879,7 @@ function loadTurnCursors(path2) {
57830
57879
  }
57831
57880
  function loadTurnOffsets(path2) {
57832
57881
  try {
57833
- const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
57882
+ const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
57834
57883
  const out2 = /* @__PURE__ */ new Map();
57835
57884
  for (const [k, v] of Object.entries(raw2)) {
57836
57885
  const off = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -57868,7 +57917,7 @@ function gitSourceWatchTargets(root) {
57868
57917
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
57869
57918
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
57870
57919
  );
57871
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join28(root, d) + sep4));
57920
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join29(root, d) + sep4));
57872
57921
  } catch {
57873
57922
  }
57874
57923
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -57880,19 +57929,19 @@ function gitSourceWatchTargets(root) {
57880
57929
  if (!f.startsWith(prefix)) continue;
57881
57930
  const rest2 = f.slice(prefix.length);
57882
57931
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
57883
- else targets.add(join28(root, f));
57932
+ else targets.add(join29(root, f));
57884
57933
  }
57885
57934
  for (const c of children) {
57886
- if (IGNORED_PATH.test(join28(root, c) + sep4)) continue;
57935
+ if (IGNORED_PATH.test(join29(root, c) + sep4)) continue;
57887
57936
  if (hasIgnoredChild(c)) addUnder(c);
57888
- else targets.add(join28(root, c));
57937
+ else targets.add(join29(root, c));
57889
57938
  }
57890
57939
  };
57891
57940
  addUnder("");
57892
57941
  if (targets.size > 0) return [...targets];
57893
57942
  } catch {
57894
57943
  }
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)));
57944
+ 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
57945
  }
57897
57946
  function createWorkspaceEngine(opts) {
57898
57947
  const paths = workspacePaths(opts.workspaceRoot);
@@ -58085,7 +58134,7 @@ function createWorkspaceEngine(opts) {
58085
58134
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
58086
58135
  let episodeId2;
58087
58136
  if (srcPaths.length > 0) {
58088
- const abs = srcPaths.map((p) => join28(opts.workspaceRoot, p));
58137
+ const abs = srcPaths.map((p) => join29(opts.workspaceRoot, p));
58089
58138
  try {
58090
58139
  const r = await runReindexPass(
58091
58140
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -58121,8 +58170,8 @@ function createWorkspaceEngine(opts) {
58121
58170
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
58122
58171
  );
58123
58172
  };
58124
- const gitDir = join28(opts.workspaceRoot, ".git");
58125
- if (existsSync23(gitDir)) {
58173
+ const gitDir = join29(opts.workspaceRoot, ".git");
58174
+ if (existsSync24(gitDir)) {
58126
58175
  stopGit = startGitSensor(gitDir, (ev) => {
58127
58176
  void handleGitEvent(ev).catch((err2) => {
58128
58177
  console.warn("[errata] git event handler failed:", err2);
@@ -58303,10 +58352,10 @@ function createWorkspaceEngine(opts) {
58303
58352
  console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
58304
58353
  }
58305
58354
  writeContextFile(opts.workspaceRoot, body2);
58306
- const target = join28(opts.workspaceRoot, "AGENTS.md");
58355
+ const target = join29(opts.workspaceRoot, "AGENTS.md");
58307
58356
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
58308
58357
  if (elicit) {
58309
- writePrimingHandles(join28(paths.configDir, "priming-handles.json"), [
58358
+ writePrimingHandles(join29(paths.configDir, "priming-handles.json"), [
58310
58359
  ...snapshot.recentProblems.map((r) => r.node),
58311
58360
  // Resolved-band handles: the ✓ problem AND its Solution are citable
58312
58361
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -58607,7 +58656,7 @@ function createWorkspaceEngine(opts) {
58607
58656
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
58608
58657
  });
58609
58658
  };
58610
- const turnCursorPath = join28(paths.configDir, "turn-cursors.json");
58659
+ const turnCursorPath = join29(paths.configDir, "turn-cursors.json");
58611
58660
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
58612
58661
  const turnOffset = loadTurnOffsets(turnCursorPath);
58613
58662
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -58662,7 +58711,7 @@ function createWorkspaceEngine(opts) {
58662
58711
  let processedTurns = 0;
58663
58712
  const seqAtStart = store.currentIngestSeq();
58664
58713
  const elicit = isEdgeElicitationEnabled();
58665
- const handleMap = elicit ? readPrimingHandles(join28(paths.configDir, "priming-handles.json")) : {};
58714
+ const handleMap = elicit ? readPrimingHandles(join29(paths.configDir, "priming-handles.json")) : {};
58666
58715
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
58667
58716
  const toRel = (abs) => {
58668
58717
  const p = abs.replace(/\\/g, "/");
@@ -59463,7 +59512,7 @@ function createWorkspaceEngine(opts) {
59463
59512
  }
59464
59513
  turns = next.turns;
59465
59514
  nextOffset = next.nextOffset;
59466
- await new Promise((resolve6) => setImmediate(resolve6));
59515
+ await new Promise((resolve7) => setImmediate(resolve7));
59467
59516
  }
59468
59517
  };
59469
59518
  const seenMessageIds = /* @__PURE__ */ new Set();
@@ -59666,7 +59715,7 @@ B: ${b}`,
59666
59715
  try {
59667
59716
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
59668
59717
  emitAndProjectSkills(opts.workspaceRoot, inputs);
59669
- writePrimingHandles(join28(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
59718
+ writePrimingHandles(join29(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
59670
59719
  } catch (err2) {
59671
59720
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
59672
59721
  }
@@ -59959,7 +60008,7 @@ B: ${b}`,
59959
60008
  console.log(
59960
60009
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
59961
60010
  );
59962
- const pending = existsSync23(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
60011
+ const pending = existsSync24(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
59963
60012
  return { uploaded: 0, failed: 0, remaining: pending };
59964
60013
  }
59965
60014
  try {
@@ -60093,7 +60142,7 @@ async function startDaemon(opts) {
60093
60142
  );
60094
60143
  await engine.stop();
60095
60144
  try {
60096
- if (existsSync24(engine.paths.daemonLock)) {
60145
+ if (existsSync25(engine.paths.daemonLock)) {
60097
60146
  }
60098
60147
  } catch {
60099
60148
  }
@@ -60101,9 +60150,9 @@ async function startDaemon(opts) {
60101
60150
  };
60102
60151
  }
60103
60152
  async function listenServer(fetchFn, port) {
60104
- return new Promise((resolve6) => {
60153
+ return new Promise((resolve7) => {
60105
60154
  const server = serve({ fetch: fetchFn, hostname: "127.0.0.1", port }, (info2) => {
60106
- resolve6({ server, port: info2.port });
60155
+ resolve7({ server, port: info2.port });
60107
60156
  });
60108
60157
  });
60109
60158
  }
@@ -60115,7 +60164,7 @@ init_identity2();
60115
60164
  // src/multi.ts
60116
60165
  init_dist();
60117
60166
  init_src5();
60118
- import { existsSync as existsSync29, readFileSync as readFileSync27, unlinkSync as unlinkSync3, writeFileSync as writeFileSync22 } from "node:fs";
60167
+ import { existsSync as existsSync30, readFileSync as readFileSync28, unlinkSync as unlinkSync3, writeFileSync as writeFileSync22 } from "node:fs";
60119
60168
 
60120
60169
  // src/principle-sync.ts
60121
60170
  init_src5();
@@ -60143,8 +60192,8 @@ init_reconcile();
60143
60192
 
60144
60193
  // src/lockfile-auto.ts
60145
60194
  init_src();
60146
- import { existsSync as existsSync25, readFileSync as readFileSync24 } from "node:fs";
60147
- import { join as join29 } from "node:path";
60195
+ import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
60196
+ import { join as join30 } from "node:path";
60148
60197
 
60149
60198
  // src/package-index.ts
60150
60199
  init_src();
@@ -60293,11 +60342,11 @@ function runLockfilePass(opts) {
60293
60342
  { file: "package-lock.json", parse: parsePackageLockJson }
60294
60343
  ];
60295
60344
  for (const c of candidates) {
60296
- const p = join29(opts.root, c.file);
60297
- if (!existsSync25(p)) continue;
60345
+ const p = join30(opts.root, c.file);
60346
+ if (!existsSync26(p)) continue;
60298
60347
  let sbom;
60299
60348
  try {
60300
- sbom = c.parse(readFileSync24(p, "utf8"));
60349
+ sbom = c.parse(readFileSync25(p, "utf8"));
60301
60350
  } catch {
60302
60351
  continue;
60303
60352
  }
@@ -60354,8 +60403,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
60354
60403
  }
60355
60404
 
60356
60405
  // 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";
60406
+ import { readFileSync as readFileSync26, readdirSync as readdirSync11, existsSync as existsSync27 } from "node:fs";
60407
+ import { join as join31 } from "node:path";
60359
60408
  var HEAD_BYTES = 8 * 1024;
60360
60409
  var INDEX_TTL_MS = 10 * 60 * 1e3;
60361
60410
  var MIN_SYMBOL_LEN = 4;
@@ -60388,20 +60437,20 @@ function bindingNames(clause) {
60388
60437
  function internalPackageNames(workspaceRoot) {
60389
60438
  const names = /* @__PURE__ */ new Set();
60390
60439
  const tryRead = (dir) => {
60391
- const pj = join30(dir, "package.json");
60392
- if (!existsSync26(pj)) return;
60440
+ const pj = join31(dir, "package.json");
60441
+ if (!existsSync27(pj)) return;
60393
60442
  try {
60394
- const name2 = JSON.parse(readFileSync25(pj, "utf8")).name;
60443
+ const name2 = JSON.parse(readFileSync26(pj, "utf8")).name;
60395
60444
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
60396
60445
  } catch {
60397
60446
  }
60398
60447
  };
60399
60448
  tryRead(workspaceRoot);
60400
60449
  for (const group of ["packages", "apps"]) {
60401
- const groupDir = join30(workspaceRoot, group);
60402
- if (!existsSync26(groupDir)) continue;
60450
+ const groupDir = join31(workspaceRoot, group);
60451
+ if (!existsSync27(groupDir)) continue;
60403
60452
  try {
60404
- for (const entry of readdirSync11(groupDir)) tryRead(join30(groupDir, entry));
60453
+ for (const entry of readdirSync11(groupDir)) tryRead(join31(groupDir, entry));
60405
60454
  } catch {
60406
60455
  }
60407
60456
  }
@@ -60414,7 +60463,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
60414
60463
  if (cached2 && now - cached2.builtAt < INDEX_TTL_MS) return cached2;
60415
60464
  const readHead = deps.readHead ?? ((absPath) => {
60416
60465
  try {
60417
- return readFileSync25(absPath, "utf8").slice(0, HEAD_BYTES);
60466
+ return readFileSync26(absPath, "utf8").slice(0, HEAD_BYTES);
60418
60467
  } catch {
60419
60468
  return "";
60420
60469
  }
@@ -60434,7 +60483,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
60434
60483
  }
60435
60484
  const symbols = /* @__PURE__ */ new Set();
60436
60485
  for (const rel of files) {
60437
- const head2 = readHead(join30(workspaceRoot, rel));
60486
+ const head2 = readHead(join31(workspaceRoot, rel));
60438
60487
  if (!head2) continue;
60439
60488
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
60440
60489
  re.lastIndex = 0;
@@ -60966,8 +61015,8 @@ var ConsolidateWorker = class {
60966
61015
  const id = this.nextId++;
60967
61016
  try {
60968
61017
  await this.ready;
60969
- return await new Promise((resolve6, reject) => {
60970
- this.pending.set(id, { resolve: resolve6, reject });
61018
+ return await new Promise((resolve7, reject) => {
61019
+ this.pending.set(id, { resolve: resolve7, reject });
60971
61020
  this.worker.postMessage({ ...req, id });
60972
61021
  });
60973
61022
  } finally {
@@ -60996,12 +61045,12 @@ var ConsolidateWorker = class {
60996
61045
  });
60997
61046
  noteIsolateSpawned();
60998
61047
  this.worker = worker;
60999
- this.ready = new Promise((resolve6, reject) => {
61048
+ this.ready = new Promise((resolve7, reject) => {
61000
61049
  const onReady = (m) => {
61001
61050
  if (m?.ready) {
61002
61051
  worker.off("message", onReady);
61003
61052
  worker.off("error", onErr);
61004
- resolve6();
61053
+ resolve7();
61005
61054
  }
61006
61055
  };
61007
61056
  const onErr = (err2) => {
@@ -61046,7 +61095,7 @@ var ConsolidateWorker = class {
61046
61095
  init_paths();
61047
61096
 
61048
61097
  // src/lock.ts
61049
- import { existsSync as existsSync27, readFileSync as readFileSync26 } from "node:fs";
61098
+ import { existsSync as existsSync28, readFileSync as readFileSync27 } from "node:fs";
61050
61099
  function isProcessAlive(pid) {
61051
61100
  if (!pid || pid <= 0) return false;
61052
61101
  try {
@@ -61057,9 +61106,9 @@ function isProcessAlive(pid) {
61057
61106
  }
61058
61107
  }
61059
61108
  function readDaemonLock(lockPath) {
61060
- if (!existsSync27(lockPath)) return null;
61109
+ if (!existsSync28(lockPath)) return null;
61061
61110
  try {
61062
- const lock = JSON.parse(readFileSync26(lockPath, "utf8"));
61111
+ const lock = JSON.parse(readFileSync27(lockPath, "utf8"));
61063
61112
  return typeof lock.pid === "number" ? lock : null;
61064
61113
  } catch {
61065
61114
  return null;
@@ -61187,13 +61236,13 @@ function startUpdatePoller(opts) {
61187
61236
  };
61188
61237
  }
61189
61238
  function runNpmInstall(channel) {
61190
- return new Promise((resolve6) => {
61239
+ return new Promise((resolve7) => {
61191
61240
  const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
61192
61241
  stdio: "inherit",
61193
61242
  shell: true
61194
61243
  });
61195
- child.on("close", (code) => resolve6(code ?? 1));
61196
- child.on("error", () => resolve6(1));
61244
+ child.on("close", (code) => resolve7(code ?? 1));
61245
+ child.on("error", () => resolve7(1));
61197
61246
  });
61198
61247
  }
61199
61248
 
@@ -61347,13 +61396,14 @@ async function reanchorProject(opts) {
61347
61396
  init_registry();
61348
61397
 
61349
61398
  // src/adopt.ts
61350
- import { existsSync as existsSync28 } from "node:fs";
61351
- import { dirname as dirname10, join as join31 } from "node:path";
61399
+ init_git_remote();
61400
+ import { existsSync as existsSync29 } from "node:fs";
61401
+ import { dirname as dirname11, join as join32 } from "node:path";
61352
61402
  function findGitRoot(absPath) {
61353
61403
  let dir = absPath;
61354
61404
  for (let depth = 0; depth < 64; depth++) {
61355
- if (existsSync28(join31(dir, ".git"))) return dir;
61356
- const parent = dirname10(dir);
61405
+ if (existsSync29(join32(dir, ".git"))) return dir;
61406
+ const parent = dirname11(dir);
61357
61407
  if (parent === dir) return null;
61358
61408
  dir = parent;
61359
61409
  }
@@ -61871,10 +61921,6 @@ async function startMultiDaemon(opts = {}) {
61871
61921
  }
61872
61922
  records.push(rec);
61873
61923
  void ambientLinkAll();
61874
- if (!mountedIds.has(rec.id)) {
61875
- mountedIds.add(rec.id);
61876
- app.route(`/ws/${rec.id}`, rec.webApp);
61877
- }
61878
61924
  try {
61879
61925
  writeFileSync22(
61880
61926
  rec.engine.paths.daemonLock,
@@ -61964,11 +62010,13 @@ async function startMultiDaemon(opts = {}) {
61964
62010
  }
61965
62011
  return hit?.count ?? -1;
61966
62012
  };
62013
+ let lastHook = null;
61967
62014
  app.get(
61968
62015
  "/health",
61969
62016
  (c) => c.json({
61970
62017
  ok: true,
61971
62018
  daemonVersion: DAEMON_VERSION,
62019
+ lastHook,
61972
62020
  // What the daemon is DOING, not just what it holds. Without these a
61973
62021
  // pegged daemon is only diagnosable by attaching a CPU profiler to the
61974
62022
  // live process — see watch-census.ts for the incident that proved it.
@@ -61999,6 +62047,7 @@ async function startMultiDaemon(opts = {}) {
61999
62047
  } catch {
62000
62048
  return c.json({ error: "bad-json" }, 400);
62001
62049
  }
62050
+ lastHook = { at: Date.now(), event: typeof body2["hook_event_name"] === "string" ? body2["hook_event_name"] : c.req.path };
62002
62051
  let owner = ownerOf(records, pathInBody(body2));
62003
62052
  if (!owner) {
62004
62053
  const missPath = pathInBody(body2);
@@ -62053,6 +62102,18 @@ async function startMultiDaemon(opts = {}) {
62053
62102
  mountedIds.add(r.id);
62054
62103
  app.route(`/ws/${r.id}`, r.webApp);
62055
62104
  }
62105
+ const dispatchHot = async (c) => {
62106
+ const id = c.req.param("id");
62107
+ const rec = records.find((r) => r.id === id);
62108
+ if (!rec) return c.notFound();
62109
+ const url2 = new URL(c.req.url);
62110
+ url2.pathname = url2.pathname.slice(`/ws/${id}`.length) || "/";
62111
+ const method = c.req.method;
62112
+ const body2 = method === "GET" || method === "HEAD" ? void 0 : await c.req.raw.arrayBuffer();
62113
+ return rec.webApp.fetch(new Request(url2.toString(), { method, headers: c.req.raw.headers, body: body2 }));
62114
+ };
62115
+ app.all("/ws/:id", dispatchHot);
62116
+ app.all("/ws/:id/*", dispatchHot);
62056
62117
  const retireWorkspace = async (rec, reason) => {
62057
62118
  const idx = records.indexOf(rec);
62058
62119
  if (idx === -1) return;
@@ -62074,7 +62135,7 @@ async function startMultiDaemon(opts = {}) {
62074
62135
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
62075
62136
  } catch {
62076
62137
  }
62077
- const reason = retireDecision({ exists: existsSync29(rec.root), lastActiveAt, now });
62138
+ const reason = retireDecision({ exists: existsSync30(rec.root), lastActiveAt, now });
62078
62139
  if (reason) void retireWorkspace(rec, reason);
62079
62140
  }
62080
62141
  };
@@ -62236,7 +62297,7 @@ async function startMultiDaemon(opts = {}) {
62236
62297
  const packageAutoAll = async () => {
62237
62298
  const out2 = /* @__PURE__ */ new Map();
62238
62299
  for (const r of records) {
62239
- await new Promise((resolve6) => setImmediate(resolve6));
62300
+ await new Promise((resolve7) => setImmediate(resolve7));
62240
62301
  const done = markPass(`package-index:${r.entry.name}`);
62241
62302
  try {
62242
62303
  out2.set(
@@ -62830,7 +62891,7 @@ async function startMultiDaemon(opts = {}) {
62830
62891
  clearInterval(codexWake);
62831
62892
  clearTimeout(codexWakeBoot);
62832
62893
  try {
62833
- const cur = readFileSync27(lockPath, "utf8");
62894
+ const cur = readFileSync28(lockPath, "utf8");
62834
62895
  if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
62835
62896
  } catch {
62836
62897
  }
@@ -62878,6 +62939,7 @@ async function startMultiDaemon(opts = {}) {
62878
62939
 
62879
62940
  // src/cli.ts
62880
62941
  init_src5();
62942
+ init_git_remote();
62881
62943
  init_config();
62882
62944
  init_src7();
62883
62945
  init_cloud_auth();
@@ -63037,7 +63099,7 @@ async function loginOAuthDevice(opts) {
63037
63099
  let deviceSession = null;
63038
63100
  let approvedInstallation = null;
63039
63101
  while (Date.now() < deadline) {
63040
- await (opts.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms))))(intervalMs);
63102
+ await (opts.sleep ?? ((ms) => new Promise((resolve7) => setTimeout(resolve7, ms))))(intervalMs);
63041
63103
  const poll = await fetchFn(device.token, {
63042
63104
  method: "POST",
63043
63105
  headers: { "content-type": "application/json", accept: "application/json" },
@@ -63141,7 +63203,7 @@ async function loginOAuthLoopback(opts) {
63141
63203
  const state = randomState();
63142
63204
  const scope = opts.scope ?? DEFAULT_OAUTH_SCOPE;
63143
63205
  const { code, redirectUri, clientId } = await new Promise(
63144
- (resolve6, reject) => {
63206
+ (resolve7, reject) => {
63145
63207
  const server = createServer((req, res) => {
63146
63208
  const u = new URL(req.url ?? "/", "http://127.0.0.1");
63147
63209
  if (u.pathname !== "/callback") {
@@ -63164,7 +63226,7 @@ async function loginOAuthLoopback(opts) {
63164
63226
  res.writeHead(200, { "content-type": "text/html" });
63165
63227
  res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
63166
63228
  server.close();
63167
- resolve6({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
63229
+ resolve7({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
63168
63230
  });
63169
63231
  let activeClientId = oauthClientId();
63170
63232
  server.on("error", reject);
@@ -63405,6 +63467,7 @@ function openInBrowser(url2) {
63405
63467
 
63406
63468
  // src/cli.ts
63407
63469
  init_paths();
63470
+ init_checkout_root();
63408
63471
 
63409
63472
  // src/cli-args.ts
63410
63473
  var BURST_VALUE_FLAGS = /* @__PURE__ */ new Set(["--limit", "--hops", "--max-hops"]);
@@ -63824,7 +63887,7 @@ var exitCleanOnEpipe = (err2) => {
63824
63887
  };
63825
63888
  process.stdout.on("error", exitCleanOnEpipe);
63826
63889
  process.stderr.on("error", exitCleanOnEpipe);
63827
- var ROOT = process.cwd();
63890
+ var ROOT = checkoutRootOf(process.cwd());
63828
63891
  var argv = process.argv.slice(2);
63829
63892
  var cmd = argv[0] ?? "help";
63830
63893
  var rest = argv.slice(1);
@@ -64081,21 +64144,21 @@ async function cmdInit() {
64081
64144
  if (!skipHooks) {
64082
64145
  console.log("");
64083
64146
  console.log("installing harness hooks...");
64084
- const { existsSync: existsSync31 } = await import("node:fs");
64085
- const { join: join33 } = await import("node:path");
64147
+ const { existsSync: existsSync32 } = await import("node:fs");
64148
+ const { join: join34 } = await import("node:path");
64086
64149
  try {
64087
64150
  await installClaudeHooks(port);
64088
64151
  } catch (err2) {
64089
64152
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
64090
64153
  }
64091
- if (existsSync31(join33(ROOT, ".cursor"))) {
64154
+ if (existsSync32(join34(ROOT, ".cursor"))) {
64092
64155
  try {
64093
64156
  await installCursorMcpConfig();
64094
64157
  } catch (err2) {
64095
64158
  console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
64096
64159
  }
64097
64160
  }
64098
- if (existsSync31(join33(ROOT, ".codex"))) {
64161
+ if (existsSync32(join34(ROOT, ".codex"))) {
64099
64162
  try {
64100
64163
  await installCodexHooks(port);
64101
64164
  } catch (err2) {
@@ -64272,9 +64335,9 @@ async function cmdStatus() {
64272
64335
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
64273
64336
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
64274
64337
  }
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)) {
64338
+ console.log(` graph db: ${existsSync31(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
64339
+ console.log(` event log: ${existsSync31(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
64340
+ if (existsSync31(paths.castalia)) {
64278
64341
  try {
64279
64342
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
64280
64343
  const store = openGraphStore2({ path: paths.castalia });
@@ -64336,6 +64399,15 @@ async function cmdStatus() {
64336
64399
  const line = watchCensusLine(h.watch);
64337
64400
  if (line) console.log(` watcher: ${line}`);
64338
64401
  }
64402
+ if (h.lastHook !== void 0) {
64403
+ if (h.lastHook === null) {
64404
+ console.log(` hooks: none received since the daemon started`);
64405
+ } else {
64406
+ const min = Math.round((Date.now() - h.lastHook.at) / 6e4);
64407
+ const ago2 = min < 1 ? "just now" : min < 60 ? `${min}m ago` : `${Math.floor(min / 60)}h ${min % 60}m ago`;
64408
+ console.log(` hooks: last received ${ago2} (${h.lastHook.event})`);
64409
+ }
64410
+ }
64339
64411
  }
64340
64412
  } catch {
64341
64413
  }
@@ -65068,11 +65140,11 @@ function cmdInstallationProfile(args2) {
65068
65140
  }
65069
65141
  async function cmdReview() {
65070
65142
  const paths = workspacePaths(ROOT);
65071
- if (!existsSync30(paths.reviewQueue)) {
65143
+ if (!existsSync31(paths.reviewQueue)) {
65072
65144
  console.log("(review queue empty)");
65073
65145
  return;
65074
65146
  }
65075
- const queue = JSON.parse(readFileSync28(paths.reviewQueue, "utf8"));
65147
+ const queue = JSON.parse(readFileSync29(paths.reviewQueue, "utf8"));
65076
65148
  if (queue.length === 0) {
65077
65149
  console.log("(review queue empty)");
65078
65150
  return;
@@ -65743,7 +65815,7 @@ async function gatherRepo(store, ws) {
65743
65815
  };
65744
65816
  }
65745
65817
  async function gatherReportData(generatedAt) {
65746
- const { existsSync: existsSync31 } = await import("node:fs");
65818
+ const { existsSync: existsSync32 } = await import("node:fs");
65747
65819
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
65748
65820
  const cfg = loadConfig();
65749
65821
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -65751,7 +65823,7 @@ async function gatherReportData(generatedAt) {
65751
65823
  for (const ws of listWorkspaces()) {
65752
65824
  if (ws.missing) continue;
65753
65825
  const dbPath = workspacePaths(ws.path).castalia;
65754
- if (!existsSync31(dbPath)) continue;
65826
+ if (!existsSync32(dbPath)) continue;
65755
65827
  let store = null;
65756
65828
  try {
65757
65829
  store = openGraphStore2({ path: dbPath });
@@ -65795,8 +65867,8 @@ async function cmdReport(args2) {
65795
65867
  const outDir = workspacePaths(ROOT).configDir;
65796
65868
  mkdirSync9(outDir, { recursive: true });
65797
65869
  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");
65870
+ for (const f of files) writeFileSync23(join33(outDir, f.name), f.html, "utf8");
65871
+ const indexPath = join33(outDir, "report.html");
65800
65872
  console.log(`report \u2192 ${indexPath}`);
65801
65873
  console.log(
65802
65874
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -65916,24 +65988,24 @@ async function cmdInstallHooks(args2) {
65916
65988
  }
65917
65989
  }
65918
65990
  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] ?? "";
65991
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
65992
+ const { join: join34 } = await import("node:path");
65993
+ const dir = join34(ROOT, ".opencode", "plugin");
65994
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
65995
+ const file2 = join34(dir, "inerrata.js");
65996
+ if (existsSync32(file2)) {
65997
+ const head2 = readFileSync30(file2, "utf8").split("\n")[0] ?? "";
65926
65998
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
65927
65999
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
65928
66000
  process.exit(2);
65929
66001
  }
65930
66002
  }
65931
66003
  writeFileSync23(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
65932
- const cfgFile = join33(ROOT, "opencode.json");
66004
+ const cfgFile = join34(ROOT, "opencode.json");
65933
66005
  let cfg = { $schema: "https://opencode.ai/config.json" };
65934
- if (existsSync31(cfgFile)) {
66006
+ if (existsSync32(cfgFile)) {
65935
66007
  try {
65936
- cfg = JSON.parse(readFileSync29(cfgFile, "utf8"));
66008
+ cfg = JSON.parse(readFileSync30(cfgFile, "utf8"));
65937
66009
  } catch {
65938
66010
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
65939
66011
  process.exit(2);
@@ -65964,15 +66036,15 @@ function errataMcpInvocation() {
65964
66036
  return { command: cmd2, args: args2 };
65965
66037
  }
65966
66038
  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");
66039
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66040
+ const { join: join34 } = await import("node:path");
66041
+ const dir = join34(ROOT, ".claude");
66042
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66043
+ const file2 = join34(dir, "settings.json");
65972
66044
  let settings = {};
65973
- if (existsSync31(file2)) {
66045
+ if (existsSync32(file2)) {
65974
66046
  try {
65975
- settings = JSON.parse(readFileSync29(file2, "utf8"));
66047
+ settings = JSON.parse(readFileSync30(file2, "utf8"));
65976
66048
  } catch {
65977
66049
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
65978
66050
  process.exit(2);
@@ -66021,7 +66093,7 @@ async function installClaudeHooks(port) {
66021
66093
  writeFileSync23(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
66022
66094
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
66023
66095
  await installClaudeMcpConfig();
66024
- const claudeMd = join33(ROOT, "CLAUDE.md");
66096
+ const claudeMd = join34(ROOT, "CLAUDE.md");
66025
66097
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
66026
66098
  if (recall.kind === "collision") {
66027
66099
  console.warn(
@@ -66033,15 +66105,15 @@ async function installClaudeHooks(port) {
66033
66105
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
66034
66106
  }
66035
66107
  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 });
66108
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66109
+ const { join: join34, dirname: dirname12 } = await import("node:path");
66110
+ const file2 = join34(ROOT, ".mcp.json");
66111
+ const dir = dirname12(file2);
66112
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66041
66113
  let cfg = {};
66042
- if (existsSync31(file2)) {
66114
+ if (existsSync32(file2)) {
66043
66115
  try {
66044
- cfg = JSON.parse(readFileSync29(file2, "utf8"));
66116
+ cfg = JSON.parse(readFileSync30(file2, "utf8"));
66045
66117
  } catch {
66046
66118
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
66047
66119
  process.exit(2);
@@ -66055,15 +66127,15 @@ async function installClaudeMcpConfig() {
66055
66127
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
66056
66128
  }
66057
66129
  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");
66130
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66131
+ const { join: join34 } = await import("node:path");
66132
+ const dir = join34(ROOT, ".cursor");
66133
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66134
+ const file2 = join34(dir, "mcp.json");
66063
66135
  let cfg = {};
66064
- if (existsSync31(file2)) {
66136
+ if (existsSync32(file2)) {
66065
66137
  try {
66066
- cfg = JSON.parse(readFileSync29(file2, "utf8"));
66138
+ cfg = JSON.parse(readFileSync30(file2, "utf8"));
66067
66139
  } catch {
66068
66140
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
66069
66141
  process.exit(2);
@@ -66079,14 +66151,14 @@ async function installCursorMcpConfig() {
66079
66151
  console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
66080
66152
  }
66081
66153
  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");
66154
+ const { mkdirSync: mkdirSync9, existsSync: existsSync32, readFileSync: readFileSync30, writeFileSync: writeFileSync23 } = await import("node:fs");
66155
+ const { join: join34 } = await import("node:path");
66156
+ const dir = join34(ROOT, ".codex");
66157
+ if (!existsSync32(dir)) mkdirSync9(dir, { recursive: true });
66158
+ const file2 = join34(dir, "config.toml");
66087
66159
  let existing = "";
66088
- if (existsSync31(file2)) {
66089
- existing = readFileSync29(file2, "utf8");
66160
+ if (existsSync32(file2)) {
66161
+ existing = readFileSync30(file2, "utf8");
66090
66162
  const beginIdx = existing.indexOf(CODEX_HOOKS_BEGIN);
66091
66163
  const endIdx = existing.indexOf(CODEX_HOOKS_END);
66092
66164
  if (beginIdx >= 0 && endIdx > beginIdx) {
@@ -66363,7 +66435,7 @@ async function cmdDash(args2) {
66363
66435
  const hotspotScanMark = /* @__PURE__ */ new Map();
66364
66436
  const HOTSPOT_FANIN = 20;
66365
66437
  const runNightlyPass = async (dueIds) => {
66366
- const yieldToLoop2 = () => new Promise((resolve6) => setImmediate(resolve6));
66438
+ const yieldToLoop2 = () => new Promise((resolve7) => setImmediate(resolve7));
66367
66439
  const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
66368
66440
  const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
66369
66441
  let skillsLearned = 0;
@@ -66441,7 +66513,7 @@ async function cmdDash(args2) {
66441
66513
  await yieldToLoop2();
66442
66514
  try {
66443
66515
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile);
66444
- const res = bleedRules(join32(r.root, ".claude", "rules"), items);
66516
+ const res = bleedRules(join33(r.root, ".claude", "rules"), items);
66445
66517
  if (res.written || res.pruned) {
66446
66518
  console.log(
66447
66519
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")