lib/aia/main.rb in aia-0.5.10 vs lib/aia/main.rb in aia-0.5.11

- old
+ new

@@ -18,15 +18,16 @@ SPINNER_FORMAT = :bouncing_ball include AIA::DynamicContent include AIA::UserQuery - attr_accessor :logger, :tools, :backend + attr_accessor :logger, :tools, :backend, :directive_output attr_reader :spinner - def initialize(args= ARGV) + def initialize(args= ARGV) + @directive_output = "" AIA::Tools.load_tools AIA::Cli.new(args) if AIA.config.debug? @@ -69,11 +70,11 @@ # Reline::HISTORY.max_size = max_history_size end def call - @directives_processor.execute_my_directives + directive_output = @directives_processor.execute_my_directives if AIA.config.chat? AIA.config.out_file = STDOUT AIA.config.extra = "--quiet" if 'mods' == AIA.config.backend end @@ -101,10 +102,12 @@ abort "backend not found: #{AIA.config.backend}" if backend_klass.nil? the_prompt = @prompt.to_s + the_prompt.prepend(directive_output + "\n") unless directive_output.nil? || directive_output.empty? + if AIA.config.terse? the_prompt.prepend "Be terse in your response. " end @backend = backend_klass.new( @@ -184,11 +187,13 @@ if result parts = the_prompt_text[signal.size..].split(' ') directive = parts.shift parameters = parts.join(' ') AIA.config.directives << [directive, parameters] - @directives_processor.execute_my_directives + directive_output = @directives_processor.execute_my_directives + else + directive_output = "" end result end @@ -200,10 +205,19 @@ until the_prompt_text.empty? the_prompt_text = render_erb(the_prompt_text) if AIA.config.erb? the_prompt_text = render_env(the_prompt_text) if AIA.config.shell? - unless handle_directives(the_prompt_text) + if handle_directives(the_prompt_text) + unless directive_output.nil? + the_prompt_text = insert_terse_phrase(the_prompt_text) + the_prompt_text << directive_output + result = get_and_display_result(the_prompt_text) + + log_the_follow_up(the_prompt_text, result) + speak result + end + else the_prompt_text = insert_terse_phrase(the_prompt_text) result = get_and_display_result(the_prompt_text) log_the_follow_up(the_prompt_text, result) speak result