aia 0.0.5 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +24 -2
- 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 +45 -31
- data/lib/aia/configuration.rb +0 -5
- data/lib/aia/external/,keep +0 -0
- data/lib/aia/external/.irbrc +11 -0
- data/lib/aia/external/ag.rb +103 -0
- data/lib/aia/external/bat.rb +189 -0
- data/lib/aia/external/fzf.rb +147 -0
- data/lib/aia/external/glow.rb +37 -0
- data/lib/aia/external/mods.rb +57 -0
- data/lib/aia/external/rg.rb +1163 -0
- data/lib/aia/external/sgpt.rb +58 -0
- data/lib/aia/external/subl.rb +47 -0
- data/lib/aia/external/tool.rb +73 -0
- data/lib/aia/external.rb +259 -0
- data/lib/aia/external_two.rb +43 -0
- data/lib/aia/main.rb +2 -2
- data/lib/aia/prompt_processing.rb +67 -13
- data/lib/aia/version.rb +1 -1
- metadata +18 -5
- data/bin/aia_completion.sh +0 -37
- data/lib/aia/external_commands.rb +0 -116
@@ -0,0 +1,147 @@
|
|
1
|
+
# lib/aia/external/fzf.rb
|
2
|
+
|
3
|
+
class AIA::External::Fzf < AIA::External::Tool
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
@role = :selecter
|
7
|
+
@desc = 'Command-line fuzzy finder written in Go'
|
8
|
+
@url = 'https://github.com/junegunn/fzf'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def command(options = {})
|
13
|
+
cd_command = "cd #{options[:prompt_dir]}"
|
14
|
+
find_command = "find . -name '*.txt'"
|
15
|
+
fzf_options = build_fzf_options(options[:fuzzy])
|
16
|
+
"#{cd_command} ; #{find_command} | fzf #{fzf_options}"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def build_fzf_options(fuzzy)
|
22
|
+
[
|
23
|
+
"--tabstop=2",
|
24
|
+
"--header='Prompt contents below'",
|
25
|
+
"--header-first",
|
26
|
+
"--prompt='Search term: '",
|
27
|
+
'--delimiter :',
|
28
|
+
"--preview 'ww {1}'", # 'ww' from word_wrap gem
|
29
|
+
"--preview-window=down:50%:wrap"
|
30
|
+
].tap { |opts| opts << "--exact" unless fuzzy }.join(' ')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
__END__
|
35
|
+
|
36
|
+
usage: fzf [options]
|
37
|
+
|
38
|
+
Search
|
39
|
+
-x, --extended Extended-search mode
|
40
|
+
(enabled by default; +x or --no-extended to disable)
|
41
|
+
-e, --exact Enable Exact-match
|
42
|
+
-i Case-insensitive match (default: smart-case match)
|
43
|
+
+i Case-sensitive match
|
44
|
+
--scheme=SCHEME Scoring scheme [default|path|history]
|
45
|
+
--literal Do not normalize latin script letters before matching
|
46
|
+
-n, --nth=N[,..] Comma-separated list of field index expressions
|
47
|
+
for limiting search scope. Each can be a non-zero
|
48
|
+
integer or a range expression ([BEGIN]..[END]).
|
49
|
+
--with-nth=N[,..] Transform the presentation of each line using
|
50
|
+
field index expressions
|
51
|
+
-d, --delimiter=STR Field delimiter regex (default: AWK-style)
|
52
|
+
+s, --no-sort Do not sort the result
|
53
|
+
--track Track the current selection when the result is updated
|
54
|
+
--tac Reverse the order of the input
|
55
|
+
--disabled Do not perform search
|
56
|
+
--tiebreak=CRI[,..] Comma-separated list of sort criteria to apply
|
57
|
+
when the scores are tied [length|chunk|begin|end|index]
|
58
|
+
(default: length)
|
59
|
+
|
60
|
+
Interface
|
61
|
+
-m, --multi[=MAX] Enable multi-select with tab/shift-tab
|
62
|
+
--no-mouse Disable mouse
|
63
|
+
--bind=KEYBINDS Custom key bindings. Refer to the man page.
|
64
|
+
--cycle Enable cyclic scroll
|
65
|
+
--keep-right Keep the right end of the line visible on overflow
|
66
|
+
--scroll-off=LINES Number of screen lines to keep above or below when
|
67
|
+
scrolling to the top or to the bottom (default: 0)
|
68
|
+
--no-hscroll Disable horizontal scroll
|
69
|
+
--hscroll-off=COLS Number of screen columns to keep to the right of the
|
70
|
+
highlighted substring (default: 10)
|
71
|
+
--filepath-word Make word-wise movements respect path separators
|
72
|
+
--jump-labels=CHARS Label characters for jump and jump-accept
|
73
|
+
|
74
|
+
Layout
|
75
|
+
--height=[~]HEIGHT[%] Display fzf window below the cursor with the given
|
76
|
+
height instead of using fullscreen.
|
77
|
+
If prefixed with '~', fzf will determine the height
|
78
|
+
according to the input size.
|
79
|
+
--min-height=HEIGHT Minimum height when --height is given in percent
|
80
|
+
(default: 10)
|
81
|
+
--layout=LAYOUT Choose layout: [default|reverse|reverse-list]
|
82
|
+
--border[=STYLE] Draw border around the finder
|
83
|
+
[rounded|sharp|bold|block|thinblock|double|horizontal|vertical|
|
84
|
+
top|bottom|left|right|none] (default: rounded)
|
85
|
+
--border-label=LABEL Label to print on the border
|
86
|
+
--border-label-pos=COL Position of the border label
|
87
|
+
[POSITIVE_INTEGER: columns from left|
|
88
|
+
NEGATIVE_INTEGER: columns from right][:bottom]
|
89
|
+
(default: 0 or center)
|
90
|
+
--margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)
|
91
|
+
--padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)
|
92
|
+
--info=STYLE Finder info style
|
93
|
+
[default|right|hidden|inline[:SEPARATOR]|inline-right]
|
94
|
+
--separator=STR String to form horizontal separator on info line
|
95
|
+
--no-separator Hide info line separator
|
96
|
+
--scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)
|
97
|
+
--no-scrollbar Hide scrollbar
|
98
|
+
--prompt=STR Input prompt (default: '> ')
|
99
|
+
--pointer=STR Pointer to the current line (default: '>')
|
100
|
+
--marker=STR Multi-select marker (default: '>')
|
101
|
+
--header=STR String to print as header
|
102
|
+
--header-lines=N The first N lines of the input are treated as header
|
103
|
+
--header-first Print header before the prompt line
|
104
|
+
--ellipsis=STR Ellipsis to show when line is truncated (default: '..')
|
105
|
+
|
106
|
+
Display
|
107
|
+
--ansi Enable processing of ANSI color codes
|
108
|
+
--tabstop=SPACES Number of spaces for a tab character (default: 8)
|
109
|
+
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
|
110
|
+
--no-bold Do not use bold text
|
111
|
+
|
112
|
+
History
|
113
|
+
--history=FILE History file
|
114
|
+
--history-size=N Maximum number of history entries (default: 1000)
|
115
|
+
|
116
|
+
Preview
|
117
|
+
--preview=COMMAND Command to preview highlighted line ({})
|
118
|
+
--preview-window=OPT Preview window layout (default: right:50%)
|
119
|
+
[up|down|left|right][,SIZE[%]]
|
120
|
+
[,[no]wrap][,[no]cycle][,[no]follow][,[no]hidden]
|
121
|
+
[,border-BORDER_OPT]
|
122
|
+
[,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]
|
123
|
+
[,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]
|
124
|
+
--preview-label=LABEL
|
125
|
+
--preview-label-pos=N Same as --border-label and --border-label-pos,
|
126
|
+
but for preview window
|
127
|
+
|
128
|
+
Scripting
|
129
|
+
-q, --query=STR Start the finder with the given query
|
130
|
+
-1, --select-1 Automatically select the only match
|
131
|
+
-0, --exit-0 Exit immediately when there's no match
|
132
|
+
-f, --filter=STR Filter mode. Do not start interactive finder.
|
133
|
+
--print-query Print query as the first line
|
134
|
+
--expect=KEYS Comma-separated list of keys to complete fzf
|
135
|
+
--read0 Read input delimited by ASCII NUL characters
|
136
|
+
--print0 Print output delimited by ASCII NUL characters
|
137
|
+
--sync Synchronous search for multi-staged filtering
|
138
|
+
--listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /)
|
139
|
+
(To allow remote process execution, use --listen-unsafe)
|
140
|
+
--version Display version information and exit
|
141
|
+
|
142
|
+
Environment variables
|
143
|
+
FZF_DEFAULT_COMMAND Default command to use when input is tty
|
144
|
+
FZF_DEFAULT_OPTS Default options
|
145
|
+
(e.g. '--layout=reverse --inline-info')
|
146
|
+
FZF_API_KEY X-API-Key header for HTTP server (--listen)
|
147
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# lib/aia/external/glow.rb
|
2
|
+
|
3
|
+
class AIA::External::Glow < AIA::External::Tool
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
@role = :render
|
7
|
+
@desc = 'Render markdown on the CLI'
|
8
|
+
@url = 'https://github.com/charmbracelet/glow'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
__END__
|
14
|
+
|
15
|
+
Render markdown on the CLI, with pizzazz!
|
16
|
+
|
17
|
+
Usage:
|
18
|
+
glow [SOURCE|DIR] [flags]
|
19
|
+
glow [command]
|
20
|
+
|
21
|
+
Available Commands:
|
22
|
+
completion Generate the autocompletion script for the specified shell
|
23
|
+
config Edit the glow config file
|
24
|
+
help Help about any command
|
25
|
+
stash Stash a markdown
|
26
|
+
|
27
|
+
Flags:
|
28
|
+
-a, --all show system files and directories (TUI-mode only)
|
29
|
+
--config string config file (default /Users/dewayne/Library/Preferences/glow/glow.yml)
|
30
|
+
-h, --help help for glow
|
31
|
+
-l, --local show local files only; no network (TUI-mode only)
|
32
|
+
-p, --pager display with pager
|
33
|
+
-s, --style string style name or JSON path (default "auto")
|
34
|
+
-v, --version version for glow
|
35
|
+
-w, --width uint word-wrap at width
|
36
|
+
|
37
|
+
Use "glow [command] --help" for more information about a command.
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# lib/aia/external/mods.rb
|
2
|
+
|
3
|
+
class AIA::External::Mods < AIA::External::Tool
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
@role = :search
|
7
|
+
@desc = 'AI on the command-line'
|
8
|
+
@url = 'https://github.com/charmbracelet/mods'
|
9
|
+
end
|
10
|
+
|
11
|
+
def command(extra_options = [])
|
12
|
+
model = ENV['MODS_MODEL'] || 'gpt-4-1106-preview'
|
13
|
+
ai_default_opts = "-m #{model} --no-limit -f"
|
14
|
+
"#{name} #{ai_default_opts} #{extra_options.join(' ')}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
__END__
|
19
|
+
|
20
|
+
GPT on the command line. Built for pipelines.
|
21
|
+
|
22
|
+
Usage:
|
23
|
+
mods [OPTIONS] [PREFIX TERM]
|
24
|
+
|
25
|
+
Options:
|
26
|
+
-m, --model Default model (gpt-3.5-turbo, gpt-4, ggml-gpt4all-j...).
|
27
|
+
-a, --api OpenAI compatible REST API (openai, localai).
|
28
|
+
-x, --http-proxy HTTP proxy to use for API requests.
|
29
|
+
-f, --format Ask for the response to be formatted as markdown unless otherwise set.
|
30
|
+
-r, --raw Render output as raw text when connected to a TTY.
|
31
|
+
-P, --prompt Include the prompt from the arguments and stdin, truncate stdin to specified number of lines.
|
32
|
+
-p, --prompt-args Include the prompt from the arguments in the response.
|
33
|
+
-c, --continue Continue from the last response or a given save title.
|
34
|
+
-C, --continue-last Continue from the last response.
|
35
|
+
-l, --list Lists saved conversations.
|
36
|
+
-t, --title Saves the current conversation with the given title.
|
37
|
+
-d, --delete Deletes a saved conversation with the given title or ID.
|
38
|
+
-s, --show Show a saved conversation with the given title or ID.
|
39
|
+
-S, --show-last Show a the last saved conversation.
|
40
|
+
-q, --quiet Quiet mode (hide the spinner while loading and stderr messages for success).
|
41
|
+
-h, --help Show help and exit.
|
42
|
+
-v, --version Show version and exit.
|
43
|
+
--max-retries Maximum number of times to retry API calls.
|
44
|
+
--no-limit Turn off the client-side limit on the size of the input into the model.
|
45
|
+
--max-tokens Maximum number of tokens in response.
|
46
|
+
--temp Temperature (randomness) of results, from 0.0 to 2.0.
|
47
|
+
--topp TopP, an alternative to temperature that narrows response, from 0.0 to 1.0.
|
48
|
+
--fanciness Your desired level of fanciness.
|
49
|
+
--status-text Text to show while generating.
|
50
|
+
--no-cache Disables caching of the prompt/response.
|
51
|
+
--reset-settings Backup your old settings file and reset everything to the defaults.
|
52
|
+
--settings Open settings in your $EDITOR.
|
53
|
+
--dirs Print the directories in which mods store its data
|
54
|
+
|
55
|
+
Example:
|
56
|
+
# Editorialize your video files
|
57
|
+
ls ~/vids | mods -f "summarize each of these titles, group them by decade" | glow
|