Class: Aidp::Execute::InteractiveRepl

Inherits:
Object
  • Object
show all
Includes:
RescueLogging
Defined in:
lib/aidp/execute/interactive_repl.rb

Overview

Interactive REPL for controlling async work loops Provides live control during work loop execution:

  • Pause/resume/cancel work loop

  • Inject instructions mid-execution

  • Update configuration live

  • View streaming output

  • Rollback commits

Usage:

repl = InteractiveRepl.new(project_dir, provider_manager, config)
repl.start_work_loop(step_name, step_spec, context)

Instance Method Summary collapse

Methods included from RescueLogging

__log_rescue_impl, log_rescue, #log_rescue

Constructor Details

#initialize(project_dir, provider_manager, config, options = {}) ⇒ InteractiveRepl

Returns a new instance of InteractiveRepl.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/aidp/execute/interactive_repl.rb', line 26

def initialize(project_dir, provider_manager, config, options = {})
  @project_dir = project_dir
  @provider_manager = provider_manager
  @config = config
  @options = options
  @prompt = options[:prompt] || TTY::Prompt.new
  @async_runner = nil
  @repl_macros = ReplMacros.new
  @output_display_thread = nil
  @running = false
  @completion_setup_needed = true
end

Instance Method Details

#start_work_loop(step_name, step_spec, context = {}) ⇒ Object

Start work loop and enter interactive REPL



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/aidp/execute/interactive_repl.rb', line 40

def start_work_loop(step_name, step_spec, context = {})
  @async_runner = AsyncWorkLoopRunner.new(
    @project_dir,
    @provider_manager,
    @config,
    @options
  )

  display_welcome(step_name)

  # Start async work loop
  result = @async_runner.execute_step_async(step_name, step_spec, context)
  @prompt.say("Work loop started (#{result[:state][:state]})")

  # Start output display thread
  start_output_display

  # Enter REPL loop
  @running = true
  repl_loop

  # Wait for completion
  final_result = @async_runner.wait

  # Stop output display
  stop_output_display

  display_completion(final_result)
  final_result
end