Ruby CLI tool for accessing Bluesky API / ATProto

added readme

Changed files
+130 -17
+130 -17
README.md
··· 1 - # Ratproto 1 + # RatProto – Ruby ATProto Tool 🐀 2 + 3 + `rat` is a small command-line tool for working with the **Bluesky AT Protocol** from Ruby. 4 + 5 + It builds on top of the existing ATProto Ruby gems: 6 + 7 + - [`minisky`](https://ruby.sdk.blue/minisky/) — XRPC client for PDS/AppView 8 + - [`skyfall`](https://ruby.sdk.blue/skyfall/) — firehose & Jetstream streaming 9 + - [`didkit`](https://ruby.sdk.blue/didkit/) — DID & handle resolution 10 + 11 + You can use `rat` to: 12 + 13 + - fetch AT Protocol records 14 + - stream firehose / Jetstream commits with optional filters 15 + - resolve DIDs & handles 16 + 2 17 3 - TODO: Delete this and the text below, and describe your gem 18 + > [!CAUTION] 19 + > Here be dragons - currently 100% vibe-coded using ChatGPT. Seems to be working correctly. Will be rewritten manually in the next version :) 4 20 5 - Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ratproto`. To experiment with that code, run `bin/console` for an interactive prompt. 6 21 7 22 ## Installation 8 23 9 - TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. 24 + ``` 25 + gem install ratproto 26 + ``` 27 + 28 + 29 + ## Usage 30 + 31 + ``` 32 + rat fetch at://<did>/<collection>/<rkey> 33 + rat stream <relay.host> [options] 34 + rat resolve <did-or-handle> 35 + ``` 36 + 37 + 38 + ### Fetching a record 39 + 40 + Use an at:// URI to fetch a record directly from the user’s PDS: 41 + 42 + ``` 43 + rat fetch at://did:plc:abcd1234/app.bsky.feed.post/3kz4vx5j 44 + ``` 45 + 46 + Example output: 47 + 48 + ``` 49 + { 50 + "$type": "app.bsky.feed.post", 51 + "text": "hello world 👋", 52 + "createdAt": "2025-01-01T12:34:56.789Z" 53 + } 54 + ``` 55 + 56 + ### Resolving a DID or handle 57 + 58 + You can resolve either a DID: 59 + 60 + ``` 61 + rat resolve did:plc:abcd1234 62 + ``` 63 + 64 + or a handle: 65 + 66 + ``` 67 + rat resolve @example.com 68 + ``` 69 + 70 + Example output: 71 + 72 + ``` 73 + did:plc:abcd1234 74 + { 75 + "@context": "...", 76 + "id": "did:plc:abcd1234", 77 + ... 78 + } 79 + ``` 80 + 81 + ### Streaming commit events 82 + 83 + Rat can connect to either a relay/PDS firehose, or a Jetstream JSON stream: 84 + 85 + ``` 86 + rat stream bsky.network 87 + ``` 88 + 89 + You’ll see output like: 90 + 91 + ``` 92 + [2025-01-02T12:34:56+01:00] did:plc:abcd1234 :create app.bsky.feed.post 3rblblbl {"text":"hi"} 93 + [2025-01-02T12:34:57+01:00] did:plc:efgh5678 :delete app.bsky.graph.follow 3szxczxc 94 + ``` 95 + 96 + Press Ctrl-C to disconnect. 97 + 98 + To use Jetstream, add `--jetstream` or `-j`: 99 + 100 + ``` 101 + rat stream -j jetstream1.us-east.bsky.network 102 + ``` 103 + 104 + #### Filtering by DID and/or collection 105 + 106 + You can filter on DID: 107 + 108 + ``` 109 + rat stream jetstream1.us-east.bsky.network \ 110 + --jetstream \ 111 + --did did:plc:abcd1234,did:plc:wxyz9999 112 + ``` 10 113 11 - Install the gem and add to the application's Gemfile by executing: 114 + Or collection: 12 115 13 - ```bash 14 - bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG 116 + ``` 117 + rat stream jetstream1.us-east.bsky.network \ 118 + --jetstream \ 119 + --collection app.bsky.feed.post 15 120 ``` 16 121 17 - If bundler is not being used to manage dependencies, install the gem by executing: 122 + Or both: 18 123 19 - ```bash 20 - gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG 124 + ``` 125 + rat stream jetstream1.us-east.bsky.network \ 126 + --jetstream \ 127 + -d did:plc:abcd1234 \ 128 + -c app.bsky.feed.post,app.bsky.graph.follow 21 129 ``` 22 130 23 - ## Usage 131 + You can repeat both options instead if you prefer: 24 132 25 - TODO: Write usage instructions here 133 + ``` 134 + rat stream host --jetstream -d did:1 -d did:2 -c app.bsky.feed.post 135 + ``` 26 136 27 - ## Development 137 + #### Starting from a cursor 28 138 29 - After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. 139 + ``` 140 + rat stream host -r 12345 141 + ``` 142 + 30 143 31 - To install this gem onto your local machine, run `bundle exec rake install`. 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). 144 + ## Credits 32 145 33 - ## Contributing 146 + Copyright © 2026 Kuba Suder ([@mackuba.eu](https://bsky.app/profile/mackuba.eu)) & ChatGPT. 34 147 35 - Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ratproto. 148 + The code is available under the terms of the [zlib license](https://choosealicense.com/licenses/zlib/) (permissive, similar to MIT).