@event4u/agent-config 14.13.0 → 14.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +116 -387
  5. package/dist/agent-src/commands/analyze/inbox.md +36 -0
  6. package/dist/agent-src/rules/code-comment-discipline.md +6 -0
  7. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +6 -6
  8. package/dist/agent-src/scripts/guarded_baseline.ts +22 -7
  9. package/dist/agent-src/scripts/stubs_due.ts +118 -2
  10. package/dist/agent-src/scripts/update_roadmap_progress.ts +8 -8
  11. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  12. package/dist/cli-delegate/cmd_conformance.js +38 -1
  13. package/dist/discovery/deprecation-report.md +1 -1
  14. package/dist/discovery/discovery-manifest.json +4 -4
  15. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  16. package/dist/discovery/discovery-manifest.summary.md +1 -1
  17. package/dist/discovery/dormancy-report.md +1 -1
  18. package/dist/discovery/orphan-report.md +1 -1
  19. package/dist/discovery/packs.json +2 -2
  20. package/dist/discovery/trust-report.md +1 -1
  21. package/dist/discovery/workspaces.json +2 -2
  22. package/dist/hooks/dispatch.js +1438 -711
  23. package/dist/mcp/registry-manifest.json +2 -2
  24. package/dist/mcp/server.json +2 -2
  25. package/dist/mcp/server.mjs +112 -17
  26. package/docs/guidelines/agent-infra/guarded-baseline.md +1 -1
  27. package/docs/guidelines/code-clarity.md +18 -0
  28. package/package.json +1 -1
  29. package/src/agent-src/scripts/archive_completed_roadmaps.ts +6 -6
  30. package/src/agent-src/scripts/guarded_baseline.ts +22 -7
  31. package/src/agent-src/scripts/stubs_due.ts +118 -2
  32. package/src/agent-src/scripts/update_roadmap_progress.ts +8 -8
  33. package/src/config/estate-count-budget.json +20 -1
  34. package/src/config/gate-coverage.yml +150 -0
  35. package/src/config/gate-violation-baselines.json +8 -3
  36. package/src/config/preamble-payload-budget.json +19 -11
  37. package/src/config/rule-stub-ceilings.json +14 -7
  38. package/src/scripts/_dispatch.bash +0 -4
  39. package/src/scripts/_lib/activation_ladder.ts +47 -3
  40. package/src/scripts/_lib/activation_receipt_producer.ts +341 -0
  41. package/src/scripts/_lib/adr_frontmatter.ts +26 -0
  42. package/src/scripts/_lib/candidate_pair_delta.ts +349 -0
  43. package/src/scripts/_lib/carrier_status.ts +118 -0
  44. package/src/scripts/_lib/cascade_stage_enumeration.ts +92 -0
  45. package/src/scripts/_lib/corpus_manifest.ts +726 -0
  46. package/src/scripts/_lib/delivery_arm_experiment.ts +18 -2
  47. package/src/scripts/_lib/estate_carrier_cases.ts +72 -0
  48. package/src/scripts/_lib/evaluation_cascade.ts +452 -0
  49. package/src/scripts/_lib/evolution_roi.ts +562 -0
  50. package/src/scripts/_lib/harness_evolution_guards.ts +10 -0
  51. package/src/scripts/_lib/lexical_shortlist.ts +215 -0
  52. package/src/scripts/_lib/llm_candidate_proposer.ts +461 -0
  53. package/src/scripts/_lib/llm_proposer_transport.ts +153 -0
  54. package/src/scripts/_lib/pathology_archive.ts +393 -0
  55. package/src/scripts/_lib/promotion_capability.ts +315 -0
  56. package/src/scripts/_lib/promotion_evidence.ts +414 -0
  57. package/src/scripts/_lib/promotion_review.ts +294 -0
  58. package/src/scripts/_lib/prompt_shape.ts +92 -0
  59. package/src/scripts/_lib/release_highlights.ts +70 -1
  60. package/src/scripts/_lib/release_material.ts +125 -2
  61. package/src/scripts/_lib/routing_corpus.ts +307 -0
  62. package/src/scripts/_lib/routing_index_input.ts +104 -0
  63. package/src/scripts/_lib/rule_injection.ts +22 -1
  64. package/src/scripts/_lib/semantic_noop.ts +167 -0
  65. package/src/scripts/activation_receipt.ts +258 -0
  66. package/src/scripts/ai_council/cross_exam.ts +128 -0
  67. package/src/scripts/ai_council/explain_route.ts +157 -0
  68. package/src/scripts/ai_council/information_gain.ts +293 -0
  69. package/src/scripts/ai_council/leakage_corpus.ts +385 -0
  70. package/src/scripts/ai_council/leakage_patterns.ts +453 -0
  71. package/src/scripts/ai_council/minority_retention.ts +171 -0
  72. package/src/scripts/ai_council/recouncil_savings.ts +299 -0
  73. package/src/scripts/ai_council/replay_route.ts +223 -0
  74. package/src/scripts/ai_council/reviewer_assignment.ts +279 -0
  75. package/src/scripts/ai_council/routing_training_row.ts +197 -0
  76. package/src/scripts/ai_council/synthesis_strategy.ts +159 -0
  77. package/src/scripts/check_adr_frontmatter.ts +4 -9
  78. package/src/scripts/check_estate_count.ts +205 -24
  79. package/src/scripts/check_release_highlights.ts +96 -13
  80. package/src/scripts/check_roadmap_trackable.ts +17 -2
  81. package/src/scripts/corpus_manifest.ts +235 -0
  82. package/src/scripts/evolution_lab.ts +181 -8
  83. package/src/scripts/hook_manifest.json +1 -1
  84. package/src/scripts/hook_manifest.yaml +28 -6
  85. package/src/scripts/hooks/comment_discipline_hook.ts +146 -0
  86. package/src/scripts/hooks/concern_registry.ts +2 -0
  87. package/src/scripts/hooks/turn_end_gate_hook.ts +9 -1
  88. package/src/scripts/language_mirror_hook.ts +14 -2
  89. package/src/scripts/lint_carrier_integrity.ts +820 -0
  90. package/src/scripts/lint_code_comments.ts +643 -0
  91. package/src/scripts/lint_plan_risk_register.ts +39 -19
  92. package/src/scripts/lint_promotion_paths.ts +779 -0
  93. package/src/scripts/llm_propose.ts +256 -0
  94. package/src/scripts/measure_delivery_sets.ts +361 -0
  95. package/src/scripts/measure_routing_signal.ts +307 -0
  96. package/src/scripts/model_rule_injection.ts +19 -3
  97. package/src/scripts/probe_council_retention.ts +495 -0
  98. package/src/scripts/release.ts +21 -37
  99. package/src/scripts/release_drill.ts +143 -0
  100. package/src/scripts/release_env.ts +35 -0
  101. package/src/scripts/release_publication.ts +84 -0
@@ -112,17 +112,17 @@ var require_visit = __commonJS({
112
112
  visit.BREAK = BREAK;
113
113
  visit.SKIP = SKIP;
114
114
  visit.REMOVE = REMOVE;
115
- function visit_(key, node, visitor, path102) {
116
- const ctrl = callVisitor(key, node, visitor, path102);
115
+ function visit_(key, node, visitor, path105) {
116
+ const ctrl = callVisitor(key, node, visitor, path105);
117
117
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
118
- replaceNode(key, path102, ctrl);
119
- return visit_(key, ctrl, visitor, path102);
118
+ replaceNode(key, path105, ctrl);
119
+ return visit_(key, ctrl, visitor, path105);
120
120
  }
121
121
  if (typeof ctrl !== "symbol") {
122
122
  if (identity.isCollection(node)) {
123
- path102 = Object.freeze(path102.concat(node));
123
+ path105 = Object.freeze(path105.concat(node));
124
124
  for (let i = 0; i < node.items.length; ++i) {
125
- const ci = visit_(i, node.items[i], visitor, path102);
125
+ const ci = visit_(i, node.items[i], visitor, path105);
126
126
  if (typeof ci === "number")
127
127
  i = ci - 1;
128
128
  else if (ci === BREAK)
@@ -133,13 +133,13 @@ var require_visit = __commonJS({
133
133
  }
134
134
  }
135
135
  } else if (identity.isPair(node)) {
136
- path102 = Object.freeze(path102.concat(node));
137
- const ck = visit_("key", node.key, visitor, path102);
136
+ path105 = Object.freeze(path105.concat(node));
137
+ const ck = visit_("key", node.key, visitor, path105);
138
138
  if (ck === BREAK)
139
139
  return BREAK;
140
140
  else if (ck === REMOVE)
141
141
  node.key = null;
142
- const cv = visit_("value", node.value, visitor, path102);
142
+ const cv = visit_("value", node.value, visitor, path105);
143
143
  if (cv === BREAK)
144
144
  return BREAK;
145
145
  else if (cv === REMOVE)
@@ -160,17 +160,17 @@ var require_visit = __commonJS({
160
160
  visitAsync.BREAK = BREAK;
161
161
  visitAsync.SKIP = SKIP;
162
162
  visitAsync.REMOVE = REMOVE;
163
- async function visitAsync_(key, node, visitor, path102) {
164
- const ctrl = await callVisitor(key, node, visitor, path102);
163
+ async function visitAsync_(key, node, visitor, path105) {
164
+ const ctrl = await callVisitor(key, node, visitor, path105);
165
165
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
166
- replaceNode(key, path102, ctrl);
167
- return visitAsync_(key, ctrl, visitor, path102);
166
+ replaceNode(key, path105, ctrl);
167
+ return visitAsync_(key, ctrl, visitor, path105);
168
168
  }
169
169
  if (typeof ctrl !== "symbol") {
170
170
  if (identity.isCollection(node)) {
171
- path102 = Object.freeze(path102.concat(node));
171
+ path105 = Object.freeze(path105.concat(node));
172
172
  for (let i = 0; i < node.items.length; ++i) {
173
- const ci = await visitAsync_(i, node.items[i], visitor, path102);
173
+ const ci = await visitAsync_(i, node.items[i], visitor, path105);
174
174
  if (typeof ci === "number")
175
175
  i = ci - 1;
176
176
  else if (ci === BREAK)
@@ -181,13 +181,13 @@ var require_visit = __commonJS({
181
181
  }
182
182
  }
183
183
  } else if (identity.isPair(node)) {
184
- path102 = Object.freeze(path102.concat(node));
185
- const ck = await visitAsync_("key", node.key, visitor, path102);
184
+ path105 = Object.freeze(path105.concat(node));
185
+ const ck = await visitAsync_("key", node.key, visitor, path105);
186
186
  if (ck === BREAK)
187
187
  return BREAK;
188
188
  else if (ck === REMOVE)
189
189
  node.key = null;
190
- const cv = await visitAsync_("value", node.value, visitor, path102);
190
+ const cv = await visitAsync_("value", node.value, visitor, path105);
191
191
  if (cv === BREAK)
192
192
  return BREAK;
193
193
  else if (cv === REMOVE)
@@ -214,23 +214,23 @@ var require_visit = __commonJS({
214
214
  }
215
215
  return visitor;
216
216
  }
217
- function callVisitor(key, node, visitor, path102) {
217
+ function callVisitor(key, node, visitor, path105) {
218
218
  if (typeof visitor === "function")
219
- return visitor(key, node, path102);
219
+ return visitor(key, node, path105);
220
220
  if (identity.isMap(node))
221
- return visitor.Map?.(key, node, path102);
221
+ return visitor.Map?.(key, node, path105);
222
222
  if (identity.isSeq(node))
223
- return visitor.Seq?.(key, node, path102);
223
+ return visitor.Seq?.(key, node, path105);
224
224
  if (identity.isPair(node))
225
- return visitor.Pair?.(key, node, path102);
225
+ return visitor.Pair?.(key, node, path105);
226
226
  if (identity.isScalar(node))
227
- return visitor.Scalar?.(key, node, path102);
227
+ return visitor.Scalar?.(key, node, path105);
228
228
  if (identity.isAlias(node))
229
- return visitor.Alias?.(key, node, path102);
229
+ return visitor.Alias?.(key, node, path105);
230
230
  return void 0;
231
231
  }
232
- function replaceNode(key, path102, node) {
233
- const parent = path102[path102.length - 1];
232
+ function replaceNode(key, path105, node) {
233
+ const parent = path105[path105.length - 1];
234
234
  if (identity.isCollection(parent)) {
235
235
  parent.items[key] = node;
236
236
  } else if (identity.isPair(parent)) {
@@ -840,10 +840,10 @@ var require_Collection = __commonJS({
840
840
  var createNode = require_createNode();
841
841
  var identity = require_identity();
842
842
  var Node = require_Node();
843
- function collectionFromPath(schema, path102, value) {
843
+ function collectionFromPath(schema, path105, value) {
844
844
  let v = value;
845
- for (let i = path102.length - 1; i >= 0; --i) {
846
- const k = path102[i];
845
+ for (let i = path105.length - 1; i >= 0; --i) {
846
+ const k = path105[i];
847
847
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
848
848
  const a = [];
849
849
  a[k] = v;
@@ -862,7 +862,7 @@ var require_Collection = __commonJS({
862
862
  sourceObjects: /* @__PURE__ */ new Map()
863
863
  });
864
864
  }
865
- var isEmptyPath = (path102) => path102 == null || typeof path102 === "object" && !!path102[Symbol.iterator]().next().done;
865
+ var isEmptyPath = (path105) => path105 == null || typeof path105 === "object" && !!path105[Symbol.iterator]().next().done;
866
866
  var Collection = class extends Node.NodeBase {
867
867
  constructor(type, schema) {
868
868
  super(type);
@@ -892,11 +892,11 @@ var require_Collection = __commonJS({
892
892
  * be a Pair instance or a `{ key, value }` object, which may not have a key
893
893
  * that already exists in the map.
894
894
  */
895
- addIn(path102, value) {
896
- if (isEmptyPath(path102))
895
+ addIn(path105, value) {
896
+ if (isEmptyPath(path105))
897
897
  this.add(value);
898
898
  else {
899
- const [key, ...rest] = path102;
899
+ const [key, ...rest] = path105;
900
900
  const node = this.get(key, true);
901
901
  if (identity.isCollection(node))
902
902
  node.addIn(rest, value);
@@ -910,8 +910,8 @@ var require_Collection = __commonJS({
910
910
  * Removes a value from the collection.
911
911
  * @returns `true` if the item was found and removed.
912
912
  */
913
- deleteIn(path102) {
914
- const [key, ...rest] = path102;
913
+ deleteIn(path105) {
914
+ const [key, ...rest] = path105;
915
915
  if (rest.length === 0)
916
916
  return this.delete(key);
917
917
  const node = this.get(key, true);
@@ -925,8 +925,8 @@ var require_Collection = __commonJS({
925
925
  * scalar values from their surrounding node; to disable set `keepScalar` to
926
926
  * `true` (collections are always returned intact).
927
927
  */
928
- getIn(path102, keepScalar) {
929
- const [key, ...rest] = path102;
928
+ getIn(path105, keepScalar) {
929
+ const [key, ...rest] = path105;
930
930
  const node = this.get(key, true);
931
931
  if (rest.length === 0)
932
932
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -944,8 +944,8 @@ var require_Collection = __commonJS({
944
944
  /**
945
945
  * Checks if the collection includes a value with the key `key`.
946
946
  */
947
- hasIn(path102) {
948
- const [key, ...rest] = path102;
947
+ hasIn(path105) {
948
+ const [key, ...rest] = path105;
949
949
  if (rest.length === 0)
950
950
  return this.has(key);
951
951
  const node = this.get(key, true);
@@ -955,8 +955,8 @@ var require_Collection = __commonJS({
955
955
  * Sets a value in this collection. For `!!set`, `value` needs to be a
956
956
  * boolean to add/remove the item from the set.
957
957
  */
958
- setIn(path102, value) {
959
- const [key, ...rest] = path102;
958
+ setIn(path105, value) {
959
+ const [key, ...rest] = path105;
960
960
  if (rest.length === 0) {
961
961
  this.set(key, value);
962
962
  } else {
@@ -980,13 +980,13 @@ var require_Collection = __commonJS({
980
980
  var require_stringifyComment = __commonJS({
981
981
  "node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
982
982
  "use strict";
983
- var stringifyComment = (str15) => str15.replace(/^(?!$)(?: $)?/gm, "#");
983
+ var stringifyComment = (str16) => str16.replace(/^(?!$)(?: $)?/gm, "#");
984
984
  function indentComment(comment, indent) {
985
985
  if (/^\n+$/.test(comment))
986
986
  return comment.substring(1);
987
987
  return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
988
988
  }
989
- var lineComment = (str15, indent, comment) => str15.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str15.endsWith(" ") ? "" : " ") + comment;
989
+ var lineComment = (str16, indent, comment) => str16.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str16.endsWith(" ") ? "" : " ") + comment;
990
990
  exports.indentComment = indentComment;
991
991
  exports.lineComment = lineComment;
992
992
  exports.stringifyComment = stringifyComment;
@@ -1140,16 +1140,16 @@ var require_stringifyString = __commonJS({
1140
1140
  lineWidth: ctx.options.lineWidth,
1141
1141
  minContentWidth: ctx.options.minContentWidth
1142
1142
  });
1143
- var containsDocumentMarker = (str15) => /^(%|---|\.\.\.)/m.test(str15);
1144
- function lineLengthOverLimit(str15, lineWidth, indentLength) {
1143
+ var containsDocumentMarker = (str16) => /^(%|---|\.\.\.)/m.test(str16);
1144
+ function lineLengthOverLimit(str16, lineWidth, indentLength) {
1145
1145
  if (!lineWidth || lineWidth < 0)
1146
1146
  return false;
1147
1147
  const limit = lineWidth - indentLength;
1148
- const strLen = str15.length;
1148
+ const strLen = str16.length;
1149
1149
  if (strLen <= limit)
1150
1150
  return false;
1151
1151
  for (let i = 0, start = 0; i < strLen; ++i) {
1152
- if (str15[i] === "\n") {
1152
+ if (str16[i] === "\n") {
1153
1153
  if (i - start > limit)
1154
1154
  return true;
1155
1155
  start = i + 1;
@@ -1166,11 +1166,11 @@ var require_stringifyString = __commonJS({
1166
1166
  const { implicitKey } = ctx;
1167
1167
  const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
1168
1168
  const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
1169
- let str15 = "";
1169
+ let str16 = "";
1170
1170
  let start = 0;
1171
1171
  for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
1172
1172
  if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") {
1173
- str15 += json.slice(start, i) + "\\ ";
1173
+ str16 += json.slice(start, i) + "\\ ";
1174
1174
  i += 1;
1175
1175
  start = i;
1176
1176
  ch = "\\";
@@ -1179,38 +1179,38 @@ var require_stringifyString = __commonJS({
1179
1179
  switch (json[i + 1]) {
1180
1180
  case "u":
1181
1181
  {
1182
- str15 += json.slice(start, i);
1182
+ str16 += json.slice(start, i);
1183
1183
  const code = json.substr(i + 2, 4);
1184
1184
  switch (code) {
1185
1185
  case "0000":
1186
- str15 += "\\0";
1186
+ str16 += "\\0";
1187
1187
  break;
1188
1188
  case "0007":
1189
- str15 += "\\a";
1189
+ str16 += "\\a";
1190
1190
  break;
1191
1191
  case "000b":
1192
- str15 += "\\v";
1192
+ str16 += "\\v";
1193
1193
  break;
1194
1194
  case "001b":
1195
- str15 += "\\e";
1195
+ str16 += "\\e";
1196
1196
  break;
1197
1197
  case "0085":
1198
- str15 += "\\N";
1198
+ str16 += "\\N";
1199
1199
  break;
1200
1200
  case "00a0":
1201
- str15 += "\\_";
1201
+ str16 += "\\_";
1202
1202
  break;
1203
1203
  case "2028":
1204
- str15 += "\\L";
1204
+ str16 += "\\L";
1205
1205
  break;
1206
1206
  case "2029":
1207
- str15 += "\\P";
1207
+ str16 += "\\P";
1208
1208
  break;
1209
1209
  default:
1210
1210
  if (code.substr(0, 2) === "00")
1211
- str15 += "\\x" + code.substr(2);
1211
+ str16 += "\\x" + code.substr(2);
1212
1212
  else
1213
- str15 += json.substr(i, 6);
1213
+ str16 += json.substr(i, 6);
1214
1214
  }
1215
1215
  i += 5;
1216
1216
  start = i + 1;
@@ -1220,14 +1220,14 @@ var require_stringifyString = __commonJS({
1220
1220
  if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
1221
1221
  i += 1;
1222
1222
  } else {
1223
- str15 += json.slice(start, i) + "\n\n";
1223
+ str16 += json.slice(start, i) + "\n\n";
1224
1224
  while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') {
1225
- str15 += "\n";
1225
+ str16 += "\n";
1226
1226
  i += 2;
1227
1227
  }
1228
- str15 += indent;
1228
+ str16 += indent;
1229
1229
  if (json[i + 2] === " ")
1230
- str15 += "\\";
1230
+ str16 += "\\";
1231
1231
  i += 1;
1232
1232
  start = i + 1;
1233
1233
  }
@@ -1236,8 +1236,8 @@ var require_stringifyString = __commonJS({
1236
1236
  i += 1;
1237
1237
  }
1238
1238
  }
1239
- str15 = start ? str15 + json.slice(start) : json;
1240
- return implicitKey ? str15 : foldFlowLines.foldFlowLines(str15, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
1239
+ str16 = start ? str16 + json.slice(start) : json;
1240
+ return implicitKey ? str16 : foldFlowLines.foldFlowLines(str16, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
1241
1241
  }
1242
1242
  function singleQuotedString(value, ctx) {
1243
1243
  if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
@@ -1365,15 +1365,15 @@ ${indent}${start}${value}${end}`;
1365
1365
  return quotedString(value, ctx);
1366
1366
  }
1367
1367
  }
1368
- const str15 = value.replace(/\n+/g, `$&
1368
+ const str16 = value.replace(/\n+/g, `$&
1369
1369
  ${indent}`);
1370
1370
  if (actualString) {
1371
- const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str15);
1371
+ const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str16);
1372
1372
  const { compat, tags } = ctx.doc.schema;
1373
1373
  if (tags.some(test) || compat?.some(test))
1374
1374
  return quotedString(value, ctx);
1375
1375
  }
1376
- return implicitKey ? str15 : foldFlowLines.foldFlowLines(str15, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
1376
+ return implicitKey ? str16 : foldFlowLines.foldFlowLines(str16, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
1377
1377
  }
1378
1378
  function stringifyString(item, ctx, onComment, onChompKeep) {
1379
1379
  const { implicitKey, inFlow } = ctx;
@@ -1525,11 +1525,11 @@ var require_stringify = __commonJS({
1525
1525
  const props = stringifyProps(node, tagObj, ctx);
1526
1526
  if (props.length > 0)
1527
1527
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
1528
- const str15 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
1528
+ const str16 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
1529
1529
  if (!props)
1530
- return str15;
1531
- return identity.isScalar(node) || str15[0] === "{" || str15[0] === "[" ? `${props} ${str15}` : `${props}
1532
- ${ctx.indent}${str15}`;
1530
+ return str16;
1531
+ return identity.isScalar(node) || str16[0] === "{" || str16[0] === "[" ? `${props} ${str16}` : `${props}
1532
+ ${ctx.indent}${str16}`;
1533
1533
  }
1534
1534
  exports.createStringifyContext = createStringifyContext;
1535
1535
  exports.stringify = stringify;
@@ -1564,8 +1564,8 @@ var require_stringifyPair = __commonJS({
1564
1564
  });
1565
1565
  let keyCommentDone = false;
1566
1566
  let chompKeep = false;
1567
- let str15 = stringify.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
1568
- if (!explicitKey && !ctx.inFlow && str15.length > 1024) {
1567
+ let str16 = stringify.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
1568
+ if (!explicitKey && !ctx.inFlow && str16.length > 1024) {
1569
1569
  if (simpleKeys)
1570
1570
  throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
1571
1571
  explicitKey = true;
@@ -1574,27 +1574,27 @@ var require_stringifyPair = __commonJS({
1574
1574
  if (allNullValues || value == null) {
1575
1575
  if (keyCommentDone && onComment)
1576
1576
  onComment();
1577
- return str15 === "" ? "?" : explicitKey ? `? ${str15}` : str15;
1577
+ return str16 === "" ? "?" : explicitKey ? `? ${str16}` : str16;
1578
1578
  }
1579
1579
  } else if (allNullValues && !simpleKeys || value == null && explicitKey) {
1580
- str15 = `? ${str15}`;
1580
+ str16 = `? ${str16}`;
1581
1581
  if (keyComment && !keyCommentDone) {
1582
- str15 += stringifyComment.lineComment(str15, ctx.indent, commentString(keyComment));
1582
+ str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
1583
1583
  } else if (chompKeep && onChompKeep)
1584
1584
  onChompKeep();
1585
- return str15;
1585
+ return str16;
1586
1586
  }
1587
1587
  if (keyCommentDone)
1588
1588
  keyComment = null;
1589
1589
  if (explicitKey) {
1590
1590
  if (keyComment)
1591
- str15 += stringifyComment.lineComment(str15, ctx.indent, commentString(keyComment));
1592
- str15 = `? ${str15}
1591
+ str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
1592
+ str16 = `? ${str16}
1593
1593
  ${indent}:`;
1594
1594
  } else {
1595
- str15 = `${str15}:`;
1595
+ str16 = `${str16}:`;
1596
1596
  if (keyComment)
1597
- str15 += stringifyComment.lineComment(str15, ctx.indent, commentString(keyComment));
1597
+ str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
1598
1598
  }
1599
1599
  let vsb, vcb, valueComment;
1600
1600
  if (identity.isNode(value)) {
@@ -1610,7 +1610,7 @@ ${indent}:`;
1610
1610
  }
1611
1611
  ctx.implicitKey = false;
1612
1612
  if (!explicitKey && !keyComment && identity.isScalar(value))
1613
- ctx.indentAtStart = str15.length + 1;
1613
+ ctx.indentAtStart = str16.length + 1;
1614
1614
  chompKeep = false;
1615
1615
  if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
1616
1616
  ctx.indent = ctx.indent.substring(2);
@@ -1654,16 +1654,16 @@ ${ctx.indent}`;
1654
1654
  } else if (valueStr === "" || valueStr[0] === "\n") {
1655
1655
  ws = "";
1656
1656
  }
1657
- str15 += ws + valueStr;
1657
+ str16 += ws + valueStr;
1658
1658
  if (ctx.inFlow) {
1659
1659
  if (valueCommentDone && onComment)
1660
1660
  onComment();
1661
1661
  } else if (valueComment && !valueCommentDone) {
1662
- str15 += stringifyComment.lineComment(str15, ctx.indent, commentString(valueComment));
1662
+ str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(valueComment));
1663
1663
  } else if (chompKeep && onChompKeep) {
1664
1664
  onChompKeep();
1665
1665
  }
1666
- return str15;
1666
+ return str16;
1667
1667
  }
1668
1668
  exports.stringifyPair = stringifyPair;
1669
1669
  }
@@ -1890,31 +1890,31 @@ var require_stringifyCollection = __commonJS({
1890
1890
  }
1891
1891
  }
1892
1892
  chompKeep = false;
1893
- let str16 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
1893
+ let str17 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
1894
1894
  if (comment2)
1895
- str16 += stringifyComment.lineComment(str16, itemIndent, commentString(comment2));
1895
+ str17 += stringifyComment.lineComment(str17, itemIndent, commentString(comment2));
1896
1896
  if (chompKeep && comment2)
1897
1897
  chompKeep = false;
1898
- lines.push(blockItemPrefix + str16);
1898
+ lines.push(blockItemPrefix + str17);
1899
1899
  }
1900
- let str15;
1900
+ let str16;
1901
1901
  if (lines.length === 0) {
1902
- str15 = flowChars.start + flowChars.end;
1902
+ str16 = flowChars.start + flowChars.end;
1903
1903
  } else {
1904
- str15 = lines[0];
1904
+ str16 = lines[0];
1905
1905
  for (let i = 1; i < lines.length; ++i) {
1906
1906
  const line = lines[i];
1907
- str15 += line ? `
1907
+ str16 += line ? `
1908
1908
  ${indent}${line}` : "\n";
1909
1909
  }
1910
1910
  }
1911
1911
  if (comment) {
1912
- str15 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
1912
+ str16 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
1913
1913
  if (onComment)
1914
1914
  onComment();
1915
1915
  } else if (chompKeep && onChompKeep)
1916
1916
  onChompKeep();
1917
- return str15;
1917
+ return str16;
1918
1918
  }
1919
1919
  function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
1920
1920
  const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
@@ -1957,21 +1957,21 @@ ${indent}${line}` : "\n";
1957
1957
  }
1958
1958
  if (comment)
1959
1959
  reqNewline = true;
1960
- let str15 = stringify.stringify(item, itemCtx, () => comment = null);
1961
- reqNewline || (reqNewline = lines.length > linesAtValue || str15.includes("\n"));
1960
+ let str16 = stringify.stringify(item, itemCtx, () => comment = null);
1961
+ reqNewline || (reqNewline = lines.length > linesAtValue || str16.includes("\n"));
1962
1962
  if (i < items.length - 1) {
1963
- str15 += ",";
1963
+ str16 += ",";
1964
1964
  } else if (ctx.options.trailingComma) {
1965
1965
  if (ctx.options.lineWidth > 0) {
1966
- reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str15.length + 2) > ctx.options.lineWidth);
1966
+ reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str16.length + 2) > ctx.options.lineWidth);
1967
1967
  }
1968
1968
  if (reqNewline) {
1969
- str15 += ",";
1969
+ str16 += ",";
1970
1970
  }
1971
1971
  }
1972
1972
  if (comment)
1973
- str15 += stringifyComment.lineComment(str15, itemIndent, commentString(comment));
1974
- lines.push(str15);
1973
+ str16 += stringifyComment.lineComment(str16, itemIndent, commentString(comment));
1974
+ lines.push(str16);
1975
1975
  linesAtValue = lines.length;
1976
1976
  }
1977
1977
  const { start, end } = flowChars;
@@ -1983,11 +1983,11 @@ ${indent}${line}` : "\n";
1983
1983
  reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
1984
1984
  }
1985
1985
  if (reqNewline) {
1986
- let str15 = start;
1986
+ let str16 = start;
1987
1987
  for (const line of lines)
1988
- str15 += line ? `
1988
+ str16 += line ? `
1989
1989
  ${indentStep}${indent}${line}` : "\n";
1990
- return `${str15}
1990
+ return `${str16}
1991
1991
  ${indent}${end}`;
1992
1992
  } else {
1993
1993
  return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
@@ -2319,7 +2319,7 @@ var require_string = __commonJS({
2319
2319
  identify: (value) => typeof value === "string",
2320
2320
  default: true,
2321
2321
  tag: "tag:yaml.org,2002:str",
2322
- resolve: (str15) => str15,
2322
+ resolve: (str16) => str16,
2323
2323
  stringify(item, ctx, onComment, onChompKeep) {
2324
2324
  ctx = Object.assign({ actualString: true }, ctx);
2325
2325
  return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
@@ -2357,7 +2357,7 @@ var require_bool = __commonJS({
2357
2357
  default: true,
2358
2358
  tag: "tag:yaml.org,2002:bool",
2359
2359
  test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
2360
- resolve: (str15) => new Scalar.Scalar(str15[0] === "t" || str15[0] === "T"),
2360
+ resolve: (str16) => new Scalar.Scalar(str16[0] === "t" || str16[0] === "T"),
2361
2361
  stringify({ source, value }, ctx) {
2362
2362
  if (source && boolTag.test.test(source)) {
2363
2363
  const sv = source[0] === "t" || source[0] === "T";
@@ -2409,7 +2409,7 @@ var require_float = __commonJS({
2409
2409
  default: true,
2410
2410
  tag: "tag:yaml.org,2002:float",
2411
2411
  test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
2412
- resolve: (str15) => str15.slice(-3).toLowerCase() === "nan" ? NaN : str15[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
2412
+ resolve: (str16) => str16.slice(-3).toLowerCase() === "nan" ? NaN : str16[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
2413
2413
  stringify: stringifyNumber.stringifyNumber
2414
2414
  };
2415
2415
  var floatExp = {
@@ -2418,7 +2418,7 @@ var require_float = __commonJS({
2418
2418
  tag: "tag:yaml.org,2002:float",
2419
2419
  format: "EXP",
2420
2420
  test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
2421
- resolve: (str15) => parseFloat(str15),
2421
+ resolve: (str16) => parseFloat(str16),
2422
2422
  stringify(node) {
2423
2423
  const num = Number(node.value);
2424
2424
  return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
@@ -2429,11 +2429,11 @@ var require_float = __commonJS({
2429
2429
  default: true,
2430
2430
  tag: "tag:yaml.org,2002:float",
2431
2431
  test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
2432
- resolve(str15) {
2433
- const node = new Scalar.Scalar(parseFloat(str15));
2434
- const dot = str15.indexOf(".");
2435
- if (dot !== -1 && str15[str15.length - 1] === "0")
2436
- node.minFractionDigits = str15.length - dot - 1;
2432
+ resolve(str16) {
2433
+ const node = new Scalar.Scalar(parseFloat(str16));
2434
+ const dot = str16.indexOf(".");
2435
+ if (dot !== -1 && str16[str16.length - 1] === "0")
2436
+ node.minFractionDigits = str16.length - dot - 1;
2437
2437
  return node;
2438
2438
  },
2439
2439
  stringify: stringifyNumber.stringifyNumber
@@ -2450,7 +2450,7 @@ var require_int = __commonJS({
2450
2450
  "use strict";
2451
2451
  var stringifyNumber = require_stringifyNumber();
2452
2452
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
2453
- var intResolve = (str15, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str15) : parseInt(str15.substring(offset), radix);
2453
+ var intResolve = (str16, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str16) : parseInt(str16.substring(offset), radix);
2454
2454
  function intStringify(node, radix, prefix) {
2455
2455
  const { value } = node;
2456
2456
  if (intIdentify(value) && value >= 0)
@@ -2463,7 +2463,7 @@ var require_int = __commonJS({
2463
2463
  tag: "tag:yaml.org,2002:int",
2464
2464
  format: "OCT",
2465
2465
  test: /^0o[0-7]+$/,
2466
- resolve: (str15, _onError, opt) => intResolve(str15, 2, 8, opt),
2466
+ resolve: (str16, _onError, opt) => intResolve(str16, 2, 8, opt),
2467
2467
  stringify: (node) => intStringify(node, 8, "0o")
2468
2468
  };
2469
2469
  var int2 = {
@@ -2471,7 +2471,7 @@ var require_int = __commonJS({
2471
2471
  default: true,
2472
2472
  tag: "tag:yaml.org,2002:int",
2473
2473
  test: /^[-+]?[0-9]+$/,
2474
- resolve: (str15, _onError, opt) => intResolve(str15, 0, 10, opt),
2474
+ resolve: (str16, _onError, opt) => intResolve(str16, 0, 10, opt),
2475
2475
  stringify: stringifyNumber.stringifyNumber
2476
2476
  };
2477
2477
  var intHex = {
@@ -2480,7 +2480,7 @@ var require_int = __commonJS({
2480
2480
  tag: "tag:yaml.org,2002:int",
2481
2481
  format: "HEX",
2482
2482
  test: /^0x[0-9a-fA-F]+$/,
2483
- resolve: (str15, _onError, opt) => intResolve(str15, 2, 16, opt),
2483
+ resolve: (str16, _onError, opt) => intResolve(str16, 2, 16, opt),
2484
2484
  stringify: (node) => intStringify(node, 16, "0x")
2485
2485
  };
2486
2486
  exports.int = int2;
@@ -2533,7 +2533,7 @@ var require_schema2 = __commonJS({
2533
2533
  identify: (value) => typeof value === "string",
2534
2534
  default: true,
2535
2535
  tag: "tag:yaml.org,2002:str",
2536
- resolve: (str15) => str15,
2536
+ resolve: (str16) => str16,
2537
2537
  stringify: stringifyJSON
2538
2538
  },
2539
2539
  {
@@ -2550,7 +2550,7 @@ var require_schema2 = __commonJS({
2550
2550
  default: true,
2551
2551
  tag: "tag:yaml.org,2002:bool",
2552
2552
  test: /^true$|^false$/,
2553
- resolve: (str15) => str15 === "true",
2553
+ resolve: (str16) => str16 === "true",
2554
2554
  stringify: stringifyJSON
2555
2555
  },
2556
2556
  {
@@ -2558,7 +2558,7 @@ var require_schema2 = __commonJS({
2558
2558
  default: true,
2559
2559
  tag: "tag:yaml.org,2002:int",
2560
2560
  test: /^-?(?:0|[1-9][0-9]*)$/,
2561
- resolve: (str15, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str15) : parseInt(str15, 10),
2561
+ resolve: (str16, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str16) : parseInt(str16, 10),
2562
2562
  stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value)
2563
2563
  },
2564
2564
  {
@@ -2566,7 +2566,7 @@ var require_schema2 = __commonJS({
2566
2566
  default: true,
2567
2567
  tag: "tag:yaml.org,2002:float",
2568
2568
  test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
2569
- resolve: (str15) => parseFloat(str15),
2569
+ resolve: (str16) => parseFloat(str16),
2570
2570
  stringify: stringifyJSON
2571
2571
  }
2572
2572
  ];
@@ -2574,9 +2574,9 @@ var require_schema2 = __commonJS({
2574
2574
  default: true,
2575
2575
  tag: "",
2576
2576
  test: /^/,
2577
- resolve(str15, onError) {
2578
- onError(`Unresolved plain scalar ${JSON.stringify(str15)}`);
2579
- return str15;
2577
+ resolve(str16, onError) {
2578
+ onError(`Unresolved plain scalar ${JSON.stringify(str16)}`);
2579
+ return str16;
2580
2580
  }
2581
2581
  };
2582
2582
  var schema = [map.map, seq.seq].concat(jsonScalars, jsonError);
@@ -2608,10 +2608,10 @@ var require_binary = __commonJS({
2608
2608
  if (typeof node_buffer.Buffer === "function") {
2609
2609
  return node_buffer.Buffer.from(src, "base64");
2610
2610
  } else if (typeof atob === "function") {
2611
- const str15 = atob(src.replace(/[\n\r]/g, ""));
2612
- const buffer = new Uint8Array(str15.length);
2613
- for (let i = 0; i < str15.length; ++i)
2614
- buffer[i] = str15.charCodeAt(i);
2611
+ const str16 = atob(src.replace(/[\n\r]/g, ""));
2612
+ const buffer = new Uint8Array(str16.length);
2613
+ for (let i = 0; i < str16.length; ++i)
2614
+ buffer[i] = str16.charCodeAt(i);
2615
2615
  return buffer;
2616
2616
  } else {
2617
2617
  onError("This environment does not support reading binary tags; either Buffer or atob is required");
@@ -2622,28 +2622,28 @@ var require_binary = __commonJS({
2622
2622
  if (!value)
2623
2623
  return "";
2624
2624
  const buf = value;
2625
- let str15;
2625
+ let str16;
2626
2626
  if (typeof node_buffer.Buffer === "function") {
2627
- str15 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
2627
+ str16 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
2628
2628
  } else if (typeof btoa === "function") {
2629
2629
  let s = "";
2630
2630
  for (let i = 0; i < buf.length; ++i)
2631
2631
  s += String.fromCharCode(buf[i]);
2632
- str15 = btoa(s);
2632
+ str16 = btoa(s);
2633
2633
  } else {
2634
2634
  throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
2635
2635
  }
2636
2636
  type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
2637
2637
  if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
2638
2638
  const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
2639
- const n = Math.ceil(str15.length / lineWidth);
2639
+ const n = Math.ceil(str16.length / lineWidth);
2640
2640
  const lines = new Array(n);
2641
2641
  for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
2642
- lines[i] = str15.substr(o, lineWidth);
2642
+ lines[i] = str16.substr(o, lineWidth);
2643
2643
  }
2644
- str15 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
2644
+ str16 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
2645
2645
  }
2646
- return stringifyString.stringifyString({ comment, type, value: str15 }, ctx, onComment, onChompKeep);
2646
+ return stringifyString.stringifyString({ comment, type, value: str16 }, ctx, onComment, onChompKeep);
2647
2647
  }
2648
2648
  };
2649
2649
  exports.binary = binary;
@@ -2849,7 +2849,7 @@ var require_float2 = __commonJS({
2849
2849
  default: true,
2850
2850
  tag: "tag:yaml.org,2002:float",
2851
2851
  test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
2852
- resolve: (str15) => str15.slice(-3).toLowerCase() === "nan" ? NaN : str15[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
2852
+ resolve: (str16) => str16.slice(-3).toLowerCase() === "nan" ? NaN : str16[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
2853
2853
  stringify: stringifyNumber.stringifyNumber
2854
2854
  };
2855
2855
  var floatExp = {
@@ -2858,7 +2858,7 @@ var require_float2 = __commonJS({
2858
2858
  tag: "tag:yaml.org,2002:float",
2859
2859
  format: "EXP",
2860
2860
  test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
2861
- resolve: (str15) => parseFloat(str15.replace(/_/g, "")),
2861
+ resolve: (str16) => parseFloat(str16.replace(/_/g, "")),
2862
2862
  stringify(node) {
2863
2863
  const num = Number(node.value);
2864
2864
  return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
@@ -2869,11 +2869,11 @@ var require_float2 = __commonJS({
2869
2869
  default: true,
2870
2870
  tag: "tag:yaml.org,2002:float",
2871
2871
  test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
2872
- resolve(str15) {
2873
- const node = new Scalar.Scalar(parseFloat(str15.replace(/_/g, "")));
2874
- const dot = str15.indexOf(".");
2872
+ resolve(str16) {
2873
+ const node = new Scalar.Scalar(parseFloat(str16.replace(/_/g, "")));
2874
+ const dot = str16.indexOf(".");
2875
2875
  if (dot !== -1) {
2876
- const f = str15.substring(dot + 1).replace(/_/g, "");
2876
+ const f = str16.substring(dot + 1).replace(/_/g, "");
2877
2877
  if (f[f.length - 1] === "0")
2878
2878
  node.minFractionDigits = f.length;
2879
2879
  }
@@ -2893,34 +2893,34 @@ var require_int2 = __commonJS({
2893
2893
  "use strict";
2894
2894
  var stringifyNumber = require_stringifyNumber();
2895
2895
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
2896
- function intResolve(str15, offset, radix, { intAsBigInt }) {
2897
- const sign = str15[0];
2896
+ function intResolve(str16, offset, radix, { intAsBigInt }) {
2897
+ const sign = str16[0];
2898
2898
  if (sign === "-" || sign === "+")
2899
2899
  offset += 1;
2900
- str15 = str15.substring(offset).replace(/_/g, "");
2900
+ str16 = str16.substring(offset).replace(/_/g, "");
2901
2901
  if (intAsBigInt) {
2902
2902
  switch (radix) {
2903
2903
  case 2:
2904
- str15 = `0b${str15}`;
2904
+ str16 = `0b${str16}`;
2905
2905
  break;
2906
2906
  case 8:
2907
- str15 = `0o${str15}`;
2907
+ str16 = `0o${str16}`;
2908
2908
  break;
2909
2909
  case 16:
2910
- str15 = `0x${str15}`;
2910
+ str16 = `0x${str16}`;
2911
2911
  break;
2912
2912
  }
2913
- const n2 = BigInt(str15);
2913
+ const n2 = BigInt(str16);
2914
2914
  return sign === "-" ? BigInt(-1) * n2 : n2;
2915
2915
  }
2916
- const n = parseInt(str15, radix);
2916
+ const n = parseInt(str16, radix);
2917
2917
  return sign === "-" ? -1 * n : n;
2918
2918
  }
2919
2919
  function intStringify(node, radix, prefix) {
2920
2920
  const { value } = node;
2921
2921
  if (intIdentify(value)) {
2922
- const str15 = value.toString(radix);
2923
- return value < 0 ? "-" + prefix + str15.substr(1) : prefix + str15;
2922
+ const str16 = value.toString(radix);
2923
+ return value < 0 ? "-" + prefix + str16.substr(1) : prefix + str16;
2924
2924
  }
2925
2925
  return stringifyNumber.stringifyNumber(node);
2926
2926
  }
@@ -2930,7 +2930,7 @@ var require_int2 = __commonJS({
2930
2930
  tag: "tag:yaml.org,2002:int",
2931
2931
  format: "BIN",
2932
2932
  test: /^[-+]?0b[0-1_]+$/,
2933
- resolve: (str15, _onError, opt) => intResolve(str15, 2, 2, opt),
2933
+ resolve: (str16, _onError, opt) => intResolve(str16, 2, 2, opt),
2934
2934
  stringify: (node) => intStringify(node, 2, "0b")
2935
2935
  };
2936
2936
  var intOct = {
@@ -2939,7 +2939,7 @@ var require_int2 = __commonJS({
2939
2939
  tag: "tag:yaml.org,2002:int",
2940
2940
  format: "OCT",
2941
2941
  test: /^[-+]?0[0-7_]+$/,
2942
- resolve: (str15, _onError, opt) => intResolve(str15, 1, 8, opt),
2942
+ resolve: (str16, _onError, opt) => intResolve(str16, 1, 8, opt),
2943
2943
  stringify: (node) => intStringify(node, 8, "0")
2944
2944
  };
2945
2945
  var int2 = {
@@ -2947,7 +2947,7 @@ var require_int2 = __commonJS({
2947
2947
  default: true,
2948
2948
  tag: "tag:yaml.org,2002:int",
2949
2949
  test: /^[-+]?[0-9][0-9_]*$/,
2950
- resolve: (str15, _onError, opt) => intResolve(str15, 0, 10, opt),
2950
+ resolve: (str16, _onError, opt) => intResolve(str16, 0, 10, opt),
2951
2951
  stringify: stringifyNumber.stringifyNumber
2952
2952
  };
2953
2953
  var intHex = {
@@ -2956,7 +2956,7 @@ var require_int2 = __commonJS({
2956
2956
  tag: "tag:yaml.org,2002:int",
2957
2957
  format: "HEX",
2958
2958
  test: /^[-+]?0x[0-9a-fA-F_]+$/,
2959
- resolve: (str15, _onError, opt) => intResolve(str15, 2, 16, opt),
2959
+ resolve: (str16, _onError, opt) => intResolve(str16, 2, 16, opt),
2960
2960
  stringify: (node) => intStringify(node, 16, "0x")
2961
2961
  };
2962
2962
  exports.int = int2;
@@ -3060,9 +3060,9 @@ var require_timestamp = __commonJS({
3060
3060
  "node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
3061
3061
  "use strict";
3062
3062
  var stringifyNumber = require_stringifyNumber();
3063
- function parseSexagesimal(str15, asBigInt) {
3064
- const sign = str15[0];
3065
- const parts = sign === "-" || sign === "+" ? str15.substring(1) : str15;
3063
+ function parseSexagesimal(str16, asBigInt) {
3064
+ const sign = str16[0];
3065
+ const parts = sign === "-" || sign === "+" ? str16.substring(1) : str16;
3066
3066
  const num = (n) => asBigInt ? BigInt(n) : Number(n);
3067
3067
  const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
3068
3068
  return sign === "-" ? num(-1) * res : res;
@@ -3099,7 +3099,7 @@ var require_timestamp = __commonJS({
3099
3099
  tag: "tag:yaml.org,2002:int",
3100
3100
  format: "TIME",
3101
3101
  test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
3102
- resolve: (str15, _onError, { intAsBigInt }) => parseSexagesimal(str15, intAsBigInt),
3102
+ resolve: (str16, _onError, { intAsBigInt }) => parseSexagesimal(str16, intAsBigInt),
3103
3103
  stringify: stringifySexagesimal
3104
3104
  };
3105
3105
  var floatTime = {
@@ -3108,7 +3108,7 @@ var require_timestamp = __commonJS({
3108
3108
  tag: "tag:yaml.org,2002:float",
3109
3109
  format: "TIME",
3110
3110
  test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
3111
- resolve: (str15) => parseSexagesimal(str15, false),
3111
+ resolve: (str16) => parseSexagesimal(str16, false),
3112
3112
  stringify: stringifySexagesimal
3113
3113
  };
3114
3114
  var timestamp = {
@@ -3119,8 +3119,8 @@ var require_timestamp = __commonJS({
3119
3119
  // may be omitted altogether, resulting in a date format. In such a case, the time part is
3120
3120
  // assumed to be 00:00:00Z (start of day, UTC).
3121
3121
  test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
3122
- resolve(str15) {
3123
- const match = str15.match(timestamp.test);
3122
+ resolve(str16) {
3123
+ const match = str16.match(timestamp.test);
3124
3124
  if (!match)
3125
3125
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
3126
3126
  const [, year, month, day, hour, minute, second] = match.map(Number);
@@ -3471,9 +3471,9 @@ var require_Document = __commonJS({
3471
3471
  this.contents.add(value);
3472
3472
  }
3473
3473
  /** Adds a value to the document. */
3474
- addIn(path102, value) {
3474
+ addIn(path105, value) {
3475
3475
  if (assertCollection(this.contents))
3476
- this.contents.addIn(path102, value);
3476
+ this.contents.addIn(path105, value);
3477
3477
  }
3478
3478
  /**
3479
3479
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3548,14 +3548,14 @@ var require_Document = __commonJS({
3548
3548
  * Removes a value from the document.
3549
3549
  * @returns `true` if the item was found and removed.
3550
3550
  */
3551
- deleteIn(path102) {
3552
- if (Collection.isEmptyPath(path102)) {
3551
+ deleteIn(path105) {
3552
+ if (Collection.isEmptyPath(path105)) {
3553
3553
  if (this.contents == null)
3554
3554
  return false;
3555
3555
  this.contents = null;
3556
3556
  return true;
3557
3557
  }
3558
- return assertCollection(this.contents) ? this.contents.deleteIn(path102) : false;
3558
+ return assertCollection(this.contents) ? this.contents.deleteIn(path105) : false;
3559
3559
  }
3560
3560
  /**
3561
3561
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3570,10 +3570,10 @@ var require_Document = __commonJS({
3570
3570
  * scalar values from their surrounding node; to disable set `keepScalar` to
3571
3571
  * `true` (collections are always returned intact).
3572
3572
  */
3573
- getIn(path102, keepScalar) {
3574
- if (Collection.isEmptyPath(path102))
3573
+ getIn(path105, keepScalar) {
3574
+ if (Collection.isEmptyPath(path105))
3575
3575
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3576
- return identity.isCollection(this.contents) ? this.contents.getIn(path102, keepScalar) : void 0;
3576
+ return identity.isCollection(this.contents) ? this.contents.getIn(path105, keepScalar) : void 0;
3577
3577
  }
3578
3578
  /**
3579
3579
  * Checks if the document includes a value with the key `key`.
@@ -3584,10 +3584,10 @@ var require_Document = __commonJS({
3584
3584
  /**
3585
3585
  * Checks if the document includes a value at `path`.
3586
3586
  */
3587
- hasIn(path102) {
3588
- if (Collection.isEmptyPath(path102))
3587
+ hasIn(path105) {
3588
+ if (Collection.isEmptyPath(path105))
3589
3589
  return this.contents !== void 0;
3590
- return identity.isCollection(this.contents) ? this.contents.hasIn(path102) : false;
3590
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path105) : false;
3591
3591
  }
3592
3592
  /**
3593
3593
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3604,13 +3604,13 @@ var require_Document = __commonJS({
3604
3604
  * Sets a value in this document. For `!!set`, `value` needs to be a
3605
3605
  * boolean to add/remove the item from the set.
3606
3606
  */
3607
- setIn(path102, value) {
3608
- if (Collection.isEmptyPath(path102)) {
3607
+ setIn(path105, value) {
3608
+ if (Collection.isEmptyPath(path105)) {
3609
3609
  this.contents = value;
3610
3610
  } else if (this.contents == null) {
3611
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path102), value);
3611
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path105), value);
3612
3612
  } else if (assertCollection(this.contents)) {
3613
- this.contents.setIn(path102, value);
3613
+ this.contents.setIn(path105, value);
3614
3614
  }
3615
3615
  }
3616
3616
  /**
@@ -5570,9 +5570,9 @@ var require_cst_visit = __commonJS({
5570
5570
  visit.BREAK = BREAK;
5571
5571
  visit.SKIP = SKIP;
5572
5572
  visit.REMOVE = REMOVE;
5573
- visit.itemAtPath = (cst, path102) => {
5573
+ visit.itemAtPath = (cst, path105) => {
5574
5574
  let item = cst;
5575
- for (const [field, index] of path102) {
5575
+ for (const [field, index] of path105) {
5576
5576
  const tok = item?.[field];
5577
5577
  if (tok && "items" in tok) {
5578
5578
  item = tok.items[index];
@@ -5581,23 +5581,23 @@ var require_cst_visit = __commonJS({
5581
5581
  }
5582
5582
  return item;
5583
5583
  };
5584
- visit.parentCollection = (cst, path102) => {
5585
- const parent = visit.itemAtPath(cst, path102.slice(0, -1));
5586
- const field = path102[path102.length - 1][0];
5584
+ visit.parentCollection = (cst, path105) => {
5585
+ const parent = visit.itemAtPath(cst, path105.slice(0, -1));
5586
+ const field = path105[path105.length - 1][0];
5587
5587
  const coll = parent?.[field];
5588
5588
  if (coll && "items" in coll)
5589
5589
  return coll;
5590
5590
  throw new Error("Parent collection not found");
5591
5591
  };
5592
- function _visit(path102, item, visitor) {
5593
- let ctrl = visitor(item, path102);
5592
+ function _visit(path105, item, visitor) {
5593
+ let ctrl = visitor(item, path105);
5594
5594
  if (typeof ctrl === "symbol")
5595
5595
  return ctrl;
5596
5596
  for (const field of ["key", "value"]) {
5597
5597
  const token = item[field];
5598
5598
  if (token && "items" in token) {
5599
5599
  for (let i = 0; i < token.items.length; ++i) {
5600
- const ci = _visit(Object.freeze(path102.concat([[field, i]])), token.items[i], visitor);
5600
+ const ci = _visit(Object.freeze(path105.concat([[field, i]])), token.items[i], visitor);
5601
5601
  if (typeof ci === "number")
5602
5602
  i = ci - 1;
5603
5603
  else if (ci === BREAK)
@@ -5608,10 +5608,10 @@ var require_cst_visit = __commonJS({
5608
5608
  }
5609
5609
  }
5610
5610
  if (typeof ctrl === "function" && field === "key")
5611
- ctrl = ctrl(item, path102);
5611
+ ctrl = ctrl(item, path105);
5612
5612
  }
5613
5613
  }
5614
- return typeof ctrl === "function" ? ctrl(item, path102) : ctrl;
5614
+ return typeof ctrl === "function" ? ctrl(item, path105) : ctrl;
5615
5615
  }
5616
5616
  exports.visit = visit;
5617
5617
  }
@@ -6913,14 +6913,14 @@ var require_parser = __commonJS({
6913
6913
  case "scalar":
6914
6914
  case "single-quoted-scalar":
6915
6915
  case "double-quoted-scalar": {
6916
- const fs100 = this.flowScalar(this.type);
6916
+ const fs102 = this.flowScalar(this.type);
6917
6917
  if (atNextItem || it.value) {
6918
- map.items.push({ start, key: fs100, sep: [] });
6918
+ map.items.push({ start, key: fs102, sep: [] });
6919
6919
  this.onKeyLine = true;
6920
6920
  } else if (it.sep) {
6921
- this.stack.push(fs100);
6921
+ this.stack.push(fs102);
6922
6922
  } else {
6923
- Object.assign(it, { key: fs100, sep: [] });
6923
+ Object.assign(it, { key: fs102, sep: [] });
6924
6924
  this.onKeyLine = true;
6925
6925
  }
6926
6926
  return;
@@ -7048,13 +7048,13 @@ var require_parser = __commonJS({
7048
7048
  case "scalar":
7049
7049
  case "single-quoted-scalar":
7050
7050
  case "double-quoted-scalar": {
7051
- const fs100 = this.flowScalar(this.type);
7051
+ const fs102 = this.flowScalar(this.type);
7052
7052
  if (!it || it.value)
7053
- fc.items.push({ start: [], key: fs100, sep: [] });
7053
+ fc.items.push({ start: [], key: fs102, sep: [] });
7054
7054
  else if (it.sep)
7055
- this.stack.push(fs100);
7055
+ this.stack.push(fs102);
7056
7056
  else
7057
- Object.assign(it, { key: fs100, sep: [] });
7057
+ Object.assign(it, { key: fs102, sep: [] });
7058
7058
  return;
7059
7059
  }
7060
7060
  case "flow-map-end":
@@ -7363,16 +7363,16 @@ var require_dist = __commonJS({
7363
7363
  });
7364
7364
 
7365
7365
  // src/scripts/hooks/dispatch_entry.ts
7366
- import * as path101 from "node:path";
7367
- import { fileURLToPath as fileURLToPath65 } from "node:url";
7366
+ import * as path104 from "node:path";
7367
+ import { fileURLToPath as fileURLToPath67 } from "node:url";
7368
7368
 
7369
7369
  // src/scripts/hooks/dispatch_hook.ts
7370
7370
  var import_yaml6 = __toESM(require_dist(), 1);
7371
- import { spawnSync as spawnSync8 } from "node:child_process";
7372
- import fs99 from "node:fs";
7373
- import path100 from "node:path";
7371
+ import { spawnSync as spawnSync10 } from "node:child_process";
7372
+ import fs101 from "node:fs";
7373
+ import path103 from "node:path";
7374
7374
  import * as tty2 from "node:tty";
7375
- import { fileURLToPath as fileURLToPath64, pathToFileURL as pathToFileURL58 } from "node:url";
7375
+ import { fileURLToPath as fileURLToPath66, pathToFileURL as pathToFileURL59 } from "node:url";
7376
7376
 
7377
7377
  // src/scripts/_lib/spawn_env.ts
7378
7378
  var DENY_EXACT = /* @__PURE__ */ new Set([
@@ -8243,7 +8243,7 @@ import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL5 } from
8243
8243
  var import_yaml2 = __toESM(require_dist(), 1);
8244
8244
  import * as fs9 from "node:fs";
8245
8245
  import * as path10 from "node:path";
8246
- import process5 from "node:process";
8246
+ import process6 from "node:process";
8247
8247
  import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL4 } from "node:url";
8248
8248
  import { createRequire as createRequire2 } from "node:module";
8249
8249
 
@@ -8692,6 +8692,7 @@ function _pyJsonScalarAscii(value) {
8692
8692
  }
8693
8693
 
8694
8694
  // src/scripts/_lib/scan_scope.ts
8695
+ import process2 from "node:process";
8695
8696
  var DeadScopeError = class extends Error {
8696
8697
  gate;
8697
8698
  constructor(gate, message) {
@@ -8713,6 +8714,11 @@ function assertScanned(opts) {
8713
8714
  `${opts.gate}: scanned 0 ${opts.units} under ${roots} \u2014 the scan scope is dead or the root moved. A gate that read nothing has not passed. Repoint the root (prefer the shared resolver in _lib/agent_src.ts), or declare a justified \`allowEmpty\` reason if an empty corpus is genuinely expected.`
8714
8715
  );
8715
8716
  }
8717
+ function reportScanned(opts, write = process2.stdout.write.bind(process2.stdout)) {
8718
+ assertScanned(opts);
8719
+ write(`scanned: ${String(opts.scanned)}
8720
+ `);
8721
+ }
8716
8722
 
8717
8723
  // src/scripts/lint_hidden_unicode.ts
8718
8724
  var CHECK = "hidden-unicode";
@@ -9653,11 +9659,11 @@ function stampUserVersion(conn, version) {
9653
9659
  var import_yaml = __toESM(require_dist(), 1);
9654
9660
  import * as fs6 from "node:fs";
9655
9661
  import * as path7 from "node:path";
9656
- import process3 from "node:process";
9662
+ import process4 from "node:process";
9657
9663
  import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
9658
9664
 
9659
9665
  // src/scripts/memory_status.ts
9660
- import process2 from "node:process";
9666
+ import process3 from "node:process";
9661
9667
  import * as fs5 from "node:fs";
9662
9668
  import * as path6 from "node:path";
9663
9669
  import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
@@ -9733,8 +9739,8 @@ var _ExitError = class extends Error {
9733
9739
  code;
9734
9740
  };
9735
9741
  function _usageError(msg) {
9736
- process2.stderr.write(_USAGE);
9737
- process2.stderr.write(`${_PROG}: error: ${msg}
9742
+ process3.stderr.write(_USAGE);
9743
+ process3.stderr.write(`${_PROG}: error: ${msg}
9738
9744
  `);
9739
9745
  throw new _ExitError(2);
9740
9746
  }
@@ -9764,7 +9770,7 @@ function _parseArgs(argv) {
9764
9770
  } else if (a === "--health") {
9765
9771
  args.health = true;
9766
9772
  } else if (a === "-h" || a === "--help") {
9767
- process2.stdout.write(_USAGE);
9773
+ process3.stdout.write(_USAGE);
9768
9774
  throw new _ExitError(0);
9769
9775
  } else {
9770
9776
  _usageError(`unrecognized arguments: ${a}`);
@@ -9773,18 +9779,18 @@ function _parseArgs(argv) {
9773
9779
  return args;
9774
9780
  }
9775
9781
  function main2() {
9776
- const args = _parseArgs(process2.argv.slice(2));
9782
+ const args = _parseArgs(process3.argv.slice(2));
9777
9783
  if (args.health) {
9778
- process2.stdout.write(`${_pyJsonDumps(health())}
9784
+ process3.stdout.write(`${_pyJsonDumps(health())}
9779
9785
  `);
9780
9786
  return 0;
9781
9787
  }
9782
9788
  const r = status();
9783
9789
  if (args.format === "json") {
9784
- process2.stdout.write(`${_pyJsonDumps(r)}
9790
+ process3.stdout.write(`${_pyJsonDumps(r)}
9785
9791
  `);
9786
9792
  } else {
9787
- process2.stdout.write(` \u2139\uFE0F backend=${r.backend} status=${r.status} reason=${r.reason}
9793
+ process3.stdout.write(` \u2139\uFE0F backend=${r.backend} status=${r.status} reason=${r.reason}
9788
9794
  `);
9789
9795
  }
9790
9796
  return 0;
@@ -9793,16 +9799,16 @@ function _isCliEntry2() {
9793
9799
  if (true) {
9794
9800
  return false;
9795
9801
  }
9796
- if (process2.argv[1] === void 0) {
9802
+ if (process3.argv[1] === void 0) {
9797
9803
  return false;
9798
9804
  }
9799
- const argvUrl = pathToFileURL2(path6.resolve(process2.argv[1])).href;
9805
+ const argvUrl = pathToFileURL2(path6.resolve(process3.argv[1])).href;
9800
9806
  if (import.meta.url === argvUrl) {
9801
9807
  return true;
9802
9808
  }
9803
9809
  try {
9804
9810
  const here = fs5.realpathSync(fileURLToPath3(import.meta.url));
9805
- const argv = fs5.realpathSync(path6.resolve(process2.argv[1]));
9811
+ const argv = fs5.realpathSync(path6.resolve(process3.argv[1]));
9806
9812
  return here === argv;
9807
9813
  } catch {
9808
9814
  return false;
@@ -9811,10 +9817,10 @@ function _isCliEntry2() {
9811
9817
  var _isMain = _isCliEntry2();
9812
9818
  if (_isMain) {
9813
9819
  try {
9814
- process2.exitCode = main2();
9820
+ process3.exitCode = main2();
9815
9821
  } catch (e) {
9816
9822
  if (e instanceof _ExitError) {
9817
- process2.exitCode = e.code;
9823
+ process3.exitCode = e.code;
9818
9824
  } else {
9819
9825
  throw e;
9820
9826
  }
@@ -10318,7 +10324,7 @@ function _print_text(report2) {
10318
10324
  out.push(` unknown: ${rm.unknown_modes.join(", ")} (not in the six reserved slugs)`);
10319
10325
  }
10320
10326
  }
10321
- process3.stdout.write(out.map((line) => `${line}
10327
+ process4.stdout.write(out.map((line) => `${line}
10322
10328
  `).join(""));
10323
10329
  }
10324
10330
  function _sortedEntries(obj) {
@@ -10443,10 +10449,10 @@ function _escapeNonAscii2(s) {
10443
10449
  var _PROG2 = "memory_report.py";
10444
10450
  var _USAGE2 = "usage: memory_report.py [-h] [--format {text,json}]\n";
10445
10451
  function _argError2(msg) {
10446
- process3.stderr.write(_USAGE2);
10447
- process3.stderr.write(`${_PROG2}: error: ${msg}
10452
+ process4.stderr.write(_USAGE2);
10453
+ process4.stderr.write(`${_PROG2}: error: ${msg}
10448
10454
  `);
10449
- process3.exit(2);
10455
+ process4.exit(2);
10450
10456
  }
10451
10457
  function _parseArgs2(argv) {
10452
10458
  const args = { format: "text" };
@@ -10457,8 +10463,8 @@ function _parseArgs2(argv) {
10457
10463
  } else if (a.startsWith("--format=")) {
10458
10464
  args.format = _checkChoice(a.slice("--format=".length), ["text", "json"], "--format");
10459
10465
  } else if (a === "-h" || a === "--help") {
10460
- process3.stdout.write(_USAGE2);
10461
- process3.exit(0);
10466
+ process4.stdout.write(_USAGE2);
10467
+ process4.exit(0);
10462
10468
  } else {
10463
10469
  _argError2(`unrecognized arguments: ${a}`);
10464
10470
  }
@@ -10474,10 +10480,10 @@ function _checkChoice(value, choices, flag) {
10474
10480
  return value;
10475
10481
  }
10476
10482
  function main3() {
10477
- const args = _parseArgs2(process3.argv.slice(2));
10483
+ const args = _parseArgs2(process4.argv.slice(2));
10478
10484
  const report2 = build_report();
10479
10485
  if (args.format === "json") {
10480
- process3.stdout.write(`${pyJsonDumps(report2, 2)}
10486
+ process4.stdout.write(`${pyJsonDumps(report2, 2)}
10481
10487
  `);
10482
10488
  } else {
10483
10489
  _print_text(report2);
@@ -10488,16 +10494,16 @@ function _isCliEntry3() {
10488
10494
  if (true) {
10489
10495
  return false;
10490
10496
  }
10491
- if (process3.argv[1] === void 0) {
10497
+ if (process4.argv[1] === void 0) {
10492
10498
  return false;
10493
10499
  }
10494
- const argvUrl = pathToFileURL3(path7.resolve(process3.argv[1])).href;
10500
+ const argvUrl = pathToFileURL3(path7.resolve(process4.argv[1])).href;
10495
10501
  if (import.meta.url === argvUrl) {
10496
10502
  return true;
10497
10503
  }
10498
10504
  try {
10499
10505
  const here = fs6.realpathSync(fileURLToPath4(import.meta.url));
10500
- const argv = fs6.realpathSync(path7.resolve(process3.argv[1]));
10506
+ const argv = fs6.realpathSync(path7.resolve(process4.argv[1]));
10501
10507
  return here === argv;
10502
10508
  } catch {
10503
10509
  return false;
@@ -10505,7 +10511,7 @@ function _isCliEntry3() {
10505
10511
  }
10506
10512
  var _isMain2 = _isCliEntry3();
10507
10513
  if (_isMain2) {
10508
- process3.exit(main3());
10514
+ process4.exit(main3());
10509
10515
  }
10510
10516
 
10511
10517
  // src/scripts/_lib/memory_fts_index.ts
@@ -10753,7 +10759,7 @@ function queryIndex(indexPath, keys, types) {
10753
10759
  import { createHash as createHash2 } from "node:crypto";
10754
10760
  import * as fs8 from "node:fs";
10755
10761
  import * as path9 from "node:path";
10756
- import process4 from "node:process";
10762
+ import process5 from "node:process";
10757
10763
  import { fileURLToPath as fileURLToPath5 } from "node:url";
10758
10764
  var PROG = "learning_sidecar.ts";
10759
10765
  var HALF_LIFE_DAYS = 30;
@@ -10919,13 +10925,13 @@ function main4(argv) {
10919
10925
  else if (a === "--write") write = true;
10920
10926
  else if (a === "--format") format = argv[++i] ?? "text";
10921
10927
  else if (a === "-h" || a === "--help") {
10922
- process4.stdout.write(
10928
+ process5.stdout.write(
10923
10929
  `usage: ${PROG} [--intake-dir DIR] [--out-dir DIR] [--now ISO] [--write] [--format text|json]
10924
10930
  `
10925
10931
  );
10926
10932
  return 0;
10927
10933
  } else {
10928
- process4.stderr.write(`${PROG}: error: unknown argument ${a}
10934
+ process5.stderr.write(`${PROG}: error: unknown argument ${a}
10929
10935
  `);
10930
10936
  return 2;
10931
10937
  }
@@ -10937,7 +10943,7 @@ function main4(argv) {
10937
10943
  try {
10938
10944
  sidecar = buildSidecar(intakeDir, nowIso);
10939
10945
  } catch (exc) {
10940
- process4.stderr.write(`${PROG}: internal error: ${String(exc)}
10946
+ process5.stderr.write(`${PROG}: internal error: ${String(exc)}
10941
10947
  `);
10942
10948
  return 3;
10943
10949
  }
@@ -10947,20 +10953,20 @@ function main4(argv) {
10947
10953
  fs8.writeFileSync(path9.join(outDir, LESSONS_NAME), renderLessonsMd(sidecar));
10948
10954
  }
10949
10955
  if (format === "json") {
10950
- process4.stdout.write(JSON.stringify(sidecar, null, 2) + "\n");
10956
+ process5.stdout.write(JSON.stringify(sidecar, null, 2) + "\n");
10951
10957
  return 0;
10952
10958
  }
10953
10959
  const byVerdict = { preferred: 0, contested: 0, dead_end: 0 };
10954
10960
  for (const l of sidecar.lessons) byVerdict[l.verdict] += 1;
10955
- process4.stdout.write(
10961
+ process5.stdout.write(
10956
10962
  `${PROG}: ${sidecar.lessons.length} lesson(s) \u2014 ${byVerdict.preferred} preferred, ${byVerdict.contested} contested, ${byVerdict.dead_end} dead-end${write ? " (written)" : ""}
10957
10963
  `
10958
10964
  );
10959
10965
  return 0;
10960
10966
  }
10961
10967
  var _bundled = true;
10962
- if (!_bundled && fileURLToPath5(import.meta.url) === path9.resolve(process4.argv[1] ?? "")) {
10963
- process4.exit(main4(process4.argv.slice(2)));
10968
+ if (!_bundled && fileURLToPath5(import.meta.url) === path9.resolve(process5.argv[1] ?? "")) {
10969
+ process5.exit(main4(process5.argv.slice(2)));
10964
10970
  }
10965
10971
 
10966
10972
  // src/scripts/memory_lookup.ts
@@ -11776,11 +11782,11 @@ function _parseArgs3(argv) {
11776
11782
  args.tokenBudget = _parseInt(a.slice("--token-budget=".length), "--token-budget");
11777
11783
  } else if (a === "-h" || a === "--help") {
11778
11784
  _printUsage();
11779
- process5.exit(0);
11785
+ process6.exit(0);
11780
11786
  } else {
11781
- process5.stderr.write(`memory_lookup: error: unrecognized arguments: ${a}
11787
+ process6.stderr.write(`memory_lookup: error: unrecognized arguments: ${a}
11782
11788
  `);
11783
- process5.exit(2);
11789
+ process6.exit(2);
11784
11790
  }
11785
11791
  }
11786
11792
  return args;
@@ -11788,34 +11794,34 @@ function _parseArgs3(argv) {
11788
11794
  function _parseInt(value, flag) {
11789
11795
  const n = Number(value);
11790
11796
  if (value === void 0 || !Number.isInteger(n)) {
11791
- process5.stderr.write(
11797
+ process6.stderr.write(
11792
11798
  `memory_lookup: error: argument ${flag}: invalid int value: '${value ?? ""}'
11793
11799
  `
11794
11800
  );
11795
- process5.exit(2);
11801
+ process6.exit(2);
11796
11802
  }
11797
11803
  return n;
11798
11804
  }
11799
11805
  function _checkChoice2(value, choices, flag) {
11800
11806
  if (value === void 0 || !choices.includes(value)) {
11801
- process5.stderr.write(
11807
+ process6.stderr.write(
11802
11808
  `memory_lookup: error: argument ${flag}: invalid choice: '${value ?? ""}' (choose from ${choices.map((c) => `'${c}'`).join(", ")})
11803
11809
  `
11804
11810
  );
11805
- process5.exit(2);
11811
+ process6.exit(2);
11806
11812
  }
11807
11813
  return value;
11808
11814
  }
11809
11815
  function _printUsage() {
11810
- process5.stdout.write(
11816
+ process6.stdout.write(
11811
11817
  "usage: memory_lookup [-h] [--types TYPES] [--key KEY] [--limit LIMIT] [--format {text,json}] [--envelope {legacy,v1}] [--detail {index,full}] [--token-budget N]\n"
11812
11818
  );
11813
11819
  }
11814
11820
  function main5() {
11815
- const args = _parseArgs3(process5.argv.slice(2));
11821
+ const args = _parseArgs3(process6.argv.slice(2));
11816
11822
  const types = args.types.split(",").map((t) => t.trim()).filter((t) => t);
11817
11823
  if (types.length === 0) {
11818
- process5.stderr.write("error: --types is required\n");
11824
+ process6.stderr.write("error: --types is required\n");
11819
11825
  return 2;
11820
11826
  }
11821
11827
  if (args.envelope === "v1") {
@@ -11824,7 +11830,7 @@ function main5() {
11824
11830
  opts.token_budget = args.tokenBudget;
11825
11831
  }
11826
11832
  const envelope = retrieve_v1(types, args.key, args.limit, opts);
11827
- process5.stdout.write(`${pyJsonDumps2(envelope, 2)}
11833
+ process6.stdout.write(`${pyJsonDumps2(envelope, 2)}
11828
11834
  `);
11829
11835
  return 0;
11830
11836
  }
@@ -11833,14 +11839,14 @@ function main5() {
11833
11839
  const payload = {
11834
11840
  hits: hits.map((h) => h.as_dict())
11835
11841
  };
11836
- process5.stdout.write(`${pyJsonDumps2(payload, 2)}
11842
+ process6.stdout.write(`${pyJsonDumps2(payload, 2)}
11837
11843
  `);
11838
11844
  } else {
11839
11845
  if (hits.length === 0) {
11840
- process5.stdout.write(" (no hits)\n");
11846
+ process6.stdout.write(" (no hits)\n");
11841
11847
  }
11842
11848
  for (const h of hits) {
11843
- process5.stdout.write(
11849
+ process6.stdout.write(
11844
11850
  ` [${h.source}] ${h.type} score=${_fixed2(h.score)} id=${h.id || "-"} path=${h.path}
11845
11851
  `
11846
11852
  );
@@ -12123,16 +12129,16 @@ function _escapeNonAscii3(s) {
12123
12129
  return out;
12124
12130
  }
12125
12131
  function _isCliEntry4() {
12126
- if (process5.argv[1] === void 0) {
12132
+ if (process6.argv[1] === void 0) {
12127
12133
  return false;
12128
12134
  }
12129
- const argvUrl = pathToFileURL4(path10.resolve(process5.argv[1])).href;
12135
+ const argvUrl = pathToFileURL4(path10.resolve(process6.argv[1])).href;
12130
12136
  if (import.meta.url === argvUrl) {
12131
12137
  return true;
12132
12138
  }
12133
12139
  try {
12134
12140
  const here = fs9.realpathSync(fileURLToPath6(import.meta.url));
12135
- const argv = fs9.realpathSync(path10.resolve(process5.argv[1]));
12141
+ const argv = fs9.realpathSync(path10.resolve(process6.argv[1]));
12136
12142
  return here === argv;
12137
12143
  } catch {
12138
12144
  return false;
@@ -12140,7 +12146,7 @@ function _isCliEntry4() {
12140
12146
  }
12141
12147
  var _isMain3 = _isCliEntry4();
12142
12148
  if (_isMain3) {
12143
- process5.exit(main5());
12149
+ process6.exit(main5());
12144
12150
  }
12145
12151
 
12146
12152
  // src/scripts/_lib/agent_settings.ts
@@ -14799,7 +14805,7 @@ import { spawnSync as spawnSync3 } from "node:child_process";
14799
14805
  import * as fs19 from "node:fs";
14800
14806
  import { createRequire as createRequire4 } from "node:module";
14801
14807
  import * as path18 from "node:path";
14802
- import process6 from "node:process";
14808
+ import process7 from "node:process";
14803
14809
  import { fileURLToPath as fileURLToPath10 } from "node:url";
14804
14810
 
14805
14811
  // src/scripts/_lib/transcript_reads.ts
@@ -18043,7 +18049,7 @@ function redact_low_impact_entry(text, opts = {}) {
18043
18049
  var HOT_CONTEXT_REL = path18.join("agents", "runtime", "state", "hot-context.md");
18044
18050
  var REPLAY_ENV_VAR3 = "AGENT_CONFIG_REPLAY";
18045
18051
  function _is_replay_mode2() {
18046
- return (process6.env[REPLAY_ENV_VAR3] ?? "").trim() === "1";
18052
+ return (process7.env[REPLAY_ENV_VAR3] ?? "").trim() === "1";
18047
18053
  }
18048
18054
  var WORD_CAP = 400;
18049
18055
  var MAX_AGE_HOURS = 48;
@@ -18057,10 +18063,10 @@ var KEY_FACTS_CHARS = 600;
18057
18063
  var MAX_REREAD_LINES = 3;
18058
18064
  var VERIFICATION_RE = /\b(fail(ing|ed|ure)?|error|exit[= ][1-9]|red\b|broken)\b/i;
18059
18065
  function _history_path(root) {
18060
- return process6.env.AGENT_CHAT_HISTORY_FILE || path18.join(root, HISTORY_REL);
18066
+ return process7.env.AGENT_CHAT_HISTORY_FILE || path18.join(root, HISTORY_REL);
18061
18067
  }
18062
18068
  function _hot_context_path(root) {
18063
- return process6.env.AGENT_HOT_CONTEXT_FILE || path18.join(root, HOT_CONTEXT_REL);
18069
+ return process7.env.AGENT_HOT_CONTEXT_FILE || path18.join(root, HOT_CONTEXT_REL);
18064
18070
  }
18065
18071
  function _current_branch(root) {
18066
18072
  try {
@@ -18214,7 +18220,7 @@ function _write_hot_context(root, transcriptPath = null) {
18214
18220
  const target = _hot_context_path(root);
18215
18221
  const text = build_hot_context(root, /* @__PURE__ */ new Date(), transcriptPath);
18216
18222
  fs19.mkdirSync(path18.dirname(target), { recursive: true });
18217
- const tmp = `${target}.tmp-${process6.pid}`;
18223
+ const tmp = `${target}.tmp-${process7.pid}`;
18218
18224
  fs19.writeFileSync(tmp, text, { encoding: "utf-8" });
18219
18225
  fs19.renameSync(tmp, target);
18220
18226
  }
@@ -18267,15 +18273,15 @@ function _session_index_block_or_null(root) {
18267
18273
  const req = createRequire4(import.meta.url);
18268
18274
  const mod = req("./session_memory_index.js");
18269
18275
  if (!mod.session_index_enabled(root)) return null;
18270
- const prev = process6.cwd();
18276
+ const prev = process7.cwd();
18271
18277
  try {
18272
- process6.chdir(root);
18278
+ process7.chdir(root);
18273
18279
  return mod.build_session_index_block();
18274
18280
  } finally {
18275
- process6.chdir(prev);
18281
+ process7.chdir(prev);
18276
18282
  }
18277
18283
  } catch (exc) {
18278
- process6.stderr.write(`hot-context-hook: session index skipped: ${String(exc)}
18284
+ process7.stderr.write(`hot-context-hook: session index skipped: ${String(exc)}
18279
18285
  `);
18280
18286
  return null;
18281
18287
  }
@@ -18296,7 +18302,7 @@ function main7() {
18296
18302
  } catch {
18297
18303
  }
18298
18304
  const event = String(envelope.event ?? "");
18299
- const root = String(envelope.workspace_root ?? process6.cwd());
18305
+ const root = String(envelope.workspace_root ?? process7.cwd());
18300
18306
  const payload = envelope.payload && typeof envelope.payload === "object" && !Array.isArray(envelope.payload) ? envelope.payload : {};
18301
18307
  try {
18302
18308
  if (_is_replay_mode2()) {
@@ -18317,7 +18323,7 @@ function main7() {
18317
18323
  blocks.push(indexBlock);
18318
18324
  }
18319
18325
  if (blocks.length > 0) {
18320
- process6.stdout.write(
18326
+ process7.stdout.write(
18321
18327
  JSON.stringify({
18322
18328
  decision: "allow",
18323
18329
  reason: decision.action === "inject" ? decision.reason : "memory session index",
@@ -18327,20 +18333,20 @@ function main7() {
18327
18333
  }
18328
18334
  }
18329
18335
  } catch (exc) {
18330
- process6.stderr.write(`hot-context-hook: ${String(exc)}
18336
+ process7.stderr.write(`hot-context-hook: ${String(exc)}
18331
18337
  `);
18332
18338
  }
18333
18339
  return 0;
18334
18340
  }
18335
18341
  var _bundled2 = true;
18336
- if (!_bundled2 && fileURLToPath10(import.meta.url) === path18.resolve(process6.argv[1] ?? "")) {
18337
- process6.exit(main7());
18342
+ if (!_bundled2 && fileURLToPath10(import.meta.url) === path18.resolve(process7.argv[1] ?? "")) {
18343
+ process7.exit(main7());
18338
18344
  }
18339
18345
 
18340
18346
  // src/scripts/handoff_context_hook.ts
18341
18347
  import * as fs23 from "node:fs";
18342
18348
  import * as path22 from "node:path";
18343
- import process7 from "node:process";
18349
+ import process8 from "node:process";
18344
18350
  import { fileURLToPath as fileURLToPath12 } from "node:url";
18345
18351
 
18346
18352
  // src/scripts/_lib/envelope_grounding.ts
@@ -19310,10 +19316,10 @@ var HANDOFF_CONTEXT_REL = path22.join("agents", "runtime", "state", "handoff-con
19310
19316
  var MAX_AGE_HOURS2 = 48;
19311
19317
  var REPLAY_ENV_VAR4 = "AGENT_CONFIG_REPLAY";
19312
19318
  function _is_replay_mode3() {
19313
- return (process7.env[REPLAY_ENV_VAR4] ?? "").trim() === "1";
19319
+ return (process8.env[REPLAY_ENV_VAR4] ?? "").trim() === "1";
19314
19320
  }
19315
19321
  function _handoff_context_path(root) {
19316
- return process7.env.AGENT_HANDOFF_CONTEXT_FILE || path22.join(root, HANDOFF_CONTEXT_REL);
19322
+ return process8.env.AGENT_HANDOFF_CONTEXT_FILE || path22.join(root, HANDOFF_CONTEXT_REL);
19317
19323
  }
19318
19324
  function guardedInjection(block, reason) {
19319
19325
  if (!hasBoundaryMarker(block)) {
@@ -19362,7 +19368,7 @@ function consume_handoff_context(root, now = /* @__PURE__ */ new Date()) {
19362
19368
  return guardedInjection(block, `handoff consumed (session=${sourceSession})`);
19363
19369
  }
19364
19370
  function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
19365
- const target = process7.env.AGENT_RECYCLE_ENVELOPE_FILE || path22.join(root, RECYCLE_ENVELOPE_REL);
19371
+ const target = process8.env.AGENT_RECYCLE_ENVELOPE_FILE || path22.join(root, RECYCLE_ENVELOPE_REL);
19366
19372
  let text;
19367
19373
  try {
19368
19374
  text = fs23.readFileSync(target, "utf-8");
@@ -19413,7 +19419,7 @@ function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
19413
19419
  }
19414
19420
  const drift = describeDrift(envelope, collectRepoAnchor(root));
19415
19421
  const warnings = scanEnvelopeDirectives(envelope);
19416
- const focus = (process7.env.AGENT_RESUME_FOCUS ?? "").trim();
19422
+ const focus = (process8.env.AGENT_RESUME_FOCUS ?? "").trim();
19417
19423
  const block = wrapAsPriorSessionData(JSON.stringify(envelope, null, 2), {
19418
19424
  kind: "recycle-envelope",
19419
19425
  source: RECYCLE_ENVELOPE_REL,
@@ -19443,7 +19449,7 @@ function main9() {
19443
19449
  } catch {
19444
19450
  }
19445
19451
  const event = String(envelope.event ?? "");
19446
- const root = String(envelope.workspace_root ?? process7.cwd());
19452
+ const root = String(envelope.workspace_root ?? process8.cwd());
19447
19453
  try {
19448
19454
  if (_is_replay_mode3()) {
19449
19455
  return 0;
@@ -19462,7 +19468,7 @@ function main9() {
19462
19468
  reasons.push(handoff.reason);
19463
19469
  }
19464
19470
  if (blocks.length > 0) {
19465
- process7.stdout.write(
19471
+ process8.stdout.write(
19466
19472
  JSON.stringify({
19467
19473
  decision: "allow",
19468
19474
  reason: reasons.join(" \xB7 "),
@@ -19472,14 +19478,14 @@ function main9() {
19472
19478
  }
19473
19479
  }
19474
19480
  } catch (exc) {
19475
- process7.stderr.write(`handoff-context-hook: ${String(exc)}
19481
+ process8.stderr.write(`handoff-context-hook: ${String(exc)}
19476
19482
  `);
19477
19483
  }
19478
19484
  return 0;
19479
19485
  }
19480
19486
  var _bundled3 = true;
19481
- if (!_bundled3 && fileURLToPath12(import.meta.url) === path22.resolve(process7.argv[1] ?? "")) {
19482
- process7.exit(main9());
19487
+ if (!_bundled3 && fileURLToPath12(import.meta.url) === path22.resolve(process8.argv[1] ?? "")) {
19488
+ process8.exit(main9());
19483
19489
  }
19484
19490
 
19485
19491
  // src/scripts/roadmap_progress_hook.ts
@@ -22010,7 +22016,7 @@ import * as path37 from "node:path";
22010
22016
  // src/scripts/_lib/claude_plugin.ts
22011
22017
  import * as os5 from "node:os";
22012
22018
  import * as path36 from "node:path";
22013
- import process8 from "node:process";
22019
+ import process9 from "node:process";
22014
22020
  var CLAUDE_PLUGIN_ID = "agent-config";
22015
22021
  var CLAUDE_MARKETPLACE_NAME = "event4u-agent-config";
22016
22022
  var CLAUDE_MARKETPLACE_REPO = "event4u-app/agent-config";
@@ -22026,7 +22032,7 @@ var CODEX_PLUGIN_INSTALL_HINT = [
22026
22032
  `claude plugin install ${CODEX_PLUGIN_ID}@${CODEX_MARKETPLACE_NAME}`
22027
22033
  ];
22028
22034
  function claude_config_dir() {
22029
- const env = (process8.env["CLAUDE_CONFIG_DIR"] ?? "").trim();
22035
+ const env = (process9.env["CLAUDE_CONFIG_DIR"] ?? "").trim();
22030
22036
  return env !== "" ? env : path36.join(os5.homedir(), ".claude");
22031
22037
  }
22032
22038
 
@@ -24393,7 +24399,7 @@ if (isCliEntry9()) {
24393
24399
  // src/scripts/session_register_hook.ts
24394
24400
  import * as fs53 from "node:fs";
24395
24401
  import * as path53 from "node:path";
24396
- import process9 from "node:process";
24402
+ import process10 from "node:process";
24397
24403
  import { fileURLToPath as fileURLToPath31 } from "node:url";
24398
24404
 
24399
24405
  // src/scripts/_lib/session_register.ts
@@ -24680,8 +24686,8 @@ function lockfile_path(env) {
24680
24686
  }
24681
24687
  return write_target("installed.lock", { env: env ?? null });
24682
24688
  }
24683
- function read_lockfile(path102) {
24684
- const target = path102 ?? lockfile_path();
24689
+ function read_lockfile(path105) {
24690
+ const target = path105 ?? lockfile_path();
24685
24691
  let text;
24686
24692
  try {
24687
24693
  text = fs51.readFileSync(target, { encoding: "utf-8" });
@@ -24937,7 +24943,7 @@ function claim_read_paths(workspace_root, session_id) {
24937
24943
  return out;
24938
24944
  }
24939
24945
  function _is_replay_mode4() {
24940
- return String(process9.env[REPLAY_ENV_VAR6] ?? "").trim() !== "";
24946
+ return String(process10.env[REPLAY_ENV_VAR6] ?? "").trim() !== "";
24941
24947
  }
24942
24948
  function _read_claim_file(file) {
24943
24949
  try {
@@ -25210,7 +25216,7 @@ function main28() {
25210
25216
  const payload = envelope["payload"];
25211
25217
  const payload_cwd = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload["cwd"] : null;
25212
25218
  const root = session_checkout(
25213
- String(envelope["workspace_root"] ?? process9.cwd()),
25219
+ String(envelope["workspace_root"] ?? process10.cwd()),
25214
25220
  typeof payload_cwd === "string" ? payload_cwd : null
25215
25221
  );
25216
25222
  const platform = String(envelope["platform"] ?? "generic").trim().toLowerCase();
@@ -25235,13 +25241,13 @@ function main28() {
25235
25241
  touch(root, session_id, platform, /* @__PURE__ */ new Date());
25236
25242
  if (event === "session_start") {
25237
25243
  if (!ttl_is_measured(platform)) {
25238
- process9.stderr.write(
25244
+ process10.stderr.write(
25239
25245
  `session-register: no measured turn cadence for platform "${platform}"; falling back to the conservative default TTL of ${Math.round(ttl_seconds_for(platform) / 3600)}h. A claim from this session may be held slightly too long after a crash \u2014 never released early.
25240
25246
  `
25241
25247
  );
25242
25248
  }
25243
25249
  if (!HEARTBEAT_REACHABLE_PLATFORMS.has(platform)) {
25244
- process9.stderr.write(
25250
+ process10.stderr.write(
25245
25251
  `session-register: platform "${platform}" has no reliably firing per-turn slot; this session will expire from the register after its TTL even while active.
25246
25252
  `
25247
25253
  );
@@ -25256,7 +25262,7 @@ function main28() {
25256
25262
  if (event === "session_start") {
25257
25263
  const block = foreign_sessions_block(root, session_id, /* @__PURE__ */ new Date());
25258
25264
  if (block !== null) {
25259
- process9.stdout.write(
25265
+ process10.stdout.write(
25260
25266
  JSON.stringify({
25261
25267
  decision: "allow",
25262
25268
  reason: "live foreign sessions on this repository",
@@ -25267,14 +25273,14 @@ function main28() {
25267
25273
  }
25268
25274
  }
25269
25275
  } catch (exc) {
25270
- process9.stderr.write(`session-register: ${String(exc)}
25276
+ process10.stderr.write(`session-register: ${String(exc)}
25271
25277
  `);
25272
25278
  }
25273
25279
  return 0;
25274
25280
  }
25275
25281
  var _bundled4 = true;
25276
- if (!_bundled4 && fileURLToPath31(import.meta.url) === path53.resolve(process9.argv[1] ?? "")) {
25277
- process9.exit(main28());
25282
+ if (!_bundled4 && fileURLToPath31(import.meta.url) === path53.resolve(process10.argv[1] ?? "")) {
25283
+ process10.exit(main28());
25278
25284
  }
25279
25285
 
25280
25286
  // src/scripts/language_mirror_hook.ts
@@ -25298,6 +25304,43 @@ function humanAuthoredLead(text) {
25298
25304
  }
25299
25305
  return kept.join("\n");
25300
25306
  }
25307
+ var REGION_OPEN = /^\s*<([A-Za-z][\w-]*)>\s*$/;
25308
+ var REGION_NOTE = /\b(content (above|below) is from|treat (it|this|that|the (content|text|above|following)) as data)\b/i;
25309
+ function stripInjectedRegions(text) {
25310
+ const lines = text.split("\n");
25311
+ const kept = [];
25312
+ for (let i = 0; i < lines.length; i++) {
25313
+ const line = lines[i] ?? "";
25314
+ const open = REGION_OPEN.exec(line);
25315
+ if (open === null) {
25316
+ kept.push(line);
25317
+ continue;
25318
+ }
25319
+ const close = new RegExp(`^\\s*</${open[1] ?? ""}>\\s*$`);
25320
+ let end = -1;
25321
+ for (let j = i + 1; j < lines.length; j++) {
25322
+ if (close.test(lines[j] ?? "")) {
25323
+ end = j;
25324
+ break;
25325
+ }
25326
+ }
25327
+ if (end === -1) {
25328
+ kept.push(line);
25329
+ continue;
25330
+ }
25331
+ if (kept.length > 0 && REGION_NOTE.test(kept[kept.length - 1] ?? "")) {
25332
+ kept.pop();
25333
+ }
25334
+ i = end;
25335
+ while (i + 1 < lines.length && (lines[i + 1] ?? "").trim() !== "") {
25336
+ if (!REGION_NOTE.test(lines[i + 1] ?? "")) {
25337
+ break;
25338
+ }
25339
+ i++;
25340
+ }
25341
+ }
25342
+ return kept.join("\n");
25343
+ }
25301
25344
 
25302
25345
  // src/scripts/language_mirror_hook.ts
25303
25346
  var EXIT_ALLOW9 = 0;
@@ -25344,7 +25387,7 @@ function instructionText(prompt) {
25344
25387
  return kept.join("\n");
25345
25388
  }
25346
25389
  function classify(prompt) {
25347
- const text = instructionText(prompt);
25390
+ const text = instructionText(stripInjectedRegions(prompt));
25348
25391
  const lead = humanAuthoredLead(text);
25349
25392
  const leadVerdict = _score2(lead);
25350
25393
  if (leadVerdict.language !== "und") {
@@ -27169,15 +27212,15 @@ function targets_kernel_rule(filePath) {
27169
27212
  if (segments.length === 0) {
27170
27213
  return null;
27171
27214
  }
27172
- const basename11 = segments[segments.length - 1];
27173
- if (!is_kernel_rule(basename11)) {
27215
+ const basename12 = segments[segments.length - 1];
27216
+ if (!is_kernel_rule(basename12)) {
27174
27217
  return null;
27175
27218
  }
27176
27219
  const dirSegments = segments.slice(0, -1);
27177
27220
  if (!dirSegments.includes("rules")) {
27178
27221
  return null;
27179
27222
  }
27180
- return basename11.replace(/\.md$/, "");
27223
+ return basename12.replace(/\.md$/, "");
27181
27224
  }
27182
27225
  var _MUTATOR_VERBS = /* @__PURE__ */ new Set([
27183
27226
  "sed",
@@ -30406,7 +30449,7 @@ import path74 from "node:path";
30406
30449
  import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL42 } from "node:url";
30407
30450
 
30408
30451
  // src/scripts/_lib/host_capability.ts
30409
- import process10 from "node:process";
30452
+ import process11 from "node:process";
30410
30453
  var SAFE_DEFAULT = {
30411
30454
  schema_version: 1,
30412
30455
  subagent_spawn: false,
@@ -30449,7 +30492,7 @@ function resolveHostCapabilities(hostId, override) {
30449
30492
  }
30450
30493
  function probeHostCapabilities(hostId) {
30451
30494
  const base = resolveHostCapabilities(hostId);
30452
- const flag = process10.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
30495
+ const flag = process11.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
30453
30496
  const probedAgentTeams = typeof flag === "string" && flag !== "";
30454
30497
  return { ...base, agent_teams: base.agent_teams || probedAgentTeams };
30455
30498
  }
@@ -31666,7 +31709,7 @@ if (_isCliEntry37()) {
31666
31709
  // src/scripts/hooks/rule_inject_hook.ts
31667
31710
  import * as fs79 from "node:fs";
31668
31711
  import * as path79 from "node:path";
31669
- import process11 from "node:process";
31712
+ import process12 from "node:process";
31670
31713
  import { fileURLToPath as fileURLToPath51, pathToFileURL as pathToFileURL45 } from "node:url";
31671
31714
 
31672
31715
  // src/scripts/_lib/lean_projection_mode.ts
@@ -31918,13 +31961,19 @@ function loadRuleBody(repoRoot, id) {
31918
31961
  function bytesOf(text) {
31919
31962
  return Buffer.byteLength(text, "utf8");
31920
31963
  }
31921
- function selectForInjection(repoRoot, matches, capBytes) {
31964
+ function selectForInjection(repoRoot, matches, capBytes, shortlist) {
31922
31965
  const bodyBytes2 = /* @__PURE__ */ new Map();
31923
31966
  for (const m of matches) {
31924
31967
  const body = loadRuleBody(repoRoot, m.id);
31925
31968
  bodyBytes2.set(m.id, body === null ? 0 : bytesOf(body));
31926
31969
  }
31927
- const ranked = [...matches].sort((a, b) => b.score - a.score || a.order - b.order);
31970
+ const rank2 = /* @__PURE__ */ new Map();
31971
+ for (const [i, id] of (shortlist ?? []).entries()) {
31972
+ if (!rank2.has(id)) rank2.set(id, i);
31973
+ }
31974
+ const ranked = [...matches].sort(
31975
+ (a, b) => b.score - a.score || (rank2.get(a.id) ?? Infinity) - (rank2.get(b.id) ?? Infinity) || a.order - b.order
31976
+ );
31928
31977
  const selected = [];
31929
31978
  const dropped = [];
31930
31979
  let total = 0;
@@ -31958,7 +32007,7 @@ function str5(o, ...keys) {
31958
32007
  return null;
31959
32008
  }
31960
32009
  function workspaceRoot2(env) {
31961
- return str5(env, "workspace", "cwd", "project_dir") ?? process11.cwd();
32010
+ return str5(env, "workspace", "cwd", "project_dir") ?? process12.cwd();
31962
32011
  }
31963
32012
  function statePath(root, session) {
31964
32013
  const safe = session.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 80) || "unknown";
@@ -32026,9 +32075,9 @@ ${body.trim()}
32026
32075
  function gateOpen(root, cliEntry) {
32027
32076
  if (deliversBodies(normalizeLeanProjectionMode(leanProjectionModeRaw(root)))) return true;
32028
32077
  if (hookSectionEnabled(root, "rule_inject")) return true;
32029
- return cliEntry && process11.env["AGENT_CONFIG_REPLAY"] !== "1";
32078
+ return cliEntry && process12.env["AGENT_CONFIG_REPLAY"] !== "1";
32030
32079
  }
32031
- function main50(argv = process11.argv.slice(2)) {
32080
+ function main50(argv = process12.argv.slice(2)) {
32032
32081
  let eventOverride = null;
32033
32082
  for (let i = 0; i < argv.length; i += 1) {
32034
32083
  if (argv[i] === "--event") {
@@ -32074,7 +32123,7 @@ function main50(argv = process11.argv.slice(2)) {
32074
32123
  if (injection === null) return EXIT_ALLOW24;
32075
32124
  for (const id of injection.rules) seen.add(id);
32076
32125
  writeSeen(root, session, seen);
32077
- process11.stdout.write(
32126
+ process12.stdout.write(
32078
32127
  `${JSON.stringify({
32079
32128
  decision: "warn",
32080
32129
  reason: `rule-inject: ${injection.rules.length} rule body/bodies on ${slot} (${injection.bytes} B)`,
@@ -32086,17 +32135,17 @@ function main50(argv = process11.argv.slice(2)) {
32086
32135
  }
32087
32136
  function _isCliEntry38() {
32088
32137
  if (true) return false;
32089
- if (process11.argv[1] === void 0) return false;
32090
- const argvUrl = pathToFileURL45(path79.resolve(process11.argv[1])).href;
32138
+ if (process12.argv[1] === void 0) return false;
32139
+ const argvUrl = pathToFileURL45(path79.resolve(process12.argv[1])).href;
32091
32140
  if (import.meta.url === argvUrl) return true;
32092
32141
  try {
32093
- return fs79.realpathSync(fileURLToPath51(import.meta.url)) === fs79.realpathSync(path79.resolve(process11.argv[1]));
32142
+ return fs79.realpathSync(fileURLToPath51(import.meta.url)) === fs79.realpathSync(path79.resolve(process12.argv[1]));
32094
32143
  } catch {
32095
32144
  return false;
32096
32145
  }
32097
32146
  }
32098
32147
  if (_isCliEntry38()) {
32099
- process11.exit(main50());
32148
+ process12.exit(main50());
32100
32149
  }
32101
32150
 
32102
32151
  // src/scripts/hooks/end_review_nudge_hook.ts
@@ -32164,8 +32213,8 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
32164
32213
  try {
32165
32214
  const realHome = fs80.realpathSync(homeDir);
32166
32215
  const realPath = fs80.realpathSync(rawPath);
32167
- const relative10 = path80.relative(realHome, realPath);
32168
- if (relative10 === "" || relative10.startsWith("..") || path80.isAbsolute(relative10)) {
32216
+ const relative11 = path80.relative(realHome, realPath);
32217
+ if (relative11 === "" || relative11.startsWith("..") || path80.isAbsolute(relative11)) {
32169
32218
  return false;
32170
32219
  }
32171
32220
  const { size } = fs80.statSync(realPath);
@@ -33488,13 +33537,690 @@ if (_isCliEntry42()) {
33488
33537
  process.exit(main54());
33489
33538
  }
33490
33539
 
33491
- // src/scripts/hooks/reread_guard_hook.ts
33492
- import * as crypto12 from "node:crypto";
33540
+ // src/scripts/hooks/comment_discipline_hook.ts
33541
+ import * as fs85 from "node:fs";
33542
+ import * as path86 from "node:path";
33543
+ import { fileURLToPath as fileURLToPath57, pathToFileURL as pathToFileURL50 } from "node:url";
33544
+
33545
+ // src/scripts/lint_code_comments.ts
33546
+ import { spawnSync as spawnSync9 } from "node:child_process";
33493
33547
  import * as fs84 from "node:fs";
33548
+ import * as os11 from "node:os";
33549
+ import * as path85 from "node:path";
33550
+ import process14 from "node:process";
33551
+ import { fileURLToPath as fileURLToPath56 } from "node:url";
33552
+
33553
+ // src/scripts/_lib/gate_self_test.ts
33554
+ import { spawnSync as spawnSync8 } from "node:child_process";
33494
33555
  import * as path84 from "node:path";
33495
- import { fileURLToPath as fileURLToPath56, pathToFileURL as pathToFileURL50 } from "node:url";
33556
+ import process13 from "node:process";
33557
+ function runGateCli(repoRoot, scriptRelPath, args, cwd) {
33558
+ const tsx = path84.join(
33559
+ repoRoot,
33560
+ "node_modules",
33561
+ ".bin",
33562
+ process13.platform === "win32" ? "tsx.cmd" : "tsx"
33563
+ );
33564
+ const res = spawnSync8(tsx, [path84.join(repoRoot, scriptRelPath), ...args], {
33565
+ cwd,
33566
+ encoding: "utf-8",
33567
+ maxBuffer: 64 * 1024 * 1024,
33568
+ // The child must not recurse into its own self-test.
33569
+ env: { ...process13.env, GATE_SELF_TEST_CHILD: "1" }
33570
+ });
33571
+ return res.status ?? 1;
33572
+ }
33573
+ function runSelfTest(opts) {
33574
+ const write = opts.write ?? process13.stdout.write.bind(process13.stdout);
33575
+ const minReject = opts.minRejectCases ?? 1;
33576
+ const rejectCases = opts.cases.filter((c) => c.expect === "reject").length;
33577
+ if (opts.cases.length < opts.minCases || rejectCases < minReject) {
33578
+ write(
33579
+ `\u274C ${opts.gate} --self-test: ${String(opts.cases.length)} case(s) (${String(rejectCases)} rejecting) is below the declared floor of ${String(opts.minCases)} (${String(minReject)} rejecting). A truncated self-test must fail rather than print success \u2014 deleting cases is otherwise the cheapest route to a green one.
33580
+ `
33581
+ );
33582
+ return 1;
33583
+ }
33584
+ let failed = 0;
33585
+ for (const testCase of opts.cases) {
33586
+ let exit;
33587
+ try {
33588
+ exit = testCase.run();
33589
+ } catch (e) {
33590
+ write(`\u274C ${opts.gate} --self-test: ${testCase.name} \u2014 threw: ${String(e)}
33591
+ `);
33592
+ failed += 1;
33593
+ continue;
33594
+ }
33595
+ const behaved = testCase.expect === "reject" ? exit !== 0 : exit === 0;
33596
+ if (behaved) {
33597
+ write(`\u2705 ${testCase.name} (expected ${testCase.expect}, exit ${String(exit)})
33598
+ `);
33599
+ } else {
33600
+ write(
33601
+ `\u274C ${testCase.name}: expected the gate to ${testCase.expect} this fixture, got exit ${String(exit)}. The gate's detection has stopped firing on a case it is supposed to catch.
33602
+ `
33603
+ );
33604
+ failed += 1;
33605
+ }
33606
+ }
33607
+ write(
33608
+ `
33609
+ ${opts.gate} --self-test: ${String(opts.cases.length - failed)}/${String(opts.cases.length)} case(s) behaved (${String(rejectCases)} rejecting, floor ${String(opts.minCases)})
33610
+ `
33611
+ );
33612
+ return failed > 0 ? 1 : 0;
33613
+ }
33614
+
33615
+ // src/scripts/lint_code_comments.ts
33616
+ var _HERE10 = fileURLToPath56(import.meta.url);
33617
+ var SCANNED_EXTENSIONS = /* @__PURE__ */ new Set([
33618
+ ".ts",
33619
+ ".tsx",
33620
+ ".js",
33621
+ ".jsx",
33622
+ ".mjs",
33623
+ ".cjs",
33624
+ ".css",
33625
+ ".scss",
33626
+ ".less",
33627
+ ".php",
33628
+ ".py",
33629
+ ".go",
33630
+ ".rs",
33631
+ ".java",
33632
+ ".kt",
33633
+ ".swift",
33634
+ ".rb",
33635
+ ".vue",
33636
+ ".svelte"
33637
+ ]);
33638
+ var SKIP_SEGMENTS = ["node_modules/", "dist/", "build/", ".next/", "vendor/", "coverage/"];
33639
+ var GENERATED_MARKERS = [
33640
+ "generated by",
33641
+ "auto-generated",
33642
+ "autogenerated",
33643
+ "@generated",
33644
+ "do not edit",
33645
+ "code generated by"
33646
+ ];
33647
+ var COMMENT_LINE = /^\s*(\{\s*)?(\/\/|\/\*|\*(?!\/)|\*\/|#(?!!)|--)/;
33648
+ function opensBlock(line) {
33649
+ const lastOpen = line.lastIndexOf("/*");
33650
+ if (lastOpen === -1) return false;
33651
+ return line.indexOf("*/", lastOpen + 2) === -1;
33652
+ }
33653
+ function closesBlock(line) {
33654
+ return line.includes("*/");
33655
+ }
33656
+ var DE_CHARS = /[äöüßÄÖÜ]/;
33657
+ var DE_WORDS = new RegExp(
33658
+ "\\b(" + [
33659
+ "der",
33660
+ "das",
33661
+ "dem",
33662
+ "den",
33663
+ "des",
33664
+ "und",
33665
+ "oder",
33666
+ "aber",
33667
+ "sondern",
33668
+ "denn",
33669
+ "nicht",
33670
+ "kein",
33671
+ "keine",
33672
+ "keiner",
33673
+ "keinen",
33674
+ "wird",
33675
+ "werden",
33676
+ "wurde",
33677
+ "worden",
33678
+ "sind",
33679
+ "waren",
33680
+ "eine",
33681
+ "einen",
33682
+ "einem",
33683
+ "einer",
33684
+ "eines",
33685
+ "dass",
33686
+ "weil",
33687
+ "damit",
33688
+ "wenn",
33689
+ "dann",
33690
+ "sonst",
33691
+ "obwohl",
33692
+ "hier",
33693
+ "dort",
33694
+ "oben",
33695
+ "unten",
33696
+ "auch",
33697
+ "nur",
33698
+ "schon",
33699
+ "noch",
33700
+ "aus",
33701
+ "fuer",
33702
+ "ueber",
33703
+ "durch",
33704
+ "gegen",
33705
+ "ohne",
33706
+ "nach",
33707
+ "vor",
33708
+ "beim",
33709
+ "zum",
33710
+ "zur",
33711
+ "vom",
33712
+ "mit",
33713
+ "sich",
33714
+ "ihre",
33715
+ "ihrer",
33716
+ "seine",
33717
+ "jede",
33718
+ "jeder",
33719
+ "jedes",
33720
+ "alle",
33721
+ "allen",
33722
+ "aller",
33723
+ "diese",
33724
+ "dieser",
33725
+ "dieses",
33726
+ "diesem",
33727
+ "steht",
33728
+ "stehen",
33729
+ "haben",
33730
+ "kann",
33731
+ "koennen",
33732
+ "muss",
33733
+ "muessen",
33734
+ "soll",
33735
+ "sollte",
33736
+ "gibt",
33737
+ "geht",
33738
+ "macht",
33739
+ "zeigt",
33740
+ "liegt",
33741
+ "deshalb",
33742
+ "deswegen",
33743
+ "trotzdem",
33744
+ "bereits",
33745
+ "immer",
33746
+ "niemals",
33747
+ "derselbe",
33748
+ "dieselbe",
33749
+ "dasselbe",
33750
+ "denselben",
33751
+ "demselben",
33752
+ "derselben",
33753
+ "andere",
33754
+ "anderer",
33755
+ "anderen",
33756
+ "anderem",
33757
+ "anderes",
33758
+ "unter",
33759
+ "ueber",
33760
+ "zwischen",
33761
+ "wegen",
33762
+ "statt",
33763
+ "ausser",
33764
+ "seit",
33765
+ "eigene",
33766
+ "eigenen",
33767
+ "eigener",
33768
+ "jeweils",
33769
+ "genau",
33770
+ "etwa",
33771
+ "sowohl",
33772
+ "warum",
33773
+ "wieso",
33774
+ "welche",
33775
+ "welcher",
33776
+ "wobei",
33777
+ "sowie"
33778
+ ].join("|") + ")\\b",
33779
+ "gi"
33780
+ );
33781
+ var REPORT_SIGNALS = [
33782
+ ["markdown-table", /^\s*(?:\/\/|\*|#|--)?\s*\|[^|]*\|[^|]*\|/],
33783
+ ["box-rule", /[─═━]{10,}/],
33784
+ ["section-mark", /^\s*(?:\/\/|\*|#|--)?\s*§\s+\S/],
33785
+ ["markdown-heading", /^\s*(?:\/\/|\*|#|--)?\s*#{2,}\s+\S/],
33786
+ ["revisit-if", /\brevisit-if\b/i]
33787
+ ];
33788
+ var PROVENANCE_SIGNALS = [
33789
+ ["roadmap-path", /\bagents\/roadmaps?\//i],
33790
+ ["reference-path", /\bagents\/(references|evidence|decisions)\//i],
33791
+ ["phase-step", /\b(phase|phase)\s*\d+\s*,\s*(step|schritt)\s*\d+/i],
33792
+ ["prototype-source", /\b(prototyp\w*|prototype)\b[^\n]{0,40}\.(html|fig|sketch|dc\.html)\b/i]
33793
+ ];
33794
+ function escapedFor(line, cls) {
33795
+ const m = /code-comment-allow\s+([a-z-]+|\*)\s*--\s*(\S.*)$/.exec(line);
33796
+ if (!m) return false;
33797
+ const target = m[1];
33798
+ return target === "*" || target === cls;
33799
+ }
33800
+ function fileIsExempt(text) {
33801
+ const head = text.slice(0, 2e3).toLowerCase();
33802
+ if (GENERATED_MARKERS.some((m) => head.includes(m))) return true;
33803
+ return /code-comment-allow-file\s*--\s*\S/.test(text.slice(0, 2e3));
33804
+ }
33805
+ function germanWordCount(s) {
33806
+ return new Set((s.match(DE_WORDS) ?? []).map((h) => h.toLowerCase())).size;
33807
+ }
33808
+ function commentProse(line) {
33809
+ return line.replace(/^\s*(\/\/+|\/\*+|\*+\/?|#+|--)/, " ");
33810
+ }
33811
+ function prosePlain(line) {
33812
+ return commentProse(line).replace(/`[^`]*`/g, " ").replace(/'[^']*'/g, " ").replace(/"[^"]*"/g, " ").replace(/[\u201c\u201e][^\u201c\u201d\u201e]*[\u201d\u201c]/g, " ").replace(/[\u2018\u201a][^\u2018\u2019\u201a]*[\u2019\u2018]/g, " ").replace(/\u00bb[^\u00ab\u00bb]*\u00ab/g, " ").replace(/[\u201c\u201e][^\u201c\u201d\u201e]*$/, " ").replace(
33813
+ /"[^"]*$/,
33814
+ (m, offset, whole) => germanWordCount(whole.slice(0, offset)) >= 2 ? m : " "
33815
+ );
33816
+ }
33817
+ function scanText2(file, text) {
33818
+ if (fileIsExempt(text)) return [];
33819
+ const out = [];
33820
+ const lines = text.split("\n");
33821
+ let inQuote = false;
33822
+ let inBlock = false;
33823
+ for (let i = 0; i < lines.length; i++) {
33824
+ const raw = lines[i] ?? "";
33825
+ const isComment = inBlock || COMMENT_LINE.test(raw);
33826
+ if (inBlock && closesBlock(raw)) inBlock = false;
33827
+ else if (!inBlock && opensBlock(raw)) inBlock = true;
33828
+ if (!isComment) {
33829
+ inQuote = false;
33830
+ continue;
33831
+ }
33832
+ const prose = commentProse(raw);
33833
+ const opensBefore = inQuote;
33834
+ const marks = (commentProse(raw).match(/[\u201c\u201d\u201e"]/g) ?? []).length;
33835
+ if (marks % 2 === 1) inQuote = !inQuote;
33836
+ if (opensBefore) continue;
33837
+ const at = i + 1;
33838
+ const snip = raw.trim().slice(0, 100);
33839
+ if (!escapedFor(raw, "de-comment")) {
33840
+ const plain = prosePlain(raw);
33841
+ const distinct = new Set((plain.match(DE_WORDS) ?? []).map((h) => h.toLowerCase()));
33842
+ const umlaut = DE_CHARS.test(plain);
33843
+ const isGerman = distinct.size >= 2 || umlaut && distinct.size >= 1;
33844
+ if (isGerman) {
33845
+ out.push({
33846
+ cls: "de-comment",
33847
+ file,
33848
+ line: at,
33849
+ signal: umlaut ? `umlaut+${[...distinct][0]}` : `function-words: ${[...distinct].slice(0, 4).join(" ")}`,
33850
+ snippet: snip
33851
+ });
33852
+ }
33853
+ }
33854
+ if (!escapedFor(raw, "report-comment")) {
33855
+ for (const [name, re] of REPORT_SIGNALS) {
33856
+ if (re.test(raw)) {
33857
+ out.push({ cls: "report-comment", file, line: at, signal: name, snippet: snip });
33858
+ break;
33859
+ }
33860
+ }
33861
+ }
33862
+ if (!escapedFor(raw, "provenance-comment")) {
33863
+ for (const [name, re] of PROVENANCE_SIGNALS) {
33864
+ if (re.test(prose)) {
33865
+ out.push({ cls: "provenance-comment", file, line: at, signal: name, snippet: snip });
33866
+ break;
33867
+ }
33868
+ }
33869
+ }
33870
+ }
33871
+ return out;
33872
+ }
33873
+ function isScannable(rel) {
33874
+ if (SKIP_SEGMENTS.some((s) => rel.includes(s))) return false;
33875
+ if (rel.endsWith(".d.ts")) return false;
33876
+ return SCANNED_EXTENSIONS.has(path85.extname(rel));
33877
+ }
33878
+ function changedFiles(root, base) {
33879
+ const r = spawnSync9("git", ["diff", "--name-only", "--diff-filter=ACMR", `${base}...HEAD`], {
33880
+ cwd: root,
33881
+ encoding: "utf-8"
33882
+ });
33883
+ const tracked = r.status === 0 ? r.stdout.split("\n") : [];
33884
+ const u = spawnSync9("git", ["ls-files", "--others", "--exclude-standard"], {
33885
+ cwd: root,
33886
+ encoding: "utf-8"
33887
+ });
33888
+ const untracked = u.status === 0 ? u.stdout.split("\n") : [];
33889
+ const m = spawnSync9("git", ["diff", "--name-only", "--diff-filter=ACMR"], {
33890
+ cwd: root,
33891
+ encoding: "utf-8"
33892
+ });
33893
+ const dirty = m.status === 0 ? m.stdout.split("\n") : [];
33894
+ return [.../* @__PURE__ */ new Set([...tracked, ...untracked, ...dirty])].filter((f) => f.trim().length > 0);
33895
+ }
33896
+ var COMMENT_CASES = [
33897
+ {
33898
+ name: "a block-comment continuation carrying no leading star is flagged",
33899
+ source: " /* Hausform mit Objekt-`message`: derselbe Aufbau, anderer Schluessel.\n `BaseException::render()` dekodiert eine JSON-Zeichenkette und legt das\n Ergebnis unter `message` ab, bei Feldfehlern ist das ein Objekt. */\n if (isRecord(payload.message)) {\n",
33900
+ flags: ["de-comment"]
33901
+ },
33902
+ {
33903
+ name: "a JSX comment, which opens with a brace rather than a slash, is flagged",
33904
+ source: " {/* Der Titel traegt die Aktion, nicht die Zeile. */}\n",
33905
+ flags: ["de-comment"]
33906
+ },
33907
+ {
33908
+ name: "a German comment line carrying two function words is flagged",
33909
+ source: "// Hier stehen nur die Werte, die Bedeutung tragen\nconst a = 1;\n",
33910
+ flags: ["de-comment"]
33911
+ },
33912
+ {
33913
+ name: "transliterated German with no umlaut at all is flagged",
33914
+ source: "/* uebersetzt aus dem Prototyp, jeder Wert ist hier belegt */\n",
33915
+ flags: ["de-comment"]
33916
+ },
33917
+ {
33918
+ name: "a German line whose only umlaut sits in ordinary prose is flagged",
33919
+ source: "// Die Schriftstufen der kompakten Datenoberfl\xE4che\n",
33920
+ flags: ["de-comment"]
33921
+ },
33922
+ {
33923
+ name: "an English comment quoting a non-ASCII sample value stays silent",
33924
+ source: "/** so a `caf\xE9@ex\xE4mple.com` email or a `/Users/m\xF6chte/f` path masks */\n",
33925
+ flags: []
33926
+ },
33927
+ {
33928
+ name: "an English comment carrying an umlauted proper name stays silent",
33929
+ source: "/** Robertson\u2013Sp\xE4rck-Jones IDF, floored at 0 so terms never subtract. */\n",
33930
+ flags: []
33931
+ },
33932
+ {
33933
+ name: "an umlauted step label in English prose stays silent",
33934
+ source: "// \u2500\u2500 \xDC2 \u2014 orthogonal stance assignment per seat \u2500\u2500\n",
33935
+ flags: []
33936
+ },
33937
+ {
33938
+ name: "a single-line German user quotation used as data stays silent",
33939
+ source: '// the phrase "nicht releasen. Warum nicht?" names no fault\n',
33940
+ flags: []
33941
+ },
33942
+ {
33943
+ name: "a German user quotation spanning two comment lines stays silent",
33944
+ source: '/**\n * "Kein Council konfiguriert (keine `.agent-settings.yml`) \u2014 ich nutze\n * Subagenten-F\xE4cher mit gegnerischen Linsen als Ersatz"\n */\n',
33945
+ flags: []
33946
+ },
33947
+ {
33948
+ name: "plain English prose stays silent",
33949
+ source: "// The cap is a stated default, not a measured optimum.\n",
33950
+ flags: []
33951
+ },
33952
+ {
33953
+ name: "a markdown table inside a comment is flagged",
33954
+ source: " * | Prototype | Role | here |\n",
33955
+ flags: ["report-comment"]
33956
+ },
33957
+ {
33958
+ name: "a box-drawing rule is flagged",
33959
+ source: " * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n",
33960
+ flags: ["report-comment"]
33961
+ },
33962
+ {
33963
+ name: "a revisit clause is flagged",
33964
+ source: " * Revisit-if: someone holds the new surface next to the sidebar.\n",
33965
+ flags: ["report-comment"]
33966
+ },
33967
+ {
33968
+ name: "a short dash rule that is not a report stays silent",
33969
+ source: "// --- setup ---\n",
33970
+ flags: []
33971
+ },
33972
+ {
33973
+ name: "a roadmap citation is flagged",
33974
+ source: "// see agents/roadmaps/todos-task-module-frontend.md\n",
33975
+ flags: ["provenance-comment"]
33976
+ },
33977
+ {
33978
+ name: "a phase-and-step citation is flagged",
33979
+ source: "// Roadmap todos-task-module, Phase 1, Schritt 1.\n",
33980
+ flags: ["provenance-comment"]
33981
+ },
33982
+ {
33983
+ name: "a plain code reference stays silent",
33984
+ source: "// see src/lib/token.ts for the parser\n",
33985
+ flags: []
33986
+ },
33987
+ {
33988
+ name: "a per-line escape carrying a reason suppresses the class",
33989
+ source: "// Hier stehen die Werte code-comment-allow de-comment -- quoted spec text\n",
33990
+ flags: []
33991
+ },
33992
+ {
33993
+ name: "a bare escape with no reason suppresses nothing",
33994
+ source: "// Hier stehen die Werte code-comment-allow de-comment\n",
33995
+ flags: ["de-comment"]
33996
+ }
33997
+ ];
33998
+ function selfTest() {
33999
+ const repoRoot = path85.resolve(path85.dirname(_HERE10), "..", "..");
34000
+ const dir = fs84.mkdtempSync(path85.join(os11.tmpdir(), "lcc-selftest-"));
34001
+ const exercise = (testCase, index) => {
34002
+ const file = path85.join(dir, `case-${String(index)}.ts`);
34003
+ fs84.writeFileSync(file, testCase.source, "utf-8");
34004
+ return runGateCli(repoRoot, "src/scripts/lint_code_comments.ts", ["--paths", file], dir);
34005
+ };
34006
+ try {
34007
+ return runSelfTest({
34008
+ gate: "lint_code_comments",
34009
+ minCases: 16,
34010
+ minRejectCases: 8,
34011
+ cases: COMMENT_CASES.map((testCase, index) => ({
34012
+ name: testCase.name,
34013
+ expect: testCase.flags.length > 0 ? "reject" : "accept",
34014
+ run: () => exercise(testCase, index)
34015
+ }))
34016
+ });
34017
+ } finally {
34018
+ fs84.rmSync(dir, { recursive: true, force: true });
34019
+ }
34020
+ }
34021
+ var HELP = `usage: lint_code_comments [--base <ref>] [--root <dir>] [--paths <f> \u2026] [--report]
34022
+
34023
+ --base <ref> diff against this ref (default: origin/main)
34024
+ --root <dir> run against another checkout (default: this repository)
34025
+ --paths scan exactly these files, ignoring the diff
34026
+ --report print every finding grouped by file and exit 0
34027
+ --self-test drive this binary over its own fixture table and exit 0 on pass
34028
+
34029
+ Classes: de-comment \xB7 report-comment \xB7 provenance-comment
34030
+ Escape: code-comment-allow <class|*> -- <reason> (per line)
34031
+ code-comment-allow-file -- <reason> (first 2000 chars)
34032
+ `;
34033
+ function main55(argv) {
34034
+ if (argv.includes("--help") || argv.includes("-h")) {
34035
+ process14.stdout.write(HELP);
34036
+ return 0;
34037
+ }
34038
+ if (argv.includes("--self-test")) {
34039
+ if (process14.env["GATE_SELF_TEST_CHILD"] === "1") {
34040
+ process14.stderr.write("lint_code_comments: refusing to nest --self-test inside a self-test child\n");
34041
+ return 2;
34042
+ }
34043
+ return selfTest();
34044
+ }
34045
+ let base = "origin/main";
34046
+ let root = path85.resolve(path85.dirname(_HERE10), "..", "..");
34047
+ let reportOnly = false;
34048
+ const explicit = [];
34049
+ for (let i = 0; i < argv.length; i++) {
34050
+ const a = argv[i];
34051
+ if (a === "--help" || a === "-h") {
34052
+ process14.stdout.write(HELP);
34053
+ return 0;
34054
+ } else if (a === "--base") {
34055
+ base = argv[++i] ?? "";
34056
+ } else if (a === "--root") {
34057
+ root = path85.resolve(argv[++i] ?? ".");
34058
+ } else if (a === "--report") {
34059
+ reportOnly = true;
34060
+ } else if (a === "--paths") {
34061
+ while (i + 1 < argv.length && !argv[i + 1].startsWith("--")) explicit.push(argv[++i]);
34062
+ } else {
34063
+ process14.stderr.write(`lint_code_comments: unknown argument ${a}
34064
+ ${HELP}`);
34065
+ return 1;
34066
+ }
34067
+ }
34068
+ if (!base && explicit.length === 0) {
34069
+ process14.stderr.write("--base needs a ref\n");
34070
+ return 1;
34071
+ }
34072
+ const candidates = (explicit.length > 0 ? explicit : changedFiles(root, base)).filter(isScannable);
34073
+ const findings = [];
34074
+ for (const rel of candidates) {
34075
+ const abs = path85.isAbsolute(rel) ? rel : path85.join(root, rel);
34076
+ let text;
34077
+ try {
34078
+ text = fs84.readFileSync(abs, "utf-8");
34079
+ } catch {
34080
+ continue;
34081
+ }
34082
+ findings.push(...scanText2(rel, text));
34083
+ }
34084
+ try {
34085
+ reportScanned({
34086
+ gate: "lint_code_comments",
34087
+ scanned: candidates.length,
34088
+ units: "source file(s)",
34089
+ roots: explicit.length > 0 ? explicit.slice(0, 4) : [`git diff ${base}...HEAD`],
34090
+ allowEmpty: "EMPTY_VALID: the scan root is a DIFF, and a diff with no source file in it is the normal case for a docs-only or config-only change. git already answered for the range: an unreadable ref yields no candidates AND no findings, which is indistinguishable here from a clean docs commit, so this gate deliberately does not treat zero as a dead scope. The scope failure this class exists to catch \u2014 a moved source tree \u2014 cannot occur, because there is no committed path list to go stale."
34091
+ });
34092
+ } catch (e) {
34093
+ if (e instanceof DeadScopeError) {
34094
+ process14.stderr.write(`\u274C ${e.message}
34095
+ `);
34096
+ return 1;
34097
+ }
34098
+ throw e;
34099
+ }
34100
+ process14.stdout.write(` against ${explicit.length > 0 ? "an explicit path list" : base}
34101
+ `);
34102
+ if (findings.length === 0) {
34103
+ process14.stdout.write("\u2705 lint_code_comments: no German, report-shaped or provenance comments.\n");
34104
+ return 0;
34105
+ }
34106
+ const byFile = /* @__PURE__ */ new Map();
34107
+ for (const f of findings) {
34108
+ const l = byFile.get(f.file) ?? [];
34109
+ l.push(f);
34110
+ byFile.set(f.file, l);
34111
+ }
34112
+ for (const [file, list] of [...byFile].sort()) {
34113
+ process14.stdout.write(`
34114
+ ${file} (${list.length})
34115
+ `);
34116
+ for (const f of list.slice(0, 8)) {
34117
+ process14.stdout.write(` ${String(f.line).padStart(5)} ${f.cls}/${f.signal} ${f.snippet}
34118
+ `);
34119
+ }
34120
+ if (list.length > 8) process14.stdout.write(` \u2026 ${list.length - 8} more in this file
34121
+ `);
34122
+ }
34123
+ const counts = /* @__PURE__ */ new Map();
34124
+ for (const f of findings) counts.set(f.cls, (counts.get(f.cls) ?? 0) + 1);
34125
+ process14.stdout.write(`
34126
+ ${[...counts].map(([c, n]) => `${c}: ${n}`).join(" \xB7 ")} across ${byFile.size} file(s)
34127
+ `);
34128
+ if (reportOnly) return 0;
34129
+ process14.stderr.write(
34130
+ "\n\u274C lint_code_comments: comments carry language, evidence or report structure that does not belong in source.\n A comment states a WHY or a constraint the code cannot show, in English. Evidence belongs in the\n roadmap that asked for it. Rewrite the comment, delete it, or escape one line with\n `code-comment-allow <class> -- <reason>`.\n"
34131
+ );
34132
+ return 2;
34133
+ }
34134
+ var _isMain6 = (() => {
34135
+ const entry = process14.argv[1];
34136
+ if (!entry) return false;
34137
+ try {
34138
+ return fs84.realpathSync(entry) === fs84.realpathSync(_HERE10);
34139
+ } catch {
34140
+ return false;
34141
+ }
34142
+ })();
34143
+ if (_isMain6) process14.exit(main55(process14.argv.slice(2)));
34144
+
34145
+ // src/scripts/hooks/comment_discipline_hook.ts
33496
34146
  var EXIT_ALLOW28 = 0;
33497
34147
  var EXIT_WARN15 = 2;
34148
+ var MAX_REPORTED = 3;
34149
+ function str10(v) {
34150
+ return typeof v === "string" ? v : "";
34151
+ }
34152
+ function isObject13(v) {
34153
+ return typeof v === "object" && v !== null && !Array.isArray(v);
34154
+ }
34155
+ function writtenText(toolName2, toolInput) {
34156
+ if (toolName2 === "Write") return str10(toolInput["content"]);
34157
+ if (toolName2 === "Edit") {
34158
+ return str10(toolInput["new_string"]) || str10(toolInput["newString"]);
34159
+ }
34160
+ return "";
34161
+ }
34162
+ function buildAdvisoryLine3(file, findings) {
34163
+ const counts = /* @__PURE__ */ new Map();
34164
+ for (const f of findings) counts.set(f.cls, (counts.get(f.cls) ?? 0) + 1);
34165
+ const summary = [...counts].map(([c, n]) => `${c} \xD7${n}`).join(" \xB7 ");
34166
+ const named = findings.slice(0, MAX_REPORTED).map((f) => `line ${f.line} (${f.signal})`).join(", ");
34167
+ const more = findings.length > MAX_REPORTED ? `, +${findings.length - MAX_REPORTED} more` : "";
34168
+ return `comment-discipline: the text just written to ${file} carries ${summary} \u2014 ${named}${more}. A comment states a WHY or a constraint the code cannot show, in English; evidence for a roadmap step belongs in that roadmap, not in a second copy in the source. Rewrite or delete those lines now, before the next write \u2014 \`lint_code_comments\` refuses them at the gate.`;
34169
+ }
34170
+ function main56() {
34171
+ try {
34172
+ const [envelope, payload] = unwrap(readHookStdin(), "claude");
34173
+ const event = str10(envelope["event"]);
34174
+ if (event !== "" && event !== "post_tool_use") return EXIT_ALLOW28;
34175
+ const toolName2 = str10(
34176
+ payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]
34177
+ );
34178
+ if (toolName2 !== "Write" && toolName2 !== "Edit") return EXIT_ALLOW28;
34179
+ const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
34180
+ if (!isObject13(ti)) return EXIT_ALLOW28;
34181
+ const filePath = str10(ti["file_path"] ?? ti["path"] ?? ti["filePath"]);
34182
+ if (!filePath || !isScannable(filePath)) return EXIT_ALLOW28;
34183
+ const text = writtenText(toolName2, ti);
34184
+ if (!text) return EXIT_ALLOW28;
34185
+ const workspaceRoot3 = str10(envelope["workspace_root"]).trim() || process.cwd();
34186
+ const abs = path86.isAbsolute(filePath) ? filePath : path86.resolve(workspaceRoot3, filePath);
34187
+ const rel = path86.relative(workspaceRoot3, abs);
34188
+ const shown = rel.startsWith("..") ? path86.basename(abs) : rel;
34189
+ const findings = scanText2(shown, text);
34190
+ if (findings.length === 0) return EXIT_ALLOW28;
34191
+ process.stdout.write(
34192
+ `${JSON.stringify({
34193
+ decision: "warn",
34194
+ reason: `comment-discipline: ${findings.length} comment finding(s) in the text written to ${shown}`,
34195
+ additional_context: buildAdvisoryLine3(shown, findings)
34196
+ })}
34197
+ `
34198
+ );
34199
+ return EXIT_WARN15;
34200
+ } catch {
34201
+ return EXIT_ALLOW28;
34202
+ }
34203
+ }
34204
+ function _isCliEntry43() {
34205
+ if (true) return false;
34206
+ if (process.argv[1] === void 0) return false;
34207
+ const argvUrl = pathToFileURL50(path86.resolve(process.argv[1])).href;
34208
+ if (import.meta.url === argvUrl) return true;
34209
+ try {
34210
+ return fs85.realpathSync(fileURLToPath57(import.meta.url)) === fs85.realpathSync(path86.resolve(process.argv[1]));
34211
+ } catch {
34212
+ return false;
34213
+ }
34214
+ }
34215
+ if (_isCliEntry43()) process.exit(main56());
34216
+
34217
+ // src/scripts/hooks/reread_guard_hook.ts
34218
+ import * as crypto12 from "node:crypto";
34219
+ import * as fs86 from "node:fs";
34220
+ import * as path87 from "node:path";
34221
+ import { fileURLToPath as fileURLToPath58, pathToFileURL as pathToFileURL51 } from "node:url";
34222
+ var EXIT_ALLOW29 = 0;
34223
+ var EXIT_WARN16 = 2;
33498
34224
  var EXEMPT_PATH_PATTERNS2 = [
33499
34225
  /(^|\/)dist\//i,
33500
34226
  // dist/**
@@ -33509,10 +34235,10 @@ var EXEMPT_PATH_PATTERNS2 = [
33509
34235
  ];
33510
34236
  var READ_TOOLS = /* @__PURE__ */ new Set(["Read"]);
33511
34237
  var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Edit", "Write"]);
33512
- function isObject13(v) {
34238
+ function isObject14(v) {
33513
34239
  return typeof v === "object" && v !== null && !Array.isArray(v);
33514
34240
  }
33515
- function str10(v) {
34241
+ function str11(v) {
33516
34242
  return typeof v === "string" ? v : "";
33517
34243
  }
33518
34244
  function isExemptPath2(filePath) {
@@ -33523,21 +34249,21 @@ function emptyLedger() {
33523
34249
  return { reads: {}, writes: {}, fired: {} };
33524
34250
  }
33525
34251
  function deriveSessionKey4(envelope, payload) {
33526
- const raw = str10(envelope["session_id"]) || str10(payload["session_id"] ?? payload["sessionId"]);
34252
+ const raw = str11(envelope["session_id"]) || str11(payload["session_id"] ?? payload["sessionId"]);
33527
34253
  const material = raw || "unknown-session";
33528
34254
  return crypto12.createHash("sha256").update(material).digest("hex");
33529
34255
  }
33530
34256
  function ledgerFile(workspaceRoot3, sessionKey) {
33531
- return path84.join(workspaceRoot3, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
34257
+ return path87.join(workspaceRoot3, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
33532
34258
  }
33533
34259
  function readLedger(workspaceRoot3, sessionKey) {
33534
34260
  try {
33535
- const parsed = JSON.parse(fs84.readFileSync(ledgerFile(workspaceRoot3, sessionKey), "utf8"));
33536
- if (!isObject13(parsed)) return emptyLedger();
34261
+ const parsed = JSON.parse(fs86.readFileSync(ledgerFile(workspaceRoot3, sessionKey), "utf8"));
34262
+ if (!isObject14(parsed)) return emptyLedger();
33537
34263
  return {
33538
- reads: isObject13(parsed["reads"]) ? parsed["reads"] : {},
33539
- writes: isObject13(parsed["writes"]) ? parsed["writes"] : {},
33540
- fired: isObject13(parsed["fired"]) ? parsed["fired"] : {}
34264
+ reads: isObject14(parsed["reads"]) ? parsed["reads"] : {},
34265
+ writes: isObject14(parsed["writes"]) ? parsed["writes"] : {},
34266
+ fired: isObject14(parsed["fired"]) ? parsed["fired"] : {}
33541
34267
  };
33542
34268
  } catch {
33543
34269
  return emptyLedger();
@@ -33550,14 +34276,14 @@ function writeLedger(workspaceRoot3, sessionKey, ledger) {
33550
34276
  }
33551
34277
  }
33552
34278
  function extractToolName4(payload) {
33553
- return str10(payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]);
34279
+ return str11(payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]);
33554
34280
  }
33555
34281
  function extractToolInput2(payload) {
33556
34282
  const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
33557
- return isObject13(ti) ? ti : {};
34283
+ return isObject14(ti) ? ti : {};
33558
34284
  }
33559
34285
  function extractFilePath3(toolInput) {
33560
- return str10(toolInput["file_path"] ?? toolInput["path"] ?? toolInput["filePath"]);
34286
+ return str11(toolInput["file_path"] ?? toolInput["path"] ?? toolInput["filePath"]);
33561
34287
  }
33562
34288
  function isRangedRead(toolInput) {
33563
34289
  for (const key of ["offset", "limit", "start_line", "end_line", "startLine", "endLine"]) {
@@ -33573,41 +34299,41 @@ function buildDuplicateReadLine(relPath, earlierTs) {
33573
34299
  function buildPostEditReadLine(relPath) {
33574
34300
  return `re-read guard: this session just edited ${relPath} \u2014 a full-file re-read re-pays for content you already have; a ranged Read (offset/limit) over the edited hunk is enough to verify the change.`;
33575
34301
  }
33576
- function main55() {
34302
+ function main57() {
33577
34303
  try {
33578
34304
  const [envelope, payload] = unwrap(readHookStdin(), "claude");
33579
- const event = str10(envelope["event"]);
33580
- if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW28;
34305
+ const event = str11(envelope["event"]);
34306
+ if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW29;
33581
34307
  const toolName2 = extractToolName4(payload);
33582
34308
  const isRead = READ_TOOLS.has(toolName2);
33583
34309
  const isWrite = WRITE_TOOLS2.has(toolName2);
33584
- if (!isRead && !isWrite) return EXIT_ALLOW28;
34310
+ if (!isRead && !isWrite) return EXIT_ALLOW29;
33585
34311
  const toolInput = extractToolInput2(payload);
33586
34312
  const filePath = extractFilePath3(toolInput);
33587
- if (!filePath) return EXIT_ALLOW28;
33588
- const workspaceRoot3 = str10(envelope["workspace_root"]).trim() || process.cwd();
33589
- const absPath = path84.isAbsolute(filePath) ? filePath : path84.resolve(workspaceRoot3, filePath);
33590
- const relPath = path84.relative(workspaceRoot3, absPath);
33591
- if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW28;
34313
+ if (!filePath) return EXIT_ALLOW29;
34314
+ const workspaceRoot3 = str11(envelope["workspace_root"]).trim() || process.cwd();
34315
+ const absPath = path87.isAbsolute(filePath) ? filePath : path87.resolve(workspaceRoot3, filePath);
34316
+ const relPath = path87.relative(workspaceRoot3, absPath);
34317
+ if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW29;
33592
34318
  const sessionKey = deriveSessionKey4(envelope, payload);
33593
34319
  const ledger = readLedger(workspaceRoot3, sessionKey);
33594
34320
  const key = relPath.startsWith("..") ? absPath : relPath;
33595
34321
  if (isWrite) {
33596
34322
  ledger.writes[key] = Date.now();
33597
34323
  writeLedger(workspaceRoot3, sessionKey, ledger);
33598
- return EXIT_ALLOW28;
34324
+ return EXIT_ALLOW29;
33599
34325
  }
33600
34326
  if (isRangedRead(toolInput)) {
33601
- return EXIT_ALLOW28;
34327
+ return EXIT_ALLOW29;
33602
34328
  }
33603
34329
  let mtime;
33604
34330
  let size;
33605
34331
  try {
33606
- const st = fs84.statSync(absPath);
34332
+ const st = fs86.statSync(absPath);
33607
34333
  mtime = st.mtimeMs;
33608
34334
  size = st.size;
33609
34335
  } catch {
33610
- return EXIT_ALLOW28;
34336
+ return EXIT_ALLOW29;
33611
34337
  }
33612
34338
  const prior = ledger.reads[key];
33613
34339
  const ownWrite = ledger.writes[key];
@@ -33622,7 +34348,7 @@ function main55() {
33622
34348
  if (ownWrite !== void 0) delete ledger.writes[key];
33623
34349
  if (advisory !== null) ledger.fired[key] = true;
33624
34350
  writeLedger(workspaceRoot3, sessionKey, ledger);
33625
- if (advisory === null) return EXIT_ALLOW28;
34351
+ if (advisory === null) return EXIT_ALLOW29;
33626
34352
  process.stdout.write(
33627
34353
  `${JSON.stringify({
33628
34354
  decision: "warn",
@@ -33631,39 +34357,39 @@ function main55() {
33631
34357
  })}
33632
34358
  `
33633
34359
  );
33634
- return EXIT_WARN15;
34360
+ return EXIT_WARN16;
33635
34361
  } catch {
33636
- return EXIT_ALLOW28;
34362
+ return EXIT_ALLOW29;
33637
34363
  }
33638
34364
  }
33639
- function _isCliEntry43() {
34365
+ function _isCliEntry44() {
33640
34366
  if (true) {
33641
34367
  return false;
33642
34368
  }
33643
34369
  if (process.argv[1] === void 0) {
33644
34370
  return false;
33645
34371
  }
33646
- const argvUrl = pathToFileURL50(path84.resolve(process.argv[1])).href;
34372
+ const argvUrl = pathToFileURL51(path87.resolve(process.argv[1])).href;
33647
34373
  if (import.meta.url === argvUrl) {
33648
34374
  return true;
33649
34375
  }
33650
34376
  try {
33651
- const here = fs84.realpathSync(fileURLToPath56(import.meta.url));
33652
- const argv = fs84.realpathSync(path84.resolve(process.argv[1]));
34377
+ const here = fs86.realpathSync(fileURLToPath58(import.meta.url));
34378
+ const argv = fs86.realpathSync(path87.resolve(process.argv[1]));
33653
34379
  return here === argv;
33654
34380
  } catch {
33655
34381
  return false;
33656
34382
  }
33657
34383
  }
33658
- if (_isCliEntry43()) {
33659
- process.exit(main55());
34384
+ if (_isCliEntry44()) {
34385
+ process.exit(main57());
33660
34386
  }
33661
34387
 
33662
34388
  // src/scripts/hooks/session_eol_hook.ts
33663
- import * as fs87 from "node:fs";
33664
- import * as path88 from "node:path";
33665
- import process12 from "node:process";
33666
- import { fileURLToPath as fileURLToPath57, pathToFileURL as pathToFileURL51 } from "node:url";
34389
+ import * as fs89 from "node:fs";
34390
+ import * as path91 from "node:path";
34391
+ import process15 from "node:process";
34392
+ import { fileURLToPath as fileURLToPath59, pathToFileURL as pathToFileURL52 } from "node:url";
33667
34393
 
33668
34394
  // src/config/recycle-threshold-budget.json
33669
34395
  var recycle_threshold_budget_default = {
@@ -33681,13 +34407,13 @@ var recycle_threshold_budget_default = {
33681
34407
 
33682
34408
  // src/scripts/_lib/session_eol.ts
33683
34409
  import * as crypto13 from "node:crypto";
33684
- import * as fs85 from "node:fs";
33685
- import * as path86 from "node:path";
34410
+ import * as fs87 from "node:fs";
34411
+ import * as path89 from "node:path";
33686
34412
 
33687
34413
  // src/scripts/_lib/cc_transcript.ts
33688
- import * as path85 from "node:path";
34414
+ import * as path88 from "node:path";
33689
34415
  import { homedir as homedir7 } from "node:os";
33690
- var DEFAULT_PROJECTS_ROOT = path85.join(homedir7(), ".claude", "projects");
34416
+ var DEFAULT_PROJECTS_ROOT = path88.join(homedir7(), ".claude", "projects");
33691
34417
  function billableInputTokens(u) {
33692
34418
  return u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens;
33693
34419
  }
@@ -33796,17 +34522,17 @@ function scanEolSlice(text, prior) {
33796
34522
  return next;
33797
34523
  }
33798
34524
  function eolStateDir(workspaceRoot3) {
33799
- return path86.join(workspaceRoot3, "agents", "runtime", "state", "session-eol");
34525
+ return path89.join(workspaceRoot3, "agents", "runtime", "state", "session-eol");
33800
34526
  }
33801
34527
  function eolStateFile(workspaceRoot3, sessionKey) {
33802
- return path86.join(eolStateDir(workspaceRoot3), `${sessionKey}.json`);
34528
+ return path89.join(eolStateDir(workspaceRoot3), `${sessionKey}.json`);
33803
34529
  }
33804
34530
  function eolSessionKey(raw) {
33805
34531
  return crypto13.createHash("sha256").update(raw || "unknown-session").digest("hex");
33806
34532
  }
33807
34533
  function readNewCompleteLines(filePath, fromByte) {
33808
34534
  try {
33809
- const { size } = fs85.statSync(filePath);
34535
+ const { size } = fs87.statSync(filePath);
33810
34536
  if (size < fromByte) {
33811
34537
  return { text: "", nextOffset: 0, truncated: true };
33812
34538
  }
@@ -33815,11 +34541,11 @@ function readNewCompleteLines(filePath, fromByte) {
33815
34541
  }
33816
34542
  const length = size - fromByte;
33817
34543
  const buffer = Buffer.alloc(length);
33818
- const fd = fs85.openSync(filePath, "r");
34544
+ const fd = fs87.openSync(filePath, "r");
33819
34545
  try {
33820
- fs85.readSync(fd, buffer, 0, length, fromByte);
34546
+ fs87.readSync(fd, buffer, 0, length, fromByte);
33821
34547
  } finally {
33822
- fs85.closeSync(fd);
34548
+ fs87.closeSync(fd);
33823
34549
  }
33824
34550
  const lastNewline = buffer.lastIndexOf(10);
33825
34551
  if (lastNewline === -1) {
@@ -33836,8 +34562,8 @@ function readNewCompleteLines(filePath, fromByte) {
33836
34562
  }
33837
34563
 
33838
34564
  // src/scripts/_lib/run_checkpoint.ts
33839
- import * as fs86 from "node:fs";
33840
- import * as path87 from "node:path";
34565
+ import * as fs88 from "node:fs";
34566
+ import * as path90 from "node:path";
33841
34567
 
33842
34568
  // src/scripts/_lib/roadmap_checkboxes.ts
33843
34569
  var CHECKBOX_LINE = /^[ \t]*[-*][ \t]+\[([ xX~-])\][ \t]+(.*)$/;
@@ -33867,7 +34593,7 @@ function phaseLines(text) {
33867
34593
  }
33868
34594
 
33869
34595
  // src/scripts/_lib/run_checkpoint.ts
33870
- var CHECKPOINT_DIR_REL = path87.join("agents", "runtime", "state", "checkpoints");
34596
+ var CHECKPOINT_DIR_REL = path90.join("agents", "runtime", "state", "checkpoints");
33871
34597
  function countRoadmap(text) {
33872
34598
  const counts = { open: 0, done: 0, parked: 0, next: null };
33873
34599
  for (const raw of phaseLines(text)) {
@@ -33888,34 +34614,34 @@ function countRoadmap(text) {
33888
34614
  return counts;
33889
34615
  }
33890
34616
  function checkpointFile(repoRoot, runId) {
33891
- return path87.join(repoRoot, CHECKPOINT_DIR_REL, `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
34617
+ return path90.join(repoRoot, CHECKPOINT_DIR_REL, `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
33892
34618
  }
33893
34619
  function roadmapPath(repoRoot, slug) {
33894
- return path87.join(repoRoot, "agents", "roadmaps", `${slug}.md`);
34620
+ return path90.join(repoRoot, "agents", "roadmaps", `${slug}.md`);
33895
34621
  }
33896
34622
  function readHead(repoRoot) {
33897
34623
  try {
33898
- let gitDir = path87.join(repoRoot, ".git");
33899
- if (fs86.statSync(gitDir).isFile()) {
33900
- const m = /^gitdir:\s*(.+)$/m.exec(fs86.readFileSync(gitDir, "utf-8").trim());
34624
+ let gitDir = path90.join(repoRoot, ".git");
34625
+ if (fs88.statSync(gitDir).isFile()) {
34626
+ const m = /^gitdir:\s*(.+)$/m.exec(fs88.readFileSync(gitDir, "utf-8").trim());
33901
34627
  if (m === null) return null;
33902
- gitDir = path87.resolve(repoRoot, m[1]);
34628
+ gitDir = path90.resolve(repoRoot, m[1]);
33903
34629
  }
33904
34630
  let refRoot = gitDir;
33905
34631
  try {
33906
- const common = fs86.readFileSync(path87.join(gitDir, "commondir"), "utf-8").trim();
33907
- if (common !== "") refRoot = path87.resolve(gitDir, common);
34632
+ const common = fs88.readFileSync(path90.join(gitDir, "commondir"), "utf-8").trim();
34633
+ if (common !== "") refRoot = path90.resolve(gitDir, common);
33908
34634
  } catch {
33909
34635
  }
33910
- const head = fs86.readFileSync(path87.join(gitDir, "HEAD"), "utf-8").trim();
34636
+ const head = fs88.readFileSync(path90.join(gitDir, "HEAD"), "utf-8").trim();
33911
34637
  if (/^[0-9a-f]{40}$/.test(head)) return head;
33912
34638
  const ref = /^ref:\s*(.+)$/.exec(head);
33913
34639
  if (ref === null) return null;
33914
34640
  const refName = ref[1];
33915
34641
  try {
33916
- return fs86.readFileSync(path87.join(refRoot, refName), "utf-8").trim() || null;
34642
+ return fs88.readFileSync(path90.join(refRoot, refName), "utf-8").trim() || null;
33917
34643
  } catch {
33918
- const packed = fs86.readFileSync(path87.join(refRoot, "packed-refs"), "utf-8");
34644
+ const packed = fs88.readFileSync(path90.join(refRoot, "packed-refs"), "utf-8");
33919
34645
  for (const line of packed.split("\n")) {
33920
34646
  const pm = /^([0-9a-f]{40})\s+(.+)$/.exec(line.trim());
33921
34647
  if (pm !== null && pm[2] === refName) return pm[1];
@@ -33929,7 +34655,7 @@ function readHead(repoRoot) {
33929
34655
  function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
33930
34656
  let text;
33931
34657
  try {
33932
- text = fs86.readFileSync(roadmapPath(repoRoot, slug), "utf-8");
34658
+ text = fs88.readFileSync(roadmapPath(repoRoot, slug), "utf-8");
33933
34659
  } catch {
33934
34660
  return null;
33935
34661
  }
@@ -33953,8 +34679,8 @@ function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
33953
34679
  function writeCheckpoint(repoRoot, cp) {
33954
34680
  const file = checkpointFile(repoRoot, cp.run_id);
33955
34681
  try {
33956
- fs86.mkdirSync(path87.dirname(file), { recursive: true });
33957
- fs86.writeFileSync(file, `${JSON.stringify(cp, null, 2)}
34682
+ fs88.mkdirSync(path90.dirname(file), { recursive: true });
34683
+ fs88.writeFileSync(file, `${JSON.stringify(cp, null, 2)}
33958
34684
  `, "utf-8");
33959
34685
  return file;
33960
34686
  } catch {
@@ -33963,24 +34689,24 @@ function writeCheckpoint(repoRoot, cp) {
33963
34689
  }
33964
34690
 
33965
34691
  // src/scripts/hooks/session_eol_hook.ts
33966
- var EXIT_WARN16 = 2;
34692
+ var EXIT_WARN17 = 2;
33967
34693
  var THRESHOLD_OVERRIDE_ENV = "AGENT_RECYCLE_THRESHOLD_TOKENS";
33968
- var CONTEXT_FILL_REL = path88.join("agents", "runtime", "state", "context-fill.json");
33969
- function str11(value) {
34694
+ var CONTEXT_FILL_REL = path91.join("agents", "runtime", "state", "context-fill.json");
34695
+ function str12(value) {
33970
34696
  return typeof value === "string" ? value : "";
33971
34697
  }
33972
34698
  var stateFile3 = eolStateFile;
33973
34699
  function deriveSessionKey5(envelope, payload) {
33974
34700
  return eolSessionKey(
33975
- str11(envelope["session_id"]) || str11(payload["transcript_path"] ?? payload["transcriptPath"])
34701
+ str12(envelope["session_id"]) || str12(payload["transcript_path"] ?? payload["transcriptPath"])
33976
34702
  );
33977
34703
  }
33978
34704
  function payloadSessionId(payload, envelope) {
33979
- return (str11(payload["session_id"]) || str11(envelope["session_id"])).trim();
34705
+ return (str12(payload["session_id"]) || str12(envelope["session_id"])).trim();
33980
34706
  }
33981
34707
  function readState4(file) {
33982
34708
  try {
33983
- const parsed = JSON.parse(fs87.readFileSync(file, "utf-8"));
34709
+ const parsed = JSON.parse(fs89.readFileSync(file, "utf-8"));
33984
34710
  if (parsed && typeof parsed === "object" && parsed.schema_version === 1 && parsed.counters && typeof parsed.counters.scanned_bytes === "number") {
33985
34711
  return {
33986
34712
  schema_version: 1,
@@ -34001,10 +34727,10 @@ function readState4(file) {
34001
34727
  };
34002
34728
  }
34003
34729
  function envelopeExists(workspaceRoot3, since = null) {
34004
- const target = path88.join(workspaceRoot3, RECYCLE_ENVELOPE_REL);
34730
+ const target = path91.join(workspaceRoot3, RECYCLE_ENVELOPE_REL);
34005
34731
  let raw;
34006
34732
  try {
34007
- raw = fs87.readFileSync(target, "utf-8");
34733
+ raw = fs89.readFileSync(target, "utf-8");
34008
34734
  } catch (exc) {
34009
34735
  return exc?.code !== "ENOENT";
34010
34736
  }
@@ -34018,10 +34744,10 @@ function envelopeExists(workspaceRoot3, since = null) {
34018
34744
  }
34019
34745
  }
34020
34746
  function buildMissingEnvelopeLine(workspaceRoot3) {
34021
- return `recycle advised earlier, but no envelope exists at ${path88.join(workspaceRoot3, RECYCLE_ENVELOPE_REL)} \u2014 /clear now starts the successor from nothing. Re-run \`agent-config session:recycle\` and check that it prints the absolute path it wrote before clearing.`;
34747
+ return `recycle advised earlier, but no envelope exists at ${path91.join(workspaceRoot3, RECYCLE_ENVELOPE_REL)} \u2014 /clear now starts the successor from nothing. Re-run \`agent-config session:recycle\` and check that it prints the absolute path it wrote before clearing.`;
34022
34748
  }
34023
34749
  function readThresholdTokens() {
34024
- const override = process12.env[THRESHOLD_OVERRIDE_ENV];
34750
+ const override = process15.env[THRESHOLD_OVERRIDE_ENV];
34025
34751
  if (override !== void 0) {
34026
34752
  const value2 = Number(override);
34027
34753
  return Number.isFinite(value2) && value2 > 0 ? value2 : null;
@@ -34029,12 +34755,12 @@ function readThresholdTokens() {
34029
34755
  const value = recycle_threshold_budget_default["recycle_threshold_tokens"];
34030
34756
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
34031
34757
  }
34032
- function buildAdvisoryLine3(tokens, threshold) {
34758
+ function buildAdvisoryLine4(tokens, threshold) {
34033
34759
  return `context past recycle threshold (${tokens.toLocaleString("en-US")} of ${threshold.toLocaleString("en-US")} tokens): run \`agent-config session:recycle\` to write the recycle envelope. It prints the absolute path it wrote \u2014 /clear only after you have seen that line. The successor session then resumes from the envelope at session_start (road-to-token-economy-recycling)`;
34034
34760
  }
34035
34761
  function writeContextFill(workspaceRoot3, tokens, threshold, ts) {
34036
34762
  try {
34037
- atomic_write_json(path88.join(workspaceRoot3, CONTEXT_FILL_REL), {
34763
+ atomic_write_json(path91.join(workspaceRoot3, CONTEXT_FILL_REL), {
34038
34764
  schema_version: 1,
34039
34765
  final_context_tokens: tokens,
34040
34766
  recycle_threshold_tokens: threshold,
@@ -34044,7 +34770,7 @@ function writeContextFill(workspaceRoot3, tokens, threshold, ts) {
34044
34770
  } catch {
34045
34771
  }
34046
34772
  }
34047
- function main56() {
34773
+ function main58() {
34048
34774
  const [envelope, payload] = unwrap(readHookStdin(), "claude");
34049
34775
  const event = String(envelope["event"] ?? "");
34050
34776
  if (event !== "" && event !== "stop") {
@@ -34053,8 +34779,8 @@ function main56() {
34053
34779
  if (is_replay_mode()) {
34054
34780
  return 0;
34055
34781
  }
34056
- const workspaceRoot3 = String(envelope["workspace_root"] ?? "").trim() || process12.cwd();
34057
- const transcriptPath = str11(
34782
+ const workspaceRoot3 = String(envelope["workspace_root"] ?? "").trim() || process15.cwd();
34783
+ const transcriptPath = str12(
34058
34784
  payload["transcript_path"] ?? payload["transcriptPath"]
34059
34785
  ).trim();
34060
34786
  if (!transcriptPath || !isSafeTranscriptPath(transcriptPath)) {
@@ -34104,18 +34830,18 @@ function main56() {
34104
34830
  }
34105
34831
  }
34106
34832
  if (shouldAdvise && threshold !== null && tokens !== null) {
34107
- process12.stdout.write(
34833
+ process15.stdout.write(
34108
34834
  `${JSON.stringify({
34109
34835
  decision: "warn",
34110
34836
  reason: `session-eol: context ${tokens} >= recycle threshold ${threshold}`,
34111
- additional_context: buildAdvisoryLine3(tokens, threshold)
34837
+ additional_context: buildAdvisoryLine4(tokens, threshold)
34112
34838
  })}
34113
34839
  `
34114
34840
  );
34115
- return EXIT_WARN16;
34841
+ return EXIT_WARN17;
34116
34842
  }
34117
34843
  if (shouldWarnMissing) {
34118
- process12.stdout.write(
34844
+ process15.stdout.write(
34119
34845
  `${JSON.stringify({
34120
34846
  decision: "warn",
34121
34847
  reason: "session-eol: recycle advised, no envelope written",
@@ -34123,42 +34849,42 @@ function main56() {
34123
34849
  })}
34124
34850
  `
34125
34851
  );
34126
- return EXIT_WARN16;
34852
+ return EXIT_WARN17;
34127
34853
  }
34128
34854
  return 0;
34129
34855
  }
34130
- function _isCliEntry44() {
34856
+ function _isCliEntry45() {
34131
34857
  if (true) {
34132
34858
  return false;
34133
34859
  }
34134
- if (process12.argv[1] === void 0) {
34860
+ if (process15.argv[1] === void 0) {
34135
34861
  return false;
34136
34862
  }
34137
- const argvUrl = pathToFileURL51(path88.resolve(process12.argv[1])).href;
34863
+ const argvUrl = pathToFileURL52(path91.resolve(process15.argv[1])).href;
34138
34864
  if (import.meta.url === argvUrl) {
34139
34865
  return true;
34140
34866
  }
34141
34867
  try {
34142
- const here = fs87.realpathSync(fileURLToPath57(import.meta.url));
34143
- const argv = fs87.realpathSync(path88.resolve(process12.argv[1]));
34868
+ const here = fs89.realpathSync(fileURLToPath59(import.meta.url));
34869
+ const argv = fs89.realpathSync(path91.resolve(process15.argv[1]));
34144
34870
  return here === argv;
34145
34871
  } catch {
34146
34872
  return false;
34147
34873
  }
34148
34874
  }
34149
- if (_isCliEntry44()) {
34150
- process12.exit(main56());
34875
+ if (_isCliEntry45()) {
34876
+ process15.exit(main58());
34151
34877
  }
34152
34878
 
34153
34879
  // src/scripts/hooks/tool_result_bytes_hook.ts
34154
- import * as fs88 from "node:fs";
34155
- import * as path89 from "node:path";
34156
- import { fileURLToPath as fileURLToPath58, pathToFileURL as pathToFileURL52 } from "node:url";
34157
- var EXIT_ALLOW29 = 0;
34158
- function isObject14(v) {
34880
+ import * as fs90 from "node:fs";
34881
+ import * as path92 from "node:path";
34882
+ import { fileURLToPath as fileURLToPath60, pathToFileURL as pathToFileURL53 } from "node:url";
34883
+ var EXIT_ALLOW30 = 0;
34884
+ function isObject15(v) {
34159
34885
  return typeof v === "object" && v !== null && !Array.isArray(v);
34160
34886
  }
34161
- var CENSUS_FILE = path89.join("agents", "runtime", "state", "tool-result-census.jsonl");
34887
+ var CENSUS_FILE = path92.join("agents", "runtime", "state", "tool-result-census.jsonl");
34162
34888
  var RESULT_KEYS = ["tool_response", "toolResponse", "tool_result", "toolUseResult"];
34163
34889
  function _resultBytes(payload) {
34164
34890
  for (const key of RESULT_KEYS) {
@@ -34190,22 +34916,22 @@ function _toolName(payload, envelope) {
34190
34916
  }
34191
34917
  function unwrapPayload4(envelope) {
34192
34918
  const inner = envelope["payload"];
34193
- return isObject14(inner) ? inner : envelope;
34919
+ return isObject15(inner) ? inner : envelope;
34194
34920
  }
34195
34921
  function censusFile(consumerRoot) {
34196
- return path89.join(consumerRoot, CENSUS_FILE);
34922
+ return path92.join(consumerRoot, CENSUS_FILE);
34197
34923
  }
34198
34924
  function _appendCensusLine(consumerRoot, line) {
34199
34925
  if (is_replay_mode()) return;
34200
34926
  const file = censusFile(consumerRoot);
34201
- fs88.mkdirSync(path89.dirname(file), { recursive: true });
34202
- fs88.appendFileSync(file, `${JSON.stringify(line)}
34927
+ fs90.mkdirSync(path92.dirname(file), { recursive: true });
34928
+ fs90.appendFileSync(file, `${JSON.stringify(line)}
34203
34929
  `, "utf8");
34204
34930
  }
34205
34931
  function processEnvelope4(envelope, consumerRoot) {
34206
34932
  try {
34207
- if (!isObject14(envelope)) return EXIT_ALLOW29;
34208
- if (envelope["event"] !== "post_tool_use") return EXIT_ALLOW29;
34933
+ if (!isObject15(envelope)) return EXIT_ALLOW30;
34934
+ if (envelope["event"] !== "post_tool_use") return EXIT_ALLOW30;
34209
34935
  const payload = unwrapPayload4(envelope);
34210
34936
  const bytes = _resultBytes(payload);
34211
34937
  _appendCensusLine(consumerRoot, {
@@ -34215,12 +34941,12 @@ function processEnvelope4(envelope, consumerRoot) {
34215
34941
  measurable: bytes !== null
34216
34942
  });
34217
34943
  } catch {
34218
- return EXIT_ALLOW29;
34944
+ return EXIT_ALLOW30;
34219
34945
  }
34220
- return EXIT_ALLOW29;
34946
+ return EXIT_ALLOW30;
34221
34947
  }
34222
34948
  function resolveConsumerRoot2(envelope) {
34223
- if (isObject14(envelope)) {
34949
+ if (isObject15(envelope)) {
34224
34950
  for (const key of ["workspace_root", "project_root"]) {
34225
34951
  const v = envelope[key];
34226
34952
  if (typeof v === "string" && v) return v;
@@ -34230,37 +34956,37 @@ function resolveConsumerRoot2(envelope) {
34230
34956
  }
34231
34957
  return process.cwd();
34232
34958
  }
34233
- function main57() {
34959
+ function main59() {
34234
34960
  const raw = readHookStdin();
34235
34961
  let envelope = {};
34236
34962
  try {
34237
34963
  envelope = raw.trim() ? JSON.parse(raw) : {};
34238
34964
  } catch {
34239
- return EXIT_ALLOW29;
34965
+ return EXIT_ALLOW30;
34240
34966
  }
34241
34967
  return processEnvelope4(envelope, resolveConsumerRoot2(envelope));
34242
34968
  }
34243
- function _isCliEntry45() {
34969
+ function _isCliEntry46() {
34244
34970
  if (true) {
34245
34971
  return false;
34246
34972
  }
34247
34973
  if (process.argv[1] === void 0) return false;
34248
- const argvUrl = pathToFileURL52(path89.resolve(process.argv[1])).href;
34974
+ const argvUrl = pathToFileURL53(path92.resolve(process.argv[1])).href;
34249
34975
  if (import.meta.url === argvUrl) return true;
34250
34976
  try {
34251
- return fs88.realpathSync(fileURLToPath58(import.meta.url)) === fs88.realpathSync(path89.resolve(process.argv[1]));
34977
+ return fs90.realpathSync(fileURLToPath60(import.meta.url)) === fs90.realpathSync(path92.resolve(process.argv[1]));
34252
34978
  } catch {
34253
34979
  return false;
34254
34980
  }
34255
34981
  }
34256
- if (_isCliEntry45()) process.exit(main57());
34982
+ if (_isCliEntry46()) process.exit(main59());
34257
34983
 
34258
34984
  // src/scripts/hooks/spawn_guard_shadow_hook.ts
34259
- import * as fs89 from "node:fs";
34260
- import * as path90 from "node:path";
34261
- import { fileURLToPath as fileURLToPath59, pathToFileURL as pathToFileURL53 } from "node:url";
34262
- var EXIT_ALLOW30 = 0;
34263
- function isObject15(v) {
34985
+ import * as fs91 from "node:fs";
34986
+ import * as path93 from "node:path";
34987
+ import { fileURLToPath as fileURLToPath61, pathToFileURL as pathToFileURL54 } from "node:url";
34988
+ var EXIT_ALLOW31 = 0;
34989
+ function isObject16(v) {
34264
34990
  return typeof v === "object" && v !== null && !Array.isArray(v);
34265
34991
  }
34266
34992
  var DISPATCH_TOOL_NAMES2 = /* @__PURE__ */ new Set(["Agent", "Task"]);
@@ -34279,7 +35005,7 @@ function evaluateCandidates(depthEstimate, concurrentOpen) {
34279
35005
  }
34280
35006
  function unwrapPayload5(envelope) {
34281
35007
  const inner = envelope["payload"];
34282
- return isObject15(inner) ? inner : envelope;
35008
+ return isObject16(inner) ? inner : envelope;
34283
35009
  }
34284
35010
  function extractToolName5(payload) {
34285
35011
  const v = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
@@ -34287,10 +35013,10 @@ function extractToolName5(payload) {
34287
35013
  }
34288
35014
  function processEnvelope5(envelope, consumerRoot) {
34289
35015
  try {
34290
- if (!isObject15(envelope)) return EXIT_ALLOW30;
35016
+ if (!isObject16(envelope)) return EXIT_ALLOW31;
34291
35017
  const payload = unwrapPayload5(envelope);
34292
35018
  const toolName2 = extractToolName5(payload);
34293
- if (toolName2 === null || !DISPATCH_TOOL_NAMES2.has(toolName2)) return EXIT_ALLOW30;
35019
+ if (toolName2 === null || !DISPATCH_TOOL_NAMES2.has(toolName2)) return EXIT_ALLOW31;
34294
35020
  const stats = openRecordStats(consumerRoot);
34295
35021
  const depthEstimate = stats.max_depth + 1;
34296
35022
  const verdicts = evaluateCandidates(depthEstimate, stats.open_count);
@@ -34318,47 +35044,47 @@ function processEnvelope5(envelope, consumerRoot) {
34318
35044
  posture: "shadow"
34319
35045
  });
34320
35046
  } catch {
34321
- return EXIT_ALLOW30;
35047
+ return EXIT_ALLOW31;
34322
35048
  }
34323
- return EXIT_ALLOW30;
35049
+ return EXIT_ALLOW31;
34324
35050
  }
34325
- function main58() {
35051
+ function main60() {
34326
35052
  const raw = readHookStdin();
34327
35053
  let envelope = {};
34328
35054
  try {
34329
35055
  envelope = raw.trim() ? JSON.parse(raw) : {};
34330
35056
  } catch {
34331
- return EXIT_ALLOW30;
35057
+ return EXIT_ALLOW31;
34332
35058
  }
34333
35059
  return processEnvelope5(envelope, resolveConsumerRoot(envelope));
34334
35060
  }
34335
- function _isCliEntry46() {
35061
+ function _isCliEntry47() {
34336
35062
  if (true) return false;
34337
35063
  if (process.argv[1] === void 0) return false;
34338
- const argvUrl = pathToFileURL53(path90.resolve(process.argv[1])).href;
35064
+ const argvUrl = pathToFileURL54(path93.resolve(process.argv[1])).href;
34339
35065
  if (import.meta.url === argvUrl) return true;
34340
35066
  try {
34341
- return fs89.realpathSync(fileURLToPath59(import.meta.url)) === fs89.realpathSync(path90.resolve(process.argv[1]));
35067
+ return fs91.realpathSync(fileURLToPath61(import.meta.url)) === fs91.realpathSync(path93.resolve(process.argv[1]));
34342
35068
  } catch {
34343
35069
  return false;
34344
35070
  }
34345
35071
  }
34346
- if (_isCliEntry46()) process.exit(main58());
35072
+ if (_isCliEntry47()) process.exit(main60());
34347
35073
 
34348
35074
  // src/scripts/hooks/source_first_gate_hook.ts
34349
- import * as fs90 from "node:fs";
34350
- import * as path91 from "node:path";
34351
- import { fileURLToPath as fileURLToPath60, pathToFileURL as pathToFileURL54 } from "node:url";
34352
- var EXIT_ALLOW31 = 0;
35075
+ import * as fs92 from "node:fs";
35076
+ import * as path94 from "node:path";
35077
+ import { fileURLToPath as fileURLToPath62, pathToFileURL as pathToFileURL55 } from "node:url";
35078
+ var EXIT_ALLOW32 = 0;
34353
35079
  var MAX_SHADOW_WARNS = 2;
34354
- var SHADOW_LOG = path91.join("agents", "runtime", "state", "source-first-gate.jsonl");
34355
- var STATE_FILE9 = path91.join("agents", "runtime", "state", "source-first-gate.json");
34356
- function isObject16(v) {
35080
+ var SHADOW_LOG = path94.join("agents", "runtime", "state", "source-first-gate.jsonl");
35081
+ var STATE_FILE9 = path94.join("agents", "runtime", "state", "source-first-gate.json");
35082
+ function isObject17(v) {
34357
35083
  return typeof v === "object" && v !== null && !Array.isArray(v);
34358
35084
  }
34359
35085
  function unwrapPayload6(envelope) {
34360
35086
  const inner = envelope["payload"];
34361
- return isObject16(inner) ? inner : envelope;
35087
+ return isObject17(inner) ? inner : envelope;
34362
35088
  }
34363
35089
  var TOOL_MATCHERS = [
34364
35090
  { pattern: /^browser_take_screenshot$/i, hit: { label: "playwright-mcp", capture_kind: "page" } },
@@ -34378,7 +35104,7 @@ function isHandoverPath(file) {
34378
35104
  const normalized = file.replace(/\\/g, "/").toLowerCase();
34379
35105
  return normalized.endsWith("design.html") || normalized.includes(".claude/design-system/");
34380
35106
  }
34381
- function str12(o, ...keys) {
35107
+ function str13(o, ...keys) {
34382
35108
  for (const k of keys) {
34383
35109
  const v = o[k];
34384
35110
  if (typeof v === "string" && v) return v;
@@ -34386,12 +35112,12 @@ function str12(o, ...keys) {
34386
35112
  return null;
34387
35113
  }
34388
35114
  function extractEvent2(outer) {
34389
- if (!isObject16(outer)) return null;
35115
+ if (!isObject17(outer)) return null;
34390
35116
  const payload = unwrapPayload6(outer);
34391
- const toolName2 = str12(payload, "tool_name", "toolName", "tool");
35117
+ const toolName2 = str13(payload, "tool_name", "toolName", "tool");
34392
35118
  const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
34393
- const input = isObject16(ti) ? ti : {};
34394
- const file = str12(input, "file_path", "path", "filePath") ?? "";
35119
+ const input = isObject17(ti) ? ti : {};
35120
+ const file = str13(input, "file_path", "path", "filePath") ?? "";
34395
35121
  let isWrite = false;
34396
35122
  for (const key of ["content", "new_string", "new_str", "text", "newText"]) {
34397
35123
  if (typeof input[key] === "string" && input[key].length > 0) isWrite = true;
@@ -34405,7 +35131,7 @@ function extractEvent2(outer) {
34405
35131
  }
34406
35132
  }
34407
35133
  if (!capture && SHELL_TOOLS.test(toolName2)) {
34408
- const command = str12(input, "command", "cmd", "script") ?? "";
35134
+ const command = str13(input, "command", "cmd", "script") ?? "";
34409
35135
  for (const m of COMMAND_MATCHERS) {
34410
35136
  if (m.pattern.test(command)) {
34411
35137
  capture = m.hit;
@@ -34418,15 +35144,15 @@ function extractEvent2(outer) {
34418
35144
  capture,
34419
35145
  file,
34420
35146
  isWrite,
34421
- agentIdPresent: str12(payload, "agent_id", "agentId") !== null,
34422
- agentType: str12(payload, "agent_type", "agentType")
35147
+ agentIdPresent: str13(payload, "agent_id", "agentId") !== null,
35148
+ agentType: str13(payload, "agent_type", "agentType")
34423
35149
  };
34424
35150
  }
34425
35151
  var EMPTY_STATE = { handoverSeen: false, sourceRead: false, wouldWarn: 0 };
34426
35152
  var MAX_SESSIONS2 = 50;
34427
35153
  function readState5(root, session) {
34428
35154
  try {
34429
- const all = JSON.parse(fs90.readFileSync(path91.join(root, STATE_FILE9), "utf-8"));
35155
+ const all = JSON.parse(fs92.readFileSync(path94.join(root, STATE_FILE9), "utf-8"));
34430
35156
  const entry = all[session];
34431
35157
  if (entry && typeof entry.handoverSeen === "boolean" && typeof entry.sourceRead === "boolean" && typeof entry.wouldWarn === "number") {
34432
35158
  return entry;
@@ -34438,13 +35164,13 @@ function readState5(root, session) {
34438
35164
  function writeState4(root, session, state) {
34439
35165
  if (is_replay_mode()) return;
34440
35166
  try {
34441
- const file = path91.join(root, STATE_FILE9);
35167
+ const file = path94.join(root, STATE_FILE9);
34442
35168
  let all = {};
34443
35169
  try {
34444
- all = JSON.parse(fs90.readFileSync(file, "utf-8"));
35170
+ all = JSON.parse(fs92.readFileSync(file, "utf-8"));
34445
35171
  } catch {
34446
35172
  }
34447
- if (!isObject16(all)) all = {};
35173
+ if (!isObject17(all)) all = {};
34448
35174
  all[session] = state;
34449
35175
  const keys = Object.keys(all);
34450
35176
  if (keys.length > MAX_SESSIONS2) {
@@ -34452,8 +35178,8 @@ function writeState4(root, session, state) {
34452
35178
  for (const key of keys.slice(keys.length - MAX_SESSIONS2)) pruned[key] = all[key];
34453
35179
  all = pruned;
34454
35180
  }
34455
- fs90.mkdirSync(path91.dirname(file), { recursive: true });
34456
- fs90.writeFileSync(file, JSON.stringify(all));
35181
+ fs92.mkdirSync(path94.dirname(file), { recursive: true });
35182
+ fs92.writeFileSync(file, JSON.stringify(all));
34457
35183
  } catch {
34458
35184
  }
34459
35185
  }
@@ -34474,7 +35200,7 @@ function evaluateCandidates2(handoverSeen, handoverOnDisk, sourceRead) {
34474
35200
  }
34475
35201
  function handoverPresentOnDisk(root) {
34476
35202
  try {
34477
- return fs90.statSync(path91.join(root, ".claude", "design-system")).isDirectory();
35203
+ return fs92.statSync(path94.join(root, ".claude", "design-system")).isDirectory();
34478
35204
  } catch {
34479
35205
  return false;
34480
35206
  }
@@ -34482,9 +35208,9 @@ function handoverPresentOnDisk(root) {
34482
35208
  function appendShadowLine(root, line) {
34483
35209
  if (is_replay_mode()) return;
34484
35210
  try {
34485
- const file = path91.join(root, SHADOW_LOG);
34486
- fs90.mkdirSync(path91.dirname(file), { recursive: true });
34487
- fs90.appendFileSync(file, `${JSON.stringify(line)}
35211
+ const file = path94.join(root, SHADOW_LOG);
35212
+ fs92.mkdirSync(path94.dirname(file), { recursive: true });
35213
+ fs92.appendFileSync(file, `${JSON.stringify(line)}
34488
35214
  `, "utf8");
34489
35215
  } catch {
34490
35216
  }
@@ -34498,14 +35224,14 @@ function nextState2(event, state) {
34498
35224
  function processEnvelope6(envelope, consumerRoot, session) {
34499
35225
  try {
34500
35226
  const event = extractEvent2(envelope);
34501
- if (!event) return EXIT_ALLOW31;
35227
+ if (!event) return EXIT_ALLOW32;
34502
35228
  const before = readState5(consumerRoot, session);
34503
35229
  const after = nextState2(event, before);
34504
35230
  if (event.capture === null) {
34505
35231
  if (after.handoverSeen !== before.handoverSeen || after.sourceRead !== before.sourceRead) {
34506
35232
  writeState4(consumerRoot, session, after);
34507
35233
  }
34508
- return EXIT_ALLOW31;
35234
+ return EXIT_ALLOW32;
34509
35235
  }
34510
35236
  const onDisk = handoverPresentOnDisk(consumerRoot);
34511
35237
  const verdicts = evaluateCandidates2(after.handoverSeen, onDisk, after.sourceRead);
@@ -34541,42 +35267,42 @@ function processEnvelope6(envelope, consumerRoot, session) {
34541
35267
  const persisted = anyWarn && !valveWouldSilence ? { ...after, wouldWarn: after.wouldWarn + 1 } : after;
34542
35268
  writeState4(consumerRoot, session, persisted);
34543
35269
  } catch {
34544
- return EXIT_ALLOW31;
35270
+ return EXIT_ALLOW32;
34545
35271
  }
34546
- return EXIT_ALLOW31;
35272
+ return EXIT_ALLOW32;
34547
35273
  }
34548
- function main59() {
35274
+ function main61() {
34549
35275
  const raw = readHookStdin();
34550
35276
  let envelope = {};
34551
35277
  try {
34552
35278
  envelope = raw.trim() ? JSON.parse(raw) : {};
34553
35279
  } catch {
34554
- return EXIT_ALLOW31;
35280
+ return EXIT_ALLOW32;
34555
35281
  }
34556
- const sessionVal = isObject16(envelope) ? envelope["session_id"] : null;
35282
+ const sessionVal = isObject17(envelope) ? envelope["session_id"] : null;
34557
35283
  const session = typeof sessionVal === "string" && sessionVal ? sessionVal : "unknown";
34558
35284
  return processEnvelope6(envelope, resolveConsumerRoot(envelope), session);
34559
35285
  }
34560
- function _isCliEntry47() {
35286
+ function _isCliEntry48() {
34561
35287
  if (true) return false;
34562
35288
  if (process.argv[1] === void 0) return false;
34563
- const argvUrl = pathToFileURL54(path91.resolve(process.argv[1])).href;
35289
+ const argvUrl = pathToFileURL55(path94.resolve(process.argv[1])).href;
34564
35290
  if (import.meta.url === argvUrl) return true;
34565
35291
  try {
34566
- return fs90.realpathSync(fileURLToPath60(import.meta.url)) === fs90.realpathSync(path91.resolve(process.argv[1]));
35292
+ return fs92.realpathSync(fileURLToPath62(import.meta.url)) === fs92.realpathSync(path94.resolve(process.argv[1]));
34567
35293
  } catch {
34568
35294
  return false;
34569
35295
  }
34570
35296
  }
34571
- if (_isCliEntry47()) process.exit(main59());
35297
+ if (_isCliEntry48()) process.exit(main61());
34572
35298
 
34573
35299
  // src/scripts/hooks/interruption_ledger_hook.ts
34574
- import * as fs91 from "node:fs";
34575
- import * as path92 from "node:path";
34576
- import { fileURLToPath as fileURLToPath61, pathToFileURL as pathToFileURL55 } from "node:url";
35300
+ import * as fs93 from "node:fs";
35301
+ import * as path95 from "node:path";
35302
+ import { fileURLToPath as fileURLToPath63, pathToFileURL as pathToFileURL56 } from "node:url";
34577
35303
  var EXIT_OK2 = 0;
34578
35304
  var TRANSCRIPT_READ_MAX_BYTES2 = 2 * 1024 * 1024;
34579
- var LEDGER_RELPATH = path92.join("agents", "runtime", "state", "interruptions.jsonl");
35305
+ var LEDGER_RELPATH = path95.join("agents", "runtime", "state", "interruptions.jsonl");
34580
35306
  function hasNumberedOptions(reply) {
34581
35307
  let count = 0;
34582
35308
  for (const line of reply.split("\n")) {
@@ -34600,14 +35326,14 @@ function classifyReply(reply) {
34600
35326
  function readClaimedRoadmap(workspaceRoot3, sessionId2) {
34601
35327
  if (!sessionId2) return null;
34602
35328
  try {
34603
- const file = path92.join(
35329
+ const file = path95.join(
34604
35330
  workspaceRoot3,
34605
35331
  "agents",
34606
35332
  "runtime",
34607
35333
  "state",
34608
35334
  `roadmap-claim-${sessionId2}.json`
34609
35335
  );
34610
- const parsed = JSON.parse(fs91.readFileSync(file, "utf8"));
35336
+ const parsed = JSON.parse(fs93.readFileSync(file, "utf8"));
34611
35337
  if (parsed === null || typeof parsed !== "object") return null;
34612
35338
  const slug = parsed["slug"];
34613
35339
  return typeof slug === "string" && slug.length > 0 ? slug : null;
@@ -34618,7 +35344,7 @@ function readClaimedRoadmap(workspaceRoot3, sessionId2) {
34618
35344
  function alreadyRecorded(ledgerPath, runId, turn) {
34619
35345
  let raw;
34620
35346
  try {
34621
- raw = fs91.readFileSync(ledgerPath, "utf8");
35347
+ raw = fs93.readFileSync(ledgerPath, "utf8");
34622
35348
  } catch {
34623
35349
  return false;
34624
35350
  }
@@ -34634,10 +35360,10 @@ function alreadyRecorded(ledgerPath, runId, turn) {
34634
35360
  }
34635
35361
  return false;
34636
35362
  }
34637
- function str13(v) {
35363
+ function str14(v) {
34638
35364
  return typeof v === "string" ? v : "";
34639
35365
  }
34640
- function main60() {
35366
+ function main62() {
34641
35367
  let envelope;
34642
35368
  let payload;
34643
35369
  try {
@@ -34645,8 +35371,8 @@ function main60() {
34645
35371
  } catch {
34646
35372
  return EXIT_OK2;
34647
35373
  }
34648
- const workspaceRoot3 = str13(envelope["workspace_root"]) || process.cwd();
34649
- const transcriptPath = str13(
35374
+ const workspaceRoot3 = str14(envelope["workspace_root"]) || process.cwd();
35375
+ const transcriptPath = str14(
34650
35376
  payload["transcript_path"] ?? payload["transcriptPath"]
34651
35377
  );
34652
35378
  if (!transcriptPath) return EXIT_OK2;
@@ -34660,9 +35386,9 @@ function main60() {
34660
35386
  return EXIT_OK2;
34661
35387
  }
34662
35388
  if (!lastAssistant) return EXIT_OK2;
34663
- const sessionId2 = str13(payload["session_id"]) || str13(envelope["session_id"]);
35389
+ const sessionId2 = str14(payload["session_id"]) || str14(envelope["session_id"]);
34664
35390
  const runId = sessionId2 ? derive_session_tag(sessionId2) : "unknown";
34665
- const ledgerPath = path92.join(workspaceRoot3, LEDGER_RELPATH);
35391
+ const ledgerPath = path95.join(workspaceRoot3, LEDGER_RELPATH);
34666
35392
  if (alreadyRecorded(ledgerPath, runId, turnOrdinal)) return EXIT_OK2;
34667
35393
  const verdict = classifyReply(lastAssistant);
34668
35394
  const record = {
@@ -34674,43 +35400,43 @@ function main60() {
34674
35400
  at: (/* @__PURE__ */ new Date()).toISOString()
34675
35401
  };
34676
35402
  try {
34677
- fs91.mkdirSync(path92.dirname(ledgerPath), { recursive: true });
34678
- fs91.appendFileSync(ledgerPath, `${JSON.stringify(record)}
35403
+ fs93.mkdirSync(path95.dirname(ledgerPath), { recursive: true });
35404
+ fs93.appendFileSync(ledgerPath, `${JSON.stringify(record)}
34679
35405
  `, "utf8");
34680
35406
  } catch {
34681
35407
  }
34682
35408
  return EXIT_OK2;
34683
35409
  }
34684
- function _isCliEntry48() {
35410
+ function _isCliEntry49() {
34685
35411
  if (process.argv[1] === void 0) {
34686
35412
  return false;
34687
35413
  }
34688
- const argvUrl = pathToFileURL55(path92.resolve(process.argv[1])).href;
35414
+ const argvUrl = pathToFileURL56(path95.resolve(process.argv[1])).href;
34689
35415
  if (import.meta.url === argvUrl) {
34690
35416
  return true;
34691
35417
  }
34692
35418
  try {
34693
- const here = fs91.realpathSync(fileURLToPath61(import.meta.url));
34694
- const argv = fs91.realpathSync(path92.resolve(process.argv[1]));
35419
+ const here = fs93.realpathSync(fileURLToPath63(import.meta.url));
35420
+ const argv = fs93.realpathSync(path95.resolve(process.argv[1]));
34695
35421
  return here === argv;
34696
35422
  } catch {
34697
35423
  return false;
34698
35424
  }
34699
35425
  }
34700
- if (_isCliEntry48()) {
34701
- process.exit(main60());
35426
+ if (_isCliEntry49()) {
35427
+ process.exit(main62());
34702
35428
  }
34703
35429
 
34704
35430
  // src/scripts/hooks/run_continuation_hook.ts
34705
- import * as fs94 from "node:fs";
35431
+ import * as fs96 from "node:fs";
34706
35432
 
34707
35433
  // src/scripts/_lib/billing_grant.ts
34708
- import * as fs92 from "node:fs";
34709
- import * as path93 from "node:path";
34710
- var BILLING_GRANT_DIR_REL = path93.join("agents", "runtime", "billing-grants");
35434
+ import * as fs94 from "node:fs";
35435
+ import * as path96 from "node:path";
35436
+ var BILLING_GRANT_DIR_REL = path96.join("agents", "runtime", "billing-grants");
34711
35437
  var BILLING_GRANT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
34712
35438
  function grantFile(repoRoot, runId) {
34713
- return path93.join(
35439
+ return path96.join(
34714
35440
  repoRoot,
34715
35441
  BILLING_GRANT_DIR_REL,
34716
35442
  `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
@@ -34718,29 +35444,29 @@ function grantFile(repoRoot, runId) {
34718
35444
  }
34719
35445
  function revokeBillingGrant(repoRoot, runId) {
34720
35446
  try {
34721
- fs92.unlinkSync(grantFile(repoRoot, runId));
35447
+ fs94.unlinkSync(grantFile(repoRoot, runId));
34722
35448
  } catch {
34723
35449
  }
34724
35450
  }
34725
35451
 
34726
35452
  // src/scripts/hooks/run_continuation_hook.ts
34727
- import * as path95 from "node:path";
34728
- import { fileURLToPath as fileURLToPath62, pathToFileURL as pathToFileURL56 } from "node:url";
35453
+ import * as path98 from "node:path";
35454
+ import { fileURLToPath as fileURLToPath64, pathToFileURL as pathToFileURL57 } from "node:url";
34729
35455
 
34730
35456
  // src/scripts/_lib/loop_guards.ts
34731
- import * as fs93 from "node:fs";
34732
- import * as path94 from "node:path";
35457
+ import * as fs95 from "node:fs";
35458
+ import * as path97 from "node:path";
34733
35459
  function atomicWriteJson(file, value) {
34734
35460
  const tmp = `${file}.${String(process.pid)}.tmp`;
34735
35461
  try {
34736
- fs93.mkdirSync(path94.dirname(file), { recursive: true });
34737
- fs93.writeFileSync(tmp, `${JSON.stringify(value)}
35462
+ fs95.mkdirSync(path97.dirname(file), { recursive: true });
35463
+ fs95.writeFileSync(tmp, `${JSON.stringify(value)}
34738
35464
  `, "utf8");
34739
- fs93.renameSync(tmp, file);
35465
+ fs95.renameSync(tmp, file);
34740
35466
  return true;
34741
35467
  } catch {
34742
35468
  try {
34743
- fs93.unlinkSync(tmp);
35469
+ fs95.unlinkSync(tmp);
34744
35470
  } catch {
34745
35471
  }
34746
35472
  return false;
@@ -34786,7 +35512,7 @@ function stallSignal(history, window = 3) {
34786
35512
  }
34787
35513
  function readUnavailableDependency(transcriptPath) {
34788
35514
  try {
34789
- const raw = fs93.readFileSync(transcriptPath, "utf8");
35515
+ const raw = fs95.readFileSync(transcriptPath, "utf8");
34790
35516
  return detectUnavailableDependency(raw.slice(-DEPENDENCY_SCAN_BYTES));
34791
35517
  } catch {
34792
35518
  return null;
@@ -34794,17 +35520,17 @@ function readUnavailableDependency(transcriptPath) {
34794
35520
  }
34795
35521
 
34796
35522
  // src/scripts/hooks/run_continuation_hook.ts
34797
- var EXIT_ALLOW32 = 0;
35523
+ var EXIT_ALLOW33 = 0;
34798
35524
  var EXIT_BLOCK5 = 1;
34799
35525
  var BLOCKED_BY_MARKER = /<!--\s*blocked-by:\s*\S[^>]*-->/;
34800
35526
  var LEDGER_TAIL_MAX_BYTES = 512 * 1024;
34801
- var EVENTS_RELPATH = path95.join(
35527
+ var EVENTS_RELPATH = path98.join(
34802
35528
  "agents",
34803
35529
  "runtime",
34804
35530
  "state",
34805
35531
  "run-continuation.jsonl"
34806
35532
  );
34807
- var STATE_DIR_REL = path95.join("agents", "runtime", "state");
35533
+ var STATE_DIR_REL = path98.join("agents", "runtime", "state");
34808
35534
  var MAX_ITERATIONS = 25;
34809
35535
  var WALL_CLOCK_CAP_MS = 4 * 60 * 60 * 1e3;
34810
35536
  var STALL_WINDOW = 3;
@@ -34907,20 +35633,20 @@ function ladder(state, openCount, nowMs, blockedCount, caps = {
34907
35633
  function stateRelPath(runId, slug) {
34908
35634
  const safeRun = runId.replace(/[^A-Za-z0-9_-]/g, "_");
34909
35635
  const safeSlug = slug.replace(/[^A-Za-z0-9_-]/g, "_");
34910
- return path95.join(STATE_DIR_REL, `run-continuation-${safeRun}-${safeSlug}.json`);
35636
+ return path98.join(STATE_DIR_REL, `run-continuation-${safeRun}-${safeSlug}.json`);
34911
35637
  }
34912
35638
  function legacyStateRelPath(runId) {
34913
35639
  const safe = runId.replace(/[^A-Za-z0-9_-]/g, "_");
34914
- return path95.join(STATE_DIR_REL, `run-continuation-${safe}.json`);
35640
+ return path98.join(STATE_DIR_REL, `run-continuation-${safe}.json`);
34915
35641
  }
34916
35642
  function readRunState(workspaceRoot3, runId, slug) {
34917
- const keyedFile = path95.join(workspaceRoot3, stateRelPath(runId, slug));
35643
+ const keyedFile = path98.join(workspaceRoot3, stateRelPath(runId, slug));
34918
35644
  const keyed = readState6(keyedFile);
34919
35645
  if (keyed !== null) return { state: keyed, from: "keyed", keyedFile };
34920
35646
  if (fileExists(keyedFile)) {
34921
35647
  return { state: null, from: "keyed", keyedFile };
34922
35648
  }
34923
- const legacy = readState6(path95.join(workspaceRoot3, legacyStateRelPath(runId)));
35649
+ const legacy = readState6(path98.join(workspaceRoot3, legacyStateRelPath(runId)));
34924
35650
  if (legacy === null) return { state: null, from: "none", keyedFile };
34925
35651
  if (legacy.roadmap !== void 0 && legacy.roadmap !== slug) {
34926
35652
  return { state: null, from: "none", keyedFile };
@@ -34933,25 +35659,25 @@ function writeState5(file, state) {
34933
35659
  function clearRunState(workspaceRoot3, runId, keyedFile, adoptedLegacy) {
34934
35660
  revokeBillingGrant(workspaceRoot3, runId);
34935
35661
  try {
34936
- fs94.rmSync(keyedFile, { force: true });
35662
+ fs96.rmSync(keyedFile, { force: true });
34937
35663
  } catch {
34938
35664
  }
34939
35665
  if (!adoptedLegacy) return;
34940
35666
  try {
34941
- fs94.rmSync(path95.join(workspaceRoot3, legacyStateRelPath(runId)), { force: true });
35667
+ fs96.rmSync(path98.join(workspaceRoot3, legacyStateRelPath(runId)), { force: true });
34942
35668
  } catch {
34943
35669
  }
34944
35670
  }
34945
35671
  function fileExists(p) {
34946
35672
  try {
34947
- return fs94.statSync(p).isFile();
35673
+ return fs96.statSync(p).isFile();
34948
35674
  } catch {
34949
35675
  return false;
34950
35676
  }
34951
35677
  }
34952
35678
  function readState6(file) {
34953
35679
  try {
34954
- const parsed = JSON.parse(fs94.readFileSync(file, "utf8"));
35680
+ const parsed = JSON.parse(fs96.readFileSync(file, "utf8"));
34955
35681
  if (parsed === null || typeof parsed !== "object") return null;
34956
35682
  const o = parsed;
34957
35683
  if (typeof o["started_at"] !== "string") return null;
@@ -34991,16 +35717,16 @@ function readState6(file) {
34991
35717
  }
34992
35718
  }
34993
35719
  function normalizeDir(p) {
34994
- const abs = path95.resolve(p);
35720
+ const abs = path98.resolve(p);
34995
35721
  try {
34996
- return fs94.realpathSync(abs);
35722
+ return fs96.realpathSync(abs);
34997
35723
  } catch {
34998
35724
  return abs;
34999
35725
  }
35000
35726
  }
35001
35727
  function normalizeFile(p) {
35002
- const abs = path95.resolve(p);
35003
- return path95.join(normalizeDir(path95.dirname(abs)), path95.basename(abs));
35728
+ const abs = path98.resolve(p);
35729
+ return path98.join(normalizeDir(path98.dirname(abs)), path98.basename(abs));
35004
35730
  }
35005
35731
  function provenance(workspaceRoot3, claimPath, sessionRoot, sessionCwd) {
35006
35732
  const reader = normalizeDir(workspaceRoot3);
@@ -35027,36 +35753,36 @@ function provenance(workspaceRoot3, claimPath, sessionRoot, sessionCwd) {
35027
35753
  };
35028
35754
  }
35029
35755
  function resolveRoadmap(sessionRoot, workspaceRoot3, slug) {
35030
- const dirRel = path95.join("agents", "roadmaps");
35756
+ const dirRel = path98.join("agents", "roadmaps");
35031
35757
  const stem = slug.trim().replace(/\.md$/, "");
35032
- const rel = path95.join(dirRel, `${stem}.md`);
35033
- const norm = path95.normalize(rel);
35034
- if (path95.dirname(norm) !== dirRel) return null;
35035
- if (sessionRoot !== workspaceRoot3 && isDirectory(path95.join(sessionRoot, dirRel))) {
35036
- return path95.join(sessionRoot, norm);
35758
+ const rel = path98.join(dirRel, `${stem}.md`);
35759
+ const norm = path98.normalize(rel);
35760
+ if (path98.dirname(norm) !== dirRel) return null;
35761
+ if (sessionRoot !== workspaceRoot3 && isDirectory(path98.join(sessionRoot, dirRel))) {
35762
+ return path98.join(sessionRoot, norm);
35037
35763
  }
35038
- return path95.join(normalizeDir(workspaceRoot3), norm);
35764
+ return path98.join(normalizeDir(workspaceRoot3), norm);
35039
35765
  }
35040
35766
  function isDirectory(p) {
35041
35767
  try {
35042
- return fs94.statSync(p).isDirectory();
35768
+ return fs96.statSync(p).isDirectory();
35043
35769
  } catch {
35044
35770
  return false;
35045
35771
  }
35046
35772
  }
35047
35773
  function eventAlreadyLogged(workspaceRoot3, runId, slug, event) {
35048
35774
  try {
35049
- const file = path95.join(workspaceRoot3, EVENTS_RELPATH);
35050
- const size = fs94.statSync(file).size;
35775
+ const file = path98.join(workspaceRoot3, EVENTS_RELPATH);
35776
+ const size = fs96.statSync(file).size;
35051
35777
  const start = Math.max(0, size - LEDGER_TAIL_MAX_BYTES);
35052
- const fd = fs94.openSync(file, "r");
35778
+ const fd = fs96.openSync(file, "r");
35053
35779
  let text;
35054
35780
  try {
35055
35781
  const buf = Buffer.alloc(size - start);
35056
- const read = fs94.readSync(fd, buf, 0, buf.length, start);
35782
+ const read = fs96.readSync(fd, buf, 0, buf.length, start);
35057
35783
  text = buf.subarray(0, read).toString("utf8");
35058
35784
  } finally {
35059
- fs94.closeSync(fd);
35785
+ fs96.closeSync(fd);
35060
35786
  }
35061
35787
  for (const line of text.split("\n")) {
35062
35788
  if (line === "") continue;
@@ -35079,9 +35805,9 @@ function eventAlreadyLogged(workspaceRoot3, runId, slug, event) {
35079
35805
  }
35080
35806
  function appendEvent2(workspaceRoot3, record) {
35081
35807
  try {
35082
- const file = path95.join(workspaceRoot3, EVENTS_RELPATH);
35083
- fs94.mkdirSync(path95.dirname(file), { recursive: true });
35084
- fs94.appendFileSync(file, `${JSON.stringify(record)}
35808
+ const file = path98.join(workspaceRoot3, EVENTS_RELPATH);
35809
+ fs96.mkdirSync(path98.dirname(file), { recursive: true });
35810
+ fs96.appendFileSync(file, `${JSON.stringify(record)}
35085
35811
  `, "utf8");
35086
35812
  } catch {
35087
35813
  }
@@ -35089,33 +35815,33 @@ function appendEvent2(workspaceRoot3, record) {
35089
35815
  function refusedThisTurn(workspaceRoot3, sessionId2, turnOrdinal) {
35090
35816
  try {
35091
35817
  const file = sessionRefusalFile(workspaceRoot3, deriveSessionKey(sessionId2 || "unknown-session"));
35092
- const rec = parseRecord(fs94.readFileSync(file, "utf-8"));
35818
+ const rec = parseRecord(fs96.readFileSync(file, "utf-8"));
35093
35819
  return rec !== null && rec.refused_turn === turnOrdinal;
35094
35820
  } catch {
35095
35821
  return false;
35096
35822
  }
35097
35823
  }
35098
- function str14(v) {
35824
+ function str15(v) {
35099
35825
  return typeof v === "string" ? v : "";
35100
35826
  }
35101
- function main61() {
35102
- if (is_replay_mode()) return EXIT_ALLOW32;
35103
- if (process.env["AGENT_CONFIG_NO_RUN_CONTINUATION"] === "1") return EXIT_ALLOW32;
35827
+ function main63() {
35828
+ if (is_replay_mode()) return EXIT_ALLOW33;
35829
+ if (process.env["AGENT_CONFIG_NO_RUN_CONTINUATION"] === "1") return EXIT_ALLOW33;
35104
35830
  let envelope;
35105
35831
  let payload;
35106
35832
  try {
35107
35833
  [envelope, payload] = unwrap(readHookStdin(), "claude");
35108
35834
  } catch {
35109
- return EXIT_ALLOW32;
35835
+ return EXIT_ALLOW33;
35110
35836
  }
35111
- const workspaceRoot3 = str14(envelope["workspace_root"]) || process.cwd();
35112
- const sessionId2 = str14(payload["session_id"]) || str14(envelope["session_id"]);
35837
+ const workspaceRoot3 = str15(envelope["workspace_root"]) || process.cwd();
35838
+ const sessionId2 = str15(payload["session_id"]) || str15(envelope["session_id"]);
35113
35839
  const claim = resolve_claim(workspaceRoot3, sessionId2 || null);
35114
- if (claim === null) return EXIT_ALLOW32;
35840
+ if (claim === null) return EXIT_ALLOW33;
35115
35841
  const slug = claim.slug;
35116
35842
  const sessionRoot = session_checkout(
35117
35843
  workspaceRoot3,
35118
- str14(payload["cwd"])
35844
+ str15(payload["cwd"])
35119
35845
  );
35120
35846
  const roadmapPath2 = resolveRoadmap(sessionRoot, workspaceRoot3, slug);
35121
35847
  const runId = deriveSessionKey(sessionId2 || "unknown-session");
@@ -35123,7 +35849,7 @@ function main61() {
35123
35849
  let roadmapText = null;
35124
35850
  if (roadmapPath2 !== null) {
35125
35851
  try {
35126
- roadmapText = fs94.readFileSync(roadmapPath2, "utf8");
35852
+ roadmapText = fs96.readFileSync(roadmapPath2, "utf8");
35127
35853
  roadmapFile = roadmapPath2;
35128
35854
  } catch {
35129
35855
  roadmapText = null;
@@ -35132,13 +35858,13 @@ function main61() {
35132
35858
  if (roadmapText === null || roadmapFile === null) {
35133
35859
  const runState = readRunState(workspaceRoot3, runId, slug);
35134
35860
  const driven = runState.state;
35135
- if (driven === null && runState.from === "none") return EXIT_ALLOW32;
35136
- if (driven?.halted !== void 0) return EXIT_ALLOW32;
35861
+ if (driven === null && runState.from === "none") return EXIT_ALLOW33;
35862
+ if (driven?.halted !== void 0) return EXIT_ALLOW33;
35137
35863
  const absenceRoots = provenance(
35138
35864
  workspaceRoot3,
35139
35865
  claim.path,
35140
35866
  sessionRoot,
35141
- str14(payload["cwd"])
35867
+ str15(payload["cwd"])
35142
35868
  );
35143
35869
  absenceRoots["roadmap_path"] = roadmapPath2;
35144
35870
  const absentFires = (driven?.absent_fires ?? 0) + 1;
@@ -35157,29 +35883,29 @@ function main61() {
35157
35883
  ...absenceRoots
35158
35884
  });
35159
35885
  }
35160
- if (driven === null) return EXIT_ALLOW32;
35886
+ if (driven === null) return EXIT_ALLOW33;
35161
35887
  if (absentFires < ABSENT_CONFIRM_FIRES) {
35162
35888
  driven.absent_fires = absentFires;
35163
35889
  writeState5(runState.keyedFile, driven);
35164
- return EXIT_ALLOW32;
35890
+ return EXIT_ALLOW33;
35165
35891
  }
35166
35892
  clearRunState(workspaceRoot3, runId, runState.keyedFile, runState.from === "legacy");
35167
- return EXIT_ALLOW32;
35893
+ return EXIT_ALLOW33;
35168
35894
  }
35169
- if (parseExecutionMode(roadmapText) !== "autonomous") return EXIT_ALLOW32;
35170
- const transcriptPath = str14(
35895
+ if (parseExecutionMode(roadmapText) !== "autonomous") return EXIT_ALLOW33;
35896
+ const transcriptPath = str15(
35171
35897
  payload["transcript_path"] ?? payload["transcriptPath"]
35172
35898
  );
35173
- if (!transcriptPath) return EXIT_ALLOW32;
35899
+ if (!transcriptPath) return EXIT_ALLOW33;
35174
35900
  try {
35175
- if (fs94.statSync(transcriptPath).size > TRANSCRIPT_READ_MAX_BYTES) {
35901
+ if (fs96.statSync(transcriptPath).size > TRANSCRIPT_READ_MAX_BYTES) {
35176
35902
  const inert = readRunState(workspaceRoot3, runId, slug);
35177
35903
  if (inert.state !== null && inert.state.inert_reported !== true) {
35178
35904
  const inertRoots = provenance(
35179
35905
  workspaceRoot3,
35180
35906
  claim.path,
35181
35907
  sessionRoot,
35182
- str14(payload["cwd"])
35908
+ str15(payload["cwd"])
35183
35909
  );
35184
35910
  inertRoots["roadmap_path"] = roadmapFile;
35185
35911
  appendEvent2(workspaceRoot3, {
@@ -35193,10 +35919,10 @@ function main61() {
35193
35919
  inert.state.inert_reported = true;
35194
35920
  writeState5(inert.keyedFile, inert.state);
35195
35921
  }
35196
- return EXIT_ALLOW32;
35922
+ return EXIT_ALLOW33;
35197
35923
  }
35198
35924
  } catch {
35199
- return EXIT_ALLOW32;
35925
+ return EXIT_ALLOW33;
35200
35926
  }
35201
35927
  let turnOrdinal = 0;
35202
35928
  try {
@@ -35204,13 +35930,13 @@ function main61() {
35204
35930
  maxBytes: TRANSCRIPT_READ_MAX_BYTES
35205
35931
  }).turnOrdinal;
35206
35932
  } catch {
35207
- return EXIT_ALLOW32;
35933
+ return EXIT_ALLOW33;
35208
35934
  }
35209
35935
  const roots = provenance(
35210
35936
  workspaceRoot3,
35211
35937
  claim.path,
35212
35938
  sessionRoot,
35213
- str14(payload["cwd"])
35939
+ str15(payload["cwd"])
35214
35940
  );
35215
35941
  roots["roadmap_path"] = roadmapFile;
35216
35942
  if (refusedThisTurn(workspaceRoot3, sessionId2, turnOrdinal)) {
@@ -35222,7 +35948,7 @@ function main61() {
35222
35948
  at: (/* @__PURE__ */ new Date()).toISOString(),
35223
35949
  ...roots
35224
35950
  });
35225
- return EXIT_ALLOW32;
35951
+ return EXIT_ALLOW33;
35226
35952
  }
35227
35953
  const mainState = readRunState(workspaceRoot3, runId, slug);
35228
35954
  const stateFile4 = mainState.keyedFile;
@@ -35266,24 +35992,24 @@ function main61() {
35266
35992
  }
35267
35993
  if (action === "complete") {
35268
35994
  clearRunState(workspaceRoot3, runId, stateFile4, mainState.from === "legacy");
35269
- return EXIT_ALLOW32;
35995
+ return EXIT_ALLOW33;
35270
35996
  }
35271
35997
  if (action === "blocked") {
35272
35998
  clearRunState(workspaceRoot3, runId, stateFile4, mainState.from === "legacy");
35273
- return EXIT_ALLOW32;
35999
+ return EXIT_ALLOW33;
35274
36000
  }
35275
36001
  if (!state.halted) {
35276
36002
  state.halted = action;
35277
36003
  writeState5(stateFile4, state);
35278
36004
  }
35279
- return EXIT_ALLOW32;
36005
+ return EXIT_ALLOW33;
35280
36006
  }
35281
36007
  state.iterations += 1;
35282
36008
  state.last_turn = turnOrdinal;
35283
36009
  state.history.push(scan.open);
35284
36010
  state.last_engaged_at = (/* @__PURE__ */ new Date()).toISOString();
35285
36011
  if (!writeState5(stateFile4, state)) {
35286
- return EXIT_ALLOW32;
36012
+ return EXIT_ALLOW33;
35287
36013
  }
35288
36014
  appendEvent2(workspaceRoot3, {
35289
36015
  event: "engage",
@@ -35307,34 +36033,34 @@ ${stepLine}
35307
36033
  Continue with this step now: do the work, run its verify line, flip the box, then end the turn. Escalate instead of continuing ONLY for a locked decision class (high_impact / user_required) or a halt your contract names.
35308
36034
  `;
35309
36035
  }
35310
- function _isCliEntry49() {
36036
+ function _isCliEntry50() {
35311
36037
  if (true) {
35312
36038
  return false;
35313
36039
  }
35314
36040
  if (process.argv[1] === void 0) return false;
35315
- const argvUrl = pathToFileURL56(path95.resolve(process.argv[1])).href;
36041
+ const argvUrl = pathToFileURL57(path98.resolve(process.argv[1])).href;
35316
36042
  if (import.meta.url === argvUrl) return true;
35317
36043
  try {
35318
- const here = fs94.realpathSync(fileURLToPath62(import.meta.url));
35319
- const argv = fs94.realpathSync(path95.resolve(process.argv[1]));
36044
+ const here = fs96.realpathSync(fileURLToPath64(import.meta.url));
36045
+ const argv = fs96.realpathSync(path98.resolve(process.argv[1]));
35320
36046
  return here === argv;
35321
36047
  } catch {
35322
36048
  return false;
35323
36049
  }
35324
36050
  }
35325
- if (_isCliEntry49()) {
35326
- process.exit(main61());
36051
+ if (_isCliEntry50()) {
36052
+ process.exit(main63());
35327
36053
  }
35328
36054
 
35329
36055
  // src/scripts/hooks/journal_record_hook.ts
35330
- import * as fs96 from "node:fs";
35331
- import * as path97 from "node:path";
35332
- import { fileURLToPath as fileURLToPath63, pathToFileURL as pathToFileURL57 } from "node:url";
36056
+ import * as fs98 from "node:fs";
36057
+ import * as path100 from "node:path";
36058
+ import { fileURLToPath as fileURLToPath65, pathToFileURL as pathToFileURL58 } from "node:url";
35333
36059
 
35334
36060
  // src/scripts/_lib/runtime_journal.ts
35335
36061
  import * as crypto14 from "node:crypto";
35336
- import * as fs95 from "node:fs";
35337
- import * as path96 from "node:path";
36062
+ import * as fs97 from "node:fs";
36063
+ import * as path99 from "node:path";
35338
36064
 
35339
36065
  // src/scripts/_lib/outcome_vocabularies.ts
35340
36066
  var RUN_TERMINAL_STATES = [
@@ -35437,7 +36163,7 @@ function requireId(name, id, optional) {
35437
36163
  }
35438
36164
  var JOURNAL_DIR_NAME = "agent-journal";
35439
36165
  var JOURNAL_FILE_NAME = "journal.sqlite";
35440
- var JOURNAL_FALLBACK_REL = path96.join("agents", "runtime", "state", JOURNAL_FILE_NAME);
36166
+ var JOURNAL_FALLBACK_REL = path99.join("agents", "runtime", "state", JOURNAL_FILE_NAME);
35441
36167
  function digest(domain, input) {
35442
36168
  return crypto14.createHash("sha256").update(`${domain}\0${input}`).digest("hex").slice(0, 12);
35443
36169
  }
@@ -35448,20 +36174,20 @@ function resolveJournal(root) {
35448
36174
  if (common !== null) {
35449
36175
  const own = git_dir(root) ?? common;
35450
36176
  return {
35451
- path: path96.join(common, JOURNAL_DIR_NAME, JOURNAL_FILE_NAME),
36177
+ path: path99.join(common, JOURNAL_DIR_NAME, JOURNAL_FILE_NAME),
35452
36178
  scope: "repo-shared",
35453
36179
  reason: "common git dir resolved \u2014 every worktree of this repo writes one database",
35454
36180
  repository_id: digest(REPO_DOMAIN, common),
35455
36181
  worktree_id: digest(WORKTREE_DOMAIN, own)
35456
36182
  };
35457
36183
  }
35458
- let real = path96.resolve(root);
36184
+ let real = path99.resolve(root);
35459
36185
  try {
35460
- real = fs95.realpathSync(real);
36186
+ real = fs97.realpathSync(real);
35461
36187
  } catch {
35462
36188
  }
35463
36189
  return {
35464
- path: path96.join(real, JOURNAL_FALLBACK_REL),
36190
+ path: path99.join(real, JOURNAL_FALLBACK_REL),
35465
36191
  scope: "worktree-local",
35466
36192
  reason: "no common git dir \u2014 not inside a git repository; falling back to the tree-local path",
35467
36193
  repository_id: digest(REPO_DOMAIN, real),
@@ -35547,7 +36273,7 @@ function ensureWal(db) {
35547
36273
  function discard(dbPath) {
35548
36274
  for (const p of [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]) {
35549
36275
  try {
35550
- fs95.rmSync(p, { force: true });
36276
+ fs97.rmSync(p, { force: true });
35551
36277
  } catch {
35552
36278
  }
35553
36279
  }
@@ -35559,9 +36285,9 @@ function openJournal(root) {
35559
36285
  );
35560
36286
  }
35561
36287
  const location = resolveJournal(root);
35562
- fs95.mkdirSync(path96.dirname(location.path), { recursive: true });
36288
+ fs97.mkdirSync(path99.dirname(location.path), { recursive: true });
35563
36289
  const { DatabaseSync } = loadSqliteSync("runtime_journal");
35564
- if (fs95.existsSync(location.path)) {
36290
+ if (fs97.existsSync(location.path)) {
35565
36291
  let drift = false;
35566
36292
  let probe = null;
35567
36293
  try {
@@ -35707,14 +36433,14 @@ function recordEvent(h, input) {
35707
36433
  }
35708
36434
 
35709
36435
  // src/scripts/hooks/journal_record_hook.ts
35710
- var EXIT_ALLOW33 = 0;
36436
+ var EXIT_ALLOW34 = 0;
35711
36437
  var SETTINGS_SECTION = "runtime_journal";
35712
- function isObject17(v) {
36438
+ function isObject18(v) {
35713
36439
  return typeof v === "object" && v !== null && !Array.isArray(v);
35714
36440
  }
35715
36441
  function unwrapPayload7(envelope) {
35716
36442
  const inner = envelope["payload"];
35717
- return isObject17(inner) ? inner : envelope;
36443
+ return isObject18(inner) ? inner : envelope;
35718
36444
  }
35719
36445
  function firstString(envelope, payload, keys) {
35720
36446
  for (const source of [envelope, payload]) {
@@ -35757,7 +36483,7 @@ function reduceEnvelope(envelope) {
35757
36483
  };
35758
36484
  }
35759
36485
  function resolveConsumerRoot3(envelope) {
35760
- if (isObject17(envelope)) {
36486
+ if (isObject18(envelope)) {
35761
36487
  for (const key of ["workspace_root", "project_root"]) {
35762
36488
  const v = envelope[key];
35763
36489
  if (typeof v === "string" && v) return v;
@@ -35769,12 +36495,12 @@ function resolveConsumerRoot3(envelope) {
35769
36495
  }
35770
36496
  function processEnvelope7(envelope, consumerRoot) {
35771
36497
  try {
35772
- if (!isObject17(envelope)) return EXIT_ALLOW33;
35773
- if (is_replay_mode()) return EXIT_ALLOW33;
35774
- if (!hookSectionEnabled(consumerRoot, SETTINGS_SECTION)) return EXIT_ALLOW33;
35775
- if (!isJournalAvailable()) return EXIT_ALLOW33;
36498
+ if (!isObject18(envelope)) return EXIT_ALLOW34;
36499
+ if (is_replay_mode()) return EXIT_ALLOW34;
36500
+ if (!hookSectionEnabled(consumerRoot, SETTINGS_SECTION)) return EXIT_ALLOW34;
36501
+ if (!isJournalAvailable()) return EXIT_ALLOW34;
35776
36502
  const input = reduceEnvelope(envelope);
35777
- if (input === null) return EXIT_ALLOW33;
36503
+ if (input === null) return EXIT_ALLOW34;
35778
36504
  withJournal(consumerRoot, (h) => {
35779
36505
  recordEvent(h, {
35780
36506
  event: input.event,
@@ -35785,34 +36511,34 @@ function processEnvelope7(envelope, consumerRoot) {
35785
36511
  });
35786
36512
  });
35787
36513
  } catch {
35788
- return EXIT_ALLOW33;
36514
+ return EXIT_ALLOW34;
35789
36515
  }
35790
- return EXIT_ALLOW33;
36516
+ return EXIT_ALLOW34;
35791
36517
  }
35792
- function main62() {
36518
+ function main64() {
35793
36519
  const raw = readHookStdin();
35794
36520
  let envelope = {};
35795
36521
  try {
35796
36522
  envelope = raw.trim() ? JSON.parse(raw) : {};
35797
36523
  } catch {
35798
- return EXIT_ALLOW33;
36524
+ return EXIT_ALLOW34;
35799
36525
  }
35800
36526
  return processEnvelope7(envelope, resolveConsumerRoot3(envelope));
35801
36527
  }
35802
- function _isCliEntry50() {
36528
+ function _isCliEntry51() {
35803
36529
  if (true) {
35804
36530
  return false;
35805
36531
  }
35806
36532
  if (process.argv[1] === void 0) return false;
35807
- const argvUrl = pathToFileURL57(path97.resolve(process.argv[1])).href;
36533
+ const argvUrl = pathToFileURL58(path100.resolve(process.argv[1])).href;
35808
36534
  if (import.meta.url === argvUrl) return true;
35809
36535
  try {
35810
- return fs96.realpathSync(fileURLToPath63(import.meta.url)) === fs96.realpathSync(path97.resolve(process.argv[1]));
36536
+ return fs98.realpathSync(fileURLToPath65(import.meta.url)) === fs98.realpathSync(path100.resolve(process.argv[1]));
35811
36537
  } catch {
35812
36538
  return false;
35813
36539
  }
35814
36540
  }
35815
- if (_isCliEntry50()) process.exit(main62());
36541
+ if (_isCliEntry51()) process.exit(main64());
35816
36542
 
35817
36543
  // src/scripts/hooks/concern_registry.ts
35818
36544
  var CONCERN_REGISTRY = {
@@ -35861,15 +36587,16 @@ var CONCERN_REGISTRY = {
35861
36587
  "src/scripts/hooks/end_review_nudge_hook.ts": main51,
35862
36588
  "src/scripts/hooks/turn_end_gate_hook.ts": main53,
35863
36589
  "src/scripts/hooks/edit_shape_hook.ts": main54,
35864
- "src/scripts/hooks/reread_guard_hook.ts": main55,
35865
- "src/scripts/hooks/session_eol_hook.ts": main56,
36590
+ "src/scripts/hooks/comment_discipline_hook.ts": main56,
36591
+ "src/scripts/hooks/reread_guard_hook.ts": main57,
36592
+ "src/scripts/hooks/session_eol_hook.ts": main58,
35866
36593
  "src/scripts/hooks/subagent_ledger_hook.ts": main52,
35867
- "src/scripts/hooks/tool_result_bytes_hook.ts": main57,
35868
- "src/scripts/hooks/spawn_guard_shadow_hook.ts": main58,
35869
- "src/scripts/hooks/source_first_gate_hook.ts": main59,
35870
- "src/scripts/hooks/interruption_ledger_hook.ts": main60,
35871
- "src/scripts/hooks/run_continuation_hook.ts": main61,
35872
- "src/scripts/hooks/journal_record_hook.ts": main62
36594
+ "src/scripts/hooks/tool_result_bytes_hook.ts": main59,
36595
+ "src/scripts/hooks/spawn_guard_shadow_hook.ts": main60,
36596
+ "src/scripts/hooks/source_first_gate_hook.ts": main61,
36597
+ "src/scripts/hooks/interruption_ledger_hook.ts": main62,
36598
+ "src/scripts/hooks/run_continuation_hook.ts": main63,
36599
+ "src/scripts/hooks/journal_record_hook.ts": main64
35873
36600
  };
35874
36601
 
35875
36602
  // src/scripts/hooks/stdin_failure_policy.ts
@@ -35969,8 +36696,8 @@ function _py_json_dumps2(value, indent) {
35969
36696
 
35970
36697
  // src/scripts/_lib/collector_denominator.ts
35971
36698
  import crypto15 from "node:crypto";
35972
- import fs98 from "node:fs";
35973
- import path99 from "node:path";
36699
+ import fs100 from "node:fs";
36700
+ import path102 from "node:path";
35974
36701
 
35975
36702
  // src/scripts/_lib/collector_record.ts
35976
36703
  var COLLECTOR_EVENTS = [
@@ -36047,30 +36774,30 @@ var FIELD_PURPOSE = {
36047
36774
  var ALLOWED_FIELDS = new Set(Object.keys(FIELD_PURPOSE));
36048
36775
 
36049
36776
  // src/scripts/_lib/collector_store.ts
36050
- import * as fs97 from "node:fs";
36051
- import * as os11 from "node:os";
36052
- import * as path98 from "node:path";
36777
+ import * as fs99 from "node:fs";
36778
+ import * as os12 from "node:os";
36779
+ import * as path101 from "node:path";
36053
36780
  var COLLECTOR_DIR_NAME = "agent-collector";
36054
36781
  var COLLECTOR_FILE_NAME = "collector.sqlite";
36055
36782
  var OPT_OUT_MARKER_NAME = "OPT-OUT";
36056
36783
  var MIGRATION_MARKER_NAME = "MIGRATION-IN-FLIGHT";
36057
36784
  var QUARANTINE_DIR_NAME = "quarantine";
36058
36785
  function defaultUserRoot() {
36059
- return path98.join(os11.homedir(), ".event4u", "agent-config");
36786
+ return path101.join(os12.homedir(), ".event4u", "agent-config");
36060
36787
  }
36061
36788
  function resolveCollectorStore(userRoot = defaultUserRoot()) {
36062
- const dir = path98.join(userRoot, COLLECTOR_DIR_NAME);
36789
+ const dir = path101.join(userRoot, COLLECTOR_DIR_NAME);
36063
36790
  return {
36064
36791
  userRoot,
36065
36792
  root: dir,
36066
- path: path98.join(dir, COLLECTOR_FILE_NAME),
36067
- optOutMarker: path98.join(dir, OPT_OUT_MARKER_NAME),
36068
- migrationMarker: path98.join(dir, MIGRATION_MARKER_NAME),
36069
- quarantineDir: path98.join(dir, QUARANTINE_DIR_NAME)
36793
+ path: path101.join(dir, COLLECTOR_FILE_NAME),
36794
+ optOutMarker: path101.join(dir, OPT_OUT_MARKER_NAME),
36795
+ migrationMarker: path101.join(dir, MIGRATION_MARKER_NAME),
36796
+ quarantineDir: path101.join(dir, QUARANTINE_DIR_NAME)
36070
36797
  };
36071
36798
  }
36072
36799
  function isOptedOut(userRoot = defaultUserRoot()) {
36073
- return fs97.existsSync(resolveCollectorStore(userRoot).optOutMarker);
36800
+ return fs99.existsSync(resolveCollectorStore(userRoot).optOutMarker);
36074
36801
  }
36075
36802
  var MIGRATIONS = Object.freeze({
36076
36803
  // 0 → 1. No DDL: `user_version` 0 is the default SQLite assigns, and a
@@ -36087,24 +36814,24 @@ var SPOOL_DIR_NAME = "spool";
36087
36814
  var SPOOL_PENDING_NAME = "pending.jsonl";
36088
36815
  var ENABLED_MARKER_NAME = "ENABLED";
36089
36816
  function denominatorPath(userRoot) {
36090
- return path99.join(resolveCollectorStore(userRoot).root, DENOMINATOR_FILE_NAME);
36817
+ return path102.join(resolveCollectorStore(userRoot).root, DENOMINATOR_FILE_NAME);
36091
36818
  }
36092
36819
  function spoolDir(userRoot) {
36093
- return path99.join(resolveCollectorStore(userRoot).root, SPOOL_DIR_NAME);
36820
+ return path102.join(resolveCollectorStore(userRoot).root, SPOOL_DIR_NAME);
36094
36821
  }
36095
36822
  function spoolPendingPath(userRoot) {
36096
- return path99.join(spoolDir(userRoot), SPOOL_PENDING_NAME);
36823
+ return path102.join(spoolDir(userRoot), SPOOL_PENDING_NAME);
36097
36824
  }
36098
36825
  function enabledMarkerPath(userRoot) {
36099
- return path99.join(resolveCollectorStore(userRoot).root, ENABLED_MARKER_NAME);
36826
+ return path102.join(resolveCollectorStore(userRoot).root, ENABLED_MARKER_NAME);
36100
36827
  }
36101
36828
  function isCollectorEnabled(userRoot) {
36102
36829
  if (isOptedOut(userRoot)) return false;
36103
- if (fs98.existsSync(killSwitchPathLocal(userRoot))) return false;
36104
- return fs98.existsSync(enabledMarkerPath(userRoot));
36830
+ if (fs100.existsSync(killSwitchPathLocal(userRoot))) return false;
36831
+ return fs100.existsSync(enabledMarkerPath(userRoot));
36105
36832
  }
36106
36833
  function killSwitchPathLocal(userRoot) {
36107
- return path99.join(resolveCollectorStore(userRoot).root, "STOP");
36834
+ return path102.join(resolveCollectorStore(userRoot).root, "STOP");
36108
36835
  }
36109
36836
  function utcDate(at = Date.now()) {
36110
36837
  return new Date(at).toISOString().slice(0, 10);
@@ -36116,8 +36843,8 @@ function recordOpportunity(event, platform, userRoot, at = Date.now(), opts = {}
36116
36843
  if (!COLLECTOR_EVENTS.includes(event)) return false;
36117
36844
  if (!COLLECTOR_PLATFORMS.includes(platform)) return false;
36118
36845
  const target = denominatorPath(userRoot);
36119
- fs98.mkdirSync(path99.dirname(target), { recursive: true });
36120
- fs98.appendFileSync(target, `${utcDate(at)} ${event} ${platform}
36846
+ fs100.mkdirSync(path102.dirname(target), { recursive: true });
36847
+ fs100.appendFileSync(target, `${utcDate(at)} ${event} ${platform}
36121
36848
  `);
36122
36849
  return true;
36123
36850
  } catch {
@@ -36131,19 +36858,19 @@ var MACHINE_ID_NAME = "machine-id";
36131
36858
  var EPISODE_DIR_NAME = "episodes";
36132
36859
  var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
36133
36860
  function machineIdPath(userRoot) {
36134
- return path99.join(resolveCollectorStore(userRoot).root, MACHINE_ID_NAME);
36861
+ return path102.join(resolveCollectorStore(userRoot).root, MACHINE_ID_NAME);
36135
36862
  }
36136
36863
  function machineId(userRoot) {
36137
36864
  const target = machineIdPath(userRoot);
36138
36865
  try {
36139
- const existing = fs98.readFileSync(target, "utf8").trim();
36866
+ const existing = fs100.readFileSync(target, "utf8").trim();
36140
36867
  if (UUID_RE.test(existing)) return existing;
36141
36868
  } catch {
36142
36869
  }
36143
36870
  try {
36144
36871
  const minted = crypto15.randomUUID();
36145
- fs98.mkdirSync(path99.dirname(target), { recursive: true });
36146
- fs98.writeFileSync(target, `${minted}
36872
+ fs100.mkdirSync(path102.dirname(target), { recursive: true });
36873
+ fs100.writeFileSync(target, `${minted}
36147
36874
  `);
36148
36875
  return minted;
36149
36876
  } catch {
@@ -36167,17 +36894,17 @@ function episodeId(env = process.env) {
36167
36894
  ].join("-");
36168
36895
  }
36169
36896
  function nextSequence(episode, userRoot) {
36170
- const dir = path99.join(resolveCollectorStore(userRoot).root, EPISODE_DIR_NAME);
36171
- const target = path99.join(dir, `${episode}.seq`);
36897
+ const dir = path102.join(resolveCollectorStore(userRoot).root, EPISODE_DIR_NAME);
36898
+ const target = path102.join(dir, `${episode}.seq`);
36172
36899
  try {
36173
- fs98.mkdirSync(dir, { recursive: true });
36900
+ fs100.mkdirSync(dir, { recursive: true });
36174
36901
  let current = 0;
36175
36902
  try {
36176
- const raw = Number.parseInt(fs98.readFileSync(target, "utf8").trim(), 10);
36903
+ const raw = Number.parseInt(fs100.readFileSync(target, "utf8").trim(), 10);
36177
36904
  if (Number.isInteger(raw) && raw >= 0) current = raw + 1;
36178
36905
  } catch {
36179
36906
  }
36180
- fs98.writeFileSync(target, `${current}
36907
+ fs100.writeFileSync(target, `${current}
36181
36908
  `);
36182
36909
  return current;
36183
36910
  } catch {
@@ -36216,12 +36943,12 @@ function spoolRecord(record, userRoot) {
36216
36943
  try {
36217
36944
  if (!isCollectorEnabled(userRoot)) return false;
36218
36945
  const target = spoolPendingPath(userRoot);
36219
- fs98.mkdirSync(path99.dirname(target), { recursive: true });
36946
+ fs100.mkdirSync(path102.dirname(target), { recursive: true });
36220
36947
  try {
36221
- if (fs98.statSync(target).size >= SPOOL_MAX_BYTES) return false;
36948
+ if (fs100.statSync(target).size >= SPOOL_MAX_BYTES) return false;
36222
36949
  } catch {
36223
36950
  }
36224
- fs98.appendFileSync(target, `${JSON.stringify(record)}
36951
+ fs100.appendFileSync(target, `${JSON.stringify(record)}
36225
36952
  `);
36226
36953
  return true;
36227
36954
  } catch {
@@ -36231,14 +36958,14 @@ function spoolRecord(record, userRoot) {
36231
36958
 
36232
36959
  // src/scripts/hooks/dispatch_hook.ts
36233
36960
  var _IN_BUNDLE = true;
36234
- var REPO_ROOT = path100.resolve(
36235
- path100.dirname(fileURLToPath64(import.meta.url)),
36961
+ var REPO_ROOT = path103.resolve(
36962
+ path103.dirname(fileURLToPath66(import.meta.url)),
36236
36963
  ..._IN_BUNDLE ? ["..", ".."] : ["..", "..", ".."]
36237
36964
  );
36238
- var MANIFEST_PATH = path100.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
36239
- var EXIT_ALLOW34 = 0;
36965
+ var MANIFEST_PATH = path103.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
36966
+ var EXIT_ALLOW35 = 0;
36240
36967
  var EXIT_BLOCK6 = 1;
36241
- var EXIT_WARN17 = 2;
36968
+ var EXIT_WARN18 = 2;
36242
36969
  var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
36243
36970
  "session_start",
36244
36971
  "session_end",
@@ -36252,9 +36979,9 @@ var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
36252
36979
  "subagent_stop"
36253
36980
  ]);
36254
36981
  var _SEVERITY_BY_EXIT = {
36255
- [EXIT_ALLOW34]: "allow",
36982
+ [EXIT_ALLOW35]: "allow",
36256
36983
  [EXIT_BLOCK6]: "block",
36257
- [EXIT_WARN17]: "warn"
36984
+ [EXIT_WARN18]: "warn"
36258
36985
  };
36259
36986
  function _isObject17(v) {
36260
36987
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -36297,11 +37024,11 @@ function _manifest_fingerprint(text) {
36297
37024
  return `${h.toString(16)}:${String(text.length)}`;
36298
37025
  }
36299
37026
  function _load_yaml3(p) {
36300
- const text = fs99.readFileSync(p, "utf-8");
37027
+ const text = fs101.readFileSync(p, "utf-8");
36301
37028
  const compiled = p.replace(/\.ya?ml$/u, ".json");
36302
37029
  if (compiled !== p) {
36303
37030
  try {
36304
- const raw = JSON.parse(fs99.readFileSync(compiled, "utf-8"));
37031
+ const raw = JSON.parse(fs101.readFileSync(compiled, "utf-8"));
36305
37032
  if (_isObject17(raw) && raw["fingerprint"] === _manifest_fingerprint(text) && _isObject17(raw["manifest"])) {
36306
37033
  return raw["manifest"];
36307
37034
  }
@@ -36407,7 +37134,7 @@ function _maybe_capture_payload(args, payload_text) {
36407
37134
  }
36408
37135
  try {
36409
37136
  const target = _expanduser3(capture_dir);
36410
- fs99.mkdirSync(target, { recursive: true });
37137
+ fs101.mkdirSync(target, { recursive: true });
36411
37138
  let payload;
36412
37139
  try {
36413
37140
  payload = payload_text.trim() ? JSON.parse(payload_text) : {};
@@ -36424,8 +37151,8 @@ function _maybe_capture_payload(args, payload_text) {
36424
37151
  const ts = Date.now();
36425
37152
  const native = (args.native_event || args.event).replace(/\//g, "_");
36426
37153
  const fname = `${args.platform}__${native}__${ts}__${process.pid}.json`;
36427
- fs99.writeFileSync(
36428
- path100.join(target, fname),
37154
+ fs101.writeFileSync(
37155
+ path103.join(target, fname),
36429
37156
  _py_json_dumps2(record, 2) + "\n",
36430
37157
  { encoding: "utf-8" }
36431
37158
  );
@@ -36436,7 +37163,7 @@ function _maybe_capture_payload(args, payload_text) {
36436
37163
  function _expanduser3(p) {
36437
37164
  if (p === "~" || p.startsWith("~/")) {
36438
37165
  const home = process.env["HOME"] || process.env["USERPROFILE"] || "";
36439
- return path100.join(home, p.slice(1));
37166
+ return path103.join(home, p.slice(1));
36440
37167
  }
36441
37168
  return p;
36442
37169
  }
@@ -36468,25 +37195,25 @@ function _resolve_tsx_invocation2(scriptPath, scriptArgs) {
36468
37195
  const walkUp = (start) => {
36469
37196
  let dir = start;
36470
37197
  for (; ; ) {
36471
- const candidate = path100.join(dir, "node_modules", ".bin", binName);
37198
+ const candidate = path103.join(dir, "node_modules", ".bin", binName);
36472
37199
  if (_isFile8(candidate)) {
36473
37200
  return candidate;
36474
37201
  }
36475
- const parent = path100.dirname(dir);
37202
+ const parent = path103.dirname(dir);
36476
37203
  if (parent === dir) {
36477
37204
  return null;
36478
37205
  }
36479
37206
  dir = parent;
36480
37207
  }
36481
37208
  };
36482
- const tsx = walkUp(path100.dirname(scriptPath)) ?? walkUp(path100.dirname(fileURLToPath64(import.meta.url)));
37209
+ const tsx = walkUp(path103.dirname(scriptPath)) ?? walkUp(path103.dirname(fileURLToPath66(import.meta.url)));
36483
37210
  if (tsx !== null) {
36484
37211
  return { command: tsx, args: [scriptPath, ...scriptArgs] };
36485
37212
  }
36486
37213
  return { command: "npx", args: ["tsx", scriptPath, ...scriptArgs] };
36487
37214
  }
36488
37215
  function _run_concern_inproc(main_fn, concern, envelope) {
36489
- const scriptAbs = path100.join(REPO_ROOT, String(concern["script"]));
37216
+ const scriptAbs = path103.join(REPO_ROOT, String(concern["script"]));
36490
37217
  const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
36491
37218
  argsList.push("--platform", String(envelope["platform"] || "generic"));
36492
37219
  const workspace = String(envelope["workspace_root"] || process.cwd());
@@ -36563,7 +37290,7 @@ function _run_concern(concern, envelope) {
36563
37290
  return _run_concern_inproc(inproc, concern, envelope);
36564
37291
  }
36565
37292
  }
36566
- const script = path100.join(REPO_ROOT, String(concern["script"]));
37293
+ const script = path103.join(REPO_ROOT, String(concern["script"]));
36567
37294
  const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
36568
37295
  const cmd = [script, ...argsList];
36569
37296
  cmd.push("--platform", String(envelope["platform"] || "generic"));
@@ -36586,7 +37313,7 @@ function _run_concern(concern, envelope) {
36586
37313
  const concern_env = hardenedSpawnEnv({ AGENT_CONFIG_PACKAGE_ROOT: REPO_ROOT });
36587
37314
  const started = performance.now();
36588
37315
  const { command, args: spawnArgs } = _resolve_tsx_invocation2(script, cmd.slice(1));
36589
- const proc = spawnSync8(command, spawnArgs, {
37316
+ const proc = spawnSync10(command, spawnArgs, {
36590
37317
  input: _compactJsonDumps(envelope),
36591
37318
  encoding: "utf-8",
36592
37319
  cwd: workspace,
@@ -36620,7 +37347,7 @@ function _run_concern(concern, envelope) {
36620
37347
  }
36621
37348
  function _isFile8(p) {
36622
37349
  try {
36623
- return fs99.statSync(p).isFile();
37350
+ return fs101.statSync(p).isFile();
36624
37351
  } catch {
36625
37352
  return false;
36626
37353
  }
@@ -36632,20 +37359,20 @@ function _reduce(rcs) {
36632
37359
  if (rcs.some((rc) => rc === EXIT_BLOCK6)) {
36633
37360
  return EXIT_BLOCK6;
36634
37361
  }
36635
- if (rcs.some((rc) => rc === EXIT_WARN17)) {
36636
- return EXIT_WARN17;
37362
+ if (rcs.some((rc) => rc === EXIT_WARN18)) {
37363
+ return EXIT_WARN18;
36637
37364
  }
36638
- return EXIT_ALLOW34;
37365
+ return EXIT_ALLOW35;
36639
37366
  }
36640
37367
  function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
36641
37368
  if (is_replay_mode()) {
36642
37369
  return;
36643
37370
  }
36644
37371
  const workspace = String(envelope["workspace_root"] || process.cwd());
36645
- const state_root = path100.join(workspace, "agents", "runtime", "state");
37372
+ const state_root = path103.join(workspace, "agents", "runtime", "state");
36646
37373
  const fb_dir = feedback_dir(state_root, session_id);
36647
37374
  try {
36648
- fs99.mkdirSync(fb_dir, { recursive: true });
37375
+ fs101.mkdirSync(fb_dir, { recursive: true });
36649
37376
  } catch (exc) {
36650
37377
  const msg = exc instanceof Error ? exc.message : String(exc);
36651
37378
  process.stderr.write(`dispatch_hook: feedback dir unavailable: ${msg}
@@ -36653,7 +37380,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
36653
37380
  return;
36654
37381
  }
36655
37382
  for (const entry of entries) {
36656
- const target = path100.join(fb_dir, `${entry["concern"]}.json`);
37383
+ const target = path103.join(fb_dir, `${entry["concern"]}.json`);
36657
37384
  try {
36658
37385
  atomic_write_json(target, entry);
36659
37386
  } catch (exc) {
@@ -36702,7 +37429,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
36702
37429
  };
36703
37430
  try {
36704
37431
  const invocation = `${String(process.pid)}-${process.hrtime.bigint().toString()}`;
36705
- update_json_under_lock(path100.join(fb_dir, "summary.json"), (loaded) => {
37432
+ update_json_under_lock(path103.join(fb_dir, "summary.json"), (loaded) => {
36706
37433
  const priorRaw = loaded["invocations"];
36707
37434
  const prior = Array.isArray(priorRaw) ? priorRaw : [];
36708
37435
  const next = [...prior, { invocation, ...summary }];
@@ -36724,13 +37451,13 @@ var SUMMARY_INVOCATION_CAP = 20;
36724
37451
  function _record_rule_trips(envelope, entries) {
36725
37452
  if (is_replay_mode()) return;
36726
37453
  const tripped = entries.filter(
36727
- (e) => e["exit_code"] === EXIT_BLOCK6 || e["exit_code"] === EXIT_WARN17
37454
+ (e) => e["exit_code"] === EXIT_BLOCK6 || e["exit_code"] === EXIT_WARN18
36728
37455
  );
36729
37456
  if (tripped.length === 0) return;
36730
37457
  try {
36731
37458
  const workspace = String(envelope["workspace_root"] || process.cwd());
36732
- const state_dir = path100.join(workspace, "agents", "runtime", "state");
36733
- const target = path100.join(state_dir, "rule-trips.json");
37459
+ const state_dir = path103.join(workspace, "agents", "runtime", "state");
37460
+ const target = path103.join(state_dir, "rule-trips.json");
36734
37461
  const today = _now_iso3().slice(0, 10);
36735
37462
  update_json_under_lock(target, (loaded) => {
36736
37463
  const doc = { schema_version: 1, concerns: {}, ...loaded };
@@ -36742,7 +37469,7 @@ function _record_rule_trips(envelope, entries) {
36742
37469
  const prev = _isObject17(prevRaw) ? prevRaw : { block: 0, warn: 0 };
36743
37470
  concerns[name] = {
36744
37471
  block: (Number(prev["block"]) || 0) + (e["exit_code"] === EXIT_BLOCK6 ? 1 : 0),
36745
- warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN17 ? 1 : 0),
37472
+ warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN18 ? 1 : 0),
36746
37473
  last_trip: today
36747
37474
  };
36748
37475
  }
@@ -36835,7 +37562,7 @@ function _parse_args(argv) {
36835
37562
  }
36836
37563
  return args;
36837
37564
  }
36838
- function main63(argv) {
37565
+ function main65(argv) {
36839
37566
  const args = _parse_args(argv ?? process.argv.slice(2));
36840
37567
  if (args.project_dir) {
36841
37568
  const project_dir = _expanduser3(args.project_dir);
@@ -36853,29 +37580,29 @@ function main63(argv) {
36853
37580
  if (probe.failure !== null) {
36854
37581
  process.stderr.write(`dispatch_hook: --read-exit read failed: ${probe.failure}
36855
37582
  `);
36856
- return EXIT_ALLOW34;
37583
+ return EXIT_ALLOW35;
36857
37584
  }
36858
37585
  const envelope2 = _build_envelope(args, probe.text);
36859
37586
  process.stderr.write(
36860
37587
  `dispatch_hook: --read-exit ok (${probe.text.length} chars, ${Object.keys(_isObject17(envelope2["payload"]) ? envelope2["payload"] : {}).length} payload keys)
36861
37588
  `
36862
37589
  );
36863
- return EXIT_ALLOW34;
37590
+ return EXIT_ALLOW35;
36864
37591
  }
36865
37592
  if (!EVENT_VOCABULARY.has(args.event)) {
36866
37593
  process.stderr.write(
36867
37594
  `dispatch_hook: unknown event '${args.event}'; allowed: ${_sortedRepr(EVENT_VOCABULARY)}
36868
37595
  `
36869
37596
  );
36870
- return EXIT_ALLOW34;
37597
+ return EXIT_ALLOW35;
36871
37598
  }
36872
37599
  recordOpportunity(args.event, args.platform);
36873
37600
  recordCapture(args.event, args.platform);
36874
37601
  const manifest_path = args.manifest;
36875
- if (!fs99.existsSync(manifest_path)) {
37602
+ if (!fs101.existsSync(manifest_path)) {
36876
37603
  process.stderr.write(`dispatch_hook: manifest missing at ${manifest_path}
36877
37604
  `);
36878
- return EXIT_ALLOW34;
37605
+ return EXIT_ALLOW35;
36879
37606
  }
36880
37607
  const manifest = _load_yaml3(manifest_path);
36881
37608
  if (args.min_version) {
@@ -36921,10 +37648,10 @@ function main63(argv) {
36921
37648
  concerns: concerns.map((c) => c["name"])
36922
37649
  };
36923
37650
  process.stdout.write(_py_json_dumps2(plan, 2) + "\n");
36924
- return EXIT_ALLOW34;
37651
+ return EXIT_ALLOW35;
36925
37652
  }
36926
37653
  if (concerns.length === 0) {
36927
- return EXIT_ALLOW34;
37654
+ return EXIT_ALLOW35;
36928
37655
  }
36929
37656
  if (_stdin_read_failed !== null) {
36930
37657
  const deny = denyOnStdinFailure(args.platform, args.event, concerns, _stdin_read_failed);
@@ -36963,7 +37690,7 @@ function main63(argv) {
36963
37690
  const raw_rc = rc;
36964
37691
  if (rc >= 3) {
36965
37692
  if (!concern["fail_closed"]) {
36966
- rc = EXIT_ALLOW34;
37693
+ rc = EXIT_ALLOW35;
36967
37694
  } else {
36968
37695
  rc = EXIT_BLOCK6;
36969
37696
  }
@@ -36976,7 +37703,7 @@ function main63(argv) {
36976
37703
  `dispatch_hook: concern '${String(concern["name"])}' is declared severity: advisory but returned BLOCK \u2014 downgraded to warn.
36977
37704
  `
36978
37705
  );
36979
- rc = EXIT_WARN17;
37706
+ rc = EXIT_WARN18;
36980
37707
  }
36981
37708
  rcs.push(rc);
36982
37709
  const reply = _parse_concern_stdout(stdout_text);
@@ -36986,7 +37713,7 @@ function main63(argv) {
36986
37713
  if (message) {
36987
37714
  concern_messages.push({ rc, text: message, def: concern });
36988
37715
  }
36989
- if (args.event === "session_start" && rc === EXIT_ALLOW34 && typeof reply["context"] === "string" && reply["context"].trim()) {
37716
+ if (args.event === "session_start" && rc === EXIT_ALLOW35 && typeof reply["context"] === "string" && reply["context"].trim()) {
36990
37717
  context_blocks.push(reply["context"].trim());
36991
37718
  }
36992
37719
  feedback_entries.push({
@@ -37014,7 +37741,7 @@ function main63(argv) {
37014
37741
  const final_rc = _reduce(rcs);
37015
37742
  _write_feedback(envelope, session_id, feedback_entries, final_rc, started_at);
37016
37743
  _record_rule_trips(envelope, feedback_entries);
37017
- if (context_blocks.length > 0 && final_rc === EXIT_ALLOW34) {
37744
+ if (context_blocks.length > 0 && final_rc === EXIT_ALLOW35) {
37018
37745
  process.stdout.write(context_blocks.join("\n\n") + "\n");
37019
37746
  }
37020
37747
  const decidingReasons = shapeAndRecord(
@@ -37039,7 +37766,7 @@ function main63(argv) {
37039
37766
  }
37040
37767
  function _isDir4(p) {
37041
37768
  try {
37042
- return fs99.statSync(p).isDirectory();
37769
+ return fs101.statSync(p).isDirectory();
37043
37770
  } catch {
37044
37771
  return false;
37045
37772
  }
@@ -37049,36 +37776,36 @@ function _sortedRepr(s) {
37049
37776
  return `[${items.map((x) => `'${x}'`).join(", ")}]`;
37050
37777
  }
37051
37778
  var _stdin_read_failed = null;
37052
- function _isCliEntry51() {
37779
+ function _isCliEntry52() {
37053
37780
  if (true) {
37054
37781
  return false;
37055
37782
  }
37056
37783
  if (process.argv[1] === void 0) {
37057
37784
  return false;
37058
37785
  }
37059
- const argvUrl = pathToFileURL58(path100.resolve(process.argv[1])).href;
37786
+ const argvUrl = pathToFileURL59(path103.resolve(process.argv[1])).href;
37060
37787
  if (import.meta.url === argvUrl) {
37061
37788
  return true;
37062
37789
  }
37063
37790
  try {
37064
- const here = fs99.realpathSync(fileURLToPath64(import.meta.url));
37065
- const argv = fs99.realpathSync(path100.resolve(process.argv[1]));
37791
+ const here = fs101.realpathSync(fileURLToPath66(import.meta.url));
37792
+ const argv = fs101.realpathSync(path103.resolve(process.argv[1]));
37066
37793
  return here === argv;
37067
37794
  } catch {
37068
37795
  return false;
37069
37796
  }
37070
37797
  }
37071
- var isCliEntry14 = _isCliEntry51();
37798
+ var isCliEntry14 = _isCliEntry52();
37072
37799
  if (isCliEntry14) {
37073
- process.exit(main63(process.argv.slice(2)));
37800
+ process.exit(main65(process.argv.slice(2)));
37074
37801
  }
37075
37802
 
37076
37803
  // src/scripts/hooks/dispatch_entry.ts
37077
- var _selfPath = fileURLToPath65(import.meta.url);
37078
- var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path101.resolve(process.argv[1]) === path101.resolve(_selfPath);
37804
+ var _selfPath = fileURLToPath67(import.meta.url);
37805
+ var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path104.resolve(process.argv[1]) === path104.resolve(_selfPath);
37079
37806
  if (_invokedDirectly2) {
37080
- process.exitCode = main63(process.argv.slice(2));
37807
+ process.exitCode = main65(process.argv.slice(2));
37081
37808
  }
37082
37809
  export {
37083
- main63 as main
37810
+ main65 as main
37084
37811
  };