Skip to content

Commit 33e26d2

Browse files
committed
Update README, lint, and get CI working to auto-publish
1 parent 42355e1 commit 33e26d2

3 files changed

Lines changed: 33 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,17 @@ jobs:
3737
ruby-version: '3.4'
3838
bundler-cache: true
3939

40+
- name: Cache Claude CLI
41+
id: cache-claude
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.local/bin/claude
45+
key: claude-cli-${{ runner.os }}-${{ hashFiles('**/lockfile') || 'weekly' }}-${{ github.run_number % 100 }}
46+
restore-keys: |
47+
claude-cli-${{ runner.os }}-
48+
4049
- name: Install Claude Code CLI
50+
if: steps.cache-claude.outputs.cache-hit != 'true'
4151
run: curl -fsSL https://claude.ai/install.sh | bash
4252

4353
- name: Add Claude to PATH

README.md

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,13 @@ gem 'ruby_agent'
3737
```ruby
3838
require 'ruby_agent'
3939

40-
agent = RubyAgent.new(
41-
system_prompt: "You are a helpful assistant",
42-
model: "claude-sonnet-4-5-20250929"
43-
)
44-
45-
agent.on_assistant do |event, all_events|
46-
if event.dig("message", "content", 0, "type") == "text"
47-
text = event.dig("message", "content", 0, "text")
48-
puts "Assistant: #{text}"
49-
end
50-
end
51-
52-
agent.on_result do |event, all_events|
53-
puts "Result: #{event['subtype']}"
54-
agent.exit if event["subtype"] == "success"
55-
end
56-
57-
agent.connect do
58-
agent.ask("What is 1+1?", sender_name: "User")
59-
end
40+
agent = RubyAgent.new
41+
agent.on_result { |e, _| agent.exit if e["subtype"] == "success" }
42+
agent.connect { agent.ask("What is 2+2?") }
6043
```
6144

45+
That's it! Three lines to create an agent, ask Claude a question, and exit when done.
46+
6247
### Advanced Example with Callbacks
6348

6449
```ruby
@@ -219,9 +204,10 @@ end
219204
rake ci
220205

221206
# Or run tasks individually:
222-
rake ci:test # Run test suite
223-
rake ci:lint # Run RuboCop linter
224-
rake ci:scan # Run security audit
207+
rake ci:test # Run test suite
208+
rake ci:lint # Run RuboCop linter
209+
rake ci:lint:fix # Auto-fix linting issues
210+
rake ci:scan # Run security audit
225211
```
226212

227213
5. Commit your changes: `git commit -am 'Add some feature'`
@@ -251,7 +237,7 @@ We use RuboCop for code linting:
251237
rake ci:lint
252238

253239
# Auto-fix linting issues
254-
bundle exec rubocop -a
240+
rake ci:lint:fix
255241
```
256242

257243
### Publishing

Rakefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,25 @@ namespace :ci do
1515
sh "bundle exec rake test"
1616
end
1717

18-
desc "Run linter"
19-
task :lint do
20-
sh "bundle exec rubocop"
21-
rescue StandardError
22-
puts "Rubocop not configured yet, skipping..."
18+
namespace :lint do
19+
desc "Run linter"
20+
task :default do
21+
sh "bundle exec rubocop"
22+
end
23+
24+
desc "Auto-fix linting issues"
25+
task :fix do
26+
sh "bundle exec rubocop -a"
27+
end
2328
end
2429

2530
desc "Run security scan"
2631
task :scan do
2732
sh "bundle exec bundler-audit check --update"
28-
rescue StandardError
29-
puts "Bundler-audit not installed, skipping..."
3033
end
34+
35+
# alias ci:lint to ci:lint:default
36+
task lint: "lint:default"
3137
end
3238

3339
desc "Run all CI tasks"

0 commit comments

Comments
 (0)