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/repl.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { DeepAgentService } from '../../core/services/deep-agent.service';\nimport { ConfigService } from '../../../common/services/config.service';\nimport { ConfigManagerService } from '../../config/services/config-manager.service';\nimport { MentionsService } from '../../mentions/services/mentions.service';\nimport { McpRegistryService } from '../../mcp/services/mcp-registry.service';\nimport { AgentRegistryService } from '../../agents/services/agent-registry.service';\nimport { SkillRegistryService } from '../../skills/services/skill-registry.service';\nimport { PlanModeService } from '../../core/services/plan-mode.service';\nimport { SmartInput } from './smart-input';\nimport { WelcomeScreenService } from './welcome-screen.service';\nimport { ReplCommandsService } from './commands/repl-commands.service';\nimport { GitCommandsService } from './commands/git-commands.service';\nimport { AgentCommandsService } from './commands/agent-commands.service';\nimport { McpCommandsService } from './commands/mcp-commands.service';\nimport { ConfigCommandsService } from '../../config/services/config-commands.service';\nimport { ProjectCommandsService } from './commands/project-commands.service';\nimport { ToolsRegistryService } from '../../tools/services/tools-registry.service';\nimport { Colors, Icons } from '../utils/theme';\n\n@Injectable()\nexport class ReplService {\n private smartInput: SmartInput | null = null;\n private abortController: AbortController | null = null;\n private isProcessing = false;\n private spinnerTimer: ReturnType<typeof setInterval> | null = null;\n\n constructor(\n private readonly deepAgent: DeepAgentService,\n private readonly configService: ConfigService,\n private readonly configManager: ConfigManagerService,\n private readonly mentionsService: MentionsService,\n private readonly mcpRegistry: McpRegistryService,\n private readonly agentRegistry: AgentRegistryService,\n private readonly skillRegistry: SkillRegistryService,\n private readonly welcomeScreen: WelcomeScreenService,\n private readonly planMode: PlanModeService,\n private readonly replCommands: ReplCommandsService,\n private readonly gitCommands: GitCommandsService,\n private readonly agentCommands: AgentCommandsService,\n private readonly mcpCommands: McpCommandsService,\n private readonly configCommands: ConfigCommandsService,\n private readonly projectCommands: ProjectCommandsService,\n private readonly toolsRegistry: ToolsRegistryService,\n ) {}\n\n async start(): Promise<void> {\n const initResult = await this.deepAgent.initialize();\n const agentCount = this.agentRegistry.resolveAllAgents().length;\n\n this.welcomeScreen.printWelcomeScreen({\n projectPath: initResult.projectPath || undefined,\n model: this.getModelDisplayName(),\n toolCount: initResult.toolCount,\n agentCount,\n });\n\n this.smartInput = new SmartInput({\n prompt: `${Colors.cyan}${Colors.bold}>${Colors.reset} `,\n promptVisibleLen: 2,\n getCommandSuggestions: (input) => this.getCommandSuggestions(input),\n getMentionSuggestions: (partial) => this.getMentionSuggestions(partial),\n onSubmit: (line) => this.handleLine(line),\n onCancel: () => this.handleCancel(),\n onExit: () => this.handleExit(),\n });\n\n this.smartInput.start();\n }\n\n private getCommandSuggestions(input: string): Array<{ text: string; display: string; description: string }> {\n const commands = [\n { text: '/help', display: '/help', description: 'Show help' },\n { text: '/clear', display: '/clear', description: 'Clear conversation' },\n { text: '/compact', display: '/compact', description: 'Compact history' },\n { text: '/exit', display: '/exit', description: 'Exit' },\n { text: '/status', display: '/status', description: 'Git status' },\n { text: '/diff', display: '/diff', description: 'Git diff' },\n { text: '/log', display: '/log', description: 'Git log' },\n { text: '/commit', display: '/commit', description: 'Commit changes' },\n { text: '/up', display: '/up', description: 'Smart commit & push' },\n { text: '/split-up', display: '/split-up', description: 'Split commits' },\n { text: '/pr', display: '/pr', description: 'Create Pull Request' },\n { text: '/review', display: '/review', description: 'Code review' },\n { text: '/fix', display: '/fix', description: 'Auto-fix code' },\n { text: '/ident', display: '/ident', description: 'Format code' },\n { text: '/release', display: '/release', description: 'Release notes' },\n { text: '/tools', display: '/tools', description: 'List tools' },\n { text: '/agents', display: '/agents', description: 'List agents' },\n { text: '/skills', display: '/skills', description: 'List skills' },\n { text: '/context', display: '/context', description: 'Session info' },\n { text: '/mentions', display: '/mentions', description: 'Mentions help' },\n { text: '/model', display: '/model', description: 'Show model' },\n { text: '/config', display: '/config', description: 'Configuration' },\n { text: '/project', display: '/project', description: 'Project context' },\n { text: '/project-deep', display: '/project-deep', description: 'Deep project analysis' },\n { text: '/init', display: '/init', description: 'Analyze project and generate context' },\n { text: '/mcp', display: '/mcp', description: 'MCP servers' },\n ];\n\n return commands.filter(c => c.text.startsWith(input));\n }\n\n private getMentionSuggestions(partial: string): Array<{ text: string; display: string; description: string }> {\n const fs = require('fs');\n const path = require('path');\n\n const gitOpts = [\n { text: '@git:status', display: '@git:status', description: 'Git status' },\n { text: '@git:diff', display: '@git:diff', description: 'Git diff' },\n { text: '@git:log', display: '@git:log', description: 'Git log' },\n { text: '@git:branch', display: '@git:branch', description: 'Branches' },\n ];\n\n if (partial === '') return [...gitOpts, ...this.getFileEntries('')];\n if (partial.startsWith('git:')) return gitOpts.filter(o => o.text.startsWith('@' + partial));\n\n return [...gitOpts.filter(o => o.text.startsWith('@' + partial)), ...this.getFileEntries(partial)].slice(0, 30);\n }\n\n private getFileEntries(partial: string): Array<{ text: string; display: string; description: string }> {\n const fs = require('fs');\n const path = require('path');\n\n try {\n let dir: string;\n let prefix: string;\n\n if (partial.endsWith('/')) {\n dir = partial.slice(0, -1) || '.';\n prefix = '';\n } else if (partial.includes('/')) {\n dir = path.dirname(partial);\n prefix = path.basename(partial);\n } else {\n dir = '.';\n prefix = partial;\n }\n\n const resolved = path.resolve(process.cwd(), dir);\n if (!fs.existsSync(resolved) || !fs.statSync(resolved).isDirectory()) return [];\n\n const entries = fs.readdirSync(resolved, { withFileTypes: true });\n const ignore = ['node_modules', '.git', 'dist', 'coverage', '.next', '__pycache__'];\n\n return entries\n .filter(e => !ignore.includes(e.name))\n .filter(e => !e.name.startsWith('.') || prefix.startsWith('.'))\n .filter(e => prefix === '' || e.name.toLowerCase().startsWith(prefix.toLowerCase()))\n .map(e => {\n const relDir = dir === '.' ? '' : dir + '/';\n const isDir = e.isDirectory();\n return {\n text: '@' + relDir + e.name + (isDir ? '/' : ''),\n display: '@' + relDir + e.name + (isDir ? '/' : ''),\n description: isDir ? 'dir' : '',\n };\n })\n .slice(0, 20);\n } catch {\n return [];\n }\n }\n\n private handleCancel(): void {\n if (this.isProcessing && this.abortController) {\n this.abortController.abort();\n this.stopSpinner();\n process.stdout.write(`\\r\\n${Colors.yellow} Cancelled${Colors.reset}\\r\\n\\r\\n`);\n this.isProcessing = false;\n } else {\n process.stdout.write(`${Colors.dim} (Use /exit to quit)${Colors.reset}\\r\\n`);\n this.smartInput?.showPrompt();\n }\n }\n\n private handleExit(): void {\n process.stdout.write(`${Colors.dim} Goodbye!${Colors.reset}\\r\\n`);\n this.stop();\n process.exit(0);\n }\n\n private async handleLine(input: string): Promise<void> {\n const trimmed = input.trim();\n\n if (!trimmed) {\n this.smartInput?.showPrompt();\n return;\n }\n\n if (trimmed.startsWith('/')) {\n await this.handleCommand(trimmed);\n } else {\n await this.handleMessage(trimmed);\n }\n\n this.smartInput?.showPrompt();\n }\n\n private async handleCommand(command: string): Promise<void> {\n const parts = command.slice(1).split(/\\s+/);\n const cmd = parts[0].toLowerCase();\n const args = parts.slice(1);\n\n switch (cmd) {\n case 'help': this.replCommands.printHelp(); break;\n case 'clear': this.replCommands.cmdClear(this.welcomeScreen); break;\n case 'exit':\n case 'quit': this.handleExit(); return;\n case 'compact': await this.handleCompact(); break;\n case 'context': this.replCommands.cmdContext(); break;\n case 'config': \n await this.configCommands.handleConfigCommand(args, this.smartInput!); \n break;\n case 'model': this.replCommands.cmdModel(args); break;\n case 'init':\n await this.projectCommands.cmdProject(['analyze'], this.smartInput!);\n break;\n case 'mentions': this.replCommands.cmdMentionsHelp(); break;\n case 'tools': this.cmdTools(); break;\n\n case 'status': this.gitCommands.runGit('git status'); break;\n case 'diff': this.gitCommands.runGit(args.length ? `git diff ${args.join(' ')}` : 'git diff'); break;\n case 'log': this.gitCommands.runGit('git log --oneline -15'); break;\n case 'commit': \n await this.gitCommands.cmdCommit(args, this.smartInput!); \n break;\n case 'up': \n await this.gitCommands.cmdUp(this.smartInput!); \n break;\n case 'split-up': \n await this.gitCommands.cmdSplitUp(this.smartInput!); \n break;\n case 'pr': \n await this.gitCommands.cmdPr(this.smartInput!); \n break;\n case 'review': await this.gitCommands.cmdReview(args); break;\n case 'fix': await this.gitCommands.cmdFix(args); break;\n case 'ident': await this.gitCommands.cmdIdent(); break;\n case 'release': await this.gitCommands.cmdRelease(args); break;\n\n case 'agents': \n await this.agentCommands.cmdAgents(args, this.smartInput!); \n break;\n case 'skills': \n await this.agentCommands.cmdSkills(args, this.smartInput!); \n break;\n\n case 'mcp': \n await this.mcpCommands.cmdMcp(args, this.smartInput!); \n break;\n\n case 'project':\n await this.projectCommands.cmdProject(args, this.smartInput!);\n break;\n case 'project-deep':\n await this.projectCommands.cmdProject(['deep'], this.smartInput!);\n break;\n\n default:\n process.stdout.write(`${Colors.red} Unknown: /${cmd}${Colors.reset} ${Colors.dim}Try /help${Colors.reset}\\r\\n`);\n }\n }\n\n private async handleCompact(): Promise<void> {\n const msgCount = this.deepAgent.getMessageCount();\n if (msgCount < 4) {\n process.stdout.write(`${Colors.dim} Nothing to compact (${msgCount} messages)${Colors.reset}\\r\\n`);\n return;\n }\n process.stdout.write(`${Colors.dim} Summarizing ${msgCount} messages...${Colors.reset}\\r\\n`);\n const result = await this.deepAgent.compactHistory();\n if (result.compacted) {\n process.stdout.write(`${Colors.green} Compacted: ${result.messagesBefore} → ${result.messagesAfter} messages${Colors.reset}\\r\\n`);\n } else {\n process.stdout.write(`${Colors.yellow} Could not compact (summarization failed)${Colors.reset}\\r\\n`);\n }\n }\n\n private async handleMessage(message: string): Promise<void> {\n this.isProcessing = true;\n this.abortController = new AbortController();\n this.smartInput?.enterPassiveMode();\n\n try {\n let messageToProcess = message;\n\n const planCheck = await this.planMode.shouldEnterPlanMode(message);\n if (planCheck.shouldPlan) {\n const usePlan = await this.smartInput!.askChoice(\n '📝 Complex task. Create a plan?',\n [\n { key: 'y', label: 'yes', description: 'Create structured plan' },\n { key: 'n', label: 'no', description: 'Proceed without plan' },\n ]\n );\n \n if (usePlan === 'y') {\n const plannedMessage = await this.runInteractivePlanMode(message);\n if (!plannedMessage) {\n this.isProcessing = false;\n this.smartInput?.exitPassiveMode();\n return;\n }\n messageToProcess = plannedMessage;\n }\n }\n\n const mentionResult = await this.mentionsService.processMessage(messageToProcess);\n if (mentionResult.mentions.length > 0) {\n const summary = this.mentionsService.getMentionsSummary(mentionResult.mentions);\n for (const line of summary) {\n process.stdout.write(`${Colors.dim}${line}${Colors.reset}\\r\\n`);\n }\n process.stdout.write('\\r\\n');\n }\n\n this.startSpinner('Thinking');\n\n let firstChunk = true;\n let fullResponse = '';\n\n for await (const chunk of this.deepAgent.chat(mentionResult.expandedMessage)) {\n if (this.abortController?.signal.aborted) break;\n\n const isToolOutput = chunk.includes('\\x1b[') && (\n chunk.includes('⏿') ||\n chunk.includes('tokens:') ||\n chunk.includes('conversation compacted')\n );\n\n if (firstChunk && !isToolOutput) {\n this.stopSpinner();\n process.stdout.write(`\\r\\n${Colors.magenta}${Colors.bold}${Icons.chestnut} Cast${Colors.reset}\\r\\n`);\n firstChunk = false;\n }\n\n if (!isToolOutput) {\n fullResponse += chunk;\n }\n process.stdout.write(chunk);\n }\n\n if (!firstChunk) {\n process.stdout.write('\\r\\n');\n } else {\n this.stopSpinner();\n }\n } catch (error) {\n this.stopSpinner();\n const msg = (error as Error).message;\n if (!msg.includes('abort')) {\n process.stdout.write(`\\r\\n${Colors.red} Error: ${msg}${Colors.reset}\\r\\n\\r\\n`);\n }\n } finally {\n this.isProcessing = false;\n this.abortController = null;\n this.smartInput?.exitPassiveMode();\n }\n }\n\n private async runInteractivePlanMode(userMessage: string): Promise<string | null> {\n process.stdout.write(`\\r\\n${Colors.cyan}${Colors.bold}📋 PLAN MODE${Colors.reset}\\r\\n`);\n process.stdout.write(`${Colors.dim}Build plan first, execute after approval${Colors.reset}\\r\\n\\r\\n`);\n\n const clarifyingQuestions = await this.planMode.generateClarifyingQuestions(userMessage);\n const answers: string[] = [];\n\n if (clarifyingQuestions.length > 0) {\n process.stdout.write(`${Colors.dim}I need a few quick clarifications:${Colors.reset}\\r\\n`);\n for (let i = 0; i < clarifyingQuestions.length; i++) {\n const q = clarifyingQuestions[i];\n const answer = await this.smartInput!.question(`${Colors.yellow}Q${i + 1}:${Colors.reset} ${q} `);\n if (answer.trim()) {\n answers.push(`- ${q} => ${answer.trim()}`);\n }\n }\n process.stdout.write('\\r\\n');\n }\n\n const context = answers.length > 0 ? `User clarifications:\\n${answers.join('\\n')}` : undefined;\n let plan = await this.planMode.generatePlan(userMessage, context);\n\n while (true) {\n process.stdout.write(this.planMode.formatPlanForDisplay(plan));\n\n const action = await this.smartInput!.askChoice('Plan options', [\n { key: 'a', label: 'accept', description: 'Use this plan and continue' },\n { key: 'r', label: 'refine', description: 'Refine plan with extra feedback' },\n { key: 'c', label: 'cancel', description: 'Cancel and return to prompt' },\n ]);\n\n if (action === 'c') {\n process.stdout.write(`${Colors.dim} Plan cancelled${Colors.reset}\\r\\n\\r\\n`);\n return null;\n }\n\n if (action === 'r') {\n const feedback = await this.smartInput!.question(`${Colors.cyan}Refinement feedback:${Colors.reset} `);\n if (!feedback.trim()) {\n process.stdout.write(`${Colors.dim} No feedback provided. Keeping current plan.${Colors.reset}\\r\\n\\r\\n`);\n continue;\n }\n plan = await this.planMode.refinePlan(plan, feedback.trim());\n continue;\n }\n\n return this.buildPlanExecutionPrompt(userMessage, plan, answers);\n }\n }\n\n private buildPlanExecutionPrompt(userMessage: string, plan: { title: string; overview: string; steps: Array<{ id: number; description: string; files: string[] }> }, clarifications: string[]): string {\n const lines: string[] = [];\n lines.push(userMessage);\n lines.push('');\n lines.push('Approved execution plan:');\n lines.push(`Title: ${plan.title}`);\n lines.push(`Overview: ${plan.overview}`);\n lines.push('Steps:');\n for (const step of plan.steps) {\n const files = step.files.length > 0 ? ` | files: ${step.files.join(', ')}` : '';\n lines.push(`${step.id}. ${step.description}${files}`);\n }\n if (clarifications.length > 0) {\n lines.push('');\n lines.push('User clarifications:');\n lines.push(...clarifications);\n }\n lines.push('');\n lines.push('Execute the task following this approved plan and report progress by step.');\n return lines.join('\\n');\n }\n\n private startSpinner(label: string): void {\n let i = 0;\n this.spinnerTimer = setInterval(() => {\n process.stdout.write(`\\r${Colors.cyan}${Icons.thinkingChestnut[i++ % Icons.thinkingChestnut.length]}${Colors.reset} ${Colors.dim}${label}...${Colors.reset}`);\n }, 80);\n }\n\n private stopSpinner(): void {\n if (this.spinnerTimer) {\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n process.stdout.write('\\r\\x1b[K');\n }\n }\n\n private cmdTools(): void {\n const allTools = this.toolsRegistry.getAllTools();\n const tools: [string, string][] = allTools.map(t => [t.name, t.description.slice(0, 60)]);\n\n if (tools.length > 0) {\n const maxLen = Math.max(...tools.map(([n]) => n.length));\n\n process.stdout.write('\\r\\n');\n process.stdout.write(`${Colors.bold}Built-in Tools (${tools.length}):${Colors.reset}\\r\\n`);\n for (const [name, desc] of tools) {\n process.stdout.write(` ${Colors.cyan}${name.padEnd(maxLen)}${Colors.reset} ${Colors.dim}${desc}${Colors.reset}\\r\\n`);\n }\n }\n\n const mcpTools = this.mcpRegistry.getAllMcpTools();\n if (mcpTools.length > 0) {\n process.stdout.write(`\\r\\n${Colors.bold}MCP Tools (${mcpTools.length}):${Colors.reset}\\r\\n`);\n for (const t of mcpTools.slice(0, 10)) {\n process.stdout.write(` ${Colors.cyan}${t.name}${Colors.reset} ${Colors.dim}${t.description.slice(0, 50)}${Colors.reset}\\r\\n`);\n }\n }\n process.stdout.write('\\r\\n');\n }\n\n private getModelDisplayName(): string {\n try {\n const modelConfig = this.configManager.getModelConfig('default');\n if (modelConfig) {\n return `${modelConfig.provider}/${modelConfig.model}`;\n }\n } catch {\n }\n return `${this.configService.getProvider()}/${this.configService.getModel()}`;\n }\n\n stop(): void {\n this.stopSpinner();\n this.smartInput?.destroy();\n }\n}\n"],"names":["ReplService","start","initResult","deepAgent","initialize","agentCount","agentRegistry","resolveAllAgents","length","welcomeScreen","printWelcomeScreen","projectPath","undefined","model","getModelDisplayName","toolCount","smartInput","SmartInput","prompt","Colors","cyan","bold","reset","promptVisibleLen","getCommandSuggestions","input","getMentionSuggestions","partial","onSubmit","line","handleLine","onCancel","handleCancel","onExit","handleExit","commands","text","display","description","filter","c","startsWith","fs","require","path","gitOpts","getFileEntries","o","slice","dir","prefix","endsWith","includes","dirname","basename","resolved","resolve","process","cwd","existsSync","statSync","isDirectory","entries","readdirSync","withFileTypes","ignore","e","name","toLowerCase","map","relDir","isDir","isProcessing","abortController","abort","stopSpinner","stdout","write","yellow","dim","showPrompt","stop","exit","trimmed","trim","handleCommand","handleMessage","command","parts","split","cmd","args","replCommands","printHelp","cmdClear","handleCompact","cmdContext","configCommands","handleConfigCommand","cmdModel","projectCommands","cmdProject","cmdMentionsHelp","cmdTools","gitCommands","runGit","join","cmdCommit","cmdUp","cmdSplitUp","cmdPr","cmdReview","cmdFix","cmdIdent","cmdRelease","agentCommands","cmdAgents","cmdSkills","mcpCommands","cmdMcp","red","msgCount","getMessageCount","result","compactHistory","compacted","green","messagesBefore","messagesAfter","message","AbortController","enterPassiveMode","messageToProcess","planCheck","planMode","shouldEnterPlanMode","shouldPlan","usePlan","askChoice","key","label","plannedMessage","runInteractivePlanMode","exitPassiveMode","mentionResult","mentionsService","processMessage","mentions","summary","getMentionsSummary","startSpinner","firstChunk","fullResponse","chunk","chat","expandedMessage","signal","aborted","isToolOutput","magenta","Icons","chestnut","error","msg","userMessage","clarifyingQuestions","generateClarifyingQuestions","answers","i","q","answer","question","push","context","plan","generatePlan","formatPlanForDisplay","action","feedback","refinePlan","buildPlanExecutionPrompt","clarifications","lines","title","overview","step","steps","files","id","spinnerTimer","setInterval","thinkingChestnut","clearInterval","allTools","toolsRegistry","getAllTools","tools","t","maxLen","Math","max","n","desc","padEnd","mcpTools","mcpRegistry","getAllMcpTools","modelConfig","configManager","getModelConfig","provider","configService","getProvider","getModel","destroy","skillRegistry"],"mappings":";;;;+BAqBaA;;;eAAAA;;;wBArBc;kCACM;+BACH;sCACO;iCACL;oCACG;sCACE;sCACA;iCACL;4BACL;sCACU;qCACD;oCACD;sCACE;oCACF;uCACG;wCACC;sCACF;uBACP;;;;;;;;;;AAGvB,IAAA,AAAMA,cAAN,MAAMA;IAyBX,MAAMC,QAAuB;QAC3B,MAAMC,aAAa,MAAM,IAAI,CAACC,SAAS,CAACC,UAAU;QAClD,MAAMC,aAAa,IAAI,CAACC,aAAa,CAACC,gBAAgB,GAAGC,MAAM;QAE/D,IAAI,CAACC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XlL,aAAgC;aAChCyD,kBAA0C;aAC1CD,eAAe;aACfqH,eAAsD;IAmB3D;AA2bL"}
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SmartInput", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SmartInput;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _theme = require("../utils/theme");
|
|
12
|
+
let SmartInput = class SmartInput {
|
|
13
|
+
start() {
|
|
14
|
+
if (process.stdin.isTTY) {
|
|
15
|
+
process.stdin.setRawMode(true);
|
|
16
|
+
}
|
|
17
|
+
process.stdin.resume();
|
|
18
|
+
process.stdin.setEncoding('utf8');
|
|
19
|
+
this.terminalWidth = process.stdout.columns || 80;
|
|
20
|
+
// Listener para redimensionamento
|
|
21
|
+
process.stdout.on('resize', ()=>{
|
|
22
|
+
this.terminalWidth = process.stdout.columns || 80;
|
|
23
|
+
});
|
|
24
|
+
this.dataHandler = (data)=>this.handleData(data);
|
|
25
|
+
process.stdin.on('data', this.dataHandler);
|
|
26
|
+
this.mode = 'input';
|
|
27
|
+
this.render();
|
|
28
|
+
}
|
|
29
|
+
enterPassiveMode() {
|
|
30
|
+
this.mode = 'passive';
|
|
31
|
+
this.clearSuggestions();
|
|
32
|
+
}
|
|
33
|
+
exitPassiveMode() {
|
|
34
|
+
this.mode = 'input';
|
|
35
|
+
}
|
|
36
|
+
showPrompt() {
|
|
37
|
+
this.buffer = '';
|
|
38
|
+
this.cursor = 0;
|
|
39
|
+
this.suggestions = [];
|
|
40
|
+
this.selectedIndex = -1;
|
|
41
|
+
this.mode = 'input';
|
|
42
|
+
this.render();
|
|
43
|
+
}
|
|
44
|
+
async question(query) {
|
|
45
|
+
this.mode = 'question';
|
|
46
|
+
this.questionBuffer = '';
|
|
47
|
+
process.stdout.write(query + ' ');
|
|
48
|
+
return new Promise((resolve)=>{
|
|
49
|
+
this.questionResolve = resolve;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async askChoice(message, choices) {
|
|
53
|
+
process.stdout.write(`\r\n${_theme.Colors.cyan}${message}${_theme.Colors.reset}\r\n\r\n`);
|
|
54
|
+
choices.forEach((ch, i)=>{
|
|
55
|
+
const desc = ch.description ? `${_theme.Colors.dim} - ${ch.description}${_theme.Colors.reset}` : '';
|
|
56
|
+
process.stdout.write(` ${_theme.Colors.white}${i + 1}.${_theme.Colors.reset} ${_theme.Colors.bold}${ch.label}${_theme.Colors.reset}${desc}\r\n`);
|
|
57
|
+
});
|
|
58
|
+
process.stdout.write('\r\n');
|
|
59
|
+
while(true){
|
|
60
|
+
const answer = await this.question(`${_theme.Colors.yellow}Choose (1-${choices.length}):${_theme.Colors.reset}`);
|
|
61
|
+
const idx = parseInt(answer) - 1;
|
|
62
|
+
if (idx >= 0 && idx < choices.length) {
|
|
63
|
+
return choices[idx].key;
|
|
64
|
+
}
|
|
65
|
+
process.stdout.write(`${_theme.Colors.red} Invalid choice, try again.${_theme.Colors.reset}\r\n`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
pause() {
|
|
69
|
+
this.isPaused = true;
|
|
70
|
+
if (this.dataHandler) {
|
|
71
|
+
process.stdin.removeListener('data', this.dataHandler);
|
|
72
|
+
}
|
|
73
|
+
if (process.stdin.isTTY) {
|
|
74
|
+
process.stdin.setRawMode(false);
|
|
75
|
+
}
|
|
76
|
+
this.clearSuggestions();
|
|
77
|
+
process.stdout.write('\r\n');
|
|
78
|
+
}
|
|
79
|
+
resume() {
|
|
80
|
+
this.isPaused = false;
|
|
81
|
+
if (this.dataHandler) {
|
|
82
|
+
process.stdin.on('data', this.dataHandler);
|
|
83
|
+
}
|
|
84
|
+
if (process.stdin.isTTY) {
|
|
85
|
+
process.stdin.setRawMode(true);
|
|
86
|
+
}
|
|
87
|
+
process.stdin.resume();
|
|
88
|
+
this.showPrompt();
|
|
89
|
+
}
|
|
90
|
+
destroy() {
|
|
91
|
+
this.clearSuggestions();
|
|
92
|
+
if (this.dataHandler) {
|
|
93
|
+
process.stdin.removeListener('data', this.dataHandler);
|
|
94
|
+
this.dataHandler = null;
|
|
95
|
+
}
|
|
96
|
+
if (process.stdin.isTTY) {
|
|
97
|
+
process.stdin.setRawMode(false);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
handleData(data) {
|
|
101
|
+
if (this.isPaused) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (this.mode === 'passive') {
|
|
105
|
+
for (const ch of data){
|
|
106
|
+
if (ch.charCodeAt(0) === 0x03) {
|
|
107
|
+
this.opts.onCancel();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.mode === 'question') {
|
|
113
|
+
this.handleQuestionData(data);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.handleInputData(data);
|
|
117
|
+
}
|
|
118
|
+
handleQuestionData(data) {
|
|
119
|
+
const write = (s)=>process.stdout.write(s);
|
|
120
|
+
for(let i = 0; i < data.length; i++){
|
|
121
|
+
const code = data.charCodeAt(i);
|
|
122
|
+
if (code === 0x0d || code === 0x0a) {
|
|
123
|
+
write('\r\n');
|
|
124
|
+
const resolve = this.questionResolve;
|
|
125
|
+
const answer = this.questionBuffer;
|
|
126
|
+
this.questionResolve = null;
|
|
127
|
+
this.questionBuffer = '';
|
|
128
|
+
this.mode = 'input';
|
|
129
|
+
if (resolve) resolve(answer);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (code === 0x7f || code === 0x08) {
|
|
133
|
+
if (this.questionBuffer.length > 0) {
|
|
134
|
+
this.questionBuffer = this.questionBuffer.slice(0, -1);
|
|
135
|
+
write('\b \b');
|
|
136
|
+
}
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (code === 0x03) {
|
|
140
|
+
write('\r\n');
|
|
141
|
+
const resolve = this.questionResolve;
|
|
142
|
+
this.questionResolve = null;
|
|
143
|
+
this.questionBuffer = '';
|
|
144
|
+
this.mode = 'input';
|
|
145
|
+
if (resolve) resolve('');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (code >= 0x20) {
|
|
149
|
+
this.questionBuffer += data[i];
|
|
150
|
+
write(data[i]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
handleInputData(data) {
|
|
155
|
+
let needsRender = false;
|
|
156
|
+
let bufferChanged = false;
|
|
157
|
+
let i = 0;
|
|
158
|
+
while(i < data.length){
|
|
159
|
+
if (data[i] === '\x1b' && data[i + 1] === '[') {
|
|
160
|
+
const rest = data.slice(i);
|
|
161
|
+
if (rest.startsWith('\x1b[A')) {
|
|
162
|
+
this.keyUp();
|
|
163
|
+
i += 3;
|
|
164
|
+
needsRender = true;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (rest.startsWith('\x1b[B')) {
|
|
168
|
+
this.keyDown();
|
|
169
|
+
i += 3;
|
|
170
|
+
needsRender = true;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (rest.startsWith('\x1b[C')) {
|
|
174
|
+
this.keyRight();
|
|
175
|
+
i += 3;
|
|
176
|
+
needsRender = true;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (rest.startsWith('\x1b[D')) {
|
|
180
|
+
this.keyLeft();
|
|
181
|
+
i += 3;
|
|
182
|
+
needsRender = true;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (rest.startsWith('\x1b[H')) {
|
|
186
|
+
this.cursor = 0;
|
|
187
|
+
i += 3;
|
|
188
|
+
needsRender = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (rest.startsWith('\x1b[F')) {
|
|
192
|
+
this.cursor = this.buffer.length;
|
|
193
|
+
i += 3;
|
|
194
|
+
needsRender = true;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (rest.startsWith('\x1b[3~')) {
|
|
198
|
+
this.keyDelete();
|
|
199
|
+
i += 4;
|
|
200
|
+
needsRender = true;
|
|
201
|
+
bufferChanged = true;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
i++;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const code = data.charCodeAt(i);
|
|
208
|
+
switch(code){
|
|
209
|
+
case 0x0d:
|
|
210
|
+
case 0x0a:
|
|
211
|
+
this.keyEnter();
|
|
212
|
+
i++;
|
|
213
|
+
continue;
|
|
214
|
+
case 0x09:
|
|
215
|
+
this.keyTab();
|
|
216
|
+
needsRender = true;
|
|
217
|
+
break;
|
|
218
|
+
case 0x7f:
|
|
219
|
+
case 0x08:
|
|
220
|
+
this.keyBackspace();
|
|
221
|
+
needsRender = true;
|
|
222
|
+
bufferChanged = true;
|
|
223
|
+
break;
|
|
224
|
+
case 0x03:
|
|
225
|
+
this.keyCtrlC();
|
|
226
|
+
i++;
|
|
227
|
+
continue;
|
|
228
|
+
case 0x04:
|
|
229
|
+
if (this.buffer.length === 0) {
|
|
230
|
+
this.clearSuggestions();
|
|
231
|
+
process.stdout.write('\r\n');
|
|
232
|
+
this.opts.onExit();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
case 0x0c:
|
|
237
|
+
this.clearSuggestions();
|
|
238
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
239
|
+
needsRender = true;
|
|
240
|
+
break;
|
|
241
|
+
case 0x15:
|
|
242
|
+
this.buffer = this.buffer.slice(this.cursor);
|
|
243
|
+
this.cursor = 0;
|
|
244
|
+
needsRender = true;
|
|
245
|
+
bufferChanged = true;
|
|
246
|
+
break;
|
|
247
|
+
case 0x0b:
|
|
248
|
+
this.buffer = this.buffer.slice(0, this.cursor);
|
|
249
|
+
needsRender = true;
|
|
250
|
+
bufferChanged = true;
|
|
251
|
+
break;
|
|
252
|
+
case 0x01:
|
|
253
|
+
this.cursor = 0;
|
|
254
|
+
needsRender = true;
|
|
255
|
+
break;
|
|
256
|
+
case 0x05:
|
|
257
|
+
this.cursor = this.buffer.length;
|
|
258
|
+
needsRender = true;
|
|
259
|
+
break;
|
|
260
|
+
case 0x17:
|
|
261
|
+
this.deleteWordBack();
|
|
262
|
+
needsRender = true;
|
|
263
|
+
bufferChanged = true;
|
|
264
|
+
break;
|
|
265
|
+
case 0x0f:
|
|
266
|
+
if (this.opts.onExpandToolOutput) {
|
|
267
|
+
this.clearSuggestions();
|
|
268
|
+
process.stdout.write('\r\n');
|
|
269
|
+
this.opts.onExpandToolOutput();
|
|
270
|
+
needsRender = true;
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
if (code >= 0x20) {
|
|
275
|
+
this.buffer = this.buffer.slice(0, this.cursor) + data[i] + this.buffer.slice(this.cursor);
|
|
276
|
+
this.cursor++;
|
|
277
|
+
needsRender = true;
|
|
278
|
+
bufferChanged = true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
i++;
|
|
282
|
+
}
|
|
283
|
+
if (needsRender) {
|
|
284
|
+
if (bufferChanged) {
|
|
285
|
+
this.computeSuggestions();
|
|
286
|
+
}
|
|
287
|
+
this.render();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
keyUp() {
|
|
291
|
+
if (this.suggestions.length > 0) {
|
|
292
|
+
this.selectedIndex = this.selectedIndex <= 0 ? this.suggestions.length - 1 : this.selectedIndex - 1;
|
|
293
|
+
} else {
|
|
294
|
+
if (this.historyIndex === -1) this.savedBuffer = this.buffer;
|
|
295
|
+
if (this.historyIndex < this.history.length - 1) {
|
|
296
|
+
this.historyIndex++;
|
|
297
|
+
this.buffer = this.history[this.historyIndex];
|
|
298
|
+
this.cursor = this.buffer.length;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
keyDown() {
|
|
303
|
+
if (this.suggestions.length > 0) {
|
|
304
|
+
this.selectedIndex = this.selectedIndex >= this.suggestions.length - 1 ? 0 : this.selectedIndex + 1;
|
|
305
|
+
} else {
|
|
306
|
+
if (this.historyIndex > 0) {
|
|
307
|
+
this.historyIndex--;
|
|
308
|
+
this.buffer = this.history[this.historyIndex];
|
|
309
|
+
this.cursor = this.buffer.length;
|
|
310
|
+
} else if (this.historyIndex === 0) {
|
|
311
|
+
this.historyIndex = -1;
|
|
312
|
+
this.buffer = this.savedBuffer;
|
|
313
|
+
this.cursor = this.buffer.length;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
keyLeft() {
|
|
318
|
+
if (this.cursor > 0) this.cursor--;
|
|
319
|
+
}
|
|
320
|
+
keyRight() {
|
|
321
|
+
if (this.cursor < this.buffer.length) this.cursor++;
|
|
322
|
+
}
|
|
323
|
+
keyBackspace() {
|
|
324
|
+
if (this.cursor > 0) {
|
|
325
|
+
this.buffer = this.buffer.slice(0, this.cursor - 1) + this.buffer.slice(this.cursor);
|
|
326
|
+
this.cursor--;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
keyDelete() {
|
|
330
|
+
if (this.cursor < this.buffer.length) {
|
|
331
|
+
this.buffer = this.buffer.slice(0, this.cursor) + this.buffer.slice(this.cursor + 1);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
keyEnter() {
|
|
335
|
+
if (this.selectedIndex >= 0 && this.suggestions.length > 0) {
|
|
336
|
+
this.acceptSuggestion();
|
|
337
|
+
this.computeSuggestions();
|
|
338
|
+
this.render();
|
|
339
|
+
} else {
|
|
340
|
+
this.submitLine();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
keyTab() {
|
|
344
|
+
if (this.suggestions.length > 0) {
|
|
345
|
+
if (this.selectedIndex < 0) {
|
|
346
|
+
this.selectedIndex = 0;
|
|
347
|
+
this.acceptSuggestion();
|
|
348
|
+
this.computeSuggestions();
|
|
349
|
+
} else {
|
|
350
|
+
this.acceptSuggestion();
|
|
351
|
+
this.computeSuggestions();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
keyCtrlC() {
|
|
356
|
+
if (this.buffer.length > 0) {
|
|
357
|
+
this.buffer = '';
|
|
358
|
+
this.cursor = 0;
|
|
359
|
+
this.suggestions = [];
|
|
360
|
+
this.selectedIndex = -1;
|
|
361
|
+
this.lastCtrlCTime = Date.now();
|
|
362
|
+
this.clearSuggestions();
|
|
363
|
+
process.stdout.write('\r\n');
|
|
364
|
+
this.render();
|
|
365
|
+
} else {
|
|
366
|
+
const now = Date.now();
|
|
367
|
+
if (now - this.lastCtrlCTime < 1500) {
|
|
368
|
+
this.clearSuggestions();
|
|
369
|
+
process.stdout.write('\r\n');
|
|
370
|
+
this.opts.onExit();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.lastCtrlCTime = now;
|
|
374
|
+
this.clearSuggestions();
|
|
375
|
+
process.stdout.write(`\r\n${_theme.Colors.dim} Press Ctrl+C again to exit${_theme.Colors.reset}\r\n`);
|
|
376
|
+
this.render();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
deleteWordBack() {
|
|
380
|
+
const before = this.buffer.slice(0, this.cursor);
|
|
381
|
+
const match = before.match(/\S+\s*$/);
|
|
382
|
+
if (match) {
|
|
383
|
+
const len = match[0].length;
|
|
384
|
+
this.buffer = this.buffer.slice(0, this.cursor - len) + this.buffer.slice(this.cursor);
|
|
385
|
+
this.cursor -= len;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
submitLine() {
|
|
389
|
+
const line = this.buffer;
|
|
390
|
+
this.clearSuggestions();
|
|
391
|
+
process.stdout.write('\r\n');
|
|
392
|
+
if (line.trim()) {
|
|
393
|
+
this.history.unshift(line);
|
|
394
|
+
if (this.history.length > 200) this.history.pop();
|
|
395
|
+
}
|
|
396
|
+
this.buffer = '';
|
|
397
|
+
this.cursor = 0;
|
|
398
|
+
this.historyIndex = -1;
|
|
399
|
+
this.suggestions = [];
|
|
400
|
+
this.selectedIndex = -1;
|
|
401
|
+
this.opts.onSubmit(line);
|
|
402
|
+
}
|
|
403
|
+
acceptSuggestion() {
|
|
404
|
+
const s = this.suggestions[this.selectedIndex];
|
|
405
|
+
if (!s) return;
|
|
406
|
+
if (this.buffer.startsWith('/')) {
|
|
407
|
+
this.buffer = s.text;
|
|
408
|
+
this.cursor = this.buffer.length;
|
|
409
|
+
} else {
|
|
410
|
+
const atMatch = this.buffer.match(/@[\w./:~\-]*$/);
|
|
411
|
+
if (atMatch && atMatch.index !== undefined) {
|
|
412
|
+
this.buffer = this.buffer.slice(0, atMatch.index) + s.text;
|
|
413
|
+
this.cursor = this.buffer.length;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
this.selectedIndex = -1;
|
|
417
|
+
if (s.text.endsWith('/')) {
|
|
418
|
+
this.computeSuggestions();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
computeSuggestions() {
|
|
422
|
+
this.selectedIndex = -1;
|
|
423
|
+
if (this.buffer.startsWith('/')) {
|
|
424
|
+
this.suggestions = this.opts.getCommandSuggestions(this.buffer);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const atMatch = this.buffer.match(/@([\w./:~\-]*)$/);
|
|
428
|
+
if (atMatch) {
|
|
429
|
+
this.suggestions = this.opts.getMentionSuggestions(atMatch[1]);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
this.suggestions = [];
|
|
433
|
+
}
|
|
434
|
+
calculateCursorPosition() {
|
|
435
|
+
const totalLength = this.promptLen + this.cursor;
|
|
436
|
+
const row = Math.floor(totalLength / this.terminalWidth);
|
|
437
|
+
const col = totalLength % this.terminalWidth + 1;
|
|
438
|
+
return {
|
|
439
|
+
row,
|
|
440
|
+
col
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
render() {
|
|
444
|
+
const write = (s)=>process.stdout.write(s);
|
|
445
|
+
// Calcular quantas linhas o buffer atual ocupa
|
|
446
|
+
const totalLength = this.promptLen + this.buffer.length;
|
|
447
|
+
const linesUsed = Math.ceil(totalLength / this.terminalWidth);
|
|
448
|
+
// Ir para o início do input (primeira linha do input)
|
|
449
|
+
if (linesUsed > 1) {
|
|
450
|
+
write(`\x1b[${linesUsed - 1}A`); // Sobe para primeira linha do input
|
|
451
|
+
}
|
|
452
|
+
write('\r'); // Volta para início da linha
|
|
453
|
+
// Limpar todas as linhas usadas pelo input
|
|
454
|
+
for(let i = 0; i < linesUsed; i++){
|
|
455
|
+
write('\x1b[K'); // Limpa linha atual
|
|
456
|
+
if (i < linesUsed - 1) write('\n'); // Desce se não for última linha
|
|
457
|
+
}
|
|
458
|
+
// Voltar para primeira linha
|
|
459
|
+
if (linesUsed > 1) {
|
|
460
|
+
write(`\x1b[${linesUsed - 1}A`);
|
|
461
|
+
}
|
|
462
|
+
write('\r');
|
|
463
|
+
// Escrever prompt + buffer
|
|
464
|
+
write(this.prompt + this.buffer);
|
|
465
|
+
// Limpar resto da tela (para sugestões antigas)
|
|
466
|
+
write('\x1b[J');
|
|
467
|
+
this.renderedLines = 0;
|
|
468
|
+
// Renderizar sugestões
|
|
469
|
+
if (this.suggestions.length > 0) {
|
|
470
|
+
const maxVisible = 10;
|
|
471
|
+
const total = this.suggestions.length;
|
|
472
|
+
let scrollStart = 0;
|
|
473
|
+
if (this.selectedIndex >= 0 && total > maxVisible) {
|
|
474
|
+
scrollStart = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), total - maxVisible));
|
|
475
|
+
}
|
|
476
|
+
const scrollEnd = Math.min(scrollStart + maxVisible, total);
|
|
477
|
+
if (scrollStart > 0) {
|
|
478
|
+
write(`\r\n ${_theme.Colors.dim}\u2191 ${scrollStart} above${_theme.Colors.reset}`);
|
|
479
|
+
this.renderedLines++;
|
|
480
|
+
}
|
|
481
|
+
for(let i = scrollStart; i < scrollEnd; i++){
|
|
482
|
+
const s = this.suggestions[i];
|
|
483
|
+
const selected = i === this.selectedIndex;
|
|
484
|
+
if (selected) {
|
|
485
|
+
write(`\r\n ${_theme.Colors.primary}\u276f${_theme.Colors.reset} ${_theme.Colors.bold}${_theme.Colors.primary}${s.display}${_theme.Colors.reset}`);
|
|
486
|
+
} else {
|
|
487
|
+
write(`\r\n ${_theme.Colors.dim}${s.display}${_theme.Colors.reset}`);
|
|
488
|
+
}
|
|
489
|
+
if (s.description) {
|
|
490
|
+
write(` ${_theme.Colors.muted}${s.description}${_theme.Colors.reset}`);
|
|
491
|
+
}
|
|
492
|
+
this.renderedLines++;
|
|
493
|
+
}
|
|
494
|
+
const remaining = total - scrollEnd;
|
|
495
|
+
if (remaining > 0) {
|
|
496
|
+
write(`\r\n ${_theme.Colors.dim}\u2193 ${remaining} below${_theme.Colors.reset}`);
|
|
497
|
+
this.renderedLines++;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
// Voltar para linha do input se renderizou sugestões
|
|
501
|
+
if (this.renderedLines > 0) {
|
|
502
|
+
write(`\x1b[${this.renderedLines}A`);
|
|
503
|
+
}
|
|
504
|
+
// Posicionar cursor corretamente considerando wrapping
|
|
505
|
+
const { row, col } = this.calculateCursorPosition();
|
|
506
|
+
if (row > 0) {
|
|
507
|
+
write(`\x1b[${row}B`); // Desce 'row' linhas
|
|
508
|
+
}
|
|
509
|
+
write(`\x1b[${col}G`); // Move para coluna
|
|
510
|
+
}
|
|
511
|
+
clearSuggestions() {
|
|
512
|
+
if (this.renderedLines > 0) {
|
|
513
|
+
const { row, col } = this.calculateCursorPosition();
|
|
514
|
+
// Posiciona no fim do buffer
|
|
515
|
+
if (row > 0) {
|
|
516
|
+
process.stdout.write(`\x1b[${row}B`);
|
|
517
|
+
}
|
|
518
|
+
process.stdout.write(`\x1b[${col}G\x1b[J`);
|
|
519
|
+
this.renderedLines = 0;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
constructor(opts){
|
|
523
|
+
this.buffer = '';
|
|
524
|
+
this.cursor = 0;
|
|
525
|
+
this.history = [];
|
|
526
|
+
this.historyIndex = -1;
|
|
527
|
+
this.savedBuffer = '';
|
|
528
|
+
this.suggestions = [];
|
|
529
|
+
this.selectedIndex = -1;
|
|
530
|
+
this.renderedLines = 0;
|
|
531
|
+
this.mode = 'input';
|
|
532
|
+
this.questionResolve = null;
|
|
533
|
+
this.questionBuffer = '';
|
|
534
|
+
this.dataHandler = null;
|
|
535
|
+
this.terminalWidth = 80; // default
|
|
536
|
+
this.isPaused = false;
|
|
537
|
+
this.lastCtrlCTime = 0;
|
|
538
|
+
this.opts = opts;
|
|
539
|
+
this.prompt = opts.prompt;
|
|
540
|
+
this.promptLen = opts.promptVisibleLen;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
//# sourceMappingURL=smart-input.js.map
|