UNPKG

@every-env/cli

Version:

Multi-agent orchestrator for AI-powered development workflows

97 lines 4.06 kB
import { BasePatternCommand } from './base-command.js'; import { logger } from '../utils/logger.js'; import chalk from 'chalk'; import ora from 'ora'; export class PlanCommand extends BasePatternCommand { constructor(commandRegistry) { super({ name: 'plan', description: 'Create implementation plans and work breakdowns', commandRegistry, }); } configureCommand(command) { command .command('plan [patterns...]') .description(this.description) .option('-o, --output <path>', 'Output directory for plan files', 'plans') .option('-t, --template <name>', 'Plan template to use') .option('--timeline', 'Include timeline in plans', true) .option('--resources', 'Include resource estimates', true) .option('--tasks', 'Break down into detailed tasks', true) .action(async (patterns, options) => { await this.execute(patterns, options); }); // Add common options this.handleCommonOptions(command); } async execute(patterns, options) { const spinner = ora('Loading configuration...').start(); try { // Load config const { ConfigLoader } = await import('../core/config-loader.js'); const configLoader = new ConfigLoader(); const config = await configLoader.load(); spinner.succeed(); // Handle list option if (options.list) { await this.listPatterns(config); return; } // If no patterns specified, show available patterns if (patterns.length === 0) { console.log(chalk.yellow('\n⚠️ No patterns specified\n')); await this.listPatterns(config); console.log(chalk.gray('Run with pattern names to create plans\n')); return; } // Validate patterns const errors = await this.validatePatterns(config, patterns); if (errors.length > 0) { spinner.fail('Pattern validation failed'); errors.forEach(error => console.error(chalk.red(` ✗ ${error}`))); process.exit(1); } // Override config with command options const planConfig = { ...config, variables: { ...config.variables, outputDir: options.output, includeTimeline: options.timeline, includeResources: options.resources, includeTasks: options.tasks, planTemplate: options.template, }, }; // Execute patterns spinner.start('Executing plan patterns...'); const executionOptions = { dryRun: options.dryRun, force: options.force, only: options.only, maxAgents: options.maxAgents, }; const results = await this.executeCommand(planConfig, patterns, executionOptions); spinner.succeed(`Created ${results.length} plan(s)`); // Show results console.log(chalk.green('\n✅ Plans created successfully:\n')); for (const result of results) { if ('outputPath' in result && result.outputPath) { console.log(` 📄 ${result.outputPath}`); } else if ('error' in result) { console.log(` ❌ Error: ${result.error}`); } } console.log(); } catch (error) { spinner.fail('Plan generation failed'); logger.error('Plan command error:', error); console.error(chalk.red(`\n❌ Error: ${error instanceof Error ? error.message : String(error)}\n`)); process.exit(1); } } } //# sourceMappingURL=plan-command.js.map