aidp 0.1.0 → 0.5.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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -4
  3. data/bin/aidp +2 -2
  4. data/lib/aidp/analyze/agent_personas.rb +1 -1
  5. data/lib/aidp/analyze/data_retention_manager.rb +2 -2
  6. data/lib/aidp/analyze/database.rb +99 -82
  7. data/lib/aidp/analyze/error_handler.rb +12 -76
  8. data/lib/aidp/analyze/focus_guidance.rb +2 -2
  9. data/lib/aidp/analyze/large_analysis_progress.rb +2 -2
  10. data/lib/aidp/analyze/metrics_storage.rb +336 -0
  11. data/lib/aidp/analyze/prioritizer.rb +4 -4
  12. data/lib/aidp/analyze/repository_chunker.rb +15 -13
  13. data/lib/aidp/analyze/ruby_maat_integration.rb +6 -102
  14. data/lib/aidp/analyze/runner.rb +107 -191
  15. data/lib/aidp/analyze/steps.rb +29 -30
  16. data/lib/aidp/analyze/storage.rb +234 -172
  17. data/lib/aidp/cli/jobs_command.rb +489 -0
  18. data/lib/aidp/cli/terminal_io.rb +52 -0
  19. data/lib/aidp/cli.rb +227 -0
  20. data/lib/aidp/config.rb +33 -0
  21. data/lib/aidp/core_ext/class_attribute.rb +36 -0
  22. data/lib/aidp/database/pg_adapter.rb +148 -0
  23. data/lib/aidp/database_config.rb +69 -0
  24. data/lib/aidp/database_connection.rb +72 -0
  25. data/lib/aidp/database_migration.rb +158 -0
  26. data/lib/aidp/execute/runner.rb +65 -92
  27. data/lib/aidp/execute/steps.rb +81 -82
  28. data/lib/aidp/job_manager.rb +41 -0
  29. data/lib/aidp/jobs/base_job.rb +47 -0
  30. data/lib/aidp/jobs/provider_execution_job.rb +96 -0
  31. data/lib/aidp/project_detector.rb +117 -0
  32. data/lib/aidp/provider_manager.rb +25 -0
  33. data/lib/aidp/providers/agent_supervisor.rb +348 -0
  34. data/lib/aidp/providers/anthropic.rb +187 -0
  35. data/lib/aidp/providers/base.rb +162 -0
  36. data/lib/aidp/providers/cursor.rb +304 -0
  37. data/lib/aidp/providers/gemini.rb +187 -0
  38. data/lib/aidp/providers/macos_ui.rb +24 -0
  39. data/lib/aidp/providers/supervised_base.rb +317 -0
  40. data/lib/aidp/providers/supervised_cursor.rb +22 -0
  41. data/lib/aidp/sync.rb +13 -0
  42. data/lib/aidp/util.rb +39 -0
  43. data/lib/aidp/{shared/version.rb → version.rb} +1 -3
  44. data/lib/aidp/workspace.rb +19 -0
  45. data/lib/aidp.rb +36 -45
  46. data/templates/ANALYZE/01_REPOSITORY_ANALYSIS.md +4 -4
  47. metadata +89 -45
  48. data/lib/aidp/shared/cli.rb +0 -117
  49. data/lib/aidp/shared/config.rb +0 -35
  50. data/lib/aidp/shared/project_detector.rb +0 -119
  51. data/lib/aidp/shared/providers/anthropic.rb +0 -26
  52. data/lib/aidp/shared/providers/base.rb +0 -17
  53. data/lib/aidp/shared/providers/cursor.rb +0 -102
  54. data/lib/aidp/shared/providers/gemini.rb +0 -26
  55. data/lib/aidp/shared/providers/macos_ui.rb +0 -26
  56. data/lib/aidp/shared/sync.rb +0 -15
  57. data/lib/aidp/shared/util.rb +0 -41
  58. data/lib/aidp/shared/workspace.rb +0 -21
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aidp
4
+ module Jobs
5
+ class ProviderExecutionJob < BaseJob
6
+ def self.enqueue(provider_type:, prompt:, session: nil, metadata: {})
7
+ job = super
8
+ # Extract job ID explicitly for better readability and debugging
9
+ job_id = job.que_attrs[:job_id]
10
+ raise "Failed to enqueue job: no job ID returned" unless job_id
11
+ job_id
12
+ end
13
+
14
+ def run(provider_type:, prompt:, session: nil, metadata: {})
15
+ start_time = Time.now
16
+
17
+ # Get provider instance
18
+ provider = Aidp::ProviderManager.get_provider(provider_type)
19
+ raise "Provider #{provider_type} not available" unless provider
20
+
21
+ begin
22
+ # Execute provider
23
+ result = provider.send(prompt: prompt, session: session)
24
+
25
+ # Store result
26
+ store_result(result, metadata)
27
+
28
+ # Record metrics
29
+ record_metrics(
30
+ provider_type: provider_type,
31
+ duration: Time.now - start_time,
32
+ success: true,
33
+ error: nil
34
+ )
35
+ rescue => error
36
+ # Record metrics
37
+ record_metrics(
38
+ provider_type: provider_type,
39
+ duration: Time.now - start_time,
40
+ success: false,
41
+ error: error.message
42
+ )
43
+
44
+ # Re-raise error to trigger Que's retry mechanism
45
+ raise
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def store_result(result, metadata)
52
+ return unless metadata[:step_name]
53
+
54
+ Aidp::DatabaseConnection.connection.exec_params(
55
+ <<~SQL,
56
+ INSERT INTO analysis_results (step_name, data, metadata, created_at, updated_at)
57
+ VALUES ($1, $2, $3, $4, $5)
58
+ ON CONFLICT (step_name)
59
+ DO UPDATE SET
60
+ data = EXCLUDED.data,
61
+ metadata = EXCLUDED.metadata,
62
+ updated_at = EXCLUDED.updated_at
63
+ SQL
64
+ [
65
+ metadata[:step_name],
66
+ result.to_json,
67
+ metadata.to_json,
68
+ Time.now,
69
+ Time.now
70
+ ]
71
+ )
72
+ end
73
+
74
+ def record_metrics(provider_type:, duration:, success:, error: nil)
75
+ Aidp::DatabaseConnection.connection.exec_params(
76
+ <<~SQL,
77
+ INSERT INTO provider_metrics (
78
+ provider_type, duration, success, error,
79
+ job_id, attempt, created_at
80
+ )
81
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
82
+ SQL
83
+ [
84
+ provider_type,
85
+ duration,
86
+ success,
87
+ error,
88
+ que_attrs[:job_id],
89
+ que_attrs[:error_count] + 1,
90
+ Time.now
91
+ ]
92
+ )
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "yaml"
5
+
6
+ module Aidp
7
+ # Detects project type, language, framework, and other characteristics
8
+ class ProjectDetector
9
+ attr_reader :project_dir
10
+
11
+ def initialize(project_dir = Dir.pwd)
12
+ @project_dir = project_dir
13
+ end
14
+
15
+ def detect
16
+ {
17
+ language: detect_language,
18
+ framework: detect_framework,
19
+ build_system: detect_build_system,
20
+ package_manager: detect_package_manager,
21
+ static_analysis_tools: detect_static_analysis_tools,
22
+ test_framework: detect_test_framework,
23
+ database: detect_database,
24
+ deployment: detect_deployment
25
+ }
26
+ end
27
+
28
+ private
29
+
30
+ def detect_language
31
+ return "ruby" if File.exist?(File.join(@project_dir, "Gemfile"))
32
+ return "javascript" if File.exist?(File.join(@project_dir, "package.json"))
33
+ return "python" if File.exist?(File.join(@project_dir, "requirements.txt")) || File.exist?(File.join(@project_dir, "pyproject.toml"))
34
+ return "java" if File.exist?(File.join(@project_dir, "pom.xml")) || File.exist?(File.join(@project_dir, "build.gradle"))
35
+ return "go" if File.exist?(File.join(@project_dir, "go.mod"))
36
+ return "rust" if File.exist?(File.join(@project_dir, "Cargo.toml"))
37
+ return "csharp" if File.exist?(File.join(@project_dir, "*.csproj"))
38
+ "unknown"
39
+ end
40
+
41
+ def detect_framework
42
+ case detect_language
43
+ when "ruby"
44
+ return "rails" if File.exist?(File.join(@project_dir, "config", "application.rb"))
45
+ return "sinatra" if File.exist?(File.join(@project_dir, "app.rb")) && File.read(File.join(@project_dir, "app.rb")).include?("Sinatra")
46
+ when "javascript"
47
+ return "react" if File.exist?(File.join(@project_dir, "package.json")) && File.read(File.join(@project_dir, "package.json")).include?("react")
48
+ return "vue" if File.exist?(File.join(@project_dir, "package.json")) && File.read(File.join(@project_dir, "package.json")).include?("vue")
49
+ return "angular" if File.exist?(File.join(@project_dir, "angular.json"))
50
+ return "express" if File.exist?(File.join(@project_dir, "package.json")) && File.read(File.join(@project_dir, "package.json")).include?("express")
51
+ when "python"
52
+ return "django" if File.exist?(File.join(@project_dir, "manage.py"))
53
+ return "flask" if File.exist?(File.join(@project_dir, "app.py")) && File.read(File.join(@project_dir, "app.py")).include?("Flask")
54
+ when "java"
55
+ return "spring" if File.exist?(File.join(@project_dir, "pom.xml")) && File.read(File.join(@project_dir, "pom.xml")).include?("spring-boot")
56
+ end
57
+ "unknown"
58
+ end
59
+
60
+ def detect_build_system
61
+ return "maven" if File.exist?(File.join(@project_dir, "pom.xml"))
62
+ return "gradle" if File.exist?(File.join(@project_dir, "build.gradle"))
63
+ return "npm" if File.exist?(File.join(@project_dir, "package.json"))
64
+ return "bundler" if File.exist?(File.join(@project_dir, "Gemfile"))
65
+ return "pip" if File.exist?(File.join(@project_dir, "requirements.txt"))
66
+ return "cargo" if File.exist?(File.join(@project_dir, "Cargo.toml"))
67
+ return "go" if File.exist?(File.join(@project_dir, "go.mod"))
68
+ "unknown"
69
+ end
70
+
71
+ def detect_package_manager
72
+ detect_build_system
73
+ end
74
+
75
+ def detect_static_analysis_tools
76
+ tools = []
77
+ tools << "rubocop" if File.exist?(File.join(@project_dir, ".rubocop.yml"))
78
+ tools << "eslint" if File.exist?(File.join(@project_dir, ".eslintrc"))
79
+ tools << "flake8" if File.exist?(File.join(@project_dir, ".flake8"))
80
+ tools << "checkstyle" if File.exist?(File.join(@project_dir, "checkstyle.xml"))
81
+ tools << "clippy" if File.exist?(File.join(@project_dir, "Cargo.toml"))
82
+ tools
83
+ end
84
+
85
+ def detect_test_framework
86
+ case detect_language
87
+ when "ruby"
88
+ return "rspec" if File.exist?(File.join(@project_dir, "spec"))
89
+ return "minitest" if File.exist?(File.join(@project_dir, "test"))
90
+ when "javascript"
91
+ return "jest" if File.exist?(File.join(@project_dir, "package.json")) && File.read(File.join(@project_dir, "package.json")).include?("jest")
92
+ return "mocha" if File.exist?(File.join(@project_dir, "package.json")) && File.read(File.join(@project_dir, "package.json")).include?("mocha")
93
+ when "python"
94
+ return "pytest" if File.exist?(File.join(@project_dir, "pytest.ini"))
95
+ return "unittest" if Dir.exist?(File.join(@project_dir, "tests"))
96
+ when "java"
97
+ return "junit" if File.exist?(File.join(@project_dir, "src", "test"))
98
+ end
99
+ "unknown"
100
+ end
101
+
102
+ def detect_database
103
+ return "postgresql" if File.exist?(File.join(@project_dir, "config", "database.yml")) && File.read(File.join(@project_dir, "config", "database.yml")).include?("postgresql")
104
+ return "mysql" if File.exist?(File.join(@project_dir, "config", "database.yml")) && File.read(File.join(@project_dir, "config", "database.yml")).include?("mysql")
105
+ return "sqlite" if File.exist?(File.join(@project_dir, "config", "database.yml")) && File.read(File.join(@project_dir, "config", "database.yml")).include?("sqlite")
106
+ "unknown"
107
+ end
108
+
109
+ def detect_deployment
110
+ return "docker" if File.exist?(File.join(@project_dir, "Dockerfile"))
111
+ return "kubernetes" if File.exist?(File.join(@project_dir, "k8s")) || File.exist?(File.join(@project_dir, "kubernetes"))
112
+ return "heroku" if File.exist?(File.join(@project_dir, "Procfile"))
113
+ return "aws" if File.exist?(File.join(@project_dir, "serverless.yml")) || File.exist?(File.join(@project_dir, "template.yaml"))
114
+ "unknown"
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aidp
4
+ class ProviderManager
5
+ class << self
6
+ def get_provider(provider_type)
7
+ case provider_type
8
+ when "cursor"
9
+ Aidp::Providers::Cursor.new
10
+ when "anthropic"
11
+ Aidp::Providers::Anthropic.new
12
+ when "gemini"
13
+ Aidp::Providers::Gemini.new
14
+ when "macos_ui"
15
+ Aidp::Providers::MacosUI.new
16
+ end
17
+ end
18
+
19
+ def load_from_config(config = {})
20
+ provider_type = config["provider"] || "cursor"
21
+ get_provider(provider_type)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,348 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timeout"
4
+ require "open3"
5
+
6
+ module Aidp
7
+ module Providers
8
+ # Supervisor for managing agent execution with progressive warnings instead of hard timeouts
9
+ class AgentSupervisor
10
+ # Execution states
11
+ STATES = {
12
+ idle: "⏳",
13
+ starting: "🚀",
14
+ running: "🔄",
15
+ warning: "⚠️",
16
+ user_aborted: "🛑",
17
+ completed: "✅",
18
+ failed: "❌"
19
+ }.freeze
20
+
21
+ attr_reader :state, :start_time, :end_time, :duration, :output, :error_output, :exit_code
22
+
23
+ def initialize(command, timeout_seconds: 300, debug: false)
24
+ @command = command
25
+ @timeout_seconds = timeout_seconds
26
+ @debug = debug
27
+ @state = :idle
28
+ @start_time = nil
29
+ @end_time = nil
30
+ @duration = 0
31
+ @output = ""
32
+ @error_output = ""
33
+ @exit_code = nil
34
+ @process_pid = nil
35
+ @output_count = 0
36
+ @last_output_time = nil
37
+ @supervisor_thread = nil
38
+ @output_threads = []
39
+ @warning_shown = false
40
+ @user_aborted = false
41
+ end
42
+
43
+ # Execute the command with supervision
44
+ def execute(input = nil)
45
+ @state = :starting
46
+ @start_time = Time.now
47
+ @last_output_time = @start_time
48
+
49
+ puts "🚀 Starting agent execution (will warn at #{@timeout_seconds}s)"
50
+
51
+ begin
52
+ # Start the process
53
+ Open3.popen3(*@command) do |stdin, stdout, stderr, wait|
54
+ @process_pid = wait.pid
55
+ @state = :running
56
+
57
+ # Send input if provided
58
+ if input
59
+ stdin.puts input
60
+ stdin.close
61
+ end
62
+
63
+ # Start timeout thread that will warn but not kill
64
+ timeout_thread = Thread.new do
65
+ sleep @timeout_seconds
66
+ if @state == :running && !@warning_shown
67
+ show_timeout_warning
68
+ end
69
+ end
70
+
71
+ # Start supervisor thread
72
+ start_supervisor_thread(wait)
73
+
74
+ # Start output collection threads
75
+ start_output_threads(stdout, stderr)
76
+
77
+ # Wait for completion
78
+ result = wait_for_completion(wait)
79
+
80
+ # Kill timeout thread since we're done
81
+ timeout_thread.kill
82
+
83
+ # Clean up threads
84
+ cleanup_threads
85
+
86
+ @end_time = Time.now
87
+ @duration = @end_time - @start_time
88
+
89
+ return result
90
+ end
91
+ rescue => e
92
+ @state = :failed
93
+ @end_time = Time.now
94
+ @duration = @end_time - @start_time if @start_time
95
+ puts "❌ Agent execution failed: #{e.message}"
96
+ raise
97
+ end
98
+ end
99
+
100
+ # Get current execution status
101
+ def status
102
+ elapsed = @start_time ? Time.now - @start_time : 0
103
+ minutes = (elapsed / 60).to_i
104
+ seconds = (elapsed % 60).to_i
105
+ time_str = (minutes > 0) ? "#{minutes}m #{seconds}s" : "#{seconds}s"
106
+
107
+ case @state
108
+ when :idle
109
+ "⏳ Idle"
110
+ when :starting
111
+ "🚀 Starting..."
112
+ when :running
113
+ output_info = (@output_count > 0) ? " (#{@output_count} outputs)" : ""
114
+ "🔄 Running #{time_str}#{output_info}"
115
+ when :warning
116
+ "⚠️ Taking longer than expected #{time_str}"
117
+ when :user_aborted
118
+ "🛑 Aborted by user after #{time_str}"
119
+ when :completed
120
+ "✅ Completed in #{time_str}"
121
+ when :failed
122
+ "❌ Failed after #{time_str}"
123
+ end
124
+ end
125
+
126
+ # Check if execution is still active
127
+ def active?
128
+ [:starting, :running, :warning].include?(@state)
129
+ end
130
+
131
+ # Check if execution completed successfully
132
+ def success?
133
+ @state == :completed && @exit_code == 0
134
+ end
135
+
136
+ # Show timeout warning and give user control
137
+ def show_timeout_warning
138
+ return if @warning_shown
139
+ @warning_shown = true
140
+ @state = :warning
141
+
142
+ puts "\n⚠️ Agent has been running for #{@timeout_seconds} seconds"
143
+ puts " This is longer than expected, but the agent may still be working."
144
+ puts " You can:"
145
+ puts " 1. Continue waiting (press Enter)"
146
+ puts " 2. Abort execution (type 'abort' and press Enter)"
147
+ puts " 3. Wait 5 more minutes (type 'wait' and press Enter)"
148
+
149
+ begin
150
+ Timeout.timeout(30) do
151
+ response = gets&.chomp&.downcase
152
+ case response
153
+ when "abort"
154
+ puts "🛑 Aborting execution..."
155
+ @user_aborted = true
156
+ @state = :user_aborted
157
+ kill!
158
+ when "wait"
159
+ puts "⏰ Will warn again in 5 minutes..."
160
+ @warning_shown = false
161
+ @state = :running
162
+ # Start another warning thread for 5 more minutes
163
+ Thread.new do
164
+ sleep 300 # 5 minutes
165
+ if @state == :running && !@warning_shown
166
+ show_timeout_warning
167
+ end
168
+ end
169
+ else
170
+ puts "🔄 Continuing to wait..."
171
+ @state = :running
172
+ end
173
+ end
174
+ rescue Timeout::Error
175
+ puts "⏰ No response received, continuing to wait..."
176
+ @state = :running
177
+ rescue Interrupt
178
+ puts "\n🛑 User interrupted, aborting..."
179
+ @user_aborted = true
180
+ @state = :user_aborted
181
+ kill!
182
+ end
183
+ end
184
+
185
+ # Force kill the process
186
+ def kill!
187
+ return unless @process_pid && active?
188
+
189
+ puts "💀 Force killing agent process (PID: #{@process_pid})"
190
+
191
+ begin
192
+ # Try graceful termination first
193
+ Process.kill("TERM", @process_pid)
194
+ sleep 1
195
+
196
+ # Force kill if still running
197
+ if process_running?(@process_pid)
198
+ Process.kill("KILL", @process_pid)
199
+ sleep 1
200
+ end
201
+
202
+ # Double-check and force kill again if needed
203
+ if process_running?(@process_pid)
204
+ puts "⚠️ Process still running, using SIGKILL..."
205
+ Process.kill("KILL", @process_pid)
206
+ sleep 1
207
+ end
208
+
209
+ @state = :user_aborted
210
+ rescue Errno::ESRCH
211
+ # Process already dead
212
+ @state = :user_aborted
213
+ rescue => e
214
+ puts "⚠️ Error killing process: #{e.message}"
215
+ # Try one more time with KILL
216
+ begin
217
+ Process.kill("KILL", @process_pid) if process_running?(@process_pid)
218
+ rescue
219
+ # Give up
220
+ end
221
+ end
222
+ end
223
+
224
+ private
225
+
226
+ def start_supervisor_thread(wait)
227
+ @supervisor_thread = Thread.new do
228
+ loop do
229
+ sleep 10 # Check every 10 seconds
230
+
231
+ # Check if process is done
232
+ if wait.value
233
+ break
234
+ end
235
+
236
+ # Check for stuck condition (no output for 3 minutes)
237
+ if @last_output_time && Time.now - @last_output_time > 180
238
+ puts "⚠️ Agent appears stuck (no output for 3+ minutes)"
239
+ # Don't kill, just warn
240
+ end
241
+ end
242
+ rescue => e
243
+ puts "⚠️ Supervisor thread error: #{e.message}" if @debug
244
+ end
245
+
246
+ @supervisor_thread
247
+ end
248
+
249
+ def start_output_threads(stdout, stderr)
250
+ # Stdout thread
251
+ @output_threads << Thread.new do
252
+ stdout.each_line do |line|
253
+ @output += line
254
+ @output_count += 1
255
+ @last_output_time = Time.now
256
+
257
+ if @debug
258
+ puts "📤 #{line.chomp}"
259
+ end
260
+ end
261
+ rescue IOError => e
262
+ puts "📤 stdout closed: #{e.message}" if @debug
263
+ rescue => e
264
+ puts "⚠️ stdout thread error: #{e.message}" if @debug
265
+ end
266
+
267
+ # Stderr thread
268
+ @output_threads << Thread.new do
269
+ stderr.each_line do |line|
270
+ @error_output += line
271
+ @output_count += 1
272
+ @last_output_time = Time.now
273
+
274
+ if @debug
275
+ puts "❌ #{line.chomp}"
276
+ end
277
+ end
278
+ rescue IOError => e
279
+ puts "❌ stderr closed: #{e.message}" if @debug
280
+ rescue => e
281
+ puts "⚠️ stderr thread error: #{e.message}" if @debug
282
+ end
283
+ end
284
+
285
+ def wait_for_completion(wait)
286
+ # Wait for process to complete
287
+ exit_status = wait.value
288
+ @exit_code = exit_status.exitstatus
289
+
290
+ # Update duration
291
+ @duration = Time.now - @start_time
292
+
293
+ if @user_aborted || @state == :user_aborted
294
+ # Process was killed by user
295
+ {
296
+ success: false,
297
+ state: @state,
298
+ output: @output,
299
+ error_output: @error_output,
300
+ exit_code: @exit_code,
301
+ duration: @duration,
302
+ reason: "user_aborted"
303
+ }
304
+ elsif exit_status.success?
305
+ @state = :completed
306
+ {
307
+ success: true,
308
+ state: @state,
309
+ output: @output,
310
+ error_output: @error_output,
311
+ exit_code: @exit_code,
312
+ duration: @duration
313
+ }
314
+ else
315
+ @state = :failed
316
+ {
317
+ success: false,
318
+ state: @state,
319
+ output: @output,
320
+ error_output: @error_output,
321
+ exit_code: @exit_code,
322
+ duration: @duration,
323
+ reason: "non_zero_exit"
324
+ }
325
+ end
326
+ end
327
+
328
+ def cleanup_threads
329
+ # Wait for output threads to finish (with timeout)
330
+ @output_threads.each do |thread|
331
+ thread.join(5) # Wait up to 5 seconds
332
+ rescue => e
333
+ puts "⚠️ Error joining thread: #{e.message}" if @debug
334
+ end
335
+
336
+ # Kill supervisor thread
337
+ @supervisor_thread&.kill
338
+ end
339
+
340
+ def process_running?(pid)
341
+ Process.kill(0, pid)
342
+ true
343
+ rescue Errno::ESRCH
344
+ false
345
+ end
346
+ end
347
+ end
348
+ end