@uniqbit/mate-core 0.18.5 → 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/companion-instructions.mjs +9 -0
- package/claude-plugin/hooks/hooks.json +21 -2
- 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 +52 -15
- package/src/brand/art.generated.ts +69 -0
- package/src/brand/index.ts +12 -0
- package/src/brand/palette.ts +19 -0
- package/src/brand/svg.generated.ts +8 -0
- package/src/brand/terminal.ts +88 -0
- package/src/brand/types.ts +33 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +12 -0
- package/src/cli/commands/artifact/delivery/archive.ts +125 -0
- package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
- package/src/cli/commands/artifact/delivery/environment.ts +127 -0
- package/src/cli/commands/artifact/delivery/link.ts +174 -0
- package/src/cli/commands/artifact/delivery/output.ts +89 -0
- package/src/cli/commands/artifact/finish/command.ts +83 -8
- package/src/cli/commands/artifact/finish/engine.ts +91 -14
- package/src/cli/commands/artifact/finish/finisher.ts +10 -0
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +182 -138
- package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/artifact/pending/command.ts +31 -3
- package/src/cli/commands/artifact/pending/discovery.ts +21 -57
- package/src/cli/commands/cap/graphify.ts +52 -3
- package/src/cli/commands/cap/index-cmd.ts +71 -15
- package/src/cli/commands/cap/openspec.ts +13 -25
- 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 +68 -46
- 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 +143 -48
- package/src/cli/commands/doctor.ts +195 -7
- 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/plugin/install.ts +9 -4
- package/src/cli/commands/plugin/plugin.ts +3 -2
- package/src/cli/commands/report/adapter.ts +11 -2
- package/src/cli/commands/report/contract.ts +21 -0
- package/src/cli/commands/report/highlight.ts +34 -4
- package/src/cli/commands/report/index.ts +20 -1
- package/src/cli/commands/report/markdown.ts +110 -0
- package/src/cli/commands/report/palette.ts +118 -0
- package/src/cli/commands/report/renderer.ts +456 -153
- package/src/cli/commands/report/types.ts +16 -0
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/setup.ts +50 -24
- package/src/cli/commands/studio/factory-credential.ts +49 -0
- package/src/cli/commands/studio/index.ts +29 -2
- package/src/cli/commands/studio/openspec-cli.ts +10 -58
- package/src/cli/commands/studio/payload.ts +249 -15
- package/src/cli/commands/studio/routes.ts +41 -6
- package/src/cli/commands/studio/selection.ts +161 -17
- package/src/cli/commands/studio/server.ts +404 -324
- 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/commands/wrap.ts +5 -13
- 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 +22 -1
- package/src/cli/parse-flags.ts +32 -6
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +86 -151
- package/src/cli/usage.ts +14 -0
- package/src/create-mate.ts +5 -4
- package/src/hooks/companion-instructions.ts +190 -0
- package/src/hooks/hook-io.ts +63 -0
- package/src/hooks/session-banner.ts +21 -29
- package/src/hooks/session-guidance.ts +9 -17
- package/src/hooks/session-prepare.ts +115 -28
- package/src/hooks/tokensave-route.ts +26 -0
- package/src/hooks/validate-artifact-path.ts +82 -24
- package/src/index.ts +4 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -0
- package/src/lib/change-layout.ts +154 -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 +16 -12
- package/src/lib/context-mode-package.ts +24 -11
- package/src/lib/delivery/archive-change.ts +166 -0
- package/src/lib/delivery/branches.ts +132 -0
- package/src/lib/delivery/environment.ts +35 -0
- package/src/lib/delivery/forge.ts +279 -0
- package/src/lib/delivery/merge-git.ts +261 -0
- package/src/lib/delivery/overlap.ts +209 -0
- package/src/lib/delivery/record-delivery.ts +283 -0
- package/src/lib/delivery/record.ts +403 -0
- package/src/lib/delivery/refresh.ts +268 -0
- package/src/lib/delivery/repository-access.ts +141 -0
- package/src/lib/delivery/resolve-branch.ts +162 -0
- package/src/lib/delivery/stages.ts +111 -0
- package/src/lib/delivery/token.ts +24 -0
- 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/frontmatter.ts +18 -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/opencode-plugin-package.ts +5 -5
- package/src/lib/openspec-cli.ts +116 -0
- package/src/lib/openspec-scopes.ts +86 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
- package/src/lib/orchestrator/adapters/claude.ts +54 -41
- package/src/lib/orchestrator/adapters/opencode.ts +2 -0
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +31 -25
- package/src/lib/orchestrator/openspec-store.ts +14 -54
- package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
- package/src/lib/orchestrator/projection-claude-links.ts +159 -0
- package/src/lib/orchestrator/projection-claude-skills.ts +19 -137
- package/src/lib/orchestrator/projection-entries.ts +100 -34
- 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-runtime-documents.ts +15 -6
- package/src/lib/orchestrator/projection-types.ts +36 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +87 -0
- package/src/lib/orchestrator/session-context-link.ts +67 -0
- package/src/lib/orchestrator/session-prepare.ts +45 -5
- package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
- package/src/lib/orchestrator/types.ts +7 -2
- package/src/lib/orchestrator/working-repo-projection.ts +50 -7
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/orchestrator/wrap-pass.ts +22 -1
- package/src/lib/package-paths.ts +37 -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 +109 -7
- package/src/opencode/companion-policy.ts +37 -18
- package/src/opencode/enter-worktree.ts +72 -0
- package/src/opencode/projected-guidance.ts +4 -1
- package/src/opencode/session-prepare.ts +2 -1
- package/src/opencode/tui.tsx +13 -6
- package/src/plugins.ts +1 -0
- package/src/runtime/artifact-refusal.ts +63 -0
- package/src/runtime/claude-delivery-plan.ts +107 -8
- package/src/runtime/commit-attribution-guard.ts +181 -0
- package/src/runtime/companion-git.ts +52 -10
- package/src/runtime/companion-guidance.ts +20 -8
- package/src/runtime/companion-instructions.ts +340 -0
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/env.ts +48 -3
- package/src/runtime/error-message.ts +4 -0
- package/src/runtime/git-layout.ts +219 -0
- package/src/runtime/index.ts +29 -0
- package/src/runtime/managed-block.ts +117 -0
- package/src/runtime/markdown-scan.ts +266 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +50 -2
- package/src/runtime/projected-flag.ts +7 -0
- package/src/runtime/projected-guidance.ts +1 -0
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/runtime-document-manifest.ts +62 -11
- package/src/runtime/secret-guard.ts +162 -0
- package/src/runtime/secret-patterns.ts +397 -0
- package/src/runtime/secret-scan.ts +90 -0
- package/src/runtime/session-context.ts +98 -0
- package/src/runtime/session-kind.ts +13 -0
- package/src/runtime/shell-heredoc.ts +81 -0
- package/src/runtime/tokensave-route.ts +152 -0
- package/src/runtime/wrap-state.ts +44 -2
- package/src/runtime/write-atomic.ts +64 -0
- package/src/studio.ts +124 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
- package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
- package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
- package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +134 -0
- 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 +200 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +86 -0
- package/src/templates/mate-skills/{claude/mate-openspec-backfill → agents/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
- 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 +12 -5
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +108 -0
- 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 +169 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/agents/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
- package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +134 -0
- 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 +200 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +86 -0
- package/src/templates/mate-skills/{agents/mate-openspec-backfill → claude/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
- 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 +12 -5
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +108 -0
- 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 +169 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/claude/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
- package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/openspec-references.ts +142 -0
- package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +3938 -391
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +56 -7
- package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
- package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
- package/src/tools/setup/capabilities/graphify.ts +46 -7
- package/src/tools/setup/capabilities/openspec.ts +163 -272
- 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 +113 -71
- package/src/tools/setup/context-services.ts +9 -17
- package/src/tools/setup/dynamic-plugins/install.ts +24 -28
- package/src/tools/setup/engine.ts +100 -23
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/managed-output.ts +51 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/mate.ts +86 -11
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +40 -0
- package/src/tools/setup/plugins/guidance.ts +7 -4
- package/src/tools/setup/providers/agent-file-sections.ts +4 -2
- package/src/tools/setup/providers/claude-attribution.ts +65 -0
- package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +51 -19
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +290 -8
- package/src/tools/setup/providers/opencode.ts +180 -1
- package/src/tools/setup/utils.ts +18 -4
- 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 +183 -26
- 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/wrappers/bin/graphify +52 -4
- package/wrappers/bin/openspec +33 -9
- package/wrappers/lib/graphify-gate.mjs +8 -0
- package/src/cli/commands/studio/views/client.ts +0 -654
- 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 -107
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -842
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/reports/index.tsx +0 -49
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -87
- package/src/cli/commands/studio/views/specs/index.tsx +0 -157
- package/src/cli/commands/studio/views/styles.ts +0 -519
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -43
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
- package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
- package/src/lib/components/theme.ts +0 -2
- package/src/tools/setup/git-utils.ts +0 -30
- package/src/tools/setup/runtime-documents.ts +0 -291
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { pathIsDirectory } from "./fs-utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a change lives in a Companion Repository: the active `openspec/changes/<name>/`
|
|
8
|
+
* directory, its dated archive `openspec/changes/archive/YYYY-MM-DD-<name>/`, and the
|
|
9
|
+
* canonical specs its delta specs map to. Only directories count, and only names are read.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Companion-relative POSIX paths. */
|
|
13
|
+
export const CHANGES_RELATIVE_DIR = "openspec/changes";
|
|
14
|
+
export const ARCHIVE_RELATIVE_DIR = "openspec/changes/archive";
|
|
15
|
+
export const SPECS_RELATIVE_DIR = "openspec/specs";
|
|
16
|
+
|
|
17
|
+
const ARCHIVE_DIR_NAME = "archive";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One path segment: no separator, NUL, or leading dot (so never `.`, `..`, or hidden).
|
|
21
|
+
* Wider than OpenSpec's kebab-case, so archives made under older rules still resolve.
|
|
22
|
+
*/
|
|
23
|
+
const SEGMENT = /^[^./\\\0][^/\\\0]*$/;
|
|
24
|
+
|
|
25
|
+
/** The `YYYY-MM-DD-<name>` anchor `openspec archive` gives an archived change. */
|
|
26
|
+
const ANCHOR = /^(\d{4}-\d{2}-\d{2})-(.+)$/;
|
|
27
|
+
|
|
28
|
+
export function changesDirOf(companionPath: string): string {
|
|
29
|
+
return path.join(companionPath, ...CHANGES_RELATIVE_DIR.split("/"));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function archiveDirOf(companionPath: string): string {
|
|
33
|
+
return path.join(companionPath, ...ARCHIVE_RELATIVE_DIR.split("/"));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A change name or archive anchor: one path segment that is not the archive directory. */
|
|
37
|
+
export function isChangeName(candidate: string): boolean {
|
|
38
|
+
return SEGMENT.test(candidate) && candidate !== ARCHIVE_DIR_NAME;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Anchor {
|
|
42
|
+
date: string;
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** `2026-01-02-acme` → `{date: "2026-01-02", name: "acme"}`; null for anything else, `2026-01-02-` included. */
|
|
47
|
+
export function parseAnchor(candidate: string): Anchor | null {
|
|
48
|
+
const match = ANCHOR.exec(candidate);
|
|
49
|
+
if (!match || !isChangeName(match[2])) return null;
|
|
50
|
+
return { date: match[1], name: match[2] };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The change name of an archive anchor (`2026-01-02-acme` → `acme`); other names pass through. */
|
|
54
|
+
export function changeNameOf(anchorOrName: string): string {
|
|
55
|
+
return parseAnchor(anchorOrName)?.name ?? anchorOrName;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function directoryNames(dir: string): Promise<string[]> {
|
|
59
|
+
try {
|
|
60
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
61
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
62
|
+
} catch {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Active change names, sorted. */
|
|
68
|
+
export async function activeChanges(companionPath: string): Promise<string[]> {
|
|
69
|
+
return (await directoryNames(changesDirOf(companionPath))).filter(isChangeName).toSorted();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Archive anchors, optionally only those of change `name`, sorted oldest first. */
|
|
73
|
+
export async function archiveAnchors(companionPath: string, name?: string): Promise<string[]> {
|
|
74
|
+
return (await directoryNames(archiveDirOf(companionPath)))
|
|
75
|
+
.filter((anchor) => {
|
|
76
|
+
const parsed = parseAnchor(anchor);
|
|
77
|
+
return parsed !== null && (name === undefined || parsed.name === name);
|
|
78
|
+
})
|
|
79
|
+
.toSorted();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ChangeLocation {
|
|
83
|
+
dir: string;
|
|
84
|
+
archived: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Resolves a change name or anchor to its directory: the archive an anchor names exactly,
|
|
89
|
+
* else the active change, else the newest archive of that name. Anything that is not a
|
|
90
|
+
* single change-name segment resolves to nothing.
|
|
91
|
+
*/
|
|
92
|
+
export async function locateChange(
|
|
93
|
+
companionPath: string,
|
|
94
|
+
target: string,
|
|
95
|
+
): Promise<ChangeLocation | null> {
|
|
96
|
+
if (!isChangeName(target)) return null;
|
|
97
|
+
const archiveDir = archiveDirOf(companionPath);
|
|
98
|
+
if (parseAnchor(target) && (await pathIsDirectory(path.join(archiveDir, target)))) {
|
|
99
|
+
return { dir: path.join(archiveDir, target), archived: true };
|
|
100
|
+
}
|
|
101
|
+
const active = path.join(changesDirOf(companionPath), target);
|
|
102
|
+
if (await pathIsDirectory(active)) return { dir: active, archived: false };
|
|
103
|
+
const newest = (await archiveAnchors(companionPath, target)).at(-1);
|
|
104
|
+
return newest ? { dir: path.join(archiveDir, newest), archived: true } : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface DeltaSpec {
|
|
108
|
+
/** POSIX path under the change's `specs/`, e.g. `identity/user-auth/spec.md`. */
|
|
109
|
+
file: string;
|
|
110
|
+
/** The companion-relative canonical path the file maps to. */
|
|
111
|
+
canonical: string;
|
|
112
|
+
/** The capability path of a `spec.md` below `specs/`; null for any other file. */
|
|
113
|
+
capability: string | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Every file below `dir` at any depth, as sorted POSIX paths relative to it. Reads directory
|
|
118
|
+
* entry names only, never contents; an unreadable directory contributes nothing.
|
|
119
|
+
*/
|
|
120
|
+
export async function filesBelow(dir: string): Promise<string[]> {
|
|
121
|
+
const walk = async (current: string, relative: string): Promise<string[]> => {
|
|
122
|
+
let entries;
|
|
123
|
+
try {
|
|
124
|
+
entries = await fs.readdir(current, { withFileTypes: true });
|
|
125
|
+
} catch {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const nested = await Promise.all(
|
|
129
|
+
entries.map(async (entry) => {
|
|
130
|
+
const entryRelative = relative ? `${relative}/${entry.name}` : entry.name;
|
|
131
|
+
if (entry.isDirectory()) return walk(path.join(current, entry.name), entryRelative);
|
|
132
|
+
return entry.isFile() ? [entryRelative] : [];
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
return nested.flat();
|
|
136
|
+
};
|
|
137
|
+
return (await walk(dir, "")).toSorted();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Every file under the change's `specs/`, at any depth, sorted. Reads directory entry
|
|
142
|
+
* names only, never contents. A change without `specs/` has none.
|
|
143
|
+
*/
|
|
144
|
+
export async function deltaSpecs(changeDir: string): Promise<DeltaSpec[]> {
|
|
145
|
+
const files = await filesBelow(path.join(changeDir, "specs"));
|
|
146
|
+
return files.map((file) => {
|
|
147
|
+
const capability = path.posix.dirname(file);
|
|
148
|
+
return {
|
|
149
|
+
file,
|
|
150
|
+
canonical: `${SPECS_RELATIVE_DIR}/${file}`,
|
|
151
|
+
capability: path.posix.basename(file) === "spec.md" && capability !== "." ? capability : null,
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
}
|
|
@@ -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,5 +1,9 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource react */
|
|
1
3
|
import { Box, Text } from "ink";
|
|
2
4
|
|
|
5
|
+
import { BRAND_ACCENT } from "../../brand/palette";
|
|
6
|
+
|
|
3
7
|
interface WizardHeaderProps {
|
|
4
8
|
title: string;
|
|
5
9
|
step: number;
|
|
@@ -10,20 +14,20 @@ export function WizardHeader({ title, step, totalSteps }: WizardHeaderProps) {
|
|
|
10
14
|
const showStepCounter = totalSteps > 1;
|
|
11
15
|
|
|
12
16
|
return (
|
|
13
|
-
<Box
|
|
14
|
-
<
|
|
15
|
-
<Text bold color=
|
|
16
|
-
mate
|
|
17
|
+
<Box width="100%" justifyContent="space-between">
|
|
18
|
+
<Text wrap="truncate-end">
|
|
19
|
+
<Text bold color={BRAND_ACCENT}>
|
|
20
|
+
mate
|
|
17
21
|
</Text>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
<Text dimColor> · {title}</Text>
|
|
23
|
+
</Text>
|
|
24
|
+
{showStepCounter ? (
|
|
25
|
+
<Box flexShrink={0} marginLeft={2}>
|
|
26
|
+
<Text dimColor>
|
|
27
|
+
{step + 1} / {totalSteps}
|
|
28
|
+
</Text>
|
|
25
29
|
</Box>
|
|
26
|
-
|
|
30
|
+
) : null}
|
|
27
31
|
</Box>
|
|
28
32
|
);
|
|
29
33
|
}
|