@mmerterden/multi-agent-pipeline 20.39.0 → 20.40.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 (436) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +24 -9
  3. package/README.tr.md +22 -8
  4. package/docs/FIGMA_PIPELINE.md +1 -1
  5. package/docs/ecosystem.md +6 -6
  6. package/docs/facts.json +5 -5
  7. package/docs/features.md +4 -4
  8. package/index.js +13 -2
  9. package/install/_common.mjs +0 -126
  10. package/install/_dev-only-files.mjs +1 -0
  11. package/install/_managed-block.mjs +5 -18
  12. package/install/_unattended-profile.mjs +200 -30
  13. package/install/claude.mjs +29 -39
  14. package/install/codex.mjs +2 -1
  15. package/install/copilot.mjs +1 -23
  16. package/install/index.mjs +195 -54
  17. package/install/templates/claude-hooks.json +23 -1
  18. package/manifest.json +438 -381
  19. package/package.json +3 -2
  20. package/pipeline/agents/code-reviewer.md +1 -1
  21. package/pipeline/commands/multi-agent/SKILL.md +1 -1
  22. package/pipeline/commands/multi-agent/analysis/SKILL.md +1 -1
  23. package/pipeline/commands/multi-agent/autopilot/SKILL.md +3 -3
  24. package/pipeline/commands/multi-agent/autopilot-off/SKILL.md +15 -13
  25. package/pipeline/commands/multi-agent/garbage-collect/SKILL.md +7 -5
  26. package/pipeline/commands/multi-agent/health/SKILL.md +6 -4
  27. package/pipeline/commands/multi-agent/office-on/SKILL.md +2 -3
  28. package/pipeline/commands/multi-agent/office-pair/SKILL.md +23 -0
  29. package/pipeline/contract/CHANGELOG.md +27 -0
  30. package/pipeline/contract/README.md +2 -0
  31. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  32. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  33. package/pipeline/contract/fixtures/error-unsigned.json +1 -1
  34. package/pipeline/contract/fixtures/launch-plan.json +1 -1
  35. package/pipeline/contract/manifest.json +28 -2
  36. package/pipeline/contract/types/index.d.ts +178 -5
  37. package/pipeline/lib/agent-model-sync.mjs +2 -4
  38. package/pipeline/lib/args.mjs +194 -0
  39. package/pipeline/lib/autopilot-activation.sh +1 -1
  40. package/pipeline/lib/autopilot-state.sh +1 -1
  41. package/pipeline/lib/bg-launch.mjs +3 -3
  42. package/pipeline/lib/classify-intent.sh +9 -9
  43. package/pipeline/lib/claude-sessions.mjs +74 -5
  44. package/pipeline/lib/cli-help.mjs +80 -0
  45. package/pipeline/lib/credential-inventory.sh +23 -4
  46. package/pipeline/lib/credential-resolve.mjs +8 -12
  47. package/pipeline/lib/credential-store.sh +1 -1
  48. package/pipeline/lib/cross-repo.mjs +61 -0
  49. package/pipeline/lib/extract-conventions.sh +27 -27
  50. package/pipeline/lib/fetch-figma-annotations.sh +1 -1
  51. package/pipeline/lib/free-hosts.generated.mjs +22 -0
  52. package/pipeline/lib/glob-match.mjs +189 -0
  53. package/pipeline/lib/health-messages.mjs +351 -0
  54. package/pipeline/lib/identifier-scan.mjs +22 -11
  55. package/pipeline/lib/jira-family-write.sh +3 -3
  56. package/pipeline/lib/jira-publish.sh +1 -1
  57. package/pipeline/lib/json-file-lock.mjs +24 -23
  58. package/pipeline/lib/mcp-config-audit.mjs +1479 -0
  59. package/pipeline/lib/outbound-gate.mjs +8 -70
  60. package/pipeline/lib/owned-path-gate.mjs +6 -180
  61. package/pipeline/lib/plan-todos.sh +1 -1
  62. package/pipeline/lib/plugin-skill-roots.mjs +45 -1
  63. package/pipeline/lib/pr-request-location.mjs +3 -3
  64. package/pipeline/lib/prefs-value.mjs +122 -21
  65. package/pipeline/lib/regular-file.mjs +11 -6
  66. package/pipeline/lib/repo-profile-derive.mjs +138 -65
  67. package/pipeline/lib/repo-profile-root.mjs +52 -0
  68. package/pipeline/lib/repo-profile.mjs +5 -38
  69. package/pipeline/lib/review-watch.sh +1 -1
  70. package/pipeline/lib/run-worktree.mjs +147 -0
  71. package/pipeline/lib/run-writable.sh +85 -0
  72. package/pipeline/lib/safe-write.mjs +542 -0
  73. package/pipeline/lib/secret-patterns.generated.mjs +249 -0
  74. package/pipeline/lib/shadow-git.sh +1 -1
  75. package/pipeline/lib/slug.mjs +118 -0
  76. package/pipeline/lib/tdd-evidence.mjs +13 -13
  77. package/pipeline/lib/unattended-profile-check.mjs +75 -31
  78. package/pipeline/lib/unattended-tool-homes.mjs +1407 -0
  79. package/pipeline/lib/untrusted-fence.mjs +65 -0
  80. package/pipeline/lib/untrusted.mjs +13 -25
  81. package/pipeline/lib/user-facing.mjs +3 -5
  82. package/pipeline/lib/vercel-deploy.sh +2 -2
  83. package/pipeline/lib/web-push.mjs +198 -0
  84. package/pipeline/multi-agent-refs/analysis/locked.md +6 -6
  85. package/pipeline/multi-agent-refs/analysis-template.md +3 -3
  86. package/pipeline/multi-agent-refs/conventions-defaults.md +2 -2
  87. package/pipeline/multi-agent-refs/features/autopilot-operations.md +10 -7
  88. package/pipeline/multi-agent-refs/features/constitution.md +3 -3
  89. package/pipeline/multi-agent-refs/features/doctor.md +6 -1
  90. package/pipeline/multi-agent-refs/features/external-context-injection.md +1 -1
  91. package/pipeline/multi-agent-refs/features/office-remote-protocol.md +152 -1
  92. package/pipeline/multi-agent-refs/features/office-threat-model.md +1 -1
  93. package/pipeline/multi-agent-refs/features/phone-api.md +1 -1
  94. package/pipeline/multi-agent-refs/features/plan-critic.md +3 -3
  95. package/pipeline/multi-agent-refs/features/repo-profile.md +2 -2
  96. package/pipeline/multi-agent-refs/features/review-decision.md +21 -8
  97. package/pipeline/multi-agent-refs/features/scaffold.md +1 -1
  98. package/pipeline/multi-agent-refs/features/unattended-gates.md +3 -3
  99. package/pipeline/multi-agent-refs/features/unattended-security.md +486 -22
  100. package/pipeline/multi-agent-refs/features/usage-reporting.md +60 -0
  101. package/pipeline/multi-agent-refs/garbage-collect/phases.md +3 -1
  102. package/pipeline/multi-agent-refs/help/en.md +2 -2
  103. package/pipeline/multi-agent-refs/help/tr.md +7 -7
  104. package/pipeline/multi-agent-refs/keychain.md +1 -0
  105. package/pipeline/multi-agent-refs/knowledge.md +1 -0
  106. package/pipeline/multi-agent-refs/orchestrator/skill-loading.md +1 -1
  107. package/pipeline/multi-agent-refs/outside-the-pipeline.md +1 -0
  108. package/pipeline/multi-agent-refs/phases/phase-3-review.md +4 -3
  109. package/pipeline/multi-agent-refs/phases/phase-5-report.md +6 -4
  110. package/pipeline/multi-agent-refs/phases.md +1 -1
  111. package/pipeline/multi-agent-refs/sync/stack-plugins.md +1 -1
  112. package/pipeline/multi-agent-refs/test-gen/stages.md +1 -1
  113. package/pipeline/multi-agent-refs/tracker-contract.md +2 -2
  114. package/pipeline/multi-agent-refs/unattended-contract.md +1 -1
  115. package/pipeline/office/assets/app_icon_180.png +0 -0
  116. package/pipeline/office/assets/app_icon_192.png +0 -0
  117. package/pipeline/office/assets/app_icon_512.png +0 -0
  118. package/pipeline/office/index.html +502 -6
  119. package/pipeline/office/toolkit.json +1 -1
  120. package/pipeline/preferences-template.json +2 -1
  121. package/pipeline/rules/figma-pipeline.md +1 -1
  122. package/pipeline/rules/outside-the-pipeline.md +3 -3
  123. package/pipeline/schemas/agent-state.schema.json +1 -1
  124. package/pipeline/schemas/analysis-spec.schema.json +1 -1
  125. package/pipeline/schemas/autopilot-config.schema.json +1 -1
  126. package/pipeline/schemas/autopilot-off-request.schema.json +1 -1
  127. package/pipeline/schemas/autopilot-off.schema.json +8 -2
  128. package/pipeline/schemas/dev-critic-output.schema.json +1 -1
  129. package/pipeline/schemas/launch.json +6 -6
  130. package/pipeline/schemas/learnings-ledger.schema.json +8 -0
  131. package/pipeline/schemas/office-archive.schema.json +168 -0
  132. package/pipeline/schemas/office-server-room.schema.json +283 -0
  133. package/pipeline/schemas/prefs.schema.json +17 -1
  134. package/pipeline/schemas/runs-index.schema.json +1 -1
  135. package/pipeline/schemas/secret-patterns.json +257 -1
  136. package/pipeline/schemas/secret-patterns.schema.json +25 -4
  137. package/pipeline/schemas/toolkit-path-params.json +1077 -0
  138. package/pipeline/schemas/toolkit-path-params.schema.json +36 -0
  139. package/pipeline/schemas/unattended-policy.json +10 -1
  140. package/pipeline/schemas/unattended-policy.schema.json +4 -0
  141. package/pipeline/schemas/unattended-profile.json +93 -4
  142. package/pipeline/schemas/unattended-profile.schema.json +10 -0
  143. package/pipeline/scripts/_active-run.mjs +6 -3
  144. package/pipeline/scripts/_analysis-doc-diagrams.mjs +115 -0
  145. package/pipeline/scripts/_analysis-doc-markers.mjs +252 -0
  146. package/pipeline/scripts/_analysis-doc-redesign.mjs +160 -0
  147. package/pipeline/scripts/_analysis-doc-rules.mjs +191 -0
  148. package/pipeline/scripts/_analysis-doc-shapes.mjs +196 -0
  149. package/pipeline/scripts/_analysis-doc-structure.mjs +313 -0
  150. package/pipeline/scripts/_autopilot-ops.mjs +12 -3
  151. package/pipeline/scripts/_contract-core.mjs +282 -0
  152. package/pipeline/scripts/_contract-office-page.mjs +108 -0
  153. package/pipeline/scripts/_contract-routes-catalog.mjs +84 -0
  154. package/pipeline/scripts/_contract-routes-office.mjs +133 -0
  155. package/pipeline/scripts/_contract-routes-ops.mjs +538 -0
  156. package/pipeline/scripts/_contract-routes-repos.mjs +270 -0
  157. package/pipeline/scripts/_contract-routes-runs.mjs +468 -0
  158. package/pipeline/scripts/_contract-routes-work.mjs +255 -0
  159. package/pipeline/scripts/_lint-suppression.mjs +1067 -0
  160. package/pipeline/scripts/_memory-policy.mjs +40 -26
  161. package/pipeline/scripts/_renamed-skills.mjs +11 -2
  162. package/pipeline/scripts/_retrieval.mjs +2 -6
  163. package/pipeline/scripts/_secret-scan.mjs +8 -2
  164. package/pipeline/scripts/_stack-adapter.mjs +28 -19
  165. package/pipeline/scripts/_test-gaming.mjs +44 -6
  166. package/pipeline/scripts/_unified-diff.mjs +2 -2
  167. package/pipeline/scripts/activity-snapshot.mjs +36 -15
  168. package/pipeline/scripts/analysis-conform-coverage.mjs +3 -0
  169. package/pipeline/scripts/analysis-sources.mjs +3 -0
  170. package/pipeline/scripts/analysis-story-tree.mjs +6 -5
  171. package/pipeline/scripts/analysis-tickets-writeback.mjs +7 -0
  172. package/pipeline/scripts/anonymize-findings.mjs +1 -1
  173. package/pipeline/scripts/answer-check.mjs +3 -0
  174. package/pipeline/scripts/answer-question.mjs +22 -9
  175. package/pipeline/scripts/argv-secret-scan.mjs +3 -0
  176. package/pipeline/scripts/audit-log.sh +22 -2
  177. package/pipeline/scripts/autopilot-arming.mjs +6 -5
  178. package/pipeline/scripts/autopilot-awake.mjs +3 -0
  179. package/pipeline/scripts/autopilot-control.mjs +31 -34
  180. package/pipeline/scripts/autopilot-intake.mjs +3 -0
  181. package/pipeline/scripts/autopilot-publish.mjs +34 -13
  182. package/pipeline/scripts/autopilot-runner.mjs +289 -86
  183. package/pipeline/scripts/autopilot-status.sh +1 -1
  184. package/pipeline/scripts/base-branch-candidates.mjs +7 -0
  185. package/pipeline/scripts/bug-bash.mjs +3 -0
  186. package/pipeline/scripts/build-references.mjs +3 -0
  187. package/pipeline/scripts/build-skills-index.mjs +16 -5
  188. package/pipeline/scripts/build-stack-plugins.mjs +3 -0
  189. package/pipeline/scripts/bulk-read.sh +1 -1
  190. package/pipeline/scripts/capture-evidence.sh +1 -1
  191. package/pipeline/scripts/capture-flush.sh +52 -2
  192. package/pipeline/scripts/check-derived-drift.mjs +5 -2
  193. package/pipeline/scripts/classify-plan-safety.mjs +7 -0
  194. package/pipeline/scripts/commands.mjs +21 -11
  195. package/pipeline/scripts/confirm-command.mjs +3 -0
  196. package/pipeline/scripts/confluence-readback.mjs +3 -0
  197. package/pipeline/scripts/constitution.mjs +6 -13
  198. package/pipeline/scripts/contract-server.mjs +710 -2317
  199. package/pipeline/scripts/cost-analyze.mjs +8 -18
  200. package/pipeline/scripts/cost-budget-check.mjs +4 -15
  201. package/pipeline/scripts/council-view.mjs +3 -0
  202. package/pipeline/scripts/crush-json.mjs +3 -0
  203. package/pipeline/scripts/debt-ledger.mjs +12 -37
  204. package/pipeline/scripts/decisions-log.mjs +14 -8
  205. package/pipeline/scripts/diff-explain.mjs +8 -16
  206. package/pipeline/scripts/diff-risk-score.mjs +5 -15
  207. package/pipeline/scripts/doctor.mjs +47 -11
  208. package/pipeline/scripts/edit-syntax-gate.mjs +5 -10
  209. package/pipeline/scripts/estimate.mjs +5 -10
  210. package/pipeline/scripts/evidence-gate.mjs +5 -21
  211. package/pipeline/scripts/explore-findings.mjs +3 -0
  212. package/pipeline/scripts/feedback-send.mjs +5 -6
  213. package/pipeline/scripts/file-context.mjs +20 -22
  214. package/pipeline/scripts/find-polluter.mjs +29 -17
  215. package/pipeline/scripts/finding-fingerprint.mjs +22 -9
  216. package/pipeline/scripts/gate-ledger.mjs +25 -21
  217. package/pipeline/scripts/gc-abandoned.sh +143 -40
  218. package/pipeline/scripts/gc-plan.mjs +8 -1
  219. package/pipeline/scripts/gc-refs.sh +4 -4
  220. package/pipeline/scripts/gc-tmp.sh +3 -3
  221. package/pipeline/scripts/gc-worktrees.sh +4 -4
  222. package/pipeline/scripts/gen-facts.mjs +3 -0
  223. package/pipeline/scripts/gen-free-hosts.mjs +132 -0
  224. package/pipeline/scripts/gen-mode-dispatch.mjs +11 -3
  225. package/pipeline/scripts/gen-secret-patterns.mjs +263 -0
  226. package/pipeline/scripts/gen-skills-index.mjs +11 -1
  227. package/pipeline/scripts/graph-affected.mjs +3 -0
  228. package/pipeline/scripts/graph-build.mjs +6 -18
  229. package/pipeline/scripts/graph-confirm.mjs +3 -0
  230. package/pipeline/scripts/graph-hint.mjs +13 -19
  231. package/pipeline/scripts/graph-links.mjs +3 -0
  232. package/pipeline/scripts/graph-mermaid.mjs +3 -0
  233. package/pipeline/scripts/graph-query.mjs +3 -0
  234. package/pipeline/scripts/handle-diff-audit.mjs +20 -12
  235. package/pipeline/scripts/health-report.mjs +201 -158
  236. package/pipeline/scripts/host-hooks.mjs +3 -0
  237. package/pipeline/scripts/issues.mjs +26 -11
  238. package/pipeline/scripts/jira-family.mjs +14 -23
  239. package/pipeline/scripts/jira-search.sh +1 -1
  240. package/pipeline/scripts/jira-wiki-escape.mjs +10 -0
  241. package/pipeline/scripts/job-launch.mjs +107 -8
  242. package/pipeline/scripts/launch-request.mjs +6 -2
  243. package/pipeline/scripts/learn-from-transcripts.mjs +14 -25
  244. package/pipeline/scripts/learnings-ledger.mjs +113 -81
  245. package/pipeline/scripts/localize-commands.mjs +7 -0
  246. package/pipeline/scripts/log-metric.sh +26 -8
  247. package/pipeline/scripts/match-skills.mjs +7 -0
  248. package/pipeline/scripts/mcp-config-audit.mjs +130 -0
  249. package/pipeline/scripts/migrate-prefs.mjs +34 -21
  250. package/pipeline/scripts/migrate-state.mjs +3 -0
  251. package/pipeline/scripts/mutation-probe.mjs +51 -32
  252. package/pipeline/scripts/note-agent-event.mjs +7 -14
  253. package/pipeline/scripts/note-skill-use.mjs +273 -0
  254. package/pipeline/scripts/note-skill-use.sh +19 -0
  255. package/pipeline/scripts/observations.mjs +17 -16
  256. package/pipeline/scripts/office-archive.mjs +267 -0
  257. package/pipeline/scripts/office-build.mjs +117 -8
  258. package/pipeline/scripts/office-control.mjs +7 -3
  259. package/pipeline/scripts/office-credentials.mjs +3 -0
  260. package/pipeline/scripts/office-ledger.mjs +3 -0
  261. package/pipeline/scripts/office-memory.mjs +6 -3
  262. package/pipeline/scripts/office-pair.mjs +24 -3
  263. package/pipeline/scripts/office-prune.mjs +3 -0
  264. package/pipeline/scripts/office-push.mjs +613 -0
  265. package/pipeline/scripts/office-remote-client.mjs +30 -3
  266. package/pipeline/scripts/office-server-room.mjs +435 -0
  267. package/pipeline/scripts/office-settings.mjs +4 -4
  268. package/pipeline/scripts/office-webapp.mjs +59 -0
  269. package/pipeline/scripts/offload-ref.sh +1 -1
  270. package/pipeline/scripts/open-questions-gate.mjs +25 -12
  271. package/pipeline/scripts/output-quality-check.sh +1 -1
  272. package/pipeline/scripts/owned-path-gate.mjs +22 -11
  273. package/pipeline/scripts/package-manager.mjs +7 -0
  274. package/pipeline/scripts/parity-score.mjs +3 -0
  275. package/pipeline/scripts/phase-tracker.sh +179 -35
  276. package/pipeline/scripts/phase0-exit-gate.mjs +4 -1
  277. package/pipeline/scripts/phone-devices.mjs +32 -16
  278. package/pipeline/scripts/plan-complexity.mjs +17 -13
  279. package/pipeline/scripts/plan-coverage-gate.mjs +3 -2
  280. package/pipeline/scripts/plan-critique-gate.mjs +22 -12
  281. package/pipeline/scripts/plan-remote-links.mjs +18 -11
  282. package/pipeline/scripts/plugin-refresh.sh +1 -1
  283. package/pipeline/scripts/pr-request.mjs +3 -0
  284. package/pipeline/scripts/pr-timeline.mjs +13 -9
  285. package/pipeline/scripts/pre-commit-check.sh +175 -124
  286. package/pipeline/scripts/pre-push-check.sh +12 -0
  287. package/pipeline/scripts/probe-evidence-capability.sh +1 -1
  288. package/pipeline/scripts/probe-store-key.mjs +33 -15
  289. package/pipeline/scripts/product-context.mjs +25 -26
  290. package/pipeline/scripts/prune-logs.sh +4 -4
  291. package/pipeline/scripts/purge.sh +2 -2
  292. package/pipeline/scripts/record-phase.mjs +19 -9
  293. package/pipeline/scripts/release-notes.mjs +3 -0
  294. package/pipeline/scripts/render-flow-run.mjs +48 -32
  295. package/pipeline/scripts/render-jira-evidence.mjs +18 -11
  296. package/pipeline/scripts/render-work-summary.sh +1 -1
  297. package/pipeline/scripts/repo-map.mjs +35 -20
  298. package/pipeline/scripts/repo-profile.mjs +21 -21
  299. package/pipeline/scripts/repo-recommend.mjs +22 -9
  300. package/pipeline/scripts/research-gate.mjs +20 -12
  301. package/pipeline/scripts/review-decision-gate.mjs +209 -33
  302. package/pipeline/scripts/review-delta.mjs +36 -15
  303. package/pipeline/scripts/review-file-filter.mjs +3 -0
  304. package/pipeline/scripts/review-scope.mjs +3 -0
  305. package/pipeline/scripts/rework-base.mjs +3 -0
  306. package/pipeline/scripts/rework-escalation.mjs +25 -20
  307. package/pipeline/scripts/rework-rulings.mjs +3 -0
  308. package/pipeline/scripts/routine-registry.mjs +27 -20
  309. package/pipeline/scripts/run-aggregator.mjs +15 -16
  310. package/pipeline/scripts/run-commit-check.mjs +3 -0
  311. package/pipeline/scripts/run-kill.mjs +6 -14
  312. package/pipeline/scripts/run-log.mjs +32 -15
  313. package/pipeline/scripts/run-metrics.mjs +7 -0
  314. package/pipeline/scripts/run-results.mjs +3 -0
  315. package/pipeline/scripts/run-scope-guard.mjs +3 -0
  316. package/pipeline/scripts/run-stop-guard.mjs +15 -9
  317. package/pipeline/scripts/run-write.mjs +400 -0
  318. package/pipeline/scripts/runs-index.mjs +22 -15
  319. package/pipeline/scripts/scaffold-gate.mjs +26 -9
  320. package/pipeline/scripts/scan-agent-config.sh +39 -11
  321. package/pipeline/scripts/scan-skills.sh +17 -6
  322. package/pipeline/scripts/scenario-audit.mjs +3 -0
  323. package/pipeline/scripts/scope-check-gate.mjs +21 -11
  324. package/pipeline/scripts/search-logs.sh +1 -1
  325. package/pipeline/scripts/security-evidence-gate.mjs +23 -12
  326. package/pipeline/scripts/service-read.mjs +6 -9
  327. package/pipeline/scripts/skill-candidates.mjs +3 -0
  328. package/pipeline/scripts/skill-conformance.mjs +29 -15
  329. package/pipeline/scripts/skill-siblings.mjs +34 -4
  330. package/pipeline/scripts/skill-usage.mjs +379 -0
  331. package/pipeline/scripts/smoke-schema-validation.sh +1 -1
  332. package/pipeline/scripts/spec-consistency-gate.mjs +22 -12
  333. package/pipeline/scripts/stack-toggle.mjs +3 -0
  334. package/pipeline/scripts/status-overview.mjs +2 -2
  335. package/pipeline/scripts/steer-run.mjs +3 -0
  336. package/pipeline/scripts/symbol-existence-gate.mjs +22 -14
  337. package/pipeline/scripts/sync-skill-copies.mjs +141 -0
  338. package/pipeline/scripts/system-status.mjs +3 -0
  339. package/pipeline/scripts/task-mirror.mjs +59 -22
  340. package/pipeline/scripts/test-classify.mjs +15 -10
  341. package/pipeline/scripts/test-gap-scan.mjs +5 -15
  342. package/pipeline/scripts/test-gen-gate.mjs +19 -10
  343. package/pipeline/scripts/test-gen-state.mjs +16 -15
  344. package/pipeline/scripts/test-integrity-gate.mjs +113 -16
  345. package/pipeline/scripts/test-stability-gate.mjs +3 -0
  346. package/pipeline/scripts/test-strength.mjs +39 -18
  347. package/pipeline/scripts/test-summary.mjs +24 -16
  348. package/pipeline/scripts/token-budget-report.mjs +18 -8
  349. package/pipeline/scripts/toolkit-tools.mjs +19 -4
  350. package/pipeline/scripts/transcript-index.mjs +38 -18
  351. package/pipeline/scripts/triage-memory.mjs +20 -59
  352. package/pipeline/scripts/unattended_policy.py +1828 -27
  353. package/pipeline/scripts/uninstall.mjs +120 -13
  354. package/pipeline/scripts/update-check.sh +1 -1
  355. package/pipeline/scripts/update-issue-progress.sh +6 -6
  356. package/pipeline/scripts/usage-identity.mjs +18 -7
  357. package/pipeline/scripts/usage-register-beacon.mjs +3 -0
  358. package/pipeline/scripts/usage-register.mjs +21 -12
  359. package/pipeline/scripts/usage-report.mjs +27 -11
  360. package/pipeline/scripts/user-test-handoff.sh +1 -1
  361. package/pipeline/scripts/validate-analysis-doc.mjs +163 -1240
  362. package/pipeline/scripts/validate-analysis.mjs +7 -0
  363. package/pipeline/scripts/validate-code-graph.mjs +7 -0
  364. package/pipeline/scripts/validate-complaint-doc.mjs +3 -0
  365. package/pipeline/scripts/validate-diff-risk.mjs +7 -0
  366. package/pipeline/scripts/validate-planning.mjs +3 -0
  367. package/pipeline/scripts/validate-reviewer.mjs +7 -0
  368. package/pipeline/scripts/validate-state.mjs +7 -0
  369. package/pipeline/scripts/validate-test-gap.mjs +7 -0
  370. package/pipeline/scripts/validate-triage.mjs +7 -0
  371. package/pipeline/scripts/valven-gate.mjs +14 -14
  372. package/pipeline/scripts/valven-port.mjs +14 -13
  373. package/pipeline/scripts/valven-split.mjs +14 -13
  374. package/pipeline/scripts/verify-citations.mjs +13 -14
  375. package/pipeline/scripts/verify.mjs +3 -0
  376. package/pipeline/scripts/work-items.mjs +5 -5
  377. package/pipeline/scripts/worktree-finalize.sh +3 -3
  378. package/pipeline/scripts/worktree-prepare-all.mjs +3 -0
  379. package/pipeline/scripts/worktrees.mjs +3 -0
  380. package/pipeline/scripts/write-state.mjs +33 -23
  381. package/pipeline/scripts/write-store-config.mjs +5 -1
  382. package/pipeline/skills/.skill-manifest.json +40 -40
  383. package/pipeline/skills/.skills-index.json +32 -32
  384. package/pipeline/skills/shared/README.md +31 -31
  385. package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
  386. package/pipeline/skills/shared/core/multi-agent-autopilot-off/SKILL.md +15 -13
  387. package/pipeline/skills/shared/core/multi-agent-health/SKILL.md +6 -2
  388. package/pipeline/skills/shared/external/agent-introspection-debugging/SKILL.md +1 -6
  389. package/pipeline/skills/shared/external/android-performance/SKILL.md +1 -1
  390. package/pipeline/skills/shared/external/app-clips/SKILL.md +1 -1
  391. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +1 -1
  392. package/pipeline/skills/shared/external/app-store-release-notes/SKILL.md +1 -1
  393. package/pipeline/skills/shared/external/app-store-release-notes/evals/trigger-eval.json +11 -0
  394. package/pipeline/skills/shared/external/app-store-review/SKILL.md +1 -1
  395. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +1 -1
  396. package/pipeline/skills/shared/external/avkit/SKILL.md +1 -1
  397. package/pipeline/skills/shared/external/context-compression/SKILL.md +1 -1
  398. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +1 -1
  399. package/pipeline/skills/shared/external/core-data/SKILL.md +1 -1
  400. package/pipeline/skills/shared/external/council/SKILL.md +1 -6
  401. package/pipeline/skills/shared/external/e2e-testing/SKILL.md +1 -9
  402. package/pipeline/skills/shared/external/fix-review-verdicts/SKILL.md +3 -0
  403. package/pipeline/skills/shared/external/humanizer/SKILL.md +1 -5
  404. package/pipeline/skills/shared/external/ios-coding-standard/references/lint-local.sh +1 -1
  405. package/pipeline/skills/shared/external/ios-localization/SKILL.md +1 -1
  406. package/pipeline/skills/shared/external/ios-security/SKILL.md +1 -1
  407. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +1 -1
  408. package/pipeline/skills/shared/external/kotlin-coroutines-expert/references/patterns.md +1 -1
  409. package/pipeline/skills/shared/external/live-activities/SKILL.md +1 -1
  410. package/pipeline/skills/shared/external/macos-app-distribution/SKILL.md +1 -1
  411. package/pipeline/skills/shared/external/macos-app-distribution/evals/trigger-eval.json +10 -0
  412. package/pipeline/skills/shared/external/macos-menubar-utility/SKILL.md +1 -1
  413. package/pipeline/skills/shared/external/macos-menubar-utility/evals/trigger-eval.json +10 -0
  414. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +1 -1
  415. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +1 -1
  416. package/pipeline/skills/shared/external/push-notifications/SKILL.md +1 -1
  417. package/pipeline/skills/shared/external/search-first/SKILL.md +1 -6
  418. package/pipeline/skills/shared/external/skill-creator/SKILL.md +1 -1
  419. package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
  420. package/pipeline/skills/shared/external/swift-concurrency-fix/SKILL.md +1 -1
  421. package/pipeline/skills/shared/external/swift-concurrency-fix/evals/trigger-eval.json +11 -0
  422. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +1 -1
  423. package/pipeline/skills/shared/external/swift-testing/SKILL.md +1 -1
  424. package/pipeline/skills/shared/external/swift-testing-review/SKILL.md +1 -1
  425. package/pipeline/skills/shared/external/swift-testing-review/evals/trigger-eval.json +11 -0
  426. package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
  427. package/pipeline/skills/shared/external/swiftdata-review/SKILL.md +1 -1
  428. package/pipeline/skills/shared/external/swiftdata-review/evals/trigger-eval.json +11 -0
  429. package/pipeline/skills/shared/external/swiftui-glass-effects/SKILL.md +1 -1
  430. package/pipeline/skills/shared/external/tailwind-styling/SKILL.md +1 -1
  431. package/pipeline/skills/shared/external/tailwind-styling/evals/trigger-eval.json +11 -0
  432. package/pipeline/skills/shared/external/vision-framework/SKILL.md +1 -1
  433. package/pipeline/skills/shared/external/widgetkit/SKILL.md +1 -1
  434. package/pipeline/skills/skill-copies.json +43 -0
  435. package/pipeline/skills/skills-index.md +31 -31
  436. package/pipeline/office/NOTICE.md +0 -18
@@ -707,97 +707,6 @@ export function pruneLegacyMultiAgentSkills(skillsDir) {
707
707
  return removed;
708
708
  }
709
709
 
710
- /**
711
- * Trees an older installer created and no current one manages.
712
- *
713
- * A tree that stops being copied does not stop existing: the wipe-before-copy
714
- * pattern only runs for trees the installer still writes, so a tree dropped
715
- * from the installer keeps whatever it last wrote until something removes it.
716
- *
717
- * `eval/` held eval corpora for harnesses that are maintainer CI tooling and do
718
- * not ship, so nothing installed can read or remove it.
719
- *
720
- * `~/.multi-agent/` is the shared runtime the retired Cursor / Antigravity /
721
- * VS Code Copilot Chat adapters used to reach the gate scripts by absolute
722
- * path: scripts, lib and schemas that no current installer refreshes, and that
723
- * look like a live install when browsed.
724
- *
725
- * `root: "home"` entries sit beside `~/.claude`, not inside it.
726
- *
727
- * @type {ReadonlyArray<{dir: string, root?: "claude"|"home", reason: string, knownEntries?: string[], entryMarker?: string}>}
728
- */
729
- const ABANDONED_TREES = Object.freeze([
730
- {
731
- dir: "eval",
732
- reason: "eval corpora; the harnesses that read them are maintainer-only and no longer ship",
733
- },
734
- {
735
- // Two roots the pipeline wrote task state into before the log root settled
736
- // on ~/.claude/logs/multi-agent/. Nothing in the tree references either any
737
- // more - no script, no doc, no schema - so they are orphaned copies of
738
- // state nothing can read. `entryMarker` is the guard: every entry must be a
739
- // directory holding an agent-state.json, which is the shape only this
740
- // pipeline wrote. A folder someone else put there fails that test and the
741
- // tree is kept.
742
- dir: "multi-agent-tasks",
743
- entryMarker: "agent-state.json",
744
- reason: "pre-log-root task state; the current root is ~/.claude/logs/multi-agent/",
745
- },
746
- {
747
- dir: ".multi-agent-state",
748
- entryMarker: "agent-state.json",
749
- reason: "pre-log-root task state; the current root is ~/.claude/logs/multi-agent/",
750
- },
751
- {
752
- dir: ".multi-agent",
753
- root: "home",
754
- // `.multi-agent/` is also the live per-repo path memory-save.sh and the
755
- // offload-ref writer use (memory/, refs/, .gitignore). If $HOME is itself a
756
- // repo, or anything else put an unknown entry there, the tree is not ours.
757
- knownEntries: ["scripts", "lib", "schemas", ".DS_Store"],
758
- reason:
759
- "shared runtime for the Cursor / Antigravity / Copilot Chat adapters, all deleted in v10.7.0",
760
- },
761
- ]);
762
-
763
- /**
764
- * @param {string} target
765
- * @param {ReadonlyArray<string>|undefined} knownEntries
766
- * @param {string|undefined} entryMarker file every entry must contain, for trees keyed by task id
767
- * @returns {boolean} true when every top-level entry is one the abandoned tree is known to contain
768
- */
769
- function isKnownLegacyTree(target, knownEntries, entryMarker) {
770
- if (entryMarker) {
771
- // Shape check rather than a name list, for trees whose entries are task ids
772
- // and therefore unknowable in advance. An entry qualifies when it carries
773
- // the marker, or when it is an empty directory - an abandoned run that was
774
- // torn down leaves one of those, and nothing that is empty can belong to
775
- // anyone else. A directory with content but no marker is somebody's, and
776
- // one such entry keeps the whole tree.
777
- try {
778
- return readdirSync(target)
779
- .filter((name) => name !== ".DS_Store")
780
- .every((name) => {
781
- const entry = join(target, name);
782
- if (existsSync(join(entry, entryMarker))) return true;
783
- try {
784
- return readdirSync(entry).filter((n) => n !== ".DS_Store").length === 0;
785
- } catch {
786
- return false;
787
- }
788
- });
789
- } catch {
790
- return false;
791
- }
792
- }
793
- if (!knownEntries) return true;
794
- try {
795
- return readdirSync(target).every((name) => knownEntries.includes(name));
796
- } catch {
797
- return false;
798
- }
799
- }
800
-
801
710
  /**
802
711
  * Registry of command renames. Command names are an interface: users type
803
712
  * them, docs and saved routines reference them, and Copilot installs derive
@@ -824,41 +733,6 @@ export const COMMAND_RENAMES = Object.freeze({
824
733
  "local-autopilot": "autopilot",
825
734
  });
826
735
 
827
- /**
828
- * Remove trees an older install left behind.
829
- *
830
- * @param {string} claudeDir e.g. `$HOME/.claude`
831
- * @param {string} [home] `$HOME`, for entries marked `root: "home"`. Defaults to
832
- * the parent of `claudeDir`, which is the layout every installer uses.
833
- * @returns {number} directories removed
834
- */
835
- export function pruneAbandonedTrees(claudeDir, home = dirname(claudeDir)) {
836
- let removed = 0;
837
- for (const { dir, root, reason, knownEntries, entryMarker } of ABANDONED_TREES) {
838
- const base = root === "home" ? home : claudeDir;
839
- const target = join(base, dir);
840
- if (!existsSync(target)) continue;
841
- if (!isKnownLegacyTree(target, knownEntries, entryMarker)) {
842
- console.log(
843
- ` kept ${target}: holds entries no abandoned install wrote, so it is not ours to remove`,
844
- );
845
- continue;
846
- }
847
- if (dryRun) {
848
- console.log(` [dry-run] would remove abandoned tree ${target} (${reason})`);
849
- removed++;
850
- continue;
851
- }
852
- try {
853
- rmSync(target, { recursive: true, force: true });
854
- removed++;
855
- } catch {
856
- /* non-fatal - a leftover tree must never fail an install */
857
- }
858
- }
859
- return removed;
860
- }
861
-
862
736
  /**
863
737
  * Copy a single file, honouring dry-run mode.
864
738
  * @param {string} src
@@ -72,6 +72,7 @@ const DEV_ONLY_TOOLING = Object.freeze([
72
72
  "_shingle-index.mjs", // imported only by upstream-overlap-gate.mjs, which never ships
73
73
  "_png-phash.mjs", // imported only by upstream-overlap-gate.mjs, which never ships
74
74
  "gen-free-llm-skill.mjs", // reads the sibling toolkit checkout; an install has none
75
+ "gen-toolkit-path-params.mjs", // reads the sibling toolkit checkout; an install has none
75
76
  "gen-fact-marks.mjs", // renders the counts in the repo's own docs; an install has no docs/
76
77
  "gen-ref-toc.mjs", // regenerates the repo's own reference tree; an install has no pipeline/
77
78
  "ref-filler-audit.mjs", // audits the repo's own instruction docs; an install has no pipeline/
@@ -6,10 +6,8 @@
6
6
  * everything around it. Every install replaces only that span, so user content
7
7
  * before and after survives.
8
8
  *
9
- * Extracted from `install/copilot.mjs` in v13.0.0 when Codex CLI became a third
10
- * install target. The bounding logic carries two rounds of drift-cleanup fixes
11
- * (v5.6.2 pre-marker sections, v11.4.1 explicit end marker) and must not be
12
- * re-derived per target.
9
+ * Shared by the Copilot and Codex installers, so the bounding rules are defined
10
+ * once rather than per target.
13
11
  *
14
12
  * @module install/_managed-block
15
13
  */
@@ -51,11 +49,10 @@ export function legacyTrailingContent(section) {
51
49
  * @param {string} opts.body - pipeline section content (without the end marker)
52
50
  * @param {string} opts.startMarker - first line of the managed span
53
51
  * @param {string} opts.endMarker - HTML comment terminating the managed span
54
- * @param {RegExp[]} [opts.driftPatterns] - pre-marker sections to scrub
55
52
  * @returns {"created"|"updated"|"appended"} what the merge did
56
53
  */
57
54
  export function mergeManagedBlock(opts) {
58
- const { path, body, startMarker, endMarker, driftPatterns = [] } = opts;
55
+ const { path, body, startMarker, endMarker } = opts;
59
56
  const managedBlock = body.trimEnd() + "\n\n" + endMarker + "\n";
60
57
 
61
58
  if (!existsSync(path)) {
@@ -63,17 +60,7 @@ export function mergeManagedBlock(opts) {
63
60
  return "created";
64
61
  }
65
62
 
66
- let existing = readFileSync(path, "utf-8");
67
-
68
- // Drift cleanup: strip pipeline sections written by installers that predate
69
- // the stable marker. Without this they linger and contradict current output.
70
- let cleaned = false;
71
- for (const re of driftPatterns) {
72
- if (re.test(existing)) {
73
- existing = existing.replace(re, "");
74
- cleaned = true;
75
- }
76
- }
63
+ const existing = readFileSync(path, "utf-8");
77
64
 
78
65
  if (!existing.includes(startMarker)) {
79
66
  writeFile(path, existing.trimEnd() + "\n\n" + managedBlock);
@@ -95,5 +82,5 @@ export function mergeManagedBlock(opts) {
95
82
  const trailingClean = trailing.replace(/^[\r\n]+/, "").trimEnd();
96
83
  if (trailingClean.length > 0) out += "\n" + trailingClean + "\n";
97
84
  writeFile(path, out);
98
- return cleaned ? "updated+scrubbed" : "updated";
85
+ return "updated";
99
86
  }
@@ -19,7 +19,8 @@
19
19
  *
20
20
  * The sandbox is the boundary: Seatbelt on macOS, enforced for every Bash
21
21
  * command and every process it starts, with writes limited to the working
22
- * directory, the session temp directory and the unattended run directory, and
22
+ * directory, the session temp directory, the directories runs share under the
23
+ * unattended run root and, per launch, the run's own run directory, and
23
24
  * egress limited to the listed hosts. The file tools and MCP tools are outside
24
25
  * it; the Edit and Read deny rules cover the file tools, and agent-guard.sh
25
26
  * under MULTI_AGENT_UNATTENDED=1 is a second layer over all of them
@@ -35,7 +36,9 @@
35
36
  * Opt-in, printed in full with a reason per line BEFORE anything is written.
36
37
  * Allow and deny rules are additive; a sandbox block already in the file is
37
38
  * corrected to the shipped one, keeping its extra deny entries and dropping
38
- * whatever widens it.
39
+ * whatever widens it. allowWrite is replaced with the shipped set, so a write
40
+ * path an operator added is dropped; no mechanism adds one back, because the
41
+ * launch precondition refuses any.
39
42
  *
40
43
  * @module install/_unattended-profile
41
44
  */
@@ -44,8 +47,39 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
44
47
  import { dirname, join } from "node:path";
45
48
  import { fileURLToPath } from "node:url";
46
49
 
50
+ import { listSessions } from "../pipeline/lib/claude-sessions.mjs";
47
51
  import { unattendedSettingsPath } from "../pipeline/lib/unattended-settings-location.mjs";
48
52
  import { prefsHosts, profileGaps } from "../pipeline/lib/unattended-profile-check.mjs";
53
+ import {
54
+ TOOL_HOME_KEYS,
55
+ drainRunQuarantine,
56
+ ensureRunRoot,
57
+ expandHome,
58
+ migrateLegacyHomes,
59
+ prepareToolHomes,
60
+ recordDataSource,
61
+ } from "../pipeline/lib/unattended-tool-homes.mjs";
62
+
63
+ /**
64
+ * Entries earlier releases wrote for tool homes: under the run directory, and
65
+ * for the data directory alone, which the whole tool-home parent now covers.
66
+ * They name paths nothing reads any more, or less than the shipped entry; an
67
+ * install removes them along with the old directories.
68
+ */
69
+ const LEGACY_DENY_WRITE = [
70
+ "~/.multi-agent-unattended/gradle-home/init.d",
71
+ "~/.multi-agent-unattended/gradle-home/init.gradle",
72
+ "~/.multi-agent-unattended/gradle-home/init.gradle.kts",
73
+ "~/.multi-agent-unattended/gradle-home/gradle.properties",
74
+ "~/.multi-agent-unattended/xdg-data",
75
+ "~/.multi-agent-unattended-homes/xdg-data",
76
+ ];
77
+ const LEGACY_DENY_RULES = [
78
+ "Edit(~/.multi-agent-unattended/gradle-home/**)",
79
+ "Edit(~/.multi-agent-unattended/xdg-data/**)",
80
+ "Edit(~/.multi-agent-unattended-homes/xdg-data/**)",
81
+ ];
82
+ const profileEnvKeys = () => new Set(PROFILE.env.map(([k]) => k));
49
83
 
50
84
  const PROFILE_PATH = join(
51
85
  dirname(dirname(fileURLToPath(import.meta.url))),
@@ -67,6 +101,29 @@ const LEGACY = JSON.parse(
67
101
  ),
68
102
  );
69
103
 
104
+ /**
105
+ * The tool homes install readies: an older layout removed when no run is at
106
+ * work (the clone of the operator's Gradle cache an earlier release kept
107
+ * included), the data directory rebuilt, the run root and the directories
108
+ * runs share made, and what earlier removals left in the quarantine deleted
109
+ * within the after-run budget.
110
+ */
111
+ function readyToolHomes(home, env) {
112
+ let listed = null;
113
+ const sessions = () => (listed ??= { rows: listSessions(env) }).rows;
114
+ migrateLegacyHomes({ home, env, sessions });
115
+ prepareToolHomes({ home, profile: PROFILE, env });
116
+ ensureRunRoot({ home });
117
+ drainRunQuarantine({ home });
118
+ }
119
+
120
+ /**
121
+ * Env keys no shared profile carries: a Gradle variable belongs to one run's
122
+ * launch settings file, and GRADLE_RO_DEP_CACHE, a dependency cache no run is
123
+ * given, to none.
124
+ */
125
+ const strayGradleKey = (key) => /^GRADLE_/.test(key) && !TOOL_HOME_KEYS.includes(key);
126
+
70
127
  /** Env entries: [key, value, why][]. */
71
128
  export const UNATTENDED_ENV = PROFILE.env;
72
129
 
@@ -136,7 +193,9 @@ function sandboxBlock(existing, extraHosts) {
136
193
  filesystem: {
137
194
  ...keepFs,
138
195
  allowWrite: [...want.filesystem.allowWrite],
139
- denyWrite: union(curFs.denyWrite, want.filesystem.denyWrite),
196
+ denyWrite: union(curFs.denyWrite, want.filesystem.denyWrite).filter(
197
+ (p) => !LEGACY_DENY_WRITE.includes(p),
198
+ ),
140
199
  denyRead: union(curFs.denyRead, want.filesystem.denyRead),
141
200
  },
142
201
  network: {
@@ -193,12 +252,39 @@ export function planUnattendedProfile(current = {}, { home = "", settings, extra
193
252
  for (const [rule, why] of PROFILE.deny) {
194
253
  rows.push({ label: `deny:${rule}`, why, mark: hasRule(deny, rule) ? "already" : "add" });
195
254
  }
196
- for (const [key, value, why] of PROFILE.env) {
255
+ for (const [key, raw, why] of PROFILE.env) {
256
+ // A tool-home path is written absolute: Gradle and gh do not expand ~.
257
+ const toolHome = TOOL_HOME_KEYS.includes(key);
258
+ const value = toolHome && home ? expandHome(raw, home) : raw;
197
259
  let mark = "add";
198
260
  if (env[key] === value) mark = "already";
199
- else if (env[key] !== undefined) mark = "kept";
261
+ else if (env[key] !== undefined) mark = toolHome ? "replace" : "kept";
200
262
  rows.push({ label: `env:${key}=${value}`, why, mark });
201
263
  }
264
+ for (const key of TOOL_HOME_KEYS) {
265
+ if (profileEnvKeys().has(key) || env[key] === undefined) continue;
266
+ rows.push({
267
+ label: `unset:${key}`,
268
+ why: "set per launch to the run's own Gradle home, in the launch environment, never in the shared profile",
269
+ mark: "drop",
270
+ });
271
+ }
272
+ for (const key of Object.keys(env)) {
273
+ if (!strayGradleKey(key)) continue;
274
+ rows.push({
275
+ label: `unset:${key}`,
276
+ why: "a Gradle variable belongs to one run's launch settings file, never to the shared profile",
277
+ mark: "drop",
278
+ });
279
+ }
280
+ for (const rule of LEGACY_DENY_RULES) {
281
+ if (!hasRule(deny, rule)) continue;
282
+ rows.push({
283
+ label: `undeny:${rule}`,
284
+ why: "names a tool home an earlier release kept under ~/.multi-agent-unattended; the homes moved",
285
+ mark: "drop",
286
+ });
287
+ }
202
288
  const present = current.sandbox && typeof current.sandbox === "object";
203
289
  const target = sandboxBlock(current.sandbox, hosts);
204
290
  let sandboxMark = "add";
@@ -207,7 +293,7 @@ export function planUnattendedProfile(current = {}, { home = "", settings, extra
207
293
  JSON.stringify(current.sandbox) === JSON.stringify(target) ? "already" : "correct";
208
294
  rows.push({
209
295
  label: "sandbox",
210
- why: "OS sandbox for Bash and everything it starts: required, no unsandboxed retry, no excluded commands, writes limited to the worktree and the unattended run directory, protected host files denied, credential stores unreadable, network limited to the listed hosts",
296
+ why: "OS sandbox for Bash and everything it starts: required, no unsandboxed retry, no excluded commands, writes limited to the worktree, the shared directories under the unattended run root and, per launch, the run's own run directory, protected host files denied, credential stores unreadable, network limited to the listed hosts",
211
297
  mark: sandboxMark,
212
298
  });
213
299
  for (const label of legacyEntries(attended)) {
@@ -228,6 +314,7 @@ const MARK_TEXT = {
228
314
  correct: "will be corrected",
229
315
  warn: "left in settings.json",
230
316
  migrate: "removed from settings.json",
317
+ drop: "will be removed",
231
318
  };
232
319
 
233
320
  /**
@@ -297,6 +384,17 @@ export function buildUnattendedProfile(current = {}, opts = {}) {
297
384
  const deny = Array.isArray(perms.deny) ? [...perms.deny] : [];
298
385
  const next = { ...current };
299
386
  for (const { label, mark } of rows) {
387
+ if (mark === "drop" && label.startsWith("unset:")) {
388
+ const { [label.slice("unset:".length)]: _gone, ...rest } = next.env || {};
389
+ next.env = rest;
390
+ continue;
391
+ }
392
+ if (mark === "drop" && label.startsWith("undeny:")) {
393
+ const rule = label.slice("undeny:".length);
394
+ const at = deny.findIndex((r) => String(r) === rule);
395
+ if (at >= 0) deny.splice(at, 1);
396
+ continue;
397
+ }
300
398
  if (!["add", "replace", "correct"].includes(mark)) continue;
301
399
  if (label.startsWith("defaultMode:")) perms.defaultMode = label.slice("defaultMode:".length);
302
400
  else if (label.startsWith("deny:")) deny.push(label.slice("deny:".length));
@@ -313,74 +411,142 @@ export function buildUnattendedProfile(current = {}, opts = {}) {
313
411
  }
314
412
 
315
413
  /**
316
- * Bring an existing profile up to the shipped deny rules without touching
317
- * anything else: only permissions.deny and the sandbox's denyRead and
318
- * denyWrite grow, so a release that adds a deny reaches every installed
319
- * profile on the next install, and nothing it allows changes. No profile file,
320
- * or one that does not parse, is left alone.
414
+ * Bring an existing profile up to the shipped deny rules without widening
415
+ * anything: permissions.deny and the sandbox's denyRead and denyWrite grow,
416
+ * and every sandbox allowWrite entry the shipped profile does not carry is
417
+ * removed, an operator's own addition included, so a release that narrows the
418
+ * posture reaches every installed profile on the next install. There is no
419
+ * place for an operator to add a write path: the launch precondition refuses
420
+ * a profile whose allowWrite holds anything beyond the shipped set, and a
421
+ * checkout's settings that add one.
422
+ *
423
+ * Migration from earlier tool-home layouts: env.GRADLE_USER_HOME is removed
424
+ * (each launch sets its run's own), and so is every other GRADLE_ variable,
425
+ * GRADLE_RO_DEP_CACHE included; XDG_DATA_HOME moves to
426
+ * ~/.multi-agent-unattended-homes/xdg-data, the deny entries for the old
427
+ * paths are removed, and the old homes are removed without following a link
428
+ * (migrateLegacyHomes): gradle-home and xdg-data under
429
+ * ~/.multi-agent-unattended, the per-repository Gradle homes under
430
+ * ~/.multi-agent-unattended-homes/gradle, the clone of the operator's Gradle
431
+ * cache at ~/.multi-agent-unattended-homes/gradle-ro and the launch settings
432
+ * files under ~/.claude/multi-agent-unattended.launch. While an unattended
433
+ * run may be at work that removal waits, recorded as pending, for the next
434
+ * install or launch. ~/.gradle and the operator's data directory are left as
435
+ * they are. The data directory is rebuilt, the run root and its shared
436
+ * directories made, the quarantine drained and the operator's data directory
437
+ * recorded again. No profile file, or one that does not parse, is left alone.
321
438
  *
322
- * @param {{home:string, dryRun?:boolean}} opts
323
- * @returns {{path:string, added:string[], written:boolean}}
439
+ * @param {{home:string, dryRun?:boolean, env?:Record<string, string|undefined>}} opts
440
+ * @returns {{path:string, added:string[], removed:string[], written:boolean}}
324
441
  */
325
- export function tightenUnattendedProfile({ home, dryRun = false }) {
442
+ export function tightenUnattendedProfile({ home, dryRun = false, env = process.env }) {
326
443
  const path = unattendedSettingsPath(home);
327
- if (!existsSync(path)) return { path, added: [], written: false };
444
+ const none = { path, added: [], removed: [], written: false };
445
+ if (!existsSync(path)) return none;
328
446
  let current;
329
447
  try {
330
448
  current = JSON.parse(readFileSync(path, "utf-8"));
331
449
  } catch {
332
- return { path, added: [], written: false };
450
+ return none;
333
451
  }
334
- if (!current || typeof current !== "object" || Array.isArray(current))
335
- return { path, added: [], written: false };
452
+ if (!current || typeof current !== "object" || Array.isArray(current)) return none;
336
453
  const added = [];
454
+ const removed = [];
337
455
  const perms = { ...(current.permissions || {}) };
338
- const deny = Array.isArray(perms.deny) ? [...perms.deny] : [];
456
+ const deny = (Array.isArray(perms.deny) ? [...perms.deny] : []).filter((r) => {
457
+ if (!LEGACY_DENY_RULES.includes(String(r))) return true;
458
+ removed.push(`deny:${r}`);
459
+ return false;
460
+ });
339
461
  for (const [rule] of PROFILE.deny) {
340
462
  if (hasRule(deny, rule)) continue;
341
463
  deny.push(rule);
342
464
  added.push(`deny:${rule}`);
343
465
  }
344
466
  const next = { ...current, permissions: { ...perms, deny } };
467
+ // The data directory: set, or put back when a value points elsewhere, since
468
+ // the sandbox denies the files the default would read. The Gradle home is
469
+ // set per run, so a value an earlier install wrote here is removed.
470
+ for (const key of TOOL_HOME_KEYS) {
471
+ const env = next.env && typeof next.env === "object" ? next.env : {};
472
+ const shipped = PROFILE.env.find(([k]) => k === key);
473
+ if (!shipped) {
474
+ if (env[key] === undefined) continue;
475
+ const { [key]: _gone, ...rest } = env;
476
+ next.env = rest;
477
+ removed.push(`env.${key}`);
478
+ continue;
479
+ }
480
+ const value = expandHome(shipped[1], home);
481
+ if (env[key] === value) continue;
482
+ next.env = { ...env, [key]: value };
483
+ added.push(`env.${key}=${value}`);
484
+ }
485
+ for (const key of Object.keys(next.env && typeof next.env === "object" ? next.env : {})) {
486
+ if (!strayGradleKey(key)) continue;
487
+ const { [key]: _gone, ...rest } = next.env;
488
+ next.env = rest;
489
+ removed.push(`env.${key}`);
490
+ }
345
491
  // Directories the toolkit's index refuses: a list, so it only grows too.
346
492
  for (const [key, value] of PROFILE.env) {
347
493
  if (key !== "MCP_TOOLKIT_INDEX_DENY") continue;
348
- const env = current.env && typeof current.env === "object" ? current.env : {};
494
+ const env = next.env && typeof next.env === "object" ? next.env : {};
349
495
  const have = String(env[key] ?? "")
350
496
  .split(",")
351
497
  .map((x) => x.trim())
352
498
  .filter(Boolean);
353
499
  const missing = value.split(",").filter((x) => !have.includes(x));
354
500
  if (!missing.length) continue;
355
- next.env = { ...env, [key]: [...have, ...missing].join(",") };
501
+ next.env = { ...(next.env || env), [key]: [...have, ...missing].join(",") };
356
502
  added.push(...missing.map((x) => `env.${key}:${x}`));
357
503
  }
358
504
  const sb = current.sandbox;
359
505
  if (sb && typeof sb === "object" && !Array.isArray(sb)) {
360
506
  const fs = sb.filesystem && typeof sb.filesystem === "object" ? sb.filesystem : {};
361
507
  const nextFs = { ...fs };
508
+ if (Array.isArray(fs.denyWrite)) {
509
+ const stale = fs.denyWrite.map(String).filter((p) => LEGACY_DENY_WRITE.includes(p));
510
+ if (stale.length) {
511
+ nextFs.denyWrite = fs.denyWrite.filter((p) => !LEGACY_DENY_WRITE.includes(String(p)));
512
+ removed.push(...stale.map((p) => `sandbox.denyWrite:${p}`));
513
+ }
514
+ }
362
515
  for (const key of ["denyRead", "denyWrite"]) {
363
- const have = Array.isArray(fs[key]) ? fs[key].map(String) : [];
516
+ const have = Array.isArray(nextFs[key]) ? nextFs[key].map(String) : [];
364
517
  const missing = PROFILE.sandbox.filesystem[key].filter((p) => !have.includes(p));
365
518
  if (!missing.length) continue;
366
519
  nextFs[key] = [...have, ...missing];
367
520
  added.push(...missing.map((p) => `sandbox.${key}:${p}`));
368
521
  }
522
+ if (Array.isArray(fs.allowWrite)) {
523
+ const shipped = PROFILE.sandbox.filesystem.allowWrite;
524
+ const have = fs.allowWrite.map(String);
525
+ const dropped = have.filter((p) => !shipped.includes(p));
526
+ const missing = shipped.filter((p) => !have.includes(p));
527
+ if (dropped.length) removed.push(...dropped.map((p) => `sandbox.allowWrite:${p}`));
528
+ if (missing.length) added.push(...missing.map((p) => `sandbox.allowWrite:${p}`));
529
+ if (dropped.length || missing.length)
530
+ nextFs.allowWrite = [...have.filter((p) => shipped.includes(p)), ...missing];
531
+ }
369
532
  next.sandbox = { ...sb, filesystem: nextFs };
370
533
  }
371
- if (!added.length || dryRun) return { path, added, written: false };
534
+ if (dryRun) return { path, added, removed, written: false };
535
+ recordDataSource({ home, env });
536
+ readyToolHomes(home, env);
537
+ if (!added.length && !removed.length) return { path, added, removed, written: false };
372
538
  writeFileSync(path, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
373
- return { path, added, written: true };
539
+ return { path, added, removed, written: true };
374
540
  }
375
541
 
376
542
  /**
377
543
  * Write the profile into its own settings file. Idempotent: running it twice
378
544
  * changes nothing the second time.
379
545
  *
380
- * @param {{home:string, dryRun?:boolean}} opts
546
+ * @param {{home:string, dryRun?:boolean, env?:Record<string, string|undefined>}} opts
381
547
  * @returns {{path:string, added:string[], warned:string[], migrated:string[], removed:string[], already:string[], kept:string[], written:boolean}}
382
548
  */
383
- export function applyUnattendedProfile({ home, dryRun = false }) {
549
+ export function applyUnattendedProfile({ home, dryRun = false, env = process.env }) {
384
550
  const path = unattendedSettingsPath(home);
385
551
  const settingsPath = join(home, ".claude", "settings.json");
386
552
  const current = readSettingsFile(path);
@@ -388,21 +554,25 @@ export function applyUnattendedProfile({ home, dryRun = false }) {
388
554
  const { rows, extraHosts } = planUnattendedProfile(current, { home, settings });
389
555
  const pick = (...marks) => rows.filter((r) => marks.includes(r.mark)).map((r) => r.label);
390
556
  const added = pick("add", "replace", "correct");
557
+ const dropped = pick("drop");
391
558
  const migrated = pick("migrate").map((l) => l.slice("migrate:".length));
392
559
  const result = {
393
560
  path,
394
561
  added,
395
562
  warned: pick("warn").map((l) => l.slice("warn:".length)),
396
563
  migrated,
397
- removed: [],
564
+ removed: dropped,
398
565
  already: pick("already"),
399
566
  kept: pick("kept"),
400
567
  };
401
- if (dryRun || (!added.length && !migrated.length)) return { ...result, written: false };
568
+ if (dryRun) return { ...result, written: false };
569
+ recordDataSource({ home, env });
570
+ readyToolHomes(home, env);
571
+ if (!added.length && !dropped.length && !migrated.length) return { ...result, written: false };
402
572
 
403
- if (added.length) {
573
+ if (added.length || dropped.length) {
404
574
  const next = buildUnattendedProfile(current, { home, settings, extraHosts });
405
- const gaps = profileGaps(next, PROFILE, { extraHosts });
575
+ const gaps = profileGaps(next, PROFILE, { extraHosts, home });
406
576
  if (gaps.sandbox.length || gaps.permissions.length)
407
577
  throw new Error(
408
578
  `the profile would still fall short: ${[...gaps.sandbox, ...gaps.permissions].join("; ")}`,