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

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 (181) 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 +16 -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/factory-host.ts +6 -0
  18. package/src/index.ts +1 -0
  19. package/src/lib/delivery/merge-git.ts +31 -7
  20. package/src/lib/delivery/overlap.ts +14 -1
  21. package/src/lib/delivery/repository-access.ts +11 -6
  22. package/src/lib/delivery/staging/apply-chain.ts +25 -7
  23. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  24. package/src/lib/delivery/staging/naming.ts +3 -0
  25. package/src/lib/delivery/staging/openspec-type.ts +38 -7
  26. package/src/lib/delivery/staging/pending.ts +153 -11
  27. package/src/lib/delivery/staging/preflight.ts +239 -0
  28. package/src/lib/delivery/staging/project.ts +243 -104
  29. package/src/lib/delivery/staging/replay.ts +5 -3
  30. package/src/lib/delivery/staging/settle-linked.ts +5 -119
  31. package/src/lib/delivery/staging/submit.ts +139 -18
  32. package/src/lib/delivery/submit-change.ts +163 -37
  33. package/src/lib/friction/mark.ts +49 -11
  34. package/src/lib/friction/view/read.ts +10 -1
  35. package/src/lib/openspec-cli.ts +10 -5
  36. package/src/lib/skills-cli.ts +38 -0
  37. package/src/lib/tool-manifest.ts +73 -0
  38. package/src/lib/triage/context.ts +138 -12
  39. package/src/lib/triage/prepare.ts +19 -4
  40. package/src/plugin-api.ts +1 -0
  41. package/src/runtime/command-arg.ts +15 -0
  42. package/src/runtime/companion-guidance.ts +1 -1
  43. package/src/runtime/friction-log.ts +41 -17
  44. package/src/runtime/friction-recorder.ts +15 -2
  45. package/src/runtime/git-tracked.ts +13 -2
  46. package/src/studio.ts +6 -1
  47. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +5 -1
  48. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  49. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +42 -4
  50. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +27 -2
  51. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  52. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +26 -1
  53. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +28 -0
  54. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +28 -3
  55. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  56. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  57. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  58. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  59. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +28 -3
  60. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +28 -6
  61. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +27 -2
  62. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +28 -0
  63. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +24 -2
  64. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +42 -4
  65. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +27 -2
  66. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  67. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +26 -1
  68. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +28 -0
  69. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +28 -3
  70. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  71. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  72. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  73. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  74. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +28 -3
  75. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +28 -6
  76. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +27 -2
  77. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +28 -0
  78. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +24 -2
  79. package/src/templates/triage/PLAYBOOK.md +9 -1
  80. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +108 -108
  81. package/src/tools/setup/capabilities/graphify.ts +23 -1
  82. package/src/tools/setup/capabilities/rtk.ts +27 -86
  83. package/src/tools/setup/capabilities/tokensave.ts +76 -54
  84. package/src/tools/setup/dynamic-plugins/audiences.ts +28 -14
  85. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  86. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  87. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  88. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  89. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  90. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  91. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  92. package/src/tools/setup/dynamic-plugins/workspaces.ts +17 -8
  93. package/src/tools/setup/mate.ts +26 -1
  94. package/src/tools/setup/plugins/gitignore.ts +45 -12
  95. package/src/tools/setup/service.ts +8 -0
  96. package/src/tools/setup/utils.ts +10 -1
  97. package/studio-dist/client/assets/app-ggXJ_QVh.css +2 -0
  98. package/studio-dist/client/assets/button-amJ3g5oD.js +1 -0
  99. package/studio-dist/client/assets/cn-BQPKiwI4.js +1 -0
  100. package/studio-dist/client/assets/combobox-CJ7aGFid.js +1 -0
  101. package/studio-dist/client/assets/{companion-view-DINdPF-b.js → companion-view-C_N237bf.js} +1 -1
  102. package/studio-dist/client/assets/fields-BAiGkJ5N.js +1 -0
  103. package/studio-dist/client/assets/friction-DqOU59v7.js +1 -0
  104. package/studio-dist/client/assets/getting-started-yp42dj5S.js +1 -0
  105. package/studio-dist/client/assets/{getting-started._topic-DVB8e5R9.js → getting-started._topic-C9zVXz_m.js} +1 -1
  106. package/studio-dist/client/assets/{getting-started.index-DQvLHEr1.js → getting-started.index-DWbDKICP.js} +1 -1
  107. package/studio-dist/client/assets/graph-BYaD_5Bq.js +2 -0
  108. package/studio-dist/client/assets/{graph-canvas-DIcAqwtK.js → graph-canvas-ySGKMhmk.js} +1 -1
  109. package/studio-dist/client/assets/index-Qx7reRPD.js +40 -0
  110. package/studio-dist/client/assets/panel-C4bf_h2W.js +1 -0
  111. package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +1 -0
  112. package/studio-dist/client/assets/reports-JFSwSueq.js +1 -0
  113. package/studio-dist/client/assets/routes-BdOWSgzK.js +1 -0
  114. package/studio-dist/client/assets/select-BHYYWPhK.js +1 -0
  115. package/studio-dist/client/assets/skills-Bo9FLsBd.js +1 -0
  116. package/studio-dist/client/assets/{specs-Dl8HfGlU.js → specs-BrCOjOch.js} +1 -1
  117. package/studio-dist/client/assets/specs-view-CdE2rlli.js +1 -0
  118. package/studio-dist/client/assets/{store-DyXbi6o9.js → store-C3vJq8Wj.js} +1 -1
  119. package/studio-dist/client/assets/{usage-Blcl8kA_.js → usage-BLsLy0nN.js} +13 -13
  120. package/studio-dist/client/assets/{useAnchoredPopupScrollLock-BBXJpX5L.js → useAnchoredPopupScrollLock-DC7f8GOp.js} +1 -1
  121. package/studio-dist/client/assets/useMutation-uJUrejsi.js +1 -0
  122. package/studio-dist/client/assets/vault-BB1B_OhR.js +1 -0
  123. package/studio-dist/client/assets/warnings-CqOOGlPD.js +1 -0
  124. package/studio-dist/client/assets/workflow-BFzmI-06.js +1 -0
  125. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-JoHQ5ihx.js → __23tanstack-start-server-fn-resolver-gVfW5vIV.js} +1 -1
  126. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +42 -42
  127. package/studio-dist/server/assets/{button-B7e1fRyW.js → button-D6bvrFmm.js} +3 -3480
  128. package/studio-dist/server/assets/cn-FXJAM0KO.js +5528 -0
  129. package/studio-dist/server/assets/{combobox--S_OmUfh.js → combobox-D2MbYV1O.js} +6 -5
  130. package/studio-dist/server/assets/{companion-view-D-vGM55e.js → companion-view-Mf1ANbMb.js} +2 -2
  131. package/studio-dist/server/assets/{fields-B4qM2ZwC.js → fields-B4mAPETz.js} +2 -1
  132. package/studio-dist/server/assets/{friction-sLxaWY-H.js → friction-9a5S1m7U.js} +54 -14
  133. package/studio-dist/server/assets/{getting-started-Cq5Pcnsr.js → getting-started-RU6tYU2Q.js} +2 -2
  134. package/studio-dist/server/assets/{getting-started._topic-CmWdl3u3.js → getting-started._topic-C02HGrC6.js} +2 -2
  135. package/studio-dist/server/assets/{getting-started.index-AB8xpTFY.js → getting-started.index-EzLRosbb.js} +2 -2
  136. package/studio-dist/server/assets/{graph-C_Hn-Wf_.js → graph-CZ2H9Fzr.js} +7 -6
  137. package/studio-dist/server/assets/{graph-canvas-BthrSmPS.js → graph-canvas-rP5TT14Z.js} +1 -1
  138. package/studio-dist/server/assets/{guides-BVQ4pt5B.js → guides-BGftp4wf.js} +1 -1
  139. package/studio-dist/server/assets/{markdown-view-rwiiVcPC.js → markdown-view-CArpV-CS.js} +1 -1
  140. package/studio-dist/server/assets/{panel-CUxRIpYL.js → panel-DR0iq46J.js} +4 -3
  141. package/studio-dist/server/assets/{plugins._service._view-BSvGnlhU.js → plugins._service._view-n7u2k5dF.js} +7 -4
  142. package/studio-dist/server/assets/{queries-S_Pl90IG.js → queries-D-yVP9i0.js} +1 -1
  143. package/studio-dist/server/assets/{reports-CJpAItPk.js → reports-C2SmTgqh.js} +6 -5
  144. package/studio-dist/server/assets/{router-DF0etoNa.js → router-CPt0TAk_.js} +54 -29
  145. package/studio-dist/server/assets/{routes-6ylCLkyg.js → routes-CwH8LEy2.js} +8 -7
  146. package/studio-dist/server/assets/{select-CjuKScan.js → select-C3i6TTX-.js} +5 -4
  147. package/studio-dist/server/assets/{shell-DLkP7wG9.js → shell-CagqZZMZ.js} +2 -1
  148. package/studio-dist/server/assets/{skills-zeU80A9S.js → skills-C21Mg_8-.js} +7 -6
  149. package/studio-dist/server/assets/{specs-DDBNT_v1.js → specs-DetoMiaB.js} +3 -3
  150. package/studio-dist/server/assets/{specs-view-exvmWdg0.js → specs-view-CmbfLDwN.js} +9 -8
  151. package/studio-dist/server/assets/{store-kS7zk0Hr.js → store-aC-I6f6o.js} +1 -1
  152. package/studio-dist/server/assets/{studio-queries-qOXOYoPt.js → studio-queries-Dqf-3nzj.js} +1 -1
  153. package/studio-dist/server/assets/{usage-C2um7YiV.js → usage-CS4CBK9D.js} +9 -9
  154. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-kQBB3y_b.js → useAnchoredPopupScrollLock-BjMNgXv9.js} +2 -2
  155. package/studio-dist/server/assets/{useMutation-C-WO6hCM.js → useMutation-DpBIuWXt.js} +2 -2
  156. package/studio-dist/server/assets/{vault-B8vgVIH9.js → vault-DVQidlId.js} +6 -6
  157. package/studio-dist/server/assets/{warnings-BxK4VfV5.js → warnings-C7hgXpdk.js} +2 -1
  158. package/studio-dist/server/assets/{workflow-BrTK632u.js → workflow-6dZZ1ofw.js} +7 -6
  159. package/studio-dist/server/server.js +2 -2
  160. package/tool-manifest.yaml +85 -0
  161. package/studio-dist/client/assets/app-aIwDxf48.css +0 -2
  162. package/studio-dist/client/assets/button-CX0sWAJl.js +0 -1
  163. package/studio-dist/client/assets/combobox-BmA8RjOc.js +0 -1
  164. package/studio-dist/client/assets/fields-BobQ7zRF.js +0 -1
  165. package/studio-dist/client/assets/friction-YdYd3zaz.js +0 -1
  166. package/studio-dist/client/assets/getting-started-CY7NEtTw.js +0 -1
  167. package/studio-dist/client/assets/graph-DbNnR884.js +0 -2
  168. package/studio-dist/client/assets/index-CysBCSxM.js +0 -40
  169. package/studio-dist/client/assets/panel-Csr49lBo.js +0 -1
  170. package/studio-dist/client/assets/plugins._service._view-CEA_CcPe.js +0 -1
  171. package/studio-dist/client/assets/reports-CLdgxxkg.js +0 -1
  172. package/studio-dist/client/assets/routes-DGilWbDE.js +0 -1
  173. package/studio-dist/client/assets/select-DdebbX7K.js +0 -1
  174. package/studio-dist/client/assets/skills-C3zNkU8g.js +0 -1
  175. package/studio-dist/client/assets/specs-view-B_n0Pekv.js +0 -1
  176. package/studio-dist/client/assets/useBaseQuery-C2cjmeH2.js +0 -1
  177. package/studio-dist/client/assets/useMutation-DI6LbvVa.js +0 -1
  178. package/studio-dist/client/assets/vault-Cb9DmM1i.js +0 -1
  179. package/studio-dist/client/assets/warnings-B-rvoW8q.js +0 -1
  180. package/studio-dist/client/assets/workflow-DN5T19jd.js +0 -1
  181. package/studio-dist/server/assets/useBaseQuery--iH3rd-T.js +0 -2051
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mate-companion-mentions",
3
- "version": "1.0.0-canary.7",
3
+ "version": "1.0.0-canary.8",
4
4
  "description": "@mate:<path> mentions: find and attach files from the mate companion repo in the @ menu.",
5
5
  "author": {
6
6
  "name": "Kevin Tornquist"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniqbit/mate-core",
3
- "version": "1.0.0-canary.7",
3
+ "version": "1.0.0-canary.8",
4
4
  "description": "Core framework and plugin APIs for Mate.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "src/",
13
13
  "studio-dist/",
14
14
  "wrappers/",
15
+ "tool-manifest.yaml",
15
16
  "claude-plugin/",
16
17
  "opencode-plugin/",
17
18
  "claude-capability-plugins/",
@@ -73,6 +74,7 @@
73
74
  "react": "^19.2.7",
74
75
  "react-doctor": "0.9.13",
75
76
  "semver": "^7.8.5",
77
+ "skills": "1.7.6",
76
78
  "smol-toml": "1.9.1",
77
79
  "yaml": "^2.9.0",
78
80
  "zod": "4.6.7"
@@ -84,7 +86,8 @@
84
86
  "@types/bun": "^1.3.14",
85
87
  "@types/node": "^26.0.1",
86
88
  "@types/react": "^19.2.17",
87
- "@types/semver": "^7.7.1"
89
+ "@types/semver": "^7.7.1",
90
+ "typescript": "^7.0.2"
88
91
  },
89
92
  "peerDependencies": {
90
93
  "@opentui/core": ">=0.5.14",
@@ -103,7 +106,7 @@
103
106
  }
104
107
  },
105
108
  "engines": {
106
- "node": ">=22.19.0"
109
+ "node": ">=22.20.0"
107
110
  },
108
111
  "packageManager": "bun@1.4.4"
109
112
  }
@@ -61,10 +61,12 @@ function renderHuman(result: SubmitResult): string[] {
61
61
  * warnings to stderr, and runs the artifact type's check (`openspec validate <change>
62
62
  * --strict`). The other active changes of its Delivery Group (`<repository>/<delivery-branch>`,
63
63
  * or `change/<change>` without a branch) in this checkout join when all their tasks are
64
- * checked. The group is then pushed whole, in one secret-scanned commit that sets
65
- * `state: submitted` in each `delivery.yaml` and carries a `Mate-Transaction` trailer, to the
66
- * pending branch, the inbox `mate/inbox`. While a member has open tasks or fails its check the
67
- * group answers `waiting`, naming it, and nothing is pushed or changed. The commit is built in a
64
+ * checked, and its `submitted` members edited since this checkout submitted or took them go
65
+ * through the same steps and get a result entry. The group is then pushed whole, in one
66
+ * secret-scanned commit that sets `state: submitted` in each `delivery.yaml` and carries a
67
+ * `Mate-Transaction` trailer, to the pending branch, the inbox `mate/inbox`. While a member has
68
+ * open tasks or fails its check the group answers `waiting`, naming it, and nothing is pushed or
69
+ * changed. The commit is built in a
68
70
  * temporary worktree, pushed without force and rebuilt up to three times; the checkout is not
69
71
  * touched.
70
72
  * Nothing is archived and no canonical spec is written; publication does that after the merge.
@@ -7,6 +7,7 @@ import {
7
7
  } from "../../../../lib/delivery/record-delivery";
8
8
  import type { ArtifactType } from "../../../../lib/delivery/staging/artifact-type";
9
9
  import { isDeliveryGroup } from "../../../../lib/delivery/staging/naming";
10
+ import { groupOfChange } from "../../../../lib/delivery/staging/submit";
10
11
  import { declaredSubmitType } from "../../../../lib/delivery/staging/registry";
11
12
  import { errorMessage } from "../../../../runtime/error-message";
12
13
  import { settleLinked } from "../../../../lib/delivery/staging/settle-linked";
@@ -271,7 +272,8 @@ function refusalResult(type: string, name: string, message: string): FinishResul
271
272
  * checkout, recorded in its `delivery.yaml` on the pending branch (published with the group,
272
273
  * else pushed there alone).
273
274
  * - `--confirm-merged` / `--confirm-open` / `--confirm-dropped` — the user's answer for the
274
- * group's Working Repository delivery, recorded the same way. One at a time; never with
275
+ * group's Working Repository delivery, else for the repository the group is named after,
276
+ * recorded the same way. One at a time; never with
275
277
  * `--all`, `--specs` or `--no-push`.
276
278
  * - `--specs [<path>...]` — publish drifted canonical specs as their own publication. Bare, it
277
279
  * publishes every drifted spec; with paths, only those. A bare name alongside it is a change
@@ -501,11 +503,12 @@ export async function runArtifactPublishCommand(
501
503
  const environment = await deliveryEnvironment();
502
504
  if ("error" in environment) return environment.error;
503
505
  const answer = refreshOnly ? undefined : confirm;
504
- const record = (names: string[], edit: DeliveryEdit = {}) =>
506
+ const record = (names: string[], edit: DeliveryEdit = {}, repository?: string) =>
505
507
  recordDelivery(
506
508
  { ...environment, companionPath: dir },
507
509
  {
508
510
  changes: names,
511
+ repository,
509
512
  refresh: edit.confirm === undefined && refresh,
510
513
  refreshAll: true,
511
514
  edit,
@@ -522,16 +525,30 @@ export async function runArtifactPublishCommand(
522
525
  }
523
526
  }
524
527
  if (!answer) return null;
525
- // The answer is for the Working Repository's delivery; changes without one keep theirs.
526
- let confirmed = 0;
527
- for (const change of changes) {
528
- // oxlint-disable-next-line no-await-in-loop -- one record at a time, in group order
529
- const outcome = await record([change], { confirm: answer });
530
- if (!("refusal" in outcome)) confirmed += 1;
531
- else if (outcome.refusal.reason !== "no-delivery-branch") {
532
- return deliveryRefusal([change], outcome.refusal.reason);
528
+ // The answer is for the Working Repository's delivery, else, as in the companion or for a
529
+ // group of another repository, for the repository the group is named after; changes
530
+ // without that delivery keep theirs.
531
+ const groupRepository = async (change: string) =>
532
+ (await groupOfChange(dir, change, declaredType)).repository;
533
+ const confirmEach = async (
534
+ repositoryOf: (change: string) => Promise<string | undefined>,
535
+ ): Promise<number | string> => {
536
+ let confirmed = 0;
537
+ for (const change of changes) {
538
+ // oxlint-disable-next-line no-await-in-loop -- one record at a time, in group order
539
+ const outcome = await record([change], { confirm: answer }, await repositoryOf(change));
540
+ if (!("refusal" in outcome)) confirmed += 1;
541
+ else if (outcome.refusal.reason !== "no-delivery-branch") {
542
+ return deliveryRefusal([change], outcome.refusal.reason);
543
+ }
533
544
  }
534
- }
545
+ return confirmed;
546
+ };
547
+ const working = environment.workingRepo;
548
+ const inWorking = Boolean(working?.slug || working?.umbrellaChildren);
549
+ let confirmed = await confirmEach(inWorking ? async () => undefined : groupRepository);
550
+ if (confirmed === 0 && inWorking) confirmed = await confirmEach(groupRepository);
551
+ if (typeof confirmed === "string") return confirmed;
535
552
  return confirmed > 0 ? null : deliveryRefusal(changes, "no-delivery-branch");
536
553
  };
537
554
 
@@ -1,9 +1,14 @@
1
1
  import path from "node:path";
2
2
 
3
+ import {
4
+ linkedDeliveryEnvironment,
5
+ type DeliveryEnvironment,
6
+ } from "../../../../lib/delivery/environment";
3
7
  import { readDeliveryState, type DeliveryState } from "../../../../lib/delivery/record";
4
8
  import {
5
9
  discoverSubmitted,
6
10
  type DiscoverSubmittedOptions,
11
+ type MergeCheck,
7
12
  type MergeClaim,
8
13
  type SubmittedChangeView,
9
14
  type SubmittedDiscovery,
@@ -44,12 +49,31 @@ export interface PendingCommandDeps {
44
49
  ) => Promise<SubmittedDiscovery>;
45
50
  /** True when the companion's Git mode is `auto`. */
46
51
  loadGitAutoMode?: (context: LaunchContext) => Promise<boolean>;
52
+ /** The checkouts linked on this machine that the merge check inspects. */
53
+ deliveryEnvironment?: (
54
+ context: LaunchContext,
55
+ capabilities: CapabilityConfig[],
56
+ ) => Promise<DeliveryEnvironment>;
47
57
  stdout?: (line: string) => void;
48
58
  stderr?: (line: string) => void;
49
59
  }
50
60
 
51
61
  /** Presence-only flags; every other `--flag` consumes the following token as its value. */
52
- const BOOLEAN_FLAGS: BooleanFlagSet = new Set(["json"]);
62
+ const BOOLEAN_FLAGS: BooleanFlagSet = new Set(["json", "no-merge-check"]);
63
+
64
+ /** After this, the merge check starts no further delivery. */
65
+ const MERGE_CHECK_BUDGET_MS = 30_000;
66
+
67
+ function defaultDeliveryEnvironment(
68
+ context: LaunchContext,
69
+ capabilities: CapabilityConfig[],
70
+ ): Promise<DeliveryEnvironment> {
71
+ return linkedDeliveryEnvironment(
72
+ context,
73
+ capabilities,
74
+ context.repository?.path ?? process.env.MATE_REPO_PATH,
75
+ );
76
+ }
53
77
 
54
78
  /**
55
79
  * Whether `mate artifact publish --all` would publish this entry. Discovery does not know
@@ -148,7 +172,29 @@ function renderClaim(claim: MergeClaim): string {
148
172
  : `answered by ${who}, not checked by Git`;
149
173
  }
150
174
 
175
+ /** Deliveries the merge check left unchecked and why it failed; empty when neither. */
176
+ function renderMergeCheck(check: MergeCheck | undefined): string[] {
177
+ if (!check || (check.unchecked.length === 0 && !check.warning)) return [];
178
+ return [
179
+ ...(check.unchecked.length > 0
180
+ ? [
181
+ "Not checked for a merge on this machine, stored state shown:",
182
+ ...check.unchecked.map(
183
+ (entry) =>
184
+ ` ${inboxText(entry.change)}: ${inboxText(entry.branch)} in ${inboxText(entry.repository)}`,
185
+ ),
186
+ ]
187
+ : []),
188
+ ...(check.warning ? [`Merge check: ${inboxText(check.warning)}`] : []),
189
+ "",
190
+ ];
191
+ }
192
+
151
193
  function renderSubmitted(submitted: SubmittedDiscovery): string[] {
194
+ return [...renderGroups(submitted), ...renderMergeCheck(submitted.mergeCheck)];
195
+ }
196
+
197
+ function renderGroups(submitted: SubmittedDiscovery): string[] {
152
198
  const fetched = submitted.fetchedAt ? `fetched ${submitted.fetchedAt}` : "never fetched";
153
199
  const freshness = submitted.stale
154
200
  ? `last known state, ${fetched}${submitted.error ? `: ${submitted.error}` : ""}`
@@ -160,7 +206,7 @@ function renderSubmitted(submitted: SubmittedDiscovery): string[] {
160
206
  return [
161
207
  `${count} submitted change${count === 1 ? "" : "s"} on ${submitted.pendingBranch} by Delivery Group (${freshness}):`,
162
208
  ...submitted.groups.flatMap((group) => [
163
- ` ${inboxText(group.group)}${group.publishable ? " publishable" : ""}${group.blocked ? " blocked" : ""}`,
209
+ ` ${inboxText(group.group)}${group.publishable ? ` publishable${group.needsRefresh ? " with --refresh" : ""}` : ""}${group.blocked ? " blocked" : ""}`,
164
210
  ...(group.heldBy.length > 0
165
211
  ? [` held by unpublished ${group.heldBy.map(inboxText).join(", ")}`]
166
212
  : []),
@@ -170,6 +216,10 @@ function renderSubmitted(submitted: SubmittedDiscovery): string[] {
170
216
  (part) =>
171
217
  ` touches ${inboxText(part.capability)} › ${inboxText(part.requirement)}`,
172
218
  ),
219
+ ...(change.found ?? []).map(
220
+ (found) =>
221
+ ` merged in ${inboxText(found.repository)}: found by Git on this machine, not recorded yet`,
222
+ ),
173
223
  ...change.merges
174
224
  .filter((claim) => !claim.yours)
175
225
  .map(
@@ -216,17 +266,25 @@ function renderHuman(result: PendingResult): string[] {
216
266
  * the pending branch: `git show <submitted.ref>:<path>/<file>` reads a file of it. Each group
217
267
  * carries `publishable`, `blocked` and `heldBy` (unpublished dependencies whose group cannot
218
268
  * publish). In Git mode `auto` the default and pending branches are fetched first; otherwise, or
219
- * when the fetch fails, the last fetched state is reported as `stale`. Separately, `pending` lists archives an earlier Mate left uncommitted, publishable
269
+ * when the fetch fails, the last fetched state is reported as `stale`. Then each unsettled branch
270
+ * delivery in a repository linked on this machine is checked for a merge by local Git, starting
271
+ * none after 30 s: a proven merge counts in `delivery.status` and `publishable`, is named in the
272
+ * change's `found` and sets its group's `needsRefresh`, since nothing records it and
273
+ * `delivery.record` stays as stored; `submitted.mergeCheck` names the deliveries left `unchecked`,
274
+ * whose stored state stands. In Git mode `auto` the check first fetches the default and delivery
275
+ * branches into the linked checkout, and a recorded pull request's head when the branch and its
276
+ * recorded head are missing there. Separately, `pending` lists archives an earlier Mate left uncommitted, publishable
220
277
  * from this checkout only: archived OpenSpec changes whose own files — the archive directory or
221
278
  * the active directory archiving deleted — are still uncommitted in the companion working
222
279
  * tree, each with the uncommitted canonical specs it applied to, so the publication
223
280
  * workflow can offer exact selectable entries instead of parsing OpenSpec prose.
224
281
  * Uncommitted specs no pending change accounts for are reported separately, each with the
225
282
  * archives whose delta specs name it. Every reported entry carries `coveredByAll`, marking
226
- * what `mate artifact publish --all` would publish. Read-only:
227
- * nothing is validated, produced, committed, or pushed.
283
+ * what `mate artifact publish --all` would publish. Read-only apart
284
+ * from those fetches: nothing is validated, produced, committed, or pushed.
228
285
  * @flags
229
286
  * - `--json` — emit a machine-readable {@link PendingResult} instead of human-readable text.
287
+ * - `--no-merge-check` — skip the merge check and report only stored merge results.
230
288
  * @remarks No-ops (with a message on stderr) when the openspec capability is disabled for
231
289
  * this repo. Exits non-zero only when the companion, launch context, or Git guard rejects.
232
290
  */
@@ -236,7 +294,9 @@ export async function runArtifactPendingCommand(
236
294
  ): Promise<void> {
237
295
  const emitOut = deps.stdout ?? ((line: string) => process.stdout.write(`${line}\n`));
238
296
  const emitErr = deps.stderr ?? ((line: string) => process.stderr.write(`${line}\n`));
239
- const json = parseFlags(argv, BOOLEAN_FLAGS).json === true;
297
+ const flags = parseFlags(argv, BOOLEAN_FLAGS);
298
+ const json = flags.json === true;
299
+ const mergeCheck = flags["no-merge-check"] !== true;
240
300
 
241
301
  const ensureCompanion = deps.ensureUnambiguousCompanion ?? ensureUnambiguousCompanion;
242
302
  if (!(await ensureCompanion(process.cwd()))) {
@@ -258,7 +318,8 @@ export async function runArtifactPendingCommand(
258
318
  }
259
319
 
260
320
  const loadCapabilities = deps.loadCapabilities ?? defaultLoadCapabilities;
261
- if (!hasOpenspecCapability(await loadCapabilities(context))) {
321
+ const capabilities = await loadCapabilities(context);
322
+ if (!hasOpenspecCapability(capabilities)) {
262
323
  emitErr("mate: the openspec capability must be enabled to list pending artifacts.");
263
324
  return;
264
325
  }
@@ -286,11 +347,14 @@ export async function runArtifactPendingCommand(
286
347
  // The local listing stands on its own; a failed discovery is reported, not fatal.
287
348
  // A declared type's submitted changes are listed in place of the built-in type's; an invalid
288
349
  // declaration is reported with the discovery.
350
+ const environment = () =>
351
+ (deps.deliveryEnvironment ?? defaultDeliveryEnvironment)(context, capabilities);
289
352
  const submitted = await declaredSubmitType(context.companionPath)
290
353
  .then((type) =>
291
354
  (deps.discoverSubmitted ?? discoverSubmitted)(context.companionPath, {
292
355
  fetch: gitAutoMode,
293
356
  ...(type ? { type } : {}),
357
+ ...(mergeCheck ? { checkMerges: { environment, budgetMs: MERGE_CHECK_BUDGET_MS } } : {}),
294
358
  }),
295
359
  )
296
360
  .catch((error: unknown): SubmittedDiscovery => ({
@@ -19,8 +19,8 @@ interface TokensaveCapDeps {
19
19
  * runs in. Requires the `tokensave` capability to be enabled
20
20
  * in `.mate/config/framework.yaml` and a registered working repo for the
21
21
  * current `MATE_REPO_ID`. Ensures the `tokensave` binary is installed in that
22
- * repo (via {@link ensureTokensaveInstalled}) before forwarding. Never upgrades:
23
- * this runs mid-session (e.g. `mate cap index`), and upgrades belong to `mate setup`.
22
+ * repo (via {@link ensureTokensaveInstalled}) before forwarding. Never checks its version:
23
+ * this runs mid-session (e.g. `mate cap index`), and the check belongs to `mate setup`.
24
24
  * @remarks The child process's exit code is propagated via `process.exitCode`.
25
25
  */
26
26
  export async function runTokensaveCapCommand(
@@ -14,6 +14,7 @@ import {
14
14
  type LinkRefreshResult,
15
15
  } from "../../../lib/orchestrator/refresh-working-claude-links";
16
16
  import type { FrameworkConfig } from "../../../lib/orchestrator/types";
17
+ import { runSkillsCli } from "../../../lib/skills-cli";
17
18
  import {
18
19
  fetchLatestVersion,
19
20
  getCurrentVersion,
@@ -27,7 +28,6 @@ import {
27
28
  type CompanionSyncOptions,
28
29
  } from "../../../tools/setup";
29
30
  import type { ManagedOutputOwner, ManagedOutputReport } from "../../../tools/setup/plugin";
30
- import { runCommand } from "../../../tools/setup/utils";
31
31
  import { confirm } from "../../confirm";
32
32
  import { defaultGitOps, type GitOps } from "../artifact/finish/git";
33
33
  import { resolveCompanionPath } from "./tui";
@@ -132,8 +132,7 @@ export const companionUpdateDeps: CompanionUpdateDeps = {
132
132
  .access(path.join(companionPath, SKILLS_LOCKFILE))
133
133
  .then(() => true)
134
134
  .catch(() => false),
135
- runSkillsUpdate: (companionPath) =>
136
- runCommand("npx", ["skills", "update", "-p", "-y"], { cwd: companionPath }),
135
+ runSkillsUpdate: (companionPath) => runSkillsCli(["update", "-p", "-y"], companionPath),
137
136
  createGitOps: (companionPath) => defaultGitOps(companionPath, undefined),
138
137
  snapshotPath,
139
138
  confirm,
@@ -67,6 +67,8 @@ interface DoctorDeps {
67
67
  /** Returns a member checkout's HEAD commit, or null when unreadable. */
68
68
  gitHead?: (memberPath: string) => string | null;
69
69
  inspectPlugins?: (companionPath: string) => Promise<PluginInspection>;
70
+ /** Appliance startup: this machine's local plugins neither load nor count. */
71
+ committedPluginsOnly?: boolean;
70
72
  /** Loads the companion's declared plugins so their Capabilities contribute. */
71
73
  hydratePlugins?: (companionPath: string) => Promise<void>;
72
74
  inspectClaudePlugins?: (
@@ -571,7 +573,13 @@ export async function collectDoctorReport(deps: DoctorDeps = {}): Promise<Doctor
571
573
  /** Doctor reports plugin failures below; hydration supplies their contributions. */
572
574
  const hydrate =
573
575
  deps.hydratePlugins ??
574
- ((companionPath) => hydrateDynamicPlugins({ companionPath, env, warn: () => {} }));
576
+ ((companionPath) =>
577
+ hydrateDynamicPlugins({
578
+ companionPath,
579
+ env,
580
+ warn: () => {},
581
+ includeLocal: !deps.committedPluginsOnly,
582
+ }));
575
583
  await hydrate(root.rootPath);
576
584
  const inspectClaudePlugins = deps.inspectClaudePlugins ?? inspectClaudePluginDirectories;
577
585
  const inspection = await inspectClaudePlugins(root.rootPath, root.config);
@@ -581,7 +589,9 @@ export async function collectDoctorReport(deps: DoctorDeps = {}): Promise<Doctor
581
589
 
582
590
  if (root.rootPath && root.config) {
583
591
  const inspect =
584
- deps.inspectPlugins ?? ((companionPath) => inspectDeclaredPlugins(companionPath, { env }));
592
+ deps.inspectPlugins ??
593
+ ((companionPath) =>
594
+ inspectDeclaredPlugins(companionPath, { env, includeLocal: !deps.committedPluginsOnly }));
585
595
  const inspection = await inspect(root.rootPath);
586
596
  report.pluginFailures = inspection.failures;
587
597
  report.pluginCapabilities = inspection.capabilities;
@@ -851,7 +861,8 @@ function renderHumanReport(report: DoctorReport): void {
851
861
  * audience) are verified strictly (installed, loadable); any failure is named
852
862
  * on stderr and exits non-zero, as is an undeclared `MATE_AUDIENCE` or a
853
863
  * Capability whose runtime contributions fail to load.
854
- * `--json` emits the same report as one JSON document.
864
+ * `--json` emits the same report as one JSON document. `--frozen-plugins`
865
+ * ignores local plugins, for appliance startup verification.
855
866
  */
856
867
  /** One step: the checks run concurrently, so finer steps would finish in arbitrary order. */
857
868
  async function collectWithProgress(deps: DoctorDeps): Promise<DoctorReport> {
@@ -865,7 +876,8 @@ async function collectWithProgress(deps: DoctorDeps): Promise<DoctorReport> {
865
876
 
866
877
  export async function runDoctorCommand(argv: string[] = [], deps: DoctorDeps = {}): Promise<void> {
867
878
  const json = argv.includes("--json");
868
- const report = json ? await collectDoctorReport(deps) : await collectWithProgress(deps);
879
+ const checkDeps = { ...deps, committedPluginsOnly: argv.includes("--frozen-plugins") };
880
+ const report = json ? await collectDoctorReport(checkDeps) : await collectWithProgress(checkDeps);
869
881
  if (json) await writeJsonStdout(report);
870
882
  else renderHumanReport(report);
871
883
 
@@ -36,7 +36,7 @@ export function reportPluginInstallResults(results: PluginInstallResult[]): bool
36
36
  process.stderr.write(
37
37
  `${FRAMEWORK_NAME}: plugin "${result.package}" failed to install: ${result.error ?? "unknown error"}\n`,
38
38
  );
39
- process.stderr.write(`${registryConfigHint(result.package)}\n`);
39
+ if (!result.refused) process.stderr.write(`${registryConfigHint(result.package)}\n`);
40
40
  } else if (result.status === "installed") {
41
41
  console.log(` installed plugin ${result.package}@${result.resolvedVersion}`);
42
42
  }
@@ -66,6 +66,10 @@ export interface InstallCommandDeps {
66
66
  runPlan?: typeof runInstallPlan;
67
67
  }
68
68
 
69
+ export function isFrozenPluginInstall(argv: string[]): boolean {
70
+ return argv.includes("--frozen-plugins");
71
+ }
72
+
69
73
  /** `--with <id>` / `--without <id>`, repeatable, also as `--with=<id>[,<id>]`. */
70
74
  export function parseMemberChoiceFlags(argv: string[]): MemberChoices | { error: string } {
71
75
  const choices: MemberChoices = {};
@@ -156,7 +160,7 @@ function printPlanText(plan: Awaited<ReturnType<typeof inspectInstallPlan>>): vo
156
160
  * - `--yes` — skip confirmation; required for non-TTY execution. Tools the companion only recommends are not installed by `--yes` alone.
157
161
  * - `--with <capability>` — install a tool the companion recommends (RTK, TokenSave, Graphify, Context Mode) and remember the choice. Repeatable.
158
162
  * - `--without <capability>` — decline a recommended tool and remember the choice. Repeatable.
159
- * - `--frozen-plugins` — deployment restore: install the base plugins and the selected audience's exactly from their committed lockfiles, never rewrite a plugin manifest or lockfile. The checkout's plugin-generated files are written, not committed.
163
+ * - `--frozen-plugins` — deployment restore: install the base plugins and the selected audience's exactly from their committed lockfiles, never rewrite a plugin manifest or lockfile. Local plugins are ignored. The checkout's plugin-generated files are written, not committed.
160
164
  */
161
165
  export async function runInstallCommand(
162
166
  argv: string[],
@@ -164,7 +168,7 @@ export async function runInstallCommand(
164
168
  deps: InstallCommandDeps = {},
165
169
  ): Promise<boolean> {
166
170
  const skipConfirm = argv.includes("--yes");
167
- const frozen = argv.includes("--frozen-plugins");
171
+ const frozen = isFrozenPluginInstall(argv);
168
172
  const flagChoices = parseMemberChoiceFlags(argv);
169
173
  if ("error" in flagChoices) {
170
174
  process.stderr.write(`${FRAMEWORK_NAME}: ${flagChoices.error}\n`);
@@ -222,7 +226,7 @@ export async function runInstallCommand(
222
226
  return false;
223
227
  }
224
228
  if (outcome.declared) {
225
- await hydrateDynamicPlugins({ companionPath: context.companionPath });
229
+ await hydrateDynamicPlugins({ companionPath: context.companionPath, includeLocal: !frozen });
226
230
  if (frozen) {
227
231
  const failures = await verifyDeclaredPlugins(context.companionPath);
228
232
  if (failures.length > 0) {
@@ -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
  }