mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
- Reorganize v3/ into implementation/ subfolders: - planning/, architecture/, migration/, integration/ - security/, adrs/, research/, swarm-plans/ - Add 15-agent concurrent swarm implementation plans: - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x) - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies - Update .claude/settings.json with proper hooks format - Add bash aliases for claude --dangerously-skip-permissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
108 lines
3.0 KiB
TypeScript
108 lines
3.0 KiB
TypeScript
import { exec } from "child_process";
|
|
import { promisify } from "util";
|
|
import * as fs from "fs/promises";
|
|
import * as path from "path";
|
|
|
|
const execAsync = promisify(exec);
|
|
|
|
interface AgentTask {
|
|
name: string;
|
|
mode: string;
|
|
task: string;
|
|
priority: number;
|
|
}
|
|
|
|
interface TaskResult {
|
|
agent: string;
|
|
success: boolean;
|
|
output?: string;
|
|
error?: string;
|
|
duration: number;
|
|
}
|
|
|
|
class ParallelCoordinator {
|
|
private results: TaskResult[] = [];
|
|
private startTime: number = 0;
|
|
|
|
async runParallelAgents(tasks: AgentTask[]): Promise<void> {
|
|
console.log("🚀 Starting parallel agent execution...\n");
|
|
this.startTime = Date.now();
|
|
|
|
const promises = tasks.map(task => this.executeAgent(task));
|
|
|
|
try {
|
|
await Promise.all(promises);
|
|
} catch (error) {
|
|
console.error("Error during parallel execution:", error);
|
|
}
|
|
|
|
await this.generateReport();
|
|
}
|
|
|
|
private async executeAgent(task: AgentTask): Promise<void> {
|
|
const startTime = Date.now();
|
|
console.log(`📋 Starting ${task.name} agent (mode: ${task.mode})...`);
|
|
|
|
try {
|
|
const command = `npx claude-flow sparc run ${task.mode} "${task.task}"`;
|
|
const { stdout, stderr } = await execAsync(command, {
|
|
cwd: process.cwd(),
|
|
timeout: 300000 // 5 minute timeout
|
|
});
|
|
|
|
const duration = Date.now() - startTime;
|
|
|
|
this.results.push({
|
|
agent: task.name,
|
|
success: true,
|
|
output: stdout,
|
|
duration
|
|
});
|
|
|
|
console.log(`✅ ${task.name} completed in ${duration}ms`);
|
|
} catch (error: any) {
|
|
const duration = Date.now() - startTime;
|
|
|
|
this.results.push({
|
|
agent: task.name,
|
|
success: false,
|
|
error: error.message || String(error),
|
|
duration
|
|
});
|
|
|
|
console.error(`❌ ${task.name} failed after ${duration}ms:`, error.message);
|
|
}
|
|
}
|
|
|
|
private async generateReport(): Promise<void> {
|
|
const totalDuration = Date.now() - this.startTime;
|
|
const successCount = this.results.filter(r => r.success).length;
|
|
|
|
const report = {
|
|
summary: {
|
|
totalAgents: this.results.length,
|
|
successfulAgents: successCount,
|
|
failedAgents: this.results.length - successCount,
|
|
totalDuration: totalDuration,
|
|
averageDuration: totalDuration / this.results.length
|
|
},
|
|
results: this.results,
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
|
|
await fs.writeFile(
|
|
path.join(__dirname, "results.json"),
|
|
JSON.stringify(report, null, 2)
|
|
);
|
|
|
|
console.log("\n📊 Execution Summary:");
|
|
console.log(`Total agents: ${report.summary.totalAgents}`);
|
|
console.log(`Successful: ${report.summary.successfulAgents}`);
|
|
console.log(`Failed: ${report.summary.failedAgents}`);
|
|
console.log(`Total duration: ${report.summary.totalDuration}ms`);
|
|
console.log(`Average duration: ${Math.round(report.summary.averageDuration)}ms`);
|
|
console.log("\nDetailed results saved to results.json");
|
|
}
|
|
}
|
|
|
|
export { ParallelCoordinator, AgentTask, TaskResult }; |