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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/errata.mjs CHANGED
@@ -980,7 +980,7 @@ function lemma(token) {
980
980
  }
981
981
  return token;
982
982
  }
983
- function tokenize(text, resolve10) {
983
+ function tokenize(text, resolve11) {
984
984
  const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
985
985
  const out2 = /* @__PURE__ */ new Set();
986
986
  for (const raw2 of matches) {
@@ -990,7 +990,7 @@ function tokenize(text, resolve10) {
990
990
  out2.add(token);
991
991
  continue;
992
992
  }
993
- const canonical = resolve10(token);
993
+ const canonical = resolve11(token);
994
994
  out2.add(canonical ?? lemma(token));
995
995
  }
996
996
  return [...out2].sort();
@@ -24309,7 +24309,7 @@ function ingestDesignProblem(store, flag, opts) {
24309
24309
  ...existing.attrs,
24310
24310
  // An INDEPENDENT source re-deriving a resolved problem marks
24311
24311
  // immediately — that is the strongest recurrence evidence there is.
24312
- ...resolvedUnretracted ? recurAttrs() : {},
24312
+ ...resolvedUnretracted && !opts.replay ? recurAttrs() : {},
24313
24313
  sources: [...sources, opts.source],
24314
24314
  corroborations: corroborations2,
24315
24315
  ...promoted ? { provisional: false } : {},
@@ -24336,7 +24336,11 @@ function ingestDesignProblem(store, flag, opts) {
24336
24336
  lastUpdatedAt: opts.ts
24337
24337
  });
24338
24338
  if (recurredResolved) reopenedFromRegression = maybeReopenFromRegression(store, problemId, opts.ts);
24339
- } else if (resolvedUnretracted && opts.ts - (Number(existing.attrs["recurredAt"]) || 0) > RECURRENCE_DEBOUNCE_MS) {
24339
+ } else if (resolvedUnretracted && !opts.replay && // From the later of the last recurrence and the close itself: before the
24340
+ // first recurrence there is no recurredAt, and measuring from 0 booked the
24341
+ // resolving session's own turn-final restatement — seconds after its fix —
24342
+ // as the problem coming back (15 of 19 recurrences on the arena store).
24343
+ opts.ts - Math.max(Number(existing.attrs["recurredAt"]) || 0, Number(existing.attrs["resolvedAt"]) || 0) > RECURRENCE_DEBOUNCE_MS) {
24340
24344
  store.updateNode(problemId, {
24341
24345
  attrs: { ...existing.attrs, ...recurAttrs() },
24342
24346
  lastUpdatedAt: opts.ts
@@ -37163,7 +37167,7 @@ async function waitForDaemonExit(lock, timeoutMs, pollMs = 200) {
37163
37167
  for (; ; ) {
37164
37168
  if (daemonLockState(lock, true) === "stale") return true;
37165
37169
  if (Date.now() >= deadline) return false;
37166
- await new Promise((resolve10) => setTimeout(resolve10, pollMs));
37170
+ await new Promise((resolve11) => setTimeout(resolve11, pollMs));
37167
37171
  }
37168
37172
  }
37169
37173
  function releaseOwnLock(lockPath) {
@@ -41249,13 +41253,13 @@ async function Module2(moduleArg = {}) {
41249
41253
  }
41250
41254
  readAsync = /* @__PURE__ */ __name(async (url2) => {
41251
41255
  if (isFileURI(url2)) {
41252
- return new Promise((resolve10, reject) => {
41256
+ return new Promise((resolve11, reject) => {
41253
41257
  var xhr = new XMLHttpRequest();
41254
41258
  xhr.open("GET", url2, true);
41255
41259
  xhr.responseType = "arraybuffer";
41256
41260
  xhr.onload = () => {
41257
41261
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
41258
- resolve10(xhr.response);
41262
+ resolve11(xhr.response);
41259
41263
  return;
41260
41264
  }
41261
41265
  reject(xhr.status);
@@ -41451,9 +41455,9 @@ async function Module2(moduleArg = {}) {
41451
41455
  __name(receiveInstantiationResult, "receiveInstantiationResult");
41452
41456
  var info2 = getWasmImports();
41453
41457
  if (Module["instantiateWasm"]) {
41454
- return new Promise((resolve10, reject) => {
41458
+ return new Promise((resolve11, reject) => {
41455
41459
  Module["instantiateWasm"](info2, (mod, inst) => {
41456
- resolve10(receiveInstance(mod, inst));
41460
+ resolve11(receiveInstance(mod, inst));
41457
41461
  });
41458
41462
  });
41459
41463
  }
@@ -42784,8 +42788,8 @@ async function Module2(moduleArg = {}) {
42784
42788
  if (runtimeInitialized) {
42785
42789
  moduleRtn = Module;
42786
42790
  } else {
42787
- moduleRtn = new Promise((resolve10, reject) => {
42788
- readyPromiseResolve = resolve10;
42791
+ moduleRtn = new Promise((resolve11, reject) => {
42792
+ readyPromiseResolve = resolve11;
42789
42793
  readyPromiseReject = reject;
42790
42794
  });
42791
42795
  }
@@ -48120,7 +48124,7 @@ async function findStaleFiles(store, rootPath, workspaceId2, lineageVerifiedAt)
48120
48124
  }
48121
48125
  if (++scanned % SCAN_YIELD_EVERY === 0) {
48122
48126
  check2();
48123
- await new Promise((resolve10) => setImmediate(resolve10));
48127
+ await new Promise((resolve11) => setImmediate(resolve11));
48124
48128
  }
48125
48129
  }
48126
48130
  check2();
@@ -58815,7 +58819,7 @@ function buildWebUi(deps) {
58815
58819
  const transcriptPath = String(body2["transcript_path"] ?? "");
58816
58820
  const sessionId = String(body2["session_id"] ?? "");
58817
58821
  if (transcriptPath && deps.onTurn) {
58818
- deps.onTurn({ sessionId, transcriptPath });
58822
+ deps.onTurn({ sessionId, transcriptPath, ...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {} });
58819
58823
  }
58820
58824
  if (body2["hook_event_name"] === "SubagentStop" && typeof body2["agent_id"] === "string" && body2["agent_id"]) {
58821
58825
  deps.onSubagentStop?.(body2["agent_id"]);
@@ -58845,7 +58849,8 @@ function buildWebUi(deps) {
58845
58849
  sessionId,
58846
58850
  text: whole.text,
58847
58851
  ...messageId ? { messageId } : {},
58848
- ...agentId ? { agentId } : {}
58852
+ ...agentId ? { agentId } : {},
58853
+ ...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {}
58849
58854
  });
58850
58855
  }
58851
58856
  return c.json({ ok: true, ...whole === null ? { buffered: true } : {} });
@@ -61514,9 +61519,9 @@ var require_dispatcher_base = __commonJS({
61514
61519
  }
61515
61520
  close(callback) {
61516
61521
  if (callback === void 0) {
61517
- return new Promise((resolve10, reject) => {
61522
+ return new Promise((resolve11, reject) => {
61518
61523
  this.close((err2, data) => {
61519
- return err2 ? reject(err2) : resolve10(data);
61524
+ return err2 ? reject(err2) : resolve11(data);
61520
61525
  });
61521
61526
  });
61522
61527
  }
@@ -61554,12 +61559,12 @@ var require_dispatcher_base = __commonJS({
61554
61559
  err2 = null;
61555
61560
  }
61556
61561
  if (callback === void 0) {
61557
- return new Promise((resolve10, reject) => {
61562
+ return new Promise((resolve11, reject) => {
61558
61563
  this.destroy(err2, (err3, data) => {
61559
61564
  return err3 ? (
61560
61565
  /* istanbul ignore next: should never error */
61561
61566
  reject(err3)
61562
- ) : resolve10(data);
61567
+ ) : resolve11(data);
61563
61568
  });
61564
61569
  });
61565
61570
  }
@@ -63826,8 +63831,8 @@ var require_util2 = __commonJS({
63826
63831
  function createDeferredPromise() {
63827
63832
  let res;
63828
63833
  let rej;
63829
- const promise2 = new Promise((resolve10, reject) => {
63830
- res = resolve10;
63834
+ const promise2 = new Promise((resolve11, reject) => {
63835
+ res = resolve11;
63831
63836
  rej = reject;
63832
63837
  });
63833
63838
  return { promise: promise2, resolve: res, reject: rej };
@@ -65968,12 +65973,12 @@ upgrade: ${upgrade}\r
65968
65973
  cb();
65969
65974
  }
65970
65975
  }
65971
- const waitForDrain = () => new Promise((resolve10, reject) => {
65976
+ const waitForDrain = () => new Promise((resolve11, reject) => {
65972
65977
  assert2(callback === null);
65973
65978
  if (socket[kError]) {
65974
65979
  reject(socket[kError]);
65975
65980
  } else {
65976
- callback = resolve10;
65981
+ callback = resolve11;
65977
65982
  }
65978
65983
  });
65979
65984
  socket.on("close", onDrain).on("drain", onDrain);
@@ -66610,12 +66615,12 @@ var require_client_h2 = __commonJS({
66610
66615
  cb();
66611
66616
  }
66612
66617
  }
66613
- const waitForDrain = () => new Promise((resolve10, reject) => {
66618
+ const waitForDrain = () => new Promise((resolve11, reject) => {
66614
66619
  assert2(callback === null);
66615
66620
  if (socket[kError]) {
66616
66621
  reject(socket[kError]);
66617
66622
  } else {
66618
- callback = resolve10;
66623
+ callback = resolve11;
66619
66624
  }
66620
66625
  });
66621
66626
  h2stream.on("close", onDrain).on("drain", onDrain);
@@ -67092,16 +67097,16 @@ var require_client = __commonJS({
67092
67097
  return this[kNeedDrain] < 2;
67093
67098
  }
67094
67099
  async [kClose]() {
67095
- return new Promise((resolve10) => {
67100
+ return new Promise((resolve11) => {
67096
67101
  if (this[kSize]) {
67097
- this[kClosedResolve] = resolve10;
67102
+ this[kClosedResolve] = resolve11;
67098
67103
  } else {
67099
- resolve10(null);
67104
+ resolve11(null);
67100
67105
  }
67101
67106
  });
67102
67107
  }
67103
67108
  async [kDestroy](err2) {
67104
- return new Promise((resolve10) => {
67109
+ return new Promise((resolve11) => {
67105
67110
  const requests = this[kQueue].splice(this[kPendingIdx]);
67106
67111
  for (let i2 = 0; i2 < requests.length; i2++) {
67107
67112
  const request = requests[i2];
@@ -67112,7 +67117,7 @@ var require_client = __commonJS({
67112
67117
  this[kClosedResolve]();
67113
67118
  this[kClosedResolve] = null;
67114
67119
  }
67115
- resolve10(null);
67120
+ resolve11(null);
67116
67121
  };
67117
67122
  if (this[kHTTPContext]) {
67118
67123
  this[kHTTPContext].destroy(err2, callback);
@@ -67163,7 +67168,7 @@ var require_client = __commonJS({
67163
67168
  });
67164
67169
  }
67165
67170
  try {
67166
- const socket = await new Promise((resolve10, reject) => {
67171
+ const socket = await new Promise((resolve11, reject) => {
67167
67172
  client[kConnector]({
67168
67173
  host,
67169
67174
  hostname: hostname3,
@@ -67175,7 +67180,7 @@ var require_client = __commonJS({
67175
67180
  if (err2) {
67176
67181
  reject(err2);
67177
67182
  } else {
67178
- resolve10(socket2);
67183
+ resolve11(socket2);
67179
67184
  }
67180
67185
  });
67181
67186
  });
@@ -67511,8 +67516,8 @@ var require_pool_base = __commonJS({
67511
67516
  if (this[kQueue].isEmpty()) {
67512
67517
  await Promise.all(this[kClients].map((c) => c.close()));
67513
67518
  } else {
67514
- await new Promise((resolve10) => {
67515
- this[kClosedResolve] = resolve10;
67519
+ await new Promise((resolve11) => {
67520
+ this[kClosedResolve] = resolve11;
67516
67521
  });
67517
67522
  }
67518
67523
  }
@@ -68727,7 +68732,7 @@ var require_readable = __commonJS({
68727
68732
  if (this._readableState.closeEmitted) {
68728
68733
  return null;
68729
68734
  }
68730
- return await new Promise((resolve10, reject) => {
68735
+ return await new Promise((resolve11, reject) => {
68731
68736
  if (this[kContentLength] > limit) {
68732
68737
  this.destroy(new AbortError());
68733
68738
  }
@@ -68740,7 +68745,7 @@ var require_readable = __commonJS({
68740
68745
  if (signal?.aborted) {
68741
68746
  reject(signal.reason ?? new AbortError());
68742
68747
  } else {
68743
- resolve10(null);
68748
+ resolve11(null);
68744
68749
  }
68745
68750
  }).on("error", noop).on("data", function(chunk) {
68746
68751
  limit -= chunk.length;
@@ -68759,7 +68764,7 @@ var require_readable = __commonJS({
68759
68764
  }
68760
68765
  async function consume(stream, type) {
68761
68766
  assert2(!stream[kConsume]);
68762
- return new Promise((resolve10, reject) => {
68767
+ return new Promise((resolve11, reject) => {
68763
68768
  if (isUnusable(stream)) {
68764
68769
  const rState = stream._readableState;
68765
68770
  if (rState.destroyed && rState.closeEmitted === false) {
@@ -68776,7 +68781,7 @@ var require_readable = __commonJS({
68776
68781
  stream[kConsume] = {
68777
68782
  type,
68778
68783
  stream,
68779
- resolve: resolve10,
68784
+ resolve: resolve11,
68780
68785
  reject,
68781
68786
  length: 0,
68782
68787
  body: []
@@ -68846,18 +68851,18 @@ var require_readable = __commonJS({
68846
68851
  return buffer;
68847
68852
  }
68848
68853
  function consumeEnd(consume2) {
68849
- const { type, body: body2, resolve: resolve10, stream, length } = consume2;
68854
+ const { type, body: body2, resolve: resolve11, stream, length } = consume2;
68850
68855
  try {
68851
68856
  if (type === "text") {
68852
- resolve10(chunksDecode(body2, length));
68857
+ resolve11(chunksDecode(body2, length));
68853
68858
  } else if (type === "json") {
68854
- resolve10(JSON.parse(chunksDecode(body2, length)));
68859
+ resolve11(JSON.parse(chunksDecode(body2, length)));
68855
68860
  } else if (type === "arrayBuffer") {
68856
- resolve10(chunksConcat(body2, length).buffer);
68861
+ resolve11(chunksConcat(body2, length).buffer);
68857
68862
  } else if (type === "blob") {
68858
- resolve10(new Blob(body2, { type: stream[kContentType] }));
68863
+ resolve11(new Blob(body2, { type: stream[kContentType] }));
68859
68864
  } else if (type === "bytes") {
68860
- resolve10(chunksConcat(body2, length));
68865
+ resolve11(chunksConcat(body2, length));
68861
68866
  }
68862
68867
  consumeFinish(consume2);
68863
68868
  } catch (err2) {
@@ -69114,9 +69119,9 @@ var require_api_request = __commonJS({
69114
69119
  };
69115
69120
  function request(opts, callback) {
69116
69121
  if (callback === void 0) {
69117
- return new Promise((resolve10, reject) => {
69122
+ return new Promise((resolve11, reject) => {
69118
69123
  request.call(this, opts, (err2, data) => {
69119
- return err2 ? reject(err2) : resolve10(data);
69124
+ return err2 ? reject(err2) : resolve11(data);
69120
69125
  });
69121
69126
  });
69122
69127
  }
@@ -69339,9 +69344,9 @@ var require_api_stream = __commonJS({
69339
69344
  };
69340
69345
  function stream(opts, factory, callback) {
69341
69346
  if (callback === void 0) {
69342
- return new Promise((resolve10, reject) => {
69347
+ return new Promise((resolve11, reject) => {
69343
69348
  stream.call(this, opts, factory, (err2, data) => {
69344
- return err2 ? reject(err2) : resolve10(data);
69349
+ return err2 ? reject(err2) : resolve11(data);
69345
69350
  });
69346
69351
  });
69347
69352
  }
@@ -69626,9 +69631,9 @@ var require_api_upgrade = __commonJS({
69626
69631
  };
69627
69632
  function upgrade(opts, callback) {
69628
69633
  if (callback === void 0) {
69629
- return new Promise((resolve10, reject) => {
69634
+ return new Promise((resolve11, reject) => {
69630
69635
  upgrade.call(this, opts, (err2, data) => {
69631
- return err2 ? reject(err2) : resolve10(data);
69636
+ return err2 ? reject(err2) : resolve11(data);
69632
69637
  });
69633
69638
  });
69634
69639
  }
@@ -69720,9 +69725,9 @@ var require_api_connect = __commonJS({
69720
69725
  };
69721
69726
  function connect(opts, callback) {
69722
69727
  if (callback === void 0) {
69723
- return new Promise((resolve10, reject) => {
69728
+ return new Promise((resolve11, reject) => {
69724
69729
  connect.call(this, opts, (err2, data) => {
69725
- return err2 ? reject(err2) : resolve10(data);
69730
+ return err2 ? reject(err2) : resolve11(data);
69726
69731
  });
69727
69732
  });
69728
69733
  }
@@ -73584,7 +73589,7 @@ var require_fetch = __commonJS({
73584
73589
  function dispatch({ body: body2 }) {
73585
73590
  const url2 = requestCurrentURL(request);
73586
73591
  const agent = fetchParams.controller.dispatcher;
73587
- return new Promise((resolve10, reject) => agent.dispatch(
73592
+ return new Promise((resolve11, reject) => agent.dispatch(
73588
73593
  {
73589
73594
  path: url2.pathname + url2.search,
73590
73595
  origin: url2.origin,
@@ -73660,7 +73665,7 @@ var require_fetch = __commonJS({
73660
73665
  }
73661
73666
  }
73662
73667
  const onError = this.onError.bind(this);
73663
- resolve10({
73668
+ resolve11({
73664
73669
  status,
73665
73670
  statusText,
73666
73671
  headersList,
@@ -73706,7 +73711,7 @@ var require_fetch = __commonJS({
73706
73711
  for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
73707
73712
  headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
73708
73713
  }
73709
- resolve10({
73714
+ resolve11({
73710
73715
  status,
73711
73716
  statusText: STATUS_CODES[status],
73712
73717
  headersList,
@@ -77345,8 +77350,8 @@ var require_util8 = __commonJS({
77345
77350
  return true;
77346
77351
  }
77347
77352
  function delay(ms) {
77348
- return new Promise((resolve10) => {
77349
- setTimeout(resolve10, ms).unref();
77353
+ return new Promise((resolve11) => {
77354
+ setTimeout(resolve11, ms).unref();
77350
77355
  });
77351
77356
  }
77352
77357
  module2.exports = {
@@ -78034,16 +78039,16 @@ __export(witness_ledger_exports, {
78034
78039
  summarizeWitnessLedger: () => summarizeWitnessLedger,
78035
78040
  witnessLedgerPath: () => witnessLedgerPath
78036
78041
  });
78037
- import { appendFileSync as appendFileSync3, existsSync as existsSync27, readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
78038
- import { join as join35 } from "node:path";
78042
+ import { appendFileSync as appendFileSync3, existsSync as existsSync28, readFileSync as readFileSync32, writeFileSync as writeFileSync22 } from "node:fs";
78043
+ import { join as join36 } from "node:path";
78039
78044
  function witnessLedgerPath(configDir) {
78040
- return join35(configDir, "witness-ledger.jsonl");
78045
+ return join36(configDir, "witness-ledger.jsonl");
78041
78046
  }
78042
78047
  function appendWitnessLedger(configDir, entry) {
78043
78048
  const path3 = witnessLedgerPath(configDir);
78044
78049
  try {
78045
78050
  appendFileSync3(path3, JSON.stringify(entry) + "\n");
78046
- const lines = readFileSync31(path3, "utf8").split("\n").filter(Boolean);
78051
+ const lines = readFileSync32(path3, "utf8").split("\n").filter(Boolean);
78047
78052
  if (lines.length > LEDGER_MAX_LINES) {
78048
78053
  writeFileSync22(path3, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
78049
78054
  }
@@ -78052,9 +78057,9 @@ function appendWitnessLedger(configDir, entry) {
78052
78057
  }
78053
78058
  function readWitnessLedger(configDir) {
78054
78059
  const path3 = witnessLedgerPath(configDir);
78055
- if (!existsSync27(path3)) return [];
78060
+ if (!existsSync28(path3)) return [];
78056
78061
  try {
78057
- return readFileSync31(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
78062
+ return readFileSync32(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
78058
78063
  } catch {
78059
78064
  return [];
78060
78065
  }
@@ -78493,12 +78498,12 @@ var init_report_render = __esm({
78493
78498
 
78494
78499
  // src/cli.ts
78495
78500
  init_src6();
78496
- import { closeSync as closeSync3, existsSync as existsSync40, openSync as openSync3, readFileSync as readFileSync48, renameSync as renameSync10, statSync as statSync16 } from "node:fs";
78497
- import { join as join56, resolve as pathResolve2 } from "node:path";
78501
+ import { closeSync as closeSync3, existsSync as existsSync41, openSync as openSync3, readFileSync as readFileSync49, renameSync as renameSync10, statSync as statSync17 } from "node:fs";
78502
+ import { join as join57, resolve as pathResolve2 } from "node:path";
78498
78503
  import { spawn as spawn5 } from "node:child_process";
78499
78504
 
78500
78505
  // src/daemon.ts
78501
- import { existsSync as existsSync29, writeFileSync as writeFileSync25 } from "node:fs";
78506
+ import { existsSync as existsSync30, writeFileSync as writeFileSync25 } from "node:fs";
78502
78507
 
78503
78508
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.34/node_modules/@hono/node-server/dist/index.mjs
78504
78509
  import { createServer as createServerHTTP } from "http";
@@ -78928,7 +78933,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
78928
78933
  });
78929
78934
  if (!chunk) {
78930
78935
  if (i2 === 1) {
78931
- await new Promise((resolve10) => setTimeout(resolve10));
78936
+ await new Promise((resolve11) => setTimeout(resolve11));
78932
78937
  maxReadCount = 3;
78933
78938
  continue;
78934
78939
  }
@@ -79077,6 +79082,32 @@ init_webui();
79077
79082
  init_config();
79078
79083
  init_lock();
79079
79084
 
79085
+ // src/replay-checkout.ts
79086
+ import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync7 } from "node:fs";
79087
+ import { dirname as dirname9, isAbsolute as isAbsolute4, join as join19, resolve as resolve6 } from "node:path";
79088
+ var REPLAY_MARKER = "errata-replay";
79089
+ function gitDirOf(cwd) {
79090
+ for (let dir = resolve6(cwd); ; dir = dirname9(dir)) {
79091
+ const dotGit = join19(dir, ".git");
79092
+ if (existsSync19(dotGit)) {
79093
+ try {
79094
+ if (statSync7(dotGit).isDirectory()) return dotGit;
79095
+ const m = /^gitdir:\s*(.+)$/m.exec(readFileSync18(dotGit, "utf8"));
79096
+ if (!m) return null;
79097
+ const target = m[1].trim();
79098
+ return isAbsolute4(target) ? target : resolve6(dir, target);
79099
+ } catch {
79100
+ return null;
79101
+ }
79102
+ }
79103
+ if (dirname9(dir) === dir) return null;
79104
+ }
79105
+ }
79106
+ function isReplayCheckout(cwd) {
79107
+ const gitDir = gitDirOf(cwd);
79108
+ return gitDir != null && existsSync19(join19(gitDir, REPLAY_MARKER));
79109
+ }
79110
+
79080
79111
  // src/activity-feed.ts
79081
79112
  var LABEL_MAX = 120;
79082
79113
  var DEFAULT_TAIL = 20;
@@ -79182,8 +79213,8 @@ function knowledgeTag(label, attrs) {
79182
79213
 
79183
79214
  // src/engine.ts
79184
79215
  import { execFileSync as execFileSync6 } from "node:child_process";
79185
- import { existsSync as existsSync28, statSync as statSync11, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync33, writeFileSync as writeFileSync24 } from "node:fs";
79186
- import { basename as basename8, join as join37, relative as relative6, sep as sep5 } from "node:path";
79216
+ import { existsSync as existsSync29, statSync as statSync12, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync34, writeFileSync as writeFileSync24 } from "node:fs";
79217
+ import { basename as basename8, join as join38, relative as relative6, sep as sep5 } from "node:path";
79187
79218
 
79188
79219
  // src/coalesced-file-pass.ts
79189
79220
  function createCoalescedFilePass(delayMs, run3, onError) {
@@ -79227,8 +79258,8 @@ function createCoalescedFilePass(delayMs, run3, onError) {
79227
79258
 
79228
79259
  // src/source-watcher.ts
79229
79260
  import { EventEmitter as EventEmitter2 } from "node:events";
79230
- import { readdirSync as readdirSync6, statSync as statSync7, watch as watch2 } from "node:fs";
79231
- import { join as join21, sep as sep4 } from "node:path";
79261
+ import { readdirSync as readdirSync6, statSync as statSync8, watch as watch2 } from "node:fs";
79262
+ import { join as join22, sep as sep4 } from "node:path";
79232
79263
 
79233
79264
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
79234
79265
  import { stat as statcb } from "fs";
@@ -79959,9 +79990,9 @@ var NodeFsHandler = class {
79959
79990
  if (this.fsw.closed) {
79960
79991
  return;
79961
79992
  }
79962
- const dirname21 = sysPath.dirname(file2);
79993
+ const dirname22 = sysPath.dirname(file2);
79963
79994
  const basename11 = sysPath.basename(file2);
79964
- const parent = this.fsw._getWatchedDir(dirname21);
79995
+ const parent = this.fsw._getWatchedDir(dirname22);
79965
79996
  let prevStats = stats;
79966
79997
  if (parent.has(basename11))
79967
79998
  return;
@@ -79988,7 +80019,7 @@ var NodeFsHandler = class {
79988
80019
  prevStats = newStats2;
79989
80020
  }
79990
80021
  } catch (error48) {
79991
- this.fsw._remove(dirname21, basename11);
80022
+ this.fsw._remove(dirname22, basename11);
79992
80023
  }
79993
80024
  } else if (parent.has(basename11)) {
79994
80025
  const at = newStats.atimeMs;
@@ -80084,7 +80115,7 @@ var NodeFsHandler = class {
80084
80115
  this._addToNodeFs(path3, initialAdd, wh, depth + 1);
80085
80116
  }
80086
80117
  }).on(EV.ERROR, this._boundHandleError);
80087
- return new Promise((resolve10, reject) => {
80118
+ return new Promise((resolve11, reject) => {
80088
80119
  if (!stream)
80089
80120
  return reject();
80090
80121
  stream.once(STR_END, () => {
@@ -80093,7 +80124,7 @@ var NodeFsHandler = class {
80093
80124
  return;
80094
80125
  }
80095
80126
  const wasThrottled = throttler ? throttler.clear() : false;
80096
- resolve10(void 0);
80127
+ resolve11(void 0);
80097
80128
  previous.getChildren().filter((item2) => {
80098
80129
  return item2 !== directory && !current.has(item2);
80099
80130
  }).forEach((item2) => {
@@ -80958,13 +80989,13 @@ var NativeSourceWatcher = class extends EventEmitter2 {
80958
80989
  if (this.closed || this.handles.has(target)) return;
80959
80990
  let isDir;
80960
80991
  try {
80961
- isDir = statSync7(target).isDirectory();
80992
+ isDir = statSync8(target).isDirectory();
80962
80993
  } catch {
80963
80994
  return;
80964
80995
  }
80965
80996
  try {
80966
80997
  const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
80967
- const path3 = isDir ? name2 ? join21(target, name2.toString()) : null : target;
80998
+ const path3 = isDir ? name2 ? join22(target, name2.toString()) : null : target;
80968
80999
  if (!path3) {
80969
81000
  this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
80970
81001
  this.scheduleReconcile(target, isDir);
@@ -81012,7 +81043,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81012
81043
  const files = /* @__PURE__ */ new Map();
81013
81044
  const add = (path3) => {
81014
81045
  try {
81015
- files.set(path3, signature(statSync7(path3)));
81046
+ files.set(path3, signature(statSync8(path3)));
81016
81047
  } catch {
81017
81048
  }
81018
81049
  };
@@ -81030,7 +81061,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81030
81061
  continue;
81031
81062
  }
81032
81063
  for (const entry of entries) {
81033
- const path3 = join21(dir, entry.name);
81064
+ const path3 = join22(dir, entry.name);
81034
81065
  if (this.ignored(path3)) continue;
81035
81066
  if (entry.isDirectory()) dirs.push(path3);
81036
81067
  else if (entry.isFile()) add(path3);
@@ -81067,7 +81098,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
81067
81098
  let isFile;
81068
81099
  let sig;
81069
81100
  try {
81070
- const s = statSync7(path3);
81101
+ const s = statSync8(path3);
81071
81102
  if (s.isDirectory()) return;
81072
81103
  isFile = s.isFile();
81073
81104
  sig = signature(s);
@@ -81341,9 +81372,9 @@ init_src6();
81341
81372
  init_session_registry();
81342
81373
 
81343
81374
  // src/snapshot-reuse.ts
81344
- import { readFileSync as readFileSync18, renameSync as renameSync3, statSync as statSync8, writeFileSync as writeFileSync14 } from "node:fs";
81375
+ import { readFileSync as readFileSync19, renameSync as renameSync3, statSync as statSync9, writeFileSync as writeFileSync14 } from "node:fs";
81345
81376
  import { fileURLToPath as fileURLToPath2 } from "node:url";
81346
- import { dirname as dirname11, join as join22 } from "node:path";
81377
+ import { dirname as dirname12, join as join23 } from "node:path";
81347
81378
  function revisitFlagsUnchanged(store, held, flaggedNow) {
81348
81379
  if (held.anySeq === void 0 || held.revisitIds === void 0 || !store.changedAmong) return false;
81349
81380
  const watched = [.../* @__PURE__ */ new Set([...held.revisitIds, ...flaggedNow])];
@@ -81359,7 +81390,7 @@ function snapshotCodeIdentity(version3) {
81359
81390
  if (codeIdentityMemo === void 0) {
81360
81391
  let built = "unknown";
81361
81392
  try {
81362
- built = String(statSync8(fileURLToPath2(import.meta.url)).mtimeMs);
81393
+ built = String(statSync9(fileURLToPath2(import.meta.url)).mtimeMs);
81363
81394
  } catch {
81364
81395
  }
81365
81396
  codeIdentityMemo = `${version3}@${built}`;
@@ -81367,11 +81398,11 @@ function snapshotCodeIdentity(version3) {
81367
81398
  return codeIdentityMemo;
81368
81399
  }
81369
81400
  function heldSnapshotPath(configDir) {
81370
- return join22(configDir, "snapshot-held.json");
81401
+ return join23(configDir, "snapshot-held.json");
81371
81402
  }
81372
81403
  function loadHeldSnapshot(path3) {
81373
81404
  try {
81374
- const held = JSON.parse(readFileSync18(path3, "utf8"));
81405
+ const held = JSON.parse(readFileSync19(path3, "utf8"));
81375
81406
  return typeof held?.key === "string" && typeof held.at === "number" ? held : null;
81376
81407
  } catch {
81377
81408
  return null;
@@ -81379,7 +81410,7 @@ function loadHeldSnapshot(path3) {
81379
81410
  }
81380
81411
  function saveHeldSnapshot(path3, held) {
81381
81412
  try {
81382
- const tmp = join22(dirname11(path3), `.${process.pid}.snapshot-held.tmp`);
81413
+ const tmp = join23(dirname12(path3), `.${process.pid}.snapshot-held.tmp`);
81383
81414
  writeFileSync14(tmp, JSON.stringify(held));
81384
81415
  renameSync3(tmp, path3);
81385
81416
  } catch {
@@ -81575,8 +81606,8 @@ init_review2();
81575
81606
 
81576
81607
  // src/turn.ts
81577
81608
  init_checkout_root();
81578
- import { closeSync as closeSync2, existsSync as existsSync19, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync9 } from "node:fs";
81579
- import { basename as basename6, delimiter, dirname as dirname12, join as join23, normalize as normalize3 } from "node:path";
81609
+ import { closeSync as closeSync2, existsSync as existsSync20, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
81610
+ import { basename as basename6, delimiter, dirname as dirname13, join as join24, normalize as normalize3 } from "node:path";
81580
81611
  import { homedir as homedir4 } from "node:os";
81581
81612
  import { createHash as createHash16 } from "node:crypto";
81582
81613
  function completeJsonlPrefix(buf) {
@@ -81964,11 +81995,11 @@ function turnsSince(turns, mark) {
81964
81995
  return at >= 0 ? turns.slice(at + 1) : turns;
81965
81996
  }
81966
81997
  function claudeProjectDir(cwd, home = homedir4()) {
81967
- return join23(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
81998
+ return join24(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
81968
81999
  }
81969
82000
  function recentTranscripts(cwd, opts = {}) {
81970
82001
  const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
81971
- if (!existsSync19(dir)) return [];
82002
+ if (!existsSync20(dir)) return [];
81972
82003
  let names;
81973
82004
  try {
81974
82005
  names = readdirSync7(dir);
@@ -81979,10 +82010,10 @@ function recentTranscripts(cwd, opts = {}) {
81979
82010
  const refs = [];
81980
82011
  for (const name2 of names) {
81981
82012
  if (!name2.endsWith(".jsonl")) continue;
81982
- const path3 = join23(dir, name2);
82013
+ const path3 = join24(dir, name2);
81983
82014
  let mtimeMs;
81984
82015
  try {
81985
- mtimeMs = statSync9(path3).mtimeMs;
82016
+ mtimeMs = statSync10(path3).mtimeMs;
81986
82017
  } catch {
81987
82018
  continue;
81988
82019
  }
@@ -81994,8 +82025,8 @@ function recentTranscripts(cwd, opts = {}) {
81994
82025
  }
81995
82026
  function subagentTranscripts(mainTranscriptPath, sessionId) {
81996
82027
  if (!mainTranscriptPath || !sessionId) return [];
81997
- const dir = join23(dirname12(mainTranscriptPath), sessionId, "subagents");
81998
- if (!existsSync19(dir)) return [];
82028
+ const dir = join24(dirname13(mainTranscriptPath), sessionId, "subagents");
82029
+ if (!existsSync20(dir)) return [];
81999
82030
  let names;
82000
82031
  try {
82001
82032
  names = readdirSync7(dir);
@@ -82005,10 +82036,10 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
82005
82036
  const refs = [];
82006
82037
  for (const name2 of names) {
82007
82038
  if (!name2.endsWith(".jsonl")) continue;
82008
- const path3 = join23(dir, name2);
82039
+ const path3 = join24(dir, name2);
82009
82040
  let mtimeMs;
82010
82041
  try {
82011
- mtimeMs = statSync9(path3).mtimeMs;
82042
+ mtimeMs = statSync10(path3).mtimeMs;
82012
82043
  } catch {
82013
82044
  continue;
82014
82045
  }
@@ -82024,8 +82055,8 @@ function splitPathList(value, sep7 = delimiter) {
82024
82055
  function codexSessionRoots(env2 = process.env, home = homedir4()) {
82025
82056
  const roots = /* @__PURE__ */ new Set();
82026
82057
  for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
82027
- if (env2["CODEX_HOME"]) roots.add(join23(env2["CODEX_HOME"], "sessions"));
82028
- roots.add(join23(home, ".codex", "sessions"));
82058
+ if (env2["CODEX_HOME"]) roots.add(join24(env2["CODEX_HOME"], "sessions"));
82059
+ roots.add(join24(home, ".codex", "sessions"));
82029
82060
  return [...roots];
82030
82061
  }
82031
82062
  function readCodexRolloutIdentity(path3) {
@@ -82079,7 +82110,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82079
82110
  const owner = checkoutRootOf(cwd);
82080
82111
  const owners = /* @__PURE__ */ new Map();
82081
82112
  for (const root of codexSessionRoots(opts.env, opts.home)) {
82082
- if (!existsSync19(root)) {
82113
+ if (!existsSync20(root)) {
82083
82114
  codexRolloutActivity.delete(root);
82084
82115
  continue;
82085
82116
  }
@@ -82097,10 +82128,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82097
82128
  continue;
82098
82129
  }
82099
82130
  for (const name2 of names) {
82100
- const full = join23(dir, name2);
82131
+ const full = join24(dir, name2);
82101
82132
  let st;
82102
82133
  try {
82103
- st = statSync9(full);
82134
+ st = statSync10(full);
82104
82135
  } catch {
82105
82136
  continue;
82106
82137
  }
@@ -82139,8 +82170,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
82139
82170
  function geminiSessionRoots(env2 = process.env, home = homedir4()) {
82140
82171
  const roots = /* @__PURE__ */ new Set();
82141
82172
  for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
82142
- if (env2["GEMINI_CLI_HOME"]) roots.add(join23(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
82143
- roots.add(join23(home, ".gemini", "tmp"));
82173
+ if (env2["GEMINI_CLI_HOME"]) roots.add(join24(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
82174
+ roots.add(join24(home, ".gemini", "tmp"));
82144
82175
  return [...roots];
82145
82176
  }
82146
82177
  function geminiProjectHash(cwd) {
@@ -82180,7 +82211,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82180
82211
  const hashes = geminiHashesFor(cwd);
82181
82212
  const out2 = [];
82182
82213
  for (const root of geminiSessionRoots(opts.env, opts.home)) {
82183
- if (!existsSync19(root)) continue;
82214
+ if (!existsSync20(root)) continue;
82184
82215
  let slugs;
82185
82216
  try {
82186
82217
  slugs = readdirSync7(root);
@@ -82188,7 +82219,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82188
82219
  continue;
82189
82220
  }
82190
82221
  for (const slug2 of slugs) {
82191
- const chats = join23(root, slug2, "chats");
82222
+ const chats = join24(root, slug2, "chats");
82192
82223
  let names;
82193
82224
  try {
82194
82225
  names = readdirSync7(chats);
@@ -82197,10 +82228,10 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82197
82228
  }
82198
82229
  for (const name2 of names) {
82199
82230
  if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
82200
- const full = join23(chats, name2);
82231
+ const full = join24(chats, name2);
82201
82232
  let st;
82202
82233
  try {
82203
- st = statSync9(full);
82234
+ st = statSync10(full);
82204
82235
  } catch {
82205
82236
  continue;
82206
82237
  }
@@ -82217,8 +82248,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
82217
82248
  function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
82218
82249
  const roots = /* @__PURE__ */ new Set();
82219
82250
  for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
82220
- if (env2["XDG_DATA_HOME"]) roots.add(join23(env2["XDG_DATA_HOME"], "opencode", "errata"));
82221
- roots.add(join23(home, ".local", "share", "opencode", "errata"));
82251
+ if (env2["XDG_DATA_HOME"]) roots.add(join24(env2["XDG_DATA_HOME"], "opencode", "errata"));
82252
+ roots.add(join24(home, ".local", "share", "opencode", "errata"));
82222
82253
  return [...roots];
82223
82254
  }
82224
82255
  function readOpencodeTranscriptDirectory(path3) {
@@ -82251,7 +82282,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
82251
82282
  }
82252
82283
  const out2 = [];
82253
82284
  for (const root of opencodeSessionRoots(opts.env, opts.home)) {
82254
- if (!existsSync19(root)) continue;
82285
+ if (!existsSync20(root)) continue;
82255
82286
  let names;
82256
82287
  try {
82257
82288
  names = readdirSync7(root);
@@ -82260,10 +82291,10 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
82260
82291
  }
82261
82292
  for (const name2 of names) {
82262
82293
  if (!name2.endsWith(".jsonl")) continue;
82263
- const full = join23(root, name2);
82294
+ const full = join24(root, name2);
82264
82295
  let st;
82265
82296
  try {
82266
- st = statSync9(full);
82297
+ st = statSync10(full);
82267
82298
  } catch {
82268
82299
  continue;
82269
82300
  }
@@ -82283,7 +82314,7 @@ init_src2();
82283
82314
  init_agent_signals();
82284
82315
  init_tool_index();
82285
82316
  init_src5();
82286
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync15 } from "node:fs";
82317
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
82287
82318
  var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
82288
82319
  var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
82289
82320
  var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
@@ -83118,7 +83149,7 @@ function writePrimingHandles(path3, nodes, now = Date.now()) {
83118
83149
  }
83119
83150
  function readPrimingHandles(path3) {
83120
83151
  try {
83121
- return JSON.parse(readFileSync19(path3, "utf8"));
83152
+ return JSON.parse(readFileSync20(path3, "utf8"));
83122
83153
  } catch {
83123
83154
  return {};
83124
83155
  }
@@ -83720,8 +83751,8 @@ ${conversation}` }]
83720
83751
  // src/constraint-backfill.ts
83721
83752
  init_src5();
83722
83753
  init_src2();
83723
- import { existsSync as existsSync20, readFileSync as readFileSync20, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
83724
- import { join as join24 } from "node:path";
83754
+ import { existsSync as existsSync21, readFileSync as readFileSync21, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
83755
+ import { join as join25 } from "node:path";
83725
83756
  import { homedir as homedir5 } from "node:os";
83726
83757
  var BACKFILL_VERSION = 1;
83727
83758
  var EMPTY = {
@@ -83735,13 +83766,13 @@ var EMPTY = {
83735
83766
  recoverable: 0
83736
83767
  };
83737
83768
  function markerPath(configDir) {
83738
- return join24(configDir, "constraint-backfill.json");
83769
+ return join25(configDir, "constraint-backfill.json");
83739
83770
  }
83740
83771
  function alreadyDone(configDir) {
83741
83772
  const p = markerPath(configDir);
83742
- if (!existsSync20(p)) return false;
83773
+ if (!existsSync21(p)) return false;
83743
83774
  try {
83744
- const raw2 = JSON.parse(readFileSync20(p, "utf8"));
83775
+ const raw2 = JSON.parse(readFileSync21(p, "utf8"));
83745
83776
  return raw2?.version === BACKFILL_VERSION;
83746
83777
  } catch {
83747
83778
  return false;
@@ -83751,7 +83782,7 @@ function replay(root) {
83751
83782
  const statements2 = /* @__PURE__ */ new Set();
83752
83783
  const citedByFix = /* @__PURE__ */ new Set();
83753
83784
  const dir = claudeProjectDir(root, homedir5());
83754
- if (!existsSync20(dir)) return { statements: statements2, citedByFix };
83785
+ if (!existsSync21(dir)) return { statements: statements2, citedByFix };
83755
83786
  let names;
83756
83787
  try {
83757
83788
  names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
@@ -83761,7 +83792,7 @@ function replay(root) {
83761
83792
  for (const f of names) {
83762
83793
  let lines;
83763
83794
  try {
83764
- lines = readFileSync20(join24(dir, f), "utf8").split("\n");
83795
+ lines = readFileSync21(join25(dir, f), "utf8").split("\n");
83765
83796
  } catch {
83766
83797
  continue;
83767
83798
  }
@@ -83888,8 +83919,8 @@ function backfillConstraintKind(store, opts) {
83888
83919
  // src/edge-repair.ts
83889
83920
  init_src();
83890
83921
  init_src5();
83891
- import { existsSync as existsSync21, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
83892
- import { join as join25 } from "node:path";
83922
+ import { existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync17 } from "node:fs";
83923
+ import { join as join26 } from "node:path";
83893
83924
  function citeEdgeId(from, type, to) {
83894
83925
  return `edge_${digest({ from, type, to })}`.slice(0, 24);
83895
83926
  }
@@ -83904,13 +83935,13 @@ var EMPTY2 = {
83904
83935
  byType: {}
83905
83936
  };
83906
83937
  function markerPath2(configDir) {
83907
- return join25(configDir, "edge-repair.json");
83938
+ return join26(configDir, "edge-repair.json");
83908
83939
  }
83909
83940
  function alreadyDone2(configDir) {
83910
83941
  const p = markerPath2(configDir);
83911
- if (!existsSync21(p)) return false;
83942
+ if (!existsSync22(p)) return false;
83912
83943
  try {
83913
- return JSON.parse(readFileSync21(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
83944
+ return JSON.parse(readFileSync22(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
83914
83945
  } catch {
83915
83946
  return false;
83916
83947
  }
@@ -83973,8 +84004,8 @@ function repairInvalidEdges(store, opts) {
83973
84004
  init_reconcile();
83974
84005
 
83975
84006
  // src/pass-ledger.ts
83976
- import { appendFileSync as appendFileSync2, existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync18 } from "node:fs";
83977
- import { join as join26 } from "node:path";
84007
+ import { appendFileSync as appendFileSync2, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync18 } from "node:fs";
84008
+ import { join as join27 } from "node:path";
83978
84009
 
83979
84010
  // src/isolate-census.ts
83980
84011
  var live2 = 0;
@@ -84005,7 +84036,7 @@ var HOUR_MS = 36e5;
84005
84036
  var TRIM_EVERY = 50;
84006
84037
  var appendsSinceTrim = /* @__PURE__ */ new Map();
84007
84038
  function passLedgerPath(configDir) {
84008
- return join26(configDir, "pass-ledger.jsonl");
84039
+ return join27(configDir, "pass-ledger.jsonl");
84009
84040
  }
84010
84041
  function appendPassLedger(configDir, kind, durationMs, counts) {
84011
84042
  const path3 = passLedgerPath(configDir);
@@ -84037,7 +84068,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
84037
84068
  return;
84038
84069
  }
84039
84070
  appendsSinceTrim.set(path3, 0);
84040
- const lines = readFileSync22(path3, "utf8").split("\n").filter(Boolean);
84071
+ const lines = readFileSync23(path3, "utf8").split("\n").filter(Boolean);
84041
84072
  const keptByKind = /* @__PURE__ */ new Map();
84042
84073
  const tailHours = /* @__PURE__ */ new Map();
84043
84074
  const tailFloor = Date.now() - LEVEL_TAIL_DAYS * 24 * HOUR_MS;
@@ -84072,9 +84103,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
84072
84103
  }
84073
84104
  function readPassLedger(configDir) {
84074
84105
  const path3 = passLedgerPath(configDir);
84075
- if (!existsSync22(path3)) return [];
84106
+ if (!existsSync23(path3)) return [];
84076
84107
  try {
84077
- return readFileSync22(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
84108
+ return readFileSync23(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
84078
84109
  (e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
84079
84110
  ).map((e) => ({ ...e, counts: e.counts ?? {} }));
84080
84111
  } catch {
@@ -84430,8 +84461,8 @@ var PassWorker = class {
84430
84461
  const id = this.nextId++;
84431
84462
  try {
84432
84463
  await this.ready;
84433
- return await new Promise((resolve10, reject) => {
84434
- this.pending.set(id, { resolve: resolve10, reject });
84464
+ return await new Promise((resolve11, reject) => {
84465
+ this.pending.set(id, { resolve: resolve11, reject });
84435
84466
  this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
84436
84467
  });
84437
84468
  } finally {
@@ -84466,12 +84497,12 @@ var PassWorker = class {
84466
84497
  });
84467
84498
  noteIsolateSpawned();
84468
84499
  this.worker = worker;
84469
- this.ready = new Promise((resolve10, reject) => {
84500
+ this.ready = new Promise((resolve11, reject) => {
84470
84501
  const onReady = (m) => {
84471
84502
  if (m?.ready) {
84472
84503
  worker.off("message", onReady);
84473
84504
  worker.off("error", onErr);
84474
- resolve10();
84505
+ resolve11();
84475
84506
  }
84476
84507
  };
84477
84508
  const onErr = (err2) => reject(err2);
@@ -84517,11 +84548,11 @@ init_outbox();
84517
84548
  init_src10();
84518
84549
  init_src();
84519
84550
  init_src2();
84520
- import { readFileSync as readFileSync23 } from "node:fs";
84521
- import { join as join27 } from "node:path";
84551
+ import { readFileSync as readFileSync24 } from "node:fs";
84552
+ import { join as join28 } from "node:path";
84522
84553
  function loadClaimIgnorePatterns(workspaceRoot) {
84523
84554
  try {
84524
- return readFileSync23(join27(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
84555
+ return readFileSync24(join28(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
84525
84556
  } catch {
84526
84557
  return [];
84527
84558
  }
@@ -84904,9 +84935,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
84904
84935
  // src/retrieval-stack.ts
84905
84936
  init_src();
84906
84937
  import { execFileSync as execFileSync5 } from "node:child_process";
84907
- import { existsSync as existsSync23, readFileSync as readFileSync24, statSync as statSync10 } from "node:fs";
84938
+ import { existsSync as existsSync24, readFileSync as readFileSync25, statSync as statSync11 } from "node:fs";
84908
84939
  import { homedir as homedir6 } from "node:os";
84909
- import { join as join28 } from "node:path";
84940
+ import { join as join29 } from "node:path";
84910
84941
  var RETRIEVAL_STACK_CAP = 24;
84911
84942
  var MANIFEST_SCAN_CAP = 400;
84912
84943
  var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
@@ -85196,51 +85227,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
85196
85227
  function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
85197
85228
  const read2 = (p) => {
85198
85229
  try {
85199
- return readFileSync24(p, "utf8");
85230
+ return readFileSync25(p, "utf8");
85200
85231
  } catch {
85201
85232
  return null;
85202
85233
  }
85203
85234
  };
85204
85235
  const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
85205
85236
  const home = homedir6();
85206
- const npm = parseNpmrcPolicy(texts(join28(root, ".npmrc"), join28(home, ".npmrc")));
85237
+ const npm = parseNpmrcPolicy(texts(join29(root, ".npmrc"), join29(home, ".npmrc")));
85207
85238
  const blocked = /* @__PURE__ */ new Set();
85208
85239
  if (!npm.defaultPublic) blocked.add("npm");
85209
85240
  if (pypiIndexIsPrivate(
85210
85241
  texts(
85211
- join28(root, "pip.conf"),
85212
- join28(root, "pip.ini"),
85213
- join28(root, "pyproject.toml"),
85214
- join28(root, "requirements.txt"),
85215
- join28(home, ".pip", "pip.conf"),
85216
- join28(home, ".config", "pip", "pip.conf"),
85217
- join28(env2["APPDATA"] ?? home, "pip", "pip.ini")
85242
+ join29(root, "pip.conf"),
85243
+ join29(root, "pip.ini"),
85244
+ join29(root, "pyproject.toml"),
85245
+ join29(root, "requirements.txt"),
85246
+ join29(home, ".pip", "pip.conf"),
85247
+ join29(home, ".config", "pip", "pip.conf"),
85248
+ join29(env2["APPDATA"] ?? home, "pip", "pip.ini")
85218
85249
  )
85219
85250
  )) {
85220
85251
  blocked.add("pypi");
85221
85252
  }
85222
85253
  if (cargoRegistryIsPrivate(
85223
85254
  texts(
85224
- join28(root, ".cargo", "config.toml"),
85225
- join28(root, ".cargo", "config"),
85226
- join28(home, ".cargo", "config.toml"),
85227
- join28(home, ".cargo", "config")
85255
+ join29(root, ".cargo", "config.toml"),
85256
+ join29(root, ".cargo", "config"),
85257
+ join29(home, ".cargo", "config.toml"),
85258
+ join29(home, ".cargo", "config")
85228
85259
  )
85229
85260
  )) {
85230
85261
  blocked.add("cargo");
85231
85262
  }
85232
85263
  if (nugetSourcesArePrivate(
85233
85264
  texts(
85234
- join28(root, "NuGet.config"),
85235
- join28(root, "nuget.config"),
85236
- join28(root, "NuGet.Config"),
85237
- join28(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
85238
- join28(home, ".nuget", "NuGet", "NuGet.Config")
85265
+ join29(root, "NuGet.config"),
85266
+ join29(root, "nuget.config"),
85267
+ join29(root, "NuGet.Config"),
85268
+ join29(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
85269
+ join29(home, ".nuget", "NuGet", "NuGet.Config")
85239
85270
  )
85240
85271
  )) {
85241
85272
  blocked.add("nuget");
85242
85273
  }
85243
- const goEnvFile = env2["GOENV"] ?? join28(env2["APPDATA"] ?? join28(home, ".config"), "go", "env");
85274
+ const goEnvFile = env2["GOENV"] ?? join29(env2["APPDATA"] ?? join29(home, ".config"), "go", "env");
85244
85275
  const goEnvText = read2(goEnvFile) ?? "";
85245
85276
  const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
85246
85277
  (k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
@@ -85251,10 +85282,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
85251
85282
  env2["GONOSUMCHECK"],
85252
85283
  ...fromFile
85253
85284
  ]);
85254
- const gemfiles = texts(join28(root, "Gemfile"));
85285
+ const gemfiles = texts(join29(root, "Gemfile"));
85255
85286
  if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
85256
85287
  if (mavenReposArePrivate(
85257
- texts(join28(root, "pom.xml"), join28(home, ".m2", "settings.xml"))
85288
+ texts(join29(root, "pom.xml"), join29(home, ".m2", "settings.xml"))
85258
85289
  )) {
85259
85290
  blocked.add("maven");
85260
85291
  }
@@ -85421,10 +85452,10 @@ function readDirectDependencies(root) {
85421
85452
  const familiesSeen = /* @__PURE__ */ new Set();
85422
85453
  for (const c of LOCKFILES) {
85423
85454
  if (familiesSeen.has(c.family)) continue;
85424
- const p = join28(root, c.file);
85425
- if (!existsSync23(p)) continue;
85455
+ const p = join29(root, c.file);
85456
+ if (!existsSync24(p)) continue;
85426
85457
  try {
85427
- const s = statSync10(p);
85458
+ const s = statSync11(p);
85428
85459
  stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
85429
85460
  } catch {
85430
85461
  continue;
@@ -85442,7 +85473,7 @@ function readDirectDependencies(root) {
85442
85473
  const direct = [];
85443
85474
  for (const { c, path: path3 } of found) {
85444
85475
  try {
85445
- direct.push(...c.parse(readFileSync24(path3, "utf8")).direct ?? []);
85476
+ direct.push(...c.parse(readFileSync25(path3, "utf8")).direct ?? []);
85446
85477
  } catch {
85447
85478
  }
85448
85479
  }
@@ -85485,14 +85516,14 @@ function manifestPaths(root) {
85485
85516
  "project.godot"
85486
85517
  ];
85487
85518
  return {
85488
- paths: ROOT_MANIFESTS.filter((f) => existsSync23(join28(root, f))),
85519
+ paths: ROOT_MANIFESTS.filter((f) => existsSync24(join29(root, f))),
85489
85520
  tracked: false,
85490
85521
  truncated: false
85491
85522
  };
85492
85523
  }
85493
85524
  var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
85494
85525
  function rootDeclaresWorkspace(root, texts) {
85495
- if (WORKSPACE_MARKERS.some((f) => existsSync23(join28(root, f)))) return true;
85526
+ if (WORKSPACE_MARKERS.some((f) => existsSync24(join29(root, f)))) return true;
85496
85527
  return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
85497
85528
  }
85498
85529
  var EMPTY_SCAN = { deps: [], self: [], complete: true };
@@ -85506,11 +85537,11 @@ function scanManifests(root) {
85506
85537
  const texts = /* @__PURE__ */ new Map();
85507
85538
  const stamps = [];
85508
85539
  for (const rel of paths) {
85509
- const abs = join28(root, rel);
85540
+ const abs = join29(root, rel);
85510
85541
  try {
85511
- const s = statSync10(abs);
85542
+ const s = statSync11(abs);
85512
85543
  stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
85513
- texts.set(rel, readFileSync24(abs, "utf8"));
85544
+ texts.set(rel, readFileSync25(abs, "utf8"));
85514
85545
  } catch {
85515
85546
  }
85516
85547
  }
@@ -85546,22 +85577,22 @@ function readRetrievalInputs(root, repoLocator) {
85546
85577
  }
85547
85578
 
85548
85579
  // src/git-sensor.ts
85549
- import { existsSync as existsSync24, readFileSync as readFileSync25, watch as fsWatch } from "node:fs";
85550
- import { join as join29 } from "node:path";
85580
+ import { existsSync as existsSync25, readFileSync as readFileSync26, watch as fsWatch } from "node:fs";
85581
+ import { join as join30 } from "node:path";
85551
85582
  function readFirstLine(path3) {
85552
85583
  try {
85553
- return readFileSync25(path3, "utf8").split(/\r?\n/, 1)[0].trim();
85584
+ return readFileSync26(path3, "utf8").split(/\r?\n/, 1)[0].trim();
85554
85585
  } catch {
85555
85586
  return null;
85556
85587
  }
85557
85588
  }
85558
85589
  function readGitRefState(gitDir) {
85559
- const head2 = readFirstLine(join29(gitDir, "HEAD"));
85590
+ const head2 = readFirstLine(join30(gitDir, "HEAD"));
85560
85591
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
85561
85592
  const branch = m ? m[1] : null;
85562
85593
  let sha2 = null;
85563
85594
  if (branch) {
85564
- sha2 = readFirstLine(join29(gitDir, "refs", "heads", branch));
85595
+ sha2 = readFirstLine(join30(gitDir, "refs", "heads", branch));
85565
85596
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
85566
85597
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
85567
85598
  sha2 = head2;
@@ -85569,13 +85600,13 @@ function readGitRefState(gitDir) {
85569
85600
  return {
85570
85601
  branch,
85571
85602
  sha: sha2,
85572
- mergeHeadExists: existsSync24(join29(gitDir, "MERGE_HEAD")),
85573
- origHeadExists: existsSync24(join29(gitDir, "ORIG_HEAD"))
85603
+ mergeHeadExists: existsSync25(join30(gitDir, "MERGE_HEAD")),
85604
+ origHeadExists: existsSync25(join30(gitDir, "ORIG_HEAD"))
85574
85605
  };
85575
85606
  }
85576
85607
  function shaFromPackedRefs(gitDir, ref) {
85577
85608
  try {
85578
- for (const line of readFileSync25(join29(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
85609
+ for (const line of readFileSync26(join30(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
85579
85610
  const [sha2, name2] = line.split(/\s+/);
85580
85611
  if (name2 === ref && sha2) return sha2;
85581
85612
  }
@@ -85609,7 +85640,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85609
85640
  const settle = () => {
85610
85641
  if (timer) clearTimeout(timer);
85611
85642
  timer = setTimeout(() => {
85612
- if (existsSync24(join29(gitDir, "index.lock"))) {
85643
+ if (existsSync25(join30(gitDir, "index.lock"))) {
85613
85644
  settle();
85614
85645
  return;
85615
85646
  }
@@ -85620,7 +85651,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85620
85651
  }, debounceMs);
85621
85652
  };
85622
85653
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
85623
- const p = join29(gitDir, sub);
85654
+ const p = join30(gitDir, sub);
85624
85655
  try {
85625
85656
  watchers.push(fsWatch(p, settle));
85626
85657
  } catch {
@@ -85640,7 +85671,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
85640
85671
  // src/git-delta.ts
85641
85672
  import { execFile as execFile2 } from "node:child_process";
85642
85673
  function git(repoDir, args2) {
85643
- return new Promise((resolve10, reject) => {
85674
+ return new Promise((resolve11, reject) => {
85644
85675
  execFile2(
85645
85676
  "git",
85646
85677
  ["-C", repoDir, ...args2],
@@ -85651,7 +85682,7 @@ function git(repoDir, args2) {
85651
85682
  // git-sensor runs on every commit/checkout.
85652
85683
  windowsHide: true
85653
85684
  },
85654
- (err2, stdout) => err2 ? reject(err2) : resolve10(stdout)
85685
+ (err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
85655
85686
  );
85656
85687
  });
85657
85688
  }
@@ -85850,8 +85881,8 @@ var TelemetryRecorder = class {
85850
85881
  };
85851
85882
 
85852
85883
  // src/file-activity.ts
85853
- import { readFileSync as readFileSync27 } from "node:fs";
85854
- import { join as join31 } from "node:path";
85884
+ import { readFileSync as readFileSync28 } from "node:fs";
85885
+ import { join as join32 } from "node:path";
85855
85886
  import { createHash as createHash17 } from "node:crypto";
85856
85887
 
85857
85888
  // ../../packages/privacy/src/patterns/credentials.ts
@@ -86603,8 +86634,8 @@ init_git_remote();
86603
86634
  // src/history-bundle.ts
86604
86635
  init_src();
86605
86636
  import { execFile as execFile3 } from "node:child_process";
86606
- import { readFileSync as readFileSync26 } from "node:fs";
86607
- import { join as join30 } from "node:path";
86637
+ import { readFileSync as readFileSync27 } from "node:fs";
86638
+ import { join as join31 } from "node:path";
86608
86639
  var DEFAULT_MAX_TOKENS = 6e3;
86609
86640
  var FILE_LIST_CAP = 60;
86610
86641
  var DIFF_FILE_CAP = 40;
@@ -86643,7 +86674,7 @@ function pathAllowedByFloor(path3) {
86643
86674
  function loadRepoIgnore(root, extraPatterns = []) {
86644
86675
  let source = "";
86645
86676
  try {
86646
- source = readFileSync26(join30(root, ".errataignore"), "utf8");
86677
+ source = readFileSync27(join31(root, ".errataignore"), "utf8");
86647
86678
  } catch {
86648
86679
  source = "";
86649
86680
  }
@@ -86820,12 +86851,12 @@ function headerPaths(diff) {
86820
86851
  }
86821
86852
  var GIT_MAX_BUFFER = 64 * 1024 * 1024;
86822
86853
  function git2(repoDir, args2, maxBuffer = GIT_MAX_BUFFER) {
86823
- return new Promise((resolve10, reject) => {
86854
+ return new Promise((resolve11, reject) => {
86824
86855
  execFile3(
86825
86856
  "git",
86826
86857
  ["-C", repoDir, ...args2],
86827
86858
  { encoding: "utf8", maxBuffer, windowsHide: true },
86828
- (err2, stdout) => err2 ? reject(err2) : resolve10(stdout)
86859
+ (err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
86829
86860
  );
86830
86861
  });
86831
86862
  }
@@ -86948,7 +86979,7 @@ function readActivityBranch(root) {
86948
86979
  try {
86949
86980
  const gitDir = resolveGitDir(root);
86950
86981
  if (!gitDir) return null;
86951
- const head2 = readFileSync27(join31(gitDir, "HEAD"), "utf8").trim();
86982
+ const head2 = readFileSync28(join32(gitDir, "HEAD"), "utf8").trim();
86952
86983
  const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
86953
86984
  return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
86954
86985
  } catch {
@@ -87105,21 +87136,21 @@ var FileActivityReporter = class {
87105
87136
 
87106
87137
  // src/skills.ts
87107
87138
  import {
87108
- existsSync as existsSync25,
87139
+ existsSync as existsSync26,
87109
87140
  mkdirSync as mkdirSync7,
87110
- readFileSync as readFileSync28,
87141
+ readFileSync as readFileSync29,
87111
87142
  readdirSync as readdirSync9,
87112
87143
  unlinkSync as unlinkSync4,
87113
87144
  writeFileSync as writeFileSync19
87114
87145
  } from "node:fs";
87115
- import { basename as basename7, join as join32 } from "node:path";
87146
+ import { basename as basename7, join as join33 } from "node:path";
87116
87147
  function skillFileName(id) {
87117
87148
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
87118
87149
  }
87119
87150
  function readSkillManifest(manifestPath) {
87120
- if (!existsSync25(manifestPath)) return [];
87151
+ if (!existsSync26(manifestPath)) return [];
87121
87152
  try {
87122
- const parsed = JSON.parse(readFileSync28(manifestPath, "utf8"));
87153
+ const parsed = JSON.parse(readFileSync29(manifestPath, "utf8"));
87123
87154
  return (parsed.skills ?? []).map((s) => ({
87124
87155
  title: s.title ?? "",
87125
87156
  layer: s.layer ?? "technique",
@@ -87143,7 +87174,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87143
87174
  for (const s of res.skills) {
87144
87175
  const fileName = skillFileName(s.id);
87145
87176
  keep.add(fileName);
87146
- writeFileSync19(join32(paths.skillsDir, fileName), s.markdown, "utf8");
87177
+ writeFileSync19(join33(paths.skillsDir, fileName), s.markdown, "utf8");
87147
87178
  rows.push({
87148
87179
  id: s.id,
87149
87180
  title: s.title,
@@ -87156,7 +87187,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87156
87187
  const fileName = skillFileName(p.id);
87157
87188
  if (keep.has(fileName)) continue;
87158
87189
  keep.add(fileName);
87159
- writeFileSync19(join32(paths.skillsDir, fileName), p.markdown, "utf8");
87190
+ writeFileSync19(join33(paths.skillsDir, fileName), p.markdown, "utf8");
87160
87191
  rows.push({
87161
87192
  id: p.id,
87162
87193
  title: p.title,
@@ -87170,7 +87201,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87170
87201
  if (!f.endsWith(".md")) continue;
87171
87202
  if (keep.has(basename7(f))) continue;
87172
87203
  try {
87173
- unlinkSync4(join32(paths.skillsDir, f));
87204
+ unlinkSync4(join33(paths.skillsDir, f));
87174
87205
  pruned++;
87175
87206
  } catch {
87176
87207
  }
@@ -87188,22 +87219,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
87188
87219
  init_src2();
87189
87220
  import {
87190
87221
  cpSync,
87191
- existsSync as existsSync26,
87222
+ existsSync as existsSync27,
87192
87223
  lstatSync,
87193
87224
  mkdirSync as mkdirSync8,
87194
- readFileSync as readFileSync29,
87225
+ readFileSync as readFileSync30,
87195
87226
  readdirSync as readdirSync10,
87196
87227
  rmSync as rmSync3,
87197
87228
  symlinkSync,
87198
87229
  writeFileSync as writeFileSync20
87199
87230
  } from "node:fs";
87200
- import { join as join33 } from "node:path";
87231
+ import { join as join34 } from "node:path";
87201
87232
  var SKILL_NS = "errata-";
87202
87233
  var HARNESS_SKILL_DIRS = [
87203
- { configDir: ".claude", skillsDir: join33(".claude", "skills") },
87234
+ { configDir: ".claude", skillsDir: join34(".claude", "skills") },
87204
87235
  // Cursor adopted the standard; its exact project dir is still moving — kept
87205
87236
  // best-effort and gated on `.cursor/` presence so we never create it blind.
87206
- { configDir: ".cursor", skillsDir: join33(".cursor", "skills") }
87237
+ { configDir: ".cursor", skillsDir: join34(".cursor", "skills") }
87207
87238
  ];
87208
87239
  function skillSlug(title, id) {
87209
87240
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -87248,12 +87279,12 @@ function skillCiteHandle(s) {
87248
87279
  return priorHandle({ id: s.id, description: s.title });
87249
87280
  }
87250
87281
  function reconcileNamespaced(dir, keep) {
87251
- if (!existsSync26(dir)) return 0;
87282
+ if (!existsSync27(dir)) return 0;
87252
87283
  let pruned = 0;
87253
87284
  for (const name2 of readdirSync10(dir)) {
87254
87285
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
87255
87286
  try {
87256
- rmSync3(join33(dir, name2), { recursive: true, force: true });
87287
+ rmSync3(join34(dir, name2), { recursive: true, force: true });
87257
87288
  pruned++;
87258
87289
  } catch {
87259
87290
  }
@@ -87262,7 +87293,7 @@ function reconcileNamespaced(dir, keep) {
87262
87293
  }
87263
87294
  function linkOrCopy(linkPath, target) {
87264
87295
  try {
87265
- if (existsSync26(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
87296
+ if (existsSync27(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
87266
87297
  } catch {
87267
87298
  }
87268
87299
  try {
@@ -87283,7 +87314,7 @@ function safeLstat(p) {
87283
87314
  }
87284
87315
  }
87285
87316
  function emitAndProjectSkills(root, skills) {
87286
- const agentsSkillsDir = join33(root, ".agents", "skills");
87317
+ const agentsSkillsDir = join34(root, ".agents", "skills");
87287
87318
  mkdirSync8(agentsSkillsDir, { recursive: true });
87288
87319
  const slugs = [];
87289
87320
  const keep = /* @__PURE__ */ new Set();
@@ -87291,7 +87322,7 @@ function emitAndProjectSkills(root, skills) {
87291
87322
  for (const s of skills) {
87292
87323
  let body2;
87293
87324
  try {
87294
- body2 = readFileSync29(s.bodyPath, "utf8");
87325
+ body2 = readFileSync30(s.bodyPath, "utf8");
87295
87326
  } catch {
87296
87327
  continue;
87297
87328
  }
@@ -87300,9 +87331,9 @@ function emitAndProjectSkills(root, skills) {
87300
87331
  keep.add(slug2);
87301
87332
  slugs.push(slug2);
87302
87333
  const description = deriveDescription(s.title, s.layer, body2);
87303
- mkdirSync8(join33(agentsSkillsDir, slug2), { recursive: true });
87334
+ mkdirSync8(join34(agentsSkillsDir, slug2), { recursive: true });
87304
87335
  writeFileSync20(
87305
- join33(agentsSkillsDir, slug2, "SKILL.md"),
87336
+ join34(agentsSkillsDir, slug2, "SKILL.md"),
87306
87337
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
87307
87338
  "utf8"
87308
87339
  );
@@ -87311,11 +87342,11 @@ function emitAndProjectSkills(root, skills) {
87311
87342
  reconcileNamespaced(agentsSkillsDir, keep);
87312
87343
  let projected = 0;
87313
87344
  for (const h of HARNESS_SKILL_DIRS) {
87314
- if (!existsSync26(join33(root, h.configDir))) continue;
87315
- const dir = join33(root, h.skillsDir);
87345
+ if (!existsSync27(join34(root, h.configDir))) continue;
87346
+ const dir = join34(root, h.skillsDir);
87316
87347
  mkdirSync8(dir, { recursive: true });
87317
87348
  for (const slug2 of slugs) {
87318
- linkOrCopy(join33(dir, slug2), join33(agentsSkillsDir, slug2));
87349
+ linkOrCopy(join34(dir, slug2), join34(agentsSkillsDir, slug2));
87319
87350
  projected++;
87320
87351
  }
87321
87352
  reconcileNamespaced(dir, keep);
@@ -87324,15 +87355,15 @@ function emitAndProjectSkills(root, skills) {
87324
87355
  return { slugs, emitted, projected };
87325
87356
  }
87326
87357
  function emitInputsFromManifest(erretaDir, manifestPath) {
87327
- if (!existsSync26(manifestPath)) return [];
87358
+ if (!existsSync27(manifestPath)) return [];
87328
87359
  try {
87329
- const parsed = JSON.parse(readFileSync29(manifestPath, "utf8"));
87360
+ const parsed = JSON.parse(readFileSync30(manifestPath, "utf8"));
87330
87361
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
87331
87362
  id: s.id,
87332
87363
  title: s.title ?? s.id,
87333
87364
  layer: s.layer ?? "technique",
87334
87365
  confidence: s.confidence ?? 0,
87335
- bodyPath: join33(erretaDir, s.file)
87366
+ bodyPath: join34(erretaDir, s.file)
87336
87367
  }));
87337
87368
  } catch {
87338
87369
  return [];
@@ -87346,10 +87377,10 @@ var GITIGNORE_LINES = [
87346
87377
  ".cursor/skills/errata-*/"
87347
87378
  ];
87348
87379
  function ensureSkillGitignore(root) {
87349
- const path3 = join33(root, ".gitignore");
87380
+ const path3 = join34(root, ".gitignore");
87350
87381
  let current = "";
87351
87382
  try {
87352
- current = existsSync26(path3) ? readFileSync29(path3, "utf8") : "";
87383
+ current = existsSync27(path3) ? readFileSync30(path3, "utf8") : "";
87353
87384
  } catch {
87354
87385
  return;
87355
87386
  }
@@ -87452,18 +87483,18 @@ init_paths();
87452
87483
  init_profile2();
87453
87484
 
87454
87485
  // src/witness-queue.ts
87455
- import { readFileSync as readFileSync30, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
87456
- import { dirname as dirname13, join as join34 } from "node:path";
87486
+ import { readFileSync as readFileSync31, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
87487
+ import { dirname as dirname14, join as join35 } from "node:path";
87457
87488
  var WITNESS_QUEUE_CAP = 500;
87458
87489
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
87459
87490
  var WITNESS_MAX_ATTEMPTS = 5;
87460
87491
  function witnessQueuePath(workspaceConfigDir) {
87461
- return join34(workspaceConfigDir, "witness-queue.json");
87492
+ return join35(workspaceConfigDir, "witness-queue.json");
87462
87493
  }
87463
87494
  function loadWitnessQueueWithLosses(path3) {
87464
87495
  let raw2;
87465
87496
  try {
87466
- raw2 = JSON.parse(readFileSync30(path3, "utf8"));
87497
+ raw2 = JSON.parse(readFileSync31(path3, "utf8"));
87467
87498
  } catch (err2) {
87468
87499
  const absent = err2?.code === "ENOENT";
87469
87500
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -87476,7 +87507,7 @@ function loadWitnessQueueWithLosses(path3) {
87476
87507
  }
87477
87508
  function saveWitnessQueue(path3, queue) {
87478
87509
  try {
87479
- const tmp = join34(dirname13(path3), `.${Date.now()}.witness-queue.tmp`);
87510
+ const tmp = join35(dirname14(path3), `.${Date.now()}.witness-queue.tmp`);
87480
87511
  writeFileSync21(tmp, JSON.stringify(queue), "utf8");
87481
87512
  renameSync4(tmp, path3);
87482
87513
  } catch {
@@ -87786,8 +87817,8 @@ function maybeFlushDigests() {
87786
87817
 
87787
87818
  // src/liveness-watch.ts
87788
87819
  init_src5();
87789
- import { readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
87790
- import { join as join36 } from "node:path";
87820
+ import { readFileSync as readFileSync33, writeFileSync as writeFileSync23 } from "node:fs";
87821
+ import { join as join37 } from "node:path";
87791
87822
 
87792
87823
  // src/loop-lag.ts
87793
87824
  var HEARTBEAT_MS = 500;
@@ -87919,11 +87950,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
87919
87950
  var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
87920
87951
  var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
87921
87952
  function alarmStatePath(configDir) {
87922
- return join36(configDir, "liveness-alarms.json");
87953
+ return join37(configDir, "liveness-alarms.json");
87923
87954
  }
87924
87955
  function loadAlarmState(path3) {
87925
87956
  try {
87926
- const raw2 = JSON.parse(readFileSync32(path3, "utf8"));
87957
+ const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
87927
87958
  return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
87928
87959
  } catch {
87929
87960
  return /* @__PURE__ */ new Map();
@@ -88187,7 +88218,7 @@ function createWatchBreaker(deps) {
88187
88218
  }
88188
88219
 
88189
88220
  // src/engine.ts
88190
- var DAEMON_VERSION = true ? "2.0.23-dev.4829" : "2.0.0-alpha.0";
88221
+ var DAEMON_VERSION = true ? "2.0.23-dev.4863" : "2.0.0-alpha.0";
88191
88222
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
88192
88223
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
88193
88224
  var GIT_OP_MUTE_MS = 4e3;
@@ -88199,7 +88230,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
88199
88230
  function appendIdentityAudit(path3, record2, line) {
88200
88231
  if (!record2.accepted && record2.score <= 0) return;
88201
88232
  try {
88202
- if (existsSync28(path3) && statSync11(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
88233
+ if (existsSync29(path3) && statSync12(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
88203
88234
  renameSync5(path3, `${path3}.1`);
88204
88235
  }
88205
88236
  appendFileSync4(path3, line);
@@ -88209,7 +88240,7 @@ function appendIdentityAudit(path3, record2, line) {
88209
88240
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
88210
88241
  function loadTurnCursors(path3) {
88211
88242
  try {
88212
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88243
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88213
88244
  return new Map(
88214
88245
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
88215
88246
  );
@@ -88219,7 +88250,7 @@ function loadTurnCursors(path3) {
88219
88250
  }
88220
88251
  function loadTurnOffsets(path3) {
88221
88252
  try {
88222
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88253
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88223
88254
  const out2 = /* @__PURE__ */ new Map();
88224
88255
  for (const [k, v] of Object.entries(raw2)) {
88225
88256
  const off2 = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -88232,7 +88263,7 @@ function loadTurnOffsets(path3) {
88232
88263
  }
88233
88264
  function loadTurnMoves(path3) {
88234
88265
  try {
88235
- const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
88266
+ const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
88236
88267
  const out2 = /* @__PURE__ */ new Map();
88237
88268
  for (const [k, v] of Object.entries(raw2)) {
88238
88269
  const to = typeof v === "object" && v !== null ? v.movedTo : void 0;
@@ -88253,7 +88284,7 @@ function saveTurnCursors(path3, cursors, offsets, moves = /* @__PURE__ */ new Ma
88253
88284
  } catch {
88254
88285
  }
88255
88286
  }
88256
- var turnCursorFile = (configDir) => join37(configDir, "turn-cursors.json");
88287
+ var turnCursorFile = (configDir) => join38(configDir, "turn-cursors.json");
88257
88288
  function turnCursorOnDisk(configDir, sessionId) {
88258
88289
  const path3 = turnCursorFile(configDir);
88259
88290
  const offset = loadTurnOffsets(path3).get(sessionId);
@@ -88285,7 +88316,7 @@ function gitSourceWatchTargets(root) {
88285
88316
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
88286
88317
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
88287
88318
  );
88288
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join37(root, d) + sep5));
88319
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join38(root, d) + sep5));
88289
88320
  } catch {
88290
88321
  }
88291
88322
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -88297,19 +88328,19 @@ function gitSourceWatchTargets(root) {
88297
88328
  if (!f.startsWith(prefix)) continue;
88298
88329
  const rest2 = f.slice(prefix.length);
88299
88330
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
88300
- else targets.add(join37(root, f));
88331
+ else targets.add(join38(root, f));
88301
88332
  }
88302
88333
  for (const c of children) {
88303
- if (IGNORED_PATH.test(join37(root, c) + sep5)) continue;
88334
+ if (IGNORED_PATH.test(join38(root, c) + sep5)) continue;
88304
88335
  if (hasIgnoredChild(c)) addUnder(c);
88305
- else targets.add(join37(root, c));
88336
+ else targets.add(join38(root, c));
88306
88337
  }
88307
88338
  };
88308
88339
  addUnder("");
88309
88340
  if (targets.size > 0) return [...targets];
88310
88341
  } catch {
88311
88342
  }
88312
- return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join37(root, String(e.name)) + sep5)).map((e) => join37(root, String(e.name)));
88343
+ return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join38(root, String(e.name)) + sep5)).map((e) => join38(root, String(e.name)));
88313
88344
  }
88314
88345
  function createWorkspaceEngine(opts) {
88315
88346
  const paths = workspacePaths(opts.workspaceRoot);
@@ -88403,7 +88434,7 @@ function createWorkspaceEngine(opts) {
88403
88434
  }
88404
88435
  let size = 0;
88405
88436
  try {
88406
- size = statSync11(path3).size;
88437
+ size = statSync12(path3).size;
88407
88438
  } catch {
88408
88439
  }
88409
88440
  lastActivityTs = Date.now();
@@ -88511,7 +88542,7 @@ function createWorkspaceEngine(opts) {
88511
88542
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
88512
88543
  let episodeId2;
88513
88544
  if (srcPaths.length > 0) {
88514
- const abs = srcPaths.map((p) => join37(opts.workspaceRoot, p));
88545
+ const abs = srcPaths.map((p) => join38(opts.workspaceRoot, p));
88515
88546
  try {
88516
88547
  const r = await runReindexPass(
88517
88548
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -88547,8 +88578,8 @@ function createWorkspaceEngine(opts) {
88547
88578
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
88548
88579
  );
88549
88580
  };
88550
- const gitDir = join37(opts.workspaceRoot, ".git");
88551
- if (existsSync28(gitDir)) {
88581
+ const gitDir = join38(opts.workspaceRoot, ".git");
88582
+ if (existsSync29(gitDir)) {
88552
88583
  stopGit = startGitSensor(gitDir, (ev) => {
88553
88584
  void handleGitEvent(ev).catch((err2) => {
88554
88585
  console.warn("[errata] git event handler failed:", err2);
@@ -88609,7 +88640,7 @@ function createWorkspaceEngine(opts) {
88609
88640
  },
88610
88641
  onAlarms: (alarms) => {
88611
88642
  toastLivenessAlarms(
88612
- sharedAlarmToastGate(join37(globalDir(), "liveness-toasts.json")),
88643
+ sharedAlarmToastGate(join38(globalDir(), "liveness-toasts.json")),
88613
88644
  { root: opts.workspaceRoot, name: profile.name },
88614
88645
  alarms,
88615
88646
  (body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
@@ -88626,7 +88657,7 @@ function createWorkspaceEngine(opts) {
88626
88657
  let subagentBase = null;
88627
88658
  let subagentBaseVersion = 0;
88628
88659
  const subagentRenders = /* @__PURE__ */ new Map();
88629
- const sessions = createSessionRegistry({ originsPath: join37(paths.configDir, "session-origins.json") });
88660
+ const sessions = createSessionRegistry({ originsPath: join38(paths.configDir, "session-origins.json") });
88630
88661
  const sessionRenders = /* @__PURE__ */ new Map();
88631
88662
  const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
88632
88663
  const supersessionAsks = new SupersessionAsks();
@@ -88731,7 +88762,7 @@ function createWorkspaceEngine(opts) {
88731
88762
  const elicit = isEdgeElicitationEnabled();
88732
88763
  const snapOpts = {
88733
88764
  profile,
88734
- atCommit: readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0,
88765
+ atCommit: readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0,
88735
88766
  reviewCount: pendingCount(paths),
88736
88767
  reviewUiUrl: opts.reviewUrl(),
88737
88768
  workingFile: workingFiles.mostRecent() ?? void 0,
@@ -88771,7 +88802,7 @@ function createWorkspaceEngine(opts) {
88771
88802
  );
88772
88803
  return null;
88773
88804
  }) : null;
88774
- if (snapOpts.atCommit !== (readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0)) {
88805
+ if (snapOpts.atCommit !== (readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0)) {
88775
88806
  contextDirty = true;
88776
88807
  return;
88777
88808
  }
@@ -88817,10 +88848,10 @@ function createWorkspaceEngine(opts) {
88817
88848
  } catch (err2) {
88818
88849
  console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
88819
88850
  }
88820
- const target = join37(opts.workspaceRoot, "AGENTS.md");
88851
+ const target = join38(opts.workspaceRoot, "AGENTS.md");
88821
88852
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
88822
88853
  if (elicit) {
88823
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), [
88854
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), [
88824
88855
  ...snapshot.recentProblems.map((r) => r.node),
88825
88856
  // Resolved-band handles: the ✓ problem AND its Solution are citable
88826
88857
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -89128,8 +89159,8 @@ function createWorkspaceEngine(opts) {
89128
89159
  const cached2 = subagentRenders.get(a.agentId);
89129
89160
  if (cached2?.key === key) return cached2.block;
89130
89161
  const elicit = isEdgeElicitationEnabled();
89131
- const handlesPath = join37(paths.configDir, "priming-handles.json");
89132
- const atCommit = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89162
+ const handlesPath = join38(paths.configDir, "priming-handles.json");
89163
+ const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89133
89164
  const block = renderSubagentBlock({
89134
89165
  store,
89135
89166
  entry,
@@ -89184,7 +89215,7 @@ function createWorkspaceEngine(opts) {
89184
89215
  const cached2 = sessionRenders.get(sessionId);
89185
89216
  if (cached2?.key === key) return cached2.block;
89186
89217
  const elicit = isEdgeElicitationEnabled();
89187
- const atCommit = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89218
+ const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89188
89219
  const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
89189
89220
  delete scoped.workingFile;
89190
89221
  if (workingFile) {
@@ -89228,7 +89259,7 @@ function createWorkspaceEngine(opts) {
89228
89259
  ]
89229
89260
  };
89230
89261
  if (elicit && block.handleNodes.length) {
89231
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), block.handleNodes);
89262
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), block.handleNodes);
89232
89263
  }
89233
89264
  sessionRenders.delete(sessionId);
89234
89265
  sessionRenders.set(sessionId, { key, block });
@@ -89304,7 +89335,15 @@ function createWorkspaceEngine(opts) {
89304
89335
  doneHarvest();
89305
89336
  }
89306
89337
  };
89338
+ const replaySessions = /* @__PURE__ */ new Set();
89339
+ const sessionCwdSeen = /* @__PURE__ */ new Set();
89340
+ const noteSessionCwd = (sessionId, cwd) => {
89341
+ if (!cwd || !sessionId || sessionCwdSeen.has(sessionId)) return;
89342
+ sessionCwdSeen.add(sessionId);
89343
+ if (isReplayCheckout(cwd)) replaySessions.add(sessionId);
89344
+ };
89307
89345
  const harvestTextsInner = async (sessionId, items) => {
89346
+ const replay2 = replaySessions.has(sessionId);
89308
89347
  let minted = 0;
89309
89348
  let tagsSeen = 0;
89310
89349
  let vulnerabilitiesSeen = 0;
@@ -89354,7 +89393,7 @@ function createWorkspaceEngine(opts) {
89354
89393
  let processedTurns = 0;
89355
89394
  const seqAtStart = store.currentIngestSeq();
89356
89395
  const elicit = isEdgeElicitationEnabled();
89357
- const handleMap = elicit ? readPrimingHandles(join37(paths.configDir, "priming-handles.json")) : {};
89396
+ const handleMap = elicit ? readPrimingHandles(join38(paths.configDir, "priming-handles.json")) : {};
89358
89397
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
89359
89398
  const toRel = (abs) => {
89360
89399
  const p = abs.replace(/\\/g, "/");
@@ -89406,7 +89445,8 @@ function createWorkspaceEngine(opts) {
89406
89445
  workspaceId: profile.id,
89407
89446
  source: sessionId,
89408
89447
  ts: t,
89409
- hostHarness: turn.hostHarness
89448
+ hostHarness: turn.hostHarness,
89449
+ replay: replay2
89410
89450
  });
89411
89451
  if (r.created || r.corroborated) minted++;
89412
89452
  else if (r.rejected) tagsRejected++;
@@ -89573,7 +89613,7 @@ function createWorkspaceEngine(opts) {
89573
89613
  let anchorReadFailed = false;
89574
89614
  if (p.location) {
89575
89615
  try {
89576
- fileText = readFileSync33(join37(opts.workspaceRoot, p.location.path), "utf8");
89616
+ fileText = readFileSync34(join38(opts.workspaceRoot, p.location.path), "utf8");
89577
89617
  } catch {
89578
89618
  anchorReadFailed = true;
89579
89619
  }
@@ -89585,7 +89625,7 @@ function createWorkspaceEngine(opts) {
89585
89625
  line: p.location?.line,
89586
89626
  fileText,
89587
89627
  existingId: p.threadId ? threads.get(p.threadId) ?? handleMap[p.threadId]?.id ?? store.getNode(p.threadId)?.id : void 0
89588
- }, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness });
89628
+ }, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness, replay: replay2 });
89589
89629
  let anchorDisposition = p.location ? "unresolved" : "absent";
89590
89630
  if (result.rejected) {
89591
89631
  tagsRejected++;
@@ -89673,13 +89713,14 @@ function createWorkspaceEngine(opts) {
89673
89713
  workspaceId: profile.id,
89674
89714
  source: sessionId,
89675
89715
  ts: t,
89676
- hostHarness: turn.hostHarness
89716
+ hostHarness: turn.hostHarness,
89717
+ replay: replay2
89677
89718
  });
89678
89719
  if (!r.rejected && r.problemId) {
89679
89720
  findingIds.set(p.statement, r.problemId);
89680
89721
  if (p.threadId) threads.set(p.threadId, r.problemId);
89681
89722
  }
89682
- if (r.created && dedupPath) {
89723
+ if (r.created && dedupPath && !replay2) {
89683
89724
  try {
89684
89725
  const closedId = findResolvedAnchorMatch(store, dedupPath, profile.id, p.statement, p.kind);
89685
89726
  const touch = closedId ? markResolvedRecurrence(store, closedId, t, sessionId) : { marked: false, reopened: false };
@@ -89735,10 +89776,10 @@ function createWorkspaceEngine(opts) {
89735
89776
  let enclosing = {};
89736
89777
  if (p.location?.line !== void 0) {
89737
89778
  try {
89738
- const headSha = readGitRefState(join37(opts.workspaceRoot, ".git")).sha ?? void 0;
89779
+ const headSha = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
89739
89780
  enclosing = {
89740
89781
  line: p.location.line,
89741
- fileText: readFileSync33(join37(opts.workspaceRoot, anchorPath), "utf8"),
89782
+ fileText: readFileSync34(join38(opts.workspaceRoot, anchorPath), "utf8"),
89742
89783
  ...headSha ? { headSha } : {}
89743
89784
  };
89744
89785
  } catch {
@@ -90364,11 +90405,12 @@ function createWorkspaceEngine(opts) {
90364
90405
  }
90365
90406
  turns = next.turns;
90366
90407
  nextOffset = next.nextOffset;
90367
- await new Promise((resolve10) => setImmediate(resolve10));
90408
+ await new Promise((resolve11) => setImmediate(resolve11));
90368
90409
  }
90369
90410
  };
90370
90411
  const seenMessageIds = /* @__PURE__ */ new Set();
90371
90412
  const onMessage = (e) => {
90413
+ noteSessionCwd(e.sessionId, e.cwd);
90372
90414
  if (e.messageId) {
90373
90415
  if (seenMessageIds.has(e.messageId)) return;
90374
90416
  seenMessageIds.add(e.messageId);
@@ -90421,6 +90463,7 @@ function createWorkspaceEngine(opts) {
90421
90463
  }
90422
90464
  };
90423
90465
  const onTurn = (e) => {
90466
+ noteSessionCwd(e.sessionId, e.cwd);
90424
90467
  setImmediate(() => void harvestSession(e.sessionId, e.transcriptPath));
90425
90468
  };
90426
90469
  setImmediate(() => {
@@ -90610,7 +90653,7 @@ B: ${b}`,
90610
90653
  try {
90611
90654
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
90612
90655
  emitAndProjectSkills(opts.workspaceRoot, inputs);
90613
- writePrimingHandles(join37(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
90656
+ writePrimingHandles(join38(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
90614
90657
  } catch (err2) {
90615
90658
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
90616
90659
  }
@@ -90977,7 +91020,7 @@ B: ${b}`,
90977
91020
  console.log(
90978
91021
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
90979
91022
  );
90980
- const pending = existsSync28(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
91023
+ const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
90981
91024
  return { uploaded: 0, failed: 0, remaining: pending };
90982
91025
  }
90983
91026
  if (!shipsFromWorkspace(opts.workspaceRoot)) {
@@ -90989,7 +91032,7 @@ B: ${b}`,
90989
91032
  console.log(
90990
91033
  "[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
90991
91034
  );
90992
- const pending = existsSync28(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
91035
+ const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
90993
91036
  return { uploaded: 0, failed: 0, remaining: pending };
90994
91037
  }
90995
91038
  try {
@@ -91166,7 +91209,7 @@ async function startDaemon(opts) {
91166
91209
  );
91167
91210
  await engine.stop();
91168
91211
  try {
91169
- if (existsSync29(engine.paths.daemonLock)) {
91212
+ if (existsSync30(engine.paths.daemonLock)) {
91170
91213
  }
91171
91214
  } catch {
91172
91215
  }
@@ -91174,9 +91217,9 @@ async function startDaemon(opts) {
91174
91217
  };
91175
91218
  }
91176
91219
  async function listenServer(fetchFn, port) {
91177
- return new Promise((resolve10, reject) => {
91220
+ return new Promise((resolve11, reject) => {
91178
91221
  const server = serve({ fetch: withLoopbackGuard(fetchFn), hostname: "127.0.0.1", port }, (info2) => {
91179
- resolve10({ server, port: info2.port });
91222
+ resolve11({ server, port: info2.port });
91180
91223
  });
91181
91224
  server.once(
91182
91225
  "error",
@@ -91367,8 +91410,8 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
91367
91410
  }
91368
91411
 
91369
91412
  // src/edge-park.ts
91370
- import { readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
91371
- import { dirname as dirname14, join as join38 } from "node:path";
91413
+ import { readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
91414
+ import { dirname as dirname15, join as join39 } from "node:path";
91372
91415
  var EDGE_PARK_CAP = 2e3;
91373
91416
  var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
91374
91417
  var EDGE_PARK_MAX_ATTEMPTS = 6;
@@ -91383,12 +91426,12 @@ function wireEdgeKey(from, type, to) {
91383
91426
  return JSON.stringify([from, type, to]);
91384
91427
  }
91385
91428
  function edgeParkPath(workspaceConfigDir, destinationKey) {
91386
- return join38(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
91429
+ return join39(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
91387
91430
  }
91388
91431
  function loadEdgePark(path3) {
91389
91432
  let raw2;
91390
91433
  try {
91391
- raw2 = JSON.parse(readFileSync34(path3, "utf8"));
91434
+ raw2 = JSON.parse(readFileSync35(path3, "utf8"));
91392
91435
  } catch {
91393
91436
  return [];
91394
91437
  }
@@ -91399,7 +91442,7 @@ function loadEdgePark(path3) {
91399
91442
  }
91400
91443
  function saveEdgePark(path3, queue) {
91401
91444
  try {
91402
- const tmp = join38(dirname14(path3), `.${Date.now()}.edge-park.tmp`);
91445
+ const tmp = join39(dirname15(path3), `.${Date.now()}.edge-park.tmp`);
91403
91446
  writeFileSync26(tmp, JSON.stringify(queue), "utf8");
91404
91447
  renameSync6(tmp, path3);
91405
91448
  } catch {
@@ -91722,8 +91765,8 @@ function invalidateInstanceReceipt(current, destination, failedId, mirrorLegacy)
91722
91765
  // src/multi.ts
91723
91766
  init_dist();
91724
91767
  init_src5();
91725
- import { existsSync as existsSync34, readFileSync as readFileSync40, writeFileSync as writeFileSync29 } from "node:fs";
91726
- import { basename as basename10, dirname as dirname17, join as join47, resolve as pathResolve } from "node:path";
91768
+ import { existsSync as existsSync35, readFileSync as readFileSync41, writeFileSync as writeFileSync29 } from "node:fs";
91769
+ import { basename as basename10, dirname as dirname18, join as join48, resolve as pathResolve } from "node:path";
91727
91770
 
91728
91771
  // src/principle-sync.ts
91729
91772
  init_src5();
@@ -91751,8 +91794,8 @@ init_reconcile();
91751
91794
 
91752
91795
  // src/lockfile-auto.ts
91753
91796
  init_src();
91754
- import { existsSync as existsSync30, readFileSync as readFileSync35 } from "node:fs";
91755
- import { join as join39 } from "node:path";
91797
+ import { existsSync as existsSync31, readFileSync as readFileSync36 } from "node:fs";
91798
+ import { join as join40 } from "node:path";
91756
91799
 
91757
91800
  // src/package-index.ts
91758
91801
  init_src();
@@ -91925,11 +91968,11 @@ function runLockfilePass(opts) {
91925
91968
  { file: "package-lock.json", parse: parsePackageLockJson }
91926
91969
  ];
91927
91970
  for (const c of candidates) {
91928
- const p = join39(opts.root, c.file);
91929
- if (!existsSync30(p)) continue;
91971
+ const p = join40(opts.root, c.file);
91972
+ if (!existsSync31(p)) continue;
91930
91973
  let sbom;
91931
91974
  try {
91932
- sbom = c.parse(readFileSync35(p, "utf8"));
91975
+ sbom = c.parse(readFileSync36(p, "utf8"));
91933
91976
  } catch {
91934
91977
  continue;
91935
91978
  }
@@ -91990,8 +92033,8 @@ init_profile2();
91990
92033
  init_session_registry();
91991
92034
 
91992
92035
  // src/public-symbols.ts
91993
- import { readFileSync as readFileSync36, readdirSync as readdirSync12, existsSync as existsSync31 } from "node:fs";
91994
- import { join as join40 } from "node:path";
92036
+ import { readFileSync as readFileSync37, readdirSync as readdirSync12, existsSync as existsSync32 } from "node:fs";
92037
+ import { join as join41 } from "node:path";
91995
92038
  var HEAD_BYTES = 8 * 1024;
91996
92039
  var INDEX_TTL_MS = 10 * 60 * 1e3;
91997
92040
  var MIN_SYMBOL_LEN = 4;
@@ -92024,20 +92067,20 @@ function bindingNames(clause) {
92024
92067
  function internalPackageNames(workspaceRoot) {
92025
92068
  const names = /* @__PURE__ */ new Set();
92026
92069
  const tryRead = (dir) => {
92027
- const pj = join40(dir, "package.json");
92028
- if (!existsSync31(pj)) return;
92070
+ const pj = join41(dir, "package.json");
92071
+ if (!existsSync32(pj)) return;
92029
92072
  try {
92030
- const name2 = JSON.parse(readFileSync36(pj, "utf8")).name;
92073
+ const name2 = JSON.parse(readFileSync37(pj, "utf8")).name;
92031
92074
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
92032
92075
  } catch {
92033
92076
  }
92034
92077
  };
92035
92078
  tryRead(workspaceRoot);
92036
92079
  for (const group of ["packages", "apps"]) {
92037
- const groupDir = join40(workspaceRoot, group);
92038
- if (!existsSync31(groupDir)) continue;
92080
+ const groupDir = join41(workspaceRoot, group);
92081
+ if (!existsSync32(groupDir)) continue;
92039
92082
  try {
92040
- for (const entry of readdirSync12(groupDir)) tryRead(join40(groupDir, entry));
92083
+ for (const entry of readdirSync12(groupDir)) tryRead(join41(groupDir, entry));
92041
92084
  } catch {
92042
92085
  }
92043
92086
  }
@@ -92056,7 +92099,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
92056
92099
  }
92057
92100
  const readHead = deps.readHead ?? ((absPath) => {
92058
92101
  try {
92059
- return readFileSync36(absPath, "utf8").slice(0, HEAD_BYTES);
92102
+ return readFileSync37(absPath, "utf8").slice(0, HEAD_BYTES);
92060
92103
  } catch {
92061
92104
  return "";
92062
92105
  }
@@ -92076,7 +92119,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
92076
92119
  }
92077
92120
  const symbols = /* @__PURE__ */ new Set();
92078
92121
  for (const rel of files) {
92079
- const head2 = readHead(join40(workspaceRoot, rel));
92122
+ const head2 = readHead(join41(workspaceRoot, rel));
92080
92123
  if (!head2) continue;
92081
92124
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
92082
92125
  re.lastIndex = 0;
@@ -92880,8 +92923,8 @@ var ConsolidateWorker = class {
92880
92923
  const id = this.nextId++;
92881
92924
  try {
92882
92925
  await this.ready;
92883
- return await new Promise((resolve10, reject) => {
92884
- this.pending.set(id, { resolve: resolve10, reject });
92926
+ return await new Promise((resolve11, reject) => {
92927
+ this.pending.set(id, { resolve: resolve11, reject });
92885
92928
  this.worker.postMessage({ ...req, id });
92886
92929
  });
92887
92930
  } finally {
@@ -92911,12 +92954,12 @@ var ConsolidateWorker = class {
92911
92954
  });
92912
92955
  noteIsolateSpawned();
92913
92956
  this.worker = worker;
92914
- this.ready = new Promise((resolve10, reject) => {
92957
+ this.ready = new Promise((resolve11, reject) => {
92915
92958
  const onReady = (m) => {
92916
92959
  if (m?.ready) {
92917
92960
  worker.off("message", onReady);
92918
92961
  worker.off("error", onErr);
92919
- resolve10();
92962
+ resolve11();
92920
92963
  }
92921
92964
  };
92922
92965
  const onErr = (err2) => {
@@ -92974,8 +93017,8 @@ var GeneralizeWorker = class {
92974
93017
  this.touch();
92975
93018
  await this.ready;
92976
93019
  const id = this.nextId++;
92977
- return new Promise((resolve10, reject) => {
92978
- this.pending.set(id, { resolve: resolve10, reject });
93020
+ return new Promise((resolve11, reject) => {
93021
+ this.pending.set(id, { resolve: resolve11, reject });
92979
93022
  const req = { id, castaliaPath, text };
92980
93023
  this.worker.postMessage(req);
92981
93024
  });
@@ -93001,12 +93044,12 @@ var GeneralizeWorker = class {
93001
93044
  });
93002
93045
  noteIsolateSpawned();
93003
93046
  this.worker = worker;
93004
- this.ready = new Promise((resolve10, reject) => {
93047
+ this.ready = new Promise((resolve11, reject) => {
93005
93048
  const onReady = (m) => {
93006
93049
  if (m?.ready) {
93007
93050
  worker.off("message", onReady);
93008
93051
  worker.off("error", onErr);
93009
- resolve10();
93052
+ resolve11();
93010
93053
  }
93011
93054
  };
93012
93055
  const onErr = (err2) => {
@@ -93107,7 +93150,7 @@ init_config();
93107
93150
 
93108
93151
  // src/update.ts
93109
93152
  import { spawn as spawn2 } from "node:child_process";
93110
- import { isAbsolute as isAbsolute5, join as join41 } from "node:path";
93153
+ import { isAbsolute as isAbsolute6, join as join42 } from "node:path";
93111
93154
  var PACKAGE_NAME = "@inerrata-corporation/errata";
93112
93155
  function parse3(v) {
93113
93156
  const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
@@ -93227,17 +93270,17 @@ function startUpdatePoller(opts) {
93227
93270
  };
93228
93271
  }
93229
93272
  function runNpmInstall(channel) {
93230
- return new Promise((resolve10) => {
93273
+ return new Promise((resolve11) => {
93231
93274
  const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
93232
93275
  stdio: "inherit",
93233
93276
  shell: true
93234
93277
  });
93235
- child.on("close", (code) => resolve10(code ?? 1));
93236
- child.on("error", () => resolve10(1));
93278
+ child.on("close", (code) => resolve11(code ?? 1));
93279
+ child.on("error", () => resolve11(1));
93237
93280
  });
93238
93281
  }
93239
93282
  async function runInstalledHookRefresh() {
93240
- const root = await new Promise((resolve10) => {
93283
+ const root = await new Promise((resolve11) => {
93241
93284
  const child = spawn2("npm", ["root", "-g"], {
93242
93285
  shell: true,
93243
93286
  windowsHide: true,
@@ -93249,18 +93292,18 @@ async function runInstalledHookRefresh() {
93249
93292
  output += chunk;
93250
93293
  if (output.length > 32768) child.kill();
93251
93294
  });
93252
- child.on("error", () => resolve10(""));
93253
- child.on("close", (code) => resolve10(code === 0 ? output.trim() : ""));
93295
+ child.on("error", () => resolve11(""));
93296
+ child.on("close", (code) => resolve11(code === 0 ? output.trim() : ""));
93254
93297
  });
93255
- if (!isAbsolute5(root)) return 1;
93256
- return new Promise((resolve10) => {
93257
- const child = spawn2(process.execPath, [join41(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
93298
+ if (!isAbsolute6(root)) return 1;
93299
+ return new Promise((resolve11) => {
93300
+ const child = spawn2(process.execPath, [join42(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
93258
93301
  windowsHide: true,
93259
93302
  stdio: "inherit",
93260
93303
  timeout: 3e4
93261
93304
  });
93262
- child.on("error", () => resolve10(1));
93263
- child.on("close", (code) => resolve10(code ?? 1));
93305
+ child.on("error", () => resolve11(1));
93306
+ child.on("close", (code) => resolve11(code ?? 1));
93264
93307
  });
93265
93308
  }
93266
93309
 
@@ -93275,7 +93318,7 @@ function liveCloudClient(src) {
93275
93318
  let current = null;
93276
93319
  let currentKey = "";
93277
93320
  let checkedAt = -Infinity;
93278
- const resolve10 = () => {
93321
+ const resolve11 = () => {
93279
93322
  const t = now();
93280
93323
  if (current && t - checkedAt < recheckMs) return current;
93281
93324
  checkedAt = t;
@@ -93295,7 +93338,7 @@ function liveCloudClient(src) {
93295
93338
  };
93296
93339
  return new Proxy({}, {
93297
93340
  get(_target, prop) {
93298
- const client = resolve10();
93341
+ const client = resolve11();
93299
93342
  const value = Reflect.get(client, prop, client);
93300
93343
  return typeof value === "function" ? value.bind(client) : value;
93301
93344
  }
@@ -93400,12 +93443,12 @@ function landCloudEdge(store, e, from, to) {
93400
93443
  }
93401
93444
 
93402
93445
  // src/causal-edge-queue.ts
93403
- import { readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
93404
- import { dirname as dirname15, join as join42 } from "node:path";
93446
+ import { readFileSync as readFileSync38, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
93447
+ import { dirname as dirname16, join as join43 } from "node:path";
93405
93448
  var CAUSAL_EDGE_QUEUE_CAP = 5e3;
93406
93449
  var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
93407
93450
  function causalEdgeQueuePath(workspaceConfigDir) {
93408
- return join42(workspaceConfigDir, "causal-edge-queue.json");
93451
+ return join43(workspaceConfigDir, "causal-edge-queue.json");
93409
93452
  }
93410
93453
  function parkedEdgeKey(e) {
93411
93454
  return `${e.from}|${e.type}|${e.to}`;
@@ -93413,7 +93456,7 @@ function parkedEdgeKey(e) {
93413
93456
  function loadCausalEdgeQueue(path3) {
93414
93457
  let raw2;
93415
93458
  try {
93416
- raw2 = JSON.parse(readFileSync37(path3, "utf8"));
93459
+ raw2 = JSON.parse(readFileSync38(path3, "utf8"));
93417
93460
  } catch {
93418
93461
  return [];
93419
93462
  }
@@ -93424,7 +93467,7 @@ function loadCausalEdgeQueue(path3) {
93424
93467
  }
93425
93468
  function saveCausalEdgeQueue(path3, queue) {
93426
93469
  try {
93427
- const tmp = join42(dirname15(path3), `.${Date.now()}.causal-edge-queue.tmp`);
93470
+ const tmp = join43(dirname16(path3), `.${Date.now()}.causal-edge-queue.tmp`);
93428
93471
  writeFileSync27(tmp, JSON.stringify(queue), "utf8");
93429
93472
  renameSync7(tmp, path3);
93430
93473
  } catch {
@@ -93856,9 +93899,9 @@ init_src11();
93856
93899
  init_src();
93857
93900
  import { execFile as execFile6 } from "node:child_process";
93858
93901
  import { promisify as promisify4 } from "node:util";
93859
- import { extname as extname3, join as join43 } from "node:path";
93902
+ import { extname as extname3, join as join44 } from "node:path";
93860
93903
  import { createHash as createHash19 } from "node:crypto";
93861
- import { readFileSync as readFileSync38 } from "node:fs";
93904
+ import { readFileSync as readFileSync39 } from "node:fs";
93862
93905
 
93863
93906
  // src/history-dependency-snapshot.ts
93864
93907
  init_src();
@@ -93981,7 +94024,7 @@ var Bounded = class extends Map {
93981
94024
  var DEFAULT_GIT = {};
93982
94025
  function readFileSafe(path3) {
93983
94026
  try {
93984
- return readFileSync38(path3, "utf8");
94027
+ return readFileSync39(path3, "utf8");
93985
94028
  } catch {
93986
94029
  return "";
93987
94030
  }
@@ -94012,13 +94055,13 @@ async function syncHistoryRevision(opts) {
94012
94055
  const started2 = Date.now();
94013
94056
  let changed = 0, remaining = false;
94014
94057
  const pages = Math.min(20, Math.max(1, opts.maxPages ?? 10));
94015
- const resolve10 = opts.profile.projectId ? reverseSymbolResolver({ store: opts.store, salt: opts.salt, projectId: opts.profile.projectId }) : async () => null;
94058
+ const resolve11 = opts.profile.projectId ? reverseSymbolResolver({ store: opts.store, salt: opts.salt, projectId: opts.profile.projectId }) : async () => null;
94016
94059
  for (let i2 = 0; i2 < pages; i2++) {
94017
- const result = await syncHistoryRevisionPage(opts, resolve10);
94060
+ const result = await syncHistoryRevisionPage(opts, resolve11);
94018
94061
  changed += result.changed;
94019
94062
  remaining = result.remaining;
94020
94063
  if (!remaining || result.nextBeat || Date.now() - started2 >= (opts.budgetMs ?? 45e3)) break;
94021
- await new Promise((resolve11) => setImmediate(resolve11));
94064
+ await new Promise((resolve12) => setImmediate(resolve12));
94022
94065
  }
94023
94066
  return { changed, remaining };
94024
94067
  })();
@@ -94029,13 +94072,13 @@ async function syncHistoryRevision(opts) {
94029
94072
  if (inFlight.get(opts.root) === work) inFlight.delete(opts.root);
94030
94073
  }
94031
94074
  }
94032
- async function syncHistoryRevisionPage(opts, resolve10) {
94075
+ async function syncHistoryRevisionPage(opts, resolve11) {
94033
94076
  const { root, profile, store, cloud, salt } = opts;
94034
94077
  if (!profile.projectId) return { changed: 0, remaining: false };
94035
94078
  const projectId = profile.projectId;
94036
94079
  const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
94037
94080
  const caches = cachesFor(opts.git ?? DEFAULT_GIT);
94038
- const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join43(root, ".errataignore"))).digest("hex").slice(0, 16);
94081
+ const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join44(root, ".errataignore"))).digest("hex").slice(0, 16);
94039
94082
  const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
94040
94083
  if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
94041
94084
  const oldCursor = profile.historyRevisionCursor;
@@ -94163,7 +94206,7 @@ async function syncHistoryRevisionPage(opts, resolve10) {
94163
94206
  const paths = /* @__PURE__ */ new Set(), symbols = [];
94164
94207
  let partial2 = false;
94165
94208
  for (const anchor of anchors ?? []) {
94166
- const localId = await resolve10(anchor.symbolId), local = localId ? store.getNode(localId) : null;
94209
+ const localId = await resolve11(anchor.symbolId), local = localId ? store.getNode(localId) : null;
94167
94210
  const path3 = local?.attrs["relPath"];
94168
94211
  if (typeof path3 !== "string" || !pathAllowedByFloor(path3) || isPathBlocked(ignore2, path3) || /[\r\n]/.test(path3)) continue;
94169
94212
  paths.add(path3);
@@ -94355,8 +94398,8 @@ ${await git3(["rev-list", "--parents", "-1", from])}`.split("\n").map((row) => r
94355
94398
  init_src7();
94356
94399
  init_src();
94357
94400
  import { execFile as execFile7 } from "node:child_process";
94358
- import { readFileSync as readFileSync39 } from "node:fs";
94359
- import { join as join44 } from "node:path";
94401
+ import { readFileSync as readFileSync40 } from "node:fs";
94402
+ import { join as join45 } from "node:path";
94360
94403
  import { promisify as promisify5 } from "node:util";
94361
94404
 
94362
94405
  // src/history-walk.ts
@@ -94763,8 +94806,8 @@ var GitBlobReader = class {
94763
94806
  if (this.failed) return Promise.reject(this.failed);
94764
94807
  if (/[\r\n]/.test(spec)) return Promise.resolve(null);
94765
94808
  const proc = this.start();
94766
- return new Promise((resolve10, reject) => {
94767
- this.queue.push({ resolve: resolve10, reject });
94809
+ return new Promise((resolve11, reject) => {
94810
+ this.queue.push({ resolve: resolve11, reject });
94768
94811
  proc.stdin.write(`${spec}
94769
94812
  `);
94770
94813
  });
@@ -94778,14 +94821,14 @@ var GitBlobReader = class {
94778
94821
  const proc = this.proc;
94779
94822
  this.proc = null;
94780
94823
  if (!proc || proc.exitCode !== null) return Promise.resolve();
94781
- return new Promise((resolve10) => {
94824
+ return new Promise((resolve11) => {
94782
94825
  const timer = setTimeout(() => {
94783
94826
  proc.kill();
94784
- resolve10();
94827
+ resolve11();
94785
94828
  }, timeoutMs);
94786
94829
  proc.once("exit", () => {
94787
94830
  clearTimeout(timer);
94788
- resolve10();
94831
+ resolve11();
94789
94832
  });
94790
94833
  proc.stdin.end();
94791
94834
  });
@@ -94915,7 +94958,7 @@ async function defaultGit(root, args2) {
94915
94958
  function readIgnoreLines(root, profile) {
94916
94959
  let lines = [];
94917
94960
  try {
94918
- lines = readFileSync39(join44(root, ".errataignore"), "utf8").split("\n");
94961
+ lines = readFileSync40(join45(root, ".errataignore"), "utf8").split("\n");
94919
94962
  } catch {
94920
94963
  }
94921
94964
  return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
@@ -95495,8 +95538,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
95495
95538
  init_cloud_auth();
95496
95539
  import { createHash as createHash20 } from "node:crypto";
95497
95540
  import { execFileSync as execFileSync7 } from "node:child_process";
95498
- import { existsSync as existsSync32, writeFileSync as writeFileSync28 } from "node:fs";
95499
- import { join as join45 } from "node:path";
95541
+ import { existsSync as existsSync33, writeFileSync as writeFileSync28 } from "node:fs";
95542
+ import { join as join46 } from "node:path";
95500
95543
 
95501
95544
  // src/device-poll.ts
95502
95545
  var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
@@ -95586,7 +95629,7 @@ async function loginOAuthDevice(opts) {
95586
95629
  let deviceSession = null;
95587
95630
  let approvedInstallation = null;
95588
95631
  while (Date.now() < deadline) {
95589
- await (opts.sleep ?? ((ms) => new Promise((resolve10) => setTimeout(resolve10, ms))))(waitMs);
95632
+ await (opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms))))(waitMs);
95590
95633
  waitMs = intervalMs;
95591
95634
  const poll = await fetchDevicePoll(fetchFn, device.token, {
95592
95635
  method: "POST",
@@ -95711,7 +95754,7 @@ async function loginOAuthLoopback(opts) {
95711
95754
  const state = randomState();
95712
95755
  const scope = opts.scope ?? CODE_FLOW_OAUTH_SCOPE;
95713
95756
  const { code, redirectUri, clientId } = await new Promise(
95714
- (resolve10, reject) => {
95757
+ (resolve11, reject) => {
95715
95758
  const server = createServer((req, res) => {
95716
95759
  const u = new URL(req.url ?? "/", "http://127.0.0.1");
95717
95760
  if (u.pathname !== "/callback") {
@@ -95734,7 +95777,7 @@ async function loginOAuthLoopback(opts) {
95734
95777
  res.writeHead(200, { "content-type": "text/html" });
95735
95778
  res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
95736
95779
  server.close();
95737
- resolve10({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
95780
+ resolve11({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
95738
95781
  });
95739
95782
  let activeClientId = oauthClientId();
95740
95783
  server.on("error", reject);
@@ -95833,7 +95876,7 @@ async function linkThroughConsole(opts) {
95833
95876
  const deadline = Date.now() + Math.min(code.expires_in * 1e3, opts.timeoutMs ?? Number.POSITIVE_INFINITY);
95834
95877
  let intervalMs = Math.max(2, code.interval ?? 5) * 1e3;
95835
95878
  let waitMs = intervalMs;
95836
- const sleep = opts.sleep ?? ((ms) => new Promise((resolve10) => setTimeout(resolve10, ms)));
95879
+ const sleep = opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms)));
95837
95880
  while (Date.now() < deadline) {
95838
95881
  await sleep(waitMs);
95839
95882
  waitMs = intervalMs;
@@ -95955,8 +95998,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
95955
95998
  delete nextProfile.projectLinkHold;
95956
95999
  let wroteIgnore = false;
95957
96000
  if (decision.writeIgnoreStarter !== false) {
95958
- const target = join45(root, ".errataignore");
95959
- if (!existsSync32(target)) {
96001
+ const target = join46(root, ".errataignore");
96002
+ if (!existsSync33(target)) {
95960
96003
  writeFileSync28(target, IGNORE_STARTER, "utf8");
95961
96004
  wroteIgnore = true;
95962
96005
  }
@@ -95970,13 +96013,13 @@ init_registry();
95970
96013
 
95971
96014
  // src/adopt.ts
95972
96015
  init_git_remote();
95973
- import { existsSync as existsSync33 } from "node:fs";
95974
- import { dirname as dirname16, join as join46 } from "node:path";
96016
+ import { existsSync as existsSync34 } from "node:fs";
96017
+ import { dirname as dirname17, join as join47 } from "node:path";
95975
96018
  function findGitRoot(absPath) {
95976
96019
  let dir = absPath;
95977
96020
  for (let depth = 0; depth < 64; depth++) {
95978
- if (existsSync33(join46(dir, ".git"))) return dir;
95979
- const parent = dirname16(dir);
96021
+ if (existsSync34(join47(dir, ".git"))) return dir;
96022
+ const parent = dirname17(dir);
95980
96023
  if (parent === dir) return null;
95981
96024
  dir = parent;
95982
96025
  }
@@ -96389,7 +96432,7 @@ function resolveWorkspaceRef(ref, entries, ownerRoot) {
96389
96432
 
96390
96433
  // src/rehome.ts
96391
96434
  init_src2();
96392
- import { isAbsolute as isAbsolute6 } from "node:path";
96435
+ import { isAbsolute as isAbsolute7 } from "node:path";
96393
96436
  function sourcesOf(n) {
96394
96437
  const s = n.attrs["sources"];
96395
96438
  return Array.isArray(s) ? s.filter((x) => typeof x === "string") : [];
@@ -96453,7 +96496,7 @@ function captureWorkPaths(store, home) {
96453
96496
  if (store.outEdges(row.id, ["ANCHORED_AT"]).length > 0) where = home;
96454
96497
  else {
96455
96498
  const hint = row.attrs["anchorHint"];
96456
- if (typeof hint?.path === "string" && hint.path.length > 0) where = isAbsolute6(hint.path) ? hint.path : home;
96499
+ if (typeof hint?.path === "string" && hint.path.length > 0) where = isAbsolute7(hint.path) ? hint.path : home;
96457
96500
  }
96458
96501
  for (const s of sources) {
96459
96502
  const list = out2.get(s) ?? [];
@@ -96618,7 +96661,7 @@ async function startMultiDaemon(opts = {}) {
96618
96661
  };
96619
96662
  const sharedDbPath = sharedStorePath();
96620
96663
  ensureParent(sharedDbPath);
96621
- if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname17(sharedDbPath));
96664
+ if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname18(sharedDbPath));
96622
96665
  await prepareStore(sharedDbPath, process.cwd(), "shared");
96623
96666
  const sharedStore = openGraphStore({ path: sharedDbPath });
96624
96667
  const bundledRun = import.meta.url.endsWith(".mjs");
@@ -96762,7 +96805,7 @@ async function startMultiDaemon(opts = {}) {
96762
96805
  held.push(...quarantined);
96763
96806
  let ignoreFile = "";
96764
96807
  try {
96765
- ignoreFile = readFileSync40(join47(r.root, ".errataignore"), "utf8");
96808
+ ignoreFile = readFileSync41(join48(r.root, ".errataignore"), "utf8");
96766
96809
  } catch {
96767
96810
  }
96768
96811
  const retryInputs = JSON.stringify([
@@ -96830,7 +96873,7 @@ async function startMultiDaemon(opts = {}) {
96830
96873
  const id = entry.id;
96831
96874
  const castaliaPath = workspacePaths(entry.path).castalia;
96832
96875
  ensureParent(castaliaPath);
96833
- excludeFromIndexing(dirname17(castaliaPath));
96876
+ excludeFromIndexing(dirname18(castaliaPath));
96834
96877
  await prepareStore(castaliaPath, entry.path, id);
96835
96878
  if (stopping) throw new Error("daemon stopping");
96836
96879
  const wsIdentity = identityFor(entry);
@@ -97337,10 +97380,10 @@ async function startMultiDaemon(opts = {}) {
97337
97380
  };
97338
97381
  const MISFILED_SWEEP_DELAY_MS = 2 * 6e4;
97339
97382
  const sweepMisfiled = async (rec) => {
97340
- const checkedPath = join47(workspacePaths(rec.root).configDir, "rehome-checked.json");
97383
+ const checkedPath = join48(workspacePaths(rec.root).configDir, "rehome-checked.json");
97341
97384
  let checked;
97342
97385
  try {
97343
- checked = new Set(JSON.parse(readFileSync40(checkedPath, "utf8")));
97386
+ checked = new Set(JSON.parse(readFileSync41(checkedPath, "utf8")));
97344
97387
  } catch {
97345
97388
  checked = /* @__PURE__ */ new Set();
97346
97389
  }
@@ -97459,7 +97502,7 @@ async function startMultiDaemon(opts = {}) {
97459
97502
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
97460
97503
  } catch {
97461
97504
  }
97462
- const reason = retireDecision({ exists: existsSync34(rec.root), lastActiveAt, now });
97505
+ const reason = retireDecision({ exists: existsSync35(rec.root), lastActiveAt, now });
97463
97506
  if (reason) void retireWorkspace(rec, reason);
97464
97507
  }
97465
97508
  };
@@ -97822,7 +97865,7 @@ async function startMultiDaemon(opts = {}) {
97822
97865
  const packageAutoAll = async () => {
97823
97866
  const out2 = /* @__PURE__ */ new Map();
97824
97867
  for (const r of records) {
97825
- await new Promise((resolve10) => setImmediate(resolve10));
97868
+ await new Promise((resolve11) => setImmediate(resolve11));
97826
97869
  const done = markPass(`package-index:${r.entry.name}`);
97827
97870
  try {
97828
97871
  out2.set(
@@ -99086,15 +99129,15 @@ function shouldUseOAuthLogin(flags2, env2 = process.env) {
99086
99129
  import { spawnSync as spawnSync2 } from "node:child_process";
99087
99130
 
99088
99131
  // src/codex-runtime.ts
99089
- import { readdirSync as readdirSync13, statSync as statSync12 } from "node:fs";
99090
- import { join as join48 } from "node:path";
99132
+ import { readdirSync as readdirSync13, statSync as statSync13 } from "node:fs";
99133
+ import { join as join49 } from "node:path";
99091
99134
  function resolveCodexExecutable(options = {}) {
99092
99135
  const platform = options.platform ?? process.platform;
99093
99136
  const env2 = options.env ?? process.env;
99094
99137
  if (platform !== "win32") return "codex";
99095
99138
  const fileTime = (path3) => {
99096
99139
  try {
99097
- const s = statSync12(path3);
99140
+ const s = statSync13(path3);
99098
99141
  return s.isFile() ? s.mtimeMs : null;
99099
99142
  } catch {
99100
99143
  return null;
@@ -99102,13 +99145,13 @@ function resolveCodexExecutable(options = {}) {
99102
99145
  };
99103
99146
  for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
99104
99147
  if (!dir.trim()) continue;
99105
- const path3 = join48(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
99148
+ const path3 = join49(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
99106
99149
  if (fileTime(path3) !== null) return path3;
99107
99150
  }
99108
99151
  if (!env2["LOCALAPPDATA"]) return "codex";
99109
- const root = join48(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
99152
+ const root = join49(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
99110
99153
  try {
99111
- const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join48(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
99154
+ const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join49(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
99112
99155
  return candidates[0]?.path ?? "codex";
99113
99156
  } catch {
99114
99157
  return "codex";
@@ -99247,14 +99290,14 @@ async function diagnoseInstallation(cfg, dependencies) {
99247
99290
  }
99248
99291
 
99249
99292
  // src/credential-scan.ts
99250
- import { readFileSync as readFileSync42, statSync as statSync13 } from "node:fs";
99293
+ import { readFileSync as readFileSync43, statSync as statSync14 } from "node:fs";
99251
99294
  import { homedir as homedir8 } from "node:os";
99252
- import { join as join50 } from "node:path";
99295
+ import { join as join51 } from "node:path";
99253
99296
 
99254
99297
  // src/claude-statusline.ts
99255
- import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync41, writeFileSync as writeFileSync30 } from "node:fs";
99298
+ import { existsSync as existsSync36, mkdirSync as mkdirSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync30 } from "node:fs";
99256
99299
  import { homedir as homedir7 } from "node:os";
99257
- import { dirname as dirname18, join as join49 } from "node:path";
99300
+ import { dirname as dirname19, join as join50 } from "node:path";
99258
99301
  var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
99259
99302
  import { readFileSync } from 'node:fs';
99260
99303
 
@@ -99302,8 +99345,8 @@ function isSameInstall(value, relay) {
99302
99345
  return command.includes(relay.replace(/\\/g, "/").toLowerCase());
99303
99346
  }
99304
99347
  function userClaudeSettingsPath() {
99305
- const base = process.env["CLAUDE_CONFIG_DIR"] ?? join49(homedir7(), ".claude");
99306
- return join49(base, "settings.json");
99348
+ const base = process.env["CLAUDE_CONFIG_DIR"] ?? join50(homedir7(), ".claude");
99349
+ return join50(base, "settings.json");
99307
99350
  }
99308
99351
  function ensureUserStatusLine(opts) {
99309
99352
  const env2 = opts.env ?? process.env;
@@ -99311,22 +99354,22 @@ function ensureUserStatusLine(opts) {
99311
99354
  if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
99312
99355
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
99313
99356
  let settings = {};
99314
- if (existsSync35(settingsPath)) {
99357
+ if (existsSync36(settingsPath)) {
99315
99358
  try {
99316
- const parsed = JSON.parse(readFileSync41(settingsPath, "utf8"));
99359
+ const parsed = JSON.parse(readFileSync42(settingsPath, "utf8"));
99317
99360
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
99318
99361
  settings = parsed;
99319
99362
  } catch {
99320
99363
  return "unreadable";
99321
99364
  }
99322
99365
  }
99323
- const relay = join49(opts.relayDir, STATUSLINE_RELAY_FILE);
99366
+ const relay = join50(opts.relayDir, STATUSLINE_RELAY_FILE);
99324
99367
  const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
99325
99368
  const ownMain = keep(settings["statusLine"]);
99326
99369
  const ownRows = keep(settings["subagentStatusLine"]);
99327
99370
  if (ownMain && ownRows) return "kept-own";
99328
99371
  mkdirSync9(opts.relayDir, { recursive: true });
99329
- if (!existsSync35(relay) || readFileSync41(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
99372
+ if (!existsSync36(relay) || readFileSync42(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
99330
99373
  writeFileSync30(relay, STATUSLINE_RELAY_SOURCE, "utf8");
99331
99374
  }
99332
99375
  const nodePath = opts.nodePath ?? process.execPath;
@@ -99338,7 +99381,7 @@ function ensureUserStatusLine(opts) {
99338
99381
  return ownMain ? "kept-own" : "unchanged";
99339
99382
  }
99340
99383
  Object.assign(settings, next);
99341
- mkdirSync9(dirname18(settingsPath), { recursive: true });
99384
+ mkdirSync9(dirname19(settingsPath), { recursive: true });
99342
99385
  writeFileSync30(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
99343
99386
  return "installed";
99344
99387
  }
@@ -99380,36 +99423,36 @@ function findCredentialLines(text) {
99380
99423
  function harnessConfigPaths(root) {
99381
99424
  const env2 = process.env;
99382
99425
  const home = homedir8();
99383
- const codexHome = env2["CODEX_HOME"] || join50(home, ".codex");
99384
- const geminiHome = join50(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
99426
+ const codexHome = env2["CODEX_HOME"] || join51(home, ".codex");
99427
+ const geminiHome = join51(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
99385
99428
  return [
99386
99429
  // Claude Code: user settings, `claude mcp add` (local/user scope), project.
99387
99430
  userClaudeSettingsPath(),
99388
- join50(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
99389
- join50(root, ".claude", "settings.json"),
99390
- join50(root, ".claude", "settings.local.json"),
99391
- join50(root, ".mcp.json"),
99431
+ join51(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
99432
+ join51(root, ".claude", "settings.json"),
99433
+ join51(root, ".claude", "settings.local.json"),
99434
+ join51(root, ".mcp.json"),
99392
99435
  // Codex
99393
- join50(codexHome, "config.toml"),
99394
- join50(root, ".codex", "config.toml"),
99436
+ join51(codexHome, "config.toml"),
99437
+ join51(root, ".codex", "config.toml"),
99395
99438
  // Gemini CLI
99396
- join50(geminiHome, "settings.json"),
99397
- join50(root, ".gemini", "settings.json"),
99439
+ join51(geminiHome, "settings.json"),
99440
+ join51(root, ".gemini", "settings.json"),
99398
99441
  // Cursor
99399
- join50(home, ".cursor", "mcp.json"),
99400
- join50(root, ".cursor", "mcp.json"),
99442
+ join51(home, ".cursor", "mcp.json"),
99443
+ join51(root, ".cursor", "mcp.json"),
99401
99444
  // VS Code (user profile mcp.json + workspace)
99402
- join50(vscodeUserDir(home, env2), "mcp.json"),
99403
- join50(root, ".vscode", "mcp.json"),
99445
+ join51(vscodeUserDir(home, env2), "mcp.json"),
99446
+ join51(root, ".vscode", "mcp.json"),
99404
99447
  // OpenCode (XDG on every platform; the daemon's installer writes the project one)
99405
- join50(env2["XDG_CONFIG_HOME"] ?? join50(home, ".config"), "opencode", "opencode.json"),
99406
- join50(root, "opencode.json")
99448
+ join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "opencode", "opencode.json"),
99449
+ join51(root, "opencode.json")
99407
99450
  ];
99408
99451
  }
99409
99452
  function vscodeUserDir(home, env2) {
99410
- if (process.platform === "win32") return join50(env2["APPDATA"] ?? join50(home, "AppData", "Roaming"), "Code", "User");
99411
- if (process.platform === "darwin") return join50(home, "Library", "Application Support", "Code", "User");
99412
- return join50(env2["XDG_CONFIG_HOME"] ?? join50(home, ".config"), "Code", "User");
99453
+ if (process.platform === "win32") return join51(env2["APPDATA"] ?? join51(home, "AppData", "Roaming"), "Code", "User");
99454
+ if (process.platform === "darwin") return join51(home, "Library", "Application Support", "Code", "User");
99455
+ return join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "Code", "User");
99413
99456
  }
99414
99457
  function scanHarnessConfigs(paths, read2 = readBounded) {
99415
99458
  const findings = [];
@@ -99424,9 +99467,9 @@ function scanHarnessConfigs(paths, read2 = readBounded) {
99424
99467
  }
99425
99468
  function readBounded(path3) {
99426
99469
  try {
99427
- const stat4 = statSync13(path3);
99470
+ const stat4 = statSync14(path3);
99428
99471
  if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
99429
- return readFileSync42(path3, "utf8");
99472
+ return readFileSync43(path3, "utf8");
99430
99473
  } catch {
99431
99474
  return null;
99432
99475
  }
@@ -99451,14 +99494,14 @@ function credentialHygieneCheck(scan2) {
99451
99494
 
99452
99495
  // src/codex-doctor.ts
99453
99496
  import { spawn as spawn4 } from "node:child_process";
99454
- import { readFileSync as readFileSync44, statSync as statSync14 } from "node:fs";
99455
- import { join as join52 } from "node:path";
99497
+ import { readFileSync as readFileSync45, statSync as statSync15 } from "node:fs";
99498
+ import { join as join53 } from "node:path";
99456
99499
  import { createInterface } from "node:readline";
99457
99500
 
99458
99501
  // src/codex-hooks.ts
99459
- import { existsSync as existsSync36, mkdirSync as mkdirSync10, readFileSync as readFileSync43, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
99502
+ import { existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync44, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
99460
99503
  import { homedir as homedir9 } from "node:os";
99461
- import { join as join51 } from "node:path";
99504
+ import { join as join52 } from "node:path";
99462
99505
 
99463
99506
  // src/hook-commands.ts
99464
99507
  function hookCurlCommand(port, path3 = "/api/hook") {
@@ -99670,34 +99713,34 @@ function buildCodexRelaySource(workspaceRoot) {
99670
99713
  init_checkout_root();
99671
99714
  var CODEX_HOOK_REVIEW_HELP = "Codex desktop: Settings > Hooks, select this project, expand each event and Trust the Errata hook. CLI users can use /hooks.";
99672
99715
  function writeRelay(file2, source) {
99673
- if (existsSync36(file2) && readFileSync43(file2, "utf8") === source) return;
99716
+ if (existsSync37(file2) && readFileSync44(file2, "utf8") === source) return;
99674
99717
  const temp = `${file2}.${process.pid}.tmp`;
99675
99718
  try {
99676
99719
  writeFileSync31(temp, source, { encoding: "utf8", mode: 384 });
99677
99720
  renameSync8(temp, file2);
99678
99721
  } finally {
99679
- if (existsSync36(temp)) unlinkSync5(temp);
99722
+ if (existsSync37(temp)) unlinkSync5(temp);
99680
99723
  }
99681
99724
  }
99682
99725
  function refreshCodexRelay(root) {
99683
- const config2 = join51(root, ".codex", "config.toml");
99684
- if (!existsSync36(config2)) return "absent";
99685
- const existing = readFileSync43(config2, "utf8");
99726
+ const config2 = join52(root, ".codex", "config.toml");
99727
+ if (!existsSync37(config2)) return "absent";
99728
+ const existing = readFileSync44(config2, "utf8");
99686
99729
  if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
99687
99730
  replaceCodexHooks(existing, "");
99688
- const relay = join51(root, ".codex", "hooks", "errata-relay.mjs");
99689
- const prior = existsSync36(relay) ? readFileSync43(relay, "utf8") : "";
99731
+ const relay = join52(root, ".codex", "hooks", "errata-relay.mjs");
99732
+ const prior = existsSync37(relay) ? readFileSync44(relay, "utf8") : "";
99690
99733
  if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
99691
99734
  throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
99692
99735
  }
99693
99736
  const source = buildCodexRelaySource(checkoutRootOf(root));
99694
99737
  if (prior === source) return "current";
99695
- mkdirSync10(join51(root, ".codex", "hooks"), { recursive: true });
99738
+ mkdirSync10(join52(root, ".codex", "hooks"), { recursive: true });
99696
99739
  writeRelay(relay, source);
99697
99740
  return "updated";
99698
99741
  }
99699
- function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join51(homedir9(), ".codex")) {
99700
- return existsSync36(join51(root, ".codex")) || existsSync36(codexHome);
99742
+ function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join52(homedir9(), ".codex")) {
99743
+ return existsSync37(join52(root, ".codex")) || existsSync37(codexHome);
99701
99744
  }
99702
99745
  function replaceCodexHooks(existing, block) {
99703
99746
  const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
@@ -99713,14 +99756,14 @@ function replaceCodexHooks(existing, block) {
99713
99756
  return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
99714
99757
  }
99715
99758
  function writeCodexHooks(root, port, nodePath = process.execPath) {
99716
- const dir = join51(root, ".codex");
99717
- const file2 = join51(dir, "config.toml");
99718
- const relay = join51(dir, "hooks", "errata-relay.mjs");
99759
+ const dir = join52(root, ".codex");
99760
+ const file2 = join52(dir, "config.toml");
99761
+ const relay = join52(dir, "hooks", "errata-relay.mjs");
99719
99762
  const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
99720
- const final = replaceCodexHooks(existsSync36(file2) ? readFileSync43(file2, "utf8") : "", block);
99721
- mkdirSync10(join51(dir, "hooks"), { recursive: true });
99763
+ const final = replaceCodexHooks(existsSync37(file2) ? readFileSync44(file2, "utf8") : "", block);
99764
+ mkdirSync10(join52(dir, "hooks"), { recursive: true });
99722
99765
  writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
99723
- if (!existsSync36(file2) || readFileSync43(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
99766
+ if (!existsSync37(file2) || readFileSync44(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
99724
99767
  return file2;
99725
99768
  }
99726
99769
 
@@ -99729,7 +99772,7 @@ init_checkout_root();
99729
99772
  function inspectCodexRelay(cwd) {
99730
99773
  const root = nearestGitRoot(cwd) ?? cwd;
99731
99774
  try {
99732
- const source = readFileSync44(join52(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
99775
+ const source = readFileSync45(join53(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
99733
99776
  if (source === buildCodexRelaySource(checkoutRootOf(root))) {
99734
99777
  return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
99735
99778
  }
@@ -99740,8 +99783,8 @@ function inspectCodexRelay(cwd) {
99740
99783
  function inspectCodexContext(cwd) {
99741
99784
  const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
99742
99785
  try {
99743
- const file2 = join52(root, ".errata", "context.md");
99744
- if (statSync14(file2).size <= 128 * 1024 && readFileSync44(file2, "utf8").trim()) {
99786
+ const file2 = join53(root, ".errata", "context.md");
99787
+ if (statSync15(file2).size <= 128 * 1024 && readFileSync45(file2, "utf8").trim()) {
99745
99788
  return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
99746
99789
  }
99747
99790
  } catch {
@@ -99751,7 +99794,7 @@ function inspectCodexContext(cwd) {
99751
99794
  var CodexRuntimeUnavailableError = class extends Error {
99752
99795
  };
99753
99796
  function readCodexHookState(cwd, options = {}) {
99754
- return new Promise((resolve10, reject) => {
99797
+ return new Promise((resolve11, reject) => {
99755
99798
  const child = spawn4(options.bin ?? resolveCodexExecutable(), options.args ?? ["app-server", "--stdio"], {
99756
99799
  cwd,
99757
99800
  windowsHide: true,
@@ -99772,7 +99815,7 @@ function readCodexHookState(cwd, options = {}) {
99772
99815
  child.once("close", () => {
99773
99816
  clearTimeout(reap);
99774
99817
  if (error48) reject(error48);
99775
- else resolve10({ ...hooks, features });
99818
+ else resolve11({ ...hooks, features });
99776
99819
  });
99777
99820
  child.kill();
99778
99821
  };
@@ -99919,9 +99962,9 @@ function consolidationGapMs(lastPassMs, policy) {
99919
99962
 
99920
99963
  // src/codex-context-plugin.ts
99921
99964
  import { createHash as createHash21 } from "node:crypto";
99922
- import { cpSync as cpSync2, existsSync as existsSync37, mkdirSync as mkdirSync11, readFileSync as readFileSync45, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
99965
+ import { cpSync as cpSync2, existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync46, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
99923
99966
  import { homedir as homedir10 } from "node:os";
99924
- import { join as join53 } from "node:path";
99967
+ import { join as join54 } from "node:path";
99925
99968
  import { fileURLToPath as fileURLToPath3 } from "node:url";
99926
99969
 
99927
99970
  // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
@@ -100619,7 +100662,7 @@ var NAME = "errata-context";
100619
100662
  var PREFIX2 = `./.errata/plugins/${NAME}/`;
100620
100663
  var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
100621
100664
  function readText(file2) {
100622
- return existsSync37(file2) ? readFileSync45(file2, "utf8") : "";
100665
+ return existsSync38(file2) ? readFileSync46(file2, "utf8") : "";
100623
100666
  }
100624
100667
  function writeChanged(file2, content) {
100625
100668
  if (readText(file2) === content) return;
@@ -100629,13 +100672,13 @@ function writeChanged(file2, content) {
100629
100672
  }
100630
100673
  function bundledContextPlugin() {
100631
100674
  const packaged = fileURLToPath3(new URL("./resources/context-plugin/", import.meta.url));
100632
- if (existsSync37(join53(packaged, ".codex-plugin/plugin.json"))) return packaged;
100675
+ if (existsSync38(join54(packaged, ".codex-plugin/plugin.json"))) return packaged;
100633
100676
  return fileURLToPath3(new URL("../dist/resources/context-plugin/", import.meta.url));
100634
100677
  }
100635
100678
  function refreshCodexContextPlugin(root) {
100636
- const file2 = join53(root, ".agents", "plugins", "marketplace.json");
100637
- if (!existsSync37(file2)) return false;
100638
- const marketplace = JSON.parse(readFileSync45(file2, "utf8"));
100679
+ const file2 = join54(root, ".agents", "plugins", "marketplace.json");
100680
+ if (!existsSync38(file2)) return false;
100681
+ const marketplace = JSON.parse(readFileSync46(file2, "utf8"));
100639
100682
  const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
100640
100683
  const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
100641
100684
  if (!entry) return false;
@@ -100646,24 +100689,24 @@ function refreshCodexContextPlugin(root) {
100646
100689
  function installCodexContextPlugin(root, options = {}) {
100647
100690
  const bundle = options.bundle ?? bundledContextPlugin();
100648
100691
  const manifest = JSON.parse(
100649
- readFileSync45(join53(bundle, ".codex-plugin/plugin.json"), "utf8")
100692
+ readFileSync46(join54(bundle, ".codex-plugin/plugin.json"), "utf8")
100650
100693
  );
100651
100694
  if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
100652
100695
  throw new Error("Invalid bundled Errata Context manifest.");
100653
100696
  }
100654
- const checksums = readFileSync45(join53(bundle, "SHA256SUMS"), "utf8");
100697
+ const checksums = readFileSync46(join54(bundle, "SHA256SUMS"), "utf8");
100655
100698
  for (const line of checksums.trim().split("\n")) {
100656
100699
  const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
100657
100700
  if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
100658
100701
  throw new Error("Invalid bundled Errata Context checksum manifest.");
100659
100702
  }
100660
- const actual = createHash21("sha256").update(readFileSync45(join53(bundle, match2[2]))).digest("hex");
100703
+ const actual = createHash21("sha256").update(readFileSync46(join54(bundle, match2[2]))).digest("hex");
100661
100704
  if (actual !== match2[1])
100662
100705
  throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
100663
100706
  }
100664
100707
  const release = `${manifest.version}-${createHash21("sha256").update(checksums).digest("hex").slice(0, 12)}`;
100665
- const plugin = join53(root, ".errata", "plugins", NAME, release);
100666
- const marketplaceFile = join53(root, ".agents", "plugins", "marketplace.json");
100708
+ const plugin = join54(root, ".errata", "plugins", NAME, release);
100709
+ const marketplaceFile = join54(root, ".agents", "plugins", "marketplace.json");
100667
100710
  const priorMarketplace = readText(marketplaceFile);
100668
100711
  const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
100669
100712
  name: "errata-local",
@@ -100684,12 +100727,12 @@ function installCodexContextPlugin(root, options = {}) {
100684
100727
  );
100685
100728
  }
100686
100729
  const key = `${NAME}@${marketplace.name}`;
100687
- const configFile = join53(root, ".codex", "config.toml");
100730
+ const configFile = join54(root, ".codex", "config.toml");
100688
100731
  const config2 = readText(configFile);
100689
100732
  const parsed = parse4(config2);
100690
100733
  const plugins = object2(parsed.plugins);
100691
- const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join53(homedir10(), ".codex");
100692
- const globalPlugins = object2(parse4(readText(join53(codexHome, "config.toml"))).plugins);
100734
+ const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join54(homedir10(), ".codex");
100735
+ const globalPlugins = object2(parse4(readText(join54(codexHome, "config.toml"))).plugins);
100693
100736
  const disabledGlobally = Object.entries(globalPlugins).some(
100694
100737
  ([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
100695
100738
  );
@@ -100713,13 +100756,13 @@ enabled = ${enabled}
100713
100756
  mkdirSync11(plugin, { recursive: true });
100714
100757
  cpSync2(bundle, plugin, { recursive: true });
100715
100758
  writeChanged(
100716
- join53(plugin, ".mcp.json"),
100759
+ join54(plugin, ".mcp.json"),
100717
100760
  JSON.stringify(
100718
100761
  {
100719
100762
  mcpServers: {
100720
100763
  errata_context: {
100721
100764
  command: options.nodePath ?? process.execPath,
100722
- args: [join53(plugin, "dist", "mcp-server.mjs")],
100765
+ args: [join54(plugin, "dist", "mcp-server.mjs")],
100723
100766
  env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
100724
100767
  }
100725
100768
  }
@@ -100728,8 +100771,8 @@ enabled = ${enabled}
100728
100771
  2
100729
100772
  ) + "\n"
100730
100773
  );
100731
- mkdirSync11(join53(root, ".agents", "plugins"), { recursive: true });
100732
- mkdirSync11(join53(root, ".codex"), { recursive: true });
100774
+ mkdirSync11(join54(root, ".agents", "plugins"), { recursive: true });
100775
+ mkdirSync11(join54(root, ".codex"), { recursive: true });
100733
100776
  writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
100734
100777
  writeChanged(configFile, nextConfig);
100735
100778
  return { plugin, enabled, marketplace: marketplaceFile };
@@ -100737,16 +100780,16 @@ enabled = ${enabled}
100737
100780
 
100738
100781
  // src/codex-hook-refresh.ts
100739
100782
  init_checkout_root();
100740
- import { existsSync as existsSync38, readdirSync as readdirSync14, readFileSync as readFileSync46 } from "node:fs";
100741
- import { dirname as dirname19, join as join54, resolve as resolve8 } from "node:path";
100783
+ import { existsSync as existsSync39, readdirSync as readdirSync14, readFileSync as readFileSync47 } from "node:fs";
100784
+ import { dirname as dirname20, join as join55, resolve as resolve9 } from "node:path";
100742
100785
  init_registry();
100743
100786
  function codexHookRoots(roots) {
100744
- const found = new Set(roots.map((root) => resolve8(root)));
100787
+ const found = new Set(roots.map((root) => resolve9(root)));
100745
100788
  for (const root of [...found]) {
100746
100789
  const main2 = mainCheckoutOfWorktree(root) ?? root;
100747
100790
  found.add(main2);
100748
- const dir = join54(main2, ".git", "worktrees");
100749
- if (!existsSync38(dir)) continue;
100791
+ const dir = join55(main2, ".git", "worktrees");
100792
+ if (!existsSync39(dir)) continue;
100750
100793
  let names;
100751
100794
  try {
100752
100795
  names = readdirSync14(dir);
@@ -100755,7 +100798,7 @@ function codexHookRoots(roots) {
100755
100798
  }
100756
100799
  for (const name2 of names) {
100757
100800
  try {
100758
- const checkout = dirname19(readFileSync46(join54(dir, name2, "gitdir"), "utf8").trim());
100801
+ const checkout = dirname20(readFileSync47(join55(dir, name2, "gitdir"), "utf8").trim());
100759
100802
  if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
100760
100803
  } catch {
100761
100804
  }
@@ -100778,8 +100821,8 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
100778
100821
 
100779
100822
  // src/claude-mods.ts
100780
100823
  import { createHash as createHash22 } from "node:crypto";
100781
- import { cpSync as cpSync3, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync47, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync15, writeFileSync as writeFileSync33 } from "node:fs";
100782
- import { delimiter as delimiter2, dirname as dirname20, join as join55, relative as relative7, resolve as resolve9, sep as sep6 } from "node:path";
100824
+ import { cpSync as cpSync3, existsSync as existsSync40, mkdirSync as mkdirSync12, readFileSync as readFileSync48, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync16, writeFileSync as writeFileSync33 } from "node:fs";
100825
+ import { delimiter as delimiter2, dirname as dirname21, join as join56, relative as relative7, resolve as resolve10, sep as sep6 } from "node:path";
100783
100826
  import { fileURLToPath as fileURLToPath4 } from "node:url";
100784
100827
  var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
100785
100828
  var HASH_FILE = ".errata-mod-hash";
@@ -100794,9 +100837,9 @@ function isEngineOwned(relPath) {
100794
100837
  function listFiles(root, dir = root) {
100795
100838
  const out2 = [];
100796
100839
  for (const name2 of readdirSync15(dir)) {
100797
- const abs = join55(dir, name2);
100840
+ const abs = join56(dir, name2);
100798
100841
  if (isEngineOwned(relative7(root, abs))) continue;
100799
- if (statSync15(abs).isDirectory()) out2.push(...listFiles(root, abs));
100842
+ if (statSync16(abs).isDirectory()) out2.push(...listFiles(root, abs));
100800
100843
  else out2.push(abs);
100801
100844
  }
100802
100845
  return out2;
@@ -100806,21 +100849,21 @@ function modHash(dir) {
100806
100849
  for (const abs of listFiles(dir).sort()) {
100807
100850
  h.update(relative7(dir, abs).split(sep6).join("/"));
100808
100851
  h.update("\0");
100809
- h.update(readFileSync47(abs));
100852
+ h.update(readFileSync48(abs));
100810
100853
  h.update("\0");
100811
100854
  }
100812
100855
  return h.digest("hex");
100813
100856
  }
100814
100857
  function bundledMods(bundleDir) {
100815
- if (!existsSync39(bundleDir)) return [];
100816
- return readdirSync15(bundleDir).filter((name2) => existsSync39(join55(bundleDir, name2, ".claude-plugin", "plugin.json")));
100858
+ if (!existsSync40(bundleDir)) return [];
100859
+ return readdirSync15(bundleDir).filter((name2) => existsSync40(join56(bundleDir, name2, ".claude-plugin", "plugin.json")));
100817
100860
  }
100818
100861
  function sameDir(a, b) {
100819
- const norm = (p) => resolve9(p).replace(/[\\/]+$/, "").toLowerCase();
100862
+ const norm = (p) => resolve10(p).replace(/[\\/]+$/, "").toLowerCase();
100820
100863
  return norm(a) === norm(b);
100821
100864
  }
100822
100865
  function isUnder(path3, root) {
100823
- const rel = relative7(resolve9(root), resolve9(path3));
100866
+ const rel = relative7(resolve10(root), resolve10(path3));
100824
100867
  return rel !== "" && !rel.startsWith("..") && !rel.includes(":");
100825
100868
  }
100826
100869
  function off(env2) {
@@ -100828,9 +100871,9 @@ function off(env2) {
100828
100871
  return v === "0" || v === "off" || v === "false" || v === "no";
100829
100872
  }
100830
100873
  function readSettings(path3) {
100831
- if (!existsSync39(path3)) return {};
100874
+ if (!existsSync40(path3)) return {};
100832
100875
  try {
100833
- const parsed = JSON.parse(readFileSync47(path3, "utf8"));
100876
+ const parsed = JSON.parse(readFileSync48(path3, "utf8"));
100834
100877
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
100835
100878
  return parsed;
100836
100879
  } catch {
@@ -100854,13 +100897,13 @@ function currentDirs(settings) {
100854
100897
  return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
100855
100898
  }
100856
100899
  function writeSettings(path3, settings) {
100857
- mkdirSync12(dirname20(path3), { recursive: true });
100900
+ mkdirSync12(dirname21(path3), { recursive: true });
100858
100901
  writeFileSync33(path3, JSON.stringify(settings, null, 2) + "\n", "utf8");
100859
100902
  }
100860
100903
  function ensureClaudeMods(opts) {
100861
100904
  const env2 = opts.env ?? process.env;
100862
100905
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
100863
- const modsRoot = join55(opts.installRoot, "claude-mods");
100906
+ const modsRoot = join56(opts.installRoot, "claude-mods");
100864
100907
  if (off(env2)) {
100865
100908
  const settings2 = readSettings(settingsPath);
100866
100909
  if (!settings2) return { kind: "unreadable" };
@@ -100877,11 +100920,11 @@ function ensureClaudeMods(opts) {
100877
100920
  let changed = false;
100878
100921
  const installed = [];
100879
100922
  for (const name2 of names) {
100880
- const src = join55(bundleDir, name2);
100881
- const dest = join55(modsRoot, name2);
100923
+ const src = join56(bundleDir, name2);
100924
+ const dest = join56(modsRoot, name2);
100882
100925
  const hash2 = modHash(src);
100883
- const hashFile = join55(dest, HASH_FILE);
100884
- if (!existsSync39(hashFile) || readFileSync47(hashFile, "utf8") !== hash2) {
100926
+ const hashFile = join56(dest, HASH_FILE);
100927
+ if (!existsSync40(hashFile) || readFileSync48(hashFile, "utf8") !== hash2) {
100885
100928
  rmSync4(dest, { recursive: true, force: true });
100886
100929
  cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
100887
100930
  writeFileSync33(hashFile, hash2, "utf8");
@@ -101315,9 +101358,9 @@ function resolveHookPort(explicit) {
101315
101358
  }
101316
101359
  }
101317
101360
  }
101318
- const settingsPath = join56(ROOT, ".claude", "settings.json");
101361
+ const settingsPath = join57(ROOT, ".claude", "settings.json");
101319
101362
  try {
101320
- if (existsSync40(settingsPath)) return installedHookPort(readFileSync48(settingsPath, "utf8")) ?? 7891;
101363
+ if (existsSync41(settingsPath)) return installedHookPort(readFileSync49(settingsPath, "utf8")) ?? 7891;
101321
101364
  } catch {
101322
101365
  }
101323
101366
  return 7891;
@@ -101342,14 +101385,14 @@ async function cmdInit() {
101342
101385
  if (!skipHooks) {
101343
101386
  console.log("");
101344
101387
  console.log("installing harness hooks...");
101345
- const { existsSync: existsSync41 } = await import("node:fs");
101346
- const { join: join57 } = await import("node:path");
101388
+ const { existsSync: existsSync42 } = await import("node:fs");
101389
+ const { join: join58 } = await import("node:path");
101347
101390
  try {
101348
101391
  await installClaudeHooks(port);
101349
101392
  } catch (err2) {
101350
101393
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
101351
101394
  }
101352
- if (existsSync41(join57(ROOT, ".cursor"))) {
101395
+ if (existsSync42(join58(ROOT, ".cursor"))) {
101353
101396
  try {
101354
101397
  await installCursorMcpConfig();
101355
101398
  } catch (err2) {
@@ -101564,12 +101607,12 @@ async function cmdStatus() {
101564
101607
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
101565
101608
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
101566
101609
  }
101567
- console.log(` graph db: ${existsSync40(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
101568
- console.log(` event log: ${existsSync40(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
101610
+ console.log(` graph db: ${existsSync41(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
101611
+ console.log(` event log: ${existsSync41(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
101569
101612
  for (const line of captureStatusLines(summarizePassLedger(paths.configDir).get("capture"))) {
101570
101613
  console.log(` capture: ${line}`);
101571
101614
  }
101572
- if (existsSync40(paths.castalia)) {
101615
+ if (existsSync41(paths.castalia)) {
101573
101616
  try {
101574
101617
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
101575
101618
  const store = openGraphStore2({ path: paths.castalia });
@@ -102570,11 +102613,11 @@ async function cmdInstallationProfile(args2) {
102570
102613
  }
102571
102614
  async function cmdReview() {
102572
102615
  const paths = workspacePaths(ROOT);
102573
- if (!existsSync40(paths.reviewQueue)) {
102616
+ if (!existsSync41(paths.reviewQueue)) {
102574
102617
  console.log("(review queue empty)");
102575
102618
  return;
102576
102619
  }
102577
- const queue = JSON.parse(readFileSync48(paths.reviewQueue, "utf8"));
102620
+ const queue = JSON.parse(readFileSync49(paths.reviewQueue, "utf8"));
102578
102621
  if (queue.length === 0) {
102579
102622
  console.log("(review queue empty)");
102580
102623
  return;
@@ -103274,7 +103317,7 @@ async function gatherRepo(store, ws) {
103274
103317
  };
103275
103318
  }
103276
103319
  async function gatherReportData(generatedAt) {
103277
- const { existsSync: existsSync41 } = await import("node:fs");
103320
+ const { existsSync: existsSync42 } = await import("node:fs");
103278
103321
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
103279
103322
  const cfg = loadConfig();
103280
103323
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -103282,7 +103325,7 @@ async function gatherReportData(generatedAt) {
103282
103325
  for (const ws of listWorkspaces()) {
103283
103326
  if (ws.missing) continue;
103284
103327
  const dbPath = workspacePaths(ws.path).castalia;
103285
- if (!existsSync41(dbPath)) continue;
103328
+ if (!existsSync42(dbPath)) continue;
103286
103329
  let store = null;
103287
103330
  try {
103288
103331
  store = openGraphStore2({ path: dbPath });
@@ -103326,8 +103369,8 @@ async function cmdReport(args2) {
103326
103369
  const outDir = workspacePaths(ROOT).configDir;
103327
103370
  mkdirSync13(outDir, { recursive: true });
103328
103371
  const files = renderReport2(data, { includeFutureVerbs });
103329
- for (const f of files) writeFileSync34(join56(outDir, f.name), f.html, "utf8");
103330
- const indexPath = join56(outDir, "report.html");
103372
+ for (const f of files) writeFileSync34(join57(outDir, f.name), f.html, "utf8");
103373
+ const indexPath = join57(outDir, "report.html");
103331
103374
  console.log(`report \u2192 ${indexPath}`);
103332
103375
  console.log(
103333
103376
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -103383,7 +103426,7 @@ function spawnDaemonDetached(options = {}) {
103383
103426
  try {
103384
103427
  const logPath = daemonLogPath();
103385
103428
  try {
103386
- if (statSync16(logPath).size > 5 * 1024 * 1024) renameSync10(logPath, `${logPath}.1`);
103429
+ if (statSync17(logPath).size > 5 * 1024 * 1024) renameSync10(logPath, `${logPath}.1`);
103387
103430
  } catch {
103388
103431
  }
103389
103432
  out2 = openSync3(logPath, "a");
@@ -103452,24 +103495,24 @@ async function cmdInstallHooks(args2) {
103452
103495
  }
103453
103496
  }
103454
103497
  async function installOpencodePlugin(port) {
103455
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103456
- const { join: join57 } = await import("node:path");
103457
- const dir = join57(ROOT, ".opencode", "plugin");
103458
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103459
- const file2 = join57(dir, "inerrata.js");
103460
- if (existsSync41(file2)) {
103461
- const head2 = readFileSync49(file2, "utf8").split("\n")[0] ?? "";
103498
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103499
+ const { join: join58 } = await import("node:path");
103500
+ const dir = join58(ROOT, ".opencode", "plugin");
103501
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103502
+ const file2 = join58(dir, "inerrata.js");
103503
+ if (existsSync42(file2)) {
103504
+ const head2 = readFileSync50(file2, "utf8").split("\n")[0] ?? "";
103462
103505
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
103463
103506
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
103464
103507
  process.exit(2);
103465
103508
  }
103466
103509
  }
103467
103510
  writeFileSync34(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
103468
- const cfgFile = join57(ROOT, "opencode.json");
103511
+ const cfgFile = join58(ROOT, "opencode.json");
103469
103512
  let cfg = { $schema: "https://opencode.ai/config.json" };
103470
- if (existsSync41(cfgFile)) {
103513
+ if (existsSync42(cfgFile)) {
103471
103514
  try {
103472
- cfg = JSON.parse(readFileSync49(cfgFile, "utf8"));
103515
+ cfg = JSON.parse(readFileSync50(cfgFile, "utf8"));
103473
103516
  } catch {
103474
103517
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
103475
103518
  process.exit(2);
@@ -103515,15 +103558,15 @@ function installClaudeMods() {
103515
103558
  }
103516
103559
  }
103517
103560
  async function installClaudeHooks(port) {
103518
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103519
- const { join: join57 } = await import("node:path");
103520
- const dir = join57(ROOT, ".claude");
103521
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103522
- const file2 = join57(dir, "settings.json");
103561
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103562
+ const { join: join58 } = await import("node:path");
103563
+ const dir = join58(ROOT, ".claude");
103564
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103565
+ const file2 = join58(dir, "settings.json");
103523
103566
  let settings = {};
103524
- if (existsSync41(file2)) {
103567
+ if (existsSync42(file2)) {
103525
103568
  try {
103526
- settings = JSON.parse(readFileSync49(file2, "utf8"));
103569
+ settings = JSON.parse(readFileSync50(file2, "utf8"));
103527
103570
  } catch {
103528
103571
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103529
103572
  process.exit(2);
@@ -103577,7 +103620,7 @@ async function installClaudeHooks(port) {
103577
103620
  console.log(` ${ensureStatusLine(port)}`);
103578
103621
  console.log(` ${installClaudeMods().line}`);
103579
103622
  await installClaudeMcpConfig();
103580
- const claudeMd = join57(ROOT, "CLAUDE.md");
103623
+ const claudeMd = join58(ROOT, "CLAUDE.md");
103581
103624
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
103582
103625
  if (recall.kind === "collision") {
103583
103626
  console.warn(
@@ -103589,15 +103632,15 @@ async function installClaudeHooks(port) {
103589
103632
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
103590
103633
  }
103591
103634
  async function installClaudeMcpConfig() {
103592
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103593
- const { join: join57, dirname: dirname21 } = await import("node:path");
103594
- const file2 = join57(ROOT, ".mcp.json");
103595
- const dir = dirname21(file2);
103596
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103635
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103636
+ const { join: join58, dirname: dirname22 } = await import("node:path");
103637
+ const file2 = join58(ROOT, ".mcp.json");
103638
+ const dir = dirname22(file2);
103639
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103597
103640
  let cfg = {};
103598
- if (existsSync41(file2)) {
103641
+ if (existsSync42(file2)) {
103599
103642
  try {
103600
- cfg = JSON.parse(readFileSync49(file2, "utf8"));
103643
+ cfg = JSON.parse(readFileSync50(file2, "utf8"));
103601
103644
  } catch {
103602
103645
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103603
103646
  process.exit(2);
@@ -103611,15 +103654,15 @@ async function installClaudeMcpConfig() {
103611
103654
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
103612
103655
  }
103613
103656
  async function installCursorMcpConfig() {
103614
- const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync49, writeFileSync: writeFileSync34 } = await import("node:fs");
103615
- const { join: join57 } = await import("node:path");
103616
- const dir = join57(ROOT, ".cursor");
103617
- if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
103618
- const file2 = join57(dir, "mcp.json");
103657
+ const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
103658
+ const { join: join58 } = await import("node:path");
103659
+ const dir = join58(ROOT, ".cursor");
103660
+ if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
103661
+ const file2 = join58(dir, "mcp.json");
103619
103662
  let cfg = {};
103620
- if (existsSync41(file2)) {
103663
+ if (existsSync42(file2)) {
103621
103664
  try {
103622
- cfg = JSON.parse(readFileSync49(file2, "utf8"));
103665
+ cfg = JSON.parse(readFileSync50(file2, "utf8"));
103623
103666
  } catch {
103624
103667
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
103625
103668
  process.exit(2);
@@ -103638,7 +103681,7 @@ async function installCodexHooks(port) {
103638
103681
  const gitRoot = nearestGitRoot(process.cwd());
103639
103682
  const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
103640
103683
  const file2 = writeCodexHooks(hookRoot, port);
103641
- const instructions = writeManagedBlock(join56(hookRoot, "AGENTS.md"), {
103684
+ const instructions = writeManagedBlock(join57(hookRoot, "AGENTS.md"), {
103642
103685
  body: AGENTS_POINTER_BODY,
103643
103686
  stable: true
103644
103687
  });
@@ -104006,7 +104049,7 @@ async function cmdDash(args2) {
104006
104049
  const hotspotScanMark = /* @__PURE__ */ new Map();
104007
104050
  const HOTSPOT_FANIN = 20;
104008
104051
  const runNightlyPass = async (dueIds) => {
104009
- const yieldToLoop2 = () => new Promise((resolve10) => setImmediate(resolve10));
104052
+ const yieldToLoop2 = () => new Promise((resolve11) => setImmediate(resolve11));
104010
104053
  const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
104011
104054
  const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
104012
104055
  let skillsLearned = 0;
@@ -104084,9 +104127,9 @@ async function cmdDash(args2) {
104084
104127
  await yieldToLoop2();
104085
104128
  try {
104086
104129
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
104087
- atCommit: readGitRefState(join56(r.root, ".git")).sha ?? void 0
104130
+ atCommit: readGitRefState(join57(r.root, ".git")).sha ?? void 0
104088
104131
  });
104089
- const res = bleedRules(join56(r.root, ".claude", "rules"), items);
104132
+ const res = bleedRules(join57(r.root, ".claude", "rules"), items);
104090
104133
  if (res.written || res.pruned) {
104091
104134
  console.log(
104092
104135
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")