legionio 1.4.118 → 1.4.119

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a10f06b3cc591d8fa5aae3b31216e037826f961962df05276ba5fbd78805235c
4
- data.tar.gz: 5a9e88f6bbb42b27586adba45becd7ecaedc69f190bd3f0fbddb3de27fcffd79
3
+ metadata.gz: ac22c22ec64e117b1568d5569a2983e46fdc9aadb566642c05c35973fb29428a
4
+ data.tar.gz: e6b5a99eebc5b0de37a59ad9cebc4fd5e96b8fb125b1974faa64e2454e268907
5
5
  SHA512:
6
- metadata.gz: 3cab7e4e400553baf1b57918d610dbb7a0dd1143dd4df52f104bd03e55d23e53bfbffd815c32b9836ec421ba58c613b32ec97d6af0b68f26cf0fdb55570e7790
7
- data.tar.gz: 13c8e47feeccf21c4ea33b2ddd31f37f8afd6f73765e6df48ead40e6e2a96125019c9b5aa1107383db46958bcaf51a7cd593344f70b1d295e807dedf33b1d41f
6
+ metadata.gz: 789c1485afd78d006d6d9aad725e483c5b6fd467a952476a11e1db29ac8c710f9d80c7e8dce4ac0045627abc45defae5ae45ebe995d167b95ffa866897ae4979
7
+ data.tar.gz: 852f58359d4cb4beb1a1708f6d01f9423dc2d18e0d9f028493f2f018eaa5f999b87c564b8015d39004f08ff70e43e41ff92bfcb075fc28b8608281c702704fd8
data/.rubocop.yml CHANGED
@@ -48,6 +48,7 @@ Metrics/BlockLength:
48
48
  - 'lib/legion/api/acp.rb'
49
49
  - 'lib/legion/api/auth_saml.rb'
50
50
  - 'lib/legion/cli/failover_command.rb'
51
+ - 'lib/legion/cli/setup_command.rb'
51
52
 
52
53
  Metrics/AbcSize:
53
54
  Max: 60
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Legion Changelog
2
2
 
3
+ ## [1.4.119] - 2026-03-22
4
+
5
+ ### Added
6
+ - `legion setup claude-code` installs Legion MCP server entry into `~/.claude/settings.json` and writes the `/legion` slash command skill to `~/.claude/commands/legion.md`
7
+ - `legion setup cursor` installs Legion MCP server entry into `.cursor/mcp.json` in the current project directory
8
+ - `legion setup vscode` installs Legion MCP server entry into `.vscode/mcp.json` using the VS Code stdio server format
9
+ - `legion setup status` shows which platforms (Claude Code, Cursor, VS Code) have Legion MCP configured
10
+ - All `legion setup` subcommands support `--force` to overwrite existing entries and `--json` for machine-readable output
11
+ - MCP installs merge with existing server configs rather than overwriting unrelated entries
12
+
3
13
  ## [1.4.118] - 2026-03-22
4
14
 
5
15
  ### Added
@@ -0,0 +1,252 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'fileutils'
5
+ require 'thor'
6
+ require 'legion/cli/output'
7
+
8
+ module Legion
9
+ module CLI
10
+ class Setup < Thor
11
+ namespace 'setup'
12
+
13
+ def self.exit_on_failure?
14
+ true
15
+ end
16
+
17
+ class_option :json, type: :boolean, default: false, desc: 'Output as JSON'
18
+ class_option :no_color, type: :boolean, default: false, desc: 'Disable color output'
19
+ class_option :force, type: :boolean, default: false, desc: 'Overwrite existing config'
20
+
21
+ LEGION_MCP_ENTRY = {
22
+ 'command' => 'legionio',
23
+ 'args' => %w[mcp stdio]
24
+ }.freeze
25
+
26
+ SKILL_CONTENT = <<~MARKDOWN
27
+ ---
28
+ name: legion
29
+ description: Orchestrate LegionIO extensions and agents
30
+ ---
31
+
32
+ You have access to LegionIO MCP tools. When the user asks you to work with Legion:
33
+
34
+ 1. Use `legion.discover_tools` to find relevant capabilities
35
+ 2. Use `legion.do_action` for natural language task routing
36
+ 3. Use `legion.run_task` to execute specific extension functions
37
+ 4. Use `legion.list_peers` and `legion.ask_peer` for agent coordination
38
+ 5. Present results as a consolidated summary
39
+ MARKDOWN
40
+
41
+ desc 'claude-code', 'Install Legion MCP server and slash command skill for Claude Code'
42
+ def claude_code
43
+ out = formatter
44
+ installed = []
45
+
46
+ install_claude_mcp(installed)
47
+ install_claude_skill(installed)
48
+
49
+ if options[:json]
50
+ out.json(platform: 'claude-code', installed: installed)
51
+ else
52
+ out.spacer
53
+ out.success("Legion configured for Claude Code (#{installed.size} item(s))")
54
+ out.spacer
55
+ puts " Run '/legion' in Claude Code to use your LegionIO tools."
56
+ end
57
+ end
58
+
59
+ desc 'cursor', 'Install Legion MCP server config for Cursor'
60
+ def cursor
61
+ out = formatter
62
+ path = File.join(Dir.pwd, '.cursor', 'mcp.json')
63
+ installed = []
64
+
65
+ write_mcp_servers_json(nil, path, installed)
66
+
67
+ if options[:json]
68
+ out.json(platform: 'cursor', installed: installed)
69
+ else
70
+ out.spacer
71
+ out.success("Legion configured for Cursor (#{installed.size} item(s))")
72
+ out.spacer
73
+ puts " MCP config written to: #{path}"
74
+ end
75
+ end
76
+
77
+ desc 'vscode', 'Install Legion MCP server config for VS Code'
78
+ def vscode
79
+ out = formatter
80
+ path = File.join(Dir.pwd, '.vscode', 'mcp.json')
81
+ installed = []
82
+
83
+ write_vscode_mcp_json(nil, path, installed)
84
+
85
+ if options[:json]
86
+ out.json(platform: 'vscode', installed: installed)
87
+ else
88
+ out.spacer
89
+ out.success("Legion configured for VS Code (#{installed.size} item(s))")
90
+ out.spacer
91
+ puts " MCP config written to: #{path}"
92
+ end
93
+ end
94
+
95
+ desc 'status', 'Show which platforms have Legion MCP configured'
96
+ def status
97
+ out = formatter
98
+ platforms = check_all_platforms
99
+
100
+ if options[:json]
101
+ out.json(platforms: platforms)
102
+ else
103
+ out.header('Legion MCP Setup Status')
104
+ out.spacer
105
+ platforms.each do |p|
106
+ icon = p[:configured] ? out.colorize('configured', :success) : out.colorize('not configured', :muted)
107
+ puts " #{out.colorize(p[:name].ljust(16), :label)} #{icon}"
108
+ puts " #{out.colorize(p[:path], :muted)}" if p[:path]
109
+ end
110
+ out.spacer
111
+ configured_count = platforms.count { |p| p[:configured] }
112
+ puts " #{configured_count} of #{platforms.size} platform(s) configured"
113
+ end
114
+ end
115
+
116
+ no_commands do
117
+ def formatter
118
+ @formatter ||= Output::Formatter.new(
119
+ json: options[:json],
120
+ color: !options[:no_color]
121
+ )
122
+ end
123
+
124
+ private
125
+
126
+ def install_claude_mcp(installed)
127
+ settings_path = File.expand_path('~/.claude/settings.json')
128
+ existing = load_json_file(settings_path)
129
+ servers = existing['mcpServers'] || {}
130
+
131
+ if servers.key?('legion') && !options[:force]
132
+ puts ' Claude Code MCP entry already present (use --force to overwrite)' unless options[:json]
133
+ return
134
+ end
135
+
136
+ servers['legion'] = LEGION_MCP_ENTRY
137
+ existing['mcpServers'] = servers
138
+
139
+ write_json_file(settings_path, existing)
140
+ installed << settings_path
141
+ puts " Wrote MCP server entry to #{settings_path}" unless options[:json]
142
+ end
143
+
144
+ def install_claude_skill(installed)
145
+ skill_path = File.expand_path('~/.claude/commands/legion.md')
146
+
147
+ if File.exist?(skill_path) && !options[:force]
148
+ puts ' Claude Code skill already present (use --force to overwrite)' unless options[:json]
149
+ return
150
+ end
151
+
152
+ FileUtils.mkdir_p(File.dirname(skill_path))
153
+ File.write(skill_path, SKILL_CONTENT)
154
+ installed << skill_path
155
+ puts " Wrote slash command skill to #{skill_path}" unless options[:json]
156
+ end
157
+
158
+ def write_mcp_servers_json(_out, path, installed)
159
+ existing = load_json_file(path)
160
+ servers = existing['mcpServers'] || {}
161
+
162
+ if servers.key?('legion') && !options[:force]
163
+ puts " Legion entry already present in #{path} (use --force to overwrite)" unless options[:json]
164
+ return
165
+ end
166
+
167
+ servers['legion'] = LEGION_MCP_ENTRY
168
+ existing['mcpServers'] = servers
169
+
170
+ write_json_file(path, existing)
171
+ installed << path
172
+ puts " Wrote MCP config to #{path}" unless options[:json]
173
+ end
174
+
175
+ def write_vscode_mcp_json(_out, path, installed)
176
+ existing = load_json_file(path)
177
+ servers = existing['servers'] || {}
178
+
179
+ if servers.key?('legion') && !options[:force]
180
+ puts " Legion entry already present in #{path} (use --force to overwrite)" unless options[:json]
181
+ return
182
+ end
183
+
184
+ servers['legion'] = {
185
+ 'type' => 'stdio',
186
+ 'command' => 'legionio',
187
+ 'args' => %w[mcp stdio]
188
+ }
189
+ existing['servers'] = servers
190
+
191
+ write_json_file(path, existing)
192
+ installed << path
193
+ puts " Wrote MCP config to #{path}" unless options[:json]
194
+ end
195
+
196
+ def load_json_file(path)
197
+ return {} unless File.exist?(path)
198
+
199
+ ::JSON.parse(File.read(path))
200
+ rescue ::JSON::ParserError
201
+ {}
202
+ end
203
+
204
+ def write_json_file(path, data)
205
+ FileUtils.mkdir_p(File.dirname(path))
206
+ File.write(path, ::JSON.pretty_generate(data))
207
+ end
208
+
209
+ def check_all_platforms
210
+ [
211
+ check_claude_code,
212
+ check_cursor,
213
+ check_vscode
214
+ ]
215
+ end
216
+
217
+ def check_claude_code
218
+ path = File.expand_path('~/.claude/settings.json')
219
+ configured = begin
220
+ data = ::JSON.parse(File.read(path))
221
+ data.dig('mcpServers', 'legion') ? true : false
222
+ rescue StandardError
223
+ false
224
+ end
225
+ { name: 'Claude Code', path: path, configured: configured }
226
+ end
227
+
228
+ def check_cursor
229
+ path = File.join(Dir.pwd, '.cursor', 'mcp.json')
230
+ configured = begin
231
+ data = ::JSON.parse(File.read(path))
232
+ data.dig('mcpServers', 'legion') ? true : false
233
+ rescue StandardError
234
+ false
235
+ end
236
+ { name: 'Cursor', path: path, configured: configured }
237
+ end
238
+
239
+ def check_vscode
240
+ path = File.join(Dir.pwd, '.vscode', 'mcp.json')
241
+ configured = begin
242
+ data = ::JSON.parse(File.read(path))
243
+ data.dig('servers', 'legion') ? true : false
244
+ rescue StandardError
245
+ false
246
+ end
247
+ { name: 'VS Code', path: path, configured: configured }
248
+ end
249
+ end
250
+ end
251
+ end
252
+ end
data/lib/legion/cli.rb CHANGED
@@ -41,6 +41,7 @@ module Legion
41
41
  autoload :Eval, 'legion/cli/eval_command'
42
42
  autoload :Update, 'legion/cli/update_command'
43
43
  autoload :Init, 'legion/cli/init_command'
44
+ autoload :Setup, 'legion/cli/setup_command'
44
45
  autoload :Skill, 'legion/cli/skill_command'
45
46
  autoload :Prompt, 'legion/cli/prompt_command'
46
47
  autoload :Image, 'legion/cli/image_command'
@@ -255,6 +256,9 @@ module Legion
255
256
  desc 'init', 'Initialize a new Legion workspace'
256
257
  subcommand 'init', Legion::CLI::Init
257
258
 
259
+ desc 'setup SUBCOMMAND', 'Set up Legion MCP integration for IDEs'
260
+ subcommand 'setup', Legion::CLI::Setup
261
+
258
262
  desc 'skill', 'Manage skills (.legion/skills/ markdown files)'
259
263
  subcommand 'skill', Legion::CLI::Skill
260
264
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Legion
4
- VERSION = '1.4.118'
4
+ VERSION = '1.4.119'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legionio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.118
4
+ version: 1.4.119
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -575,6 +575,7 @@ files:
575
575
  - lib/legion/cli/relationship.rb
576
576
  - lib/legion/cli/review_command.rb
577
577
  - lib/legion/cli/schedule_command.rb
578
+ - lib/legion/cli/setup_command.rb
578
579
  - lib/legion/cli/skill_command.rb
579
580
  - lib/legion/cli/start.rb
580
581
  - lib/legion/cli/status.rb