@event4u/agent-config 15.0.0 → 16.0.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 (78) 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 +142 -348
  5. package/dist/agent-src/commands/roadmap/create.md +3 -2
  6. package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +50 -0
  7. package/dist/agent-src/rules/user-interaction.md +31 -30
  8. package/dist/agent-src/skills/error-handling-patterns/SKILL.md +9 -0
  9. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  10. package/dist/cli-delegate/{chunk-HZ52BRGG.js → chunk-H32DGUJH.js} +14 -89
  11. package/dist/cli-delegate/chunk-NUHLI2RX.js +80 -0
  12. package/dist/cli-delegate/{chunk-TYSY33MD.js → chunk-QJWAUMJW.js} +12 -2
  13. package/dist/cli-delegate/{chunk-2KKXJW25.js → chunk-S3VFXMTM.js} +1 -1
  14. package/dist/cli-delegate/cmd_conformance.js +831 -272
  15. package/dist/cli-delegate/cmd_explain.js +4 -2
  16. package/dist/cli-delegate/cmd_handoff.js +2 -2
  17. package/dist/cli-delegate/cmd_packs_active.js +2 -1
  18. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  19. package/dist/cli-delegate/cmd_settings_set.js +13 -0
  20. package/dist/discovery/deprecation-report.md +1 -1
  21. package/dist/discovery/discovery-manifest.json +5 -5
  22. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  23. package/dist/discovery/discovery-manifest.summary.md +1 -1
  24. package/dist/discovery/dormancy-report.md +1 -1
  25. package/dist/discovery/orphan-report.md +1 -1
  26. package/dist/discovery/packs.json +2 -2
  27. package/dist/discovery/trust-report.md +1 -1
  28. package/dist/discovery/workspaces.json +2 -2
  29. package/dist/hooks/dispatch.js +1274 -571
  30. package/dist/install/install.mjs +1 -0
  31. package/dist/mcp/registry-manifest.json +2 -2
  32. package/dist/mcp/server.json +2 -2
  33. package/dist/mcp/server.mjs +1218 -632
  34. package/dist/scripts/_lib/installed_lock.js +1 -1
  35. package/dist/server/io/yamlIO.js +50 -0
  36. package/package.json +1 -1
  37. package/src/config/continuity-surface.json +7 -0
  38. package/src/config/gate-violation-baselines.json +3 -3
  39. package/src/config/host-injection-effect.json +1 -1
  40. package/src/config/preamble-payload-budget.json +12 -7
  41. package/src/config/preamble-payload-exceptions.json +28 -0
  42. package/src/scripts/_dispatch.bash +3 -1
  43. package/src/scripts/_lib/base_ref_payload.ts +315 -0
  44. package/src/scripts/_lib/dropped_decision.ts +142 -0
  45. package/src/scripts/_lib/installed_lock.ts +1 -1
  46. package/src/scripts/_lib/measured_payload_ceiling.ts +424 -0
  47. package/src/scripts/_lib/payload_catalogue_completeness.ts +211 -0
  48. package/src/scripts/_lib/release_findings_ingest.ts +324 -0
  49. package/src/scripts/_lib/release_tag_dispatch.ts +63 -0
  50. package/src/scripts/_lib/review_baseline.ts +254 -0
  51. package/src/scripts/_lib/review_skipped_record.ts +61 -1
  52. package/src/scripts/_lib/standing_bound_ratchet.ts +216 -103
  53. package/src/scripts/_lib/turn_end_refusals.ts +51 -4
  54. package/src/scripts/check_beta_review_markers.ts +35 -4
  55. package/src/scripts/check_finding_dispositions.ts +167 -16
  56. package/src/scripts/check_held_object_arrivals.ts +381 -0
  57. package/src/scripts/check_preamble_payload_budget.ts +399 -122
  58. package/src/scripts/check_release_published.ts +1 -1
  59. package/src/scripts/check_reply_consistency.ts +86 -17
  60. package/src/scripts/hook_manifest.json +1 -1
  61. package/src/scripts/hook_manifest.yaml +39 -3
  62. package/src/scripts/hooks/block_kernel_rule_writes.ts +12 -2
  63. package/src/scripts/hooks/concern_registry.ts +2 -0
  64. package/src/scripts/hooks/end_review_nudge_hook.ts +101 -21
  65. package/src/scripts/hooks/review_baseline_hook.ts +130 -0
  66. package/src/scripts/hooks/turn_end_gate_hook.ts +232 -14
  67. package/src/scripts/hooks_doctor.ts +4 -1
  68. package/src/scripts/install.ts +1 -1
  69. package/src/scripts/interruption_report.ts +8 -2
  70. package/src/scripts/janitor.ts +8 -1
  71. package/src/scripts/measure_turn_end_gate.ts +302 -5
  72. package/src/scripts/release.ts +52 -64
  73. package/src/scripts/release_drill.ts +193 -14
  74. package/src/scripts/release_env.ts +1 -1
  75. package/src/scripts/release_publication.ts +1 -1
  76. package/src/scripts/report_held_object_arrivals.ts +456 -0
  77. package/src/scripts/sync_agent_settings.ts +140 -18
  78. package/src/server/io/yamlIO.ts +48 -0
@@ -1080,17 +1080,17 @@ function _strip_frontmatter(text) {
1080
1080
  }
1081
1081
  return [meta, _lstripNewlines(body)];
1082
1082
  }
1083
- function _splitMax(text, sep20, maxsplit) {
1083
+ function _splitMax(text, sep21, maxsplit) {
1084
1084
  const out = [];
1085
1085
  let rest = text;
1086
1086
  let count = 0;
1087
1087
  while (count < maxsplit) {
1088
- const idx = rest.indexOf(sep20);
1088
+ const idx = rest.indexOf(sep21);
1089
1089
  if (idx === -1) {
1090
1090
  break;
1091
1091
  }
1092
1092
  out.push(rest.slice(0, idx));
1093
- rest = rest.slice(idx + sep20.length);
1093
+ rest = rest.slice(idx + sep21.length);
1094
1094
  count += 1;
1095
1095
  }
1096
1096
  out.push(rest);
@@ -1900,17 +1900,17 @@ var require_visit = __commonJS({
1900
1900
  visit.BREAK = BREAK;
1901
1901
  visit.SKIP = SKIP;
1902
1902
  visit.REMOVE = REMOVE;
1903
- function visit_(key, node, visitor, path103) {
1904
- const ctrl = callVisitor(key, node, visitor, path103);
1903
+ function visit_(key, node, visitor, path105) {
1904
+ const ctrl = callVisitor(key, node, visitor, path105);
1905
1905
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
1906
- replaceNode(key, path103, ctrl);
1907
- return visit_(key, ctrl, visitor, path103);
1906
+ replaceNode(key, path105, ctrl);
1907
+ return visit_(key, ctrl, visitor, path105);
1908
1908
  }
1909
1909
  if (typeof ctrl !== "symbol") {
1910
1910
  if (identity.isCollection(node)) {
1911
- path103 = Object.freeze(path103.concat(node));
1911
+ path105 = Object.freeze(path105.concat(node));
1912
1912
  for (let i = 0; i < node.items.length; ++i) {
1913
- const ci = visit_(i, node.items[i], visitor, path103);
1913
+ const ci = visit_(i, node.items[i], visitor, path105);
1914
1914
  if (typeof ci === "number")
1915
1915
  i = ci - 1;
1916
1916
  else if (ci === BREAK)
@@ -1921,13 +1921,13 @@ var require_visit = __commonJS({
1921
1921
  }
1922
1922
  }
1923
1923
  } else if (identity.isPair(node)) {
1924
- path103 = Object.freeze(path103.concat(node));
1925
- const ck = visit_("key", node.key, visitor, path103);
1924
+ path105 = Object.freeze(path105.concat(node));
1925
+ const ck = visit_("key", node.key, visitor, path105);
1926
1926
  if (ck === BREAK)
1927
1927
  return BREAK;
1928
1928
  else if (ck === REMOVE)
1929
1929
  node.key = null;
1930
- const cv = visit_("value", node.value, visitor, path103);
1930
+ const cv = visit_("value", node.value, visitor, path105);
1931
1931
  if (cv === BREAK)
1932
1932
  return BREAK;
1933
1933
  else if (cv === REMOVE)
@@ -1948,17 +1948,17 @@ var require_visit = __commonJS({
1948
1948
  visitAsync.BREAK = BREAK;
1949
1949
  visitAsync.SKIP = SKIP;
1950
1950
  visitAsync.REMOVE = REMOVE;
1951
- async function visitAsync_(key, node, visitor, path103) {
1952
- const ctrl = await callVisitor(key, node, visitor, path103);
1951
+ async function visitAsync_(key, node, visitor, path105) {
1952
+ const ctrl = await callVisitor(key, node, visitor, path105);
1953
1953
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
1954
- replaceNode(key, path103, ctrl);
1955
- return visitAsync_(key, ctrl, visitor, path103);
1954
+ replaceNode(key, path105, ctrl);
1955
+ return visitAsync_(key, ctrl, visitor, path105);
1956
1956
  }
1957
1957
  if (typeof ctrl !== "symbol") {
1958
1958
  if (identity.isCollection(node)) {
1959
- path103 = Object.freeze(path103.concat(node));
1959
+ path105 = Object.freeze(path105.concat(node));
1960
1960
  for (let i = 0; i < node.items.length; ++i) {
1961
- const ci = await visitAsync_(i, node.items[i], visitor, path103);
1961
+ const ci = await visitAsync_(i, node.items[i], visitor, path105);
1962
1962
  if (typeof ci === "number")
1963
1963
  i = ci - 1;
1964
1964
  else if (ci === BREAK)
@@ -1969,13 +1969,13 @@ var require_visit = __commonJS({
1969
1969
  }
1970
1970
  }
1971
1971
  } else if (identity.isPair(node)) {
1972
- path103 = Object.freeze(path103.concat(node));
1973
- const ck = await visitAsync_("key", node.key, visitor, path103);
1972
+ path105 = Object.freeze(path105.concat(node));
1973
+ const ck = await visitAsync_("key", node.key, visitor, path105);
1974
1974
  if (ck === BREAK)
1975
1975
  return BREAK;
1976
1976
  else if (ck === REMOVE)
1977
1977
  node.key = null;
1978
- const cv = await visitAsync_("value", node.value, visitor, path103);
1978
+ const cv = await visitAsync_("value", node.value, visitor, path105);
1979
1979
  if (cv === BREAK)
1980
1980
  return BREAK;
1981
1981
  else if (cv === REMOVE)
@@ -2002,23 +2002,23 @@ var require_visit = __commonJS({
2002
2002
  }
2003
2003
  return visitor;
2004
2004
  }
2005
- function callVisitor(key, node, visitor, path103) {
2005
+ function callVisitor(key, node, visitor, path105) {
2006
2006
  if (typeof visitor === "function")
2007
- return visitor(key, node, path103);
2007
+ return visitor(key, node, path105);
2008
2008
  if (identity.isMap(node))
2009
- return visitor.Map?.(key, node, path103);
2009
+ return visitor.Map?.(key, node, path105);
2010
2010
  if (identity.isSeq(node))
2011
- return visitor.Seq?.(key, node, path103);
2011
+ return visitor.Seq?.(key, node, path105);
2012
2012
  if (identity.isPair(node))
2013
- return visitor.Pair?.(key, node, path103);
2013
+ return visitor.Pair?.(key, node, path105);
2014
2014
  if (identity.isScalar(node))
2015
- return visitor.Scalar?.(key, node, path103);
2015
+ return visitor.Scalar?.(key, node, path105);
2016
2016
  if (identity.isAlias(node))
2017
- return visitor.Alias?.(key, node, path103);
2017
+ return visitor.Alias?.(key, node, path105);
2018
2018
  return void 0;
2019
2019
  }
2020
- function replaceNode(key, path103, node) {
2021
- const parent = path103[path103.length - 1];
2020
+ function replaceNode(key, path105, node) {
2021
+ const parent = path105[path105.length - 1];
2022
2022
  if (identity.isCollection(parent)) {
2023
2023
  parent.items[key] = node;
2024
2024
  } else if (identity.isPair(parent)) {
@@ -2628,10 +2628,10 @@ var require_Collection = __commonJS({
2628
2628
  var createNode = require_createNode();
2629
2629
  var identity = require_identity();
2630
2630
  var Node = require_Node();
2631
- function collectionFromPath(schema, path103, value) {
2631
+ function collectionFromPath(schema, path105, value) {
2632
2632
  let v = value;
2633
- for (let i = path103.length - 1; i >= 0; --i) {
2634
- const k = path103[i];
2633
+ for (let i = path105.length - 1; i >= 0; --i) {
2634
+ const k = path105[i];
2635
2635
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
2636
2636
  const a = [];
2637
2637
  a[k] = v;
@@ -2650,7 +2650,7 @@ var require_Collection = __commonJS({
2650
2650
  sourceObjects: /* @__PURE__ */ new Map()
2651
2651
  });
2652
2652
  }
2653
- var isEmptyPath = (path103) => path103 == null || typeof path103 === "object" && !!path103[Symbol.iterator]().next().done;
2653
+ var isEmptyPath = (path105) => path105 == null || typeof path105 === "object" && !!path105[Symbol.iterator]().next().done;
2654
2654
  var Collection = class extends Node.NodeBase {
2655
2655
  constructor(type, schema) {
2656
2656
  super(type);
@@ -2680,11 +2680,11 @@ var require_Collection = __commonJS({
2680
2680
  * be a Pair instance or a `{ key, value }` object, which may not have a key
2681
2681
  * that already exists in the map.
2682
2682
  */
2683
- addIn(path103, value) {
2684
- if (isEmptyPath(path103))
2683
+ addIn(path105, value) {
2684
+ if (isEmptyPath(path105))
2685
2685
  this.add(value);
2686
2686
  else {
2687
- const [key, ...rest] = path103;
2687
+ const [key, ...rest] = path105;
2688
2688
  const node = this.get(key, true);
2689
2689
  if (identity.isCollection(node))
2690
2690
  node.addIn(rest, value);
@@ -2698,8 +2698,8 @@ var require_Collection = __commonJS({
2698
2698
  * Removes a value from the collection.
2699
2699
  * @returns `true` if the item was found and removed.
2700
2700
  */
2701
- deleteIn(path103) {
2702
- const [key, ...rest] = path103;
2701
+ deleteIn(path105) {
2702
+ const [key, ...rest] = path105;
2703
2703
  if (rest.length === 0)
2704
2704
  return this.delete(key);
2705
2705
  const node = this.get(key, true);
@@ -2713,8 +2713,8 @@ var require_Collection = __commonJS({
2713
2713
  * scalar values from their surrounding node; to disable set `keepScalar` to
2714
2714
  * `true` (collections are always returned intact).
2715
2715
  */
2716
- getIn(path103, keepScalar) {
2717
- const [key, ...rest] = path103;
2716
+ getIn(path105, keepScalar) {
2717
+ const [key, ...rest] = path105;
2718
2718
  const node = this.get(key, true);
2719
2719
  if (rest.length === 0)
2720
2720
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -2732,8 +2732,8 @@ var require_Collection = __commonJS({
2732
2732
  /**
2733
2733
  * Checks if the collection includes a value with the key `key`.
2734
2734
  */
2735
- hasIn(path103) {
2736
- const [key, ...rest] = path103;
2735
+ hasIn(path105) {
2736
+ const [key, ...rest] = path105;
2737
2737
  if (rest.length === 0)
2738
2738
  return this.has(key);
2739
2739
  const node = this.get(key, true);
@@ -2743,8 +2743,8 @@ var require_Collection = __commonJS({
2743
2743
  * Sets a value in this collection. For `!!set`, `value` needs to be a
2744
2744
  * boolean to add/remove the item from the set.
2745
2745
  */
2746
- setIn(path103, value) {
2747
- const [key, ...rest] = path103;
2746
+ setIn(path105, value) {
2747
+ const [key, ...rest] = path105;
2748
2748
  if (rest.length === 0) {
2749
2749
  this.set(key, value);
2750
2750
  } else {
@@ -5259,9 +5259,9 @@ var require_Document = __commonJS({
5259
5259
  this.contents.add(value);
5260
5260
  }
5261
5261
  /** Adds a value to the document. */
5262
- addIn(path103, value) {
5262
+ addIn(path105, value) {
5263
5263
  if (assertCollection(this.contents))
5264
- this.contents.addIn(path103, value);
5264
+ this.contents.addIn(path105, value);
5265
5265
  }
5266
5266
  /**
5267
5267
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -5336,14 +5336,14 @@ var require_Document = __commonJS({
5336
5336
  * Removes a value from the document.
5337
5337
  * @returns `true` if the item was found and removed.
5338
5338
  */
5339
- deleteIn(path103) {
5340
- if (Collection.isEmptyPath(path103)) {
5339
+ deleteIn(path105) {
5340
+ if (Collection.isEmptyPath(path105)) {
5341
5341
  if (this.contents == null)
5342
5342
  return false;
5343
5343
  this.contents = null;
5344
5344
  return true;
5345
5345
  }
5346
- return assertCollection(this.contents) ? this.contents.deleteIn(path103) : false;
5346
+ return assertCollection(this.contents) ? this.contents.deleteIn(path105) : false;
5347
5347
  }
5348
5348
  /**
5349
5349
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -5358,10 +5358,10 @@ var require_Document = __commonJS({
5358
5358
  * scalar values from their surrounding node; to disable set `keepScalar` to
5359
5359
  * `true` (collections are always returned intact).
5360
5360
  */
5361
- getIn(path103, keepScalar) {
5362
- if (Collection.isEmptyPath(path103))
5361
+ getIn(path105, keepScalar) {
5362
+ if (Collection.isEmptyPath(path105))
5363
5363
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
5364
- return identity.isCollection(this.contents) ? this.contents.getIn(path103, keepScalar) : void 0;
5364
+ return identity.isCollection(this.contents) ? this.contents.getIn(path105, keepScalar) : void 0;
5365
5365
  }
5366
5366
  /**
5367
5367
  * Checks if the document includes a value with the key `key`.
@@ -5372,10 +5372,10 @@ var require_Document = __commonJS({
5372
5372
  /**
5373
5373
  * Checks if the document includes a value at `path`.
5374
5374
  */
5375
- hasIn(path103) {
5376
- if (Collection.isEmptyPath(path103))
5375
+ hasIn(path105) {
5376
+ if (Collection.isEmptyPath(path105))
5377
5377
  return this.contents !== void 0;
5378
- return identity.isCollection(this.contents) ? this.contents.hasIn(path103) : false;
5378
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path105) : false;
5379
5379
  }
5380
5380
  /**
5381
5381
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -5392,13 +5392,13 @@ var require_Document = __commonJS({
5392
5392
  * Sets a value in this document. For `!!set`, `value` needs to be a
5393
5393
  * boolean to add/remove the item from the set.
5394
5394
  */
5395
- setIn(path103, value) {
5396
- if (Collection.isEmptyPath(path103)) {
5395
+ setIn(path105, value) {
5396
+ if (Collection.isEmptyPath(path105)) {
5397
5397
  this.contents = value;
5398
5398
  } else if (this.contents == null) {
5399
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path103), value);
5399
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path105), value);
5400
5400
  } else if (assertCollection(this.contents)) {
5401
- this.contents.setIn(path103, value);
5401
+ this.contents.setIn(path105, value);
5402
5402
  }
5403
5403
  }
5404
5404
  /**
@@ -5784,10 +5784,10 @@ var require_resolve_block_map = __commonJS({
5784
5784
  let offset = bm.offset;
5785
5785
  let commentEnd = null;
5786
5786
  for (const collItem of bm.items) {
5787
- const { start, key, sep: sep20, value } = collItem;
5787
+ const { start, key, sep: sep21, value } = collItem;
5788
5788
  const keyProps = resolveProps.resolveProps(start, {
5789
5789
  indicator: "explicit-key-ind",
5790
- next: key ?? sep20?.[0],
5790
+ next: key ?? sep21?.[0],
5791
5791
  offset,
5792
5792
  onError,
5793
5793
  parentIndent: bm.indent,
@@ -5801,7 +5801,7 @@ var require_resolve_block_map = __commonJS({
5801
5801
  else if ("indent" in key && key.indent !== bm.indent)
5802
5802
  onError(offset, "BAD_INDENT", startColMsg);
5803
5803
  }
5804
- if (!keyProps.anchor && !keyProps.tag && !sep20) {
5804
+ if (!keyProps.anchor && !keyProps.tag && !sep21) {
5805
5805
  commentEnd = keyProps.end;
5806
5806
  if (keyProps.comment) {
5807
5807
  if (map.comment)
@@ -5825,7 +5825,7 @@ var require_resolve_block_map = __commonJS({
5825
5825
  ctx.atKey = false;
5826
5826
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
5827
5827
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
5828
- const valueProps = resolveProps.resolveProps(sep20 ?? [], {
5828
+ const valueProps = resolveProps.resolveProps(sep21 ?? [], {
5829
5829
  indicator: "map-value-ind",
5830
5830
  next: value,
5831
5831
  offset: keyNode.range[2],
@@ -5841,7 +5841,7 @@ var require_resolve_block_map = __commonJS({
5841
5841
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
5842
5842
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
5843
5843
  }
5844
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep20, null, valueProps, onError);
5844
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep21, null, valueProps, onError);
5845
5845
  if (ctx.schema.compat)
5846
5846
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
5847
5847
  offset = valueNode.range[2];
@@ -5932,7 +5932,7 @@ var require_resolve_end = __commonJS({
5932
5932
  let comment = "";
5933
5933
  if (end) {
5934
5934
  let hasSpace = false;
5935
- let sep20 = "";
5935
+ let sep21 = "";
5936
5936
  for (const token of end) {
5937
5937
  const { source, type } = token;
5938
5938
  switch (type) {
@@ -5946,13 +5946,13 @@ var require_resolve_end = __commonJS({
5946
5946
  if (!comment)
5947
5947
  comment = cb;
5948
5948
  else
5949
- comment += sep20 + cb;
5950
- sep20 = "";
5949
+ comment += sep21 + cb;
5950
+ sep21 = "";
5951
5951
  break;
5952
5952
  }
5953
5953
  case "newline":
5954
5954
  if (comment)
5955
- sep20 += source;
5955
+ sep21 += source;
5956
5956
  hasSpace = true;
5957
5957
  break;
5958
5958
  default:
@@ -5995,18 +5995,18 @@ var require_resolve_flow_collection = __commonJS({
5995
5995
  let offset = fc.offset + fc.start.source.length;
5996
5996
  for (let i = 0; i < fc.items.length; ++i) {
5997
5997
  const collItem = fc.items[i];
5998
- const { start, key, sep: sep20, value } = collItem;
5998
+ const { start, key, sep: sep21, value } = collItem;
5999
5999
  const props = resolveProps.resolveProps(start, {
6000
6000
  flow: fcName,
6001
6001
  indicator: "explicit-key-ind",
6002
- next: key ?? sep20?.[0],
6002
+ next: key ?? sep21?.[0],
6003
6003
  offset,
6004
6004
  onError,
6005
6005
  parentIndent: fc.indent,
6006
6006
  startOnNewline: false
6007
6007
  });
6008
6008
  if (!props.found) {
6009
- if (!props.anchor && !props.tag && !sep20 && !value) {
6009
+ if (!props.anchor && !props.tag && !sep21 && !value) {
6010
6010
  if (i === 0 && props.comma)
6011
6011
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
6012
6012
  else if (i < fc.items.length - 1)
@@ -6060,8 +6060,8 @@ var require_resolve_flow_collection = __commonJS({
6060
6060
  }
6061
6061
  }
6062
6062
  }
6063
- if (!isMap && !sep20 && !props.found) {
6064
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep20, null, props, onError);
6063
+ if (!isMap && !sep21 && !props.found) {
6064
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep21, null, props, onError);
6065
6065
  coll.items.push(valueNode);
6066
6066
  offset = valueNode.range[2];
6067
6067
  if (isBlock(value))
@@ -6073,7 +6073,7 @@ var require_resolve_flow_collection = __commonJS({
6073
6073
  if (isBlock(key))
6074
6074
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
6075
6075
  ctx.atKey = false;
6076
- const valueProps = resolveProps.resolveProps(sep20 ?? [], {
6076
+ const valueProps = resolveProps.resolveProps(sep21 ?? [], {
6077
6077
  flow: fcName,
6078
6078
  indicator: "map-value-ind",
6079
6079
  next: value,
@@ -6084,8 +6084,8 @@ var require_resolve_flow_collection = __commonJS({
6084
6084
  });
6085
6085
  if (valueProps.found) {
6086
6086
  if (!isMap && !props.found && ctx.options.strict) {
6087
- if (sep20)
6088
- for (const st of sep20) {
6087
+ if (sep21)
6088
+ for (const st of sep21) {
6089
6089
  if (st === valueProps.found)
6090
6090
  break;
6091
6091
  if (st.type === "newline") {
@@ -6102,7 +6102,7 @@ var require_resolve_flow_collection = __commonJS({
6102
6102
  else
6103
6103
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
6104
6104
  }
6105
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep20, null, valueProps, onError) : null;
6105
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep21, null, valueProps, onError) : null;
6106
6106
  if (valueNode) {
6107
6107
  if (isBlock(value))
6108
6108
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -6282,7 +6282,7 @@ var require_resolve_block_scalar = __commonJS({
6282
6282
  chompStart = i + 1;
6283
6283
  }
6284
6284
  let value = "";
6285
- let sep20 = "";
6285
+ let sep21 = "";
6286
6286
  let prevMoreIndented = false;
6287
6287
  for (let i = 0; i < contentStart; ++i)
6288
6288
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -6299,24 +6299,24 @@ var require_resolve_block_scalar = __commonJS({
6299
6299
  indent = "";
6300
6300
  }
6301
6301
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
6302
- value += sep20 + indent.slice(trimIndent) + content;
6303
- sep20 = "\n";
6302
+ value += sep21 + indent.slice(trimIndent) + content;
6303
+ sep21 = "\n";
6304
6304
  } else if (indent.length > trimIndent || content[0] === " ") {
6305
- if (sep20 === " ")
6306
- sep20 = "\n";
6307
- else if (!prevMoreIndented && sep20 === "\n")
6308
- sep20 = "\n\n";
6309
- value += sep20 + indent.slice(trimIndent) + content;
6310
- sep20 = "\n";
6305
+ if (sep21 === " ")
6306
+ sep21 = "\n";
6307
+ else if (!prevMoreIndented && sep21 === "\n")
6308
+ sep21 = "\n\n";
6309
+ value += sep21 + indent.slice(trimIndent) + content;
6310
+ sep21 = "\n";
6311
6311
  prevMoreIndented = true;
6312
6312
  } else if (content === "") {
6313
- if (sep20 === "\n")
6313
+ if (sep21 === "\n")
6314
6314
  value += "\n";
6315
6315
  else
6316
- sep20 = "\n";
6316
+ sep21 = "\n";
6317
6317
  } else {
6318
- value += sep20 + content;
6319
- sep20 = " ";
6318
+ value += sep21 + content;
6319
+ sep21 = " ";
6320
6320
  prevMoreIndented = false;
6321
6321
  }
6322
6322
  }
@@ -6498,25 +6498,25 @@ var require_resolve_flow_scalar = __commonJS({
6498
6498
  if (!match)
6499
6499
  return source;
6500
6500
  let res = match[1];
6501
- let sep20 = " ";
6501
+ let sep21 = " ";
6502
6502
  let pos = first.lastIndex;
6503
6503
  line.lastIndex = pos;
6504
6504
  while (match = line.exec(source)) {
6505
6505
  if (match[1] === "") {
6506
- if (sep20 === "\n")
6507
- res += sep20;
6506
+ if (sep21 === "\n")
6507
+ res += sep21;
6508
6508
  else
6509
- sep20 = "\n";
6509
+ sep21 = "\n";
6510
6510
  } else {
6511
- res += sep20 + match[1];
6512
- sep20 = " ";
6511
+ res += sep21 + match[1];
6512
+ sep21 = " ";
6513
6513
  }
6514
6514
  pos = line.lastIndex;
6515
6515
  }
6516
6516
  const last = /[ \t]*(.*)/sy;
6517
6517
  last.lastIndex = pos;
6518
6518
  match = last.exec(source);
6519
- return res + sep20 + (match?.[1] ?? "");
6519
+ return res + sep21 + (match?.[1] ?? "");
6520
6520
  }
6521
6521
  function doubleQuotedValue(source, onError) {
6522
6522
  let res = "";
@@ -7326,14 +7326,14 @@ var require_cst_stringify = __commonJS({
7326
7326
  }
7327
7327
  }
7328
7328
  }
7329
- function stringifyItem({ start, key, sep: sep20, value }) {
7329
+ function stringifyItem({ start, key, sep: sep21, value }) {
7330
7330
  let res = "";
7331
7331
  for (const st of start)
7332
7332
  res += st.source;
7333
7333
  if (key)
7334
7334
  res += stringifyToken(key);
7335
- if (sep20)
7336
- for (const st of sep20)
7335
+ if (sep21)
7336
+ for (const st of sep21)
7337
7337
  res += st.source;
7338
7338
  if (value)
7339
7339
  res += stringifyToken(value);
@@ -7358,9 +7358,9 @@ var require_cst_visit = __commonJS({
7358
7358
  visit.BREAK = BREAK;
7359
7359
  visit.SKIP = SKIP;
7360
7360
  visit.REMOVE = REMOVE;
7361
- visit.itemAtPath = (cst, path103) => {
7361
+ visit.itemAtPath = (cst, path105) => {
7362
7362
  let item = cst;
7363
- for (const [field, index] of path103) {
7363
+ for (const [field, index] of path105) {
7364
7364
  const tok = item?.[field];
7365
7365
  if (tok && "items" in tok) {
7366
7366
  item = tok.items[index];
@@ -7369,23 +7369,23 @@ var require_cst_visit = __commonJS({
7369
7369
  }
7370
7370
  return item;
7371
7371
  };
7372
- visit.parentCollection = (cst, path103) => {
7373
- const parent = visit.itemAtPath(cst, path103.slice(0, -1));
7374
- const field = path103[path103.length - 1][0];
7372
+ visit.parentCollection = (cst, path105) => {
7373
+ const parent = visit.itemAtPath(cst, path105.slice(0, -1));
7374
+ const field = path105[path105.length - 1][0];
7375
7375
  const coll = parent?.[field];
7376
7376
  if (coll && "items" in coll)
7377
7377
  return coll;
7378
7378
  throw new Error("Parent collection not found");
7379
7379
  };
7380
- function _visit(path103, item, visitor) {
7381
- let ctrl = visitor(item, path103);
7380
+ function _visit(path105, item, visitor) {
7381
+ let ctrl = visitor(item, path105);
7382
7382
  if (typeof ctrl === "symbol")
7383
7383
  return ctrl;
7384
7384
  for (const field of ["key", "value"]) {
7385
7385
  const token = item[field];
7386
7386
  if (token && "items" in token) {
7387
7387
  for (let i = 0; i < token.items.length; ++i) {
7388
- const ci = _visit(Object.freeze(path103.concat([[field, i]])), token.items[i], visitor);
7388
+ const ci = _visit(Object.freeze(path105.concat([[field, i]])), token.items[i], visitor);
7389
7389
  if (typeof ci === "number")
7390
7390
  i = ci - 1;
7391
7391
  else if (ci === BREAK)
@@ -7396,10 +7396,10 @@ var require_cst_visit = __commonJS({
7396
7396
  }
7397
7397
  }
7398
7398
  if (typeof ctrl === "function" && field === "key")
7399
- ctrl = ctrl(item, path103);
7399
+ ctrl = ctrl(item, path105);
7400
7400
  }
7401
7401
  }
7402
- return typeof ctrl === "function" ? ctrl(item, path103) : ctrl;
7402
+ return typeof ctrl === "function" ? ctrl(item, path105) : ctrl;
7403
7403
  }
7404
7404
  exports.visit = visit;
7405
7405
  }
@@ -8500,18 +8500,18 @@ var require_parser = __commonJS({
8500
8500
  if (this.type === "map-value-ind") {
8501
8501
  const prev = getPrevProps(this.peek(2));
8502
8502
  const start = getFirstKeyStartProps(prev);
8503
- let sep20;
8503
+ let sep21;
8504
8504
  if (scalar.end) {
8505
- sep20 = scalar.end;
8506
- sep20.push(this.sourceToken);
8505
+ sep21 = scalar.end;
8506
+ sep21.push(this.sourceToken);
8507
8507
  delete scalar.end;
8508
8508
  } else
8509
- sep20 = [this.sourceToken];
8509
+ sep21 = [this.sourceToken];
8510
8510
  const map = {
8511
8511
  type: "block-map",
8512
8512
  offset: scalar.offset,
8513
8513
  indent: scalar.indent,
8514
- items: [{ start, key: scalar, sep: sep20 }]
8514
+ items: [{ start, key: scalar, sep: sep21 }]
8515
8515
  };
8516
8516
  this.onKeyLine = true;
8517
8517
  this.stack[this.stack.length - 1] = map;
@@ -8664,15 +8664,15 @@ var require_parser = __commonJS({
8664
8664
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
8665
8665
  const start2 = getFirstKeyStartProps(it.start);
8666
8666
  const key = it.key;
8667
- const sep20 = it.sep;
8668
- sep20.push(this.sourceToken);
8667
+ const sep21 = it.sep;
8668
+ sep21.push(this.sourceToken);
8669
8669
  delete it.key;
8670
8670
  delete it.sep;
8671
8671
  this.stack.push({
8672
8672
  type: "block-map",
8673
8673
  offset: this.offset,
8674
8674
  indent: this.indent,
8675
- items: [{ start: start2, key, sep: sep20 }]
8675
+ items: [{ start: start2, key, sep: sep21 }]
8676
8676
  });
8677
8677
  } else if (start.length > 0) {
8678
8678
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -8701,14 +8701,14 @@ var require_parser = __commonJS({
8701
8701
  case "scalar":
8702
8702
  case "single-quoted-scalar":
8703
8703
  case "double-quoted-scalar": {
8704
- const fs106 = this.flowScalar(this.type);
8704
+ const fs108 = this.flowScalar(this.type);
8705
8705
  if (atNextItem || it.value) {
8706
- map.items.push({ start, key: fs106, sep: [] });
8706
+ map.items.push({ start, key: fs108, sep: [] });
8707
8707
  this.onKeyLine = true;
8708
8708
  } else if (it.sep) {
8709
- this.stack.push(fs106);
8709
+ this.stack.push(fs108);
8710
8710
  } else {
8711
- Object.assign(it, { key: fs106, sep: [] });
8711
+ Object.assign(it, { key: fs108, sep: [] });
8712
8712
  this.onKeyLine = true;
8713
8713
  }
8714
8714
  return;
@@ -8836,13 +8836,13 @@ var require_parser = __commonJS({
8836
8836
  case "scalar":
8837
8837
  case "single-quoted-scalar":
8838
8838
  case "double-quoted-scalar": {
8839
- const fs106 = this.flowScalar(this.type);
8839
+ const fs108 = this.flowScalar(this.type);
8840
8840
  if (!it || it.value)
8841
- fc.items.push({ start: [], key: fs106, sep: [] });
8841
+ fc.items.push({ start: [], key: fs108, sep: [] });
8842
8842
  else if (it.sep)
8843
- this.stack.push(fs106);
8843
+ this.stack.push(fs108);
8844
8844
  else
8845
- Object.assign(it, { key: fs106, sep: [] });
8845
+ Object.assign(it, { key: fs108, sep: [] });
8846
8846
  return;
8847
8847
  }
8848
8848
  case "flow-map-end":
@@ -8866,13 +8866,13 @@ var require_parser = __commonJS({
8866
8866
  const prev = getPrevProps(parent);
8867
8867
  const start = getFirstKeyStartProps(prev);
8868
8868
  fixFlowSeqItems(fc);
8869
- const sep20 = fc.end.splice(1, fc.end.length);
8870
- sep20.push(this.sourceToken);
8869
+ const sep21 = fc.end.splice(1, fc.end.length);
8870
+ sep21.push(this.sourceToken);
8871
8871
  const map = {
8872
8872
  type: "block-map",
8873
8873
  offset: fc.offset,
8874
8874
  indent: fc.indent,
8875
- items: [{ start, key: fc, sep: sep20 }]
8875
+ items: [{ start, key: fc, sep: sep21 }]
8876
8876
  };
8877
8877
  this.onKeyLine = true;
8878
8878
  this.stack[this.stack.length - 1] = map;
@@ -19565,17 +19565,17 @@ function freshMatch(pattern, text) {
19565
19565
  const re = new RegExp(pattern.source, pattern.flags);
19566
19566
  return re.exec(text);
19567
19567
  }
19568
- function splitN(text, sep20, maxsplit) {
19568
+ function splitN(text, sep21, maxsplit) {
19569
19569
  const parts = [];
19570
19570
  let rest = text;
19571
19571
  let count = 0;
19572
19572
  while (count < maxsplit) {
19573
- const idx = rest.indexOf(sep20);
19573
+ const idx = rest.indexOf(sep21);
19574
19574
  if (idx === -1) {
19575
19575
  break;
19576
19576
  }
19577
19577
  parts.push(rest.slice(0, idx));
19578
- rest = rest.slice(idx + sep20.length);
19578
+ rest = rest.slice(idx + sep21.length);
19579
19579
  count += 1;
19580
19580
  }
19581
19581
  parts.push(rest);
@@ -23337,8 +23337,8 @@ function atomicAppendLine(target, line) {
23337
23337
  } catch {
23338
23338
  existing = "";
23339
23339
  }
23340
- const sep20 = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
23341
- atomicWriteFile(target, `${existing}${sep20}${line}
23340
+ const sep21 = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
23341
+ atomicWriteFile(target, `${existing}${sep21}${line}
23342
23342
  `);
23343
23343
  }
23344
23344
  function randSuffix() {
@@ -24564,8 +24564,8 @@ function lockfile_path(env) {
24564
24564
  }
24565
24565
  return write_target("installed.lock", { env: env ?? null });
24566
24566
  }
24567
- function read_lockfile(path103) {
24568
- const target = path103 ?? lockfile_path();
24567
+ function read_lockfile(path105) {
24568
+ const target = path105 ?? lockfile_path();
24569
24569
  let text;
24570
24570
  try {
24571
24571
  text = fs52.readFileSync(target, { encoding: "utf-8" });
@@ -24682,18 +24682,18 @@ function manifest_path(project_root, env) {
24682
24682
  }
24683
24683
  return fsPath.join(project_root, DEFAULT_MANIFEST_RELATIVE);
24684
24684
  }
24685
- function read_manifest(path103) {
24685
+ function read_manifest(path105) {
24686
24686
  let text;
24687
24687
  try {
24688
- text = require_read_text(path103);
24688
+ text = require_read_text(path105);
24689
24689
  } catch {
24690
24690
  return null;
24691
24691
  }
24692
24692
  const data = _parse_manual(text);
24693
24693
  return _normalise_v2_shape(data);
24694
24694
  }
24695
- function require_read_text(path103) {
24696
- return fs53.readFileSync(path103, { encoding: "utf-8" });
24695
+ function require_read_text(path105) {
24696
+ return fs53.readFileSync(path105, { encoding: "utf-8" });
24697
24697
  }
24698
24698
  function _normalise_v2_shape(data) {
24699
24699
  if (data["tools"] === void 0 || data["tools"] === null) {
@@ -24874,9 +24874,9 @@ function stable_sort(items, key) {
24874
24874
  return a.index - b.index;
24875
24875
  }).map((entry) => entry.item);
24876
24876
  }
24877
- function write_manifest(path103, version, tools, options = {}) {
24877
+ function write_manifest(path105, version, tools, options = {}) {
24878
24878
  const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
24879
- return write_atomic(path103, rendered);
24879
+ return write_atomic(path105, rendered);
24880
24880
  }
24881
24881
  function upsert_tool(existing, options) {
24882
24882
  const {
@@ -27478,17 +27478,17 @@ function _split_frontmatter(text) {
27478
27478
  }
27479
27479
  return [parts[1], parts[2]];
27480
27480
  }
27481
- function _pySplit(s, sep20, maxsplit) {
27481
+ function _pySplit(s, sep21, maxsplit) {
27482
27482
  const out = [];
27483
27483
  let rest = s;
27484
27484
  let n = 0;
27485
27485
  while (n < maxsplit) {
27486
- const idx = rest.indexOf(sep20);
27486
+ const idx = rest.indexOf(sep21);
27487
27487
  if (idx === -1) {
27488
27488
  break;
27489
27489
  }
27490
27490
  out.push(rest.slice(0, idx));
27491
- rest = rest.slice(idx + sep20.length);
27491
+ rest = rest.slice(idx + sep21.length);
27492
27492
  n++;
27493
27493
  }
27494
27494
  out.push(rest);
@@ -36536,8 +36536,8 @@ function shutilWhich(name) {
36536
36536
  return isExecutableFile(name) ? name : null;
36537
36537
  }
36538
36538
  const pathEnv = process19.env["PATH"] || "";
36539
- const sep20 = process19.platform === "win32" ? ";" : ":";
36540
- const dirs = pathEnv.split(sep20);
36539
+ const sep21 = process19.platform === "win32" ? ";" : ":";
36540
+ const dirs = pathEnv.split(sep21);
36541
36541
  const exts = process19.platform === "win32" ? (process19.env["PATHEXT"] || ".COM;.EXE;.BAT;.CMD").split(";") : [""];
36542
36542
  const seenDirs = /* @__PURE__ */ new Set();
36543
36543
  for (const dir of dirs) {
@@ -38551,9 +38551,9 @@ function detectToolPresence(root) {
38551
38551
  agentsMd: existsSync41(join68(root, "AGENTS.md"))
38552
38552
  };
38553
38553
  }
38554
- function isDir5(path103) {
38554
+ function isDir5(path105) {
38555
38555
  try {
38556
- return statSync44(path103).isDirectory();
38556
+ return statSync44(path105).isDirectory();
38557
38557
  } catch {
38558
38558
  return false;
38559
38559
  }
@@ -38566,10 +38566,10 @@ var init_detect = __esm({
38566
38566
 
38567
38567
  // src/scripts/router_target_paths.mjs
38568
38568
  function parseRouteTarget(target) {
38569
- const sep20 = target.indexOf(":");
38570
- if (sep20 <= 0) return null;
38571
- const kind = target.slice(0, sep20);
38572
- const id = target.slice(sep20 + 1);
38569
+ const sep21 = target.indexOf(":");
38570
+ if (sep21 <= 0) return null;
38571
+ const kind = target.slice(0, sep21);
38572
+ const id = target.slice(sep21 + 1);
38573
38573
  if (!id) return null;
38574
38574
  if (!Object.prototype.hasOwnProperty.call(ROUTE_TARGET_TEMPLATES, kind)) return null;
38575
38575
  return { kind, id };
@@ -40754,6 +40754,473 @@ var init_before_complete_hook = __esm({
40754
40754
  }
40755
40755
  });
40756
40756
 
40757
+ // src/scripts/check_reply_consistency.ts
40758
+ import * as fs81 from "node:fs";
40759
+ import * as path81 from "node:path";
40760
+ import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL24 } from "node:url";
40761
+ function _strip_codespans(line) {
40762
+ return line.replace(CODESPAN_RE, "``");
40763
+ }
40764
+ function splitAndMask(text) {
40765
+ return mask_fences(_splitlines8(text));
40766
+ }
40767
+ function _splitlines8(text) {
40768
+ if (text === "") return [];
40769
+ const parts = text.split(/\r\n|\r|\n/);
40770
+ if (parts.length > 0 && parts[parts.length - 1] === "") {
40771
+ parts.pop();
40772
+ }
40773
+ return parts;
40774
+ }
40775
+ function mask_fences(lines) {
40776
+ const out = [];
40777
+ let fence = null;
40778
+ for (const raw of lines) {
40779
+ const m = FENCE_RE2.exec(raw);
40780
+ if (m) {
40781
+ const marker = m[1];
40782
+ if (fence === null) {
40783
+ fence = marker;
40784
+ } else if (fence === marker) {
40785
+ fence = null;
40786
+ }
40787
+ out.push("");
40788
+ continue;
40789
+ }
40790
+ out.push(fence === null ? raw : "");
40791
+ }
40792
+ return out;
40793
+ }
40794
+ function find_option_blocks(text) {
40795
+ const lines = mask_fences(_splitlines8(text));
40796
+ const blocks = [];
40797
+ let current = null;
40798
+ for (let idx = 0; idx < lines.length; idx++) {
40799
+ const m = OPTION_LINE_RE.exec(lines[idx]);
40800
+ if (m) {
40801
+ const num2 = parseInt(m[1], 10);
40802
+ if (current === null) {
40803
+ current = { startLine: idx + 1, endLine: idx + 1, numbers: [num2] };
40804
+ } else {
40805
+ current.endLine = idx + 1;
40806
+ current.numbers.push(num2);
40807
+ }
40808
+ } else {
40809
+ if (current !== null && current.numbers.length >= 2) {
40810
+ blocks.push(current);
40811
+ }
40812
+ current = null;
40813
+ }
40814
+ }
40815
+ if (current !== null && current.numbers.length >= 2) {
40816
+ blocks.push(current);
40817
+ }
40818
+ return blocks;
40819
+ }
40820
+ function recommendationsUnder(text, block, maskedLines) {
40821
+ const lines = maskedLines ?? mask_fences(_splitlines8(text));
40822
+ const recs = [];
40823
+ let inspected = 0;
40824
+ for (let idx = block.endLine; idx < lines.length && inspected < REC_ADJACENCY_WINDOW; idx++) {
40825
+ const line = lines[idx];
40826
+ if (line.trim() === "") {
40827
+ continue;
40828
+ }
40829
+ if (HEADING_RE.test(line) || OPTION_LINE_RE.test(line)) {
40830
+ break;
40831
+ }
40832
+ inspected += 1;
40833
+ const m = REC_LINE_RE.exec(line);
40834
+ if (m) {
40835
+ recs.push({ line: idx + 1, num: parseInt(m[1], 10) });
40836
+ }
40837
+ }
40838
+ return recs;
40839
+ }
40840
+ function check_reply(text) {
40841
+ const rawLines = _splitlines8(text);
40842
+ const lines = mask_fences(rawLines);
40843
+ const findings = [];
40844
+ for (let idx = 0; idx < lines.length; idx++) {
40845
+ const stripped = _strip_codespans(lines[idx]);
40846
+ if (OPTION_LINE_RE.test(stripped) && TAG_RE.test(stripped)) {
40847
+ findings.push({
40848
+ line: idx + 1,
40849
+ message: `inline tag on numbered option \u2014 ${rawLines[idx].trim()}`
40850
+ });
40851
+ }
40852
+ }
40853
+ const blocks = find_option_blocks(text);
40854
+ for (const block of blocks) {
40855
+ const recs = recommendationsUnder(text, block);
40856
+ if (recs.length === 0) {
40857
+ findings.push({
40858
+ line: block.startLine,
40859
+ message: "numbered options block without a Recommendation:/Empfehlung: line directly under it"
40860
+ });
40861
+ continue;
40862
+ }
40863
+ if (recs.length > 1) {
40864
+ findings.push({
40865
+ line: recs[1].line,
40866
+ message: `multiple recommendation lines under one options block: [${recs.map((r) => r.num).join(", ")}]`
40867
+ });
40868
+ continue;
40869
+ }
40870
+ const rec = recs[0];
40871
+ if (!block.numbers.includes(rec.num)) {
40872
+ findings.push({
40873
+ line: rec.line,
40874
+ message: `recommendation ${String(rec.num)} not present in the options block above it (options: [${block.numbers.join(", ")}])`
40875
+ });
40876
+ }
40877
+ }
40878
+ findings.sort((a, b) => a.line - b.line);
40879
+ return findings;
40880
+ }
40881
+ function _isDir12(p) {
40882
+ try {
40883
+ return fs81.statSync(p).isDirectory();
40884
+ } catch {
40885
+ return false;
40886
+ }
40887
+ }
40888
+ function _rglobMdSorted4(dir) {
40889
+ const out = [];
40890
+ const walk = (current) => {
40891
+ let entries;
40892
+ try {
40893
+ entries = fs81.readdirSync(current, { withFileTypes: true });
40894
+ } catch {
40895
+ return;
40896
+ }
40897
+ for (const ent of entries) {
40898
+ const full = path81.join(current, ent.name);
40899
+ if (ent.isDirectory() || ent.isSymbolicLink() && _isDir12(full)) {
40900
+ walk(full);
40901
+ } else if (ent.name.endsWith(".md")) {
40902
+ out.push(full);
40903
+ }
40904
+ }
40905
+ };
40906
+ walk(dir);
40907
+ out.sort();
40908
+ return out;
40909
+ }
40910
+ function _relToPosixOrAbs(child, root) {
40911
+ const rel = path81.relative(root, child);
40912
+ if (rel === "" || rel.startsWith("..") || path81.isAbsolute(rel)) {
40913
+ return child.split(path81.sep).join("/");
40914
+ }
40915
+ return rel.split(path81.sep).join("/");
40916
+ }
40917
+ function cmd_scan_dir(root) {
40918
+ let roots;
40919
+ if (!_isDir12(root)) {
40920
+ const legacy = path81.join(ROOT4, ".agent-src.uncondensed");
40921
+ if (path81.resolve(root) === path81.resolve(legacy)) {
40922
+ roots = artefact_roots();
40923
+ if (roots.length === 0) {
40924
+ process.stderr.write("error: no artefact roots found (legacy or packages/*)\n");
40925
+ return 1;
40926
+ }
40927
+ } else {
40928
+ process.stderr.write(`error: not a directory: ${root}
40929
+ `);
40930
+ return 1;
40931
+ }
40932
+ } else {
40933
+ roots = [root];
40934
+ }
40935
+ const violations = [];
40936
+ let scanned = 0;
40937
+ for (const r of roots) {
40938
+ for (const md of _rglobMdSorted4(r)) {
40939
+ scanned += 1;
40940
+ const text = fs81.readFileSync(md, "utf-8");
40941
+ const lines = _splitlines8(text);
40942
+ for (let idx = 0; idx < lines.length; idx++) {
40943
+ const raw = lines[idx];
40944
+ const stripped = _strip_codespans(raw);
40945
+ if (OPTION_LINE_RE.test(stripped) && TAG_RE.test(stripped)) {
40946
+ violations.push([md, idx + 1, raw.trim()]);
40947
+ }
40948
+ }
40949
+ }
40950
+ }
40951
+ try {
40952
+ assertScanned({
40953
+ gate: "check_reply_consistency",
40954
+ scanned,
40955
+ units: "markdown file(s)",
40956
+ roots: roots.map((r) => _relToPosixOrAbs(r, ROOT4))
40957
+ });
40958
+ } catch (exc) {
40959
+ if (exc instanceof DeadScopeError) {
40960
+ process.stderr.write(`\u274C ${exc.message}
40961
+ `);
40962
+ return 1;
40963
+ }
40964
+ throw exc;
40965
+ }
40966
+ if (violations.length > 0) {
40967
+ for (const [p, line, snippet] of violations) {
40968
+ process.stderr.write(` \u{1F534} ${p}:${String(line)} \u2014 inline-tag \u2014 ${snippet}
40969
+ `);
40970
+ }
40971
+ process.stderr.write(`
40972
+ \u274C ${String(violations.length)} legacy-pattern violation(s)
40973
+ `);
40974
+ return 2;
40975
+ }
40976
+ if (!QUIET) {
40977
+ const scanned2 = roots.map((r) => _relToPosixOrAbs(r, ROOT4)).join(", ");
40978
+ process.stdout.write(`\u2705 No legacy (recommended) tags found under ${scanned2}
40979
+ `);
40980
+ }
40981
+ return 0;
40982
+ }
40983
+ function _usage_error(message) {
40984
+ process.stderr.write(USAGE3);
40985
+ process.stderr.write(`check_reply_consistency: error: ${message}
40986
+ `);
40987
+ process.exit(1);
40988
+ }
40989
+ function _readStdin3() {
40990
+ try {
40991
+ return fs81.readFileSync(0, "utf-8");
40992
+ } catch {
40993
+ return "";
40994
+ }
40995
+ }
40996
+ function parse_args8(argv) {
40997
+ let stdin = false;
40998
+ let file = null;
40999
+ let scan_dir2 = null;
41000
+ let verbose = false;
41001
+ const groupSeen = [];
41002
+ const need = (i, name) => {
41003
+ const v = argv[i];
41004
+ if (v === void 0) {
41005
+ _usage_error(`argument ${name}: expected one argument`);
41006
+ }
41007
+ return v;
41008
+ };
41009
+ for (let i = 0; i < argv.length; i++) {
41010
+ const arg = argv[i];
41011
+ if (arg === "--stdin") {
41012
+ stdin = true;
41013
+ groupSeen.push("--stdin");
41014
+ } else if (arg === "--file") {
41015
+ file = need(++i, "--file");
41016
+ groupSeen.push("--file");
41017
+ } else if (arg.startsWith("--file=")) {
41018
+ file = arg.slice("--file=".length);
41019
+ groupSeen.push("--file");
41020
+ } else if (arg === "--scan-dir") {
41021
+ scan_dir2 = need(++i, "--scan-dir");
41022
+ groupSeen.push("--scan-dir");
41023
+ } else if (arg.startsWith("--scan-dir=")) {
41024
+ scan_dir2 = arg.slice("--scan-dir=".length);
41025
+ groupSeen.push("--scan-dir");
41026
+ } else if (arg === "-v" || arg === "--verbose") {
41027
+ verbose = true;
41028
+ } else if (arg === "--quiet") {
41029
+ } else if (arg === "-h" || arg === "--help") {
41030
+ process.stdout.write(USAGE3);
41031
+ process.exit(0);
41032
+ } else {
41033
+ _usage_error(`unrecognized arguments: ${arg}`);
41034
+ }
41035
+ }
41036
+ if (groupSeen.length === 0) {
41037
+ _usage_error("one of the arguments --stdin --file --scan-dir is required");
41038
+ }
41039
+ if (groupSeen.length > 1) {
41040
+ _usage_error(`argument ${groupSeen[1]}: not allowed with argument ${groupSeen[0]}`);
41041
+ }
41042
+ return { stdin, file, scan_dir: scan_dir2, verbose };
41043
+ }
41044
+ function main27(argv = process.argv.slice(2)) {
41045
+ const args = parse_args8(argv);
41046
+ if (args.scan_dir !== null) {
41047
+ return cmd_scan_dir(args.scan_dir);
41048
+ }
41049
+ let text;
41050
+ try {
41051
+ text = args.stdin ? _readStdin3() : fs81.readFileSync(args.file, "utf-8");
41052
+ } catch (e) {
41053
+ process.stderr.write(`error: ${String(e)}
41054
+ `);
41055
+ return 1;
41056
+ }
41057
+ const findings = check_reply(text);
41058
+ if (findings.length === 0) {
41059
+ if (args.verbose && !QUIET) {
41060
+ process.stdout.write("\u2705 reply consistent (every options block carries one adjacent recommendation)\n");
41061
+ }
41062
+ return 0;
41063
+ }
41064
+ for (const f of findings) {
41065
+ process.stderr.write(`\u274C line ${String(f.line)}: ${f.message}
41066
+ `);
41067
+ }
41068
+ return 2;
41069
+ }
41070
+ function _isCliEntry19() {
41071
+ if (true) {
41072
+ return false;
41073
+ }
41074
+ if (process.argv[1] === void 0) {
41075
+ return false;
41076
+ }
41077
+ const argvUrl = pathToFileURL24(path81.resolve(process.argv[1])).href;
41078
+ if (import.meta.url === argvUrl) {
41079
+ return true;
41080
+ }
41081
+ try {
41082
+ const here = fs81.realpathSync(fileURLToPath39(import.meta.url));
41083
+ const argv = fs81.realpathSync(path81.resolve(process.argv[1]));
41084
+ return here === argv;
41085
+ } catch {
41086
+ return false;
41087
+ }
41088
+ }
41089
+ var _HERE21, ROOT4, QUIET, OPTION_LINE_RE, REC_LINE_RE, TAG_RE, CODESPAN_RE, HEADING_RE, FENCE_RE2, REC_ADJACENCY_WINDOW, USAGE3, _IN_BUNDLE;
41090
+ var init_check_reply_consistency = __esm({
41091
+ "src/scripts/check_reply_consistency.ts"() {
41092
+ "use strict";
41093
+ init_agent_src();
41094
+ init_scan_scope();
41095
+ _HERE21 = fileURLToPath39(import.meta.url);
41096
+ ROOT4 = path81.resolve(path81.dirname(_HERE21), "..", "..");
41097
+ QUIET = process.argv.slice(2).includes("--quiet");
41098
+ OPTION_LINE_RE = /^\s*>?\s*(\d+)\.\s+\S/;
41099
+ REC_LINE_RE = /(?:Recommendation|Empfehlung)\s*:\s*(\d+)\b/i;
41100
+ TAG_RE = /\((?:recommended|rec|empfohlen)\)/i;
41101
+ CODESPAN_RE = /`[^`\n]*`/g;
41102
+ HEADING_RE = /^#{1,6}\s/;
41103
+ FENCE_RE2 = /^\s*(```|~~~)/;
41104
+ REC_ADJACENCY_WINDOW = 2;
41105
+ USAGE3 = "usage: check_reply_consistency [-h] (--stdin | --file FILE | --scan-dir SCAN_DIR)\n [-v] [--quiet]\n";
41106
+ _IN_BUNDLE = true;
41107
+ if (!_IN_BUNDLE && (_isCliEntry19() || process.argv[1] === _HERE21)) {
41108
+ process.exit(main27());
41109
+ }
41110
+ }
41111
+ });
41112
+
41113
+ // src/scripts/_lib/dropped_decision.ts
41114
+ function detectDroppedDecision(assistantTurnTexts, closingFromPayload = false) {
41115
+ if (assistantTurnTexts.length < 2) return null;
41116
+ const asksIn = (text) => {
41117
+ const blocks = find_option_blocks(text);
41118
+ if (blocks.length === 0) return blocks;
41119
+ const masked = splitAndMask(text);
41120
+ return blocks.filter((b) => recommendationsUnder(text, b, masked).length > 0);
41121
+ };
41122
+ const closing = assistantTurnTexts[assistantTurnTexts.length - 1];
41123
+ if (asksIn(closing).length > 0) return null;
41124
+ for (let i = assistantTurnTexts.length - 2; i >= 0; i -= 1) {
41125
+ const earlier = assistantTurnTexts[i];
41126
+ const blocks = asksIn(earlier);
41127
+ if (blocks.length === 0) continue;
41128
+ const block = blocks[blocks.length - 1];
41129
+ return {
41130
+ detector: "pending-decision",
41131
+ // The option NUMBERS and the line span, never the option text: the
41132
+ // evidence is quoted into a refusal that reaches the transcript, and
41133
+ // an options block can carry anything the reply carried.
41134
+ evidence: `options ${block.numbers.join("/")} at lines ${block.startLine}-${block.endLine} of an earlier reply this turn (closing reply read from ${closingFromPayload ? "the stop payload" : "the transcript"})`,
41135
+ reason: "an earlier reply in THIS turn put numbered options to the user and no user answer followed \u2014 this closing reply carries no options block, so the decision disappeared without being answered, cancelled or superseded. A hook nudge, a reviewer result or a task notification may ADD to a turn; it may not displace a question already asked (user-interaction Iron Law 3: a decision handed to the user outlives the turn). Re-present the block and its recommendation line at the end of this reply"
41136
+ };
41137
+ }
41138
+ return null;
41139
+ }
41140
+ var init_dropped_decision = __esm({
41141
+ "src/scripts/_lib/dropped_decision.ts"() {
41142
+ "use strict";
41143
+ init_check_reply_consistency();
41144
+ }
41145
+ });
41146
+
41147
+ // src/scripts/_lib/review_baseline.ts
41148
+ import { spawnSync as spawnSync13 } from "node:child_process";
41149
+ import * as fs82 from "node:fs";
41150
+ import * as path82 from "node:path";
41151
+ function currentHeadSha(cwd) {
41152
+ try {
41153
+ const r = spawnSync13("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" });
41154
+ if (r.status !== 0) return null;
41155
+ const out = (r.stdout ?? "").trim();
41156
+ return out === "" ? null : out;
41157
+ } catch {
41158
+ return null;
41159
+ }
41160
+ }
41161
+ function baselineStateDir(workspaceRoot) {
41162
+ return path82.join(workspaceRoot, BASELINE_STATE_REL);
41163
+ }
41164
+ function baselineStateFile(workspaceRoot, sessionKey) {
41165
+ return path82.join(baselineStateDir(workspaceRoot), `${sessionKey}.json`);
41166
+ }
41167
+ function parseBaseline(raw) {
41168
+ let decoded;
41169
+ try {
41170
+ decoded = JSON.parse(raw);
41171
+ } catch {
41172
+ return null;
41173
+ }
41174
+ if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) return null;
41175
+ const o = decoded;
41176
+ const lines = o["baseline_lines"];
41177
+ if (typeof lines !== "number" || !Number.isFinite(lines) || lines < 0) return null;
41178
+ const written = o["written_at"];
41179
+ if (typeof written !== "string") return null;
41180
+ const head = o["head_sha"];
41181
+ const measure = o["measure"];
41182
+ return {
41183
+ head_sha: typeof head === "string" && head !== "" ? head : null,
41184
+ baseline_lines: lines,
41185
+ ...measure === "exact" || measure === "capped_approximation" ? { measure } : {},
41186
+ written_at: written
41187
+ };
41188
+ }
41189
+ function readBaseline(workspaceRoot, sessionKey) {
41190
+ const file = baselineStateFile(workspaceRoot, sessionKey);
41191
+ let raw;
41192
+ try {
41193
+ raw = fs82.readFileSync(file, "utf-8");
41194
+ } catch (exc) {
41195
+ const code = exc?.code;
41196
+ return code === "ENOENT" ? "absent" : "unreadable";
41197
+ }
41198
+ return parseBaseline(raw) ?? "unreadable";
41199
+ }
41200
+ function applyBaseline(measuredLines, baseline, headSha, measuredMeasure = "exact") {
41201
+ if (baseline === "absent" || baseline === "unreadable") {
41202
+ return { applied: false, fallback: baseline, lines: measuredLines };
41203
+ }
41204
+ if (baseline.measure !== "exact" || measuredMeasure !== "exact") {
41205
+ return { applied: false, fallback: "mixed-measure", lines: measuredLines };
41206
+ }
41207
+ if (baseline.head_sha !== headSha()) {
41208
+ return { applied: false, fallback: "head-moved", lines: measuredLines };
41209
+ }
41210
+ return {
41211
+ applied: true,
41212
+ baseline,
41213
+ lines: Math.max(0, measuredLines - baseline.baseline_lines)
41214
+ };
41215
+ }
41216
+ var BASELINE_STATE_REL;
41217
+ var init_review_baseline = __esm({
41218
+ "src/scripts/_lib/review_baseline.ts"() {
41219
+ "use strict";
41220
+ BASELINE_STATE_REL = path82.join("agents", "runtime", "state", "review-baseline");
41221
+ }
41222
+ });
41223
+
40757
41224
  // src/scripts/_lib/audit_field_provenance.ts
40758
41225
  function appliedIds(values) {
40759
41226
  const out = [];
@@ -40787,6 +41254,9 @@ function buildReviewSkippedLine(input) {
40787
41254
  }
40788
41255
  if (!input.ts) errors.push("ts (ISO-8601 UTC) is required");
40789
41256
  if (!input.id) errors.push("id (ULID, UUID, or content hash) is required");
41257
+ if (input.baseline !== void 0 && !BASELINE_APPLICATIONS.includes(input.baseline)) {
41258
+ errors.push(`baseline must be one of ${BASELINE_APPLICATIONS.join(", ")}`);
41259
+ }
40790
41260
  if (errors.length) return { line: null, errors };
40791
41261
  const line = {
40792
41262
  schema_version: 1,
@@ -40813,15 +41283,29 @@ function buildReviewSkippedLine(input) {
40813
41283
  persona: null,
40814
41284
  input_kind: "prompt",
40815
41285
  type: "note",
40816
- review_skipped: { diff_lines: input.diff_lines, mutation_measure: input.mutation_measure }
41286
+ review_skipped: {
41287
+ diff_lines: input.diff_lines,
41288
+ mutation_measure: input.mutation_measure,
41289
+ // Omitted, not defaulted, when the producer recorded nothing —
41290
+ // audit-log-v1's absent-versus-present split is the same one
41291
+ // `skills_applied` uses above, for the same reason.
41292
+ ...input.baseline === void 0 ? {} : { baseline: input.baseline }
41293
+ }
40817
41294
  };
40818
41295
  return { line, errors: [] };
40819
41296
  }
40820
- var PRODUCER_PRIVACY_CLASS, HIGH_RISK_DIFF_LINES;
41297
+ var BASELINE_APPLICATIONS, PRODUCER_PRIVACY_CLASS, HIGH_RISK_DIFF_LINES;
40821
41298
  var init_review_skipped_record = __esm({
40822
41299
  "src/scripts/_lib/review_skipped_record.ts"() {
40823
41300
  "use strict";
40824
41301
  init_audit_field_provenance();
41302
+ BASELINE_APPLICATIONS = [
41303
+ "applied",
41304
+ "absent",
41305
+ "unreadable",
41306
+ "head_moved",
41307
+ "mixed_measure"
41308
+ ];
40825
41309
  PRODUCER_PRIVACY_CLASS = "ids-only";
40826
41310
  HIGH_RISK_DIFF_LINES = 200;
40827
41311
  }
@@ -40888,24 +41372,24 @@ var init_envelope = __esm({
40888
41372
  });
40889
41373
 
40890
41374
  // src/scripts/hooks/end_review_nudge_hook.ts
40891
- import { spawnSync as spawnSync13 } from "node:child_process";
41375
+ import { spawnSync as spawnSync14 } from "node:child_process";
40892
41376
  import * as crypto7 from "node:crypto";
40893
- import * as fs81 from "node:fs";
41377
+ import * as fs83 from "node:fs";
40894
41378
  import * as os16 from "node:os";
40895
- import * as path81 from "node:path";
40896
- import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL24 } from "node:url";
41379
+ import * as path83 from "node:path";
41380
+ import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL25 } from "node:url";
40897
41381
  function isSafeTranscriptPath(rawPath, opts = {}) {
40898
41382
  if (!rawPath || !/\.jsonl$/i.test(rawPath)) return false;
40899
41383
  const homeDir = opts.homeDir ?? os16.homedir();
40900
41384
  const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
40901
41385
  try {
40902
- const realHome = fs81.realpathSync(homeDir);
40903
- const realPath = fs81.realpathSync(rawPath);
40904
- const relative21 = path81.relative(realHome, realPath);
40905
- if (relative21 === "" || relative21.startsWith("..") || path81.isAbsolute(relative21)) {
41386
+ const realHome = fs83.realpathSync(homeDir);
41387
+ const realPath = fs83.realpathSync(rawPath);
41388
+ const relative22 = path83.relative(realHome, realPath);
41389
+ if (relative22 === "" || relative22.startsWith("..") || path83.isAbsolute(relative22)) {
40906
41390
  return false;
40907
41391
  }
40908
- const { size } = fs81.statSync(realPath);
41392
+ const { size } = fs83.statSync(realPath);
40909
41393
  return size <= maxBytes;
40910
41394
  } catch {
40911
41395
  return false;
@@ -40934,7 +41418,7 @@ function nonDocMutatedLines(rows) {
40934
41418
  }
40935
41419
  function gitNumstatRows(cwd) {
40936
41420
  try {
40937
- const r = spawnSync13("git", ["diff", "--numstat", "HEAD"], {
41421
+ const r = spawnSync14("git", ["diff", "--numstat", "HEAD"], {
40938
41422
  cwd,
40939
41423
  encoding: "utf8",
40940
41424
  maxBuffer: 16 * 1024 * 1024
@@ -40947,7 +41431,7 @@ function gitNumstatRows(cwd) {
40947
41431
  }
40948
41432
  function untrackedNonDocFiles(cwd) {
40949
41433
  try {
40950
- const r = spawnSync13("git", ["ls-files", "--others", "--exclude-standard"], {
41434
+ const r = spawnSync14("git", ["ls-files", "--others", "--exclude-standard"], {
40951
41435
  cwd,
40952
41436
  encoding: "utf8",
40953
41437
  maxBuffer: 16 * 1024 * 1024
@@ -40960,13 +41444,13 @@ function untrackedNonDocFiles(cwd) {
40960
41444
  }
40961
41445
  function untrackedFileLineCount(cwd, relPath) {
40962
41446
  try {
40963
- const abs = path81.resolve(cwd, relPath);
40964
- const size = fs81.statSync(abs).size;
41447
+ const abs = path83.resolve(cwd, relPath);
41448
+ const size = fs83.statSync(abs).size;
40965
41449
  if (size === 0) return 0;
40966
41450
  if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
40967
41451
  return MUTATION_LINE_THRESHOLD + 1;
40968
41452
  }
40969
- const buf = fs81.readFileSync(abs);
41453
+ const buf = fs83.readFileSync(abs);
40970
41454
  if (buf.length === 0) return 0;
40971
41455
  const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
40972
41456
  if (probe.includes(0)) return 0;
@@ -41041,30 +41525,31 @@ function scanTranscriptForReviewer(transcriptText) {
41041
41525
  function buildAdvisoryLine(diffLines) {
41042
41526
  return `this session mutated ${diffLines} lines without a neutral review; spawn a cross-model reviewer before claiming done (delegation-policy / verify-budget)`;
41043
41527
  }
41044
- function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure) {
41528
+ function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure, baseline) {
41045
41529
  if (is_replay_mode()) return;
41046
41530
  const ts = (/* @__PURE__ */ new Date()).toISOString();
41047
41531
  const { line, errors } = buildReviewSkippedLine({
41048
41532
  diff_lines: diffLines,
41049
41533
  mutation_measure: mutationMeasure,
41050
41534
  ts,
41051
- id: crypto7.randomUUID()
41535
+ id: crypto7.randomUUID(),
41536
+ baseline
41052
41537
  });
41053
41538
  if (errors.length || line === null) return;
41054
41539
  try {
41055
- const dir = path81.join(workspaceRoot, "agents", "runtime", "state", "audit");
41056
- fs81.mkdirSync(dir, { recursive: true });
41057
- const file = path81.join(dir, `${ts.slice(0, 7)}.jsonl`);
41058
- fs81.appendFileSync(file, `${JSON.stringify(line)}
41540
+ const dir = path83.join(workspaceRoot, "agents", "runtime", "state", "audit");
41541
+ fs83.mkdirSync(dir, { recursive: true });
41542
+ const file = path83.join(dir, `${ts.slice(0, 7)}.jsonl`);
41543
+ fs83.appendFileSync(file, `${JSON.stringify(line)}
41059
41544
  `, "utf8");
41060
41545
  } catch {
41061
41546
  }
41062
41547
  }
41063
41548
  function sessionStateDir(workspaceRoot) {
41064
- return path81.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
41549
+ return path83.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
41065
41550
  }
41066
41551
  function sessionStateFile(workspaceRoot, sessionKey) {
41067
- return path81.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
41552
+ return path83.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
41068
41553
  }
41069
41554
  function deriveSessionKey(envelope, payload) {
41070
41555
  const raw = str2(envelope["session_id"]) || str2(payload["transcript_path"] ?? payload["transcriptPath"]);
@@ -41073,7 +41558,7 @@ function deriveSessionKey(envelope, payload) {
41073
41558
  }
41074
41559
  function hasFiredThisSession(workspaceRoot, sessionKey) {
41075
41560
  try {
41076
- return fs81.existsSync(sessionStateFile(workspaceRoot, sessionKey));
41561
+ return fs83.existsSync(sessionStateFile(workspaceRoot, sessionKey));
41077
41562
  } catch {
41078
41563
  return false;
41079
41564
  }
@@ -41087,26 +41572,39 @@ function markFiredThisSession(workspaceRoot, sessionKey, ts) {
41087
41572
  function _read_stdin() {
41088
41573
  return readHookStdin();
41089
41574
  }
41090
- function main27() {
41575
+ function main28() {
41091
41576
  const [envelope, payload] = unwrap(_read_stdin(), "claude");
41092
41577
  const event = String(envelope["event"] ?? "");
41093
41578
  if (event !== "" && event !== "stop") {
41094
41579
  return 0;
41095
41580
  }
41096
41581
  const workspace_root = String(envelope["workspace_root"] ?? "").trim() || process.cwd();
41097
- let diffLines;
41582
+ let measuredLines;
41098
41583
  let mutationMeasure;
41099
41584
  try {
41100
41585
  const measured = totalNonDocMutatedLinesWithMeasure(workspace_root);
41101
- diffLines = measured.lines;
41586
+ measuredLines = measured.lines;
41102
41587
  mutationMeasure = measured.measure;
41103
41588
  } catch {
41104
41589
  return 0;
41105
41590
  }
41591
+ const sessionKey = deriveSessionKey(envelope, payload);
41592
+ const baselineOutcome = applyBaseline(
41593
+ measuredLines,
41594
+ readBaseline(workspace_root, sessionKey),
41595
+ // A THUNK, not a value: on the `absent` and `unreadable` branches the
41596
+ // result is discarded, and those two are the steady state on every host
41597
+ // without this nudge and on every session before its first baseline
41598
+ // write. Passing the value eagerly spent an 11-14 ms `git rev-parse` on
41599
+ // each of those stops for nothing.
41600
+ () => currentHeadSha(workspace_root),
41601
+ mutationMeasure
41602
+ );
41603
+ const diffLines = baselineOutcome.lines;
41604
+ const baselineApplication = baselineOutcome.applied ? "applied" : FALLBACK_TO_TELEMETRY[baselineOutcome.fallback];
41106
41605
  if (diffLines <= MUTATION_LINE_THRESHOLD) {
41107
41606
  return 0;
41108
41607
  }
41109
- const sessionKey = deriveSessionKey(envelope, payload);
41110
41608
  if (hasFiredThisSession(workspace_root, sessionKey)) {
41111
41609
  return 0;
41112
41610
  }
@@ -41116,7 +41614,7 @@ function main27() {
41116
41614
  let reviewerRan = false;
41117
41615
  if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
41118
41616
  try {
41119
- reviewerRan = scanTranscriptForReviewer(fs81.readFileSync(transcriptPath, "utf-8"));
41617
+ reviewerRan = scanTranscriptForReviewer(fs83.readFileSync(transcriptPath, "utf-8"));
41120
41618
  } catch {
41121
41619
  reviewerRan = false;
41122
41620
  }
@@ -41126,7 +41624,12 @@ function main27() {
41126
41624
  }
41127
41625
  markFiredThisSession(workspace_root, sessionKey, (/* @__PURE__ */ new Date()).toISOString());
41128
41626
  try {
41129
- appendReviewSkippedTelemetry(workspace_root, diffLines, mutationMeasure);
41627
+ appendReviewSkippedTelemetry(
41628
+ workspace_root,
41629
+ diffLines,
41630
+ mutationMeasure,
41631
+ baselineApplication
41632
+ );
41130
41633
  } catch {
41131
41634
  }
41132
41635
  process.stdout.write(
@@ -41139,29 +41642,30 @@ function main27() {
41139
41642
  );
41140
41643
  return EXIT_WARN2;
41141
41644
  }
41142
- function _isCliEntry19() {
41645
+ function _isCliEntry20() {
41143
41646
  if (true) {
41144
41647
  return false;
41145
41648
  }
41146
41649
  if (process.argv[1] === void 0) {
41147
41650
  return false;
41148
41651
  }
41149
- const argvUrl = pathToFileURL24(path81.resolve(process.argv[1])).href;
41652
+ const argvUrl = pathToFileURL25(path83.resolve(process.argv[1])).href;
41150
41653
  if (import.meta.url === argvUrl) {
41151
41654
  return true;
41152
41655
  }
41153
41656
  try {
41154
- const here = fs81.realpathSync(fileURLToPath39(import.meta.url));
41155
- const argv = fs81.realpathSync(path81.resolve(process.argv[1]));
41657
+ const here = fs83.realpathSync(fileURLToPath40(import.meta.url));
41658
+ const argv = fs83.realpathSync(path83.resolve(process.argv[1]));
41156
41659
  return here === argv;
41157
41660
  } catch {
41158
41661
  return false;
41159
41662
  }
41160
41663
  }
41161
- var MUTATION_LINE_THRESHOLD, UNTRACKED_FILE_CAP, TRANSCRIPT_SCAN_MAX_BYTES, EXIT_WARN2, DOC_PATH_RE, BINARY_PROBE_BYTES, UNTRACKED_FILE_READ_CAP_BYTES, DISPATCH_TOOL_RE, REVIEW_SHAPED_LABEL_RE, REVIEW_SHAPED_PROMPT_RE, REVIEW_SKILL_NAME_RE;
41664
+ var MUTATION_LINE_THRESHOLD, UNTRACKED_FILE_CAP, TRANSCRIPT_SCAN_MAX_BYTES, EXIT_WARN2, DOC_PATH_RE, BINARY_PROBE_BYTES, UNTRACKED_FILE_READ_CAP_BYTES, DISPATCH_TOOL_RE, REVIEW_SHAPED_LABEL_RE, REVIEW_SHAPED_PROMPT_RE, REVIEW_SKILL_NAME_RE, FALLBACK_TO_TELEMETRY;
41162
41665
  var init_end_review_nudge_hook = __esm({
41163
41666
  "src/scripts/hooks/end_review_nudge_hook.ts"() {
41164
41667
  "use strict";
41668
+ init_review_baseline();
41165
41669
  init_review_skipped_record();
41166
41670
  init_envelope();
41167
41671
  init_hook_stdin();
@@ -41177,8 +41681,14 @@ var init_end_review_nudge_hook = __esm({
41177
41681
  REVIEW_SHAPED_LABEL_RE = /\b(review|judge|adversarial|critique|second[- ]opinion|blind\s+(pass|review)|cross-model)\b/i;
41178
41682
  REVIEW_SHAPED_PROMPT_RE = /\b(code\s+review|neutral\s+review|adversarial|judge|critique|second[- ]opinion|blind\s+(pass|review)|cross-model)\b/i;
41179
41683
  REVIEW_SKILL_NAME_RE = /^(review[-:]changes|judge[-:][a-z0-9-]+|adversarial-review|code-review)$/i;
41180
- if (_isCliEntry19()) {
41181
- process.exit(main27());
41684
+ FALLBACK_TO_TELEMETRY = {
41685
+ absent: "absent",
41686
+ unreadable: "unreadable",
41687
+ "head-moved": "head_moved",
41688
+ "mixed-measure": "mixed_measure"
41689
+ };
41690
+ if (_isCliEntry20()) {
41691
+ process.exit(main28());
41182
41692
  }
41183
41693
  }
41184
41694
  });
@@ -41331,9 +41841,9 @@ var init_subagent_response = __esm({
41331
41841
 
41332
41842
  // src/scripts/hooks/subagent_ledger_hook.ts
41333
41843
  import * as crypto8 from "node:crypto";
41334
- import * as fs82 from "node:fs";
41335
- import * as path82 from "node:path";
41336
- import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL25 } from "node:url";
41844
+ import * as fs84 from "node:fs";
41845
+ import * as path84 from "node:path";
41846
+ import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL26 } from "node:url";
41337
41847
  function isObject2(v) {
41338
41848
  return typeof v === "object" && v !== null && !Array.isArray(v);
41339
41849
  }
@@ -41424,10 +41934,10 @@ function _jsonObjectCandidates(message) {
41424
41934
  return out;
41425
41935
  }
41426
41936
  function openDir(root) {
41427
- return path82.join(root, LEDGER_DIR, OPEN_SUBDIR);
41937
+ return path84.join(root, LEDGER_DIR, OPEN_SUBDIR);
41428
41938
  }
41429
41939
  function openFile(root, ref) {
41430
- return path82.join(openDir(root), `${ref}.json`);
41940
+ return path84.join(openDir(root), `${ref}.json`);
41431
41941
  }
41432
41942
  function _asOpenRecord(value, expectedRef) {
41433
41943
  if (!isObject2(value)) return null;
@@ -41453,7 +41963,7 @@ function readOpenRecords(root) {
41453
41963
  const out = /* @__PURE__ */ new Map();
41454
41964
  let names;
41455
41965
  try {
41456
- names = fs82.readdirSync(openDir(root));
41966
+ names = fs84.readdirSync(openDir(root));
41457
41967
  } catch {
41458
41968
  return out;
41459
41969
  }
@@ -41461,7 +41971,7 @@ function readOpenRecords(root) {
41461
41971
  if (!name.endsWith(".json")) continue;
41462
41972
  const expectedRef = name.slice(0, -".json".length);
41463
41973
  try {
41464
- const raw = fs82.readFileSync(path82.join(openDir(root), name), "utf8");
41974
+ const raw = fs84.readFileSync(path84.join(openDir(root), name), "utf8");
41465
41975
  const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
41466
41976
  if (rec) out.set(rec.ref, rec);
41467
41977
  } catch {
@@ -41476,13 +41986,13 @@ function resolveDepth(parentRef, open) {
41476
41986
  return { depth: parent.depth + 1, depth_basis: "observed" };
41477
41987
  }
41478
41988
  function ledgerFileFor2(root, ts) {
41479
- return path82.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
41989
+ return path84.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
41480
41990
  }
41481
41991
  function appendLedgerLine(root, ts, line) {
41482
41992
  if (is_replay_mode()) return;
41483
41993
  const file = ledgerFileFor2(root, ts);
41484
- fs82.mkdirSync(path82.dirname(file), { recursive: true });
41485
- fs82.appendFileSync(file, `${JSON.stringify(line)}
41994
+ fs84.mkdirSync(path84.dirname(file), { recursive: true });
41995
+ fs84.appendFileSync(file, `${JSON.stringify(line)}
41486
41996
  `, "utf8");
41487
41997
  }
41488
41998
  function armsExceeded(elapsedMs) {
@@ -41490,7 +42000,7 @@ function armsExceeded(elapsedMs) {
41490
42000
  return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
41491
42001
  }
41492
42002
  function openRecordStats(root, nowMs = Date.now()) {
41493
- const ledgerPresent = fs82.existsSync(path82.join(root, LEDGER_DIR));
42003
+ const ledgerPresent = fs84.existsSync(path84.join(root, LEDGER_DIR));
41494
42004
  const open = readOpenRecords(root);
41495
42005
  let maxDepth = 0;
41496
42006
  let counted = 0;
@@ -41518,13 +42028,13 @@ function writeOpenRecord(root, rec) {
41518
42028
  function removeOpenRecord(root, ref) {
41519
42029
  if (is_replay_mode()) return;
41520
42030
  try {
41521
- fs82.unlinkSync(openFile(root, ref));
42031
+ fs84.unlinkSync(openFile(root, ref));
41522
42032
  } catch {
41523
42033
  }
41524
42034
  }
41525
42035
  function countOpen(root) {
41526
42036
  try {
41527
- return fs82.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
42037
+ return fs84.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
41528
42038
  } catch {
41529
42039
  return 0;
41530
42040
  }
@@ -41675,7 +42185,7 @@ function resolveConsumerRoot(envelope) {
41675
42185
  }
41676
42186
  return process.cwd();
41677
42187
  }
41678
- function main28() {
42188
+ function main29() {
41679
42189
  const raw = readHookStdin();
41680
42190
  let envelope = {};
41681
42191
  try {
@@ -41685,15 +42195,15 @@ function main28() {
41685
42195
  }
41686
42196
  return processEnvelope(envelope, resolveConsumerRoot(envelope));
41687
42197
  }
41688
- function _isCliEntry20() {
42198
+ function _isCliEntry21() {
41689
42199
  if (true) {
41690
42200
  return false;
41691
42201
  }
41692
42202
  if (process.argv[1] === void 0) return false;
41693
- const argvUrl = pathToFileURL25(path82.resolve(process.argv[1])).href;
42203
+ const argvUrl = pathToFileURL26(path84.resolve(process.argv[1])).href;
41694
42204
  if (import.meta.url === argvUrl) return true;
41695
42205
  try {
41696
- return fs82.realpathSync(fileURLToPath40(import.meta.url)) === fs82.realpathSync(path82.resolve(process.argv[1]));
42206
+ return fs84.realpathSync(fileURLToPath41(import.meta.url)) === fs84.realpathSync(path84.resolve(process.argv[1]));
41697
42207
  } catch {
41698
42208
  return false;
41699
42209
  }
@@ -41706,7 +42216,7 @@ var init_subagent_ledger_hook = __esm({
41706
42216
  init_state_io();
41707
42217
  init_hook_stdin();
41708
42218
  EXIT_ALLOW3 = 0;
41709
- LEDGER_DIR = path82.join("agents", "runtime", "state", "subagent-ledger");
42219
+ LEDGER_DIR = path84.join("agents", "runtime", "state", "subagent-ledger");
41710
42220
  OPEN_SUBDIR = "open";
41711
42221
  OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
41712
42222
  DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
@@ -41716,24 +42226,26 @@ var init_subagent_ledger_hook = __esm({
41716
42226
  { label: "30m", ms: 30 * 60 * 1e3 },
41717
42227
  { label: "2h", ms: 2 * 60 * 60 * 1e3 }
41718
42228
  ];
41719
- if (_isCliEntry20()) process.exit(main28());
42229
+ if (_isCliEntry21()) process.exit(main29());
41720
42230
  }
41721
42231
  });
41722
42232
 
41723
42233
  // src/scripts/_lib/turn_end_refusals.ts
41724
42234
  import * as crypto9 from "node:crypto";
41725
- import * as path83 from "node:path";
42235
+ import * as path85 from "node:path";
41726
42236
  function refusalStateDir(workspaceRoot) {
41727
- return path83.join(workspaceRoot, REFUSAL_STATE_REL);
42237
+ return path85.join(workspaceRoot, REFUSAL_STATE_REL);
41728
42238
  }
41729
42239
  function deriveSessionKey2(sessionId) {
41730
42240
  return crypto9.createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
41731
42241
  }
41732
42242
  function sessionRefusalFile(workspaceRoot, sessionKey) {
41733
- return path83.join(refusalStateDir(workspaceRoot), `${sessionKey}.json`);
42243
+ return path85.join(refusalStateDir(workspaceRoot), `${sessionKey}.json`);
41734
42244
  }
41735
42245
  function emptyCounts() {
41736
- return { promissory: 0, language: 0, verification: 0, completion: 0 };
42246
+ const out = {};
42247
+ for (const id of DETECTOR_IDS) out[id] = 0;
42248
+ return out;
41737
42249
  }
41738
42250
  function isDetector(v) {
41739
42251
  return typeof v === "string" && DETECTOR_IDS.includes(v);
@@ -41759,6 +42271,9 @@ function parseRecord(raw) {
41759
42271
  if (typeof o["agent_config_version"] === "string") {
41760
42272
  rec.agent_config_version = o["agent_config_version"];
41761
42273
  }
42274
+ if (typeof o["refused_prompt_id"] === "string") {
42275
+ rec.refused_prompt_id = o["refused_prompt_id"];
42276
+ }
41762
42277
  const counts2 = o["counts"];
41763
42278
  if (typeof counts2 === "object" && counts2 !== null && !Array.isArray(counts2)) {
41764
42279
  const parsed = {};
@@ -41802,6 +42317,9 @@ function foldRefusal(prev, input) {
41802
42317
  else if (prev?.agent_config_version !== void 0) {
41803
42318
  rec.agent_config_version = prev.agent_config_version;
41804
42319
  }
42320
+ if (input.promptId !== void 0 && input.promptId !== "") {
42321
+ rec.refused_prompt_id = input.promptId;
42322
+ }
41805
42323
  return rec;
41806
42324
  }
41807
42325
  function readInstallBoundary() {
@@ -41825,16 +42343,18 @@ var init_turn_end_refusals = __esm({
41825
42343
  "promissory",
41826
42344
  "language",
41827
42345
  "verification",
41828
- "completion"
42346
+ "completion",
42347
+ "pending-decision",
42348
+ "untested"
41829
42349
  ];
41830
- REFUSAL_STATE_REL = path83.join("agents", "runtime", "state", "turn-end-gate");
42350
+ REFUSAL_STATE_REL = path85.join("agents", "runtime", "state", "turn-end-gate");
41831
42351
  }
41832
42352
  });
41833
42353
 
41834
42354
  // src/scripts/hooks/turn_end_gate_hook.ts
41835
- import * as fs83 from "node:fs";
41836
- import * as path84 from "node:path";
41837
- import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL26 } from "node:url";
42355
+ import * as fs85 from "node:fs";
42356
+ import * as path86 from "node:path";
42357
+ import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL27 } from "node:url";
41838
42358
  function stripFencedBlocks(text) {
41839
42359
  const out = [];
41840
42360
  let open = null;
@@ -41891,7 +42411,7 @@ function detectPromissory(reply) {
41891
42411
  function readCiSettled(workspaceRoot, session_id) {
41892
42412
  if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
41893
42413
  try {
41894
- const raw = fs83.readFileSync(path84.join(workspaceRoot, statePathFor2(session_id)), "utf-8");
42414
+ const raw = fs85.readFileSync(path86.join(workspaceRoot, statePathFor2(session_id)), "utf-8");
41895
42415
  const decoded = JSON.parse(raw);
41896
42416
  if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
41897
42417
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
@@ -41925,8 +42445,8 @@ function detectCompletionClaim(reply, ci) {
41925
42445
  function readLanguagePin(workspaceRoot, session_id) {
41926
42446
  if (!hasStableSessionId(session_id)) return "und";
41927
42447
  try {
41928
- const raw = fs83.readFileSync(
41929
- path84.join(workspaceRoot, statePathFor(session_id)),
42448
+ const raw = fs85.readFileSync(
42449
+ path86.join(workspaceRoot, statePathFor(session_id)),
41930
42450
  "utf-8"
41931
42451
  );
41932
42452
  const decoded = JSON.parse(raw);
@@ -41975,12 +42495,34 @@ function detectUnverifiedEdit(toolCalls) {
41975
42495
  reason: "this turn changed a file and then ran no verification command \u2014 no test, type-check, lint or build call follows the last edit (verify-before-complete: a claim without a fresh run is unverified)"
41976
42496
  };
41977
42497
  }
42498
+ function _isTestPath(p) {
42499
+ return _TEST_PATH_RE.test(p) || _TEST_FILE_RE.test(p);
42500
+ }
42501
+ function _isProductionSource(p) {
42502
+ return _SOURCE_RE.test(p) && !_isTestPath(p);
42503
+ }
42504
+ function detectUntestedChange(reply, toolCalls) {
42505
+ const edited = toolCalls.filter((c) => _EDIT_TOOLS.has(c.name) && c.path !== void 0).map((c) => c.path);
42506
+ const source = edited.filter(_isProductionSource);
42507
+ if (source.length === 0) return null;
42508
+ if (edited.some(_isTestPath)) return null;
42509
+ const prose = visibleProse(reply);
42510
+ const m = _COMPLETION_RE.exec(prose);
42511
+ if (!m) return null;
42512
+ if (_NEGATED_CLAIM_RE.test(_lineAround(prose, m.index))) return null;
42513
+ const shown = source.slice(0, 3).join(", ");
42514
+ return {
42515
+ detector: "untested",
42516
+ evidence: shown + (source.length > 3 ? ` (+${String(source.length - 3)} more)` : ""),
42517
+ reason: "a completion claim over production code this turn changed, with NO test file touched anywhere in the turn \u2014 running a linter is not evidence the change works. Write the test that would have caught the failure, and enumerate the states the change actually has (every view, every CRUD path, the empty and error states) rather than the happy one. If a test genuinely does not belong here, say which file carries the coverage instead"
42518
+ };
42519
+ }
41978
42520
  function sessionStateFile2(workspaceRoot, sessionKey) {
41979
42521
  return sessionRefusalFile(workspaceRoot, sessionKey);
41980
42522
  }
41981
42523
  function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
41982
42524
  try {
41983
- const raw = fs83.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
42525
+ const raw = fs85.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
41984
42526
  const decoded = JSON.parse(raw);
41985
42527
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
41986
42528
  return decoded["refused_turn"] === turnOrdinal;
@@ -41989,12 +42531,12 @@ function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
41989
42531
  }
41990
42532
  return false;
41991
42533
  }
41992
- function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors) {
42534
+ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors, promptId) {
41993
42535
  if (is_replay_mode()) return;
41994
42536
  const file = sessionStateFile2(workspaceRoot, sessionKey);
41995
42537
  let prev = null;
41996
42538
  try {
41997
- prev = parseRecord(fs83.readFileSync(file, "utf-8"));
42539
+ prev = parseRecord(fs85.readFileSync(file, "utf-8"));
41998
42540
  } catch {
41999
42541
  }
42000
42542
  let version;
@@ -42010,27 +42552,34 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors) {
42010
42552
  detectors,
42011
42553
  turnOrdinal,
42012
42554
  at: (/* @__PURE__ */ new Date()).toISOString(),
42013
- version
42555
+ version,
42556
+ promptId
42014
42557
  })
42015
42558
  );
42016
42559
  } catch {
42017
42560
  }
42018
42561
  }
42019
42562
  function readTranscriptTail(transcriptPath, opts = {}) {
42020
- const empty = { lastAssistant: "", turnOrdinal: 0, toolCalls: [] };
42563
+ const empty = {
42564
+ lastAssistant: "",
42565
+ turnOrdinal: 0,
42566
+ toolCalls: [],
42567
+ assistantTurnTexts: []
42568
+ };
42021
42569
  if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
42022
42570
  let lines;
42023
42571
  try {
42024
- if (opts.maxBytes !== void 0 && fs83.statSync(transcriptPath).size > opts.maxBytes) {
42572
+ if (opts.maxBytes !== void 0 && fs85.statSync(transcriptPath).size > opts.maxBytes) {
42025
42573
  return empty;
42026
42574
  }
42027
- lines = fs83.readFileSync(transcriptPath, "utf-8").split("\n");
42575
+ lines = fs85.readFileSync(transcriptPath, "utf-8").split("\n");
42028
42576
  } catch {
42029
42577
  return empty;
42030
42578
  }
42031
42579
  let lastAssistant = "";
42032
42580
  let turnOrdinal = 0;
42033
42581
  let toolCalls = [];
42582
+ let assistantTurnTexts = [];
42034
42583
  for (const rawLine of lines) {
42035
42584
  const line = rawLine.trim();
42036
42585
  if (!line) continue;
@@ -42049,20 +42598,27 @@ function readTranscriptTail(transcriptPath, opts = {}) {
42049
42598
  if (typeof msg !== "object" || msg === null || Array.isArray(msg)) continue;
42050
42599
  const content = msg["content"];
42051
42600
  if (role === "assistant") {
42052
- toolCalls.push(..._toolCalls(content));
42601
+ toolCalls.push(...extractToolCalls(content));
42053
42602
  }
42054
42603
  const text = _messageText(content);
42055
42604
  if (text === null) continue;
42056
42605
  if (role === "assistant") {
42057
42606
  lastAssistant = text;
42607
+ assistantTurnTexts.push(text);
42058
42608
  } else if (!isSyntheticPrompt(text)) {
42059
42609
  turnOrdinal += 1;
42060
42610
  toolCalls = [];
42611
+ assistantTurnTexts = [];
42061
42612
  }
42062
42613
  }
42063
- return { lastAssistant: lastAssistant.trim(), turnOrdinal, toolCalls };
42614
+ return {
42615
+ lastAssistant: lastAssistant.trim(),
42616
+ turnOrdinal,
42617
+ toolCalls,
42618
+ assistantTurnTexts
42619
+ };
42064
42620
  }
42065
- function _toolCalls(content) {
42621
+ function extractToolCalls(content) {
42066
42622
  if (!Array.isArray(content)) return [];
42067
42623
  const out = [];
42068
42624
  for (const blk of content) {
@@ -42100,7 +42656,7 @@ function _messageText(content) {
42100
42656
  function str4(v) {
42101
42657
  return typeof v === "string" ? v : "";
42102
42658
  }
42103
- function main29() {
42659
+ function main30() {
42104
42660
  let envelope;
42105
42661
  let payload;
42106
42662
  try {
@@ -42118,10 +42674,19 @@ function main29() {
42118
42674
  const transcriptPath = str4(
42119
42675
  payload["transcript_path"] ?? payload["transcriptPath"]
42120
42676
  );
42121
- const { lastAssistant, turnOrdinal, toolCalls } = readTranscriptTail(transcriptPath, {
42122
- maxBytes: TRANSCRIPT_READ_MAX_BYTES
42123
- });
42677
+ const { lastAssistant, turnOrdinal, toolCalls, assistantTurnTexts } = readTranscriptTail(
42678
+ transcriptPath,
42679
+ { maxBytes: TRANSCRIPT_READ_MAX_BYTES }
42680
+ );
42124
42681
  if (!lastAssistant) return EXIT_ALLOW4;
42682
+ const payloadClosing = str4(
42683
+ payload["last_assistant_message"] ?? payload["lastAssistantMessage"]
42684
+ );
42685
+ const closingFromPayload = payloadClosing !== "" && !assistantTurnTexts.includes(payloadClosing);
42686
+ const turnTexts = closingFromPayload ? [...assistantTurnTexts, payloadClosing] : assistantTurnTexts;
42687
+ const promptId = str4(
42688
+ payload["prompt_id"] ?? payload["promptId"]
42689
+ );
42125
42690
  const rawSessionId = str4(envelope["session_id"]) || "";
42126
42691
  const sessionKey = deriveSessionKey2(rawSessionId || "unknown-session");
42127
42692
  if (alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal)) return EXIT_ALLOW4;
@@ -42143,7 +42708,23 @@ function main29() {
42143
42708
  // gating is where the comment above says gating belongs — inside the
42144
42709
  // detector: no CI observed, or a settled read, or no completion claim
42145
42710
  // ⇒ no finding.
42146
- dispatchOpen ? null : detectCompletionClaim(lastAssistant, readCiSettled(workspaceRoot, rawSessionId))
42711
+ dispatchOpen ? null : detectCompletionClaim(lastAssistant, readCiSettled(workspaceRoot, rawSessionId)),
42712
+ // Detector E is UNCONDITIONAL, and that is the opposite choice from A
42713
+ // and D one line above rather than an oversight. An open dispatch
42714
+ // excuses a promissory closing because the work is genuinely still
42715
+ // running; it excuses nothing about a question the user was already
42716
+ // asked. Worse: a dispatch — or the `end-review-nudge` stop concern
42717
+ // that produced the measured failure — IS the continuation that drops
42718
+ // the decision, so narrowing E the same way would silence it in exactly
42719
+ // the case it exists for.
42720
+ detectDroppedDecision(turnTexts, closingFromPayload),
42721
+ // Detector F takes the OTHER side of that same question, and the two
42722
+ // sitting adjacent is the clearest place to say why. E fires on a
42723
+ // question already asked, which an open dispatch cannot excuse. F fires
42724
+ // on a completion CLAIM, and a turn waiting on a subagent has not
42725
+ // finished — so its closing is not the claim F is about. Same slot,
42726
+ // opposite trigger, opposite treatment of `dispatchOpen`.
42727
+ dispatchOpen ? null : detectUntestedChange(lastAssistant, toolCalls)
42147
42728
  ]) {
42148
42729
  if (f) findings.push(f);
42149
42730
  }
@@ -42152,7 +42733,8 @@ function main29() {
42152
42733
  workspaceRoot,
42153
42734
  sessionKey,
42154
42735
  turnOrdinal,
42155
- findings.map((f) => f.detector)
42736
+ findings.map((f) => f.detector),
42737
+ promptId
42156
42738
  );
42157
42739
  const lines = findings.map(
42158
42740
  (f) => ` \xB7 ${f.detector}: ${f.reason}
@@ -42161,37 +42743,38 @@ function main29() {
42161
42743
  process.stderr.write(
42162
42744
  `turn-end-gate: REFUSED \u2014 this turn is not finished.
42163
42745
  ${lines.join("\n")}
42164
- Do the promised work now, correct the language, run the verification the edit needs, or read the CI verdict before claiming it \u2014 then end the turn.
42746
+ Do the promised work now, correct the language, run the verification the edit needs, read the CI verdict before claiming it, or re-present the options block this turn dropped \u2014 then end the turn.
42165
42747
  This turn will not be refused a second time.
42166
42748
  `
42167
42749
  );
42168
42750
  return EXIT_BLOCK;
42169
42751
  }
42170
- function _isCliEntry21() {
42752
+ function _isCliEntry22() {
42171
42753
  if (true) {
42172
42754
  return false;
42173
42755
  }
42174
42756
  if (process.argv[1] === void 0) {
42175
42757
  return false;
42176
42758
  }
42177
- const argvUrl = pathToFileURL26(path84.resolve(process.argv[1])).href;
42759
+ const argvUrl = pathToFileURL27(path86.resolve(process.argv[1])).href;
42178
42760
  if (import.meta.url === argvUrl) {
42179
42761
  return true;
42180
42762
  }
42181
42763
  try {
42182
- const here = fs83.realpathSync(fileURLToPath41(import.meta.url));
42183
- const argv = fs83.realpathSync(path84.resolve(process.argv[1]));
42764
+ const here = fs85.realpathSync(fileURLToPath42(import.meta.url));
42765
+ const argv = fs85.realpathSync(path86.resolve(process.argv[1]));
42184
42766
  return here === argv;
42185
42767
  } catch {
42186
42768
  return false;
42187
42769
  }
42188
42770
  }
42189
- var EXIT_BLOCK, EXIT_ALLOW4, TRANSCRIPT_READ_MAX_BYTES, PROMISSORY, HANDBACK, _COMPLETION_RE, _NEGATED_CLAIM_RE, _EDIT_TOOLS, _VERIFY_RE;
42771
+ var EXIT_BLOCK, EXIT_ALLOW4, TRANSCRIPT_READ_MAX_BYTES, PROMISSORY, HANDBACK, _COMPLETION_RE, _NEGATED_CLAIM_RE, _EDIT_TOOLS, _VERIFY_RE, _SOURCE_RE, _TEST_PATH_RE, _TEST_FILE_RE;
42190
42772
  var init_turn_end_gate_hook = __esm({
42191
42773
  "src/scripts/hooks/turn_end_gate_hook.ts"() {
42192
42774
  "use strict";
42193
42775
  init_language_mirror_hook();
42194
42776
  init_before_complete_hook();
42777
+ init_dropped_decision();
42195
42778
  init_end_review_nudge_hook();
42196
42779
  init_envelope();
42197
42780
  init_hook_stdin();
@@ -42252,17 +42835,20 @@ var init_turn_end_gate_hook = __esm({
42252
42835
  _NEGATED_CLAIM_RE = /\b(noch nicht|nicht fertig|nicht durch|wäre verfrüht|ist verfrüht|not yet|not done|isn'?t done|nein)\b/i;
42253
42836
  _EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
42254
42837
  _VERIFY_RE = /\b(test|tests|vitest|jest|pytest|phpunit|pest|tsc|eslint|ruff|mypy|pyright|clippy|phpstan|typecheck|lint[-_:a-z]*|build|ci|preflight|smoke[-_:a-z]*|check[-_:a-z]*|validate[-_:a-z]*)\b|\b(task|npm|pnpm|yarn|composer|cargo|go|make|php artisan|bun)\s+(run\s+)?\S*(test|check|lint|build|ci|typecheck)/i;
42255
- if (_isCliEntry21()) {
42256
- process.exit(main29());
42838
+ _SOURCE_RE = /\.(?:ts|tsx|js|jsx|mjs|cjs|vue|svelte|php|py|rb|go|rs|java|kt|swift|cs|scala|ex|exs)$/i;
42839
+ _TEST_PATH_RE = /(?:^|\/)(?:tests?|specs?|__tests__|__specs__|e2e|cypress|playwright|features)\//i;
42840
+ _TEST_FILE_RE = /(?:\.(?:test|spec)\.[a-z]+$)|(?:_test\.[a-z]+$)|(?:(?:^|\/)test_[^/]+$)|(?:Test\.php$)|(?:Spec\.php$)|(?:\.feature$)/i;
42841
+ if (_isCliEntry22()) {
42842
+ process.exit(main30());
42257
42843
  }
42258
42844
  }
42259
42845
  });
42260
42846
 
42261
42847
  // src/scripts/hooks/evidence_independence.ts
42262
42848
  import crypto10 from "node:crypto";
42263
- import fs84 from "node:fs";
42264
- import path85 from "node:path";
42265
- import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL27 } from "node:url";
42849
+ import fs86 from "node:fs";
42850
+ import path87 from "node:path";
42851
+ import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL28 } from "node:url";
42266
42852
  function _isObject6(v) {
42267
42853
  return typeof v === "object" && v !== null && !Array.isArray(v);
42268
42854
  }
@@ -42299,8 +42885,8 @@ function extractDispatch(envelope) {
42299
42885
  }
42300
42886
  function _ledgerStamp(consumer_root) {
42301
42887
  try {
42302
- const raw = fs84.readFileSync(
42303
- path85.join(consumer_root, "agents", "state", "git-authorization.json"),
42888
+ const raw = fs86.readFileSync(
42889
+ path87.join(consumer_root, "agents", "state", "git-authorization.json"),
42304
42890
  "utf8"
42305
42891
  );
42306
42892
  const d = JSON.parse(raw);
@@ -42311,7 +42897,7 @@ function _ledgerStamp(consumer_root) {
42311
42897
  }
42312
42898
  function _load2(target) {
42313
42899
  try {
42314
- const decoded = JSON.parse(fs84.readFileSync(target, "utf8"));
42900
+ const decoded = JSON.parse(fs86.readFileSync(target, "utf8"));
42315
42901
  if (_isObject6(decoded) && Array.isArray(decoded["evaluations"])) {
42316
42902
  return decoded;
42317
42903
  }
@@ -42368,7 +42954,7 @@ function run4(stdin_text, options) {
42368
42954
  return EXIT_ALLOW5;
42369
42955
  }
42370
42956
  }
42371
- const target = path85.join(options.consumer_root, STATE_FILE4);
42957
+ const target = path87.join(options.consumer_root, STATE_FILE4);
42372
42958
  const state = _load2(target);
42373
42959
  const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
42374
42960
  const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root)}`;
@@ -42406,7 +42992,7 @@ function _errText3(err) {
42406
42992
  const t = err instanceof Error ? err.message : String(err);
42407
42993
  return t.replace(/\s+/g, " ").trim().slice(0, 200);
42408
42994
  }
42409
- function main30(argv) {
42995
+ function main31(argv) {
42410
42996
  const args = argv ?? process.argv.slice(2);
42411
42997
  let consumer_root = process.cwd();
42412
42998
  for (let i = 0; i < args.length; i += 1) {
@@ -42420,20 +43006,20 @@ function main30(argv) {
42420
43006
  }
42421
43007
  return run4(readHookStdin(), { consumer_root });
42422
43008
  }
42423
- function _isCliEntry22() {
43009
+ function _isCliEntry23() {
42424
43010
  if (true) {
42425
43011
  return false;
42426
43012
  }
42427
43013
  if (process.argv[1] === void 0) {
42428
43014
  return false;
42429
43015
  }
42430
- const argvUrl = pathToFileURL27(path85.resolve(process.argv[1])).href;
43016
+ const argvUrl = pathToFileURL28(path87.resolve(process.argv[1])).href;
42431
43017
  if (import.meta.url === argvUrl) {
42432
43018
  return true;
42433
43019
  }
42434
43020
  try {
42435
- const here = fs84.realpathSync(fileURLToPath42(import.meta.url));
42436
- const argv = fs84.realpathSync(path85.resolve(process.argv[1]));
43021
+ const here = fs86.realpathSync(fileURLToPath43(import.meta.url));
43022
+ const argv = fs86.realpathSync(path87.resolve(process.argv[1]));
42437
43023
  return here === argv;
42438
43024
  } catch {
42439
43025
  return false;
@@ -42447,7 +43033,7 @@ var init_evidence_independence = __esm({
42447
43033
  init_hook_stdin();
42448
43034
  EXIT_ALLOW5 = 0;
42449
43035
  EXIT_BLOCK2 = 1;
42450
- STATE_FILE4 = path85.join("agents", "state", "evidence-dispatch.json");
43036
+ STATE_FILE4 = path87.join("agents", "state", "evidence-dispatch.json");
42451
43037
  DISPATCH_TOOLS = /* @__PURE__ */ new Set([
42452
43038
  "Agent",
42453
43039
  "Task",
@@ -42480,8 +43066,8 @@ var init_evidence_independence = __esm({
42480
43066
  ];
42481
43067
  SELF_SCOPE_RE = /\b(my (work|change|diff|implementation|code|fix|patch|branch|pr)|this (diff|change|pr|delta|implementation|patch)|the delta|the change i|what i (wrote|built|changed|implemented)|i just (wrote|built|changed|implemented))\b/i;
42482
43068
  WARN_TEXT = "First evaluation dispatch this turn. Two shapes fabricated a binding honest-null in the audited sessions \u2014 check your prompt for both before it goes out: (1) a verdict pre-loaded into the prompt, and (2) a scope narrowed to files you chose. A review you commissioned on your own work is admissible as gate evidence only when the prompt is recorded alongside the verdict.";
42483
- if (_isCliEntry22()) {
42484
- process.exit(main30());
43069
+ if (_isCliEntry23()) {
43070
+ process.exit(main31());
42485
43071
  }
42486
43072
  }
42487
43073
  });
@@ -42782,9 +43368,9 @@ var init_subagent_routing = __esm({
42782
43368
  });
42783
43369
 
42784
43370
  // src/scripts/hooks/delegation_nudge_hook.ts
42785
- import fs85 from "node:fs";
42786
- import path86 from "node:path";
42787
- import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL28 } from "node:url";
43371
+ import fs87 from "node:fs";
43372
+ import path88 from "node:path";
43373
+ import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL29 } from "node:url";
42788
43374
  function _isObject7(v) {
42789
43375
  return typeof v === "object" && v !== null && !Array.isArray(v);
42790
43376
  }
@@ -42950,7 +43536,7 @@ function _workspaceRoot(envelope) {
42950
43536
  }
42951
43537
  return process.cwd();
42952
43538
  }
42953
- function main31() {
43539
+ function main32() {
42954
43540
  let envelope = {};
42955
43541
  try {
42956
43542
  const raw = readHookStdin();
@@ -42989,20 +43575,20 @@ function main31() {
42989
43575
  );
42990
43576
  return EXIT_WARN3;
42991
43577
  }
42992
- function _isCliEntry23() {
43578
+ function _isCliEntry24() {
42993
43579
  if (true) {
42994
43580
  return false;
42995
43581
  }
42996
43582
  if (process.argv[1] === void 0) {
42997
43583
  return false;
42998
43584
  }
42999
- const argvUrl = pathToFileURL28(path86.resolve(process.argv[1])).href;
43585
+ const argvUrl = pathToFileURL29(path88.resolve(process.argv[1])).href;
43000
43586
  if (import.meta.url === argvUrl) {
43001
43587
  return true;
43002
43588
  }
43003
43589
  try {
43004
- const here = fs85.realpathSync(fileURLToPath43(import.meta.url));
43005
- const argv = fs85.realpathSync(path86.resolve(process.argv[1]));
43590
+ const here = fs87.realpathSync(fileURLToPath44(import.meta.url));
43591
+ const argv = fs87.realpathSync(path88.resolve(process.argv[1]));
43006
43592
  return here === argv;
43007
43593
  } catch {
43008
43594
  return false;
@@ -43029,18 +43615,18 @@ var init_delegation_nudge_hook = __esm({
43029
43615
  STEP_LINE_RE = /^\s*\d+[.)]\s+\S/gm;
43030
43616
  ORDERED_LINE_FLOOR = 3;
43031
43617
  ORDERED_WORD_FLOOR = 2;
43032
- if (_isCliEntry23()) {
43033
- process.exit(main31());
43618
+ if (_isCliEntry24()) {
43619
+ process.exit(main32());
43034
43620
  }
43035
43621
  }
43036
43622
  });
43037
43623
 
43038
43624
  // src/scripts/conformance_scan.ts
43039
43625
  import { createHash as createHash14 } from "node:crypto";
43040
- import fs86 from "node:fs";
43626
+ import fs88 from "node:fs";
43041
43627
  import os17 from "node:os";
43042
- import path87 from "node:path";
43043
- import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL29 } from "node:url";
43628
+ import path89 from "node:path";
43629
+ import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL30 } from "node:url";
43044
43630
  function spansCarrierChange(firstAts) {
43045
43631
  const stamps = firstAts.filter((s) => s !== "").sort();
43046
43632
  if (stamps.length === 0) {
@@ -43382,7 +43968,7 @@ function scanSession(sessionId, lines) {
43382
43968
  }
43383
43969
  function defaultStore(projectDir) {
43384
43970
  const slug = projectStoreSlug(projectDir);
43385
- return path87.join(process.env["HOME"] ?? "", ".claude", "projects", slug);
43971
+ return path89.join(process.env["HOME"] ?? "", ".claude", "projects", slug);
43386
43972
  }
43387
43973
  function _tokens(chars) {
43388
43974
  return Math.round(chars / 4);
@@ -43393,13 +43979,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
43393
43979
  return {
43394
43980
  project: {
43395
43981
  dir: projectRulesDir,
43396
- present: fs86.existsSync(projectRulesDir),
43982
+ present: fs88.existsSync(projectRulesDir),
43397
43983
  files: p.files,
43398
43984
  tokens: _tokens(p.chars)
43399
43985
  },
43400
43986
  global: {
43401
43987
  dir: globalRulesDir,
43402
- present: fs86.existsSync(globalRulesDir),
43988
+ present: fs88.existsSync(globalRulesDir),
43403
43989
  files: g.files,
43404
43990
  tokens: _tokens(g.chars)
43405
43991
  },
@@ -43407,13 +43993,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
43407
43993
  };
43408
43994
  }
43409
43995
  function storeKey(store) {
43410
- return createHash14("sha256").update(path87.resolve(store)).digest("hex").slice(0, 12);
43996
+ return createHash14("sha256").update(path89.resolve(store)).digest("hex").slice(0, 12);
43411
43997
  }
43412
43998
  function scanStore(store, limit) {
43413
- const files = fs86.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs86.statSync(path87.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
43999
+ const files = fs88.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs88.statSync(path89.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
43414
44000
  const per_session = [];
43415
44001
  for (const f of files) {
43416
- const lines = fs86.readFileSync(path87.join(store, f), "utf8").split("\n");
44002
+ const lines = fs88.readFileSync(path89.join(store, f), "utf8").split("\n");
43417
44003
  const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
43418
44004
  if (r.assistant_turns > 0) {
43419
44005
  per_session.push(r);
@@ -43441,10 +44027,10 @@ function scanStore(store, limit) {
43441
44027
  const task_completeness_rate_pct = completeness_windows === 0 ? 0 : Number((100 * task_completeness / completeness_windows).toFixed(1));
43442
44028
  const era = spansCarrierChange(per_session.map((s) => s.first_at));
43443
44029
  const delivered = measureDelivered(
43444
- path87.join(REPO_ROOT7, ".claude", "rules"),
43445
- path87.join(process.env["HOME"] ?? os17.homedir(), ".claude", "rules")
44030
+ path89.join(REPO_ROOT7, ".claude", "rules"),
44031
+ path89.join(process.env["HOME"] ?? os17.homedir(), ".claude", "rules")
43446
44032
  );
43447
- const ownStore = path87.resolve(store) === path87.resolve(defaultStore(REPO_ROOT7));
44033
+ const ownStore = path89.resolve(store) === path89.resolve(defaultStore(REPO_ROOT7));
43448
44034
  return {
43449
44035
  scanned_at: (/* @__PURE__ */ new Date()).toISOString(),
43450
44036
  store,
@@ -43474,8 +44060,8 @@ function scanStore(store, limit) {
43474
44060
  };
43475
44061
  }
43476
44062
  function recordRate(file, scanned_at, rate) {
43477
- fs86.mkdirSync(path87.dirname(file), { recursive: true });
43478
- fs86.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
44063
+ fs88.mkdirSync(path89.dirname(file), { recursive: true });
44064
+ fs88.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
43479
44065
  `, "utf8");
43480
44066
  }
43481
44067
  function render3(report2) {
@@ -43574,7 +44160,7 @@ function render3(report2) {
43574
44160
  lines.push(" checkbox batching \u2014 measured NOWHERE. ~5 low-severity findings.");
43575
44161
  return lines.join("\n");
43576
44162
  }
43577
- function main32(argv) {
44163
+ function main33(argv) {
43578
44164
  const args = argv ?? process.argv.slice(2);
43579
44165
  let store = null;
43580
44166
  let limit = 30;
@@ -43606,14 +44192,14 @@ function main32(argv) {
43606
44192
  return 2;
43607
44193
  }
43608
44194
  const resolved = store ?? defaultStore(process.cwd());
43609
- if (!fs86.existsSync(resolved)) {
44195
+ if (!fs88.existsSync(resolved)) {
43610
44196
  process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
43611
44197
  `);
43612
44198
  return 1;
43613
44199
  }
43614
44200
  const report2 = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
43615
44201
  if (out) {
43616
- fs86.writeFileSync(out, `${JSON.stringify(report2, null, 2)}
44202
+ fs88.writeFileSync(out, `${JSON.stringify(report2, null, 2)}
43617
44203
  `, "utf8");
43618
44204
  }
43619
44205
  if (record) {
@@ -43621,7 +44207,7 @@ function main32(argv) {
43621
44207
  }
43622
44208
  if (why !== null) {
43623
44209
  const id = why;
43624
- fs86.writeSync(
44210
+ fs88.writeSync(
43625
44211
  1,
43626
44212
  json ? `${JSON.stringify(
43627
44213
  {
@@ -43641,25 +44227,25 @@ function main32(argv) {
43641
44227
  );
43642
44228
  return 0;
43643
44229
  }
43644
- fs86.writeSync(1, json ? `${JSON.stringify(report2, null, 2)}
44230
+ fs88.writeSync(1, json ? `${JSON.stringify(report2, null, 2)}
43645
44231
  ` : `${render3(report2)}
43646
44232
  `);
43647
44233
  return 0;
43648
44234
  }
43649
- function _isCliEntry24() {
44235
+ function _isCliEntry25() {
43650
44236
  if (true) {
43651
44237
  return false;
43652
44238
  }
43653
44239
  if (process.argv[1] === void 0) {
43654
44240
  return false;
43655
44241
  }
43656
- const argvUrl = pathToFileURL29(path87.resolve(process.argv[1])).href;
44242
+ const argvUrl = pathToFileURL30(path89.resolve(process.argv[1])).href;
43657
44243
  if (import.meta.url === argvUrl) {
43658
44244
  return true;
43659
44245
  }
43660
44246
  try {
43661
- const here = fs86.realpathSync(fileURLToPath44(import.meta.url));
43662
- const argv = fs86.realpathSync(path87.resolve(process.argv[1]));
44247
+ const here = fs88.realpathSync(fileURLToPath45(import.meta.url));
44248
+ const argv = fs88.realpathSync(path89.resolve(process.argv[1]));
43663
44249
  return here === argv;
43664
44250
  } catch {
43665
44251
  return false;
@@ -43680,7 +44266,7 @@ var init_conformance_scan = __esm({
43680
44266
  init_turn_end_gate_hook();
43681
44267
  init_evidence_independence();
43682
44268
  init_delegation_nudge_hook();
43683
- REPO_ROOT7 = path87.resolve(path87.dirname(fileURLToPath44(import.meta.url)), "..", "..");
44269
+ REPO_ROOT7 = path89.resolve(path89.dirname(fileURLToPath45(import.meta.url)), "..", "..");
43684
44270
  OBSERVED_BAND = { low: 9.1, high: 39.2 };
43685
44271
  BAND_MIN_TURNS = 1978;
43686
44272
  CARRIER_CHANGES = [
@@ -43707,28 +44293,28 @@ var init_conformance_scan = __esm({
43707
44293
  };
43708
44294
  HARNESS_TEXT = /^(API Error:|Request (timed out|was aborted)|\[Request interrupted|Error: |Credit balance is too low|You've hit your|Prompt is too long)/i;
43709
44295
  EN_OPENER = /^(let me|i'?ll |i'?m |found it|ok[,. ]|okay|alright|here'?s|now[,. ]|looking|checking|reading|running|the |this |that |there |we |you |good |right[,. ]|perfect|done[.,]|all |confirmed|correct)/i;
43710
- DEFAULT_RATE_SERIES = path87.join(
44296
+ DEFAULT_RATE_SERIES = path89.join(
43711
44297
  REPO_ROOT7,
43712
44298
  "agents",
43713
44299
  "runtime",
43714
44300
  "state",
43715
44301
  "conformance-rates.jsonl"
43716
44302
  );
43717
- if (_isCliEntry24()) {
43718
- process.exit(main32());
44303
+ if (_isCliEntry25()) {
44304
+ process.exit(main33());
43719
44305
  }
43720
44306
  }
43721
44307
  });
43722
44308
 
43723
44309
  // src/scripts/report_carrier_divergence.ts
43724
- import * as fs87 from "node:fs";
44310
+ import * as fs89 from "node:fs";
43725
44311
  import * as os18 from "node:os";
43726
- import * as path88 from "node:path";
44312
+ import * as path90 from "node:path";
43727
44313
  import process20 from "node:process";
43728
- import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL30 } from "node:url";
44314
+ import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL31 } from "node:url";
43729
44315
  function _listRules(dir) {
43730
44316
  try {
43731
- return fs87.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
44317
+ return fs89.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
43732
44318
  } catch {
43733
44319
  return [];
43734
44320
  }
@@ -43736,7 +44322,7 @@ function _listRules(dir) {
43736
44322
  function _ruleType(file) {
43737
44323
  let text;
43738
44324
  try {
43739
- text = fs87.readFileSync(file, "utf-8");
44325
+ text = fs89.readFileSync(file, "utf-8");
43740
44326
  } catch {
43741
44327
  return "";
43742
44328
  }
@@ -43747,8 +44333,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
43747
44333
  const out = {
43748
44334
  projectDir,
43749
44335
  globalDir,
43750
- globalPresent: fs87.existsSync(globalDir),
43751
- projectPresent: fs87.existsSync(projectDir),
44336
+ globalPresent: fs89.existsSync(globalDir),
44337
+ projectPresent: fs89.existsSync(projectDir),
43752
44338
  shared: 0,
43753
44339
  identical: [],
43754
44340
  provenanceOnly: [],
@@ -43771,7 +44357,7 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
43771
44357
  }
43772
44358
  if (!inP && inG) {
43773
44359
  out.globalOnly.push(rule);
43774
- if (sourceDir !== void 0 && _ruleType(path88.join(sourceDir, rule)) === "manual") {
44360
+ if (sourceDir !== void 0 && _ruleType(path90.join(sourceDir, rule)) === "manual") {
43775
44361
  out.manualOnlyGlobal.push(rule);
43776
44362
  }
43777
44363
  continue;
@@ -43781,8 +44367,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
43781
44367
  let projectCopy;
43782
44368
  let globalCopy;
43783
44369
  try {
43784
- projectCopy = fs87.readFileSync(path88.join(projectDir, rule));
43785
- globalCopy = fs87.readFileSync(path88.join(globalDir, rule));
44370
+ projectCopy = fs89.readFileSync(path90.join(projectDir, rule));
44371
+ globalCopy = fs89.readFileSync(path90.join(globalDir, rule));
43786
44372
  verdict = comparePair(projectCopy, globalCopy);
43787
44373
  } catch {
43788
44374
  out.shared -= 1;
@@ -43927,11 +44513,11 @@ function render4(d) {
43927
44513
  }
43928
44514
  return lines.join("\n");
43929
44515
  }
43930
- function main33(argv) {
44516
+ function main34(argv) {
43931
44517
  const args = argv ?? process20.argv.slice(2);
43932
- let projectDir = path88.join(REPO_ROOT8, PROJECT_RULES);
43933
- let globalDir = path88.join(os18.homedir(), GLOBAL_RULES);
43934
- let sourceDir = path88.join(REPO_ROOT8, PROJECTION_SOURCE);
44518
+ let projectDir = path90.join(REPO_ROOT8, PROJECT_RULES);
44519
+ let globalDir = path90.join(os18.homedir(), GLOBAL_RULES);
44520
+ let sourceDir = path90.join(REPO_ROOT8, PROJECTION_SOURCE);
43935
44521
  const value = (i) => {
43936
44522
  const v = args[i + 1];
43937
44523
  return v === void 0 || v.startsWith("-") ? null : v;
@@ -43945,7 +44531,7 @@ function main33(argv) {
43945
44531
  `);
43946
44532
  return 1;
43947
44533
  }
43948
- const resolved = path88.resolve(v);
44534
+ const resolved = path90.resolve(v);
43949
44535
  if (a === "--project") projectDir = resolved;
43950
44536
  else if (a === "--global") globalDir = resolved;
43951
44537
  else sourceDir = resolved;
@@ -43965,36 +44551,36 @@ function main33(argv) {
43965
44551
  `);
43966
44552
  return 0;
43967
44553
  }
43968
- function _isCliEntry25() {
44554
+ function _isCliEntry26() {
43969
44555
  if (process20.argv[1] === void 0) return false;
43970
- if (import.meta.url === pathToFileURL30(path88.resolve(process20.argv[1])).href) return true;
44556
+ if (import.meta.url === pathToFileURL31(path90.resolve(process20.argv[1])).href) return true;
43971
44557
  try {
43972
- return fs87.realpathSync(_HERE21) === fs87.realpathSync(path88.resolve(process20.argv[1]));
44558
+ return fs89.realpathSync(_HERE22) === fs89.realpathSync(path90.resolve(process20.argv[1]));
43973
44559
  } catch {
43974
44560
  return false;
43975
44561
  }
43976
44562
  }
43977
- var _HERE21, REPO_ROOT8, PROJECT_RULES, PROJECTION_SOURCE, GLOBAL_RULES;
44563
+ var _HERE22, REPO_ROOT8, PROJECT_RULES, PROJECTION_SOURCE, GLOBAL_RULES;
43978
44564
  var init_report_carrier_divergence = __esm({
43979
44565
  "src/scripts/report_carrier_divergence.ts"() {
43980
44566
  "use strict";
43981
44567
  init_carrier_divergence();
43982
- _HERE21 = fileURLToPath45(import.meta.url);
43983
- REPO_ROOT8 = path88.resolve(path88.dirname(_HERE21), "..", "..");
43984
- PROJECT_RULES = path88.join(".claude", "rules");
43985
- PROJECTION_SOURCE = path88.join("dist", "agent-src", "rules");
43986
- GLOBAL_RULES = path88.join(".claude", "rules");
43987
- if (_isCliEntry25()) {
43988
- process20.exit(main33());
44568
+ _HERE22 = fileURLToPath46(import.meta.url);
44569
+ REPO_ROOT8 = path90.resolve(path90.dirname(_HERE22), "..", "..");
44570
+ PROJECT_RULES = path90.join(".claude", "rules");
44571
+ PROJECTION_SOURCE = path90.join("dist", "agent-src", "rules");
44572
+ GLOBAL_RULES = path90.join(".claude", "rules");
44573
+ if (_isCliEntry26()) {
44574
+ process20.exit(main34());
43989
44575
  }
43990
44576
  }
43991
44577
  });
43992
44578
 
43993
44579
  // src/scripts/report_skill_activation.ts
43994
- import * as fs88 from "node:fs";
44580
+ import * as fs90 from "node:fs";
43995
44581
  import * as os19 from "node:os";
43996
- import * as path89 from "node:path";
43997
- import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL31 } from "node:url";
44582
+ import * as path91 from "node:path";
44583
+ import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL32 } from "node:url";
43998
44584
  function censusSkills(root) {
43999
44585
  const out = {
44000
44586
  total: 0,
@@ -44002,25 +44588,25 @@ function censusSkills(root) {
44002
44588
  withTriggerCorpus: [],
44003
44589
  withDeterministicObligation: []
44004
44590
  };
44005
- if (!fs88.existsSync(root)) {
44591
+ if (!fs90.existsSync(root)) {
44006
44592
  return out;
44007
44593
  }
44008
- for (const entry of fs88.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
44594
+ for (const entry of fs90.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
44009
44595
  if (!entry.isDirectory()) {
44010
44596
  continue;
44011
44597
  }
44012
- const file = path89.join(root, entry.name, "SKILL.md");
44013
- if (!fs88.existsSync(file)) {
44598
+ const file = path91.join(root, entry.name, "SKILL.md");
44599
+ if (!fs90.existsSync(file)) {
44014
44600
  continue;
44015
44601
  }
44016
44602
  out.total += 1;
44017
- const text = fs88.readFileSync(file, "utf8");
44603
+ const text = fs90.readFileSync(file, "utf8");
44018
44604
  const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
44019
44605
  const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
44020
44606
  if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
44021
44607
  out.withTriggerKey.push(entry.name);
44022
44608
  }
44023
- if (fs88.existsSync(path89.join(root, entry.name, "evals", "triggers.json"))) {
44609
+ if (fs90.existsSync(path91.join(root, entry.name, "evals", "triggers.json"))) {
44024
44610
  out.withTriggerCorpus.push(entry.name);
44025
44611
  }
44026
44612
  const body = fmEnd === -1 ? text : text.slice(fmEnd + 4);
@@ -44031,17 +44617,17 @@ function censusSkills(root) {
44031
44617
  return out;
44032
44618
  }
44033
44619
  function defaultStore2(cwd) {
44034
- return path89.join(os19.homedir(), ".claude", "projects", projectStoreSlug(cwd));
44620
+ return path91.join(os19.homedir(), ".claude", "projects", projectStoreSlug(cwd));
44035
44621
  }
44036
44622
  function measureUsage(store, limit) {
44037
44623
  const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
44038
- if (!fs88.existsSync(store)) {
44624
+ if (!fs90.existsSync(store)) {
44039
44625
  return rep;
44040
44626
  }
44041
- const files = fs88.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path89.join(store, f)).sort((a, b) => fs88.statSync(b).mtimeMs - fs88.statSync(a).mtimeMs).slice(0, limit);
44627
+ const files = fs90.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path91.join(store, f)).sort((a, b) => fs90.statSync(b).mtimeMs - fs90.statSync(a).mtimeMs).slice(0, limit);
44042
44628
  rep.sessions = files.length;
44043
44629
  for (const file of files) {
44044
- for (const line of fs88.readFileSync(file, "utf8").split("\n")) {
44630
+ for (const line of fs90.readFileSync(file, "utf8").split("\n")) {
44045
44631
  if (!line.trim()) {
44046
44632
  continue;
44047
44633
  }
@@ -44113,15 +44699,15 @@ function buildRecord(census, usage, today) {
44113
44699
  assistant_turns: usage.reduce((a, u) => a + u.assistantTurns, 0),
44114
44700
  invocations: usage.reduce((a, u) => a + u.invocations, 0),
44115
44701
  distinct_skills_invoked: distinct.size,
44116
- stores: usage.map((u) => path89.basename(u.store))
44702
+ stores: usage.map((u) => path91.basename(u.store))
44117
44703
  };
44118
44704
  }
44119
44705
  function readRecord(repoRoot) {
44120
- const file = path89.join(repoRoot, RECORD_PATH);
44121
- if (!fs88.existsSync(file)) {
44706
+ const file = path91.join(repoRoot, RECORD_PATH);
44707
+ if (!fs90.existsSync(file)) {
44122
44708
  return null;
44123
44709
  }
44124
- return JSON.parse(fs88.readFileSync(file, "utf8"));
44710
+ return JSON.parse(fs90.readFileSync(file, "utf8"));
44125
44711
  }
44126
44712
  function render5(census, usage, published = null) {
44127
44713
  const lines = [];
@@ -44156,7 +44742,7 @@ function render5(census, usage, published = null) {
44156
44742
  }
44157
44743
  totalInv += u.invocations;
44158
44744
  lines.push(
44159
- ` ${path89.basename(u.store).slice(-38).padEnd(38)} sessions=${String(u.sessions).padStart(3)} asst=${String(u.assistantTurns).padStart(6)} Skill calls=${String(u.invocations).padStart(3)}`
44745
+ ` ${path91.basename(u.store).slice(-38).padEnd(38)} sessions=${String(u.sessions).padStart(3)} asst=${String(u.assistantTurns).padStart(6)} Skill calls=${String(u.invocations).padStart(3)}`
44160
44746
  );
44161
44747
  }
44162
44748
  lines.push("");
@@ -44226,7 +44812,7 @@ function render5(census, usage, published = null) {
44226
44812
  lines.push(" catalogue once per session, then count descriptions against bare names.");
44227
44813
  return lines.join("\n");
44228
44814
  }
44229
- function main34(argv) {
44815
+ function main35(argv) {
44230
44816
  let limit = 30;
44231
44817
  let emit2 = false;
44232
44818
  let allowEmpty = false;
@@ -44248,7 +44834,7 @@ function main34(argv) {
44248
44834
  } else if (a === "--allow-empty-store") {
44249
44835
  allowEmpty = true;
44250
44836
  } else if (a === "--help" || a === "-h") {
44251
- process.stdout.write(USAGE3);
44837
+ process.stdout.write(USAGE4);
44252
44838
  return 0;
44253
44839
  }
44254
44840
  }
@@ -44259,7 +44845,7 @@ function main34(argv) {
44259
44845
  if (stores.length === 0) {
44260
44846
  stores.push(defaultStore2(REPO_ROOT9));
44261
44847
  }
44262
- const census = censusSkills(path89.join(root, SKILLS_ROOT));
44848
+ const census = censusSkills(path91.join(root, SKILLS_ROOT));
44263
44849
  const usage = stores.map((s) => measureUsage(s, limit));
44264
44850
  process.stdout.write(`${render5(census, usage, readRecord(root))}
44265
44851
  `);
@@ -44280,40 +44866,40 @@ function main34(argv) {
44280
44866
  return 1;
44281
44867
  }
44282
44868
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
44283
- const file = path89.join(root, RECORD_PATH);
44284
- fs88.mkdirSync(path89.dirname(file), { recursive: true });
44285
- fs88.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
44869
+ const file = path91.join(root, RECORD_PATH);
44870
+ fs90.mkdirSync(path91.dirname(file), { recursive: true });
44871
+ fs90.writeFileSync(file, `${JSON.stringify(buildRecord(census, usage, today), null, 2)}
44286
44872
  `);
44287
44873
  process.stdout.write(`
44288
44874
  wrote ${RECORD_PATH} (measured ${today})
44289
44875
  `);
44290
44876
  return 0;
44291
44877
  }
44292
- var _HERE22, REPO_ROOT9, SKILLS_ROOT, TRIGGER_KEYS, DETERMINISTIC_RE, RECORD_PATH, USAGE3;
44878
+ var _HERE23, REPO_ROOT9, SKILLS_ROOT, TRIGGER_KEYS, DETERMINISTIC_RE, RECORD_PATH, USAGE4;
44293
44879
  var init_report_skill_activation = __esm({
44294
44880
  "src/scripts/report_skill_activation.ts"() {
44295
44881
  "use strict";
44296
44882
  init_cc_transcript();
44297
44883
  init_scan_scope();
44298
- _HERE22 = fileURLToPath46(import.meta.url);
44299
- REPO_ROOT9 = path89.resolve(path89.dirname(_HERE22), "..", "..");
44884
+ _HERE23 = fileURLToPath47(import.meta.url);
44885
+ REPO_ROOT9 = path91.resolve(path91.dirname(_HERE23), "..", "..");
44300
44886
  SKILLS_ROOT = "src/skills";
44301
44887
  TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
44302
44888
  DETERMINISTIC_RE = /^\s*(?:[-*]\s*)?(?:\*\*)?(MUST|NEVER|ALWAYS)\b/m;
44303
44889
  RECORD_PATH = "agents/evidence/metrics/skill-activation-census.json";
44304
- USAGE3 = "usage: report_skill_activation [--root DIR] [--limit N] [--store PATH]... [--emit] [--allow-empty-store]\n";
44305
- if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL31(path89.resolve(process.argv[1])).href) {
44306
- process.exit(main34(process.argv.slice(2)));
44890
+ USAGE4 = "usage: report_skill_activation [--root DIR] [--limit N] [--store PATH]... [--emit] [--allow-empty-store]\n";
44891
+ if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL32(path91.resolve(process.argv[1])).href) {
44892
+ process.exit(main35(process.argv.slice(2)));
44307
44893
  }
44308
44894
  }
44309
44895
  });
44310
44896
 
44311
44897
  // src/scripts/report_skill_obligation_violations.ts
44312
- import * as fs89 from "node:fs";
44898
+ import * as fs91 from "node:fs";
44313
44899
  import * as os20 from "node:os";
44314
- import * as path90 from "node:path";
44900
+ import * as path92 from "node:path";
44315
44901
  import process21 from "node:process";
44316
- import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL32 } from "node:url";
44902
+ import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL33 } from "node:url";
44317
44903
  function _verb(line) {
44318
44904
  const m = /\b(NEVER|MUST|ALWAYS)\b/.exec(line);
44319
44905
  return m?.[1] ?? "NEVER";
@@ -44332,7 +44918,7 @@ function _artefacts(line) {
44332
44918
  return out;
44333
44919
  }
44334
44920
  function extractObligations(repoRoot) {
44335
- const skillsRoot = path90.join(repoRoot, SKILLS_ROOT);
44921
+ const skillsRoot = path92.join(repoRoot, SKILLS_ROOT);
44336
44922
  const census = censusSkills(skillsRoot);
44337
44923
  const out = {
44338
44924
  skills: census.withDeterministicObligation,
@@ -44346,7 +44932,7 @@ function extractObligations(repoRoot) {
44346
44932
  for (const skill of census.withDeterministicObligation) {
44347
44933
  let text;
44348
44934
  try {
44349
- text = fs89.readFileSync(path90.join(skillsRoot, skill, "SKILL.md"), "utf-8");
44935
+ text = fs91.readFileSync(path92.join(skillsRoot, skill, "SKILL.md"), "utf-8");
44350
44936
  } catch {
44351
44937
  continue;
44352
44938
  }
@@ -44448,7 +45034,7 @@ function scanSessionForViolations(session, lines, forbidden, parsed) {
44448
45034
  return flags;
44449
45035
  }
44450
45036
  function defaultStore3(cwd) {
44451
- return path90.join(os20.homedir(), ".claude", "projects", projectStoreSlug(cwd));
45037
+ return path92.join(os20.homedir(), ".claude", "projects", projectStoreSlug(cwd));
44452
45038
  }
44453
45039
  function scanStore2(repoRoot, store, limit) {
44454
45040
  const census = extractObligations(repoRoot);
@@ -44461,14 +45047,14 @@ function scanStore2(repoRoot, store, limit) {
44461
45047
  };
44462
45048
  let files;
44463
45049
  try {
44464
- files = fs89.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path90.join(store, f), m: fs89.statSync(path90.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
45050
+ files = fs91.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path92.join(store, f), m: fs91.statSync(path92.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
44465
45051
  } catch {
44466
45052
  return report2;
44467
45053
  }
44468
45054
  report2.sessions = files.length;
44469
45055
  for (const file of files) {
44470
- const lines = fs89.readFileSync(file, "utf-8").split("\n");
44471
- const id = path90.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
45056
+ const lines = fs91.readFileSync(file, "utf-8").split("\n");
45057
+ const id = path92.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
44472
45058
  const entries = _parseSession(lines);
44473
45059
  if (loadedSkillsFrom(entries).size > 0) report2.sessionsWithASkill += 1;
44474
45060
  report2.flags.push(...scanSessionForViolations(id, lines, census.forbidden, entries));
@@ -44538,7 +45124,7 @@ function render6(r) {
44538
45124
  lines.push(" ships as detection-only, and this one says so.");
44539
45125
  return lines.join("\n");
44540
45126
  }
44541
- function main35(argv) {
45127
+ function main36(argv) {
44542
45128
  const args = argv ?? process21.argv.slice(2);
44543
45129
  let limit = 30;
44544
45130
  let json = false;
@@ -44591,24 +45177,24 @@ function main35(argv) {
44591
45177
  }
44592
45178
  return 0;
44593
45179
  }
44594
- function _isCliEntry26() {
45180
+ function _isCliEntry27() {
44595
45181
  if (process21.argv[1] === void 0) return false;
44596
- if (import.meta.url === pathToFileURL32(path90.resolve(process21.argv[1])).href) return true;
45182
+ if (import.meta.url === pathToFileURL33(path92.resolve(process21.argv[1])).href) return true;
44597
45183
  try {
44598
- return fs89.realpathSync(_HERE23) === fs89.realpathSync(path90.resolve(process21.argv[1]));
45184
+ return fs91.realpathSync(_HERE24) === fs91.realpathSync(path92.resolve(process21.argv[1]));
44599
45185
  } catch {
44600
45186
  return false;
44601
45187
  }
44602
45188
  }
44603
- var _HERE23, REPO_ROOT10, OBLIGATION_LINE_RE, PATH_RE2, CMD_RE, CMD_HEADS, PIVOT_RE, WRITE_TOOLS, SHELL_TOOLS, SKILL_BODY_RE, PATH_FIELDS, COMMAND_FIELDS;
45189
+ var _HERE24, REPO_ROOT10, OBLIGATION_LINE_RE, PATH_RE2, CMD_RE, CMD_HEADS, PIVOT_RE, WRITE_TOOLS, SHELL_TOOLS, SKILL_BODY_RE, PATH_FIELDS, COMMAND_FIELDS;
44604
45190
  var init_report_skill_obligation_violations = __esm({
44605
45191
  "src/scripts/report_skill_obligation_violations.ts"() {
44606
45192
  "use strict";
44607
45193
  init_cc_transcript();
44608
45194
  init_transcript_entry();
44609
45195
  init_report_skill_activation();
44610
- _HERE23 = fileURLToPath47(import.meta.url);
44611
- REPO_ROOT10 = path90.resolve(path90.dirname(_HERE23), "..", "..");
45196
+ _HERE24 = fileURLToPath48(import.meta.url);
45197
+ REPO_ROOT10 = path92.resolve(path92.dirname(_HERE24), "..", "..");
44612
45198
  OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
44613
45199
  PATH_RE2 = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
44614
45200
  CMD_RE = /`([a-z][a-z0-9-]*(?: [a-z][a-z0-9:._-]*){1,3})`/g;
@@ -44642,31 +45228,31 @@ var init_report_skill_obligation_violations = __esm({
44642
45228
  SKILL_BODY_RE = /Base directory for this skill:\s*\S*?\/skills\/([A-Za-z0-9_-]+)/;
44643
45229
  PATH_FIELDS = ["file_path", "path", "filePath", "notebook_path", "target_file"];
44644
45230
  COMMAND_FIELDS = ["command", "cmd"];
44645
- if (_isCliEntry26()) {
44646
- process21.exit(main35());
45231
+ if (_isCliEntry27()) {
45232
+ process21.exit(main36());
44647
45233
  }
44648
45234
  }
44649
45235
  });
44650
45236
 
44651
45237
  // src/scripts/report_conformance_funnel.ts
44652
- import * as fs90 from "node:fs";
45238
+ import * as fs92 from "node:fs";
44653
45239
  import * as os21 from "node:os";
44654
- import * as path91 from "node:path";
45240
+ import * as path93 from "node:path";
44655
45241
  import process22 from "node:process";
44656
- import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL33 } from "node:url";
45242
+ import { fileURLToPath as fileURLToPath49, pathToFileURL as pathToFileURL34 } from "node:url";
44657
45243
  function buildFunnel(opts = {}) {
44658
45244
  const repoRoot = opts.repoRoot ?? REPO_ROOT11;
44659
- const projectRulesDir = opts.projectRulesDir ?? path91.join(repoRoot, PROJECT_RULES);
44660
- const globalRulesDir = opts.globalRulesDir ?? path91.join(os21.homedir(), GLOBAL_RULES);
44661
- const sourceDir = opts.sourceDir ?? path91.join(repoRoot, PROJECTION_SOURCE);
45245
+ const projectRulesDir = opts.projectRulesDir ?? path93.join(repoRoot, PROJECT_RULES);
45246
+ const globalRulesDir = opts.globalRulesDir ?? path93.join(os21.homedir(), GLOBAL_RULES);
45247
+ const sourceDir = opts.sourceDir ?? path93.join(repoRoot, PROJECTION_SOURCE);
44662
45248
  const store = opts.store ?? defaultStore(repoRoot);
44663
45249
  const limit = opts.limit ?? 30;
44664
45250
  return {
44665
45251
  delivered: measureDelivered(projectRulesDir, globalRulesDir),
44666
45252
  divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
44667
- skills: censusSkills(path91.join(repoRoot, SKILLS_ROOT)),
45253
+ skills: censusSkills(path93.join(repoRoot, SKILLS_ROOT)),
44668
45254
  usage: measureUsage(store, limit),
44669
- storePresent: fs90.existsSync(store),
45255
+ storePresent: fs92.existsSync(store),
44670
45256
  sk2: scanStore2(repoRoot, store, limit)
44671
45257
  };
44672
45258
  }
@@ -44791,7 +45377,7 @@ function render7(r) {
44791
45377
  lines.push("workflow without a measured false-positive rate first (locked policy).");
44792
45378
  return lines.join("\n");
44793
45379
  }
44794
- function main36(argv) {
45380
+ function main37(argv) {
44795
45381
  const args = argv ?? process22.argv.slice(2);
44796
45382
  const opts = {};
44797
45383
  const value = (i) => {
@@ -44807,7 +45393,7 @@ function main36(argv) {
44807
45393
  `);
44808
45394
  return 1;
44809
45395
  }
44810
- const resolved = path91.resolve(v);
45396
+ const resolved = path93.resolve(v);
44811
45397
  if (a === "--store") opts.store = resolved;
44812
45398
  else if (a === "--project") opts.projectRulesDir = resolved;
44813
45399
  else if (a === "--global") opts.globalRulesDir = resolved;
@@ -44837,16 +45423,16 @@ function main36(argv) {
44837
45423
  `);
44838
45424
  return 0;
44839
45425
  }
44840
- function _isCliEntry27() {
45426
+ function _isCliEntry28() {
44841
45427
  if (process22.argv[1] === void 0) return false;
44842
- if (import.meta.url === pathToFileURL33(path91.resolve(process22.argv[1])).href) return true;
45428
+ if (import.meta.url === pathToFileURL34(path93.resolve(process22.argv[1])).href) return true;
44843
45429
  try {
44844
- return fs90.realpathSync(_HERE24) === fs90.realpathSync(path91.resolve(process22.argv[1]));
45430
+ return fs92.realpathSync(_HERE25) === fs92.realpathSync(path93.resolve(process22.argv[1]));
44845
45431
  } catch {
44846
45432
  return false;
44847
45433
  }
44848
45434
  }
44849
- var _HERE24, REPO_ROOT11;
45435
+ var _HERE25, REPO_ROOT11;
44850
45436
  var init_report_conformance_funnel = __esm({
44851
45437
  "src/scripts/report_conformance_funnel.ts"() {
44852
45438
  "use strict";
@@ -44854,10 +45440,10 @@ var init_report_conformance_funnel = __esm({
44854
45440
  init_report_carrier_divergence();
44855
45441
  init_report_skill_activation();
44856
45442
  init_report_skill_obligation_violations();
44857
- _HERE24 = fileURLToPath48(import.meta.url);
44858
- REPO_ROOT11 = path91.resolve(path91.dirname(_HERE24), "..", "..");
44859
- if (_isCliEntry27()) {
44860
- process22.exit(main36());
45443
+ _HERE25 = fileURLToPath49(import.meta.url);
45444
+ REPO_ROOT11 = path93.resolve(path93.dirname(_HERE25), "..", "..");
45445
+ if (_isCliEntry28()) {
45446
+ process22.exit(main37());
44861
45447
  }
44862
45448
  }
44863
45449
  });
@@ -44878,16 +45464,16 @@ __export(cmd_conformance_exports, {
44878
45464
  conformanceLogPath: () => conformanceLogPath,
44879
45465
  detectSmokePlatform: () => detectSmokePlatform,
44880
45466
  installLogPath: () => installLogPath,
44881
- main: () => main37,
45467
+ main: () => main38,
44882
45468
  routeTargetPaths: () => routeTargetPaths,
44883
45469
  runConformanceChecks: () => runConformanceChecks
44884
45470
  });
44885
- import * as fs91 from "node:fs";
45471
+ import * as fs93 from "node:fs";
44886
45472
  import * as os22 from "node:os";
44887
- import * as path92 from "node:path";
45473
+ import * as path94 from "node:path";
44888
45474
  import process23 from "node:process";
44889
- import { spawnSync as spawnSync14 } from "node:child_process";
44890
- import { fileURLToPath as fileURLToPath49, pathToFileURL as pathToFileURL34 } from "node:url";
45475
+ import { spawnSync as spawnSync15 } from "node:child_process";
45476
+ import { fileURLToPath as fileURLToPath50, pathToFileURL as pathToFileURL35 } from "node:url";
44891
45477
  function print3(s = "") {
44892
45478
  process23.stdout.write(`${s}
44893
45479
  `);
@@ -44901,17 +45487,17 @@ function conformanceLogPath() {
44901
45487
  if (override && override.trim().length > 0) {
44902
45488
  return override;
44903
45489
  }
44904
- return path92.join(os22.homedir(), ".event4u", "agent-config", "conformance-log.jsonl");
45490
+ return path94.join(os22.homedir(), ".event4u", "agent-config", "conformance-log.jsonl");
44905
45491
  }
44906
45492
  function installLogPath() {
44907
45493
  const override = process23.env["AGENT_CONFIG_INSTALL_LOG"];
44908
45494
  if (override && override.trim().length > 0) {
44909
45495
  return override;
44910
45496
  }
44911
- return path92.join(os22.homedir(), ".event4u", "agent-config", "install-log.jsonl");
45497
+ return path94.join(os22.homedir(), ".event4u", "agent-config", "install-log.jsonl");
44912
45498
  }
44913
45499
  function _check_txlog_clean(logPath = installLogPath()) {
44914
- if (!fs91.existsSync(logPath)) {
45500
+ if (!fs93.existsSync(logPath)) {
44915
45501
  return {
44916
45502
  id: "txlog-clean",
44917
45503
  status: "ok",
@@ -44945,11 +45531,11 @@ function _check_txlog_clean(logPath = installLogPath()) {
44945
45531
  };
44946
45532
  }
44947
45533
  function routeTargetPaths(target) {
44948
- return routeTargetPathsPosix(target).map((rel) => path92.join(...rel.split("/")));
45534
+ return routeTargetPathsPosix(target).map((rel) => path94.join(...rel.split("/")));
44949
45535
  }
44950
45536
  function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
44951
- const routerPath = path92.join(packageRoot, "dist", "router.json");
44952
- if (!fs91.existsSync(routerPath)) {
45537
+ const routerPath = path94.join(packageRoot, "dist", "router.json");
45538
+ if (!fs93.existsSync(routerPath)) {
44953
45539
  return {
44954
45540
  id: "router-pointers",
44955
45541
  status: "fail",
@@ -44959,7 +45545,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
44959
45545
  }
44960
45546
  let router;
44961
45547
  try {
44962
- router = JSON.parse(fs91.readFileSync(routerPath, "utf8"));
45548
+ router = JSON.parse(fs93.readFileSync(routerPath, "utf8"));
44963
45549
  } catch (exc) {
44964
45550
  return {
44965
45551
  id: "router-pointers",
@@ -44968,13 +45554,13 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
44968
45554
  remedy: "reinstall the package \u2014 dist/router.json is corrupt"
44969
45555
  };
44970
45556
  }
44971
- const rulesDir = path92.join(packageRoot, "dist", "agent-src", "rules");
45557
+ const rulesDir = path94.join(packageRoot, "dist", "agent-src", "rules");
44972
45558
  const broken = [];
44973
45559
  let ids = 0;
44974
45560
  let targets = 0;
44975
45561
  for (const kernelId of router["kernel"] ?? []) {
44976
45562
  ids += 1;
44977
- if (!fs91.existsSync(path92.join(rulesDir, `${kernelId}.md`))) {
45563
+ if (!fs93.existsSync(path94.join(rulesDir, `${kernelId}.md`))) {
44978
45564
  broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
44979
45565
  }
44980
45566
  }
@@ -44982,7 +45568,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
44982
45568
  for (const entry of router[tier] ?? []) {
44983
45569
  const ruleId = String(entry["id"] ?? "");
44984
45570
  ids += 1;
44985
- if (!fs91.existsSync(path92.join(rulesDir, `${ruleId}.md`))) {
45571
+ if (!fs93.existsSync(path94.join(rulesDir, `${ruleId}.md`))) {
44986
45572
  broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
44987
45573
  }
44988
45574
  for (const target of entry["routes_to"] ?? []) {
@@ -44992,7 +45578,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
44992
45578
  broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
44993
45579
  continue;
44994
45580
  }
44995
- if (!candidates.some((rel) => fs91.existsSync(path92.join(packageRoot, rel)))) {
45581
+ if (!candidates.some((rel) => fs93.existsSync(path94.join(packageRoot, rel)))) {
44996
45582
  broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
44997
45583
  }
44998
45584
  }
@@ -45024,9 +45610,9 @@ function detectSmokePlatform(projectRoot) {
45024
45610
  return "claude";
45025
45611
  }
45026
45612
  function dispatcherRunner(packageRoot) {
45027
- const localTsx = path92.join(packageRoot, "node_modules", ".bin", "tsx");
45028
- const script = path92.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
45029
- if (fs91.existsSync(localTsx)) {
45613
+ const localTsx = path94.join(packageRoot, "node_modules", ".bin", "tsx");
45614
+ const script = path94.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
45615
+ if (fs93.existsSync(localTsx)) {
45030
45616
  return [localTsx, script];
45031
45617
  }
45032
45618
  return ["npx", "tsx", script];
@@ -45043,7 +45629,7 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT2, opts =
45043
45629
  ...event === "stop" ? { stop_reason: "conformance-smoke" } : { source: "startup" }
45044
45630
  });
45045
45631
  const argv = [...runner, "--platform", platform, "--event", event];
45046
- const proc = spawnSync14(argv[0], argv.slice(1), {
45632
+ const proc = spawnSync15(argv[0], argv.slice(1), {
45047
45633
  input: payload,
45048
45634
  cwd: projectRoot,
45049
45635
  encoding: "utf8",
@@ -45076,12 +45662,12 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT2, opts =
45076
45662
  };
45077
45663
  }
45078
45664
  function readSettingsMode(projectRoot) {
45079
- const settingsPath = path92.join(projectRoot, ".agent-settings.yml");
45080
- if (!fs91.existsSync(settingsPath)) {
45665
+ const settingsPath = path94.join(projectRoot, ".agent-settings.yml");
45666
+ if (!fs93.existsSync(settingsPath)) {
45081
45667
  return "eager-all";
45082
45668
  }
45083
45669
  try {
45084
- const parsed = YAML7.parse(fs91.readFileSync(settingsPath, "utf8"));
45670
+ const parsed = YAML7.parse(fs93.readFileSync(settingsPath, "utf8"));
45085
45671
  const lean = parsed?.["lean_projection"] ?? null;
45086
45672
  const mode = lean?.["mode"];
45087
45673
  return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
@@ -45092,7 +45678,7 @@ function readSettingsMode(projectRoot) {
45092
45678
  function kernelIdsFromRouter(packageRoot) {
45093
45679
  try {
45094
45680
  const router = JSON.parse(
45095
- fs91.readFileSync(path92.join(packageRoot, "dist", "router.json"), "utf8")
45681
+ fs93.readFileSync(path94.join(packageRoot, "dist", "router.json"), "utf8")
45096
45682
  );
45097
45683
  return new Set((router["kernel"] ?? []).map(String));
45098
45684
  } catch {
@@ -45109,8 +45695,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
45109
45695
  remedy: "set lean_projection.mode to 'eager-all' or 'thin' in .agent-settings.yml"
45110
45696
  };
45111
45697
  }
45112
- const rulesDir = projectedRulesDir ?? path92.join(projectRoot, ".augment", "rules");
45113
- if (!fs91.existsSync(rulesDir)) {
45698
+ const rulesDir = projectedRulesDir ?? path94.join(projectRoot, ".augment", "rules");
45699
+ if (!fs93.existsSync(rulesDir)) {
45114
45700
  return {
45115
45701
  id: "lean-projection",
45116
45702
  status: "skipped",
@@ -45119,7 +45705,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
45119
45705
  };
45120
45706
  }
45121
45707
  const kernel = kernelIdsFromRouter(packageRoot);
45122
- const files = fs91.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
45708
+ const files = fs93.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
45123
45709
  const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
45124
45710
  if (nonKernel.length === 0) {
45125
45711
  return {
@@ -45133,7 +45719,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
45133
45719
  for (const f of nonKernel) {
45134
45720
  let text = "";
45135
45721
  try {
45136
- text = fs91.readFileSync(path92.join(rulesDir, f), "utf8");
45722
+ text = fs93.readFileSync(path94.join(rulesDir, f), "utf8");
45137
45723
  } catch {
45138
45724
  continue;
45139
45725
  }
@@ -45164,8 +45750,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
45164
45750
  function _check_host_manifest(projectRoot) {
45165
45751
  const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
45166
45752
  const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
45167
- const settingsPath = path92.join(projectRoot, ".agent-settings.yml");
45168
- if (!fs91.existsSync(settingsPath)) {
45753
+ const settingsPath = path94.join(projectRoot, ".agent-settings.yml");
45754
+ if (!fs93.existsSync(settingsPath)) {
45169
45755
  return {
45170
45756
  id: "host-manifest",
45171
45757
  status: "ok",
@@ -45175,7 +45761,7 @@ function _check_host_manifest(projectRoot) {
45175
45761
  }
45176
45762
  let parsed = null;
45177
45763
  try {
45178
- parsed = YAML7.parse(fs91.readFileSync(settingsPath, "utf8"));
45764
+ parsed = YAML7.parse(fs93.readFileSync(settingsPath, "utf8"));
45179
45765
  } catch (exc) {
45180
45766
  return {
45181
45767
  id: "host-manifest",
@@ -45242,7 +45828,7 @@ function _parse4(argv) {
45242
45828
  while (i < argv.length) {
45243
45829
  const a = argv[i];
45244
45830
  if (a === "-h" || a === "--help") {
45245
- process23.stdout.write(USAGE4);
45831
+ process23.stdout.write(USAGE5);
45246
45832
  throw new ArgparseExit4(0);
45247
45833
  }
45248
45834
  if (a === "--json") {
@@ -45256,7 +45842,7 @@ function _parse4(argv) {
45256
45842
  opts.project = a.slice(a.indexOf("=") + 1);
45257
45843
  } else {
45258
45844
  if (i + 1 >= argv.length) {
45259
- process23.stderr.write(USAGE4);
45845
+ process23.stderr.write(USAGE5);
45260
45846
  process23.stderr.write("agent-config conformance: error: --project expects a value\n");
45261
45847
  throw new ArgparseExit4(2);
45262
45848
  }
@@ -45264,7 +45850,7 @@ function _parse4(argv) {
45264
45850
  i += 1;
45265
45851
  }
45266
45852
  } else {
45267
- process23.stderr.write(USAGE4);
45853
+ process23.stderr.write(USAGE5);
45268
45854
  process23.stderr.write(`agent-config conformance: error: unrecognized argument ${a}
45269
45855
  `);
45270
45856
  throw new ArgparseExit4(2);
@@ -45273,7 +45859,7 @@ function _parse4(argv) {
45273
45859
  }
45274
45860
  return opts;
45275
45861
  }
45276
- function main37(argv = null) {
45862
+ function main38(argv = null) {
45277
45863
  const opts = _parse4(argv !== null ? Array.from(argv) : process23.argv.slice(2));
45278
45864
  if (opts.funnel) {
45279
45865
  print3(render7(buildFunnel()));
@@ -45344,23 +45930,23 @@ function main37(argv = null) {
45344
45930
  }
45345
45931
  return failed ? 1 : 0;
45346
45932
  }
45347
- function _isCliEntry28() {
45933
+ function _isCliEntry29() {
45348
45934
  if (process23.argv[1] === void 0) {
45349
45935
  return false;
45350
45936
  }
45351
- const argvUrl = pathToFileURL34(path92.resolve(process23.argv[1])).href;
45937
+ const argvUrl = pathToFileURL35(path94.resolve(process23.argv[1])).href;
45352
45938
  if (import.meta.url === argvUrl) {
45353
45939
  return true;
45354
45940
  }
45355
45941
  try {
45356
- const here = fs91.realpathSync(fileURLToPath49(import.meta.url));
45357
- const argv = fs91.realpathSync(path92.resolve(process23.argv[1]));
45942
+ const here = fs93.realpathSync(fileURLToPath50(import.meta.url));
45943
+ const argv = fs93.realpathSync(path94.resolve(process23.argv[1]));
45358
45944
  return here === argv;
45359
45945
  } catch {
45360
45946
  return false;
45361
45947
  }
45362
45948
  }
45363
- var YAML7, _HERE25, PACKAGE_ROOT2, CONFORMANCE_CHECK_IDS, THIN_STUB_MARKER, USAGE4;
45949
+ var YAML7, _HERE26, PACKAGE_ROOT2, CONFORMANCE_CHECK_IDS, THIN_STUB_MARKER, USAGE5;
45364
45950
  var init_cmd_conformance = __esm({
45365
45951
  "src/scripts/_cli/cmd_conformance.ts"() {
45366
45952
  "use strict";
@@ -45373,7 +45959,7 @@ var init_cmd_conformance = __esm({
45373
45959
  init_router_target_paths();
45374
45960
  init_report_conformance_funnel();
45375
45961
  init_cmd_doctor();
45376
- _HERE25 = fileURLToPath49(import.meta.url);
45962
+ _HERE26 = fileURLToPath50(import.meta.url);
45377
45963
  PACKAGE_ROOT2 = resolvePackageRoot(import.meta.url);
45378
45964
  CONFORMANCE_CHECK_IDS = [
45379
45965
  "txlog-clean",
@@ -45383,10 +45969,10 @@ var init_cmd_conformance = __esm({
45383
45969
  "host-manifest"
45384
45970
  ];
45385
45971
  THIN_STUB_MARKER = "Routed rule \u2014 load the body on trigger-match";
45386
- USAGE4 = "usage: agent-config conformance [-h] [--project PROJECT] [--json]\n [--skip-dispatcher] [--funnel]\n";
45387
- if (_isCliEntry28() || process23.argv[1] === _HERE25) {
45972
+ USAGE5 = "usage: agent-config conformance [-h] [--project PROJECT] [--json]\n [--skip-dispatcher] [--funnel]\n";
45973
+ if (_isCliEntry29() || process23.argv[1] === _HERE26) {
45388
45974
  try {
45389
- process23.exitCode = main37(process23.argv.slice(2));
45975
+ process23.exitCode = main38(process23.argv.slice(2));
45390
45976
  } catch (e) {
45391
45977
  if (e instanceof ArgparseExit4) {
45392
45978
  process23.exitCode = e.code;
@@ -45421,7 +46007,7 @@ __export(settings_exports, {
45421
46007
  read_tier_usage_settings: () => read_tier_usage_settings
45422
46008
  });
45423
46009
  import { createRequire as createRequire7 } from "node:module";
45424
- import * as fs92 from "node:fs";
46010
+ import * as fs94 from "node:fs";
45425
46011
  function _isPlainObject8(v) {
45426
46012
  return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
45427
46013
  }
@@ -45458,7 +46044,7 @@ function _coerce_path(value, def) {
45458
46044
  }
45459
46045
  function _isFile15(p) {
45460
46046
  try {
45461
- return fs92.statSync(p).isFile();
46047
+ return fs94.statSync(p).isFile();
45462
46048
  } catch {
45463
46049
  return false;
45464
46050
  }
@@ -45469,7 +46055,7 @@ function _read_telemetry_section(p, key) {
45469
46055
  }
45470
46056
  let raw = {};
45471
46057
  try {
45472
- raw = YAML8.parse(fs92.readFileSync(p, "utf-8"), { version: "1.1" });
46058
+ raw = YAML8.parse(fs94.readFileSync(p, "utf-8"), { version: "1.1" });
45473
46059
  if (raw === null || raw === void 0) {
45474
46060
  raw = {};
45475
46061
  }
@@ -46113,7 +46699,7 @@ __export(aggregator_exports, {
46113
46699
  aggregate: () => aggregate2,
46114
46700
  rank_artefacts: () => rank_artefacts
46115
46701
  });
46116
- import * as fs93 from "node:fs";
46702
+ import * as fs95 from "node:fs";
46117
46703
  function _key(kind, artId) {
46118
46704
  return `${kind}\0${artId}`;
46119
46705
  }
@@ -46150,7 +46736,7 @@ function* _iter_events(log_path) {
46150
46736
  if (!_isFile16(log_path)) {
46151
46737
  return;
46152
46738
  }
46153
- const text = fs93.readFileSync(log_path, "utf-8");
46739
+ const text = fs95.readFileSync(log_path, "utf-8");
46154
46740
  const lines = _pyFileLines(text);
46155
46741
  let lineNo = 0;
46156
46742
  for (const line of lines) {
@@ -46184,7 +46770,7 @@ function _pyFileLines(text) {
46184
46770
  }
46185
46771
  function _isFile16(p) {
46186
46772
  try {
46187
- return fs93.statSync(p).isFile();
46773
+ return fs95.statSync(p).isFile();
46188
46774
  } catch {
46189
46775
  return false;
46190
46776
  }
@@ -46772,14 +47358,14 @@ var init_report_renderer = __esm({
46772
47358
  });
46773
47359
 
46774
47360
  // src/scripts/ai_council/bundler.ts
46775
- import * as fs94 from "node:fs";
47361
+ import * as fs96 from "node:fs";
46776
47362
  function _context(mode, text, manifest = [], excluded = []) {
46777
47363
  return { mode, text, manifest, excluded };
46778
47364
  }
46779
47365
  function _utf8Len(s) {
46780
47366
  return Buffer.byteLength(s, "utf-8");
46781
47367
  }
46782
- function _splitlines8(s) {
47368
+ function _splitlines9(s) {
46783
47369
  if (s === "") {
46784
47370
  return [];
46785
47371
  }
@@ -46791,7 +47377,7 @@ function _splitlines8(s) {
46791
47377
  }
46792
47378
  function redact(text) {
46793
47379
  const out = [];
46794
- for (const line of _splitlines8(text)) {
47380
+ for (const line of _splitlines9(text)) {
46795
47381
  let replaced = line;
46796
47382
  for (const [pattern, placeholder] of _REDACTION_LINE_PATTERNS) {
46797
47383
  if (pattern.test(replaced)) {
@@ -46830,10 +47416,10 @@ function bundle_prompt(text) {
46830
47416
  return _context("prompt", _enforceSize(redacted, "prompt"), ["<inline prompt>"]);
46831
47417
  }
46832
47418
  function bundle_roadmap(p) {
46833
- if (!fs94.existsSync(p)) {
47419
+ if (!fs96.existsSync(p)) {
46834
47420
  throw new FileNotFoundError2(`Roadmap not found: ${p}`);
46835
47421
  }
46836
- const raw = fs94.readFileSync(p, { encoding: "utf-8" });
47422
+ const raw = fs96.readFileSync(p, { encoding: "utf-8" });
46837
47423
  const redacted = redact(raw);
46838
47424
  return _context(
46839
47425
  "roadmap",
@@ -47011,8 +47597,8 @@ function aggregate_scores(findings, scores) {
47011
47597
  by_id.get(s.finding_id).push(s);
47012
47598
  }
47013
47599
  const out = /* @__PURE__ */ new Map();
47014
- for (const [fid, fs106] of by_id) {
47015
- if (fs106.length === 0) {
47600
+ for (const [fid, fs108] of by_id) {
47601
+ if (fs108.length === 0) {
47016
47602
  out.set(
47017
47603
  fid,
47018
47604
  new ConsensusMetadata({
@@ -47028,13 +47614,13 @@ function aggregate_scores(findings, scores) {
47028
47614
  );
47029
47615
  continue;
47030
47616
  }
47031
- const mean2 = fs106.reduce((acc, s) => acc + s.score, 0) / fs106.length;
47032
- const agree_rate = fs106.filter((s) => s.agree).length / fs106.length;
47617
+ const mean2 = fs108.reduce((acc, s) => acc + s.score, 0) / fs108.length;
47618
+ const agree_rate = fs108.filter((s) => s.agree).length / fs108.length;
47033
47619
  const strength = mean2 / 10 * agree_rate;
47034
- const dissent = fs106.filter((s) => !s.agree).length;
47035
- const concur = fs106.filter((s) => s.agree).length;
47036
- const scorers = fs106.map((s) => s.scorer);
47037
- const dissent_reasons = fs106.filter((s) => !s.agree).map((s) => [s.scorer, s.reason]);
47620
+ const dissent = fs108.filter((s) => !s.agree).length;
47621
+ const concur = fs108.filter((s) => s.agree).length;
47622
+ const scorers = fs108.map((s) => s.scorer);
47623
+ const dissent_reasons = fs108.filter((s) => !s.agree).map((s) => [s.scorer, s.reason]);
47038
47624
  const mean_rounded = pyRound(mean2, 2);
47039
47625
  out.set(
47040
47626
  fid,
@@ -47474,26 +48060,26 @@ One sentence, and the single strongest reason.`;
47474
48060
  });
47475
48061
 
47476
48062
  // src/scripts/ai_council/recouncil_guard.ts
47477
- import * as fs95 from "node:fs";
47478
- import * as path93 from "node:path";
48063
+ import * as fs97 from "node:fs";
48064
+ import * as path95 from "node:path";
47479
48065
  function configFingerprint(members, rounds) {
47480
48066
  return `${[...members].sort().join(",")}|rounds=${String(rounds)}`;
47481
48067
  }
47482
48068
  function readPriorRuns(responsesDir, repoRoot) {
47483
48069
  let names;
47484
48070
  try {
47485
- names = fs95.readdirSync(responsesDir).filter((f) => f.endsWith(".md"));
48071
+ names = fs97.readdirSync(responsesDir).filter((f) => f.endsWith(".md"));
47486
48072
  } catch {
47487
48073
  return [];
47488
48074
  }
47489
48075
  const out = [];
47490
48076
  for (const name of names) {
47491
- const abs = path93.join(responsesDir, name);
48077
+ const abs = path95.join(responsesDir, name);
47492
48078
  let head;
47493
48079
  let stat;
47494
48080
  try {
47495
- stat = fs95.statSync(abs);
47496
- const text = fs95.readFileSync(abs, "utf8");
48081
+ stat = fs97.statSync(abs);
48082
+ const text = fs97.readFileSync(abs, "utf8");
47497
48083
  const json = _leadingJson(text);
47498
48084
  if (json === null) continue;
47499
48085
  head = JSON.parse(json);
@@ -47507,7 +48093,7 @@ function readPriorRuns(responsesDir, repoRoot) {
47507
48093
  let questionText = null;
47508
48094
  if (questionPath !== "") {
47509
48095
  try {
47510
- const q = fs95.readFileSync(path93.join(repoRoot, questionPath), "utf8");
48096
+ const q = fs97.readFileSync(path95.join(repoRoot, questionPath), "utf8");
47511
48097
  questionHash = _sha256_hex(q);
47512
48098
  questionText = q;
47513
48099
  } catch {
@@ -47588,14 +48174,14 @@ function warnIfRecounciled(repoRoot, questionFile, fallbackText, members, rounds
47588
48174
  try {
47589
48175
  let text = fallbackText;
47590
48176
  try {
47591
- text = fs95.readFileSync(path93.resolve(repoRoot, questionFile), "utf8");
48177
+ text = fs97.readFileSync(path95.resolve(repoRoot, questionFile), "utf8");
47592
48178
  } catch {
47593
48179
  }
47594
48180
  const v = checkRecouncil(
47595
48181
  text,
47596
48182
  // `name/model` — the SAME shape the artefact writer records.
47597
48183
  configFingerprint(members.map((m) => `${m.name}/${m.model}`), rounds),
47598
- readPriorRuns(path93.join(repoRoot, "agents/runtime/council/responses"), repoRoot)
48184
+ readPriorRuns(path95.join(repoRoot, "agents/runtime/council/responses"), repoRoot)
47599
48185
  );
47600
48186
  if (v !== null) write(renderRecouncilWarning(v));
47601
48187
  } catch {
@@ -47707,7 +48293,7 @@ function _pyReprStr2(s) {
47707
48293
  function _pyRepr9(value) {
47708
48294
  return value === null ? "None" : _pyReprStr2(value);
47709
48295
  }
47710
- function _splitlines9(text) {
48296
+ function _splitlines10(text) {
47711
48297
  if (text === "") {
47712
48298
  return [];
47713
48299
  }
@@ -47787,7 +48373,7 @@ function _strip_host_identity(text) {
47787
48373
  return text;
47788
48374
  }
47789
48375
  const kept = [];
47790
- for (const line of _splitlines9(text)) {
48376
+ for (const line of _splitlines10(text)) {
47791
48377
  const low = line.toLowerCase();
47792
48378
  if (HOST_AGENT_IDENTITY_PATTERNS.some((needle) => low.includes(needle))) {
47793
48379
  continue;
@@ -47816,7 +48402,7 @@ function handoff_preamble(project, original_ask) {
47816
48402
  }
47817
48403
  const cleaned_ask = _pyStrip3(_strip_host_identity(original_ask || ""));
47818
48404
  if (cleaned_ask) {
47819
- const quoted = _splitlines9(cleaned_ask).map((ln) => `> ${ln}`).join("\n");
48405
+ const quoted = _splitlines10(cleaned_ask).map((ln) => `> ${ln}`).join("\n");
47820
48406
  blocks.push(`The user originally asked:
47821
48407
  ${quoted}`);
47822
48408
  }
@@ -48224,8 +48810,8 @@ not. Cite the peer-reviewer label and the targeted response label
48224
48810
  });
48225
48811
 
48226
48812
  // src/scripts/ai_council/advisors.ts
48227
- import * as fs96 from "node:fs";
48228
- import * as path94 from "node:path";
48813
+ import * as fs98 from "node:fs";
48814
+ import * as path96 from "node:path";
48229
48815
  function _split_frontmatter2(raw) {
48230
48816
  const match = _FRONTMATTER_RE2.exec(raw);
48231
48817
  if (!match) {
@@ -48253,12 +48839,12 @@ function _display_name_from(advisor_name, frontmatter) {
48253
48839
  }
48254
48840
  function resolve_persona_text(persona_path, repo_root2) {
48255
48841
  const candidates = [
48256
- path94.join(repo_root2, "dist/agent-src", persona_path),
48257
- path94.join(repo_root2, ".agent-src.uncondensed", persona_path)
48842
+ path96.join(repo_root2, "dist/agent-src", persona_path),
48843
+ path96.join(repo_root2, ".agent-src.uncondensed", persona_path)
48258
48844
  ];
48259
48845
  for (const candidate of candidates) {
48260
- if (fs96.existsSync(candidate)) {
48261
- const raw = fs96.readFileSync(candidate, "utf-8");
48846
+ if (fs98.existsSync(candidate)) {
48847
+ const raw = fs98.readFileSync(candidate, "utf-8");
48262
48848
  const [meta, body] = _split_frontmatter2(raw);
48263
48849
  return [body.trim(), meta];
48264
48850
  }
@@ -49066,15 +49652,15 @@ var init_qualification = __esm({
49066
49652
  });
49067
49653
 
49068
49654
  // src/scripts/ai_council/probe_store.ts
49069
- import fs97 from "node:fs";
49070
- import path95 from "node:path";
49655
+ import fs99 from "node:fs";
49656
+ import path97 from "node:path";
49071
49657
  function probeStorePath(root) {
49072
- return path95.join(root, PROBE_STORE_RELPATH);
49658
+ return path97.join(root, PROBE_STORE_RELPATH);
49073
49659
  }
49074
49660
  function readProbeStore(root) {
49075
49661
  let raw;
49076
49662
  try {
49077
- raw = fs97.readFileSync(probeStorePath(root), "utf8");
49663
+ raw = fs99.readFileSync(probeStorePath(root), "utf8");
49078
49664
  } catch {
49079
49665
  return EMPTY;
49080
49666
  }
@@ -49124,8 +49710,8 @@ function recordProbes(root, entries) {
49124
49710
  members[e.name] = { at: e.at, outcome: e.outcome };
49125
49711
  }
49126
49712
  const target = probeStorePath(root);
49127
- fs97.mkdirSync(path95.dirname(target), { recursive: true });
49128
- fs97.writeFileSync(target, `${JSON.stringify({ schema: 1, members }, null, 2)}
49713
+ fs99.mkdirSync(path97.dirname(target), { recursive: true });
49714
+ fs99.writeFileSync(target, `${JSON.stringify({ schema: 1, members }, null, 2)}
49129
49715
  `, "utf8");
49130
49716
  } catch {
49131
49717
  }
@@ -49139,7 +49725,7 @@ var init_probe_store = __esm({
49139
49725
  "use strict";
49140
49726
  init_env_kill_switch();
49141
49727
  _KILL_SWITCH_ENV2 = "AGENT_CONFIG_NO_EVENTS_LOG";
49142
- PROBE_STORE_RELPATH = path95.join("agents", "runtime", "state", "council-probes.json");
49728
+ PROBE_STORE_RELPATH = path97.join("agents", "runtime", "state", "council-probes.json");
49143
49729
  EMPTY = { schema: 1, members: {} };
49144
49730
  VALID_OUTCOMES = /* @__PURE__ */ new Set([
49145
49731
  "ok",
@@ -49443,10 +50029,10 @@ var init_council_fallback_posture = __esm({
49443
50029
  });
49444
50030
 
49445
50031
  // src/scripts/_lib/billing_grant.ts
49446
- import * as fs98 from "node:fs";
49447
- import * as path96 from "node:path";
50032
+ import * as fs100 from "node:fs";
50033
+ import * as path98 from "node:path";
49448
50034
  function grantFile(repoRoot, runId) {
49449
- return path96.join(
50035
+ return path98.join(
49450
50036
  repoRoot,
49451
50037
  BILLING_GRANT_DIR_REL,
49452
50038
  `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
@@ -49457,8 +50043,8 @@ function issueBillingGrant(repoRoot, runId, now = () => /* @__PURE__ */ new Date
49457
50043
  const existing = _read(file);
49458
50044
  if (existing !== null && existing.run_id === runId) return existing;
49459
50045
  const grant = { run_id: runId, issued_at: now().toISOString() };
49460
- fs98.mkdirSync(path96.dirname(file), { recursive: true });
49461
- fs98.writeFileSync(file, `${JSON.stringify(grant, null, 2)}
50046
+ fs100.mkdirSync(path98.dirname(file), { recursive: true });
50047
+ fs100.writeFileSync(file, `${JSON.stringify(grant, null, 2)}
49462
50048
  `, "utf8");
49463
50049
  return grant;
49464
50050
  }
@@ -49476,13 +50062,13 @@ function hasBillingGrant(repoRoot, env = process.env, now = () => /* @__PURE__ *
49476
50062
  }
49477
50063
  function revokeBillingGrant(repoRoot, runId) {
49478
50064
  try {
49479
- fs98.unlinkSync(grantFile(repoRoot, runId));
50065
+ fs100.unlinkSync(grantFile(repoRoot, runId));
49480
50066
  } catch {
49481
50067
  }
49482
50068
  }
49483
50069
  function _read(file) {
49484
50070
  try {
49485
- const raw = JSON.parse(fs98.readFileSync(file, "utf8"));
50071
+ const raw = JSON.parse(fs100.readFileSync(file, "utf8"));
49486
50072
  if (raw === null || typeof raw !== "object") return null;
49487
50073
  const o = raw;
49488
50074
  if (typeof o.run_id !== "string" || typeof o.issued_at !== "string") return null;
@@ -49503,7 +50089,7 @@ var init_billing_grant = __esm({
49503
50089
  "src/scripts/_lib/billing_grant.ts"() {
49504
50090
  "use strict";
49505
50091
  BILLING_GRANT_ENV = "AC_BILLING_GRANT";
49506
- BILLING_GRANT_DIR_REL = path96.join("agents", "runtime", "billing-grants");
50092
+ BILLING_GRANT_DIR_REL = path98.join("agents", "runtime", "billing-grants");
49507
50093
  BILLING_GRANT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
49508
50094
  }
49509
50095
  });
@@ -49592,10 +50178,10 @@ var init_council_fallback_wiring = __esm({
49592
50178
  });
49593
50179
 
49594
50180
  // src/scripts/_lib/quota_parked.ts
49595
- import * as fs99 from "node:fs";
49596
- import * as path97 from "node:path";
50181
+ import * as fs101 from "node:fs";
50182
+ import * as path99 from "node:path";
49597
50183
  function markerFile(repoRoot, runId) {
49598
- return path97.join(
50184
+ return path99.join(
49599
50185
  repoRoot,
49600
50186
  QUOTA_PARKED_DIR_REL,
49601
50187
  `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
@@ -49610,14 +50196,14 @@ function writeQuotaParked(repoRoot, runId, providers, now = () => /* @__PURE__ *
49610
50196
  providers: merged,
49611
50197
  parked_at: existing?.parked_at ?? now().toISOString()
49612
50198
  };
49613
- fs99.mkdirSync(path97.dirname(file), { recursive: true });
49614
- fs99.writeFileSync(file, `${JSON.stringify(marker, null, 2)}
50199
+ fs101.mkdirSync(path99.dirname(file), { recursive: true });
50200
+ fs101.writeFileSync(file, `${JSON.stringify(marker, null, 2)}
49615
50201
  `, "utf8");
49616
50202
  return marker;
49617
50203
  }
49618
50204
  function readMarker(file) {
49619
50205
  try {
49620
- const raw = JSON.parse(fs99.readFileSync(file, "utf8"));
50206
+ const raw = JSON.parse(fs101.readFileSync(file, "utf8"));
49621
50207
  if (raw === null || typeof raw !== "object") return null;
49622
50208
  const o = raw;
49623
50209
  if (typeof o["run_id"] !== "string" || typeof o["parked_at"] !== "string") return null;
@@ -49632,7 +50218,7 @@ var QUOTA_PARKED_DIR_REL;
49632
50218
  var init_quota_parked = __esm({
49633
50219
  "src/scripts/_lib/quota_parked.ts"() {
49634
50220
  "use strict";
49635
- QUOTA_PARKED_DIR_REL = path97.join("agents", "runtime", "state", "quota-parked");
50221
+ QUOTA_PARKED_DIR_REL = path99.join("agents", "runtime", "state", "quota-parked");
49636
50222
  }
49637
50223
  });
49638
50224
 
@@ -49702,7 +50288,7 @@ __export(low_impact_corpus_exports, {
49702
50288
  load_validated_phrases: () => load_validated_phrases,
49703
50289
  parse_corpus_strict: () => parse_corpus_strict
49704
50290
  });
49705
- import * as fs100 from "node:fs";
50291
+ import * as fs102 from "node:fs";
49706
50292
  function _entry(phrase, normalised, section, line_no, trailing_metadata = "") {
49707
50293
  return { phrase, normalised, section, line_no, trailing_metadata };
49708
50294
  }
@@ -49749,7 +50335,7 @@ function _lineNoAt(text, offset) {
49749
50335
  }
49750
50336
  return count + 1;
49751
50337
  }
49752
- function _splitlines10(s) {
50338
+ function _splitlines11(s) {
49753
50339
  if (s === "") {
49754
50340
  return [];
49755
50341
  }
@@ -49764,7 +50350,7 @@ function _scanSection(text, section, bodyStart, bodyEnd, strict) {
49764
50350
  const warnings = [];
49765
50351
  const body = text.slice(bodyStart, bodyEnd);
49766
50352
  const baseLine = _lineNoAt(text, bodyStart);
49767
- const bodyLines = _splitlines10(body);
50353
+ const bodyLines = _splitlines11(body);
49768
50354
  for (let offset = 0; offset < bodyLines.length; offset += 1) {
49769
50355
  const rawLine = bodyLines[offset];
49770
50356
  const lineNo = baseLine + offset;
@@ -49875,10 +50461,10 @@ function _checkHeadingDrift(text, title) {
49875
50461
  }
49876
50462
  function parse_corpus_strict(corpusPath) {
49877
50463
  const p = corpusPath;
49878
- if (!fs100.existsSync(p)) {
50464
+ if (!fs102.existsSync(p)) {
49879
50465
  return new CorpusParseResult();
49880
50466
  }
49881
- const text = fs100.readFileSync(p, { encoding: "utf-8" });
50467
+ const text = fs102.readFileSync(p, { encoding: "utf-8" });
49882
50468
  const allTitles = _SECTION_KEYS.map((k) => _SECTION_TITLES[k]);
49883
50469
  const resultSections = {
49884
50470
  validated: [],
@@ -49941,10 +50527,10 @@ function load_anti_example_phrases(corpusPath) {
49941
50527
  }
49942
50528
  function load_corpus_lock(yamlPath) {
49943
50529
  const p = yamlPath;
49944
- if (!fs100.existsSync(p)) {
50530
+ if (!fs102.existsSync(p)) {
49945
50531
  return new CorpusParseResult();
49946
50532
  }
49947
- const parsed = (0, import_yaml8.parse)(fs100.readFileSync(p, { encoding: "utf-8" }), { version: "1.1" });
50533
+ const parsed = (0, import_yaml8.parse)(fs102.readFileSync(p, { encoding: "utf-8" }), { version: "1.1" });
49948
50534
  const doc = parsed === null || parsed === void 0 ? {} : parsed;
49949
50535
  const schemaVersion = doc["schema_version"];
49950
50536
  if (schemaVersion !== 1) {
@@ -50006,7 +50592,7 @@ function _deriveLockPath(corpusPath) {
50006
50592
  }
50007
50593
  function _loadSectionFromLock(corpusPath, section) {
50008
50594
  const lockPath = _deriveLockPath(corpusPath);
50009
- if (!fs100.existsSync(lockPath)) {
50595
+ if (!fs102.existsSync(lockPath)) {
50010
50596
  return null;
50011
50597
  }
50012
50598
  try {
@@ -50018,10 +50604,10 @@ function _loadSectionFromLock(corpusPath, section) {
50018
50604
  }
50019
50605
  function _loadSectionLenient(corpusPath, section) {
50020
50606
  const p = corpusPath;
50021
- if (!fs100.existsSync(p)) {
50607
+ if (!fs102.existsSync(p)) {
50022
50608
  return [];
50023
50609
  }
50024
- const text = fs100.readFileSync(p, { encoding: "utf-8" });
50610
+ const text = fs102.readFileSync(p, { encoding: "utf-8" });
50025
50611
  const allTitles = _SECTION_KEYS.map((k) => _SECTION_TITLES[k]);
50026
50612
  const bounds = _sectionBounds(text, _SECTION_TITLES[section], allTitles);
50027
50613
  if (bounds === null) {
@@ -51149,8 +51735,8 @@ var init_consensus_round = __esm({
51149
51735
  });
51150
51736
 
51151
51737
  // src/scripts/ai_council/budget_guard.ts
51152
- import * as fs101 from "node:fs";
51153
- import * as path98 from "node:path";
51738
+ import * as fs103 from "node:fs";
51739
+ import * as path100 from "node:path";
51154
51740
  function _resolveLedgerPath(p) {
51155
51741
  if (p !== null) {
51156
51742
  return p;
@@ -51165,18 +51751,18 @@ function _nowUtcMs() {
51165
51751
  return Date.now();
51166
51752
  }
51167
51753
  function _ensureLedgerDir(p) {
51168
- const parent = path98.dirname(p);
51754
+ const parent = path100.dirname(p);
51169
51755
  try {
51170
- fs101.mkdirSync(parent, { recursive: true });
51756
+ fs103.mkdirSync(parent, { recursive: true });
51171
51757
  let mode;
51172
51758
  try {
51173
- mode = fs101.statSync(parent).mode & 511;
51759
+ mode = fs103.statSync(parent).mode & 511;
51174
51760
  } catch {
51175
51761
  mode = 448;
51176
51762
  }
51177
51763
  if (mode !== 448) {
51178
51764
  try {
51179
- fs101.chmodSync(parent, 448);
51765
+ fs103.chmodSync(parent, 448);
51180
51766
  } catch {
51181
51767
  }
51182
51768
  }
@@ -51188,18 +51774,18 @@ function _ensureLedgerDir(p) {
51188
51774
  }
51189
51775
  }
51190
51776
  function _ensureLedgerFileMode(p) {
51191
- if (!fs101.existsSync(p)) {
51777
+ if (!fs103.existsSync(p)) {
51192
51778
  return;
51193
51779
  }
51194
51780
  let current;
51195
51781
  try {
51196
- current = fs101.statSync(p).mode & 511;
51782
+ current = fs103.statSync(p).mode & 511;
51197
51783
  } catch {
51198
51784
  return;
51199
51785
  }
51200
51786
  if (current !== 384) {
51201
51787
  try {
51202
- fs101.chmodSync(p, 384);
51788
+ fs103.chmodSync(p, 384);
51203
51789
  } catch {
51204
51790
  }
51205
51791
  }
@@ -51351,11 +51937,11 @@ function pyNumToStr(n) {
51351
51937
  }
51352
51938
  function read_entries2(p = null) {
51353
51939
  const resolved = _resolveLedgerPath(p);
51354
- if (!fs101.existsSync(resolved)) {
51940
+ if (!fs103.existsSync(resolved)) {
51355
51941
  return [];
51356
51942
  }
51357
51943
  const out = [];
51358
- const text = fs101.readFileSync(resolved, "utf-8");
51944
+ const text = fs103.readFileSync(resolved, "utf-8");
51359
51945
  for (const rawLine of text.split(/\r\n|\r|\n/u)) {
51360
51946
  const line = rawLine.trim();
51361
51947
  if (line === "") {
@@ -51458,7 +52044,7 @@ function record_spend(usd, provider, model, options = {}) {
51458
52044
  )}
51459
52045
  `;
51460
52046
  try {
51461
- fs101.appendFileSync(p, entry, { encoding: "utf-8" });
52047
+ fs103.appendFileSync(p, entry, { encoding: "utf-8" });
51462
52048
  } catch (exc) {
51463
52049
  process.stderr.write(`[council:budget_guard] write failed: ${_errStr(exc)}
51464
52050
  `);
@@ -53119,18 +53705,18 @@ __export(project_context_exports, {
53119
53705
  REPO_PURPOSE_MAX_CHARS: () => REPO_PURPOSE_MAX_CHARS,
53120
53706
  detect_project_context: () => detect_project_context
53121
53707
  });
53122
- import * as fs102 from "node:fs";
53123
- import * as path99 from "node:path";
53708
+ import * as fs104 from "node:fs";
53709
+ import * as path101 from "node:path";
53124
53710
  function _isPlainObject11(v) {
53125
53711
  return typeof v === "object" && v !== null && !Array.isArray(v);
53126
53712
  }
53127
53713
  function _read_json(p) {
53128
- if (!fs102.existsSync(p)) {
53714
+ if (!fs104.existsSync(p)) {
53129
53715
  return null;
53130
53716
  }
53131
53717
  let raw;
53132
53718
  try {
53133
- raw = fs102.readFileSync(p, "utf-8");
53719
+ raw = fs104.readFileSync(p, "utf-8");
53134
53720
  } catch {
53135
53721
  return null;
53136
53722
  }
@@ -53152,7 +53738,7 @@ function _name_from(composer, pkg, root) {
53152
53738
  }
53153
53739
  }
53154
53740
  try {
53155
- const base = path99.basename(root);
53741
+ const base = path101.basename(root);
53156
53742
  return base || null;
53157
53743
  } catch {
53158
53744
  return null;
@@ -53210,7 +53796,7 @@ function _stack_from(composer, pkg) {
53210
53796
  }
53211
53797
  return parts.join(" \xB7 ");
53212
53798
  }
53213
- function _splitlines11(text) {
53799
+ function _splitlines12(text) {
53214
53800
  if (text === "") {
53215
53801
  return [];
53216
53802
  }
@@ -53221,17 +53807,17 @@ function _splitlines11(text) {
53221
53807
  return parts;
53222
53808
  }
53223
53809
  function _purpose_from_readme(p) {
53224
- if (!fs102.existsSync(p)) {
53810
+ if (!fs104.existsSync(p)) {
53225
53811
  return null;
53226
53812
  }
53227
53813
  let text;
53228
53814
  try {
53229
- text = fs102.readFileSync(p, "utf-8");
53815
+ text = fs104.readFileSync(p, "utf-8");
53230
53816
  } catch {
53231
53817
  return null;
53232
53818
  }
53233
53819
  const paragraph = [];
53234
- for (const raw of _splitlines11(text)) {
53820
+ for (const raw of _splitlines12(text)) {
53235
53821
  const stripped = raw.trim();
53236
53822
  if (!stripped) {
53237
53823
  if (paragraph.length > 0) {
@@ -53310,13 +53896,13 @@ function _rfind(haystack, needle) {
53310
53896
  return -1;
53311
53897
  }
53312
53898
  function detect_project_context(root) {
53313
- const resolvedRoot = path99.resolve(root ?? process.cwd());
53314
- const composer = _read_json(path99.join(resolvedRoot, "composer.json"));
53315
- const pkg = _read_json(path99.join(resolvedRoot, "package.json"));
53899
+ const resolvedRoot = path101.resolve(root ?? process.cwd());
53900
+ const composer = _read_json(path101.join(resolvedRoot, "composer.json"));
53901
+ const pkg = _read_json(path101.join(resolvedRoot, "package.json"));
53316
53902
  return new ProjectContext(
53317
53903
  _name_from(composer, pkg, resolvedRoot),
53318
53904
  _stack_from(composer, pkg),
53319
- _purpose_from_readme(path99.join(resolvedRoot, "README.md"))
53905
+ _purpose_from_readme(path101.join(resolvedRoot, "README.md"))
53320
53906
  );
53321
53907
  }
53322
53908
  var REPO_PURPOSE_MAX_CHARS, _HEADING_RE, _BADGE_RE, _HTML_RE, ProjectContext;
@@ -53586,7 +54172,7 @@ __export(shadow_dispatch_exports, {
53586
54172
  slo_banner: () => slo_banner,
53587
54173
  slo_status: () => slo_status
53588
54174
  });
53589
- import * as fs103 from "node:fs";
54175
+ import * as fs105 from "node:fs";
53590
54176
  import { createHash as createHash16 } from "node:crypto";
53591
54177
  function should_shadow(sampleRate, opts = {}) {
53592
54178
  const rate = Math.max(0, Math.min(1, sampleRate));
@@ -53624,7 +54210,7 @@ function record_shadow_decision(logPath, opts) {
53624
54210
  escalated,
53625
54211
  escalation_reason: escalationReason
53626
54212
  };
53627
- fs103.mkdirSync(_dirname2(logPath), { recursive: true });
54213
+ fs105.mkdirSync(_dirname2(logPath), { recursive: true });
53628
54214
  const row = _pyJsonDumps2({
53629
54215
  timestamp: decision.timestamp,
53630
54216
  query_hash: decision.query_hash,
@@ -53634,7 +54220,7 @@ function record_shadow_decision(logPath, opts) {
53634
54220
  escalated: decision.escalated,
53635
54221
  escalation_reason: decision.escalation_reason
53636
54222
  }) + "\n";
53637
- fs103.appendFileSync(logPath, row, { encoding: "utf-8" });
54223
+ fs105.appendFileSync(logPath, row, { encoding: "utf-8" });
53638
54224
  return decision;
53639
54225
  }
53640
54226
  function _isoNowSeconds() {
@@ -53643,11 +54229,11 @@ function _isoNowSeconds() {
53643
54229
  return `${pad(d.getUTCFullYear(), 4)}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`;
53644
54230
  }
53645
54231
  function* _iterLog(logPath) {
53646
- if (!fs103.existsSync(logPath)) {
54232
+ if (!fs105.existsSync(logPath)) {
53647
54233
  return;
53648
54234
  }
53649
- const content = fs103.readFileSync(logPath, { encoding: "utf-8" });
53650
- for (const rawLine of _splitlines12(content)) {
54235
+ const content = fs105.readFileSync(logPath, { encoding: "utf-8" });
54236
+ for (const rawLine of _splitlines13(content)) {
53651
54237
  const line = _strip8(rawLine);
53652
54238
  if (!line) {
53653
54239
  continue;
@@ -53842,7 +54428,7 @@ function _dirname2(p) {
53842
54428
  function _strip8(s) {
53843
54429
  return s.trim();
53844
54430
  }
53845
- function _splitlines12(s) {
54431
+ function _splitlines13(s) {
53846
54432
  if (s === "") {
53847
54433
  return [];
53848
54434
  }
@@ -54001,7 +54587,7 @@ function _pySlice3(s, n) {
54001
54587
  function _pyStrip8(s) {
54002
54588
  return s.trim();
54003
54589
  }
54004
- function _splitlines13(s) {
54590
+ function _splitlines14(s) {
54005
54591
  if (s === "") {
54006
54592
  return [];
54007
54593
  }
@@ -54063,7 +54649,7 @@ function _aborted_marker(reason, members) {
54063
54649
  return `> Low-impact council aborted (${reason}) \u2014 escalating to user: members tried: ${names}.`;
54064
54650
  }
54065
54651
  function _split_marker(answers) {
54066
- const parts = answers.filter((a) => a.ok).map((a) => `${a.member}: ${_pySlice3(_pyStrip8(_splitlines13(a.text)[0] ?? ""), 80)}`).join(" / ");
54652
+ const parts = answers.filter((a) => a.ok).map((a) => `${a.member}: ${_pySlice3(_pyStrip8(_splitlines14(a.text)[0] ?? ""), 80)}`).join(" / ");
54067
54653
  return `> Low-impact council split \u2014 escalating to user (${parts}):`;
54068
54654
  }
54069
54655
  function _unavailable_marker() {
@@ -54079,7 +54665,7 @@ function _resolved_marker(ok_answers) {
54079
54665
  return `> Resolved via low-impact council fast-path: ${verdict}.`;
54080
54666
  }
54081
54667
  function _answer_line(text) {
54082
- for (const line of _splitlines13(text)) {
54668
+ for (const line of _splitlines14(text)) {
54083
54669
  const stripped = _pyStrip8(line);
54084
54670
  if (stripped !== "") {
54085
54671
  return stripped;
@@ -54307,7 +54893,7 @@ function parse_low_impact_log(text) {
54307
54893
  const by_member = /* @__PURE__ */ new Map();
54308
54894
  let total = 0;
54309
54895
  let total_cost = 0;
54310
- for (const raw of _splitlines13(text)) {
54896
+ for (const raw of _splitlines14(text)) {
54311
54897
  const m = _LOG_LINE_RE.exec(_pyStrip8(raw));
54312
54898
  if (!m) {
54313
54899
  continue;
@@ -54571,11 +55157,11 @@ __export(council_cli_exports, {
54571
55157
  cmd_status: () => cmd_status,
54572
55158
  format_estimate_table: () => format_estimate_table,
54573
55159
  load_settings: () => load_settings,
54574
- main: () => main38
55160
+ main: () => main39
54575
55161
  });
54576
- import * as fs104 from "node:fs";
54577
- import * as path100 from "node:path";
54578
- import { fileURLToPath as fileURLToPath50, pathToFileURL as pathToFileURL35 } from "node:url";
55162
+ import * as fs106 from "node:fs";
55163
+ import * as path102 from "node:path";
55164
+ import { fileURLToPath as fileURLToPath51, pathToFileURL as pathToFileURL36 } from "node:url";
54579
55165
  function _pyFixed6(x, ndigits) {
54580
55166
  if (!Number.isFinite(x)) {
54581
55167
  return String(x);
@@ -54783,7 +55369,7 @@ function _stderr2(s) {
54783
55369
  function load_settings(p = SETTINGS_FILE2, opts = {}) {
54784
55370
  const ai_council_path = opts.ai_council_path ?? AI_COUNCIL_FILE;
54785
55371
  const settings = load_agent_settings({ project_path: p });
54786
- if (fs104.existsSync(ai_council_path)) {
55372
+ if (fs106.existsSync(ai_council_path)) {
54787
55373
  const cfg = load_council_config(ai_council_path);
54788
55374
  settings["ai_council"] = synthesizeAiCouncilBlock(cfg);
54789
55375
  }
@@ -55149,7 +55735,7 @@ function build_question(opts) {
55149
55735
  let ctx;
55150
55736
  let artefact;
55151
55737
  if (input_mode === "prompt") {
55152
- const text = fs104.readFileSync(input_path, "utf-8");
55738
+ const text = fs106.readFileSync(input_path, "utf-8");
55153
55739
  ctx = bundle_prompt(text);
55154
55740
  artefact = String(input_path);
55155
55741
  } else if (input_mode === "roadmap") {
@@ -55293,9 +55879,9 @@ function _maybe_write_decision_replay(opts) {
55293
55879
  include_member_arguments: include_args
55294
55880
  })
55295
55881
  );
55296
- const target = path100.join(path100.dirname(opts.out_path), "decision-replay.md");
55297
- fs104.mkdirSync(path100.dirname(target), { recursive: true });
55298
- fs104.writeFileSync(target, replay, { encoding: "utf-8" });
55882
+ const target = path102.join(path102.dirname(opts.out_path), "decision-replay.md");
55883
+ fs106.mkdirSync(path102.dirname(target), { recursive: true });
55884
+ fs106.writeFileSync(target, replay, { encoding: "utf-8" });
55299
55885
  return target;
55300
55886
  }
55301
55887
  function _peer_review_active(ai_cfg, args) {
@@ -55968,7 +56554,7 @@ function cmd_status(args, opts = {}) {
55968
56554
  const env = opts.env ?? process.env;
55969
56555
  const override = env[COUNCIL_CONFIG_ENV];
55970
56556
  const path_ = resolve_config_path(REPO_ROOT12, { env });
55971
- const exists3 = fs104.existsSync(String(path_));
56557
+ const exists3 = fs106.existsSync(String(path_));
55972
56558
  const provenance = override ? `${COUNCIL_CONFIG_ENV} override` : "user-global";
55973
56559
  let cfg = null;
55974
56560
  let parse_error = null;
@@ -56436,8 +57022,8 @@ function cmd_run(args, opts = {}) {
56436
57022
  kind: "responses",
56437
57023
  subcommand: "run"
56438
57024
  });
56439
- fs104.mkdirSync(path100.dirname(_resolveTarget(out_path)), { recursive: true });
56440
- fs104.writeFileSync(_resolveTarget(out_path), _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
57025
+ fs106.mkdirSync(path102.dirname(_resolveTarget(out_path)), { recursive: true });
57026
+ fs106.writeFileSync(_resolveTarget(out_path), _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
56441
57027
  const _all_subscription = allSeatsNonBillable(all_responses);
56442
57028
  _stdout2(
56443
57029
  `
@@ -56463,7 +57049,7 @@ function _debate_round_filename(round_number) {
56463
57049
  return `debate-round-${round_number}.json`;
56464
57050
  }
56465
57051
  function _write_debate_round(out_dir, round_number, responses, opts) {
56466
- fs104.mkdirSync(_resolveTarget(out_dir), { recursive: true });
57052
+ fs106.mkdirSync(_resolveTarget(out_dir), { recursive: true });
56467
57053
  const actual_total = sumBillableCost(responses, opts.table);
56468
57054
  const payload = {
56469
57055
  schema_version: SCHEMA_VERSION9,
@@ -56480,15 +57066,15 @@ function _write_debate_round(out_dir, round_number, responses, opts) {
56480
57066
  prompt_cache_round_gap_ms: opts.cache_gap_ms_since_previous_round ?? null,
56481
57067
  responses: serializeResponses(responses)
56482
57068
  };
56483
- const out_path = path100.join(_resolveTarget(out_dir), _debate_round_filename(round_number));
56484
- fs104.writeFileSync(out_path, _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
57069
+ const out_path = path102.join(_resolveTarget(out_dir), _debate_round_filename(round_number));
57070
+ fs106.writeFileSync(out_path, _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
56485
57071
  return out_path;
56486
57072
  }
56487
57073
  function _load_debate_seed(p, expected_members) {
56488
- if (!fs104.existsSync(p)) {
57074
+ if (!fs106.existsSync(p)) {
56489
57075
  throw new FileNotFoundError3(`--continue-as-debate path not found: ${p}`);
56490
57076
  }
56491
- const payload = JSON.parse(fs104.readFileSync(p, "utf-8"));
57077
+ const payload = JSON.parse(fs106.readFileSync(p, "utf-8"));
56492
57078
  const source_members = (payload["members"] || []).slice();
56493
57079
  const expected_labels = expected_members.map((m) => `${m.name}/${m.model}`);
56494
57080
  if (!_listEq(source_members, expected_labels)) {
@@ -56534,7 +57120,7 @@ function _readStdinLine() {
56534
57120
  try {
56535
57121
  const buf = Buffer.alloc(4096);
56536
57122
  const fd = 0;
56537
- const n = fs104.readSync(fd, buf, 0, buf.length, null);
57123
+ const n = fs106.readSync(fd, buf, 0, buf.length, null);
56538
57124
  return buf.toString("utf-8", 0, n).split("\n")[0]?.trim().toLowerCase() ?? "";
56539
57125
  } catch {
56540
57126
  return "";
@@ -56762,7 +57348,7 @@ council:debate \xB7 ${all_rounds.length} round(s) complete \xB7 actual $${_pyFix
56762
57348
  return errors_last.length > 0 && errors_last.length === last.length ? 1 : 0;
56763
57349
  }
56764
57350
  function cmd_render(args) {
56765
- const payload = JSON.parse(fs104.readFileSync(args.responses, "utf-8"));
57351
+ const payload = JSON.parse(fs106.readFileSync(args.responses, "utf-8"));
56766
57352
  const items = payload["responses"] || [];
56767
57353
  const explicit = _getattr3(args, "prompt_mode", null);
56768
57354
  const mode = explicit || payload["prompt_mode"] || payload["mode"];
@@ -56791,8 +57377,8 @@ function cmd_render(args) {
56791
57377
  kind: "sessions",
56792
57378
  subcommand: "render"
56793
57379
  });
56794
- fs104.mkdirSync(path100.dirname(_resolveTarget(out_path)), { recursive: true });
56795
- fs104.writeFileSync(_resolveTarget(out_path), body + "\n", { encoding: "utf-8" });
57380
+ fs106.mkdirSync(path102.dirname(_resolveTarget(out_path)), { recursive: true });
57381
+ fs106.writeFileSync(_resolveTarget(out_path), body + "\n", { encoding: "utf-8" });
56796
57382
  _stdout2(`council:render \xB7 wrote ${out_path}
56797
57383
  `);
56798
57384
  return 0;
@@ -56803,15 +57389,15 @@ function cmd_render(args) {
56803
57389
  function _cmd_replay_low_impact_stats(args) {
56804
57390
  const li = low_impact_exports;
56805
57391
  const responses_path = args.responses;
56806
- const log_path = path100.join(path100.dirname(responses_path), "low-impact-resolutions.md");
56807
- if (!fs104.existsSync(log_path)) {
57392
+ const log_path = path102.join(path102.dirname(responses_path), "low-impact-resolutions.md");
57393
+ if (!fs106.existsSync(log_path)) {
56808
57394
  _stdout2(
56809
57395
  `council:replay \xB7 no low-impact-resolutions.md alongside ${responses_path} \u2014 session had no fast-path entries.
56810
57396
  `
56811
57397
  );
56812
57398
  return 0;
56813
57399
  }
56814
- const body = fs104.readFileSync(log_path, "utf-8");
57400
+ const body = fs106.readFileSync(log_path, "utf-8");
56815
57401
  const stats = li.parse_low_impact_log(body);
56816
57402
  const out = li.render_low_impact_stats(stats);
56817
57403
  if (_getattr3(args, "output", null)) {
@@ -56819,8 +57405,8 @@ function _cmd_replay_low_impact_stats(args) {
56819
57405
  kind: "sessions",
56820
57406
  subcommand: "replay"
56821
57407
  });
56822
- fs104.mkdirSync(path100.dirname(_resolveTarget(target)), { recursive: true });
56823
- fs104.writeFileSync(_resolveTarget(target), out, { encoding: "utf-8" });
57408
+ fs106.mkdirSync(path102.dirname(_resolveTarget(target)), { recursive: true });
57409
+ fs106.writeFileSync(_resolveTarget(target), out, { encoding: "utf-8" });
56824
57410
  _stdout2(`council:replay \xB7 wrote ${target}
56825
57411
  `);
56826
57412
  return 0;
@@ -56832,7 +57418,7 @@ function cmd_replay(args) {
56832
57418
  if (_getattr3(args, "low_impact_stats", false)) {
56833
57419
  return _cmd_replay_low_impact_stats(args);
56834
57420
  }
56835
- const payload = JSON.parse(fs104.readFileSync(args.responses, "utf-8"));
57421
+ const payload = JSON.parse(fs106.readFileSync(args.responses, "utf-8"));
56836
57422
  const consensus = _deserialise_consensus(payload["consensus"]);
56837
57423
  if (consensus === null) {
56838
57424
  _stderr2(
@@ -56857,8 +57443,8 @@ function cmd_replay(args) {
56857
57443
  kind: "sessions",
56858
57444
  subcommand: "replay"
56859
57445
  });
56860
- fs104.mkdirSync(path100.dirname(_resolveTarget(out_path)), { recursive: true });
56861
- fs104.writeFileSync(_resolveTarget(out_path), body, { encoding: "utf-8" });
57446
+ fs106.mkdirSync(path102.dirname(_resolveTarget(out_path)), { recursive: true });
57447
+ fs106.writeFileSync(_resolveTarget(out_path), body, { encoding: "utf-8" });
56862
57448
  _stdout2(`council:replay \xB7 wrote ${out_path}
56863
57449
  `);
56864
57450
  } else {
@@ -56915,8 +57501,8 @@ function cmd_quota(args, opts = {}) {
56915
57501
  }
56916
57502
  function _validate_council_output_path(path_str, opts) {
56917
57503
  const expected_rel = COUNCIL_CANONICAL_DIRS[opts.kind];
56918
- const expected_abs = _resolveReal(path100.join(REPO_ROOT12, expected_rel));
56919
- const target = path100.isAbsolute(path_str) ? path_str : path100.join(REPO_ROOT12, path_str);
57504
+ const expected_abs = _resolveReal(path102.join(REPO_ROOT12, expected_rel));
57505
+ const target = path102.isAbsolute(path_str) ? path_str : path102.join(REPO_ROOT12, path_str);
56920
57506
  const target_resolved = _resolveReal(target);
56921
57507
  if (!_isRelativeTo(target_resolved, expected_abs)) {
56922
57508
  throw new ArgumentTypeError(
@@ -56926,12 +57512,12 @@ function _validate_council_output_path(path_str, opts) {
56926
57512
  return path_str;
56927
57513
  }
56928
57514
  function _resolveTarget(path_str) {
56929
- return path100.isAbsolute(path_str) ? path_str : path100.join(REPO_ROOT12, path_str);
57515
+ return path102.isAbsolute(path_str) ? path_str : path102.join(REPO_ROOT12, path_str);
56930
57516
  }
56931
57517
  function _resolveReal(p) {
56932
- const abs = path100.resolve(p);
57518
+ const abs = path102.resolve(p);
56933
57519
  try {
56934
- return fs104.realpathSync(abs);
57520
+ return fs106.realpathSync(abs);
56935
57521
  } catch {
56936
57522
  return abs;
56937
57523
  }
@@ -56940,8 +57526,8 @@ function _isRelativeTo(target, base) {
56940
57526
  if (target === base) {
56941
57527
  return true;
56942
57528
  }
56943
- const rel = path100.relative(base, target);
56944
- return rel !== "" && !rel.startsWith("..") && !path100.isAbsolute(rel);
57529
+ const rel = path102.relative(base, target);
57530
+ return rel !== "" && !rel.startsWith("..") && !path102.isAbsolute(rel);
56945
57531
  }
56946
57532
  function _topError(message) {
56947
57533
  _stderr2(_TOP_USAGE2);
@@ -57266,7 +57852,7 @@ function _parse_siblings_overrides(items) {
57266
57852
  function _isFileNotFound(exc) {
57267
57853
  return exc instanceof FileNotFoundError3 || exc instanceof Error && exc.code === "ENOENT";
57268
57854
  }
57269
- function main38(argv = null) {
57855
+ function main39(argv = null) {
57270
57856
  const args = _parseArgs7(argv ?? process.argv.slice(2));
57271
57857
  try {
57272
57858
  if (args.cmd === "estimate") {
@@ -57310,23 +57896,23 @@ function main38(argv = null) {
57310
57896
  }
57311
57897
  return 1;
57312
57898
  }
57313
- function _isCliEntry29() {
57899
+ function _isCliEntry30() {
57314
57900
  if (process.argv[1] === void 0) {
57315
57901
  return false;
57316
57902
  }
57317
- const argvUrl = pathToFileURL35(path100.resolve(process.argv[1])).href;
57903
+ const argvUrl = pathToFileURL36(path102.resolve(process.argv[1])).href;
57318
57904
  if (import.meta.url === argvUrl) {
57319
57905
  return true;
57320
57906
  }
57321
57907
  try {
57322
- const here = fs104.realpathSync(fileURLToPath50(import.meta.url));
57323
- const argv = fs104.realpathSync(path100.resolve(process.argv[1]));
57908
+ const here = fs106.realpathSync(fileURLToPath51(import.meta.url));
57909
+ const argv = fs106.realpathSync(path102.resolve(process.argv[1]));
57324
57910
  return here === argv;
57325
57911
  } catch {
57326
57912
  return false;
57327
57913
  }
57328
57914
  }
57329
- var _ArgExit2, ArgumentTypeError, _PROG9, SCHEMA_VERSION9, _API_PROVIDERS, _CLI_PROVIDERS, _HERE26, REPO_ROOT12, SETTINGS_FILE2, AI_COUNCIL_FILE, COUNCIL_CANONICAL_DIRS, CouncilDisabledError, _CLI_FACTORY, ValueError4, _VALID_ABSENT_REASONS, FileNotFoundError3, _SUBCOMMANDS, _TOP_USAGE2;
57915
+ var _ArgExit2, ArgumentTypeError, _PROG9, SCHEMA_VERSION9, _API_PROVIDERS, _CLI_PROVIDERS, _HERE27, REPO_ROOT12, SETTINGS_FILE2, AI_COUNCIL_FILE, COUNCIL_CANONICAL_DIRS, CouncilDisabledError, _CLI_FACTORY, ValueError4, _VALID_ABSENT_REASONS, FileNotFoundError3, _SUBCOMMANDS, _TOP_USAGE2;
57330
57916
  var init_council_cli = __esm({
57331
57917
  "src/scripts/council_cli.ts"() {
57332
57918
  "use strict";
@@ -57392,7 +57978,7 @@ var init_council_cli = __esm({
57392
57978
  "xai",
57393
57979
  "perplexity"
57394
57980
  ]);
57395
- _HERE26 = path100.dirname(fileURLToPath50(import.meta.url));
57981
+ _HERE27 = path102.dirname(fileURLToPath51(import.meta.url));
57396
57982
  [REPO_ROOT12] = resolve_project_root(null);
57397
57983
  SETTINGS_FILE2 = project_settings_path(REPO_ROOT12);
57398
57984
  AI_COUNCIL_FILE = resolve_config_path(REPO_ROOT12);
@@ -57425,9 +58011,9 @@ var init_council_cli = __esm({
57425
58011
  {estimate,run,debate,render,replay,quota,shadow-report,status}
57426
58012
  ...
57427
58013
  `;
57428
- if (_isCliEntry29()) {
58014
+ if (_isCliEntry30()) {
57429
58015
  try {
57430
- process.exitCode = main38(process.argv.slice(2));
58016
+ process.exitCode = main39(process.argv.slice(2));
57431
58017
  } catch (err) {
57432
58018
  if (!(err instanceof _ArgExit2)) {
57433
58019
  throw err;
@@ -57456,7 +58042,7 @@ function run_enveloped(spec) {
57456
58042
  if (cmd === void 0) {
57457
58043
  throw new Error("envelope argv must not be empty");
57458
58044
  }
57459
- return new Promise((resolve56) => {
58045
+ return new Promise((resolve57) => {
57460
58046
  execFile(
57461
58047
  cmd,
57462
58048
  args,
@@ -57479,7 +58065,7 @@ function run_enveloped(spec) {
57479
58065
  }
57480
58066
  const [out, outTrunc] = _truncate(String(stdout ?? ""), spec.max_output_bytes);
57481
58067
  const [err, errTrunc] = _truncate(String(stderr ?? ""), spec.max_output_bytes);
57482
- resolve56({
58068
+ resolve57({
57483
58069
  exit_code: timedOut ? null : exitCode,
57484
58070
  timed_out: timedOut,
57485
58071
  stdout: out,
@@ -57500,8 +58086,8 @@ var init_safety_envelope = __esm({
57500
58086
  });
57501
58087
 
57502
58088
  // src/scripts/mcp_server/__main__.ts
57503
- import * as path102 from "node:path";
57504
- import { fileURLToPath as fileURLToPath52 } from "node:url";
58089
+ import * as path104 from "node:path";
58090
+ import { fileURLToPath as fileURLToPath53 } from "node:url";
57505
58091
 
57506
58092
  // src/scripts/mcp_server/index.ts
57507
58093
  var __version__ = "0.1.0";
@@ -57548,9 +58134,9 @@ init_prompts();
57548
58134
  init_resources();
57549
58135
 
57550
58136
  // src/scripts/mcp_server/tools.ts
57551
- import * as fs105 from "node:fs";
57552
- import * as path101 from "node:path";
57553
- import { fileURLToPath as fileURLToPath51 } from "node:url";
58137
+ import * as fs107 from "node:fs";
58138
+ import * as path103 from "node:path";
58139
+ import { fileURLToPath as fileURLToPath52 } from "node:url";
57554
58140
 
57555
58141
  // src/scripts/chat_history.ts
57556
58142
  init_memory_lookup();
@@ -60969,8 +61555,8 @@ function buildGraph(files, extracts, resolution = EMPTY_RESOLUTION_CONFIG) {
60969
61555
  }
60970
61556
  function resolveRawEdge(r, ex) {
60971
61557
  if (r.relation === "member") {
60972
- const sep20 = r.sourceId.includes("#") ? "::" : "#";
60973
- const target = `${r.sourceId}${sep20}${r.targetName}`;
61558
+ const sep21 = r.sourceId.includes("#") ? "::" : "#";
61559
+ const target = `${r.sourceId}${sep21}${r.targetName}`;
60974
61560
  emit2({
60975
61561
  source: r.sourceId,
60976
61562
  target: nodeIds.has(target) ? target : `symbol:${r.targetName}`,
@@ -62780,14 +63366,14 @@ function _resolveConsumerRoot(override) {
62780
63366
  return resolvePath(process.cwd());
62781
63367
  }
62782
63368
  function _relativeUnder(target, root) {
62783
- const rel = path101.relative(root, target);
63369
+ const rel = path103.relative(root, target);
62784
63370
  if (rel === "") {
62785
63371
  return "";
62786
63372
  }
62787
- if (rel.startsWith("..") || path101.isAbsolute(rel)) {
63373
+ if (rel.startsWith("..") || path103.isAbsolute(rel)) {
62788
63374
  return null;
62789
63375
  }
62790
- return rel.split(path101.sep).join("/");
63376
+ return rel.split(path103.sep).join("/");
62791
63377
  }
62792
63378
  function _reprStrList(values) {
62793
63379
  return `[${values.map((v) => `'${v}'`).join(", ")}]`;
@@ -62796,11 +63382,11 @@ function _validateInTreePath(raw, consumerRoot) {
62796
63382
  const root = resolvePath(consumerRoot);
62797
63383
  let target;
62798
63384
  if (raw === null || raw === void 0 || raw === "") {
62799
- target = path101.join(root, "agents", "runtime", ".agent-chat-history");
62800
- } else if (path101.isAbsolute(raw)) {
63385
+ target = path103.join(root, "agents", "runtime", ".agent-chat-history");
63386
+ } else if (path103.isAbsolute(raw)) {
62801
63387
  target = resolvePath(raw);
62802
63388
  } else {
62803
- target = resolvePath(path101.join(root, raw));
63389
+ target = resolvePath(path103.join(root, raw));
62804
63390
  }
62805
63391
  const rel = _relativeUnder(target, root);
62806
63392
  if (rel === null) {
@@ -62838,11 +63424,11 @@ async function _lintSkillsHandler(args, consumerRoot) {
62838
63424
  if (typeof raw !== "string") {
62839
63425
  throw new Error("'paths' entries must be strings");
62840
63426
  }
62841
- const resolved = path101.isAbsolute(raw) ? resolvePath(raw) : resolvePath(path101.join(root, raw));
63427
+ const resolved = path103.isAbsolute(raw) ? resolvePath(raw) : resolvePath(path103.join(root, raw));
62842
63428
  if (_relativeUnder(resolved, root) === null) {
62843
63429
  throw new Error(`path escapes consumer_root: ${resolved}`);
62844
63430
  }
62845
- if (fs105.existsSync(resolved)) {
63431
+ if (fs107.existsSync(resolved)) {
62846
63432
  paths.push(resolved);
62847
63433
  }
62848
63434
  }
@@ -62879,7 +63465,7 @@ async function _chatHistoryAppendHandler(args, consumerRoot) {
62879
63465
  if (typeof minSchema !== "number" || !Number.isInteger(minSchema) || typeof minSchema === "boolean") {
62880
63466
  throw new Error("'min_schema_version' must be an integer");
62881
63467
  }
62882
- const existingHeader = fs105.existsSync(target) ? _chReadHeader(target) : null;
63468
+ const existingHeader = fs107.existsSync(target) ? _chReadHeader(target) : null;
62883
63469
  const observed = existingHeader !== null && typeof existingHeader === "object" ? _pyInt7(existingHeader.v ?? 0) : SCHEMA_VERSION3;
62884
63470
  if (observed < minSchema) {
62885
63471
  throw new Error(`chat-history schema ${observed} below required ${minSchema}`);
@@ -62894,8 +63480,8 @@ async function _chatHistoryAppendHandler(args, consumerRoot) {
62894
63480
  session: session === void 0 ? null : session
62895
63481
  };
62896
63482
  }
62897
- if (!fs105.existsSync(target) || _chReadHeader(target) === null) {
62898
- fs105.mkdirSync(path101.dirname(target), { recursive: true });
63483
+ if (!fs107.existsSync(target) || _chReadHeader(target) === null) {
63484
+ fs107.mkdirSync(path103.dirname(target), { recursive: true });
62899
63485
  _chInit(target);
62900
63486
  }
62901
63487
  _chAppend(entry, target, session ?? null);
@@ -62939,7 +63525,7 @@ async function _chatHistoryReadHandler(args, consumerRoot) {
62939
63525
  if (detail !== "full" && detail !== "index") {
62940
63526
  throw new Error("'detail' must be 'index' or 'full'");
62941
63527
  }
62942
- if (!fs105.existsSync(target)) {
63528
+ if (!fs107.existsSync(target)) {
62943
63529
  return { path: target, entries: [], count: 0 };
62944
63530
  }
62945
63531
  if (around !== void 0 && around !== null) {
@@ -63041,8 +63627,8 @@ async function _memoryStatusHandler(_args, consumerRoot) {
63041
63627
  }
63042
63628
  return result;
63043
63629
  }
63044
- var _PACKAGE_ROOT3 = path101.resolve(
63045
- path101.dirname(fileURLToPath51(import.meta.url)),
63630
+ var _PACKAGE_ROOT3 = path103.resolve(
63631
+ path103.dirname(fileURLToPath52(import.meta.url)),
63046
63632
  "..",
63047
63633
  "..",
63048
63634
  ".."
@@ -63086,10 +63672,10 @@ async function _memorySignalHandler(args, consumerRoot) {
63086
63672
  async function _roadmapProgressHandler(args, consumerRoot) {
63087
63673
  const dryRun = _pyTruthy6(args.dry_run ?? false);
63088
63674
  const root = resolvePath(consumerRoot);
63089
- const roadmapRoot = path101.join(root, "agents", "roadmaps");
63090
- const target = path101.join(root, "agents", "roadmaps-progress.md");
63675
+ const roadmapRoot = path103.join(root, "agents", "roadmaps");
63676
+ const target = path103.join(root, "agents", "roadmaps-progress.md");
63091
63677
  const urp = await Promise.resolve().then(() => (init_update_roadmap_progress(), update_roadmap_progress_exports));
63092
- if (!fs105.existsSync(roadmapRoot)) {
63678
+ if (!fs107.existsSync(roadmapRoot)) {
63093
63679
  return {
63094
63680
  written: false,
63095
63681
  path: target,
@@ -63104,7 +63690,7 @@ async function _roadmapProgressHandler(args, consumerRoot) {
63104
63690
  const stepsDone = roadmaps.reduce((s, r) => s + r.done, 0);
63105
63691
  const stepsTotal = roadmaps.reduce((s, r) => s + r.total_active, 0);
63106
63692
  if (!dryRun) {
63107
- fs105.writeFileSync(target, content, "utf-8");
63693
+ fs107.writeFileSync(target, content, "utf-8");
63108
63694
  }
63109
63695
  return {
63110
63696
  written: !dryRun,
@@ -63125,11 +63711,11 @@ async function _roadmapArchiveHandler(_args, consumerRoot) {
63125
63711
  let dashboardRegenerated = false;
63126
63712
  if (archived.length > 0) {
63127
63713
  const urp = await Promise.resolve().then(() => (init_update_roadmap_progress(), update_roadmap_progress_exports));
63128
- const roadmapRoot = path101.join(root, "agents", "roadmaps");
63129
- if (fs105.existsSync(roadmapRoot)) {
63714
+ const roadmapRoot = path103.join(root, "agents", "roadmaps");
63715
+ if (fs107.existsSync(roadmapRoot)) {
63130
63716
  const roadmaps = urp.collect(roadmapRoot);
63131
- fs105.writeFileSync(
63132
- path101.join(root, "agents", "roadmaps-progress.md"),
63717
+ fs107.writeFileSync(
63718
+ path103.join(root, "agents", "roadmaps-progress.md"),
63133
63719
  urp.render(roadmaps, urp.collect_bundles(root), roadmapRoot),
63134
63720
  "utf-8"
63135
63721
  );
@@ -63145,9 +63731,9 @@ async function _roadmapArchiveHandler(_args, consumerRoot) {
63145
63731
  async function _capabilitiesIndexHandler(args, consumerRoot) {
63146
63732
  const check = _pyTruthy6(args.check ?? false);
63147
63733
  const cap = await Promise.resolve().then(() => (init_generate_capabilities_index(), generate_capabilities_index_exports));
63148
- const out = path101.join(_PACKAGE_ROOT3, "CAPABILITIES.yaml");
63734
+ const out = path103.join(_PACKAGE_ROOT3, "CAPABILITIES.yaml");
63149
63735
  const content = cap.build();
63150
- const onDisk = fs105.existsSync(out) ? fs105.readFileSync(out, "utf-8") : "";
63736
+ const onDisk = fs107.existsSync(out) ? fs107.readFileSync(out, "utf-8") : "";
63151
63737
  const drift = onDisk !== content;
63152
63738
  if (check) {
63153
63739
  return { check: true, written: false, drift, path: out };
@@ -63158,7 +63744,7 @@ async function _capabilitiesIndexHandler(args, consumerRoot) {
63158
63744
  `CAPABILITIES.yaml path escapes consumer_root: ${out} not under ${root}`
63159
63745
  );
63160
63746
  }
63161
- fs105.writeFileSync(out, content, "utf-8");
63747
+ fs107.writeFileSync(out, content, "utf-8");
63162
63748
  return { check: false, written: true, drift, path: out };
63163
63749
  }
63164
63750
  async function _runDoctorLeg(consumerRoot) {
@@ -63258,11 +63844,11 @@ async function _councilEstimateHandler(args, consumerRoot) {
63258
63844
  throw new Error("'depth' must be 'shallow' or 'deep' when provided");
63259
63845
  }
63260
63846
  const root = resolvePath(consumerRoot);
63261
- const target = path101.isAbsolute(inputRaw) ? resolvePath(inputRaw) : resolvePath(path101.join(root, inputRaw));
63847
+ const target = path103.isAbsolute(inputRaw) ? resolvePath(inputRaw) : resolvePath(path103.join(root, inputRaw));
63262
63848
  if (_relativeUnder(target, root) === null) {
63263
63849
  throw new Error(`path escapes consumer_root: ${target}`);
63264
63850
  }
63265
- if (!fs105.existsSync(target)) {
63851
+ if (!fs107.existsSync(target)) {
63266
63852
  throw new Error(`input_path not found: ${target}`);
63267
63853
  }
63268
63854
  const cli = await Promise.resolve().then(() => (init_council_cli(), council_cli_exports));
@@ -63324,18 +63910,18 @@ async function _runTestsHandler(args, consumerRoot) {
63324
63910
  if (typeof relPathRaw !== "string" || !strip(relPathRaw)) {
63325
63911
  throw new Error("'path' must be a non-empty string when provided");
63326
63912
  }
63327
- const resolved = path101.isAbsolute(relPathRaw) ? resolvePath(relPathRaw) : resolvePath(path101.join(root, relPathRaw));
63913
+ const resolved = path103.isAbsolute(relPathRaw) ? resolvePath(relPathRaw) : resolvePath(path103.join(root, relPathRaw));
63328
63914
  const rel = _relativeUnder(resolved, root);
63329
63915
  if (rel === null) {
63330
63916
  throw new Error(`path escapes consumer_root: ${resolved}`);
63331
63917
  }
63332
- if (!fs105.existsSync(resolved)) {
63918
+ if (!fs107.existsSync(resolved)) {
63333
63919
  throw new Error(`path not found: ${resolved}`);
63334
63920
  }
63335
63921
  relArg = rel;
63336
63922
  }
63337
- const vitestEntry = path101.join(root, "node_modules", "vitest", "vitest.mjs");
63338
- if (!fs105.existsSync(vitestEntry)) {
63923
+ const vitestEntry = path103.join(root, "node_modules", "vitest", "vitest.mjs");
63924
+ if (!fs107.existsSync(vitestEntry)) {
63339
63925
  throw new Error(
63340
63926
  "run_tests pilot supports vitest projects only \u2014 node_modules/vitest/vitest.mjs not found under consumer_root"
63341
63927
  );
@@ -63965,8 +64551,8 @@ function _strCmp3(a, b) {
63965
64551
  return a < b ? -1 : a > b ? 1 : 0;
63966
64552
  }
63967
64553
  function _pathlibCompare3(a, b) {
63968
- const pa = a.split(path101.sep);
63969
- const pb = b.split(path101.sep);
64554
+ const pa = a.split(path103.sep);
64555
+ const pb = b.split(path103.sep);
63970
64556
  const n = Math.min(pa.length, pb.length);
63971
64557
  for (let i = 0; i < n; i++) {
63972
64558
  const c = _strCmp3(pa[i], pb[i]);
@@ -64185,18 +64771,18 @@ async function _serveOverSdk(server) {
64185
64771
  const transport = new StdioServerTransport();
64186
64772
  await sdkServer.connect(transport);
64187
64773
  }
64188
- function main39() {
64774
+ function main40() {
64189
64775
  void run_stdio();
64190
64776
  }
64191
64777
 
64192
64778
  // src/scripts/mcp_server/__main__.ts
64193
- var _selfPath = fileURLToPath52(import.meta.url);
64194
- var _invokedDirectly3 = globalThis.__AC_MCP_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path102.resolve(process.argv[1]) === path102.resolve(_selfPath);
64779
+ var _selfPath = fileURLToPath53(import.meta.url);
64780
+ var _invokedDirectly3 = globalThis.__AC_MCP_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path104.resolve(process.argv[1]) === path104.resolve(_selfPath);
64195
64781
  if (_invokedDirectly3) {
64196
- main39();
64782
+ main40();
64197
64783
  }
64198
64784
  export {
64199
- main39 as main
64785
+ main40 as main
64200
64786
  };
64201
64787
  /*! Bundled license information:
64202
64788