@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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Version 1 of the compact apply transport: a stateless envelope around fresh
|
|
5
|
+
* `openspec instructions apply --json` output. A full envelope carries the whole
|
|
6
|
+
* upstream payload; a compact one carries only what a checkbox update changes,
|
|
7
|
+
* valid against the full baseline whose digest it repeats.
|
|
8
|
+
*/
|
|
9
|
+
const APPLY_CONTEXT_PROTOCOL = "mate-apply-context";
|
|
10
|
+
const APPLY_CONTEXT_VERSION = 1;
|
|
11
|
+
|
|
12
|
+
export type ApplyPayload = Record<string, unknown>;
|
|
13
|
+
|
|
14
|
+
export interface TaskState {
|
|
15
|
+
id: string;
|
|
16
|
+
done: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FullEnvelope {
|
|
20
|
+
version: 1;
|
|
21
|
+
mode: "full";
|
|
22
|
+
/** Baseline for a later `--since`; null when this payload cannot be compacted against. */
|
|
23
|
+
digest: string | null;
|
|
24
|
+
payload: ApplyPayload;
|
|
25
|
+
/** Why `digest` is null, e.g. an unreadable context file or ambiguous task location. */
|
|
26
|
+
limitation?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CompactEnvelope {
|
|
30
|
+
version: 1;
|
|
31
|
+
mode: "compact";
|
|
32
|
+
digest: string;
|
|
33
|
+
state: unknown;
|
|
34
|
+
progress: unknown;
|
|
35
|
+
/** Every current task, in upstream order. */
|
|
36
|
+
taskStates: TaskState[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type ApplyEnvelope = FullEnvelope | CompactEnvelope;
|
|
40
|
+
|
|
41
|
+
/** What the payload was produced by and resolved against; any change invalidates a baseline. */
|
|
42
|
+
export interface DigestIdentity {
|
|
43
|
+
producer: Record<string, unknown>;
|
|
44
|
+
editContext: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ArtifactFingerprint {
|
|
48
|
+
path: string;
|
|
49
|
+
sha256: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
53
|
+
|
|
54
|
+
export function isWellFormedDigest(value: unknown): value is string {
|
|
55
|
+
return typeof value === "string" && DIGEST_PATTERN.test(value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** JSON with object keys sorted at every level; arrays keep their order. */
|
|
59
|
+
export function canonicalJson(value: unknown): string {
|
|
60
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
61
|
+
if (value !== null && typeof value === "object") {
|
|
62
|
+
const entries = Object.keys(value as Record<string, unknown>)
|
|
63
|
+
.sort()
|
|
64
|
+
.filter((key) => (value as Record<string, unknown>)[key] !== undefined)
|
|
65
|
+
.map(
|
|
66
|
+
(key) => `${JSON.stringify(key)}:${canonicalJson((value as Record<string, unknown>)[key])}`,
|
|
67
|
+
);
|
|
68
|
+
return `{${entries.join(",")}}`;
|
|
69
|
+
}
|
|
70
|
+
return JSON.stringify(value) ?? "null";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
74
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Tasks a compact update can describe: objects with a unique string `id` and boolean `done`. */
|
|
78
|
+
export function compactableTasks(
|
|
79
|
+
payload: ApplyPayload,
|
|
80
|
+
): { ok: true; tasks: Record<string, unknown>[] } | { ok: false; reason: string } {
|
|
81
|
+
if (typeof payload.state !== "string") return { ok: false, reason: "upstream state is missing" };
|
|
82
|
+
if (!("progress" in payload)) return { ok: false, reason: "upstream progress is missing" };
|
|
83
|
+
if (!Array.isArray(payload.tasks)) return { ok: false, reason: "upstream tasks are missing" };
|
|
84
|
+
const seen = new Set<string>();
|
|
85
|
+
for (const task of payload.tasks) {
|
|
86
|
+
if (!isRecord(task) || typeof task.id !== "string" || typeof task.done !== "boolean") {
|
|
87
|
+
return { ok: false, reason: "a task lacks a string id or boolean done" };
|
|
88
|
+
}
|
|
89
|
+
if (seen.has(task.id)) return { ok: false, reason: `duplicate task id ${task.id}` };
|
|
90
|
+
seen.add(task.id);
|
|
91
|
+
}
|
|
92
|
+
return { ok: true, tasks: payload.tasks as Record<string, unknown>[] };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The payload minus what a compact update carries: top-level state/progress and task done. */
|
|
96
|
+
function staticView(payload: ApplyPayload): ApplyPayload {
|
|
97
|
+
const { state: _state, progress: _progress, ...rest } = payload;
|
|
98
|
+
if (Array.isArray(rest.tasks)) {
|
|
99
|
+
rest.tasks = rest.tasks.map((task) => {
|
|
100
|
+
if (!isRecord(task)) return task;
|
|
101
|
+
const { done: _done, ...descriptor } = task;
|
|
102
|
+
return descriptor;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return rest;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function computeDigest(
|
|
109
|
+
identity: DigestIdentity,
|
|
110
|
+
payload: ApplyPayload,
|
|
111
|
+
fingerprints: ArtifactFingerprint[],
|
|
112
|
+
): string {
|
|
113
|
+
const canonical = canonicalJson({
|
|
114
|
+
protocol: APPLY_CONTEXT_PROTOCOL,
|
|
115
|
+
version: APPLY_CONTEXT_VERSION,
|
|
116
|
+
identity,
|
|
117
|
+
payload: staticView(payload),
|
|
118
|
+
fingerprints: [...fingerprints].sort((a, b) => a.path.localeCompare(b.path)),
|
|
119
|
+
});
|
|
120
|
+
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function nonEmpty(value: unknown): boolean {
|
|
124
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
125
|
+
if (isRecord(value)) return Object.keys(value).length > 0;
|
|
126
|
+
return value !== undefined && value !== null && value !== false && value !== "";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Why fresh output must be sent in full whatever the baseline: warnings, prerequisites, a block. */
|
|
130
|
+
export function fullReason(payload: ApplyPayload): string | null {
|
|
131
|
+
if (payload.state === "blocked") return "blocked";
|
|
132
|
+
if (nonEmpty(payload.warnings)) return "warnings";
|
|
133
|
+
if (nonEmpty(payload.missingArtifacts)) return "missing artifacts";
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface EncodeInput {
|
|
138
|
+
payload: ApplyPayload;
|
|
139
|
+
/** Null disables compaction; `limitation` says why. */
|
|
140
|
+
digest: string | null;
|
|
141
|
+
limitation?: string;
|
|
142
|
+
since?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function encodeApplyContext(input: EncodeInput): ApplyEnvelope {
|
|
146
|
+
const { payload, digest, limitation, since } = input;
|
|
147
|
+
const full = (): FullEnvelope => ({
|
|
148
|
+
version: 1,
|
|
149
|
+
mode: "full",
|
|
150
|
+
digest,
|
|
151
|
+
payload,
|
|
152
|
+
...(digest === null && limitation ? { limitation } : {}),
|
|
153
|
+
});
|
|
154
|
+
if (digest === null || since !== digest || fullReason(payload) !== null) return full();
|
|
155
|
+
const tasks = compactableTasks(payload);
|
|
156
|
+
if (!tasks.ok) return full();
|
|
157
|
+
return {
|
|
158
|
+
version: 1,
|
|
159
|
+
mode: "compact",
|
|
160
|
+
digest,
|
|
161
|
+
state: payload.state,
|
|
162
|
+
progress: payload.progress,
|
|
163
|
+
taskStates: tasks.tasks.map((task) => ({ id: task.id as string, done: task.done as boolean })),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The fresh upstream payload an envelope stands for. Throws when a compact
|
|
169
|
+
* update does not belong to the baseline; callers then fetch a full envelope.
|
|
170
|
+
*/
|
|
171
|
+
export function reconstructPayload(baseline: FullEnvelope, update: ApplyEnvelope): ApplyPayload {
|
|
172
|
+
if (update.mode === "full") return update.payload;
|
|
173
|
+
if (baseline.digest === null || baseline.digest !== update.digest) {
|
|
174
|
+
throw new Error("compact update does not match the baseline digest");
|
|
175
|
+
}
|
|
176
|
+
const baseTasks = baseline.payload.tasks;
|
|
177
|
+
if (
|
|
178
|
+
!Array.isArray(baseTasks) ||
|
|
179
|
+
baseTasks.length !== update.taskStates.length ||
|
|
180
|
+
baseTasks.some((task, index) => !isRecord(task) || task.id !== update.taskStates[index].id)
|
|
181
|
+
) {
|
|
182
|
+
throw new Error("compact update tasks do not match the baseline tasks");
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
...baseline.payload,
|
|
186
|
+
state: update.state,
|
|
187
|
+
progress: update.progress,
|
|
188
|
+
tasks: baseTasks.map((task, index) => ({
|
|
189
|
+
...(task as Record<string, unknown>),
|
|
190
|
+
done: update.taskStates[index].done,
|
|
191
|
+
})),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
1
3
|
import readline from "node:readline";
|
|
2
4
|
import { Box, Text, render as inkRender } from "ink";
|
|
3
5
|
import { useEffect } from "react";
|
|
4
6
|
|
|
7
|
+
import { BRAND_ACCENT } from "../../brand/palette";
|
|
5
8
|
import { WizardFooter } from "./wizard-footer";
|
|
6
9
|
|
|
10
|
+
function Choice({ label, selected }: { label: string; selected: boolean }) {
|
|
11
|
+
return (
|
|
12
|
+
<Text>
|
|
13
|
+
<Text color={BRAND_ACCENT}>{selected ? "▸" : " "}</Text>{" "}
|
|
14
|
+
<Text bold={selected} dimColor={!selected}>
|
|
15
|
+
{label}
|
|
16
|
+
</Text>
|
|
17
|
+
</Text>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
interface ConfirmPromptAppProps {
|
|
8
22
|
question: string;
|
|
9
23
|
yesSelected: boolean;
|
|
@@ -17,15 +31,13 @@ export function ConfirmPromptApp({ question, yesSelected, onMounted }: ConfirmPr
|
|
|
17
31
|
|
|
18
32
|
return (
|
|
19
33
|
<Box flexDirection="column" width="100%">
|
|
20
|
-
<
|
|
21
|
-
<Text bold>{question}</Text>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</Box>
|
|
28
|
-
</Box>
|
|
34
|
+
<Text>
|
|
35
|
+
<Text color={BRAND_ACCENT}>?</Text> <Text bold>{question}</Text>
|
|
36
|
+
{" "}
|
|
37
|
+
<Choice label="Yes" selected={yesSelected} />
|
|
38
|
+
{" "}
|
|
39
|
+
<Choice label="No" selected={!yesSelected} />
|
|
40
|
+
</Text>
|
|
29
41
|
<WizardFooter hint="y yes · n no · ← → navigate · enter confirm · q cancel" />
|
|
30
42
|
</Box>
|
|
31
43
|
);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
1
3
|
import { Text } from "ink";
|
|
2
4
|
|
|
5
|
+
import { BRAND_ACCENT } from "../../brand/palette";
|
|
6
|
+
|
|
3
7
|
export interface SelectMenuItem {
|
|
4
8
|
key: string;
|
|
5
9
|
label: string;
|
|
@@ -21,9 +25,12 @@ export function SelectMenu({ items, activeIndex, mode = "multi" }: SelectMenuPro
|
|
|
21
25
|
const active = i === activeIndex;
|
|
22
26
|
const indicator = item.indicator ?? (mode === "radio" ? "○" : undefined);
|
|
23
27
|
return (
|
|
24
|
-
<Text key={item.key}
|
|
25
|
-
{active ?
|
|
26
|
-
|
|
28
|
+
<Text key={item.key} dimColor={item.dimColor} wrap="truncate-end">
|
|
29
|
+
<Text color={active ? BRAND_ACCENT : undefined}>
|
|
30
|
+
{active ? "▸" : " "}
|
|
31
|
+
{indicator !== undefined ? ` ${indicator}` : ""}
|
|
32
|
+
</Text>{" "}
|
|
33
|
+
<Text bold={active}>{item.label}</Text>
|
|
27
34
|
{item.description ? <Text dimColor> {item.description}</Text> : null}
|
|
28
35
|
</Text>
|
|
29
36
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
1
3
|
import { useEffect, useState } from "react";
|
|
2
4
|
|
|
3
|
-
const SPINNER_FRAMES = ["
|
|
4
|
-
const SPINNER_INTERVAL_MS =
|
|
5
|
+
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
6
|
+
const SPINNER_INTERVAL_MS = 80;
|
|
5
7
|
|
|
6
8
|
export function useSpinnerFrame(active: boolean, intervalMs: number = SPINNER_INTERVAL_MS): string {
|
|
7
9
|
const [frame, setFrame] = useState(0);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
3
|
+
import { Box, Static, Text, render as inkRender, renderToString } from "ink";
|
|
2
4
|
|
|
5
|
+
import { BRAND_ACCENT } from "../../brand/palette";
|
|
6
|
+
import { installLiveProgress } from "../live-progress";
|
|
3
7
|
import { useSpinnerFrame } from "./spinner";
|
|
4
|
-
import { MIDNIGHT_PURPLE_BRIGHT } from "./theme";
|
|
5
8
|
|
|
6
9
|
export type StartupStepStatus = "running" | "done" | "error";
|
|
7
10
|
|
|
@@ -11,42 +14,108 @@ export interface StartupStep {
|
|
|
11
14
|
status: StartupStepStatus;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* A line printed once: a finished step, the start line of a step that hands
|
|
19
|
+
* the terminal over, or a warning. `key` stays unique when a step id runs again.
|
|
20
|
+
*/
|
|
21
|
+
export interface StartupLogEntry {
|
|
22
|
+
key: string;
|
|
23
|
+
kind: "done" | "error" | "handover" | "warning";
|
|
24
|
+
label: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function LogRow({ entry }: { entry: StartupLogEntry }) {
|
|
28
|
+
switch (entry.kind) {
|
|
29
|
+
case "done":
|
|
30
|
+
return (
|
|
31
|
+
<Text wrap="truncate-end">
|
|
32
|
+
{" "}
|
|
33
|
+
<Text color={BRAND_ACCENT}>✓</Text> {entry.label}
|
|
34
|
+
</Text>
|
|
35
|
+
);
|
|
36
|
+
case "error":
|
|
37
|
+
return (
|
|
38
|
+
<Text wrap="truncate-end">
|
|
39
|
+
{" "}
|
|
40
|
+
<Text color="red">✗</Text> {entry.label}
|
|
41
|
+
<Text color="red"> failed</Text>
|
|
42
|
+
</Text>
|
|
43
|
+
);
|
|
44
|
+
case "handover":
|
|
45
|
+
return (
|
|
46
|
+
<Text wrap="truncate-end">
|
|
47
|
+
{" "}
|
|
48
|
+
{entry.label}
|
|
49
|
+
</Text>
|
|
50
|
+
);
|
|
51
|
+
case "warning":
|
|
52
|
+
return (
|
|
53
|
+
<Text color="yellow">
|
|
54
|
+
{" "}
|
|
55
|
+
<Text bold>warning</Text> {entry.label}
|
|
56
|
+
</Text>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
16
60
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
61
|
+
/** The same line without colour or cursor control, for output that is not a terminal. */
|
|
62
|
+
function formatPlainLogEntry(entry: StartupLogEntry): string {
|
|
63
|
+
switch (entry.kind) {
|
|
64
|
+
case "done":
|
|
65
|
+
return ` ✓ ${entry.label}`;
|
|
66
|
+
case "error":
|
|
67
|
+
return ` ✗ ${entry.label} failed`;
|
|
68
|
+
case "handover":
|
|
69
|
+
return ` ${entry.label}`;
|
|
70
|
+
case "warning":
|
|
71
|
+
return ` warning ${entry.label}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
25
74
|
|
|
75
|
+
function LiveRow({ step }: { step: StartupStep }) {
|
|
76
|
+
const spinner = useSpinnerFrame(true);
|
|
26
77
|
return (
|
|
27
|
-
<Text>
|
|
28
|
-
{
|
|
29
|
-
<Text color={step.
|
|
30
|
-
{step.label}
|
|
31
|
-
</Text>
|
|
78
|
+
<Text wrap="truncate-end">
|
|
79
|
+
{" "}
|
|
80
|
+
<Text color={BRAND_ACCENT}>{spinner}</Text> {step.label}
|
|
32
81
|
</Text>
|
|
33
82
|
);
|
|
34
83
|
}
|
|
35
84
|
|
|
36
85
|
export interface StartupProgressAppProps {
|
|
37
86
|
title: string;
|
|
87
|
+
/** False when the screen remounts after a hand-over; the header is already printed. */
|
|
88
|
+
showHeader: boolean;
|
|
38
89
|
steps: StartupStep[];
|
|
90
|
+
/** Append-only; Ink's Static prints each entry once. */
|
|
91
|
+
log: StartupLogEntry[];
|
|
39
92
|
}
|
|
40
93
|
|
|
41
|
-
|
|
94
|
+
type HeaderItem = { key: "header"; title: string };
|
|
95
|
+
|
|
96
|
+
function StartupProgressApp({ title, showHeader, steps, log }: StartupProgressAppProps) {
|
|
97
|
+
// The newest running step is the one live line.
|
|
98
|
+
const running = steps.findLast((step) => step.status === "running");
|
|
99
|
+
const printed: (HeaderItem | StartupLogEntry)[] = showHeader
|
|
100
|
+
? [{ key: "header", title }, ...log]
|
|
101
|
+
: log;
|
|
42
102
|
return (
|
|
43
103
|
<Box flexDirection="column">
|
|
44
|
-
<
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
104
|
+
<Static items={printed}>
|
|
105
|
+
{(item) =>
|
|
106
|
+
"kind" in item ? (
|
|
107
|
+
<LogRow key={item.key} entry={item} />
|
|
108
|
+
) : (
|
|
109
|
+
<Text key={item.key} wrap="truncate-end">
|
|
110
|
+
<Text bold color={BRAND_ACCENT}>
|
|
111
|
+
mate
|
|
112
|
+
</Text>{" "}
|
|
113
|
+
· {item.title}
|
|
114
|
+
</Text>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
</Static>
|
|
118
|
+
{running ? <LiveRow step={running} /> : null}
|
|
50
119
|
</Box>
|
|
51
120
|
);
|
|
52
121
|
}
|
|
@@ -55,8 +124,16 @@ export interface StartupProgressController {
|
|
|
55
124
|
start(id: string, label: string): void;
|
|
56
125
|
succeed(id: string): void;
|
|
57
126
|
fail(id: string): void;
|
|
58
|
-
/** Marks whichever step is currently running as failed (used for unexpected errors). */
|
|
127
|
+
/** Marks whichever step is currently running or handed over as failed (used for unexpected errors). */
|
|
59
128
|
failCurrent(): void;
|
|
129
|
+
/** Runs `fn` as a live step: `✓` when it resolves, `✗` when it throws (rethrown). */
|
|
130
|
+
step<T>(id: string, label: string, fn: () => T | Promise<T>): Promise<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Prints a start line and leaves the terminal to a child process or prompt,
|
|
133
|
+
* with no spinner, until `succeed` or `fail` prints the result line.
|
|
134
|
+
*/
|
|
135
|
+
handOver(id: string, label: string): void;
|
|
136
|
+
warn(message: string): void;
|
|
60
137
|
stop(): void;
|
|
61
138
|
}
|
|
62
139
|
|
|
@@ -64,6 +141,8 @@ export interface StartupProgressDeps {
|
|
|
64
141
|
render?: typeof inkRender;
|
|
65
142
|
stdout?: NodeJS.WriteStream;
|
|
66
143
|
stderr?: NodeJS.WriteStream;
|
|
144
|
+
/** Animated Ink screen when true, plain lines otherwise. Defaults to `stdout.isTTY`. */
|
|
145
|
+
interactive?: boolean;
|
|
67
146
|
}
|
|
68
147
|
|
|
69
148
|
export function createStartupProgress(
|
|
@@ -71,45 +150,152 @@ export function createStartupProgress(
|
|
|
71
150
|
deps: StartupProgressDeps = {},
|
|
72
151
|
): StartupProgressController {
|
|
73
152
|
const render = deps.render ?? inkRender;
|
|
153
|
+
const stdout = deps.stdout ?? process.stdout;
|
|
154
|
+
const stderr = deps.stderr ?? process.stderr;
|
|
155
|
+
const interactive = deps.interactive ?? stdout.isTTY === true;
|
|
74
156
|
let steps: StartupStep[] = [];
|
|
157
|
+
/** Steps whose start line is printed and whose child owns the terminal. */
|
|
158
|
+
const handedOver = new Map<string, string>();
|
|
159
|
+
/** Entries printed by the current Ink mount. */
|
|
160
|
+
let log: StartupLogEntry[] = [];
|
|
161
|
+
let showHeader = true;
|
|
162
|
+
let entryCount = 0;
|
|
163
|
+
let instance: ReturnType<typeof inkRender> | undefined;
|
|
75
164
|
let stopped = false;
|
|
76
165
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
166
|
+
const app = () => (
|
|
167
|
+
<StartupProgressApp title={title} showHeader={showHeader} steps={steps} log={log} />
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const mount = (withHeader: boolean) => {
|
|
171
|
+
showHeader = withHeader;
|
|
172
|
+
log = [];
|
|
173
|
+
instance = render(app(), { stdout, stderr });
|
|
174
|
+
};
|
|
81
175
|
|
|
82
176
|
const rerender = () => {
|
|
177
|
+
instance?.rerender(app());
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const unmount = () => {
|
|
181
|
+
instance?.unmount();
|
|
182
|
+
instance = undefined;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const print = (kind: StartupLogEntry["kind"], label: string) => {
|
|
186
|
+
const entry: StartupLogEntry = { key: `${kind}:${entryCount++}`, kind, label };
|
|
187
|
+
if (!interactive) {
|
|
188
|
+
stdout.write(`${formatPlainLogEntry(entry)}\n`);
|
|
189
|
+
} else if (instance) {
|
|
190
|
+
log = [...log, entry];
|
|
191
|
+
rerender();
|
|
192
|
+
} else {
|
|
193
|
+
// Unmounted after a hand-over: write the line directly instead of remounting.
|
|
194
|
+
stdout.write(
|
|
195
|
+
`${renderToString(<LogRow entry={entry} />, { columns: stdout.columns || 80 })}\n`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/** Running live steps lose their spinner and finish later as handed-over steps. */
|
|
201
|
+
const handOverRunning = () => {
|
|
202
|
+
const running = steps.filter((step) => step.status === "running");
|
|
203
|
+
if (running.length === 0) return;
|
|
204
|
+
steps = steps.filter((step) => step.status !== "running");
|
|
205
|
+
for (const step of running) {
|
|
206
|
+
handedOver.set(step.id, step.label);
|
|
207
|
+
print("handover", step.label);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const finish = (id: string, status: "done" | "error") => {
|
|
83
212
|
if (stopped) return;
|
|
84
|
-
|
|
213
|
+
const step = steps.find((candidate) => candidate.id === id);
|
|
214
|
+
if (step) {
|
|
215
|
+
steps = steps.map((candidate) =>
|
|
216
|
+
candidate.id === id ? { ...candidate, status } : candidate,
|
|
217
|
+
);
|
|
218
|
+
print(status, step.label);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const label = handedOver.get(id);
|
|
222
|
+
if (label === undefined) return;
|
|
223
|
+
handedOver.delete(id);
|
|
224
|
+
print(status, label);
|
|
85
225
|
};
|
|
86
226
|
|
|
87
|
-
|
|
227
|
+
const controller: StartupProgressController = {
|
|
88
228
|
start(id, label) {
|
|
229
|
+
if (stopped) return;
|
|
230
|
+
handedOver.delete(id);
|
|
89
231
|
const existing = steps.some((step) => step.id === id);
|
|
90
232
|
steps = existing
|
|
91
233
|
? steps.map((step) => (step.id === id ? { id, label, status: "running" } : step))
|
|
92
234
|
: [...steps, { id, label, status: "running" }];
|
|
93
|
-
|
|
235
|
+
if (interactive && !instance) mount(false);
|
|
236
|
+
else rerender();
|
|
94
237
|
},
|
|
95
238
|
succeed(id) {
|
|
96
|
-
|
|
97
|
-
rerender();
|
|
239
|
+
finish(id, "done");
|
|
98
240
|
},
|
|
99
241
|
fail(id) {
|
|
100
|
-
|
|
101
|
-
rerender();
|
|
242
|
+
finish(id, "error");
|
|
102
243
|
},
|
|
103
244
|
failCurrent() {
|
|
104
|
-
const running = steps.
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
245
|
+
const running = steps.findLast((step) => step.status === "running");
|
|
246
|
+
if (running) {
|
|
247
|
+
finish(running.id, "error");
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const lastHandedOver = [...handedOver.keys()].at(-1);
|
|
251
|
+
if (lastHandedOver !== undefined) finish(lastHandedOver, "error");
|
|
252
|
+
},
|
|
253
|
+
async step(id, label, fn) {
|
|
254
|
+
controller.start(id, label);
|
|
255
|
+
try {
|
|
256
|
+
const result = await fn();
|
|
257
|
+
finish(id, "done");
|
|
258
|
+
return result;
|
|
259
|
+
} catch (error) {
|
|
260
|
+
finish(id, "error");
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
handOver(id, label) {
|
|
265
|
+
if (stopped) return;
|
|
266
|
+
steps = steps.filter((step) => step.id !== id);
|
|
267
|
+
handOverRunning();
|
|
268
|
+
handedOver.set(id, label);
|
|
269
|
+
print("handover", label);
|
|
270
|
+
unmount();
|
|
271
|
+
},
|
|
272
|
+
warn(message) {
|
|
273
|
+
if (stopped) return;
|
|
274
|
+
// Outside a terminal there is no live line to protect; warnings stay on stderr.
|
|
275
|
+
if (!interactive) stderr.write(`${message}\n`);
|
|
276
|
+
else print("warning", message);
|
|
108
277
|
},
|
|
109
278
|
stop() {
|
|
110
279
|
if (stopped) return;
|
|
111
280
|
stopped = true;
|
|
112
|
-
|
|
281
|
+
unmount();
|
|
282
|
+
restoreLiveProgress();
|
|
113
283
|
},
|
|
114
284
|
};
|
|
285
|
+
|
|
286
|
+
const restoreLiveProgress = interactive
|
|
287
|
+
? installLiveProgress({
|
|
288
|
+
warn: (message) => controller.warn(message),
|
|
289
|
+
releaseTerminal: () => {
|
|
290
|
+
if (stopped) return;
|
|
291
|
+
handOverRunning();
|
|
292
|
+
unmount();
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
: () => {};
|
|
296
|
+
|
|
297
|
+
if (interactive) mount(true);
|
|
298
|
+
else stdout.write(`mate · ${title}\n`);
|
|
299
|
+
|
|
300
|
+
return controller;
|
|
115
301
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
1
3
|
import { Box, Text } from "ink";
|
|
2
4
|
|
|
3
5
|
import { BRAND_ACCENT } from "../../brand/palette";
|
|
@@ -12,20 +14,20 @@ export function WizardHeader({ title, step, totalSteps }: WizardHeaderProps) {
|
|
|
12
14
|
const showStepCounter = totalSteps > 1;
|
|
13
15
|
|
|
14
16
|
return (
|
|
15
|
-
<Box
|
|
16
|
-
<
|
|
17
|
+
<Box width="100%" justifyContent="space-between">
|
|
18
|
+
<Text wrap="truncate-end">
|
|
17
19
|
<Text bold color={BRAND_ACCENT}>
|
|
18
|
-
mate
|
|
20
|
+
mate
|
|
19
21
|
</Text>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
<Text dimColor> · {title}</Text>
|
|
23
|
+
</Text>
|
|
24
|
+
{showStepCounter ? (
|
|
25
|
+
<Box flexShrink={0} marginLeft={2}>
|
|
26
|
+
<Text dimColor>
|
|
27
|
+
{step + 1} / {totalSteps}
|
|
28
|
+
</Text>
|
|
27
29
|
</Box>
|
|
28
|
-
|
|
30
|
+
) : null}
|
|
29
31
|
</Box>
|
|
30
32
|
);
|
|
31
33
|
}
|