@uniqbit/mate-core 1.0.0-canary.8 → 1.0.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/package.json +5 -4
- package/src/cli/commands/artifact/delivery/link.ts +1 -1
- package/src/cli/commands/artifact/delivery/output.ts +10 -1
- package/src/cli/commands/artifact/delivery/resolve.ts +3 -2
- package/src/cli/commands/artifact/delivery/submit.ts +9 -4
- package/src/cli/commands/artifact/delivery/take.ts +12 -9
- package/src/cli/commands/artifact/finish/command.ts +16 -14
- package/src/cli/commands/artifact/finish/engine.ts +8 -8
- package/src/cli/commands/artifact/project/command.ts +2 -3
- package/src/cli/commands/companion/hub.ts +11 -6
- package/src/cli/commands/companion/link.ts +173 -46
- package/src/cli/commands/doctor.ts +17 -0
- package/src/cli/commands/report/contract.ts +0 -17
- package/src/cli/commands/studio/access.ts +4 -0
- package/src/cli/commands/studio/actions.ts +35 -2
- package/src/cli/commands/studio/mcp-manager.ts +162 -0
- package/src/cli/commands/studio/routes.ts +12 -0
- package/src/cli/commands/studio/selection.ts +44 -11
- package/src/cli/commands/studio/server.ts +246 -2
- package/src/cli/commands/studio/services.ts +26 -0
- package/src/cli/commands/studio/terminal-launch.ts +21 -4
- package/src/cli/commands/studio/terminal.ts +3 -14
- package/src/cli/commands/studio/work-requests.ts +9 -0
- package/src/cli/commands/studio/work.ts +473 -0
- package/src/cli/commands/vscode/release-vsix.json +2 -2
- package/src/cli/commands/working/cleanup.ts +1 -18
- package/src/cli/companion-link-wizard.tsx +158 -91
- package/src/cli/usage.ts +1 -1
- package/src/create-mate.ts +4 -1
- package/src/lib/agent-credential.ts +131 -0
- package/src/lib/credential-kinds.ts +7 -0
- package/src/lib/delivery/merge-git.ts +16 -0
- package/src/lib/delivery/record-delivery.ts +12 -6
- package/src/lib/delivery/record.ts +5 -0
- package/src/lib/delivery/refresh.ts +34 -6
- package/src/lib/delivery/staging/refs.ts +9 -4
- package/src/lib/delivery/staging/submit.ts +81 -22
- package/src/lib/mcp-manager/resolve.ts +88 -0
- package/src/lib/mcp-manager/store.ts +133 -0
- package/src/lib/mcp-manager/types.ts +72 -0
- package/src/lib/mcp-manager/validate.ts +242 -0
- package/src/lib/opencode-server.ts +2 -17
- package/src/lib/orchestrator/config-store.ts +30 -7
- package/src/lib/orchestrator/engine-floor.ts +16 -4
- package/src/lib/orchestrator/engine-guard.ts +7 -1
- package/src/lib/orchestrator/repo-local-store.ts +14 -0
- package/src/lib/orchestrator/repository-link.ts +80 -52
- package/src/lib/orchestrator/root-context.ts +17 -1
- package/src/lib/orchestrator/types.ts +4 -0
- package/src/lib/studio-chat/agent.ts +139 -0
- package/src/lib/studio-chat/companion-context.ts +136 -0
- package/src/lib/studio-chat/credential.ts +79 -0
- package/src/lib/studio-chat/harness-chat-agent.ts +334 -0
- package/src/lib/studio-chat/host-sandbox.ts +578 -0
- package/src/lib/studio-chat/prepare-bridges.ts +95 -0
- package/src/lib/studio-chat/session.ts +15 -0
- package/src/lib/studio-chat/turns.ts +112 -0
- package/src/lib/workset/claims.ts +85 -0
- package/src/lib/workset/execution.ts +71 -0
- package/src/lib/workset/git-transaction.ts +74 -0
- package/src/lib/workset/groups.ts +176 -0
- package/src/lib/workset/inventory.ts +196 -0
- package/src/lib/workset/projection.ts +237 -0
- package/src/lib/workset/record.ts +101 -36
- package/src/lib/workset/repositories.ts +24 -0
- package/src/lib/workset/sharing.ts +951 -0
- package/src/lib/workset/stages.ts +50 -14
- package/src/lib/workset/transactions.ts +158 -0
- package/src/runtime/companion-git-state.ts +1 -0
- package/src/runtime/companion-guidance.ts +2 -2
- package/src/runtime/forge-remote.ts +6 -0
- package/src/runtime/host-process.ts +28 -0
- package/src/runtime/secret-guard.ts +18 -1
- package/src/runtime/secret-patterns.ts +4 -3
- package/src/runtime/submitted-arrivals.ts +28 -2
- package/src/runtime/workflow/turn.ts +14 -12
- package/src/runtime/write-atomic.ts +2 -2
- package/src/studio.ts +61 -0
- package/src/templates/capabilities/openspec-cap/mate-full/schema.yaml +1 -1
- package/src/templates/capabilities/openspec-cap/mate-full/templates/proposal.md +1 -1
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +3 -2
- package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +5 -3
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +3 -2
- package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +5 -3
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +12 -12
- package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
- package/src/tools/setup/context-services.ts +35 -6
- package/src/tools/setup/dynamic-plugins/audiences.ts +3 -2
- package/src/tools/setup/dynamic-plugins/declarations.ts +0 -26
- package/src/tools/setup/engine.ts +55 -3
- package/src/tools/setup/plugin.ts +14 -0
- package/src/tools/setup/plugins/gitignore.ts +1 -0
- package/src/tools/setup/providers/claude-format.ts +40 -7
- package/src/tools/setup/providers/claude.ts +38 -3
- package/src/tools/setup/providers/opencode-format.ts +13 -3
- package/src/tools/setup/providers/opencode.ts +7 -18
- package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
- package/studio-dist/THIRD-PARTY-NOTICES.md +297 -0
- package/studio-dist/client/THIRD-PARTY-LICENSES.md +4294 -0
- package/studio-dist/client/assets/DialogTitle-DOhjDa7H.js +1 -0
- package/studio-dist/client/assets/app-CG3vCgyA.css +2 -0
- package/studio-dist/client/assets/bundle-mjs-CdK3cBzO.js +1 -0
- package/studio-dist/client/assets/button-upSzkd-q.js +1 -0
- package/studio-dist/client/assets/chat-DbaMXb8H.js +157 -0
- package/studio-dist/client/assets/cn-BCnYnarL.js +1 -0
- package/studio-dist/client/assets/combobox-cP9OsRf2.js +1 -0
- package/studio-dist/client/assets/{companion-view-C_N237bf.js → companion-view-B54_Lj0S.js} +1 -1
- package/studio-dist/client/assets/fields-DNZ4a89M.js +1 -0
- package/studio-dist/client/assets/friction-DgEimeDB.js +1 -0
- package/studio-dist/client/assets/getting-started-BTfYCt5s.js +1 -0
- package/studio-dist/client/assets/{getting-started-djaQeWlu.js → getting-started-CAszmdDJ.js} +1 -1
- package/studio-dist/client/assets/getting-started._topic-CHJMf0pa.js +1 -0
- package/studio-dist/client/assets/getting-started.index-MR6HftWs.js +1 -0
- package/studio-dist/client/assets/{graph-canvas-ySGKMhmk.js → graph-canvas-BdNk2F9O.js} +1 -1
- package/studio-dist/client/assets/graph-hRijsC89.js +2 -0
- package/studio-dist/client/assets/guides-CwFnh08E.js +1 -0
- package/studio-dist/client/assets/highlighted-body-JLMTFACH-BcroQey-.js +1 -0
- package/studio-dist/client/assets/index-D5oGyvG8.js +41 -0
- package/studio-dist/client/assets/{markdown-view-jMiaBTSO.js → markdown-view-CJ8JsLb7.js} +1 -1
- package/studio-dist/client/assets/marked.esm-vFuq1cCd.js +65 -0
- package/studio-dist/client/assets/mcp-BE9M-bkO.js +4 -0
- package/studio-dist/client/assets/mermaid-WFAXDIZX-BjSsakrn.js +1 -0
- package/studio-dist/client/assets/panel-CDQ6Lryw.js +1 -0
- package/studio-dist/client/assets/plugins._service._view-DRVPUAWN.js +1 -0
- package/studio-dist/client/assets/{prepaint-CKsXyJOR.js → prepaint-sD_LlrDN.js} +1 -1
- package/studio-dist/client/assets/{queries-Dfp5deWj.js → queries-COL925ML.js} +1 -1
- package/studio-dist/client/assets/react-dom-K3Hp2Cdj.js +1 -0
- package/studio-dist/client/assets/{react-BYUSgtBs.js → react-h2xQ_NSp.js} +1 -1
- package/studio-dist/client/assets/reports-BClsojkb.js +1 -0
- package/studio-dist/client/assets/routes-CJQ2MAej.js +1 -0
- package/studio-dist/client/assets/search-DhWdEiKT.js +1 -0
- package/studio-dist/client/assets/select-B2FsN9FY.js +1 -0
- package/studio-dist/client/assets/skills-SoUHk77W.js +1 -0
- package/studio-dist/client/assets/{specs-BrCOjOch.js → specs-C_tZnAvF.js} +1 -1
- package/studio-dist/client/assets/specs-view-C6t3Y5IT.js +1 -0
- package/studio-dist/client/assets/steps-CF3-Zpmh.js +1 -0
- package/studio-dist/client/assets/{store-C3vJq8Wj.js → store-pY9gU4uS.js} +1 -1
- package/studio-dist/client/assets/studio-X7bnFrRe.js +36 -0
- package/studio-dist/client/assets/studio-queries-CKtAnIKP.js +2 -0
- package/studio-dist/client/assets/usage-BaaqUpTG.js +55 -0
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-BspHR7Wt.js +1 -0
- package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
- package/studio-dist/client/assets/useMutation-DKeEoP5S.js +1 -0
- package/studio-dist/client/assets/useOpenInteractionType-CtaZCaFT.js +1 -0
- package/studio-dist/client/assets/usePopupHandleStore-Bc7Q4bnF.js +1 -0
- package/studio-dist/client/assets/vault-sAPFUnPN.js +1 -0
- package/studio-dist/client/assets/{warnings-CqOOGlPD.js → warnings-D7YY1HSG.js} +1 -1
- package/studio-dist/client/assets/work-BZek_LGB.js +5 -0
- package/studio-dist/client/assets/workflow-N5boHXFz.js +1 -0
- package/studio-dist/server/THIRD-PARTY-LICENSES.md +4371 -0
- package/studio-dist/server/assets/DialogTitle-DnKSl2V0.js +421 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-gVfW5vIV.js → __23tanstack-start-server-fn-resolver-Bli9bpSB.js} +38 -18
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +91 -59
- package/studio-dist/server/assets/{actions-D8erOphH.js → actions-CHEFA1i9.js} +33 -1
- package/studio-dist/server/assets/{cn-FXJAM0KO.js → bundle-mjs-Ot6dQ8Pq.js} +1 -2056
- package/studio-dist/server/assets/{button-D6bvrFmm.js → button-BqA1urbl.js} +14 -7
- package/studio-dist/server/assets/chat-zl332Tvu.js +49486 -0
- package/studio-dist/server/assets/cn-B0fl6NWK.js +2057 -0
- package/studio-dist/server/assets/{combobox-D2MbYV1O.js → combobox-iTjvPCtS.js} +7 -6
- package/studio-dist/server/assets/{companion-view-Mf1ANbMb.js → companion-view-DIQ6AFIY.js} +2 -2
- package/studio-dist/server/assets/{companions-Dr6IpNAb.js → companions-aVwjRL8j.js} +1 -1
- package/studio-dist/server/assets/{fields-B4mAPETz.js → fields-BMap2_Ju.js} +10 -3
- package/studio-dist/server/assets/{friction-CWOTjpCV.js → friction-BER50hoD.js} +2 -2
- package/studio-dist/server/assets/{friction-9a5S1m7U.js → friction-BPs9KWdq.js} +8 -8
- package/studio-dist/server/assets/{getting-started-RU6tYU2Q.js → getting-started-DGfRVmZ_.js} +2 -2
- package/studio-dist/server/assets/{getting-started._topic-C02HGrC6.js → getting-started._topic-BgrBA4Vj.js} +2 -2
- package/studio-dist/server/assets/{getting-started.index-EzLRosbb.js → getting-started.index-BaFfQ9Mn.js} +2 -2
- package/studio-dist/server/assets/{graph-CZ2H9Fzr.js → graph-Cgzlrv3P.js} +8 -8
- package/studio-dist/server/assets/{graph-B11ITte0.js → graph-DODpuOy_.js} +1 -1
- package/studio-dist/server/assets/{graph-canvas-rP5TT14Z.js → graph-canvas-DW_zU1nA.js} +2 -2
- package/studio-dist/server/assets/{guides-BGftp4wf.js → guides-CA_EMG7E.js} +1 -1
- package/studio-dist/server/assets/{guides-B8HdeK_C.js → guides-D0SpoD32.js} +1 -1
- package/studio-dist/server/assets/{guides.server-DqFQAStf.js → guides.server-DJjQuy03.js} +1 -1
- package/studio-dist/server/assets/highlighted-body-JLMTFACH-BeHllu-r.js +41 -0
- package/studio-dist/server/assets/{markdown-view-CArpV-CS.js → markdown-view-CvVBGMZV.js} +1 -1
- package/studio-dist/server/assets/mcp-BU0fLYyJ.js +1103 -0
- package/studio-dist/server/assets/mcp-manager-D9YctTQe.js +50 -0
- package/studio-dist/server/assets/mermaid-WFAXDIZX-B1yDN6vG.js +1 -0
- package/studio-dist/server/assets/{panel-DR0iq46J.js → panel-D1K6Bsux.js} +4 -32
- package/studio-dist/server/assets/{plugins._service._view-n7u2k5dF.js → plugins._service._view-DdO1nELF.js} +4 -4
- package/studio-dist/server/assets/{prepaint-B28ClcPN.js → prepaint-BB3dwSmz.js} +1 -1
- package/studio-dist/server/assets/{queries-D-yVP9i0.js → queries-BwiDxQy5.js} +1 -1
- package/studio-dist/server/assets/{react-CiBZPDs8.js → react-B2cLiz-i.js} +1 -1
- package/studio-dist/server/assets/{reports-C2SmTgqh.js → reports-9Pr7Bz6o.js} +7 -7
- package/studio-dist/server/assets/{reports-B9k98oE6.js → reports-Cc9M3phM.js} +1 -1
- package/studio-dist/server/assets/{router-CPt0TAk_.js → router-DcWe0J7Y.js} +827 -548
- package/studio-dist/server/assets/{routes-CwH8LEy2.js → routes-BEXxl0py.js} +8 -8
- package/studio-dist/server/assets/{search-b-yQesv3.js → search-bltT7gwy.js} +39 -7
- package/studio-dist/server/assets/{select-C3i6TTX-.js → select-CZvHgGCi.js} +7 -6
- package/studio-dist/server/assets/{shell-CagqZZMZ.js → shell-BQ0vMKXN.js} +13 -4
- package/studio-dist/server/assets/{skills-DGg0mWDM.js → skills-Be_52h0i.js} +1 -1
- package/studio-dist/server/assets/{skills-C21Mg_8-.js → skills-BpGGUl6L.js} +8 -8
- package/studio-dist/server/assets/{specs-DetoMiaB.js → specs-CCGgXE-V.js} +5 -5
- package/studio-dist/server/assets/{specs-view-CmbfLDwN.js → specs-view-DtL5JxYM.js} +12 -11
- package/studio-dist/server/assets/{steps-D1tYAyWZ.js → steps-BWFSO6dM.js} +1 -1
- package/studio-dist/server/assets/{store-aC-I6f6o.js → store-X7yLPp7v.js} +1 -1
- package/studio-dist/server/assets/{studio-queries-Dqf-3nzj.js → studio-queries-ur1ygXi3.js} +117 -13
- package/studio-dist/server/assets/{studio-qRvQjRpz.js → studio-qzH-UETC.js} +1555 -179
- package/studio-dist/server/assets/{usage-Cwle9-xY.js → usage-C1o0DLzS.js} +1 -1
- package/studio-dist/server/assets/{usage-CS4CBK9D.js → usage-DWbSPrPD.js} +10 -9
- package/studio-dist/server/assets/{useAnchoredPopupScrollLock-BjMNgXv9.js → useAnchoredPopupScrollLock-DLDmv6kM.js} +4 -135
- package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
- package/studio-dist/server/assets/{useMutation-DpBIuWXt.js → useMutation-NjlA8oFY.js} +2 -2
- package/studio-dist/server/assets/useOpenInteractionType-CZYscfOb.js +136 -0
- package/studio-dist/server/assets/usePopupHandleStore-DEEXJYv0.js +26 -0
- package/studio-dist/server/assets/{vault-CEBBRLMb.js → vault-B_kfi1h-.js} +1 -1
- package/studio-dist/server/assets/{vault-DVQidlId.js → vault-dL79JlKH.js} +8 -115
- package/studio-dist/server/assets/{views-UgO0Qz_g.js → views-BSGH56lb.js} +3 -3
- package/studio-dist/server/assets/{warnings-C7hgXpdk.js → warnings-DtUVPV-k.js} +2 -2
- package/studio-dist/server/assets/work-D789VXGH.js +110 -0
- package/studio-dist/server/assets/work-DsCEfhmK.js +3817 -0
- package/studio-dist/server/assets/work-requests-BLhOmQFO.js +11 -0
- package/studio-dist/server/assets/{workflow-6dZZ1ofw.js → workflow-BOZ2sRYg.js} +9 -9
- package/studio-dist/server/server.js +3 -3
- package/wrappers/bin/openspec +87 -2
- package/studio-dist/client/assets/app-ggXJ_QVh.css +0 -2
- package/studio-dist/client/assets/button-amJ3g5oD.js +0 -1
- package/studio-dist/client/assets/cn-BQPKiwI4.js +0 -1
- package/studio-dist/client/assets/combobox-CJ7aGFid.js +0 -1
- package/studio-dist/client/assets/fields-BAiGkJ5N.js +0 -1
- package/studio-dist/client/assets/friction-DqOU59v7.js +0 -1
- package/studio-dist/client/assets/getting-started-yp42dj5S.js +0 -1
- package/studio-dist/client/assets/getting-started._topic-C9zVXz_m.js +0 -1
- package/studio-dist/client/assets/getting-started.index-DWbDKICP.js +0 -1
- package/studio-dist/client/assets/graph-BYaD_5Bq.js +0 -2
- package/studio-dist/client/assets/guides-D6T6W_jV.js +0 -1
- package/studio-dist/client/assets/index-Qx7reRPD.js +0 -40
- package/studio-dist/client/assets/panel-C4bf_h2W.js +0 -1
- package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +0 -1
- package/studio-dist/client/assets/reports-JFSwSueq.js +0 -1
- package/studio-dist/client/assets/routes-BdOWSgzK.js +0 -1
- package/studio-dist/client/assets/search-CXosfvYh.js +0 -1
- package/studio-dist/client/assets/select-BHYYWPhK.js +0 -1
- package/studio-dist/client/assets/skills-Bo9FLsBd.js +0 -1
- package/studio-dist/client/assets/specs-view-CdE2rlli.js +0 -1
- package/studio-dist/client/assets/steps-CKUno4lh.js +0 -1
- package/studio-dist/client/assets/studio-0ueISxwP.js +0 -100
- package/studio-dist/client/assets/studio-queries-BflKt9va.js +0 -2
- package/studio-dist/client/assets/usage-BLsLy0nN.js +0 -55
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-DC7f8GOp.js +0 -1
- package/studio-dist/client/assets/useMutation-uJUrejsi.js +0 -1
- package/studio-dist/client/assets/vault-BB1B_OhR.js +0 -1
- package/studio-dist/client/assets/workflow-BFzmI-06.js +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime automatic */
|
|
2
2
|
/** @jsxImportSource react */
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
3
5
|
import { Box, render as inkRender } from "ink";
|
|
4
6
|
import { useEffect } from "react";
|
|
5
7
|
|
|
@@ -17,15 +19,24 @@ const companionLinkWizardDeps = {
|
|
|
17
19
|
export interface CompanionLinkInputs {
|
|
18
20
|
source: CompanionSource;
|
|
19
21
|
gitUrl?: string;
|
|
22
|
+
/** A clone already on this machine whose origin is `gitUrl`'s repository; links it instead of cloning. */
|
|
23
|
+
clonePath?: string;
|
|
20
24
|
localPath?: string;
|
|
21
25
|
companionPaths?: string[];
|
|
26
|
+
/** True replaces the companions `replacedBy` names, false keeps both. */
|
|
27
|
+
replace?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ExistingCompanion {
|
|
31
|
+
path: string;
|
|
32
|
+
registered: boolean;
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
interface
|
|
35
|
+
interface SelectStep {
|
|
25
36
|
kind: "select";
|
|
26
|
-
field: "source";
|
|
37
|
+
field: "source" | "clonePath" | "replace";
|
|
27
38
|
label: string;
|
|
28
|
-
options: Array<{ key:
|
|
39
|
+
options: Array<{ key: string; label: string }>;
|
|
29
40
|
activeIndex: number;
|
|
30
41
|
}
|
|
31
42
|
|
|
@@ -33,7 +44,7 @@ interface CompanionMultiSelectStep {
|
|
|
33
44
|
kind: "multiselect";
|
|
34
45
|
field: "companionPaths";
|
|
35
46
|
label: string;
|
|
36
|
-
options: string
|
|
47
|
+
options: Array<{ key: string; label: string }>;
|
|
37
48
|
activeIndex: number;
|
|
38
49
|
selected: Set<string>;
|
|
39
50
|
}
|
|
@@ -46,7 +57,7 @@ interface TextStep {
|
|
|
46
57
|
error?: string;
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
type WizardStep =
|
|
60
|
+
type WizardStep = SelectStep | CompanionMultiSelectStep | TextStep;
|
|
50
61
|
|
|
51
62
|
interface WizardAppProps {
|
|
52
63
|
step: WizardStep;
|
|
@@ -77,9 +88,8 @@ function CompanionLinkWizardApp({ step, stepNumber, totalSteps, onMounted }: Wiz
|
|
|
77
88
|
if (step.kind === "multiselect") {
|
|
78
89
|
const enterHint = isLastStep ? "enter confirm" : "enter next";
|
|
79
90
|
const items = step.options.map((option) => ({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
indicator: step.selected.has(option) ? "◉" : "○",
|
|
91
|
+
...option,
|
|
92
|
+
indicator: step.selected.has(option.key) ? "◉" : "○",
|
|
83
93
|
}));
|
|
84
94
|
return (
|
|
85
95
|
<Box flexDirection="column" width="100%">
|
|
@@ -106,65 +116,128 @@ function CompanionLinkWizardApp({ step, stepNumber, totalSteps, onMounted }: Wiz
|
|
|
106
116
|
}
|
|
107
117
|
|
|
108
118
|
export interface CompanionLinkWizardOptions {
|
|
109
|
-
existingCompanions?:
|
|
119
|
+
existingCompanions?: ExistingCompanion[];
|
|
120
|
+
/** Existing companions whose origin is the URL's repository. */
|
|
121
|
+
clonesOf?: (gitUrl: string) => string[];
|
|
122
|
+
/** The linked companions these inputs would replace; empty asks nothing. */
|
|
123
|
+
replacedBy?: (inputs: CompanionLinkInputs) => string[];
|
|
110
124
|
stdin?: NodeJS.ReadStream;
|
|
111
125
|
stdout?: NodeJS.WriteStream;
|
|
112
126
|
stderr?: NodeJS.WriteStream;
|
|
113
127
|
}
|
|
114
128
|
|
|
129
|
+
const REPLACE = "replace";
|
|
130
|
+
|
|
131
|
+
interface WizardValues {
|
|
132
|
+
source: CompanionSource;
|
|
133
|
+
gitUrl: string;
|
|
134
|
+
/** Into the matching clones; their count means "Clone a new copy". */
|
|
135
|
+
cloneActiveIndex: number;
|
|
136
|
+
localPath: string;
|
|
137
|
+
companionPaths: Set<string>;
|
|
138
|
+
companionActiveIndex: number;
|
|
139
|
+
replace: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function resultOf(
|
|
143
|
+
values: WizardValues,
|
|
144
|
+
clonesOf: (gitUrl: string) => string[],
|
|
145
|
+
): CompanionLinkInputs {
|
|
146
|
+
const { source } = values;
|
|
147
|
+
return {
|
|
148
|
+
source,
|
|
149
|
+
gitUrl: source === "git" ? values.gitUrl : undefined,
|
|
150
|
+
clonePath: source === "git" ? clonesOf(values.gitUrl)[values.cloneActiveIndex] : undefined,
|
|
151
|
+
localPath: source === "local" ? values.localPath : undefined,
|
|
152
|
+
companionPaths: source === "existing" ? [...values.companionPaths] : undefined,
|
|
153
|
+
replace: values.replace,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
115
157
|
function buildSteps(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
localPath: string;
|
|
120
|
-
companionPaths: Set<string>;
|
|
121
|
-
companionActiveIndex: number;
|
|
158
|
+
values: WizardValues,
|
|
159
|
+
options: Required<Pick<CompanionLinkWizardOptions, "clonesOf" | "replacedBy">> & {
|
|
160
|
+
existingCompanions: ExistingCompanion[];
|
|
122
161
|
},
|
|
123
|
-
existingCompanions: string[],
|
|
124
162
|
): WizardStep[] {
|
|
125
|
-
const
|
|
126
|
-
|
|
163
|
+
const { existingCompanions, clonesOf, replacedBy } = options;
|
|
164
|
+
const sourceOptions: SelectStep["options"] = [
|
|
127
165
|
...(existingCompanions.length > 0
|
|
128
|
-
? [{ key: "existing"
|
|
166
|
+
? [{ key: "existing", label: "Use a companion already on this machine" }]
|
|
129
167
|
: []),
|
|
130
|
-
{ key: "
|
|
168
|
+
{ key: "git", label: "Clone from a Git URL into ~/.mate/companions" },
|
|
169
|
+
{ key: "local", label: "Enter the path of another folder" },
|
|
170
|
+
];
|
|
171
|
+
const steps: WizardStep[] = [
|
|
172
|
+
{
|
|
173
|
+
kind: "select",
|
|
174
|
+
field: "source",
|
|
175
|
+
label: "Companion Source",
|
|
176
|
+
options: sourceOptions,
|
|
177
|
+
activeIndex: Math.max(
|
|
178
|
+
0,
|
|
179
|
+
sourceOptions.findIndex((option) => option.key === values.source),
|
|
180
|
+
),
|
|
181
|
+
},
|
|
131
182
|
];
|
|
132
|
-
const sourceStep: SourceStep = {
|
|
133
|
-
kind: "select",
|
|
134
|
-
field: "source",
|
|
135
|
-
label: "Companion Source",
|
|
136
|
-
options: sourceOptions,
|
|
137
|
-
activeIndex: Math.max(
|
|
138
|
-
0,
|
|
139
|
-
sourceOptions.findIndex((option) => option.key === source),
|
|
140
|
-
),
|
|
141
|
-
};
|
|
142
183
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
const clones = values.source === "git" ? clonesOf(values.gitUrl) : [];
|
|
185
|
+
if (values.source === "git") {
|
|
186
|
+
steps.push({ kind: "text", field: "gitUrl", label: "Companion Git URL", value: values.gitUrl });
|
|
187
|
+
if (clones.length > 0) {
|
|
188
|
+
steps.push({
|
|
189
|
+
kind: "select",
|
|
190
|
+
field: "clonePath",
|
|
191
|
+
label: "This repository is already cloned on this machine",
|
|
192
|
+
options: [
|
|
193
|
+
...clones.map((clone) => ({
|
|
194
|
+
key: clone,
|
|
195
|
+
label: `Use ${path.basename(clone)} ${clone}`,
|
|
196
|
+
})),
|
|
197
|
+
{ key: "new", label: "Clone a new copy" },
|
|
198
|
+
],
|
|
199
|
+
activeIndex: Math.min(values.cloneActiveIndex, clones.length),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
} else if (values.source === "local") {
|
|
203
|
+
steps.push({
|
|
204
|
+
kind: "text",
|
|
205
|
+
field: "localPath",
|
|
206
|
+
label: "Local Companion Path",
|
|
207
|
+
value: values.localPath,
|
|
208
|
+
});
|
|
209
|
+
} else {
|
|
210
|
+
steps.push({
|
|
211
|
+
kind: "multiselect",
|
|
212
|
+
field: "companionPaths",
|
|
213
|
+
label: "Existing Companions",
|
|
214
|
+
options: existingCompanions.map((companion) => ({
|
|
215
|
+
key: companion.path,
|
|
216
|
+
// Name and mark lead: the menu cuts long paths at the terminal's edge.
|
|
217
|
+
label: `${path.basename(companion.path)}${companion.registered ? "" : " (not registered)"} ${companion.path}`,
|
|
218
|
+
})),
|
|
219
|
+
activeIndex: values.companionActiveIndex,
|
|
220
|
+
selected: values.companionPaths,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const replaced = replacedBy(resultOf(values, clonesOf));
|
|
225
|
+
if (replaced.length > 0) {
|
|
226
|
+
steps.push({
|
|
227
|
+
kind: "select",
|
|
228
|
+
field: "replace",
|
|
229
|
+
label: "This folder is already linked to another companion",
|
|
230
|
+
options: [
|
|
231
|
+
{
|
|
232
|
+
key: REPLACE,
|
|
233
|
+
label: `Replace ${replaced.map((companion) => path.basename(companion)).join(", ")}`,
|
|
234
|
+
},
|
|
235
|
+
{ key: "keep", label: "Keep both" },
|
|
236
|
+
],
|
|
237
|
+
activeIndex: values.replace ? 0 : 1,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return steps;
|
|
168
241
|
}
|
|
169
242
|
|
|
170
243
|
export async function selectCompanionLinkInputs(
|
|
@@ -174,20 +247,27 @@ export async function selectCompanionLinkInputs(
|
|
|
174
247
|
const stdout = options.stdout ?? process.stdout;
|
|
175
248
|
const stderr = options.stderr ?? process.stderr;
|
|
176
249
|
const existingCompanions = options.existingCompanions ?? [];
|
|
250
|
+
const stepOptions = {
|
|
251
|
+
existingCompanions,
|
|
252
|
+
clonesOf: options.clonesOf ?? (() => []),
|
|
253
|
+
replacedBy: options.replacedBy ?? (() => []),
|
|
254
|
+
};
|
|
177
255
|
|
|
178
256
|
return new Promise<CompanionLinkInputs | null>((resolve, reject) => {
|
|
179
257
|
let resolved = false;
|
|
180
|
-
|
|
181
|
-
|
|
258
|
+
const values: WizardValues = {
|
|
259
|
+
source: existingCompanions.length > 0 ? "existing" : "git",
|
|
182
260
|
gitUrl: "",
|
|
261
|
+
cloneActiveIndex: 0,
|
|
183
262
|
localPath: "",
|
|
184
263
|
companionPaths: new Set<string>(),
|
|
185
264
|
companionActiveIndex: 0,
|
|
265
|
+
replace: true,
|
|
186
266
|
};
|
|
187
267
|
let currentStepIndex = 0;
|
|
188
268
|
const keepAlive = setInterval(() => {}, 1 << 30);
|
|
189
269
|
let rendered: ReturnType<typeof inkRender> | undefined;
|
|
190
|
-
let steps = buildSteps(
|
|
270
|
+
let steps = buildSteps(values, stepOptions);
|
|
191
271
|
|
|
192
272
|
const cleanup = () => {
|
|
193
273
|
clearInterval(keepAlive);
|
|
@@ -205,13 +285,6 @@ export async function selectCompanionLinkInputs(
|
|
|
205
285
|
resolve(value);
|
|
206
286
|
};
|
|
207
287
|
|
|
208
|
-
const buildResult = (): CompanionLinkInputs => ({
|
|
209
|
-
source,
|
|
210
|
-
gitUrl: source === "git" ? values.gitUrl : undefined,
|
|
211
|
-
localPath: source === "local" ? values.localPath : undefined,
|
|
212
|
-
companionPaths: source === "existing" ? [...values.companionPaths] : undefined,
|
|
213
|
-
});
|
|
214
|
-
|
|
215
288
|
const rerender = () => {
|
|
216
289
|
rendered?.rerender(
|
|
217
290
|
<CompanionLinkWizardApp
|
|
@@ -222,8 +295,16 @@ export async function selectCompanionLinkInputs(
|
|
|
222
295
|
);
|
|
223
296
|
};
|
|
224
297
|
|
|
225
|
-
|
|
226
|
-
|
|
298
|
+
// Later steps depend on earlier answers, so every submit rebuilds them.
|
|
299
|
+
const advance = () => {
|
|
300
|
+
steps = buildSteps(values, stepOptions);
|
|
301
|
+
if (currentStepIndex < steps.length - 1) {
|
|
302
|
+
currentStepIndex++;
|
|
303
|
+
rerender();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
doResolve(resultOf(values, stepOptions.clonesOf));
|
|
307
|
+
rendered?.unmount();
|
|
227
308
|
};
|
|
228
309
|
|
|
229
310
|
const onData = (chunk: string) => {
|
|
@@ -232,8 +313,8 @@ export async function selectCompanionLinkInputs(
|
|
|
232
313
|
if (step.kind === "multiselect" && chunk === " ") {
|
|
233
314
|
const option = step.options[step.activeIndex];
|
|
234
315
|
if (option) {
|
|
235
|
-
if (step.selected.has(option)) step.selected.delete(option);
|
|
236
|
-
else step.selected.add(option);
|
|
316
|
+
if (step.selected.has(option.key)) step.selected.delete(option.key);
|
|
317
|
+
else step.selected.add(option.key);
|
|
237
318
|
}
|
|
238
319
|
rerender();
|
|
239
320
|
return;
|
|
@@ -277,14 +358,7 @@ export async function selectCompanionLinkInputs(
|
|
|
277
358
|
if (parsed.action !== "submit" || !step.value.trim()) {
|
|
278
359
|
return;
|
|
279
360
|
}
|
|
280
|
-
|
|
281
|
-
if (currentStepIndex < steps.length - 1) {
|
|
282
|
-
currentStepIndex++;
|
|
283
|
-
rerender();
|
|
284
|
-
} else {
|
|
285
|
-
doResolve(buildResult());
|
|
286
|
-
rendered?.unmount();
|
|
287
|
-
}
|
|
361
|
+
advance();
|
|
288
362
|
return;
|
|
289
363
|
}
|
|
290
364
|
|
|
@@ -305,26 +379,19 @@ export async function selectCompanionLinkInputs(
|
|
|
305
379
|
}
|
|
306
380
|
|
|
307
381
|
if (step.kind === "select") {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
rerender();
|
|
382
|
+
const key = step.options[step.activeIndex]!.key;
|
|
383
|
+
if (step.field === "source") values.source = key as CompanionSource;
|
|
384
|
+
else if (step.field === "clonePath") values.cloneActiveIndex = step.activeIndex;
|
|
385
|
+
else values.replace = key === REPLACE;
|
|
386
|
+
advance();
|
|
314
387
|
return;
|
|
315
388
|
}
|
|
316
389
|
|
|
317
390
|
if (step.selected.size === 0) {
|
|
318
391
|
const option = step.options[step.activeIndex];
|
|
319
|
-
if (option) step.selected.add(option);
|
|
320
|
-
}
|
|
321
|
-
if (currentStepIndex < steps.length - 1) {
|
|
322
|
-
currentStepIndex++;
|
|
323
|
-
rerender();
|
|
324
|
-
} else {
|
|
325
|
-
doResolve(buildResult());
|
|
326
|
-
rendered?.unmount();
|
|
392
|
+
if (option) step.selected.add(option.key);
|
|
327
393
|
}
|
|
394
|
+
advance();
|
|
328
395
|
};
|
|
329
396
|
|
|
330
397
|
const onMounted = () => {
|
package/src/cli/usage.ts
CHANGED
|
@@ -47,7 +47,7 @@ export function usage(): string {
|
|
|
47
47
|
` ${n} artifact submit <change>... [--repository <org/repo>]`,
|
|
48
48
|
" [--branch <b> [--direct]|--not-applicable <reason>|--skip-branch] [--fetch] [--json]",
|
|
49
49
|
` ${n} artifact submit --drop <change>... [--json]`,
|
|
50
|
-
` ${n} artifact take <change> [--json] a submitted change into this checkout
|
|
50
|
+
` ${n} artifact take <change> [--json] a submitted or shared change into this checkout`,
|
|
51
51
|
` ${n} artifact archive <change> [options] (deprecated alias of artifact submit)`,
|
|
52
52
|
` ${n} artifact resolve <change> (--capability <c> --requirement <name> --file <path>)...`,
|
|
53
53
|
" [--json] one triple per stale requirement of the change",
|
package/src/create-mate.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { setActiveDistribution, type DistributionConfig } from "./distribution";
|
|
|
3
3
|
import { FRAMEWORK_NAME } from "./framework";
|
|
4
4
|
import { currentSession } from "./lib/session-attribution";
|
|
5
5
|
import { runRecordingFailure } from "./runtime/command-friction";
|
|
6
|
+
import { createMcpManagerPlugin } from "./tools/setup/capabilities/mcp-manager";
|
|
6
7
|
import { createBunPlugin } from "./tools/setup/package-managers/bun";
|
|
7
8
|
import { createUvPlugin } from "./tools/setup/package-managers/uv";
|
|
8
9
|
import type { PluginRegistration } from "./tools/setup/plugin";
|
|
@@ -26,7 +27,8 @@ export interface MateCli {
|
|
|
26
27
|
* Assemble a distribution from an identity config and plugin registration
|
|
27
28
|
* entries. Distributions choose their plugin set; the framework always adds
|
|
28
29
|
* bun as the required runtime substrate, uv for the capabilities that install
|
|
29
|
-
* through it (enabled only by them, e.g. Graphify),
|
|
30
|
+
* through it (enabled only by them, e.g. Graphify), the `mcp-manager`
|
|
31
|
+
* Capability (enabled by a `mcpManager` section), plus gitignore management
|
|
30
32
|
* named after the framework identity (built last since it reads the full
|
|
31
33
|
* plugin set). Returns the runnable CLI.
|
|
32
34
|
*/
|
|
@@ -35,6 +37,7 @@ export function createMate({ config, plugins, main: runMain = main }: CreateMate
|
|
|
35
37
|
...plugins,
|
|
36
38
|
{ plugin: createBunPlugin(), policy: "required" },
|
|
37
39
|
{ plugin: createUvPlugin(), policy: "optional" },
|
|
40
|
+
createMcpManagerPlugin(),
|
|
38
41
|
createGitignorePlugin(FRAMEWORK_NAME),
|
|
39
42
|
]);
|
|
40
43
|
setActiveDistribution({ config, registry });
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { writeAtomic } from "../runtime/write-atomic";
|
|
5
|
+
import { CREDENTIAL_KIND_LABELS, CREDENTIAL_KINDS, type CredentialKind } from "./credential-kinds";
|
|
6
|
+
|
|
7
|
+
export type { CredentialKind } from "./credential-kinds";
|
|
8
|
+
|
|
9
|
+
export const AGENT_CREDENTIAL_NAMES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"] as const;
|
|
10
|
+
export type AgentCredentialName = (typeof AGENT_CREDENTIAL_NAMES)[number];
|
|
11
|
+
|
|
12
|
+
export interface AgentCredential {
|
|
13
|
+
name: AgentCredentialName;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class AgentCredentialError extends Error {
|
|
18
|
+
override name = "AgentCredentialError";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const KINDS: Record<CredentialKind, { name: AgentCredentialName; prefixes: readonly string[] }> = {
|
|
22
|
+
subscription: { name: "CLAUDE_CODE_OAUTH_TOKEN", prefixes: ["sk-ant-oat"] },
|
|
23
|
+
"api-key": { name: "ANTHROPIC_API_KEY", prefixes: ["sk-ant-api", "sk-ant-usr"] },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function credentialKind(name: AgentCredentialName): CredentialKind {
|
|
27
|
+
return name === "CLAUDE_CODE_OAUTH_TOKEN" ? "subscription" : "api-key";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function credentialLabel(name: AgentCredentialName): string {
|
|
31
|
+
return CREDENTIAL_KIND_LABELS[credentialKind(name)];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CredentialStatus {
|
|
35
|
+
kind: CredentialKind | null;
|
|
36
|
+
/** `login`: no credential set or supplied; the local Claude login answers. */
|
|
37
|
+
source: "studio" | "startup" | "login" | null;
|
|
38
|
+
/** When it was set in Studio, as an ISO date; null otherwise. */
|
|
39
|
+
setAt: string | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function checkedCredential(kind: unknown, value: unknown): AgentCredential {
|
|
43
|
+
if (typeof kind !== "string" || !CREDENTIAL_KINDS.includes(kind as CredentialKind)) {
|
|
44
|
+
throw new AgentCredentialError(`kind must be one of ${CREDENTIAL_KINDS.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
const expected = KINDS[kind as CredentialKind];
|
|
47
|
+
const label = CREDENTIAL_KIND_LABELS[kind as CredentialKind];
|
|
48
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
49
|
+
if (!text) throw new AgentCredentialError(`no ${label} was given`);
|
|
50
|
+
if (/\s/.test(text) || !expected.prefixes.some((prefix) => text.startsWith(prefix))) {
|
|
51
|
+
throw new AgentCredentialError(
|
|
52
|
+
`${label}s start with ${expected.prefixes.join(" or ")} and have no spaces; nothing was stored`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return { name: expected.name, value: text };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parse(text: string): AgentCredential | null {
|
|
59
|
+
for (const line of text.split("\n")) {
|
|
60
|
+
const separator = line.indexOf("=");
|
|
61
|
+
const name = line.slice(0, separator) as AgentCredentialName;
|
|
62
|
+
if (separator > 0 && AGENT_CREDENTIAL_NAMES.includes(name)) {
|
|
63
|
+
const value = line.slice(separator + 1).trim();
|
|
64
|
+
if (value) return { name, value };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface AgentCredentials {
|
|
71
|
+
current(): AgentCredential | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class CredentialStore implements AgentCredentials {
|
|
75
|
+
private stored: AgentCredential | null = null;
|
|
76
|
+
private setAt: Date | null = null;
|
|
77
|
+
|
|
78
|
+
constructor(
|
|
79
|
+
private readonly file: string | null,
|
|
80
|
+
private readonly startup: AgentCredential | null,
|
|
81
|
+
) {
|
|
82
|
+
if (file === null) return;
|
|
83
|
+
try {
|
|
84
|
+
this.stored = parse(fs.readFileSync(file, "utf8"));
|
|
85
|
+
this.setAt = this.stored ? fs.statSync(file).mtime : null;
|
|
86
|
+
} catch {
|
|
87
|
+
this.stored = null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
current(): AgentCredential | null {
|
|
92
|
+
return this.stored ?? this.startup;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
studio(): AgentCredential | null {
|
|
96
|
+
return this.stored;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
status(): CredentialStatus {
|
|
100
|
+
if (this.stored) {
|
|
101
|
+
return {
|
|
102
|
+
kind: credentialKind(this.stored.name),
|
|
103
|
+
source: "studio",
|
|
104
|
+
setAt: this.setAt?.toISOString() ?? null,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (this.startup) {
|
|
108
|
+
return { kind: credentialKind(this.startup.name), source: "startup", setAt: null };
|
|
109
|
+
}
|
|
110
|
+
return { kind: null, source: null, setAt: null };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async set(credential: AgentCredential): Promise<void> {
|
|
114
|
+
const file = this.writable();
|
|
115
|
+
await fs.promises.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
116
|
+
await writeAtomic(file, `${credential.name}=${credential.value}\n`, 0o600);
|
|
117
|
+
this.stored = credential;
|
|
118
|
+
this.setAt = (await fs.promises.stat(file)).mtime;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
clear(): void {
|
|
122
|
+
fs.rmSync(this.writable(), { force: true });
|
|
123
|
+
this.stored = null;
|
|
124
|
+
this.setAt = null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private writable(): string {
|
|
128
|
+
if (this.file === null) throw new AgentCredentialError("this store keeps no credential file");
|
|
129
|
+
return this.file;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const CREDENTIAL_KINDS = ["subscription", "api-key"] as const;
|
|
2
|
+
export type CredentialKind = (typeof CREDENTIAL_KINDS)[number];
|
|
3
|
+
|
|
4
|
+
export const CREDENTIAL_KIND_LABELS: Record<CredentialKind, string> = {
|
|
5
|
+
subscription: "Claude subscription token",
|
|
6
|
+
"api-key": "Anthropic API key",
|
|
7
|
+
};
|
|
@@ -48,6 +48,8 @@ export interface FetchResult {
|
|
|
48
48
|
message?: string;
|
|
49
49
|
/** The delivery branch no longer exists on `origin`. */
|
|
50
50
|
branchDeleted?: boolean;
|
|
51
|
+
/** The delivery branch is missing on `origin` because its head was never pushed. */
|
|
52
|
+
branchUnpushed?: boolean;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
/** The first default-branch commit holding a delivery's content. */
|
|
@@ -102,6 +104,11 @@ export interface MergeGit {
|
|
|
102
104
|
* False when a merge commit brought it in; null when Git could not tell.
|
|
103
105
|
*/
|
|
104
106
|
onFirstParent(commit: string, defaultBranch: string): Promise<boolean | null>;
|
|
107
|
+
/**
|
|
108
|
+
* True when every entry of the local branch's reflog is `head`: the branch never moved since
|
|
109
|
+
* it was created there. False when one differs; null without a reflog or when Git fails.
|
|
110
|
+
*/
|
|
111
|
+
neverAdvanced(branch: string, head: string): Promise<boolean | null>;
|
|
105
112
|
/**
|
|
106
113
|
* The commit on `origin/<defaultBranch>` that carries the delivery's changes by patch
|
|
107
114
|
* identity: every branch commit (rebase), else the whole branch diff (squash). Null in a
|
|
@@ -381,6 +388,15 @@ export function mergeGit(repoPath: string, deps: MergeGitDeps = {}): MergeGit {
|
|
|
381
388
|
const parent = await value("rev-parse", `${oldest}^1`);
|
|
382
389
|
return parent ? parent === commit : null;
|
|
383
390
|
},
|
|
391
|
+
async neverAdvanced(branch, head) {
|
|
392
|
+
const reflog = await git(["reflog", "show", "--format=%H", `refs/heads/${branch}`, "--"]);
|
|
393
|
+
if (reflog.code !== 0) return null;
|
|
394
|
+
const entries = reflog.stdout
|
|
395
|
+
.split("\n")
|
|
396
|
+
.map((entry) => entry.trim())
|
|
397
|
+
.filter(Boolean);
|
|
398
|
+
return entries.length > 0 ? entries.every((entry) => entry === head) : null;
|
|
399
|
+
},
|
|
384
400
|
async patchMatch(head, defaultBranch) {
|
|
385
401
|
if (await isPartialClone()) return null;
|
|
386
402
|
const upstream = remoteRef(defaultBranch);
|
|
@@ -90,8 +90,9 @@ export interface DeliveryRequest {
|
|
|
90
90
|
/** Resolve and refuse as usual, but write nothing. */
|
|
91
91
|
dryRun?: boolean;
|
|
92
92
|
/**
|
|
93
|
-
* With `refresh`: refuse
|
|
94
|
-
*
|
|
93
|
+
* With `refresh`: refuse a delivery branch without commits of its own, and one Git settles or
|
|
94
|
+
* suggests as merged while a work tree that has it checked out holds modified tracked files,
|
|
95
|
+
* since that work is on no commit.
|
|
95
96
|
*/
|
|
96
97
|
refuseUncommitted?: boolean;
|
|
97
98
|
}
|
|
@@ -116,6 +117,8 @@ export type DeliveryRefusal =
|
|
|
116
117
|
branch: string;
|
|
117
118
|
worktree: string;
|
|
118
119
|
}
|
|
120
|
+
/** `refuseUncommitted`: the delivery branch has no commits of its own, so it delivers nothing. */
|
|
121
|
+
| { reason: "empty-delivery-branch"; change: string; repository: string; branch: string }
|
|
119
122
|
| {
|
|
120
123
|
reason: "no-delivery-branch";
|
|
121
124
|
change: string;
|
|
@@ -424,11 +427,14 @@ export async function recordDelivery(
|
|
|
424
427
|
record = refreshed.record;
|
|
425
428
|
outcomes = refreshed.outcomes;
|
|
426
429
|
for (const outcome of request.refuseUncommitted ? outcomes : []) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
+
const { repository: repo, branch } = outcome;
|
|
431
|
+
if (outcome.answerReason === "empty-branch") {
|
|
432
|
+
return { refusal: { reason: "empty-delivery-branch", change, repository: repo, branch } };
|
|
433
|
+
}
|
|
434
|
+
if (outcome.result !== "merged" && outcome.answerReason !== "likely-merged") continue;
|
|
435
|
+
const local = await access(repo).local?.();
|
|
436
|
+
const worktree = await local?.git.dirtyWorktree(branch);
|
|
430
437
|
if (worktree) {
|
|
431
|
-
const { repository: repo, branch } = outcome;
|
|
432
438
|
return {
|
|
433
439
|
refusal: { reason: "uncommitted-work", change, repository: repo, branch, worktree },
|
|
434
440
|
};
|
|
@@ -66,6 +66,11 @@ export type SubmissionState = "active" | "submitted" | "dropped";
|
|
|
66
66
|
|
|
67
67
|
const SUBMISSION_STATES: readonly SubmissionState[] = ["active", "submitted", "dropped"];
|
|
68
68
|
|
|
69
|
+
export function submissionStateOf(text: string | null): SubmissionState {
|
|
70
|
+
const state = text ? /^state:\s*["']?(\w+)["']?\s*(?:#.*)?$/m.exec(text)?.[1] : undefined;
|
|
71
|
+
return state === "submitted" || state === "dropped" ? state : "active";
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
/** Why the change's Delivery Group could not publish; cleared by resubmit, resolution or publication. */
|
|
70
75
|
export interface DeliveryBlock {
|
|
71
76
|
reason: string;
|