@uniqbit/mate-core 1.0.0-canary.0 → 1.0.0-canary.2
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/marketplace.json +14 -0
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
- package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
- package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
- package/claude-plugin/hooks/hooks.json +10 -1
- package/claude-plugin/hooks/tokensave-route.mjs +52 -0
- package/opencode-plugin/src/server.ts +4 -0
- package/opencode-plugin/src/tui.tsx +2 -0
- package/opencode-plugin/tui.tsx +2 -0
- package/package.json +45 -16
- package/src/brand/terminal.ts +5 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +4 -0
- package/src/cli/commands/artifact/delivery/archive.ts +13 -5
- package/src/cli/commands/artifact/delivery/environment.ts +36 -13
- package/src/cli/commands/artifact/delivery/link.ts +35 -15
- package/src/cli/commands/artifact/delivery/output.ts +31 -0
- package/src/cli/commands/artifact/finish/command.ts +50 -5
- package/src/cli/commands/artifact/finish/engine.ts +44 -11
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +6 -1
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/cap/index-cmd.ts +64 -15
- package/src/cli/commands/cap/tokensave.ts +7 -5
- package/src/cli/commands/companion/link.ts +14 -1
- package/src/cli/commands/companion/open.ts +16 -11
- package/src/cli/commands/companion/sync.ts +10 -0
- package/src/cli/commands/companion/tui.ts +17 -7
- package/src/cli/commands/companion/update.ts +74 -12
- package/src/cli/commands/doctor.ts +20 -5
- package/src/cli/commands/factory/factory.ts +301 -0
- package/src/cli/commands/install.ts +133 -9
- package/src/cli/commands/launch/shared.ts +16 -11
- package/src/cli/commands/report/index.ts +20 -1
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/setup.ts +44 -10
- package/src/cli/commands/studio/factory-credential.ts +49 -0
- package/src/cli/commands/studio/index.ts +29 -2
- package/src/cli/commands/studio/payload.ts +249 -15
- package/src/cli/commands/studio/routes.ts +41 -8
- package/src/cli/commands/studio/selection.ts +142 -16
- package/src/cli/commands/studio/server.ts +403 -364
- package/src/cli/commands/studio/services.ts +60 -0
- package/src/cli/commands/studio/studio-app.ts +67 -0
- package/src/cli/commands/studio/terminal-assets.ts +21 -33
- package/src/cli/commands/studio/terminal.ts +85 -15
- package/src/cli/commands/studio/views/model.ts +18 -0
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +267 -0
- package/src/cli/commands/studio/views/vault/view.ts +185 -0
- package/src/cli/commands/studio/workset-session.ts +131 -0
- package/src/cli/commands/unwrap.ts +8 -0
- package/src/cli/commands/update.ts +27 -1
- package/src/cli/commands/working/cleanup.ts +10 -1
- package/src/cli/commands/working/link.ts +76 -0
- package/src/cli/commands/working/working.ts +10 -0
- package/src/cli/commands/working/worktree.ts +356 -0
- package/src/cli/companion-link-wizard.tsx +2 -0
- package/src/cli/companion-selector.tsx +2 -0
- package/src/cli/confirm.ts +2 -0
- package/src/cli/install-plan.tsx +127 -160
- package/src/cli/launch-selector.tsx +2 -0
- package/src/cli/main.ts +18 -0
- package/src/cli/parse-flags.ts +9 -1
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +79 -20
- package/src/cli/usage.ts +11 -1
- package/src/create-mate.ts +5 -4
- package/src/hooks/tokensave-route.ts +26 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -0
- package/src/lib/components/confirm-prompt.tsx +21 -9
- package/src/lib/components/select-menu.tsx +10 -3
- package/src/lib/components/spinner.tsx +4 -2
- package/src/lib/components/startup-progress.tsx +227 -41
- package/src/lib/components/text-input-display.tsx +2 -0
- package/src/lib/components/wizard-footer.tsx +2 -0
- package/src/lib/components/wizard-header.tsx +13 -11
- package/src/lib/delivery/archive-change.ts +14 -2
- package/src/lib/delivery/branches.ts +29 -5
- package/src/lib/delivery/environment.ts +7 -1
- package/src/lib/delivery/forge.ts +2 -2
- package/src/lib/delivery/merge-git.ts +261 -0
- package/src/lib/delivery/overlap.ts +11 -4
- package/src/lib/delivery/record-delivery.ts +97 -10
- package/src/lib/delivery/record.ts +67 -7
- package/src/lib/delivery/refresh.ts +104 -10
- package/src/lib/delivery/repository-access.ts +46 -2
- package/src/lib/delivery/resolve-branch.ts +162 -0
- package/src/lib/delivery/token.ts +7 -41
- package/src/lib/factory/attach-client.ts +113 -0
- package/src/lib/factory/attach.ts +178 -0
- package/src/lib/factory/broker.ts +190 -0
- package/src/lib/factory/bun-commands.ts +39 -0
- package/src/lib/factory/client.ts +92 -0
- package/src/lib/factory/command.ts +61 -0
- package/src/lib/factory/credential-store.ts +153 -0
- package/src/lib/factory/frames.ts +77 -0
- package/src/lib/factory/ids.ts +58 -0
- package/src/lib/factory/keyed-serial.ts +27 -0
- package/src/lib/factory/outcomes/actions.ts +114 -0
- package/src/lib/factory/outcomes/index.ts +381 -0
- package/src/lib/factory/outcomes/lifecycle.ts +205 -0
- package/src/lib/factory/outcomes/runs.ts +81 -0
- package/src/lib/factory/outcomes/sessions.ts +38 -0
- package/src/lib/factory/prepare.ts +49 -0
- package/src/lib/factory/pty.ts +103 -0
- package/src/lib/factory/runner/companion-context.ts +178 -0
- package/src/lib/factory/runner/control.ts +92 -0
- package/src/lib/factory/runner/harness-agent.ts +250 -0
- package/src/lib/factory/runner/live.ts +159 -0
- package/src/lib/factory/runner/questions.ts +22 -0
- package/src/lib/factory/runner/rank.ts +26 -0
- package/src/lib/factory/runner/run-policy.ts +12 -0
- package/src/lib/factory/runner/run.ts +199 -0
- package/src/lib/factory/runner/scheduler.ts +416 -0
- package/src/lib/factory/runner/state.ts +233 -0
- package/src/lib/factory/runner/workflow.ts +542 -0
- package/src/lib/factory/runtime.ts +972 -0
- package/src/lib/factory/sandbox.ts +292 -0
- package/src/lib/factory/worktree-branch.ts +17 -0
- package/src/lib/install.ts +66 -14
- package/src/lib/live-progress.ts +36 -0
- package/src/lib/member-choices.ts +67 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude.ts +6 -1
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +29 -23
- package/src/lib/orchestrator/projection-entries.ts +56 -21
- package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
- package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
- package/src/lib/orchestrator/projection-types.ts +33 -1
- package/src/lib/orchestrator/session-context-link.ts +67 -0
- package/src/lib/orchestrator/setup-compatibilities.ts +55 -12
- package/src/lib/orchestrator/types.ts +5 -0
- package/src/lib/orchestrator/working-repo-projection.ts +50 -7
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/package-paths.ts +29 -0
- package/src/lib/runtime-directory-refresh.ts +17 -1
- package/src/lib/workset/record.ts +513 -0
- package/src/lib/workset/repositories.ts +55 -0
- package/src/lib/workset/stage.ts +148 -0
- package/src/lib/workset/stages.ts +113 -0
- package/src/lib/workset/worktree-index.ts +116 -0
- package/src/lib/workset/worktree.ts +830 -0
- package/src/opencode/companion-hooks.ts +45 -2
- package/src/opencode/enter-worktree.ts +72 -0
- package/src/opencode/tui.tsx +9 -4
- package/src/plugins.ts +1 -0
- package/src/runtime/claude-delivery-plan.ts +22 -5
- package/src/runtime/companion-git.ts +52 -10
- package/src/runtime/companion-guidance.ts +7 -7
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/env.ts +48 -3
- package/src/runtime/git-layout.ts +219 -0
- package/src/runtime/index.ts +24 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +36 -2
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/secret-guard.ts +19 -5
- package/src/runtime/secret-patterns.ts +267 -34
- package/src/runtime/session-context.ts +98 -0
- package/src/runtime/tokensave-route.ts +152 -0
- package/src/runtime/wrap-state.ts +24 -16
- package/src/studio.ts +124 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +10 -8
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +16 -98
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +10 -2
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +76 -18
- package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +2 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +32 -5
- package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +8 -1
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +16 -1
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +22 -6
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +2 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +8 -1
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +7 -0
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +55 -50
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +47 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +2 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +2 -0
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +29 -10
- package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +4 -2
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +21 -0
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +13 -0
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +76 -18
- package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +2 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +32 -5
- package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +8 -1
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +16 -1
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +22 -6
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +2 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +8 -1
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +7 -0
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +55 -50
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +47 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +2 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +2 -0
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +29 -10
- package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +4 -2
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +21 -0
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +13 -0
- package/src/templates/mate-skills/openspec-references.ts +2 -0
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +364 -224
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +34 -5
- package/src/tools/setup/capabilities/graphify-secrets.ts +2 -14
- package/src/tools/setup/capabilities/graphify.ts +34 -7
- package/src/tools/setup/capabilities/openspec.ts +12 -2
- package/src/tools/setup/capabilities/react-doctor.ts +8 -1
- package/src/tools/setup/capabilities/rtk.ts +4 -0
- package/src/tools/setup/capabilities/tokensave.ts +77 -68
- package/src/tools/setup/engine.ts +3 -2
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +5 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +11 -5
- package/src/tools/setup/utils.ts +4 -0
- package/src/tools/setup/working-repo-cleanup.ts +29 -1
- package/src/tools/setup/working-repo-local-state.ts +252 -75
- package/src/tools/setup.ts +57 -16
- package/studio-dist/client/assets/companion-view-Csva26Ir.js +1 -0
- package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +1 -0
- package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
- package/studio-dist/client/assets/factory-B7l9ZQyx.js +4 -0
- package/studio-dist/client/assets/index-n6uo_92S.js +40 -0
- package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
- package/studio-dist/client/assets/prepaint-CD5OpmTM.js +24 -0
- package/studio-dist/client/assets/queries-CN3JwMBX.js +1 -0
- package/studio-dist/client/assets/react-CabXf2Ds.js +1 -0
- package/studio-dist/client/assets/report-time-Dc-KOqQu.js +1 -0
- package/studio-dist/client/assets/reports-C01RsnMA.js +1 -0
- package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
- package/studio-dist/client/assets/routes-4pbC-2Hj.js +1 -0
- package/studio-dist/client/assets/skills-CihQganl.js +1 -0
- package/studio-dist/client/assets/spec-areas-C2L48N4C.js +1 -0
- package/studio-dist/client/assets/specs-D24_35_K.js +1 -0
- package/studio-dist/client/assets/studio-DKxfi691.css +1 -0
- package/studio-dist/client/assets/studio-queries-rvbJupCy.js +3 -0
- package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
- package/studio-dist/client/assets/vault-Bd4CQiTK.js +1 -0
- package/studio-dist/client/assets/warnings-V_Ys51wJ.js +1 -0
- package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
- package/studio-dist/client/assets/workflow-BJejeVwQ.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-BQKuMdJW.js +3881 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +85 -0
- package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
- package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
- package/studio-dist/server/assets/companion-view-aBady57v.js +33 -0
- package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
- package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
- package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +778 -0
- package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
- package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
- package/studio-dist/server/assets/factory-D6xnjedJ.js +2385 -0
- package/studio-dist/server/assets/factory-DT3UzHlh.js +68 -0
- package/studio-dist/server/assets/model-PyPALjii.js +18 -0
- package/studio-dist/server/assets/prepaint-BMke0fo1.js +41 -0
- package/studio-dist/server/assets/queries-Ag2iL8q2.js +107 -0
- package/studio-dist/server/assets/react-COs0LHn-.js +51 -0
- package/studio-dist/server/assets/report-time-DAfzln-N.js +8 -0
- package/studio-dist/server/assets/reports-BnUNJVtx.js +126 -0
- package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
- package/studio-dist/server/assets/router-BH--drIx.js +4298 -0
- package/studio-dist/server/assets/routes-khSDK1bV.js +361 -0
- package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
- package/studio-dist/server/assets/shell-CboT2f66.js +51 -0
- package/studio-dist/server/assets/skills-MWYnWoKs.js +106 -0
- package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +16 -0
- package/studio-dist/server/assets/specs-DE3w8hZP.js +155 -0
- package/studio-dist/server/assets/start-BW5ovN0k.js +33 -0
- package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
- package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +3365 -0
- package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
- package/studio-dist/server/assets/vault-BGulVoNh.js +70 -0
- package/studio-dist/server/assets/vault-CuyyhLyB.js +832 -0
- package/studio-dist/server/assets/views-Bd7cRr27.js +82 -0
- package/studio-dist/server/assets/warnings-BH05rOuG.js +15 -0
- package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
- package/studio-dist/server/assets/workflow-BSuIKWqH.js +42 -0
- package/studio-dist/server/server.js +16220 -0
- package/src/cli/commands/studio/client-asset.ts +0 -16
- package/src/cli/commands/studio/views/client.ts +0 -44
- package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
- package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
- package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -102
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -910
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/markdown.tsx +0 -250
- package/src/cli/commands/studio/views/palette.ts +0 -134
- package/src/cli/commands/studio/views/reports/index.tsx +0 -44
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -68
- package/src/cli/commands/studio/views/specs/index.tsx +0 -149
- package/src/cli/commands/studio/views/studio-client/actions.ts +0 -51
- package/src/cli/commands/studio/views/studio-client/companion.ts +0 -13
- package/src/cli/commands/studio/views/studio-client/index.ts +0 -32
- package/src/cli/commands/studio/views/studio-client/keys.ts +0 -3
- package/src/cli/commands/studio/views/studio-client/main.ts +0 -3
- package/src/cli/commands/studio/views/studio-client/page.ts +0 -146
- package/src/cli/commands/studio/views/studio-client/panels.ts +0 -57
- package/src/cli/commands/studio/views/studio-client/reports.ts +0 -122
- package/src/cli/commands/studio/views/studio-client/theme.ts +0 -63
- package/src/cli/commands/studio/views/studio-client/vault-editor.ts +0 -166
- package/src/cli/commands/studio/views/studio-client/vault-pane.ts +0 -202
- package/src/cli/commands/studio/views/studio-client/vault-tree.ts +0 -258
- package/src/cli/commands/studio/views/studio-client.generated.ts +0 -2
- package/src/cli/commands/studio/views/styles.ts +0 -530
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -41
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/delivery-path.tsx +0 -370
- package/src/cli/commands/studio/views/workflow/graph.ts +0 -220
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -20
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -278
- package/src/lib/components/theme.ts +0 -2
- package/src/tools/setup/git-utils.ts +0 -30
|
@@ -4,12 +4,17 @@ import {
|
|
|
4
4
|
} from "../../../lib/orchestrator/capabilities";
|
|
5
5
|
import { resolveForCapability } from "../../../lib/orchestrator/framework-context";
|
|
6
6
|
import { resolveSecretPolicy } from "../../../runtime/policy";
|
|
7
|
+
import { tokensaveCheckout } from "../../../runtime/tokensave-route";
|
|
7
8
|
import type { CapabilityConfig } from "../../../lib/orchestrator/types";
|
|
8
9
|
import {
|
|
9
10
|
ensureTokensaveBranchingPosture,
|
|
10
11
|
ensureTokensaveStoreExcluded,
|
|
11
12
|
isTokensaveIndexed,
|
|
12
13
|
} from "../../../tools/setup/capabilities/tokensave";
|
|
14
|
+
import {
|
|
15
|
+
createStartupProgress,
|
|
16
|
+
type StartupProgressController,
|
|
17
|
+
} from "../../../lib/components/startup-progress";
|
|
13
18
|
import { ensureUnambiguousCompanion } from "../shared/companion-selection";
|
|
14
19
|
import { runGraphifyCapCommand } from "./graphify";
|
|
15
20
|
import { runTokensaveCapCommand } from "./tokensave";
|
|
@@ -21,15 +26,25 @@ export type SyncCapStep = "graphify" | "tokensave";
|
|
|
21
26
|
export interface SyncCapDeps {
|
|
22
27
|
ensureUnambiguousCompanion?: (cwd: string) => Promise<boolean>;
|
|
23
28
|
loadCapabilities?: () => Promise<CapabilityConfig[]>;
|
|
24
|
-
|
|
29
|
+
/** The resolved Working Repository's path, if any. */
|
|
30
|
+
resolveRepositoryPath?: () => Promise<string | undefined>;
|
|
31
|
+
cwd?: () => string;
|
|
32
|
+
isTokensaveInitialized?: (repoPath: string) => Promise<boolean>;
|
|
25
33
|
ensureTokensaveStoreExcluded?: (repoPath: string) => Promise<void>;
|
|
26
34
|
ensureTokensaveBranchingPosture?: (repoPath: string) => Promise<void>;
|
|
27
35
|
runGraphify?: CapRunner;
|
|
28
36
|
runTokensave?: CapRunner;
|
|
37
|
+
/** Replace the default hand-over lines; launch passes its own progress screen. */
|
|
29
38
|
onStepStart?: (step: SyncCapStep) => void;
|
|
30
39
|
onStepDone?: (step: SyncCapStep, ok: boolean) => void;
|
|
40
|
+
createProgress?: typeof createStartupProgress;
|
|
31
41
|
}
|
|
32
42
|
|
|
43
|
+
const STEP_LABELS: Record<SyncCapStep, string> = {
|
|
44
|
+
graphify: "Syncing graphify",
|
|
45
|
+
tokensave: "Syncing tokensave",
|
|
46
|
+
};
|
|
47
|
+
|
|
33
48
|
/** The companion's live secret policy decides the secret-file excludes. */
|
|
34
49
|
async function defaultEnsureBranchingPosture(repoPath: string): Promise<void> {
|
|
35
50
|
const { companionPath } = await resolveForCapability(process.cwd());
|
|
@@ -42,12 +57,11 @@ async function defaultLoadCapabilities(): Promise<CapabilityConfig[]> {
|
|
|
42
57
|
return config.capabilities ?? [];
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
async function
|
|
60
|
+
async function defaultResolveRepositoryPath(): Promise<string | undefined> {
|
|
46
61
|
const { repositoryId, repository, workingRepoStore } = await resolveForCapability(process.cwd());
|
|
47
62
|
const repo =
|
|
48
63
|
repository ?? (await workingRepoStore.load()).repos.find((entry) => entry.id === repositoryId);
|
|
49
|
-
|
|
50
|
-
return isTokensaveIndexed(repo.path);
|
|
64
|
+
return repo?.path;
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
// The reused cap commands (runGraphifyCapCommand / runTokensaveCapCommand) signal
|
|
@@ -120,12 +134,6 @@ export async function runIndexCapCommand(args: string[], deps: SyncCapDeps = {})
|
|
|
120
134
|
|
|
121
135
|
const loadCapabilities = deps.loadCapabilities ?? defaultLoadCapabilities;
|
|
122
136
|
const ensureCompanion = deps.ensureUnambiguousCompanion ?? ensureUnambiguousCompanion;
|
|
123
|
-
const isTokensaveInitialized = deps.isTokensaveInitialized ?? defaultIsTokensaveInitialized;
|
|
124
|
-
const ensureStoreExcluded = deps.ensureTokensaveStoreExcluded ?? ensureTokensaveStoreExcluded;
|
|
125
|
-
const ensureBranchingPosture =
|
|
126
|
-
deps.ensureTokensaveBranchingPosture ?? defaultEnsureBranchingPosture;
|
|
127
|
-
const runGraphify = deps.runGraphify ?? runGraphifyCapCommand;
|
|
128
|
-
const runTokensave = deps.runTokensave ?? runTokensaveCapCommand;
|
|
129
137
|
|
|
130
138
|
if (!(await ensureCompanion(process.cwd()))) {
|
|
131
139
|
process.exitCode = 1;
|
|
@@ -133,10 +141,44 @@ export async function runIndexCapCommand(args: string[], deps: SyncCapDeps = {})
|
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
const capabilities = await loadCapabilities();
|
|
136
|
-
let failed = false;
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
// graphify and tokensave write straight to the terminal: labelled hand-overs, no spinner.
|
|
146
|
+
let progress: StartupProgressController | undefined;
|
|
147
|
+
const onStepStart =
|
|
148
|
+
deps.onStepStart ??
|
|
149
|
+
((step: SyncCapStep) => {
|
|
150
|
+
progress ??= (deps.createProgress ?? createStartupProgress)("Indexing capabilities");
|
|
151
|
+
progress.handOver(step, STEP_LABELS[step]);
|
|
152
|
+
});
|
|
153
|
+
const onStepDone =
|
|
154
|
+
deps.onStepDone ??
|
|
155
|
+
((step: SyncCapStep, ok: boolean) => {
|
|
156
|
+
if (ok) progress?.succeed(step);
|
|
157
|
+
else progress?.fail(step);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
await runSteps(options, capabilities, { onStepStart, onStepDone }, deps);
|
|
162
|
+
} finally {
|
|
163
|
+
progress?.stop();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function runSteps(
|
|
168
|
+
options: { includeGraphify: boolean; includeTokensave: boolean },
|
|
169
|
+
capabilities: CapabilityConfig[],
|
|
170
|
+
{ onStepStart, onStepDone }: Required<Pick<SyncCapDeps, "onStepStart" | "onStepDone">>,
|
|
171
|
+
deps: SyncCapDeps,
|
|
172
|
+
): Promise<void> {
|
|
173
|
+
const resolveRepositoryPath = deps.resolveRepositoryPath ?? defaultResolveRepositoryPath;
|
|
174
|
+
const cwd = deps.cwd ?? (() => process.cwd());
|
|
175
|
+
const isTokensaveInitialized = deps.isTokensaveInitialized ?? isTokensaveIndexed;
|
|
176
|
+
const ensureStoreExcluded = deps.ensureTokensaveStoreExcluded ?? ensureTokensaveStoreExcluded;
|
|
177
|
+
const ensureBranchingPosture =
|
|
178
|
+
deps.ensureTokensaveBranchingPosture ?? defaultEnsureBranchingPosture;
|
|
179
|
+
const runGraphify = deps.runGraphify ?? runGraphifyCapCommand;
|
|
180
|
+
const runTokensave = deps.runTokensave ?? runTokensaveCapCommand;
|
|
181
|
+
let failed = false;
|
|
140
182
|
|
|
141
183
|
if (hasGraphifyCapability(capabilities)) {
|
|
142
184
|
if (
|
|
@@ -154,8 +196,15 @@ export async function runIndexCapCommand(args: string[], deps: SyncCapDeps = {})
|
|
|
154
196
|
|
|
155
197
|
if (!options.includeGraphify && hasTokensaveCapability(capabilities)) {
|
|
156
198
|
onStepStart("tokensave");
|
|
157
|
-
|
|
158
|
-
|
|
199
|
+
/** One checkout for check, init, posture and sync; `runTokensave` resolves the same one. */
|
|
200
|
+
const resolved = await resolveRepositoryPath();
|
|
201
|
+
const repoPath = resolved ? tokensaveCheckout(cwd(), resolved) : null;
|
|
202
|
+
if (!repoPath) {
|
|
203
|
+
// Never the raw cwd: it may be a subfolder, and `runTokensave` would refuse anyway.
|
|
204
|
+
process.stderr.write("mate cap index: no working repository resolved for tokensave\n");
|
|
205
|
+
failed = true;
|
|
206
|
+
onStepDone("tokensave", false);
|
|
207
|
+
} else if (!(await isTokensaveInitialized(repoPath))) {
|
|
159
208
|
await ensureStoreExcluded(repoPath);
|
|
160
209
|
const initOk = await runCapStep(() => runTokensave(["init", "--no-git-hook"]));
|
|
161
210
|
if (!initOk) {
|
|
@@ -2,18 +2,21 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
|
|
3
3
|
import { resolveForLaunch } from "../../../lib/orchestrator/framework-context";
|
|
4
4
|
import type { CapabilityConfig } from "../../../lib/orchestrator/types";
|
|
5
|
+
import { tokensaveCheckout } from "../../../runtime/tokensave-route";
|
|
5
6
|
import { ensureTokensaveInstalled } from "../../../tools/setup/capabilities/tokensave";
|
|
6
7
|
|
|
7
8
|
interface TokensaveCapDeps {
|
|
8
9
|
resolveForLaunch?: typeof resolveForLaunch;
|
|
9
10
|
ensureInstalled?: (repoPath: string, options?: { upgrade?: boolean }) => Promise<boolean>;
|
|
10
11
|
spawn?: typeof spawnSync;
|
|
12
|
+
cwd?: () => string;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @command mate cap tokensave [...args]
|
|
15
17
|
* @description Forwards `[...args]` to the `tokensave` CLI, run from the
|
|
16
|
-
* active working repository
|
|
18
|
+
* active working repository, or from the linked worktree of it the command
|
|
19
|
+
* runs in. Requires the `tokensave` capability to be enabled
|
|
17
20
|
* in `.mate/config/framework.yaml` and a registered working repo for the
|
|
18
21
|
* current `MATE_REPO_ID`. Ensures the `tokensave` binary is installed in that
|
|
19
22
|
* repo (via {@link ensureTokensaveInstalled}) before forwarding. Never upgrades:
|
|
@@ -27,10 +30,9 @@ export async function runTokensaveCapCommand(
|
|
|
27
30
|
const resolveLaunch = deps.resolveForLaunch ?? resolveForLaunch;
|
|
28
31
|
const ensureInstalled = deps.ensureInstalled ?? ensureTokensaveInstalled;
|
|
29
32
|
const spawn = deps.spawn ?? spawnSync;
|
|
33
|
+
const cwd = deps.cwd ?? (() => process.cwd());
|
|
30
34
|
|
|
31
|
-
const { repositoryId, repository, configStore, workingRepoStore } = await resolveLaunch(
|
|
32
|
-
process.cwd(),
|
|
33
|
-
);
|
|
35
|
+
const { repositoryId, repository, configStore, workingRepoStore } = await resolveLaunch(cwd());
|
|
34
36
|
const config = await configStore.load();
|
|
35
37
|
|
|
36
38
|
const capability = (config.capabilities ?? []).find(
|
|
@@ -56,7 +58,7 @@ export async function runTokensaveCapCommand(
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
const result = spawn("tokensave", args, {
|
|
59
|
-
cwd: repo.path,
|
|
61
|
+
cwd: tokensaveCheckout(cwd(), repo.path),
|
|
60
62
|
stdio: "inherit",
|
|
61
63
|
});
|
|
62
64
|
|
|
@@ -20,6 +20,7 @@ import { runSetupFlowAtPath } from "../setup";
|
|
|
20
20
|
import { runInstallCommand } from "../install";
|
|
21
21
|
import type { CompanionSource, LinkedRepository } from "../../../lib/orchestrator/types";
|
|
22
22
|
import { invalidateInstallState } from "../../../lib/install";
|
|
23
|
+
import { createStartupProgress } from "../../../lib/components/startup-progress";
|
|
23
24
|
import { companionGit, describeGitFailure, type GitResult } from "../../../runtime/companion-git";
|
|
24
25
|
|
|
25
26
|
interface CompanionLinkCommandDeps {
|
|
@@ -42,6 +43,7 @@ interface CompanionLinkCommandDeps {
|
|
|
42
43
|
installCompanion?: (companionPath: string) => Promise<boolean | void>;
|
|
43
44
|
isDirectory?: (candidatePath: string) => Promise<boolean>;
|
|
44
45
|
findDescendantRepoLocalRegistries?: typeof findDescendantRepoLocalRegistries;
|
|
46
|
+
createProgress?: typeof createStartupProgress;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/** All companions surfaced by the "existing companion" picker live under this directory. */
|
|
@@ -86,6 +88,7 @@ export async function runCompanionLinkCommandWithDeps(
|
|
|
86
88
|
companionGit(path.dirname(destination), { prompt: "if-terminal" }).clone(url, destination));
|
|
87
89
|
const mkdir = deps.mkdir ?? fs.mkdir;
|
|
88
90
|
const stat = deps.stat ?? fs.stat;
|
|
91
|
+
const createProgress = deps.createProgress ?? createStartupProgress;
|
|
89
92
|
const listCompanions =
|
|
90
93
|
deps.listCompanions ??
|
|
91
94
|
(() => {
|
|
@@ -151,7 +154,17 @@ export async function runCompanionLinkCommandWithDeps(
|
|
|
151
154
|
const existingTarget = await stat(companionPath).catch(() => null);
|
|
152
155
|
if (!existingTarget?.isDirectory()) {
|
|
153
156
|
await mkdir(companionsDir, { recursive: true });
|
|
154
|
-
|
|
157
|
+
// Git may ask for credentials: a labelled hand-over, never a spinner.
|
|
158
|
+
const progress = createProgress("Linking companion");
|
|
159
|
+
let clone: GitResult;
|
|
160
|
+
try {
|
|
161
|
+
progress.handOver("clone", "Cloning companion");
|
|
162
|
+
clone = await cloneCompanion(gitUrl, companionPath);
|
|
163
|
+
if (clone.status === 0) progress.succeed("clone");
|
|
164
|
+
else progress.fail("clone");
|
|
165
|
+
} finally {
|
|
166
|
+
progress.stop();
|
|
167
|
+
}
|
|
155
168
|
if (clone.status !== 0) {
|
|
156
169
|
const detail = describeGitFailure(clone);
|
|
157
170
|
exitWithError(
|
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
findRepoLocalRegistryFile,
|
|
7
7
|
} from "../../../lib/orchestrator/repository-link";
|
|
8
8
|
import { GlobalConfigStore } from "../../../lib/orchestrator/global-config-store";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
editorWorkspacePath,
|
|
11
|
+
getPreferredEditorCli,
|
|
12
|
+
openEditorWorkspace,
|
|
13
|
+
} from "../../../lib/orchestrator/editor";
|
|
10
14
|
import { WorkingRepoRequiredError } from "../../../lib/orchestrator/types";
|
|
11
15
|
import { resolveProjection } from "../../../runtime/projection";
|
|
12
16
|
|
|
@@ -32,7 +36,7 @@ export const workspaceOpenCommandDeps = {
|
|
|
32
36
|
},
|
|
33
37
|
resolveProjection,
|
|
34
38
|
getPreferredEditorCli: () => getPreferredEditorCli(),
|
|
35
|
-
|
|
39
|
+
openEditorWorkspace,
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
/**
|
|
@@ -49,14 +53,16 @@ function orderCompanionPaths(cwd: string, matches: CompanionMatch[]): string[] {
|
|
|
49
53
|
|
|
50
54
|
/**
|
|
51
55
|
* @command mate companion open
|
|
52
|
-
* @description
|
|
53
|
-
*
|
|
54
|
-
*
|
|
56
|
+
* @description Merges the active working repository, every Linked Companion,
|
|
57
|
+
* and the worktree-detection settings into `.mate/<repo>.mate.code-workspace`,
|
|
58
|
+
* keeping developer edits, then opens that file in the editor. A legacy
|
|
59
|
+
* `.mate/workspace.code-workspace` is renamed to it once.
|
|
55
60
|
* @remarks Never selects a companion: no picker, no `MATE_ARTIFACT_PATH`
|
|
56
61
|
* narrowing, and the companion recorded at the Projection Root is left as it
|
|
57
62
|
* was. Stale companion pointers are skipped with a stderr warning. Throws
|
|
58
63
|
* {@link WorkingRepoRequiredError} when no existing Linked Companion remains;
|
|
59
|
-
* sets a non-zero exit code if the editor CLI is unavailable
|
|
64
|
+
* sets a non-zero exit code if the editor CLI is unavailable or the workspace
|
|
65
|
+
* file cannot be read, leaving that file unchanged.
|
|
60
66
|
*/
|
|
61
67
|
export async function runWorkspaceOpenCommand(): Promise<void> {
|
|
62
68
|
const cwd = workspaceOpenCommandDeps.cwd();
|
|
@@ -64,18 +70,17 @@ export async function runWorkspaceOpenCommand(): Promise<void> {
|
|
|
64
70
|
if (matches.length === 0) throw new WorkingRepoRequiredError("companion open");
|
|
65
71
|
|
|
66
72
|
const repoPath = await workspaceOpenCommandDeps.findRepoRoot(cwd);
|
|
67
|
-
const
|
|
73
|
+
const opened = await workspaceOpenCommandDeps.openEditorWorkspace(
|
|
68
74
|
orderCompanionPaths(cwd, matches),
|
|
69
75
|
repoPath,
|
|
70
76
|
workspaceOpenCommandDeps.getPreferredEditorCli(),
|
|
71
77
|
);
|
|
72
78
|
|
|
73
|
-
if (!
|
|
79
|
+
if (!opened) {
|
|
74
80
|
process.exitCode = 1;
|
|
75
81
|
return;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
);
|
|
84
|
+
const documentPath = path.relative(repoPath, editorWorkspacePath(repoPath));
|
|
85
|
+
console.log(`Workspace: opened ${documentPath} in the editor`);
|
|
81
86
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
2
|
+
import { createStartupProgress } from "../../../lib/components/startup-progress";
|
|
2
3
|
import { syncCompanionGit } from "../../../lib/orchestrator/companion-git-sync";
|
|
3
4
|
import { LaunchPreflightError } from "../../../lib/orchestrator/types";
|
|
4
5
|
import { resolveCompanionRuntime } from "../../../runtime/env";
|
|
@@ -11,6 +12,7 @@ export interface CompanionSyncDeps {
|
|
|
11
12
|
resolveRepoPath: typeof resolveRepoPath;
|
|
12
13
|
readCompanionPolicy: typeof readCompanionPolicy;
|
|
13
14
|
syncCompanionGit: typeof syncCompanionGit;
|
|
15
|
+
createProgress: typeof createStartupProgress;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const companionSyncDeps: CompanionSyncDeps = {
|
|
@@ -20,6 +22,7 @@ export const companionSyncDeps: CompanionSyncDeps = {
|
|
|
20
22
|
resolveRepoPath,
|
|
21
23
|
readCompanionPolicy,
|
|
22
24
|
syncCompanionGit,
|
|
25
|
+
createProgress: createStartupProgress,
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -66,12 +69,16 @@ export async function runCompanionSyncCommand(): Promise<void> {
|
|
|
66
69
|
|
|
67
70
|
const repoPath = await companionSyncDeps.resolveRepoPath(cwd);
|
|
68
71
|
|
|
72
|
+
const progress = companionSyncDeps.createProgress("Syncing companion");
|
|
69
73
|
try {
|
|
74
|
+
// Git may ask for credentials: a labelled hand-over, never a spinner.
|
|
75
|
+
progress.handOver("git", "Syncing companion Git");
|
|
70
76
|
const result = await companionSyncDeps.syncCompanionGit(
|
|
71
77
|
companionPath,
|
|
72
78
|
repoPath === companionPath ? undefined : repoPath,
|
|
73
79
|
true,
|
|
74
80
|
);
|
|
81
|
+
progress.succeed("git");
|
|
75
82
|
if (result.skipped) {
|
|
76
83
|
process.stdout.write(
|
|
77
84
|
`${FRAMEWORK_NAME}: ${companionPath} is not a Git working tree; nothing to synchronize.\n`,
|
|
@@ -82,11 +89,14 @@ export async function runCompanionSyncCommand(): Promise<void> {
|
|
|
82
89
|
`${FRAMEWORK_NAME}: synchronized ${companionPath} (${result.changed ? "updated" : "no changes"}).\n`,
|
|
83
90
|
);
|
|
84
91
|
} catch (error) {
|
|
92
|
+
progress.fail("git");
|
|
85
93
|
if (error instanceof LaunchPreflightError) {
|
|
86
94
|
process.stderr.write(`${error.message}\n`);
|
|
87
95
|
process.exitCode = 1;
|
|
88
96
|
return;
|
|
89
97
|
}
|
|
90
98
|
throw error;
|
|
99
|
+
} finally {
|
|
100
|
+
progress.stop();
|
|
91
101
|
}
|
|
92
102
|
}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { accessSync } from "node:fs";
|
|
3
3
|
|
|
4
|
+
import { accentText, colorEnabled } from "../../../brand/terminal";
|
|
4
5
|
import { getActiveDistribution } from "../../../distribution";
|
|
5
6
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
6
7
|
import { resolveFrameworkContext } from "../../../lib/orchestrator/framework-context";
|
|
7
8
|
import { findRepoLocalLinkedRepository } from "../../../lib/orchestrator/repository-link";
|
|
8
9
|
import { ensureUnambiguousCompanion } from "../launch/shared";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
/** Plain lines, no box: paths are never padded or cut and wrap when wider than the terminal. */
|
|
12
|
+
export function renderBanner(
|
|
13
|
+
repoPath: string,
|
|
14
|
+
companionPath: string,
|
|
15
|
+
options: { color?: boolean } = {},
|
|
16
|
+
): string {
|
|
11
17
|
const { version } = getActiveDistribution().config;
|
|
12
18
|
const name = FRAMEWORK_NAME;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const color = options.color ?? colorEnabled(process.stdout.isTTY === true, process.env);
|
|
20
|
+
const rows: [string, string][] = [
|
|
21
|
+
["repo", repoPath],
|
|
22
|
+
[name, companionPath],
|
|
23
|
+
];
|
|
24
|
+
const labelWidth = Math.max(...rows.map(([label]) => label.length));
|
|
25
|
+
return [
|
|
26
|
+
`${color ? accentText(name) : name} v${version}`,
|
|
27
|
+
...rows.map(([label, value]) => ` ${label.padEnd(labelWidth)} ${value}`),
|
|
28
|
+
].join("\n");
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
export function resolveShell(): string {
|
|
@@ -3,6 +3,10 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
6
|
+
import {
|
|
7
|
+
createStartupProgress,
|
|
8
|
+
type StartupProgressController,
|
|
9
|
+
} from "../../../lib/components/startup-progress";
|
|
6
10
|
import { ConfigStore } from "../../../lib/orchestrator/config-store";
|
|
7
11
|
import {
|
|
8
12
|
refreshWorkingClaudeLinks,
|
|
@@ -17,7 +21,11 @@ import {
|
|
|
17
21
|
isNewer,
|
|
18
22
|
} from "../../../lib/update-checker";
|
|
19
23
|
import { resolveCompanionRuntime } from "../../../runtime/env";
|
|
20
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
syncCompanionFiles,
|
|
26
|
+
untrackManagedSkillCopies,
|
|
27
|
+
type CompanionSyncOptions,
|
|
28
|
+
} from "../../../tools/setup";
|
|
21
29
|
import type { ManagedOutputOwner, ManagedOutputReport } from "../../../tools/setup/plugin";
|
|
22
30
|
import { runCommand } from "../../../tools/setup/utils";
|
|
23
31
|
import { confirm } from "../../confirm";
|
|
@@ -96,6 +104,8 @@ export interface CompanionUpdateDeps {
|
|
|
96
104
|
config: FrameworkConfig,
|
|
97
105
|
options: CompanionSyncOptions,
|
|
98
106
|
) => Promise<ManagedOutputReport>;
|
|
107
|
+
/** Removes the Mate skill copies the managed `.gitignore` lists from the index; returns their paths. */
|
|
108
|
+
untrackSkillCopies: (companionPath: string, config: FrameworkConfig) => Promise<string[]>;
|
|
99
109
|
/** Returns true when the file was rewritten. */
|
|
100
110
|
writeEngineFloor: (companionPath: string, range: string) => Promise<boolean>;
|
|
101
111
|
/** Re-links the companion's Claude skills and commands into its wrapped Working Repositories. */
|
|
@@ -109,6 +119,7 @@ export interface CompanionUpdateDeps {
|
|
|
109
119
|
snapshotPath: (companionPath: string, relativePath: string) => Promise<string>;
|
|
110
120
|
confirm: (question: string) => Promise<boolean>;
|
|
111
121
|
isInteractive: () => boolean;
|
|
122
|
+
createProgress: typeof createStartupProgress;
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
export const companionUpdateDeps: CompanionUpdateDeps = {
|
|
@@ -122,6 +133,7 @@ export const companionUpdateDeps: CompanionUpdateDeps = {
|
|
|
122
133
|
async syncCompanionFiles(companionPath, config, options) {
|
|
123
134
|
return (await syncCompanionFiles(companionPath, config, undefined, options)).managedOutput;
|
|
124
135
|
},
|
|
136
|
+
untrackSkillCopies: untrackManagedSkillCopies,
|
|
125
137
|
async writeEngineFloor(companionPath, range) {
|
|
126
138
|
const store = new RawFrameworkConfigStore(frameworkConfigPath(companionPath));
|
|
127
139
|
const raw = (await store.load()) ?? {};
|
|
@@ -142,6 +154,7 @@ export const companionUpdateDeps: CompanionUpdateDeps = {
|
|
|
142
154
|
snapshotPath,
|
|
143
155
|
confirm,
|
|
144
156
|
isInteractive: () => !!(process.stdin.isTTY && process.stdout.isTTY),
|
|
157
|
+
createProgress: createStartupProgress,
|
|
145
158
|
};
|
|
146
159
|
|
|
147
160
|
export interface UpdateChanges {
|
|
@@ -163,13 +176,18 @@ export async function snapshotChangedPaths(
|
|
|
163
176
|
return before;
|
|
164
177
|
}
|
|
165
178
|
|
|
166
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Paths the update wrote, and the subset that already carried local edits (design D4).
|
|
181
|
+
* `untracked` skill copies are Mate output: committed as deletions, never a conflict.
|
|
182
|
+
*/
|
|
167
183
|
export async function diffChangedPaths(
|
|
168
184
|
companionPath: string,
|
|
169
185
|
git: GitOps,
|
|
170
186
|
before: Map<string, string>,
|
|
171
187
|
report: ManagedOutputReport,
|
|
188
|
+
untracked: readonly string[] = [],
|
|
172
189
|
): Promise<UpdateChanges> {
|
|
190
|
+
const removals = new Set(untracked);
|
|
173
191
|
const written: string[] = [];
|
|
174
192
|
const conflict: string[] = [];
|
|
175
193
|
const overwritten: string[] = [];
|
|
@@ -183,6 +201,11 @@ export async function diffChangedPaths(
|
|
|
183
201
|
}),
|
|
184
202
|
);
|
|
185
203
|
for (const { changed, owner, unchanged } of preexisting) {
|
|
204
|
+
if (removals.has(changed)) {
|
|
205
|
+
written.push(changed);
|
|
206
|
+
if (owner === "mate" && !unchanged) overwritten.push(changed);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
186
209
|
// Reported output is committed even when a local edit preceded the sync.
|
|
187
210
|
if (!owner && unchanged) continue;
|
|
188
211
|
written.push(changed);
|
|
@@ -229,9 +252,10 @@ function reportLinkRefresh(results: LinkRefreshResult[]): void {
|
|
|
229
252
|
}
|
|
230
253
|
|
|
231
254
|
/** Version precondition; returns the running version when the update may proceed. */
|
|
232
|
-
async function checkVersion(): Promise<string | undefined> {
|
|
255
|
+
async function checkVersion(progress: StartupProgressController): Promise<string | undefined> {
|
|
233
256
|
const current = companionUpdateDeps.getCurrentVersion();
|
|
234
257
|
if (isCanaryVersion(current)) {
|
|
258
|
+
progress.stop();
|
|
235
259
|
fail(
|
|
236
260
|
`\`${FRAMEWORK_NAME} companion update\` requires a stable ${FRAMEWORK_NAME}; ${current} is a prerelease.`,
|
|
237
261
|
);
|
|
@@ -239,12 +263,16 @@ async function checkVersion(): Promise<string | undefined> {
|
|
|
239
263
|
}
|
|
240
264
|
let latest: string;
|
|
241
265
|
try {
|
|
242
|
-
latest = await
|
|
266
|
+
latest = await progress.step("registry", "Checking registry", () =>
|
|
267
|
+
companionUpdateDeps.fetchLatestVersion(),
|
|
268
|
+
);
|
|
243
269
|
} catch (error) {
|
|
270
|
+
progress.stop();
|
|
244
271
|
fail(`could not check the registry for the newest version: ${errorMessage(error)}`);
|
|
245
272
|
return undefined;
|
|
246
273
|
}
|
|
247
274
|
if (isNewer(latest, current)) {
|
|
275
|
+
progress.stop();
|
|
248
276
|
fail(
|
|
249
277
|
[
|
|
250
278
|
`${current} is installed, but the newest stable version is ${latest}.`,
|
|
@@ -259,6 +287,7 @@ async function checkVersion(): Promise<string | undefined> {
|
|
|
259
287
|
async function commitAndPush(
|
|
260
288
|
git: GitOps,
|
|
261
289
|
written: string[],
|
|
290
|
+
removed: readonly string[],
|
|
262
291
|
version: string,
|
|
263
292
|
yes: boolean,
|
|
264
293
|
): Promise<void> {
|
|
@@ -276,7 +305,7 @@ async function commitAndPush(
|
|
|
276
305
|
}
|
|
277
306
|
try {
|
|
278
307
|
await git.add(written);
|
|
279
|
-
await git.commit(message, written);
|
|
308
|
+
await git.commit(message, written, { removed });
|
|
280
309
|
} catch (error) {
|
|
281
310
|
fail(`commit failed: ${errorMessage(error)}`);
|
|
282
311
|
return;
|
|
@@ -320,7 +349,20 @@ export async function runCompanionUpdateCommand(argv: string[]): Promise<void> {
|
|
|
320
349
|
return;
|
|
321
350
|
}
|
|
322
351
|
|
|
323
|
-
const
|
|
352
|
+
const progress = companionUpdateDeps.createProgress("Updating companion");
|
|
353
|
+
try {
|
|
354
|
+
await updateCompanion(companionPath, yes, progress);
|
|
355
|
+
} finally {
|
|
356
|
+
progress.stop();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async function updateCompanion(
|
|
361
|
+
companionPath: string,
|
|
362
|
+
yes: boolean,
|
|
363
|
+
progress: StartupProgressController,
|
|
364
|
+
): Promise<void> {
|
|
365
|
+
const version = await checkVersion(progress);
|
|
324
366
|
if (!version) return;
|
|
325
367
|
|
|
326
368
|
let git: GitOps;
|
|
@@ -329,22 +371,36 @@ export async function runCompanionUpdateCommand(argv: string[]): Promise<void> {
|
|
|
329
371
|
git = companionUpdateDeps.createGitOps(companionPath);
|
|
330
372
|
before = await snapshotChangedPaths(companionPath, git);
|
|
331
373
|
} catch (error) {
|
|
374
|
+
progress.stop();
|
|
332
375
|
fail(errorMessage(error));
|
|
333
376
|
return;
|
|
334
377
|
}
|
|
335
378
|
|
|
336
379
|
let config: FrameworkConfig;
|
|
337
380
|
let report: ManagedOutputReport;
|
|
381
|
+
let untracked: string[];
|
|
338
382
|
try {
|
|
339
|
-
config = await
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
383
|
+
({ config, report, untracked } = await progress.step(
|
|
384
|
+
"sync",
|
|
385
|
+
"Syncing companion files",
|
|
386
|
+
async () => {
|
|
387
|
+
const loaded = await companionUpdateDeps.loadConfig(companionPath);
|
|
388
|
+
// Only this command and setup regenerate OpenSpec output; launches leave it alone.
|
|
389
|
+
const synced = await companionUpdateDeps.syncCompanionFiles(companionPath, loaded, {
|
|
390
|
+
regenerateOpenSpec: true,
|
|
391
|
+
});
|
|
392
|
+
// After the sync wrote the managed `.gitignore`; a declined commit leaves the removals staged.
|
|
393
|
+
const removed = await companionUpdateDeps.untrackSkillCopies(companionPath, loaded);
|
|
394
|
+
return { config: loaded, report: synced, untracked: removed };
|
|
395
|
+
},
|
|
396
|
+
));
|
|
344
397
|
} catch (error) {
|
|
398
|
+
progress.stop();
|
|
345
399
|
fail(`companion file synchronization failed: ${errorMessage(error)}`);
|
|
346
400
|
return;
|
|
347
401
|
}
|
|
402
|
+
// The reports, the skills refresh and the commit confirm below own the terminal.
|
|
403
|
+
progress.stop();
|
|
348
404
|
|
|
349
405
|
if (await companionUpdateDeps.hasSkillsLock(companionPath)) {
|
|
350
406
|
try {
|
|
@@ -371,6 +427,7 @@ export async function runCompanionUpdateCommand(argv: string[]): Promise<void> {
|
|
|
371
427
|
git,
|
|
372
428
|
before,
|
|
373
429
|
report,
|
|
430
|
+
untracked,
|
|
374
431
|
);
|
|
375
432
|
if (written.length === 0) {
|
|
376
433
|
process.stdout.write(
|
|
@@ -383,6 +440,11 @@ export async function runCompanionUpdateCommand(argv: string[]): Promise<void> {
|
|
|
383
440
|
[
|
|
384
441
|
"the update rewrote files that already had uncommitted changes; local edits and update output can no longer be separated, so nothing is committed:",
|
|
385
442
|
listPaths(conflict),
|
|
443
|
+
...(untracked.length > 0
|
|
444
|
+
? [
|
|
445
|
+
"Mate skill copies were removed from the Git index and stay staged as deletions; the files are still on disk.",
|
|
446
|
+
]
|
|
447
|
+
: []),
|
|
386
448
|
].join("\n"),
|
|
387
449
|
);
|
|
388
450
|
return;
|
|
@@ -400,5 +462,5 @@ export async function runCompanionUpdateCommand(argv: string[]): Promise<void> {
|
|
|
400
462
|
process.stdout.write(
|
|
401
463
|
[`${FRAMEWORK_NAME}: the update changed ${companionPath}:`, listPaths(written), ""].join("\n"),
|
|
402
464
|
);
|
|
403
|
-
await commitAndPush(git, written, version, yes);
|
|
465
|
+
await commitAndPush(git, written, untracked, version, yes);
|
|
404
466
|
}
|