terminal-pilot 0.0.30 → 0.0.32
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/dist/cli.js +1599 -497
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +489 -6
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.js +489 -6
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.js +489 -6
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.js +489 -6
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.js +630 -44
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +626 -40
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +68 -17
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +489 -6
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.js +489 -6
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.js +489 -6
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.js +489 -6
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.js +489 -6
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/runtime.js.map +1 -1
- package/dist/commands/screenshot.js +489 -6
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.js +489 -6
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.js +489 -6
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.js +554 -20
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +489 -6
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.js +489 -6
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +1599 -497
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +1609 -507
- package/dist/testing/qa-cli.js.map +4 -4
- package/node_modules/@poe-code/agent-defs/README.md +35 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +21 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +18 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +25 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +20 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +45 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +40 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +28 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.d.ts +1 -0
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +37 -18
- package/node_modules/@poe-code/agent-skill-config/dist/resolve-skill-reference.js +8 -4
- package/node_modules/@poe-code/agent-skill-config/package.json +1 -5
- package/node_modules/@poe-code/config-mutations/README.md +55 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +829 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +64 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +39 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +32 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +171 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.d.ts +4 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.js +27 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +75 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +76 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +43 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +62 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +55 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +194 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +168 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +29 -0
- package/node_modules/@poe-code/frontmatter/README.md +35 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.d.ts +25 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.js +100 -0
- package/node_modules/@poe-code/frontmatter/dist/index.d.ts +3 -0
- package/node_modules/@poe-code/frontmatter/dist/index.js +3 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +20 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.js +209 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.d.ts +1 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.js +48 -0
- package/node_modules/@poe-code/frontmatter/package.json +25 -0
- package/node_modules/toolcraft-design/README.md +160 -0
- package/node_modules/toolcraft-design/dist/acp/components.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/acp/components.js +137 -0
- package/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/acp/index.js +2 -0
- package/node_modules/toolcraft-design/dist/acp/writer.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/acp/writer.js +21 -0
- package/node_modules/toolcraft-design/dist/components/browser.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/browser.js +31 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +95 -0
- package/node_modules/toolcraft-design/dist/components/color.d.ts +31 -0
- package/node_modules/toolcraft-design/dist/components/color.js +102 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.js +23 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.d.ts +22 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.js +45 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +33 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.js +213 -0
- package/node_modules/toolcraft-design/dist/components/index.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/index.js +10 -0
- package/node_modules/toolcraft-design/dist/components/logger.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/components/logger.js +60 -0
- package/node_modules/toolcraft-design/dist/components/symbols.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/components/symbols.js +71 -0
- package/node_modules/toolcraft-design/dist/components/table.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/table.js +302 -0
- package/node_modules/toolcraft-design/dist/components/template.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/components/template.js +437 -0
- package/node_modules/toolcraft-design/dist/components/text.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/text.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.js +343 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.js +219 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.js +123 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.js +56 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +268 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +107 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.js +167 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.js +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.js +233 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.js +79 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.js +68 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.js +51 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +71 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.js +264 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.d.ts +38 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +39 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.js +297 -0
- package/node_modules/toolcraft-design/dist/explorer/events.d.ts +67 -0
- package/node_modules/toolcraft-design/dist/explorer/events.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.js +95 -0
- package/node_modules/toolcraft-design/dist/explorer/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/index.js +8 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.js +59 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.js +376 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +782 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.js +97 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.js +49 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.js +53 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.js +116 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.js +87 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +156 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.js +81 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +340 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +101 -0
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +137 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +86 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.d.ts +27 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/toolcraft-design/dist/index.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/index.js +43 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.js +12 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.js +22 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.js +50 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.js +71 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/toolcraft-design/dist/prompts/index.d.ts +91 -0
- package/node_modules/toolcraft-design/dist/prompts/index.js +137 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.js +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.js +47 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +274 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.js +53 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.js +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.js +28 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +131 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +52 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.js +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.js +89 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.js +32 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.js +60 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.js +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.js +104 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.js +39 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/toolcraft-design/dist/static/index.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/static/index.js +2 -0
- package/node_modules/toolcraft-design/dist/static/menu.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/static/menu.js +42 -0
- package/node_modules/toolcraft-design/dist/static/spinner.d.ts +14 -0
- package/node_modules/toolcraft-design/dist/static/spinner.js +52 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +36 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +1190 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +615 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/toolcraft-design/dist/tokens/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/index.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.js +6 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.js +8 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.js +5 -0
- package/node_modules/toolcraft-design/package.json +44 -0
- package/package.json +15 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PromptStateName } from "./core.js";
|
|
2
|
+
export declare const UNICODE: boolean;
|
|
3
|
+
export declare const GLYPHS: {
|
|
4
|
+
readonly stepActive: string;
|
|
5
|
+
readonly stepCancel: string;
|
|
6
|
+
readonly stepError: string;
|
|
7
|
+
readonly stepSubmit: string;
|
|
8
|
+
readonly barStart: string;
|
|
9
|
+
readonly bar: string;
|
|
10
|
+
readonly barEnd: string;
|
|
11
|
+
readonly radioActive: string;
|
|
12
|
+
readonly radioInactive: string;
|
|
13
|
+
readonly checkboxActive: string;
|
|
14
|
+
readonly checkboxSelected: string;
|
|
15
|
+
readonly checkboxInactive: string;
|
|
16
|
+
readonly passwordMask: string;
|
|
17
|
+
readonly ellipsis: "...";
|
|
18
|
+
};
|
|
19
|
+
export declare function symbol(state: PromptStateName): string;
|
|
20
|
+
export declare function symbolBar(state: PromptStateName): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
function supportsUnicode() {
|
|
3
|
+
if (!process.platform.startsWith("win")) {
|
|
4
|
+
return process.env.TERM !== "linux";
|
|
5
|
+
}
|
|
6
|
+
return Boolean(process.env.CI ||
|
|
7
|
+
process.env.WT_SESSION ||
|
|
8
|
+
process.env.TERMINUS_SUBLIME ||
|
|
9
|
+
process.env.ConEmuTask === "{cmd::Cmder}" ||
|
|
10
|
+
process.env.TERM_PROGRAM === "Terminus-Sublime" ||
|
|
11
|
+
process.env.TERM_PROGRAM === "vscode" ||
|
|
12
|
+
process.env.TERM === "xterm-256color" ||
|
|
13
|
+
process.env.TERM === "alacritty" ||
|
|
14
|
+
process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm");
|
|
15
|
+
}
|
|
16
|
+
export const UNICODE = supportsUnicode();
|
|
17
|
+
function glyph(unicode, ascii) {
|
|
18
|
+
return UNICODE ? unicode : ascii;
|
|
19
|
+
}
|
|
20
|
+
export const GLYPHS = {
|
|
21
|
+
stepActive: glyph("◆", "*"),
|
|
22
|
+
stepCancel: glyph("■", "x"),
|
|
23
|
+
stepError: glyph("▲", "x"),
|
|
24
|
+
stepSubmit: glyph("◇", "o"),
|
|
25
|
+
barStart: glyph("┌", "T"),
|
|
26
|
+
bar: glyph("│", "|"),
|
|
27
|
+
barEnd: glyph("└", "-"),
|
|
28
|
+
radioActive: glyph("●", ">"),
|
|
29
|
+
radioInactive: glyph("○", " "),
|
|
30
|
+
checkboxActive: glyph("◻", "[ ]"),
|
|
31
|
+
checkboxSelected: glyph("◼", "[+]"),
|
|
32
|
+
checkboxInactive: glyph("◻", "[ ]"),
|
|
33
|
+
passwordMask: glyph("•", "*"),
|
|
34
|
+
ellipsis: "..."
|
|
35
|
+
};
|
|
36
|
+
export function symbol(state) {
|
|
37
|
+
if (state === "cancel")
|
|
38
|
+
return color.red(GLYPHS.stepCancel);
|
|
39
|
+
if (state === "error")
|
|
40
|
+
return color.yellow(GLYPHS.stepError);
|
|
41
|
+
if (state === "submit")
|
|
42
|
+
return color.green(GLYPHS.stepSubmit);
|
|
43
|
+
return color.cyan(GLYPHS.stepActive);
|
|
44
|
+
}
|
|
45
|
+
export function symbolBar(state) {
|
|
46
|
+
if (state === "cancel")
|
|
47
|
+
return color.red(GLYPHS.bar);
|
|
48
|
+
if (state === "error")
|
|
49
|
+
return color.yellow(GLYPHS.bar);
|
|
50
|
+
if (state === "submit")
|
|
51
|
+
return color.green(GLYPHS.bar);
|
|
52
|
+
return color.cyan(GLYPHS.bar);
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CANCEL, isCancel } from "./cancel-symbol.js";
|
|
2
|
+
export { textPrompt, type TextOptions } from "./text.js";
|
|
3
|
+
export { passwordPrompt, type PasswordOptions } from "./password.js";
|
|
4
|
+
export { confirmPrompt, type ConfirmOptions } from "./confirm.js";
|
|
5
|
+
export { selectPrompt, type SelectOption, type SelectOptions } from "./select.js";
|
|
6
|
+
export { multiselectPrompt, type MultiselectOptions } from "./multiselect.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CANCEL, isCancel } from "./cancel-symbol.js";
|
|
2
|
+
export { textPrompt } from "./text.js";
|
|
3
|
+
export { passwordPrompt } from "./password.js";
|
|
4
|
+
export { confirmPrompt } from "./confirm.js";
|
|
5
|
+
export { selectPrompt } from "./select.js";
|
|
6
|
+
export { multiselectPrompt } from "./multiselect.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const aliases = {
|
|
2
|
+
k: "up",
|
|
3
|
+
j: "down",
|
|
4
|
+
h: "left",
|
|
5
|
+
l: "right"
|
|
6
|
+
};
|
|
7
|
+
const keyActions = {
|
|
8
|
+
up: "up",
|
|
9
|
+
down: "down",
|
|
10
|
+
left: "left",
|
|
11
|
+
right: "right",
|
|
12
|
+
space: "space",
|
|
13
|
+
return: "enter",
|
|
14
|
+
enter: "enter",
|
|
15
|
+
escape: "cancel"
|
|
16
|
+
};
|
|
17
|
+
export function mapKey(name, char) {
|
|
18
|
+
if (char === "\x03") {
|
|
19
|
+
return "cancel";
|
|
20
|
+
}
|
|
21
|
+
if (char === " ") {
|
|
22
|
+
return "space";
|
|
23
|
+
}
|
|
24
|
+
if (!name) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return keyActions[name] ?? aliases[name];
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CANCEL } from "./cancel-symbol.js";
|
|
2
|
+
import { type SelectOption } from "./select.js";
|
|
3
|
+
export interface MultiselectOptions<Value> {
|
|
4
|
+
message: string;
|
|
5
|
+
options: Array<SelectOption<Value>>;
|
|
6
|
+
initialValues?: Value[];
|
|
7
|
+
required?: boolean;
|
|
8
|
+
maxItems?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
input?: NodeJS.ReadableStream;
|
|
11
|
+
output?: NodeJS.WritableStream;
|
|
12
|
+
}
|
|
13
|
+
export declare function multiselectPrompt<Value>(opts: MultiselectOptions<Value>): Promise<Value[] | typeof CANCEL>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
import { GLYPHS, symbol } from "./glyphs.js";
|
|
3
|
+
import { Prompt } from "./core.js";
|
|
4
|
+
import { limitOptions } from "./pagination.js";
|
|
5
|
+
import { findNonDisabled } from "./select.js";
|
|
6
|
+
class MultiselectPrompt extends Prompt {
|
|
7
|
+
options;
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
if (opts.options.length === 0) {
|
|
10
|
+
throw new Error("Multiselect prompt requires at least one option.");
|
|
11
|
+
}
|
|
12
|
+
if (opts.options.every((option) => option.disabled)) {
|
|
13
|
+
throw new Error("Multiselect prompt requires at least one enabled option.");
|
|
14
|
+
}
|
|
15
|
+
const cursor = findNonDisabled(0, 1, opts.options);
|
|
16
|
+
super({
|
|
17
|
+
...opts,
|
|
18
|
+
initialValue: [...(opts.initialValues ?? [])],
|
|
19
|
+
validate: (value) => {
|
|
20
|
+
if (opts.required && (!value || value.length === 0)) {
|
|
21
|
+
return "Please select at least one option.\nPress SPACE to select, ENTER to submit";
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
},
|
|
25
|
+
render: (prompt) => renderMultiselectPrompt(prompt, opts)
|
|
26
|
+
}, false);
|
|
27
|
+
this.options = opts.options;
|
|
28
|
+
this._cursor = cursor;
|
|
29
|
+
this.on("cursor", (action) => {
|
|
30
|
+
if (action === "up" || action === "left") {
|
|
31
|
+
this._cursor = findNonDisabled(this._cursor - 1, -1, this.options);
|
|
32
|
+
}
|
|
33
|
+
else if (action === "down" || action === "right") {
|
|
34
|
+
this._cursor = findNonDisabled(this._cursor + 1, 1, this.options);
|
|
35
|
+
}
|
|
36
|
+
else if (action === "space") {
|
|
37
|
+
this.toggleFocused();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.on("key", (key) => {
|
|
41
|
+
if (key === "a") {
|
|
42
|
+
this.toggleAll();
|
|
43
|
+
}
|
|
44
|
+
else if (key === "i") {
|
|
45
|
+
this.invert();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
get visibleOptions() {
|
|
50
|
+
return this.options;
|
|
51
|
+
}
|
|
52
|
+
enabledOptions() {
|
|
53
|
+
return this.options.filter((option) => !option.disabled);
|
|
54
|
+
}
|
|
55
|
+
toggleFocused() {
|
|
56
|
+
const option = this.options[this.cursor];
|
|
57
|
+
if (!option || option.disabled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.toggleValue(option.value);
|
|
61
|
+
}
|
|
62
|
+
toggleValue(value) {
|
|
63
|
+
const current = this.value ?? [];
|
|
64
|
+
this.setValue(current.includes(value)
|
|
65
|
+
? current.filter((item) => item !== value)
|
|
66
|
+
: [...current, value]);
|
|
67
|
+
}
|
|
68
|
+
toggleAll() {
|
|
69
|
+
const enabledValues = this.enabledOptions().map((option) => option.value);
|
|
70
|
+
const current = this.value ?? [];
|
|
71
|
+
const allSelected = enabledValues.every((value) => current.includes(value));
|
|
72
|
+
this.setValue(allSelected ? [] : enabledValues);
|
|
73
|
+
}
|
|
74
|
+
invert() {
|
|
75
|
+
const current = this.value ?? [];
|
|
76
|
+
this.setValue(this.enabledOptions().map((option) => option.value).filter((value) => !current.includes(value)));
|
|
77
|
+
}
|
|
78
|
+
promptNonTty() {
|
|
79
|
+
if (process.env.POE_NO_PROMPT === "1") {
|
|
80
|
+
return Promise.resolve(this.value ?? []);
|
|
81
|
+
}
|
|
82
|
+
return super.promptNonTty();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function hasValue(values, value) {
|
|
86
|
+
return (values ?? []).includes(value);
|
|
87
|
+
}
|
|
88
|
+
function renderOption(option, values, active, submitted, cancelled) {
|
|
89
|
+
const selected = hasValue(values, option.value);
|
|
90
|
+
const hint = option.hint ? color.dim(` (${option.hint})`) : "";
|
|
91
|
+
if (submitted)
|
|
92
|
+
return color.dim(option.label);
|
|
93
|
+
if (cancelled)
|
|
94
|
+
return color.dim.strikethrough(option.label);
|
|
95
|
+
if (option.disabled)
|
|
96
|
+
return `${color.gray(GLYPHS.checkboxInactive)} ${color.gray.strikethrough(option.label)}${hint}`;
|
|
97
|
+
if (selected)
|
|
98
|
+
return `${color.green(GLYPHS.checkboxSelected)} ${active ? option.label : color.dim(option.label)}${hint}`;
|
|
99
|
+
if (active)
|
|
100
|
+
return `${color.cyan(GLYPHS.checkboxActive)} ${option.label}${hint}`;
|
|
101
|
+
return `${color.dim(GLYPHS.checkboxInactive)} ${color.dim(option.label)}${hint}`;
|
|
102
|
+
}
|
|
103
|
+
function renderMultiselectPrompt(prompt, opts) {
|
|
104
|
+
if (prompt.state === "submit" || prompt.state === "cancel") {
|
|
105
|
+
const labels = prompt.visibleOptions
|
|
106
|
+
.filter((option) => hasValue(prompt.value, option.value))
|
|
107
|
+
.map((option) => prompt.state === "submit" ? color.dim(option.label) : color.dim.strikethrough(option.label))
|
|
108
|
+
.join(", ");
|
|
109
|
+
const end = prompt.state === "submit" ? color.green(GLYPHS.barEnd) : color.red(GLYPHS.barEnd);
|
|
110
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}\n${color.gray(GLYPHS.bar)} ${labels}\n${end}`;
|
|
111
|
+
}
|
|
112
|
+
const lines = limitOptions({
|
|
113
|
+
cursor: prompt.cursor,
|
|
114
|
+
options: prompt.visibleOptions,
|
|
115
|
+
output: opts.output ?? process.stdout,
|
|
116
|
+
maxItems: opts.maxItems,
|
|
117
|
+
columnPadding: 3,
|
|
118
|
+
style: (option, active) => renderOption(option, prompt.value, active, false, false)
|
|
119
|
+
}).map((line) => `${prompt.state === "error" ? color.yellow(GLYPHS.bar) : color.cyan(GLYPHS.bar)} ${line}`);
|
|
120
|
+
const body = [`${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}`, ...lines];
|
|
121
|
+
if (prompt.state === "error") {
|
|
122
|
+
body.push(`${color.yellow(GLYPHS.barEnd)} ${color.yellow(prompt.error)}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
body.push(color.cyan(GLYPHS.barEnd));
|
|
126
|
+
}
|
|
127
|
+
return body.join("\n");
|
|
128
|
+
}
|
|
129
|
+
export function multiselectPrompt(opts) {
|
|
130
|
+
return new MultiselectPrompt(opts).prompt();
|
|
131
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PaginationOptions<Option> {
|
|
2
|
+
cursor: number;
|
|
3
|
+
options: Option[];
|
|
4
|
+
style: (option: Option, active: boolean) => string;
|
|
5
|
+
output: NodeJS.WritableStream;
|
|
6
|
+
maxItems?: number;
|
|
7
|
+
columnPadding?: number;
|
|
8
|
+
rowPadding?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function limitOptions<Option>(opts: PaginationOptions<Option>): string[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
import { GLYPHS } from "./glyphs.js";
|
|
3
|
+
import { getColumns, getRows } from "./wrap.js";
|
|
4
|
+
import { wrapAnsi } from "fast-wrap-ansi";
|
|
5
|
+
function countLines(values) {
|
|
6
|
+
return values.reduce((sum, value) => sum + value.split("\n").length, 0);
|
|
7
|
+
}
|
|
8
|
+
function trimToRows(values, cursorOffset, rows, hasTop, hasBottom) {
|
|
9
|
+
const output = [...values];
|
|
10
|
+
while (countLines(output) > rows && output.length > 1) {
|
|
11
|
+
const removeFromTop = hasTop && cursorOffset > 0;
|
|
12
|
+
const removeFromBottom = hasBottom && cursorOffset < output.length - 1;
|
|
13
|
+
if (removeFromTop) {
|
|
14
|
+
output.shift();
|
|
15
|
+
cursorOffset -= 1;
|
|
16
|
+
}
|
|
17
|
+
else if (removeFromBottom) {
|
|
18
|
+
output.pop();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
output.pop();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
export function limitOptions(opts) {
|
|
27
|
+
const { cursor, options, style, output, maxItems = Number.POSITIVE_INFINITY, columnPadding = 0, rowPadding = 4 } = opts;
|
|
28
|
+
if (options.length === 0) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const columns = Math.max(1, getColumns(output) - columnPadding);
|
|
32
|
+
const rowBudget = Math.max(getRows(output) - rowPadding, 0);
|
|
33
|
+
const visibleCount = Math.max(Math.min(maxItems, rowBudget), 5);
|
|
34
|
+
const cappedVisibleCount = Math.min(visibleCount, options.length);
|
|
35
|
+
let start = 0;
|
|
36
|
+
if (cursor >= cappedVisibleCount - 3) {
|
|
37
|
+
start = Math.max(Math.min(cursor - cappedVisibleCount + 3, options.length - cappedVisibleCount), 0);
|
|
38
|
+
}
|
|
39
|
+
const hasTopMarker = cappedVisibleCount < options.length && start > 0;
|
|
40
|
+
const hasBottomMarker = cappedVisibleCount < options.length && start + cappedVisibleCount < options.length;
|
|
41
|
+
const visible = options
|
|
42
|
+
.slice(start, start + cappedVisibleCount)
|
|
43
|
+
.map((option, index) => wrapAnsi(style(option, start + index === cursor), columns, { hard: true, trim: false }));
|
|
44
|
+
const trimmed = trimToRows(visible, Math.max(cursor - start, 0), Math.max(rowBudget - Number(hasTopMarker) - Number(hasBottomMarker), 1), hasTopMarker, hasBottomMarker);
|
|
45
|
+
if (hasTopMarker) {
|
|
46
|
+
trimmed.unshift(color.dim(GLYPHS.ellipsis));
|
|
47
|
+
}
|
|
48
|
+
if (hasBottomMarker) {
|
|
49
|
+
trimmed.push(color.dim(GLYPHS.ellipsis));
|
|
50
|
+
}
|
|
51
|
+
return trimmed;
|
|
52
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CANCEL } from "./cancel-symbol.js";
|
|
2
|
+
export interface PasswordOptions {
|
|
3
|
+
message: string;
|
|
4
|
+
mask?: string;
|
|
5
|
+
validate?: (value: string) => string | Error | undefined;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
input?: NodeJS.ReadableStream;
|
|
8
|
+
output?: NodeJS.WritableStream;
|
|
9
|
+
}
|
|
10
|
+
export declare function passwordPrompt(opts: PasswordOptions): Promise<string | typeof CANCEL>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
import { GLYPHS, symbol, symbolBar } from "./glyphs.js";
|
|
3
|
+
import { Prompt } from "./core.js";
|
|
4
|
+
class PasswordPrompt extends Prompt {
|
|
5
|
+
mask;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
initialValue: "",
|
|
10
|
+
initialUserInput: "",
|
|
11
|
+
render: (prompt) => renderPasswordPrompt(prompt, opts),
|
|
12
|
+
validate: opts.validate
|
|
13
|
+
});
|
|
14
|
+
this.mask = opts.mask ?? GLYPHS.passwordMask;
|
|
15
|
+
this.on("userInput", (value) => this.setValue(value));
|
|
16
|
+
}
|
|
17
|
+
get masked() {
|
|
18
|
+
return this.mask.repeat(this.userInput.length);
|
|
19
|
+
}
|
|
20
|
+
get userInputWithCursor() {
|
|
21
|
+
if (this.state === "submit") {
|
|
22
|
+
return this.masked;
|
|
23
|
+
}
|
|
24
|
+
const masked = this.masked;
|
|
25
|
+
const before = masked.slice(0, this.cursor);
|
|
26
|
+
const current = masked[this.cursor];
|
|
27
|
+
const after = masked.slice(this.cursor + 1);
|
|
28
|
+
if (current) {
|
|
29
|
+
return `${before}${color.inverse(current)}${after}`;
|
|
30
|
+
}
|
|
31
|
+
return `${before}${color.inverse("█")}`;
|
|
32
|
+
}
|
|
33
|
+
promptNonTty() {
|
|
34
|
+
return this.readNonTtyLine();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function renderHeader(prompt, message) {
|
|
38
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${message}`;
|
|
39
|
+
}
|
|
40
|
+
function renderPasswordPrompt(prompt, opts) {
|
|
41
|
+
const value = prompt.masked;
|
|
42
|
+
if (prompt.state === "submit") {
|
|
43
|
+
return `${renderHeader(prompt, opts.message)}\n${color.gray(GLYPHS.bar)} ${color.dim(value)}\n${color.green(GLYPHS.barEnd)}`;
|
|
44
|
+
}
|
|
45
|
+
if (prompt.state === "cancel") {
|
|
46
|
+
return `${renderHeader(prompt, opts.message)}\n${color.gray(GLYPHS.bar)} ${color.dim.strikethrough(value)}\n${color.red(GLYPHS.barEnd)}`;
|
|
47
|
+
}
|
|
48
|
+
if (prompt.state === "error") {
|
|
49
|
+
return `${renderHeader(prompt, opts.message)}\n${symbolBar(prompt.state)} ${prompt.userInputWithCursor}\n${color.yellow(GLYPHS.barEnd)} ${color.yellow(prompt.error)}`;
|
|
50
|
+
}
|
|
51
|
+
return `${renderHeader(prompt, opts.message)}\n${symbolBar(prompt.state)} ${prompt.userInputWithCursor}\n${color.cyan(GLYPHS.barEnd)}`;
|
|
52
|
+
}
|
|
53
|
+
export function passwordPrompt(opts) {
|
|
54
|
+
return new PasswordPrompt(opts).prompt();
|
|
55
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CANCEL } from "./cancel-symbol.js";
|
|
2
|
+
export interface SelectOption<Value> {
|
|
3
|
+
value: Value;
|
|
4
|
+
label: string;
|
|
5
|
+
hint?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectOptions<Value> {
|
|
9
|
+
message: string;
|
|
10
|
+
options: Array<SelectOption<Value>>;
|
|
11
|
+
initialValue?: Value;
|
|
12
|
+
maxItems?: number;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
input?: NodeJS.ReadableStream;
|
|
15
|
+
output?: NodeJS.WritableStream;
|
|
16
|
+
}
|
|
17
|
+
export declare function findNonDisabled<Value>(start: number, direction: 1 | -1, options: Array<SelectOption<Value>>): number;
|
|
18
|
+
export declare function selectPrompt<Value>(opts: SelectOptions<Value>): Promise<Value | typeof CANCEL>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
import { GLYPHS, symbol } from "./glyphs.js";
|
|
3
|
+
import { Prompt } from "./core.js";
|
|
4
|
+
import { limitOptions } from "./pagination.js";
|
|
5
|
+
class SelectPrompt extends Prompt {
|
|
6
|
+
options;
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
if (opts.options.length === 0) {
|
|
9
|
+
throw new Error("Select prompt requires at least one option.");
|
|
10
|
+
}
|
|
11
|
+
if (opts.options.every((option) => option.disabled)) {
|
|
12
|
+
throw new Error("Select prompt requires at least one enabled option.");
|
|
13
|
+
}
|
|
14
|
+
const initialIndex = Math.max(opts.options.findIndex((option) => option.value === opts.initialValue), 0);
|
|
15
|
+
const cursor = findNonDisabled(initialIndex, 1, opts.options);
|
|
16
|
+
super({
|
|
17
|
+
...opts,
|
|
18
|
+
initialValue: opts.options[cursor]?.value,
|
|
19
|
+
render: (prompt) => renderSelectPrompt(prompt, opts)
|
|
20
|
+
}, false);
|
|
21
|
+
this.options = opts.options;
|
|
22
|
+
this._cursor = cursor;
|
|
23
|
+
this.setValue(this.options[this._cursor]?.value);
|
|
24
|
+
this.on("cursor", (action) => {
|
|
25
|
+
if (action === "up" || action === "left") {
|
|
26
|
+
this._cursor = findNonDisabled(this._cursor - 1, -1, this.options);
|
|
27
|
+
}
|
|
28
|
+
else if (action === "down" || action === "right") {
|
|
29
|
+
this._cursor = findNonDisabled(this._cursor + 1, 1, this.options);
|
|
30
|
+
}
|
|
31
|
+
this.setValue(this.options[this._cursor]?.value);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
get visibleOptions() {
|
|
35
|
+
return this.options;
|
|
36
|
+
}
|
|
37
|
+
promptNonTty() {
|
|
38
|
+
if (process.env.POE_NO_PROMPT === "1") {
|
|
39
|
+
return Promise.resolve(this.value);
|
|
40
|
+
}
|
|
41
|
+
return super.promptNonTty();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function findNonDisabled(start, direction, options) {
|
|
45
|
+
if (options.every((option) => option.disabled)) {
|
|
46
|
+
return start;
|
|
47
|
+
}
|
|
48
|
+
let index = start;
|
|
49
|
+
for (let checked = 0; checked < options.length; checked += 1) {
|
|
50
|
+
index = (index + options.length) % options.length;
|
|
51
|
+
if (!options[index]?.disabled) {
|
|
52
|
+
return index;
|
|
53
|
+
}
|
|
54
|
+
index += direction;
|
|
55
|
+
}
|
|
56
|
+
return start;
|
|
57
|
+
}
|
|
58
|
+
function renderOption(option, active, submitted, cancelled) {
|
|
59
|
+
const hint = option.hint ? color.dim(` (${option.hint})`) : "";
|
|
60
|
+
if (submitted)
|
|
61
|
+
return color.dim(option.label);
|
|
62
|
+
if (cancelled)
|
|
63
|
+
return color.dim.strikethrough(option.label);
|
|
64
|
+
if (option.disabled)
|
|
65
|
+
return `${color.gray(GLYPHS.radioInactive)} ${color.gray.strikethrough(option.label)}${hint}`;
|
|
66
|
+
if (active)
|
|
67
|
+
return `${color.green(GLYPHS.radioActive)} ${option.label}${hint}`;
|
|
68
|
+
return `${color.dim(GLYPHS.radioInactive)} ${color.dim(option.label)}${hint}`;
|
|
69
|
+
}
|
|
70
|
+
function renderSelectPrompt(prompt, opts) {
|
|
71
|
+
if (prompt.state === "submit" || prompt.state === "cancel") {
|
|
72
|
+
const option = prompt.visibleOptions[prompt.cursor];
|
|
73
|
+
const rendered = option ? renderOption(option, false, prompt.state === "submit", prompt.state === "cancel") : "";
|
|
74
|
+
const end = prompt.state === "submit" ? color.green(GLYPHS.barEnd) : color.red(GLYPHS.barEnd);
|
|
75
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}\n${color.gray(GLYPHS.bar)} ${rendered}\n${end}`;
|
|
76
|
+
}
|
|
77
|
+
const lines = limitOptions({
|
|
78
|
+
cursor: prompt.cursor,
|
|
79
|
+
options: prompt.visibleOptions,
|
|
80
|
+
output: opts.output ?? process.stdout,
|
|
81
|
+
maxItems: opts.maxItems,
|
|
82
|
+
columnPadding: 3,
|
|
83
|
+
style: (option, active) => renderOption(option, active, false, false)
|
|
84
|
+
}).map((line) => `${color.cyan(GLYPHS.bar)} ${line}`);
|
|
85
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}\n${lines.join("\n")}\n${color.cyan(GLYPHS.barEnd)}`;
|
|
86
|
+
}
|
|
87
|
+
export function selectPrompt(opts) {
|
|
88
|
+
return new SelectPrompt(opts).prompt();
|
|
89
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PassThrough, Writable } from "node:stream";
|
|
2
|
+
export interface PromptHarness {
|
|
3
|
+
input: PassThrough & {
|
|
4
|
+
isTTY?: boolean;
|
|
5
|
+
setRawMode?: (enabled: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
output: Writable & {
|
|
8
|
+
columns?: number;
|
|
9
|
+
rows?: number;
|
|
10
|
+
isTTY?: boolean;
|
|
11
|
+
frames: string[];
|
|
12
|
+
};
|
|
13
|
+
rawModes: boolean[];
|
|
14
|
+
getOutput: () => string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPromptHarness(options?: {
|
|
17
|
+
tty?: boolean;
|
|
18
|
+
columns?: number;
|
|
19
|
+
rows?: number;
|
|
20
|
+
}): PromptHarness;
|
|
21
|
+
export declare function tick(): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PassThrough, Writable } from "node:stream";
|
|
2
|
+
export function createPromptHarness(options = {}) {
|
|
3
|
+
const chunks = [];
|
|
4
|
+
const frames = [];
|
|
5
|
+
const rawModes = [];
|
|
6
|
+
const input = new PassThrough();
|
|
7
|
+
const output = new Writable({
|
|
8
|
+
write(chunk, _encoding, callback) {
|
|
9
|
+
const value = String(chunk);
|
|
10
|
+
chunks.push(value);
|
|
11
|
+
frames.push(value);
|
|
12
|
+
callback();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
input.isTTY = options.tty ?? true;
|
|
16
|
+
input.setRawMode = (enabled) => {
|
|
17
|
+
rawModes.push(enabled);
|
|
18
|
+
};
|
|
19
|
+
output.isTTY = options.tty ?? true;
|
|
20
|
+
output.columns = options.columns ?? 80;
|
|
21
|
+
output.rows = options.rows ?? 20;
|
|
22
|
+
output.frames = frames;
|
|
23
|
+
return {
|
|
24
|
+
input,
|
|
25
|
+
output,
|
|
26
|
+
rawModes,
|
|
27
|
+
getOutput: () => chunks.join("")
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export async function tick() {
|
|
31
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CANCEL } from "./cancel-symbol.js";
|
|
2
|
+
export interface TextOptions {
|
|
3
|
+
message: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
initialValue?: string;
|
|
7
|
+
validate?: (value: string) => string | Error | undefined;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
input?: NodeJS.ReadableStream;
|
|
10
|
+
output?: NodeJS.WritableStream;
|
|
11
|
+
}
|
|
12
|
+
export declare function textPrompt(opts: TextOptions): Promise<string | typeof CANCEL>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { color } from "../../components/color.js";
|
|
2
|
+
import { GLYPHS, symbol, symbolBar } from "./glyphs.js";
|
|
3
|
+
import { Prompt } from "./core.js";
|
|
4
|
+
class TextPrompt extends Prompt {
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
const initialUserInput = opts.initialValue ?? "";
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
initialValue: initialUserInput,
|
|
10
|
+
initialUserInput,
|
|
11
|
+
render: (prompt) => renderTextPrompt(prompt, opts),
|
|
12
|
+
validate: opts.validate
|
|
13
|
+
});
|
|
14
|
+
this.on("userInput", (value) => this.setValue(value));
|
|
15
|
+
this.on("finalize", () => {
|
|
16
|
+
if (this.state === "submit") {
|
|
17
|
+
this.setValue(this.value || opts.defaultValue || "");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
get userInputWithCursor() {
|
|
22
|
+
if (this.state === "submit") {
|
|
23
|
+
return this.userInput;
|
|
24
|
+
}
|
|
25
|
+
const before = this.userInput.slice(0, this.cursor);
|
|
26
|
+
const current = this.userInput[this.cursor];
|
|
27
|
+
const after = this.userInput.slice(this.cursor + 1);
|
|
28
|
+
if (current) {
|
|
29
|
+
return `${before}${color.inverse(current)}${after}`;
|
|
30
|
+
}
|
|
31
|
+
return `${before}${color.inverse("█")}`;
|
|
32
|
+
}
|
|
33
|
+
promptNonTty() {
|
|
34
|
+
return this.readNonTtyLine();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function renderHeader(prompt, message) {
|
|
38
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${message}`;
|
|
39
|
+
}
|
|
40
|
+
function renderTextPrompt(prompt, opts) {
|
|
41
|
+
const value = prompt.value ?? "";
|
|
42
|
+
if (prompt.state === "submit") {
|
|
43
|
+
return `${renderHeader(prompt, opts.message)}\n${color.gray(GLYPHS.bar)} ${color.dim(value)}\n${color.green(GLYPHS.barEnd)}`;
|
|
44
|
+
}
|
|
45
|
+
if (prompt.state === "cancel") {
|
|
46
|
+
return `${renderHeader(prompt, opts.message)}\n${color.gray(GLYPHS.bar)} ${color.dim.strikethrough(value)}\n${color.red(GLYPHS.barEnd)}`;
|
|
47
|
+
}
|
|
48
|
+
const input = prompt.userInput.length > 0
|
|
49
|
+
? prompt.userInputWithCursor
|
|
50
|
+
: opts.placeholder
|
|
51
|
+
? `${color.inverse(opts.placeholder[0] ?? " ")}${color.dim(opts.placeholder.slice(1))}`
|
|
52
|
+
: color.inverse("_");
|
|
53
|
+
if (prompt.state === "error") {
|
|
54
|
+
return `${renderHeader(prompt, opts.message)}\n${symbolBar(prompt.state)} ${input}\n${color.yellow(GLYPHS.barEnd)} ${color.yellow(prompt.error)}`;
|
|
55
|
+
}
|
|
56
|
+
return `${renderHeader(prompt, opts.message)}\n${symbolBar(prompt.state)} ${input}\n${color.cyan(GLYPHS.barEnd)}`;
|
|
57
|
+
}
|
|
58
|
+
export function textPrompt(opts) {
|
|
59
|
+
return new TextPrompt(opts).prompt();
|
|
60
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getColumns(output: NodeJS.WritableStream): number;
|
|
2
|
+
export declare function getRows(output: NodeJS.WritableStream): number;
|
|
3
|
+
export declare function wrapTextWithPrefix(output: NodeJS.WritableStream, text: string, prefix: string, startPrefix?: string): string;
|
|
4
|
+
export declare function wrapFrame(output: NodeJS.WritableStream, frame: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { wrapAnsi } from "fast-wrap-ansi";
|
|
2
|
+
import stringWidth from "fast-string-width";
|
|
3
|
+
export function getColumns(output) {
|
|
4
|
+
return Math.max(1, output.columns ?? 80);
|
|
5
|
+
}
|
|
6
|
+
export function getRows(output) {
|
|
7
|
+
return Math.max(1, output.rows ?? 20);
|
|
8
|
+
}
|
|
9
|
+
export function wrapTextWithPrefix(output, text, prefix, startPrefix = prefix) {
|
|
10
|
+
const width = Math.max(1, getColumns(output) - stringWidth(prefix));
|
|
11
|
+
return wrapAnsi(text, width, { hard: true, trim: false })
|
|
12
|
+
.split("\n")
|
|
13
|
+
.map((line, index) => `${index === 0 ? startPrefix : prefix}${line}`)
|
|
14
|
+
.join("\n");
|
|
15
|
+
}
|
|
16
|
+
export function wrapFrame(output, frame) {
|
|
17
|
+
return wrapAnsi(frame, getColumns(output), { hard: true, trim: false });
|
|
18
|
+
}
|