@uniqbit/mate-core 0.20.0 → 0.21.1

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 (287) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
  3. package/claude-plugin/hooks/hooks.json +10 -1
  4. package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
  5. package/opencode-plugin/src/server.ts +9 -2
  6. package/package.json +2 -1
  7. package/src/cli/commands/artifact/delivery/environment.ts +28 -8
  8. package/src/cli/commands/artifact/delivery/link.ts +28 -9
  9. package/src/cli/commands/artifact/delivery/output.ts +7 -0
  10. package/src/cli/commands/companion/update.ts +2 -19
  11. package/src/cli/commands/factory/factory.ts +11 -1
  12. package/src/cli/commands/install.ts +47 -36
  13. package/src/cli/commands/launch/claude.ts +2 -0
  14. package/src/cli/commands/launch/shared.ts +33 -6
  15. package/src/cli/commands/plugin/install.ts +27 -11
  16. package/src/cli/commands/report/index.ts +180 -184
  17. package/src/cli/commands/report/markdown.ts +67 -72
  18. package/src/cli/commands/shared/companion-selection.ts +3 -1
  19. package/src/cli/commands/studio/access.ts +6 -14
  20. package/src/cli/commands/studio/areas.ts +112 -33
  21. package/src/cli/commands/studio/companion-add.ts +87 -0
  22. package/src/cli/commands/studio/companion-removal.ts +15 -8
  23. package/src/cli/commands/studio/factory-credential.ts +1 -15
  24. package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
  25. package/src/cli/commands/studio/factory-relay.ts +18 -0
  26. package/src/cli/commands/studio/graph-model.ts +61 -0
  27. package/src/cli/commands/studio/graph.ts +336 -0
  28. package/src/cli/commands/studio/index.ts +4 -4
  29. package/src/cli/commands/studio/payload.ts +42 -15
  30. package/src/cli/commands/studio/repository-add.ts +116 -0
  31. package/src/cli/commands/studio/routes.ts +6 -0
  32. package/src/cli/commands/studio/selection.ts +12 -3
  33. package/src/cli/commands/studio/server.ts +127 -5
  34. package/src/cli/commands/studio/services.ts +40 -0
  35. package/src/cli/commands/studio/terminal.ts +45 -3
  36. package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
  37. package/src/cli/commands/studio/workset-session.ts +47 -14
  38. package/src/cli/commands/unwrap.ts +3 -0
  39. package/src/cli/commands/update.ts +2 -0
  40. package/src/cli/commands/vscode/release-vsix.json +4 -0
  41. package/src/cli/commands/vscode/setup.ts +71 -13
  42. package/src/cli/commands/vscode/vsix.ts +48 -7
  43. package/src/cli/commands/working/cleanup.ts +40 -8
  44. package/src/cli/commands/working/worktree.ts +176 -35
  45. package/src/cli/main.ts +17 -2
  46. package/src/cli/usage.ts +1 -1
  47. package/src/hooks/rtk-worktree-git.ts +48 -0
  48. package/src/hooks/validate-artifact-path.ts +38 -7
  49. package/src/lib/delivery/branch-template.ts +122 -0
  50. package/src/lib/delivery/branches.ts +21 -16
  51. package/src/lib/delivery/checkout.ts +102 -0
  52. package/src/lib/delivery/environment.ts +2 -0
  53. package/src/lib/delivery/merge-git.ts +13 -1
  54. package/src/lib/delivery/record-delivery.ts +83 -29
  55. package/src/lib/delivery/record.ts +15 -3
  56. package/src/lib/delivery/resolve-branch.ts +157 -110
  57. package/src/lib/factory/attach-client.ts +11 -1
  58. package/src/lib/factory/broker.ts +37 -40
  59. package/src/lib/factory/client.ts +22 -1
  60. package/src/lib/factory/clone-url.ts +39 -0
  61. package/src/lib/factory/command.ts +21 -5
  62. package/src/lib/factory/git-auth.ts +61 -0
  63. package/src/lib/factory/git-credential-store.ts +181 -0
  64. package/src/lib/factory/ids.ts +12 -2
  65. package/src/lib/factory/outcomes/actions.ts +20 -4
  66. package/src/lib/factory/outcomes/index.ts +77 -11
  67. package/src/lib/factory/outcomes/lifecycle.ts +9 -2
  68. package/src/lib/factory/outcomes/sessions.ts +23 -1
  69. package/src/lib/factory/prepare.ts +9 -3
  70. package/src/lib/factory/runner/scheduler.ts +96 -14
  71. package/src/lib/factory/runner/workflow.ts +5 -1
  72. package/src/lib/factory/runtime.ts +143 -43
  73. package/src/lib/orchestrator/companion-hub.ts +6 -1
  74. package/src/lib/orchestrator/engine-floor.ts +48 -0
  75. package/src/lib/orchestrator/launcher.ts +34 -1
  76. package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
  77. package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
  78. package/src/lib/orchestrator/projection-claude-links.ts +32 -8
  79. package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
  80. package/src/lib/orchestrator/projection-entries.ts +22 -18
  81. package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
  82. package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
  83. package/src/lib/orchestrator/projection-types.ts +28 -1
  84. package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
  85. package/src/lib/orchestrator/session-prepare.ts +6 -1
  86. package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
  87. package/src/lib/orchestrator/types.ts +4 -0
  88. package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
  89. package/src/lib/orchestrator/working-repo-projection.ts +24 -4
  90. package/src/lib/orchestrator/wrap-pass.ts +1 -0
  91. package/src/lib/public-npm.ts +95 -50
  92. package/src/lib/session-state.ts +72 -2
  93. package/src/lib/update-checker.ts +7 -1
  94. package/src/lib/usage/aggregate.ts +202 -0
  95. package/src/lib/usage/cache.ts +87 -0
  96. package/src/lib/usage/claude-pricing.ts +71 -0
  97. package/src/lib/usage/claude.ts +189 -0
  98. package/src/lib/usage/collect.ts +56 -0
  99. package/src/lib/usage/opencode.ts +188 -0
  100. package/src/lib/usage/records.ts +80 -0
  101. package/src/lib/usage/rtk-database.ts +72 -0
  102. package/src/lib/usage/savings.ts +209 -0
  103. package/src/lib/usage/scope.ts +182 -0
  104. package/src/lib/usage/source.ts +102 -0
  105. package/src/lib/usage/types.ts +143 -0
  106. package/src/lib/usage/window.ts +37 -0
  107. package/src/lib/workset/factory-local.ts +157 -0
  108. package/src/lib/workset/record.ts +25 -11
  109. package/src/lib/workset/repositories.ts +118 -25
  110. package/src/lib/workset/worktree-include.ts +161 -0
  111. package/src/lib/workset/worktree-index.ts +6 -2
  112. package/src/lib/workset/worktree.ts +591 -101
  113. package/src/opencode/companion-hooks.ts +46 -8
  114. package/src/opencode/companion-policy.ts +18 -5
  115. package/src/opencode/enter-worktree.ts +254 -6
  116. package/src/opencode/session-register.ts +2 -2
  117. package/src/runtime/claude-bg-isolation.ts +138 -0
  118. package/src/runtime/companion-git.ts +10 -2
  119. package/src/runtime/companion-guidance.ts +17 -4
  120. package/src/runtime/current-branch.ts +16 -2
  121. package/src/runtime/entered-worktree.ts +24 -0
  122. package/src/runtime/git-tracked.ts +60 -0
  123. package/src/runtime/repo-destination.ts +72 -0
  124. package/src/runtime/repo-local.ts +25 -3
  125. package/src/runtime/rtk-git-guard.ts +66 -0
  126. package/src/runtime/runtime-document-manifest.ts +229 -19
  127. package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
  128. package/src/runtime/secret-guard.ts +9 -2
  129. package/src/runtime/secret-policy-weakening.ts +122 -0
  130. package/src/runtime/serving-claude-wrap.ts +15 -2
  131. package/src/runtime/umbrella-folder.ts +56 -0
  132. package/src/runtime/wrap-state.ts +5 -13
  133. package/src/studio.ts +37 -0
  134. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
  135. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
  136. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
  137. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
  138. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
  139. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
  140. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
  141. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
  142. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
  143. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
  144. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
  145. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
  146. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +307 -42
  147. package/src/tools/setup/capabilities/rtk.ts +93 -1
  148. package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
  149. package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
  150. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
  151. package/src/tools/setup/dynamic-plugins/install.ts +24 -22
  152. package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
  153. package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
  154. package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
  155. package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
  156. package/src/tools/setup/mate.ts +3 -3
  157. package/src/tools/setup/plugins/gitignore.ts +15 -9
  158. package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
  159. package/src/tools/setup/providers/claude.ts +25 -3
  160. package/src/tools/setup/utils.ts +4 -2
  161. package/src/tools/setup/working-repo-cleanup.ts +2 -2
  162. package/src/tools/setup/working-repo-local-state.ts +2 -0
  163. package/src/tools/setup.ts +25 -14
  164. package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
  165. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
  166. package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
  167. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
  168. package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
  169. package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
  170. package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
  171. package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
  172. package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
  173. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
  174. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
  175. package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
  176. package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
  177. package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
  178. package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
  179. package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
  180. package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
  181. package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
  182. package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
  183. package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
  184. package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
  185. package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
  186. package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
  187. package/studio-dist/client/assets/select-CnaMd617.js +1 -0
  188. package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
  189. package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
  190. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
  191. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
  192. package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
  193. package/studio-dist/client/assets/store-Dw34catY.js +1 -0
  194. package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
  195. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
  196. package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
  197. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
  198. package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
  199. package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
  200. package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
  201. package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
  202. package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
  203. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
  204. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
  205. package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
  206. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
  207. package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
  208. package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
  209. package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
  210. package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
  211. package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
  212. package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
  213. package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
  214. package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
  215. package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
  216. package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
  217. package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
  218. package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
  219. package/studio-dist/server/assets/graph-CSje3029.js +801 -0
  220. package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
  221. package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
  222. package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
  223. package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
  224. package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
  225. package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
  226. package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
  227. package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
  228. package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
  229. package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
  230. package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
  231. package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
  232. package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
  233. package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
  234. package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
  235. package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
  236. package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
  237. package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
  238. package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
  239. package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
  240. package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
  241. package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
  242. package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
  243. package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
  244. package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
  245. package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
  246. package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
  247. package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
  248. package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
  249. package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
  250. package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
  251. package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
  252. package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
  253. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
  254. package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
  255. package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
  256. package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
  257. package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
  258. package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
  259. package/studio-dist/server/server.js +582 -8
  260. package/src/cli/commands/report/collector.ts +0 -288
  261. package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
  262. package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
  263. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
  264. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
  265. package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
  266. package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
  267. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
  268. package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
  269. package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
  270. package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
  271. package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
  272. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
  273. package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
  274. package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
  275. package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
  276. package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
  277. package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
  278. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
  279. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
  280. package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
  281. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
  282. package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
  283. package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
  284. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
  285. package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
  286. package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
  287. package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
@@ -1,12 +1,12 @@
1
- import { execFile } from "node:child_process";
2
1
  import fs from "node:fs/promises";
3
2
  import os from "node:os";
4
3
  import path from "node:path";
5
- import { promisify } from "node:util";
6
4
 
7
5
  import { FRAMEWORK_NAME } from "../../framework";
8
- import { gitEnvironment } from "../../runtime/companion-git";
6
+ import { gitTracks } from "../../runtime/git-tracked";
7
+ import { repoDestination } from "../../runtime/repo-destination";
9
8
  import {
9
+ CLAUDE_LOCAL_CONFIG_DOCUMENT,
10
10
  documentRegions,
11
11
  readManifest,
12
12
  updateManifest,
@@ -17,6 +17,13 @@ import {
17
17
  } from "../../runtime/runtime-document-manifest";
18
18
  import { writeAtomic } from "../../runtime/write-atomic";
19
19
  import { pruneEmptyAncestors } from "../../tools/setup/utils";
20
+ import {
21
+ removalWithWarnings,
22
+ writeWithWarnings,
23
+ type ProjectionRemovalReport,
24
+ type ProjectionWriteReport,
25
+ type ProjectionWriteState,
26
+ } from "./projection-types";
20
27
 
21
28
  export {
22
29
  CLAUDE_LOCAL_CONFIG_DOCUMENT,
@@ -41,23 +48,7 @@ export {
41
48
  * else in it belongs to Claude Code.
42
49
  */
43
50
  export function isExternalDocument(documentPath: string): boolean {
44
- return documentPath.startsWith("~/");
45
- }
46
-
47
- const execFileAsync = promisify(execFile);
48
-
49
- /** Whether Git tracks the repo-relative path; any `ls-files` failure reads as untracked. */
50
- async function gitTracks(repoPath: string, relativePath: string): Promise<boolean> {
51
- try {
52
- const { stdout } = await execFileAsync("git", ["ls-files", "-z", "--", relativePath], {
53
- cwd: path.resolve(repoPath),
54
- encoding: "utf8",
55
- env: gitEnvironment(),
56
- });
57
- return stdout.split("\0").includes(relativePath);
58
- } catch {
59
- return false;
60
- }
51
+ return documentPath === CLAUDE_LOCAL_CONFIG_DOCUMENT;
61
52
  }
62
53
 
63
54
  /**
@@ -85,11 +76,19 @@ export const runtimeDocumentDeps = {
85
76
  homeDir: (): string => os.homedir(),
86
77
  };
87
78
 
88
- function documentPathIn(repoPath: string, documentPath: string): string {
79
+ /** Where a recorded document lives; `root` bounds pruning and is absent for the external one. */
80
+ type DocumentTarget =
81
+ | { kind: "inside"; path: string; root?: string }
82
+ | { kind: "refused"; warning: string };
83
+
84
+ function documentPathIn(repoPath: string, documentPath: string): DocumentTarget {
89
85
  if (isExternalDocument(documentPath)) {
90
- return path.join(runtimeDocumentDeps.homeDir(), ...documentPath.slice("~/".length).split("/"));
86
+ return {
87
+ kind: "inside",
88
+ path: path.join(runtimeDocumentDeps.homeDir(), ...documentPath.slice("~/".length).split("/")),
89
+ };
91
90
  }
92
- return path.join(path.resolve(repoPath), ...documentPath.split("/"));
91
+ return repoDestination(repoPath, documentPath);
93
92
  }
94
93
 
95
94
  function isRecord(value: unknown): value is Record<string, unknown> {
@@ -257,7 +256,7 @@ export async function placeRuntimeDocument(
257
256
  repoPath: string,
258
257
  documentPath: string,
259
258
  documents?: readonly RenderedRuntimeDocument[],
260
- ): Promise<"written" | "current" | "skipped"> {
259
+ ): Promise<ProjectionWriteState | ProjectionWriteReport> {
261
260
  /**
262
261
  * No render at all is not an empty render: a scope that supplies no documents
263
262
  * — a launch, which projects this entry without rendering for it — is claiming
@@ -266,13 +265,12 @@ export async function placeRuntimeDocument(
266
265
  if (!documents) return "skipped";
267
266
 
268
267
  const rendered = documents.find((candidate) => candidate.path === documentPath);
269
- if (!rendered) {
270
- return (await removeRuntimeDocument(repoPath, documentPath)) === "removed"
271
- ? "written"
272
- : "current";
273
- }
268
+ if (!rendered) return asWrite(await removeRuntimeDocument(repoPath, documentPath));
274
269
 
275
- const target = documentPathIn(repoPath, documentPath);
270
+ const destination = documentPathIn(repoPath, documentPath);
271
+ /** Refused: the record stays, so nothing Mate placed earlier is forgotten. */
272
+ if (destination.kind === "refused") return { state: "skipped", warnings: [destination.warning] };
273
+ const target = destination.path;
276
274
  const raw = await readRaw(target);
277
275
  const document = parseDocument(raw, target);
278
276
 
@@ -295,18 +293,31 @@ export async function placeRuntimeDocument(
295
293
  return "written";
296
294
  }
297
295
 
296
+ /** A removal as the write of an entry whose write is that removal. */
297
+ export function asWrite(
298
+ removed: "removed" | "absent" | ProjectionRemovalReport,
299
+ ): ProjectionWriteState | ProjectionWriteReport {
300
+ if (typeof removed === "string") return removed === "removed" ? "written" : "current";
301
+ return writeWithWarnings(
302
+ removed.state === "removed" ? "written" : "current",
303
+ removed.warnings ?? [],
304
+ );
305
+ }
306
+
298
307
  /**
299
308
  * Strips the recorded regions and leaves the document Mate found; a document
300
309
  * left empty is deleted along with any directory Mate created to hold it.
310
+ * A refused destination keeps its record and warns.
301
311
  */
302
312
  export async function removeRuntimeDocument(
303
313
  repoPath: string,
304
314
  documentPath: string,
305
- ): Promise<"removed" | "absent"> {
315
+ ): Promise<"removed" | "absent" | ProjectionRemovalReport> {
306
316
  const regions = documentRegions(await readManifest(repoPath), documentPath);
307
317
  if (!regions) return "absent";
308
318
 
309
- await revertDocumentOnDisk(repoPath, documentPath, regions);
319
+ const reverted = await revertDocumentOnDisk(repoPath, documentPath, regions);
320
+ if (reverted !== null) return removalWithWarnings("absent", [reverted]);
310
321
  await updateManifest(repoPath, (manifest) => withoutDocuments(manifest, [documentPath]));
311
322
  return "removed";
312
323
  }
@@ -315,28 +326,29 @@ export async function removeRuntimeDocument(
315
326
  * One document's regions, taken back out of the file that holds them. Knows
316
327
  * nothing of the manifest, which is what lets several destinations be reverted
317
328
  * at once: every document is a distinct file, while the manifest recording them
318
- * all is not.
329
+ * all is not. Answers the refusal warning when the destination is refused.
319
330
  */
320
331
  async function revertDocumentOnDisk(
321
332
  repoPath: string,
322
333
  documentPath: string,
323
334
  regions: readonly ManagedRegion[],
324
- ): Promise<void> {
325
- const target = documentPathIn(repoPath, documentPath);
335
+ ): Promise<string | null> {
336
+ const destination = documentPathIn(repoPath, documentPath);
337
+ if (destination.kind === "refused") return destination.warning;
338
+ const target = destination.path;
326
339
  const raw = await readRaw(target);
327
- if (raw === null) return;
340
+ if (raw === null) return null;
328
341
 
329
342
  const document = parseDocument(raw, target);
330
343
  for (const region of regions) revertRegion(document, region);
331
- if (Object.keys(document).length === 0 && !isExternalDocument(documentPath)) {
344
+ if (Object.keys(document).length === 0 && destination.root !== undefined) {
332
345
  await fs.unlink(target);
333
346
  const holder = path.dirname(target);
334
- if (holder !== path.resolve(repoPath)) {
335
- await pruneEmptyAncestors(holder, path.resolve(repoPath));
336
- }
347
+ if (holder !== destination.root) await pruneEmptyAncestors(holder, destination.root);
337
348
  } else {
338
349
  await writeAtomic(target, serialize(document));
339
350
  }
351
+ return null;
340
352
  }
341
353
 
342
354
  /**
@@ -355,11 +367,16 @@ async function revertDocumentOnDisk(
355
367
  export async function removeRuntimeDocuments(
356
368
  repoPath: string,
357
369
  documentPaths: readonly string[],
358
- ): Promise<{ removed: string[]; absent: string[]; error?: { document: string; error: Error } }> {
370
+ ): Promise<{
371
+ removed: string[];
372
+ absent: string[];
373
+ warnings: string[];
374
+ error?: { document: string; error: Error };
375
+ }> {
359
376
  const manifest = await readManifest(repoPath);
360
377
  const recorded = documentPaths.filter((candidate) => documentRegions(manifest, candidate));
361
378
  const absent = documentPaths.filter((candidate) => !documentRegions(manifest, candidate));
362
- if (recorded.length === 0) return { removed: [], absent };
379
+ if (recorded.length === 0) return { removed: [], absent, warnings: [] };
363
380
 
364
381
  const settled = await Promise.allSettled(
365
382
  recorded.map((documentPath) =>
@@ -368,6 +385,7 @@ export async function removeRuntimeDocuments(
368
385
  );
369
386
 
370
387
  const removed: string[] = [];
388
+ const warnings: string[] = [];
371
389
  let failure: { document: string; error: Error } | undefined;
372
390
  for (const [index, result] of settled.entries()) {
373
391
  const documentPath = recorded[index]!;
@@ -378,9 +396,14 @@ export async function removeRuntimeDocuments(
378
396
  };
379
397
  continue;
380
398
  }
399
+ /** Refused: not a failure, and the record stays. */
400
+ if (result.value !== null) {
401
+ warnings.push(result.value);
402
+ continue;
403
+ }
381
404
  removed.push(documentPath);
382
405
  }
383
406
 
384
407
  await updateManifest(repoPath, (current) => withoutDocuments(current, removed));
385
- return { removed, absent, ...(failure ? { error: failure } : {}) };
408
+ return { removed, absent, warnings, ...(failure ? { error: failure } : {}) };
386
409
  }
@@ -86,9 +86,10 @@ export interface ProjectionWriteReport {
86
86
  * What a `self` removal may return instead of a bare state, when it kept
87
87
  * shared exclude lines another Checkout of the clone still needs: `retained`
88
88
  * when it kept everything it would have removed, `removed` when only part.
89
+ * Also how a removal that has only warnings reports them.
89
90
  */
90
91
  export interface ProjectionRemovalReport {
91
- state: "removed" | "retained";
92
+ state: "removed" | "retained" | "absent";
92
93
  /** The kept lines. */
93
94
  kept: string[];
94
95
  /** Paths of the Checkouts that still need them. */
@@ -99,6 +100,28 @@ export interface ProjectionRemovalReport {
99
100
  /** What a `self` removal returns. */
100
101
  export type ProjectionSelfRemoval = "removed" | "absent" | ProjectionRemovalReport;
101
102
 
103
+ /** A write state carrying warnings; the bare state when there are none. */
104
+ export function writeWithWarnings(
105
+ written: ProjectionWriteState | ProjectionWriteReport,
106
+ warnings: readonly string[],
107
+ ): ProjectionWriteState | ProjectionWriteReport {
108
+ if (warnings.length === 0) return written;
109
+ if (typeof written === "string") return { state: written, warnings: [...warnings] };
110
+ return { ...written, warnings: [...(written.warnings ?? []), ...warnings] };
111
+ }
112
+
113
+ /** A removal state carrying warnings; the bare state when there are none. */
114
+ export function removalWithWarnings(
115
+ removed: ProjectionSelfRemoval,
116
+ warnings: readonly string[],
117
+ ): ProjectionSelfRemoval {
118
+ if (warnings.length === 0) return removed;
119
+ if (typeof removed === "string") {
120
+ return { state: removed, kept: [], keptFor: [], warnings: [...warnings] };
121
+ }
122
+ return { ...removed, warnings: [...(removed.warnings ?? []), ...warnings] };
123
+ }
124
+
102
125
  /** A shared exclude-file edit as a removal outcome. */
103
126
  export function excludeRemovalReport(result: ExcludeEditResult): ProjectionSelfRemoval {
104
127
  if (result.kept.length === 0) return result.changed ? "removed" : "absent";
@@ -177,11 +200,15 @@ export interface ProjectionResult {
177
200
  root: string;
178
201
  scope: ProjectionScope;
179
202
  outcomes: ProjectionEntryOutcome[];
203
+ /** About the pass rather than one entry, such as records the manifest had ignored. */
204
+ warnings: string[];
180
205
  }
181
206
 
182
207
  export interface ProjectionRemovalResult {
183
208
  root: string;
184
209
  outcomes: ProjectionEntryOutcome[];
210
+ /** About the pass rather than one entry, such as records the manifest had ignored. */
211
+ warnings: string[];
185
212
  }
186
213
 
187
214
  export interface ProjectionEntryPresence {
@@ -73,7 +73,9 @@ export async function refreshWorkingClaudeLinks(
73
73
  enabled,
74
74
  registered,
75
75
  );
76
- const written = skills === "written" || commands === "written";
76
+ const written = [skills, commands].some(
77
+ (result) => (typeof result === "string" ? result : result.state) === "written",
78
+ );
77
79
  results.push({ repository, outcome: written ? "written" : "current" });
78
80
  } catch (error) {
79
81
  results.push({
@@ -318,6 +318,11 @@ async function projectClaude(
318
318
  companionPath: input.companionPath,
319
319
  config,
320
320
  });
321
+ // The launch pass rewrites the manifest, so the wrap pass below no longer sees what it dropped.
322
+ run.warnings.push(
323
+ ...(result.warnings ?? []),
324
+ ...result.outcomes.flatMap((outcome) => outcome.warnings ?? []),
325
+ );
321
326
  for (const outcome of result.outcomes) {
322
327
  if (outcome.state === "failed" && outcome.degradable) {
323
328
  run.warnings.push(entryFailureMessage(outcome, repository.id));
@@ -464,7 +469,7 @@ export async function prepareSession(input: PrepareSessionInput): Promise<Prepar
464
469
  ...(input.repository ? { repositoryId: input.repository.id } : {}),
465
470
  companionPath: input.companionPath,
466
471
  steps: run.steps,
467
- warnings: run.warnings,
472
+ warnings: [...new Set(run.warnings)],
468
473
  ...(run.companionChanged ? { companionChanged: true as const } : {}),
469
474
  ...(run.failure === undefined ? {} : { failure: run.failure }),
470
475
  ...(run.wrapState ? { wrapState: run.wrapState } : {}),
@@ -48,7 +48,7 @@ const TICKET_COMPATIBILITIES: TicketCompatibility[] = [
48
48
  id: "jira",
49
49
  label: "Jira",
50
50
  description:
51
- "Propose, apply, and archive ask for an optional Jira key (ABC-123), which names the Delivery Branch workset/<KEY>-<workset-id>.",
51
+ "Propose, apply, and archive ask for an optional Jira key (ABC-123), which goes into the Delivery Branch template (default workset/<KEY>-<workset-id>).",
52
52
  },
53
53
  ];
54
54
 
@@ -74,6 +74,8 @@ export interface CapabilityConfig {
74
74
  protectedBranches?: string[];
75
75
  /** openspec only: how changes record tickets; absent means `none`. */
76
76
  ticket?: string;
77
+ /** openspec only: Delivery Branch template with `{workset}` and optional `{ticket}`. */
78
+ branchTemplate?: string;
77
79
  }
78
80
 
79
81
  export type FrameworkType = "working" | "companion" | "hub";
@@ -174,6 +176,8 @@ export interface LaunchRequest {
174
176
  scope?: LaunchScope;
175
177
  skipGit?: boolean;
176
178
  interactiveGit?: boolean;
179
+ /** The launch's preparation already ran and was reported; its notices are not repeated. */
180
+ quiet?: boolean;
177
181
  }
178
182
 
179
183
  export interface LaunchResult {
@@ -0,0 +1,102 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+
4
+ import { gitEnvironment } from "../../runtime/companion-git";
5
+ import { readGitLayout } from "../../runtime/git-layout";
6
+ import { umbrellaChildFolders } from "../../runtime/umbrella-folder";
7
+ import { parseRemote, type ForgeRepo } from "../delivery/forge";
8
+
9
+ export {
10
+ mirroredUmbrellaOf,
11
+ umbrellaFolderOf,
12
+ umbrellaMirroredBy,
13
+ } from "../../runtime/umbrella-folder";
14
+
15
+ /**
16
+ * Umbrella Repositories: a linked folder that is no Git checkout itself and whose
17
+ * direct children are. Derived from the filesystem on every lookup; the registry
18
+ * records nothing about it.
19
+ */
20
+
21
+ const execFileAsync = promisify(execFile);
22
+
23
+ /** A checkout a registry entry stands for. */
24
+ export interface EntryCheckout {
25
+ path: string;
26
+ /** The `origin` URL as `readOrigin` returned it; null without one. */
27
+ origin: string | null;
28
+ /** The forge repository `origin` names; null without one or for another host form. */
29
+ remote: ForgeRepo | null;
30
+ /** The Umbrella Repository holding the checkout; absent for the entry itself. */
31
+ umbrella?: string;
32
+ }
33
+
34
+ /** Reads a checkout's `origin` URL; null without one. */
35
+ export type OriginReader = (checkout: string) => Promise<string | null>;
36
+
37
+ /** Raw config, not `remote get-url`, so `insteadOf` rewrites do not change the identity. */
38
+ const rawOrigin: OriginReader = async (checkout) => {
39
+ try {
40
+ const { stdout } = await execFileAsync("git", ["config", "--get", "remote.origin.url"], {
41
+ cwd: checkout,
42
+ env: gitEnvironment(),
43
+ });
44
+ return stdout.trim() || null;
45
+ } catch {
46
+ return null;
47
+ }
48
+ };
49
+
50
+ /**
51
+ * The Umbrella Repository's children at `folder`, in name order: direct child folders
52
+ * with a Git layout, an `origin` that names a forge repository, and no Repository
53
+ * Link of their own (theirs wins). Empty when `folder` is a Git checkout, so it is no
54
+ * umbrella.
55
+ */
56
+ export async function umbrellaChildrenOf(
57
+ folder: string,
58
+ readOrigin: OriginReader = rawOrigin,
59
+ ): Promise<EntryCheckout[]> {
60
+ if (readGitLayout(folder)) return [];
61
+ const candidates = umbrellaChildFolders(folder);
62
+ const children = await mapBounded(candidates, async (child): Promise<EntryCheckout | null> => {
63
+ const origin = await readOrigin(child);
64
+ const remote = origin ? parseRemote(origin) : null;
65
+ return remote ? { path: child, origin, remote, umbrella: folder } : null;
66
+ });
67
+ return children.filter((child): child is EntryCheckout => child !== null);
68
+ }
69
+
70
+ /** Git subprocesses at once: a broad folder such as `~/src` may hold hundreds of clones. */
71
+ const ORIGIN_READS = 8;
72
+
73
+ /** `map` over `items` in order, at most `ORIGIN_READS` at a time. */
74
+ async function mapBounded<T, R>(items: readonly T[], map: (item: T) => Promise<R>): Promise<R[]> {
75
+ const results: R[] = Array.from({ length: items.length });
76
+ let next = 0;
77
+ const worker = async (): Promise<void> => {
78
+ while (next < items.length) {
79
+ const at = next++;
80
+ // oxlint-disable-next-line no-await-in-loop -- each worker reads one child at a time
81
+ results[at] = await map(items[at]!);
82
+ }
83
+ };
84
+ await Promise.all(Array.from({ length: Math.min(ORIGIN_READS, items.length) }, worker));
85
+ return results;
86
+ }
87
+
88
+ /**
89
+ * The checkouts a registry entry stands for: an Umbrella Repository's children, else
90
+ * the entry's own folder, with its `origin` when it has one. `readChildOrigin` reads the
91
+ * children, raw config by default so every caller gives a child the same identity.
92
+ */
93
+ export async function linkedCheckoutsOf(
94
+ entry: { path: string },
95
+ readOrigin: OriginReader = rawOrigin,
96
+ readChildOrigin: OriginReader = rawOrigin,
97
+ ): Promise<EntryCheckout[]> {
98
+ const children = await umbrellaChildrenOf(entry.path, readChildOrigin);
99
+ if (children.length > 0) return children;
100
+ const origin = await readOrigin(entry.path);
101
+ return [{ path: entry.path, origin, remote: origin ? parseRemote(origin) : null }];
102
+ }
@@ -10,6 +10,7 @@ import {
10
10
  copies as recordedCopies,
11
11
  documents as recordedDocuments,
12
12
  readManifest,
13
+ readManifestNotices,
13
14
  } from "../../runtime/runtime-document-manifest";
14
15
  import { removeRuntimeDocuments } from "./projection-runtime-documents";
15
16
  import {
@@ -103,6 +104,8 @@ export async function project(
103
104
  input: ProjectionInput,
104
105
  ): Promise<ProjectionResult> {
105
106
  const outcomes: ProjectionEntryOutcome[] = [];
107
+ /** Read before any entry rewrites the manifest and drops what it ignored. */
108
+ const warnings = await readManifestNotices(input.repoPath);
106
109
  const runtimes = input.runtimes ? new Set(input.runtimes) : null;
107
110
  for (const entry of projectionEntries()) {
108
111
  if (!entry.scopes.includes(scope)) continue;
@@ -114,7 +117,7 @@ export async function project(
114
117
  outcomes.push(outcome(entry, "failed", toError(error)));
115
118
  }
116
119
  }
117
- return { root: repoLocalDirPath(input.repoPath), scope, outcomes };
120
+ return { root: repoLocalDirPath(input.repoPath), scope, outcomes, warnings };
118
121
  }
119
122
 
120
123
  /**
@@ -124,6 +127,8 @@ export async function project(
124
127
  */
125
128
  export async function unproject(input: ProjectionRemovalInput): Promise<ProjectionRemovalResult> {
126
129
  const outcomes: ProjectionEntryOutcome[] = [];
130
+ /** Read before the Projection Root, manifest included, is removed. */
131
+ const warnings = await readManifestNotices(input.repoPath);
127
132
  for (const entry of projectionEntries().toReversed()) {
128
133
  const { removal } = entry;
129
134
  if (removal.by === "entry") {
@@ -142,7 +147,7 @@ export async function unproject(input: ProjectionRemovalInput): Promise<Projecti
142
147
  outcomes.push(outcome(entry, "failed", toError(error)));
143
148
  }
144
149
  }
145
- return { root: repoLocalDirPath(input.repoPath), outcomes };
150
+ return { root: repoLocalDirPath(input.repoPath), outcomes, warnings };
146
151
  }
147
152
 
148
153
  /**
@@ -231,6 +236,8 @@ export type UnwrapResult =
231
236
  documents: string[];
232
237
  copies: string[];
233
238
  kept?: UnwrapKeptLines;
239
+ /** Ignored manifest records and refused destinations, for the caller to present. */
240
+ warnings: string[];
234
241
  }
235
242
  | { kind: "failed"; document: string; error: Error };
236
243
 
@@ -262,8 +269,14 @@ export async function unwrapWorkingRuntimeDocuments(
262
269
  repoPath: string,
263
270
  globalConfigStore: GlobalConfigStore = new GlobalConfigStore(),
264
271
  ): Promise<UnwrapResult> {
272
+ const notices = await readManifestNotices(repoPath);
265
273
  const manifest = await readManifest(repoPath);
266
274
  const documents = recordedDocuments(manifest);
275
+ const warningsOf = (outcomes: ProjectionEntryOutcome[], refused: string[] = []): string[] => [
276
+ ...notices,
277
+ ...refused,
278
+ ...outcomes.flatMap((entry) => entry.warnings ?? []),
279
+ ];
267
280
  const copies = Object.keys(recordedCopies(manifest));
268
281
  const removeWrapEntries = async (): Promise<ProjectionEntryOutcome[]> =>
269
282
  removeWorkingRepositoryUnwrapEntries(repoPath, await globalConfigStore.list());
@@ -283,6 +296,7 @@ export async function unwrapWorkingRuntimeDocuments(
283
296
  documents: [],
284
297
  copies: removedAny ? copies : [],
285
298
  ...keptLines(outcomes),
299
+ warnings: warningsOf(outcomes),
286
300
  };
287
301
  }
288
302
 
@@ -293,7 +307,7 @@ export async function unwrapWorkingRuntimeDocuments(
293
307
  * a surviving key reads back as still wrapped — leaving a launch refused after
294
308
  * a successful unwrap.
295
309
  */
296
- const { removed, error } = await removeRuntimeDocuments(repoPath, documents);
310
+ const { removed, warnings: refused, error } = await removeRuntimeDocuments(repoPath, documents);
297
311
  /** Reported after the successful withdrawals are already durable. */
298
312
  if (error) return { kind: "failed", document: error.document, error: error.error };
299
313
  const outcomes = await removeWrapEntries();
@@ -305,7 +319,13 @@ export async function unwrapWorkingRuntimeDocuments(
305
319
  error: failure.error ?? new Error("wrap entry removal failed"),
306
320
  };
307
321
  }
308
- return { kind: "unwrapped", documents: removed, copies, ...keptLines(outcomes) };
322
+ return {
323
+ kind: "unwrapped",
324
+ documents: removed,
325
+ copies,
326
+ ...keptLines(outcomes),
327
+ warnings: warningsOf(outcomes, refused),
328
+ };
309
329
  }
310
330
 
311
331
  /**
@@ -143,6 +143,7 @@ export async function runWrapPass(
143
143
  },
144
144
  warnings: [
145
145
  ...rendered.warnings,
146
+ ...result.warnings,
146
147
  ...result.outcomes.flatMap((outcome) => outcome.warnings ?? []),
147
148
  /** A degradable failure does not fail the pass, but it is never silent. */
148
149
  ...result.outcomes