@event4u/agent-config 14.6.0 → 14.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +255 -145
  3. package/README.md +1 -1
  4. package/dist/agent-src/commands/analyze/inbox.md +264 -10
  5. package/dist/agent-src/commands/analyze.md +1 -1
  6. package/dist/agent-src/commands/evals/git-pr-merge.json +13 -0
  7. package/dist/agent-src/commands/evals/roadmap.json +17 -1
  8. package/dist/agent-src/commands/pr/create.md +14 -2
  9. package/dist/agent-src/commands/pr/merge.md +379 -0
  10. package/dist/agent-src/commands/roadmap/process-full.md +272 -32
  11. package/dist/agent-src/commands/roadmap.md +1 -1
  12. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +46 -36
  13. package/dist/agent-src/contexts/execution/autonomy-mechanics.md +37 -2
  14. package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +95 -2
  15. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +289 -106
  16. package/dist/agent-src/rules/artifact-drafting-protocol.md +5 -1
  17. package/dist/agent-src/rules/context-hygiene.md +2 -0
  18. package/dist/agent-src/rules/decision-revisit-gate.md +67 -32
  19. package/dist/agent-src/rules/fix-what-you-see.md +108 -0
  20. package/dist/agent-src/rules/no-roadmap-references.md +0 -5
  21. package/dist/agent-src/rules/recurring-criticism.md +110 -0
  22. package/dist/agent-src/rules/roadmap-progress-sync.md +20 -1
  23. package/dist/agent-src/rules/rule-type-governance.md +0 -2
  24. package/dist/agent-src/rules/self-repair-loop.md +17 -0
  25. package/dist/agent-src/rules/skill-quality.md +0 -2
  26. package/dist/agent-src/rules/source-confidentiality.md +37 -7
  27. package/dist/agent-src/scripts/archival_sweep.ts +117 -0
  28. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
  29. package/dist/agent-src/scripts/dashboard_mode.ts +212 -0
  30. package/dist/agent-src/scripts/gate_budget.ts +282 -0
  31. package/dist/agent-src/scripts/gate_execute.ts +72 -31
  32. package/dist/agent-src/scripts/roadmap_gates.ts +74 -3
  33. package/dist/agent-src/scripts/update_roadmap_progress.ts +296 -53
  34. package/dist/agent-src/skills/adr-create/SKILL.md +124 -5
  35. package/dist/agent-src/skills/ai-council/SKILL.md +48 -807
  36. package/dist/agent-src/skills/ai-council/references/advanced-modes.md +320 -0
  37. package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +99 -0
  38. package/dist/agent-src/skills/ai-council/references/execution-modes.md +162 -0
  39. package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +125 -0
  40. package/dist/agent-src/skills/ai-council/references/procedure.md +143 -0
  41. package/dist/agent-src/skills/decision-record/SKILL.md +61 -3
  42. package/dist/agent-src/skills/decision-review/SKILL.md +65 -0
  43. package/dist/agent-src/skills/merge-conflicts/SKILL.md +26 -0
  44. package/dist/agent-src/skills/quality-tools/SKILL.md +34 -326
  45. package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +113 -0
  46. package/dist/agent-src/skills/quality-tools/references/php-tools.md +222 -0
  47. package/dist/agent-src/skills/roadmap-management/SKILL.md +15 -409
  48. package/dist/agent-src/skills/roadmap-management/references/archival.md +226 -0
  49. package/dist/agent-src/skills/roadmap-management/references/authoring.md +107 -0
  50. package/dist/agent-src/skills/roadmap-management/references/dashboard.md +47 -0
  51. package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +58 -0
  52. package/dist/agent-src/skills/security/SKILL.md +8 -0
  53. package/dist/agent-src/skills/security-audit/SKILL.md +12 -1
  54. package/dist/agent-src/skills/skill-writing/SKILL.md +34 -570
  55. package/dist/agent-src/skills/skill-writing/references/procedure.md +275 -0
  56. package/dist/agent-src/skills/skill-writing/references/read-only-scripts.md +18 -0
  57. package/dist/agent-src/skills/skill-writing/references/section-patterns.md +298 -0
  58. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  59. package/dist/agent-src/templates/roadmaps.md +65 -4
  60. package/dist/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  61. package/dist/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  62. package/dist/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  63. package/dist/cli/registry.js +2 -1
  64. package/dist/cli/registry.js.map +1 -1
  65. package/dist/cli-delegate/chunk-2GNWGMAL.js +172 -0
  66. package/dist/cli-delegate/{chunk-P6LQDIWK.js → chunk-7PRE6ZV2.js} +338 -0
  67. package/dist/cli-delegate/{chunk-BKO2AZ7Z.js → chunk-B2ERU2VA.js} +1 -1
  68. package/dist/cli-delegate/chunk-E4XIZDIB.js +402 -0
  69. package/dist/cli-delegate/{chunk-3UCJWMMP.js → chunk-EEJUMCDZ.js} +16 -16
  70. package/dist/cli-delegate/{chunk-NXFWFAYV.js → chunk-G23AT6GD.js} +1 -0
  71. package/dist/cli-delegate/{chunk-XURJ4AQC.js → chunk-H4VIVD4C.js} +385 -284
  72. package/dist/cli-delegate/chunk-I3EIN2YG.js +36 -0
  73. package/dist/cli-delegate/{chunk-RLN73PR5.js → chunk-LPPWO5CE.js} +12 -8
  74. package/dist/cli-delegate/chunk-MWRD5YOH.js +100 -0
  75. package/dist/cli-delegate/{chunk-UEZ7D35A.js → chunk-N7CDDGI3.js} +4 -23
  76. package/dist/cli-delegate/{chunk-63WSP6YZ.js → chunk-PMEKGDED.js} +74 -167
  77. package/dist/cli-delegate/{chunk-GRRPEPRN.js → chunk-T7L2QK3K.js} +24 -5
  78. package/dist/cli-delegate/{chunk-EVTY7ISR.js → chunk-YM4GZDJG.js} +9 -1
  79. package/dist/cli-delegate/cmd_adr_effective.js +1162 -0
  80. package/dist/cli-delegate/cmd_conformance.js +466 -716
  81. package/dist/cli-delegate/cmd_converge.js +3 -3
  82. package/dist/cli-delegate/cmd_doctor.js +10 -10
  83. package/dist/cli-delegate/cmd_explain.js +1 -1
  84. package/dist/cli-delegate/cmd_export.js +10 -9
  85. package/dist/cli-delegate/cmd_handoff.js +10 -9
  86. package/dist/cli-delegate/cmd_memory_get.js +2 -1
  87. package/dist/cli-delegate/cmd_migrate.js +2 -2
  88. package/dist/cli-delegate/cmd_packs_active.js +1 -1
  89. package/dist/cli-delegate/cmd_preflight.js +5 -5
  90. package/dist/cli-delegate/cmd_prune.js +11 -10
  91. package/dist/cli-delegate/cmd_route_audit.js +6 -5
  92. package/dist/cli-delegate/cmd_route_explain.js +3 -3
  93. package/dist/cli-delegate/cmd_session_recycle.js +840 -30
  94. package/dist/cli-delegate/cmd_settings_get.js +3 -3
  95. package/dist/cli-delegate/cmd_settings_migrate.js +10 -9
  96. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  97. package/dist/cli-delegate/cmd_sync.js +11 -10
  98. package/dist/cli-delegate/cmd_uninstall.js +13 -11
  99. package/dist/cli-delegate/cmd_update.js +4 -4
  100. package/dist/cli-delegate/cmd_upgrade.js +4 -4
  101. package/dist/cli-delegate/cmd_validate.js +11 -10
  102. package/dist/cli-delegate/cmd_versions.js +3 -3
  103. package/dist/discovery/deprecation-report.md +1 -1
  104. package/dist/discovery/discovery-manifest.json +111 -37
  105. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  106. package/dist/discovery/discovery-manifest.summary.md +5 -5
  107. package/dist/discovery/dormancy-report.md +1 -1
  108. package/dist/discovery/orphan-report.md +1 -1
  109. package/dist/discovery/packs.json +15 -12
  110. package/dist/discovery/trust-report.md +3 -3
  111. package/dist/discovery/workspaces.json +11 -8
  112. package/dist/hooks/dispatch.js +3165 -2192
  113. package/dist/install/claudePathsPlan.js +187 -0
  114. package/dist/install/claudePathsPlan.js.map +1 -0
  115. package/dist/install/globalRuleLayers.js +169 -0
  116. package/dist/install/globalRuleLayers.js.map +1 -0
  117. package/dist/install/hostLayerFingerprint.js +136 -0
  118. package/dist/install/hostLayerFingerprint.js.map +1 -0
  119. package/dist/install/install.mjs +553 -425
  120. package/dist/install/partitionEligibility.js +432 -0
  121. package/dist/install/partitionEligibility.js.map +1 -0
  122. package/dist/install/ruleLayerPartition.js +157 -0
  123. package/dist/install/ruleLayerPartition.js.map +1 -0
  124. package/dist/mcp/registry-manifest.json +3 -3
  125. package/dist/mcp/server.json +2 -2
  126. package/dist/mcp/server.mjs +1863 -1234
  127. package/dist/router.json +1 -1
  128. package/dist/scripts/_lib/agent_src.js +41 -0
  129. package/dist/scripts/_lib/agent_src.js.map +1 -1
  130. package/dist/scripts/_lib/install_layout.js +83 -0
  131. package/dist/scripts/_lib/install_layout.js.map +1 -0
  132. package/dist/scripts/_lib/installed_lock.js +444 -0
  133. package/dist/scripts/_lib/installed_lock.js.map +1 -0
  134. package/dist/scripts/_lib/prune_empty_dirs.js +85 -0
  135. package/dist/scripts/_lib/prune_empty_dirs.js.map +1 -0
  136. package/dist/scripts/condense.js +63 -251
  137. package/dist/scripts/condense.js.map +1 -1
  138. package/dist/server/schemas/settings.js +4 -0
  139. package/dist/server/schemas/settings.js.map +1 -1
  140. package/docs/contracts/settings-classes.md +12 -6
  141. package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +8 -3
  142. package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +45 -1
  143. package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +26 -0
  144. package/docs/guidelines/agent-infra/false-green.md +47 -1
  145. package/docs/guidelines/agent-infra/memory-access.md +17 -0
  146. package/docs/guidelines/agent-infra/recurring-criticism-mechanics.md +96 -0
  147. package/package.json +1 -1
  148. package/src/agent-src/scripts/archival_sweep.ts +117 -0
  149. package/src/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
  150. package/src/agent-src/scripts/dashboard_mode.ts +212 -0
  151. package/src/agent-src/scripts/gate_budget.ts +282 -0
  152. package/src/agent-src/scripts/gate_execute.ts +72 -31
  153. package/src/agent-src/scripts/roadmap_gates.ts +74 -3
  154. package/src/agent-src/scripts/update_roadmap_progress.ts +296 -53
  155. package/src/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  156. package/src/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  157. package/src/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  158. package/src/config/agent-settings.template.yml +27 -2
  159. package/src/config/ci-local-parity.yml +39 -0
  160. package/src/config/estate-count-budget.json +612 -3
  161. package/src/config/evaluator-budgets.json +3 -3
  162. package/src/config/gate-coverage.yml +220 -12
  163. package/src/config/gate-violation-baselines.json +73 -63
  164. package/src/config/gitignore-block.txt +15 -2
  165. package/src/config/hook-latency-budget.json +5 -0
  166. package/src/config/rule-activation-census.json +14 -6
  167. package/src/config/rule-stub-ceilings.json +34 -7
  168. package/src/install/claudePathsPlan.ts +196 -0
  169. package/src/install/globalRuleLayers.ts +197 -0
  170. package/src/install/hostLayerFingerprint.ts +145 -0
  171. package/src/install/partitionEligibility.ts +502 -0
  172. package/src/install/ruleLayerPartition.ts +212 -0
  173. package/src/scripts/_cli/cmd_adr_effective.ts +484 -0
  174. package/src/scripts/_cli/cmd_session_recycle.ts +9 -1
  175. package/src/scripts/_dispatch.bash +17 -1
  176. package/src/scripts/_lib/ac_heading.ts +30 -0
  177. package/src/scripts/_lib/adr_frontmatter.test.ts +365 -0
  178. package/src/scripts/_lib/adr_frontmatter.ts +459 -0
  179. package/src/scripts/_lib/agent_src.ts +42 -0
  180. package/src/scripts/_lib/bench_ab_pinned_repo.ts +162 -0
  181. package/src/scripts/_lib/bench_ab_workspace.ts +10 -1
  182. package/src/scripts/_lib/envelope_grounding.ts +49 -9
  183. package/src/scripts/_lib/installed_lock.ts +50 -5
  184. package/src/scripts/_lib/layer_overlap_notice.ts +11 -2
  185. package/src/scripts/_lib/md_section.ts +129 -0
  186. package/src/scripts/_lib/prune_empty_dirs.ts +80 -0
  187. package/src/scripts/_lib/scope_guard.sh +26 -3
  188. package/src/scripts/_lib/self_repair.ts +19 -0
  189. package/src/scripts/_lib/self_repair_class_b.ts +171 -0
  190. package/src/scripts/adr/evidence_census.ts +899 -0
  191. package/src/scripts/adr/regenerate_index.ts +12 -32
  192. package/src/scripts/adr_cite_check.ts +540 -39
  193. package/src/scripts/ai_council/cli_help.ts +55 -0
  194. package/src/scripts/audit_adr_coverage.ts +103 -17
  195. package/src/scripts/before_complete_hook.ts +153 -28
  196. package/src/scripts/bench_ab_v2_complexity.ts +27 -7
  197. package/src/scripts/bench_hook_latency.ts +204 -0
  198. package/src/scripts/build_archive_index.ts +34 -0
  199. package/src/scripts/check_adr_frontmatter.ts +574 -39
  200. package/src/scripts/check_hook_bundle_content.ts +219 -0
  201. package/src/scripts/check_new_adr_evidence.ts +529 -0
  202. package/src/scripts/check_references.ts +78 -0
  203. package/src/scripts/check_release_published.ts +32 -11
  204. package/src/scripts/check_rule_layer_partition.ts +531 -0
  205. package/src/scripts/check_single_delivery.ts +194 -17
  206. package/src/scripts/check_standing_rule_delivery.ts +8 -2
  207. package/src/scripts/ci_settle.ts +170 -0
  208. package/src/scripts/condense.ts +79 -259
  209. package/src/scripts/council_cli.ts +3 -3
  210. package/src/scripts/dispatch_r2_reviewer.ts +6 -14
  211. package/src/scripts/external_sources_denylist.json +4 -1
  212. package/src/scripts/hook_manifest.json +1 -1
  213. package/src/scripts/hook_manifest.yaml +77 -14
  214. package/src/scripts/hooks/block_no_verify.ts +61 -10
  215. package/src/scripts/hooks/block_unauthorized_git.ts +21 -1
  216. package/src/scripts/hooks/concern_registry.ts +4 -0
  217. package/src/scripts/hooks/dispatch_hook.ts +154 -187
  218. package/src/scripts/hooks/dispatch_issues.ts +38 -19
  219. package/src/scripts/hooks/fallback_yaml.ts +66 -0
  220. package/src/scripts/hooks/host_semantics.ts +21 -0
  221. package/src/scripts/hooks/injection_budget.ts +13 -3
  222. package/src/scripts/hooks/py_json_dumps.ts +103 -0
  223. package/src/scripts/hooks/rtk_wrap_hook.ts +8 -3
  224. package/src/scripts/hooks/run_continuation_hook.ts +8 -5
  225. package/src/scripts/hooks/ship_diff_volume_hook.ts +81 -15
  226. package/src/scripts/hooks/source_first_gate_hook.ts +464 -0
  227. package/src/scripts/hooks/state_io.ts +870 -21
  228. package/src/scripts/hooks/stdin_failure_policy.ts +96 -0
  229. package/src/scripts/hooks/subagent_ledger_hook.ts +44 -15
  230. package/src/scripts/hooks/telemetry_flush_hook.ts +139 -0
  231. package/src/scripts/hooks/telemetry_self_repair.ts +128 -0
  232. package/src/scripts/hooks/telemetry_usage_hook.ts +22 -4
  233. package/src/scripts/hooks/turn_end_gate_hook.ts +81 -15
  234. package/src/scripts/injection_scan_hook.ts +137 -5
  235. package/src/scripts/install.ts +16 -11
  236. package/src/scripts/language_mirror_hook.ts +561 -25
  237. package/src/scripts/lint_framework_leakage_allowlist.json +2 -2
  238. package/src/scripts/lint_hook_manifest.ts +49 -0
  239. package/src/scripts/lint_plan_risk_register.ts +4 -3
  240. package/src/scripts/lint_provenance_vocabulary.ts +472 -4
  241. package/src/scripts/lint_skill_router_head.ts +4 -4
  242. package/src/scripts/mcp_server/tools.ts +2 -2
  243. package/src/scripts/new_roadmap.ts +136 -0
  244. package/src/scripts/pack_mcp_content.ts +20 -5
  245. package/src/scripts/release.ts +37 -38
  246. package/src/scripts/report_layer_overlap.ts +6 -0
  247. package/src/scripts/routing_doctor.ts +5 -1
  248. package/src/scripts/self_repair_hook.ts +37 -5
  249. package/src/scripts/session_register_hook.ts +11 -0
  250. package/src/scripts/skill_usage_collect.ts +11 -1
  251. package/src/scripts/skill_usage_report.ts +278 -8
  252. package/src/scripts/sync_pr_branch.ts +170 -20
  253. package/src/server/schemas/settings.ts +8 -0
  254. package/dist/cli-delegate/chunk-EJITJBJX.js +0 -172
  255. package/dist/cli-delegate/chunk-PZWRPRWP.js +0 -38
  256. package/dist/cli-delegate/{chunk-PPQO4NGR.js → chunk-6RJA2F5A.js} +3 -3
  257. package/dist/cli-delegate/{chunk-RYNADUFG.js → chunk-LWTYTX6F.js} +0 -0
  258. package/dist/cli-delegate/{chunk-FBKL6JWT.js → chunk-MMSGVZKV.js} +3 -3
@@ -1,112 +1,20 @@
1
1
  import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
2
  import {
3
- write_target
4
- } from "./chunk-NDJLNC6Q.js";
3
+ write_atomic
4
+ } from "./chunk-MWRD5YOH.js";
5
5
  import {
6
6
  require_dist
7
7
  } from "./chunk-OY53J6II.js";
8
+ import {
9
+ write_target
10
+ } from "./chunk-NDJLNC6Q.js";
8
11
  import {
9
12
  __export,
10
13
  __toESM
11
14
  } from "./chunk-J55WI3RR.js";
12
15
 
13
- // src/scripts/_lib/fs_atomic.ts
14
- import fs from "node:fs";
15
- import path from "node:path";
16
- import { randomBytes } from "node:crypto";
17
- function _normalize_encoding(encoding) {
18
- const compact = encoding.toLowerCase().replace(/[-_\s]/g, "");
19
- const candidates = [encoding, compact];
20
- if (compact === "latin1" || compact === "iso88591") candidates.push("latin1");
21
- if (compact === "utf8") candidates.push("utf8");
22
- if (compact === "utf16le" || compact === "utf16") candidates.push("utf16le");
23
- if (compact === "usascii") candidates.push("ascii");
24
- for (const c of candidates) {
25
- if (Buffer.isEncoding(c)) return c;
26
- }
27
- throw new Error(`unknown encoding: ${encoding}`);
28
- }
29
- function write_atomic(p, data, options = {}) {
30
- const encoding = options.encoding ?? "utf-8";
31
- const target = path.normalize(p);
32
- const parent = path.dirname(target);
33
- fs.mkdirSync(parent, { recursive: true });
34
- let payload;
35
- if (typeof data === "string") {
36
- payload = Buffer.from(data, _normalize_encoding(encoding));
37
- } else if (data instanceof Uint8Array) {
38
- payload = Buffer.from(data);
39
- } else {
40
- throw new TypeError(
41
- `write_atomic: data must be str or bytes, got ${typeof data}`
42
- );
43
- }
44
- let fd = null;
45
- let tmp_path = "";
46
- for (let attempt = 0; attempt < 32; attempt += 1) {
47
- tmp_path = path.join(
48
- parent,
49
- `.${path.basename(target)}.tmp.${randomBytes(6).toString("hex")}`
50
- );
51
- try {
52
- fd = fs.openSync(tmp_path, "wx", 384);
53
- break;
54
- } catch (err) {
55
- if (err.code === "EEXIST") continue;
56
- throw err;
57
- }
58
- }
59
- if (fd === null) {
60
- throw new Error("write_atomic: could not create a unique temp file");
61
- }
62
- let closed = false;
63
- try {
64
- let offset = 0;
65
- while (offset < payload.length) {
66
- offset += fs.writeSync(fd, payload, offset, payload.length - offset);
67
- }
68
- try {
69
- fs.fsyncSync(fd);
70
- } catch {
71
- }
72
- fs.closeSync(fd);
73
- closed = true;
74
- fs.renameSync(tmp_path, target);
75
- } catch (err) {
76
- if (!closed) {
77
- try {
78
- fs.closeSync(fd);
79
- } catch {
80
- }
81
- }
82
- try {
83
- fs.unlinkSync(tmp_path);
84
- } catch {
85
- }
86
- throw err;
87
- }
88
- _fsync_dir(parent);
89
- return target;
90
- }
91
- function _fsync_dir(directory) {
92
- let dir_fd;
93
- try {
94
- dir_fd = fs.openSync(directory, fs.constants.O_RDONLY);
95
- } catch {
96
- return;
97
- }
98
- try {
99
- try {
100
- fs.fsyncSync(dir_fd);
101
- } catch {
102
- }
103
- } finally {
104
- fs.closeSync(dir_fd);
105
- }
106
- }
107
-
108
16
  // src/scripts/_lib/installed_tools.ts
109
- import * as fs2 from "node:fs";
17
+ import * as fs from "node:fs";
110
18
  import * as os from "node:os";
111
19
  import * as fsPath from "node:path";
112
20
  var MANIFEST_ENV = "AGENT_CONFIG_INSTALLED_TOOLS";
@@ -144,18 +52,18 @@ function manifest_path(project_root, env) {
144
52
  var _TOP_KEY_RE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
145
53
  var _LIST_DASH_RE = /^\s*-\s*(.+?)\s*$/;
146
54
  var _INDENT_KEY_RE = /^\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
147
- function read_manifest(path4) {
55
+ function read_manifest(path3) {
148
56
  let text;
149
57
  try {
150
- text = require_read_text(path4);
58
+ text = require_read_text(path3);
151
59
  } catch {
152
60
  return null;
153
61
  }
154
62
  const data = _parse_manual(text);
155
63
  return _normalise_v2_shape(data);
156
64
  }
157
- function require_read_text(path4) {
158
- return fs2.readFileSync(path4, { encoding: "utf-8" });
65
+ function require_read_text(path3) {
66
+ return fs.readFileSync(path3, { encoding: "utf-8" });
159
67
  }
160
68
  function _normalise_v2_shape(data) {
161
69
  if (data["tools"] === void 0 || data["tools"] === null) {
@@ -336,9 +244,9 @@ function stable_sort(items, key) {
336
244
  return a.index - b.index;
337
245
  }).map((entry) => entry.item);
338
246
  }
339
- function write_manifest(path4, version, tools, options = {}) {
247
+ function write_manifest(path3, version, tools, options = {}) {
340
248
  const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
341
- return write_atomic(path4, rendered);
249
+ return write_atomic(path3, rendered);
342
250
  }
343
251
  var ScopeMismatchError = class extends Error {
344
252
  name_;
@@ -483,8 +391,8 @@ function randSuffix() {
483
391
 
484
392
  // src/scripts/_lib/claude_settings_hooks.ts
485
393
  var YAML = __toESM(require_dist(), 1);
486
- import * as fs3 from "node:fs";
487
- import * as path2 from "node:path";
394
+ import * as fs2 from "node:fs";
395
+ import * as path from "node:path";
488
396
  function _yaml_parse(text) {
489
397
  return YAML.parse(text);
490
398
  }
@@ -506,7 +414,7 @@ var SettingsLockError = class extends Error {
506
414
  }
507
415
  };
508
416
  function build_claude_hook_matrix(manifest_path2) {
509
- const raw = fs3.readFileSync(manifest_path2, "utf8");
417
+ const raw = fs2.readFileSync(manifest_path2, "utf8");
510
418
  const manifest = _yaml_parse(raw) ?? {};
511
419
  const hook_spec = manifest["schema_version"] ?? 1;
512
420
  const platforms = manifest["platforms"] ?? {};
@@ -536,8 +444,8 @@ function _is_managed_group(group) {
536
444
  );
537
445
  }
538
446
  function _read_settings(settings_path) {
539
- if (!fs3.existsSync(settings_path)) return {};
540
- const raw = fs3.readFileSync(settings_path, "utf8");
447
+ if (!fs2.existsSync(settings_path)) return {};
448
+ const raw = fs2.readFileSync(settings_path, "utf8");
541
449
  if (raw.trim() === "") return {};
542
450
  let parsed;
543
451
  try {
@@ -552,18 +460,18 @@ function _read_settings(settings_path) {
552
460
  }
553
461
  function _with_lock(settings_path, fn) {
554
462
  const lockPath = settings_path + ".agent-config.lock";
555
- fs3.mkdirSync(path2.dirname(lockPath), { recursive: true });
463
+ fs2.mkdirSync(path.dirname(lockPath), { recursive: true });
556
464
  let fd;
557
465
  try {
558
- fd = fs3.openSync(lockPath, "wx");
466
+ fd = fs2.openSync(lockPath, "wx");
559
467
  } catch {
560
468
  throw new SettingsLockError(lockPath);
561
469
  }
562
470
  try {
563
471
  return fn();
564
472
  } finally {
565
- fs3.closeSync(fd);
566
- fs3.rmSync(lockPath, { force: true });
473
+ fs2.closeSync(fd);
474
+ fs2.rmSync(lockPath, { force: true });
567
475
  }
568
476
  }
569
477
  function ensure_managed_hooks(settings_path, matrix) {
@@ -592,7 +500,7 @@ function ensure_managed_hooks(settings_path, matrix) {
592
500
  });
593
501
  }
594
502
  function remove_managed_hooks(settings_path) {
595
- if (!fs3.existsSync(settings_path)) return { changed: false, events: [] };
503
+ if (!fs2.existsSync(settings_path)) return { changed: false, events: [] };
596
504
  return _with_lock(settings_path, () => {
597
505
  const settings = _read_settings(settings_path);
598
506
  const hooks = settings["hooks"];
@@ -637,10 +545,10 @@ __export(global_deploy_inventory_exports, {
637
545
  record_deploy: () => record_deploy,
638
546
  save_inventory: () => save_inventory
639
547
  });
640
- import { randomBytes as randomBytes2 } from "node:crypto";
641
- import * as fs4 from "node:fs";
548
+ import { randomBytes } from "node:crypto";
549
+ import * as fs3 from "node:fs";
642
550
  import * as os2 from "node:os";
643
- import * as path3 from "node:path";
551
+ import * as path2 from "node:path";
644
552
  var SCHEMA_VERSION2 = 1;
645
553
  var INVENTORY_BASENAME = "deployed-files.json";
646
554
  var INVENTORY_ENV = "AGENT_CONFIG_DEPLOY_INVENTORY";
@@ -649,22 +557,22 @@ function expanduser2(p) {
649
557
  return os2.homedir();
650
558
  }
651
559
  if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
652
- return path3.join(os2.homedir(), p.slice(2));
560
+ return path2.join(os2.homedir(), p.slice(2));
653
561
  }
654
562
  return p;
655
563
  }
656
564
  function resolve_path(p) {
657
565
  try {
658
- return fs4.realpathSync(p);
566
+ return fs3.realpathSync(p);
659
567
  } catch {
660
- const abs = path3.resolve(p);
661
- const parts = abs.split(path3.sep);
568
+ const abs = path2.resolve(p);
569
+ const parts = abs.split(path2.sep);
662
570
  for (let i = parts.length; i > 0; i -= 1) {
663
- const prefix = parts.slice(0, i).join(path3.sep) || path3.sep;
571
+ const prefix = parts.slice(0, i).join(path2.sep) || path2.sep;
664
572
  try {
665
- const real = fs4.realpathSync(prefix);
573
+ const real = fs3.realpathSync(prefix);
666
574
  const rest = parts.slice(i);
667
- return rest.length > 0 ? path3.join(real, ...rest) : real;
575
+ return rest.length > 0 ? path2.join(real, ...rest) : real;
668
576
  } catch {
669
577
  continue;
670
578
  }
@@ -674,7 +582,7 @@ function resolve_path(p) {
674
582
  }
675
583
  function path_exists(p) {
676
584
  try {
677
- fs4.statSync(p);
585
+ fs3.statSync(p);
678
586
  return true;
679
587
  } catch {
680
588
  return false;
@@ -692,7 +600,7 @@ function load_inventory(p) {
692
600
  const target = p ?? inventory_path();
693
601
  let data;
694
602
  try {
695
- data = JSON.parse(fs4.readFileSync(target, { encoding: "utf-8" }));
603
+ data = JSON.parse(fs3.readFileSync(target, { encoding: "utf-8" }));
696
604
  } catch {
697
605
  return { schema_version: SCHEMA_VERSION2, tools: {} };
698
606
  }
@@ -703,15 +611,15 @@ function load_inventory(p) {
703
611
  }
704
612
  function save_inventory(data, p) {
705
613
  const target = p ?? inventory_path();
706
- fs4.mkdirSync(path3.dirname(target), { recursive: true });
614
+ fs3.mkdirSync(path2.dirname(target), { recursive: true });
707
615
  const payload = json_dumps_sorted(data, 2) + "\n";
708
- const parent = path3.dirname(target);
616
+ const parent = path2.dirname(target);
709
617
  let fd = null;
710
618
  let tmp_name = "";
711
619
  for (let attempt = 0; attempt < 32; attempt += 1) {
712
- tmp_name = path3.join(parent, `${path3.basename(target)}.${randomBytes2(6).toString("hex")}`);
620
+ tmp_name = path2.join(parent, `${path2.basename(target)}.${randomBytes(6).toString("hex")}`);
713
621
  try {
714
- fd = fs4.openSync(tmp_name, "wx", 384);
622
+ fd = fs3.openSync(tmp_name, "wx", 384);
715
623
  break;
716
624
  } catch (err) {
717
625
  if (err.code === "EEXIST") {
@@ -724,16 +632,16 @@ function save_inventory(data, p) {
724
632
  throw new Error("save_inventory: could not create a unique temp file");
725
633
  }
726
634
  try {
727
- fs4.writeFileSync(fd, payload, { encoding: "utf-8" });
728
- fs4.closeSync(fd);
729
- fs4.renameSync(tmp_name, target);
635
+ fs3.writeFileSync(fd, payload, { encoding: "utf-8" });
636
+ fs3.closeSync(fd);
637
+ fs3.renameSync(tmp_name, target);
730
638
  } catch (err) {
731
639
  try {
732
- fs4.closeSync(fd);
640
+ fs3.closeSync(fd);
733
641
  } catch {
734
642
  }
735
643
  try {
736
- fs4.unlinkSync(tmp_name);
644
+ fs3.unlinkSync(tmp_name);
737
645
  } catch {
738
646
  }
739
647
  throw err;
@@ -792,7 +700,7 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
792
700
  const out = /* @__PURE__ */ new Set();
793
701
  let src_stat;
794
702
  try {
795
- src_stat = fs4.statSync(src);
703
+ src_stat = fs3.statSync(src);
796
704
  } catch {
797
705
  return out;
798
706
  }
@@ -804,23 +712,23 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
804
712
  return out;
805
713
  }
806
714
  const _walk = (node, prefix) => {
807
- const entries = fs4.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
715
+ const entries = fs3.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
808
716
  for (const name of entries) {
809
- const entry = path3.join(node, name);
717
+ const entry = path2.join(node, name);
810
718
  const rel = join_rel(prefix, name);
811
- const lst = fs4.lstatSync(entry);
719
+ const lst = fs3.lstatSync(entry);
812
720
  if (lst.isDirectory() && !lst.isSymbolicLink()) {
813
721
  _walk(entry, rel);
814
722
  continue;
815
723
  }
816
724
  let resolved_is_dir = false;
817
725
  try {
818
- resolved_is_dir = fs4.statSync(entry).isDirectory();
726
+ resolved_is_dir = fs3.statSync(entry).isDirectory();
819
727
  } catch {
820
728
  resolved_is_dir = false;
821
729
  }
822
730
  if (resolved_is_dir) {
823
- _walk(fs4.realpathSync(entry), rel);
731
+ _walk(fs3.realpathSync(entry), rel);
824
732
  continue;
825
733
  }
826
734
  if (file_filter !== null && !file_filter(entry)) {
@@ -833,13 +741,13 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
833
741
  return out;
834
742
  }
835
743
  function join_rel(prefix, name) {
836
- return prefix ? path3.join(prefix, name) : name;
744
+ return prefix ? path2.join(prefix, name) : name;
837
745
  }
838
746
  function as_posix(p) {
839
747
  if (p === "") {
840
748
  return ".";
841
749
  }
842
- return p.split(path3.sep).join("/");
750
+ return p.split(path2.sep).join("/");
843
751
  }
844
752
  function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false) {
845
753
  const tools = inventory["tools"] ?? {};
@@ -864,15 +772,15 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
864
772
  if (typeof rel !== "string" || !rel || rel.startsWith("/") || rel.startsWith("..")) {
865
773
  continue;
866
774
  }
867
- const target = path3.join(anchor_resolved, rel);
775
+ const target = path2.join(anchor_resolved, rel);
868
776
  try {
869
- relative_to(resolve_path(path3.dirname(target)), anchor_resolved);
777
+ relative_to(resolve_path(path2.dirname(target)), anchor_resolved);
870
778
  } catch {
871
779
  continue;
872
780
  }
873
781
  let lst = null;
874
782
  try {
875
- lst = fs4.lstatSync(target);
783
+ lst = fs3.lstatSync(target);
876
784
  } catch {
877
785
  lst = null;
878
786
  }
@@ -886,12 +794,12 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
886
794
  continue;
887
795
  }
888
796
  try {
889
- fs4.unlinkSync(target);
797
+ fs3.unlinkSync(target);
890
798
  } catch {
891
799
  continue;
892
800
  }
893
801
  deleted.push(target);
894
- prune_candidates.add(path3.dirname(target));
802
+ prune_candidates.add(path2.dirname(target));
895
803
  }
896
804
  prune_empty_dirs(prune_candidates, anchor_resolved);
897
805
  return deleted;
@@ -902,10 +810,10 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
902
810
  const prune_candidates = /* @__PURE__ */ new Set();
903
811
  const needle = `package: ${package_tag}`;
904
812
  for (const dest_sub of dest_subs) {
905
- const root = dest_sub ? path3.join(anchor_resolved, dest_sub) : anchor_resolved;
813
+ const root = dest_sub ? path2.join(anchor_resolved, dest_sub) : anchor_resolved;
906
814
  let root_stat;
907
815
  try {
908
- root_stat = fs4.statSync(root);
816
+ root_stat = fs3.statSync(root);
909
817
  } catch {
910
818
  continue;
911
819
  }
@@ -915,7 +823,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
915
823
  for (const md of rglob_md(root)) {
916
824
  let md_lst;
917
825
  try {
918
- md_lst = fs4.lstatSync(md);
826
+ md_lst = fs3.lstatSync(md);
919
827
  } catch {
920
828
  continue;
921
829
  }
@@ -927,13 +835,13 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
927
835
  continue;
928
836
  }
929
837
  try {
930
- relative_to(resolve_path(path3.dirname(md)), anchor_resolved);
838
+ relative_to(resolve_path(path2.dirname(md)), anchor_resolved);
931
839
  } catch {
932
840
  continue;
933
841
  }
934
842
  let head;
935
843
  try {
936
- head = fs4.readFileSync(md, { encoding: "utf-8" });
844
+ head = fs3.readFileSync(md, { encoding: "utf-8" });
937
845
  } catch {
938
846
  continue;
939
847
  }
@@ -951,12 +859,12 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
951
859
  continue;
952
860
  }
953
861
  try {
954
- fs4.unlinkSync(md);
862
+ fs3.unlinkSync(md);
955
863
  } catch {
956
864
  continue;
957
865
  }
958
866
  deleted.push(md);
959
- prune_candidates.add(path3.dirname(md));
867
+ prune_candidates.add(path2.dirname(md));
960
868
  }
961
869
  }
962
870
  prune_empty_dirs(prune_candidates, anchor_resolved);
@@ -976,51 +884,51 @@ function record_deploy(tool_id, anchor, current_files, inventory) {
976
884
  }
977
885
  function prune_empty_dirs(prune_candidates, anchor_resolved) {
978
886
  const ordered = [...prune_candidates].sort(
979
- (a, b) => b.split(path3.sep).length - a.split(path3.sep).length
887
+ (a, b) => b.split(path2.sep).length - a.split(path2.sep).length
980
888
  );
981
889
  for (const start of ordered) {
982
890
  let node = start;
983
891
  while (node !== anchor_resolved && is_ancestor(anchor_resolved, node)) {
984
892
  try {
985
- fs4.rmdirSync(node);
893
+ fs3.rmdirSync(node);
986
894
  } catch {
987
895
  break;
988
896
  }
989
- node = path3.dirname(node);
897
+ node = path2.dirname(node);
990
898
  }
991
899
  }
992
900
  }
993
901
  function is_ancestor(anchor, node) {
994
- const rel = path3.relative(anchor, node);
995
- return rel !== "" && !rel.startsWith("..") && !path3.isAbsolute(rel);
902
+ const rel = path2.relative(anchor, node);
903
+ return rel !== "" && !rel.startsWith("..") && !path2.isAbsolute(rel);
996
904
  }
997
905
  function relative_to(child, parent) {
998
906
  if (child === parent) {
999
907
  return "";
1000
908
  }
1001
- const rel = path3.relative(parent, child);
1002
- if (rel.startsWith("..") || path3.isAbsolute(rel)) {
909
+ const rel = path2.relative(parent, child);
910
+ if (rel.startsWith("..") || path2.isAbsolute(rel)) {
1003
911
  throw new Error(`'${child}' is not in the subpath of '${parent}'`);
1004
912
  }
1005
913
  return rel;
1006
914
  }
1007
915
  function relative_to_posix(child, parent) {
1008
- return path3.relative(parent, child).split(path3.sep).join("/");
916
+ return path2.relative(parent, child).split(path2.sep).join("/");
1009
917
  }
1010
918
  function rglob_md(root) {
1011
919
  const out = [];
1012
920
  const walk = (dir) => {
1013
921
  let names;
1014
922
  try {
1015
- names = fs4.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
923
+ names = fs3.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
1016
924
  } catch {
1017
925
  return;
1018
926
  }
1019
927
  for (const name of names) {
1020
- const full = path3.join(dir, name);
928
+ const full = path2.join(dir, name);
1021
929
  let lst;
1022
930
  try {
1023
- lst = fs4.lstatSync(full);
931
+ lst = fs3.lstatSync(full);
1024
932
  } catch {
1025
933
  continue;
1026
934
  }
@@ -1061,7 +969,6 @@ function splitlines2(text) {
1061
969
  }
1062
970
 
1063
971
  export {
1064
- write_atomic,
1065
972
  SCHEMA_VERSIONS_SUPPORTED,
1066
973
  DEFAULT_DEPLOY_ROOTS,
1067
974
  manifest_path,
@@ -58,6 +58,7 @@ var _VERSION_RE = /^\s*agent_config_version\s*:\s*"?([^"\s]+)"?\s*$/;
58
58
  var _SCHEMA_RE = /^\s*schema_version\s*:\s*(\d+)\s*$/;
59
59
  var _LAYOUT_RE = /^\s*install_layout_version\s*:\s*(\d+)\s*$/;
60
60
  var _INSTALLED_AT_RE = /^\s*installed_at\s*:\s*"?([^"\s]+)"?\s*$/;
61
+ var _FINGERPRINT_RE = /^\s*host_layer_fingerprint\s*:\s*"?([0-9a-f]{64})"?\s*$/;
61
62
  var _TOOL_RE = /^\s*-\s*([A-Za-z0-9_\-.]+)\s*$/;
62
63
  function expanduser(p) {
63
64
  if (p === "~") {
@@ -123,6 +124,12 @@ function read_lockfile(path2) {
123
124
  in_tools = false;
124
125
  continue;
125
126
  }
127
+ const fp_m = _FINGERPRINT_RE.exec(raw_line);
128
+ if (fp_m) {
129
+ data.host_layer_fingerprint = fp_m[1];
130
+ in_tools = false;
131
+ continue;
132
+ }
126
133
  if (raw_line.trim().startsWith("tools:")) {
127
134
  in_tools = true;
128
135
  continue;
@@ -145,14 +152,17 @@ function splitlines(text) {
145
152
  }
146
153
  return parts;
147
154
  }
148
- function _render(version, tools, installed_at) {
155
+ function _render(version, tools, installed_at, fingerprint) {
149
156
  const lines = [
150
157
  `schema_version: ${SCHEMA_VERSION}`,
151
158
  `install_layout_version: ${INSTALL_LAYOUT_VERSION}`,
152
159
  `agent_config_version: "${version}"`,
153
- `installed_at: "${installed_at}"`,
154
- "tools:"
160
+ `installed_at: "${installed_at}"`
155
161
  ];
162
+ if (fingerprint) {
163
+ lines.push(`host_layer_fingerprint: "${fingerprint}"`);
164
+ }
165
+ lines.push("tools:");
156
166
  for (const tool of tools) {
157
167
  lines.push(` - ${tool}`);
158
168
  }
@@ -162,7 +172,12 @@ function write_lockfile(version, tools, options = {}) {
162
172
  const target = options.path ?? lockfile_path();
163
173
  fs.mkdirSync(path.dirname(target), { recursive: true });
164
174
  const stamp = strftime_iso_z(options.now ?? /* @__PURE__ */ new Date());
165
- const rendered = _render(version, sorted_unique(tools), stamp);
175
+ const rendered = _render(
176
+ version,
177
+ sorted_unique(tools),
178
+ stamp,
179
+ options.host_layer_fingerprint ?? null
180
+ );
166
181
  const parent = path.dirname(target);
167
182
  const { fd, tmp_name } = mkstemp(parent, ".installed.lock.");
168
183
  try {
@@ -218,7 +233,11 @@ function migrate_layout(options = {}) {
218
233
  const version = existing.agent_config_version || current_package_version();
219
234
  const tools = [...existing.tools ?? []];
220
235
  const when = options.now ?? _parse_installed_at(existing.installed_at);
221
- write_lockfile(version, tools, { path: target, now: when });
236
+ write_lockfile(version, tools, {
237
+ path: target,
238
+ now: when,
239
+ host_layer_fingerprint: existing.host_layer_fingerprint ?? null
240
+ });
222
241
  return {
223
242
  from: from_v,
224
243
  to: INSTALL_LAYOUT_VERSION,
@@ -4230,7 +4230,15 @@ var settingsSchema = external_exports.object({
4230
4230
  ),
4231
4231
  horizon_weeks: external_exports.number().int().min(0).default(0).describe(
4232
4232
  'Optional planning horizon (weeks) the agent shows in roadmap framing ("next 4 weeks"). Set 0 to omit the horizon \u2014 most teams prefer to ship without a hardcoded window.'
4233
- )
4233
+ ),
4234
+ gate_budget: external_exports.object({
4235
+ max_cost_per_run_usd: external_exports.number().min(0).default(5).describe(
4236
+ "Per-run USD ceiling for a CLASS-1 roadmap blocker executed via `agent-config gates --execute`. A class-1 entry whose **Budget:** field states a larger figure renders its consent line instead of running. Bounds the size of an authorised spend; never supplies the authorisation \u2014 `--confirm` is still required on every class-1 run."
4237
+ ),
4238
+ max_cost_per_rolling_7d_usd: external_exports.number().min(0).default(25).describe(
4239
+ "Rolling 7-day USD ceiling for class-1 gate execution, summed from the append-only receipt ledger at agents/runtime/state/gate-budget-ledger.jsonl. A run whose estimate would cross it renders instead of running. A per-run cap alone bounds one mistake, not a week of them, which is why option (a) of b-gate-budget-preauth carries two numbers."
4240
+ )
4241
+ }).default({ max_cost_per_run_usd: 5, max_cost_per_rolling_7d_usd: 25 })
4234
4242
  }),
4235
4243
  planning: external_exports.object({
4236
4244
  challenge_on_create: external_exports.boolean().default(true).describe(