@sethdouglasford/claude-flow
Version:
Claude Code Flow - Advanced AI-powered development workflows with SPARC methodology
136 lines (132 loc) ⢠5.79 kB
JavaScript
/**
* Swarm Strategies Command - List and describe available swarm strategies
*/
import { Command } from "../cliffy-compat.js";
import { StrategyFactory } from "../../swarm/strategy-factory.js";
export async function swarmStrategiesAction(ctx) {
const strategyInfo = StrategyFactory.getStrategyInfo();
const availableStrategies = StrategyFactory.getAvailableStrategies();
if (ctx.flags.help || ctx.flags.h) {
showStrategiesHelp();
return;
}
// If a specific strategy is requested, show detailed info
const requestedStrategy = ctx.args[0];
if (requestedStrategy) {
if (!availableStrategies.includes(requestedStrategy)) {
console.error(`ā Unknown strategy: ${requestedStrategy}`);
console.error(`Available strategies: ${availableStrategies.join(", ")}`);
return;
}
showDetailedStrategyInfo(requestedStrategy, strategyInfo[requestedStrategy]);
return;
}
// Show all strategies
console.log("šÆ Available Swarm Strategies\n");
availableStrategies.forEach((strategy, index) => {
const info = strategyInfo[strategy];
const isLast = index === availableStrategies.length - 1;
console.log(`${isLast ? "ā" : "ā"}ā ${strategy.toUpperCase()}`);
console.log(`${isLast ? " " : "ā"} ${info.description}`);
console.log(`${isLast ? " " : "ā"} Duration: ~${info.estimatedDuration} min | Mode: ${info.coordinationMode}`);
console.log(`${isLast ? " " : "ā"} Best for: ${info.preferredFor.slice(0, 3).join(", ")}${info.preferredFor.length > 3 ? "..." : ""}`);
if (!isLast)
console.log("ā");
});
console.log(`\nš” Use 'claude-flow swarm-strategies <strategy>' for detailed information`);
console.log(`š” Use 'claude-flow swarm --strategy <strategy>' to use a specific strategy`);
}
function showDetailedStrategyInfo(strategy, info) {
console.log(`šÆ ${strategy.toUpperCase()} Strategy\n`);
console.log(`š Description:`);
console.log(` ${info.description}\n`);
console.log(`šļø Coordination Mode: ${info.coordinationMode}`);
console.log(`ā±ļø Estimated Duration: ~${info.estimatedDuration} minutes\n`);
console.log(`⨠Key Features:`);
info.features.forEach((feature) => {
console.log(` ⢠${feature}`);
});
console.log(`\nšÆ Best Used For:`);
info.preferredFor.forEach((use) => {
console.log(` ⢠${use}`);
});
console.log(`\nš” Example Usage:`);
console.log(` claude-flow swarm "your objective here" --strategy ${strategy}`);
// Add strategy-specific tips
const tips = getStrategyTips(strategy);
if (tips.length > 0) {
console.log(`\nš” Tips for ${strategy} strategy:`);
tips.forEach((tip) => {
console.log(` ⢠${tip}`);
});
}
}
function getStrategyTips(strategy) {
const tips = {
auto: [
"Let the system choose the best strategy based on your objective",
"Great for general tasks when you're unsure which approach to use",
],
research: [
"Provide specific research questions for better results",
"Works best with objectives that require gathering information",
"Includes web search and source credibility analysis",
],
development: [
"Specify the technology stack you want to use",
"Include requirements for testing and documentation",
"Works well for building applications, APIs, and features",
],
analysis: [
"Provide data sources or specify what needs to be analyzed",
"Include context about what insights you're looking for",
"Great for business intelligence and data-driven decisions",
],
testing: [
"Specify the type of testing needed (unit, integration, etc.)",
"Include information about the codebase being tested",
"Ensures comprehensive test coverage and quality assurance",
],
optimization: [
"Identify specific performance concerns or bottlenecks",
"Include current performance metrics if available",
"Best used when you have measurable performance issues",
],
maintenance: [
"Specify what systems or components need maintenance",
"Include any known issues or update requirements",
"Great for keeping systems healthy and up-to-date",
],
custom: [
"Use when you need specialized behavior not covered by other strategies",
"Consider implementing your own strategy for unique workflows",
],
};
return tips[strategy] || [];
}
function showStrategiesHelp() {
console.log(`
Usage: claude-flow swarm-strategies [strategy]
List and describe available swarm strategies.
Arguments:
strategy Show detailed information for a specific strategy
Options:
--help, -h Show this help message
Examples:
claude-flow swarm-strategies # List all strategies
claude-flow swarm-strategies development # Show development strategy details
claude-flow swarm-strategies research # Show research strategy details
`);
}
export const swarmStrategiesCommand = new Command()
.name("swarm-strategies")
.description("List and describe available swarm strategies")
.arguments("[strategy]")
.option("--help, -h", "Show help message")
.action(async (strategy, options) => {
await swarmStrategiesAction({
args: strategy ? [strategy] : [],
flags: options || {},
});
});
//# sourceMappingURL=swarm-strategies.js.map