aia 0.3.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aia/aia_completion.bash +39 -0
- data/lib/aia/aia_completion.fish +34 -0
- data/lib/aia/aia_completion.zsh +39 -0
- data/lib/aia/cli.rb +48 -4
- data/lib/aia/configuration.rb +0 -5
- data/lib/aia/version.rb +1 -1
- metadata +5 -5
- data/bin/aia_completion.sh +0 -37
- data/lib/aia/external/temp.md +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d2d934f517983c9854654eeb01d9b5ca6a08c92cb531b315a8b223e6e2ffd23
|
4
|
+
data.tar.gz: cd5ac0f18c2a290205c717c2d9e1e2e43ffe0a51f5aac400d3a1fce6137db4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c859d26173c65d577cd9a49c4333f5c104d69b37205523a1f2249f284de38e1af06ec1870cea9774858e9688eb67639135fe2500b3550693f33ba621eada79
|
7
|
+
data.tar.gz: 808e69fc41eaba3396ebfb7157063e43709034a5009fcc06fb01c0055a2b371ef128962bea32a2cae8efc0e8ee0b8d8aeb5f4f180e5e4754176bfc70fecf17a0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# lib/aia/aia_completion.bash
|
2
|
+
# Setup a prompt completion for use with
|
3
|
+
# the bash shell
|
4
|
+
#
|
5
|
+
# This script assumes that the system environment
|
6
|
+
# variable PROMPTS_DIR has been set correctly
|
7
|
+
|
8
|
+
_aia_completion() {
|
9
|
+
# The current word being completed
|
10
|
+
local cur_word="${COMP_WORDS[COMP_CWORD]}"
|
11
|
+
|
12
|
+
# The previous word before the current word
|
13
|
+
local prev_word="${COMP_WORDS[COMP_CWORD-1]}"
|
14
|
+
|
15
|
+
# Store the previous directory to return to it later
|
16
|
+
local initial_pwd=$(pwd)
|
17
|
+
|
18
|
+
# Check if we are currently completing the option that requires prompt IDs
|
19
|
+
if [[ "$prev_word" == "aia" ]]; then
|
20
|
+
# Change directory to the prompts directory
|
21
|
+
cd "$PROMPTS_DIR" || return
|
22
|
+
|
23
|
+
# Generate a list of relative paths from the ~/.prompts directory (without .txt extension)
|
24
|
+
local files=($(find . -name "*.txt" -type f | sed 's|^\./||' | sed 's/\.txt$//'))
|
25
|
+
|
26
|
+
# Change back to the initial directory
|
27
|
+
cd "$initial_pwd" || return
|
28
|
+
|
29
|
+
# Generate possible matches and store them in the COMPREPLY array
|
30
|
+
COMPREPLY=($(compgen -W "${files[*]}" -- "$cur_word"))
|
31
|
+
else
|
32
|
+
# If not the specific option, perform regular file completion
|
33
|
+
COMPREPLY=($(compgen -o default -- "$cur_word"))
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# Register the completion function for the aia command
|
38
|
+
complete -F _aia_completion aia
|
39
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# lib/aia/aia_completion.fish
|
2
|
+
# Setup a prompt completion for use with the fish shell
|
3
|
+
#
|
4
|
+
# This script assumes that the system environment
|
5
|
+
# variable PROMPTS_DIR has been set correctly
|
6
|
+
|
7
|
+
function __fish_aia_complete
|
8
|
+
# Get the command line and current token
|
9
|
+
set -l cmd_line (commandline -opc)
|
10
|
+
set -l current_token (commandline -ct)
|
11
|
+
|
12
|
+
# Check if we are currently completing the option that requires prompt IDs
|
13
|
+
if set -q cmd_line[2]
|
14
|
+
# Change directory to the prompts directory
|
15
|
+
if test -d $PROMPTS_DIR
|
16
|
+
pushd $PROMPTS_DIR
|
17
|
+
# Generate completions based on .txt files in the PROMPTS_DIR directory
|
18
|
+
for file in (find . -name "*.txt" -type f)
|
19
|
+
set file (string replace -r '\.txt$' '' -- $file)
|
20
|
+
set file (string replace -r '^\./' '' -- $file)
|
21
|
+
printf "%s\n" $file
|
22
|
+
end
|
23
|
+
popd
|
24
|
+
end
|
25
|
+
else
|
26
|
+
# Use the default file completion if we are not completing a prompt ID
|
27
|
+
complete -f -c aia -a "(commandline -ct)"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Register the completion function for the aia command
|
32
|
+
complete -c aia -a '(__fish_aia_complete)' -f
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# lib/aia/aia_completion.zsh
|
2
|
+
# Setup a prompt completion for use with
|
3
|
+
# the zsh shell
|
4
|
+
#
|
5
|
+
# This script assumes that the system environment
|
6
|
+
# variable PROMPTS_DIR has been set correctly
|
7
|
+
|
8
|
+
_aia_completion() {
|
9
|
+
# The current word being completed
|
10
|
+
local cur_word="$words[$CURRENT]"
|
11
|
+
|
12
|
+
# The previous word before the current word
|
13
|
+
local prev_word="$words[$CURRENT-1]"
|
14
|
+
|
15
|
+
# Store the previous directory to return to it later
|
16
|
+
local initial_pwd=$PWD
|
17
|
+
|
18
|
+
# Check if we are currently completing the option that requires prompt IDs
|
19
|
+
if [[ "$prev_word" == "aia" ]]; then
|
20
|
+
# Change directory to the prompts directory
|
21
|
+
cd "$PROMPTS_DIR" || return
|
22
|
+
|
23
|
+
# Generate a list of relative paths from the ~/.prompts directory (without .txt extension)
|
24
|
+
local files=($(find . -name "*.txt" -type f | sed 's|^\./||' | sed 's/\.txt$//'))
|
25
|
+
|
26
|
+
# Change back to the initial directory
|
27
|
+
cd "$initial_pwd" || return
|
28
|
+
|
29
|
+
# Generate possible matches and store them in an array
|
30
|
+
_describe 'prompt ID' files
|
31
|
+
else
|
32
|
+
# If not the specific option, use the standard filename completion
|
33
|
+
_files
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# Register the completion function for the aia command using compctl
|
38
|
+
compctl -K _aia_completion aia
|
39
|
+
|
data/lib/aia/cli.rb
CHANGED
@@ -12,6 +12,7 @@ module AIA::Cli
|
|
12
12
|
version?: [false, "--version", "Print Version"],
|
13
13
|
help?: [false, "-h --help", "Show Usage"],
|
14
14
|
fuzzy?: [false, "--fuzzy", "Use Fuzzy Matching"],
|
15
|
+
completion: [nil, "--completion", "Show completion script for bash|zsh|fish"],
|
15
16
|
# TODO: Consider dropping output in favor of always
|
16
17
|
# going to STDOUT so user can redirect or pipe somewhere else
|
17
18
|
output: [OUTPUT,"-o --output --no-output", "Out FILENAME"],
|
@@ -32,8 +33,9 @@ module AIA::Cli
|
|
32
33
|
usage = "\n#{MY_NAME} v#{AIA::VERSION}\n\n"
|
33
34
|
usage += "Usage: #{MY_NAME} [options] prompt_id [context_file]* [-- external_options+]\n\n"
|
34
35
|
usage += usage_options
|
35
|
-
usage +=
|
36
|
-
usage +=
|
36
|
+
usage += usage_options_details
|
37
|
+
usage += "\n"
|
38
|
+
usage += usage_notes if verbose?
|
37
39
|
|
38
40
|
usage
|
39
41
|
end
|
@@ -63,10 +65,30 @@ module AIA::Cli
|
|
63
65
|
end
|
64
66
|
|
65
67
|
|
68
|
+
def usage_options_details
|
69
|
+
<<~EOS
|
70
|
+
|
71
|
+
Details
|
72
|
+
-------
|
73
|
+
|
74
|
+
Use (--help --verbose) or (-h -v) for verbose usage text.
|
75
|
+
|
76
|
+
Use --completion bash|zsh|fish to show a script
|
77
|
+
that will add prompt ID completion to your desired shell.
|
78
|
+
You must copy the output from this option into a
|
79
|
+
place where the function will be executed for
|
80
|
+
your shell.
|
81
|
+
|
82
|
+
EOS
|
83
|
+
end
|
84
|
+
|
85
|
+
|
66
86
|
def usage_notes
|
67
87
|
<<~EOS
|
88
|
+
|
68
89
|
#{usage_envars}
|
69
|
-
#{AIA::
|
90
|
+
#{AIA::External::HELP}
|
91
|
+
|
70
92
|
EOS
|
71
93
|
end
|
72
94
|
|
@@ -117,6 +139,8 @@ module AIA::Cli
|
|
117
139
|
check_for option
|
118
140
|
end
|
119
141
|
|
142
|
+
show_completion unless @options[:completion].nil?
|
143
|
+
|
120
144
|
# get the options meant for the backend AI command
|
121
145
|
extract_extra_options
|
122
146
|
|
@@ -163,7 +187,6 @@ module AIA::Cli
|
|
163
187
|
end
|
164
188
|
|
165
189
|
|
166
|
-
|
167
190
|
def show_usage
|
168
191
|
@options[:help?][0] = false
|
169
192
|
puts usage
|
@@ -172,6 +195,27 @@ module AIA::Cli
|
|
172
195
|
alias_method :show_help, :show_usage
|
173
196
|
|
174
197
|
|
198
|
+
def show_completion
|
199
|
+
shell = @options[:completion].first
|
200
|
+
script = Pathname.new(__dir__) + "aia_completion.#{shell}"
|
201
|
+
|
202
|
+
if script.exist?
|
203
|
+
puts
|
204
|
+
puts script.read
|
205
|
+
puts
|
206
|
+
else
|
207
|
+
STDERR.puts <<~EOS
|
208
|
+
|
209
|
+
ERRORL The shell '#{shell}' is not supported.
|
210
|
+
|
211
|
+
EOS
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
exit
|
216
|
+
end
|
217
|
+
|
218
|
+
|
175
219
|
def show_version
|
176
220
|
puts AIA::VERSION
|
177
221
|
exit
|
data/lib/aia/configuration.rb
CHANGED
data/lib/aia/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
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
|
+
date: 2023-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prompt_manager
|
@@ -90,7 +90,6 @@ email:
|
|
90
90
|
- dvanhoozer@gmail.com
|
91
91
|
executables:
|
92
92
|
- aia
|
93
|
-
- aia_completion.sh
|
94
93
|
extensions: []
|
95
94
|
extra_rdoc_files: []
|
96
95
|
files:
|
@@ -101,8 +100,10 @@ files:
|
|
101
100
|
- README.md
|
102
101
|
- Rakefile
|
103
102
|
- bin/aia
|
104
|
-
- bin/aia_completion.sh
|
105
103
|
- lib/aia.rb
|
104
|
+
- lib/aia/aia_completion.bash
|
105
|
+
- lib/aia/aia_completion.fish
|
106
|
+
- lib/aia/aia_completion.zsh
|
106
107
|
- lib/aia/cli.rb
|
107
108
|
- lib/aia/configuration.rb
|
108
109
|
- lib/aia/external.rb
|
@@ -116,7 +117,6 @@ files:
|
|
116
117
|
- lib/aia/external/rg.rb
|
117
118
|
- lib/aia/external/sgpt.rb
|
118
119
|
- lib/aia/external/subl.rb
|
119
|
-
- lib/aia/external/temp.md
|
120
120
|
- lib/aia/external/tool.rb
|
121
121
|
- lib/aia/external_two.rb
|
122
122
|
- lib/aia/logging.rb
|
data/bin/aia_completion.sh
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# bin/aia_completion.sh
|
2
|
-
# Setup a prompt completion for use with
|
3
|
-
# aia (a Ruby program) AI Assistant
|
4
|
-
#
|
5
|
-
|
6
|
-
if [ -z "$PROMPTS_DIR" ]; then
|
7
|
-
echo "Error: PROMPTS_DIR environment variable is not set"
|
8
|
-
exit 1
|
9
|
-
fi
|
10
|
-
|
11
|
-
# SMELL: Is this BASH-only or will it work with other shells?
|
12
|
-
|
13
|
-
# Function to generate prompt completions for aia
|
14
|
-
|
15
|
-
_aia_completion() {
|
16
|
-
# The current word being completed
|
17
|
-
local cur_word="${COMP_WORDS[COMP_CWORD]}"
|
18
|
-
|
19
|
-
# Store the previous directory to return to it later
|
20
|
-
local initial_pwd=$(pwd)
|
21
|
-
|
22
|
-
# Change directory to the prompts directory
|
23
|
-
cd $PROMPTS_DIR
|
24
|
-
|
25
|
-
# Generate a list of relative paths from the ~/.prompts directory (without .txt extension)
|
26
|
-
local files=($(find . -name "*.txt" -type f | sed 's|^\./||' | sed 's/\.txt$//'))
|
27
|
-
|
28
|
-
# Change back to the initial directory
|
29
|
-
cd "$initial_pwd"
|
30
|
-
|
31
|
-
# Generate possible matches and store them in the COMPREPLY array
|
32
|
-
COMPREPLY=($(compgen -W "${files[*]}" -- "$cur_word"))
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
# Register the completion function for the aip command
|
37
|
-
complete -F _aia_completion aia
|
data/lib/aia/external/temp.md
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
If you want to find out which classes have inherited from a class named `Tool`, you can leverage Ruby's `ObjectSpace` module to iterate through all the classes and select those that are descendants of `Tool`. Here's how you could write the code:
|
2
|
-
|
3
|
-
```ruby
|
4
|
-
class Tool
|
5
|
-
# Tool class implementation
|
6
|
-
end
|
7
|
-
|
8
|
-
# Other classes that inherit from Tool
|
9
|
-
class Hammer < Tool; end
|
10
|
-
class Screwdriver < Tool; end
|
11
|
-
class Wrench < Tool; end
|
12
|
-
|
13
|
-
# Non-inheriting classes
|
14
|
-
class RandomClass; end
|
15
|
-
|
16
|
-
def find_descendants_of(klass)
|
17
|
-
ObjectSpace.each_object(Class).select { |c| c < klass }.map(&:name)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Get the list of class names that inherit from Tool
|
21
|
-
descendant_classes = find_descendants_of(Tool)
|
22
|
-
|
23
|
-
# Format the list as markdown (as required)
|
24
|
-
markdown_list = descendant_classes.map { |name| "- #{name}" }.join("\n")
|
25
|
-
puts markdown_list
|
26
|
-
```
|
27
|
-
|
28
|
-
When you run this code, you will get an output similar to the following (the actual order may vary):
|
29
|
-
|
30
|
-
```
|
31
|
-
- Hammer
|
32
|
-
- Screwdriver
|
33
|
-
- Wrench
|
34
|
-
```
|
35
|
-
|
36
|
-
This list shows the class names that have inherited from the `Tool` class, and it is formatted as a markdown list without enclosing backticks as requested.
|
37
|
-
|