aidp 0.7.0 → 0.8.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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +60 -214
  3. data/bin/aidp +1 -1
  4. data/lib/aidp/analysis/kb_inspector.rb +38 -23
  5. data/lib/aidp/analysis/seams.rb +2 -31
  6. data/lib/aidp/analysis/tree_sitter_grammar_loader.rb +1 -13
  7. data/lib/aidp/analysis/tree_sitter_scan.rb +3 -20
  8. data/lib/aidp/analyze/error_handler.rb +2 -75
  9. data/lib/aidp/analyze/json_file_storage.rb +292 -0
  10. data/lib/aidp/analyze/progress.rb +12 -0
  11. data/lib/aidp/analyze/progress_visualizer.rb +12 -17
  12. data/lib/aidp/analyze/ruby_maat_integration.rb +13 -31
  13. data/lib/aidp/analyze/runner.rb +256 -87
  14. data/lib/aidp/cli/jobs_command.rb +100 -432
  15. data/lib/aidp/cli.rb +309 -239
  16. data/lib/aidp/config.rb +298 -10
  17. data/lib/aidp/debug_logger.rb +195 -0
  18. data/lib/aidp/debug_mixin.rb +187 -0
  19. data/lib/aidp/execute/progress.rb +9 -0
  20. data/lib/aidp/execute/runner.rb +221 -40
  21. data/lib/aidp/execute/steps.rb +17 -7
  22. data/lib/aidp/execute/workflow_selector.rb +211 -0
  23. data/lib/aidp/harness/completion_checker.rb +268 -0
  24. data/lib/aidp/harness/condition_detector.rb +1526 -0
  25. data/lib/aidp/harness/config_loader.rb +373 -0
  26. data/lib/aidp/harness/config_manager.rb +382 -0
  27. data/lib/aidp/harness/config_schema.rb +1006 -0
  28. data/lib/aidp/harness/config_validator.rb +355 -0
  29. data/lib/aidp/harness/configuration.rb +477 -0
  30. data/lib/aidp/harness/enhanced_runner.rb +494 -0
  31. data/lib/aidp/harness/error_handler.rb +616 -0
  32. data/lib/aidp/harness/provider_config.rb +423 -0
  33. data/lib/aidp/harness/provider_factory.rb +306 -0
  34. data/lib/aidp/harness/provider_manager.rb +1269 -0
  35. data/lib/aidp/harness/provider_type_checker.rb +88 -0
  36. data/lib/aidp/harness/runner.rb +411 -0
  37. data/lib/aidp/harness/state/errors.rb +28 -0
  38. data/lib/aidp/harness/state/metrics.rb +219 -0
  39. data/lib/aidp/harness/state/persistence.rb +128 -0
  40. data/lib/aidp/harness/state/provider_state.rb +132 -0
  41. data/lib/aidp/harness/state/ui_state.rb +68 -0
  42. data/lib/aidp/harness/state/workflow_state.rb +123 -0
  43. data/lib/aidp/harness/state_manager.rb +586 -0
  44. data/lib/aidp/harness/status_display.rb +888 -0
  45. data/lib/aidp/harness/ui/base.rb +16 -0
  46. data/lib/aidp/harness/ui/enhanced_tui.rb +545 -0
  47. data/lib/aidp/harness/ui/enhanced_workflow_selector.rb +252 -0
  48. data/lib/aidp/harness/ui/error_handler.rb +132 -0
  49. data/lib/aidp/harness/ui/frame_manager.rb +361 -0
  50. data/lib/aidp/harness/ui/job_monitor.rb +500 -0
  51. data/lib/aidp/harness/ui/navigation/main_menu.rb +311 -0
  52. data/lib/aidp/harness/ui/navigation/menu_formatter.rb +120 -0
  53. data/lib/aidp/harness/ui/navigation/menu_item.rb +142 -0
  54. data/lib/aidp/harness/ui/navigation/menu_state.rb +139 -0
  55. data/lib/aidp/harness/ui/navigation/submenu.rb +202 -0
  56. data/lib/aidp/harness/ui/navigation/workflow_selector.rb +176 -0
  57. data/lib/aidp/harness/ui/progress_display.rb +280 -0
  58. data/lib/aidp/harness/ui/question_collector.rb +141 -0
  59. data/lib/aidp/harness/ui/spinner_group.rb +184 -0
  60. data/lib/aidp/harness/ui/spinner_helper.rb +152 -0
  61. data/lib/aidp/harness/ui/status_manager.rb +312 -0
  62. data/lib/aidp/harness/ui/status_widget.rb +280 -0
  63. data/lib/aidp/harness/ui/workflow_controller.rb +312 -0
  64. data/lib/aidp/harness/user_interface.rb +2381 -0
  65. data/lib/aidp/provider_manager.rb +131 -7
  66. data/lib/aidp/providers/anthropic.rb +28 -103
  67. data/lib/aidp/providers/base.rb +170 -0
  68. data/lib/aidp/providers/cursor.rb +52 -181
  69. data/lib/aidp/providers/gemini.rb +24 -107
  70. data/lib/aidp/providers/macos_ui.rb +99 -5
  71. data/lib/aidp/providers/opencode.rb +194 -0
  72. data/lib/aidp/storage/csv_storage.rb +172 -0
  73. data/lib/aidp/storage/file_manager.rb +214 -0
  74. data/lib/aidp/storage/json_storage.rb +140 -0
  75. data/lib/aidp/version.rb +1 -1
  76. data/lib/aidp.rb +54 -39
  77. data/templates/COMMON/AGENT_BASE.md +11 -0
  78. data/templates/EXECUTE/00_PRD.md +4 -4
  79. data/templates/EXECUTE/02_ARCHITECTURE.md +5 -4
  80. data/templates/EXECUTE/07_TEST_PLAN.md +4 -1
  81. data/templates/EXECUTE/08_TASKS.md +4 -4
  82. data/templates/EXECUTE/10_IMPLEMENTATION_AGENT.md +4 -4
  83. data/templates/README.md +279 -0
  84. data/templates/aidp-development.yml.example +373 -0
  85. data/templates/aidp-minimal.yml.example +48 -0
  86. data/templates/aidp-production.yml.example +475 -0
  87. data/templates/aidp.yml.example +598 -0
  88. metadata +93 -69
  89. data/lib/aidp/analyze/agent_personas.rb +0 -71
  90. data/lib/aidp/analyze/agent_tool_executor.rb +0 -439
  91. data/lib/aidp/analyze/data_retention_manager.rb +0 -421
  92. data/lib/aidp/analyze/database.rb +0 -260
  93. data/lib/aidp/analyze/dependencies.rb +0 -335
  94. data/lib/aidp/analyze/export_manager.rb +0 -418
  95. data/lib/aidp/analyze/focus_guidance.rb +0 -517
  96. data/lib/aidp/analyze/incremental_analyzer.rb +0 -533
  97. data/lib/aidp/analyze/language_analysis_strategies.rb +0 -897
  98. data/lib/aidp/analyze/large_analysis_progress.rb +0 -499
  99. data/lib/aidp/analyze/memory_manager.rb +0 -339
  100. data/lib/aidp/analyze/metrics_storage.rb +0 -336
  101. data/lib/aidp/analyze/parallel_processor.rb +0 -454
  102. data/lib/aidp/analyze/performance_optimizer.rb +0 -691
  103. data/lib/aidp/analyze/repository_chunker.rb +0 -697
  104. data/lib/aidp/analyze/static_analysis_detector.rb +0 -577
  105. data/lib/aidp/analyze/storage.rb +0 -655
  106. data/lib/aidp/analyze/tool_configuration.rb +0 -441
  107. data/lib/aidp/analyze/tool_modernization.rb +0 -750
  108. data/lib/aidp/database/pg_adapter.rb +0 -148
  109. data/lib/aidp/database_config.rb +0 -69
  110. data/lib/aidp/database_connection.rb +0 -72
  111. data/lib/aidp/job_manager.rb +0 -41
  112. data/lib/aidp/jobs/base_job.rb +0 -45
  113. data/lib/aidp/jobs/provider_execution_job.rb +0 -83
  114. data/lib/aidp/project_detector.rb +0 -117
  115. data/lib/aidp/providers/agent_supervisor.rb +0 -348
  116. data/lib/aidp/providers/supervised_base.rb +0 -317
  117. data/lib/aidp/providers/supervised_cursor.rb +0 -22
  118. data/lib/aidp/sync.rb +0 -13
  119. data/lib/aidp/workspace.rb +0 -19
@@ -1,499 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
- require "yaml"
5
- require "time"
6
- require "securerandom"
7
-
8
- module Aidp
9
- class LargeAnalysisProgress
10
- # Progress tracking states
11
- PROGRESS_STATES = %w[pending running paused completed failed cancelled].freeze
12
-
13
- # Default configuration
14
- DEFAULT_CONFIG = {
15
- checkpoint_interval: 100, # Save progress every 100 items
16
- max_checkpoints: 50, # Keep last 50 checkpoints
17
- progress_file: ".aidp-large-analysis-progress.yml",
18
- auto_save: true,
19
- detailed_logging: false
20
- }.freeze
21
-
22
- def initialize(project_dir = Dir.pwd, config = {})
23
- @project_dir = project_dir
24
- @config = DEFAULT_CONFIG.merge(config)
25
- @progress_file = File.join(@project_dir, @config[:progress_file])
26
- @current_progress = load_progress || create_initial_progress
27
- @checkpoints = []
28
- @start_time = nil
29
- @last_save_time = Time.now
30
- end
31
-
32
- # Start a large analysis job
33
- def start_analysis(analysis_config)
34
- @current_progress = {
35
- id: generate_analysis_id,
36
- state: "running",
37
- config: analysis_config,
38
- start_time: Time.now,
39
- last_update: Time.now,
40
- total_items: analysis_config[:total_items] || 0,
41
- processed_items: 0,
42
- failed_items: 0,
43
- current_phase: "initialization",
44
- phases: analysis_config[:phases] || [],
45
- phase_progress: {},
46
- checkpoints: [],
47
- errors: [],
48
- warnings: [],
49
- statistics: {
50
- items_per_second: 0,
51
- estimated_completion: nil,
52
- memory_usage: 0,
53
- cpu_usage: 0
54
- }
55
- }
56
-
57
- @start_time = @current_progress[:start_time]
58
- save_progress
59
-
60
- @current_progress
61
- end
62
-
63
- # Update progress for current item
64
- def update_item_progress(item_index, item_data = {})
65
- return unless @current_progress
66
-
67
- @current_progress[:processed_items] += 1
68
- @current_progress[:last_update] = Time.now
69
-
70
- # Update statistics
71
- update_statistics
72
-
73
- # Check if checkpoint should be saved
74
- save_checkpoint(item_index, item_data) if should_save_checkpoint?
75
-
76
- # Auto-save if enabled
77
- save_progress if @config[:auto_save] && should_auto_save?
78
-
79
- @current_progress
80
- end
81
-
82
- # Update phase progress
83
- def update_phase_progress(phase_name, phase_data = {})
84
- return unless @current_progress
85
-
86
- @current_progress[:current_phase] = phase_name
87
- @current_progress[:phase_progress][phase_name] = {
88
- start_time: Time.now,
89
- items_processed: 0,
90
- items_failed: 0,
91
- data: phase_data
92
- }
93
-
94
- save_progress
95
- @current_progress
96
- end
97
-
98
- # Mark item as failed
99
- def mark_item_failed(item_index, error_data = {})
100
- return unless @current_progress
101
-
102
- @current_progress[:failed_items] += 1
103
- @current_progress[:errors] << {
104
- item_index: item_index,
105
- timestamp: Time.now,
106
- error: error_data[:error],
107
- details: error_data[:details]
108
- }
109
-
110
- # Update current phase if applicable
111
- if @current_progress[:current_phase] && @current_progress[:phase_progress][@current_progress[:current_phase]]
112
- @current_progress[:phase_progress][@current_progress[:current_phase]][:items_failed] += 1
113
- end
114
-
115
- save_progress
116
- @current_progress
117
- end
118
-
119
- # Pause analysis
120
- def pause_analysis(reason = nil)
121
- return unless @current_progress
122
-
123
- @current_progress[:state] = "paused"
124
- @current_progress[:pause_reason] = reason
125
- @current_progress[:pause_time] = Time.now
126
- @current_progress[:last_update] = Time.now
127
-
128
- save_progress
129
- @current_progress
130
- end
131
-
132
- # Resume analysis
133
- def resume_analysis
134
- return unless @current_progress
135
-
136
- @current_progress[:state] = "running"
137
- @current_progress[:resume_time] = Time.now
138
- @current_progress[:last_update] = Time.now
139
-
140
- # Calculate pause duration
141
- if @current_progress[:pause_time]
142
- pause_duration = @current_progress[:resume_time] - @current_progress[:pause_time]
143
- @current_progress[:total_pause_time] ||= 0
144
- @current_progress[:total_pause_time] += pause_duration
145
- end
146
-
147
- save_progress
148
- @current_progress
149
- end
150
-
151
- # Complete analysis
152
- def complete_analysis(completion_data = {})
153
- return unless @current_progress
154
-
155
- @current_progress[:state] = "completed"
156
- @current_progress[:completion_time] = Time.now
157
- @current_progress[:last_update] = Time.now
158
- @current_progress[:completion_data] = completion_data
159
-
160
- # Calculate final statistics
161
- calculate_final_statistics
162
-
163
- save_progress
164
- @current_progress
165
- end
166
-
167
- # Fail analysis
168
- def fail_analysis(error_data = {})
169
- return unless @current_progress
170
-
171
- @current_progress[:state] = "failed"
172
- @current_progress[:failure_time] = Time.now
173
- @current_progress[:last_update] = Time.now
174
- @current_progress[:failure_data] = error_data
175
-
176
- save_progress
177
- @current_progress
178
- end
179
-
180
- # Cancel analysis
181
- def cancel_analysis(reason = nil)
182
- return unless @current_progress
183
-
184
- @current_progress[:state] = "cancelled"
185
- @current_progress[:cancellation_time] = Time.now
186
- @current_progress[:last_update] = Time.now
187
- @current_progress[:cancellation_reason] = reason
188
-
189
- save_progress
190
- @current_progress
191
- end
192
-
193
- # Get current progress
194
- def get_progress
195
- return nil unless @current_progress
196
-
197
- # Update statistics before returning
198
- update_statistics
199
-
200
- {
201
- id: @current_progress[:id],
202
- state: @current_progress[:state],
203
- progress_percentage: calculate_progress_percentage,
204
- processed_items: @current_progress[:processed_items],
205
- total_items: @current_progress[:total_items],
206
- failed_items: @current_progress[:failed_items],
207
- current_phase: @current_progress[:current_phase],
208
- elapsed_time: calculate_elapsed_time,
209
- estimated_remaining: calculate_estimated_remaining,
210
- statistics: @current_progress[:statistics],
211
- errors: @current_progress[:errors].last(10), # Last 10 errors
212
- warnings: @current_progress[:warnings].last(10) # Last 10 warnings
213
- }
214
- end
215
-
216
- # Get detailed progress report
217
- def get_detailed_progress
218
- return nil unless @current_progress
219
-
220
- {
221
- basic_progress: get_progress,
222
- phase_progress: @current_progress[:phase_progress],
223
- all_errors: @current_progress[:errors],
224
- all_warnings: @current_progress[:warnings],
225
- checkpoints: @current_progress[:checkpoints],
226
- configuration: @current_progress[:config],
227
- timing: {
228
- start_time: @current_progress[:start_time],
229
- last_update: @current_progress[:last_update],
230
- elapsed_time: calculate_elapsed_time,
231
- pause_time: @current_progress[:total_pause_time] || 0,
232
- effective_time: calculate_effective_time
233
- }
234
- }
235
- end
236
-
237
- # Get progress history
238
- def get_progress_history(limit = 10)
239
- return [] unless File.exist?(@progress_file)
240
-
241
- begin
242
- progress_data = YAML.load_file(@progress_file)
243
- history = progress_data[:history] || []
244
- history.last(limit)
245
- rescue
246
- []
247
- end
248
- end
249
-
250
- # Reset progress
251
- def reset_progress
252
- @current_progress = create_initial_progress
253
- @checkpoints = []
254
- @start_time = nil
255
- @last_save_time = Time.now
256
-
257
- # Clear progress file
258
- File.delete(@progress_file) if File.exist?(@progress_file)
259
-
260
- @current_progress
261
- end
262
-
263
- # Export progress data
264
- def export_progress(format = "json")
265
- return nil unless @current_progress
266
-
267
- case format.downcase
268
- when "json"
269
- JSON.pretty_generate(@current_progress)
270
- when "yaml"
271
- YAML.dump(@current_progress)
272
- else
273
- raise "Unsupported export format: #{format}"
274
- end
275
- end
276
-
277
- # Import progress data
278
- def import_progress(data, format = "json")
279
- parsed_data = case format.downcase
280
- when "json"
281
- JSON.parse(data)
282
- when "yaml"
283
- YAML.safe_load(data)
284
- else
285
- raise "Unsupported import format: #{format}"
286
- end
287
-
288
- @current_progress = parsed_data
289
- save_progress
290
-
291
- {
292
- success: true,
293
- imported_progress: @current_progress
294
- }
295
- end
296
-
297
- private
298
-
299
- def load_progress
300
- return nil unless File.exist?(@progress_file)
301
-
302
- begin
303
- YAML.load_file(@progress_file)
304
- rescue
305
- nil
306
- end
307
- end
308
-
309
- def save_progress
310
- return unless @current_progress
311
-
312
- # Add to history if this is a significant update
313
- add_to_history if should_add_to_history?
314
-
315
- # Save current progress
316
- File.write(@progress_file, YAML.dump(@current_progress))
317
- @last_save_time = Time.now
318
- end
319
-
320
- def create_initial_progress
321
- {
322
- id: generate_analysis_id,
323
- state: "pending",
324
- start_time: nil,
325
- last_update: Time.now,
326
- total_items: 0,
327
- processed_items: 0,
328
- failed_items: 0,
329
- current_phase: "initialization",
330
- phases: [],
331
- phase_progress: {},
332
- checkpoints: [],
333
- errors: [],
334
- warnings: [],
335
- statistics: {
336
- items_per_second: 0,
337
- estimated_completion: nil,
338
- memory_usage: 0,
339
- cpu_usage: 0
340
- }
341
- }
342
- end
343
-
344
- def generate_analysis_id
345
- timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
346
- "analysis_#{timestamp}_#{SecureRandom.hex(4)}"
347
- end
348
-
349
- def should_save_checkpoint?
350
- return false unless @current_progress
351
-
352
- @current_progress[:processed_items] % @config[:checkpoint_interval] == 0
353
- end
354
-
355
- def save_checkpoint(item_index, item_data)
356
- return unless @current_progress
357
-
358
- checkpoint = {
359
- timestamp: Time.now,
360
- item_index: item_index,
361
- processed_items: @current_progress[:processed_items],
362
- failed_items: @current_progress[:failed_items],
363
- current_phase: @current_progress[:current_phase],
364
- data: item_data
365
- }
366
-
367
- @current_progress[:checkpoints] << checkpoint
368
-
369
- # Keep only the last N checkpoints
370
- return unless @current_progress[:checkpoints].length > @config[:max_checkpoints]
371
-
372
- @current_progress[:checkpoints] = @current_progress[:checkpoints].last(@config[:max_checkpoints])
373
- end
374
-
375
- def should_auto_save?
376
- return false unless @current_progress
377
-
378
- (Time.now - @last_save_time) > 60 # Save every minute
379
- end
380
-
381
- def should_add_to_history?
382
- return false unless @current_progress
383
-
384
- # Add to history on significant events
385
- %w[completed failed cancelled].include?(@current_progress[:state])
386
- end
387
-
388
- def add_to_history
389
- return unless @current_progress
390
-
391
- history_file = @progress_file.sub(".yml", "_history.yml")
392
- history = []
393
-
394
- if File.exist?(history_file)
395
- begin
396
- history_data = YAML.load_file(history_file)
397
- history = history_data[:history] || []
398
- rescue
399
- history = []
400
- end
401
- end
402
-
403
- # Add current progress to history
404
- history << {
405
- timestamp: Time.now,
406
- progress: @current_progress.dup
407
- }
408
-
409
- # Keep only last 100 entries
410
- history = history.last(100)
411
-
412
- # Save history
413
- File.write(history_file, YAML.dump({history: history}))
414
- end
415
-
416
- def update_statistics
417
- return unless @current_progress && @start_time
418
-
419
- elapsed_time = calculate_elapsed_time
420
- return if elapsed_time <= 0
421
-
422
- # Calculate items per second
423
- @current_progress[:statistics][:items_per_second] =
424
- @current_progress[:processed_items].to_f / elapsed_time
425
-
426
- # Calculate estimated completion
427
- if @current_progress[:statistics][:items_per_second] > 0
428
- remaining_items = @current_progress[:total_items] - @current_progress[:processed_items]
429
- estimated_seconds = remaining_items / @current_progress[:statistics][:items_per_second]
430
- @current_progress[:statistics][:estimated_completion] = Time.now + estimated_seconds
431
- end
432
-
433
- # Update resource usage (simplified)
434
- @current_progress[:statistics][:memory_usage] = get_memory_usage
435
- @current_progress[:statistics][:cpu_usage] = get_cpu_usage
436
- end
437
-
438
- def calculate_final_statistics
439
- return unless @current_progress
440
-
441
- total_time = calculate_elapsed_time
442
- effective_time = calculate_effective_time
443
-
444
- @current_progress[:final_statistics] = {
445
- total_time: total_time,
446
- effective_time: effective_time,
447
- pause_time: @current_progress[:total_pause_time] || 0,
448
- average_items_per_second: @current_progress[:processed_items].to_f / effective_time,
449
- success_rate: calculate_success_rate,
450
- total_errors: @current_progress[:errors].length,
451
- total_warnings: @current_progress[:warnings].length
452
- }
453
- end
454
-
455
- def calculate_progress_percentage
456
- return 0 unless @current_progress && @current_progress[:total_items] > 0
457
-
458
- (@current_progress[:processed_items].to_f / @current_progress[:total_items] * 100).round(2)
459
- end
460
-
461
- def calculate_elapsed_time
462
- return 0 unless @current_progress && @current_progress[:start_time]
463
-
464
- end_time = @current_progress[:last_update] || Time.now
465
- end_time - @current_progress[:start_time]
466
- end
467
-
468
- def calculate_effective_time
469
- elapsed_time = calculate_elapsed_time
470
- pause_time = @current_progress[:total_pause_time] || 0
471
- elapsed_time - pause_time
472
- end
473
-
474
- def calculate_estimated_remaining
475
- return nil unless @current_progress && @current_progress[:statistics][:items_per_second] > 0
476
-
477
- remaining_items = @current_progress[:total_items] - @current_progress[:processed_items]
478
- remaining_items / @current_progress[:statistics][:items_per_second]
479
- end
480
-
481
- def calculate_success_rate
482
- return 0 unless @current_progress && @current_progress[:processed_items] > 0
483
-
484
- successful_items = @current_progress[:processed_items] - @current_progress[:failed_items]
485
- (successful_items.to_f / @current_progress[:processed_items] * 100).round(2)
486
- end
487
-
488
- def get_memory_usage
489
- # Get current memory usage in MB
490
- Process.getrusage(:SELF).maxrss / 1024.0
491
- end
492
-
493
- def get_cpu_usage
494
- # Simplified CPU usage calculation
495
- # In a real implementation, this would track CPU time
496
- 0.5 # Return 50% as default
497
- end
498
- end
499
- end