UNPKG

@graphteon/juricode

Version:

We are forging the future with lines of digital steel

44 lines 1.99 kB
import prompts from 'prompts'; import chalk from 'chalk'; import ora from 'ora'; import boxen from 'boxen'; import { TaskService } from '../api/task'; import { ConversationService } from '../api/conversation'; export const convertTaskToConversation = async (taskId) => { const spinner = ora('Loading task details...').start(); try { const taskService = new TaskService(); const task = await taskService.getTask(taskId); spinner.succeed('Task found!'); const messageAnswer = await prompts({ type: 'text', name: 'message', message: 'Enter initial message for the conversation (optional):', }); const convSpinner = ora('Creating conversation from task...').start(); try { const conversationService = new ConversationService(); const conversation = await conversationService.createConversation({ repository: task.selected_repository || undefined, git_provider: 'github', initial_user_msg: messageAnswer.message || undefined, title: `Conversation from task: ${task.title}` }); convSpinner.succeed('Conversation created successfully!'); console.log(boxen(`ID: ${chalk.cyan(conversation.conversation_id)} Title: ${chalk.white(conversation.title)} Status: ${chalk.yellow('RUNNING')} Repository: ${chalk.yellow(conversation.repository || 'N/A')} Created At: ${chalk.gray(new Date(conversation.created_at).toLocaleString())}`, { padding: 1, borderColor: 'green' })); } catch (error) { convSpinner.fail('Failed to create conversation'); console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error')); } } catch (error) { spinner.fail('Failed to load task'); console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error')); } }; //# sourceMappingURL=convert.js.map