aia 0.0.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-25 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prompt_manager
@@ -105,7 +105,20 @@ files:
105
105
  - lib/aia.rb
106
106
  - lib/aia/cli.rb
107
107
  - lib/aia/configuration.rb
108
- - lib/aia/external_commands.rb
108
+ - lib/aia/external.rb
109
+ - lib/aia/external/,keep
110
+ - lib/aia/external/.irbrc
111
+ - lib/aia/external/ag.rb
112
+ - lib/aia/external/bat.rb
113
+ - lib/aia/external/fzf.rb
114
+ - lib/aia/external/glow.rb
115
+ - lib/aia/external/mods.rb
116
+ - lib/aia/external/rg.rb
117
+ - lib/aia/external/sgpt.rb
118
+ - lib/aia/external/subl.rb
119
+ - lib/aia/external/temp.md
120
+ - lib/aia/external/tool.rb
121
+ - lib/aia/external_two.rb
109
122
  - lib/aia/logging.rb
110
123
  - lib/aia/main.rb
111
124
  - lib/aia/prompt_processing.rb
@@ -1,116 +0,0 @@
1
- # lib/aia/external_commands.rb
2
-
3
- # TODO: move stuff associated with the CLI options for
4
- # external commands to this module.
5
- # Is the EDITOR considered an external command? Yes.
6
-
7
- module AIA::ExternalCommands
8
- TOOLS = {
9
- 'fzf' => [ 'Command-line fuzzy finder written in Go',
10
- 'https://github.com/junegunn/fzf'],
11
-
12
- 'mods' => [ 'AI on the command-line',
13
- 'https://github.com/charmbracelet/mods'],
14
-
15
- 'rg' => [ 'Search tool like grep and The Silver Searcher',
16
- 'https://github.com/BurntSushi/ripgrep']
17
- }
18
-
19
-
20
- HELP = <<~EOS
21
- External Tools Used
22
- -------------------
23
-
24
- To install the external CLI programs used by aia:
25
- brew install #{TOOLS.keys.join(' ')}
26
-
27
- #{TOOLS.to_a.map{|t| t.join("\n ") }.join("\n\n")}
28
-
29
- A text editor whose executable is setup in the
30
- system environment variable 'EDITOR' like this:
31
-
32
- export EDITOR="#{ENV['EDITOR']}"
33
-
34
- EOS
35
-
36
-
37
- # Setup the AI CLI program with necessary variables
38
- def setup_external_programs
39
- verify_external_tools
40
-
41
- ai_default_opts = "-m #{MODS_MODEL} --no-limit "
42
- ai_default_opts += "-f " if markdown?
43
- @ai_options = ai_default_opts.dup
44
-
45
-
46
- @ai_options += @extra_options.join(' ')
47
-
48
- @ai_command = "#{AI_CLI_PROGRAM} #{@ai_options} "
49
- end
50
-
51
-
52
- # Check if the external tools are present on the system
53
- def verify_external_tools
54
- missing_tools = []
55
-
56
- TOOLS.each do |tool, url|
57
- path = `which #{tool}`.chomp
58
- if path.empty? || !File.executable?(path)
59
- missing_tools << { name: tool, url: url }
60
- end
61
- end
62
-
63
- if missing_tools.any?
64
- puts format_missing_tools_response(missing_tools)
65
- end
66
- end
67
-
68
-
69
- def format_missing_tools_response(missing_tools)
70
- response = <<~EOS
71
-
72
- WARNING: #{MY_NAME} makes use of a few external CLI tools.
73
- #{MY_NAME} may not respond as designed without these.
74
-
75
- The following tools are missing on your system:
76
-
77
- EOS
78
-
79
- missing_tools.each do |tool|
80
- response << " #{tool[:name]}: install from #{tool[:url]}\n"
81
- end
82
-
83
- response
84
- end
85
-
86
-
87
- # Build the command to interact with the AI CLI program
88
- def build_command
89
- command = @ai_command + %Q["#{@prompt.to_s}"]
90
-
91
- @arguments.each do |input_file|
92
- file_path = Pathname.new(input_file)
93
- abort("File does not exist: #{input_file}") unless file_path.exist?
94
- command += " < #{input_file}"
95
- end
96
-
97
- command
98
- end
99
-
100
-
101
- # Execute the command and log the results
102
- def send_prompt_to_external_command
103
- command = build_command
104
-
105
- puts command if verbose?
106
- @result = `#{command}`
107
-
108
- if output.nil?
109
- puts @result
110
- else
111
- output.write @result
112
- end
113
-
114
- @result
115
- end
116
- end