@inerrata-corporation/errata 2.0.2-dev.938 → 2.0.2-dev.981

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/errata.mjs CHANGED
@@ -30779,6 +30779,87 @@ var init_src10 = __esm({
30779
30779
  }
30780
30780
  });
30781
30781
 
30782
+ // ../../packages/indexer/src/parse-cache.ts
30783
+ import { createHash as createHash3 } from "node:crypto";
30784
+ import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync7, readdirSync as readdirSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync8 } from "node:fs";
30785
+ import { homedir as homedir3 } from "node:os";
30786
+ import { join as join8 } from "node:path";
30787
+ function parseCacheDir() {
30788
+ return process.env["ERRATA_PARSE_CACHE"] ?? join8(homedir3(), ".errata", "parse-cache");
30789
+ }
30790
+ function parseCacheKey(source, providerId) {
30791
+ return createHash3("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
30792
+ }
30793
+ function entryPath(dir, key) {
30794
+ return join8(dir, key.slice(0, 2), `${key.slice(2)}.json`);
30795
+ }
30796
+ function readParseCache(dir, key) {
30797
+ const file2 = entryPath(dir, key);
30798
+ try {
30799
+ const raw2 = readFileSync7(file2, "utf8");
30800
+ const parsed = JSON.parse(raw2);
30801
+ if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
30802
+ return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
30803
+ } catch {
30804
+ return null;
30805
+ }
30806
+ }
30807
+ function writeParseCache(dir, key, providerId, value) {
30808
+ try {
30809
+ const envelope = {
30810
+ v: PARSE_CACHE_VERSION,
30811
+ provider: providerId,
30812
+ symbols: value.symbols,
30813
+ reExports: value.reExports
30814
+ };
30815
+ const body2 = JSON.stringify(envelope);
30816
+ if (body2.length > MAX_ENTRY_BYTES) return;
30817
+ const file2 = entryPath(dir, key);
30818
+ mkdirSync6(join8(dir, key.slice(0, 2)), { recursive: true });
30819
+ writeFileSync8(file2, body2);
30820
+ } catch {
30821
+ }
30822
+ }
30823
+ function sweepParseCacheOnce(dir, now = Date.now()) {
30824
+ if (sweptThisProcess) return 0;
30825
+ sweptThisProcess = true;
30826
+ let removed = 0;
30827
+ try {
30828
+ if (!existsSync9(dir)) return 0;
30829
+ for (const bucket of readdirSync2(dir)) {
30830
+ const bucketDir = join8(dir, bucket);
30831
+ let names;
30832
+ try {
30833
+ names = readdirSync2(bucketDir);
30834
+ } catch {
30835
+ continue;
30836
+ }
30837
+ for (const name2 of names) {
30838
+ const file2 = join8(bucketDir, name2);
30839
+ try {
30840
+ if (now - statSync(file2).mtimeMs > ENTRY_TTL_MS) {
30841
+ rmSync2(file2, { force: true });
30842
+ removed++;
30843
+ }
30844
+ } catch {
30845
+ }
30846
+ }
30847
+ }
30848
+ } catch {
30849
+ }
30850
+ return removed;
30851
+ }
30852
+ var PARSE_CACHE_VERSION, ENTRY_TTL_MS, MAX_ENTRY_BYTES, sweptThisProcess;
30853
+ var init_parse_cache = __esm({
30854
+ "../../packages/indexer/src/parse-cache.ts"() {
30855
+ "use strict";
30856
+ PARSE_CACHE_VERSION = 1;
30857
+ ENTRY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
30858
+ MAX_ENTRY_BYTES = 2 * 1024 * 1024;
30859
+ sweptThisProcess = false;
30860
+ }
30861
+ });
30862
+
30782
30863
  // ../../packages/indexer/src/simhash.ts
30783
30864
  function fnv1a64(s) {
30784
30865
  let h = FNV_OFFSET;
@@ -31002,10 +31083,10 @@ var init_identity3 = __esm({
31002
31083
  });
31003
31084
 
31004
31085
  // ../../packages/indexer/src/pipeline.ts
31005
- import { appendFileSync, readFileSync as readFileSync7, statSync } from "node:fs";
31086
+ import { appendFileSync, readFileSync as readFileSync8, statSync as statSync2 } from "node:fs";
31006
31087
  import { readdir } from "node:fs/promises";
31007
- import { extname, join as join8, relative as relative2, sep } from "node:path";
31008
- import { createHash as createHash3 } from "node:crypto";
31088
+ import { extname, join as join9, relative as relative2, sep } from "node:path";
31089
+ import { createHash as createHash4 } from "node:crypto";
31009
31090
  import { execFileSync } from "node:child_process";
31010
31091
  function nowTs() {
31011
31092
  return indexNow ?? Date.now();
@@ -31014,7 +31095,7 @@ function fingerprintOf(signature, bodyHash) {
31014
31095
  return `${signature ?? ""}|${bodyHash ?? ""}`;
31015
31096
  }
31016
31097
  function sha(s) {
31017
- return createHash3("sha256").update(s).digest("hex").slice(0, 16);
31098
+ return createHash4("sha256").update(s).digest("hex").slice(0, 16);
31018
31099
  }
31019
31100
  function fileNodeId(workspaceId2, relPath) {
31020
31101
  return `file_${sha(workspaceId2 + ":" + relPath.replace(/\\/g, "/"))}`;
@@ -31138,7 +31219,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31138
31219
  for (const rel of [...changedRelPaths]) {
31139
31220
  let h;
31140
31221
  try {
31141
- h = createHash3("sha256").update(readFileSync7(join8(rootPath, rel))).digest("hex");
31222
+ h = createHash4("sha256").update(readFileSync8(join9(rootPath, rel))).digest("hex");
31142
31223
  } catch {
31143
31224
  continue;
31144
31225
  }
@@ -31187,13 +31268,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
31187
31268
  let parsedFiles = 0;
31188
31269
  for (const rel of changedRelPaths) {
31189
31270
  if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
31190
- const abs = join8(rootPath, ...rel.split("/"));
31271
+ const abs = join9(rootPath, ...rel.split("/"));
31191
31272
  const ext = extname(abs).toLowerCase();
31192
31273
  const provider = providers.find((p) => p.fileExtensions.includes(ext));
31193
31274
  if (!provider) continue;
31194
31275
  let symbols;
31195
31276
  try {
31196
- symbols = provider.extractSymbols(readFileSync7(abs, "utf8"), abs);
31277
+ symbols = provider.extractSymbols(readFileSync8(abs, "utf8"), abs);
31197
31278
  } catch {
31198
31279
  continue;
31199
31280
  }
@@ -31447,8 +31528,13 @@ async function runIndexer(store, opts) {
31447
31528
  byLanguage: {},
31448
31529
  durationMs: 0,
31449
31530
  nodesPurged: 0,
31450
- edgesPurged: 0
31531
+ edgesPurged: 0,
31532
+ parseCacheHits: 0,
31533
+ parseCacheMisses: 0
31451
31534
  };
31535
+ const cacheDir = parseCacheDir();
31536
+ const parseCacheEnabled = cacheDir !== "";
31537
+ if (parseCacheEnabled) sweepParseCacheOnce(cacheDir);
31452
31538
  if (opts.clean) {
31453
31539
  const purge = purgeWorkspaceCodeGraph(store, opts.workspaceId);
31454
31540
  report.nodesPurged = purge.nodes;
@@ -31502,25 +31588,38 @@ async function runIndexer(store, opts) {
31502
31588
  }
31503
31589
  let source;
31504
31590
  try {
31505
- const st = statSync(f.absPath);
31591
+ const st = statSync2(f.absPath);
31506
31592
  if (st.size > maxBytes) {
31507
31593
  report.filesSkipped++;
31508
31594
  continue;
31509
31595
  }
31510
- source = readFileSync7(f.absPath, "utf8");
31596
+ source = readFileSync8(f.absPath, "utf8");
31511
31597
  } catch {
31512
31598
  report.filesSkipped++;
31513
31599
  continue;
31514
31600
  }
31601
+ const cacheKey2 = parseCacheKey(source, f.provider.id);
31602
+ const cached2 = parseCacheEnabled ? readParseCache(cacheDir, cacheKey2) : null;
31515
31603
  let symbols;
31516
- try {
31517
- symbols = f.provider.extractSymbols(source, f.absPath);
31518
- } catch {
31519
- report.filesSkipped++;
31520
- continue;
31604
+ let reExports;
31605
+ if (cached2) {
31606
+ symbols = cached2.symbols;
31607
+ reExports = cached2.reExports;
31608
+ report.parseCacheHits++;
31609
+ } else {
31610
+ try {
31611
+ symbols = f.provider.extractSymbols(source, f.absPath);
31612
+ } catch {
31613
+ report.filesSkipped++;
31614
+ continue;
31615
+ }
31616
+ reExports = scanReExports(source);
31617
+ report.parseCacheMisses++;
31618
+ if (parseCacheEnabled) {
31619
+ writeParseCache(cacheDir, cacheKey2, f.provider.id, { symbols, reExports });
31620
+ }
31521
31621
  }
31522
31622
  symbolsByFile.set(f.relPath, symbols);
31523
- const reExports = scanReExports(source);
31524
31623
  if (reExports.length > 0) reExportsByFile.set(f.relPath, reExports);
31525
31624
  report.filesParsed++;
31526
31625
  report.byLanguage[f.provider.id] = (report.byLanguage[f.provider.id] ?? 0) + 1;
@@ -31565,7 +31664,7 @@ async function runIndexer(store, opts) {
31565
31664
  const depth = fileNode.relPath.split("/").length;
31566
31665
  if (depth !== 3) continue;
31567
31666
  try {
31568
- const pkg = JSON.parse(readFileSync7(fileNode.absPath, "utf8"));
31667
+ const pkg = JSON.parse(readFileSync8(fileNode.absPath, "utf8"));
31569
31668
  if (!pkg.name) continue;
31570
31669
  const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
31571
31670
  const candidates = [
@@ -31947,7 +32046,7 @@ async function scan(root, current, ignores, providers, out2) {
31947
32046
  for (const ent of entries) {
31948
32047
  if (ignores.has(ent.name)) continue;
31949
32048
  if (ent.name.startsWith(".") && ent.name !== ".") continue;
31950
- const abs = join8(current, ent.name);
32049
+ const abs = join9(current, ent.name);
31951
32050
  if (ent.isDirectory()) {
31952
32051
  await scan(root, abs, ignores, providers, out2);
31953
32052
  } else if (ent.isFile()) {
@@ -31956,7 +32055,7 @@ async function scan(root, current, ignores, providers, out2) {
31956
32055
  const rel = relative2(root, abs).split(sep).join("/");
31957
32056
  let size = 0;
31958
32057
  try {
31959
- size = statSync(abs).size;
32058
+ size = statSync2(abs).size;
31960
32059
  } catch {
31961
32060
  continue;
31962
32061
  }
@@ -32002,10 +32101,10 @@ function gitListFiles(root, ignores, providers) {
32002
32101
  if (rels === null) return null;
32003
32102
  const out2 = [];
32004
32103
  for (const rel of rels) {
32005
- const abs = join8(root, rel);
32104
+ const abs = join9(root, rel);
32006
32105
  let size;
32007
32106
  try {
32008
- size = statSync(abs).size;
32107
+ size = statSync2(abs).size;
32009
32108
  } catch {
32010
32109
  continue;
32011
32110
  }
@@ -32025,7 +32124,7 @@ function upsertFile(store, id, f, workspaceId2) {
32025
32124
  const now = nowTs();
32026
32125
  let contentHash;
32027
32126
  try {
32028
- contentHash = createHash3("sha256").update(readFileSync7(f.absPath)).digest("hex");
32127
+ contentHash = createHash4("sha256").update(readFileSync8(f.absPath)).digest("hex");
32029
32128
  } catch {
32030
32129
  }
32031
32130
  const node2 = {
@@ -32224,6 +32323,7 @@ var init_pipeline = __esm({
32224
32323
  "../../packages/indexer/src/pipeline.ts"() {
32225
32324
  "use strict";
32226
32325
  init_src2();
32326
+ init_parse_cache();
32227
32327
  init_identity3();
32228
32328
  DEFAULT_IGNORES = /* @__PURE__ */ new Set([
32229
32329
  "node_modules",
@@ -36388,8 +36488,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
36388
36488
 
36389
36489
  // ../../packages/indexer/src/languages/tree-sitter-loader.ts
36390
36490
  import { fileURLToPath } from "node:url";
36391
- import { dirname as dirname5, join as join9 } from "node:path";
36392
- import { existsSync as existsSync9, readdirSync as readdirSync2 } from "node:fs";
36491
+ import { dirname as dirname5, join as join10 } from "node:path";
36492
+ import { existsSync as existsSync10, readdirSync as readdirSync3 } from "node:fs";
36393
36493
  import { createRequire as createRequire2 } from "node:module";
36394
36494
  function entryDir() {
36395
36495
  try {
@@ -36403,27 +36503,27 @@ function entryDir() {
36403
36503
  }
36404
36504
  function findWasmDir() {
36405
36505
  const here = entryDir();
36406
- const seaWasm = join9(here, "resources", "wasm");
36407
- if (existsSync9(join9(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
36506
+ const seaWasm = join10(here, "resources", "wasm");
36507
+ if (existsSync10(join10(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
36408
36508
  let dir = here;
36409
36509
  for (let i2 = 0; i2 < 6; i2++) {
36410
- const flat = join9(
36510
+ const flat = join10(
36411
36511
  dir,
36412
36512
  "node_modules",
36413
36513
  "@vscode",
36414
36514
  "tree-sitter-wasm",
36415
36515
  "wasm"
36416
36516
  );
36417
- if (existsSync9(join9(flat, "tree-sitter-typescript.wasm"))) return flat;
36517
+ if (existsSync10(join10(flat, "tree-sitter-typescript.wasm"))) return flat;
36418
36518
  dir = dirname5(dir);
36419
36519
  }
36420
36520
  let root = here;
36421
36521
  for (let i2 = 0; i2 < 6; i2++) {
36422
- const pnpmDir = join9(root, "node_modules", ".pnpm");
36423
- if (existsSync9(pnpmDir)) {
36424
- for (const entry of readdirSync2(pnpmDir)) {
36522
+ const pnpmDir = join10(root, "node_modules", ".pnpm");
36523
+ if (existsSync10(pnpmDir)) {
36524
+ for (const entry of readdirSync3(pnpmDir)) {
36425
36525
  if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
36426
- const candidate = join9(
36526
+ const candidate = join10(
36427
36527
  pnpmDir,
36428
36528
  entry,
36429
36529
  "node_modules",
@@ -36431,7 +36531,7 @@ function findWasmDir() {
36431
36531
  "tree-sitter-wasm",
36432
36532
  "wasm"
36433
36533
  );
36434
- if (existsSync9(join9(candidate, "tree-sitter-typescript.wasm"))) {
36534
+ if (existsSync10(join10(candidate, "tree-sitter-typescript.wasm"))) {
36435
36535
  return candidate;
36436
36536
  }
36437
36537
  }
@@ -36445,27 +36545,27 @@ function findWasmDir() {
36445
36545
  }
36446
36546
  function findRuntimeDir() {
36447
36547
  const here = entryDir();
36448
- const seaRuntime = join9(here, "resources", "wasm");
36449
- if (existsSync9(join9(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
36548
+ const seaRuntime = join10(here, "resources", "wasm");
36549
+ if (existsSync10(join10(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
36450
36550
  let dir = here;
36451
36551
  for (let i2 = 0; i2 < 6; i2++) {
36452
- const flat = join9(dir, "node_modules", "web-tree-sitter");
36453
- if (existsSync9(join9(flat, "web-tree-sitter.wasm"))) return flat;
36552
+ const flat = join10(dir, "node_modules", "web-tree-sitter");
36553
+ if (existsSync10(join10(flat, "web-tree-sitter.wasm"))) return flat;
36454
36554
  dir = dirname5(dir);
36455
36555
  }
36456
36556
  let root = here;
36457
36557
  for (let i2 = 0; i2 < 6; i2++) {
36458
- const pnpmDir = join9(root, "node_modules", ".pnpm");
36459
- if (existsSync9(pnpmDir)) {
36460
- for (const entry of readdirSync2(pnpmDir)) {
36558
+ const pnpmDir = join10(root, "node_modules", ".pnpm");
36559
+ if (existsSync10(pnpmDir)) {
36560
+ for (const entry of readdirSync3(pnpmDir)) {
36461
36561
  if (entry.startsWith("web-tree-sitter@")) {
36462
- const candidate = join9(
36562
+ const candidate = join10(
36463
36563
  pnpmDir,
36464
36564
  entry,
36465
36565
  "node_modules",
36466
36566
  "web-tree-sitter"
36467
36567
  );
36468
- if (existsSync9(join9(candidate, "web-tree-sitter.wasm"))) {
36568
+ if (existsSync10(join10(candidate, "web-tree-sitter.wasm"))) {
36469
36569
  return candidate;
36470
36570
  }
36471
36571
  }
@@ -36482,7 +36582,7 @@ async function loadWebTreeSitter() {
36482
36582
  void err2;
36483
36583
  }
36484
36584
  const here = entryDir();
36485
- const seaResourceBase = join9(here, "resources", "_resolve.js");
36585
+ const seaResourceBase = join10(here, "resources", "_resolve.js");
36486
36586
  const resourceRequire = createRequire2(seaResourceBase);
36487
36587
  return resourceRequire("web-tree-sitter");
36488
36588
  }
@@ -36497,9 +36597,9 @@ async function ensureTreeSitterReady() {
36497
36597
  await Parser2.init({
36498
36598
  locateFile: (name2) => {
36499
36599
  if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
36500
- return join9(runtime, name2);
36600
+ return join10(runtime, name2);
36501
36601
  }
36502
- return join9(grammars, name2);
36602
+ return join10(grammars, name2);
36503
36603
  }
36504
36604
  });
36505
36605
  })();
@@ -36511,7 +36611,7 @@ async function loadGrammar(name2) {
36511
36611
  if (cached2) return cached2;
36512
36612
  if (!languageClass) throw new Error("tree-sitter not initialized");
36513
36613
  const grammars = findWasmDir();
36514
- const lang = await languageClass.load(join9(grammars, `${name2}.wasm`));
36614
+ const lang = await languageClass.load(join10(grammars, `${name2}.wasm`));
36515
36615
  grammarCache.set(name2, lang);
36516
36616
  return lang;
36517
36617
  }
@@ -36534,7 +36634,7 @@ var init_tree_sitter_loader = __esm({
36534
36634
  });
36535
36635
 
36536
36636
  // ../../packages/indexer/src/languages/typescript-treesitter.ts
36537
- import { createHash as createHash4 } from "node:crypto";
36637
+ import { createHash as createHash5 } from "node:crypto";
36538
36638
  function extractNode(node2, source, containerQname, containerKind) {
36539
36639
  switch (node2.type) {
36540
36640
  case "function_declaration":
@@ -36747,7 +36847,7 @@ function scopeRecord(kind, name2, qname, node2, body2, source) {
36747
36847
  const sig = header.replace(/\s+/g, " ").trim();
36748
36848
  if (sig) rec.signature = sig;
36749
36849
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
36750
- rec.bodyHash = createHash4("sha256").update(bodyText).digest("hex").slice(0, 16);
36850
+ rec.bodyHash = createHash5("sha256").update(bodyText).digest("hex").slice(0, 16);
36751
36851
  rec.bodySimhash = toHex(simhash(bodyText));
36752
36852
  }
36753
36853
  }
@@ -37189,14 +37289,14 @@ var init_typescript_treesitter = __esm({
37189
37289
  });
37190
37290
 
37191
37291
  // ../../packages/indexer/src/languages/python-treesitter.ts
37192
- import { createHash as createHash5 } from "node:crypto";
37292
+ import { createHash as createHash6 } from "node:crypto";
37193
37293
  function sigAndHash(node2, body2, source) {
37194
37294
  if (!body2) return {};
37195
37295
  const out2 = {};
37196
37296
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
37197
37297
  if (sig) out2.signature = sig;
37198
37298
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
37199
- out2.bodyHash = createHash5("sha256").update(bodyText).digest("hex").slice(0, 16);
37299
+ out2.bodyHash = createHash6("sha256").update(bodyText).digest("hex").slice(0, 16);
37200
37300
  out2.bodySimhash = toHex(simhash(bodyText));
37201
37301
  return out2;
37202
37302
  }
@@ -37609,7 +37709,7 @@ var init_python_treesitter = __esm({
37609
37709
  });
37610
37710
 
37611
37711
  // ../../packages/indexer/src/languages/cpp-treesitter.ts
37612
- import { createHash as createHash6 } from "node:crypto";
37712
+ import { createHash as createHash7 } from "node:crypto";
37613
37713
  function extractNode3(node2, containerQname, containerIsClass, source) {
37614
37714
  switch (node2.type) {
37615
37715
  case "function_definition":
@@ -37793,7 +37893,7 @@ function sigAndHash2(node2, body2, source) {
37793
37893
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
37794
37894
  if (sig) out2.signature = sig;
37795
37895
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
37796
- out2.bodyHash = createHash6("sha256").update(bodyText).digest("hex").slice(0, 16);
37896
+ out2.bodyHash = createHash7("sha256").update(bodyText).digest("hex").slice(0, 16);
37797
37897
  out2.bodySimhash = toHex(simhash(bodyText));
37798
37898
  return out2;
37799
37899
  }
@@ -37954,7 +38054,7 @@ var init_cpp_treesitter = __esm({
37954
38054
  });
37955
38055
 
37956
38056
  // ../../packages/indexer/src/languages/go-treesitter.ts
37957
- import { createHash as createHash7 } from "node:crypto";
38057
+ import { createHash as createHash8 } from "node:crypto";
37958
38058
  function extractNode4(node2, containerQname, source) {
37959
38059
  switch (node2.type) {
37960
38060
  case "function_declaration": {
@@ -38116,7 +38216,7 @@ function sigAndHash3(node2, body2, source) {
38116
38216
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
38117
38217
  if (sig) out2.signature = sig;
38118
38218
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
38119
- out2.bodyHash = createHash7("sha256").update(bodyText).digest("hex").slice(0, 16);
38219
+ out2.bodyHash = createHash8("sha256").update(bodyText).digest("hex").slice(0, 16);
38120
38220
  out2.bodySimhash = toHex(simhash(bodyText));
38121
38221
  return out2;
38122
38222
  }
@@ -38260,7 +38360,7 @@ var init_go_treesitter = __esm({
38260
38360
  });
38261
38361
 
38262
38362
  // ../../packages/indexer/src/languages/rust-treesitter.ts
38263
- import { createHash as createHash8 } from "node:crypto";
38363
+ import { createHash as createHash9 } from "node:crypto";
38264
38364
  function extractNode5(node2, containerQname, containerIsClass, source) {
38265
38365
  switch (node2.type) {
38266
38366
  case "function_item":
@@ -38475,7 +38575,7 @@ function sigAndHash4(node2, body2, source) {
38475
38575
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
38476
38576
  if (sig) out2.signature = sig;
38477
38577
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
38478
- out2.bodyHash = createHash8("sha256").update(bodyText).digest("hex").slice(0, 16);
38578
+ out2.bodyHash = createHash9("sha256").update(bodyText).digest("hex").slice(0, 16);
38479
38579
  out2.bodySimhash = toHex(simhash(bodyText));
38480
38580
  return out2;
38481
38581
  }
@@ -38626,7 +38726,7 @@ var init_rust_treesitter = __esm({
38626
38726
  });
38627
38727
 
38628
38728
  // ../../packages/indexer/src/languages/ruby-treesitter.ts
38629
- import { createHash as createHash9 } from "node:crypto";
38729
+ import { createHash as createHash10 } from "node:crypto";
38630
38730
  function sigAndHash5(node2, body2, source) {
38631
38731
  if (!body2) {
38632
38732
  const sig2 = source.slice(node2.startIndex, node2.endIndex).replace(/\s+/g, " ").trim();
@@ -38636,7 +38736,7 @@ function sigAndHash5(node2, body2, source) {
38636
38736
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
38637
38737
  if (sig) out2.signature = sig;
38638
38738
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
38639
- out2.bodyHash = createHash9("sha256").update(bodyText).digest("hex").slice(0, 16);
38739
+ out2.bodyHash = createHash10("sha256").update(bodyText).digest("hex").slice(0, 16);
38640
38740
  out2.bodySimhash = toHex(simhash(bodyText));
38641
38741
  return out2;
38642
38742
  }
@@ -38982,7 +39082,7 @@ var init_ruby_treesitter = __esm({
38982
39082
  });
38983
39083
 
38984
39084
  // ../../packages/indexer/src/languages/csharp-treesitter.ts
38985
- import { createHash as createHash10 } from "node:crypto";
39085
+ import { createHash as createHash11 } from "node:crypto";
38986
39086
  function extractNode7(node2, containerQname, containerIsType, source, eof) {
38987
39087
  switch (node2.type) {
38988
39088
  case "method_declaration":
@@ -39184,7 +39284,7 @@ function sigAndHash6(node2, body2, source) {
39184
39284
  const sig = source.slice(node2.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
39185
39285
  if (sig) out2.signature = sig;
39186
39286
  const bodyText = source.slice(body2.startIndex, body2.endIndex);
39187
- out2.bodyHash = createHash10("sha256").update(bodyText).digest("hex").slice(0, 16);
39287
+ out2.bodyHash = createHash11("sha256").update(bodyText).digest("hex").slice(0, 16);
39188
39288
  out2.bodySimhash = toHex(simhash(bodyText));
39189
39289
  return out2;
39190
39290
  }
@@ -39414,8 +39514,8 @@ var init_src11 = __esm({
39414
39514
 
39415
39515
  // src/reconcile.ts
39416
39516
  import { execFileSync as execFileSync2 } from "node:child_process";
39417
- import { readdirSync as readdirSync3, statSync as statSync2 } from "node:fs";
39418
- import { join as join10, relative as relative3, sep as sep2 } from "node:path";
39517
+ import { readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
39518
+ import { join as join11, relative as relative3, sep as sep2 } from "node:path";
39419
39519
  function gitSourceFiles(root) {
39420
39520
  let stdout;
39421
39521
  try {
@@ -39430,7 +39530,7 @@ function gitSourceFiles(root) {
39430
39530
  const out2 = [];
39431
39531
  for (const rel of stdout.split("\0")) {
39432
39532
  if (!rel || !SOURCE_RE.test(rel)) continue;
39433
- const abs = join10(root, rel);
39533
+ const abs = join11(root, rel);
39434
39534
  if (IGNORED.test(abs)) continue;
39435
39535
  out2.push(abs);
39436
39536
  }
@@ -39439,13 +39539,13 @@ function gitSourceFiles(root) {
39439
39539
  function* walkSource(dir) {
39440
39540
  let entries;
39441
39541
  try {
39442
- entries = readdirSync3(dir, { withFileTypes: true });
39542
+ entries = readdirSync4(dir, { withFileTypes: true });
39443
39543
  } catch {
39444
39544
  return;
39445
39545
  }
39446
39546
  for (const e of entries) {
39447
39547
  const name2 = String(e.name);
39448
- const full = join10(dir, name2);
39548
+ const full = join11(dir, name2);
39449
39549
  if (IGNORED.test(full)) continue;
39450
39550
  if (e.isDirectory()) yield* walkSource(full);
39451
39551
  else if (SOURCE_RE.test(name2)) yield full;
@@ -39463,7 +39563,7 @@ async function findStaleFiles(store, rootPath, workspaceId2) {
39463
39563
  if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
39464
39564
  let mtimeMs;
39465
39565
  try {
39466
- mtimeMs = statSync2(abs).mtimeMs;
39566
+ mtimeMs = statSync3(abs).mtimeMs;
39467
39567
  } catch {
39468
39568
  continue;
39469
39569
  }
@@ -39591,7 +39691,7 @@ __export(mcp_exports, {
39591
39691
  runTool: () => runTool,
39592
39692
  searchGraph: () => searchGraph
39593
39693
  });
39594
- import { existsSync as existsSync10, readFileSync as readFileSync8 } from "node:fs";
39694
+ import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
39595
39695
  import { resolve } from "node:path";
39596
39696
  function collectEnrichmentPulls(store, opts = {}) {
39597
39697
  const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
@@ -39628,7 +39728,7 @@ function takeEnrichmentNudge(store) {
39628
39728
  ` + items;
39629
39729
  }
39630
39730
  function takeDiscriminatorNudge(path2) {
39631
- if (!path2 || !existsSync10(path2)) return null;
39731
+ if (!path2 || !existsSync11(path2)) return null;
39632
39732
  let shared;
39633
39733
  try {
39634
39734
  shared = openGraphStore({ path: path2 });
@@ -39734,10 +39834,10 @@ function showNode(store, node2, maxLines) {
39734
39834
  if (!relPath) return { found: false, reason: "no file owner for node" };
39735
39835
  const workspaceRoot = process.cwd();
39736
39836
  const absPath = resolve(workspaceRoot, relPath);
39737
- if (!existsSync10(absPath)) {
39837
+ if (!existsSync11(absPath)) {
39738
39838
  return { found: false, reason: `file not found on disk: ${absPath}` };
39739
39839
  }
39740
- const source = readFileSync8(absPath, "utf8");
39840
+ const source = readFileSync9(absPath, "utf8");
39741
39841
  const attrs = node2.attrs;
39742
39842
  let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
39743
39843
  let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
@@ -40482,7 +40582,7 @@ var init_mcp = __esm({
40482
40582
  const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
40483
40583
  try {
40484
40584
  const path2 = sharedStorePath();
40485
- if (!existsSync10(path2)) return { found: true, ...local };
40585
+ if (!existsSync11(path2)) return { found: true, ...local };
40486
40586
  const shared = openGraphStore({ path: path2 });
40487
40587
  try {
40488
40588
  if (!shared.getNode(id)) return { found: true, ...local };
@@ -41082,7 +41182,7 @@ var init_mcp = __esm({
41082
41182
  inputSchema: { type: "object", properties: {} },
41083
41183
  handler: () => {
41084
41184
  const path2 = sharedStorePath();
41085
- if (!existsSync10(path2)) return { count: 0, pending: [] };
41185
+ if (!existsSync11(path2)) return { count: 0, pending: [] };
41086
41186
  const shared = openGraphStore({ path: path2 });
41087
41187
  try {
41088
41188
  const pending = pendingAbstractions(shared);
@@ -41110,7 +41210,7 @@ var init_mcp = __esm({
41110
41210
  },
41111
41211
  handler: (args2) => {
41112
41212
  const path2 = sharedStorePath();
41113
- if (!existsSync10(path2)) return { count: 0, pending: [] };
41213
+ if (!existsSync11(path2)) return { count: 0, pending: [] };
41114
41214
  const shared = openGraphStore({ path: path2 });
41115
41215
  try {
41116
41216
  const pending = pendingDiscriminators(shared, {
@@ -41154,7 +41254,7 @@ var init_mcp = __esm({
41154
41254
  },
41155
41255
  handler: (args2) => {
41156
41256
  const path2 = sharedStorePath();
41157
- if (!existsSync10(path2)) return { count: 0, routes: [] };
41257
+ if (!existsSync11(path2)) return { count: 0, routes: [] };
41158
41258
  const shared = openGraphStore({ path: path2 });
41159
41259
  try {
41160
41260
  const result = triageOf(shared, {
@@ -41539,8 +41639,8 @@ __export(vfile_exports, {
41539
41639
  resolvePath: () => resolvePath,
41540
41640
  segmentsOf: () => segmentsOf
41541
41641
  });
41542
- import { writeFileSync as writeFileSync8 } from "node:fs";
41543
- import { join as join11, resolve as resolve2, sep as sep3 } from "node:path";
41642
+ import { writeFileSync as writeFileSync9 } from "node:fs";
41643
+ import { join as join12, resolve as resolve2, sep as sep3 } from "node:path";
41544
41644
  function segmentsOf(rawPath) {
41545
41645
  let p = rawPath.replace(/\\/g, "/");
41546
41646
  p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
@@ -41614,14 +41714,14 @@ async function renderVFile(rawPath, store, ctx = {}) {
41614
41714
  }
41615
41715
  async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
41616
41716
  const segs = segmentsOf(rawPath);
41617
- const gRoot = join11(workspaceRoot, ".errata", "g");
41717
+ const gRoot = join12(workspaceRoot, ".errata", "g");
41618
41718
  const abs = resolve2(gRoot, ...segs.length ? segs : ["index"]);
41619
41719
  if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
41620
41720
  throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
41621
41721
  }
41622
41722
  const text = await renderVFile(rawPath, store, ctx);
41623
41723
  ensureParent(abs);
41624
- writeFileSync8(abs, text, "utf8");
41724
+ writeFileSync9(abs, text, "utf8");
41625
41725
  return abs;
41626
41726
  }
41627
41727
  async function materializeOverview(workspaceRoot, store, ctx = {}) {
@@ -49041,25 +49141,25 @@ var init_tool_index = __esm({
49041
49141
 
49042
49142
  // src/outbox.ts
49043
49143
  import {
49044
- existsSync as existsSync11,
49045
- readdirSync as readdirSync4,
49046
- readFileSync as readFileSync9,
49144
+ existsSync as existsSync12,
49145
+ readdirSync as readdirSync5,
49146
+ readFileSync as readFileSync10,
49047
49147
  renameSync,
49048
49148
  unlinkSync,
49049
- writeFileSync as writeFileSync9
49149
+ writeFileSync as writeFileSync10
49050
49150
  } from "node:fs";
49051
- import { join as join12 } from "node:path";
49052
- import { createHash as createHash11 } from "node:crypto";
49151
+ import { join as join13 } from "node:path";
49152
+ import { createHash as createHash12 } from "node:crypto";
49053
49153
  function enqueueOutbox(paths, payload) {
49054
49154
  ensureDir(paths.outbox);
49055
- const id = createHash11("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
49056
- const file2 = join12(paths.outbox, `${Date.now()}-${id}.json`);
49057
- writeFileSync9(file2, JSON.stringify(payload, null, 2), "utf8");
49155
+ const id = createHash12("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
49156
+ const file2 = join13(paths.outbox, `${Date.now()}-${id}.json`);
49157
+ writeFileSync10(file2, JSON.stringify(payload, null, 2), "utf8");
49058
49158
  return file2;
49059
49159
  }
49060
49160
  async function flushOutbox(paths, client, store) {
49061
49161
  ensureDir(paths.outbox);
49062
- const entries = existsSync11(paths.outbox) ? readdirSync4(paths.outbox) : [];
49162
+ const entries = existsSync12(paths.outbox) ? readdirSync5(paths.outbox) : [];
49063
49163
  let uploaded = 0;
49064
49164
  let failed = 0;
49065
49165
  const quarantine = (abs, reason) => {
@@ -49070,10 +49170,10 @@ async function flushOutbox(paths, client, store) {
49070
49170
  }
49071
49171
  };
49072
49172
  for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
49073
- const abs = join12(paths.outbox, f);
49173
+ const abs = join13(paths.outbox, f);
49074
49174
  let payload;
49075
49175
  try {
49076
- payload = JSON.parse(readFileSync9(abs, "utf8"));
49176
+ payload = JSON.parse(readFileSync10(abs, "utf8"));
49077
49177
  } catch {
49078
49178
  failed++;
49079
49179
  quarantine(abs, "unparseable JSON");
@@ -49118,7 +49218,7 @@ async function flushOutbox(paths, client, store) {
49118
49218
  }
49119
49219
  }
49120
49220
  }
49121
- const remainingFiles = existsSync11(paths.outbox) ? readdirSync4(paths.outbox).filter((e) => e.endsWith(".json")) : [];
49221
+ const remainingFiles = existsSync12(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
49122
49222
  return { uploaded, failed, remaining: remainingFiles.length };
49123
49223
  }
49124
49224
  var init_outbox = __esm({
@@ -49827,27 +49927,27 @@ __export(witness_ledger_exports, {
49827
49927
  summarizeWitnessLedger: () => summarizeWitnessLedger,
49828
49928
  witnessLedgerPath: () => witnessLedgerPath
49829
49929
  });
49830
- import { appendFileSync as appendFileSync3, existsSync as existsSync21, readFileSync as readFileSync21, writeFileSync as writeFileSync18 } from "node:fs";
49831
- import { join as join26 } from "node:path";
49930
+ import { appendFileSync as appendFileSync3, existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync19 } from "node:fs";
49931
+ import { join as join27 } from "node:path";
49832
49932
  function witnessLedgerPath(configDir) {
49833
- return join26(configDir, "witness-ledger.jsonl");
49933
+ return join27(configDir, "witness-ledger.jsonl");
49834
49934
  }
49835
49935
  function appendWitnessLedger(configDir, entry) {
49836
49936
  const path2 = witnessLedgerPath(configDir);
49837
49937
  try {
49838
49938
  appendFileSync3(path2, JSON.stringify(entry) + "\n");
49839
- const lines = readFileSync21(path2, "utf8").split("\n").filter(Boolean);
49939
+ const lines = readFileSync22(path2, "utf8").split("\n").filter(Boolean);
49840
49940
  if (lines.length > LEDGER_MAX_LINES) {
49841
- writeFileSync18(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
49941
+ writeFileSync19(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
49842
49942
  }
49843
49943
  } catch {
49844
49944
  }
49845
49945
  }
49846
49946
  function readWitnessLedger(configDir) {
49847
49947
  const path2 = witnessLedgerPath(configDir);
49848
- if (!existsSync21(path2)) return [];
49948
+ if (!existsSync22(path2)) return [];
49849
49949
  try {
49850
- return readFileSync21(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
49950
+ return readFileSync22(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
49851
49951
  } catch {
49852
49952
  return [];
49853
49953
  }
@@ -50286,12 +50386,12 @@ var init_report_render = __esm({
50286
50386
 
50287
50387
  // src/cli.ts
50288
50388
  init_src6();
50289
- import { closeSync as closeSync2, existsSync as existsSync29, openSync as openSync2, readFileSync as readFileSync27, renameSync as renameSync4, statSync as statSync6 } from "node:fs";
50290
- import { join as join31, resolve as pathResolve } from "node:path";
50389
+ import { closeSync as closeSync2, existsSync as existsSync30, openSync as openSync2, readFileSync as readFileSync28, renameSync as renameSync4, statSync as statSync7 } from "node:fs";
50390
+ import { join as join32, resolve as pathResolve } from "node:path";
50291
50391
  import { spawn as spawn3 } from "node:child_process";
50292
50392
 
50293
50393
  // src/daemon.ts
50294
- import { existsSync as existsSync23, writeFileSync as writeFileSync20 } from "node:fs";
50394
+ import { existsSync as existsSync24, writeFileSync as writeFileSync21 } from "node:fs";
50295
50395
 
50296
50396
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
50297
50397
  import { createServer as createServerHTTP } from "http";
@@ -50871,8 +50971,8 @@ init_config();
50871
50971
 
50872
50972
  // src/engine.ts
50873
50973
  import { execFileSync as execFileSync3 } from "node:child_process";
50874
- import { existsSync as existsSync22, statSync as statSync5, appendFileSync as appendFileSync4, readdirSync as readdirSync9, renameSync as renameSync3, readFileSync as readFileSync22, writeFileSync as writeFileSync19 } from "node:fs";
50875
- import { join as join27, relative as relative6, sep as sep4 } from "node:path";
50974
+ 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";
50975
+ import { join as join28, relative as relative6, sep as sep4 } from "node:path";
50876
50976
 
50877
50977
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
50878
50978
  import { stat as statcb } from "fs";
@@ -52734,9 +52834,9 @@ init_src10();
52734
52834
  init_review2();
52735
52835
 
52736
52836
  // src/turn.ts
52737
- import { closeSync, existsSync as existsSync12, fstatSync, openSync, readdirSync as readdirSync5, readSync, statSync as statSync3 } from "node:fs";
52738
- import { basename as basename3, dirname as dirname8, join as join15 } from "node:path";
52739
- import { homedir as homedir3 } from "node:os";
52837
+ import { closeSync, existsSync as existsSync13, fstatSync, openSync, readdirSync as readdirSync6, readSync, statSync as statSync4 } from "node:fs";
52838
+ import { basename as basename3, dirname as dirname8, join as join16 } from "node:path";
52839
+ import { homedir as homedir4 } from "node:os";
52740
52840
  function readFrom(path2, fromByte, maxBytes) {
52741
52841
  let fd;
52742
52842
  try {
@@ -52954,15 +53054,15 @@ function turnsSince(turns, mark) {
52954
53054
  const at = turns.findIndex((t) => t.uuid === mark);
52955
53055
  return at >= 0 ? turns.slice(at + 1) : turns;
52956
53056
  }
52957
- function claudeProjectDir(cwd, home = homedir3()) {
52958
- return join15(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
53057
+ function claudeProjectDir(cwd, home = homedir4()) {
53058
+ return join16(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
52959
53059
  }
52960
53060
  function recentTranscripts(cwd, opts = {}) {
52961
- const dir = claudeProjectDir(cwd, opts.home ?? homedir3());
52962
- if (!existsSync12(dir)) return [];
53061
+ const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
53062
+ if (!existsSync13(dir)) return [];
52963
53063
  let names;
52964
53064
  try {
52965
- names = readdirSync5(dir);
53065
+ names = readdirSync6(dir);
52966
53066
  } catch {
52967
53067
  return [];
52968
53068
  }
@@ -52970,10 +53070,10 @@ function recentTranscripts(cwd, opts = {}) {
52970
53070
  const refs = [];
52971
53071
  for (const name2 of names) {
52972
53072
  if (!name2.endsWith(".jsonl")) continue;
52973
- const path2 = join15(dir, name2);
53073
+ const path2 = join16(dir, name2);
52974
53074
  let mtimeMs;
52975
53075
  try {
52976
- mtimeMs = statSync3(path2).mtimeMs;
53076
+ mtimeMs = statSync4(path2).mtimeMs;
52977
53077
  } catch {
52978
53078
  continue;
52979
53079
  }
@@ -52985,21 +53085,21 @@ function recentTranscripts(cwd, opts = {}) {
52985
53085
  }
52986
53086
  function subagentTranscripts(mainTranscriptPath, sessionId) {
52987
53087
  if (!mainTranscriptPath || !sessionId) return [];
52988
- const dir = join15(dirname8(mainTranscriptPath), sessionId, "subagents");
52989
- if (!existsSync12(dir)) return [];
53088
+ const dir = join16(dirname8(mainTranscriptPath), sessionId, "subagents");
53089
+ if (!existsSync13(dir)) return [];
52990
53090
  let names;
52991
53091
  try {
52992
- names = readdirSync5(dir);
53092
+ names = readdirSync6(dir);
52993
53093
  } catch {
52994
53094
  return [];
52995
53095
  }
52996
53096
  const refs = [];
52997
53097
  for (const name2 of names) {
52998
53098
  if (!name2.endsWith(".jsonl")) continue;
52999
- const path2 = join15(dir, name2);
53099
+ const path2 = join16(dir, name2);
53000
53100
  let mtimeMs;
53001
53101
  try {
53002
- mtimeMs = statSync3(path2).mtimeMs;
53102
+ mtimeMs = statSync4(path2).mtimeMs;
53003
53103
  } catch {
53004
53104
  continue;
53005
53105
  }
@@ -53015,7 +53115,7 @@ init_src2();
53015
53115
  init_agent_signals();
53016
53116
  init_tool_index();
53017
53117
  init_src5();
53018
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "node:fs";
53118
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "node:fs";
53019
53119
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
53020
53120
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
53021
53121
  var HANDLE_RE = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|prob|claim|err)_[0-9a-f]{6,})/gi;
@@ -53510,13 +53610,13 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
53510
53610
  entries.sort((a, b) => (b[1].seenAt ?? 0) - (a[1].seenAt ?? 0));
53511
53611
  entries.length = HANDLE_MAP_MAX;
53512
53612
  }
53513
- writeFileSync10(path2, JSON.stringify(Object.fromEntries(entries)));
53613
+ writeFileSync11(path2, JSON.stringify(Object.fromEntries(entries)));
53514
53614
  } catch {
53515
53615
  }
53516
53616
  }
53517
53617
  function readPrimingHandles(path2) {
53518
53618
  try {
53519
- return JSON.parse(readFileSync10(path2, "utf8"));
53619
+ return JSON.parse(readFileSync11(path2, "utf8"));
53520
53620
  } catch {
53521
53621
  return {};
53522
53622
  }
@@ -53929,9 +54029,9 @@ ${conversation}` }]
53929
54029
  // src/constraint-backfill.ts
53930
54030
  init_src5();
53931
54031
  init_src2();
53932
- import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync6, writeFileSync as writeFileSync11 } from "node:fs";
53933
- import { join as join16 } from "node:path";
53934
- import { homedir as homedir4 } from "node:os";
54032
+ import { existsSync as existsSync14, readFileSync as readFileSync12, readdirSync as readdirSync7, writeFileSync as writeFileSync12 } from "node:fs";
54033
+ import { join as join17 } from "node:path";
54034
+ import { homedir as homedir5 } from "node:os";
53935
54035
  var BACKFILL_VERSION = 1;
53936
54036
  var EMPTY = {
53937
54037
  skipped: true,
@@ -53944,13 +54044,13 @@ var EMPTY = {
53944
54044
  recoverable: 0
53945
54045
  };
53946
54046
  function markerPath(configDir) {
53947
- return join16(configDir, "constraint-backfill.json");
54047
+ return join17(configDir, "constraint-backfill.json");
53948
54048
  }
53949
54049
  function alreadyDone(configDir) {
53950
54050
  const p = markerPath(configDir);
53951
- if (!existsSync13(p)) return false;
54051
+ if (!existsSync14(p)) return false;
53952
54052
  try {
53953
- const raw2 = JSON.parse(readFileSync11(p, "utf8"));
54053
+ const raw2 = JSON.parse(readFileSync12(p, "utf8"));
53954
54054
  return raw2?.version === BACKFILL_VERSION;
53955
54055
  } catch {
53956
54056
  return false;
@@ -53959,18 +54059,18 @@ function alreadyDone(configDir) {
53959
54059
  function replay(root) {
53960
54060
  const statements = /* @__PURE__ */ new Set();
53961
54061
  const citedByFix = /* @__PURE__ */ new Set();
53962
- const dir = claudeProjectDir(root, homedir4());
53963
- if (!existsSync13(dir)) return { statements, citedByFix };
54062
+ const dir = claudeProjectDir(root, homedir5());
54063
+ if (!existsSync14(dir)) return { statements, citedByFix };
53964
54064
  let names;
53965
54065
  try {
53966
- names = readdirSync6(dir).filter((n) => n.endsWith(".jsonl"));
54066
+ names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
53967
54067
  } catch {
53968
54068
  return { statements, citedByFix };
53969
54069
  }
53970
54070
  for (const f of names) {
53971
54071
  let lines;
53972
54072
  try {
53973
- lines = readFileSync11(join16(dir, f), "utf8").split("\n");
54073
+ lines = readFileSync12(join17(dir, f), "utf8").split("\n");
53974
54074
  } catch {
53975
54075
  continue;
53976
54076
  }
@@ -54084,7 +54184,7 @@ function backfillConstraintKind(store, opts) {
54084
54184
  }
54085
54185
  });
54086
54186
  try {
54087
- writeFileSync11(
54187
+ writeFileSync12(
54088
54188
  markerPath(opts.configDir),
54089
54189
  JSON.stringify({ version: BACKFILL_VERSION, at: opts.now, ...report, cloudTwins: report.cloudTwins.length }, null, 2),
54090
54190
  "utf8"
@@ -54097,8 +54197,8 @@ function backfillConstraintKind(store, opts) {
54097
54197
  // src/edge-repair.ts
54098
54198
  init_src();
54099
54199
  init_src5();
54100
- import { existsSync as existsSync14, readFileSync as readFileSync12, writeFileSync as writeFileSync12 } from "node:fs";
54101
- import { join as join17 } from "node:path";
54200
+ import { existsSync as existsSync15, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "node:fs";
54201
+ import { join as join18 } from "node:path";
54102
54202
  function citeEdgeId(from, type, to) {
54103
54203
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
54104
54204
  }
@@ -54113,13 +54213,13 @@ var EMPTY2 = {
54113
54213
  byType: {}
54114
54214
  };
54115
54215
  function markerPath2(configDir) {
54116
- return join17(configDir, "edge-repair.json");
54216
+ return join18(configDir, "edge-repair.json");
54117
54217
  }
54118
54218
  function alreadyDone2(configDir) {
54119
54219
  const p = markerPath2(configDir);
54120
- if (!existsSync14(p)) return false;
54220
+ if (!existsSync15(p)) return false;
54121
54221
  try {
54122
- return JSON.parse(readFileSync12(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
54222
+ return JSON.parse(readFileSync13(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
54123
54223
  } catch {
54124
54224
  return false;
54125
54225
  }
@@ -54168,7 +54268,7 @@ function repairInvalidEdges(store, opts) {
54168
54268
  });
54169
54269
  store.pruneEdgeRejections(opts.now - REJECTION_RETENTION_MS);
54170
54270
  try {
54171
- writeFileSync12(
54271
+ writeFileSync13(
54172
54272
  markerPath2(opts.configDir),
54173
54273
  JSON.stringify({ version: EDGE_REPAIR_VERSION, at: opts.now, ...report }, null, 2),
54174
54274
  "utf8"
@@ -54182,8 +54282,8 @@ function repairInvalidEdges(store, opts) {
54182
54282
  init_reconcile();
54183
54283
 
54184
54284
  // src/pass-ledger.ts
54185
- import { appendFileSync as appendFileSync2, existsSync as existsSync15, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "node:fs";
54186
- import { join as join18 } from "node:path";
54285
+ import { appendFileSync as appendFileSync2, existsSync as existsSync16, readFileSync as readFileSync14, writeFileSync as writeFileSync14 } from "node:fs";
54286
+ import { join as join19 } from "node:path";
54187
54287
 
54188
54288
  // src/isolate-census.ts
54189
54289
  var live = 0;
@@ -54206,7 +54306,7 @@ var PER_KIND_MAX = 100;
54206
54306
  var TRIM_EVERY = 50;
54207
54307
  var appendsSinceTrim = /* @__PURE__ */ new Map();
54208
54308
  function passLedgerPath(configDir) {
54209
- return join18(configDir, "pass-ledger.jsonl");
54309
+ return join19(configDir, "pass-ledger.jsonl");
54210
54310
  }
54211
54311
  function appendPassLedger(configDir, kind, durationMs, counts) {
54212
54312
  const path2 = passLedgerPath(configDir);
@@ -54235,7 +54335,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
54235
54335
  return;
54236
54336
  }
54237
54337
  appendsSinceTrim.set(path2, 0);
54238
- const lines = readFileSync13(path2, "utf8").split("\n").filter(Boolean);
54338
+ const lines = readFileSync14(path2, "utf8").split("\n").filter(Boolean);
54239
54339
  const keptByKind = /* @__PURE__ */ new Map();
54240
54340
  const kept = [];
54241
54341
  for (let i2 = lines.length - 1; i2 >= 0; i2--) {
@@ -54251,16 +54351,16 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
54251
54351
  kept.push(lines[i2]);
54252
54352
  }
54253
54353
  if (kept.length < lines.length) {
54254
- writeFileSync13(path2, kept.reverse().join("\n") + "\n");
54354
+ writeFileSync14(path2, kept.reverse().join("\n") + "\n");
54255
54355
  }
54256
54356
  } catch {
54257
54357
  }
54258
54358
  }
54259
54359
  function readPassLedger(configDir) {
54260
54360
  const path2 = passLedgerPath(configDir);
54261
- if (!existsSync15(path2)) return [];
54361
+ if (!existsSync16(path2)) return [];
54262
54362
  try {
54263
- return readFileSync13(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
54363
+ return readFileSync14(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
54264
54364
  (e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
54265
54365
  ).map((e) => ({ ...e, counts: e.counts ?? {} }));
54266
54366
  } catch {
@@ -54628,11 +54728,11 @@ init_outbox();
54628
54728
  init_src9();
54629
54729
  init_src();
54630
54730
  init_src2();
54631
- import { readFileSync as readFileSync14 } from "node:fs";
54632
- import { join as join19 } from "node:path";
54731
+ import { readFileSync as readFileSync15 } from "node:fs";
54732
+ import { join as join20 } from "node:path";
54633
54733
  function loadClaimIgnorePatterns(workspaceRoot) {
54634
54734
  try {
54635
- return readFileSync14(join19(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
54735
+ return readFileSync15(join20(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
54636
54736
  } catch {
54637
54737
  return [];
54638
54738
  }
@@ -54993,22 +55093,22 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
54993
55093
  }
54994
55094
 
54995
55095
  // src/git-sensor.ts
54996
- import { existsSync as existsSync16, readFileSync as readFileSync15, watch as fsWatch } from "node:fs";
54997
- import { join as join20 } from "node:path";
55096
+ import { existsSync as existsSync17, readFileSync as readFileSync16, watch as fsWatch } from "node:fs";
55097
+ import { join as join21 } from "node:path";
54998
55098
  function readFirstLine(path2) {
54999
55099
  try {
55000
- return readFileSync15(path2, "utf8").split(/\r?\n/, 1)[0].trim();
55100
+ return readFileSync16(path2, "utf8").split(/\r?\n/, 1)[0].trim();
55001
55101
  } catch {
55002
55102
  return null;
55003
55103
  }
55004
55104
  }
55005
55105
  function readGitRefState(gitDir) {
55006
- const head2 = readFirstLine(join20(gitDir, "HEAD"));
55106
+ const head2 = readFirstLine(join21(gitDir, "HEAD"));
55007
55107
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
55008
55108
  const branch = m ? m[1] : null;
55009
55109
  let sha2 = null;
55010
55110
  if (branch) {
55011
- sha2 = readFirstLine(join20(gitDir, "refs", "heads", branch));
55111
+ sha2 = readFirstLine(join21(gitDir, "refs", "heads", branch));
55012
55112
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
55013
55113
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
55014
55114
  sha2 = head2;
@@ -55016,13 +55116,13 @@ function readGitRefState(gitDir) {
55016
55116
  return {
55017
55117
  branch,
55018
55118
  sha: sha2,
55019
- mergeHeadExists: existsSync16(join20(gitDir, "MERGE_HEAD")),
55020
- origHeadExists: existsSync16(join20(gitDir, "ORIG_HEAD"))
55119
+ mergeHeadExists: existsSync17(join21(gitDir, "MERGE_HEAD")),
55120
+ origHeadExists: existsSync17(join21(gitDir, "ORIG_HEAD"))
55021
55121
  };
55022
55122
  }
55023
55123
  function shaFromPackedRefs(gitDir, ref) {
55024
55124
  try {
55025
- for (const line of readFileSync15(join20(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
55125
+ for (const line of readFileSync16(join21(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
55026
55126
  const [sha2, name2] = line.split(/\s+/);
55027
55127
  if (name2 === ref && sha2) return sha2;
55028
55128
  }
@@ -55056,7 +55156,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
55056
55156
  const settle = () => {
55057
55157
  if (timer) clearTimeout(timer);
55058
55158
  timer = setTimeout(() => {
55059
- if (existsSync16(join20(gitDir, "index.lock"))) {
55159
+ if (existsSync17(join21(gitDir, "index.lock"))) {
55060
55160
  settle();
55061
55161
  return;
55062
55162
  }
@@ -55067,7 +55167,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
55067
55167
  }, debounceMs);
55068
55168
  };
55069
55169
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
55070
- const p = join20(gitDir, sub);
55170
+ const p = join21(gitDir, sub);
55071
55171
  try {
55072
55172
  watchers.push(fsWatch(p, settle));
55073
55173
  } catch {
@@ -55292,21 +55392,21 @@ var TelemetryRecorder = class {
55292
55392
 
55293
55393
  // src/skills.ts
55294
55394
  import {
55295
- existsSync as existsSync17,
55296
- mkdirSync as mkdirSync6,
55297
- readFileSync as readFileSync16,
55298
- readdirSync as readdirSync7,
55395
+ existsSync as existsSync18,
55396
+ mkdirSync as mkdirSync7,
55397
+ readFileSync as readFileSync17,
55398
+ readdirSync as readdirSync8,
55299
55399
  unlinkSync as unlinkSync2,
55300
- writeFileSync as writeFileSync14
55400
+ writeFileSync as writeFileSync15
55301
55401
  } from "node:fs";
55302
- import { basename as basename4, join as join21 } from "node:path";
55402
+ import { basename as basename4, join as join22 } from "node:path";
55303
55403
  function skillFileName(id) {
55304
55404
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
55305
55405
  }
55306
55406
  function readSkillManifest(manifestPath) {
55307
- if (!existsSync17(manifestPath)) return [];
55407
+ if (!existsSync18(manifestPath)) return [];
55308
55408
  try {
55309
- const parsed = JSON.parse(readFileSync16(manifestPath, "utf8"));
55409
+ const parsed = JSON.parse(readFileSync17(manifestPath, "utf8"));
55310
55410
  return (parsed.skills ?? []).map((s) => ({
55311
55411
  title: s.title ?? "",
55312
55412
  layer: s.layer ?? "technique",
@@ -55320,9 +55420,9 @@ function readSkillManifest(manifestPath) {
55320
55420
  async function syncSkills(paths, client, seed, pins = [], techSeed) {
55321
55421
  const res = await client.getSkills(void 0, seed, techSeed);
55322
55422
  const staleDaemon = res.staleDaemon && res.latestDaemonVersion ? { latest: res.latestDaemonVersion } : void 0;
55323
- mkdirSync6(paths.skillsDir, { recursive: true });
55423
+ mkdirSync7(paths.skillsDir, { recursive: true });
55324
55424
  if (res.skills.length === 0 && pins.length === 0 && !res.skillsGated) {
55325
- const existing = readdirSync7(paths.skillsDir).filter((f) => f.endsWith(".md"));
55425
+ const existing = readdirSync8(paths.skillsDir).filter((f) => f.endsWith(".md"));
55326
55426
  if (existing.length > 0) return { written: 0, pruned: 0, ...staleDaemon ? { staleDaemon } : {} };
55327
55427
  }
55328
55428
  const rows = [];
@@ -55330,7 +55430,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
55330
55430
  for (const s of res.skills) {
55331
55431
  const fileName = skillFileName(s.id);
55332
55432
  keep.add(fileName);
55333
- writeFileSync14(join21(paths.skillsDir, fileName), s.markdown, "utf8");
55433
+ writeFileSync15(join22(paths.skillsDir, fileName), s.markdown, "utf8");
55334
55434
  rows.push({
55335
55435
  id: s.id,
55336
55436
  title: s.title,
@@ -55343,7 +55443,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
55343
55443
  const fileName = skillFileName(p.id);
55344
55444
  if (keep.has(fileName)) continue;
55345
55445
  keep.add(fileName);
55346
- writeFileSync14(join21(paths.skillsDir, fileName), p.markdown, "utf8");
55446
+ writeFileSync15(join22(paths.skillsDir, fileName), p.markdown, "utf8");
55347
55447
  rows.push({
55348
55448
  id: p.id,
55349
55449
  title: p.title,
@@ -55353,17 +55453,17 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
55353
55453
  });
55354
55454
  }
55355
55455
  let pruned = 0;
55356
- for (const f of readdirSync7(paths.skillsDir)) {
55456
+ for (const f of readdirSync8(paths.skillsDir)) {
55357
55457
  if (!f.endsWith(".md")) continue;
55358
55458
  if (keep.has(basename4(f))) continue;
55359
55459
  try {
55360
- unlinkSync2(join21(paths.skillsDir, f));
55460
+ unlinkSync2(join22(paths.skillsDir, f));
55361
55461
  pruned++;
55362
55462
  } catch {
55363
55463
  }
55364
55464
  }
55365
55465
  rows.sort((a, b) => a.id.localeCompare(b.id));
55366
- writeFileSync14(
55466
+ writeFileSync15(
55367
55467
  paths.skillsManifest,
55368
55468
  JSON.stringify({ generatedAt: Date.now(), skills: rows }, null, 2),
55369
55469
  "utf8"
@@ -55375,22 +55475,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
55375
55475
  init_src2();
55376
55476
  import {
55377
55477
  cpSync,
55378
- existsSync as existsSync18,
55478
+ existsSync as existsSync19,
55379
55479
  lstatSync,
55380
- mkdirSync as mkdirSync7,
55381
- readFileSync as readFileSync17,
55382
- readdirSync as readdirSync8,
55383
- rmSync as rmSync2,
55480
+ mkdirSync as mkdirSync8,
55481
+ readFileSync as readFileSync18,
55482
+ readdirSync as readdirSync9,
55483
+ rmSync as rmSync3,
55384
55484
  symlinkSync,
55385
- writeFileSync as writeFileSync15
55485
+ writeFileSync as writeFileSync16
55386
55486
  } from "node:fs";
55387
- import { join as join22 } from "node:path";
55487
+ import { join as join23 } from "node:path";
55388
55488
  var SKILL_NS = "errata-";
55389
55489
  var HARNESS_SKILL_DIRS = [
55390
- { configDir: ".claude", skillsDir: join22(".claude", "skills") },
55490
+ { configDir: ".claude", skillsDir: join23(".claude", "skills") },
55391
55491
  // Cursor adopted the standard; its exact project dir is still moving — kept
55392
55492
  // best-effort and gated on `.cursor/` presence so we never create it blind.
55393
- { configDir: ".cursor", skillsDir: join22(".cursor", "skills") }
55493
+ { configDir: ".cursor", skillsDir: join23(".cursor", "skills") }
55394
55494
  ];
55395
55495
  function skillSlug(title, id) {
55396
55496
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -55435,12 +55535,12 @@ function skillCiteHandle(s) {
55435
55535
  return priorHandle({ id: s.id, description: s.title });
55436
55536
  }
55437
55537
  function reconcileNamespaced(dir, keep) {
55438
- if (!existsSync18(dir)) return 0;
55538
+ if (!existsSync19(dir)) return 0;
55439
55539
  let pruned = 0;
55440
- for (const name2 of readdirSync8(dir)) {
55540
+ for (const name2 of readdirSync9(dir)) {
55441
55541
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
55442
55542
  try {
55443
- rmSync2(join22(dir, name2), { recursive: true, force: true });
55543
+ rmSync3(join23(dir, name2), { recursive: true, force: true });
55444
55544
  pruned++;
55445
55545
  } catch {
55446
55546
  }
@@ -55449,7 +55549,7 @@ function reconcileNamespaced(dir, keep) {
55449
55549
  }
55450
55550
  function linkOrCopy(linkPath, target) {
55451
55551
  try {
55452
- if (existsSync18(linkPath) || safeLstat(linkPath)) rmSync2(linkPath, { recursive: true, force: true });
55552
+ if (existsSync19(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
55453
55553
  } catch {
55454
55554
  }
55455
55555
  try {
@@ -55470,15 +55570,15 @@ function safeLstat(p) {
55470
55570
  }
55471
55571
  }
55472
55572
  function emitAndProjectSkills(root, skills) {
55473
- const agentsSkillsDir = join22(root, ".agents", "skills");
55474
- mkdirSync7(agentsSkillsDir, { recursive: true });
55573
+ const agentsSkillsDir = join23(root, ".agents", "skills");
55574
+ mkdirSync8(agentsSkillsDir, { recursive: true });
55475
55575
  const slugs = [];
55476
55576
  const keep = /* @__PURE__ */ new Set();
55477
55577
  let emitted = 0;
55478
55578
  for (const s of skills) {
55479
55579
  let body2;
55480
55580
  try {
55481
- body2 = readFileSync17(s.bodyPath, "utf8");
55581
+ body2 = readFileSync18(s.bodyPath, "utf8");
55482
55582
  } catch {
55483
55583
  continue;
55484
55584
  }
@@ -55487,9 +55587,9 @@ function emitAndProjectSkills(root, skills) {
55487
55587
  keep.add(slug2);
55488
55588
  slugs.push(slug2);
55489
55589
  const description = deriveDescription(s.title, s.layer, body2);
55490
- mkdirSync7(join22(agentsSkillsDir, slug2), { recursive: true });
55491
- writeFileSync15(
55492
- join22(agentsSkillsDir, slug2, "SKILL.md"),
55590
+ mkdirSync8(join23(agentsSkillsDir, slug2), { recursive: true });
55591
+ writeFileSync16(
55592
+ join23(agentsSkillsDir, slug2, "SKILL.md"),
55493
55593
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
55494
55594
  "utf8"
55495
55595
  );
@@ -55498,11 +55598,11 @@ function emitAndProjectSkills(root, skills) {
55498
55598
  reconcileNamespaced(agentsSkillsDir, keep);
55499
55599
  let projected = 0;
55500
55600
  for (const h of HARNESS_SKILL_DIRS) {
55501
- if (!existsSync18(join22(root, h.configDir))) continue;
55502
- const dir = join22(root, h.skillsDir);
55503
- mkdirSync7(dir, { recursive: true });
55601
+ if (!existsSync19(join23(root, h.configDir))) continue;
55602
+ const dir = join23(root, h.skillsDir);
55603
+ mkdirSync8(dir, { recursive: true });
55504
55604
  for (const slug2 of slugs) {
55505
- linkOrCopy(join22(dir, slug2), join22(agentsSkillsDir, slug2));
55605
+ linkOrCopy(join23(dir, slug2), join23(agentsSkillsDir, slug2));
55506
55606
  projected++;
55507
55607
  }
55508
55608
  reconcileNamespaced(dir, keep);
@@ -55511,15 +55611,15 @@ function emitAndProjectSkills(root, skills) {
55511
55611
  return { slugs, emitted, projected };
55512
55612
  }
55513
55613
  function emitInputsFromManifest(erretaDir, manifestPath) {
55514
- if (!existsSync18(manifestPath)) return [];
55614
+ if (!existsSync19(manifestPath)) return [];
55515
55615
  try {
55516
- const parsed = JSON.parse(readFileSync17(manifestPath, "utf8"));
55616
+ const parsed = JSON.parse(readFileSync18(manifestPath, "utf8"));
55517
55617
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
55518
55618
  id: s.id,
55519
55619
  title: s.title ?? s.id,
55520
55620
  layer: s.layer ?? "technique",
55521
55621
  confidence: s.confidence ?? 0,
55522
- bodyPath: join22(erretaDir, s.file)
55622
+ bodyPath: join23(erretaDir, s.file)
55523
55623
  }));
55524
55624
  } catch {
55525
55625
  return [];
@@ -55533,17 +55633,17 @@ var GITIGNORE_LINES = [
55533
55633
  ".cursor/skills/errata-*/"
55534
55634
  ];
55535
55635
  function ensureSkillGitignore(root) {
55536
- const path2 = join22(root, ".gitignore");
55636
+ const path2 = join23(root, ".gitignore");
55537
55637
  let current = "";
55538
55638
  try {
55539
- current = existsSync18(path2) ? readFileSync17(path2, "utf8") : "";
55639
+ current = existsSync19(path2) ? readFileSync18(path2, "utf8") : "";
55540
55640
  } catch {
55541
55641
  return;
55542
55642
  }
55543
55643
  if (current.includes(GITIGNORE_MARK)) return;
55544
55644
  const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
55545
55645
  try {
55546
- writeFileSync15(path2, `${current}${prefix}
55646
+ writeFileSync16(path2, `${current}${prefix}
55547
55647
  ${GITIGNORE_LINES.join("\n")}
55548
55648
  `, "utf8");
55549
55649
  } catch {
@@ -55640,20 +55740,20 @@ init_paths();
55640
55740
  // src/profile.ts
55641
55741
  init_src2();
55642
55742
  init_paths();
55643
- import { existsSync as existsSync20, readFileSync as readFileSync19, writeFileSync as writeFileSync16 } from "node:fs";
55644
- import { createHash as createHash12 } from "node:crypto";
55645
- import { join as join24 } from "node:path";
55743
+ import { existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync17 } from "node:fs";
55744
+ import { createHash as createHash13 } from "node:crypto";
55745
+ import { join as join25 } from "node:path";
55646
55746
 
55647
55747
  // src/git-remote.ts
55648
55748
  init_src();
55649
- import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync4 } from "node:fs";
55650
- import { isAbsolute as isAbsolute3, join as join23, resolve as resolve5 } from "node:path";
55749
+ import { existsSync as existsSync20, readFileSync as readFileSync19, statSync as statSync5 } from "node:fs";
55750
+ import { isAbsolute as isAbsolute3, join as join24, resolve as resolve5 } from "node:path";
55651
55751
  function resolveGitDir(root) {
55652
- const dotGit = join23(root, ".git");
55752
+ const dotGit = join24(root, ".git");
55653
55753
  try {
55654
- const st = statSync4(dotGit);
55754
+ const st = statSync5(dotGit);
55655
55755
  if (st.isDirectory()) return dotGit;
55656
- const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync18(dotGit, "utf8"));
55756
+ const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync19(dotGit, "utf8"));
55657
55757
  if (!m) return null;
55658
55758
  const dir = m[1];
55659
55759
  return isAbsolute3(dir) ? dir : resolve5(root, dir);
@@ -55662,22 +55762,22 @@ function resolveGitDir(root) {
55662
55762
  }
55663
55763
  }
55664
55764
  function gitConfigPath(gitDir) {
55665
- const commondirFile = join23(gitDir, "commondir");
55666
- if (existsSync19(commondirFile)) {
55667
- const common = readFileSync18(commondirFile, "utf8").trim();
55765
+ const commondirFile = join24(gitDir, "commondir");
55766
+ if (existsSync20(commondirFile)) {
55767
+ const common = readFileSync19(commondirFile, "utf8").trim();
55668
55768
  const commonDir = isAbsolute3(common) ? common : resolve5(gitDir, common);
55669
- return join23(commonDir, "config");
55769
+ return join24(commonDir, "config");
55670
55770
  }
55671
- return join23(gitDir, "config");
55771
+ return join24(gitDir, "config");
55672
55772
  }
55673
55773
  function readRemotes(root) {
55674
55774
  const gitDir = resolveGitDir(root);
55675
55775
  if (!gitDir) return [];
55676
55776
  const cfgPath = gitConfigPath(gitDir);
55677
- if (!existsSync19(cfgPath)) return [];
55777
+ if (!existsSync20(cfgPath)) return [];
55678
55778
  let txt;
55679
55779
  try {
55680
- txt = readFileSync18(cfgPath, "utf8");
55780
+ txt = readFileSync19(cfgPath, "utf8");
55681
55781
  } catch {
55682
55782
  return [];
55683
55783
  }
@@ -55698,11 +55798,11 @@ function detectRepoLocator(root, remote) {
55698
55798
 
55699
55799
  // src/profile.ts
55700
55800
  function workspaceId(root) {
55701
- return "wp_" + createHash12("sha256").update(root).digest("hex").slice(0, 12);
55801
+ return "wp_" + createHash13("sha256").update(root).digest("hex").slice(0, 12);
55702
55802
  }
55703
55803
  function sessionOriginKey(sessionId) {
55704
55804
  if (!sessionId) return void 0;
55705
- return "ws_" + createHash12("sha256").update(sessionId).digest("hex").slice(0, 12);
55805
+ return "ws_" + createHash13("sha256").update(sessionId).digest("hex").slice(0, 12);
55706
55806
  }
55707
55807
  function refreshRepoLocator(root, profile) {
55708
55808
  const detected = detectRepoLocator(root, profile.repoRemote);
@@ -55719,13 +55819,13 @@ function refreshRepoLocator(root, profile) {
55719
55819
  }
55720
55820
  function loadProfile(root) {
55721
55821
  const p = workspacePaths(root);
55722
- if (!existsSync20(p.workspaceJson)) return null;
55723
- return JSON.parse(readFileSync19(p.workspaceJson, "utf8"));
55822
+ if (!existsSync21(p.workspaceJson)) return null;
55823
+ return JSON.parse(readFileSync20(p.workspaceJson, "utf8"));
55724
55824
  }
55725
55825
  function saveProfile(root, profile) {
55726
55826
  const p = workspacePaths(root);
55727
55827
  ensureDir(p.configDir);
55728
- writeFileSync16(p.workspaceJson, JSON.stringify(profile, null, 2), "utf8");
55828
+ writeFileSync17(p.workspaceJson, JSON.stringify(profile, null, 2), "utf8");
55729
55829
  }
55730
55830
  function autodetectProfile(root) {
55731
55831
  const id = workspaceId(root);
@@ -55733,10 +55833,10 @@ function autodetectProfile(root) {
55733
55833
  const p = emptyProfile(id, name2);
55734
55834
  const locator = detectRepoLocator(root);
55735
55835
  if (locator) p.repoLocator = locator;
55736
- const pkgPath = join24(root, "package.json");
55737
- if (existsSync20(pkgPath)) {
55836
+ const pkgPath = join25(root, "package.json");
55837
+ if (existsSync21(pkgPath)) {
55738
55838
  try {
55739
- const pkg = JSON.parse(readFileSync19(pkgPath, "utf8"));
55839
+ const pkg = JSON.parse(readFileSync20(pkgPath, "utf8"));
55740
55840
  p.languages.push("typescript", "javascript");
55741
55841
  const nodeVer = pkg.engines?.node ?? "node";
55742
55842
  p.stack.push(`node@${nodeVer}`);
@@ -55757,10 +55857,10 @@ function autodetectProfile(root) {
55757
55857
  } catch {
55758
55858
  }
55759
55859
  }
55760
- const pyproject = join24(root, "pyproject.toml");
55761
- if (existsSync20(pyproject)) {
55860
+ const pyproject = join25(root, "pyproject.toml");
55861
+ if (existsSync21(pyproject)) {
55762
55862
  try {
55763
- const txt = readFileSync19(pyproject, "utf8");
55863
+ const txt = readFileSync20(pyproject, "utf8");
55764
55864
  const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
55765
55865
  p.languages.push("python");
55766
55866
  p.stack.push(`python@${py ?? "3"}`);
@@ -55771,16 +55871,16 @@ function autodetectProfile(root) {
55771
55871
  } catch {
55772
55872
  }
55773
55873
  }
55774
- const reqs = join24(root, "requirements.txt");
55775
- if (existsSync20(reqs)) {
55874
+ const reqs = join25(root, "requirements.txt");
55875
+ if (existsSync21(reqs)) {
55776
55876
  if (!p.languages.includes("python")) p.languages.push("python");
55777
55877
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
55778
55878
  }
55779
- if (existsSync20(join24(root, "go.mod"))) {
55879
+ if (existsSync21(join25(root, "go.mod"))) {
55780
55880
  p.languages.push("go");
55781
55881
  p.stack.push("go");
55782
55882
  }
55783
- if (existsSync20(join24(root, "Cargo.toml"))) {
55883
+ if (existsSync21(join25(root, "Cargo.toml"))) {
55784
55884
  p.languages.push("rust");
55785
55885
  p.stack.push("rust");
55786
55886
  }
@@ -55790,18 +55890,18 @@ function autodetectProfile(root) {
55790
55890
  }
55791
55891
 
55792
55892
  // src/witness-queue.ts
55793
- import { readFileSync as readFileSync20, renameSync as renameSync2, writeFileSync as writeFileSync17 } from "node:fs";
55794
- import { dirname as dirname9, join as join25 } from "node:path";
55893
+ import { readFileSync as readFileSync21, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
55894
+ import { dirname as dirname9, join as join26 } from "node:path";
55795
55895
  var WITNESS_QUEUE_CAP = 500;
55796
55896
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
55797
55897
  var WITNESS_MAX_ATTEMPTS = 5;
55798
55898
  function witnessQueuePath(workspaceConfigDir) {
55799
- return join25(workspaceConfigDir, "witness-queue.json");
55899
+ return join26(workspaceConfigDir, "witness-queue.json");
55800
55900
  }
55801
55901
  function loadWitnessQueueWithLosses(path2) {
55802
55902
  let raw2;
55803
55903
  try {
55804
- raw2 = JSON.parse(readFileSync20(path2, "utf8"));
55904
+ raw2 = JSON.parse(readFileSync21(path2, "utf8"));
55805
55905
  } catch (err2) {
55806
55906
  const absent = err2?.code === "ENOENT";
55807
55907
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -55814,8 +55914,8 @@ function loadWitnessQueueWithLosses(path2) {
55814
55914
  }
55815
55915
  function saveWitnessQueue(path2, queue) {
55816
55916
  try {
55817
- const tmp = join25(dirname9(path2), `.${Date.now()}.witness-queue.tmp`);
55818
- writeFileSync17(tmp, JSON.stringify(queue), "utf8");
55917
+ const tmp = join26(dirname9(path2), `.${Date.now()}.witness-queue.tmp`);
55918
+ writeFileSync18(tmp, JSON.stringify(queue), "utf8");
55819
55919
  renameSync2(tmp, path2);
55820
55920
  } catch {
55821
55921
  }
@@ -56229,7 +56329,7 @@ function createLivenessWatch(deps) {
56229
56329
  }
56230
56330
 
56231
56331
  // src/engine.ts
56232
- var DAEMON_VERSION = true ? "2.0.2-dev.938" : "2.0.0-alpha.0";
56332
+ var DAEMON_VERSION = true ? "2.0.2-dev.981" : "2.0.0-alpha.0";
56233
56333
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
56234
56334
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
56235
56335
  var GIT_OP_MUTE_MS = 4e3;
@@ -56239,7 +56339,7 @@ var TURN_REPLAY_LOOKBACK_MS = 7 * 24 * 60 * 6e4;
56239
56339
  function appendIdentityAudit(path2, record2, line) {
56240
56340
  if (!record2.accepted && record2.score <= 0) return;
56241
56341
  try {
56242
- if (existsSync22(path2) && statSync5(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
56342
+ if (existsSync23(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
56243
56343
  renameSync3(path2, `${path2}.1`);
56244
56344
  }
56245
56345
  appendFileSync4(path2, line);
@@ -56249,7 +56349,7 @@ function appendIdentityAudit(path2, record2, line) {
56249
56349
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
56250
56350
  function loadTurnCursors(path2) {
56251
56351
  try {
56252
- const raw2 = JSON.parse(readFileSync22(path2, "utf8"));
56352
+ const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
56253
56353
  return new Map(
56254
56354
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
56255
56355
  );
@@ -56259,7 +56359,7 @@ function loadTurnCursors(path2) {
56259
56359
  }
56260
56360
  function loadTurnOffsets(path2) {
56261
56361
  try {
56262
- const raw2 = JSON.parse(readFileSync22(path2, "utf8"));
56362
+ const raw2 = JSON.parse(readFileSync23(path2, "utf8"));
56263
56363
  const out2 = /* @__PURE__ */ new Map();
56264
56364
  for (const [k, v] of Object.entries(raw2)) {
56265
56365
  const off = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -56275,7 +56375,7 @@ function saveTurnCursors(path2, cursors, offsets) {
56275
56375
  const merged = {};
56276
56376
  for (const [k, uuid3] of cursors) merged[k] = { uuid: uuid3, offset: offsets.get(k) ?? 0 };
56277
56377
  for (const [k, offset] of offsets) if (!merged[k]) merged[k] = { uuid: "", offset };
56278
- writeFileSync19(path2, JSON.stringify(merged), "utf8");
56378
+ writeFileSync20(path2, JSON.stringify(merged), "utf8");
56279
56379
  } catch {
56280
56380
  }
56281
56381
  }
@@ -56297,7 +56397,7 @@ function gitSourceWatchTargets(root) {
56297
56397
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
56298
56398
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
56299
56399
  );
56300
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join27(root, d) + sep4));
56400
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join28(root, d) + sep4));
56301
56401
  } catch {
56302
56402
  }
56303
56403
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -56309,19 +56409,19 @@ function gitSourceWatchTargets(root) {
56309
56409
  if (!f.startsWith(prefix)) continue;
56310
56410
  const rest2 = f.slice(prefix.length);
56311
56411
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
56312
- else targets.add(join27(root, f));
56412
+ else targets.add(join28(root, f));
56313
56413
  }
56314
56414
  for (const c of children) {
56315
- if (IGNORED_PATH.test(join27(root, c) + sep4)) continue;
56415
+ if (IGNORED_PATH.test(join28(root, c) + sep4)) continue;
56316
56416
  if (hasIgnoredChild(c)) addUnder(c);
56317
- else targets.add(join27(root, c));
56417
+ else targets.add(join28(root, c));
56318
56418
  }
56319
56419
  };
56320
56420
  addUnder("");
56321
56421
  if (targets.size > 0) return [...targets];
56322
56422
  } catch {
56323
56423
  }
56324
- return readdirSync9(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join27(root, String(e.name)) + sep4)).map((e) => join27(root, String(e.name)));
56424
+ 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)));
56325
56425
  }
56326
56426
  function createWorkspaceEngine(opts) {
56327
56427
  const paths = workspacePaths(opts.workspaceRoot);
@@ -56381,7 +56481,7 @@ function createWorkspaceEngine(opts) {
56381
56481
  }
56382
56482
  let size = 0;
56383
56483
  try {
56384
- size = statSync5(path2).size;
56484
+ size = statSync6(path2).size;
56385
56485
  } catch {
56386
56486
  }
56387
56487
  lastActivityTs = Date.now();
@@ -56496,7 +56596,7 @@ function createWorkspaceEngine(opts) {
56496
56596
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
56497
56597
  let episodeId2;
56498
56598
  if (srcPaths.length > 0) {
56499
- const abs = srcPaths.map((p) => join27(opts.workspaceRoot, p));
56599
+ const abs = srcPaths.map((p) => join28(opts.workspaceRoot, p));
56500
56600
  try {
56501
56601
  const r = await runReindexPass(
56502
56602
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -56532,8 +56632,8 @@ function createWorkspaceEngine(opts) {
56532
56632
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
56533
56633
  );
56534
56634
  };
56535
- const gitDir = join27(opts.workspaceRoot, ".git");
56536
- if (existsSync22(gitDir)) {
56635
+ const gitDir = join28(opts.workspaceRoot, ".git");
56636
+ if (existsSync23(gitDir)) {
56537
56637
  stopGit = startGitSensor(gitDir, (ev) => {
56538
56638
  void handleGitEvent(ev).catch((err2) => {
56539
56639
  console.warn("[errata] git event handler failed:", err2);
@@ -56712,10 +56812,10 @@ function createWorkspaceEngine(opts) {
56712
56812
  console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
56713
56813
  }
56714
56814
  writeContextFile(opts.workspaceRoot, body2);
56715
- const target = join27(opts.workspaceRoot, "AGENTS.md");
56815
+ const target = join28(opts.workspaceRoot, "AGENTS.md");
56716
56816
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
56717
56817
  if (elicit) {
56718
- writePrimingHandles(join27(paths.configDir, "priming-handles.json"), [
56818
+ writePrimingHandles(join28(paths.configDir, "priming-handles.json"), [
56719
56819
  ...snapshot.recentProblems.map((r) => r.node),
56720
56820
  // Resolved-band handles: the ✓ problem AND its Solution are citable
56721
56821
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -56997,7 +57097,7 @@ function createWorkspaceEngine(opts) {
56997
57097
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
56998
57098
  });
56999
57099
  };
57000
- const turnCursorPath = join27(paths.configDir, "turn-cursors.json");
57100
+ const turnCursorPath = join28(paths.configDir, "turn-cursors.json");
57001
57101
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
57002
57102
  const turnOffset = loadTurnOffsets(turnCursorPath);
57003
57103
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -57037,7 +57137,7 @@ function createWorkspaceEngine(opts) {
57037
57137
  let processedTurns = 0;
57038
57138
  const seqAtStart = store.currentIngestSeq();
57039
57139
  const elicit = isEdgeElicitationEnabled();
57040
- const handleMap = elicit ? readPrimingHandles(join27(paths.configDir, "priming-handles.json")) : {};
57140
+ const handleMap = elicit ? readPrimingHandles(join28(paths.configDir, "priming-handles.json")) : {};
57041
57141
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
57042
57142
  const toRel = (abs) => {
57043
57143
  const p = abs.replace(/\\/g, "/");
@@ -57537,14 +57637,9 @@ function createWorkspaceEngine(opts) {
57537
57637
  });
57538
57638
  };
57539
57639
  if (typeof cloud.reportContradictions === "function") {
57540
- const emitRefutes = plan.refutes.filter((r) => !mintedHere(r.nodeId));
57541
- const refuteSkipped = plan.refutes.length - emitRefutes.length;
57542
- if (refuteSkipped > 0) {
57543
- appendWitnessLedger(paths.configDir, { ts: Date.now(), channel: "contradict", clientSelfSkipped: refuteSkipped });
57544
- }
57545
57640
  await sendWitnesses(
57546
57641
  "contradict",
57547
- emitRefutes,
57642
+ plan.refutes,
57548
57643
  (items2, session) => cloud.reportContradictions({
57549
57644
  daemonVersion: DAEMON_VERSION,
57550
57645
  projectId: profile.id,
@@ -57851,7 +57946,7 @@ function createWorkspaceEngine(opts) {
57851
57946
  try {
57852
57947
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
57853
57948
  emitAndProjectSkills(opts.workspaceRoot, inputs);
57854
- writePrimingHandles(join27(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
57949
+ writePrimingHandles(join28(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
57855
57950
  } catch (err2) {
57856
57951
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
57857
57952
  }
@@ -58106,7 +58201,7 @@ function createWorkspaceEngine(opts) {
58106
58201
  console.log(
58107
58202
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
58108
58203
  );
58109
- const pending = existsSync22(paths.outbox) ? readdirSync9(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
58204
+ const pending = existsSync23(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
58110
58205
  return { uploaded: 0, failed: 0, remaining: pending };
58111
58206
  }
58112
58207
  try {
@@ -58193,7 +58288,7 @@ async function startDaemon(opts) {
58193
58288
  reviewUrl: () => webUiUrl + "/review"
58194
58289
  });
58195
58290
  const writeLockFile = (url2) => {
58196
- writeFileSync20(
58291
+ writeFileSync21(
58197
58292
  engine.paths.daemonLock,
58198
58293
  JSON.stringify({ pid: process.pid, webUiUrl: url2, startedAt: Date.now() }),
58199
58294
  "utf8"
@@ -58236,7 +58331,7 @@ async function startDaemon(opts) {
58236
58331
  );
58237
58332
  await engine.stop();
58238
58333
  try {
58239
- if (existsSync23(engine.paths.daemonLock)) {
58334
+ if (existsSync24(engine.paths.daemonLock)) {
58240
58335
  }
58241
58336
  } catch {
58242
58337
  }
@@ -58258,7 +58353,7 @@ init_identity2();
58258
58353
  // src/multi.ts
58259
58354
  init_dist();
58260
58355
  init_src5();
58261
- import { existsSync as existsSync28, readFileSync as readFileSync26, unlinkSync as unlinkSync3, writeFileSync as writeFileSync21 } from "node:fs";
58356
+ import { existsSync as existsSync29, readFileSync as readFileSync27, unlinkSync as unlinkSync3, writeFileSync as writeFileSync22 } from "node:fs";
58262
58357
 
58263
58358
  // src/principle-sync.ts
58264
58359
  init_src5();
@@ -58286,8 +58381,8 @@ init_reconcile();
58286
58381
 
58287
58382
  // src/lockfile-auto.ts
58288
58383
  init_src();
58289
- import { existsSync as existsSync24, readFileSync as readFileSync23 } from "node:fs";
58290
- import { join as join28 } from "node:path";
58384
+ import { existsSync as existsSync25, readFileSync as readFileSync24 } from "node:fs";
58385
+ import { join as join29 } from "node:path";
58291
58386
 
58292
58387
  // src/package-index.ts
58293
58388
  init_src();
@@ -58436,11 +58531,11 @@ function runLockfilePass(opts) {
58436
58531
  { file: "package-lock.json", parse: parsePackageLockJson }
58437
58532
  ];
58438
58533
  for (const c of candidates) {
58439
- const p = join28(opts.root, c.file);
58440
- if (!existsSync24(p)) continue;
58534
+ const p = join29(opts.root, c.file);
58535
+ if (!existsSync25(p)) continue;
58441
58536
  let sbom;
58442
58537
  try {
58443
- sbom = c.parse(readFileSync23(p, "utf8"));
58538
+ sbom = c.parse(readFileSync24(p, "utf8"));
58444
58539
  } catch {
58445
58540
  continue;
58446
58541
  }
@@ -58497,8 +58592,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
58497
58592
  }
58498
58593
 
58499
58594
  // src/public-symbols.ts
58500
- import { readFileSync as readFileSync24, readdirSync as readdirSync10, existsSync as existsSync25 } from "node:fs";
58501
- import { join as join29 } from "node:path";
58595
+ import { readFileSync as readFileSync25, readdirSync as readdirSync11, existsSync as existsSync26 } from "node:fs";
58596
+ import { join as join30 } from "node:path";
58502
58597
  var HEAD_BYTES = 8 * 1024;
58503
58598
  var INDEX_TTL_MS = 10 * 60 * 1e3;
58504
58599
  var MIN_SYMBOL_LEN = 4;
@@ -58531,20 +58626,20 @@ function bindingNames(clause) {
58531
58626
  function internalPackageNames(workspaceRoot) {
58532
58627
  const names = /* @__PURE__ */ new Set();
58533
58628
  const tryRead = (dir) => {
58534
- const pj = join29(dir, "package.json");
58535
- if (!existsSync25(pj)) return;
58629
+ const pj = join30(dir, "package.json");
58630
+ if (!existsSync26(pj)) return;
58536
58631
  try {
58537
- const name2 = JSON.parse(readFileSync24(pj, "utf8")).name;
58632
+ const name2 = JSON.parse(readFileSync25(pj, "utf8")).name;
58538
58633
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
58539
58634
  } catch {
58540
58635
  }
58541
58636
  };
58542
58637
  tryRead(workspaceRoot);
58543
58638
  for (const group of ["packages", "apps"]) {
58544
- const groupDir = join29(workspaceRoot, group);
58545
- if (!existsSync25(groupDir)) continue;
58639
+ const groupDir = join30(workspaceRoot, group);
58640
+ if (!existsSync26(groupDir)) continue;
58546
58641
  try {
58547
- for (const entry of readdirSync10(groupDir)) tryRead(join29(groupDir, entry));
58642
+ for (const entry of readdirSync11(groupDir)) tryRead(join30(groupDir, entry));
58548
58643
  } catch {
58549
58644
  }
58550
58645
  }
@@ -58557,7 +58652,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
58557
58652
  if (cached2 && now - cached2.builtAt < INDEX_TTL_MS) return cached2;
58558
58653
  const readHead = deps.readHead ?? ((absPath) => {
58559
58654
  try {
58560
- return readFileSync24(absPath, "utf8").slice(0, HEAD_BYTES);
58655
+ return readFileSync25(absPath, "utf8").slice(0, HEAD_BYTES);
58561
58656
  } catch {
58562
58657
  return "";
58563
58658
  }
@@ -58577,7 +58672,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
58577
58672
  }
58578
58673
  const symbols = /* @__PURE__ */ new Set();
58579
58674
  for (const rel of files) {
58580
- const head2 = readHead(join29(workspaceRoot, rel));
58675
+ const head2 = readHead(join30(workspaceRoot, rel));
58581
58676
  if (!head2) continue;
58582
58677
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
58583
58678
  re.lastIndex = 0;
@@ -59186,7 +59281,7 @@ var ConsolidateWorker = class {
59186
59281
  init_paths();
59187
59282
 
59188
59283
  // src/lock.ts
59189
- import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
59284
+ import { existsSync as existsSync27, readFileSync as readFileSync26 } from "node:fs";
59190
59285
  function isProcessAlive(pid) {
59191
59286
  if (!pid || pid <= 0) return false;
59192
59287
  try {
@@ -59197,9 +59292,9 @@ function isProcessAlive(pid) {
59197
59292
  }
59198
59293
  }
59199
59294
  function readDaemonLock(lockPath) {
59200
- if (!existsSync26(lockPath)) return null;
59295
+ if (!existsSync27(lockPath)) return null;
59201
59296
  try {
59202
- const lock = JSON.parse(readFileSync25(lockPath, "utf8"));
59297
+ const lock = JSON.parse(readFileSync26(lockPath, "utf8"));
59203
59298
  return typeof lock.pid === "number" ? lock : null;
59204
59299
  } catch {
59205
59300
  return null;
@@ -59487,12 +59582,12 @@ async function reanchorProject(opts) {
59487
59582
  init_registry();
59488
59583
 
59489
59584
  // src/adopt.ts
59490
- import { existsSync as existsSync27 } from "node:fs";
59491
- import { dirname as dirname10, join as join30 } from "node:path";
59585
+ import { existsSync as existsSync28 } from "node:fs";
59586
+ import { dirname as dirname10, join as join31 } from "node:path";
59492
59587
  function findGitRoot(absPath) {
59493
59588
  let dir = absPath;
59494
59589
  for (let depth = 0; depth < 64; depth++) {
59495
- if (existsSync27(join30(dir, ".git"))) return dir;
59590
+ if (existsSync28(join31(dir, ".git"))) return dir;
59496
59591
  const parent = dirname10(dir);
59497
59592
  if (parent === dir) return null;
59498
59593
  dir = parent;
@@ -59846,7 +59941,7 @@ async function startMultiDaemon(opts = {}) {
59846
59941
  app.route(`/ws/${rec.id}`, rec.webApp);
59847
59942
  }
59848
59943
  try {
59849
- writeFileSync21(
59944
+ writeFileSync22(
59850
59945
  rec.engine.paths.daemonLock,
59851
59946
  JSON.stringify({ pid: process.pid, webUiUrl: `${baseUrl}/ws/${rec.id}`, startedAt: Date.now() }),
59852
59947
  "utf8"
@@ -60044,7 +60139,7 @@ async function startMultiDaemon(opts = {}) {
60044
60139
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
60045
60140
  } catch {
60046
60141
  }
60047
- const reason = retireDecision({ exists: existsSync28(rec.root), lastActiveAt, now });
60142
+ const reason = retireDecision({ exists: existsSync29(rec.root), lastActiveAt, now });
60048
60143
  if (reason) void retireWorkspace(rec, reason);
60049
60144
  }
60050
60145
  };
@@ -60085,7 +60180,7 @@ async function startMultiDaemon(opts = {}) {
60085
60180
  baseUrl = `http://127.0.0.1:${port}`;
60086
60181
  try {
60087
60182
  ensureDir(globalDir());
60088
- writeFileSync21(
60183
+ writeFileSync22(
60089
60184
  lockPath,
60090
60185
  JSON.stringify({ pid: process.pid, webUiUrl: baseUrl, startedAt: Date.now() }),
60091
60186
  "utf8"
@@ -60094,7 +60189,7 @@ async function startMultiDaemon(opts = {}) {
60094
60189
  }
60095
60190
  for (const r of records) {
60096
60191
  try {
60097
- writeFileSync21(
60192
+ writeFileSync22(
60098
60193
  r.engine.paths.daemonLock,
60099
60194
  JSON.stringify({ pid: process.pid, webUiUrl: `${baseUrl}/ws/${r.id}`, startedAt: Date.now() }),
60100
60195
  "utf8"
@@ -60764,7 +60859,7 @@ async function startMultiDaemon(opts = {}) {
60764
60859
  async stop() {
60765
60860
  clearInterval(idleSweep);
60766
60861
  try {
60767
- const cur = readFileSync26(lockPath, "utf8");
60862
+ const cur = readFileSync27(lockPath, "utf8");
60768
60863
  if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
60769
60864
  } catch {
60770
60865
  }
@@ -61805,21 +61900,21 @@ async function cmdInit() {
61805
61900
  if (!skipHooks) {
61806
61901
  console.log("");
61807
61902
  console.log("installing harness hooks...");
61808
- const { existsSync: existsSync30 } = await import("node:fs");
61809
- const { join: join32 } = await import("node:path");
61903
+ const { existsSync: existsSync31 } = await import("node:fs");
61904
+ const { join: join33 } = await import("node:path");
61810
61905
  try {
61811
61906
  await installClaudeHooks(port);
61812
61907
  } catch (err2) {
61813
61908
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
61814
61909
  }
61815
- if (existsSync30(join32(ROOT, ".cursor"))) {
61910
+ if (existsSync31(join33(ROOT, ".cursor"))) {
61816
61911
  try {
61817
61912
  await installCursorMcpConfig();
61818
61913
  } catch (err2) {
61819
61914
  console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
61820
61915
  }
61821
61916
  }
61822
- if (existsSync30(join32(ROOT, ".codex"))) {
61917
+ if (existsSync31(join33(ROOT, ".codex"))) {
61823
61918
  try {
61824
61919
  await installCodexHooks(port);
61825
61920
  } catch (err2) {
@@ -61996,9 +62091,9 @@ async function cmdStatus() {
61996
62091
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
61997
62092
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
61998
62093
  }
61999
- console.log(` graph db: ${existsSync29(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
62000
- console.log(` event log: ${existsSync29(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
62001
- if (existsSync29(paths.castalia)) {
62094
+ console.log(` graph db: ${existsSync30(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
62095
+ console.log(` event log: ${existsSync30(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
62096
+ if (existsSync30(paths.castalia)) {
62002
62097
  try {
62003
62098
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
62004
62099
  const store = openGraphStore2({ path: paths.castalia });
@@ -62792,11 +62887,11 @@ function cmdInstallationProfile(args2) {
62792
62887
  }
62793
62888
  async function cmdReview() {
62794
62889
  const paths = workspacePaths(ROOT);
62795
- if (!existsSync29(paths.reviewQueue)) {
62890
+ if (!existsSync30(paths.reviewQueue)) {
62796
62891
  console.log("(review queue empty)");
62797
62892
  return;
62798
62893
  }
62799
- const queue = JSON.parse(readFileSync27(paths.reviewQueue, "utf8"));
62894
+ const queue = JSON.parse(readFileSync28(paths.reviewQueue, "utf8"));
62800
62895
  if (queue.length === 0) {
62801
62896
  console.log("(review queue empty)");
62802
62897
  return;
@@ -63467,7 +63562,7 @@ async function gatherRepo(store, ws) {
63467
63562
  };
63468
63563
  }
63469
63564
  async function gatherReportData(generatedAt) {
63470
- const { existsSync: existsSync30 } = await import("node:fs");
63565
+ const { existsSync: existsSync31 } = await import("node:fs");
63471
63566
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
63472
63567
  const cfg = loadConfig();
63473
63568
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -63475,7 +63570,7 @@ async function gatherReportData(generatedAt) {
63475
63570
  for (const ws of listWorkspaces()) {
63476
63571
  if (ws.missing) continue;
63477
63572
  const dbPath = workspacePaths(ws.path).castalia;
63478
- if (!existsSync30(dbPath)) continue;
63573
+ if (!existsSync31(dbPath)) continue;
63479
63574
  let store = null;
63480
63575
  try {
63481
63576
  store = openGraphStore2({ path: dbPath });
@@ -63506,7 +63601,7 @@ async function gatherReportData(generatedAt) {
63506
63601
  };
63507
63602
  }
63508
63603
  async function cmdReport(args2) {
63509
- const { mkdirSync: mkdirSync8, writeFileSync: writeFileSync22 } = await import("node:fs");
63604
+ const { mkdirSync: mkdirSync9, writeFileSync: writeFileSync23 } = await import("node:fs");
63510
63605
  const { renderReport: renderReport2 } = await Promise.resolve().then(() => (init_report_render(), report_render_exports));
63511
63606
  const includeFutureVerbs = args2.includes("--future-verbs");
63512
63607
  const now = /* @__PURE__ */ new Date();
@@ -63517,10 +63612,10 @@ async function cmdReport(args2) {
63517
63612
  process.exit(2);
63518
63613
  }
63519
63614
  const outDir = workspacePaths(ROOT).configDir;
63520
- mkdirSync8(outDir, { recursive: true });
63615
+ mkdirSync9(outDir, { recursive: true });
63521
63616
  const files = renderReport2(data, { includeFutureVerbs });
63522
- for (const f of files) writeFileSync22(join31(outDir, f.name), f.html, "utf8");
63523
- const indexPath = join31(outDir, "report.html");
63617
+ for (const f of files) writeFileSync23(join32(outDir, f.name), f.html, "utf8");
63618
+ const indexPath = join32(outDir, "report.html");
63524
63619
  console.log(`report \u2192 ${indexPath}`);
63525
63620
  console.log(
63526
63621
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -63572,7 +63667,7 @@ function spawnDaemonDetached() {
63572
63667
  try {
63573
63668
  const logPath = daemonLogPath();
63574
63669
  try {
63575
- if (statSync6(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
63670
+ if (statSync7(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
63576
63671
  } catch {
63577
63672
  }
63578
63673
  out2 = openSync2(logPath, "a");
@@ -63647,15 +63742,15 @@ function hookRelayCommand(port, path2) {
63647
63742
  return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 2 -X POST -H \\"Content-Type: application/json\\" --data-binary @- ${url2} 2>NUL || echo {}"` : `curl -s --connect-timeout 1 --max-time 2 -X POST -H 'Content-Type: application/json' --data-binary @- ${url2} 2>/dev/null || echo '{}'`;
63648
63743
  }
63649
63744
  async function installClaudeHooks(port) {
63650
- const { mkdirSync: mkdirSync8, existsSync: existsSync30, readFileSync: readFileSync28, writeFileSync: writeFileSync22 } = await import("node:fs");
63651
- const { join: join32 } = await import("node:path");
63652
- const dir = join32(ROOT, ".claude");
63653
- if (!existsSync30(dir)) mkdirSync8(dir, { recursive: true });
63654
- const file2 = join32(dir, "settings.json");
63745
+ const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
63746
+ const { join: join33 } = await import("node:path");
63747
+ const dir = join33(ROOT, ".claude");
63748
+ if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
63749
+ const file2 = join33(dir, "settings.json");
63655
63750
  let settings = {};
63656
- if (existsSync30(file2)) {
63751
+ if (existsSync31(file2)) {
63657
63752
  try {
63658
- settings = JSON.parse(readFileSync28(file2, "utf8"));
63753
+ settings = JSON.parse(readFileSync29(file2, "utf8"));
63659
63754
  } catch {
63660
63755
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
63661
63756
  process.exit(2);
@@ -63701,10 +63796,10 @@ async function installClaudeHooks(port) {
63701
63796
  dropErrata(list);
63702
63797
  list.push({ hooks: [{ type: "command", command: injectCmd }] });
63703
63798
  }
63704
- writeFileSync22(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
63799
+ writeFileSync23(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
63705
63800
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
63706
63801
  await installClaudeMcpConfig();
63707
- const claudeMd = join32(ROOT, "CLAUDE.md");
63802
+ const claudeMd = join33(ROOT, "CLAUDE.md");
63708
63803
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
63709
63804
  if (recall.kind === "collision") {
63710
63805
  console.warn(
@@ -63716,15 +63811,15 @@ async function installClaudeHooks(port) {
63716
63811
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
63717
63812
  }
63718
63813
  async function installClaudeMcpConfig() {
63719
- const { mkdirSync: mkdirSync8, existsSync: existsSync30, readFileSync: readFileSync28, writeFileSync: writeFileSync22 } = await import("node:fs");
63720
- const { join: join32, dirname: dirname11 } = await import("node:path");
63721
- const file2 = join32(ROOT, ".mcp.json");
63814
+ const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
63815
+ const { join: join33, dirname: dirname11 } = await import("node:path");
63816
+ const file2 = join33(ROOT, ".mcp.json");
63722
63817
  const dir = dirname11(file2);
63723
- if (!existsSync30(dir)) mkdirSync8(dir, { recursive: true });
63818
+ if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
63724
63819
  let cfg = {};
63725
- if (existsSync30(file2)) {
63820
+ if (existsSync31(file2)) {
63726
63821
  try {
63727
- cfg = JSON.parse(readFileSync28(file2, "utf8"));
63822
+ cfg = JSON.parse(readFileSync29(file2, "utf8"));
63728
63823
  } catch {
63729
63824
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
63730
63825
  process.exit(2);
@@ -63732,21 +63827,21 @@ async function installClaudeMcpConfig() {
63732
63827
  }
63733
63828
  cfg.mcpServers ??= {};
63734
63829
  cfg.mcpServers["errata"] = errataMcpInvocation();
63735
- writeFileSync22(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
63830
+ writeFileSync23(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
63736
63831
  console.log(`installed Claude Code MCP server config \u2192 ${file2}`);
63737
63832
  console.log(` Claude Code will spawn \`errata mcp\` on workspace open.`);
63738
63833
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
63739
63834
  }
63740
63835
  async function installCursorMcpConfig() {
63741
- const { mkdirSync: mkdirSync8, existsSync: existsSync30, readFileSync: readFileSync28, writeFileSync: writeFileSync22 } = await import("node:fs");
63742
- const { join: join32 } = await import("node:path");
63743
- const dir = join32(ROOT, ".cursor");
63744
- if (!existsSync30(dir)) mkdirSync8(dir, { recursive: true });
63745
- const file2 = join32(dir, "mcp.json");
63836
+ const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
63837
+ const { join: join33 } = await import("node:path");
63838
+ const dir = join33(ROOT, ".cursor");
63839
+ if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
63840
+ const file2 = join33(dir, "mcp.json");
63746
63841
  let cfg = {};
63747
- if (existsSync30(file2)) {
63842
+ if (existsSync31(file2)) {
63748
63843
  try {
63749
- cfg = JSON.parse(readFileSync28(file2, "utf8"));
63844
+ cfg = JSON.parse(readFileSync29(file2, "utf8"));
63750
63845
  } catch {
63751
63846
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
63752
63847
  process.exit(2);
@@ -63754,7 +63849,7 @@ async function installCursorMcpConfig() {
63754
63849
  }
63755
63850
  cfg.mcpServers ??= {};
63756
63851
  cfg.mcpServers["errata"] = errataMcpInvocation();
63757
- writeFileSync22(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
63852
+ writeFileSync23(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
63758
63853
  console.log(`installed Cursor MCP server config \u2192 ${file2}`);
63759
63854
  console.log(` Cursor will spawn \`errata mcp\` on workspace open.`);
63760
63855
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses`);
@@ -63762,16 +63857,16 @@ async function installCursorMcpConfig() {
63762
63857
  console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
63763
63858
  }
63764
63859
  async function installCodexHooks(port) {
63765
- const { mkdirSync: mkdirSync8, existsSync: existsSync30, readFileSync: readFileSync28, writeFileSync: writeFileSync22 } = await import("node:fs");
63766
- const { join: join32 } = await import("node:path");
63767
- const dir = join32(ROOT, ".codex");
63768
- if (!existsSync30(dir)) mkdirSync8(dir, { recursive: true });
63769
- const file2 = join32(dir, "config.toml");
63860
+ const { mkdirSync: mkdirSync9, existsSync: existsSync31, readFileSync: readFileSync29, writeFileSync: writeFileSync23 } = await import("node:fs");
63861
+ const { join: join33 } = await import("node:path");
63862
+ const dir = join33(ROOT, ".codex");
63863
+ if (!existsSync31(dir)) mkdirSync9(dir, { recursive: true });
63864
+ const file2 = join33(dir, "config.toml");
63770
63865
  const BEGIN = `# >>> errata hooks (errata-managed)`;
63771
63866
  const END = `# <<< errata hooks`;
63772
63867
  let existing = "";
63773
- if (existsSync30(file2)) {
63774
- existing = readFileSync28(file2, "utf8");
63868
+ if (existsSync31(file2)) {
63869
+ existing = readFileSync29(file2, "utf8");
63775
63870
  const beginIdx = existing.indexOf(BEGIN);
63776
63871
  const endIdx = existing.indexOf(END);
63777
63872
  if (beginIdx >= 0 && endIdx > beginIdx) {
@@ -63800,7 +63895,7 @@ ${END}
63800
63895
  const final = existing.length > 0 && !existing.endsWith("\n") ? `${existing}
63801
63896
 
63802
63897
  ${block}` : existing + (existing.endsWith("\n\n") ? "" : "\n") + block;
63803
- writeFileSync22(file2, final, "utf8");
63898
+ writeFileSync23(file2, final, "utf8");
63804
63899
  console.log(`installed Codex hooks \u2192 ${file2}`);
63805
63900
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
63806
63901
  console.log("");
@@ -64137,7 +64232,7 @@ async function cmdDash(args2) {
64137
64232
  await yieldToLoop2();
64138
64233
  try {
64139
64234
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile);
64140
- const res = bleedRules(join31(r.root, ".claude", "rules"), items);
64235
+ const res = bleedRules(join32(r.root, ".claude", "rules"), items);
64141
64236
  if (res.written || res.pruned) {
64142
64237
  console.log(
64143
64238
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")