@event4u/agent-config 10.2.0 → 10.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +168 -256
- package/README.md +1 -1
- package/dist/agent-src/commands/analyze/reference-repo.md +62 -0
- package/dist/agent-src/commands/analyze.md +2 -1
- package/dist/agent-src/commands/design-system/capture.md +44 -0
- package/dist/agent-src/commands/design-system/generate.md +53 -0
- package/dist/agent-src/commands/design-system/import.md +63 -0
- package/dist/agent-src/commands/design-system.md +66 -0
- package/dist/agent-src/commands/roadmap/create.md +4 -1
- package/dist/agent-src/personas/advisors/first-principles.md +6 -0
- package/dist/agent-src/rules/active-remediation.md +53 -2
- package/dist/agent-src/rules/code-provenance.md +66 -4
- package/dist/agent-src/rules/content-quoting-floor.md +6 -0
- package/dist/agent-src/rules/design-fidelity.md +49 -3
- package/dist/agent-src/skills/design-review/references/verification-automation.md +23 -1
- package/dist/agent-src/skills/design-system-capture/SKILL.md +9 -0
- package/dist/agent-src/skills/design-system-capture/references/design-system-json.md +70 -0
- package/dist/agent-src/skills/fe-design/SKILL.md +27 -3
- package/dist/agent-src/skills/judge-synthesis/SKILL.md +30 -0
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +11 -0
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +8 -8
- package/dist/agent-src/skills/skill-writing/SKILL.md +4 -0
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/persona.md +26 -0
- package/dist/agent-src/templates/roadmaps.md +27 -7
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.ts +4 -1
- package/dist/agent-src/templates/skill.md +35 -1
- package/dist/cli/commands/commands.candidates.test.js +257 -0
- package/dist/cli/commands/commands.candidates.test.js.map +1 -0
- package/dist/cli/commands/commands.js +199 -0
- package/dist/cli/commands/commands.js.map +1 -1
- package/dist/cli/main.js +1 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/registry.js +1 -1
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/{chunk-E4RUZKXB.js → chunk-FV34EGEX.js} +1 -1
- package/dist/cli-delegate/chunk-RLN73PR5.js +157 -0
- package/dist/cli-delegate/{chunk-I5EAFRII.js → chunk-ZPSXJTLI.js} +2 -154
- package/dist/cli-delegate/cmd_conformance.js +672 -214
- package/dist/cli-delegate/cmd_doctor.js +1 -1
- package/dist/cli-delegate/cmd_handoff.js +8 -6
- package/dist/cli-delegate/cmd_session_recycle.js +5 -3
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +127 -22
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -3
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +9 -5
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +8 -4
- package/dist/hooks/dispatch.js +1056 -411
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +1103 -593
- package/dist/router.json +1 -1
- package/docs/guidelines/agent-infra/active-remediation-mechanics.md +54 -0
- package/docs/guidelines/design-antipatterns.md +79 -10
- package/docs/guidelines/design-fidelity-mechanics.md +120 -2
- package/package.json +1 -1
- package/src/agent-src/templates/scripts/work_engine/directives/ui/design.ts +4 -1
- package/src/config/gate-coverage.yml +65 -10
- package/src/config/gate-violation-baselines.json +6 -0
- package/src/config/review-prompt-binding-baseline.json +19 -0
- package/src/config/rule-enforcement-baseline.json +0 -1
- package/src/scripts/_dispatch.bash +1 -0
- package/src/scripts/_lib/design_system_import.ts +987 -0
- package/src/scripts/ai_council/clients.ts +15 -1
- package/src/scripts/check_ci_local_parity.ts +60 -6
- package/src/scripts/check_review_prompt_binding.ts +553 -0
- package/src/scripts/check_suppression_hygiene.ts +19 -3
- package/src/scripts/design_slop_rules.test.ts +37 -6
- package/src/scripts/design_slop_rules.ts +150 -22
- package/src/scripts/design_system_import.ts +264 -0
- package/src/scripts/dispatch_r2_reviewer.ts +15 -1
- package/src/scripts/hook_manifest.yaml +71 -2
- package/src/scripts/hooks/concern_registry.ts +4 -0
- package/src/scripts/hooks/dispatch_hook.ts +10 -0
- package/src/scripts/hooks/host_semantics.ts +2 -0
- package/src/scripts/hooks/spawn_guard_shadow_hook.ts +212 -0
- package/src/scripts/hooks/subagent_ledger_hook.ts +723 -0
- package/src/scripts/hooks/turn_end_gate_hook.ts +39 -2
- package/src/scripts/hooks/ui_route_nudge_hook.ts +55 -2
- package/src/scripts/lint_design_antipattern_parity.ts +201 -0
- package/src/scripts/lint_harvest_provenance.ts +483 -0
- package/src/scripts/lint_hook_manifest.ts +2 -0
- package/src/scripts/lint_rule_skill_pack_reach.ts +194 -13
- package/src/scripts/lint_skill_router_head.ts +254 -0
- package/src/scripts/report_consultation_rate.ts +126 -1
- package/src/scripts/run_skill_evals.ts +10 -5
- package/src/scripts/schemas/persona.schema.json +8 -0
- package/src/scripts/schemas/provenance-harvest.schema.json +39 -0
- package/src/scripts/sweep_dead_scan_roots.ts +51 -0
- package/tests/fixtures/hooks/subagent_start.json +7 -0
- package/tests/fixtures/hooks/subagent_stop.json +8 -0
package/dist/hooks/dispatch.js
CHANGED
|
@@ -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,
|
|
116
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
115
|
+
function visit_(key, node, visitor, path71) {
|
|
116
|
+
const ctrl = callVisitor(key, node, visitor, path71);
|
|
117
117
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
118
|
-
replaceNode(key,
|
|
119
|
-
return visit_(key, ctrl, visitor,
|
|
118
|
+
replaceNode(key, path71, ctrl);
|
|
119
|
+
return visit_(key, ctrl, visitor, path71);
|
|
120
120
|
}
|
|
121
121
|
if (typeof ctrl !== "symbol") {
|
|
122
122
|
if (identity.isCollection(node)) {
|
|
123
|
-
|
|
123
|
+
path71 = Object.freeze(path71.concat(node));
|
|
124
124
|
for (let i = 0; i < node.items.length; ++i) {
|
|
125
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
125
|
+
const ci = visit_(i, node.items[i], visitor, path71);
|
|
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
|
-
|
|
137
|
-
const ck = visit_("key", node.key, visitor,
|
|
136
|
+
path71 = Object.freeze(path71.concat(node));
|
|
137
|
+
const ck = visit_("key", node.key, visitor, path71);
|
|
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,
|
|
142
|
+
const cv = visit_("value", node.value, visitor, path71);
|
|
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,
|
|
164
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
163
|
+
async function visitAsync_(key, node, visitor, path71) {
|
|
164
|
+
const ctrl = await callVisitor(key, node, visitor, path71);
|
|
165
165
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
166
|
-
replaceNode(key,
|
|
167
|
-
return visitAsync_(key, ctrl, visitor,
|
|
166
|
+
replaceNode(key, path71, ctrl);
|
|
167
|
+
return visitAsync_(key, ctrl, visitor, path71);
|
|
168
168
|
}
|
|
169
169
|
if (typeof ctrl !== "symbol") {
|
|
170
170
|
if (identity.isCollection(node)) {
|
|
171
|
-
|
|
171
|
+
path71 = Object.freeze(path71.concat(node));
|
|
172
172
|
for (let i = 0; i < node.items.length; ++i) {
|
|
173
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
173
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path71);
|
|
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
|
-
|
|
185
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
184
|
+
path71 = Object.freeze(path71.concat(node));
|
|
185
|
+
const ck = await visitAsync_("key", node.key, visitor, path71);
|
|
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,
|
|
190
|
+
const cv = await visitAsync_("value", node.value, visitor, path71);
|
|
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,
|
|
217
|
+
function callVisitor(key, node, visitor, path71) {
|
|
218
218
|
if (typeof visitor === "function")
|
|
219
|
-
return visitor(key, node,
|
|
219
|
+
return visitor(key, node, path71);
|
|
220
220
|
if (identity.isMap(node))
|
|
221
|
-
return visitor.Map?.(key, node,
|
|
221
|
+
return visitor.Map?.(key, node, path71);
|
|
222
222
|
if (identity.isSeq(node))
|
|
223
|
-
return visitor.Seq?.(key, node,
|
|
223
|
+
return visitor.Seq?.(key, node, path71);
|
|
224
224
|
if (identity.isPair(node))
|
|
225
|
-
return visitor.Pair?.(key, node,
|
|
225
|
+
return visitor.Pair?.(key, node, path71);
|
|
226
226
|
if (identity.isScalar(node))
|
|
227
|
-
return visitor.Scalar?.(key, node,
|
|
227
|
+
return visitor.Scalar?.(key, node, path71);
|
|
228
228
|
if (identity.isAlias(node))
|
|
229
|
-
return visitor.Alias?.(key, node,
|
|
229
|
+
return visitor.Alias?.(key, node, path71);
|
|
230
230
|
return void 0;
|
|
231
231
|
}
|
|
232
|
-
function replaceNode(key,
|
|
233
|
-
const parent =
|
|
232
|
+
function replaceNode(key, path71, node) {
|
|
233
|
+
const parent = path71[path71.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,
|
|
843
|
+
function collectionFromPath(schema, path71, value) {
|
|
844
844
|
let v = value;
|
|
845
|
-
for (let i =
|
|
846
|
-
const k =
|
|
845
|
+
for (let i = path71.length - 1; i >= 0; --i) {
|
|
846
|
+
const k = path71[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 = (
|
|
865
|
+
var isEmptyPath = (path71) => path71 == null || typeof path71 === "object" && !!path71[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(
|
|
896
|
-
if (isEmptyPath(
|
|
895
|
+
addIn(path71, value) {
|
|
896
|
+
if (isEmptyPath(path71))
|
|
897
897
|
this.add(value);
|
|
898
898
|
else {
|
|
899
|
-
const [key, ...rest] =
|
|
899
|
+
const [key, ...rest] = path71;
|
|
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(
|
|
914
|
-
const [key, ...rest] =
|
|
913
|
+
deleteIn(path71) {
|
|
914
|
+
const [key, ...rest] = path71;
|
|
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(
|
|
929
|
-
const [key, ...rest] =
|
|
928
|
+
getIn(path71, keepScalar) {
|
|
929
|
+
const [key, ...rest] = path71;
|
|
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(
|
|
948
|
-
const [key, ...rest] =
|
|
947
|
+
hasIn(path71) {
|
|
948
|
+
const [key, ...rest] = path71;
|
|
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(
|
|
959
|
-
const [key, ...rest] =
|
|
958
|
+
setIn(path71, value) {
|
|
959
|
+
const [key, ...rest] = path71;
|
|
960
960
|
if (rest.length === 0) {
|
|
961
961
|
this.set(key, value);
|
|
962
962
|
} else {
|
|
@@ -980,13 +980,13 @@ var require_Collection = __commonJS({
|
|
|
980
980
|
var require_stringifyComment = __commonJS({
|
|
981
981
|
"node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
|
|
982
982
|
"use strict";
|
|
983
|
-
var stringifyComment = (
|
|
983
|
+
var stringifyComment = (str9) => str9.replace(/^(?!$)(?: $)?/gm, "#");
|
|
984
984
|
function indentComment(comment, indent) {
|
|
985
985
|
if (/^\n+$/.test(comment))
|
|
986
986
|
return comment.substring(1);
|
|
987
987
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
988
988
|
}
|
|
989
|
-
var lineComment = (
|
|
989
|
+
var lineComment = (str9, indent, comment) => str9.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str9.endsWith(" ") ? "" : " ") + comment;
|
|
990
990
|
exports.indentComment = indentComment;
|
|
991
991
|
exports.lineComment = lineComment;
|
|
992
992
|
exports.stringifyComment = stringifyComment;
|
|
@@ -1140,16 +1140,16 @@ var require_stringifyString = __commonJS({
|
|
|
1140
1140
|
lineWidth: ctx.options.lineWidth,
|
|
1141
1141
|
minContentWidth: ctx.options.minContentWidth
|
|
1142
1142
|
});
|
|
1143
|
-
var containsDocumentMarker = (
|
|
1144
|
-
function lineLengthOverLimit(
|
|
1143
|
+
var containsDocumentMarker = (str9) => /^(%|---|\.\.\.)/m.test(str9);
|
|
1144
|
+
function lineLengthOverLimit(str9, lineWidth, indentLength) {
|
|
1145
1145
|
if (!lineWidth || lineWidth < 0)
|
|
1146
1146
|
return false;
|
|
1147
1147
|
const limit = lineWidth - indentLength;
|
|
1148
|
-
const strLen =
|
|
1148
|
+
const strLen = str9.length;
|
|
1149
1149
|
if (strLen <= limit)
|
|
1150
1150
|
return false;
|
|
1151
1151
|
for (let i = 0, start = 0; i < strLen; ++i) {
|
|
1152
|
-
if (
|
|
1152
|
+
if (str9[i] === "\n") {
|
|
1153
1153
|
if (i - start > limit)
|
|
1154
1154
|
return true;
|
|
1155
1155
|
start = i + 1;
|
|
@@ -1166,11 +1166,11 @@ var require_stringifyString = __commonJS({
|
|
|
1166
1166
|
const { implicitKey } = ctx;
|
|
1167
1167
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
1168
1168
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
1169
|
-
let
|
|
1169
|
+
let str9 = "";
|
|
1170
1170
|
let start = 0;
|
|
1171
1171
|
for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
|
|
1172
1172
|
if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") {
|
|
1173
|
-
|
|
1173
|
+
str9 += json.slice(start, i) + "\\ ";
|
|
1174
1174
|
i += 1;
|
|
1175
1175
|
start = i;
|
|
1176
1176
|
ch = "\\";
|
|
@@ -1179,38 +1179,38 @@ var require_stringifyString = __commonJS({
|
|
|
1179
1179
|
switch (json[i + 1]) {
|
|
1180
1180
|
case "u":
|
|
1181
1181
|
{
|
|
1182
|
-
|
|
1182
|
+
str9 += json.slice(start, i);
|
|
1183
1183
|
const code = json.substr(i + 2, 4);
|
|
1184
1184
|
switch (code) {
|
|
1185
1185
|
case "0000":
|
|
1186
|
-
|
|
1186
|
+
str9 += "\\0";
|
|
1187
1187
|
break;
|
|
1188
1188
|
case "0007":
|
|
1189
|
-
|
|
1189
|
+
str9 += "\\a";
|
|
1190
1190
|
break;
|
|
1191
1191
|
case "000b":
|
|
1192
|
-
|
|
1192
|
+
str9 += "\\v";
|
|
1193
1193
|
break;
|
|
1194
1194
|
case "001b":
|
|
1195
|
-
|
|
1195
|
+
str9 += "\\e";
|
|
1196
1196
|
break;
|
|
1197
1197
|
case "0085":
|
|
1198
|
-
|
|
1198
|
+
str9 += "\\N";
|
|
1199
1199
|
break;
|
|
1200
1200
|
case "00a0":
|
|
1201
|
-
|
|
1201
|
+
str9 += "\\_";
|
|
1202
1202
|
break;
|
|
1203
1203
|
case "2028":
|
|
1204
|
-
|
|
1204
|
+
str9 += "\\L";
|
|
1205
1205
|
break;
|
|
1206
1206
|
case "2029":
|
|
1207
|
-
|
|
1207
|
+
str9 += "\\P";
|
|
1208
1208
|
break;
|
|
1209
1209
|
default:
|
|
1210
1210
|
if (code.substr(0, 2) === "00")
|
|
1211
|
-
|
|
1211
|
+
str9 += "\\x" + code.substr(2);
|
|
1212
1212
|
else
|
|
1213
|
-
|
|
1213
|
+
str9 += json.substr(i, 6);
|
|
1214
1214
|
}
|
|
1215
1215
|
i += 5;
|
|
1216
1216
|
start = i + 1;
|
|
@@ -1220,14 +1220,14 @@ var require_stringifyString = __commonJS({
|
|
|
1220
1220
|
if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
|
|
1221
1221
|
i += 1;
|
|
1222
1222
|
} else {
|
|
1223
|
-
|
|
1223
|
+
str9 += json.slice(start, i) + "\n\n";
|
|
1224
1224
|
while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') {
|
|
1225
|
-
|
|
1225
|
+
str9 += "\n";
|
|
1226
1226
|
i += 2;
|
|
1227
1227
|
}
|
|
1228
|
-
|
|
1228
|
+
str9 += indent;
|
|
1229
1229
|
if (json[i + 2] === " ")
|
|
1230
|
-
|
|
1230
|
+
str9 += "\\";
|
|
1231
1231
|
i += 1;
|
|
1232
1232
|
start = i + 1;
|
|
1233
1233
|
}
|
|
@@ -1236,8 +1236,8 @@ var require_stringifyString = __commonJS({
|
|
|
1236
1236
|
i += 1;
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
|
-
|
|
1240
|
-
return implicitKey ?
|
|
1239
|
+
str9 = start ? str9 + json.slice(start) : json;
|
|
1240
|
+
return implicitKey ? str9 : foldFlowLines.foldFlowLines(str9, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
1241
1241
|
}
|
|
1242
1242
|
function singleQuotedString(value, ctx) {
|
|
1243
1243
|
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
|
|
@@ -1365,15 +1365,15 @@ ${indent}${start}${value}${end}`;
|
|
|
1365
1365
|
return quotedString(value, ctx);
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
|
-
const
|
|
1368
|
+
const str9 = value.replace(/\n+/g, `$&
|
|
1369
1369
|
${indent}`);
|
|
1370
1370
|
if (actualString) {
|
|
1371
|
-
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(
|
|
1371
|
+
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str9);
|
|
1372
1372
|
const { compat, tags } = ctx.doc.schema;
|
|
1373
1373
|
if (tags.some(test) || compat?.some(test))
|
|
1374
1374
|
return quotedString(value, ctx);
|
|
1375
1375
|
}
|
|
1376
|
-
return implicitKey ?
|
|
1376
|
+
return implicitKey ? str9 : foldFlowLines.foldFlowLines(str9, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
1377
1377
|
}
|
|
1378
1378
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
1379
1379
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -1525,11 +1525,11 @@ var require_stringify = __commonJS({
|
|
|
1525
1525
|
const props = stringifyProps(node, tagObj, ctx);
|
|
1526
1526
|
if (props.length > 0)
|
|
1527
1527
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1528
|
-
const
|
|
1528
|
+
const str9 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
1529
1529
|
if (!props)
|
|
1530
|
-
return
|
|
1531
|
-
return identity.isScalar(node) ||
|
|
1532
|
-
${ctx.indent}${
|
|
1530
|
+
return str9;
|
|
1531
|
+
return identity.isScalar(node) || str9[0] === "{" || str9[0] === "[" ? `${props} ${str9}` : `${props}
|
|
1532
|
+
${ctx.indent}${str9}`;
|
|
1533
1533
|
}
|
|
1534
1534
|
exports.createStringifyContext = createStringifyContext;
|
|
1535
1535
|
exports.stringify = stringify;
|
|
@@ -1564,8 +1564,8 @@ var require_stringifyPair = __commonJS({
|
|
|
1564
1564
|
});
|
|
1565
1565
|
let keyCommentDone = false;
|
|
1566
1566
|
let chompKeep = false;
|
|
1567
|
-
let
|
|
1568
|
-
if (!explicitKey && !ctx.inFlow &&
|
|
1567
|
+
let str9 = stringify.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
1568
|
+
if (!explicitKey && !ctx.inFlow && str9.length > 1024) {
|
|
1569
1569
|
if (simpleKeys)
|
|
1570
1570
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1571
1571
|
explicitKey = true;
|
|
@@ -1574,27 +1574,27 @@ var require_stringifyPair = __commonJS({
|
|
|
1574
1574
|
if (allNullValues || value == null) {
|
|
1575
1575
|
if (keyCommentDone && onComment)
|
|
1576
1576
|
onComment();
|
|
1577
|
-
return
|
|
1577
|
+
return str9 === "" ? "?" : explicitKey ? `? ${str9}` : str9;
|
|
1578
1578
|
}
|
|
1579
1579
|
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
|
|
1580
|
-
|
|
1580
|
+
str9 = `? ${str9}`;
|
|
1581
1581
|
if (keyComment && !keyCommentDone) {
|
|
1582
|
-
|
|
1582
|
+
str9 += stringifyComment.lineComment(str9, ctx.indent, commentString(keyComment));
|
|
1583
1583
|
} else if (chompKeep && onChompKeep)
|
|
1584
1584
|
onChompKeep();
|
|
1585
|
-
return
|
|
1585
|
+
return str9;
|
|
1586
1586
|
}
|
|
1587
1587
|
if (keyCommentDone)
|
|
1588
1588
|
keyComment = null;
|
|
1589
1589
|
if (explicitKey) {
|
|
1590
1590
|
if (keyComment)
|
|
1591
|
-
|
|
1592
|
-
|
|
1591
|
+
str9 += stringifyComment.lineComment(str9, ctx.indent, commentString(keyComment));
|
|
1592
|
+
str9 = `? ${str9}
|
|
1593
1593
|
${indent}:`;
|
|
1594
1594
|
} else {
|
|
1595
|
-
|
|
1595
|
+
str9 = `${str9}:`;
|
|
1596
1596
|
if (keyComment)
|
|
1597
|
-
|
|
1597
|
+
str9 += stringifyComment.lineComment(str9, ctx.indent, commentString(keyComment));
|
|
1598
1598
|
}
|
|
1599
1599
|
let vsb, vcb, valueComment;
|
|
1600
1600
|
if (identity.isNode(value)) {
|
|
@@ -1610,7 +1610,7 @@ ${indent}:`;
|
|
|
1610
1610
|
}
|
|
1611
1611
|
ctx.implicitKey = false;
|
|
1612
1612
|
if (!explicitKey && !keyComment && identity.isScalar(value))
|
|
1613
|
-
ctx.indentAtStart =
|
|
1613
|
+
ctx.indentAtStart = str9.length + 1;
|
|
1614
1614
|
chompKeep = false;
|
|
1615
1615
|
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
1616
1616
|
ctx.indent = ctx.indent.substring(2);
|
|
@@ -1654,16 +1654,16 @@ ${ctx.indent}`;
|
|
|
1654
1654
|
} else if (valueStr === "" || valueStr[0] === "\n") {
|
|
1655
1655
|
ws = "";
|
|
1656
1656
|
}
|
|
1657
|
-
|
|
1657
|
+
str9 += ws + valueStr;
|
|
1658
1658
|
if (ctx.inFlow) {
|
|
1659
1659
|
if (valueCommentDone && onComment)
|
|
1660
1660
|
onComment();
|
|
1661
1661
|
} else if (valueComment && !valueCommentDone) {
|
|
1662
|
-
|
|
1662
|
+
str9 += stringifyComment.lineComment(str9, ctx.indent, commentString(valueComment));
|
|
1663
1663
|
} else if (chompKeep && onChompKeep) {
|
|
1664
1664
|
onChompKeep();
|
|
1665
1665
|
}
|
|
1666
|
-
return
|
|
1666
|
+
return str9;
|
|
1667
1667
|
}
|
|
1668
1668
|
exports.stringifyPair = stringifyPair;
|
|
1669
1669
|
}
|
|
@@ -1890,31 +1890,31 @@ var require_stringifyCollection = __commonJS({
|
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
1892
|
chompKeep = false;
|
|
1893
|
-
let
|
|
1893
|
+
let str10 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
1894
1894
|
if (comment2)
|
|
1895
|
-
|
|
1895
|
+
str10 += stringifyComment.lineComment(str10, itemIndent, commentString(comment2));
|
|
1896
1896
|
if (chompKeep && comment2)
|
|
1897
1897
|
chompKeep = false;
|
|
1898
|
-
lines.push(blockItemPrefix +
|
|
1898
|
+
lines.push(blockItemPrefix + str10);
|
|
1899
1899
|
}
|
|
1900
|
-
let
|
|
1900
|
+
let str9;
|
|
1901
1901
|
if (lines.length === 0) {
|
|
1902
|
-
|
|
1902
|
+
str9 = flowChars.start + flowChars.end;
|
|
1903
1903
|
} else {
|
|
1904
|
-
|
|
1904
|
+
str9 = lines[0];
|
|
1905
1905
|
for (let i = 1; i < lines.length; ++i) {
|
|
1906
1906
|
const line = lines[i];
|
|
1907
|
-
|
|
1907
|
+
str9 += line ? `
|
|
1908
1908
|
${indent}${line}` : "\n";
|
|
1909
1909
|
}
|
|
1910
1910
|
}
|
|
1911
1911
|
if (comment) {
|
|
1912
|
-
|
|
1912
|
+
str9 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
|
|
1913
1913
|
if (onComment)
|
|
1914
1914
|
onComment();
|
|
1915
1915
|
} else if (chompKeep && onChompKeep)
|
|
1916
1916
|
onChompKeep();
|
|
1917
|
-
return
|
|
1917
|
+
return str9;
|
|
1918
1918
|
}
|
|
1919
1919
|
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
1920
1920
|
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
@@ -1957,21 +1957,21 @@ ${indent}${line}` : "\n";
|
|
|
1957
1957
|
}
|
|
1958
1958
|
if (comment)
|
|
1959
1959
|
reqNewline = true;
|
|
1960
|
-
let
|
|
1961
|
-
reqNewline || (reqNewline = lines.length > linesAtValue ||
|
|
1960
|
+
let str9 = stringify.stringify(item, itemCtx, () => comment = null);
|
|
1961
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str9.includes("\n"));
|
|
1962
1962
|
if (i < items.length - 1) {
|
|
1963
|
-
|
|
1963
|
+
str9 += ",";
|
|
1964
1964
|
} else if (ctx.options.trailingComma) {
|
|
1965
1965
|
if (ctx.options.lineWidth > 0) {
|
|
1966
|
-
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (
|
|
1966
|
+
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str9.length + 2) > ctx.options.lineWidth);
|
|
1967
1967
|
}
|
|
1968
1968
|
if (reqNewline) {
|
|
1969
|
-
|
|
1969
|
+
str9 += ",";
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
1972
|
if (comment)
|
|
1973
|
-
|
|
1974
|
-
lines.push(
|
|
1973
|
+
str9 += stringifyComment.lineComment(str9, itemIndent, commentString(comment));
|
|
1974
|
+
lines.push(str9);
|
|
1975
1975
|
linesAtValue = lines.length;
|
|
1976
1976
|
}
|
|
1977
1977
|
const { start, end } = flowChars;
|
|
@@ -1983,11 +1983,11 @@ ${indent}${line}` : "\n";
|
|
|
1983
1983
|
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
1984
1984
|
}
|
|
1985
1985
|
if (reqNewline) {
|
|
1986
|
-
let
|
|
1986
|
+
let str9 = start;
|
|
1987
1987
|
for (const line of lines)
|
|
1988
|
-
|
|
1988
|
+
str9 += line ? `
|
|
1989
1989
|
${indentStep}${indent}${line}` : "\n";
|
|
1990
|
-
return `${
|
|
1990
|
+
return `${str9}
|
|
1991
1991
|
${indent}${end}`;
|
|
1992
1992
|
} else {
|
|
1993
1993
|
return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
@@ -2319,7 +2319,7 @@ var require_string = __commonJS({
|
|
|
2319
2319
|
identify: (value) => typeof value === "string",
|
|
2320
2320
|
default: true,
|
|
2321
2321
|
tag: "tag:yaml.org,2002:str",
|
|
2322
|
-
resolve: (
|
|
2322
|
+
resolve: (str9) => str9,
|
|
2323
2323
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
2324
2324
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
2325
2325
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
@@ -2357,7 +2357,7 @@ var require_bool = __commonJS({
|
|
|
2357
2357
|
default: true,
|
|
2358
2358
|
tag: "tag:yaml.org,2002:bool",
|
|
2359
2359
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2360
|
-
resolve: (
|
|
2360
|
+
resolve: (str9) => new Scalar.Scalar(str9[0] === "t" || str9[0] === "T"),
|
|
2361
2361
|
stringify({ source, value }, ctx) {
|
|
2362
2362
|
if (source && boolTag.test.test(source)) {
|
|
2363
2363
|
const sv = source[0] === "t" || source[0] === "T";
|
|
@@ -2409,7 +2409,7 @@ var require_float = __commonJS({
|
|
|
2409
2409
|
default: true,
|
|
2410
2410
|
tag: "tag:yaml.org,2002:float",
|
|
2411
2411
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2412
|
-
resolve: (
|
|
2412
|
+
resolve: (str9) => str9.slice(-3).toLowerCase() === "nan" ? NaN : str9[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2413
2413
|
stringify: stringifyNumber.stringifyNumber
|
|
2414
2414
|
};
|
|
2415
2415
|
var floatExp = {
|
|
@@ -2418,7 +2418,7 @@ var require_float = __commonJS({
|
|
|
2418
2418
|
tag: "tag:yaml.org,2002:float",
|
|
2419
2419
|
format: "EXP",
|
|
2420
2420
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2421
|
-
resolve: (
|
|
2421
|
+
resolve: (str9) => parseFloat(str9),
|
|
2422
2422
|
stringify(node) {
|
|
2423
2423
|
const num = Number(node.value);
|
|
2424
2424
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2429,11 +2429,11 @@ var require_float = __commonJS({
|
|
|
2429
2429
|
default: true,
|
|
2430
2430
|
tag: "tag:yaml.org,2002:float",
|
|
2431
2431
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
2432
|
-
resolve(
|
|
2433
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2434
|
-
const dot =
|
|
2435
|
-
if (dot !== -1 &&
|
|
2436
|
-
node.minFractionDigits =
|
|
2432
|
+
resolve(str9) {
|
|
2433
|
+
const node = new Scalar.Scalar(parseFloat(str9));
|
|
2434
|
+
const dot = str9.indexOf(".");
|
|
2435
|
+
if (dot !== -1 && str9[str9.length - 1] === "0")
|
|
2436
|
+
node.minFractionDigits = str9.length - dot - 1;
|
|
2437
2437
|
return node;
|
|
2438
2438
|
},
|
|
2439
2439
|
stringify: stringifyNumber.stringifyNumber
|
|
@@ -2450,7 +2450,7 @@ var require_int = __commonJS({
|
|
|
2450
2450
|
"use strict";
|
|
2451
2451
|
var stringifyNumber = require_stringifyNumber();
|
|
2452
2452
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2453
|
-
var intResolve = (
|
|
2453
|
+
var intResolve = (str9, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str9) : parseInt(str9.substring(offset), radix);
|
|
2454
2454
|
function intStringify(node, radix, prefix) {
|
|
2455
2455
|
const { value } = node;
|
|
2456
2456
|
if (intIdentify(value) && value >= 0)
|
|
@@ -2463,7 +2463,7 @@ var require_int = __commonJS({
|
|
|
2463
2463
|
tag: "tag:yaml.org,2002:int",
|
|
2464
2464
|
format: "OCT",
|
|
2465
2465
|
test: /^0o[0-7]+$/,
|
|
2466
|
-
resolve: (
|
|
2466
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 2, 8, opt),
|
|
2467
2467
|
stringify: (node) => intStringify(node, 8, "0o")
|
|
2468
2468
|
};
|
|
2469
2469
|
var int2 = {
|
|
@@ -2471,7 +2471,7 @@ var require_int = __commonJS({
|
|
|
2471
2471
|
default: true,
|
|
2472
2472
|
tag: "tag:yaml.org,2002:int",
|
|
2473
2473
|
test: /^[-+]?[0-9]+$/,
|
|
2474
|
-
resolve: (
|
|
2474
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 0, 10, opt),
|
|
2475
2475
|
stringify: stringifyNumber.stringifyNumber
|
|
2476
2476
|
};
|
|
2477
2477
|
var intHex = {
|
|
@@ -2480,7 +2480,7 @@ var require_int = __commonJS({
|
|
|
2480
2480
|
tag: "tag:yaml.org,2002:int",
|
|
2481
2481
|
format: "HEX",
|
|
2482
2482
|
test: /^0x[0-9a-fA-F]+$/,
|
|
2483
|
-
resolve: (
|
|
2483
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 2, 16, opt),
|
|
2484
2484
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2485
2485
|
};
|
|
2486
2486
|
exports.int = int2;
|
|
@@ -2533,7 +2533,7 @@ var require_schema2 = __commonJS({
|
|
|
2533
2533
|
identify: (value) => typeof value === "string",
|
|
2534
2534
|
default: true,
|
|
2535
2535
|
tag: "tag:yaml.org,2002:str",
|
|
2536
|
-
resolve: (
|
|
2536
|
+
resolve: (str9) => str9,
|
|
2537
2537
|
stringify: stringifyJSON
|
|
2538
2538
|
},
|
|
2539
2539
|
{
|
|
@@ -2550,7 +2550,7 @@ var require_schema2 = __commonJS({
|
|
|
2550
2550
|
default: true,
|
|
2551
2551
|
tag: "tag:yaml.org,2002:bool",
|
|
2552
2552
|
test: /^true$|^false$/,
|
|
2553
|
-
resolve: (
|
|
2553
|
+
resolve: (str9) => str9 === "true",
|
|
2554
2554
|
stringify: stringifyJSON
|
|
2555
2555
|
},
|
|
2556
2556
|
{
|
|
@@ -2558,7 +2558,7 @@ var require_schema2 = __commonJS({
|
|
|
2558
2558
|
default: true,
|
|
2559
2559
|
tag: "tag:yaml.org,2002:int",
|
|
2560
2560
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
2561
|
-
resolve: (
|
|
2561
|
+
resolve: (str9, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str9) : parseInt(str9, 10),
|
|
2562
2562
|
stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value)
|
|
2563
2563
|
},
|
|
2564
2564
|
{
|
|
@@ -2566,7 +2566,7 @@ var require_schema2 = __commonJS({
|
|
|
2566
2566
|
default: true,
|
|
2567
2567
|
tag: "tag:yaml.org,2002:float",
|
|
2568
2568
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
2569
|
-
resolve: (
|
|
2569
|
+
resolve: (str9) => parseFloat(str9),
|
|
2570
2570
|
stringify: stringifyJSON
|
|
2571
2571
|
}
|
|
2572
2572
|
];
|
|
@@ -2574,9 +2574,9 @@ var require_schema2 = __commonJS({
|
|
|
2574
2574
|
default: true,
|
|
2575
2575
|
tag: "",
|
|
2576
2576
|
test: /^/,
|
|
2577
|
-
resolve(
|
|
2578
|
-
onError(`Unresolved plain scalar ${JSON.stringify(
|
|
2579
|
-
return
|
|
2577
|
+
resolve(str9, onError) {
|
|
2578
|
+
onError(`Unresolved plain scalar ${JSON.stringify(str9)}`);
|
|
2579
|
+
return str9;
|
|
2580
2580
|
}
|
|
2581
2581
|
};
|
|
2582
2582
|
var schema = [map.map, seq.seq].concat(jsonScalars, jsonError);
|
|
@@ -2608,10 +2608,10 @@ var require_binary = __commonJS({
|
|
|
2608
2608
|
if (typeof node_buffer.Buffer === "function") {
|
|
2609
2609
|
return node_buffer.Buffer.from(src, "base64");
|
|
2610
2610
|
} else if (typeof atob === "function") {
|
|
2611
|
-
const
|
|
2612
|
-
const buffer = new Uint8Array(
|
|
2613
|
-
for (let i = 0; i <
|
|
2614
|
-
buffer[i] =
|
|
2611
|
+
const str9 = atob(src.replace(/[\n\r]/g, ""));
|
|
2612
|
+
const buffer = new Uint8Array(str9.length);
|
|
2613
|
+
for (let i = 0; i < str9.length; ++i)
|
|
2614
|
+
buffer[i] = str9.charCodeAt(i);
|
|
2615
2615
|
return buffer;
|
|
2616
2616
|
} else {
|
|
2617
2617
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -2622,28 +2622,28 @@ var require_binary = __commonJS({
|
|
|
2622
2622
|
if (!value)
|
|
2623
2623
|
return "";
|
|
2624
2624
|
const buf = value;
|
|
2625
|
-
let
|
|
2625
|
+
let str9;
|
|
2626
2626
|
if (typeof node_buffer.Buffer === "function") {
|
|
2627
|
-
|
|
2627
|
+
str9 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
2628
2628
|
} else if (typeof btoa === "function") {
|
|
2629
2629
|
let s = "";
|
|
2630
2630
|
for (let i = 0; i < buf.length; ++i)
|
|
2631
2631
|
s += String.fromCharCode(buf[i]);
|
|
2632
|
-
|
|
2632
|
+
str9 = btoa(s);
|
|
2633
2633
|
} else {
|
|
2634
2634
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
2635
2635
|
}
|
|
2636
2636
|
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
|
|
2637
2637
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
2638
2638
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2639
|
-
const n = Math.ceil(
|
|
2639
|
+
const n = Math.ceil(str9.length / lineWidth);
|
|
2640
2640
|
const lines = new Array(n);
|
|
2641
2641
|
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
2642
|
-
lines[i] =
|
|
2642
|
+
lines[i] = str9.substr(o, lineWidth);
|
|
2643
2643
|
}
|
|
2644
|
-
|
|
2644
|
+
str9 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
2645
2645
|
}
|
|
2646
|
-
return stringifyString.stringifyString({ comment, type, value:
|
|
2646
|
+
return stringifyString.stringifyString({ comment, type, value: str9 }, ctx, onComment, onChompKeep);
|
|
2647
2647
|
}
|
|
2648
2648
|
};
|
|
2649
2649
|
exports.binary = binary;
|
|
@@ -2849,7 +2849,7 @@ var require_float2 = __commonJS({
|
|
|
2849
2849
|
default: true,
|
|
2850
2850
|
tag: "tag:yaml.org,2002:float",
|
|
2851
2851
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2852
|
-
resolve: (
|
|
2852
|
+
resolve: (str9) => str9.slice(-3).toLowerCase() === "nan" ? NaN : str9[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2853
2853
|
stringify: stringifyNumber.stringifyNumber
|
|
2854
2854
|
};
|
|
2855
2855
|
var floatExp = {
|
|
@@ -2858,7 +2858,7 @@ var require_float2 = __commonJS({
|
|
|
2858
2858
|
tag: "tag:yaml.org,2002:float",
|
|
2859
2859
|
format: "EXP",
|
|
2860
2860
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2861
|
-
resolve: (
|
|
2861
|
+
resolve: (str9) => parseFloat(str9.replace(/_/g, "")),
|
|
2862
2862
|
stringify(node) {
|
|
2863
2863
|
const num = Number(node.value);
|
|
2864
2864
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2869,11 +2869,11 @@ var require_float2 = __commonJS({
|
|
|
2869
2869
|
default: true,
|
|
2870
2870
|
tag: "tag:yaml.org,2002:float",
|
|
2871
2871
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
2872
|
-
resolve(
|
|
2873
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2874
|
-
const dot =
|
|
2872
|
+
resolve(str9) {
|
|
2873
|
+
const node = new Scalar.Scalar(parseFloat(str9.replace(/_/g, "")));
|
|
2874
|
+
const dot = str9.indexOf(".");
|
|
2875
2875
|
if (dot !== -1) {
|
|
2876
|
-
const f =
|
|
2876
|
+
const f = str9.substring(dot + 1).replace(/_/g, "");
|
|
2877
2877
|
if (f[f.length - 1] === "0")
|
|
2878
2878
|
node.minFractionDigits = f.length;
|
|
2879
2879
|
}
|
|
@@ -2893,34 +2893,34 @@ var require_int2 = __commonJS({
|
|
|
2893
2893
|
"use strict";
|
|
2894
2894
|
var stringifyNumber = require_stringifyNumber();
|
|
2895
2895
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2896
|
-
function intResolve(
|
|
2897
|
-
const sign =
|
|
2896
|
+
function intResolve(str9, offset, radix, { intAsBigInt }) {
|
|
2897
|
+
const sign = str9[0];
|
|
2898
2898
|
if (sign === "-" || sign === "+")
|
|
2899
2899
|
offset += 1;
|
|
2900
|
-
|
|
2900
|
+
str9 = str9.substring(offset).replace(/_/g, "");
|
|
2901
2901
|
if (intAsBigInt) {
|
|
2902
2902
|
switch (radix) {
|
|
2903
2903
|
case 2:
|
|
2904
|
-
|
|
2904
|
+
str9 = `0b${str9}`;
|
|
2905
2905
|
break;
|
|
2906
2906
|
case 8:
|
|
2907
|
-
|
|
2907
|
+
str9 = `0o${str9}`;
|
|
2908
2908
|
break;
|
|
2909
2909
|
case 16:
|
|
2910
|
-
|
|
2910
|
+
str9 = `0x${str9}`;
|
|
2911
2911
|
break;
|
|
2912
2912
|
}
|
|
2913
|
-
const n2 = BigInt(
|
|
2913
|
+
const n2 = BigInt(str9);
|
|
2914
2914
|
return sign === "-" ? BigInt(-1) * n2 : n2;
|
|
2915
2915
|
}
|
|
2916
|
-
const n = parseInt(
|
|
2916
|
+
const n = parseInt(str9, radix);
|
|
2917
2917
|
return sign === "-" ? -1 * n : n;
|
|
2918
2918
|
}
|
|
2919
2919
|
function intStringify(node, radix, prefix) {
|
|
2920
2920
|
const { value } = node;
|
|
2921
2921
|
if (intIdentify(value)) {
|
|
2922
|
-
const
|
|
2923
|
-
return value < 0 ? "-" + prefix +
|
|
2922
|
+
const str9 = value.toString(radix);
|
|
2923
|
+
return value < 0 ? "-" + prefix + str9.substr(1) : prefix + str9;
|
|
2924
2924
|
}
|
|
2925
2925
|
return stringifyNumber.stringifyNumber(node);
|
|
2926
2926
|
}
|
|
@@ -2930,7 +2930,7 @@ var require_int2 = __commonJS({
|
|
|
2930
2930
|
tag: "tag:yaml.org,2002:int",
|
|
2931
2931
|
format: "BIN",
|
|
2932
2932
|
test: /^[-+]?0b[0-1_]+$/,
|
|
2933
|
-
resolve: (
|
|
2933
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 2, 2, opt),
|
|
2934
2934
|
stringify: (node) => intStringify(node, 2, "0b")
|
|
2935
2935
|
};
|
|
2936
2936
|
var intOct = {
|
|
@@ -2939,7 +2939,7 @@ var require_int2 = __commonJS({
|
|
|
2939
2939
|
tag: "tag:yaml.org,2002:int",
|
|
2940
2940
|
format: "OCT",
|
|
2941
2941
|
test: /^[-+]?0[0-7_]+$/,
|
|
2942
|
-
resolve: (
|
|
2942
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 1, 8, opt),
|
|
2943
2943
|
stringify: (node) => intStringify(node, 8, "0")
|
|
2944
2944
|
};
|
|
2945
2945
|
var int2 = {
|
|
@@ -2947,7 +2947,7 @@ var require_int2 = __commonJS({
|
|
|
2947
2947
|
default: true,
|
|
2948
2948
|
tag: "tag:yaml.org,2002:int",
|
|
2949
2949
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
2950
|
-
resolve: (
|
|
2950
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 0, 10, opt),
|
|
2951
2951
|
stringify: stringifyNumber.stringifyNumber
|
|
2952
2952
|
};
|
|
2953
2953
|
var intHex = {
|
|
@@ -2956,7 +2956,7 @@ var require_int2 = __commonJS({
|
|
|
2956
2956
|
tag: "tag:yaml.org,2002:int",
|
|
2957
2957
|
format: "HEX",
|
|
2958
2958
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
2959
|
-
resolve: (
|
|
2959
|
+
resolve: (str9, _onError, opt) => intResolve(str9, 2, 16, opt),
|
|
2960
2960
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2961
2961
|
};
|
|
2962
2962
|
exports.int = int2;
|
|
@@ -3060,9 +3060,9 @@ var require_timestamp = __commonJS({
|
|
|
3060
3060
|
"node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
3061
3061
|
"use strict";
|
|
3062
3062
|
var stringifyNumber = require_stringifyNumber();
|
|
3063
|
-
function parseSexagesimal(
|
|
3064
|
-
const sign =
|
|
3065
|
-
const parts = sign === "-" || sign === "+" ?
|
|
3063
|
+
function parseSexagesimal(str9, asBigInt) {
|
|
3064
|
+
const sign = str9[0];
|
|
3065
|
+
const parts = sign === "-" || sign === "+" ? str9.substring(1) : str9;
|
|
3066
3066
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
3067
3067
|
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
|
|
3068
3068
|
return sign === "-" ? num(-1) * res : res;
|
|
@@ -3099,7 +3099,7 @@ var require_timestamp = __commonJS({
|
|
|
3099
3099
|
tag: "tag:yaml.org,2002:int",
|
|
3100
3100
|
format: "TIME",
|
|
3101
3101
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
3102
|
-
resolve: (
|
|
3102
|
+
resolve: (str9, _onError, { intAsBigInt }) => parseSexagesimal(str9, intAsBigInt),
|
|
3103
3103
|
stringify: stringifySexagesimal
|
|
3104
3104
|
};
|
|
3105
3105
|
var floatTime = {
|
|
@@ -3108,7 +3108,7 @@ var require_timestamp = __commonJS({
|
|
|
3108
3108
|
tag: "tag:yaml.org,2002:float",
|
|
3109
3109
|
format: "TIME",
|
|
3110
3110
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
3111
|
-
resolve: (
|
|
3111
|
+
resolve: (str9) => parseSexagesimal(str9, false),
|
|
3112
3112
|
stringify: stringifySexagesimal
|
|
3113
3113
|
};
|
|
3114
3114
|
var timestamp = {
|
|
@@ -3119,8 +3119,8 @@ var require_timestamp = __commonJS({
|
|
|
3119
3119
|
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
3120
3120
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
3121
3121
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
3122
|
-
resolve(
|
|
3123
|
-
const match =
|
|
3122
|
+
resolve(str9) {
|
|
3123
|
+
const match = str9.match(timestamp.test);
|
|
3124
3124
|
if (!match)
|
|
3125
3125
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
3126
3126
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -3471,9 +3471,9 @@ var require_Document = __commonJS({
|
|
|
3471
3471
|
this.contents.add(value);
|
|
3472
3472
|
}
|
|
3473
3473
|
/** Adds a value to the document. */
|
|
3474
|
-
addIn(
|
|
3474
|
+
addIn(path71, value) {
|
|
3475
3475
|
if (assertCollection(this.contents))
|
|
3476
|
-
this.contents.addIn(
|
|
3476
|
+
this.contents.addIn(path71, 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(
|
|
3552
|
-
if (Collection.isEmptyPath(
|
|
3551
|
+
deleteIn(path71) {
|
|
3552
|
+
if (Collection.isEmptyPath(path71)) {
|
|
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(
|
|
3558
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path71) : 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(
|
|
3574
|
-
if (Collection.isEmptyPath(
|
|
3573
|
+
getIn(path71, keepScalar) {
|
|
3574
|
+
if (Collection.isEmptyPath(path71))
|
|
3575
3575
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3576
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3576
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path71, 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(
|
|
3588
|
-
if (Collection.isEmptyPath(
|
|
3587
|
+
hasIn(path71) {
|
|
3588
|
+
if (Collection.isEmptyPath(path71))
|
|
3589
3589
|
return this.contents !== void 0;
|
|
3590
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3590
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path71) : 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(
|
|
3608
|
-
if (Collection.isEmptyPath(
|
|
3607
|
+
setIn(path71, value) {
|
|
3608
|
+
if (Collection.isEmptyPath(path71)) {
|
|
3609
3609
|
this.contents = value;
|
|
3610
3610
|
} else if (this.contents == null) {
|
|
3611
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3611
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path71), value);
|
|
3612
3612
|
} else if (assertCollection(this.contents)) {
|
|
3613
|
-
this.contents.setIn(
|
|
3613
|
+
this.contents.setIn(path71, 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,
|
|
5573
|
+
visit.itemAtPath = (cst, path71) => {
|
|
5574
5574
|
let item = cst;
|
|
5575
|
-
for (const [field, index] of
|
|
5575
|
+
for (const [field, index] of path71) {
|
|
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,
|
|
5585
|
-
const parent = visit.itemAtPath(cst,
|
|
5586
|
-
const field =
|
|
5584
|
+
visit.parentCollection = (cst, path71) => {
|
|
5585
|
+
const parent = visit.itemAtPath(cst, path71.slice(0, -1));
|
|
5586
|
+
const field = path71[path71.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(
|
|
5593
|
-
let ctrl = visitor(item,
|
|
5592
|
+
function _visit(path71, item, visitor) {
|
|
5593
|
+
let ctrl = visitor(item, path71);
|
|
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(
|
|
5600
|
+
const ci = _visit(Object.freeze(path71.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,
|
|
5611
|
+
ctrl = ctrl(item, path71);
|
|
5612
5612
|
}
|
|
5613
5613
|
}
|
|
5614
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5614
|
+
return typeof ctrl === "function" ? ctrl(item, path71) : 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
|
|
6916
|
+
const fs68 = this.flowScalar(this.type);
|
|
6917
6917
|
if (atNextItem || it.value) {
|
|
6918
|
-
map.items.push({ start, key:
|
|
6918
|
+
map.items.push({ start, key: fs68, sep: [] });
|
|
6919
6919
|
this.onKeyLine = true;
|
|
6920
6920
|
} else if (it.sep) {
|
|
6921
|
-
this.stack.push(
|
|
6921
|
+
this.stack.push(fs68);
|
|
6922
6922
|
} else {
|
|
6923
|
-
Object.assign(it, { key:
|
|
6923
|
+
Object.assign(it, { key: fs68, 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
|
|
7051
|
+
const fs68 = this.flowScalar(this.type);
|
|
7052
7052
|
if (!it || it.value)
|
|
7053
|
-
fc.items.push({ start: [], key:
|
|
7053
|
+
fc.items.push({ start: [], key: fs68, sep: [] });
|
|
7054
7054
|
else if (it.sep)
|
|
7055
|
-
this.stack.push(
|
|
7055
|
+
this.stack.push(fs68);
|
|
7056
7056
|
else
|
|
7057
|
-
Object.assign(it, { key:
|
|
7057
|
+
Object.assign(it, { key: fs68, 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
|
|
7367
|
-
import { fileURLToPath as
|
|
7366
|
+
import * as path70 from "node:path";
|
|
7367
|
+
import { fileURLToPath as fileURLToPath50 } 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
|
|
7373
|
-
import
|
|
7374
|
-
import { fileURLToPath as
|
|
7372
|
+
import fs67 from "node:fs";
|
|
7373
|
+
import path69 from "node:path";
|
|
7374
|
+
import { fileURLToPath as fileURLToPath49, pathToFileURL as pathToFileURL43 } from "node:url";
|
|
7375
7375
|
|
|
7376
7376
|
// src/scripts/_lib/spawn_env.ts
|
|
7377
7377
|
var DENY_EXACT = /* @__PURE__ */ new Set([
|
|
@@ -23417,7 +23417,7 @@ var SLOP_RULES = [
|
|
|
23417
23417
|
}
|
|
23418
23418
|
},
|
|
23419
23419
|
{
|
|
23420
|
-
id: "slop-lock-shape",
|
|
23420
|
+
id: "slop-v8-lock-shape",
|
|
23421
23421
|
catalogId: "V8",
|
|
23422
23422
|
severity: "P2",
|
|
23423
23423
|
engines: ["css"],
|
|
@@ -23444,27 +23444,6 @@ var SLOP_RULES = [
|
|
|
23444
23444
|
return [];
|
|
23445
23445
|
}
|
|
23446
23446
|
},
|
|
23447
|
-
{
|
|
23448
|
-
id: "slop-lock-colour",
|
|
23449
|
-
catalogId: "C6",
|
|
23450
|
-
severity: "P3",
|
|
23451
|
-
engines: ["css"],
|
|
23452
|
-
description: "Colour Lock \u2014 multiple saturated accent hue families",
|
|
23453
|
-
message: "Several accent hue families read as no single accent identity; lock one (C6 / Colour Lock).",
|
|
23454
|
-
gated: (ctx) => ctx.has("colour lock", "color lock"),
|
|
23455
|
-
detect: ({ content }) => {
|
|
23456
|
-
const buckets = /* @__PURE__ */ new Set();
|
|
23457
|
-
for (const pm of content.matchAll(/#([0-9a-f]{3}|[0-9a-f]{6})\b/gi)) {
|
|
23458
|
-
const b = hueBucket("#" + (pm[1] ?? ""));
|
|
23459
|
-
if (b !== null) buckets.add(b);
|
|
23460
|
-
}
|
|
23461
|
-
if (buckets.size >= 3) {
|
|
23462
|
-
const idx = content.search(/#[0-9a-f]{3,6}\b/i);
|
|
23463
|
-
return [{ line: lineOf(content, Math.max(0, idx)), snippet: `${buckets.size} distinct accent hue families` }];
|
|
23464
|
-
}
|
|
23465
|
-
return [];
|
|
23466
|
-
}
|
|
23467
|
-
},
|
|
23468
23447
|
{
|
|
23469
23448
|
id: "slop-l9-section-monotony",
|
|
23470
23449
|
catalogId: "L9",
|
|
@@ -23506,6 +23485,116 @@ var SLOP_RULES = [
|
|
|
23506
23485
|
if (maxRun > 2) return [{ line: 1, snippet: `${maxRun} consecutive media+text sections` }];
|
|
23507
23486
|
return [];
|
|
23508
23487
|
}
|
|
23488
|
+
},
|
|
23489
|
+
// -------------------------------------------------------------------------
|
|
23490
|
+
// Catalog thresholds promoted to rules (road-to-design-detector-evidence
|
|
23491
|
+
// Phase 3). Each entry below already published its number in
|
|
23492
|
+
// docs/guidelines/design-antipatterns.md — the prose is the specification,
|
|
23493
|
+
// nothing here is invented, and each was graded per rule against the clean
|
|
23494
|
+
// corpus rather than as a batch.
|
|
23495
|
+
// -------------------------------------------------------------------------
|
|
23496
|
+
{
|
|
23497
|
+
id: "slop-v4-over-rounded",
|
|
23498
|
+
catalogId: "V4",
|
|
23499
|
+
severity: "P3",
|
|
23500
|
+
engines: ["css"],
|
|
23501
|
+
description: "border-radius > 16px on an element declared under 200px wide",
|
|
23502
|
+
message: "Heavy rounding on a small surface reads as scaffold-default; scale the radius to the element (V4).",
|
|
23503
|
+
gated: (ctx) => ctx.has("pill", "fully rounded", "soft ui", "claymorphism"),
|
|
23504
|
+
detect: ({ content }) => cssBlocks(content).filter((b) => {
|
|
23505
|
+
const r = /border-radius\s*:\s*(\d+)px/i.exec(b.body);
|
|
23506
|
+
if (!r?.[1]) return false;
|
|
23507
|
+
const radius = parseInt(r[1], 10);
|
|
23508
|
+
if (radius <= 16 || radius >= 100) return false;
|
|
23509
|
+
const size = /(?:^|[;{\s])(?:max-)?(?:width|height)\s*:\s*(\d+)px/i.exec(b.body);
|
|
23510
|
+
return size?.[1] !== void 0 && parseInt(size[1], 10) < 200;
|
|
23511
|
+
}).map((b) => ({ line: b.line, snippet: b.selector.slice(0, 80) }))
|
|
23512
|
+
},
|
|
23513
|
+
{
|
|
23514
|
+
id: "slop-c3-dark-glow",
|
|
23515
|
+
catalogId: "C3",
|
|
23516
|
+
severity: "P2",
|
|
23517
|
+
engines: ["css"],
|
|
23518
|
+
description: "Saturated zero-offset glow (box-shadow / text-shadow) in a dark context",
|
|
23519
|
+
message: "A neon glow on dark reads as gaming-UI default rather than a considered accent (C3).",
|
|
23520
|
+
gated: (ctx) => ctx.has("glow", "neon", "cyberpunk", "gaming"),
|
|
23521
|
+
detect: ({ content, lines }) => {
|
|
23522
|
+
const darkContext = /prefers-color-scheme\s*:\s*dark/i.test(content) || /\.dark\b|\[data-theme=["']?dark/i.test(content) || /background(?:-color)?\s*:\s*#(?:0[0-9a-f]{5}|1[0-9a-f]{5}|000|111)\b/i.test(content);
|
|
23523
|
+
if (!darkContext) return [];
|
|
23524
|
+
const out = [];
|
|
23525
|
+
for (let i = 0; i < lines.length; i++) {
|
|
23526
|
+
const l = lines[i] ?? "";
|
|
23527
|
+
const m = /(?:box|text)-shadow\s*:\s*0\s+0\s+(\d+)px[^;]*?(#[0-9a-f]{3,8})/i.exec(l);
|
|
23528
|
+
if (!m?.[1] || !m[2]) continue;
|
|
23529
|
+
if (parseInt(m[1], 10) < 8) continue;
|
|
23530
|
+
if (hueBucket(m[2]) === null) continue;
|
|
23531
|
+
out.push({ line: i + 1, snippet: l.trim().slice(0, 80) });
|
|
23532
|
+
}
|
|
23533
|
+
return out;
|
|
23534
|
+
}
|
|
23535
|
+
},
|
|
23536
|
+
{
|
|
23537
|
+
id: "slop-t9-uppercase-body",
|
|
23538
|
+
catalogId: "T9",
|
|
23539
|
+
severity: "P3",
|
|
23540
|
+
engines: ["css"],
|
|
23541
|
+
description: "text-transform: uppercase applied to body-length text",
|
|
23542
|
+
message: "All-caps destroys word-shape for sustained reading; reserve it for short labels (T9).",
|
|
23543
|
+
gated: (ctx) => ctx.has("all caps", "all-caps", "uppercase display"),
|
|
23544
|
+
detect: ({ content }) => cssBlocks(content).filter((b) => /\b(p|body|article|\.prose|\.body|\.content|\.copy|blockquote|li)\b/i.test(b.selector)).filter((b) => !/label|button|\bth\b|badge|chip|tag|eyebrow|kicker|caption|nav/i.test(b.selector)).filter((b) => /text-transform\s*:\s*uppercase/i.test(b.body)).map((b) => ({ line: b.line, snippet: b.selector.slice(0, 80) }))
|
|
23545
|
+
},
|
|
23546
|
+
{
|
|
23547
|
+
id: "slop-t10-wide-tracking-body",
|
|
23548
|
+
catalogId: "T10",
|
|
23549
|
+
severity: "P3",
|
|
23550
|
+
engines: ["css"],
|
|
23551
|
+
description: "letter-spacing above 0.05em on body-length text",
|
|
23552
|
+
message: "Wide tracking slows sustained reading; it belongs to display type, not body (T10).",
|
|
23553
|
+
gated: (ctx) => ctx.has("wide tracking", "letterspacing", "letter-spacing"),
|
|
23554
|
+
detect: ({ content }) => cssBlocks(content).filter((b) => /\b(p|body|article|\.prose|\.body|\.content|\.copy|blockquote|li)\b/i.test(b.selector)).filter((b) => !/label|button|\bth\b|badge|chip|tag|eyebrow|kicker|caption|nav|h[1-6]/i.test(b.selector)).filter((b) => {
|
|
23555
|
+
const em = /letter-spacing\s*:\s*(\d*\.?\d+)(em|rem)/i.exec(b.body);
|
|
23556
|
+
if (em?.[1]) return parseFloat(em[1]) > 0.05;
|
|
23557
|
+
const px = /letter-spacing\s*:\s*(\d*\.?\d+)px/i.exec(b.body);
|
|
23558
|
+
return px?.[1] !== void 0 && parseFloat(px[1]) > 0.8;
|
|
23559
|
+
}).map((b) => ({ line: b.line, snippet: b.selector.slice(0, 80) }))
|
|
23560
|
+
},
|
|
23561
|
+
{
|
|
23562
|
+
id: "slop-m1-bounce-easing",
|
|
23563
|
+
catalogId: "M1",
|
|
23564
|
+
severity: "P2",
|
|
23565
|
+
engines: ["css"],
|
|
23566
|
+
description: "Bounce or elastic easing on a UI transition",
|
|
23567
|
+
message: "Overshoot draws attention to the animation instead of the state change (M1).",
|
|
23568
|
+
gated: (ctx) => ctx.has("bounce", "playful motion", "elastic"),
|
|
23569
|
+
detect: ({ lines }) => {
|
|
23570
|
+
const out = [];
|
|
23571
|
+
for (let i = 0; i < lines.length; i++) {
|
|
23572
|
+
const l = lines[i] ?? "";
|
|
23573
|
+
const cb = /cubic-bezier\(\s*[-\d.]+\s*,\s*(-?[\d.]+)\s*,\s*[-\d.]+\s*,\s*(-?[\d.]+)\s*\)/i.exec(l);
|
|
23574
|
+
if (cb?.[1] !== void 0 && cb[2] !== void 0) {
|
|
23575
|
+
const y1 = parseFloat(cb[1]);
|
|
23576
|
+
const y2 = parseFloat(cb[2]);
|
|
23577
|
+
if (y1 < 0 || y1 > 1 || y2 < 0 || y2 > 1) {
|
|
23578
|
+
out.push({ line: i + 1, snippet: l.trim().slice(0, 80) });
|
|
23579
|
+
continue;
|
|
23580
|
+
}
|
|
23581
|
+
}
|
|
23582
|
+
if (/(?:transition|animation)[^;]*\b(?:bounce|elastic|back(?:In|Out|InOut))\b/i.test(l)) {
|
|
23583
|
+
out.push({ line: i + 1, snippet: l.trim().slice(0, 80) });
|
|
23584
|
+
}
|
|
23585
|
+
}
|
|
23586
|
+
return out;
|
|
23587
|
+
}
|
|
23588
|
+
},
|
|
23589
|
+
{
|
|
23590
|
+
id: "slop-m3-img-hover-transform",
|
|
23591
|
+
catalogId: "M3",
|
|
23592
|
+
severity: "P3",
|
|
23593
|
+
engines: ["css"],
|
|
23594
|
+
description: "transform or filter animation on an <img> hover",
|
|
23595
|
+
message: "Hover-scaling an image triggers composite plus decode and often shifts layout (M3).",
|
|
23596
|
+
gated: (ctx) => ctx.has("image hover", "hover zoom", "ken burns"),
|
|
23597
|
+
detect: ({ content }) => cssBlocks(content).filter((b) => /\bimg\b/i.test(b.selector) && /:hover|:focus-within/i.test(b.selector)).filter((b) => /(?:^|[;{\s])(?:transform|filter)\s*:/i.test(b.body)).map((b) => ({ line: b.line, snippet: b.selector.slice(0, 80) }))
|
|
23509
23598
|
}
|
|
23510
23599
|
];
|
|
23511
23600
|
|
|
@@ -24230,8 +24319,11 @@ function decide4(event, state) {
|
|
|
24230
24319
|
if (state.nudges >= MAX_NUDGES) return { state, warn: false };
|
|
24231
24320
|
return { state: { ...state, nudges: state.nudges + 1 }, warn: true };
|
|
24232
24321
|
}
|
|
24322
|
+
function stateChanged(before, after) {
|
|
24323
|
+
return before.consulted !== after.consulted || before.nudges !== after.nudges;
|
|
24324
|
+
}
|
|
24233
24325
|
function nudgeReason2(file) {
|
|
24234
|
-
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.`;
|
|
24326
|
+
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 inventory, if an artifact was provided \u2192 build \u2192 review). Skip only if this is ui-trivial: <=1 file, <=5 lines, no new component, no new state, no new dependency.`;
|
|
24235
24327
|
}
|
|
24236
24328
|
function main37() {
|
|
24237
24329
|
let envelope;
|
|
@@ -24252,7 +24344,7 @@ function main37() {
|
|
|
24252
24344
|
if (!event) return EXIT_ALLOW15;
|
|
24253
24345
|
const before = readState2(root, session);
|
|
24254
24346
|
const { state, warn } = decide4(event, before);
|
|
24255
|
-
if (
|
|
24347
|
+
if (stateChanged(before, state)) {
|
|
24256
24348
|
writeState2(root, session, state);
|
|
24257
24349
|
}
|
|
24258
24350
|
if (!warn) return EXIT_ALLOW15;
|
|
@@ -25619,12 +25711,461 @@ if (_isCliEntry31()) {
|
|
|
25619
25711
|
}
|
|
25620
25712
|
|
|
25621
25713
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
25714
|
+
import * as crypto7 from "node:crypto";
|
|
25715
|
+
import * as fs61 from "node:fs";
|
|
25716
|
+
import * as path62 from "node:path";
|
|
25717
|
+
import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL38 } from "node:url";
|
|
25718
|
+
|
|
25719
|
+
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
25622
25720
|
import * as crypto6 from "node:crypto";
|
|
25623
25721
|
import * as fs60 from "node:fs";
|
|
25624
25722
|
import * as path61 from "node:path";
|
|
25625
25723
|
import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL37 } from "node:url";
|
|
25626
|
-
|
|
25724
|
+
|
|
25725
|
+
// src/scripts/_lib/subagent_response.ts
|
|
25726
|
+
var MAX_SUMMARY_CHARS = 2e3;
|
|
25727
|
+
var MAX_RESPONSE_LINE_CHARS = 240;
|
|
25728
|
+
var MAX_RESPONSE_ENTRIES = 40;
|
|
25729
|
+
var MAX_ARTIFACT_REF_CHARS = 200;
|
|
25730
|
+
var MAX_ENVELOPE_CHARS = 12e3;
|
|
25731
|
+
var CONFIDENCE = /* @__PURE__ */ new Set(["low", "medium", "high"]);
|
|
25732
|
+
function validateResponse(input) {
|
|
25733
|
+
const errors = [];
|
|
25734
|
+
if (input === null || typeof input !== "object") {
|
|
25735
|
+
return { valid: false, errors: ["response is not an object"] };
|
|
25736
|
+
}
|
|
25737
|
+
const r = input;
|
|
25738
|
+
if (typeof r.summary !== "string") errors.push("summary missing or not a string");
|
|
25739
|
+
if (typeof r.handoff !== "string") errors.push("handoff missing or not a string");
|
|
25740
|
+
if (!CONFIDENCE.has(r.confidence)) errors.push(`confidence must be low|medium|high (got ${String(r.confidence)})`);
|
|
25741
|
+
if (!Array.isArray(r.findings)) errors.push("findings missing or not an array");
|
|
25742
|
+
if (!Array.isArray(r.risks)) errors.push("risks missing or not an array");
|
|
25743
|
+
if (Array.isArray(r.findings)) {
|
|
25744
|
+
for (const [i, f] of r.findings.entries()) {
|
|
25745
|
+
if (!f || typeof f.title !== "string") errors.push(`finding[${i}] missing title`);
|
|
25746
|
+
const refs = f?.evidence_refs;
|
|
25747
|
+
if (refs && refs.some((x) => typeof x !== "string" || x.includes("\n"))) {
|
|
25748
|
+
errors.push(`finding[${i}] evidence_refs must be ref tokens, not bodies`);
|
|
25749
|
+
}
|
|
25750
|
+
}
|
|
25751
|
+
}
|
|
25752
|
+
if (r.assumptions !== void 0) {
|
|
25753
|
+
if (!Array.isArray(r.assumptions)) {
|
|
25754
|
+
errors.push("assumptions must be an array of {statement, basis, epistemic_state}");
|
|
25755
|
+
} else {
|
|
25756
|
+
for (const [i, a] of r.assumptions.entries()) {
|
|
25757
|
+
errors.push(...validateAssumption(a, `assumptions[${i}]`));
|
|
25758
|
+
}
|
|
25759
|
+
}
|
|
25760
|
+
}
|
|
25761
|
+
if (typeof r.summary === "string" && r.summary.length > MAX_SUMMARY_CHARS) {
|
|
25762
|
+
errors.push(`summary is ${r.summary.length} chars (max ${MAX_SUMMARY_CHARS}) \u2014 the envelope carries a bounded summary; the full result belongs on disk (artifact_paths)`);
|
|
25763
|
+
}
|
|
25764
|
+
if (typeof r.handoff === "string" && r.handoff.length > MAX_RESPONSE_LINE_CHARS) {
|
|
25765
|
+
errors.push(`handoff is ${r.handoff.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
25766
|
+
}
|
|
25767
|
+
for (const [key, arr] of [
|
|
25768
|
+
["findings", r.findings],
|
|
25769
|
+
["risks", r.risks],
|
|
25770
|
+
["artifact_paths", r.artifact_paths]
|
|
25771
|
+
]) {
|
|
25772
|
+
if (Array.isArray(arr) && arr.length > MAX_RESPONSE_ENTRIES) {
|
|
25773
|
+
errors.push(`${key} carries ${arr.length} entries (max ${MAX_RESPONSE_ENTRIES}) \u2014 an envelope is a handoff, not a transcript`);
|
|
25774
|
+
}
|
|
25775
|
+
}
|
|
25776
|
+
if (Array.isArray(r.risks)) {
|
|
25777
|
+
for (const [i, risk] of r.risks.entries()) {
|
|
25778
|
+
if (typeof risk === "string" && risk.length > MAX_RESPONSE_LINE_CHARS) {
|
|
25779
|
+
errors.push(`risks[${i}] is ${risk.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
25780
|
+
}
|
|
25781
|
+
}
|
|
25782
|
+
}
|
|
25783
|
+
if (Array.isArray(r.findings)) {
|
|
25784
|
+
for (const [i, f] of r.findings.entries()) {
|
|
25785
|
+
if (f && typeof f.title === "string" && f.title.length > MAX_RESPONSE_LINE_CHARS) {
|
|
25786
|
+
errors.push(`finding[${i}] title is ${f.title.length} chars (max ${MAX_RESPONSE_LINE_CHARS})`);
|
|
25787
|
+
}
|
|
25788
|
+
}
|
|
25789
|
+
}
|
|
25790
|
+
if (r.artifact_paths !== void 0) {
|
|
25791
|
+
if (!Array.isArray(r.artifact_paths)) {
|
|
25792
|
+
errors.push("artifact_paths must be an array of path ref tokens");
|
|
25793
|
+
} else {
|
|
25794
|
+
for (const [i, p] of r.artifact_paths.entries()) {
|
|
25795
|
+
if (typeof p !== "string" || p.includes("\n") || p.length > MAX_ARTIFACT_REF_CHARS) {
|
|
25796
|
+
errors.push(`artifact_paths[${i}] must be a single-line path ref \u2264 ${MAX_ARTIFACT_REF_CHARS} chars`);
|
|
25797
|
+
}
|
|
25798
|
+
}
|
|
25799
|
+
}
|
|
25800
|
+
}
|
|
25801
|
+
try {
|
|
25802
|
+
const serialized = JSON.stringify(input);
|
|
25803
|
+
if (serialized.length > MAX_ENVELOPE_CHARS) {
|
|
25804
|
+
errors.push(`envelope serializes to ${serialized.length} chars (max ${MAX_ENVELOPE_CHARS}) \u2014 move content to disk and reference it via artifact_paths`);
|
|
25805
|
+
}
|
|
25806
|
+
} catch {
|
|
25807
|
+
errors.push("envelope is not JSON-serializable");
|
|
25808
|
+
}
|
|
25809
|
+
return { valid: errors.length === 0, errors };
|
|
25810
|
+
}
|
|
25811
|
+
|
|
25812
|
+
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
25627
25813
|
var EXIT_ALLOW18 = 0;
|
|
25814
|
+
function isObject7(v) {
|
|
25815
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
25816
|
+
}
|
|
25817
|
+
var LEDGER_DIR = path61.join("agents", "runtime", "state", "subagent-ledger");
|
|
25818
|
+
var OPEN_SUBDIR = "open";
|
|
25819
|
+
var OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
25820
|
+
function refFor(agentId) {
|
|
25821
|
+
return crypto6.createHash("sha256").update(agentId, "utf8").digest("hex").slice(0, 12);
|
|
25822
|
+
}
|
|
25823
|
+
function unwrapPayload2(envelope) {
|
|
25824
|
+
const inner = envelope["payload"];
|
|
25825
|
+
return isObject7(inner) ? inner : envelope;
|
|
25826
|
+
}
|
|
25827
|
+
function str4(payload, ...keys) {
|
|
25828
|
+
for (const k of keys) {
|
|
25829
|
+
const v = payload[k];
|
|
25830
|
+
if (typeof v === "string" && v) return v;
|
|
25831
|
+
}
|
|
25832
|
+
return null;
|
|
25833
|
+
}
|
|
25834
|
+
function extractParentId(payload, ownId) {
|
|
25835
|
+
const explicit = str4(payload, "parent_agent_id", "parentAgentId");
|
|
25836
|
+
if (explicit) return explicit;
|
|
25837
|
+
const session = payload["session"];
|
|
25838
|
+
if (isObject7(session)) {
|
|
25839
|
+
const sessionAgent = str4(session, "agent_id", "agentId");
|
|
25840
|
+
if (sessionAgent && sessionAgent !== ownId) return sessionAgent;
|
|
25841
|
+
}
|
|
25842
|
+
return null;
|
|
25843
|
+
}
|
|
25844
|
+
function classifyEnvelope(message) {
|
|
25845
|
+
if (message === null || !message.trim()) return { verdict: "absent", error_count: 0 };
|
|
25846
|
+
const candidates = _jsonObjectCandidates(message);
|
|
25847
|
+
if (candidates.length === 0) return { verdict: "absent", error_count: 0 };
|
|
25848
|
+
let best = null;
|
|
25849
|
+
for (const candidate of candidates) {
|
|
25850
|
+
const result = validateResponse(candidate);
|
|
25851
|
+
if (result.valid) return { verdict: "ok", error_count: 0 };
|
|
25852
|
+
if (best === null) best = { verdict: "fail", error_count: result.errors.length };
|
|
25853
|
+
}
|
|
25854
|
+
return best ?? { verdict: "absent", error_count: 0 };
|
|
25855
|
+
}
|
|
25856
|
+
function _jsonObjectCandidates(message) {
|
|
25857
|
+
const texts = [];
|
|
25858
|
+
for (const match of message.matchAll(/^[ \t]*```[ \t]*(?:json)?[ \t]*\r?\n([\s\S]*?)^[ \t]*```/gm)) {
|
|
25859
|
+
if (match[1]) texts.push(match[1]);
|
|
25860
|
+
}
|
|
25861
|
+
let depth = 0;
|
|
25862
|
+
let start = -1;
|
|
25863
|
+
let inString = false;
|
|
25864
|
+
let escaped = false;
|
|
25865
|
+
for (let i = 0; i < message.length; i++) {
|
|
25866
|
+
const ch = message[i];
|
|
25867
|
+
if (inString) {
|
|
25868
|
+
if (escaped) escaped = false;
|
|
25869
|
+
else if (ch === "\\") escaped = true;
|
|
25870
|
+
else if (ch === '"') inString = false;
|
|
25871
|
+
continue;
|
|
25872
|
+
}
|
|
25873
|
+
if (ch === '"') inString = true;
|
|
25874
|
+
else if (ch === "{") {
|
|
25875
|
+
if (depth === 0) start = i;
|
|
25876
|
+
depth++;
|
|
25877
|
+
} else if (ch === "}") {
|
|
25878
|
+
if (depth > 0) {
|
|
25879
|
+
depth--;
|
|
25880
|
+
if (depth === 0 && start !== -1) {
|
|
25881
|
+
texts.push(message.slice(start, i + 1));
|
|
25882
|
+
start = -1;
|
|
25883
|
+
}
|
|
25884
|
+
}
|
|
25885
|
+
}
|
|
25886
|
+
}
|
|
25887
|
+
const out = [];
|
|
25888
|
+
for (const text of texts) {
|
|
25889
|
+
try {
|
|
25890
|
+
const parsed = JSON.parse(text.trim());
|
|
25891
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) out.push(parsed);
|
|
25892
|
+
} catch {
|
|
25893
|
+
}
|
|
25894
|
+
}
|
|
25895
|
+
return out;
|
|
25896
|
+
}
|
|
25897
|
+
function openDir(root) {
|
|
25898
|
+
return path61.join(root, LEDGER_DIR, OPEN_SUBDIR);
|
|
25899
|
+
}
|
|
25900
|
+
function openFile(root, ref) {
|
|
25901
|
+
return path61.join(openDir(root), `${ref}.json`);
|
|
25902
|
+
}
|
|
25903
|
+
var DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
|
|
25904
|
+
function _asOpenRecord(value, expectedRef) {
|
|
25905
|
+
if (!isObject7(value)) return null;
|
|
25906
|
+
const ref = value["ref"];
|
|
25907
|
+
if (typeof ref !== "string" || ref !== expectedRef) return null;
|
|
25908
|
+
if (typeof value["started_at"] !== "string") return null;
|
|
25909
|
+
if (typeof value["depth"] !== "number" || !Number.isFinite(value["depth"])) return null;
|
|
25910
|
+
if (typeof value["depth_basis"] !== "string" || !DEPTH_BASES.has(value["depth_basis"])) return null;
|
|
25911
|
+
const agentType = value["agent_type"];
|
|
25912
|
+
const parentRef = value["parent_ref"];
|
|
25913
|
+
const sessionId2 = value["session_id"];
|
|
25914
|
+
return {
|
|
25915
|
+
ref,
|
|
25916
|
+
agent_type: typeof agentType === "string" ? agentType : null,
|
|
25917
|
+
started_at: value["started_at"],
|
|
25918
|
+
parent_ref: typeof parentRef === "string" ? parentRef : null,
|
|
25919
|
+
depth: value["depth"],
|
|
25920
|
+
depth_basis: value["depth_basis"],
|
|
25921
|
+
session_id: typeof sessionId2 === "string" ? sessionId2 : null
|
|
25922
|
+
};
|
|
25923
|
+
}
|
|
25924
|
+
function readOpenRecords(root) {
|
|
25925
|
+
const out = /* @__PURE__ */ new Map();
|
|
25926
|
+
let names;
|
|
25927
|
+
try {
|
|
25928
|
+
names = fs60.readdirSync(openDir(root));
|
|
25929
|
+
} catch {
|
|
25930
|
+
return out;
|
|
25931
|
+
}
|
|
25932
|
+
for (const name of names) {
|
|
25933
|
+
if (!name.endsWith(".json")) continue;
|
|
25934
|
+
const expectedRef = name.slice(0, -".json".length);
|
|
25935
|
+
try {
|
|
25936
|
+
const raw = fs60.readFileSync(path61.join(openDir(root), name), "utf8");
|
|
25937
|
+
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
25938
|
+
if (rec) out.set(rec.ref, rec);
|
|
25939
|
+
} catch {
|
|
25940
|
+
}
|
|
25941
|
+
}
|
|
25942
|
+
return out;
|
|
25943
|
+
}
|
|
25944
|
+
function resolveDepth(parentRef, open) {
|
|
25945
|
+
if (parentRef === null) return { depth: 1, depth_basis: "assumed-root" };
|
|
25946
|
+
const parent = open.get(parentRef);
|
|
25947
|
+
if (!parent) return { depth: 2, depth_basis: "asserted-parent" };
|
|
25948
|
+
return { depth: parent.depth + 1, depth_basis: "observed" };
|
|
25949
|
+
}
|
|
25950
|
+
function ledgerFileFor(root, ts) {
|
|
25951
|
+
return path61.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
|
|
25952
|
+
}
|
|
25953
|
+
function appendLedgerLine(root, ts, line) {
|
|
25954
|
+
if (is_replay_mode()) return;
|
|
25955
|
+
const file = ledgerFileFor(root, ts);
|
|
25956
|
+
fs60.mkdirSync(path61.dirname(file), { recursive: true });
|
|
25957
|
+
fs60.appendFileSync(file, `${JSON.stringify(line)}
|
|
25958
|
+
`, "utf8");
|
|
25959
|
+
}
|
|
25960
|
+
var WALL_CLOCK_ARMS_MS = [
|
|
25961
|
+
{ label: "5m", ms: 5 * 60 * 1e3 },
|
|
25962
|
+
{ label: "15m", ms: 15 * 60 * 1e3 },
|
|
25963
|
+
{ label: "30m", ms: 30 * 60 * 1e3 },
|
|
25964
|
+
{ label: "2h", ms: 2 * 60 * 60 * 1e3 }
|
|
25965
|
+
];
|
|
25966
|
+
function armsExceeded(elapsedMs) {
|
|
25967
|
+
if (elapsedMs === null || !Number.isFinite(elapsedMs)) return [];
|
|
25968
|
+
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
25969
|
+
}
|
|
25970
|
+
function openRecordStats(root, nowMs = Date.now()) {
|
|
25971
|
+
const ledgerPresent = fs60.existsSync(path61.join(root, LEDGER_DIR));
|
|
25972
|
+
const open = readOpenRecords(root);
|
|
25973
|
+
let maxDepth = 0;
|
|
25974
|
+
let counted = 0;
|
|
25975
|
+
let stale = 0;
|
|
25976
|
+
for (const rec of open.values()) {
|
|
25977
|
+
const started = Date.parse(rec.started_at);
|
|
25978
|
+
const isStale2 = Number.isFinite(started) && nowMs - started >= OPEN_RECORD_TTL_MS;
|
|
25979
|
+
if (isStale2) {
|
|
25980
|
+
stale++;
|
|
25981
|
+
continue;
|
|
25982
|
+
}
|
|
25983
|
+
counted++;
|
|
25984
|
+
if (rec.depth > maxDepth) maxDepth = rec.depth;
|
|
25985
|
+
}
|
|
25986
|
+
return {
|
|
25987
|
+
open_count: counted,
|
|
25988
|
+
max_depth: maxDepth,
|
|
25989
|
+
stale_excluded: stale,
|
|
25990
|
+
ledger_present: ledgerPresent
|
|
25991
|
+
};
|
|
25992
|
+
}
|
|
25993
|
+
function writeOpenRecord(root, rec) {
|
|
25994
|
+
atomic_write_json(openFile(root, rec.ref), rec);
|
|
25995
|
+
}
|
|
25996
|
+
function removeOpenRecord(root, ref) {
|
|
25997
|
+
if (is_replay_mode()) return;
|
|
25998
|
+
try {
|
|
25999
|
+
fs60.unlinkSync(openFile(root, ref));
|
|
26000
|
+
} catch {
|
|
26001
|
+
}
|
|
26002
|
+
}
|
|
26003
|
+
function countOpen(root) {
|
|
26004
|
+
try {
|
|
26005
|
+
return fs60.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
26006
|
+
} catch {
|
|
26007
|
+
return 0;
|
|
26008
|
+
}
|
|
26009
|
+
}
|
|
26010
|
+
function reapStaleOpenRecords(root, nowIso) {
|
|
26011
|
+
const now = Date.parse(nowIso);
|
|
26012
|
+
if (!Number.isFinite(now)) return 0;
|
|
26013
|
+
let reaped = 0;
|
|
26014
|
+
for (const rec of readOpenRecords(root).values()) {
|
|
26015
|
+
const started = Date.parse(rec.started_at);
|
|
26016
|
+
if (!Number.isFinite(started) || now - started < OPEN_RECORD_TTL_MS) continue;
|
|
26017
|
+
removeOpenRecord(root, rec.ref);
|
|
26018
|
+
reaped++;
|
|
26019
|
+
appendLedgerLine(root, nowIso, {
|
|
26020
|
+
event: "subagent_reaped",
|
|
26021
|
+
ts: nowIso,
|
|
26022
|
+
ref: rec.ref,
|
|
26023
|
+
agent_type: rec.agent_type,
|
|
26024
|
+
depth: rec.depth,
|
|
26025
|
+
depth_basis: rec.depth_basis,
|
|
26026
|
+
// R2 round 2, finding 5: the arm list is NOT repeated here. A reap
|
|
26027
|
+
// fires only past OPEN_RECORD_TTL_MS (24 h), which exceeds every
|
|
26028
|
+
// arm (largest: 2 h), so `stop_loss_arms_exceeded` would be a
|
|
26029
|
+
// constant on this line — a field that cannot vary answers no
|
|
26030
|
+
// question. `age_ms` carries strictly more information and is what
|
|
26031
|
+
// a reader should aggregate over.
|
|
26032
|
+
age_ms: now - started,
|
|
26033
|
+
reason: "open record exceeded OPEN_RECORD_TTL_MS without a stop"
|
|
26034
|
+
});
|
|
26035
|
+
}
|
|
26036
|
+
return reaped;
|
|
26037
|
+
}
|
|
26038
|
+
function appendUnidentified(root, event, nowIso, payload) {
|
|
26039
|
+
appendLedgerLine(root, nowIso, {
|
|
26040
|
+
event,
|
|
26041
|
+
ts: nowIso,
|
|
26042
|
+
ref: null,
|
|
26043
|
+
unidentified: true,
|
|
26044
|
+
// The agent TYPE is an id-shaped enum and may still be present; it is
|
|
26045
|
+
// the only thing salvageable from a payload with no id.
|
|
26046
|
+
agent_type: str4(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
26047
|
+
reason: "payload carried no agent id \u2014 nothing to correlate start with stop"
|
|
26048
|
+
});
|
|
26049
|
+
}
|
|
26050
|
+
function handleStart(root, payload, nowIso, sessionId2) {
|
|
26051
|
+
const agentId = str4(payload, "agent_id", "agentId");
|
|
26052
|
+
if (agentId === null) {
|
|
26053
|
+
appendUnidentified(root, "subagent_start", nowIso, payload);
|
|
26054
|
+
return;
|
|
26055
|
+
}
|
|
26056
|
+
const ref = refFor(agentId);
|
|
26057
|
+
const parentId = extractParentId(payload, agentId);
|
|
26058
|
+
const parentRef = parentId ? refFor(parentId) : null;
|
|
26059
|
+
const { depth, depth_basis } = resolveDepth(parentRef, readOpenRecords(root));
|
|
26060
|
+
const rec = {
|
|
26061
|
+
ref,
|
|
26062
|
+
agent_type: str4(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
26063
|
+
started_at: nowIso,
|
|
26064
|
+
parent_ref: parentRef,
|
|
26065
|
+
depth,
|
|
26066
|
+
depth_basis,
|
|
26067
|
+
session_id: sessionId2
|
|
26068
|
+
};
|
|
26069
|
+
writeOpenRecord(root, rec);
|
|
26070
|
+
appendLedgerLine(root, nowIso, {
|
|
26071
|
+
event: "subagent_start",
|
|
26072
|
+
ts: nowIso,
|
|
26073
|
+
ref,
|
|
26074
|
+
agent_type: rec.agent_type,
|
|
26075
|
+
parent_ref: parentRef,
|
|
26076
|
+
depth,
|
|
26077
|
+
depth_basis,
|
|
26078
|
+
concurrent_open: countOpen(root)
|
|
26079
|
+
});
|
|
26080
|
+
}
|
|
26081
|
+
function handleStop(root, payload, nowIso) {
|
|
26082
|
+
const agentId = str4(payload, "agent_id", "agentId");
|
|
26083
|
+
if (agentId === null) {
|
|
26084
|
+
appendUnidentified(root, "subagent_stop", nowIso, payload);
|
|
26085
|
+
return;
|
|
26086
|
+
}
|
|
26087
|
+
const ref = refFor(agentId);
|
|
26088
|
+
const rec = readOpenRecords(root).get(ref) ?? null;
|
|
26089
|
+
let durationMs = null;
|
|
26090
|
+
if (rec) {
|
|
26091
|
+
const started = Date.parse(rec.started_at);
|
|
26092
|
+
if (Number.isFinite(started)) durationMs = Math.max(0, Date.parse(nowIso) - started);
|
|
26093
|
+
}
|
|
26094
|
+
const parse = classifyEnvelope(str4(payload, "last_assistant_message", "lastAssistantMessage"));
|
|
26095
|
+
removeOpenRecord(root, ref);
|
|
26096
|
+
appendLedgerLine(root, nowIso, {
|
|
26097
|
+
event: "subagent_stop",
|
|
26098
|
+
ts: nowIso,
|
|
26099
|
+
ref,
|
|
26100
|
+
agent_type: rec?.agent_type ?? str4(payload, "agent_type", "agentType", "subagent_type", "subagentType"),
|
|
26101
|
+
depth: rec?.depth ?? null,
|
|
26102
|
+
depth_basis: rec?.depth_basis ?? null,
|
|
26103
|
+
// `null` = the matching start was never seen. That is a finding about
|
|
26104
|
+
// the instrument's own coverage and is recorded as such, not as 0.
|
|
26105
|
+
duration_ms: durationMs,
|
|
26106
|
+
// Phase 3 Step 3, shadow: which wall-clock arms this dispatch would
|
|
26107
|
+
// have tripped. Recorded, never acted on.
|
|
26108
|
+
stop_loss_arms_exceeded: armsExceeded(durationMs),
|
|
26109
|
+
start_seen: rec !== null,
|
|
26110
|
+
envelope_parse: parse.verdict,
|
|
26111
|
+
envelope_error_count: parse.error_count,
|
|
26112
|
+
concurrent_open: countOpen(root)
|
|
26113
|
+
});
|
|
26114
|
+
}
|
|
26115
|
+
function processEnvelope2(envelope, consumerRoot) {
|
|
26116
|
+
try {
|
|
26117
|
+
if (!isObject7(envelope)) return EXIT_ALLOW18;
|
|
26118
|
+
const event = envelope["event"];
|
|
26119
|
+
if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW18;
|
|
26120
|
+
const payload = unwrapPayload2(envelope);
|
|
26121
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
26122
|
+
const sessionId2 = str4(payload, "session_id", "sessionId") ?? str4(envelope, "session_id", "sessionId");
|
|
26123
|
+
reapStaleOpenRecords(consumerRoot, nowIso);
|
|
26124
|
+
if (event === "subagent_start") handleStart(consumerRoot, payload, nowIso, sessionId2);
|
|
26125
|
+
else handleStop(consumerRoot, payload, nowIso);
|
|
26126
|
+
} catch {
|
|
26127
|
+
return EXIT_ALLOW18;
|
|
26128
|
+
}
|
|
26129
|
+
return EXIT_ALLOW18;
|
|
26130
|
+
}
|
|
26131
|
+
function resolveConsumerRoot(envelope) {
|
|
26132
|
+
if (isObject7(envelope)) {
|
|
26133
|
+
const pr = str4(envelope, "workspace_root", "project_root");
|
|
26134
|
+
if (pr) return pr;
|
|
26135
|
+
const payload = unwrapPayload2(envelope);
|
|
26136
|
+
const cwd = str4(payload, "cwd");
|
|
26137
|
+
if (cwd) return cwd;
|
|
26138
|
+
}
|
|
26139
|
+
return process.cwd();
|
|
26140
|
+
}
|
|
26141
|
+
function main42() {
|
|
26142
|
+
const raw = readHookStdin();
|
|
26143
|
+
let envelope = {};
|
|
26144
|
+
try {
|
|
26145
|
+
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
26146
|
+
} catch {
|
|
26147
|
+
return EXIT_ALLOW18;
|
|
26148
|
+
}
|
|
26149
|
+
return processEnvelope2(envelope, resolveConsumerRoot(envelope));
|
|
26150
|
+
}
|
|
26151
|
+
function _isCliEntry32() {
|
|
26152
|
+
if (true) {
|
|
26153
|
+
return false;
|
|
26154
|
+
}
|
|
26155
|
+
if (process.argv[1] === void 0) return false;
|
|
26156
|
+
const argvUrl = pathToFileURL37(path61.resolve(process.argv[1])).href;
|
|
26157
|
+
if (import.meta.url === argvUrl) return true;
|
|
26158
|
+
try {
|
|
26159
|
+
return fs60.realpathSync(fileURLToPath43(import.meta.url)) === fs60.realpathSync(path61.resolve(process.argv[1]));
|
|
26160
|
+
} catch {
|
|
26161
|
+
return false;
|
|
26162
|
+
}
|
|
26163
|
+
}
|
|
26164
|
+
if (_isCliEntry32()) process.exit(main42());
|
|
26165
|
+
|
|
26166
|
+
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
26167
|
+
var EXIT_BLOCK4 = 1;
|
|
26168
|
+
var EXIT_ALLOW19 = 0;
|
|
25628
26169
|
var TRANSCRIPT_READ_MAX_BYTES = 8 * 1024 * 1024;
|
|
25629
26170
|
function stripFencedBlocks(text) {
|
|
25630
26171
|
const out = [];
|
|
@@ -25728,7 +26269,7 @@ function detectPromissory(reply) {
|
|
|
25728
26269
|
}
|
|
25729
26270
|
function readCiSettled(workspaceRoot2) {
|
|
25730
26271
|
try {
|
|
25731
|
-
const raw =
|
|
26272
|
+
const raw = fs61.readFileSync(path62.join(workspaceRoot2, STATE_FILE3), "utf-8");
|
|
25732
26273
|
const decoded = JSON.parse(raw);
|
|
25733
26274
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
25734
26275
|
const ci = decoded["ci_last"];
|
|
@@ -25762,7 +26303,7 @@ function detectCompletionClaim(reply, ci) {
|
|
|
25762
26303
|
}
|
|
25763
26304
|
function readLanguagePin(workspaceRoot2) {
|
|
25764
26305
|
try {
|
|
25765
|
-
const raw =
|
|
26306
|
+
const raw = fs61.readFileSync(path62.join(workspaceRoot2, STATE_FILE5), "utf-8");
|
|
25766
26307
|
const decoded = JSON.parse(raw);
|
|
25767
26308
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
25768
26309
|
const lang = decoded["language"];
|
|
@@ -25811,17 +26352,17 @@ function detectUnverifiedEdit(toolCalls) {
|
|
|
25811
26352
|
};
|
|
25812
26353
|
}
|
|
25813
26354
|
function stateDir(workspaceRoot2) {
|
|
25814
|
-
return
|
|
26355
|
+
return path62.join(workspaceRoot2, "agents", "runtime", "state", "turn-end-gate");
|
|
25815
26356
|
}
|
|
25816
26357
|
function sessionStateFile2(workspaceRoot2, sessionKey) {
|
|
25817
|
-
return
|
|
26358
|
+
return path62.join(stateDir(workspaceRoot2), `${sessionKey}.json`);
|
|
25818
26359
|
}
|
|
25819
26360
|
function deriveSessionKey2(sessionId2) {
|
|
25820
|
-
return
|
|
26361
|
+
return crypto7.createHash("sha256").update(sessionId2).digest("hex").slice(0, 32);
|
|
25821
26362
|
}
|
|
25822
26363
|
function alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal) {
|
|
25823
26364
|
try {
|
|
25824
|
-
const raw =
|
|
26365
|
+
const raw = fs61.readFileSync(sessionStateFile2(workspaceRoot2, sessionKey), "utf-8");
|
|
25825
26366
|
const decoded = JSON.parse(raw);
|
|
25826
26367
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
25827
26368
|
return decoded["refused_turn"] === turnOrdinal;
|
|
@@ -25846,10 +26387,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
|
|
|
25846
26387
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
|
|
25847
26388
|
let lines;
|
|
25848
26389
|
try {
|
|
25849
|
-
if (opts.maxBytes !== void 0 &&
|
|
26390
|
+
if (opts.maxBytes !== void 0 && fs61.statSync(transcriptPath).size > opts.maxBytes) {
|
|
25850
26391
|
return empty;
|
|
25851
26392
|
}
|
|
25852
|
-
lines =
|
|
26393
|
+
lines = fs61.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
25853
26394
|
} catch {
|
|
25854
26395
|
return empty;
|
|
25855
26396
|
}
|
|
@@ -25922,33 +26463,41 @@ function _messageText(content) {
|
|
|
25922
26463
|
}
|
|
25923
26464
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
25924
26465
|
}
|
|
25925
|
-
function
|
|
26466
|
+
function str5(v) {
|
|
25926
26467
|
return typeof v === "string" ? v : "";
|
|
25927
26468
|
}
|
|
25928
|
-
function
|
|
26469
|
+
function main43() {
|
|
25929
26470
|
let envelope;
|
|
25930
26471
|
let payload;
|
|
25931
26472
|
try {
|
|
25932
26473
|
[envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
25933
26474
|
} catch {
|
|
25934
|
-
return
|
|
26475
|
+
return EXIT_ALLOW19;
|
|
25935
26476
|
}
|
|
25936
|
-
if (payload["stop_hook_active"] === true) return
|
|
25937
|
-
const workspaceRoot2 =
|
|
25938
|
-
|
|
26477
|
+
if (payload["stop_hook_active"] === true) return EXIT_ALLOW19;
|
|
26478
|
+
const workspaceRoot2 = str5(envelope["workspace_root"]) || process.cwd();
|
|
26479
|
+
let dispatchOpen = false;
|
|
26480
|
+
try {
|
|
26481
|
+
dispatchOpen = openRecordStats(workspaceRoot2).open_count > 0;
|
|
26482
|
+
} catch {
|
|
26483
|
+
}
|
|
26484
|
+
const transcriptPath = str5(
|
|
25939
26485
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
25940
26486
|
);
|
|
25941
26487
|
const { lastAssistant, turnOrdinal, toolCalls } = readTranscriptTail(transcriptPath, {
|
|
25942
26488
|
maxBytes: TRANSCRIPT_READ_MAX_BYTES
|
|
25943
26489
|
});
|
|
25944
|
-
if (!lastAssistant) return
|
|
26490
|
+
if (!lastAssistant) return EXIT_ALLOW19;
|
|
25945
26491
|
const sessionKey = deriveSessionKey2(
|
|
25946
|
-
|
|
26492
|
+
str5(envelope["session_id"]) || "unknown-session"
|
|
25947
26493
|
);
|
|
25948
|
-
if (alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal)) return
|
|
26494
|
+
if (alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal)) return EXIT_ALLOW19;
|
|
25949
26495
|
const findings = [];
|
|
25950
26496
|
for (const f of [
|
|
25951
|
-
|
|
26497
|
+
// A and D are the completion-adjacent pair a pending dispatch excuses
|
|
26498
|
+
// (Phase 3 Step 2, narrowed by R2 round 2 finding 2). B and C are not
|
|
26499
|
+
// excused by anything about a dispatch and run unchanged.
|
|
26500
|
+
dispatchOpen ? null : detectPromissory(lastAssistant),
|
|
25952
26501
|
detectLanguage(lastAssistant, readLanguagePin(workspaceRoot2)),
|
|
25953
26502
|
detectUnverifiedEdit(toolCalls),
|
|
25954
26503
|
// Round 7 § Phase 1 — detector D, in the same unconditional list as the
|
|
@@ -25958,11 +26507,11 @@ function main42() {
|
|
|
25958
26507
|
// gating is where the comment above says gating belongs — inside the
|
|
25959
26508
|
// detector: no CI observed, or a settled read, or no completion claim
|
|
25960
26509
|
// ⇒ no finding.
|
|
25961
|
-
detectCompletionClaim(lastAssistant, readCiSettled(workspaceRoot2))
|
|
26510
|
+
dispatchOpen ? null : detectCompletionClaim(lastAssistant, readCiSettled(workspaceRoot2))
|
|
25962
26511
|
]) {
|
|
25963
26512
|
if (f) findings.push(f);
|
|
25964
26513
|
}
|
|
25965
|
-
if (findings.length === 0) return
|
|
26514
|
+
if (findings.length === 0) return EXIT_ALLOW19;
|
|
25966
26515
|
markRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal, findings[0].detector);
|
|
25967
26516
|
const lines = findings.map(
|
|
25968
26517
|
(f) => ` \xB7 ${f.detector}: ${f.reason}
|
|
@@ -25977,36 +26526,36 @@ ${lines.join("\n")}
|
|
|
25977
26526
|
);
|
|
25978
26527
|
return EXIT_BLOCK4;
|
|
25979
26528
|
}
|
|
25980
|
-
function
|
|
26529
|
+
function _isCliEntry33() {
|
|
25981
26530
|
if (true) {
|
|
25982
26531
|
return false;
|
|
25983
26532
|
}
|
|
25984
26533
|
if (process.argv[1] === void 0) {
|
|
25985
26534
|
return false;
|
|
25986
26535
|
}
|
|
25987
|
-
const argvUrl =
|
|
26536
|
+
const argvUrl = pathToFileURL38(path62.resolve(process.argv[1])).href;
|
|
25988
26537
|
if (import.meta.url === argvUrl) {
|
|
25989
26538
|
return true;
|
|
25990
26539
|
}
|
|
25991
26540
|
try {
|
|
25992
|
-
const here =
|
|
25993
|
-
const argv =
|
|
26541
|
+
const here = fs61.realpathSync(fileURLToPath44(import.meta.url));
|
|
26542
|
+
const argv = fs61.realpathSync(path62.resolve(process.argv[1]));
|
|
25994
26543
|
return here === argv;
|
|
25995
26544
|
} catch {
|
|
25996
26545
|
return false;
|
|
25997
26546
|
}
|
|
25998
26547
|
}
|
|
25999
|
-
if (
|
|
26000
|
-
process.exit(
|
|
26548
|
+
if (_isCliEntry33()) {
|
|
26549
|
+
process.exit(main43());
|
|
26001
26550
|
}
|
|
26002
26551
|
|
|
26003
26552
|
// src/scripts/hooks/edit_shape_hook.ts
|
|
26004
26553
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
26005
|
-
import * as
|
|
26006
|
-
import * as
|
|
26007
|
-
import * as
|
|
26008
|
-
import { fileURLToPath as
|
|
26009
|
-
var
|
|
26554
|
+
import * as crypto8 from "node:crypto";
|
|
26555
|
+
import * as fs62 from "node:fs";
|
|
26556
|
+
import * as path63 from "node:path";
|
|
26557
|
+
import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL39 } from "node:url";
|
|
26558
|
+
var EXIT_ALLOW20 = 0;
|
|
26010
26559
|
var EXIT_WARN11 = 2;
|
|
26011
26560
|
var MIN_FILE_LINES = 50;
|
|
26012
26561
|
var MAX_DIFF_RATIO = 0.2;
|
|
@@ -26022,10 +26571,10 @@ var EXEMPT_PATH_PATTERNS = [
|
|
|
26022
26571
|
/(^|\/)agents\/runtime\//i
|
|
26023
26572
|
// agents/runtime/**
|
|
26024
26573
|
];
|
|
26025
|
-
function
|
|
26574
|
+
function isObject8(v) {
|
|
26026
26575
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
26027
26576
|
}
|
|
26028
|
-
function
|
|
26577
|
+
function str6(v) {
|
|
26029
26578
|
return typeof v === "string" ? v : "";
|
|
26030
26579
|
}
|
|
26031
26580
|
function isExemptPath(filePath) {
|
|
@@ -26058,7 +26607,7 @@ function effectiveDiffLines(cwd, relPath) {
|
|
|
26058
26607
|
}
|
|
26059
26608
|
function fileLineCount(absPath) {
|
|
26060
26609
|
try {
|
|
26061
|
-
const text =
|
|
26610
|
+
const text = fs62.readFileSync(absPath, "utf8");
|
|
26062
26611
|
if (text.length === 0) return 0;
|
|
26063
26612
|
return text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
|
|
26064
26613
|
} catch {
|
|
@@ -26070,16 +26619,16 @@ function buildAdvisoryLine2(fileLines, diffLines) {
|
|
|
26070
26619
|
return `this Write replaced ${fileLines} lines for an effective diff of ~${pct}% (${diffLines} changed lines) \u2014 a targeted Edit pays for the diff, not the file.`;
|
|
26071
26620
|
}
|
|
26072
26621
|
function deriveSessionKey3(envelope, payload) {
|
|
26073
|
-
const raw =
|
|
26622
|
+
const raw = str6(envelope["session_id"]) || str6(payload["session_id"] ?? payload["sessionId"]);
|
|
26074
26623
|
const material = raw || "unknown-session";
|
|
26075
|
-
return
|
|
26624
|
+
return crypto8.createHash("sha256").update(material).digest("hex");
|
|
26076
26625
|
}
|
|
26077
26626
|
function sessionStateFile3(workspaceRoot2, sessionKey) {
|
|
26078
|
-
return
|
|
26627
|
+
return path63.join(workspaceRoot2, "agents", "runtime", "state", "edit-shape", `${sessionKey}.json`);
|
|
26079
26628
|
}
|
|
26080
26629
|
function hasFiredThisSession2(workspaceRoot2, sessionKey) {
|
|
26081
26630
|
try {
|
|
26082
|
-
return
|
|
26631
|
+
return fs62.existsSync(sessionStateFile3(workspaceRoot2, sessionKey));
|
|
26083
26632
|
} catch {
|
|
26084
26633
|
return false;
|
|
26085
26634
|
}
|
|
@@ -26093,33 +26642,33 @@ function markFiredThisSession2(workspaceRoot2, sessionKey) {
|
|
|
26093
26642
|
}
|
|
26094
26643
|
}
|
|
26095
26644
|
function extractToolName2(payload) {
|
|
26096
|
-
return
|
|
26645
|
+
return str6(payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]);
|
|
26097
26646
|
}
|
|
26098
26647
|
function extractFilePath(payload) {
|
|
26099
26648
|
const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
|
|
26100
|
-
if (!
|
|
26101
|
-
return
|
|
26649
|
+
if (!isObject8(ti)) return "";
|
|
26650
|
+
return str6(ti["file_path"] ?? ti["path"] ?? ti["filePath"]);
|
|
26102
26651
|
}
|
|
26103
|
-
function
|
|
26652
|
+
function main44() {
|
|
26104
26653
|
try {
|
|
26105
26654
|
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
26106
|
-
const event =
|
|
26107
|
-
if (event !== "" && event !== "post_tool_use") return
|
|
26655
|
+
const event = str6(envelope["event"]);
|
|
26656
|
+
if (event !== "" && event !== "post_tool_use") return EXIT_ALLOW20;
|
|
26108
26657
|
const toolName = extractToolName2(payload);
|
|
26109
|
-
if (toolName !== "Write") return
|
|
26658
|
+
if (toolName !== "Write") return EXIT_ALLOW20;
|
|
26110
26659
|
const filePath = extractFilePath(payload);
|
|
26111
|
-
if (!filePath) return
|
|
26112
|
-
const workspaceRoot2 =
|
|
26113
|
-
const absPath =
|
|
26114
|
-
const relPath =
|
|
26115
|
-
if (isExemptPath(relPath) || isExemptPath(absPath)) return
|
|
26660
|
+
if (!filePath) return EXIT_ALLOW20;
|
|
26661
|
+
const workspaceRoot2 = str6(envelope["workspace_root"]).trim() || process.cwd();
|
|
26662
|
+
const absPath = path63.isAbsolute(filePath) ? filePath : path63.resolve(workspaceRoot2, filePath);
|
|
26663
|
+
const relPath = path63.relative(workspaceRoot2, absPath);
|
|
26664
|
+
if (isExemptPath(relPath) || isExemptPath(absPath)) return EXIT_ALLOW20;
|
|
26116
26665
|
const fileLines = fileLineCount(absPath);
|
|
26117
|
-
if (fileLines < MIN_FILE_LINES) return
|
|
26666
|
+
if (fileLines < MIN_FILE_LINES) return EXIT_ALLOW20;
|
|
26118
26667
|
const diffLines = effectiveDiffLines(workspaceRoot2, relPath.startsWith("..") ? absPath : relPath);
|
|
26119
|
-
if (diffLines === 0) return
|
|
26120
|
-
if (diffLines / fileLines > MAX_DIFF_RATIO) return
|
|
26668
|
+
if (diffLines === 0) return EXIT_ALLOW20;
|
|
26669
|
+
if (diffLines / fileLines > MAX_DIFF_RATIO) return EXIT_ALLOW20;
|
|
26121
26670
|
const sessionKey = deriveSessionKey3(envelope, payload);
|
|
26122
|
-
if (hasFiredThisSession2(workspaceRoot2, sessionKey)) return
|
|
26671
|
+
if (hasFiredThisSession2(workspaceRoot2, sessionKey)) return EXIT_ALLOW20;
|
|
26123
26672
|
markFiredThisSession2(workspaceRoot2, sessionKey);
|
|
26124
26673
|
process.stdout.write(
|
|
26125
26674
|
`${JSON.stringify({
|
|
@@ -26131,38 +26680,38 @@ function main43() {
|
|
|
26131
26680
|
);
|
|
26132
26681
|
return EXIT_WARN11;
|
|
26133
26682
|
} catch {
|
|
26134
|
-
return
|
|
26683
|
+
return EXIT_ALLOW20;
|
|
26135
26684
|
}
|
|
26136
26685
|
}
|
|
26137
|
-
function
|
|
26686
|
+
function _isCliEntry34() {
|
|
26138
26687
|
if (true) {
|
|
26139
26688
|
return false;
|
|
26140
26689
|
}
|
|
26141
26690
|
if (process.argv[1] === void 0) {
|
|
26142
26691
|
return false;
|
|
26143
26692
|
}
|
|
26144
|
-
const argvUrl =
|
|
26693
|
+
const argvUrl = pathToFileURL39(path63.resolve(process.argv[1])).href;
|
|
26145
26694
|
if (import.meta.url === argvUrl) {
|
|
26146
26695
|
return true;
|
|
26147
26696
|
}
|
|
26148
26697
|
try {
|
|
26149
|
-
const here =
|
|
26150
|
-
const argv =
|
|
26698
|
+
const here = fs62.realpathSync(fileURLToPath45(import.meta.url));
|
|
26699
|
+
const argv = fs62.realpathSync(path63.resolve(process.argv[1]));
|
|
26151
26700
|
return here === argv;
|
|
26152
26701
|
} catch {
|
|
26153
26702
|
return false;
|
|
26154
26703
|
}
|
|
26155
26704
|
}
|
|
26156
|
-
if (
|
|
26157
|
-
process.exit(
|
|
26705
|
+
if (_isCliEntry34()) {
|
|
26706
|
+
process.exit(main44());
|
|
26158
26707
|
}
|
|
26159
26708
|
|
|
26160
26709
|
// src/scripts/hooks/reread_guard_hook.ts
|
|
26161
|
-
import * as
|
|
26162
|
-
import * as
|
|
26163
|
-
import * as
|
|
26164
|
-
import { fileURLToPath as
|
|
26165
|
-
var
|
|
26710
|
+
import * as crypto9 from "node:crypto";
|
|
26711
|
+
import * as fs63 from "node:fs";
|
|
26712
|
+
import * as path64 from "node:path";
|
|
26713
|
+
import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL40 } from "node:url";
|
|
26714
|
+
var EXIT_ALLOW21 = 0;
|
|
26166
26715
|
var EXIT_WARN12 = 2;
|
|
26167
26716
|
var EXEMPT_PATH_PATTERNS2 = [
|
|
26168
26717
|
/(^|\/)dist\//i,
|
|
@@ -26178,10 +26727,10 @@ var EXEMPT_PATH_PATTERNS2 = [
|
|
|
26178
26727
|
];
|
|
26179
26728
|
var READ_TOOLS = /* @__PURE__ */ new Set(["Read"]);
|
|
26180
26729
|
var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Edit", "Write"]);
|
|
26181
|
-
function
|
|
26730
|
+
function isObject9(v) {
|
|
26182
26731
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
26183
26732
|
}
|
|
26184
|
-
function
|
|
26733
|
+
function str7(v) {
|
|
26185
26734
|
return typeof v === "string" ? v : "";
|
|
26186
26735
|
}
|
|
26187
26736
|
function isExemptPath2(filePath) {
|
|
@@ -26192,21 +26741,21 @@ function emptyLedger() {
|
|
|
26192
26741
|
return { reads: {}, writes: {}, fired: {} };
|
|
26193
26742
|
}
|
|
26194
26743
|
function deriveSessionKey4(envelope, payload) {
|
|
26195
|
-
const raw =
|
|
26744
|
+
const raw = str7(envelope["session_id"]) || str7(payload["session_id"] ?? payload["sessionId"]);
|
|
26196
26745
|
const material = raw || "unknown-session";
|
|
26197
|
-
return
|
|
26746
|
+
return crypto9.createHash("sha256").update(material).digest("hex");
|
|
26198
26747
|
}
|
|
26199
26748
|
function ledgerFile(workspaceRoot2, sessionKey) {
|
|
26200
|
-
return
|
|
26749
|
+
return path64.join(workspaceRoot2, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
|
|
26201
26750
|
}
|
|
26202
26751
|
function readLedger(workspaceRoot2, sessionKey) {
|
|
26203
26752
|
try {
|
|
26204
|
-
const parsed = JSON.parse(
|
|
26205
|
-
if (!
|
|
26753
|
+
const parsed = JSON.parse(fs63.readFileSync(ledgerFile(workspaceRoot2, sessionKey), "utf8"));
|
|
26754
|
+
if (!isObject9(parsed)) return emptyLedger();
|
|
26206
26755
|
return {
|
|
26207
|
-
reads:
|
|
26208
|
-
writes:
|
|
26209
|
-
fired:
|
|
26756
|
+
reads: isObject9(parsed["reads"]) ? parsed["reads"] : {},
|
|
26757
|
+
writes: isObject9(parsed["writes"]) ? parsed["writes"] : {},
|
|
26758
|
+
fired: isObject9(parsed["fired"]) ? parsed["fired"] : {}
|
|
26210
26759
|
};
|
|
26211
26760
|
} catch {
|
|
26212
26761
|
return emptyLedger();
|
|
@@ -26219,14 +26768,14 @@ function writeLedger(workspaceRoot2, sessionKey, ledger) {
|
|
|
26219
26768
|
}
|
|
26220
26769
|
}
|
|
26221
26770
|
function extractToolName3(payload) {
|
|
26222
|
-
return
|
|
26771
|
+
return str7(payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]);
|
|
26223
26772
|
}
|
|
26224
26773
|
function extractToolInput2(payload) {
|
|
26225
26774
|
const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
|
|
26226
|
-
return
|
|
26775
|
+
return isObject9(ti) ? ti : {};
|
|
26227
26776
|
}
|
|
26228
26777
|
function extractFilePath2(toolInput) {
|
|
26229
|
-
return
|
|
26778
|
+
return str7(toolInput["file_path"] ?? toolInput["path"] ?? toolInput["filePath"]);
|
|
26230
26779
|
}
|
|
26231
26780
|
function isRangedRead(toolInput) {
|
|
26232
26781
|
for (const key of ["offset", "limit", "start_line", "end_line", "startLine", "endLine"]) {
|
|
@@ -26242,41 +26791,41 @@ function buildDuplicateReadLine(relPath, earlierTs) {
|
|
|
26242
26791
|
function buildPostEditReadLine(relPath) {
|
|
26243
26792
|
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.`;
|
|
26244
26793
|
}
|
|
26245
|
-
function
|
|
26794
|
+
function main45() {
|
|
26246
26795
|
try {
|
|
26247
26796
|
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
26248
|
-
const event =
|
|
26249
|
-
if (event !== "" && event !== "pre_tool_use") return
|
|
26797
|
+
const event = str7(envelope["event"]);
|
|
26798
|
+
if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW21;
|
|
26250
26799
|
const toolName = extractToolName3(payload);
|
|
26251
26800
|
const isRead = READ_TOOLS.has(toolName);
|
|
26252
26801
|
const isWrite = WRITE_TOOLS2.has(toolName);
|
|
26253
|
-
if (!isRead && !isWrite) return
|
|
26802
|
+
if (!isRead && !isWrite) return EXIT_ALLOW21;
|
|
26254
26803
|
const toolInput = extractToolInput2(payload);
|
|
26255
26804
|
const filePath = extractFilePath2(toolInput);
|
|
26256
|
-
if (!filePath) return
|
|
26257
|
-
const workspaceRoot2 =
|
|
26258
|
-
const absPath =
|
|
26259
|
-
const relPath =
|
|
26260
|
-
if (isExemptPath2(relPath) || isExemptPath2(absPath)) return
|
|
26805
|
+
if (!filePath) return EXIT_ALLOW21;
|
|
26806
|
+
const workspaceRoot2 = str7(envelope["workspace_root"]).trim() || process.cwd();
|
|
26807
|
+
const absPath = path64.isAbsolute(filePath) ? filePath : path64.resolve(workspaceRoot2, filePath);
|
|
26808
|
+
const relPath = path64.relative(workspaceRoot2, absPath);
|
|
26809
|
+
if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW21;
|
|
26261
26810
|
const sessionKey = deriveSessionKey4(envelope, payload);
|
|
26262
26811
|
const ledger = readLedger(workspaceRoot2, sessionKey);
|
|
26263
26812
|
const key = relPath.startsWith("..") ? absPath : relPath;
|
|
26264
26813
|
if (isWrite) {
|
|
26265
26814
|
ledger.writes[key] = Date.now();
|
|
26266
26815
|
writeLedger(workspaceRoot2, sessionKey, ledger);
|
|
26267
|
-
return
|
|
26816
|
+
return EXIT_ALLOW21;
|
|
26268
26817
|
}
|
|
26269
26818
|
if (isRangedRead(toolInput)) {
|
|
26270
|
-
return
|
|
26819
|
+
return EXIT_ALLOW21;
|
|
26271
26820
|
}
|
|
26272
26821
|
let mtime;
|
|
26273
26822
|
let size;
|
|
26274
26823
|
try {
|
|
26275
|
-
const st =
|
|
26824
|
+
const st = fs63.statSync(absPath);
|
|
26276
26825
|
mtime = st.mtimeMs;
|
|
26277
26826
|
size = st.size;
|
|
26278
26827
|
} catch {
|
|
26279
|
-
return
|
|
26828
|
+
return EXIT_ALLOW21;
|
|
26280
26829
|
}
|
|
26281
26830
|
const prior = ledger.reads[key];
|
|
26282
26831
|
const ownWrite = ledger.writes[key];
|
|
@@ -26291,7 +26840,7 @@ function main44() {
|
|
|
26291
26840
|
if (ownWrite !== void 0) delete ledger.writes[key];
|
|
26292
26841
|
if (advisory !== null) ledger.fired[key] = true;
|
|
26293
26842
|
writeLedger(workspaceRoot2, sessionKey, ledger);
|
|
26294
|
-
if (advisory === null) return
|
|
26843
|
+
if (advisory === null) return EXIT_ALLOW21;
|
|
26295
26844
|
process.stdout.write(
|
|
26296
26845
|
`${JSON.stringify({
|
|
26297
26846
|
decision: "warn",
|
|
@@ -26302,37 +26851,37 @@ function main44() {
|
|
|
26302
26851
|
);
|
|
26303
26852
|
return EXIT_WARN12;
|
|
26304
26853
|
} catch {
|
|
26305
|
-
return
|
|
26854
|
+
return EXIT_ALLOW21;
|
|
26306
26855
|
}
|
|
26307
26856
|
}
|
|
26308
|
-
function
|
|
26857
|
+
function _isCliEntry35() {
|
|
26309
26858
|
if (true) {
|
|
26310
26859
|
return false;
|
|
26311
26860
|
}
|
|
26312
26861
|
if (process.argv[1] === void 0) {
|
|
26313
26862
|
return false;
|
|
26314
26863
|
}
|
|
26315
|
-
const argvUrl =
|
|
26864
|
+
const argvUrl = pathToFileURL40(path64.resolve(process.argv[1])).href;
|
|
26316
26865
|
if (import.meta.url === argvUrl) {
|
|
26317
26866
|
return true;
|
|
26318
26867
|
}
|
|
26319
26868
|
try {
|
|
26320
|
-
const here =
|
|
26321
|
-
const argv =
|
|
26869
|
+
const here = fs63.realpathSync(fileURLToPath46(import.meta.url));
|
|
26870
|
+
const argv = fs63.realpathSync(path64.resolve(process.argv[1]));
|
|
26322
26871
|
return here === argv;
|
|
26323
26872
|
} catch {
|
|
26324
26873
|
return false;
|
|
26325
26874
|
}
|
|
26326
26875
|
}
|
|
26327
|
-
if (
|
|
26328
|
-
process.exit(
|
|
26876
|
+
if (_isCliEntry35()) {
|
|
26877
|
+
process.exit(main45());
|
|
26329
26878
|
}
|
|
26330
26879
|
|
|
26331
26880
|
// src/scripts/hooks/session_eol_hook.ts
|
|
26332
|
-
import * as
|
|
26333
|
-
import * as
|
|
26881
|
+
import * as fs65 from "node:fs";
|
|
26882
|
+
import * as path67 from "node:path";
|
|
26334
26883
|
import process11 from "node:process";
|
|
26335
|
-
import { fileURLToPath as
|
|
26884
|
+
import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL41 } from "node:url";
|
|
26336
26885
|
|
|
26337
26886
|
// src/config/recycle-threshold-budget.json
|
|
26338
26887
|
var recycle_threshold_budget_default = {
|
|
@@ -26349,14 +26898,14 @@ var recycle_threshold_budget_default = {
|
|
|
26349
26898
|
};
|
|
26350
26899
|
|
|
26351
26900
|
// src/scripts/_lib/session_eol.ts
|
|
26352
|
-
import * as
|
|
26353
|
-
import * as
|
|
26354
|
-
import * as
|
|
26901
|
+
import * as crypto10 from "node:crypto";
|
|
26902
|
+
import * as fs64 from "node:fs";
|
|
26903
|
+
import * as path66 from "node:path";
|
|
26355
26904
|
|
|
26356
26905
|
// src/scripts/_lib/cc_transcript.ts
|
|
26357
|
-
import * as
|
|
26906
|
+
import * as path65 from "node:path";
|
|
26358
26907
|
import { homedir as homedir6 } from "node:os";
|
|
26359
|
-
var DEFAULT_PROJECTS_ROOT =
|
|
26908
|
+
var DEFAULT_PROJECTS_ROOT = path65.join(homedir6(), ".claude", "projects");
|
|
26360
26909
|
function billableInputTokens(u) {
|
|
26361
26910
|
return u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens;
|
|
26362
26911
|
}
|
|
@@ -26465,17 +27014,17 @@ function scanEolSlice(text, prior) {
|
|
|
26465
27014
|
return next;
|
|
26466
27015
|
}
|
|
26467
27016
|
function eolStateDir(workspaceRoot2) {
|
|
26468
|
-
return
|
|
27017
|
+
return path66.join(workspaceRoot2, "agents", "runtime", "state", "session-eol");
|
|
26469
27018
|
}
|
|
26470
27019
|
function eolStateFile(workspaceRoot2, sessionKey) {
|
|
26471
|
-
return
|
|
27020
|
+
return path66.join(eolStateDir(workspaceRoot2), `${sessionKey}.json`);
|
|
26472
27021
|
}
|
|
26473
27022
|
function eolSessionKey(raw) {
|
|
26474
|
-
return
|
|
27023
|
+
return crypto10.createHash("sha256").update(raw || "unknown-session").digest("hex");
|
|
26475
27024
|
}
|
|
26476
27025
|
function readNewCompleteLines(filePath, fromByte) {
|
|
26477
27026
|
try {
|
|
26478
|
-
const { size } =
|
|
27027
|
+
const { size } = fs64.statSync(filePath);
|
|
26479
27028
|
if (size < fromByte) {
|
|
26480
27029
|
return { text: "", nextOffset: 0, truncated: true };
|
|
26481
27030
|
}
|
|
@@ -26484,11 +27033,11 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
26484
27033
|
}
|
|
26485
27034
|
const length = size - fromByte;
|
|
26486
27035
|
const buffer = Buffer.alloc(length);
|
|
26487
|
-
const fd =
|
|
27036
|
+
const fd = fs64.openSync(filePath, "r");
|
|
26488
27037
|
try {
|
|
26489
|
-
|
|
27038
|
+
fs64.readSync(fd, buffer, 0, length, fromByte);
|
|
26490
27039
|
} finally {
|
|
26491
|
-
|
|
27040
|
+
fs64.closeSync(fd);
|
|
26492
27041
|
}
|
|
26493
27042
|
const lastNewline = buffer.lastIndexOf(10);
|
|
26494
27043
|
if (lastNewline === -1) {
|
|
@@ -26507,19 +27056,19 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
26507
27056
|
// src/scripts/hooks/session_eol_hook.ts
|
|
26508
27057
|
var EXIT_WARN13 = 2;
|
|
26509
27058
|
var THRESHOLD_OVERRIDE_ENV = "AGENT_RECYCLE_THRESHOLD_TOKENS";
|
|
26510
|
-
var CONTEXT_FILL_REL =
|
|
26511
|
-
function
|
|
27059
|
+
var CONTEXT_FILL_REL = path67.join("agents", "runtime", "state", "context-fill.json");
|
|
27060
|
+
function str8(value) {
|
|
26512
27061
|
return typeof value === "string" ? value : "";
|
|
26513
27062
|
}
|
|
26514
27063
|
var stateFile3 = eolStateFile;
|
|
26515
27064
|
function deriveSessionKey5(envelope, payload) {
|
|
26516
27065
|
return eolSessionKey(
|
|
26517
|
-
|
|
27066
|
+
str8(envelope["session_id"]) || str8(payload["transcript_path"] ?? payload["transcriptPath"])
|
|
26518
27067
|
);
|
|
26519
27068
|
}
|
|
26520
27069
|
function readState3(file) {
|
|
26521
27070
|
try {
|
|
26522
|
-
const parsed = JSON.parse(
|
|
27071
|
+
const parsed = JSON.parse(fs65.readFileSync(file, "utf-8"));
|
|
26523
27072
|
if (parsed && typeof parsed === "object" && parsed.schema_version === 1 && parsed.counters && typeof parsed.counters.scanned_bytes === "number") {
|
|
26524
27073
|
return {
|
|
26525
27074
|
schema_version: 1,
|
|
@@ -26540,10 +27089,10 @@ function readState3(file) {
|
|
|
26540
27089
|
};
|
|
26541
27090
|
}
|
|
26542
27091
|
function envelopeExists(workspaceRoot2, since = null) {
|
|
26543
|
-
const target =
|
|
27092
|
+
const target = path67.join(workspaceRoot2, RECYCLE_ENVELOPE_REL);
|
|
26544
27093
|
let raw;
|
|
26545
27094
|
try {
|
|
26546
|
-
raw =
|
|
27095
|
+
raw = fs65.readFileSync(target, "utf-8");
|
|
26547
27096
|
} catch (exc) {
|
|
26548
27097
|
return exc?.code !== "ENOENT";
|
|
26549
27098
|
}
|
|
@@ -26557,7 +27106,7 @@ function envelopeExists(workspaceRoot2, since = null) {
|
|
|
26557
27106
|
}
|
|
26558
27107
|
}
|
|
26559
27108
|
function buildMissingEnvelopeLine(workspaceRoot2) {
|
|
26560
|
-
return `recycle advised earlier, but no envelope exists at ${
|
|
27109
|
+
return `recycle advised earlier, but no envelope exists at ${path67.join(workspaceRoot2, RECYCLE_ENVELOPE_REL)} \u2014 /clear now starts the successor from nothing. Re-run \`agent-config session:recycle\` and check that it prints the absolute path it wrote before clearing.`;
|
|
26561
27110
|
}
|
|
26562
27111
|
function readThresholdTokens() {
|
|
26563
27112
|
const override = process11.env[THRESHOLD_OVERRIDE_ENV];
|
|
@@ -26573,7 +27122,7 @@ function buildAdvisoryLine3(tokens, threshold) {
|
|
|
26573
27122
|
}
|
|
26574
27123
|
function writeContextFill(workspaceRoot2, tokens, threshold, ts) {
|
|
26575
27124
|
try {
|
|
26576
|
-
atomic_write_json(
|
|
27125
|
+
atomic_write_json(path67.join(workspaceRoot2, CONTEXT_FILL_REL), {
|
|
26577
27126
|
schema_version: 1,
|
|
26578
27127
|
final_context_tokens: tokens,
|
|
26579
27128
|
recycle_threshold_tokens: threshold,
|
|
@@ -26583,7 +27132,7 @@ function writeContextFill(workspaceRoot2, tokens, threshold, ts) {
|
|
|
26583
27132
|
} catch {
|
|
26584
27133
|
}
|
|
26585
27134
|
}
|
|
26586
|
-
function
|
|
27135
|
+
function main46() {
|
|
26587
27136
|
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
26588
27137
|
const event = String(envelope["event"] ?? "");
|
|
26589
27138
|
if (event !== "" && event !== "stop") {
|
|
@@ -26593,7 +27142,7 @@ function main45() {
|
|
|
26593
27142
|
return 0;
|
|
26594
27143
|
}
|
|
26595
27144
|
const workspaceRoot2 = String(envelope["workspace_root"] ?? "").trim() || process11.cwd();
|
|
26596
|
-
const transcriptPath =
|
|
27145
|
+
const transcriptPath = str8(
|
|
26597
27146
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
26598
27147
|
).trim();
|
|
26599
27148
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath)) {
|
|
@@ -26655,29 +27204,119 @@ function main45() {
|
|
|
26655
27204
|
}
|
|
26656
27205
|
return 0;
|
|
26657
27206
|
}
|
|
26658
|
-
function
|
|
27207
|
+
function _isCliEntry36() {
|
|
26659
27208
|
if (true) {
|
|
26660
27209
|
return false;
|
|
26661
27210
|
}
|
|
26662
27211
|
if (process11.argv[1] === void 0) {
|
|
26663
27212
|
return false;
|
|
26664
27213
|
}
|
|
26665
|
-
const argvUrl =
|
|
27214
|
+
const argvUrl = pathToFileURL41(path67.resolve(process11.argv[1])).href;
|
|
26666
27215
|
if (import.meta.url === argvUrl) {
|
|
26667
27216
|
return true;
|
|
26668
27217
|
}
|
|
26669
27218
|
try {
|
|
26670
|
-
const here =
|
|
26671
|
-
const argv =
|
|
27219
|
+
const here = fs65.realpathSync(fileURLToPath47(import.meta.url));
|
|
27220
|
+
const argv = fs65.realpathSync(path67.resolve(process11.argv[1]));
|
|
26672
27221
|
return here === argv;
|
|
26673
27222
|
} catch {
|
|
26674
27223
|
return false;
|
|
26675
27224
|
}
|
|
26676
27225
|
}
|
|
26677
|
-
if (
|
|
26678
|
-
process11.exit(
|
|
27226
|
+
if (_isCliEntry36()) {
|
|
27227
|
+
process11.exit(main46());
|
|
26679
27228
|
}
|
|
26680
27229
|
|
|
27230
|
+
// src/scripts/hooks/spawn_guard_shadow_hook.ts
|
|
27231
|
+
import * as fs66 from "node:fs";
|
|
27232
|
+
import * as path68 from "node:path";
|
|
27233
|
+
import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL42 } from "node:url";
|
|
27234
|
+
var EXIT_ALLOW22 = 0;
|
|
27235
|
+
function isObject10(v) {
|
|
27236
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
27237
|
+
}
|
|
27238
|
+
var DISPATCH_TOOL_NAMES2 = /* @__PURE__ */ new Set(["Agent", "Task"]);
|
|
27239
|
+
var CANDIDATES = [
|
|
27240
|
+
{ label: "n2m4", max_depth: 2, max_concurrent: 4 },
|
|
27241
|
+
{ label: "n3m6", max_depth: 3, max_concurrent: 6 },
|
|
27242
|
+
{ label: "n4m8", max_depth: 4, max_concurrent: 8 }
|
|
27243
|
+
];
|
|
27244
|
+
function evaluateCandidates(depthEstimate, concurrentOpen) {
|
|
27245
|
+
void depthEstimate;
|
|
27246
|
+
return CANDIDATES.map((c) => {
|
|
27247
|
+
const on = [];
|
|
27248
|
+
if (concurrentOpen >= c.max_concurrent) on.push("concurrent");
|
|
27249
|
+
return { label: c.label, would_deny: on.length > 0, on };
|
|
27250
|
+
});
|
|
27251
|
+
}
|
|
27252
|
+
function unwrapPayload3(envelope) {
|
|
27253
|
+
const inner = envelope["payload"];
|
|
27254
|
+
return isObject10(inner) ? inner : envelope;
|
|
27255
|
+
}
|
|
27256
|
+
function extractToolName4(payload) {
|
|
27257
|
+
const v = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
|
|
27258
|
+
return typeof v === "string" && v ? v : null;
|
|
27259
|
+
}
|
|
27260
|
+
function processEnvelope3(envelope, consumerRoot) {
|
|
27261
|
+
try {
|
|
27262
|
+
if (!isObject10(envelope)) return EXIT_ALLOW22;
|
|
27263
|
+
const payload = unwrapPayload3(envelope);
|
|
27264
|
+
const toolName = extractToolName4(payload);
|
|
27265
|
+
if (toolName === null || !DISPATCH_TOOL_NAMES2.has(toolName)) return EXIT_ALLOW22;
|
|
27266
|
+
const stats = openRecordStats(consumerRoot);
|
|
27267
|
+
const depthEstimate = stats.max_depth + 1;
|
|
27268
|
+
const verdicts = evaluateCandidates(depthEstimate, stats.open_count);
|
|
27269
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
27270
|
+
appendLedgerLine(consumerRoot, nowIso, {
|
|
27271
|
+
event: "spawn_guard_shadow",
|
|
27272
|
+
ts: nowIso,
|
|
27273
|
+
tool: toolName,
|
|
27274
|
+
concurrent_open: stats.open_count,
|
|
27275
|
+
depth_estimate: depthEstimate,
|
|
27276
|
+
depth_estimate_basis: "deepest-open-record-plus-one",
|
|
27277
|
+
// R2 round 2, finding 3: the estimate is >= 2 whenever anything is
|
|
27278
|
+
// open, nesting or not, so it must not reach a derivation. It rides
|
|
27279
|
+
// as context with the flag that says so.
|
|
27280
|
+
depth_usable_for_derivation: false,
|
|
27281
|
+
// R2 round 2, finding 4: without these, a quiet estate, a ledger
|
|
27282
|
+
// this hook cannot see, and a root mismatch all emit byte-identical
|
|
27283
|
+
// records — the instrument-goes-quiet failure one layer up from the
|
|
27284
|
+
// one the ledger already fixed for itself.
|
|
27285
|
+
ledger_present: stats.ledger_present,
|
|
27286
|
+
stale_open_excluded: stats.stale_excluded,
|
|
27287
|
+
candidates: verdicts.map((v) => ({ label: v.label, would_deny: v.would_deny, on: v.on })),
|
|
27288
|
+
// Shadow posture is a property of this file, not of a setting —
|
|
27289
|
+
// there is no code path here that can deny.
|
|
27290
|
+
posture: "shadow"
|
|
27291
|
+
});
|
|
27292
|
+
} catch {
|
|
27293
|
+
return EXIT_ALLOW22;
|
|
27294
|
+
}
|
|
27295
|
+
return EXIT_ALLOW22;
|
|
27296
|
+
}
|
|
27297
|
+
function main47() {
|
|
27298
|
+
const raw = readHookStdin();
|
|
27299
|
+
let envelope = {};
|
|
27300
|
+
try {
|
|
27301
|
+
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
27302
|
+
} catch {
|
|
27303
|
+
return EXIT_ALLOW22;
|
|
27304
|
+
}
|
|
27305
|
+
return processEnvelope3(envelope, resolveConsumerRoot(envelope));
|
|
27306
|
+
}
|
|
27307
|
+
function _isCliEntry37() {
|
|
27308
|
+
if (true) return false;
|
|
27309
|
+
if (process.argv[1] === void 0) return false;
|
|
27310
|
+
const argvUrl = pathToFileURL42(path68.resolve(process.argv[1])).href;
|
|
27311
|
+
if (import.meta.url === argvUrl) return true;
|
|
27312
|
+
try {
|
|
27313
|
+
return fs66.realpathSync(fileURLToPath48(import.meta.url)) === fs66.realpathSync(path68.resolve(process.argv[1]));
|
|
27314
|
+
} catch {
|
|
27315
|
+
return false;
|
|
27316
|
+
}
|
|
27317
|
+
}
|
|
27318
|
+
if (_isCliEntry37()) process.exit(main47());
|
|
27319
|
+
|
|
26681
27320
|
// src/scripts/hooks/concern_registry.ts
|
|
26682
27321
|
var CONCERN_REGISTRY = {
|
|
26683
27322
|
"src/scripts/chat_history.ts": main6,
|
|
@@ -26714,10 +27353,12 @@ var CONCERN_REGISTRY = {
|
|
|
26714
27353
|
"src/scripts/hooks/orchestration_record_hook.ts": main39,
|
|
26715
27354
|
"src/scripts/hooks/delegation_nudge_hook.ts": main40,
|
|
26716
27355
|
"src/scripts/hooks/end_review_nudge_hook.ts": main41,
|
|
26717
|
-
"src/scripts/hooks/turn_end_gate_hook.ts":
|
|
26718
|
-
"src/scripts/hooks/edit_shape_hook.ts":
|
|
26719
|
-
"src/scripts/hooks/reread_guard_hook.ts":
|
|
26720
|
-
"src/scripts/hooks/session_eol_hook.ts":
|
|
27356
|
+
"src/scripts/hooks/turn_end_gate_hook.ts": main43,
|
|
27357
|
+
"src/scripts/hooks/edit_shape_hook.ts": main44,
|
|
27358
|
+
"src/scripts/hooks/reread_guard_hook.ts": main45,
|
|
27359
|
+
"src/scripts/hooks/session_eol_hook.ts": main46,
|
|
27360
|
+
"src/scripts/hooks/subagent_ledger_hook.ts": main42,
|
|
27361
|
+
"src/scripts/hooks/spawn_guard_shadow_hook.ts": main47
|
|
26721
27362
|
};
|
|
26722
27363
|
|
|
26723
27364
|
// src/scripts/hooks/host_semantics.ts
|
|
@@ -26729,7 +27370,9 @@ var CLAUDE_HOOK_EVENT_NAME = {
|
|
|
26729
27370
|
session_start: "SessionStart",
|
|
26730
27371
|
session_end: "SessionEnd",
|
|
26731
27372
|
stop: "Stop",
|
|
26732
|
-
pre_compact: "PreCompact"
|
|
27373
|
+
pre_compact: "PreCompact",
|
|
27374
|
+
subagent_start: "SubagentStart",
|
|
27375
|
+
subagent_stop: "SubagentStop"
|
|
26733
27376
|
};
|
|
26734
27377
|
var CLAUDE_BLOCK_CAPABLE_EVENTS = /* @__PURE__ */ new Set([
|
|
26735
27378
|
"pre_tool_use",
|
|
@@ -26771,12 +27414,12 @@ function emitFor(platform, event, severity, reasons, legacyExit) {
|
|
|
26771
27414
|
|
|
26772
27415
|
// src/scripts/hooks/dispatch_hook.ts
|
|
26773
27416
|
var _IN_BUNDLE = true;
|
|
26774
|
-
var REPO_ROOT =
|
|
26775
|
-
|
|
27417
|
+
var REPO_ROOT = path69.resolve(
|
|
27418
|
+
path69.dirname(fileURLToPath49(import.meta.url)),
|
|
26776
27419
|
..._IN_BUNDLE ? ["..", ".."] : ["..", "..", ".."]
|
|
26777
27420
|
);
|
|
26778
|
-
var MANIFEST_PATH =
|
|
26779
|
-
var
|
|
27421
|
+
var MANIFEST_PATH = path69.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
|
|
27422
|
+
var EXIT_ALLOW23 = 0;
|
|
26780
27423
|
var EXIT_BLOCK5 = 1;
|
|
26781
27424
|
var EXIT_WARN14 = 2;
|
|
26782
27425
|
var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
|
|
@@ -26787,10 +27430,12 @@ var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
|
|
|
26787
27430
|
"post_tool_use",
|
|
26788
27431
|
"stop",
|
|
26789
27432
|
"pre_compact",
|
|
26790
|
-
"agent_error"
|
|
27433
|
+
"agent_error",
|
|
27434
|
+
"subagent_start",
|
|
27435
|
+
"subagent_stop"
|
|
26791
27436
|
]);
|
|
26792
27437
|
var _SEVERITY_BY_EXIT = {
|
|
26793
|
-
[
|
|
27438
|
+
[EXIT_ALLOW23]: "allow",
|
|
26794
27439
|
[EXIT_BLOCK5]: "block",
|
|
26795
27440
|
[EXIT_WARN14]: "warn"
|
|
26796
27441
|
};
|
|
@@ -26827,7 +27472,7 @@ function _parse_concern_stdout(stdout_text) {
|
|
|
26827
27472
|
return _isObject14(parsed) ? parsed : { _raw: parsed };
|
|
26828
27473
|
}
|
|
26829
27474
|
function _load_yaml3(p) {
|
|
26830
|
-
const text =
|
|
27475
|
+
const text = fs67.readFileSync(p, "utf-8");
|
|
26831
27476
|
const data = (0, import_yaml6.parse)(text, { version: "1.1" });
|
|
26832
27477
|
return _isObject14(data) ? data : {};
|
|
26833
27478
|
}
|
|
@@ -26984,7 +27629,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
26984
27629
|
}
|
|
26985
27630
|
try {
|
|
26986
27631
|
const target = _expanduser3(capture_dir);
|
|
26987
|
-
|
|
27632
|
+
fs67.mkdirSync(target, { recursive: true });
|
|
26988
27633
|
let payload;
|
|
26989
27634
|
try {
|
|
26990
27635
|
payload = payload_text.trim() ? JSON.parse(payload_text) : {};
|
|
@@ -27001,8 +27646,8 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
27001
27646
|
const ts = Date.now();
|
|
27002
27647
|
const native = (args.native_event || args.event).replace(/\//g, "_");
|
|
27003
27648
|
const fname = `${args.platform}__${native}__${ts}__${process.pid}.json`;
|
|
27004
|
-
|
|
27005
|
-
|
|
27649
|
+
fs67.writeFileSync(
|
|
27650
|
+
path69.join(target, fname),
|
|
27006
27651
|
_py_json_dumps2(record, 2) + "\n",
|
|
27007
27652
|
{ encoding: "utf-8" }
|
|
27008
27653
|
);
|
|
@@ -27013,7 +27658,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
27013
27658
|
function _expanduser3(p) {
|
|
27014
27659
|
if (p === "~" || p.startsWith("~/")) {
|
|
27015
27660
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "";
|
|
27016
|
-
return
|
|
27661
|
+
return path69.join(home, p.slice(1));
|
|
27017
27662
|
}
|
|
27018
27663
|
return p;
|
|
27019
27664
|
}
|
|
@@ -27045,25 +27690,25 @@ function _resolve_tsx_invocation2(scriptPath, scriptArgs) {
|
|
|
27045
27690
|
const walkUp = (start) => {
|
|
27046
27691
|
let dir = start;
|
|
27047
27692
|
for (; ; ) {
|
|
27048
|
-
const candidate =
|
|
27693
|
+
const candidate = path69.join(dir, "node_modules", ".bin", binName);
|
|
27049
27694
|
if (_isFile7(candidate)) {
|
|
27050
27695
|
return candidate;
|
|
27051
27696
|
}
|
|
27052
|
-
const parent =
|
|
27697
|
+
const parent = path69.dirname(dir);
|
|
27053
27698
|
if (parent === dir) {
|
|
27054
27699
|
return null;
|
|
27055
27700
|
}
|
|
27056
27701
|
dir = parent;
|
|
27057
27702
|
}
|
|
27058
27703
|
};
|
|
27059
|
-
const tsx = walkUp(
|
|
27704
|
+
const tsx = walkUp(path69.dirname(scriptPath)) ?? walkUp(path69.dirname(fileURLToPath49(import.meta.url)));
|
|
27060
27705
|
if (tsx !== null) {
|
|
27061
27706
|
return { command: tsx, args: [scriptPath, ...scriptArgs] };
|
|
27062
27707
|
}
|
|
27063
27708
|
return { command: "npx", args: ["tsx", scriptPath, ...scriptArgs] };
|
|
27064
27709
|
}
|
|
27065
27710
|
function _run_concern_inproc(main_fn, concern, envelope) {
|
|
27066
|
-
const scriptAbs =
|
|
27711
|
+
const scriptAbs = path69.join(REPO_ROOT, String(concern["script"]));
|
|
27067
27712
|
const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
|
|
27068
27713
|
argsList.push("--platform", String(envelope["platform"] || "generic"));
|
|
27069
27714
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
@@ -27140,7 +27785,7 @@ function _run_concern(concern, envelope) {
|
|
|
27140
27785
|
return _run_concern_inproc(inproc, concern, envelope);
|
|
27141
27786
|
}
|
|
27142
27787
|
}
|
|
27143
|
-
const script =
|
|
27788
|
+
const script = path69.join(REPO_ROOT, String(concern["script"]));
|
|
27144
27789
|
const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
|
|
27145
27790
|
const cmd = [script, ...argsList];
|
|
27146
27791
|
cmd.push("--platform", String(envelope["platform"] || "generic"));
|
|
@@ -27197,7 +27842,7 @@ function _run_concern(concern, envelope) {
|
|
|
27197
27842
|
}
|
|
27198
27843
|
function _isFile7(p) {
|
|
27199
27844
|
try {
|
|
27200
|
-
return
|
|
27845
|
+
return fs67.statSync(p).isFile();
|
|
27201
27846
|
} catch {
|
|
27202
27847
|
return false;
|
|
27203
27848
|
}
|
|
@@ -27212,17 +27857,17 @@ function _reduce(rcs) {
|
|
|
27212
27857
|
if (rcs.some((rc) => rc === EXIT_WARN14)) {
|
|
27213
27858
|
return EXIT_WARN14;
|
|
27214
27859
|
}
|
|
27215
|
-
return
|
|
27860
|
+
return EXIT_ALLOW23;
|
|
27216
27861
|
}
|
|
27217
27862
|
function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
27218
27863
|
if (is_replay_mode()) {
|
|
27219
27864
|
return;
|
|
27220
27865
|
}
|
|
27221
27866
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
27222
|
-
const state_root =
|
|
27867
|
+
const state_root = path69.join(workspace, "agents", "runtime", "state");
|
|
27223
27868
|
const fb_dir = feedback_dir(state_root, session_id);
|
|
27224
27869
|
try {
|
|
27225
|
-
|
|
27870
|
+
fs67.mkdirSync(fb_dir, { recursive: true });
|
|
27226
27871
|
} catch (exc) {
|
|
27227
27872
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
27228
27873
|
process.stderr.write(`dispatch_hook: feedback dir unavailable: ${msg}
|
|
@@ -27230,7 +27875,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
27230
27875
|
return;
|
|
27231
27876
|
}
|
|
27232
27877
|
for (const entry of entries) {
|
|
27233
|
-
const target =
|
|
27878
|
+
const target = path69.join(fb_dir, `${entry["concern"]}.json`);
|
|
27234
27879
|
try {
|
|
27235
27880
|
atomic_write_json(target, entry);
|
|
27236
27881
|
} catch (exc) {
|
|
@@ -27270,7 +27915,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
27270
27915
|
})
|
|
27271
27916
|
};
|
|
27272
27917
|
try {
|
|
27273
|
-
atomic_write_json(
|
|
27918
|
+
atomic_write_json(path69.join(fb_dir, "summary.json"), summary);
|
|
27274
27919
|
} catch (exc) {
|
|
27275
27920
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
27276
27921
|
process.stderr.write(`dispatch_hook: summary write failed: ${msg}
|
|
@@ -27285,12 +27930,12 @@ function _record_rule_trips(envelope, entries) {
|
|
|
27285
27930
|
if (tripped.length === 0) return;
|
|
27286
27931
|
try {
|
|
27287
27932
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
27288
|
-
const state_dir =
|
|
27289
|
-
const target =
|
|
27290
|
-
|
|
27933
|
+
const state_dir = path69.join(workspace, "agents", "runtime", "state");
|
|
27934
|
+
const target = path69.join(state_dir, "rule-trips.json");
|
|
27935
|
+
fs67.mkdirSync(state_dir, { recursive: true });
|
|
27291
27936
|
let doc = { schema_version: 1, concerns: {} };
|
|
27292
27937
|
try {
|
|
27293
|
-
const parsed = JSON.parse(
|
|
27938
|
+
const parsed = JSON.parse(fs67.readFileSync(target, "utf-8"));
|
|
27294
27939
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) doc = parsed;
|
|
27295
27940
|
} catch {
|
|
27296
27941
|
}
|
|
@@ -27389,7 +28034,7 @@ function _parse_args(argv) {
|
|
|
27389
28034
|
}
|
|
27390
28035
|
return args;
|
|
27391
28036
|
}
|
|
27392
|
-
function
|
|
28037
|
+
function main48(argv) {
|
|
27393
28038
|
const args = _parse_args(argv ?? process.argv.slice(2));
|
|
27394
28039
|
if (args.project_dir) {
|
|
27395
28040
|
const project_dir = _expanduser3(args.project_dir);
|
|
@@ -27407,13 +28052,13 @@ function main46(argv) {
|
|
|
27407
28052
|
`dispatch_hook: unknown event '${args.event}'; allowed: ${_sortedRepr(EVENT_VOCABULARY)}
|
|
27408
28053
|
`
|
|
27409
28054
|
);
|
|
27410
|
-
return
|
|
28055
|
+
return EXIT_ALLOW23;
|
|
27411
28056
|
}
|
|
27412
28057
|
const manifest_path = args.manifest;
|
|
27413
|
-
if (!
|
|
28058
|
+
if (!fs67.existsSync(manifest_path)) {
|
|
27414
28059
|
process.stderr.write(`dispatch_hook: manifest missing at ${manifest_path}
|
|
27415
28060
|
`);
|
|
27416
|
-
return
|
|
28061
|
+
return EXIT_ALLOW23;
|
|
27417
28062
|
}
|
|
27418
28063
|
const manifest = _load_yaml3(manifest_path);
|
|
27419
28064
|
if (args.min_version) {
|
|
@@ -27437,10 +28082,10 @@ function main46(argv) {
|
|
|
27437
28082
|
concerns: concerns.map((c) => c["name"])
|
|
27438
28083
|
};
|
|
27439
28084
|
process.stdout.write(_py_json_dumps2(plan, 2) + "\n");
|
|
27440
|
-
return
|
|
28085
|
+
return EXIT_ALLOW23;
|
|
27441
28086
|
}
|
|
27442
28087
|
if (concerns.length === 0) {
|
|
27443
|
-
return
|
|
28088
|
+
return EXIT_ALLOW23;
|
|
27444
28089
|
}
|
|
27445
28090
|
const envelope = _build_envelope(args, payload_text);
|
|
27446
28091
|
const session_id = _resolve_session_id(envelope);
|
|
@@ -27460,7 +28105,7 @@ function main46(argv) {
|
|
|
27460
28105
|
const raw_rc = rc;
|
|
27461
28106
|
if (rc >= 3) {
|
|
27462
28107
|
if (!concern["fail_closed"]) {
|
|
27463
|
-
rc =
|
|
28108
|
+
rc = EXIT_ALLOW23;
|
|
27464
28109
|
} else {
|
|
27465
28110
|
rc = EXIT_BLOCK5;
|
|
27466
28111
|
}
|
|
@@ -27483,7 +28128,7 @@ function main46(argv) {
|
|
|
27483
28128
|
if (message) {
|
|
27484
28129
|
concern_messages.push({ rc, text: message });
|
|
27485
28130
|
}
|
|
27486
|
-
if (args.event === "session_start" && rc ===
|
|
28131
|
+
if (args.event === "session_start" && rc === EXIT_ALLOW23 && typeof reply["context"] === "string" && reply["context"].trim()) {
|
|
27487
28132
|
context_blocks.push(reply["context"].trim());
|
|
27488
28133
|
}
|
|
27489
28134
|
feedback_entries.push({
|
|
@@ -27502,7 +28147,7 @@ function main46(argv) {
|
|
|
27502
28147
|
const final_rc = _reduce(rcs);
|
|
27503
28148
|
_write_feedback(envelope, session_id, feedback_entries, final_rc, started_at);
|
|
27504
28149
|
_record_rule_trips(envelope, feedback_entries);
|
|
27505
|
-
if (context_blocks.length > 0 && final_rc ===
|
|
28150
|
+
if (context_blocks.length > 0 && final_rc === EXIT_ALLOW23) {
|
|
27506
28151
|
process.stdout.write(context_blocks.join("\n\n") + "\n");
|
|
27507
28152
|
}
|
|
27508
28153
|
const decidingReasons = concern_messages.filter((m) => m.rc === final_rc).map((m) => m.text);
|
|
@@ -27523,7 +28168,7 @@ function main46(argv) {
|
|
|
27523
28168
|
}
|
|
27524
28169
|
function _isDir4(p) {
|
|
27525
28170
|
try {
|
|
27526
|
-
return
|
|
28171
|
+
return fs67.statSync(p).isDirectory();
|
|
27527
28172
|
} catch {
|
|
27528
28173
|
return false;
|
|
27529
28174
|
}
|
|
@@ -27534,41 +28179,41 @@ function _sortedRepr(s) {
|
|
|
27534
28179
|
}
|
|
27535
28180
|
function _readStdin14() {
|
|
27536
28181
|
try {
|
|
27537
|
-
return
|
|
28182
|
+
return fs67.readFileSync(0, "utf-8");
|
|
27538
28183
|
} catch {
|
|
27539
28184
|
return "";
|
|
27540
28185
|
}
|
|
27541
28186
|
}
|
|
27542
|
-
function
|
|
28187
|
+
function _isCliEntry38() {
|
|
27543
28188
|
if (true) {
|
|
27544
28189
|
return false;
|
|
27545
28190
|
}
|
|
27546
28191
|
if (process.argv[1] === void 0) {
|
|
27547
28192
|
return false;
|
|
27548
28193
|
}
|
|
27549
|
-
const argvUrl =
|
|
28194
|
+
const argvUrl = pathToFileURL43(path69.resolve(process.argv[1])).href;
|
|
27550
28195
|
if (import.meta.url === argvUrl) {
|
|
27551
28196
|
return true;
|
|
27552
28197
|
}
|
|
27553
28198
|
try {
|
|
27554
|
-
const here =
|
|
27555
|
-
const argv =
|
|
28199
|
+
const here = fs67.realpathSync(fileURLToPath49(import.meta.url));
|
|
28200
|
+
const argv = fs67.realpathSync(path69.resolve(process.argv[1]));
|
|
27556
28201
|
return here === argv;
|
|
27557
28202
|
} catch {
|
|
27558
28203
|
return false;
|
|
27559
28204
|
}
|
|
27560
28205
|
}
|
|
27561
|
-
var isCliEntry13 =
|
|
28206
|
+
var isCliEntry13 = _isCliEntry38();
|
|
27562
28207
|
if (isCliEntry13) {
|
|
27563
|
-
process.exit(
|
|
28208
|
+
process.exit(main48(process.argv.slice(2)));
|
|
27564
28209
|
}
|
|
27565
28210
|
|
|
27566
28211
|
// src/scripts/hooks/dispatch_entry.ts
|
|
27567
|
-
var _selfPath =
|
|
27568
|
-
var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 &&
|
|
28212
|
+
var _selfPath = fileURLToPath50(import.meta.url);
|
|
28213
|
+
var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path70.resolve(process.argv[1]) === path70.resolve(_selfPath);
|
|
27569
28214
|
if (_invokedDirectly2) {
|
|
27570
|
-
process.exitCode =
|
|
28215
|
+
process.exitCode = main48(process.argv.slice(2));
|
|
27571
28216
|
}
|
|
27572
28217
|
export {
|
|
27573
|
-
|
|
28218
|
+
main48 as main
|
|
27574
28219
|
};
|