@uniqbit/mate-core 1.0.0-canary.7 → 1.0.0-canary.9

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 (225) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/package.json +6 -3
  3. package/src/cli/commands/artifact/delivery/submit.ts +6 -4
  4. package/src/cli/commands/artifact/finish/command.ts +28 -11
  5. package/src/cli/commands/artifact/pending/command.ts +71 -7
  6. package/src/cli/commands/cap/tokensave.ts +2 -2
  7. package/src/cli/commands/companion/update.ts +2 -3
  8. package/src/cli/commands/doctor.ts +33 -4
  9. package/src/cli/commands/install.ts +8 -4
  10. package/src/cli/commands/plugin/install.ts +82 -35
  11. package/src/cli/commands/studio/service-host.ts +3 -0
  12. package/src/cli/commands/triage.ts +32 -11
  13. package/src/cli/commands/vscode/release-vsix.json +2 -2
  14. package/src/cli/install-plan.tsx +3 -0
  15. package/src/cli/main.ts +51 -7
  16. package/src/cli/usage.ts +3 -3
  17. package/src/create-mate.ts +4 -1
  18. package/src/factory-host.ts +6 -0
  19. package/src/index.ts +1 -0
  20. package/src/lib/delivery/merge-git.ts +31 -7
  21. package/src/lib/delivery/overlap.ts +14 -1
  22. package/src/lib/delivery/repository-access.ts +11 -6
  23. package/src/lib/delivery/staging/apply-chain.ts +25 -7
  24. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  25. package/src/lib/delivery/staging/naming.ts +3 -0
  26. package/src/lib/delivery/staging/openspec-type.ts +38 -7
  27. package/src/lib/delivery/staging/pending.ts +153 -11
  28. package/src/lib/delivery/staging/preflight.ts +239 -0
  29. package/src/lib/delivery/staging/project.ts +243 -104
  30. package/src/lib/delivery/staging/replay.ts +5 -3
  31. package/src/lib/delivery/staging/settle-linked.ts +5 -119
  32. package/src/lib/delivery/staging/submit.ts +139 -18
  33. package/src/lib/delivery/submit-change.ts +163 -37
  34. package/src/lib/friction/mark.ts +49 -11
  35. package/src/lib/friction/view/read.ts +10 -1
  36. package/src/lib/mcp-manager/resolve.ts +70 -0
  37. package/src/lib/mcp-manager/store.ts +109 -0
  38. package/src/lib/mcp-manager/types.ts +58 -0
  39. package/src/lib/mcp-manager/validate.ts +246 -0
  40. package/src/lib/openspec-cli.ts +10 -5
  41. package/src/lib/orchestrator/config-store.ts +30 -7
  42. package/src/lib/orchestrator/engine-floor.ts +16 -4
  43. package/src/lib/orchestrator/engine-guard.ts +7 -1
  44. package/src/lib/orchestrator/types.ts +4 -0
  45. package/src/lib/skills-cli.ts +38 -0
  46. package/src/lib/tool-manifest.ts +73 -0
  47. package/src/lib/triage/context.ts +138 -12
  48. package/src/lib/triage/prepare.ts +19 -4
  49. package/src/plugin-api.ts +1 -0
  50. package/src/runtime/command-arg.ts +15 -0
  51. package/src/runtime/companion-guidance.ts +1 -1
  52. package/src/runtime/friction-log.ts +41 -17
  53. package/src/runtime/friction-recorder.ts +15 -2
  54. package/src/runtime/git-tracked.ts +13 -2
  55. package/src/runtime/workflow/turn.ts +14 -12
  56. package/src/studio.ts +23 -1
  57. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +5 -1
  58. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  59. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +42 -4
  60. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +27 -2
  61. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  62. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +26 -1
  63. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +28 -0
  64. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +28 -3
  65. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  66. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  67. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  68. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  69. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +28 -3
  70. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +28 -6
  71. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +27 -2
  72. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +28 -0
  73. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +24 -2
  74. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +42 -4
  75. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +27 -2
  76. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  77. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +26 -1
  78. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +28 -0
  79. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +28 -3
  80. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  81. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  82. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  83. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  84. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +28 -3
  85. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +28 -6
  86. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +27 -2
  87. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +28 -0
  88. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +24 -2
  89. package/src/templates/triage/PLAYBOOK.md +9 -1
  90. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +108 -108
  91. package/src/tools/setup/capabilities/graphify.ts +23 -1
  92. package/src/tools/setup/capabilities/mcp-manager.ts +74 -0
  93. package/src/tools/setup/capabilities/rtk.ts +27 -86
  94. package/src/tools/setup/capabilities/tokensave.ts +76 -54
  95. package/src/tools/setup/context-services.ts +35 -6
  96. package/src/tools/setup/dynamic-plugins/audiences.ts +31 -16
  97. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  98. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  99. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  100. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  101. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  102. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  103. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  104. package/src/tools/setup/dynamic-plugins/workspaces.ts +17 -8
  105. package/src/tools/setup/engine.ts +55 -3
  106. package/src/tools/setup/mate.ts +26 -1
  107. package/src/tools/setup/plugin.ts +14 -0
  108. package/src/tools/setup/plugins/gitignore.ts +45 -12
  109. package/src/tools/setup/providers/claude-format.ts +39 -2
  110. package/src/tools/setup/providers/claude.ts +10 -0
  111. package/src/tools/setup/providers/opencode-format.ts +13 -3
  112. package/src/tools/setup/service.ts +8 -0
  113. package/src/tools/setup/utils.ts +10 -1
  114. package/studio-dist/client/assets/app-ggXJ_QVh.css +2 -0
  115. package/studio-dist/client/assets/button-C9SQW3kI.js +1 -0
  116. package/studio-dist/client/assets/cn-DC80MJV0.js +1 -0
  117. package/studio-dist/client/assets/combobox-D7mKYCBb.js +1 -0
  118. package/studio-dist/client/assets/{companion-view-DINdPF-b.js → companion-view-C1F0_jbt.js} +1 -1
  119. package/studio-dist/client/assets/fields-CEep8IFT.js +1 -0
  120. package/studio-dist/client/assets/friction-D9dBU7WN.js +1 -0
  121. package/studio-dist/client/assets/getting-started-BDyGvHhc.js +1 -0
  122. package/studio-dist/client/assets/{getting-started-djaQeWlu.js → getting-started-BN4aTpsz.js} +1 -1
  123. package/studio-dist/client/assets/getting-started._topic-B9ajbF4o.js +1 -0
  124. package/studio-dist/client/assets/getting-started.index-CYiBPtb7.js +1 -0
  125. package/studio-dist/client/assets/graph-ah7ZXfTa.js +2 -0
  126. package/studio-dist/client/assets/{graph-canvas-DIcAqwtK.js → graph-canvas-Be5qgdDt.js} +1 -1
  127. package/studio-dist/client/assets/guides-CsL0660B.js +1 -0
  128. package/studio-dist/client/assets/index-zmRH87D4.js +40 -0
  129. package/studio-dist/client/assets/{markdown-view-jMiaBTSO.js → markdown-view-dku7MGPn.js} +1 -1
  130. package/studio-dist/client/assets/panel-COgk0vP5.js +1 -0
  131. package/studio-dist/client/assets/plugins._service._view-Cn3WBHab.js +1 -0
  132. package/studio-dist/client/assets/{prepaint-CKsXyJOR.js → prepaint-BkoDSw5X.js} +1 -1
  133. package/studio-dist/client/assets/{queries-Dfp5deWj.js → queries-CMvC2OkU.js} +1 -1
  134. package/studio-dist/client/assets/reports-C_AqLBYH.js +1 -0
  135. package/studio-dist/client/assets/routes-BokQmHtC.js +1 -0
  136. package/studio-dist/client/assets/{search-CXosfvYh.js → search-DxidNK2M.js} +1 -1
  137. package/studio-dist/client/assets/select-CYFCbHUd.js +1 -0
  138. package/studio-dist/client/assets/skills-R3vttWHM.js +1 -0
  139. package/studio-dist/client/assets/{specs-Dl8HfGlU.js → specs-Bqd1ajyD.js} +1 -1
  140. package/studio-dist/client/assets/specs-view-znqFPx9p.js +1 -0
  141. package/studio-dist/client/assets/{steps-CKUno4lh.js → steps-tVDWn7j6.js} +1 -1
  142. package/studio-dist/client/assets/{store-DyXbi6o9.js → store-BYnEU33C.js} +1 -1
  143. package/studio-dist/client/assets/studio-ndtFcS2Y.js +100 -0
  144. package/studio-dist/client/assets/{studio-queries-BflKt9va.js → studio-queries-CkUSByy7.js} +1 -1
  145. package/studio-dist/client/assets/{usage-Blcl8kA_.js → usage-Kuhr8dSl.js} +13 -13
  146. package/studio-dist/client/assets/{useAnchoredPopupScrollLock-BBXJpX5L.js → useAnchoredPopupScrollLock-dc_kP4Go.js} +1 -1
  147. package/studio-dist/client/assets/useMutation-CqtM9COw.js +1 -0
  148. package/studio-dist/client/assets/vault-CSP8kwRg.js +1 -0
  149. package/studio-dist/client/assets/warnings-Cnw99ugO.js +1 -0
  150. package/studio-dist/client/assets/workflow-BPJAmmZi.js +1 -0
  151. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-JoHQ5ihx.js → __23tanstack-start-server-fn-resolver-CS3QRY4Q.js} +18 -18
  152. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +58 -58
  153. package/studio-dist/server/assets/{button-B7e1fRyW.js → button-Ct_WeYLc.js} +3 -3480
  154. package/studio-dist/server/assets/cn-DWFJaP_9.js +5528 -0
  155. package/studio-dist/server/assets/{combobox--S_OmUfh.js → combobox-17vO5Uz8.js} +6 -5
  156. package/studio-dist/server/assets/{companion-view-D-vGM55e.js → companion-view-JkxnGLlp.js} +2 -2
  157. package/studio-dist/server/assets/{companions-Dr6IpNAb.js → companions-YNLsbnch.js} +1 -1
  158. package/studio-dist/server/assets/{fields-B4qM2ZwC.js → fields-VytPpqBq.js} +2 -1
  159. package/studio-dist/server/assets/{friction-sLxaWY-H.js → friction-B6osqFSm.js} +56 -16
  160. package/studio-dist/server/assets/{friction-CWOTjpCV.js → friction-BW86PCPM.js} +2 -2
  161. package/studio-dist/server/assets/{getting-started-Cq5Pcnsr.js → getting-started-CFHSeX5h.js} +2 -2
  162. package/studio-dist/server/assets/{getting-started._topic-CmWdl3u3.js → getting-started._topic-BK2eU6AS.js} +2 -2
  163. package/studio-dist/server/assets/{getting-started.index-AB8xpTFY.js → getting-started.index-DZLuXnNO.js} +2 -2
  164. package/studio-dist/server/assets/{graph-C_Hn-Wf_.js → graph-BJVZBevL.js} +8 -7
  165. package/studio-dist/server/assets/{graph-B11ITte0.js → graph-DGZHV-Ek.js} +1 -1
  166. package/studio-dist/server/assets/{graph-canvas-BthrSmPS.js → graph-canvas-lrNT6jbl.js} +2 -2
  167. package/studio-dist/server/assets/{guides-B8HdeK_C.js → guides-CEwLOZb9.js} +1 -1
  168. package/studio-dist/server/assets/{guides-BVQ4pt5B.js → guides-_G8Vucsk.js} +1 -1
  169. package/studio-dist/server/assets/{guides.server-DqFQAStf.js → guides.server-ZWFKX2XJ.js} +1 -1
  170. package/studio-dist/server/assets/{markdown-view-rwiiVcPC.js → markdown-view-Bmjghg_Z.js} +1 -1
  171. package/studio-dist/server/assets/{panel-CUxRIpYL.js → panel-DvRjyil3.js} +4 -3
  172. package/studio-dist/server/assets/{plugins._service._view-BSvGnlhU.js → plugins._service._view-B32LzraG.js} +8 -5
  173. package/studio-dist/server/assets/{prepaint-B28ClcPN.js → prepaint-BEHwKl51.js} +1 -1
  174. package/studio-dist/server/assets/{queries-S_Pl90IG.js → queries-D6Vq0AuZ.js} +1 -1
  175. package/studio-dist/server/assets/{reports-B9k98oE6.js → reports-DDaH5k0H.js} +1 -1
  176. package/studio-dist/server/assets/{reports-CJpAItPk.js → reports-Dn92pLap.js} +7 -6
  177. package/studio-dist/server/assets/{router-DF0etoNa.js → router-Bjf4S9tO.js} +57 -32
  178. package/studio-dist/server/assets/{routes-6ylCLkyg.js → routes-B4sNiE0X.js} +8 -7
  179. package/studio-dist/server/assets/{search-b-yQesv3.js → search-DKeJRvg8.js} +1 -1
  180. package/studio-dist/server/assets/{select-CjuKScan.js → select-CVHYL7oR.js} +5 -4
  181. package/studio-dist/server/assets/{shell-DLkP7wG9.js → shell-BxbYYaAk.js} +4 -3
  182. package/studio-dist/server/assets/{skills-zeU80A9S.js → skills-B4-0qpqN.js} +8 -7
  183. package/studio-dist/server/assets/{skills-DGg0mWDM.js → skills-Bj8eOgzR.js} +1 -1
  184. package/studio-dist/server/assets/{specs-DDBNT_v1.js → specs-rfMug6qW.js} +4 -4
  185. package/studio-dist/server/assets/{specs-view-exvmWdg0.js → specs-view-qi1SE1Sl.js} +10 -9
  186. package/studio-dist/server/assets/{steps-D1tYAyWZ.js → steps-rger6HJc.js} +1 -1
  187. package/studio-dist/server/assets/{store-kS7zk0Hr.js → store-Dg9T7oWs.js} +1 -1
  188. package/studio-dist/server/assets/{studio-qRvQjRpz.js → studio-D79JzDLc.js} +1347 -0
  189. package/studio-dist/server/assets/{studio-queries-qOXOYoPt.js → studio-queries-CeFfmIuM.js} +3 -3
  190. package/studio-dist/server/assets/{usage-C2um7YiV.js → usage-BJgYWRCX.js} +10 -10
  191. package/studio-dist/server/assets/{usage-Cwle9-xY.js → usage-Dw_UQFX-.js} +1 -1
  192. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-kQBB3y_b.js → useAnchoredPopupScrollLock-ciS_sEq3.js} +2 -2
  193. package/studio-dist/server/assets/{useMutation-C-WO6hCM.js → useMutation-DnWK0PhO.js} +2 -2
  194. package/studio-dist/server/assets/{vault-CEBBRLMb.js → vault-BzarssiL.js} +1 -1
  195. package/studio-dist/server/assets/{vault-B8vgVIH9.js → vault-CvlrLd2H.js} +6 -6
  196. package/studio-dist/server/assets/{views-UgO0Qz_g.js → views-CAxwKHMK.js} +2 -2
  197. package/studio-dist/server/assets/{warnings-BxK4VfV5.js → warnings-BpVCugHm.js} +2 -1
  198. package/studio-dist/server/assets/{workflow-BrTK632u.js → workflow-BdrzcCt8.js} +9 -8
  199. package/studio-dist/server/server.js +2 -2
  200. package/tool-manifest.yaml +85 -0
  201. package/studio-dist/client/assets/app-aIwDxf48.css +0 -2
  202. package/studio-dist/client/assets/button-CX0sWAJl.js +0 -1
  203. package/studio-dist/client/assets/combobox-BmA8RjOc.js +0 -1
  204. package/studio-dist/client/assets/fields-BobQ7zRF.js +0 -1
  205. package/studio-dist/client/assets/friction-YdYd3zaz.js +0 -1
  206. package/studio-dist/client/assets/getting-started-CY7NEtTw.js +0 -1
  207. package/studio-dist/client/assets/getting-started._topic-DVB8e5R9.js +0 -1
  208. package/studio-dist/client/assets/getting-started.index-DQvLHEr1.js +0 -1
  209. package/studio-dist/client/assets/graph-DbNnR884.js +0 -2
  210. package/studio-dist/client/assets/guides-D6T6W_jV.js +0 -1
  211. package/studio-dist/client/assets/index-CysBCSxM.js +0 -40
  212. package/studio-dist/client/assets/panel-Csr49lBo.js +0 -1
  213. package/studio-dist/client/assets/plugins._service._view-CEA_CcPe.js +0 -1
  214. package/studio-dist/client/assets/reports-CLdgxxkg.js +0 -1
  215. package/studio-dist/client/assets/routes-DGilWbDE.js +0 -1
  216. package/studio-dist/client/assets/select-DdebbX7K.js +0 -1
  217. package/studio-dist/client/assets/skills-C3zNkU8g.js +0 -1
  218. package/studio-dist/client/assets/specs-view-B_n0Pekv.js +0 -1
  219. package/studio-dist/client/assets/studio-0ueISxwP.js +0 -100
  220. package/studio-dist/client/assets/useBaseQuery-C2cjmeH2.js +0 -1
  221. package/studio-dist/client/assets/useMutation-DI6LbvVa.js +0 -1
  222. package/studio-dist/client/assets/vault-Cb9DmM1i.js +0 -1
  223. package/studio-dist/client/assets/warnings-B-rvoW8q.js +0 -1
  224. package/studio-dist/client/assets/workflow-DN5T19jd.js +0 -1
  225. package/studio-dist/server/assets/useBaseQuery--iH3rd-T.js +0 -2051
@@ -5,7 +5,7 @@ import { resolveInstallContext } from "../../../lib/install";
5
5
  import { backfillHubAllowedAgents } from "../../../lib/orchestrator/companion-hub";
6
6
  import { ConfigStore } from "../../../lib/orchestrator/config-store";
7
7
  import type { FrameworkConfig, PluginDeclaration } from "../../../lib/orchestrator/types";
8
- import { applySetupCompatibilities } from "../../../tools/setup";
8
+ import { applySetupCompatibilities, syncCompanionFiles } from "../../../tools/setup";
9
9
  import {
10
10
  describeUnknownAudience,
11
11
  readAudienceSelection,
@@ -13,6 +13,10 @@ import {
13
13
  } from "../../../tools/setup/dynamic-plugins/audiences";
14
14
  import { hydrateDynamicPlugins } from "../../../tools/setup/dynamic-plugins/hydrate";
15
15
  import type { PluginInstallDeps } from "../../../tools/setup/dynamic-plugins/install";
16
+ import {
17
+ committedDeclarationProblems,
18
+ declareLocalPlugin,
19
+ } from "../../../tools/setup/dynamic-plugins/local";
16
20
  import { installPluginWorkspaces } from "../../../tools/setup/dynamic-plugins/workspaces";
17
21
  import { reportPluginInstallResults, reportPluginWorkspaces } from "../install";
18
22
 
@@ -35,77 +39,114 @@ function withDeclaration(
35
39
  );
36
40
  }
37
41
 
38
- const INSTALL_USAGE = `usage: ${FRAMEWORK_NAME} plugin install <package>[@version]`;
42
+ /** The local file sits in another directory, so a relative `file:` path is taken from `cwd` now. */
43
+ function absoluteFileSpec(version: string, cwd: string): string {
44
+ if (!version.startsWith("file:") || version.startsWith("file://")) return version;
45
+ const target = version.slice("file:".length);
46
+ if (target.startsWith("~/") || path.isAbsolute(target)) return version;
47
+ return `file:${path.resolve(cwd, target)}`;
48
+ }
49
+
50
+ const INSTALL_USAGE = `usage: ${FRAMEWORK_NAME} plugin install [--local] <package>[@version]`;
39
51
 
40
52
  export interface PluginInstallCommandDeps {
41
53
  cwd?: string;
42
54
  installDeps?: PluginInstallDeps;
43
55
  setupHub?: (companionPath: string, config: FrameworkConfig) => Promise<void>;
56
+ syncCompanion?: (companionPath: string, config: FrameworkConfig) => Promise<unknown>;
57
+ }
58
+
59
+ function refuse(message: string): false {
60
+ process.stderr.write(`${FRAMEWORK_NAME}: ${message}\n`);
61
+ process.exitCode = 1;
62
+ return false;
44
63
  }
45
64
 
46
65
  /**
47
- * @command mate plugin install <package>[@version]
66
+ * @command mate plugin install [--local] <package>[@version]
48
67
  * @description Declares `<package>` in the companion's (or hub's) `framework.yaml`
49
68
  * `plugins:` list (adding it, or updating its version if already declared)
50
69
  * and installs it immediately into the shared workspace, the same way
51
70
  * `mate install` would on its next run: with the selected audience's
52
- * plugins, and without any other audience's.
71
+ * plugins, and without any other audience's. A successful install in a
72
+ * companion then syncs the companion's agent runtime settings, as
73
+ * `mate install` does.
74
+ * @flags
75
+ * - `--local` — declare the package in the untracked `.mate/config/framework.local.yaml` and install it into the ignored `.mate/local-plugins/`, for this machine only. No tracked file names it. A relative `file:` path is resolved from the current directory and written as an absolute path. Refused in a hub and for a package `framework.yaml` declares.
53
76
  */
54
77
  export async function runPluginInstallCommand(
55
78
  argv: string[],
56
79
  deps: PluginInstallCommandDeps = {},
57
80
  ): Promise<boolean> {
58
- const spec = argv[0];
59
- if (spec === "-h" || spec === "--help") {
81
+ if (argv.includes("-h") || argv.includes("--help")) {
60
82
  process.stdout.write(`${INSTALL_USAGE}\n`);
61
83
  return true;
62
84
  }
63
- if (!spec || spec.startsWith("-")) {
64
- const problem = spec ? `unknown option ${spec}; ` : "";
65
- process.stderr.write(`${FRAMEWORK_NAME}: ${problem}${INSTALL_USAGE}\n`);
66
- process.exitCode = 1;
67
- return false;
85
+ const local = argv.includes("--local");
86
+ const unknownOption = argv.find((arg) => arg.startsWith("-") && arg !== "--local");
87
+ const spec = argv.find((arg) => !arg.startsWith("-"));
88
+ if (unknownOption || !spec) {
89
+ const problem = unknownOption ? `unknown option ${unknownOption}; ` : "";
90
+ return refuse(`${problem}${INSTALL_USAGE}`);
68
91
  }
69
- const { package: packageName, version } = parsePackageSpec(spec);
92
+ const cwd = deps.cwd ?? process.cwd();
93
+ const parsed = parsePackageSpec(spec);
94
+ const packageName = parsed.package;
95
+ const version = local ? absoluteFileSpec(parsed.version, cwd) : parsed.version;
70
96
 
71
- const context = await resolveInstallContext(deps.cwd ?? process.cwd());
97
+ const context = await resolveInstallContext(cwd);
72
98
  if (context.kind === "ambiguous") {
73
99
  process.stderr.write(`${context.message}\n`);
74
100
  process.exitCode = 1;
75
101
  return false;
76
102
  }
77
103
  if ((context.kind !== "companion" && context.kind !== "hub") || !context.companionPath) {
78
- process.stderr.write(
79
- `${FRAMEWORK_NAME}: \`plugin install\` requires a companion or hub context; run it from inside a linked working repository or a hub root.\n`,
104
+ return refuse(
105
+ "`plugin install` requires a companion or hub context; run it from inside a linked working repository or a hub root.",
80
106
  );
81
- process.exitCode = 1;
82
- return false;
83
107
  }
84
108
 
85
109
  // A hub declares no audiences; the selection only applies to a companion.
86
110
  let audience: string | null = null;
87
111
  if (context.kind === "companion") {
88
112
  const resolved = resolveAudience(context.config, readAudienceSelection(process.env));
89
- if (!resolved.ok) {
90
- process.stderr.write(`${FRAMEWORK_NAME}: ${describeUnknownAudience(resolved)}\n`);
91
- process.exitCode = 1;
92
- return false;
93
- }
113
+ if (!resolved.ok) return refuse(describeUnknownAudience(resolved));
94
114
  audience = resolved.active;
95
115
  }
96
116
 
97
- const configPath = path.join(
98
- context.companionPath,
99
- `.${FRAMEWORK_NAME}`,
100
- "config",
101
- "framework.yaml",
102
- );
103
- const store = new ConfigStore(configPath);
104
- const nextPlugins = withDeclaration(context.config.plugins ?? [], packageName, version);
105
- const nextConfig = { ...context.config, plugins: nextPlugins };
106
- const agentsBackfilled = context.kind === "hub" && backfillHubAllowedAgents(nextConfig);
107
- if (nextPlugins !== context.config.plugins || agentsBackfilled) {
108
- await store.save(nextConfig);
117
+ let nextConfig = context.config;
118
+ if (local) {
119
+ const problems = await declareLocalPlugin(
120
+ context.companionPath,
121
+ context.config,
122
+ packageName,
123
+ version,
124
+ );
125
+ if (problems.length > 0) {
126
+ return refuse(problems.map((problem) => problem.message).join("\n"));
127
+ }
128
+ } else {
129
+ const problems = await committedDeclarationProblems(
130
+ context.companionPath,
131
+ context.config,
132
+ packageName,
133
+ );
134
+ if (problems.length > 0) {
135
+ return refuse(problems.map((problem) => problem.message).join("\n"));
136
+ }
137
+ const configPath = path.join(
138
+ context.companionPath,
139
+ `.${FRAMEWORK_NAME}`,
140
+ "config",
141
+ "framework.yaml",
142
+ );
143
+ const store = new ConfigStore(configPath);
144
+ const nextPlugins = withDeclaration(context.config.plugins ?? [], packageName, version);
145
+ nextConfig = { ...context.config, plugins: nextPlugins };
146
+ const agentsBackfilled = context.kind === "hub" && backfillHubAllowedAgents(nextConfig);
147
+ if (nextPlugins !== context.config.plugins || agentsBackfilled) {
148
+ await store.save(nextConfig);
149
+ }
109
150
  }
110
151
 
111
152
  const outcome = await installPluginWorkspaces(context.companionPath, nextConfig, audience, {
@@ -114,6 +155,9 @@ export async function runPluginInstallCommand(
114
155
  const { results } = outcome;
115
156
  reportPluginWorkspaces(outcome);
116
157
  reportPluginInstallResults(results);
158
+ const succeeded =
159
+ results.find((result) => result.package === packageName)?.status !== "failed" &&
160
+ !results.some((result) => result.refused);
117
161
  await hydrateDynamicPlugins({ companionPath: context.companionPath });
118
162
  if (context.kind === "hub") {
119
163
  await (
@@ -122,6 +166,9 @@ export async function runPluginInstallCommand(
122
166
  applySetupCompatibilities(companionPath, config, "sync", undefined, undefined, "hub"))
123
167
  )(context.companionPath, nextConfig);
124
168
  }
169
+ if (context.kind === "companion" && succeeded) {
170
+ await (deps.syncCompanion ?? syncCompanionFiles)(context.companionPath, nextConfig);
171
+ }
125
172
 
126
- return results.find((result) => result.package === packageName)?.status !== "failed";
173
+ return succeeded;
127
174
  }
@@ -13,6 +13,7 @@ import type {
13
13
  StudioServiceHost,
14
14
  StudioSocketHandler,
15
15
  StudioSocketPeer,
16
+ StudioViewLayout,
16
17
  StudioWorksetSessions,
17
18
  } from "../../../tools/setup/service";
18
19
  import { SERVICE_ASSET_PREFIX, SERVICE_ROUTE_PREFIX } from "./routes";
@@ -26,6 +27,7 @@ export interface StudioServiceViewSummary {
26
27
  moduleUrl?: string;
27
28
  /** The service route answering the view's attention count, when it declares one. */
28
29
  attentionUrl?: string;
30
+ layout?: StudioViewLayout;
29
31
  }
30
32
 
31
33
  /** A mounted service as Studio's application sees it. */
@@ -218,6 +220,7 @@ function mountedServices(mounted: MountedService[]): MountedServices {
218
220
  ...(view.attention
219
221
  ? { attentionUrl: `${SERVICE_ROUTE_PREFIX}${service.id}${view.attention}` }
220
222
  : {}),
223
+ ...(view.layout ? { layout: view.layout } : {}),
221
224
  })),
222
225
  })),
223
226
  match(pathname, method) {
@@ -1,6 +1,8 @@
1
1
  import readline from "node:readline/promises";
2
2
 
3
3
  import { FRAMEWORK_NAME } from "../../framework";
4
+ import { FrictionRefusal } from "../../lib/friction/fields";
5
+ import { formatCommand } from "../../runtime/command-arg";
4
6
  import {
5
7
  launchAgent,
6
8
  TRIAGE_AGENT_NAMES,
@@ -18,11 +20,12 @@ import { currentSession } from "../../runtime/session-id";
18
20
  import { collectDoctorReport } from "./doctor";
19
21
 
20
22
  interface TriageArgs {
23
+ target?: string;
21
24
  agent: TriageAgent | null;
22
25
  launch: boolean;
23
26
  }
24
27
 
25
- const TRIAGE_USAGE = `Usage: ${FRAMEWORK_NAME} triage [--agent <${TRIAGE_AGENTS.join("|")}>] [--no-launch]`;
28
+ const TRIAGE_USAGE = `Usage: ${FRAMEWORK_NAME} triage ["<fingerprint|report-id>"] [--agent <${TRIAGE_AGENTS.join("|")}>] [--no-launch]`;
26
29
 
27
30
  function parseTriageArgs(argv: string[]): TriageArgs | { error: string } {
28
31
  const args: TriageArgs = { agent: null, launch: true };
@@ -37,6 +40,12 @@ function parseTriageArgs(argv: string[]): TriageArgs | { error: string } {
37
40
  return { error: `--agent must be one of: ${TRIAGE_AGENTS.join(", ")}` };
38
41
  }
39
42
  args.agent = value as TriageAgent;
43
+ } else if (!arg.startsWith("-")) {
44
+ if (arg.trim() === "") return { error: "the Triage Target is empty" };
45
+ if (args.target !== undefined) {
46
+ return { error: `triage takes one Triage Target; got a second: ${arg}` };
47
+ }
48
+ args.target = arg;
40
49
  } else {
41
50
  return { error: `unknown triage option: ${arg}` };
42
51
  }
@@ -102,6 +111,8 @@ function printPaths(files: TriageSessionFiles): void {
102
111
  * shipped playbook, a seed prompt and a 30-day friction snapshot) and starts
103
112
  * Claude Code or OpenCode in it, directly and not through a Mate launch.
104
113
  * Runs before every gate, so it works when Mate itself does not.
114
+ * An optional Triage Target (a fingerprint or Free Report id) focuses the
115
+ * session on that item and chooses the snapshot's companion.
105
116
  * `--no-launch` only prints the session paths.
106
117
  */
107
118
  export async function runTriageCommand(argv: string[] = [], deps: TriageDeps = {}): Promise<void> {
@@ -113,20 +124,30 @@ export async function runTriageCommand(argv: string[] = [], deps: TriageDeps = {
113
124
  return;
114
125
  }
115
126
  const env = deps.env ?? process.env;
116
- const { files, agents } = await prepareTriageSession({
117
- argv,
118
- cwd: deps.cwd ?? process.cwd(),
119
- homeDir: env.HOME,
120
- now: deps.now ?? new Date(),
121
- pathValue: env.PATH ?? "",
122
- env,
123
- collectDoctor: deps.collectDoctor ?? ((cwd) => collectDoctorReport({ cwd, write: false })),
124
- });
127
+ let prepared: Awaited<ReturnType<typeof prepareTriageSession>>;
128
+ try {
129
+ prepared = await prepareTriageSession({
130
+ argv,
131
+ cwd: deps.cwd ?? process.cwd(),
132
+ homeDir: env.HOME,
133
+ now: deps.now ?? new Date(),
134
+ pathValue: env.PATH ?? "",
135
+ env,
136
+ collectDoctor: deps.collectDoctor ?? ((cwd) => collectDoctorReport({ cwd, write: false })),
137
+ target: args.target,
138
+ });
139
+ } catch (error) {
140
+ if (!(error instanceof FrictionRefusal)) throw error;
141
+ console.error(`${FRAMEWORK_NAME}: ${error.message}`);
142
+ process.exitCode = 1;
143
+ return;
144
+ }
145
+ const { files, agents } = prepared;
125
146
  printPaths(files);
126
147
  if (!args.launch) return;
127
148
  if (currentSession(env)) {
128
149
  console.log(
129
- `No agent started: this is an agent session. Run \`${FRAMEWORK_NAME} triage\` in your own terminal.`,
150
+ `No agent started: this is an agent session. Run \`${formatCommand([FRAMEWORK_NAME, "triage", ...argv])}\` in your own terminal.`,
130
151
  );
131
152
  return;
132
153
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.0.0-canary.7",
3
- "sha512": "sha512-U8mQKQBKZcgFCeZgNdNEVa7xNaOi00D/PC6OZo82FWTlucUkmgw1LhLc3XsqircmbC0NQwIQ09YvTnfyqv4sgA=="
2
+ "version": "1.0.0-canary.9",
3
+ "sha512": "sha512-edfJ2SPotUD1hVW5lyvHcfrKColGjbOt3Cxwvx+S7s2bFLuCM9QUifSabD5PUBYr5siWStkT5kozpjt3lGfPxA=="
4
4
  }
@@ -7,6 +7,7 @@ import { BRAND_ACCENT } from "../brand/palette";
7
7
  import { useSpinnerFrame } from "../lib/components/spinner";
8
8
  import type { InstallPlan, InstallPlanItem, InstallRequirementResult } from "../lib/install";
9
9
  import { runInstallPlan } from "../lib/install";
10
+ import { holdToolNotices } from "../lib/tool-manifest";
10
11
 
11
12
  type Execution = { ok: boolean; results: InstallRequirementResult[] };
12
13
 
@@ -178,8 +179,10 @@ export function InstallExecutionView({
178
179
  export async function renderInstallExecution(plan: InstallPlan): Promise<Execution> {
179
180
  return new Promise((resolve) => {
180
181
  let app: ReturnType<typeof render> | undefined;
182
+ const releaseNotices = holdToolNotices();
181
183
  const finish = (execution: Execution) => {
182
184
  app?.unmount();
185
+ releaseNotices();
183
186
  resolve(execution);
184
187
  };
185
188
  app = render(<InstallExecutionView plan={plan} onDone={finish} />);
package/src/cli/main.ts CHANGED
@@ -27,7 +27,7 @@ import { runVscodeCommand } from "./commands/vscode/setup";
27
27
  import { parseWrapArgs, runWrapCommand } from "./commands/wrap";
28
28
  import { runWorkingCommand } from "./commands/working/working";
29
29
  import { runWorkflowCommand } from "./commands/workflow/workflow";
30
- import { runInstallCommand } from "./commands/install";
30
+ import { isFrozenPluginInstall, runInstallCommand } from "./commands/install";
31
31
  import { parseDirectLaunchArgs } from "./commands/launch/shared";
32
32
  import {
33
33
  inspectInstallPreflight,
@@ -86,6 +86,40 @@ function printPreflightErrorDocument(message: string): void {
86
86
  );
87
87
  }
88
88
 
89
+ /**
90
+ * Built-in commands whose `--help` or `-h` main answers with the usage before any gate.
91
+ * `workflow` and `plugin install` print their own usage, `cap` its plugin's, and `claude` and
92
+ * `opencode` pass it to the agent.
93
+ */
94
+ const MAIN_ANSWERS_HELP = new Set([
95
+ "install",
96
+ "plugin",
97
+ "artifact",
98
+ "companion",
99
+ "hub",
100
+ "report",
101
+ "studio",
102
+ "config",
103
+ "doctor",
104
+ "friction",
105
+ "update",
106
+ "working",
107
+ "wrap",
108
+ "session",
109
+ "vscode",
110
+ "unwrap",
111
+ "triage",
112
+ ]);
113
+
114
+ /** True when `args` ask for help before a `--`, which passes what follows on untouched. */
115
+ function asksForHelp(command: string, args: readonly string[]): boolean {
116
+ if (!MAIN_ANSWERS_HELP.has(command) || (command === "plugin" && args[0] === "install")) {
117
+ return false;
118
+ }
119
+ const end = args.indexOf("--");
120
+ return (end < 0 ? args : args.slice(0, end)).some((arg) => arg === "--help" || arg === "-h");
121
+ }
122
+
89
123
  const FRICTION_GATE_NEEDS = new Map<string | undefined, GateNeeds>([
90
124
  ["list", { updateGuard: true, companion: true, install: true }],
91
125
  ["report", { companion: true }],
@@ -93,23 +127,27 @@ const FRICTION_GATE_NEEDS = new Map<string | undefined, GateNeeds>([
93
127
 
94
128
  export async function main(argv = process.argv, deps: MainDeps = mainDeps): Promise<void> {
95
129
  const [, , command, subcommand, ...rest] = argv;
130
+ const helpRequest = command !== undefined && asksForHelp(command, argv.slice(3));
96
131
 
97
132
  /**
98
133
  * A Claude plugin asks this on every mention of a plain session. It changes
99
134
  * nothing and prints only its answer, so it skips the runtime refresh,
100
135
  * plugin loading, the update checks and every gate.
101
136
  */
102
- if (command === "session" && subcommand === "context") {
137
+ if (command === "session" && subcommand === "context" && !helpRequest) {
103
138
  await runSessionContextCommand(rest);
104
139
  return;
105
140
  }
106
141
 
107
- if (command === "triage") {
142
+ if (command === "triage" && !helpRequest) {
108
143
  await runTriageCommand(argv.slice(3));
109
144
  return;
110
145
  }
111
146
 
112
- if (!(await ensureRuntimeDirectory(command, deps.refreshRuntimeDirectory))) {
147
+ // Help needs no runtime paths, so a failed refresh only warns, as for `mate help`.
148
+ if (
149
+ !(await ensureRuntimeDirectory(helpRequest ? "help" : command, deps.refreshRuntimeDirectory))
150
+ ) {
113
151
  process.exitCode = 1;
114
152
  return;
115
153
  }
@@ -123,10 +161,16 @@ export async function main(argv = process.argv, deps: MainDeps = mainDeps): Prom
123
161
  // text is printed, so their commands route like compiled-in ones
124
162
  // (including MCP servers whose command is their own cap subcommand) and
125
163
  // show up in `mate help`. Diagnostics stay on stderr; a missing or
126
- // ambiguous companion makes this a no-op.
127
- await deps.hydrateDynamicPlugins();
164
+ // ambiguous companion makes this a no-op. A frozen verification ignores
165
+ // local plugins.
166
+ const ignoresLocalPlugins = command === "doctor" && isFrozenPluginInstall(argv);
167
+ // A package registers once per process, so a load here would pin the
168
+ // pre-install version for the install's own sync; both installs load after their plugin step.
169
+ if (!(command === "install" || (command === "plugin" && subcommand === "install"))) {
170
+ await deps.hydrateDynamicPlugins({ includeLocal: !ignoresLocalPlugins });
171
+ }
128
172
 
129
- if (!command || command === "help" || command === "--help" || command === "-h") {
173
+ if (!command || command === "help" || command === "--help" || command === "-h" || helpRequest) {
130
174
  console.log(usage());
131
175
  return;
132
176
  }
package/src/cli/usage.ts CHANGED
@@ -40,7 +40,7 @@ export function usage(): string {
40
40
  ` ${n} artifact publish <group|change|anchor>|--specs [<path>...]|--all [--refresh]`,
41
41
  " [--confirm-merged|--confirm-open|--confirm-dropped] [--type openspec] [--no-push] [--json]",
42
42
  " target: a Delivery Group or submitted change, or a dated archive anchor of an earlier Mate",
43
- ` ${n} artifact pending [--json]`,
43
+ ` ${n} artifact pending [--no-merge-check] [--json]`,
44
44
  ` ${n} artifact link <change>... [--repository <org/repo>] [--branch <b> [--direct]]`,
45
45
  " [--not-applicable <reason>] [--pr <url>] [--ticket <KEY>] [--refresh]",
46
46
  " [--confirm-merged|--confirm-open|--confirm-dropped] [--spec-base] [--json]",
@@ -67,7 +67,7 @@ export function usage(): string {
67
67
  " [--workaround <text>] [--json]",
68
68
  ` ${n} friction mark <fingerprint|report-id> --state <open|fixed|reported|dismissed>`,
69
69
  " [--note <text>] [--link <url>] [--json]",
70
- ` ${n} triage [--agent <claude|opencode>] [--no-launch]`,
70
+ ` ${n} triage ["<fingerprint|report-id>"] [--agent <claude|opencode>] [--no-launch]`,
71
71
  ` ${n} report [--days N] [--input FILE|-] [--json]`,
72
72
  ` ${n} studio [--writable] [--terminal] [--detach-timeout <minutes>]`,
73
73
  ` ${n} studio serve --port <port> [--host <host>] [--writable] [--terminal]`,
@@ -82,7 +82,7 @@ export function usage(): string {
82
82
  ` ${n} cap openspec <subcommand> [args...]`,
83
83
  ` ${n} cap graphify <subcommand> [args...]`,
84
84
  ` ${n} cap index [--graphify] [--tokensave]`,
85
- ` ${n} plugin install <package>[@version]`,
85
+ ` ${n} plugin install [--local] <package>[@version]`,
86
86
  ...pluginCliCommandLines(),
87
87
  ` ${n} update`,
88
88
  ` ${n} update --check`,
@@ -3,6 +3,7 @@ import { setActiveDistribution, type DistributionConfig } from "./distribution";
3
3
  import { FRAMEWORK_NAME } from "./framework";
4
4
  import { currentSession } from "./lib/session-attribution";
5
5
  import { runRecordingFailure } from "./runtime/command-friction";
6
+ import { createMcpManagerPlugin } from "./tools/setup/capabilities/mcp-manager";
6
7
  import { createBunPlugin } from "./tools/setup/package-managers/bun";
7
8
  import { createUvPlugin } from "./tools/setup/package-managers/uv";
8
9
  import type { PluginRegistration } from "./tools/setup/plugin";
@@ -26,7 +27,8 @@ export interface MateCli {
26
27
  * Assemble a distribution from an identity config and plugin registration
27
28
  * entries. Distributions choose their plugin set; the framework always adds
28
29
  * bun as the required runtime substrate, uv for the capabilities that install
29
- * through it (enabled only by them, e.g. Graphify), plus gitignore management
30
+ * through it (enabled only by them, e.g. Graphify), the `mcp-manager`
31
+ * Capability (enabled by a `mcpManager` section), plus gitignore management
30
32
  * named after the framework identity (built last since it reads the full
31
33
  * plugin set). Returns the runnable CLI.
32
34
  */
@@ -35,6 +37,7 @@ export function createMate({ config, plugins, main: runMain = main }: CreateMate
35
37
  ...plugins,
36
38
  { plugin: createBunPlugin(), policy: "required" },
37
39
  { plugin: createUvPlugin(), policy: "optional" },
40
+ createMcpManagerPlugin(),
38
41
  createGitignorePlugin(FRAMEWORK_NAME),
39
42
  ]);
40
43
  setActiveDistribution({ config, registry });
@@ -65,5 +65,11 @@ export { readWorksetStages, type WorksetWithStage } from "./lib/workset/stages";
65
65
  export { buildCompanionGuidance } from "./playbooks/companion-guidance";
66
66
  export { errorMessage } from "./runtime/error-message";
67
67
  export { resolveSecretPolicy } from "./runtime/policy";
68
+ export {
69
+ installedPluginPackages,
70
+ type InstalledPluginPackage,
71
+ type InstalledPluginsOptions,
72
+ } from "./tools/setup/dynamic-plugins/installed";
73
+ export type { PluginOrigin } from "./tools/setup/dynamic-plugins/paths";
68
74
  export { deployReactDoctorSkill } from "./tools/setup/capabilities/react-doctor";
69
75
  export { applyMateSkills, MATE_SKILLS } from "./tools/setup/mate";
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export {
21
21
  type NormalizedRegistration,
22
22
  } from "./tools/setup/registry";
23
23
  export { ensureCapabilityEnabled, type EnsureCapabilityEnabledDeps } from "./cli/plugin-commands";
24
+ export { toolVersion } from "./lib/tool-manifest";
24
25
  // Dynamic plugin authors: import from this package as TYPES ONLY. Runtime
25
26
  // imports resolve a second, uninitialized copy of mate-core inside the
26
27
  // plugin's own node_modules; all runtime behavior flows through PluginHost.
@@ -22,7 +22,14 @@ export interface ProcessResult {
22
22
  export type SpawnProcess = (
23
23
  command: string,
24
24
  args: readonly string[],
25
- options: { cwd: string; env: NodeJS.ProcessEnv; input?: string; timeoutMs?: number },
25
+ options: {
26
+ cwd: string;
27
+ env: NodeJS.ProcessEnv;
28
+ input?: string;
29
+ timeoutMs?: number;
30
+ /** Kills the process once aborted; the result then counts as timed out. */
31
+ signal?: AbortSignal;
32
+ },
26
33
  ) => Promise<ProcessResult>;
27
34
 
28
35
  export interface PatchMatch {
@@ -134,6 +141,8 @@ export interface MergeGitDeps {
134
141
  containmentLimit?: number;
135
142
  /** Wall time one containment search may take; 5 s by default. */
136
143
  containmentBudgetMs?: number;
144
+ /** Once aborted, running Git commands are killed and new ones fail at once. */
145
+ signal?: AbortSignal;
137
146
  }
138
147
 
139
148
  /** Upstream commits compared by patch identity at most; more is asked instead. */
@@ -179,12 +188,20 @@ export const spawnProcess: SpawnProcess = (command, args, options) =>
179
188
  env: options.env,
180
189
  stdio: ["pipe", "pipe", "pipe"],
181
190
  timeout: options.timeoutMs,
191
+ ...(options.signal ? { signal: options.signal } : {}),
182
192
  });
183
193
  const stdout: Buffer[] = [];
184
194
  const stderr: Buffer[] = [];
185
195
  child.stdout.on("data", (chunk: Buffer) => stdout.push(chunk));
186
196
  child.stderr.on("data", (chunk: Buffer) => stderr.push(chunk));
187
- child.on("error", (error) => resolve({ code: -1, stdout: "", stderr: error.message }));
197
+ child.on("error", (error) =>
198
+ resolve({
199
+ code: -1,
200
+ stdout: "",
201
+ stderr: error.message,
202
+ ...(options.signal?.aborted ? { timedOut: true } : {}),
203
+ }),
204
+ );
188
205
  child.on("close", (code, signal) =>
189
206
  resolve({
190
207
  code: code ?? -1,
@@ -229,7 +246,10 @@ export function localGitEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.Proces
229
246
  }
230
247
 
231
248
  export function mergeGit(repoPath: string, deps: MergeGitDeps = {}): MergeGit {
232
- const spawnFn = deps.spawn ?? spawnProcess;
249
+ const baseSpawn = deps.spawn ?? spawnProcess;
250
+ const spawnFn: SpawnProcess = deps.signal
251
+ ? (command, args, options) => baseSpawn(command, args, { ...options, signal: deps.signal })
252
+ : baseSpawn;
233
253
  const base = gitEnvironment(deps.env ?? process.env) as NodeJS.ProcessEnv;
234
254
  const promptless = promptlessEnv(base);
235
255
  const localEnv: NodeJS.ProcessEnv = { ...promptless, GIT_NO_LAZY_FETCH: "1" };
@@ -247,10 +267,14 @@ export function mergeGit(repoPath: string, deps: MergeGitDeps = {}): MergeGit {
247
267
  (await value("config", "--get", "extensions.partialClone")) !== null;
248
268
 
249
269
  const supportsContainment = (): Promise<boolean> => {
250
- let known = containmentSupport.get(spawnFn);
270
+ let known = containmentSupport.get(baseSpawn);
251
271
  if (!known) {
252
- known = git(["version"]).then((result) => result.code === 0 && hasWriteTree(result.stdout));
253
- containmentSupport.set(spawnFn, known);
272
+ known = git(["version"]).then((result) => {
273
+ // A killed probe proves nothing about this Git.
274
+ if (result.timedOut) containmentSupport.delete(baseSpawn);
275
+ return result.code === 0 && hasWriteTree(result.stdout);
276
+ });
277
+ containmentSupport.set(baseSpawn, known);
254
278
  }
255
279
  return known;
256
280
  };
@@ -392,7 +416,7 @@ export function mergeGit(repoPath: string, deps: MergeGitDeps = {}): MergeGit {
392
416
  if (!(await supportsContainment())) return "unknown";
393
417
  const upstream = remoteRef(defaultBranch);
394
418
  const tip = await verify(upstream);
395
- const notContained = notContainedMemo(spawnFn);
419
+ const notContained = notContainedMemo(baseSpawn);
396
420
  const key = `${repoPath}\0${head}\0${tip}`;
397
421
  // Unchanged head and default tip: a repeated refresh does not test every candidate again.
398
422
  if (tip && notContained.has(key)) return "none";
@@ -44,13 +44,26 @@ export type CountedWarning = {
44
44
  message: string;
45
45
  };
46
46
 
47
+ /**
48
+ * - `preflight-skipped`: submit could not archive the change's Delivery Group as publication
49
+ * would, or only against the last fetched refs
50
+ * - `preflight-blocked`: publication will block the group on the stale delta of `change` until it
51
+ * is resolved on the pending branch
52
+ */
53
+ export type PreflightWarning = {
54
+ kind: "preflight-skipped" | "preflight-blocked";
55
+ change: string;
56
+ message: string;
57
+ };
58
+
47
59
  export type SubmitWarning =
48
60
  | { kind: "overlap"; change: string; capability: string; requirement: string; message: string }
49
61
  | DependencyWarning
50
62
  | PlanningWarning
51
63
  | GroupWarning
52
64
  | StageWarning
53
- | CountedWarning;
65
+ | CountedWarning
66
+ | PreflightWarning;
54
67
 
55
68
  const SECTION = /^##\s+(ADDED|MODIFIED|REMOVED|RENAMED)\s+Requirements\s*$/;
56
69
  const REQUIREMENT = /^###\s+Requirement:\s*(.+?)\s*$/;
@@ -22,11 +22,16 @@ export interface Checkout {
22
22
  }
23
23
 
24
24
  export interface RepositoryAccessDeps {
25
- openCheckout?: (path: string) => Checkout;
25
+ openCheckout?: (path: string, signal?: AbortSignal) => Checkout;
26
+ /** Once aborted, the checkouts' merge queries and fetches are killed. */
27
+ signal?: AbortSignal;
26
28
  }
27
29
 
28
- function defaultOpenCheckout(path: string): Checkout {
29
- return { git: mergeGit(path), defaultBranch: () => workingRepoGit(path).defaultBranch() };
30
+ function defaultOpenCheckout(path: string, signal?: AbortSignal): Checkout {
31
+ return {
32
+ git: mergeGit(path, signal ? { signal } : {}),
33
+ defaultBranch: () => workingRepoGit(path).defaultBranch(),
34
+ };
30
35
  }
31
36
 
32
37
  /**
@@ -48,7 +53,7 @@ export function repositoryAccessFor(
48
53
  const working = slug && sameRepository(slug, repository) ? environment.workingRepo : null;
49
54
  let localAccess: Promise<LocalMergeAccess | null> | undefined;
50
55
  const local = (): Promise<LocalMergeAccess | null> =>
51
- (localAccess ??= openLocal(environment, repository, deps.openCheckout));
56
+ (localAccess ??= openLocal(environment, repository, deps));
52
57
  let otherDefault: Promise<string> | undefined;
53
58
  const defaultBranch = working
54
59
  ? () => working.git.defaultBranch()
@@ -72,11 +77,11 @@ export function repositoryAccessFor(
72
77
  async function openLocal(
73
78
  environment: DeliveryEnvironment,
74
79
  repository: string,
75
- open: ((path: string) => Checkout) | undefined,
80
+ deps: RepositoryAccessDeps,
76
81
  ): Promise<LocalMergeAccess | null> {
77
82
  const path = await environment.checkoutOf?.(repository);
78
83
  if (!path) return null;
79
- const checkout = (open ?? defaultOpenCheckout)(path);
84
+ const checkout = (deps.openCheckout ?? defaultOpenCheckout)(path, deps.signal);
80
85
  if (!(await checkout.git.isRepository())) return null;
81
86
  const defaultBranch = await checkout.defaultBranch();
82
87
  const fetched = new Map<string, Promise<FetchResult>>();