UNPKG

cortexweaver

Version:

CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate

127 lines 5.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PheromoneManager = void 0; /** * PheromoneManager handles pheromone creation and improvement proposals for the Governor agent */ class PheromoneManager { constructor(cognitiveCanvas, config, currentTask) { this.cognitiveCanvas = cognitiveCanvas; this.config = config; this.currentTask = currentTask; } /** * Create guide and warning pheromones */ async createPheromones(pheromones) { if (!this.cognitiveCanvas) { return; } try { for (const pheromone of pheromones) { const pheromoneData = { id: `${pheromone.type}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, type: pheromone.type, strength: pheromone.strength, context: pheromone.context, metadata: { message: pheromone.message, agentId: this.config?.id, taskId: this.currentTask?.id, createdBy: 'governor' }, createdAt: new Date().toISOString(), expiresAt: new Date(Date.now() + 3600000).toISOString() // 1 hour expiry }; await this.cognitiveCanvas.createPheromone(pheromoneData); } } catch (error) { console.warn('Failed to create pheromones:', error.message); } } /** * Propose improvements to code standards or configuration */ async proposeImprovements(analysisData) { const codeStandards = []; const configChanges = []; let priority = 'low'; // Analyze cost issues if (analysisData.budgetStatus.tokenLimitExceeded || analysisData.budgetStatus.costLimitExceeded) { priority = 'high'; configChanges.push('increase budget limits'); codeStandards.push('implement prompt caching'); codeStandards.push('optimize API call frequency'); } // Analyze quality issues if (analysisData.qualityData.passRate < 0.7) { if (priority !== 'high') priority = 'medium'; codeStandards.push('improve test coverage'); codeStandards.push('implement code review process'); codeStandards.push('add quality gates'); } // Generate warnings for approaching limits if (analysisData.budgetStatus.warnings.length > 0) { if (priority === 'low') priority = 'medium'; codeStandards.push('monitor usage patterns'); configChanges.push('adjust budget alerts'); } const rationale = this.buildRationale(analysisData); return { codeStandards, configChanges, priority, rationale }; } /** * Generate pheromones based on analysis results */ async generatePheromones(costData, budgetStatus, qualityData) { const pheromones = []; if (budgetStatus.costLimitExceeded) { pheromones.push({ type: 'warn_pheromone', message: 'Budget limit exceeded - reduce API calls', strength: 0.9, context: 'budget_critical' }); } else if (budgetStatus.warnings.length > 0) { pheromones.push({ type: 'warn_pheromone', message: 'Budget limit approaching - optimize usage', strength: 0.7, context: 'budget_warning' }); } if (qualityData.passRate < 0.5) { pheromones.push({ type: 'warn_pheromone', message: 'Test coverage is critically low', strength: 0.8, context: 'quality_warning' }); } else if (qualityData.passRate > 0.9) { pheromones.push({ type: 'guide_pheromone', message: 'Excellent test coverage - maintain standards', strength: 0.6, context: 'quality_praise' }); } if (costData.totalTokens > 10000) { pheromones.push({ type: 'guide_pheromone', message: 'Use caching to reduce API calls', strength: 0.6, context: 'optimization' }); } return pheromones; } /** * Build rationale for improvement proposals */ buildRationale(analysisData) { const reasons = []; if (analysisData.budgetStatus.tokenLimitExceeded) reasons.push('token budget exceeded'); if (analysisData.budgetStatus.costLimitExceeded) reasons.push('cost budget exceeded'); if (analysisData.qualityData.passRate < 0.7) reasons.push('low test pass rate'); if (analysisData.qualityData.totalTests === 0) reasons.push('no test coverage'); return reasons.length > 0 ? `Improvements needed due to: ${reasons.join(', ')}` : 'Proactive improvements to maintain project health'; } /** * Update references for dependency injection */ updateReferences(cognitiveCanvas, config, currentTask) { this.cognitiveCanvas = cognitiveCanvas; this.config = config; this.currentTask = currentTask; } } exports.PheromoneManager = PheromoneManager; //# sourceMappingURL=pheromone-manager.js.map