claude-code-sdk-ruby 0.1.0 → 0.1.1
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/CHANGELOG.md +12 -6
- data/README.md +7 -7
- data/examples/bypass_permissions.rb +34 -0
- data/lib/claude_sdk/internal/transport/subprocess_cli.rb +18 -1
- data/lib/claude_sdk/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201bb35600be5d00c23889cd6da0de9052423babcc686ce4b49bd67922b76144
|
4
|
+
data.tar.gz: d0f26949887331ef0ee43dba2131df613d4a823e4dcfa8a64b7435e89d4b1737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e14672cb48c916ed7536f9a695cf2e38a6d75df6728b4dffcdb22dd92cdab307eda60b56652e82d06ff723509097a0d0b4bfc04cabc175d1f6a3fcb6463ebc
|
7
|
+
data.tar.gz: 82e050ae3ada3def50e92fa74d937331cbae601f85184be9eb407a2b18da3c3e0d48851cfda59813a7e93444f219ccbae9a889fdb4b583ec8ff5e41c560e5dea
|
data/CHANGELOG.md
CHANGED
@@ -7,13 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
-
|
11
|
-
- Removed unused `async-process` dependency
|
10
|
+
## [0.1.1] - 2025-07-15
|
12
11
|
|
13
|
-
|
12
|
+
### Fixed
|
13
|
+
- Fixed permission mode conversion to use camelCase format for CLI compatibility
|
14
|
+
- `:bypass_permissions` now correctly converts to `"bypassPermissions"`
|
15
|
+
- `:accept_edits` now correctly converts to `"acceptEdits"`
|
16
|
+
- This ensures the SDK properly passes permission modes to the Claude CLI
|
17
|
+
|
18
|
+
## [0.1.0] - 2025-07-15
|
14
19
|
|
15
20
|
### Added
|
16
|
-
- Initial release of claude-sdk-ruby
|
21
|
+
- Initial release of claude-code-sdk-ruby
|
17
22
|
- Core SDK functionality for interacting with Claude Code CLI
|
18
23
|
- Support for async query processing
|
19
24
|
- Message types: User, Assistant, System, and Result
|
@@ -39,5 +44,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
39
44
|
- simplecov (~> 0.22)
|
40
45
|
- yard (~> 0.9)
|
41
46
|
|
42
|
-
[Unreleased]: https://github.com/
|
43
|
-
[0.
|
47
|
+
[Unreleased]: https://github.com/parruda/claude-code-sdk-ruby/compare/v0.1.1...HEAD
|
48
|
+
[0.1.1]: https://github.com/parruda/claude-code-sdk-ruby/compare/v0.1.0...v0.1.1
|
49
|
+
[0.1.0]: https://github.com/parruda/claude-code-sdk-ruby/releases/tag/v0.1.0
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Claude SDK Ruby
|
1
|
+
# Claude Code SDK Ruby
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/claude-sdk-ruby)
|
3
|
+
[](https://badge.fury.io/rb/claude-code-sdk-ruby)
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
5
5
|
|
6
6
|
Official Ruby SDK for interacting with Claude Code CLI. This gem provides a Ruby-idiomatic interface to Claude Code with full async support, proper error handling, and comprehensive type definitions.
|
@@ -10,7 +10,7 @@ Official Ruby SDK for interacting with Claude Code CLI. This gem provides a Ruby
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'claude-sdk-ruby'
|
13
|
+
gem 'claude-code-sdk-ruby'
|
14
14
|
```
|
15
15
|
|
16
16
|
And then execute:
|
@@ -22,7 +22,7 @@ bundle install
|
|
22
22
|
Or install it yourself as:
|
23
23
|
|
24
24
|
```bash
|
25
|
-
gem install claude-sdk-ruby
|
25
|
+
gem install claude-code-sdk-ruby
|
26
26
|
```
|
27
27
|
|
28
28
|
## Prerequisites
|
@@ -203,17 +203,17 @@ bundle exec rspec
|
|
203
203
|
COVERAGE=true bundle exec rspec
|
204
204
|
|
205
205
|
# Build the gem
|
206
|
-
gem build claude-sdk-ruby.gemspec
|
206
|
+
gem build claude-code-sdk-ruby.gemspec
|
207
207
|
|
208
208
|
# Install locally
|
209
|
-
gem install ./claude-sdk-ruby-0.1.0.gem
|
209
|
+
gem install ./claude-code-sdk-ruby-0.1.0.gem
|
210
210
|
```
|
211
211
|
|
212
212
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
213
213
|
|
214
214
|
## Contributing
|
215
215
|
|
216
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
216
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/parruda/claude-code-sdk-ruby.
|
217
217
|
|
218
218
|
## License
|
219
219
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "claude_sdk"
|
5
|
+
|
6
|
+
# Example showing how to use bypass permissions mode
|
7
|
+
# This will pass --permission-mode bypassPermissions to the CLI
|
8
|
+
|
9
|
+
options = ClaudeSDK::ClaudeCodeOptions.new(
|
10
|
+
permission_mode: :bypass_permissions,
|
11
|
+
)
|
12
|
+
|
13
|
+
client = ClaudeSDK::Client.new(options)
|
14
|
+
|
15
|
+
begin
|
16
|
+
response = client.query("List the files in the current directory")
|
17
|
+
|
18
|
+
response.each do |message|
|
19
|
+
if message["type"] == "user"
|
20
|
+
puts "User: #{message["content"]}"
|
21
|
+
elsif message["type"] == "assistant"
|
22
|
+
message["content"].each do |block|
|
23
|
+
if block["type"] == "text"
|
24
|
+
puts "Assistant: #{block["text"]}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue ClaudeSDK::CLINotFoundError => e
|
30
|
+
puts "Error: #{e.message}"
|
31
|
+
puts "Please install Claude Code CLI first"
|
32
|
+
rescue StandardError => e
|
33
|
+
puts "Error: #{e.message}"
|
34
|
+
end
|
@@ -334,7 +334,7 @@ module ClaudeSDK
|
|
334
334
|
cmd.push("--permission-prompt-tool", @options.permission_prompt_tool_name)
|
335
335
|
end
|
336
336
|
|
337
|
-
cmd.push("--permission-mode", @options.permission_mode
|
337
|
+
cmd.push("--permission-mode", format_permission_mode(@options.permission_mode)) if @options.permission_mode
|
338
338
|
|
339
339
|
cmd.push("--continue") if @options.continue_conversation
|
340
340
|
|
@@ -357,6 +357,23 @@ module ClaudeSDK
|
|
357
357
|
server.respond_to?(:to_h) ? server.to_h : server
|
358
358
|
end
|
359
359
|
end
|
360
|
+
|
361
|
+
# Convert permission mode from Ruby symbol format to CLI camelCase format
|
362
|
+
#
|
363
|
+
# @param mode [Symbol] the permission mode symbol
|
364
|
+
# @return [String] the camelCase formatted mode
|
365
|
+
def format_permission_mode(mode)
|
366
|
+
case mode
|
367
|
+
when :default
|
368
|
+
"default"
|
369
|
+
when :accept_edits
|
370
|
+
"acceptEdits"
|
371
|
+
when :bypass_permissions
|
372
|
+
"bypassPermissions"
|
373
|
+
else
|
374
|
+
mode.to_s
|
375
|
+
end
|
376
|
+
end
|
360
377
|
end
|
361
378
|
end
|
362
379
|
end
|
data/lib/claude_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claude-code-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Arruda
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: async
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- claude-code-sdk-ruby.gemspec
|
56
56
|
- examples/async_multiple_queries.rb
|
57
57
|
- examples/basic_usage.rb
|
58
|
+
- examples/bypass_permissions.rb
|
58
59
|
- examples/enumerator_usage.rb
|
59
60
|
- examples/error_handling.rb
|
60
61
|
- examples/mcp_servers.rb
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.6.
|
93
|
+
rubygems_version: 3.6.7
|
93
94
|
specification_version: 4
|
94
95
|
summary: Ruby SDK for Claude Code
|
95
96
|
test_files: []
|