@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,6 +1,7 @@
|
|
|
1
1
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
+
import { signalProcessGroup, within } from "../../../runtime/host-process";
|
|
4
5
|
import type { LiveSessions, SessionCloseReason } from "./live-sessions";
|
|
5
6
|
import { tokensEqual } from "./access";
|
|
6
7
|
|
|
@@ -114,14 +115,6 @@ export const bunTerminalSpawn: TerminalSpawn = (request) => {
|
|
|
114
115
|
};
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
function signalGroup(pid: number, signal: NodeJS.Signals): void {
|
|
118
|
-
try {
|
|
119
|
-
process.kill(-pid, signal);
|
|
120
|
-
} catch {
|
|
121
|
-
/** The group is already gone. */
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
118
|
/** Keeps the newest `limit` bytes; the oldest are dropped, possibly mid-sequence. */
|
|
126
119
|
export class RingBuffer {
|
|
127
120
|
private chunks: Uint8Array[] = [];
|
|
@@ -303,7 +296,7 @@ export class TerminalRegistry {
|
|
|
303
296
|
constructor(private readonly options: TerminalRegistryOptions) {
|
|
304
297
|
this.limits = { ...TERMINAL_LIMITS, ...options.limits };
|
|
305
298
|
this.spawn = options.spawn ?? bunTerminalSpawn;
|
|
306
|
-
this.signal = options.signalGroup ??
|
|
299
|
+
this.signal = options.signalGroup ?? signalProcessGroup;
|
|
307
300
|
this.now = options.now ?? Date.now;
|
|
308
301
|
options.sessions?.closeWith((companionPath, worksetId, reason) =>
|
|
309
302
|
this.endWorkset(companionPath, worksetId, reason),
|
|
@@ -735,11 +728,7 @@ export class TerminalRegistry {
|
|
|
735
728
|
const connection = [...this.connections].find((c) => c.viewer === viewer);
|
|
736
729
|
if (connection) connection.session = null;
|
|
737
730
|
}
|
|
738
|
-
const wait = (ms: number) =>
|
|
739
|
-
Promise.race([
|
|
740
|
-
session.process.exited.then(() => true),
|
|
741
|
-
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), ms)),
|
|
742
|
-
]);
|
|
731
|
+
const wait = (ms: number) => within(session.process.exited, ms);
|
|
743
732
|
session.ending = (async () => {
|
|
744
733
|
if (!session.exited) {
|
|
745
734
|
this.signal(session.process.pid, "SIGTERM");
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { companionTicketFormat, TICKETS_OFF } from "../../../lib/delivery/branches";
|
|
2
|
+
import type { Operator } from "../../../lib/workset/claims";
|
|
3
|
+
import { findEntry, ownershipFacts } from "../../../lib/workset/execution";
|
|
4
|
+
import {
|
|
5
|
+
configuredOperator,
|
|
6
|
+
type GitFailure,
|
|
7
|
+
isGitBacked,
|
|
8
|
+
workGit,
|
|
9
|
+
} from "../../../lib/workset/git-transaction";
|
|
10
|
+
import {
|
|
11
|
+
activeMembers,
|
|
12
|
+
type InventoryWorkset,
|
|
13
|
+
readWorkInventory,
|
|
14
|
+
} from "../../../lib/workset/inventory";
|
|
15
|
+
import {
|
|
16
|
+
LOCAL_ONLY,
|
|
17
|
+
NO_OPERATOR,
|
|
18
|
+
projectWorkCard,
|
|
19
|
+
type WorkActionId,
|
|
20
|
+
type WorkCard,
|
|
21
|
+
type WorkContext,
|
|
22
|
+
type WorkFacts,
|
|
23
|
+
type WorkMemberStatus,
|
|
24
|
+
unsynced,
|
|
25
|
+
workActionRefusalOf,
|
|
26
|
+
} from "../../../lib/workset/projection";
|
|
27
|
+
import { createOutcome, WorksetError } from "../../../lib/workset/record";
|
|
28
|
+
import { branchProbe, linkedRepositoryIdentities } from "../../../lib/workset/repositories";
|
|
29
|
+
import { deriveWorksetStage, type WorksetStageId } from "../../../lib/workset/stage";
|
|
30
|
+
import { collectChangeFacts } from "../../../lib/workset/stages";
|
|
31
|
+
import {
|
|
32
|
+
claimGroupOf,
|
|
33
|
+
confirmShare,
|
|
34
|
+
planProblems,
|
|
35
|
+
previewShare,
|
|
36
|
+
readTeamBacklog,
|
|
37
|
+
refreshTeam,
|
|
38
|
+
type RemoteBacklog,
|
|
39
|
+
remoteOnlyEntries,
|
|
40
|
+
type SharePreview,
|
|
41
|
+
type TeamStatus,
|
|
42
|
+
} from "../../../lib/workset/sharing";
|
|
43
|
+
import { sameMembers, updateClaim } from "../../../lib/workset/transactions";
|
|
44
|
+
import { readSubmittedFolders } from "../../../runtime/companion-git-state";
|
|
45
|
+
import { pendingSubmittedChanges } from "../../../runtime/pending-records";
|
|
46
|
+
import { WORK_ACTIONS, skillInstalledFor } from "./actions";
|
|
47
|
+
import type { StudioSkillInventory } from "./mate-inventory";
|
|
48
|
+
import type { StudioChange, StudioShippedChange } from "./payload";
|
|
49
|
+
import type { TerminalAgent } from "./terminal";
|
|
50
|
+
|
|
51
|
+
export interface WorkLaunchOffer {
|
|
52
|
+
action: string;
|
|
53
|
+
subject: string;
|
|
54
|
+
label: string;
|
|
55
|
+
prompts: Partial<Record<TerminalAgent, string>>;
|
|
56
|
+
runAgents: TerminalAgent[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface StudioWorkCard extends WorkCard {
|
|
60
|
+
title: string;
|
|
61
|
+
memberNames: string[];
|
|
62
|
+
claimMemberNames: string[];
|
|
63
|
+
offers: WorkLaunchOffer[];
|
|
64
|
+
needsYou: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface StudioWorkTeam {
|
|
68
|
+
remote?: string;
|
|
69
|
+
branch?: string;
|
|
70
|
+
fetchedAt?: string;
|
|
71
|
+
failure?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface StudioWorkPayload {
|
|
75
|
+
writable: boolean;
|
|
76
|
+
operator: Operator | null;
|
|
77
|
+
gitBacked: boolean;
|
|
78
|
+
team: StudioWorkTeam;
|
|
79
|
+
cards: StudioWorkCard[];
|
|
80
|
+
linkedRepositories: string[];
|
|
81
|
+
ticketFormat: string;
|
|
82
|
+
diagnostics: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface WorkInput {
|
|
86
|
+
changes: readonly StudioChange[];
|
|
87
|
+
shipped: readonly StudioShippedChange[];
|
|
88
|
+
writable: boolean;
|
|
89
|
+
skills?: StudioSkillInventory;
|
|
90
|
+
terminalAgents?: TerminalAgent[];
|
|
91
|
+
linkedRepositories?: string[];
|
|
92
|
+
ticketFormat?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function needsPerson(card: WorkCard): boolean {
|
|
96
|
+
if (card.done || card.bucket !== "local") return false;
|
|
97
|
+
return ["human-review", "merge-wait", "publish"].includes(card.stage);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function teamOf(status: TeamStatus): StudioWorkTeam {
|
|
101
|
+
return {
|
|
102
|
+
...(status.shared ? { remote: status.shared.remote, branch: status.shared.branch } : {}),
|
|
103
|
+
...(status.fetchedAt ? { fetchedAt: status.fetchedAt } : {}),
|
|
104
|
+
...(status.failure ? { failure: status.failure.message } : {}),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const AGENTS: readonly TerminalAgent[] = ["claude", "opencode"];
|
|
109
|
+
|
|
110
|
+
function wantedOffers(
|
|
111
|
+
entry: InventoryWorkset,
|
|
112
|
+
stage: WorksetStageId,
|
|
113
|
+
members: readonly WorkMemberStatus[],
|
|
114
|
+
): { id: string; subject: string }[] {
|
|
115
|
+
const active = activeMembers(entry);
|
|
116
|
+
if (entry.record.changes.length === 0) {
|
|
117
|
+
return [
|
|
118
|
+
{ id: "explore-workset", subject: entry.id },
|
|
119
|
+
{ id: "propose-workset", subject: entry.id },
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
if (active.length === 0) {
|
|
123
|
+
const id = stage === "clarify-intent" ? "explore-workset" : "propose-workset";
|
|
124
|
+
return [{ id, subject: entry.id }];
|
|
125
|
+
}
|
|
126
|
+
if (stage === "propose") return [{ id: "propose-workset", subject: entry.id }];
|
|
127
|
+
if (stage === "human-review" || stage === "apply") {
|
|
128
|
+
const waiting = new Set(
|
|
129
|
+
members
|
|
130
|
+
.filter((member) => member.stage !== "human-review" && member.stage !== "apply")
|
|
131
|
+
.map((member) => member.name),
|
|
132
|
+
);
|
|
133
|
+
return active
|
|
134
|
+
.filter((change) => !waiting.has(change))
|
|
135
|
+
.map((change) => ({ id: "apply-change", subject: change }));
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function offersFor(facts: WorkFacts, input: WorkInput): WorkLaunchOffer[] {
|
|
141
|
+
if (!input.skills) return [];
|
|
142
|
+
return wantedOffers(facts.inventory, facts.stage.stage, facts.members).flatMap(
|
|
143
|
+
({ id, subject }) => {
|
|
144
|
+
const action = WORK_ACTIONS.find((candidate) => candidate.id === id)!;
|
|
145
|
+
const copy = AGENTS.filter((agent) => skillInstalledFor(input.skills!, action.skill, agent));
|
|
146
|
+
if (copy.length === 0) return [];
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
action: action.id,
|
|
150
|
+
subject,
|
|
151
|
+
label: action.label,
|
|
152
|
+
prompts: Object.fromEntries(copy.map((agent) => [agent, action.prompts[agent](subject)])),
|
|
153
|
+
runAgents: copy.filter((agent) => input.terminalAgents?.includes(agent)),
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface WorkModel {
|
|
161
|
+
context: WorkContext;
|
|
162
|
+
facts: Map<string, WorkFacts>;
|
|
163
|
+
backlog: RemoteBacklog;
|
|
164
|
+
diagnostics: string[];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function readWorkModel(
|
|
168
|
+
companionPath: string,
|
|
169
|
+
input: WorkInput,
|
|
170
|
+
lastFailure?: GitFailure,
|
|
171
|
+
): Promise<WorkModel> {
|
|
172
|
+
const git = workGit(companionPath);
|
|
173
|
+
const gitBacked = await isGitBacked(git);
|
|
174
|
+
const [inventory, backlog, operator, pending] = await Promise.all([
|
|
175
|
+
readWorkInventory(companionPath),
|
|
176
|
+
readTeamBacklog(companionPath, lastFailure),
|
|
177
|
+
gitBacked ? configuredOperator(git) : Promise.resolve(null),
|
|
178
|
+
gitBacked ? pendingSubmittedChanges(companionPath) : Promise.resolve([]),
|
|
179
|
+
]);
|
|
180
|
+
const local = new Set(
|
|
181
|
+
inventory.worksets.flatMap((entry) => entry.members.map((member) => member.name)),
|
|
182
|
+
);
|
|
183
|
+
const localIds = new Set(inventory.worksets.map((entry) => entry.id));
|
|
184
|
+
const remote = remoteOnlyEntries(backlog, local);
|
|
185
|
+
const shadowed = new Set(remote.filter((entry) => localIds.has(entry.id)).map((e) => e.id));
|
|
186
|
+
const entries = [
|
|
187
|
+
...inventory.worksets.map((entry) =>
|
|
188
|
+
shadowed.has(entry.id)
|
|
189
|
+
? {
|
|
190
|
+
...entry,
|
|
191
|
+
diagnostics: [
|
|
192
|
+
...entry.diagnostics,
|
|
193
|
+
`shared work on the inbox is also named ${entry.id}; rename one of them`,
|
|
194
|
+
],
|
|
195
|
+
actionable: false,
|
|
196
|
+
}
|
|
197
|
+
: entry,
|
|
198
|
+
),
|
|
199
|
+
...remote.filter((entry) => !shadowed.has(entry.id)),
|
|
200
|
+
];
|
|
201
|
+
const published = new Set(input.shipped.map((change) => change.anchor));
|
|
202
|
+
const changeFacts = await collectChangeFacts(
|
|
203
|
+
companionPath,
|
|
204
|
+
entries.flatMap((entry) => entry.members),
|
|
205
|
+
input.changes,
|
|
206
|
+
published,
|
|
207
|
+
{ submitted: new Set(pending.map((change) => change.name)) },
|
|
208
|
+
);
|
|
209
|
+
const reads = {
|
|
210
|
+
branchHere: branchProbe(companionPath),
|
|
211
|
+
recorded: gitBacked ? readSubmittedFolders(companionPath) : {},
|
|
212
|
+
};
|
|
213
|
+
const context: WorkContext = {
|
|
214
|
+
writable: input.writable,
|
|
215
|
+
...(operator ? { operator } : {}),
|
|
216
|
+
gitBacked,
|
|
217
|
+
};
|
|
218
|
+
const facts = new Map<string, WorkFacts>();
|
|
219
|
+
await Promise.all(
|
|
220
|
+
entries.map(async (entry) => {
|
|
221
|
+
const stage = deriveWorksetStage(entry.record, entry.members, (name) =>
|
|
222
|
+
changeFacts.get(name),
|
|
223
|
+
);
|
|
224
|
+
const ownership = gitBacked
|
|
225
|
+
? await ownershipFacts(companionPath, entry, backlog, operator ?? undefined, reads)
|
|
226
|
+
: {
|
|
227
|
+
sharing: LOCAL_ONLY,
|
|
228
|
+
claim: { kind: "none" as const },
|
|
229
|
+
progress: { kind: "none" as const },
|
|
230
|
+
};
|
|
231
|
+
const members: WorkMemberStatus[] = entry.members.map((member) => {
|
|
232
|
+
const fact = changeFacts.get(member.name);
|
|
233
|
+
const memberStage = fact
|
|
234
|
+
? deriveWorksetStage({ ...entry.record, changes: [member.name] }, [member], () => fact)
|
|
235
|
+
: stage;
|
|
236
|
+
return {
|
|
237
|
+
name: member.name,
|
|
238
|
+
stage: memberStage.stage,
|
|
239
|
+
stageLabel: memberStage.label,
|
|
240
|
+
delivered: memberStage.stage === "done",
|
|
241
|
+
...(member.kind === "missing" ? { problem: "neither active nor archived" } : {}),
|
|
242
|
+
...(member.kind === "conflict" ? { problem: "listed by another Workset" } : {}),
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
facts.set(entry.id, { inventory: entry, stage, members, ...ownership });
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
return {
|
|
249
|
+
context,
|
|
250
|
+
facts,
|
|
251
|
+
backlog,
|
|
252
|
+
diagnostics: inventory.diagnostics,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function assembleWork(
|
|
257
|
+
companionPath: string,
|
|
258
|
+
input: WorkInput,
|
|
259
|
+
lastFailure?: GitFailure,
|
|
260
|
+
): Promise<StudioWorkPayload> {
|
|
261
|
+
const model = await readWorkModel(companionPath, input, lastFailure);
|
|
262
|
+
const cards = [...model.facts.values()]
|
|
263
|
+
.map((facts): StudioWorkCard => {
|
|
264
|
+
const card = projectWorkCard(facts, model.context);
|
|
265
|
+
const entry = facts.inventory;
|
|
266
|
+
const holdsSharedCopy = card.bucket !== "remote" && !unsynced(facts.sharing);
|
|
267
|
+
return {
|
|
268
|
+
...card,
|
|
269
|
+
title: entry.record.title,
|
|
270
|
+
memberNames: activeMembers(entry),
|
|
271
|
+
claimMemberNames: claimGroupOf(entry, model.backlog),
|
|
272
|
+
offers: holdsSharedCopy ? offersFor(facts, input) : [],
|
|
273
|
+
needsYou: needsPerson(card),
|
|
274
|
+
};
|
|
275
|
+
})
|
|
276
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
277
|
+
return {
|
|
278
|
+
writable: input.writable,
|
|
279
|
+
operator: model.context.operator ?? null,
|
|
280
|
+
gitBacked: model.context.gitBacked,
|
|
281
|
+
team: teamOf(model.backlog.status),
|
|
282
|
+
cards,
|
|
283
|
+
linkedRepositories: input.linkedRepositories ?? [],
|
|
284
|
+
ticketFormat: input.ticketFormat ?? "none",
|
|
285
|
+
diagnostics: model.diagnostics,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export type WorkRequest =
|
|
290
|
+
| { action: "capture"; text: string; repository?: string; ticket?: string }
|
|
291
|
+
| { action: "refresh" }
|
|
292
|
+
| { action: "share-preview"; workset: string; include?: string[] }
|
|
293
|
+
| { action: "share"; workset: string; hash: string; include?: string[]; key: string }
|
|
294
|
+
| { action: "claim" | "release"; workset: string; members: string[]; key: string }
|
|
295
|
+
| { action: "start-manual"; workset: string; members: string[] };
|
|
296
|
+
|
|
297
|
+
export type WorkRefusalKind = "prerequisite" | "access" | "conflict" | "stale" | "failed";
|
|
298
|
+
|
|
299
|
+
export type WorkResult =
|
|
300
|
+
| {
|
|
301
|
+
ok: true;
|
|
302
|
+
preview?: SharePreview;
|
|
303
|
+
prompts?: Partial<Record<TerminalAgent, string>>[];
|
|
304
|
+
needsTake?: string[];
|
|
305
|
+
}
|
|
306
|
+
| { ok: false; kind: WorkRefusalKind; reason: string };
|
|
307
|
+
|
|
308
|
+
export interface WorkServiceDeps {
|
|
309
|
+
writable: boolean;
|
|
310
|
+
inputFor: (companionPath: string, refresh?: boolean) => Promise<Omit<WorkInput, "writable">>;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const NOT_WRITABLE = "start Studio with --writable to change Work";
|
|
314
|
+
|
|
315
|
+
function refusal(kind: WorkRefusalKind, reason: string): WorkResult {
|
|
316
|
+
return { ok: false, kind, reason };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function policyActionOf(
|
|
320
|
+
action: Exclude<WorkRequest["action"], "refresh" | "capture">,
|
|
321
|
+
): WorkActionId {
|
|
322
|
+
return action === "share-preview" ? "share" : action;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function capture(
|
|
326
|
+
companionPath: string,
|
|
327
|
+
request: Extract<WorkRequest, { action: "capture" }>,
|
|
328
|
+
): Promise<WorkResult> {
|
|
329
|
+
const ticket = request.ticket?.trim();
|
|
330
|
+
if (ticket && (await companionTicketFormat(companionPath)) !== "jira") {
|
|
331
|
+
throw new WorksetError(TICKETS_OFF);
|
|
332
|
+
}
|
|
333
|
+
await createOutcome(
|
|
334
|
+
companionPath,
|
|
335
|
+
{ text: request.text, repository: request.repository ?? "", ...(ticket ? { ticket } : {}) },
|
|
336
|
+
await linkedRepositoryIdentities(companionPath),
|
|
337
|
+
);
|
|
338
|
+
return { ok: true };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function createWorkServices(deps: WorkServiceDeps) {
|
|
342
|
+
const failures = new Map<string, GitFailure>();
|
|
343
|
+
|
|
344
|
+
const inputOf = async (companionPath: string): Promise<WorkInput> => ({
|
|
345
|
+
...(await deps.inputFor(companionPath)),
|
|
346
|
+
writable: deps.writable,
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
async function act(companionPath: string, request: WorkRequest): Promise<WorkResult> {
|
|
350
|
+
if (request.action === "refresh") {
|
|
351
|
+
const [refreshed] = await Promise.all([
|
|
352
|
+
refreshTeam(companionPath),
|
|
353
|
+
deps.inputFor(companionPath, true).catch(() => undefined),
|
|
354
|
+
]);
|
|
355
|
+
if ("failure" in refreshed) {
|
|
356
|
+
failures.set(companionPath, refreshed.failure);
|
|
357
|
+
return refusal("failed", refreshed.failure.message);
|
|
358
|
+
}
|
|
359
|
+
failures.delete(companionPath);
|
|
360
|
+
return { ok: true };
|
|
361
|
+
}
|
|
362
|
+
if (!deps.writable) return refusal("access", NOT_WRITABLE);
|
|
363
|
+
if (request.action === "capture") return capture(companionPath, request);
|
|
364
|
+
|
|
365
|
+
const input = await inputOf(companionPath);
|
|
366
|
+
const model = await readWorkModel(companionPath, input, failures.get(companionPath));
|
|
367
|
+
const facts = model.facts.get(request.workset);
|
|
368
|
+
if (!facts) return refusal("prerequisite", `no Workset ${request.workset}`);
|
|
369
|
+
const entry = facts.inventory;
|
|
370
|
+
const refused = workActionRefusalOf(policyActionOf(request.action), facts, model.context);
|
|
371
|
+
if (refused) return refusal(refused.kind, refused.reason);
|
|
372
|
+
const operator = model.context.operator;
|
|
373
|
+
const members = activeMembers(facts.inventory);
|
|
374
|
+
const bound =
|
|
375
|
+
request.action === "claim" || request.action === "release"
|
|
376
|
+
? claimGroupOf(entry, model.backlog)
|
|
377
|
+
: members;
|
|
378
|
+
if ("members" in request && !sameMembers(bound, request.members)) {
|
|
379
|
+
return refusal("stale", `its changes are now ${bound.join(", ")}; review it again`);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
switch (request.action) {
|
|
383
|
+
case "share-preview": {
|
|
384
|
+
const preview = await previewShare(companionPath, entry, model.backlog, {
|
|
385
|
+
include: request.include,
|
|
386
|
+
});
|
|
387
|
+
return "refusal" in preview
|
|
388
|
+
? refusal("prerequisite", preview.refusal)
|
|
389
|
+
: { ok: true, preview: preview.preview };
|
|
390
|
+
}
|
|
391
|
+
case "share": {
|
|
392
|
+
const outcome = await confirmShare(
|
|
393
|
+
companionPath,
|
|
394
|
+
{ hash: request.hash, include: request.include, transactionId: `tx-${request.key}` },
|
|
395
|
+
{
|
|
396
|
+
inventoryEntry: async (backlog) =>
|
|
397
|
+
findEntry(await readWorkInventory(companionPath), backlog, request.workset),
|
|
398
|
+
},
|
|
399
|
+
);
|
|
400
|
+
if (outcome.status === "shared") {
|
|
401
|
+
failures.delete(companionPath);
|
|
402
|
+
return { ok: true };
|
|
403
|
+
}
|
|
404
|
+
if (outcome.status === "failed") return refusal("failed", outcome.failure.message);
|
|
405
|
+
return refusal(outcome.status === "stale" ? "stale" : "conflict", outcome.reason);
|
|
406
|
+
}
|
|
407
|
+
case "claim":
|
|
408
|
+
case "release": {
|
|
409
|
+
if (!operator) return refusal("prerequisite", NO_OPERATOR);
|
|
410
|
+
const outcome = await updateClaim(companionPath, {
|
|
411
|
+
action: request.action,
|
|
412
|
+
members: request.members,
|
|
413
|
+
operator,
|
|
414
|
+
transactionId: `tx-${request.key}`,
|
|
415
|
+
workset: entry.id,
|
|
416
|
+
});
|
|
417
|
+
if (outcome.status === "accepted") {
|
|
418
|
+
failures.delete(companionPath);
|
|
419
|
+
return {
|
|
420
|
+
ok: true,
|
|
421
|
+
...(outcome.needsTake.length > 0 ? { needsTake: outcome.needsTake } : {}),
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
if (outcome.status === "failed") return refusal("failed", outcome.failure.message);
|
|
425
|
+
if (outcome.status === "stale") return refusal("stale", outcome.reason);
|
|
426
|
+
return refusal(outcome.kind, outcome.reason);
|
|
427
|
+
}
|
|
428
|
+
case "start-manual": {
|
|
429
|
+
const offers = offersFor(facts, input);
|
|
430
|
+
const needsPlan = offers.some((offer) => offer.action === "apply-change");
|
|
431
|
+
const problems = needsPlan ? await planProblems(companionPath, members) : [];
|
|
432
|
+
if (problems.length > 0) return refusal("conflict", problems.join("; "));
|
|
433
|
+
return { ok: true, prompts: offers.map((offer) => offer.prompts) };
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async function reserveStart(
|
|
439
|
+
companionPath: string,
|
|
440
|
+
subject: { kind: "workset" | "change"; name: string },
|
|
441
|
+
): Promise<string | null> {
|
|
442
|
+
const model = await readWorkModel(
|
|
443
|
+
companionPath,
|
|
444
|
+
await inputOf(companionPath),
|
|
445
|
+
failures.get(companionPath),
|
|
446
|
+
);
|
|
447
|
+
const facts = [...model.facts.values()].find(({ inventory }) =>
|
|
448
|
+
subject.kind === "workset"
|
|
449
|
+
? inventory.id === subject.name
|
|
450
|
+
: inventory.members.some(
|
|
451
|
+
(member) => member.kind === "active" && member.name === subject.name,
|
|
452
|
+
),
|
|
453
|
+
);
|
|
454
|
+
if (!facts) return `this companion has no ${subject.kind} named ${subject.name}`;
|
|
455
|
+
const { inventory } = facts;
|
|
456
|
+
const members = activeMembers(inventory);
|
|
457
|
+
if (members.length === 0) {
|
|
458
|
+
return inventory.actionable ? null : (inventory.diagnostics[0] ?? "it cannot be started");
|
|
459
|
+
}
|
|
460
|
+
const refused = workActionRefusalOf("start-manual", facts, model.context);
|
|
461
|
+
if (refused) return refused.reason;
|
|
462
|
+
const problems = subject.kind === "change" ? await planProblems(companionPath, members) : [];
|
|
463
|
+
return problems.length > 0 ? problems.join("; ") : null;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return {
|
|
467
|
+
async work(companionPath: string): Promise<StudioWorkPayload> {
|
|
468
|
+
return assembleWork(companionPath, await inputOf(companionPath), failures.get(companionPath));
|
|
469
|
+
},
|
|
470
|
+
act,
|
|
471
|
+
reserveStart,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0
|
|
3
|
-
"sha512": "sha512-
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"sha512": "sha512-pUKQLcYiKxPD5TZmBeRaY9b49n2Jl7gXHfXThaTAOmDF3hA2pAyT0uEBMV4ZZmJ2M2oXmq+rxCf2Fzkwu3O77g=="
|
|
4
4
|
}
|
|
@@ -3,12 +3,10 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
|
|
6
|
-
import { parse } from "yaml";
|
|
7
|
-
|
|
8
6
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
9
7
|
import { gitEnvironment } from "../../../runtime/companion-git";
|
|
10
8
|
import { checkoutCommonDir } from "../../../runtime/git-layout";
|
|
11
|
-
import type
|
|
9
|
+
import { localRootKind, type RootKind } from "../../../lib/orchestrator/root-context";
|
|
12
10
|
import {
|
|
13
11
|
collectWorkspaceInventory,
|
|
14
12
|
type WorkspaceInventoryPairingEntry,
|
|
@@ -60,21 +58,6 @@ export async function resolveUmbrella(cwd: string): Promise<string | null> {
|
|
|
60
58
|
return folder ? canonicalPath(folder) : null;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
async function localRootKind(repoPath: string): Promise<RootKind | null> {
|
|
64
|
-
try {
|
|
65
|
-
const raw = await fs.readFile(
|
|
66
|
-
path.join(repoPath, `.${FRAMEWORK_NAME}`, "config", "framework.yaml"),
|
|
67
|
-
"utf8",
|
|
68
|
-
);
|
|
69
|
-
const config = parse(raw) as { type?: string } | null;
|
|
70
|
-
if (config?.type === "working" || config?.type === "hub") return config.type;
|
|
71
|
-
return "companion";
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;
|
|
74
|
-
return "companion";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
61
|
const defaultDeps: WorkingCleanupCommandDeps = {
|
|
79
62
|
cwd: process.cwd(),
|
|
80
63
|
resolveGitRoot,
|