- Python 94%
- TypeScript 6%
atproto-tools #
A command line interface for Tangled repositories — issues
and pull requests for AT Protocol, in the spirit of GitHub's gh, minus most
of the parts you don't need.
Zero external dependencies: Python standard library only.
Install #
uv sync
uv run tg --help
Or install the tg executable onto your path:
uv tool install .
Using it #
tg works out which repository you mean from your tangled.org git remote, so
inside a clone you can just say:
tg issue list
tg pr create --title "Fix the parser" --source fix-parser
Pass --repo (or -R) to override, and --handle when the repository is owned
by a different account than the one in your config.
Issues #
tg issue list # open issues, numbered in creation order
tg issue list --state all
tg issue view 3 # by number, record key, or AT-URI
tg issue view 3 --comments
tg issue create --title "Crash on empty input" --body "$(cat notes.md)"
tg issue comment 3 --body "Reproduced on 3.13"
tg issue close 3
Pull requests #
tg pr list
tg pr list --state merged
tg pr view 2
tg pr create --title "Add tests" --source add-tests --target main
tg pr update 2 # re-push the current branch as a new round
tg pr comment 2 --body "Please rebase"
tg pr close 2 --merged
tg pr create diffs origin/<target>..<source>, gzips the patch, uploads it as
a blob, and creates the pull record. tg pr update does the same and replaces
the record, which is how a second round of review is added.
Repositories #
tg repo list
tg repo view journal
Authentication #
Reads are public, so only writing needs a session:
tg auth login --handle example.me # prompts for a password
tg auth status
tg auth logout
Sessions are cached and refreshed automatically. For unattended use, set
EXAMPLE_ME_APP_PASS (the handle, uppercased, with dots as underscores)
instead of a password prompt.
Configuration #
repos.json, at $TANGLED_CONFIG_PATH (default ~/.config/tangled/repos.json),
maps repository names to the repository's DID and the handle that owns it:
{
"repos": {
"journal": {"did": "did:plc:...", "handle": "example.me"}
}
}
Sessions live at $ATPROTO_TOKEN_PATH (default ~/.config/atproto/token.json).
Raw XRPC #
tg api calls any endpoint directly and prints the JSON. It is the escape hatch
for the roughly 90% of the Tangled API that tg does not wrap yet.
tg api com.atproto.repo.listRecords '{"repo":"example.me","collection":"sh.tangled.repo.issue"}'
tg api com.atproto.repo.describeRepo '{"repo":"example.me"}'
cat body.json | tg api com.atproto.repo.createRecord - # '-' reads stdin
tg api com.atproto.repo.createRecord @body.json # '@file' reads a file
It resolves the account, attaches a cached session if there is one, and never
prompts — if a write fails, it tells you to run tg auth login.
Which host. Records live on the owner's PDS, but Tangled's git operations
live on the knot. tg api uses the PDS by default; pass --host knot for
git endpoints, or a full URL to aim anywhere. If you hit a sh.tangled.*
endpoint that the PDS doesn't serve, it points you at the knot.
HTTP method. Lexicon queries are GET and procedures are POST, and only
the lexicon knows which is which. By default tg api tries GET and retries as
POST if the server rejects the verb — safe, since a wrong verb is refused
before anything happens. Override with --method.
Secrets are refused. Any endpoint with secret in its name is blocked:
$ tg api sh.tangled.repo.addSecret '{"name":"FOO","value":"hunter2"}'
Error: sh.tangled.repo.addSecret is not reachable through tg api.
A secret passed as an argument ends up in your shell history, the process list and your scrollback, and reading one back prints it to your terminal. Manage secrets with the spindle's secret store instead.
How Tangled stores things #
Everything a Tangled repository knows lives as AT Protocol records on the owner's PDS — not on the knot, which serves git:
| Collection | Holds |
|---|---|
sh.tangled.repo |
one record per repository, rkey = repo name |
sh.tangled.repo.issue |
issues, pointing at their repo by repo DID |
sh.tangled.repo.issue.state |
open/closed, as a separate event record |
sh.tangled.repo.issue.comment |
issue comments |
sh.tangled.repo.pull |
pull requests, carrying a gzipped patch blob |
sh.tangled.repo.pull.status |
open/closed/merged, also as separate events |
sh.tangled.repo.pull.comment |
pull request comments |
Two consequences shape the CLI:
- State is event-sourced. An issue or pull request is open until a record
says otherwise, and the newest record wins.
tg issue closewrites a state record; it never mutates the issue. - There are no sequential numbers. Records are keyed by TID.
tgderives display numbers from creation order, the way the web UI does, and also accepts the raw record key or a full AT-URI wherever it takes an issue or PR.
Layout #
cli/ the tg command: argument parsing and output
tangled.py record-level operations (issues, pulls, state, comments)
gitutil.py git remote detection and patch generation
config.py repos.json and session paths
auth/ session lifecycle: cached token, refresh, re-authenticate
xrpc/ XRPC transport and record helpers
Tests #
uv run pytest tests/ -q
uv run ruff check .