@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
|
@@ -3,7 +3,8 @@ import { promisify } from "node:util";
|
|
|
3
3
|
|
|
4
4
|
import { readCompanionConfig } from "../orchestrator/config-store";
|
|
5
5
|
import type { CapabilityConfig, TicketFormat } from "../orchestrator/types";
|
|
6
|
-
import {
|
|
6
|
+
import { parseBranchTemplate, type BranchTemplateSetting } from "./branch-template";
|
|
7
|
+
import { deliveryCheckout } from "./checkout";
|
|
7
8
|
|
|
8
9
|
export type { TicketFormat };
|
|
9
10
|
|
|
@@ -80,6 +81,22 @@ export async function companionTicketFormat(companionPath: string): Promise<Tick
|
|
|
80
81
|
return configuredTicketFormat(config.capabilities ?? []).format;
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/** The openspec capability's `branchTemplate`; absent or invalid means the default. */
|
|
85
|
+
export function configuredBranchTemplate(
|
|
86
|
+
capabilities: readonly CapabilityConfig[],
|
|
87
|
+
): BranchTemplateSetting {
|
|
88
|
+
const openspec = capabilities.find((capability) => capability.name === "openspec");
|
|
89
|
+
return parseBranchTemplate(openspec?.branchTemplate);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The Delivery Branch template in a companion's `framework.yaml`, with its diagnostic. */
|
|
93
|
+
export async function companionBranchTemplate(
|
|
94
|
+
companionPath: string,
|
|
95
|
+
): Promise<BranchTemplateSetting> {
|
|
96
|
+
const config = await readCompanionConfig(companionPath);
|
|
97
|
+
return configuredBranchTemplate(config.capabilities ?? []);
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
/** Read-only local Git queries against a Working Repository. Nothing here touches the network. */
|
|
84
101
|
export interface WorkingRepoGit {
|
|
85
102
|
/** Checked-out branch, or null in a detached HEAD. */
|
|
@@ -108,20 +125,8 @@ export function workingRepoGit(repoPath: string): WorkingRepoGit {
|
|
|
108
125
|
}
|
|
109
126
|
};
|
|
110
127
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const defaultBranch = async (): Promise<string> => {
|
|
114
|
-
const remoteHead = await run("symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD");
|
|
115
|
-
if (remoteHead) return remoteHead.replace(/^origin\//, "");
|
|
116
|
-
for (const candidate of ["main", "master"]) {
|
|
117
|
-
// oxlint-disable-next-line no-await-in-loop -- the steps are a decision chain
|
|
118
|
-
if (await remoteTip(candidate)) return candidate;
|
|
119
|
-
}
|
|
120
|
-
return (await run("config", "--get", "init.defaultBranch")) || "main";
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const hasRef = async (ref: string): Promise<boolean> =>
|
|
124
|
-
(await run("rev-parse", "--verify", "--quiet", ref)) !== null;
|
|
128
|
+
// Ref queries are the ones a Delivery Branch resolves through.
|
|
129
|
+
const { hasRef, listRefs, defaultBranch } = deliveryCheckout(repoPath);
|
|
125
130
|
|
|
126
131
|
const currentBranch = async (): Promise<string | null> =>
|
|
127
132
|
(await run("symbolic-ref", "--quiet", "--short", "HEAD")) || null;
|
|
@@ -142,6 +147,6 @@ export function workingRepoGit(repoPath: string): WorkingRepoGit {
|
|
|
142
147
|
);
|
|
143
148
|
},
|
|
144
149
|
hasRef,
|
|
145
|
-
listRefs
|
|
150
|
+
listRefs,
|
|
146
151
|
};
|
|
147
152
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
localGitEnv,
|
|
3
|
+
mergeGit,
|
|
4
|
+
spawnProcess,
|
|
5
|
+
type MergeGit,
|
|
6
|
+
type ProcessResult,
|
|
7
|
+
} from "./merge-git";
|
|
8
|
+
import { localMergeEvidence } from "./refresh";
|
|
9
|
+
|
|
10
|
+
/** True when the ref resolves in the checkout. */
|
|
11
|
+
export type HasRef = (ref: string) => Promise<boolean>;
|
|
12
|
+
|
|
13
|
+
/** Full names of the refs under the given prefixes, e.g. `refs/heads/workset/`. */
|
|
14
|
+
export type ListRefs = (prefixes: string[]) => Promise<string[]>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A local merge check, without fetch or forge: a merge commit settles `merged`, commits
|
|
18
|
+
* matched on the default branch read as `squashed`. A head on the default branch's own line
|
|
19
|
+
* is `open`: it may be a fast-forward, but then its commits are already there and continuing
|
|
20
|
+
* on it is safe.
|
|
21
|
+
*/
|
|
22
|
+
export type MergeProbeResult = "merged" | "squashed" | "open";
|
|
23
|
+
|
|
24
|
+
/** The local Git a Delivery Branch resolves in: refs, the default branch, and merge checks. */
|
|
25
|
+
export interface DeliveryCheckout {
|
|
26
|
+
hasRef: HasRef;
|
|
27
|
+
listRefs: ListRefs;
|
|
28
|
+
/** `origin/HEAD`, then an existing `origin/main` or `origin/master`, then `init.defaultBranch`, then `main`. */
|
|
29
|
+
defaultBranch(): Promise<string>;
|
|
30
|
+
/** Null when the checkout cannot check merges; the branch then counts as never checked. */
|
|
31
|
+
mergeProbe(branch: string, recordedHead: string | undefined): Promise<MergeProbeResult | null>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Runs `git` in the checkout. `env` is the environment local queries need; a runner with
|
|
36
|
+
* its own Git policy (another user, extra `-c` settings) may keep its own instead.
|
|
37
|
+
*/
|
|
38
|
+
export type CheckoutRunner = (
|
|
39
|
+
args: readonly string[],
|
|
40
|
+
options: { env: NodeJS.ProcessEnv; input?: string; timeoutMs?: number },
|
|
41
|
+
) => Promise<ProcessResult>;
|
|
42
|
+
|
|
43
|
+
/** A {@link ListRefs} over a Git runner that answers stdout, or null on failure. */
|
|
44
|
+
function listRefsWith(git: (args: string[]) => Promise<string | null>): ListRefs {
|
|
45
|
+
return async (prefixes) => {
|
|
46
|
+
const stdout = await git(["for-each-ref", "--format=%(refname)", ...prefixes]);
|
|
47
|
+
return stdout ? stdout.split("\n").filter(Boolean) : [];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The default branch over a Git runner that answers trimmed stdout, or null on failure. */
|
|
52
|
+
async function defaultBranchWith(
|
|
53
|
+
run: (...args: string[]) => Promise<string | null>,
|
|
54
|
+
): Promise<string> {
|
|
55
|
+
const remoteHead = await run("symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD");
|
|
56
|
+
if (remoteHead) return remoteHead.replace(/^origin\//, "");
|
|
57
|
+
for (const candidate of ["main", "master"]) {
|
|
58
|
+
// oxlint-disable-next-line no-await-in-loop -- the steps are a decision chain
|
|
59
|
+
if (await run("rev-parse", "--verify", "--quiet", `refs/remotes/origin/${candidate}`)) {
|
|
60
|
+
return candidate;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return (await run("config", "--get", "init.defaultBranch")) || "main";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The merge check over local merge queries; see {@link MergeProbeResult}. */
|
|
67
|
+
export async function probeMerge(
|
|
68
|
+
git: MergeGit,
|
|
69
|
+
defaultBranch: string,
|
|
70
|
+
branch: string,
|
|
71
|
+
recordedHead: string | undefined,
|
|
72
|
+
): Promise<MergeProbeResult> {
|
|
73
|
+
const evidence = await localMergeEvidence(git, defaultBranch, branch, recordedHead);
|
|
74
|
+
if (evidence.merged) return "merged";
|
|
75
|
+
const style = evidence.suggestion?.style;
|
|
76
|
+
return style === "squash" || style === "rebase" ? "squashed" : "open";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The checkout at `path`, every query through one runner, so a caller's Git policy reaches
|
|
81
|
+
* ref lookups and merge checks alike. Without `run`, `git` is spawned in `path`.
|
|
82
|
+
*/
|
|
83
|
+
export function deliveryCheckout(path: string, run?: CheckoutRunner): DeliveryCheckout {
|
|
84
|
+
const git: CheckoutRunner =
|
|
85
|
+
run ?? ((args, options) => spawnProcess("git", args, { cwd: path, ...options }));
|
|
86
|
+
const env = localGitEnv();
|
|
87
|
+
const stdout = async (...args: string[]): Promise<string | null> => {
|
|
88
|
+
const result = await git(args, { env });
|
|
89
|
+
return result.code === 0 ? result.stdout.trim() || null : null;
|
|
90
|
+
};
|
|
91
|
+
let defaultBranch: Promise<string> | undefined;
|
|
92
|
+
const merges = mergeGit(path, { spawn: (_command, args, options) => git(args, options) });
|
|
93
|
+
const checkout: DeliveryCheckout = {
|
|
94
|
+
hasRef: async (ref) =>
|
|
95
|
+
(await git(["rev-parse", "--verify", "--quiet", ref], { env })).code === 0,
|
|
96
|
+
listRefs: listRefsWith((args) => stdout(...args)),
|
|
97
|
+
defaultBranch: () => (defaultBranch ??= defaultBranchWith(stdout)),
|
|
98
|
+
mergeProbe: async (branch, recordedHead) =>
|
|
99
|
+
probeMerge(merges, await checkout.defaultBranch(), branch, recordedHead),
|
|
100
|
+
};
|
|
101
|
+
return checkout;
|
|
102
|
+
}
|
|
@@ -9,6 +9,8 @@ export interface WorkingRepoInfo {
|
|
|
9
9
|
slug: string | null;
|
|
10
10
|
forgeRepo: ForgeRepo | null;
|
|
11
11
|
git: WorkingRepoGit;
|
|
12
|
+
/** Set when the Working Repository is an Umbrella Repository: its children's repository paths. */
|
|
13
|
+
umbrellaChildren?: string[];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/** The companion, the Working Repository with its remote identity, and protected-branch patterns. */
|
|
@@ -117,10 +117,22 @@ function patchIds(output: string): Array<[string, string]> {
|
|
|
117
117
|
.filter((parts): parts is [string, string] => parts.length === 2 && parts[0] !== "");
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
function promptlessEnv(base: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
|
121
|
+
return { ...withoutAskPass(base), GIT_TERMINAL_PROMPT: "0" };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Environment for local Git queries: never prompts, never fetches lazily. */
|
|
125
|
+
export function localGitEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
|
126
|
+
return {
|
|
127
|
+
...promptlessEnv(gitEnvironment(env) as NodeJS.ProcessEnv),
|
|
128
|
+
GIT_NO_LAZY_FETCH: "1",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
120
132
|
export function mergeGit(repoPath: string, deps: MergeGitDeps = {}): MergeGit {
|
|
121
133
|
const spawnFn = deps.spawn ?? spawnProcess;
|
|
122
134
|
const base = gitEnvironment(deps.env ?? process.env) as NodeJS.ProcessEnv;
|
|
123
|
-
const promptless
|
|
135
|
+
const promptless = promptlessEnv(base);
|
|
124
136
|
const localEnv: NodeJS.ProcessEnv = { ...promptless, GIT_NO_LAZY_FETCH: "1" };
|
|
125
137
|
|
|
126
138
|
const git = (args: readonly string[], input?: string) =>
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type WorkingRepoGit,
|
|
6
6
|
} from "./branches";
|
|
7
7
|
import { changeNameOf, locateChange, type ChangeLocation } from "../change-layout";
|
|
8
|
+
import { scopedRepositories } from "../openspec-scopes";
|
|
8
9
|
import { companionRelative, type DeliveryEnvironment } from "./environment";
|
|
9
10
|
import {
|
|
10
11
|
canaryTicketOf,
|
|
@@ -26,12 +27,8 @@ import {
|
|
|
26
27
|
type RefreshAccess,
|
|
27
28
|
type RefreshCache,
|
|
28
29
|
} from "./refresh";
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
resolveDeliveryBranch,
|
|
32
|
-
type HasRef,
|
|
33
|
-
type ListRefs,
|
|
34
|
-
} from "./resolve-branch";
|
|
30
|
+
import { probeMerge, type DeliveryCheckout } from "./checkout";
|
|
31
|
+
import { resolveDeliveryBranch } from "./resolve-branch";
|
|
35
32
|
import {
|
|
36
33
|
repositoryAccessFor,
|
|
37
34
|
type RepositoryAccess,
|
|
@@ -46,8 +43,9 @@ export interface DeliveryEdit {
|
|
|
46
43
|
/** The user's answer, recorded after any refresh with source `user`. */
|
|
47
44
|
confirm?: MergeState;
|
|
48
45
|
/**
|
|
49
|
-
* Records the Delivery Branch resolved with this Jira key, which names a new branch
|
|
50
|
-
* `workset/<TICKET>-<id
|
|
46
|
+
* Records the Delivery Branch resolved with this Jira key, which names a new branch by the
|
|
47
|
+
* template (default `workset/<TICKET>-<id>`); the key itself is not stored. Refused while
|
|
48
|
+
* tickets are off.
|
|
51
49
|
*/
|
|
52
50
|
ticket?: string;
|
|
53
51
|
}
|
|
@@ -78,6 +76,8 @@ export interface DeliveryRequest {
|
|
|
78
76
|
export type DeliveryRefusal =
|
|
79
77
|
| { reason: "unknown-change"; change: string }
|
|
80
78
|
| { reason: "no-repository" }
|
|
79
|
+
/** An edit in an Umbrella Repository whose changes are scoped to not exactly one child. */
|
|
80
|
+
| { reason: "umbrella-repository"; umbrella: string; scoped: string[]; children: string[] }
|
|
81
81
|
| { reason: "tickets-off" }
|
|
82
82
|
| { reason: "no-resolved-branch"; change: string; diagnostics: string[] }
|
|
83
83
|
/** `--ticket` on a repository whose delivery is direct or not applicable. */
|
|
@@ -117,7 +117,7 @@ export interface NeedsBranch {
|
|
|
117
117
|
diagnostics: string[];
|
|
118
118
|
change: string;
|
|
119
119
|
record: DeliveryRecord;
|
|
120
|
-
/** First existing safe default or legacy branch in the
|
|
120
|
+
/** First existing safe default or legacy branch in the session's checkout of the repository. */
|
|
121
121
|
suggestedBranch: string | null;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -143,14 +143,55 @@ async function checkoutGit(
|
|
|
143
143
|
return checkout ? workingRepoGit(checkout) : null;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
/**
|
|
147
|
-
async function
|
|
146
|
+
/** The Umbrella Repository's children the changes are scoped to, in scope order. */
|
|
147
|
+
async function scopedChildren(
|
|
148
|
+
located: readonly { dir: string }[],
|
|
149
|
+
children: readonly string[],
|
|
150
|
+
): Promise<string[]> {
|
|
151
|
+
const scoped: string[] = [];
|
|
152
|
+
for (const { dir } of located) {
|
|
153
|
+
// oxlint-disable-next-line no-await-in-loop -- a few small files, in order
|
|
154
|
+
for (const repository of await scopedRepositories(dir)) {
|
|
155
|
+
const child = children.find((entry) => sameRepository(entry, repository));
|
|
156
|
+
if (child && !scoped.includes(child)) scoped.push(child);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return scoped;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The Git whose branches the session works on: the Working Repository's, or in an Umbrella
|
|
164
|
+
* Repository, which is no checkout, the delivery's child checkout.
|
|
165
|
+
*/
|
|
166
|
+
async function sessionGitOf(
|
|
167
|
+
environment: DeliveryEnvironment,
|
|
168
|
+
repository: string | null,
|
|
169
|
+
): Promise<WorkingRepoGit | null> {
|
|
170
|
+
const working = environment.workingRepo;
|
|
171
|
+
if (!working?.umbrellaChildren) return working?.git ?? null;
|
|
172
|
+
return repository ? checkoutGit(environment, repository) : null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The repository's local checkout for resolving its Delivery Branch; null when none is known.
|
|
177
|
+
* Merges are checked through the repository's local merge access, without a fetch.
|
|
178
|
+
*/
|
|
179
|
+
async function deliveryCheckoutIn(
|
|
148
180
|
environment: DeliveryEnvironment,
|
|
149
181
|
repository: string,
|
|
150
|
-
|
|
182
|
+
access: RepositoryAccess,
|
|
183
|
+
): Promise<DeliveryCheckout | null> {
|
|
151
184
|
const git = await checkoutGit(environment, repository);
|
|
152
185
|
if (!git) return null;
|
|
153
|
-
return {
|
|
186
|
+
return {
|
|
187
|
+
hasRef: (ref) => git.hasRef(ref),
|
|
188
|
+
listRefs: async (prefixes) => (await git.listRefs?.(prefixes)) ?? [],
|
|
189
|
+
defaultBranch: () => git.defaultBranch(),
|
|
190
|
+
mergeProbe: async (branch, recordedHead) => {
|
|
191
|
+
const local = await access.local?.();
|
|
192
|
+
return local ? probeMerge(local.git, local.defaultBranch, branch, recordedHead) : null;
|
|
193
|
+
},
|
|
194
|
+
};
|
|
154
195
|
}
|
|
155
196
|
|
|
156
197
|
/** A delivery a ticket must not replace: direct, or not applicable. */
|
|
@@ -189,7 +230,6 @@ export async function recordDelivery(
|
|
|
189
230
|
located.push({ ...location, change });
|
|
190
231
|
}
|
|
191
232
|
|
|
192
|
-
const repository = request.repository ?? environment.workingRepo?.slug ?? null;
|
|
193
233
|
const ticketFormat = environment.ticket?.format ?? "none";
|
|
194
234
|
if (edit.ticket !== undefined && ticketFormat === "none") {
|
|
195
235
|
return { refusal: { reason: "tickets-off" } };
|
|
@@ -199,6 +239,19 @@ export async function recordDelivery(
|
|
|
199
239
|
edit.pr !== undefined ||
|
|
200
240
|
edit.confirm !== undefined ||
|
|
201
241
|
edit.ticket !== undefined;
|
|
242
|
+
const working = environment.workingRepo;
|
|
243
|
+
let repository = request.repository ?? working?.slug ?? null;
|
|
244
|
+
// In an Umbrella Repository the changes' only scoped child stands in for the Working Repository.
|
|
245
|
+
if (!repository && working?.umbrellaChildren) {
|
|
246
|
+
const children = working.umbrellaChildren;
|
|
247
|
+
const scoped = await scopedChildren(located, children);
|
|
248
|
+
if (scoped.length === 1) repository = scoped[0]!;
|
|
249
|
+
else if (edits) {
|
|
250
|
+
return {
|
|
251
|
+
refusal: { reason: "umbrella-repository", umbrella: working.path, scoped, children },
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
202
255
|
if (edits && !repository) return { refusal: { reason: "no-repository" } };
|
|
203
256
|
const refuseProtected = async (
|
|
204
257
|
repo: string,
|
|
@@ -223,23 +276,24 @@ export async function recordDelivery(
|
|
|
223
276
|
};
|
|
224
277
|
const cache: RefreshCache = new Map();
|
|
225
278
|
const resolved: Array<DeliveryResult & { dir: string }> = [];
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
279
|
+
const checkout = repository
|
|
280
|
+
? await deliveryCheckoutIn(environment, repository, access(repository))
|
|
281
|
+
: null;
|
|
282
|
+
const sessionGit = await sessionGitOf(environment, repository);
|
|
283
|
+
const currentBranch = (await sessionGit?.currentBranch()) ?? null;
|
|
230
284
|
|
|
231
285
|
for (const { change, dir, archived } of located) {
|
|
232
286
|
let record = await readOrUnlinkedRecord(dir, change);
|
|
233
|
-
const resolution = await resolveDeliveryBranch(
|
|
234
|
-
|
|
235
|
-
repository,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
287
|
+
const resolution = await resolveDeliveryBranch(
|
|
288
|
+
checkout,
|
|
289
|
+
{ companionPath: environment.companionPath, repository, change },
|
|
290
|
+
edit.ticket !== undefined ? { ticket: edit.ticket } : {},
|
|
291
|
+
);
|
|
292
|
+
// Reported once, on the first change, as it concerns the companion, not a change.
|
|
293
|
+
const templateDiagnostic = resolved.length === 0 ? resolution.templateDiagnostic : null;
|
|
294
|
+
const diagnostics = templateDiagnostic
|
|
295
|
+
? [templateDiagnostic, ...resolution.diagnostics]
|
|
296
|
+
: resolution.diagnostics;
|
|
243
297
|
const defaultBranch = resolution.branch;
|
|
244
298
|
const recordedBranch = repository ? findDelivery(record, repository)?.branch : undefined;
|
|
245
299
|
if (recordedBranch && defaultBranch && recordedBranch !== defaultBranch) {
|
|
@@ -277,7 +331,7 @@ export async function recordDelivery(
|
|
|
277
331
|
if (request.requireDelivery && record.deliveries.length === 0) {
|
|
278
332
|
let suggestedBranch: string | null = null;
|
|
279
333
|
for (const candidate of [defaultBranch, legacyDeliveryBranch(changeNameOf(change))]) {
|
|
280
|
-
if (candidate && (await
|
|
334
|
+
if (candidate && (await sessionGit?.branchExists(candidate))) {
|
|
281
335
|
suggestedBranch = candidate;
|
|
282
336
|
break;
|
|
283
337
|
}
|
|
@@ -5,6 +5,11 @@ import { parse, stringify } from "yaml";
|
|
|
5
5
|
import { errorMessage } from "../../runtime/error-message";
|
|
6
6
|
import { changeNameOf } from "../change-layout";
|
|
7
7
|
import { scopedRepositories } from "../openspec-scopes";
|
|
8
|
+
import {
|
|
9
|
+
applyBranchTemplate,
|
|
10
|
+
DEFAULT_BRANCH_TEMPLATE,
|
|
11
|
+
type BranchTemplate,
|
|
12
|
+
} from "./branch-template";
|
|
8
13
|
|
|
9
14
|
/** The Delivery Record's file name at a change root; it moves with the change into its archive. */
|
|
10
15
|
export const DELIVERY_FILE = "delivery.yaml";
|
|
@@ -131,9 +136,16 @@ export function legacyDeliveryWarning(anchorName: string): string {
|
|
|
131
136
|
return `${anchorName} has no delivery.yaml, so its merge was not checked; publishing it as a legacy archive.`;
|
|
132
137
|
}
|
|
133
138
|
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
/**
|
|
140
|
+
* The template's branch for a Workset; with the default template `workset/<workset-id>`, or
|
|
141
|
+
* `workset/<TICKET>-<workset-id>` when a ticket is given.
|
|
142
|
+
*/
|
|
143
|
+
export function defaultDeliveryBranch(
|
|
144
|
+
worksetId: string,
|
|
145
|
+
ticket?: string | null,
|
|
146
|
+
template: BranchTemplate = DEFAULT_BRANCH_TEMPLATE,
|
|
147
|
+
): string {
|
|
148
|
+
return applyBranchTemplate(template, worksetId, ticket);
|
|
137
149
|
}
|
|
138
150
|
|
|
139
151
|
export function legacyDeliveryBranch(change: string): string {
|