Class: SwarmCLI::Migrator

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_cli/migrator.rb

Overview

Migrator converts Claude Swarm v1 YAML configurations to SwarmSDK v2 format.

Key transformations:

  • version: 1 → 2
  • swarm.main → swarm.lead
  • swarm.instances → swarm.agents
  • For each agent:
    • prompt → system_prompt
    • connections → delegates_to
    • mcps → mcp_servers
    • allowed_tools → tools
    • vibe → bypass_permissions
    • reasoning_effort → parameters.reasoning

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_path) ⇒ Migrator

Returns a new instance of Migrator.



21
22
23
# File 'lib/swarm_cli/migrator.rb', line 21

def initialize(input_path)
  @input_path = input_path
end

Instance Attribute Details

#input_pathObject (readonly)

Returns the value of attribute input_path.



19
20
21
# File 'lib/swarm_cli/migrator.rb', line 19

def input_path
  @input_path
end

Instance Method Details

#migrateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/swarm_cli/migrator.rb', line 25

def migrate
  # Read and parse v1 YAML
  v1_config = YAML.load_file(input_path)

  # Validate it's a v1 config
  unless v1_config["version"] == 1
    raise SwarmCLI::ExecutionError, "Input file is not a v1 configuration (version: #{v1_config["version"]})"
  end

  # Build v2 config
  v2_config = {
    "version" => 2,
    "swarm" => migrate_swarm(v1_config["swarm"]),
  }

  # Convert to YAML string
  YAML.dump(v2_config)
end