@event4u/agent-config 9.35.0 → 9.36.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/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +61 -165
  3. package/dist/agent-src/commands/analyze/reference-repo.md +135 -42
  4. package/dist/agent-src/contexts/augment-infrastructure.md +1 -1
  5. package/dist/agent-src/rules/design-review-after-ui-write.md +53 -6
  6. package/dist/agent-src/rules/improve-before-implement.md +1 -1
  7. package/dist/agent-src/rules/ui-audit-gate.md +35 -0
  8. package/dist/agent-src/skills/design-system-capture/SKILL.md +2 -2
  9. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +1 -1
  10. package/dist/agent-src/skills/fe-design/SKILL.md +84 -12
  11. package/dist/agent-src/skills/fe-design/evals/triggers.json +11 -3
  12. package/dist/agent-src/skills/prediction-pool-optimizer/SKILL.md +5 -5
  13. package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +1 -1
  14. package/dist/agent-src/skills/skill-writing/SKILL.md +24 -0
  15. package/dist/agent-src/skills/subagent-orchestration/prompts/README.md +29 -0
  16. package/dist/agent-src/templates/AGENTS.md +1 -1
  17. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  18. package/dist/cli-delegate/{chunk-ZAXH3ZWU.js → chunk-JP53LNVT.js} +9 -0
  19. package/dist/cli-delegate/{chunk-736JCWLM.js → chunk-M2DPGFZ4.js} +10 -0
  20. package/dist/cli-delegate/{chunk-H6F2CQFI.js → chunk-NR7HSN3P.js} +2 -2
  21. package/dist/cli-delegate/{chunk-2TGMGLBL.js → chunk-SFGARMAB.js} +11 -1
  22. package/dist/cli-delegate/{chunk-DS6BLDMG.js → chunk-U7CMAIOC.js} +7 -2
  23. package/dist/cli-delegate/cmd_conformance.js +3 -3
  24. package/dist/cli-delegate/cmd_doctor.js +2 -2
  25. package/dist/cli-delegate/cmd_export.js +3 -3
  26. package/dist/cli-delegate/cmd_migrate.js +1 -1
  27. package/dist/cli-delegate/cmd_prune.js +3 -3
  28. package/dist/cli-delegate/cmd_refresh.js +1 -1
  29. package/dist/cli-delegate/cmd_session_recycle.js +8 -1
  30. package/dist/cli-delegate/cmd_settings_migrate.js +3 -3
  31. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  32. package/dist/cli-delegate/cmd_sync.js +3 -3
  33. package/dist/cli-delegate/cmd_uninstall.js +3 -3
  34. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  35. package/dist/cli-delegate/cmd_validate.js +3 -3
  36. package/dist/discovery/deprecation-report.md +1 -1
  37. package/dist/discovery/discovery-manifest.json +12 -12
  38. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  39. package/dist/discovery/discovery-manifest.summary.md +1 -1
  40. package/dist/discovery/dormancy-report.md +1 -1
  41. package/dist/discovery/orphan-report.md +1 -1
  42. package/dist/discovery/packs.json +2 -2
  43. package/dist/discovery/trust-report.md +1 -1
  44. package/dist/discovery/workspaces.json +2 -2
  45. package/dist/hooks/dispatch.js +530 -323
  46. package/dist/install/install.mjs +18 -4
  47. package/dist/mcp/registry-manifest.json +1 -1
  48. package/dist/mcp/server.json +2 -2
  49. package/dist/mcp/server.mjs +25 -5
  50. package/dist/router.json +1 -1
  51. package/dist/server/schemas/settings.js +5 -0
  52. package/dist/server/schemas/settings.js.map +1 -1
  53. package/docs/contracts/settings-classes.md +4 -2
  54. package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +46 -4
  55. package/package.json +2 -2
  56. package/src/agent-src/templates/AGENTS.md +1 -1
  57. package/src/config/agent-settings.template.yml +32 -0
  58. package/src/config/gate-coverage.yml +12 -0
  59. package/src/scripts/_cli/cmd_doctor.ts +32 -0
  60. package/src/scripts/_cli/cmd_migrate.ts +26 -3
  61. package/src/scripts/_cli/cmd_refresh.ts +29 -0
  62. package/src/scripts/_cli/cmd_session_recycle.ts +40 -2
  63. package/src/scripts/_lib/hook_settings.ts +79 -0
  64. package/src/scripts/_lib/ui_surface.ts +97 -0
  65. package/src/scripts/capture_skill_catalogue.ts +483 -0
  66. package/src/scripts/hook_manifest.yaml +18 -3
  67. package/src/scripts/hooks/concern_registry.ts +2 -0
  68. package/src/scripts/hooks/design_slop_hook.ts +1 -1
  69. package/src/scripts/hooks/ui_route_nudge_hook.ts +250 -0
  70. package/src/scripts/lint_roadmap_complexity.ts +60 -0
  71. package/src/scripts/lint_rule_skill_pack_reach.ts +263 -0
  72. package/src/scripts/report_consultation_rate.ts +358 -0
  73. package/src/scripts/report_skill_activation.ts +5 -1
  74. package/src/server/schemas/settings.ts +9 -0
  75. /package/dist/agent-src/skills/design-system-capture/{reference → references}/design-system-json.md +0 -0
  76. /package/dist/agent-src/skills/prediction-pool-optimizer/{reference → references}/ev-fixtures.md +0 -0
  77. /package/dist/agent-src/skills/prediction-pool-optimizer/{reference → references}/odds-and-bonus.md +0 -0
  78. /package/dist/agent-src/skills/react-shadcn-ui/{reference → references}/registry.md +0 -0
@@ -112,17 +112,17 @@ var require_visit = __commonJS({
112
112
  visit.BREAK = BREAK;
113
113
  visit.SKIP = SKIP;
114
114
  visit.REMOVE = REMOVE;
115
- function visit_(key, node, visitor, path67) {
116
- const ctrl = callVisitor(key, node, visitor, path67);
115
+ function visit_(key, node, visitor, path69) {
116
+ const ctrl = callVisitor(key, node, visitor, path69);
117
117
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
118
- replaceNode(key, path67, ctrl);
119
- return visit_(key, ctrl, visitor, path67);
118
+ replaceNode(key, path69, ctrl);
119
+ return visit_(key, ctrl, visitor, path69);
120
120
  }
121
121
  if (typeof ctrl !== "symbol") {
122
122
  if (identity.isCollection(node)) {
123
- path67 = Object.freeze(path67.concat(node));
123
+ path69 = Object.freeze(path69.concat(node));
124
124
  for (let i = 0; i < node.items.length; ++i) {
125
- const ci = visit_(i, node.items[i], visitor, path67);
125
+ const ci = visit_(i, node.items[i], visitor, path69);
126
126
  if (typeof ci === "number")
127
127
  i = ci - 1;
128
128
  else if (ci === BREAK)
@@ -133,13 +133,13 @@ var require_visit = __commonJS({
133
133
  }
134
134
  }
135
135
  } else if (identity.isPair(node)) {
136
- path67 = Object.freeze(path67.concat(node));
137
- const ck = visit_("key", node.key, visitor, path67);
136
+ path69 = Object.freeze(path69.concat(node));
137
+ const ck = visit_("key", node.key, visitor, path69);
138
138
  if (ck === BREAK)
139
139
  return BREAK;
140
140
  else if (ck === REMOVE)
141
141
  node.key = null;
142
- const cv = visit_("value", node.value, visitor, path67);
142
+ const cv = visit_("value", node.value, visitor, path69);
143
143
  if (cv === BREAK)
144
144
  return BREAK;
145
145
  else if (cv === REMOVE)
@@ -160,17 +160,17 @@ var require_visit = __commonJS({
160
160
  visitAsync.BREAK = BREAK;
161
161
  visitAsync.SKIP = SKIP;
162
162
  visitAsync.REMOVE = REMOVE;
163
- async function visitAsync_(key, node, visitor, path67) {
164
- const ctrl = await callVisitor(key, node, visitor, path67);
163
+ async function visitAsync_(key, node, visitor, path69) {
164
+ const ctrl = await callVisitor(key, node, visitor, path69);
165
165
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
166
- replaceNode(key, path67, ctrl);
167
- return visitAsync_(key, ctrl, visitor, path67);
166
+ replaceNode(key, path69, ctrl);
167
+ return visitAsync_(key, ctrl, visitor, path69);
168
168
  }
169
169
  if (typeof ctrl !== "symbol") {
170
170
  if (identity.isCollection(node)) {
171
- path67 = Object.freeze(path67.concat(node));
171
+ path69 = Object.freeze(path69.concat(node));
172
172
  for (let i = 0; i < node.items.length; ++i) {
173
- const ci = await visitAsync_(i, node.items[i], visitor, path67);
173
+ const ci = await visitAsync_(i, node.items[i], visitor, path69);
174
174
  if (typeof ci === "number")
175
175
  i = ci - 1;
176
176
  else if (ci === BREAK)
@@ -181,13 +181,13 @@ var require_visit = __commonJS({
181
181
  }
182
182
  }
183
183
  } else if (identity.isPair(node)) {
184
- path67 = Object.freeze(path67.concat(node));
185
- const ck = await visitAsync_("key", node.key, visitor, path67);
184
+ path69 = Object.freeze(path69.concat(node));
185
+ const ck = await visitAsync_("key", node.key, visitor, path69);
186
186
  if (ck === BREAK)
187
187
  return BREAK;
188
188
  else if (ck === REMOVE)
189
189
  node.key = null;
190
- const cv = await visitAsync_("value", node.value, visitor, path67);
190
+ const cv = await visitAsync_("value", node.value, visitor, path69);
191
191
  if (cv === BREAK)
192
192
  return BREAK;
193
193
  else if (cv === REMOVE)
@@ -214,23 +214,23 @@ var require_visit = __commonJS({
214
214
  }
215
215
  return visitor;
216
216
  }
217
- function callVisitor(key, node, visitor, path67) {
217
+ function callVisitor(key, node, visitor, path69) {
218
218
  if (typeof visitor === "function")
219
- return visitor(key, node, path67);
219
+ return visitor(key, node, path69);
220
220
  if (identity.isMap(node))
221
- return visitor.Map?.(key, node, path67);
221
+ return visitor.Map?.(key, node, path69);
222
222
  if (identity.isSeq(node))
223
- return visitor.Seq?.(key, node, path67);
223
+ return visitor.Seq?.(key, node, path69);
224
224
  if (identity.isPair(node))
225
- return visitor.Pair?.(key, node, path67);
225
+ return visitor.Pair?.(key, node, path69);
226
226
  if (identity.isScalar(node))
227
- return visitor.Scalar?.(key, node, path67);
227
+ return visitor.Scalar?.(key, node, path69);
228
228
  if (identity.isAlias(node))
229
- return visitor.Alias?.(key, node, path67);
229
+ return visitor.Alias?.(key, node, path69);
230
230
  return void 0;
231
231
  }
232
- function replaceNode(key, path67, node) {
233
- const parent = path67[path67.length - 1];
232
+ function replaceNode(key, path69, node) {
233
+ const parent = path69[path69.length - 1];
234
234
  if (identity.isCollection(parent)) {
235
235
  parent.items[key] = node;
236
236
  } else if (identity.isPair(parent)) {
@@ -840,10 +840,10 @@ var require_Collection = __commonJS({
840
840
  var createNode = require_createNode();
841
841
  var identity = require_identity();
842
842
  var Node = require_Node();
843
- function collectionFromPath(schema, path67, value) {
843
+ function collectionFromPath(schema, path69, value) {
844
844
  let v = value;
845
- for (let i = path67.length - 1; i >= 0; --i) {
846
- const k = path67[i];
845
+ for (let i = path69.length - 1; i >= 0; --i) {
846
+ const k = path69[i];
847
847
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
848
848
  const a = [];
849
849
  a[k] = v;
@@ -862,7 +862,7 @@ var require_Collection = __commonJS({
862
862
  sourceObjects: /* @__PURE__ */ new Map()
863
863
  });
864
864
  }
865
- var isEmptyPath = (path67) => path67 == null || typeof path67 === "object" && !!path67[Symbol.iterator]().next().done;
865
+ var isEmptyPath = (path69) => path69 == null || typeof path69 === "object" && !!path69[Symbol.iterator]().next().done;
866
866
  var Collection = class extends Node.NodeBase {
867
867
  constructor(type, schema) {
868
868
  super(type);
@@ -892,11 +892,11 @@ var require_Collection = __commonJS({
892
892
  * be a Pair instance or a `{ key, value }` object, which may not have a key
893
893
  * that already exists in the map.
894
894
  */
895
- addIn(path67, value) {
896
- if (isEmptyPath(path67))
895
+ addIn(path69, value) {
896
+ if (isEmptyPath(path69))
897
897
  this.add(value);
898
898
  else {
899
- const [key, ...rest] = path67;
899
+ const [key, ...rest] = path69;
900
900
  const node = this.get(key, true);
901
901
  if (identity.isCollection(node))
902
902
  node.addIn(rest, value);
@@ -910,8 +910,8 @@ var require_Collection = __commonJS({
910
910
  * Removes a value from the collection.
911
911
  * @returns `true` if the item was found and removed.
912
912
  */
913
- deleteIn(path67) {
914
- const [key, ...rest] = path67;
913
+ deleteIn(path69) {
914
+ const [key, ...rest] = path69;
915
915
  if (rest.length === 0)
916
916
  return this.delete(key);
917
917
  const node = this.get(key, true);
@@ -925,8 +925,8 @@ var require_Collection = __commonJS({
925
925
  * scalar values from their surrounding node; to disable set `keepScalar` to
926
926
  * `true` (collections are always returned intact).
927
927
  */
928
- getIn(path67, keepScalar) {
929
- const [key, ...rest] = path67;
928
+ getIn(path69, keepScalar) {
929
+ const [key, ...rest] = path69;
930
930
  const node = this.get(key, true);
931
931
  if (rest.length === 0)
932
932
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -944,8 +944,8 @@ var require_Collection = __commonJS({
944
944
  /**
945
945
  * Checks if the collection includes a value with the key `key`.
946
946
  */
947
- hasIn(path67) {
948
- const [key, ...rest] = path67;
947
+ hasIn(path69) {
948
+ const [key, ...rest] = path69;
949
949
  if (rest.length === 0)
950
950
  return this.has(key);
951
951
  const node = this.get(key, true);
@@ -955,8 +955,8 @@ var require_Collection = __commonJS({
955
955
  * Sets a value in this collection. For `!!set`, `value` needs to be a
956
956
  * boolean to add/remove the item from the set.
957
957
  */
958
- setIn(path67, value) {
959
- const [key, ...rest] = path67;
958
+ setIn(path69, value) {
959
+ const [key, ...rest] = path69;
960
960
  if (rest.length === 0) {
961
961
  this.set(key, value);
962
962
  } else {
@@ -3471,9 +3471,9 @@ var require_Document = __commonJS({
3471
3471
  this.contents.add(value);
3472
3472
  }
3473
3473
  /** Adds a value to the document. */
3474
- addIn(path67, value) {
3474
+ addIn(path69, value) {
3475
3475
  if (assertCollection(this.contents))
3476
- this.contents.addIn(path67, value);
3476
+ this.contents.addIn(path69, value);
3477
3477
  }
3478
3478
  /**
3479
3479
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3548,14 +3548,14 @@ var require_Document = __commonJS({
3548
3548
  * Removes a value from the document.
3549
3549
  * @returns `true` if the item was found and removed.
3550
3550
  */
3551
- deleteIn(path67) {
3552
- if (Collection.isEmptyPath(path67)) {
3551
+ deleteIn(path69) {
3552
+ if (Collection.isEmptyPath(path69)) {
3553
3553
  if (this.contents == null)
3554
3554
  return false;
3555
3555
  this.contents = null;
3556
3556
  return true;
3557
3557
  }
3558
- return assertCollection(this.contents) ? this.contents.deleteIn(path67) : false;
3558
+ return assertCollection(this.contents) ? this.contents.deleteIn(path69) : false;
3559
3559
  }
3560
3560
  /**
3561
3561
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3570,10 +3570,10 @@ var require_Document = __commonJS({
3570
3570
  * scalar values from their surrounding node; to disable set `keepScalar` to
3571
3571
  * `true` (collections are always returned intact).
3572
3572
  */
3573
- getIn(path67, keepScalar) {
3574
- if (Collection.isEmptyPath(path67))
3573
+ getIn(path69, keepScalar) {
3574
+ if (Collection.isEmptyPath(path69))
3575
3575
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3576
- return identity.isCollection(this.contents) ? this.contents.getIn(path67, keepScalar) : void 0;
3576
+ return identity.isCollection(this.contents) ? this.contents.getIn(path69, keepScalar) : void 0;
3577
3577
  }
3578
3578
  /**
3579
3579
  * Checks if the document includes a value with the key `key`.
@@ -3584,10 +3584,10 @@ var require_Document = __commonJS({
3584
3584
  /**
3585
3585
  * Checks if the document includes a value at `path`.
3586
3586
  */
3587
- hasIn(path67) {
3588
- if (Collection.isEmptyPath(path67))
3587
+ hasIn(path69) {
3588
+ if (Collection.isEmptyPath(path69))
3589
3589
  return this.contents !== void 0;
3590
- return identity.isCollection(this.contents) ? this.contents.hasIn(path67) : false;
3590
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path69) : false;
3591
3591
  }
3592
3592
  /**
3593
3593
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3604,13 +3604,13 @@ var require_Document = __commonJS({
3604
3604
  * Sets a value in this document. For `!!set`, `value` needs to be a
3605
3605
  * boolean to add/remove the item from the set.
3606
3606
  */
3607
- setIn(path67, value) {
3608
- if (Collection.isEmptyPath(path67)) {
3607
+ setIn(path69, value) {
3608
+ if (Collection.isEmptyPath(path69)) {
3609
3609
  this.contents = value;
3610
3610
  } else if (this.contents == null) {
3611
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path67), value);
3611
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path69), value);
3612
3612
  } else if (assertCollection(this.contents)) {
3613
- this.contents.setIn(path67, value);
3613
+ this.contents.setIn(path69, value);
3614
3614
  }
3615
3615
  }
3616
3616
  /**
@@ -5570,9 +5570,9 @@ var require_cst_visit = __commonJS({
5570
5570
  visit.BREAK = BREAK;
5571
5571
  visit.SKIP = SKIP;
5572
5572
  visit.REMOVE = REMOVE;
5573
- visit.itemAtPath = (cst, path67) => {
5573
+ visit.itemAtPath = (cst, path69) => {
5574
5574
  let item = cst;
5575
- for (const [field, index] of path67) {
5575
+ for (const [field, index] of path69) {
5576
5576
  const tok = item?.[field];
5577
5577
  if (tok && "items" in tok) {
5578
5578
  item = tok.items[index];
@@ -5581,23 +5581,23 @@ var require_cst_visit = __commonJS({
5581
5581
  }
5582
5582
  return item;
5583
5583
  };
5584
- visit.parentCollection = (cst, path67) => {
5585
- const parent = visit.itemAtPath(cst, path67.slice(0, -1));
5586
- const field = path67[path67.length - 1][0];
5584
+ visit.parentCollection = (cst, path69) => {
5585
+ const parent = visit.itemAtPath(cst, path69.slice(0, -1));
5586
+ const field = path69[path69.length - 1][0];
5587
5587
  const coll = parent?.[field];
5588
5588
  if (coll && "items" in coll)
5589
5589
  return coll;
5590
5590
  throw new Error("Parent collection not found");
5591
5591
  };
5592
- function _visit(path67, item, visitor) {
5593
- let ctrl = visitor(item, path67);
5592
+ function _visit(path69, item, visitor) {
5593
+ let ctrl = visitor(item, path69);
5594
5594
  if (typeof ctrl === "symbol")
5595
5595
  return ctrl;
5596
5596
  for (const field of ["key", "value"]) {
5597
5597
  const token = item[field];
5598
5598
  if (token && "items" in token) {
5599
5599
  for (let i = 0; i < token.items.length; ++i) {
5600
- const ci = _visit(Object.freeze(path67.concat([[field, i]])), token.items[i], visitor);
5600
+ const ci = _visit(Object.freeze(path69.concat([[field, i]])), token.items[i], visitor);
5601
5601
  if (typeof ci === "number")
5602
5602
  i = ci - 1;
5603
5603
  else if (ci === BREAK)
@@ -5608,10 +5608,10 @@ var require_cst_visit = __commonJS({
5608
5608
  }
5609
5609
  }
5610
5610
  if (typeof ctrl === "function" && field === "key")
5611
- ctrl = ctrl(item, path67);
5611
+ ctrl = ctrl(item, path69);
5612
5612
  }
5613
5613
  }
5614
- return typeof ctrl === "function" ? ctrl(item, path67) : ctrl;
5614
+ return typeof ctrl === "function" ? ctrl(item, path69) : ctrl;
5615
5615
  }
5616
5616
  exports.visit = visit;
5617
5617
  }
@@ -6913,14 +6913,14 @@ var require_parser = __commonJS({
6913
6913
  case "scalar":
6914
6914
  case "single-quoted-scalar":
6915
6915
  case "double-quoted-scalar": {
6916
- const fs64 = this.flowScalar(this.type);
6916
+ const fs66 = this.flowScalar(this.type);
6917
6917
  if (atNextItem || it.value) {
6918
- map.items.push({ start, key: fs64, sep: [] });
6918
+ map.items.push({ start, key: fs66, sep: [] });
6919
6919
  this.onKeyLine = true;
6920
6920
  } else if (it.sep) {
6921
- this.stack.push(fs64);
6921
+ this.stack.push(fs66);
6922
6922
  } else {
6923
- Object.assign(it, { key: fs64, sep: [] });
6923
+ Object.assign(it, { key: fs66, sep: [] });
6924
6924
  this.onKeyLine = true;
6925
6925
  }
6926
6926
  return;
@@ -7048,13 +7048,13 @@ var require_parser = __commonJS({
7048
7048
  case "scalar":
7049
7049
  case "single-quoted-scalar":
7050
7050
  case "double-quoted-scalar": {
7051
- const fs64 = this.flowScalar(this.type);
7051
+ const fs66 = this.flowScalar(this.type);
7052
7052
  if (!it || it.value)
7053
- fc.items.push({ start: [], key: fs64, sep: [] });
7053
+ fc.items.push({ start: [], key: fs66, sep: [] });
7054
7054
  else if (it.sep)
7055
- this.stack.push(fs64);
7055
+ this.stack.push(fs66);
7056
7056
  else
7057
- Object.assign(it, { key: fs64, sep: [] });
7057
+ Object.assign(it, { key: fs66, sep: [] });
7058
7058
  return;
7059
7059
  }
7060
7060
  case "flow-map-end":
@@ -7363,15 +7363,15 @@ var require_dist = __commonJS({
7363
7363
  });
7364
7364
 
7365
7365
  // src/scripts/hooks/dispatch_entry.ts
7366
- import * as path66 from "node:path";
7367
- import { fileURLToPath as fileURLToPath47 } from "node:url";
7366
+ import * as path68 from "node:path";
7367
+ import { fileURLToPath as fileURLToPath48 } from "node:url";
7368
7368
 
7369
7369
  // src/scripts/hooks/dispatch_hook.ts
7370
7370
  var import_yaml6 = __toESM(require_dist(), 1);
7371
7371
  import { spawnSync as spawnSync7 } from "node:child_process";
7372
- import fs63 from "node:fs";
7373
- import path65 from "node:path";
7374
- import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL40 } from "node:url";
7372
+ import fs65 from "node:fs";
7373
+ import path67 from "node:path";
7374
+ import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL41 } from "node:url";
7375
7375
 
7376
7376
  // src/scripts/_lib/spawn_env.ts
7377
7377
  var DENY_EXACT = /* @__PURE__ */ new Set([
@@ -22995,6 +22995,44 @@ import fs51 from "node:fs";
22995
22995
  import path52 from "node:path";
22996
22996
  import { fileURLToPath as fileURLToPath37, pathToFileURL as pathToFileURL30 } from "node:url";
22997
22997
 
22998
+ // src/scripts/_lib/ui_surface.ts
22999
+ var UI_EXTENSIONS = [
23000
+ "html",
23001
+ "htm",
23002
+ "css",
23003
+ "scss",
23004
+ "sass",
23005
+ "less",
23006
+ "vue",
23007
+ "svelte",
23008
+ "astro",
23009
+ "jsx",
23010
+ "tsx"
23011
+ ];
23012
+ var UI_COMPOUND_SUFFIXES = [".blade.php"];
23013
+ var UI_EXT = new RegExp(
23014
+ `(\\.(${UI_EXTENSIONS.join("|")})|${UI_COMPOUND_SUFFIXES.map((s) => s.replace(/\./g, "\\.")).join("|")})$`,
23015
+ "i"
23016
+ );
23017
+ function isUiPath(p) {
23018
+ return UI_EXT.test(p);
23019
+ }
23020
+ var UI_PATH_FRAGMENTS = [
23021
+ "resources/views/",
23022
+ "resources/js/",
23023
+ // `components/` already subsumes `src/components/` under substring
23024
+ // matching — listing both here would be dead weight. The rules' own
23025
+ // `path_prefix` list keeps both because matching there is anchored.
23026
+ "components/",
23027
+ "pages/"
23028
+ ];
23029
+ var UI_TREE_EXCLUSIONS = ["pages/api/"];
23030
+ function isUiTreePath(p) {
23031
+ const normalized = p.replace(/\\/g, "/").toLowerCase();
23032
+ if (UI_TREE_EXCLUSIONS.some((fragment) => normalized.includes(fragment))) return false;
23033
+ return UI_PATH_FRAGMENTS.some((fragment) => normalized.includes(fragment));
23034
+ }
23035
+
22998
23036
  // src/scripts/lint_design_slop.ts
22999
23037
  import fs50 from "node:fs";
23000
23038
  import path51 from "node:path";
@@ -23584,7 +23622,6 @@ var SETTINGS_FILE7 = ".agent-settings.yml";
23584
23622
  var EXIT_ALLOW13 = 0;
23585
23623
  var EXIT_WARN6 = 2;
23586
23624
  var DEGRADE_AFTER = 3;
23587
- var UI_EXT = /\.(html|htm|css|scss|sass|less|vue|svelte|astro|jsx|tsx)$/i;
23588
23625
  function isObject2(v) {
23589
23626
  return typeof v === "object" && v !== null && !Array.isArray(v);
23590
23627
  }
@@ -23993,11 +24030,180 @@ function isCliEntry11() {
23993
24030
  }
23994
24031
  if (isCliEntry11()) process.exit(main36());
23995
24032
 
23996
- // src/scripts/hooks/orchestration_record_hook.ts
23997
- import * as crypto4 from "node:crypto";
24033
+ // src/scripts/hooks/ui_route_nudge_hook.ts
23998
24034
  import * as fs55 from "node:fs";
23999
24035
  import * as path56 from "node:path";
24000
- import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL33 } from "node:url";
24036
+ import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL32 } from "node:url";
24037
+
24038
+ // src/scripts/_lib/hook_settings.ts
24039
+ import * as fs54 from "node:fs";
24040
+ import * as path55 from "node:path";
24041
+ var SETTINGS_FILE9 = ".agent-settings.yml";
24042
+ function hookSectionEnabled(root, section) {
24043
+ const file = path55.join(root, SETTINGS_FILE9);
24044
+ let text;
24045
+ try {
24046
+ if (!fs54.statSync(file).isFile()) return false;
24047
+ text = fs54.readFileSync(file, "utf-8");
24048
+ } catch {
24049
+ return false;
24050
+ }
24051
+ const escaped = section.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24052
+ const sectionPattern = new RegExp(`^(\\s+)${escaped}\\s*:\\s*$`);
24053
+ let inHooks = false;
24054
+ let sectionIndent = null;
24055
+ const indentOf = (line) => line.length - line.replace(/^\s+/, "").length;
24056
+ for (const raw of text.split(/\r\n|\r|\n/)) {
24057
+ const line = raw.replace(/\s+$/, "");
24058
+ if (!line || line.replace(/^\s+/, "").startsWith("#")) continue;
24059
+ if (!(line.startsWith(" ") || line.startsWith(" "))) {
24060
+ inHooks = /^hooks\s*:\s*$/.test(line);
24061
+ sectionIndent = null;
24062
+ continue;
24063
+ }
24064
+ if (inHooks) {
24065
+ const opened = sectionPattern.exec(line);
24066
+ if (opened) {
24067
+ sectionIndent = opened[1].length;
24068
+ continue;
24069
+ }
24070
+ if (sectionIndent !== null && indentOf(line) <= sectionIndent) {
24071
+ sectionIndent = null;
24072
+ }
24073
+ }
24074
+ if (sectionIndent !== null && /^\s+enabled\s*:\s*true\b/.test(line)) return true;
24075
+ }
24076
+ return false;
24077
+ }
24078
+
24079
+ // src/scripts/hooks/ui_route_nudge_hook.ts
24080
+ var EXIT_ALLOW15 = 0;
24081
+ var EXIT_WARN8 = 2;
24082
+ var MAX_NUDGES = 2;
24083
+ var DESIGN_SURFACES = [
24084
+ "fe-design",
24085
+ "existing-ui-audit",
24086
+ "design-review",
24087
+ "design-intelligence"
24088
+ ];
24089
+ function isObject4(v) {
24090
+ return typeof v === "object" && v !== null && !Array.isArray(v);
24091
+ }
24092
+ function unwrap2(envelope) {
24093
+ const inner = envelope["payload"];
24094
+ return isObject4(inner) ? inner : envelope;
24095
+ }
24096
+ function extractEvent(outer) {
24097
+ const envelope = unwrap2(outer);
24098
+ const ti = envelope["tool_input"] ?? envelope["toolInput"] ?? envelope["input"];
24099
+ if (!isObject4(ti)) return null;
24100
+ const fileVal = ti["file_path"] ?? ti["path"] ?? ti["filePath"];
24101
+ const file = typeof fileVal === "string" ? fileVal : "";
24102
+ let isWrite = false;
24103
+ for (const key of ["content", "new_string", "new_str", "text", "newText"]) {
24104
+ if (typeof ti[key] === "string" && ti[key].length > 0) isWrite = true;
24105
+ }
24106
+ return { file, isWrite };
24107
+ }
24108
+ function isConsultation(event) {
24109
+ if (event.isWrite || !event.file) return false;
24110
+ const normalized = event.file.replace(/\\/g, "/").toLowerCase();
24111
+ return DESIGN_SURFACES.some((surface) => normalized.includes(`skills/${surface}/`));
24112
+ }
24113
+ function isUiWrite(event) {
24114
+ if (!event.isWrite || !event.file) return false;
24115
+ return isUiPath(event.file) || isUiTreePath(event.file);
24116
+ }
24117
+ function stateFile2(root) {
24118
+ return path56.join(root, "agents", "runtime", "state", "ui-route-nudge.json");
24119
+ }
24120
+ function readState2(root, session) {
24121
+ try {
24122
+ const all = JSON.parse(fs55.readFileSync(stateFile2(root), "utf-8"));
24123
+ const entry = all[session];
24124
+ if (entry && typeof entry.consulted === "boolean" && typeof entry.nudges === "number") {
24125
+ return entry;
24126
+ }
24127
+ } catch {
24128
+ }
24129
+ return { consulted: false, nudges: 0 };
24130
+ }
24131
+ var MAX_SESSIONS = 50;
24132
+ function pruneSessions(all, keep = MAX_SESSIONS) {
24133
+ const keys = Object.keys(all);
24134
+ if (keys.length <= keep) return all;
24135
+ const survivors = keys.slice(keys.length - keep);
24136
+ const pruned = {};
24137
+ for (const key of survivors) pruned[key] = all[key];
24138
+ return pruned;
24139
+ }
24140
+ function writeState2(root, session, state) {
24141
+ try {
24142
+ const file = stateFile2(root);
24143
+ let all = {};
24144
+ try {
24145
+ all = JSON.parse(fs55.readFileSync(file, "utf-8"));
24146
+ } catch {
24147
+ }
24148
+ if (typeof all !== "object" || all === null || Array.isArray(all)) all = {};
24149
+ all[session] = state;
24150
+ fs55.mkdirSync(path56.dirname(file), { recursive: true });
24151
+ fs55.writeFileSync(file, JSON.stringify(pruneSessions(all)));
24152
+ } catch {
24153
+ }
24154
+ }
24155
+ function decide4(event, state) {
24156
+ if (isConsultation(event)) {
24157
+ return { state: { ...state, consulted: true }, warn: false };
24158
+ }
24159
+ if (!isUiWrite(event)) return { state, warn: false };
24160
+ if (state.consulted) return { state, warn: false };
24161
+ if (state.nudges >= MAX_NUDGES) return { state, warn: false };
24162
+ return { state: { ...state, nudges: state.nudges + 1 }, warn: true };
24163
+ }
24164
+ function nudgeReason2(file) {
24165
+ return `Non-trivial UI write to ${file} with no design consultation this session. Run \`existing-ui-audit\` first, then the fe-design loop (brief \u2192 build \u2192 review). Skip only if this is ui-trivial: <=1 file, <=5 lines, no new component, no new state, no new dependency.`;
24166
+ }
24167
+ function main37() {
24168
+ let envelope;
24169
+ try {
24170
+ const raw = readHookStdin();
24171
+ if (!raw.trim()) return EXIT_ALLOW15;
24172
+ envelope = JSON.parse(raw);
24173
+ } catch {
24174
+ return EXIT_ALLOW15;
24175
+ }
24176
+ if (!isObject4(envelope)) return EXIT_ALLOW15;
24177
+ const rootVal = envelope["workspace_root"];
24178
+ const root = typeof rootVal === "string" && rootVal ? rootVal : process.cwd();
24179
+ if (!hookSectionEnabled(root, "ui_route_nudge")) return EXIT_ALLOW15;
24180
+ const sessionVal = envelope["session_id"];
24181
+ const session = typeof sessionVal === "string" && sessionVal ? sessionVal : "unknown";
24182
+ const event = extractEvent(envelope);
24183
+ if (!event) return EXIT_ALLOW15;
24184
+ const before = readState2(root, session);
24185
+ const { state, warn } = decide4(event, before);
24186
+ if (state.consulted !== before.consulted || state.nudges !== before.nudges) {
24187
+ writeState2(root, session, state);
24188
+ }
24189
+ if (!warn) return EXIT_ALLOW15;
24190
+ process.stdout.write(`${JSON.stringify({ reason: nudgeReason2(event.file) })}
24191
+ `);
24192
+ return EXIT_WARN8;
24193
+ }
24194
+ function isCliEntry12() {
24195
+ const entry = process.argv[1];
24196
+ if (!entry) return false;
24197
+ return pathToFileURL32(path56.resolve(entry)).href === import.meta.url;
24198
+ }
24199
+ if (isCliEntry12()) process.exit(main37());
24200
+ var _HOOK_FILE = fileURLToPath39(import.meta.url);
24201
+
24202
+ // src/scripts/hooks/orchestration_record_hook.ts
24203
+ import * as crypto4 from "node:crypto";
24204
+ import * as fs57 from "node:fs";
24205
+ import * as path58 from "node:path";
24206
+ import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL34 } from "node:url";
24001
24207
 
24002
24208
  // src/scripts/_lib/orchestration_record.ts
24003
24209
  var DISPATCH_OUTCOMES = ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED", "killed"];
@@ -24193,9 +24399,9 @@ function buildOrchestrationLine(input) {
24193
24399
 
24194
24400
  // src/scripts/orchestration_record.ts
24195
24401
  import * as crypto3 from "node:crypto";
24196
- import * as fs54 from "node:fs";
24197
- import * as path55 from "node:path";
24198
- import { pathToFileURL as pathToFileURL32 } from "node:url";
24402
+ import * as fs56 from "node:fs";
24403
+ import * as path57 from "node:path";
24404
+ import { pathToFileURL as pathToFileURL33 } from "node:url";
24199
24405
  var DEFAULT_DIR = "agents/runtime/state/audit";
24200
24406
  function parseFlags(argv) {
24201
24407
  const flags = {};
@@ -24245,7 +24451,7 @@ function contentHashId(input) {
24245
24451
  });
24246
24452
  return crypto3.createHash("sha256").update(canonical).digest("hex").slice(0, 26).toUpperCase();
24247
24453
  }
24248
- function main37(argv = process.argv.slice(2)) {
24454
+ function main38(argv = process.argv.slice(2)) {
24249
24455
  const flags = parseFlags(argv);
24250
24456
  const dir = str2(flags, "dir") ?? DEFAULT_DIR;
24251
24457
  const dryRun = flags["dry-run"] === true;
@@ -24306,27 +24512,27 @@ function main37(argv = process.argv.slice(2)) {
24306
24512
  process.stdout.write(serialized + "\n");
24307
24513
  return 0;
24308
24514
  }
24309
- fs54.mkdirSync(dir, { recursive: true });
24310
- const file = path55.join(dir, `${ts.slice(0, 7)}.jsonl`);
24311
- fs54.appendFileSync(file, serialized + "\n", "utf8");
24515
+ fs56.mkdirSync(dir, { recursive: true });
24516
+ const file = path57.join(dir, `${ts.slice(0, 7)}.jsonl`);
24517
+ fs56.appendFileSync(file, serialized + "\n", "utf8");
24312
24518
  process.stdout.write(`orchestration telemetry recorded \u2192 ${file} (id ${line.id})
24313
24519
  `);
24314
24520
  return 0;
24315
24521
  }
24316
24522
  if (process.argv[1] !== void 0) {
24317
- const invokedUrl = pathToFileURL32(path55.resolve(process.argv[1])).href;
24318
- if (import.meta.url === invokedUrl) process.exit(main37());
24523
+ const invokedUrl = pathToFileURL33(path57.resolve(process.argv[1])).href;
24524
+ if (import.meta.url === invokedUrl) process.exit(main38());
24319
24525
  }
24320
24526
 
24321
24527
  // src/scripts/hooks/orchestration_record_hook.ts
24322
- var EXIT_ALLOW15 = 0;
24323
- function isObject4(v) {
24528
+ var EXIT_ALLOW16 = 0;
24529
+ function isObject5(v) {
24324
24530
  return typeof v === "object" && v !== null && !Array.isArray(v);
24325
24531
  }
24326
24532
  var DISPATCH_TOOL_NAMES = /* @__PURE__ */ new Set(["Agent", "Task"]);
24327
24533
  function unwrapPayload(envelope) {
24328
24534
  const inner = envelope["payload"];
24329
- return isObject4(inner) ? inner : envelope;
24535
+ return isObject5(inner) ? inner : envelope;
24330
24536
  }
24331
24537
  function extractToolName(payload) {
24332
24538
  const v = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
@@ -24334,12 +24540,12 @@ function extractToolName(payload) {
24334
24540
  }
24335
24541
  function extractToolInput(payload) {
24336
24542
  const v = payload["tool_input"] ?? payload["toolInput"];
24337
- return isObject4(v) ? v : null;
24543
+ return isObject5(v) ? v : null;
24338
24544
  }
24339
24545
  function extractToolResult(payload) {
24340
24546
  for (const key of ["tool_response", "toolResponse", "tool_result", "toolUseResult"]) {
24341
24547
  const v = payload[key];
24342
- if (isObject4(v)) return v;
24548
+ if (isObject5(v)) return v;
24343
24549
  }
24344
24550
  return null;
24345
24551
  }
@@ -24360,7 +24566,7 @@ function extractDispatchFacts(payload) {
24360
24566
  const result = extractToolResult(payload);
24361
24567
  const resolvedModel = result && typeof result["resolvedModel"] === "string" ? result["resolvedModel"] : null;
24362
24568
  let totalTokens = result ? numOrNull(result["totalTokens"]) : null;
24363
- if (totalTokens === null && result && isObject4(result["usage"])) {
24569
+ if (totalTokens === null && result && isObject5(result["usage"])) {
24364
24570
  const usage = result["usage"];
24365
24571
  const inTok = numOrNull(usage["input_tokens"]);
24366
24572
  const outTok = numOrNull(usage["output_tokens"]);
@@ -24409,35 +24615,35 @@ function buildRecordInput(facts, ts, id) {
24409
24615
  return input;
24410
24616
  }
24411
24617
  function auditFileFor(consumerRoot, ts) {
24412
- return path56.join(consumerRoot, DEFAULT_DIR, `${ts.slice(0, 7)}.jsonl`);
24618
+ return path58.join(consumerRoot, DEFAULT_DIR, `${ts.slice(0, 7)}.jsonl`);
24413
24619
  }
24414
24620
  function appendLine(consumerRoot, ts, line) {
24415
24621
  if (is_replay_mode()) return;
24416
24622
  const file = auditFileFor(consumerRoot, ts);
24417
- fs55.mkdirSync(path56.dirname(file), { recursive: true });
24418
- fs55.appendFileSync(file, `${JSON.stringify(line)}
24623
+ fs57.mkdirSync(path58.dirname(file), { recursive: true });
24624
+ fs57.appendFileSync(file, `${JSON.stringify(line)}
24419
24625
  `, "utf8");
24420
24626
  }
24421
24627
  function processEnvelope(envelope, consumer_root) {
24422
24628
  try {
24423
- if (!isObject4(envelope)) return EXIT_ALLOW15;
24629
+ if (!isObject5(envelope)) return EXIT_ALLOW16;
24424
24630
  const payload = unwrapPayload(envelope);
24425
24631
  const toolName = extractToolName(payload);
24426
- if (toolName === null || !DISPATCH_TOOL_NAMES.has(toolName)) return EXIT_ALLOW15;
24632
+ if (toolName === null || !DISPATCH_TOOL_NAMES.has(toolName)) return EXIT_ALLOW16;
24427
24633
  const facts = extractDispatchFacts(payload);
24428
24634
  const ts = (/* @__PURE__ */ new Date()).toISOString();
24429
24635
  const id = crypto4.randomUUID();
24430
24636
  const input = buildRecordInput(facts, ts, id);
24431
24637
  const { line, errors } = buildOrchestrationLine(input);
24432
- if (errors.length || line === null) return EXIT_ALLOW15;
24638
+ if (errors.length || line === null) return EXIT_ALLOW16;
24433
24639
  appendLine(consumer_root, ts, line);
24434
24640
  } catch {
24435
- return EXIT_ALLOW15;
24641
+ return EXIT_ALLOW16;
24436
24642
  }
24437
- return EXIT_ALLOW15;
24643
+ return EXIT_ALLOW16;
24438
24644
  }
24439
24645
  function _resolveRoot(envelope) {
24440
- if (isObject4(envelope)) {
24646
+ if (isObject5(envelope)) {
24441
24647
  const cwd = envelope["cwd"];
24442
24648
  if (typeof cwd === "string" && cwd) return cwd;
24443
24649
  const pr = envelope["workspace_root"] ?? envelope["project_root"];
@@ -24445,13 +24651,13 @@ function _resolveRoot(envelope) {
24445
24651
  }
24446
24652
  return process.cwd();
24447
24653
  }
24448
- function main38() {
24654
+ function main39() {
24449
24655
  const raw = readHookStdin();
24450
24656
  let envelope = {};
24451
24657
  try {
24452
24658
  envelope = raw.trim() ? JSON.parse(raw) : {};
24453
24659
  } catch {
24454
- return EXIT_ALLOW15;
24660
+ return EXIT_ALLOW16;
24455
24661
  }
24456
24662
  return processEnvelope(envelope, _resolveRoot(envelope));
24457
24663
  }
@@ -24460,20 +24666,20 @@ function _isCliEntry29() {
24460
24666
  return false;
24461
24667
  }
24462
24668
  if (process.argv[1] === void 0) return false;
24463
- const argvUrl = pathToFileURL33(path56.resolve(process.argv[1])).href;
24669
+ const argvUrl = pathToFileURL34(path58.resolve(process.argv[1])).href;
24464
24670
  if (import.meta.url === argvUrl) return true;
24465
24671
  try {
24466
- return fs55.realpathSync(fileURLToPath39(import.meta.url)) === fs55.realpathSync(path56.resolve(process.argv[1]));
24672
+ return fs57.realpathSync(fileURLToPath40(import.meta.url)) === fs57.realpathSync(path58.resolve(process.argv[1]));
24467
24673
  } catch {
24468
24674
  return false;
24469
24675
  }
24470
24676
  }
24471
- if (_isCliEntry29()) process.exit(main38());
24677
+ if (_isCliEntry29()) process.exit(main39());
24472
24678
 
24473
24679
  // src/scripts/hooks/delegation_nudge_hook.ts
24474
- import fs56 from "node:fs";
24475
- import path57 from "node:path";
24476
- import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL34 } from "node:url";
24680
+ import fs58 from "node:fs";
24681
+ import path59 from "node:path";
24682
+ import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL35 } from "node:url";
24477
24683
 
24478
24684
  // src/scripts/_lib/host_capability.ts
24479
24685
  import process10 from "node:process";
@@ -24808,8 +25014,8 @@ function resolveSubagentRouting(inp) {
24808
25014
  }
24809
25015
 
24810
25016
  // src/scripts/hooks/delegation_nudge_hook.ts
24811
- var EXIT_ALLOW16 = 0;
24812
- var EXIT_WARN8 = 2;
25017
+ var EXIT_ALLOW17 = 0;
25018
+ var EXIT_WARN9 = 2;
24813
25019
  function _isObject13(v) {
24814
25020
  return typeof v === "object" && v !== null && !Array.isArray(v);
24815
25021
  }
@@ -24966,34 +25172,34 @@ function _workspaceRoot3(envelope) {
24966
25172
  }
24967
25173
  return process.cwd();
24968
25174
  }
24969
- function main39() {
25175
+ function main40() {
24970
25176
  let envelope = {};
24971
25177
  try {
24972
25178
  const raw = readHookStdin();
24973
25179
  envelope = raw.trim() ? JSON.parse(raw) : {};
24974
25180
  } catch {
24975
- return EXIT_ALLOW16;
25181
+ return EXIT_ALLOW17;
24976
25182
  }
24977
25183
  const env = _isObject13(envelope) ? envelope : {};
24978
25184
  const event = env["event"];
24979
25185
  const slot = typeof event === "string" && event !== "" ? event : "user_prompt_submit";
24980
25186
  if (slot !== "user_prompt_submit") {
24981
- return EXIT_ALLOW16;
25187
+ return EXIT_ALLOW17;
24982
25188
  }
24983
25189
  const payload = _isObject13(env["payload"]) ? env["payload"] : env;
24984
25190
  const prompt = _extractPrompt2(payload);
24985
25191
  if (!prompt) {
24986
- return EXIT_ALLOW16;
25192
+ return EXIT_ALLOW17;
24987
25193
  }
24988
25194
  if (isSyntheticPrompt(prompt)) {
24989
- return EXIT_ALLOW16;
25195
+ return EXIT_ALLOW17;
24990
25196
  }
24991
25197
  const root = _workspaceRoot3(env);
24992
25198
  const platform = env["platform"];
24993
25199
  const hostId = typeof platform === "string" && platform ? platform : null;
24994
25200
  const result = classifyPrompt(prompt, root, hostId);
24995
25201
  if (!result) {
24996
- return EXIT_ALLOW16;
25202
+ return EXIT_ALLOW17;
24997
25203
  }
24998
25204
  process.stdout.write(
24999
25205
  `${JSON.stringify({
@@ -25003,7 +25209,7 @@ function main39() {
25003
25209
  })}
25004
25210
  `
25005
25211
  );
25006
- return EXIT_WARN8;
25212
+ return EXIT_WARN9;
25007
25213
  }
25008
25214
  function _isCliEntry30() {
25009
25215
  if (true) {
@@ -25012,29 +25218,29 @@ function _isCliEntry30() {
25012
25218
  if (process.argv[1] === void 0) {
25013
25219
  return false;
25014
25220
  }
25015
- const argvUrl = pathToFileURL34(path57.resolve(process.argv[1])).href;
25221
+ const argvUrl = pathToFileURL35(path59.resolve(process.argv[1])).href;
25016
25222
  if (import.meta.url === argvUrl) {
25017
25223
  return true;
25018
25224
  }
25019
25225
  try {
25020
- const here = fs56.realpathSync(fileURLToPath40(import.meta.url));
25021
- const argv = fs56.realpathSync(path57.resolve(process.argv[1]));
25226
+ const here = fs58.realpathSync(fileURLToPath41(import.meta.url));
25227
+ const argv = fs58.realpathSync(path59.resolve(process.argv[1]));
25022
25228
  return here === argv;
25023
25229
  } catch {
25024
25230
  return false;
25025
25231
  }
25026
25232
  }
25027
25233
  if (_isCliEntry30()) {
25028
- process.exit(main39());
25234
+ process.exit(main40());
25029
25235
  }
25030
25236
 
25031
25237
  // src/scripts/hooks/end_review_nudge_hook.ts
25032
25238
  import { spawnSync as spawnSync5 } from "node:child_process";
25033
25239
  import * as crypto5 from "node:crypto";
25034
- import * as fs57 from "node:fs";
25240
+ import * as fs59 from "node:fs";
25035
25241
  import * as os6 from "node:os";
25036
- import * as path58 from "node:path";
25037
- import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL35 } from "node:url";
25242
+ import * as path60 from "node:path";
25243
+ import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL36 } from "node:url";
25038
25244
 
25039
25245
  // src/scripts/_lib/review_skipped_record.ts
25040
25246
  function isNonNegInt(n) {
@@ -25081,19 +25287,19 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
25081
25287
  const homeDir = opts.homeDir ?? os6.homedir();
25082
25288
  const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
25083
25289
  try {
25084
- const realHome = fs57.realpathSync(homeDir);
25085
- const realPath = fs57.realpathSync(rawPath);
25086
- const relative9 = path58.relative(realHome, realPath);
25087
- if (relative9 === "" || relative9.startsWith("..") || path58.isAbsolute(relative9)) {
25290
+ const realHome = fs59.realpathSync(homeDir);
25291
+ const realPath = fs59.realpathSync(rawPath);
25292
+ const relative9 = path60.relative(realHome, realPath);
25293
+ if (relative9 === "" || relative9.startsWith("..") || path60.isAbsolute(relative9)) {
25088
25294
  return false;
25089
25295
  }
25090
- const { size } = fs57.statSync(realPath);
25296
+ const { size } = fs59.statSync(realPath);
25091
25297
  return size <= maxBytes;
25092
25298
  } catch {
25093
25299
  return false;
25094
25300
  }
25095
25301
  }
25096
- var EXIT_WARN9 = 2;
25302
+ var EXIT_WARN10 = 2;
25097
25303
  function parseNumstat(raw) {
25098
25304
  const rows = [];
25099
25305
  for (const line of raw.split("\n")) {
@@ -25166,7 +25372,7 @@ function totalNonDocMutatedLinesWithMeasure(cwd) {
25166
25372
  );
25167
25373
  return { lines: trackedLines + untrackedLines, measure: "exact" };
25168
25374
  }
25169
- function isObject5(v) {
25375
+ function isObject6(v) {
25170
25376
  return typeof v === "object" && v !== null && !Array.isArray(v);
25171
25377
  }
25172
25378
  function str3(v) {
@@ -25186,16 +25392,16 @@ function scanTranscriptForReviewer(transcriptText) {
25186
25392
  } catch {
25187
25393
  continue;
25188
25394
  }
25189
- if (!isObject5(obj) || obj["type"] !== "assistant") continue;
25395
+ if (!isObject6(obj) || obj["type"] !== "assistant") continue;
25190
25396
  const msg = obj["message"];
25191
- if (!isObject5(msg)) continue;
25397
+ if (!isObject6(msg)) continue;
25192
25398
  const content = msg["content"];
25193
25399
  if (!Array.isArray(content)) continue;
25194
25400
  for (const blk of content) {
25195
- if (!isObject5(blk) || blk["type"] !== "tool_use") continue;
25401
+ if (!isObject6(blk) || blk["type"] !== "tool_use") continue;
25196
25402
  const name = str3(blk["name"]);
25197
25403
  const input = blk["input"];
25198
- const inputObj = isObject5(input) ? input : {};
25404
+ const inputObj = isObject6(input) ? input : {};
25199
25405
  if (DISPATCH_TOOL_RE.test(name)) {
25200
25406
  const label = [
25201
25407
  str3(inputObj["description"]),
@@ -25230,19 +25436,19 @@ function appendReviewSkippedTelemetry(workspaceRoot2, diffLines, mutationMeasure
25230
25436
  });
25231
25437
  if (errors.length || line === null) return;
25232
25438
  try {
25233
- const dir = path58.join(workspaceRoot2, "agents", "runtime", "state", "audit");
25234
- fs57.mkdirSync(dir, { recursive: true });
25235
- const file = path58.join(dir, `${ts.slice(0, 7)}.jsonl`);
25236
- fs57.appendFileSync(file, `${JSON.stringify(line)}
25439
+ const dir = path60.join(workspaceRoot2, "agents", "runtime", "state", "audit");
25440
+ fs59.mkdirSync(dir, { recursive: true });
25441
+ const file = path60.join(dir, `${ts.slice(0, 7)}.jsonl`);
25442
+ fs59.appendFileSync(file, `${JSON.stringify(line)}
25237
25443
  `, "utf8");
25238
25444
  } catch {
25239
25445
  }
25240
25446
  }
25241
25447
  function sessionStateDir(workspaceRoot2) {
25242
- return path58.join(workspaceRoot2, "agents", "runtime", "state", "end-review-nudge");
25448
+ return path60.join(workspaceRoot2, "agents", "runtime", "state", "end-review-nudge");
25243
25449
  }
25244
25450
  function sessionStateFile(workspaceRoot2, sessionKey) {
25245
- return path58.join(sessionStateDir(workspaceRoot2), `${sessionKey}.json`);
25451
+ return path60.join(sessionStateDir(workspaceRoot2), `${sessionKey}.json`);
25246
25452
  }
25247
25453
  function deriveSessionKey(envelope, payload) {
25248
25454
  const raw = str3(envelope["session_id"]) || str3(payload["transcript_path"] ?? payload["transcriptPath"]);
@@ -25251,7 +25457,7 @@ function deriveSessionKey(envelope, payload) {
25251
25457
  }
25252
25458
  function hasFiredThisSession(workspaceRoot2, sessionKey) {
25253
25459
  try {
25254
- return fs57.existsSync(sessionStateFile(workspaceRoot2, sessionKey));
25460
+ return fs59.existsSync(sessionStateFile(workspaceRoot2, sessionKey));
25255
25461
  } catch {
25256
25462
  return false;
25257
25463
  }
@@ -25265,7 +25471,7 @@ function markFiredThisSession(workspaceRoot2, sessionKey, ts) {
25265
25471
  function _read_stdin3() {
25266
25472
  return readHookStdin();
25267
25473
  }
25268
- function main40() {
25474
+ function main41() {
25269
25475
  const [envelope, payload] = unwrap(_read_stdin3(), "claude");
25270
25476
  const event = String(envelope["event"] ?? "");
25271
25477
  if (event !== "" && event !== "stop") {
@@ -25294,7 +25500,7 @@ function main40() {
25294
25500
  let reviewerRan = false;
25295
25501
  if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
25296
25502
  try {
25297
- reviewerRan = scanTranscriptForReviewer(fs57.readFileSync(transcriptPath, "utf-8"));
25503
+ reviewerRan = scanTranscriptForReviewer(fs59.readFileSync(transcriptPath, "utf-8"));
25298
25504
  } catch {
25299
25505
  reviewerRan = false;
25300
25506
  }
@@ -25315,7 +25521,7 @@ function main40() {
25315
25521
  })}
25316
25522
  `
25317
25523
  );
25318
- return EXIT_WARN9;
25524
+ return EXIT_WARN10;
25319
25525
  }
25320
25526
  function _isCliEntry31() {
25321
25527
  if (true) {
@@ -25324,29 +25530,29 @@ function _isCliEntry31() {
25324
25530
  if (process.argv[1] === void 0) {
25325
25531
  return false;
25326
25532
  }
25327
- const argvUrl = pathToFileURL35(path58.resolve(process.argv[1])).href;
25533
+ const argvUrl = pathToFileURL36(path60.resolve(process.argv[1])).href;
25328
25534
  if (import.meta.url === argvUrl) {
25329
25535
  return true;
25330
25536
  }
25331
25537
  try {
25332
- const here = fs57.realpathSync(fileURLToPath41(import.meta.url));
25333
- const argv = fs57.realpathSync(path58.resolve(process.argv[1]));
25538
+ const here = fs59.realpathSync(fileURLToPath42(import.meta.url));
25539
+ const argv = fs59.realpathSync(path60.resolve(process.argv[1]));
25334
25540
  return here === argv;
25335
25541
  } catch {
25336
25542
  return false;
25337
25543
  }
25338
25544
  }
25339
25545
  if (_isCliEntry31()) {
25340
- process.exit(main40());
25546
+ process.exit(main41());
25341
25547
  }
25342
25548
 
25343
25549
  // src/scripts/hooks/turn_end_gate_hook.ts
25344
25550
  import * as crypto6 from "node:crypto";
25345
- import * as fs58 from "node:fs";
25346
- import * as path59 from "node:path";
25347
- import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL36 } from "node:url";
25551
+ import * as fs60 from "node:fs";
25552
+ import * as path61 from "node:path";
25553
+ import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL37 } from "node:url";
25348
25554
  var EXIT_BLOCK4 = 1;
25349
- var EXIT_ALLOW17 = 0;
25555
+ var EXIT_ALLOW18 = 0;
25350
25556
  var TRANSCRIPT_READ_MAX_BYTES = 8 * 1024 * 1024;
25351
25557
  function stripFencedBlocks(text) {
25352
25558
  const out = [];
@@ -25450,7 +25656,7 @@ function detectPromissory(reply) {
25450
25656
  }
25451
25657
  function readLanguagePin(workspaceRoot2) {
25452
25658
  try {
25453
- const raw = fs58.readFileSync(path59.join(workspaceRoot2, STATE_FILE5), "utf-8");
25659
+ const raw = fs60.readFileSync(path61.join(workspaceRoot2, STATE_FILE5), "utf-8");
25454
25660
  const decoded = JSON.parse(raw);
25455
25661
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
25456
25662
  const lang = decoded["language"];
@@ -25499,17 +25705,17 @@ function detectUnverifiedEdit(toolCalls) {
25499
25705
  };
25500
25706
  }
25501
25707
  function stateDir(workspaceRoot2) {
25502
- return path59.join(workspaceRoot2, "agents", "runtime", "state", "turn-end-gate");
25708
+ return path61.join(workspaceRoot2, "agents", "runtime", "state", "turn-end-gate");
25503
25709
  }
25504
25710
  function sessionStateFile2(workspaceRoot2, sessionKey) {
25505
- return path59.join(stateDir(workspaceRoot2), `${sessionKey}.json`);
25711
+ return path61.join(stateDir(workspaceRoot2), `${sessionKey}.json`);
25506
25712
  }
25507
25713
  function deriveSessionKey2(sessionId2) {
25508
25714
  return crypto6.createHash("sha256").update(sessionId2).digest("hex").slice(0, 32);
25509
25715
  }
25510
25716
  function alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal) {
25511
25717
  try {
25512
- const raw = fs58.readFileSync(sessionStateFile2(workspaceRoot2, sessionKey), "utf-8");
25718
+ const raw = fs60.readFileSync(sessionStateFile2(workspaceRoot2, sessionKey), "utf-8");
25513
25719
  const decoded = JSON.parse(raw);
25514
25720
  if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
25515
25721
  return decoded["refused_turn"] === turnOrdinal;
@@ -25534,10 +25740,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
25534
25740
  if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
25535
25741
  let lines;
25536
25742
  try {
25537
- if (opts.maxBytes !== void 0 && fs58.statSync(transcriptPath).size > opts.maxBytes) {
25743
+ if (opts.maxBytes !== void 0 && fs60.statSync(transcriptPath).size > opts.maxBytes) {
25538
25744
  return empty;
25539
25745
  }
25540
- lines = fs58.readFileSync(transcriptPath, "utf-8").split("\n");
25746
+ lines = fs60.readFileSync(transcriptPath, "utf-8").split("\n");
25541
25747
  } catch {
25542
25748
  return empty;
25543
25749
  }
@@ -25650,29 +25856,29 @@ function readGateSettings(workspaceRoot2) {
25650
25856
  function str4(v) {
25651
25857
  return typeof v === "string" ? v : "";
25652
25858
  }
25653
- function main41() {
25859
+ function main42() {
25654
25860
  let envelope;
25655
25861
  let payload;
25656
25862
  try {
25657
25863
  [envelope, payload] = unwrap(readHookStdin(), "claude");
25658
25864
  } catch {
25659
- return EXIT_ALLOW17;
25865
+ return EXIT_ALLOW18;
25660
25866
  }
25661
- if (payload["stop_hook_active"] === true) return EXIT_ALLOW17;
25867
+ if (payload["stop_hook_active"] === true) return EXIT_ALLOW18;
25662
25868
  const workspaceRoot2 = str4(envelope["workspace_root"]) || process.cwd();
25663
25869
  const settings = readGateSettings(workspaceRoot2);
25664
- if (!settings.enabled) return EXIT_ALLOW17;
25870
+ if (!settings.enabled) return EXIT_ALLOW18;
25665
25871
  const transcriptPath = str4(
25666
25872
  payload["transcript_path"] ?? payload["transcriptPath"]
25667
25873
  );
25668
25874
  const { lastAssistant, turnOrdinal, toolCalls } = readTranscriptTail(transcriptPath, {
25669
25875
  maxBytes: TRANSCRIPT_READ_MAX_BYTES
25670
25876
  });
25671
- if (!lastAssistant) return EXIT_ALLOW17;
25877
+ if (!lastAssistant) return EXIT_ALLOW18;
25672
25878
  const sessionKey = deriveSessionKey2(
25673
25879
  str4(envelope["session_id"]) || "unknown-session"
25674
25880
  );
25675
- if (alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal)) return EXIT_ALLOW17;
25881
+ if (alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal)) return EXIT_ALLOW18;
25676
25882
  const findings = [];
25677
25883
  if (settings.promissory) {
25678
25884
  const f = detectPromissory(lastAssistant);
@@ -25686,7 +25892,7 @@ function main41() {
25686
25892
  const f = detectUnverifiedEdit(toolCalls);
25687
25893
  if (f) findings.push(f);
25688
25894
  }
25689
- if (findings.length === 0) return EXIT_ALLOW17;
25895
+ if (findings.length === 0) return EXIT_ALLOW18;
25690
25896
  markRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal, findings[0].detector);
25691
25897
  const lines = findings.map(
25692
25898
  (f) => ` \xB7 ${f.detector}: ${f.reason}
@@ -25709,30 +25915,30 @@ function _isCliEntry32() {
25709
25915
  if (process.argv[1] === void 0) {
25710
25916
  return false;
25711
25917
  }
25712
- const argvUrl = pathToFileURL36(path59.resolve(process.argv[1])).href;
25918
+ const argvUrl = pathToFileURL37(path61.resolve(process.argv[1])).href;
25713
25919
  if (import.meta.url === argvUrl) {
25714
25920
  return true;
25715
25921
  }
25716
25922
  try {
25717
- const here = fs58.realpathSync(fileURLToPath42(import.meta.url));
25718
- const argv = fs58.realpathSync(path59.resolve(process.argv[1]));
25923
+ const here = fs60.realpathSync(fileURLToPath43(import.meta.url));
25924
+ const argv = fs60.realpathSync(path61.resolve(process.argv[1]));
25719
25925
  return here === argv;
25720
25926
  } catch {
25721
25927
  return false;
25722
25928
  }
25723
25929
  }
25724
25930
  if (_isCliEntry32()) {
25725
- process.exit(main41());
25931
+ process.exit(main42());
25726
25932
  }
25727
25933
 
25728
25934
  // src/scripts/hooks/edit_shape_hook.ts
25729
25935
  import { spawnSync as spawnSync6 } from "node:child_process";
25730
25936
  import * as crypto7 from "node:crypto";
25731
- import * as fs59 from "node:fs";
25732
- import * as path60 from "node:path";
25733
- import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL37 } from "node:url";
25734
- var EXIT_ALLOW18 = 0;
25735
- var EXIT_WARN10 = 2;
25937
+ import * as fs61 from "node:fs";
25938
+ import * as path62 from "node:path";
25939
+ import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL38 } from "node:url";
25940
+ var EXIT_ALLOW19 = 0;
25941
+ var EXIT_WARN11 = 2;
25736
25942
  var MIN_FILE_LINES = 50;
25737
25943
  var MAX_DIFF_RATIO = 0.2;
25738
25944
  var EXEMPT_PATH_PATTERNS = [
@@ -25747,7 +25953,7 @@ var EXEMPT_PATH_PATTERNS = [
25747
25953
  /(^|\/)agents\/runtime\//i
25748
25954
  // agents/runtime/**
25749
25955
  ];
25750
- function isObject6(v) {
25956
+ function isObject7(v) {
25751
25957
  return typeof v === "object" && v !== null && !Array.isArray(v);
25752
25958
  }
25753
25959
  function str5(v) {
@@ -25783,7 +25989,7 @@ function effectiveDiffLines(cwd, relPath) {
25783
25989
  }
25784
25990
  function fileLineCount(absPath) {
25785
25991
  try {
25786
- const text = fs59.readFileSync(absPath, "utf8");
25992
+ const text = fs61.readFileSync(absPath, "utf8");
25787
25993
  if (text.length === 0) return 0;
25788
25994
  return text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
25789
25995
  } catch {
@@ -25800,11 +26006,11 @@ function deriveSessionKey3(envelope, payload) {
25800
26006
  return crypto7.createHash("sha256").update(material).digest("hex");
25801
26007
  }
25802
26008
  function sessionStateFile3(workspaceRoot2, sessionKey) {
25803
- return path60.join(workspaceRoot2, "agents", "runtime", "state", "edit-shape", `${sessionKey}.json`);
26009
+ return path62.join(workspaceRoot2, "agents", "runtime", "state", "edit-shape", `${sessionKey}.json`);
25804
26010
  }
25805
26011
  function hasFiredThisSession2(workspaceRoot2, sessionKey) {
25806
26012
  try {
25807
- return fs59.existsSync(sessionStateFile3(workspaceRoot2, sessionKey));
26013
+ return fs61.existsSync(sessionStateFile3(workspaceRoot2, sessionKey));
25808
26014
  } catch {
25809
26015
  return false;
25810
26016
  }
@@ -25822,29 +26028,29 @@ function extractToolName2(payload) {
25822
26028
  }
25823
26029
  function extractFilePath(payload) {
25824
26030
  const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
25825
- if (!isObject6(ti)) return "";
26031
+ if (!isObject7(ti)) return "";
25826
26032
  return str5(ti["file_path"] ?? ti["path"] ?? ti["filePath"]);
25827
26033
  }
25828
- function main42() {
26034
+ function main43() {
25829
26035
  try {
25830
26036
  const [envelope, payload] = unwrap(readHookStdin(), "claude");
25831
26037
  const event = str5(envelope["event"]);
25832
- if (event !== "" && event !== "post_tool_use") return EXIT_ALLOW18;
26038
+ if (event !== "" && event !== "post_tool_use") return EXIT_ALLOW19;
25833
26039
  const toolName = extractToolName2(payload);
25834
- if (toolName !== "Write") return EXIT_ALLOW18;
26040
+ if (toolName !== "Write") return EXIT_ALLOW19;
25835
26041
  const filePath = extractFilePath(payload);
25836
- if (!filePath) return EXIT_ALLOW18;
26042
+ if (!filePath) return EXIT_ALLOW19;
25837
26043
  const workspaceRoot2 = str5(envelope["workspace_root"]).trim() || process.cwd();
25838
- const absPath = path60.isAbsolute(filePath) ? filePath : path60.resolve(workspaceRoot2, filePath);
25839
- const relPath = path60.relative(workspaceRoot2, absPath);
25840
- if (isExemptPath(relPath) || isExemptPath(absPath)) return EXIT_ALLOW18;
26044
+ const absPath = path62.isAbsolute(filePath) ? filePath : path62.resolve(workspaceRoot2, filePath);
26045
+ const relPath = path62.relative(workspaceRoot2, absPath);
26046
+ if (isExemptPath(relPath) || isExemptPath(absPath)) return EXIT_ALLOW19;
25841
26047
  const fileLines = fileLineCount(absPath);
25842
- if (fileLines < MIN_FILE_LINES) return EXIT_ALLOW18;
26048
+ if (fileLines < MIN_FILE_LINES) return EXIT_ALLOW19;
25843
26049
  const diffLines = effectiveDiffLines(workspaceRoot2, relPath.startsWith("..") ? absPath : relPath);
25844
- if (diffLines === 0) return EXIT_ALLOW18;
25845
- if (diffLines / fileLines > MAX_DIFF_RATIO) return EXIT_ALLOW18;
26050
+ if (diffLines === 0) return EXIT_ALLOW19;
26051
+ if (diffLines / fileLines > MAX_DIFF_RATIO) return EXIT_ALLOW19;
25846
26052
  const sessionKey = deriveSessionKey3(envelope, payload);
25847
- if (hasFiredThisSession2(workspaceRoot2, sessionKey)) return EXIT_ALLOW18;
26053
+ if (hasFiredThisSession2(workspaceRoot2, sessionKey)) return EXIT_ALLOW19;
25848
26054
  markFiredThisSession2(workspaceRoot2, sessionKey);
25849
26055
  process.stdout.write(
25850
26056
  `${JSON.stringify({
@@ -25854,9 +26060,9 @@ function main42() {
25854
26060
  })}
25855
26061
  `
25856
26062
  );
25857
- return EXIT_WARN10;
26063
+ return EXIT_WARN11;
25858
26064
  } catch {
25859
- return EXIT_ALLOW18;
26065
+ return EXIT_ALLOW19;
25860
26066
  }
25861
26067
  }
25862
26068
  function _isCliEntry33() {
@@ -25866,29 +26072,29 @@ function _isCliEntry33() {
25866
26072
  if (process.argv[1] === void 0) {
25867
26073
  return false;
25868
26074
  }
25869
- const argvUrl = pathToFileURL37(path60.resolve(process.argv[1])).href;
26075
+ const argvUrl = pathToFileURL38(path62.resolve(process.argv[1])).href;
25870
26076
  if (import.meta.url === argvUrl) {
25871
26077
  return true;
25872
26078
  }
25873
26079
  try {
25874
- const here = fs59.realpathSync(fileURLToPath43(import.meta.url));
25875
- const argv = fs59.realpathSync(path60.resolve(process.argv[1]));
26080
+ const here = fs61.realpathSync(fileURLToPath44(import.meta.url));
26081
+ const argv = fs61.realpathSync(path62.resolve(process.argv[1]));
25876
26082
  return here === argv;
25877
26083
  } catch {
25878
26084
  return false;
25879
26085
  }
25880
26086
  }
25881
26087
  if (_isCliEntry33()) {
25882
- process.exit(main42());
26088
+ process.exit(main43());
25883
26089
  }
25884
26090
 
25885
26091
  // src/scripts/hooks/reread_guard_hook.ts
25886
26092
  import * as crypto8 from "node:crypto";
25887
- import * as fs60 from "node:fs";
25888
- import * as path61 from "node:path";
25889
- import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL38 } from "node:url";
25890
- var EXIT_ALLOW19 = 0;
25891
- var EXIT_WARN11 = 2;
26093
+ import * as fs62 from "node:fs";
26094
+ import * as path63 from "node:path";
26095
+ import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL39 } from "node:url";
26096
+ var EXIT_ALLOW20 = 0;
26097
+ var EXIT_WARN12 = 2;
25892
26098
  var EXEMPT_PATH_PATTERNS2 = [
25893
26099
  /(^|\/)dist\//i,
25894
26100
  // dist/**
@@ -25903,7 +26109,7 @@ var EXEMPT_PATH_PATTERNS2 = [
25903
26109
  ];
25904
26110
  var READ_TOOLS = /* @__PURE__ */ new Set(["Read"]);
25905
26111
  var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Edit", "Write"]);
25906
- function isObject7(v) {
26112
+ function isObject8(v) {
25907
26113
  return typeof v === "object" && v !== null && !Array.isArray(v);
25908
26114
  }
25909
26115
  function str6(v) {
@@ -25922,16 +26128,16 @@ function deriveSessionKey4(envelope, payload) {
25922
26128
  return crypto8.createHash("sha256").update(material).digest("hex");
25923
26129
  }
25924
26130
  function ledgerFile(workspaceRoot2, sessionKey) {
25925
- return path61.join(workspaceRoot2, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
26131
+ return path63.join(workspaceRoot2, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
25926
26132
  }
25927
26133
  function readLedger(workspaceRoot2, sessionKey) {
25928
26134
  try {
25929
- const parsed = JSON.parse(fs60.readFileSync(ledgerFile(workspaceRoot2, sessionKey), "utf8"));
25930
- if (!isObject7(parsed)) return emptyLedger();
26135
+ const parsed = JSON.parse(fs62.readFileSync(ledgerFile(workspaceRoot2, sessionKey), "utf8"));
26136
+ if (!isObject8(parsed)) return emptyLedger();
25931
26137
  return {
25932
- reads: isObject7(parsed["reads"]) ? parsed["reads"] : {},
25933
- writes: isObject7(parsed["writes"]) ? parsed["writes"] : {},
25934
- fired: isObject7(parsed["fired"]) ? parsed["fired"] : {}
26138
+ reads: isObject8(parsed["reads"]) ? parsed["reads"] : {},
26139
+ writes: isObject8(parsed["writes"]) ? parsed["writes"] : {},
26140
+ fired: isObject8(parsed["fired"]) ? parsed["fired"] : {}
25935
26141
  };
25936
26142
  } catch {
25937
26143
  return emptyLedger();
@@ -25948,7 +26154,7 @@ function extractToolName3(payload) {
25948
26154
  }
25949
26155
  function extractToolInput2(payload) {
25950
26156
  const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
25951
- return isObject7(ti) ? ti : {};
26157
+ return isObject8(ti) ? ti : {};
25952
26158
  }
25953
26159
  function extractFilePath2(toolInput) {
25954
26160
  return str6(toolInput["file_path"] ?? toolInput["path"] ?? toolInput["filePath"]);
@@ -25967,41 +26173,41 @@ function buildDuplicateReadLine(relPath, earlierTs) {
25967
26173
  function buildPostEditReadLine(relPath) {
25968
26174
  return `re-read guard: this session just edited ${relPath} \u2014 a full-file re-read re-pays for content you already have; a ranged Read (offset/limit) over the edited hunk is enough to verify the change.`;
25969
26175
  }
25970
- function main43() {
26176
+ function main44() {
25971
26177
  try {
25972
26178
  const [envelope, payload] = unwrap(readHookStdin(), "claude");
25973
26179
  const event = str6(envelope["event"]);
25974
- if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW19;
26180
+ if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW20;
25975
26181
  const toolName = extractToolName3(payload);
25976
26182
  const isRead = READ_TOOLS.has(toolName);
25977
26183
  const isWrite = WRITE_TOOLS2.has(toolName);
25978
- if (!isRead && !isWrite) return EXIT_ALLOW19;
26184
+ if (!isRead && !isWrite) return EXIT_ALLOW20;
25979
26185
  const toolInput = extractToolInput2(payload);
25980
26186
  const filePath = extractFilePath2(toolInput);
25981
- if (!filePath) return EXIT_ALLOW19;
26187
+ if (!filePath) return EXIT_ALLOW20;
25982
26188
  const workspaceRoot2 = str6(envelope["workspace_root"]).trim() || process.cwd();
25983
- const absPath = path61.isAbsolute(filePath) ? filePath : path61.resolve(workspaceRoot2, filePath);
25984
- const relPath = path61.relative(workspaceRoot2, absPath);
25985
- if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW19;
26189
+ const absPath = path63.isAbsolute(filePath) ? filePath : path63.resolve(workspaceRoot2, filePath);
26190
+ const relPath = path63.relative(workspaceRoot2, absPath);
26191
+ if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW20;
25986
26192
  const sessionKey = deriveSessionKey4(envelope, payload);
25987
26193
  const ledger = readLedger(workspaceRoot2, sessionKey);
25988
26194
  const key = relPath.startsWith("..") ? absPath : relPath;
25989
26195
  if (isWrite) {
25990
26196
  ledger.writes[key] = Date.now();
25991
26197
  writeLedger(workspaceRoot2, sessionKey, ledger);
25992
- return EXIT_ALLOW19;
26198
+ return EXIT_ALLOW20;
25993
26199
  }
25994
26200
  if (isRangedRead(toolInput)) {
25995
- return EXIT_ALLOW19;
26201
+ return EXIT_ALLOW20;
25996
26202
  }
25997
26203
  let mtime;
25998
26204
  let size;
25999
26205
  try {
26000
- const st = fs60.statSync(absPath);
26206
+ const st = fs62.statSync(absPath);
26001
26207
  mtime = st.mtimeMs;
26002
26208
  size = st.size;
26003
26209
  } catch {
26004
- return EXIT_ALLOW19;
26210
+ return EXIT_ALLOW20;
26005
26211
  }
26006
26212
  const prior = ledger.reads[key];
26007
26213
  const ownWrite = ledger.writes[key];
@@ -26016,7 +26222,7 @@ function main43() {
26016
26222
  if (ownWrite !== void 0) delete ledger.writes[key];
26017
26223
  if (advisory !== null) ledger.fired[key] = true;
26018
26224
  writeLedger(workspaceRoot2, sessionKey, ledger);
26019
- if (advisory === null) return EXIT_ALLOW19;
26225
+ if (advisory === null) return EXIT_ALLOW20;
26020
26226
  process.stdout.write(
26021
26227
  `${JSON.stringify({
26022
26228
  decision: "warn",
@@ -26025,9 +26231,9 @@ function main43() {
26025
26231
  })}
26026
26232
  `
26027
26233
  );
26028
- return EXIT_WARN11;
26234
+ return EXIT_WARN12;
26029
26235
  } catch {
26030
- return EXIT_ALLOW19;
26236
+ return EXIT_ALLOW20;
26031
26237
  }
26032
26238
  }
26033
26239
  function _isCliEntry34() {
@@ -26037,27 +26243,27 @@ function _isCliEntry34() {
26037
26243
  if (process.argv[1] === void 0) {
26038
26244
  return false;
26039
26245
  }
26040
- const argvUrl = pathToFileURL38(path61.resolve(process.argv[1])).href;
26246
+ const argvUrl = pathToFileURL39(path63.resolve(process.argv[1])).href;
26041
26247
  if (import.meta.url === argvUrl) {
26042
26248
  return true;
26043
26249
  }
26044
26250
  try {
26045
- const here = fs60.realpathSync(fileURLToPath44(import.meta.url));
26046
- const argv = fs60.realpathSync(path61.resolve(process.argv[1]));
26251
+ const here = fs62.realpathSync(fileURLToPath45(import.meta.url));
26252
+ const argv = fs62.realpathSync(path63.resolve(process.argv[1]));
26047
26253
  return here === argv;
26048
26254
  } catch {
26049
26255
  return false;
26050
26256
  }
26051
26257
  }
26052
26258
  if (_isCliEntry34()) {
26053
- process.exit(main43());
26259
+ process.exit(main44());
26054
26260
  }
26055
26261
 
26056
26262
  // src/scripts/hooks/session_eol_hook.ts
26057
- import * as fs62 from "node:fs";
26058
- import * as path64 from "node:path";
26263
+ import * as fs64 from "node:fs";
26264
+ import * as path66 from "node:path";
26059
26265
  import process11 from "node:process";
26060
- import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL39 } from "node:url";
26266
+ import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL40 } from "node:url";
26061
26267
 
26062
26268
  // src/config/recycle-threshold-budget.json
26063
26269
  var recycle_threshold_budget_default = {
@@ -26075,13 +26281,13 @@ var recycle_threshold_budget_default = {
26075
26281
 
26076
26282
  // src/scripts/_lib/session_eol.ts
26077
26283
  import * as crypto9 from "node:crypto";
26078
- import * as fs61 from "node:fs";
26079
- import * as path63 from "node:path";
26284
+ import * as fs63 from "node:fs";
26285
+ import * as path65 from "node:path";
26080
26286
 
26081
26287
  // src/scripts/_lib/cc_transcript.ts
26082
- import * as path62 from "node:path";
26288
+ import * as path64 from "node:path";
26083
26289
  import { homedir as homedir6 } from "node:os";
26084
- var DEFAULT_PROJECTS_ROOT = path62.join(homedir6(), ".claude", "projects");
26290
+ var DEFAULT_PROJECTS_ROOT = path64.join(homedir6(), ".claude", "projects");
26085
26291
  function billableInputTokens(u) {
26086
26292
  return u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens;
26087
26293
  }
@@ -26190,17 +26396,17 @@ function scanEolSlice(text, prior) {
26190
26396
  return next;
26191
26397
  }
26192
26398
  function eolStateDir(workspaceRoot2) {
26193
- return path63.join(workspaceRoot2, "agents", "runtime", "state", "session-eol");
26399
+ return path65.join(workspaceRoot2, "agents", "runtime", "state", "session-eol");
26194
26400
  }
26195
26401
  function eolStateFile(workspaceRoot2, sessionKey) {
26196
- return path63.join(eolStateDir(workspaceRoot2), `${sessionKey}.json`);
26402
+ return path65.join(eolStateDir(workspaceRoot2), `${sessionKey}.json`);
26197
26403
  }
26198
26404
  function eolSessionKey(raw) {
26199
26405
  return crypto9.createHash("sha256").update(raw || "unknown-session").digest("hex");
26200
26406
  }
26201
26407
  function readNewCompleteLines(filePath, fromByte) {
26202
26408
  try {
26203
- const { size } = fs61.statSync(filePath);
26409
+ const { size } = fs63.statSync(filePath);
26204
26410
  if (size < fromByte) {
26205
26411
  return { text: "", nextOffset: 0, truncated: true };
26206
26412
  }
@@ -26209,11 +26415,11 @@ function readNewCompleteLines(filePath, fromByte) {
26209
26415
  }
26210
26416
  const length = size - fromByte;
26211
26417
  const buffer = Buffer.alloc(length);
26212
- const fd = fs61.openSync(filePath, "r");
26418
+ const fd = fs63.openSync(filePath, "r");
26213
26419
  try {
26214
- fs61.readSync(fd, buffer, 0, length, fromByte);
26420
+ fs63.readSync(fd, buffer, 0, length, fromByte);
26215
26421
  } finally {
26216
- fs61.closeSync(fd);
26422
+ fs63.closeSync(fd);
26217
26423
  }
26218
26424
  const lastNewline = buffer.lastIndexOf(10);
26219
26425
  if (lastNewline === -1) {
@@ -26230,21 +26436,21 @@ function readNewCompleteLines(filePath, fromByte) {
26230
26436
  }
26231
26437
 
26232
26438
  // src/scripts/hooks/session_eol_hook.ts
26233
- var EXIT_WARN12 = 2;
26439
+ var EXIT_WARN13 = 2;
26234
26440
  var THRESHOLD_OVERRIDE_ENV = "AGENT_RECYCLE_THRESHOLD_TOKENS";
26235
- var CONTEXT_FILL_REL = path64.join("agents", "runtime", "state", "context-fill.json");
26441
+ var CONTEXT_FILL_REL = path66.join("agents", "runtime", "state", "context-fill.json");
26236
26442
  function str7(value) {
26237
26443
  return typeof value === "string" ? value : "";
26238
26444
  }
26239
- var stateFile2 = eolStateFile;
26445
+ var stateFile3 = eolStateFile;
26240
26446
  function deriveSessionKey5(envelope, payload) {
26241
26447
  return eolSessionKey(
26242
26448
  str7(envelope["session_id"]) || str7(payload["transcript_path"] ?? payload["transcriptPath"])
26243
26449
  );
26244
26450
  }
26245
- function readState2(file) {
26451
+ function readState3(file) {
26246
26452
  try {
26247
- const parsed = JSON.parse(fs62.readFileSync(file, "utf-8"));
26453
+ const parsed = JSON.parse(fs64.readFileSync(file, "utf-8"));
26248
26454
  if (parsed && typeof parsed === "object" && parsed.schema_version === 1 && parsed.counters && typeof parsed.counters.scanned_bytes === "number") {
26249
26455
  return {
26250
26456
  schema_version: 1,
@@ -26276,7 +26482,7 @@ function buildAdvisoryLine3(tokens, threshold) {
26276
26482
  }
26277
26483
  function writeContextFill(workspaceRoot2, tokens, threshold, ts) {
26278
26484
  try {
26279
- atomic_write_json(path64.join(workspaceRoot2, CONTEXT_FILL_REL), {
26485
+ atomic_write_json(path66.join(workspaceRoot2, CONTEXT_FILL_REL), {
26280
26486
  schema_version: 1,
26281
26487
  final_context_tokens: tokens,
26282
26488
  recycle_threshold_tokens: threshold,
@@ -26286,7 +26492,7 @@ function writeContextFill(workspaceRoot2, tokens, threshold, ts) {
26286
26492
  } catch {
26287
26493
  }
26288
26494
  }
26289
- function main44() {
26495
+ function main45() {
26290
26496
  const [envelope, payload] = unwrap(readHookStdin(), "claude");
26291
26497
  const event = String(envelope["event"] ?? "");
26292
26498
  if (event !== "" && event !== "stop") {
@@ -26303,8 +26509,8 @@ function main44() {
26303
26509
  return 0;
26304
26510
  }
26305
26511
  const sessionKey = deriveSessionKey5(envelope, payload);
26306
- const file = stateFile2(workspaceRoot2, sessionKey);
26307
- const state = readState2(file);
26512
+ const file = stateFile3(workspaceRoot2, sessionKey);
26513
+ const state = readState3(file);
26308
26514
  let counters = state.counters;
26309
26515
  const read = readNewCompleteLines(transcriptPath, counters.scanned_bytes);
26310
26516
  if (read.truncated) {
@@ -26341,7 +26547,7 @@ function main44() {
26341
26547
  })}
26342
26548
  `
26343
26549
  );
26344
- return EXIT_WARN12;
26550
+ return EXIT_WARN13;
26345
26551
  }
26346
26552
  return 0;
26347
26553
  }
@@ -26352,20 +26558,20 @@ function _isCliEntry35() {
26352
26558
  if (process11.argv[1] === void 0) {
26353
26559
  return false;
26354
26560
  }
26355
- const argvUrl = pathToFileURL39(path64.resolve(process11.argv[1])).href;
26561
+ const argvUrl = pathToFileURL40(path66.resolve(process11.argv[1])).href;
26356
26562
  if (import.meta.url === argvUrl) {
26357
26563
  return true;
26358
26564
  }
26359
26565
  try {
26360
- const here = fs62.realpathSync(fileURLToPath45(import.meta.url));
26361
- const argv = fs62.realpathSync(path64.resolve(process11.argv[1]));
26566
+ const here = fs64.realpathSync(fileURLToPath46(import.meta.url));
26567
+ const argv = fs64.realpathSync(path66.resolve(process11.argv[1]));
26362
26568
  return here === argv;
26363
26569
  } catch {
26364
26570
  return false;
26365
26571
  }
26366
26572
  }
26367
26573
  if (_isCliEntry35()) {
26368
- process11.exit(main44());
26574
+ process11.exit(main45());
26369
26575
  }
26370
26576
 
26371
26577
  // src/scripts/hooks/concern_registry.ts
@@ -26400,13 +26606,14 @@ var CONCERN_REGISTRY = {
26400
26606
  "src/scripts/hooks/rtk_wrap_hook.ts": main33,
26401
26607
  "src/scripts/hooks/design_slop_hook.ts": main35,
26402
26608
  "src/scripts/hooks/code_graph_nudge_hook.ts": main36,
26403
- "src/scripts/hooks/orchestration_record_hook.ts": main38,
26404
- "src/scripts/hooks/delegation_nudge_hook.ts": main39,
26405
- "src/scripts/hooks/end_review_nudge_hook.ts": main40,
26406
- "src/scripts/hooks/turn_end_gate_hook.ts": main41,
26407
- "src/scripts/hooks/edit_shape_hook.ts": main42,
26408
- "src/scripts/hooks/reread_guard_hook.ts": main43,
26409
- "src/scripts/hooks/session_eol_hook.ts": main44
26609
+ "src/scripts/hooks/ui_route_nudge_hook.ts": main37,
26610
+ "src/scripts/hooks/orchestration_record_hook.ts": main39,
26611
+ "src/scripts/hooks/delegation_nudge_hook.ts": main40,
26612
+ "src/scripts/hooks/end_review_nudge_hook.ts": main41,
26613
+ "src/scripts/hooks/turn_end_gate_hook.ts": main42,
26614
+ "src/scripts/hooks/edit_shape_hook.ts": main43,
26615
+ "src/scripts/hooks/reread_guard_hook.ts": main44,
26616
+ "src/scripts/hooks/session_eol_hook.ts": main45
26410
26617
  };
26411
26618
 
26412
26619
  // src/scripts/hooks/host_semantics.ts
@@ -26460,14 +26667,14 @@ function emitFor(platform, event, severity, reasons, legacyExit) {
26460
26667
 
26461
26668
  // src/scripts/hooks/dispatch_hook.ts
26462
26669
  var _IN_BUNDLE = true;
26463
- var REPO_ROOT = path65.resolve(
26464
- path65.dirname(fileURLToPath46(import.meta.url)),
26670
+ var REPO_ROOT = path67.resolve(
26671
+ path67.dirname(fileURLToPath47(import.meta.url)),
26465
26672
  ..._IN_BUNDLE ? ["..", ".."] : ["..", "..", ".."]
26466
26673
  );
26467
- var MANIFEST_PATH = path65.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
26468
- var EXIT_ALLOW20 = 0;
26674
+ var MANIFEST_PATH = path67.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
26675
+ var EXIT_ALLOW21 = 0;
26469
26676
  var EXIT_BLOCK5 = 1;
26470
- var EXIT_WARN13 = 2;
26677
+ var EXIT_WARN14 = 2;
26471
26678
  var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
26472
26679
  "session_start",
26473
26680
  "session_end",
@@ -26479,9 +26686,9 @@ var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
26479
26686
  "agent_error"
26480
26687
  ]);
26481
26688
  var _SEVERITY_BY_EXIT = {
26482
- [EXIT_ALLOW20]: "allow",
26689
+ [EXIT_ALLOW21]: "allow",
26483
26690
  [EXIT_BLOCK5]: "block",
26484
- [EXIT_WARN13]: "warn"
26691
+ [EXIT_WARN14]: "warn"
26485
26692
  };
26486
26693
  function _isObject14(v) {
26487
26694
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -26516,7 +26723,7 @@ function _parse_concern_stdout(stdout_text) {
26516
26723
  return _isObject14(parsed) ? parsed : { _raw: parsed };
26517
26724
  }
26518
26725
  function _load_yaml3(p) {
26519
- const text = fs63.readFileSync(p, "utf-8");
26726
+ const text = fs65.readFileSync(p, "utf-8");
26520
26727
  const data = (0, import_yaml6.parse)(text, { version: "1.1" });
26521
26728
  return _isObject14(data) ? data : {};
26522
26729
  }
@@ -26673,7 +26880,7 @@ function _maybe_capture_payload(args, payload_text) {
26673
26880
  }
26674
26881
  try {
26675
26882
  const target = _expanduser3(capture_dir);
26676
- fs63.mkdirSync(target, { recursive: true });
26883
+ fs65.mkdirSync(target, { recursive: true });
26677
26884
  let payload;
26678
26885
  try {
26679
26886
  payload = payload_text.trim() ? JSON.parse(payload_text) : {};
@@ -26690,8 +26897,8 @@ function _maybe_capture_payload(args, payload_text) {
26690
26897
  const ts = Date.now();
26691
26898
  const native = (args.native_event || args.event).replace(/\//g, "_");
26692
26899
  const fname = `${args.platform}__${native}__${ts}__${process.pid}.json`;
26693
- fs63.writeFileSync(
26694
- path65.join(target, fname),
26900
+ fs65.writeFileSync(
26901
+ path67.join(target, fname),
26695
26902
  _py_json_dumps2(record, 2) + "\n",
26696
26903
  { encoding: "utf-8" }
26697
26904
  );
@@ -26702,7 +26909,7 @@ function _maybe_capture_payload(args, payload_text) {
26702
26909
  function _expanduser3(p) {
26703
26910
  if (p === "~" || p.startsWith("~/")) {
26704
26911
  const home = process.env["HOME"] || process.env["USERPROFILE"] || "";
26705
- return path65.join(home, p.slice(1));
26912
+ return path67.join(home, p.slice(1));
26706
26913
  }
26707
26914
  return p;
26708
26915
  }
@@ -26734,25 +26941,25 @@ function _resolve_tsx_invocation2(scriptPath, scriptArgs) {
26734
26941
  const walkUp = (start) => {
26735
26942
  let dir = start;
26736
26943
  for (; ; ) {
26737
- const candidate = path65.join(dir, "node_modules", ".bin", binName);
26944
+ const candidate = path67.join(dir, "node_modules", ".bin", binName);
26738
26945
  if (_isFile7(candidate)) {
26739
26946
  return candidate;
26740
26947
  }
26741
- const parent = path65.dirname(dir);
26948
+ const parent = path67.dirname(dir);
26742
26949
  if (parent === dir) {
26743
26950
  return null;
26744
26951
  }
26745
26952
  dir = parent;
26746
26953
  }
26747
26954
  };
26748
- const tsx = walkUp(path65.dirname(scriptPath)) ?? walkUp(path65.dirname(fileURLToPath46(import.meta.url)));
26955
+ const tsx = walkUp(path67.dirname(scriptPath)) ?? walkUp(path67.dirname(fileURLToPath47(import.meta.url)));
26749
26956
  if (tsx !== null) {
26750
26957
  return { command: tsx, args: [scriptPath, ...scriptArgs] };
26751
26958
  }
26752
26959
  return { command: "npx", args: ["tsx", scriptPath, ...scriptArgs] };
26753
26960
  }
26754
26961
  function _run_concern_inproc(main_fn, concern, envelope) {
26755
- const scriptAbs = path65.join(REPO_ROOT, String(concern["script"]));
26962
+ const scriptAbs = path67.join(REPO_ROOT, String(concern["script"]));
26756
26963
  const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
26757
26964
  argsList.push("--platform", String(envelope["platform"] || "generic"));
26758
26965
  const workspace = String(envelope["workspace_root"] || process.cwd());
@@ -26829,7 +27036,7 @@ function _run_concern(concern, envelope) {
26829
27036
  return _run_concern_inproc(inproc, concern, envelope);
26830
27037
  }
26831
27038
  }
26832
- const script = path65.join(REPO_ROOT, String(concern["script"]));
27039
+ const script = path67.join(REPO_ROOT, String(concern["script"]));
26833
27040
  const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
26834
27041
  const cmd = [script, ...argsList];
26835
27042
  cmd.push("--platform", String(envelope["platform"] || "generic"));
@@ -26886,7 +27093,7 @@ function _run_concern(concern, envelope) {
26886
27093
  }
26887
27094
  function _isFile7(p) {
26888
27095
  try {
26889
- return fs63.statSync(p).isFile();
27096
+ return fs65.statSync(p).isFile();
26890
27097
  } catch {
26891
27098
  return false;
26892
27099
  }
@@ -26898,20 +27105,20 @@ function _reduce(rcs) {
26898
27105
  if (rcs.some((rc) => rc === EXIT_BLOCK5)) {
26899
27106
  return EXIT_BLOCK5;
26900
27107
  }
26901
- if (rcs.some((rc) => rc === EXIT_WARN13)) {
26902
- return EXIT_WARN13;
27108
+ if (rcs.some((rc) => rc === EXIT_WARN14)) {
27109
+ return EXIT_WARN14;
26903
27110
  }
26904
- return EXIT_ALLOW20;
27111
+ return EXIT_ALLOW21;
26905
27112
  }
26906
27113
  function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
26907
27114
  if (is_replay_mode()) {
26908
27115
  return;
26909
27116
  }
26910
27117
  const workspace = String(envelope["workspace_root"] || process.cwd());
26911
- const state_root = path65.join(workspace, "agents", "runtime", "state");
27118
+ const state_root = path67.join(workspace, "agents", "runtime", "state");
26912
27119
  const fb_dir = feedback_dir(state_root, session_id);
26913
27120
  try {
26914
- fs63.mkdirSync(fb_dir, { recursive: true });
27121
+ fs65.mkdirSync(fb_dir, { recursive: true });
26915
27122
  } catch (exc) {
26916
27123
  const msg = exc instanceof Error ? exc.message : String(exc);
26917
27124
  process.stderr.write(`dispatch_hook: feedback dir unavailable: ${msg}
@@ -26919,7 +27126,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
26919
27126
  return;
26920
27127
  }
26921
27128
  for (const entry of entries) {
26922
- const target = path65.join(fb_dir, `${entry["concern"]}.json`);
27129
+ const target = path67.join(fb_dir, `${entry["concern"]}.json`);
26923
27130
  try {
26924
27131
  atomic_write_json(target, entry);
26925
27132
  } catch (exc) {
@@ -26959,7 +27166,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
26959
27166
  })
26960
27167
  };
26961
27168
  try {
26962
- atomic_write_json(path65.join(fb_dir, "summary.json"), summary);
27169
+ atomic_write_json(path67.join(fb_dir, "summary.json"), summary);
26963
27170
  } catch (exc) {
26964
27171
  const msg = exc instanceof Error ? exc.message : String(exc);
26965
27172
  process.stderr.write(`dispatch_hook: summary write failed: ${msg}
@@ -26969,17 +27176,17 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
26969
27176
  function _record_rule_trips(envelope, entries) {
26970
27177
  if (is_replay_mode()) return;
26971
27178
  const tripped = entries.filter(
26972
- (e) => e["exit_code"] === EXIT_BLOCK5 || e["exit_code"] === EXIT_WARN13
27179
+ (e) => e["exit_code"] === EXIT_BLOCK5 || e["exit_code"] === EXIT_WARN14
26973
27180
  );
26974
27181
  if (tripped.length === 0) return;
26975
27182
  try {
26976
27183
  const workspace = String(envelope["workspace_root"] || process.cwd());
26977
- const state_dir = path65.join(workspace, "agents", "runtime", "state");
26978
- const target = path65.join(state_dir, "rule-trips.json");
26979
- fs63.mkdirSync(state_dir, { recursive: true });
27184
+ const state_dir = path67.join(workspace, "agents", "runtime", "state");
27185
+ const target = path67.join(state_dir, "rule-trips.json");
27186
+ fs65.mkdirSync(state_dir, { recursive: true });
26980
27187
  let doc = { schema_version: 1, concerns: {} };
26981
27188
  try {
26982
- const parsed = JSON.parse(fs63.readFileSync(target, "utf-8"));
27189
+ const parsed = JSON.parse(fs65.readFileSync(target, "utf-8"));
26983
27190
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) doc = parsed;
26984
27191
  } catch {
26985
27192
  }
@@ -26990,7 +27197,7 @@ function _record_rule_trips(envelope, entries) {
26990
27197
  const prev = concerns[name] ?? { block: 0, warn: 0 };
26991
27198
  concerns[name] = {
26992
27199
  block: (Number(prev["block"]) || 0) + (e["exit_code"] === EXIT_BLOCK5 ? 1 : 0),
26993
- warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN13 ? 1 : 0),
27200
+ warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN14 ? 1 : 0),
26994
27201
  last_trip: today
26995
27202
  };
26996
27203
  }
@@ -27078,7 +27285,7 @@ function _parse_args(argv) {
27078
27285
  }
27079
27286
  return args;
27080
27287
  }
27081
- function main45(argv) {
27288
+ function main46(argv) {
27082
27289
  const args = _parse_args(argv ?? process.argv.slice(2));
27083
27290
  if (args.project_dir) {
27084
27291
  const project_dir = _expanduser3(args.project_dir);
@@ -27096,13 +27303,13 @@ function main45(argv) {
27096
27303
  `dispatch_hook: unknown event '${args.event}'; allowed: ${_sortedRepr(EVENT_VOCABULARY)}
27097
27304
  `
27098
27305
  );
27099
- return EXIT_ALLOW20;
27306
+ return EXIT_ALLOW21;
27100
27307
  }
27101
27308
  const manifest_path = args.manifest;
27102
- if (!fs63.existsSync(manifest_path)) {
27309
+ if (!fs65.existsSync(manifest_path)) {
27103
27310
  process.stderr.write(`dispatch_hook: manifest missing at ${manifest_path}
27104
27311
  `);
27105
- return EXIT_ALLOW20;
27312
+ return EXIT_ALLOW21;
27106
27313
  }
27107
27314
  const manifest = _load_yaml3(manifest_path);
27108
27315
  if (args.min_version) {
@@ -27126,10 +27333,10 @@ function main45(argv) {
27126
27333
  concerns: concerns.map((c) => c["name"])
27127
27334
  };
27128
27335
  process.stdout.write(_py_json_dumps2(plan, 2) + "\n");
27129
- return EXIT_ALLOW20;
27336
+ return EXIT_ALLOW21;
27130
27337
  }
27131
27338
  if (concerns.length === 0) {
27132
- return EXIT_ALLOW20;
27339
+ return EXIT_ALLOW21;
27133
27340
  }
27134
27341
  const envelope = _build_envelope(args, payload_text);
27135
27342
  const session_id = _resolve_session_id(envelope);
@@ -27149,7 +27356,7 @@ function main45(argv) {
27149
27356
  const raw_rc = rc;
27150
27357
  if (rc >= 3) {
27151
27358
  if (!concern["fail_closed"]) {
27152
- rc = EXIT_ALLOW20;
27359
+ rc = EXIT_ALLOW21;
27153
27360
  } else {
27154
27361
  rc = EXIT_BLOCK5;
27155
27362
  }
@@ -27162,7 +27369,7 @@ function main45(argv) {
27162
27369
  `dispatch_hook: concern '${String(concern["name"])}' is declared severity: advisory but returned BLOCK \u2014 downgraded to warn.
27163
27370
  `
27164
27371
  );
27165
- rc = EXIT_WARN13;
27372
+ rc = EXIT_WARN14;
27166
27373
  }
27167
27374
  rcs.push(rc);
27168
27375
  const reply = _parse_concern_stdout(stdout_text);
@@ -27172,7 +27379,7 @@ function main45(argv) {
27172
27379
  if (message) {
27173
27380
  concern_messages.push({ rc, text: message });
27174
27381
  }
27175
- if (args.event === "session_start" && rc === EXIT_ALLOW20 && typeof reply["context"] === "string" && reply["context"].trim()) {
27382
+ if (args.event === "session_start" && rc === EXIT_ALLOW21 && typeof reply["context"] === "string" && reply["context"].trim()) {
27176
27383
  context_blocks.push(reply["context"].trim());
27177
27384
  }
27178
27385
  feedback_entries.push({
@@ -27191,7 +27398,7 @@ function main45(argv) {
27191
27398
  const final_rc = _reduce(rcs);
27192
27399
  _write_feedback(envelope, session_id, feedback_entries, final_rc, started_at);
27193
27400
  _record_rule_trips(envelope, feedback_entries);
27194
- if (context_blocks.length > 0 && final_rc === EXIT_ALLOW20) {
27401
+ if (context_blocks.length > 0 && final_rc === EXIT_ALLOW21) {
27195
27402
  process.stdout.write(context_blocks.join("\n\n") + "\n");
27196
27403
  }
27197
27404
  const decidingReasons = concern_messages.filter((m) => m.rc === final_rc).map((m) => m.text);
@@ -27212,7 +27419,7 @@ function main45(argv) {
27212
27419
  }
27213
27420
  function _isDir4(p) {
27214
27421
  try {
27215
- return fs63.statSync(p).isDirectory();
27422
+ return fs65.statSync(p).isDirectory();
27216
27423
  } catch {
27217
27424
  return false;
27218
27425
  }
@@ -27223,7 +27430,7 @@ function _sortedRepr(s) {
27223
27430
  }
27224
27431
  function _readStdin14() {
27225
27432
  try {
27226
- return fs63.readFileSync(0, "utf-8");
27433
+ return fs65.readFileSync(0, "utf-8");
27227
27434
  } catch {
27228
27435
  return "";
27229
27436
  }
@@ -27235,29 +27442,29 @@ function _isCliEntry36() {
27235
27442
  if (process.argv[1] === void 0) {
27236
27443
  return false;
27237
27444
  }
27238
- const argvUrl = pathToFileURL40(path65.resolve(process.argv[1])).href;
27445
+ const argvUrl = pathToFileURL41(path67.resolve(process.argv[1])).href;
27239
27446
  if (import.meta.url === argvUrl) {
27240
27447
  return true;
27241
27448
  }
27242
27449
  try {
27243
- const here = fs63.realpathSync(fileURLToPath46(import.meta.url));
27244
- const argv = fs63.realpathSync(path65.resolve(process.argv[1]));
27450
+ const here = fs65.realpathSync(fileURLToPath47(import.meta.url));
27451
+ const argv = fs65.realpathSync(path67.resolve(process.argv[1]));
27245
27452
  return here === argv;
27246
27453
  } catch {
27247
27454
  return false;
27248
27455
  }
27249
27456
  }
27250
- var isCliEntry12 = _isCliEntry36();
27251
- if (isCliEntry12) {
27252
- process.exit(main45(process.argv.slice(2)));
27457
+ var isCliEntry13 = _isCliEntry36();
27458
+ if (isCliEntry13) {
27459
+ process.exit(main46(process.argv.slice(2)));
27253
27460
  }
27254
27461
 
27255
27462
  // src/scripts/hooks/dispatch_entry.ts
27256
- var _selfPath = fileURLToPath47(import.meta.url);
27257
- var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path66.resolve(process.argv[1]) === path66.resolve(_selfPath);
27463
+ var _selfPath = fileURLToPath48(import.meta.url);
27464
+ var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path68.resolve(process.argv[1]) === path68.resolve(_selfPath);
27258
27465
  if (_invokedDirectly2) {
27259
- process.exitCode = main45(process.argv.slice(2));
27466
+ process.exitCode = main46(process.argv.slice(2));
27260
27467
  }
27261
27468
  export {
27262
- main45 as main
27469
+ main46 as main
27263
27470
  };