cast-code 1.0.0
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 +21 -0
- package/README.md +217 -0
- package/dist/app.module.js +45 -0
- package/dist/app.module.js.map +1 -0
- package/dist/common/common.module.js +49 -0
- package/dist/common/common.module.js.map +1 -0
- package/dist/common/constants/index.js +105 -0
- package/dist/common/constants/index.js.map +1 -0
- package/dist/common/index.js +24 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/services/config.service.js +119 -0
- package/dist/common/services/config.service.js.map +1 -0
- package/dist/common/services/llm.service.js +56 -0
- package/dist/common/services/llm.service.js.map +1 -0
- package/dist/common/services/markdown-parser.service.js +101 -0
- package/dist/common/services/markdown-parser.service.js.map +1 -0
- package/dist/common/services/markdown-renderer.service.js +220 -0
- package/dist/common/services/markdown-renderer.service.js.map +1 -0
- package/dist/common/services/multi-llm.service.js +115 -0
- package/dist/common/services/multi-llm.service.js.map +1 -0
- package/dist/common/types/index.js +20 -0
- package/dist/common/types/index.js.map +1 -0
- package/dist/common/types/markdown.types.js +6 -0
- package/dist/common/types/markdown.types.js.map +1 -0
- package/dist/main.js +84 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/agents/agents.module.js +43 -0
- package/dist/modules/agents/agents.module.js.map +1 -0
- package/dist/modules/agents/definitions/architect.md +35 -0
- package/dist/modules/agents/definitions/backend.md +43 -0
- package/dist/modules/agents/definitions/coder.md +34 -0
- package/dist/modules/agents/definitions/devops.md +42 -0
- package/dist/modules/agents/definitions/frontend.md +46 -0
- package/dist/modules/agents/definitions/reviewer.md +35 -0
- package/dist/modules/agents/definitions/tester.md +41 -0
- package/dist/modules/agents/index.js +23 -0
- package/dist/modules/agents/index.js.map +1 -0
- package/dist/modules/agents/services/agent-loader.service.js +150 -0
- package/dist/modules/agents/services/agent-loader.service.js.map +1 -0
- package/dist/modules/agents/services/agent-registry.service.js +108 -0
- package/dist/modules/agents/services/agent-registry.service.js.map +1 -0
- package/dist/modules/agents/types/agent.types.js +6 -0
- package/dist/modules/agents/types/agent.types.js.map +1 -0
- package/dist/modules/agents/types/index.js +20 -0
- package/dist/modules/agents/types/index.js.map +1 -0
- package/dist/modules/config/config.module.js +38 -0
- package/dist/modules/config/config.module.js.map +1 -0
- package/dist/modules/config/index.js +24 -0
- package/dist/modules/config/index.js.map +1 -0
- package/dist/modules/config/services/config-commands.service.js +405 -0
- package/dist/modules/config/services/config-commands.service.js.map +1 -0
- package/dist/modules/config/services/config-manager.service.js +175 -0
- package/dist/modules/config/services/config-manager.service.js.map +1 -0
- package/dist/modules/config/services/init-config.service.js +238 -0
- package/dist/modules/config/services/init-config.service.js.map +1 -0
- package/dist/modules/config/types/config.types.js +163 -0
- package/dist/modules/config/types/config.types.js.map +1 -0
- package/dist/modules/config/types/index.js +20 -0
- package/dist/modules/config/types/index.js.map +1 -0
- package/dist/modules/core/core.module.js +60 -0
- package/dist/modules/core/core.module.js.map +1 -0
- package/dist/modules/core/index.js +22 -0
- package/dist/modules/core/index.js.map +1 -0
- package/dist/modules/core/services/deep-agent.service.js +575 -0
- package/dist/modules/core/services/deep-agent.service.js.map +1 -0
- package/dist/modules/core/services/plan-mode.service.js +225 -0
- package/dist/modules/core/services/plan-mode.service.js.map +1 -0
- package/dist/modules/git/git.module.js +48 -0
- package/dist/modules/git/git.module.js.map +1 -0
- package/dist/modules/git/index.js +23 -0
- package/dist/modules/git/index.js.map +1 -0
- package/dist/modules/git/services/code-review.service.js +330 -0
- package/dist/modules/git/services/code-review.service.js.map +1 -0
- package/dist/modules/git/services/commit-generator.service.js +403 -0
- package/dist/modules/git/services/commit-generator.service.js.map +1 -0
- package/dist/modules/git/services/index.js +21 -0
- package/dist/modules/git/services/index.js.map +1 -0
- package/dist/modules/git/services/monorepo-detector.service.js +338 -0
- package/dist/modules/git/services/monorepo-detector.service.js.map +1 -0
- package/dist/modules/git/services/pr-generator.service.js +429 -0
- package/dist/modules/git/services/pr-generator.service.js.map +1 -0
- package/dist/modules/git/services/release-notes.service.js +426 -0
- package/dist/modules/git/services/release-notes.service.js.map +1 -0
- package/dist/modules/git/types/git.types.js +6 -0
- package/dist/modules/git/types/git.types.js.map +1 -0
- package/dist/modules/git/types/index.js +20 -0
- package/dist/modules/git/types/index.js.map +1 -0
- package/dist/modules/mcp/catalog/mcp-templates.js +606 -0
- package/dist/modules/mcp/catalog/mcp-templates.js.map +1 -0
- package/dist/modules/mcp/index.js +23 -0
- package/dist/modules/mcp/index.js.map +1 -0
- package/dist/modules/mcp/mcp.module.js +35 -0
- package/dist/modules/mcp/mcp.module.js.map +1 -0
- package/dist/modules/mcp/services/mcp-client.service.js +289 -0
- package/dist/modules/mcp/services/mcp-client.service.js.map +1 -0
- package/dist/modules/mcp/services/mcp-registry.service.js +197 -0
- package/dist/modules/mcp/services/mcp-registry.service.js.map +1 -0
- package/dist/modules/mcp/types/index.js +20 -0
- package/dist/modules/mcp/types/index.js.map +1 -0
- package/dist/modules/mcp/types/mcp.types.js +6 -0
- package/dist/modules/mcp/types/mcp.types.js.map +1 -0
- package/dist/modules/memory/index.js +23 -0
- package/dist/modules/memory/index.js.map +1 -0
- package/dist/modules/memory/memory.module.js +35 -0
- package/dist/modules/memory/memory.module.js.map +1 -0
- package/dist/modules/memory/services/memory-tools.service.js +78 -0
- package/dist/modules/memory/services/memory-tools.service.js.map +1 -0
- package/dist/modules/memory/services/memory.service.js +169 -0
- package/dist/modules/memory/services/memory.service.js.map +1 -0
- package/dist/modules/memory/types/index.js +20 -0
- package/dist/modules/memory/types/index.js.map +1 -0
- package/dist/modules/memory/types/memory.types.js +6 -0
- package/dist/modules/memory/types/memory.types.js.map +1 -0
- package/dist/modules/mentions/index.js +22 -0
- package/dist/modules/mentions/index.js.map +1 -0
- package/dist/modules/mentions/mentions.module.js +32 -0
- package/dist/modules/mentions/mentions.module.js.map +1 -0
- package/dist/modules/mentions/services/mentions.service.js +336 -0
- package/dist/modules/mentions/services/mentions.service.js.map +1 -0
- package/dist/modules/mentions/types/index.js +20 -0
- package/dist/modules/mentions/types/index.js.map +1 -0
- package/dist/modules/mentions/types/mention.types.js +19 -0
- package/dist/modules/mentions/types/mention.types.js.map +1 -0
- package/dist/modules/permissions/index.js +23 -0
- package/dist/modules/permissions/index.js.map +1 -0
- package/dist/modules/permissions/permissions.module.js +35 -0
- package/dist/modules/permissions/permissions.module.js.map +1 -0
- package/dist/modules/permissions/services/permission.service.js +269 -0
- package/dist/modules/permissions/services/permission.service.js.map +1 -0
- package/dist/modules/permissions/services/prompt.service.js +116 -0
- package/dist/modules/permissions/services/prompt.service.js.map +1 -0
- package/dist/modules/permissions/types/permission.types.js +32 -0
- package/dist/modules/permissions/types/permission.types.js.map +1 -0
- package/dist/modules/project/index.js +24 -0
- package/dist/modules/project/index.js.map +1 -0
- package/dist/modules/project/project.module.js +38 -0
- package/dist/modules/project/project.module.js.map +1 -0
- package/dist/modules/project/services/project-analyzer.service.js +1063 -0
- package/dist/modules/project/services/project-analyzer.service.js.map +1 -0
- package/dist/modules/project/services/project-context.service.js +62 -0
- package/dist/modules/project/services/project-context.service.js.map +1 -0
- package/dist/modules/project/services/project-loader.service.js +147 -0
- package/dist/modules/project/services/project-loader.service.js.map +1 -0
- package/dist/modules/project/types/index.js +20 -0
- package/dist/modules/project/types/index.js.map +1 -0
- package/dist/modules/project/types/project.types.js +6 -0
- package/dist/modules/project/types/project.types.js.map +1 -0
- package/dist/modules/repl/index.js +21 -0
- package/dist/modules/repl/index.js.map +1 -0
- package/dist/modules/repl/repl.module.js +66 -0
- package/dist/modules/repl/repl.module.js.map +1 -0
- package/dist/modules/repl/services/commands/agent-commands.service.js +196 -0
- package/dist/modules/repl/services/commands/agent-commands.service.js.map +1 -0
- package/dist/modules/repl/services/commands/git-commands.service.js +500 -0
- package/dist/modules/repl/services/commands/git-commands.service.js.map +1 -0
- package/dist/modules/repl/services/commands/mcp-commands.service.js +579 -0
- package/dist/modules/repl/services/commands/mcp-commands.service.js.map +1 -0
- package/dist/modules/repl/services/commands/project-commands.service.js +226 -0
- package/dist/modules/repl/services/commands/project-commands.service.js.map +1 -0
- package/dist/modules/repl/services/commands/repl-commands.service.js +254 -0
- package/dist/modules/repl/services/commands/repl-commands.service.js.map +1 -0
- package/dist/modules/repl/services/repl.service.js +647 -0
- package/dist/modules/repl/services/repl.service.js.map +1 -0
- package/dist/modules/repl/services/smart-input.js +544 -0
- package/dist/modules/repl/services/smart-input.js.map +1 -0
- package/dist/modules/repl/services/welcome-screen.service.js +117 -0
- package/dist/modules/repl/services/welcome-screen.service.js.map +1 -0
- package/dist/modules/repl/utils/prompts-with-esc.js +187 -0
- package/dist/modules/repl/utils/prompts-with-esc.js.map +1 -0
- package/dist/modules/repl/utils/theme.js +185 -0
- package/dist/modules/repl/utils/theme.js.map +1 -0
- package/dist/modules/skills/definitions/general/file-operations.md +60 -0
- package/dist/modules/skills/definitions/general/git-operations.md +59 -0
- package/dist/modules/skills/definitions/general/planning.md +86 -0
- package/dist/modules/skills/definitions/general/search.md +59 -0
- package/dist/modules/skills/definitions/specialized/api-design.md +85 -0
- package/dist/modules/skills/definitions/specialized/database-operations.md +78 -0
- package/dist/modules/skills/definitions/specialized/frontend-bootstrap.md +71 -0
- package/dist/modules/skills/definitions/specialized/react-patterns.md +77 -0
- package/dist/modules/skills/definitions/specialized/testing-strategies.md +79 -0
- package/dist/modules/skills/index.js +23 -0
- package/dist/modules/skills/index.js.map +1 -0
- package/dist/modules/skills/services/skill-loader.service.js +130 -0
- package/dist/modules/skills/services/skill-loader.service.js.map +1 -0
- package/dist/modules/skills/services/skill-registry.service.js +96 -0
- package/dist/modules/skills/services/skill-registry.service.js.map +1 -0
- package/dist/modules/skills/skills.module.js +38 -0
- package/dist/modules/skills/skills.module.js.map +1 -0
- package/dist/modules/skills/types/index.js +20 -0
- package/dist/modules/skills/types/index.js.map +1 -0
- package/dist/modules/skills/types/skill.types.js +6 -0
- package/dist/modules/skills/types/skill.types.js.map +1 -0
- package/dist/modules/tasks/index.js +24 -0
- package/dist/modules/tasks/index.js.map +1 -0
- package/dist/modules/tasks/services/plan-executor.service.js +199 -0
- package/dist/modules/tasks/services/plan-executor.service.js.map +1 -0
- package/dist/modules/tasks/services/plan-mode.service.js +118 -0
- package/dist/modules/tasks/services/plan-mode.service.js.map +1 -0
- package/dist/modules/tasks/services/plan-persistence.service.js +148 -0
- package/dist/modules/tasks/services/plan-persistence.service.js.map +1 -0
- package/dist/modules/tasks/services/task-management.service.js +255 -0
- package/dist/modules/tasks/services/task-management.service.js.map +1 -0
- package/dist/modules/tasks/services/task-tools.service.js +270 -0
- package/dist/modules/tasks/services/task-tools.service.js.map +1 -0
- package/dist/modules/tasks/tasks.module.js +49 -0
- package/dist/modules/tasks/tasks.module.js.map +1 -0
- package/dist/modules/tasks/types/task.types.js +21 -0
- package/dist/modules/tasks/types/task.types.js.map +1 -0
- package/dist/modules/tools/index.js +24 -0
- package/dist/modules/tools/index.js.map +1 -0
- package/dist/modules/tools/services/filesystem-tools.service.js +450 -0
- package/dist/modules/tools/services/filesystem-tools.service.js.map +1 -0
- package/dist/modules/tools/services/search-tools.service.js +63 -0
- package/dist/modules/tools/services/search-tools.service.js.map +1 -0
- package/dist/modules/tools/services/shell-tools.service.js +194 -0
- package/dist/modules/tools/services/shell-tools.service.js.map +1 -0
- package/dist/modules/tools/services/tools-registry.service.js +83 -0
- package/dist/modules/tools/services/tools-registry.service.js.map +1 -0
- package/dist/modules/tools/tools.module.js +46 -0
- package/dist/modules/tools/tools.module.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/repl/services/smart-input.ts"],"sourcesContent":["import { Colors } from '../utils/theme';\n\nexport interface Suggestion {\n text: string;\n display: string;\n description?: string;\n}\n\nexport interface SmartInputOptions {\n prompt: string;\n promptVisibleLen: number;\n getCommandSuggestions: (input: string) => Suggestion[];\n getMentionSuggestions: (partial: string) => Suggestion[];\n onSubmit: (line: string) => void;\n onCancel: () => void;\n onExit: () => void;\n onExpandToolOutput?: () => void;\n}\n\nexport class SmartInput {\n private buffer = '';\n private cursor = 0;\n\n private history: string[] = [];\n private historyIndex = -1;\n private savedBuffer = '';\n\n private suggestions: Suggestion[] = [];\n private selectedIndex = -1;\n private renderedLines = 0;\n\n private mode: 'input' | 'passive' | 'question' = 'input';\n private questionResolve: ((answer: string) => void) | null = null;\n private questionBuffer = '';\n\n private prompt: string;\n private promptLen: number;\n private opts: SmartInputOptions;\n\n private dataHandler: ((data: string) => void) | null = null;\n private terminalWidth = 80; // default\n private isPaused = false;\n\n constructor(opts: SmartInputOptions) {\n this.opts = opts;\n this.prompt = opts.prompt;\n this.promptLen = opts.promptVisibleLen;\n }\n\n start() {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n }\n process.stdin.resume();\n process.stdin.setEncoding('utf8');\n\n this.terminalWidth = process.stdout.columns || 80;\n\n // Listener para redimensionamento\n process.stdout.on('resize', () => {\n this.terminalWidth = process.stdout.columns || 80;\n });\n\n this.dataHandler = (data: string) => this.handleData(data);\n process.stdin.on('data', this.dataHandler);\n\n this.mode = 'input';\n this.render();\n }\n\n enterPassiveMode() {\n this.mode = 'passive';\n this.clearSuggestions();\n }\n\n exitPassiveMode() {\n this.mode = 'input';\n }\n\n showPrompt() {\n this.buffer = '';\n this.cursor = 0;\n this.suggestions = [];\n this.selectedIndex = -1;\n this.mode = 'input';\n this.render();\n }\n\n async question(query: string): Promise<string> {\n this.mode = 'question';\n this.questionBuffer = '';\n process.stdout.write(query + ' ');\n\n return new Promise<string>((resolve) => {\n this.questionResolve = resolve;\n });\n }\n\n async askChoice(\n message: string,\n choices: { key: string; label: string; description?: string }[],\n ): Promise<string> {\n process.stdout.write(`\\r\\n${Colors.cyan}${message}${Colors.reset}\\r\\n\\r\\n`);\n choices.forEach((ch, i) => {\n const desc = ch.description ? `${Colors.dim} - ${ch.description}${Colors.reset}` : '';\n process.stdout.write(` ${Colors.white}${i + 1}.${Colors.reset} ${Colors.bold}${ch.label}${Colors.reset}${desc}\\r\\n`);\n });\n process.stdout.write('\\r\\n');\n\n while (true) {\n const answer = await this.question(`${Colors.yellow}Choose (1-${choices.length}):${Colors.reset}`);\n const idx = parseInt(answer) - 1;\n if (idx >= 0 && idx < choices.length) {\n return choices[idx].key;\n }\n process.stdout.write(`${Colors.red} Invalid choice, try again.${Colors.reset}\\r\\n`);\n }\n }\n\n pause() {\n this.isPaused = true;\n if (this.dataHandler) {\n process.stdin.removeListener('data', this.dataHandler);\n }\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n }\n\n resume() {\n this.isPaused = false;\n if (this.dataHandler) {\n process.stdin.on('data', this.dataHandler);\n }\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n }\n process.stdin.resume();\n this.showPrompt();\n }\n\n destroy() {\n this.clearSuggestions();\n if (this.dataHandler) {\n process.stdin.removeListener('data', this.dataHandler);\n this.dataHandler = null;\n }\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n }\n\n private handleData(data: string) {\n if (this.isPaused) {\n return;\n }\n\n if (this.mode === 'passive') {\n for (const ch of data) {\n if (ch.charCodeAt(0) === 0x03) {\n this.opts.onCancel();\n }\n }\n return;\n }\n\n if (this.mode === 'question') {\n this.handleQuestionData(data);\n return;\n }\n\n this.handleInputData(data);\n }\n\n private handleQuestionData(data: string) {\n const write = (s: string) => process.stdout.write(s);\n\n for (let i = 0; i < data.length; i++) {\n const code = data.charCodeAt(i);\n\n if (code === 0x0d || code === 0x0a) {\n write('\\r\\n');\n const resolve = this.questionResolve;\n const answer = this.questionBuffer;\n this.questionResolve = null;\n this.questionBuffer = '';\n this.mode = 'input';\n if (resolve) resolve(answer);\n return;\n }\n\n if (code === 0x7f || code === 0x08) {\n if (this.questionBuffer.length > 0) {\n this.questionBuffer = this.questionBuffer.slice(0, -1);\n write('\\b \\b');\n }\n continue;\n }\n\n if (code === 0x03) {\n write('\\r\\n');\n const resolve = this.questionResolve;\n this.questionResolve = null;\n this.questionBuffer = '';\n this.mode = 'input';\n if (resolve) resolve('');\n return;\n }\n\n if (code >= 0x20) {\n this.questionBuffer += data[i];\n write(data[i]);\n }\n }\n }\n\n private handleInputData(data: string) {\n let needsRender = false;\n let bufferChanged = false;\n let i = 0;\n\n while (i < data.length) {\n if (data[i] === '\\x1b' && data[i + 1] === '[') {\n const rest = data.slice(i);\n\n if (rest.startsWith('\\x1b[A')) { this.keyUp(); i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[B')) { this.keyDown(); i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[C')) { this.keyRight(); i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[D')) { this.keyLeft(); i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[H')) { this.cursor = 0; i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[F')) { this.cursor = this.buffer.length; i += 3; needsRender = true; continue; }\n if (rest.startsWith('\\x1b[3~')) { this.keyDelete(); i += 4; needsRender = true; bufferChanged = true; continue; }\n\n i++;\n continue;\n }\n\n const code = data.charCodeAt(i);\n\n switch (code) {\n case 0x0d:\n case 0x0a:\n this.keyEnter();\n i++;\n continue;\n\n case 0x09:\n this.keyTab();\n needsRender = true;\n break;\n\n case 0x7f:\n case 0x08:\n this.keyBackspace();\n needsRender = true;\n bufferChanged = true;\n break;\n\n case 0x03:\n this.keyCtrlC();\n i++;\n continue;\n\n case 0x04:\n if (this.buffer.length === 0) {\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n this.opts.onExit();\n return;\n }\n break;\n\n case 0x0c:\n this.clearSuggestions();\n process.stdout.write('\\x1b[2J\\x1b[H');\n needsRender = true;\n break;\n\n case 0x15:\n this.buffer = this.buffer.slice(this.cursor);\n this.cursor = 0;\n needsRender = true;\n bufferChanged = true;\n break;\n\n case 0x0b:\n this.buffer = this.buffer.slice(0, this.cursor);\n needsRender = true;\n bufferChanged = true;\n break;\n\n case 0x01:\n this.cursor = 0;\n needsRender = true;\n break;\n\n case 0x05:\n this.cursor = this.buffer.length;\n needsRender = true;\n break;\n\n case 0x17:\n this.deleteWordBack();\n needsRender = true;\n bufferChanged = true;\n break;\n\n case 0x0f:\n if (this.opts.onExpandToolOutput) {\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n this.opts.onExpandToolOutput();\n needsRender = true;\n }\n break;\n\n default:\n if (code >= 0x20) {\n this.buffer =\n this.buffer.slice(0, this.cursor) +\n data[i] +\n this.buffer.slice(this.cursor);\n this.cursor++;\n needsRender = true;\n bufferChanged = true;\n }\n }\n\n i++;\n }\n\n if (needsRender) {\n if (bufferChanged) {\n this.computeSuggestions();\n }\n this.render();\n }\n }\n\n private keyUp() {\n if (this.suggestions.length > 0) {\n this.selectedIndex =\n this.selectedIndex <= 0\n ? this.suggestions.length - 1\n : this.selectedIndex - 1;\n } else {\n if (this.historyIndex === -1) this.savedBuffer = this.buffer;\n if (this.historyIndex < this.history.length - 1) {\n this.historyIndex++;\n this.buffer = this.history[this.historyIndex];\n this.cursor = this.buffer.length;\n }\n }\n }\n\n private keyDown() {\n if (this.suggestions.length > 0) {\n this.selectedIndex =\n this.selectedIndex >= this.suggestions.length - 1\n ? 0\n : this.selectedIndex + 1;\n } else {\n if (this.historyIndex > 0) {\n this.historyIndex--;\n this.buffer = this.history[this.historyIndex];\n this.cursor = this.buffer.length;\n } else if (this.historyIndex === 0) {\n this.historyIndex = -1;\n this.buffer = this.savedBuffer;\n this.cursor = this.buffer.length;\n }\n }\n }\n\n private keyLeft() { if (this.cursor > 0) this.cursor--; }\n private keyRight() { if (this.cursor < this.buffer.length) this.cursor++; }\n\n private keyBackspace() {\n if (this.cursor > 0) {\n this.buffer =\n this.buffer.slice(0, this.cursor - 1) +\n this.buffer.slice(this.cursor);\n this.cursor--;\n }\n }\n\n private keyDelete() {\n if (this.cursor < this.buffer.length) {\n this.buffer =\n this.buffer.slice(0, this.cursor) +\n this.buffer.slice(this.cursor + 1);\n }\n }\n\n private keyEnter() {\n if (this.selectedIndex >= 0 && this.suggestions.length > 0) {\n this.acceptSuggestion();\n this.computeSuggestions();\n this.render();\n } else {\n this.submitLine();\n }\n }\n\n private keyTab() {\n if (this.suggestions.length > 0) {\n if (this.selectedIndex < 0) {\n this.selectedIndex = 0;\n this.acceptSuggestion();\n this.computeSuggestions();\n } else {\n this.acceptSuggestion();\n this.computeSuggestions();\n }\n }\n }\n\n private lastCtrlCTime = 0;\n\n private keyCtrlC() {\n if (this.buffer.length > 0) {\n this.buffer = '';\n this.cursor = 0;\n this.suggestions = [];\n this.selectedIndex = -1;\n this.lastCtrlCTime = Date.now();\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n this.render();\n } else {\n const now = Date.now();\n if (now - this.lastCtrlCTime < 1500) {\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n this.opts.onExit();\n return;\n }\n this.lastCtrlCTime = now;\n this.clearSuggestions();\n process.stdout.write(`\\r\\n${Colors.dim} Press Ctrl+C again to exit${Colors.reset}\\r\\n`);\n this.render();\n }\n }\n\n private deleteWordBack() {\n const before = this.buffer.slice(0, this.cursor);\n const match = before.match(/\\S+\\s*$/);\n if (match) {\n const len = match[0].length;\n this.buffer =\n this.buffer.slice(0, this.cursor - len) +\n this.buffer.slice(this.cursor);\n this.cursor -= len;\n }\n }\n\n private submitLine() {\n const line = this.buffer;\n\n this.clearSuggestions();\n process.stdout.write('\\r\\n');\n\n if (line.trim()) {\n this.history.unshift(line);\n if (this.history.length > 200) this.history.pop();\n }\n\n this.buffer = '';\n this.cursor = 0;\n this.historyIndex = -1;\n this.suggestions = [];\n this.selectedIndex = -1;\n\n this.opts.onSubmit(line);\n }\n\n private acceptSuggestion() {\n const s = this.suggestions[this.selectedIndex];\n if (!s) return;\n\n if (this.buffer.startsWith('/')) {\n this.buffer = s.text;\n this.cursor = this.buffer.length;\n } else {\n const atMatch = this.buffer.match(/@[\\w./:~\\-]*$/);\n if (atMatch && atMatch.index !== undefined) {\n this.buffer = this.buffer.slice(0, atMatch.index) + s.text;\n this.cursor = this.buffer.length;\n }\n }\n\n this.selectedIndex = -1;\n\n if (s.text.endsWith('/')) {\n this.computeSuggestions();\n }\n }\n\n private computeSuggestions() {\n this.selectedIndex = -1;\n\n if (this.buffer.startsWith('/')) {\n this.suggestions = this.opts.getCommandSuggestions(this.buffer);\n return;\n }\n\n const atMatch = this.buffer.match(/@([\\w./:~\\-]*)$/);\n if (atMatch) {\n this.suggestions = this.opts.getMentionSuggestions(atMatch[1]);\n return;\n }\n\n this.suggestions = [];\n }\n\n private calculateCursorPosition(): { row: number; col: number } {\n const totalLength = this.promptLen + this.cursor;\n const row = Math.floor(totalLength / this.terminalWidth);\n const col = (totalLength % this.terminalWidth) + 1;\n return { row, col };\n }\n\n private render() {\n const write = (s: string) => process.stdout.write(s);\n\n // Calcular quantas linhas o buffer atual ocupa\n const totalLength = this.promptLen + this.buffer.length;\n const linesUsed = Math.ceil(totalLength / this.terminalWidth);\n\n // Ir para o início do input (primeira linha do input)\n if (linesUsed > 1) {\n write(`\\x1b[${linesUsed - 1}A`); // Sobe para primeira linha do input\n }\n write('\\r'); // Volta para início da linha\n\n // Limpar todas as linhas usadas pelo input\n for (let i = 0; i < linesUsed; i++) {\n write('\\x1b[K'); // Limpa linha atual\n if (i < linesUsed - 1) write('\\n'); // Desce se não for última linha\n }\n\n // Voltar para primeira linha\n if (linesUsed > 1) {\n write(`\\x1b[${linesUsed - 1}A`);\n }\n write('\\r');\n\n // Escrever prompt + buffer\n write(this.prompt + this.buffer);\n\n // Limpar resto da tela (para sugestões antigas)\n write('\\x1b[J');\n\n this.renderedLines = 0;\n\n // Renderizar sugestões\n if (this.suggestions.length > 0) {\n const maxVisible = 10;\n const total = this.suggestions.length;\n\n let scrollStart = 0;\n if (this.selectedIndex >= 0 && total > maxVisible) {\n scrollStart = Math.max(0, Math.min(\n this.selectedIndex - Math.floor(maxVisible / 2),\n total - maxVisible,\n ));\n }\n const scrollEnd = Math.min(scrollStart + maxVisible, total);\n\n if (scrollStart > 0) {\n write(`\\r\\n ${Colors.dim}\\u2191 ${scrollStart} above${Colors.reset}`);\n this.renderedLines++;\n }\n\n for (let i = scrollStart; i < scrollEnd; i++) {\n const s = this.suggestions[i];\n const selected = i === this.selectedIndex;\n\n if (selected) {\n write(`\\r\\n ${Colors.primary}\\u276f${Colors.reset} ${Colors.bold}${Colors.primary}${s.display}${Colors.reset}`);\n } else {\n write(`\\r\\n ${Colors.dim}${s.display}${Colors.reset}`);\n }\n\n if (s.description) {\n write(` ${Colors.muted}${s.description}${Colors.reset}`);\n }\n\n this.renderedLines++;\n }\n\n const remaining = total - scrollEnd;\n if (remaining > 0) {\n write(`\\r\\n ${Colors.dim}\\u2193 ${remaining} below${Colors.reset}`);\n this.renderedLines++;\n }\n }\n\n // Voltar para linha do input se renderizou sugestões\n if (this.renderedLines > 0) {\n write(`\\x1b[${this.renderedLines}A`);\n }\n\n // Posicionar cursor corretamente considerando wrapping\n const { row, col } = this.calculateCursorPosition();\n\n if (row > 0) {\n write(`\\x1b[${row}B`); // Desce 'row' linhas\n }\n write(`\\x1b[${col}G`); // Move para coluna\n }\n\n private clearSuggestions() {\n if (this.renderedLines > 0) {\n const { row, col } = this.calculateCursorPosition();\n\n // Posiciona no fim do buffer\n if (row > 0) {\n process.stdout.write(`\\x1b[${row}B`);\n }\n process.stdout.write(`\\x1b[${col}G\\x1b[J`);\n\n this.renderedLines = 0;\n }\n }\n}\n"],"names":["SmartInput","start","process","stdin","isTTY","setRawMode","resume","setEncoding","terminalWidth","stdout","columns","on","dataHandler","data","handleData","mode","render","enterPassiveMode","clearSuggestions","exitPassiveMode","showPrompt","buffer","cursor","suggestions","selectedIndex","question","query","questionBuffer","write","Promise","resolve","questionResolve","askChoice","message","choices","Colors","cyan","reset","forEach","ch","i","desc","description","dim","white","bold","label","answer","yellow","length","idx","parseInt","key","red","pause","isPaused","removeListener","destroy","charCodeAt","opts","onCancel","handleQuestionData","handleInputData","s","code","slice","needsRender","bufferChanged","rest","startsWith","keyUp","keyDown","keyRight","keyLeft","keyDelete","keyEnter","keyTab","keyBackspace","keyCtrlC","onExit","deleteWordBack","onExpandToolOutput","computeSuggestions","historyIndex","savedBuffer","history","acceptSuggestion","submitLine","lastCtrlCTime","Date","now","before","match","len","line","trim","unshift","pop","onSubmit","text","atMatch","index","undefined","endsWith","getCommandSuggestions","getMentionSuggestions","calculateCursorPosition","totalLength","promptLen","row","Math","floor","col","linesUsed","ceil","prompt","renderedLines","maxVisible","total","scrollStart","max","min","scrollEnd","selected","primary","display","muted","remaining","promptVisibleLen"],"mappings":";;;;+BAmBaA;;;eAAAA;;;uBAnBU;AAmBhB,IAAA,AAAMA,aAAN,MAAMA;IA8BXC,QAAQ;QACN,IAAIC,QAAQC,KAAK,CAACC,KAAK,EAAE;YACvBF,QAAQC,KAAK,CAACE,UAAU,CAAC;QAC3B;QACAH,QAAQC,KAAK,CAACG,MAAM;QACpBJ,QAAQC,KAAK,CAACI,WAAW,CAAC;QAE1B,IAAI,CAACC,aAAa,GAAGN,QAAQO,MAAM,CAACC,OAAO,IAAI;QAE/C,kCAAkC;QAClCR,QAAQO,MAAM,CAACE,EAAE,CAAC,UAAU;YAC1B,IAAI,CAACH,aAAa,GAAGN,QAAQO,MAAM,CAACC,OAAO,IAAI;QACjD;QAEA,IAAI,CAACE,WAAW,GAAG,CAACC,OAAiB,IAAI,CAACC,UAAU,CAACD;QACrDX,QAAQC,KAAK,CAACQ,EAAE,CAAC,QAAQ,IAAI,CAACC,WAAW;QAEzC,IAAI,CAACG,IAAI,GAAG;QACZ,IAAI,CAACC,MAAM;IACb;IAEAC,mBAAmB;QACjB,IAAI,CAACF,IAAI,GAAG;QACZ,IAAI,CAACG,gBAAgB;IACvB;IAEAC,kBAAkB;QAChB,IAAI,CAACJ,IAAI,GAAG;IACd;IAEAK,aAAa;QACX,IAAI,CAACC,MAAM,GAAG;QACd,IAA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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "WelcomeScreenService", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return WelcomeScreenService;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _common = require("@nestjs/common");
|
|
12
|
+
const _theme = require("../utils/theme");
|
|
13
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
}
|
|
19
|
+
function _ts_metadata(k, v) {
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
21
|
+
}
|
|
22
|
+
const stripAnsi = (str)=>{
|
|
23
|
+
return str.replace(/\x1b\[[0-9;]*m/g, '');
|
|
24
|
+
};
|
|
25
|
+
const visiblePadEnd = (str, targetLength)=>{
|
|
26
|
+
const visibleLength = stripAnsi(str).length;
|
|
27
|
+
const padding = targetLength - visibleLength;
|
|
28
|
+
return padding > 0 ? str + ' '.repeat(padding) : str;
|
|
29
|
+
};
|
|
30
|
+
let WelcomeScreenService = class WelcomeScreenService {
|
|
31
|
+
printWelcomeScreen(context) {
|
|
32
|
+
const width = 56;
|
|
33
|
+
const innerWidth = width - 4;
|
|
34
|
+
console.log('');
|
|
35
|
+
console.log((0, _theme.colorize)(_theme.Box.topLeft + _theme.Box.horizontal.repeat(innerWidth + 2) + _theme.Box.topRight, 'primary'));
|
|
36
|
+
const logoText = `${_theme.Icons.chestnut} CAST CODE ${_theme.Icons.chestnut}`;
|
|
37
|
+
const logoPadding = Math.floor((innerWidth - logoText.length) / 2);
|
|
38
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + ' ' + ' '.repeat(logoPadding) + (0, _theme.colorize)(logoText, 'bold') + ' '.repeat(innerWidth - logoPadding - logoText.length) + ' ' + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
39
|
+
const subtitle = 'Multi-Agent CLI Assistant';
|
|
40
|
+
const subPadding = Math.floor((innerWidth - subtitle.length) / 2);
|
|
41
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + ' ' + ' '.repeat(subPadding) + (0, _theme.colorize)(subtitle, 'muted') + ' '.repeat(innerWidth - subPadding - subtitle.length) + ' ' + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
42
|
+
console.log((0, _theme.colorize)(_theme.Box.leftT + _theme.Box.horizontal.repeat(innerWidth + 2) + _theme.Box.rightT, 'primary'));
|
|
43
|
+
const labelColor = 'muted';
|
|
44
|
+
const maxLabel = 9;
|
|
45
|
+
const contentWidth = innerWidth - 2;
|
|
46
|
+
const modelLine = ` ${(0, _theme.colorize)('Model:'.padEnd(maxLabel), labelColor)}${(0, _theme.colorize)(context.model, 'cyan')} `;
|
|
47
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + visiblePadEnd(modelLine, innerWidth) + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
48
|
+
if (context.projectPath) {
|
|
49
|
+
const maxPathLen = innerWidth - maxLabel - 3;
|
|
50
|
+
let displayPath = context.projectPath;
|
|
51
|
+
if (displayPath.length > maxPathLen) {
|
|
52
|
+
displayPath = '...' + displayPath.slice(displayPath.length - maxPathLen + 3);
|
|
53
|
+
}
|
|
54
|
+
const projectLine = ` ${(0, _theme.colorize)('Project:'.padEnd(maxLabel), labelColor)}${(0, _theme.colorize)(displayPath, 'accent')} `;
|
|
55
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + visiblePadEnd(projectLine, innerWidth) + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
56
|
+
}
|
|
57
|
+
const toolsLine = ` ${(0, _theme.colorize)('Tools:'.padEnd(maxLabel), labelColor)}${(0, _theme.colorize)(context.toolCount.toString(), 'green')} ${(0, _theme.colorize)('available', labelColor)} `;
|
|
58
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + visiblePadEnd(toolsLine, innerWidth) + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
59
|
+
const agentsLine = ` ${(0, _theme.colorize)('Agents:'.padEnd(maxLabel), labelColor)}${(0, _theme.colorize)(context.agentCount.toString(), 'magenta')} ${(0, _theme.colorize)('ready', labelColor)} `;
|
|
60
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + visiblePadEnd(agentsLine, innerWidth) + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
61
|
+
console.log((0, _theme.colorize)(_theme.Box.leftT + _theme.Box.horizontal.repeat(innerWidth + 2) + _theme.Box.rightT, 'primary'));
|
|
62
|
+
const tips = [
|
|
63
|
+
{
|
|
64
|
+
cmd: '/help',
|
|
65
|
+
desc: 'Show all commands'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
cmd: '/init',
|
|
69
|
+
desc: 'Map project context'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
cmd: '/mcp add',
|
|
73
|
+
desc: 'Connect Figma MCP'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
cmd: '@file',
|
|
77
|
+
desc: 'Add file context'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
cmd: 'Tab',
|
|
81
|
+
desc: 'Accept suggestions'
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
for (const tip of tips){
|
|
85
|
+
const tipLine = ` ${(0, _theme.colorize)(_theme.Icons.arrow, 'primary')} ${(0, _theme.colorize)(tip.cmd, 'cyan')} ${(0, _theme.colorize)(tip.desc, 'muted')} `;
|
|
86
|
+
console.log((0, _theme.colorize)(_theme.Box.vertical, 'primary') + visiblePadEnd(tipLine, innerWidth) + (0, _theme.colorize)(_theme.Box.vertical, 'primary'));
|
|
87
|
+
}
|
|
88
|
+
console.log((0, _theme.colorize)(_theme.Box.bottomLeft + _theme.Box.horizontal.repeat(innerWidth + 2) + _theme.Box.bottomRight, 'primary'));
|
|
89
|
+
console.log('');
|
|
90
|
+
}
|
|
91
|
+
printBanner() {
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log((0, _theme.colorize)(` ${_theme.Icons.chestnut} CAST CODE ${_theme.Icons.chestnut}`, 'primary'));
|
|
94
|
+
console.log('');
|
|
95
|
+
}
|
|
96
|
+
printStatusLine(context) {
|
|
97
|
+
const parts = [];
|
|
98
|
+
parts.push((0, _theme.colorize)(_theme.Icons.chestnut, 'primary') + ' ' + (0, _theme.colorize)(context.model, 'cyan'));
|
|
99
|
+
if (context.branch) {
|
|
100
|
+
const branchIcon = context.hasChanges ? _theme.Icons.circle : _theme.Icons.branch;
|
|
101
|
+
const branchColor = context.hasChanges ? 'warning' : 'success';
|
|
102
|
+
parts.push((0, _theme.colorize)(branchIcon, branchColor) + ' ' + (0, _theme.colorize)(context.branch, 'muted'));
|
|
103
|
+
}
|
|
104
|
+
if (context.messageCount && context.messageCount > 0) {
|
|
105
|
+
parts.push((0, _theme.colorize)(_theme.Icons.bullet, 'muted') + ' ' + (0, _theme.colorize)(context.messageCount.toString(), 'muted') + ' msgs');
|
|
106
|
+
}
|
|
107
|
+
console.log('\n ' + parts.join(' ') + '\n');
|
|
108
|
+
}
|
|
109
|
+
constructor(){}
|
|
110
|
+
};
|
|
111
|
+
WelcomeScreenService = _ts_decorate([
|
|
112
|
+
(0, _common.Injectable)(),
|
|
113
|
+
_ts_metadata("design:type", Function),
|
|
114
|
+
_ts_metadata("design:paramtypes", [])
|
|
115
|
+
], WelcomeScreenService);
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=welcome-screen.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/repl/services/welcome-screen.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { Colors, colorize, Box, Icons } from '../utils/theme';\n\nexport interface WelcomeScreenContext {\n projectPath?: string;\n model: string;\n toolCount: number;\n agentCount: number;\n}\n\nconst stripAnsi = (str: string): string => {\n return str.replace(/\\x1b\\[[0-9;]*m/g, '');\n};\n\nconst visiblePadEnd = (str: string, targetLength: number): string => {\n const visibleLength = stripAnsi(str).length;\n const padding = targetLength - visibleLength;\n return padding > 0 ? str + ' '.repeat(padding) : str;\n};\n\n@Injectable()\nexport class WelcomeScreenService {\n constructor() {}\n\n printWelcomeScreen(context: WelcomeScreenContext): void {\n const width = 56;\n const innerWidth = width - 4;\n\n console.log('');\n\n console.log(\n colorize(Box.topLeft + Box.horizontal.repeat(innerWidth + 2) + Box.topRight, 'primary')\n );\n\n const logoText = `${Icons.chestnut} CAST CODE ${Icons.chestnut}`;\n const logoPadding = Math.floor((innerWidth - logoText.length) / 2);\n console.log(\n colorize(Box.vertical, 'primary') + ' ' +\n ' '.repeat(logoPadding) +\n colorize(logoText, 'bold') +\n ' '.repeat(innerWidth - logoPadding - logoText.length) +\n ' ' + colorize(Box.vertical, 'primary')\n );\n\n const subtitle = 'Multi-Agent CLI Assistant';\n const subPadding = Math.floor((innerWidth - subtitle.length) / 2);\n console.log(\n colorize(Box.vertical, 'primary') + ' ' +\n ' '.repeat(subPadding) +\n colorize(subtitle, 'muted') +\n ' '.repeat(innerWidth - subPadding - subtitle.length) +\n ' ' + colorize(Box.vertical, 'primary')\n );\n\n console.log(\n colorize(Box.leftT + Box.horizontal.repeat(innerWidth + 2) + Box.rightT, 'primary')\n );\n\n const labelColor = 'muted' as const;\n const maxLabel = 9;\n \n const contentWidth = innerWidth - 2;\n \n const modelLine = ` ${colorize('Model:'.padEnd(maxLabel), labelColor)}${colorize(context.model, 'cyan')} `;\n console.log(\n colorize(Box.vertical, 'primary') +\n visiblePadEnd(modelLine, innerWidth) +\n colorize(Box.vertical, 'primary')\n );\n\n if (context.projectPath) {\n const maxPathLen = innerWidth - maxLabel - 3;\n let displayPath = context.projectPath;\n if (displayPath.length > maxPathLen) {\n displayPath = '...' + displayPath.slice(displayPath.length - maxPathLen + 3);\n }\n const projectLine = ` ${colorize('Project:'.padEnd(maxLabel), labelColor)}${colorize(displayPath, 'accent')} `;\n console.log(\n colorize(Box.vertical, 'primary') +\n visiblePadEnd(projectLine, innerWidth) +\n colorize(Box.vertical, 'primary')\n );\n }\n\n const toolsLine = ` ${colorize('Tools:'.padEnd(maxLabel), labelColor)}${colorize(context.toolCount.toString(), 'green')} ${colorize('available', labelColor)} `;\n console.log(\n colorize(Box.vertical, 'primary') +\n visiblePadEnd(toolsLine, innerWidth) +\n colorize(Box.vertical, 'primary')\n );\n\n const agentsLine = ` ${colorize('Agents:'.padEnd(maxLabel), labelColor)}${colorize(context.agentCount.toString(), 'magenta')} ${colorize('ready', labelColor)} `;\n console.log(\n colorize(Box.vertical, 'primary') +\n visiblePadEnd(agentsLine, innerWidth) +\n colorize(Box.vertical, 'primary')\n );\n\n console.log(\n colorize(Box.leftT + Box.horizontal.repeat(innerWidth + 2) + Box.rightT, 'primary')\n );\n\n const tips = [\n { cmd: '/help', desc: 'Show all commands' },\n { cmd: '/init', desc: 'Map project context' },\n { cmd: '/mcp add', desc: 'Connect Figma MCP' },\n { cmd: '@file', desc: 'Add file context' },\n { cmd: 'Tab', desc: 'Accept suggestions' },\n ];\n\n for (const tip of tips) {\n const tipLine = ` ${colorize(Icons.arrow, 'primary')} ${colorize(tip.cmd, 'cyan')} ${colorize(tip.desc, 'muted')} `;\n console.log(\n colorize(Box.vertical, 'primary') +\n visiblePadEnd(tipLine, innerWidth) +\n colorize(Box.vertical, 'primary')\n );\n }\n\n console.log(\n colorize(Box.bottomLeft + Box.horizontal.repeat(innerWidth + 2) + Box.bottomRight, 'primary')\n );\n console.log('');\n }\n\n printBanner(): void {\n console.log('');\n console.log(colorize(` ${Icons.chestnut} CAST CODE ${Icons.chestnut}`, 'primary'));\n console.log('');\n }\n\n printStatusLine(context: {\n model: string;\n branch?: string;\n hasChanges?: boolean;\n messageCount?: number;\n }): void {\n const parts: string[] = [];\n \n parts.push(colorize(Icons.chestnut, 'primary') + ' ' + colorize(context.model, 'cyan'));\n \n if (context.branch) {\n const branchIcon = context.hasChanges ? Icons.circle : Icons.branch;\n const branchColor = context.hasChanges ? 'warning' : 'success';\n parts.push(colorize(branchIcon, branchColor) + ' ' + colorize(context.branch, 'muted'));\n }\n \n if (context.messageCount && context.messageCount > 0) {\n parts.push(colorize(Icons.bullet, 'muted') + ' ' + colorize(context.messageCount.toString(), 'muted') + ' msgs');\n }\n\n console.log('\\n ' + parts.join(' ') + '\\n');\n }\n}\n"],"names":["WelcomeScreenService","stripAnsi","str","replace","visiblePadEnd","targetLength","visibleLength","length","padding","repeat","printWelcomeScreen","context","width","innerWidth","console","log","colorize","Box","topLeft","horizontal","topRight","logoText","Icons","chestnut","logoPadding","Math","floor","vertical","subtitle","subPadding","leftT","rightT","labelColor","maxLabel","contentWidth","modelLine","padEnd","model","projectPath","maxPathLen","displayPath","slice","projectLine","toolsLine","toolCount","toString","agentsLine","agentCount","tips","cmd","desc","tip","tipLine","arrow","bottomLeft","bottomRight","printBanner","printStatusLine","parts","push","branch","branchIcon","hasChanges","circle","branchColor","messageCount","bullet","join"],"mappings":";;;;+BAqBaA;;;eAAAA;;;wBArBc;uBACkB;;;;;;;;;;AAS7C,MAAMC,YAAY,CAACC;IACjB,OAAOA,IAAIC,OAAO,CAAC,mBAAmB;AACxC;AAEA,MAAMC,gBAAgB,CAACF,KAAaG;IAClC,MAAMC,gBAAgBL,UAAUC,KAAKK,MAAM;IAC3C,MAAMC,UAAUH,eAAeC;IAC/B,OAAOE,UAAU,IAAIN,MAAM,IAAIO,MAA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|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get CancelledPromptError () {
|
|
13
|
+
return CancelledPromptError;
|
|
14
|
+
},
|
|
15
|
+
get confirmWithEsc () {
|
|
16
|
+
return confirmWithEsc;
|
|
17
|
+
},
|
|
18
|
+
get inputWithEsc () {
|
|
19
|
+
return inputWithEsc;
|
|
20
|
+
},
|
|
21
|
+
get menuWithEsc () {
|
|
22
|
+
return menuWithEsc;
|
|
23
|
+
},
|
|
24
|
+
get numberWithEsc () {
|
|
25
|
+
return numberWithEsc;
|
|
26
|
+
},
|
|
27
|
+
get selectWithEsc () {
|
|
28
|
+
return selectWithEsc;
|
|
29
|
+
},
|
|
30
|
+
get withEsc () {
|
|
31
|
+
return withEsc;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _prompts = require("@inquirer/prompts");
|
|
35
|
+
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
36
|
+
function _interop_require_default(obj) {
|
|
37
|
+
return obj && obj.__esModule ? obj : {
|
|
38
|
+
default: obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
let CancelledPromptError = class CancelledPromptError extends Error {
|
|
42
|
+
constructor(){
|
|
43
|
+
super('Cancelled');
|
|
44
|
+
this.name = 'CancelledPromptError';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
async function selectWithEsc(config) {
|
|
48
|
+
const abortController = new AbortController();
|
|
49
|
+
// Escuta ESC em raw mode
|
|
50
|
+
const handleKeypress = (chunk)=>{
|
|
51
|
+
const str = chunk.toString();
|
|
52
|
+
// ESC é \x1b ou \x1b\x1b em alguns terminais
|
|
53
|
+
if (str === '\x1b' || str === '\x1b\x1b' || str === '\x03') {
|
|
54
|
+
abortController.abort();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
if (process.stdin.isTTY) {
|
|
58
|
+
process.stdin.on('data', handleKeypress);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const result = await (0, _prompts.select)(config, {
|
|
62
|
+
signal: abortController.signal
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error.name === 'AbortPromptError' || abortController.signal.aborted) {
|
|
67
|
+
throw new CancelledPromptError();
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
} finally{
|
|
71
|
+
if (process.stdin.isTTY) {
|
|
72
|
+
process.stdin.removeListener('data', handleKeypress);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function inputWithEsc(config) {
|
|
77
|
+
const abortController = new AbortController();
|
|
78
|
+
const handleKeypress = (chunk)=>{
|
|
79
|
+
const str = chunk.toString();
|
|
80
|
+
if (str === '\x1b' || str === '\x1b\x1b' || str === '\x03') {
|
|
81
|
+
abortController.abort();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (process.stdin.isTTY) {
|
|
85
|
+
process.stdin.on('data', handleKeypress);
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const result = await (0, _prompts.input)(config, {
|
|
89
|
+
signal: abortController.signal
|
|
90
|
+
});
|
|
91
|
+
return result;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (error.name === 'AbortPromptError' || abortController.signal.aborted) {
|
|
94
|
+
throw new CancelledPromptError();
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
} finally{
|
|
98
|
+
if (process.stdin.isTTY) {
|
|
99
|
+
process.stdin.removeListener('data', handleKeypress);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function confirmWithEsc(config) {
|
|
104
|
+
const abortController = new AbortController();
|
|
105
|
+
const handleKeypress = (chunk)=>{
|
|
106
|
+
const str = chunk.toString();
|
|
107
|
+
if (str === '\x1b' || str === '\x1b\x1b' || str === '\x03') {
|
|
108
|
+
abortController.abort();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (process.stdin.isTTY) {
|
|
112
|
+
process.stdin.on('data', handleKeypress);
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const result = await (0, _prompts.confirm)(config, {
|
|
116
|
+
signal: abortController.signal
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (error.name === 'AbortPromptError' || abortController.signal.aborted) {
|
|
121
|
+
throw new CancelledPromptError();
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
} finally{
|
|
125
|
+
if (process.stdin.isTTY) {
|
|
126
|
+
process.stdin.removeListener('data', handleKeypress);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function numberWithEsc(config) {
|
|
131
|
+
const abortController = new AbortController();
|
|
132
|
+
const handleKeypress = (chunk)=>{
|
|
133
|
+
const str = chunk.toString();
|
|
134
|
+
if (str === '\x1b' || str === '\x1b\x1b' || str === '\x03') {
|
|
135
|
+
abortController.abort();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
if (process.stdin.isTTY) {
|
|
139
|
+
process.stdin.on('data', handleKeypress);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const result = await (0, _prompts.number)(config, {
|
|
143
|
+
signal: abortController.signal
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (error.name === 'AbortPromptError' || abortController.signal.aborted) {
|
|
148
|
+
throw new CancelledPromptError();
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
} finally{
|
|
152
|
+
if (process.stdin.isTTY) {
|
|
153
|
+
process.stdin.removeListener('data', handleKeypress);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function menuWithEsc(title, choices, options) {
|
|
158
|
+
if (options?.showEscHint !== false) {
|
|
159
|
+
console.log(_chalk.default.gray(`
|
|
160
|
+
(pressione ESC para voltar)
|
|
161
|
+
`));
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const result = await selectWithEsc({
|
|
165
|
+
message: title,
|
|
166
|
+
choices: choices.map((c)=>({
|
|
167
|
+
name: c.label + (c.description ? _chalk.default.gray(` - ${c.description}`) : ''),
|
|
168
|
+
value: c.value
|
|
169
|
+
}))
|
|
170
|
+
});
|
|
171
|
+
return result;
|
|
172
|
+
} catch (CancelledPromptError) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function withEsc(fn) {
|
|
177
|
+
try {
|
|
178
|
+
return await fn();
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof CancelledPromptError || error.name === 'CancelledPromptError') {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=prompts-with-esc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/repl/utils/prompts-with-esc.ts"],"sourcesContent":["import { select, input, confirm, checkbox, number } from '@inquirer/prompts';\nimport chalk from 'chalk';\n\nexport class CancelledPromptError extends Error {\n constructor() {\n super('Cancelled');\n this.name = 'CancelledPromptError';\n }\n}\n\n/**\n * Wrapper para prompts do @inquirer/prompts que adiciona suporte à tecla ESC\n * Pressionar ESC cancela o prompt e lança CancelledPromptError\n */\nexport async function selectWithEsc<T>(config: Parameters<typeof select<T>>[0]): Promise<T> {\n const abortController = new AbortController();\n \n // Escuta ESC em raw mode\n const handleKeypress = (chunk: Buffer) => {\n const str = chunk.toString();\n // ESC é \\x1b ou \\x1b\\x1b em alguns terminais\n if (str === '\\x1b' || str === '\\x1b\\x1b' || str === '\\x03') {\n abortController.abort();\n }\n };\n\n if (process.stdin.isTTY) {\n process.stdin.on('data', handleKeypress);\n }\n\n try {\n const result = await select(config, { signal: abortController.signal });\n return result;\n } catch (error: any) {\n if (error.name === 'AbortPromptError' || abortController.signal.aborted) {\n throw new CancelledPromptError();\n }\n throw error;\n } finally {\n if (process.stdin.isTTY) {\n process.stdin.removeListener('data', handleKeypress);\n }\n }\n}\n\nexport async function inputWithEsc(config: Parameters<typeof input>[0]): Promise<string> {\n const abortController = new AbortController();\n \n const handleKeypress = (chunk: Buffer) => {\n const str = chunk.toString();\n if (str === '\\x1b' || str === '\\x1b\\x1b' || str === '\\x03') {\n abortController.abort();\n }\n };\n\n if (process.stdin.isTTY) {\n process.stdin.on('data', handleKeypress);\n }\n\n try {\n const result = await input(config, { signal: abortController.signal });\n return result;\n } catch (error: any) {\n if (error.name === 'AbortPromptError' || abortController.signal.aborted) {\n throw new CancelledPromptError();\n }\n throw error;\n } finally {\n if (process.stdin.isTTY) {\n process.stdin.removeListener('data', handleKeypress);\n }\n }\n}\n\nexport async function confirmWithEsc(config: Parameters<typeof confirm>[0]): Promise<boolean> {\n const abortController = new AbortController();\n \n const handleKeypress = (chunk: Buffer) => {\n const str = chunk.toString();\n if (str === '\\x1b' || str === '\\x1b\\x1b' || str === '\\x03') {\n abortController.abort();\n }\n };\n\n if (process.stdin.isTTY) {\n process.stdin.on('data', handleKeypress);\n }\n\n try {\n const result = await confirm(config, { signal: abortController.signal });\n return result;\n } catch (error: any) {\n if (error.name === 'AbortPromptError' || abortController.signal.aborted) {\n throw new CancelledPromptError();\n }\n throw error;\n } finally {\n if (process.stdin.isTTY) {\n process.stdin.removeListener('data', handleKeypress);\n }\n }\n}\n\nexport async function numberWithEsc(config: Parameters<typeof number>[0]): Promise<number> {\n const abortController = new AbortController();\n \n const handleKeypress = (chunk: Buffer) => {\n const str = chunk.toString();\n if (str === '\\x1b' || str === '\\x1b\\x1b' || str === '\\x03') {\n abortController.abort();\n }\n };\n\n if (process.stdin.isTTY) {\n process.stdin.on('data', handleKeypress);\n }\n\n try {\n const result = await number(config, { signal: abortController.signal });\n return result;\n } catch (error: any) {\n if (error.name === 'AbortPromptError' || abortController.signal.aborted) {\n throw new CancelledPromptError();\n }\n throw error;\n } finally {\n if (process.stdin.isTTY) {\n process.stdin.removeListener('data', handleKeypress);\n }\n }\n}\n\n/**\n * Menu interativo com suporte a ESC\n * Retorna null se o usuário pressionar ESC\n */\nexport async function menuWithEsc<T extends string>(\n title: string,\n choices: { value: T; label: string; description?: string }[],\n options?: { showEscHint?: boolean }\n): Promise<T | null> {\n if (options?.showEscHint !== false) {\n console.log(chalk.gray(`\n(pressione ESC para voltar)\n`));\n }\n\n try {\n const result = await selectWithEsc<T>({\n message: title,\n choices: choices.map(c => ({\n name: c.label + (c.description ? chalk.gray(` - ${c.description}`) : ''),\n value: c.value,\n })),\n });\n return result;\n } catch (CancelledPromptError) {\n return null;\n }\n}\n\n/**\n * Wrapper para múltiplas operações com tratamento de ESC\n * Se o usuário pressionar ESC em qualquer prompt, retorna null\n */\nexport async function withEsc<T>(fn: () => Promise<T>): Promise<T | null> {\n try {\n return await fn();\n } catch (error: any) {\n if (error instanceof CancelledPromptError || error.name === 'CancelledPromptError') {\n return null;\n }\n throw error;\n }\n}\n"],"names":["CancelledPromptError","confirmWithEsc","inputWithEsc","menuWithEsc","numberWithEsc","selectWithEsc","withEsc","Error","name","config","abortController","AbortController","handleKeypress","chunk","str","toString","abort","process","stdin","isTTY","on","result","select","signal","error","aborted","removeListener","input","confirm","number","title","choices","options","showEscHint","console","log","chalk","gray","message","map","c","label","description","value","fn"],"mappings":";;;;;;;;;;;QAGaA;eAAAA;;QAuESC;eAAAA;;QA7BAC;eAAAA;;QA2FAC;eAAAA;;QAjCAC;eAAAA;;QAzFAC;eAAAA;;QAuJAC;eAAAA;;;yBArKmC;8DACvC;;;;;;AAEX,IAAA,AAAMN,uBAAN,M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AC3B;IAEA,IAAI;QACF,MAAMS,SAAS,MAAMQ,IAAAA,eAAM,EAACpB,QAAQ;YAAEc,QAAQb,gBAAgBa,MAAM;QAAC;QACrE,OAAOF;IACT,EAAE,OAAOG,OAAY;QACnB,IAAIA,MAAMhB,IAAI,KAAK,sBAAsBE,gBAAgBa,MAAM,CAACE,OAAO,EAAE;YACvE,MAAM,IAAIzB;QACZ;QACA,MAAMwB;IACR,SAAU;QACR,IAAIP,QAAQC,KAAK,CAACC,KAAK,EAAE;YACvBF,QAAQC,KAAK,CAACQ,cAAc,CAAC,QAAQd;QACvC;IACF;AACF;AAMO,eAAeT,YACpB2B,KAAa,EACbC,OAA4D,EAC5DC,OAAmC;IAEnC,IAAIA,SAASC,gBAAgB,OAAO;QAClCC,QAAQC,GAAG,CAACC,cAAK,CAACC,IAAI,CAAC,CAAC;;AAE5B,CAAC;IACC;IAEA,IAAI;QACF,MAAMhB,SAAS,MAAMhB,cAAiB;YACpCiC,SAASR;YACTC,SAASA,QAAQQ,GAAG,CAACC,CAAAA,IAAM,CAAA;oBACzBhC,MAAMgC,EAAEC,KAAK,GAAID,CAAAA,EAAEE,WAAW,GAAGN,cAAK,CAACC,IAAI,CAAC,CAAC,GAAG,EAAEG,EAAEE,WAAW,EAAE,IAAI,EAAC;oBACtEC,OAAOH,EAAEG,KAAK;gBAChB,CAAA;QACF;QACA,OAAOtB;IACT,EAAE,OAAOrB,sBAAsB;QAC7B,OAAO;IACT;AACF;AAMO,eAAeM,QAAWsC,EAAoB;IACnD,IAAI;QACF,OAAO,MAAMA;IACf,EAAE,OAAOpB,OAAY;QACnB,IAAIA,iBAAiBxB,wBAAwBwB,MAAMhB,IAAI,KAAK,wBAAwB;YAClF,OAAO;QACT;QACA,MAAMgB;IACR;AACF"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get Box () {
|
|
13
|
+
return Box;
|
|
14
|
+
},
|
|
15
|
+
get Colors () {
|
|
16
|
+
return Colors;
|
|
17
|
+
},
|
|
18
|
+
get Icons () {
|
|
19
|
+
return Icons;
|
|
20
|
+
},
|
|
21
|
+
get UI () {
|
|
22
|
+
return UI;
|
|
23
|
+
},
|
|
24
|
+
get colorize () {
|
|
25
|
+
return colorize;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const Colors = {
|
|
29
|
+
reset: '\x1b[0m',
|
|
30
|
+
bold: '\x1b[1m',
|
|
31
|
+
dim: '\x1b[2m',
|
|
32
|
+
italic: '\x1b[3m',
|
|
33
|
+
underline: '\x1b[4m',
|
|
34
|
+
primary: '\x1b[38;5;51m',
|
|
35
|
+
secondary: '\x1b[38;5;183m',
|
|
36
|
+
accent: '\x1b[38;5;220m',
|
|
37
|
+
success: '\x1b[38;5;82m',
|
|
38
|
+
error: '\x1b[38;5;196m',
|
|
39
|
+
warning: '\x1b[38;5;208m',
|
|
40
|
+
info: '\x1b[38;5;39m',
|
|
41
|
+
text: '\x1b[37m',
|
|
42
|
+
muted: '\x1b[38;5;245m',
|
|
43
|
+
subtle: '\x1b[38;5;240m',
|
|
44
|
+
cyan: '\x1b[38;5;51m',
|
|
45
|
+
green: '\x1b[38;5;82m',
|
|
46
|
+
yellow: '\x1b[38;5;220m',
|
|
47
|
+
red: '\x1b[38;5;196m',
|
|
48
|
+
magenta: '\x1b[38;5;183m',
|
|
49
|
+
blue: '\x1b[38;5;39m',
|
|
50
|
+
gray: '\x1b[38;5;245m',
|
|
51
|
+
white: '\x1b[37m'
|
|
52
|
+
};
|
|
53
|
+
const colorize = (text, color)=>{
|
|
54
|
+
return `${Colors[color]}${text}${Colors.reset}`;
|
|
55
|
+
};
|
|
56
|
+
const Box = {
|
|
57
|
+
topLeft: '╭',
|
|
58
|
+
topRight: '╮',
|
|
59
|
+
bottomLeft: '╰',
|
|
60
|
+
bottomRight: '╯',
|
|
61
|
+
horizontal: '─',
|
|
62
|
+
vertical: '│',
|
|
63
|
+
leftT: '├',
|
|
64
|
+
rightT: '┤',
|
|
65
|
+
topT: '┬',
|
|
66
|
+
bottomT: '┴',
|
|
67
|
+
cross: '┼',
|
|
68
|
+
thickH: '━',
|
|
69
|
+
thickV: '┃'
|
|
70
|
+
};
|
|
71
|
+
const Icons = {
|
|
72
|
+
check: '✓',
|
|
73
|
+
cross: '✗',
|
|
74
|
+
arrow: '❯',
|
|
75
|
+
bullet: '•',
|
|
76
|
+
diamond: '◆',
|
|
77
|
+
star: '★',
|
|
78
|
+
circle: '●',
|
|
79
|
+
dot: '·',
|
|
80
|
+
spinner: [
|
|
81
|
+
'⠋',
|
|
82
|
+
'⠙',
|
|
83
|
+
'⠹',
|
|
84
|
+
'⠸',
|
|
85
|
+
'⠼',
|
|
86
|
+
'⠴',
|
|
87
|
+
'⠦',
|
|
88
|
+
'⠧',
|
|
89
|
+
'⠇',
|
|
90
|
+
'⠏'
|
|
91
|
+
],
|
|
92
|
+
tool: '⏿',
|
|
93
|
+
search: '🔍',
|
|
94
|
+
file: '📄',
|
|
95
|
+
folder: '📁',
|
|
96
|
+
git: '⎇',
|
|
97
|
+
branch: '⎇',
|
|
98
|
+
cloud: '☁',
|
|
99
|
+
rocket: '🚀',
|
|
100
|
+
gear: '⚙',
|
|
101
|
+
lightbulb: '💡',
|
|
102
|
+
sparkles: '✨',
|
|
103
|
+
wand: '🪄',
|
|
104
|
+
robot: '🤖',
|
|
105
|
+
pending: '○',
|
|
106
|
+
inProgress: '◐',
|
|
107
|
+
done: '✓',
|
|
108
|
+
up: '↑',
|
|
109
|
+
down: '↓',
|
|
110
|
+
left: '←',
|
|
111
|
+
right: '→',
|
|
112
|
+
chestnut: '🌰',
|
|
113
|
+
thinkingChestnut: [
|
|
114
|
+
'🌰◜',
|
|
115
|
+
'🌰◠',
|
|
116
|
+
'🌰◝',
|
|
117
|
+
'🌰◞',
|
|
118
|
+
'🌰◡',
|
|
119
|
+
'🌰◟'
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
const UI = {
|
|
123
|
+
line: (width, char = Box.horizontal, color = 'subtle')=>{
|
|
124
|
+
return colorize(char.repeat(width), color);
|
|
125
|
+
},
|
|
126
|
+
box: (content, width = 50, title)=>{
|
|
127
|
+
const lines = [];
|
|
128
|
+
const innerWidth = width - 4;
|
|
129
|
+
if (title) {
|
|
130
|
+
const titleLen = title.length;
|
|
131
|
+
const leftPad = Math.floor((innerWidth - titleLen) / 2);
|
|
132
|
+
const rightPad = innerWidth - titleLen - leftPad;
|
|
133
|
+
lines.push(colorize(Box.topLeft, 'primary') + colorize(Box.horizontal.repeat(leftPad), 'subtle') + colorize(' ' + title + ' ', 'bold') + colorize(Box.horizontal.repeat(rightPad), 'subtle') + colorize(Box.topRight, 'primary'));
|
|
134
|
+
} else {
|
|
135
|
+
lines.push(colorize(Box.topLeft + Box.horizontal.repeat(innerWidth + 2) + Box.topRight, 'primary'));
|
|
136
|
+
}
|
|
137
|
+
for (const line of content){
|
|
138
|
+
const truncated = line.length > innerWidth ? line.slice(0, innerWidth - 1) + '…' : line;
|
|
139
|
+
const padding = ' '.repeat(innerWidth - truncated.length);
|
|
140
|
+
lines.push(colorize(Box.vertical + ' ', 'primary') + truncated + padding + colorize(' ' + Box.vertical, 'primary'));
|
|
141
|
+
}
|
|
142
|
+
lines.push(colorize(Box.bottomLeft + Box.horizontal.repeat(innerWidth + 2) + Box.bottomRight, 'primary'));
|
|
143
|
+
return lines.join('\n');
|
|
144
|
+
},
|
|
145
|
+
header: (text, icon)=>{
|
|
146
|
+
const prefix = icon ? colorize(icon + ' ', 'accent') : '';
|
|
147
|
+
return '\n' + prefix + colorize(text, 'bold') + '\n' + colorize(Box.horizontal.repeat(text.length + (icon ? 2 : 0)), 'subtle');
|
|
148
|
+
},
|
|
149
|
+
kv: (key, value, width = 12)=>{
|
|
150
|
+
const paddedKey = key.padEnd(width);
|
|
151
|
+
return colorize(paddedKey, 'muted') + ' ' + value;
|
|
152
|
+
},
|
|
153
|
+
item: (text, icon = Icons.bullet, iconColor = 'primary')=>{
|
|
154
|
+
return ' ' + colorize(icon, iconColor) + ' ' + text;
|
|
155
|
+
},
|
|
156
|
+
success: (text)=>{
|
|
157
|
+
return colorize(Icons.check + ' ' + text, 'success');
|
|
158
|
+
},
|
|
159
|
+
error: (text)=>{
|
|
160
|
+
return colorize(Icons.cross + ' ' + text, 'error');
|
|
161
|
+
},
|
|
162
|
+
warning: (text)=>{
|
|
163
|
+
return '⚠ ' + colorize(text, 'warning');
|
|
164
|
+
},
|
|
165
|
+
pad: (text, width, align = 'left')=>{
|
|
166
|
+
const len = text.length;
|
|
167
|
+
if (len >= width) return text;
|
|
168
|
+
if (align === 'center') {
|
|
169
|
+
const left = Math.floor((width - len) / 2);
|
|
170
|
+
const right = width - len - left;
|
|
171
|
+
return ' '.repeat(left) + text + ' '.repeat(right);
|
|
172
|
+
} else if (align === 'right') {
|
|
173
|
+
return ' '.repeat(width - len) + text;
|
|
174
|
+
}
|
|
175
|
+
return text + ' '.repeat(width - len);
|
|
176
|
+
},
|
|
177
|
+
progress: (percent, width = 20)=>{
|
|
178
|
+
const filled = Math.round(percent / 100 * width);
|
|
179
|
+
const empty = width - filled;
|
|
180
|
+
const bar = colorize('█'.repeat(filled), 'success') + colorize('░'.repeat(empty), 'subtle');
|
|
181
|
+
return '[' + bar + '] ' + colorize(percent + '%', 'muted');
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/repl/utils/theme.ts"],"sourcesContent":["export const Colors = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n italic: '\\x1b[3m',\n underline: '\\x1b[4m',\n\n primary: '\\x1b[38;5;51m', \n secondary: '\\x1b[38;5;183m',\n accent: '\\x1b[38;5;220m', \n\n success: '\\x1b[38;5;82m', \n error: '\\x1b[38;5;196m', \n warning: '\\x1b[38;5;208m',\n info: '\\x1b[38;5;39m', \n\n text: '\\x1b[37m',\n muted: '\\x1b[38;5;245m', \n subtle: '\\x1b[38;5;240m',\n\n cyan: '\\x1b[38;5;51m',\n green: '\\x1b[38;5;82m',\n yellow: '\\x1b[38;5;220m',\n red: '\\x1b[38;5;196m',\n magenta: '\\x1b[38;5;183m',\n blue: '\\x1b[38;5;39m',\n gray: '\\x1b[38;5;245m',\n white: '\\x1b[37m',\n} as const;\n\nexport const colorize = (text: string, color: keyof typeof Colors): string => {\n return `${Colors[color]}${text}${Colors.reset}`;\n};\n\nexport const Box = {\n topLeft: '╭',\n topRight: '╮',\n bottomLeft: '╰',\n bottomRight: '╯',\n horizontal: '─',\n vertical: '│',\n leftT: '├',\n rightT: '┤',\n topT: '┬',\n bottomT: '┴',\n cross: '┼',\n thickH: '━',\n thickV: '┃',\n} as const;\n\nexport const Icons = {\n check: '✓',\n cross: '✗',\n arrow: '❯',\n bullet: '•',\n diamond: '◆',\n star: '★',\n circle: '●',\n dot: '·',\n spinner: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n tool: '⏿',\n search: '🔍',\n file: '📄',\n folder: '📁',\n git: '⎇',\n branch: '⎇',\n cloud: '☁',\n rocket: '🚀',\n gear: '⚙',\n lightbulb: '💡',\n sparkles: '✨',\n wand: '🪄',\n robot: '🤖',\n pending: '○',\n inProgress: '◐',\n done: '✓',\n up: '↑',\n down: '↓',\n left: '←',\n right: '→',\n chestnut: '🌰',\n thinkingChestnut: ['🌰◜', '🌰◠', '🌰◝', '🌰◞', '🌰◡', '🌰◟'],\n} as const;\n\nexport const UI = {\n line: (width: number, char = Box.horizontal, color: keyof typeof Colors = 'subtle'): string => {\n return colorize(char.repeat(width), color);\n },\n\n box: (content: string[], width = 50, title?: string): string => {\n const lines: string[] = [];\n const innerWidth = width - 4;\n\n if (title) {\n const titleLen = title.length;\n const leftPad = Math.floor((innerWidth - titleLen) / 2);\n const rightPad = innerWidth - titleLen - leftPad;\n lines.push(\n colorize(Box.topLeft, 'primary') +\n colorize(Box.horizontal.repeat(leftPad), 'subtle') +\n colorize(' ' + title + ' ', 'bold') +\n colorize(Box.horizontal.repeat(rightPad), 'subtle') +\n colorize(Box.topRight, 'primary')\n );\n } else {\n lines.push(\n colorize(Box.topLeft + Box.horizontal.repeat(innerWidth + 2) + Box.topRight, 'primary')\n );\n }\n\n for (const line of content) {\n const truncated = line.length > innerWidth ? line.slice(0, innerWidth - 1) + '…' : line;\n const padding = ' '.repeat(innerWidth - truncated.length);\n lines.push(\n colorize(Box.vertical + ' ', 'primary') +\n truncated +\n padding +\n colorize(' ' + Box.vertical, 'primary')\n );\n }\n\n lines.push(\n colorize(Box.bottomLeft + Box.horizontal.repeat(innerWidth + 2) + Box.bottomRight, 'primary')\n );\n\n return lines.join('\\n');\n },\n\n header: (text: string, icon?: string): string => {\n const prefix = icon ? colorize(icon + ' ', 'accent') : '';\n return '\\n' + prefix + colorize(text, 'bold') + '\\n' + colorize(Box.horizontal.repeat(text.length + (icon ? 2 : 0)), 'subtle');\n },\n\n kv: (key: string, value: string, width = 12): string => {\n const paddedKey = key.padEnd(width);\n return colorize(paddedKey, 'muted') + ' ' + value;\n },\n\n item: (text: string, icon = Icons.bullet, iconColor: keyof typeof Colors = 'primary'): string => {\n return ' ' + colorize(icon, iconColor) + ' ' + text;\n },\n\n success: (text: string): string => {\n return colorize(Icons.check + ' ' + text, 'success');\n },\n\n error: (text: string): string => {\n return colorize(Icons.cross + ' ' + text, 'error');\n },\n\n warning: (text: string): string => {\n return '⚠ ' + colorize(text, 'warning');\n },\n\n pad: (text: string, width: number, align: 'left' | 'center' | 'right' = 'left'): string => {\n const len = text.length;\n if (len >= width) return text;\n \n if (align === 'center') {\n const left = Math.floor((width - len) / 2);\n const right = width - len - left;\n return ' '.repeat(left) + text + ' '.repeat(right);\n } else if (align === 'right') {\n return ' '.repeat(width - len) + text;\n }\n return text + ' '.repeat(width - len);\n },\n\n progress: (percent: number, width = 20): string => {\n const filled = Math.round((percent / 100) * width);\n const empty = width - filled;\n const bar = colorize('█'.repeat(filled), 'success') + colorize('░'.repeat(empty), 'subtle');\n return '[' + bar + '] ' + colorize(percent + '%', 'muted');\n },\n} as const;\n"],"names":["Box","Colors","Icons","UI","colorize","reset","bold","dim","italic","underline","primary","secondary","accent","success","error","warning","info","text","muted","subtle","cyan","green","yellow","red","magenta","blue","gray","white","color","topLeft","topRight","bottomLeft","bottomRight","horizontal","vertical","leftT","rightT","topT","bottomT","cross","thickH","thickV","check","arrow","bullet","diamond","star","circle","dot","spinner","tool","search","file","folder","git","branch","cloud","rocket","gear","lightbulb","sparkles","wand","robot","pending","inProgress","done","up","down","left","right","chestnut","thinkingChestnut","line","width","char","repeat","box","content","title","lines","innerWidth","titleLen","length","leftPad","Math","floor","rightPad","push","truncated","slice","padding","join","header","icon","prefix","kv","key","value","paddedKey","padEnd","item","iconColor","pad","align","len","progress","percent","filled","round","empty","bar"],"mappings":";;;;;;;;;;;QAkCaA;eAAAA;;QAlCAC;eAAAA;;QAkDAC;eAAAA;;QAkCAC;eAAAA;;QAtDAC;eAAAA;;;AA9BN,MAAMH,SAAS;IACpBI,OAAO;IACPC,MAAM;IACNC,KAAK;IACLC,QAAQ;IACRC,WAAW;IAEXC,SAAS;IACTC,WAAW;IACXC,QAAQ;IAERC,SAAS;IACTC,OAAO;IACPC,SAAS;IACTC,MAAM;IAENC,MAAM;IACNC,OAAO;IACPC,QAAQ;IAERC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,KAAK;IACLC,SAAS;IACTC,MAAM;IACNC,MAAM;IACNC,OAAO;AAC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