Module: AIA

Defined in:
lib/aia.rb,
lib/aia/config.rb,
lib/aia/session.rb,
lib/aia/utility.rb,
lib/aia/version.rb,
lib/aia/config/base.rb,
lib/aia/ui_presenter.rb,
lib/aia/topic_context.rb,
lib/aia/prompt_handler.rb,
lib/aia/config/defaults.rb,
lib/aia/history_manager.rb,
lib/aia/config/validator.rb,
lib/aia/ruby_llm_adapter.rb,
lib/aia/config/cli_parser.rb,
lib/aia/directives/models.rb,
lib/aia/config/file_loader.rb,
lib/aia/directives/utility.rb,
lib/aia/directive_processor.rb,
lib/aia/directives/registry.rb,
lib/aia/directives/execution.rb,
lib/aia/directives/checkpoint.rb,
lib/aia/chat_processor_service.rb,
lib/aia/directives/web_and_file.rb,
lib/aia/directives/configuration.rb

Overview

lib/aia/directives/configuration.rb

Defined Under Namespace

Modules: ConfigModules, Directives Classes: ChatProcessorService, Config, DirectiveProcessor, Fzf, HistoryManager, PromptHandler, RubyLLMAdapter, Session, TopicContext, UIPresenter, Utility

Constant Summary collapse

VERSION =

The VERSION constant defines the current version of the AIA application, which is read from the .version file in the project root.

File.read(File.join(File.dirname(__FILE__), '..', '..', '.version')).strip

Class Method Summary collapse

Class Method Details

.bad_file?(filename) ⇒ Boolean



71
72
73
# File 'lib/aia.rb', line 71

def self.bad_file?(filename)
  !good_file?(filename)
end

.build_flagsObject



75
76
77
78
79
80
81
82
83
# File 'lib/aia.rb', line 75

def self.build_flags
  @config.each_pair do |key, value|
    if [TrueClass, FalseClass].include?(value.class)
      define_singleton_method("#{key}?") do
        @config[key]
      end
    end
  end
end

.clientObject



57
58
59
# File 'lib/aia.rb', line 57

def self.client
  @config.client
end

.client=(client) ⇒ Object



61
62
63
# File 'lib/aia.rb', line 61

def self.client=(client)
  @config.client = client
end

.configObject



53
54
55
# File 'lib/aia.rb', line 53

def self.config
  @config
end

.good_file?(filename) ⇒ Boolean



65
66
67
68
69
# File 'lib/aia.rb', line 65

def self.good_file?(filename)
  File.exist?(filename) &&
  File.readable?(filename) &&
  !File.directory?(filename)
end

.runObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/aia.rb', line 85

def self.run
  @config = Config.setup

  build_flags

  # Load Fzf if fuzzy search is enabled and fzf is installed
  if @config.fuzzy
    begin
      # Cache fzf availability check for better performance
      if system('which fzf >/dev/null 2>&1')
        require_relative 'aia/fzf'
      else
        warn "Warning: Fuzzy search enabled but fzf not found. Install fzf for enhanced search capabilities."
      end
    rescue StandardError => e
      warn "Warning: Failed to load fzf: #{e.message}"
    end
  end

  prompt_handler = PromptHandler.new

  # Initialize the appropriate client adapter based on configuration
  @config.client = if 'ruby_llm' == @config.adapter
                    RubyLLMAdapter.new
                  else
                    # TODO: ?? some other LLM API wrapper
                    STDERR.puts "ERROR: There is no adapter for #{@config.adapter}"
                    exit 1
                  end

  # There are two kinds of sessions: batch and chat
  # A chat session is started when the --chat CLI option is used
  # BUT its also possible to start a chat session with an initial prompt AND
  # within that initial prompt there can be a workflow (aka pipeline)
  # defined.  If that is the case, then the chat session will not start
  # until the initial prompt has completed its workflow.

  session        = Session.new(prompt_handler)

  session.start
end