···11`goat`: Go AT protocol CLI tool
22===============================
3344-**NOTE: this project is moving to a dedicated git repo at [bluesky-social/goat](https://github.com/bluesky-social/goat). This copy of the code is deprecated and will eventually be removed, though a notice will remain.**
55-66-77-This is a re-implementation of [adenosine-cli](https://gitlab.com/bnewbold/adenosine/-/tree/main/adenosine-cli?ref_type=heads) in golang.
88-99-1010-## Install
1111-1212-If you have the Go toolchain installed and configured correctly, you can directly build and install the tool for your local account:
1313-1414-```bash
1515-go install github.com/bluesky-social/goat@latest
1616-```
1717-1818-A more manual way to install is:
1919-2020-```bash
2121-git clone https://github.com/bluesky-social/goat
2222-go build .
2323-sudo cp goat /usr/local/bin
2424-```
2525-2626-The intention is to also provide a Homebrew "cask" and Debian/Ubuntu packages.
2727-2828-2929-## Usage
3030-3131-`goat` is relatively self-documenting via help pages:
3232-3333-```bash
3434-goat --help
3535-goat bsky -h
3636-goat help bsky
3737-# etc
3838-```
3939-4040-Most commands use public APIs are don't require authentication. Some commands, like creating records, require an atproto account. You can log in using an "app password" with `goat account login -u <handle> -p <app-password>`.
4141-4242-WARNING: `goat` will store both the app password and authentication tokens in the current users home directory, in cleartext. `goat logout` will wipe the file. Intention is to eventually support configuration via environment variables to keep sensitive state in a password manager or otherwise not-cleartext-on-disk.
4343-4444-Some commands output JSON, and you can use tools like `jq` to process them.
4545-4646-## Examples
4747-4848-Resolve an account's identity in the network:
4949-5050-```bash
5151-$ goat resolve wyden.senate.gov
5252-{
5353- "id": "did:plc:ydtsvzzsl6nlfkmnuooeqcmc",
5454- "alsoKnownAs": [
5555- "at://wyden.senate.gov"
5656- ],
5757- "verificationMethod": [
5858- {
5959- "id": "did:plc:ydtsvzzsl6nlfkmnuooeqcmc#atproto",
6060- "type": "Multikey",
6161- "controller": "did:plc:ydtsvzzsl6nlfkmnuooeqcmc",
6262- "publicKeyMultibase": "zQ3shuMW7q4KBdsFcdvebGi2EVv8KcqS24tF9Pg7Wh5NLB2NM"
6363- }
6464- ],
6565- "service": [
6666- {
6767- "id": "#atproto_pds",
6868- "type": "AtprotoPersonalDataServer",
6969- "serviceEndpoint": "https://shimeji.us-east.host.bsky.network"
7070- }
7171- ]
7272-}
7373-```
7474-7575-List record collection types for an account:
7676-7777-```bash
7878-$ goat ls -c dril.bsky.social
7979-app.bsky.actor.profile
8080-app.bsky.feed.post
8181-app.bsky.feed.repost
8282-app.bsky.graph.follow
8383-chat.bsky.actor.declaration
8484-```
8585-8686-Fetch a record from the network as JSON:
8787-8888-```bash
8989-$ goat get at://dril.bsky.social/app.bsky.feed.post/3kkreaz3amd27
9090-{
9191- "$type": "app.bsky.feed.post",
9292- "createdAt": "2024-02-06T18:15:19.802Z",
9393- "langs": [
9494- "en"
9595- ],
9696- "text": "I do not Fucking recall them asking the blue sky elders permission to open registration to commoners ."
9797-}
9898-```
9999-100100-Make a public snapshot of your account:
101101-102102-```bash
103103-$ goat repo export jay.bsky.team
104104-downloading from https://morel.us-east.host.bsky.network to: jay.bsky.team.20240811183155.car
105105-106106-$ downloading blobs to: jay.bsky.team_blobs
107107-jay.bsky.team_blobs/bafkreia2x4faux5y7v7v54yl5ebkbaek7z7nhmsd4cooubz3yj4zox34cq downloaded
108108-jay.bsky.team_blobs/bafkreia3qgbww7odprmysd6jcyxoh5sczkwoxinnmzpsp73gs623fqfm3a downloaded
109109-jay.bsky.team_blobs/bafkreia3rgnywdrysy65vid42ulyno2cybxhxrn3ragm7cw3smmsxzvbs4 downloaded
110110-[...]
111111-```
112112-113113-Show PLC history for a single account, or make a snapshot of all PLC records (this takes a while), or monitor new ops:
114114-115115-```bash
116116-$ goat plc history atproto.com
117117-[...]
118118-119119-$ goat plc dump | pv -l | gzip > plc_snapshot.json.gz
120120-[...]
121121-122122-$ goat plc dump --cursor now --tail
123123-[...]
124124-```
125125-126126-Verify syntax and generate TIDs:
127127-128128-```bash
129129-$ goat syntax handle check xn--fiqa61au8b7zsevnm8ak20mc4a87e.xn--fiqs8s
130130-valid
131131-132132-$ goat syntax rkey check dHJ1ZQ==
133133-error: recordkey syntax didn't validate via regex
134134-135135-$ goat syntax tid inspect 3kzifvcppte22
136136-Timestamp (UTC): 2024-08-12T02:08:03.29Z
137137-Timestamp (Local): 2024-08-11T19:08:03-07:00
138138-ClockID: 0
139139-uint64: 0x187dcbda2b5ca800
140140-```
141141-142142-The `firehose` commands subscribes to the repo commit stream from a Relay. The default stream outputs event metadata, but doesn't include record blocks (bytes). The `--ops` variant will unpack records and output one line per record operation (instead of one line per commit event), and includes the record values themselves. Some example invocations:
143143-144144-```bash
145145-# possible handle updates
146146-$ goat firehose --account-events | jq .payload.handle
147147-[...]
148148-149149-# text of posts (empty lines for post-deletions)
150150-$ goat firehose - app.bsky.feed.post --ops | jq .record.text
151151-[...]
152152-153153-# sample ratio of languages in current posts
154154-$ goat firehose --ops -c app.bsky.feed.post | head -n100 | jq .record.langs[0] -c | sort | uniq -c | sort -nr
155155- 51 "en"
156156- 33 "ja"
157157- 7 null
158158- 3 "pt"
159159- 2 "ko"
160160- 1 "th"
161161- 1 "id"
162162- 1 "es"
163163- 1 "am"
164164-```
165165-166166-A minimal bsky posting interface, requires account login:
167167-168168-```bash
169169-$ goat bsky post "hello from goat"
170170-```
44+**NOTE: this project has been moved to a dedicated git repo at [bluesky-social/goat](https://github.com/bluesky-social/goat)**