@event4u/agent-config 14.17.0 → 14.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +170 -79
- package/README.md +1 -1
- package/dist/agent-src/commands/pr/merge.md +35 -44
- package/dist/agent-src/skills/accessibility-auditor/SKILL.md +2 -0
- package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +27 -1
- package/dist/agent-src/skills/code-intelligence/SKILL.md +60 -12
- package/dist/agent-src/skills/complexity-first-planning/SKILL.md +27 -0
- package/dist/agent-src/skills/design-review/SKILL.md +2 -0
- package/dist/agent-src/skills/feature-planning/SKILL.md +34 -0
- package/dist/agent-src/skills/git-workflow/SKILL.md +37 -12
- package/dist/agent-src/skills/git-workflow/references/push-closes-its-loop.md +176 -0
- package/dist/agent-src/skills/laravel-mail/SKILL.md +44 -0
- package/dist/agent-src/skills/testing-anti-patterns/SKILL.md +40 -0
- package/dist/agent-src/skills/using-git-worktrees/SKILL.md +12 -0
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +53 -8
- package/dist/agent-src/skills/worktree-lifecycle/SKILL.md +3 -1
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/cli-delegate/cmd_conformance.js +335 -659
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +15 -15
- 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 +959 -1304
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +671 -1002
- package/dist/shared/settingsConsent.js +1 -1
- package/package.json +1 -1
- package/src/config/conformance-claim-baseline.json +9 -0
- package/src/config/gate-violation-baselines.json +3 -3
- package/src/config/release-gate-locality.yml +129 -0
- package/src/scripts/_lib/release_highlights.ts +172 -1
- package/src/scripts/_lib/release_material.ts +66 -0
- package/src/scripts/_lib/repeated_run.ts +77 -0
- package/src/scripts/_lib/tamper_vocabulary.ts +242 -0
- package/src/scripts/_lib/unified_diff.ts +121 -0
- package/src/scripts/check_finding_dispositions.ts +179 -3
- package/src/scripts/check_installed_hooks_fresh.ts +381 -0
- package/src/scripts/check_release_highlights.ts +25 -13
- package/src/scripts/check_suppression_hygiene.ts +11 -0
- package/src/scripts/code_graph/build.ts +230 -33
- package/src/scripts/code_graph/extract.ts +168 -33
- package/src/scripts/code_graph/types.ts +37 -2
- package/src/scripts/code_graph/validate.ts +12 -1
- package/src/scripts/conformance_scan.ts +2 -2
- package/src/scripts/detect_silent_catch.ts +403 -0
- package/src/scripts/detect_verification_tampering.ts +538 -0
- package/src/scripts/git_authorization_hook.ts +153 -17
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +33 -19
- package/src/scripts/hooks/block_no_verify.ts +3 -3
- package/src/scripts/hooks/concern_registry.ts +2 -2
- package/src/scripts/hooks/evidence_independence.ts +21 -2
- package/src/scripts/hooks/{block_unauthorized_git.ts → git_command_classifier.ts} +25 -369
- package/src/scripts/hooks/push_settle_hook.ts +250 -0
- package/src/scripts/hooks/ship_diff_volume_hook.ts +1 -1
- package/src/scripts/install-hooks.sh +134 -1
- package/src/scripts/language_mirror_hook.ts +27 -5
- package/src/scripts/release.ts +31 -143
- package/src/scripts/release_drill.ts +71 -1
- package/src/scripts/release_publication.ts +243 -3
- package/src/scripts/release_verify.ts +220 -0
- package/src/scripts/schemas/review-findings.schema.json +1 -1
- package/src/scripts/schemas/skill.schema.json +11 -1
- package/src/scripts/self_review_gate.ts +10 -1
- package/src/shared/settingsConsent.ts +1 -1
package/dist/mcp/server.mjs
CHANGED
|
@@ -1841,17 +1841,17 @@ var require_visit = __commonJS({
|
|
|
1841
1841
|
visit.BREAK = BREAK;
|
|
1842
1842
|
visit.SKIP = SKIP;
|
|
1843
1843
|
visit.REMOVE = REMOVE;
|
|
1844
|
-
function visit_(key, node, visitor,
|
|
1845
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
1844
|
+
function visit_(key, node, visitor, path92) {
|
|
1845
|
+
const ctrl = callVisitor(key, node, visitor, path92);
|
|
1846
1846
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
1847
|
-
replaceNode(key,
|
|
1848
|
-
return visit_(key, ctrl, visitor,
|
|
1847
|
+
replaceNode(key, path92, ctrl);
|
|
1848
|
+
return visit_(key, ctrl, visitor, path92);
|
|
1849
1849
|
}
|
|
1850
1850
|
if (typeof ctrl !== "symbol") {
|
|
1851
1851
|
if (identity.isCollection(node)) {
|
|
1852
|
-
|
|
1852
|
+
path92 = Object.freeze(path92.concat(node));
|
|
1853
1853
|
for (let i = 0; i < node.items.length; ++i) {
|
|
1854
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
1854
|
+
const ci = visit_(i, node.items[i], visitor, path92);
|
|
1855
1855
|
if (typeof ci === "number")
|
|
1856
1856
|
i = ci - 1;
|
|
1857
1857
|
else if (ci === BREAK)
|
|
@@ -1862,13 +1862,13 @@ var require_visit = __commonJS({
|
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
1864
|
} else if (identity.isPair(node)) {
|
|
1865
|
-
|
|
1866
|
-
const ck = visit_("key", node.key, visitor,
|
|
1865
|
+
path92 = Object.freeze(path92.concat(node));
|
|
1866
|
+
const ck = visit_("key", node.key, visitor, path92);
|
|
1867
1867
|
if (ck === BREAK)
|
|
1868
1868
|
return BREAK;
|
|
1869
1869
|
else if (ck === REMOVE)
|
|
1870
1870
|
node.key = null;
|
|
1871
|
-
const cv = visit_("value", node.value, visitor,
|
|
1871
|
+
const cv = visit_("value", node.value, visitor, path92);
|
|
1872
1872
|
if (cv === BREAK)
|
|
1873
1873
|
return BREAK;
|
|
1874
1874
|
else if (cv === REMOVE)
|
|
@@ -1889,17 +1889,17 @@ var require_visit = __commonJS({
|
|
|
1889
1889
|
visitAsync.BREAK = BREAK;
|
|
1890
1890
|
visitAsync.SKIP = SKIP;
|
|
1891
1891
|
visitAsync.REMOVE = REMOVE;
|
|
1892
|
-
async function visitAsync_(key, node, visitor,
|
|
1893
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
1892
|
+
async function visitAsync_(key, node, visitor, path92) {
|
|
1893
|
+
const ctrl = await callVisitor(key, node, visitor, path92);
|
|
1894
1894
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
1895
|
-
replaceNode(key,
|
|
1896
|
-
return visitAsync_(key, ctrl, visitor,
|
|
1895
|
+
replaceNode(key, path92, ctrl);
|
|
1896
|
+
return visitAsync_(key, ctrl, visitor, path92);
|
|
1897
1897
|
}
|
|
1898
1898
|
if (typeof ctrl !== "symbol") {
|
|
1899
1899
|
if (identity.isCollection(node)) {
|
|
1900
|
-
|
|
1900
|
+
path92 = Object.freeze(path92.concat(node));
|
|
1901
1901
|
for (let i = 0; i < node.items.length; ++i) {
|
|
1902
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
1902
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path92);
|
|
1903
1903
|
if (typeof ci === "number")
|
|
1904
1904
|
i = ci - 1;
|
|
1905
1905
|
else if (ci === BREAK)
|
|
@@ -1910,13 +1910,13 @@ var require_visit = __commonJS({
|
|
|
1910
1910
|
}
|
|
1911
1911
|
}
|
|
1912
1912
|
} else if (identity.isPair(node)) {
|
|
1913
|
-
|
|
1914
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
1913
|
+
path92 = Object.freeze(path92.concat(node));
|
|
1914
|
+
const ck = await visitAsync_("key", node.key, visitor, path92);
|
|
1915
1915
|
if (ck === BREAK)
|
|
1916
1916
|
return BREAK;
|
|
1917
1917
|
else if (ck === REMOVE)
|
|
1918
1918
|
node.key = null;
|
|
1919
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
1919
|
+
const cv = await visitAsync_("value", node.value, visitor, path92);
|
|
1920
1920
|
if (cv === BREAK)
|
|
1921
1921
|
return BREAK;
|
|
1922
1922
|
else if (cv === REMOVE)
|
|
@@ -1943,23 +1943,23 @@ var require_visit = __commonJS({
|
|
|
1943
1943
|
}
|
|
1944
1944
|
return visitor;
|
|
1945
1945
|
}
|
|
1946
|
-
function callVisitor(key, node, visitor,
|
|
1946
|
+
function callVisitor(key, node, visitor, path92) {
|
|
1947
1947
|
if (typeof visitor === "function")
|
|
1948
|
-
return visitor(key, node,
|
|
1948
|
+
return visitor(key, node, path92);
|
|
1949
1949
|
if (identity.isMap(node))
|
|
1950
|
-
return visitor.Map?.(key, node,
|
|
1950
|
+
return visitor.Map?.(key, node, path92);
|
|
1951
1951
|
if (identity.isSeq(node))
|
|
1952
|
-
return visitor.Seq?.(key, node,
|
|
1952
|
+
return visitor.Seq?.(key, node, path92);
|
|
1953
1953
|
if (identity.isPair(node))
|
|
1954
|
-
return visitor.Pair?.(key, node,
|
|
1954
|
+
return visitor.Pair?.(key, node, path92);
|
|
1955
1955
|
if (identity.isScalar(node))
|
|
1956
|
-
return visitor.Scalar?.(key, node,
|
|
1956
|
+
return visitor.Scalar?.(key, node, path92);
|
|
1957
1957
|
if (identity.isAlias(node))
|
|
1958
|
-
return visitor.Alias?.(key, node,
|
|
1958
|
+
return visitor.Alias?.(key, node, path92);
|
|
1959
1959
|
return void 0;
|
|
1960
1960
|
}
|
|
1961
|
-
function replaceNode(key,
|
|
1962
|
-
const parent =
|
|
1961
|
+
function replaceNode(key, path92, node) {
|
|
1962
|
+
const parent = path92[path92.length - 1];
|
|
1963
1963
|
if (identity.isCollection(parent)) {
|
|
1964
1964
|
parent.items[key] = node;
|
|
1965
1965
|
} else if (identity.isPair(parent)) {
|
|
@@ -2569,10 +2569,10 @@ var require_Collection = __commonJS({
|
|
|
2569
2569
|
var createNode = require_createNode();
|
|
2570
2570
|
var identity = require_identity();
|
|
2571
2571
|
var Node = require_Node();
|
|
2572
|
-
function collectionFromPath(schema,
|
|
2572
|
+
function collectionFromPath(schema, path92, value) {
|
|
2573
2573
|
let v = value;
|
|
2574
|
-
for (let i =
|
|
2575
|
-
const k =
|
|
2574
|
+
for (let i = path92.length - 1; i >= 0; --i) {
|
|
2575
|
+
const k = path92[i];
|
|
2576
2576
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
2577
2577
|
const a = [];
|
|
2578
2578
|
a[k] = v;
|
|
@@ -2591,7 +2591,7 @@ var require_Collection = __commonJS({
|
|
|
2591
2591
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
2592
2592
|
});
|
|
2593
2593
|
}
|
|
2594
|
-
var isEmptyPath = (
|
|
2594
|
+
var isEmptyPath = (path92) => path92 == null || typeof path92 === "object" && !!path92[Symbol.iterator]().next().done;
|
|
2595
2595
|
var Collection = class extends Node.NodeBase {
|
|
2596
2596
|
constructor(type, schema) {
|
|
2597
2597
|
super(type);
|
|
@@ -2621,11 +2621,11 @@ var require_Collection = __commonJS({
|
|
|
2621
2621
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
2622
2622
|
* that already exists in the map.
|
|
2623
2623
|
*/
|
|
2624
|
-
addIn(
|
|
2625
|
-
if (isEmptyPath(
|
|
2624
|
+
addIn(path92, value) {
|
|
2625
|
+
if (isEmptyPath(path92))
|
|
2626
2626
|
this.add(value);
|
|
2627
2627
|
else {
|
|
2628
|
-
const [key, ...rest] =
|
|
2628
|
+
const [key, ...rest] = path92;
|
|
2629
2629
|
const node = this.get(key, true);
|
|
2630
2630
|
if (identity.isCollection(node))
|
|
2631
2631
|
node.addIn(rest, value);
|
|
@@ -2639,8 +2639,8 @@ var require_Collection = __commonJS({
|
|
|
2639
2639
|
* Removes a value from the collection.
|
|
2640
2640
|
* @returns `true` if the item was found and removed.
|
|
2641
2641
|
*/
|
|
2642
|
-
deleteIn(
|
|
2643
|
-
const [key, ...rest] =
|
|
2642
|
+
deleteIn(path92) {
|
|
2643
|
+
const [key, ...rest] = path92;
|
|
2644
2644
|
if (rest.length === 0)
|
|
2645
2645
|
return this.delete(key);
|
|
2646
2646
|
const node = this.get(key, true);
|
|
@@ -2654,8 +2654,8 @@ var require_Collection = __commonJS({
|
|
|
2654
2654
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
2655
2655
|
* `true` (collections are always returned intact).
|
|
2656
2656
|
*/
|
|
2657
|
-
getIn(
|
|
2658
|
-
const [key, ...rest] =
|
|
2657
|
+
getIn(path92, keepScalar) {
|
|
2658
|
+
const [key, ...rest] = path92;
|
|
2659
2659
|
const node = this.get(key, true);
|
|
2660
2660
|
if (rest.length === 0)
|
|
2661
2661
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -2673,8 +2673,8 @@ var require_Collection = __commonJS({
|
|
|
2673
2673
|
/**
|
|
2674
2674
|
* Checks if the collection includes a value with the key `key`.
|
|
2675
2675
|
*/
|
|
2676
|
-
hasIn(
|
|
2677
|
-
const [key, ...rest] =
|
|
2676
|
+
hasIn(path92) {
|
|
2677
|
+
const [key, ...rest] = path92;
|
|
2678
2678
|
if (rest.length === 0)
|
|
2679
2679
|
return this.has(key);
|
|
2680
2680
|
const node = this.get(key, true);
|
|
@@ -2684,8 +2684,8 @@ var require_Collection = __commonJS({
|
|
|
2684
2684
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
2685
2685
|
* boolean to add/remove the item from the set.
|
|
2686
2686
|
*/
|
|
2687
|
-
setIn(
|
|
2688
|
-
const [key, ...rest] =
|
|
2687
|
+
setIn(path92, value) {
|
|
2688
|
+
const [key, ...rest] = path92;
|
|
2689
2689
|
if (rest.length === 0) {
|
|
2690
2690
|
this.set(key, value);
|
|
2691
2691
|
} else {
|
|
@@ -5200,9 +5200,9 @@ var require_Document = __commonJS({
|
|
|
5200
5200
|
this.contents.add(value);
|
|
5201
5201
|
}
|
|
5202
5202
|
/** Adds a value to the document. */
|
|
5203
|
-
addIn(
|
|
5203
|
+
addIn(path92, value) {
|
|
5204
5204
|
if (assertCollection(this.contents))
|
|
5205
|
-
this.contents.addIn(
|
|
5205
|
+
this.contents.addIn(path92, value);
|
|
5206
5206
|
}
|
|
5207
5207
|
/**
|
|
5208
5208
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -5277,14 +5277,14 @@ var require_Document = __commonJS({
|
|
|
5277
5277
|
* Removes a value from the document.
|
|
5278
5278
|
* @returns `true` if the item was found and removed.
|
|
5279
5279
|
*/
|
|
5280
|
-
deleteIn(
|
|
5281
|
-
if (Collection.isEmptyPath(
|
|
5280
|
+
deleteIn(path92) {
|
|
5281
|
+
if (Collection.isEmptyPath(path92)) {
|
|
5282
5282
|
if (this.contents == null)
|
|
5283
5283
|
return false;
|
|
5284
5284
|
this.contents = null;
|
|
5285
5285
|
return true;
|
|
5286
5286
|
}
|
|
5287
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
5287
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path92) : false;
|
|
5288
5288
|
}
|
|
5289
5289
|
/**
|
|
5290
5290
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -5299,10 +5299,10 @@ var require_Document = __commonJS({
|
|
|
5299
5299
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
5300
5300
|
* `true` (collections are always returned intact).
|
|
5301
5301
|
*/
|
|
5302
|
-
getIn(
|
|
5303
|
-
if (Collection.isEmptyPath(
|
|
5302
|
+
getIn(path92, keepScalar) {
|
|
5303
|
+
if (Collection.isEmptyPath(path92))
|
|
5304
5304
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
5305
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
5305
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path92, keepScalar) : void 0;
|
|
5306
5306
|
}
|
|
5307
5307
|
/**
|
|
5308
5308
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -5313,10 +5313,10 @@ var require_Document = __commonJS({
|
|
|
5313
5313
|
/**
|
|
5314
5314
|
* Checks if the document includes a value at `path`.
|
|
5315
5315
|
*/
|
|
5316
|
-
hasIn(
|
|
5317
|
-
if (Collection.isEmptyPath(
|
|
5316
|
+
hasIn(path92) {
|
|
5317
|
+
if (Collection.isEmptyPath(path92))
|
|
5318
5318
|
return this.contents !== void 0;
|
|
5319
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
5319
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path92) : false;
|
|
5320
5320
|
}
|
|
5321
5321
|
/**
|
|
5322
5322
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -5333,13 +5333,13 @@ var require_Document = __commonJS({
|
|
|
5333
5333
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
5334
5334
|
* boolean to add/remove the item from the set.
|
|
5335
5335
|
*/
|
|
5336
|
-
setIn(
|
|
5337
|
-
if (Collection.isEmptyPath(
|
|
5336
|
+
setIn(path92, value) {
|
|
5337
|
+
if (Collection.isEmptyPath(path92)) {
|
|
5338
5338
|
this.contents = value;
|
|
5339
5339
|
} else if (this.contents == null) {
|
|
5340
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
5340
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path92), value);
|
|
5341
5341
|
} else if (assertCollection(this.contents)) {
|
|
5342
|
-
this.contents.setIn(
|
|
5342
|
+
this.contents.setIn(path92, value);
|
|
5343
5343
|
}
|
|
5344
5344
|
}
|
|
5345
5345
|
/**
|
|
@@ -7299,9 +7299,9 @@ var require_cst_visit = __commonJS({
|
|
|
7299
7299
|
visit.BREAK = BREAK;
|
|
7300
7300
|
visit.SKIP = SKIP;
|
|
7301
7301
|
visit.REMOVE = REMOVE;
|
|
7302
|
-
visit.itemAtPath = (cst,
|
|
7302
|
+
visit.itemAtPath = (cst, path92) => {
|
|
7303
7303
|
let item = cst;
|
|
7304
|
-
for (const [field, index] of
|
|
7304
|
+
for (const [field, index] of path92) {
|
|
7305
7305
|
const tok = item?.[field];
|
|
7306
7306
|
if (tok && "items" in tok) {
|
|
7307
7307
|
item = tok.items[index];
|
|
@@ -7310,23 +7310,23 @@ var require_cst_visit = __commonJS({
|
|
|
7310
7310
|
}
|
|
7311
7311
|
return item;
|
|
7312
7312
|
};
|
|
7313
|
-
visit.parentCollection = (cst,
|
|
7314
|
-
const parent = visit.itemAtPath(cst,
|
|
7315
|
-
const field =
|
|
7313
|
+
visit.parentCollection = (cst, path92) => {
|
|
7314
|
+
const parent = visit.itemAtPath(cst, path92.slice(0, -1));
|
|
7315
|
+
const field = path92[path92.length - 1][0];
|
|
7316
7316
|
const coll = parent?.[field];
|
|
7317
7317
|
if (coll && "items" in coll)
|
|
7318
7318
|
return coll;
|
|
7319
7319
|
throw new Error("Parent collection not found");
|
|
7320
7320
|
};
|
|
7321
|
-
function _visit(
|
|
7322
|
-
let ctrl = visitor(item,
|
|
7321
|
+
function _visit(path92, item, visitor) {
|
|
7322
|
+
let ctrl = visitor(item, path92);
|
|
7323
7323
|
if (typeof ctrl === "symbol")
|
|
7324
7324
|
return ctrl;
|
|
7325
7325
|
for (const field of ["key", "value"]) {
|
|
7326
7326
|
const token = item[field];
|
|
7327
7327
|
if (token && "items" in token) {
|
|
7328
7328
|
for (let i = 0; i < token.items.length; ++i) {
|
|
7329
|
-
const ci = _visit(Object.freeze(
|
|
7329
|
+
const ci = _visit(Object.freeze(path92.concat([[field, i]])), token.items[i], visitor);
|
|
7330
7330
|
if (typeof ci === "number")
|
|
7331
7331
|
i = ci - 1;
|
|
7332
7332
|
else if (ci === BREAK)
|
|
@@ -7337,10 +7337,10 @@ var require_cst_visit = __commonJS({
|
|
|
7337
7337
|
}
|
|
7338
7338
|
}
|
|
7339
7339
|
if (typeof ctrl === "function" && field === "key")
|
|
7340
|
-
ctrl = ctrl(item,
|
|
7340
|
+
ctrl = ctrl(item, path92);
|
|
7341
7341
|
}
|
|
7342
7342
|
}
|
|
7343
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
7343
|
+
return typeof ctrl === "function" ? ctrl(item, path92) : ctrl;
|
|
7344
7344
|
}
|
|
7345
7345
|
exports.visit = visit;
|
|
7346
7346
|
}
|
|
@@ -8642,14 +8642,14 @@ var require_parser = __commonJS({
|
|
|
8642
8642
|
case "scalar":
|
|
8643
8643
|
case "single-quoted-scalar":
|
|
8644
8644
|
case "double-quoted-scalar": {
|
|
8645
|
-
const
|
|
8645
|
+
const fs94 = this.flowScalar(this.type);
|
|
8646
8646
|
if (atNextItem || it.value) {
|
|
8647
|
-
map.items.push({ start, key:
|
|
8647
|
+
map.items.push({ start, key: fs94, sep: [] });
|
|
8648
8648
|
this.onKeyLine = true;
|
|
8649
8649
|
} else if (it.sep) {
|
|
8650
|
-
this.stack.push(
|
|
8650
|
+
this.stack.push(fs94);
|
|
8651
8651
|
} else {
|
|
8652
|
-
Object.assign(it, { key:
|
|
8652
|
+
Object.assign(it, { key: fs94, sep: [] });
|
|
8653
8653
|
this.onKeyLine = true;
|
|
8654
8654
|
}
|
|
8655
8655
|
return;
|
|
@@ -8777,13 +8777,13 @@ var require_parser = __commonJS({
|
|
|
8777
8777
|
case "scalar":
|
|
8778
8778
|
case "single-quoted-scalar":
|
|
8779
8779
|
case "double-quoted-scalar": {
|
|
8780
|
-
const
|
|
8780
|
+
const fs94 = this.flowScalar(this.type);
|
|
8781
8781
|
if (!it || it.value)
|
|
8782
|
-
fc.items.push({ start: [], key:
|
|
8782
|
+
fc.items.push({ start: [], key: fs94, sep: [] });
|
|
8783
8783
|
else if (it.sep)
|
|
8784
|
-
this.stack.push(
|
|
8784
|
+
this.stack.push(fs94);
|
|
8785
8785
|
else
|
|
8786
|
-
Object.assign(it, { key:
|
|
8786
|
+
Object.assign(it, { key: fs94, sep: [] });
|
|
8787
8787
|
return;
|
|
8788
8788
|
}
|
|
8789
8789
|
case "flow-map-end":
|
|
@@ -22974,8 +22974,8 @@ function lockfile_path(env) {
|
|
|
22974
22974
|
}
|
|
22975
22975
|
return write_target("installed.lock", { env: env ?? null });
|
|
22976
22976
|
}
|
|
22977
|
-
function read_lockfile(
|
|
22978
|
-
const target =
|
|
22977
|
+
function read_lockfile(path92) {
|
|
22978
|
+
const target = path92 ?? lockfile_path();
|
|
22979
22979
|
let text;
|
|
22980
22980
|
try {
|
|
22981
22981
|
text = fs38.readFileSync(target, { encoding: "utf-8" });
|
|
@@ -23192,18 +23192,18 @@ function manifest_path(project_root, env) {
|
|
|
23192
23192
|
}
|
|
23193
23193
|
return fsPath.join(project_root, DEFAULT_MANIFEST_RELATIVE);
|
|
23194
23194
|
}
|
|
23195
|
-
function read_manifest(
|
|
23195
|
+
function read_manifest(path92) {
|
|
23196
23196
|
let text;
|
|
23197
23197
|
try {
|
|
23198
|
-
text = require_read_text(
|
|
23198
|
+
text = require_read_text(path92);
|
|
23199
23199
|
} catch {
|
|
23200
23200
|
return null;
|
|
23201
23201
|
}
|
|
23202
23202
|
const data = _parse_manual(text);
|
|
23203
23203
|
return _normalise_v2_shape(data);
|
|
23204
23204
|
}
|
|
23205
|
-
function require_read_text(
|
|
23206
|
-
return fs40.readFileSync(
|
|
23205
|
+
function require_read_text(path92) {
|
|
23206
|
+
return fs40.readFileSync(path92, { encoding: "utf-8" });
|
|
23207
23207
|
}
|
|
23208
23208
|
function _normalise_v2_shape(data) {
|
|
23209
23209
|
if (data["tools"] === void 0 || data["tools"] === null) {
|
|
@@ -23384,9 +23384,9 @@ function stable_sort(items, key) {
|
|
|
23384
23384
|
return a.index - b.index;
|
|
23385
23385
|
}).map((entry) => entry.item);
|
|
23386
23386
|
}
|
|
23387
|
-
function write_manifest(
|
|
23387
|
+
function write_manifest(path92, version, tools, options = {}) {
|
|
23388
23388
|
const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
|
|
23389
|
-
return write_atomic(
|
|
23389
|
+
return write_atomic(path92, rendered);
|
|
23390
23390
|
}
|
|
23391
23391
|
function upsert_tool(existing, options) {
|
|
23392
23392
|
const {
|
|
@@ -36596,9 +36596,9 @@ function detectToolPresence(root) {
|
|
|
36596
36596
|
agentsMd: existsSync33(join58(root, "AGENTS.md"))
|
|
36597
36597
|
};
|
|
36598
36598
|
}
|
|
36599
|
-
function isDir5(
|
|
36599
|
+
function isDir5(path92) {
|
|
36600
36600
|
try {
|
|
36601
|
-
return statSync38(
|
|
36601
|
+
return statSync38(path92).isDirectory();
|
|
36602
36602
|
} catch {
|
|
36603
36603
|
return false;
|
|
36604
36604
|
}
|
|
@@ -36909,7 +36909,11 @@ function _setPinLost(consumer_root, session_id) {
|
|
|
36909
36909
|
_migrateLegacyMarker(consumer_root);
|
|
36910
36910
|
try {
|
|
36911
36911
|
atomic_write_text(path65.join(consumer_root, pinLostMarker(session_id)), (/* @__PURE__ */ new Date()).toISOString());
|
|
36912
|
-
} catch {
|
|
36912
|
+
} catch (err) {
|
|
36913
|
+
process.stderr.write(
|
|
36914
|
+
`language-mirror: pin-lost marker write failed (${_errText(err)}) \u2014 the pin will NOT be re-emitted after this compaction. Turn outcome unchanged.
|
|
36915
|
+
`
|
|
36916
|
+
);
|
|
36913
36917
|
}
|
|
36914
36918
|
}
|
|
36915
36919
|
function _pinLost(consumer_root, session_id) {
|
|
@@ -37134,7 +37138,11 @@ function run(stdin_text, options) {
|
|
|
37134
37138
|
atomic_write_json(target, next);
|
|
37135
37139
|
_pruneLegacyState(options.consumer_root);
|
|
37136
37140
|
_pruneStaleSessions(options.consumer_root, Date.now());
|
|
37137
|
-
} catch {
|
|
37141
|
+
} catch (err) {
|
|
37142
|
+
process.stderr.write(
|
|
37143
|
+
`language-mirror: pin-state write failed (${_errText(err)}) \u2014 the language pin did NOT persist and the next turn re-derives it. This turn's notice is unchanged.
|
|
37144
|
+
`
|
|
37145
|
+
);
|
|
37138
37146
|
}
|
|
37139
37147
|
}
|
|
37140
37148
|
if (effective === "de" || effective === "en") {
|
|
@@ -37146,6 +37154,10 @@ function run(stdin_text, options) {
|
|
|
37146
37154
|
}
|
|
37147
37155
|
return EXIT_ALLOW;
|
|
37148
37156
|
}
|
|
37157
|
+
function _errText(err) {
|
|
37158
|
+
const t = err instanceof Error ? err.message : String(err);
|
|
37159
|
+
return t.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
37160
|
+
}
|
|
37149
37161
|
function main22(argv) {
|
|
37150
37162
|
const args = argv ?? process.argv.slice(2);
|
|
37151
37163
|
let consumer_root = process.cwd();
|
|
@@ -37292,7 +37304,7 @@ function splitFences(prompt) {
|
|
|
37292
37304
|
function _commandLines(fence) {
|
|
37293
37305
|
return fence.split("\n").map((l) => l.trim()).filter((l) => l.length > 0).filter((l) => !/^(remote:|error:|hint:|fatal:|warning:|To |!\s|\s*\^)/i.test(l)).map((l) => l.replace(/^[$>#]\s*/, "")).filter((l) => /^(git|gh|npm|pnpm|yarn|task)\b/.test(l));
|
|
37294
37306
|
}
|
|
37295
|
-
function
|
|
37307
|
+
function _errText2(err) {
|
|
37296
37308
|
const t = err instanceof Error ? err.message : String(err);
|
|
37297
37309
|
return t.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
37298
37310
|
}
|
|
@@ -37309,7 +37321,17 @@ function extractMergeTargets(prompt) {
|
|
|
37309
37321
|
return [...out].sort((a, b) => a - b);
|
|
37310
37322
|
}
|
|
37311
37323
|
function isRevocation(prompt) {
|
|
37312
|
-
|
|
37324
|
+
if (REVOKE_STOP_WORD.test(prompt) || isBareRefusal(prompt)) {
|
|
37325
|
+
return true;
|
|
37326
|
+
}
|
|
37327
|
+
MERGE_VERB.lastIndex = 0;
|
|
37328
|
+
let m;
|
|
37329
|
+
while ((m = MERGE_VERB.exec(prompt)) !== null) {
|
|
37330
|
+
if (negatedBefore(prompt, m.index, m[0])) {
|
|
37331
|
+
return true;
|
|
37332
|
+
}
|
|
37333
|
+
}
|
|
37334
|
+
return false;
|
|
37313
37335
|
}
|
|
37314
37336
|
function _grantId(session_id, at, targets) {
|
|
37315
37337
|
return `${sessionSlug(session_id) || "nosession"}:${at}:${targets.join(",")}`;
|
|
@@ -37429,6 +37451,17 @@ function negatedBefore(text, index, matched = "") {
|
|
|
37429
37451
|
const after = afterFrom < end ? text.slice(afterFrom, clauseEnd(text, afterFrom, end)) : "";
|
|
37430
37452
|
return NEGATION_WORD.test(before) || NEGATION_WORD.test(matched) || NEGATION_WORD.test(after);
|
|
37431
37453
|
}
|
|
37454
|
+
function isBareRefusal(text) {
|
|
37455
|
+
for (const sentence of _sentences(text)) {
|
|
37456
|
+
for (const clause of sentence.split(CLAUSE_SPLIT)) {
|
|
37457
|
+
const tokens = (clause ?? "").match(WORD_TOKEN) ?? [];
|
|
37458
|
+
if (tokens.length > 0 && tokens.every((t) => NEGATION_TOKEN.test(t))) {
|
|
37459
|
+
return true;
|
|
37460
|
+
}
|
|
37461
|
+
}
|
|
37462
|
+
}
|
|
37463
|
+
return false;
|
|
37464
|
+
}
|
|
37432
37465
|
function classifyAuthorization(prompt) {
|
|
37433
37466
|
const { prose, fences } = splitFences(prompt);
|
|
37434
37467
|
const authorized = /* @__PURE__ */ new Set();
|
|
@@ -37496,40 +37529,6 @@ function readGrants(consumer_root, session_id) {
|
|
|
37496
37529
|
return [];
|
|
37497
37530
|
}
|
|
37498
37531
|
}
|
|
37499
|
-
function consumeGrantTarget(consumer_root, session_id, target) {
|
|
37500
|
-
const file = path66.join(consumer_root, ledgerFileFor(session_id));
|
|
37501
|
-
let decoded;
|
|
37502
|
-
try {
|
|
37503
|
-
decoded = JSON.parse(fs65.readFileSync(file, "utf8"));
|
|
37504
|
-
} catch {
|
|
37505
|
-
return;
|
|
37506
|
-
}
|
|
37507
|
-
if (!_isObject4(decoded) || !Array.isArray(decoded["grants"])) {
|
|
37508
|
-
return;
|
|
37509
|
-
}
|
|
37510
|
-
let touched = false;
|
|
37511
|
-
for (const g of decoded["grants"]) {
|
|
37512
|
-
if (!_isObject4(g) || !Array.isArray(g["targets"]) || !Array.isArray(g["consumed"])) {
|
|
37513
|
-
continue;
|
|
37514
|
-
}
|
|
37515
|
-
const targets = g["targets"];
|
|
37516
|
-
const consumed = g["consumed"];
|
|
37517
|
-
if (targets.includes(target) && !consumed.includes(target)) {
|
|
37518
|
-
consumed.push(target);
|
|
37519
|
-
touched = true;
|
|
37520
|
-
}
|
|
37521
|
-
}
|
|
37522
|
-
if (touched) {
|
|
37523
|
-
try {
|
|
37524
|
-
atomic_write_json(file, decoded);
|
|
37525
|
-
} catch (err) {
|
|
37526
|
-
process.stderr.write(
|
|
37527
|
-
`git-authorization: grant-consumption write failed (${_errText(err)}) \u2014 the target stays UNSPENT, so one further merge of a PR the user named will still be authorized. Authorization outcome unchanged.
|
|
37528
|
-
`
|
|
37529
|
-
);
|
|
37530
|
-
}
|
|
37531
|
-
}
|
|
37532
|
-
}
|
|
37533
37532
|
function takePending(consumer_root, session_id, now) {
|
|
37534
37533
|
const file = path66.join(consumer_root, pendingFileFor(session_id));
|
|
37535
37534
|
let raw;
|
|
@@ -37621,7 +37620,7 @@ function run2(stdin_text, options) {
|
|
|
37621
37620
|
atomic_write_json(path66.join(options.consumer_root, ledgerFileFor(session)), ledger);
|
|
37622
37621
|
} catch (err) {
|
|
37623
37622
|
process.stderr.write(
|
|
37624
|
-
`git-authorization: session-ledger write failed (${
|
|
37623
|
+
`git-authorization: session-ledger write failed (${_errText2(err)}) \u2014 the gate degrades to "no ledger" for this session, which denies the irreversible subset and warns on the rest. Authorization outcome unchanged.
|
|
37625
37624
|
`
|
|
37626
37625
|
);
|
|
37627
37626
|
}
|
|
@@ -37660,7 +37659,7 @@ function _isCliEntry19() {
|
|
|
37660
37659
|
return false;
|
|
37661
37660
|
}
|
|
37662
37661
|
}
|
|
37663
|
-
var EXIT_ALLOW2, STATE_FILE2, STATE_DIR2, PENDING_DIR, PENDING_FILE, PENDING_MAX_AGE_MS, ALL_OPS, PHRASES, OUTPUT_LINE, PASTED_COMMANDS, PR_NUMBER_MAX,
|
|
37662
|
+
var EXIT_ALLOW2, STATE_FILE2, STATE_DIR2, PENDING_DIR, PENDING_FILE, PENDING_MAX_AGE_MS, ALL_OPS, PHRASES, OUTPUT_LINE, PASTED_COMMANDS, PR_NUMBER_MAX, REVOKE_STOP_WORD, MERGE_VERB, APOSTROPHE, NEGATION_ALTERNATION, NEGATION_WORD, NEGATION_TOKEN, CONTRAST_ALTERNATION, CONTRAST_CUE, ABBREVIATION_BEFORE_DOT, WORD_TOKEN, CLAUSE_SPLIT;
|
|
37664
37663
|
var init_git_authorization_hook = __esm({
|
|
37665
37664
|
"src/scripts/git_authorization_hook.ts"() {
|
|
37666
37665
|
"use strict";
|
|
@@ -37882,159 +37881,30 @@ var init_git_authorization_hook = __esm({
|
|
|
37882
37881
|
{ op: "branch", re: /\bgit\s+(checkout\s+-b|switch\s+-c|branch)\b/i }
|
|
37883
37882
|
];
|
|
37884
37883
|
PR_NUMBER_MAX = 2147483647;
|
|
37885
|
-
|
|
37886
|
-
|
|
37887
|
-
|
|
37884
|
+
REVOKE_STOP_WORD = /\b(stop|stopp|halt|abbrechen|abbruch|cancel|revoke|widerruf(en)?|zur(ü|ue)ck(nehmen|ziehen)|hold\s+(everything|on|the\s+merge)|warte|wait)\b/iu;
|
|
37885
|
+
MERGE_VERB = /\b(merg(e|en|ing)|zusammenf(ü|ue)hren)\b/giu;
|
|
37886
|
+
APOSTROPHE = "'\u2019\u2018\u02BC";
|
|
37887
|
+
NEGATION_ALTERNATION = `nicht|nichts|kein(?:e|en|em|er|es)?|niemals|nie|no|not|don[${APOSTROPHE}]?t|never|without|ohne`;
|
|
37888
|
+
NEGATION_WORD = new RegExp(`\\b(${NEGATION_ALTERNATION})\\b`, "i");
|
|
37889
|
+
NEGATION_TOKEN = new RegExp(`^(?:${NEGATION_ALTERNATION})$`, "i");
|
|
37890
|
+
CONTRAST_ALTERNATION = "aber|sondern|jedoch|but|however|instead";
|
|
37891
|
+
CONTRAST_CUE = new RegExp(`\\b(${CONTRAST_ALTERNATION})\\b`, "gi");
|
|
37888
37892
|
ABBREVIATION_BEFORE_DOT = /(?:^|[\s("'\u2018\u201c])(?:[a-z]|z\.b|bzw|ca|usw|d\.h|u\.a|evtl|ggf|inkl|max|min|nr|abb|e\.g|i\.e|etc|vs|approx|fig|no|st|dr|prof)\.$/i;
|
|
37893
|
+
WORD_TOKEN = new RegExp(`[\\p{L}\\p{N}${APOSTROPHE}]+`, "gu");
|
|
37894
|
+
CLAUSE_SPLIT = new RegExp(`[,;:]|\\b(?:${CONTRAST_ALTERNATION})\\b`, "iu");
|
|
37889
37895
|
if (_isCliEntry19()) {
|
|
37890
37896
|
process.exit(main23());
|
|
37891
37897
|
}
|
|
37892
37898
|
}
|
|
37893
37899
|
});
|
|
37894
37900
|
|
|
37895
|
-
// src/scripts/hooks/
|
|
37896
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
37897
|
-
function fileBlocks(patch) {
|
|
37898
|
-
return patch.split(/^(?=diff --git )/m).filter((b) => b.startsWith("diff --git "));
|
|
37899
|
-
}
|
|
37900
|
-
function renamedSchemaRemoval(patch) {
|
|
37901
|
-
for (const block of fileBlocks(patch)) {
|
|
37902
|
-
if (!RENAME_METADATA.test(block)) {
|
|
37903
|
-
continue;
|
|
37904
|
-
}
|
|
37905
|
-
for (const line of block.split("\n")) {
|
|
37906
|
-
if (line.startsWith("-") && !line.startsWith("---") && SCHEMA_REMOVAL_BODY.test(line)) {
|
|
37907
|
-
return true;
|
|
37908
|
-
}
|
|
37909
|
-
}
|
|
37910
|
-
}
|
|
37911
|
-
return false;
|
|
37912
|
-
}
|
|
37913
|
-
function classifyDiff(patch) {
|
|
37914
|
-
if (patch.trim() === "") {
|
|
37915
|
-
return { verdict: "undecidable", markers: [], reason: "empty diff" };
|
|
37916
|
-
}
|
|
37917
|
-
const markers = [];
|
|
37918
|
-
for (const { label, re } of DESTRUCTIVE_MARKERS) {
|
|
37919
|
-
if (re.test(patch)) {
|
|
37920
|
-
markers.push(label);
|
|
37921
|
-
}
|
|
37922
|
-
}
|
|
37923
|
-
if (renamedSchemaRemoval(patch)) {
|
|
37924
|
-
markers.push("a renamed file drops a column or table");
|
|
37925
|
-
}
|
|
37926
|
-
const bump = MAJOR_BUMP.exec(patch);
|
|
37927
|
-
if (bump && bump[1] !== bump[2]) {
|
|
37928
|
-
markers.push(`major version bump ${bump[1]}.x to ${bump[2]}.x`);
|
|
37929
|
-
}
|
|
37930
|
-
const filesChanged = (patch.match(/^diff --git /gm) ?? []).length;
|
|
37931
|
-
if (markers.length > 0) {
|
|
37932
|
-
return { verdict: "destructive", markers, filesChanged };
|
|
37933
|
-
}
|
|
37934
|
-
return { verdict: "additive", markers: [], filesChanged };
|
|
37935
|
-
}
|
|
37936
|
-
function fetchPatch(pr, opts = {}) {
|
|
37937
|
-
const run6 = opts.exec ?? execFileSync2;
|
|
37938
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
37939
|
-
const capture = (file, args) => run6(file, args, { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 15e3 });
|
|
37940
|
-
for (const ref of [`refs/pull/${pr}/head`, `pull/${pr}/head`]) {
|
|
37941
|
-
try {
|
|
37942
|
-
const base = capture("git", ["merge-base", "HEAD", ref]).trim();
|
|
37943
|
-
if (base) {
|
|
37944
|
-
const patch = capture("git", ["diff", `${base}...${ref}`]);
|
|
37945
|
-
if (patch.trim() !== "") {
|
|
37946
|
-
return { patch, source: "local" };
|
|
37947
|
-
}
|
|
37948
|
-
}
|
|
37949
|
-
} catch {
|
|
37950
|
-
}
|
|
37951
|
-
}
|
|
37952
|
-
if (opts.allowNetwork === false) {
|
|
37953
|
-
return { patch: "", source: "none", reason: "no local ref and network reads disabled" };
|
|
37954
|
-
}
|
|
37955
|
-
try {
|
|
37956
|
-
const patch = capture("gh", ["pr", "diff", String(pr), "--patch"]);
|
|
37957
|
-
if (patch.trim() !== "") {
|
|
37958
|
-
return { patch, source: "gh" };
|
|
37959
|
-
}
|
|
37960
|
-
return { patch: "", source: "none", reason: "gh returned an empty diff" };
|
|
37961
|
-
} catch {
|
|
37962
|
-
return { patch: "", source: "none", reason: "no local ref, and gh pr diff failed" };
|
|
37963
|
-
}
|
|
37964
|
-
}
|
|
37965
|
-
function analyseMergeImpact(pr, opts = {}) {
|
|
37966
|
-
const got = fetchPatch(pr, opts);
|
|
37967
|
-
if (got.source === "none") {
|
|
37968
|
-
return { verdict: "undecidable", markers: [], ...got.reason ? { reason: got.reason } : {} };
|
|
37969
|
-
}
|
|
37970
|
-
return classifyDiff(got.patch);
|
|
37971
|
-
}
|
|
37972
|
-
function describeImpact(pr, impact) {
|
|
37973
|
-
const say = `Say "merge #${pr}" to authorize it.`;
|
|
37974
|
-
switch (impact.verdict) {
|
|
37975
|
-
case "additive":
|
|
37976
|
-
return `Impact scan: PR #${pr} touches ${impact.filesChanged ?? 0} file(s) and trips no destructive marker \u2014 no schema drop, no removed export or route, no major bump, no BREAKING CHANGE. Additive as far as the diff can show, which is not the same as safe to merge: the base has moved since review and merging may trigger a deploy. ${say}`;
|
|
37977
|
-
case "destructive":
|
|
37978
|
-
return `Impact scan: PR #${pr} is NOT additive \u2014 ${impact.markers.join("; ")}. Read the diff before authorizing. ${say}`;
|
|
37979
|
-
default:
|
|
37980
|
-
return `Impact scan: could not read the diff for PR #${pr} (${impact.reason ?? "unknown"}), so nothing is known about what it changes. ${say}`;
|
|
37981
|
-
}
|
|
37982
|
-
}
|
|
37983
|
-
var DESTRUCTIVE_MARKERS, SCHEMA_REMOVAL_BODY, RENAME_METADATA, MAJOR_BUMP;
|
|
37984
|
-
var init_merge_impact = __esm({
|
|
37985
|
-
"src/scripts/hooks/merge_impact.ts"() {
|
|
37986
|
-
"use strict";
|
|
37987
|
-
DESTRUCTIVE_MARKERS = [
|
|
37988
|
-
// Schema removal. Matched on ADDED lines only — a migration that *removes* a
|
|
37989
|
-
// dropColumn call is the opposite of destructive, and matching the raw patch
|
|
37990
|
-
// would score it the same way.
|
|
37991
|
-
{ label: "migration drops a column or table", re: /^\+.*\b(dropColumn|dropTable|dropIfExists|removeColumn|drop_column|drop_table)\b/im },
|
|
37992
|
-
{ label: "raw DROP or TRUNCATE in a migration", re: /^\+.*\b(DROP\s+(TABLE|COLUMN|INDEX|CONSTRAINT)|TRUNCATE\s+TABLE)\b/im },
|
|
37993
|
-
// The author said so themselves. Conventional Commits marks a breaking change
|
|
37994
|
-
// with a `!` before the colon or a body trailer.
|
|
37995
|
-
{ label: "author marked a BREAKING CHANGE", re: /^\+.*BREAKING[ -]CHANGE/m },
|
|
37996
|
-
// A removed export is the shape most likely to break an importer.
|
|
37997
|
-
{ label: "an exported symbol was removed", re: /^-\s*export\s+(default\s+|const\s+|function\s+|class\s+|interface\s+|type\s+|async\s+)/m },
|
|
37998
|
-
{ label: "a public PHP or Python symbol was removed", re: /^-\s*(public\s+function|def\s+[a-z_]+\s*\()/m },
|
|
37999
|
-
// Route removal breaks callers that never imported anything.
|
|
38000
|
-
{ label: "a route or endpoint was removed", re: /^-.*\b(Route::(get|post|put|patch|delete)|@(Get|Post|Put|Patch|Delete)Mapping|app\.(get|post|put|patch|delete)\s*\()/m },
|
|
38001
|
-
{ label: "a whole file was deleted", re: /^deleted file mode /m }
|
|
38002
|
-
];
|
|
38003
|
-
SCHEMA_REMOVAL_BODY = /\b(dropColumn|dropTable|dropIfExists|removeColumn|drop_column|drop_table|DROP\s+(TABLE|COLUMN|INDEX|CONSTRAINT)|TRUNCATE\s+TABLE)\b/i;
|
|
38004
|
-
RENAME_METADATA = /^rename (?:from|to) /m;
|
|
38005
|
-
MAJOR_BUMP = /^-\s*"version"\s*:\s*"(\d+)\.[^"]*"[\s\S]{0,200}?^\+\s*"version"\s*:\s*"(\d+)\./m;
|
|
38006
|
-
}
|
|
38007
|
-
});
|
|
38008
|
-
|
|
38009
|
-
// src/scripts/hooks/block_unauthorized_git.ts
|
|
38010
|
-
import fs66 from "node:fs";
|
|
38011
|
-
import path67 from "node:path";
|
|
38012
|
-
import { fileURLToPath as fileURLToPath34, pathToFileURL as pathToFileURL24 } from "node:url";
|
|
38013
|
-
function _isObject5(v) {
|
|
38014
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
38015
|
-
}
|
|
37901
|
+
// src/scripts/hooks/git_command_classifier.ts
|
|
38016
37902
|
function ghApiWrite(pathRe) {
|
|
38017
37903
|
return new RegExp(
|
|
38018
37904
|
`${P}gh\\s+api\\b(?=[^\\n]*${pathRe})(?=[^\\n]*(?:-X|--method)\\s+(?:POST|PATCH|PUT|DELETE)\\b)`,
|
|
38019
37905
|
"i"
|
|
38020
37906
|
);
|
|
38021
37907
|
}
|
|
38022
|
-
function extractCommand(envelope) {
|
|
38023
|
-
const payload = _isObject5(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
38024
|
-
const toolRaw = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
|
|
38025
|
-
const tool = typeof toolRaw === "string" ? toolRaw : null;
|
|
38026
|
-
if (tool !== null && !COMMAND_TOOLS.has(tool)) {
|
|
38027
|
-
return null;
|
|
38028
|
-
}
|
|
38029
|
-
const input = _isObject5(payload["tool_input"]) ? payload["tool_input"] : _isObject5(payload["toolInput"]) ? payload["toolInput"] : payload;
|
|
38030
|
-
for (const key of ["command", "cmd", "script"]) {
|
|
38031
|
-
const v = input[key];
|
|
38032
|
-
if (typeof v === "string" && v.trim()) {
|
|
38033
|
-
return v;
|
|
38034
|
-
}
|
|
38035
|
-
}
|
|
38036
|
-
return null;
|
|
38037
|
-
}
|
|
38038
37908
|
function splitOutsideQuotes(command) {
|
|
38039
37909
|
const parts = [];
|
|
38040
37910
|
let cur = "";
|
|
@@ -38196,184 +38066,11 @@ function commandOp(command) {
|
|
|
38196
38066
|
}
|
|
38197
38067
|
return found;
|
|
38198
38068
|
}
|
|
38199
|
-
|
|
38200
|
-
|
|
38201
|
-
|
|
38202
|
-
return _boundedTarget(gh[1]);
|
|
38203
|
-
}
|
|
38204
|
-
const api = /\/pulls\/(\d{1,10})\/merge\b/i.exec(command);
|
|
38205
|
-
return api ? _boundedTarget(api[1]) : null;
|
|
38206
|
-
}
|
|
38207
|
-
function _boundedTarget(digits) {
|
|
38208
|
-
const n = Number.parseInt(digits, 10);
|
|
38209
|
-
return Number.isSafeInteger(n) && n > 0 && n <= PR_NUMBER_MAX ? n : null;
|
|
38210
|
-
}
|
|
38211
|
-
function grantCovers(grants, op, target) {
|
|
38212
|
-
if (op !== "pr-merge" || target === null) {
|
|
38213
|
-
return null;
|
|
38214
|
-
}
|
|
38215
|
-
return grants.find(
|
|
38216
|
-
(g) => g.op === "pr-merge" && g.targets.includes(target) && !g.consumed.includes(target)
|
|
38217
|
-
) ?? null;
|
|
38218
|
-
}
|
|
38219
|
-
function _loadLedger(consumer_root, session_id, now) {
|
|
38220
|
-
const grants = readGrants(consumer_root, session_id);
|
|
38221
|
-
const candidates = [ledgerFileFor(session_id)];
|
|
38222
|
-
if (!candidates.includes(STATE_FILE2)) {
|
|
38223
|
-
candidates.push(STATE_FILE2);
|
|
38224
|
-
}
|
|
38225
|
-
for (const rel of candidates) {
|
|
38226
|
-
const found = _readLedgerFile(path67.join(consumer_root, rel), session_id, now);
|
|
38227
|
-
if (found !== null) {
|
|
38228
|
-
return { ...found, grants };
|
|
38229
|
-
}
|
|
38230
|
-
}
|
|
38231
|
-
return { authorized: /* @__PURE__ */ new Set(), present: false, grants };
|
|
38232
|
-
}
|
|
38233
|
-
function _readLedgerFile(file, session_id, now) {
|
|
38234
|
-
try {
|
|
38235
|
-
const raw = fs66.readFileSync(file, "utf8");
|
|
38236
|
-
const decoded = JSON.parse(raw);
|
|
38237
|
-
if (_isObject5(decoded) && Array.isArray(decoded["authorized"])) {
|
|
38238
|
-
const ledgerSession = typeof decoded["session_id"] === "string" ? decoded["session_id"] : "";
|
|
38239
|
-
if (session_id && ledgerSession && ledgerSession !== session_id) {
|
|
38240
|
-
return null;
|
|
38241
|
-
}
|
|
38242
|
-
const at = Date.parse(String(decoded["detected_at"] ?? ""));
|
|
38243
|
-
if (Number.isFinite(at) && now - at > LEDGER_MAX_AGE_MS) {
|
|
38244
|
-
return null;
|
|
38245
|
-
}
|
|
38246
|
-
return {
|
|
38247
|
-
authorized: new Set(decoded["authorized"].filter(Boolean)),
|
|
38248
|
-
present: true
|
|
38249
|
-
};
|
|
38250
|
-
}
|
|
38251
|
-
} catch {
|
|
38252
|
-
}
|
|
38253
|
-
return null;
|
|
38254
|
-
}
|
|
38255
|
-
function decide(command, ledger, impact) {
|
|
38256
|
-
if (command === null) {
|
|
38257
|
-
return { exit: EXIT_ALLOW3, stdout: "", stderr: "" };
|
|
38258
|
-
}
|
|
38259
|
-
const op = commandOp(command);
|
|
38260
|
-
if (op === null || ledger.authorized.has(op)) {
|
|
38261
|
-
return { exit: EXIT_ALLOW3, stdout: "", stderr: "" };
|
|
38262
|
-
}
|
|
38263
|
-
const target = mergeTargetOf(command);
|
|
38264
|
-
if (grantCovers(ledger.grants ?? [], op, target) && target !== null) {
|
|
38265
|
-
return { exit: EXIT_ALLOW3, stdout: "", stderr: "", consumedTarget: target };
|
|
38266
|
-
}
|
|
38267
|
-
const shown = command.length > 120 ? `${command.slice(0, 117)}\u2026` : command;
|
|
38268
|
-
if (BLOCK_OPS.has(op)) {
|
|
38269
|
-
const scan2 = op === "pr-merge" && target !== null && impact ? ` ${impact}` : "";
|
|
38270
|
-
const reason = `Blocked: \`${op}\` with no authorization in this turn's prompt. This operation is irreversible and non-destructive-by-default already declares it never-autonomous. Command: ${shown}.${scan2} Ask the user, in one numbered-options block, and run it only after they answer this turn.`;
|
|
38271
|
-
return { exit: EXIT_BLOCK, stdout: "", stderr: `${reason}
|
|
38272
|
-
`, blockedOp: op };
|
|
38273
|
-
}
|
|
38274
|
-
if (WARN_OPS.has(op)) {
|
|
38275
|
-
const reason = `No \`${op}\` authorization found in this turn's prompt (commit-policy: a one-shot authorization is spent on the operation it named). If the user did authorize it this turn, proceed; otherwise stop and ask. Command: ${shown}`;
|
|
38276
|
-
return {
|
|
38277
|
-
exit: EXIT_ALLOW3,
|
|
38278
|
-
stdout: `${JSON.stringify({ decision: "warn", reason })}
|
|
38279
|
-
`,
|
|
38280
|
-
stderr: ""
|
|
38281
|
-
};
|
|
38282
|
-
}
|
|
38283
|
-
return { exit: EXIT_ALLOW3, stdout: "", stderr: "" };
|
|
38284
|
-
}
|
|
38285
|
-
function run3(stdin_text, options) {
|
|
38286
|
-
let envelope = {};
|
|
38287
|
-
if (stdin_text.trim()) {
|
|
38288
|
-
try {
|
|
38289
|
-
const decoded = JSON.parse(stdin_text);
|
|
38290
|
-
if (_isObject5(decoded)) {
|
|
38291
|
-
envelope = decoded;
|
|
38292
|
-
}
|
|
38293
|
-
} catch {
|
|
38294
|
-
return EXIT_ALLOW3;
|
|
38295
|
-
}
|
|
38296
|
-
}
|
|
38297
|
-
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
38298
|
-
const command = extractCommand(envelope);
|
|
38299
|
-
const ledger = _loadLedger(options.consumer_root, session_id, Date.now());
|
|
38300
|
-
let impact;
|
|
38301
|
-
const stage1 = command === null ? null : commandOp(command);
|
|
38302
|
-
const stage2Target = command === null ? null : mergeTargetOf(command);
|
|
38303
|
-
if (stage1 === "pr-merge" && stage2Target !== null && !ledger.authorized.has("pr-merge") && !grantCovers(ledger.grants ?? [], "pr-merge", stage2Target)) {
|
|
38304
|
-
try {
|
|
38305
|
-
impact = describeImpact(
|
|
38306
|
-
stage2Target,
|
|
38307
|
-
analyseMergeImpact(stage2Target, { cwd: options.consumer_root })
|
|
38308
|
-
);
|
|
38309
|
-
} catch {
|
|
38310
|
-
}
|
|
38311
|
-
}
|
|
38312
|
-
const decision = decide(command, ledger, impact);
|
|
38313
|
-
if (decision.consumedTarget !== void 0) {
|
|
38314
|
-
consumeGrantTarget(options.consumer_root, session_id, decision.consumedTarget);
|
|
38315
|
-
}
|
|
38316
|
-
if (decision.blockedOp) {
|
|
38317
|
-
try {
|
|
38318
|
-
atomic_write_json(path67.join(options.consumer_root, pendingFileFor(session_id)), {
|
|
38319
|
-
op: decision.blockedOp,
|
|
38320
|
-
session_id,
|
|
38321
|
-
refused_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
38322
|
-
});
|
|
38323
|
-
} catch {
|
|
38324
|
-
}
|
|
38325
|
-
}
|
|
38326
|
-
if (decision.stdout) {
|
|
38327
|
-
process.stdout.write(decision.stdout);
|
|
38328
|
-
}
|
|
38329
|
-
if (decision.stderr) {
|
|
38330
|
-
process.stderr.write(decision.stderr);
|
|
38331
|
-
}
|
|
38332
|
-
return decision.exit;
|
|
38333
|
-
}
|
|
38334
|
-
function main24(argv) {
|
|
38335
|
-
const args = argv ?? process.argv.slice(2);
|
|
38336
|
-
let consumer_root = process.cwd();
|
|
38337
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
38338
|
-
const a = args[i];
|
|
38339
|
-
if (a === "--project-dir" && args[i + 1] !== void 0) {
|
|
38340
|
-
consumer_root = args[i + 1];
|
|
38341
|
-
i += 1;
|
|
38342
|
-
} else if (a !== void 0 && a.startsWith("--project-dir=")) {
|
|
38343
|
-
consumer_root = a.slice("--project-dir=".length);
|
|
38344
|
-
}
|
|
38345
|
-
}
|
|
38346
|
-
return run3(readHookStdin(), { consumer_root });
|
|
38347
|
-
}
|
|
38348
|
-
function _isCliEntry20() {
|
|
38349
|
-
if (true) {
|
|
38350
|
-
return false;
|
|
38351
|
-
}
|
|
38352
|
-
if (process.argv[1] === void 0) {
|
|
38353
|
-
return false;
|
|
38354
|
-
}
|
|
38355
|
-
const argvUrl = pathToFileURL24(path67.resolve(process.argv[1])).href;
|
|
38356
|
-
if (import.meta.url === argvUrl) {
|
|
38357
|
-
return true;
|
|
38358
|
-
}
|
|
38359
|
-
try {
|
|
38360
|
-
const here = fs66.realpathSync(fileURLToPath34(import.meta.url));
|
|
38361
|
-
const argv = fs66.realpathSync(path67.resolve(process.argv[1]));
|
|
38362
|
-
return here === argv;
|
|
38363
|
-
} catch {
|
|
38364
|
-
return false;
|
|
38365
|
-
}
|
|
38366
|
-
}
|
|
38367
|
-
var EXIT_ALLOW3, EXIT_BLOCK, BLOCK_OPS, WARN_OPS, G, P, COMMAND_OPS, COMMAND_TOOLS, LEDGER_MAX_AGE_MS;
|
|
38368
|
-
var init_block_unauthorized_git = __esm({
|
|
38369
|
-
"src/scripts/hooks/block_unauthorized_git.ts"() {
|
|
38069
|
+
var BLOCK_OPS, G, P, COMMAND_OPS;
|
|
38070
|
+
var init_git_command_classifier = __esm({
|
|
38071
|
+
"src/scripts/hooks/git_command_classifier.ts"() {
|
|
38370
38072
|
"use strict";
|
|
38371
|
-
init_hook_stdin();
|
|
38372
|
-
init_merge_impact();
|
|
38373
|
-
init_state_io();
|
|
38374
38073
|
init_git_authorization_hook();
|
|
38375
|
-
EXIT_ALLOW3 = 0;
|
|
38376
|
-
EXIT_BLOCK = 1;
|
|
38377
38074
|
BLOCK_OPS = /* @__PURE__ */ new Set([
|
|
38378
38075
|
"publish",
|
|
38379
38076
|
"tag",
|
|
@@ -38407,27 +38104,6 @@ var init_block_unauthorized_git = __esm({
|
|
|
38407
38104
|
/** `-x` is the flag that takes `.env` and local certificates. */
|
|
38408
38105
|
"clean-ignored"
|
|
38409
38106
|
]);
|
|
38410
|
-
WARN_OPS = /* @__PURE__ */ new Set([
|
|
38411
|
-
"commit",
|
|
38412
|
-
"push",
|
|
38413
|
-
"pr-create",
|
|
38414
|
-
"branch",
|
|
38415
|
-
// ── Added 2026-09-03, deliberately at warn rather than block.
|
|
38416
|
-
//
|
|
38417
|
-
// Each is destructive in some reading, and each is also routine enough that
|
|
38418
|
-
// blocking it would be the friction that gets the whole guard routed around —
|
|
38419
|
-
// the failure mode this estate has already recorded twice. `reset-hard` is the
|
|
38420
|
-
// sharpest case and stays here for a decidable reason: the Hard Floor's
|
|
38421
|
-
// qualifier is "past unpushed work", and the command text cannot say whether
|
|
38422
|
-
// the work was pushed.
|
|
38423
|
-
"tag-force",
|
|
38424
|
-
"rebase",
|
|
38425
|
-
"reset-hard",
|
|
38426
|
-
"clean",
|
|
38427
|
-
"stash-drop",
|
|
38428
|
-
"branch-delete",
|
|
38429
|
-
"close"
|
|
38430
|
-
]);
|
|
38431
38107
|
G = "(?:-[A-Za-z-]+(?:=\\S+)?(?:\\s+\\S+)?\\s+)*";
|
|
38432
38108
|
P = "^(?:\\S*\\/)?";
|
|
38433
38109
|
COMMAND_OPS = [
|
|
@@ -38536,28 +38212,13 @@ var init_block_unauthorized_git = __esm({
|
|
|
38536
38212
|
{ op: "commit", re: new RegExp(`${P}git\\s+${G}commit\\b`, "i") },
|
|
38537
38213
|
{ op: "branch", re: new RegExp(`${P}git\\s+${G}(checkout\\s+-b|switch\\s+-c)\\b`, "i") }
|
|
38538
38214
|
];
|
|
38539
|
-
COMMAND_TOOLS = /* @__PURE__ */ new Set([
|
|
38540
|
-
"launch-process",
|
|
38541
|
-
"launch_process",
|
|
38542
|
-
"Bash",
|
|
38543
|
-
"BashTool",
|
|
38544
|
-
"run-process",
|
|
38545
|
-
"runProcess",
|
|
38546
|
-
"shell",
|
|
38547
|
-
"execute_shell",
|
|
38548
|
-
"RunShellCommand"
|
|
38549
|
-
]);
|
|
38550
|
-
LEDGER_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
38551
|
-
if (_isCliEntry20()) {
|
|
38552
|
-
process.exit(main24());
|
|
38553
|
-
}
|
|
38554
38215
|
}
|
|
38555
38216
|
});
|
|
38556
38217
|
|
|
38557
38218
|
// src/scripts/before_complete_hook.ts
|
|
38558
|
-
import
|
|
38559
|
-
import
|
|
38560
|
-
import { fileURLToPath as
|
|
38219
|
+
import fs66 from "node:fs";
|
|
38220
|
+
import path67 from "node:path";
|
|
38221
|
+
import { fileURLToPath as fileURLToPath34, pathToFileURL as pathToFileURL24 } from "node:url";
|
|
38561
38222
|
function statePathFor2(session_id) {
|
|
38562
38223
|
return session_state_file(STATE_DIR3, session_id);
|
|
38563
38224
|
}
|
|
@@ -38589,7 +38250,7 @@ function _empty_state() {
|
|
|
38589
38250
|
}
|
|
38590
38251
|
function _extract_command(payload) {
|
|
38591
38252
|
const toolRaw = payload["tool_name"] || payload["toolName"] || payload["tool"];
|
|
38592
|
-
if (!(typeof toolRaw === "string" &&
|
|
38253
|
+
if (!(typeof toolRaw === "string" && COMMAND_TOOLS.has(toolRaw))) {
|
|
38593
38254
|
return [typeof toolRaw === "string" ? toolRaw : null, null];
|
|
38594
38255
|
}
|
|
38595
38256
|
const tool = toolRaw;
|
|
@@ -38732,7 +38393,7 @@ function _update(state, event, envelope) {
|
|
|
38732
38393
|
state["checked_at"] = _now2();
|
|
38733
38394
|
return state;
|
|
38734
38395
|
}
|
|
38735
|
-
function
|
|
38396
|
+
function run3(stdin_text, options) {
|
|
38736
38397
|
const { consumer_root } = options;
|
|
38737
38398
|
const verbose = options.verbose ?? false;
|
|
38738
38399
|
let envelope = {};
|
|
@@ -38756,7 +38417,7 @@ function run4(stdin_text, options) {
|
|
|
38756
38417
|
}
|
|
38757
38418
|
return 0;
|
|
38758
38419
|
}
|
|
38759
|
-
const target =
|
|
38420
|
+
const target = path67.join(consumer_root, statePathFor2(session_id));
|
|
38760
38421
|
let state = {};
|
|
38761
38422
|
const outcome = update_json_under_lock(target, (loaded) => {
|
|
38762
38423
|
state = _update({ ..._empty_state(), ...loaded }, event, envelope);
|
|
@@ -38769,9 +38430,9 @@ function run4(stdin_text, options) {
|
|
|
38769
38430
|
return 0;
|
|
38770
38431
|
}
|
|
38771
38432
|
if (event === "session_start" || event === "user_prompt_submit") {
|
|
38772
|
-
prune_legacy_state_file(
|
|
38433
|
+
prune_legacy_state_file(path67.join(consumer_root, STATE_FILE3));
|
|
38773
38434
|
prune_stale_session_states(
|
|
38774
|
-
|
|
38435
|
+
path67.join(consumer_root, STATE_DIR3),
|
|
38775
38436
|
Date.now(),
|
|
38776
38437
|
STATE_RETENTION_DAYS2
|
|
38777
38438
|
);
|
|
@@ -38812,39 +38473,39 @@ function parse_args6(argv) {
|
|
|
38812
38473
|
function _readStdin2() {
|
|
38813
38474
|
return readHookStdin();
|
|
38814
38475
|
}
|
|
38815
|
-
function
|
|
38476
|
+
function main24(argv) {
|
|
38816
38477
|
const args = parse_args6(argv ?? process.argv.slice(2));
|
|
38817
|
-
return
|
|
38478
|
+
return run3(_readStdin2(), { consumer_root: process.cwd(), verbose: args.verbose });
|
|
38818
38479
|
}
|
|
38819
|
-
function
|
|
38480
|
+
function _isCliEntry20() {
|
|
38820
38481
|
if (true) {
|
|
38821
38482
|
return false;
|
|
38822
38483
|
}
|
|
38823
38484
|
if (process.argv[1] === void 0) {
|
|
38824
38485
|
return false;
|
|
38825
38486
|
}
|
|
38826
|
-
const argvUrl =
|
|
38487
|
+
const argvUrl = pathToFileURL24(path67.resolve(process.argv[1])).href;
|
|
38827
38488
|
if (import.meta.url === argvUrl) {
|
|
38828
38489
|
return true;
|
|
38829
38490
|
}
|
|
38830
38491
|
try {
|
|
38831
|
-
const here =
|
|
38832
|
-
const argv =
|
|
38492
|
+
const here = fs66.realpathSync(fileURLToPath34(import.meta.url));
|
|
38493
|
+
const argv = fs66.realpathSync(path67.resolve(process.argv[1]));
|
|
38833
38494
|
return here === argv;
|
|
38834
38495
|
} catch {
|
|
38835
38496
|
return false;
|
|
38836
38497
|
}
|
|
38837
38498
|
}
|
|
38838
|
-
var STATE_FILE3, STATE_DIR3, STATE_RETENTION_DAYS2,
|
|
38499
|
+
var STATE_FILE3, STATE_DIR3, STATE_RETENTION_DAYS2, COMMAND_TOOLS, _VERIFICATION_RE, _VACUOUS_PATTERNS, _CI_POLL_RE, isCliEntry3;
|
|
38839
38500
|
var init_before_complete_hook = __esm({
|
|
38840
38501
|
"src/scripts/before_complete_hook.ts"() {
|
|
38841
38502
|
"use strict";
|
|
38842
38503
|
init_state_io();
|
|
38843
38504
|
init_hook_stdin();
|
|
38844
|
-
STATE_FILE3 =
|
|
38845
|
-
STATE_DIR3 =
|
|
38505
|
+
STATE_FILE3 = path67.join("agents", "state", "verify-before-complete.json");
|
|
38506
|
+
STATE_DIR3 = path67.join("agents", "state", "verify-before-complete");
|
|
38846
38507
|
STATE_RETENTION_DAYS2 = 7;
|
|
38847
|
-
|
|
38508
|
+
COMMAND_TOOLS = /* @__PURE__ */ new Set([
|
|
38848
38509
|
"launch-process",
|
|
38849
38510
|
"launch_process",
|
|
38850
38511
|
// Augment
|
|
@@ -38879,9 +38540,9 @@ var init_before_complete_hook = __esm({
|
|
|
38879
38540
|
/\bnothing to check\b/i
|
|
38880
38541
|
];
|
|
38881
38542
|
_CI_POLL_RE = /\bgh\s+(?:pr\s+checks|run\s+(?:watch|list|view))\b/i;
|
|
38882
|
-
isCliEntry3 =
|
|
38543
|
+
isCliEntry3 = _isCliEntry20();
|
|
38883
38544
|
if (isCliEntry3) {
|
|
38884
|
-
process.exit(
|
|
38545
|
+
process.exit(main24(process.argv.slice(2)));
|
|
38885
38546
|
}
|
|
38886
38547
|
}
|
|
38887
38548
|
});
|
|
@@ -38939,11 +38600,11 @@ var init_review_skipped_record = __esm({
|
|
|
38939
38600
|
});
|
|
38940
38601
|
|
|
38941
38602
|
// src/scripts/hooks/envelope.ts
|
|
38942
|
-
function
|
|
38603
|
+
function _isObject5(obj) {
|
|
38943
38604
|
return typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
38944
38605
|
}
|
|
38945
38606
|
function looks_like_envelope(obj) {
|
|
38946
|
-
if (!
|
|
38607
|
+
if (!_isObject5(obj)) {
|
|
38947
38608
|
return false;
|
|
38948
38609
|
}
|
|
38949
38610
|
return ENVELOPE_KEYS.every((key) => key in obj);
|
|
@@ -38962,14 +38623,14 @@ function unwrap(stdin_text, default_platform = "generic") {
|
|
|
38962
38623
|
if (looks_like_envelope(decoded)) {
|
|
38963
38624
|
const env = decoded;
|
|
38964
38625
|
let payload2 = env["payload"];
|
|
38965
|
-
if (!payload2 || !
|
|
38626
|
+
if (!payload2 || !_isObject5(payload2)) {
|
|
38966
38627
|
payload2 = {};
|
|
38967
38628
|
}
|
|
38968
38629
|
const platRaw = env["platform"];
|
|
38969
38630
|
const platform = String(platRaw || default_platform);
|
|
38970
38631
|
return [env, payload2, platform];
|
|
38971
38632
|
}
|
|
38972
|
-
const payload =
|
|
38633
|
+
const payload = _isObject5(decoded) ? decoded : {};
|
|
38973
38634
|
return [
|
|
38974
38635
|
{
|
|
38975
38636
|
schema_version: 1,
|
|
@@ -39001,22 +38662,22 @@ var init_envelope = __esm({
|
|
|
39001
38662
|
// src/scripts/hooks/end_review_nudge_hook.ts
|
|
39002
38663
|
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
39003
38664
|
import * as crypto7 from "node:crypto";
|
|
39004
|
-
import * as
|
|
38665
|
+
import * as fs67 from "node:fs";
|
|
39005
38666
|
import * as os14 from "node:os";
|
|
39006
|
-
import * as
|
|
39007
|
-
import { fileURLToPath as
|
|
38667
|
+
import * as path68 from "node:path";
|
|
38668
|
+
import { fileURLToPath as fileURLToPath35, pathToFileURL as pathToFileURL25 } from "node:url";
|
|
39008
38669
|
function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
39009
38670
|
if (!rawPath || !/\.jsonl$/i.test(rawPath)) return false;
|
|
39010
38671
|
const homeDir = opts.homeDir ?? os14.homedir();
|
|
39011
38672
|
const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
|
|
39012
38673
|
try {
|
|
39013
|
-
const realHome =
|
|
39014
|
-
const realPath =
|
|
39015
|
-
const relative16 =
|
|
39016
|
-
if (relative16 === "" || relative16.startsWith("..") ||
|
|
38674
|
+
const realHome = fs67.realpathSync(homeDir);
|
|
38675
|
+
const realPath = fs67.realpathSync(rawPath);
|
|
38676
|
+
const relative16 = path68.relative(realHome, realPath);
|
|
38677
|
+
if (relative16 === "" || relative16.startsWith("..") || path68.isAbsolute(relative16)) {
|
|
39017
38678
|
return false;
|
|
39018
38679
|
}
|
|
39019
|
-
const { size } =
|
|
38680
|
+
const { size } = fs67.statSync(realPath);
|
|
39020
38681
|
return size <= maxBytes;
|
|
39021
38682
|
} catch {
|
|
39022
38683
|
return false;
|
|
@@ -39071,13 +38732,13 @@ function untrackedNonDocFiles(cwd) {
|
|
|
39071
38732
|
}
|
|
39072
38733
|
function untrackedFileLineCount(cwd, relPath) {
|
|
39073
38734
|
try {
|
|
39074
|
-
const abs =
|
|
39075
|
-
const size =
|
|
38735
|
+
const abs = path68.resolve(cwd, relPath);
|
|
38736
|
+
const size = fs67.statSync(abs).size;
|
|
39076
38737
|
if (size === 0) return 0;
|
|
39077
38738
|
if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
|
|
39078
38739
|
return MUTATION_LINE_THRESHOLD + 1;
|
|
39079
38740
|
}
|
|
39080
|
-
const buf =
|
|
38741
|
+
const buf = fs67.readFileSync(abs);
|
|
39081
38742
|
if (buf.length === 0) return 0;
|
|
39082
38743
|
const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
|
|
39083
38744
|
if (probe.includes(0)) return 0;
|
|
@@ -39163,19 +38824,19 @@ function appendReviewSkippedTelemetry(workspaceRoot, diffLines, mutationMeasure)
|
|
|
39163
38824
|
});
|
|
39164
38825
|
if (errors.length || line === null) return;
|
|
39165
38826
|
try {
|
|
39166
|
-
const dir =
|
|
39167
|
-
|
|
39168
|
-
const file =
|
|
39169
|
-
|
|
38827
|
+
const dir = path68.join(workspaceRoot, "agents", "runtime", "state", "audit");
|
|
38828
|
+
fs67.mkdirSync(dir, { recursive: true });
|
|
38829
|
+
const file = path68.join(dir, `${ts.slice(0, 7)}.jsonl`);
|
|
38830
|
+
fs67.appendFileSync(file, `${JSON.stringify(line)}
|
|
39170
38831
|
`, "utf8");
|
|
39171
38832
|
} catch {
|
|
39172
38833
|
}
|
|
39173
38834
|
}
|
|
39174
38835
|
function sessionStateDir(workspaceRoot) {
|
|
39175
|
-
return
|
|
38836
|
+
return path68.join(workspaceRoot, "agents", "runtime", "state", "end-review-nudge");
|
|
39176
38837
|
}
|
|
39177
38838
|
function sessionStateFile(workspaceRoot, sessionKey) {
|
|
39178
|
-
return
|
|
38839
|
+
return path68.join(sessionStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
39179
38840
|
}
|
|
39180
38841
|
function deriveSessionKey(envelope, payload) {
|
|
39181
38842
|
const raw = str(envelope["session_id"]) || str(payload["transcript_path"] ?? payload["transcriptPath"]);
|
|
@@ -39184,7 +38845,7 @@ function deriveSessionKey(envelope, payload) {
|
|
|
39184
38845
|
}
|
|
39185
38846
|
function hasFiredThisSession(workspaceRoot, sessionKey) {
|
|
39186
38847
|
try {
|
|
39187
|
-
return
|
|
38848
|
+
return fs67.existsSync(sessionStateFile(workspaceRoot, sessionKey));
|
|
39188
38849
|
} catch {
|
|
39189
38850
|
return false;
|
|
39190
38851
|
}
|
|
@@ -39198,7 +38859,7 @@ function markFiredThisSession(workspaceRoot, sessionKey, ts) {
|
|
|
39198
38859
|
function _read_stdin() {
|
|
39199
38860
|
return readHookStdin();
|
|
39200
38861
|
}
|
|
39201
|
-
function
|
|
38862
|
+
function main25() {
|
|
39202
38863
|
const [envelope, payload] = unwrap(_read_stdin(), "claude");
|
|
39203
38864
|
const event = String(envelope["event"] ?? "");
|
|
39204
38865
|
if (event !== "" && event !== "stop") {
|
|
@@ -39227,7 +38888,7 @@ function main26() {
|
|
|
39227
38888
|
let reviewerRan = false;
|
|
39228
38889
|
if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
|
|
39229
38890
|
try {
|
|
39230
|
-
reviewerRan = scanTranscriptForReviewer(
|
|
38891
|
+
reviewerRan = scanTranscriptForReviewer(fs67.readFileSync(transcriptPath, "utf-8"));
|
|
39231
38892
|
} catch {
|
|
39232
38893
|
reviewerRan = false;
|
|
39233
38894
|
}
|
|
@@ -39250,20 +38911,20 @@ function main26() {
|
|
|
39250
38911
|
);
|
|
39251
38912
|
return EXIT_WARN2;
|
|
39252
38913
|
}
|
|
39253
|
-
function
|
|
38914
|
+
function _isCliEntry21() {
|
|
39254
38915
|
if (true) {
|
|
39255
38916
|
return false;
|
|
39256
38917
|
}
|
|
39257
38918
|
if (process.argv[1] === void 0) {
|
|
39258
38919
|
return false;
|
|
39259
38920
|
}
|
|
39260
|
-
const argvUrl =
|
|
38921
|
+
const argvUrl = pathToFileURL25(path68.resolve(process.argv[1])).href;
|
|
39261
38922
|
if (import.meta.url === argvUrl) {
|
|
39262
38923
|
return true;
|
|
39263
38924
|
}
|
|
39264
38925
|
try {
|
|
39265
|
-
const here =
|
|
39266
|
-
const argv =
|
|
38926
|
+
const here = fs67.realpathSync(fileURLToPath35(import.meta.url));
|
|
38927
|
+
const argv = fs67.realpathSync(path68.resolve(process.argv[1]));
|
|
39267
38928
|
return here === argv;
|
|
39268
38929
|
} catch {
|
|
39269
38930
|
return false;
|
|
@@ -39288,8 +38949,8 @@ var init_end_review_nudge_hook = __esm({
|
|
|
39288
38949
|
REVIEW_SHAPED_LABEL_RE = /\b(review|judge|adversarial|critique|second[- ]opinion|blind\s+(pass|review)|cross-model)\b/i;
|
|
39289
38950
|
REVIEW_SHAPED_PROMPT_RE = /\b(code\s+review|neutral\s+review|adversarial|judge|critique|second[- ]opinion|blind\s+(pass|review)|cross-model)\b/i;
|
|
39290
38951
|
REVIEW_SKILL_NAME_RE = /^(review[-:]changes|judge[-:][a-z0-9-]+|adversarial-review|code-review)$/i;
|
|
39291
|
-
if (
|
|
39292
|
-
process.exit(
|
|
38952
|
+
if (_isCliEntry21()) {
|
|
38953
|
+
process.exit(main25());
|
|
39293
38954
|
}
|
|
39294
38955
|
}
|
|
39295
38956
|
});
|
|
@@ -39442,9 +39103,9 @@ var init_subagent_response = __esm({
|
|
|
39442
39103
|
|
|
39443
39104
|
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
39444
39105
|
import * as crypto8 from "node:crypto";
|
|
39445
|
-
import * as
|
|
39446
|
-
import * as
|
|
39447
|
-
import { fileURLToPath as
|
|
39106
|
+
import * as fs68 from "node:fs";
|
|
39107
|
+
import * as path69 from "node:path";
|
|
39108
|
+
import { fileURLToPath as fileURLToPath36, pathToFileURL as pathToFileURL26 } from "node:url";
|
|
39448
39109
|
function isObject2(v) {
|
|
39449
39110
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
39450
39111
|
}
|
|
@@ -39535,10 +39196,10 @@ function _jsonObjectCandidates(message) {
|
|
|
39535
39196
|
return out;
|
|
39536
39197
|
}
|
|
39537
39198
|
function openDir(root) {
|
|
39538
|
-
return
|
|
39199
|
+
return path69.join(root, LEDGER_DIR, OPEN_SUBDIR);
|
|
39539
39200
|
}
|
|
39540
39201
|
function openFile(root, ref) {
|
|
39541
|
-
return
|
|
39202
|
+
return path69.join(openDir(root), `${ref}.json`);
|
|
39542
39203
|
}
|
|
39543
39204
|
function _asOpenRecord(value, expectedRef) {
|
|
39544
39205
|
if (!isObject2(value)) return null;
|
|
@@ -39564,7 +39225,7 @@ function readOpenRecords(root) {
|
|
|
39564
39225
|
const out = /* @__PURE__ */ new Map();
|
|
39565
39226
|
let names;
|
|
39566
39227
|
try {
|
|
39567
|
-
names =
|
|
39228
|
+
names = fs68.readdirSync(openDir(root));
|
|
39568
39229
|
} catch {
|
|
39569
39230
|
return out;
|
|
39570
39231
|
}
|
|
@@ -39572,7 +39233,7 @@ function readOpenRecords(root) {
|
|
|
39572
39233
|
if (!name.endsWith(".json")) continue;
|
|
39573
39234
|
const expectedRef = name.slice(0, -".json".length);
|
|
39574
39235
|
try {
|
|
39575
|
-
const raw =
|
|
39236
|
+
const raw = fs68.readFileSync(path69.join(openDir(root), name), "utf8");
|
|
39576
39237
|
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
39577
39238
|
if (rec) out.set(rec.ref, rec);
|
|
39578
39239
|
} catch {
|
|
@@ -39587,13 +39248,13 @@ function resolveDepth(parentRef, open) {
|
|
|
39587
39248
|
return { depth: parent.depth + 1, depth_basis: "observed" };
|
|
39588
39249
|
}
|
|
39589
39250
|
function ledgerFileFor2(root, ts) {
|
|
39590
|
-
return
|
|
39251
|
+
return path69.join(root, LEDGER_DIR, `${ts.slice(0, 7)}.jsonl`);
|
|
39591
39252
|
}
|
|
39592
39253
|
function appendLedgerLine(root, ts, line) {
|
|
39593
39254
|
if (is_replay_mode()) return;
|
|
39594
39255
|
const file = ledgerFileFor2(root, ts);
|
|
39595
|
-
|
|
39596
|
-
|
|
39256
|
+
fs68.mkdirSync(path69.dirname(file), { recursive: true });
|
|
39257
|
+
fs68.appendFileSync(file, `${JSON.stringify(line)}
|
|
39597
39258
|
`, "utf8");
|
|
39598
39259
|
}
|
|
39599
39260
|
function armsExceeded(elapsedMs) {
|
|
@@ -39601,7 +39262,7 @@ function armsExceeded(elapsedMs) {
|
|
|
39601
39262
|
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
39602
39263
|
}
|
|
39603
39264
|
function openRecordStats(root, nowMs = Date.now()) {
|
|
39604
|
-
const ledgerPresent =
|
|
39265
|
+
const ledgerPresent = fs68.existsSync(path69.join(root, LEDGER_DIR));
|
|
39605
39266
|
const open = readOpenRecords(root);
|
|
39606
39267
|
let maxDepth = 0;
|
|
39607
39268
|
let counted = 0;
|
|
@@ -39629,13 +39290,13 @@ function writeOpenRecord(root, rec) {
|
|
|
39629
39290
|
function removeOpenRecord(root, ref) {
|
|
39630
39291
|
if (is_replay_mode()) return;
|
|
39631
39292
|
try {
|
|
39632
|
-
|
|
39293
|
+
fs68.unlinkSync(openFile(root, ref));
|
|
39633
39294
|
} catch {
|
|
39634
39295
|
}
|
|
39635
39296
|
}
|
|
39636
39297
|
function countOpen(root) {
|
|
39637
39298
|
try {
|
|
39638
|
-
return
|
|
39299
|
+
return fs68.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
39639
39300
|
} catch {
|
|
39640
39301
|
return 0;
|
|
39641
39302
|
}
|
|
@@ -39762,9 +39423,9 @@ function handleStop(root, payload, nowIso, sessionId) {
|
|
|
39762
39423
|
}
|
|
39763
39424
|
function processEnvelope(envelope, consumerRoot) {
|
|
39764
39425
|
try {
|
|
39765
|
-
if (!isObject2(envelope)) return
|
|
39426
|
+
if (!isObject2(envelope)) return EXIT_ALLOW3;
|
|
39766
39427
|
const event = envelope["event"];
|
|
39767
|
-
if (event !== "subagent_start" && event !== "subagent_stop") return
|
|
39428
|
+
if (event !== "subagent_start" && event !== "subagent_stop") return EXIT_ALLOW3;
|
|
39768
39429
|
const payload = unwrapPayload(envelope);
|
|
39769
39430
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
39770
39431
|
const sessionId = str2(payload, "session_id", "sessionId") ?? str2(envelope, "session_id", "sessionId");
|
|
@@ -39772,9 +39433,9 @@ function processEnvelope(envelope, consumerRoot) {
|
|
|
39772
39433
|
if (event === "subagent_start") handleStart(consumerRoot, payload, nowIso, sessionId);
|
|
39773
39434
|
else handleStop(consumerRoot, payload, nowIso, sessionId);
|
|
39774
39435
|
} catch {
|
|
39775
|
-
return
|
|
39436
|
+
return EXIT_ALLOW3;
|
|
39776
39437
|
}
|
|
39777
|
-
return
|
|
39438
|
+
return EXIT_ALLOW3;
|
|
39778
39439
|
}
|
|
39779
39440
|
function resolveConsumerRoot(envelope) {
|
|
39780
39441
|
if (isObject2(envelope)) {
|
|
@@ -39786,38 +39447,38 @@ function resolveConsumerRoot(envelope) {
|
|
|
39786
39447
|
}
|
|
39787
39448
|
return process.cwd();
|
|
39788
39449
|
}
|
|
39789
|
-
function
|
|
39450
|
+
function main26() {
|
|
39790
39451
|
const raw = readHookStdin();
|
|
39791
39452
|
let envelope = {};
|
|
39792
39453
|
try {
|
|
39793
39454
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
39794
39455
|
} catch {
|
|
39795
|
-
return
|
|
39456
|
+
return EXIT_ALLOW3;
|
|
39796
39457
|
}
|
|
39797
39458
|
return processEnvelope(envelope, resolveConsumerRoot(envelope));
|
|
39798
39459
|
}
|
|
39799
|
-
function
|
|
39460
|
+
function _isCliEntry22() {
|
|
39800
39461
|
if (true) {
|
|
39801
39462
|
return false;
|
|
39802
39463
|
}
|
|
39803
39464
|
if (process.argv[1] === void 0) return false;
|
|
39804
|
-
const argvUrl =
|
|
39465
|
+
const argvUrl = pathToFileURL26(path69.resolve(process.argv[1])).href;
|
|
39805
39466
|
if (import.meta.url === argvUrl) return true;
|
|
39806
39467
|
try {
|
|
39807
|
-
return
|
|
39468
|
+
return fs68.realpathSync(fileURLToPath36(import.meta.url)) === fs68.realpathSync(path69.resolve(process.argv[1]));
|
|
39808
39469
|
} catch {
|
|
39809
39470
|
return false;
|
|
39810
39471
|
}
|
|
39811
39472
|
}
|
|
39812
|
-
var
|
|
39473
|
+
var EXIT_ALLOW3, LEDGER_DIR, OPEN_SUBDIR, OPEN_RECORD_TTL_MS, DEPTH_BASES, WALL_CLOCK_ARMS_MS;
|
|
39813
39474
|
var init_subagent_ledger_hook = __esm({
|
|
39814
39475
|
"src/scripts/hooks/subagent_ledger_hook.ts"() {
|
|
39815
39476
|
"use strict";
|
|
39816
39477
|
init_subagent_response();
|
|
39817
39478
|
init_state_io();
|
|
39818
39479
|
init_hook_stdin();
|
|
39819
|
-
|
|
39820
|
-
LEDGER_DIR =
|
|
39480
|
+
EXIT_ALLOW3 = 0;
|
|
39481
|
+
LEDGER_DIR = path69.join("agents", "runtime", "state", "subagent-ledger");
|
|
39821
39482
|
OPEN_SUBDIR = "open";
|
|
39822
39483
|
OPEN_RECORD_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
39823
39484
|
DEPTH_BASES = /* @__PURE__ */ new Set(["observed", "asserted-parent", "assumed-root"]);
|
|
@@ -39827,21 +39488,21 @@ var init_subagent_ledger_hook = __esm({
|
|
|
39827
39488
|
{ label: "30m", ms: 30 * 60 * 1e3 },
|
|
39828
39489
|
{ label: "2h", ms: 2 * 60 * 60 * 1e3 }
|
|
39829
39490
|
];
|
|
39830
|
-
if (
|
|
39491
|
+
if (_isCliEntry22()) process.exit(main26());
|
|
39831
39492
|
}
|
|
39832
39493
|
});
|
|
39833
39494
|
|
|
39834
39495
|
// src/scripts/_lib/turn_end_refusals.ts
|
|
39835
39496
|
import * as crypto9 from "node:crypto";
|
|
39836
|
-
import * as
|
|
39497
|
+
import * as path70 from "node:path";
|
|
39837
39498
|
function refusalStateDir(workspaceRoot) {
|
|
39838
|
-
return
|
|
39499
|
+
return path70.join(workspaceRoot, REFUSAL_STATE_REL);
|
|
39839
39500
|
}
|
|
39840
39501
|
function deriveSessionKey2(sessionId) {
|
|
39841
39502
|
return crypto9.createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
39842
39503
|
}
|
|
39843
39504
|
function sessionRefusalFile(workspaceRoot, sessionKey) {
|
|
39844
|
-
return
|
|
39505
|
+
return path70.join(refusalStateDir(workspaceRoot), `${sessionKey}.json`);
|
|
39845
39506
|
}
|
|
39846
39507
|
function emptyCounts() {
|
|
39847
39508
|
return { promissory: 0, language: 0, verification: 0, completion: 0 };
|
|
@@ -39938,14 +39599,14 @@ var init_turn_end_refusals = __esm({
|
|
|
39938
39599
|
"verification",
|
|
39939
39600
|
"completion"
|
|
39940
39601
|
];
|
|
39941
|
-
REFUSAL_STATE_REL =
|
|
39602
|
+
REFUSAL_STATE_REL = path70.join("agents", "runtime", "state", "turn-end-gate");
|
|
39942
39603
|
}
|
|
39943
39604
|
});
|
|
39944
39605
|
|
|
39945
39606
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
39946
|
-
import * as
|
|
39947
|
-
import * as
|
|
39948
|
-
import { fileURLToPath as
|
|
39607
|
+
import * as fs69 from "node:fs";
|
|
39608
|
+
import * as path71 from "node:path";
|
|
39609
|
+
import { fileURLToPath as fileURLToPath37, pathToFileURL as pathToFileURL27 } from "node:url";
|
|
39949
39610
|
function stripFencedBlocks(text) {
|
|
39950
39611
|
const out = [];
|
|
39951
39612
|
let open = null;
|
|
@@ -40002,7 +39663,7 @@ function detectPromissory(reply) {
|
|
|
40002
39663
|
function readCiSettled(workspaceRoot, session_id) {
|
|
40003
39664
|
if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
|
|
40004
39665
|
try {
|
|
40005
|
-
const raw =
|
|
39666
|
+
const raw = fs69.readFileSync(path71.join(workspaceRoot, statePathFor2(session_id)), "utf-8");
|
|
40006
39667
|
const decoded = JSON.parse(raw);
|
|
40007
39668
|
if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
|
|
40008
39669
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
@@ -40036,8 +39697,8 @@ function detectCompletionClaim(reply, ci) {
|
|
|
40036
39697
|
function readLanguagePin(workspaceRoot, session_id) {
|
|
40037
39698
|
if (!hasStableSessionId(session_id)) return "und";
|
|
40038
39699
|
try {
|
|
40039
|
-
const raw =
|
|
40040
|
-
|
|
39700
|
+
const raw = fs69.readFileSync(
|
|
39701
|
+
path71.join(workspaceRoot, statePathFor(session_id)),
|
|
40041
39702
|
"utf-8"
|
|
40042
39703
|
);
|
|
40043
39704
|
const decoded = JSON.parse(raw);
|
|
@@ -40091,7 +39752,7 @@ function sessionStateFile2(workspaceRoot, sessionKey) {
|
|
|
40091
39752
|
}
|
|
40092
39753
|
function alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal) {
|
|
40093
39754
|
try {
|
|
40094
|
-
const raw =
|
|
39755
|
+
const raw = fs69.readFileSync(sessionStateFile2(workspaceRoot, sessionKey), "utf-8");
|
|
40095
39756
|
const decoded = JSON.parse(raw);
|
|
40096
39757
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
40097
39758
|
return decoded["refused_turn"] === turnOrdinal;
|
|
@@ -40105,7 +39766,7 @@ function markRefusedTurn(workspaceRoot, sessionKey, turnOrdinal, detectors) {
|
|
|
40105
39766
|
const file = sessionStateFile2(workspaceRoot, sessionKey);
|
|
40106
39767
|
let prev = null;
|
|
40107
39768
|
try {
|
|
40108
|
-
prev = parseRecord(
|
|
39769
|
+
prev = parseRecord(fs69.readFileSync(file, "utf-8"));
|
|
40109
39770
|
} catch {
|
|
40110
39771
|
}
|
|
40111
39772
|
let version;
|
|
@@ -40132,10 +39793,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
|
|
|
40132
39793
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
|
|
40133
39794
|
let lines;
|
|
40134
39795
|
try {
|
|
40135
|
-
if (opts.maxBytes !== void 0 &&
|
|
39796
|
+
if (opts.maxBytes !== void 0 && fs69.statSync(transcriptPath).size > opts.maxBytes) {
|
|
40136
39797
|
return empty;
|
|
40137
39798
|
}
|
|
40138
|
-
lines =
|
|
39799
|
+
lines = fs69.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
40139
39800
|
} catch {
|
|
40140
39801
|
return empty;
|
|
40141
39802
|
}
|
|
@@ -40211,15 +39872,15 @@ function _messageText(content) {
|
|
|
40211
39872
|
function str3(v) {
|
|
40212
39873
|
return typeof v === "string" ? v : "";
|
|
40213
39874
|
}
|
|
40214
|
-
function
|
|
39875
|
+
function main27() {
|
|
40215
39876
|
let envelope;
|
|
40216
39877
|
let payload;
|
|
40217
39878
|
try {
|
|
40218
39879
|
[envelope, payload] = unwrap(readHookStdin(), "claude");
|
|
40219
39880
|
} catch {
|
|
40220
|
-
return
|
|
39881
|
+
return EXIT_ALLOW4;
|
|
40221
39882
|
}
|
|
40222
|
-
if (payload["stop_hook_active"] === true) return
|
|
39883
|
+
if (payload["stop_hook_active"] === true) return EXIT_ALLOW4;
|
|
40223
39884
|
const workspaceRoot = str3(envelope["workspace_root"]) || process.cwd();
|
|
40224
39885
|
let dispatchOpen = false;
|
|
40225
39886
|
try {
|
|
@@ -40232,10 +39893,10 @@ function main28() {
|
|
|
40232
39893
|
const { lastAssistant, turnOrdinal, toolCalls } = readTranscriptTail(transcriptPath, {
|
|
40233
39894
|
maxBytes: TRANSCRIPT_READ_MAX_BYTES
|
|
40234
39895
|
});
|
|
40235
|
-
if (!lastAssistant) return
|
|
39896
|
+
if (!lastAssistant) return EXIT_ALLOW4;
|
|
40236
39897
|
const rawSessionId = str3(envelope["session_id"]) || "";
|
|
40237
39898
|
const sessionKey = deriveSessionKey2(rawSessionId || "unknown-session");
|
|
40238
|
-
if (alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal)) return
|
|
39899
|
+
if (alreadyRefusedTurn(workspaceRoot, sessionKey, turnOrdinal)) return EXIT_ALLOW4;
|
|
40239
39900
|
const findings = [];
|
|
40240
39901
|
for (const f of [
|
|
40241
39902
|
// A and D are the completion-adjacent pair a pending dispatch excuses
|
|
@@ -40258,7 +39919,7 @@ function main28() {
|
|
|
40258
39919
|
]) {
|
|
40259
39920
|
if (f) findings.push(f);
|
|
40260
39921
|
}
|
|
40261
|
-
if (findings.length === 0) return
|
|
39922
|
+
if (findings.length === 0) return EXIT_ALLOW4;
|
|
40262
39923
|
markRefusedTurn(
|
|
40263
39924
|
workspaceRoot,
|
|
40264
39925
|
sessionKey,
|
|
@@ -40276,28 +39937,28 @@ ${lines.join("\n")}
|
|
|
40276
39937
|
This turn will not be refused a second time.
|
|
40277
39938
|
`
|
|
40278
39939
|
);
|
|
40279
|
-
return
|
|
39940
|
+
return EXIT_BLOCK;
|
|
40280
39941
|
}
|
|
40281
|
-
function
|
|
39942
|
+
function _isCliEntry23() {
|
|
40282
39943
|
if (true) {
|
|
40283
39944
|
return false;
|
|
40284
39945
|
}
|
|
40285
39946
|
if (process.argv[1] === void 0) {
|
|
40286
39947
|
return false;
|
|
40287
39948
|
}
|
|
40288
|
-
const argvUrl =
|
|
39949
|
+
const argvUrl = pathToFileURL27(path71.resolve(process.argv[1])).href;
|
|
40289
39950
|
if (import.meta.url === argvUrl) {
|
|
40290
39951
|
return true;
|
|
40291
39952
|
}
|
|
40292
39953
|
try {
|
|
40293
|
-
const here =
|
|
40294
|
-
const argv =
|
|
39954
|
+
const here = fs69.realpathSync(fileURLToPath37(import.meta.url));
|
|
39955
|
+
const argv = fs69.realpathSync(path71.resolve(process.argv[1]));
|
|
40295
39956
|
return here === argv;
|
|
40296
39957
|
} catch {
|
|
40297
39958
|
return false;
|
|
40298
39959
|
}
|
|
40299
39960
|
}
|
|
40300
|
-
var
|
|
39961
|
+
var EXIT_BLOCK, EXIT_ALLOW4, TRANSCRIPT_READ_MAX_BYTES, PROMISSORY, HANDBACK, _COMPLETION_RE, _NEGATED_CLAIM_RE, _EDIT_TOOLS, _VERIFY_RE;
|
|
40301
39962
|
var init_turn_end_gate_hook = __esm({
|
|
40302
39963
|
"src/scripts/hooks/turn_end_gate_hook.ts"() {
|
|
40303
39964
|
"use strict";
|
|
@@ -40309,8 +39970,8 @@ var init_turn_end_gate_hook = __esm({
|
|
|
40309
39970
|
init_state_io();
|
|
40310
39971
|
init_subagent_ledger_hook();
|
|
40311
39972
|
init_turn_end_refusals();
|
|
40312
|
-
|
|
40313
|
-
|
|
39973
|
+
EXIT_BLOCK = 1;
|
|
39974
|
+
EXIT_ALLOW4 = 0;
|
|
40314
39975
|
TRANSCRIPT_READ_MAX_BYTES = 8 * 1024 * 1024;
|
|
40315
39976
|
PROMISSORY = [
|
|
40316
39977
|
/\bich melde mich\b/i,
|
|
@@ -40363,18 +40024,18 @@ var init_turn_end_gate_hook = __esm({
|
|
|
40363
40024
|
_NEGATED_CLAIM_RE = /\b(noch nicht|nicht fertig|nicht durch|wäre verfrüht|ist verfrüht|not yet|not done|isn'?t done|nein)\b/i;
|
|
40364
40025
|
_EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
40365
40026
|
_VERIFY_RE = /\b(test|tests|vitest|jest|pytest|phpunit|pest|tsc|eslint|ruff|mypy|pyright|clippy|phpstan|typecheck|lint[-_:a-z]*|build|ci|preflight|smoke[-_:a-z]*|check[-_:a-z]*|validate[-_:a-z]*)\b|\b(task|npm|pnpm|yarn|composer|cargo|go|make|php artisan|bun)\s+(run\s+)?\S*(test|check|lint|build|ci|typecheck)/i;
|
|
40366
|
-
if (
|
|
40367
|
-
process.exit(
|
|
40027
|
+
if (_isCliEntry23()) {
|
|
40028
|
+
process.exit(main27());
|
|
40368
40029
|
}
|
|
40369
40030
|
}
|
|
40370
40031
|
});
|
|
40371
40032
|
|
|
40372
40033
|
// src/scripts/hooks/evidence_independence.ts
|
|
40373
40034
|
import crypto10 from "node:crypto";
|
|
40374
|
-
import
|
|
40375
|
-
import
|
|
40376
|
-
import { fileURLToPath as
|
|
40377
|
-
function
|
|
40035
|
+
import fs70 from "node:fs";
|
|
40036
|
+
import path72 from "node:path";
|
|
40037
|
+
import { fileURLToPath as fileURLToPath38, pathToFileURL as pathToFileURL28 } from "node:url";
|
|
40038
|
+
function _isObject6(v) {
|
|
40378
40039
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
40379
40040
|
}
|
|
40380
40041
|
function isDispatchTool(tool) {
|
|
@@ -40396,10 +40057,10 @@ function preloadedVerdict(prompt) {
|
|
|
40396
40057
|
return null;
|
|
40397
40058
|
}
|
|
40398
40059
|
function extractDispatch(envelope) {
|
|
40399
|
-
const payload =
|
|
40060
|
+
const payload = _isObject6(envelope["payload"]) ? envelope["payload"] : envelope;
|
|
40400
40061
|
const toolRaw = payload["tool_name"] ?? payload["toolName"] ?? payload["tool"];
|
|
40401
40062
|
const tool = typeof toolRaw === "string" ? toolRaw : null;
|
|
40402
|
-
const input =
|
|
40063
|
+
const input = _isObject6(payload["tool_input"]) ? payload["tool_input"] : _isObject6(payload["toolInput"]) ? payload["toolInput"] : payload;
|
|
40403
40064
|
for (const key of ["prompt", "instructions", "task", "description"]) {
|
|
40404
40065
|
const v = input[key];
|
|
40405
40066
|
if (typeof v === "string" && v.trim()) {
|
|
@@ -40410,8 +40071,8 @@ function extractDispatch(envelope) {
|
|
|
40410
40071
|
}
|
|
40411
40072
|
function _ledgerStamp(consumer_root) {
|
|
40412
40073
|
try {
|
|
40413
|
-
const raw =
|
|
40414
|
-
|
|
40074
|
+
const raw = fs70.readFileSync(
|
|
40075
|
+
path72.join(consumer_root, "agents", "state", "git-authorization.json"),
|
|
40415
40076
|
"utf8"
|
|
40416
40077
|
);
|
|
40417
40078
|
const d = JSON.parse(raw);
|
|
@@ -40422,22 +40083,22 @@ function _ledgerStamp(consumer_root) {
|
|
|
40422
40083
|
}
|
|
40423
40084
|
function _load2(target) {
|
|
40424
40085
|
try {
|
|
40425
|
-
const decoded = JSON.parse(
|
|
40426
|
-
if (
|
|
40086
|
+
const decoded = JSON.parse(fs70.readFileSync(target, "utf8"));
|
|
40087
|
+
if (_isObject6(decoded) && Array.isArray(decoded["evaluations"])) {
|
|
40427
40088
|
return decoded;
|
|
40428
40089
|
}
|
|
40429
40090
|
} catch {
|
|
40430
40091
|
}
|
|
40431
40092
|
return { session_id: "", turn_started_at: "", evaluations: [] };
|
|
40432
40093
|
}
|
|
40433
|
-
function
|
|
40094
|
+
function decide(tool, prompt, priorEvaluations) {
|
|
40434
40095
|
if (!isDispatchTool(tool) || !isEvaluationPrompt(prompt)) {
|
|
40435
|
-
return { exit:
|
|
40096
|
+
return { exit: EXIT_ALLOW5, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
40436
40097
|
}
|
|
40437
40098
|
const preloaded = preloadedVerdict(prompt);
|
|
40438
40099
|
if (preloaded !== null) {
|
|
40439
40100
|
return {
|
|
40440
|
-
exit:
|
|
40101
|
+
exit: EXIT_BLOCK2,
|
|
40441
40102
|
stdout: "",
|
|
40442
40103
|
stderr: `Blocked: this evaluation prompt pre-loads its verdict ("${preloaded}"). That is the construct that produced a fabricated NO-FINDINGS committed as binding gate evidence, over a delta an unsteered pass then found a live critical in. Remove the expectation from the prompt and let the evaluator reach its own verdict.
|
|
40443
40104
|
`,
|
|
@@ -40445,11 +40106,11 @@ function decide2(tool, prompt, priorEvaluations) {
|
|
|
40445
40106
|
};
|
|
40446
40107
|
}
|
|
40447
40108
|
if (!isSelfScoped(prompt)) {
|
|
40448
|
-
return { exit:
|
|
40109
|
+
return { exit: EXIT_ALLOW5, stdout: "", stderr: "", evaluations: priorEvaluations };
|
|
40449
40110
|
}
|
|
40450
40111
|
if (priorEvaluations >= 1) {
|
|
40451
40112
|
return {
|
|
40452
|
-
exit:
|
|
40113
|
+
exit: EXIT_ALLOW5,
|
|
40453
40114
|
stdout: `${JSON.stringify({
|
|
40454
40115
|
decision: "warn",
|
|
40455
40116
|
reason: `Second evaluation dispatch of your own work in this turn. If both passes judge the SAME subject, that is verdict shopping \u2014 commissioning another with a different prompt or scope selects the answer instead of measuring it. Report what the first pass returned, then re-plan. If this is an implementation fan-out rather than a second review, carry on: this check reads prose and cannot tell the two apart with certainty.`
|
|
@@ -40460,26 +40121,26 @@ function decide2(tool, prompt, priorEvaluations) {
|
|
|
40460
40121
|
};
|
|
40461
40122
|
}
|
|
40462
40123
|
return {
|
|
40463
|
-
exit:
|
|
40124
|
+
exit: EXIT_ALLOW5,
|
|
40464
40125
|
stdout: `${JSON.stringify({ decision: "warn", reason: WARN_TEXT })}
|
|
40465
40126
|
`,
|
|
40466
40127
|
stderr: "",
|
|
40467
40128
|
evaluations: priorEvaluations + 1
|
|
40468
40129
|
};
|
|
40469
40130
|
}
|
|
40470
|
-
function
|
|
40131
|
+
function run4(stdin_text, options) {
|
|
40471
40132
|
let envelope = {};
|
|
40472
40133
|
if (stdin_text.trim()) {
|
|
40473
40134
|
try {
|
|
40474
40135
|
const decoded = JSON.parse(stdin_text);
|
|
40475
|
-
if (
|
|
40136
|
+
if (_isObject6(decoded)) {
|
|
40476
40137
|
envelope = decoded;
|
|
40477
40138
|
}
|
|
40478
40139
|
} catch {
|
|
40479
|
-
return
|
|
40140
|
+
return EXIT_ALLOW5;
|
|
40480
40141
|
}
|
|
40481
40142
|
}
|
|
40482
|
-
const target =
|
|
40143
|
+
const target = path72.join(options.consumer_root, STATE_FILE4);
|
|
40483
40144
|
const state = _load2(target);
|
|
40484
40145
|
const session_id = typeof envelope["session_id"] === "string" ? envelope["session_id"] : "";
|
|
40485
40146
|
const turnMarker = `${session_id}:${_ledgerStamp(options.consumer_root)}`;
|
|
@@ -40489,7 +40150,7 @@ function run5(stdin_text, options) {
|
|
|
40489
40150
|
state.evaluations = [];
|
|
40490
40151
|
}
|
|
40491
40152
|
const [tool, prompt] = extractDispatch(envelope);
|
|
40492
|
-
const decision =
|
|
40153
|
+
const decision = decide(tool, prompt, state.evaluations.length);
|
|
40493
40154
|
if (decision.evaluations > state.evaluations.length) {
|
|
40494
40155
|
state.evaluations.push({
|
|
40495
40156
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -40498,7 +40159,11 @@ function run5(stdin_text, options) {
|
|
|
40498
40159
|
});
|
|
40499
40160
|
try {
|
|
40500
40161
|
atomic_write_json(target, state);
|
|
40501
|
-
} catch {
|
|
40162
|
+
} catch (err) {
|
|
40163
|
+
process.stderr.write(
|
|
40164
|
+
`evidence-independence: evaluation-count write failed (${_errText3(err)}) \u2014 this turn's count did NOT advance, so a second self-scoped evaluation will not be warned about. The pre-loaded-verdict block is unaffected.
|
|
40165
|
+
`
|
|
40166
|
+
);
|
|
40502
40167
|
}
|
|
40503
40168
|
}
|
|
40504
40169
|
if (decision.stdout) {
|
|
@@ -40509,7 +40174,11 @@ function run5(stdin_text, options) {
|
|
|
40509
40174
|
}
|
|
40510
40175
|
return decision.exit;
|
|
40511
40176
|
}
|
|
40512
|
-
function
|
|
40177
|
+
function _errText3(err) {
|
|
40178
|
+
const t = err instanceof Error ? err.message : String(err);
|
|
40179
|
+
return t.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
40180
|
+
}
|
|
40181
|
+
function main28(argv) {
|
|
40513
40182
|
const args = argv ?? process.argv.slice(2);
|
|
40514
40183
|
let consumer_root = process.cwd();
|
|
40515
40184
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -40521,36 +40190,36 @@ function main29(argv) {
|
|
|
40521
40190
|
consumer_root = a.slice("--project-dir=".length);
|
|
40522
40191
|
}
|
|
40523
40192
|
}
|
|
40524
|
-
return
|
|
40193
|
+
return run4(readHookStdin(), { consumer_root });
|
|
40525
40194
|
}
|
|
40526
|
-
function
|
|
40195
|
+
function _isCliEntry24() {
|
|
40527
40196
|
if (true) {
|
|
40528
40197
|
return false;
|
|
40529
40198
|
}
|
|
40530
40199
|
if (process.argv[1] === void 0) {
|
|
40531
40200
|
return false;
|
|
40532
40201
|
}
|
|
40533
|
-
const argvUrl =
|
|
40202
|
+
const argvUrl = pathToFileURL28(path72.resolve(process.argv[1])).href;
|
|
40534
40203
|
if (import.meta.url === argvUrl) {
|
|
40535
40204
|
return true;
|
|
40536
40205
|
}
|
|
40537
40206
|
try {
|
|
40538
|
-
const here =
|
|
40539
|
-
const argv =
|
|
40207
|
+
const here = fs70.realpathSync(fileURLToPath38(import.meta.url));
|
|
40208
|
+
const argv = fs70.realpathSync(path72.resolve(process.argv[1]));
|
|
40540
40209
|
return here === argv;
|
|
40541
40210
|
} catch {
|
|
40542
40211
|
return false;
|
|
40543
40212
|
}
|
|
40544
40213
|
}
|
|
40545
|
-
var
|
|
40214
|
+
var EXIT_ALLOW5, EXIT_BLOCK2, STATE_FILE4, DISPATCH_TOOLS, EVALUATION_RE, PRELOADED_VERDICT_RE, SELF_SCOPE_RE, WARN_TEXT;
|
|
40546
40215
|
var init_evidence_independence = __esm({
|
|
40547
40216
|
"src/scripts/hooks/evidence_independence.ts"() {
|
|
40548
40217
|
"use strict";
|
|
40549
40218
|
init_state_io();
|
|
40550
40219
|
init_hook_stdin();
|
|
40551
|
-
|
|
40552
|
-
|
|
40553
|
-
STATE_FILE4 =
|
|
40220
|
+
EXIT_ALLOW5 = 0;
|
|
40221
|
+
EXIT_BLOCK2 = 1;
|
|
40222
|
+
STATE_FILE4 = path72.join("agents", "state", "evidence-dispatch.json");
|
|
40554
40223
|
DISPATCH_TOOLS = /* @__PURE__ */ new Set([
|
|
40555
40224
|
"Agent",
|
|
40556
40225
|
"Task",
|
|
@@ -40583,8 +40252,8 @@ var init_evidence_independence = __esm({
|
|
|
40583
40252
|
];
|
|
40584
40253
|
SELF_SCOPE_RE = /\b(my (work|change|diff|implementation|code|fix|patch|branch|pr)|this (diff|change|pr|delta|implementation|patch)|the delta|the change i|what i (wrote|built|changed|implemented)|i just (wrote|built|changed|implemented))\b/i;
|
|
40585
40254
|
WARN_TEXT = "First evaluation dispatch this turn. Two shapes fabricated a binding honest-null in the audited sessions \u2014 check your prompt for both before it goes out: (1) a verdict pre-loaded into the prompt, and (2) a scope narrowed to files you chose. A review you commissioned on your own work is admissible as gate evidence only when the prompt is recorded alongside the verdict.";
|
|
40586
|
-
if (
|
|
40587
|
-
process.exit(
|
|
40255
|
+
if (_isCliEntry24()) {
|
|
40256
|
+
process.exit(main28());
|
|
40588
40257
|
}
|
|
40589
40258
|
}
|
|
40590
40259
|
});
|
|
@@ -40940,10 +40609,10 @@ var init_subagent_routing = __esm({
|
|
|
40940
40609
|
});
|
|
40941
40610
|
|
|
40942
40611
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
40943
|
-
import
|
|
40944
|
-
import
|
|
40945
|
-
import { fileURLToPath as
|
|
40946
|
-
function
|
|
40612
|
+
import fs71 from "node:fs";
|
|
40613
|
+
import path73 from "node:path";
|
|
40614
|
+
import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL29 } from "node:url";
|
|
40615
|
+
function _isObject7(v) {
|
|
40947
40616
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
40948
40617
|
}
|
|
40949
40618
|
function enumeratedFileTokens(text) {
|
|
@@ -41094,34 +40763,34 @@ function _workspaceRoot(envelope) {
|
|
|
41094
40763
|
}
|
|
41095
40764
|
return process.cwd();
|
|
41096
40765
|
}
|
|
41097
|
-
function
|
|
40766
|
+
function main29() {
|
|
41098
40767
|
let envelope = {};
|
|
41099
40768
|
try {
|
|
41100
40769
|
const raw = readHookStdin();
|
|
41101
40770
|
envelope = raw.trim() ? JSON.parse(raw) : {};
|
|
41102
40771
|
} catch {
|
|
41103
|
-
return
|
|
40772
|
+
return EXIT_ALLOW6;
|
|
41104
40773
|
}
|
|
41105
|
-
const env =
|
|
40774
|
+
const env = _isObject7(envelope) ? envelope : {};
|
|
41106
40775
|
const event = env["event"];
|
|
41107
40776
|
const slot = typeof event === "string" && event !== "" ? event : "user_prompt_submit";
|
|
41108
40777
|
if (slot !== "user_prompt_submit") {
|
|
41109
|
-
return
|
|
40778
|
+
return EXIT_ALLOW6;
|
|
41110
40779
|
}
|
|
41111
|
-
const payload =
|
|
40780
|
+
const payload = _isObject7(env["payload"]) ? env["payload"] : env;
|
|
41112
40781
|
const prompt = _extractPrompt2(payload);
|
|
41113
40782
|
if (!prompt) {
|
|
41114
|
-
return
|
|
40783
|
+
return EXIT_ALLOW6;
|
|
41115
40784
|
}
|
|
41116
40785
|
if (isSyntheticPrompt(prompt)) {
|
|
41117
|
-
return
|
|
40786
|
+
return EXIT_ALLOW6;
|
|
41118
40787
|
}
|
|
41119
40788
|
const root = _workspaceRoot(env);
|
|
41120
40789
|
const platform = env["platform"];
|
|
41121
40790
|
const hostId = typeof platform === "string" && platform ? platform : null;
|
|
41122
40791
|
const result = classifyPrompt(prompt, root, hostId);
|
|
41123
40792
|
if (!result) {
|
|
41124
|
-
return
|
|
40793
|
+
return EXIT_ALLOW6;
|
|
41125
40794
|
}
|
|
41126
40795
|
process.stdout.write(
|
|
41127
40796
|
`${JSON.stringify({
|
|
@@ -41133,26 +40802,26 @@ function main30() {
|
|
|
41133
40802
|
);
|
|
41134
40803
|
return EXIT_WARN3;
|
|
41135
40804
|
}
|
|
41136
|
-
function
|
|
40805
|
+
function _isCliEntry25() {
|
|
41137
40806
|
if (true) {
|
|
41138
40807
|
return false;
|
|
41139
40808
|
}
|
|
41140
40809
|
if (process.argv[1] === void 0) {
|
|
41141
40810
|
return false;
|
|
41142
40811
|
}
|
|
41143
|
-
const argvUrl =
|
|
40812
|
+
const argvUrl = pathToFileURL29(path73.resolve(process.argv[1])).href;
|
|
41144
40813
|
if (import.meta.url === argvUrl) {
|
|
41145
40814
|
return true;
|
|
41146
40815
|
}
|
|
41147
40816
|
try {
|
|
41148
|
-
const here =
|
|
41149
|
-
const argv =
|
|
40817
|
+
const here = fs71.realpathSync(fileURLToPath39(import.meta.url));
|
|
40818
|
+
const argv = fs71.realpathSync(path73.resolve(process.argv[1]));
|
|
41150
40819
|
return here === argv;
|
|
41151
40820
|
} catch {
|
|
41152
40821
|
return false;
|
|
41153
40822
|
}
|
|
41154
40823
|
}
|
|
41155
|
-
var
|
|
40824
|
+
var EXIT_ALLOW6, EXIT_WARN3, FILE_TOKEN_RE, FILE_SIGNAL_FLOOR, EXPLICIT_COUNT_RE, FOR_EACH_RE, STEP_WORD_RE, STEP_LINE_RE, ORDERED_LINE_FLOOR, ORDERED_WORD_FLOOR;
|
|
41156
40825
|
var init_delegation_nudge_hook = __esm({
|
|
41157
40826
|
"src/scripts/hooks/delegation_nudge_hook.ts"() {
|
|
41158
40827
|
"use strict";
|
|
@@ -41163,7 +40832,7 @@ var init_delegation_nudge_hook = __esm({
|
|
|
41163
40832
|
init_session_role();
|
|
41164
40833
|
init_subagent_routing();
|
|
41165
40834
|
init_prompt_shape();
|
|
41166
|
-
|
|
40835
|
+
EXIT_ALLOW6 = 0;
|
|
41167
40836
|
EXIT_WARN3 = 2;
|
|
41168
40837
|
FILE_TOKEN_RE = /`?\b[\w][\w.\-]{0,80}\.(ts|tsx|js|jsx|mjs|cjs|py|php|rb|go|rs|java|kt|swift|md|mdx|json|ya?ml|css|scss|less|html|vue|svelte|sql|sh|bash|c|cpp|h|hpp|cs|toml|xml)\b`?/gi;
|
|
41169
40838
|
FILE_SIGNAL_FLOOR = 3;
|
|
@@ -41173,18 +40842,18 @@ var init_delegation_nudge_hook = __esm({
|
|
|
41173
40842
|
STEP_LINE_RE = /^\s*\d+[.)]\s+\S/gm;
|
|
41174
40843
|
ORDERED_LINE_FLOOR = 3;
|
|
41175
40844
|
ORDERED_WORD_FLOOR = 2;
|
|
41176
|
-
if (
|
|
41177
|
-
process.exit(
|
|
40845
|
+
if (_isCliEntry25()) {
|
|
40846
|
+
process.exit(main29());
|
|
41178
40847
|
}
|
|
41179
40848
|
}
|
|
41180
40849
|
});
|
|
41181
40850
|
|
|
41182
40851
|
// src/scripts/conformance_scan.ts
|
|
41183
40852
|
import { createHash as createHash12 } from "node:crypto";
|
|
41184
|
-
import
|
|
40853
|
+
import fs72 from "node:fs";
|
|
41185
40854
|
import os15 from "node:os";
|
|
41186
|
-
import
|
|
41187
|
-
import { fileURLToPath as
|
|
40855
|
+
import path74 from "node:path";
|
|
40856
|
+
import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL30 } from "node:url";
|
|
41188
40857
|
function spansCarrierChange(firstAts) {
|
|
41189
40858
|
const stamps = firstAts.filter((s) => s !== "").sort();
|
|
41190
40859
|
if (stamps.length === 0) {
|
|
@@ -41244,7 +40913,7 @@ function renderWhy(report2, id) {
|
|
|
41244
40913
|
}
|
|
41245
40914
|
return lines.join("\n");
|
|
41246
40915
|
}
|
|
41247
|
-
function
|
|
40916
|
+
function _isObject8(v) {
|
|
41248
40917
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
41249
40918
|
}
|
|
41250
40919
|
function userText(entry) {
|
|
@@ -41268,15 +40937,15 @@ function assistantText(entry) {
|
|
|
41268
40937
|
}
|
|
41269
40938
|
function toolUses2(entry) {
|
|
41270
40939
|
const msg = entry["message"];
|
|
41271
|
-
const content =
|
|
40940
|
+
const content = _isObject8(msg) ? msg["content"] : void 0;
|
|
41272
40941
|
if (!Array.isArray(content)) {
|
|
41273
40942
|
return [];
|
|
41274
40943
|
}
|
|
41275
|
-
return content.filter((b) =>
|
|
40944
|
+
return content.filter((b) => _isObject8(b) && b["type"] === "tool_use").map((b) => {
|
|
41276
40945
|
const o = b;
|
|
41277
40946
|
return {
|
|
41278
40947
|
name: String(o["name"] ?? ""),
|
|
41279
|
-
input:
|
|
40948
|
+
input: _isObject8(o["input"]) ? o["input"] : {}
|
|
41280
40949
|
};
|
|
41281
40950
|
});
|
|
41282
40951
|
}
|
|
@@ -41510,7 +41179,7 @@ function scanSession(sessionId, lines) {
|
|
|
41510
41179
|
}
|
|
41511
41180
|
function defaultStore(projectDir) {
|
|
41512
41181
|
const slug = projectStoreSlug(projectDir);
|
|
41513
|
-
return
|
|
41182
|
+
return path74.join(process.env["HOME"] ?? "", ".claude", "projects", slug);
|
|
41514
41183
|
}
|
|
41515
41184
|
function _tokens(chars) {
|
|
41516
41185
|
return Math.round(chars / 4);
|
|
@@ -41521,13 +41190,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
41521
41190
|
return {
|
|
41522
41191
|
project: {
|
|
41523
41192
|
dir: projectRulesDir,
|
|
41524
|
-
present:
|
|
41193
|
+
present: fs72.existsSync(projectRulesDir),
|
|
41525
41194
|
files: p.files,
|
|
41526
41195
|
tokens: _tokens(p.chars)
|
|
41527
41196
|
},
|
|
41528
41197
|
global: {
|
|
41529
41198
|
dir: globalRulesDir,
|
|
41530
|
-
present:
|
|
41199
|
+
present: fs72.existsSync(globalRulesDir),
|
|
41531
41200
|
files: g.files,
|
|
41532
41201
|
tokens: _tokens(g.chars)
|
|
41533
41202
|
},
|
|
@@ -41535,13 +41204,13 @@ function measureDelivered(projectRulesDir, globalRulesDir) {
|
|
|
41535
41204
|
};
|
|
41536
41205
|
}
|
|
41537
41206
|
function storeKey(store) {
|
|
41538
|
-
return createHash12("sha256").update(
|
|
41207
|
+
return createHash12("sha256").update(path74.resolve(store)).digest("hex").slice(0, 12);
|
|
41539
41208
|
}
|
|
41540
41209
|
function scanStore(store, limit) {
|
|
41541
|
-
const files =
|
|
41210
|
+
const files = fs72.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, m: fs72.statSync(path74.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.f);
|
|
41542
41211
|
const per_session = [];
|
|
41543
41212
|
for (const f of files) {
|
|
41544
|
-
const lines =
|
|
41213
|
+
const lines = fs72.readFileSync(path74.join(store, f), "utf8").split("\n");
|
|
41545
41214
|
const r = scanSession(f.replace(/\.jsonl$/, "").slice(0, 8), lines);
|
|
41546
41215
|
if (r.assistant_turns > 0) {
|
|
41547
41216
|
per_session.push(r);
|
|
@@ -41569,10 +41238,10 @@ function scanStore(store, limit) {
|
|
|
41569
41238
|
const task_completeness_rate_pct = completeness_windows === 0 ? 0 : Number((100 * task_completeness / completeness_windows).toFixed(1));
|
|
41570
41239
|
const era = spansCarrierChange(per_session.map((s) => s.first_at));
|
|
41571
41240
|
const delivered = measureDelivered(
|
|
41572
|
-
|
|
41573
|
-
|
|
41241
|
+
path74.join(REPO_ROOT6, ".claude", "rules"),
|
|
41242
|
+
path74.join(process.env["HOME"] ?? os15.homedir(), ".claude", "rules")
|
|
41574
41243
|
);
|
|
41575
|
-
const ownStore =
|
|
41244
|
+
const ownStore = path74.resolve(store) === path74.resolve(defaultStore(REPO_ROOT6));
|
|
41576
41245
|
return {
|
|
41577
41246
|
scanned_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41578
41247
|
store,
|
|
@@ -41602,8 +41271,8 @@ function scanStore(store, limit) {
|
|
|
41602
41271
|
};
|
|
41603
41272
|
}
|
|
41604
41273
|
function recordRate(file, scanned_at, rate) {
|
|
41605
|
-
|
|
41606
|
-
|
|
41274
|
+
fs72.mkdirSync(path74.dirname(file), { recursive: true });
|
|
41275
|
+
fs72.appendFileSync(file, `${JSON.stringify({ measured_at: scanned_at, ...rate })}
|
|
41607
41276
|
`, "utf8");
|
|
41608
41277
|
}
|
|
41609
41278
|
function render2(report2) {
|
|
@@ -41702,7 +41371,7 @@ function render2(report2) {
|
|
|
41702
41371
|
lines.push(" checkbox batching \u2014 measured NOWHERE. ~5 low-severity findings.");
|
|
41703
41372
|
return lines.join("\n");
|
|
41704
41373
|
}
|
|
41705
|
-
function
|
|
41374
|
+
function main30(argv) {
|
|
41706
41375
|
const args = argv ?? process.argv.slice(2);
|
|
41707
41376
|
let store = null;
|
|
41708
41377
|
let limit = 30;
|
|
@@ -41734,14 +41403,14 @@ function main31(argv) {
|
|
|
41734
41403
|
return 2;
|
|
41735
41404
|
}
|
|
41736
41405
|
const resolved = store ?? defaultStore(process.cwd());
|
|
41737
|
-
if (!
|
|
41406
|
+
if (!fs72.existsSync(resolved)) {
|
|
41738
41407
|
process.stderr.write(`conformance:behavior: no transcript store at ${resolved}
|
|
41739
41408
|
`);
|
|
41740
41409
|
return 1;
|
|
41741
41410
|
}
|
|
41742
41411
|
const report2 = scanStore(resolved, Number.isFinite(limit) && limit > 0 ? limit : 30);
|
|
41743
41412
|
if (out) {
|
|
41744
|
-
|
|
41413
|
+
fs72.writeFileSync(out, `${JSON.stringify(report2, null, 2)}
|
|
41745
41414
|
`, "utf8");
|
|
41746
41415
|
}
|
|
41747
41416
|
if (record) {
|
|
@@ -41749,7 +41418,7 @@ function main31(argv) {
|
|
|
41749
41418
|
}
|
|
41750
41419
|
if (why !== null) {
|
|
41751
41420
|
const id = why;
|
|
41752
|
-
|
|
41421
|
+
fs72.writeSync(
|
|
41753
41422
|
1,
|
|
41754
41423
|
json ? `${JSON.stringify(
|
|
41755
41424
|
{
|
|
@@ -41769,25 +41438,25 @@ function main31(argv) {
|
|
|
41769
41438
|
);
|
|
41770
41439
|
return 0;
|
|
41771
41440
|
}
|
|
41772
|
-
|
|
41441
|
+
fs72.writeSync(1, json ? `${JSON.stringify(report2, null, 2)}
|
|
41773
41442
|
` : `${render2(report2)}
|
|
41774
41443
|
`);
|
|
41775
41444
|
return 0;
|
|
41776
41445
|
}
|
|
41777
|
-
function
|
|
41446
|
+
function _isCliEntry26() {
|
|
41778
41447
|
if (true) {
|
|
41779
41448
|
return false;
|
|
41780
41449
|
}
|
|
41781
41450
|
if (process.argv[1] === void 0) {
|
|
41782
41451
|
return false;
|
|
41783
41452
|
}
|
|
41784
|
-
const argvUrl =
|
|
41453
|
+
const argvUrl = pathToFileURL30(path74.resolve(process.argv[1])).href;
|
|
41785
41454
|
if (import.meta.url === argvUrl) {
|
|
41786
41455
|
return true;
|
|
41787
41456
|
}
|
|
41788
41457
|
try {
|
|
41789
|
-
const here =
|
|
41790
|
-
const argv =
|
|
41458
|
+
const here = fs72.realpathSync(fileURLToPath40(import.meta.url));
|
|
41459
|
+
const argv = fs72.realpathSync(path74.resolve(process.argv[1]));
|
|
41791
41460
|
return here === argv;
|
|
41792
41461
|
} catch {
|
|
41793
41462
|
return false;
|
|
@@ -41803,12 +41472,12 @@ var init_conformance_scan = __esm({
|
|
|
41803
41472
|
init_language_mirror_hook();
|
|
41804
41473
|
init_prompt_shape();
|
|
41805
41474
|
init_git_authorization_hook();
|
|
41806
|
-
|
|
41475
|
+
init_git_command_classifier();
|
|
41807
41476
|
init_before_complete_hook();
|
|
41808
41477
|
init_turn_end_gate_hook();
|
|
41809
41478
|
init_evidence_independence();
|
|
41810
41479
|
init_delegation_nudge_hook();
|
|
41811
|
-
REPO_ROOT6 =
|
|
41480
|
+
REPO_ROOT6 = path74.resolve(path74.dirname(fileURLToPath40(import.meta.url)), "..", "..");
|
|
41812
41481
|
OBSERVED_BAND = { low: 9.1, high: 39.2 };
|
|
41813
41482
|
BAND_MIN_TURNS = 1978;
|
|
41814
41483
|
CARRIER_CHANGES = [
|
|
@@ -41835,28 +41504,28 @@ var init_conformance_scan = __esm({
|
|
|
41835
41504
|
};
|
|
41836
41505
|
HARNESS_TEXT = /^(API Error:|Request (timed out|was aborted)|\[Request interrupted|Error: |Credit balance is too low|You've hit your|Prompt is too long)/i;
|
|
41837
41506
|
EN_OPENER = /^(let me|i'?ll |i'?m |found it|ok[,. ]|okay|alright|here'?s|now[,. ]|looking|checking|reading|running|the |this |that |there |we |you |good |right[,. ]|perfect|done[.,]|all |confirmed|correct)/i;
|
|
41838
|
-
DEFAULT_RATE_SERIES =
|
|
41507
|
+
DEFAULT_RATE_SERIES = path74.join(
|
|
41839
41508
|
REPO_ROOT6,
|
|
41840
41509
|
"agents",
|
|
41841
41510
|
"runtime",
|
|
41842
41511
|
"state",
|
|
41843
41512
|
"conformance-rates.jsonl"
|
|
41844
41513
|
);
|
|
41845
|
-
if (
|
|
41846
|
-
process.exit(
|
|
41514
|
+
if (_isCliEntry26()) {
|
|
41515
|
+
process.exit(main30());
|
|
41847
41516
|
}
|
|
41848
41517
|
}
|
|
41849
41518
|
});
|
|
41850
41519
|
|
|
41851
41520
|
// src/scripts/report_carrier_divergence.ts
|
|
41852
|
-
import * as
|
|
41521
|
+
import * as fs73 from "node:fs";
|
|
41853
41522
|
import * as os16 from "node:os";
|
|
41854
|
-
import * as
|
|
41523
|
+
import * as path75 from "node:path";
|
|
41855
41524
|
import process18 from "node:process";
|
|
41856
|
-
import { fileURLToPath as
|
|
41525
|
+
import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL31 } from "node:url";
|
|
41857
41526
|
function _listRules(dir) {
|
|
41858
41527
|
try {
|
|
41859
|
-
return
|
|
41528
|
+
return fs73.readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
|
|
41860
41529
|
} catch {
|
|
41861
41530
|
return [];
|
|
41862
41531
|
}
|
|
@@ -41864,7 +41533,7 @@ function _listRules(dir) {
|
|
|
41864
41533
|
function _ruleType(file) {
|
|
41865
41534
|
let text;
|
|
41866
41535
|
try {
|
|
41867
|
-
text =
|
|
41536
|
+
text = fs73.readFileSync(file, "utf-8");
|
|
41868
41537
|
} catch {
|
|
41869
41538
|
return "";
|
|
41870
41539
|
}
|
|
@@ -41875,8 +41544,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
41875
41544
|
const out = {
|
|
41876
41545
|
projectDir,
|
|
41877
41546
|
globalDir,
|
|
41878
|
-
globalPresent:
|
|
41879
|
-
projectPresent:
|
|
41547
|
+
globalPresent: fs73.existsSync(globalDir),
|
|
41548
|
+
projectPresent: fs73.existsSync(projectDir),
|
|
41880
41549
|
shared: 0,
|
|
41881
41550
|
identical: [],
|
|
41882
41551
|
provenanceOnly: [],
|
|
@@ -41899,7 +41568,7 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
41899
41568
|
}
|
|
41900
41569
|
if (!inP && inG) {
|
|
41901
41570
|
out.globalOnly.push(rule);
|
|
41902
|
-
if (sourceDir !== void 0 && _ruleType(
|
|
41571
|
+
if (sourceDir !== void 0 && _ruleType(path75.join(sourceDir, rule)) === "manual") {
|
|
41903
41572
|
out.manualOnlyGlobal.push(rule);
|
|
41904
41573
|
}
|
|
41905
41574
|
continue;
|
|
@@ -41909,8 +41578,8 @@ function compareCarriers(projectDir, globalDir, sourceDir) {
|
|
|
41909
41578
|
let projectCopy;
|
|
41910
41579
|
let globalCopy;
|
|
41911
41580
|
try {
|
|
41912
|
-
projectCopy =
|
|
41913
|
-
globalCopy =
|
|
41581
|
+
projectCopy = fs73.readFileSync(path75.join(projectDir, rule));
|
|
41582
|
+
globalCopy = fs73.readFileSync(path75.join(globalDir, rule));
|
|
41914
41583
|
verdict = comparePair(projectCopy, globalCopy);
|
|
41915
41584
|
} catch {
|
|
41916
41585
|
out.shared -= 1;
|
|
@@ -42055,11 +41724,11 @@ function render3(d) {
|
|
|
42055
41724
|
}
|
|
42056
41725
|
return lines.join("\n");
|
|
42057
41726
|
}
|
|
42058
|
-
function
|
|
41727
|
+
function main31(argv) {
|
|
42059
41728
|
const args = argv ?? process18.argv.slice(2);
|
|
42060
|
-
let projectDir =
|
|
42061
|
-
let globalDir =
|
|
42062
|
-
let sourceDir =
|
|
41729
|
+
let projectDir = path75.join(REPO_ROOT7, PROJECT_RULES);
|
|
41730
|
+
let globalDir = path75.join(os16.homedir(), GLOBAL_RULES);
|
|
41731
|
+
let sourceDir = path75.join(REPO_ROOT7, PROJECTION_SOURCE);
|
|
42063
41732
|
const value = (i) => {
|
|
42064
41733
|
const v = args[i + 1];
|
|
42065
41734
|
return v === void 0 || v.startsWith("-") ? null : v;
|
|
@@ -42073,7 +41742,7 @@ function main32(argv) {
|
|
|
42073
41742
|
`);
|
|
42074
41743
|
return 1;
|
|
42075
41744
|
}
|
|
42076
|
-
const resolved =
|
|
41745
|
+
const resolved = path75.resolve(v);
|
|
42077
41746
|
if (a === "--project") projectDir = resolved;
|
|
42078
41747
|
else if (a === "--global") globalDir = resolved;
|
|
42079
41748
|
else sourceDir = resolved;
|
|
@@ -42093,11 +41762,11 @@ function main32(argv) {
|
|
|
42093
41762
|
`);
|
|
42094
41763
|
return 0;
|
|
42095
41764
|
}
|
|
42096
|
-
function
|
|
41765
|
+
function _isCliEntry27() {
|
|
42097
41766
|
if (process18.argv[1] === void 0) return false;
|
|
42098
|
-
if (import.meta.url ===
|
|
41767
|
+
if (import.meta.url === pathToFileURL31(path75.resolve(process18.argv[1])).href) return true;
|
|
42099
41768
|
try {
|
|
42100
|
-
return
|
|
41769
|
+
return fs73.realpathSync(_HERE19) === fs73.realpathSync(path75.resolve(process18.argv[1]));
|
|
42101
41770
|
} catch {
|
|
42102
41771
|
return false;
|
|
42103
41772
|
}
|
|
@@ -42107,37 +41776,37 @@ var init_report_carrier_divergence = __esm({
|
|
|
42107
41776
|
"src/scripts/report_carrier_divergence.ts"() {
|
|
42108
41777
|
"use strict";
|
|
42109
41778
|
init_carrier_divergence();
|
|
42110
|
-
_HERE19 =
|
|
42111
|
-
REPO_ROOT7 =
|
|
42112
|
-
PROJECT_RULES =
|
|
42113
|
-
PROJECTION_SOURCE =
|
|
42114
|
-
GLOBAL_RULES =
|
|
42115
|
-
if (
|
|
42116
|
-
process18.exit(
|
|
41779
|
+
_HERE19 = fileURLToPath41(import.meta.url);
|
|
41780
|
+
REPO_ROOT7 = path75.resolve(path75.dirname(_HERE19), "..", "..");
|
|
41781
|
+
PROJECT_RULES = path75.join(".claude", "rules");
|
|
41782
|
+
PROJECTION_SOURCE = path75.join("dist", "agent-src", "rules");
|
|
41783
|
+
GLOBAL_RULES = path75.join(".claude", "rules");
|
|
41784
|
+
if (_isCliEntry27()) {
|
|
41785
|
+
process18.exit(main31());
|
|
42117
41786
|
}
|
|
42118
41787
|
}
|
|
42119
41788
|
});
|
|
42120
41789
|
|
|
42121
41790
|
// src/scripts/report_skill_activation.ts
|
|
42122
|
-
import * as
|
|
41791
|
+
import * as fs74 from "node:fs";
|
|
42123
41792
|
import * as os17 from "node:os";
|
|
42124
|
-
import * as
|
|
42125
|
-
import { fileURLToPath as
|
|
41793
|
+
import * as path76 from "node:path";
|
|
41794
|
+
import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL32 } from "node:url";
|
|
42126
41795
|
function censusSkills(root) {
|
|
42127
41796
|
const out = { total: 0, withTriggerKey: [], withDeterministicObligation: [] };
|
|
42128
|
-
if (!
|
|
41797
|
+
if (!fs74.existsSync(root)) {
|
|
42129
41798
|
return out;
|
|
42130
41799
|
}
|
|
42131
|
-
for (const entry of
|
|
41800
|
+
for (const entry of fs74.readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
42132
41801
|
if (!entry.isDirectory()) {
|
|
42133
41802
|
continue;
|
|
42134
41803
|
}
|
|
42135
|
-
const file =
|
|
42136
|
-
if (!
|
|
41804
|
+
const file = path76.join(root, entry.name, "SKILL.md");
|
|
41805
|
+
if (!fs74.existsSync(file)) {
|
|
42137
41806
|
continue;
|
|
42138
41807
|
}
|
|
42139
41808
|
out.total += 1;
|
|
42140
|
-
const text =
|
|
41809
|
+
const text = fs74.readFileSync(file, "utf8");
|
|
42141
41810
|
const fmEnd = text.startsWith("---") ? text.indexOf("\n---", 3) : -1;
|
|
42142
41811
|
const fm = fmEnd === -1 ? "" : text.slice(0, fmEnd);
|
|
42143
41812
|
if (TRIGGER_KEYS.some((k) => new RegExp(`^${k}`, "m").test(fm))) {
|
|
@@ -42151,17 +41820,17 @@ function censusSkills(root) {
|
|
|
42151
41820
|
return out;
|
|
42152
41821
|
}
|
|
42153
41822
|
function defaultStore2(cwd) {
|
|
42154
|
-
return
|
|
41823
|
+
return path76.join(os17.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
42155
41824
|
}
|
|
42156
41825
|
function measureUsage(store, limit) {
|
|
42157
41826
|
const rep = { store, sessions: 0, assistantTurns: 0, invocations: 0, bySkill: {} };
|
|
42158
|
-
if (!
|
|
41827
|
+
if (!fs74.existsSync(store)) {
|
|
42159
41828
|
return rep;
|
|
42160
41829
|
}
|
|
42161
|
-
const files =
|
|
41830
|
+
const files = fs74.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => path76.join(store, f)).sort((a, b) => fs74.statSync(b).mtimeMs - fs74.statSync(a).mtimeMs).slice(0, limit);
|
|
42162
41831
|
rep.sessions = files.length;
|
|
42163
41832
|
for (const file of files) {
|
|
42164
|
-
for (const line of
|
|
41833
|
+
for (const line of fs74.readFileSync(file, "utf8").split("\n")) {
|
|
42165
41834
|
if (!line.trim()) {
|
|
42166
41835
|
continue;
|
|
42167
41836
|
}
|
|
@@ -42224,7 +41893,7 @@ function render4(census, usage) {
|
|
|
42224
41893
|
}
|
|
42225
41894
|
totalInv += u.invocations;
|
|
42226
41895
|
lines.push(
|
|
42227
|
-
` ${
|
|
41896
|
+
` ${path76.basename(u.store).slice(-38).padEnd(38)} sessions=${String(u.sessions).padStart(3)} asst=${String(u.assistantTurns).padStart(6)} Skill calls=${String(u.invocations).padStart(3)}`
|
|
42228
41897
|
);
|
|
42229
41898
|
}
|
|
42230
41899
|
lines.push("");
|
|
@@ -42249,7 +41918,7 @@ function render4(census, usage) {
|
|
|
42249
41918
|
lines.push(" catalogue once per session, then count descriptions against bare names.");
|
|
42250
41919
|
return lines.join("\n");
|
|
42251
41920
|
}
|
|
42252
|
-
function
|
|
41921
|
+
function main32(argv) {
|
|
42253
41922
|
let limit = 30;
|
|
42254
41923
|
const stores = [];
|
|
42255
41924
|
for (let i = 0; i < argv.length; i += 1) {
|
|
@@ -42272,7 +41941,7 @@ function main33(argv) {
|
|
|
42272
41941
|
if (stores.length === 0) {
|
|
42273
41942
|
stores.push(defaultStore2(REPO_ROOT8));
|
|
42274
41943
|
}
|
|
42275
|
-
const census = censusSkills(
|
|
41944
|
+
const census = censusSkills(path76.join(REPO_ROOT8, SKILLS_ROOT));
|
|
42276
41945
|
const usage = stores.map((s) => measureUsage(s, limit));
|
|
42277
41946
|
process.stdout.write(`${render4(census, usage)}
|
|
42278
41947
|
`);
|
|
@@ -42283,23 +41952,23 @@ var init_report_skill_activation = __esm({
|
|
|
42283
41952
|
"src/scripts/report_skill_activation.ts"() {
|
|
42284
41953
|
"use strict";
|
|
42285
41954
|
init_cc_transcript();
|
|
42286
|
-
_HERE20 =
|
|
42287
|
-
REPO_ROOT8 =
|
|
41955
|
+
_HERE20 = fileURLToPath42(import.meta.url);
|
|
41956
|
+
REPO_ROOT8 = path76.resolve(path76.dirname(_HERE20), "..", "..");
|
|
42288
41957
|
SKILLS_ROOT = "src/skills";
|
|
42289
41958
|
TRIGGER_KEYS = ["triggers:", "trigger_description:", "file_pattern:", "path_prefix:"];
|
|
42290
41959
|
DETERMINISTIC_RE = /^\s*(?:[-*]\s*)?(?:\*\*)?(MUST|NEVER|ALWAYS)\b/m;
|
|
42291
|
-
if (process.argv[1] !== void 0 && import.meta.url ===
|
|
42292
|
-
process.exit(
|
|
41960
|
+
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL32(path76.resolve(process.argv[1])).href) {
|
|
41961
|
+
process.exit(main32(process.argv.slice(2)));
|
|
42293
41962
|
}
|
|
42294
41963
|
}
|
|
42295
41964
|
});
|
|
42296
41965
|
|
|
42297
41966
|
// src/scripts/report_skill_obligation_violations.ts
|
|
42298
|
-
import * as
|
|
41967
|
+
import * as fs75 from "node:fs";
|
|
42299
41968
|
import * as os18 from "node:os";
|
|
42300
|
-
import * as
|
|
41969
|
+
import * as path77 from "node:path";
|
|
42301
41970
|
import process19 from "node:process";
|
|
42302
|
-
import { fileURLToPath as
|
|
41971
|
+
import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL33 } from "node:url";
|
|
42303
41972
|
function _verb(line) {
|
|
42304
41973
|
const m = /\b(NEVER|MUST|ALWAYS)\b/.exec(line);
|
|
42305
41974
|
return m?.[1] ?? "NEVER";
|
|
@@ -42318,7 +41987,7 @@ function _artefacts(line) {
|
|
|
42318
41987
|
return out;
|
|
42319
41988
|
}
|
|
42320
41989
|
function extractObligations(repoRoot) {
|
|
42321
|
-
const skillsRoot =
|
|
41990
|
+
const skillsRoot = path77.join(repoRoot, SKILLS_ROOT);
|
|
42322
41991
|
const census = censusSkills(skillsRoot);
|
|
42323
41992
|
const out = {
|
|
42324
41993
|
skills: census.withDeterministicObligation,
|
|
@@ -42332,7 +42001,7 @@ function extractObligations(repoRoot) {
|
|
|
42332
42001
|
for (const skill of census.withDeterministicObligation) {
|
|
42333
42002
|
let text;
|
|
42334
42003
|
try {
|
|
42335
|
-
text =
|
|
42004
|
+
text = fs75.readFileSync(path77.join(skillsRoot, skill, "SKILL.md"), "utf-8");
|
|
42336
42005
|
} catch {
|
|
42337
42006
|
continue;
|
|
42338
42007
|
}
|
|
@@ -42434,7 +42103,7 @@ function scanSessionForViolations(session, lines, forbidden, parsed) {
|
|
|
42434
42103
|
return flags;
|
|
42435
42104
|
}
|
|
42436
42105
|
function defaultStore3(cwd) {
|
|
42437
|
-
return
|
|
42106
|
+
return path77.join(os18.homedir(), ".claude", "projects", projectStoreSlug(cwd));
|
|
42438
42107
|
}
|
|
42439
42108
|
function scanStore2(repoRoot, store, limit) {
|
|
42440
42109
|
const census = extractObligations(repoRoot);
|
|
@@ -42447,14 +42116,14 @@ function scanStore2(repoRoot, store, limit) {
|
|
|
42447
42116
|
};
|
|
42448
42117
|
let files;
|
|
42449
42118
|
try {
|
|
42450
|
-
files =
|
|
42119
|
+
files = fs75.readdirSync(store).filter((f) => f.endsWith(".jsonl")).map((f) => ({ p: path77.join(store, f), m: fs75.statSync(path77.join(store, f)).mtimeMs })).sort((a, b) => b.m - a.m).slice(0, limit).map((x) => x.p);
|
|
42451
42120
|
} catch {
|
|
42452
42121
|
return report2;
|
|
42453
42122
|
}
|
|
42454
42123
|
report2.sessions = files.length;
|
|
42455
42124
|
for (const file of files) {
|
|
42456
|
-
const lines =
|
|
42457
|
-
const id =
|
|
42125
|
+
const lines = fs75.readFileSync(file, "utf-8").split("\n");
|
|
42126
|
+
const id = path77.basename(file).replace(/\.jsonl$/, "").slice(0, 8);
|
|
42458
42127
|
const entries = _parseSession(lines);
|
|
42459
42128
|
if (loadedSkillsFrom(entries).size > 0) report2.sessionsWithASkill += 1;
|
|
42460
42129
|
report2.flags.push(...scanSessionForViolations(id, lines, census.forbidden, entries));
|
|
@@ -42524,7 +42193,7 @@ function render5(r) {
|
|
|
42524
42193
|
lines.push(" ships as detection-only, and this one says so.");
|
|
42525
42194
|
return lines.join("\n");
|
|
42526
42195
|
}
|
|
42527
|
-
function
|
|
42196
|
+
function main33(argv) {
|
|
42528
42197
|
const args = argv ?? process19.argv.slice(2);
|
|
42529
42198
|
let limit = 30;
|
|
42530
42199
|
let json = false;
|
|
@@ -42577,11 +42246,11 @@ function main34(argv) {
|
|
|
42577
42246
|
}
|
|
42578
42247
|
return 0;
|
|
42579
42248
|
}
|
|
42580
|
-
function
|
|
42249
|
+
function _isCliEntry28() {
|
|
42581
42250
|
if (process19.argv[1] === void 0) return false;
|
|
42582
|
-
if (import.meta.url ===
|
|
42251
|
+
if (import.meta.url === pathToFileURL33(path77.resolve(process19.argv[1])).href) return true;
|
|
42583
42252
|
try {
|
|
42584
|
-
return
|
|
42253
|
+
return fs75.realpathSync(_HERE21) === fs75.realpathSync(path77.resolve(process19.argv[1]));
|
|
42585
42254
|
} catch {
|
|
42586
42255
|
return false;
|
|
42587
42256
|
}
|
|
@@ -42593,8 +42262,8 @@ var init_report_skill_obligation_violations = __esm({
|
|
|
42593
42262
|
init_cc_transcript();
|
|
42594
42263
|
init_transcript_entry();
|
|
42595
42264
|
init_report_skill_activation();
|
|
42596
|
-
_HERE21 =
|
|
42597
|
-
REPO_ROOT9 =
|
|
42265
|
+
_HERE21 = fileURLToPath43(import.meta.url);
|
|
42266
|
+
REPO_ROOT9 = path77.resolve(path77.dirname(_HERE21), "..", "..");
|
|
42598
42267
|
OBLIGATION_LINE_RE = new RegExp(`${DETERMINISTIC_RE.source}.*`, "gm");
|
|
42599
42268
|
PATH_RE = /`([A-Za-z0-9_./-]*\/[A-Za-z0-9_.-]+\.[a-z]{2,6})`/g;
|
|
42600
42269
|
CMD_RE = /`([a-z][a-z0-9-]*(?: [a-z][a-z0-9:._-]*){1,3})`/g;
|
|
@@ -42628,31 +42297,31 @@ var init_report_skill_obligation_violations = __esm({
|
|
|
42628
42297
|
SKILL_BODY_RE = /Base directory for this skill:\s*\S*?\/skills\/([A-Za-z0-9_-]+)/;
|
|
42629
42298
|
PATH_FIELDS = ["file_path", "path", "filePath", "notebook_path", "target_file"];
|
|
42630
42299
|
COMMAND_FIELDS = ["command", "cmd"];
|
|
42631
|
-
if (
|
|
42632
|
-
process19.exit(
|
|
42300
|
+
if (_isCliEntry28()) {
|
|
42301
|
+
process19.exit(main33());
|
|
42633
42302
|
}
|
|
42634
42303
|
}
|
|
42635
42304
|
});
|
|
42636
42305
|
|
|
42637
42306
|
// src/scripts/report_conformance_funnel.ts
|
|
42638
|
-
import * as
|
|
42307
|
+
import * as fs76 from "node:fs";
|
|
42639
42308
|
import * as os19 from "node:os";
|
|
42640
|
-
import * as
|
|
42309
|
+
import * as path78 from "node:path";
|
|
42641
42310
|
import process20 from "node:process";
|
|
42642
|
-
import { fileURLToPath as
|
|
42311
|
+
import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL34 } from "node:url";
|
|
42643
42312
|
function buildFunnel(opts = {}) {
|
|
42644
42313
|
const repoRoot = opts.repoRoot ?? REPO_ROOT10;
|
|
42645
|
-
const projectRulesDir = opts.projectRulesDir ??
|
|
42646
|
-
const globalRulesDir = opts.globalRulesDir ??
|
|
42647
|
-
const sourceDir = opts.sourceDir ??
|
|
42314
|
+
const projectRulesDir = opts.projectRulesDir ?? path78.join(repoRoot, PROJECT_RULES);
|
|
42315
|
+
const globalRulesDir = opts.globalRulesDir ?? path78.join(os19.homedir(), GLOBAL_RULES);
|
|
42316
|
+
const sourceDir = opts.sourceDir ?? path78.join(repoRoot, PROJECTION_SOURCE);
|
|
42648
42317
|
const store = opts.store ?? defaultStore(repoRoot);
|
|
42649
42318
|
const limit = opts.limit ?? 30;
|
|
42650
42319
|
return {
|
|
42651
42320
|
delivered: measureDelivered(projectRulesDir, globalRulesDir),
|
|
42652
42321
|
divergence: compareCarriers(projectRulesDir, globalRulesDir, sourceDir),
|
|
42653
|
-
skills: censusSkills(
|
|
42322
|
+
skills: censusSkills(path78.join(repoRoot, SKILLS_ROOT)),
|
|
42654
42323
|
usage: measureUsage(store, limit),
|
|
42655
|
-
storePresent:
|
|
42324
|
+
storePresent: fs76.existsSync(store),
|
|
42656
42325
|
sk2: scanStore2(repoRoot, store, limit)
|
|
42657
42326
|
};
|
|
42658
42327
|
}
|
|
@@ -42777,7 +42446,7 @@ function render6(r) {
|
|
|
42777
42446
|
lines.push("workflow without a measured false-positive rate first (locked policy).");
|
|
42778
42447
|
return lines.join("\n");
|
|
42779
42448
|
}
|
|
42780
|
-
function
|
|
42449
|
+
function main34(argv) {
|
|
42781
42450
|
const args = argv ?? process20.argv.slice(2);
|
|
42782
42451
|
const opts = {};
|
|
42783
42452
|
const value = (i) => {
|
|
@@ -42793,7 +42462,7 @@ function main35(argv) {
|
|
|
42793
42462
|
`);
|
|
42794
42463
|
return 1;
|
|
42795
42464
|
}
|
|
42796
|
-
const resolved =
|
|
42465
|
+
const resolved = path78.resolve(v);
|
|
42797
42466
|
if (a === "--store") opts.store = resolved;
|
|
42798
42467
|
else if (a === "--project") opts.projectRulesDir = resolved;
|
|
42799
42468
|
else if (a === "--global") opts.globalRulesDir = resolved;
|
|
@@ -42823,11 +42492,11 @@ function main35(argv) {
|
|
|
42823
42492
|
`);
|
|
42824
42493
|
return 0;
|
|
42825
42494
|
}
|
|
42826
|
-
function
|
|
42495
|
+
function _isCliEntry29() {
|
|
42827
42496
|
if (process20.argv[1] === void 0) return false;
|
|
42828
|
-
if (import.meta.url ===
|
|
42497
|
+
if (import.meta.url === pathToFileURL34(path78.resolve(process20.argv[1])).href) return true;
|
|
42829
42498
|
try {
|
|
42830
|
-
return
|
|
42499
|
+
return fs76.realpathSync(_HERE22) === fs76.realpathSync(path78.resolve(process20.argv[1]));
|
|
42831
42500
|
} catch {
|
|
42832
42501
|
return false;
|
|
42833
42502
|
}
|
|
@@ -42840,10 +42509,10 @@ var init_report_conformance_funnel = __esm({
|
|
|
42840
42509
|
init_report_carrier_divergence();
|
|
42841
42510
|
init_report_skill_activation();
|
|
42842
42511
|
init_report_skill_obligation_violations();
|
|
42843
|
-
_HERE22 =
|
|
42844
|
-
REPO_ROOT10 =
|
|
42845
|
-
if (
|
|
42846
|
-
process20.exit(
|
|
42512
|
+
_HERE22 = fileURLToPath44(import.meta.url);
|
|
42513
|
+
REPO_ROOT10 = path78.resolve(path78.dirname(_HERE22), "..", "..");
|
|
42514
|
+
if (_isCliEntry29()) {
|
|
42515
|
+
process20.exit(main34());
|
|
42847
42516
|
}
|
|
42848
42517
|
}
|
|
42849
42518
|
});
|
|
@@ -42864,16 +42533,16 @@ __export(cmd_conformance_exports, {
|
|
|
42864
42533
|
conformanceLogPath: () => conformanceLogPath,
|
|
42865
42534
|
detectSmokePlatform: () => detectSmokePlatform,
|
|
42866
42535
|
installLogPath: () => installLogPath,
|
|
42867
|
-
main: () =>
|
|
42536
|
+
main: () => main35,
|
|
42868
42537
|
routeTargetPaths: () => routeTargetPaths,
|
|
42869
42538
|
runConformanceChecks: () => runConformanceChecks
|
|
42870
42539
|
});
|
|
42871
|
-
import * as
|
|
42540
|
+
import * as fs77 from "node:fs";
|
|
42872
42541
|
import * as os20 from "node:os";
|
|
42873
|
-
import * as
|
|
42542
|
+
import * as path79 from "node:path";
|
|
42874
42543
|
import process21 from "node:process";
|
|
42875
42544
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
42876
|
-
import { fileURLToPath as
|
|
42545
|
+
import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL35 } from "node:url";
|
|
42877
42546
|
function print3(s = "") {
|
|
42878
42547
|
process21.stdout.write(`${s}
|
|
42879
42548
|
`);
|
|
@@ -42887,17 +42556,17 @@ function conformanceLogPath() {
|
|
|
42887
42556
|
if (override && override.trim().length > 0) {
|
|
42888
42557
|
return override;
|
|
42889
42558
|
}
|
|
42890
|
-
return
|
|
42559
|
+
return path79.join(os20.homedir(), ".event4u", "agent-config", "conformance-log.jsonl");
|
|
42891
42560
|
}
|
|
42892
42561
|
function installLogPath() {
|
|
42893
42562
|
const override = process21.env["AGENT_CONFIG_INSTALL_LOG"];
|
|
42894
42563
|
if (override && override.trim().length > 0) {
|
|
42895
42564
|
return override;
|
|
42896
42565
|
}
|
|
42897
|
-
return
|
|
42566
|
+
return path79.join(os20.homedir(), ".event4u", "agent-config", "install-log.jsonl");
|
|
42898
42567
|
}
|
|
42899
42568
|
function _check_txlog_clean(logPath = installLogPath()) {
|
|
42900
|
-
if (!
|
|
42569
|
+
if (!fs77.existsSync(logPath)) {
|
|
42901
42570
|
return {
|
|
42902
42571
|
id: "txlog-clean",
|
|
42903
42572
|
status: "ok",
|
|
@@ -42931,11 +42600,11 @@ function _check_txlog_clean(logPath = installLogPath()) {
|
|
|
42931
42600
|
};
|
|
42932
42601
|
}
|
|
42933
42602
|
function routeTargetPaths(target) {
|
|
42934
|
-
return routeTargetPathsPosix(target).map((rel) =>
|
|
42603
|
+
return routeTargetPathsPosix(target).map((rel) => path79.join(...rel.split("/")));
|
|
42935
42604
|
}
|
|
42936
42605
|
function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
|
|
42937
|
-
const routerPath =
|
|
42938
|
-
if (!
|
|
42606
|
+
const routerPath = path79.join(packageRoot, "dist", "router.json");
|
|
42607
|
+
if (!fs77.existsSync(routerPath)) {
|
|
42939
42608
|
return {
|
|
42940
42609
|
id: "router-pointers",
|
|
42941
42610
|
status: "fail",
|
|
@@ -42945,7 +42614,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
|
|
|
42945
42614
|
}
|
|
42946
42615
|
let router;
|
|
42947
42616
|
try {
|
|
42948
|
-
router = JSON.parse(
|
|
42617
|
+
router = JSON.parse(fs77.readFileSync(routerPath, "utf8"));
|
|
42949
42618
|
} catch (exc) {
|
|
42950
42619
|
return {
|
|
42951
42620
|
id: "router-pointers",
|
|
@@ -42954,13 +42623,13 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
|
|
|
42954
42623
|
remedy: "reinstall the package \u2014 dist/router.json is corrupt"
|
|
42955
42624
|
};
|
|
42956
42625
|
}
|
|
42957
|
-
const rulesDir =
|
|
42626
|
+
const rulesDir = path79.join(packageRoot, "dist", "agent-src", "rules");
|
|
42958
42627
|
const broken = [];
|
|
42959
42628
|
let ids = 0;
|
|
42960
42629
|
let targets = 0;
|
|
42961
42630
|
for (const kernelId of router["kernel"] ?? []) {
|
|
42962
42631
|
ids += 1;
|
|
42963
|
-
if (!
|
|
42632
|
+
if (!fs77.existsSync(path79.join(rulesDir, `${kernelId}.md`))) {
|
|
42964
42633
|
broken.push(`kernel:${kernelId} \u2192 rules/${kernelId}.md missing`);
|
|
42965
42634
|
}
|
|
42966
42635
|
}
|
|
@@ -42968,7 +42637,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
|
|
|
42968
42637
|
for (const entry of router[tier] ?? []) {
|
|
42969
42638
|
const ruleId = String(entry["id"] ?? "");
|
|
42970
42639
|
ids += 1;
|
|
42971
|
-
if (!
|
|
42640
|
+
if (!fs77.existsSync(path79.join(rulesDir, `${ruleId}.md`))) {
|
|
42972
42641
|
broken.push(`${tier}:${ruleId} \u2192 rules/${ruleId}.md missing`);
|
|
42973
42642
|
}
|
|
42974
42643
|
for (const target of entry["routes_to"] ?? []) {
|
|
@@ -42978,7 +42647,7 @@ function _check_router_pointers(packageRoot = PACKAGE_ROOT2) {
|
|
|
42978
42647
|
broken.push(`${ruleId} \u2192 unparseable routes_to ${JSON.stringify(target)}`);
|
|
42979
42648
|
continue;
|
|
42980
42649
|
}
|
|
42981
|
-
if (!candidates.some((rel) =>
|
|
42650
|
+
if (!candidates.some((rel) => fs77.existsSync(path79.join(packageRoot, rel)))) {
|
|
42982
42651
|
broken.push(`${ruleId} \u2192 ${target} (${candidates[0]} missing)`);
|
|
42983
42652
|
}
|
|
42984
42653
|
}
|
|
@@ -43010,9 +42679,9 @@ function detectSmokePlatform(projectRoot) {
|
|
|
43010
42679
|
return "claude";
|
|
43011
42680
|
}
|
|
43012
42681
|
function dispatcherRunner(packageRoot) {
|
|
43013
|
-
const localTsx =
|
|
43014
|
-
const script =
|
|
43015
|
-
if (
|
|
42682
|
+
const localTsx = path79.join(packageRoot, "node_modules", ".bin", "tsx");
|
|
42683
|
+
const script = path79.join(packageRoot, "src", "scripts", "hooks", "dispatch_hook.ts");
|
|
42684
|
+
if (fs77.existsSync(localTsx)) {
|
|
43016
42685
|
return [localTsx, script];
|
|
43017
42686
|
}
|
|
43018
42687
|
return ["npx", "tsx", script];
|
|
@@ -43062,12 +42731,12 @@ function _check_hook_dispatcher(projectRoot, packageRoot = PACKAGE_ROOT2, opts =
|
|
|
43062
42731
|
};
|
|
43063
42732
|
}
|
|
43064
42733
|
function readSettingsMode(projectRoot) {
|
|
43065
|
-
const settingsPath =
|
|
43066
|
-
if (!
|
|
42734
|
+
const settingsPath = path79.join(projectRoot, ".agent-settings.yml");
|
|
42735
|
+
if (!fs77.existsSync(settingsPath)) {
|
|
43067
42736
|
return "eager-all";
|
|
43068
42737
|
}
|
|
43069
42738
|
try {
|
|
43070
|
-
const parsed = YAML7.parse(
|
|
42739
|
+
const parsed = YAML7.parse(fs77.readFileSync(settingsPath, "utf8"));
|
|
43071
42740
|
const lean = parsed?.["lean_projection"] ?? null;
|
|
43072
42741
|
const mode = lean?.["mode"];
|
|
43073
42742
|
return typeof mode === "string" && mode.length > 0 ? mode : "eager-all";
|
|
@@ -43078,7 +42747,7 @@ function readSettingsMode(projectRoot) {
|
|
|
43078
42747
|
function kernelIdsFromRouter(packageRoot) {
|
|
43079
42748
|
try {
|
|
43080
42749
|
const router = JSON.parse(
|
|
43081
|
-
|
|
42750
|
+
fs77.readFileSync(path79.join(packageRoot, "dist", "router.json"), "utf8")
|
|
43082
42751
|
);
|
|
43083
42752
|
return new Set((router["kernel"] ?? []).map(String));
|
|
43084
42753
|
} catch {
|
|
@@ -43095,8 +42764,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
|
|
|
43095
42764
|
remedy: "set lean_projection.mode to 'eager-all' or 'thin' in .agent-settings.yml"
|
|
43096
42765
|
};
|
|
43097
42766
|
}
|
|
43098
|
-
const rulesDir = projectedRulesDir ??
|
|
43099
|
-
if (!
|
|
42767
|
+
const rulesDir = projectedRulesDir ?? path79.join(projectRoot, ".augment", "rules");
|
|
42768
|
+
if (!fs77.existsSync(rulesDir)) {
|
|
43100
42769
|
return {
|
|
43101
42770
|
id: "lean-projection",
|
|
43102
42771
|
status: "skipped",
|
|
@@ -43105,7 +42774,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
|
|
|
43105
42774
|
};
|
|
43106
42775
|
}
|
|
43107
42776
|
const kernel = kernelIdsFromRouter(packageRoot);
|
|
43108
|
-
const files =
|
|
42777
|
+
const files = fs77.readdirSync(rulesDir).filter((f) => f.endsWith(".md") && f !== "INDEX.md").sort();
|
|
43109
42778
|
const nonKernel = files.filter((f) => !kernel.has(f.replace(/\.md$/, "")));
|
|
43110
42779
|
if (nonKernel.length === 0) {
|
|
43111
42780
|
return {
|
|
@@ -43119,7 +42788,7 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
|
|
|
43119
42788
|
for (const f of nonKernel) {
|
|
43120
42789
|
let text = "";
|
|
43121
42790
|
try {
|
|
43122
|
-
text =
|
|
42791
|
+
text = fs77.readFileSync(path79.join(rulesDir, f), "utf8");
|
|
43123
42792
|
} catch {
|
|
43124
42793
|
continue;
|
|
43125
42794
|
}
|
|
@@ -43150,8 +42819,8 @@ function _check_lean_projection(projectRoot, packageRoot = PACKAGE_ROOT2, projec
|
|
|
43150
42819
|
function _check_host_manifest(projectRoot) {
|
|
43151
42820
|
const detected = Object.entries(detectToolPresence(projectRoot)).filter(([, v]) => v === true).map(([k]) => k);
|
|
43152
42821
|
const detectedNote = detected.length > 0 ? `detected surfaces: ${detected.join(", ")}` : "no surfaces detected";
|
|
43153
|
-
const settingsPath =
|
|
43154
|
-
if (!
|
|
42822
|
+
const settingsPath = path79.join(projectRoot, ".agent-settings.yml");
|
|
42823
|
+
if (!fs77.existsSync(settingsPath)) {
|
|
43155
42824
|
return {
|
|
43156
42825
|
id: "host-manifest",
|
|
43157
42826
|
status: "ok",
|
|
@@ -43161,7 +42830,7 @@ function _check_host_manifest(projectRoot) {
|
|
|
43161
42830
|
}
|
|
43162
42831
|
let parsed = null;
|
|
43163
42832
|
try {
|
|
43164
|
-
parsed = YAML7.parse(
|
|
42833
|
+
parsed = YAML7.parse(fs77.readFileSync(settingsPath, "utf8"));
|
|
43165
42834
|
} catch (exc) {
|
|
43166
42835
|
return {
|
|
43167
42836
|
id: "host-manifest",
|
|
@@ -43259,7 +42928,7 @@ function _parse4(argv) {
|
|
|
43259
42928
|
}
|
|
43260
42929
|
return opts;
|
|
43261
42930
|
}
|
|
43262
|
-
function
|
|
42931
|
+
function main35(argv = null) {
|
|
43263
42932
|
const opts = _parse4(argv !== null ? Array.from(argv) : process21.argv.slice(2));
|
|
43264
42933
|
if (opts.funnel) {
|
|
43265
42934
|
print3(render6(buildFunnel()));
|
|
@@ -43330,17 +42999,17 @@ function main36(argv = null) {
|
|
|
43330
42999
|
}
|
|
43331
43000
|
return failed ? 1 : 0;
|
|
43332
43001
|
}
|
|
43333
|
-
function
|
|
43002
|
+
function _isCliEntry30() {
|
|
43334
43003
|
if (process21.argv[1] === void 0) {
|
|
43335
43004
|
return false;
|
|
43336
43005
|
}
|
|
43337
|
-
const argvUrl =
|
|
43006
|
+
const argvUrl = pathToFileURL35(path79.resolve(process21.argv[1])).href;
|
|
43338
43007
|
if (import.meta.url === argvUrl) {
|
|
43339
43008
|
return true;
|
|
43340
43009
|
}
|
|
43341
43010
|
try {
|
|
43342
|
-
const here =
|
|
43343
|
-
const argv =
|
|
43011
|
+
const here = fs77.realpathSync(fileURLToPath45(import.meta.url));
|
|
43012
|
+
const argv = fs77.realpathSync(path79.resolve(process21.argv[1]));
|
|
43344
43013
|
return here === argv;
|
|
43345
43014
|
} catch {
|
|
43346
43015
|
return false;
|
|
@@ -43359,7 +43028,7 @@ var init_cmd_conformance = __esm({
|
|
|
43359
43028
|
init_router_target_paths();
|
|
43360
43029
|
init_report_conformance_funnel();
|
|
43361
43030
|
init_cmd_doctor();
|
|
43362
|
-
_HERE23 =
|
|
43031
|
+
_HERE23 = fileURLToPath45(import.meta.url);
|
|
43363
43032
|
PACKAGE_ROOT2 = resolvePackageRoot(import.meta.url);
|
|
43364
43033
|
CONFORMANCE_CHECK_IDS = [
|
|
43365
43034
|
"txlog-clean",
|
|
@@ -43370,9 +43039,9 @@ var init_cmd_conformance = __esm({
|
|
|
43370
43039
|
];
|
|
43371
43040
|
THIN_STUB_MARKER = "Routed rule \u2014 load the body on trigger-match";
|
|
43372
43041
|
USAGE3 = "usage: agent-config conformance [-h] [--project PROJECT] [--json]\n [--skip-dispatcher] [--funnel]\n";
|
|
43373
|
-
if (
|
|
43042
|
+
if (_isCliEntry30() || process21.argv[1] === _HERE23) {
|
|
43374
43043
|
try {
|
|
43375
|
-
process21.exitCode =
|
|
43044
|
+
process21.exitCode = main35(process21.argv.slice(2));
|
|
43376
43045
|
} catch (e) {
|
|
43377
43046
|
if (e instanceof ArgparseExit4) {
|
|
43378
43047
|
process21.exitCode = e.code;
|
|
@@ -43407,7 +43076,7 @@ __export(settings_exports, {
|
|
|
43407
43076
|
read_tier_usage_settings: () => read_tier_usage_settings
|
|
43408
43077
|
});
|
|
43409
43078
|
import { createRequire as createRequire6 } from "node:module";
|
|
43410
|
-
import * as
|
|
43079
|
+
import * as fs78 from "node:fs";
|
|
43411
43080
|
function _isPlainObject8(v) {
|
|
43412
43081
|
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
|
|
43413
43082
|
}
|
|
@@ -43444,7 +43113,7 @@ function _coerce_path(value, def) {
|
|
|
43444
43113
|
}
|
|
43445
43114
|
function _isFile14(p) {
|
|
43446
43115
|
try {
|
|
43447
|
-
return
|
|
43116
|
+
return fs78.statSync(p).isFile();
|
|
43448
43117
|
} catch {
|
|
43449
43118
|
return false;
|
|
43450
43119
|
}
|
|
@@ -43455,7 +43124,7 @@ function _read_telemetry_section(p, key) {
|
|
|
43455
43124
|
}
|
|
43456
43125
|
let raw = {};
|
|
43457
43126
|
try {
|
|
43458
|
-
raw = YAML8.parse(
|
|
43127
|
+
raw = YAML8.parse(fs78.readFileSync(p, "utf-8"), { version: "1.1" });
|
|
43459
43128
|
if (raw === null || raw === void 0) {
|
|
43460
43129
|
raw = {};
|
|
43461
43130
|
}
|
|
@@ -44099,7 +43768,7 @@ __export(aggregator_exports, {
|
|
|
44099
43768
|
aggregate: () => aggregate2,
|
|
44100
43769
|
rank_artefacts: () => rank_artefacts
|
|
44101
43770
|
});
|
|
44102
|
-
import * as
|
|
43771
|
+
import * as fs79 from "node:fs";
|
|
44103
43772
|
function _key(kind, artId) {
|
|
44104
43773
|
return `${kind}\0${artId}`;
|
|
44105
43774
|
}
|
|
@@ -44136,7 +43805,7 @@ function* _iter_events(log_path) {
|
|
|
44136
43805
|
if (!_isFile15(log_path)) {
|
|
44137
43806
|
return;
|
|
44138
43807
|
}
|
|
44139
|
-
const text =
|
|
43808
|
+
const text = fs79.readFileSync(log_path, "utf-8");
|
|
44140
43809
|
const lines = _pyFileLines(text);
|
|
44141
43810
|
let lineNo = 0;
|
|
44142
43811
|
for (const line of lines) {
|
|
@@ -44170,7 +43839,7 @@ function _pyFileLines(text) {
|
|
|
44170
43839
|
}
|
|
44171
43840
|
function _isFile15(p) {
|
|
44172
43841
|
try {
|
|
44173
|
-
return
|
|
43842
|
+
return fs79.statSync(p).isFile();
|
|
44174
43843
|
} catch {
|
|
44175
43844
|
return false;
|
|
44176
43845
|
}
|
|
@@ -44684,7 +44353,7 @@ var init_report_renderer = __esm({
|
|
|
44684
44353
|
});
|
|
44685
44354
|
|
|
44686
44355
|
// src/scripts/ai_council/bundler.ts
|
|
44687
|
-
import * as
|
|
44356
|
+
import * as fs80 from "node:fs";
|
|
44688
44357
|
function _context(mode, text, manifest = [], excluded = []) {
|
|
44689
44358
|
return { mode, text, manifest, excluded };
|
|
44690
44359
|
}
|
|
@@ -44742,10 +44411,10 @@ function bundle_prompt(text) {
|
|
|
44742
44411
|
return _context("prompt", _enforceSize(redacted, "prompt"), ["<inline prompt>"]);
|
|
44743
44412
|
}
|
|
44744
44413
|
function bundle_roadmap(p) {
|
|
44745
|
-
if (!
|
|
44414
|
+
if (!fs80.existsSync(p)) {
|
|
44746
44415
|
throw new FileNotFoundError2(`Roadmap not found: ${p}`);
|
|
44747
44416
|
}
|
|
44748
|
-
const raw =
|
|
44417
|
+
const raw = fs80.readFileSync(p, { encoding: "utf-8" });
|
|
44749
44418
|
const redacted = redact(raw);
|
|
44750
44419
|
return _context(
|
|
44751
44420
|
"roadmap",
|
|
@@ -44923,8 +44592,8 @@ function aggregate_scores(findings, scores) {
|
|
|
44923
44592
|
by_id.get(s.finding_id).push(s);
|
|
44924
44593
|
}
|
|
44925
44594
|
const out = /* @__PURE__ */ new Map();
|
|
44926
|
-
for (const [fid,
|
|
44927
|
-
if (
|
|
44595
|
+
for (const [fid, fs94] of by_id) {
|
|
44596
|
+
if (fs94.length === 0) {
|
|
44928
44597
|
out.set(
|
|
44929
44598
|
fid,
|
|
44930
44599
|
new ConsensusMetadata({
|
|
@@ -44940,13 +44609,13 @@ function aggregate_scores(findings, scores) {
|
|
|
44940
44609
|
);
|
|
44941
44610
|
continue;
|
|
44942
44611
|
}
|
|
44943
|
-
const mean2 =
|
|
44944
|
-
const agree_rate =
|
|
44612
|
+
const mean2 = fs94.reduce((acc, s) => acc + s.score, 0) / fs94.length;
|
|
44613
|
+
const agree_rate = fs94.filter((s) => s.agree).length / fs94.length;
|
|
44945
44614
|
const strength = mean2 / 10 * agree_rate;
|
|
44946
|
-
const dissent =
|
|
44947
|
-
const concur =
|
|
44948
|
-
const scorers =
|
|
44949
|
-
const dissent_reasons =
|
|
44615
|
+
const dissent = fs94.filter((s) => !s.agree).length;
|
|
44616
|
+
const concur = fs94.filter((s) => s.agree).length;
|
|
44617
|
+
const scorers = fs94.map((s) => s.scorer);
|
|
44618
|
+
const dissent_reasons = fs94.filter((s) => !s.agree).map((s) => [s.scorer, s.reason]);
|
|
44950
44619
|
const mean_rounded = pyRound(mean2, 2);
|
|
44951
44620
|
out.set(
|
|
44952
44621
|
fid,
|
|
@@ -45386,26 +45055,26 @@ One sentence, and the single strongest reason.`;
|
|
|
45386
45055
|
});
|
|
45387
45056
|
|
|
45388
45057
|
// src/scripts/ai_council/recouncil_guard.ts
|
|
45389
|
-
import * as
|
|
45390
|
-
import * as
|
|
45058
|
+
import * as fs81 from "node:fs";
|
|
45059
|
+
import * as path80 from "node:path";
|
|
45391
45060
|
function configFingerprint(members, rounds) {
|
|
45392
45061
|
return `${[...members].sort().join(",")}|rounds=${String(rounds)}`;
|
|
45393
45062
|
}
|
|
45394
45063
|
function readPriorRuns(responsesDir, repoRoot) {
|
|
45395
45064
|
let names;
|
|
45396
45065
|
try {
|
|
45397
|
-
names =
|
|
45066
|
+
names = fs81.readdirSync(responsesDir).filter((f) => f.endsWith(".md"));
|
|
45398
45067
|
} catch {
|
|
45399
45068
|
return [];
|
|
45400
45069
|
}
|
|
45401
45070
|
const out = [];
|
|
45402
45071
|
for (const name of names) {
|
|
45403
|
-
const abs =
|
|
45072
|
+
const abs = path80.join(responsesDir, name);
|
|
45404
45073
|
let head;
|
|
45405
45074
|
let stat;
|
|
45406
45075
|
try {
|
|
45407
|
-
stat =
|
|
45408
|
-
const text =
|
|
45076
|
+
stat = fs81.statSync(abs);
|
|
45077
|
+
const text = fs81.readFileSync(abs, "utf8");
|
|
45409
45078
|
const json = _leadingJson(text);
|
|
45410
45079
|
if (json === null) continue;
|
|
45411
45080
|
head = JSON.parse(json);
|
|
@@ -45419,7 +45088,7 @@ function readPriorRuns(responsesDir, repoRoot) {
|
|
|
45419
45088
|
let questionText = null;
|
|
45420
45089
|
if (questionPath !== "") {
|
|
45421
45090
|
try {
|
|
45422
|
-
const q =
|
|
45091
|
+
const q = fs81.readFileSync(path80.join(repoRoot, questionPath), "utf8");
|
|
45423
45092
|
questionHash = _sha256_hex(q);
|
|
45424
45093
|
questionText = q;
|
|
45425
45094
|
} catch {
|
|
@@ -45500,14 +45169,14 @@ function warnIfRecounciled(repoRoot, questionFile, fallbackText, members, rounds
|
|
|
45500
45169
|
try {
|
|
45501
45170
|
let text = fallbackText;
|
|
45502
45171
|
try {
|
|
45503
|
-
text =
|
|
45172
|
+
text = fs81.readFileSync(path80.resolve(repoRoot, questionFile), "utf8");
|
|
45504
45173
|
} catch {
|
|
45505
45174
|
}
|
|
45506
45175
|
const v = checkRecouncil(
|
|
45507
45176
|
text,
|
|
45508
45177
|
// `name/model` — the SAME shape the artefact writer records.
|
|
45509
45178
|
configFingerprint(members.map((m) => `${m.name}/${m.model}`), rounds),
|
|
45510
|
-
readPriorRuns(
|
|
45179
|
+
readPriorRuns(path80.join(repoRoot, "agents/runtime/council/responses"), repoRoot)
|
|
45511
45180
|
);
|
|
45512
45181
|
if (v !== null) write(renderRecouncilWarning(v));
|
|
45513
45182
|
} catch {
|
|
@@ -46107,8 +45776,8 @@ not. Cite the peer-reviewer label and the targeted response label
|
|
|
46107
45776
|
});
|
|
46108
45777
|
|
|
46109
45778
|
// src/scripts/ai_council/advisors.ts
|
|
46110
|
-
import * as
|
|
46111
|
-
import * as
|
|
45779
|
+
import * as fs82 from "node:fs";
|
|
45780
|
+
import * as path81 from "node:path";
|
|
46112
45781
|
function _split_frontmatter2(raw) {
|
|
46113
45782
|
const match = _FRONTMATTER_RE2.exec(raw);
|
|
46114
45783
|
if (!match) {
|
|
@@ -46136,12 +45805,12 @@ function _display_name_from(advisor_name, frontmatter) {
|
|
|
46136
45805
|
}
|
|
46137
45806
|
function resolve_persona_text(persona_path, repo_root2) {
|
|
46138
45807
|
const candidates = [
|
|
46139
|
-
|
|
46140
|
-
|
|
45808
|
+
path81.join(repo_root2, "dist/agent-src", persona_path),
|
|
45809
|
+
path81.join(repo_root2, ".agent-src.uncondensed", persona_path)
|
|
46141
45810
|
];
|
|
46142
45811
|
for (const candidate of candidates) {
|
|
46143
|
-
if (
|
|
46144
|
-
const raw =
|
|
45812
|
+
if (fs82.existsSync(candidate)) {
|
|
45813
|
+
const raw = fs82.readFileSync(candidate, "utf-8");
|
|
46145
45814
|
const [meta, body] = _split_frontmatter2(raw);
|
|
46146
45815
|
return [body.trim(), meta];
|
|
46147
45816
|
}
|
|
@@ -46737,15 +46406,15 @@ var init_qualification = __esm({
|
|
|
46737
46406
|
});
|
|
46738
46407
|
|
|
46739
46408
|
// src/scripts/ai_council/probe_store.ts
|
|
46740
|
-
import
|
|
46741
|
-
import
|
|
46409
|
+
import fs83 from "node:fs";
|
|
46410
|
+
import path82 from "node:path";
|
|
46742
46411
|
function probeStorePath(root) {
|
|
46743
|
-
return
|
|
46412
|
+
return path82.join(root, PROBE_STORE_RELPATH);
|
|
46744
46413
|
}
|
|
46745
46414
|
function readProbeStore(root) {
|
|
46746
46415
|
let raw;
|
|
46747
46416
|
try {
|
|
46748
|
-
raw =
|
|
46417
|
+
raw = fs83.readFileSync(probeStorePath(root), "utf8");
|
|
46749
46418
|
} catch {
|
|
46750
46419
|
return EMPTY;
|
|
46751
46420
|
}
|
|
@@ -46795,8 +46464,8 @@ function recordProbes(root, entries) {
|
|
|
46795
46464
|
members[e.name] = { at: e.at, outcome: e.outcome };
|
|
46796
46465
|
}
|
|
46797
46466
|
const target = probeStorePath(root);
|
|
46798
|
-
|
|
46799
|
-
|
|
46467
|
+
fs83.mkdirSync(path82.dirname(target), { recursive: true });
|
|
46468
|
+
fs83.writeFileSync(target, `${JSON.stringify({ schema: 1, members }, null, 2)}
|
|
46800
46469
|
`, "utf8");
|
|
46801
46470
|
} catch {
|
|
46802
46471
|
}
|
|
@@ -46810,7 +46479,7 @@ var init_probe_store = __esm({
|
|
|
46810
46479
|
"use strict";
|
|
46811
46480
|
init_env_kill_switch();
|
|
46812
46481
|
_KILL_SWITCH_ENV2 = "AGENT_CONFIG_NO_EVENTS_LOG";
|
|
46813
|
-
PROBE_STORE_RELPATH =
|
|
46482
|
+
PROBE_STORE_RELPATH = path82.join("agents", "runtime", "state", "council-probes.json");
|
|
46814
46483
|
EMPTY = { schema: 1, members: {} };
|
|
46815
46484
|
VALID_OUTCOMES = /* @__PURE__ */ new Set([
|
|
46816
46485
|
"ok",
|
|
@@ -47114,10 +46783,10 @@ var init_council_fallback_posture = __esm({
|
|
|
47114
46783
|
});
|
|
47115
46784
|
|
|
47116
46785
|
// src/scripts/_lib/billing_grant.ts
|
|
47117
|
-
import * as
|
|
47118
|
-
import * as
|
|
46786
|
+
import * as fs84 from "node:fs";
|
|
46787
|
+
import * as path83 from "node:path";
|
|
47119
46788
|
function grantFile(repoRoot, runId) {
|
|
47120
|
-
return
|
|
46789
|
+
return path83.join(
|
|
47121
46790
|
repoRoot,
|
|
47122
46791
|
BILLING_GRANT_DIR_REL,
|
|
47123
46792
|
`${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
|
|
@@ -47128,8 +46797,8 @@ function issueBillingGrant(repoRoot, runId, now = () => /* @__PURE__ */ new Date
|
|
|
47128
46797
|
const existing = _read(file);
|
|
47129
46798
|
if (existing !== null && existing.run_id === runId) return existing;
|
|
47130
46799
|
const grant = { run_id: runId, issued_at: now().toISOString() };
|
|
47131
|
-
|
|
47132
|
-
|
|
46800
|
+
fs84.mkdirSync(path83.dirname(file), { recursive: true });
|
|
46801
|
+
fs84.writeFileSync(file, `${JSON.stringify(grant, null, 2)}
|
|
47133
46802
|
`, "utf8");
|
|
47134
46803
|
return grant;
|
|
47135
46804
|
}
|
|
@@ -47147,13 +46816,13 @@ function hasBillingGrant(repoRoot, env = process.env, now = () => /* @__PURE__ *
|
|
|
47147
46816
|
}
|
|
47148
46817
|
function revokeBillingGrant(repoRoot, runId) {
|
|
47149
46818
|
try {
|
|
47150
|
-
|
|
46819
|
+
fs84.unlinkSync(grantFile(repoRoot, runId));
|
|
47151
46820
|
} catch {
|
|
47152
46821
|
}
|
|
47153
46822
|
}
|
|
47154
46823
|
function _read(file) {
|
|
47155
46824
|
try {
|
|
47156
|
-
const raw = JSON.parse(
|
|
46825
|
+
const raw = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
47157
46826
|
if (raw === null || typeof raw !== "object") return null;
|
|
47158
46827
|
const o = raw;
|
|
47159
46828
|
if (typeof o.run_id !== "string" || typeof o.issued_at !== "string") return null;
|
|
@@ -47174,7 +46843,7 @@ var init_billing_grant = __esm({
|
|
|
47174
46843
|
"src/scripts/_lib/billing_grant.ts"() {
|
|
47175
46844
|
"use strict";
|
|
47176
46845
|
BILLING_GRANT_ENV = "AC_BILLING_GRANT";
|
|
47177
|
-
BILLING_GRANT_DIR_REL =
|
|
46846
|
+
BILLING_GRANT_DIR_REL = path83.join("agents", "runtime", "billing-grants");
|
|
47178
46847
|
BILLING_GRANT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
47179
46848
|
}
|
|
47180
46849
|
});
|
|
@@ -47263,10 +46932,10 @@ var init_council_fallback_wiring = __esm({
|
|
|
47263
46932
|
});
|
|
47264
46933
|
|
|
47265
46934
|
// src/scripts/_lib/quota_parked.ts
|
|
47266
|
-
import * as
|
|
47267
|
-
import * as
|
|
46935
|
+
import * as fs85 from "node:fs";
|
|
46936
|
+
import * as path84 from "node:path";
|
|
47268
46937
|
function markerFile(repoRoot, runId) {
|
|
47269
|
-
return
|
|
46938
|
+
return path84.join(
|
|
47270
46939
|
repoRoot,
|
|
47271
46940
|
QUOTA_PARKED_DIR_REL,
|
|
47272
46941
|
`${runId.replace(/[^A-Za-z0-9_-]/g, "_")}.json`
|
|
@@ -47281,14 +46950,14 @@ function writeQuotaParked(repoRoot, runId, providers, now = () => /* @__PURE__ *
|
|
|
47281
46950
|
providers: merged,
|
|
47282
46951
|
parked_at: existing?.parked_at ?? now().toISOString()
|
|
47283
46952
|
};
|
|
47284
|
-
|
|
47285
|
-
|
|
46953
|
+
fs85.mkdirSync(path84.dirname(file), { recursive: true });
|
|
46954
|
+
fs85.writeFileSync(file, `${JSON.stringify(marker, null, 2)}
|
|
47286
46955
|
`, "utf8");
|
|
47287
46956
|
return marker;
|
|
47288
46957
|
}
|
|
47289
46958
|
function readMarker(file) {
|
|
47290
46959
|
try {
|
|
47291
|
-
const raw = JSON.parse(
|
|
46960
|
+
const raw = JSON.parse(fs85.readFileSync(file, "utf8"));
|
|
47292
46961
|
if (raw === null || typeof raw !== "object") return null;
|
|
47293
46962
|
const o = raw;
|
|
47294
46963
|
if (typeof o["run_id"] !== "string" || typeof o["parked_at"] !== "string") return null;
|
|
@@ -47303,7 +46972,7 @@ var QUOTA_PARKED_DIR_REL;
|
|
|
47303
46972
|
var init_quota_parked = __esm({
|
|
47304
46973
|
"src/scripts/_lib/quota_parked.ts"() {
|
|
47305
46974
|
"use strict";
|
|
47306
|
-
QUOTA_PARKED_DIR_REL =
|
|
46975
|
+
QUOTA_PARKED_DIR_REL = path84.join("agents", "runtime", "state", "quota-parked");
|
|
47307
46976
|
}
|
|
47308
46977
|
});
|
|
47309
46978
|
|
|
@@ -47373,7 +47042,7 @@ __export(low_impact_corpus_exports, {
|
|
|
47373
47042
|
load_validated_phrases: () => load_validated_phrases,
|
|
47374
47043
|
parse_corpus_strict: () => parse_corpus_strict
|
|
47375
47044
|
});
|
|
47376
|
-
import * as
|
|
47045
|
+
import * as fs86 from "node:fs";
|
|
47377
47046
|
function _entry(phrase, normalised, section, line_no, trailing_metadata = "") {
|
|
47378
47047
|
return { phrase, normalised, section, line_no, trailing_metadata };
|
|
47379
47048
|
}
|
|
@@ -47546,10 +47215,10 @@ function _checkHeadingDrift(text, title) {
|
|
|
47546
47215
|
}
|
|
47547
47216
|
function parse_corpus_strict(corpusPath) {
|
|
47548
47217
|
const p = corpusPath;
|
|
47549
|
-
if (!
|
|
47218
|
+
if (!fs86.existsSync(p)) {
|
|
47550
47219
|
return new CorpusParseResult();
|
|
47551
47220
|
}
|
|
47552
|
-
const text =
|
|
47221
|
+
const text = fs86.readFileSync(p, { encoding: "utf-8" });
|
|
47553
47222
|
const allTitles = _SECTION_KEYS.map((k) => _SECTION_TITLES[k]);
|
|
47554
47223
|
const resultSections = {
|
|
47555
47224
|
validated: [],
|
|
@@ -47612,10 +47281,10 @@ function load_anti_example_phrases(corpusPath) {
|
|
|
47612
47281
|
}
|
|
47613
47282
|
function load_corpus_lock(yamlPath) {
|
|
47614
47283
|
const p = yamlPath;
|
|
47615
|
-
if (!
|
|
47284
|
+
if (!fs86.existsSync(p)) {
|
|
47616
47285
|
return new CorpusParseResult();
|
|
47617
47286
|
}
|
|
47618
|
-
const parsed = (0, import_yaml8.parse)(
|
|
47287
|
+
const parsed = (0, import_yaml8.parse)(fs86.readFileSync(p, { encoding: "utf-8" }), { version: "1.1" });
|
|
47619
47288
|
const doc = parsed === null || parsed === void 0 ? {} : parsed;
|
|
47620
47289
|
const schemaVersion = doc["schema_version"];
|
|
47621
47290
|
if (schemaVersion !== 1) {
|
|
@@ -47677,7 +47346,7 @@ function _deriveLockPath(corpusPath) {
|
|
|
47677
47346
|
}
|
|
47678
47347
|
function _loadSectionFromLock(corpusPath, section) {
|
|
47679
47348
|
const lockPath = _deriveLockPath(corpusPath);
|
|
47680
|
-
if (!
|
|
47349
|
+
if (!fs86.existsSync(lockPath)) {
|
|
47681
47350
|
return null;
|
|
47682
47351
|
}
|
|
47683
47352
|
try {
|
|
@@ -47689,10 +47358,10 @@ function _loadSectionFromLock(corpusPath, section) {
|
|
|
47689
47358
|
}
|
|
47690
47359
|
function _loadSectionLenient(corpusPath, section) {
|
|
47691
47360
|
const p = corpusPath;
|
|
47692
|
-
if (!
|
|
47361
|
+
if (!fs86.existsSync(p)) {
|
|
47693
47362
|
return [];
|
|
47694
47363
|
}
|
|
47695
|
-
const text =
|
|
47364
|
+
const text = fs86.readFileSync(p, { encoding: "utf-8" });
|
|
47696
47365
|
const allTitles = _SECTION_KEYS.map((k) => _SECTION_TITLES[k]);
|
|
47697
47366
|
const bounds = _sectionBounds(text, _SECTION_TITLES[section], allTitles);
|
|
47698
47367
|
if (bounds === null) {
|
|
@@ -48820,8 +48489,8 @@ var init_consensus_round = __esm({
|
|
|
48820
48489
|
});
|
|
48821
48490
|
|
|
48822
48491
|
// src/scripts/ai_council/budget_guard.ts
|
|
48823
|
-
import * as
|
|
48824
|
-
import * as
|
|
48492
|
+
import * as fs87 from "node:fs";
|
|
48493
|
+
import * as path85 from "node:path";
|
|
48825
48494
|
function _resolveLedgerPath(p) {
|
|
48826
48495
|
if (p !== null) {
|
|
48827
48496
|
return p;
|
|
@@ -48836,18 +48505,18 @@ function _nowUtcMs() {
|
|
|
48836
48505
|
return Date.now();
|
|
48837
48506
|
}
|
|
48838
48507
|
function _ensureLedgerDir(p) {
|
|
48839
|
-
const parent =
|
|
48508
|
+
const parent = path85.dirname(p);
|
|
48840
48509
|
try {
|
|
48841
|
-
|
|
48510
|
+
fs87.mkdirSync(parent, { recursive: true });
|
|
48842
48511
|
let mode;
|
|
48843
48512
|
try {
|
|
48844
|
-
mode =
|
|
48513
|
+
mode = fs87.statSync(parent).mode & 511;
|
|
48845
48514
|
} catch {
|
|
48846
48515
|
mode = 448;
|
|
48847
48516
|
}
|
|
48848
48517
|
if (mode !== 448) {
|
|
48849
48518
|
try {
|
|
48850
|
-
|
|
48519
|
+
fs87.chmodSync(parent, 448);
|
|
48851
48520
|
} catch {
|
|
48852
48521
|
}
|
|
48853
48522
|
}
|
|
@@ -48859,18 +48528,18 @@ function _ensureLedgerDir(p) {
|
|
|
48859
48528
|
}
|
|
48860
48529
|
}
|
|
48861
48530
|
function _ensureLedgerFileMode(p) {
|
|
48862
|
-
if (!
|
|
48531
|
+
if (!fs87.existsSync(p)) {
|
|
48863
48532
|
return;
|
|
48864
48533
|
}
|
|
48865
48534
|
let current;
|
|
48866
48535
|
try {
|
|
48867
|
-
current =
|
|
48536
|
+
current = fs87.statSync(p).mode & 511;
|
|
48868
48537
|
} catch {
|
|
48869
48538
|
return;
|
|
48870
48539
|
}
|
|
48871
48540
|
if (current !== 384) {
|
|
48872
48541
|
try {
|
|
48873
|
-
|
|
48542
|
+
fs87.chmodSync(p, 384);
|
|
48874
48543
|
} catch {
|
|
48875
48544
|
}
|
|
48876
48545
|
}
|
|
@@ -49022,11 +48691,11 @@ function pyNumToStr(n) {
|
|
|
49022
48691
|
}
|
|
49023
48692
|
function read_entries2(p = null) {
|
|
49024
48693
|
const resolved = _resolveLedgerPath(p);
|
|
49025
|
-
if (!
|
|
48694
|
+
if (!fs87.existsSync(resolved)) {
|
|
49026
48695
|
return [];
|
|
49027
48696
|
}
|
|
49028
48697
|
const out = [];
|
|
49029
|
-
const text =
|
|
48698
|
+
const text = fs87.readFileSync(resolved, "utf-8");
|
|
49030
48699
|
for (const rawLine of text.split(/\r\n|\r|\n/u)) {
|
|
49031
48700
|
const line = rawLine.trim();
|
|
49032
48701
|
if (line === "") {
|
|
@@ -49129,7 +48798,7 @@ function record_spend(usd, provider, model, options = {}) {
|
|
|
49129
48798
|
)}
|
|
49130
48799
|
`;
|
|
49131
48800
|
try {
|
|
49132
|
-
|
|
48801
|
+
fs87.appendFileSync(p, entry, { encoding: "utf-8" });
|
|
49133
48802
|
} catch (exc) {
|
|
49134
48803
|
process.stderr.write(`[council:budget_guard] write failed: ${_errStr(exc)}
|
|
49135
48804
|
`);
|
|
@@ -50820,18 +50489,18 @@ __export(project_context_exports, {
|
|
|
50820
50489
|
REPO_PURPOSE_MAX_CHARS: () => REPO_PURPOSE_MAX_CHARS,
|
|
50821
50490
|
detect_project_context: () => detect_project_context
|
|
50822
50491
|
});
|
|
50823
|
-
import * as
|
|
50824
|
-
import * as
|
|
50492
|
+
import * as fs88 from "node:fs";
|
|
50493
|
+
import * as path86 from "node:path";
|
|
50825
50494
|
function _isPlainObject11(v) {
|
|
50826
50495
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
50827
50496
|
}
|
|
50828
50497
|
function _read_json(p) {
|
|
50829
|
-
if (!
|
|
50498
|
+
if (!fs88.existsSync(p)) {
|
|
50830
50499
|
return null;
|
|
50831
50500
|
}
|
|
50832
50501
|
let raw;
|
|
50833
50502
|
try {
|
|
50834
|
-
raw =
|
|
50503
|
+
raw = fs88.readFileSync(p, "utf-8");
|
|
50835
50504
|
} catch {
|
|
50836
50505
|
return null;
|
|
50837
50506
|
}
|
|
@@ -50853,7 +50522,7 @@ function _name_from(composer, pkg, root) {
|
|
|
50853
50522
|
}
|
|
50854
50523
|
}
|
|
50855
50524
|
try {
|
|
50856
|
-
const base =
|
|
50525
|
+
const base = path86.basename(root);
|
|
50857
50526
|
return base || null;
|
|
50858
50527
|
} catch {
|
|
50859
50528
|
return null;
|
|
@@ -50922,12 +50591,12 @@ function _splitlines10(text) {
|
|
|
50922
50591
|
return parts;
|
|
50923
50592
|
}
|
|
50924
50593
|
function _purpose_from_readme(p) {
|
|
50925
|
-
if (!
|
|
50594
|
+
if (!fs88.existsSync(p)) {
|
|
50926
50595
|
return null;
|
|
50927
50596
|
}
|
|
50928
50597
|
let text;
|
|
50929
50598
|
try {
|
|
50930
|
-
text =
|
|
50599
|
+
text = fs88.readFileSync(p, "utf-8");
|
|
50931
50600
|
} catch {
|
|
50932
50601
|
return null;
|
|
50933
50602
|
}
|
|
@@ -51011,13 +50680,13 @@ function _rfind(haystack, needle) {
|
|
|
51011
50680
|
return -1;
|
|
51012
50681
|
}
|
|
51013
50682
|
function detect_project_context(root) {
|
|
51014
|
-
const resolvedRoot =
|
|
51015
|
-
const composer = _read_json(
|
|
51016
|
-
const pkg = _read_json(
|
|
50683
|
+
const resolvedRoot = path86.resolve(root ?? process.cwd());
|
|
50684
|
+
const composer = _read_json(path86.join(resolvedRoot, "composer.json"));
|
|
50685
|
+
const pkg = _read_json(path86.join(resolvedRoot, "package.json"));
|
|
51017
50686
|
return new ProjectContext(
|
|
51018
50687
|
_name_from(composer, pkg, resolvedRoot),
|
|
51019
50688
|
_stack_from(composer, pkg),
|
|
51020
|
-
_purpose_from_readme(
|
|
50689
|
+
_purpose_from_readme(path86.join(resolvedRoot, "README.md"))
|
|
51021
50690
|
);
|
|
51022
50691
|
}
|
|
51023
50692
|
var REPO_PURPOSE_MAX_CHARS, _HEADING_RE, _BADGE_RE, _HTML_RE, ProjectContext;
|
|
@@ -51287,7 +50956,7 @@ __export(shadow_dispatch_exports, {
|
|
|
51287
50956
|
slo_banner: () => slo_banner,
|
|
51288
50957
|
slo_status: () => slo_status
|
|
51289
50958
|
});
|
|
51290
|
-
import * as
|
|
50959
|
+
import * as fs89 from "node:fs";
|
|
51291
50960
|
import { createHash as createHash14 } from "node:crypto";
|
|
51292
50961
|
function should_shadow(sampleRate, opts = {}) {
|
|
51293
50962
|
const rate = Math.max(0, Math.min(1, sampleRate));
|
|
@@ -51325,7 +50994,7 @@ function record_shadow_decision(logPath, opts) {
|
|
|
51325
50994
|
escalated,
|
|
51326
50995
|
escalation_reason: escalationReason
|
|
51327
50996
|
};
|
|
51328
|
-
|
|
50997
|
+
fs89.mkdirSync(_dirname2(logPath), { recursive: true });
|
|
51329
50998
|
const row = _pyJsonDumps2({
|
|
51330
50999
|
timestamp: decision.timestamp,
|
|
51331
51000
|
query_hash: decision.query_hash,
|
|
@@ -51335,7 +51004,7 @@ function record_shadow_decision(logPath, opts) {
|
|
|
51335
51004
|
escalated: decision.escalated,
|
|
51336
51005
|
escalation_reason: decision.escalation_reason
|
|
51337
51006
|
}) + "\n";
|
|
51338
|
-
|
|
51007
|
+
fs89.appendFileSync(logPath, row, { encoding: "utf-8" });
|
|
51339
51008
|
return decision;
|
|
51340
51009
|
}
|
|
51341
51010
|
function _isoNowSeconds() {
|
|
@@ -51344,10 +51013,10 @@ function _isoNowSeconds() {
|
|
|
51344
51013
|
return `${pad(d.getUTCFullYear(), 4)}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`;
|
|
51345
51014
|
}
|
|
51346
51015
|
function* _iterLog(logPath) {
|
|
51347
|
-
if (!
|
|
51016
|
+
if (!fs89.existsSync(logPath)) {
|
|
51348
51017
|
return;
|
|
51349
51018
|
}
|
|
51350
|
-
const content =
|
|
51019
|
+
const content = fs89.readFileSync(logPath, { encoding: "utf-8" });
|
|
51351
51020
|
for (const rawLine of _splitlines11(content)) {
|
|
51352
51021
|
const line = _strip8(rawLine);
|
|
51353
51022
|
if (!line) {
|
|
@@ -52272,11 +51941,11 @@ __export(council_cli_exports, {
|
|
|
52272
51941
|
cmd_status: () => cmd_status,
|
|
52273
51942
|
format_estimate_table: () => format_estimate_table,
|
|
52274
51943
|
load_settings: () => load_settings,
|
|
52275
|
-
main: () =>
|
|
51944
|
+
main: () => main36
|
|
52276
51945
|
});
|
|
52277
|
-
import * as
|
|
52278
|
-
import * as
|
|
52279
|
-
import { fileURLToPath as
|
|
51946
|
+
import * as fs90 from "node:fs";
|
|
51947
|
+
import * as path87 from "node:path";
|
|
51948
|
+
import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL36 } from "node:url";
|
|
52280
51949
|
function _pyFixed6(x, ndigits) {
|
|
52281
51950
|
if (!Number.isFinite(x)) {
|
|
52282
51951
|
return String(x);
|
|
@@ -52484,7 +52153,7 @@ function _stderr2(s) {
|
|
|
52484
52153
|
function load_settings(p = SETTINGS_FILE2, opts = {}) {
|
|
52485
52154
|
const ai_council_path = opts.ai_council_path ?? AI_COUNCIL_FILE;
|
|
52486
52155
|
const settings = load_agent_settings({ project_path: p });
|
|
52487
|
-
if (
|
|
52156
|
+
if (fs90.existsSync(ai_council_path)) {
|
|
52488
52157
|
const cfg = load_council_config(ai_council_path);
|
|
52489
52158
|
settings["ai_council"] = synthesizeAiCouncilBlock(cfg);
|
|
52490
52159
|
}
|
|
@@ -52850,7 +52519,7 @@ function build_question(opts) {
|
|
|
52850
52519
|
let ctx;
|
|
52851
52520
|
let artefact;
|
|
52852
52521
|
if (input_mode === "prompt") {
|
|
52853
|
-
const text =
|
|
52522
|
+
const text = fs90.readFileSync(input_path, "utf-8");
|
|
52854
52523
|
ctx = bundle_prompt(text);
|
|
52855
52524
|
artefact = String(input_path);
|
|
52856
52525
|
} else if (input_mode === "roadmap") {
|
|
@@ -52994,9 +52663,9 @@ function _maybe_write_decision_replay(opts) {
|
|
|
52994
52663
|
include_member_arguments: include_args
|
|
52995
52664
|
})
|
|
52996
52665
|
);
|
|
52997
|
-
const target =
|
|
52998
|
-
|
|
52999
|
-
|
|
52666
|
+
const target = path87.join(path87.dirname(opts.out_path), "decision-replay.md");
|
|
52667
|
+
fs90.mkdirSync(path87.dirname(target), { recursive: true });
|
|
52668
|
+
fs90.writeFileSync(target, replay, { encoding: "utf-8" });
|
|
53000
52669
|
return target;
|
|
53001
52670
|
}
|
|
53002
52671
|
function _peer_review_active(ai_cfg, args) {
|
|
@@ -53679,7 +53348,7 @@ function cmd_status(args, opts = {}) {
|
|
|
53679
53348
|
const env = opts.env ?? process.env;
|
|
53680
53349
|
const override = env[COUNCIL_CONFIG_ENV];
|
|
53681
53350
|
const path_ = resolve_config_path(REPO_ROOT11, { env });
|
|
53682
|
-
const exists3 =
|
|
53351
|
+
const exists3 = fs90.existsSync(String(path_));
|
|
53683
53352
|
const provenance = override ? `${COUNCIL_CONFIG_ENV} override` : "user-global";
|
|
53684
53353
|
let cfg = null;
|
|
53685
53354
|
let parse_error = null;
|
|
@@ -54135,8 +53804,8 @@ function cmd_run(args, opts = {}) {
|
|
|
54135
53804
|
kind: "responses",
|
|
54136
53805
|
subcommand: "run"
|
|
54137
53806
|
});
|
|
54138
|
-
|
|
54139
|
-
|
|
53807
|
+
fs90.mkdirSync(path87.dirname(_resolveTarget(out_path)), { recursive: true });
|
|
53808
|
+
fs90.writeFileSync(_resolveTarget(out_path), _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
|
|
54140
53809
|
const _all_subscription = allSeatsNonBillable(all_responses);
|
|
54141
53810
|
_stdout2(
|
|
54142
53811
|
`
|
|
@@ -54162,7 +53831,7 @@ function _debate_round_filename(round_number) {
|
|
|
54162
53831
|
return `debate-round-${round_number}.json`;
|
|
54163
53832
|
}
|
|
54164
53833
|
function _write_debate_round(out_dir, round_number, responses, opts) {
|
|
54165
|
-
|
|
53834
|
+
fs90.mkdirSync(_resolveTarget(out_dir), { recursive: true });
|
|
54166
53835
|
const actual_total = sumBillableCost(responses, opts.table);
|
|
54167
53836
|
const payload = {
|
|
54168
53837
|
schema_version: SCHEMA_VERSION8,
|
|
@@ -54179,15 +53848,15 @@ function _write_debate_round(out_dir, round_number, responses, opts) {
|
|
|
54179
53848
|
prompt_cache_round_gap_ms: opts.cache_gap_ms_since_previous_round ?? null,
|
|
54180
53849
|
responses: serializeResponses(responses)
|
|
54181
53850
|
};
|
|
54182
|
-
const out_path =
|
|
54183
|
-
|
|
53851
|
+
const out_path = path87.join(_resolveTarget(out_dir), _debate_round_filename(round_number));
|
|
53852
|
+
fs90.writeFileSync(out_path, _jsonDumpsIndent2(payload) + "\n", { encoding: "utf-8" });
|
|
54184
53853
|
return out_path;
|
|
54185
53854
|
}
|
|
54186
53855
|
function _load_debate_seed(p, expected_members) {
|
|
54187
|
-
if (!
|
|
53856
|
+
if (!fs90.existsSync(p)) {
|
|
54188
53857
|
throw new FileNotFoundError3(`--continue-as-debate path not found: ${p}`);
|
|
54189
53858
|
}
|
|
54190
|
-
const payload = JSON.parse(
|
|
53859
|
+
const payload = JSON.parse(fs90.readFileSync(p, "utf-8"));
|
|
54191
53860
|
const source_members = (payload["members"] || []).slice();
|
|
54192
53861
|
const expected_labels = expected_members.map((m) => `${m.name}/${m.model}`);
|
|
54193
53862
|
if (!_listEq(source_members, expected_labels)) {
|
|
@@ -54233,7 +53902,7 @@ function _readStdinLine() {
|
|
|
54233
53902
|
try {
|
|
54234
53903
|
const buf = Buffer.alloc(4096);
|
|
54235
53904
|
const fd = 0;
|
|
54236
|
-
const n =
|
|
53905
|
+
const n = fs90.readSync(fd, buf, 0, buf.length, null);
|
|
54237
53906
|
return buf.toString("utf-8", 0, n).split("\n")[0]?.trim().toLowerCase() ?? "";
|
|
54238
53907
|
} catch {
|
|
54239
53908
|
return "";
|
|
@@ -54461,7 +54130,7 @@ council:debate \xB7 ${all_rounds.length} round(s) complete \xB7 actual $${_pyFix
|
|
|
54461
54130
|
return errors_last.length > 0 && errors_last.length === last.length ? 1 : 0;
|
|
54462
54131
|
}
|
|
54463
54132
|
function cmd_render(args) {
|
|
54464
|
-
const payload = JSON.parse(
|
|
54133
|
+
const payload = JSON.parse(fs90.readFileSync(args.responses, "utf-8"));
|
|
54465
54134
|
const items = payload["responses"] || [];
|
|
54466
54135
|
const explicit = _getattr3(args, "prompt_mode", null);
|
|
54467
54136
|
const mode = explicit || payload["prompt_mode"] || payload["mode"];
|
|
@@ -54490,8 +54159,8 @@ function cmd_render(args) {
|
|
|
54490
54159
|
kind: "sessions",
|
|
54491
54160
|
subcommand: "render"
|
|
54492
54161
|
});
|
|
54493
|
-
|
|
54494
|
-
|
|
54162
|
+
fs90.mkdirSync(path87.dirname(_resolveTarget(out_path)), { recursive: true });
|
|
54163
|
+
fs90.writeFileSync(_resolveTarget(out_path), body + "\n", { encoding: "utf-8" });
|
|
54495
54164
|
_stdout2(`council:render \xB7 wrote ${out_path}
|
|
54496
54165
|
`);
|
|
54497
54166
|
return 0;
|
|
@@ -54502,15 +54171,15 @@ function cmd_render(args) {
|
|
|
54502
54171
|
function _cmd_replay_low_impact_stats(args) {
|
|
54503
54172
|
const li = low_impact_exports;
|
|
54504
54173
|
const responses_path = args.responses;
|
|
54505
|
-
const log_path =
|
|
54506
|
-
if (!
|
|
54174
|
+
const log_path = path87.join(path87.dirname(responses_path), "low-impact-resolutions.md");
|
|
54175
|
+
if (!fs90.existsSync(log_path)) {
|
|
54507
54176
|
_stdout2(
|
|
54508
54177
|
`council:replay \xB7 no low-impact-resolutions.md alongside ${responses_path} \u2014 session had no fast-path entries.
|
|
54509
54178
|
`
|
|
54510
54179
|
);
|
|
54511
54180
|
return 0;
|
|
54512
54181
|
}
|
|
54513
|
-
const body =
|
|
54182
|
+
const body = fs90.readFileSync(log_path, "utf-8");
|
|
54514
54183
|
const stats = li.parse_low_impact_log(body);
|
|
54515
54184
|
const out = li.render_low_impact_stats(stats);
|
|
54516
54185
|
if (_getattr3(args, "output", null)) {
|
|
@@ -54518,8 +54187,8 @@ function _cmd_replay_low_impact_stats(args) {
|
|
|
54518
54187
|
kind: "sessions",
|
|
54519
54188
|
subcommand: "replay"
|
|
54520
54189
|
});
|
|
54521
|
-
|
|
54522
|
-
|
|
54190
|
+
fs90.mkdirSync(path87.dirname(_resolveTarget(target)), { recursive: true });
|
|
54191
|
+
fs90.writeFileSync(_resolveTarget(target), out, { encoding: "utf-8" });
|
|
54523
54192
|
_stdout2(`council:replay \xB7 wrote ${target}
|
|
54524
54193
|
`);
|
|
54525
54194
|
return 0;
|
|
@@ -54531,7 +54200,7 @@ function cmd_replay(args) {
|
|
|
54531
54200
|
if (_getattr3(args, "low_impact_stats", false)) {
|
|
54532
54201
|
return _cmd_replay_low_impact_stats(args);
|
|
54533
54202
|
}
|
|
54534
|
-
const payload = JSON.parse(
|
|
54203
|
+
const payload = JSON.parse(fs90.readFileSync(args.responses, "utf-8"));
|
|
54535
54204
|
const consensus = _deserialise_consensus(payload["consensus"]);
|
|
54536
54205
|
if (consensus === null) {
|
|
54537
54206
|
_stderr2(
|
|
@@ -54556,8 +54225,8 @@ function cmd_replay(args) {
|
|
|
54556
54225
|
kind: "sessions",
|
|
54557
54226
|
subcommand: "replay"
|
|
54558
54227
|
});
|
|
54559
|
-
|
|
54560
|
-
|
|
54228
|
+
fs90.mkdirSync(path87.dirname(_resolveTarget(out_path)), { recursive: true });
|
|
54229
|
+
fs90.writeFileSync(_resolveTarget(out_path), body, { encoding: "utf-8" });
|
|
54561
54230
|
_stdout2(`council:replay \xB7 wrote ${out_path}
|
|
54562
54231
|
`);
|
|
54563
54232
|
} else {
|
|
@@ -54614,8 +54283,8 @@ function cmd_quota(args, opts = {}) {
|
|
|
54614
54283
|
}
|
|
54615
54284
|
function _validate_council_output_path(path_str, opts) {
|
|
54616
54285
|
const expected_rel = COUNCIL_CANONICAL_DIRS[opts.kind];
|
|
54617
|
-
const expected_abs = _resolveReal(
|
|
54618
|
-
const target =
|
|
54286
|
+
const expected_abs = _resolveReal(path87.join(REPO_ROOT11, expected_rel));
|
|
54287
|
+
const target = path87.isAbsolute(path_str) ? path_str : path87.join(REPO_ROOT11, path_str);
|
|
54619
54288
|
const target_resolved = _resolveReal(target);
|
|
54620
54289
|
if (!_isRelativeTo(target_resolved, expected_abs)) {
|
|
54621
54290
|
throw new ArgumentTypeError(
|
|
@@ -54625,12 +54294,12 @@ function _validate_council_output_path(path_str, opts) {
|
|
|
54625
54294
|
return path_str;
|
|
54626
54295
|
}
|
|
54627
54296
|
function _resolveTarget(path_str) {
|
|
54628
|
-
return
|
|
54297
|
+
return path87.isAbsolute(path_str) ? path_str : path87.join(REPO_ROOT11, path_str);
|
|
54629
54298
|
}
|
|
54630
54299
|
function _resolveReal(p) {
|
|
54631
|
-
const abs =
|
|
54300
|
+
const abs = path87.resolve(p);
|
|
54632
54301
|
try {
|
|
54633
|
-
return
|
|
54302
|
+
return fs90.realpathSync(abs);
|
|
54634
54303
|
} catch {
|
|
54635
54304
|
return abs;
|
|
54636
54305
|
}
|
|
@@ -54639,8 +54308,8 @@ function _isRelativeTo(target, base) {
|
|
|
54639
54308
|
if (target === base) {
|
|
54640
54309
|
return true;
|
|
54641
54310
|
}
|
|
54642
|
-
const rel =
|
|
54643
|
-
return rel !== "" && !rel.startsWith("..") && !
|
|
54311
|
+
const rel = path87.relative(base, target);
|
|
54312
|
+
return rel !== "" && !rel.startsWith("..") && !path87.isAbsolute(rel);
|
|
54644
54313
|
}
|
|
54645
54314
|
function _topError(message) {
|
|
54646
54315
|
_stderr2(_TOP_USAGE2);
|
|
@@ -54965,7 +54634,7 @@ function _parse_siblings_overrides(items) {
|
|
|
54965
54634
|
function _isFileNotFound(exc) {
|
|
54966
54635
|
return exc instanceof FileNotFoundError3 || exc instanceof Error && exc.code === "ENOENT";
|
|
54967
54636
|
}
|
|
54968
|
-
function
|
|
54637
|
+
function main36(argv = null) {
|
|
54969
54638
|
const args = _parseArgs7(argv ?? process.argv.slice(2));
|
|
54970
54639
|
try {
|
|
54971
54640
|
if (args.cmd === "estimate") {
|
|
@@ -55009,17 +54678,17 @@ function main37(argv = null) {
|
|
|
55009
54678
|
}
|
|
55010
54679
|
return 1;
|
|
55011
54680
|
}
|
|
55012
|
-
function
|
|
54681
|
+
function _isCliEntry31() {
|
|
55013
54682
|
if (process.argv[1] === void 0) {
|
|
55014
54683
|
return false;
|
|
55015
54684
|
}
|
|
55016
|
-
const argvUrl =
|
|
54685
|
+
const argvUrl = pathToFileURL36(path87.resolve(process.argv[1])).href;
|
|
55017
54686
|
if (import.meta.url === argvUrl) {
|
|
55018
54687
|
return true;
|
|
55019
54688
|
}
|
|
55020
54689
|
try {
|
|
55021
|
-
const here =
|
|
55022
|
-
const argv =
|
|
54690
|
+
const here = fs90.realpathSync(fileURLToPath46(import.meta.url));
|
|
54691
|
+
const argv = fs90.realpathSync(path87.resolve(process.argv[1]));
|
|
55023
54692
|
return here === argv;
|
|
55024
54693
|
} catch {
|
|
55025
54694
|
return false;
|
|
@@ -55090,7 +54759,7 @@ var init_council_cli = __esm({
|
|
|
55090
54759
|
"xai",
|
|
55091
54760
|
"perplexity"
|
|
55092
54761
|
]);
|
|
55093
|
-
_HERE24 =
|
|
54762
|
+
_HERE24 = path87.dirname(fileURLToPath46(import.meta.url));
|
|
55094
54763
|
[REPO_ROOT11] = resolve_project_root(null);
|
|
55095
54764
|
SETTINGS_FILE2 = project_settings_path(REPO_ROOT11);
|
|
55096
54765
|
AI_COUNCIL_FILE = resolve_config_path(REPO_ROOT11);
|
|
@@ -55123,9 +54792,9 @@ var init_council_cli = __esm({
|
|
|
55123
54792
|
{estimate,run,debate,render,replay,quota,shadow-report,status}
|
|
55124
54793
|
...
|
|
55125
54794
|
`;
|
|
55126
|
-
if (
|
|
54795
|
+
if (_isCliEntry31()) {
|
|
55127
54796
|
try {
|
|
55128
|
-
process.exitCode =
|
|
54797
|
+
process.exitCode = main36(process.argv.slice(2));
|
|
55129
54798
|
} catch (err) {
|
|
55130
54799
|
if (!(err instanceof _ArgExit2)) {
|
|
55131
54800
|
throw err;
|
|
@@ -55223,14 +54892,14 @@ __export(skill_catalogue_exports, {
|
|
|
55223
54892
|
resolveSkillsRoot: () => resolveSkillsRoot,
|
|
55224
54893
|
truncationModeOf: () => truncationModeOf
|
|
55225
54894
|
});
|
|
55226
|
-
import * as
|
|
55227
|
-
import * as
|
|
54895
|
+
import * as fs91 from "node:fs";
|
|
54896
|
+
import * as path88 from "node:path";
|
|
55228
54897
|
function resolveSkillsRoot(workspaceRoot) {
|
|
55229
54898
|
for (const candidate of DEFAULT_CATALOGUE_ROOTS) {
|
|
55230
|
-
const abs =
|
|
54899
|
+
const abs = path88.join(workspaceRoot, candidate);
|
|
55231
54900
|
try {
|
|
55232
|
-
if (!
|
|
55233
|
-
if (
|
|
54901
|
+
if (!fs91.existsSync(abs) || !fs91.statSync(abs).isDirectory()) continue;
|
|
54902
|
+
if (fs91.readdirSync(abs).length === 0) continue;
|
|
55234
54903
|
return abs;
|
|
55235
54904
|
} catch {
|
|
55236
54905
|
}
|
|
@@ -55275,9 +54944,9 @@ function descriptionOf(frontmatter) {
|
|
|
55275
54944
|
return "";
|
|
55276
54945
|
}
|
|
55277
54946
|
function readProjectedCatalogue(root) {
|
|
55278
|
-
const names =
|
|
54947
|
+
const names = fs91.readdirSync(root).filter((n) => fs91.existsSync(path88.join(root, n, "SKILL.md"))).sort();
|
|
55279
54948
|
return names.map((name, index) => {
|
|
55280
|
-
const content =
|
|
54949
|
+
const content = fs91.readFileSync(path88.join(root, name, "SKILL.md"), "utf-8");
|
|
55281
54950
|
const frontmatter = frontmatterOf(content);
|
|
55282
54951
|
const description = descriptionOf(frontmatter);
|
|
55283
54952
|
return {
|
|
@@ -55479,12 +55148,12 @@ function buildNoTruncationRecord(host, observedAt, entriesOffered, projectedSkil
|
|
|
55479
55148
|
};
|
|
55480
55149
|
}
|
|
55481
55150
|
function markdownFilesUnder(root) {
|
|
55482
|
-
if (!
|
|
55151
|
+
if (!fs91.existsSync(root)) return [];
|
|
55483
55152
|
const out = [];
|
|
55484
55153
|
const walk = (dir) => {
|
|
55485
|
-
for (const entry of
|
|
55486
|
-
const full =
|
|
55487
|
-
if (
|
|
55154
|
+
for (const entry of fs91.readdirSync(dir, { withFileTypes: true })) {
|
|
55155
|
+
const full = path88.join(dir, entry.name);
|
|
55156
|
+
if (fs91.statSync(full).isDirectory()) walk(full);
|
|
55488
55157
|
else if (entry.name.endsWith(".md")) out.push(full);
|
|
55489
55158
|
}
|
|
55490
55159
|
};
|
|
@@ -55492,9 +55161,9 @@ function markdownFilesUnder(root) {
|
|
|
55492
55161
|
return out;
|
|
55493
55162
|
}
|
|
55494
55163
|
function measureCatalogueVolume(host, root) {
|
|
55495
|
-
const skillsRoot =
|
|
55496
|
-
const skills =
|
|
55497
|
-
const commandEntries = markdownFilesUnder(
|
|
55164
|
+
const skillsRoot = path88.join(root, "skills");
|
|
55165
|
+
const skills = fs91.existsSync(skillsRoot) ? readProjectedCatalogue(skillsRoot) : [];
|
|
55166
|
+
const commandEntries = markdownFilesUnder(path88.join(root, "commands")).length;
|
|
55498
55167
|
return {
|
|
55499
55168
|
host,
|
|
55500
55169
|
root,
|
|
@@ -55642,9 +55311,9 @@ function migrationPromptLines(host, eligibility, settingsPath) {
|
|
|
55642
55311
|
];
|
|
55643
55312
|
}
|
|
55644
55313
|
function readObservationLog(logPath) {
|
|
55645
|
-
if (!
|
|
55314
|
+
if (!fs91.existsSync(logPath)) return [];
|
|
55646
55315
|
const out = [];
|
|
55647
|
-
for (const line of
|
|
55316
|
+
for (const line of fs91.readFileSync(logPath, "utf-8").split("\n")) {
|
|
55648
55317
|
const trimmed = line.trim();
|
|
55649
55318
|
if (trimmed.length === 0) continue;
|
|
55650
55319
|
try {
|
|
@@ -55719,7 +55388,7 @@ var init_skill_catalogue = __esm({
|
|
|
55719
55388
|
"src/scripts/_lib/skill_catalogue.ts"() {
|
|
55720
55389
|
"use strict";
|
|
55721
55390
|
DEFAULT_CATALOGUE_ROOTS = [".claude/skills", "src/skills"];
|
|
55722
|
-
OBSERVATION_LOG =
|
|
55391
|
+
OBSERVATION_LOG = path88.join(
|
|
55723
55392
|
"agents",
|
|
55724
55393
|
"evidence",
|
|
55725
55394
|
"metrics",
|
|
@@ -55870,13 +55539,13 @@ __export(score_skill_relevance_exports, {
|
|
|
55870
55539
|
_SAMPLE: () => _SAMPLE,
|
|
55871
55540
|
_parse_frontmatter: () => _parse_frontmatter2,
|
|
55872
55541
|
_tokenize: () => _tokenize,
|
|
55873
|
-
main: () =>
|
|
55542
|
+
main: () => main37,
|
|
55874
55543
|
parse_args: () => parse_args7,
|
|
55875
55544
|
rank: () => rank
|
|
55876
55545
|
});
|
|
55877
|
-
import * as
|
|
55878
|
-
import * as
|
|
55879
|
-
import { fileURLToPath as
|
|
55546
|
+
import * as fs92 from "node:fs";
|
|
55547
|
+
import * as path89 from "node:path";
|
|
55548
|
+
import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL37 } from "node:url";
|
|
55880
55549
|
function pyLen2(s) {
|
|
55881
55550
|
let n = 0;
|
|
55882
55551
|
for (const _ of s) {
|
|
@@ -55888,7 +55557,7 @@ function _tokenize(text) {
|
|
|
55888
55557
|
return tokenize3(text);
|
|
55889
55558
|
}
|
|
55890
55559
|
function _parse_frontmatter2(filePath) {
|
|
55891
|
-
const text =
|
|
55560
|
+
const text = fs92.readFileSync(filePath, "utf-8");
|
|
55892
55561
|
if (!text.startsWith("---")) {
|
|
55893
55562
|
return {};
|
|
55894
55563
|
}
|
|
@@ -55945,7 +55614,7 @@ function _load_skills(skillsDir) {
|
|
|
55945
55614
|
for (const skillMd of _globSkillMd(skillsDir)) {
|
|
55946
55615
|
const fm = _parse_frontmatter2(skillMd);
|
|
55947
55616
|
const rawName = fm["name"];
|
|
55948
|
-
const name = _truthyStr(rawName) ? String(rawName) :
|
|
55617
|
+
const name = _truthyStr(rawName) ? String(rawName) : path89.basename(path89.dirname(skillMd));
|
|
55949
55618
|
const rawDesc = fm["description"];
|
|
55950
55619
|
const desc = _truthyStr(rawDesc) ? String(rawDesc) : "";
|
|
55951
55620
|
let personas = fm["personas"] ?? [];
|
|
@@ -55974,23 +55643,23 @@ function _truthyStr(v) {
|
|
|
55974
55643
|
function _globSkillMd(root) {
|
|
55975
55644
|
let names;
|
|
55976
55645
|
try {
|
|
55977
|
-
names =
|
|
55646
|
+
names = fs92.readdirSync(root);
|
|
55978
55647
|
} catch {
|
|
55979
55648
|
return [];
|
|
55980
55649
|
}
|
|
55981
55650
|
const dirs = [];
|
|
55982
55651
|
for (const name of names) {
|
|
55983
|
-
const dir =
|
|
55984
|
-
const skillMd =
|
|
55652
|
+
const dir = path89.join(root, name);
|
|
55653
|
+
const skillMd = path89.join(dir, "SKILL.md");
|
|
55985
55654
|
try {
|
|
55986
|
-
if (
|
|
55655
|
+
if (fs92.statSync(dir).isDirectory() && fs92.statSync(skillMd).isFile()) {
|
|
55987
55656
|
dirs.push(name);
|
|
55988
55657
|
}
|
|
55989
55658
|
} catch {
|
|
55990
55659
|
}
|
|
55991
55660
|
}
|
|
55992
55661
|
dirs.sort();
|
|
55993
|
-
return dirs.map((name) =>
|
|
55662
|
+
return dirs.map((name) => path89.join(root, name, "SKILL.md"));
|
|
55994
55663
|
}
|
|
55995
55664
|
function _score3(taskTerms, skill, opts = {}) {
|
|
55996
55665
|
const rankable = {
|
|
@@ -56182,10 +55851,10 @@ function catalogueDeficit(dir) {
|
|
|
56182
55851
|
return `no catalogue root resolved \u2014 tried ${DEFAULT_CATALOGUE_ROOTS.join(", ")} under ${ROOT3}`;
|
|
56183
55852
|
}
|
|
56184
55853
|
try {
|
|
56185
|
-
if (!
|
|
55854
|
+
if (!fs92.existsSync(dir) || !fs92.statSync(dir).isDirectory()) {
|
|
56186
55855
|
return `${dir} is not a directory`;
|
|
56187
55856
|
}
|
|
56188
|
-
if (
|
|
55857
|
+
if (fs92.readdirSync(dir).length === 0) {
|
|
56189
55858
|
return `${dir} exists and is EMPTY \u2014 an empty catalogue, not an empty result`;
|
|
56190
55859
|
}
|
|
56191
55860
|
} catch (e) {
|
|
@@ -56193,7 +55862,7 @@ function catalogueDeficit(dir) {
|
|
|
56193
55862
|
}
|
|
56194
55863
|
return null;
|
|
56195
55864
|
}
|
|
56196
|
-
function
|
|
55865
|
+
function main37(argv = null) {
|
|
56197
55866
|
const args = parse_args7(argv ?? process.argv.slice(2));
|
|
56198
55867
|
const task = args.sample ? _SAMPLE.task : args.task;
|
|
56199
55868
|
if (!task) {
|
|
@@ -56232,17 +55901,17 @@ This is NOT "no skill matches": nothing was read, so no conclusion about skill c
|
|
|
56232
55901
|
}
|
|
56233
55902
|
return 0;
|
|
56234
55903
|
}
|
|
56235
|
-
function
|
|
55904
|
+
function _isCliEntry32() {
|
|
56236
55905
|
if (process.argv[1] === void 0) {
|
|
56237
55906
|
return false;
|
|
56238
55907
|
}
|
|
56239
|
-
const argvUrl =
|
|
55908
|
+
const argvUrl = pathToFileURL37(path89.resolve(process.argv[1])).href;
|
|
56240
55909
|
if (import.meta.url === argvUrl) {
|
|
56241
55910
|
return true;
|
|
56242
55911
|
}
|
|
56243
55912
|
try {
|
|
56244
|
-
const here =
|
|
56245
|
-
const argv =
|
|
55913
|
+
const here = fs92.realpathSync(fileURLToPath47(import.meta.url));
|
|
55914
|
+
const argv = fs92.realpathSync(path89.resolve(process.argv[1]));
|
|
56246
55915
|
return here === argv;
|
|
56247
55916
|
} catch {
|
|
56248
55917
|
return false;
|
|
@@ -56254,23 +55923,23 @@ var init_score_skill_relevance = __esm({
|
|
|
56254
55923
|
"use strict";
|
|
56255
55924
|
init_skillRanking();
|
|
56256
55925
|
init_skill_catalogue();
|
|
56257
|
-
_HERE25 =
|
|
56258
|
-
ROOT3 =
|
|
55926
|
+
_HERE25 = fileURLToPath47(import.meta.url);
|
|
55927
|
+
ROOT3 = path89.resolve(path89.dirname(_HERE25), "..", "..", "..");
|
|
56259
55928
|
DEFAULT_SKILLS_DIR = resolveSkillsRoot(ROOT3);
|
|
56260
55929
|
PROG5 = "score_skill_relevance.py";
|
|
56261
55930
|
_SAMPLE = {
|
|
56262
55931
|
task: "build a livewire component for the user dashboard with reactive state"
|
|
56263
55932
|
};
|
|
56264
|
-
_isMain5 =
|
|
55933
|
+
_isMain5 = _isCliEntry32();
|
|
56265
55934
|
if (_isMain5) {
|
|
56266
|
-
process.exitCode =
|
|
55935
|
+
process.exitCode = main37();
|
|
56267
55936
|
}
|
|
56268
55937
|
}
|
|
56269
55938
|
});
|
|
56270
55939
|
|
|
56271
55940
|
// src/scripts/mcp_server/__main__.ts
|
|
56272
|
-
import * as
|
|
56273
|
-
import { fileURLToPath as
|
|
55941
|
+
import * as path91 from "node:path";
|
|
55942
|
+
import { fileURLToPath as fileURLToPath49 } from "node:url";
|
|
56274
55943
|
|
|
56275
55944
|
// src/scripts/mcp_server/index.ts
|
|
56276
55945
|
var __version__ = "0.1.0";
|
|
@@ -56317,9 +55986,9 @@ init_prompts();
|
|
|
56317
55986
|
init_resources();
|
|
56318
55987
|
|
|
56319
55988
|
// src/scripts/mcp_server/tools.ts
|
|
56320
|
-
import * as
|
|
56321
|
-
import * as
|
|
56322
|
-
import { fileURLToPath as
|
|
55989
|
+
import * as fs93 from "node:fs";
|
|
55990
|
+
import * as path90 from "node:path";
|
|
55991
|
+
import { fileURLToPath as fileURLToPath48 } from "node:url";
|
|
56323
55992
|
|
|
56324
55993
|
// src/scripts/chat_history.ts
|
|
56325
55994
|
init_memory_lookup();
|
|
@@ -58552,9 +58221,9 @@ function _strip9(s) {
|
|
|
58552
58221
|
}
|
|
58553
58222
|
function _resolvePath2(p) {
|
|
58554
58223
|
try {
|
|
58555
|
-
return
|
|
58224
|
+
return fs93.realpathSync(p);
|
|
58556
58225
|
} catch {
|
|
58557
|
-
return
|
|
58226
|
+
return path90.resolve(p);
|
|
58558
58227
|
}
|
|
58559
58228
|
}
|
|
58560
58229
|
function _resolveConsumerRoot(override) {
|
|
@@ -58564,14 +58233,14 @@ function _resolveConsumerRoot(override) {
|
|
|
58564
58233
|
return _resolvePath2(process.cwd());
|
|
58565
58234
|
}
|
|
58566
58235
|
function _relativeUnder(target, root) {
|
|
58567
|
-
const rel =
|
|
58236
|
+
const rel = path90.relative(root, target);
|
|
58568
58237
|
if (rel === "") {
|
|
58569
58238
|
return "";
|
|
58570
58239
|
}
|
|
58571
|
-
if (rel.startsWith("..") ||
|
|
58240
|
+
if (rel.startsWith("..") || path90.isAbsolute(rel)) {
|
|
58572
58241
|
return null;
|
|
58573
58242
|
}
|
|
58574
|
-
return rel.split(
|
|
58243
|
+
return rel.split(path90.sep).join("/");
|
|
58575
58244
|
}
|
|
58576
58245
|
function _reprStrList(values) {
|
|
58577
58246
|
return `[${values.map((v) => `'${v}'`).join(", ")}]`;
|
|
@@ -58580,11 +58249,11 @@ function _validateInTreePath(raw, consumerRoot) {
|
|
|
58580
58249
|
const root = _resolvePath2(consumerRoot);
|
|
58581
58250
|
let target;
|
|
58582
58251
|
if (raw === null || raw === void 0 || raw === "") {
|
|
58583
|
-
target =
|
|
58584
|
-
} else if (
|
|
58252
|
+
target = path90.join(root, "agents", "runtime", ".agent-chat-history");
|
|
58253
|
+
} else if (path90.isAbsolute(raw)) {
|
|
58585
58254
|
target = _resolvePath2(raw);
|
|
58586
58255
|
} else {
|
|
58587
|
-
target = _resolvePath2(
|
|
58256
|
+
target = _resolvePath2(path90.join(root, raw));
|
|
58588
58257
|
}
|
|
58589
58258
|
const rel = _relativeUnder(target, root);
|
|
58590
58259
|
if (rel === null) {
|
|
@@ -58622,11 +58291,11 @@ async function _lintSkillsHandler(args, consumerRoot) {
|
|
|
58622
58291
|
if (typeof raw !== "string") {
|
|
58623
58292
|
throw new Error("'paths' entries must be strings");
|
|
58624
58293
|
}
|
|
58625
|
-
const resolved =
|
|
58294
|
+
const resolved = path90.isAbsolute(raw) ? _resolvePath2(raw) : _resolvePath2(path90.join(root, raw));
|
|
58626
58295
|
if (_relativeUnder(resolved, root) === null) {
|
|
58627
58296
|
throw new Error(`path escapes consumer_root: ${resolved}`);
|
|
58628
58297
|
}
|
|
58629
|
-
if (
|
|
58298
|
+
if (fs93.existsSync(resolved)) {
|
|
58630
58299
|
paths.push(resolved);
|
|
58631
58300
|
}
|
|
58632
58301
|
}
|
|
@@ -58663,7 +58332,7 @@ async function _chatHistoryAppendHandler(args, consumerRoot) {
|
|
|
58663
58332
|
if (typeof minSchema !== "number" || !Number.isInteger(minSchema) || typeof minSchema === "boolean") {
|
|
58664
58333
|
throw new Error("'min_schema_version' must be an integer");
|
|
58665
58334
|
}
|
|
58666
|
-
const existingHeader =
|
|
58335
|
+
const existingHeader = fs93.existsSync(target) ? _chReadHeader(target) : null;
|
|
58667
58336
|
const observed = existingHeader !== null && typeof existingHeader === "object" ? _pyInt7(existingHeader.v ?? 0) : SCHEMA_VERSION3;
|
|
58668
58337
|
if (observed < minSchema) {
|
|
58669
58338
|
throw new Error(`chat-history schema ${observed} below required ${minSchema}`);
|
|
@@ -58678,8 +58347,8 @@ async function _chatHistoryAppendHandler(args, consumerRoot) {
|
|
|
58678
58347
|
session: session === void 0 ? null : session
|
|
58679
58348
|
};
|
|
58680
58349
|
}
|
|
58681
|
-
if (!
|
|
58682
|
-
|
|
58350
|
+
if (!fs93.existsSync(target) || _chReadHeader(target) === null) {
|
|
58351
|
+
fs93.mkdirSync(path90.dirname(target), { recursive: true });
|
|
58683
58352
|
_chInit(target);
|
|
58684
58353
|
}
|
|
58685
58354
|
_chAppend(entry, target, session ?? null);
|
|
@@ -58723,7 +58392,7 @@ async function _chatHistoryReadHandler(args, consumerRoot) {
|
|
|
58723
58392
|
if (detail !== "full" && detail !== "index") {
|
|
58724
58393
|
throw new Error("'detail' must be 'index' or 'full'");
|
|
58725
58394
|
}
|
|
58726
|
-
if (!
|
|
58395
|
+
if (!fs93.existsSync(target)) {
|
|
58727
58396
|
return { path: target, entries: [], count: 0 };
|
|
58728
58397
|
}
|
|
58729
58398
|
if (around !== void 0 && around !== null) {
|
|
@@ -58825,8 +58494,8 @@ async function _memoryStatusHandler(_args, consumerRoot) {
|
|
|
58825
58494
|
}
|
|
58826
58495
|
return result;
|
|
58827
58496
|
}
|
|
58828
|
-
var _PACKAGE_ROOT3 =
|
|
58829
|
-
|
|
58497
|
+
var _PACKAGE_ROOT3 = path90.resolve(
|
|
58498
|
+
path90.dirname(fileURLToPath48(import.meta.url)),
|
|
58830
58499
|
"..",
|
|
58831
58500
|
"..",
|
|
58832
58501
|
".."
|
|
@@ -58870,10 +58539,10 @@ async function _memorySignalHandler(args, consumerRoot) {
|
|
|
58870
58539
|
async function _roadmapProgressHandler(args, consumerRoot) {
|
|
58871
58540
|
const dryRun = _pyTruthy6(args.dry_run ?? false);
|
|
58872
58541
|
const root = _resolvePath2(consumerRoot);
|
|
58873
|
-
const roadmapRoot =
|
|
58874
|
-
const target =
|
|
58542
|
+
const roadmapRoot = path90.join(root, "agents", "roadmaps");
|
|
58543
|
+
const target = path90.join(root, "agents", "roadmaps-progress.md");
|
|
58875
58544
|
const urp = await Promise.resolve().then(() => (init_update_roadmap_progress(), update_roadmap_progress_exports));
|
|
58876
|
-
if (!
|
|
58545
|
+
if (!fs93.existsSync(roadmapRoot)) {
|
|
58877
58546
|
return {
|
|
58878
58547
|
written: false,
|
|
58879
58548
|
path: target,
|
|
@@ -58888,7 +58557,7 @@ async function _roadmapProgressHandler(args, consumerRoot) {
|
|
|
58888
58557
|
const stepsDone = roadmaps.reduce((s, r) => s + r.done, 0);
|
|
58889
58558
|
const stepsTotal = roadmaps.reduce((s, r) => s + r.total_active, 0);
|
|
58890
58559
|
if (!dryRun) {
|
|
58891
|
-
|
|
58560
|
+
fs93.writeFileSync(target, content, "utf-8");
|
|
58892
58561
|
}
|
|
58893
58562
|
return {
|
|
58894
58563
|
written: !dryRun,
|
|
@@ -58909,11 +58578,11 @@ async function _roadmapArchiveHandler(_args, consumerRoot) {
|
|
|
58909
58578
|
let dashboardRegenerated = false;
|
|
58910
58579
|
if (archived.length > 0) {
|
|
58911
58580
|
const urp = await Promise.resolve().then(() => (init_update_roadmap_progress(), update_roadmap_progress_exports));
|
|
58912
|
-
const roadmapRoot =
|
|
58913
|
-
if (
|
|
58581
|
+
const roadmapRoot = path90.join(root, "agents", "roadmaps");
|
|
58582
|
+
if (fs93.existsSync(roadmapRoot)) {
|
|
58914
58583
|
const roadmaps = urp.collect(roadmapRoot);
|
|
58915
|
-
|
|
58916
|
-
|
|
58584
|
+
fs93.writeFileSync(
|
|
58585
|
+
path90.join(root, "agents", "roadmaps-progress.md"),
|
|
58917
58586
|
urp.render(roadmaps, urp.collect_bundles(root), roadmapRoot),
|
|
58918
58587
|
"utf-8"
|
|
58919
58588
|
);
|
|
@@ -58929,9 +58598,9 @@ async function _roadmapArchiveHandler(_args, consumerRoot) {
|
|
|
58929
58598
|
async function _capabilitiesIndexHandler(args, consumerRoot) {
|
|
58930
58599
|
const check = _pyTruthy6(args.check ?? false);
|
|
58931
58600
|
const cap = await Promise.resolve().then(() => (init_generate_capabilities_index(), generate_capabilities_index_exports));
|
|
58932
|
-
const out =
|
|
58601
|
+
const out = path90.join(_PACKAGE_ROOT3, "CAPABILITIES.yaml");
|
|
58933
58602
|
const content = cap.build();
|
|
58934
|
-
const onDisk =
|
|
58603
|
+
const onDisk = fs93.existsSync(out) ? fs93.readFileSync(out, "utf-8") : "";
|
|
58935
58604
|
const drift = onDisk !== content;
|
|
58936
58605
|
if (check) {
|
|
58937
58606
|
return { check: true, written: false, drift, path: out };
|
|
@@ -58942,7 +58611,7 @@ async function _capabilitiesIndexHandler(args, consumerRoot) {
|
|
|
58942
58611
|
`CAPABILITIES.yaml path escapes consumer_root: ${out} not under ${root}`
|
|
58943
58612
|
);
|
|
58944
58613
|
}
|
|
58945
|
-
|
|
58614
|
+
fs93.writeFileSync(out, content, "utf-8");
|
|
58946
58615
|
return { check: false, written: true, drift, path: out };
|
|
58947
58616
|
}
|
|
58948
58617
|
async function _runDoctorLeg(consumerRoot) {
|
|
@@ -59042,11 +58711,11 @@ async function _councilEstimateHandler(args, consumerRoot) {
|
|
|
59042
58711
|
throw new Error("'depth' must be 'shallow' or 'deep' when provided");
|
|
59043
58712
|
}
|
|
59044
58713
|
const root = _resolvePath2(consumerRoot);
|
|
59045
|
-
const target =
|
|
58714
|
+
const target = path90.isAbsolute(inputRaw) ? _resolvePath2(inputRaw) : _resolvePath2(path90.join(root, inputRaw));
|
|
59046
58715
|
if (_relativeUnder(target, root) === null) {
|
|
59047
58716
|
throw new Error(`path escapes consumer_root: ${target}`);
|
|
59048
58717
|
}
|
|
59049
|
-
if (!
|
|
58718
|
+
if (!fs93.existsSync(target)) {
|
|
59050
58719
|
throw new Error(`input_path not found: ${target}`);
|
|
59051
58720
|
}
|
|
59052
58721
|
const cli = await Promise.resolve().then(() => (init_council_cli(), council_cli_exports));
|
|
@@ -59108,18 +58777,18 @@ async function _runTestsHandler(args, consumerRoot) {
|
|
|
59108
58777
|
if (typeof relPathRaw !== "string" || !_strip9(relPathRaw)) {
|
|
59109
58778
|
throw new Error("'path' must be a non-empty string when provided");
|
|
59110
58779
|
}
|
|
59111
|
-
const resolved =
|
|
58780
|
+
const resolved = path90.isAbsolute(relPathRaw) ? _resolvePath2(relPathRaw) : _resolvePath2(path90.join(root, relPathRaw));
|
|
59112
58781
|
const rel = _relativeUnder(resolved, root);
|
|
59113
58782
|
if (rel === null) {
|
|
59114
58783
|
throw new Error(`path escapes consumer_root: ${resolved}`);
|
|
59115
58784
|
}
|
|
59116
|
-
if (!
|
|
58785
|
+
if (!fs93.existsSync(resolved)) {
|
|
59117
58786
|
throw new Error(`path not found: ${resolved}`);
|
|
59118
58787
|
}
|
|
59119
58788
|
relArg = rel;
|
|
59120
58789
|
}
|
|
59121
|
-
const vitestEntry =
|
|
59122
|
-
if (!
|
|
58790
|
+
const vitestEntry = path90.join(root, "node_modules", "vitest", "vitest.mjs");
|
|
58791
|
+
if (!fs93.existsSync(vitestEntry)) {
|
|
59123
58792
|
throw new Error(
|
|
59124
58793
|
"run_tests pilot supports vitest projects only \u2014 node_modules/vitest/vitest.mjs not found under consumer_root"
|
|
59125
58794
|
);
|
|
@@ -59773,8 +59442,8 @@ function _strCmp3(a, b) {
|
|
|
59773
59442
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
59774
59443
|
}
|
|
59775
59444
|
function _pathlibCompare3(a, b) {
|
|
59776
|
-
const pa = a.split(
|
|
59777
|
-
const pb = b.split(
|
|
59445
|
+
const pa = a.split(path90.sep);
|
|
59446
|
+
const pb = b.split(path90.sep);
|
|
59778
59447
|
const n = Math.min(pa.length, pb.length);
|
|
59779
59448
|
for (let i = 0; i < n; i++) {
|
|
59780
59449
|
const c = _strCmp3(pa[i], pb[i]);
|
|
@@ -59993,18 +59662,18 @@ async function _serveOverSdk(server) {
|
|
|
59993
59662
|
const transport = new StdioServerTransport();
|
|
59994
59663
|
await sdkServer.connect(transport);
|
|
59995
59664
|
}
|
|
59996
|
-
function
|
|
59665
|
+
function main38() {
|
|
59997
59666
|
void run_stdio();
|
|
59998
59667
|
}
|
|
59999
59668
|
|
|
60000
59669
|
// src/scripts/mcp_server/__main__.ts
|
|
60001
|
-
var _selfPath =
|
|
60002
|
-
var _invokedDirectly2 = globalThis.__AC_MCP_BUNDLE_DIRECT === true || process.argv[1] !== void 0 &&
|
|
59670
|
+
var _selfPath = fileURLToPath49(import.meta.url);
|
|
59671
|
+
var _invokedDirectly2 = globalThis.__AC_MCP_BUNDLE_DIRECT === true || process.argv[1] !== void 0 && path91.resolve(process.argv[1]) === path91.resolve(_selfPath);
|
|
60003
59672
|
if (_invokedDirectly2) {
|
|
60004
|
-
|
|
59673
|
+
main38();
|
|
60005
59674
|
}
|
|
60006
59675
|
export {
|
|
60007
|
-
|
|
59676
|
+
main38 as main
|
|
60008
59677
|
};
|
|
60009
59678
|
/*! Bundled license information:
|
|
60010
59679
|
|