summaryrefslogtreecommitdiff
path: root/examples/plain_ruby
diff options
context:
space:
mode:
Diffstat (limited to 'examples/plain_ruby')
-rw-r--r--examples/plain_ruby/Justfile12
-rw-r--r--examples/plain_ruby/README.md5
-rwxr-xr-xexamples/plain_ruby/agents.rb40
-rw-r--r--examples/plain_ruby/agents_example.txt1
-rwxr-xr-xexamples/plain_ruby/config.rb2
5 files changed, 60 insertions, 0 deletions
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: