UNPKG

autoagent-cli

Version:

Run autonomous AI agents using Claude or Gemini for task execution

87 lines (86 loc) 3.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerListCommand = registerListCommand; const logger_1 = require("../../utils/logger"); const providers_1 = require("../../providers"); const autonomous_agent_1 = require("../../core/autonomous-agent"); function registerListCommand(program) { program .command('list <type>') .description('List tasks or providers') .option('-s, --status <status>', 'Filter by status (for tasks)') .option('--json', 'Output in JSON format') .option('-w, --workspace <path>', 'Workspace directory') .action(async (type, options) => { try { switch (type) { case 'tasks': await listTasks(options); break; case 'providers': await listProviders(options.json); break; default: logger_1.Logger.error(`Unknown list type: ${type}. Use 'tasks' or 'providers'.`); process.exit(1); } } catch (error) { logger_1.Logger.error(`Failed: ${error instanceof Error ? error.message : String(error)}`); process.exit(1); } }); } async function listTasks(options) { if (options.status !== undefined && options.status !== null) { const validStatuses = ['pending', 'in-progress', 'done', 'completed']; if (!validStatuses.includes(options.status)) { logger_1.Logger.error(`Invalid status: ${options.status}. Valid statuses are: ${validStatuses.join(', ')}`); process.exit(1); } } const agent = new autonomous_agent_1.AutonomousAgent({ workspace: options.workspace }); await agent.initialize(); const tasks = await agent.listTasks(options.status); if (tasks.length === 0) { if (options.json === true) { console.log('[]'); } else { logger_1.Logger.info(options.status !== undefined && options.status !== '' ? `No tasks found with status: ${options.status}` : 'No tasks found'); } return; } if (options.json === true) { console.log(JSON.stringify(tasks, null, 2)); } else { logger_1.Logger.info(`Found ${tasks.length} task(s):\n`); tasks.forEach(task => { const statusIcon = task.status === 'completed' || task.status === 'done' ? '✅' : task.status === 'in-progress' || task.status === 'in_progress' ? '🔄' : '⏳'; logger_1.Logger.info(` ${statusIcon} ${task.id}: ${task.title} (${task.status})`); }); } } async function listProviders(json) { const availableProviders = await (0, providers_1.getAvailableProviders)(); const allProviders = ['claude', 'gemini']; if (json === true) { const providersInfo = allProviders.map(name => ({ name, available: availableProviders.includes(name) })); console.log(JSON.stringify(providersInfo, null, 2)); } else { logger_1.Logger.info('AI Providers:\n'); allProviders.forEach(name => { const available = availableProviders.includes(name); const status = available ? '✅ Available' : '❌ Not installed'; logger_1.Logger.info(` ${name}: ${status}`); }); } }