@uniqbit/mate-core 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
- package/claude-plugin/hooks/hooks.json +10 -1
- package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
- package/opencode-plugin/src/server.ts +9 -2
- package/package.json +2 -1
- package/src/cli/commands/artifact/delivery/environment.ts +28 -8
- package/src/cli/commands/artifact/delivery/link.ts +28 -9
- package/src/cli/commands/artifact/delivery/output.ts +7 -0
- package/src/cli/commands/companion/update.ts +2 -19
- package/src/cli/commands/factory/factory.ts +11 -1
- package/src/cli/commands/install.ts +47 -36
- package/src/cli/commands/launch/claude.ts +2 -0
- package/src/cli/commands/launch/shared.ts +33 -6
- package/src/cli/commands/plugin/install.ts +27 -11
- package/src/cli/commands/report/index.ts +180 -184
- package/src/cli/commands/report/markdown.ts +67 -72
- package/src/cli/commands/shared/companion-selection.ts +3 -1
- package/src/cli/commands/studio/access.ts +6 -14
- package/src/cli/commands/studio/areas.ts +112 -33
- package/src/cli/commands/studio/companion-add.ts +87 -0
- package/src/cli/commands/studio/companion-removal.ts +15 -8
- package/src/cli/commands/studio/factory-credential.ts +1 -15
- package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
- package/src/cli/commands/studio/factory-relay.ts +18 -0
- package/src/cli/commands/studio/graph-model.ts +61 -0
- package/src/cli/commands/studio/graph.ts +336 -0
- package/src/cli/commands/studio/index.ts +4 -4
- package/src/cli/commands/studio/payload.ts +42 -15
- package/src/cli/commands/studio/repository-add.ts +116 -0
- package/src/cli/commands/studio/routes.ts +6 -0
- package/src/cli/commands/studio/selection.ts +12 -3
- package/src/cli/commands/studio/server.ts +127 -5
- package/src/cli/commands/studio/services.ts +40 -0
- package/src/cli/commands/studio/terminal.ts +45 -3
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
- package/src/cli/commands/studio/workset-session.ts +47 -14
- package/src/cli/commands/unwrap.ts +3 -0
- package/src/cli/commands/update.ts +2 -0
- package/src/cli/commands/vscode/release-vsix.json +4 -0
- package/src/cli/commands/vscode/setup.ts +71 -13
- package/src/cli/commands/vscode/vsix.ts +48 -7
- package/src/cli/commands/working/cleanup.ts +40 -8
- package/src/cli/commands/working/worktree.ts +176 -35
- package/src/cli/main.ts +17 -2
- package/src/cli/usage.ts +1 -1
- package/src/hooks/rtk-worktree-git.ts +48 -0
- package/src/hooks/validate-artifact-path.ts +38 -7
- package/src/lib/delivery/branch-template.ts +122 -0
- package/src/lib/delivery/branches.ts +21 -16
- package/src/lib/delivery/checkout.ts +102 -0
- package/src/lib/delivery/environment.ts +2 -0
- package/src/lib/delivery/merge-git.ts +13 -1
- package/src/lib/delivery/record-delivery.ts +83 -29
- package/src/lib/delivery/record.ts +15 -3
- package/src/lib/delivery/resolve-branch.ts +157 -110
- package/src/lib/factory/attach-client.ts +11 -1
- package/src/lib/factory/broker.ts +37 -40
- package/src/lib/factory/client.ts +22 -1
- package/src/lib/factory/clone-url.ts +39 -0
- package/src/lib/factory/command.ts +21 -5
- package/src/lib/factory/git-auth.ts +61 -0
- package/src/lib/factory/git-credential-store.ts +181 -0
- package/src/lib/factory/ids.ts +12 -2
- package/src/lib/factory/outcomes/actions.ts +20 -4
- package/src/lib/factory/outcomes/index.ts +77 -11
- package/src/lib/factory/outcomes/lifecycle.ts +9 -2
- package/src/lib/factory/outcomes/sessions.ts +23 -1
- package/src/lib/factory/prepare.ts +9 -3
- package/src/lib/factory/runner/scheduler.ts +96 -14
- package/src/lib/factory/runner/workflow.ts +5 -1
- package/src/lib/factory/runtime.ts +143 -43
- package/src/lib/orchestrator/companion-hub.ts +6 -1
- package/src/lib/orchestrator/engine-floor.ts +48 -0
- package/src/lib/orchestrator/launcher.ts +34 -1
- package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
- package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
- package/src/lib/orchestrator/projection-claude-links.ts +32 -8
- package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
- package/src/lib/orchestrator/projection-entries.ts +22 -18
- package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
- package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
- package/src/lib/orchestrator/projection-types.ts +28 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
- package/src/lib/orchestrator/session-prepare.ts +6 -1
- package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
- package/src/lib/orchestrator/types.ts +4 -0
- package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
- package/src/lib/orchestrator/working-repo-projection.ts +24 -4
- package/src/lib/orchestrator/wrap-pass.ts +1 -0
- package/src/lib/public-npm.ts +95 -50
- package/src/lib/session-state.ts +72 -2
- package/src/lib/update-checker.ts +7 -1
- package/src/lib/usage/aggregate.ts +202 -0
- package/src/lib/usage/cache.ts +87 -0
- package/src/lib/usage/claude-pricing.ts +71 -0
- package/src/lib/usage/claude.ts +189 -0
- package/src/lib/usage/collect.ts +56 -0
- package/src/lib/usage/opencode.ts +188 -0
- package/src/lib/usage/records.ts +80 -0
- package/src/lib/usage/rtk-database.ts +72 -0
- package/src/lib/usage/savings.ts +209 -0
- package/src/lib/usage/scope.ts +182 -0
- package/src/lib/usage/source.ts +102 -0
- package/src/lib/usage/types.ts +143 -0
- package/src/lib/usage/window.ts +37 -0
- package/src/lib/workset/factory-local.ts +157 -0
- package/src/lib/workset/record.ts +25 -11
- package/src/lib/workset/repositories.ts +118 -25
- package/src/lib/workset/worktree-include.ts +161 -0
- package/src/lib/workset/worktree-index.ts +6 -2
- package/src/lib/workset/worktree.ts +591 -101
- package/src/opencode/companion-hooks.ts +46 -8
- package/src/opencode/companion-policy.ts +18 -5
- package/src/opencode/enter-worktree.ts +254 -6
- package/src/opencode/session-register.ts +2 -2
- package/src/runtime/claude-bg-isolation.ts +138 -0
- package/src/runtime/companion-git.ts +10 -2
- package/src/runtime/companion-guidance.ts +17 -4
- package/src/runtime/current-branch.ts +16 -2
- package/src/runtime/entered-worktree.ts +24 -0
- package/src/runtime/git-tracked.ts +60 -0
- package/src/runtime/repo-destination.ts +72 -0
- package/src/runtime/repo-local.ts +25 -3
- package/src/runtime/rtk-git-guard.ts +66 -0
- package/src/runtime/runtime-document-manifest.ts +229 -19
- package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
- package/src/runtime/secret-guard.ts +9 -2
- package/src/runtime/secret-policy-weakening.ts +122 -0
- package/src/runtime/serving-claude-wrap.ts +15 -2
- package/src/runtime/umbrella-folder.ts +56 -0
- package/src/runtime/wrap-state.ts +5 -13
- package/src/studio.ts +37 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +307 -42
- package/src/tools/setup/capabilities/rtk.ts +93 -1
- package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
- package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
- package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
- package/src/tools/setup/dynamic-plugins/install.ts +24 -22
- package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
- package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
- package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
- package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
- package/src/tools/setup/mate.ts +3 -3
- package/src/tools/setup/plugins/gitignore.ts +15 -9
- package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
- package/src/tools/setup/providers/claude.ts +25 -3
- package/src/tools/setup/utils.ts +4 -2
- package/src/tools/setup/working-repo-cleanup.ts +2 -2
- package/src/tools/setup/working-repo-local-state.ts +2 -0
- package/src/tools/setup.ts +25 -14
- package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
- package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
- package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
- package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
- package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
- package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
- package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
- package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
- package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
- package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
- package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
- package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
- package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
- package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
- package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
- package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
- package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
- package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
- package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
- package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
- package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
- package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
- package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
- package/studio-dist/client/assets/select-CnaMd617.js +1 -0
- package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
- package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
- package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
- package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
- package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
- package/studio-dist/client/assets/store-Dw34catY.js +1 -0
- package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
- package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
- package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
- package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
- package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
- package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
- package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
- package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
- package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
- package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
- package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
- package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
- package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
- package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
- package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
- package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
- package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
- package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
- package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
- package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
- package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
- package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
- package/studio-dist/server/assets/graph-CSje3029.js +801 -0
- package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
- package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
- package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
- package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
- package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
- package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
- package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
- package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
- package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
- package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
- package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
- package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
- package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
- package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
- package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
- package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
- package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
- package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
- package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
- package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
- package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
- package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
- package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
- package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
- package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
- package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
- package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
- package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
- package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
- package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
- package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
- package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
- package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
- package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
- package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
- package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
- package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
- package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
- package/studio-dist/server/server.js +582 -8
- package/src/cli/commands/report/collector.ts +0 -288
- package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
- package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
- package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
- package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
- package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
- package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
- package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
- package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
- package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
- package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
- package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
- package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
- package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
- package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
- package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
- package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
- package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
- package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
- package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
- package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
- package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
- package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
- package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
- package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
- package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
- package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
- package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "Mate hooks \u2014 PreToolUse artifact-path and secret guardrail, PreToolUse tokensave worktree routing, SessionStart banner, companion guidance, session prepare then companion instructions, SubagentStart companion instructions, SessionEnd and Notification session registry",
|
|
2
|
+
"description": "Mate hooks \u2014 PreToolUse artifact-path and secret guardrail, PreToolUse tokensave worktree routing, PreToolUse RTK git deny in entered worktrees, SessionStart banner, companion guidance, session prepare then companion instructions, SubagentStart companion instructions, SessionEnd and Notification session registry",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"PreToolUse": [
|
|
5
5
|
{
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/tokensave-route.mjs\""
|
|
20
20
|
}
|
|
21
21
|
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"matcher": "Bash",
|
|
25
|
+
"hooks": [
|
|
26
|
+
{
|
|
27
|
+
"type": "command",
|
|
28
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/rtk-worktree-git.mjs\""
|
|
29
|
+
}
|
|
30
|
+
]
|
|
22
31
|
}
|
|
23
32
|
],
|
|
24
33
|
"SessionStart": [
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Thin shim for src/hooks/rtk-worktree-git.ts, loaded through ts-loader.mjs: the
|
|
4
|
+
* installed plugin sits inside node_modules, where node's native type stripping is off.
|
|
5
|
+
* Runs on every Bash call, so it answers before loading any TypeScript unless the
|
|
6
|
+
* command names git and runs in a linked worktree (a `.git` file, not a folder).
|
|
7
|
+
*/
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
|
|
11
|
+
async function readInput() {
|
|
12
|
+
if (process.stdin.isTTY) return null;
|
|
13
|
+
const chunks = [];
|
|
14
|
+
for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk));
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** True when the nearest `.git` at or above `directory` is a file: a linked worktree. */
|
|
23
|
+
function inLinkedWorktree(directory) {
|
|
24
|
+
try {
|
|
25
|
+
let current = fs.realpathSync(directory);
|
|
26
|
+
for (;;) {
|
|
27
|
+
const dotGit = fs.statSync(path.join(current, ".git"), { throwIfNoEntry: false });
|
|
28
|
+
if (dotGit) return dotGit.isFile();
|
|
29
|
+
const parent = path.dirname(current);
|
|
30
|
+
if (parent === current) return false;
|
|
31
|
+
current = parent;
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const input = await readInput();
|
|
40
|
+
const command = input?.tool_input?.command;
|
|
41
|
+
if (
|
|
42
|
+
typeof input?.cwd === "string" &&
|
|
43
|
+
typeof command === "string" &&
|
|
44
|
+
/\bgit\b/.test(command) &&
|
|
45
|
+
inLinkedWorktree(input.cwd)
|
|
46
|
+
) {
|
|
47
|
+
await import("./ts-loader.mjs");
|
|
48
|
+
const { buildRtkWorktreeGit } = await import("../../src/hooks/rtk-worktree-git.ts");
|
|
49
|
+
const { stdout } = buildRtkWorktreeGit(input);
|
|
50
|
+
if (stdout) {
|
|
51
|
+
process.stdout.on("error", () => {});
|
|
52
|
+
process.stdout.write(stdout);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Any failure passes the call unchanged.
|
|
57
|
+
}
|
|
58
|
+
process.exitCode = 0;
|
|
@@ -63,13 +63,20 @@ export const MateOpenCodePlugin = Plugin.define({
|
|
|
63
63
|
await registerCompanionHooks(api, context, env);
|
|
64
64
|
await registerTokensaveRouting(api);
|
|
65
65
|
await registerCompanion(api, context, env);
|
|
66
|
-
await registerEnterWorktree(api, context);
|
|
66
|
+
const worktreeCleanup = await registerEnterWorktree(api, context);
|
|
67
67
|
const sessionsCleanup = await registerOpenCodeSessions(api).catch(() => undefined);
|
|
68
68
|
if (sessionsCleanup) server?.onStop(() => sessionsCleanup());
|
|
69
69
|
/** Last: the guardrails above are live while the local phase holds `setup`. */
|
|
70
|
-
const prepareCleanup = await registerPrepare(api, context.companionPath, env)
|
|
70
|
+
const prepareCleanup = await registerPrepare(api, context.companionPath, env).catch(
|
|
71
|
+
(error: unknown) => {
|
|
72
|
+
/** A failed setup returns no cleanup: end the subscription that would move sessions. */
|
|
73
|
+
worktreeCleanup();
|
|
74
|
+
throw error;
|
|
75
|
+
},
|
|
76
|
+
);
|
|
71
77
|
return async () => {
|
|
72
78
|
server?.dispose();
|
|
79
|
+
worktreeCleanup();
|
|
73
80
|
/** A Mate OpenCode server's sessions outlive a location; its idle stop ends them. */
|
|
74
81
|
await sessionsCleanup?.({ keepSessions: Boolean(server) });
|
|
75
82
|
await prepareCleanup?.();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniqbit/mate-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Core framework and plugin APIs for Mate.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"react": "^19.2.7",
|
|
72
72
|
"react-doctor": "0.9.13",
|
|
73
73
|
"semver": "^7.8.5",
|
|
74
|
+
"smol-toml": "1.9.1",
|
|
74
75
|
"yaml": "^2.9.0",
|
|
75
76
|
"zod": "4.6.7"
|
|
76
77
|
},
|
|
@@ -13,6 +13,12 @@ import {
|
|
|
13
13
|
type LaunchContext,
|
|
14
14
|
} from "../../../../lib/orchestrator/framework-context";
|
|
15
15
|
import type { CapabilityConfig, LinkedRepository } from "../../../../lib/orchestrator/types";
|
|
16
|
+
import {
|
|
17
|
+
linkedCheckoutsOf,
|
|
18
|
+
umbrellaChildrenOf,
|
|
19
|
+
type EntryCheckout,
|
|
20
|
+
type OriginReader,
|
|
21
|
+
} from "../../../../lib/orchestrator/umbrella-checkouts";
|
|
16
22
|
import { WorkingRepoRequiredError } from "../../../../lib/orchestrator/types";
|
|
17
23
|
import { ensureUnambiguousCompanion } from "../../shared/companion-selection";
|
|
18
24
|
|
|
@@ -22,6 +28,8 @@ export interface DeliveryEnvironmentDeps {
|
|
|
22
28
|
loadCapabilities?: (context: LaunchContext) => Promise<CapabilityConfig[]>;
|
|
23
29
|
workingRepoGit?: (repoPath: string) => WorkingRepoGit;
|
|
24
30
|
loadLinkedRepositories?: (context: LaunchContext) => Promise<LinkedRepository[]>;
|
|
31
|
+
/** Reads an Umbrella Repository child's `origin`; raw config by default, as worktree planning reads it. */
|
|
32
|
+
readChildOrigin?: OriginReader;
|
|
25
33
|
/** True when the companion's Git mode is `auto`. */
|
|
26
34
|
loadGitAutoMode?: (context: LaunchContext) => Promise<boolean>;
|
|
27
35
|
}
|
|
@@ -36,6 +44,11 @@ interface LinkedCheckout {
|
|
|
36
44
|
path: string;
|
|
37
45
|
}
|
|
38
46
|
|
|
47
|
+
/** The checkouts whose `origin` names a forge repository. */
|
|
48
|
+
function withRemotes(checkouts: readonly EntryCheckout[]): LinkedCheckout[] {
|
|
49
|
+
return checkouts.flatMap(({ path, remote }) => (remote ? [{ remote, path }] : []));
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
async function defaultLoadGitAutoMode(context: LaunchContext): Promise<boolean> {
|
|
40
53
|
return (await context.configStore.load()).git === "auto";
|
|
41
54
|
}
|
|
@@ -73,16 +86,24 @@ export async function resolveDeliveryEnvironment(
|
|
|
73
86
|
|
|
74
87
|
const openGit = deps.workingRepoGit ?? workingRepoGit;
|
|
75
88
|
const repoPath = context.repository?.path ?? process.env.MATE_REPO_PATH;
|
|
89
|
+
const readOrigin = (checkout: string) => openGit(checkout).remoteUrl();
|
|
76
90
|
let workingRepo: WorkingRepoInfo | null = null;
|
|
91
|
+
// An Umbrella Repository has no `origin` of its own; its children name the repositories.
|
|
92
|
+
const ownChildren = repoPath
|
|
93
|
+
? withRemotes(await umbrellaChildrenOf(repoPath, deps.readChildOrigin))
|
|
94
|
+
: [];
|
|
77
95
|
if (repoPath) {
|
|
78
96
|
const git = openGit(repoPath);
|
|
79
|
-
const remote = await git.remoteUrl();
|
|
97
|
+
const remote = ownChildren.length > 0 ? null : await git.remoteUrl();
|
|
80
98
|
const forgeRepo = remote ? parseRemote(remote) : null;
|
|
81
99
|
workingRepo = {
|
|
82
100
|
path: repoPath,
|
|
83
101
|
slug: forgeRepo ? repositoryPath(forgeRepo) : null,
|
|
84
102
|
forgeRepo,
|
|
85
103
|
git,
|
|
104
|
+
...(ownChildren.length > 0
|
|
105
|
+
? { umbrellaChildren: ownChildren.map((child) => repositoryPath(child.remote)) }
|
|
106
|
+
: {}),
|
|
86
107
|
};
|
|
87
108
|
}
|
|
88
109
|
|
|
@@ -94,14 +115,13 @@ export async function resolveDeliveryEnvironment(
|
|
|
94
115
|
const repositories = await (deps.loadLinkedRepositories ?? defaultLoadLinkedRepositories)(
|
|
95
116
|
context,
|
|
96
117
|
).catch(() => []);
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
118
|
+
// The Working Repository's own entry is skipped; an umbrella's children are in `ownChildren`.
|
|
119
|
+
const checkouts = await Promise.all(
|
|
120
|
+
repositories
|
|
121
|
+
.filter((repository) => repository.path !== repoPath)
|
|
122
|
+
.map((repository) => linkedCheckoutsOf(repository, readOrigin, deps.readChildOrigin)),
|
|
100
123
|
);
|
|
101
|
-
return
|
|
102
|
-
const remote = remotes[index] ? parseRemote(remotes[index]) : null;
|
|
103
|
-
return remote ? [{ remote, path: repository.path }] : [];
|
|
104
|
-
});
|
|
124
|
+
return [...ownChildren, ...withRemotes(checkouts.flat())];
|
|
105
125
|
})());
|
|
106
126
|
const linkedMatch = async (repository: string) =>
|
|
107
127
|
(await linked()).find(({ remote }) => sameRepository(repositoryPath(remote), repository));
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { applyWarnings, type DependencyWarning } from "../../../../lib/delivery/overlap";
|
|
8
8
|
import { isJiraKey, normalizeJiraKey, type MergeState } from "../../../../lib/delivery/record";
|
|
9
9
|
import { attributeCurrentSession } from "../../../../lib/session-attribution";
|
|
10
|
+
import { claudeSessionIsolation } from "../../../../runtime/claude-bg-isolation";
|
|
10
11
|
import { type BooleanFlagSet, parseFlags, positionalArgs, stringFlag } from "../../../parse-flags";
|
|
11
12
|
import {
|
|
12
13
|
branchFlagsFrom,
|
|
@@ -49,8 +50,15 @@ const CONFIRMATIONS: Record<string, MergeState> = {
|
|
|
49
50
|
"confirm-dropped": "closed-unmerged",
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
/**
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* `warnings`: declared dependencies not implemented yet; they inform and never block.
|
|
55
|
+
* `session.isolated`: a Claude Code background session outside a linked worktree, where
|
|
56
|
+
* it may not write.
|
|
57
|
+
*/
|
|
58
|
+
export type LinkResult = DeliveryResult & {
|
|
59
|
+
warnings: DependencyWarning[];
|
|
60
|
+
session: { isolated: boolean };
|
|
61
|
+
};
|
|
54
62
|
|
|
55
63
|
function refusalMessage(refusal: DeliveryRefusal): string {
|
|
56
64
|
if (refusal.reason === "unknown-change") {
|
|
@@ -77,13 +85,15 @@ function renderHuman(result: LinkResult): string[] {
|
|
|
77
85
|
* from the forge or a local checkout (`--refresh`), or the user's answer (`--confirm-*`,
|
|
78
86
|
* source `user`).
|
|
79
87
|
* @flags
|
|
80
|
-
* - `--repository <org/repo>` — the delivery to edit; defaults to the Working Repository
|
|
88
|
+
* - `--repository <org/repo>` — the delivery to edit; defaults to the Working Repository, or in
|
|
89
|
+
* an Umbrella Repository to the change's only scoped child.
|
|
81
90
|
* - `--branch <branch>` — record the delivery branch; a protected branch needs `--direct`.
|
|
82
91
|
* - `--direct` — with `--branch`, record a direct delivery, settled only by the user's answer; required for a protected branch.
|
|
83
92
|
* - `--not-applicable <reason>` — no branch delivers this change in the repository.
|
|
84
93
|
* - `--pr <url>` — record the PR URL; with `--refresh`, picks that PR among several.
|
|
85
94
|
* - `--ticket <KEY>` — record the Delivery Branch resolved with this Jira key (`ABC-123`, any
|
|
86
|
-
* case): a new branch is named
|
|
95
|
+
* case): a new branch is named by the `branchTemplate` (default
|
|
96
|
+
* `workset/<TICKET>-<workset-id>`), while a recorded, inherited,
|
|
87
97
|
* or existing branch is kept. The key is not stored. Excludes `--branch` and
|
|
88
98
|
* `--not-applicable`; refused unless the openspec capability sets `ticket: jira`.
|
|
89
99
|
* - `--refresh` — ask the forge (with `MATE_GIT_TOKEN`), then a local checkout, for the merge
|
|
@@ -94,6 +104,11 @@ function renderHuman(result: LinkResult): string[] {
|
|
|
94
104
|
* - `--json` — emit an array of {@link LinkResult}, one per change.
|
|
95
105
|
* @remarks Warns, without blocking, about each `dependsOn` change that is neither archived nor
|
|
96
106
|
* fully implemented, since apply records the branch before writing code. Without an edit flag or `--refresh` it only reads the record and writes nothing.
|
|
107
|
+
* Every result reports `session.isolated`: true in a Claude Code background session
|
|
108
|
+
* (`CLAUDE_JOB_DIR`) whose isolation (the job's, else its launch `--settings`, else
|
|
109
|
+
* `worktree.bgIsolation` in the Claude settings files) is not `none`, when the Working
|
|
110
|
+
* Repository (else the current folder) lies in a Git checkout that is not a linked
|
|
111
|
+
* worktree. An isolation value other than `worktree` or `none` is ignored with a warning.
|
|
97
112
|
* Network requests go only to the forge API, with `--refresh` and with `--branch` for
|
|
98
113
|
* another repository's default branch, and to `origin` through `git fetch` with `--refresh`
|
|
99
114
|
* in Git mode `auto` or with `--fetch`. Only `git` is started; no credential is read. The
|
|
@@ -169,13 +184,17 @@ export async function runArtifactLinkCommand(
|
|
|
169
184
|
deps,
|
|
170
185
|
);
|
|
171
186
|
if ("refusal" in outcome) return refuse(refusalMessage(outcome.refusal));
|
|
187
|
+
const sessionEnv = deps.sessionEnv ?? process.env;
|
|
172
188
|
// One change names the session's work; a batch link names none.
|
|
173
189
|
if (changes.length === 1) {
|
|
174
|
-
await (deps.attribute ?? attributeCurrentSession)(
|
|
175
|
-
{ change: changes[0]! },
|
|
176
|
-
deps.sessionEnv ?? process.env,
|
|
177
|
-
);
|
|
190
|
+
await (deps.attribute ?? attributeCurrentSession)({ change: changes[0]! }, sessionEnv);
|
|
178
191
|
}
|
|
192
|
+
const isolation = claudeSessionIsolation(
|
|
193
|
+
sessionEnv,
|
|
194
|
+
environment.workingRepo?.path ?? process.cwd(),
|
|
195
|
+
);
|
|
196
|
+
for (const diagnostic of isolation.diagnostics) emitErr(`warning: ${diagnostic}`);
|
|
197
|
+
const session = { isolated: isolation.isolated };
|
|
179
198
|
const results: LinkResult[] = [];
|
|
180
199
|
for (const result of "results" in outcome ? outcome.results : []) {
|
|
181
200
|
for (const diagnostic of result.diagnostics) emitErr(`warning: ${diagnostic}`);
|
|
@@ -184,7 +203,7 @@ export async function runArtifactLinkCommand(
|
|
|
184
203
|
for (const entry of result.settlement.unscoped) {
|
|
185
204
|
emitErr(unscopedDeliveryWarning(result.change, entry));
|
|
186
205
|
}
|
|
187
|
-
results.push({ ...result, warnings });
|
|
206
|
+
results.push({ ...result, warnings, session });
|
|
188
207
|
}
|
|
189
208
|
if (flags.json === true) emitOut(JSON.stringify(results));
|
|
190
209
|
else for (const result of results) for (const line of renderHuman(result)) emitOut(line);
|
|
@@ -73,6 +73,13 @@ export function sharedRefusalMessage(
|
|
|
73
73
|
if (refusal.reason === "no-repository") {
|
|
74
74
|
return "mate: the Working Repository has no origin remote to identify it; pass --repository <org/repo>.";
|
|
75
75
|
}
|
|
76
|
+
if (refusal.reason === "umbrella-repository") {
|
|
77
|
+
const named =
|
|
78
|
+
refusal.scoped.length > 0
|
|
79
|
+
? `the change is scoped to its children ${refusal.scoped.join(", ")}`
|
|
80
|
+
: `the change is scoped to none of its children (${refusal.children.join(", ")})`;
|
|
81
|
+
return `mate: the Working Repository ${refusal.umbrella} is an Umbrella Repository and ${named}; pass --repository <org/repo>.`;
|
|
82
|
+
}
|
|
76
83
|
if (refusal.reason === "tickets-off") {
|
|
77
84
|
return `mate: ${TICKETS_OFF}`;
|
|
78
85
|
}
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
type StartupProgressController,
|
|
9
9
|
} from "../../../lib/components/startup-progress";
|
|
10
10
|
import { ConfigStore } from "../../../lib/orchestrator/config-store";
|
|
11
|
+
import { writeEngineFloor } from "../../../lib/orchestrator/engine-floor";
|
|
11
12
|
import {
|
|
12
13
|
refreshWorkingClaudeLinks,
|
|
13
14
|
type LinkRefreshResult,
|
|
14
15
|
} from "../../../lib/orchestrator/refresh-working-claude-links";
|
|
15
16
|
import type { FrameworkConfig } from "../../../lib/orchestrator/types";
|
|
16
|
-
import { YamlFileStore } from "../../../lib/orchestrator/yaml-file-store";
|
|
17
17
|
import {
|
|
18
18
|
fetchLatestVersion,
|
|
19
19
|
getCurrentVersion,
|
|
@@ -56,16 +56,6 @@ function frameworkConfigPath(companionPath: string): string {
|
|
|
56
56
|
return path.join(companionPath, `.${FRAMEWORK_NAME}`, "config", "framework.yaml");
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Raw view of `framework.yaml`: `ConfigStore.load()` merges defaults, so saving
|
|
61
|
-
* its result would add keys the companion never declared.
|
|
62
|
-
*/
|
|
63
|
-
class RawFrameworkConfigStore extends YamlFileStore<Record<string, unknown>> {
|
|
64
|
-
protected onMissing(): Promise<Record<string, unknown>> {
|
|
65
|
-
return Promise.resolve({});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
59
|
async function hashTree(absolute: string, hash: crypto.Hash, relative: string): Promise<void> {
|
|
70
60
|
const stat = await fs.lstat(absolute);
|
|
71
61
|
if (stat.isDirectory()) {
|
|
@@ -134,14 +124,7 @@ export const companionUpdateDeps: CompanionUpdateDeps = {
|
|
|
134
124
|
return (await syncCompanionFiles(companionPath, config, undefined, options)).managedOutput;
|
|
135
125
|
},
|
|
136
126
|
untrackSkillCopies: untrackManagedSkillCopies,
|
|
137
|
-
|
|
138
|
-
const store = new RawFrameworkConfigStore(frameworkConfigPath(companionPath));
|
|
139
|
-
const raw = (await store.load()) ?? {};
|
|
140
|
-
const engines = (raw.engines ?? {}) as Record<string, string>;
|
|
141
|
-
if (engines[FRAMEWORK_NAME] === range) return false;
|
|
142
|
-
await store.save({ ...raw, engines: { ...engines, [FRAMEWORK_NAME]: range } });
|
|
143
|
-
return true;
|
|
144
|
-
},
|
|
127
|
+
writeEngineFloor,
|
|
145
128
|
refreshWorkingClaudeLinks,
|
|
146
129
|
hasSkillsLock: (companionPath) =>
|
|
147
130
|
fs
|
|
@@ -13,6 +13,11 @@ import {
|
|
|
13
13
|
import { brokerHandler, serveBroker, takeAgentCredential } from "../../../lib/factory/broker";
|
|
14
14
|
import { attachSocketFor, FACTORY_BROKER_ENV } from "../../../lib/factory/client";
|
|
15
15
|
import { CREDENTIAL_FILE, CredentialStore } from "../../../lib/factory/credential-store";
|
|
16
|
+
import {
|
|
17
|
+
GIT_CREDENTIAL_FILE,
|
|
18
|
+
GitCredentialStore,
|
|
19
|
+
takeGitStartupToken,
|
|
20
|
+
} from "../../../lib/factory/git-credential-store";
|
|
16
21
|
import { WorksetRuntime } from "../../../lib/factory/runtime";
|
|
17
22
|
import { usage } from "../../usage";
|
|
18
23
|
|
|
@@ -262,8 +267,13 @@ export async function runFactoryCommand(
|
|
|
262
267
|
path.join(options["state-dir"], CREDENTIAL_FILE),
|
|
263
268
|
takeAgentCredential(),
|
|
264
269
|
);
|
|
270
|
+
const gitTokens = new GitCredentialStore(
|
|
271
|
+
path.join(options["state-dir"], GIT_CREDENTIAL_FILE),
|
|
272
|
+
takeGitStartupToken(),
|
|
273
|
+
);
|
|
265
274
|
const runtime = new WorksetRuntime({
|
|
266
275
|
dockerHost: options["docker-host"],
|
|
276
|
+
gitCredentials: gitTokens,
|
|
267
277
|
stateDir: options["state-dir"],
|
|
268
278
|
image: options.image,
|
|
269
279
|
user: options.user,
|
|
@@ -282,7 +292,7 @@ export async function runFactoryCommand(
|
|
|
282
292
|
...(options.idleMinutes !== undefined ? { idleMinutes: options.idleMinutes } : {}),
|
|
283
293
|
});
|
|
284
294
|
fs.rmSync(options.socket, { force: true });
|
|
285
|
-
const server = serveBroker(options.socket, brokerHandler(runtime, credentials));
|
|
295
|
+
const server = serveBroker(options.socket, brokerHandler(runtime, credentials, gitTokens));
|
|
286
296
|
const attach = serveAttach(attachSocketFor(options.socket), { runtime, credentials });
|
|
287
297
|
process.stderr.write(
|
|
288
298
|
`mate factory: broker on ${options.socket}${credentials.current() ? "" : " (no Workset agent credential)"}\n`,
|
|
@@ -15,21 +15,20 @@ import { MemberChoicesStore, type MemberChoices } from "../../lib/member-choices
|
|
|
15
15
|
import { renderInstallExecution } from "../install-plan";
|
|
16
16
|
import {
|
|
17
17
|
describeUnknownAudience,
|
|
18
|
-
installPluginDeclarations,
|
|
19
18
|
readAudienceSelection,
|
|
20
19
|
resolveAudience,
|
|
21
20
|
} from "../../tools/setup/dynamic-plugins/audiences";
|
|
22
21
|
import { hydrateDynamicPlugins } from "../../tools/setup/dynamic-plugins/hydrate";
|
|
23
|
-
import {
|
|
24
|
-
installDeclaredPlugins,
|
|
25
|
-
type PluginInstallResult,
|
|
26
|
-
} from "../../tools/setup/dynamic-plugins/install";
|
|
22
|
+
import type { PluginInstallResult } from "../../tools/setup/dynamic-plugins/install";
|
|
27
23
|
import { registryConfigHint } from "../../tools/setup/dynamic-plugins/registry-hint";
|
|
28
|
-
import {
|
|
29
|
-
FrozenInstallError,
|
|
30
|
-
installDeclaredPluginsFrozen,
|
|
31
|
-
} from "../../tools/setup/dynamic-plugins/frozen";
|
|
24
|
+
import { FrozenInstallError } from "../../tools/setup/dynamic-plugins/frozen";
|
|
32
25
|
import { verifyDeclaredPlugins } from "../../tools/setup/dynamic-plugins/verify";
|
|
26
|
+
import {
|
|
27
|
+
AUDIENCE_WORKSPACES_VERSION,
|
|
28
|
+
describeRemovedAudience,
|
|
29
|
+
installPluginWorkspaces,
|
|
30
|
+
type PluginWorkspacesOutcome,
|
|
31
|
+
} from "../../tools/setup/dynamic-plugins/workspaces";
|
|
33
32
|
|
|
34
33
|
export function reportPluginInstallResults(results: PluginInstallResult[]): boolean {
|
|
35
34
|
for (const result of results) {
|
|
@@ -45,6 +44,18 @@ export function reportPluginInstallResults(results: PluginInstallResult[]): bool
|
|
|
45
44
|
return results.every((result) => result.status !== "failed");
|
|
46
45
|
}
|
|
47
46
|
|
|
47
|
+
/** Names what the plugin step removed or migrated, beyond the per-plugin results. */
|
|
48
|
+
export function reportPluginWorkspaces(
|
|
49
|
+
outcome: Pick<PluginWorkspacesOutcome, "removed" | "migrated">,
|
|
50
|
+
): void {
|
|
51
|
+
for (const audience of outcome.removed) console.log(` ${describeRemovedAudience(audience)}`);
|
|
52
|
+
if (outcome.migrated) {
|
|
53
|
+
console.log(
|
|
54
|
+
` moved audience plugins out of the shared plugin workspace and raised engines.${FRAMEWORK_NAME} to >=${AUDIENCE_WORKSPACES_VERSION}; commit .${FRAMEWORK_NAME}/plugins/ and framework.yaml`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
export interface InstallCommandDeps {
|
|
49
60
|
memberChoicesStore?: MemberChoicesStore;
|
|
50
61
|
confirm?: typeof confirm;
|
|
@@ -145,7 +156,7 @@ function printPlanText(plan: Awaited<ReturnType<typeof inspectInstallPlan>>): vo
|
|
|
145
156
|
* - `--yes` — skip confirmation; required for non-TTY execution. Tools the companion only recommends are not installed by `--yes` alone.
|
|
146
157
|
* - `--with <capability>` — install a tool the companion recommends (RTK, TokenSave, Graphify, Context Mode) and remember the choice. Repeatable.
|
|
147
158
|
* - `--without <capability>` — decline a recommended tool and remember the choice. Repeatable.
|
|
148
|
-
* - `--frozen-plugins` — deployment restore: install
|
|
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.
|
|
149
160
|
*/
|
|
150
161
|
export async function runInstallCommand(
|
|
151
162
|
argv: string[],
|
|
@@ -176,53 +187,53 @@ export async function runInstallCommand(
|
|
|
176
187
|
process.exitCode = 1;
|
|
177
188
|
return false;
|
|
178
189
|
}
|
|
190
|
+
let audience: string | null = null;
|
|
179
191
|
if (context.kind === "companion") {
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
process.stderr.write(`${FRAMEWORK_NAME}: ${describeUnknownAudience(
|
|
192
|
+
const resolved = resolveAudience(context.config, readAudienceSelection(process.env));
|
|
193
|
+
if (!resolved.ok) {
|
|
194
|
+
process.stderr.write(`${FRAMEWORK_NAME}: ${describeUnknownAudience(resolved)}\n`);
|
|
183
195
|
process.exitCode = 1;
|
|
184
196
|
return false;
|
|
185
197
|
}
|
|
198
|
+
audience = resolved.active;
|
|
186
199
|
}
|
|
187
|
-
const declarations =
|
|
188
|
-
context.kind === "companion" || context.kind === "hub"
|
|
189
|
-
? installPluginDeclarations(context.config)
|
|
190
|
-
: [];
|
|
191
200
|
// Root-declared plugins (companion or hub) install first and hydrate into
|
|
192
201
|
// the registry before the plan is built, so one run goes install → load →
|
|
193
|
-
// plan and their own install requirements are part of the plan.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
declarations.length
|
|
198
|
-
) {
|
|
199
|
-
let results: PluginInstallResult[];
|
|
202
|
+
// plan and their own install requirements are part of the plan. The base
|
|
203
|
+
// plugins and the selected audience's install; no other audience does.
|
|
204
|
+
if ((context.kind === "companion" || context.kind === "hub") && context.companionPath) {
|
|
205
|
+
let outcome: PluginWorkspacesOutcome;
|
|
200
206
|
try {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
outcome = await installPluginWorkspaces(context.companionPath, context.config, audience, {
|
|
208
|
+
frozen,
|
|
209
|
+
});
|
|
204
210
|
} catch (error) {
|
|
205
211
|
if (!(error instanceof FrozenInstallError)) throw error;
|
|
206
212
|
process.stderr.write(`${FRAMEWORK_NAME}: frozen plugin install refused: ${error.message}\n`);
|
|
207
213
|
process.exitCode = 1;
|
|
208
214
|
return false;
|
|
209
215
|
}
|
|
210
|
-
|
|
216
|
+
reportPluginWorkspaces(outcome);
|
|
217
|
+
if (!reportPluginInstallResults(outcome.results)) {
|
|
211
218
|
process.stderr.write(
|
|
212
219
|
`${FRAMEWORK_NAME}: a declared plugin failed to install; installation is incomplete.\n`,
|
|
213
220
|
);
|
|
214
221
|
process.exitCode = 1;
|
|
215
222
|
return false;
|
|
216
223
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
if (outcome.declared) {
|
|
225
|
+
await hydrateDynamicPlugins({ companionPath: context.companionPath });
|
|
226
|
+
if (frozen) {
|
|
227
|
+
const failures = await verifyDeclaredPlugins(context.companionPath);
|
|
228
|
+
if (failures.length > 0) {
|
|
229
|
+
for (const failure of failures) {
|
|
230
|
+
process.stderr.write(
|
|
231
|
+
`${FRAMEWORK_NAME}: plugin ${failure.package}: ${failure.reason}\n`,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
process.exitCode = 1;
|
|
235
|
+
return false;
|
|
223
236
|
}
|
|
224
|
-
process.exitCode = 1;
|
|
225
|
-
return false;
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
}
|
|
@@ -9,6 +9,8 @@ import { makeLaunchCommand } from "./shared";
|
|
|
9
9
|
* - `-- --no-git` — skip companion Git synchronization for this launch.
|
|
10
10
|
* - `-- --companion` — launch against the Companion Repository without a Working Repository.
|
|
11
11
|
* - `-- --yes` — accepted as a Mate compatibility no-op; launches are always prompt-free.
|
|
12
|
+
* - `-- --prepare-only` — prepare and index, then stop without launching Claude (Workset sessions).
|
|
13
|
+
* - `-- --prepared` — launch without progress, notices or indexing, after `--prepare-only` ran (Workset sessions).
|
|
12
14
|
* @remarks When invoked via `directPassthrough` (the top-level `mate claude`
|
|
13
15
|
* alias), all args before `--` are treated as agent args rather than being
|
|
14
16
|
* parsed as launch options.
|
|
@@ -22,18 +22,32 @@ export interface ParsedLaunchArgs {
|
|
|
22
22
|
agentArgs: string[];
|
|
23
23
|
skipGit?: boolean;
|
|
24
24
|
scope?: LaunchScope;
|
|
25
|
+
/** Only prepare and index, then stop; a Workset session runs this before it attaches. */
|
|
26
|
+
prepareOnly?: boolean;
|
|
27
|
+
/** The preparation ran already: no progress, notices or index, straight to the agent. */
|
|
28
|
+
prepared?: boolean;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
const MATE_LAUNCH_OPTIONS = new Set([
|
|
31
|
+
const MATE_LAUNCH_OPTIONS = new Set([
|
|
32
|
+
"--no-git",
|
|
33
|
+
"--companion",
|
|
34
|
+
"--yes",
|
|
35
|
+
"--prepare-only",
|
|
36
|
+
"--prepared",
|
|
37
|
+
]);
|
|
28
38
|
|
|
29
39
|
function parseMateLaunchArgs(agentArgs: string[]): ParsedLaunchArgs {
|
|
30
40
|
const skipGit = agentArgs.includes("--no-git");
|
|
31
41
|
const companion = agentArgs.includes("--companion");
|
|
42
|
+
const prepareOnly = agentArgs.includes("--prepare-only");
|
|
43
|
+
const prepared = agentArgs.includes("--prepared");
|
|
32
44
|
|
|
33
45
|
return {
|
|
34
46
|
agentArgs: agentArgs.filter((arg) => !MATE_LAUNCH_OPTIONS.has(arg)),
|
|
35
47
|
...(skipGit ? { skipGit: true } : {}),
|
|
36
48
|
...(companion ? { scope: "companion" as const } : {}),
|
|
49
|
+
...(prepareOnly ? { prepareOnly: true } : {}),
|
|
50
|
+
...(prepared ? { prepared: true } : {}),
|
|
37
51
|
};
|
|
38
52
|
}
|
|
39
53
|
|
|
@@ -93,12 +107,15 @@ export async function runLaunchToolCommand(
|
|
|
93
107
|
options: {
|
|
94
108
|
skipGit?: boolean;
|
|
95
109
|
scope?: LaunchScope;
|
|
110
|
+
prepareOnly?: boolean;
|
|
111
|
+
prepared?: boolean;
|
|
96
112
|
} = {},
|
|
97
113
|
): Promise<void> {
|
|
98
114
|
const interactiveGit = !!(process.stdin.isTTY && process.stdout.isTTY);
|
|
99
|
-
const progress =
|
|
100
|
-
|
|
101
|
-
|
|
115
|
+
const progress =
|
|
116
|
+
interactiveGit && !options.prepared
|
|
117
|
+
? launchCommandDeps.createProgress(`Starting ${tool}`)
|
|
118
|
+
: undefined;
|
|
102
119
|
|
|
103
120
|
try {
|
|
104
121
|
// Git may ask for credentials and graphify/tokensave write straight to the
|
|
@@ -107,13 +124,15 @@ export async function runLaunchToolCommand(
|
|
|
107
124
|
const prepared = await launchCommandDeps.createLauncher().prepare({
|
|
108
125
|
tool,
|
|
109
126
|
args,
|
|
110
|
-
|
|
127
|
+
// The `--prepare-only` run before it synced already.
|
|
128
|
+
skipGit: options.skipGit || options.prepared,
|
|
111
129
|
scope: options.scope,
|
|
112
130
|
interactiveGit,
|
|
131
|
+
...(options.prepared ? { quiet: true } : {}),
|
|
113
132
|
});
|
|
114
133
|
progress?.succeed("sync");
|
|
115
134
|
|
|
116
|
-
if (options.scope !== "companion") {
|
|
135
|
+
if (options.scope !== "companion" && !options.prepared) {
|
|
117
136
|
const indexSteps: SyncCapDeps = progress
|
|
118
137
|
? {
|
|
119
138
|
onStepStart: (step) => progress.handOver(step, STEP_LABELS[step]),
|
|
@@ -128,6 +147,12 @@ export async function runLaunchToolCommand(
|
|
|
128
147
|
}
|
|
129
148
|
progress?.stop();
|
|
130
149
|
|
|
150
|
+
if (options.prepareOnly) {
|
|
151
|
+
// As at an ordinary launch, an index that fails never keeps the agent from starting.
|
|
152
|
+
process.exitCode = 0;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
131
156
|
const result = await prepared.execute();
|
|
132
157
|
/**
|
|
133
158
|
* The printed result stays useful, but the status is what a supervisor
|
|
@@ -190,6 +215,8 @@ export function makeLaunchCommand(tool: LaunchTarget) {
|
|
|
190
215
|
await runLaunchToolCommand(tool, parsed.agentArgs, {
|
|
191
216
|
skipGit: parsed.skipGit,
|
|
192
217
|
scope: parsed.scope,
|
|
218
|
+
prepareOnly: parsed.prepareOnly,
|
|
219
|
+
prepared: parsed.prepared,
|
|
193
220
|
});
|
|
194
221
|
};
|
|
195
222
|
}
|