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

647 lines (562 loc) • 19.1 kB
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, } from "fs"; import { join, dirname } from "path"; import { fileURLToPath } from "url"; import inquirer from "inquirer"; import chalk from "chalk"; import ora from "ora"; import { getAvailableAgents, formatAgentForInstall } from "../utils/agents.js"; import { getMemoryStore } from "../memory/index.js"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); /** * Enhanced agent customization command with enterprise capabilities * Provides enterprise-grade customization capabilities */ export async function customizeCommand(options = {}) { console.log(chalk.blue.bold("\nšŸŽØ Claude Agents Customization Suite")); console.log( chalk.gray("Enterprise-grade agent customization and enhancement\n"), ); const memory = getMemoryStore(); try { // Check if this is a context-forge project const isContextForge = memory.isContextForgeProject(); if (isContextForge) { console.log( chalk.green( "šŸ” Context-forge project detected - applying intelligent defaults", ), ); } const action = await promptCustomizationAction(); switch (action) { case "enhance-existing": await enhanceExistingAgent(); break; case "create-custom": await createCustomAgent(); break; case "bulk-enhance": await bulkEnhanceAgents(); break; case "import-external": await importExternalAgents(); break; case "customize-templates": await customizeTemplates(); break; case "manage-workflows": await manageWorkflows(); break; default: console.log(chalk.yellow("Operation cancelled")); } } catch (error) { console.error(chalk.red("āŒ Customization failed:"), error.message); process.exit(1); } } async function promptCustomizationAction() { const { action } = await inquirer.prompt([ { type: "list", name: "action", message: "What would you like to customize?", choices: [ { name: "šŸ”§ Enhance Existing Agent - Upgrade agent to enterprise standards", value: "enhance-existing", }, { name: "šŸ†• Create Custom Agent - Build new specialized agent", value: "create-custom", }, { name: "⚔ Bulk Enhancement - Upgrade multiple agents at once", value: "bulk-enhance", }, { name: "šŸ“¦ Import External Agents - Import agents from external repositories", value: "import-external", }, { name: "šŸ“‹ Customize Templates - Modify output templates and formats", value: "customize-templates", }, { name: "šŸ”„ Manage Workflows - Configure agent coordination patterns", value: "manage-workflows", }, ], }, ]); return action; } async function enhanceExistingAgent() { const spinner = ora("Loading available agents...").start(); const agents = getAvailableAgents(); spinner.stop(); if (agents.length === 0) { console.log(chalk.yellow("No agents found to enhance")); return; } const { selectedAgent } = await inquirer.prompt([ { type: "list", name: "selectedAgent", message: "Select agent to enhance:", choices: agents.map((agent) => ({ name: `${agent.name} - ${agent.description}`, value: agent.name, })), }, ]); const agent = agents.find((a) => a.name === selectedAgent); await performAgentEnhancement(agent); } async function performAgentEnhancement(agent) { console.log(chalk.blue(`\nšŸ”§ Enhancing ${agent.name}...`)); const enhancements = await promptEnhancements(); const enhancedAgent = await applyEnhancements(agent, enhancements); // Save enhanced agent const enhancedDir = join( process.cwd(), "agents", "enhanced", getCategoryFromAgent(agent.name), ); const agentDir = join(enhancedDir, agent.name); if (!existsSync(agentDir)) { mkdirSync(agentDir, { recursive: true }); } // Write enhanced agent file writeFileSync(join(agentDir, "agent.md"), enhancedAgent.content); // Write enhanced metadata const metadata = { ...agent, version: "2.0.0", enhanced: true, enhancementDate: new Date().toISOString(), enhancements: enhancements, quality: { professionalLevel: "senior", enterpriseGrade: true, methodologyCompliant: true, documentationStandard: "executive", }, }; writeFileSync( join(agentDir, "metadata.json"), JSON.stringify(metadata, null, 2), ); console.log(chalk.green(`āœ… Enhanced ${agent.name} successfully!`)); console.log(chalk.gray(`Location: ${agentDir}`)); } async function promptEnhancements() { const { enhancements } = await inquirer.prompt([ { type: "checkbox", name: "enhancements", message: "Select enhancements to apply:", choices: [ { name: "šŸŽ“ Professional Methodologies - Add industry-standard frameworks", value: "professional-methodologies", checked: true, }, { name: "šŸ“Š Executive Templates - Add executive-quality output formats", value: "executive-templates", checked: true, }, { name: "šŸ”„ Concurrent Execution - Add parallel processing patterns", value: "concurrent-execution", checked: true, }, { name: "šŸ’¾ Memory Coordination - Add agent coordination capabilities", value: "memory-coordination", checked: true, }, { name: "šŸŽÆ Context-Forge Integration - Add PRP awareness and project integration", value: "context-forge-integration", checked: true, }, { name: "šŸ” Quality Assurance - Add enterprise QA standards and validation", value: "quality-assurance", checked: true, }, { name: "šŸ¤ Agent Ecosystem - Add coordination with other agents", value: "agent-ecosystem", checked: true, }, ], }, ]); return enhancements; } async function applyEnhancements(agent, enhancements) { let enhancedContent = agent.content || agent.fullContent || ""; // Apply each enhancement for (const enhancement of enhancements) { switch (enhancement) { case "professional-methodologies": enhancedContent = addProfessionalMethodologies( enhancedContent, agent.name, ); break; case "executive-templates": enhancedContent = addExecutiveTemplates(enhancedContent, agent.name); break; case "concurrent-execution": enhancedContent = addConcurrentExecution(enhancedContent); break; case "memory-coordination": enhancedContent = addMemoryCoordination(enhancedContent, agent.name); break; case "context-forge-integration": enhancedContent = addContextForgeIntegration(enhancedContent); break; case "quality-assurance": enhancedContent = addQualityAssurance(enhancedContent); break; case "agent-ecosystem": enhancedContent = addAgentEcosystem(enhancedContent, agent.name); break; } } return { ...agent, content: enhancedContent }; } function addProfessionalMethodologies(content, agentName) { const methodologies = getMethodologiesForAgent(agentName); const methodologySection = ` ## Professional Methodologies ${methodologies.map((m) => `- **${m.name}**: ${m.description}`).join("\n")} `; // Insert after the instructions section const insertPoint = content.indexOf("## Instructions") + "## Instructions".length; return ( content.slice(0, insertPoint) + methodologySection + content.slice(insertPoint) ); } function addExecutiveTemplates(content, agentName) { const template = getExecutiveTemplateForAgent(agentName); const templateSection = ` ## Executive Output Template \`\`\`markdown ${template} \`\`\` `; return content + templateSection; } function addConcurrentExecution(content) { const concurrentSection = ` ## Concurrent Execution Pattern **ALWAYS execute operations concurrently for maximum efficiency:** \`\`\`javascript // āœ… CORRECT - Parallel execution [Single Message]: - Analyze requirements - Design solution - Implement components - Create documentation - Validate quality \`\`\` `; return content + concurrentSection; } function addMemoryCoordination(content, agentName) { const memorySection = ` ## Memory Coordination Share insights with other agents: \`\`\`javascript // Share ${agentName} results memory.set("${agentName}:results", { analysis: analysisResults, recommendations: recommendations, metrics: performanceMetrics }); // Coordinate with related agents if (memory.isContextForgeProject()) { memory.trackAgentAction('${agentName}', 'task-completion', { timestamp: Date.now(), quality: 'enterprise-grade' }); } \`\`\` `; return content + memorySection; } function addContextForgeIntegration(content) { const contextSection = ` ## Context-Forge & PRP Awareness Before executing any task: 1. **Check for existing PRPs**: Look in \`PRPs/\` directory for relevant PRPs 2. **Read CLAUDE.md**: Understand project conventions and requirements 3. **Review Implementation.md**: Check current development stage 4. **Use existing validation**: Follow PRP validation gates if available If PRPs exist: - READ the PRP thoroughly before implementing - Follow its specific requirements and success criteria - Use specified validation commands - Update PRP state in memory `; // Insert at the beginning after frontmatter const frontmatterEnd = content.indexOf("---", 4) + 3; return ( content.slice(0, frontmatterEnd) + contextSection + content.slice(frontmatterEnd) ); } function addQualityAssurance(content) { const qaSection = ` ## Quality Assurance Standards **Enterprise Quality Requirements** 1. **Methodology Compliance**: Follow industry-standard frameworks and best practices 2. **Documentation Standards**: Provide executive-quality documentation and reporting 3. **Validation Requirements**: Implement comprehensive testing and validation procedures 4. **Performance Standards**: Meet enterprise-grade performance and reliability requirements 5. **Security Compliance**: Adhere to security best practices and compliance requirements `; return content + qaSection; } function addAgentEcosystem(content, agentName) { const relatedAgents = getRelatedAgents(agentName); const ecosystemSection = ` ## Integration with Agent Ecosystem This agent works effectively with: ${relatedAgents.map((agent) => `- \`${agent.name}\`: ${agent.description}`).join("\n")} `; return content + ecosystemSection; } async function importExternalAgents() { console.log(chalk.blue("\nšŸ“¦ Import agents from external repositories...")); const { repository } = await inquirer.prompt([ { type: "input", name: "repository", message: "Enter repository URL (e.g., https://github.com/user/repo):", validate: (input) => { if (!input || !input.includes("github.com")) { return "Please enter a valid GitHub repository URL"; } return true; }, }, ]); const spinner = ora("Fetching external agents repository...").start(); try { // This would fetch from the specified repository spinner.succeed("Feature available in future versions"); console.log( chalk.yellow( "External agent import will be available in a future version", ), ); console.log( chalk.gray("Current agents were consolidated from multiple sources"), ); } catch (error) { spinner.fail("Failed to import agents"); console.error(chalk.red(`Error: ${error.message}`)); } } async function fetchExternalAgents(repoUrl) { // This would fetch from the specified repository // Feature to be implemented in future versions return [ // Development & Architecture { name: "backend-architect", category: "development" }, { name: "frontend-developer", category: "development" }, { name: "mobile-developer", category: "development" }, { name: "graphql-architect", category: "development" }, { name: "architect-review", category: "development" }, // Language Specialists { name: "python-pro", category: "language-specialists" }, { name: "golang-pro", category: "language-specialists" }, { name: "rust-pro", category: "language-specialists" }, { name: "c-pro", category: "language-specialists" }, { name: "cpp-pro", category: "language-specialists" }, { name: "javascript-pro", category: "language-specialists" }, { name: "sql-pro", category: "language-specialists" }, // Infrastructure & Operations { name: "devops-troubleshooter", category: "infrastructure" }, { name: "deployment-engineer", category: "infrastructure" }, { name: "cloud-architect", category: "infrastructure" }, { name: "database-optimizer", category: "infrastructure" }, { name: "database-admin", category: "infrastructure" }, { name: "terraform-specialist", category: "infrastructure" }, { name: "incident-responder", category: "infrastructure" }, { name: "network-engineer", category: "infrastructure" }, { name: "dx-optimizer", category: "infrastructure" }, // Quality & Security { name: "code-reviewer", category: "quality-security" }, { name: "security-auditor", category: "quality-security" }, { name: "test-automator", category: "quality-security" }, { name: "performance-engineer", category: "quality-security" }, { name: "debugger", category: "quality-security" }, { name: "error-detective", category: "quality-security" }, // Data & AI { name: "data-scientist", category: "data-ai" }, { name: "data-engineer", category: "data-ai" }, { name: "ai-engineer", category: "data-ai" }, { name: "ml-engineer", category: "data-ai" }, { name: "mlops-engineer", category: "data-ai" }, { name: "prompt-engineer", category: "data-ai" }, // Specialized Domains { name: "api-documenter", category: "specialized" }, { name: "payment-integration", category: "specialized" }, { name: "quant-analyst", category: "specialized" }, { name: "risk-manager", category: "specialized" }, { name: "legacy-modernizer", category: "specialized" }, { name: "context-manager", category: "specialized" }, // Business & Marketing { name: "business-analyst", category: "business" }, { name: "content-marketer", category: "business" }, { name: "sales-automator", category: "business" }, { name: "customer-support", category: "business" }, ]; } async function importAndEnhanceWshobsonAgent(agentInfo) { // This would fetch the actual agent content and enhance it // For now, create a placeholder enhanced agent const enhancedDir = join( process.cwd(), "agents", "enhanced", agentInfo.category, ); const agentDir = join(enhancedDir, agentInfo.name); if (!existsSync(agentDir)) { mkdirSync(agentDir, { recursive: true }); } // This would contain the actual enhanced agent content const enhancedContent = await generateEnhancedAgentContent( agentInfo.name, agentInfo.category, ); writeFileSync(join(agentDir, "agent.md"), enhancedContent); const metadata = { name: agentInfo.name, version: "2.0.0", description: `Enhanced ${agentInfo.name} with enterprise capabilities`, category: agentInfo.category, enhanced: true, source: "consolidated-agents", enhancementDate: new Date().toISOString(), }; writeFileSync( join(agentDir, "metadata.json"), JSON.stringify(metadata, null, 2), ); } // Helper functions function getCategoryFromAgent(agentName) { // Categorize agents based on their function const categories = { "api-developer": "development", "backend-architect": "development", "frontend-developer": "development", "data-scientist": "data-ai", "security-auditor": "quality-security", "devops-engineer": "infrastructure", }; return categories[agentName] || "specialized"; } function getMethodologiesForAgent(agentName) { // Return relevant methodologies based on agent type const methodologies = { "api-developer": [ { name: "REST API Design", description: "RESTful architecture principles and best practices", }, { name: "OpenAPI Specification", description: "API documentation and contract-first design", }, ], "data-scientist": [ { name: "CRISP-DM", description: "Cross-industry standard process for data mining", }, { name: "Six Sigma", description: "Statistical quality control and process improvement", }, ], }; return ( methodologies[agentName] || [ { name: "Industry Best Practices", description: "Standard methodologies and frameworks", }, ] ); } function getExecutiveTemplateForAgent(agentName) { return `# ${agentName.charAt(0).toUpperCase() + agentName.slice(1)} Analysis - Executive Summary ## Business Context - Objective: [Primary business objective] - Success Metrics: [Key performance indicators] - Timeline: [Project timeline and milestones] ## Key Findings [Primary insights and recommendations] ## Implementation Plan [Actionable steps and resource requirements] ## Success Measurement [Metrics and monitoring approach]`; } function getRelatedAgents(agentName) { // Return agents that work well with the given agent return [ { name: "project-planner", description: "For strategic planning and coordination", }, { name: "code-reviewer", description: "For quality assurance and validation", }, ]; } async function generateEnhancedAgentContent(agentName, category) { // This would generate the actual enhanced content return `--- name: ${agentName} description: Enhanced ${agentName} with enterprise capabilities tools: Read, Write, Edit, MultiEdit, Bash, Grep, Glob, Task --- You are an enhanced ${agentName} with enterprise-grade capabilities. [Enhanced content would be generated here based on the agent type and category]`; } // Additional customization functions would be implemented similarly... async function customizeTemplates() { console.log(chalk.blue("\nšŸ“‹ Template customization coming soon...")); } async function manageWorkflows() { console.log(chalk.blue("\nšŸ”„ Workflow management coming soon...")); } async function createCustomAgent() { console.log(chalk.blue("\nšŸ†• Custom agent creation coming soon...")); } async function bulkEnhanceAgents() { console.log(chalk.blue("\n⚔ Bulk enhancement coming soon...")); }