rovecode 0.3.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/LICENSE +662 -0
- package/README.md +737 -0
- package/THIRD_PARTY_NOTICES.md +268 -0
- package/bin/rovecode.ts +21 -0
- package/package.json +56 -0
- package/src/acp/server.ts +374 -0
- package/src/cli/auth-login.ts +122 -0
- package/src/cli/connect.ts +244 -0
- package/src/cli/context-cmd.ts +199 -0
- package/src/cli/dispatch.ts +82 -0
- package/src/cli/doctor.ts +362 -0
- package/src/cli/export.ts +276 -0
- package/src/cli/help.ts +293 -0
- package/src/cli/is-tui-invocation.ts +8 -0
- package/src/cli/main.ts +583 -0
- package/src/cli/market-cmd.ts +658 -0
- package/src/cli/mcp-login.ts +141 -0
- package/src/cli/mcp-market-cmd.ts +302 -0
- package/src/cli/output.ts +382 -0
- package/src/cli/repl.ts +250 -0
- package/src/cli/repomap-root.ts +14 -0
- package/src/cli/resume.ts +57 -0
- package/src/cli/run-flags.ts +43 -0
- package/src/cli/run-limits.ts +78 -0
- package/src/cli/runtime.ts +931 -0
- package/src/cli/session-arg.ts +30 -0
- package/src/cli/sessions-cmd.ts +145 -0
- package/src/cli/setup.ts +153 -0
- package/src/cli/skills-cmd.ts +194 -0
- package/src/cli/start-chat.ts +65 -0
- package/src/cli/trust-cmd.ts +52 -0
- package/src/coding/bash.ts +148 -0
- package/src/coding/checkpoints.ts +327 -0
- package/src/coding/diff.ts +138 -0
- package/src/coding/files.ts +341 -0
- package/src/coding/hashline.ts +274 -0
- package/src/coding/lsp-gate.ts +254 -0
- package/src/coding/lsp-servers.ts +147 -0
- package/src/coding/lsp.ts +283 -0
- package/src/coding/repomap-cache.ts +99 -0
- package/src/coding/repomap-files.ts +192 -0
- package/src/coding/repomap.ts +481 -0
- package/src/core/agents.ts +255 -0
- package/src/core/compaction.ts +259 -0
- package/src/core/config.ts +289 -0
- package/src/core/context-report.ts +228 -0
- package/src/core/context.ts +60 -0
- package/src/core/count-remote.ts +107 -0
- package/src/core/execpolicy-rules.ts +196 -0
- package/src/core/execpolicy.ts +385 -0
- package/src/core/executor.ts +454 -0
- package/src/core/guardrails.ts +400 -0
- package/src/core/hooks.ts +411 -0
- package/src/core/images.ts +230 -0
- package/src/core/intro.ts +266 -0
- package/src/core/loop.ts +567 -0
- package/src/core/modes.ts +372 -0
- package/src/core/orchestrator.ts +245 -0
- package/src/core/proc-group.ts +48 -0
- package/src/core/project-trust.ts +98 -0
- package/src/core/reflection.ts +165 -0
- package/src/core/sandbox-config.ts +186 -0
- package/src/core/session-id.ts +24 -0
- package/src/core/session-images.ts +73 -0
- package/src/core/session-ops.ts +183 -0
- package/src/core/session-text.ts +29 -0
- package/src/core/session.ts +469 -0
- package/src/core/settings.ts +170 -0
- package/src/core/tasks.ts +646 -0
- package/src/core/token-scale.ts +108 -0
- package/src/core/tools.ts +309 -0
- package/src/core/trust.ts +104 -0
- package/src/core/types.ts +330 -0
- package/src/core/update-check.ts +171 -0
- package/src/core/usage.ts +204 -0
- package/src/core/validate.ts +121 -0
- package/src/core/verify-gate.ts +159 -0
- package/src/core/verify.ts +236 -0
- package/src/core/voice.ts +158 -0
- package/src/core/win-job.ts +183 -0
- package/src/core/workspace.ts +184 -0
- package/src/design/audit.ts +797 -0
- package/src/design/direction.ts +190 -0
- package/src/design/rules.ts +157 -0
- package/src/eval/bench.ts +150 -0
- package/src/eval/gauntlet-runner.ts +215 -0
- package/src/eval/gauntlet-support.ts +84 -0
- package/src/eval/gauntlet-wave3.ts +269 -0
- package/src/eval/gauntlet-wave4.ts +217 -0
- package/src/eval/gauntlet.ts +253 -0
- package/src/index.ts +17 -0
- package/src/lanes/agy.ts +95 -0
- package/src/lanes/approval.ts +24 -0
- package/src/lanes/claude.ts +129 -0
- package/src/lanes/codex.ts +127 -0
- package/src/lanes/events.ts +130 -0
- package/src/lanes/job.ts +142 -0
- package/src/lanes/opencode.ts +122 -0
- package/src/lanes/process.ts +184 -0
- package/src/lanes/progress.ts +183 -0
- package/src/lanes/registry.ts +178 -0
- package/src/lanes/runner.ts +124 -0
- package/src/lanes/types.ts +112 -0
- package/src/market/catalogs/mcp-docs.json +111 -0
- package/src/market/catalogs/plugins.json +111 -0
- package/src/market/catalogs/skills.json +478 -0
- package/src/market/clone.ts +72 -0
- package/src/market/context-cost.ts +121 -0
- package/src/market/digest.ts +106 -0
- package/src/market/index.ts +22 -0
- package/src/market/install.ts +578 -0
- package/src/market/manifest.ts +187 -0
- package/src/market/prereq.ts +145 -0
- package/src/market/registry.ts +363 -0
- package/src/market/resolve.ts +111 -0
- package/src/market/types.ts +236 -0
- package/src/market/validate.ts +227 -0
- package/src/mcp/client.ts +449 -0
- package/src/mcp/config.ts +252 -0
- package/src/mcp/local-package.ts +211 -0
- package/src/mcp/market-catalog.ts +84 -0
- package/src/mcp/market-install.ts +289 -0
- package/src/mcp/market.ts +362 -0
- package/src/mcp/oauth.ts +251 -0
- package/src/mcp/prompts-resources.ts +249 -0
- package/src/mcp/shared.ts +149 -0
- package/src/mcp/status.ts +67 -0
- package/src/mcp/tools.ts +275 -0
- package/src/mcp/transport.ts +122 -0
- package/src/mcp/trust.ts +25 -0
- package/src/memory/blocks.ts +278 -0
- package/src/memory/recall.ts +355 -0
- package/src/memory/scope.ts +182 -0
- package/src/memory/store.ts +105 -0
- package/src/memory/tools.ts +99 -0
- package/src/plugins/cli.ts +119 -0
- package/src/plugins/discover.ts +108 -0
- package/src/plugins/index.ts +50 -0
- package/src/plugins/install.ts +184 -0
- package/src/plugins/load.ts +124 -0
- package/src/plugins/manifest.ts +92 -0
- package/src/plugins/state.ts +83 -0
- package/src/providers/auth.ts +408 -0
- package/src/providers/cache.ts +223 -0
- package/src/providers/catalog-local.ts +160 -0
- package/src/providers/catalog.ts +421 -0
- package/src/providers/middleware-context.ts +86 -0
- package/src/providers/middleware.ts +373 -0
- package/src/providers/model-list.ts +23 -0
- package/src/providers/models-index.json +1 -0
- package/src/providers/oauth/common.ts +105 -0
- package/src/providers/oauth/device-code.ts +107 -0
- package/src/providers/oauth/github-copilot.ts +146 -0
- package/src/providers/oauth/loopback.ts +158 -0
- package/src/providers/oauth/openai.ts +163 -0
- package/src/providers/oauth/openrouter.ts +89 -0
- package/src/providers/oauth/pkce.ts +45 -0
- package/src/providers/oauth/registry.ts +39 -0
- package/src/providers/oauth/seam.ts +89 -0
- package/src/providers/profile-glm53.ts +111 -0
- package/src/providers/profile-sonnet5-persona.ts +65 -0
- package/src/providers/profile-sonnet5-voice.ts +23 -0
- package/src/providers/profiles.ts +156 -0
- package/src/providers/provider-config.ts +311 -0
- package/src/providers/registry.ts +333 -0
- package/src/providers/responses.ts +209 -0
- package/src/providers/retry.ts +234 -0
- package/src/providers/router.ts +294 -0
- package/src/providers/sse.ts +26 -0
- package/src/providers/stream-errors.ts +117 -0
- package/src/providers/stream.ts +566 -0
- package/src/providers/thinking.ts +189 -0
- package/src/providers/wire-messages.ts +129 -0
- package/src/providers/wire-responses.ts +79 -0
- package/src/providers/wire-select.ts +53 -0
- package/src/server/http.ts +291 -0
- package/src/server/openapi.ts +246 -0
- package/src/sextant/card-hits.ts +102 -0
- package/src/sextant/card-keys.ts +55 -0
- package/src/sextant/context-source.ts +157 -0
- package/src/sextant/crew-cards.ts +350 -0
- package/src/sextant/draw-agents.ts +273 -0
- package/src/sextant/draw-code.ts +388 -0
- package/src/sextant/draw-context.ts +222 -0
- package/src/sextant/draw-frame.ts +164 -0
- package/src/sextant/draw-market.ts +573 -0
- package/src/sextant/draw-messages.ts +386 -0
- package/src/sextant/draw-pet.ts +230 -0
- package/src/sextant/draw-plan.ts +187 -0
- package/src/sextant/draw-tabs.ts +85 -0
- package/src/sextant/draw-util.ts +65 -0
- package/src/sextant/draw-wizard.ts +378 -0
- package/src/sextant/engine.ts +230 -0
- package/src/sextant/frame-hits.ts +25 -0
- package/src/sextant/frame.ts +101 -0
- package/src/sextant/git-status.ts +197 -0
- package/src/sextant/grid.ts +59 -0
- package/src/sextant/input.ts +119 -0
- package/src/sextant/keys.ts +521 -0
- package/src/sextant/layout.ts +86 -0
- package/src/sextant/local-commands.ts +169 -0
- package/src/sextant/market-source.ts +287 -0
- package/src/sextant/mentions.ts +200 -0
- package/src/sextant/message-hits.ts +26 -0
- package/src/sextant/model.ts +387 -0
- package/src/sextant/overlays.ts +456 -0
- package/src/sextant/panel-hits.ts +38 -0
- package/src/sextant/pet.ts +399 -0
- package/src/sextant/screen.ts +324 -0
- package/src/sextant/scroll-hits.ts +66 -0
- package/src/sextant/scrollbar.ts +82 -0
- package/src/sextant/sextant-bridge.ts +174 -0
- package/src/sextant/sextant-cards.ts +142 -0
- package/src/sextant/sextant-diff-base.ts +63 -0
- package/src/sextant/sextant-files.ts +154 -0
- package/src/sextant/sextant-frame-loop.ts +335 -0
- package/src/sextant/sextant-renderer.ts +574 -0
- package/src/sextant/sextant-repo.ts +140 -0
- package/src/sextant/theme.ts +66 -0
- package/src/sextant/tool-rows.ts +189 -0
- package/src/sextant/types.ts +493 -0
- package/src/skills/index.ts +387 -0
- package/src/skills/pack.ts +220 -0
- package/src/skills/spec.ts +162 -0
- package/src/skills/tools.ts +69 -0
- package/src/skills/versioned.ts +227 -0
- package/src/telemetry/otel-export.ts +122 -0
- package/src/telemetry/otel-lanes.ts +89 -0
- package/src/telemetry/otel-logs.ts +131 -0
- package/src/telemetry/otel-metrics.ts +136 -0
- package/src/telemetry/otel.ts +397 -0
- package/src/telemetry/otlp.ts +76 -0
- package/src/tools/ask-user.ts +156 -0
- package/src/tools/bash-bg.ts +94 -0
- package/src/tools/bash-jobs.ts +237 -0
- package/src/tools/design.ts +151 -0
- package/src/tools/evalcell.ts +338 -0
- package/src/tools/html-text.ts +139 -0
- package/src/tools/provider.ts +149 -0
- package/src/tools/task.ts +250 -0
- package/src/tools/todo.ts +320 -0
- package/src/tools/webfetch.ts +332 -0
- package/src/tools/websearch.ts +359 -0
- package/src/tui/agents-cmd.ts +41 -0
- package/src/tui/app.ts +749 -0
- package/src/tui/attach.ts +127 -0
- package/src/tui/boot-notes.ts +41 -0
- package/src/tui/builtin-prompts.ts +59 -0
- package/src/tui/checkpoints-cmd.ts +70 -0
- package/src/tui/clipboard-image.ts +81 -0
- package/src/tui/clipboard.ts +78 -0
- package/src/tui/commands.ts +283 -0
- package/src/tui/config-view.ts +53 -0
- package/src/tui/context-cmds.ts +282 -0
- package/src/tui/cost.ts +108 -0
- package/src/tui/crash-guard.ts +173 -0
- package/src/tui/focus-terminal.ts +34 -0
- package/src/tui/git-cmds.ts +273 -0
- package/src/tui/git-plain.ts +58 -0
- package/src/tui/info-cmd.ts +150 -0
- package/src/tui/input-plain.ts +76 -0
- package/src/tui/mcp-cmd.ts +128 -0
- package/src/tui/memory-note.ts +77 -0
- package/src/tui/modes-cmd.ts +45 -0
- package/src/tui/notify-seq.ts +100 -0
- package/src/tui/notify.ts +318 -0
- package/src/tui/overlays.ts +97 -0
- package/src/tui/pi-renderer.ts +428 -0
- package/src/tui/providers-cmd.ts +377 -0
- package/src/tui/reasoning-view.ts +56 -0
- package/src/tui/renderer.ts +128 -0
- package/src/tui/replay-marker.ts +29 -0
- package/src/tui/session-cmd.ts +148 -0
- package/src/tui/session-manage.ts +95 -0
- package/src/tui/sextant-attach.ts +102 -0
- package/src/tui/sextant-io.ts +202 -0
- package/src/tui/sextant-smoke.ts +110 -0
- package/src/tui/shell-cmd.ts +158 -0
- package/src/tui/smoke.ts +72 -0
- package/src/tui/staged-terminal.ts +50 -0
- package/src/tui/startup.ts +12 -0
- package/src/tui/theme.ts +59 -0
- package/src/tui/todo-label.ts +7 -0
- package/src/tui/trust-card.ts +107 -0
- package/src/tui/tui-commands.ts +87 -0
- package/tsconfig.json +30 -0
- package/vendor/pi-tui/LICENSE +21 -0
- package/vendor/pi-tui/PATCHES.md +12 -0
- package/vendor/pi-tui/PROVENANCE.md +12 -0
- package/vendor/pi-tui/README.upstream.md +854 -0
- package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/src/alt-screen-search.ts +158 -0
- package/vendor/pi-tui/src/autocomplete.ts +827 -0
- package/vendor/pi-tui/src/components/alt-screen-flash.ts +52 -0
- package/vendor/pi-tui/src/components/box.ts +138 -0
- package/vendor/pi-tui/src/components/cancellable-loader.ts +41 -0
- package/vendor/pi-tui/src/components/editor.ts +2364 -0
- package/vendor/pi-tui/src/components/h-stack.ts +45 -0
- package/vendor/pi-tui/src/components/image.ts +128 -0
- package/vendor/pi-tui/src/components/input.ts +448 -0
- package/vendor/pi-tui/src/components/loader.ts +93 -0
- package/vendor/pi-tui/src/components/markdown.ts +1016 -0
- package/vendor/pi-tui/src/components/scroll-view.ts +217 -0
- package/vendor/pi-tui/src/components/select-list.ts +230 -0
- package/vendor/pi-tui/src/components/settings-list.ts +277 -0
- package/vendor/pi-tui/src/components/spacer.ts +29 -0
- package/vendor/pi-tui/src/components/stack.ts +155 -0
- package/vendor/pi-tui/src/components/text.ts +108 -0
- package/vendor/pi-tui/src/components/truncated-text.ts +66 -0
- package/vendor/pi-tui/src/components/v-stack.ts +34 -0
- package/vendor/pi-tui/src/editor-component.ts +75 -0
- package/vendor/pi-tui/src/fuzzy.ts +138 -0
- package/vendor/pi-tui/src/index.ts +149 -0
- package/vendor/pi-tui/src/keybindings.ts +321 -0
- package/vendor/pi-tui/src/keys.ts +1402 -0
- package/vendor/pi-tui/src/kill-ring.ts +47 -0
- package/vendor/pi-tui/src/latex.ts +1381 -0
- package/vendor/pi-tui/src/layout-node.ts +52 -0
- package/vendor/pi-tui/src/layout.ts +411 -0
- package/vendor/pi-tui/src/native-modifiers.ts +60 -0
- package/vendor/pi-tui/src/native-module-path.ts +32 -0
- package/vendor/pi-tui/src/stdin-buffer.ts +445 -0
- package/vendor/pi-tui/src/terminal-colors.ts +74 -0
- package/vendor/pi-tui/src/terminal-image.ts +701 -0
- package/vendor/pi-tui/src/terminal.ts +554 -0
- package/vendor/pi-tui/src/tui-alt-screen.ts +1379 -0
- package/vendor/pi-tui/src/tui-main-screen.ts +655 -0
- package/vendor/pi-tui/src/tui.ts +1264 -0
- package/vendor/pi-tui/src/undo-stack.ts +29 -0
- package/vendor/pi-tui/src/utils.ts +1327 -0
- package/vendor/pi-tui/src/word-navigation.ts +118 -0
- package/vendor/pi-tui/test/test-themes.ts +39 -0
- package/vendor/pi-tui/test/virtual-terminal.ts +219 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/** The opening intro: ROVECODE assembles itself in the middle of the terminal.
|
|
2
|
+
*
|
|
3
|
+
* Four acts, all of them Berkay's picks (2026-09-06). The mark fills in left to right — chosen over a
|
|
4
|
+
* checklist that ticks itself off and a single progress bar. A hairline frame draws inward from the four
|
|
5
|
+
* corners until the halves meet — chosen over a shimmer pass and a rain of blocks. The cloud mascot leans
|
|
6
|
+
* down out of the frame's top line — chosen over raining the letters into place and rising from the
|
|
7
|
+
* bottom. Then the mark breathes once. Centred on a cleared screen, and it hands over to the session's
|
|
8
|
+
* card (core/voice.ts).
|
|
9
|
+
*
|
|
10
|
+
* The CLI holds this screen until the runtime and interface are ready, not merely until their modules
|
|
11
|
+
* are imported. The CLI waits for both the choreography and the prepared first frame, concurrently.
|
|
12
|
+
* Fast boots still show the intro (~1.1s); slow boots hold the completed mark with a two-Hz activity line.
|
|
13
|
+
* Standalone callers can still play the finite animation. Off for pipes, --plain, ROVECODE_INTRO=0
|
|
14
|
+
* and --no-intro.
|
|
15
|
+
*
|
|
16
|
+
* It never reads stdin. Someone who starts typing immediately types into the terminal's buffer and the
|
|
17
|
+
* TUI gets those keys when it begins reading — an intro that swallowed the first keystroke to offer a
|
|
18
|
+
* skip would cost more than it saved. */
|
|
19
|
+
|
|
20
|
+
/** ░ ▒ ▓ █ — a letter's brightness as the wave passes over it */
|
|
21
|
+
const RAMP = ["░", "▒", "▓", "█"] as const;
|
|
22
|
+
|
|
23
|
+
/** ROVECODE, two rows per letter, three columns each. Only the full blocks take the ramp; the halves
|
|
24
|
+
* (▀ ▄) are the letter's shape and stay put, which is what keeps the word readable at every step. */
|
|
25
|
+
const LETTERS: readonly (readonly [string, string])[] = [
|
|
26
|
+
["█▀█", "█▀▄"], // R
|
|
27
|
+
["█▀█", "█▄█"], // O
|
|
28
|
+
["█ █", "▀▄▀"], // V
|
|
29
|
+
["█▀▀", "█▄▄"], // E
|
|
30
|
+
["█▀▀", "█▄▄"], // C
|
|
31
|
+
["█▀█", "█▄█"], // O
|
|
32
|
+
["█▀▄", "█▄▀"], // D
|
|
33
|
+
["█▀▀", "█▄▄"], // E
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/** columns the mark occupies: three per letter plus the gaps */
|
|
37
|
+
export const MARK_COLS = LETTERS.length * 4 - 1;
|
|
38
|
+
/** the frame sits this many columns clear of the mark on each side */
|
|
39
|
+
const FRAME_PAD = 4;
|
|
40
|
+
/** columns the frame's two horizontal runs cover between them. Kept EVEN so the two halves meet exactly
|
|
41
|
+
* instead of leaving a one-column gap the eye reads as a mistake. */
|
|
42
|
+
const FRAME_COLS = MARK_COLS + FRAME_PAD * 2 + ((MARK_COLS + FRAME_PAD * 2) % 2);
|
|
43
|
+
/** columns each end of the frame grows per step — 3 makes the draw snappy without skipping */
|
|
44
|
+
const FRAME_GROWTH = 3;
|
|
45
|
+
|
|
46
|
+
/** The mascot, hanging down from behind the frame's top line — Berkay's pick over the cloud raining the
|
|
47
|
+
* letters into place and rising from the bottom (2026-09-06).
|
|
48
|
+
*
|
|
49
|
+
* This is a COPY of SPRITE + FACE from sextant/pet.ts, not an import, and that is deliberate: importing
|
|
50
|
+
* the sextant module here would pull the panel painter into the boot path of a process that has not
|
|
51
|
+
* decided to draw panels yet, which is the opposite of the work that made startup cheap. The copy cannot
|
|
52
|
+
* drift — test/unit/intro.test.ts asserts these rows are identical to the ones the TUI paints, so the
|
|
53
|
+
* intro's cloud and the session's cloud are the same cloud or the suite fails. */
|
|
54
|
+
const CLOUD_OUTLINE: readonly string[] = [
|
|
55
|
+
" ╭────╮ ",
|
|
56
|
+
" ╭───╯ ╰──╮ ",
|
|
57
|
+
" ╭╯ ╰╮ ",
|
|
58
|
+
" │ │ ",
|
|
59
|
+
" ╰╮ ╭╯ ",
|
|
60
|
+
" ╰───────────╯ ",
|
|
61
|
+
];
|
|
62
|
+
/** the face's columns and rows, copied from pet.ts FACE. Placed by INDEX rather than typed into the art,
|
|
63
|
+
* so an eye cannot end up one column off the anchor the TUI paints it on — which is exactly what happened
|
|
64
|
+
* when these rows were written by hand. */
|
|
65
|
+
const FACE_AT = { EYE_L: 6, EYE_R: 12, MOUTH: 9, EYE_ROW: 3, MOUTH_ROW: 4 } as const;
|
|
66
|
+
const CLOUD: readonly string[] = CLOUD_OUTLINE.map((row, r) => {
|
|
67
|
+
const cells = [...row];
|
|
68
|
+
if (r === FACE_AT.EYE_ROW) { cells[FACE_AT.EYE_L] = "•"; cells[FACE_AT.EYE_R] = "•"; }
|
|
69
|
+
if (r === FACE_AT.MOUTH_ROW) cells[FACE_AT.MOUTH] = "◡";
|
|
70
|
+
return cells.join("");
|
|
71
|
+
});
|
|
72
|
+
export const CLOUD_COLS = 18;
|
|
73
|
+
/** rows of cloud that hang BELOW the frame line once it has fully descended */
|
|
74
|
+
const CLOUD_BODY = CLOUD.length - 1;
|
|
75
|
+
|
|
76
|
+
/** the four acts, in steps */
|
|
77
|
+
const SWEEP_STEPS = LETTERS.length + RAMP.length - 1; // the mark fills in
|
|
78
|
+
const FRAME_STEPS = Math.ceil(FRAME_COLS / 2 / FRAME_GROWTH); // the corners reach the middle
|
|
79
|
+
const CLOUD_STEPS = CLOUD.length; // the mascot leans over the line
|
|
80
|
+
const BREATHE = [3, 2, 3] as const; // █ ▓ █, once
|
|
81
|
+
export const INTRO_STEPS = SWEEP_STEPS + FRAME_STEPS + CLOUD_STEPS + BREATHE.length;
|
|
82
|
+
/** how long the whole show takes when nothing interrupts it */
|
|
83
|
+
export const INTRO_MS = 1100;
|
|
84
|
+
|
|
85
|
+
/** the two mark rows at `step`; step 0 is the whole word at its faintest, SWEEP_STEPS is solid. Past the
|
|
86
|
+
* sweep the mark holds, except for the breath at the very end. */
|
|
87
|
+
export function introFrame(step: number): [string, string] {
|
|
88
|
+
const breathIx = step - SWEEP_STEPS - FRAME_STEPS - CLOUD_STEPS;
|
|
89
|
+
const held = breathIx >= 0 ? BREATHE[Math.min(breathIx, BREATHE.length - 1)]! : undefined;
|
|
90
|
+
const rows: [string, string] = ["", ""];
|
|
91
|
+
LETTERS.forEach((letter, i) => {
|
|
92
|
+
const level = held ?? Math.max(0, Math.min(RAMP.length - 1, step - i));
|
|
93
|
+
const shade = RAMP[level]!;
|
|
94
|
+
for (const r of [0, 1] as const) rows[r] += (rows[r].length > 0 ? " " : "") + letter[r]!.replaceAll("█", shade);
|
|
95
|
+
});
|
|
96
|
+
return rows;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** How far the cloud has leaned over the top line: 0 before it starts, CLOUD.length when it is all the
|
|
100
|
+
* way out. It only begins once the frame has closed — one thing happens at a time. */
|
|
101
|
+
export function cloudDescent(step: number): number {
|
|
102
|
+
return Math.max(0, Math.min(CLOUD.length, step - SWEEP_STEPS - FRAME_STEPS));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The cloud's rows that hang BELOW the frame line, padded to a fixed count so the block below never
|
|
106
|
+
* shifts as it comes down — the mark must not jump while the mascot arrives. */
|
|
107
|
+
export function cloudRows(step: number): string[] {
|
|
108
|
+
const d = cloudDescent(step);
|
|
109
|
+
const shown = CLOUD.slice(1, Math.max(0, d));
|
|
110
|
+
return [...shown, ...Array.from({ length: CLOUD_BODY - shown.length }, () => "")];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The cloud's FIRST row is drawn into the frame's top line rather than under it, which is what makes it
|
|
114
|
+
* read as leaning over the edge instead of floating below it. Spaces in the sprite leave the line
|
|
115
|
+
* showing through; the sprite's own glyphs cut into it. */
|
|
116
|
+
export function mergeCloudIntoLine(line: string, step: number): string {
|
|
117
|
+
if (cloudDescent(step) === 0 || line.length === 0) return line;
|
|
118
|
+
const at = Math.max(0, Math.floor((line.length - CLOUD_COLS) / 2));
|
|
119
|
+
// always the sprite's FIRST row: it is the cloud's crown, and it stays cut into the line while the body
|
|
120
|
+
// appears underneath. Advancing it row by row instead made the line show the cloud's underside.
|
|
121
|
+
const row = CLOUD[0]!;
|
|
122
|
+
const chars = [...line];
|
|
123
|
+
[...row].forEach((ch, i) => { if (ch !== " " && at + i < chars.length) chars[at + i] = ch; });
|
|
124
|
+
return chars.join("");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** the frame's top and bottom rows at `step`: two runs growing inward from the corners until they meet.
|
|
128
|
+
* Empty strings before the mark has finished filling in — one thing happens at a time. */
|
|
129
|
+
export function frameRows(step: number): [string, string] {
|
|
130
|
+
const grown = step - SWEEP_STEPS;
|
|
131
|
+
if (grown < 0) return ["", ""];
|
|
132
|
+
const half = Math.min(FRAME_COLS / 2, Math.max(0, grown) * FRAME_GROWTH);
|
|
133
|
+
if (half === 0) return ["", ""];
|
|
134
|
+
const run = "─".repeat(Math.max(0, half - 1)); // the corner glyph is the half's first column
|
|
135
|
+
const gap = Math.max(0, FRAME_COLS - half * 2);
|
|
136
|
+
const line = (l: string, r: string) => `${l}${run}${" ".repeat(gap)}${run}${r}`;
|
|
137
|
+
return [line("╭", "╮"), line("╰", "╯")];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface IntroOptions {
|
|
141
|
+
/** where the frames go; injected in tests */
|
|
142
|
+
write: (s: string) => void;
|
|
143
|
+
/** false → nothing is written, ever. A pipe is not a screen. */
|
|
144
|
+
tty: boolean;
|
|
145
|
+
version?: string;
|
|
146
|
+
columns?: number;
|
|
147
|
+
rows?: number;
|
|
148
|
+
/** CLI loading mode: stay visible after the sequence until finish(), with a low-frequency activity line. */
|
|
149
|
+
holdUntilReady?: boolean;
|
|
150
|
+
/** Live terminal dimensions and resize subscription; no stdin is read by the intro. */
|
|
151
|
+
size?: () => { columns: number; rows: number };
|
|
152
|
+
onResize?: (paint: () => void) => () => void;
|
|
153
|
+
/** ms between steps; the default spreads INTRO_STEPS over INTRO_MS */
|
|
154
|
+
frameMs?: number;
|
|
155
|
+
setInterval?: (fn: () => void, ms: number) => unknown;
|
|
156
|
+
clearInterval?: (h: unknown) => void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** rows the whole block occupies: frame top (the cloud’s crown cut into it), the cloud’s body, a blank,
|
|
160
|
+
* the two mark rows, the version, the status line, the frame bottom */
|
|
161
|
+
export const INTRO_ROWS = 7 + (CLOUD.length - 1);
|
|
162
|
+
|
|
163
|
+
/** Is there room to play it? A terminal too narrow wraps the frame into nonsense; one too short scrolls
|
|
164
|
+
* its own top away. Both were real — 34×24 overflowed by six columns, 40×10 painted thirteen lines — and
|
|
165
|
+
* neither is worth degrading the animation for: the session’s card already has a prose form for a small
|
|
166
|
+
* terminal, and no intro at all is better than a broken one. One row and one column of margin, so the
|
|
167
|
+
* block is never flush against the edges. */
|
|
168
|
+
export function introFits(columns: number, rows: number): boolean {
|
|
169
|
+
return columns >= FRAME_COLS + 2 && rows >= INTRO_ROWS + 2;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface Intro {
|
|
173
|
+
/** what the session is doing right now, under the mark; "" clears the line */
|
|
174
|
+
status: (line: string) => void;
|
|
175
|
+
/** The mark has actually played through. Does not clear it; slow preparation may still be running. */
|
|
176
|
+
animationDone: Promise<void>;
|
|
177
|
+
/** resolves after finish(), or after the finite sequence when holdUntilReady is false */
|
|
178
|
+
done: Promise<void>;
|
|
179
|
+
/** cut it short: paint the final state and stop. Safe to call twice, and after `done`. */
|
|
180
|
+
finish: () => void;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const CLEAR_SCREEN = "\x1b[2J\x1b[H";
|
|
184
|
+
const HIDE_CURSOR = "\x1b[?25l";
|
|
185
|
+
const SHOW_CURSOR = "\x1b[?25h";
|
|
186
|
+
|
|
187
|
+
/** Play the intro centred on a cleared screen. Off a terminal this is a no-op whose `done` is already
|
|
188
|
+
* resolved, so callers do not branch — the check lives here, once. */
|
|
189
|
+
export function startIntro(opts: IntroOptions): Intro {
|
|
190
|
+
const size = opts.size ?? (() => ({ columns: opts.columns ?? 80, rows: opts.rows ?? 24 }));
|
|
191
|
+
const initial = size();
|
|
192
|
+
if (!opts.tty || !introFits(initial.columns, initial.rows)) return { status: () => {}, animationDone: Promise.resolve(), done: Promise.resolve(), finish: () => {} };
|
|
193
|
+
const setI = opts.setInterval ?? setInterval;
|
|
194
|
+
const clearI = opts.clearInterval ?? ((h: unknown) => clearInterval(h as ReturnType<typeof setInterval>));
|
|
195
|
+
let step = 0, line = "", ended = false, holding = false, pulse = 0, handle: unknown = null;
|
|
196
|
+
let paintedSize = initial;
|
|
197
|
+
let unsubscribe: (() => void) | undefined;
|
|
198
|
+
let settle: () => void = () => {};
|
|
199
|
+
const done = new Promise<void>((r) => { settle = r; });
|
|
200
|
+
let animationSettled: () => void = () => {};
|
|
201
|
+
const animationDone = new Promise<void>((r) => { animationSettled = r; });
|
|
202
|
+
const label = (): string => line && holding && !ended ? `${line} ${"·".repeat(pulse + 1)}` : line;
|
|
203
|
+
const centred = (text: string, cols: number): string => {
|
|
204
|
+
const clipped = [...text.replace(/\s+/g, " ")].slice(0, Math.max(0, cols - 2)).join("");
|
|
205
|
+
return " ".repeat(Math.max(0, Math.floor((cols - clipped.length) / 2))) + clipped;
|
|
206
|
+
};
|
|
207
|
+
const paint = (): void => {
|
|
208
|
+
const { columns: cols, rows } = paintedSize = size();
|
|
209
|
+
if (!introFits(cols, rows)) { opts.write(CLEAR_SCREEN + HIDE_CURSOR); return; }
|
|
210
|
+
const pad = (width: number): string => " ".repeat(Math.max(0, Math.floor((cols - width) / 2)));
|
|
211
|
+
const markPad = pad(MARK_COLS), framePad = pad(FRAME_COLS);
|
|
212
|
+
const cloudPad = framePad + " ".repeat(Math.max(0, Math.floor((FRAME_COLS - CLOUD_COLS) / 2)));
|
|
213
|
+
const top = "\n".repeat(Math.max(0, Math.floor((rows - INTRO_ROWS) / 2)));
|
|
214
|
+
const [markTop, markBottom] = introFrame(step);
|
|
215
|
+
const [frameTop, frameBottom] = frameRows(step);
|
|
216
|
+
const frameLine = (s: string) => (s.length > 0 ? `${framePad}${s}` : "");
|
|
217
|
+
opts.write([
|
|
218
|
+
CLEAR_SCREEN, HIDE_CURSOR, top,
|
|
219
|
+
`${frameLine(mergeCloudIntoLine(frameTop, step))}\n`,
|
|
220
|
+
cloudRows(step).map((r) => `${r.length > 0 ? cloudPad + r : ""}\n`).join(""),
|
|
221
|
+
"\n",
|
|
222
|
+
`${markPad}${markTop}\n${markPad}${markBottom}\n`,
|
|
223
|
+
`${centred(opts.version ?? "", cols)}\n`,
|
|
224
|
+
`${centred(label(), cols)}\n`,
|
|
225
|
+
`${frameLine(frameBottom)}\n`,
|
|
226
|
+
].join(""));
|
|
227
|
+
};
|
|
228
|
+
const paintStatus = (): void => {
|
|
229
|
+
if (ended) return;
|
|
230
|
+
const s = size();
|
|
231
|
+
if (s.columns !== paintedSize.columns || s.rows !== paintedSize.rows) { paint(); return; }
|
|
232
|
+
if (!introFits(s.columns, s.rows)) return;
|
|
233
|
+
const y = Math.max(0, Math.floor((s.rows - INTRO_ROWS) / 2)) + INTRO_ROWS - 1;
|
|
234
|
+
const esc = String.fromCharCode(27);
|
|
235
|
+
// Keep the logo still: slow boots repaint one short status row, not the entire terminal.
|
|
236
|
+
opts.write(`${esc}[${y};1H${esc}[2K${centred(label(), s.columns)}`);
|
|
237
|
+
};
|
|
238
|
+
const end = (): void => {
|
|
239
|
+
if (ended) return;
|
|
240
|
+
ended = true;
|
|
241
|
+
clearI(handle);
|
|
242
|
+
unsubscribe?.();
|
|
243
|
+
step = INTRO_STEPS;
|
|
244
|
+
line = "";
|
|
245
|
+
paint();
|
|
246
|
+
opts.write(`${SHOW_CURSOR}${CLEAR_SCREEN}`);
|
|
247
|
+
animationSettled();
|
|
248
|
+
settle();
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
paint();
|
|
252
|
+
unsubscribe = opts.onResize?.(() => { if (!ended) paint(); });
|
|
253
|
+
handle = setI(() => {
|
|
254
|
+
if (ended) return;
|
|
255
|
+
if (step < INTRO_STEPS) { step += 1; paint(); if (step === INTRO_STEPS) animationSettled(); }
|
|
256
|
+
else if (!opts.holdUntilReady) end();
|
|
257
|
+
else {
|
|
258
|
+
clearI(handle);
|
|
259
|
+
holding = true;
|
|
260
|
+
paintStatus();
|
|
261
|
+
handle = setI(() => { pulse = (pulse + 1) % 3; paintStatus(); }, 500);
|
|
262
|
+
}
|
|
263
|
+
}, opts.frameMs ?? Math.round(INTRO_MS / INTRO_STEPS));
|
|
264
|
+
|
|
265
|
+
return { status: (l: string) => { if (!ended && l !== line) { line = l; paintStatus(); } }, animationDone, done, finish: end };
|
|
266
|
+
}
|