@uniqbit/mate-core 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +305 -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.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
|
@@ -117,6 +117,8 @@ async function runUpdate(
|
|
|
117
117
|
process.exitCode = 1;
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
+
// Saved even when not newer, so a wrong cached version is replaced; a failed write changes nothing.
|
|
121
|
+
await updateCommandDeps.saveUpdateState(latest).catch(() => {});
|
|
120
122
|
// The version lines and the confirm prompt below own the terminal.
|
|
121
123
|
releaseTerminal();
|
|
122
124
|
|
|
@@ -3,6 +3,7 @@ import { spawnSync } from "node:child_process";
|
|
|
3
3
|
import { version as coreVersion } from "../../../../package.json";
|
|
4
4
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
5
5
|
import { resolveEditorBinary } from "../../../lib/orchestrator/editor";
|
|
6
|
+
import releaseVsix from "./release-vsix.json";
|
|
6
7
|
import { resolveVsix, VsixError, vsixResolverDeps, type VsixResolverDeps } from "./vsix";
|
|
7
8
|
|
|
8
9
|
const EDITORS = ["code", "cursor"] as const;
|
|
@@ -46,14 +47,32 @@ function parseVscodeSetupArgs(argv: string[]): VscodeSetupArgs | { error: string
|
|
|
46
47
|
return args;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/** One `--list-extensions --show-versions` entry; `version` is absent when the line has none. */
|
|
51
|
+
export interface InstalledExtension {
|
|
52
|
+
id: string;
|
|
53
|
+
version?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Splits `publisher.name@1.2.3` on the last `@`. */
|
|
57
|
+
function parseExtensionLine(line: string): InstalledExtension {
|
|
58
|
+
const at = line.lastIndexOf("@");
|
|
59
|
+
return at > 0 ? { id: line.slice(0, at), version: line.slice(at + 1) } : { id: line };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function findMate(extensions: InstalledExtension[] | null): InstalledExtension | undefined {
|
|
63
|
+
return extensions?.find(({ id }) => id.toLowerCase() === EXTENSION_ID);
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
export interface VscodeSetupDeps {
|
|
50
67
|
resolveEditor: (cli: Editor) => string | null;
|
|
51
68
|
/** Runs `<binary> --install-extension <vsix> --force`; returns the exit status and output. */
|
|
52
69
|
install: (binary: string, vsix: string) => { ok: boolean; output: string };
|
|
53
|
-
/** `<binary> --list-extensions`; null when it cannot be listed. */
|
|
54
|
-
installedExtensions: (binary: string) =>
|
|
70
|
+
/** `<binary> --list-extensions --show-versions`; null when it cannot be listed. */
|
|
71
|
+
installedExtensions: (binary: string) => InstalledExtension[] | null;
|
|
55
72
|
vsix: VsixResolverDeps;
|
|
56
73
|
version: string;
|
|
74
|
+
/** Written at release preparation; applies only when it names `version`. */
|
|
75
|
+
releaseVsix: { version: string | null; sha512: string | null };
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
export const vscodeSetupDeps: VscodeSetupDeps = {
|
|
@@ -66,11 +85,20 @@ export const vscodeSetupDeps: VscodeSetupDeps = {
|
|
|
66
85
|
return { ok: result.status === 0, output: output.trim() };
|
|
67
86
|
},
|
|
68
87
|
installedExtensions: (binary) => {
|
|
69
|
-
const result = spawnSync(binary, ["--list-extensions"
|
|
70
|
-
|
|
88
|
+
const result = spawnSync(binary, ["--list-extensions", "--show-versions"], {
|
|
89
|
+
encoding: "utf8",
|
|
90
|
+
timeout: 30_000,
|
|
91
|
+
});
|
|
92
|
+
if (result.status !== 0) return null;
|
|
93
|
+
return result.stdout
|
|
94
|
+
.split("\n")
|
|
95
|
+
.map((line) => line.trim())
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.map(parseExtensionLine);
|
|
71
98
|
},
|
|
72
99
|
vsix: vsixResolverDeps,
|
|
73
100
|
version: coreVersion,
|
|
101
|
+
releaseVsix,
|
|
74
102
|
};
|
|
75
103
|
|
|
76
104
|
function fail(message: string, usage = false): void {
|
|
@@ -99,9 +127,7 @@ export async function runVscodeSetupCommand(
|
|
|
99
127
|
(entry): entry is { editor: Editor; binary: string } => entry.binary !== null,
|
|
100
128
|
);
|
|
101
129
|
if (parsed.ifInstalled) {
|
|
102
|
-
const editors = found.filter(({ binary }) =>
|
|
103
|
-
deps.installedExtensions(binary)?.some((id) => id.toLowerCase() === EXTENSION_ID),
|
|
104
|
-
);
|
|
130
|
+
const editors = found.filter(({ binary }) => findMate(deps.installedExtensions(binary)));
|
|
105
131
|
if (editors.length === 0) return;
|
|
106
132
|
return installInto(editors, parsed.vsix, deps);
|
|
107
133
|
}
|
|
@@ -124,28 +150,60 @@ async function installInto(
|
|
|
124
150
|
vsixArg: string | undefined,
|
|
125
151
|
deps: VscodeSetupDeps,
|
|
126
152
|
): Promise<void> {
|
|
153
|
+
const expectedDigest = deps.releaseVsix.version === deps.version ? deps.releaseVsix.sha512 : null;
|
|
127
154
|
let vsix: string;
|
|
128
155
|
try {
|
|
129
|
-
vsix = await resolveVsix({ vsix: vsixArg, version: deps.version }, deps.vsix);
|
|
156
|
+
vsix = await resolveVsix({ vsix: vsixArg, version: deps.version, expectedDigest }, deps.vsix);
|
|
157
|
+
if (!expectedDigest && !vsixArg) {
|
|
158
|
+
console.error(
|
|
159
|
+
`VSIX not verified: this Mate build has no release digest for ${deps.version}.`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
130
162
|
} catch (error) {
|
|
131
163
|
if (error instanceof VsixError) return fail(error.message);
|
|
132
164
|
throw error;
|
|
133
165
|
}
|
|
134
166
|
|
|
135
|
-
|
|
167
|
+
const installed: Array<{ name: string; version: string }> = [];
|
|
168
|
+
// A failure before any success announces the next success, so all failing prints no "Continuing".
|
|
169
|
+
let continuePending = false;
|
|
136
170
|
for (const { editor, binary } of editors) {
|
|
171
|
+
const name = EDITOR_NAMES[editor];
|
|
137
172
|
const result = deps.install(binary, vsix);
|
|
138
173
|
if (result.ok) {
|
|
139
|
-
|
|
140
|
-
|
|
174
|
+
const version = findMate(deps.installedExtensions(binary))?.version ?? deps.version;
|
|
175
|
+
if (continuePending) {
|
|
176
|
+
console.log(` Continuing with ${name}.`);
|
|
177
|
+
continuePending = false;
|
|
178
|
+
}
|
|
179
|
+
installed.push({ name, version });
|
|
180
|
+
console.log(` ${name}: installed v${version}`);
|
|
141
181
|
} else {
|
|
142
|
-
console.log(` ${
|
|
182
|
+
console.log(` ${name}: failed${result.output ? ` — ${result.output}` : ""}`);
|
|
183
|
+
if (installed.length > 0) {
|
|
184
|
+
console.log(` Continuing with ${joinNames(installed.map((entry) => entry.name))}.`);
|
|
185
|
+
} else {
|
|
186
|
+
continuePending = true;
|
|
187
|
+
}
|
|
143
188
|
}
|
|
144
189
|
}
|
|
145
|
-
if (installed === 0) return fail("the extension could not be installed into any editor");
|
|
190
|
+
if (installed.length === 0) return fail("the extension could not be installed into any editor");
|
|
191
|
+
console.log(closingLine(installed));
|
|
146
192
|
console.log("Reload open editor windows to load the Mate sidebar.");
|
|
147
193
|
}
|
|
148
194
|
|
|
195
|
+
function joinNames(names: string[]): string {
|
|
196
|
+
return names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function closingLine(installed: Array<{ name: string; version: string }>): string {
|
|
200
|
+
const versions = new Set(installed.map((entry) => entry.version));
|
|
201
|
+
if (versions.size === 1) {
|
|
202
|
+
return `Mate extension v${installed[0]!.version} installed in ${joinNames(installed.map((entry) => entry.name))}.`;
|
|
203
|
+
}
|
|
204
|
+
return `Mate extension installed in ${joinNames(installed.map((entry) => `${entry.name} (v${entry.version})`))}.`;
|
|
205
|
+
}
|
|
206
|
+
|
|
149
207
|
export async function runVscodeCommand(subcommand: string | undefined, rest: string[]) {
|
|
150
208
|
if (subcommand === "setup") {
|
|
151
209
|
await runVscodeSetupCommand(rest);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { execFile as execFileCb } from "node:child_process";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { promisify } from "node:util";
|
|
5
6
|
|
|
6
7
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
7
8
|
import { packPublicPackage } from "../../../lib/public-npm";
|
|
9
|
+
import { getUpdateConfig } from "../../../lib/update-checker";
|
|
8
10
|
import { mateHome } from "../../../runtime/runtime-directory";
|
|
9
11
|
|
|
10
12
|
const VSCODE_PACKAGE = "@uniqbit/mate-vscode";
|
|
@@ -34,19 +36,36 @@ export const vsixResolverDeps: VsixResolverDeps = {
|
|
|
34
36
|
(stat) => stat.isFile(),
|
|
35
37
|
() => false,
|
|
36
38
|
),
|
|
37
|
-
pack: (spec, destination) => packPublicPackage(spec, destination),
|
|
39
|
+
pack: (spec, destination) => packPublicPackage(spec, destination, getUpdateConfig().registry),
|
|
38
40
|
extract: extractVsix,
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
function vsixCacheDir(version: string, homeDir?: string): string {
|
|
42
|
-
|
|
44
|
+
// `v2`: copies cached before the download ignored repository npm config are not reused.
|
|
45
|
+
return path.join(mateHome(homeDir), "cache", "vscode", "v2", version);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export class VsixError extends Error {}
|
|
46
49
|
|
|
47
|
-
/**
|
|
50
|
+
/** SRI form; must match `digestOf` in `apps/mate-vscode/scripts/release-vsix.ts`. */
|
|
51
|
+
async function vsixDigest(file: string): Promise<string> {
|
|
52
|
+
return `sha512-${createHash("sha512")
|
|
53
|
+
.update(await fs.readFile(file))
|
|
54
|
+
.digest("base64")}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `--vsix` wins, unchecked; otherwise the cached copy for `version`; otherwise download it from the
|
|
59
|
+
* update registry. With `expectedDigest`, a cached or downloaded VSIX that differs is deleted and refused.
|
|
60
|
+
*/
|
|
48
61
|
export async function resolveVsix(
|
|
49
|
-
options: {
|
|
62
|
+
options: {
|
|
63
|
+
vsix?: string;
|
|
64
|
+
version: string;
|
|
65
|
+
expectedDigest?: string | null;
|
|
66
|
+
cacheDir?: string;
|
|
67
|
+
cwd?: string;
|
|
68
|
+
},
|
|
50
69
|
deps: VsixResolverDeps = vsixResolverDeps,
|
|
51
70
|
): Promise<string> {
|
|
52
71
|
if (options.vsix) {
|
|
@@ -54,20 +73,42 @@ export async function resolveVsix(
|
|
|
54
73
|
if (!(await deps.exists(file))) throw new VsixError(`VSIX not found: ${file}`);
|
|
55
74
|
return file;
|
|
56
75
|
}
|
|
76
|
+
const expected = options.expectedDigest;
|
|
57
77
|
const cacheDir = options.cacheDir ?? vsixCacheDir(options.version);
|
|
58
78
|
const cached = path.join(cacheDir, VSIX_FILE);
|
|
59
|
-
if (await deps.exists(cached)) return cached;
|
|
60
|
-
|
|
61
79
|
const spec = `${VSCODE_PACKAGE}@${options.version}`;
|
|
80
|
+
if (await deps.exists(cached)) {
|
|
81
|
+
if (!expected || (await vsixDigest(cached)) === expected) return cached;
|
|
82
|
+
await fs.rm(cached, { force: true });
|
|
83
|
+
throw new VsixError(
|
|
84
|
+
`the cached VSIX for ${spec} does not match the digest shipped with Mate ${options.version} and was removed. ` +
|
|
85
|
+
`Nothing was installed. Run \`${FRAMEWORK_NAME} vscode setup\` again to download a fresh copy.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Checked under a temporary name, so a differing download never becomes the cached copy.
|
|
90
|
+
const pending = path.join(cacheDir, `.${VSIX_FILE}.${randomUUID()}`);
|
|
62
91
|
try {
|
|
63
92
|
await fs.mkdir(cacheDir, { recursive: true });
|
|
64
93
|
const tarball = await deps.pack(spec, cacheDir);
|
|
65
|
-
await deps.extract(tarball,
|
|
94
|
+
await deps.extract(tarball, pending);
|
|
66
95
|
} catch (error) {
|
|
96
|
+
await fs.rm(pending, { force: true });
|
|
67
97
|
throw new VsixError(
|
|
68
98
|
`could not download ${spec}: ${(error as Error).message.trim()}\n` +
|
|
69
99
|
`Install a local build instead with \`${FRAMEWORK_NAME} vscode setup --vsix <path>\`.`,
|
|
70
100
|
);
|
|
71
101
|
}
|
|
102
|
+
if (expected) {
|
|
103
|
+
const actual = await vsixDigest(pending);
|
|
104
|
+
if (actual !== expected) {
|
|
105
|
+
await fs.rm(pending, { force: true });
|
|
106
|
+
throw new VsixError(
|
|
107
|
+
`${spec} does not match the VSIX digest shipped with Mate ${options.version} (expected ${expected}, got ${actual}). ` +
|
|
108
|
+
`Nothing was installed. Check the npm registry configured for @uniqbit, then run \`${FRAMEWORK_NAME} vscode setup\` again.`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await fs.rename(pending, cached);
|
|
72
113
|
return cached;
|
|
73
114
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type WorkspaceInventoryPairingEntry,
|
|
15
15
|
type WorkspaceInventoryV1,
|
|
16
16
|
} from "../../../lib/orchestrator/workspace-inventory";
|
|
17
|
+
import { umbrellaFolderOf, umbrellaMirroredBy } from "../../../lib/orchestrator/umbrella-checkouts";
|
|
17
18
|
import {
|
|
18
19
|
cleanupWorkingRepository,
|
|
19
20
|
type WorkingRepoCleanupResult,
|
|
@@ -32,6 +33,8 @@ async function canonicalPath(candidatePath: string): Promise<string> {
|
|
|
32
33
|
export interface WorkingCleanupCommandDeps {
|
|
33
34
|
cwd: string;
|
|
34
35
|
resolveGitRoot: (cwd: string) => Promise<string | null>;
|
|
36
|
+
/** Outside Git: the linked Umbrella Repository or mirrored umbrella worktree holding `cwd`. */
|
|
37
|
+
resolveUmbrella: (cwd: string) => Promise<string | null>;
|
|
35
38
|
localRootKind: (repoPath: string) => Promise<RootKind | null>;
|
|
36
39
|
collectInventory: () => Promise<WorkspaceInventoryV1>;
|
|
37
40
|
cleanup: (
|
|
@@ -51,6 +54,12 @@ async function resolveGitRoot(cwd: string): Promise<string | null> {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
/** Default `resolveUmbrella`: from files alone, canonical like the Git root. */
|
|
58
|
+
export async function resolveUmbrella(cwd: string): Promise<string | null> {
|
|
59
|
+
const folder = umbrellaFolderOf(await canonicalPath(cwd));
|
|
60
|
+
return folder ? canonicalPath(folder) : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
async function localRootKind(repoPath: string): Promise<RootKind | null> {
|
|
55
64
|
try {
|
|
56
65
|
const raw = await fs.readFile(
|
|
@@ -69,6 +78,7 @@ async function localRootKind(repoPath: string): Promise<RootKind | null> {
|
|
|
69
78
|
const defaultDeps: WorkingCleanupCommandDeps = {
|
|
70
79
|
cwd: process.cwd(),
|
|
71
80
|
resolveGitRoot,
|
|
81
|
+
resolveUmbrella,
|
|
72
82
|
localRootKind,
|
|
73
83
|
collectInventory: collectWorkspaceInventory,
|
|
74
84
|
cleanup: cleanupWorkingRepository,
|
|
@@ -100,6 +110,26 @@ async function pairingsOf(
|
|
|
100
110
|
return { matches: ofClone.map(({ pairing }) => pairing), byClone: true };
|
|
101
111
|
}
|
|
102
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The pairings of an umbrella folder: the umbrella's own, which a mirrored worktree
|
|
115
|
+
* `<umbrella>.worktrees/<id>` shares, since the registry never lists that folder.
|
|
116
|
+
*/
|
|
117
|
+
async function umbrellaPairingsOf(
|
|
118
|
+
folder: string,
|
|
119
|
+
pairings: WorkspaceInventoryPairingEntry[],
|
|
120
|
+
): Promise<WorkspaceInventoryPairingEntry[]> {
|
|
121
|
+
const mirrored = umbrellaMirroredBy(folder);
|
|
122
|
+
const served = new Set([folder, ...(mirrored ? [await canonicalPath(mirrored)] : [])]);
|
|
123
|
+
const resolved = await Promise.all(
|
|
124
|
+
pairings.map(async (pairing) =>
|
|
125
|
+
served.has(await canonicalPath(pairing.repository.path)) ? pairing : null,
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
return resolved.filter((pairing): pairing is WorkspaceInventoryPairingEntry => pairing !== null);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const NOT_LINKED = `${FRAMEWORK_NAME}: working cleanup must run from a linked Git working repository or Umbrella Repository\n`;
|
|
132
|
+
|
|
103
133
|
export async function runWorkingCleanupCommand(
|
|
104
134
|
argv: string[],
|
|
105
135
|
deps: WorkingCleanupCommandDeps = defaultDeps,
|
|
@@ -109,11 +139,12 @@ export async function runWorkingCleanupCommand(
|
|
|
109
139
|
process.exitCode = 1;
|
|
110
140
|
return;
|
|
111
141
|
}
|
|
112
|
-
const
|
|
142
|
+
const gitRoot = await deps.resolveGitRoot(deps.cwd);
|
|
143
|
+
// Its children are Checkouts of their own; only the folder's integration is removed.
|
|
144
|
+
const umbrella = gitRoot ? null : await deps.resolveUmbrella(deps.cwd);
|
|
145
|
+
const repoPath = gitRoot ?? umbrella;
|
|
113
146
|
if (!repoPath) {
|
|
114
|
-
process.stderr.write(
|
|
115
|
-
`${FRAMEWORK_NAME}: working cleanup must run from a linked Git working repository\n`,
|
|
116
|
-
);
|
|
147
|
+
process.stderr.write(NOT_LINKED);
|
|
117
148
|
process.exitCode = 1;
|
|
118
149
|
return;
|
|
119
150
|
}
|
|
@@ -125,11 +156,12 @@ export async function runWorkingCleanupCommand(
|
|
|
125
156
|
process.exitCode = 1;
|
|
126
157
|
return;
|
|
127
158
|
}
|
|
128
|
-
const {
|
|
159
|
+
const { pairings } = await deps.collectInventory();
|
|
160
|
+
const { matches, byClone } = umbrella
|
|
161
|
+
? { matches: await umbrellaPairingsOf(umbrella, pairings), byClone: false }
|
|
162
|
+
: await pairingsOf(repoPath, pairings);
|
|
129
163
|
if (matches.length === 0) {
|
|
130
|
-
process.stderr.write(
|
|
131
|
-
`${FRAMEWORK_NAME}: working cleanup must run from a linked Git working repository\n`,
|
|
132
|
-
);
|
|
164
|
+
process.stderr.write(NOT_LINKED);
|
|
133
165
|
process.exitCode = 1;
|
|
134
166
|
return;
|
|
135
167
|
}
|