@soederpop/luca 0.0.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.md +71 -0
- package/README.md +78 -0
- package/bun.lock +2928 -0
- package/bunfig.toml +3 -0
- package/commands/audit-docs.ts +740 -0
- package/commands/build-scaffolds.ts +154 -0
- package/commands/generate-api-docs.ts +114 -0
- package/commands/update-introspection.ts +67 -0
- package/docs/CLI.md +335 -0
- package/docs/README.md +88 -0
- package/docs/TABLE-OF-CONTENTS.md +157 -0
- package/docs/apis/clients/elevenlabs.md +84 -0
- package/docs/apis/clients/graph.md +56 -0
- package/docs/apis/clients/openai.md +69 -0
- package/docs/apis/clients/rest.md +41 -0
- package/docs/apis/clients/websocket.md +107 -0
- package/docs/apis/features/agi/assistant.md +471 -0
- package/docs/apis/features/agi/assistants-manager.md +154 -0
- package/docs/apis/features/agi/claude-code.md +602 -0
- package/docs/apis/features/agi/conversation-history.md +352 -0
- package/docs/apis/features/agi/conversation.md +333 -0
- package/docs/apis/features/agi/docs-reader.md +121 -0
- package/docs/apis/features/agi/openai-codex.md +318 -0
- package/docs/apis/features/agi/openapi.md +138 -0
- package/docs/apis/features/agi/semantic-search.md +387 -0
- package/docs/apis/features/agi/skills-library.md +216 -0
- package/docs/apis/features/node/container-link.md +133 -0
- package/docs/apis/features/node/content-db.md +313 -0
- package/docs/apis/features/node/disk-cache.md +379 -0
- package/docs/apis/features/node/dns.md +651 -0
- package/docs/apis/features/node/docker.md +705 -0
- package/docs/apis/features/node/downloader.md +81 -0
- package/docs/apis/features/node/esbuild.md +59 -0
- package/docs/apis/features/node/file-manager.md +182 -0
- package/docs/apis/features/node/fs.md +581 -0
- package/docs/apis/features/node/git.md +330 -0
- package/docs/apis/features/node/google-auth.md +174 -0
- package/docs/apis/features/node/google-calendar.md +187 -0
- package/docs/apis/features/node/google-docs.md +151 -0
- package/docs/apis/features/node/google-drive.md +225 -0
- package/docs/apis/features/node/google-sheets.md +179 -0
- package/docs/apis/features/node/grep.md +290 -0
- package/docs/apis/features/node/helpers.md +135 -0
- package/docs/apis/features/node/ink.md +334 -0
- package/docs/apis/features/node/ipc-socket.md +260 -0
- package/docs/apis/features/node/json-tree.md +86 -0
- package/docs/apis/features/node/launcher-app-command-listener.md +145 -0
- package/docs/apis/features/node/networking.md +281 -0
- package/docs/apis/features/node/nlp.md +133 -0
- package/docs/apis/features/node/opener.md +97 -0
- package/docs/apis/features/node/os.md +118 -0
- package/docs/apis/features/node/package-finder.md +402 -0
- package/docs/apis/features/node/postgres.md +212 -0
- package/docs/apis/features/node/proc.md +430 -0
- package/docs/apis/features/node/process-manager.md +210 -0
- package/docs/apis/features/node/python.md +278 -0
- package/docs/apis/features/node/repl.md +88 -0
- package/docs/apis/features/node/runpod.md +673 -0
- package/docs/apis/features/node/secure-shell.md +169 -0
- package/docs/apis/features/node/semantic-search.md +401 -0
- package/docs/apis/features/node/sqlite.md +211 -0
- package/docs/apis/features/node/telegram.md +254 -0
- package/docs/apis/features/node/tts.md +118 -0
- package/docs/apis/features/node/ui.md +703 -0
- package/docs/apis/features/node/vault.md +64 -0
- package/docs/apis/features/node/vm.md +84 -0
- package/docs/apis/features/node/window-manager.md +337 -0
- package/docs/apis/features/node/yaml-tree.md +85 -0
- package/docs/apis/features/node/yaml.md +176 -0
- package/docs/apis/features/web/asset-loader.md +47 -0
- package/docs/apis/features/web/container-link.md +133 -0
- package/docs/apis/features/web/esbuild.md +59 -0
- package/docs/apis/features/web/helpers.md +135 -0
- package/docs/apis/features/web/network.md +30 -0
- package/docs/apis/features/web/speech.md +55 -0
- package/docs/apis/features/web/vault.md +64 -0
- package/docs/apis/features/web/vm.md +84 -0
- package/docs/apis/features/web/voice.md +67 -0
- package/docs/apis/servers/express.md +127 -0
- package/docs/apis/servers/mcp.md +213 -0
- package/docs/apis/servers/websocket.md +99 -0
- package/docs/documentation-audit.md +134 -0
- package/docs/examples/content-db.md +77 -0
- package/docs/examples/disk-cache.md +83 -0
- package/docs/examples/docker.md +101 -0
- package/docs/examples/downloader.md +70 -0
- package/docs/examples/esbuild.md +80 -0
- package/docs/examples/file-manager.md +82 -0
- package/docs/examples/fs.md +83 -0
- package/docs/examples/git.md +85 -0
- package/docs/examples/google-auth.md +88 -0
- package/docs/examples/google-calendar.md +94 -0
- package/docs/examples/google-docs.md +82 -0
- package/docs/examples/google-drive.md +96 -0
- package/docs/examples/google-sheets.md +95 -0
- package/docs/examples/grep.md +85 -0
- package/docs/examples/ink-blocks.md +75 -0
- package/docs/examples/ink-renderer.md +41 -0
- package/docs/examples/ink.md +103 -0
- package/docs/examples/ipc-socket.md +103 -0
- package/docs/examples/json-tree.md +91 -0
- package/docs/examples/launcher-app-command-listener.md +120 -0
- package/docs/examples/networking.md +58 -0
- package/docs/examples/nlp.md +91 -0
- package/docs/examples/opener.md +78 -0
- package/docs/examples/os.md +72 -0
- package/docs/examples/package-finder.md +89 -0
- package/docs/examples/port-exposer.md +89 -0
- package/docs/examples/postgres.md +91 -0
- package/docs/examples/proc.md +81 -0
- package/docs/examples/process-manager.md +79 -0
- package/docs/examples/python.md +91 -0
- package/docs/examples/repl.md +93 -0
- package/docs/examples/runpod.md +119 -0
- package/docs/examples/secure-shell.md +92 -0
- package/docs/examples/sqlite.md +86 -0
- package/docs/examples/telegram.md +77 -0
- package/docs/examples/tts.md +86 -0
- package/docs/examples/ui.md +80 -0
- package/docs/examples/vault.md +70 -0
- package/docs/examples/vm.md +86 -0
- package/docs/examples/window-manager.md +125 -0
- package/docs/examples/yaml-tree.md +93 -0
- package/docs/examples/yaml.md +104 -0
- package/docs/ideas/class-registration-refactor-possibilities.md +197 -0
- package/docs/ideas/container-use-api.md +9 -0
- package/docs/ideas/easy-auth-for-express-servers-and-luca-serve.md +0 -0
- package/docs/ideas/feature-stacks.md +22 -0
- package/docs/ideas/luca-cli-self-sufficiency-demo.md +23 -0
- package/docs/ideas/mcp-design.md +9 -0
- package/docs/ideas/web-container-debugging-feature.md +13 -0
- package/docs/introspection-audit.md +49 -0
- package/docs/introspection.md +154 -0
- package/docs/mcp/readme.md +162 -0
- package/docs/models.ts +38 -0
- package/docs/philosophy.md +85 -0
- package/docs/principles.md +7 -0
- package/docs/prompts/audit-codebase-for-failures-to-use-the-container.md +34 -0
- package/docs/prompts/mcp-test-easy-command.md +27 -0
- package/docs/reports/assistant-bugs.md +38 -0
- package/docs/reports/attach-pattern-usage.md +18 -0
- package/docs/reports/code-audit-results.md +391 -0
- package/docs/reports/introspection-audit-tasks.md +378 -0
- package/docs/reports/luca-mcp-improvements.md +128 -0
- package/docs/scaffolds/client.md +140 -0
- package/docs/scaffolds/command.md +106 -0
- package/docs/scaffolds/endpoint.md +176 -0
- package/docs/scaffolds/feature.md +148 -0
- package/docs/scaffolds/server.md +187 -0
- package/docs/tasks/web-container-helper-discovery.md +71 -0
- package/docs/todos.md +1 -0
- package/docs/tutorials/01-getting-started.md +106 -0
- package/docs/tutorials/02-container.md +210 -0
- package/docs/tutorials/03-scripts.md +194 -0
- package/docs/tutorials/04-features-overview.md +196 -0
- package/docs/tutorials/05-state-and-events.md +171 -0
- package/docs/tutorials/06-servers.md +157 -0
- package/docs/tutorials/07-endpoints.md +198 -0
- package/docs/tutorials/08-commands.md +171 -0
- package/docs/tutorials/09-clients.md +162 -0
- package/docs/tutorials/10-creating-features.md +198 -0
- package/docs/tutorials/11-contentbase.md +191 -0
- package/docs/tutorials/12-assistants.md +215 -0
- package/docs/tutorials/13-introspection.md +147 -0
- package/docs/tutorials/14-type-system.md +174 -0
- package/docs/tutorials/15-project-patterns.md +222 -0
- package/docs/tutorials/16-google-features.md +534 -0
- package/docs/tutorials/17-tui-blocks.md +530 -0
- package/docs/tutorials/18-semantic-search.md +334 -0
- package/index.ts +1 -0
- package/luca.console.ts +9 -0
- package/main.py +6 -0
- package/package.json +154 -0
- package/pyproject.toml +7 -0
- package/scripts/animations/chrome-glitch.ts +55 -0
- package/scripts/animations/index.ts +16 -0
- package/scripts/animations/neon-pulse.ts +64 -0
- package/scripts/animations/types.ts +6 -0
- package/scripts/build-web.ts +28 -0
- package/scripts/examples/ask-luca-expert.ts +42 -0
- package/scripts/examples/assistant-questions.ts +12 -0
- package/scripts/examples/excalidraw-expert.ts +75 -0
- package/scripts/examples/expert-chat.ts +0 -0
- package/scripts/examples/file-manager.ts +14 -0
- package/scripts/examples/ideas.ts +12 -0
- package/scripts/examples/interactive-chat.ts +20 -0
- package/scripts/examples/openai-tool-calls.ts +113 -0
- package/scripts/examples/opening-a-web-browser.ts +5 -0
- package/scripts/examples/telegram-bot.ts +79 -0
- package/scripts/examples/telegram-ink-ui.ts +302 -0
- package/scripts/examples/using-assistant-with-mcp.ts +560 -0
- package/scripts/examples/using-claude-code.ts +10 -0
- package/scripts/examples/using-contentdb.ts +35 -0
- package/scripts/examples/using-conversations.ts +35 -0
- package/scripts/examples/using-disk-cache.ts +10 -0
- package/scripts/examples/using-docker-shell.ts +75 -0
- package/scripts/examples/using-elevenlabs.ts +25 -0
- package/scripts/examples/using-google-calendar.ts +57 -0
- package/scripts/examples/using-google-docs.ts +74 -0
- package/scripts/examples/using-google-drive.ts +74 -0
- package/scripts/examples/using-google-sheets.ts +89 -0
- package/scripts/examples/using-nlp.ts +55 -0
- package/scripts/examples/using-ollama.ts +10 -0
- package/scripts/examples/using-openai-codex.ts +23 -0
- package/scripts/examples/using-postgres.ts +55 -0
- package/scripts/examples/using-runpod.ts +32 -0
- package/scripts/examples/using-tts.ts +40 -0
- package/scripts/examples/vm-loading-esm-modules.ts +16 -0
- package/scripts/scaffold.ts +391 -0
- package/scripts/scratch.ts +15 -0
- package/scripts/test-command-listener.ts +123 -0
- package/scripts/test-window-manager-lifecycle.ts +86 -0
- package/scripts/test-window-manager.ts +43 -0
- package/scripts/update-introspection-data.ts +58 -0
- package/src/agi/README.md +14 -0
- package/src/agi/container.server.ts +114 -0
- package/src/agi/endpoints/ask.ts +60 -0
- package/src/agi/endpoints/conversations/[id].ts +45 -0
- package/src/agi/endpoints/conversations.ts +31 -0
- package/src/agi/endpoints/experts.ts +37 -0
- package/src/agi/features/assistant.ts +767 -0
- package/src/agi/features/assistants-manager.ts +260 -0
- package/src/agi/features/claude-code.ts +1111 -0
- package/src/agi/features/conversation-history.ts +497 -0
- package/src/agi/features/conversation.ts +799 -0
- package/src/agi/features/openai-codex.ts +631 -0
- package/src/agi/features/openapi.ts +438 -0
- package/src/agi/features/skills-library.ts +425 -0
- package/src/agi/index.ts +6 -0
- package/src/agi/lib/token-counter.ts +122 -0
- package/src/browser.ts +25 -0
- package/src/bus.ts +100 -0
- package/src/cli/cli.ts +70 -0
- package/src/client.ts +461 -0
- package/src/clients/civitai/index.ts +541 -0
- package/src/clients/client-template.ts +41 -0
- package/src/clients/comfyui/index.ts +597 -0
- package/src/clients/elevenlabs/index.ts +291 -0
- package/src/clients/openai/index.ts +451 -0
- package/src/clients/supabase/index.ts +366 -0
- package/src/command.ts +164 -0
- package/src/commands/chat.ts +182 -0
- package/src/commands/console.ts +192 -0
- package/src/commands/describe.ts +433 -0
- package/src/commands/eval.ts +116 -0
- package/src/commands/help.ts +214 -0
- package/src/commands/index.ts +14 -0
- package/src/commands/mcp.ts +64 -0
- package/src/commands/prompt.ts +807 -0
- package/src/commands/run.ts +257 -0
- package/src/commands/sandbox-mcp.ts +439 -0
- package/src/commands/scaffold.ts +79 -0
- package/src/commands/serve.ts +172 -0
- package/src/container.ts +781 -0
- package/src/endpoint.ts +340 -0
- package/src/feature.ts +75 -0
- package/src/hash-object.ts +97 -0
- package/src/helper.ts +543 -0
- package/src/introspection/generated.agi.ts +23388 -0
- package/src/introspection/generated.node.ts +18899 -0
- package/src/introspection/generated.web.ts +2021 -0
- package/src/introspection/index.ts +256 -0
- package/src/introspection/scan.ts +912 -0
- package/src/node/container.ts +354 -0
- package/src/node/feature.ts +13 -0
- package/src/node/features/container-link.ts +558 -0
- package/src/node/features/content-db.ts +475 -0
- package/src/node/features/disk-cache.ts +382 -0
- package/src/node/features/dns.ts +655 -0
- package/src/node/features/docker.ts +912 -0
- package/src/node/features/downloader.ts +92 -0
- package/src/node/features/esbuild.ts +68 -0
- package/src/node/features/file-manager.ts +357 -0
- package/src/node/features/fs.ts +534 -0
- package/src/node/features/git.ts +492 -0
- package/src/node/features/google-auth.ts +502 -0
- package/src/node/features/google-calendar.ts +300 -0
- package/src/node/features/google-docs.ts +404 -0
- package/src/node/features/google-drive.ts +339 -0
- package/src/node/features/google-sheets.ts +279 -0
- package/src/node/features/grep.ts +406 -0
- package/src/node/features/helpers.ts +374 -0
- package/src/node/features/ink.ts +490 -0
- package/src/node/features/ipc-socket.ts +459 -0
- package/src/node/features/json-tree.ts +188 -0
- package/src/node/features/launcher-app-command-listener.ts +388 -0
- package/src/node/features/networking.ts +925 -0
- package/src/node/features/nlp.ts +211 -0
- package/src/node/features/opener.ts +166 -0
- package/src/node/features/os.ts +157 -0
- package/src/node/features/package-finder.ts +539 -0
- package/src/node/features/port-exposer.ts +342 -0
- package/src/node/features/postgres.ts +273 -0
- package/src/node/features/proc.ts +502 -0
- package/src/node/features/process-manager.ts +542 -0
- package/src/node/features/python.ts +444 -0
- package/src/node/features/repl.ts +194 -0
- package/src/node/features/runpod.ts +802 -0
- package/src/node/features/secure-shell.ts +248 -0
- package/src/node/features/semantic-search.ts +924 -0
- package/src/node/features/sqlite.ts +289 -0
- package/src/node/features/telegram.ts +342 -0
- package/src/node/features/tts.ts +184 -0
- package/src/node/features/ui.ts +857 -0
- package/src/node/features/vault.ts +164 -0
- package/src/node/features/vm.ts +312 -0
- package/src/node/features/window-manager.ts +804 -0
- package/src/node/features/yaml-tree.ts +149 -0
- package/src/node/features/yaml.ts +132 -0
- package/src/node.ts +70 -0
- package/src/react/index.ts +175 -0
- package/src/registry.ts +199 -0
- package/src/scaffolds/generated.ts +1613 -0
- package/src/scaffolds/template.ts +37 -0
- package/src/schemas/base.ts +255 -0
- package/src/server.ts +135 -0
- package/src/servers/express.ts +209 -0
- package/src/servers/mcp.ts +805 -0
- package/src/servers/socket.ts +120 -0
- package/src/state.ts +101 -0
- package/src/web/clients/socket.ts +82 -0
- package/src/web/container.ts +74 -0
- package/src/web/extension.ts +30 -0
- package/src/web/feature.ts +12 -0
- package/src/web/features/asset-loader.ts +64 -0
- package/src/web/features/container-link.ts +385 -0
- package/src/web/features/esbuild.ts +79 -0
- package/src/web/features/helpers.ts +267 -0
- package/src/web/features/network.ts +61 -0
- package/src/web/features/speech.ts +87 -0
- package/src/web/features/vault.ts +189 -0
- package/src/web/features/vm.ts +78 -0
- package/src/web/features/voice-recognition.ts +129 -0
- package/src/web/shims/isomorphic-vm.ts +149 -0
- package/test/bus.test.ts +134 -0
- package/test/clients-servers.test.ts +216 -0
- package/test/container-link.test.ts +274 -0
- package/test/features.test.ts +160 -0
- package/test/integration.test.ts +787 -0
- package/test/node-container.test.ts +121 -0
- package/test/rate-limit.test.ts +272 -0
- package/test/semantic-search.test.ts +550 -0
- package/test/state.test.ts +121 -0
- package/test-integration/assistant.test.ts +138 -0
- package/test-integration/assistants-manager.test.ts +123 -0
- package/test-integration/claude-code.test.ts +98 -0
- package/test-integration/conversation-history.test.ts +205 -0
- package/test-integration/conversation.test.ts +137 -0
- package/test-integration/elevenlabs.test.ts +55 -0
- package/test-integration/google-services.test.ts +80 -0
- package/test-integration/helpers.ts +89 -0
- package/test-integration/openai-codex.test.ts +93 -0
- package/test-integration/runpod.test.ts +58 -0
- package/test-integration/server-endpoints.test.ts +97 -0
- package/test-integration/skills-library.test.ts +157 -0
- package/test-integration/telegram.test.ts +46 -0
- package/tsconfig.json +58 -0
- package/uv.lock +8 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
# UI (features.ui)
|
|
2
|
+
|
|
3
|
+
UI Feature - Interactive Terminal User Interface Builder This feature provides comprehensive tools for creating beautiful, interactive terminal experiences. It combines several popular libraries (chalk, figlet, inquirer) into a unified interface for building professional CLI applications with colors, ASCII art, and interactive prompts. **Core Capabilities:** - Rich color management using chalk library - ASCII art generation with multiple fonts - Interactive prompts and wizards - Automatic color assignment for consistent theming - Text padding and formatting utilities - Gradient text effects (horizontal and vertical) - Banner creation with styled ASCII art **Color System:** - Full chalk API access for complex styling - Automatic color assignment with palette cycling - Consistent color mapping for named entities - Support for hex colors and gradients **ASCII Art Features:** - Multiple font options via figlet - Automatic font discovery and caching - Banner creation with color gradients - Text styling and effects **Interactive Elements:** - Wizard creation with inquirer integration - External editor integration - User input validation and processing **Usage Examples:** **Basic Colors:** ```typescript const ui = container.feature('ui'); // Direct color usage ui.print.red('Error message'); ui.print.green('Success!'); // Complex styling console.log(ui.colors.blue.bold.underline('Important text')); ``` **ASCII Art Banners:** ```typescript const banner = ui.banner('MyApp', { font: 'Big', colors: ['red', 'white', 'blue'] }); console.log(banner); ``` **Interactive Wizards:** ```typescript const answers = await ui.wizard([ { type: 'input', name: 'name', message: 'Your name?' }, { type: 'confirm', name: 'continue', message: 'Continue?' } ]); ``` **Automatic Color Assignment:** ```typescript const userColor = ui.assignColor('john'); const adminColor = ui.assignColor('admin'); console.log(userColor('John\'s message')); console.log(adminColor('Admin notice')); ```
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
container.feature('ui')
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
### markdown
|
|
14
|
+
|
|
15
|
+
Parse markdown text and render it for terminal display using marked-terminal.
|
|
16
|
+
|
|
17
|
+
**Parameters:**
|
|
18
|
+
|
|
19
|
+
| Name | Type | Required | Description |
|
|
20
|
+
|------|------|----------|-------------|
|
|
21
|
+
| `text` | `string` | ✓ | The markdown string to parse and render |
|
|
22
|
+
|
|
23
|
+
**Returns:** `void`
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### assignColor
|
|
28
|
+
|
|
29
|
+
Assigns a consistent color to a named entity. This method provides automatic color assignment that remains consistent across the application session. Each unique name gets assigned a color from the palette, and subsequent calls with the same name return the same color function. **Assignment Strategy:** - First call with a name assigns the next available palette color - Subsequent calls return the previously assigned color - Colors cycle through the palette when all colors are used - Returns a chalk hex color function for styling text
|
|
30
|
+
|
|
31
|
+
**Parameters:**
|
|
32
|
+
|
|
33
|
+
| Name | Type | Required | Description |
|
|
34
|
+
|------|------|----------|-------------|
|
|
35
|
+
| `name` | `string` | ✓ | The unique identifier to assign a color to |
|
|
36
|
+
|
|
37
|
+
**Returns:** `(str: string) => string`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// Assign colors to users
|
|
41
|
+
const johnColor = ui.assignColor('john');
|
|
42
|
+
const janeColor = ui.assignColor('jane');
|
|
43
|
+
|
|
44
|
+
// Use consistently throughout the app
|
|
45
|
+
console.log(johnColor('John: Hello there!'));
|
|
46
|
+
console.log(janeColor('Jane: Hi John!'));
|
|
47
|
+
console.log(johnColor('John: How are you?')); // Same color as before
|
|
48
|
+
|
|
49
|
+
// Different entities get different colors
|
|
50
|
+
const errorColor = ui.assignColor('error');
|
|
51
|
+
const successColor = ui.assignColor('success');
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### wizard
|
|
57
|
+
|
|
58
|
+
Creates an interactive wizard using inquirer prompts. This method provides a convenient wrapper around inquirer for creating interactive command-line wizards. It supports all inquirer question types and can handle complex validation and conditional logic. **Supported Question Types:** - input: Text input fields - confirm: Yes/no confirmations - list: Single selection from options - checkbox: Multiple selections - password: Hidden text input - editor: External editor integration **Advanced Features:** - Conditional questions based on previous answers - Input validation and transformation - Custom prompts and styling - Initial answer pre-population
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
|
|
62
|
+
| Name | Type | Required | Description |
|
|
63
|
+
|------|------|----------|-------------|
|
|
64
|
+
| `questions` | `any[]` | ✓ | Array of inquirer question objects |
|
|
65
|
+
| `initialAnswers` | `any` | | Pre-populated answers to skip questions or provide defaults |
|
|
66
|
+
|
|
67
|
+
**Returns:** `void`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// Basic wizard
|
|
71
|
+
const answers = await ui.wizard([
|
|
72
|
+
{
|
|
73
|
+
type: 'input',
|
|
74
|
+
name: 'projectName',
|
|
75
|
+
message: 'What is your project name?',
|
|
76
|
+
validate: (input) => input.length > 0 || 'Name is required'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'list',
|
|
80
|
+
name: 'framework',
|
|
81
|
+
message: 'Choose a framework:',
|
|
82
|
+
choices: ['React', 'Vue', 'Angular', 'Svelte']
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'confirm',
|
|
86
|
+
name: 'typescript',
|
|
87
|
+
message: 'Use TypeScript?',
|
|
88
|
+
default: true
|
|
89
|
+
}
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
console.log(`Creating ${answers.projectName} with ${answers.framework}`);
|
|
93
|
+
|
|
94
|
+
// With initial answers
|
|
95
|
+
const moreAnswers = await ui.wizard([
|
|
96
|
+
{ type: 'input', name: 'version', message: 'Version?' }
|
|
97
|
+
], { version: '1.0.0' });
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### askQuestion
|
|
103
|
+
|
|
104
|
+
Prompt the user with a single text input question.
|
|
105
|
+
|
|
106
|
+
**Parameters:**
|
|
107
|
+
|
|
108
|
+
| Name | Type | Required | Description |
|
|
109
|
+
|------|------|----------|-------------|
|
|
110
|
+
| `question` | `string` | ✓ | The question message to display |
|
|
111
|
+
|
|
112
|
+
**Returns:** `void`
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### openInEditor
|
|
117
|
+
|
|
118
|
+
Opens text in the user's external editor for editing. This method integrates with the user's configured editor (via $EDITOR or $VISUAL environment variables) to allow editing of text content. The edited content is returned when the user saves and closes the editor. **Editor Integration:** - Respects $EDITOR and $VISUAL environment variables - Creates temporary file with specified extension - Returns modified content after editor closes - Handles editor cancellation gracefully
|
|
119
|
+
|
|
120
|
+
**Parameters:**
|
|
121
|
+
|
|
122
|
+
| Name | Type | Required | Description |
|
|
123
|
+
|------|------|----------|-------------|
|
|
124
|
+
| `text` | `string` | ✓ | The initial text content to edit |
|
|
125
|
+
| `extension` | `any` | | File extension for syntax highlighting (default: ".ts") |
|
|
126
|
+
|
|
127
|
+
**Returns:** `void`
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// Edit code snippet
|
|
131
|
+
const code = `function hello() {\n console.log('Hello');\n}`;
|
|
132
|
+
const editedCode = await ui.openInEditor(code, '.js');
|
|
133
|
+
|
|
134
|
+
// Edit configuration
|
|
135
|
+
const config = JSON.stringify({ port: 3000 }, null, 2);
|
|
136
|
+
const newConfig = await ui.openInEditor(config, '.json');
|
|
137
|
+
|
|
138
|
+
// Edit markdown content
|
|
139
|
+
const markdown = '# Title\n\nContent here...';
|
|
140
|
+
const editedMarkdown = await ui.openInEditor(markdown, '.md');
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### asciiArt
|
|
146
|
+
|
|
147
|
+
Generates ASCII art from text using the specified font. This method converts regular text into stylized ASCII art using figlet's extensive font collection. Perfect for creating eye-catching headers, logos, and decorative text in terminal applications. **Font Capabilities:** - Large collection of artistic fonts - Various styles: block, script, decorative, technical - Different sizes and character sets - Consistent spacing and alignment
|
|
148
|
+
|
|
149
|
+
**Parameters:**
|
|
150
|
+
|
|
151
|
+
| Name | Type | Required | Description |
|
|
152
|
+
|------|------|----------|-------------|
|
|
153
|
+
| `text` | `string` | ✓ | The text to convert to ASCII art |
|
|
154
|
+
| `font` | `Fonts` | ✓ | The figlet font to use (see fonts property for available options) |
|
|
155
|
+
|
|
156
|
+
**Returns:** `void`
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// Create a banner
|
|
160
|
+
const banner = ui.asciiArt('WELCOME', 'Big');
|
|
161
|
+
console.log(banner);
|
|
162
|
+
|
|
163
|
+
// Different fonts for different purposes
|
|
164
|
+
const title = ui.asciiArt('MyApp', 'Standard');
|
|
165
|
+
const subtitle = ui.asciiArt('v2.0', 'Small');
|
|
166
|
+
|
|
167
|
+
// Technical/coding themes
|
|
168
|
+
const code = ui.asciiArt('CODE', '3D-ASCII');
|
|
169
|
+
|
|
170
|
+
// List available fonts first
|
|
171
|
+
console.log('Available fonts:', ui.fonts.slice(0, 10).join(', '));
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
### banner
|
|
177
|
+
|
|
178
|
+
Creates a styled banner with ASCII art and color gradients. This method combines ASCII art generation with color gradient effects to create visually striking banners for terminal applications. It automatically applies color gradients to the generated ASCII art based on the specified options. **Banner Features:** - ASCII art text generation - Automatic color gradient application - Customizable gradient directions - Multiple color combinations - Professional terminal presentation
|
|
179
|
+
|
|
180
|
+
**Parameters:**
|
|
181
|
+
|
|
182
|
+
| Name | Type | Required | Description |
|
|
183
|
+
|------|------|----------|-------------|
|
|
184
|
+
| `text` | `string` | ✓ | The text to convert to a styled banner |
|
|
185
|
+
| `options` | `{ font: Fonts; colors: Color[] }` | | Banner styling options |
|
|
186
|
+
|
|
187
|
+
`{ font: Fonts; colors: Color[] }` properties:
|
|
188
|
+
|
|
189
|
+
| Property | Type | Description |
|
|
190
|
+
|----------|------|-------------|
|
|
191
|
+
| `font` | `any` | The figlet font to use for ASCII art generation |
|
|
192
|
+
| `colors` | `any` | Array of colors for the gradient effect |
|
|
193
|
+
|
|
194
|
+
**Returns:** `void`
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
// Classic patriotic banner
|
|
198
|
+
const banner = ui.banner('AMERICA', {
|
|
199
|
+
font: 'Big',
|
|
200
|
+
colors: ['red', 'white', 'blue']
|
|
201
|
+
});
|
|
202
|
+
console.log(banner);
|
|
203
|
+
|
|
204
|
+
// Tech company banner
|
|
205
|
+
const techBanner = ui.banner('TechCorp', {
|
|
206
|
+
font: 'Slant',
|
|
207
|
+
colors: ['cyan', 'blue', 'magenta']
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Warning banner
|
|
211
|
+
const warningBanner = ui.banner('WARNING', {
|
|
212
|
+
font: 'Standard',
|
|
213
|
+
colors: ['yellow', 'red']
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Available fonts: see ui.fonts property
|
|
217
|
+
// Available colors: any chalk color names
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### endent
|
|
223
|
+
|
|
224
|
+
Dedent and format a tagged template literal using endent. Strips leading indentation while preserving relative indentation.
|
|
225
|
+
|
|
226
|
+
**Parameters:**
|
|
227
|
+
|
|
228
|
+
| Name | Type | Required | Description |
|
|
229
|
+
|------|------|----------|-------------|
|
|
230
|
+
| `args` | `any[]` | ✓ | Tagged template literal arguments |
|
|
231
|
+
|
|
232
|
+
**Returns:** `void`
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
### applyGradient
|
|
237
|
+
|
|
238
|
+
Applies color gradients to text with configurable direction. This method creates smooth color transitions across text content, supporting both horizontal (character-by-character) and vertical (line-by-line) gradients. Perfect for creating visually appealing terminal output and ASCII art effects. **Gradient Types:** - Horizontal: Colors transition across characters in each line - Vertical: Colors transition across lines of text - Customizable color sequences and transitions - Automatic color cycling for long content
|
|
239
|
+
|
|
240
|
+
**Parameters:**
|
|
241
|
+
|
|
242
|
+
| Name | Type | Required | Description |
|
|
243
|
+
|------|------|----------|-------------|
|
|
244
|
+
| `text` | `string` | ✓ | The text content to apply gradients to |
|
|
245
|
+
| `lineColors` | `Color[]` | | Array of colors to cycle through in the gradient |
|
|
246
|
+
| `direction` | `"horizontal" | "vertical"` | | Gradient direction: 'horizontal' or 'vertical' |
|
|
247
|
+
|
|
248
|
+
**Returns:** `void`
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
// Horizontal rainbow effect
|
|
252
|
+
const rainbow = ui.applyGradient('Hello World!',
|
|
253
|
+
['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
|
|
254
|
+
'horizontal'
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
// Vertical gradient for multi-line text
|
|
258
|
+
const multiline = 'Line 1\nLine 2\nLine 3\nLine 4';
|
|
259
|
+
const vertical = ui.applyGradient(multiline,
|
|
260
|
+
['red', 'white', 'blue'],
|
|
261
|
+
'vertical'
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// Fire effect
|
|
265
|
+
const fire = ui.applyGradient('FIRE', ['red', 'yellow'], 'horizontal');
|
|
266
|
+
|
|
267
|
+
// Ocean effect
|
|
268
|
+
const ocean = ui.applyGradient('OCEAN', ['blue', 'cyan', 'white'], 'vertical');
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
### applyHorizontalGradient
|
|
274
|
+
|
|
275
|
+
Applies horizontal color gradients character by character. This method creates color transitions across characters within the text, cycling through the provided colors to create smooth horizontal gradients. Each character gets assigned a color based on its position in the sequence. **Horizontal Gradient Behavior:** - Each character is individually colored - Colors cycle through the provided array - Creates smooth transitions across text width - Works well with ASCII art and single lines
|
|
276
|
+
|
|
277
|
+
**Parameters:**
|
|
278
|
+
|
|
279
|
+
| Name | Type | Required | Description |
|
|
280
|
+
|------|------|----------|-------------|
|
|
281
|
+
| `text` | `string` | ✓ | The text to apply horizontal gradients to |
|
|
282
|
+
| `lineColors` | `Color[]` | | Array of colors to cycle through |
|
|
283
|
+
|
|
284
|
+
**Returns:** `void`
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
// Rainbow effect across characters
|
|
288
|
+
const rainbow = ui.applyHorizontalGradient('RAINBOW',
|
|
289
|
+
['red', 'yellow', 'green', 'cyan', 'blue', 'magenta']
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
// Simple two-color transition
|
|
293
|
+
const sunset = ui.applyHorizontalGradient('SUNSET', ['red', 'orange']);
|
|
294
|
+
|
|
295
|
+
// Great for short text and ASCII art
|
|
296
|
+
const art = ui.asciiArt('COOL', 'Big');
|
|
297
|
+
const coloredArt = ui.applyHorizontalGradient(art, ['cyan', 'blue']);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
### applyVerticalGradient
|
|
303
|
+
|
|
304
|
+
Applies vertical color gradients line by line. This method creates color transitions across lines of text, with each line getting a different color from the sequence. Perfect for multi-line content like ASCII art, banners, and structured output. **Vertical Gradient Behavior:** - Each line is colored uniformly - Colors cycle through the provided array - Creates smooth transitions across text height - Ideal for multi-line ASCII art and structured content
|
|
305
|
+
|
|
306
|
+
**Parameters:**
|
|
307
|
+
|
|
308
|
+
| Name | Type | Required | Description |
|
|
309
|
+
|------|------|----------|-------------|
|
|
310
|
+
| `text` | `string` | ✓ | The text to apply vertical gradients to (supports newlines) |
|
|
311
|
+
| `lineColors` | `Color[]` | | Array of colors to cycle through for each line |
|
|
312
|
+
|
|
313
|
+
**Returns:** `void`
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
// Patriotic vertical gradient
|
|
317
|
+
const flag = 'USA\nUSA\nUSA\nUSA';
|
|
318
|
+
const patriotic = ui.applyVerticalGradient(flag, ['red', 'white', 'blue']);
|
|
319
|
+
|
|
320
|
+
// Sunset effect on ASCII art
|
|
321
|
+
const banner = ui.asciiArt('SUNSET', 'Big');
|
|
322
|
+
const sunset = ui.applyVerticalGradient(banner,
|
|
323
|
+
['yellow', 'orange', 'red', 'purple']
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
// Ocean waves effect
|
|
327
|
+
const waves = 'Wave 1\nWave 2\nWave 3\nWave 4\nWave 5';
|
|
328
|
+
const ocean = ui.applyVerticalGradient(waves, ['cyan', 'blue']);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
### padLeft
|
|
334
|
+
|
|
335
|
+
Pads text on the left to reach the specified length. This utility method adds padding characters to the left side of text to achieve a desired total length. Useful for creating aligned columns, formatted tables, and consistent text layout in terminal applications. **Padding Behavior:** - Adds padding to the left (start) of the string - Uses specified padding character (default: space) - Returns original string if already at or beyond target length - Handles multi-character padding by repeating the character
|
|
336
|
+
|
|
337
|
+
**Parameters:**
|
|
338
|
+
|
|
339
|
+
| Name | Type | Required | Description |
|
|
340
|
+
|------|------|----------|-------------|
|
|
341
|
+
| `str` | `string` | ✓ | The string to pad |
|
|
342
|
+
| `length` | `number` | ✓ | The desired total length after padding |
|
|
343
|
+
| `padChar` | `any` | | The character to use for padding (default: " ") |
|
|
344
|
+
|
|
345
|
+
**Returns:** `void`
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
// Number alignment
|
|
349
|
+
const numbers = ['1', '23', '456'];
|
|
350
|
+
numbers.forEach(num => {
|
|
351
|
+
console.log(ui.padLeft(num, 5, '0')); // '00001', '00023', '00456'
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// Text alignment in columns
|
|
355
|
+
const items = ['apple', 'banana', 'cherry'];
|
|
356
|
+
items.forEach(item => {
|
|
357
|
+
console.log(ui.padLeft(item, 10) + ' | Price: $1.00');
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// Custom padding character
|
|
361
|
+
const title = ui.padLeft('TITLE', 20, '-'); // '---------------TITLE'
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
### padRight
|
|
367
|
+
|
|
368
|
+
Pads text on the right to reach the specified length. This utility method adds padding characters to the right side of text to achieve a desired total length. Essential for creating properly aligned columns, tables, and formatted output in terminal applications. **Padding Behavior:** - Adds padding to the right (end) of the string - Uses specified padding character (default: space) - Returns original string if already at or beyond target length - Handles multi-character padding by repeating the character
|
|
369
|
+
|
|
370
|
+
**Parameters:**
|
|
371
|
+
|
|
372
|
+
| Name | Type | Required | Description |
|
|
373
|
+
|------|------|----------|-------------|
|
|
374
|
+
| `str` | `string` | ✓ | The string to pad |
|
|
375
|
+
| `length` | `number` | ✓ | The desired total length after padding |
|
|
376
|
+
| `padChar` | `any` | | The character to use for padding (default: " ") |
|
|
377
|
+
|
|
378
|
+
**Returns:** `void`
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
// Create aligned table columns
|
|
382
|
+
const data = [
|
|
383
|
+
['Name', 'Age', 'City'],
|
|
384
|
+
['John', '25', 'NYC'],
|
|
385
|
+
['Jane', '30', 'LA'],
|
|
386
|
+
['Bob', '35', 'Chicago']
|
|
387
|
+
];
|
|
388
|
+
|
|
389
|
+
data.forEach(row => {
|
|
390
|
+
const formatted = row.map((cell, i) => {
|
|
391
|
+
const widths = [15, 5, 10];
|
|
392
|
+
return ui.padRight(cell, widths[i]);
|
|
393
|
+
}).join(' | ');
|
|
394
|
+
console.log(formatted);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Progress bars
|
|
398
|
+
const progress = ui.padRight('████', 20, '░'); // '████░░░░░░░░░░░░░░░░'
|
|
399
|
+
|
|
400
|
+
// Menu items with dots
|
|
401
|
+
const menuItem = ui.padRight('Coffee', 20, '.') + '$3.50';
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
## Getters
|
|
407
|
+
|
|
408
|
+
| Property | Type | Description |
|
|
409
|
+
|----------|------|-------------|
|
|
410
|
+
| `colors` | `typeof colors` | Provides access to the full chalk colors API. Chalk provides extensive color and styling capabilities including: - Basic colors: red, green, blue, yellow, etc. - Background colors: bgRed, bgGreen, etc. - Styles: bold, italic, underline, strikethrough - Advanced: rgb, hex, hsl color support Colors and styles can be chained for complex formatting. |
|
|
411
|
+
| `colorPalette` | `string[]` | Gets the current color palette used for automatic color assignment. The color palette is a predefined set of hex colors that are automatically assigned to named entities in a cycling fashion. This ensures consistent color assignment across the application. |
|
|
412
|
+
| `randomColor` | `any` | Gets a random color name from the available chalk colors. This provides access to a randomly selected color from chalk's built-in color set. Useful for adding variety to terminal output or testing. |
|
|
413
|
+
| `fonts` | `string[]` | Gets an array of available fonts for ASCII art generation. This method provides access to all fonts available through figlet for creating ASCII art. The fonts are automatically discovered and cached on first access for performance. **Font Discovery:** - Fonts are loaded from figlet's built-in font collection - Results are cached in state to avoid repeated file system access - Returns comprehensive list of available font names |
|
|
414
|
+
|
|
415
|
+
## State (Zod v4 schema)
|
|
416
|
+
|
|
417
|
+
| Property | Type | Description |
|
|
418
|
+
|----------|------|-------------|
|
|
419
|
+
| `enabled` | `boolean` | Whether this feature is currently enabled |
|
|
420
|
+
| `fonts` | `array` | Array of available fonts for ASCII art generation |
|
|
421
|
+
| `colorPalette` | `array` | Color palette of hex colors for automatic color assignment |
|
|
422
|
+
|
|
423
|
+
## Examples
|
|
424
|
+
|
|
425
|
+
**assignColor**
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
// Assign colors to users
|
|
429
|
+
const johnColor = ui.assignColor('john');
|
|
430
|
+
const janeColor = ui.assignColor('jane');
|
|
431
|
+
|
|
432
|
+
// Use consistently throughout the app
|
|
433
|
+
console.log(johnColor('John: Hello there!'));
|
|
434
|
+
console.log(janeColor('Jane: Hi John!'));
|
|
435
|
+
console.log(johnColor('John: How are you?')); // Same color as before
|
|
436
|
+
|
|
437
|
+
// Different entities get different colors
|
|
438
|
+
const errorColor = ui.assignColor('error');
|
|
439
|
+
const successColor = ui.assignColor('success');
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
**wizard**
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
// Basic wizard
|
|
448
|
+
const answers = await ui.wizard([
|
|
449
|
+
{
|
|
450
|
+
type: 'input',
|
|
451
|
+
name: 'projectName',
|
|
452
|
+
message: 'What is your project name?',
|
|
453
|
+
validate: (input) => input.length > 0 || 'Name is required'
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: 'list',
|
|
457
|
+
name: 'framework',
|
|
458
|
+
message: 'Choose a framework:',
|
|
459
|
+
choices: ['React', 'Vue', 'Angular', 'Svelte']
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
type: 'confirm',
|
|
463
|
+
name: 'typescript',
|
|
464
|
+
message: 'Use TypeScript?',
|
|
465
|
+
default: true
|
|
466
|
+
}
|
|
467
|
+
]);
|
|
468
|
+
|
|
469
|
+
console.log(`Creating ${answers.projectName} with ${answers.framework}`);
|
|
470
|
+
|
|
471
|
+
// With initial answers
|
|
472
|
+
const moreAnswers = await ui.wizard([
|
|
473
|
+
{ type: 'input', name: 'version', message: 'Version?' }
|
|
474
|
+
], { version: '1.0.0' });
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
**openInEditor**
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
// Edit code snippet
|
|
483
|
+
const code = `function hello() {\n console.log('Hello');\n}`;
|
|
484
|
+
const editedCode = await ui.openInEditor(code, '.js');
|
|
485
|
+
|
|
486
|
+
// Edit configuration
|
|
487
|
+
const config = JSON.stringify({ port: 3000 }, null, 2);
|
|
488
|
+
const newConfig = await ui.openInEditor(config, '.json');
|
|
489
|
+
|
|
490
|
+
// Edit markdown content
|
|
491
|
+
const markdown = '# Title\n\nContent here...';
|
|
492
|
+
const editedMarkdown = await ui.openInEditor(markdown, '.md');
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
**asciiArt**
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
// Create a banner
|
|
501
|
+
const banner = ui.asciiArt('WELCOME', 'Big');
|
|
502
|
+
console.log(banner);
|
|
503
|
+
|
|
504
|
+
// Different fonts for different purposes
|
|
505
|
+
const title = ui.asciiArt('MyApp', 'Standard');
|
|
506
|
+
const subtitle = ui.asciiArt('v2.0', 'Small');
|
|
507
|
+
|
|
508
|
+
// Technical/coding themes
|
|
509
|
+
const code = ui.asciiArt('CODE', '3D-ASCII');
|
|
510
|
+
|
|
511
|
+
// List available fonts first
|
|
512
|
+
console.log('Available fonts:', ui.fonts.slice(0, 10).join(', '));
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
**banner**
|
|
518
|
+
|
|
519
|
+
```ts
|
|
520
|
+
// Classic patriotic banner
|
|
521
|
+
const banner = ui.banner('AMERICA', {
|
|
522
|
+
font: 'Big',
|
|
523
|
+
colors: ['red', 'white', 'blue']
|
|
524
|
+
});
|
|
525
|
+
console.log(banner);
|
|
526
|
+
|
|
527
|
+
// Tech company banner
|
|
528
|
+
const techBanner = ui.banner('TechCorp', {
|
|
529
|
+
font: 'Slant',
|
|
530
|
+
colors: ['cyan', 'blue', 'magenta']
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// Warning banner
|
|
534
|
+
const warningBanner = ui.banner('WARNING', {
|
|
535
|
+
font: 'Standard',
|
|
536
|
+
colors: ['yellow', 'red']
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
// Available fonts: see ui.fonts property
|
|
540
|
+
// Available colors: any chalk color names
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
**applyGradient**
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
// Horizontal rainbow effect
|
|
549
|
+
const rainbow = ui.applyGradient('Hello World!',
|
|
550
|
+
['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
|
|
551
|
+
'horizontal'
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
// Vertical gradient for multi-line text
|
|
555
|
+
const multiline = 'Line 1\nLine 2\nLine 3\nLine 4';
|
|
556
|
+
const vertical = ui.applyGradient(multiline,
|
|
557
|
+
['red', 'white', 'blue'],
|
|
558
|
+
'vertical'
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
// Fire effect
|
|
562
|
+
const fire = ui.applyGradient('FIRE', ['red', 'yellow'], 'horizontal');
|
|
563
|
+
|
|
564
|
+
// Ocean effect
|
|
565
|
+
const ocean = ui.applyGradient('OCEAN', ['blue', 'cyan', 'white'], 'vertical');
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
**applyHorizontalGradient**
|
|
571
|
+
|
|
572
|
+
```ts
|
|
573
|
+
// Rainbow effect across characters
|
|
574
|
+
const rainbow = ui.applyHorizontalGradient('RAINBOW',
|
|
575
|
+
['red', 'yellow', 'green', 'cyan', 'blue', 'magenta']
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
// Simple two-color transition
|
|
579
|
+
const sunset = ui.applyHorizontalGradient('SUNSET', ['red', 'orange']);
|
|
580
|
+
|
|
581
|
+
// Great for short text and ASCII art
|
|
582
|
+
const art = ui.asciiArt('COOL', 'Big');
|
|
583
|
+
const coloredArt = ui.applyHorizontalGradient(art, ['cyan', 'blue']);
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
**applyVerticalGradient**
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
// Patriotic vertical gradient
|
|
592
|
+
const flag = 'USA\nUSA\nUSA\nUSA';
|
|
593
|
+
const patriotic = ui.applyVerticalGradient(flag, ['red', 'white', 'blue']);
|
|
594
|
+
|
|
595
|
+
// Sunset effect on ASCII art
|
|
596
|
+
const banner = ui.asciiArt('SUNSET', 'Big');
|
|
597
|
+
const sunset = ui.applyVerticalGradient(banner,
|
|
598
|
+
['yellow', 'orange', 'red', 'purple']
|
|
599
|
+
);
|
|
600
|
+
|
|
601
|
+
// Ocean waves effect
|
|
602
|
+
const waves = 'Wave 1\nWave 2\nWave 3\nWave 4\nWave 5';
|
|
603
|
+
const ocean = ui.applyVerticalGradient(waves, ['cyan', 'blue']);
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
**padLeft**
|
|
609
|
+
|
|
610
|
+
```ts
|
|
611
|
+
// Number alignment
|
|
612
|
+
const numbers = ['1', '23', '456'];
|
|
613
|
+
numbers.forEach(num => {
|
|
614
|
+
console.log(ui.padLeft(num, 5, '0')); // '00001', '00023', '00456'
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
// Text alignment in columns
|
|
618
|
+
const items = ['apple', 'banana', 'cherry'];
|
|
619
|
+
items.forEach(item => {
|
|
620
|
+
console.log(ui.padLeft(item, 10) + ' | Price: $1.00');
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// Custom padding character
|
|
624
|
+
const title = ui.padLeft('TITLE', 20, '-'); // '---------------TITLE'
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
**padRight**
|
|
630
|
+
|
|
631
|
+
```ts
|
|
632
|
+
// Create aligned table columns
|
|
633
|
+
const data = [
|
|
634
|
+
['Name', 'Age', 'City'],
|
|
635
|
+
['John', '25', 'NYC'],
|
|
636
|
+
['Jane', '30', 'LA'],
|
|
637
|
+
['Bob', '35', 'Chicago']
|
|
638
|
+
];
|
|
639
|
+
|
|
640
|
+
data.forEach(row => {
|
|
641
|
+
const formatted = row.map((cell, i) => {
|
|
642
|
+
const widths = [15, 5, 10];
|
|
643
|
+
return ui.padRight(cell, widths[i]);
|
|
644
|
+
}).join(' | ');
|
|
645
|
+
console.log(formatted);
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// Progress bars
|
|
649
|
+
const progress = ui.padRight('████', 20, '░'); // '████░░░░░░░░░░░░░░░░'
|
|
650
|
+
|
|
651
|
+
// Menu items with dots
|
|
652
|
+
const menuItem = ui.padRight('Coffee', 20, '.') + '$3.50';
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
**colors**
|
|
658
|
+
|
|
659
|
+
```ts
|
|
660
|
+
// Basic colors
|
|
661
|
+
ui.colors.red('Error message')
|
|
662
|
+
ui.colors.green('Success!')
|
|
663
|
+
|
|
664
|
+
// Chained styling
|
|
665
|
+
ui.colors.blue.bold.underline('Important link')
|
|
666
|
+
ui.colors.white.bgRed.bold(' ALERT ')
|
|
667
|
+
|
|
668
|
+
// Hex and RGB colors
|
|
669
|
+
ui.colors.hex('#FF5733')('Custom color')
|
|
670
|
+
ui.colors.rgb(255, 87, 51)('RGB color')
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
**randomColor**
|
|
676
|
+
|
|
677
|
+
```ts
|
|
678
|
+
const randomColor = ui.randomColor;
|
|
679
|
+
console.log(ui.colors[randomColor]('This text is a random color!'));
|
|
680
|
+
|
|
681
|
+
// Use in loops for varied output
|
|
682
|
+
items.forEach(item => {
|
|
683
|
+
const color = ui.randomColor;
|
|
684
|
+
console.log(ui.colors[color](`- ${item}`));
|
|
685
|
+
});
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
**fonts**
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
// List all available fonts
|
|
694
|
+
const fonts = ui.fonts;
|
|
695
|
+
console.log(`Available fonts: ${fonts.join(', ')}`);
|
|
696
|
+
|
|
697
|
+
// Use random font for variety
|
|
698
|
+
const randomFont = fonts[Math.floor(Math.random() * fonts.length)];
|
|
699
|
+
const art = ui.asciiArt('Hello', randomFont);
|
|
700
|
+
|
|
701
|
+
// Common fonts: 'Big', 'Standard', 'Small', 'Slant', '3D-ASCII'
|
|
702
|
+
```
|
|
703
|
+
|