@event4u/agent-config 16.0.0 → 16.1.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 (246) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +297 -137
  5. package/CONTRIBUTING.md +9 -0
  6. package/README.md +2 -2
  7. package/dist/agent-src/commands/analyze/inbox.md +26 -0
  8. package/dist/agent-src/commands/analyze/roadmap-repos.md +27 -0
  9. package/dist/agent-src/commands/challenge-me/closure.md +178 -0
  10. package/dist/agent-src/commands/challenge-me.md +9 -2
  11. package/dist/agent-src/commands/council/default.md +25 -5
  12. package/dist/agent-src/commands/feature/plan.md +28 -1
  13. package/dist/agent-src/commands/feature/roadmap.md +28 -1
  14. package/dist/agent-src/commands/implement-ticket.md +27 -0
  15. package/dist/agent-src/commands/jira-ticket.md +27 -0
  16. package/dist/agent-src/commands/pr/create.md +29 -0
  17. package/dist/agent-src/commands/pr/merge.md +60 -9
  18. package/dist/agent-src/commands/roadmap/ai-council.md +7 -1
  19. package/dist/agent-src/commands/roadmap/create.md +74 -27
  20. package/dist/agent-src/commands/roadmap/materialize.md +27 -0
  21. package/dist/agent-src/commands/roadmap/process-full.md +123 -18
  22. package/dist/agent-src/commands/team.md +22 -0
  23. package/dist/agent-src/contexts/authority/scope-growth-ownership.md +80 -0
  24. package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +47 -0
  25. package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +44 -3
  26. package/dist/agent-src/contexts/execution/autonomy-mechanics.md +15 -15
  27. package/dist/agent-src/contexts/execution/decision-closure-execution.md +93 -0
  28. package/dist/agent-src/contexts/execution/fix-loop-ladder.md +108 -0
  29. package/dist/agent-src/contexts/execution/plan-confidence-gate.md +4 -2
  30. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +75 -6
  31. package/dist/agent-src/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
  32. package/dist/agent-src/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
  33. package/dist/agent-src/guidelines/design-fidelity-routing.md +29 -0
  34. package/dist/agent-src/rules/autonomous-execution.md +15 -8
  35. package/dist/agent-src/rules/delegation-policy.md +23 -45
  36. package/dist/agent-src/rules/design-fidelity.md +32 -37
  37. package/dist/agent-src/rules/evaluator-independence.md +43 -49
  38. package/dist/agent-src/rules/test-first.md +41 -0
  39. package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +3 -3
  40. package/dist/agent-src/skills/ai-council/SKILL.md +11 -3
  41. package/dist/agent-src/skills/api-design/data/manifest.json +3 -3
  42. package/dist/agent-src/skills/database/data/manifest.json +4 -4
  43. package/dist/agent-src/skills/database/data/query-tuning.csv +3 -3
  44. package/dist/agent-src/skills/design-review/SKILL.md +50 -0
  45. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -4
  46. package/dist/agent-src/skills/experiment-loop/SKILL.md +31 -1
  47. package/dist/agent-src/skills/roadmap-writing/SKILL.md +1 -1
  48. package/dist/agent-src/skills/storybook-workshop/SKILL.md +42 -3
  49. package/dist/agent-src/skills/threat-modeling/SKILL.md +9 -4
  50. package/dist/agent-src/skills/threat-modeling/data/manifest.json +4 -4
  51. package/dist/agent-src/skills/verify-repair-loop/SKILL.md +37 -3
  52. package/dist/agent-src/templates/agent-settings.md +1 -1
  53. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  54. package/dist/agent-src/templates/roadmaps.md +188 -0
  55. package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  56. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  57. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  58. package/dist/cli-delegate/check_update_banner.js +40 -2
  59. package/dist/cli-delegate/chunk-4E2W63DA.js +335 -0
  60. package/dist/cli-delegate/chunk-5R7HOLAF.js +99 -0
  61. package/dist/cli-delegate/{chunk-IVBPRCQO.js → chunk-6KFEC3G7.js} +1 -1
  62. package/dist/cli-delegate/{chunk-2TAQ2K4V.js → chunk-6KM6ORRY.js} +55 -386
  63. package/dist/cli-delegate/{chunk-2XY7ILBT.js → chunk-FC75PGJE.js} +42 -2
  64. package/dist/cli-delegate/{chunk-GYC3VRYN.js → chunk-FXYUYU4N.js} +57 -13
  65. package/dist/cli-delegate/{chunk-55ACLDUE.js → chunk-GJCBB2UG.js} +168 -10
  66. package/dist/cli-delegate/{chunk-AK6HODNQ.js → chunk-HDVVGPQW.js} +873 -539
  67. package/dist/cli-delegate/{chunk-H32DGUJH.js → chunk-P6ZHP5W2.js} +1 -1
  68. package/dist/cli-delegate/{chunk-57PN4GYJ.js → chunk-RGNIWTEA.js} +1 -1
  69. package/dist/cli-delegate/chunk-ROYYTEZU.js +39 -0
  70. package/dist/cli-delegate/{chunk-3FKR64R5.js → chunk-UNCRJBT3.js} +31 -7
  71. package/dist/cli-delegate/{chunk-2DK2VJWG.js → chunk-WGXTVKCQ.js} +20 -6
  72. package/dist/cli-delegate/chunk-YDPILCOL.js +152 -0
  73. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  74. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  75. package/dist/cli-delegate/cmd_conformance.js +90 -56
  76. package/dist/cli-delegate/cmd_doctor.js +7 -5
  77. package/dist/cli-delegate/cmd_explain.js +2 -2
  78. package/dist/cli-delegate/cmd_export.js +9 -7
  79. package/dist/cli-delegate/cmd_fleet.js +4 -2
  80. package/dist/cli-delegate/cmd_handoff.js +4 -4
  81. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  82. package/dist/cli-delegate/cmd_migrate.js +2 -2
  83. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  84. package/dist/cli-delegate/cmd_preflight.js +4 -2
  85. package/dist/cli-delegate/cmd_prune.js +10 -8
  86. package/dist/cli-delegate/cmd_route_audit.js +2 -2
  87. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  88. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  89. package/dist/cli-delegate/cmd_settings_get.js +28 -2
  90. package/dist/cli-delegate/cmd_settings_migrate.js +9 -7
  91. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  92. package/dist/cli-delegate/cmd_sync.js +10 -8
  93. package/dist/cli-delegate/cmd_uninstall.js +16 -13
  94. package/dist/cli-delegate/cmd_update.js +1 -1
  95. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  96. package/dist/cli-delegate/cmd_validate.js +12 -10
  97. package/dist/cli-delegate/cmd_versions.js +1 -1
  98. package/dist/discovery/deprecation-report.md +1 -1
  99. package/dist/discovery/discovery-manifest.json +85 -38
  100. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  101. package/dist/discovery/discovery-manifest.summary.md +4 -4
  102. package/dist/discovery/dormancy-report.md +1 -1
  103. package/dist/discovery/orphan-report.md +1 -1
  104. package/dist/discovery/packs.json +10 -8
  105. package/dist/discovery/trust-report.md +3 -3
  106. package/dist/discovery/workspaces.json +8 -6
  107. package/dist/hooks/dispatch.js +1832 -1007
  108. package/dist/install/claudeRuleRewrite.js +14 -3
  109. package/dist/install/conflict.js +60 -10
  110. package/dist/install/conflictTracker.js +218 -0
  111. package/dist/install/fsPrimitives.js +54 -0
  112. package/dist/install/install.mjs +2007 -1481
  113. package/dist/install/manifestFiles.js +259 -0
  114. package/dist/install/preflight.js +14 -2
  115. package/dist/install/preserve.js +157 -0
  116. package/dist/install/recordedOwnership.js +132 -0
  117. package/dist/install/txlog.js +11 -2
  118. package/dist/mcp/registry-manifest.json +3 -3
  119. package/dist/mcp/server.json +2 -2
  120. package/dist/mcp/server.mjs +398 -39
  121. package/dist/router.json +1 -1
  122. package/dist/scripts/_lib/agent_settings.js +3 -2
  123. package/dist/scripts/_lib/fs_atomic.js +167 -0
  124. package/dist/scripts/_lib/installed_tools.js +460 -0
  125. package/dist/scripts/_lib/lean_projection_mode.js +3 -2
  126. package/dist/scripts/_lib/settings_renamed_keys.js +78 -0
  127. package/dist/server/routes/install.js +8 -0
  128. package/dist/server/routes/wizard.js +9 -3
  129. package/dist/server/schemas/settings.js +17 -5
  130. package/dist/shared/missionExecution.js +97 -0
  131. package/dist/ui/assets/{index-D0jaCRPM.js → index-DH1xc62v.js} +17 -17
  132. package/dist/ui/index.html +1 -1
  133. package/docs/MIGRATION.md +103 -0
  134. package/docs/contracts/settings-classes.md +26 -7
  135. package/docs/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
  136. package/docs/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
  137. package/docs/guidelines/design-fidelity-routing.md +29 -0
  138. package/package.json +1 -1
  139. package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  140. package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  141. package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  142. package/src/config/agent-settings.template.yml +139 -27
  143. package/src/config/auto-rule-budget.json +16 -0
  144. package/src/config/ci-local-parity.yml +18 -5
  145. package/src/config/continuity-surface.json +21 -0
  146. package/src/config/gate-coverage.yml +146 -13
  147. package/src/config/gate-violation-baselines.json +6 -6
  148. package/src/config/hook-token-budget.json +2 -0
  149. package/src/config/loop-surfaces.yaml +215 -0
  150. package/src/config/platform-anchor.json +3 -2
  151. package/src/config/release-gate-locality.yml +11 -0
  152. package/src/config/routing-coverage-seed.json +18 -4
  153. package/src/config/rule-enforcement-baseline.json +0 -1
  154. package/src/install/claudeRuleRewrite.ts +16 -2
  155. package/src/install/conflict.ts +65 -9
  156. package/src/install/conflictTracker.ts +299 -0
  157. package/src/install/fsPrimitives.ts +54 -0
  158. package/src/install/manifestFiles.ts +312 -0
  159. package/src/install/preflight.ts +16 -2
  160. package/src/install/preserve.ts +205 -0
  161. package/src/install/recordedOwnership.ts +149 -0
  162. package/src/install/txlog.ts +11 -2
  163. package/src/install/types.ts +19 -4
  164. package/src/scripts/_cli/cmd_conformance.ts +88 -15
  165. package/src/scripts/_cli/cmd_doctor.ts +4 -3
  166. package/src/scripts/_cli/cmd_route_explain.ts +9 -2
  167. package/src/scripts/_cli/cmd_settings_get.ts +44 -0
  168. package/src/scripts/_cli/doctor_execution.ts +90 -0
  169. package/src/scripts/_lib/activation_payload.ts +247 -0
  170. package/src/scripts/_lib/agent_settings.ts +4 -2
  171. package/src/scripts/_lib/authority_path.ts +102 -0
  172. package/src/scripts/_lib/cascade_base.ts +94 -0
  173. package/src/scripts/_lib/changelog_eras.ts +7 -2
  174. package/src/scripts/_lib/continuation_ladder.ts +149 -2
  175. package/src/scripts/_lib/council_transport.ts +129 -0
  176. package/src/scripts/_lib/delivery_ready.ts +112 -0
  177. package/src/scripts/_lib/forge_protection.ts +267 -0
  178. package/src/scripts/_lib/hook_platform_keys.ts +27 -0
  179. package/src/scripts/_lib/json_python_parity.ts +127 -0
  180. package/src/scripts/_lib/lean_projection_mode.ts +14 -3
  181. package/src/scripts/_lib/loop_surfaces.ts +382 -0
  182. package/src/scripts/_lib/mission_record.ts +190 -0
  183. package/src/scripts/_lib/obligation_frequency.ts +217 -0
  184. package/src/scripts/_lib/obligations.ts +402 -0
  185. package/src/scripts/_lib/orchestration_record.ts +11 -20
  186. package/src/scripts/_lib/release_highlights.ts +199 -10
  187. package/src/scripts/_lib/release_holds.ts +493 -0
  188. package/src/scripts/_lib/release_migration_gate.ts +184 -0
  189. package/src/scripts/_lib/rides_along.ts +102 -0
  190. package/src/scripts/_lib/settings_renamed_keys.ts +82 -0
  191. package/src/scripts/_lib/test_delta.ts +166 -0
  192. package/src/scripts/_lib/test_provenance.ts +171 -0
  193. package/src/scripts/_lib/typed_op_grant.ts +246 -0
  194. package/src/scripts/_lib/typed_op_watch.ts +185 -0
  195. package/src/scripts/ai_council/config.ts +8 -11
  196. package/src/scripts/ai_council/fallback_config.ts +5 -3
  197. package/src/scripts/ai_council/ownership_classes.ts +118 -0
  198. package/src/scripts/ask_block_census.ts +285 -15
  199. package/src/scripts/check_enforcement_matrix.ts +624 -0
  200. package/src/scripts/check_gate_reachability.ts +173 -10
  201. package/src/scripts/check_generator_sync.ts +954 -0
  202. package/src/scripts/check_preamble_payload_budget.ts +75 -2
  203. package/src/scripts/check_release_highlights.ts +33 -1
  204. package/src/scripts/check_release_holds.ts +567 -0
  205. package/src/scripts/check_rule_projection_integrity.ts +22 -12
  206. package/src/scripts/check_test_delta.ts +294 -0
  207. package/src/scripts/check_test_weakening.ts +299 -0
  208. package/src/scripts/closure_scan.ts +333 -0
  209. package/src/scripts/compile_hook_manifest.ts +43 -3
  210. package/src/scripts/council_record_shape.ts +209 -0
  211. package/src/scripts/hook_manifest.json +1 -1
  212. package/src/scripts/hook_manifest.yaml +88 -9
  213. package/src/scripts/hooks/concern_registry.ts +4 -0
  214. package/src/scripts/hooks/design_pass_hook.ts +128 -3
  215. package/src/scripts/hooks/evidence_independence.ts +96 -0
  216. package/src/scripts/hooks/memory_recall_hook.ts +540 -0
  217. package/src/scripts/hooks/obligation_settle_hook.ts +182 -0
  218. package/src/scripts/hooks/rule_inject_hook.ts +49 -1
  219. package/src/scripts/hooks/run_continuation_hook.ts +17 -20
  220. package/src/scripts/hooks_doctor.ts +85 -0
  221. package/src/scripts/hooks_status.ts +19 -0
  222. package/src/scripts/install.ts +106 -206
  223. package/src/scripts/janitor.ts +7 -0
  224. package/src/scripts/lint_decision_classes.ts +464 -0
  225. package/src/scripts/lint_hook_manifest.ts +11 -0
  226. package/src/scripts/lint_major_migration_sections.ts +450 -0
  227. package/src/scripts/lint_plan_risk_register.ts +47 -3
  228. package/src/scripts/lint_roadmap_blockers.ts +61 -0
  229. package/src/scripts/lint_roadmap_producers.ts +202 -0
  230. package/src/scripts/measure_rule_budget.ts +101 -5
  231. package/src/scripts/new_roadmap.ts +37 -0
  232. package/src/scripts/orchestration_record.ts +0 -5
  233. package/src/scripts/release.ts +14 -98
  234. package/src/scripts/release_drill.ts +267 -1
  235. package/src/scripts/release_publication.ts +51 -0
  236. package/src/scripts/report_enforcement_drift.ts +566 -0
  237. package/src/scripts/report_host_injection_effect.ts +3 -11
  238. package/src/scripts/report_standing_payload_by_host.ts +26 -152
  239. package/src/scripts/schemas/agent-settings.schema.json +23 -0
  240. package/src/scripts/schemas/command.schema.json +4 -0
  241. package/src/scripts/scope_growth.ts +219 -0
  242. package/src/scripts/trigger_eval_grandfather.json +0 -1
  243. package/src/scripts/ui_conformance_probe.ts +622 -0
  244. package/src/server/schemas/settings.ts +31 -7
  245. package/src/shared/missionExecution.ts +126 -0
  246. package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
@@ -1,7 +1,4 @@
1
1
  import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
- import {
3
- write_atomic
4
- } from "./chunk-MWRD5YOH.js";
5
2
  import {
6
3
  require_dist
7
4
  } from "./chunk-OY53J6II.js";
@@ -13,344 +10,23 @@ import {
13
10
  __toESM
14
11
  } from "./chunk-J55WI3RR.js";
15
12
 
16
- // src/scripts/_lib/installed_tools.ts
17
- import * as fs from "node:fs";
18
- import * as os from "node:os";
19
- import * as fsPath from "node:path";
20
- var MANIFEST_ENV = "AGENT_CONFIG_INSTALLED_TOOLS";
21
- var DEFAULT_MANIFEST_RELATIVE = fsPath.join("agents", "installed-tools.lock");
22
- var SCHEMA_VERSION = 2;
23
- var SCHEMA_VERSIONS_SUPPORTED = [1, 2];
24
- var _VALID_SCOPES = ["global", "project"];
25
- var DEFAULT_DEPLOY_ROOTS = [
26
- ".augment/rules",
27
- ".augment/skills",
28
- ".augment/commands",
29
- ".cursor/rules",
30
- ".claude/skills",
31
- ".claude/commands",
32
- ".clinerules",
33
- ".windsurf/rules"
34
- ];
35
- function expanduser(p) {
36
- if (p === "~") {
37
- return os.homedir();
38
- }
39
- if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
40
- return fsPath.join(os.homedir(), p.slice(2));
41
- }
42
- return p;
43
- }
44
- function manifest_path(project_root, env) {
45
- const env_map = env ?? process.env;
46
- const override = env_map[MANIFEST_ENV];
47
- if (override) {
48
- return expanduser(override);
49
- }
50
- return fsPath.join(project_root, DEFAULT_MANIFEST_RELATIVE);
51
- }
52
- var _TOP_KEY_RE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
53
- var _LIST_DASH_RE = /^\s*-\s*(.+?)\s*$/;
54
- var _INDENT_KEY_RE = /^\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*"?([^"\n]*?)"?\s*$/;
55
- function read_manifest(path3) {
56
- let text;
57
- try {
58
- text = require_read_text(path3);
59
- } catch {
60
- return null;
61
- }
62
- const data = _parse_manual(text);
63
- return _normalise_v2_shape(data);
64
- }
65
- function require_read_text(path3) {
66
- return fs.readFileSync(path3, { encoding: "utf-8" });
67
- }
68
- function _normalise_v2_shape(data) {
69
- if (data["tools"] === void 0 || data["tools"] === null) {
70
- data["tools"] = [];
71
- }
72
- if (data["deploy_roots"] === void 0 || data["deploy_roots"] === null) {
73
- data["deploy_roots"] = [];
74
- }
75
- const tools = data["tools"];
76
- for (const tool of tools) {
77
- if (typeof tool !== "object" || tool === null) {
78
- continue;
79
- }
80
- const t = tool;
81
- if (t["files"] === void 0 || t["files"] === null) {
82
- t["files"] = [];
83
- }
84
- if (t["merged_keys"] === void 0 || t["merged_keys"] === null) {
85
- t["merged_keys"] = [];
86
- }
87
- }
88
- return data;
89
- }
90
- function _parse_manual(text) {
91
- const data = { tools: [] };
92
- const tools = data["tools"];
93
- let in_tools = false;
94
- let current = null;
95
- let skip_until_outdent = false;
96
- for (const raw of splitlines(text)) {
97
- const stripped = raw.trim();
98
- if (!stripped || stripped.startsWith("#")) {
99
- continue;
100
- }
101
- if (stripped === "tools:") {
102
- in_tools = true;
103
- current = null;
104
- skip_until_outdent = false;
105
- continue;
106
- }
107
- if (in_tools) {
108
- const indent = raw.length - lstrip_spaces(raw).length;
109
- if (skip_until_outdent && indent > 4) {
110
- continue;
111
- }
112
- skip_until_outdent = false;
113
- const m = _LIST_DASH_RE.exec(raw);
114
- if (m && indent === 2) {
115
- const first = m[1];
116
- current = {};
117
- tools.push(current);
118
- const inline = _TOP_KEY_RE.exec(first);
119
- if (inline) {
120
- current[inline[1]] = inline[2];
121
- }
122
- continue;
123
- }
124
- const mk = _INDENT_KEY_RE.exec(raw);
125
- if (mk && current !== null && indent === 4) {
126
- const key = mk[1];
127
- const val = mk[2];
128
- if ((key === "files" || key === "merged_keys") && !val) {
129
- skip_until_outdent = true;
130
- continue;
131
- }
132
- current[key] = val;
133
- continue;
134
- }
135
- }
136
- const m_top = _TOP_KEY_RE.exec(raw);
137
- if (m_top) {
138
- const key = m_top[1];
139
- const value = m_top[2];
140
- if (key === "deploy_roots" && !value) {
141
- in_tools = false;
142
- current = null;
143
- skip_until_outdent = true;
144
- continue;
145
- }
146
- if (key === "schema_version") {
147
- const parsed = parse_int_strict(value);
148
- data[key] = parsed === null ? value : parsed;
149
- } else {
150
- data[key] = value;
151
- }
152
- in_tools = false;
153
- current = null;
154
- skip_until_outdent = false;
155
- }
156
- }
157
- return data;
158
- }
159
- function splitlines(text) {
160
- const parts = text.split("\n");
161
- if (parts.length > 0 && parts[parts.length - 1] === "") {
162
- parts.pop();
163
- }
164
- return parts;
165
- }
166
- function lstrip_spaces(s) {
167
- let i = 0;
168
- while (i < s.length && s[i] === " ") {
169
- i += 1;
170
- }
171
- return s.slice(i);
172
- }
173
- function parse_int_strict(value) {
174
- if (!/^[+-]?\d+$/.test(value.trim())) {
175
- return null;
176
- }
177
- return Number.parseInt(value, 10);
178
- }
179
- function _render(version, tools, options = {}) {
180
- const deploy_roots = options.deploy_roots ?? null;
181
- const lines = [
182
- `schema_version: ${SCHEMA_VERSION}`,
183
- `agent_config_version: "${version}"`
184
- ];
185
- if (deploy_roots && deploy_roots.length > 0) {
186
- lines.push("deploy_roots:");
187
- for (const root of deploy_roots) {
188
- lines.push(` - ${root}`);
189
- }
190
- }
191
- lines.push("tools:");
192
- for (const tool of tools) {
193
- lines.push(` - name: ${String(tool["name"])}`);
194
- lines.push(` scope: ${String(tool["scope"])}`);
195
- lines.push(` bridge_marker: ${String(tool["bridge_marker"])}`);
196
- lines.push(` installed_at: "${String(tool["installed_at"])}"`);
197
- const status = tool["status"];
198
- if (status) {
199
- lines.push(` status: ${String(status)}`);
200
- }
201
- let files = tool["files"] ?? [];
202
- if (files.length > 0) {
203
- files = stable_sort(files, (f) => [String(f["path"])]);
204
- lines.push(" files:");
205
- for (const entry of files) {
206
- lines.push(` - path: ${String(entry["path"])}`);
207
- lines.push(` kind: ${String(entry["kind"])}`);
208
- const sha = entry["sha256"];
209
- if (sha === null || sha === void 0) {
210
- lines.push(" sha256: null");
211
- } else {
212
- lines.push(` sha256: "${String(sha)}"`);
213
- }
214
- }
215
- }
216
- let merged = tool["merged_keys"] ?? [];
217
- if (merged.length > 0) {
218
- merged = stable_sort(merged, (e) => [
219
- String(e["file"]),
220
- String(e["json_pointer"])
221
- ]);
222
- lines.push(" merged_keys:");
223
- for (const entry of merged) {
224
- lines.push(` - file: ${String(entry["file"])}`);
225
- lines.push(` json_pointer: "${String(entry["json_pointer"])}"`);
226
- const vh = entry["value_hash"];
227
- if (vh !== null && vh !== void 0) {
228
- lines.push(` value_hash: "${String(vh)}"`);
229
- }
230
- }
231
- }
232
- }
233
- return lines.join("\n") + "\n";
234
- }
235
- function stable_sort(items, key) {
236
- return items.map((item, index) => ({ item, index, k: key(item) })).sort((a, b) => {
237
- const len = Math.max(a.k.length, b.k.length);
238
- for (let i = 0; i < len; i += 1) {
239
- const av = a.k[i] ?? "";
240
- const bv = b.k[i] ?? "";
241
- if (av < bv) return -1;
242
- if (av > bv) return 1;
243
- }
244
- return a.index - b.index;
245
- }).map((entry) => entry.item);
246
- }
247
- function write_manifest(path3, version, tools, options = {}) {
248
- const rendered = _render(version, tools, { deploy_roots: options.deploy_roots ?? null });
249
- return write_atomic(path3, rendered);
250
- }
251
- var ScopeMismatchError = class extends Error {
252
- name_;
253
- recorded_scope;
254
- new_scope;
255
- constructor(name, recorded_scope, new_scope) {
256
- super(
257
- `tool '${name}' is committed as scope=${recorded_scope}; refusing to change it to scope=${new_scope} without --force`
258
- );
259
- this.name = "ScopeMismatchError";
260
- this.name_ = name;
261
- this.recorded_scope = recorded_scope;
262
- this.new_scope = new_scope;
263
- }
264
- };
265
- function upsert_tool(existing, options) {
266
- const {
267
- name,
268
- scope,
269
- bridge_marker,
270
- installed_at = null,
271
- force = false,
272
- files = null,
273
- merged_keys = null
274
- } = options;
275
- if (!_VALID_SCOPES.includes(scope)) {
276
- throw new ValueError(`scope must be one of ${_VALID_SCOPES.join(",")}: '${scope}'`);
277
- }
278
- const stamp = installed_at || _today();
279
- const _build = (prior = null) => {
280
- const entry = {
281
- name,
282
- scope,
283
- bridge_marker,
284
- installed_at: stamp
285
- };
286
- if (files !== null) {
287
- entry["files"] = [...files];
288
- } else if (prior !== null && Array.isArray(prior["files"]) && prior["files"].length > 0) {
289
- entry["files"] = [...prior["files"]];
290
- }
291
- if (merged_keys !== null) {
292
- entry["merged_keys"] = [...merged_keys];
293
- } else if (prior !== null && Array.isArray(prior["merged_keys"]) && prior["merged_keys"].length > 0) {
294
- entry["merged_keys"] = [...prior["merged_keys"]];
295
- }
296
- return entry;
297
- };
298
- const result = [];
299
- let found = false;
300
- for (const entry of existing) {
301
- if (entry["name"] === name) {
302
- found = true;
303
- const recorded = String(entry["scope"] ?? "");
304
- if (recorded === scope) {
305
- if (files === null && merged_keys === null) {
306
- result.push(entry);
307
- } else {
308
- const refreshed = _build(entry);
309
- refreshed["installed_at"] = entry["installed_at"] ?? stamp;
310
- result.push(refreshed);
311
- }
312
- continue;
313
- }
314
- if (!force) {
315
- throw new ScopeMismatchError(name, recorded, scope);
316
- }
317
- result.push(_build(entry));
318
- continue;
319
- }
320
- result.push(entry);
321
- }
322
- if (!found) {
323
- result.push(_build());
324
- }
325
- return result;
326
- }
327
- var ValueError = class extends Error {
328
- constructor(message) {
329
- super(message);
330
- this.name = "ValueError";
331
- }
332
- };
333
- function _today() {
334
- return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
335
- }
336
-
337
13
  // src/install/atomic.ts
338
14
  import {
339
15
  closeSync,
340
16
  fsyncSync,
341
17
  mkdirSync,
342
18
  openSync,
343
- readFileSync as readFileSync2,
19
+ readFileSync,
344
20
  renameSync,
345
21
  unlinkSync,
346
22
  writeSync
347
23
  } from "node:fs";
348
- import { dirname, join as join2 } from "node:path";
24
+ import { dirname, join } from "node:path";
349
25
  function atomicWriteFile(target, data, options = {}) {
350
26
  const mode = options.mode ?? 420;
351
27
  const parent = dirname(target);
352
28
  mkdirSync(parent, { recursive: true });
353
- const tmp = join2(parent, `.tmp.${process.pid}.${randSuffix()}`);
29
+ const tmp = join(parent, `.tmp.${process.pid}.${randSuffix()}`);
354
30
  let fd = null;
355
31
  try {
356
32
  fd = openSync(tmp, "w", mode);
@@ -377,7 +53,7 @@ function atomicWriteFile(target, data, options = {}) {
377
53
  function atomicAppendLine(target, line) {
378
54
  let existing = "";
379
55
  try {
380
- existing = readFileSync2(target, "utf8");
56
+ existing = readFileSync(target, "utf8");
381
57
  } catch {
382
58
  existing = "";
383
59
  }
@@ -391,7 +67,7 @@ function randSuffix() {
391
67
 
392
68
  // src/scripts/_lib/claude_settings_hooks.ts
393
69
  var YAML = __toESM(require_dist(), 1);
394
- import * as fs2 from "node:fs";
70
+ import * as fs from "node:fs";
395
71
  import * as path from "node:path";
396
72
  function _yaml_parse(text) {
397
73
  return YAML.parse(text);
@@ -413,8 +89,8 @@ var SettingsLockError = class extends Error {
413
89
  this.name = "SettingsLockError";
414
90
  }
415
91
  };
416
- function build_claude_hook_matrix(manifest_path2) {
417
- const raw = fs2.readFileSync(manifest_path2, "utf8");
92
+ function build_claude_hook_matrix(manifest_path) {
93
+ const raw = fs.readFileSync(manifest_path, "utf8");
418
94
  const manifest = _yaml_parse(raw) ?? {};
419
95
  const hook_spec = manifest["schema_version"] ?? 1;
420
96
  const platforms = manifest["platforms"] ?? {};
@@ -444,8 +120,8 @@ function _is_managed_group(group) {
444
120
  );
445
121
  }
446
122
  function _read_settings(settings_path) {
447
- if (!fs2.existsSync(settings_path)) return {};
448
- const raw = fs2.readFileSync(settings_path, "utf8");
123
+ if (!fs.existsSync(settings_path)) return {};
124
+ const raw = fs.readFileSync(settings_path, "utf8");
449
125
  if (raw.trim() === "") return {};
450
126
  let parsed;
451
127
  try {
@@ -460,18 +136,18 @@ function _read_settings(settings_path) {
460
136
  }
461
137
  function _with_lock(settings_path, fn) {
462
138
  const lockPath = settings_path + ".agent-config.lock";
463
- fs2.mkdirSync(path.dirname(lockPath), { recursive: true });
139
+ fs.mkdirSync(path.dirname(lockPath), { recursive: true });
464
140
  let fd;
465
141
  try {
466
- fd = fs2.openSync(lockPath, "wx");
142
+ fd = fs.openSync(lockPath, "wx");
467
143
  } catch {
468
144
  throw new SettingsLockError(lockPath);
469
145
  }
470
146
  try {
471
147
  return fn();
472
148
  } finally {
473
- fs2.closeSync(fd);
474
- fs2.rmSync(lockPath, { force: true });
149
+ fs.closeSync(fd);
150
+ fs.rmSync(lockPath, { force: true });
475
151
  }
476
152
  }
477
153
  function ensure_managed_hooks(settings_path, matrix) {
@@ -500,7 +176,7 @@ function ensure_managed_hooks(settings_path, matrix) {
500
176
  });
501
177
  }
502
178
  function remove_managed_hooks(settings_path) {
503
- if (!fs2.existsSync(settings_path)) return { changed: false, events: [] };
179
+ if (!fs.existsSync(settings_path)) return { changed: false, events: [] };
504
180
  return _with_lock(settings_path, () => {
505
181
  const settings = _read_settings(settings_path);
506
182
  const hooks = settings["hooks"];
@@ -535,7 +211,7 @@ var global_deploy_inventory_exports = {};
535
211
  __export(global_deploy_inventory_exports, {
536
212
  INVENTORY_BASENAME: () => INVENTORY_BASENAME,
537
213
  INVENTORY_ENV: () => INVENTORY_ENV,
538
- SCHEMA_VERSION: () => SCHEMA_VERSION2,
214
+ SCHEMA_VERSION: () => SCHEMA_VERSION,
539
215
  expected_deploy_files: () => expected_deploy_files,
540
216
  inventory_path: () => inventory_path,
541
217
  is_ancestor: () => is_ancestor,
@@ -546,31 +222,31 @@ __export(global_deploy_inventory_exports, {
546
222
  save_inventory: () => save_inventory
547
223
  });
548
224
  import { randomBytes } from "node:crypto";
549
- import * as fs3 from "node:fs";
550
- import * as os2 from "node:os";
225
+ import * as fs2 from "node:fs";
226
+ import * as os from "node:os";
551
227
  import * as path2 from "node:path";
552
- var SCHEMA_VERSION2 = 1;
228
+ var SCHEMA_VERSION = 1;
553
229
  var INVENTORY_BASENAME = "deployed-files.json";
554
230
  var INVENTORY_ENV = "AGENT_CONFIG_DEPLOY_INVENTORY";
555
- function expanduser2(p) {
231
+ function expanduser(p) {
556
232
  if (p === "~") {
557
- return os2.homedir();
233
+ return os.homedir();
558
234
  }
559
235
  if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
560
- return path2.join(os2.homedir(), p.slice(2));
236
+ return path2.join(os.homedir(), p.slice(2));
561
237
  }
562
238
  return p;
563
239
  }
564
240
  function resolve_path(p) {
565
241
  try {
566
- return fs3.realpathSync(p);
242
+ return fs2.realpathSync(p);
567
243
  } catch {
568
244
  const abs = path2.resolve(p);
569
245
  const parts = abs.split(path2.sep);
570
246
  for (let i = parts.length; i > 0; i -= 1) {
571
247
  const prefix = parts.slice(0, i).join(path2.sep) || path2.sep;
572
248
  try {
573
- const real = fs3.realpathSync(prefix);
249
+ const real = fs2.realpathSync(prefix);
574
250
  const rest = parts.slice(i);
575
251
  return rest.length > 0 ? path2.join(real, ...rest) : real;
576
252
  } catch {
@@ -582,7 +258,7 @@ function resolve_path(p) {
582
258
  }
583
259
  function path_exists(p) {
584
260
  try {
585
- fs3.statSync(p);
261
+ fs2.statSync(p);
586
262
  return true;
587
263
  } catch {
588
264
  return false;
@@ -592,7 +268,7 @@ function inventory_path(env) {
592
268
  const env_map = env ?? process.env;
593
269
  const override = env_map[INVENTORY_ENV];
594
270
  if (override) {
595
- return expanduser2(override);
271
+ return expanduser(override);
596
272
  }
597
273
  return write_target(INVENTORY_BASENAME, { env: env ?? null });
598
274
  }
@@ -600,18 +276,18 @@ function load_inventory(p) {
600
276
  const target = p ?? inventory_path();
601
277
  let data;
602
278
  try {
603
- data = JSON.parse(fs3.readFileSync(target, { encoding: "utf-8" }));
279
+ data = JSON.parse(fs2.readFileSync(target, { encoding: "utf-8" }));
604
280
  } catch {
605
- return { schema_version: SCHEMA_VERSION2, tools: {} };
281
+ return { schema_version: SCHEMA_VERSION, tools: {} };
606
282
  }
607
283
  if (typeof data !== "object" || data === null || Array.isArray(data) || typeof data["tools"] !== "object" || data["tools"] === null || Array.isArray(data["tools"])) {
608
- return { schema_version: SCHEMA_VERSION2, tools: {} };
284
+ return { schema_version: SCHEMA_VERSION, tools: {} };
609
285
  }
610
286
  return data;
611
287
  }
612
288
  function save_inventory(data, p) {
613
289
  const target = p ?? inventory_path();
614
- fs3.mkdirSync(path2.dirname(target), { recursive: true });
290
+ fs2.mkdirSync(path2.dirname(target), { recursive: true });
615
291
  const payload = json_dumps_sorted(data, 2) + "\n";
616
292
  const parent = path2.dirname(target);
617
293
  let fd = null;
@@ -619,7 +295,7 @@ function save_inventory(data, p) {
619
295
  for (let attempt = 0; attempt < 32; attempt += 1) {
620
296
  tmp_name = path2.join(parent, `${path2.basename(target)}.${randomBytes(6).toString("hex")}`);
621
297
  try {
622
- fd = fs3.openSync(tmp_name, "wx", 384);
298
+ fd = fs2.openSync(tmp_name, "wx", 384);
623
299
  break;
624
300
  } catch (err) {
625
301
  if (err.code === "EEXIST") {
@@ -632,16 +308,16 @@ function save_inventory(data, p) {
632
308
  throw new Error("save_inventory: could not create a unique temp file");
633
309
  }
634
310
  try {
635
- fs3.writeFileSync(fd, payload, { encoding: "utf-8" });
636
- fs3.closeSync(fd);
637
- fs3.renameSync(tmp_name, target);
311
+ fs2.writeFileSync(fd, payload, { encoding: "utf-8" });
312
+ fs2.closeSync(fd);
313
+ fs2.renameSync(tmp_name, target);
638
314
  } catch (err) {
639
315
  try {
640
- fs3.closeSync(fd);
316
+ fs2.closeSync(fd);
641
317
  } catch {
642
318
  }
643
319
  try {
644
- fs3.unlinkSync(tmp_name);
320
+ fs2.unlinkSync(tmp_name);
645
321
  } catch {
646
322
  }
647
323
  throw err;
@@ -700,7 +376,7 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
700
376
  const out = /* @__PURE__ */ new Set();
701
377
  let src_stat;
702
378
  try {
703
- src_stat = fs3.statSync(src);
379
+ src_stat = fs2.statSync(src);
704
380
  } catch {
705
381
  return out;
706
382
  }
@@ -712,23 +388,23 @@ function expected_deploy_files(src, dest_rel, file_filter = null) {
712
388
  return out;
713
389
  }
714
390
  const _walk = (node, prefix) => {
715
- const entries = fs3.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
391
+ const entries = fs2.readdirSync(node).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
716
392
  for (const name of entries) {
717
393
  const entry = path2.join(node, name);
718
394
  const rel = join_rel(prefix, name);
719
- const lst = fs3.lstatSync(entry);
395
+ const lst = fs2.lstatSync(entry);
720
396
  if (lst.isDirectory() && !lst.isSymbolicLink()) {
721
397
  _walk(entry, rel);
722
398
  continue;
723
399
  }
724
400
  let resolved_is_dir = false;
725
401
  try {
726
- resolved_is_dir = fs3.statSync(entry).isDirectory();
402
+ resolved_is_dir = fs2.statSync(entry).isDirectory();
727
403
  } catch {
728
404
  resolved_is_dir = false;
729
405
  }
730
406
  if (resolved_is_dir) {
731
- _walk(fs3.realpathSync(entry), rel);
407
+ _walk(fs2.realpathSync(entry), rel);
732
408
  continue;
733
409
  }
734
410
  if (file_filter !== null && !file_filter(entry)) {
@@ -761,8 +437,8 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
761
437
  if (typeof recorded_anchor !== "string" || !Array.isArray(prev_files)) {
762
438
  return [];
763
439
  }
764
- const anchor_resolved = resolve_path(expanduser2(anchor));
765
- if (resolve_path(expanduser2(recorded_anchor)) !== anchor_resolved) {
440
+ const anchor_resolved = resolve_path(expanduser(anchor));
441
+ if (resolve_path(expanduser(recorded_anchor)) !== anchor_resolved) {
766
442
  return [];
767
443
  }
768
444
  const deleted = [];
@@ -780,7 +456,7 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
780
456
  }
781
457
  let lst = null;
782
458
  try {
783
- lst = fs3.lstatSync(target);
459
+ lst = fs2.lstatSync(target);
784
460
  } catch {
785
461
  lst = null;
786
462
  }
@@ -794,7 +470,7 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
794
470
  continue;
795
471
  }
796
472
  try {
797
- fs3.unlinkSync(target);
473
+ fs2.unlinkSync(target);
798
474
  } catch {
799
475
  continue;
800
476
  }
@@ -805,7 +481,7 @@ function reap_stale(tool_id, anchor, current_files, inventory, dry_run = false)
805
481
  return deleted;
806
482
  }
807
483
  function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_run = false) {
808
- const anchor_resolved = resolve_path(expanduser2(anchor));
484
+ const anchor_resolved = resolve_path(expanduser(anchor));
809
485
  const deleted = [];
810
486
  const prune_candidates = /* @__PURE__ */ new Set();
811
487
  const needle = `package: ${package_tag}`;
@@ -813,7 +489,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
813
489
  const root = dest_sub ? path2.join(anchor_resolved, dest_sub) : anchor_resolved;
814
490
  let root_stat;
815
491
  try {
816
- root_stat = fs3.statSync(root);
492
+ root_stat = fs2.statSync(root);
817
493
  } catch {
818
494
  continue;
819
495
  }
@@ -823,7 +499,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
823
499
  for (const md of rglob_md(root)) {
824
500
  let md_lst;
825
501
  try {
826
- md_lst = fs3.lstatSync(md);
502
+ md_lst = fs2.lstatSync(md);
827
503
  } catch {
828
504
  continue;
829
505
  }
@@ -841,7 +517,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
841
517
  }
842
518
  let head;
843
519
  try {
844
- head = fs3.readFileSync(md, { encoding: "utf-8" });
520
+ head = fs2.readFileSync(md, { encoding: "utf-8" });
845
521
  } catch {
846
522
  continue;
847
523
  }
@@ -850,7 +526,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
850
526
  }
851
527
  const end = head.indexOf("\n---", 3);
852
528
  const block = head.slice(0, end !== -1 ? end : head.length);
853
- const hit = splitlines2(block).some((line) => line.trim() === needle);
529
+ const hit = splitlines(block).some((line) => line.trim() === needle);
854
530
  if (!hit) {
855
531
  continue;
856
532
  }
@@ -859,7 +535,7 @@ function reap_tagged_orphans(anchor, dest_subs, current_files, package_tag, dry_
859
535
  continue;
860
536
  }
861
537
  try {
862
- fs3.unlinkSync(md);
538
+ fs2.unlinkSync(md);
863
539
  } catch {
864
540
  continue;
865
541
  }
@@ -879,7 +555,7 @@ function record_deploy(tool_id, anchor, current_files, inventory) {
879
555
  anchor: String(anchor),
880
556
  files: sorted_strings([...current_files])
881
557
  };
882
- inventory["schema_version"] = SCHEMA_VERSION2;
558
+ inventory["schema_version"] = SCHEMA_VERSION;
883
559
  return inventory;
884
560
  }
885
561
  function prune_empty_dirs(prune_candidates, anchor_resolved) {
@@ -890,7 +566,7 @@ function prune_empty_dirs(prune_candidates, anchor_resolved) {
890
566
  let node = start;
891
567
  while (node !== anchor_resolved && is_ancestor(anchor_resolved, node)) {
892
568
  try {
893
- fs3.rmdirSync(node);
569
+ fs2.rmdirSync(node);
894
570
  } catch {
895
571
  break;
896
572
  }
@@ -920,7 +596,7 @@ function rglob_md(root) {
920
596
  const walk = (dir) => {
921
597
  let names;
922
598
  try {
923
- names = fs3.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
599
+ names = fs2.readdirSync(dir).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
924
600
  } catch {
925
601
  return;
926
602
  }
@@ -928,7 +604,7 @@ function rglob_md(root) {
928
604
  const full = path2.join(dir, name);
929
605
  let lst;
930
606
  try {
931
- lst = fs3.lstatSync(full);
607
+ lst = fs2.lstatSync(full);
932
608
  } catch {
933
609
  continue;
934
610
  }
@@ -960,7 +636,7 @@ function difference(prev, current) {
960
636
  function sorted_strings(items) {
961
637
  return items.filter((i) => typeof i === "string").sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
962
638
  }
963
- function splitlines2(text) {
639
+ function splitlines(text) {
964
640
  const parts = text.split("\n");
965
641
  if (parts.length > 0 && parts[parts.length - 1] === "") {
966
642
  parts.pop();
@@ -1130,13 +806,6 @@ function printResiduals(toolIds, quiet, write = (s) => process.stdout.write(s))
1130
806
  }
1131
807
 
1132
808
  export {
1133
- SCHEMA_VERSIONS_SUPPORTED,
1134
- DEFAULT_DEPLOY_ROOTS,
1135
- manifest_path,
1136
- read_manifest,
1137
- write_manifest,
1138
- ScopeMismatchError,
1139
- upsert_tool,
1140
809
  atomicAppendLine,
1141
810
  probeHostCapabilities,
1142
811
  MANAGED_SIGNATURE,