@sethdouglasford/claude-flow
Version:
Claude Code Flow - Advanced AI-powered development workflows with SPARC methodology
102 lines • 3.9 kB
JavaScript
/**
* Simplified Research Strategy Implementation
* Basic research task decomposition without overengineering
*/
import { createMetrics } from "./base.js";
import { Logger } from "../../core/logger.js";
import { generateId } from "../../utils/helpers.js";
export class ResearchStrategy {
logger;
metrics = createMetrics();
simpleCache = new Map();
constructor(config = {}) {
this.logger = new Logger({ level: "info", format: "text", destination: "console" }, { component: "ResearchStrategy" });
this.logger.info("ResearchStrategy initialized");
}
async decomposeObjective(objective) {
this.logger.info("Decomposing research objective", {
objectiveId: objective.id,
description: objective.description,
});
// Check cache first
const cacheKey = `${objective.id}-${objective.description.slice(0, 50)}`;
const cached = this.simpleCache.get(cacheKey);
if (cached) {
return cached;
}
const tasks = [];
const dependencies = new Map();
// Create simple research tasks without complex parameters
const searchTask = this.createSimpleTask("research", "Web Search", `Search for information about: ${objective.description}`, 5 * 60 * 1000);
tasks.push(searchTask);
const analysisTask = this.createSimpleTask("analysis", "Analyze Results", `Analyze the search results for: ${objective.description}`, 5 * 60 * 1000);
tasks.push(analysisTask);
dependencies.set(analysisTask.id.id, [searchTask.id.id]);
const reportTask = this.createSimpleTask("documentation", "Create Report", `Create a summary report of findings for: ${objective.description}`, 5 * 60 * 1000);
tasks.push(reportTask);
dependencies.set(reportTask.id.id, [analysisTask.id.id]);
const totalDuration = tasks.length * 5 * 60 * 1000; // Simple calculation
const result = {
tasks,
dependencies,
estimatedDuration: totalDuration,
};
// Cache result
this.simpleCache.set(cacheKey, result);
return result;
}
// Remove all the complex optimization methods
createSimpleTask(type, name, description, duration) {
const taskId = {
id: generateId("task"),
swarmId: "research-swarm",
sequence: 1,
priority: 1,
};
return {
id: taskId,
type,
name,
description,
instructions: description,
requirements: {
capabilities: [type],
tools: ["WebFetchTool", "WebSearch"],
permissions: ["read", "write"],
},
constraints: {
dependencies: [],
dependents: [],
conflicts: [],
maxRetries: 1,
timeoutAfter: duration,
},
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",
}],
};
}
// Simple metrics update
updateMetrics(tasksCompleted, executionTime) {
this.metrics.tasksCompleted += tasksCompleted;
this.metrics.averageExecutionTime =
(this.metrics.averageExecutionTime + executionTime) / 2;
this.metrics.successRate = Math.min(0.95, this.metrics.successRate + 0.1);
}
getMetrics() {
return { ...this.metrics };
}
}
//# sourceMappingURL=research.js.map