claude_swarm 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/release.md +1 -1
  3. data/.claude/hooks/lint-code-files.rb +65 -0
  4. data/.rubocop.yml +22 -2
  5. data/CHANGELOG.md +14 -1
  6. data/CLAUDE.md +1 -1
  7. data/CONTRIBUTING.md +69 -0
  8. data/README.md +27 -2
  9. data/Rakefile +71 -3
  10. data/analyze_coverage.rb +94 -0
  11. data/docs/v2/CHANGELOG.swarm_cli.md +43 -0
  12. data/docs/v2/CHANGELOG.swarm_memory.md +379 -0
  13. data/docs/v2/CHANGELOG.swarm_sdk.md +362 -0
  14. data/docs/v2/README.md +308 -0
  15. data/docs/v2/guides/claude-code-agents.md +262 -0
  16. data/docs/v2/guides/complete-tutorial.md +3088 -0
  17. data/docs/v2/guides/getting-started.md +1456 -0
  18. data/docs/v2/guides/memory-adapters.md +998 -0
  19. data/docs/v2/guides/plugins.md +816 -0
  20. data/docs/v2/guides/quick-start-cli.md +1745 -0
  21. data/docs/v2/guides/rails-integration.md +1902 -0
  22. data/docs/v2/guides/swarm-memory.md +599 -0
  23. data/docs/v2/reference/cli.md +729 -0
  24. data/docs/v2/reference/ruby-dsl.md +2154 -0
  25. data/docs/v2/reference/yaml.md +1835 -0
  26. data/docs-team-swarm.yml +2222 -0
  27. data/examples/learning-assistant/assistant.md +7 -0
  28. data/examples/learning-assistant/example-memories/concept-example.md +90 -0
  29. data/examples/learning-assistant/example-memories/experience-example.md +66 -0
  30. data/examples/learning-assistant/example-memories/fact-example.md +76 -0
  31. data/examples/learning-assistant/example-memories/memory-index.md +78 -0
  32. data/examples/learning-assistant/example-memories/skill-example.md +168 -0
  33. data/examples/learning-assistant/learning_assistant.rb +34 -0
  34. data/examples/learning-assistant/learning_assistant.yml +20 -0
  35. data/examples/v2/dsl/01_basic.rb +44 -0
  36. data/examples/v2/dsl/02_core_parameters.rb +59 -0
  37. data/examples/v2/dsl/03_capabilities.rb +71 -0
  38. data/examples/v2/dsl/04_llm_parameters.rb +56 -0
  39. data/examples/v2/dsl/05_advanced_flags.rb +73 -0
  40. data/examples/v2/dsl/06_permissions.rb +80 -0
  41. data/examples/v2/dsl/07_mcp_server.rb +62 -0
  42. data/examples/v2/dsl/08_swarm_hooks.rb +53 -0
  43. data/examples/v2/dsl/09_agent_hooks.rb +67 -0
  44. data/examples/v2/dsl/10_all_agents_hooks.rb +67 -0
  45. data/examples/v2/dsl/11_delegation.rb +60 -0
  46. data/examples/v2/dsl/12_complete_integration.rb +137 -0
  47. data/examples/v2/file_tools_swarm.yml +102 -0
  48. data/examples/v2/hooks/01_basic_hooks.rb +133 -0
  49. data/examples/v2/hooks/02_usage_tracking.rb +201 -0
  50. data/examples/v2/hooks/03_production_monitoring.rb +429 -0
  51. data/examples/v2/hooks/agent_stop_exit_0.yml +21 -0
  52. data/examples/v2/hooks/agent_stop_exit_1.yml +21 -0
  53. data/examples/v2/hooks/agent_stop_exit_2.yml +26 -0
  54. data/examples/v2/hooks/multiple_hooks_all_pass.yml +37 -0
  55. data/examples/v2/hooks/multiple_hooks_first_fails.yml +37 -0
  56. data/examples/v2/hooks/multiple_hooks_second_fails.yml +37 -0
  57. data/examples/v2/hooks/multiple_hooks_warnings.yml +37 -0
  58. data/examples/v2/hooks/post_tool_use_exit_0.yml +24 -0
  59. data/examples/v2/hooks/post_tool_use_exit_1.yml +24 -0
  60. data/examples/v2/hooks/post_tool_use_exit_2.yml +24 -0
  61. data/examples/v2/hooks/post_tool_use_multi_matcher_exit_0.yml +26 -0
  62. data/examples/v2/hooks/post_tool_use_multi_matcher_exit_1.yml +26 -0
  63. data/examples/v2/hooks/post_tool_use_multi_matcher_exit_2.yml +26 -0
  64. data/examples/v2/hooks/pre_tool_use_exit_0.yml +24 -0
  65. data/examples/v2/hooks/pre_tool_use_exit_1.yml +24 -0
  66. data/examples/v2/hooks/pre_tool_use_exit_2.yml +24 -0
  67. data/examples/v2/hooks/pre_tool_use_multi_matcher_exit_0.yml +26 -0
  68. data/examples/v2/hooks/pre_tool_use_multi_matcher_exit_1.yml +26 -0
  69. data/examples/v2/hooks/pre_tool_use_multi_matcher_exit_2.yml +27 -0
  70. data/examples/v2/hooks/swarm_summary.sh +44 -0
  71. data/examples/v2/hooks/user_prompt_exit_0.yml +21 -0
  72. data/examples/v2/hooks/user_prompt_exit_1.yml +21 -0
  73. data/examples/v2/hooks/user_prompt_exit_2.yml +21 -0
  74. data/examples/v2/hooks/validate_bash.rb +59 -0
  75. data/examples/v2/multi_directory_permissions.yml +221 -0
  76. data/examples/v2/node_context_demo.rb +127 -0
  77. data/examples/v2/node_workflow.rb +173 -0
  78. data/examples/v2/path_resolution_demo.rb +216 -0
  79. data/examples/v2/simple-swarm-v2.rb +90 -0
  80. data/examples/v2/simple-swarm-v2.yml +62 -0
  81. data/examples/v2/swarm.yml +71 -0
  82. data/examples/v2/swarm_with_hooks.yml +61 -0
  83. data/examples/v2/swarm_with_hooks_simple.yml +25 -0
  84. data/examples/v2/think_tool_demo.rb +62 -0
  85. data/exe/swarm +6 -0
  86. data/lib/claude_swarm/claude_mcp_server.rb +0 -6
  87. data/lib/claude_swarm/cli.rb +10 -3
  88. data/lib/claude_swarm/commands/ps.rb +19 -20
  89. data/lib/claude_swarm/commands/show.rb +1 -1
  90. data/lib/claude_swarm/configuration.rb +10 -12
  91. data/lib/claude_swarm/mcp_generator.rb +10 -1
  92. data/lib/claude_swarm/orchestrator.rb +73 -49
  93. data/lib/claude_swarm/system_utils.rb +37 -11
  94. data/lib/claude_swarm/version.rb +1 -1
  95. data/lib/claude_swarm/worktree_manager.rb +1 -0
  96. data/lib/claude_swarm/yaml_loader.rb +22 -0
  97. data/lib/claude_swarm.rb +6 -2
  98. data/lib/swarm_cli/cli.rb +201 -0
  99. data/lib/swarm_cli/command_registry.rb +61 -0
  100. data/lib/swarm_cli/commands/mcp_serve.rb +130 -0
  101. data/lib/swarm_cli/commands/mcp_tools.rb +148 -0
  102. data/lib/swarm_cli/commands/migrate.rb +55 -0
  103. data/lib/swarm_cli/commands/run.rb +173 -0
  104. data/lib/swarm_cli/config_loader.rb +97 -0
  105. data/lib/swarm_cli/formatters/human_formatter.rb +711 -0
  106. data/lib/swarm_cli/formatters/json_formatter.rb +51 -0
  107. data/lib/swarm_cli/interactive_repl.rb +918 -0
  108. data/lib/swarm_cli/mcp_serve_options.rb +44 -0
  109. data/lib/swarm_cli/mcp_tools_options.rb +59 -0
  110. data/lib/swarm_cli/migrate_options.rb +54 -0
  111. data/lib/swarm_cli/migrator.rb +132 -0
  112. data/lib/swarm_cli/options.rb +151 -0
  113. data/lib/swarm_cli/ui/components/agent_badge.rb +33 -0
  114. data/lib/swarm_cli/ui/components/content_block.rb +120 -0
  115. data/lib/swarm_cli/ui/components/divider.rb +57 -0
  116. data/lib/swarm_cli/ui/components/panel.rb +62 -0
  117. data/lib/swarm_cli/ui/components/usage_stats.rb +70 -0
  118. data/lib/swarm_cli/ui/formatters/cost.rb +49 -0
  119. data/lib/swarm_cli/ui/formatters/number.rb +58 -0
  120. data/lib/swarm_cli/ui/formatters/text.rb +77 -0
  121. data/lib/swarm_cli/ui/formatters/time.rb +73 -0
  122. data/lib/swarm_cli/ui/icons.rb +59 -0
  123. data/lib/swarm_cli/ui/renderers/event_renderer.rb +188 -0
  124. data/lib/swarm_cli/ui/state/agent_color_cache.rb +45 -0
  125. data/lib/swarm_cli/ui/state/depth_tracker.rb +40 -0
  126. data/lib/swarm_cli/ui/state/spinner_manager.rb +170 -0
  127. data/lib/swarm_cli/ui/state/usage_tracker.rb +62 -0
  128. data/lib/swarm_cli/version.rb +5 -0
  129. data/lib/swarm_cli.rb +44 -0
  130. data/lib/swarm_memory/adapters/base.rb +141 -0
  131. data/lib/swarm_memory/adapters/filesystem_adapter.rb +845 -0
  132. data/lib/swarm_memory/chat_extension.rb +34 -0
  133. data/lib/swarm_memory/cli/commands.rb +306 -0
  134. data/lib/swarm_memory/core/entry.rb +37 -0
  135. data/lib/swarm_memory/core/frontmatter_parser.rb +108 -0
  136. data/lib/swarm_memory/core/metadata_extractor.rb +68 -0
  137. data/lib/swarm_memory/core/path_normalizer.rb +75 -0
  138. data/lib/swarm_memory/core/semantic_index.rb +244 -0
  139. data/lib/swarm_memory/core/storage.rb +288 -0
  140. data/lib/swarm_memory/core/storage_read_tracker.rb +63 -0
  141. data/lib/swarm_memory/dsl/builder_extension.rb +40 -0
  142. data/lib/swarm_memory/dsl/memory_config.rb +113 -0
  143. data/lib/swarm_memory/embeddings/embedder.rb +36 -0
  144. data/lib/swarm_memory/embeddings/informers_embedder.rb +152 -0
  145. data/lib/swarm_memory/errors.rb +21 -0
  146. data/lib/swarm_memory/integration/cli_registration.rb +30 -0
  147. data/lib/swarm_memory/integration/configuration.rb +43 -0
  148. data/lib/swarm_memory/integration/registration.rb +31 -0
  149. data/lib/swarm_memory/integration/sdk_plugin.rb +531 -0
  150. data/lib/swarm_memory/optimization/analyzer.rb +244 -0
  151. data/lib/swarm_memory/optimization/defragmenter.rb +863 -0
  152. data/lib/swarm_memory/prompts/memory.md.erb +109 -0
  153. data/lib/swarm_memory/prompts/memory_assistant.md.erb +181 -0
  154. data/lib/swarm_memory/prompts/memory_researcher.md.erb +281 -0
  155. data/lib/swarm_memory/prompts/memory_retrieval.md.erb +78 -0
  156. data/lib/swarm_memory/search/semantic_search.rb +112 -0
  157. data/lib/swarm_memory/search/text_search.rb +42 -0
  158. data/lib/swarm_memory/search/text_similarity.rb +80 -0
  159. data/lib/swarm_memory/skills/meta/deep-learning.md +101 -0
  160. data/lib/swarm_memory/skills/meta/deep-learning.yml +14 -0
  161. data/lib/swarm_memory/tools/load_skill.rb +313 -0
  162. data/lib/swarm_memory/tools/memory_defrag.rb +382 -0
  163. data/lib/swarm_memory/tools/memory_delete.rb +99 -0
  164. data/lib/swarm_memory/tools/memory_edit.rb +185 -0
  165. data/lib/swarm_memory/tools/memory_glob.rb +160 -0
  166. data/lib/swarm_memory/tools/memory_grep.rb +247 -0
  167. data/lib/swarm_memory/tools/memory_multi_edit.rb +281 -0
  168. data/lib/swarm_memory/tools/memory_read.rb +123 -0
  169. data/lib/swarm_memory/tools/memory_write.rb +231 -0
  170. data/lib/swarm_memory/utils.rb +50 -0
  171. data/lib/swarm_memory/version.rb +5 -0
  172. data/lib/swarm_memory.rb +166 -0
  173. data/lib/swarm_sdk/agent/RETRY_LOGIC.md +127 -0
  174. data/lib/swarm_sdk/agent/builder.rb +461 -0
  175. data/lib/swarm_sdk/agent/chat/context_tracker.rb +314 -0
  176. data/lib/swarm_sdk/agent/chat/hook_integration.rb +372 -0
  177. data/lib/swarm_sdk/agent/chat/logging_helpers.rb +116 -0
  178. data/lib/swarm_sdk/agent/chat/system_reminder_injector.rb +152 -0
  179. data/lib/swarm_sdk/agent/chat.rb +1159 -0
  180. data/lib/swarm_sdk/agent/context.rb +112 -0
  181. data/lib/swarm_sdk/agent/context_manager.rb +309 -0
  182. data/lib/swarm_sdk/agent/definition.rb +556 -0
  183. data/lib/swarm_sdk/claude_code_agent_adapter.rb +205 -0
  184. data/lib/swarm_sdk/configuration.rb +296 -0
  185. data/lib/swarm_sdk/context_compactor/metrics.rb +147 -0
  186. data/lib/swarm_sdk/context_compactor/token_counter.rb +106 -0
  187. data/lib/swarm_sdk/context_compactor.rb +340 -0
  188. data/lib/swarm_sdk/hooks/adapter.rb +359 -0
  189. data/lib/swarm_sdk/hooks/context.rb +197 -0
  190. data/lib/swarm_sdk/hooks/definition.rb +80 -0
  191. data/lib/swarm_sdk/hooks/error.rb +29 -0
  192. data/lib/swarm_sdk/hooks/executor.rb +146 -0
  193. data/lib/swarm_sdk/hooks/registry.rb +147 -0
  194. data/lib/swarm_sdk/hooks/result.rb +150 -0
  195. data/lib/swarm_sdk/hooks/shell_executor.rb +254 -0
  196. data/lib/swarm_sdk/hooks/tool_call.rb +35 -0
  197. data/lib/swarm_sdk/hooks/tool_result.rb +62 -0
  198. data/lib/swarm_sdk/log_collector.rb +51 -0
  199. data/lib/swarm_sdk/log_stream.rb +69 -0
  200. data/lib/swarm_sdk/markdown_parser.rb +75 -0
  201. data/lib/swarm_sdk/model_aliases.json +5 -0
  202. data/lib/swarm_sdk/models.json +1 -0
  203. data/lib/swarm_sdk/models.rb +120 -0
  204. data/lib/swarm_sdk/node/agent_config.rb +49 -0
  205. data/lib/swarm_sdk/node/builder.rb +439 -0
  206. data/lib/swarm_sdk/node/transformer_executor.rb +248 -0
  207. data/lib/swarm_sdk/node_context.rb +170 -0
  208. data/lib/swarm_sdk/node_orchestrator.rb +384 -0
  209. data/lib/swarm_sdk/permissions/config.rb +239 -0
  210. data/lib/swarm_sdk/permissions/error_formatter.rb +121 -0
  211. data/lib/swarm_sdk/permissions/path_matcher.rb +35 -0
  212. data/lib/swarm_sdk/permissions/validator.rb +173 -0
  213. data/lib/swarm_sdk/permissions_builder.rb +122 -0
  214. data/lib/swarm_sdk/plugin.rb +147 -0
  215. data/lib/swarm_sdk/plugin_registry.rb +101 -0
  216. data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +243 -0
  217. data/lib/swarm_sdk/providers/openai_with_responses.rb +582 -0
  218. data/lib/swarm_sdk/result.rb +97 -0
  219. data/lib/swarm_sdk/swarm/agent_initializer.rb +334 -0
  220. data/lib/swarm_sdk/swarm/all_agents_builder.rb +140 -0
  221. data/lib/swarm_sdk/swarm/builder.rb +586 -0
  222. data/lib/swarm_sdk/swarm/mcp_configurator.rb +151 -0
  223. data/lib/swarm_sdk/swarm/tool_configurator.rb +419 -0
  224. data/lib/swarm_sdk/swarm.rb +982 -0
  225. data/lib/swarm_sdk/tools/bash.rb +274 -0
  226. data/lib/swarm_sdk/tools/clock.rb +44 -0
  227. data/lib/swarm_sdk/tools/delegate.rb +164 -0
  228. data/lib/swarm_sdk/tools/document_converters/base_converter.rb +83 -0
  229. data/lib/swarm_sdk/tools/document_converters/docx_converter.rb +99 -0
  230. data/lib/swarm_sdk/tools/document_converters/html_converter.rb +101 -0
  231. data/lib/swarm_sdk/tools/document_converters/pdf_converter.rb +78 -0
  232. data/lib/swarm_sdk/tools/document_converters/xlsx_converter.rb +194 -0
  233. data/lib/swarm_sdk/tools/edit.rb +150 -0
  234. data/lib/swarm_sdk/tools/glob.rb +158 -0
  235. data/lib/swarm_sdk/tools/grep.rb +228 -0
  236. data/lib/swarm_sdk/tools/image_extractors/docx_image_extractor.rb +43 -0
  237. data/lib/swarm_sdk/tools/image_extractors/pdf_image_extractor.rb +163 -0
  238. data/lib/swarm_sdk/tools/image_formats/tiff_builder.rb +65 -0
  239. data/lib/swarm_sdk/tools/multi_edit.rb +232 -0
  240. data/lib/swarm_sdk/tools/path_resolver.rb +43 -0
  241. data/lib/swarm_sdk/tools/read.rb +251 -0
  242. data/lib/swarm_sdk/tools/registry.rb +93 -0
  243. data/lib/swarm_sdk/tools/scratchpad/scratchpad_list.rb +96 -0
  244. data/lib/swarm_sdk/tools/scratchpad/scratchpad_read.rb +76 -0
  245. data/lib/swarm_sdk/tools/scratchpad/scratchpad_write.rb +91 -0
  246. data/lib/swarm_sdk/tools/stores/read_tracker.rb +61 -0
  247. data/lib/swarm_sdk/tools/stores/scratchpad_storage.rb +224 -0
  248. data/lib/swarm_sdk/tools/stores/storage.rb +148 -0
  249. data/lib/swarm_sdk/tools/stores/todo_manager.rb +65 -0
  250. data/lib/swarm_sdk/tools/think.rb +95 -0
  251. data/lib/swarm_sdk/tools/todo_write.rb +216 -0
  252. data/lib/swarm_sdk/tools/web_fetch.rb +261 -0
  253. data/lib/swarm_sdk/tools/write.rb +117 -0
  254. data/lib/swarm_sdk/utils.rb +50 -0
  255. data/lib/swarm_sdk/version.rb +5 -0
  256. data/lib/swarm_sdk.rb +157 -0
  257. data/llm.v2.txt +13407 -0
  258. data/rubocop/cop/security/no_reflection_methods.rb +47 -0
  259. data/rubocop/cop/security/no_ruby_llm_logger.rb +32 -0
  260. data/swarm_cli.gemspec +57 -0
  261. data/swarm_memory.gemspec +28 -0
  262. data/swarm_sdk.gemspec +41 -0
  263. data/team.yml +1 -1
  264. data/team_full.yml +1875 -0
  265. data/{team_v2.yml → team_sdk.yml} +121 -52
  266. metadata +247 -4
  267. data/EXAMPLES.md +0 -164
@@ -0,0 +1,729 @@
1
+ # SwarmCLI Command Reference
2
+
3
+ Complete command-line interface reference for SwarmCLI v2.
4
+
5
+ ---
6
+
7
+ ## Global Options
8
+
9
+ Available for all commands:
10
+
11
+ ### `--help`, `-h`
12
+
13
+ Display help information for the command.
14
+
15
+ **Type:** Flag
16
+ **Default:** N/A
17
+
18
+ ```bash
19
+ swarm --help
20
+ swarm run --help
21
+ swarm mcp serve --help
22
+ ```
23
+
24
+ ### `--version`, `-v`
25
+
26
+ Display SwarmCLI version number.
27
+
28
+ **Type:** Flag
29
+ **Default:** N/A
30
+
31
+ ```bash
32
+ swarm --version
33
+ ```
34
+
35
+ ---
36
+
37
+ ## swarm run
38
+
39
+ Execute a swarm with AI agents.
40
+
41
+ ### Synopsis
42
+
43
+ ```bash
44
+ swarm run CONFIG_FILE [PROMPT_TEXT] [OPTIONS]
45
+ swarm run CONFIG_FILE -p PROMPT [OPTIONS]
46
+ echo "PROMPT" | swarm run CONFIG_FILE
47
+ echo "PROMPT" | swarm run CONFIG_FILE -p
48
+ ```
49
+
50
+ ### Description
51
+
52
+ Runs a swarm of AI agents defined in a YAML or Ruby DSL configuration file. Supports two modes:
53
+
54
+ 1. **Interactive REPL mode** (default): Opens an interactive session where you can chat with the swarm
55
+ 2. **Non-interactive mode** (`-p` flag): Executes a single prompt and exits
56
+
57
+ ### Arguments
58
+
59
+ #### CONFIG_FILE
60
+
61
+ **Type:** String (required)
62
+ **Description:** Path to swarm configuration file
63
+ **Formats:** `.yml`, `.yaml` (YAML) or `.rb` (Ruby DSL)
64
+
65
+ **Examples:**
66
+ ```bash
67
+ swarm run team.yml
68
+ swarm run config/swarm.rb
69
+ ```
70
+
71
+ #### PROMPT_TEXT
72
+
73
+ **Type:** String (optional)
74
+ **Description:** Initial message for REPL mode or task prompt for non-interactive mode
75
+ **Usage:**
76
+ - Without `-p` flag: Opens REPL with this as first message
77
+ - With `-p` flag: Runs prompt non-interactively and exits
78
+
79
+ **Examples:**
80
+ ```bash
81
+ # REPL with initial message
82
+ swarm run team.yml "Build a REST API"
83
+
84
+ # Non-interactive execution
85
+ swarm run team.yml -p "Build a REST API"
86
+ ```
87
+
88
+ ### Options
89
+
90
+ #### `--prompt`, `-p`
91
+
92
+ Run in non-interactive mode. When specified, executes a single prompt and exits instead of opening a REPL.
93
+
94
+ **Type:** Flag
95
+ **Default:** `false` (REPL mode)
96
+ **Prompt source:** Reads from PROMPT_TEXT argument or stdin
97
+
98
+ **Examples:**
99
+ ```bash
100
+ # From argument
101
+ swarm run team.yml -p "Build a REST API"
102
+
103
+ # From stdin
104
+ echo "Build a REST API" | swarm run team.yml -p
105
+ ```
106
+
107
+ #### `--output-format FORMAT`
108
+
109
+ Output format for results.
110
+
111
+ **Type:** String
112
+ **Values:** `human`, `json`
113
+ **Default:** `human`
114
+
115
+ **Human format:**
116
+ - Pretty-printed, colorized output
117
+ - Progress indicators and spinners
118
+ - Agent badges and visual structure
119
+ - Best for terminal viewing
120
+
121
+ **JSON format:**
122
+ - Structured JSON events on stdout
123
+ - One JSON object per line
124
+ - Suitable for programmatic consumption
125
+ - Includes all event types: `swarm_start`, `user_prompt`, `agent_step`, `tool_call`, `tool_result`, `agent_stop`, `swarm_stop`
126
+
127
+ **Examples:**
128
+ ```bash
129
+ # Human-readable output (default)
130
+ swarm run team.yml -p "Build API"
131
+
132
+ # JSON output for parsing
133
+ swarm run team.yml -p "Build API" --output-format json
134
+ swarm run team.yml -p "Build API" --output-format json | jq '.type'
135
+ ```
136
+
137
+ #### `--quiet`, `-q`
138
+
139
+ Suppress progress output in human format. Only affects human output; ignored in JSON mode.
140
+
141
+ **Type:** Flag
142
+ **Default:** `false`
143
+ **Applies to:** Human format only
144
+
145
+ **Examples:**
146
+ ```bash
147
+ swarm run team.yml -p "Build API" --quiet
148
+ swarm run team.yml -p "Build API" -q
149
+ ```
150
+
151
+ #### `--truncate`
152
+
153
+ Truncate long outputs for concise view in human format.
154
+
155
+ **Type:** Flag
156
+ **Default:** `false`
157
+ **Applies to:** Human format only
158
+
159
+ **Examples:**
160
+ ```bash
161
+ swarm run team.yml -p "Build API" --truncate
162
+ ```
163
+
164
+ #### `--verbose`
165
+
166
+ Show system reminders and additional debug information in human format.
167
+
168
+ **Type:** Flag
169
+ **Default:** `false`
170
+ **Applies to:** Human format only
171
+
172
+ **Examples:**
173
+ ```bash
174
+ swarm run team.yml -p "Build API" --verbose
175
+ ```
176
+
177
+ ### Examples
178
+
179
+ ```bash
180
+ # Interactive REPL mode
181
+ swarm run team.yml
182
+
183
+ # REPL with initial message
184
+ swarm run team.yml "Build a REST API"
185
+
186
+ # REPL with piped initial message
187
+ echo "Build a REST API" | swarm run team.yml
188
+
189
+ # Non-interactive execution from argument
190
+ swarm run team.yml -p "Build a REST API"
191
+
192
+ # Non-interactive from stdin
193
+ echo "Build a REST API" | swarm run team.yml -p
194
+
195
+ # JSON output for parsing
196
+ swarm run team.yml -p "Refactor code" --output-format json
197
+
198
+ # Quiet mode
199
+ swarm run team.yml -p "Build API" --quiet
200
+
201
+ # Verbose debugging
202
+ swarm run team.yml -p "Build API" --verbose
203
+
204
+ # Truncated output
205
+ swarm run team.yml -p "Build API" --truncate
206
+ ```
207
+
208
+ ### Exit Codes
209
+
210
+ - **0**: Success
211
+ - **1**: Error (configuration error, execution error, etc.)
212
+ - **130**: Interrupted (Ctrl+C)
213
+
214
+ ---
215
+
216
+ ## swarm migrate
217
+
218
+ Migrate Claude Swarm v1 configurations to SwarmSDK v2 format.
219
+
220
+ ### Synopsis
221
+
222
+ ```bash
223
+ swarm migrate INPUT_FILE [--output OUTPUT_FILE]
224
+ ```
225
+
226
+ ### Description
227
+
228
+ Converts a Claude Swarm v1 YAML configuration to the new SwarmSDK v2 format. The migrated configuration is written to a file or stdout.
229
+
230
+ ### Arguments
231
+
232
+ #### INPUT_FILE
233
+
234
+ **Type:** String (required)
235
+ **Description:** Path to Claude Swarm v1 configuration file
236
+
237
+ **Examples:**
238
+ ```bash
239
+ swarm migrate old-config.yml
240
+ swarm migrate config/v1-swarm.yml
241
+ ```
242
+
243
+ ### Options
244
+
245
+ #### `--output FILE`, `-o FILE`
246
+
247
+ Output file path for migrated configuration.
248
+
249
+ **Type:** String
250
+ **Default:** stdout
251
+ **Behavior:**
252
+ - If specified: Writes to file and prints success message to stderr
253
+ - If omitted: Prints migrated YAML to stdout
254
+
255
+ **Examples:**
256
+ ```bash
257
+ # Output to file
258
+ swarm migrate old-config.yml --output new-config.yml
259
+ swarm migrate old-config.yml -o new-config.yml
260
+
261
+ # Output to stdout (redirect as needed)
262
+ swarm migrate old-config.yml > new-config.yml
263
+ swarm migrate old-config.yml | tee new-config.yml
264
+ ```
265
+
266
+ ### Examples
267
+
268
+ ```bash
269
+ # Print to stdout
270
+ swarm migrate old-config.yml
271
+
272
+ # Save to file
273
+ swarm migrate old-config.yml --output new-config.yml
274
+
275
+ # Short form
276
+ swarm migrate old-config.yml -o new-config.yml
277
+
278
+ # Pipe and review
279
+ swarm migrate old-config.yml | less
280
+ ```
281
+
282
+ ### Exit Codes
283
+
284
+ - **0**: Success
285
+ - **1**: Error (file not found, invalid YAML, etc.)
286
+ - **130**: Interrupted (Ctrl+C)
287
+
288
+ ---
289
+
290
+ ## swarm mcp serve
291
+
292
+ Start an MCP server exposing the swarm's lead agent as a tool.
293
+
294
+ ### Synopsis
295
+
296
+ ```bash
297
+ swarm mcp serve CONFIG_FILE
298
+ ```
299
+
300
+ ### Description
301
+
302
+ Starts an MCP (Model Context Protocol) server that exposes the swarm's lead agent as a tool named `task`. The server uses stdio transport and can be integrated with other AI systems.
303
+
304
+ The exposed tool accepts:
305
+ - **task** (required): The task or prompt to execute
306
+ - **description** (optional): Brief description of the task
307
+ - **thinking_budget** (optional): Thinking budget level (`think`, `think hard`, `think harder`, `ultrathink`)
308
+
309
+ ### Arguments
310
+
311
+ #### CONFIG_FILE
312
+
313
+ **Type:** String (required)
314
+ **Description:** Path to swarm configuration file (YAML or Ruby DSL)
315
+
316
+ **Examples:**
317
+ ```bash
318
+ swarm mcp serve team.yml
319
+ swarm mcp serve config/swarm.rb
320
+ ```
321
+
322
+ ### Options
323
+
324
+ None beyond global `--help`.
325
+
326
+ ### Examples
327
+
328
+ ```bash
329
+ # Start MCP server
330
+ swarm mcp serve team.yml
331
+
332
+ # Use in Claude Desktop configuration
333
+ # Add to claude_desktop_config.json:
334
+ {
335
+ "mcpServers": {
336
+ "swarm": {
337
+ "command": "swarm",
338
+ "args": ["mcp", "serve", "/path/to/team.yml"]
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ ### MCP Tool Schema
345
+
346
+ **Tool name:** `task`
347
+
348
+ **Parameters:**
349
+ - `task` (string, required): The task or prompt to execute
350
+ - `description` (string, optional): Brief description of the task
351
+ - `thinking_budget` (string, optional): One of `think`, `think hard`, `think harder`, `ultrathink`
352
+
353
+ **Response:**
354
+ - On success: Returns the swarm's response content as a string
355
+ - On failure: Returns a JSON object with `success: false` and error details
356
+
357
+ ### Exit Codes
358
+
359
+ - **0**: Success
360
+ - **1**: Error (configuration error, server startup error)
361
+ - **130**: Interrupted (Ctrl+C)
362
+
363
+ ---
364
+
365
+ ## swarm mcp tools
366
+
367
+ Start an MCP server exposing SwarmSDK tools.
368
+
369
+ ### Synopsis
370
+
371
+ ```bash
372
+ swarm mcp tools [TOOL_NAMES...]
373
+ ```
374
+
375
+ ### Description
376
+
377
+ Starts an MCP server that exposes SwarmSDK tools (Read, Write, Edit, Bash, Grep, Glob, etc.) for use in other AI systems. Tools can be space-separated or comma-separated.
378
+
379
+ ### Arguments
380
+
381
+ #### TOOL_NAMES
382
+
383
+ **Type:** String (optional, variadic)
384
+ **Default:** All available tools
385
+ **Format:** Space-separated or comma-separated tool names
386
+
387
+ **Available tools:**
388
+ - `Read`: Read files
389
+ - `Write`: Write files
390
+ - `Edit`: Edit files with find/replace
391
+ - `MultiEdit`: Edit multiple files
392
+ - `Bash`: Execute bash commands
393
+ - `Grep`: Search file contents (ripgrep)
394
+ - `Glob`: Find files by pattern
395
+ - `TodoWrite`: Manage task lists
396
+ - `Think`: Extended reasoning
397
+ - `WebFetch`: Fetch and process web content
398
+ - `ScratchpadWrite`: Write to shared scratchpad (volatile)
399
+ - `ScratchpadRead`: Read from shared scratchpad
400
+ - `ScratchpadList`: List scratchpad entries
401
+ - `MemoryWrite`: Write to per-agent memory (persistent)
402
+ - `MemoryRead`: Read from memory (with line numbers)
403
+ - `MemoryEdit`: Edit memory entries
404
+ - `MemoryMultiEdit`: Apply multiple edits to memory
405
+ - `MemoryGlob`: Search memory by glob pattern
406
+ - `MemoryGrep`: Search memory content by regex
407
+ - `MemoryDelete`: Delete memory entries
408
+
409
+ **Examples:**
410
+ ```bash
411
+ # All tools
412
+ swarm mcp tools
413
+
414
+ # Specific tools (space-separated)
415
+ swarm mcp tools Read Write Bash
416
+
417
+ # Specific tools (comma-separated)
418
+ swarm mcp tools Read,Write,Bash
419
+
420
+ # Mixed format
421
+ swarm mcp tools Read Write,Edit Bash
422
+ ```
423
+
424
+ ### Options
425
+
426
+ None beyond global `--help`.
427
+
428
+ ### Examples
429
+
430
+ ```bash
431
+ # Expose all tools
432
+ swarm mcp tools
433
+
434
+ # Expose file operations only
435
+ swarm mcp tools Read Write Edit
436
+
437
+ # Expose search tools
438
+ swarm mcp tools Grep Glob
439
+
440
+ # Expose scratchpad tools
441
+ swarm mcp tools ScratchpadWrite ScratchpadRead ScratchpadEdit ScratchpadMultiEdit ScratchpadGlob ScratchpadGrep
442
+
443
+ # Use in Claude Desktop configuration
444
+ {
445
+ "mcpServers": {
446
+ "swarm-tools": {
447
+ "command": "swarm",
448
+ "args": ["mcp", "tools", "Read", "Write", "Bash"]
449
+ }
450
+ }
451
+ }
452
+ ```
453
+
454
+ ### Exit Codes
455
+
456
+ - **0**: Success
457
+ - **1**: Error (invalid tool name, server startup error)
458
+ - **130**: Interrupted (Ctrl+C)
459
+
460
+ ---
461
+
462
+ ## Output Formats
463
+
464
+ ### Human Format
465
+
466
+ The default output format provides a rich, terminal-friendly experience:
467
+
468
+ **Features:**
469
+ - Colorized agent badges
470
+ - Progress spinners during execution
471
+ - Pretty-printed tool calls and results
472
+ - Usage statistics (tokens, cost, duration)
473
+ - Visual hierarchy with borders and spacing
474
+
475
+ **Flags:**
476
+ - `--quiet`: Suppress progress indicators
477
+ - `--truncate`: Truncate long outputs
478
+ - `--verbose`: Show system reminders and debug info
479
+
480
+ **Example output:**
481
+ ```
482
+ 🚀 Swarm starting: Development Team
483
+ Lead agent: backend
484
+
485
+ 👤 backend • gpt-5 • openai
486
+ Message 1 of 1 • 3 tools • Delegates to: frontend
487
+
488
+ 🔧 Read { file_path: "src/app.js" }
489
+ ✓ Read 142 lines
490
+
491
+ 💬 backend
492
+ Here is the code analysis...
493
+
494
+ ✅ Execution complete in 3.2s
495
+ Cost: $0.0045 • Tokens: 1,234
496
+ Agents: backend, frontend
497
+ ```
498
+
499
+ ### JSON Format
500
+
501
+ Structured event stream for programmatic consumption. Each line is a JSON object with a `type` field.
502
+
503
+ **Event types:**
504
+
505
+ #### `swarm_start`
506
+ ```json
507
+ {
508
+ "type": "swarm_start",
509
+ "swarm_name": "Development Team",
510
+ "lead_agent": "backend",
511
+ "prompt": "Build a REST API",
512
+ "timestamp": "2024-01-01T12:00:00Z"
513
+ }
514
+ ```
515
+
516
+ #### `user_prompt`
517
+ ```json
518
+ {
519
+ "type": "user_prompt",
520
+ "agent": "backend",
521
+ "model": "gpt-5",
522
+ "provider": "openai",
523
+ "message_count": 1,
524
+ "tools": ["Read", "Write", "Bash"],
525
+ "delegates_to": ["frontend"]
526
+ }
527
+ ```
528
+
529
+ #### `agent_step`
530
+ ```json
531
+ {
532
+ "type": "agent_step",
533
+ "agent": "backend",
534
+ "model": "gpt-5",
535
+ "content": "I'll read the file",
536
+ "tool_calls": [
537
+ {
538
+ "id": "call_123",
539
+ "name": "Read",
540
+ "arguments": { "file_path": "src/app.js" }
541
+ }
542
+ ],
543
+ "finish_reason": "tool_calls",
544
+ "usage": {
545
+ "input_tokens": 234,
546
+ "output_tokens": 56,
547
+ "total_tokens": 290,
548
+ "input_cost": 0.00117,
549
+ "output_cost": 0.00084,
550
+ "total_cost": 0.00201
551
+ }
552
+ }
553
+ ```
554
+
555
+ #### `tool_call`
556
+ ```json
557
+ {
558
+ "type": "tool_call",
559
+ "agent": "backend",
560
+ "tool_call_id": "call_123",
561
+ "tool": "Read",
562
+ "arguments": { "file_path": "src/app.js" }
563
+ }
564
+ ```
565
+
566
+ #### `tool_result`
567
+ ```json
568
+ {
569
+ "type": "tool_result",
570
+ "agent": "backend",
571
+ "tool_call_id": "call_123",
572
+ "tool": "Read",
573
+ "result": "File contents..."
574
+ }
575
+ ```
576
+
577
+ #### `agent_stop`
578
+ ```json
579
+ {
580
+ "type": "agent_stop",
581
+ "agent": "backend",
582
+ "model": "gpt-5",
583
+ "content": "Here is the analysis",
584
+ "finish_reason": "stop",
585
+ "usage": { ... }
586
+ }
587
+ ```
588
+
589
+ #### `swarm_stop`
590
+ ```json
591
+ {
592
+ "type": "swarm_stop",
593
+ "swarm_name": "Development Team",
594
+ "lead_agent": "backend",
595
+ "last_agent": "backend",
596
+ "content": "Analysis complete",
597
+ "success": true,
598
+ "duration": 3.2,
599
+ "total_cost": 0.0045,
600
+ "total_tokens": 1234,
601
+ "agents_involved": ["backend", "frontend"],
602
+ "timestamp": "2024-01-01T12:00:03Z"
603
+ }
604
+ ```
605
+
606
+ ---
607
+
608
+ ## Configuration Files
609
+
610
+ SwarmCLI accepts two configuration formats:
611
+
612
+ ### YAML Configuration
613
+
614
+ ```yaml
615
+ version: 2
616
+ swarm:
617
+ name: "Development Team"
618
+ lead: backend
619
+ agents:
620
+ backend:
621
+ description: "Backend developer"
622
+ model: gpt-5
623
+ tools: [Read, Write, Bash]
624
+ ```
625
+
626
+ See [YAML Reference](./yaml.md) for complete documentation.
627
+
628
+ ### Ruby DSL Configuration
629
+
630
+ ```ruby
631
+ SwarmSDK.build do
632
+ name "Development Team"
633
+ lead :backend
634
+
635
+ agent :backend do
636
+ model "gpt-5"
637
+ description "Backend developer"
638
+ tools :Read, :Write, :Bash
639
+ end
640
+ end
641
+ ```
642
+
643
+ See [Ruby DSL Reference](./ruby-dsl.md) for complete documentation.
644
+
645
+ ---
646
+
647
+ ## Environment Variables
648
+
649
+ SwarmCLI respects the following environment variables:
650
+
651
+ ### LLM Provider API Keys
652
+
653
+ **OpenAI:**
654
+ - `OPENAI_API_KEY`: OpenAI API key
655
+ - `OPENAI_BASE_URL`: Custom OpenAI API endpoint
656
+
657
+ **Anthropic:**
658
+ - `ANTHROPIC_API_KEY`: Anthropic API key
659
+
660
+ **Google:**
661
+ - `GOOGLE_API_KEY`: Google AI API key
662
+
663
+ **Other providers:** See RubyLLM documentation for provider-specific variables.
664
+
665
+ ### Debug
666
+
667
+ - `DEBUG=1`: Enable debug logging (MCP clients, internal operations)
668
+
669
+ ---
670
+
671
+ ## Common Workflows
672
+
673
+ ### Development Workflow
674
+
675
+ ```bash
676
+ # 1. Create configuration
677
+ cat > team.yml <<EOF
678
+ version: 2
679
+ swarm:
680
+ name: "Dev Team"
681
+ lead: developer
682
+ agents:
683
+ developer:
684
+ description: "Software developer"
685
+ model: gpt-5
686
+ tools: [Read, Write, Edit, Bash]
687
+ EOF
688
+
689
+ # 2. Test interactively
690
+ swarm run team.yml
691
+
692
+ # 3. Test non-interactively
693
+ swarm run team.yml -p "Add error handling to app.js"
694
+
695
+ # 4. Use JSON output for automation
696
+ swarm run team.yml -p "Run tests" --output-format json | jq
697
+ ```
698
+
699
+ ### CI/CD Integration
700
+
701
+ ```bash
702
+ # Run swarm task and check exit code
703
+ swarm run ci-swarm.yml -p "Run linter and tests" --quiet
704
+ if [ $? -eq 0 ]; then
705
+ echo "All checks passed"
706
+ else
707
+ echo "Checks failed"
708
+ exit 1
709
+ fi
710
+ ```
711
+
712
+ ### MCP Server Setup
713
+
714
+ ```bash
715
+ # Start swarm as MCP server (daemonize or run in tmux/screen)
716
+ swarm mcp serve team.yml
717
+
718
+ # Or expose just tools
719
+ swarm mcp tools Read Write Bash
720
+ ```
721
+
722
+ ---
723
+
724
+ ## See Also
725
+
726
+ - [YAML Reference](./yaml.md): Complete YAML configuration reference
727
+ - [Ruby DSL Reference](./ruby-dsl.md): Complete Ruby DSL reference
728
+ - [Getting Started Guide](../guides/getting-started.md): Introduction to SwarmSDK
729
+ - [Quick Start CLI](../guides/quick-start-cli.md): Quick CLI examples