enhance_swarm 2.0.0 → 2.1.1
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 +4 -4
- data/.claude/CLAUDE.md +164 -0
- data/.claude/MCP.md +117 -0
- data/.claude/PERSONAS.md +114 -0
- data/.claude/RULES.md +221 -0
- data/.enhance_swarm/logs/general_output.log +0 -404
- data/.enhance_swarm.yml +33 -0
- data/CHANGELOG.md +71 -0
- data/PRODUCTION_INSTALL_TEST.md +117 -0
- data/README.md +129 -3
- data/lib/enhance_swarm/agent_spawner.rb +218 -12
- data/lib/enhance_swarm/cli.rb +130 -1
- data/lib/enhance_swarm/task_coordinator.rb +363 -86
- data/lib/enhance_swarm/version.rb +1 -1
- metadata +14 -97
- data/PRODUCTION_TEST_LOG.md +0 -502
- data/debug_agent_spawner.rb +0 -99
- data/debug_cli_spawn.rb +0 -95
- data/debug_fixes.rb +0 -209
- data/debug_script_execution.rb +0 -124
- data/debug_session_issue.rb +0 -87
- data/debug_spawn.rb +0 -113
- data/debug_spawn_step_by_step.rb +0 -190
- data/debug_worktree.rb +0 -77
- data/enhance_swarm-0.1.1.gem +0 -0
- data/enhance_swarm-1.0.0.gem +0 -0
- data/final_validation_test.rb +0 -199
- data/setup.sh +0 -86
- data/test_blog_app/.enhance_swarm/archives/session_1751187575_e119ea73_20250629_105935.json +0 -16
- data/test_blog_app/.enhance_swarm/archives/session_1751187637_7fda97dd_20250629_110037.json +0 -32
- data/test_blog_app/.enhance_swarm/archives/session_1751190527_4c99147e_20250629_114847.json +0 -32
- data/test_blog_app/.enhance_swarm/archives/session_1751190541_8dc83406_20250629_114901.json +0 -16
- data/test_blog_app/.ruby-version +0 -1
- data/test_blog_app/Gemfile +0 -18
- data/test_blog_app/Gemfile.lock +0 -206
- data/test_blog_app/README.md +0 -24
- data/test_blog_app/Rakefile +0 -6
- data/test_blog_app/app/assets/images/.keep +0 -0
- data/test_blog_app/app/assets/stylesheets/application.css +0 -10
- data/test_blog_app/app/controllers/application_controller.rb +0 -4
- data/test_blog_app/app/controllers/concerns/.keep +0 -0
- data/test_blog_app/app/helpers/application_helper.rb +0 -2
- data/test_blog_app/app/models/application_record.rb +0 -3
- data/test_blog_app/app/models/concerns/.keep +0 -0
- data/test_blog_app/app/views/layouts/application.html.erb +0 -27
- data/test_blog_app/app/views/pwa/manifest.json.erb +0 -22
- data/test_blog_app/app/views/pwa/service-worker.js +0 -26
- data/test_blog_app/bin/dev +0 -2
- data/test_blog_app/bin/rails +0 -4
- data/test_blog_app/bin/rake +0 -4
- data/test_blog_app/bin/setup +0 -34
- data/test_blog_app/config/application.rb +0 -42
- data/test_blog_app/config/boot.rb +0 -3
- data/test_blog_app/config/credentials.yml.enc +0 -1
- data/test_blog_app/config/database.yml +0 -32
- data/test_blog_app/config/environment.rb +0 -5
- data/test_blog_app/config/environments/development.rb +0 -51
- data/test_blog_app/config/environments/production.rb +0 -67
- data/test_blog_app/config/environments/test.rb +0 -42
- data/test_blog_app/config/initializers/assets.rb +0 -7
- data/test_blog_app/config/initializers/content_security_policy.rb +0 -25
- data/test_blog_app/config/initializers/filter_parameter_logging.rb +0 -8
- data/test_blog_app/config/initializers/inflections.rb +0 -16
- data/test_blog_app/config/locales/en.yml +0 -31
- data/test_blog_app/config/master.key +0 -1
- data/test_blog_app/config/puma.rb +0 -38
- data/test_blog_app/config/routes.rb +0 -14
- data/test_blog_app/config.ru +0 -6
- data/test_blog_app/db/seeds.rb +0 -9
- data/test_blog_app/lib/tasks/.keep +0 -0
- data/test_blog_app/log/.keep +0 -0
- data/test_blog_app/public/400.html +0 -114
- data/test_blog_app/public/404.html +0 -114
- data/test_blog_app/public/406-unsupported-browser.html +0 -114
- data/test_blog_app/public/422.html +0 -114
- data/test_blog_app/public/500.html +0 -114
- data/test_blog_app/public/icon.png +0 -0
- data/test_blog_app/public/icon.svg +0 -3
- data/test_blog_app/public/robots.txt +0 -1
- data/test_blog_app/script/.keep +0 -0
- data/test_blog_app/storage/.keep +0 -0
- data/test_blog_app/test/controllers/.keep +0 -0
- data/test_blog_app/test/fixtures/files/.keep +0 -0
- data/test_blog_app/test/helpers/.keep +0 -0
- data/test_blog_app/test/integration/.keep +0 -0
- data/test_blog_app/test/models/.keep +0 -0
- data/test_blog_app/test/test_helper.rb +0 -15
- data/test_blog_app/test_enhance_swarm_e2e.rb +0 -244
- data/test_blog_app/test_realistic_workflow.rb +0 -292
- data/test_blog_app/tmp/.keep +0 -0
- data/test_blog_app/tmp/pids/.keep +0 -0
- data/test_blog_app/tmp/storage/.keep +0 -0
- data/test_blog_app/vendor/.keep +0 -0
- data/test_builtin_functionality.rb +0 -121
- data/test_complete_system.rb +0 -267
- data/test_core_components.rb +0 -156
- data/test_real_claude_integration.rb +0 -285
- data/test_security.rb +0 -150
- data/test_smart_defaults.rb +0 -155
- data/test_task_integration.rb +0 -173
- data/test_web_ui.rb +0 -245
- data/web/assets/css/main.css +0 -645
- data/web/assets/js/kanban.js +0 -499
- data/web/assets/js/main.js +0 -525
- data/web/templates/dashboard.html.erb +0 -226
- data/web/templates/kanban.html.erb +0 -193
data/README.md
CHANGED
@@ -18,6 +18,7 @@ EnhanceSwarm transforms Claude into a sophisticated development team that works
|
|
18
18
|
### Installation
|
19
19
|
```bash
|
20
20
|
gem install enhance_swarm
|
21
|
+
# Version 2.1.0+ required for critical fixes and detached mode
|
21
22
|
```
|
22
23
|
|
23
24
|
### Initialize in Your Project
|
@@ -27,13 +28,27 @@ enhance-swarm init
|
|
27
28
|
```
|
28
29
|
|
29
30
|
### Run Intelligent Multi-Agent Development
|
31
|
+
|
32
|
+
**Recommended: Detached Mode (Non-blocking)**
|
30
33
|
```bash
|
31
|
-
#
|
32
|
-
enhance-swarm orchestrate "
|
34
|
+
# Start orchestration in background - returns immediately
|
35
|
+
enhance-swarm orchestrate "Create a Contact management system with CRUD operations" --detached
|
36
|
+
|
37
|
+
# Monitor progress
|
38
|
+
enhance-swarm status
|
39
|
+
|
40
|
+
# Check logs
|
41
|
+
tail -f .enhance_swarm/logs/orchestration.log
|
42
|
+
```
|
33
43
|
|
34
|
-
|
44
|
+
**Alternative: Interactive Mode**
|
45
|
+
```bash
|
46
|
+
# Or use the enhanced ENHANCE protocol (interactive)
|
35
47
|
enhance-swarm enhance
|
36
48
|
# Then enter: "Build a todo management system with real-time updates"
|
49
|
+
|
50
|
+
# Standard orchestration (blocking)
|
51
|
+
enhance-swarm orchestrate "Add user authentication with email verification"
|
37
52
|
```
|
38
53
|
|
39
54
|
## 🎯 How It Works
|
@@ -100,6 +115,38 @@ enhance-swarm doctor
|
|
100
115
|
enhance-swarm cleanup
|
101
116
|
```
|
102
117
|
|
118
|
+
## 📋 Real-World Example
|
119
|
+
|
120
|
+
**Task**: "Create a comprehensive Contact management system with name, email, phone, company fields, and full CRUD operations with proper validation and testing"
|
121
|
+
|
122
|
+
**What EnhanceSwarm Creates**:
|
123
|
+
```
|
124
|
+
📁 Generated Files (14 files, 304 insertions):
|
125
|
+
├── app/models/contact.rb # Model with validations
|
126
|
+
├── app/controllers/contacts_controller.rb # Full CRUD controller
|
127
|
+
├── app/views/contacts/
|
128
|
+
│ ├── index.html.erb # List all contacts
|
129
|
+
│ ├── show.html.erb # View contact details
|
130
|
+
│ ├── new.html.erb # Create new contact
|
131
|
+
│ ├── edit.html.erb # Edit existing contact
|
132
|
+
│ └── _form.html.erb # Shared form partial
|
133
|
+
├── db/migrate/create_contacts.rb # Database migration
|
134
|
+
├── config/routes.rb # Updated routes
|
135
|
+
└── .enhance_swarm/logs/ # Orchestration logs
|
136
|
+
```
|
137
|
+
|
138
|
+
**Multi-Agent Workflow**:
|
139
|
+
1. **Backend Agent**: Creates Contact model with validations, database migration
|
140
|
+
2. **Frontend Agent**: Builds complete view set with Tailwind CSS responsive design
|
141
|
+
3. **Integration Agent**: Updates routes, ensures everything works together
|
142
|
+
4. **Auto-commit**: All changes committed to git with proper message
|
143
|
+
|
144
|
+
**🎨 Styling Framework**:
|
145
|
+
- **Bullet Train Projects**: Tailwind CSS (default) - modern utility-first framework
|
146
|
+
- **Regular Rails Projects**: Bootstrap or Tailwind CSS based on project setup
|
147
|
+
|
148
|
+
**Total Time**: ~2 minutes (background execution)
|
149
|
+
|
103
150
|
## 🎭 Agent Roles & Specializations
|
104
151
|
|
105
152
|
### Backend Agent
|
@@ -189,6 +236,44 @@ resources:
|
|
189
236
|
- Comprehensive security testing framework
|
190
237
|
- Production validation and deployment readiness
|
191
238
|
|
239
|
+
## 📊 Monitoring & Status
|
240
|
+
|
241
|
+
### Check Orchestration Progress
|
242
|
+
```bash
|
243
|
+
# Check if orchestration is running
|
244
|
+
enhance-swarm status
|
245
|
+
|
246
|
+
# Monitor logs in real-time
|
247
|
+
tail -f .enhance_swarm/logs/orchestration.log
|
248
|
+
|
249
|
+
# View specific agent output
|
250
|
+
cat .enhance_swarm/logs/backend_output.log
|
251
|
+
```
|
252
|
+
|
253
|
+
### Understanding Output
|
254
|
+
```bash
|
255
|
+
🎯 Starting intelligent multi-agent orchestration
|
256
|
+
🚀 Orchestration started in detached mode
|
257
|
+
📁 Check .enhance_swarm/logs/ for progress updates
|
258
|
+
|
259
|
+
# Status responses:
|
260
|
+
📊 Orchestration running (PID: 12345)
|
261
|
+
Status: RUNNING
|
262
|
+
✅ Status: COMPLETED
|
263
|
+
❌ Status: FAILED: <error message>
|
264
|
+
```
|
265
|
+
|
266
|
+
### Log Structure
|
267
|
+
```
|
268
|
+
.enhance_swarm/logs/
|
269
|
+
├── orchestration.log # Main orchestration progress
|
270
|
+
├── orchestration_status.txt # Current status (RUNNING/COMPLETED/FAILED)
|
271
|
+
├── orchestration.pid # Process ID for monitoring
|
272
|
+
├── backend_output.log # Backend agent output
|
273
|
+
├── frontend_output.log # Frontend agent output
|
274
|
+
└── general_output.log # General agent output
|
275
|
+
```
|
276
|
+
|
192
277
|
## 🎯 Real-World Examples
|
193
278
|
|
194
279
|
### Add Authentication System
|
@@ -242,6 +327,47 @@ enhance-swarm status
|
|
242
327
|
ENHANCE_SWARM_DEBUG=true enhance-swarm orchestrate "your task"
|
243
328
|
```
|
244
329
|
|
330
|
+
## 📚 Quick Reference
|
331
|
+
|
332
|
+
### Essential Commands
|
333
|
+
```bash
|
334
|
+
# Setup
|
335
|
+
gem install enhance_swarm && enhance-swarm init
|
336
|
+
|
337
|
+
# Start orchestration (recommended)
|
338
|
+
enhance-swarm orchestrate "Your task description" --detached
|
339
|
+
|
340
|
+
# Monitor progress
|
341
|
+
enhance-swarm status
|
342
|
+
tail -f .enhance_swarm/logs/orchestration.log
|
343
|
+
|
344
|
+
# Alternative: Interactive mode
|
345
|
+
enhance-swarm enhance
|
346
|
+
```
|
347
|
+
|
348
|
+
### Command Options
|
349
|
+
```bash
|
350
|
+
--detached # Run in background (recommended)
|
351
|
+
--background # Run with periodic updates
|
352
|
+
--follow # Stream live output (blocking)
|
353
|
+
--coordination # Enable task coordination (default: true)
|
354
|
+
```
|
355
|
+
|
356
|
+
### Common Tasks
|
357
|
+
```bash
|
358
|
+
# Full-stack features
|
359
|
+
enhance-swarm orchestrate "Create user registration with email verification" --detached
|
360
|
+
|
361
|
+
# CRUD systems
|
362
|
+
enhance-swarm orchestrate "Build inventory management with categories and search" --detached
|
363
|
+
|
364
|
+
# API development
|
365
|
+
enhance-swarm orchestrate "Add REST API with JWT authentication" --detached
|
366
|
+
|
367
|
+
# UI components
|
368
|
+
enhance-swarm orchestrate "Create responsive dashboard with charts" --detached
|
369
|
+
```
|
370
|
+
|
245
371
|
## 🤝 Contributing
|
246
372
|
|
247
373
|
EnhanceSwarm is designed for production use and community contributions:
|
@@ -255,15 +255,17 @@ module EnhanceSwarm
|
|
255
255
|
## Your Task:
|
256
256
|
#{base_prompt}
|
257
257
|
|
258
|
-
##
|
259
|
-
1.
|
260
|
-
2.
|
261
|
-
3.
|
262
|
-
4.
|
263
|
-
5.
|
264
|
-
6.
|
265
|
-
7.
|
266
|
-
8.
|
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
|
-
|
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'
|
@@ -291,6 +300,203 @@ module EnhanceSwarm
|
|
291
300
|
else
|
292
301
|
"You are a #{role} specialist agent focusing on your area of expertise."
|
293
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: Use Super Scaffolding with non-interactive mode:
|
354
|
+
```bash
|
355
|
+
# For Contact model:
|
356
|
+
printf "y\\ncontacts\\nti-address-book\\n" | bundle exec rails generate super_scaffold Contact Team name:text_field email:email_field phone:phone_field company:text_field
|
357
|
+
|
358
|
+
# For Project model:
|
359
|
+
printf "y\\nprojects\\nti-view-grid\\n" | bundle exec rails generate super_scaffold Project Team title:text_field description:trix_editor status:buttons due_date:date_field
|
360
|
+
|
361
|
+
# Template for any model:
|
362
|
+
printf "y\\n[plural_slug]\\n[icon_name]\\n" | bundle exec rails generate super_scaffold [ModelName] Team [field:type ...]
|
363
|
+
```
|
364
|
+
- Auto-answers: navbar=yes, slug=[plural_slug], icon=[icon_name]
|
365
|
+
- Common icons: ti-address-book, ti-view-grid, ti-users, ti-folder, ti-calendar
|
366
|
+
2. THEN: bundle exec rails db:migrate
|
367
|
+
3. THEN: bundle exec rails test (to verify everything works)
|
368
|
+
4. ONLY IF NEEDED: bin/resolve Projects::Base --eject --open (for customization)
|
369
|
+
5. Configure config/models/roles.yml with proper permissions
|
370
|
+
|
371
|
+
**🚨 CRITICAL: You MUST actually run these commands using the Bash tool - not just describe them!**
|
372
|
+
**🚨 DO NOT create manual Rails models/controllers - ONLY use Super Scaffolding!**
|
373
|
+
**🚨 NEVER skip step 1 - Super Scaffolding is MANDATORY for Bullet Train projects!**
|
374
|
+
**🚨 ALWAYS use printf with proper answers for interactive prompts!**
|
375
|
+
|
376
|
+
**API Routes (add to config/routes/api/v1.rb):**
|
377
|
+
```ruby
|
378
|
+
namespace :api do
|
379
|
+
namespace :v1 do
|
380
|
+
shallow do
|
381
|
+
resources :teams do
|
382
|
+
resources :contacts
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
```
|
388
|
+
BT_ENHANCEMENT
|
389
|
+
when 'frontend'
|
390
|
+
<<~BT_ENHANCEMENT
|
391
|
+
|
392
|
+
|
393
|
+
## 🚅 BULLET TRAIN FRONTEND SPECIALIZATION:
|
394
|
+
|
395
|
+
**CRITICAL: Customize generated views, don't create from scratch**
|
396
|
+
- Super Scaffolding generates account/contacts/* views automatically
|
397
|
+
- Use bin/resolve account/contacts/_form --eject for view customization
|
398
|
+
- All views follow account-scoped pattern: app/views/account/contacts/
|
399
|
+
|
400
|
+
**Required View Structure:**
|
401
|
+
- app/views/account/contacts/index.html.erb (team-scoped listing)
|
402
|
+
- app/views/account/contacts/show.html.erb (individual contact)
|
403
|
+
- app/views/account/contacts/_form.html.erb (create/edit form)
|
404
|
+
- Use Bullet Train themes and components
|
405
|
+
|
406
|
+
**🎨 STYLING: Use Tailwind CSS (Bullet Train Default)**
|
407
|
+
- ALWAYS use Tailwind CSS classes (bg-blue-500, text-white, etc.)
|
408
|
+
- NEVER use Bootstrap or custom CSS - BT uses Tailwind by default
|
409
|
+
- Use BT's Tailwind theme tokens and design system
|
410
|
+
- Follow BT responsive patterns: sm:, md:, lg: breakpoints
|
411
|
+
- Use BT component classes: .btn, .card, .form-control (Tailwind-based)
|
412
|
+
|
413
|
+
**Navigation Integration:**
|
414
|
+
- Add to account navigation (usually in app/views/account/shared/_menu.html.erb)
|
415
|
+
- Use BT icon helpers and Tailwind styling patterns
|
416
|
+
- Ensure mobile-responsive with Tailwind responsive classes
|
417
|
+
|
418
|
+
**Commands:**
|
419
|
+
1. bin/resolve account/contacts --eject (to customize views)
|
420
|
+
2. bin/resolve shared/fields --open (for field customization)
|
421
|
+
3. Use existing BT theme patterns and components
|
422
|
+
BT_ENHANCEMENT
|
423
|
+
when 'qa'
|
424
|
+
<<~BT_ENHANCEMENT
|
425
|
+
|
426
|
+
|
427
|
+
## 🚅 BULLET TRAIN QA SPECIALIZATION:
|
428
|
+
|
429
|
+
**CRITICAL: Test team-scoped behavior and permissions**
|
430
|
+
- Test models with proper team association and scoping
|
431
|
+
- Validate role-based permissions from config/models/roles.yml
|
432
|
+
- Test API endpoints with proper authentication and authorization
|
433
|
+
|
434
|
+
**Required Test Structure:**
|
435
|
+
```ruby
|
436
|
+
# spec/models/contact_spec.rb
|
437
|
+
require 'rails_helper'
|
438
|
+
|
439
|
+
RSpec.describe Contact, type: :model do
|
440
|
+
let(:team) { create(:team) }
|
441
|
+
let(:contact) { create(:contact, team: team) }
|
442
|
+
|
443
|
+
it "belongs to team" do
|
444
|
+
expect(contact.team).to eq(team)
|
445
|
+
end
|
446
|
+
|
447
|
+
it "validates required fields" do
|
448
|
+
# Test BT field validations
|
449
|
+
end
|
450
|
+
|
451
|
+
it "respects team scoping" do
|
452
|
+
# Test team isolation
|
453
|
+
end
|
454
|
+
end
|
455
|
+
```
|
456
|
+
|
457
|
+
**API Testing:**
|
458
|
+
- spec/requests/api/v1/contacts_spec.rb with proper authentication
|
459
|
+
- Test team-scoped API access and permissions
|
460
|
+
- Validate webhook payload generation
|
461
|
+
|
462
|
+
**Commands:**
|
463
|
+
1. bundle exec rspec spec/models/contact_spec.rb
|
464
|
+
2. bundle exec rspec spec/requests/api/v1/contacts_spec.rb
|
465
|
+
3. Test with different user roles and team memberships
|
466
|
+
BT_ENHANCEMENT
|
467
|
+
when 'scaffolding'
|
468
|
+
<<~BT_ENHANCEMENT
|
469
|
+
|
470
|
+
|
471
|
+
## 🚅 BULLET TRAIN SCAFFOLDING MASTER PROTOCOL:
|
472
|
+
|
473
|
+
**🚨 MANDATORY EXECUTION SEQUENCE (MUST RUN THESE EXACT COMMANDS) - NO EXCEPTIONS:**
|
474
|
+
1. bundle exec rails generate super_scaffold Contact Team name:text_field email:email_field phone:phone_field company:text_field
|
475
|
+
2. bundle exec rails db:migrate
|
476
|
+
3. bundle exec rails test (verify everything works)
|
477
|
+
4. Configure roles in config/models/roles.yml
|
478
|
+
5. Add API routes to config/routes/api/v1.rb
|
479
|
+
6. bundle exec rails test (final verification)
|
480
|
+
|
481
|
+
**🚨 YOU MUST USE THE BASH TOOL TO ACTUALLY EXECUTE THESE COMMANDS - NOT JUST WRITE CODE FILES!**
|
482
|
+
**🚨 FAILURE TO RUN SUPER_SCAFFOLD COMMAND IS A CRITICAL ERROR!**
|
483
|
+
**🚨 DO NOT CREATE MANUAL MODELS/CONTROLLERS - BULLET TRAIN REQUIRES SUPER SCAFFOLDING!**
|
484
|
+
|
485
|
+
**POST-SCAFFOLDING OPTIMIZATION:**
|
486
|
+
- bin/resolve Contacts::Base --eject --open (for model customization)
|
487
|
+
- bin/resolve account/contacts/_form --eject (for view customization)
|
488
|
+
- Add custom validations and business logic
|
489
|
+
- Configure webhooks and integrations
|
490
|
+
|
491
|
+
**TEAM ARCHITECTURE VERIFICATION:**
|
492
|
+
- Ensure all models use team-scoped ownership
|
493
|
+
- Validate proper role inheritance in config/models/roles.yml
|
494
|
+
- Test API endpoints respect team boundaries
|
495
|
+
- Confirm webhook payloads include team context
|
496
|
+
BT_ENHANCEMENT
|
497
|
+
else
|
498
|
+
''
|
499
|
+
end
|
294
500
|
end
|
295
501
|
|
296
502
|
def create_agent_script(prompt, role, working_dir)
|
@@ -323,9 +529,9 @@ module EnhanceSwarm
|
|
323
529
|
#{prompt}
|
324
530
|
EOF
|
325
531
|
|
326
|
-
# Run Claude with the prompt
|
532
|
+
# Run Claude with the prompt in interactive mode with full permissions
|
327
533
|
echo "Executing Claude for #{role} agent..."
|
328
|
-
claude --
|
534
|
+
claude --dangerously-skip-permissions < "$PROMPT_FILE"
|
329
535
|
|
330
536
|
# Cleanup
|
331
537
|
rm -f "$PROMPT_FILE"
|
data/lib/enhance_swarm/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
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'
|
7
8
|
require_relative 'task_coordinator'
|
@@ -84,18 +85,73 @@ module EnhanceSwarm
|
|
84
85
|
desc 'orchestrate TASK_DESC', 'Intelligent multi-agent orchestration with smart coordination'
|
85
86
|
option :coordination, type: :boolean, default: true, desc: 'Enable intelligent task coordination'
|
86
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'
|
87
90
|
def orchestrate(task_desc)
|
88
91
|
say "🎯 Starting intelligent multi-agent orchestration", :blue
|
89
92
|
say "Task: #{task_desc}", :white
|
90
93
|
|
91
94
|
begin
|
92
95
|
coordinator = TaskCoordinator.new
|
93
|
-
|
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
|
94
110
|
|
95
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
|
96
117
|
rescue StandardError => e
|
97
118
|
say "❌ Orchestration failed: #{e.message}", :red
|
98
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
|
153
|
+
else
|
154
|
+
say "💤 No orchestration currently running", :yellow
|
99
155
|
end
|
100
156
|
end
|
101
157
|
|
@@ -572,6 +628,79 @@ module EnhanceSwarm
|
|
572
628
|
|
573
629
|
private
|
574
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
|
+
working_dir = '#{Dir.pwd}'
|
656
|
+
|
657
|
+
begin
|
658
|
+
Dir.chdir(working_dir)
|
659
|
+
|
660
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration_status.txt", 'RUNNING')
|
661
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration.log",
|
662
|
+
"\#{Time.now}: Coordinator starting in \#{working_dir}\\n", mode: 'a')
|
663
|
+
|
664
|
+
coordinator = EnhanceSwarm::TaskCoordinator.new
|
665
|
+
coordinator.coordinate_task(task_desc)
|
666
|
+
|
667
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration_status.txt", 'COMPLETED')
|
668
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration.log",
|
669
|
+
"\#{Time.now}: Orchestration completed successfully\\n", mode: 'a')
|
670
|
+
|
671
|
+
rescue => e
|
672
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration_status.txt", "FAILED: \#{e.message}")
|
673
|
+
File.write("\#{working_dir}/.enhance_swarm/logs/orchestration.log",
|
674
|
+
"\#{Time.now}: ERROR: \#{e.message}\\n\#{e.backtrace.first(3).join('\\n')}\\n", mode: 'a')
|
675
|
+
end
|
676
|
+
RUBY
|
677
|
+
chdir: Dir.pwd,
|
678
|
+
out: File.join(Dir.pwd, '.enhance_swarm/logs/orchestration.log'),
|
679
|
+
err: File.join(Dir.pwd, '.enhance_swarm/logs/orchestration.log')
|
680
|
+
)
|
681
|
+
|
682
|
+
# Store PID and detach
|
683
|
+
File.write('.enhance_swarm/logs/orchestration.pid', pid.to_s)
|
684
|
+
Process.detach(pid)
|
685
|
+
|
686
|
+
File.write('.enhance_swarm/logs/orchestration.log',
|
687
|
+
"#{Time.now}: Orchestration PID: #{pid}\n", mode: 'a')
|
688
|
+
end
|
689
|
+
|
690
|
+
def run_background_orchestration(task_desc, coordinator)
|
691
|
+
thread = Thread.new do
|
692
|
+
coordinator.coordinate_task(task_desc)
|
693
|
+
end
|
694
|
+
|
695
|
+
# Monitor with periodic updates
|
696
|
+
while thread.alive?
|
697
|
+
say "⏳ Orchestration running... (#{Time.now.strftime('%H:%M:%S')})", :blue
|
698
|
+
sleep(30)
|
699
|
+
end
|
700
|
+
|
701
|
+
thread.value # Wait for completion
|
702
|
+
end
|
703
|
+
|
575
704
|
def spawn_with_streaming(task_desc, role = nil)
|
576
705
|
orchestrator = Orchestrator.new
|
577
706
|
agent_role = role || options[:role] || 'general'
|