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
JavaScript
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.",
),
);
}