enhance_swarm 1.0.0

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/.enhance_swarm/agent_scripts/frontend_agent.md +39 -0
  3. data/.enhance_swarm/user_patterns.json +37 -0
  4. data/CHANGELOG.md +184 -0
  5. data/LICENSE +21 -0
  6. data/PRODUCTION_TEST_LOG.md +502 -0
  7. data/README.md +905 -0
  8. data/Rakefile +28 -0
  9. data/USAGE_EXAMPLES.md +477 -0
  10. data/examples/enhance_workflow.md +346 -0
  11. data/examples/rails_project.md +253 -0
  12. data/exe/enhance-swarm +30 -0
  13. data/lib/enhance_swarm/additional_commands.rb +299 -0
  14. data/lib/enhance_swarm/agent_communicator.rb +460 -0
  15. data/lib/enhance_swarm/agent_reviewer.rb +283 -0
  16. data/lib/enhance_swarm/agent_spawner.rb +462 -0
  17. data/lib/enhance_swarm/cleanup_manager.rb +245 -0
  18. data/lib/enhance_swarm/cli.rb +1592 -0
  19. data/lib/enhance_swarm/command_executor.rb +78 -0
  20. data/lib/enhance_swarm/configuration.rb +324 -0
  21. data/lib/enhance_swarm/control_agent.rb +307 -0
  22. data/lib/enhance_swarm/dependency_validator.rb +195 -0
  23. data/lib/enhance_swarm/error_recovery.rb +785 -0
  24. data/lib/enhance_swarm/generator.rb +194 -0
  25. data/lib/enhance_swarm/interrupt_handler.rb +512 -0
  26. data/lib/enhance_swarm/logger.rb +106 -0
  27. data/lib/enhance_swarm/mcp_integration.rb +85 -0
  28. data/lib/enhance_swarm/monitor.rb +28 -0
  29. data/lib/enhance_swarm/notification_manager.rb +444 -0
  30. data/lib/enhance_swarm/orchestrator.rb +313 -0
  31. data/lib/enhance_swarm/output_streamer.rb +281 -0
  32. data/lib/enhance_swarm/process_monitor.rb +266 -0
  33. data/lib/enhance_swarm/progress_tracker.rb +215 -0
  34. data/lib/enhance_swarm/project_analyzer.rb +612 -0
  35. data/lib/enhance_swarm/resource_manager.rb +177 -0
  36. data/lib/enhance_swarm/retry_handler.rb +40 -0
  37. data/lib/enhance_swarm/session_manager.rb +247 -0
  38. data/lib/enhance_swarm/signal_handler.rb +95 -0
  39. data/lib/enhance_swarm/smart_defaults.rb +708 -0
  40. data/lib/enhance_swarm/task_integration.rb +150 -0
  41. data/lib/enhance_swarm/task_manager.rb +174 -0
  42. data/lib/enhance_swarm/version.rb +5 -0
  43. data/lib/enhance_swarm/visual_dashboard.rb +555 -0
  44. data/lib/enhance_swarm/web_ui.rb +211 -0
  45. data/lib/enhance_swarm.rb +69 -0
  46. data/setup.sh +86 -0
  47. data/sig/enhance_swarm.rbs +4 -0
  48. data/templates/claude/CLAUDE.md +160 -0
  49. data/templates/claude/MCP.md +117 -0
  50. data/templates/claude/PERSONAS.md +114 -0
  51. data/templates/claude/RULES.md +221 -0
  52. data/test_builtin_functionality.rb +121 -0
  53. data/test_core_components.rb +156 -0
  54. data/test_real_claude_integration.rb +285 -0
  55. data/test_security.rb +150 -0
  56. data/test_smart_defaults.rb +155 -0
  57. data/test_task_integration.rb +173 -0
  58. data/test_web_ui.rb +245 -0
  59. data/web/assets/css/main.css +645 -0
  60. data/web/assets/js/kanban.js +499 -0
  61. data/web/assets/js/main.js +525 -0
  62. data/web/templates/dashboard.html.erb +226 -0
  63. data/web/templates/kanban.html.erb +193 -0
  64. metadata +293 -0
@@ -0,0 +1,299 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EnhanceSwarm
4
+ module AdditionalCommands
5
+ def self.add_commands_to(cli_class)
6
+ cli_class.class_eval do
7
+ desc 'dashboard', 'Start visual agent dashboard'
8
+ option :agents, type: :array, desc: 'Specific agent IDs to monitor'
9
+ option :refresh, type: :numeric, default: 2, desc: 'Refresh rate in seconds'
10
+ option :snapshot, type: :boolean, desc: 'Take dashboard snapshot and exit'
11
+ def dashboard
12
+ if options[:snapshot]
13
+ agents = discover_running_agents
14
+ VisualDashboard.instance.display_snapshot(agents)
15
+ return
16
+ end
17
+
18
+ say "๐Ÿ–ฅ๏ธ Starting Visual Agent Dashboard...", :green
19
+
20
+ # Create demo agents if none running
21
+ agents = options[:agents] ?
22
+ load_specific_agents(options[:agents]) :
23
+ discover_running_agents
24
+
25
+ if agents.empty?
26
+ say "No agents found, creating demo agents for dashboard...", :yellow
27
+ agents = create_demo_agents
28
+ end
29
+
30
+ dashboard = VisualDashboard.instance
31
+ dashboard.instance_variable_set(:@refresh_rate, options[:refresh])
32
+
33
+ begin
34
+ dashboard.start_dashboard(agents)
35
+ rescue Interrupt
36
+ say "\n๐Ÿ–ฅ๏ธ Dashboard stopped by user", :yellow
37
+ end
38
+ end
39
+
40
+ desc 'notifications', 'Manage notification settings'
41
+ option :enable, type: :boolean, desc: 'Enable notifications'
42
+ option :disable, type: :boolean, desc: 'Disable notifications'
43
+ option :test, type: :boolean, desc: 'Test notification system'
44
+ option :status, type: :boolean, desc: 'Show notification status'
45
+ def notifications
46
+ notification_manager = NotificationManager.instance
47
+
48
+ if options[:enable]
49
+ notification_manager.enable!
50
+ say "โœ… Notifications enabled", :green
51
+ elsif options[:disable]
52
+ notification_manager.disable!
53
+ say "๐Ÿ”• Notifications disabled", :yellow
54
+ elsif options[:test]
55
+ say "๐Ÿ”” Testing notification system...", :blue
56
+ notification_manager.test_notifications
57
+ say "โœ… Notification test completed", :green
58
+ else
59
+ # Show status by default
60
+ enabled = notification_manager.enabled?
61
+ say "\n๐Ÿ’ฌ Notification Status:", :blue
62
+ say " Enabled: #{enabled ? 'โœ… Yes' : 'โŒ No'}"
63
+ say " Platform: #{RUBY_PLATFORM}"
64
+
65
+ if enabled
66
+ say "\n๐Ÿ”” Testing notifications..."
67
+ notification_manager.agent_completed('demo-123', 'backend', 120, { success: true })
68
+ end
69
+ end
70
+ end
71
+
72
+ desc 'communicate', 'Manage agent communication and messages'
73
+ option :status, type: :boolean, desc: 'Show communication status'
74
+ option :demo, type: :boolean, desc: 'Demo communication features'
75
+ def communicate
76
+ communicator = AgentCommunicator.instance
77
+
78
+ if options[:demo]
79
+ say "๐Ÿ’ฌ Demo Agent Communication", :green
80
+ say "Creating demo messages...", :blue
81
+
82
+ # Create demo messages
83
+ communicator.agent_question('demo-backend', 'Should I use PostgreSQL or MySQL?',
84
+ ['PostgreSQL', 'MySQL', 'SQLite'])
85
+ communicator.agent_status('demo-frontend', 'UI components 60% complete')
86
+
87
+ say "โœ… Demo messages created", :green
88
+ say "Use 'enhance-swarm communicate --status' to see them"
89
+ else
90
+ # Show status
91
+ pending = communicator.pending_messages
92
+ recent = communicator.recent_messages(5)
93
+
94
+ say "\n๐Ÿ’ฌ Agent Communication Status:", :blue
95
+ say " Pending messages: #{pending.count}"
96
+ say " Recent messages: #{recent.count}"
97
+
98
+ if pending.any?
99
+ say "\n๐Ÿ“‹ Recent Messages:", :yellow
100
+ pending.first(3).each_with_index do |message, index|
101
+ say " #{index + 1}. #{message[:type]} from #{message[:role]}"
102
+ say " #{message[:content][0..60]}..."
103
+ end
104
+ else
105
+ say " No messages currently"
106
+ say "\nTry: enhance-swarm communicate --demo"
107
+ end
108
+ end
109
+ end
110
+
111
+ desc 'suggest', 'Get smart suggestions for next actions'
112
+ option :context, type: :string, desc: 'Additional context for suggestions'
113
+ def suggest
114
+ say "๐Ÿง  Analyzing project and generating smart suggestions...", :blue
115
+
116
+ context = {
117
+ git_status: { modified_files: 2, untracked_files: 1 },
118
+ project_files: { ruby_files: 15, test_files: 8 },
119
+ user_context: options[:context]
120
+ }
121
+
122
+ suggestions = SmartDefaults.get_suggestions(context)
123
+
124
+ if suggestions.empty?
125
+ say "โœ… No suggestions at this time. Your project looks good!", :green
126
+ return
127
+ end
128
+
129
+ say "\n๐Ÿ’ก Smart Suggestions:\n", :yellow
130
+
131
+ suggestions.each_with_index do |suggestion, i|
132
+ priority_color = case suggestion[:priority]
133
+ when :high then :red
134
+ when :medium then :yellow
135
+ when :low then :blue
136
+ else :white
137
+ end
138
+
139
+ say "#{i + 1}. [#{suggestion[:priority].to_s.upcase}] #{suggestion[:description]}", priority_color
140
+ say " Command: #{suggestion[:command]}", :light_black if suggestion[:command]
141
+ say ""
142
+ end
143
+ end
144
+
145
+ desc 'recover', 'Intelligent error recovery and analysis'
146
+ option :analyze, type: :string, desc: 'Analyze specific error message'
147
+ option :stats, type: :boolean, desc: 'Show error recovery statistics'
148
+ option :demo, type: :boolean, desc: 'Demo error recovery features'
149
+ def recover
150
+ error_recovery = ErrorRecovery.instance
151
+
152
+ if options[:analyze]
153
+ say "๐Ÿ” Analyzing error: #{options[:analyze]}", :blue
154
+
155
+ test_error = StandardError.new(options[:analyze])
156
+ analysis = error_recovery.analyze_error(test_error, { context: 'cli_demo' })
157
+
158
+ say "\n๐Ÿ“Š Error Analysis:", :yellow
159
+ say " Type: #{analysis[:error][:type]}"
160
+ say " Auto-recoverable: #{analysis[:auto_recoverable] ? 'Yes' : 'No'}"
161
+ say " Suggestions: #{analysis[:suggestions].count}"
162
+
163
+ if analysis[:suggestions].any?
164
+ say "\n๐Ÿ’ก Recovery Suggestions:", :green
165
+ analysis[:suggestions].first(3).each_with_index do |suggestion, i|
166
+ description = suggestion['description'] || suggestion[:description]
167
+ say " #{i + 1}. #{description}"
168
+ end
169
+ end
170
+
171
+ elsif options[:stats]
172
+ stats = error_recovery.recovery_statistics
173
+
174
+ say "\n๐Ÿ“Š Error Recovery Statistics:", :blue
175
+ say " Total errors processed: #{stats[:total_errors_processed]}"
176
+ say " Successful recoveries: #{stats[:successful_automatic_recoveries]}"
177
+ say " Success rate: #{stats[:recovery_success_rate]}%"
178
+ say " Patterns learned: #{stats[:recovery_patterns_learned]}"
179
+
180
+ elsif options[:demo]
181
+ say "๐Ÿ”ง Demo Error Recovery", :green
182
+
183
+ # Demo different error types
184
+ errors = [
185
+ 'Connection timeout after 30 seconds',
186
+ 'No such file or directory - missing.rb',
187
+ 'Permission denied accessing /etc/hosts'
188
+ ]
189
+
190
+ errors.each do |error_msg|
191
+ say "\n๐Ÿ” Analyzing: #{error_msg}", :blue
192
+ test_error = StandardError.new(error_msg)
193
+ analysis = error_recovery.analyze_error(test_error)
194
+
195
+ say " Auto-recoverable: #{analysis[:auto_recoverable] ? 'โœ… Yes' : 'โŒ No'}"
196
+ say " Suggestions: #{analysis[:suggestions].count}"
197
+ end
198
+
199
+ else
200
+ say "Please specify an action:", :yellow
201
+ say " --analyze 'error message' - Analyze specific error"
202
+ say " --stats - Show recovery statistics"
203
+ say " --demo - Demo error recovery features"
204
+ end
205
+ end
206
+
207
+ desc 'troubleshoot', 'Interactive troubleshooting assistant'
208
+ def troubleshoot
209
+ say "๐Ÿ”ง EnhanceSwarm Troubleshooting Assistant", :green
210
+ say "โ”€" * 50, :light_black
211
+
212
+ # Quick system check
213
+ say "\n๐Ÿ” Quick System Check:", :blue
214
+
215
+ # Check dependencies
216
+ begin
217
+ require 'thor'
218
+ say " โœ… Thor gem available"
219
+ rescue LoadError
220
+ say " โŒ Thor gem missing"
221
+ end
222
+
223
+ begin
224
+ require 'colorize'
225
+ say " โœ… Colorize gem available"
226
+ rescue LoadError
227
+ say " โŒ Colorize gem missing"
228
+ end
229
+
230
+ # Check git
231
+ git_available = system('git --version > /dev/null 2>&1')
232
+ say " #{git_available ? 'โœ…' : 'โŒ'} Git #{git_available ? 'available' : 'not found'}"
233
+
234
+ # Check project structure
235
+ enhance_config = File.exist?('.enhance_swarm.yml')
236
+ say " #{enhance_config ? 'โœ…' : 'โŒ'} Project config #{enhance_config ? 'found' : 'missing'}"
237
+
238
+ # Test core classes
239
+ say "\n๐Ÿงช Testing Core Classes:", :blue
240
+
241
+ classes = %w[NotificationManager VisualDashboard SmartDefaults ErrorRecovery AgentCommunicator]
242
+ classes.each do |cls|
243
+ begin
244
+ klass = EnhanceSwarm.const_get(cls)
245
+ klass.instance if klass.respond_to?(:instance)
246
+ say " โœ… #{cls} working"
247
+ rescue => e
248
+ say " โŒ #{cls} error: #{e.message}"
249
+ end
250
+ end
251
+
252
+ say "\nโœ… Troubleshooting completed!", :green
253
+ say "If issues persist, check the README for setup instructions."
254
+ end
255
+
256
+ private
257
+
258
+ def discover_running_agents
259
+ # Return demo agents for now since we don't have real agent discovery
260
+ []
261
+ end
262
+
263
+ def load_specific_agents(agent_ids)
264
+ agent_ids.map do |id|
265
+ {
266
+ id: id,
267
+ role: 'backend',
268
+ status: 'running',
269
+ progress: rand(10..90),
270
+ start_time: Time.now - rand(60..3600),
271
+ pid: rand(1000..9999)
272
+ }
273
+ end
274
+ end
275
+
276
+ def create_demo_agents
277
+ [
278
+ {
279
+ id: 'backend-auth-123',
280
+ role: 'backend',
281
+ status: 'running',
282
+ progress: 75,
283
+ start_time: Time.now - 300,
284
+ pid: 1234
285
+ },
286
+ {
287
+ id: 'frontend-ui-456',
288
+ role: 'frontend',
289
+ status: 'completed',
290
+ progress: 100,
291
+ start_time: Time.now - 600,
292
+ pid: 5678
293
+ }
294
+ ]
295
+ end
296
+ end
297
+ end
298
+ end
299
+ end