enhance_swarm 1.0.0 → 2.1.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/CLAUDE.md +164 -0
  3. data/.claude/MCP.md +117 -0
  4. data/.claude/PERSONAS.md +114 -0
  5. data/.claude/RULES.md +221 -0
  6. data/.enhance_swarm/archives/session_1751182876_06ee7e0e_20250629_094116.json +16 -0
  7. data/.enhance_swarm/archives/session_1751187567_9d1227c8_20250629_105927.json +16 -0
  8. data/.enhance_swarm/archives/session_1751190454_6faf48a2_20250629_114734.json +16 -0
  9. data/.enhance_swarm/archives/session_1751190516_3e4f9437_20250629_114836.json +16 -0
  10. data/.enhance_swarm/archives/session_1751192354_79568f0f_20250629_121914.json +16 -0
  11. data/.enhance_swarm/archives/session_1751195070_99653548_20250629_130433.json +16 -0
  12. data/.enhance_swarm/archives/session_1751196542_a292e40c_20250629_132902.json +7 -0
  13. data/.enhance_swarm/archives/session_1751196824_9b65d28e_20250629_133344.json +24 -0
  14. data/.enhance_swarm/archives/session_1751197867_d16edbc5_20250629_135109.json +24 -0
  15. data/.enhance_swarm/archives/session_1751208541_f9531ce5_20250629_164901.json +16 -0
  16. data/.enhance_swarm/logs/backend_error.log +0 -0
  17. data/.enhance_swarm/logs/backend_output.log +0 -0
  18. data/.enhance_swarm/logs/debug_manual_error.log +0 -0
  19. data/.enhance_swarm/logs/debug_manual_output.log +18 -0
  20. data/.enhance_swarm/logs/frontend_error.log +0 -0
  21. data/.enhance_swarm/logs/frontend_output.log +45 -0
  22. data/.enhance_swarm/logs/general_error.log +0 -0
  23. data/.enhance_swarm/logs/general_output.log +0 -0
  24. data/.enhance_swarm/user_patterns.json +5 -5
  25. data/.enhance_swarm.yml +33 -0
  26. data/CHANGELOG.md +71 -0
  27. data/DEPLOYMENT.md +344 -0
  28. data/README.md +277 -789
  29. data/lib/enhance_swarm/agent_spawner.rb +210 -13
  30. data/lib/enhance_swarm/cli.rb +169 -8
  31. data/lib/enhance_swarm/control_agent.rb +28 -27
  32. data/lib/enhance_swarm/smart_orchestration.rb +60 -0
  33. data/lib/enhance_swarm/task_coordinator.rb +1327 -0
  34. data/lib/enhance_swarm/version.rb +1 -1
  35. data/lib/enhance_swarm/visual_dashboard.rb +2 -1
  36. metadata +34 -20
  37. data/PRODUCTION_TEST_LOG.md +0 -502
  38. data/setup.sh +0 -86
  39. data/test_builtin_functionality.rb +0 -121
  40. data/test_core_components.rb +0 -156
  41. data/test_real_claude_integration.rb +0 -285
  42. data/test_security.rb +0 -150
  43. data/test_smart_defaults.rb +0 -155
  44. data/test_task_integration.rb +0 -173
  45. data/test_web_ui.rb +0 -245
  46. data/web/assets/css/main.css +0 -645
  47. data/web/assets/js/kanban.js +0 -499
  48. data/web/assets/js/main.js +0 -525
  49. data/web/templates/dashboard.html.erb +0 -226
  50. data/web/templates/kanban.html.erb +0 -193
@@ -255,15 +255,17 @@ module EnhanceSwarm
255
255
  ## Your Task:
256
256
  #{base_prompt}
257
257
 
258
- ## Important Instructions:
259
- 1. Stay focused on your role as a #{role} specialist
260
- 2. Follow the project's code standards and conventions
261
- 3. Work autonomously but consider integration with other agents
262
- 4. Create high-quality, production-ready code
263
- 5. Include comprehensive tests where appropriate
264
- 6. Document your changes and decisions
265
- 7. If you encounter permission issues, provide detailed implementation plans instead
266
- 8. Always output what you would implement, even if file operations fail
258
+ ## Critical Instructions:
259
+ 1. YOU MUST ACTUALLY IMPLEMENT CODE - Use Read, Edit, Write, and Bash tools to create real files
260
+ 2. Stay focused on your role as a #{role} specialist
261
+ 3. Follow the project's code standards and conventions
262
+ 4. Work autonomously - DO NOT ASK FOR PERMISSION, JUST IMPLEMENT
263
+ 5. Create high-quality, production-ready code with proper validations
264
+ 6. 🚨 FOR BULLET TRAIN PROJECTS: ALWAYS use Super Scaffolding - NEVER create manual models!
265
+ 7. 🎨 FOR BULLET TRAIN PROJECTS: ALWAYS use Tailwind CSS - NEVER Bootstrap or custom CSS!
266
+ 8. Use Bash tool to run Rails generators, database migrations, and tests
267
+ 9. Commit your changes when complete using Git commands
268
+ 10. If you encounter any issues, fix them and continue until task is complete
267
269
 
268
270
  ## Available Tools:
269
271
  You have access to all Claude Code tools for file editing, terminal commands, and project analysis.
@@ -275,7 +277,14 @@ module EnhanceSwarm
275
277
  end
276
278
 
277
279
  def get_role_description(role)
278
- case role.to_s.downcase
280
+ config = EnhanceSwarm.configuration
281
+ project_analyzer = ProjectAnalyzer.new
282
+ project_context = project_analyzer.generate_smart_defaults
283
+
284
+ # Check if this is a Bullet Train project
285
+ is_bullet_train = has_bullet_train_stack?(config, project_context)
286
+
287
+ base_description = case role.to_s.downcase
279
288
  when 'backend'
280
289
  'You specialize in server-side logic, APIs, database design, models, and business logic implementation.'
281
290
  when 'frontend'
@@ -286,9 +295,195 @@ module EnhanceSwarm
286
295
  'You specialize in user experience design, interaction flows, accessibility, and user-centric improvements.'
287
296
  when 'general'
288
297
  'You are a general-purpose agent capable of handling various development tasks across the full stack.'
298
+ when 'scaffolding'
299
+ 'You specialize in Bullet Train Super Scaffolding, following Andrew Culver\'s conventions for team-scoped architecture, model relationships, and framework configuration.'
289
300
  else
290
301
  "You are a #{role} specialist agent focusing on your area of expertise."
291
302
  end
303
+
304
+ # Add Bullet Train specific instructions if this is a BT project
305
+ if is_bullet_train
306
+ base_description + get_bullet_train_role_enhancement(role)
307
+ else
308
+ base_description
309
+ end
310
+ end
311
+
312
+ def has_bullet_train_stack?(config, project_context)
313
+ # Check Gemfile for bullet_train gems
314
+ return true if File.exist?('Gemfile') && File.read('Gemfile').include?('bullet_train')
315
+
316
+ # Check technology stack
317
+ tech_stack = config.technology_stack || project_context[:technology_stack] || []
318
+ tech_stack.include?('Bullet Train')
319
+ rescue
320
+ false
321
+ end
322
+
323
+ def get_bullet_train_role_enhancement(role)
324
+ case role.to_s.downcase
325
+ when 'backend'
326
+ <<~BT_ENHANCEMENT
327
+
328
+
329
+ ## 🚅 BULLET TRAIN BACKEND SPECIALIZATION:
330
+
331
+ **CRITICAL: Use Super Scaffolding for ALL model generation**
332
+ - NEVER create models manually - always use: rails generate super_scaffold ModelName Team field:field_type
333
+ - Use bin/resolve ClassName --eject --open before modifying any existing models
334
+ - ALL models must inherit team-scoped architecture: belongs_to :team
335
+
336
+ **Model Structure (EXACT pattern):**
337
+ ```ruby
338
+ class Contact < ApplicationRecord
339
+ include Contacts::Base # Gem concern with core logic
340
+ include Webhooks::Outgoing::TeamSupport
341
+ # 🚅 add concerns above.
342
+
343
+ # 🚅 add belongs_to associations above.
344
+ # 🚅 add has_many associations above.
345
+ # 🚅 add scopes above.
346
+ # 🚅 add validations above.
347
+ # 🚅 add callbacks above.
348
+ # 🚅 add methods above.
349
+ end
350
+ ```
351
+
352
+ **🚨 MANDATORY EXECUTION SEQUENCE - NO EXCEPTIONS:**
353
+ 1. FIRST: bundle exec rails generate super_scaffold Contact Team name:text_field email:email_field phone:phone_field company:text_field
354
+ 2. THEN: bundle exec rails db:migrate
355
+ 3. THEN: bundle exec rails test (to verify everything works)
356
+ 4. ONLY IF NEEDED: bin/resolve Contacts::Base --eject --open (for customization)
357
+ 5. Configure config/models/roles.yml with proper permissions
358
+
359
+ **🚨 CRITICAL: You MUST actually run these commands using the Bash tool - not just describe them!**
360
+ **🚨 DO NOT create manual Rails models/controllers - ONLY use Super Scaffolding!**
361
+ **🚨 NEVER skip step 1 - Super Scaffolding is MANDATORY for Bullet Train projects!**
362
+
363
+ **API Routes (add to config/routes/api/v1.rb):**
364
+ ```ruby
365
+ namespace :api do
366
+ namespace :v1 do
367
+ shallow do
368
+ resources :teams do
369
+ resources :contacts
370
+ end
371
+ end
372
+ end
373
+ end
374
+ ```
375
+ BT_ENHANCEMENT
376
+ when 'frontend'
377
+ <<~BT_ENHANCEMENT
378
+
379
+
380
+ ## 🚅 BULLET TRAIN FRONTEND SPECIALIZATION:
381
+
382
+ **CRITICAL: Customize generated views, don't create from scratch**
383
+ - Super Scaffolding generates account/contacts/* views automatically
384
+ - Use bin/resolve account/contacts/_form --eject for view customization
385
+ - All views follow account-scoped pattern: app/views/account/contacts/
386
+
387
+ **Required View Structure:**
388
+ - app/views/account/contacts/index.html.erb (team-scoped listing)
389
+ - app/views/account/contacts/show.html.erb (individual contact)
390
+ - app/views/account/contacts/_form.html.erb (create/edit form)
391
+ - Use Bullet Train themes and components
392
+
393
+ **🎨 STYLING: Use Tailwind CSS (Bullet Train Default)**
394
+ - ALWAYS use Tailwind CSS classes (bg-blue-500, text-white, etc.)
395
+ - NEVER use Bootstrap or custom CSS - BT uses Tailwind by default
396
+ - Use BT's Tailwind theme tokens and design system
397
+ - Follow BT responsive patterns: sm:, md:, lg: breakpoints
398
+ - Use BT component classes: .btn, .card, .form-control (Tailwind-based)
399
+
400
+ **Navigation Integration:**
401
+ - Add to account navigation (usually in app/views/account/shared/_menu.html.erb)
402
+ - Use BT icon helpers and Tailwind styling patterns
403
+ - Ensure mobile-responsive with Tailwind responsive classes
404
+
405
+ **Commands:**
406
+ 1. bin/resolve account/contacts --eject (to customize views)
407
+ 2. bin/resolve shared/fields --open (for field customization)
408
+ 3. Use existing BT theme patterns and components
409
+ BT_ENHANCEMENT
410
+ when 'qa'
411
+ <<~BT_ENHANCEMENT
412
+
413
+
414
+ ## 🚅 BULLET TRAIN QA SPECIALIZATION:
415
+
416
+ **CRITICAL: Test team-scoped behavior and permissions**
417
+ - Test models with proper team association and scoping
418
+ - Validate role-based permissions from config/models/roles.yml
419
+ - Test API endpoints with proper authentication and authorization
420
+
421
+ **Required Test Structure:**
422
+ ```ruby
423
+ # spec/models/contact_spec.rb
424
+ require 'rails_helper'
425
+
426
+ RSpec.describe Contact, type: :model do
427
+ let(:team) { create(:team) }
428
+ let(:contact) { create(:contact, team: team) }
429
+
430
+ it "belongs to team" do
431
+ expect(contact.team).to eq(team)
432
+ end
433
+
434
+ it "validates required fields" do
435
+ # Test BT field validations
436
+ end
437
+
438
+ it "respects team scoping" do
439
+ # Test team isolation
440
+ end
441
+ end
442
+ ```
443
+
444
+ **API Testing:**
445
+ - spec/requests/api/v1/contacts_spec.rb with proper authentication
446
+ - Test team-scoped API access and permissions
447
+ - Validate webhook payload generation
448
+
449
+ **Commands:**
450
+ 1. bundle exec rspec spec/models/contact_spec.rb
451
+ 2. bundle exec rspec spec/requests/api/v1/contacts_spec.rb
452
+ 3. Test with different user roles and team memberships
453
+ BT_ENHANCEMENT
454
+ when 'scaffolding'
455
+ <<~BT_ENHANCEMENT
456
+
457
+
458
+ ## 🚅 BULLET TRAIN SCAFFOLDING MASTER PROTOCOL:
459
+
460
+ **🚨 MANDATORY EXECUTION SEQUENCE (MUST RUN THESE EXACT COMMANDS) - NO EXCEPTIONS:**
461
+ 1. bundle exec rails generate super_scaffold Contact Team name:text_field email:email_field phone:phone_field company:text_field
462
+ 2. bundle exec rails db:migrate
463
+ 3. bundle exec rails test (verify everything works)
464
+ 4. Configure roles in config/models/roles.yml
465
+ 5. Add API routes to config/routes/api/v1.rb
466
+ 6. bundle exec rails test (final verification)
467
+
468
+ **🚨 YOU MUST USE THE BASH TOOL TO ACTUALLY EXECUTE THESE COMMANDS - NOT JUST WRITE CODE FILES!**
469
+ **🚨 FAILURE TO RUN SUPER_SCAFFOLD COMMAND IS A CRITICAL ERROR!**
470
+ **🚨 DO NOT CREATE MANUAL MODELS/CONTROLLERS - BULLET TRAIN REQUIRES SUPER SCAFFOLDING!**
471
+
472
+ **POST-SCAFFOLDING OPTIMIZATION:**
473
+ - bin/resolve Contacts::Base --eject --open (for model customization)
474
+ - bin/resolve account/contacts/_form --eject (for view customization)
475
+ - Add custom validations and business logic
476
+ - Configure webhooks and integrations
477
+
478
+ **TEAM ARCHITECTURE VERIFICATION:**
479
+ - Ensure all models use team-scoped ownership
480
+ - Validate proper role inheritance in config/models/roles.yml
481
+ - Test API endpoints respect team boundaries
482
+ - Confirm webhook payloads include team context
483
+ BT_ENHANCEMENT
484
+ else
485
+ ''
486
+ end
292
487
  end
293
488
 
294
489
  def create_agent_script(prompt, role, working_dir)
@@ -321,9 +516,9 @@ module EnhanceSwarm
321
516
  #{prompt}
322
517
  EOF
323
518
 
324
- # Run Claude with the prompt
519
+ # Run Claude with the prompt in interactive mode with full permissions
325
520
  echo "Executing Claude for #{role} agent..."
326
- claude --print < "$PROMPT_FILE"
521
+ claude --dangerously-skip-permissions < "$PROMPT_FILE"
327
522
 
328
523
  # Cleanup
329
524
  rm -f "$PROMPT_FILE"
@@ -417,6 +612,8 @@ module EnhanceSwarm
417
612
  base_prompt += "\n\nFOCUS: Controllers, views, JavaScript, forms, user interactions, and integration."
418
613
  when 'qa'
419
614
  base_prompt += "\n\nFOCUS: Comprehensive testing, edge cases, quality assurance, and validation."
615
+ when 'scaffolding'
616
+ base_prompt += "\n\nFOCUS: Bullet Train Super Scaffolding, Andrew Culver's best practices, team-scoped architecture, and framework setup."
420
617
  end
421
618
 
422
619
  base_prompt
@@ -449,7 +646,7 @@ module EnhanceSwarm
449
646
 
450
647
  def sanitize_role(role)
451
648
  # Only allow known safe roles
452
- allowed_roles = %w[ux backend frontend qa general]
649
+ allowed_roles = %w[ux backend frontend qa general scaffolding]
453
650
  role = role.to_s.downcase.strip
454
651
  allowed_roles.include?(role) ? role : 'general'
455
652
  end
@@ -2,8 +2,11 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'colorize'
5
+ require 'timeout'
5
6
  require_relative 'web_ui'
6
7
  require_relative 'session_manager'
8
+ require_relative 'task_coordinator'
9
+ require_relative 'smart_orchestration'
7
10
 
8
11
  module EnhanceSwarm
9
12
  class CLI < Thor
@@ -54,15 +57,101 @@ module EnhanceSwarm
54
57
  notifications: options[:notifications]
55
58
  })
56
59
 
57
- if options[:control_agent] && !options[:dry_run]
58
- enhance_with_control_agent
60
+ # Get task description from user
61
+ print "Enter task description: "
62
+ task_description = $stdin.gets.chomp
63
+
64
+ # Use smart orchestration by default
65
+ begin
66
+ SmartOrchestration.enhance_with_coordination(task_description)
67
+ say "✅ Smart orchestration completed successfully!", :green
68
+ rescue StandardError => e
69
+ say "❌ Smart orchestration failed, falling back to control agent", :yellow
70
+ Logger.error("Smart orchestration error: #{e.message}")
71
+
72
+ if options[:control_agent] && !options[:dry_run]
73
+ enhance_with_control_agent_manual(task_description)
74
+ else
75
+ orchestrator = Orchestrator.new
76
+ orchestrator.enhance(
77
+ task_id: options[:task],
78
+ dry_run: options[:dry_run],
79
+ follow: options[:follow]
80
+ )
81
+ end
82
+ end
83
+ end
84
+
85
+ desc 'orchestrate TASK_DESC', 'Intelligent multi-agent orchestration with smart coordination'
86
+ option :coordination, type: :boolean, default: true, desc: 'Enable intelligent task coordination'
87
+ option :follow, type: :boolean, default: false, desc: 'Stream live output from all agents'
88
+ option :background, type: :boolean, default: false, desc: 'Run orchestration in background (non-blocking)'
89
+ option :detached, type: :boolean, default: false, desc: 'Run completely detached and return immediately'
90
+ def orchestrate(task_desc)
91
+ say "🎯 Starting intelligent multi-agent orchestration", :blue
92
+ say "Task: #{task_desc}", :white
93
+
94
+ begin
95
+ coordinator = TaskCoordinator.new
96
+
97
+ if options[:detached]
98
+ # Run completely detached - spawn background process and return immediately
99
+ spawn_detached_orchestration(task_desc, coordinator)
100
+ say "🚀 Orchestration started in detached mode", :green
101
+ say "📁 Check .enhance_swarm/logs/ for progress updates", :blue
102
+ return
103
+ elsif options[:background]
104
+ # Run in background with periodic status updates
105
+ run_background_orchestration(task_desc, coordinator)
106
+ else
107
+ # Run normally (blocking)
108
+ coordinator.coordinate_task(task_desc)
109
+ end
110
+
111
+ say "✅ Multi-agent orchestration completed successfully!", :green
112
+ rescue Timeout::Error => e
113
+ say "⏰ Orchestration timed out: #{e.message}", :red
114
+ say "Consider breaking down the task into smaller parts", :yellow
115
+ rescue SystemExit, Interrupt
116
+ say "🛑 Orchestration interrupted by user", :yellow
117
+ rescue StandardError => e
118
+ say "❌ Orchestration failed: #{e.message}", :red
119
+ say "Debug info: #{e.backtrace.first(3).join("\n")}", :yellow
120
+ say "Run 'enhance-swarm doctor' to check system health", :blue
121
+ end
122
+ end
123
+
124
+ desc 'status', 'Check status of running orchestration'
125
+ def status
126
+ if File.exist?('.enhance_swarm/logs/orchestration.pid')
127
+ pid = File.read('.enhance_swarm/logs/orchestration.pid').strip
128
+
129
+ begin
130
+ Process.getpgid(pid.to_i)
131
+ say "🔄 Orchestration running (PID: #{pid})", :blue
132
+
133
+ if File.exist?('.enhance_swarm/logs/orchestration_status.txt')
134
+ status = File.read('.enhance_swarm/logs/orchestration_status.txt').strip
135
+ say "Status: #{status}", :yellow
136
+ end
137
+
138
+ # Show recent log entries
139
+ if File.exist?('.enhance_swarm/logs/orchestration.log')
140
+ logs = File.readlines('.enhance_swarm/logs/orchestration.log').last(5)
141
+ say "\nRecent activity:", :white
142
+ logs.each { |log| say " #{log.strip}", :light_black }
143
+ end
144
+
145
+ rescue Errno::ESRCH
146
+ say "💤 No orchestration currently running", :yellow
147
+
148
+ if File.exist?('.enhance_swarm/logs/orchestration_status.txt')
149
+ status = File.read('.enhance_swarm/logs/orchestration_status.txt').strip
150
+ say "Last status: #{status}", :light_black
151
+ end
152
+ end
59
153
  else
60
- orchestrator = Orchestrator.new
61
- orchestrator.enhance(
62
- task_id: options[:task],
63
- dry_run: options[:dry_run],
64
- follow: options[:follow]
65
- )
154
+ say "💤 No orchestration currently running", :yellow
66
155
  end
67
156
  end
68
157
 
@@ -539,6 +628,78 @@ module EnhanceSwarm
539
628
 
540
629
  private
541
630
 
631
+ def spawn_detached_orchestration(task_desc, coordinator)
632
+ require 'fileutils'
633
+
634
+ # Ensure logs directory exists
635
+ FileUtils.mkdir_p('.enhance_swarm/logs')
636
+
637
+ # Create status files
638
+ File.write('.enhance_swarm/logs/orchestration_status.txt', 'STARTING')
639
+
640
+ # Log the start
641
+ File.write('.enhance_swarm/logs/orchestration.log',
642
+ "#{Time.now}: Starting detached orchestration\nTask: #{task_desc}\n",
643
+ mode: 'a')
644
+
645
+ # Spawn background process using Ruby Process.spawn
646
+ pid = Process.spawn(
647
+ {
648
+ 'ENHANCE_SWARM_DETACHED' => 'true',
649
+ 'ENHANCE_SWARM_TASK' => task_desc
650
+ },
651
+ 'ruby', '-e', <<~RUBY,
652
+ require '#{File.expand_path('../../enhance_swarm', __FILE__)}'
653
+
654
+ task_desc = ENV['ENHANCE_SWARM_TASK']
655
+
656
+ begin
657
+ Dir.chdir('#{Dir.pwd}')
658
+
659
+ File.write('.enhance_swarm/logs/orchestration_status.txt', 'RUNNING')
660
+ File.write('.enhance_swarm/logs/orchestration.log',
661
+ "\#{Time.now}: Coordinator starting\\n", mode: 'a')
662
+
663
+ coordinator = EnhanceSwarm::TaskCoordinator.new
664
+ coordinator.coordinate_task(task_desc)
665
+
666
+ File.write('.enhance_swarm/logs/orchestration_status.txt', 'COMPLETED')
667
+ File.write('.enhance_swarm/logs/orchestration.log',
668
+ "\#{Time.now}: Orchestration completed successfully\\n", mode: 'a')
669
+
670
+ rescue => e
671
+ File.write('.enhance_swarm/logs/orchestration_status.txt', "FAILED: \#{e.message}")
672
+ File.write('.enhance_swarm/logs/orchestration.log',
673
+ "\#{Time.now}: ERROR: \#{e.message}\\n\#{e.backtrace.first(3).join('\\n')}\\n", mode: 'a')
674
+ end
675
+ RUBY
676
+ chdir: Dir.pwd,
677
+ out: '.enhance_swarm/logs/orchestration.log',
678
+ err: '.enhance_swarm/logs/orchestration.log'
679
+ )
680
+
681
+ # Store PID and detach
682
+ File.write('.enhance_swarm/logs/orchestration.pid', pid.to_s)
683
+ Process.detach(pid)
684
+
685
+ File.write('.enhance_swarm/logs/orchestration.log',
686
+ "#{Time.now}: Orchestration PID: #{pid}\n", mode: 'a')
687
+ end
688
+
689
+ def run_background_orchestration(task_desc, coordinator)
690
+ thread = Thread.new do
691
+ coordinator.coordinate_task(task_desc)
692
+ end
693
+
694
+ # Monitor with periodic updates
695
+ while thread.alive?
696
+ say "⏳ Orchestration running... (#{Time.now.strftime('%H:%M:%S')})", :blue
697
+ sleep(30)
698
+ end
699
+
700
+ thread.value # Wait for completion
701
+ end
702
+
542
703
  def spawn_with_streaming(task_desc, role = nil)
543
704
  orchestrator = Orchestrator.new
544
705
  agent_role = role || options[:role] || 'general'
@@ -76,6 +76,34 @@ module EnhanceSwarm
76
76
  }
77
77
  end
78
78
 
79
+ # Enhanced progress tracking integration
80
+ def track_progress_with_streamer(streamer = nil)
81
+ return unless streamer
82
+
83
+ Thread.new do
84
+ while @status == 'coordinating'
85
+ status = current_status
86
+
87
+ # Update progress tracker
88
+ progress = status['progress_percentage'] || 0
89
+ message = status['message'] || 'Coordinating agents...'
90
+
91
+ streamer.set_progress(progress,
92
+ message: message,
93
+ details: {
94
+ operation: 'control_coordination',
95
+ phase: status['phase'],
96
+ active_agents: status['active_agents']&.length || 0,
97
+ completed_agents: status['completed_agents']&.length || 0
98
+ })
99
+
100
+ break if %w[completed failed].include?(status['status'])
101
+
102
+ sleep(2)
103
+ end
104
+ end
105
+ end
106
+
79
107
  private
80
108
 
81
109
  def spawn_control_agent
@@ -276,32 +304,5 @@ module EnhanceSwarm
276
304
  end
277
305
  end
278
306
 
279
- # Enhanced progress tracking integration
280
- def track_progress_with_streamer(streamer = nil)
281
- return unless streamer
282
-
283
- Thread.new do
284
- while @status == 'coordinating'
285
- status = current_status
286
-
287
- # Update progress tracker
288
- progress = status['progress_percentage'] || 0
289
- message = status['message'] || 'Coordinating agents...'
290
-
291
- streamer.set_progress(progress,
292
- message: message,
293
- operation: 'control_coordination',
294
- details: {
295
- phase: status['phase'],
296
- active_agents: status['active_agents']&.length || 0,
297
- completed_agents: status['completed_agents']&.length || 0
298
- })
299
-
300
- break if %w[completed failed].include?(status['status'])
301
-
302
- sleep(2)
303
- end
304
- end
305
- end
306
307
  end
307
308
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'logger'
4
+ require_relative 'task_coordinator'
5
+
6
+ module EnhanceSwarm
7
+ # Smart orchestration with intelligent defaults for all new installations
8
+ # Implements real dev team patterns as the default user experience
9
+ class SmartOrchestration
10
+ def self.enhance_with_coordination(description)
11
+ orchestrator = new
12
+ orchestrator.smart_enhance(description)
13
+ end
14
+
15
+ def initialize
16
+ @coordinator = TaskCoordinator.new
17
+ end
18
+
19
+ def smart_enhance(description)
20
+ Logger.info("🎯 Smart Enhancement Protocol: #{description}")
21
+
22
+ # Check if this looks like a review/polish task
23
+ if review_task?(description)
24
+ handle_review_task(description)
25
+ else
26
+ # Standard coordinated development
27
+ @coordinator.coordinate_task(description)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def review_task?(description)
34
+ description.downcase.match?(/review|polish|qa|test|merge|integrate|finish|complete|open browser/)
35
+ end
36
+
37
+ def handle_review_task(description)
38
+ Logger.info("🔍 Detected review/polish task - using smart review workflow")
39
+
40
+ # Create specialized review and polish tasks
41
+ review_tasks = [
42
+ "Review current codebase state and identify missing features or improvements",
43
+ "Perform QA testing of all existing functionality and identify issues",
44
+ "Polish and improve UI/UX consistency and user experience",
45
+ "Integrate all improvements and ensure everything works together",
46
+ "Prepare for final review and browser testing"
47
+ ]
48
+
49
+ review_tasks.each_with_index do |task, index|
50
+ Logger.info("📋 Review Phase #{index + 1}: #{task}")
51
+ @coordinator.coordinate_task(task)
52
+
53
+ # Brief pause between review phases
54
+ sleep(1) if index < review_tasks.length - 1
55
+ end
56
+
57
+ Logger.info("✅ Smart review workflow completed")
58
+ end
59
+ end
60
+ end