diff --git a/README.md b/README.md index 99210ff..52a4474 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,148 @@ -# Ratproto +# RatProto – Ruby ATProto Tool 🐀 -TODO: Delete this and the text below, and describe your gem +`rat` is a small command-line tool for working with the **Bluesky AT Protocol** from Ruby. + +It builds on top of the existing ATProto Ruby gems: + +- [`minisky`](https://ruby.sdk.blue/minisky/) — XRPC client for PDS/AppView +- [`skyfall`](https://ruby.sdk.blue/skyfall/) — firehose & Jetstream streaming +- [`didkit`](https://ruby.sdk.blue/didkit/) — DID & handle resolution + +You can use `rat` to: + +- fetch AT Protocol records +- stream firehose / Jetstream commits with optional filters +- resolve DIDs & handles + + +> [!CAUTION] +> Here be dragons - currently 100% vibe-coded using ChatGPT. Seems to be working correctly. Will be rewritten manually in the next version :) -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. ## Installation -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. +``` +gem install ratproto +``` + -Install the gem and add to the application's Gemfile by executing: +## Usage -```bash -bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG ``` +rat fetch at://// +rat stream [options] +rat resolve +``` + -If bundler is not being used to manage dependencies, install the gem by executing: +### Fetching a record -```bash -gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG +Use an at:// URI to fetch a record directly from the user’s PDS: + +``` +rat fetch at://did:plc:abcd1234/app.bsky.feed.post/3kz4vx5j ``` -## Usage +Example output: + +``` +{ + "$type": "app.bsky.feed.post", + "text": "hello world 👋", + "createdAt": "2025-01-01T12:34:56.789Z" +} +``` + +### Resolving a DID or handle + +You can resolve either a DID: + +``` +rat resolve did:plc:abcd1234 +``` + +or a handle: + +``` +rat resolve @example.com +``` + +Example output: + +``` +did:plc:abcd1234 +{ + "@context": "...", + "id": "did:plc:abcd1234", + ... +} +``` + +### Streaming commit events -TODO: Write usage instructions here +Rat can connect to either a relay/PDS firehose, or a Jetstream JSON stream: -## Development +``` +rat stream bsky.network +``` + +You’ll see output like: + +``` +[2025-01-02T12:34:56+01:00] did:plc:abcd1234 :create app.bsky.feed.post 3rblblbl {"text":"hi"} +[2025-01-02T12:34:57+01:00] did:plc:efgh5678 :delete app.bsky.graph.follow 3szxczxc +``` + +Press Ctrl-C to disconnect. + +To use Jetstream, add `--jetstream` or `-j`: + +``` +rat stream -j jetstream1.us-east.bsky.network +``` + +#### Filtering by DID and/or collection + +You can filter on DID: + +``` +rat stream jetstream1.us-east.bsky.network \ + --jetstream \ + --did did:plc:abcd1234,did:plc:wxyz9999 +``` + +Or collection: + +``` +rat stream jetstream1.us-east.bsky.network \ + --jetstream \ + --collection app.bsky.feed.post +``` + +Or both: + +``` +rat stream jetstream1.us-east.bsky.network \ + --jetstream \ + -d did:plc:abcd1234 \ + -c app.bsky.feed.post,app.bsky.graph.follow +``` + +You can repeat both options instead if you prefer: + +``` +rat stream host --jetstream -d did:1 -d did:2 -c app.bsky.feed.post +``` + +#### Starting from a cursor + +``` +rat stream host -r 12345 +``` -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. -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). +## Credits -## Contributing +Copyright © 2026 Kuba Suder ([@mackuba.eu](https://bsky.app/profile/mackuba.eu)) & ChatGPT. -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ratproto. +The code is available under the terms of the [zlib license](https://choosealicense.com/licenses/zlib/) (permissive, similar to MIT).