aia 0.8.3 → 0.8.5
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/.version +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +28 -17
- data/lib/aia/config.rb +37 -26
- data/lib/aia/directive_processor.rb +29 -0
- data/lib/aia.rb +10 -0
- metadata +26 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307fe4fba0b6c2134cba097ffd9b01750eea1f3e06d6c6de5131099435caaa16
|
4
|
+
data.tar.gz: ac46548236f1c9162d62af9a999776d9a01ffa5cc8ff283ed9bfd774414ddc85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ec4085dabf70365ccc74a95126891a6075eefc57ad1a652432278b38355f55d2c503ebc6e10b52d9f77e3d7788fef0a9b1d9d6e6aa3b7d72b2cda82d337c08'
|
7
|
+
data.tar.gz: 84eed4f09f8d9d506887ea91cd9b810cc47e77a724c3031e43b464779e5cfcaf5f0a92cc30304bf0d6ffea0eb31e35a23dc2baabff1671cff1bca8852b7e7801
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
## [Unreleased]
|
3
3
|
|
4
4
|
## Released
|
5
|
+
### [0.8.5] 2025-04-49
|
6
|
+
- documentation updates
|
7
|
+
- integrated the https://pure.md web service for inserting web pages into the context window
|
8
|
+
- //include http?://example.com/stuff
|
9
|
+
- //webpage http?://example.com/stuff
|
5
10
|
|
6
11
|
### [0.8.2] 2025-04-18
|
7
12
|
- fixed problems with pre-loaded context and chat repl
|
data/README.md
CHANGED
@@ -17,18 +17,13 @@
|
|
17
17
|
AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manager) to manage prompts. It utilizes the [CLI tool fzf](https://github.com/junegunn/fzf) for prompt selection.
|
18
18
|
|
19
19
|
**Most Recent Change**: Refer to the [Changelog](CHANGELOG.md)
|
20
|
+
- //include directive now supports web URLs
|
21
|
+
- //webpage insert web URL content as markdown into context
|
20
22
|
|
21
|
-
**
|
22
|
-
- **Directive Processing in Chat and Prompts:** You can now use directives in chat sessions and prompt files with the syntax: `//command args`. Supported directives include:
|
23
|
-
- `shell`/`sh`: Execute shell commands
|
24
|
-
- `ruby`/`rb`: Execute Ruby code
|
25
|
-
- `config`/`cfg`: Display or update configuration
|
26
|
-
- `include`/`inc`: Include file content
|
27
|
-
- `next`: Specify the next prompt ID in a sequence
|
28
|
-
- `pipeline`: Specify a pipeline of prompt IDs to process
|
29
|
-
- `clear`: Clear the context (handy in a chat session)
|
30
|
-
- `help`: Show available directives
|
23
|
+
**Wiki**: [Checkout the AIA Wiki](https://github.com/MadBomber/aia/wiki)
|
31
24
|
|
25
|
+
**Notable Recent Changes:**
|
26
|
+
- **Directive Processing in Chat and Prompts:** You can now use directives in chat sessions and prompt files. Use the directive **//help** to get a list of available directives.
|
32
27
|
|
33
28
|
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
34
29
|
|
@@ -90,7 +85,7 @@ Install the command-line utilities by executing:
|
|
90
85
|
|
91
86
|
brew install fzf
|
92
87
|
|
93
|
-
You will also need to establish a directory in your
|
88
|
+
You will also need to establish a directory in your filesystem where your prompt text files, last used parameters and usage log files are kept.
|
94
89
|
|
95
90
|
Setup a system environment variable (envar) named "AIA_PROMPTS_DIR" that points to your prompts directory. The default is in your HOME directory named ".prompts". The envar "AIA_ROLES_PREFIX" points to your role prefix where you have prompts that define the different roles you want the LLM to assume when it is doing its work. The default roles prefix is "roles".
|
96
91
|
|
@@ -104,7 +99,7 @@ aia --completion bash
|
|
104
99
|
|
105
100
|
## What is a Prompt ID?
|
106
101
|
|
107
|
-
A prompt ID is the basename of a text file (extension *.txt) located in a prompts directory. The prompts directory is specified by the environment variable "AIA_PROMPTS_DIR". If this variable is not set, the default is in your HOME directory named ".prompts".
|
102
|
+
A prompt ID is the basename of a text file (extension *.txt) located in a prompts directory. The prompts directory is specified by the environment variable "AIA_PROMPTS_DIR". If this variable is not set, the default is in your HOME directory named ".prompts". It can also be set on the command line with the `--prompts-dir` option.
|
108
103
|
|
109
104
|
This file contains the context and instructions for the LLM to follow. The prompt ID is what you use as an option on the command line to specify which prompt text file to use. Prompt files can have comments, parameters, directives and ERB blocks along with the instruction text to feed to the LLM. It can also have shell commands and use system environment variables. Consider the following example:
|
110
105
|
|
@@ -142,16 +137,32 @@ Tell me how to do something for a $(uname -s) platform that would rename all
|
|
142
137
|
of the files in the directory $MY_DIRECTORY to have a prefix of for its filename
|
143
138
|
that is [PREFIX] and a ${SUFFIX}
|
144
139
|
|
145
|
-
|
146
|
-
|
147
|
-
|
140
|
+
<!--
|
141
|
+
directives, ERB blocks and other junk can be used
|
142
|
+
anywhere in the file mixing dynamic context/instructions with
|
143
|
+
the static stuff.
|
144
|
+
-->
|
145
|
+
|
146
|
+
```markdown
|
147
|
+
# Header 1 -- not a comment
|
148
|
+
## Header 2 -- not a comment
|
149
|
+
### Header 3, etc -- not a comment
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
# this is a comment; but it stays in the prompt
|
153
|
+
puts "hello world" <!-- this is also a comment; but it gets removed -->
|
154
|
+
```
|
155
|
+
Kewl!
|
156
|
+
```
|
148
157
|
|
149
158
|
__END__
|
150
159
|
|
151
|
-
|
152
|
-
the LLM.
|
160
|
+
Everything after the "__END__" line is not part of the context or instructions to
|
161
|
+
the LLM.
|
153
162
|
```
|
154
163
|
|
164
|
+
Comments in a prompt text file are just there to document the prompt. They are removed before the completed prompt is processed by the LLM. This reduces token counts; but, more importantly it helps you remember why you structured your prompt they way you did - if you remembered to document your prompt.
|
165
|
+
|
155
166
|
That is just about everything including the kitchen sink that a pre-compositional parameterized prompt file can have. It can be an executable with a she-bang line and a special system prompt name `run` as shown in the example. It has line comments that use the `#` symbol. It had end of file block comments that appear after the "__END__" line. It has directive command that begin with the double slash `//` - an homage to IBM JCL. It has shell variables in both forms. It has shell commands. It has parameters that default to a regex that uses square brackets and all uppercase characeters to define the parameter name whose value is to be given in a Q&A session before the prompt is sent to the LLM for processing.
|
156
167
|
|
157
168
|
AIA has the ability to define a workflow of prompt IDs with either the //next or //pipeline directives.
|
data/lib/aia/config.rb
CHANGED
@@ -10,15 +10,17 @@ require 'toml-rb'
|
|
10
10
|
require 'erb'
|
11
11
|
require 'optparse'
|
12
12
|
|
13
|
-
|
14
13
|
module AIA
|
15
14
|
class Config
|
16
|
-
DEFAULT_CONFIG = {
|
15
|
+
DEFAULT_CONFIG = OpenStruct.new({
|
17
16
|
aia_dir: File.join(ENV['HOME'], '.aia'),
|
18
17
|
config_file: File.join(ENV['HOME'], '.aia', 'config.yml'),
|
19
18
|
out_file: 'temp.md',
|
20
19
|
log_file: File.join(ENV['HOME'], '.prompts', '_prompts.log'),
|
21
20
|
prompts_dir: File.join(ENV['HOME'], '.prompts'),
|
21
|
+
#
|
22
|
+
prompt_extname: PromptManager::Storage::FileSystemAdapter::PROMPT_EXTENSION,
|
23
|
+
#
|
22
24
|
roles_prefix: 'roles',
|
23
25
|
roles_dir: File.join(ENV['HOME'], '.prompts', 'roles'),
|
24
26
|
role: '',
|
@@ -67,11 +69,10 @@ module AIA
|
|
67
69
|
|
68
70
|
# Ruby libraries to require for Ruby binding
|
69
71
|
require_libs: [],
|
70
|
-
}.freeze
|
71
|
-
|
72
|
+
}).freeze
|
72
73
|
|
73
74
|
def self.setup
|
74
|
-
default_config =
|
75
|
+
default_config = DEFAULT_CONFIG.dup
|
75
76
|
cli_config = cli_options
|
76
77
|
envar_config = envar_options(default_config, cli_config)
|
77
78
|
|
@@ -92,6 +93,35 @@ module AIA
|
|
92
93
|
|
93
94
|
|
94
95
|
def self.tailor_the_config(config)
|
96
|
+
remaining_args = config.remaining_args.dup
|
97
|
+
config.remaining_args = nil
|
98
|
+
|
99
|
+
# Is first remaining argument a prompt ID?
|
100
|
+
unless remaining_args.empty?
|
101
|
+
maybe_id = remaining_args.first
|
102
|
+
maybe_id_plus = File.join(config.prompts_dir, maybe_id + config.prompt_extname)
|
103
|
+
|
104
|
+
if AIA.bad_file?(maybe_id) && AIA.good_file?(maybe_id_plus)
|
105
|
+
config.prompt_id =remaining_args.shift
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
unless remaining_args.empty?
|
110
|
+
bad_files = remaining_args.reject { |filename| AIA.good_file?(filename) }
|
111
|
+
if bad_files.any?
|
112
|
+
STDERR.puts "Error: The following files do not exist: #{bad_files.join(', ')}"
|
113
|
+
exit 1
|
114
|
+
end
|
115
|
+
|
116
|
+
config.context_files = remaining_args
|
117
|
+
end
|
118
|
+
|
119
|
+
if config.prompt_id.nil? && !config.chat && !config.fuzzy
|
120
|
+
STDERR.puts "Error: A prompt ID is required unless using --chat, --fuzzy, or providing context files. Use -h or --help for help."
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
|
124
|
+
|
95
125
|
unless config.role.empty?
|
96
126
|
unless config.roles_prefix.empty?
|
97
127
|
unless config.role.start_with?(config.roles_prefix)
|
@@ -151,7 +181,7 @@ module AIA
|
|
151
181
|
STDERR.puts "Error: A prompt ID is required unless using --chat, --fuzzy, or providing context files. Use -h or --help for help."
|
152
182
|
exit 1
|
153
183
|
end
|
154
|
-
|
184
|
+
|
155
185
|
# If we're in chat mode with context files but no prompt_id, that's valid
|
156
186
|
if config.chat && config.prompt_id.empty? && config.context_files && !config.context_files.empty?
|
157
187
|
# This is a valid use case - no action needed
|
@@ -391,32 +421,13 @@ module AIA
|
|
391
421
|
|
392
422
|
# Parse the command line arguments
|
393
423
|
begin
|
394
|
-
remaining_args = opt_parser.parse(args)
|
424
|
+
config.remaining_args = opt_parser.parse(args)
|
395
425
|
rescue OptionParser::InvalidOption => e
|
396
426
|
puts e.message
|
397
427
|
puts opt_parser
|
398
428
|
exit 1
|
399
429
|
end
|
400
430
|
|
401
|
-
# Handle remaining args
|
402
|
-
unless remaining_args.empty?
|
403
|
-
# If in chat mode and all args are existing files, treat them all as context files
|
404
|
-
if config.chat && remaining_args.all? { |arg| File.exist?(arg) }
|
405
|
-
config.context_files = remaining_args
|
406
|
-
# If first arg is empty string and we're in chat mode, treat all args as context files
|
407
|
-
elsif config.chat && remaining_args.first == ""
|
408
|
-
remaining_args.shift # Remove the empty string
|
409
|
-
config.context_files = remaining_args unless remaining_args.empty?
|
410
|
-
else
|
411
|
-
# First remaining arg is the prompt ID
|
412
|
-
config.prompt_id = remaining_args.shift
|
413
|
-
|
414
|
-
# Remaining args are context files
|
415
|
-
config.context_files = remaining_args unless remaining_args.empty?
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
|
420
431
|
config
|
421
432
|
end
|
422
433
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# lib/aia/directive_processor.rb
|
2
2
|
|
3
|
+
require 'faraday'
|
4
|
+
|
3
5
|
module AIA
|
4
6
|
class DirectiveProcessor
|
7
|
+
PUREMD_API_KEY = ENV.fetch('PUREMD_API_KEY', nil)
|
5
8
|
EXCLUDED_METHODS = %w[ run initialize private? ]
|
6
9
|
@descriptions = {}
|
7
10
|
@aliases = {}
|
@@ -100,10 +103,32 @@ module AIA
|
|
100
103
|
!respond_to?(method_name) && respond_to?(method_name, true)
|
101
104
|
end
|
102
105
|
|
106
|
+
|
103
107
|
################
|
104
108
|
## Directives ##
|
105
109
|
################
|
106
110
|
|
111
|
+
|
112
|
+
desc "webpage inserted as markdown to context using pure.md"
|
113
|
+
def webpage(args, context_manager=nil)
|
114
|
+
if PUREMD_API_KEY.nil?
|
115
|
+
"ERROR: PUREMD_API_KEY is required in order to include a webpage"
|
116
|
+
else
|
117
|
+
url = `echo #{args.shift}`.strip
|
118
|
+
puremd_url = "https://pure.md/#{url}"
|
119
|
+
|
120
|
+
response = Faraday.get(puremd_url) do |req|
|
121
|
+
req.headers['x-puremd-api-token'] = PUREMD_API_KEY
|
122
|
+
end
|
123
|
+
|
124
|
+
if 200 == response.status
|
125
|
+
response.body
|
126
|
+
else
|
127
|
+
"Error: wtatus was #{r.status}\n#{ap response}"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
107
132
|
desc "Specify the next prompt ID to process after this one"
|
108
133
|
def next(args = [])
|
109
134
|
if args.empty?
|
@@ -129,6 +154,10 @@ module AIA
|
|
129
154
|
# echo takes care of envars and tilde expansion
|
130
155
|
file_path = `echo #{args.shift}`.strip
|
131
156
|
|
157
|
+
if file_path.start_with?(/http?:\/\//)
|
158
|
+
return webpage(args)
|
159
|
+
end
|
160
|
+
|
132
161
|
if @included_files.include?(file_path)
|
133
162
|
""
|
134
163
|
else
|
data/lib/aia.rb
CHANGED
@@ -45,6 +45,16 @@ module AIA
|
|
45
45
|
@config.client = client
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.good_file?(filename)
|
49
|
+
File.exist?(filename) &&
|
50
|
+
File.readable?(filename) &&
|
51
|
+
!File.directory?(filename)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.bad_file?(filename)
|
55
|
+
!good_file?(filename)
|
56
|
+
end
|
57
|
+
|
48
58
|
def self.build_flags
|
49
59
|
@config.each_pair do |key, value|
|
50
60
|
if [TrueClass, FalseClass].include?(value.class)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dewayne VanHoozer
|
@@ -37,6 +37,20 @@ dependencies:
|
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: faraday
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
40
54
|
- !ruby/object:Gem::Dependency
|
41
55
|
name: os
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,14 +71,14 @@ dependencies:
|
|
57
71
|
requirements:
|
58
72
|
- - ">="
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
74
|
+
version: 0.5.2
|
61
75
|
type: :runtime
|
62
76
|
prerelease: false
|
63
77
|
version_requirements: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - ">="
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.
|
81
|
+
version: 0.5.2
|
68
82
|
- !ruby/object:Gem::Dependency
|
69
83
|
name: reline
|
70
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,17 +261,13 @@ dependencies:
|
|
247
261
|
- - ">="
|
248
262
|
- !ruby/object:Gem::Version
|
249
263
|
version: '0'
|
250
|
-
description:
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
power house that rivals specialized gen-AI tools. aia currently supports "mods"
|
258
|
-
and "sgpt" CLI tools. aia uses "ripgrep" and "fzf" CLI utilities to search for
|
259
|
-
and select prompt files to send to the backend gen-AI tool along with supported
|
260
|
-
context files.
|
264
|
+
description: |
|
265
|
+
Unleash the full power of AI from your terminal! AIA is a cutting-edge CLI
|
266
|
+
assistant for generative AI workflows, offering dynamic prompt management,
|
267
|
+
seamless shell and Ruby integration, interactive chat, and advanced automation.
|
268
|
+
Effortlessly craft, manage, and execute prompts with embedded directives,
|
269
|
+
history, and flexible configuration. Experience next-level productivity for
|
270
|
+
developers, power users, and AI enthusiasts—all from your command line.
|
261
271
|
email:
|
262
272
|
- dvanhoozer@gmail.com
|
263
273
|
executables:
|
@@ -321,5 +331,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
331
|
requirements: []
|
322
332
|
rubygems_version: 3.6.8
|
323
333
|
specification_version: 4
|
324
|
-
summary: AI Assistant
|
334
|
+
summary: 'AI Assistant: dynamic prompts, shell & Ruby integration, and seamless chat
|
335
|
+
workflows.'
|
325
336
|
test_files: []
|