@graphteon/juricode
Version:
We are forging the future with lines of digital steel
125 lines (123 loc) ⢠5.31 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.listSuggestedTasks = void 0;
const prompts_1 = __importDefault(require("prompts"));
const chalk_1 = __importDefault(require("chalk"));
const ora_1 = __importDefault(require("ora"));
const boxen_1 = __importDefault(require("boxen"));
const open_hands_1 = __importDefault(require("../api/open-hands"));
const chat_1 = require("./chat");
const getTaskTypeColor = (taskType) => {
switch (taskType) {
case 'FAILING_CHECKS':
return chalk_1.default.red(taskType);
case 'MERGE_CONFLICTS':
return chalk_1.default.yellow(taskType);
case 'OPEN_ISSUE':
return chalk_1.default.blue(taskType);
default:
return chalk_1.default.white(taskType);
}
};
const getTaskTypeIcon = (taskType) => {
switch (taskType) {
case 'FAILING_CHECKS':
return 'ā';
case 'MERGE_CONFLICTS':
return 'š';
case 'OPEN_ISSUE':
return 'š';
default:
return 'š';
}
};
const listSuggestedTasks = async () => {
const spinner = (0, ora_1.default)('Fetching suggested tasks...').start();
try {
const suggestedTasks = await open_hands_1.default.getSuggestedTasks();
spinner.succeed('Suggested tasks fetched successfully!');
if (suggestedTasks.length === 0) {
console.log(chalk_1.default.yellow('No suggested tasks found'));
return;
}
const taskAnswer = await (0, prompts_1.default)({
type: 'select',
name: 'selectedTask',
message: 'Select a suggested task to work on:',
choices: suggestedTasks.map((task, index) => ({
title: `${getTaskTypeIcon(task.task_type)} [${index + 1}] ${task.title}`,
value: task,
description: `${chalk_1.default.cyan(task.repo)} | ${getTaskTypeColor(task.task_type)} | Issue #${task.issue_number}`
}))
});
if (taskAnswer.selectedTask) {
const selectedTask = taskAnswer.selectedTask;
console.log((0, boxen_1.default)(`${getTaskTypeIcon(selectedTask.task_type)} ${chalk_1.default.bold(selectedTask.title)}
Repository: ${chalk_1.default.cyan(selectedTask.repo)}
Provider: ${chalk_1.default.green(selectedTask.git_provider)}
Type: ${getTaskTypeColor(selectedTask.task_type)}
Issue: ${chalk_1.default.yellow(`#${selectedTask.issue_number}`)}`, {
padding: 1,
margin: { top: 1 },
borderColor: 'cyan',
borderStyle: 'round'
}));
const actionAnswer = await (0, prompts_1.default)({
type: 'select',
name: 'action',
message: 'What would you like to do with this suggested task?',
choices: [
{ title: 'š Start Working on Task', value: 'start' },
{ title: 'ā©ļø Back to Task List', value: 'back' },
{ title: 'š Return to Main Menu', value: 'main' }
]
});
if (actionAnswer.action === 'start') {
await startSuggestedTask(selectedTask);
}
else if (actionAnswer.action === 'back') {
await (0, exports.listSuggestedTasks)();
}
}
}
catch (error) {
spinner.fail('Failed to fetch suggested tasks');
console.error(chalk_1.default.red(error instanceof Error ? error.message : 'Unknown error'));
}
};
exports.listSuggestedTasks = listSuggestedTasks;
const startSuggestedTask = async (suggestedTask) => {
const spinner = (0, ora_1.default)('Creating conversation from suggested task...').start();
try {
const response = await open_hands_1.default.createConversationFromSuggestedTask(suggestedTask);
spinner.succeed('Conversation created successfully!');
console.log((0, boxen_1.default)(`š ${chalk_1.default.green('Task Started Successfully!')}
Conversation ID: ${chalk_1.default.cyan(response.conversation_id)}
Status: ${chalk_1.default.yellow(response.conversation_status)}
Repository: ${chalk_1.default.cyan(suggestedTask.repo)}
Task: ${chalk_1.default.white(suggestedTask.title)}`, {
padding: 1,
margin: { top: 1 },
borderColor: 'green',
borderStyle: 'double'
}));
const chatAnswer = await (0, prompts_1.default)({
type: 'confirm',
name: 'startChat',
message: 'Would you like to start chatting with the AI about this task?',
initial: true
});
if (chatAnswer.startChat) {
console.log(chalk_1.default.blue('\nš¤ Starting chat session...\n'));
await (0, chat_1.runTaskChat)(response.conversation_id);
}
}
catch (error) {
spinner.fail('Failed to create conversation from suggested task');
console.error(chalk_1.default.red(error instanceof Error ? error.message : 'Unknown error'));
}
};
//# sourceMappingURL=suggested-tasks.js.map