- Ruby 3.2 or newer.
- Bundler.
gem "autohand_sdk", git: "https://github.com/autohandai/code-agent-sdk-ruby"bundle installInstall the Autohand Code CLI:
bundle exec autohand-sdk install-cli
bundle exec autohand-sdk doctorThe installer downloads the correct platform binary from the Autohand Code CLI GitHub release and installs it into ~/.autohand/bin.
require "autohand_sdk"
AutohandSDK::Client.open(cwd: ".") do |sdk|
sdk.stream_prompt("Explain this repository in three bullets").each do |event|
print event["delta"] if event["type"] == "message_update"
end
endUse cli_path: during local CLI development:
AutohandSDK::Client.open(cli_path: "/path/to/autohand", cwd: ".") do |sdk|
puts sdk.get_state
endagent = AutohandSDK::Agent.create(
cwd: ".",
instructions: "Prefer minimal, well-tested Ruby changes.",
permission_mode: "interactive"
)
result = agent.run("Find the highest-risk release blockers")
puts result.fetch(:text)
agent.closePrefer .open when the client should always close:
AutohandSDK::Agent.open(cwd: ".") do |agent|
puts agent.run("Summarize the current git diff").fetch(:text)
end