关于 flow-nexus-swarm
flow-nexus-swarm 是用于云端 AI Agent swarm 和事件驱动工作流的编排技能,面向需要协调多 Agent 任务的团队。它支持多种拓扑、队列执行、模板及基于能力匹配的 Agent 分配。
主要功能
- 01管理多种拓扑的 Agent swarm
- 02创建并执行事件驱动工作流
- 03通过向量相似度分配 Agent
- 04使用模板创建 swarm 配置
- 05监控运行状态、指标和队列
适用场景
- 01编排跨仓库开发和协同测试
- 02运行研究分析或数据处理工作流
- 03自动化 CI/CD 与 DevOps 流程
- 04协调代码审查和安全检查
MCP 相关
该技能通过 Flow Nexus MCP 工具初始化和管理 swarm、Agent 及工作流,并监控执行状态与消息队列。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill flow-nexus-swarm安装后在 Claude Code 中输入/flow-nexus-swarm确认已加载。
详细介绍
Flow Nexus 集群与工作流编排
部署和管理基于云的 AI Agent 集群,实现事件驱动的工作流自动化、消息队列处理和智能 Agent 协调。
📋 目录
概览
Flow Nexus 提供基于云的 AI Agent 集群编排,支持:
- 多种拓扑结构:层级、网状、环形和星形架构
- 事件驱动工作流:通过异步执行处理消息队列
- 模板库:为常见用例提供预构建的集群配置
- 智能 Agent 分配:通过向量相似度匹配实现最佳 Agent 选择
- 实时监控:全面的指标和审计跟踪
- 可扩展基础设施:基于云的执行与自动扩缩容
集群管理
初始化集群
使用指定的拓扑结构和配置创建新集群:
mcp__flow-nexus__swarm_init({
topology: "hierarchical", // Options: mesh, ring, star, hierarchical
maxAgents: 8,
strategy: "balanced" // Options: balanced, specialized, adaptive
})
拓扑结构指南:
- 层级:包含协调节点的树形结构(最适合复杂项目)
- 网状:点对点协作(最适合研究和分析)
- 环形:环状协调(最适合顺序工作流)
- 星形:集中式枢纽(最适合简单任务分派)
策略指南:
- 均衡:在 Agent 之间平均分配工作负载
- 专业化:Agent 专注于特定专业领域
- 自适应:根据任务复杂度动态调整
启动 Agent
向集群添加专用 Agent:
mcp__flow-nexus__agent_spawn({
type: "researcher", // Options: researcher, coder, analyst, optimizer, coordinator
name: "Lead Researcher",
capabilities: ["web_search", "analysis", "summarization"]
})
Agent 类型:
- 研究员:信息收集、网络搜索、分析
- 编码员:代码生成、重构、实现
- 分析员:数据分析、模式识别、洞察
- 优化员:性能调优、资源优化
- 协调员:任务分派、进度跟踪、集成
编排任务
在集群中分配任务:
mcp__flow-nexus__task_orchestrate({
task: "Build a REST API with authentication and database integration",
strategy: "parallel", // Options: parallel, sequential, adaptive
maxAgents: 5,
priority: "high" // Options: low, medium, high, critical
})
执行策略:
- 并行:为相互独立的子任务实现最大并发
- 顺序:根据依赖关系逐步执行
- 自适应:根据任务分析由 AI 驱动选择策略
监控与扩缩集群
// Get detailed swarm status
mcp__flow-nexus__swarm_status({
swarm_id: "optional-id" // Uses active swarm if not provided
})
// List all active swarms
mcp__flow-nexus__swarm_list({
status: "active" // Options: active, destroyed, all
})
// Scale swarm up or down
mcp__flow-nexus__swarm_scale({
target_agents: 10,
swarm_id: "optional-id"
})
// Gracefully destroy swarm
mcp__flow-nexus__swarm_destroy({
swarm_id: "optional-id"
})
工作流自动化
创建工作流
定义由消息队列处理的事件驱动工作流:
mcp__flow-nexus__workflow_create({
name: "CI/CD Pipeline",
description: "Automated testing, building, and deployment",
steps: [
{
id: "test",
action: "run_tests",
agent: "tester",
parallel: true
},
{
id: "build",
action: "build_app",
agent: "builder",
depends_on: ["test"]
},
{
id: "deploy",
action: "deploy_prod",
agent: "deployer",
depends_on: ["build"]
}
],
triggers: ["push_to_main", "manual_trigger"],
metadata: {
priority: 10,
retry_policy: "exponential_backoff"
}
})
工作流功能:
- 依赖项管理:使用
depends_on定义步骤依赖关系 - 并行执行:设置
parallel: true以并发执行步骤 - 事件触发器:GitHub 事件、计划任务、手动触发器
- 重试策略:在发生暂时性故障时自动重试
- 优先级队列:优先执行高优先级工作流
执行工作流
以同步或异步方式运行工作流:
mcp__flow-nexus__workflow_execute({
workflow_id: "workflow_id",
input_data: {
branch: "main",
commit: "abc123",
environment: "production"
},
async: true // Queue-based execution for long-running workflows
})
执行模式:
- 同步(async: false):立即执行并等待完成
- 异步(async: true):通过消息队列处理,不阻塞
监控工作流
// Get workflow status and metrics
mcp__flow-nexus__workflow_status({
workflow_id: "id",
execution_id: "specific-run-id", // Optional
include_metrics: true
})
// List workflows with filters
mcp__flow-nexus__workflow_list({
status: "running", // Options: running, completed, failed, pending
limit: 10,
offset: 0
})
// Get complete audit trail
mcp__flow-nexus__workflow_audit_trail({
workflow_id: "id",
limit: 50,
start_time: "2025-01-01T00:00:00Z"
})
Agent 分配
智能地为工作流任务分配 Agent:
mcp__flow-nexus__workflow_agent_assign({
task_id: "task_id",
agent_type: "coder", // Preferred agent type
use_vector_similarity: true // AI-powered capability matching
})
向量相似度匹配:
- 分析任务要求和 Agent 能力
- 根据过往表现寻找最佳 Agent
- 考虑工作负载和可用性
队列管理
监控和管理消息队列:
mcp__flow-nexus__workflow_queue_status({
queue_name: "optional-specific-queue",
include_messages: true // Show pending messages
})
Agent 编排
全栈开发模式
// 1. Initialize swarm with hierarchical topology
mcp__flow-nexus__swarm_init({
topology: "hierarchical",
maxAgents: 8,
strategy: "specialized"
})
// 2. Spawn specialized agents
mcp__flow-nexus__agent_spawn({ type: "coordinator", name: "Project Manager" })
mcp__flow-nexus__agent_spawn({ type: "coder", name: "Backend Developer" })
mcp__flow-nexus__agent_spawn({ type: "coder", name: "Frontend Developer" })
mcp__flow-nexus__agent_spawn({ type: "coder", name: "Database Architect" })
mcp__flow-nexus__agent_spawn({ type: "analyst", name: "QA Engineer" })
// 3. Create development workflow
mcp__flow-nexus__workflow_create({
name: "Full-Stack Development",
steps: [
{ id: "requirements", action: "analyze_requirements", agent: "coordinator" },
{ id: "db_design", action: "design_schema", agent: "Database Architect" },
{ id: "backend", action: "build_api", agent: "Backend Developer", depends_on: ["db_design"] },
{ id: "frontend", action: "build_ui", agent: "Frontend Developer", depends_on: ["requirements"] },
{ id: "integration", action: "integrate", agent: "Backend Developer", depends_on: ["backend", "frontend"] },
{ id: "testing", action: "qa_testing", agent: "QA Engineer", depends_on: ["integration"] }
]
})
// 4. Execute workflow
mcp__flow-nexus__workflow_execute({
workflow_id: "workflow_id",
input_data: {
project: "E-commerce Platform",
tech_stack: ["Node.js", "React", "PostgreSQL"]
}
})
研究与分析模式
// 1. Initialize mesh topology for collaborative research
mcp__flow-nexus__swarm_init({
topology: "mesh",
maxAgents: 5,
strategy: "balanced"
})
// 2. Spawn research agents
mcp__flow-nexus__agent_spawn({ type: "researcher", name: "Primary Researcher" })
mcp__flow-nexus__agent_spawn({ type: "researcher", name: "Secondary Researcher" })
mcp__flow-nexus__agent_spawn({ type: "analyst", name: "Data Analyst" })
mcp__flow-nexus__agent_spawn({ type: "analyst", name: "Insights Analyst" })
// 3. Orchestrate research task
mcp__flow-nexus__task_orchestrate({
task: "Research machine learning trends for 2025 and analyze market opportunities",
strategy: "parallel",
maxAgents: 4,
priority: "high"
})
CI/CD 流水线模式
mcp__flow-nexus__workflow_create({
name: "Deployment Pipeline",
description: "Automated testing, building, and multi-environment deployment",
steps: [
{ id: "lint", action: "lint_code", agent: "code_quality", parallel: true },
{ id: "unit_test", action: "unit_tests", agent: "test_runner", parallel: true },
{ id: "integration_test", action: "integration_tests", agent: "test_runner", parallel: true },
{ id: "build", action: "build_artifacts", agent: "builder", depends_on: ["lint", "unit_test", "integration_test"] },
{ id: "security_scan", action: "security_scan", agent: "security", depends_on: ["build"] },
{ id: "deploy_staging", action: "deploy", agent: "deployer", depends_on: ["security_scan"] },
{ id: "smoke_test", action: "smoke_tests", agent: "test_runner", depends_on: ["deploy_staging"] },
{ id: "deploy_prod", action: "deploy", agent: "deployer", depends_on: ["smoke_test"] }
],
triggers: ["github_push", "github_pr_merged"],
metadata: {
priority: 10,
auto_rollback: true
}
})
数据处理流水线模式
mcp__flow-nexus__workflow_create({
name: "ETL Pipeline",
description: "Extract, Transform, Load data processing",
steps: [
{ id: "extract", action: "extract_data", agent: "data_extractor" },
{ id: "validate_raw", action: "validate_data", agent: "validator", depends_on: ["extract"] },
{ id: "transform", action: "transform_data", agent: "transformer", depends_on: ["validate_raw"] },
{ id: "enrich", action: "enrich_data", agent: "enricher", depends_on: ["transform"] },
{ id: "load", action: "load_data", agent: "loader", depends_on: ["enrich"] },
{ id: "validate_final", action: "validate_data", agent: "validator", depends_on: ["load"] }
],
triggers: ["schedule:0 2 * * *"], // Daily at 2 AM
metadata: {
retry_policy: "exponential_backoff",
max_retries: 3
}
})
模板与模式
使用预构建模板
// Create swarm from template
mcp__flow-nexus__swarm_create_from_template({
template_name: "full-stack-dev",
overrides: {
maxAgents: 6,
strategy: "specialized"
}
})
// List available templates
mcp__flow-nexus__swarm_templates_list({
category: "quickstart", // Options: quickstart, specialized, enterprise, custom, all
includeStore: true
})
可用的模板类别:
快速入门模板:
full-stack-dev:完整的 Web 开发蜂群research-team:研究与分析蜂群code-review:自动化代码审查蜂群data-pipeline:ETL 和数据处理
专用模板:
ml-development:机器学习项目蜂群mobile-dev:移动应用开发devops-automation:基础设施与部署security-audit:安全分析与测试
企业模板:
enterprise-migration:大规模系统迁移multi-repo-sync:多仓库协作compliance-review:法规合规工作流incident-response:自动化事件管理
自定义模板创建
将成功的蜂群配置保存为可在未来项目中重复使用的模板。
高级功能
实时监控
// Subscribe to execution streams
mcp__flow-nexus__execution_stream_subscribe({
stream_type: "claude-flow-swarm",
deployment_id: "deployment_id"
})
// Get execution status
mcp__flow-nexus__execution_stream_status({
stream_id: "stream_id"
})
// List files created during execution
mcp__flow-nexus__execution_files_list({
stream_id: "stream_id",
created_by: "claude-flow"
})
蜂群指标与分析
// Get swarm performance metrics
mcp__flow-nexus__swarm_status({
swarm_id: "id"
})
// Analyze workflow efficiency
mcp__flow-nexus__workflow_status({
workflow_id: "id",
include_metrics: true
})
多蜂群协调
协调多个蜂群,以处理复杂的多阶段项目:
// Phase 1: Research swarm
const researchSwarm = await mcp__flow-nexus__swarm_init({
topology: "mesh",
maxAgents: 4
})
// Phase 2: Development swarm
const devSwarm = await mcp__flow-nexus__swarm_init({
topology: "hierarchical",
maxAgents: 8
})
// Phase 3: Testing swarm
const testSwarm = await mcp__flow-nexus__swarm_init({
topology: "star",
maxAgents: 5
})
最佳实践
1. 选择合适的拓扑结构
// Simple projects: Star
mcp__flow-nexus__swarm_init({ topology: "star", maxAgents: 3 })
// Collaborative work: Mesh
mcp__flow-nexus__swarm_init({ topology: "mesh", maxAgents: 5 })
// Complex projects: Hierarchical
mcp__flow-nexus__swarm_init({ topology: "hierarchical", maxAgents: 10 })
// Sequential workflows: Ring
mcp__flow-nexus__swarm_init({ topology: "ring", maxAgents: 4 })
2. 优化 Agent 分配
// Use vector similarity for optimal matching
mcp__flow-nexus__workflow_agent_assign({
task_id: "complex-task",
use_vector_similarity: true
})
3. 实施适当的错误处理
mcp__flow-nexus__workflow_create({
name: "Resilient Workflow",
steps: [...],
metadata: {
retry_policy: "exponential_backoff",
max_retries: 3,
timeout: 300000, // 5 minutes
on_failure: "notify_and_rollback"
}
})
4. 监控并扩展
// Regular monitoring
const status = await mcp__flow-nexus__swarm_status()
// Scale based on workload
if (status.workload > 0.8) {
await mcp__flow-nexus__swarm_scale({ target_agents: status.agents + 2 })
}
5. 对长时间运行的工作流使用异步执行
// Long-running workflows should use message queues
mcp__flow-nexus__workflow_execute({
workflow_id: "data-pipeline",
async: true // Non-blocking execution
})
// Monitor progress
mcp__flow-nexus__workflow_queue_status({ include_messages: true })
6. 清理资源
// Destroy swarm when complete
mcp__flow-nexus__swarm_destroy({ swarm_id: "id" })
7. 利用模板
// Use proven templates instead of building from scratch
mcp__flow-nexus__swarm_create_from_template({
template_name: "code-review",
overrides: { maxAgents: 4 }
})
与 Claude Flow 集成
Flow Nexus 蜂群可与 Claude Flow hooks 无缝集成:
# Pre-task coordination setup
npx claude-flow@alpha hooks pre-task --description "Initialize swarm"
# Post-task metrics export
npx claude-flow@alpha hooks post-task --task-id "swarm-execution"
常见用例
1. 多仓库开发
- 协调多个仓库之间的开发
- 同步测试与部署
- 跨仓库依赖管理
2. 研究项目
- 分布式信息收集
- 并行分析不同的数据源
- 协作综合分析并生成报告
3. DevOps 自动化
- 基础设施即代码部署
- 多环境测试
- 自动回滚与恢复
4. 代码质量工作流
- 自动化代码审查
- 安全扫描
- 性能基准测试
5. 数据处理
- 大规模 ETL 流水线
- 实时数据转换
- 数据验证与质量检查
身份验证与设置
# Install Flow Nexus
npm install -g flow-nexus@latest
# Register account
npx flow-nexus@latest register
# Login
npx flow-nexus@latest login
# Add MCP server to Claude Code
claude mcp add flow-nexus npx flow-nexus@latest mcp start
支持与资源
- 平台:https:/$flow-nexus.ruv.io
- 文档:https:/$github.com$ruvnet$flow-nexus
- 问题:https:/$github.com$ruvnet$flow-nexus$issues
请记住:Flow Nexus 提供基于云的编排基础设施。如需本地执行与协调,可将核心 claude-flow MCP 服务与 Flow Nexus 配合使用,以获得最大的灵活性。
评论
支持 Markdown