auramaxx 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +77 -0
- package/apps/desktop-electron/main.js +428 -0
- package/bin/auramaxx.js +1063 -0
- package/docs/ADAPTERS.md +466 -0
- package/docs/AGENT_SETUP.md +159 -0
- package/docs/API.md +127 -0
- package/docs/APPS.md +199 -0
- package/docs/ARCHITECTURE.md +235 -0
- package/docs/AUTH.md +318 -0
- package/docs/BEST-PRACTICES.md +82 -0
- package/docs/CLI.md +141 -0
- package/docs/DESKTOP_ELECTRON.md +26 -0
- package/docs/DEVELOPING-APPS.md +453 -0
- package/docs/MCP.md +122 -0
- package/docs/PACKAGING_POLICY.md +19 -0
- package/docs/PERMISSION.md +137 -0
- package/docs/PROTOCOL.md +142 -0
- package/docs/README.md +50 -0
- package/docs/SKILLS.md +132 -0
- package/docs/TROUBLESHOOTING.md +376 -0
- package/docs/WORKSPACE.md +673 -0
- package/docs/agent-auth.md +14 -0
- package/docs/api/authentication.md +79 -0
- package/docs/api/secrets/api-keys.md +28 -0
- package/docs/api/secrets/credentials.md +80 -0
- package/docs/api/secrets/sharing.md +48 -0
- package/docs/api/system.md +41 -0
- package/docs/api/wallets/apps-strategies.md +66 -0
- package/docs/api/wallets/core.md +46 -0
- package/docs/api/wallets/data-portfolio.md +42 -0
- package/docs/aura-file.md +48 -0
- package/docs/core-concepts/FEATURES.md +114 -0
- package/docs/credentials.md +120 -0
- package/docs/external/HOW_TO_AURAMAXX/GETTING_SECRETS.md +33 -0
- package/docs/external/HOW_TO_AURAMAXX/README.md +45 -0
- package/docs/external/getting-started.md +10 -0
- package/docs/external/overview.md +19 -0
- package/docs/external/persona-paths.md +7 -0
- package/docs/external/share-secret.md +76 -0
- package/docs/external/why-aura.md +7 -0
- package/docs/security.md +227 -0
- package/docs/templates/RELEASE_NOTES_TEMPLATE.md +22 -0
- package/docs/wallet/AI.md +508 -0
- package/docs/wallet/DEVELOPING-STRATEGIES.md +713 -0
- package/docs/wallet/README.md +47 -0
- package/docs/wallet/STRATEGY.md +89 -0
- package/next.config.ts +28 -0
- package/package.json +167 -0
- package/postcss.config.mjs +8 -0
- package/prisma/migrations/20260214170000_baseline/migration.sql +511 -0
- package/prisma/migrations/20260216214537_add_passkey_model/migration.sql +18 -0
- package/prisma/migrations/20260217150500_add_credential_access_audit/migration.sql +31 -0
- package/prisma/migrations/20260222090000_update_admin_ttl_default/migration.sql +10 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +447 -0
- package/public/logo.webp +0 -0
- package/scripts/add-app.js +245 -0
- package/server/abi/SwapHelper.json +438 -0
- package/server/cli/approval.ts +447 -0
- package/server/cli/commands/actions.ts +474 -0
- package/server/cli/commands/api.ts +220 -0
- package/server/cli/commands/apikey.ts +277 -0
- package/server/cli/commands/app.ts +204 -0
- package/server/cli/commands/auth.ts +464 -0
- package/server/cli/commands/cron.ts +24 -0
- package/server/cli/commands/diary.ts +274 -0
- package/server/cli/commands/doctor.ts +1247 -0
- package/server/cli/commands/env.ts +476 -0
- package/server/cli/commands/experimental.ts +69 -0
- package/server/cli/commands/init.ts +798 -0
- package/server/cli/commands/lock.ts +157 -0
- package/server/cli/commands/mcp.ts +285 -0
- package/server/cli/commands/quickhack.ts +86 -0
- package/server/cli/commands/release-check.ts +231 -0
- package/server/cli/commands/restore.ts +314 -0
- package/server/cli/commands/service.ts +320 -0
- package/server/cli/commands/shell-hook.ts +512 -0
- package/server/cli/commands/skill.ts +216 -0
- package/server/cli/commands/start.ts +139 -0
- package/server/cli/commands/status.ts +59 -0
- package/server/cli/commands/stop.ts +36 -0
- package/server/cli/commands/token.ts +180 -0
- package/server/cli/commands/unlock.ts +50 -0
- package/server/cli/commands/vault.ts +1323 -0
- package/server/cli/commands/wallet.ts +209 -0
- package/server/cli/index.ts +280 -0
- package/server/cli/lib/approval-poll.ts +94 -0
- package/server/cli/lib/aura-parser.ts +64 -0
- package/server/cli/lib/credential-create.ts +74 -0
- package/server/cli/lib/credential-resolve.ts +280 -0
- package/server/cli/lib/dotenv-migrate.ts +116 -0
- package/server/cli/lib/dotenv-parser.ts +146 -0
- package/server/cli/lib/escalation.ts +57 -0
- package/server/cli/lib/http.ts +91 -0
- package/server/cli/lib/init-steps.ts +76 -0
- package/server/cli/lib/local-agent-trust.ts +45 -0
- package/server/cli/lib/lock-unlock-helper.ts +71 -0
- package/server/cli/lib/process.ts +162 -0
- package/server/cli/lib/prompt.ts +294 -0
- package/server/cli/lib/theme.ts +240 -0
- package/server/cli/socket.ts +579 -0
- package/server/cli/transport-client.ts +50 -0
- package/server/cron/index.ts +137 -0
- package/server/cron/job.ts +31 -0
- package/server/cron/jobs/balance-sync.ts +436 -0
- package/server/cron/jobs/incoming-scan.ts +506 -0
- package/server/cron/jobs/native-price.ts +70 -0
- package/server/cron/jobs/orphan-cleanup.ts +40 -0
- package/server/cron/jobs/strategy-runner.ts +175 -0
- package/server/cron/scheduler.ts +125 -0
- package/server/index.ts +420 -0
- package/server/lib/adapters/factory.ts +119 -0
- package/server/lib/adapters/index.ts +19 -0
- package/server/lib/adapters/router.ts +297 -0
- package/server/lib/adapters/telegram.ts +645 -0
- package/server/lib/adapters/types.ts +89 -0
- package/server/lib/adapters/webhook.ts +95 -0
- package/server/lib/address.ts +49 -0
- package/server/lib/agent-auth/contracts.ts +1194 -0
- package/server/lib/agent-profiles.ts +419 -0
- package/server/lib/ai.ts +285 -0
- package/server/lib/api-registry/contracts.ts +86 -0
- package/server/lib/api-registry/validation.ts +172 -0
- package/server/lib/apikey-migration.ts +258 -0
- package/server/lib/app-installer.ts +505 -0
- package/server/lib/app-tokens.ts +247 -0
- package/server/lib/approval-link.ts +27 -0
- package/server/lib/auth.ts +314 -0
- package/server/lib/auto-execute.ts +160 -0
- package/server/lib/batch.ts +242 -0
- package/server/lib/cold.ts +1048 -0
- package/server/lib/config.ts +408 -0
- package/server/lib/credential-access-audit.ts +85 -0
- package/server/lib/credential-access-policy.ts +111 -0
- package/server/lib/credential-health.ts +343 -0
- package/server/lib/credential-import.ts +608 -0
- package/server/lib/credential-scope.ts +102 -0
- package/server/lib/credential-shares.ts +190 -0
- package/server/lib/credential-transport.ts +533 -0
- package/server/lib/credential-vault.ts +77 -0
- package/server/lib/credentials.ts +422 -0
- package/server/lib/crypto.ts +8 -0
- package/server/lib/db.ts +58 -0
- package/server/lib/defaults.ts +386 -0
- package/server/lib/dex/index.ts +80 -0
- package/server/lib/dex/relay.ts +235 -0
- package/server/lib/dex/types.ts +59 -0
- package/server/lib/dex/uniswap.ts +370 -0
- package/server/lib/diary.ts +34 -0
- package/server/lib/dont-ask-again-policy.ts +41 -0
- package/server/lib/e2e-agent/artifacts.ts +36 -0
- package/server/lib/e2e-agent/contracts.ts +112 -0
- package/server/lib/e2e-agent/validation.ts +135 -0
- package/server/lib/encrypt.ts +114 -0
- package/server/lib/error.ts +20 -0
- package/server/lib/events.ts +217 -0
- package/server/lib/feature-flags.ts +93 -0
- package/server/lib/hot.ts +357 -0
- package/server/lib/human-action-summary.ts +80 -0
- package/server/lib/key-fingerprint.ts +28 -0
- package/server/lib/logger.ts +340 -0
- package/server/lib/network.ts +137 -0
- package/server/lib/notifications.ts +230 -0
- package/server/lib/oauth2-refresh.ts +241 -0
- package/server/lib/oursecret.ts +71 -0
- package/server/lib/passkey-credential.ts +360 -0
- package/server/lib/passkey.ts +68 -0
- package/server/lib/permissions.ts +299 -0
- package/server/lib/pino.ts +24 -0
- package/server/lib/policy-preview.ts +138 -0
- package/server/lib/price.ts +338 -0
- package/server/lib/prices.ts +34 -0
- package/server/lib/project-scope.ts +297 -0
- package/server/lib/resolve-action.ts +328 -0
- package/server/lib/resolve.ts +36 -0
- package/server/lib/secret-gist-share.ts +296 -0
- package/server/lib/sessions.ts +634 -0
- package/server/lib/socket-path.ts +56 -0
- package/server/lib/solana/connection.ts +26 -0
- package/server/lib/solana/jupiter.ts +128 -0
- package/server/lib/solana/transfer.ts +108 -0
- package/server/lib/solana/wallet.ts +136 -0
- package/server/lib/strategy/emits.ts +21 -0
- package/server/lib/strategy/engine.ts +1305 -0
- package/server/lib/strategy/executor.ts +115 -0
- package/server/lib/strategy/hook-context.ts +159 -0
- package/server/lib/strategy/hooks.ts +990 -0
- package/server/lib/strategy/index.ts +28 -0
- package/server/lib/strategy/installer.ts +305 -0
- package/server/lib/strategy/loader.ts +256 -0
- package/server/lib/strategy/message.ts +237 -0
- package/server/lib/strategy/repository.ts +218 -0
- package/server/lib/strategy/session-logger.ts +693 -0
- package/server/lib/strategy/sources.ts +288 -0
- package/server/lib/strategy/state.ts +189 -0
- package/server/lib/strategy/templates.ts +403 -0
- package/server/lib/strategy/tick.ts +404 -0
- package/server/lib/strategy/types.ts +230 -0
- package/server/lib/swap.ts +3 -0
- package/server/lib/temp.ts +86 -0
- package/server/lib/token-metadata.ts +86 -0
- package/server/lib/token-safety.ts +200 -0
- package/server/lib/token-search.ts +444 -0
- package/server/lib/totp.ts +194 -0
- package/server/lib/transactions.ts +123 -0
- package/server/lib/transport.ts +84 -0
- package/server/lib/txhistory/decoder.ts +262 -0
- package/server/lib/txhistory/enricher.ts +652 -0
- package/server/lib/txhistory/index.ts +391 -0
- package/server/lib/txhistory/signatures.ts +59 -0
- package/server/lib/update-check.ts +35 -0
- package/server/lib/verified-summary.ts +414 -0
- package/server/lib/view-registry.ts +80 -0
- package/server/mcp/profile-policy.ts +30 -0
- package/server/mcp/server.ts +1589 -0
- package/server/mcp/tools.ts +276 -0
- package/server/middleware/auth.ts +119 -0
- package/server/middleware/requestLogger.ts +84 -0
- package/server/routes/actions.ts +539 -0
- package/server/routes/adapters.ts +711 -0
- package/server/routes/addressbook.ts +113 -0
- package/server/routes/ai.ts +34 -0
- package/server/routes/apikeys.ts +343 -0
- package/server/routes/apps.ts +601 -0
- package/server/routes/auth.ts +406 -0
- package/server/routes/backup.ts +404 -0
- package/server/routes/batch.ts +270 -0
- package/server/routes/bookmarks.ts +162 -0
- package/server/routes/credential-shares.ts +380 -0
- package/server/routes/credential-vaults.ts +159 -0
- package/server/routes/credentials.ts +1782 -0
- package/server/routes/dashboard.ts +97 -0
- package/server/routes/defaults.ts +124 -0
- package/server/routes/flags.ts +11 -0
- package/server/routes/fund.ts +225 -0
- package/server/routes/heartbeat.ts +375 -0
- package/server/routes/import.ts +364 -0
- package/server/routes/launch.ts +665 -0
- package/server/routes/lock.ts +54 -0
- package/server/routes/logs.ts +68 -0
- package/server/routes/nuke.ts +111 -0
- package/server/routes/passkey-credentials.ts +99 -0
- package/server/routes/passkey.ts +366 -0
- package/server/routes/portfolio.ts +217 -0
- package/server/routes/price.ts +63 -0
- package/server/routes/resolve.ts +31 -0
- package/server/routes/security.ts +45 -0
- package/server/routes/send-evm.ts +241 -0
- package/server/routes/send-solana.ts +281 -0
- package/server/routes/send.ts +178 -0
- package/server/routes/setup.ts +210 -0
- package/server/routes/strategy.ts +894 -0
- package/server/routes/swap-evm.ts +352 -0
- package/server/routes/swap-solana.ts +176 -0
- package/server/routes/swap.ts +356 -0
- package/server/routes/token.ts +247 -0
- package/server/routes/unlock.ts +467 -0
- package/server/routes/views.ts +41 -0
- package/server/routes/wallet-assets.ts +361 -0
- package/server/routes/wallet-transactions.ts +515 -0
- package/server/routes/wallet.ts +709 -0
- package/server/types.ts +146 -0
- package/shared/credential-field-schema.ts +248 -0
- package/skills/auramaxx/HEARTBEAT.md +78 -0
- package/skills/auramaxx/SKILL.md +745 -0
- package/skills/auramaxx/docs/AGENT_SETUP.md +155 -0
- package/skills/auramaxx/docs/API.md +127 -0
- package/skills/auramaxx/docs/AUTH.md +318 -0
- package/skills/auramaxx/docs/CLI.md +130 -0
- package/skills/auramaxx/docs/MCP.md +122 -0
- package/skills/auramaxx/docs/TROUBLESHOOTING.md +357 -0
- package/skills/auramaxx/docs/WORKSPACE.md +673 -0
- package/skills/auramaxx/docs/security.md +227 -0
- package/skills/task-lifecycle/SKILL.md +378 -0
- package/src/app/api/[...doc]/page.tsx +36 -0
- package/src/app/api/agent-requests/route.ts +30 -0
- package/src/app/api/apps/install/route.ts +132 -0
- package/src/app/api/apps/manifests/route.ts +16 -0
- package/src/app/api/apps/static/[...path]/route.ts +57 -0
- package/src/app/api/docs/plain/route.ts +74 -0
- package/src/app/api/events/route.ts +92 -0
- package/src/app/api/page.tsx +290 -0
- package/src/app/api/workspace/[id]/apps/[wid]/route.ts +119 -0
- package/src/app/api/workspace/[id]/apps/route.ts +81 -0
- package/src/app/api/workspace/[id]/export/route.ts +67 -0
- package/src/app/api/workspace/[id]/route.ts +168 -0
- package/src/app/api/workspace/auth.ts +40 -0
- package/src/app/api/workspace/config/route.ts +121 -0
- package/src/app/api/workspace/import/route.ts +127 -0
- package/src/app/api/workspace/route.ts +116 -0
- package/src/app/app-legacy-do-not-use/page.tsx +2245 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/approve/[actionId]/page.tsx +409 -0
- package/src/app/docs/DocsPageContent.tsx +269 -0
- package/src/app/docs/[...doc]/page.tsx +41 -0
- package/src/app/docs/page.tsx +38 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +819 -0
- package/src/app/health/page.tsx +5 -0
- package/src/app/hello/page.tsx +102 -0
- package/src/app/icon.png +0 -0
- package/src/app/layout.tsx +39 -0
- package/src/app/page.tsx +1964 -0
- package/src/app/privacy/page.tsx +63 -0
- package/src/app/providers.tsx +87 -0
- package/src/app/share/[token]/page.tsx +295 -0
- package/src/app/terms/page.tsx +80 -0
- package/src/components/ChainSelector.tsx +44 -0
- package/src/components/HumanActionBar.tsx +697 -0
- package/src/components/NotificationDrawer.tsx +387 -0
- package/src/components/PasskeyEnrollmentPrompt.tsx +235 -0
- package/src/components/apps/AgentKeysApp.tsx +490 -0
- package/src/components/apps/App.tsx +153 -0
- package/src/components/apps/AppGrid.tsx +15 -0
- package/src/components/apps/DetailedAddressDrawer.tsx +325 -0
- package/src/components/apps/DraggableApp.tsx +562 -0
- package/src/components/apps/IFrameApp.tsx +73 -0
- package/src/components/apps/LogsApp.tsx +360 -0
- package/src/components/apps/SendApp.tsx +394 -0
- package/src/components/apps/SetupWizardApp.tsx +1004 -0
- package/src/components/apps/SystemDefaultsApp.tsx +845 -0
- package/src/components/apps/ThirdPartyApp.tsx +428 -0
- package/src/components/apps/TokenApp.tsx +319 -0
- package/src/components/apps/TransactionsApp.tsx +438 -0
- package/src/components/apps/WalletDetailApp.tsx +1505 -0
- package/src/components/apps/index.ts +13 -0
- package/src/components/design-system/Button.tsx +88 -0
- package/src/components/design-system/ChainIndicator.tsx +65 -0
- package/src/components/design-system/ChainSelector.tsx +147 -0
- package/src/components/design-system/ConfirmationModal.tsx +107 -0
- package/src/components/design-system/ConfirmationPopover.tsx +81 -0
- package/src/components/design-system/DownloadButton.tsx +149 -0
- package/src/components/design-system/Drawer.tsx +133 -0
- package/src/components/design-system/FilterDropdown.tsx +183 -0
- package/src/components/design-system/ItemPicker.tsx +157 -0
- package/src/components/design-system/Modal.tsx +296 -0
- package/src/components/design-system/Popover.tsx +142 -0
- package/src/components/design-system/TextInput.tsx +85 -0
- package/src/components/design-system/Toggle.tsx +65 -0
- package/src/components/design-system/TyvekCollapsibleSection.tsx +55 -0
- package/src/components/design-system/index.ts +14 -0
- package/src/components/docs/ClientSideMarkdown.tsx +51 -0
- package/src/components/docs/DocsSearchBar.tsx +118 -0
- package/src/components/docs/DocsThemeToggle.tsx +38 -0
- package/src/components/docs/PersistentDocGroup.tsx +91 -0
- package/src/components/docs/ShareUrlButton.tsx +33 -0
- package/src/components/docs/SidebarScrollMemory.tsx +56 -0
- package/src/components/health/CredentialHealthDashboard.tsx +214 -0
- package/src/components/icons/ChainIcons.tsx +72 -0
- package/src/components/layout/AppStoreDrawer.tsx +369 -0
- package/src/components/layout/ContentArea.tsx +21 -0
- package/src/components/layout/CreateViewModal.tsx +88 -0
- package/src/components/layout/LeftRail.tsx +114 -0
- package/src/components/layout/TabBar.tsx +284 -0
- package/src/components/layout/WalletSidebar.tsx +1030 -0
- package/src/components/layout/index.ts +6 -0
- package/src/components/marketing/AuraMaxxSpecOverlay.tsx +653 -0
- package/src/components/marketing/DeviceMorphExperience.tsx +216 -0
- package/src/components/vault/ApiKeysConsole.tsx +1272 -0
- package/src/components/vault/AuditConsole.tsx +600 -0
- package/src/components/vault/CredentialDetail.tsx +625 -0
- package/src/components/vault/CredentialEmpty.tsx +55 -0
- package/src/components/vault/CredentialField.tsx +583 -0
- package/src/components/vault/CredentialForm.tsx +1484 -0
- package/src/components/vault/CredentialList.tsx +265 -0
- package/src/components/vault/CredentialRow.tsx +130 -0
- package/src/components/vault/CredentialShareModal.tsx +273 -0
- package/src/components/vault/CredentialVault.tsx +1662 -0
- package/src/components/vault/CredentialWalletWidget.tsx +103 -0
- package/src/components/vault/DocsConsole.tsx +113 -0
- package/src/components/vault/ImportCredentialsModal.tsx +578 -0
- package/src/components/vault/LargeTypeModal.tsx +88 -0
- package/src/components/vault/PasswordGenerator.tsx +232 -0
- package/src/components/vault/TOTPDisplay.tsx +108 -0
- package/src/components/vault/TotpSetupPanel.tsx +198 -0
- package/src/components/vault/VaultSidebar.tsx +881 -0
- package/src/components/vault/credentialFormName.ts +91 -0
- package/src/components/vault/hooks/useVaultKeyboardShortcuts.ts +69 -0
- package/src/components/vault/types.ts +56 -0
- package/src/context/AuthContext.tsx +365 -0
- package/src/context/PriceContext.tsx +113 -0
- package/src/context/ThemeContext.tsx +164 -0
- package/src/context/WebSocketContext.tsx +269 -0
- package/src/context/WorkspaceContext.tsx +668 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAgentActions.ts +552 -0
- package/src/hooks/useBalance.ts +103 -0
- package/src/hooks/useBalances.ts +129 -0
- package/src/hooks/useTheme.ts +156 -0
- package/src/instrumentation.ts +12 -0
- package/src/lib/api-docs.ts +154 -0
- package/src/lib/api.ts +474 -0
- package/src/lib/app-loader.ts +148 -0
- package/src/lib/app-registry.ts +178 -0
- package/src/lib/app-sdk.ts +157 -0
- package/src/lib/audit-console-adapter.ts +151 -0
- package/src/lib/auth-client.ts +75 -0
- package/src/lib/config.ts +74 -0
- package/src/lib/credential-field-schema.ts +11 -0
- package/src/lib/crypto.ts +112 -0
- package/src/lib/db.ts +21 -0
- package/src/lib/docs.ts +544 -0
- package/src/lib/events.ts +363 -0
- package/src/lib/pino.ts +24 -0
- package/src/lib/theme-handlers.ts +168 -0
- package/src/lib/theme.ts +351 -0
- package/src/lib/tokenData.ts +378 -0
- package/src/lib/totp-import.ts +57 -0
- package/src/lib/vault-crypto.ts +129 -0
- package/src/lib/view-registry.ts +57 -0
- package/src/lib/websocket-server.ts +302 -0
- package/src/lib/websocket-setup.ts +79 -0
- package/src/lib/wordlist.ts +2050 -0
- package/src/lib/workspace-handlers.ts +285 -0
- package/start.sh +170 -0
- package/tailwind.config.ts +99 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive prompts for CLI commands
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as readline from 'readline';
|
|
6
|
+
import { paint, ANSI } from './theme';
|
|
7
|
+
|
|
8
|
+
export interface PromptSelectOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
aliases?: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function resolveSelectedValue(answer: string, options: PromptSelectOption[], defaultValue?: string): string {
|
|
15
|
+
const normalized = answer.trim().toLowerCase();
|
|
16
|
+
if (!normalized && defaultValue) return defaultValue;
|
|
17
|
+
|
|
18
|
+
for (const opt of options) {
|
|
19
|
+
const candidates = [opt.value, opt.label, ...(opt.aliases || [])].map((v) => v.toLowerCase());
|
|
20
|
+
if (candidates.includes(normalized)) return opt.value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return defaultValue || options[0].value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function renderSelectLines(
|
|
27
|
+
message: string,
|
|
28
|
+
options: PromptSelectOption[],
|
|
29
|
+
selectedIndex: number,
|
|
30
|
+
defaultValue?: string,
|
|
31
|
+
): string[] {
|
|
32
|
+
const lines = [
|
|
33
|
+
message,
|
|
34
|
+
paint(' Use up/down arrows and Enter to confirm.', ANSI.dim),
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < options.length; i += 1) {
|
|
38
|
+
const option = options[i];
|
|
39
|
+
const isDefault = defaultValue && option.value === defaultValue;
|
|
40
|
+
const suffix = isDefault ? ' [default]' : '';
|
|
41
|
+
if (i === selectedIndex) {
|
|
42
|
+
lines.push(` ${paint('//', ANSI.fgAccent, ANSI.bold)} ${paint(option.label + suffix, ANSI.bold)}`);
|
|
43
|
+
} else {
|
|
44
|
+
lines.push(` ${paint(option.label + suffix, ANSI.dim)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return lines;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function promptSelectInteractive(
|
|
52
|
+
message: string,
|
|
53
|
+
options: PromptSelectOption[],
|
|
54
|
+
defaultValue?: string,
|
|
55
|
+
): Promise<string> {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const stdin = process.stdin;
|
|
58
|
+
const stdout = process.stdout;
|
|
59
|
+
const typedStdin = stdin as NodeJS.ReadStream & { isRaw?: boolean };
|
|
60
|
+
|
|
61
|
+
const defaultIndex = Math.max(
|
|
62
|
+
0,
|
|
63
|
+
options.findIndex((opt) => opt.value === defaultValue),
|
|
64
|
+
);
|
|
65
|
+
let selectedIndex = defaultIndex;
|
|
66
|
+
let renderedLines = 0;
|
|
67
|
+
let settled = false;
|
|
68
|
+
const wasRaw = typedStdin.isRaw ?? false;
|
|
69
|
+
const wasPaused = stdin.isPaused();
|
|
70
|
+
|
|
71
|
+
const cleanup = () => {
|
|
72
|
+
if (settled) return;
|
|
73
|
+
settled = true;
|
|
74
|
+
stdin.removeListener('data', onData);
|
|
75
|
+
stdin.removeListener('error', onError);
|
|
76
|
+
if (stdin.isTTY && typeof stdin.setRawMode === 'function') {
|
|
77
|
+
stdin.setRawMode(wasRaw);
|
|
78
|
+
}
|
|
79
|
+
if (wasPaused) {
|
|
80
|
+
stdin.pause();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const render = () => {
|
|
85
|
+
const lines = renderSelectLines(message, options, selectedIndex, defaultValue);
|
|
86
|
+
if (renderedLines > 0) {
|
|
87
|
+
stdout.write(`\u001b[${renderedLines}A`);
|
|
88
|
+
}
|
|
89
|
+
for (const line of lines) {
|
|
90
|
+
stdout.write('\u001b[2K');
|
|
91
|
+
stdout.write(`${line}\n`);
|
|
92
|
+
}
|
|
93
|
+
renderedLines = lines.length;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const moveSelection = (delta: number) => {
|
|
97
|
+
if (delta === 0) return;
|
|
98
|
+
selectedIndex = (selectedIndex + delta + options.length) % options.length;
|
|
99
|
+
render();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const onError = (error: Error) => {
|
|
103
|
+
cleanup();
|
|
104
|
+
reject(error);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const onData = (chunk: Buffer | string) => {
|
|
108
|
+
const input = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
109
|
+
let delta = 0;
|
|
110
|
+
|
|
111
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
112
|
+
const c = input[i];
|
|
113
|
+
if (c === '\u0003') {
|
|
114
|
+
cleanup();
|
|
115
|
+
stdout.write('\n');
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
if (c === '\r' || c === '\n') {
|
|
119
|
+
cleanup();
|
|
120
|
+
stdout.write('\n');
|
|
121
|
+
resolve(options[selectedIndex].value);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (input.startsWith('\u001b[A', i)) {
|
|
125
|
+
delta -= 1;
|
|
126
|
+
i += 2;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (input.startsWith('\u001b[B', i)) {
|
|
130
|
+
delta += 1;
|
|
131
|
+
i += 2;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (delta !== 0) {
|
|
137
|
+
moveSelection(delta);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
if (stdin.isTTY && typeof stdin.setRawMode === 'function') {
|
|
143
|
+
stdin.setRawMode(true);
|
|
144
|
+
}
|
|
145
|
+
stdin.resume();
|
|
146
|
+
stdin.on('data', onData);
|
|
147
|
+
stdin.on('error', onError);
|
|
148
|
+
render();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
onError(error as Error);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Prompt for a password with hidden input
|
|
157
|
+
*/
|
|
158
|
+
export async function promptPassword(label: string = 'Password'): Promise<string> {
|
|
159
|
+
if (!process.stdin.isTTY) {
|
|
160
|
+
throw new Error('Interactive password prompt requires a TTY. Use --password-stdin for automation.');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
const stdin = process.stdin;
|
|
165
|
+
const stdout = process.stdout;
|
|
166
|
+
const wasRaw = stdin.isRaw;
|
|
167
|
+
const wasPaused = stdin.isPaused();
|
|
168
|
+
let settled = false;
|
|
169
|
+
let password = '';
|
|
170
|
+
|
|
171
|
+
stdout.write(`${label}: `);
|
|
172
|
+
|
|
173
|
+
const cleanup = () => {
|
|
174
|
+
if (settled) return;
|
|
175
|
+
settled = true;
|
|
176
|
+
stdin.removeListener('data', onData);
|
|
177
|
+
stdin.removeListener('error', onError);
|
|
178
|
+
if (stdin.isTTY) {
|
|
179
|
+
stdin.setRawMode(wasRaw ?? false);
|
|
180
|
+
}
|
|
181
|
+
if (wasPaused) {
|
|
182
|
+
stdin.pause();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const finish = () => {
|
|
187
|
+
cleanup();
|
|
188
|
+
stdout.write('\n');
|
|
189
|
+
resolve(password);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const abort = () => {
|
|
193
|
+
cleanup();
|
|
194
|
+
stdout.write('\n');
|
|
195
|
+
process.exit(1);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const onError = (error: Error) => {
|
|
199
|
+
cleanup();
|
|
200
|
+
reject(error);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
if (stdin.isTTY) {
|
|
204
|
+
stdin.setRawMode(true);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
stdin.resume();
|
|
208
|
+
|
|
209
|
+
const onData = (chunk: Buffer | string) => {
|
|
210
|
+
const input = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
211
|
+
for (const c of input) {
|
|
212
|
+
if (c === '\r' || c === '\n') {
|
|
213
|
+
finish();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (c === '\u0003') {
|
|
217
|
+
// Ctrl+C
|
|
218
|
+
abort();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (c === '\u007f' || c === '\b') {
|
|
222
|
+
if (password.length > 0) {
|
|
223
|
+
password = password.slice(0, -1);
|
|
224
|
+
}
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
password += c;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
stdin.on('data', onData);
|
|
232
|
+
stdin.on('error', onError);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Prompt for visible text input
|
|
238
|
+
*/
|
|
239
|
+
export async function promptInput(label: string): Promise<string> {
|
|
240
|
+
return new Promise((resolve) => {
|
|
241
|
+
const rl = readline.createInterface({
|
|
242
|
+
input: process.stdin,
|
|
243
|
+
output: process.stdout,
|
|
244
|
+
});
|
|
245
|
+
rl.question(`${label}: `, (answer) => {
|
|
246
|
+
rl.close();
|
|
247
|
+
resolve(answer.trim());
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Prompt user to select from explicit options
|
|
254
|
+
*/
|
|
255
|
+
export async function promptSelect(
|
|
256
|
+
message: string,
|
|
257
|
+
options: PromptSelectOption[],
|
|
258
|
+
defaultValue?: string,
|
|
259
|
+
): Promise<string> {
|
|
260
|
+
if (options.length === 0) throw new Error('promptSelect requires at least one option');
|
|
261
|
+
|
|
262
|
+
if (process.stdin.isTTY && process.stdout.isTTY && typeof process.stdin.setRawMode === 'function') {
|
|
263
|
+
return promptSelectInteractive(message, options, defaultValue);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const optionLine = options
|
|
267
|
+
.map((opt) => (defaultValue && opt.value === defaultValue ? `${opt.label} [default]` : opt.label))
|
|
268
|
+
.join(' | ');
|
|
269
|
+
|
|
270
|
+
const answer = await promptInput(`${message} (${optionLine})`);
|
|
271
|
+
return resolveSelectedValue(answer, options, defaultValue);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Prompt for yes/no confirmation
|
|
276
|
+
*/
|
|
277
|
+
export async function promptConfirm(msg: string): Promise<boolean> {
|
|
278
|
+
const choice = await promptSelect(
|
|
279
|
+
msg,
|
|
280
|
+
[
|
|
281
|
+
{ value: 'yes', label: 'yes', aliases: ['y'] },
|
|
282
|
+
{ value: 'no', label: 'no', aliases: ['n'] },
|
|
283
|
+
],
|
|
284
|
+
'yes',
|
|
285
|
+
);
|
|
286
|
+
return choice === 'yes';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Wait for the user to press Enter
|
|
291
|
+
*/
|
|
292
|
+
export async function waitForEnter(msg: string = 'Press Enter to continue...'): Promise<void> {
|
|
293
|
+
await promptInput(msg);
|
|
294
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aura CLI Theme — Medical / Industrial / Tyvek
|
|
3
|
+
*
|
|
4
|
+
* Shared visual primitives for all CLI commands.
|
|
5
|
+
* Inspired by the AuraMaxx SVG logo system: registration corner marks,
|
|
6
|
+
* three diagonal stripes at 45° (aura_logo.svg), dot micro-textures, monochrome fills.
|
|
7
|
+
*
|
|
8
|
+
* All output degrades safely in non-TTY / NO_COLOR / CI / TERM=dumb.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ── ANSI ─────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
const ANSI = {
|
|
14
|
+
reset: '\x1b[0m',
|
|
15
|
+
bold: '\x1b[1m',
|
|
16
|
+
dim: '\x1b[2m',
|
|
17
|
+
italic: '\x1b[3m',
|
|
18
|
+
fgAccent:'\x1b[38;5;154m',
|
|
19
|
+
fgGreen: '\x1b[32m',
|
|
20
|
+
fgRed: '\x1b[31m',
|
|
21
|
+
fgYellow:'\x1b[33m',
|
|
22
|
+
fgGray: '\x1b[90m',
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export function supportsColor(): boolean {
|
|
26
|
+
if (!process.stdout.isTTY) return false;
|
|
27
|
+
if (process.env.NO_COLOR) return false;
|
|
28
|
+
if (process.env.CI === 'true') return false;
|
|
29
|
+
return process.env.TERM !== 'dumb';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const USE_COLOR = supportsColor();
|
|
33
|
+
|
|
34
|
+
export function paint(text: string, ...codes: string[]): string {
|
|
35
|
+
if (!USE_COLOR) return text;
|
|
36
|
+
return `${codes.join('')}${text}${ANSI.reset}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ── Constants ────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
const W = 62; // content width (fits 80-col with 2-char indent + padding)
|
|
42
|
+
|
|
43
|
+
export const SEPARATOR = ' ' + '- '.repeat(Math.floor(W / 2));
|
|
44
|
+
|
|
45
|
+
const CORNER_TL = paint('.-', ANSI.fgGray);
|
|
46
|
+
const CORNER_TR = paint('-.', ANSI.fgGray);
|
|
47
|
+
const CORNER_BL = paint("'-", ANSI.fgGray);
|
|
48
|
+
const CORNER_BR = paint("-'", ANSI.fgGray);
|
|
49
|
+
|
|
50
|
+
// ── Banner ───────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Print the Aura branded banner.
|
|
54
|
+
*
|
|
55
|
+
* Left side: three diagonal stripes at 45° inside a bordered square —
|
|
56
|
+
* matching the canonical Aura logo (website/public/aura_logo.svg:
|
|
57
|
+
* three rotated rects clipped to a square with corner marks).
|
|
58
|
+
* Right side: AURA wordmark + subtitle.
|
|
59
|
+
* Outer frame: crop-mark corners (from all SVG logos).
|
|
60
|
+
*/
|
|
61
|
+
export function printBanner(subtitle?: string): void {
|
|
62
|
+
const sub = subtitle ? subtitle.toUpperCase() : '';
|
|
63
|
+
|
|
64
|
+
const P = paint('|', ANSI.fgGray); // outer pipe
|
|
65
|
+
const LP = paint('|', ANSI.fgGray); // logo pipe
|
|
66
|
+
const S = (t: string) => paint(t, ANSI.bold); // stripe chars
|
|
67
|
+
|
|
68
|
+
// Logo box borders (dashed, matching Tyvek style)
|
|
69
|
+
const LT = paint('.', ANSI.fgGray) + paint('----------', ANSI.dim) + paint('.', ANSI.fgGray);
|
|
70
|
+
const LB = paint("'", ANSI.fgGray) + paint('----------', ANSI.dim) + paint("'", ANSI.fgGray);
|
|
71
|
+
|
|
72
|
+
// Three diagonal stripes inside a 12×5 square (≈ square at 2:1 char ratio)
|
|
73
|
+
// All rows: |\\ \\ \\|
|
|
74
|
+
const r1 = `${LP}${S('\\\\')} ${S('\\\\')} ${S('\\\\')}${LP}`;
|
|
75
|
+
const r2 = `${LP}${S('\\\\')} ${S('\\\\')} ${S('\\\\')}${LP}`;
|
|
76
|
+
const r3 = `${LP}${S('\\\\')} ${S('\\\\')} ${S('\\\\')}${LP}`;
|
|
77
|
+
|
|
78
|
+
console.log('');
|
|
79
|
+
console.log(` ${CORNER_TL}${paint(' '.repeat(W - 4), ANSI.dim)}${CORNER_TR}`);
|
|
80
|
+
console.log(` ${P} ${LT}${' '.repeat(W - 19)}${P}`);
|
|
81
|
+
console.log(` ${P} ${r1} ${paint('A U R A', ANSI.bold)}${' '.repeat(W - 30)}${P}`);
|
|
82
|
+
console.log(` ${P} ${r2} ${paint('M A X X . S H', ANSI.dim)}${' '.repeat(W - 36)}${P}`);
|
|
83
|
+
console.log(` ${P} ${r3} ${sub ? paint(sub, ANSI.fgAccent) : ''}${' '.repeat(Math.max(0, W - 23 - sub.length))}${P}`);
|
|
84
|
+
console.log(` ${P} ${LB}${' '.repeat(W - 19)}${P}`);
|
|
85
|
+
console.log(` ${CORNER_BL}${paint(' '.repeat(W - 4), ANSI.dim)}${CORNER_BR}`);
|
|
86
|
+
console.log('');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ── Section ──────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Print a section header with Tyvek-style framing.
|
|
93
|
+
*
|
|
94
|
+
* Output:
|
|
95
|
+
* - - - - - - - - - - - - - - - - - - -
|
|
96
|
+
* [ SECTION TITLE ]
|
|
97
|
+
* Optional subtitle
|
|
98
|
+
*/
|
|
99
|
+
export function printSection(title: string, subtitle?: string): void {
|
|
100
|
+
console.log('');
|
|
101
|
+
console.log(SEPARATOR);
|
|
102
|
+
console.log(` ${paint(`[ ${title.toUpperCase()} ]`, ANSI.bold)}`);
|
|
103
|
+
if (subtitle) {
|
|
104
|
+
console.log(` ${paint(subtitle, ANSI.dim)}`);
|
|
105
|
+
}
|
|
106
|
+
console.log('');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ── Box ──────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Print a framed box with crop-mark corners.
|
|
113
|
+
* Replaces the old ╔═══╗ double-line Unicode boxes.
|
|
114
|
+
*
|
|
115
|
+
* Output:
|
|
116
|
+
* .- - - - - - - - - - - - - - - - -.
|
|
117
|
+
* | Line 1 |
|
|
118
|
+
* | Line 2 |
|
|
119
|
+
* '- - - - - - - - - - - - - - - - -'
|
|
120
|
+
*/
|
|
121
|
+
export function printBox(lines: string[]): void {
|
|
122
|
+
const inner = W - 4; // account for "| " and " |"
|
|
123
|
+
const dashes = '- '.repeat(Math.floor((W - 2) / 2));
|
|
124
|
+
|
|
125
|
+
console.log(` ${CORNER_TL}${paint(dashes.slice(0, W - 4), ANSI.dim)}${CORNER_TR}`);
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
// Strip ANSI to measure visible length for padding
|
|
128
|
+
const visible = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
129
|
+
const pad = Math.max(0, inner - visible.length);
|
|
130
|
+
console.log(` ${paint('|', ANSI.fgGray)} ${line}${' '.repeat(pad)}${paint('|', ANSI.fgGray)}`);
|
|
131
|
+
}
|
|
132
|
+
console.log(` ${CORNER_BL}${paint(dashes.slice(0, W - 4), ANSI.dim)}${CORNER_BR}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── Status line ──────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Print a key/value status line.
|
|
139
|
+
*
|
|
140
|
+
* Output:
|
|
141
|
+
* Label: value
|
|
142
|
+
* Label: [ok] value
|
|
143
|
+
*/
|
|
144
|
+
export function printStatus(label: string, value: string, ok?: boolean): void {
|
|
145
|
+
const paddedLabel = label.padEnd(16);
|
|
146
|
+
let indicator = '';
|
|
147
|
+
if (ok === true) indicator = paint('[ok]', ANSI.fgGreen) + ' ';
|
|
148
|
+
else if (ok === false) indicator = paint('[--]', ANSI.fgRed) + ' ';
|
|
149
|
+
console.log(` ${paint(paddedLabel, ANSI.dim)}${indicator}${value}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ── Check result (for doctor) ────────────────────────────────
|
|
153
|
+
|
|
154
|
+
export type CheckBadge = 'pass' | 'warn' | 'fail';
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Format a diagnostic check badge in Tyvek style.
|
|
158
|
+
*/
|
|
159
|
+
export function checkBadge(status: CheckBadge): string {
|
|
160
|
+
switch (status) {
|
|
161
|
+
case 'pass': return paint('[PASS]', ANSI.fgGreen, ANSI.bold);
|
|
162
|
+
case 'warn': return paint('[WARN]', ANSI.fgYellow, ANSI.bold);
|
|
163
|
+
case 'fail': return paint('[FAIL]', ANSI.fgRed, ANSI.bold);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ── Completion ───────────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Print a branded completion message.
|
|
171
|
+
*/
|
|
172
|
+
export function printComplete(message: string): void {
|
|
173
|
+
console.log('');
|
|
174
|
+
console.log(SEPARATOR);
|
|
175
|
+
console.log(` ${paint('[ok]', ANSI.fgGreen)} ${paint(message, ANSI.bold)}`);
|
|
176
|
+
console.log('');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ── Seed phrase box (security-critical) ──────────────────────
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Display a seed phrase in a clearly framed box.
|
|
183
|
+
* This is security-critical — readability is paramount.
|
|
184
|
+
*/
|
|
185
|
+
export function printSeedPhrase(mnemonic: string): void {
|
|
186
|
+
const words = mnemonic.split(' ');
|
|
187
|
+
const inner = 46;
|
|
188
|
+
|
|
189
|
+
console.log('');
|
|
190
|
+
console.log(` ${CORNER_TL}${paint('-'.repeat(inner), ANSI.dim)}${CORNER_TR}`);
|
|
191
|
+
console.log(` ${paint('|', ANSI.fgGray)} ${paint('SEED PHRASE', ANSI.bold)}${' '.repeat(inner - 14)}${paint('|', ANSI.fgGray)}`);
|
|
192
|
+
console.log(` ${paint('|', ANSI.fgGray)} ${paint('Write this down. Store it safely.', ANSI.dim)}${' '.repeat(inner - 36)}${paint('|', ANSI.fgGray)}`);
|
|
193
|
+
console.log(` ${paint('|', ANSI.fgGray)}${' '.repeat(inner + 2)}${paint('|', ANSI.fgGray)}`);
|
|
194
|
+
for (let i = 0; i < words.length; i += 4) {
|
|
195
|
+
const line = words.slice(i, i + 4)
|
|
196
|
+
.map((w, j) => `${String(i + j + 1).padStart(2)}. ${w.padEnd(10)}`)
|
|
197
|
+
.join('');
|
|
198
|
+
const pad = Math.max(0, inner - 2 - line.length);
|
|
199
|
+
console.log(` ${paint('|', ANSI.fgGray)} ${line}${' '.repeat(pad)}${paint('|', ANSI.fgGray)}`);
|
|
200
|
+
}
|
|
201
|
+
console.log(` ${paint('|', ANSI.fgGray)}${' '.repeat(inner + 2)}${paint('|', ANSI.fgGray)}`);
|
|
202
|
+
console.log(` ${paint('|', ANSI.fgGray)} ${paint('It cannot be recovered.', ANSI.fgRed)}${' '.repeat(inner - 27)}${paint('|', ANSI.fgGray)}`);
|
|
203
|
+
console.log(` ${CORNER_BL}${paint('-'.repeat(inner), ANSI.dim)}${CORNER_BR}`);
|
|
204
|
+
console.log('');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ── Help formatter ───────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Print a branded help screen.
|
|
211
|
+
*/
|
|
212
|
+
export function printHelp(
|
|
213
|
+
title: string,
|
|
214
|
+
usage: string,
|
|
215
|
+
commands: Array<{ name: string; desc: string }>,
|
|
216
|
+
extras?: string[],
|
|
217
|
+
): void {
|
|
218
|
+
printBanner(title);
|
|
219
|
+
|
|
220
|
+
console.log(` ${paint('Usage:', ANSI.bold)} ${usage}`);
|
|
221
|
+
console.log('');
|
|
222
|
+
|
|
223
|
+
if (commands.length > 0) {
|
|
224
|
+
console.log(` ${paint('Commands:', ANSI.bold)}`);
|
|
225
|
+
const maxName = Math.max(...commands.map(c => c.name.length));
|
|
226
|
+
for (const cmd of commands) {
|
|
227
|
+
console.log(` ${paint(cmd.name.padEnd(maxName + 2), ANSI.fgAccent)}${cmd.desc}`);
|
|
228
|
+
}
|
|
229
|
+
console.log('');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (extras) {
|
|
233
|
+
for (const line of extras) {
|
|
234
|
+
console.log(` ${line}`);
|
|
235
|
+
}
|
|
236
|
+
console.log('');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export { ANSI, USE_COLOR, W };
|