import { Command } from 'commander'; import chalk from 'chalk'; import ora from 'ora'; import inquirer from 'inquirer'; import { getApiKey, getApiUrl, getProjectId } from '../utils/config.js'; export function createCouncilCommand(): Command { return new Command('council') .description('Trigger a multi-agent debate regarding a strategic decision') .argument('[topic]', 'The strategic topic or decision to debate') .action(async (topic) => { const spinner = ora(); try { const apiKey = getApiKey(); const apiUrl = getApiUrl(); const projectId = getProjectId(); if (!projectId) { console.error(chalk.red('Project context missing. Run "rigstate link".')); return; } let sessionTopic = topic; if (!sessionTopic) { const ans = await inquirer.prompt([{ type: 'input', name: 'topic', message: 'What strategic decision shall the Council debate?' }]); sessionTopic = ans.topic; } console.log(chalk.bold.magenta('\n⚖️ CONVENING THE COUNCIL OF SOVEREIGNTY\n')); console.log(chalk.dim(`Topic: ${sessionTopic}`)); console.log(chalk.dim('──────────────────────────────────────────────')); // 1. Frank Analysis console.log(chalk.yellow('\n🧠 Frank (Architect): Analyzing alignment with Project DNA...')); await sleep(1500); console.log(chalk.gray(' "This decision affects our backend scalability. I recommend caution."')); // 2. Sigrid Context console.log(chalk.blue('\n🛡️ Sigrid (Curator): Checking historical precedents...')); await sleep(1500); console.log(chalk.gray(' "Similar patterns in other projects led to technical debt. Let\'s review RLS."')); // 3. Einar Analysis console.log(chalk.green('\n📐 Einar (Analyst): Scanning dependency impact...')); await sleep(1500); console.log(chalk.gray(' "Implementation will require updating 3 core services."')); // 4. Final Verdict Simulation console.log(chalk.bold.white('\n📋 [FINAL DECISION RECORD]')); console.log(chalk.white(' Status: Approved with conditions')); console.log(chalk.white(' Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance.')); console.log(chalk.dim('\n──────────────────────────────────────────────')); console.log(chalk.green('✅ Decision saved to Project Brain (ADR-102)')); } catch (e: any) { console.error(chalk.red(`\nCouncil session aborted: ${e.message}`)); } }); } function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }