@event4u/agent-config 14.13.0 → 14.14.1
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/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +138 -376
- package/README.md +1 -1
- package/dist/agent-src/commands/analyze/inbox.md +36 -0
- package/dist/agent-src/commands/pr/create.md +16 -1
- package/dist/agent-src/contexts/execution/terminal-states.md +25 -4
- package/dist/agent-src/rules/code-comment-discipline.md +6 -0
- package/dist/agent-src/rules/missing-skill-recovery.md +2 -2
- package/dist/agent-src/rules/token-budget-discipline.md +2 -2
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +6 -6
- package/dist/agent-src/scripts/guarded_baseline.ts +22 -7
- package/dist/agent-src/scripts/stubs_due.ts +118 -2
- package/dist/agent-src/scripts/update_roadmap_progress.ts +8 -8
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/cli/registry.js +1 -0
- package/dist/cli-delegate/{chunk-ILMUPLGW.js → chunk-7RXIKF62.js} +159 -86
- package/dist/cli-delegate/cmd_conformance.js +39 -2
- package/dist/cli-delegate/cmd_doctor.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +7 -7
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/hooks/dispatch.js +1696 -812
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +297 -115
- package/docs/guidelines/agent-infra/guarded-baseline.md +1 -1
- package/docs/guidelines/code-clarity.md +18 -0
- package/package.json +1 -1
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +6 -6
- package/src/agent-src/scripts/guarded_baseline.ts +22 -7
- package/src/agent-src/scripts/stubs_due.ts +118 -2
- package/src/agent-src/scripts/update_roadmap_progress.ts +8 -8
- package/src/config/assurance-capability-registry.json +1 -1
- package/src/config/estate-count-budget.json +20 -1
- package/src/config/evaluator-budgets.json +4 -4
- package/src/config/gate-coverage.yml +211 -1
- package/src/config/gate-reachability-exemptions.json +1 -0
- package/src/config/gate-violation-baselines.json +9 -3
- package/src/config/preamble-payload-budget.json +19 -11
- package/src/config/rule-stub-ceilings.json +14 -7
- package/src/config/web-launch-readiness.json +4 -2
- package/src/scripts/_cli/_doctor_emit.ts +71 -0
- package/src/scripts/_cli/_doctor_strict.ts +163 -0
- package/src/scripts/_cli/cmd_doctor.ts +16 -37
- package/src/scripts/_dispatch.bash +11 -4
- package/src/scripts/_lib/activation_ladder.ts +47 -3
- package/src/scripts/_lib/activation_receipt_producer.ts +341 -0
- package/src/scripts/_lib/adr_frontmatter.ts +26 -0
- package/src/scripts/_lib/branch_convergence.ts +186 -0
- package/src/scripts/_lib/candidate_pair_delta.ts +349 -0
- package/src/scripts/_lib/carrier_status.ts +118 -0
- package/src/scripts/_lib/cascade_stage_enumeration.ts +92 -0
- package/src/scripts/_lib/context_observation.ts +132 -0
- package/src/scripts/_lib/continuation_ladder.ts +188 -0
- package/src/scripts/_lib/corpus_manifest.ts +726 -0
- package/src/scripts/_lib/delivery_arm_experiment.ts +18 -2
- package/src/scripts/_lib/estate_carrier_cases.ts +72 -0
- package/src/scripts/_lib/evaluation_cascade.ts +452 -0
- package/src/scripts/_lib/evolution_roi.ts +562 -0
- package/src/scripts/_lib/experiment_binding.ts +95 -0
- package/src/scripts/_lib/harness_evolution_guards.ts +10 -0
- package/src/scripts/_lib/ignored_blocker.ts +8 -1
- package/src/scripts/_lib/lexical_shortlist.ts +215 -0
- package/src/scripts/_lib/llm_candidate_proposer.ts +461 -0
- package/src/scripts/_lib/llm_proposer_transport.ts +153 -0
- package/src/scripts/_lib/outcome_envelope.ts +6 -1
- package/src/scripts/_lib/outcome_vocabularies.ts +135 -5
- package/src/scripts/_lib/pathology_archive.ts +393 -0
- package/src/scripts/_lib/promotion_capability.ts +315 -0
- package/src/scripts/_lib/promotion_evidence.ts +414 -0
- package/src/scripts/_lib/promotion_review.ts +294 -0
- package/src/scripts/_lib/prompt_shape.ts +92 -0
- package/src/scripts/_lib/release_highlights.ts +79 -1
- package/src/scripts/_lib/release_material.ts +125 -2
- package/src/scripts/_lib/repeated_failure.ts +19 -2
- package/src/scripts/_lib/routing_corpus.ts +307 -0
- package/src/scripts/_lib/routing_index_input.ts +104 -0
- package/src/scripts/_lib/rule_injection.ts +22 -1
- package/src/scripts/_lib/runtime_journal.ts +11 -4
- package/src/scripts/_lib/semantic_noop.ts +167 -0
- package/src/scripts/activation_receipt.ts +258 -0
- package/src/scripts/ai_council/cross_exam.ts +128 -0
- package/src/scripts/ai_council/explain_route.ts +157 -0
- package/src/scripts/ai_council/information_gain.ts +293 -0
- package/src/scripts/ai_council/leakage_corpus.ts +385 -0
- package/src/scripts/ai_council/leakage_patterns.ts +453 -0
- package/src/scripts/ai_council/minority_retention.ts +171 -0
- package/src/scripts/ai_council/recouncil_savings.ts +299 -0
- package/src/scripts/ai_council/replay_route.ts +223 -0
- package/src/scripts/ai_council/reviewer_assignment.ts +279 -0
- package/src/scripts/ai_council/routing_training_row.ts +197 -0
- package/src/scripts/ai_council/synthesis_strategy.ts +159 -0
- package/src/scripts/check_adr_frontmatter.ts +4 -9
- package/src/scripts/check_agent_artifact_location.ts +337 -0
- package/src/scripts/check_artefact_count_messaging.ts +74 -8
- package/src/scripts/check_enforcement_coverage.ts +40 -1
- package/src/scripts/check_estate_count.ts +205 -24
- package/src/scripts/check_release_highlights.ts +113 -14
- package/src/scripts/check_roadmap_trackable.ts +17 -2
- package/src/scripts/check_web_launch_readiness.ts +310 -20
- package/src/scripts/corpus_manifest.ts +235 -0
- package/src/scripts/evolution_lab.ts +234 -9
- package/src/scripts/generate_capability_matrix.ts +16 -9
- package/src/scripts/grade_target_readiness.ts +221 -2
- package/src/scripts/hook_effect_doctor.ts +47 -4
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +28 -6
- package/src/scripts/hooks/comment_discipline_hook.ts +146 -0
- package/src/scripts/hooks/concern_registry.ts +2 -0
- package/src/scripts/hooks/run_continuation_hook.ts +78 -88
- package/src/scripts/hooks/session_eol_hook.ts +12 -1
- package/src/scripts/hooks/turn_end_gate_hook.ts +9 -1
- package/src/scripts/install-hooks.sh +18 -0
- package/src/scripts/language_mirror_hook.ts +14 -2
- package/src/scripts/lint_carrier_integrity.ts +820 -0
- package/src/scripts/lint_code_comments.ts +748 -0
- package/src/scripts/lint_plan_risk_register.ts +39 -19
- package/src/scripts/lint_promotion_paths.ts +779 -0
- package/src/scripts/llm_propose.ts +256 -0
- package/src/scripts/measure_delivery_sets.ts +361 -0
- package/src/scripts/measure_routing_signal.ts +307 -0
- package/src/scripts/model_rule_injection.ts +19 -3
- package/src/scripts/probe_council_retention.ts +495 -0
- package/src/scripts/release.ts +21 -37
- package/src/scripts/release_drill.ts +199 -0
- package/src/scripts/release_env.ts +35 -0
- package/src/scripts/release_publication.ts +142 -0
- package/src/scripts/roadmap_context.ts +15 -0
- package/src/scripts/skill_scout.ts +633 -0
- package/src/scripts/sync_pr_branch.ts +521 -42
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, path106) {
|
|
116
|
+
const ctrl = callVisitor(key, node, visitor, path106);
|
|
117
117
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
118
|
-
replaceNode(key,
|
|
119
|
-
return visit_(key, ctrl, visitor,
|
|
118
|
+
replaceNode(key, path106, ctrl);
|
|
119
|
+
return visit_(key, ctrl, visitor, path106);
|
|
120
120
|
}
|
|
121
121
|
if (typeof ctrl !== "symbol") {
|
|
122
122
|
if (identity.isCollection(node)) {
|
|
123
|
-
|
|
123
|
+
path106 = Object.freeze(path106.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, path106);
|
|
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
|
+
path106 = Object.freeze(path106.concat(node));
|
|
137
|
+
const ck = visit_("key", node.key, visitor, path106);
|
|
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, path106);
|
|
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, path106) {
|
|
164
|
+
const ctrl = await callVisitor(key, node, visitor, path106);
|
|
165
165
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
166
|
-
replaceNode(key,
|
|
167
|
-
return visitAsync_(key, ctrl, visitor,
|
|
166
|
+
replaceNode(key, path106, ctrl);
|
|
167
|
+
return visitAsync_(key, ctrl, visitor, path106);
|
|
168
168
|
}
|
|
169
169
|
if (typeof ctrl !== "symbol") {
|
|
170
170
|
if (identity.isCollection(node)) {
|
|
171
|
-
|
|
171
|
+
path106 = Object.freeze(path106.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, path106);
|
|
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
|
+
path106 = Object.freeze(path106.concat(node));
|
|
185
|
+
const ck = await visitAsync_("key", node.key, visitor, path106);
|
|
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, path106);
|
|
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, path106) {
|
|
218
218
|
if (typeof visitor === "function")
|
|
219
|
-
return visitor(key, node,
|
|
219
|
+
return visitor(key, node, path106);
|
|
220
220
|
if (identity.isMap(node))
|
|
221
|
-
return visitor.Map?.(key, node,
|
|
221
|
+
return visitor.Map?.(key, node, path106);
|
|
222
222
|
if (identity.isSeq(node))
|
|
223
|
-
return visitor.Seq?.(key, node,
|
|
223
|
+
return visitor.Seq?.(key, node, path106);
|
|
224
224
|
if (identity.isPair(node))
|
|
225
|
-
return visitor.Pair?.(key, node,
|
|
225
|
+
return visitor.Pair?.(key, node, path106);
|
|
226
226
|
if (identity.isScalar(node))
|
|
227
|
-
return visitor.Scalar?.(key, node,
|
|
227
|
+
return visitor.Scalar?.(key, node, path106);
|
|
228
228
|
if (identity.isAlias(node))
|
|
229
|
-
return visitor.Alias?.(key, node,
|
|
229
|
+
return visitor.Alias?.(key, node, path106);
|
|
230
230
|
return void 0;
|
|
231
231
|
}
|
|
232
|
-
function replaceNode(key,
|
|
233
|
-
const parent =
|
|
232
|
+
function replaceNode(key, path106, node) {
|
|
233
|
+
const parent = path106[path106.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, path106, value) {
|
|
844
844
|
let v = value;
|
|
845
|
-
for (let i =
|
|
846
|
-
const k =
|
|
845
|
+
for (let i = path106.length - 1; i >= 0; --i) {
|
|
846
|
+
const k = path106[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 = (path106) => path106 == null || typeof path106 === "object" && !!path106[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(path106, value) {
|
|
896
|
+
if (isEmptyPath(path106))
|
|
897
897
|
this.add(value);
|
|
898
898
|
else {
|
|
899
|
-
const [key, ...rest] =
|
|
899
|
+
const [key, ...rest] = path106;
|
|
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(path106) {
|
|
914
|
+
const [key, ...rest] = path106;
|
|
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(path106, keepScalar) {
|
|
929
|
+
const [key, ...rest] = path106;
|
|
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(path106) {
|
|
948
|
+
const [key, ...rest] = path106;
|
|
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(path106, value) {
|
|
959
|
+
const [key, ...rest] = path106;
|
|
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 = (str16) => str16.replace(/^(?!$)(?: $)?/gm, "#");
|
|
984
984
|
function indentComment(comment, indent) {
|
|
985
985
|
if (/^\n+$/.test(comment))
|
|
986
986
|
return comment.substring(1);
|
|
987
987
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
988
988
|
}
|
|
989
|
-
var lineComment = (
|
|
989
|
+
var lineComment = (str16, indent, comment) => str16.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str16.endsWith(" ") ? "" : " ") + comment;
|
|
990
990
|
exports.indentComment = indentComment;
|
|
991
991
|
exports.lineComment = lineComment;
|
|
992
992
|
exports.stringifyComment = stringifyComment;
|
|
@@ -1140,16 +1140,16 @@ var require_stringifyString = __commonJS({
|
|
|
1140
1140
|
lineWidth: ctx.options.lineWidth,
|
|
1141
1141
|
minContentWidth: ctx.options.minContentWidth
|
|
1142
1142
|
});
|
|
1143
|
-
var containsDocumentMarker = (
|
|
1144
|
-
function lineLengthOverLimit(
|
|
1143
|
+
var containsDocumentMarker = (str16) => /^(%|---|\.\.\.)/m.test(str16);
|
|
1144
|
+
function lineLengthOverLimit(str16, lineWidth, indentLength) {
|
|
1145
1145
|
if (!lineWidth || lineWidth < 0)
|
|
1146
1146
|
return false;
|
|
1147
1147
|
const limit = lineWidth - indentLength;
|
|
1148
|
-
const strLen =
|
|
1148
|
+
const strLen = str16.length;
|
|
1149
1149
|
if (strLen <= limit)
|
|
1150
1150
|
return false;
|
|
1151
1151
|
for (let i = 0, start = 0; i < strLen; ++i) {
|
|
1152
|
-
if (
|
|
1152
|
+
if (str16[i] === "\n") {
|
|
1153
1153
|
if (i - start > limit)
|
|
1154
1154
|
return true;
|
|
1155
1155
|
start = i + 1;
|
|
@@ -1166,11 +1166,11 @@ var require_stringifyString = __commonJS({
|
|
|
1166
1166
|
const { implicitKey } = ctx;
|
|
1167
1167
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
1168
1168
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
1169
|
-
let
|
|
1169
|
+
let str16 = "";
|
|
1170
1170
|
let start = 0;
|
|
1171
1171
|
for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
|
|
1172
1172
|
if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") {
|
|
1173
|
-
|
|
1173
|
+
str16 += json.slice(start, i) + "\\ ";
|
|
1174
1174
|
i += 1;
|
|
1175
1175
|
start = i;
|
|
1176
1176
|
ch = "\\";
|
|
@@ -1179,38 +1179,38 @@ var require_stringifyString = __commonJS({
|
|
|
1179
1179
|
switch (json[i + 1]) {
|
|
1180
1180
|
case "u":
|
|
1181
1181
|
{
|
|
1182
|
-
|
|
1182
|
+
str16 += json.slice(start, i);
|
|
1183
1183
|
const code = json.substr(i + 2, 4);
|
|
1184
1184
|
switch (code) {
|
|
1185
1185
|
case "0000":
|
|
1186
|
-
|
|
1186
|
+
str16 += "\\0";
|
|
1187
1187
|
break;
|
|
1188
1188
|
case "0007":
|
|
1189
|
-
|
|
1189
|
+
str16 += "\\a";
|
|
1190
1190
|
break;
|
|
1191
1191
|
case "000b":
|
|
1192
|
-
|
|
1192
|
+
str16 += "\\v";
|
|
1193
1193
|
break;
|
|
1194
1194
|
case "001b":
|
|
1195
|
-
|
|
1195
|
+
str16 += "\\e";
|
|
1196
1196
|
break;
|
|
1197
1197
|
case "0085":
|
|
1198
|
-
|
|
1198
|
+
str16 += "\\N";
|
|
1199
1199
|
break;
|
|
1200
1200
|
case "00a0":
|
|
1201
|
-
|
|
1201
|
+
str16 += "\\_";
|
|
1202
1202
|
break;
|
|
1203
1203
|
case "2028":
|
|
1204
|
-
|
|
1204
|
+
str16 += "\\L";
|
|
1205
1205
|
break;
|
|
1206
1206
|
case "2029":
|
|
1207
|
-
|
|
1207
|
+
str16 += "\\P";
|
|
1208
1208
|
break;
|
|
1209
1209
|
default:
|
|
1210
1210
|
if (code.substr(0, 2) === "00")
|
|
1211
|
-
|
|
1211
|
+
str16 += "\\x" + code.substr(2);
|
|
1212
1212
|
else
|
|
1213
|
-
|
|
1213
|
+
str16 += json.substr(i, 6);
|
|
1214
1214
|
}
|
|
1215
1215
|
i += 5;
|
|
1216
1216
|
start = i + 1;
|
|
@@ -1220,14 +1220,14 @@ var require_stringifyString = __commonJS({
|
|
|
1220
1220
|
if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
|
|
1221
1221
|
i += 1;
|
|
1222
1222
|
} else {
|
|
1223
|
-
|
|
1223
|
+
str16 += json.slice(start, i) + "\n\n";
|
|
1224
1224
|
while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') {
|
|
1225
|
-
|
|
1225
|
+
str16 += "\n";
|
|
1226
1226
|
i += 2;
|
|
1227
1227
|
}
|
|
1228
|
-
|
|
1228
|
+
str16 += indent;
|
|
1229
1229
|
if (json[i + 2] === " ")
|
|
1230
|
-
|
|
1230
|
+
str16 += "\\";
|
|
1231
1231
|
i += 1;
|
|
1232
1232
|
start = i + 1;
|
|
1233
1233
|
}
|
|
@@ -1236,8 +1236,8 @@ var require_stringifyString = __commonJS({
|
|
|
1236
1236
|
i += 1;
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
|
-
|
|
1240
|
-
return implicitKey ?
|
|
1239
|
+
str16 = start ? str16 + json.slice(start) : json;
|
|
1240
|
+
return implicitKey ? str16 : foldFlowLines.foldFlowLines(str16, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
1241
1241
|
}
|
|
1242
1242
|
function singleQuotedString(value, ctx) {
|
|
1243
1243
|
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
|
|
@@ -1365,15 +1365,15 @@ ${indent}${start}${value}${end}`;
|
|
|
1365
1365
|
return quotedString(value, ctx);
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
|
-
const
|
|
1368
|
+
const str16 = value.replace(/\n+/g, `$&
|
|
1369
1369
|
${indent}`);
|
|
1370
1370
|
if (actualString) {
|
|
1371
|
-
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(
|
|
1371
|
+
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str16);
|
|
1372
1372
|
const { compat, tags } = ctx.doc.schema;
|
|
1373
1373
|
if (tags.some(test) || compat?.some(test))
|
|
1374
1374
|
return quotedString(value, ctx);
|
|
1375
1375
|
}
|
|
1376
|
-
return implicitKey ?
|
|
1376
|
+
return implicitKey ? str16 : foldFlowLines.foldFlowLines(str16, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
1377
1377
|
}
|
|
1378
1378
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
1379
1379
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -1525,11 +1525,11 @@ var require_stringify = __commonJS({
|
|
|
1525
1525
|
const props = stringifyProps(node, tagObj, ctx);
|
|
1526
1526
|
if (props.length > 0)
|
|
1527
1527
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1528
|
-
const
|
|
1528
|
+
const str16 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : identity.isScalar(node) ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
1529
1529
|
if (!props)
|
|
1530
|
-
return
|
|
1531
|
-
return identity.isScalar(node) ||
|
|
1532
|
-
${ctx.indent}${
|
|
1530
|
+
return str16;
|
|
1531
|
+
return identity.isScalar(node) || str16[0] === "{" || str16[0] === "[" ? `${props} ${str16}` : `${props}
|
|
1532
|
+
${ctx.indent}${str16}`;
|
|
1533
1533
|
}
|
|
1534
1534
|
exports.createStringifyContext = createStringifyContext;
|
|
1535
1535
|
exports.stringify = stringify;
|
|
@@ -1564,8 +1564,8 @@ var require_stringifyPair = __commonJS({
|
|
|
1564
1564
|
});
|
|
1565
1565
|
let keyCommentDone = false;
|
|
1566
1566
|
let chompKeep = false;
|
|
1567
|
-
let
|
|
1568
|
-
if (!explicitKey && !ctx.inFlow &&
|
|
1567
|
+
let str16 = stringify.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
1568
|
+
if (!explicitKey && !ctx.inFlow && str16.length > 1024) {
|
|
1569
1569
|
if (simpleKeys)
|
|
1570
1570
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1571
1571
|
explicitKey = true;
|
|
@@ -1574,27 +1574,27 @@ var require_stringifyPair = __commonJS({
|
|
|
1574
1574
|
if (allNullValues || value == null) {
|
|
1575
1575
|
if (keyCommentDone && onComment)
|
|
1576
1576
|
onComment();
|
|
1577
|
-
return
|
|
1577
|
+
return str16 === "" ? "?" : explicitKey ? `? ${str16}` : str16;
|
|
1578
1578
|
}
|
|
1579
1579
|
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
|
|
1580
|
-
|
|
1580
|
+
str16 = `? ${str16}`;
|
|
1581
1581
|
if (keyComment && !keyCommentDone) {
|
|
1582
|
-
|
|
1582
|
+
str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
|
|
1583
1583
|
} else if (chompKeep && onChompKeep)
|
|
1584
1584
|
onChompKeep();
|
|
1585
|
-
return
|
|
1585
|
+
return str16;
|
|
1586
1586
|
}
|
|
1587
1587
|
if (keyCommentDone)
|
|
1588
1588
|
keyComment = null;
|
|
1589
1589
|
if (explicitKey) {
|
|
1590
1590
|
if (keyComment)
|
|
1591
|
-
|
|
1592
|
-
|
|
1591
|
+
str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
|
|
1592
|
+
str16 = `? ${str16}
|
|
1593
1593
|
${indent}:`;
|
|
1594
1594
|
} else {
|
|
1595
|
-
|
|
1595
|
+
str16 = `${str16}:`;
|
|
1596
1596
|
if (keyComment)
|
|
1597
|
-
|
|
1597
|
+
str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(keyComment));
|
|
1598
1598
|
}
|
|
1599
1599
|
let vsb, vcb, valueComment;
|
|
1600
1600
|
if (identity.isNode(value)) {
|
|
@@ -1610,7 +1610,7 @@ ${indent}:`;
|
|
|
1610
1610
|
}
|
|
1611
1611
|
ctx.implicitKey = false;
|
|
1612
1612
|
if (!explicitKey && !keyComment && identity.isScalar(value))
|
|
1613
|
-
ctx.indentAtStart =
|
|
1613
|
+
ctx.indentAtStart = str16.length + 1;
|
|
1614
1614
|
chompKeep = false;
|
|
1615
1615
|
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
1616
1616
|
ctx.indent = ctx.indent.substring(2);
|
|
@@ -1654,16 +1654,16 @@ ${ctx.indent}`;
|
|
|
1654
1654
|
} else if (valueStr === "" || valueStr[0] === "\n") {
|
|
1655
1655
|
ws = "";
|
|
1656
1656
|
}
|
|
1657
|
-
|
|
1657
|
+
str16 += ws + valueStr;
|
|
1658
1658
|
if (ctx.inFlow) {
|
|
1659
1659
|
if (valueCommentDone && onComment)
|
|
1660
1660
|
onComment();
|
|
1661
1661
|
} else if (valueComment && !valueCommentDone) {
|
|
1662
|
-
|
|
1662
|
+
str16 += stringifyComment.lineComment(str16, ctx.indent, commentString(valueComment));
|
|
1663
1663
|
} else if (chompKeep && onChompKeep) {
|
|
1664
1664
|
onChompKeep();
|
|
1665
1665
|
}
|
|
1666
|
-
return
|
|
1666
|
+
return str16;
|
|
1667
1667
|
}
|
|
1668
1668
|
exports.stringifyPair = stringifyPair;
|
|
1669
1669
|
}
|
|
@@ -1890,31 +1890,31 @@ var require_stringifyCollection = __commonJS({
|
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
1892
|
chompKeep = false;
|
|
1893
|
-
let
|
|
1893
|
+
let str17 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
1894
1894
|
if (comment2)
|
|
1895
|
-
|
|
1895
|
+
str17 += stringifyComment.lineComment(str17, itemIndent, commentString(comment2));
|
|
1896
1896
|
if (chompKeep && comment2)
|
|
1897
1897
|
chompKeep = false;
|
|
1898
|
-
lines.push(blockItemPrefix +
|
|
1898
|
+
lines.push(blockItemPrefix + str17);
|
|
1899
1899
|
}
|
|
1900
|
-
let
|
|
1900
|
+
let str16;
|
|
1901
1901
|
if (lines.length === 0) {
|
|
1902
|
-
|
|
1902
|
+
str16 = flowChars.start + flowChars.end;
|
|
1903
1903
|
} else {
|
|
1904
|
-
|
|
1904
|
+
str16 = lines[0];
|
|
1905
1905
|
for (let i = 1; i < lines.length; ++i) {
|
|
1906
1906
|
const line = lines[i];
|
|
1907
|
-
|
|
1907
|
+
str16 += line ? `
|
|
1908
1908
|
${indent}${line}` : "\n";
|
|
1909
1909
|
}
|
|
1910
1910
|
}
|
|
1911
1911
|
if (comment) {
|
|
1912
|
-
|
|
1912
|
+
str16 += "\n" + stringifyComment.indentComment(commentString(comment), indent);
|
|
1913
1913
|
if (onComment)
|
|
1914
1914
|
onComment();
|
|
1915
1915
|
} else if (chompKeep && onChompKeep)
|
|
1916
1916
|
onChompKeep();
|
|
1917
|
-
return
|
|
1917
|
+
return str16;
|
|
1918
1918
|
}
|
|
1919
1919
|
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
1920
1920
|
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
@@ -1957,21 +1957,21 @@ ${indent}${line}` : "\n";
|
|
|
1957
1957
|
}
|
|
1958
1958
|
if (comment)
|
|
1959
1959
|
reqNewline = true;
|
|
1960
|
-
let
|
|
1961
|
-
reqNewline || (reqNewline = lines.length > linesAtValue ||
|
|
1960
|
+
let str16 = stringify.stringify(item, itemCtx, () => comment = null);
|
|
1961
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str16.includes("\n"));
|
|
1962
1962
|
if (i < items.length - 1) {
|
|
1963
|
-
|
|
1963
|
+
str16 += ",";
|
|
1964
1964
|
} else if (ctx.options.trailingComma) {
|
|
1965
1965
|
if (ctx.options.lineWidth > 0) {
|
|
1966
|
-
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (
|
|
1966
|
+
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str16.length + 2) > ctx.options.lineWidth);
|
|
1967
1967
|
}
|
|
1968
1968
|
if (reqNewline) {
|
|
1969
|
-
|
|
1969
|
+
str16 += ",";
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
1972
|
if (comment)
|
|
1973
|
-
|
|
1974
|
-
lines.push(
|
|
1973
|
+
str16 += stringifyComment.lineComment(str16, itemIndent, commentString(comment));
|
|
1974
|
+
lines.push(str16);
|
|
1975
1975
|
linesAtValue = lines.length;
|
|
1976
1976
|
}
|
|
1977
1977
|
const { start, end } = flowChars;
|
|
@@ -1983,11 +1983,11 @@ ${indent}${line}` : "\n";
|
|
|
1983
1983
|
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
1984
1984
|
}
|
|
1985
1985
|
if (reqNewline) {
|
|
1986
|
-
let
|
|
1986
|
+
let str16 = start;
|
|
1987
1987
|
for (const line of lines)
|
|
1988
|
-
|
|
1988
|
+
str16 += line ? `
|
|
1989
1989
|
${indentStep}${indent}${line}` : "\n";
|
|
1990
|
-
return `${
|
|
1990
|
+
return `${str16}
|
|
1991
1991
|
${indent}${end}`;
|
|
1992
1992
|
} else {
|
|
1993
1993
|
return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
@@ -2319,7 +2319,7 @@ var require_string = __commonJS({
|
|
|
2319
2319
|
identify: (value) => typeof value === "string",
|
|
2320
2320
|
default: true,
|
|
2321
2321
|
tag: "tag:yaml.org,2002:str",
|
|
2322
|
-
resolve: (
|
|
2322
|
+
resolve: (str16) => str16,
|
|
2323
2323
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
2324
2324
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
2325
2325
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
@@ -2357,7 +2357,7 @@ var require_bool = __commonJS({
|
|
|
2357
2357
|
default: true,
|
|
2358
2358
|
tag: "tag:yaml.org,2002:bool",
|
|
2359
2359
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2360
|
-
resolve: (
|
|
2360
|
+
resolve: (str16) => new Scalar.Scalar(str16[0] === "t" || str16[0] === "T"),
|
|
2361
2361
|
stringify({ source, value }, ctx) {
|
|
2362
2362
|
if (source && boolTag.test.test(source)) {
|
|
2363
2363
|
const sv = source[0] === "t" || source[0] === "T";
|
|
@@ -2409,7 +2409,7 @@ var require_float = __commonJS({
|
|
|
2409
2409
|
default: true,
|
|
2410
2410
|
tag: "tag:yaml.org,2002:float",
|
|
2411
2411
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2412
|
-
resolve: (
|
|
2412
|
+
resolve: (str16) => str16.slice(-3).toLowerCase() === "nan" ? NaN : str16[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2413
2413
|
stringify: stringifyNumber.stringifyNumber
|
|
2414
2414
|
};
|
|
2415
2415
|
var floatExp = {
|
|
@@ -2418,7 +2418,7 @@ var require_float = __commonJS({
|
|
|
2418
2418
|
tag: "tag:yaml.org,2002:float",
|
|
2419
2419
|
format: "EXP",
|
|
2420
2420
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2421
|
-
resolve: (
|
|
2421
|
+
resolve: (str16) => parseFloat(str16),
|
|
2422
2422
|
stringify(node) {
|
|
2423
2423
|
const num = Number(node.value);
|
|
2424
2424
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2429,11 +2429,11 @@ var require_float = __commonJS({
|
|
|
2429
2429
|
default: true,
|
|
2430
2430
|
tag: "tag:yaml.org,2002:float",
|
|
2431
2431
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
2432
|
-
resolve(
|
|
2433
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2434
|
-
const dot =
|
|
2435
|
-
if (dot !== -1 &&
|
|
2436
|
-
node.minFractionDigits =
|
|
2432
|
+
resolve(str16) {
|
|
2433
|
+
const node = new Scalar.Scalar(parseFloat(str16));
|
|
2434
|
+
const dot = str16.indexOf(".");
|
|
2435
|
+
if (dot !== -1 && str16[str16.length - 1] === "0")
|
|
2436
|
+
node.minFractionDigits = str16.length - dot - 1;
|
|
2437
2437
|
return node;
|
|
2438
2438
|
},
|
|
2439
2439
|
stringify: stringifyNumber.stringifyNumber
|
|
@@ -2450,7 +2450,7 @@ var require_int = __commonJS({
|
|
|
2450
2450
|
"use strict";
|
|
2451
2451
|
var stringifyNumber = require_stringifyNumber();
|
|
2452
2452
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2453
|
-
var intResolve = (
|
|
2453
|
+
var intResolve = (str16, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str16) : parseInt(str16.substring(offset), radix);
|
|
2454
2454
|
function intStringify(node, radix, prefix) {
|
|
2455
2455
|
const { value } = node;
|
|
2456
2456
|
if (intIdentify(value) && value >= 0)
|
|
@@ -2463,7 +2463,7 @@ var require_int = __commonJS({
|
|
|
2463
2463
|
tag: "tag:yaml.org,2002:int",
|
|
2464
2464
|
format: "OCT",
|
|
2465
2465
|
test: /^0o[0-7]+$/,
|
|
2466
|
-
resolve: (
|
|
2466
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 2, 8, opt),
|
|
2467
2467
|
stringify: (node) => intStringify(node, 8, "0o")
|
|
2468
2468
|
};
|
|
2469
2469
|
var int2 = {
|
|
@@ -2471,7 +2471,7 @@ var require_int = __commonJS({
|
|
|
2471
2471
|
default: true,
|
|
2472
2472
|
tag: "tag:yaml.org,2002:int",
|
|
2473
2473
|
test: /^[-+]?[0-9]+$/,
|
|
2474
|
-
resolve: (
|
|
2474
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 0, 10, opt),
|
|
2475
2475
|
stringify: stringifyNumber.stringifyNumber
|
|
2476
2476
|
};
|
|
2477
2477
|
var intHex = {
|
|
@@ -2480,7 +2480,7 @@ var require_int = __commonJS({
|
|
|
2480
2480
|
tag: "tag:yaml.org,2002:int",
|
|
2481
2481
|
format: "HEX",
|
|
2482
2482
|
test: /^0x[0-9a-fA-F]+$/,
|
|
2483
|
-
resolve: (
|
|
2483
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 2, 16, opt),
|
|
2484
2484
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2485
2485
|
};
|
|
2486
2486
|
exports.int = int2;
|
|
@@ -2533,7 +2533,7 @@ var require_schema2 = __commonJS({
|
|
|
2533
2533
|
identify: (value) => typeof value === "string",
|
|
2534
2534
|
default: true,
|
|
2535
2535
|
tag: "tag:yaml.org,2002:str",
|
|
2536
|
-
resolve: (
|
|
2536
|
+
resolve: (str16) => str16,
|
|
2537
2537
|
stringify: stringifyJSON
|
|
2538
2538
|
},
|
|
2539
2539
|
{
|
|
@@ -2550,7 +2550,7 @@ var require_schema2 = __commonJS({
|
|
|
2550
2550
|
default: true,
|
|
2551
2551
|
tag: "tag:yaml.org,2002:bool",
|
|
2552
2552
|
test: /^true$|^false$/,
|
|
2553
|
-
resolve: (
|
|
2553
|
+
resolve: (str16) => str16 === "true",
|
|
2554
2554
|
stringify: stringifyJSON
|
|
2555
2555
|
},
|
|
2556
2556
|
{
|
|
@@ -2558,7 +2558,7 @@ var require_schema2 = __commonJS({
|
|
|
2558
2558
|
default: true,
|
|
2559
2559
|
tag: "tag:yaml.org,2002:int",
|
|
2560
2560
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
2561
|
-
resolve: (
|
|
2561
|
+
resolve: (str16, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str16) : parseInt(str16, 10),
|
|
2562
2562
|
stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value)
|
|
2563
2563
|
},
|
|
2564
2564
|
{
|
|
@@ -2566,7 +2566,7 @@ var require_schema2 = __commonJS({
|
|
|
2566
2566
|
default: true,
|
|
2567
2567
|
tag: "tag:yaml.org,2002:float",
|
|
2568
2568
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
2569
|
-
resolve: (
|
|
2569
|
+
resolve: (str16) => parseFloat(str16),
|
|
2570
2570
|
stringify: stringifyJSON
|
|
2571
2571
|
}
|
|
2572
2572
|
];
|
|
@@ -2574,9 +2574,9 @@ var require_schema2 = __commonJS({
|
|
|
2574
2574
|
default: true,
|
|
2575
2575
|
tag: "",
|
|
2576
2576
|
test: /^/,
|
|
2577
|
-
resolve(
|
|
2578
|
-
onError(`Unresolved plain scalar ${JSON.stringify(
|
|
2579
|
-
return
|
|
2577
|
+
resolve(str16, onError) {
|
|
2578
|
+
onError(`Unresolved plain scalar ${JSON.stringify(str16)}`);
|
|
2579
|
+
return str16;
|
|
2580
2580
|
}
|
|
2581
2581
|
};
|
|
2582
2582
|
var schema = [map.map, seq.seq].concat(jsonScalars, jsonError);
|
|
@@ -2608,10 +2608,10 @@ var require_binary = __commonJS({
|
|
|
2608
2608
|
if (typeof node_buffer.Buffer === "function") {
|
|
2609
2609
|
return node_buffer.Buffer.from(src, "base64");
|
|
2610
2610
|
} else if (typeof atob === "function") {
|
|
2611
|
-
const
|
|
2612
|
-
const buffer = new Uint8Array(
|
|
2613
|
-
for (let i = 0; i <
|
|
2614
|
-
buffer[i] =
|
|
2611
|
+
const str16 = atob(src.replace(/[\n\r]/g, ""));
|
|
2612
|
+
const buffer = new Uint8Array(str16.length);
|
|
2613
|
+
for (let i = 0; i < str16.length; ++i)
|
|
2614
|
+
buffer[i] = str16.charCodeAt(i);
|
|
2615
2615
|
return buffer;
|
|
2616
2616
|
} else {
|
|
2617
2617
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -2622,28 +2622,28 @@ var require_binary = __commonJS({
|
|
|
2622
2622
|
if (!value)
|
|
2623
2623
|
return "";
|
|
2624
2624
|
const buf = value;
|
|
2625
|
-
let
|
|
2625
|
+
let str16;
|
|
2626
2626
|
if (typeof node_buffer.Buffer === "function") {
|
|
2627
|
-
|
|
2627
|
+
str16 = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
2628
2628
|
} else if (typeof btoa === "function") {
|
|
2629
2629
|
let s = "";
|
|
2630
2630
|
for (let i = 0; i < buf.length; ++i)
|
|
2631
2631
|
s += String.fromCharCode(buf[i]);
|
|
2632
|
-
|
|
2632
|
+
str16 = btoa(s);
|
|
2633
2633
|
} else {
|
|
2634
2634
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
2635
2635
|
}
|
|
2636
2636
|
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
|
|
2637
2637
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
2638
2638
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2639
|
-
const n = Math.ceil(
|
|
2639
|
+
const n = Math.ceil(str16.length / lineWidth);
|
|
2640
2640
|
const lines = new Array(n);
|
|
2641
2641
|
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
2642
|
-
lines[i] =
|
|
2642
|
+
lines[i] = str16.substr(o, lineWidth);
|
|
2643
2643
|
}
|
|
2644
|
-
|
|
2644
|
+
str16 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
2645
2645
|
}
|
|
2646
|
-
return stringifyString.stringifyString({ comment, type, value:
|
|
2646
|
+
return stringifyString.stringifyString({ comment, type, value: str16 }, ctx, onComment, onChompKeep);
|
|
2647
2647
|
}
|
|
2648
2648
|
};
|
|
2649
2649
|
exports.binary = binary;
|
|
@@ -2849,7 +2849,7 @@ var require_float2 = __commonJS({
|
|
|
2849
2849
|
default: true,
|
|
2850
2850
|
tag: "tag:yaml.org,2002:float",
|
|
2851
2851
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2852
|
-
resolve: (
|
|
2852
|
+
resolve: (str16) => str16.slice(-3).toLowerCase() === "nan" ? NaN : str16[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2853
2853
|
stringify: stringifyNumber.stringifyNumber
|
|
2854
2854
|
};
|
|
2855
2855
|
var floatExp = {
|
|
@@ -2858,7 +2858,7 @@ var require_float2 = __commonJS({
|
|
|
2858
2858
|
tag: "tag:yaml.org,2002:float",
|
|
2859
2859
|
format: "EXP",
|
|
2860
2860
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2861
|
-
resolve: (
|
|
2861
|
+
resolve: (str16) => parseFloat(str16.replace(/_/g, "")),
|
|
2862
2862
|
stringify(node) {
|
|
2863
2863
|
const num = Number(node.value);
|
|
2864
2864
|
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
@@ -2869,11 +2869,11 @@ var require_float2 = __commonJS({
|
|
|
2869
2869
|
default: true,
|
|
2870
2870
|
tag: "tag:yaml.org,2002:float",
|
|
2871
2871
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
2872
|
-
resolve(
|
|
2873
|
-
const node = new Scalar.Scalar(parseFloat(
|
|
2874
|
-
const dot =
|
|
2872
|
+
resolve(str16) {
|
|
2873
|
+
const node = new Scalar.Scalar(parseFloat(str16.replace(/_/g, "")));
|
|
2874
|
+
const dot = str16.indexOf(".");
|
|
2875
2875
|
if (dot !== -1) {
|
|
2876
|
-
const f =
|
|
2876
|
+
const f = str16.substring(dot + 1).replace(/_/g, "");
|
|
2877
2877
|
if (f[f.length - 1] === "0")
|
|
2878
2878
|
node.minFractionDigits = f.length;
|
|
2879
2879
|
}
|
|
@@ -2893,34 +2893,34 @@ var require_int2 = __commonJS({
|
|
|
2893
2893
|
"use strict";
|
|
2894
2894
|
var stringifyNumber = require_stringifyNumber();
|
|
2895
2895
|
var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2896
|
-
function intResolve(
|
|
2897
|
-
const sign =
|
|
2896
|
+
function intResolve(str16, offset, radix, { intAsBigInt }) {
|
|
2897
|
+
const sign = str16[0];
|
|
2898
2898
|
if (sign === "-" || sign === "+")
|
|
2899
2899
|
offset += 1;
|
|
2900
|
-
|
|
2900
|
+
str16 = str16.substring(offset).replace(/_/g, "");
|
|
2901
2901
|
if (intAsBigInt) {
|
|
2902
2902
|
switch (radix) {
|
|
2903
2903
|
case 2:
|
|
2904
|
-
|
|
2904
|
+
str16 = `0b${str16}`;
|
|
2905
2905
|
break;
|
|
2906
2906
|
case 8:
|
|
2907
|
-
|
|
2907
|
+
str16 = `0o${str16}`;
|
|
2908
2908
|
break;
|
|
2909
2909
|
case 16:
|
|
2910
|
-
|
|
2910
|
+
str16 = `0x${str16}`;
|
|
2911
2911
|
break;
|
|
2912
2912
|
}
|
|
2913
|
-
const n2 = BigInt(
|
|
2913
|
+
const n2 = BigInt(str16);
|
|
2914
2914
|
return sign === "-" ? BigInt(-1) * n2 : n2;
|
|
2915
2915
|
}
|
|
2916
|
-
const n = parseInt(
|
|
2916
|
+
const n = parseInt(str16, radix);
|
|
2917
2917
|
return sign === "-" ? -1 * n : n;
|
|
2918
2918
|
}
|
|
2919
2919
|
function intStringify(node, radix, prefix) {
|
|
2920
2920
|
const { value } = node;
|
|
2921
2921
|
if (intIdentify(value)) {
|
|
2922
|
-
const
|
|
2923
|
-
return value < 0 ? "-" + prefix +
|
|
2922
|
+
const str16 = value.toString(radix);
|
|
2923
|
+
return value < 0 ? "-" + prefix + str16.substr(1) : prefix + str16;
|
|
2924
2924
|
}
|
|
2925
2925
|
return stringifyNumber.stringifyNumber(node);
|
|
2926
2926
|
}
|
|
@@ -2930,7 +2930,7 @@ var require_int2 = __commonJS({
|
|
|
2930
2930
|
tag: "tag:yaml.org,2002:int",
|
|
2931
2931
|
format: "BIN",
|
|
2932
2932
|
test: /^[-+]?0b[0-1_]+$/,
|
|
2933
|
-
resolve: (
|
|
2933
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 2, 2, opt),
|
|
2934
2934
|
stringify: (node) => intStringify(node, 2, "0b")
|
|
2935
2935
|
};
|
|
2936
2936
|
var intOct = {
|
|
@@ -2939,7 +2939,7 @@ var require_int2 = __commonJS({
|
|
|
2939
2939
|
tag: "tag:yaml.org,2002:int",
|
|
2940
2940
|
format: "OCT",
|
|
2941
2941
|
test: /^[-+]?0[0-7_]+$/,
|
|
2942
|
-
resolve: (
|
|
2942
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 1, 8, opt),
|
|
2943
2943
|
stringify: (node) => intStringify(node, 8, "0")
|
|
2944
2944
|
};
|
|
2945
2945
|
var int2 = {
|
|
@@ -2947,7 +2947,7 @@ var require_int2 = __commonJS({
|
|
|
2947
2947
|
default: true,
|
|
2948
2948
|
tag: "tag:yaml.org,2002:int",
|
|
2949
2949
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
2950
|
-
resolve: (
|
|
2950
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 0, 10, opt),
|
|
2951
2951
|
stringify: stringifyNumber.stringifyNumber
|
|
2952
2952
|
};
|
|
2953
2953
|
var intHex = {
|
|
@@ -2956,7 +2956,7 @@ var require_int2 = __commonJS({
|
|
|
2956
2956
|
tag: "tag:yaml.org,2002:int",
|
|
2957
2957
|
format: "HEX",
|
|
2958
2958
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
2959
|
-
resolve: (
|
|
2959
|
+
resolve: (str16, _onError, opt) => intResolve(str16, 2, 16, opt),
|
|
2960
2960
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2961
2961
|
};
|
|
2962
2962
|
exports.int = int2;
|
|
@@ -3060,9 +3060,9 @@ var require_timestamp = __commonJS({
|
|
|
3060
3060
|
"node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
|
|
3061
3061
|
"use strict";
|
|
3062
3062
|
var stringifyNumber = require_stringifyNumber();
|
|
3063
|
-
function parseSexagesimal(
|
|
3064
|
-
const sign =
|
|
3065
|
-
const parts = sign === "-" || sign === "+" ?
|
|
3063
|
+
function parseSexagesimal(str16, asBigInt) {
|
|
3064
|
+
const sign = str16[0];
|
|
3065
|
+
const parts = sign === "-" || sign === "+" ? str16.substring(1) : str16;
|
|
3066
3066
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
3067
3067
|
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
|
|
3068
3068
|
return sign === "-" ? num(-1) * res : res;
|
|
@@ -3099,7 +3099,7 @@ var require_timestamp = __commonJS({
|
|
|
3099
3099
|
tag: "tag:yaml.org,2002:int",
|
|
3100
3100
|
format: "TIME",
|
|
3101
3101
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
3102
|
-
resolve: (
|
|
3102
|
+
resolve: (str16, _onError, { intAsBigInt }) => parseSexagesimal(str16, intAsBigInt),
|
|
3103
3103
|
stringify: stringifySexagesimal
|
|
3104
3104
|
};
|
|
3105
3105
|
var floatTime = {
|
|
@@ -3108,7 +3108,7 @@ var require_timestamp = __commonJS({
|
|
|
3108
3108
|
tag: "tag:yaml.org,2002:float",
|
|
3109
3109
|
format: "TIME",
|
|
3110
3110
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
3111
|
-
resolve: (
|
|
3111
|
+
resolve: (str16) => parseSexagesimal(str16, false),
|
|
3112
3112
|
stringify: stringifySexagesimal
|
|
3113
3113
|
};
|
|
3114
3114
|
var timestamp = {
|
|
@@ -3119,8 +3119,8 @@ var require_timestamp = __commonJS({
|
|
|
3119
3119
|
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
3120
3120
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
3121
3121
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
3122
|
-
resolve(
|
|
3123
|
-
const match =
|
|
3122
|
+
resolve(str16) {
|
|
3123
|
+
const match = str16.match(timestamp.test);
|
|
3124
3124
|
if (!match)
|
|
3125
3125
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
3126
3126
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -3471,9 +3471,9 @@ var require_Document = __commonJS({
|
|
|
3471
3471
|
this.contents.add(value);
|
|
3472
3472
|
}
|
|
3473
3473
|
/** Adds a value to the document. */
|
|
3474
|
-
addIn(
|
|
3474
|
+
addIn(path106, value) {
|
|
3475
3475
|
if (assertCollection(this.contents))
|
|
3476
|
-
this.contents.addIn(
|
|
3476
|
+
this.contents.addIn(path106, 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(path106) {
|
|
3552
|
+
if (Collection.isEmptyPath(path106)) {
|
|
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(path106) : 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(path106, keepScalar) {
|
|
3574
|
+
if (Collection.isEmptyPath(path106))
|
|
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(path106, 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(path106) {
|
|
3588
|
+
if (Collection.isEmptyPath(path106))
|
|
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(path106) : 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(path106, value) {
|
|
3608
|
+
if (Collection.isEmptyPath(path106)) {
|
|
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(path106), value);
|
|
3612
3612
|
} else if (assertCollection(this.contents)) {
|
|
3613
|
-
this.contents.setIn(
|
|
3613
|
+
this.contents.setIn(path106, 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, path106) => {
|
|
5574
5574
|
let item = cst;
|
|
5575
|
-
for (const [field, index] of
|
|
5575
|
+
for (const [field, index] of path106) {
|
|
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, path106) => {
|
|
5585
|
+
const parent = visit.itemAtPath(cst, path106.slice(0, -1));
|
|
5586
|
+
const field = path106[path106.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(path106, item, visitor) {
|
|
5593
|
+
let ctrl = visitor(item, path106);
|
|
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(path106.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, path106);
|
|
5612
5612
|
}
|
|
5613
5613
|
}
|
|
5614
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5614
|
+
return typeof ctrl === "function" ? ctrl(item, path106) : 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 fs103 = this.flowScalar(this.type);
|
|
6917
6917
|
if (atNextItem || it.value) {
|
|
6918
|
-
map.items.push({ start, key:
|
|
6918
|
+
map.items.push({ start, key: fs103, sep: [] });
|
|
6919
6919
|
this.onKeyLine = true;
|
|
6920
6920
|
} else if (it.sep) {
|
|
6921
|
-
this.stack.push(
|
|
6921
|
+
this.stack.push(fs103);
|
|
6922
6922
|
} else {
|
|
6923
|
-
Object.assign(it, { key:
|
|
6923
|
+
Object.assign(it, { key: fs103, 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 fs103 = this.flowScalar(this.type);
|
|
7052
7052
|
if (!it || it.value)
|
|
7053
|
-
fc.items.push({ start: [], key:
|
|
7053
|
+
fc.items.push({ start: [], key: fs103, sep: [] });
|
|
7054
7054
|
else if (it.sep)
|
|
7055
|
-
this.stack.push(
|
|
7055
|
+
this.stack.push(fs103);
|
|
7056
7056
|
else
|
|
7057
|
-
Object.assign(it, { key:
|
|
7057
|
+
Object.assign(it, { key: fs103, sep: [] });
|
|
7058
7058
|
return;
|
|
7059
7059
|
}
|
|
7060
7060
|
case "flow-map-end":
|
|
@@ -7363,16 +7363,16 @@ var require_dist = __commonJS({
|
|
|
7363
7363
|
});
|
|
7364
7364
|
|
|
7365
7365
|
// src/scripts/hooks/dispatch_entry.ts
|
|
7366
|
-
import * as
|
|
7367
|
-
import { fileURLToPath as
|
|
7366
|
+
import * as path105 from "node:path";
|
|
7367
|
+
import { fileURLToPath as fileURLToPath67 } from "node:url";
|
|
7368
7368
|
|
|
7369
7369
|
// src/scripts/hooks/dispatch_hook.ts
|
|
7370
7370
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
7371
|
-
import { spawnSync as
|
|
7372
|
-
import
|
|
7373
|
-
import
|
|
7371
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
7372
|
+
import fs102 from "node:fs";
|
|
7373
|
+
import path104 from "node:path";
|
|
7374
7374
|
import * as tty2 from "node:tty";
|
|
7375
|
-
import { fileURLToPath as
|
|
7375
|
+
import { fileURLToPath as fileURLToPath66, pathToFileURL as pathToFileURL59 } from "node:url";
|
|
7376
7376
|
|
|
7377
7377
|
// src/scripts/_lib/spawn_env.ts
|
|
7378
7378
|
var DENY_EXACT = /* @__PURE__ */ new Set([
|
|
@@ -8243,7 +8243,7 @@ import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL5 } from
|
|
|
8243
8243
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
8244
8244
|
import * as fs9 from "node:fs";
|
|
8245
8245
|
import * as path10 from "node:path";
|
|
8246
|
-
import
|
|
8246
|
+
import process6 from "node:process";
|
|
8247
8247
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
8248
8248
|
import { createRequire as createRequire2 } from "node:module";
|
|
8249
8249
|
|
|
@@ -8692,6 +8692,7 @@ function _pyJsonScalarAscii(value) {
|
|
|
8692
8692
|
}
|
|
8693
8693
|
|
|
8694
8694
|
// src/scripts/_lib/scan_scope.ts
|
|
8695
|
+
import process2 from "node:process";
|
|
8695
8696
|
var DeadScopeError = class extends Error {
|
|
8696
8697
|
gate;
|
|
8697
8698
|
constructor(gate, message) {
|
|
@@ -8713,6 +8714,11 @@ function assertScanned(opts) {
|
|
|
8713
8714
|
`${opts.gate}: scanned 0 ${opts.units} under ${roots} \u2014 the scan scope is dead or the root moved. A gate that read nothing has not passed. Repoint the root (prefer the shared resolver in _lib/agent_src.ts), or declare a justified \`allowEmpty\` reason if an empty corpus is genuinely expected.`
|
|
8714
8715
|
);
|
|
8715
8716
|
}
|
|
8717
|
+
function reportScanned(opts, write = process2.stdout.write.bind(process2.stdout)) {
|
|
8718
|
+
assertScanned(opts);
|
|
8719
|
+
write(`scanned: ${String(opts.scanned)}
|
|
8720
|
+
`);
|
|
8721
|
+
}
|
|
8716
8722
|
|
|
8717
8723
|
// src/scripts/lint_hidden_unicode.ts
|
|
8718
8724
|
var CHECK = "hidden-unicode";
|
|
@@ -9653,11 +9659,11 @@ function stampUserVersion(conn, version) {
|
|
|
9653
9659
|
var import_yaml = __toESM(require_dist(), 1);
|
|
9654
9660
|
import * as fs6 from "node:fs";
|
|
9655
9661
|
import * as path7 from "node:path";
|
|
9656
|
-
import
|
|
9662
|
+
import process4 from "node:process";
|
|
9657
9663
|
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9658
9664
|
|
|
9659
9665
|
// src/scripts/memory_status.ts
|
|
9660
|
-
import
|
|
9666
|
+
import process3 from "node:process";
|
|
9661
9667
|
import * as fs5 from "node:fs";
|
|
9662
9668
|
import * as path6 from "node:path";
|
|
9663
9669
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -9733,8 +9739,8 @@ var _ExitError = class extends Error {
|
|
|
9733
9739
|
code;
|
|
9734
9740
|
};
|
|
9735
9741
|
function _usageError(msg) {
|
|
9736
|
-
|
|
9737
|
-
|
|
9742
|
+
process3.stderr.write(_USAGE);
|
|
9743
|
+
process3.stderr.write(`${_PROG}: error: ${msg}
|
|
9738
9744
|
`);
|
|
9739
9745
|
throw new _ExitError(2);
|
|
9740
9746
|
}
|
|
@@ -9764,7 +9770,7 @@ function _parseArgs(argv) {
|
|
|
9764
9770
|
} else if (a === "--health") {
|
|
9765
9771
|
args.health = true;
|
|
9766
9772
|
} else if (a === "-h" || a === "--help") {
|
|
9767
|
-
|
|
9773
|
+
process3.stdout.write(_USAGE);
|
|
9768
9774
|
throw new _ExitError(0);
|
|
9769
9775
|
} else {
|
|
9770
9776
|
_usageError(`unrecognized arguments: ${a}`);
|
|
@@ -9773,18 +9779,18 @@ function _parseArgs(argv) {
|
|
|
9773
9779
|
return args;
|
|
9774
9780
|
}
|
|
9775
9781
|
function main2() {
|
|
9776
|
-
const args = _parseArgs(
|
|
9782
|
+
const args = _parseArgs(process3.argv.slice(2));
|
|
9777
9783
|
if (args.health) {
|
|
9778
|
-
|
|
9784
|
+
process3.stdout.write(`${_pyJsonDumps(health())}
|
|
9779
9785
|
`);
|
|
9780
9786
|
return 0;
|
|
9781
9787
|
}
|
|
9782
9788
|
const r = status();
|
|
9783
9789
|
if (args.format === "json") {
|
|
9784
|
-
|
|
9790
|
+
process3.stdout.write(`${_pyJsonDumps(r)}
|
|
9785
9791
|
`);
|
|
9786
9792
|
} else {
|
|
9787
|
-
|
|
9793
|
+
process3.stdout.write(` \u2139\uFE0F backend=${r.backend} status=${r.status} reason=${r.reason}
|
|
9788
9794
|
`);
|
|
9789
9795
|
}
|
|
9790
9796
|
return 0;
|
|
@@ -9793,16 +9799,16 @@ function _isCliEntry2() {
|
|
|
9793
9799
|
if (true) {
|
|
9794
9800
|
return false;
|
|
9795
9801
|
}
|
|
9796
|
-
if (
|
|
9802
|
+
if (process3.argv[1] === void 0) {
|
|
9797
9803
|
return false;
|
|
9798
9804
|
}
|
|
9799
|
-
const argvUrl = pathToFileURL2(path6.resolve(
|
|
9805
|
+
const argvUrl = pathToFileURL2(path6.resolve(process3.argv[1])).href;
|
|
9800
9806
|
if (import.meta.url === argvUrl) {
|
|
9801
9807
|
return true;
|
|
9802
9808
|
}
|
|
9803
9809
|
try {
|
|
9804
9810
|
const here = fs5.realpathSync(fileURLToPath3(import.meta.url));
|
|
9805
|
-
const argv = fs5.realpathSync(path6.resolve(
|
|
9811
|
+
const argv = fs5.realpathSync(path6.resolve(process3.argv[1]));
|
|
9806
9812
|
return here === argv;
|
|
9807
9813
|
} catch {
|
|
9808
9814
|
return false;
|
|
@@ -9811,10 +9817,10 @@ function _isCliEntry2() {
|
|
|
9811
9817
|
var _isMain = _isCliEntry2();
|
|
9812
9818
|
if (_isMain) {
|
|
9813
9819
|
try {
|
|
9814
|
-
|
|
9820
|
+
process3.exitCode = main2();
|
|
9815
9821
|
} catch (e) {
|
|
9816
9822
|
if (e instanceof _ExitError) {
|
|
9817
|
-
|
|
9823
|
+
process3.exitCode = e.code;
|
|
9818
9824
|
} else {
|
|
9819
9825
|
throw e;
|
|
9820
9826
|
}
|
|
@@ -10318,7 +10324,7 @@ function _print_text(report2) {
|
|
|
10318
10324
|
out.push(` unknown: ${rm.unknown_modes.join(", ")} (not in the six reserved slugs)`);
|
|
10319
10325
|
}
|
|
10320
10326
|
}
|
|
10321
|
-
|
|
10327
|
+
process4.stdout.write(out.map((line) => `${line}
|
|
10322
10328
|
`).join(""));
|
|
10323
10329
|
}
|
|
10324
10330
|
function _sortedEntries(obj) {
|
|
@@ -10443,10 +10449,10 @@ function _escapeNonAscii2(s) {
|
|
|
10443
10449
|
var _PROG2 = "memory_report.py";
|
|
10444
10450
|
var _USAGE2 = "usage: memory_report.py [-h] [--format {text,json}]\n";
|
|
10445
10451
|
function _argError2(msg) {
|
|
10446
|
-
|
|
10447
|
-
|
|
10452
|
+
process4.stderr.write(_USAGE2);
|
|
10453
|
+
process4.stderr.write(`${_PROG2}: error: ${msg}
|
|
10448
10454
|
`);
|
|
10449
|
-
|
|
10455
|
+
process4.exit(2);
|
|
10450
10456
|
}
|
|
10451
10457
|
function _parseArgs2(argv) {
|
|
10452
10458
|
const args = { format: "text" };
|
|
@@ -10457,8 +10463,8 @@ function _parseArgs2(argv) {
|
|
|
10457
10463
|
} else if (a.startsWith("--format=")) {
|
|
10458
10464
|
args.format = _checkChoice(a.slice("--format=".length), ["text", "json"], "--format");
|
|
10459
10465
|
} else if (a === "-h" || a === "--help") {
|
|
10460
|
-
|
|
10461
|
-
|
|
10466
|
+
process4.stdout.write(_USAGE2);
|
|
10467
|
+
process4.exit(0);
|
|
10462
10468
|
} else {
|
|
10463
10469
|
_argError2(`unrecognized arguments: ${a}`);
|
|
10464
10470
|
}
|
|
@@ -10474,10 +10480,10 @@ function _checkChoice(value, choices, flag) {
|
|
|
10474
10480
|
return value;
|
|
10475
10481
|
}
|
|
10476
10482
|
function main3() {
|
|
10477
|
-
const args = _parseArgs2(
|
|
10483
|
+
const args = _parseArgs2(process4.argv.slice(2));
|
|
10478
10484
|
const report2 = build_report();
|
|
10479
10485
|
if (args.format === "json") {
|
|
10480
|
-
|
|
10486
|
+
process4.stdout.write(`${pyJsonDumps(report2, 2)}
|
|
10481
10487
|
`);
|
|
10482
10488
|
} else {
|
|
10483
10489
|
_print_text(report2);
|
|
@@ -10488,16 +10494,16 @@ function _isCliEntry3() {
|
|
|
10488
10494
|
if (true) {
|
|
10489
10495
|
return false;
|
|
10490
10496
|
}
|
|
10491
|
-
if (
|
|
10497
|
+
if (process4.argv[1] === void 0) {
|
|
10492
10498
|
return false;
|
|
10493
10499
|
}
|
|
10494
|
-
const argvUrl = pathToFileURL3(path7.resolve(
|
|
10500
|
+
const argvUrl = pathToFileURL3(path7.resolve(process4.argv[1])).href;
|
|
10495
10501
|
if (import.meta.url === argvUrl) {
|
|
10496
10502
|
return true;
|
|
10497
10503
|
}
|
|
10498
10504
|
try {
|
|
10499
10505
|
const here = fs6.realpathSync(fileURLToPath4(import.meta.url));
|
|
10500
|
-
const argv = fs6.realpathSync(path7.resolve(
|
|
10506
|
+
const argv = fs6.realpathSync(path7.resolve(process4.argv[1]));
|
|
10501
10507
|
return here === argv;
|
|
10502
10508
|
} catch {
|
|
10503
10509
|
return false;
|
|
@@ -10505,7 +10511,7 @@ function _isCliEntry3() {
|
|
|
10505
10511
|
}
|
|
10506
10512
|
var _isMain2 = _isCliEntry3();
|
|
10507
10513
|
if (_isMain2) {
|
|
10508
|
-
|
|
10514
|
+
process4.exit(main3());
|
|
10509
10515
|
}
|
|
10510
10516
|
|
|
10511
10517
|
// src/scripts/_lib/memory_fts_index.ts
|
|
@@ -10753,7 +10759,7 @@ function queryIndex(indexPath, keys, types) {
|
|
|
10753
10759
|
import { createHash as createHash2 } from "node:crypto";
|
|
10754
10760
|
import * as fs8 from "node:fs";
|
|
10755
10761
|
import * as path9 from "node:path";
|
|
10756
|
-
import
|
|
10762
|
+
import process5 from "node:process";
|
|
10757
10763
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
10758
10764
|
var PROG = "learning_sidecar.ts";
|
|
10759
10765
|
var HALF_LIFE_DAYS = 30;
|
|
@@ -10919,13 +10925,13 @@ function main4(argv) {
|
|
|
10919
10925
|
else if (a === "--write") write = true;
|
|
10920
10926
|
else if (a === "--format") format = argv[++i] ?? "text";
|
|
10921
10927
|
else if (a === "-h" || a === "--help") {
|
|
10922
|
-
|
|
10928
|
+
process5.stdout.write(
|
|
10923
10929
|
`usage: ${PROG} [--intake-dir DIR] [--out-dir DIR] [--now ISO] [--write] [--format text|json]
|
|
10924
10930
|
`
|
|
10925
10931
|
);
|
|
10926
10932
|
return 0;
|
|
10927
10933
|
} else {
|
|
10928
|
-
|
|
10934
|
+
process5.stderr.write(`${PROG}: error: unknown argument ${a}
|
|
10929
10935
|
`);
|
|
10930
10936
|
return 2;
|
|
10931
10937
|
}
|
|
@@ -10937,7 +10943,7 @@ function main4(argv) {
|
|
|
10937
10943
|
try {
|
|
10938
10944
|
sidecar = buildSidecar(intakeDir, nowIso);
|
|
10939
10945
|
} catch (exc) {
|
|
10940
|
-
|
|
10946
|
+
process5.stderr.write(`${PROG}: internal error: ${String(exc)}
|
|
10941
10947
|
`);
|
|
10942
10948
|
return 3;
|
|
10943
10949
|
}
|
|
@@ -10947,20 +10953,20 @@ function main4(argv) {
|
|
|
10947
10953
|
fs8.writeFileSync(path9.join(outDir, LESSONS_NAME), renderLessonsMd(sidecar));
|
|
10948
10954
|
}
|
|
10949
10955
|
if (format === "json") {
|
|
10950
|
-
|
|
10956
|
+
process5.stdout.write(JSON.stringify(sidecar, null, 2) + "\n");
|
|
10951
10957
|
return 0;
|
|
10952
10958
|
}
|
|
10953
10959
|
const byVerdict = { preferred: 0, contested: 0, dead_end: 0 };
|
|
10954
10960
|
for (const l of sidecar.lessons) byVerdict[l.verdict] += 1;
|
|
10955
|
-
|
|
10961
|
+
process5.stdout.write(
|
|
10956
10962
|
`${PROG}: ${sidecar.lessons.length} lesson(s) \u2014 ${byVerdict.preferred} preferred, ${byVerdict.contested} contested, ${byVerdict.dead_end} dead-end${write ? " (written)" : ""}
|
|
10957
10963
|
`
|
|
10958
10964
|
);
|
|
10959
10965
|
return 0;
|
|
10960
10966
|
}
|
|
10961
10967
|
var _bundled = true;
|
|
10962
|
-
if (!_bundled && fileURLToPath5(import.meta.url) === path9.resolve(
|
|
10963
|
-
|
|
10968
|
+
if (!_bundled && fileURLToPath5(import.meta.url) === path9.resolve(process5.argv[1] ?? "")) {
|
|
10969
|
+
process5.exit(main4(process5.argv.slice(2)));
|
|
10964
10970
|
}
|
|
10965
10971
|
|
|
10966
10972
|
// src/scripts/memory_lookup.ts
|
|
@@ -11776,11 +11782,11 @@ function _parseArgs3(argv) {
|
|
|
11776
11782
|
args.tokenBudget = _parseInt(a.slice("--token-budget=".length), "--token-budget");
|
|
11777
11783
|
} else if (a === "-h" || a === "--help") {
|
|
11778
11784
|
_printUsage();
|
|
11779
|
-
|
|
11785
|
+
process6.exit(0);
|
|
11780
11786
|
} else {
|
|
11781
|
-
|
|
11787
|
+
process6.stderr.write(`memory_lookup: error: unrecognized arguments: ${a}
|
|
11782
11788
|
`);
|
|
11783
|
-
|
|
11789
|
+
process6.exit(2);
|
|
11784
11790
|
}
|
|
11785
11791
|
}
|
|
11786
11792
|
return args;
|
|
@@ -11788,34 +11794,34 @@ function _parseArgs3(argv) {
|
|
|
11788
11794
|
function _parseInt(value, flag) {
|
|
11789
11795
|
const n = Number(value);
|
|
11790
11796
|
if (value === void 0 || !Number.isInteger(n)) {
|
|
11791
|
-
|
|
11797
|
+
process6.stderr.write(
|
|
11792
11798
|
`memory_lookup: error: argument ${flag}: invalid int value: '${value ?? ""}'
|
|
11793
11799
|
`
|
|
11794
11800
|
);
|
|
11795
|
-
|
|
11801
|
+
process6.exit(2);
|
|
11796
11802
|
}
|
|
11797
11803
|
return n;
|
|
11798
11804
|
}
|
|
11799
11805
|
function _checkChoice2(value, choices, flag) {
|
|
11800
11806
|
if (value === void 0 || !choices.includes(value)) {
|
|
11801
|
-
|
|
11807
|
+
process6.stderr.write(
|
|
11802
11808
|
`memory_lookup: error: argument ${flag}: invalid choice: '${value ?? ""}' (choose from ${choices.map((c) => `'${c}'`).join(", ")})
|
|
11803
11809
|
`
|
|
11804
11810
|
);
|
|
11805
|
-
|
|
11811
|
+
process6.exit(2);
|
|
11806
11812
|
}
|
|
11807
11813
|
return value;
|
|
11808
11814
|
}
|
|
11809
11815
|
function _printUsage() {
|
|
11810
|
-
|
|
11816
|
+
process6.stdout.write(
|
|
11811
11817
|
"usage: memory_lookup [-h] [--types TYPES] [--key KEY] [--limit LIMIT] [--format {text,json}] [--envelope {legacy,v1}] [--detail {index,full}] [--token-budget N]\n"
|
|
11812
11818
|
);
|
|
11813
11819
|
}
|
|
11814
11820
|
function main5() {
|
|
11815
|
-
const args = _parseArgs3(
|
|
11821
|
+
const args = _parseArgs3(process6.argv.slice(2));
|
|
11816
11822
|
const types = args.types.split(",").map((t) => t.trim()).filter((t) => t);
|
|
11817
11823
|
if (types.length === 0) {
|
|
11818
|
-
|
|
11824
|
+
process6.stderr.write("error: --types is required\n");
|
|
11819
11825
|
return 2;
|
|
11820
11826
|
}
|
|
11821
11827
|
if (args.envelope === "v1") {
|
|
@@ -11824,7 +11830,7 @@ function main5() {
|
|
|
11824
11830
|
opts.token_budget = args.tokenBudget;
|
|
11825
11831
|
}
|
|
11826
11832
|
const envelope = retrieve_v1(types, args.key, args.limit, opts);
|
|
11827
|
-
|
|
11833
|
+
process6.stdout.write(`${pyJsonDumps2(envelope, 2)}
|
|
11828
11834
|
`);
|
|
11829
11835
|
return 0;
|
|
11830
11836
|
}
|
|
@@ -11833,14 +11839,14 @@ function main5() {
|
|
|
11833
11839
|
const payload = {
|
|
11834
11840
|
hits: hits.map((h) => h.as_dict())
|
|
11835
11841
|
};
|
|
11836
|
-
|
|
11842
|
+
process6.stdout.write(`${pyJsonDumps2(payload, 2)}
|
|
11837
11843
|
`);
|
|
11838
11844
|
} else {
|
|
11839
11845
|
if (hits.length === 0) {
|
|
11840
|
-
|
|
11846
|
+
process6.stdout.write(" (no hits)\n");
|
|
11841
11847
|
}
|
|
11842
11848
|
for (const h of hits) {
|
|
11843
|
-
|
|
11849
|
+
process6.stdout.write(
|
|
11844
11850
|
` [${h.source}] ${h.type} score=${_fixed2(h.score)} id=${h.id || "-"} path=${h.path}
|
|
11845
11851
|
`
|
|
11846
11852
|
);
|
|
@@ -12123,16 +12129,16 @@ function _escapeNonAscii3(s) {
|
|
|
12123
12129
|
return out;
|
|
12124
12130
|
}
|
|
12125
12131
|
function _isCliEntry4() {
|
|
12126
|
-
if (
|
|
12132
|
+
if (process6.argv[1] === void 0) {
|
|
12127
12133
|
return false;
|
|
12128
12134
|
}
|
|
12129
|
-
const argvUrl = pathToFileURL4(path10.resolve(
|
|
12135
|
+
const argvUrl = pathToFileURL4(path10.resolve(process6.argv[1])).href;
|
|
12130
12136
|
if (import.meta.url === argvUrl) {
|
|
12131
12137
|
return true;
|
|
12132
12138
|
}
|
|
12133
12139
|
try {
|
|
12134
12140
|
const here = fs9.realpathSync(fileURLToPath6(import.meta.url));
|
|
12135
|
-
const argv = fs9.realpathSync(path10.resolve(
|
|
12141
|
+
const argv = fs9.realpathSync(path10.resolve(process6.argv[1]));
|
|
12136
12142
|
return here === argv;
|
|
12137
12143
|
} catch {
|
|
12138
12144
|
return false;
|
|
@@ -12140,7 +12146,7 @@ function _isCliEntry4() {
|
|
|
12140
12146
|
}
|
|
12141
12147
|
var _isMain3 = _isCliEntry4();
|
|
12142
12148
|
if (_isMain3) {
|
|
12143
|
-
|
|
12149
|
+
process6.exit(main5());
|
|
12144
12150
|
}
|
|
12145
12151
|
|
|
12146
12152
|
// src/scripts/_lib/agent_settings.ts
|
|
@@ -14799,7 +14805,7 @@ import { spawnSync as spawnSync3 } from "node:child_process";
|
|
|
14799
14805
|
import * as fs19 from "node:fs";
|
|
14800
14806
|
import { createRequire as createRequire4 } from "node:module";
|
|
14801
14807
|
import * as path18 from "node:path";
|
|
14802
|
-
import
|
|
14808
|
+
import process7 from "node:process";
|
|
14803
14809
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
14804
14810
|
|
|
14805
14811
|
// src/scripts/_lib/transcript_reads.ts
|
|
@@ -18043,7 +18049,7 @@ function redact_low_impact_entry(text, opts = {}) {
|
|
|
18043
18049
|
var HOT_CONTEXT_REL = path18.join("agents", "runtime", "state", "hot-context.md");
|
|
18044
18050
|
var REPLAY_ENV_VAR3 = "AGENT_CONFIG_REPLAY";
|
|
18045
18051
|
function _is_replay_mode2() {
|
|
18046
|
-
return (
|
|
18052
|
+
return (process7.env[REPLAY_ENV_VAR3] ?? "").trim() === "1";
|
|
18047
18053
|
}
|
|
18048
18054
|
var WORD_CAP = 400;
|
|
18049
18055
|
var MAX_AGE_HOURS = 48;
|
|
@@ -18057,10 +18063,10 @@ var KEY_FACTS_CHARS = 600;
|
|
|
18057
18063
|
var MAX_REREAD_LINES = 3;
|
|
18058
18064
|
var VERIFICATION_RE = /\b(fail(ing|ed|ure)?|error|exit[= ][1-9]|red\b|broken)\b/i;
|
|
18059
18065
|
function _history_path(root) {
|
|
18060
|
-
return
|
|
18066
|
+
return process7.env.AGENT_CHAT_HISTORY_FILE || path18.join(root, HISTORY_REL);
|
|
18061
18067
|
}
|
|
18062
18068
|
function _hot_context_path(root) {
|
|
18063
|
-
return
|
|
18069
|
+
return process7.env.AGENT_HOT_CONTEXT_FILE || path18.join(root, HOT_CONTEXT_REL);
|
|
18064
18070
|
}
|
|
18065
18071
|
function _current_branch(root) {
|
|
18066
18072
|
try {
|
|
@@ -18214,7 +18220,7 @@ function _write_hot_context(root, transcriptPath = null) {
|
|
|
18214
18220
|
const target = _hot_context_path(root);
|
|
18215
18221
|
const text = build_hot_context(root, /* @__PURE__ */ new Date(), transcriptPath);
|
|
18216
18222
|
fs19.mkdirSync(path18.dirname(target), { recursive: true });
|
|
18217
|
-
const tmp = `${target}.tmp-${
|
|
18223
|
+
const tmp = `${target}.tmp-${process7.pid}`;
|
|
18218
18224
|
fs19.writeFileSync(tmp, text, { encoding: "utf-8" });
|
|
18219
18225
|
fs19.renameSync(tmp, target);
|
|
18220
18226
|
}
|
|
@@ -18267,15 +18273,15 @@ function _session_index_block_or_null(root) {
|
|
|
18267
18273
|
const req = createRequire4(import.meta.url);
|
|
18268
18274
|
const mod = req("./session_memory_index.js");
|
|
18269
18275
|
if (!mod.session_index_enabled(root)) return null;
|
|
18270
|
-
const prev =
|
|
18276
|
+
const prev = process7.cwd();
|
|
18271
18277
|
try {
|
|
18272
|
-
|
|
18278
|
+
process7.chdir(root);
|
|
18273
18279
|
return mod.build_session_index_block();
|
|
18274
18280
|
} finally {
|
|
18275
|
-
|
|
18281
|
+
process7.chdir(prev);
|
|
18276
18282
|
}
|
|
18277
18283
|
} catch (exc) {
|
|
18278
|
-
|
|
18284
|
+
process7.stderr.write(`hot-context-hook: session index skipped: ${String(exc)}
|
|
18279
18285
|
`);
|
|
18280
18286
|
return null;
|
|
18281
18287
|
}
|
|
@@ -18296,7 +18302,7 @@ function main7() {
|
|
|
18296
18302
|
} catch {
|
|
18297
18303
|
}
|
|
18298
18304
|
const event = String(envelope.event ?? "");
|
|
18299
|
-
const root = String(envelope.workspace_root ??
|
|
18305
|
+
const root = String(envelope.workspace_root ?? process7.cwd());
|
|
18300
18306
|
const payload = envelope.payload && typeof envelope.payload === "object" && !Array.isArray(envelope.payload) ? envelope.payload : {};
|
|
18301
18307
|
try {
|
|
18302
18308
|
if (_is_replay_mode2()) {
|
|
@@ -18317,7 +18323,7 @@ function main7() {
|
|
|
18317
18323
|
blocks.push(indexBlock);
|
|
18318
18324
|
}
|
|
18319
18325
|
if (blocks.length > 0) {
|
|
18320
|
-
|
|
18326
|
+
process7.stdout.write(
|
|
18321
18327
|
JSON.stringify({
|
|
18322
18328
|
decision: "allow",
|
|
18323
18329
|
reason: decision.action === "inject" ? decision.reason : "memory session index",
|
|
@@ -18327,20 +18333,20 @@ function main7() {
|
|
|
18327
18333
|
}
|
|
18328
18334
|
}
|
|
18329
18335
|
} catch (exc) {
|
|
18330
|
-
|
|
18336
|
+
process7.stderr.write(`hot-context-hook: ${String(exc)}
|
|
18331
18337
|
`);
|
|
18332
18338
|
}
|
|
18333
18339
|
return 0;
|
|
18334
18340
|
}
|
|
18335
18341
|
var _bundled2 = true;
|
|
18336
|
-
if (!_bundled2 && fileURLToPath10(import.meta.url) === path18.resolve(
|
|
18337
|
-
|
|
18342
|
+
if (!_bundled2 && fileURLToPath10(import.meta.url) === path18.resolve(process7.argv[1] ?? "")) {
|
|
18343
|
+
process7.exit(main7());
|
|
18338
18344
|
}
|
|
18339
18345
|
|
|
18340
18346
|
// src/scripts/handoff_context_hook.ts
|
|
18341
18347
|
import * as fs23 from "node:fs";
|
|
18342
18348
|
import * as path22 from "node:path";
|
|
18343
|
-
import
|
|
18349
|
+
import process8 from "node:process";
|
|
18344
18350
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
18345
18351
|
|
|
18346
18352
|
// src/scripts/_lib/envelope_grounding.ts
|
|
@@ -19310,10 +19316,10 @@ var HANDOFF_CONTEXT_REL = path22.join("agents", "runtime", "state", "handoff-con
|
|
|
19310
19316
|
var MAX_AGE_HOURS2 = 48;
|
|
19311
19317
|
var REPLAY_ENV_VAR4 = "AGENT_CONFIG_REPLAY";
|
|
19312
19318
|
function _is_replay_mode3() {
|
|
19313
|
-
return (
|
|
19319
|
+
return (process8.env[REPLAY_ENV_VAR4] ?? "").trim() === "1";
|
|
19314
19320
|
}
|
|
19315
19321
|
function _handoff_context_path(root) {
|
|
19316
|
-
return
|
|
19322
|
+
return process8.env.AGENT_HANDOFF_CONTEXT_FILE || path22.join(root, HANDOFF_CONTEXT_REL);
|
|
19317
19323
|
}
|
|
19318
19324
|
function guardedInjection(block, reason) {
|
|
19319
19325
|
if (!hasBoundaryMarker(block)) {
|
|
@@ -19362,7 +19368,7 @@ function consume_handoff_context(root, now = /* @__PURE__ */ new Date()) {
|
|
|
19362
19368
|
return guardedInjection(block, `handoff consumed (session=${sourceSession})`);
|
|
19363
19369
|
}
|
|
19364
19370
|
function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
|
|
19365
|
-
const target =
|
|
19371
|
+
const target = process8.env.AGENT_RECYCLE_ENVELOPE_FILE || path22.join(root, RECYCLE_ENVELOPE_REL);
|
|
19366
19372
|
let text;
|
|
19367
19373
|
try {
|
|
19368
19374
|
text = fs23.readFileSync(target, "utf-8");
|
|
@@ -19413,7 +19419,7 @@ function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
|
|
|
19413
19419
|
}
|
|
19414
19420
|
const drift = describeDrift(envelope, collectRepoAnchor(root));
|
|
19415
19421
|
const warnings = scanEnvelopeDirectives(envelope);
|
|
19416
|
-
const focus = (
|
|
19422
|
+
const focus = (process8.env.AGENT_RESUME_FOCUS ?? "").trim();
|
|
19417
19423
|
const block = wrapAsPriorSessionData(JSON.stringify(envelope, null, 2), {
|
|
19418
19424
|
kind: "recycle-envelope",
|
|
19419
19425
|
source: RECYCLE_ENVELOPE_REL,
|
|
@@ -19443,7 +19449,7 @@ function main9() {
|
|
|
19443
19449
|
} catch {
|
|
19444
19450
|
}
|
|
19445
19451
|
const event = String(envelope.event ?? "");
|
|
19446
|
-
const root = String(envelope.workspace_root ??
|
|
19452
|
+
const root = String(envelope.workspace_root ?? process8.cwd());
|
|
19447
19453
|
try {
|
|
19448
19454
|
if (_is_replay_mode3()) {
|
|
19449
19455
|
return 0;
|
|
@@ -19462,7 +19468,7 @@ function main9() {
|
|
|
19462
19468
|
reasons.push(handoff.reason);
|
|
19463
19469
|
}
|
|
19464
19470
|
if (blocks.length > 0) {
|
|
19465
|
-
|
|
19471
|
+
process8.stdout.write(
|
|
19466
19472
|
JSON.stringify({
|
|
19467
19473
|
decision: "allow",
|
|
19468
19474
|
reason: reasons.join(" \xB7 "),
|
|
@@ -19472,14 +19478,14 @@ function main9() {
|
|
|
19472
19478
|
}
|
|
19473
19479
|
}
|
|
19474
19480
|
} catch (exc) {
|
|
19475
|
-
|
|
19481
|
+
process8.stderr.write(`handoff-context-hook: ${String(exc)}
|
|
19476
19482
|
`);
|
|
19477
19483
|
}
|
|
19478
19484
|
return 0;
|
|
19479
19485
|
}
|
|
19480
19486
|
var _bundled3 = true;
|
|
19481
|
-
if (!_bundled3 && fileURLToPath12(import.meta.url) === path22.resolve(
|
|
19482
|
-
|
|
19487
|
+
if (!_bundled3 && fileURLToPath12(import.meta.url) === path22.resolve(process8.argv[1] ?? "")) {
|
|
19488
|
+
process8.exit(main9());
|
|
19483
19489
|
}
|
|
19484
19490
|
|
|
19485
19491
|
// src/scripts/roadmap_progress_hook.ts
|
|
@@ -22010,7 +22016,7 @@ import * as path37 from "node:path";
|
|
|
22010
22016
|
// src/scripts/_lib/claude_plugin.ts
|
|
22011
22017
|
import * as os5 from "node:os";
|
|
22012
22018
|
import * as path36 from "node:path";
|
|
22013
|
-
import
|
|
22019
|
+
import process9 from "node:process";
|
|
22014
22020
|
var CLAUDE_PLUGIN_ID = "agent-config";
|
|
22015
22021
|
var CLAUDE_MARKETPLACE_NAME = "event4u-agent-config";
|
|
22016
22022
|
var CLAUDE_MARKETPLACE_REPO = "event4u-app/agent-config";
|
|
@@ -22026,7 +22032,7 @@ var CODEX_PLUGIN_INSTALL_HINT = [
|
|
|
22026
22032
|
`claude plugin install ${CODEX_PLUGIN_ID}@${CODEX_MARKETPLACE_NAME}`
|
|
22027
22033
|
];
|
|
22028
22034
|
function claude_config_dir() {
|
|
22029
|
-
const env = (
|
|
22035
|
+
const env = (process9.env["CLAUDE_CONFIG_DIR"] ?? "").trim();
|
|
22030
22036
|
return env !== "" ? env : path36.join(os5.homedir(), ".claude");
|
|
22031
22037
|
}
|
|
22032
22038
|
|
|
@@ -24393,7 +24399,7 @@ if (isCliEntry9()) {
|
|
|
24393
24399
|
// src/scripts/session_register_hook.ts
|
|
24394
24400
|
import * as fs53 from "node:fs";
|
|
24395
24401
|
import * as path53 from "node:path";
|
|
24396
|
-
import
|
|
24402
|
+
import process10 from "node:process";
|
|
24397
24403
|
import { fileURLToPath as fileURLToPath31 } from "node:url";
|
|
24398
24404
|
|
|
24399
24405
|
// src/scripts/_lib/session_register.ts
|
|
@@ -24680,8 +24686,8 @@ function lockfile_path(env) {
|
|
|
24680
24686
|
}
|
|
24681
24687
|
return write_target("installed.lock", { env: env ?? null });
|
|
24682
24688
|
}
|
|
24683
|
-
function read_lockfile(
|
|
24684
|
-
const target =
|
|
24689
|
+
function read_lockfile(path106) {
|
|
24690
|
+
const target = path106 ?? lockfile_path();
|
|
24685
24691
|
let text;
|
|
24686
24692
|
try {
|
|
24687
24693
|
text = fs51.readFileSync(target, { encoding: "utf-8" });
|
|
@@ -24937,7 +24943,7 @@ function claim_read_paths(workspace_root, session_id) {
|
|
|
24937
24943
|
return out;
|
|
24938
24944
|
}
|
|
24939
24945
|
function _is_replay_mode4() {
|
|
24940
|
-
return String(
|
|
24946
|
+
return String(process10.env[REPLAY_ENV_VAR6] ?? "").trim() !== "";
|
|
24941
24947
|
}
|
|
24942
24948
|
function _read_claim_file(file) {
|
|
24943
24949
|
try {
|
|
@@ -25210,7 +25216,7 @@ function main28() {
|
|
|
25210
25216
|
const payload = envelope["payload"];
|
|
25211
25217
|
const payload_cwd = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload["cwd"] : null;
|
|
25212
25218
|
const root = session_checkout(
|
|
25213
|
-
String(envelope["workspace_root"] ??
|
|
25219
|
+
String(envelope["workspace_root"] ?? process10.cwd()),
|
|
25214
25220
|
typeof payload_cwd === "string" ? payload_cwd : null
|
|
25215
25221
|
);
|
|
25216
25222
|
const platform = String(envelope["platform"] ?? "generic").trim().toLowerCase();
|
|
@@ -25235,13 +25241,13 @@ function main28() {
|
|
|
25235
25241
|
touch(root, session_id, platform, /* @__PURE__ */ new Date());
|
|
25236
25242
|
if (event === "session_start") {
|
|
25237
25243
|
if (!ttl_is_measured(platform)) {
|
|
25238
|
-
|
|
25244
|
+
process10.stderr.write(
|
|
25239
25245
|
`session-register: no measured turn cadence for platform "${platform}"; falling back to the conservative default TTL of ${Math.round(ttl_seconds_for(platform) / 3600)}h. A claim from this session may be held slightly too long after a crash \u2014 never released early.
|
|
25240
25246
|
`
|
|
25241
25247
|
);
|
|
25242
25248
|
}
|
|
25243
25249
|
if (!HEARTBEAT_REACHABLE_PLATFORMS.has(platform)) {
|
|
25244
|
-
|
|
25250
|
+
process10.stderr.write(
|
|
25245
25251
|
`session-register: platform "${platform}" has no reliably firing per-turn slot; this session will expire from the register after its TTL even while active.
|
|
25246
25252
|
`
|
|
25247
25253
|
);
|
|
@@ -25256,7 +25262,7 @@ function main28() {
|
|
|
25256
25262
|
if (event === "session_start") {
|
|
25257
25263
|
const block = foreign_sessions_block(root, session_id, /* @__PURE__ */ new Date());
|
|
25258
25264
|
if (block !== null) {
|
|
25259
|
-
|
|
25265
|
+
process10.stdout.write(
|
|
25260
25266
|
JSON.stringify({
|
|
25261
25267
|
decision: "allow",
|
|
25262
25268
|
reason: "live foreign sessions on this repository",
|
|
@@ -25267,14 +25273,14 @@ function main28() {
|
|
|
25267
25273
|
}
|
|
25268
25274
|
}
|
|
25269
25275
|
} catch (exc) {
|
|
25270
|
-
|
|
25276
|
+
process10.stderr.write(`session-register: ${String(exc)}
|
|
25271
25277
|
`);
|
|
25272
25278
|
}
|
|
25273
25279
|
return 0;
|
|
25274
25280
|
}
|
|
25275
25281
|
var _bundled4 = true;
|
|
25276
|
-
if (!_bundled4 && fileURLToPath31(import.meta.url) === path53.resolve(
|
|
25277
|
-
|
|
25282
|
+
if (!_bundled4 && fileURLToPath31(import.meta.url) === path53.resolve(process10.argv[1] ?? "")) {
|
|
25283
|
+
process10.exit(main28());
|
|
25278
25284
|
}
|
|
25279
25285
|
|
|
25280
25286
|
// src/scripts/language_mirror_hook.ts
|
|
@@ -25298,6 +25304,43 @@ function humanAuthoredLead(text) {
|
|
|
25298
25304
|
}
|
|
25299
25305
|
return kept.join("\n");
|
|
25300
25306
|
}
|
|
25307
|
+
var REGION_OPEN = /^\s*<([A-Za-z][\w-]*)>\s*$/;
|
|
25308
|
+
var REGION_NOTE = /\b(content (above|below) is from|treat (it|this|that|the (content|text|above|following)) as data)\b/i;
|
|
25309
|
+
function stripInjectedRegions(text) {
|
|
25310
|
+
const lines = text.split("\n");
|
|
25311
|
+
const kept = [];
|
|
25312
|
+
for (let i = 0; i < lines.length; i++) {
|
|
25313
|
+
const line = lines[i] ?? "";
|
|
25314
|
+
const open = REGION_OPEN.exec(line);
|
|
25315
|
+
if (open === null) {
|
|
25316
|
+
kept.push(line);
|
|
25317
|
+
continue;
|
|
25318
|
+
}
|
|
25319
|
+
const close = new RegExp(`^\\s*</${open[1] ?? ""}>\\s*$`);
|
|
25320
|
+
let end = -1;
|
|
25321
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
25322
|
+
if (close.test(lines[j] ?? "")) {
|
|
25323
|
+
end = j;
|
|
25324
|
+
break;
|
|
25325
|
+
}
|
|
25326
|
+
}
|
|
25327
|
+
if (end === -1) {
|
|
25328
|
+
kept.push(line);
|
|
25329
|
+
continue;
|
|
25330
|
+
}
|
|
25331
|
+
if (kept.length > 0 && REGION_NOTE.test(kept[kept.length - 1] ?? "")) {
|
|
25332
|
+
kept.pop();
|
|
25333
|
+
}
|
|
25334
|
+
i = end;
|
|
25335
|
+
while (i + 1 < lines.length && (lines[i + 1] ?? "").trim() !== "") {
|
|
25336
|
+
if (!REGION_NOTE.test(lines[i + 1] ?? "")) {
|
|
25337
|
+
break;
|
|
25338
|
+
}
|
|
25339
|
+
i++;
|
|
25340
|
+
}
|
|
25341
|
+
}
|
|
25342
|
+
return kept.join("\n");
|
|
25343
|
+
}
|
|
25301
25344
|
|
|
25302
25345
|
// src/scripts/language_mirror_hook.ts
|
|
25303
25346
|
var EXIT_ALLOW9 = 0;
|
|
@@ -25344,7 +25387,7 @@ function instructionText(prompt) {
|
|
|
25344
25387
|
return kept.join("\n");
|
|
25345
25388
|
}
|
|
25346
25389
|
function classify(prompt) {
|
|
25347
|
-
const text = instructionText(prompt);
|
|
25390
|
+
const text = instructionText(stripInjectedRegions(prompt));
|
|
25348
25391
|
const lead = humanAuthoredLead(text);
|
|
25349
25392
|
const leadVerdict = _score2(lead);
|
|
25350
25393
|
if (leadVerdict.language !== "und") {
|
|
@@ -27169,15 +27212,15 @@ function targets_kernel_rule(filePath) {
|
|
|
27169
27212
|
if (segments.length === 0) {
|
|
27170
27213
|
return null;
|
|
27171
27214
|
}
|
|
27172
|
-
const
|
|
27173
|
-
if (!is_kernel_rule(
|
|
27215
|
+
const basename12 = segments[segments.length - 1];
|
|
27216
|
+
if (!is_kernel_rule(basename12)) {
|
|
27174
27217
|
return null;
|
|
27175
27218
|
}
|
|
27176
27219
|
const dirSegments = segments.slice(0, -1);
|
|
27177
27220
|
if (!dirSegments.includes("rules")) {
|
|
27178
27221
|
return null;
|
|
27179
27222
|
}
|
|
27180
|
-
return
|
|
27223
|
+
return basename12.replace(/\.md$/, "");
|
|
27181
27224
|
}
|
|
27182
27225
|
var _MUTATOR_VERBS = /* @__PURE__ */ new Set([
|
|
27183
27226
|
"sed",
|
|
@@ -30406,7 +30449,7 @@ import path74 from "node:path";
|
|
|
30406
30449
|
import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL42 } from "node:url";
|
|
30407
30450
|
|
|
30408
30451
|
// src/scripts/_lib/host_capability.ts
|
|
30409
|
-
import
|
|
30452
|
+
import process11 from "node:process";
|
|
30410
30453
|
var SAFE_DEFAULT = {
|
|
30411
30454
|
schema_version: 1,
|
|
30412
30455
|
subagent_spawn: false,
|
|
@@ -30449,7 +30492,7 @@ function resolveHostCapabilities(hostId, override) {
|
|
|
30449
30492
|
}
|
|
30450
30493
|
function probeHostCapabilities(hostId) {
|
|
30451
30494
|
const base = resolveHostCapabilities(hostId);
|
|
30452
|
-
const flag =
|
|
30495
|
+
const flag = process11.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
|
|
30453
30496
|
const probedAgentTeams = typeof flag === "string" && flag !== "";
|
|
30454
30497
|
return { ...base, agent_teams: base.agent_teams || probedAgentTeams };
|
|
30455
30498
|
}
|
|
@@ -31666,7 +31709,7 @@ if (_isCliEntry37()) {
|
|
|
31666
31709
|
// src/scripts/hooks/rule_inject_hook.ts
|
|
31667
31710
|
import * as fs79 from "node:fs";
|
|
31668
31711
|
import * as path79 from "node:path";
|
|
31669
|
-
import
|
|
31712
|
+
import process12 from "node:process";
|
|
31670
31713
|
import { fileURLToPath as fileURLToPath51, pathToFileURL as pathToFileURL45 } from "node:url";
|
|
31671
31714
|
|
|
31672
31715
|
// src/scripts/_lib/lean_projection_mode.ts
|
|
@@ -31918,13 +31961,19 @@ function loadRuleBody(repoRoot, id) {
|
|
|
31918
31961
|
function bytesOf(text) {
|
|
31919
31962
|
return Buffer.byteLength(text, "utf8");
|
|
31920
31963
|
}
|
|
31921
|
-
function selectForInjection(repoRoot, matches, capBytes) {
|
|
31964
|
+
function selectForInjection(repoRoot, matches, capBytes, shortlist) {
|
|
31922
31965
|
const bodyBytes2 = /* @__PURE__ */ new Map();
|
|
31923
31966
|
for (const m of matches) {
|
|
31924
31967
|
const body = loadRuleBody(repoRoot, m.id);
|
|
31925
31968
|
bodyBytes2.set(m.id, body === null ? 0 : bytesOf(body));
|
|
31926
31969
|
}
|
|
31927
|
-
const
|
|
31970
|
+
const rank2 = /* @__PURE__ */ new Map();
|
|
31971
|
+
for (const [i, id] of (shortlist ?? []).entries()) {
|
|
31972
|
+
if (!rank2.has(id)) rank2.set(id, i);
|
|
31973
|
+
}
|
|
31974
|
+
const ranked = [...matches].sort(
|
|
31975
|
+
(a, b) => b.score - a.score || (rank2.get(a.id) ?? Infinity) - (rank2.get(b.id) ?? Infinity) || a.order - b.order
|
|
31976
|
+
);
|
|
31928
31977
|
const selected = [];
|
|
31929
31978
|
const dropped = [];
|
|
31930
31979
|
let total = 0;
|
|
@@ -31958,7 +32007,7 @@ function str5(o, ...keys) {
|
|
|
31958
32007
|
return null;
|
|
31959
32008
|
}
|
|
31960
32009
|
function workspaceRoot2(env) {
|
|
31961
|
-
return str5(env, "workspace", "cwd", "project_dir") ??
|
|
32010
|
+
return str5(env, "workspace", "cwd", "project_dir") ?? process12.cwd();
|
|
31962
32011
|
}
|
|
31963
32012
|
function statePath(root, session) {
|
|
31964
32013
|
const safe = session.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 80) || "unknown";
|
|
@@ -32026,9 +32075,9 @@ ${body.trim()}
|
|
|
32026
32075
|
function gateOpen(root, cliEntry) {
|
|
32027
32076
|
if (deliversBodies(normalizeLeanProjectionMode(leanProjectionModeRaw(root)))) return true;
|
|
32028
32077
|
if (hookSectionEnabled(root, "rule_inject")) return true;
|
|
32029
|
-
return cliEntry &&
|
|
32078
|
+
return cliEntry && process12.env["AGENT_CONFIG_REPLAY"] !== "1";
|
|
32030
32079
|
}
|
|
32031
|
-
function main50(argv =
|
|
32080
|
+
function main50(argv = process12.argv.slice(2)) {
|
|
32032
32081
|
let eventOverride = null;
|
|
32033
32082
|
for (let i = 0; i < argv.length; i += 1) {
|
|
32034
32083
|
if (argv[i] === "--event") {
|
|
@@ -32074,7 +32123,7 @@ function main50(argv = process11.argv.slice(2)) {
|
|
|
32074
32123
|
if (injection === null) return EXIT_ALLOW24;
|
|
32075
32124
|
for (const id of injection.rules) seen.add(id);
|
|
32076
32125
|
writeSeen(root, session, seen);
|
|
32077
|
-
|
|
32126
|
+
process12.stdout.write(
|
|
32078
32127
|
`${JSON.stringify({
|
|
32079
32128
|
decision: "warn",
|
|
32080
32129
|
reason: `rule-inject: ${injection.rules.length} rule body/bodies on ${slot} (${injection.bytes} B)`,
|
|
@@ -32086,17 +32135,17 @@ function main50(argv = process11.argv.slice(2)) {
|
|
|
32086
32135
|
}
|
|
32087
32136
|
function _isCliEntry38() {
|
|
32088
32137
|
if (true) return false;
|
|
32089
|
-
if (
|
|
32090
|
-
const argvUrl = pathToFileURL45(path79.resolve(
|
|
32138
|
+
if (process12.argv[1] === void 0) return false;
|
|
32139
|
+
const argvUrl = pathToFileURL45(path79.resolve(process12.argv[1])).href;
|
|
32091
32140
|
if (import.meta.url === argvUrl) return true;
|
|
32092
32141
|
try {
|
|
32093
|
-
return fs79.realpathSync(fileURLToPath51(import.meta.url)) === fs79.realpathSync(path79.resolve(
|
|
32142
|
+
return fs79.realpathSync(fileURLToPath51(import.meta.url)) === fs79.realpathSync(path79.resolve(process12.argv[1]));
|
|
32094
32143
|
} catch {
|
|
32095
32144
|
return false;
|
|
32096
32145
|
}
|
|
32097
32146
|
}
|
|
32098
32147
|
if (_isCliEntry38()) {
|
|
32099
|
-
|
|
32148
|
+
process12.exit(main50());
|
|
32100
32149
|
}
|
|
32101
32150
|
|
|
32102
32151
|
// src/scripts/hooks/end_review_nudge_hook.ts
|
|
@@ -32164,8 +32213,8 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
|
32164
32213
|
try {
|
|
32165
32214
|
const realHome = fs80.realpathSync(homeDir);
|
|
32166
32215
|
const realPath = fs80.realpathSync(rawPath);
|
|
32167
|
-
const
|
|
32168
|
-
if (
|
|
32216
|
+
const relative11 = path80.relative(realHome, realPath);
|
|
32217
|
+
if (relative11 === "" || relative11.startsWith("..") || path80.isAbsolute(relative11)) {
|
|
32169
32218
|
return false;
|
|
32170
32219
|
}
|
|
32171
32220
|
const { size } = fs80.statSync(realPath);
|
|
@@ -33488,13 +33537,747 @@ if (_isCliEntry42()) {
|
|
|
33488
33537
|
process.exit(main54());
|
|
33489
33538
|
}
|
|
33490
33539
|
|
|
33491
|
-
// src/scripts/hooks/
|
|
33492
|
-
import * as
|
|
33540
|
+
// src/scripts/hooks/comment_discipline_hook.ts
|
|
33541
|
+
import * as fs85 from "node:fs";
|
|
33542
|
+
import * as path86 from "node:path";
|
|
33543
|
+
import { fileURLToPath as fileURLToPath57, pathToFileURL as pathToFileURL50 } from "node:url";
|
|
33544
|
+
|
|
33545
|
+
// src/scripts/lint_code_comments.ts
|
|
33546
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
33493
33547
|
import * as fs84 from "node:fs";
|
|
33548
|
+
import * as os11 from "node:os";
|
|
33549
|
+
import * as path85 from "node:path";
|
|
33550
|
+
import process14 from "node:process";
|
|
33551
|
+
import { fileURLToPath as fileURLToPath56 } from "node:url";
|
|
33552
|
+
|
|
33553
|
+
// src/scripts/_lib/gate_self_test.ts
|
|
33554
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
33494
33555
|
import * as path84 from "node:path";
|
|
33495
|
-
import
|
|
33556
|
+
import process13 from "node:process";
|
|
33557
|
+
function runGateCli(repoRoot, scriptRelPath, args, cwd) {
|
|
33558
|
+
const tsx = path84.join(
|
|
33559
|
+
repoRoot,
|
|
33560
|
+
"node_modules",
|
|
33561
|
+
".bin",
|
|
33562
|
+
process13.platform === "win32" ? "tsx.cmd" : "tsx"
|
|
33563
|
+
);
|
|
33564
|
+
const res = spawnSync8(tsx, [path84.join(repoRoot, scriptRelPath), ...args], {
|
|
33565
|
+
cwd,
|
|
33566
|
+
encoding: "utf-8",
|
|
33567
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
33568
|
+
// The child must not recurse into its own self-test.
|
|
33569
|
+
env: { ...process13.env, GATE_SELF_TEST_CHILD: "1" }
|
|
33570
|
+
});
|
|
33571
|
+
return res.status ?? 1;
|
|
33572
|
+
}
|
|
33573
|
+
function runSelfTest(opts) {
|
|
33574
|
+
const write = opts.write ?? process13.stdout.write.bind(process13.stdout);
|
|
33575
|
+
const minReject = opts.minRejectCases ?? 1;
|
|
33576
|
+
const rejectCases = opts.cases.filter((c) => c.expect === "reject").length;
|
|
33577
|
+
if (opts.cases.length < opts.minCases || rejectCases < minReject) {
|
|
33578
|
+
write(
|
|
33579
|
+
`\u274C ${opts.gate} --self-test: ${String(opts.cases.length)} case(s) (${String(rejectCases)} rejecting) is below the declared floor of ${String(opts.minCases)} (${String(minReject)} rejecting). A truncated self-test must fail rather than print success \u2014 deleting cases is otherwise the cheapest route to a green one.
|
|
33580
|
+
`
|
|
33581
|
+
);
|
|
33582
|
+
return 1;
|
|
33583
|
+
}
|
|
33584
|
+
let failed = 0;
|
|
33585
|
+
for (const testCase of opts.cases) {
|
|
33586
|
+
let exit;
|
|
33587
|
+
try {
|
|
33588
|
+
exit = testCase.run();
|
|
33589
|
+
} catch (e) {
|
|
33590
|
+
write(`\u274C ${opts.gate} --self-test: ${testCase.name} \u2014 threw: ${String(e)}
|
|
33591
|
+
`);
|
|
33592
|
+
failed += 1;
|
|
33593
|
+
continue;
|
|
33594
|
+
}
|
|
33595
|
+
const behaved = testCase.expect === "reject" ? exit !== 0 : exit === 0;
|
|
33596
|
+
if (behaved) {
|
|
33597
|
+
write(`\u2705 ${testCase.name} (expected ${testCase.expect}, exit ${String(exit)})
|
|
33598
|
+
`);
|
|
33599
|
+
} else {
|
|
33600
|
+
write(
|
|
33601
|
+
`\u274C ${testCase.name}: expected the gate to ${testCase.expect} this fixture, got exit ${String(exit)}. The gate's detection has stopped firing on a case it is supposed to catch.
|
|
33602
|
+
`
|
|
33603
|
+
);
|
|
33604
|
+
failed += 1;
|
|
33605
|
+
}
|
|
33606
|
+
}
|
|
33607
|
+
write(
|
|
33608
|
+
`
|
|
33609
|
+
${opts.gate} --self-test: ${String(opts.cases.length - failed)}/${String(opts.cases.length)} case(s) behaved (${String(rejectCases)} rejecting, floor ${String(opts.minCases)})
|
|
33610
|
+
`
|
|
33611
|
+
);
|
|
33612
|
+
return failed > 0 ? 1 : 0;
|
|
33613
|
+
}
|
|
33614
|
+
|
|
33615
|
+
// src/scripts/lint_code_comments.ts
|
|
33616
|
+
var _HERE10 = fileURLToPath56(import.meta.url);
|
|
33617
|
+
var SCANNED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
33618
|
+
".ts",
|
|
33619
|
+
".tsx",
|
|
33620
|
+
".js",
|
|
33621
|
+
".jsx",
|
|
33622
|
+
".mjs",
|
|
33623
|
+
".cjs",
|
|
33624
|
+
".css",
|
|
33625
|
+
".scss",
|
|
33626
|
+
".less",
|
|
33627
|
+
".php",
|
|
33628
|
+
".py",
|
|
33629
|
+
".go",
|
|
33630
|
+
".rs",
|
|
33631
|
+
".java",
|
|
33632
|
+
".kt",
|
|
33633
|
+
".swift",
|
|
33634
|
+
".rb",
|
|
33635
|
+
".vue",
|
|
33636
|
+
".svelte"
|
|
33637
|
+
]);
|
|
33638
|
+
var SKIP_SEGMENTS = ["node_modules/", "dist/", "build/", ".next/", "vendor/", "coverage/"];
|
|
33639
|
+
var GENERATED_MARKERS = [
|
|
33640
|
+
"generated by",
|
|
33641
|
+
"auto-generated",
|
|
33642
|
+
"autogenerated",
|
|
33643
|
+
"@generated",
|
|
33644
|
+
"do not edit",
|
|
33645
|
+
"code generated by"
|
|
33646
|
+
];
|
|
33647
|
+
var COMMENT_LINE = /^\s*(\{\s*)?(\/\/|\/\*|\*(?!\/)|\*\/|#(?!!)|--)/;
|
|
33648
|
+
function opensBlock(line) {
|
|
33649
|
+
const lastOpen = line.lastIndexOf("/*");
|
|
33650
|
+
if (lastOpen === -1) return false;
|
|
33651
|
+
return line.indexOf("*/", lastOpen + 2) === -1;
|
|
33652
|
+
}
|
|
33653
|
+
function closesBlock(line) {
|
|
33654
|
+
return line.includes("*/");
|
|
33655
|
+
}
|
|
33656
|
+
var DE_CHARS = /[äöüßÄÖÜ]/;
|
|
33657
|
+
var DE_WORDS = new RegExp(
|
|
33658
|
+
"\\b(" + [
|
|
33659
|
+
"der",
|
|
33660
|
+
"das",
|
|
33661
|
+
"dem",
|
|
33662
|
+
"den",
|
|
33663
|
+
"des",
|
|
33664
|
+
"und",
|
|
33665
|
+
"oder",
|
|
33666
|
+
"aber",
|
|
33667
|
+
"sondern",
|
|
33668
|
+
"denn",
|
|
33669
|
+
"nicht",
|
|
33670
|
+
"kein",
|
|
33671
|
+
"keine",
|
|
33672
|
+
"keiner",
|
|
33673
|
+
"keinen",
|
|
33674
|
+
"wird",
|
|
33675
|
+
"werden",
|
|
33676
|
+
"wurde",
|
|
33677
|
+
"worden",
|
|
33678
|
+
"sind",
|
|
33679
|
+
"waren",
|
|
33680
|
+
"eine",
|
|
33681
|
+
"einen",
|
|
33682
|
+
"einem",
|
|
33683
|
+
"einer",
|
|
33684
|
+
"eines",
|
|
33685
|
+
"dass",
|
|
33686
|
+
"weil",
|
|
33687
|
+
"damit",
|
|
33688
|
+
"wenn",
|
|
33689
|
+
"dann",
|
|
33690
|
+
"sonst",
|
|
33691
|
+
"obwohl",
|
|
33692
|
+
"hier",
|
|
33693
|
+
"dort",
|
|
33694
|
+
"oben",
|
|
33695
|
+
"unten",
|
|
33696
|
+
"auch",
|
|
33697
|
+
"nur",
|
|
33698
|
+
"schon",
|
|
33699
|
+
"noch",
|
|
33700
|
+
"aus",
|
|
33701
|
+
"fuer",
|
|
33702
|
+
"ueber",
|
|
33703
|
+
"durch",
|
|
33704
|
+
"gegen",
|
|
33705
|
+
"ohne",
|
|
33706
|
+
"nach",
|
|
33707
|
+
"vor",
|
|
33708
|
+
"beim",
|
|
33709
|
+
"zum",
|
|
33710
|
+
"zur",
|
|
33711
|
+
"vom",
|
|
33712
|
+
"mit",
|
|
33713
|
+
"sich",
|
|
33714
|
+
"ihre",
|
|
33715
|
+
"ihrer",
|
|
33716
|
+
"seine",
|
|
33717
|
+
"jede",
|
|
33718
|
+
"jeder",
|
|
33719
|
+
"jedes",
|
|
33720
|
+
"alle",
|
|
33721
|
+
"allen",
|
|
33722
|
+
"aller",
|
|
33723
|
+
"diese",
|
|
33724
|
+
"dieser",
|
|
33725
|
+
"dieses",
|
|
33726
|
+
"diesem",
|
|
33727
|
+
"steht",
|
|
33728
|
+
"stehen",
|
|
33729
|
+
"haben",
|
|
33730
|
+
"kann",
|
|
33731
|
+
"koennen",
|
|
33732
|
+
"muss",
|
|
33733
|
+
"muessen",
|
|
33734
|
+
"soll",
|
|
33735
|
+
"sollte",
|
|
33736
|
+
"gibt",
|
|
33737
|
+
"geht",
|
|
33738
|
+
"macht",
|
|
33739
|
+
"zeigt",
|
|
33740
|
+
"liegt",
|
|
33741
|
+
"deshalb",
|
|
33742
|
+
"deswegen",
|
|
33743
|
+
"trotzdem",
|
|
33744
|
+
"bereits",
|
|
33745
|
+
"immer",
|
|
33746
|
+
"niemals",
|
|
33747
|
+
"derselbe",
|
|
33748
|
+
"dieselbe",
|
|
33749
|
+
"dasselbe",
|
|
33750
|
+
"denselben",
|
|
33751
|
+
"demselben",
|
|
33752
|
+
"derselben",
|
|
33753
|
+
"andere",
|
|
33754
|
+
"anderer",
|
|
33755
|
+
"anderen",
|
|
33756
|
+
"anderem",
|
|
33757
|
+
"anderes",
|
|
33758
|
+
"unter",
|
|
33759
|
+
"ueber",
|
|
33760
|
+
"zwischen",
|
|
33761
|
+
"wegen",
|
|
33762
|
+
"statt",
|
|
33763
|
+
"ausser",
|
|
33764
|
+
"seit",
|
|
33765
|
+
"eigene",
|
|
33766
|
+
"eigenen",
|
|
33767
|
+
"eigener",
|
|
33768
|
+
"jeweils",
|
|
33769
|
+
"genau",
|
|
33770
|
+
"etwa",
|
|
33771
|
+
"sowohl",
|
|
33772
|
+
"warum",
|
|
33773
|
+
"wieso",
|
|
33774
|
+
"welche",
|
|
33775
|
+
"welcher",
|
|
33776
|
+
"wobei",
|
|
33777
|
+
"sowie"
|
|
33778
|
+
].join("|") + ")\\b",
|
|
33779
|
+
"gi"
|
|
33780
|
+
);
|
|
33781
|
+
var REPORT_SIGNALS = [
|
|
33782
|
+
["markdown-table", /^\s*(?:\/\/|\*|#|--)?\s*\|[^|]*\|[^|]*\|/],
|
|
33783
|
+
["box-rule", /[─═━]{10,}/],
|
|
33784
|
+
["section-mark", /^\s*(?:\/\/|\*|#|--)?\s*§\s+\S/],
|
|
33785
|
+
["markdown-heading", /^\s*(?:\/\/|\*|#|--)?\s*#{2,}\s+\S/],
|
|
33786
|
+
["revisit-if", /\brevisit-if\b/i]
|
|
33787
|
+
];
|
|
33788
|
+
var PROVENANCE_SIGNALS = [
|
|
33789
|
+
["roadmap-path", /\bagents\/roadmaps?\//i],
|
|
33790
|
+
["reference-path", /\bagents\/(references|evidence|decisions)\//i],
|
|
33791
|
+
["phase-step", /\b(phase|phase)\s*\d+\s*,\s*(step|schritt)\s*\d+/i],
|
|
33792
|
+
["prototype-source", /\b(prototyp\w*|prototype)\b[^\n]{0,40}\.(html|fig|sketch|dc\.html)\b/i]
|
|
33793
|
+
];
|
|
33794
|
+
function escapedFor(line, cls) {
|
|
33795
|
+
const m = /code-comment-allow\s+([a-z-]+|\*)\s*--\s*(\S.*)$/.exec(line);
|
|
33796
|
+
if (!m) return false;
|
|
33797
|
+
const target = m[1];
|
|
33798
|
+
return target === "*" || target === cls;
|
|
33799
|
+
}
|
|
33800
|
+
function fileIsExempt(text) {
|
|
33801
|
+
const head = text.slice(0, 2e3).toLowerCase();
|
|
33802
|
+
if (GENERATED_MARKERS.some((m) => head.includes(m))) return true;
|
|
33803
|
+
return /code-comment-allow-file\s*--\s*\S/.test(text.slice(0, 2e3));
|
|
33804
|
+
}
|
|
33805
|
+
function germanWordCount(s) {
|
|
33806
|
+
return new Set((s.match(DE_WORDS) ?? []).map((h) => h.toLowerCase())).size;
|
|
33807
|
+
}
|
|
33808
|
+
function commentProse(line) {
|
|
33809
|
+
return line.replace(/^\s*(\/\/+|\/\*+|\*+\/?|#+|--)/, " ");
|
|
33810
|
+
}
|
|
33811
|
+
function prosePlain(line) {
|
|
33812
|
+
return commentProse(line).replace(/`[^`]*`/g, " ").replace(/'[^']*'/g, " ").replace(/"[^"]*"/g, " ").replace(/[\u201c\u201e][^\u201c\u201d\u201e]*[\u201d\u201c]/g, " ").replace(/[\u2018\u201a][^\u2018\u2019\u201a]*[\u2019\u2018]/g, " ").replace(/\u00bb[^\u00ab\u00bb]*\u00ab/g, " ").replace(/[\u201c\u201e][^\u201c\u201d\u201e]*$/, " ").replace(
|
|
33813
|
+
/"[^"]*$/,
|
|
33814
|
+
(m, offset, whole) => germanWordCount(whole.slice(0, offset)) >= 2 ? m : " "
|
|
33815
|
+
);
|
|
33816
|
+
}
|
|
33817
|
+
function scanText2(file, text) {
|
|
33818
|
+
if (fileIsExempt(text)) return [];
|
|
33819
|
+
const out = [];
|
|
33820
|
+
const lines = text.split("\n");
|
|
33821
|
+
let inQuote = false;
|
|
33822
|
+
let inBlock = false;
|
|
33823
|
+
for (let i = 0; i < lines.length; i++) {
|
|
33824
|
+
const raw = lines[i] ?? "";
|
|
33825
|
+
const isComment = inBlock || COMMENT_LINE.test(raw);
|
|
33826
|
+
if (inBlock && closesBlock(raw)) inBlock = false;
|
|
33827
|
+
else if (!inBlock && opensBlock(raw)) inBlock = true;
|
|
33828
|
+
if (!isComment) {
|
|
33829
|
+
inQuote = false;
|
|
33830
|
+
continue;
|
|
33831
|
+
}
|
|
33832
|
+
const prose = commentProse(raw);
|
|
33833
|
+
const opensBefore = inQuote;
|
|
33834
|
+
const marks = (commentProse(raw).match(/[\u201c\u201d\u201e"]/g) ?? []).length;
|
|
33835
|
+
if (marks % 2 === 1) inQuote = !inQuote;
|
|
33836
|
+
if (opensBefore) continue;
|
|
33837
|
+
const at = i + 1;
|
|
33838
|
+
const snip = raw.trim().slice(0, 100);
|
|
33839
|
+
if (!escapedFor(raw, "de-comment")) {
|
|
33840
|
+
const plain = prosePlain(raw);
|
|
33841
|
+
const distinct = new Set((plain.match(DE_WORDS) ?? []).map((h) => h.toLowerCase()));
|
|
33842
|
+
const umlaut = DE_CHARS.test(plain);
|
|
33843
|
+
const isGerman = distinct.size >= 2 || umlaut && distinct.size >= 1;
|
|
33844
|
+
if (isGerman) {
|
|
33845
|
+
out.push({
|
|
33846
|
+
cls: "de-comment",
|
|
33847
|
+
file,
|
|
33848
|
+
line: at,
|
|
33849
|
+
signal: umlaut ? `umlaut+${[...distinct][0]}` : `function-words: ${[...distinct].slice(0, 4).join(" ")}`,
|
|
33850
|
+
snippet: snip
|
|
33851
|
+
});
|
|
33852
|
+
}
|
|
33853
|
+
}
|
|
33854
|
+
if (!escapedFor(raw, "report-comment")) {
|
|
33855
|
+
for (const [name, re] of REPORT_SIGNALS) {
|
|
33856
|
+
if (re.test(raw)) {
|
|
33857
|
+
out.push({ cls: "report-comment", file, line: at, signal: name, snippet: snip });
|
|
33858
|
+
break;
|
|
33859
|
+
}
|
|
33860
|
+
}
|
|
33861
|
+
}
|
|
33862
|
+
if (!escapedFor(raw, "provenance-comment")) {
|
|
33863
|
+
for (const [name, re] of PROVENANCE_SIGNALS) {
|
|
33864
|
+
if (re.test(prose)) {
|
|
33865
|
+
out.push({ cls: "provenance-comment", file, line: at, signal: name, snippet: snip });
|
|
33866
|
+
break;
|
|
33867
|
+
}
|
|
33868
|
+
}
|
|
33869
|
+
}
|
|
33870
|
+
}
|
|
33871
|
+
return out;
|
|
33872
|
+
}
|
|
33873
|
+
function isScannable(rel) {
|
|
33874
|
+
if (SKIP_SEGMENTS.some((s) => rel.includes(s))) return false;
|
|
33875
|
+
if (rel.endsWith(".d.ts")) return false;
|
|
33876
|
+
return SCANNED_EXTENSIONS.has(path85.extname(rel));
|
|
33877
|
+
}
|
|
33878
|
+
function changedFiles(root, base) {
|
|
33879
|
+
const r = spawnSync9("git", ["diff", "--name-only", "--diff-filter=ACMR", `${base}...HEAD`], {
|
|
33880
|
+
cwd: root,
|
|
33881
|
+
encoding: "utf-8"
|
|
33882
|
+
});
|
|
33883
|
+
const tracked = r.status === 0 ? r.stdout.split("\n") : [];
|
|
33884
|
+
const u = spawnSync9("git", ["ls-files", "--others", "--exclude-standard"], {
|
|
33885
|
+
cwd: root,
|
|
33886
|
+
encoding: "utf-8"
|
|
33887
|
+
});
|
|
33888
|
+
const untracked = u.status === 0 ? u.stdout.split("\n") : [];
|
|
33889
|
+
const m = spawnSync9("git", ["diff", "--name-only", "--diff-filter=ACMR"], {
|
|
33890
|
+
cwd: root,
|
|
33891
|
+
encoding: "utf-8"
|
|
33892
|
+
});
|
|
33893
|
+
const dirty = m.status === 0 ? m.stdout.split("\n") : [];
|
|
33894
|
+
return [.../* @__PURE__ */ new Set([...tracked, ...untracked, ...dirty])].filter((f) => f.trim().length > 0);
|
|
33895
|
+
}
|
|
33896
|
+
function addedLineMap(root, base) {
|
|
33897
|
+
const out = /* @__PURE__ */ new Map();
|
|
33898
|
+
const u = spawnSync9("git", ["ls-files", "--others", "--exclude-standard"], {
|
|
33899
|
+
cwd: root,
|
|
33900
|
+
encoding: "utf-8"
|
|
33901
|
+
});
|
|
33902
|
+
if (u.status === 0) {
|
|
33903
|
+
for (const f of u.stdout.split("\n")) {
|
|
33904
|
+
if (f.trim()) out.set(f.trim(), "all");
|
|
33905
|
+
}
|
|
33906
|
+
}
|
|
33907
|
+
for (const argv of [
|
|
33908
|
+
["diff", "--unified=0", "--diff-filter=ACMR", `${base}...HEAD`],
|
|
33909
|
+
["diff", "--unified=0", "--diff-filter=ACMR"]
|
|
33910
|
+
]) {
|
|
33911
|
+
const r = spawnSync9("git", argv, { cwd: root, encoding: "utf-8" });
|
|
33912
|
+
if (r.status !== 0) continue;
|
|
33913
|
+
mergeAddedLines(out, parseAddedLines(r.stdout));
|
|
33914
|
+
}
|
|
33915
|
+
return out;
|
|
33916
|
+
}
|
|
33917
|
+
function parseAddedLines(diffText) {
|
|
33918
|
+
const out = /* @__PURE__ */ new Map();
|
|
33919
|
+
let file = null;
|
|
33920
|
+
for (const line of diffText.split("\n")) {
|
|
33921
|
+
if (line.startsWith("+++ ")) {
|
|
33922
|
+
const p = line.slice(4).trim();
|
|
33923
|
+
file = p === "/dev/null" ? null : p.replace(/^b\//, "");
|
|
33924
|
+
continue;
|
|
33925
|
+
}
|
|
33926
|
+
if (!file || !line.startsWith("@@")) continue;
|
|
33927
|
+
const m = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(line);
|
|
33928
|
+
if (!m) continue;
|
|
33929
|
+
const start = Number.parseInt(m[1], 10);
|
|
33930
|
+
const count = m[2] === void 0 ? 1 : Number.parseInt(m[2], 10);
|
|
33931
|
+
const set = out.get(file) ?? /* @__PURE__ */ new Set();
|
|
33932
|
+
for (let n = start; n < start + count; n += 1) set.add(n);
|
|
33933
|
+
out.set(file, set);
|
|
33934
|
+
}
|
|
33935
|
+
return out;
|
|
33936
|
+
}
|
|
33937
|
+
function mergeAddedLines(into, from) {
|
|
33938
|
+
for (const [file, lines] of from) {
|
|
33939
|
+
const prev = into.get(file);
|
|
33940
|
+
if (prev === "all") continue;
|
|
33941
|
+
const set = prev ?? /* @__PURE__ */ new Set();
|
|
33942
|
+
for (const n of lines) set.add(n);
|
|
33943
|
+
into.set(file, set);
|
|
33944
|
+
}
|
|
33945
|
+
}
|
|
33946
|
+
function findingsOnAddedLines(findings, lines) {
|
|
33947
|
+
if (lines === void 0) return [];
|
|
33948
|
+
if (lines === "all") return [...findings];
|
|
33949
|
+
return findings.filter((f) => lines.has(f.line));
|
|
33950
|
+
}
|
|
33951
|
+
var COMMENT_CASES = [
|
|
33952
|
+
{
|
|
33953
|
+
name: "a block-comment continuation carrying no leading star is flagged",
|
|
33954
|
+
source: " /* Hausform mit Objekt-`message`: derselbe Aufbau, anderer Schluessel.\n `BaseException::render()` dekodiert eine JSON-Zeichenkette und legt das\n Ergebnis unter `message` ab, bei Feldfehlern ist das ein Objekt. */\n if (isRecord(payload.message)) {\n",
|
|
33955
|
+
flags: ["de-comment"]
|
|
33956
|
+
},
|
|
33957
|
+
{
|
|
33958
|
+
name: "a JSX comment, which opens with a brace rather than a slash, is flagged",
|
|
33959
|
+
source: " {/* Der Titel traegt die Aktion, nicht die Zeile. */}\n",
|
|
33960
|
+
flags: ["de-comment"]
|
|
33961
|
+
},
|
|
33962
|
+
{
|
|
33963
|
+
name: "a German comment line carrying two function words is flagged",
|
|
33964
|
+
source: "// Hier stehen nur die Werte, die Bedeutung tragen\nconst a = 1;\n",
|
|
33965
|
+
flags: ["de-comment"]
|
|
33966
|
+
},
|
|
33967
|
+
{
|
|
33968
|
+
name: "transliterated German with no umlaut at all is flagged",
|
|
33969
|
+
source: "/* uebersetzt aus dem Prototyp, jeder Wert ist hier belegt */\n",
|
|
33970
|
+
flags: ["de-comment"]
|
|
33971
|
+
},
|
|
33972
|
+
{
|
|
33973
|
+
name: "a German line whose only umlaut sits in ordinary prose is flagged",
|
|
33974
|
+
source: "// Die Schriftstufen der kompakten Datenoberfl\xE4che\n",
|
|
33975
|
+
flags: ["de-comment"]
|
|
33976
|
+
},
|
|
33977
|
+
{
|
|
33978
|
+
name: "an English comment quoting a non-ASCII sample value stays silent",
|
|
33979
|
+
source: "/** so a `caf\xE9@ex\xE4mple.com` email or a `/Users/m\xF6chte/f` path masks */\n",
|
|
33980
|
+
flags: []
|
|
33981
|
+
},
|
|
33982
|
+
{
|
|
33983
|
+
name: "an English comment carrying an umlauted proper name stays silent",
|
|
33984
|
+
source: "/** Robertson\u2013Sp\xE4rck-Jones IDF, floored at 0 so terms never subtract. */\n",
|
|
33985
|
+
flags: []
|
|
33986
|
+
},
|
|
33987
|
+
{
|
|
33988
|
+
name: "an umlauted step label in English prose stays silent",
|
|
33989
|
+
source: "// \u2500\u2500 \xDC2 \u2014 orthogonal stance assignment per seat \u2500\u2500\n",
|
|
33990
|
+
flags: []
|
|
33991
|
+
},
|
|
33992
|
+
{
|
|
33993
|
+
name: "a single-line German user quotation used as data stays silent",
|
|
33994
|
+
source: '// the phrase "nicht releasen. Warum nicht?" names no fault\n',
|
|
33995
|
+
flags: []
|
|
33996
|
+
},
|
|
33997
|
+
{
|
|
33998
|
+
name: "a German user quotation spanning two comment lines stays silent",
|
|
33999
|
+
source: '/**\n * "Kein Council konfiguriert (keine `.agent-settings.yml`) \u2014 ich nutze\n * Subagenten-F\xE4cher mit gegnerischen Linsen als Ersatz"\n */\n',
|
|
34000
|
+
flags: []
|
|
34001
|
+
},
|
|
34002
|
+
{
|
|
34003
|
+
name: "plain English prose stays silent",
|
|
34004
|
+
source: "// The cap is a stated default, not a measured optimum.\n",
|
|
34005
|
+
flags: []
|
|
34006
|
+
},
|
|
34007
|
+
{
|
|
34008
|
+
name: "a markdown table inside a comment is flagged",
|
|
34009
|
+
source: " * | Prototype | Role | here |\n",
|
|
34010
|
+
flags: ["report-comment"]
|
|
34011
|
+
},
|
|
34012
|
+
{
|
|
34013
|
+
name: "a box-drawing rule is flagged",
|
|
34014
|
+
source: " * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n",
|
|
34015
|
+
flags: ["report-comment"]
|
|
34016
|
+
},
|
|
34017
|
+
{
|
|
34018
|
+
name: "a revisit clause is flagged",
|
|
34019
|
+
source: " * Revisit-if: someone holds the new surface next to the sidebar.\n",
|
|
34020
|
+
flags: ["report-comment"]
|
|
34021
|
+
},
|
|
34022
|
+
{
|
|
34023
|
+
name: "a short dash rule that is not a report stays silent",
|
|
34024
|
+
source: "// --- setup ---\n",
|
|
34025
|
+
flags: []
|
|
34026
|
+
},
|
|
34027
|
+
{
|
|
34028
|
+
name: "a roadmap citation is flagged",
|
|
34029
|
+
source: "// see agents/roadmaps/todos-task-module-frontend.md\n",
|
|
34030
|
+
flags: ["provenance-comment"]
|
|
34031
|
+
},
|
|
34032
|
+
{
|
|
34033
|
+
name: "a phase-and-step citation is flagged",
|
|
34034
|
+
source: "// Roadmap todos-task-module, Phase 1, Schritt 1.\n",
|
|
34035
|
+
flags: ["provenance-comment"]
|
|
34036
|
+
},
|
|
34037
|
+
{
|
|
34038
|
+
name: "a plain code reference stays silent",
|
|
34039
|
+
source: "// see src/lib/token.ts for the parser\n",
|
|
34040
|
+
flags: []
|
|
34041
|
+
},
|
|
34042
|
+
{
|
|
34043
|
+
name: "a per-line escape carrying a reason suppresses the class",
|
|
34044
|
+
source: "// Hier stehen die Werte code-comment-allow de-comment -- quoted spec text\n",
|
|
34045
|
+
flags: []
|
|
34046
|
+
},
|
|
34047
|
+
{
|
|
34048
|
+
name: "a bare escape with no reason suppresses nothing",
|
|
34049
|
+
source: "// Hier stehen die Werte code-comment-allow de-comment\n",
|
|
34050
|
+
flags: ["de-comment"]
|
|
34051
|
+
}
|
|
34052
|
+
];
|
|
34053
|
+
function selfTest() {
|
|
34054
|
+
const repoRoot = path85.resolve(path85.dirname(_HERE10), "..", "..");
|
|
34055
|
+
const dir = fs84.mkdtempSync(path85.join(os11.tmpdir(), "lcc-selftest-"));
|
|
34056
|
+
const exercise = (testCase, index) => {
|
|
34057
|
+
const file = path85.join(dir, `case-${String(index)}.ts`);
|
|
34058
|
+
fs84.writeFileSync(file, testCase.source, "utf-8");
|
|
34059
|
+
return runGateCli(repoRoot, "src/scripts/lint_code_comments.ts", ["--paths", file], dir);
|
|
34060
|
+
};
|
|
34061
|
+
try {
|
|
34062
|
+
return runSelfTest({
|
|
34063
|
+
gate: "lint_code_comments",
|
|
34064
|
+
minCases: 16,
|
|
34065
|
+
minRejectCases: 8,
|
|
34066
|
+
cases: COMMENT_CASES.map((testCase, index) => ({
|
|
34067
|
+
name: testCase.name,
|
|
34068
|
+
expect: testCase.flags.length > 0 ? "reject" : "accept",
|
|
34069
|
+
run: () => exercise(testCase, index)
|
|
34070
|
+
}))
|
|
34071
|
+
});
|
|
34072
|
+
} finally {
|
|
34073
|
+
fs84.rmSync(dir, { recursive: true, force: true });
|
|
34074
|
+
}
|
|
34075
|
+
}
|
|
34076
|
+
var HELP = `usage: lint_code_comments [--base <ref>] [--root <dir>] [--paths <f> \u2026] [--report]
|
|
34077
|
+
|
|
34078
|
+
--base <ref> diff against this ref (default: origin/main)
|
|
34079
|
+
--root <dir> run against another checkout (default: this repository)
|
|
34080
|
+
--paths scan exactly these files, ignoring the diff
|
|
34081
|
+
--report print every finding grouped by file and exit 0
|
|
34082
|
+
--self-test drive this binary over its own fixture table and exit 0 on pass
|
|
34083
|
+
|
|
34084
|
+
Classes: de-comment \xB7 report-comment \xB7 provenance-comment
|
|
34085
|
+
Escape: code-comment-allow <class|*> -- <reason> (per line)
|
|
34086
|
+
code-comment-allow-file -- <reason> (first 2000 chars)
|
|
34087
|
+
`;
|
|
34088
|
+
function main55(argv) {
|
|
34089
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
34090
|
+
process14.stdout.write(HELP);
|
|
34091
|
+
return 0;
|
|
34092
|
+
}
|
|
34093
|
+
if (argv.includes("--self-test")) {
|
|
34094
|
+
if (process14.env["GATE_SELF_TEST_CHILD"] === "1") {
|
|
34095
|
+
process14.stderr.write("lint_code_comments: refusing to nest --self-test inside a self-test child\n");
|
|
34096
|
+
return 2;
|
|
34097
|
+
}
|
|
34098
|
+
return selfTest();
|
|
34099
|
+
}
|
|
34100
|
+
let base = "origin/main";
|
|
34101
|
+
let root = path85.resolve(path85.dirname(_HERE10), "..", "..");
|
|
34102
|
+
let reportOnly = false;
|
|
34103
|
+
const explicit = [];
|
|
34104
|
+
for (let i = 0; i < argv.length; i++) {
|
|
34105
|
+
const a = argv[i];
|
|
34106
|
+
if (a === "--help" || a === "-h") {
|
|
34107
|
+
process14.stdout.write(HELP);
|
|
34108
|
+
return 0;
|
|
34109
|
+
} else if (a === "--base") {
|
|
34110
|
+
base = argv[++i] ?? "";
|
|
34111
|
+
} else if (a === "--root") {
|
|
34112
|
+
root = path85.resolve(argv[++i] ?? ".");
|
|
34113
|
+
} else if (a === "--report") {
|
|
34114
|
+
reportOnly = true;
|
|
34115
|
+
} else if (a === "--paths") {
|
|
34116
|
+
while (i + 1 < argv.length && !argv[i + 1].startsWith("--")) explicit.push(argv[++i]);
|
|
34117
|
+
} else {
|
|
34118
|
+
process14.stderr.write(`lint_code_comments: unknown argument ${a}
|
|
34119
|
+
${HELP}`);
|
|
34120
|
+
return 1;
|
|
34121
|
+
}
|
|
34122
|
+
}
|
|
34123
|
+
if (!base && explicit.length === 0) {
|
|
34124
|
+
process14.stderr.write("--base needs a ref\n");
|
|
34125
|
+
return 1;
|
|
34126
|
+
}
|
|
34127
|
+
const candidates = (explicit.length > 0 ? explicit : changedFiles(root, base)).filter(isScannable);
|
|
34128
|
+
const added = explicit.length > 0 ? null : addedLineMap(root, base);
|
|
34129
|
+
const findings = [];
|
|
34130
|
+
for (const rel of candidates) {
|
|
34131
|
+
const abs = path85.isAbsolute(rel) ? rel : path85.join(root, rel);
|
|
34132
|
+
let text;
|
|
34133
|
+
try {
|
|
34134
|
+
text = fs84.readFileSync(abs, "utf-8");
|
|
34135
|
+
} catch {
|
|
34136
|
+
continue;
|
|
34137
|
+
}
|
|
34138
|
+
const all = scanText2(rel, text);
|
|
34139
|
+
findings.push(...added ? findingsOnAddedLines(all, added.get(rel)) : all);
|
|
34140
|
+
}
|
|
34141
|
+
try {
|
|
34142
|
+
reportScanned({
|
|
34143
|
+
gate: "lint_code_comments",
|
|
34144
|
+
scanned: candidates.length,
|
|
34145
|
+
units: "source file(s)",
|
|
34146
|
+
roots: explicit.length > 0 ? explicit.slice(0, 4) : [`git diff ${base}...HEAD`],
|
|
34147
|
+
allowEmpty: "EMPTY_VALID: the scan root is a DIFF, and a diff with no source file in it is the normal case for a docs-only or config-only change. git already answered for the range: an unreadable ref yields no candidates AND no findings, which is indistinguishable here from a clean docs commit, so this gate deliberately does not treat zero as a dead scope. The scope failure this class exists to catch \u2014 a moved source tree \u2014 cannot occur, because there is no committed path list to go stale."
|
|
34148
|
+
});
|
|
34149
|
+
} catch (e) {
|
|
34150
|
+
if (e instanceof DeadScopeError) {
|
|
34151
|
+
process14.stderr.write(`\u274C ${e.message}
|
|
34152
|
+
`);
|
|
34153
|
+
return 1;
|
|
34154
|
+
}
|
|
34155
|
+
throw e;
|
|
34156
|
+
}
|
|
34157
|
+
process14.stdout.write(` against ${explicit.length > 0 ? "an explicit path list" : base}
|
|
34158
|
+
`);
|
|
34159
|
+
if (findings.length === 0) {
|
|
34160
|
+
process14.stdout.write("\u2705 lint_code_comments: no German, report-shaped or provenance comments.\n");
|
|
34161
|
+
return 0;
|
|
34162
|
+
}
|
|
34163
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
34164
|
+
for (const f of findings) {
|
|
34165
|
+
const l = byFile.get(f.file) ?? [];
|
|
34166
|
+
l.push(f);
|
|
34167
|
+
byFile.set(f.file, l);
|
|
34168
|
+
}
|
|
34169
|
+
for (const [file, list] of [...byFile].sort()) {
|
|
34170
|
+
process14.stdout.write(`
|
|
34171
|
+
${file} (${list.length})
|
|
34172
|
+
`);
|
|
34173
|
+
for (const f of list.slice(0, 8)) {
|
|
34174
|
+
process14.stdout.write(` ${String(f.line).padStart(5)} ${f.cls}/${f.signal} ${f.snippet}
|
|
34175
|
+
`);
|
|
34176
|
+
}
|
|
34177
|
+
if (list.length > 8) process14.stdout.write(` \u2026 ${list.length - 8} more in this file
|
|
34178
|
+
`);
|
|
34179
|
+
}
|
|
34180
|
+
const counts = /* @__PURE__ */ new Map();
|
|
34181
|
+
for (const f of findings) counts.set(f.cls, (counts.get(f.cls) ?? 0) + 1);
|
|
34182
|
+
process14.stdout.write(`
|
|
34183
|
+
${[...counts].map(([c, n]) => `${c}: ${n}`).join(" \xB7 ")} across ${byFile.size} file(s)
|
|
34184
|
+
`);
|
|
34185
|
+
if (reportOnly) return 0;
|
|
34186
|
+
process14.stderr.write(
|
|
34187
|
+
"\n\u274C lint_code_comments: comments carry language, evidence or report structure that does not belong in source.\n A comment states a WHY or a constraint the code cannot show, in English. Evidence belongs in the\n roadmap that asked for it. Rewrite the comment, delete it, or escape one line with\n `code-comment-allow <class> -- <reason>`.\n"
|
|
34188
|
+
);
|
|
34189
|
+
return 2;
|
|
34190
|
+
}
|
|
34191
|
+
var _isMain6 = (() => {
|
|
34192
|
+
const entry = process14.argv[1];
|
|
34193
|
+
if (!entry) return false;
|
|
34194
|
+
try {
|
|
34195
|
+
return fs84.realpathSync(entry) === fs84.realpathSync(_HERE10);
|
|
34196
|
+
} catch {
|
|
34197
|
+
return false;
|
|
34198
|
+
}
|
|
34199
|
+
})();
|
|
34200
|
+
if (_isMain6) process14.exit(main55(process14.argv.slice(2)));
|
|
34201
|
+
|
|
34202
|
+
// src/scripts/hooks/comment_discipline_hook.ts
|
|
33496
34203
|
var EXIT_ALLOW28 = 0;
|
|
33497
34204
|
var EXIT_WARN15 = 2;
|
|
34205
|
+
var MAX_REPORTED = 3;
|
|
34206
|
+
function str10(v) {
|
|
34207
|
+
return typeof v === "string" ? v : "";
|
|
34208
|
+
}
|
|
34209
|
+
function isObject13(v) {
|
|
34210
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
34211
|
+
}
|
|
34212
|
+
function writtenText(toolName2, toolInput) {
|
|
34213
|
+
if (toolName2 === "Write") return str10(toolInput["content"]);
|
|
34214
|
+
if (toolName2 === "Edit") {
|
|
34215
|
+
return str10(toolInput["new_string"]) || str10(toolInput["newString"]);
|
|
34216
|
+
}
|
|
34217
|
+
return "";
|
|
34218
|
+
}
|
|
34219
|
+
function buildAdvisoryLine3(file, findings) {
|
|
34220
|
+
const counts = /* @__PURE__ */ new Map();
|
|
34221
|
+
for (const f of findings) counts.set(f.cls, (counts.get(f.cls) ?? 0) + 1);
|
|
34222
|
+
const summary = [...counts].map(([c, n]) => `${c} \xD7${n}`).join(" \xB7 ");
|
|
34223
|
+
const named = findings.slice(0, MAX_REPORTED).map((f) => `line ${f.line} (${f.signal})`).join(", ");
|
|
34224
|
+
const more = findings.length > MAX_REPORTED ? `, +${findings.length - MAX_REPORTED} more` : "";
|
|
34225
|
+
return `comment-discipline: the text just written to ${file} carries ${summary} \u2014 ${named}${more}. A comment states a WHY or a constraint the code cannot show, in English; evidence for a roadmap step belongs in that roadmap, not in a second copy in the source. Rewrite or delete those lines now, before the next write \u2014 \`lint_code_comments\` refuses them at the gate.`;
|
|
34226
|
+
}
|
|
34227
|
+
function main56() {
|
|
34228
|
+
try {
|
|
34229
|
+
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
34230
|
+
const event = str10(envelope["event"]);
|
|
34231
|
+
if (event !== "" && event !== "post_tool_use") return EXIT_ALLOW28;
|
|
34232
|
+
const toolName2 = str10(
|
|
34233
|
+
payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]
|
|
34234
|
+
);
|
|
34235
|
+
if (toolName2 !== "Write" && toolName2 !== "Edit") return EXIT_ALLOW28;
|
|
34236
|
+
const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
|
|
34237
|
+
if (!isObject13(ti)) return EXIT_ALLOW28;
|
|
34238
|
+
const filePath = str10(ti["file_path"] ?? ti["path"] ?? ti["filePath"]);
|
|
34239
|
+
if (!filePath || !isScannable(filePath)) return EXIT_ALLOW28;
|
|
34240
|
+
const text = writtenText(toolName2, ti);
|
|
34241
|
+
if (!text) return EXIT_ALLOW28;
|
|
34242
|
+
const workspaceRoot3 = str10(envelope["workspace_root"]).trim() || process.cwd();
|
|
34243
|
+
const abs = path86.isAbsolute(filePath) ? filePath : path86.resolve(workspaceRoot3, filePath);
|
|
34244
|
+
const rel = path86.relative(workspaceRoot3, abs);
|
|
34245
|
+
const shown = rel.startsWith("..") ? path86.basename(abs) : rel;
|
|
34246
|
+
const findings = scanText2(shown, text);
|
|
34247
|
+
if (findings.length === 0) return EXIT_ALLOW28;
|
|
34248
|
+
process.stdout.write(
|
|
34249
|
+
`${JSON.stringify({
|
|
34250
|
+
decision: "warn",
|
|
34251
|
+
reason: `comment-discipline: ${findings.length} comment finding(s) in the text written to ${shown}`,
|
|
34252
|
+
additional_context: buildAdvisoryLine3(shown, findings)
|
|
34253
|
+
})}
|
|
34254
|
+
`
|
|
34255
|
+
);
|
|
34256
|
+
return EXIT_WARN15;
|
|
34257
|
+
} catch {
|
|
34258
|
+
return EXIT_ALLOW28;
|
|
34259
|
+
}
|
|
34260
|
+
}
|
|
34261
|
+
function _isCliEntry43() {
|
|
34262
|
+
if (true) return false;
|
|
34263
|
+
if (process.argv[1] === void 0) return false;
|
|
34264
|
+
const argvUrl = pathToFileURL50(path86.resolve(process.argv[1])).href;
|
|
34265
|
+
if (import.meta.url === argvUrl) return true;
|
|
34266
|
+
try {
|
|
34267
|
+
return fs85.realpathSync(fileURLToPath57(import.meta.url)) === fs85.realpathSync(path86.resolve(process.argv[1]));
|
|
34268
|
+
} catch {
|
|
34269
|
+
return false;
|
|
34270
|
+
}
|
|
34271
|
+
}
|
|
34272
|
+
if (_isCliEntry43()) process.exit(main56());
|
|
34273
|
+
|
|
34274
|
+
// src/scripts/hooks/reread_guard_hook.ts
|
|
34275
|
+
import * as crypto12 from "node:crypto";
|
|
34276
|
+
import * as fs86 from "node:fs";
|
|
34277
|
+
import * as path87 from "node:path";
|
|
34278
|
+
import { fileURLToPath as fileURLToPath58, pathToFileURL as pathToFileURL51 } from "node:url";
|
|
34279
|
+
var EXIT_ALLOW29 = 0;
|
|
34280
|
+
var EXIT_WARN16 = 2;
|
|
33498
34281
|
var EXEMPT_PATH_PATTERNS2 = [
|
|
33499
34282
|
/(^|\/)dist\//i,
|
|
33500
34283
|
// dist/**
|
|
@@ -33509,10 +34292,10 @@ var EXEMPT_PATH_PATTERNS2 = [
|
|
|
33509
34292
|
];
|
|
33510
34293
|
var READ_TOOLS = /* @__PURE__ */ new Set(["Read"]);
|
|
33511
34294
|
var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Edit", "Write"]);
|
|
33512
|
-
function
|
|
34295
|
+
function isObject14(v) {
|
|
33513
34296
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
33514
34297
|
}
|
|
33515
|
-
function
|
|
34298
|
+
function str11(v) {
|
|
33516
34299
|
return typeof v === "string" ? v : "";
|
|
33517
34300
|
}
|
|
33518
34301
|
function isExemptPath2(filePath) {
|
|
@@ -33523,21 +34306,21 @@ function emptyLedger() {
|
|
|
33523
34306
|
return { reads: {}, writes: {}, fired: {} };
|
|
33524
34307
|
}
|
|
33525
34308
|
function deriveSessionKey4(envelope, payload) {
|
|
33526
|
-
const raw =
|
|
34309
|
+
const raw = str11(envelope["session_id"]) || str11(payload["session_id"] ?? payload["sessionId"]);
|
|
33527
34310
|
const material = raw || "unknown-session";
|
|
33528
34311
|
return crypto12.createHash("sha256").update(material).digest("hex");
|
|
33529
34312
|
}
|
|
33530
34313
|
function ledgerFile(workspaceRoot3, sessionKey) {
|
|
33531
|
-
return
|
|
34314
|
+
return path87.join(workspaceRoot3, "agents", "runtime", "state", "reread-guard", `${sessionKey}.json`);
|
|
33532
34315
|
}
|
|
33533
34316
|
function readLedger(workspaceRoot3, sessionKey) {
|
|
33534
34317
|
try {
|
|
33535
|
-
const parsed = JSON.parse(
|
|
33536
|
-
if (!
|
|
34318
|
+
const parsed = JSON.parse(fs86.readFileSync(ledgerFile(workspaceRoot3, sessionKey), "utf8"));
|
|
34319
|
+
if (!isObject14(parsed)) return emptyLedger();
|
|
33537
34320
|
return {
|
|
33538
|
-
reads:
|
|
33539
|
-
writes:
|
|
33540
|
-
fired:
|
|
34321
|
+
reads: isObject14(parsed["reads"]) ? parsed["reads"] : {},
|
|
34322
|
+
writes: isObject14(parsed["writes"]) ? parsed["writes"] : {},
|
|
34323
|
+
fired: isObject14(parsed["fired"]) ? parsed["fired"] : {}
|
|
33541
34324
|
};
|
|
33542
34325
|
} catch {
|
|
33543
34326
|
return emptyLedger();
|
|
@@ -33550,14 +34333,14 @@ function writeLedger(workspaceRoot3, sessionKey, ledger) {
|
|
|
33550
34333
|
}
|
|
33551
34334
|
}
|
|
33552
34335
|
function extractToolName4(payload) {
|
|
33553
|
-
return
|
|
34336
|
+
return str11(payload["tool_name"] ?? payload["toolName"] ?? payload["tool"]);
|
|
33554
34337
|
}
|
|
33555
34338
|
function extractToolInput2(payload) {
|
|
33556
34339
|
const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
|
|
33557
|
-
return
|
|
34340
|
+
return isObject14(ti) ? ti : {};
|
|
33558
34341
|
}
|
|
33559
34342
|
function extractFilePath3(toolInput) {
|
|
33560
|
-
return
|
|
34343
|
+
return str11(toolInput["file_path"] ?? toolInput["path"] ?? toolInput["filePath"]);
|
|
33561
34344
|
}
|
|
33562
34345
|
function isRangedRead(toolInput) {
|
|
33563
34346
|
for (const key of ["offset", "limit", "start_line", "end_line", "startLine", "endLine"]) {
|
|
@@ -33573,41 +34356,41 @@ function buildDuplicateReadLine(relPath, earlierTs) {
|
|
|
33573
34356
|
function buildPostEditReadLine(relPath) {
|
|
33574
34357
|
return `re-read guard: this session just edited ${relPath} \u2014 a full-file re-read re-pays for content you already have; a ranged Read (offset/limit) over the edited hunk is enough to verify the change.`;
|
|
33575
34358
|
}
|
|
33576
|
-
function
|
|
34359
|
+
function main57() {
|
|
33577
34360
|
try {
|
|
33578
34361
|
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
33579
|
-
const event =
|
|
33580
|
-
if (event !== "" && event !== "pre_tool_use") return
|
|
34362
|
+
const event = str11(envelope["event"]);
|
|
34363
|
+
if (event !== "" && event !== "pre_tool_use") return EXIT_ALLOW29;
|
|
33581
34364
|
const toolName2 = extractToolName4(payload);
|
|
33582
34365
|
const isRead = READ_TOOLS.has(toolName2);
|
|
33583
34366
|
const isWrite = WRITE_TOOLS2.has(toolName2);
|
|
33584
|
-
if (!isRead && !isWrite) return
|
|
34367
|
+
if (!isRead && !isWrite) return EXIT_ALLOW29;
|
|
33585
34368
|
const toolInput = extractToolInput2(payload);
|
|
33586
34369
|
const filePath = extractFilePath3(toolInput);
|
|
33587
|
-
if (!filePath) return
|
|
33588
|
-
const workspaceRoot3 =
|
|
33589
|
-
const absPath =
|
|
33590
|
-
const relPath =
|
|
33591
|
-
if (isExemptPath2(relPath) || isExemptPath2(absPath)) return
|
|
34370
|
+
if (!filePath) return EXIT_ALLOW29;
|
|
34371
|
+
const workspaceRoot3 = str11(envelope["workspace_root"]).trim() || process.cwd();
|
|
34372
|
+
const absPath = path87.isAbsolute(filePath) ? filePath : path87.resolve(workspaceRoot3, filePath);
|
|
34373
|
+
const relPath = path87.relative(workspaceRoot3, absPath);
|
|
34374
|
+
if (isExemptPath2(relPath) || isExemptPath2(absPath)) return EXIT_ALLOW29;
|
|
33592
34375
|
const sessionKey = deriveSessionKey4(envelope, payload);
|
|
33593
34376
|
const ledger = readLedger(workspaceRoot3, sessionKey);
|
|
33594
34377
|
const key = relPath.startsWith("..") ? absPath : relPath;
|
|
33595
34378
|
if (isWrite) {
|
|
33596
34379
|
ledger.writes[key] = Date.now();
|
|
33597
34380
|
writeLedger(workspaceRoot3, sessionKey, ledger);
|
|
33598
|
-
return
|
|
34381
|
+
return EXIT_ALLOW29;
|
|
33599
34382
|
}
|
|
33600
34383
|
if (isRangedRead(toolInput)) {
|
|
33601
|
-
return
|
|
34384
|
+
return EXIT_ALLOW29;
|
|
33602
34385
|
}
|
|
33603
34386
|
let mtime;
|
|
33604
34387
|
let size;
|
|
33605
34388
|
try {
|
|
33606
|
-
const st =
|
|
34389
|
+
const st = fs86.statSync(absPath);
|
|
33607
34390
|
mtime = st.mtimeMs;
|
|
33608
34391
|
size = st.size;
|
|
33609
34392
|
} catch {
|
|
33610
|
-
return
|
|
34393
|
+
return EXIT_ALLOW29;
|
|
33611
34394
|
}
|
|
33612
34395
|
const prior = ledger.reads[key];
|
|
33613
34396
|
const ownWrite = ledger.writes[key];
|
|
@@ -33622,7 +34405,7 @@ function main55() {
|
|
|
33622
34405
|
if (ownWrite !== void 0) delete ledger.writes[key];
|
|
33623
34406
|
if (advisory !== null) ledger.fired[key] = true;
|
|
33624
34407
|
writeLedger(workspaceRoot3, sessionKey, ledger);
|
|
33625
|
-
if (advisory === null) return
|
|
34408
|
+
if (advisory === null) return EXIT_ALLOW29;
|
|
33626
34409
|
process.stdout.write(
|
|
33627
34410
|
`${JSON.stringify({
|
|
33628
34411
|
decision: "warn",
|
|
@@ -33631,39 +34414,39 @@ function main55() {
|
|
|
33631
34414
|
})}
|
|
33632
34415
|
`
|
|
33633
34416
|
);
|
|
33634
|
-
return
|
|
34417
|
+
return EXIT_WARN16;
|
|
33635
34418
|
} catch {
|
|
33636
|
-
return
|
|
34419
|
+
return EXIT_ALLOW29;
|
|
33637
34420
|
}
|
|
33638
34421
|
}
|
|
33639
|
-
function
|
|
34422
|
+
function _isCliEntry44() {
|
|
33640
34423
|
if (true) {
|
|
33641
34424
|
return false;
|
|
33642
34425
|
}
|
|
33643
34426
|
if (process.argv[1] === void 0) {
|
|
33644
34427
|
return false;
|
|
33645
34428
|
}
|
|
33646
|
-
const argvUrl =
|
|
34429
|
+
const argvUrl = pathToFileURL51(path87.resolve(process.argv[1])).href;
|
|
33647
34430
|
if (import.meta.url === argvUrl) {
|
|
33648
34431
|
return true;
|
|
33649
34432
|
}
|
|
33650
34433
|
try {
|
|
33651
|
-
const here =
|
|
33652
|
-
const argv =
|
|
34434
|
+
const here = fs86.realpathSync(fileURLToPath58(import.meta.url));
|
|
34435
|
+
const argv = fs86.realpathSync(path87.resolve(process.argv[1]));
|
|
33653
34436
|
return here === argv;
|
|
33654
34437
|
} catch {
|
|
33655
34438
|
return false;
|
|
33656
34439
|
}
|
|
33657
34440
|
}
|
|
33658
|
-
if (
|
|
33659
|
-
process.exit(
|
|
34441
|
+
if (_isCliEntry44()) {
|
|
34442
|
+
process.exit(main57());
|
|
33660
34443
|
}
|
|
33661
34444
|
|
|
33662
34445
|
// src/scripts/hooks/session_eol_hook.ts
|
|
33663
|
-
import * as
|
|
33664
|
-
import * as
|
|
33665
|
-
import
|
|
33666
|
-
import { fileURLToPath as
|
|
34446
|
+
import * as fs91 from "node:fs";
|
|
34447
|
+
import * as path93 from "node:path";
|
|
34448
|
+
import process15 from "node:process";
|
|
34449
|
+
import { fileURLToPath as fileURLToPath59, pathToFileURL as pathToFileURL52 } from "node:url";
|
|
33667
34450
|
|
|
33668
34451
|
// src/config/recycle-threshold-budget.json
|
|
33669
34452
|
var recycle_threshold_budget_default = {
|
|
@@ -33681,13 +34464,13 @@ var recycle_threshold_budget_default = {
|
|
|
33681
34464
|
|
|
33682
34465
|
// src/scripts/_lib/session_eol.ts
|
|
33683
34466
|
import * as crypto13 from "node:crypto";
|
|
33684
|
-
import * as
|
|
33685
|
-
import * as
|
|
34467
|
+
import * as fs87 from "node:fs";
|
|
34468
|
+
import * as path89 from "node:path";
|
|
33686
34469
|
|
|
33687
34470
|
// src/scripts/_lib/cc_transcript.ts
|
|
33688
|
-
import * as
|
|
34471
|
+
import * as path88 from "node:path";
|
|
33689
34472
|
import { homedir as homedir7 } from "node:os";
|
|
33690
|
-
var DEFAULT_PROJECTS_ROOT =
|
|
34473
|
+
var DEFAULT_PROJECTS_ROOT = path88.join(homedir7(), ".claude", "projects");
|
|
33691
34474
|
function billableInputTokens(u) {
|
|
33692
34475
|
return u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens;
|
|
33693
34476
|
}
|
|
@@ -33796,17 +34579,17 @@ function scanEolSlice(text, prior) {
|
|
|
33796
34579
|
return next;
|
|
33797
34580
|
}
|
|
33798
34581
|
function eolStateDir(workspaceRoot3) {
|
|
33799
|
-
return
|
|
34582
|
+
return path89.join(workspaceRoot3, "agents", "runtime", "state", "session-eol");
|
|
33800
34583
|
}
|
|
33801
34584
|
function eolStateFile(workspaceRoot3, sessionKey) {
|
|
33802
|
-
return
|
|
34585
|
+
return path89.join(eolStateDir(workspaceRoot3), `${sessionKey}.json`);
|
|
33803
34586
|
}
|
|
33804
34587
|
function eolSessionKey(raw) {
|
|
33805
34588
|
return crypto13.createHash("sha256").update(raw || "unknown-session").digest("hex");
|
|
33806
34589
|
}
|
|
33807
34590
|
function readNewCompleteLines(filePath, fromByte) {
|
|
33808
34591
|
try {
|
|
33809
|
-
const { size } =
|
|
34592
|
+
const { size } = fs87.statSync(filePath);
|
|
33810
34593
|
if (size < fromByte) {
|
|
33811
34594
|
return { text: "", nextOffset: 0, truncated: true };
|
|
33812
34595
|
}
|
|
@@ -33815,11 +34598,11 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
33815
34598
|
}
|
|
33816
34599
|
const length = size - fromByte;
|
|
33817
34600
|
const buffer = Buffer.alloc(length);
|
|
33818
|
-
const fd =
|
|
34601
|
+
const fd = fs87.openSync(filePath, "r");
|
|
33819
34602
|
try {
|
|
33820
|
-
|
|
34603
|
+
fs87.readSync(fd, buffer, 0, length, fromByte);
|
|
33821
34604
|
} finally {
|
|
33822
|
-
|
|
34605
|
+
fs87.closeSync(fd);
|
|
33823
34606
|
}
|
|
33824
34607
|
const lastNewline = buffer.lastIndexOf(10);
|
|
33825
34608
|
if (lastNewline === -1) {
|
|
@@ -33835,9 +34618,112 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
33835
34618
|
}
|
|
33836
34619
|
}
|
|
33837
34620
|
|
|
34621
|
+
// src/scripts/_lib/context_observation.ts
|
|
34622
|
+
import * as fs89 from "node:fs";
|
|
34623
|
+
import * as path91 from "node:path";
|
|
34624
|
+
|
|
34625
|
+
// src/scripts/_lib/loop_guards.ts
|
|
34626
|
+
import * as fs88 from "node:fs";
|
|
34627
|
+
import * as path90 from "node:path";
|
|
34628
|
+
function atomicWriteJson(file, value) {
|
|
34629
|
+
const tmp = `${file}.${String(process.pid)}.tmp`;
|
|
34630
|
+
try {
|
|
34631
|
+
fs88.mkdirSync(path90.dirname(file), { recursive: true });
|
|
34632
|
+
fs88.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
34633
|
+
`, "utf8");
|
|
34634
|
+
fs88.renameSync(tmp, file);
|
|
34635
|
+
return true;
|
|
34636
|
+
} catch {
|
|
34637
|
+
try {
|
|
34638
|
+
fs88.unlinkSync(tmp);
|
|
34639
|
+
} catch {
|
|
34640
|
+
}
|
|
34641
|
+
return false;
|
|
34642
|
+
}
|
|
34643
|
+
}
|
|
34644
|
+
var DEPENDENCY_PATTERNS = [
|
|
34645
|
+
{ kind: "binary", re: /\b(?:command not found|is not recognized as an internal or external command)\b/i },
|
|
34646
|
+
{ kind: "credential", re: /\b(?:not (?:authenticated|logged in)|authentication (?:failed|required)|no credentials found)\b/i },
|
|
34647
|
+
{ kind: "credential", re: /\b(?:missing|unset|not set)\b[^\n]{0,40}\b(?:credential|token|api[_ -]?key|secret)\b/i },
|
|
34648
|
+
{ kind: "permission", re: /\b(?:permission denied|forbidden|403 forbidden)\b/i },
|
|
34649
|
+
{ kind: "quota", re: /\b(?:rate limit(?:ed| exceeded| reached)?|quota exceeded|429 too many requests|spend (?:cap|limit) reached)\b/i },
|
|
34650
|
+
{ kind: "service", re: /\b(?:5\d\d (?:internal )?server error|service unavailable|connection refused)\b/i }
|
|
34651
|
+
];
|
|
34652
|
+
var DEPENDENCY_SCAN_BYTES = 64 * 1024;
|
|
34653
|
+
function detectUnavailableDependency(transcriptTail, tailLines = 200) {
|
|
34654
|
+
const lines = transcriptTail.split("\n");
|
|
34655
|
+
const window = lines.slice(Math.max(0, lines.length - tailLines));
|
|
34656
|
+
for (const line of window) {
|
|
34657
|
+
for (const { kind, re } of DEPENDENCY_PATTERNS) {
|
|
34658
|
+
if (re.test(line)) {
|
|
34659
|
+
return { kind, evidence: line.trim().slice(0, 200) };
|
|
34660
|
+
}
|
|
34661
|
+
}
|
|
34662
|
+
}
|
|
34663
|
+
return null;
|
|
34664
|
+
}
|
|
34665
|
+
function stallSignal(history, window = 3) {
|
|
34666
|
+
if (history.length === 0) {
|
|
34667
|
+
return { level: "flat", flatRun: 0, minimum: null, newMinimum: false };
|
|
34668
|
+
}
|
|
34669
|
+
const last = history[history.length - 1];
|
|
34670
|
+
const minimum = Math.min(...history);
|
|
34671
|
+
const earlier = history.slice(0, -1);
|
|
34672
|
+
const newMinimum = earlier.length > 0 && last < Math.min(...earlier);
|
|
34673
|
+
let flatRun = 1;
|
|
34674
|
+
for (let i = history.length - 2; i >= 0; i -= 1) {
|
|
34675
|
+
if (history[i] !== last) break;
|
|
34676
|
+
flatRun += 1;
|
|
34677
|
+
}
|
|
34678
|
+
if (newMinimum) return { level: "progressing", flatRun, minimum, newMinimum };
|
|
34679
|
+
if (flatRun >= window) return { level: "stalled", flatRun, minimum, newMinimum };
|
|
34680
|
+
return { level: "flat", flatRun, minimum, newMinimum };
|
|
34681
|
+
}
|
|
34682
|
+
function readUnavailableDependency(transcriptPath) {
|
|
34683
|
+
try {
|
|
34684
|
+
const raw = fs88.readFileSync(transcriptPath, "utf8");
|
|
34685
|
+
return detectUnavailableDependency(raw.slice(-DEPENDENCY_SCAN_BYTES));
|
|
34686
|
+
} catch {
|
|
34687
|
+
return null;
|
|
34688
|
+
}
|
|
34689
|
+
}
|
|
34690
|
+
|
|
34691
|
+
// src/scripts/_lib/context_observation.ts
|
|
34692
|
+
var CONTEXT_OBSERVATION_REL = path91.join(
|
|
34693
|
+
"agents",
|
|
34694
|
+
"runtime",
|
|
34695
|
+
"state",
|
|
34696
|
+
"context-observation.json"
|
|
34697
|
+
);
|
|
34698
|
+
function observationFile(repoRoot) {
|
|
34699
|
+
return path91.join(repoRoot, CONTEXT_OBSERVATION_REL);
|
|
34700
|
+
}
|
|
34701
|
+
function readContextObservation(repoRoot) {
|
|
34702
|
+
try {
|
|
34703
|
+
const parsed = JSON.parse(fs89.readFileSync(observationFile(repoRoot), "utf-8"));
|
|
34704
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
34705
|
+
const o = parsed;
|
|
34706
|
+
if (typeof o["fingerprint"] !== "string" || o["fingerprint"] === "") return null;
|
|
34707
|
+
if (typeof o["at"] !== "string") return null;
|
|
34708
|
+
return {
|
|
34709
|
+
schema_version: 1,
|
|
34710
|
+
roadmap: typeof o["roadmap"] === "string" ? o["roadmap"] : "",
|
|
34711
|
+
fingerprint: o["fingerprint"],
|
|
34712
|
+
at: o["at"]
|
|
34713
|
+
};
|
|
34714
|
+
} catch {
|
|
34715
|
+
return null;
|
|
34716
|
+
}
|
|
34717
|
+
}
|
|
34718
|
+
function premiseMoved(claimed, observed) {
|
|
34719
|
+
if (claimed === null || claimed === void 0 || claimed === "") return false;
|
|
34720
|
+
if (observed === null || observed === void 0 || observed === "") return false;
|
|
34721
|
+
return claimed !== observed;
|
|
34722
|
+
}
|
|
34723
|
+
|
|
33838
34724
|
// src/scripts/_lib/run_checkpoint.ts
|
|
33839
|
-
import * as
|
|
33840
|
-
import * as
|
|
34725
|
+
import * as fs90 from "node:fs";
|
|
34726
|
+
import * as path92 from "node:path";
|
|
33841
34727
|
|
|
33842
34728
|
// src/scripts/_lib/roadmap_checkboxes.ts
|
|
33843
34729
|
var CHECKBOX_LINE = /^[ \t]*[-*][ \t]+\[([ xX~-])\][ \t]+(.*)$/;
|
|
@@ -33867,7 +34753,7 @@ function phaseLines(text) {
|
|
|
33867
34753
|
}
|
|
33868
34754
|
|
|
33869
34755
|
// src/scripts/_lib/run_checkpoint.ts
|
|
33870
|
-
var CHECKPOINT_DIR_REL =
|
|
34756
|
+
var CHECKPOINT_DIR_REL = path92.join("agents", "runtime", "state", "checkpoints");
|
|
33871
34757
|
function countRoadmap(text) {
|
|
33872
34758
|
const counts = { open: 0, done: 0, parked: 0, next: null };
|
|
33873
34759
|
for (const raw of phaseLines(text)) {
|
|
@@ -33888,34 +34774,34 @@ function countRoadmap(text) {
|
|
|
33888
34774
|
return counts;
|
|
33889
34775
|
}
|
|
33890
34776
|
function checkpointFile(repoRoot, runId) {
|
|
33891
|
-
return
|
|
34777
|
+
return path92.join(repoRoot, CHECKPOINT_DIR_REL, `${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
|
|
33892
34778
|
}
|
|
33893
34779
|
function roadmapPath(repoRoot, slug) {
|
|
33894
|
-
return
|
|
34780
|
+
return path92.join(repoRoot, "agents", "roadmaps", `${slug}.md`);
|
|
33895
34781
|
}
|
|
33896
34782
|
function readHead(repoRoot) {
|
|
33897
34783
|
try {
|
|
33898
|
-
let gitDir =
|
|
33899
|
-
if (
|
|
33900
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
34784
|
+
let gitDir = path92.join(repoRoot, ".git");
|
|
34785
|
+
if (fs90.statSync(gitDir).isFile()) {
|
|
34786
|
+
const m = /^gitdir:\s*(.+)$/m.exec(fs90.readFileSync(gitDir, "utf-8").trim());
|
|
33901
34787
|
if (m === null) return null;
|
|
33902
|
-
gitDir =
|
|
34788
|
+
gitDir = path92.resolve(repoRoot, m[1]);
|
|
33903
34789
|
}
|
|
33904
34790
|
let refRoot = gitDir;
|
|
33905
34791
|
try {
|
|
33906
|
-
const common =
|
|
33907
|
-
if (common !== "") refRoot =
|
|
34792
|
+
const common = fs90.readFileSync(path92.join(gitDir, "commondir"), "utf-8").trim();
|
|
34793
|
+
if (common !== "") refRoot = path92.resolve(gitDir, common);
|
|
33908
34794
|
} catch {
|
|
33909
34795
|
}
|
|
33910
|
-
const head =
|
|
34796
|
+
const head = fs90.readFileSync(path92.join(gitDir, "HEAD"), "utf-8").trim();
|
|
33911
34797
|
if (/^[0-9a-f]{40}$/.test(head)) return head;
|
|
33912
34798
|
const ref = /^ref:\s*(.+)$/.exec(head);
|
|
33913
34799
|
if (ref === null) return null;
|
|
33914
34800
|
const refName = ref[1];
|
|
33915
34801
|
try {
|
|
33916
|
-
return
|
|
34802
|
+
return fs90.readFileSync(path92.join(refRoot, refName), "utf-8").trim() || null;
|
|
33917
34803
|
} catch {
|
|
33918
|
-
const packed =
|
|
34804
|
+
const packed = fs90.readFileSync(path92.join(refRoot, "packed-refs"), "utf-8");
|
|
33919
34805
|
for (const line of packed.split("\n")) {
|
|
33920
34806
|
const pm = /^([0-9a-f]{40})\s+(.+)$/.exec(line.trim());
|
|
33921
34807
|
if (pm !== null && pm[2] === refName) return pm[1];
|
|
@@ -33929,7 +34815,7 @@ function readHead(repoRoot) {
|
|
|
33929
34815
|
function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
|
|
33930
34816
|
let text;
|
|
33931
34817
|
try {
|
|
33932
|
-
text =
|
|
34818
|
+
text = fs90.readFileSync(roadmapPath(repoRoot, slug), "utf-8");
|
|
33933
34819
|
} catch {
|
|
33934
34820
|
return null;
|
|
33935
34821
|
}
|
|
@@ -33953,8 +34839,8 @@ function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
|
|
|
33953
34839
|
function writeCheckpoint(repoRoot, cp) {
|
|
33954
34840
|
const file = checkpointFile(repoRoot, cp.run_id);
|
|
33955
34841
|
try {
|
|
33956
|
-
|
|
33957
|
-
|
|
34842
|
+
fs90.mkdirSync(path92.dirname(file), { recursive: true });
|
|
34843
|
+
fs90.writeFileSync(file, `${JSON.stringify(cp, null, 2)}
|
|
33958
34844
|
`, "utf-8");
|
|
33959
34845
|
return file;
|
|
33960
34846
|
} catch {
|
|
@@ -33963,24 +34849,24 @@ function writeCheckpoint(repoRoot, cp) {
|
|
|
33963
34849
|
}
|
|
33964
34850
|
|
|
33965
34851
|
// src/scripts/hooks/session_eol_hook.ts
|
|
33966
|
-
var
|
|
34852
|
+
var EXIT_WARN17 = 2;
|
|
33967
34853
|
var THRESHOLD_OVERRIDE_ENV = "AGENT_RECYCLE_THRESHOLD_TOKENS";
|
|
33968
|
-
var CONTEXT_FILL_REL =
|
|
33969
|
-
function
|
|
34854
|
+
var CONTEXT_FILL_REL = path93.join("agents", "runtime", "state", "context-fill.json");
|
|
34855
|
+
function str12(value) {
|
|
33970
34856
|
return typeof value === "string" ? value : "";
|
|
33971
34857
|
}
|
|
33972
34858
|
var stateFile3 = eolStateFile;
|
|
33973
34859
|
function deriveSessionKey5(envelope, payload) {
|
|
33974
34860
|
return eolSessionKey(
|
|
33975
|
-
|
|
34861
|
+
str12(envelope["session_id"]) || str12(payload["transcript_path"] ?? payload["transcriptPath"])
|
|
33976
34862
|
);
|
|
33977
34863
|
}
|
|
33978
34864
|
function payloadSessionId(payload, envelope) {
|
|
33979
|
-
return (
|
|
34865
|
+
return (str12(payload["session_id"]) || str12(envelope["session_id"])).trim();
|
|
33980
34866
|
}
|
|
33981
34867
|
function readState4(file) {
|
|
33982
34868
|
try {
|
|
33983
|
-
const parsed = JSON.parse(
|
|
34869
|
+
const parsed = JSON.parse(fs91.readFileSync(file, "utf-8"));
|
|
33984
34870
|
if (parsed && typeof parsed === "object" && parsed.schema_version === 1 && parsed.counters && typeof parsed.counters.scanned_bytes === "number") {
|
|
33985
34871
|
return {
|
|
33986
34872
|
schema_version: 1,
|
|
@@ -34001,10 +34887,10 @@ function readState4(file) {
|
|
|
34001
34887
|
};
|
|
34002
34888
|
}
|
|
34003
34889
|
function envelopeExists(workspaceRoot3, since = null) {
|
|
34004
|
-
const target =
|
|
34890
|
+
const target = path93.join(workspaceRoot3, RECYCLE_ENVELOPE_REL);
|
|
34005
34891
|
let raw;
|
|
34006
34892
|
try {
|
|
34007
|
-
raw =
|
|
34893
|
+
raw = fs91.readFileSync(target, "utf-8");
|
|
34008
34894
|
} catch (exc) {
|
|
34009
34895
|
return exc?.code !== "ENOENT";
|
|
34010
34896
|
}
|
|
@@ -34018,10 +34904,10 @@ function envelopeExists(workspaceRoot3, since = null) {
|
|
|
34018
34904
|
}
|
|
34019
34905
|
}
|
|
34020
34906
|
function buildMissingEnvelopeLine(workspaceRoot3) {
|
|
34021
|
-
return `recycle advised earlier, but no envelope exists at ${
|
|
34907
|
+
return `recycle advised earlier, but no envelope exists at ${path93.join(workspaceRoot3, RECYCLE_ENVELOPE_REL)} \u2014 /clear now starts the successor from nothing. Re-run \`agent-config session:recycle\` and check that it prints the absolute path it wrote before clearing.`;
|
|
34022
34908
|
}
|
|
34023
34909
|
function readThresholdTokens() {
|
|
34024
|
-
const override =
|
|
34910
|
+
const override = process15.env[THRESHOLD_OVERRIDE_ENV];
|
|
34025
34911
|
if (override !== void 0) {
|
|
34026
34912
|
const value2 = Number(override);
|
|
34027
34913
|
return Number.isFinite(value2) && value2 > 0 ? value2 : null;
|
|
@@ -34029,12 +34915,12 @@ function readThresholdTokens() {
|
|
|
34029
34915
|
const value = recycle_threshold_budget_default["recycle_threshold_tokens"];
|
|
34030
34916
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
34031
34917
|
}
|
|
34032
|
-
function
|
|
34918
|
+
function buildAdvisoryLine4(tokens, threshold) {
|
|
34033
34919
|
return `context past recycle threshold (${tokens.toLocaleString("en-US")} of ${threshold.toLocaleString("en-US")} tokens): run \`agent-config session:recycle\` to write the recycle envelope. It prints the absolute path it wrote \u2014 /clear only after you have seen that line. The successor session then resumes from the envelope at session_start (road-to-token-economy-recycling)`;
|
|
34034
34920
|
}
|
|
34035
34921
|
function writeContextFill(workspaceRoot3, tokens, threshold, ts) {
|
|
34036
34922
|
try {
|
|
34037
|
-
atomic_write_json(
|
|
34923
|
+
atomic_write_json(path93.join(workspaceRoot3, CONTEXT_FILL_REL), {
|
|
34038
34924
|
schema_version: 1,
|
|
34039
34925
|
final_context_tokens: tokens,
|
|
34040
34926
|
recycle_threshold_tokens: threshold,
|
|
@@ -34044,7 +34930,7 @@ function writeContextFill(workspaceRoot3, tokens, threshold, ts) {
|
|
|
34044
34930
|
} catch {
|
|
34045
34931
|
}
|
|
34046
34932
|
}
|
|
34047
|
-
function
|
|
34933
|
+
function main58() {
|
|
34048
34934
|
const [envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
34049
34935
|
const event = String(envelope["event"] ?? "");
|
|
34050
34936
|
if (event !== "" && event !== "stop") {
|
|
@@ -34053,8 +34939,8 @@ function main56() {
|
|
|
34053
34939
|
if (is_replay_mode()) {
|
|
34054
34940
|
return 0;
|
|
34055
34941
|
}
|
|
34056
|
-
const workspaceRoot3 = String(envelope["workspace_root"] ?? "").trim() ||
|
|
34057
|
-
const transcriptPath =
|
|
34942
|
+
const workspaceRoot3 = String(envelope["workspace_root"] ?? "").trim() || process15.cwd();
|
|
34943
|
+
const transcriptPath = str12(
|
|
34058
34944
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
34059
34945
|
).trim();
|
|
34060
34946
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath)) {
|
|
@@ -34097,25 +34983,28 @@ function main56() {
|
|
|
34097
34983
|
try {
|
|
34098
34984
|
const slug = read_claimed_slug(workspaceRoot3, checkpointRunId);
|
|
34099
34985
|
if (slug !== null) {
|
|
34100
|
-
const
|
|
34986
|
+
const observed = readContextObservation(workspaceRoot3)?.fingerprint ?? null;
|
|
34987
|
+
const cp = buildCheckpoint(workspaceRoot3, eolSessionKey(checkpointRunId), slug, {
|
|
34988
|
+
...observed !== null ? { contextFingerprint: observed } : {}
|
|
34989
|
+
});
|
|
34101
34990
|
if (cp !== null) writeCheckpoint(workspaceRoot3, cp);
|
|
34102
34991
|
}
|
|
34103
34992
|
} catch {
|
|
34104
34993
|
}
|
|
34105
34994
|
}
|
|
34106
34995
|
if (shouldAdvise && threshold !== null && tokens !== null) {
|
|
34107
|
-
|
|
34996
|
+
process15.stdout.write(
|
|
34108
34997
|
`${JSON.stringify({
|
|
34109
34998
|
decision: "warn",
|
|
34110
34999
|
reason: `session-eol: context ${tokens} >= recycle threshold ${threshold}`,
|
|
34111
|
-
additional_context:
|
|
35000
|
+
additional_context: buildAdvisoryLine4(tokens, threshold)
|
|
34112
35001
|
})}
|
|
34113
35002
|
`
|
|
34114
35003
|
);
|
|
34115
|
-
return
|
|
35004
|
+
return EXIT_WARN17;
|
|
34116
35005
|
}
|
|
34117
35006
|
if (shouldWarnMissing) {
|
|
34118
|
-
|
|
35007
|
+
process15.stdout.write(
|
|
34119
35008
|
`${JSON.stringify({
|
|
34120
35009
|
decision: "warn",
|
|
34121
35010
|
reason: "session-eol: recycle advised, no envelope written",
|
|
@@ -34123,42 +35012,42 @@ function main56() {
|
|
|
34123
35012
|
})}
|
|
34124
35013
|
`
|
|
34125
35014
|
);
|
|
34126
|
-
return
|
|
35015
|
+
return EXIT_WARN17;
|
|
34127
35016
|
}
|
|
34128
35017
|
return 0;
|
|
34129
35018
|
}
|
|
34130
|
-
function
|
|
35019
|
+
function _isCliEntry45() {
|
|
34131
35020
|
if (true) {
|
|
34132
35021
|
return false;
|
|
34133
35022
|
}
|
|
34134
|
-
if (
|
|
35023
|
+
if (process15.argv[1] === void 0) {
|
|
34135
35024
|
return false;
|
|
34136
35025
|
}
|
|
34137
|
-
const argvUrl =
|
|
35026
|
+
const argvUrl = pathToFileURL52(path93.resolve(process15.argv[1])).href;
|
|
34138
35027
|
if (import.meta.url === argvUrl) {
|
|
34139
35028
|
return true;
|
|
34140
35029
|
}
|
|
34141
35030
|
try {
|
|
34142
|
-
const here =
|
|
34143
|
-
const argv =
|
|
35031
|
+
const here = fs91.realpathSync(fileURLToPath59(import.meta.url));
|
|
35032
|
+
const argv = fs91.realpathSync(path93.resolve(process15.argv[1]));
|
|
34144
35033
|
return here === argv;
|
|
34145
35034
|
} catch {
|
|
34146
35035
|
return false;
|
|
34147
35036
|
}
|
|
34148
35037
|
}
|
|
34149
|
-
if (
|
|
34150
|
-
|
|
35038
|
+
if (_isCliEntry45()) {
|
|
35039
|
+
process15.exit(main58());
|
|
34151
35040
|
}
|
|
34152
35041
|
|
|
34153
35042
|
// src/scripts/hooks/tool_result_bytes_hook.ts
|
|
34154
|
-
import * as
|
|
34155
|
-
import * as
|
|
34156
|
-
import { fileURLToPath as
|
|
34157
|
-
var
|
|
34158
|
-
function
|
|
35043
|
+
import * as fs92 from "node:fs";
|
|
35044
|
+
import * as path94 from "node:path";
|
|
35045
|
+
import { fileURLToPath as fileURLToPath60, pathToFileURL as pathToFileURL53 } from "node:url";
|
|
35046
|
+
var EXIT_ALLOW30 = 0;
|
|
35047
|
+
function isObject15(v) {
|
|
34159
35048
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
34160
35049
|
}
|
|
34161
|
-
var CENSUS_FILE =
|
|
35050
|
+
var CENSUS_FILE = path94.join("agents", "runtime", "state", "tool-result-census.jsonl");
|
|
34162
35051
|
var RESULT_KEYS = ["tool_response", "toolResponse", "tool_result", "toolUseResult"];
|
|
34163
35052
|
function _resultBytes(payload) {
|
|
34164
35053
|
for (const key of RESULT_KEYS) {
|
|
@@ -34190,22 +35079,22 @@ function _toolName(payload, envelope) {
|
|
|
34190
35079
|
}
|
|
34191
35080
|
function unwrapPayload4(envelope) {
|
|
34192
35081
|
const inner = envelope["payload"];
|
|
34193
|
-
return
|
|
35082
|
+
return isObject15(inner) ? inner : envelope;
|
|
34194
35083
|
}
|
|
34195
35084
|
function censusFile(consumerRoot) {
|
|
34196
|
-
return
|
|
35085
|
+
return path94.join(consumerRoot, CENSUS_FILE);
|
|
34197
35086
|
}
|
|
34198
35087
|
function _appendCensusLine(consumerRoot, line) {
|
|
34199
35088
|
if (is_replay_mode()) return;
|
|
34200
35089
|
const file = censusFile(consumerRoot);
|
|
34201
|
-
|
|
34202
|
-
|
|
35090
|
+
fs92.mkdirSync(path94.dirname(file), { recursive: true });
|
|
35091
|
+
fs92.appendFileSync(file, `${JSON.stringify(line)}
|
|
34203
35092
|
`, "utf8");
|
|
34204
35093
|
}
|
|
34205
35094
|
function processEnvelope4(envelope, consumerRoot) {
|
|
34206
35095
|
try {
|
|
34207
|
-
if (!
|
|
34208
|
-
if (envelope["event"] !== "post_tool_use") return
|
|
35096
|
+
if (!isObject15(envelope)) return EXIT_ALLOW30;
|
|
35097
|
+
if (envelope["event"] !== "post_tool_use") return EXIT_ALLOW30;
|
|
34209
35098
|
const payload = unwrapPayload4(envelope);
|
|
34210
35099
|
const bytes = _resultBytes(payload);
|
|
34211
35100
|
_appendCensusLine(consumerRoot, {
|
|
@@ -34215,12 +35104,12 @@ function processEnvelope4(envelope, consumerRoot) {
|
|
|
34215
35104
|
measurable: bytes !== null
|
|
34216
35105
|
});
|
|
34217
35106
|
} catch {
|
|
34218
|
-
return
|
|
35107
|
+
return EXIT_ALLOW30;
|
|
34219
35108
|
}
|
|
34220
|
-
return
|
|
35109
|
+
return EXIT_ALLOW30;
|
|
34221
35110
|
}
|
|
34222
35111
|
function resolveConsumerRoot2(envelope) {
|
|
34223
|
-
if (
|
|
35112
|
+
if (isObject15(envelope)) {
|
|
34224
35113
|
for (const key of ["workspace_root", "project_root"]) {
|
|
34225
35114
|
const v = envelope[key];
|
|
34226
35115
|
if (typeof v === "string" && v) return v;
|
|
@@ -34230,37 +35119,37 @@ function resolveConsumerRoot2(envelope) {
|
|
|
34230
35119
|
}
|
|
34231
35120
|
return process.cwd();
|
|
34232
35121
|
}
|
|
34233
|
-
function
|
|
35122
|
+
function main59() {
|
|
34234
35123
|
const raw = readHookStdin();
|
|
34235
35124
|
let envelope = {};
|
|
34236
35125
|
try {
|
|
34237
35126
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
34238
35127
|
} catch {
|
|
34239
|
-
return
|
|
35128
|
+
return EXIT_ALLOW30;
|
|
34240
35129
|
}
|
|
34241
35130
|
return processEnvelope4(envelope, resolveConsumerRoot2(envelope));
|
|
34242
35131
|
}
|
|
34243
|
-
function
|
|
35132
|
+
function _isCliEntry46() {
|
|
34244
35133
|
if (true) {
|
|
34245
35134
|
return false;
|
|
34246
35135
|
}
|
|
34247
35136
|
if (process.argv[1] === void 0) return false;
|
|
34248
|
-
const argvUrl =
|
|
35137
|
+
const argvUrl = pathToFileURL53(path94.resolve(process.argv[1])).href;
|
|
34249
35138
|
if (import.meta.url === argvUrl) return true;
|
|
34250
35139
|
try {
|
|
34251
|
-
return
|
|
35140
|
+
return fs92.realpathSync(fileURLToPath60(import.meta.url)) === fs92.realpathSync(path94.resolve(process.argv[1]));
|
|
34252
35141
|
} catch {
|
|
34253
35142
|
return false;
|
|
34254
35143
|
}
|
|
34255
35144
|
}
|
|
34256
|
-
if (
|
|
35145
|
+
if (_isCliEntry46()) process.exit(main59());
|
|
34257
35146
|
|
|
34258
35147
|
// src/scripts/hooks/spawn_guard_shadow_hook.ts
|
|
34259
|
-
import * as
|
|
34260
|
-
import * as
|
|
34261
|
-
import { fileURLToPath as
|
|
34262
|
-
var
|
|
34263
|
-
function
|
|
35148
|
+
import * as fs93 from "node:fs";
|
|
35149
|
+
import * as path95 from "node:path";
|
|
35150
|
+
import { fileURLToPath as fileURLToPath61, pathToFileURL as pathToFileURL54 } from "node:url";
|
|
35151
|
+
var EXIT_ALLOW31 = 0;
|
|
35152
|
+
function isObject16(v) {
|
|
34264
35153
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
34265
35154
|
}
|
|
34266
35155
|
var DISPATCH_TOOL_NAMES2 = /* @__PURE__ */ new Set(["Agent", "Task"]);
|
|
@@ -34279,7 +35168,7 @@ function evaluateCandidates(depthEstimate, concurrentOpen) {
|
|
|
34279
35168
|
}
|
|
34280
35169
|
function unwrapPayload5(envelope) {
|
|
34281
35170
|
const inner = envelope["payload"];
|
|
34282
|
-
return
|
|
35171
|
+
return isObject16(inner) ? inner : envelope;
|
|
34283
35172
|
}
|
|
34284
35173
|
function extractToolName5(payload) {
|
|
34285
35174
|
const v = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
|
|
@@ -34287,10 +35176,10 @@ function extractToolName5(payload) {
|
|
|
34287
35176
|
}
|
|
34288
35177
|
function processEnvelope5(envelope, consumerRoot) {
|
|
34289
35178
|
try {
|
|
34290
|
-
if (!
|
|
35179
|
+
if (!isObject16(envelope)) return EXIT_ALLOW31;
|
|
34291
35180
|
const payload = unwrapPayload5(envelope);
|
|
34292
35181
|
const toolName2 = extractToolName5(payload);
|
|
34293
|
-
if (toolName2 === null || !DISPATCH_TOOL_NAMES2.has(toolName2)) return
|
|
35182
|
+
if (toolName2 === null || !DISPATCH_TOOL_NAMES2.has(toolName2)) return EXIT_ALLOW31;
|
|
34294
35183
|
const stats = openRecordStats(consumerRoot);
|
|
34295
35184
|
const depthEstimate = stats.max_depth + 1;
|
|
34296
35185
|
const verdicts = evaluateCandidates(depthEstimate, stats.open_count);
|
|
@@ -34318,47 +35207,47 @@ function processEnvelope5(envelope, consumerRoot) {
|
|
|
34318
35207
|
posture: "shadow"
|
|
34319
35208
|
});
|
|
34320
35209
|
} catch {
|
|
34321
|
-
return
|
|
35210
|
+
return EXIT_ALLOW31;
|
|
34322
35211
|
}
|
|
34323
|
-
return
|
|
35212
|
+
return EXIT_ALLOW31;
|
|
34324
35213
|
}
|
|
34325
|
-
function
|
|
35214
|
+
function main60() {
|
|
34326
35215
|
const raw = readHookStdin();
|
|
34327
35216
|
let envelope = {};
|
|
34328
35217
|
try {
|
|
34329
35218
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
34330
35219
|
} catch {
|
|
34331
|
-
return
|
|
35220
|
+
return EXIT_ALLOW31;
|
|
34332
35221
|
}
|
|
34333
35222
|
return processEnvelope5(envelope, resolveConsumerRoot(envelope));
|
|
34334
35223
|
}
|
|
34335
|
-
function
|
|
35224
|
+
function _isCliEntry47() {
|
|
34336
35225
|
if (true) return false;
|
|
34337
35226
|
if (process.argv[1] === void 0) return false;
|
|
34338
|
-
const argvUrl =
|
|
35227
|
+
const argvUrl = pathToFileURL54(path95.resolve(process.argv[1])).href;
|
|
34339
35228
|
if (import.meta.url === argvUrl) return true;
|
|
34340
35229
|
try {
|
|
34341
|
-
return
|
|
35230
|
+
return fs93.realpathSync(fileURLToPath61(import.meta.url)) === fs93.realpathSync(path95.resolve(process.argv[1]));
|
|
34342
35231
|
} catch {
|
|
34343
35232
|
return false;
|
|
34344
35233
|
}
|
|
34345
35234
|
}
|
|
34346
|
-
if (
|
|
35235
|
+
if (_isCliEntry47()) process.exit(main60());
|
|
34347
35236
|
|
|
34348
35237
|
// src/scripts/hooks/source_first_gate_hook.ts
|
|
34349
|
-
import * as
|
|
34350
|
-
import * as
|
|
34351
|
-
import { fileURLToPath as
|
|
34352
|
-
var
|
|
35238
|
+
import * as fs94 from "node:fs";
|
|
35239
|
+
import * as path96 from "node:path";
|
|
35240
|
+
import { fileURLToPath as fileURLToPath62, pathToFileURL as pathToFileURL55 } from "node:url";
|
|
35241
|
+
var EXIT_ALLOW32 = 0;
|
|
34353
35242
|
var MAX_SHADOW_WARNS = 2;
|
|
34354
|
-
var SHADOW_LOG =
|
|
34355
|
-
var STATE_FILE9 =
|
|
34356
|
-
function
|
|
35243
|
+
var SHADOW_LOG = path96.join("agents", "runtime", "state", "source-first-gate.jsonl");
|
|
35244
|
+
var STATE_FILE9 = path96.join("agents", "runtime", "state", "source-first-gate.json");
|
|
35245
|
+
function isObject17(v) {
|
|
34357
35246
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
34358
35247
|
}
|
|
34359
35248
|
function unwrapPayload6(envelope) {
|
|
34360
35249
|
const inner = envelope["payload"];
|
|
34361
|
-
return
|
|
35250
|
+
return isObject17(inner) ? inner : envelope;
|
|
34362
35251
|
}
|
|
34363
35252
|
var TOOL_MATCHERS = [
|
|
34364
35253
|
{ pattern: /^browser_take_screenshot$/i, hit: { label: "playwright-mcp", capture_kind: "page" } },
|
|
@@ -34378,7 +35267,7 @@ function isHandoverPath(file) {
|
|
|
34378
35267
|
const normalized = file.replace(/\\/g, "/").toLowerCase();
|
|
34379
35268
|
return normalized.endsWith("design.html") || normalized.includes(".claude/design-system/");
|
|
34380
35269
|
}
|
|
34381
|
-
function
|
|
35270
|
+
function str13(o, ...keys) {
|
|
34382
35271
|
for (const k of keys) {
|
|
34383
35272
|
const v = o[k];
|
|
34384
35273
|
if (typeof v === "string" && v) return v;
|
|
@@ -34386,12 +35275,12 @@ function str12(o, ...keys) {
|
|
|
34386
35275
|
return null;
|
|
34387
35276
|
}
|
|
34388
35277
|
function extractEvent2(outer) {
|
|
34389
|
-
if (!
|
|
35278
|
+
if (!isObject17(outer)) return null;
|
|
34390
35279
|
const payload = unwrapPayload6(outer);
|
|
34391
|
-
const toolName2 =
|
|
35280
|
+
const toolName2 = str13(payload, "tool_name", "toolName", "tool");
|
|
34392
35281
|
const ti = payload["tool_input"] ?? payload["toolInput"] ?? payload["input"];
|
|
34393
|
-
const input =
|
|
34394
|
-
const file =
|
|
35282
|
+
const input = isObject17(ti) ? ti : {};
|
|
35283
|
+
const file = str13(input, "file_path", "path", "filePath") ?? "";
|
|
34395
35284
|
let isWrite = false;
|
|
34396
35285
|
for (const key of ["content", "new_string", "new_str", "text", "newText"]) {
|
|
34397
35286
|
if (typeof input[key] === "string" && input[key].length > 0) isWrite = true;
|
|
@@ -34405,7 +35294,7 @@ function extractEvent2(outer) {
|
|
|
34405
35294
|
}
|
|
34406
35295
|
}
|
|
34407
35296
|
if (!capture && SHELL_TOOLS.test(toolName2)) {
|
|
34408
|
-
const command =
|
|
35297
|
+
const command = str13(input, "command", "cmd", "script") ?? "";
|
|
34409
35298
|
for (const m of COMMAND_MATCHERS) {
|
|
34410
35299
|
if (m.pattern.test(command)) {
|
|
34411
35300
|
capture = m.hit;
|
|
@@ -34418,15 +35307,15 @@ function extractEvent2(outer) {
|
|
|
34418
35307
|
capture,
|
|
34419
35308
|
file,
|
|
34420
35309
|
isWrite,
|
|
34421
|
-
agentIdPresent:
|
|
34422
|
-
agentType:
|
|
35310
|
+
agentIdPresent: str13(payload, "agent_id", "agentId") !== null,
|
|
35311
|
+
agentType: str13(payload, "agent_type", "agentType")
|
|
34423
35312
|
};
|
|
34424
35313
|
}
|
|
34425
35314
|
var EMPTY_STATE = { handoverSeen: false, sourceRead: false, wouldWarn: 0 };
|
|
34426
35315
|
var MAX_SESSIONS2 = 50;
|
|
34427
35316
|
function readState5(root, session) {
|
|
34428
35317
|
try {
|
|
34429
|
-
const all = JSON.parse(
|
|
35318
|
+
const all = JSON.parse(fs94.readFileSync(path96.join(root, STATE_FILE9), "utf-8"));
|
|
34430
35319
|
const entry = all[session];
|
|
34431
35320
|
if (entry && typeof entry.handoverSeen === "boolean" && typeof entry.sourceRead === "boolean" && typeof entry.wouldWarn === "number") {
|
|
34432
35321
|
return entry;
|
|
@@ -34438,13 +35327,13 @@ function readState5(root, session) {
|
|
|
34438
35327
|
function writeState4(root, session, state) {
|
|
34439
35328
|
if (is_replay_mode()) return;
|
|
34440
35329
|
try {
|
|
34441
|
-
const file =
|
|
35330
|
+
const file = path96.join(root, STATE_FILE9);
|
|
34442
35331
|
let all = {};
|
|
34443
35332
|
try {
|
|
34444
|
-
all = JSON.parse(
|
|
35333
|
+
all = JSON.parse(fs94.readFileSync(file, "utf-8"));
|
|
34445
35334
|
} catch {
|
|
34446
35335
|
}
|
|
34447
|
-
if (!
|
|
35336
|
+
if (!isObject17(all)) all = {};
|
|
34448
35337
|
all[session] = state;
|
|
34449
35338
|
const keys = Object.keys(all);
|
|
34450
35339
|
if (keys.length > MAX_SESSIONS2) {
|
|
@@ -34452,8 +35341,8 @@ function writeState4(root, session, state) {
|
|
|
34452
35341
|
for (const key of keys.slice(keys.length - MAX_SESSIONS2)) pruned[key] = all[key];
|
|
34453
35342
|
all = pruned;
|
|
34454
35343
|
}
|
|
34455
|
-
|
|
34456
|
-
|
|
35344
|
+
fs94.mkdirSync(path96.dirname(file), { recursive: true });
|
|
35345
|
+
fs94.writeFileSync(file, JSON.stringify(all));
|
|
34457
35346
|
} catch {
|
|
34458
35347
|
}
|
|
34459
35348
|
}
|
|
@@ -34474,7 +35363,7 @@ function evaluateCandidates2(handoverSeen, handoverOnDisk, sourceRead) {
|
|
|
34474
35363
|
}
|
|
34475
35364
|
function handoverPresentOnDisk(root) {
|
|
34476
35365
|
try {
|
|
34477
|
-
return
|
|
35366
|
+
return fs94.statSync(path96.join(root, ".claude", "design-system")).isDirectory();
|
|
34478
35367
|
} catch {
|
|
34479
35368
|
return false;
|
|
34480
35369
|
}
|
|
@@ -34482,9 +35371,9 @@ function handoverPresentOnDisk(root) {
|
|
|
34482
35371
|
function appendShadowLine(root, line) {
|
|
34483
35372
|
if (is_replay_mode()) return;
|
|
34484
35373
|
try {
|
|
34485
|
-
const file =
|
|
34486
|
-
|
|
34487
|
-
|
|
35374
|
+
const file = path96.join(root, SHADOW_LOG);
|
|
35375
|
+
fs94.mkdirSync(path96.dirname(file), { recursive: true });
|
|
35376
|
+
fs94.appendFileSync(file, `${JSON.stringify(line)}
|
|
34488
35377
|
`, "utf8");
|
|
34489
35378
|
} catch {
|
|
34490
35379
|
}
|
|
@@ -34498,14 +35387,14 @@ function nextState2(event, state) {
|
|
|
34498
35387
|
function processEnvelope6(envelope, consumerRoot, session) {
|
|
34499
35388
|
try {
|
|
34500
35389
|
const event = extractEvent2(envelope);
|
|
34501
|
-
if (!event) return
|
|
35390
|
+
if (!event) return EXIT_ALLOW32;
|
|
34502
35391
|
const before = readState5(consumerRoot, session);
|
|
34503
35392
|
const after = nextState2(event, before);
|
|
34504
35393
|
if (event.capture === null) {
|
|
34505
35394
|
if (after.handoverSeen !== before.handoverSeen || after.sourceRead !== before.sourceRead) {
|
|
34506
35395
|
writeState4(consumerRoot, session, after);
|
|
34507
35396
|
}
|
|
34508
|
-
return
|
|
35397
|
+
return EXIT_ALLOW32;
|
|
34509
35398
|
}
|
|
34510
35399
|
const onDisk = handoverPresentOnDisk(consumerRoot);
|
|
34511
35400
|
const verdicts = evaluateCandidates2(after.handoverSeen, onDisk, after.sourceRead);
|
|
@@ -34541,42 +35430,42 @@ function processEnvelope6(envelope, consumerRoot, session) {
|
|
|
34541
35430
|
const persisted = anyWarn && !valveWouldSilence ? { ...after, wouldWarn: after.wouldWarn + 1 } : after;
|
|
34542
35431
|
writeState4(consumerRoot, session, persisted);
|
|
34543
35432
|
} catch {
|
|
34544
|
-
return
|
|
35433
|
+
return EXIT_ALLOW32;
|
|
34545
35434
|
}
|
|
34546
|
-
return
|
|
35435
|
+
return EXIT_ALLOW32;
|
|
34547
35436
|
}
|
|
34548
|
-
function
|
|
35437
|
+
function main61() {
|
|
34549
35438
|
const raw = readHookStdin();
|
|
34550
35439
|
let envelope = {};
|
|
34551
35440
|
try {
|
|
34552
35441
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
34553
35442
|
} catch {
|
|
34554
|
-
return
|
|
35443
|
+
return EXIT_ALLOW32;
|
|
34555
35444
|
}
|
|
34556
|
-
const sessionVal =
|
|
35445
|
+
const sessionVal = isObject17(envelope) ? envelope["session_id"] : null;
|
|
34557
35446
|
const session = typeof sessionVal === "string" && sessionVal ? sessionVal : "unknown";
|
|
34558
35447
|
return processEnvelope6(envelope, resolveConsumerRoot(envelope), session);
|
|
34559
35448
|
}
|
|
34560
|
-
function
|
|
35449
|
+
function _isCliEntry48() {
|
|
34561
35450
|
if (true) return false;
|
|
34562
35451
|
if (process.argv[1] === void 0) return false;
|
|
34563
|
-
const argvUrl =
|
|
35452
|
+
const argvUrl = pathToFileURL55(path96.resolve(process.argv[1])).href;
|
|
34564
35453
|
if (import.meta.url === argvUrl) return true;
|
|
34565
35454
|
try {
|
|
34566
|
-
return
|
|
35455
|
+
return fs94.realpathSync(fileURLToPath62(import.meta.url)) === fs94.realpathSync(path96.resolve(process.argv[1]));
|
|
34567
35456
|
} catch {
|
|
34568
35457
|
return false;
|
|
34569
35458
|
}
|
|
34570
35459
|
}
|
|
34571
|
-
if (
|
|
35460
|
+
if (_isCliEntry48()) process.exit(main61());
|
|
34572
35461
|
|
|
34573
35462
|
// src/scripts/hooks/interruption_ledger_hook.ts
|
|
34574
|
-
import * as
|
|
34575
|
-
import * as
|
|
34576
|
-
import { fileURLToPath as
|
|
35463
|
+
import * as fs95 from "node:fs";
|
|
35464
|
+
import * as path97 from "node:path";
|
|
35465
|
+
import { fileURLToPath as fileURLToPath63, pathToFileURL as pathToFileURL56 } from "node:url";
|
|
34577
35466
|
var EXIT_OK2 = 0;
|
|
34578
35467
|
var TRANSCRIPT_READ_MAX_BYTES2 = 2 * 1024 * 1024;
|
|
34579
|
-
var LEDGER_RELPATH =
|
|
35468
|
+
var LEDGER_RELPATH = path97.join("agents", "runtime", "state", "interruptions.jsonl");
|
|
34580
35469
|
function hasNumberedOptions(reply) {
|
|
34581
35470
|
let count = 0;
|
|
34582
35471
|
for (const line of reply.split("\n")) {
|
|
@@ -34600,14 +35489,14 @@ function classifyReply(reply) {
|
|
|
34600
35489
|
function readClaimedRoadmap(workspaceRoot3, sessionId2) {
|
|
34601
35490
|
if (!sessionId2) return null;
|
|
34602
35491
|
try {
|
|
34603
|
-
const file =
|
|
35492
|
+
const file = path97.join(
|
|
34604
35493
|
workspaceRoot3,
|
|
34605
35494
|
"agents",
|
|
34606
35495
|
"runtime",
|
|
34607
35496
|
"state",
|
|
34608
35497
|
`roadmap-claim-${sessionId2}.json`
|
|
34609
35498
|
);
|
|
34610
|
-
const parsed = JSON.parse(
|
|
35499
|
+
const parsed = JSON.parse(fs95.readFileSync(file, "utf8"));
|
|
34611
35500
|
if (parsed === null || typeof parsed !== "object") return null;
|
|
34612
35501
|
const slug = parsed["slug"];
|
|
34613
35502
|
return typeof slug === "string" && slug.length > 0 ? slug : null;
|
|
@@ -34618,7 +35507,7 @@ function readClaimedRoadmap(workspaceRoot3, sessionId2) {
|
|
|
34618
35507
|
function alreadyRecorded(ledgerPath, runId, turn) {
|
|
34619
35508
|
let raw;
|
|
34620
35509
|
try {
|
|
34621
|
-
raw =
|
|
35510
|
+
raw = fs95.readFileSync(ledgerPath, "utf8");
|
|
34622
35511
|
} catch {
|
|
34623
35512
|
return false;
|
|
34624
35513
|
}
|
|
@@ -34634,10 +35523,10 @@ function alreadyRecorded(ledgerPath, runId, turn) {
|
|
|
34634
35523
|
}
|
|
34635
35524
|
return false;
|
|
34636
35525
|
}
|
|
34637
|
-
function
|
|
35526
|
+
function str14(v) {
|
|
34638
35527
|
return typeof v === "string" ? v : "";
|
|
34639
35528
|
}
|
|
34640
|
-
function
|
|
35529
|
+
function main62() {
|
|
34641
35530
|
let envelope;
|
|
34642
35531
|
let payload;
|
|
34643
35532
|
try {
|
|
@@ -34645,8 +35534,8 @@ function main60() {
|
|
|
34645
35534
|
} catch {
|
|
34646
35535
|
return EXIT_OK2;
|
|
34647
35536
|
}
|
|
34648
|
-
const workspaceRoot3 =
|
|
34649
|
-
const transcriptPath =
|
|
35537
|
+
const workspaceRoot3 = str14(envelope["workspace_root"]) || process.cwd();
|
|
35538
|
+
const transcriptPath = str14(
|
|
34650
35539
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
34651
35540
|
);
|
|
34652
35541
|
if (!transcriptPath) return EXIT_OK2;
|
|
@@ -34660,9 +35549,9 @@ function main60() {
|
|
|
34660
35549
|
return EXIT_OK2;
|
|
34661
35550
|
}
|
|
34662
35551
|
if (!lastAssistant) return EXIT_OK2;
|
|
34663
|
-
const sessionId2 =
|
|
35552
|
+
const sessionId2 = str14(payload["session_id"]) || str14(envelope["session_id"]);
|
|
34664
35553
|
const runId = sessionId2 ? derive_session_tag(sessionId2) : "unknown";
|
|
34665
|
-
const ledgerPath =
|
|
35554
|
+
const ledgerPath = path97.join(workspaceRoot3, LEDGER_RELPATH);
|
|
34666
35555
|
if (alreadyRecorded(ledgerPath, runId, turnOrdinal)) return EXIT_OK2;
|
|
34667
35556
|
const verdict = classifyReply(lastAssistant);
|
|
34668
35557
|
const record = {
|
|
@@ -34674,43 +35563,43 @@ function main60() {
|
|
|
34674
35563
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
34675
35564
|
};
|
|
34676
35565
|
try {
|
|
34677
|
-
|
|
34678
|
-
|
|
35566
|
+
fs95.mkdirSync(path97.dirname(ledgerPath), { recursive: true });
|
|
35567
|
+
fs95.appendFileSync(ledgerPath, `${JSON.stringify(record)}
|
|
34679
35568
|
`, "utf8");
|
|
34680
35569
|
} catch {
|
|
34681
35570
|
}
|
|
34682
35571
|
return EXIT_OK2;
|
|
34683
35572
|
}
|
|
34684
|
-
function
|
|
35573
|
+
function _isCliEntry49() {
|
|
34685
35574
|
if (process.argv[1] === void 0) {
|
|
34686
35575
|
return false;
|
|
34687
35576
|
}
|
|
34688
|
-
const argvUrl =
|
|
35577
|
+
const argvUrl = pathToFileURL56(path97.resolve(process.argv[1])).href;
|
|
34689
35578
|
if (import.meta.url === argvUrl) {
|
|
34690
35579
|
return true;
|
|
34691
35580
|
}
|
|
34692
35581
|
try {
|
|
34693
|
-
const here =
|
|
34694
|
-
const argv =
|
|
35582
|
+
const here = fs95.realpathSync(fileURLToPath63(import.meta.url));
|
|
35583
|
+
const argv = fs95.realpathSync(path97.resolve(process.argv[1]));
|
|
34695
35584
|
return here === argv;
|
|
34696
35585
|
} catch {
|
|
34697
35586
|
return false;
|
|
34698
35587
|
}
|
|
34699
35588
|
}
|
|
34700
|
-
if (
|
|
34701
|
-
process.exit(
|
|
35589
|
+
if (_isCliEntry49()) {
|
|
35590
|
+
process.exit(main62());
|
|
34702
35591
|
}
|
|
34703
35592
|
|
|
34704
35593
|
// src/scripts/hooks/run_continuation_hook.ts
|
|
34705
|
-
import * as
|
|
35594
|
+
import * as fs97 from "node:fs";
|
|
34706
35595
|
|
|
34707
35596
|
// src/scripts/_lib/billing_grant.ts
|
|
34708
|
-
import * as
|
|
34709
|
-
import * as
|
|
34710
|
-
var BILLING_GRANT_DIR_REL =
|
|
35597
|
+
import * as fs96 from "node:fs";
|
|
35598
|
+
import * as path98 from "node:path";
|
|
35599
|
+
var BILLING_GRANT_DIR_REL = path98.join("agents", "runtime", "billing-grants");
|
|
34711
35600
|
var BILLING_GRANT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
34712
35601
|
function grantFile(repoRoot, runId) {
|
|
34713
|
-
return
|
|
35602
|
+
return path98.join(
|
|
34714
35603
|
repoRoot,
|
|
34715
35604
|
BILLING_GRANT_DIR_REL,
|
|
34716
35605
|
`${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
|
|
@@ -34718,96 +35607,110 @@ function grantFile(repoRoot, runId) {
|
|
|
34718
35607
|
}
|
|
34719
35608
|
function revokeBillingGrant(repoRoot, runId) {
|
|
34720
35609
|
try {
|
|
34721
|
-
|
|
35610
|
+
fs96.unlinkSync(grantFile(repoRoot, runId));
|
|
34722
35611
|
} catch {
|
|
34723
35612
|
}
|
|
34724
35613
|
}
|
|
34725
35614
|
|
|
34726
35615
|
// src/scripts/hooks/run_continuation_hook.ts
|
|
34727
|
-
import * as
|
|
34728
|
-
import { fileURLToPath as
|
|
35616
|
+
import * as path99 from "node:path";
|
|
35617
|
+
import { fileURLToPath as fileURLToPath64, pathToFileURL as pathToFileURL57 } from "node:url";
|
|
34729
35618
|
|
|
34730
|
-
// src/scripts/_lib/
|
|
34731
|
-
|
|
34732
|
-
|
|
34733
|
-
|
|
34734
|
-
|
|
34735
|
-
|
|
34736
|
-
|
|
34737
|
-
|
|
34738
|
-
|
|
34739
|
-
|
|
34740
|
-
|
|
34741
|
-
|
|
34742
|
-
|
|
34743
|
-
|
|
34744
|
-
|
|
34745
|
-
|
|
34746
|
-
|
|
34747
|
-
|
|
34748
|
-
|
|
34749
|
-
|
|
34750
|
-
|
|
34751
|
-
|
|
34752
|
-
{ kind: "credential", re: /\b(?:missing|unset|not set)\b[^\n]{0,40}\b(?:credential|token|api[_ -]?key|secret)\b/i },
|
|
34753
|
-
{ kind: "permission", re: /\b(?:permission denied|forbidden|403 forbidden)\b/i },
|
|
34754
|
-
{ kind: "quota", re: /\b(?:rate limit(?:ed| exceeded| reached)?|quota exceeded|429 too many requests|spend (?:cap|limit) reached)\b/i },
|
|
34755
|
-
{ kind: "service", re: /\b(?:5\d\d (?:internal )?server error|service unavailable|connection refused)\b/i }
|
|
35619
|
+
// src/scripts/_lib/outcome_vocabularies.ts
|
|
35620
|
+
var RUN_TERMINAL_STATES = [
|
|
35621
|
+
"success",
|
|
35622
|
+
"clean-no-op",
|
|
35623
|
+
"blocked",
|
|
35624
|
+
"approval-required",
|
|
35625
|
+
"exhausted",
|
|
35626
|
+
"stagnated",
|
|
35627
|
+
/**
|
|
35628
|
+
* The plan premise this run was built on no longer holds — the situational
|
|
35629
|
+
* -awareness fingerprint the run engaged under (`origin/main` plus every open
|
|
35630
|
+
* PR head) was re-observed and differs.
|
|
35631
|
+
*
|
|
35632
|
+
* Added by `road-to-wired-instruments` Phase 2 under the AI-council decision
|
|
35633
|
+
* of 2026-09-03 (option (a), unanimous). It is NOT `blocked` with a reason
|
|
35634
|
+
* field: premise invalidation is operationally distinct from a missing
|
|
35635
|
+
* precondition and from an exhausted budget, and folding it into either loses
|
|
35636
|
+
* both aggregation by state and type-enforced exhaustive handling. The
|
|
35637
|
+
* remedy differs too — re-probe and re-plan, where `blocked` says obtain the
|
|
35638
|
+
* missing thing and `exhausted` says the budget was too small.
|
|
35639
|
+
*/
|
|
35640
|
+
"premise-invalidated"
|
|
34756
35641
|
];
|
|
34757
|
-
var
|
|
34758
|
-
|
|
34759
|
-
|
|
34760
|
-
|
|
34761
|
-
|
|
34762
|
-
|
|
34763
|
-
|
|
34764
|
-
|
|
34765
|
-
|
|
34766
|
-
|
|
34767
|
-
|
|
34768
|
-
|
|
35642
|
+
var RUN_TERMINAL_VOCABULARY_VERSION = 2;
|
|
35643
|
+
|
|
35644
|
+
// src/scripts/_lib/continuation_ladder.ts
|
|
35645
|
+
var MAX_ITERATIONS = 25;
|
|
35646
|
+
var WALL_CLOCK_CAP_MS = 4 * 60 * 60 * 1e3;
|
|
35647
|
+
var STALL_WINDOW = 3;
|
|
35648
|
+
var HALT_ACTIONS = [
|
|
35649
|
+
"halt-max-iterations",
|
|
35650
|
+
"halt-wall-clock",
|
|
35651
|
+
"halt-stall",
|
|
35652
|
+
// Phase 5.4. Checked BEFORE the counter rungs: a dependency the run cannot
|
|
35653
|
+
// obtain is not something more iterations close, so consuming the budget
|
|
35654
|
+
// against it is the waste the rung exists to stop.
|
|
35655
|
+
"halt-dependency-unavailable",
|
|
35656
|
+
// `road-to-wired-instruments` 2.2, and BEFORE the counter rungs for the same
|
|
35657
|
+
// reason: a run whose plan premise moved does not become correct by running
|
|
35658
|
+
// more iterations against the stale plan, and letting it cap out reports
|
|
35659
|
+
// `exhausted` — a budget problem, whose remedy is a bigger budget — for what
|
|
35660
|
+
// is actually a staleness problem, whose remedy is a re-probe.
|
|
35661
|
+
"halt-premise-invalidated"
|
|
35662
|
+
];
|
|
35663
|
+
var TERMINAL_STATE_BY_ACTION = {
|
|
35664
|
+
engage: null,
|
|
35665
|
+
complete: "success",
|
|
35666
|
+
blocked: "blocked",
|
|
35667
|
+
"halt-max-iterations": "exhausted",
|
|
35668
|
+
"halt-wall-clock": "exhausted",
|
|
35669
|
+
"halt-stall": "stagnated",
|
|
35670
|
+
"halt-dependency-unavailable": "blocked",
|
|
35671
|
+
"halt-premise-invalidated": "premise-invalidated"
|
|
35672
|
+
};
|
|
35673
|
+
function terminalStateFor(action) {
|
|
35674
|
+
return TERMINAL_STATE_BY_ACTION[action] ?? null;
|
|
34769
35675
|
}
|
|
34770
|
-
function
|
|
34771
|
-
|
|
34772
|
-
|
|
35676
|
+
function ladder(state, openCount, nowMs, blockedCount, caps = {
|
|
35677
|
+
maxIterations: MAX_ITERATIONS,
|
|
35678
|
+
wallClockMs: WALL_CLOCK_CAP_MS,
|
|
35679
|
+
stallWindow: STALL_WINDOW
|
|
35680
|
+
}, unavailable = null, premiseInvalidated = false) {
|
|
35681
|
+
if (state.halted) return state.halted;
|
|
35682
|
+
if (openCount === 0) return blockedCount > 0 ? "blocked" : "complete";
|
|
35683
|
+
if (unavailable !== null) return "halt-dependency-unavailable";
|
|
35684
|
+
if (premiseInvalidated) return "halt-premise-invalidated";
|
|
35685
|
+
if (state.iterations >= caps.maxIterations) return "halt-max-iterations";
|
|
35686
|
+
const started = Date.parse(state.started_at);
|
|
35687
|
+
if (Number.isFinite(started) && nowMs - started >= caps.wallClockMs) {
|
|
35688
|
+
return "halt-wall-clock";
|
|
34773
35689
|
}
|
|
34774
|
-
const
|
|
34775
|
-
|
|
34776
|
-
|
|
34777
|
-
const newMinimum = earlier.length > 0 && last < Math.min(...earlier);
|
|
34778
|
-
let flatRun = 1;
|
|
34779
|
-
for (let i = history.length - 2; i >= 0; i -= 1) {
|
|
34780
|
-
if (history[i] !== last) break;
|
|
34781
|
-
flatRun += 1;
|
|
35690
|
+
const tail = state.history.slice(-caps.stallWindow);
|
|
35691
|
+
if (tail.length >= caps.stallWindow && tail.every((n) => n === openCount)) {
|
|
35692
|
+
return "halt-stall";
|
|
34782
35693
|
}
|
|
34783
|
-
|
|
34784
|
-
if (flatRun >= window) return { level: "stalled", flatRun, minimum, newMinimum };
|
|
34785
|
-
return { level: "flat", flatRun, minimum, newMinimum };
|
|
35694
|
+
return "engage";
|
|
34786
35695
|
}
|
|
34787
|
-
function
|
|
34788
|
-
|
|
34789
|
-
|
|
34790
|
-
|
|
34791
|
-
} catch {
|
|
34792
|
-
return null;
|
|
34793
|
-
}
|
|
35696
|
+
function parseHaltStamp(v) {
|
|
35697
|
+
if (typeof v !== "string") return null;
|
|
35698
|
+
if (HALT_ACTIONS.includes(v)) return v;
|
|
35699
|
+
return v.startsWith("halt-") ? v : null;
|
|
34794
35700
|
}
|
|
34795
35701
|
|
|
34796
35702
|
// src/scripts/hooks/run_continuation_hook.ts
|
|
34797
|
-
var
|
|
35703
|
+
var EXIT_ALLOW33 = 0;
|
|
34798
35704
|
var EXIT_BLOCK5 = 1;
|
|
34799
35705
|
var BLOCKED_BY_MARKER = /<!--\s*blocked-by:\s*\S[^>]*-->/;
|
|
34800
35706
|
var LEDGER_TAIL_MAX_BYTES = 512 * 1024;
|
|
34801
|
-
var EVENTS_RELPATH =
|
|
35707
|
+
var EVENTS_RELPATH = path99.join(
|
|
34802
35708
|
"agents",
|
|
34803
35709
|
"runtime",
|
|
34804
35710
|
"state",
|
|
34805
35711
|
"run-continuation.jsonl"
|
|
34806
35712
|
);
|
|
34807
|
-
var STATE_DIR_REL =
|
|
34808
|
-
var MAX_ITERATIONS = 25;
|
|
34809
|
-
var WALL_CLOCK_CAP_MS = 4 * 60 * 60 * 1e3;
|
|
34810
|
-
var STALL_WINDOW = 3;
|
|
35713
|
+
var STATE_DIR_REL = path99.join("agents", "runtime", "state");
|
|
34811
35714
|
var ABSENT_CONFIRM_FIRES = 2;
|
|
34812
35715
|
var DUPLICATE_WINDOW_MS = 60 * 1e3;
|
|
34813
35716
|
function isDuplicateFire(state, turnOrdinal, openCount, nowMs, roadmapSource) {
|
|
@@ -34822,15 +35725,6 @@ function isDuplicateFire(state, turnOrdinal, openCount, nowMs, roadmapSource) {
|
|
|
34822
35725
|
const at = Date.parse(state.last_engaged_at ?? "");
|
|
34823
35726
|
return Number.isFinite(at) && nowMs - at < DUPLICATE_WINDOW_MS;
|
|
34824
35727
|
}
|
|
34825
|
-
var HALT_ACTIONS = [
|
|
34826
|
-
"halt-max-iterations",
|
|
34827
|
-
"halt-wall-clock",
|
|
34828
|
-
"halt-stall",
|
|
34829
|
-
// Phase 5.4. Checked BEFORE the counter rungs: a dependency the run cannot
|
|
34830
|
-
// obtain is not something more iterations close, so consuming the budget
|
|
34831
|
-
// against it is the waste the rung exists to stop.
|
|
34832
|
-
"halt-dependency-unavailable"
|
|
34833
|
-
];
|
|
34834
35728
|
function parseExecutionMode(text) {
|
|
34835
35729
|
if (!text.startsWith("---")) return null;
|
|
34836
35730
|
const end = text.indexOf("\n---", 3);
|
|
@@ -34885,42 +35779,23 @@ function extractVerify(stepText) {
|
|
|
34885
35779
|
if (backticked !== null) return backticked[1].trim() || null;
|
|
34886
35780
|
return null;
|
|
34887
35781
|
}
|
|
34888
|
-
function ladder(state, openCount, nowMs, blockedCount, caps = {
|
|
34889
|
-
maxIterations: MAX_ITERATIONS,
|
|
34890
|
-
wallClockMs: WALL_CLOCK_CAP_MS,
|
|
34891
|
-
stallWindow: STALL_WINDOW
|
|
34892
|
-
}, unavailable = null) {
|
|
34893
|
-
if (state.halted) return state.halted;
|
|
34894
|
-
if (openCount === 0) return blockedCount > 0 ? "blocked" : "complete";
|
|
34895
|
-
if (unavailable !== null) return "halt-dependency-unavailable";
|
|
34896
|
-
if (state.iterations >= caps.maxIterations) return "halt-max-iterations";
|
|
34897
|
-
const started = Date.parse(state.started_at);
|
|
34898
|
-
if (Number.isFinite(started) && nowMs - started >= caps.wallClockMs) {
|
|
34899
|
-
return "halt-wall-clock";
|
|
34900
|
-
}
|
|
34901
|
-
const tail = state.history.slice(-caps.stallWindow);
|
|
34902
|
-
if (tail.length >= caps.stallWindow && tail.every((n) => n === openCount)) {
|
|
34903
|
-
return "halt-stall";
|
|
34904
|
-
}
|
|
34905
|
-
return "engage";
|
|
34906
|
-
}
|
|
34907
35782
|
function stateRelPath(runId, slug) {
|
|
34908
35783
|
const safeRun = runId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
34909
35784
|
const safeSlug = slug.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
34910
|
-
return
|
|
35785
|
+
return path99.join(STATE_DIR_REL, `run-continuation-${safeRun}-${safeSlug}.json`);
|
|
34911
35786
|
}
|
|
34912
35787
|
function legacyStateRelPath(runId) {
|
|
34913
35788
|
const safe = runId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
34914
|
-
return
|
|
35789
|
+
return path99.join(STATE_DIR_REL, `run-continuation-${safe}.json`);
|
|
34915
35790
|
}
|
|
34916
35791
|
function readRunState(workspaceRoot3, runId, slug) {
|
|
34917
|
-
const keyedFile =
|
|
35792
|
+
const keyedFile = path99.join(workspaceRoot3, stateRelPath(runId, slug));
|
|
34918
35793
|
const keyed = readState6(keyedFile);
|
|
34919
35794
|
if (keyed !== null) return { state: keyed, from: "keyed", keyedFile };
|
|
34920
35795
|
if (fileExists(keyedFile)) {
|
|
34921
35796
|
return { state: null, from: "keyed", keyedFile };
|
|
34922
35797
|
}
|
|
34923
|
-
const legacy = readState6(
|
|
35798
|
+
const legacy = readState6(path99.join(workspaceRoot3, legacyStateRelPath(runId)));
|
|
34924
35799
|
if (legacy === null) return { state: null, from: "none", keyedFile };
|
|
34925
35800
|
if (legacy.roadmap !== void 0 && legacy.roadmap !== slug) {
|
|
34926
35801
|
return { state: null, from: "none", keyedFile };
|
|
@@ -34933,25 +35808,25 @@ function writeState5(file, state) {
|
|
|
34933
35808
|
function clearRunState(workspaceRoot3, runId, keyedFile, adoptedLegacy) {
|
|
34934
35809
|
revokeBillingGrant(workspaceRoot3, runId);
|
|
34935
35810
|
try {
|
|
34936
|
-
|
|
35811
|
+
fs97.rmSync(keyedFile, { force: true });
|
|
34937
35812
|
} catch {
|
|
34938
35813
|
}
|
|
34939
35814
|
if (!adoptedLegacy) return;
|
|
34940
35815
|
try {
|
|
34941
|
-
|
|
35816
|
+
fs97.rmSync(path99.join(workspaceRoot3, legacyStateRelPath(runId)), { force: true });
|
|
34942
35817
|
} catch {
|
|
34943
35818
|
}
|
|
34944
35819
|
}
|
|
34945
35820
|
function fileExists(p) {
|
|
34946
35821
|
try {
|
|
34947
|
-
return
|
|
35822
|
+
return fs97.statSync(p).isFile();
|
|
34948
35823
|
} catch {
|
|
34949
35824
|
return false;
|
|
34950
35825
|
}
|
|
34951
35826
|
}
|
|
34952
35827
|
function readState6(file) {
|
|
34953
35828
|
try {
|
|
34954
|
-
const parsed = JSON.parse(
|
|
35829
|
+
const parsed = JSON.parse(fs97.readFileSync(file, "utf8"));
|
|
34955
35830
|
if (parsed === null || typeof parsed !== "object") return null;
|
|
34956
35831
|
const o = parsed;
|
|
34957
35832
|
if (typeof o["started_at"] !== "string") return null;
|
|
@@ -34981,26 +35856,27 @@ function readState6(file) {
|
|
|
34981
35856
|
if (o["inert_reported"] === true) {
|
|
34982
35857
|
rec.inert_reported = true;
|
|
34983
35858
|
}
|
|
34984
|
-
|
|
34985
|
-
|
|
34986
|
-
rec.halted = halted;
|
|
35859
|
+
if (typeof o["context_fingerprint"] === "string" && o["context_fingerprint"] !== "") {
|
|
35860
|
+
rec.context_fingerprint = o["context_fingerprint"];
|
|
34987
35861
|
}
|
|
35862
|
+
const halted = parseHaltStamp(o["halted"]);
|
|
35863
|
+
if (halted !== null) rec.halted = halted;
|
|
34988
35864
|
return rec;
|
|
34989
35865
|
} catch {
|
|
34990
35866
|
return null;
|
|
34991
35867
|
}
|
|
34992
35868
|
}
|
|
34993
35869
|
function normalizeDir(p) {
|
|
34994
|
-
const abs =
|
|
35870
|
+
const abs = path99.resolve(p);
|
|
34995
35871
|
try {
|
|
34996
|
-
return
|
|
35872
|
+
return fs97.realpathSync(abs);
|
|
34997
35873
|
} catch {
|
|
34998
35874
|
return abs;
|
|
34999
35875
|
}
|
|
35000
35876
|
}
|
|
35001
35877
|
function normalizeFile(p) {
|
|
35002
|
-
const abs =
|
|
35003
|
-
return
|
|
35878
|
+
const abs = path99.resolve(p);
|
|
35879
|
+
return path99.join(normalizeDir(path99.dirname(abs)), path99.basename(abs));
|
|
35004
35880
|
}
|
|
35005
35881
|
function provenance(workspaceRoot3, claimPath, sessionRoot, sessionCwd) {
|
|
35006
35882
|
const reader = normalizeDir(workspaceRoot3);
|
|
@@ -35027,36 +35903,36 @@ function provenance(workspaceRoot3, claimPath, sessionRoot, sessionCwd) {
|
|
|
35027
35903
|
};
|
|
35028
35904
|
}
|
|
35029
35905
|
function resolveRoadmap(sessionRoot, workspaceRoot3, slug) {
|
|
35030
|
-
const dirRel =
|
|
35906
|
+
const dirRel = path99.join("agents", "roadmaps");
|
|
35031
35907
|
const stem = slug.trim().replace(/\.md$/, "");
|
|
35032
|
-
const rel =
|
|
35033
|
-
const norm =
|
|
35034
|
-
if (
|
|
35035
|
-
if (sessionRoot !== workspaceRoot3 && isDirectory(
|
|
35036
|
-
return
|
|
35908
|
+
const rel = path99.join(dirRel, `${stem}.md`);
|
|
35909
|
+
const norm = path99.normalize(rel);
|
|
35910
|
+
if (path99.dirname(norm) !== dirRel) return null;
|
|
35911
|
+
if (sessionRoot !== workspaceRoot3 && isDirectory(path99.join(sessionRoot, dirRel))) {
|
|
35912
|
+
return path99.join(sessionRoot, norm);
|
|
35037
35913
|
}
|
|
35038
|
-
return
|
|
35914
|
+
return path99.join(normalizeDir(workspaceRoot3), norm);
|
|
35039
35915
|
}
|
|
35040
35916
|
function isDirectory(p) {
|
|
35041
35917
|
try {
|
|
35042
|
-
return
|
|
35918
|
+
return fs97.statSync(p).isDirectory();
|
|
35043
35919
|
} catch {
|
|
35044
35920
|
return false;
|
|
35045
35921
|
}
|
|
35046
35922
|
}
|
|
35047
35923
|
function eventAlreadyLogged(workspaceRoot3, runId, slug, event) {
|
|
35048
35924
|
try {
|
|
35049
|
-
const file =
|
|
35050
|
-
const size =
|
|
35925
|
+
const file = path99.join(workspaceRoot3, EVENTS_RELPATH);
|
|
35926
|
+
const size = fs97.statSync(file).size;
|
|
35051
35927
|
const start = Math.max(0, size - LEDGER_TAIL_MAX_BYTES);
|
|
35052
|
-
const fd =
|
|
35928
|
+
const fd = fs97.openSync(file, "r");
|
|
35053
35929
|
let text;
|
|
35054
35930
|
try {
|
|
35055
35931
|
const buf = Buffer.alloc(size - start);
|
|
35056
|
-
const read =
|
|
35932
|
+
const read = fs97.readSync(fd, buf, 0, buf.length, start);
|
|
35057
35933
|
text = buf.subarray(0, read).toString("utf8");
|
|
35058
35934
|
} finally {
|
|
35059
|
-
|
|
35935
|
+
fs97.closeSync(fd);
|
|
35060
35936
|
}
|
|
35061
35937
|
for (const line of text.split("\n")) {
|
|
35062
35938
|
if (line === "") continue;
|
|
@@ -35079,9 +35955,9 @@ function eventAlreadyLogged(workspaceRoot3, runId, slug, event) {
|
|
|
35079
35955
|
}
|
|
35080
35956
|
function appendEvent2(workspaceRoot3, record) {
|
|
35081
35957
|
try {
|
|
35082
|
-
const file =
|
|
35083
|
-
|
|
35084
|
-
|
|
35958
|
+
const file = path99.join(workspaceRoot3, EVENTS_RELPATH);
|
|
35959
|
+
fs97.mkdirSync(path99.dirname(file), { recursive: true });
|
|
35960
|
+
fs97.appendFileSync(file, `${JSON.stringify(record)}
|
|
35085
35961
|
`, "utf8");
|
|
35086
35962
|
} catch {
|
|
35087
35963
|
}
|
|
@@ -35089,33 +35965,33 @@ function appendEvent2(workspaceRoot3, record) {
|
|
|
35089
35965
|
function refusedThisTurn(workspaceRoot3, sessionId2, turnOrdinal) {
|
|
35090
35966
|
try {
|
|
35091
35967
|
const file = sessionRefusalFile(workspaceRoot3, deriveSessionKey(sessionId2 || "unknown-session"));
|
|
35092
|
-
const rec = parseRecord(
|
|
35968
|
+
const rec = parseRecord(fs97.readFileSync(file, "utf-8"));
|
|
35093
35969
|
return rec !== null && rec.refused_turn === turnOrdinal;
|
|
35094
35970
|
} catch {
|
|
35095
35971
|
return false;
|
|
35096
35972
|
}
|
|
35097
35973
|
}
|
|
35098
|
-
function
|
|
35974
|
+
function str15(v) {
|
|
35099
35975
|
return typeof v === "string" ? v : "";
|
|
35100
35976
|
}
|
|
35101
|
-
function
|
|
35102
|
-
if (is_replay_mode()) return
|
|
35103
|
-
if (process.env["AGENT_CONFIG_NO_RUN_CONTINUATION"] === "1") return
|
|
35977
|
+
function main63() {
|
|
35978
|
+
if (is_replay_mode()) return EXIT_ALLOW33;
|
|
35979
|
+
if (process.env["AGENT_CONFIG_NO_RUN_CONTINUATION"] === "1") return EXIT_ALLOW33;
|
|
35104
35980
|
let envelope;
|
|
35105
35981
|
let payload;
|
|
35106
35982
|
try {
|
|
35107
35983
|
[envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
35108
35984
|
} catch {
|
|
35109
|
-
return
|
|
35985
|
+
return EXIT_ALLOW33;
|
|
35110
35986
|
}
|
|
35111
|
-
const workspaceRoot3 =
|
|
35112
|
-
const sessionId2 =
|
|
35987
|
+
const workspaceRoot3 = str15(envelope["workspace_root"]) || process.cwd();
|
|
35988
|
+
const sessionId2 = str15(payload["session_id"]) || str15(envelope["session_id"]);
|
|
35113
35989
|
const claim = resolve_claim(workspaceRoot3, sessionId2 || null);
|
|
35114
|
-
if (claim === null) return
|
|
35990
|
+
if (claim === null) return EXIT_ALLOW33;
|
|
35115
35991
|
const slug = claim.slug;
|
|
35116
35992
|
const sessionRoot = session_checkout(
|
|
35117
35993
|
workspaceRoot3,
|
|
35118
|
-
|
|
35994
|
+
str15(payload["cwd"])
|
|
35119
35995
|
);
|
|
35120
35996
|
const roadmapPath2 = resolveRoadmap(sessionRoot, workspaceRoot3, slug);
|
|
35121
35997
|
const runId = deriveSessionKey(sessionId2 || "unknown-session");
|
|
@@ -35123,7 +35999,7 @@ function main61() {
|
|
|
35123
35999
|
let roadmapText = null;
|
|
35124
36000
|
if (roadmapPath2 !== null) {
|
|
35125
36001
|
try {
|
|
35126
|
-
roadmapText =
|
|
36002
|
+
roadmapText = fs97.readFileSync(roadmapPath2, "utf8");
|
|
35127
36003
|
roadmapFile = roadmapPath2;
|
|
35128
36004
|
} catch {
|
|
35129
36005
|
roadmapText = null;
|
|
@@ -35132,13 +36008,13 @@ function main61() {
|
|
|
35132
36008
|
if (roadmapText === null || roadmapFile === null) {
|
|
35133
36009
|
const runState = readRunState(workspaceRoot3, runId, slug);
|
|
35134
36010
|
const driven = runState.state;
|
|
35135
|
-
if (driven === null && runState.from === "none") return
|
|
35136
|
-
if (driven?.halted !== void 0) return
|
|
36011
|
+
if (driven === null && runState.from === "none") return EXIT_ALLOW33;
|
|
36012
|
+
if (driven?.halted !== void 0) return EXIT_ALLOW33;
|
|
35137
36013
|
const absenceRoots = provenance(
|
|
35138
36014
|
workspaceRoot3,
|
|
35139
36015
|
claim.path,
|
|
35140
36016
|
sessionRoot,
|
|
35141
|
-
|
|
36017
|
+
str15(payload["cwd"])
|
|
35142
36018
|
);
|
|
35143
36019
|
absenceRoots["roadmap_path"] = roadmapPath2;
|
|
35144
36020
|
const absentFires = (driven?.absent_fires ?? 0) + 1;
|
|
@@ -35157,29 +36033,29 @@ function main61() {
|
|
|
35157
36033
|
...absenceRoots
|
|
35158
36034
|
});
|
|
35159
36035
|
}
|
|
35160
|
-
if (driven === null) return
|
|
36036
|
+
if (driven === null) return EXIT_ALLOW33;
|
|
35161
36037
|
if (absentFires < ABSENT_CONFIRM_FIRES) {
|
|
35162
36038
|
driven.absent_fires = absentFires;
|
|
35163
36039
|
writeState5(runState.keyedFile, driven);
|
|
35164
|
-
return
|
|
36040
|
+
return EXIT_ALLOW33;
|
|
35165
36041
|
}
|
|
35166
36042
|
clearRunState(workspaceRoot3, runId, runState.keyedFile, runState.from === "legacy");
|
|
35167
|
-
return
|
|
36043
|
+
return EXIT_ALLOW33;
|
|
35168
36044
|
}
|
|
35169
|
-
if (parseExecutionMode(roadmapText) !== "autonomous") return
|
|
35170
|
-
const transcriptPath =
|
|
36045
|
+
if (parseExecutionMode(roadmapText) !== "autonomous") return EXIT_ALLOW33;
|
|
36046
|
+
const transcriptPath = str15(
|
|
35171
36047
|
payload["transcript_path"] ?? payload["transcriptPath"]
|
|
35172
36048
|
);
|
|
35173
|
-
if (!transcriptPath) return
|
|
36049
|
+
if (!transcriptPath) return EXIT_ALLOW33;
|
|
35174
36050
|
try {
|
|
35175
|
-
if (
|
|
36051
|
+
if (fs97.statSync(transcriptPath).size > TRANSCRIPT_READ_MAX_BYTES) {
|
|
35176
36052
|
const inert = readRunState(workspaceRoot3, runId, slug);
|
|
35177
36053
|
if (inert.state !== null && inert.state.inert_reported !== true) {
|
|
35178
36054
|
const inertRoots = provenance(
|
|
35179
36055
|
workspaceRoot3,
|
|
35180
36056
|
claim.path,
|
|
35181
36057
|
sessionRoot,
|
|
35182
|
-
|
|
36058
|
+
str15(payload["cwd"])
|
|
35183
36059
|
);
|
|
35184
36060
|
inertRoots["roadmap_path"] = roadmapFile;
|
|
35185
36061
|
appendEvent2(workspaceRoot3, {
|
|
@@ -35193,10 +36069,10 @@ function main61() {
|
|
|
35193
36069
|
inert.state.inert_reported = true;
|
|
35194
36070
|
writeState5(inert.keyedFile, inert.state);
|
|
35195
36071
|
}
|
|
35196
|
-
return
|
|
36072
|
+
return EXIT_ALLOW33;
|
|
35197
36073
|
}
|
|
35198
36074
|
} catch {
|
|
35199
|
-
return
|
|
36075
|
+
return EXIT_ALLOW33;
|
|
35200
36076
|
}
|
|
35201
36077
|
let turnOrdinal = 0;
|
|
35202
36078
|
try {
|
|
@@ -35204,13 +36080,13 @@ function main61() {
|
|
|
35204
36080
|
maxBytes: TRANSCRIPT_READ_MAX_BYTES
|
|
35205
36081
|
}).turnOrdinal;
|
|
35206
36082
|
} catch {
|
|
35207
|
-
return
|
|
36083
|
+
return EXIT_ALLOW33;
|
|
35208
36084
|
}
|
|
35209
36085
|
const roots = provenance(
|
|
35210
36086
|
workspaceRoot3,
|
|
35211
36087
|
claim.path,
|
|
35212
36088
|
sessionRoot,
|
|
35213
|
-
|
|
36089
|
+
str15(payload["cwd"])
|
|
35214
36090
|
);
|
|
35215
36091
|
roots["roadmap_path"] = roadmapFile;
|
|
35216
36092
|
if (refusedThisTurn(workspaceRoot3, sessionId2, turnOrdinal)) {
|
|
@@ -35222,7 +36098,7 @@ function main61() {
|
|
|
35222
36098
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35223
36099
|
...roots
|
|
35224
36100
|
});
|
|
35225
|
-
return
|
|
36101
|
+
return EXIT_ALLOW33;
|
|
35226
36102
|
}
|
|
35227
36103
|
const mainState = readRunState(workspaceRoot3, runId, slug);
|
|
35228
36104
|
const stateFile4 = mainState.keyedFile;
|
|
@@ -35247,7 +36123,17 @@ function main61() {
|
|
|
35247
36123
|
}
|
|
35248
36124
|
const unavailable = readUnavailableDependency(transcriptPath);
|
|
35249
36125
|
state.stall = stallSignal(state.history, STALL_WINDOW).level;
|
|
35250
|
-
const
|
|
36126
|
+
const observed = readContextObservation(workspaceRoot3)?.fingerprint ?? null;
|
|
36127
|
+
const premiseInvalidated = premiseMoved(state.context_fingerprint, observed);
|
|
36128
|
+
const action = ladder(
|
|
36129
|
+
state,
|
|
36130
|
+
scan.open,
|
|
36131
|
+
Date.now(),
|
|
36132
|
+
scan.blocked,
|
|
36133
|
+
void 0,
|
|
36134
|
+
unavailable,
|
|
36135
|
+
premiseInvalidated
|
|
36136
|
+
);
|
|
35251
36137
|
if (action !== "engage") {
|
|
35252
36138
|
const alreadyStamped = prev?.halted !== void 0;
|
|
35253
36139
|
const alreadyBlocked = action === "blocked" && eventAlreadyLogged(workspaceRoot3, runId, slug, "blocked");
|
|
@@ -35260,30 +36146,39 @@ function main61() {
|
|
|
35260
36146
|
iterations: state.iterations,
|
|
35261
36147
|
open: scan.open,
|
|
35262
36148
|
blocked: scan.blocked,
|
|
36149
|
+
// A ledger line is a persisted shape carrying a `RunTerminalState`,
|
|
36150
|
+
// so it names the vocabulary version it was written against: a
|
|
36151
|
+
// reader meeting an unknown value can then tell a newer writer
|
|
36152
|
+
// from a corrupt row.
|
|
36153
|
+
terminal_state: terminalStateFor(action),
|
|
36154
|
+
terminal_vocabulary_version: RUN_TERMINAL_VOCABULARY_VERSION,
|
|
35263
36155
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35264
36156
|
...roots
|
|
35265
36157
|
});
|
|
35266
36158
|
}
|
|
35267
36159
|
if (action === "complete") {
|
|
35268
36160
|
clearRunState(workspaceRoot3, runId, stateFile4, mainState.from === "legacy");
|
|
35269
|
-
return
|
|
36161
|
+
return EXIT_ALLOW33;
|
|
35270
36162
|
}
|
|
35271
36163
|
if (action === "blocked") {
|
|
35272
36164
|
clearRunState(workspaceRoot3, runId, stateFile4, mainState.from === "legacy");
|
|
35273
|
-
return
|
|
36165
|
+
return EXIT_ALLOW33;
|
|
35274
36166
|
}
|
|
35275
36167
|
if (!state.halted) {
|
|
35276
36168
|
state.halted = action;
|
|
35277
36169
|
writeState5(stateFile4, state);
|
|
35278
36170
|
}
|
|
35279
|
-
return
|
|
36171
|
+
return EXIT_ALLOW33;
|
|
35280
36172
|
}
|
|
35281
36173
|
state.iterations += 1;
|
|
35282
36174
|
state.last_turn = turnOrdinal;
|
|
36175
|
+
if (state.context_fingerprint === void 0 && observed !== null) {
|
|
36176
|
+
state.context_fingerprint = observed;
|
|
36177
|
+
}
|
|
35283
36178
|
state.history.push(scan.open);
|
|
35284
36179
|
state.last_engaged_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
35285
36180
|
if (!writeState5(stateFile4, state)) {
|
|
35286
|
-
return
|
|
36181
|
+
return EXIT_ALLOW33;
|
|
35287
36182
|
}
|
|
35288
36183
|
appendEvent2(workspaceRoot3, {
|
|
35289
36184
|
event: "engage",
|
|
@@ -35307,46 +36202,34 @@ ${stepLine}
|
|
|
35307
36202
|
Continue with this step now: do the work, run its verify line, flip the box, then end the turn. Escalate instead of continuing ONLY for a locked decision class (high_impact / user_required) or a halt your contract names.
|
|
35308
36203
|
`;
|
|
35309
36204
|
}
|
|
35310
|
-
function
|
|
36205
|
+
function _isCliEntry50() {
|
|
35311
36206
|
if (true) {
|
|
35312
36207
|
return false;
|
|
35313
36208
|
}
|
|
35314
36209
|
if (process.argv[1] === void 0) return false;
|
|
35315
|
-
const argvUrl =
|
|
36210
|
+
const argvUrl = pathToFileURL57(path99.resolve(process.argv[1])).href;
|
|
35316
36211
|
if (import.meta.url === argvUrl) return true;
|
|
35317
36212
|
try {
|
|
35318
|
-
const here =
|
|
35319
|
-
const argv =
|
|
36213
|
+
const here = fs97.realpathSync(fileURLToPath64(import.meta.url));
|
|
36214
|
+
const argv = fs97.realpathSync(path99.resolve(process.argv[1]));
|
|
35320
36215
|
return here === argv;
|
|
35321
36216
|
} catch {
|
|
35322
36217
|
return false;
|
|
35323
36218
|
}
|
|
35324
36219
|
}
|
|
35325
|
-
if (
|
|
35326
|
-
process.exit(
|
|
36220
|
+
if (_isCliEntry50()) {
|
|
36221
|
+
process.exit(main63());
|
|
35327
36222
|
}
|
|
35328
36223
|
|
|
35329
36224
|
// src/scripts/hooks/journal_record_hook.ts
|
|
35330
|
-
import * as
|
|
35331
|
-
import * as
|
|
35332
|
-
import { fileURLToPath as
|
|
36225
|
+
import * as fs99 from "node:fs";
|
|
36226
|
+
import * as path101 from "node:path";
|
|
36227
|
+
import { fileURLToPath as fileURLToPath65, pathToFileURL as pathToFileURL58 } from "node:url";
|
|
35333
36228
|
|
|
35334
36229
|
// src/scripts/_lib/runtime_journal.ts
|
|
35335
36230
|
import * as crypto14 from "node:crypto";
|
|
35336
|
-
import * as
|
|
35337
|
-
import * as
|
|
35338
|
-
|
|
35339
|
-
// src/scripts/_lib/outcome_vocabularies.ts
|
|
35340
|
-
var RUN_TERMINAL_STATES = [
|
|
35341
|
-
"success",
|
|
35342
|
-
"clean-no-op",
|
|
35343
|
-
"blocked",
|
|
35344
|
-
"approval-required",
|
|
35345
|
-
"exhausted",
|
|
35346
|
-
"stagnated"
|
|
35347
|
-
];
|
|
35348
|
-
|
|
35349
|
-
// src/scripts/_lib/runtime_journal.ts
|
|
36231
|
+
import * as fs98 from "node:fs";
|
|
36232
|
+
import * as path100 from "node:path";
|
|
35350
36233
|
var JOURNAL_SCHEMA_VERSION = 3;
|
|
35351
36234
|
var BOUNDARY_RULE_VERSION = 1;
|
|
35352
36235
|
var RETENTION_TTL_DAYS = 30;
|
|
@@ -35437,7 +36320,7 @@ function requireId(name, id, optional) {
|
|
|
35437
36320
|
}
|
|
35438
36321
|
var JOURNAL_DIR_NAME = "agent-journal";
|
|
35439
36322
|
var JOURNAL_FILE_NAME = "journal.sqlite";
|
|
35440
|
-
var JOURNAL_FALLBACK_REL =
|
|
36323
|
+
var JOURNAL_FALLBACK_REL = path100.join("agents", "runtime", "state", JOURNAL_FILE_NAME);
|
|
35441
36324
|
function digest(domain, input) {
|
|
35442
36325
|
return crypto14.createHash("sha256").update(`${domain}\0${input}`).digest("hex").slice(0, 12);
|
|
35443
36326
|
}
|
|
@@ -35448,20 +36331,20 @@ function resolveJournal(root) {
|
|
|
35448
36331
|
if (common !== null) {
|
|
35449
36332
|
const own = git_dir(root) ?? common;
|
|
35450
36333
|
return {
|
|
35451
|
-
path:
|
|
36334
|
+
path: path100.join(common, JOURNAL_DIR_NAME, JOURNAL_FILE_NAME),
|
|
35452
36335
|
scope: "repo-shared",
|
|
35453
36336
|
reason: "common git dir resolved \u2014 every worktree of this repo writes one database",
|
|
35454
36337
|
repository_id: digest(REPO_DOMAIN, common),
|
|
35455
36338
|
worktree_id: digest(WORKTREE_DOMAIN, own)
|
|
35456
36339
|
};
|
|
35457
36340
|
}
|
|
35458
|
-
let real =
|
|
36341
|
+
let real = path100.resolve(root);
|
|
35459
36342
|
try {
|
|
35460
|
-
real =
|
|
36343
|
+
real = fs98.realpathSync(real);
|
|
35461
36344
|
} catch {
|
|
35462
36345
|
}
|
|
35463
36346
|
return {
|
|
35464
|
-
path:
|
|
36347
|
+
path: path100.join(real, JOURNAL_FALLBACK_REL),
|
|
35465
36348
|
scope: "worktree-local",
|
|
35466
36349
|
reason: "no common git dir \u2014 not inside a git repository; falling back to the tree-local path",
|
|
35467
36350
|
repository_id: digest(REPO_DOMAIN, real),
|
|
@@ -35547,7 +36430,7 @@ function ensureWal(db) {
|
|
|
35547
36430
|
function discard(dbPath) {
|
|
35548
36431
|
for (const p of [dbPath, `${dbPath}-wal`, `${dbPath}-shm`]) {
|
|
35549
36432
|
try {
|
|
35550
|
-
|
|
36433
|
+
fs98.rmSync(p, { force: true });
|
|
35551
36434
|
} catch {
|
|
35552
36435
|
}
|
|
35553
36436
|
}
|
|
@@ -35559,9 +36442,9 @@ function openJournal(root) {
|
|
|
35559
36442
|
);
|
|
35560
36443
|
}
|
|
35561
36444
|
const location = resolveJournal(root);
|
|
35562
|
-
|
|
36445
|
+
fs98.mkdirSync(path100.dirname(location.path), { recursive: true });
|
|
35563
36446
|
const { DatabaseSync } = loadSqliteSync("runtime_journal");
|
|
35564
|
-
if (
|
|
36447
|
+
if (fs98.existsSync(location.path)) {
|
|
35565
36448
|
let drift = false;
|
|
35566
36449
|
let probe = null;
|
|
35567
36450
|
try {
|
|
@@ -35643,7 +36526,7 @@ function recordEvent(h, input) {
|
|
|
35643
36526
|
const explicit = requireId("episode_id", input.episode_id, true);
|
|
35644
36527
|
if (input.terminal_state !== null && input.terminal_state !== void 0 && !TERMINAL_STATES.includes(input.terminal_state)) {
|
|
35645
36528
|
throw new JournalContractError(
|
|
35646
|
-
`terminal_state ${JSON.stringify(input.terminal_state)} is not
|
|
36529
|
+
`terminal_state ${JSON.stringify(input.terminal_state)} is not in the run vocabulary.`
|
|
35647
36530
|
);
|
|
35648
36531
|
}
|
|
35649
36532
|
if (input.consumption !== null && input.consumption !== void 0 && !CONSUMPTION_STATES.includes(input.consumption)) {
|
|
@@ -35707,14 +36590,14 @@ function recordEvent(h, input) {
|
|
|
35707
36590
|
}
|
|
35708
36591
|
|
|
35709
36592
|
// src/scripts/hooks/journal_record_hook.ts
|
|
35710
|
-
var
|
|
36593
|
+
var EXIT_ALLOW34 = 0;
|
|
35711
36594
|
var SETTINGS_SECTION = "runtime_journal";
|
|
35712
|
-
function
|
|
36595
|
+
function isObject18(v) {
|
|
35713
36596
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
35714
36597
|
}
|
|
35715
36598
|
function unwrapPayload7(envelope) {
|
|
35716
36599
|
const inner = envelope["payload"];
|
|
35717
|
-
return
|
|
36600
|
+
return isObject18(inner) ? inner : envelope;
|
|
35718
36601
|
}
|
|
35719
36602
|
function firstString(envelope, payload, keys) {
|
|
35720
36603
|
for (const source of [envelope, payload]) {
|
|
@@ -35757,7 +36640,7 @@ function reduceEnvelope(envelope) {
|
|
|
35757
36640
|
};
|
|
35758
36641
|
}
|
|
35759
36642
|
function resolveConsumerRoot3(envelope) {
|
|
35760
|
-
if (
|
|
36643
|
+
if (isObject18(envelope)) {
|
|
35761
36644
|
for (const key of ["workspace_root", "project_root"]) {
|
|
35762
36645
|
const v = envelope[key];
|
|
35763
36646
|
if (typeof v === "string" && v) return v;
|
|
@@ -35769,12 +36652,12 @@ function resolveConsumerRoot3(envelope) {
|
|
|
35769
36652
|
}
|
|
35770
36653
|
function processEnvelope7(envelope, consumerRoot) {
|
|
35771
36654
|
try {
|
|
35772
|
-
if (!
|
|
35773
|
-
if (is_replay_mode()) return
|
|
35774
|
-
if (!hookSectionEnabled(consumerRoot, SETTINGS_SECTION)) return
|
|
35775
|
-
if (!isJournalAvailable()) return
|
|
36655
|
+
if (!isObject18(envelope)) return EXIT_ALLOW34;
|
|
36656
|
+
if (is_replay_mode()) return EXIT_ALLOW34;
|
|
36657
|
+
if (!hookSectionEnabled(consumerRoot, SETTINGS_SECTION)) return EXIT_ALLOW34;
|
|
36658
|
+
if (!isJournalAvailable()) return EXIT_ALLOW34;
|
|
35776
36659
|
const input = reduceEnvelope(envelope);
|
|
35777
|
-
if (input === null) return
|
|
36660
|
+
if (input === null) return EXIT_ALLOW34;
|
|
35778
36661
|
withJournal(consumerRoot, (h) => {
|
|
35779
36662
|
recordEvent(h, {
|
|
35780
36663
|
event: input.event,
|
|
@@ -35785,34 +36668,34 @@ function processEnvelope7(envelope, consumerRoot) {
|
|
|
35785
36668
|
});
|
|
35786
36669
|
});
|
|
35787
36670
|
} catch {
|
|
35788
|
-
return
|
|
36671
|
+
return EXIT_ALLOW34;
|
|
35789
36672
|
}
|
|
35790
|
-
return
|
|
36673
|
+
return EXIT_ALLOW34;
|
|
35791
36674
|
}
|
|
35792
|
-
function
|
|
36675
|
+
function main64() {
|
|
35793
36676
|
const raw = readHookStdin();
|
|
35794
36677
|
let envelope = {};
|
|
35795
36678
|
try {
|
|
35796
36679
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
35797
36680
|
} catch {
|
|
35798
|
-
return
|
|
36681
|
+
return EXIT_ALLOW34;
|
|
35799
36682
|
}
|
|
35800
36683
|
return processEnvelope7(envelope, resolveConsumerRoot3(envelope));
|
|
35801
36684
|
}
|
|
35802
|
-
function
|
|
36685
|
+
function _isCliEntry51() {
|
|
35803
36686
|
if (true) {
|
|
35804
36687
|
return false;
|
|
35805
36688
|
}
|
|
35806
36689
|
if (process.argv[1] === void 0) return false;
|
|
35807
|
-
const argvUrl =
|
|
36690
|
+
const argvUrl = pathToFileURL58(path101.resolve(process.argv[1])).href;
|
|
35808
36691
|
if (import.meta.url === argvUrl) return true;
|
|
35809
36692
|
try {
|
|
35810
|
-
return
|
|
36693
|
+
return fs99.realpathSync(fileURLToPath65(import.meta.url)) === fs99.realpathSync(path101.resolve(process.argv[1]));
|
|
35811
36694
|
} catch {
|
|
35812
36695
|
return false;
|
|
35813
36696
|
}
|
|
35814
36697
|
}
|
|
35815
|
-
if (
|
|
36698
|
+
if (_isCliEntry51()) process.exit(main64());
|
|
35816
36699
|
|
|
35817
36700
|
// src/scripts/hooks/concern_registry.ts
|
|
35818
36701
|
var CONCERN_REGISTRY = {
|
|
@@ -35861,15 +36744,16 @@ var CONCERN_REGISTRY = {
|
|
|
35861
36744
|
"src/scripts/hooks/end_review_nudge_hook.ts": main51,
|
|
35862
36745
|
"src/scripts/hooks/turn_end_gate_hook.ts": main53,
|
|
35863
36746
|
"src/scripts/hooks/edit_shape_hook.ts": main54,
|
|
35864
|
-
"src/scripts/hooks/
|
|
35865
|
-
"src/scripts/hooks/
|
|
36747
|
+
"src/scripts/hooks/comment_discipline_hook.ts": main56,
|
|
36748
|
+
"src/scripts/hooks/reread_guard_hook.ts": main57,
|
|
36749
|
+
"src/scripts/hooks/session_eol_hook.ts": main58,
|
|
35866
36750
|
"src/scripts/hooks/subagent_ledger_hook.ts": main52,
|
|
35867
|
-
"src/scripts/hooks/tool_result_bytes_hook.ts":
|
|
35868
|
-
"src/scripts/hooks/spawn_guard_shadow_hook.ts":
|
|
35869
|
-
"src/scripts/hooks/source_first_gate_hook.ts":
|
|
35870
|
-
"src/scripts/hooks/interruption_ledger_hook.ts":
|
|
35871
|
-
"src/scripts/hooks/run_continuation_hook.ts":
|
|
35872
|
-
"src/scripts/hooks/journal_record_hook.ts":
|
|
36751
|
+
"src/scripts/hooks/tool_result_bytes_hook.ts": main59,
|
|
36752
|
+
"src/scripts/hooks/spawn_guard_shadow_hook.ts": main60,
|
|
36753
|
+
"src/scripts/hooks/source_first_gate_hook.ts": main61,
|
|
36754
|
+
"src/scripts/hooks/interruption_ledger_hook.ts": main62,
|
|
36755
|
+
"src/scripts/hooks/run_continuation_hook.ts": main63,
|
|
36756
|
+
"src/scripts/hooks/journal_record_hook.ts": main64
|
|
35873
36757
|
};
|
|
35874
36758
|
|
|
35875
36759
|
// src/scripts/hooks/stdin_failure_policy.ts
|
|
@@ -35969,8 +36853,8 @@ function _py_json_dumps2(value, indent) {
|
|
|
35969
36853
|
|
|
35970
36854
|
// src/scripts/_lib/collector_denominator.ts
|
|
35971
36855
|
import crypto15 from "node:crypto";
|
|
35972
|
-
import
|
|
35973
|
-
import
|
|
36856
|
+
import fs101 from "node:fs";
|
|
36857
|
+
import path103 from "node:path";
|
|
35974
36858
|
|
|
35975
36859
|
// src/scripts/_lib/collector_record.ts
|
|
35976
36860
|
var COLLECTOR_EVENTS = [
|
|
@@ -36047,30 +36931,30 @@ var FIELD_PURPOSE = {
|
|
|
36047
36931
|
var ALLOWED_FIELDS = new Set(Object.keys(FIELD_PURPOSE));
|
|
36048
36932
|
|
|
36049
36933
|
// src/scripts/_lib/collector_store.ts
|
|
36050
|
-
import * as
|
|
36051
|
-
import * as
|
|
36052
|
-
import * as
|
|
36934
|
+
import * as fs100 from "node:fs";
|
|
36935
|
+
import * as os12 from "node:os";
|
|
36936
|
+
import * as path102 from "node:path";
|
|
36053
36937
|
var COLLECTOR_DIR_NAME = "agent-collector";
|
|
36054
36938
|
var COLLECTOR_FILE_NAME = "collector.sqlite";
|
|
36055
36939
|
var OPT_OUT_MARKER_NAME = "OPT-OUT";
|
|
36056
36940
|
var MIGRATION_MARKER_NAME = "MIGRATION-IN-FLIGHT";
|
|
36057
36941
|
var QUARANTINE_DIR_NAME = "quarantine";
|
|
36058
36942
|
function defaultUserRoot() {
|
|
36059
|
-
return
|
|
36943
|
+
return path102.join(os12.homedir(), ".event4u", "agent-config");
|
|
36060
36944
|
}
|
|
36061
36945
|
function resolveCollectorStore(userRoot = defaultUserRoot()) {
|
|
36062
|
-
const dir =
|
|
36946
|
+
const dir = path102.join(userRoot, COLLECTOR_DIR_NAME);
|
|
36063
36947
|
return {
|
|
36064
36948
|
userRoot,
|
|
36065
36949
|
root: dir,
|
|
36066
|
-
path:
|
|
36067
|
-
optOutMarker:
|
|
36068
|
-
migrationMarker:
|
|
36069
|
-
quarantineDir:
|
|
36950
|
+
path: path102.join(dir, COLLECTOR_FILE_NAME),
|
|
36951
|
+
optOutMarker: path102.join(dir, OPT_OUT_MARKER_NAME),
|
|
36952
|
+
migrationMarker: path102.join(dir, MIGRATION_MARKER_NAME),
|
|
36953
|
+
quarantineDir: path102.join(dir, QUARANTINE_DIR_NAME)
|
|
36070
36954
|
};
|
|
36071
36955
|
}
|
|
36072
36956
|
function isOptedOut(userRoot = defaultUserRoot()) {
|
|
36073
|
-
return
|
|
36957
|
+
return fs100.existsSync(resolveCollectorStore(userRoot).optOutMarker);
|
|
36074
36958
|
}
|
|
36075
36959
|
var MIGRATIONS = Object.freeze({
|
|
36076
36960
|
// 0 → 1. No DDL: `user_version` 0 is the default SQLite assigns, and a
|
|
@@ -36087,24 +36971,24 @@ var SPOOL_DIR_NAME = "spool";
|
|
|
36087
36971
|
var SPOOL_PENDING_NAME = "pending.jsonl";
|
|
36088
36972
|
var ENABLED_MARKER_NAME = "ENABLED";
|
|
36089
36973
|
function denominatorPath(userRoot) {
|
|
36090
|
-
return
|
|
36974
|
+
return path103.join(resolveCollectorStore(userRoot).root, DENOMINATOR_FILE_NAME);
|
|
36091
36975
|
}
|
|
36092
36976
|
function spoolDir(userRoot) {
|
|
36093
|
-
return
|
|
36977
|
+
return path103.join(resolveCollectorStore(userRoot).root, SPOOL_DIR_NAME);
|
|
36094
36978
|
}
|
|
36095
36979
|
function spoolPendingPath(userRoot) {
|
|
36096
|
-
return
|
|
36980
|
+
return path103.join(spoolDir(userRoot), SPOOL_PENDING_NAME);
|
|
36097
36981
|
}
|
|
36098
36982
|
function enabledMarkerPath(userRoot) {
|
|
36099
|
-
return
|
|
36983
|
+
return path103.join(resolveCollectorStore(userRoot).root, ENABLED_MARKER_NAME);
|
|
36100
36984
|
}
|
|
36101
36985
|
function isCollectorEnabled(userRoot) {
|
|
36102
36986
|
if (isOptedOut(userRoot)) return false;
|
|
36103
|
-
if (
|
|
36104
|
-
return
|
|
36987
|
+
if (fs101.existsSync(killSwitchPathLocal(userRoot))) return false;
|
|
36988
|
+
return fs101.existsSync(enabledMarkerPath(userRoot));
|
|
36105
36989
|
}
|
|
36106
36990
|
function killSwitchPathLocal(userRoot) {
|
|
36107
|
-
return
|
|
36991
|
+
return path103.join(resolveCollectorStore(userRoot).root, "STOP");
|
|
36108
36992
|
}
|
|
36109
36993
|
function utcDate(at = Date.now()) {
|
|
36110
36994
|
return new Date(at).toISOString().slice(0, 10);
|
|
@@ -36116,8 +37000,8 @@ function recordOpportunity(event, platform, userRoot, at = Date.now(), opts = {}
|
|
|
36116
37000
|
if (!COLLECTOR_EVENTS.includes(event)) return false;
|
|
36117
37001
|
if (!COLLECTOR_PLATFORMS.includes(platform)) return false;
|
|
36118
37002
|
const target = denominatorPath(userRoot);
|
|
36119
|
-
|
|
36120
|
-
|
|
37003
|
+
fs101.mkdirSync(path103.dirname(target), { recursive: true });
|
|
37004
|
+
fs101.appendFileSync(target, `${utcDate(at)} ${event} ${platform}
|
|
36121
37005
|
`);
|
|
36122
37006
|
return true;
|
|
36123
37007
|
} catch {
|
|
@@ -36131,19 +37015,19 @@ var MACHINE_ID_NAME = "machine-id";
|
|
|
36131
37015
|
var EPISODE_DIR_NAME = "episodes";
|
|
36132
37016
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
36133
37017
|
function machineIdPath(userRoot) {
|
|
36134
|
-
return
|
|
37018
|
+
return path103.join(resolveCollectorStore(userRoot).root, MACHINE_ID_NAME);
|
|
36135
37019
|
}
|
|
36136
37020
|
function machineId(userRoot) {
|
|
36137
37021
|
const target = machineIdPath(userRoot);
|
|
36138
37022
|
try {
|
|
36139
|
-
const existing =
|
|
37023
|
+
const existing = fs101.readFileSync(target, "utf8").trim();
|
|
36140
37024
|
if (UUID_RE.test(existing)) return existing;
|
|
36141
37025
|
} catch {
|
|
36142
37026
|
}
|
|
36143
37027
|
try {
|
|
36144
37028
|
const minted = crypto15.randomUUID();
|
|
36145
|
-
|
|
36146
|
-
|
|
37029
|
+
fs101.mkdirSync(path103.dirname(target), { recursive: true });
|
|
37030
|
+
fs101.writeFileSync(target, `${minted}
|
|
36147
37031
|
`);
|
|
36148
37032
|
return minted;
|
|
36149
37033
|
} catch {
|
|
@@ -36167,17 +37051,17 @@ function episodeId(env = process.env) {
|
|
|
36167
37051
|
].join("-");
|
|
36168
37052
|
}
|
|
36169
37053
|
function nextSequence(episode, userRoot) {
|
|
36170
|
-
const dir =
|
|
36171
|
-
const target =
|
|
37054
|
+
const dir = path103.join(resolveCollectorStore(userRoot).root, EPISODE_DIR_NAME);
|
|
37055
|
+
const target = path103.join(dir, `${episode}.seq`);
|
|
36172
37056
|
try {
|
|
36173
|
-
|
|
37057
|
+
fs101.mkdirSync(dir, { recursive: true });
|
|
36174
37058
|
let current = 0;
|
|
36175
37059
|
try {
|
|
36176
|
-
const raw = Number.parseInt(
|
|
37060
|
+
const raw = Number.parseInt(fs101.readFileSync(target, "utf8").trim(), 10);
|
|
36177
37061
|
if (Number.isInteger(raw) && raw >= 0) current = raw + 1;
|
|
36178
37062
|
} catch {
|
|
36179
37063
|
}
|
|
36180
|
-
|
|
37064
|
+
fs101.writeFileSync(target, `${current}
|
|
36181
37065
|
`);
|
|
36182
37066
|
return current;
|
|
36183
37067
|
} catch {
|
|
@@ -36216,12 +37100,12 @@ function spoolRecord(record, userRoot) {
|
|
|
36216
37100
|
try {
|
|
36217
37101
|
if (!isCollectorEnabled(userRoot)) return false;
|
|
36218
37102
|
const target = spoolPendingPath(userRoot);
|
|
36219
|
-
|
|
37103
|
+
fs101.mkdirSync(path103.dirname(target), { recursive: true });
|
|
36220
37104
|
try {
|
|
36221
|
-
if (
|
|
37105
|
+
if (fs101.statSync(target).size >= SPOOL_MAX_BYTES) return false;
|
|
36222
37106
|
} catch {
|
|
36223
37107
|
}
|
|
36224
|
-
|
|
37108
|
+
fs101.appendFileSync(target, `${JSON.stringify(record)}
|
|
36225
37109
|
`);
|
|
36226
37110
|
return true;
|
|
36227
37111
|
} catch {
|
|
@@ -36231,14 +37115,14 @@ function spoolRecord(record, userRoot) {
|
|
|
36231
37115
|
|
|
36232
37116
|
// src/scripts/hooks/dispatch_hook.ts
|
|
36233
37117
|
var _IN_BUNDLE = true;
|
|
36234
|
-
var REPO_ROOT =
|
|
36235
|
-
|
|
37118
|
+
var REPO_ROOT = path104.resolve(
|
|
37119
|
+
path104.dirname(fileURLToPath66(import.meta.url)),
|
|
36236
37120
|
..._IN_BUNDLE ? ["..", ".."] : ["..", "..", ".."]
|
|
36237
37121
|
);
|
|
36238
|
-
var MANIFEST_PATH =
|
|
36239
|
-
var
|
|
37122
|
+
var MANIFEST_PATH = path104.join(REPO_ROOT, "src", "scripts", "hook_manifest.yaml");
|
|
37123
|
+
var EXIT_ALLOW35 = 0;
|
|
36240
37124
|
var EXIT_BLOCK6 = 1;
|
|
36241
|
-
var
|
|
37125
|
+
var EXIT_WARN18 = 2;
|
|
36242
37126
|
var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
|
|
36243
37127
|
"session_start",
|
|
36244
37128
|
"session_end",
|
|
@@ -36252,9 +37136,9 @@ var EVENT_VOCABULARY = /* @__PURE__ */ new Set([
|
|
|
36252
37136
|
"subagent_stop"
|
|
36253
37137
|
]);
|
|
36254
37138
|
var _SEVERITY_BY_EXIT = {
|
|
36255
|
-
[
|
|
37139
|
+
[EXIT_ALLOW35]: "allow",
|
|
36256
37140
|
[EXIT_BLOCK6]: "block",
|
|
36257
|
-
[
|
|
37141
|
+
[EXIT_WARN18]: "warn"
|
|
36258
37142
|
};
|
|
36259
37143
|
function _isObject17(v) {
|
|
36260
37144
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -36297,11 +37181,11 @@ function _manifest_fingerprint(text) {
|
|
|
36297
37181
|
return `${h.toString(16)}:${String(text.length)}`;
|
|
36298
37182
|
}
|
|
36299
37183
|
function _load_yaml3(p) {
|
|
36300
|
-
const text =
|
|
37184
|
+
const text = fs102.readFileSync(p, "utf-8");
|
|
36301
37185
|
const compiled = p.replace(/\.ya?ml$/u, ".json");
|
|
36302
37186
|
if (compiled !== p) {
|
|
36303
37187
|
try {
|
|
36304
|
-
const raw = JSON.parse(
|
|
37188
|
+
const raw = JSON.parse(fs102.readFileSync(compiled, "utf-8"));
|
|
36305
37189
|
if (_isObject17(raw) && raw["fingerprint"] === _manifest_fingerprint(text) && _isObject17(raw["manifest"])) {
|
|
36306
37190
|
return raw["manifest"];
|
|
36307
37191
|
}
|
|
@@ -36407,7 +37291,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
36407
37291
|
}
|
|
36408
37292
|
try {
|
|
36409
37293
|
const target = _expanduser3(capture_dir);
|
|
36410
|
-
|
|
37294
|
+
fs102.mkdirSync(target, { recursive: true });
|
|
36411
37295
|
let payload;
|
|
36412
37296
|
try {
|
|
36413
37297
|
payload = payload_text.trim() ? JSON.parse(payload_text) : {};
|
|
@@ -36424,8 +37308,8 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
36424
37308
|
const ts = Date.now();
|
|
36425
37309
|
const native = (args.native_event || args.event).replace(/\//g, "_");
|
|
36426
37310
|
const fname = `${args.platform}__${native}__${ts}__${process.pid}.json`;
|
|
36427
|
-
|
|
36428
|
-
|
|
37311
|
+
fs102.writeFileSync(
|
|
37312
|
+
path104.join(target, fname),
|
|
36429
37313
|
_py_json_dumps2(record, 2) + "\n",
|
|
36430
37314
|
{ encoding: "utf-8" }
|
|
36431
37315
|
);
|
|
@@ -36436,7 +37320,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
36436
37320
|
function _expanduser3(p) {
|
|
36437
37321
|
if (p === "~" || p.startsWith("~/")) {
|
|
36438
37322
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "";
|
|
36439
|
-
return
|
|
37323
|
+
return path104.join(home, p.slice(1));
|
|
36440
37324
|
}
|
|
36441
37325
|
return p;
|
|
36442
37326
|
}
|
|
@@ -36468,25 +37352,25 @@ function _resolve_tsx_invocation2(scriptPath, scriptArgs) {
|
|
|
36468
37352
|
const walkUp = (start) => {
|
|
36469
37353
|
let dir = start;
|
|
36470
37354
|
for (; ; ) {
|
|
36471
|
-
const candidate =
|
|
37355
|
+
const candidate = path104.join(dir, "node_modules", ".bin", binName);
|
|
36472
37356
|
if (_isFile8(candidate)) {
|
|
36473
37357
|
return candidate;
|
|
36474
37358
|
}
|
|
36475
|
-
const parent =
|
|
37359
|
+
const parent = path104.dirname(dir);
|
|
36476
37360
|
if (parent === dir) {
|
|
36477
37361
|
return null;
|
|
36478
37362
|
}
|
|
36479
37363
|
dir = parent;
|
|
36480
37364
|
}
|
|
36481
37365
|
};
|
|
36482
|
-
const tsx = walkUp(
|
|
37366
|
+
const tsx = walkUp(path104.dirname(scriptPath)) ?? walkUp(path104.dirname(fileURLToPath66(import.meta.url)));
|
|
36483
37367
|
if (tsx !== null) {
|
|
36484
37368
|
return { command: tsx, args: [scriptPath, ...scriptArgs] };
|
|
36485
37369
|
}
|
|
36486
37370
|
return { command: "npx", args: ["tsx", scriptPath, ...scriptArgs] };
|
|
36487
37371
|
}
|
|
36488
37372
|
function _run_concern_inproc(main_fn, concern, envelope) {
|
|
36489
|
-
const scriptAbs =
|
|
37373
|
+
const scriptAbs = path104.join(REPO_ROOT, String(concern["script"]));
|
|
36490
37374
|
const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
|
|
36491
37375
|
argsList.push("--platform", String(envelope["platform"] || "generic"));
|
|
36492
37376
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
@@ -36563,7 +37447,7 @@ function _run_concern(concern, envelope) {
|
|
|
36563
37447
|
return _run_concern_inproc(inproc, concern, envelope);
|
|
36564
37448
|
}
|
|
36565
37449
|
}
|
|
36566
|
-
const script =
|
|
37450
|
+
const script = path104.join(REPO_ROOT, String(concern["script"]));
|
|
36567
37451
|
const argsList = Array.isArray(concern["args"]) ? concern["args"].map((a) => String(a)) : [];
|
|
36568
37452
|
const cmd = [script, ...argsList];
|
|
36569
37453
|
cmd.push("--platform", String(envelope["platform"] || "generic"));
|
|
@@ -36586,7 +37470,7 @@ function _run_concern(concern, envelope) {
|
|
|
36586
37470
|
const concern_env = hardenedSpawnEnv({ AGENT_CONFIG_PACKAGE_ROOT: REPO_ROOT });
|
|
36587
37471
|
const started = performance.now();
|
|
36588
37472
|
const { command, args: spawnArgs } = _resolve_tsx_invocation2(script, cmd.slice(1));
|
|
36589
|
-
const proc =
|
|
37473
|
+
const proc = spawnSync10(command, spawnArgs, {
|
|
36590
37474
|
input: _compactJsonDumps(envelope),
|
|
36591
37475
|
encoding: "utf-8",
|
|
36592
37476
|
cwd: workspace,
|
|
@@ -36620,7 +37504,7 @@ function _run_concern(concern, envelope) {
|
|
|
36620
37504
|
}
|
|
36621
37505
|
function _isFile8(p) {
|
|
36622
37506
|
try {
|
|
36623
|
-
return
|
|
37507
|
+
return fs102.statSync(p).isFile();
|
|
36624
37508
|
} catch {
|
|
36625
37509
|
return false;
|
|
36626
37510
|
}
|
|
@@ -36632,20 +37516,20 @@ function _reduce(rcs) {
|
|
|
36632
37516
|
if (rcs.some((rc) => rc === EXIT_BLOCK6)) {
|
|
36633
37517
|
return EXIT_BLOCK6;
|
|
36634
37518
|
}
|
|
36635
|
-
if (rcs.some((rc) => rc ===
|
|
36636
|
-
return
|
|
37519
|
+
if (rcs.some((rc) => rc === EXIT_WARN18)) {
|
|
37520
|
+
return EXIT_WARN18;
|
|
36637
37521
|
}
|
|
36638
|
-
return
|
|
37522
|
+
return EXIT_ALLOW35;
|
|
36639
37523
|
}
|
|
36640
37524
|
function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
36641
37525
|
if (is_replay_mode()) {
|
|
36642
37526
|
return;
|
|
36643
37527
|
}
|
|
36644
37528
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
36645
|
-
const state_root =
|
|
37529
|
+
const state_root = path104.join(workspace, "agents", "runtime", "state");
|
|
36646
37530
|
const fb_dir = feedback_dir(state_root, session_id);
|
|
36647
37531
|
try {
|
|
36648
|
-
|
|
37532
|
+
fs102.mkdirSync(fb_dir, { recursive: true });
|
|
36649
37533
|
} catch (exc) {
|
|
36650
37534
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
36651
37535
|
process.stderr.write(`dispatch_hook: feedback dir unavailable: ${msg}
|
|
@@ -36653,7 +37537,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
36653
37537
|
return;
|
|
36654
37538
|
}
|
|
36655
37539
|
for (const entry of entries) {
|
|
36656
|
-
const target =
|
|
37540
|
+
const target = path104.join(fb_dir, `${entry["concern"]}.json`);
|
|
36657
37541
|
try {
|
|
36658
37542
|
atomic_write_json(target, entry);
|
|
36659
37543
|
} catch (exc) {
|
|
@@ -36702,7 +37586,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
36702
37586
|
};
|
|
36703
37587
|
try {
|
|
36704
37588
|
const invocation = `${String(process.pid)}-${process.hrtime.bigint().toString()}`;
|
|
36705
|
-
update_json_under_lock(
|
|
37589
|
+
update_json_under_lock(path104.join(fb_dir, "summary.json"), (loaded) => {
|
|
36706
37590
|
const priorRaw = loaded["invocations"];
|
|
36707
37591
|
const prior = Array.isArray(priorRaw) ? priorRaw : [];
|
|
36708
37592
|
const next = [...prior, { invocation, ...summary }];
|
|
@@ -36724,13 +37608,13 @@ var SUMMARY_INVOCATION_CAP = 20;
|
|
|
36724
37608
|
function _record_rule_trips(envelope, entries) {
|
|
36725
37609
|
if (is_replay_mode()) return;
|
|
36726
37610
|
const tripped = entries.filter(
|
|
36727
|
-
(e) => e["exit_code"] === EXIT_BLOCK6 || e["exit_code"] ===
|
|
37611
|
+
(e) => e["exit_code"] === EXIT_BLOCK6 || e["exit_code"] === EXIT_WARN18
|
|
36728
37612
|
);
|
|
36729
37613
|
if (tripped.length === 0) return;
|
|
36730
37614
|
try {
|
|
36731
37615
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
36732
|
-
const state_dir =
|
|
36733
|
-
const target =
|
|
37616
|
+
const state_dir = path104.join(workspace, "agents", "runtime", "state");
|
|
37617
|
+
const target = path104.join(state_dir, "rule-trips.json");
|
|
36734
37618
|
const today = _now_iso3().slice(0, 10);
|
|
36735
37619
|
update_json_under_lock(target, (loaded) => {
|
|
36736
37620
|
const doc = { schema_version: 1, concerns: {}, ...loaded };
|
|
@@ -36742,7 +37626,7 @@ function _record_rule_trips(envelope, entries) {
|
|
|
36742
37626
|
const prev = _isObject17(prevRaw) ? prevRaw : { block: 0, warn: 0 };
|
|
36743
37627
|
concerns[name] = {
|
|
36744
37628
|
block: (Number(prev["block"]) || 0) + (e["exit_code"] === EXIT_BLOCK6 ? 1 : 0),
|
|
36745
|
-
warn: (Number(prev["warn"]) || 0) + (e["exit_code"] ===
|
|
37629
|
+
warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN18 ? 1 : 0),
|
|
36746
37630
|
last_trip: today
|
|
36747
37631
|
};
|
|
36748
37632
|
}
|
|
@@ -36835,7 +37719,7 @@ function _parse_args(argv) {
|
|
|
36835
37719
|
}
|
|
36836
37720
|
return args;
|
|
36837
37721
|
}
|
|
36838
|
-
function
|
|
37722
|
+
function main65(argv) {
|
|
36839
37723
|
const args = _parse_args(argv ?? process.argv.slice(2));
|
|
36840
37724
|
if (args.project_dir) {
|
|
36841
37725
|
const project_dir = _expanduser3(args.project_dir);
|
|
@@ -36853,29 +37737,29 @@ function main63(argv) {
|
|
|
36853
37737
|
if (probe.failure !== null) {
|
|
36854
37738
|
process.stderr.write(`dispatch_hook: --read-exit read failed: ${probe.failure}
|
|
36855
37739
|
`);
|
|
36856
|
-
return
|
|
37740
|
+
return EXIT_ALLOW35;
|
|
36857
37741
|
}
|
|
36858
37742
|
const envelope2 = _build_envelope(args, probe.text);
|
|
36859
37743
|
process.stderr.write(
|
|
36860
37744
|
`dispatch_hook: --read-exit ok (${probe.text.length} chars, ${Object.keys(_isObject17(envelope2["payload"]) ? envelope2["payload"] : {}).length} payload keys)
|
|
36861
37745
|
`
|
|
36862
37746
|
);
|
|
36863
|
-
return
|
|
37747
|
+
return EXIT_ALLOW35;
|
|
36864
37748
|
}
|
|
36865
37749
|
if (!EVENT_VOCABULARY.has(args.event)) {
|
|
36866
37750
|
process.stderr.write(
|
|
36867
37751
|
`dispatch_hook: unknown event '${args.event}'; allowed: ${_sortedRepr(EVENT_VOCABULARY)}
|
|
36868
37752
|
`
|
|
36869
37753
|
);
|
|
36870
|
-
return
|
|
37754
|
+
return EXIT_ALLOW35;
|
|
36871
37755
|
}
|
|
36872
37756
|
recordOpportunity(args.event, args.platform);
|
|
36873
37757
|
recordCapture(args.event, args.platform);
|
|
36874
37758
|
const manifest_path = args.manifest;
|
|
36875
|
-
if (!
|
|
37759
|
+
if (!fs102.existsSync(manifest_path)) {
|
|
36876
37760
|
process.stderr.write(`dispatch_hook: manifest missing at ${manifest_path}
|
|
36877
37761
|
`);
|
|
36878
|
-
return
|
|
37762
|
+
return EXIT_ALLOW35;
|
|
36879
37763
|
}
|
|
36880
37764
|
const manifest = _load_yaml3(manifest_path);
|
|
36881
37765
|
if (args.min_version) {
|
|
@@ -36921,10 +37805,10 @@ function main63(argv) {
|
|
|
36921
37805
|
concerns: concerns.map((c) => c["name"])
|
|
36922
37806
|
};
|
|
36923
37807
|
process.stdout.write(_py_json_dumps2(plan, 2) + "\n");
|
|
36924
|
-
return
|
|
37808
|
+
return EXIT_ALLOW35;
|
|
36925
37809
|
}
|
|
36926
37810
|
if (concerns.length === 0) {
|
|
36927
|
-
return
|
|
37811
|
+
return EXIT_ALLOW35;
|
|
36928
37812
|
}
|
|
36929
37813
|
if (_stdin_read_failed !== null) {
|
|
36930
37814
|
const deny = denyOnStdinFailure(args.platform, args.event, concerns, _stdin_read_failed);
|
|
@@ -36963,7 +37847,7 @@ function main63(argv) {
|
|
|
36963
37847
|
const raw_rc = rc;
|
|
36964
37848
|
if (rc >= 3) {
|
|
36965
37849
|
if (!concern["fail_closed"]) {
|
|
36966
|
-
rc =
|
|
37850
|
+
rc = EXIT_ALLOW35;
|
|
36967
37851
|
} else {
|
|
36968
37852
|
rc = EXIT_BLOCK6;
|
|
36969
37853
|
}
|
|
@@ -36976,7 +37860,7 @@ function main63(argv) {
|
|
|
36976
37860
|
`dispatch_hook: concern '${String(concern["name"])}' is declared severity: advisory but returned BLOCK \u2014 downgraded to warn.
|
|
36977
37861
|
`
|
|
36978
37862
|
);
|
|
36979
|
-
rc =
|
|
37863
|
+
rc = EXIT_WARN18;
|
|
36980
37864
|
}
|
|
36981
37865
|
rcs.push(rc);
|
|
36982
37866
|
const reply = _parse_concern_stdout(stdout_text);
|
|
@@ -36986,7 +37870,7 @@ function main63(argv) {
|
|
|
36986
37870
|
if (message) {
|
|
36987
37871
|
concern_messages.push({ rc, text: message, def: concern });
|
|
36988
37872
|
}
|
|
36989
|
-
if (args.event === "session_start" && rc ===
|
|
37873
|
+
if (args.event === "session_start" && rc === EXIT_ALLOW35 && typeof reply["context"] === "string" && reply["context"].trim()) {
|
|
36990
37874
|
context_blocks.push(reply["context"].trim());
|
|
36991
37875
|
}
|
|
36992
37876
|
feedback_entries.push({
|
|
@@ -37014,7 +37898,7 @@ function main63(argv) {
|
|
|
37014
37898
|
const final_rc = _reduce(rcs);
|
|
37015
37899
|
_write_feedback(envelope, session_id, feedback_entries, final_rc, started_at);
|
|
37016
37900
|
_record_rule_trips(envelope, feedback_entries);
|
|
37017
|
-
if (context_blocks.length > 0 && final_rc ===
|
|
37901
|
+
if (context_blocks.length > 0 && final_rc === EXIT_ALLOW35) {
|
|
37018
37902
|
process.stdout.write(context_blocks.join("\n\n") + "\n");
|
|
37019
37903
|
}
|
|
37020
37904
|
const decidingReasons = shapeAndRecord(
|
|
@@ -37039,7 +37923,7 @@ function main63(argv) {
|
|
|
37039
37923
|
}
|
|
37040
37924
|
function _isDir4(p) {
|
|
37041
37925
|
try {
|
|
37042
|
-
return
|
|
37926
|
+
return fs102.statSync(p).isDirectory();
|
|
37043
37927
|
} catch {
|
|
37044
37928
|
return false;
|
|
37045
37929
|
}
|
|
@@ -37049,36 +37933,36 @@ function _sortedRepr(s) {
|
|
|
37049
37933
|
return `[${items.map((x) => `'${x}'`).join(", ")}]`;
|
|
37050
37934
|
}
|
|
37051
37935
|
var _stdin_read_failed = null;
|
|
37052
|
-
function
|
|
37936
|
+
function _isCliEntry52() {
|
|
37053
37937
|
if (true) {
|
|
37054
37938
|
return false;
|
|
37055
37939
|
}
|
|
37056
37940
|
if (process.argv[1] === void 0) {
|
|
37057
37941
|
return false;
|
|
37058
37942
|
}
|
|
37059
|
-
const argvUrl =
|
|
37943
|
+
const argvUrl = pathToFileURL59(path104.resolve(process.argv[1])).href;
|
|
37060
37944
|
if (import.meta.url === argvUrl) {
|
|
37061
37945
|
return true;
|
|
37062
37946
|
}
|
|
37063
37947
|
try {
|
|
37064
|
-
const here =
|
|
37065
|
-
const argv =
|
|
37948
|
+
const here = fs102.realpathSync(fileURLToPath66(import.meta.url));
|
|
37949
|
+
const argv = fs102.realpathSync(path104.resolve(process.argv[1]));
|
|
37066
37950
|
return here === argv;
|
|
37067
37951
|
} catch {
|
|
37068
37952
|
return false;
|
|
37069
37953
|
}
|
|
37070
37954
|
}
|
|
37071
|
-
var isCliEntry14 =
|
|
37955
|
+
var isCliEntry14 = _isCliEntry52();
|
|
37072
37956
|
if (isCliEntry14) {
|
|
37073
|
-
process.exit(
|
|
37957
|
+
process.exit(main65(process.argv.slice(2)));
|
|
37074
37958
|
}
|
|
37075
37959
|
|
|
37076
37960
|
// src/scripts/hooks/dispatch_entry.ts
|
|
37077
|
-
var _selfPath =
|
|
37078
|
-
var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 &&
|
|
37961
|
+
var _selfPath = fileURLToPath67(import.meta.url);
|
|
37962
|
+
var _invokedDirectly2 = globalThis.__AC_HOOKS_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path105.resolve(process.argv[1]) === path105.resolve(_selfPath);
|
|
37079
37963
|
if (_invokedDirectly2) {
|
|
37080
|
-
process.exitCode =
|
|
37964
|
+
process.exitCode = main65(process.argv.slice(2));
|
|
37081
37965
|
}
|
|
37082
37966
|
export {
|
|
37083
|
-
|
|
37967
|
+
main65 as main
|
|
37084
37968
|
};
|