aia 0.9.6 → 0.9.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02a36ff149a0fa6eb782735e963ca860260c10b43133b56ebe49adda5074c86d
4
- data.tar.gz: 588411eb80ac91a88fc8dd456595610f9bfb71947201629ec1d5b64f5a1cf2d6
3
+ metadata.gz: 3411bc073c7fadee9f625917b13b06fb11aee61c234f61c57958be1000f261c6
4
+ data.tar.gz: 1228b68648536d5c8a4caeb2e6cf6eb91400647c96163b1ab7b6f499b1001d99
5
5
  SHA512:
6
- metadata.gz: 59eb282bad1dd8e450ec98608e8f4b295ce6c9b0084d2aef7772df4834d5beecddd7fd785a46db1a47e72cf6f90c8d1b15dbd2843a8d2be737d6bf6f47911002
7
- data.tar.gz: 4483f697b88266a73187b2483bae32ac6b82a4fc432bc3e494f35c5d3c63c4395949a95a8282a3a18f475bb9cbdacaf7253069817fc54c3d3927ae4a66a401bf
6
+ metadata.gz: cbd94570f820e5007a7a9ba94b908a0f36407ec9b9f11074283e67374b24261db18309f32c2e079521c93322ce6fe4c2223181d61f3dce99c4a0d39bc5a26e48
7
+ data.tar.gz: fdd5647498501805e598c5e7d319193928954e1e2e639e473440c323e49abee46c09aa665130679e790db15c49d81f0ab5bf09deb5ac0f4b6b67eba6a9da625c
@@ -1,5 +1,6 @@
1
1
  label: "## Table of Contents"
2
2
  patterns:
3
3
  - "README.md"
4
- - doc/*.md
4
+ - docs/*.md
5
+ - docs/draft_articles/*.md
5
6
  root_dir: "."
data/.version CHANGED
@@ -1 +1 @@
1
- 0.9.6
1
+ 0.9.8
data/CHANGELOG.md CHANGED
@@ -1,7 +1,24 @@
1
1
  # Changelog
2
2
  ## [Unreleased]
3
+
3
4
  ## Released
4
5
 
6
+ ### [0.9.8] 2025-06-25
7
+ - fixing an issue with pipelined prompts
8
+ - now showing the complete modality of the model on the processing line.
9
+ - changed -p option from prompts_dir to pipeline
10
+
11
+ ### [0.9.7] 2025-06-20
12
+
13
+ - **NEW FEATURE**: Added `--available_models` CLI option to list all available AI models
14
+ - **NEW FEATURE**: Added `//tools` to show a list of available tools and their description
15
+ - **BUG FIX**: Fixed SharedTools compatibility issue with models that don't support function calling
16
+ - **BUG FIX**: Fixed problem with piped text through STDIN not being handled correctly.
17
+ - **BUG FIX**: Fixed issue with output going to the default out_file evenhen --no-out_file is specified.
18
+ - **BUG FIX**: Fixed issue with executable prompt files by adding the --exec option
19
+ - **DOCUMENTATION**: Updated README for better clarity and structure
20
+ - **DEPENDENCY**: Updated Gemfile.lock with latest dependency versions
21
+
5
22
  ### [0.9.6] 2025-06-13
6
23
  - fixed issue 84 with the //llms directive
7
24
  - changed the monkey patch to the RubyLLM::Model::Modalities class at the suggestions of the RubyLLM author in prep for a PR against that gem.
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  AIA is a command-line utility that facilitates interaction with AI models through dynamic prompt management. It automates the management of pre-compositional prompts and executes generative AI commands with enhanced features including embedded directives, shell integration, embedded Ruby, history management, interactive chat, and prompt workflows.
8
8
 
9
- AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manager) to manage prompts, utilizes the [CLI tool fzf](https://github.com/junegunn/fzf) for prompt selection, and includes the [shared_tools gem](https://github.com/madbomber/shared_tools) which provides a collection of ready-to-use functions for use with LLMs that support tools.
9
+ AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manager) to manage prompts, utilizes the [CLI tool fzf](https://github.com/junegunn/fzf) for prompt selection, and can use the [shared_tools gem](https://github.com/madbomber/shared_tools) which provides a collection of common ready-to-use functions for use with LLMs that support tools.
10
10
 
11
11
  **Wiki**: [Checkout the AIA Wiki](https://github.com/MadBomber/aia/wiki)
12
12
 
@@ -25,12 +25,12 @@ AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manag
25
25
  3. **Create your first prompt:**
26
26
  ```bash
27
27
  mkdir -p ~/.prompts
28
- echo "What is [TOPIC]?" > ~/.prompts/ask.txt
28
+ echo "What is [TOPIC]?" > ~/.prompts/what_is.txt
29
29
  ```
30
30
 
31
31
  4. **Run your prompt:**
32
32
  ```bash
33
- aia ask
33
+ aia what_is
34
34
  ```
35
35
  You'll be prompted to enter a value for `[TOPIC]`, then AIA will send your question to the AI model.
36
36
 
@@ -40,43 +40,76 @@ AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manag
40
40
  ```
41
41
 
42
42
  ```plain
43
- , ,
44
- (\____/) AI Assistant
45
- (_oo_) Fancy LLM
46
- (O) is Online
47
- __||__ \)
48
- [/______\] /
49
- / \__AI__/ \/
50
- / /__\
51
- (\ /____\
43
+
44
+ , ,
45
+ (\____/) AI Assistant (v0.9.7) is Online
46
+ (_oo_) gpt-4o-mini
47
+ (O) using ruby_llm (v1.3.1)
48
+ __||__ \) model db was last refreshed on
49
+ [/______\] / 2025-06-18
50
+ / \__AI__/ \/ You can share my tools
51
+ / /__\
52
+ (\ /____\
53
+
52
54
  ```
53
55
 
54
56
  <!-- Tocer[start]: Auto-generated, don't remove. -->
55
57
 
56
58
  ## Table of Contents
57
59
 
58
- - [Quick Start](#quick-start)
59
60
  - [Installation & Prerequisites](#installation--prerequisites)
61
+ - [Requirements](#requirements)
62
+ - [Installation](#installation)
63
+ - [Setup Shell Completion](#setup-shell-completion)
60
64
  - [Basic Usage](#basic-usage)
65
+ - [Command Line Interface](#command-line-interface)
66
+ - [Key Command-Line Options](#key-command-line-options)
67
+ - [Directory Structure](#directory-structure)
61
68
  - [Configuration](#configuration)
62
69
  - [Essential Configuration Options](#essential-configuration-options)
63
70
  - [Configuration Precedence](#configuration-precedence)
71
+ - [Configuration Methods](#configuration-methods)
64
72
  - [Complete Configuration Reference](#complete-configuration-reference)
65
73
  - [Advanced Features](#advanced-features)
66
74
  - [Prompt Directives](#prompt-directives)
75
+ - [Configuration Directive Examples](#configuration-directive-examples)
76
+ - [Dynamic Content Examples](#dynamic-content-examples)
67
77
  - [Shell Integration](#shell-integration)
68
78
  - [Embedded Ruby (ERB)](#embedded-ruby-erb)
69
79
  - [Prompt Sequences](#prompt-sequences)
80
+ - [Using --next](#using---next)
81
+ - [Using --pipeline](#using---pipeline)
82
+ - [Example Workflow](#example-workflow)
70
83
  - [Roles and System Prompts](#roles-and-system-prompts)
71
84
  - [RubyLLM::Tool Support](#rubyllmtool-support)
72
85
  - [Examples & Tips](#examples--tips)
73
86
  - [Practical Examples](#practical-examples)
87
+ - [Code Review Prompt](#code-review-prompt)
88
+ - [Meeting Notes Processor](#meeting-notes-processor)
89
+ - [Documentation Generator](#documentation-generator)
74
90
  - [Executable Prompts](#executable-prompts)
75
91
  - [Tips from the Author](#tips-from-the-author)
92
+ - [The run Prompt](#the-run-prompt)
93
+ - [The Ad Hoc One-shot Prompt](#the-ad-hoc-one-shot-prompt)
94
+ - [Recommended Shell Setup](#recommended-shell-setup)
95
+ - [Prompt Directory Organization](#prompt-directory-organization)
76
96
  - [Security Considerations](#security-considerations)
97
+ - [Shell Command Execution](#shell-command-execution)
98
+ - [Safe Practices](#safe-practices)
99
+ - [Recommended Security Setup](#recommended-security-setup)
77
100
  - [Troubleshooting](#troubleshooting)
101
+ - [Common Issues](#common-issues)
102
+ - [Error Messages](#error-messages)
103
+ - [Debug Mode](#debug-mode)
104
+ - [Performance Issues](#performance-issues)
78
105
  - [Development](#development)
106
+ - [Testing](#testing)
107
+ - [Building](#building)
108
+ - [Architecture Notes](#architecture-notes)
79
109
  - [Contributing](#contributing)
110
+ - [Reporting Issues](#reporting-issues)
111
+ - [Development Setup](#development-setup)
112
+ - [Areas for Improvement](#areas-for-improvement)
80
113
  - [Roadmap](#roadmap)
81
114
  - [License](#license)
82
115
 
@@ -281,16 +314,21 @@ Directives are special commands in prompt files that begin with `//` and provide
281
314
  | Directive | Description | Example |
282
315
  |-----------|-------------|---------|
283
316
  | `//config` | Set configuration values | `//config model = gpt-4` |
317
+ | `//context` | Show context for this conversation | `//context` |
284
318
  | `//include` | Insert file contents | `//include path/to/file.txt` |
285
319
  | `//shell` | Execute shell commands | `//shell ls -la` |
320
+ | `//robot` | Show the pet robot ASCII art w/versions | `//robot` |
286
321
  | `//ruby` | Execute Ruby code | `//ruby puts "Hello World"` |
287
322
  | `//next` | Set next prompt in sequence | `//next summary` |
288
323
  | `//pipeline` | Set prompt workflow | `//pipeline analyze,summarize,report` |
289
324
  | `//clear` | Clear conversation history | `//clear` |
290
325
  | `//help` | Show available directives | `//help` |
291
326
  | `//available_models` | List available models | `//available_models` |
327
+ | `//tools` | Show a list of available tools and their description | `//tools` |
292
328
  | `//review` | Review current context | `//review` |
293
329
 
330
+ Directives can also be used in the interactive chat sessions.
331
+
294
332
  #### Configuration Directive Examples
295
333
 
296
334
  ```bash
@@ -462,22 +500,20 @@ aia --tools ~/tools/ --rejected_tools deprecated
462
500
  - Data processing utilities
463
501
 
464
502
  **Shared Tools Collection:**
465
- AIA includes the [shared_tools gem](https://github.com/madbomber/shared_tools) which provides a curated collection of commonly-used RubyLLM::Tool implementations:
503
+ AIA can use the [shared_tools gem](https://github.com/madbomber/shared_tools) which provides a curated collection of commonly-used tools (aka functions) via the --require option.
466
504
 
467
505
  ```bash
468
506
  # Access shared tools automatically (included with AIA)
469
- aia --tools shared --chat
507
+ aia --require shared_tools/ruby_llm --chat
470
508
 
471
- # Combine with custom tools
472
- aia --tools shared,~/my-tools/ --chat
509
+ # To access just one specific shared tool
510
+ aia --require shared_tools/ruby_llm/edit_file --chat
511
+
512
+ # Combine with your own local custom RubyLLM-based tools
513
+ aia --require shared_tools/ruby_llm --tools ~/my-tools/ --chat
473
514
  ```
474
515
 
475
- Available shared tools include:
476
- - **File operations**: read, write, edit, search files
477
- - **Web utilities**: fetch web pages, parse HTML/JSON
478
- - **System tools**: execute commands, get system info
479
- - **Data processing**: CSV/JSON manipulation, text analysis
480
- - **API helpers**: HTTP requests, common API patterns
516
+ The above examples show the shared_tools being used within an interactive chat session. They are also available in batch prompts as well using the same --require option. You can also use the //ruby directive to require the shared_tools as well and using a require statement within an ERB block.
481
517
 
482
518
  ## Examples & Tips
483
519
 
@@ -486,7 +522,7 @@ Available shared tools include:
486
522
  #### Code Review Prompt
487
523
  ```bash
488
524
  # ~/.prompts/code_review.txt
489
- //config model = gpt-4
525
+ //config model = gpt-4o-mini
490
526
  //config temperature = 0.3
491
527
 
492
528
  Review this code for:
@@ -496,7 +532,6 @@ Review this code for:
496
532
  - Maintainability concerns
497
533
 
498
534
  Code to review:
499
- //include [CODE_FILE]
500
535
  ```
501
536
 
502
537
  Usage: `aia code_review mycode.rb`
@@ -516,7 +551,7 @@ Please clean up and structure these meeting notes.
516
551
  #### Documentation Generator
517
552
  ```bash
518
553
  # ~/.prompts/document.txt
519
- //config model = gpt-4
554
+ //config model = gpt-4o-mini
520
555
  //shell find [PROJECT_DIR] -name "*.rb" | head -10
521
556
 
522
557
  Generate documentation for the Ruby project shown above.
@@ -525,48 +560,62 @@ Include: API references, usage examples, and setup instructions.
525
560
 
526
561
  ### Executable Prompts
527
562
 
528
- Create reusable executable prompts:
563
+ The `--exec` flag is used to create executable prompts. If it is not present on the shebang line then the prompt file will be treated like any other context file. That means that the file will be included as context in the prompt but no dynamic content integration or directives will be processed. All other AIA options are, well, optional. All you need is an initial prompt ID and the --exec flag.
564
+
565
+ In the example below the option `--no-out_file` is used to direct the output from the LLM processing of the prompt to STDOUT. This way the executable prompts can be good citizens on the *nix command line receiving piped in input via STDIN and send its output to STDOUT.
566
+
567
+ Create executable prompts:
529
568
 
530
569
  **weather_report** (make executable with `chmod +x`):
531
570
  ```bash
532
- #!/usr/bin/env aia run --no-out_file
533
- # Get current weather for a city
571
+ #!/usr/bin/env aia run --no-out_file --exec
572
+ # Get current storm activity for the east and south coast of the US
573
+
574
+ Summarize the tropical storm outlook fpr the Atlantic, Caribbean Sea and Gulf of America.
534
575
 
535
- What's the current weather in [CITY]?
536
- Include temperature, conditions, and 3-day forecast.
537
- Format as a brief, readable summary.
576
+ //webpage https://www.nhc.noaa.gov/text/refresh/MIATWOAT+shtml/201724_MIATWOAT.shtml
538
577
  ```
539
578
 
540
579
  Usage:
541
580
  ```bash
542
581
  ./weather_report
543
- # Prompts for city, outputs to stdout
544
-
545
- ./weather_report | glow # Render with glow
582
+ ./weather_report | glow # Render the markdown with glow
546
583
  ```
547
584
 
548
585
  ### Tips from the Author
549
586
 
550
- **Most Versatile Prompt:**
587
+ #### The run Prompt
588
+ ```bash
589
+ # ~/.prompts/run.txt
590
+ # Desc: A configuration only prompt file for use with executable prompts
591
+ # Put whatever you want here to setup the configuration desired.
592
+ # You could also add a system prompt to preface your intended prompt
593
+ ```
594
+
595
+ Usage: `echo "What is the meaning of life?" | aia run`
596
+
597
+ #### The Ad Hoc One-shot Prompt
551
598
  ```bash
552
599
  # ~/.prompts/ad_hoc.txt
553
600
  [WHAT_NOW_HUMAN]
554
601
  ```
555
- Usage: `aia ad_hoc` - perfect for any quick question without cluttering shell history.
602
+ Usage: `aia ad_hoc` - perfect for any quick one-shot question without cluttering shell history.
556
603
 
557
- **Recommended Shell Setup:**
604
+ #### Recommended Shell Setup
558
605
  ```bash
559
606
  # ~/.bashrc_aia
560
607
  export AIA_PROMPTS_DIR=~/.prompts
561
608
  export AIA_OUT_FILE=./temp.md
562
609
  export AIA_MODEL=gpt-4o-mini
563
- export AIA_VERBOSE=true # Shows spinner while waiting
610
+ export AIA_VERBOSE=true # Shows spinner while waiting for LLM response
564
611
 
565
612
  alias chat='aia --chat --terse'
566
- alias ask='aia ad_hoc'
613
+ ask() { echo "$1" | aia run --no-out_file; }
567
614
  ```
568
615
 
569
- **Prompt Organization:**
616
+ The `chat` alias and the `ask` function (shown above in HASH) are two powerful tools for interacting with the AI assistant. The `chat` alias allows you to engage in an interactive conversation with the AI assistant, while the `ask` function allows you to ask a question and receive a response. Later in this document the `run` prompt ID is discussed. Besides using the run prompt ID here its also used in making executable prompt files.
617
+
618
+ #### Prompt Directory Organization
570
619
  ```
571
620
  ~/.prompts/
572
621
  ├── daily/ # Daily workflow prompts
@@ -611,10 +660,6 @@ AIA executes shell commands and Ruby code embedded in prompts. This provides pow
611
660
  # Set restrictive permissions on prompts directory
612
661
  chmod 700 ~/.prompts
613
662
  chmod 600 ~/.prompts/*.txt
614
-
615
- # Use separate prompts directory for shared/untrusted prompts
616
- export AIA_PROMPTS_DIR_SHARED=~/shared-prompts
617
- chmod 755 ~/shared-prompts
618
663
  ```
619
664
 
620
665
  ## Troubleshooting
data/examples/headlines CHANGED
@@ -1,21 +1,30 @@
1
- #!/usr/bin/env aia run --no-out_file
2
- # File: examples/headlines
1
+ #!/usr/bin/env aia run --no-out_file --exec
2
+ # NOTE: the --exec option is REQUIRED to run this executable prompt file
3
+ # This option signals that the contents of this file are to be appended
4
+ # to the contents of the given prompt ID file. In this case it is the
5
+ # "run" prompt ID's text file.
6
+ #
7
+ # All other AIA options are, well, optional. The --no-out_file is
8
+ # used here to cause the response to this executable prompt to be
9
+ # sent to STDOUT like a good little *nix CLI tool. Its not necessary.
10
+ # if you do not use it, the output will go to the default out_file.
11
+ # You could also specify a specific file to write the output to built
12
+ # but it is more convential to use the *nix STDOUT redirect "> output.md"
13
+ #
3
14
  # Desc: retrieves the news.google.com website
4
15
  # extracts and formats the headlines
5
- # and prints them to the console
16
+ # and prints them to STDOUT
17
+ #
18
+ # Method:
19
+ # There are several ways you can accomplish this task using
20
+ # the shell or ERB integration. For this example lets use
21
+ # a built-in directive.
6
22
 
7
- //config shell = true
8
- # //config
23
+ Extract and summarize the headlines from the following markdown:
9
24
 
10
- # Puts the webpage into index.html
11
- # //shell wget2 https://news.google.com
25
+ //webpage https://news.google.com
12
26
 
13
- $(wget2 https://news.google.com)
27
+ __END__
14
28
 
15
-
16
- # Lets hear the headlines as well as read them.
17
- //config speak = true
18
-
19
- Extract and summarize the headlines from the following text:
20
-
21
- $(html2text index.html)
29
+ The //webpage directive makes use of the website https://pure.md
30
+ to convert any given URL to a markdown file.
@@ -0,0 +1,30 @@
1
+ # examples/tools/pdf_page_reader.rb
2
+ # See: https://max.engineer/giant-pdf-llm
3
+
4
+ require "ruby_llm/tool"
5
+ require 'pdf-reader'
6
+
7
+
8
+ class PdfPageReader < RubyLLM::Tool
9
+ # TODO: make the path to the pdf document a parameter
10
+ DOC = PDF::Reader.new('docs/big-doc.pdf')
11
+
12
+ description 'Read the text of any set of pages from a PDF document.'
13
+ param :page_numbers,
14
+ desc: 'Comma-separated page numbers (first page: 1). (e.g. "12, 14, 15")'
15
+
16
+ def execute(page_numbers:)
17
+ puts "\n-- Reading pages: #{page_numbers}\n\n"
18
+ page_numbers = page_numbers.split(',').map { _1.strip.to_i }
19
+ pages = page_numbers.map { [_1, DOC.pages[_1.to_i - 1]] }
20
+ {
21
+ pages: pages.map { |num, p|
22
+ # There are lines drawn with dots in my doc.
23
+ # So I squeeze them to save tokens.
24
+ { page: num, text: p&.text&.squeeze('.') }
25
+ }
26
+ }
27
+ rescue => e
28
+ { error: e.message }
29
+ end
30
+ end
@@ -1,5 +1,6 @@
1
1
  # experiments/ai_misc/coding_agent_with_ruby_llm/tools/run_shell_command.rb
2
2
 
3
+ require "io/console"
3
4
  require "ruby_llm/tool"
4
5
 
5
6
  module Tools
@@ -8,10 +9,21 @@ module Tools
8
9
  param :command, desc: "The command to execute"
9
10
 
10
11
  def execute(command:)
11
- puts "AI wants to execute the following shell command: '#{command}'"
12
- print "Do you want to execute it? (y/n) "
13
- response = gets.chomp
14
- return { error: "User declined to execute the command" } unless response == "y"
12
+ print "\n\n"
13
+ puts "AI wants to execute the following shell command:"
14
+ puts "="*command.size
15
+ puts command
16
+ puts "="*command.size
17
+ print "\n\n"
18
+
19
+ sleep 0.5
20
+ print "Execute the command? (y/N):"
21
+ allowed = STDIN.getch == "y"
22
+
23
+ unless allowed
24
+ print "Command aborted" + " "*30 if defined?(AIA)
25
+ return { error: "User declined to execute the command" }
26
+ end
15
27
 
16
28
  `#{command}`
17
29
  rescue => e
@@ -60,9 +60,8 @@ module AIA
60
60
  def output_response(response)
61
61
  speak(response)
62
62
 
63
- # Only output to STDOUT if we're in chat mode
64
-
65
- if AIA.chat? || 'STDOUT' == AIA.config.out_file.upcase
63
+ # Output to STDOUT or file based on out_file configuration
64
+ if AIA.config.out_file.nil? || 'STDOUT' == AIA.config.out_file.upcase
66
65
  print "\nAI:\n "
67
66
  puts response
68
67
  else
@@ -94,26 +93,7 @@ module AIA
94
93
 
95
94
  def determine_operation_type
96
95
  mode = AIA.config.client.model.modalities
97
-
98
- if mode.text_to_image?
99
- :text_to_image
100
- elsif mode.image_to_text?
101
- :image_to_text
102
- elsif mode.audio_to_text?
103
- :audio_to_text
104
- elsif mode.text_to_audio?
105
- :text_to_audio
106
- elsif mode.audio_to_audio?
107
- :audio_to_audio
108
- elsif mode.image_to_image?
109
- :image_to_image
110
- elsif mode.audio_to_image?
111
- :audio_to_image
112
- elsif mode.image_to_audio?
113
- :image_to_audio
114
- else
115
- :text_to_text
116
- end
96
+ mode.input.join(',') + " TO " + mode.output.join(',')
117
97
  end
118
98
  end
119
99
  end