@event4u/agent-config 15.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 (283) 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 +301 -347
  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 +77 -29
  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 +97 -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/rules/user-interaction.md +31 -30
  40. package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +3 -3
  41. package/dist/agent-src/skills/ai-council/SKILL.md +11 -3
  42. package/dist/agent-src/skills/api-design/data/manifest.json +3 -3
  43. package/dist/agent-src/skills/database/data/manifest.json +4 -4
  44. package/dist/agent-src/skills/database/data/query-tuning.csv +3 -3
  45. package/dist/agent-src/skills/design-review/SKILL.md +50 -0
  46. package/dist/agent-src/skills/error-handling-patterns/SKILL.md +9 -0
  47. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -4
  48. package/dist/agent-src/skills/experiment-loop/SKILL.md +31 -1
  49. package/dist/agent-src/skills/roadmap-writing/SKILL.md +1 -1
  50. package/dist/agent-src/skills/storybook-workshop/SKILL.md +42 -3
  51. package/dist/agent-src/skills/threat-modeling/SKILL.md +9 -4
  52. package/dist/agent-src/skills/threat-modeling/data/manifest.json +4 -4
  53. package/dist/agent-src/skills/verify-repair-loop/SKILL.md +37 -3
  54. package/dist/agent-src/templates/agent-settings.md +1 -1
  55. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  56. package/dist/agent-src/templates/roadmaps.md +188 -0
  57. package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  58. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  59. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  60. package/dist/cli-delegate/check_update_banner.js +40 -2
  61. package/dist/cli-delegate/chunk-4E2W63DA.js +335 -0
  62. package/dist/cli-delegate/chunk-5R7HOLAF.js +99 -0
  63. package/dist/cli-delegate/{chunk-IVBPRCQO.js → chunk-6KFEC3G7.js} +1 -1
  64. package/dist/cli-delegate/{chunk-2TAQ2K4V.js → chunk-6KM6ORRY.js} +55 -386
  65. package/dist/cli-delegate/{chunk-2XY7ILBT.js → chunk-FC75PGJE.js} +42 -2
  66. package/dist/cli-delegate/{chunk-GYC3VRYN.js → chunk-FXYUYU4N.js} +57 -13
  67. package/dist/cli-delegate/{chunk-55ACLDUE.js → chunk-GJCBB2UG.js} +168 -10
  68. package/dist/cli-delegate/{chunk-AK6HODNQ.js → chunk-HDVVGPQW.js} +873 -539
  69. package/dist/cli-delegate/chunk-NUHLI2RX.js +80 -0
  70. package/dist/cli-delegate/{chunk-HZ52BRGG.js → chunk-P6ZHP5W2.js} +15 -90
  71. package/dist/cli-delegate/{chunk-TYSY33MD.js → chunk-QJWAUMJW.js} +12 -2
  72. package/dist/cli-delegate/{chunk-57PN4GYJ.js → chunk-RGNIWTEA.js} +1 -1
  73. package/dist/cli-delegate/chunk-ROYYTEZU.js +39 -0
  74. package/dist/cli-delegate/{chunk-2KKXJW25.js → chunk-S3VFXMTM.js} +1 -1
  75. package/dist/cli-delegate/{chunk-3FKR64R5.js → chunk-UNCRJBT3.js} +31 -7
  76. package/dist/cli-delegate/{chunk-2DK2VJWG.js → chunk-WGXTVKCQ.js} +20 -6
  77. package/dist/cli-delegate/chunk-YDPILCOL.js +152 -0
  78. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  79. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  80. package/dist/cli-delegate/cmd_conformance.js +918 -325
  81. package/dist/cli-delegate/cmd_doctor.js +7 -5
  82. package/dist/cli-delegate/cmd_explain.js +5 -3
  83. package/dist/cli-delegate/cmd_export.js +9 -7
  84. package/dist/cli-delegate/cmd_fleet.js +4 -2
  85. package/dist/cli-delegate/cmd_handoff.js +6 -6
  86. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  87. package/dist/cli-delegate/cmd_migrate.js +2 -2
  88. package/dist/cli-delegate/cmd_packs_active.js +3 -2
  89. package/dist/cli-delegate/cmd_preflight.js +4 -2
  90. package/dist/cli-delegate/cmd_prune.js +10 -8
  91. package/dist/cli-delegate/cmd_route_audit.js +2 -2
  92. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  93. package/dist/cli-delegate/cmd_session_recycle.js +4 -4
  94. package/dist/cli-delegate/cmd_settings_get.js +28 -2
  95. package/dist/cli-delegate/cmd_settings_migrate.js +9 -7
  96. package/dist/cli-delegate/cmd_settings_set.js +14 -1
  97. package/dist/cli-delegate/cmd_sync.js +10 -8
  98. package/dist/cli-delegate/cmd_uninstall.js +16 -13
  99. package/dist/cli-delegate/cmd_update.js +1 -1
  100. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  101. package/dist/cli-delegate/cmd_validate.js +12 -10
  102. package/dist/cli-delegate/cmd_versions.js +1 -1
  103. package/dist/discovery/deprecation-report.md +1 -1
  104. package/dist/discovery/discovery-manifest.json +87 -40
  105. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  106. package/dist/discovery/discovery-manifest.summary.md +4 -4
  107. package/dist/discovery/dormancy-report.md +1 -1
  108. package/dist/discovery/orphan-report.md +1 -1
  109. package/dist/discovery/packs.json +10 -8
  110. package/dist/discovery/trust-report.md +3 -3
  111. package/dist/discovery/workspaces.json +8 -6
  112. package/dist/hooks/dispatch.js +2601 -1073
  113. package/dist/install/claudeRuleRewrite.js +14 -3
  114. package/dist/install/conflict.js +60 -10
  115. package/dist/install/conflictTracker.js +218 -0
  116. package/dist/install/fsPrimitives.js +54 -0
  117. package/dist/install/install.mjs +2008 -1481
  118. package/dist/install/manifestFiles.js +259 -0
  119. package/dist/install/preflight.js +14 -2
  120. package/dist/install/preserve.js +157 -0
  121. package/dist/install/recordedOwnership.js +132 -0
  122. package/dist/install/txlog.js +11 -2
  123. package/dist/mcp/registry-manifest.json +3 -3
  124. package/dist/mcp/server.json +2 -2
  125. package/dist/mcp/server.mjs +1612 -667
  126. package/dist/router.json +1 -1
  127. package/dist/scripts/_lib/agent_settings.js +3 -2
  128. package/dist/scripts/_lib/fs_atomic.js +167 -0
  129. package/dist/scripts/_lib/installed_lock.js +1 -1
  130. package/dist/scripts/_lib/installed_tools.js +460 -0
  131. package/dist/scripts/_lib/lean_projection_mode.js +3 -2
  132. package/dist/scripts/_lib/settings_renamed_keys.js +78 -0
  133. package/dist/server/io/yamlIO.js +50 -0
  134. package/dist/server/routes/install.js +8 -0
  135. package/dist/server/routes/wizard.js +9 -3
  136. package/dist/server/schemas/settings.js +17 -5
  137. package/dist/shared/missionExecution.js +97 -0
  138. package/dist/ui/assets/{index-D0jaCRPM.js → index-DH1xc62v.js} +17 -17
  139. package/dist/ui/index.html +1 -1
  140. package/docs/MIGRATION.md +103 -0
  141. package/docs/contracts/settings-classes.md +26 -7
  142. package/docs/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
  143. package/docs/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
  144. package/docs/guidelines/design-fidelity-routing.md +29 -0
  145. package/package.json +1 -1
  146. package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  147. package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  148. package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  149. package/src/config/agent-settings.template.yml +139 -27
  150. package/src/config/auto-rule-budget.json +16 -0
  151. package/src/config/ci-local-parity.yml +18 -5
  152. package/src/config/continuity-surface.json +28 -0
  153. package/src/config/gate-coverage.yml +146 -13
  154. package/src/config/gate-violation-baselines.json +6 -6
  155. package/src/config/hook-token-budget.json +2 -0
  156. package/src/config/host-injection-effect.json +1 -1
  157. package/src/config/loop-surfaces.yaml +215 -0
  158. package/src/config/platform-anchor.json +3 -2
  159. package/src/config/preamble-payload-budget.json +12 -7
  160. package/src/config/preamble-payload-exceptions.json +28 -0
  161. package/src/config/release-gate-locality.yml +11 -0
  162. package/src/config/routing-coverage-seed.json +18 -4
  163. package/src/config/rule-enforcement-baseline.json +0 -1
  164. package/src/install/claudeRuleRewrite.ts +16 -2
  165. package/src/install/conflict.ts +65 -9
  166. package/src/install/conflictTracker.ts +299 -0
  167. package/src/install/fsPrimitives.ts +54 -0
  168. package/src/install/manifestFiles.ts +312 -0
  169. package/src/install/preflight.ts +16 -2
  170. package/src/install/preserve.ts +205 -0
  171. package/src/install/recordedOwnership.ts +149 -0
  172. package/src/install/txlog.ts +11 -2
  173. package/src/install/types.ts +19 -4
  174. package/src/scripts/_cli/cmd_conformance.ts +88 -15
  175. package/src/scripts/_cli/cmd_doctor.ts +4 -3
  176. package/src/scripts/_cli/cmd_route_explain.ts +9 -2
  177. package/src/scripts/_cli/cmd_settings_get.ts +44 -0
  178. package/src/scripts/_cli/doctor_execution.ts +90 -0
  179. package/src/scripts/_dispatch.bash +3 -1
  180. package/src/scripts/_lib/activation_payload.ts +247 -0
  181. package/src/scripts/_lib/agent_settings.ts +4 -2
  182. package/src/scripts/_lib/authority_path.ts +102 -0
  183. package/src/scripts/_lib/base_ref_payload.ts +315 -0
  184. package/src/scripts/_lib/cascade_base.ts +94 -0
  185. package/src/scripts/_lib/changelog_eras.ts +7 -2
  186. package/src/scripts/_lib/continuation_ladder.ts +149 -2
  187. package/src/scripts/_lib/council_transport.ts +129 -0
  188. package/src/scripts/_lib/delivery_ready.ts +112 -0
  189. package/src/scripts/_lib/dropped_decision.ts +142 -0
  190. package/src/scripts/_lib/forge_protection.ts +267 -0
  191. package/src/scripts/_lib/hook_platform_keys.ts +27 -0
  192. package/src/scripts/_lib/installed_lock.ts +1 -1
  193. package/src/scripts/_lib/json_python_parity.ts +127 -0
  194. package/src/scripts/_lib/lean_projection_mode.ts +14 -3
  195. package/src/scripts/_lib/loop_surfaces.ts +382 -0
  196. package/src/scripts/_lib/measured_payload_ceiling.ts +424 -0
  197. package/src/scripts/_lib/mission_record.ts +190 -0
  198. package/src/scripts/_lib/obligation_frequency.ts +217 -0
  199. package/src/scripts/_lib/obligations.ts +402 -0
  200. package/src/scripts/_lib/orchestration_record.ts +11 -20
  201. package/src/scripts/_lib/payload_catalogue_completeness.ts +211 -0
  202. package/src/scripts/_lib/release_findings_ingest.ts +324 -0
  203. package/src/scripts/_lib/release_highlights.ts +199 -10
  204. package/src/scripts/_lib/release_holds.ts +493 -0
  205. package/src/scripts/_lib/release_migration_gate.ts +184 -0
  206. package/src/scripts/_lib/release_tag_dispatch.ts +63 -0
  207. package/src/scripts/_lib/review_baseline.ts +254 -0
  208. package/src/scripts/_lib/review_skipped_record.ts +61 -1
  209. package/src/scripts/_lib/rides_along.ts +102 -0
  210. package/src/scripts/_lib/settings_renamed_keys.ts +82 -0
  211. package/src/scripts/_lib/standing_bound_ratchet.ts +216 -103
  212. package/src/scripts/_lib/test_delta.ts +166 -0
  213. package/src/scripts/_lib/test_provenance.ts +171 -0
  214. package/src/scripts/_lib/turn_end_refusals.ts +51 -4
  215. package/src/scripts/_lib/typed_op_grant.ts +246 -0
  216. package/src/scripts/_lib/typed_op_watch.ts +185 -0
  217. package/src/scripts/ai_council/config.ts +8 -11
  218. package/src/scripts/ai_council/fallback_config.ts +5 -3
  219. package/src/scripts/ai_council/ownership_classes.ts +118 -0
  220. package/src/scripts/ask_block_census.ts +285 -15
  221. package/src/scripts/check_beta_review_markers.ts +35 -4
  222. package/src/scripts/check_enforcement_matrix.ts +624 -0
  223. package/src/scripts/check_finding_dispositions.ts +167 -16
  224. package/src/scripts/check_gate_reachability.ts +173 -10
  225. package/src/scripts/check_generator_sync.ts +954 -0
  226. package/src/scripts/check_held_object_arrivals.ts +381 -0
  227. package/src/scripts/check_preamble_payload_budget.ts +474 -124
  228. package/src/scripts/check_release_highlights.ts +33 -1
  229. package/src/scripts/check_release_holds.ts +567 -0
  230. package/src/scripts/check_release_published.ts +1 -1
  231. package/src/scripts/check_reply_consistency.ts +86 -17
  232. package/src/scripts/check_rule_projection_integrity.ts +22 -12
  233. package/src/scripts/check_test_delta.ts +294 -0
  234. package/src/scripts/check_test_weakening.ts +299 -0
  235. package/src/scripts/closure_scan.ts +333 -0
  236. package/src/scripts/compile_hook_manifest.ts +43 -3
  237. package/src/scripts/council_record_shape.ts +209 -0
  238. package/src/scripts/hook_manifest.json +1 -1
  239. package/src/scripts/hook_manifest.yaml +127 -12
  240. package/src/scripts/hooks/block_kernel_rule_writes.ts +12 -2
  241. package/src/scripts/hooks/concern_registry.ts +6 -0
  242. package/src/scripts/hooks/design_pass_hook.ts +128 -3
  243. package/src/scripts/hooks/end_review_nudge_hook.ts +101 -21
  244. package/src/scripts/hooks/evidence_independence.ts +96 -0
  245. package/src/scripts/hooks/memory_recall_hook.ts +540 -0
  246. package/src/scripts/hooks/obligation_settle_hook.ts +182 -0
  247. package/src/scripts/hooks/review_baseline_hook.ts +130 -0
  248. package/src/scripts/hooks/rule_inject_hook.ts +49 -1
  249. package/src/scripts/hooks/run_continuation_hook.ts +17 -20
  250. package/src/scripts/hooks/turn_end_gate_hook.ts +232 -14
  251. package/src/scripts/hooks_doctor.ts +89 -1
  252. package/src/scripts/hooks_status.ts +19 -0
  253. package/src/scripts/install.ts +107 -207
  254. package/src/scripts/interruption_report.ts +8 -2
  255. package/src/scripts/janitor.ts +15 -1
  256. package/src/scripts/lint_decision_classes.ts +464 -0
  257. package/src/scripts/lint_hook_manifest.ts +11 -0
  258. package/src/scripts/lint_major_migration_sections.ts +450 -0
  259. package/src/scripts/lint_plan_risk_register.ts +47 -3
  260. package/src/scripts/lint_roadmap_blockers.ts +61 -0
  261. package/src/scripts/lint_roadmap_producers.ts +202 -0
  262. package/src/scripts/measure_rule_budget.ts +101 -5
  263. package/src/scripts/measure_turn_end_gate.ts +302 -5
  264. package/src/scripts/new_roadmap.ts +37 -0
  265. package/src/scripts/orchestration_record.ts +0 -5
  266. package/src/scripts/release.ts +66 -162
  267. package/src/scripts/release_drill.ts +460 -15
  268. package/src/scripts/release_env.ts +1 -1
  269. package/src/scripts/release_publication.ts +52 -1
  270. package/src/scripts/report_enforcement_drift.ts +566 -0
  271. package/src/scripts/report_held_object_arrivals.ts +456 -0
  272. package/src/scripts/report_host_injection_effect.ts +3 -11
  273. package/src/scripts/report_standing_payload_by_host.ts +26 -152
  274. package/src/scripts/schemas/agent-settings.schema.json +23 -0
  275. package/src/scripts/schemas/command.schema.json +4 -0
  276. package/src/scripts/scope_growth.ts +219 -0
  277. package/src/scripts/sync_agent_settings.ts +140 -18
  278. package/src/scripts/trigger_eval_grandfather.json +0 -1
  279. package/src/scripts/ui_conformance_probe.ts +622 -0
  280. package/src/server/io/yamlIO.ts +48 -0
  281. package/src/server/schemas/settings.ts +31 -7
  282. package/src/shared/missionExecution.ts +126 -0
  283. package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
@@ -0,0 +1,80 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+
3
+ // src/scripts/_lib/agent_src.ts
4
+ import * as fs from "node:fs";
5
+ import * as path2 from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ // src/scripts/_lib/guidelines_lane.ts
9
+ import * as path from "node:path";
10
+ var GUIDELINES_SOURCE_REL = path.join("docs", "guidelines");
11
+
12
+ // src/scripts/_lib/agent_src.ts
13
+ var _HERE = path2.dirname(fileURLToPath(import.meta.url));
14
+ var _DEFAULT_ROOT = path2.resolve(_HERE, "..", "..", "..");
15
+ function _deriveRoots(root) {
16
+ const packages = path2.join(root, "packages");
17
+ const src = path2.join(root, "src");
18
+ return {
19
+ ROOT: root,
20
+ LEGACY_SRC: path2.join(root, ".agent-src.uncondensed"),
21
+ PACKAGES: packages,
22
+ PACKAGE_CORE: path2.join(packages, "core"),
23
+ SRC: src,
24
+ SRC_SKILLS: path2.join(src, "skills"),
25
+ SRC_RULES: path2.join(src, "rules"),
26
+ SRC_AGENT: path2.join(src, "agent-src"),
27
+ SRC_DOMAINS: path2.join(src, "domains")
28
+ };
29
+ }
30
+ var _roots = _deriveRoots(_DEFAULT_ROOT);
31
+ function _isDir(p) {
32
+ try {
33
+ return fs.statSync(p).isDirectory();
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+ function _exists(p) {
39
+ try {
40
+ fs.statSync(p);
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ function _iterdirSorted(p) {
47
+ let names;
48
+ try {
49
+ names = fs.readdirSync(p);
50
+ } catch {
51
+ return [];
52
+ }
53
+ names.sort();
54
+ return names.map((name) => path2.join(p, name));
55
+ }
56
+ function artefact_roots() {
57
+ const roots = [];
58
+ if (_exists(_roots.LEGACY_SRC)) {
59
+ roots.push(_roots.LEGACY_SRC);
60
+ }
61
+ if (_exists(_roots.PACKAGES)) {
62
+ for (const pkg of _iterdirSorted(_roots.PACKAGES)) {
63
+ const sub = path2.join(pkg, ".agent-src.uncondensed");
64
+ if (_isDir(sub)) {
65
+ roots.push(sub);
66
+ }
67
+ }
68
+ }
69
+ if (_isDir(_roots.SRC_AGENT)) {
70
+ roots.push(_roots.SRC_AGENT);
71
+ }
72
+ if (_isDir(_roots.SRC_SKILLS) || _isDir(_roots.SRC_RULES)) {
73
+ roots.push(_roots.SRC);
74
+ }
75
+ return roots;
76
+ }
77
+
78
+ export {
79
+ artefact_roots
80
+ };
@@ -1,90 +1,16 @@
1
1
  import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ artefact_roots
4
+ } from "./chunk-NUHLI2RX.js";
2
5
  import {
3
6
  DEFAULT_PROJECT_FILE,
4
7
  logger
5
- } from "./chunk-2XY7ILBT.js";
8
+ } from "./chunk-FC75PGJE.js";
6
9
 
7
10
  // src/scripts/config/profiles.ts
8
- import * as fs2 from "node:fs";
9
- import { createRequire } from "node:module";
10
- import * as path3 from "node:path";
11
-
12
- // src/scripts/_lib/agent_src.ts
13
11
  import * as fs from "node:fs";
14
- import * as path2 from "node:path";
15
- import { fileURLToPath } from "node:url";
16
-
17
- // src/scripts/_lib/guidelines_lane.ts
12
+ import { createRequire } from "node:module";
18
13
  import * as path from "node:path";
19
- var GUIDELINES_SOURCE_REL = path.join("docs", "guidelines");
20
-
21
- // src/scripts/_lib/agent_src.ts
22
- var _HERE = path2.dirname(fileURLToPath(import.meta.url));
23
- var _DEFAULT_ROOT = path2.resolve(_HERE, "..", "..", "..");
24
- function _deriveRoots(root) {
25
- const packages = path2.join(root, "packages");
26
- const src = path2.join(root, "src");
27
- return {
28
- ROOT: root,
29
- LEGACY_SRC: path2.join(root, ".agent-src.uncondensed"),
30
- PACKAGES: packages,
31
- PACKAGE_CORE: path2.join(packages, "core"),
32
- SRC: src,
33
- SRC_SKILLS: path2.join(src, "skills"),
34
- SRC_RULES: path2.join(src, "rules"),
35
- SRC_AGENT: path2.join(src, "agent-src"),
36
- SRC_DOMAINS: path2.join(src, "domains")
37
- };
38
- }
39
- var _roots = _deriveRoots(_DEFAULT_ROOT);
40
- function _isDir(p) {
41
- try {
42
- return fs.statSync(p).isDirectory();
43
- } catch {
44
- return false;
45
- }
46
- }
47
- function _exists(p) {
48
- try {
49
- fs.statSync(p);
50
- return true;
51
- } catch {
52
- return false;
53
- }
54
- }
55
- function _iterdirSorted(p) {
56
- let names;
57
- try {
58
- names = fs.readdirSync(p);
59
- } catch {
60
- return [];
61
- }
62
- names.sort();
63
- return names.map((name) => path2.join(p, name));
64
- }
65
- function artefact_roots() {
66
- const roots = [];
67
- if (_exists(_roots.LEGACY_SRC)) {
68
- roots.push(_roots.LEGACY_SRC);
69
- }
70
- if (_exists(_roots.PACKAGES)) {
71
- for (const pkg of _iterdirSorted(_roots.PACKAGES)) {
72
- const sub = path2.join(pkg, ".agent-src.uncondensed");
73
- if (_isDir(sub)) {
74
- roots.push(sub);
75
- }
76
- }
77
- }
78
- if (_isDir(_roots.SRC_AGENT)) {
79
- roots.push(_roots.SRC_AGENT);
80
- }
81
- if (_isDir(_roots.SRC_SKILLS) || _isDir(_roots.SRC_RULES)) {
82
- roots.push(_roots.SRC);
83
- }
84
- return roots;
85
- }
86
-
87
- // src/scripts/config/profiles.ts
88
14
  var _require = createRequire(import.meta.url);
89
15
  var PROFILE_ID_ENV = "AGENT_CONFIG_PROFILE_ID";
90
16
  var DEFAULT_PROFILE_ID = "developer";
@@ -135,7 +61,7 @@ function _load_yaml(p) {
135
61
  }
136
62
  let text;
137
63
  try {
138
- text = fs2.readFileSync(p, "utf-8");
64
+ text = fs.readFileSync(p, "utf-8");
139
65
  } catch (exc) {
140
66
  logger.warning("profile read failed for %s: %s", p, String(exc));
141
67
  return {};
@@ -153,8 +79,8 @@ function _load_yaml(p) {
153
79
  return _isPlainDict(data) ? data : {};
154
80
  }
155
81
  function profile_file(project_root, profile_id) {
156
- const legacy = path3.join(project_root, PROFILES_DIRNAME, `${profile_id}.yml`);
157
- if (_exists2(legacy)) {
82
+ const legacy = path.join(project_root, PROFILES_DIRNAME, `${profile_id}.yml`);
83
+ if (_exists(legacy)) {
158
84
  return legacy;
159
85
  }
160
86
  let roots;
@@ -164,8 +90,8 @@ function profile_file(project_root, profile_id) {
164
90
  return legacy;
165
91
  }
166
92
  for (const root of roots) {
167
- const candidate = path3.join(root, "profiles", `${profile_id}.yml`);
168
- if (_exists2(candidate)) {
93
+ const candidate = path.join(root, "profiles", `${profile_id}.yml`);
94
+ if (_exists(candidate)) {
169
95
  return candidate;
170
96
  }
171
97
  }
@@ -217,14 +143,14 @@ function _pick_id(pack_profile_id, user_settings, runtime_id) {
217
143
  }
218
144
  function resolve_profile(params) {
219
145
  const settings = params.user_settings ?? {};
220
- const settings_file = path3.join(params.project_root, DEFAULT_PROJECT_FILE);
146
+ const settings_file = path.join(params.project_root, DEFAULT_PROJECT_FILE);
221
147
  const [profile_id, source] = _pick_id(
222
148
  params.pack_profile_id ?? null,
223
149
  settings,
224
150
  params.runtime_id ?? null
225
151
  );
226
152
  if (profile_id === null) {
227
- if (_exists2(settings_file)) {
153
+ if (_exists(settings_file)) {
228
154
  return new ResolvedProfile({
229
155
  id: DEFAULT_PROFILE_ID,
230
156
  source: SOURCE_MISSING,
@@ -238,16 +164,16 @@ function resolve_profile(params) {
238
164
  );
239
165
  }
240
166
  const yaml_path = profile_file(params.project_root, profile_id);
241
- if (!_exists2(yaml_path)) {
167
+ if (!_exists(yaml_path)) {
242
168
  throw new ProfileError(
243
169
  `profile.id=${_repr(profile_id)} (${source}) but ${yaml_path} not found`
244
170
  );
245
171
  }
246
172
  return _build_resolved(profile_id, _load_yaml(yaml_path), { source });
247
173
  }
248
- function _exists2(p) {
174
+ function _exists(p) {
249
175
  try {
250
- fs2.statSync(p);
176
+ fs.statSync(p);
251
177
  return true;
252
178
  } catch {
253
179
  return false;
@@ -267,7 +193,6 @@ function _repr(s) {
267
193
  }
268
194
 
269
195
  export {
270
- artefact_roots,
271
196
  PROFILE_ID_ENV,
272
197
  SOURCE_MISSING,
273
198
  ProfileError,
@@ -891,7 +891,9 @@ var DETECTOR_IDS = [
891
891
  "promissory",
892
892
  "language",
893
893
  "verification",
894
- "completion"
894
+ "completion",
895
+ "pending-decision",
896
+ "untested"
895
897
  ];
896
898
  var REFUSAL_STATE_REL = path2.join("agents", "runtime", "state", "turn-end-gate");
897
899
  function refusalStateDir(workspaceRoot) {
@@ -916,7 +918,9 @@ function readSessionCounts(workspaceRoot, sessionId) {
916
918
  }
917
919
  }
918
920
  function emptyCounts() {
919
- return { promissory: 0, language: 0, verification: 0, completion: 0 };
921
+ const out = {};
922
+ for (const id of DETECTOR_IDS) out[id] = 0;
923
+ return out;
920
924
  }
921
925
  function isDetector(v) {
922
926
  return typeof v === "string" && DETECTOR_IDS.includes(v);
@@ -942,6 +946,9 @@ function parseRecord(raw) {
942
946
  if (typeof o["agent_config_version"] === "string") {
943
947
  rec.agent_config_version = o["agent_config_version"];
944
948
  }
949
+ if (typeof o["refused_prompt_id"] === "string") {
950
+ rec.refused_prompt_id = o["refused_prompt_id"];
951
+ }
945
952
  const counts = o["counts"];
946
953
  if (typeof counts === "object" && counts !== null && !Array.isArray(counts)) {
947
954
  const parsed = {};
@@ -985,6 +992,9 @@ function foldRefusal(prev, input) {
985
992
  else if (prev?.agent_config_version !== void 0) {
986
993
  rec.agent_config_version = prev.agent_config_version;
987
994
  }
995
+ if (input.promptId !== void 0 && input.promptId !== "") {
996
+ rec.refused_prompt_id = input.promptId;
997
+ }
988
998
  return rec;
989
999
  }
990
1000
  function readInstallBoundary() {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-F7DQWYR5.js";
5
5
  import {
6
6
  load_agent_settings
7
- } from "./chunk-2XY7ILBT.js";
7
+ } from "./chunk-FC75PGJE.js";
8
8
 
9
9
  // src/scripts/chat_history.ts
10
10
  import { createHash } from "node:crypto";
@@ -0,0 +1,39 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+
3
+ // src/shared/missionExecution.ts
4
+ var ESCALATION_LADDER = [
5
+ "independent",
6
+ "council",
7
+ "team",
8
+ "owner_owned_check"
9
+ ];
10
+ var FIX_LOOP_MAX_DEFAULT = 10;
11
+ var MISSION_AUTO_RUN_DEFAULT = true;
12
+ function resolveLocalAutoRun(inputs) {
13
+ if (inputs.configured) return { value: true, origin: "settings" };
14
+ if (!inputs.inMission) return { value: false, origin: "settings" };
15
+ const mission = inputs.missionValue ?? MISSION_AUTO_RUN_DEFAULT;
16
+ return mission ? { value: true, origin: "mission" } : { value: false, origin: "settings" };
17
+ }
18
+ function executionPostureFromOverrides(layers) {
19
+ const raw = {};
20
+ for (const [key, value] of layers) {
21
+ if (key === "execution.fix_loop_max") raw["fix_loop_max"] = value;
22
+ else if (key === "execution.escalation") raw["escalation"] = value;
23
+ }
24
+ return resolveExecutionPosture(raw);
25
+ }
26
+ function resolveExecutionPosture(raw) {
27
+ const block = raw ?? {};
28
+ const rawMax = block["fix_loop_max"];
29
+ const max = typeof rawMax === "number" && Number.isInteger(rawMax) && rawMax > 0 ? rawMax : FIX_LOOP_MAX_DEFAULT;
30
+ const rawLadder = block["escalation"];
31
+ const ladder = Array.isArray(rawLadder) && rawLadder.length > 0 && rawLadder.every((r) => typeof r === "string") ? rawLadder : ESCALATION_LADDER;
32
+ return { fix_loop_max: max, escalation: ladder };
33
+ }
34
+
35
+ export {
36
+ resolveLocalAutoRun,
37
+ executionPostureFromOverrides,
38
+ resolveExecutionPosture
39
+ };
@@ -3,7 +3,7 @@ import {
3
3
  pruneAgedRefusalState,
4
4
  readSessionCounts,
5
5
  statePathFor
6
- } from "./chunk-TYSY33MD.js";
6
+ } from "./chunk-QJWAUMJW.js";
7
7
  import {
8
8
  readHookStdin
9
9
  } from "./chunk-F7DQWYR5.js";
@@ -4068,6 +4068,8 @@ var leanProjectionHost = external_exports.enum(["claude-code", "cursor", "cline"
4068
4068
  var projectionMode = external_exports.enum(["legacy-all", "scoped"]);
4069
4069
  var memoryCadence = external_exports.enum(["auto", "always", "never"]);
4070
4070
  var projectAudience = external_exports.enum(["self", "internal", "client", "public"]);
4071
+ var deliveryMerge = external_exports.enum(["off", "on-green"]);
4072
+ var prTopology = external_exports.enum(["single", "stacked"]);
4071
4073
  var settingsSchema = external_exports.object({
4072
4074
  agent_config_version: external_exports.string().default("").describe(
4073
4075
  'Pin the package to an exact semver (e.g. "1.4.2") so all teammates load the same skill / rule set. Leave empty to track whatever is installed locally \u2014 useful for the maintainers of this package, risky for production projects.'
@@ -4096,7 +4098,7 @@ var settingsSchema = external_exports.object({
4096
4098
  ),
4097
4099
  lean_projection: external_exports.object({
4098
4100
  mode: leanProjectionMode.default("eager-all").describe(
4099
- "How the per-tool projector emits the rule layer. eager-all = every rule body inlined into every projection (safe; what an ABSENT key still resolves to, per ADR-267 decision point 4). thin = kernel rules full-bodied + non-kernel rules as router-resolved pointers (~45k GPT-tok lighter per session), with no delivery mechanism. delivery = thin stubs PLUS the rule-inject hook concern, which delivers a body back on a trigger match; this is the value the SHIPPED TEMPLATE carries for Claude Code since ADR-267, and the activation charge for it is paid in src/config/hook-token-budget.json (user_prompt_submit slot sum 4,096 -> 16,384)."
4101
+ "How the per-tool projector emits the rule layer. eager-all = every rule body inlined into every projection (safe; what an ABSENT key still resolves to, per ADR-267 decision point 4). thin = kernel rules full-bodied + non-kernel rules as router-resolved pointers (~45k GPT-tok lighter per session, exact-BPE \u2014 a different unit from the chars/4 figures below, never compare the two directly), with no delivery mechanism. delivery = thin stubs PLUS the rule-inject hook concern, which delivers a body back on a trigger match; this is the value the SHIPPED TEMPLATE carries for Claude Code since ADR-267. SAVING AND CHARGE, MEASURED TOGETHER so neither is published alone (2026-09-12, `check_preamble_payload_budget`): the rule bucket falls 122,769 -> 24,537 chars/4 tok per session on a thinned host (-80.0%), and a trigger match costs p50 6,728 B / p90 14,016 B / max 16,297 B per fire over 318 gate-open fires of the frozen tests/eval/routing-matrix corpus at the concern's 16,384 B cap. Bytes per fire and tokens per session are different denominators and are never summed; re-read both rather than quoting this line. The ceiling for that charge is registered in src/config/hook-token-budget.json (user_prompt_submit slot sum 4,096 -> 16,384)."
4100
4102
  ),
4101
4103
  hosts: external_exports.array(leanProjectionHost).default(["claude-code"]).describe(
4102
4104
  "Which hosts a thinning mode may thin (ADR-267). Absent resolves to [claude-code]. Only the three hosts with a per-rule rule tree are accepted, and this enum is the AUTHORING layer: an id outside it is a hard validation FAILURE here and under validate_agent_settings, never a warning. resolveLeanProjectionHosts is the READ-TIME backstop for a hand-edited .agent-settings.yml that passed neither, and THERE the id is dropped with a warning (R2 finding 6 \u2014 the two layers answer differently and neither said so). Every host outside this list receives exactly what eager-all writes, asserted byte-for-byte by check_host_tree_parity."
@@ -4185,6 +4187,17 @@ var settingsSchema = external_exports.object({
4185
4187
  "How the agent replies to PR review comments. create_review_comment = post a new review comment (works on every GitHub plan). replies_endpoint = thread the reply under the original comment (needs the newer REST endpoint). auto = detect at runtime, prefer threaded replies when available."
4186
4188
  )
4187
4189
  }),
4190
+ delivery: external_exports.object({
4191
+ merge: deliveryMerge.default("off").describe(
4192
+ "Whether a run may merge the pull request it produced. off (default) = the run ends at mergeable-green-and-open and says so. on-green = merge is permitted, and only when an object-bound grant covering {op: prod_merge, target: <base>} exists and the final head is required-check-green, target-current and tamper-checked. This key is a precondition, never the authorisation by itself; forge auto-merge is the mechanism, so branch protection stays the gate."
4193
+ ),
4194
+ wait_for_ci: external_exports.boolean().default(true).describe(
4195
+ "Whether the run stays alive until the required checks settle. true (default) = the run drives CI and reports the settled verdict. false = the run ends once the branch is pushed and the PR is open, leaving the checks to be read later. Independent of merge: a run may wait for CI without being allowed to merge."
4196
+ ),
4197
+ pr_topology: prTopology.default("single").describe(
4198
+ "How a mission's work is shaped into pull requests. single (default) = one branch, one pull request. stacked = a dependent series. stacked is never chosen by the agent and never asked about at roadmap creation \u2014 the owner plans it or it does not happen."
4199
+ )
4200
+ }),
4188
4201
  augment: external_exports.object({
4189
4202
  rules_use_symlinks: external_exports.boolean().default(false).describe(
4190
4203
  "When true, .augment/rules/*.md are symlinks into dist/agent-src/rules/ \u2014 edits flow back to source on save. When false (default), they are copies \u2014 safer on Windows and shared volumes, but rule edits in .augment/ are lost on the next `task sync`."
@@ -4226,8 +4239,8 @@ var settingsSchema = external_exports.object({
4226
4239
  skip_pre_run_gate: external_exports.boolean().default(true).describe(
4227
4240
  'Skip the /roadmap:process-* pre-run confirmation gate. true (default) starts processing immediately and surfaces the resolved config inline; false shows the numbered-options gate and waits. A genuine "which roadmap?" ambiguity always prompts regardless.'
4228
4241
  ),
4229
- quality_cadence: qualityCadence.default("end_of_roadmap").describe(
4230
- "When the agent runs the full quality / test suite during /roadmap:process-* runs. end_of_roadmap = once, after the last step (fastest, default). per_phase = after each phase boundary. per_step = after every single step (slowest, highest confidence)."
4242
+ quality_cadence: qualityCadence.default("per_phase").describe(
4243
+ "When the agent runs the full quality / test suite during /roadmap:process-* runs. per_phase = after each phase boundary (default since 2026-09-13 \u2014 end_of_roadmap lets errors compound across phases, which is expensive in a multi-phase autonomous run nobody is watching). end_of_roadmap = once, after the last step (fastest). per_step = after every single step (slowest, highest confidence)."
4231
4244
  ),
4232
4245
  dashboard_regen_cadence: regenCadence.default("every_5_steps").describe(
4233
4246
  "How often the agent regenerates agents/roadmaps/dashboard.md during a roadmap run. every_5_steps = batch the regen (default). per_step = after every step (freshest dashboard, highest subprocess overhead). phase_boundary = only at phase edges. A rename, phase add, or archive always regenerates immediately regardless."
@@ -4245,8 +4258,8 @@ var settingsSchema = external_exports.object({
4245
4258
  }).default({ max_cost_per_run_usd: 5, max_cost_per_rolling_7d_usd: 25 })
4246
4259
  }),
4247
4260
  planning: external_exports.object({
4248
- challenge_on_create: external_exports.boolean().default(true).describe(
4249
- "Gate C \u2014 plan-confidence gate before authoring. true (default) = a plan-artifact ask (/roadmap:create, roadmap-writing, /feature:plan, /feature:roadmap) first checks the four 95%-confidence conditions from /challenge-me vision; any gap routes into the interview (or the inline degrade protocol) before authoring, and a confident pass emits exactly one marker line. false = inert, plan asks author directly. An explicit user bypass always wins for that turn and is counted."
4261
+ closure_pass: external_exports.boolean().default(true).describe(
4262
+ `Gate C \u2014 plan-closure pass. true (default) = a plan-artifact ask (/roadmap:create, roadmap-writing, /feature:plan, /feature:roadmap, /roadmap:materialize, /implement-ticket, /jira-ticket, /analyze:inbox, /analyze:roadmap-repos) ends in a closure pass (/challenge-me closure): every foreseeable decision is closed at the lowest rung that owns it and written into the roadmap's "## Decisions" table, so a long run never meets a question planning could have closed. false = inert, plan asks author directly. An explicit user bypass always wins for that turn and is counted as a bypass rather than as an absent closure.`
4250
4263
  ),
4251
4264
  risk_review: external_exports.boolean().default(true).describe(
4252
4265
  'Gate R1 \u2014 plan-risk review. true (default) = every ready (non-draft) plan must carry a schema-valid "## Risk Register" section (ranked risks, mitigation + anchor per row, freshness marker, exact honest-null grammar), enforced by lint_plan_risk_register at pre-push + CI. false = escape hatch, the validator skips.'
@@ -4255,9 +4268,20 @@ var settingsSchema = external_exports.object({
4255
4268
  "Gate R2 \u2014 completion review at 100% roadmap completion / pre-PR. true (default) = a findings-before-fixes review by a fresh reviewer context must exist for the current diff hash (or an exact honest-null / skip declaration) before fix commits and PR creation, enforced by check_completion_review at pre-push + CI (CI authoritative; a crashed validator warns and allows). false = escape hatch, the validator skips."
4256
4269
  )
4257
4270
  }).default({}),
4271
+ execution: external_exports.object({
4272
+ fix_loop_max: external_exports.number().int().min(1).default(10).describe(
4273
+ "Consecutive failed fix attempts against one validation target before the escalation ladder reaches its terminal rung. Reaching the bound triggers a strategy change, never a question. Overridable globally, per project and per prompt."
4274
+ ),
4275
+ escalation: external_exports.array(external_exports.string()).default(["independent", "council", "team", "owner_owned_check"]).describe(
4276
+ "The escalation rungs, in order, walked when the fix-loop bound is reached: independent (another session or a provider-diverse reviewer), council, team, then owner_owned_check \u2014 which asks whether the residue is owner-owned, not whether to ask the owner now."
4277
+ )
4278
+ }).default({}),
4258
4279
  quality: external_exports.object({
4259
4280
  local_auto_run: external_exports.boolean().default(false).describe(
4260
- "Run quality tools (linters, type-checks, formatters) and the local test suite autonomously after edits. Off by default \u2014 the agent never runs quality tools proactively and does not ask; the user runs them manually (e.g. /quality-fix) and remote CI is the authoritative gate. The agent only runs a quality tool on an explicit ask, a concrete CI failure, or the new-gate carve-out. Turn on to restore autonomous pipeline runs."
4281
+ "Run quality tools (linters, type-checks, formatters) and the local test suite autonomously after edits, IN CHAT. Off by default \u2014 in a chat turn a human is present and remote CI is the authoritative gate, so a local full-pipeline run duplicates it at wall-clock cost. The agent only runs a quality tool on an explicit ask, a concrete CI failure, or the new-gate carve-out. A mission is governed by local_auto_run_in_mission instead."
4282
+ ),
4283
+ local_auto_run_in_mission: external_exports.boolean().default(true).describe(
4284
+ "Run quality tools autonomously inside a mission \u2014 an autonomous roadmap run with a claimed contract. On by default: nobody is waiting, the next action belongs to the agent itself, and a red found twenty steps later costs more than the run that would have caught it at step one. Inert outside a mission, and a mission never lowers local_auto_run: true."
4261
4285
  )
4262
4286
  }),
4263
4287
  design: external_exports.object({
@@ -4560,7 +4584,7 @@ var settingsSchema = external_exports.object({
4560
4584
  }).default({}),
4561
4585
  rtk_wrap: external_exports.object({
4562
4586
  enabled: external_exports.boolean().default(false).describe(
4563
- 'PreToolUse RTK-wrap nudge (token-saving Phase 3). Default off. When on AND the binary on PATH is verified as Rust Token Killer (a live two-stage identity probe \u2014 not a self-reported flag, and never a colliding same-name binary), warns (never blocks) "re-run wrapped with rtk" before a single verbose CLI command (git/npm/cargo/docker/\u2026) \u2014 upstream reports 60\u201390% output-token savings (their estimate). Skips completeness-critical / piped / compound commands and git diff. No-op when rtk is absent, unverified, or a different tool.'
4587
+ 'PreToolUse RTK-wrap nudge (token-saving Phase 3). Default off. When on AND the binary on PATH is verified as Rust Token Killer (a live two-stage identity probe \u2014 not a self-reported flag, and never a colliding same-name binary), warns (never blocks) "re-run wrapped with rtk" before a single verbose CLI command (git/npm/cargo/docker/\u2026) \u2014 upstream reports 60\u201390% output-token savings (their estimate). Skips completeness-critical / piped / compound commands and git diff. No-op when rtk is absent, unverified, or a different tool. Its own activation charge is one advisory line under the 1,024 B default concern cap in src/config/hook-token-budget.json; the per-fire distribution is UNMEASURED \u2014 stated rather than estimated, because the saving above is a third-party output-token claim and not a standing-payload reduction this package measured.'
4564
4588
  )
4565
4589
  }).default({}),
4566
4590
  design_slop: external_exports.object({
@@ -1,8 +1,10 @@
1
1
  import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
2
  import {
3
3
  buildInstallPlan,
4
+ classifyOwnership,
5
+ recordedHashesForRoot,
4
6
  sha256File
5
- } from "./chunk-523HCFYO.js";
7
+ } from "./chunk-YDPILCOL.js";
6
8
  import {
7
9
  detectToolPresence
8
10
  } from "./chunk-A4QJ6ENT.js";
@@ -17,23 +19,27 @@ import { existsSync } from "node:fs";
17
19
  function isJsonTarget(entry) {
18
20
  return entry.kind === "deployed" && entry.path.endsWith(".json");
19
21
  }
20
- function computeConflicts(plan) {
22
+ function computeConflicts(plan, recordedOverride) {
21
23
  if (plan.policy.force) return [];
24
+ const recorded = recordedOverride ?? recordedHashesForRoot(plan.root);
22
25
  const out = [];
23
26
  for (const entries of Object.values(plan.filesByTool)) {
24
27
  for (const entry of entries) {
25
28
  if (entry.kind === "bridge") continue;
26
29
  if (entry.sha256 === null) continue;
27
30
  if (!existsSync(entry.path)) continue;
28
- if (plan.policy.knownPaths.has(entry.path)) continue;
29
31
  const onDisk = sha256File(entry.path);
32
+ const ownership = classifyOwnership(recorded.get(entry.path), onDisk);
33
+ if (ownership === "recorded-unchanged") continue;
34
+ if (ownership === "unknown" && plan.policy.knownPaths.has(entry.path)) continue;
30
35
  if (onDisk === entry.sha256) continue;
31
36
  out.push({
32
37
  path: entry.path,
33
38
  kind: entry.kind,
34
39
  plannedSha256: entry.sha256,
35
40
  existingSha256: onDisk,
36
- mergeable: isJsonTarget(entry)
41
+ mergeable: isJsonTarget(entry),
42
+ ownership
37
43
  });
38
44
  }
39
45
  }
@@ -133,8 +139,16 @@ function checkConflicts(inputs) {
133
139
  id: "conflicts",
134
140
  severity: "warning",
135
141
  path: c.path,
136
- message: `existing file conflicts with planned ${c.kind} content`,
137
- remedy: "resolve interactively, or pass --force to overwrite"
142
+ message: c.ownership === "recorded-modified" ? `managed ${c.kind} file has been edited since we wrote it` : `existing file conflicts with planned ${c.kind} content`,
143
+ // A remedy here may only describe what an install actually does. Before
144
+ // the owner ruling of 2026-09-21 the writer overwrote every deployed
145
+ // file unconditionally, so the `recorded-modified` arm told the
146
+ // operator to back their edit up. It now preserves that file and stages
147
+ // the package content beside it, so the same sentence would be false in
148
+ // the opposite direction — it would understate a protection that ships.
149
+ // The `unknown` arm is unchanged: nothing is recorded for that path, so
150
+ // the writer still writes over it.
151
+ remedy: c.ownership === "recorded-modified" ? "installing preserves your edit and stages package content as <path>.agent-config.new; --force replaces it instead" : "back up this file \u2014 installing writes the planned content over it"
138
152
  }));
139
153
  }
140
154
  function checkHostDetection(inputs) {
@@ -0,0 +1,152 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ manifest_path
4
+ } from "./chunk-4E2W63DA.js";
5
+ import {
6
+ require_dist
7
+ } from "./chunk-OY53J6II.js";
8
+ import {
9
+ __toESM
10
+ } from "./chunk-J55WI3RR.js";
11
+
12
+ // src/install/plan.ts
13
+ import { createHash } from "node:crypto";
14
+ import { readFileSync, readdirSync, statSync } from "node:fs";
15
+ import { join, relative, resolve } from "node:path";
16
+ function sha256File(path) {
17
+ try {
18
+ const data = readFileSync(path);
19
+ return createHash("sha256").update(data).digest("hex");
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+ function fileEntry(path, kind, options) {
25
+ return {
26
+ path,
27
+ kind,
28
+ sha256: options.hashContent ? sha256File(path) : null
29
+ };
30
+ }
31
+ function walkSourceTree(dir) {
32
+ const out = [];
33
+ walkInto(dir, out);
34
+ return out;
35
+ }
36
+ function walkInto(dir, out) {
37
+ let entries;
38
+ try {
39
+ entries = readdirSync(dir).sort();
40
+ } catch {
41
+ return;
42
+ }
43
+ for (const name of entries) {
44
+ const full = join(dir, name);
45
+ let isDir;
46
+ try {
47
+ isDir = statSync(full).isDirectory();
48
+ } catch {
49
+ continue;
50
+ }
51
+ if (isDir) {
52
+ walkInto(full, out);
53
+ } else {
54
+ out.push(full);
55
+ }
56
+ }
57
+ }
58
+ function buildInstallPlan(inputs) {
59
+ const filesByTool = {};
60
+ for (const source of inputs.sources) {
61
+ const bucket = filesByTool[source.toolId] ?? [];
62
+ let files = walkSourceTree(source.srcDir);
63
+ if (source.fileFilter !== void 0) {
64
+ files = files.filter(source.fileFilter);
65
+ }
66
+ for (const srcFile of files) {
67
+ const rel = relative(source.srcDir, srcFile);
68
+ const destPath = resolve(source.destDir, rel);
69
+ bucket.push(
70
+ fileEntry(srcFile, source.kind, {
71
+ hashContent: source.kind !== "bridge"
72
+ })
73
+ );
74
+ bucket[bucket.length - 1] = {
75
+ ...bucket[bucket.length - 1],
76
+ path: destPath
77
+ };
78
+ }
79
+ filesByTool[source.toolId] = bucket;
80
+ }
81
+ for (const source of inputs.sources) {
82
+ if (!(source.toolId in filesByTool)) {
83
+ filesByTool[source.toolId] = [];
84
+ }
85
+ }
86
+ return {
87
+ version: 2,
88
+ target: inputs.target,
89
+ root: inputs.root,
90
+ filesByTool,
91
+ mergedKeysByTool: {},
92
+ policy: inputs.policy
93
+ };
94
+ }
95
+
96
+ // src/install/recordedOwnership.ts
97
+ var YAML = __toESM(require_dist(), 1);
98
+ import { existsSync, readFileSync as readFileSync2 } from "node:fs";
99
+ import { homedir } from "node:os";
100
+ import { isAbsolute, join as join2, resolve as resolve2 } from "node:path";
101
+ var NO_RECORDED_HASHES = /* @__PURE__ */ new Map();
102
+ function classifyOwnership(recordedSha256, onDiskSha256) {
103
+ if (recordedSha256 === void 0 || recordedSha256 === null) return "unknown";
104
+ if (onDiskSha256 === null) return "unknown";
105
+ return recordedSha256 === onDiskSha256 ? "recorded-unchanged" : "recorded-modified";
106
+ }
107
+ function readRecordedHashes(manifestPath, projectRoot) {
108
+ if (!existsSync(manifestPath)) return NO_RECORDED_HASHES;
109
+ let doc;
110
+ try {
111
+ doc = YAML.parse(readFileSync2(manifestPath, "utf8"));
112
+ } catch {
113
+ return NO_RECORDED_HASHES;
114
+ }
115
+ if (doc === null || typeof doc !== "object" || Array.isArray(doc)) return NO_RECORDED_HASHES;
116
+ const tools = doc["tools"];
117
+ if (!Array.isArray(tools)) return NO_RECORDED_HASHES;
118
+ const out = /* @__PURE__ */ new Map();
119
+ for (const tool of tools) {
120
+ if (tool === null || typeof tool !== "object" || Array.isArray(tool)) continue;
121
+ const files = tool["files"];
122
+ if (!Array.isArray(files)) continue;
123
+ for (const entry of files) {
124
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) continue;
125
+ const rec = entry;
126
+ const raw = rec["path"];
127
+ if (typeof raw !== "string" || raw.length === 0) continue;
128
+ const sha = rec["sha256"];
129
+ const expanded = expanduser(raw);
130
+ const target = isAbsolute(expanded) ? resolve2(expanded) : resolve2(projectRoot, expanded);
131
+ out.set(target, typeof sha === "string" && sha.length > 0 ? sha : null);
132
+ }
133
+ }
134
+ return out;
135
+ }
136
+ function expanduser(p) {
137
+ if (p === "~") return homedir();
138
+ if (p.startsWith("~/") || process.platform === "win32" && p.startsWith("~\\")) {
139
+ return join2(homedir(), p.slice(2));
140
+ }
141
+ return p;
142
+ }
143
+ function recordedHashesForRoot(root, env) {
144
+ return readRecordedHashes(manifest_path(root, env), root);
145
+ }
146
+
147
+ export {
148
+ classifyOwnership,
149
+ recordedHashesForRoot,
150
+ sha256File,
151
+ buildInstallPlan
152
+ };