aia 0.5.6 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '021416691c11252ce3462ee7ec394691e0a7d0fd81eb6df473df3447dd02da3b'
4
- data.tar.gz: 2bd5eb6bd2098c7e9bd04234a11c1192004bb217ec054aa9222334d9b96309d2
3
+ metadata.gz: 97bd3e1401d2883bca0d6ce3ab427a9fab12d3b71b2114a87fe278a0360f3693
4
+ data.tar.gz: 0333f04542cde2c853ccd00aff70e90b9d680960020f5187ab0b265916c24a27
5
5
  SHA512:
6
- metadata.gz: 0e2d78c3b6b1b8848645ef586c3b2f7a4557339504efc1a7434b12e313637e47b6803da8e5fa21908f88ee59046a372ef22553a5fdffe97d5777b65845f5ce41
7
- data.tar.gz: 142dd7b40622124089363670fcb6ffde02368ad07de7016e6c12e0511a47d89d8b0be9b153d31076758c321e6762e1d361fd4ac086b6f8ffca8d2a2abebeff7b
6
+ metadata.gz: 17395c59e8aabf7d4994236fd407beaf2231c6d05744af1fcd84ae588ad7ffcd4abd853096728ca50fb09976075b4ac920200e6732d7736d072e2d2a4071e7fb
7
+ data.tar.gz: f8f21824485408330c31fe99b6b77fd072e08486ccd4293df9f9a55fc464369081f901f0bf6bc8c818e2238ad17d63ce497f164cd9960967d0f55942558c55c8
data/.semver CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 6
4
+ :patch: 8
5
5
  :special: ''
6
6
  :metadata: ''
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.8] 2024-01-17
4
+ - Changed the behavior of the --dump option. It must now be followed by path/to/file.ext where ext is a supported config file format: yml, yaml, toml
5
+
6
+ ## [0.5.7] 2024-01-15
7
+ - Added ERB processing to the config_file
8
+
3
9
  ## [0.5.6] 2024-01-15
4
10
  - Adding processing for directives, shell integration and erb to the follow up prompt in a chat session
5
11
  - some code refactoring.
data/README.md CHANGED
@@ -5,6 +5,9 @@
5
5
  It leverages the `prompt_manager` gem to manage prompts for the `mods` and `sgpt` CLI utilities. It utilizes "ripgrep" for searching for prompt files. It uses `fzf` for prompt selection based on a search term and fuzzy matching.
6
6
 
7
7
  **Most Recent Change**: Refer to the [Changelog](CHANGELOG.md)
8
+ v0.5.7
9
+ - Added ERB processing to config files that have the pattern any_file.ext.erb where ext is the real extension of the file.
10
+
8
11
  v0.5.6
9
12
  - Directives within a chat session follow up are now available
10
13
  - when the `--shell` option is set access to envars and shell scripts are availabe in a chat session follow up prompt
@@ -121,7 +124,10 @@ OPTIONS
121
124
 
122
125
  --completion SHELL_NAME
123
126
 
124
- --dump FORMAT
127
+ --dump PATH/TO/FILE.ext
128
+ Dump the current configuration to a file in the format denoted by the file’s
129
+ extension. Currently only .yml, .yaml and .toml are acceptable file
130
+ extensions. If the file exists, it will be over-written without warning.
125
131
 
126
132
  -e, --edit
127
133
  Invokes an editor on the prompt file. You can make changes to the prompt file,
@@ -163,7 +169,10 @@ OPTIONS
163
169
  Specify the backend prompt resolver - default is mods
164
170
 
165
171
  -c, --config_file PATH_TO_CONFIG_FILE
166
- Load Config File - default is nil
172
+ Load Config File. both YAML and TOML formats are supported. Also ERB is
173
+ supported. For example ~/aia_config.yml.erb will be processed through ERB and
174
+ then through YAML. The result will be written out to ~/aia_config.yml so that
175
+ you can manually verify that you got what you wanted from the ERB processing.
167
176
 
168
177
  -d, --debug
169
178
  Turn On Debugging - default is false
@@ -240,8 +249,9 @@ USAGE NOTES
240
249
  bash, zsh, or fish shells. It’s crucial to integrate the script into the shell’s
241
250
  runtime to take effect.
242
251
 
243
- The --dump options will send the current configuration to STDOUT in the format
244
- requested. Both YAML and TOML formats are supported.
252
+ The --dump path/to/file.ext option will write the current configuration to a file in
253
+ the format requested by the file’s extension. The following extensions are supported:
254
+ .yml, .yaml and .toml
245
255
 
246
256
  PROMPT DIRECTIVES
247
257
  Within a prompt text file any line that begins with “//” is considered a prompt
@@ -317,7 +327,7 @@ The `aia` configuration defaults can be over-ridden by system environment variab
317
327
  | VERBOSE | FALSE | AIA_VERBOSE |
318
328
 
319
329
 
320
- See the `@options` hash in the `cli.rb` file for a complete list. There are some config items that do not necessarily make sense for use as an envar over-ride. For example if you set `export AIA_DUMP=yaml` then `aia` would dump a config file in YAML format and exit every time it is ran until you finally did `unset AIA_DUMP`
330
+ See the `@options` hash in the `cli.rb` file for a complete list. There are some config items that do not necessarily make sense for use as an envar over-ride. For example if you set `export AIA_DUMP_FILE=config.yaml` then `aia` would dump the current configuration config.yaml and exit every time it is ran until you finally `unset AIA_DUMP_FILE`
321
331
 
322
332
  In addition to these config items for `aia` the optional command line parameters for the backend prompt processing utilities (mods and sgpt) can also be set using envars with the "AIA_" prefix. For example "export AIA_TOPP=1.0" will set the "--topp 1.0" command line option for the `mods` utility when its used as the backend processor.
323
333
 
data/justfile CHANGED
@@ -116,7 +116,7 @@ module_git := "/Users/dewayne/just_modules/git.just"
116
116
 
117
117
 
118
118
  # Install Locally
119
- install: update_toc_in_readmen create_man_page test
119
+ install: update_toc_in_readmen create_man_page flay
120
120
  rake install
121
121
 
122
122
 
@@ -129,6 +129,15 @@ update_toc_in_readmen:
129
129
  preview_man_page:
130
130
  kramdown-man {{RR}}/man/aia.1.md
131
131
 
132
+ # Static Code Check
133
+ flay: coverage
134
+ flay {{RR}}
135
+
136
+
137
+ # View coverage report
138
+ coverage: test
139
+ open {{RR}}/coverage/index.html
140
+
132
141
 
133
142
  # Run Unit Tests
134
143
  test:
data/lib/aia/cli.rb CHANGED
@@ -97,7 +97,19 @@ class AIA::Cli
97
97
  end
98
98
 
99
99
 
100
+ def replace_erb_in_config_file
101
+ content = Pathname.new(AIA.config.config_file).read
102
+ content = ERB.new(content).result(binding)
103
+ AIA.config.config_file = AIA.config.config_file.to_s.gsub('.erb', '')
104
+ Pathname.new(AIA.config.config_file).write content
105
+ end
106
+
107
+
100
108
  def load_config_file
109
+ if AIA.config.config_file.to_s.end_with?(".erb")
110
+ replace_erb_in_config_file
111
+ end
112
+
101
113
  AIA.config.config_file = Pathname.new(AIA.config.config_file)
102
114
  if AIA.config.config_file.exist?
103
115
  AIA.config.merge! parse_config_file
@@ -122,7 +134,7 @@ class AIA::Cli
122
134
  #
123
135
  model: ["gpt-4-1106-preview", "--llm --model"],
124
136
  #
125
- dump: [nil, "--dump"],
137
+ dump_file: [nil, "--dump"],
126
138
  completion: [nil, "--completion"],
127
139
  #
128
140
  chat?: [false, "--chat"],
@@ -161,7 +173,7 @@ class AIA::Cli
161
173
  def execute_immediate_commands
162
174
  show_usage if AIA.config.help?
163
175
  show_version if AIA.config.version?
164
- dump_config_file if AIA.config.dump
176
+ dump_config_file if AIA.config.dump_file
165
177
  show_completion if AIA.config.completion
166
178
  end
167
179
 
@@ -169,13 +181,16 @@ class AIA::Cli
169
181
  def dump_config_file
170
182
  a_hash = prepare_config_as_hash
171
183
 
172
- case AIA.config.dump.downcase
173
- when 'yml', 'yaml'
174
- puts YAML.dump(a_hash)
175
- when 'toml'
176
- puts TomlRB.dump(a_hash)
184
+ dump_file = Pathname.new AIA.config.dump_file
185
+ extname = dump_file.extname.to_s.downcase
186
+
187
+ case extname
188
+ when '.yml', '.yaml'
189
+ dump_file.write YAML.dump(a_hash)
190
+ when '.toml'
191
+ dump_file.write TomlRB.dump(a_hash)
177
192
  else
178
- abort "Invalid config file format request. Only #{CF_FORMATS.join(', ')} are supported."
193
+ abort "Invalid config file format (#{extname}) request. Only #{CF_FORMATS.join(', ')} are supported."
179
194
  end
180
195
 
181
196
  exit
@@ -188,9 +203,10 @@ class AIA::Cli
188
203
  a_hash = AIA.config.to_h
189
204
  a_hash['dump'] = nil
190
205
 
191
- a_hash.delete('arguments')
192
- a_hash.delete('config_file')
193
-
206
+ %w[ arguments config_file dump_file ].each do |unwanted_key|
207
+ a_hash.delete(unwanted_key)
208
+ end
209
+
194
210
  a_hash
195
211
  end
196
212
 
@@ -240,8 +256,14 @@ class AIA::Cli
240
256
  AIA.config[option_sym] = switch.include?('out_file') ? STDOUT : nil
241
257
  arguments.slice!(index,1)
242
258
  else
243
- AIA.config[option_sym] = arguments[index + 1]
244
- arguments.slice!(index,2)
259
+ value = arguments[index + 1]
260
+ if value.nil? || value.start_with?('-')
261
+ STDERR.puts "ERROR: #{option_sym} requires a parameter value"
262
+ exit(1)
263
+ else
264
+ AIA.config[option_sym] = value
265
+ arguments.slice!(index,2)
266
+ end
245
267
  end
246
268
  end
247
269
 
@@ -337,4 +359,3 @@ class AIA::Cli
337
359
  end
338
360
  end
339
361
  end
340
-
data/lib/aia/logging.rb CHANGED
@@ -13,6 +13,9 @@ class AIA::Logging
13
13
  'a' # append to existing file
14
14
  )
15
15
  else
16
+ # SMELL: Looks like you get logging whether you want it or not
17
+ # TODO: when path is nil create a fake logger
18
+ # that does nothing
16
19
  Logger.new(STDOUT) # Fall back to standard output if path is nil or invalid
17
20
  end
18
21
 
data/lib/aia/main.rb CHANGED
@@ -9,13 +9,15 @@ require_relative 'dynamic_content'
9
9
  require_relative 'prompt'
10
10
  require_relative 'logging'
11
11
  require_relative 'tools'
12
+ require_relative 'user_query'
12
13
 
13
14
  # Everything is being handled within the context
14
15
  # of a single class.
15
16
 
16
17
  class AIA::Main
17
18
  include AIA::DynamicContent
18
-
19
+ include AIA::UserQuery
20
+
19
21
  attr_accessor :logger, :tools, :backend
20
22
 
21
23
  def initialize(args= ARGV)
@@ -44,9 +46,13 @@ class AIA::Main
44
46
 
45
47
 
46
48
  def speak(what)
47
- return unless AIA.config.speak?
49
+ return false unless AIA.config.speak?
50
+ # TODO: Consider putting this into a thread
51
+ # so that it can speak at the same time
52
+ # the output is going to the screen
48
53
  # MacOS uses the say command
49
54
  system "say #{Shellwords.escape(what)}"
55
+ true
50
56
  end
51
57
 
52
58
 
@@ -57,22 +63,6 @@ class AIA::Main
57
63
  end
58
64
 
59
65
 
60
- # Function to prompt the user with a question using reline
61
- def ask_question_with_reline(prompt)
62
- if prompt.start_with?("\n")
63
- puts
64
- puts
65
- prompt = prompt[1..]
66
- end
67
-
68
- answer = Reline.readline(prompt)
69
- Reline::HISTORY.push(answer) unless answer.nil? || Reline::HISTORY.to_a.include?(answer)
70
- answer
71
- rescue Interrupt
72
- ''
73
- end
74
-
75
-
76
66
  def call
77
67
  @directives_processor.execute_my_directives
78
68
 
data/lib/aia/prompt.rb CHANGED
@@ -3,10 +3,12 @@
3
3
  require 'reline'
4
4
 
5
5
  require_relative 'dynamic_content'
6
+ require_relative 'user_query'
6
7
 
7
8
  class AIA::Prompt
8
9
  include AIA::DynamicContent
9
-
10
+ include AIA::UserQuery
11
+
10
12
  #
11
13
  # used when no prompt_id is provided but there
12
14
  # are extra parameters that need to be passed
@@ -134,22 +136,6 @@ class AIA::Prompt
134
136
  end
135
137
 
136
138
 
137
- # Function to prompt the user with a question using reline
138
- def ask_question_with_reline(prompt)
139
- if prompt.start_with?("\n")
140
- puts
141
- puts
142
- prompt = prompt[1..]
143
- end
144
-
145
- answer = Reline.readline(prompt)
146
- Reline::HISTORY.push(answer) unless answer.nil? || Reline::HISTORY.to_a.include?(answer)
147
- answer
148
- rescue Interrupt
149
- ''
150
- end
151
-
152
-
153
139
  # query the user for a value to the keyword allow the
154
140
  # reuse of the previous value shown as the default
155
141
  #
@@ -0,0 +1,21 @@
1
+ # aia/lia/aia/user_query.rb
2
+
3
+ require 'reline'
4
+
5
+ module AIA::UserQuery
6
+
7
+ # Function to prompt the user with a question using reline
8
+ def ask_question_with_reline(prompt)
9
+ if prompt.start_with?("\n")
10
+ puts
11
+ puts
12
+ prompt = prompt[1..]
13
+ end
14
+
15
+ answer = Reline.readline(prompt)
16
+ Reline::HISTORY.push(answer) unless answer.nil? || Reline::HISTORY.to_a.include?(answer)
17
+ answer
18
+ rescue Interrupt
19
+ ''
20
+ end
21
+ end
data/main.just CHANGED
@@ -18,7 +18,7 @@ module git /Users/dewayne/just_modules/git.just
18
18
 
19
19
 
20
20
  # Install Locally
21
- install: update_toc_in_readmen create_man_page test
21
+ install: update_toc_in_readmen create_man_page flay
22
22
  rake install
23
23
 
24
24
 
@@ -31,6 +31,15 @@ update_toc_in_readmen:
31
31
  preview_man_page:
32
32
  kramdown-man {{RR}}/man/aia.1.md
33
33
 
34
+ # Static Code Check
35
+ flay: coverage
36
+ flay {{RR}}
37
+
38
+
39
+ # View coverage report
40
+ coverage: test
41
+ open {{RR}}/coverage/index.html
42
+
34
43
 
35
44
  # Run Unit Tests
36
45
  test:
data/man/aia.1 CHANGED
@@ -27,7 +27,8 @@ begin a chat session with the backend after the initial prompt response; will s
27
27
  .TP
28
28
  \fB\-\-completion\fR \fISHELL\[ru]NAME\fP
29
29
  .TP
30
- \fB\-\-dump\fR \fIFORMAT\fP
30
+ \fB\-\-dump\fR \fIPATH\[sl]TO\[sl]FILE\.ext\fP
31
+ Dump the current configuration to a file in the format denoted by the file\[cq]s extension\. Currently only \.yml, \.yaml and \.toml are acceptable file extensions\. \fIIf the file exists, it will be over\-written without warning\.\fP
31
32
  .TP
32
33
  \fB\-e\fR, \fB\-\-edit\fR
33
34
  Invokes an editor on the prompt file\. You can make changes to the prompt file, save it and the newly saved prompt will be processed by the backend\.
@@ -57,7 +58,7 @@ Print Version \- default is false
57
58
  Specify the backend prompt resolver \- default is mods
58
59
  .TP
59
60
  \fB\-c\fR, \fB\-\-config\[ru]file\fR \fIPATH\[ru]TO\[ru]CONFIG\[ru]FILE\fP
60
- Load Config File \- default is nil
61
+ Load Config File\. both YAML and TOML formats are supported\. Also ERB is supported\. For example \[ti]\[sl]aia\[ru]config\.yml\.erb will be processed through ERB and then through YAML\. The result will be written out to \[ti]\[sl]aia\[ru]config\.yml so that you can manually verify that you got what you wanted from the ERB processing\.
61
62
  .TP
62
63
  \fB\-d\fR, \fB\-\-debug\fR
63
64
  Turn On Debugging \- default is false
@@ -116,7 +117,7 @@ To acquire an OpenAI access key, first create an account on the OpenAI platform,
116
117
  .PP
117
118
  The \fB\-\-completion\fR option displays a script that enables prompt ID auto\-completion for bash, zsh, or fish shells\. It\[cq]s crucial to integrate the script into the shell\[cq]s runtime to take effect\.
118
119
  .PP
119
- The \fB\-\-dump\fR options will send the current configuration to STDOUT in the format requested\. Both YAML and TOML formats are supported\.
120
+ The \fB\-\-dump path\[sl]to\[sl]file\.ext\fR option will write the current configuration to a file in the format requested by the file\[cq]s extension\. The following extensions are supported: \.yml, \.yaml and \.toml
120
121
  .SH PROMPT DIRECTIVES
121
122
  .PP
122
123
  Within a prompt text file any line that begins with \[lq]\[sl]\[sl]\[rq] is considered a prompt directive\. There are numerious prompt directives available\. In the discussion above on the configuration you learned about the \[lq]\[sl]\[sl]config\[rq] directive\.
data/man/aia.1.md CHANGED
@@ -31,8 +31,8 @@ The aia command-line tool is an interface for interacting with an AI model backe
31
31
  `--completion` *SHELL_NAME*
32
32
  : Show completion script for bash|zsh|fish - default is nil
33
33
 
34
- `--dump` *FORMAT*
35
- : Dump a Config File in [yaml | toml] to STDOUT - default is nil
34
+ `--dump` *PATH/TO/FILE.ext*
35
+ : Dump the current configuration to a file in the format denoted by the file's extension. Currently only .yml, .yaml and .toml are acceptable file extensions. *If the file exists, it will be over-written without warning.*
36
36
 
37
37
  `-e`, `--edit`
38
38
  : Invokes an editor on the prompt file. You can make changes to the prompt file, save it and the newly saved prompt will be processed by the backend.
@@ -62,7 +62,7 @@ The aia command-line tool is an interface for interacting with an AI model backe
62
62
  : Specify the backend prompt resolver - default is mods
63
63
 
64
64
  `-c`, `--config_file` *PATH_TO_CONFIG_FILE*
65
- : Load Config File - default is nil
65
+ : Load Config File. both YAML and TOML formats are supported. Also ERB is supported. For example ~/aia_config.yml.erb will be processed through ERB and then through YAML. The result will be written out to ~/aia_config.yml so that you can manually verify that you got what you wanted from the ERB processing.
66
66
 
67
67
  `-d`, `--debug`
68
68
  : Turn On Debugging - default is false
@@ -122,7 +122,8 @@ To acquire an OpenAI access key, first create an account on the OpenAI platform,
122
122
 
123
123
  The `--completion` option displays a script that enables prompt ID auto-completion for bash, zsh, or fish shells. It's crucial to integrate the script into the shell's runtime to take effect.
124
124
 
125
- The `--dump` options will send the current configuration to STDOUT in the format requested. Both YAML and TOML formats are supported.
125
+ The `--dump path/to/file.ext` option will write the current configuration to a file in the format requested by the file's extension. The following extensions are supported: .yml, .yaml and .toml
126
+
126
127
 
127
128
  ## PROMPT DIRECTIVES
128
129
 
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.5.6
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-15 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: tocer
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +255,7 @@ files:
241
255
  - lib/aia/tools/sgpt.rb
242
256
  - lib/aia/tools/subl.rb
243
257
  - lib/aia/tools/vim.rb
258
+ - lib/aia/user_query.rb
244
259
  - lib/aia/version.rb
245
260
  - lib/core_ext/string_wrap.rb
246
261
  - main.just