UNPKG

@sethdouglasford/claude-flow

Version:

Claude Code Flow - Advanced AI-powered development workflows with SPARC methodology

129 lines 5.18 kB
/** * Simplified AUTO Strategy Implementation * Automatically determines the best task decomposition approach */ import { detectTaskType, createMetrics } from "./base.js"; import { generateId } from "../../utils/helpers.js"; import { Logger } from "../../core/logger.js"; export class AutoStrategy { logger; metrics = createMetrics(); constructor(_config) { this.logger = new Logger({ level: "info", format: "text", destination: "console" }, { component: "AutoStrategy" }); } async decomposeObjective(objective) { this.logger.info("Auto-decomposing objective", { objectiveId: objective.id, description: objective.description, }); const tasks = []; const dependencies = new Map(); // Simple auto-detection of task type const taskType = detectTaskType(objective.description); // Create tasks based on detected type switch (taskType) { case "development": return this.createDevelopmentTasks(objective); case "testing": return this.createTestingTasks(objective); case "analysis": return this.createAnalysisTasks(objective); case "documentation": return this.createDocumentationTasks(objective); default: return this.createGenericTasks(objective); } } createDevelopmentTasks(objective) { const tasks = []; const dependencies = new Map(); // Design phase const designTask = this.createTask("research", "Design", `Design the solution for: ${objective.description}`); tasks.push(designTask); // Implementation phase const implTask = this.createTask("coding", "Implement", "Implement the solution based on the design"); tasks.push(implTask); dependencies.set(implTask.id.id, [designTask.id.id]); // Testing phase const testTask = this.createTask("testing", "Test", "Test the implementation"); tasks.push(testTask); dependencies.set(testTask.id.id, [implTask.id.id]); return { tasks, dependencies, estimatedDuration: 20 * 60 * 1000 }; } createTestingTasks(objective) { const tasks = []; const dependencies = new Map(); const testPlanTask = this.createTask("analysis", "Test Plan", `Create test plan for: ${objective.description}`); tasks.push(testPlanTask); const executeTestsTask = this.createTask("testing", "Execute Tests", "Execute the test cases"); tasks.push(executeTestsTask); dependencies.set(executeTestsTask.id.id, [testPlanTask.id.id]); return { tasks, dependencies, estimatedDuration: 10 * 60 * 1000 }; } createAnalysisTasks(objective) { const tasks = []; const analyzeTask = this.createTask("analysis", "Analyze", `Perform analysis: ${objective.description}`); tasks.push(analyzeTask); const reportTask = this.createTask("documentation", "Report", "Create analysis report"); tasks.push(reportTask); const dependencies = new Map(); dependencies.set(reportTask.id.id, [analyzeTask.id.id]); return { tasks, dependencies, estimatedDuration: 10 * 60 * 1000 }; } createDocumentationTasks(objective) { const tasks = []; const docTask = this.createTask("documentation", "Document", `Create documentation: ${objective.description}`); tasks.push(docTask); return { tasks, dependencies: new Map(), estimatedDuration: 5 * 60 * 1000 }; } createGenericTasks(objective) { const tasks = []; // Simple generic task const genericTask = this.createTask("research", "Execute", `Execute task: ${objective.description}`); tasks.push(genericTask); return { tasks, dependencies: new Map(), estimatedDuration: 10 * 60 * 1000 }; } createTask(type, name, description) { const taskId = { id: generateId("task"), swarmId: "auto-swarm", sequence: 1, priority: 1, }; return { id: taskId, type, name, description, instructions: description, requirements: { capabilities: [type], tools: [], permissions: ["read", "write"], }, constraints: { dependencies: [], dependents: [], conflicts: [], maxRetries: 1, timeoutAfter: 5 * 60 * 1000, }, priority: "medium", input: {}, context: {}, examples: [], status: "created", createdAt: new Date(), updatedAt: new Date(), attempts: [], statusHistory: [{ timestamp: new Date(), from: "created", to: "created", reason: "Task created", triggeredBy: "system", }], }; } } //# sourceMappingURL=auto.js.map