diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/gem/Gemfile.lock | 2 | ||||
| -rw-r--r-- | examples/plain_ruby/Justfile | 12 | ||||
| -rw-r--r-- | examples/plain_ruby/README.md | 5 | ||||
| -rwxr-xr-x | examples/plain_ruby/agents.rb | 40 | ||||
| -rw-r--r-- | examples/plain_ruby/agents_example.txt | 1 | ||||
| -rwxr-xr-x | examples/plain_ruby/config.rb | 2 | ||||
| -rw-r--r-- | examples/rake/Gemfile.lock | 26 |
7 files changed, 87 insertions, 1 deletions
diff --git a/examples/gem/Gemfile.lock b/examples/gem/Gemfile.lock index f426524..8bc6670 100644 --- a/examples/gem/Gemfile.lock +++ b/examples/gem/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: ../.. specs: - rcm (0.1.1) + rcm (0.1.2) erb toml (~> 0.3) diff --git a/examples/plain_ruby/Justfile b/examples/plain_ruby/Justfile index c758519..a4528ce 100644 --- a/examples/plain_ruby/Justfile +++ b/examples/plain_ruby/Justfile @@ -9,3 +9,15 @@ dry: # Verbose output debug: ruby config.rb --debug + +# Apply the agent-backed example +agents: + ruby agents.rb + +# Dry run the agent-backed example +agents-dry: + ruby agents.rb --dry + +# Verbose output for the agent-backed example +agents-debug: + ruby agents.rb --debug diff --git a/examples/plain_ruby/README.md b/examples/plain_ruby/README.md index 7208317..464d537 100644 --- a/examples/plain_ruby/README.md +++ b/examples/plain_ruby/README.md @@ -13,6 +13,10 @@ ruby config.rb --debug # Apply configuration ruby config.rb + +# Agent-backed file processing example +ruby agents.rb --dry +ruby agents.rb ``` ## What it does @@ -20,3 +24,4 @@ ruby config.rb - Creates `/tmp/example/hello.txt` with static content (parent directory created automatically) - Ensures the line `127.0.0.1 localhost` is present in `/tmp/example/hosts.txt` - Creates `/tmp/example/greeting.txt` from an inline ERB template +- `agents.rb` drafts `/tmp/example/notes.txt` and then runs it through `hexai` with a prompt that fixes English grammar and clarity diff --git a/examples/plain_ruby/agents.rb b/examples/plain_ruby/agents.rb new file mode 100755 index 0000000..e04da98 --- /dev/null +++ b/examples/plain_ruby/agents.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# Example: Plain Ruby script using agent-backed file processing. +# +# Run with: +# ruby agents.rb --dry # dry run, no changes made +# ruby agents.rb --debug # verbose output +# ruby agents.rb # apply configuration +# +# Requires rcm to be installed as a gem, or adjust the path below: +# require_relative '../../lib/dsl' +begin + require 'rcm' +rescue LoadError + require_relative '../../lib/dsl' +end + +configure do + agent hexai do + 'hexai PROMPT' + end + + prompt fix english do + 'Correct English spellings and grammar. Improve clarity of the text. Dont introduce any new text or headers' + end + + # Draft a rough note, then let hexai polish the language in place. + file example notes draft do + path 'agents_example.txt' + manage directory + 'this are a short note with bad english and unclear wording.' + end + + file example notes polished do + path 'agents_example.txt' + requires file example notes draft + agent hexai fix english + end +end diff --git a/examples/plain_ruby/agents_example.txt b/examples/plain_ruby/agents_example.txt new file mode 100644 index 0000000..1285e52 --- /dev/null +++ b/examples/plain_ruby/agents_example.txt @@ -0,0 +1 @@ +This is a short note with poor English and unclear wording.
\ No newline at end of file diff --git a/examples/plain_ruby/config.rb b/examples/plain_ruby/config.rb index c730c05..93061c2 100755 --- a/examples/plain_ruby/config.rb +++ b/examples/plain_ruby/config.rb @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # Example: Plain Ruby script — no Rake, no bundler required. # # Run with: diff --git a/examples/rake/Gemfile.lock b/examples/rake/Gemfile.lock new file mode 100644 index 0000000..57fd030 --- /dev/null +++ b/examples/rake/Gemfile.lock @@ -0,0 +1,26 @@ +PATH + remote: ../.. + specs: + rcm (0.1.2) + erb + toml (~> 0.3) + +GEM + remote: https://rubygems.org/ + specs: + erb (6.0.2) + parslet (2.0.0) + rake (13.3.1) + toml (0.3.0) + parslet (>= 1.8.0, < 3.0.0) + +PLATFORMS + ruby + x86_64-linux + +DEPENDENCIES + rake + rcm! + +BUNDLED WITH + 2.6.9 |
