@inerrata-corporation/errata 2.0.19 → 2.0.20-dev.3679

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
@@ -137,6 +137,9 @@ var init_castalia = __esm({
137
137
  "probe-failed"
138
138
  ];
139
139
  ROUTING_REASONS = [
140
+ "trusted-system-public",
141
+ "public-target-staged",
142
+ "source-membrane",
140
143
  /** Harness org (CTF lane, e2e battery, canary) — forced org-private. */
141
144
  "harness-clamp",
142
145
  "witnessed-vulnerability-private",
@@ -1388,9 +1391,9 @@ function floatSafeRemainder(val, step) {
1388
1391
  const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1389
1392
  return valInt % stepInt / 10 ** decCount;
1390
1393
  }
1391
- function defineLazy(object2, key, getter) {
1394
+ function defineLazy(object3, key, getter) {
1392
1395
  let value = void 0;
1393
- Object.defineProperty(object2, key, {
1396
+ Object.defineProperty(object3, key, {
1394
1397
  get() {
1395
1398
  if (value === EVALUATING) {
1396
1399
  return void 0;
@@ -1402,7 +1405,7 @@ function defineLazy(object2, key, getter) {
1402
1405
  return value;
1403
1406
  },
1404
1407
  set(v) {
1405
- Object.defineProperty(object2, key, {
1408
+ Object.defineProperty(object3, key, {
1406
1409
  value: v
1407
1410
  // configurable: true,
1408
1411
  });
@@ -17175,10 +17178,10 @@ function parseManifest(path2, text) {
17175
17178
  if (name2.endsWith(".gemspec")) return parseGemspec(path2, text);
17176
17179
  return [];
17177
17180
  }
17178
- function buildSpine(sha2, manifestPaths2, readText) {
17181
+ function buildSpine(sha2, manifestPaths2, readText2) {
17179
17182
  const manifests = {};
17180
17183
  for (const p of manifestPaths2) {
17181
- const deps = parseManifest(p, readText(p));
17184
+ const deps = parseManifest(p, readText2(p));
17182
17185
  if (deps.length > 0) manifests[p] = deps;
17183
17186
  }
17184
17187
  return { sha: sha2, manifests };
@@ -21681,7 +21684,11 @@ function priorsForFile(store, relPath) {
21681
21684
  const resolvedProblems = [];
21682
21685
  const seenProblem = /* @__PURE__ */ new Set();
21683
21686
  const related = /* @__PURE__ */ new Map();
21684
- for (const e of store.inEdges(file2.id, ["ANCHORED_AT"])) {
21687
+ const anchorEdges = [
21688
+ ...store.inEdges(file2.id, ["ANCHORED_AT"]),
21689
+ ...store.outEdges(file2.id, ["DEFINES"]).flatMap((d) => store.inEdges(d.to, ["ANCHORED_AT"]))
21690
+ ];
21691
+ for (const e of anchorEdges) {
21685
21692
  const n = store.getNode(e.from);
21686
21693
  if (!n) continue;
21687
21694
  if (n.label === "Problem" || n.label === "Vulnerability") {
@@ -21929,12 +21936,21 @@ function resolveDesignProblemByStatement(store, statement, fixNote, t) {
21929
21936
  const problemId = identityId({ kind: "DesignProblem", statement });
21930
21937
  return closeDesignProblem(store, problemId, fixNote, t);
21931
21938
  }
21939
+ function closableByCaller(node2) {
21940
+ if (node2.attrs["source"] !== "cloud") return true;
21941
+ const visibility = node2.attrs["visibility"];
21942
+ return typeof visibility === "string" && MEMBER_VISIBILITIES.has(visibility);
21943
+ }
21944
+ function isVerdictable(node2) {
21945
+ return node2.label === "Problem" && node2.attrs["resolvedAt"] == null && (node2.validTo ?? null) === null && !isConstraintProblem(node2) && node2.attrs["kind"] !== "todo";
21946
+ }
21932
21947
  function resolveDesignProblemById(store, id, fixNote, t) {
21933
21948
  return closeDesignProblem(store, id.trim(), fixNote, t);
21934
21949
  }
21935
21950
  function closeDesignProblem(store, problemId, fixNote, t) {
21936
21951
  const p = store.getNode(problemId);
21937
21952
  if (!p || p.label !== "Problem" && p.label !== "Vulnerability") return false;
21953
+ if (!closableByCaller(p)) return false;
21938
21954
  if (p.attrs["resolvedAs"]) return false;
21939
21955
  if (fixNote?.trim() && !isFragmentFixNote(fixNote)) {
21940
21956
  const sols = store.outEdges(problemId, ["SOLVED_BY"]).map((e) => store.getNode(e.to)).filter((n) => n !== null);
@@ -22007,6 +22023,7 @@ function retractDesignProblemByStatement(store, statement, resolvedAs, reason, t
22007
22023
  function retractDesignProblem(store, problemId, resolvedAs, reason, t) {
22008
22024
  const p = store.getNode(problemId);
22009
22025
  if (!p || p.label !== "Problem" || p.attrs["resolvedAt"]) return false;
22026
+ if (!closableByCaller(p)) return false;
22010
22027
  store.updateNode(problemId, {
22011
22028
  attrs: {
22012
22029
  ...p.attrs,
@@ -22142,7 +22159,7 @@ function priorExposure(store, nodeId, atSeq) {
22142
22159
  if ((n.attrs["evictedCount"] ?? 0) > 0) return "evicted";
22143
22160
  return "unshown";
22144
22161
  }
22145
- var DESIGN_PROMOTE_AT, STATEMENT_ALIAS_CAP, RECURRENCE_DEBOUNCE_MS, PATTERN_DEDUP_COSINE, PATTERN_ALIAS_CAP, DEDUP_STOPWORDS, SAME_ANCHOR_DEDUP_JACCARD, EMPTY_FOLD_REPORT, SAME_ANCHOR_SCOUT_AUTO_COSINE, SAME_ANCHOR_SCOUT_MIN_COSINE, SAME_ANCHOR_NOMINATE_JACCARD, REOPEN_MIN_SOURCES, RECURRENCE_SOURCES_CAP, CITABLE_PRIOR_LABELS, MAX_ANCHOR_FILES, ENCLOSING_SYMBOL_KINDS, ENCLOSING_WALK_DEPTH, FIX_CANDIDATE_ASK_LIMIT;
22162
+ var DESIGN_PROMOTE_AT, STATEMENT_ALIAS_CAP, RECURRENCE_DEBOUNCE_MS, PATTERN_DEDUP_COSINE, PATTERN_ALIAS_CAP, DEDUP_STOPWORDS, SAME_ANCHOR_DEDUP_JACCARD, EMPTY_FOLD_REPORT, SAME_ANCHOR_SCOUT_AUTO_COSINE, SAME_ANCHOR_SCOUT_MIN_COSINE, SAME_ANCHOR_NOMINATE_JACCARD, REOPEN_MIN_SOURCES, RECURRENCE_SOURCES_CAP, CITABLE_PRIOR_LABELS, MAX_ANCHOR_FILES, ENCLOSING_SYMBOL_KINDS, ENCLOSING_WALK_DEPTH, MEMBER_VISIBILITIES, FIX_CANDIDATE_ASK_LIMIT;
22146
22163
  var init_design_problem = __esm({
22147
22164
  "../../packages/local-graph/src/design-problem.ts"() {
22148
22165
  "use strict";
@@ -22219,6 +22236,7 @@ var init_design_problem = __esm({
22219
22236
  "Property"
22220
22237
  ]);
22221
22238
  ENCLOSING_WALK_DEPTH = 8;
22239
+ MEMBER_VISIBILITIES = /* @__PURE__ */ new Set(["project", "team", "org"]);
22222
22240
  FIX_CANDIDATE_ASK_LIMIT = 5;
22223
22241
  }
22224
22242
  });
@@ -25358,6 +25376,7 @@ __export(src_exports2, {
25358
25376
  clearAnsweredRevisits: () => clearAnsweredRevisits,
25359
25377
  clearRevisit: () => clearRevisit,
25360
25378
  clearSettledFixCandidates: () => clearSettledFixCandidates,
25379
+ closableByCaller: () => closableByCaller,
25361
25380
  communityInductionRequests: () => communityInductionRequests,
25362
25381
  communitySeeds: () => communitySeeds,
25363
25382
  compareSemver: () => compareSemver,
@@ -25396,6 +25415,7 @@ __export(src_exports2, {
25396
25415
  isFragmentFixNote: () => isFragmentFixNote,
25397
25416
  isPlaceholderStatement: () => isPlaceholderStatement,
25398
25417
  isUnfilledPlaceholder: () => isUnfilledPlaceholder,
25418
+ isVerdictable: () => isVerdictable,
25399
25419
  learnedConductance: () => learnedConductance,
25400
25420
  linkProblemToLanguages: () => linkProblemToLanguages,
25401
25421
  linkProblemToPackages: () => linkProblemToPackages,
@@ -25923,6 +25943,13 @@ function renderSnapshot(s) {
25923
25943
  lines.push("_Priors that speak to it \u2014 cite one with its `[handle]` if you lean on it:_");
25924
25944
  for (const h of si.hits) {
25925
25945
  lines.push(`- **${h.description}** \u2014 \`${h.id}\``);
25946
+ if (h.verdict === "own") {
25947
+ lines.push(
25948
+ ` - still open \u2014 did this work settle it? fixed \u2192 (fix:[${h.id}]) \xB7 not a real problem \u2192 an \`errata-resolved\` block with \`id: ` + h.id + "`, `disposition: false_positive`, `reason: \u2026` \xB7 still open \u2192 say nothing"
25949
+ );
25950
+ } else if (h.verdict === "foreign") {
25951
+ lines.push(` - open in another membrane \u2014 not yours to close: (confirm:[${h.id}]) it held \xB7 (refute:[${h.id}] one line why)`);
25952
+ }
25926
25953
  }
25927
25954
  }
25928
25955
  if (si.remoteHits?.length) {
@@ -27795,8 +27822,8 @@ var init_config = __esm({
27795
27822
  "use strict";
27796
27823
  init_paths();
27797
27824
  LEGACY_CLOUD_URL = "https://inerrata-gateway.onrender.com";
27798
- DEFAULT_CLOUD_URL = true ? "https://inerrata.dev" : DEV_CLOUD_URL;
27799
- DEFAULT_UPDATE_CHANNEL = true ? "latest" : "dev";
27825
+ DEFAULT_CLOUD_URL = true ? "https://dev.inerrata.dev" : DEV_CLOUD_URL;
27826
+ DEFAULT_UPDATE_CHANNEL = false ? "latest" : "dev";
27800
27827
  }
27801
27828
  });
27802
27829
 
@@ -29219,9 +29246,9 @@ var init_context = __esm({
29219
29246
  * })
29220
29247
  * ```
29221
29248
  */
29222
- json = (object2, arg, headers) => {
29249
+ json = (object3, arg, headers) => {
29223
29250
  return this.#newResponse(
29224
- JSON.stringify(object2),
29251
+ JSON.stringify(object3),
29225
29252
  arg,
29226
29253
  setDefaultContentType("application/json", headers)
29227
29254
  );
@@ -32524,7 +32551,10 @@ var init_agent_signals = __esm({
32524
32551
  // lean-on corroboration lived, because only corroboration had an inline path. Grammar
32525
32552
  // single-sourced with parseInlineTags' CONFIRM_PREFIX/REFUTE_PREFIX.
32526
32553
  confirm: (ref) => `(confirm:[${ref}])`,
32527
- refute: (ref) => `(refute:[${ref}] one line why)`
32554
+ refute: (ref) => `(refute:[${ref}] one line why)`,
32555
+ // RETRACT — "not a real problem": the errata-resolved block with a disposition
32556
+ // (parseDesignResolutions, turn.ts). No inline form exists; the block is the grammar.
32557
+ retract: (id) => ["```errata-resolved", `id: ${id}`, "disposition: false_positive", "reason: why it was never a real problem", "```"].join("\n")
32528
32558
  };
32529
32559
  TAG_OPENERS = [
32530
32560
  ...new Set(
@@ -53491,6 +53521,7 @@ __export(webui_exports, {
53491
53521
  asFailedPostToolUse: () => asFailedPostToolUse,
53492
53522
  buildWebUi: () => buildWebUi,
53493
53523
  decideContextInject: () => decideContextInject,
53524
+ editVerdict: () => editVerdict,
53494
53525
  errorRecallTerms: () => errorRecallTerms,
53495
53526
  fileRecall: () => fileRecall,
53496
53527
  fileUriToFsPath: () => fileUriToFsPath,
@@ -53601,6 +53632,26 @@ ${lines.join("\n")}
53601
53632
  card
53602
53633
  };
53603
53634
  }
53635
+ function editVerdict(store, relPath) {
53636
+ const priors = priorsForFile(store, relPath);
53637
+ if (!priors || priors.openProblems.length === 0) return null;
53638
+ const ranked = rankByRelevance(store, priors.file.id, priors.openProblems.map((n) => n.id));
53639
+ const rank = new Map(ranked.map((r, i2) => [r.id, i2]));
53640
+ const asked = [...priors.openProblems].sort((a, b) => (rank.get(a.id) ?? 0) - (rank.get(b.id) ?? 0)).slice(0, 3);
53641
+ const lines = asked.map(
53642
+ (p) => closableByCaller(p) ? recallLine(p, `fixed: ${TAG_EXAMPLE.fix(p.id)} \xB7 not a real problem: retract it (block below) \xB7 still open: say nothing`) : recallLine(p, `another membrane's \u2014 not yours to close: ${TAG_EXAMPLE.confirm(p.id)} it held \xB7 ${TAG_EXAMPLE.refute(p.id)}`)
53643
+ );
53644
+ const retractable = asked.find((p) => closableByCaller(p));
53645
+ const shown = asked.map(deliveredPrior);
53646
+ const headline = `verdict asked: ${plural(shown.length, "open problem")} on ${relPath.split("/").slice(-2).join("/")}`;
53647
+ return {
53648
+ context: `errata \u2014 you just edited ${relPath}; ${plural(priors.openProblems.length, "open problem")} recorded on it. Give each one below a verdict in your reply:
53649
+ ${lines.join("\n")}
53650
+ ` + (retractable ? `Retract (not a real problem):
53651
+ ${TAG_EXAMPLE.retract(retractable.id)}` : ""),
53652
+ card: deliveredCard(store, headline, shown) ?? { headline, items: [] }
53653
+ };
53654
+ }
53604
53655
  function workspacePackageIds(store) {
53605
53656
  const hit = wsPackagesCache.get(store);
53606
53657
  const now = Date.now();
@@ -53671,6 +53722,7 @@ function buildWebUi(deps) {
53671
53722
  const B = deps.basePath ?? "";
53672
53723
  const lastInjectedHash = /* @__PURE__ */ new Map();
53673
53724
  const fileRecallSeen = /* @__PURE__ */ new Map();
53725
+ const editVerdictAsked = /* @__PURE__ */ new Map();
53674
53726
  const lastSubagentInjectAt = /* @__PURE__ */ new Map();
53675
53727
  const noteSessionFrom = (headerOrigin, body2, ended = false) => {
53676
53728
  const { sessionId, agentId } = hookAudience(body2);
@@ -53935,6 +53987,27 @@ function buildWebUi(deps) {
53935
53987
  }
53936
53988
  }
53937
53989
  }
53990
+ if (event === "PostToolUse" && !recall && rel && (tool === "Edit" || tool === "MultiEdit" || tool === "Write" || tool === "NotebookEdit")) {
53991
+ const sid = hookAudience(body2).contextKey;
53992
+ let asked = editVerdictAsked.get(sid);
53993
+ if (!asked) {
53994
+ asked = /* @__PURE__ */ new Set();
53995
+ editVerdictAsked.set(sid, asked);
53996
+ }
53997
+ if (!asked.has(rel)) {
53998
+ const verdict = editVerdict(deps.store, rel);
53999
+ if (verdict) {
54000
+ asked.add(rel);
54001
+ let seen = fileRecallSeen.get(sid);
54002
+ if (!seen) {
54003
+ seen = /* @__PURE__ */ new Set();
54004
+ fileRecallSeen.set(sid, seen);
54005
+ }
54006
+ seen.add(rel);
54007
+ recall = verdict;
54008
+ }
54009
+ }
54010
+ }
53938
54011
  if (event === "PostToolUse" && !recall && rel && (tool === "Read" || tool === "Edit" || tool === "Write" || tool === "NotebookEdit")) {
53939
54012
  const sid = hookAudience(body2).contextKey;
53940
54013
  let seen = fileRecallSeen.get(sid);
@@ -54397,8 +54470,8 @@ var require_ignore = __commonJS({
54397
54470
  TMP_KEY_IGNORE = Symbol.for("node-ignore");
54398
54471
  }
54399
54472
  var KEY_IGNORE = TMP_KEY_IGNORE;
54400
- var define = (object2, key, value) => {
54401
- Object.defineProperty(object2, key, { value });
54473
+ var define = (object3, key, value) => {
54474
+ Object.defineProperty(object3, key, { value });
54402
54475
  return value;
54403
54476
  };
54404
54477
  var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
@@ -55528,7 +55601,7 @@ var require_util = __commonJS({
55528
55601
  var net = __require("node:net");
55529
55602
  var { Blob: Blob2 } = __require("node:buffer");
55530
55603
  var nodeUtil = __require("node:util");
55531
- var { stringify } = __require("node:querystring");
55604
+ var { stringify: stringify2 } = __require("node:querystring");
55532
55605
  var { EventEmitter: EE } = __require("node:events");
55533
55606
  var { InvalidArgumentError } = require_errors();
55534
55607
  var { headerNameLowerCasedRecord } = require_constants();
@@ -55572,23 +55645,23 @@ var require_util = __commonJS({
55572
55645
  function isStream(obj) {
55573
55646
  return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
55574
55647
  }
55575
- function isBlobLike(object2) {
55576
- if (object2 === null) {
55648
+ function isBlobLike(object3) {
55649
+ if (object3 === null) {
55577
55650
  return false;
55578
- } else if (object2 instanceof Blob2) {
55651
+ } else if (object3 instanceof Blob2) {
55579
55652
  return true;
55580
- } else if (typeof object2 !== "object") {
55653
+ } else if (typeof object3 !== "object") {
55581
55654
  return false;
55582
55655
  } else {
55583
- const sTag = object2[Symbol.toStringTag];
55584
- return (sTag === "Blob" || sTag === "File") && ("stream" in object2 && typeof object2.stream === "function" || "arrayBuffer" in object2 && typeof object2.arrayBuffer === "function");
55656
+ const sTag = object3[Symbol.toStringTag];
55657
+ return (sTag === "Blob" || sTag === "File") && ("stream" in object3 && typeof object3.stream === "function" || "arrayBuffer" in object3 && typeof object3.arrayBuffer === "function");
55585
55658
  }
55586
55659
  }
55587
55660
  function buildURL(url2, queryParams) {
55588
55661
  if (url2.includes("?") || url2.includes("#")) {
55589
55662
  throw new Error('Query params cannot be passed when url already contains "?" or "#".');
55590
55663
  }
55591
- const stringified = stringify(queryParams);
55664
+ const stringified = stringify2(queryParams);
55592
55665
  if (stringified) {
55593
55666
  url2 += "?" + stringified;
55594
55667
  }
@@ -55863,8 +55936,8 @@ var require_util = __commonJS({
55863
55936
  }
55864
55937
  );
55865
55938
  }
55866
- function isFormDataLike(object2) {
55867
- return object2 && typeof object2 === "object" && typeof object2.append === "function" && typeof object2.delete === "function" && typeof object2.get === "function" && typeof object2.getAll === "function" && typeof object2.has === "function" && typeof object2.set === "function" && object2[Symbol.toStringTag] === "FormData";
55939
+ function isFormDataLike(object3) {
55940
+ return object3 && typeof object3 === "object" && typeof object3.append === "function" && typeof object3.delete === "function" && typeof object3.get === "function" && typeof object3.getAll === "function" && typeof object3.has === "function" && typeof object3.set === "function" && object3[Symbol.toStringTag] === "FormData";
55868
55941
  }
55869
55942
  function addAbortListener(signal, listener) {
55870
55943
  if ("addEventListener" in signal) {
@@ -57990,7 +58063,7 @@ var require_data_url = __commonJS({
57990
58063
  const buffer = Buffer.from(data, "base64");
57991
58064
  return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
57992
58065
  }
57993
- function collectAnHTTPQuotedString(input, position, extractValue) {
58066
+ function collectAnHTTPQuotedString(input, position, extractValue2) {
57994
58067
  const positionStart = position.position;
57995
58068
  let value = "";
57996
58069
  assert2(input[position.position] === '"');
@@ -58018,7 +58091,7 @@ var require_data_url = __commonJS({
58018
58091
  break;
58019
58092
  }
58020
58093
  }
58021
- if (extractValue) {
58094
+ if (extractValue2) {
58022
58095
  return value;
58023
58096
  }
58024
58097
  return input.slice(positionStart, position.position);
@@ -58618,8 +58691,8 @@ var require_util2 = __commonJS({
58618
58691
  }
58619
58692
  return "allowed";
58620
58693
  }
58621
- function isErrorLike(object2) {
58622
- return object2 instanceof Error || (object2?.constructor?.name === "Error" || object2?.constructor?.name === "DOMException");
58694
+ function isErrorLike(object3) {
58695
+ return object3 instanceof Error || (object3?.constructor?.name === "Error" || object3?.constructor?.name === "DOMException");
58623
58696
  }
58624
58697
  function isValidReasonPhrase(statusText) {
58625
58698
  for (let i2 = 0; i2 < statusText.length; ++i2) {
@@ -59044,7 +59117,7 @@ var require_util2 = __commonJS({
59044
59117
  return new FastIterableIterator(target, kind);
59045
59118
  };
59046
59119
  }
59047
- function iteratorMixin(name2, object2, kInternalIterator, keyIndex = 0, valueIndex = 1) {
59120
+ function iteratorMixin(name2, object3, kInternalIterator, keyIndex = 0, valueIndex = 1) {
59048
59121
  const makeIterator = createIterator(name2, kInternalIterator, keyIndex, valueIndex);
59049
59122
  const properties = {
59050
59123
  keys: {
@@ -59052,7 +59125,7 @@ var require_util2 = __commonJS({
59052
59125
  enumerable: true,
59053
59126
  configurable: true,
59054
59127
  value: function keys() {
59055
- webidl.brandCheck(this, object2);
59128
+ webidl.brandCheck(this, object3);
59056
59129
  return makeIterator(this, "key");
59057
59130
  }
59058
59131
  },
@@ -59061,7 +59134,7 @@ var require_util2 = __commonJS({
59061
59134
  enumerable: true,
59062
59135
  configurable: true,
59063
59136
  value: function values() {
59064
- webidl.brandCheck(this, object2);
59137
+ webidl.brandCheck(this, object3);
59065
59138
  return makeIterator(this, "value");
59066
59139
  }
59067
59140
  },
@@ -59070,7 +59143,7 @@ var require_util2 = __commonJS({
59070
59143
  enumerable: true,
59071
59144
  configurable: true,
59072
59145
  value: function entries() {
59073
- webidl.brandCheck(this, object2);
59146
+ webidl.brandCheck(this, object3);
59074
59147
  return makeIterator(this, "key+value");
59075
59148
  }
59076
59149
  },
@@ -59079,7 +59152,7 @@ var require_util2 = __commonJS({
59079
59152
  enumerable: true,
59080
59153
  configurable: true,
59081
59154
  value: function forEach(callbackfn, thisArg = globalThis) {
59082
- webidl.brandCheck(this, object2);
59155
+ webidl.brandCheck(this, object3);
59083
59156
  webidl.argumentLengthCheck(arguments, 1, `${name2}.forEach`);
59084
59157
  if (typeof callbackfn !== "function") {
59085
59158
  throw new TypeError(
@@ -59092,7 +59165,7 @@ var require_util2 = __commonJS({
59092
59165
  }
59093
59166
  }
59094
59167
  };
59095
- return Object.defineProperties(object2.prototype, {
59168
+ return Object.defineProperties(object3.prototype, {
59096
59169
  ...properties,
59097
59170
  [Symbol.iterator]: {
59098
59171
  writable: true,
@@ -59492,8 +59565,8 @@ var require_file = __commonJS({
59492
59565
  }
59493
59566
  };
59494
59567
  webidl.converters.Blob = webidl.interfaceConverter(Blob2);
59495
- function isFileLike(object2) {
59496
- return object2 instanceof File2 || object2 && (typeof object2.stream === "function" || typeof object2.arrayBuffer === "function") && object2[Symbol.toStringTag] === "File";
59568
+ function isFileLike(object3) {
59569
+ return object3 instanceof File2 || object3 && (typeof object3.stream === "function" || typeof object3.arrayBuffer === "function") && object3[Symbol.toStringTag] === "File";
59497
59570
  }
59498
59571
  module2.exports = { FileLike, isFileLike };
59499
59572
  }
@@ -59941,12 +60014,12 @@ var require_body = __commonJS({
59941
60014
  }
59942
60015
  });
59943
60016
  }
59944
- function extractBody(object2, keepalive = false) {
60017
+ function extractBody(object3, keepalive = false) {
59945
60018
  let stream = null;
59946
- if (object2 instanceof ReadableStream) {
59947
- stream = object2;
59948
- } else if (isBlobLike(object2)) {
59949
- stream = object2.stream();
60019
+ if (object3 instanceof ReadableStream) {
60020
+ stream = object3;
60021
+ } else if (isBlobLike(object3)) {
60022
+ stream = object3.stream();
59950
60023
  } else {
59951
60024
  stream = new ReadableStream({
59952
60025
  async pull(controller) {
@@ -59966,17 +60039,17 @@ var require_body = __commonJS({
59966
60039
  let source = null;
59967
60040
  let length = null;
59968
60041
  let type = null;
59969
- if (typeof object2 === "string") {
59970
- source = object2;
60042
+ if (typeof object3 === "string") {
60043
+ source = object3;
59971
60044
  type = "text/plain;charset=UTF-8";
59972
- } else if (object2 instanceof URLSearchParams) {
59973
- source = object2.toString();
60045
+ } else if (object3 instanceof URLSearchParams) {
60046
+ source = object3.toString();
59974
60047
  type = "application/x-www-form-urlencoded;charset=UTF-8";
59975
- } else if (isArrayBuffer(object2)) {
59976
- source = new Uint8Array(object2.slice());
59977
- } else if (ArrayBuffer.isView(object2)) {
59978
- source = new Uint8Array(object2.buffer.slice(object2.byteOffset, object2.byteOffset + object2.byteLength));
59979
- } else if (util.isFormDataLike(object2)) {
60048
+ } else if (isArrayBuffer(object3)) {
60049
+ source = new Uint8Array(object3.slice());
60050
+ } else if (ArrayBuffer.isView(object3)) {
60051
+ source = new Uint8Array(object3.buffer.slice(object3.byteOffset, object3.byteOffset + object3.byteLength));
60052
+ } else if (util.isFormDataLike(object3)) {
59980
60053
  const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, "0")}`;
59981
60054
  const prefix = `--${boundary}\r
59982
60055
  Content-Disposition: form-data`;
@@ -59986,7 +60059,7 @@ Content-Disposition: form-data`;
59986
60059
  const rn = new Uint8Array([13, 10]);
59987
60060
  length = 0;
59988
60061
  let hasUnknownSizeValue = false;
59989
- for (const [name2, value] of object2) {
60062
+ for (const [name2, value] of object3) {
59990
60063
  if (typeof value === "string") {
59991
60064
  const chunk2 = textEncoder.encode(prefix + `; name="${escape(normalizeLinefeeds(name2))}"\r
59992
60065
  \r
@@ -60014,7 +60087,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60014
60087
  if (hasUnknownSizeValue) {
60015
60088
  length = null;
60016
60089
  }
60017
- source = object2;
60090
+ source = object3;
60018
60091
  action = async function* () {
60019
60092
  for (const part of blobParts) {
60020
60093
  if (part.stream) {
@@ -60025,22 +60098,22 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60025
60098
  }
60026
60099
  };
60027
60100
  type = `multipart/form-data; boundary=${boundary}`;
60028
- } else if (isBlobLike(object2)) {
60029
- source = object2;
60030
- length = object2.size;
60031
- if (object2.type) {
60032
- type = object2.type;
60101
+ } else if (isBlobLike(object3)) {
60102
+ source = object3;
60103
+ length = object3.size;
60104
+ if (object3.type) {
60105
+ type = object3.type;
60033
60106
  }
60034
- } else if (typeof object2[Symbol.asyncIterator] === "function") {
60107
+ } else if (typeof object3[Symbol.asyncIterator] === "function") {
60035
60108
  if (keepalive) {
60036
60109
  throw new TypeError("keepalive");
60037
60110
  }
60038
- if (util.isDisturbed(object2) || object2.locked) {
60111
+ if (util.isDisturbed(object3) || object3.locked) {
60039
60112
  throw new TypeError(
60040
60113
  "Response body object should not be disturbed or locked"
60041
60114
  );
60042
60115
  }
60043
- stream = object2 instanceof ReadableStream ? object2 : ReadableStreamFrom(object2);
60116
+ stream = object3 instanceof ReadableStream ? object3 : ReadableStreamFrom(object3);
60044
60117
  }
60045
60118
  if (typeof source === "string" || util.isBuffer(source)) {
60046
60119
  length = Buffer.byteLength(source);
@@ -60049,7 +60122,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60049
60122
  let iterator;
60050
60123
  stream = new ReadableStream({
60051
60124
  async start() {
60052
- iterator = action(object2)[Symbol.asyncIterator]();
60125
+ iterator = action(object3)[Symbol.asyncIterator]();
60053
60126
  },
60054
60127
  async pull(controller) {
60055
60128
  const { value, done } = await iterator.next();
@@ -60077,12 +60150,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60077
60150
  const body2 = { stream, source, length };
60078
60151
  return [body2, type];
60079
60152
  }
60080
- function safelyExtractBody(object2, keepalive = false) {
60081
- if (object2 instanceof ReadableStream) {
60082
- assert2(!util.isDisturbed(object2), "The body has already been consumed.");
60083
- assert2(!object2.locked, "The stream is locked.");
60153
+ function safelyExtractBody(object3, keepalive = false) {
60154
+ if (object3 instanceof ReadableStream) {
60155
+ assert2(!util.isDisturbed(object3), "The body has already been consumed.");
60156
+ assert2(!object3.locked, "The stream is locked.");
60084
60157
  }
60085
- return extractBody(object2, keepalive);
60158
+ return extractBody(object3, keepalive);
60086
60159
  }
60087
60160
  function cloneBody(instance2, body2) {
60088
60161
  const [out1, out2] = body2.stream.tee();
@@ -60162,12 +60235,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60162
60235
  function mixinBody(prototype) {
60163
60236
  Object.assign(prototype.prototype, bodyMixinMethods(prototype));
60164
60237
  }
60165
- async function consumeBody(object2, convertBytesToJSValue, instance2) {
60166
- webidl.brandCheck(object2, instance2);
60167
- if (bodyUnusable(object2)) {
60238
+ async function consumeBody(object3, convertBytesToJSValue, instance2) {
60239
+ webidl.brandCheck(object3, instance2);
60240
+ if (bodyUnusable(object3)) {
60168
60241
  throw new TypeError("Body is unusable: Body has already been read");
60169
60242
  }
60170
- throwIfAborted(object2[kState]);
60243
+ throwIfAborted(object3[kState]);
60171
60244
  const promise2 = createDeferredPromise();
60172
60245
  const errorSteps = (error48) => promise2.reject(error48);
60173
60246
  const successSteps = (data) => {
@@ -60177,15 +60250,15 @@ Content-Type: ${value.type || "application/octet-stream"}\r
60177
60250
  errorSteps(e);
60178
60251
  }
60179
60252
  };
60180
- if (object2[kState].body == null) {
60253
+ if (object3[kState].body == null) {
60181
60254
  successSteps(Buffer.allocUnsafe(0));
60182
60255
  return promise2.promise;
60183
60256
  }
60184
- await fullyReadBody(object2[kState].body, successSteps, errorSteps);
60257
+ await fullyReadBody(object3[kState].body, successSteps, errorSteps);
60185
60258
  return promise2.promise;
60186
60259
  }
60187
- function bodyUnusable(object2) {
60188
- const body2 = object2[kState].body;
60260
+ function bodyUnusable(object3) {
60261
+ const body2 = object3[kState].body;
60189
60262
  return body2 != null && (body2.stream.locked || util.isDisturbed(body2.stream));
60190
60263
  }
60191
60264
  function parseJSONFromBytes(bytes) {
@@ -66232,10 +66305,10 @@ var require_headers = __commonJS({
66232
66305
  while (j > i2 && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i2))) ++i2;
66233
66306
  return i2 === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i2, j);
66234
66307
  }
66235
- function fill(headers, object2) {
66236
- if (Array.isArray(object2)) {
66237
- for (let i2 = 0; i2 < object2.length; ++i2) {
66238
- const header = object2[i2];
66308
+ function fill(headers, object3) {
66309
+ if (Array.isArray(object3)) {
66310
+ for (let i2 = 0; i2 < object3.length; ++i2) {
66311
+ const header = object3[i2];
66239
66312
  if (header.length !== 2) {
66240
66313
  throw webidl.errors.exception({
66241
66314
  header: "Headers constructor",
@@ -66244,10 +66317,10 @@ var require_headers = __commonJS({
66244
66317
  }
66245
66318
  appendHeader(headers, header[0], header[1]);
66246
66319
  }
66247
- } else if (typeof object2 === "object" && object2 !== null) {
66248
- const keys = Object.keys(object2);
66320
+ } else if (typeof object3 === "object" && object3 !== null) {
66321
+ const keys = Object.keys(object3);
66249
66322
  for (let i2 = 0; i2 < keys.length; ++i2) {
66250
- appendHeader(headers, keys[i2], object2[keys[i2]]);
66323
+ appendHeader(headers, keys[i2], object3[keys[i2]]);
66251
66324
  }
66252
66325
  } else {
66253
66326
  throw webidl.errors.conversionFailed({
@@ -70485,7 +70558,7 @@ var require_util6 = __commonJS({
70485
70558
  throw new Error("Invalid cookie max-age");
70486
70559
  }
70487
70560
  }
70488
- function stringify(cookie) {
70561
+ function stringify2(cookie) {
70489
70562
  if (cookie.name.length === 0) {
70490
70563
  return null;
70491
70564
  }
@@ -70539,7 +70612,7 @@ var require_util6 = __commonJS({
70539
70612
  validateCookiePath,
70540
70613
  validateCookieValue,
70541
70614
  toIMFDate,
70542
- stringify
70615
+ stringify: stringify2
70543
70616
  };
70544
70617
  }
70545
70618
  });
@@ -70689,7 +70762,7 @@ var require_cookies = __commonJS({
70689
70762
  "../../node_modules/.pnpm/undici@6.24.1/node_modules/undici/lib/web/cookies/index.js"(exports, module2) {
70690
70763
  "use strict";
70691
70764
  var { parseSetCookie } = require_parse();
70692
- var { stringify } = require_util6();
70765
+ var { stringify: stringify2 } = require_util6();
70693
70766
  var { webidl } = require_webidl();
70694
70767
  var { Headers: Headers2 } = require_headers();
70695
70768
  function getCookies(headers) {
@@ -70732,7 +70805,7 @@ var require_cookies = __commonJS({
70732
70805
  webidl.argumentLengthCheck(arguments, 2, "setCookie");
70733
70806
  webidl.brandCheck(headers, Headers2, { strict: false });
70734
70807
  cookie = webidl.converters.Cookie(cookie);
70735
- const str = stringify(cookie);
70808
+ const str = stringify2(cookie);
70736
70809
  if (str) {
70737
70810
  headers.append("Set-Cookie", str);
70738
70811
  }
@@ -73619,8 +73692,8 @@ var init_report_render = __esm({
73619
73692
 
73620
73693
  // src/cli.ts
73621
73694
  init_src6();
73622
- import { closeSync as closeSync2, existsSync as existsSync39, openSync as openSync2, readFileSync as readFileSync41, renameSync as renameSync6, statSync as statSync12 } from "node:fs";
73623
- import { join as join48, resolve as pathResolve2 } from "node:path";
73695
+ import { closeSync as closeSync2, existsSync as existsSync40, openSync as openSync2, readFileSync as readFileSync42, renameSync as renameSync7, statSync as statSync12 } from "node:fs";
73696
+ import { join as join49, resolve as pathResolve2 } from "node:path";
73624
73697
  import { spawn as spawn5 } from "node:child_process";
73625
73698
 
73626
73699
  // src/daemon.ts
@@ -82706,7 +82779,7 @@ function createWatchBreaker(deps) {
82706
82779
  }
82707
82780
 
82708
82781
  // src/engine.ts
82709
- var DAEMON_VERSION = true ? "2.0.19" : "2.0.0-alpha.0";
82782
+ var DAEMON_VERSION = true ? "2.0.20-dev.3679" : "2.0.0-alpha.0";
82710
82783
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
82711
82784
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
82712
82785
  var GIT_OP_MUTE_MS = 4e3;
@@ -83167,7 +83240,8 @@ function createWorkspaceEngine(opts) {
83167
83240
  id: h.node.id,
83168
83241
  label: h.node.label,
83169
83242
  description: h.node.description,
83170
- coverage: h.coverage
83243
+ coverage: h.coverage,
83244
+ ...isVerdictable(h.node) ? { verdict: closableByCaller(h.node) ? "own" : "foreign" } : {}
83171
83245
  })),
83172
83246
  ...collective && collective.hits.length > 0 ? {
83173
83247
  remoteHits: collective.hits.slice(0, 4).map((n) => ({ id: n.id, label: n.label, description: n.description }))
@@ -84176,7 +84250,11 @@ function createWorkspaceEngine(opts) {
84176
84250
  const closed = resolveDesignProblemById(store, pid, fx.fixNote, t);
84177
84251
  if (!closed) {
84178
84252
  const n = store.getNode(pid);
84179
- if (!n || n.label !== "Problem" && n.label !== "Vulnerability" || n.attrs["resolvedAs"] != null) {
84253
+ if (n && n.attrs["resolvedAt"] == null && !closableByCaller(n)) {
84254
+ console.warn(
84255
+ `[errata] fix tag not applied: ${pid.slice(0, 32)} belongs to a membrane you are not in \u2014 a verdict closes only your own problems; cite it with (confirm:[id]) or (refute:[id] why) instead`
84256
+ );
84257
+ } else if (!n || n.label !== "Problem" && n.label !== "Vulnerability" || n.attrs["resolvedAs"] != null) {
84180
84258
  console.warn(
84181
84259
  `[errata] fix tag went nowhere: ${!n ? `id ${pid.slice(0, 32)} unknown` : n.label !== "Problem" ? `${pid.slice(0, 32)} is a ${n.label}, not a Problem` : "the problem was retracted \u2014 a retraction is not fixable"} \u2014 the fix was NOT recorded`
84182
84260
  );
@@ -88253,7 +88331,7 @@ async function historicalAnchors(input) {
88253
88331
  if (m) beforeTokens.set(m[2], m[1]);
88254
88332
  }
88255
88333
  const parsed = /* @__PURE__ */ new Map();
88256
- const parse4 = (commit, token) => {
88334
+ const parse5 = (commit, token) => {
88257
88335
  const path2 = input.bundle.pathTokens[token];
88258
88336
  if (!path2 || /[\r\n]/.test(path2) || !pathAllowedByFloor(path2) || isPathBlocked(ignore2, path2)) return Promise.resolve(null);
88259
88337
  const provider = providers.find((p) => p.fileExtensions.includes(extname4(path2).toLowerCase()));
@@ -88292,7 +88370,7 @@ async function historicalAnchors(input) {
88292
88370
  const commit = side === "after" ? input.unit.sha : input.unit.parents[0];
88293
88371
  const token = side === "after" ? block.pathToken : beforeTokens.get(block.pathToken);
88294
88372
  if (commit && /^[a-f0-9]{40,64}$/.test(commit) && token) {
88295
- const file2 = await parse4(commit, token);
88373
+ const file2 = await parse5(commit, token);
88296
88374
  const row = (side === "after" ? after : before) - 1;
88297
88375
  const start2 = file2?.offsets[row], stop2 = file2?.offsets[row + 1];
88298
88376
  if (file2 && start2 !== void 0 && stop2 !== void 0) {
@@ -92519,18 +92597,836 @@ function consolidationGapMs(lastPassMs, policy) {
92519
92597
  return Math.max(policy.baseFloorMs, lastPassMs * policy.dutyFactor);
92520
92598
  }
92521
92599
 
92600
+ // src/codex-context-plugin.ts
92601
+ import { createHash as createHash20 } from "node:crypto";
92602
+ import { cpSync as cpSync2, existsSync as existsSync36, mkdirSync as mkdirSync10, readFileSync as readFileSync38, renameSync as renameSync6, writeFileSync as writeFileSync28 } from "node:fs";
92603
+ import { homedir as homedir8 } from "node:os";
92604
+ import { join as join45 } from "node:path";
92605
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
92606
+
92607
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
92608
+ function getLineColFromPtr(string4, ptr) {
92609
+ let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
92610
+ return [lines.length, lines.pop().length + 1];
92611
+ }
92612
+ function makeCodeBlock(string4, line, column) {
92613
+ let lines = string4.split(/\r\n|\n|\r/g);
92614
+ let codeblock = "";
92615
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
92616
+ for (let i2 = line - 1; i2 <= line + 1; i2++) {
92617
+ let l = lines[i2 - 1];
92618
+ if (!l)
92619
+ continue;
92620
+ codeblock += i2.toString().padEnd(numberLen, " ");
92621
+ codeblock += ": ";
92622
+ codeblock += l;
92623
+ codeblock += "\n";
92624
+ if (i2 === line) {
92625
+ codeblock += " ".repeat(numberLen + column + 2);
92626
+ codeblock += "^\n";
92627
+ }
92628
+ }
92629
+ return codeblock;
92630
+ }
92631
+ var TomlError = class extends Error {
92632
+ line;
92633
+ column;
92634
+ codeblock;
92635
+ constructor(message2, options) {
92636
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
92637
+ const codeblock = makeCodeBlock(options.toml, line, column);
92638
+ super(`Invalid TOML document: ${message2}
92639
+
92640
+ ${codeblock}`, options);
92641
+ this.line = line;
92642
+ this.column = column;
92643
+ this.codeblock = codeblock;
92644
+ }
92645
+ };
92646
+
92647
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/util.js
92648
+ function isEscaped(str, ptr) {
92649
+ let i2 = 0;
92650
+ while (str[ptr - ++i2] === "\\")
92651
+ ;
92652
+ return --i2 && i2 % 2;
92653
+ }
92654
+ function indexOfNewline(str, start2 = 0, end = str.length) {
92655
+ let idx = str.indexOf("\n", start2);
92656
+ if (str[idx - 1] === "\r")
92657
+ idx--;
92658
+ return idx <= end ? idx : -1;
92659
+ }
92660
+ function skipComment(str, ptr) {
92661
+ for (let i2 = ptr; i2 < str.length; i2++) {
92662
+ let c = str[i2];
92663
+ if (c === "\n")
92664
+ return i2;
92665
+ if (c === "\r" && str[i2 + 1] === "\n")
92666
+ return i2 + 1;
92667
+ if (c < " " && c !== " " || c === "\x7F") {
92668
+ throw new TomlError("control characters are not allowed in comments", {
92669
+ toml: str,
92670
+ ptr
92671
+ });
92672
+ }
92673
+ }
92674
+ return str.length;
92675
+ }
92676
+ function skipVoid(str, ptr, banNewLines, banComments) {
92677
+ let c;
92678
+ while (1) {
92679
+ while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
92680
+ ptr++;
92681
+ if (banComments || c !== "#")
92682
+ break;
92683
+ ptr = skipComment(str, ptr);
92684
+ }
92685
+ return ptr;
92686
+ }
92687
+ function skipUntil(str, ptr, sep6, end, banNewLines = false) {
92688
+ if (!end) {
92689
+ ptr = indexOfNewline(str, ptr);
92690
+ return ptr < 0 ? str.length : ptr;
92691
+ }
92692
+ for (let i2 = ptr; i2 < str.length; i2++) {
92693
+ let c = str[i2];
92694
+ if (c === "#") {
92695
+ i2 = indexOfNewline(str, i2);
92696
+ } else if (c === sep6) {
92697
+ return i2 + 1;
92698
+ } else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i2 + 1] === "\n")) {
92699
+ return i2;
92700
+ }
92701
+ }
92702
+ throw new TomlError("cannot find end of structure", {
92703
+ toml: str,
92704
+ ptr
92705
+ });
92706
+ }
92707
+ function getStringEnd(str, seek) {
92708
+ let first = str[seek];
92709
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
92710
+ seek += target.length - 1;
92711
+ do
92712
+ seek = str.indexOf(target, ++seek);
92713
+ while (seek > -1 && first !== "'" && isEscaped(str, seek));
92714
+ if (seek > -1) {
92715
+ seek += target.length;
92716
+ if (target.length > 1) {
92717
+ if (str[seek] === first)
92718
+ seek++;
92719
+ if (str[seek] === first)
92720
+ seek++;
92721
+ }
92722
+ }
92723
+ return seek;
92724
+ }
92725
+
92726
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/date.js
92727
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
92728
+ var TomlDate = class _TomlDate extends Date {
92729
+ #hasDate = false;
92730
+ #hasTime = false;
92731
+ #offset = null;
92732
+ constructor(date5) {
92733
+ let hasDate = true;
92734
+ let hasTime = true;
92735
+ let offset = "Z";
92736
+ if (typeof date5 === "string") {
92737
+ let match2 = date5.match(DATE_TIME_RE);
92738
+ if (match2) {
92739
+ if (!match2[1]) {
92740
+ hasDate = false;
92741
+ date5 = `0000-01-01T${date5}`;
92742
+ }
92743
+ hasTime = !!match2[2];
92744
+ hasTime && date5[10] === " " && (date5 = date5.replace(" ", "T"));
92745
+ if (match2[2] && +match2[2] > 23) {
92746
+ date5 = "";
92747
+ } else {
92748
+ offset = match2[3] || null;
92749
+ date5 = date5.toUpperCase();
92750
+ if (!offset && hasTime)
92751
+ date5 += "Z";
92752
+ }
92753
+ } else {
92754
+ date5 = "";
92755
+ }
92756
+ }
92757
+ super(date5);
92758
+ if (!isNaN(this.getTime())) {
92759
+ this.#hasDate = hasDate;
92760
+ this.#hasTime = hasTime;
92761
+ this.#offset = offset;
92762
+ }
92763
+ }
92764
+ isDateTime() {
92765
+ return this.#hasDate && this.#hasTime;
92766
+ }
92767
+ isLocal() {
92768
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
92769
+ }
92770
+ isDate() {
92771
+ return this.#hasDate && !this.#hasTime;
92772
+ }
92773
+ isTime() {
92774
+ return this.#hasTime && !this.#hasDate;
92775
+ }
92776
+ isValid() {
92777
+ return this.#hasDate || this.#hasTime;
92778
+ }
92779
+ toISOString() {
92780
+ let iso = super.toISOString();
92781
+ if (this.isDate())
92782
+ return iso.slice(0, 10);
92783
+ if (this.isTime())
92784
+ return iso.slice(11, 23);
92785
+ if (this.#offset === null)
92786
+ return iso.slice(0, -1);
92787
+ if (this.#offset === "Z")
92788
+ return iso;
92789
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
92790
+ offset = this.#offset[0] === "-" ? offset : -offset;
92791
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
92792
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
92793
+ }
92794
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
92795
+ let date5 = new _TomlDate(jsDate);
92796
+ date5.#offset = offset;
92797
+ return date5;
92798
+ }
92799
+ static wrapAsLocalDateTime(jsDate) {
92800
+ let date5 = new _TomlDate(jsDate);
92801
+ date5.#offset = null;
92802
+ return date5;
92803
+ }
92804
+ static wrapAsLocalDate(jsDate) {
92805
+ let date5 = new _TomlDate(jsDate);
92806
+ date5.#hasTime = false;
92807
+ date5.#offset = null;
92808
+ return date5;
92809
+ }
92810
+ static wrapAsLocalTime(jsDate) {
92811
+ let date5 = new _TomlDate(jsDate);
92812
+ date5.#hasDate = false;
92813
+ date5.#offset = null;
92814
+ return date5;
92815
+ }
92816
+ };
92817
+
92818
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/primitive.js
92819
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
92820
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
92821
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
92822
+ var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
92823
+ var ESC_MAP = {
92824
+ b: "\b",
92825
+ t: " ",
92826
+ n: "\n",
92827
+ f: "\f",
92828
+ r: "\r",
92829
+ e: "\x1B",
92830
+ '"': '"',
92831
+ "\\": "\\"
92832
+ };
92833
+ function parseString(str, ptr = 0, endPtr = str.length) {
92834
+ let isLiteral = str[ptr] === "'";
92835
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
92836
+ if (isMultiline) {
92837
+ endPtr -= 2;
92838
+ if (str[ptr += 2] === "\r")
92839
+ ptr++;
92840
+ if (str[ptr] === "\n")
92841
+ ptr++;
92842
+ }
92843
+ let tmp = 0;
92844
+ let isEscape;
92845
+ let parsed = "";
92846
+ let sliceStart = ptr;
92847
+ while (ptr < endPtr - 1) {
92848
+ let c = str[ptr++];
92849
+ if (c === "\n" || c === "\r" && str[ptr] === "\n") {
92850
+ if (!isMultiline) {
92851
+ throw new TomlError("newlines are not allowed in strings", {
92852
+ toml: str,
92853
+ ptr: ptr - 1
92854
+ });
92855
+ }
92856
+ } else if (c < " " && c !== " " || c === "\x7F") {
92857
+ throw new TomlError("control characters are not allowed in strings", {
92858
+ toml: str,
92859
+ ptr: ptr - 1
92860
+ });
92861
+ }
92862
+ if (isEscape) {
92863
+ isEscape = false;
92864
+ if (c === "x" || c === "u" || c === "U") {
92865
+ let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
92866
+ if (!ESCAPE_REGEX.test(code)) {
92867
+ throw new TomlError("invalid unicode escape", {
92868
+ toml: str,
92869
+ ptr: tmp
92870
+ });
92871
+ }
92872
+ try {
92873
+ parsed += String.fromCodePoint(parseInt(code, 16));
92874
+ } catch {
92875
+ throw new TomlError("invalid unicode escape", {
92876
+ toml: str,
92877
+ ptr: tmp
92878
+ });
92879
+ }
92880
+ } else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
92881
+ ptr = skipVoid(str, ptr - 1, true);
92882
+ if (str[ptr] !== "\n" && str[ptr] !== "\r") {
92883
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
92884
+ toml: str,
92885
+ ptr: tmp
92886
+ });
92887
+ }
92888
+ ptr = skipVoid(str, ptr);
92889
+ } else if (c in ESC_MAP) {
92890
+ parsed += ESC_MAP[c];
92891
+ } else {
92892
+ throw new TomlError("unrecognized escape sequence", {
92893
+ toml: str,
92894
+ ptr: tmp
92895
+ });
92896
+ }
92897
+ sliceStart = ptr;
92898
+ } else if (!isLiteral && c === "\\") {
92899
+ tmp = ptr - 1;
92900
+ isEscape = true;
92901
+ parsed += str.slice(sliceStart, tmp);
92902
+ }
92903
+ }
92904
+ return parsed + str.slice(sliceStart, endPtr - 1);
92905
+ }
92906
+ function parseValue(value, toml, ptr, integersAsBigInt) {
92907
+ if (value === "true")
92908
+ return true;
92909
+ if (value === "false")
92910
+ return false;
92911
+ if (value === "-inf")
92912
+ return -Infinity;
92913
+ if (value === "inf" || value === "+inf")
92914
+ return Infinity;
92915
+ if (value === "nan" || value === "+nan" || value === "-nan")
92916
+ return NaN;
92917
+ if (value === "-0")
92918
+ return integersAsBigInt ? 0n : 0;
92919
+ let isInt = INT_REGEX.test(value);
92920
+ if (isInt || FLOAT_REGEX.test(value)) {
92921
+ if (LEADING_ZERO.test(value)) {
92922
+ throw new TomlError("leading zeroes are not allowed", {
92923
+ toml,
92924
+ ptr
92925
+ });
92926
+ }
92927
+ value = value.replace(/_/g, "");
92928
+ let numeric = +value;
92929
+ if (isNaN(numeric)) {
92930
+ throw new TomlError("invalid number", {
92931
+ toml,
92932
+ ptr
92933
+ });
92934
+ }
92935
+ if (isInt) {
92936
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
92937
+ throw new TomlError("integer value cannot be represented losslessly", {
92938
+ toml,
92939
+ ptr
92940
+ });
92941
+ }
92942
+ if (isInt || integersAsBigInt === true)
92943
+ numeric = BigInt(value);
92944
+ }
92945
+ return numeric;
92946
+ }
92947
+ const date5 = new TomlDate(value);
92948
+ if (!date5.isValid()) {
92949
+ throw new TomlError("invalid value", {
92950
+ toml,
92951
+ ptr
92952
+ });
92953
+ }
92954
+ return date5;
92955
+ }
92956
+
92957
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/extract.js
92958
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
92959
+ let value = str.slice(startPtr, endPtr);
92960
+ let commentIdx = value.indexOf("#");
92961
+ if (commentIdx > -1) {
92962
+ skipComment(str, commentIdx);
92963
+ value = value.slice(0, commentIdx);
92964
+ }
92965
+ return [value.trimEnd(), commentIdx];
92966
+ }
92967
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
92968
+ if (depth === 0) {
92969
+ throw new TomlError("document contains excessively nested structures. aborting.", {
92970
+ toml: str,
92971
+ ptr
92972
+ });
92973
+ }
92974
+ let c = str[ptr];
92975
+ if (c === "[" || c === "{") {
92976
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
92977
+ if (end) {
92978
+ endPtr2 = skipVoid(str, endPtr2);
92979
+ if (str[endPtr2] === ",")
92980
+ endPtr2++;
92981
+ else if (str[endPtr2] !== end) {
92982
+ throw new TomlError("expected comma or end of structure", {
92983
+ toml: str,
92984
+ ptr: endPtr2
92985
+ });
92986
+ }
92987
+ }
92988
+ return [value, endPtr2];
92989
+ }
92990
+ let endPtr;
92991
+ if (c === '"' || c === "'") {
92992
+ endPtr = getStringEnd(str, ptr);
92993
+ let parsed = parseString(str, ptr, endPtr);
92994
+ if (end) {
92995
+ endPtr = skipVoid(str, endPtr);
92996
+ if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
92997
+ throw new TomlError("unexpected character encountered", {
92998
+ toml: str,
92999
+ ptr: endPtr
93000
+ });
93001
+ }
93002
+ endPtr += +(str[endPtr] === ",");
93003
+ }
93004
+ return [parsed, endPtr];
93005
+ }
93006
+ endPtr = skipUntil(str, ptr, ",", end);
93007
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
93008
+ if (!slice[0]) {
93009
+ throw new TomlError("incomplete key-value declaration: no value specified", {
93010
+ toml: str,
93011
+ ptr
93012
+ });
93013
+ }
93014
+ if (end && slice[1] > -1) {
93015
+ endPtr = skipVoid(str, ptr + slice[1]);
93016
+ endPtr += +(str[endPtr] === ",");
93017
+ }
93018
+ return [
93019
+ parseValue(slice[0], str, ptr, integersAsBigInt),
93020
+ endPtr
93021
+ ];
93022
+ }
93023
+
93024
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/struct.js
93025
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
93026
+ function parseKey(str, ptr, end = "=") {
93027
+ let dot = ptr - 1;
93028
+ let parsed = [];
93029
+ let endPtr = str.indexOf(end, ptr);
93030
+ if (endPtr < 0) {
93031
+ throw new TomlError("incomplete key-value: cannot find end of key", {
93032
+ toml: str,
93033
+ ptr
93034
+ });
93035
+ }
93036
+ do {
93037
+ let c = str[ptr = ++dot];
93038
+ if (c !== " " && c !== " ") {
93039
+ if (c === '"' || c === "'") {
93040
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
93041
+ throw new TomlError("multiline strings are not allowed in keys", {
93042
+ toml: str,
93043
+ ptr
93044
+ });
93045
+ }
93046
+ let eos = getStringEnd(str, ptr);
93047
+ if (eos < 0) {
93048
+ throw new TomlError("unfinished string encountered", {
93049
+ toml: str,
93050
+ ptr
93051
+ });
93052
+ }
93053
+ dot = str.indexOf(".", eos);
93054
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
93055
+ let newLine = indexOfNewline(strEnd);
93056
+ if (newLine > -1) {
93057
+ throw new TomlError("newlines are not allowed in keys", {
93058
+ toml: str,
93059
+ ptr: ptr + dot + newLine
93060
+ });
93061
+ }
93062
+ if (strEnd.trimStart()) {
93063
+ throw new TomlError("found extra tokens after the string part", {
93064
+ toml: str,
93065
+ ptr: eos
93066
+ });
93067
+ }
93068
+ if (endPtr < eos) {
93069
+ endPtr = str.indexOf(end, eos);
93070
+ if (endPtr < 0) {
93071
+ throw new TomlError("incomplete key-value: cannot find end of key", {
93072
+ toml: str,
93073
+ ptr
93074
+ });
93075
+ }
93076
+ }
93077
+ parsed.push(parseString(str, ptr, eos));
93078
+ } else {
93079
+ dot = str.indexOf(".", ptr);
93080
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
93081
+ if (!KEY_PART_RE.test(part)) {
93082
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
93083
+ toml: str,
93084
+ ptr
93085
+ });
93086
+ }
93087
+ parsed.push(part.trimEnd());
93088
+ }
93089
+ }
93090
+ } while (dot + 1 && dot < endPtr);
93091
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
93092
+ }
93093
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
93094
+ let res = {};
93095
+ let seen = /* @__PURE__ */ new Set();
93096
+ let c;
93097
+ ptr++;
93098
+ while ((c = str[ptr++]) !== "}" && c) {
93099
+ if (c === ",") {
93100
+ throw new TomlError("expected value, found comma", {
93101
+ toml: str,
93102
+ ptr: ptr - 1
93103
+ });
93104
+ } else if (c === "#")
93105
+ ptr = skipComment(str, ptr);
93106
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
93107
+ let k;
93108
+ let t = res;
93109
+ let hasOwn = false;
93110
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
93111
+ for (let i2 = 0; i2 < key.length; i2++) {
93112
+ if (i2)
93113
+ t = hasOwn ? t[k] : t[k] = {};
93114
+ k = key[i2];
93115
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
93116
+ throw new TomlError("trying to redefine an already defined value", {
93117
+ toml: str,
93118
+ ptr
93119
+ });
93120
+ }
93121
+ if (!hasOwn && k === "__proto__") {
93122
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
93123
+ }
93124
+ }
93125
+ if (hasOwn) {
93126
+ throw new TomlError("trying to redefine an already defined value", {
93127
+ toml: str,
93128
+ ptr
93129
+ });
93130
+ }
93131
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
93132
+ seen.add(value);
93133
+ t[k] = value;
93134
+ ptr = valueEndPtr;
93135
+ }
93136
+ }
93137
+ if (!c) {
93138
+ throw new TomlError("unfinished table encountered", {
93139
+ toml: str,
93140
+ ptr
93141
+ });
93142
+ }
93143
+ return [res, ptr];
93144
+ }
93145
+ function parseArray(str, ptr, depth, integersAsBigInt) {
93146
+ let res = [];
93147
+ let c;
93148
+ ptr++;
93149
+ while ((c = str[ptr++]) !== "]" && c) {
93150
+ if (c === ",") {
93151
+ throw new TomlError("expected value, found comma", {
93152
+ toml: str,
93153
+ ptr: ptr - 1
93154
+ });
93155
+ } else if (c === "#")
93156
+ ptr = skipComment(str, ptr);
93157
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
93158
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
93159
+ res.push(e[0]);
93160
+ ptr = e[1];
93161
+ }
93162
+ }
93163
+ if (!c) {
93164
+ throw new TomlError("unfinished array encountered", {
93165
+ toml: str,
93166
+ ptr
93167
+ });
93168
+ }
93169
+ return [res, ptr];
93170
+ }
93171
+
93172
+ // ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/parse.js
93173
+ function peekTable(key, table, meta3, type) {
93174
+ let t = table;
93175
+ let m = meta3;
93176
+ let k;
93177
+ let hasOwn = false;
93178
+ let state;
93179
+ for (let i2 = 0; i2 < key.length; i2++) {
93180
+ if (i2) {
93181
+ t = hasOwn ? t[k] : t[k] = {};
93182
+ m = (state = m[k]).c;
93183
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
93184
+ return null;
93185
+ }
93186
+ if (state.t === 2) {
93187
+ let l = t.length - 1;
93188
+ t = t[l];
93189
+ m = m[l].c;
93190
+ }
93191
+ }
93192
+ k = key[i2];
93193
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
93194
+ return null;
93195
+ }
93196
+ if (!hasOwn) {
93197
+ if (k === "__proto__") {
93198
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
93199
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
93200
+ }
93201
+ m[k] = {
93202
+ t: i2 < key.length - 1 && type === 2 ? 3 : type,
93203
+ d: false,
93204
+ i: 0,
93205
+ c: {}
93206
+ };
93207
+ }
93208
+ }
93209
+ state = m[k];
93210
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
93211
+ return null;
93212
+ }
93213
+ if (type === 2) {
93214
+ if (!state.d) {
93215
+ state.d = true;
93216
+ t[k] = [];
93217
+ }
93218
+ t[k].push(t = {});
93219
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
93220
+ }
93221
+ if (state.d) {
93222
+ return null;
93223
+ }
93224
+ state.d = true;
93225
+ if (type === 1) {
93226
+ t = hasOwn ? t[k] : t[k] = {};
93227
+ } else if (type === 0 && hasOwn) {
93228
+ return null;
93229
+ }
93230
+ return [k, t, state.c];
93231
+ }
93232
+ function parse4(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
93233
+ let res = {};
93234
+ let meta3 = {};
93235
+ let tbl = res;
93236
+ let m = meta3;
93237
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
93238
+ if (toml[ptr] === "[") {
93239
+ let isTableArray = toml[++ptr] === "[";
93240
+ let k = parseKey(toml, ptr += +isTableArray, "]");
93241
+ if (isTableArray) {
93242
+ if (toml[k[1] - 1] !== "]") {
93243
+ throw new TomlError("expected end of table declaration", {
93244
+ toml,
93245
+ ptr: k[1] - 1
93246
+ });
93247
+ }
93248
+ k[1]++;
93249
+ }
93250
+ let p = peekTable(
93251
+ k[0],
93252
+ res,
93253
+ meta3,
93254
+ isTableArray ? 2 : 1
93255
+ /* Type.EXPLICIT */
93256
+ );
93257
+ if (!p) {
93258
+ throw new TomlError("trying to redefine an already defined table or value", {
93259
+ toml,
93260
+ ptr
93261
+ });
93262
+ }
93263
+ m = p[2];
93264
+ tbl = p[1];
93265
+ ptr = k[1];
93266
+ } else {
93267
+ let k = parseKey(toml, ptr);
93268
+ let p = peekTable(
93269
+ k[0],
93270
+ tbl,
93271
+ m,
93272
+ 0
93273
+ /* Type.DOTTED */
93274
+ );
93275
+ if (!p) {
93276
+ throw new TomlError("trying to redefine an already defined table or value", {
93277
+ toml,
93278
+ ptr
93279
+ });
93280
+ }
93281
+ let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
93282
+ p[1][p[0]] = v[0];
93283
+ ptr = v[1];
93284
+ }
93285
+ ptr = skipVoid(toml, ptr, true);
93286
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
93287
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
93288
+ toml,
93289
+ ptr
93290
+ });
93291
+ }
93292
+ ptr = skipVoid(toml, ptr);
93293
+ }
93294
+ return res;
93295
+ }
93296
+
93297
+ // src/codex-context-plugin.ts
93298
+ var NAME = "errata-context";
93299
+ var PREFIX2 = `./.errata/plugins/${NAME}/`;
93300
+ var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
93301
+ function readText(file2) {
93302
+ return existsSync36(file2) ? readFileSync38(file2, "utf8") : "";
93303
+ }
93304
+ function writeChanged(file2, content) {
93305
+ if (readText(file2) === content) return;
93306
+ const temp = `${file2}.${process.pid}.tmp`;
93307
+ writeFileSync28(temp, content, "utf8");
93308
+ renameSync6(temp, file2);
93309
+ }
93310
+ function bundledContextPlugin() {
93311
+ const packaged = fileURLToPath2(new URL("./resources/context-plugin/", import.meta.url));
93312
+ if (existsSync36(join45(packaged, ".codex-plugin/plugin.json"))) return packaged;
93313
+ return fileURLToPath2(new URL("../dist/resources/context-plugin/", import.meta.url));
93314
+ }
93315
+ function refreshCodexContextPlugin(root) {
93316
+ const file2 = join45(root, ".agents", "plugins", "marketplace.json");
93317
+ if (!existsSync36(file2)) return false;
93318
+ const marketplace = JSON.parse(readFileSync38(file2, "utf8"));
93319
+ const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
93320
+ const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
93321
+ if (!entry) return false;
93322
+ const before = object2(entry.source).path;
93323
+ const installed = installCodexContextPlugin(root);
93324
+ return String(before) !== `${PREFIX2}${installed.plugin.split(/[\\/]/).at(-1)}`;
93325
+ }
93326
+ function installCodexContextPlugin(root, options = {}) {
93327
+ const bundle = options.bundle ?? bundledContextPlugin();
93328
+ const manifest = JSON.parse(
93329
+ readFileSync38(join45(bundle, ".codex-plugin/plugin.json"), "utf8")
93330
+ );
93331
+ if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
93332
+ throw new Error("Invalid bundled Errata Context manifest.");
93333
+ }
93334
+ const checksums = readFileSync38(join45(bundle, "SHA256SUMS"), "utf8");
93335
+ for (const line of checksums.trim().split("\n")) {
93336
+ const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
93337
+ if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
93338
+ throw new Error("Invalid bundled Errata Context checksum manifest.");
93339
+ }
93340
+ const actual = createHash20("sha256").update(readFileSync38(join45(bundle, match2[2]))).digest("hex");
93341
+ if (actual !== match2[1])
93342
+ throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
93343
+ }
93344
+ const release = `${manifest.version}-${createHash20("sha256").update(checksums).digest("hex").slice(0, 12)}`;
93345
+ const plugin = join45(root, ".errata", "plugins", NAME, release);
93346
+ const marketplaceFile = join45(root, ".agents", "plugins", "marketplace.json");
93347
+ const priorMarketplace = readText(marketplaceFile);
93348
+ const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
93349
+ name: "errata-local",
93350
+ interface: { displayName: "Errata" },
93351
+ plugins: []
93352
+ };
93353
+ if (typeof marketplace.name !== "string" || !/^[\w.-]+$/.test(marketplace.name) || !Array.isArray(marketplace.plugins)) {
93354
+ throw new Error(`Invalid marketplace at ${marketplaceFile}; preserved it.`);
93355
+ }
93356
+ const entries = marketplace.plugins;
93357
+ const matches = entries.filter((entry2) => entry2.name === NAME);
93358
+ if (matches.length > 1)
93359
+ throw new Error("Duplicate Errata Context marketplace entries; preserved them.");
93360
+ const prior = matches[0];
93361
+ if (prior && !(object2(prior.source).source === "local" && String(object2(prior.source).path).startsWith(PREFIX2))) {
93362
+ throw new Error(
93363
+ "An independently managed Errata Context entry already exists in this marketplace; preserved it."
93364
+ );
93365
+ }
93366
+ const key = `${NAME}@${marketplace.name}`;
93367
+ const configFile = join45(root, ".codex", "config.toml");
93368
+ const config2 = readText(configFile);
93369
+ const parsed = parse4(config2);
93370
+ const plugins = object2(parsed.plugins);
93371
+ const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join45(homedir8(), ".codex");
93372
+ const globalPlugins = object2(parse4(readText(join45(codexHome, "config.toml"))).plugins);
93373
+ const disabledGlobally = Object.entries(globalPlugins).some(
93374
+ ([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
93375
+ );
93376
+ const policyDisabled = object2(prior?.policy).installation === "NOT_AVAILABLE";
93377
+ const localSetting = object2(plugins[key]);
93378
+ const hasLocalSetting = Object.hasOwn(plugins, key);
93379
+ const enabled = !policyDisabled && (hasLocalSetting ? localSetting.enabled !== false : !disabledGlobally);
93380
+ const nextConfig = hasLocalSetting ? config2 : config2.trimEnd() + (config2.trim() ? "\n\n" : "") + `# Errata Context: installed by errata's Codex setup.
93381
+ [plugins.${JSON.stringify(key)}]
93382
+ enabled = ${enabled}
93383
+ `;
93384
+ parse4(nextConfig);
93385
+ const entry = {
93386
+ ...prior,
93387
+ name: NAME,
93388
+ source: { source: "local", path: `${PREFIX2}${release}` },
93389
+ policy: prior?.policy ?? { installation: "AVAILABLE", authentication: "ON_INSTALL" },
93390
+ category: prior?.category ?? "Productivity"
93391
+ };
93392
+ marketplace.plugins = [...entries.filter((item2) => item2.name !== NAME), entry];
93393
+ mkdirSync10(plugin, { recursive: true });
93394
+ cpSync2(bundle, plugin, { recursive: true });
93395
+ writeChanged(
93396
+ join45(plugin, ".mcp.json"),
93397
+ JSON.stringify(
93398
+ {
93399
+ mcpServers: {
93400
+ errata_context: {
93401
+ command: options.nodePath ?? process.execPath,
93402
+ args: [join45(plugin, "dist", "mcp-server.mjs")],
93403
+ env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
93404
+ }
93405
+ }
93406
+ },
93407
+ null,
93408
+ 2
93409
+ ) + "\n"
93410
+ );
93411
+ mkdirSync10(join45(root, ".agents", "plugins"), { recursive: true });
93412
+ mkdirSync10(join45(root, ".codex"), { recursive: true });
93413
+ writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
93414
+ writeChanged(configFile, nextConfig);
93415
+ return { plugin, enabled, marketplace: marketplaceFile };
93416
+ }
93417
+
92522
93418
  // src/codex-hook-refresh.ts
92523
93419
  init_checkout_root();
92524
- import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as readFileSync38 } from "node:fs";
92525
- import { dirname as dirname13, join as join45, resolve as resolve8 } from "node:path";
93420
+ import { existsSync as existsSync37, readdirSync as readdirSync13, readFileSync as readFileSync39 } from "node:fs";
93421
+ import { dirname as dirname13, join as join46, resolve as resolve8 } from "node:path";
92526
93422
  init_registry();
92527
93423
  function codexHookRoots(roots) {
92528
93424
  const found = new Set(roots.map((root) => resolve8(root)));
92529
93425
  for (const root of [...found]) {
92530
93426
  const main2 = mainCheckoutOfWorktree(root) ?? root;
92531
93427
  found.add(main2);
92532
- const dir = join45(main2, ".git", "worktrees");
92533
- if (!existsSync36(dir)) continue;
93428
+ const dir = join46(main2, ".git", "worktrees");
93429
+ if (!existsSync37(dir)) continue;
92534
93430
  let names;
92535
93431
  try {
92536
93432
  names = readdirSync13(dir);
@@ -92539,7 +93435,7 @@ function codexHookRoots(roots) {
92539
93435
  }
92540
93436
  for (const name2 of names) {
92541
93437
  try {
92542
- const checkout = dirname13(readFileSync38(join45(dir, name2, "gitdir"), "utf8").trim());
93438
+ const checkout = dirname13(readFileSync39(join46(dir, name2, "gitdir"), "utf8").trim());
92543
93439
  if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
92544
93440
  } catch {
92545
93441
  }
@@ -92561,9 +93457,9 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
92561
93457
  }
92562
93458
 
92563
93459
  // src/claude-statusline.ts
92564
- import { existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync39, writeFileSync as writeFileSync28 } from "node:fs";
92565
- import { homedir as homedir8 } from "node:os";
92566
- import { dirname as dirname14, join as join46 } from "node:path";
93460
+ import { existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync40, writeFileSync as writeFileSync29 } from "node:fs";
93461
+ import { homedir as homedir9 } from "node:os";
93462
+ import { dirname as dirname14, join as join47 } from "node:path";
92567
93463
  var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
92568
93464
  import { readFileSync } from 'node:fs';
92569
93465
 
@@ -92611,8 +93507,8 @@ function isSameInstall(value, relay) {
92611
93507
  return command.includes(relay.replace(/\\/g, "/").toLowerCase());
92612
93508
  }
92613
93509
  function userClaudeSettingsPath() {
92614
- const base = process.env["CLAUDE_CONFIG_DIR"] ?? join46(homedir8(), ".claude");
92615
- return join46(base, "settings.json");
93510
+ const base = process.env["CLAUDE_CONFIG_DIR"] ?? join47(homedir9(), ".claude");
93511
+ return join47(base, "settings.json");
92616
93512
  }
92617
93513
  function ensureUserStatusLine(opts) {
92618
93514
  const env2 = opts.env ?? process.env;
@@ -92620,23 +93516,23 @@ function ensureUserStatusLine(opts) {
92620
93516
  if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
92621
93517
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
92622
93518
  let settings = {};
92623
- if (existsSync37(settingsPath)) {
93519
+ if (existsSync38(settingsPath)) {
92624
93520
  try {
92625
- const parsed = JSON.parse(readFileSync39(settingsPath, "utf8"));
93521
+ const parsed = JSON.parse(readFileSync40(settingsPath, "utf8"));
92626
93522
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
92627
93523
  settings = parsed;
92628
93524
  } catch {
92629
93525
  return "unreadable";
92630
93526
  }
92631
93527
  }
92632
- const relay = join46(opts.relayDir, STATUSLINE_RELAY_FILE);
93528
+ const relay = join47(opts.relayDir, STATUSLINE_RELAY_FILE);
92633
93529
  const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
92634
93530
  const ownMain = keep(settings["statusLine"]);
92635
93531
  const ownRows = keep(settings["subagentStatusLine"]);
92636
93532
  if (ownMain && ownRows) return "kept-own";
92637
- mkdirSync10(opts.relayDir, { recursive: true });
92638
- if (!existsSync37(relay) || readFileSync39(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
92639
- writeFileSync28(relay, STATUSLINE_RELAY_SOURCE, "utf8");
93533
+ mkdirSync11(opts.relayDir, { recursive: true });
93534
+ if (!existsSync38(relay) || readFileSync40(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
93535
+ writeFileSync29(relay, STATUSLINE_RELAY_SOURCE, "utf8");
92640
93536
  }
92641
93537
  const nodePath = opts.nodePath ?? process.execPath;
92642
93538
  const next = {
@@ -92647,8 +93543,8 @@ function ensureUserStatusLine(opts) {
92647
93543
  return ownMain ? "kept-own" : "unchanged";
92648
93544
  }
92649
93545
  Object.assign(settings, next);
92650
- mkdirSync10(dirname14(settingsPath), { recursive: true });
92651
- writeFileSync28(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
93546
+ mkdirSync11(dirname14(settingsPath), { recursive: true });
93547
+ writeFileSync29(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
92652
93548
  return "installed";
92653
93549
  }
92654
93550
  function describeStatusLineOutcome(outcome) {
@@ -92667,15 +93563,15 @@ function describeStatusLineOutcome(outcome) {
92667
93563
  }
92668
93564
 
92669
93565
  // src/claude-mods.ts
92670
- import { createHash as createHash20 } from "node:crypto";
92671
- import { cpSync as cpSync2, existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync40, readdirSync as readdirSync14, rmSync as rmSync4, statSync as statSync11, writeFileSync as writeFileSync29 } from "node:fs";
92672
- import { delimiter as delimiter2, dirname as dirname15, join as join47, relative as relative7, resolve as resolve9, sep as sep5 } from "node:path";
92673
- import { fileURLToPath as fileURLToPath2 } from "node:url";
93566
+ import { createHash as createHash21 } from "node:crypto";
93567
+ import { cpSync as cpSync3, existsSync as existsSync39, mkdirSync as mkdirSync12, readFileSync as readFileSync41, readdirSync as readdirSync14, rmSync as rmSync4, statSync as statSync11, writeFileSync as writeFileSync30 } from "node:fs";
93568
+ import { delimiter as delimiter2, dirname as dirname15, join as join48, relative as relative7, resolve as resolve9, sep as sep5 } from "node:path";
93569
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
92674
93570
  var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
92675
93571
  var HASH_FILE = ".errata-mod-hash";
92676
93572
  function bundledClaudeModsDir() {
92677
93573
  const rel = import.meta.url.endsWith(".mjs") ? "./resources/claude-mods/" : "../claude-mods/";
92678
- return fileURLToPath2(new URL(rel, import.meta.url));
93574
+ return fileURLToPath3(new URL(rel, import.meta.url));
92679
93575
  }
92680
93576
  function isEngineOwned(relPath) {
92681
93577
  const p = relPath.split(sep5).join("/");
@@ -92684,7 +93580,7 @@ function isEngineOwned(relPath) {
92684
93580
  function listFiles(root, dir = root) {
92685
93581
  const out2 = [];
92686
93582
  for (const name2 of readdirSync14(dir)) {
92687
- const abs = join47(dir, name2);
93583
+ const abs = join48(dir, name2);
92688
93584
  if (isEngineOwned(relative7(root, abs))) continue;
92689
93585
  if (statSync11(abs).isDirectory()) out2.push(...listFiles(root, abs));
92690
93586
  else out2.push(abs);
@@ -92692,18 +93588,18 @@ function listFiles(root, dir = root) {
92692
93588
  return out2;
92693
93589
  }
92694
93590
  function modHash(dir) {
92695
- const h = createHash20("sha256");
93591
+ const h = createHash21("sha256");
92696
93592
  for (const abs of listFiles(dir).sort()) {
92697
93593
  h.update(relative7(dir, abs).split(sep5).join("/"));
92698
93594
  h.update("\0");
92699
- h.update(readFileSync40(abs));
93595
+ h.update(readFileSync41(abs));
92700
93596
  h.update("\0");
92701
93597
  }
92702
93598
  return h.digest("hex");
92703
93599
  }
92704
93600
  function bundledMods(bundleDir) {
92705
- if (!existsSync38(bundleDir)) return [];
92706
- return readdirSync14(bundleDir).filter((name2) => existsSync38(join47(bundleDir, name2, ".claude-plugin", "plugin.json")));
93601
+ if (!existsSync39(bundleDir)) return [];
93602
+ return readdirSync14(bundleDir).filter((name2) => existsSync39(join48(bundleDir, name2, ".claude-plugin", "plugin.json")));
92707
93603
  }
92708
93604
  function sameDir(a, b) {
92709
93605
  const norm = (p) => resolve9(p).replace(/[\\/]+$/, "").toLowerCase();
@@ -92718,9 +93614,9 @@ function off(env2) {
92718
93614
  return v === "0" || v === "off" || v === "false" || v === "no";
92719
93615
  }
92720
93616
  function readSettings(path2) {
92721
- if (!existsSync38(path2)) return {};
93617
+ if (!existsSync39(path2)) return {};
92722
93618
  try {
92723
- const parsed = JSON.parse(readFileSync40(path2, "utf8"));
93619
+ const parsed = JSON.parse(readFileSync41(path2, "utf8"));
92724
93620
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
92725
93621
  return parsed;
92726
93622
  } catch {
@@ -92744,13 +93640,13 @@ function currentDirs(settings) {
92744
93640
  return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
92745
93641
  }
92746
93642
  function writeSettings(path2, settings) {
92747
- mkdirSync11(dirname15(path2), { recursive: true });
92748
- writeFileSync29(path2, JSON.stringify(settings, null, 2) + "\n", "utf8");
93643
+ mkdirSync12(dirname15(path2), { recursive: true });
93644
+ writeFileSync30(path2, JSON.stringify(settings, null, 2) + "\n", "utf8");
92749
93645
  }
92750
93646
  function ensureClaudeMods(opts) {
92751
93647
  const env2 = opts.env ?? process.env;
92752
93648
  const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
92753
- const modsRoot = join47(opts.installRoot, "claude-mods");
93649
+ const modsRoot = join48(opts.installRoot, "claude-mods");
92754
93650
  if (off(env2)) {
92755
93651
  const settings2 = readSettings(settingsPath);
92756
93652
  if (!settings2) return { kind: "unreadable" };
@@ -92767,14 +93663,14 @@ function ensureClaudeMods(opts) {
92767
93663
  let changed = false;
92768
93664
  const installed = [];
92769
93665
  for (const name2 of names) {
92770
- const src = join47(bundleDir, name2);
92771
- const dest = join47(modsRoot, name2);
93666
+ const src = join48(bundleDir, name2);
93667
+ const dest = join48(modsRoot, name2);
92772
93668
  const hash2 = modHash(src);
92773
- const hashFile = join47(dest, HASH_FILE);
92774
- if (!existsSync38(hashFile) || readFileSync40(hashFile, "utf8") !== hash2) {
93669
+ const hashFile = join48(dest, HASH_FILE);
93670
+ if (!existsSync39(hashFile) || readFileSync41(hashFile, "utf8") !== hash2) {
92775
93671
  rmSync4(dest, { recursive: true, force: true });
92776
- cpSync2(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
92777
- writeFileSync29(hashFile, hash2, "utf8");
93672
+ cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
93673
+ writeFileSync30(hashFile, hash2, "utf8");
92778
93674
  changed = true;
92779
93675
  }
92780
93676
  installed.push(dest);
@@ -93195,9 +94091,9 @@ function resolveHookPort(explicit) {
93195
94091
  }
93196
94092
  }
93197
94093
  }
93198
- const settingsPath = join48(ROOT, ".claude", "settings.json");
94094
+ const settingsPath = join49(ROOT, ".claude", "settings.json");
93199
94095
  try {
93200
- if (existsSync39(settingsPath)) return installedHookPort(readFileSync41(settingsPath, "utf8")) ?? 7891;
94096
+ if (existsSync40(settingsPath)) return installedHookPort(readFileSync42(settingsPath, "utf8")) ?? 7891;
93201
94097
  } catch {
93202
94098
  }
93203
94099
  return 7891;
@@ -93222,14 +94118,14 @@ async function cmdInit() {
93222
94118
  if (!skipHooks) {
93223
94119
  console.log("");
93224
94120
  console.log("installing harness hooks...");
93225
- const { existsSync: existsSync40 } = await import("node:fs");
93226
- const { join: join49 } = await import("node:path");
94121
+ const { existsSync: existsSync41 } = await import("node:fs");
94122
+ const { join: join50 } = await import("node:path");
93227
94123
  try {
93228
94124
  await installClaudeHooks(port);
93229
94125
  } catch (err2) {
93230
94126
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
93231
94127
  }
93232
- if (existsSync40(join49(ROOT, ".cursor"))) {
94128
+ if (existsSync41(join50(ROOT, ".cursor"))) {
93233
94129
  try {
93234
94130
  await installCursorMcpConfig();
93235
94131
  } catch (err2) {
@@ -93444,9 +94340,9 @@ async function cmdStatus() {
93444
94340
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
93445
94341
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
93446
94342
  }
93447
- console.log(` graph db: ${existsSync39(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
93448
- console.log(` event log: ${existsSync39(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
93449
- if (existsSync39(paths.castalia)) {
94343
+ console.log(` graph db: ${existsSync40(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
94344
+ console.log(` event log: ${existsSync40(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
94345
+ if (existsSync40(paths.castalia)) {
93450
94346
  try {
93451
94347
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
93452
94348
  const store = openGraphStore2({ path: paths.castalia });
@@ -94440,11 +95336,11 @@ async function cmdInstallationProfile(args2) {
94440
95336
  }
94441
95337
  async function cmdReview() {
94442
95338
  const paths = workspacePaths(ROOT);
94443
- if (!existsSync39(paths.reviewQueue)) {
95339
+ if (!existsSync40(paths.reviewQueue)) {
94444
95340
  console.log("(review queue empty)");
94445
95341
  return;
94446
95342
  }
94447
- const queue = JSON.parse(readFileSync41(paths.reviewQueue, "utf8"));
95343
+ const queue = JSON.parse(readFileSync42(paths.reviewQueue, "utf8"));
94448
95344
  if (queue.length === 0) {
94449
95345
  console.log("(review queue empty)");
94450
95346
  return;
@@ -95115,7 +96011,7 @@ async function gatherRepo(store, ws) {
95115
96011
  };
95116
96012
  }
95117
96013
  async function gatherReportData(generatedAt) {
95118
- const { existsSync: existsSync40 } = await import("node:fs");
96014
+ const { existsSync: existsSync41 } = await import("node:fs");
95119
96015
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
95120
96016
  const cfg = loadConfig();
95121
96017
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -95123,7 +96019,7 @@ async function gatherReportData(generatedAt) {
95123
96019
  for (const ws of listWorkspaces()) {
95124
96020
  if (ws.missing) continue;
95125
96021
  const dbPath = workspacePaths(ws.path).castalia;
95126
- if (!existsSync40(dbPath)) continue;
96022
+ if (!existsSync41(dbPath)) continue;
95127
96023
  let store = null;
95128
96024
  try {
95129
96025
  store = openGraphStore2({ path: dbPath });
@@ -95154,7 +96050,7 @@ async function gatherReportData(generatedAt) {
95154
96050
  };
95155
96051
  }
95156
96052
  async function cmdReport(args2) {
95157
- const { mkdirSync: mkdirSync12, writeFileSync: writeFileSync30 } = await import("node:fs");
96053
+ const { mkdirSync: mkdirSync13, writeFileSync: writeFileSync31 } = await import("node:fs");
95158
96054
  const { renderReport: renderReport2 } = await Promise.resolve().then(() => (init_report_render(), report_render_exports));
95159
96055
  const includeFutureVerbs = args2.includes("--future-verbs");
95160
96056
  const now = /* @__PURE__ */ new Date();
@@ -95165,10 +96061,10 @@ async function cmdReport(args2) {
95165
96061
  process.exit(2);
95166
96062
  }
95167
96063
  const outDir = workspacePaths(ROOT).configDir;
95168
- mkdirSync12(outDir, { recursive: true });
96064
+ mkdirSync13(outDir, { recursive: true });
95169
96065
  const files = renderReport2(data, { includeFutureVerbs });
95170
- for (const f of files) writeFileSync30(join48(outDir, f.name), f.html, "utf8");
95171
- const indexPath = join48(outDir, "report.html");
96066
+ for (const f of files) writeFileSync31(join49(outDir, f.name), f.html, "utf8");
96067
+ const indexPath = join49(outDir, "report.html");
95172
96068
  console.log(`report \u2192 ${indexPath}`);
95173
96069
  console.log(
95174
96070
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -95224,7 +96120,7 @@ function spawnDaemonDetached(options = {}) {
95224
96120
  try {
95225
96121
  const logPath = daemonLogPath();
95226
96122
  try {
95227
- if (statSync12(logPath).size > 5 * 1024 * 1024) renameSync6(logPath, `${logPath}.1`);
96123
+ if (statSync12(logPath).size > 5 * 1024 * 1024) renameSync7(logPath, `${logPath}.1`);
95228
96124
  } catch {
95229
96125
  }
95230
96126
  out2 = openSync2(logPath, "a");
@@ -95293,24 +96189,24 @@ async function cmdInstallHooks(args2) {
95293
96189
  }
95294
96190
  }
95295
96191
  async function installOpencodePlugin(port) {
95296
- const { mkdirSync: mkdirSync12, existsSync: existsSync40, readFileSync: readFileSync42, writeFileSync: writeFileSync30 } = await import("node:fs");
95297
- const { join: join49 } = await import("node:path");
95298
- const dir = join49(ROOT, ".opencode", "plugin");
95299
- if (!existsSync40(dir)) mkdirSync12(dir, { recursive: true });
95300
- const file2 = join49(dir, "inerrata.js");
95301
- if (existsSync40(file2)) {
95302
- const head2 = readFileSync42(file2, "utf8").split("\n")[0] ?? "";
96192
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync43, writeFileSync: writeFileSync31 } = await import("node:fs");
96193
+ const { join: join50 } = await import("node:path");
96194
+ const dir = join50(ROOT, ".opencode", "plugin");
96195
+ if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
96196
+ const file2 = join50(dir, "inerrata.js");
96197
+ if (existsSync41(file2)) {
96198
+ const head2 = readFileSync43(file2, "utf8").split("\n")[0] ?? "";
95303
96199
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
95304
96200
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
95305
96201
  process.exit(2);
95306
96202
  }
95307
96203
  }
95308
- writeFileSync30(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
95309
- const cfgFile = join49(ROOT, "opencode.json");
96204
+ writeFileSync31(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
96205
+ const cfgFile = join50(ROOT, "opencode.json");
95310
96206
  let cfg = { $schema: "https://opencode.ai/config.json" };
95311
- if (existsSync40(cfgFile)) {
96207
+ if (existsSync41(cfgFile)) {
95312
96208
  try {
95313
- cfg = JSON.parse(readFileSync42(cfgFile, "utf8"));
96209
+ cfg = JSON.parse(readFileSync43(cfgFile, "utf8"));
95314
96210
  } catch {
95315
96211
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
95316
96212
  process.exit(2);
@@ -95321,7 +96217,7 @@ async function installOpencodePlugin(port) {
95321
96217
  if (!hadErrata) {
95322
96218
  const inv = errataMcpInvocation();
95323
96219
  cfg.mcp["errata"] = { type: "local", command: [inv.command, ...inv.args] };
95324
- writeFileSync30(cfgFile, JSON.stringify(cfg, null, 2) + "\n", "utf8");
96220
+ writeFileSync31(cfgFile, JSON.stringify(cfg, null, 2) + "\n", "utf8");
95325
96221
  }
95326
96222
  console.log(`installed OpenCode plugin \u2192 ${file2}`);
95327
96223
  if (hadErrata) console.log(` mcp.errata already present in ${cfgFile} \u2014 left untouched`);
@@ -95356,15 +96252,15 @@ function installClaudeMods() {
95356
96252
  }
95357
96253
  }
95358
96254
  async function installClaudeHooks(port) {
95359
- const { mkdirSync: mkdirSync12, existsSync: existsSync40, readFileSync: readFileSync42, writeFileSync: writeFileSync30 } = await import("node:fs");
95360
- const { join: join49 } = await import("node:path");
95361
- const dir = join49(ROOT, ".claude");
95362
- if (!existsSync40(dir)) mkdirSync12(dir, { recursive: true });
95363
- const file2 = join49(dir, "settings.json");
96255
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync43, writeFileSync: writeFileSync31 } = await import("node:fs");
96256
+ const { join: join50 } = await import("node:path");
96257
+ const dir = join50(ROOT, ".claude");
96258
+ if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
96259
+ const file2 = join50(dir, "settings.json");
95364
96260
  let settings = {};
95365
- if (existsSync40(file2)) {
96261
+ if (existsSync41(file2)) {
95366
96262
  try {
95367
- settings = JSON.parse(readFileSync42(file2, "utf8"));
96263
+ settings = JSON.parse(readFileSync43(file2, "utf8"));
95368
96264
  } catch {
95369
96265
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
95370
96266
  process.exit(2);
@@ -95413,12 +96309,12 @@ async function installClaudeHooks(port) {
95413
96309
  list.push({ hooks: [{ type: "command", command: injectCmd }] });
95414
96310
  }
95415
96311
  removeProjectStatusLine(settings);
95416
- writeFileSync30(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
96312
+ writeFileSync31(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
95417
96313
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
95418
96314
  console.log(` ${ensureStatusLine(port)}`);
95419
96315
  console.log(` ${installClaudeMods().line}`);
95420
96316
  await installClaudeMcpConfig();
95421
- const claudeMd = join49(ROOT, "CLAUDE.md");
96317
+ const claudeMd = join50(ROOT, "CLAUDE.md");
95422
96318
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
95423
96319
  if (recall.kind === "collision") {
95424
96320
  console.warn(
@@ -95430,15 +96326,15 @@ async function installClaudeHooks(port) {
95430
96326
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
95431
96327
  }
95432
96328
  async function installClaudeMcpConfig() {
95433
- const { mkdirSync: mkdirSync12, existsSync: existsSync40, readFileSync: readFileSync42, writeFileSync: writeFileSync30 } = await import("node:fs");
95434
- const { join: join49, dirname: dirname16 } = await import("node:path");
95435
- const file2 = join49(ROOT, ".mcp.json");
96329
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync43, writeFileSync: writeFileSync31 } = await import("node:fs");
96330
+ const { join: join50, dirname: dirname16 } = await import("node:path");
96331
+ const file2 = join50(ROOT, ".mcp.json");
95436
96332
  const dir = dirname16(file2);
95437
- if (!existsSync40(dir)) mkdirSync12(dir, { recursive: true });
96333
+ if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
95438
96334
  let cfg = {};
95439
- if (existsSync40(file2)) {
96335
+ if (existsSync41(file2)) {
95440
96336
  try {
95441
- cfg = JSON.parse(readFileSync42(file2, "utf8"));
96337
+ cfg = JSON.parse(readFileSync43(file2, "utf8"));
95442
96338
  } catch {
95443
96339
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
95444
96340
  process.exit(2);
@@ -95446,21 +96342,21 @@ async function installClaudeMcpConfig() {
95446
96342
  }
95447
96343
  cfg.mcpServers ??= {};
95448
96344
  cfg.mcpServers["errata"] = errataMcpInvocation();
95449
- writeFileSync30(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
96345
+ writeFileSync31(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
95450
96346
  console.log(`installed Claude Code MCP server config \u2192 ${file2}`);
95451
96347
  console.log(` Claude Code will spawn \`errata mcp\` on workspace open.`);
95452
96348
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
95453
96349
  }
95454
96350
  async function installCursorMcpConfig() {
95455
- const { mkdirSync: mkdirSync12, existsSync: existsSync40, readFileSync: readFileSync42, writeFileSync: writeFileSync30 } = await import("node:fs");
95456
- const { join: join49 } = await import("node:path");
95457
- const dir = join49(ROOT, ".cursor");
95458
- if (!existsSync40(dir)) mkdirSync12(dir, { recursive: true });
95459
- const file2 = join49(dir, "mcp.json");
96351
+ const { mkdirSync: mkdirSync13, existsSync: existsSync41, readFileSync: readFileSync43, writeFileSync: writeFileSync31 } = await import("node:fs");
96352
+ const { join: join50 } = await import("node:path");
96353
+ const dir = join50(ROOT, ".cursor");
96354
+ if (!existsSync41(dir)) mkdirSync13(dir, { recursive: true });
96355
+ const file2 = join50(dir, "mcp.json");
95460
96356
  let cfg = {};
95461
- if (existsSync40(file2)) {
96357
+ if (existsSync41(file2)) {
95462
96358
  try {
95463
- cfg = JSON.parse(readFileSync42(file2, "utf8"));
96359
+ cfg = JSON.parse(readFileSync43(file2, "utf8"));
95464
96360
  } catch {
95465
96361
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
95466
96362
  process.exit(2);
@@ -95468,7 +96364,7 @@ async function installCursorMcpConfig() {
95468
96364
  }
95469
96365
  cfg.mcpServers ??= {};
95470
96366
  cfg.mcpServers["errata"] = errataMcpInvocation();
95471
- writeFileSync30(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
96367
+ writeFileSync31(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
95472
96368
  console.log(`installed Cursor MCP server config \u2192 ${file2}`);
95473
96369
  console.log(` Cursor will spawn \`errata mcp\` on workspace open.`);
95474
96370
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses`);
@@ -95479,11 +96375,14 @@ async function installCodexHooks(port) {
95479
96375
  const gitRoot = nearestGitRoot(process.cwd());
95480
96376
  const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
95481
96377
  const file2 = writeCodexHooks(hookRoot, port);
95482
- const instructions = writeManagedBlock(join48(hookRoot, "AGENTS.md"), {
96378
+ const instructions = writeManagedBlock(join49(hookRoot, "AGENTS.md"), {
95483
96379
  body: AGENTS_POINTER_BODY,
95484
96380
  stable: true
95485
96381
  });
95486
96382
  console.log(`installed Codex hooks \u2192 ${file2}`);
96383
+ const panel = installCodexContextPlugin(hookRoot);
96384
+ console.log(`installed Errata Context plugin \u2192 ${panel.plugin}`);
96385
+ console.log(panel.enabled ? " Codex will load the panel on its next marketplace refresh; reopen the app if it is already running." : " Errata Context remains disabled by your existing plugin settings.");
95487
96386
  if (instructions.kind === "collision") {
95488
96387
  console.warn(" AGENTS.md's Errata block was edited; preserved it. Add an explicit instruction to read .errata/context.md each turn.");
95489
96388
  } else {
@@ -95509,6 +96408,13 @@ function refreshExistingCodexHooks() {
95509
96408
  if (result.status === "error") {
95510
96409
  ok = false;
95511
96410
  console.warn(`Codex relay refresh needs attention in ${result.root}: ${result.detail}`);
96411
+ } else {
96412
+ try {
96413
+ if (refreshCodexContextPlugin(result.root)) console.log(`updated existing Errata Context plugin \u2192 ${result.root}`);
96414
+ } catch (error48) {
96415
+ ok = false;
96416
+ console.warn(`Errata Context refresh needs attention in ${result.root}: ${error48 instanceof Error ? error48.message : error48}`);
96417
+ }
95512
96418
  }
95513
96419
  }
95514
96420
  return ok;
@@ -95915,9 +96821,9 @@ async function cmdDash(args2) {
95915
96821
  await yieldToLoop2();
95916
96822
  try {
95917
96823
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
95918
- atCommit: readGitRefState(join48(r.root, ".git")).sha ?? void 0
96824
+ atCommit: readGitRefState(join49(r.root, ".git")).sha ?? void 0
95919
96825
  });
95920
- const res = bleedRules(join48(r.root, ".claude", "rules"), items);
96826
+ const res = bleedRules(join49(r.root, ".claude", "rules"), items);
95921
96827
  if (res.written || res.pruned) {
95922
96828
  console.log(
95923
96829
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")
@@ -96160,4 +97066,41 @@ undici/lib/web/websocket/frame.js:
96160
97066
 
96161
97067
  chokidar/esm/index.js:
96162
97068
  (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
97069
+
97070
+ smol-toml/dist/error.js:
97071
+ smol-toml/dist/util.js:
97072
+ smol-toml/dist/date.js:
97073
+ smol-toml/dist/primitive.js:
97074
+ smol-toml/dist/extract.js:
97075
+ smol-toml/dist/struct.js:
97076
+ smol-toml/dist/parse.js:
97077
+ smol-toml/dist/stringify.js:
97078
+ smol-toml/dist/index.js:
97079
+ (*!
97080
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
97081
+ * SPDX-License-Identifier: BSD-3-Clause
97082
+ *
97083
+ * Redistribution and use in source and binary forms, with or without
97084
+ * modification, are permitted provided that the following conditions are met:
97085
+ *
97086
+ * 1. Redistributions of source code must retain the above copyright notice, this
97087
+ * list of conditions and the following disclaimer.
97088
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
97089
+ * this list of conditions and the following disclaimer in the
97090
+ * documentation and/or other materials provided with the distribution.
97091
+ * 3. Neither the name of the copyright holder nor the names of its contributors
97092
+ * may be used to endorse or promote products derived from this software without
97093
+ * specific prior written permission.
97094
+ *
97095
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
97096
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
97097
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
97098
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
97099
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
97100
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
97101
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
97102
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
97103
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
97104
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
97105
+ *)
96163
97106
  */