UNPKG

claude-agents-manager

Version:

Elite AI research and development platform with 60+ specialized agents, comprehensive research workflows, citation-backed reports, and advanced multi-agent coordination for Claude Code. Features deep research capabilities, concurrent execution, shared mem

740 lines (679 loc) โ€ข 21.3 kB
import inquirer from "inquirer"; import chalk from "chalk"; import ora from "ora"; import { getMemoryStore } from "../memory/index.js"; import { EliteResearchWorkflow } from "../utils/research-workflow.js"; import { getAvailableAgents, getAgentDetails } from "../utils/agents.js"; import { addInstalledAgent } from "../utils/config.js"; import { runCommand } from "./run.js"; /** * Elite Research Team Management Command * Provides automated setup, coordination, and execution of research workflows */ export async function researchCommand(options = {}) { console.log(chalk.blue.bold("\n๐Ÿ”ฌ Elite Research Team Manager")); console.log( chalk.gray( "Comprehensive research analysis with multi-agent coordination\n", ), ); const memory = getMemoryStore(); try { // Handle direct workflow execution if (options.execute) { await executeResearchWorkflow(options.execute, options); return; } // Handle team setup if (options.setup) { await setupResearchTeam(); return; } // Handle quick research patterns if (options.standard) { await executeQuickResearch("standard", options); return; } if (options.deep) { await executeQuickResearch("deep", options); return; } // Interactive mode const action = await promptResearchAction(); switch (action) { case "setup-team": await setupResearchTeam(); break; case "standard-research": await executeQuickResearch("standard", options); break; case "deep-research": await executeQuickResearch("deep", options); break; case "custom-workflow": await createCustomResearchWorkflow(); break; case "team-status": await showTeamStatus(); break; case "memory-coordination": await manageResearchMemory(); break; default: console.log(chalk.yellow("Operation cancelled")); } } catch (error) { console.error(chalk.red("โŒ Research command failed:"), error.message); process.exit(1); } } async function promptResearchAction() { const { action } = await inquirer.prompt([ { type: "list", name: "action", message: "What would you like to do?", choices: [ { name: "๐Ÿš€ Setup Elite Research Team - Install and configure all agents", value: "setup-team", }, { name: "๐Ÿ“Š Standard Research (2-4 hours) - Multi-source analysis with executive summary", value: "standard-research", }, { name: "๐ŸŽฏ Deep Research (8-24 hours) - Comprehensive academic and expert analysis", value: "deep-research", }, { name: "๐Ÿ”ง Custom Research Workflow - Design specialized research pattern", value: "custom-workflow", }, { name: "๐Ÿ“ˆ Team Status - View agent availability and performance", value: "team-status", }, { name: "๐Ÿง  Memory Coordination - Manage shared research context", value: "memory-coordination", }, ], }, ]); return action; } /** * Setup the complete Elite Research Team */ async function setupResearchTeam() { console.log(chalk.blue("\n๐Ÿ”ง Setting up Elite Research Team")); const spinner = ora("Installing research agents...").start(); const eliteResearchAgents = [ "research-coordinator", "search-specialist", "deep-miner", "content-analyzer", "pov-analyst", "fact-checker", "trend-analyst", "research-synthesizer", "expert-synthesizer", "report-generator", "executive-summarizer", "source-indexer", ]; let installedCount = 0; let alreadyInstalled = 0; for (const agentName of eliteResearchAgents) { try { // Check if agent exists in the elite-research directory const agentDetails = getAgentDetails(agentName, "elite-research"); if (agentDetails) { addInstalledAgent(agentName, agentDetails, true); installedCount++; } else { console.log( chalk.yellow( `Warning: ${agentName} not found in elite-research collection`, ), ); } } catch (error) { if (error.message.includes("already installed")) { alreadyInstalled++; } else { console.error( chalk.red(`Failed to install ${agentName}: ${error.message}`), ); } } } spinner.succeed(`Elite Research Team setup complete!`); console.log(chalk.green(`โœ… Installed: ${installedCount} agents`)); if (alreadyInstalled > 0) { console.log( chalk.gray(`โ„น๏ธ Already installed: ${alreadyInstalled} agents`), ); } // Initialize research memory space const memory = getMemoryStore(); memory.set("research:team:setup", { agents: eliteResearchAgents, setupTime: new Date().toISOString(), status: "ready", }); // Setup research workflow templates await setupResearchWorkflowTemplates(); console.log(chalk.blue("\n๐Ÿ“‹ Elite Research Team Ready!")); console.log(chalk.gray("Available commands:")); console.log( chalk.gray( ' claude-agents research --standard "topic" # 2-4 hour research', ), ); console.log( chalk.gray( ' claude-agents research --deep "topic" # 8-24 hour research', ), ); console.log( chalk.gray( " claude-agents run research-coordinator # Direct agent access", ), ); } /** * Setup research workflow templates in the workflow manager */ async function setupResearchWorkflowTemplates() { const memory = getMemoryStore(); // Standard Research Template memory.set("workflow:template:standard-research", { name: "Standard Research Workflow", description: "Multi-source analysis with basic expert consultation (2-4 hours)", category: "elite-research", phases: [ { name: "Discovery & Indexing", duration: "30-60 minutes", parallel: true, agents: [ { name: "research-coordinator", task: "Project intake, scope definition, and workflow initialization", parallel: false, }, { name: "search-specialist", task: "Multivariant search across key source categories", parallel: true, }, { name: "source-indexer", task: "Source cataloging and basic cross-referencing", parallel: true, }, ], }, { name: "Analysis & Processing", duration: "90-120 minutes", parallel: true, agents: [ { name: "content-analyzer", task: "Deep content analysis of priority sources", parallel: true, }, { name: "pov-analyst", task: "Multi-perspective analysis and bias detection", parallel: true, }, { name: "fact-checker", task: "Source verification and fact validation", parallel: true, }, ], }, { name: "Synthesis & Reporting", duration: "60-90 minutes", parallel: true, agents: [ { name: "research-synthesizer", task: "Cross-source synthesis and strategic insights", parallel: false, }, { name: "report-generator", task: "Comprehensive research report generation", parallel: true, }, { name: "executive-summarizer", task: "Executive summary optimized for decision-making", parallel: true, }, ], }, ], }); // Deep Research Template memory.set("workflow:template:deep-research", { name: "Deep Research Workflow", description: "Comprehensive academic and expert network mining (8-24 hours)", category: "elite-research", phases: [ { name: "Comprehensive Discovery", duration: "2-4 hours", parallel: true, agents: [ { name: "research-coordinator", task: "Strategic research orchestration and quality planning", parallel: false, }, { name: "search-specialist", task: "Exhaustive multivariant search across all source types", parallel: true, }, { name: "deep-miner", task: "Premium database access and expert network consultation", parallel: true, }, { name: "source-indexer", task: "Advanced cataloging with citation network analysis", parallel: true, }, ], }, { name: "Advanced Analysis", duration: "4-8 hours", parallel: true, agents: [ { name: "content-analyzer", task: "Multi-layered content analysis with thematic extraction", parallel: true, }, { name: "pov-analyst", task: "Comprehensive stakeholder mapping and bias neutralization", parallel: true, }, { name: "fact-checker", task: "Multi-source triangulation and credibility assessment", parallel: true, }, { name: "trend-analyst", task: "Historical pattern analysis and predictive modeling", parallel: true, }, ], }, { name: "Expert Synthesis", duration: "2-4 hours", parallel: true, agents: [ { name: "research-synthesizer", task: "Cross-source synthesis with predictive insights", parallel: false, }, { name: "expert-synthesizer", task: "Expert opinion compilation with consensus analysis", parallel: true, }, ], }, { name: "Comprehensive Reporting", duration: "2-4 hours", parallel: true, agents: [ { name: "report-generator", task: "Comprehensive research report with appendices", parallel: true, }, { name: "executive-summarizer", task: "Multi-tiered executive communication suite", parallel: true, }, ], }, ], }); } /** * Execute quick research workflows */ async function executeQuickResearch(mode, options) { const topic = options.standard || options.deep || options.topic || options.task || (await promptResearchTopic()); if (!topic) { console.log(chalk.red("Research topic is required")); return; } console.log(chalk.blue(`\n๐Ÿ”ฌ Executing ${mode.toUpperCase()} Research`)); console.log(chalk.gray(`Topic: ${topic}`)); console.log( chalk.gray( `Estimated time: ${mode === "deep" ? "8-24 hours" : "2-4 hours"}\n`, ), ); const workflow = new EliteResearchWorkflow(); const assignment = { title: topic, mode: mode, objective: `${mode === "deep" ? "Comprehensive strategic analysis" : "Multi-source analysis"} of: ${topic}`, timeline: mode === "deep" ? "16 hours" : "4 hours", deliverables: mode === "deep" ? [ "comprehensive-report", "executive-summary", "expert-analysis", "trend-forecast", ] : ["research-report", "executive-summary", "key-findings"], }; try { const results = await workflow.executeResearchAssignment(assignment); console.log( chalk.green.bold("\nโœ… Research Assignment Completed Successfully!"), ); displayResearchResults(results); // Store results in memory for future reference const memory = getMemoryStore(); memory.set(`research:completed:${Date.now()}`, { assignment, results, completedAt: new Date().toISOString(), }); } catch (error) { console.error(chalk.red(`Research execution failed: ${error.message}`)); } } async function promptResearchTopic() { const { topic } = await inquirer.prompt([ { type: "input", name: "topic", message: "Enter research topic:", validate: (input) => (input.trim() ? true : "Research topic is required"), }, ]); return topic; } /** * Create custom research workflows */ async function createCustomResearchWorkflow() { console.log(chalk.blue("\n๐Ÿ”ง Create Custom Research Workflow")); const { name, objective, agents, mode } = await inquirer.prompt([ { type: "input", name: "name", message: "Research project name:", validate: (input) => (input.trim() ? true : "Project name is required"), }, { type: "input", name: "objective", message: "Research objective:", validate: (input) => (input.trim() ? true : "Objective is required"), }, { type: "list", name: "mode", message: "Research depth:", choices: [ { name: "Standard (2-4 hours)", value: "standard" }, { name: "Deep (8-24 hours)", value: "deep" }, ], }, { type: "checkbox", name: "agents", message: "Select specialized agents:", choices: [ { name: "Search Specialist - Multivariant search", value: "search-specialist", }, { name: "Deep Miner - Premium databases & experts", value: "deep-miner", }, { name: "Content Analyzer - Thematic analysis", value: "content-analyzer", }, { name: "POV Analyst - Multi-perspective analysis", value: "pov-analyst", }, { name: "Fact Checker - Source validation", value: "fact-checker" }, { name: "Trend Analyst - Pattern & prediction", value: "trend-analyst", }, { name: "Research Synthesizer - Cross-source synthesis", value: "research-synthesizer", }, { name: "Expert Synthesizer - Expert opinion compilation", value: "expert-synthesizer", }, { name: "Report Generator - Comprehensive reporting", value: "report-generator", }, { name: "Executive Summarizer - C-suite communication", value: "executive-summarizer", }, ], }, ]); const workflow = new EliteResearchWorkflow(); const assignment = { title: name, mode: mode, objective: objective, customAgents: agents, timeline: mode === "deep" ? "16 hours" : "4 hours", }; console.log(chalk.blue("\nExecuting custom research workflow...")); try { const results = await workflow.executeResearchAssignment(assignment); console.log(chalk.green("\nโœ… Custom research workflow completed!")); displayResearchResults(results); } catch (error) { console.error(chalk.red(`Custom workflow failed: ${error.message}`)); } } /** * Show team status and capabilities */ async function showTeamStatus() { console.log(chalk.blue.bold("\n๐Ÿ“Š Elite Research Team Status")); console.log(chalk.blue("=".repeat(50))); const memory = getMemoryStore(); const teamSetup = memory.get("research:team:setup"); if (!teamSetup) { console.log(chalk.yellow("Elite Research Team not yet configured")); console.log(chalk.gray("Run: claude-agents research --setup")); return; } console.log(chalk.green(`โœ… Team Status: ${teamSetup.status}`)); console.log( chalk.gray(`Setup Date: ${new Date(teamSetup.setupTime).toLocaleString()}`), ); console.log(chalk.gray(`Total Agents: ${teamSetup.agents.length}`)); console.log(chalk.blue("\n๐Ÿค– Agent Capabilities:")); const agentCapabilities = { "research-coordinator": "โ˜…โ˜…โ˜… Strategic orchestration, workflow management", "search-specialist": "โ˜…โ˜…โ˜… Multivariant search, source discovery", "deep-miner": "โ˜…โ˜…โ˜… Premium databases, expert consultation", "content-analyzer": "โ˜…โ˜…โ˜… Thematic analysis, insight extraction", "pov-analyst": "โ˜…โ˜…โ˜… Multi-perspective analysis, bias detection", "fact-checker": "โ˜…โ˜…โ˜… Source validation, credibility assessment", "trend-analyst": "โ˜…โ˜…โ˜… Pattern analysis, predictive modeling", "research-synthesizer": "โ˜…โ˜…โ˜… Cross-source synthesis, strategic insights", "expert-synthesizer": "โ˜…โ˜…โ˜… Expert opinion compilation, consensus analysis", "report-generator": "โ˜…โ˜…โ˜… Comprehensive reporting, professional formatting", "executive-summarizer": "โ˜…โ˜…โ˜… C-suite communication, strategic summaries", "source-indexer": "โ˜…โ˜… Source cataloging, citation analysis", }; Object.entries(agentCapabilities).forEach(([agent, capability]) => { console.log(chalk.cyan(` ${agent}: ${chalk.gray(capability)}`)); }); // Show recent research activity const recentResearch = memory.getByPattern("research:completed:*"); if (Object.keys(recentResearch).length > 0) { console.log(chalk.blue("\n๐Ÿ“ˆ Recent Research Activity:")); Object.values(recentResearch) .slice(-3) .forEach((research) => { console.log( chalk.gray( ` โ€ข ${research.assignment.title} (${research.assignment.mode})`, ), ); }); } } /** * Manage research memory and coordination */ async function manageResearchMemory() { console.log(chalk.blue.bold("\n๐Ÿง  Research Memory Management")); const memory = getMemoryStore(); const { action } = await inquirer.prompt([ { type: "list", name: "action", message: "Memory management action:", choices: [ { name: "๐Ÿ“– View Active Research Context", value: "view-context" }, { name: "๐Ÿ”„ Share Context Between Agents", value: "share-context" }, { name: "๐Ÿ—‚๏ธ Archive Completed Research", value: "archive-research" }, { name: "๐Ÿงน Clear Research Memory", value: "clear-memory" }, ], }, ]); switch (action) { case "view-context": const context = memory.getByPattern("research:*"); console.log(chalk.blue("\n๐Ÿ“– Active Research Context:")); Object.entries(context).forEach(([key, value]) => { console.log( chalk.cyan( ` ${key}: ${JSON.stringify(value, null, 2).substring(0, 100)}...`, ), ); }); break; case "share-context": console.log( chalk.blue("\n๐Ÿ”„ Research context shared between all agents"), ); memory.set("research:shared:context", { sharedAt: new Date().toISOString(), status: "active", }); break; case "archive-research": const completed = memory.getByPattern("research:completed:*"); memory.set("research:archive", completed); console.log( chalk.green( `โœ… Archived ${Object.keys(completed).length} completed research projects`, ), ); break; case "clear-memory": const { confirm } = await inquirer.prompt([ { type: "confirm", name: "confirm", message: "Are you sure you want to clear all research memory?", default: false, }, ]); if (confirm) { // Clear research-specific memory but keep team setup const keys = Object.keys(memory.getByPattern("research:*")); keys.forEach((key) => { if (!key.includes("team:setup")) { memory.delete(key); } }); console.log(chalk.green("โœ… Research memory cleared")); } break; } } /** * Display research results in a formatted way */ function displayResearchResults(results) { console.log(chalk.blue("\n๐Ÿ“Š Research Results Summary:")); console.log(chalk.blue("=".repeat(40))); console.log(`๐Ÿ“‹ Project: ${results.projectSummary.title}`); console.log(`โฑ๏ธ Duration: ${results.projectSummary.duration}`); console.log(`๐Ÿ“ˆ Phases: ${results.projectSummary.phases}`); console.log(`๐Ÿค– Agents: ${results.projectSummary.agents}`); if (results.reports) { console.log(chalk.blue("\n๐Ÿ“ Generated Reports:")); Object.entries(results.reports).forEach(([reportKey, report]) => { if (report.filePath) { console.log(chalk.cyan(` โ€ข ${report.title}`)); console.log(chalk.gray(` ๐Ÿ“„ ${report.filePath}`)); console.log( chalk.gray( ` ๐Ÿ“ ${report.length} โ€ข ${report.sections.length} sections\n`, ), ); } else { console.log(chalk.cyan(` โ€ข ${reportKey}`)); } }); } if (results.qualityAssurance) { console.log( chalk.blue( `๐ŸŽฏ Quality Score: ${results.qualityAssurance.overallScore}/10`, ), ); } console.log(chalk.green("\n๐Ÿ“ Research files saved to: ./research-output/")); console.log( chalk.gray( "All deliverables also saved to research memory for future reference.", ), ); }