@uniqbit/mate-core 1.0.0-canary.8 → 1.0.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 (244) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/package.json +5 -4
  3. package/src/cli/commands/artifact/delivery/link.ts +1 -1
  4. package/src/cli/commands/artifact/delivery/output.ts +10 -1
  5. package/src/cli/commands/artifact/delivery/resolve.ts +3 -2
  6. package/src/cli/commands/artifact/delivery/submit.ts +9 -4
  7. package/src/cli/commands/artifact/delivery/take.ts +12 -9
  8. package/src/cli/commands/artifact/finish/command.ts +16 -14
  9. package/src/cli/commands/artifact/finish/engine.ts +8 -8
  10. package/src/cli/commands/artifact/project/command.ts +2 -3
  11. package/src/cli/commands/companion/hub.ts +11 -6
  12. package/src/cli/commands/companion/link.ts +173 -46
  13. package/src/cli/commands/doctor.ts +17 -0
  14. package/src/cli/commands/report/contract.ts +0 -17
  15. package/src/cli/commands/studio/access.ts +4 -0
  16. package/src/cli/commands/studio/actions.ts +35 -2
  17. package/src/cli/commands/studio/mcp-manager.ts +162 -0
  18. package/src/cli/commands/studio/routes.ts +12 -0
  19. package/src/cli/commands/studio/selection.ts +44 -11
  20. package/src/cli/commands/studio/server.ts +246 -2
  21. package/src/cli/commands/studio/services.ts +26 -0
  22. package/src/cli/commands/studio/terminal-launch.ts +21 -4
  23. package/src/cli/commands/studio/terminal.ts +3 -14
  24. package/src/cli/commands/studio/work-requests.ts +9 -0
  25. package/src/cli/commands/studio/work.ts +473 -0
  26. package/src/cli/commands/vscode/release-vsix.json +2 -2
  27. package/src/cli/commands/working/cleanup.ts +1 -18
  28. package/src/cli/companion-link-wizard.tsx +158 -91
  29. package/src/cli/usage.ts +1 -1
  30. package/src/create-mate.ts +4 -1
  31. package/src/lib/agent-credential.ts +131 -0
  32. package/src/lib/credential-kinds.ts +7 -0
  33. package/src/lib/delivery/merge-git.ts +16 -0
  34. package/src/lib/delivery/record-delivery.ts +12 -6
  35. package/src/lib/delivery/record.ts +5 -0
  36. package/src/lib/delivery/refresh.ts +34 -6
  37. package/src/lib/delivery/staging/refs.ts +9 -4
  38. package/src/lib/delivery/staging/submit.ts +81 -22
  39. package/src/lib/mcp-manager/resolve.ts +88 -0
  40. package/src/lib/mcp-manager/store.ts +133 -0
  41. package/src/lib/mcp-manager/types.ts +72 -0
  42. package/src/lib/mcp-manager/validate.ts +242 -0
  43. package/src/lib/opencode-server.ts +2 -17
  44. package/src/lib/orchestrator/config-store.ts +30 -7
  45. package/src/lib/orchestrator/engine-floor.ts +16 -4
  46. package/src/lib/orchestrator/engine-guard.ts +7 -1
  47. package/src/lib/orchestrator/repo-local-store.ts +14 -0
  48. package/src/lib/orchestrator/repository-link.ts +80 -52
  49. package/src/lib/orchestrator/root-context.ts +17 -1
  50. package/src/lib/orchestrator/types.ts +4 -0
  51. package/src/lib/studio-chat/agent.ts +139 -0
  52. package/src/lib/studio-chat/companion-context.ts +136 -0
  53. package/src/lib/studio-chat/credential.ts +79 -0
  54. package/src/lib/studio-chat/harness-chat-agent.ts +334 -0
  55. package/src/lib/studio-chat/host-sandbox.ts +578 -0
  56. package/src/lib/studio-chat/prepare-bridges.ts +95 -0
  57. package/src/lib/studio-chat/session.ts +15 -0
  58. package/src/lib/studio-chat/turns.ts +112 -0
  59. package/src/lib/workset/claims.ts +85 -0
  60. package/src/lib/workset/execution.ts +71 -0
  61. package/src/lib/workset/git-transaction.ts +74 -0
  62. package/src/lib/workset/groups.ts +176 -0
  63. package/src/lib/workset/inventory.ts +196 -0
  64. package/src/lib/workset/projection.ts +237 -0
  65. package/src/lib/workset/record.ts +101 -36
  66. package/src/lib/workset/repositories.ts +24 -0
  67. package/src/lib/workset/sharing.ts +951 -0
  68. package/src/lib/workset/stages.ts +50 -14
  69. package/src/lib/workset/transactions.ts +158 -0
  70. package/src/runtime/companion-git-state.ts +1 -0
  71. package/src/runtime/companion-guidance.ts +2 -2
  72. package/src/runtime/forge-remote.ts +6 -0
  73. package/src/runtime/host-process.ts +28 -0
  74. package/src/runtime/secret-guard.ts +18 -1
  75. package/src/runtime/secret-patterns.ts +4 -3
  76. package/src/runtime/submitted-arrivals.ts +28 -2
  77. package/src/runtime/workflow/turn.ts +14 -12
  78. package/src/runtime/write-atomic.ts +2 -2
  79. package/src/studio.ts +61 -0
  80. package/src/templates/capabilities/openspec-cap/mate-full/schema.yaml +1 -1
  81. package/src/templates/capabilities/openspec-cap/mate-full/templates/proposal.md +1 -1
  82. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +3 -2
  83. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +5 -3
  84. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +3 -2
  85. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +5 -3
  86. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +12 -12
  87. package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
  88. package/src/tools/setup/context-services.ts +35 -6
  89. package/src/tools/setup/dynamic-plugins/audiences.ts +3 -2
  90. package/src/tools/setup/dynamic-plugins/declarations.ts +0 -26
  91. package/src/tools/setup/engine.ts +55 -3
  92. package/src/tools/setup/plugin.ts +14 -0
  93. package/src/tools/setup/plugins/gitignore.ts +1 -0
  94. package/src/tools/setup/providers/claude-format.ts +40 -7
  95. package/src/tools/setup/providers/claude.ts +38 -3
  96. package/src/tools/setup/providers/opencode-format.ts +13 -3
  97. package/src/tools/setup/providers/opencode.ts +7 -18
  98. package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
  99. package/studio-dist/THIRD-PARTY-NOTICES.md +297 -0
  100. package/studio-dist/client/THIRD-PARTY-LICENSES.md +4294 -0
  101. package/studio-dist/client/assets/DialogTitle-DOhjDa7H.js +1 -0
  102. package/studio-dist/client/assets/app-CG3vCgyA.css +2 -0
  103. package/studio-dist/client/assets/bundle-mjs-CdK3cBzO.js +1 -0
  104. package/studio-dist/client/assets/button-upSzkd-q.js +1 -0
  105. package/studio-dist/client/assets/chat-DbaMXb8H.js +157 -0
  106. package/studio-dist/client/assets/cn-BCnYnarL.js +1 -0
  107. package/studio-dist/client/assets/combobox-cP9OsRf2.js +1 -0
  108. package/studio-dist/client/assets/{companion-view-C_N237bf.js → companion-view-B54_Lj0S.js} +1 -1
  109. package/studio-dist/client/assets/fields-DNZ4a89M.js +1 -0
  110. package/studio-dist/client/assets/friction-DgEimeDB.js +1 -0
  111. package/studio-dist/client/assets/getting-started-BTfYCt5s.js +1 -0
  112. package/studio-dist/client/assets/{getting-started-djaQeWlu.js → getting-started-CAszmdDJ.js} +1 -1
  113. package/studio-dist/client/assets/getting-started._topic-CHJMf0pa.js +1 -0
  114. package/studio-dist/client/assets/getting-started.index-MR6HftWs.js +1 -0
  115. package/studio-dist/client/assets/{graph-canvas-ySGKMhmk.js → graph-canvas-BdNk2F9O.js} +1 -1
  116. package/studio-dist/client/assets/graph-hRijsC89.js +2 -0
  117. package/studio-dist/client/assets/guides-CwFnh08E.js +1 -0
  118. package/studio-dist/client/assets/highlighted-body-JLMTFACH-BcroQey-.js +1 -0
  119. package/studio-dist/client/assets/index-D5oGyvG8.js +41 -0
  120. package/studio-dist/client/assets/{markdown-view-jMiaBTSO.js → markdown-view-CJ8JsLb7.js} +1 -1
  121. package/studio-dist/client/assets/marked.esm-vFuq1cCd.js +65 -0
  122. package/studio-dist/client/assets/mcp-BE9M-bkO.js +4 -0
  123. package/studio-dist/client/assets/mermaid-WFAXDIZX-BjSsakrn.js +1 -0
  124. package/studio-dist/client/assets/panel-CDQ6Lryw.js +1 -0
  125. package/studio-dist/client/assets/plugins._service._view-DRVPUAWN.js +1 -0
  126. package/studio-dist/client/assets/{prepaint-CKsXyJOR.js → prepaint-sD_LlrDN.js} +1 -1
  127. package/studio-dist/client/assets/{queries-Dfp5deWj.js → queries-COL925ML.js} +1 -1
  128. package/studio-dist/client/assets/react-dom-K3Hp2Cdj.js +1 -0
  129. package/studio-dist/client/assets/{react-BYUSgtBs.js → react-h2xQ_NSp.js} +1 -1
  130. package/studio-dist/client/assets/reports-BClsojkb.js +1 -0
  131. package/studio-dist/client/assets/routes-CJQ2MAej.js +1 -0
  132. package/studio-dist/client/assets/search-DhWdEiKT.js +1 -0
  133. package/studio-dist/client/assets/select-B2FsN9FY.js +1 -0
  134. package/studio-dist/client/assets/skills-SoUHk77W.js +1 -0
  135. package/studio-dist/client/assets/{specs-BrCOjOch.js → specs-C_tZnAvF.js} +1 -1
  136. package/studio-dist/client/assets/specs-view-C6t3Y5IT.js +1 -0
  137. package/studio-dist/client/assets/steps-CF3-Zpmh.js +1 -0
  138. package/studio-dist/client/assets/{store-C3vJq8Wj.js → store-pY9gU4uS.js} +1 -1
  139. package/studio-dist/client/assets/studio-X7bnFrRe.js +36 -0
  140. package/studio-dist/client/assets/studio-queries-CKtAnIKP.js +2 -0
  141. package/studio-dist/client/assets/usage-BaaqUpTG.js +55 -0
  142. package/studio-dist/client/assets/useAnchoredPopupScrollLock-BspHR7Wt.js +1 -0
  143. package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
  144. package/studio-dist/client/assets/useMutation-DKeEoP5S.js +1 -0
  145. package/studio-dist/client/assets/useOpenInteractionType-CtaZCaFT.js +1 -0
  146. package/studio-dist/client/assets/usePopupHandleStore-Bc7Q4bnF.js +1 -0
  147. package/studio-dist/client/assets/vault-sAPFUnPN.js +1 -0
  148. package/studio-dist/client/assets/{warnings-CqOOGlPD.js → warnings-D7YY1HSG.js} +1 -1
  149. package/studio-dist/client/assets/work-BZek_LGB.js +5 -0
  150. package/studio-dist/client/assets/workflow-N5boHXFz.js +1 -0
  151. package/studio-dist/server/THIRD-PARTY-LICENSES.md +4371 -0
  152. package/studio-dist/server/assets/DialogTitle-DnKSl2V0.js +421 -0
  153. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-gVfW5vIV.js → __23tanstack-start-server-fn-resolver-Bli9bpSB.js} +38 -18
  154. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +91 -59
  155. package/studio-dist/server/assets/{actions-D8erOphH.js → actions-CHEFA1i9.js} +33 -1
  156. package/studio-dist/server/assets/{cn-FXJAM0KO.js → bundle-mjs-Ot6dQ8Pq.js} +1 -2056
  157. package/studio-dist/server/assets/{button-D6bvrFmm.js → button-BqA1urbl.js} +14 -7
  158. package/studio-dist/server/assets/chat-zl332Tvu.js +49486 -0
  159. package/studio-dist/server/assets/cn-B0fl6NWK.js +2057 -0
  160. package/studio-dist/server/assets/{combobox-D2MbYV1O.js → combobox-iTjvPCtS.js} +7 -6
  161. package/studio-dist/server/assets/{companion-view-Mf1ANbMb.js → companion-view-DIQ6AFIY.js} +2 -2
  162. package/studio-dist/server/assets/{companions-Dr6IpNAb.js → companions-aVwjRL8j.js} +1 -1
  163. package/studio-dist/server/assets/{fields-B4mAPETz.js → fields-BMap2_Ju.js} +10 -3
  164. package/studio-dist/server/assets/{friction-CWOTjpCV.js → friction-BER50hoD.js} +2 -2
  165. package/studio-dist/server/assets/{friction-9a5S1m7U.js → friction-BPs9KWdq.js} +8 -8
  166. package/studio-dist/server/assets/{getting-started-RU6tYU2Q.js → getting-started-DGfRVmZ_.js} +2 -2
  167. package/studio-dist/server/assets/{getting-started._topic-C02HGrC6.js → getting-started._topic-BgrBA4Vj.js} +2 -2
  168. package/studio-dist/server/assets/{getting-started.index-EzLRosbb.js → getting-started.index-BaFfQ9Mn.js} +2 -2
  169. package/studio-dist/server/assets/{graph-CZ2H9Fzr.js → graph-Cgzlrv3P.js} +8 -8
  170. package/studio-dist/server/assets/{graph-B11ITte0.js → graph-DODpuOy_.js} +1 -1
  171. package/studio-dist/server/assets/{graph-canvas-rP5TT14Z.js → graph-canvas-DW_zU1nA.js} +2 -2
  172. package/studio-dist/server/assets/{guides-BGftp4wf.js → guides-CA_EMG7E.js} +1 -1
  173. package/studio-dist/server/assets/{guides-B8HdeK_C.js → guides-D0SpoD32.js} +1 -1
  174. package/studio-dist/server/assets/{guides.server-DqFQAStf.js → guides.server-DJjQuy03.js} +1 -1
  175. package/studio-dist/server/assets/highlighted-body-JLMTFACH-BeHllu-r.js +41 -0
  176. package/studio-dist/server/assets/{markdown-view-CArpV-CS.js → markdown-view-CvVBGMZV.js} +1 -1
  177. package/studio-dist/server/assets/mcp-BU0fLYyJ.js +1103 -0
  178. package/studio-dist/server/assets/mcp-manager-D9YctTQe.js +50 -0
  179. package/studio-dist/server/assets/mermaid-WFAXDIZX-B1yDN6vG.js +1 -0
  180. package/studio-dist/server/assets/{panel-DR0iq46J.js → panel-D1K6Bsux.js} +4 -32
  181. package/studio-dist/server/assets/{plugins._service._view-n7u2k5dF.js → plugins._service._view-DdO1nELF.js} +4 -4
  182. package/studio-dist/server/assets/{prepaint-B28ClcPN.js → prepaint-BB3dwSmz.js} +1 -1
  183. package/studio-dist/server/assets/{queries-D-yVP9i0.js → queries-BwiDxQy5.js} +1 -1
  184. package/studio-dist/server/assets/{react-CiBZPDs8.js → react-B2cLiz-i.js} +1 -1
  185. package/studio-dist/server/assets/{reports-C2SmTgqh.js → reports-9Pr7Bz6o.js} +7 -7
  186. package/studio-dist/server/assets/{reports-B9k98oE6.js → reports-Cc9M3phM.js} +1 -1
  187. package/studio-dist/server/assets/{router-CPt0TAk_.js → router-DcWe0J7Y.js} +827 -548
  188. package/studio-dist/server/assets/{routes-CwH8LEy2.js → routes-BEXxl0py.js} +8 -8
  189. package/studio-dist/server/assets/{search-b-yQesv3.js → search-bltT7gwy.js} +39 -7
  190. package/studio-dist/server/assets/{select-C3i6TTX-.js → select-CZvHgGCi.js} +7 -6
  191. package/studio-dist/server/assets/{shell-CagqZZMZ.js → shell-BQ0vMKXN.js} +13 -4
  192. package/studio-dist/server/assets/{skills-DGg0mWDM.js → skills-Be_52h0i.js} +1 -1
  193. package/studio-dist/server/assets/{skills-C21Mg_8-.js → skills-BpGGUl6L.js} +8 -8
  194. package/studio-dist/server/assets/{specs-DetoMiaB.js → specs-CCGgXE-V.js} +5 -5
  195. package/studio-dist/server/assets/{specs-view-CmbfLDwN.js → specs-view-DtL5JxYM.js} +12 -11
  196. package/studio-dist/server/assets/{steps-D1tYAyWZ.js → steps-BWFSO6dM.js} +1 -1
  197. package/studio-dist/server/assets/{store-aC-I6f6o.js → store-X7yLPp7v.js} +1 -1
  198. package/studio-dist/server/assets/{studio-queries-Dqf-3nzj.js → studio-queries-ur1ygXi3.js} +117 -13
  199. package/studio-dist/server/assets/{studio-qRvQjRpz.js → studio-qzH-UETC.js} +1555 -179
  200. package/studio-dist/server/assets/{usage-Cwle9-xY.js → usage-C1o0DLzS.js} +1 -1
  201. package/studio-dist/server/assets/{usage-CS4CBK9D.js → usage-DWbSPrPD.js} +10 -9
  202. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-BjMNgXv9.js → useAnchoredPopupScrollLock-DLDmv6kM.js} +4 -135
  203. package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
  204. package/studio-dist/server/assets/{useMutation-DpBIuWXt.js → useMutation-NjlA8oFY.js} +2 -2
  205. package/studio-dist/server/assets/useOpenInteractionType-CZYscfOb.js +136 -0
  206. package/studio-dist/server/assets/usePopupHandleStore-DEEXJYv0.js +26 -0
  207. package/studio-dist/server/assets/{vault-CEBBRLMb.js → vault-B_kfi1h-.js} +1 -1
  208. package/studio-dist/server/assets/{vault-DVQidlId.js → vault-dL79JlKH.js} +8 -115
  209. package/studio-dist/server/assets/{views-UgO0Qz_g.js → views-BSGH56lb.js} +3 -3
  210. package/studio-dist/server/assets/{warnings-C7hgXpdk.js → warnings-DtUVPV-k.js} +2 -2
  211. package/studio-dist/server/assets/work-D789VXGH.js +110 -0
  212. package/studio-dist/server/assets/work-DsCEfhmK.js +3817 -0
  213. package/studio-dist/server/assets/work-requests-BLhOmQFO.js +11 -0
  214. package/studio-dist/server/assets/{workflow-6dZZ1ofw.js → workflow-BOZ2sRYg.js} +9 -9
  215. package/studio-dist/server/server.js +3 -3
  216. package/wrappers/bin/openspec +87 -2
  217. package/studio-dist/client/assets/app-ggXJ_QVh.css +0 -2
  218. package/studio-dist/client/assets/button-amJ3g5oD.js +0 -1
  219. package/studio-dist/client/assets/cn-BQPKiwI4.js +0 -1
  220. package/studio-dist/client/assets/combobox-CJ7aGFid.js +0 -1
  221. package/studio-dist/client/assets/fields-BAiGkJ5N.js +0 -1
  222. package/studio-dist/client/assets/friction-DqOU59v7.js +0 -1
  223. package/studio-dist/client/assets/getting-started-yp42dj5S.js +0 -1
  224. package/studio-dist/client/assets/getting-started._topic-C9zVXz_m.js +0 -1
  225. package/studio-dist/client/assets/getting-started.index-DWbDKICP.js +0 -1
  226. package/studio-dist/client/assets/graph-BYaD_5Bq.js +0 -2
  227. package/studio-dist/client/assets/guides-D6T6W_jV.js +0 -1
  228. package/studio-dist/client/assets/index-Qx7reRPD.js +0 -40
  229. package/studio-dist/client/assets/panel-C4bf_h2W.js +0 -1
  230. package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +0 -1
  231. package/studio-dist/client/assets/reports-JFSwSueq.js +0 -1
  232. package/studio-dist/client/assets/routes-BdOWSgzK.js +0 -1
  233. package/studio-dist/client/assets/search-CXosfvYh.js +0 -1
  234. package/studio-dist/client/assets/select-BHYYWPhK.js +0 -1
  235. package/studio-dist/client/assets/skills-Bo9FLsBd.js +0 -1
  236. package/studio-dist/client/assets/specs-view-CdE2rlli.js +0 -1
  237. package/studio-dist/client/assets/steps-CKUno4lh.js +0 -1
  238. package/studio-dist/client/assets/studio-0ueISxwP.js +0 -100
  239. package/studio-dist/client/assets/studio-queries-BflKt9va.js +0 -2
  240. package/studio-dist/client/assets/usage-BLsLy0nN.js +0 -55
  241. package/studio-dist/client/assets/useAnchoredPopupScrollLock-DC7f8GOp.js +0 -1
  242. package/studio-dist/client/assets/useMutation-uJUrejsi.js +0 -1
  243. package/studio-dist/client/assets/vault-BB1B_OhR.js +0 -1
  244. package/studio-dist/client/assets/workflow-BFzmI-06.js +0 -1
@@ -162,8 +162,9 @@ A drifted spec is published in its own right. It is never shipped by republishin
162
162
 
163
163
  - `no-checkout` → the repository is not linked on this machine and no merge is recorded. Ask the **merge question** below.
164
164
  - `branch-deleted` → the branch is gone on the remote and no default-branch commit contains its head, so it was most likely closed without merging. Ask once per branch whether to drop its changes. Only after the user agrees, drop each submitted change with `mate artifact submit --drop "<name>" --json` (a legacy archive: `--confirm-dropped`, then offer the Git restore below). When the user says it was merged after all, record `--confirm-merged`.
165
- - `likely-merged` → local Git found the branch's changes on the default branch only by patch identity (a `squash` or `rebase` merge, on Git before 2.38), or found its head on the default branch's own line (`fast-forward`, which a branch whose work was never committed looks like too). That is evidence, not proof. Name `suggestion.style` and the short `suggestion.commit`, then ask the **merge question** with **merged** preselected; record it only after the user confirms.
166
- - `not-on-default` → the branch head is not on the default branch as of the last fetch. When the outcome's `fetch.branchDeleted` is true, the branch is deleted on the remote and this machine holds no copy to check (typical after a squash merge someone else delivered): say so and ask the **merge question** directly. When the outcome has no `fetch` field (Mate did not fetch), show `fetchedAt` (or "never fetched") and offer one fetch first; only after the user agrees, re-run `mate artifact link "<anchor>" "<anchor>" --refresh --fetch --json` and use its outcomes. Otherwise, or when the user declines, ask the **merge question**.
165
+ - `likely-merged` → local Git found the branch's changes on the default branch only by patch identity (a `squash` or `rebase` merge, on Git before 2.38), or found its head on the default branch's own line (`fast-forward`). That is evidence, not proof. Name `suggestion.style` and the short `suggestion.commit`, then ask the **merge question** with **merged** preselected; record it only after the user confirms.
166
+ - `empty-branch` → the branch has no commits of its own. Say so; ask the **merge question** with **not yet merged** preselected; never preselect merged.
167
+ - `not-on-default` → the branch head is not on the default branch as of the last fetch. With `fetch.branchUnpushed`, say it was never pushed. When the outcome's `fetch.branchDeleted` is true, the branch is deleted on the remote and this machine holds no copy to check (typical after a squash merge someone else delivered): say so and ask the **merge question** directly. When the outcome has no `fetch` field (Mate did not fetch), show `fetchedAt` (or "never fetched") and offer one fetch first; only after the user agrees, re-run `mate artifact link "<anchor>" "<anchor>" --refresh --fetch --json` and use its outcomes. Otherwise, or when the user declines, ask the **merge question**.
167
168
  - `direct` → a direct delivery is never settled automatically: Git cannot tell this change's commits from the user's other pushes. Ask the **direct-delivery question** below.
168
169
 
169
170
  **The merge question** offers exactly three answers, asked once per branch and applied to every change on it (with `mate artifact publish '<group>' …` for a submitted group):
@@ -81,9 +81,11 @@ it with `mate workflow done <skill> "<change-name>"`; otherwise name it above th
81
81
  submit retries; an unchanged resubmit adds no commit.
82
82
 
83
83
  A non-zero exit without a result is a refusal; report its message. When it names
84
- uncommitted changes, the branch already counts as merged while its work tree holds
85
- modified tracked files: tell the user to commit or stash them and submit again.
86
- Never commit, stash or discard them yourself.
84
+ uncommitted changes, the branch counts or is suggested as merged while its work tree
85
+ holds modified tracked files: tell the user to commit or stash them and submit again.
86
+ For `empty-delivery-branch` (no commits of its own), tell the user to commit the work
87
+ on it or record that repository with `--repository <org/repo> --not-applicable`. Never commit, stash or discard
88
+ them yourself.
87
89
 
88
90
  3. **Report.** Relay every entry of `warnings` first: another active change that
89
91
  modifies the same requirement, a declared dependency that is not submitted yet,
@@ -6399,11 +6399,11 @@ exports[`runtime surface golden fixtures setup openspec × claude 1`] = `
6399
6399
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
6400
6400
  "mate-propose-change/references/openspec-propose.md": "dbd00207ffa4",
6401
6401
  "mate-propose-change/references/openspec-update-change.md": "0b0f6dee9f1e",
6402
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
6402
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
6403
6403
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
6404
6404
  "mate-show-me/SKILL.md": "263dceace1b6",
6405
6405
  "mate-simplify-code/SKILL.md": "ede560857729",
6406
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
6406
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
6407
6407
  },
6408
6408
  "opencodeConfig": null,
6409
6409
  "opencodePlugins": {},
@@ -6815,11 +6815,11 @@ exports[`runtime surface golden fixtures setup openspec × opencode 1`] = `
6815
6815
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
6816
6816
  "mate-propose-change/references/openspec-propose.md": "c1f1d1291283",
6817
6817
  "mate-propose-change/references/openspec-update-change.md": "098ef729c37f",
6818
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
6818
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
6819
6819
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
6820
6820
  "mate-show-me/SKILL.md": "263dceace1b6",
6821
6821
  "mate-simplify-code/SKILL.md": "ede560857729",
6822
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
6822
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
6823
6823
  },
6824
6824
  }
6825
6825
  `;
@@ -7230,11 +7230,11 @@ exports[`runtime surface golden fixtures setup openspec × claude+opencode 1`] =
7230
7230
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
7231
7231
  "mate-propose-change/references/openspec-propose.md": "dbd00207ffa4",
7232
7232
  "mate-propose-change/references/openspec-update-change.md": "0b0f6dee9f1e",
7233
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
7233
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
7234
7234
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
7235
7235
  "mate-show-me/SKILL.md": "263dceace1b6",
7236
7236
  "mate-simplify-code/SKILL.md": "ede560857729",
7237
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
7237
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
7238
7238
  },
7239
7239
  "opencodeConfig": {
7240
7240
  "$schema": "https://opencode.ai/config.json",
@@ -7277,11 +7277,11 @@ exports[`runtime surface golden fixtures setup openspec × claude+opencode 1`] =
7277
7277
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
7278
7278
  "mate-propose-change/references/openspec-propose.md": "c1f1d1291283",
7279
7279
  "mate-propose-change/references/openspec-update-change.md": "098ef729c37f",
7280
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
7280
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
7281
7281
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
7282
7282
  "mate-show-me/SKILL.md": "263dceace1b6",
7283
7283
  "mate-simplify-code/SKILL.md": "ede560857729",
7284
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
7284
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
7285
7285
  },
7286
7286
  }
7287
7287
  `;
@@ -8114,13 +8114,13 @@ Write chunks to $GRAPHIFY_OUT and read $GRAPHIFY_OUT later.
8114
8114
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
8115
8115
  "mate-propose-change/references/openspec-propose.md": "dbd00207ffa4",
8116
8116
  "mate-propose-change/references/openspec-update-change.md": "0b0f6dee9f1e",
8117
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
8117
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
8118
8118
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
8119
8119
  "mate-react-doctor/SKILL.md": "ec2ac7fb877c",
8120
8120
  "mate-react-doctor/references/explain.md": "86754a7e5436",
8121
8121
  "mate-show-me/SKILL.md": "263dceace1b6",
8122
8122
  "mate-simplify-code/SKILL.md": "ede560857729",
8123
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
8123
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
8124
8124
  },
8125
8125
  "opencodeConfig": {
8126
8126
  "$schema": "https://opencode.ai/config.json",
@@ -8199,13 +8199,13 @@ Write chunks to $GRAPHIFY_OUT and read $GRAPHIFY_OUT later.
8199
8199
  "mate-propose-change/references/mate-revise.md": "1f90002ee95d",
8200
8200
  "mate-propose-change/references/openspec-propose.md": "c1f1d1291283",
8201
8201
  "mate-propose-change/references/openspec-update-change.md": "098ef729c37f",
8202
- "mate-publish-artifact/SKILL.md": "54ba2f6a8959",
8202
+ "mate-publish-artifact/SKILL.md": "2cf1844c8b5e",
8203
8203
  "mate-publish-artifact/references/openspec.md": "83196c70960c",
8204
8204
  "mate-react-doctor/SKILL.md": "ec2ac7fb877c",
8205
8205
  "mate-react-doctor/references/explain.md": "86754a7e5436",
8206
8206
  "mate-show-me/SKILL.md": "263dceace1b6",
8207
8207
  "mate-simplify-code/SKILL.md": "ede560857729",
8208
- "mate-submit-change/SKILL.md": "bf2e8c54586e",
8208
+ "mate-submit-change/SKILL.md": "97ce8f1dc43d",
8209
8209
  },
8210
8210
  }
8211
8211
  `;
@@ -0,0 +1,73 @@
1
+ // oxlint-disable no-await-in-loop
2
+ import { resolveMcpServers } from "../../../lib/mcp-manager/resolve";
3
+ import { parseHeaderRef, type ResolvedMcpServer } from "../../../lib/mcp-manager/types";
4
+ import { readAudienceSelection } from "../dynamic-plugins/audiences";
5
+ import type { CapabilityPlugin, McpServerDescriptor } from "../plugin";
6
+
7
+ export const MCP_MANAGER_PLUGIN_ID = "mcp-manager";
8
+
9
+ /** A validated declared server as a descriptor holding references only. */
10
+ export function toMcpServerDescriptor({ name, server }: ResolvedMcpServer): McpServerDescriptor {
11
+ const envRefs = server.env?.length ? { envRefs: server.env } : {};
12
+ if ("command" in server) {
13
+ return {
14
+ name,
15
+ command: server.command,
16
+ ...(server.args ? { args: server.args } : {}),
17
+ ...envRefs,
18
+ };
19
+ }
20
+ const headerRefs = Object.entries(server.headers ?? {}).flatMap(([header, value]) => {
21
+ const ref = parseHeaderRef(value);
22
+ return ref ? [[header, ref] as const] : [];
23
+ });
24
+ return {
25
+ name,
26
+ url: server.url,
27
+ transport: server.transport ?? "http",
28
+ ...envRefs,
29
+ ...(headerRefs.length > 0 ? { headerRefs: Object.fromEntries(headerRefs) } : {}),
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Renders the companion's `mcpManager` servers for the audience in
35
+ * `MATE_AUDIENCE` into every active Agent Runtime. Enabled by the section
36
+ * alone, so it never appears in a setup selector.
37
+ */
38
+ export function createMcpManagerPlugin(
39
+ env: Record<string, string | undefined> = process.env,
40
+ ): CapabilityPlugin {
41
+ return {
42
+ id: MCP_MANAGER_PLUGIN_ID,
43
+ kind: "capability",
44
+ label: "MCP Manager",
45
+ description: "MCP servers the companion declares in framework.yaml.",
46
+ defaultSelected: false,
47
+ selectable: false,
48
+ isEnabled: (config) => config.mcpManager !== undefined,
49
+ getInstallRequirements: () => [],
50
+ async apply(ctx) {
51
+ const servers = resolveMcpServers(ctx.config, readAudienceSelection(env));
52
+ if (servers.length === 0) return;
53
+ const owners = (await ctx.mcp?.owners?.()) ?? new Map<string, string>();
54
+ const declared = Object.keys(ctx.config.mcpManager?.servers ?? {});
55
+ const clashes = declared.flatMap((name) => {
56
+ const owner = owners.get(name);
57
+ return owner ? [`"${name}" (also registered by the "${owner}" Capability)`] : [];
58
+ });
59
+ if (clashes.length > 0) {
60
+ const reason = `${MCP_MANAGER_PLUGIN_ID}: error: mcpManager declares MCP server ${clashes.join(", ")}; rename it in mcpManager.servers. No mcpManager server was rendered.`;
61
+ if (ctx.mcp?.withhold) {
62
+ ctx.mcp.withhold(reason);
63
+ return;
64
+ }
65
+ throw new Error(reason);
66
+ }
67
+ for (const server of servers) {
68
+ await ctx.mcp?.register(toMcpServerDescriptor(server));
69
+ }
70
+ },
71
+ async teardown() {},
72
+ };
73
+ }
@@ -199,6 +199,8 @@ export interface PluginContextServices {
199
199
  services: { mcp: McpService; instructions: InstructionsService; templates: TemplatesService };
200
200
  /** MCP server names and instruction block keys registered during this run. */
201
201
  registered: { mcpServers: Set<string>; instructionBlocks: Set<string> };
202
+ /** Set by `mcp.withhold`: finalize keeps this plugin's previous MCP servers and their record. */
203
+ mcpWithheld?: boolean;
202
204
  }
203
205
 
204
206
  export interface ContextServiceMediatorOptions {
@@ -207,6 +209,8 @@ export interface ContextServiceMediatorOptions {
207
209
  hostingProviders: HostingProvider[];
208
210
  assetOverrideRoots?: string[];
209
211
  warn(message: string): void;
212
+ /** MCP server names enabled Capabilities declare as contributions, by name to plugin id. */
213
+ declaredMcpOwners?(): Promise<ReadonlyMap<string, string>>;
210
214
  }
211
215
 
212
216
  /**
@@ -244,11 +248,25 @@ export class ContextServiceMediator {
244
248
  );
245
249
  return;
246
250
  }
251
+ if (entry?.mcpWithheld) return;
247
252
  for (const provider of hosts) {
248
253
  await provider.hosting.mcp?.register(ctx, descriptor);
249
254
  }
250
255
  registered.mcpServers.add(descriptor.name);
251
256
  },
257
+ owners: async () => {
258
+ const owners = new Map(await this.options.declaredMcpOwners?.());
259
+ for (const [otherId, other] of this.byPlugin) {
260
+ if (otherId === pluginId) continue;
261
+ for (const name of other.registered.mcpServers) owners.set(name, otherId);
262
+ }
263
+ owners.forEach((owner, name) => owner === pluginId && owners.delete(name));
264
+ return owners;
265
+ },
266
+ withhold: (reason: string) => {
267
+ if (entry) entry.mcpWithheld = true;
268
+ warn(reason);
269
+ },
252
270
  };
253
271
 
254
272
  const instructions: InstructionsService = {
@@ -297,6 +315,13 @@ export class ContextServiceMediator {
297
315
  return entry;
298
316
  }
299
317
 
318
+ /** MCP server names any plugin registered in this pass. */
319
+ registeredMcpServers(): Set<string> {
320
+ return new Set(
321
+ [...this.byPlugin.values()].flatMap((entry) => [...entry.registered.mcpServers]),
322
+ );
323
+ }
324
+
300
325
  /**
301
326
  * Reconcile the bookkeeping manifest: remove provider entries that were
302
327
  * previously registered but not re-registered in this run, then persist the
@@ -307,11 +332,17 @@ export class ContextServiceMediator {
307
332
  const manifestPath = getContextServicesManifestPath(ctx.companionPath, frameworkName);
308
333
  const manifest = await loadManifest(manifestPath);
309
334
 
335
+ /** A name that moved to another plugin this pass is that plugin's now, never removed. */
336
+ const registeredThisPass = this.registeredMcpServers();
337
+
310
338
  for (const [pluginId, entry] of this.byPlugin) {
311
339
  const previous = manifest.plugins[pluginId] ?? {};
312
- const staleMcpServers = (previous.mcpServers ?? []).filter(
313
- (name) => !entry.registered.mcpServers.has(name),
314
- );
340
+ const mcpServers = entry.mcpWithheld
341
+ ? (previous.mcpServers ?? [])
342
+ : [...entry.registered.mcpServers];
343
+ const staleMcpServers = entry.mcpWithheld
344
+ ? []
345
+ : (previous.mcpServers ?? []).filter((name) => !registeredThisPass.has(name));
315
346
  const staleBlocks = (previous.instructionBlocks ?? []).filter(
316
347
  (blockKey) => !entry.registered.instructionBlocks.has(blockKey),
317
348
  );
@@ -329,9 +360,7 @@ export class ContextServiceMediator {
329
360
  }
330
361
 
331
362
  const record: PluginServiceRecord = {};
332
- if (entry.registered.mcpServers.size > 0) {
333
- record.mcpServers = [...entry.registered.mcpServers];
334
- }
363
+ if (mcpServers.length > 0) record.mcpServers = mcpServers;
335
364
  if (entry.registered.instructionBlocks.size > 0) {
336
365
  record.instructionBlocks = [...entry.registered.instructionBlocks];
337
366
  }
@@ -16,7 +16,7 @@ export const AUDIENCE_ENV = "MATE_AUDIENCE";
16
16
  export const BASE_AUDIENCE = "base";
17
17
 
18
18
  /** The keys 0.18.4 moved under `audiences.base`; companion-wide keys stayed at the root. */
19
- export const BASE_AUDIENCE_KEYS = ["capabilities", "plugins", "studio"] as const;
19
+ export const BASE_AUDIENCE_KEYS = ["capabilities", "plugins", "studio", "mcpManager"] as const;
20
20
 
21
21
  export type AudienceResolution =
22
22
  | { ok: true; active: string | null }
@@ -30,7 +30,8 @@ function pluginList(value: unknown): unknown[] {
30
30
  return isRecord(value) && Array.isArray(value.plugins) ? value.plugins : [];
31
31
  }
32
32
 
33
- function audienceEntry(raw: unknown, audience: string | null): unknown {
33
+ /** The raw entry of a declared audience; undefined for none, `base` or an undeclared one. */
34
+ export function audienceEntry(raw: unknown, audience: string | null): unknown {
34
35
  if (audience === null || audience === BASE_AUDIENCE) return undefined;
35
36
  if (!isRecord(raw) || !isRecord(raw.audiences)) return undefined;
36
37
  return Object.hasOwn(raw.audiences, audience) ? raw.audiences[audience] : undefined;
@@ -1,36 +1,10 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
-
4
- import { parse } from "yaml";
5
-
6
- import { FRAMEWORK_NAME } from "../../../framework";
7
1
  import { PLUGIN_DECLARATION_POLICIES } from "../../../lib/orchestrator/config-store";
8
2
  import type { PluginDeclaration } from "../../../lib/orchestrator/types";
9
- import { normalizeBaseAudience } from "./audiences";
10
3
 
11
4
  function isRecord(value: unknown): value is Record<string, unknown> {
12
5
  return typeof value === "object" && value !== null && !Array.isArray(value);
13
6
  }
14
7
 
15
- /**
16
- * Raw read of the companion's `plugins:` list. Deliberately avoids
17
- * `ConfigStore.load()` — hydration runs on every invocation and must never
18
- * create or migrate config files as a side effect.
19
- */
20
- export async function readDeclarations(companionPath: string): Promise<unknown[]> {
21
- try {
22
- const raw = await fs.readFile(
23
- path.join(companionPath, `.${FRAMEWORK_NAME}`, "config", "framework.yaml"),
24
- "utf8",
25
- );
26
- const parsed = normalizeBaseAudience(parse(raw) as unknown);
27
- if (!isRecord(parsed) || !Array.isArray(parsed.plugins)) return [];
28
- return parsed.plugins;
29
- } catch {
30
- return [];
31
- }
32
- }
33
-
34
8
  export function validateDeclaration(entry: unknown): {
35
9
  declaration?: PluginDeclaration;
36
10
  error?: string;
@@ -4,6 +4,7 @@ import { FRAMEWORK_NAME } from "../../framework";
4
4
  import type { FrameworkConfig } from "../../lib/orchestrator/types";
5
5
  import { getClaudePluginRoot } from "../../lib/package-paths";
6
6
  import type { RenderedRuntimeDocuments } from "../../runtime/runtime-document-manifest";
7
+ import { MCP_MANAGER_PLUGIN_ID } from "./capabilities/mcp-manager";
7
8
  import { collectHostingProviders, ContextServiceMediator } from "./context-services";
8
9
  import type {
9
10
  CapabilityContributionInput,
@@ -55,6 +56,19 @@ export interface SetupInstallationOutcome {
55
56
  claudePluginFolders: ClaudePluginFolders;
56
57
  }
57
58
 
59
+ /**
60
+ * A phase's entries in registration order, except that `mcp-manager` applies
61
+ * after every other Capability, including hydrated ones, so its clash check
62
+ * sees the servers they register.
63
+ */
64
+ function phaseEntries(entries: NormalizedRegistration[], phase: Plugin["kind"]) {
65
+ const inPhase = entries.filter((candidate) => candidate.plugin.kind === phase);
66
+ return [
67
+ ...inPhase.filter((entry) => entry.plugin.id !== MCP_MANAGER_PLUGIN_ID),
68
+ ...inPhase.filter((entry) => entry.plugin.id === MCP_MANAGER_PLUGIN_ID),
69
+ ];
70
+ }
71
+
58
72
  export function buildSetupInstallationPlan(
59
73
  config: FrameworkConfig,
60
74
  registrations: PluginRegistration[],
@@ -78,7 +92,7 @@ export function buildSetupInstallationPlan(
78
92
  "integration",
79
93
  "root",
80
94
  ] as const) {
81
- for (const entry of entries.filter((candidate) => candidate.plugin.kind === phase)) {
95
+ for (const entry of phaseEntries(entries, phase)) {
82
96
  const plugin = entry.plugin;
83
97
  if (phase === "root") {
84
98
  actions.push({ phase, pluginId: plugin.id, action: "apply" });
@@ -145,6 +159,18 @@ export async function executeSetupInstallationPlan(
145
159
  warnings.push(message);
146
160
  emitWarning(message);
147
161
  },
162
+ declaredMcpOwners: async () => {
163
+ const owners = new Map<string, string>();
164
+ /** A rejecting Capability fails the reconcile below, which reports it. */
165
+ const inputs = await collectContributionInputs(ctx, plugins, plan, () => {});
166
+ for (const input of [...inputs.values()].flat()) {
167
+ if (!input.capabilityEnabled) continue;
168
+ for (const server of input.contributions.mcpServers ?? []) {
169
+ owners.set(server.name, input.pluginId);
170
+ }
171
+ }
172
+ return owners;
173
+ },
148
174
  });
149
175
 
150
176
  for (const action of plan.actions) {
@@ -196,7 +222,12 @@ export async function executeSetupInstallationPlan(
196
222
 
197
223
  await mediator.finalize();
198
224
 
199
- const inputsByRuntime = await reconcileCapabilityContributions(ctx, plugins, plan);
225
+ const inputsByRuntime = await reconcileCapabilityContributions(
226
+ ctx,
227
+ plugins,
228
+ plan,
229
+ mediator.registeredMcpServers(),
230
+ );
200
231
  const claudeInputs = inputsByRuntime.get("claude") ?? [];
201
232
  const folderOptions = { bundledPluginRoot: getClaudePluginRoot() };
202
233
  const claudePluginFolders =
@@ -305,16 +336,37 @@ async function reconcileCapabilityContributions(
305
336
  ctx: SetupContext,
306
337
  plugins: Plugin[],
307
338
  plan: SetupInstallationPlan,
339
+ registeredMcpServers: ReadonlySet<string>,
308
340
  ): Promise<Map<string, CapabilityContributionInput[]>> {
309
341
  const inputsByRuntime = await collectContributionInputs(ctx, plugins, plan);
310
342
  for (const [runtimeId, inputs] of inputsByRuntime) {
311
343
  const reconcile = RUNTIME_SURFACE_RECONCILERS[runtimeId];
312
344
  if (!reconcile || inputs.length === 0) continue;
313
- await reconcile(ctx, inputs);
345
+ /** The mediator registers through active runtimes only. */
346
+ const spared = plan.activeProviders.includes(runtimeId)
347
+ ? registeredMcpServers
348
+ : new Set<string>();
349
+ await reconcile(
350
+ ctx,
351
+ inputs.map((input) => sparingRegistered(input, spared)),
352
+ );
314
353
  }
315
354
  return inputsByRuntime;
316
355
  }
317
356
 
357
+ /** A disabled Capability's teardown never removes a name another plugin registered this pass. */
358
+ function sparingRegistered(
359
+ input: CapabilityContributionInput,
360
+ registered: ReadonlySet<string>,
361
+ ): CapabilityContributionInput {
362
+ const servers = input.contributions.mcpServers;
363
+ if (input.capabilityEnabled || !servers?.some((server) => registered.has(server.name))) {
364
+ return input;
365
+ }
366
+ const mcpServers = servers.filter((server) => !registered.has(server.name));
367
+ return { ...input, contributions: { ...input.contributions, mcpServers } };
368
+ }
369
+
318
370
  /** Receives one Capability's rejected contributions; that Capability then contributes nothing. */
319
371
  export type ContributionErrorHandler = (capabilityId: string, error: unknown) => void;
320
372
 
@@ -78,11 +78,25 @@ export interface McpServerDescriptor {
78
78
  command?: string;
79
79
  args?: string[];
80
80
  url?: string;
81
+ /** Remote transport; absent leaves the runtime's default. */
82
+ transport?: "http" | "sse";
83
+ /** Literal values, written as given. */
81
84
  env?: Record<string, string>;
85
+ /** Variable names the runtime expands at start; a value is never written. */
86
+ envRefs?: string[];
87
+ /** Header name to a literal prefix and one variable the runtime expands at start. */
88
+ headerRefs?: Record<string, { prefix: string; variable: string }>;
82
89
  }
83
90
 
84
91
  export interface McpService {
85
92
  register(descriptor: McpServerDescriptor): Promise<void>;
93
+ /**
94
+ * MCP server names other plugins own in this pass, by name to plugin id:
95
+ * those registered so far and those enabled Capabilities declare.
96
+ */
97
+ owners?(): Promise<ReadonlyMap<string, string>>;
98
+ /** Registers nothing more this pass and keeps the plugin's previous servers in place, reporting `reason`. */
99
+ withhold?(reason: string): void;
86
100
  }
87
101
 
88
102
  export interface InstructionsService {
@@ -107,6 +107,7 @@ export function collectManagedGitignoreEntries(ctx: SetupContext, plugins: Plugi
107
107
  // Holds absolute local paths of every linked working repo; never shared
108
108
  // across machines or committed to the companion repo.
109
109
  `.${FRAMEWORK_NAME}/config/registry.yaml`,
110
+ `.${FRAMEWORK_NAME}/scratchpad/`,
110
111
  ".mcp.json.bak",
111
112
  // Listed before a member's first local plugin, so that one never shows in `git status`.
112
113
  LOCAL_PLUGINS_FILE_GITIGNORE_ENTRY,
@@ -11,19 +11,44 @@ export interface McpEntryDescriptor {
11
11
  command?: string;
12
12
  args?: string[];
13
13
  url?: string;
14
+ transport?: "http" | "sse";
14
15
  env?: Record<string, string>;
16
+ envRefs?: string[];
17
+ headerRefs?: Record<string, { prefix: string; variable: string }>;
15
18
  }
16
19
 
20
+ /** Literal `env` plus each reference rendered by `ref`; undefined when there is neither. */
21
+ export function mcpEntryEnvironment(
22
+ descriptor: McpEntryDescriptor,
23
+ ref: (variable: string) => string,
24
+ ): Record<string, string> | undefined {
25
+ if (!descriptor.env && !descriptor.envRefs?.length) return undefined;
26
+ return {
27
+ ...descriptor.env,
28
+ ...Object.fromEntries((descriptor.envRefs ?? []).map((name) => [name, ref(name)])),
29
+ };
30
+ }
31
+
32
+ /** Header references rendered by `ref`; undefined when there are none. */
33
+ export function mcpEntryHeaders(
34
+ descriptor: McpEntryDescriptor,
35
+ ref: (variable: string) => string,
36
+ ): Record<string, string> | undefined {
37
+ const entries = Object.entries(descriptor.headerRefs ?? {});
38
+ if (entries.length === 0) return undefined;
39
+ return Object.fromEntries(
40
+ entries.map(([header, { prefix, variable }]) => [header, `${prefix}${ref(variable)}`]),
41
+ );
42
+ }
43
+
44
+ const claudeRef = (variable: string) => `\${${variable}}`;
45
+
17
46
  // Claude runtime config format primitives: parse/merge/serialize for
18
47
  // `settings.local.json` (hook maps, permissions) and `.mcp.json`. Which hook
19
48
  // groups are Mate-managed lives here too, because the companion-side reconcile
20
49
  // and the working-repo projection entry must strip the same set.
21
50
 
22
- export {
23
- hookGroupKey,
24
- type ClaudeHookCommand,
25
- type ClaudeHookGroup,
26
- } from "../../../runtime/claude-hook-group";
51
+ export { hookGroupKey, type ClaudeHookGroup } from "../../../runtime/claude-hook-group";
27
52
 
28
53
  export type ClaudeHookMap = Record<string, ClaudeHookGroup[]>;
29
54
 
@@ -165,11 +190,19 @@ export async function writeClaudeMcpConfig(
165
190
 
166
191
  /** Map a provider-agnostic MCP descriptor to Claude's `.mcp.json` entry shape. */
167
192
  export function toClaudeMcpEntry(descriptor: McpEntryDescriptor): Record<string, unknown> {
168
- if (descriptor.url) return { url: descriptor.url };
193
+ if (descriptor.url) {
194
+ const headers = mcpEntryHeaders(descriptor, claudeRef);
195
+ return {
196
+ ...(descriptor.transport ? { type: descriptor.transport } : {}),
197
+ url: descriptor.url,
198
+ ...(headers ? { headers } : {}),
199
+ };
200
+ }
201
+ const env = mcpEntryEnvironment(descriptor, claudeRef);
169
202
  return {
170
203
  command: descriptor.command,
171
204
  ...(descriptor.args ? { args: descriptor.args } : {}),
172
- ...(descriptor.env ? { env: descriptor.env } : {}),
205
+ ...(env ? { env } : {}),
173
206
  };
174
207
  }
175
208
 
@@ -68,6 +68,7 @@ import {
68
68
  mateTokensaveRouteHookGroups,
69
69
  mateTurnHookGroups,
70
70
  } from "./claude-plugin-hooks";
71
+ import { relativePathWarnings } from "./relative-path-warnings";
71
72
  import { getSetupRootTemplates } from "./utils";
72
73
 
73
74
  async function configureClaudeGuidance(companionPath: string): Promise<void> {
@@ -213,7 +214,7 @@ export function getCompanionClaudeSettingsPath(companionPath: string): string {
213
214
  return path.join(companionPath, ".claude", "settings.local.json");
214
215
  }
215
216
 
216
- /** Companion-owned `.mcp.json`; loaded via `--mcp-config` only by a companion-scoped launch. */
217
+ /** Companion-owned `.mcp.json`; loaded via `--mcp-config` by a companion-scoped launch, carried into Claude wraps. */
217
218
  export function getCompanionClaudeMcpConfigPath(companionPath: string): string {
218
219
  return path.join(companionPath, ".mcp.json");
219
220
  }
@@ -524,6 +525,25 @@ function claudePluginRegions(published: readonly PublishedClaudePluginFolder[]):
524
525
  ];
525
526
  }
526
527
 
528
+ /**
529
+ * Companion `.mcp.json` servers a wrap carries. Servers a Capability registered
530
+ * during setup exist only there. Skips names Mate declares: an enabled one
531
+ * renders its own entry, a disabled one's entry is stale until the next sync.
532
+ */
533
+ async function readCarriedCompanionMcpServers(
534
+ mcpConfigPath: string,
535
+ inputs: CapabilityContributionInput[],
536
+ ): Promise<Record<string, unknown>> {
537
+ const { mcpServers } = (await readClaudeMcpConfig(mcpConfigPath)).config;
538
+ if (typeof mcpServers !== "object" || mcpServers === null || Array.isArray(mcpServers)) {
539
+ return {};
540
+ }
541
+ const declared = new Set(
542
+ inputs.flatMap((input) => (input.contributions.mcpServers ?? []).map(({ name }) => name)),
543
+ );
544
+ return Object.fromEntries(Object.entries(mcpServers).filter(([name]) => !declared.has(name)));
545
+ }
546
+
527
547
  /**
528
548
  * The working target's Claude documents, rendered as values. Each is a document
529
549
  * the runtime finds by walking up from the current directory, and every path
@@ -539,6 +559,8 @@ export async function renderClaudeWorkingDocuments(
539
559
  const pluginFolders = (
540
560
  await inspectClaudePluginFolders(inputs, { bundledPluginRoot: getClaudePluginRoot() })
541
561
  ).published;
562
+ const companionMcpConfigPath = getCompanionClaudeMcpConfigPath(ctx.companionPath);
563
+ const companionMcpServers = await readCarriedCompanionMcpServers(companionMcpConfigPath, inputs);
542
564
  return {
543
565
  documents: [
544
566
  ...renderedDocument(
@@ -570,11 +592,14 @@ export async function renderClaudeWorkingDocuments(
570
592
  {
571
593
  at: ["projects", repoRoot, "mcpServers"],
572
594
  kind: "map",
573
- entries: renderManagedClaudeMcpServers(inputs),
595
+ entries: { ...companionMcpServers, ...renderManagedClaudeMcpServers(inputs) },
574
596
  },
575
597
  ]),
576
598
  ],
577
- warnings: [],
599
+ warnings: relativePathWarnings(companionMcpConfigPath, companionMcpServers, ["mcpServers"], {
600
+ document: CLAUDE_LOCAL_CONFIG_DOCUMENT,
601
+ resolvesAgainst: "the session's directory",
602
+ }),
578
603
  };
579
604
  }
580
605
 
@@ -800,6 +825,12 @@ async function teardownClaude(companionPath: string, allowedAgents: string[]): P
800
825
  }
801
826
  }
802
827
 
828
+ async function removeHubAppliedClaudeFiles(ctx: SetupContext): Promise<void> {
829
+ await fs.rm(getCompanionClaudeSettingsPath(ctx.companionPath), { force: true });
830
+ await fs.rm(getCompanionClaudeMcpConfigPath(ctx.companionPath), { force: true });
831
+ await pruneEmptyAncestors(path.join(ctx.companionPath, ".claude"), ctx.companionPath);
832
+ }
833
+
803
834
  async function teardownLegacyClaudeBin(companionPath: string): Promise<void> {
804
835
  try {
805
836
  await fs.rm(path.join(companionPath, ".claude", "bin"), { recursive: true, force: true });
@@ -946,6 +977,10 @@ export function createClaudePlugin(): ProviderPlugin {
946
977
  await syncCompanionClaudeSettings(ctx.companionPath, ctx.config);
947
978
  },
948
979
  async teardown(ctx) {
980
+ if (ctx.scope === "hub") {
981
+ await removeHubAppliedClaudeFiles(ctx);
982
+ return;
983
+ }
949
984
  await teardownClaude(ctx.companionPath, ctx.config.allowedAgents ?? []);
950
985
  },
951
986
  };