aia 0.5.7 → 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: 63be1bf9f76bf377e09bd05cefc15651c05372863f411c343849d5a68d40a4d8
4
- data.tar.gz: c979390da7d47566026c89590c283dda30c7cc9a4778242acf131d8a241b58ba
3
+ metadata.gz: 97bd3e1401d2883bca0d6ce3ab427a9fab12d3b71b2114a87fe278a0360f3693
4
+ data.tar.gz: 0333f04542cde2c853ccd00aff70e90b9d680960020f5187ab0b265916c24a27
5
5
  SHA512:
6
- metadata.gz: ceb70944b23cfe72c06fd3aa62bc377cfa95122238c75cc68906ac6f3117de1d2e9809064343b642016d729dc6cdc8af55706db292858231d0777ad7508d61d0
7
- data.tar.gz: c1eb7647759e8c0dd9429df75ac4943e7399887e1ef0ffb3ccbc2d9f716a33d114e836c00957ebd6c192515fe4d7a2db336c4e9aa36fc84c446b06da3b1641b9
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: 7
4
+ :patch: 8
5
5
  :special: ''
6
6
  :metadata: ''
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ## [Unreleased]
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
+
2
6
  ## [0.5.7] 2024-01-15
3
7
  - Added ERB processing to the config_file
4
8
 
data/README.md CHANGED
@@ -124,7 +124,10 @@ OPTIONS
124
124
 
125
125
  --completion SHELL_NAME
126
126
 
127
- --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.
128
131
 
129
132
  -e, --edit
130
133
  Invokes an editor on the prompt file. You can make changes to the prompt file,
@@ -246,8 +249,9 @@ USAGE NOTES
246
249
  bash, zsh, or fish shells. It’s crucial to integrate the script into the shell’s
247
250
  runtime to take effect.
248
251
 
249
- The --dump options will send the current configuration to STDOUT in the format
250
- 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
251
255
 
252
256
  PROMPT DIRECTIVES
253
257
  Within a prompt text file any line that begins with “//” is considered a prompt
@@ -323,7 +327,7 @@ The `aia` configuration defaults can be over-ridden by system environment variab
323
327
  | VERBOSE | FALSE | AIA_VERBOSE |
324
328
 
325
329
 
326
- 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`
327
331
 
328
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.
329
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
@@ -134,7 +134,7 @@ class AIA::Cli
134
134
  #
135
135
  model: ["gpt-4-1106-preview", "--llm --model"],
136
136
  #
137
- dump: [nil, "--dump"],
137
+ dump_file: [nil, "--dump"],
138
138
  completion: [nil, "--completion"],
139
139
  #
140
140
  chat?: [false, "--chat"],
@@ -173,7 +173,7 @@ class AIA::Cli
173
173
  def execute_immediate_commands
174
174
  show_usage if AIA.config.help?
175
175
  show_version if AIA.config.version?
176
- dump_config_file if AIA.config.dump
176
+ dump_config_file if AIA.config.dump_file
177
177
  show_completion if AIA.config.completion
178
178
  end
179
179
 
@@ -181,13 +181,16 @@ class AIA::Cli
181
181
  def dump_config_file
182
182
  a_hash = prepare_config_as_hash
183
183
 
184
- case AIA.config.dump.downcase
185
- when 'yml', 'yaml'
186
- puts YAML.dump(a_hash)
187
- when 'toml'
188
- 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)
189
192
  else
190
- 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."
191
194
  end
192
195
 
193
196
  exit
@@ -200,9 +203,10 @@ class AIA::Cli
200
203
  a_hash = AIA.config.to_h
201
204
  a_hash['dump'] = nil
202
205
 
203
- a_hash.delete('arguments')
204
- a_hash.delete('config_file')
205
-
206
+ %w[ arguments config_file dump_file ].each do |unwanted_key|
207
+ a_hash.delete(unwanted_key)
208
+ end
209
+
206
210
  a_hash
207
211
  end
208
212
 
@@ -252,8 +256,14 @@ class AIA::Cli
252
256
  AIA.config[option_sym] = switch.include?('out_file') ? STDOUT : nil
253
257
  arguments.slice!(index,1)
254
258
  else
255
- AIA.config[option_sym] = arguments[index + 1]
256
- 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
257
267
  end
258
268
  end
259
269
 
@@ -349,4 +359,3 @@ class AIA::Cli
349
359
  end
350
360
  end
351
361
  end
352
-
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\.
@@ -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.
@@ -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.7
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-16 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