Some checks failed
ci / cargo test (abacus) (push) Has been cancelled
ci / cargo test (agent-runtime) (push) Has been cancelled
ci / cargo test (context-passport) (push) Has been cancelled
ci / cargo test (game-economy) (push) Has been cancelled
ci / cargo test (ledgerline) (push) Has been cancelled
ci / cargo test (mint) (push) Has been cancelled
ci / cargo test (rago) (push) Has been cancelled
ci / cargo test (relay) (push) Has been cancelled
ci / cargo test (toolgate) (push) Has been cancelled
ci / cargo test (turnstile) (push) Has been cancelled
ci / cargo test (vend) (push) Has been cancelled
ci / node suites (push) Has been cancelled
New apps/rithub-export: one click at https://rithub.dev/export, or `rit export` from the CLI, produces a downloadable .tar.gz of every repo the signed-in account owns -- real `git bundle --all` per repo (+ wiki if any; `git clone <bundle>` reproduces the exact commits, no history rewriting), plus issues/pulls/releases+assets as documented JSON (the engine's own public API object shape, each issue/pull carrying its full comment thread). manifest.json indexes per-repo files + counts. - Two ways in, one job underneath: the web page authenticates via a one-time real OAuth2 (PKCE) consent, same "no pasted tokens" pattern as apps/rithub-approvals (own encrypted-at-rest token store, own data dir/key); `rit export` brings its own Bearer token, no browser round trip. Git traffic goes loopback-to-the-engine, never the public domain (same reasoning as the 2026-11-26 import-timeout fix). - One export at a time, box-wide (jobStore.mjs's boxTooBusy/ hasActiveJob, os.loadavg() read directly) -- a request while busy gets a clear 503, matching railyard-box's own "no heavy job unless load1<6" rule instead of silently queuing a pile-up. - Opt-in nightly copy, kept 7 days on our side (nightly.mjs): a sweep every 24h exports every opted-in login with a stored token, then prunes every archive past the retention window. An opt-in copy to the user's OWN storage target needs their own credentials -- documented as a real, separate follow-up, not built this pass (nightly.mjs's own comment has the exact extension point). - Scope stated plainly: every repo the account *owns*, not an org repo it merely has access to -- org export is a natural follow-up. Real bug found live while building this, fixed before shipping: the token used to travel to `git clone` as a `-c http.extraHeader=...` argv element, which Node's own child_process error message echoes back verbatim the moment a clone legitimately fails (e.g. a repo with no wiki yet) -- putting the raw token into this job's own persisted log, served back through /export/api/jobs. Fixed via GIT_CONFIG_KEY_0/VALUE_0 env vars instead of argv (git >=2.31); jobStore.mjs's appendLog also redacts any token-shaped substring as an independent second layer. Confirmed live after the fix: the exact same failing clone (nonexistent wiki) no longer has the token anywhere in its error text or the on-disk index. `rit export` added (packages/rithub-cli/src/export.mjs); CLI bumped 0.3.2 -> 0.3.5 across this pass and the sibling RIT-ACT commit (--agent/export flags + README), published, confirmed live. Live-verified on rithub.dev with a throwaway mail.tm test account, 2 repos, an issue+comment, a PR+comment, and a release+asset: `rit export` produced an archive whose manifest counts (2 repos, 1 issue, 1 pull, 1 release, 1 asset) matched the live API exactly; `git clone` from both repo bundles reproduced byte-for-byte the real branch SHAs (including a non-default branch carrying an open PR); the issue/PR JSON carried the real comment bodies; the release asset's downloaded bytes matched the uploaded file exactly. Re-ran the same flow from the web UI (gstack): one-time Authorize, "Export now" click, Download -- same result. A different account's /export/api/jobs correctly saw an empty list (no cross-account leak). Test account and all artifacts purged after. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
259 lines
13 KiB
Markdown
259 lines
13 KiB
Markdown
# @recoder.xyz/rithub
|
|
|
|
Your GitHub account is a single point of failure. One flag, suspension, or
|
|
outage and every repo on it is unreachable until it's fixed. `rit` is a
|
|
`gh`-style command-line client for [Rithub](https://rithub.dev) that keeps
|
|
a live mirror there — `rit push` creates the repo on Rithub if it's
|
|
missing, then pushes, so importing your repos is one command, not a form.
|
|
|
|
```
|
|
npm i -g @recoder.xyz/rithub
|
|
```
|
|
|
|
(npm refuses the bare name `rithub` outright — "too similar to existing
|
|
package github" — confirmed again 2026-11-30 trying to publish under it
|
|
directly. The package stays scoped, but it installs **two** bin names:
|
|
`rit` and `rithub` — same binary, either one works.)
|
|
|
|
```
|
|
rit login # opens a browser for a real device-code sign-in
|
|
rit whoami
|
|
rit clone homeplan # bare name = your own account
|
|
rit clone caelum0x/homeplan # or owner/repo, for any repo you can see
|
|
rit repo create my-app --private
|
|
rit push # creates the repo on Rithub if missing, then pushes
|
|
rit logout
|
|
```
|
|
|
|
`rit login` with no `--token` runs a real RFC-8628-shaped device-code sign-in
|
|
(`https://rithub.dev/device`): it prints a short code, opens the browser
|
|
(best-effort -- still prints the URL either way), and polls until you
|
|
confirm there. The token is validated against the real account
|
|
(`GET /api/v1/user`) before anything is saved to
|
|
`~/.config/rithub/config.json` (written `0600`). `--paste-token` falls
|
|
back to the older "copy a token from Settings -> Applications" flow for a
|
|
box with no outbound access to the sign-in endpoints.
|
|
|
|
**Agent identity, enforced at sign-in, not opt-in (2026-12-01):** every
|
|
device sign-in defaults to an **agent** credential -- a force-push, a
|
|
branch delete, or a push to a protected branch made with it is held for a
|
|
human to approve at `https://rithub.dev/approvals`, even with plain `git`,
|
|
even if that token never runs through `rit` at all. A human signing in
|
|
for themselves unticks "this is me" on the `/device` page to get the
|
|
old, unmarked, behaves-exactly-like-before personal token. `rit login
|
|
--agent` removes that choice entirely for a scripted/CI caller where no
|
|
human will be looking at the page. A one-click **"New agent token"**
|
|
button at `https://rithub.dev/user/settings/applications` ("Agent tokens"
|
|
panel) mints one without any device flow at all, and the same panel lists
|
|
every agent-identity token for one-click revoke (which stops that
|
|
credential from pushing anything through Rithub's git-smart-HTTP gateway
|
|
from then on).
|
|
|
|
That device-flow prompt only happens at a real TTY. Run `rit login` with no
|
|
`--token`/`RITHUB_TOKEN` from a non-interactive session -- an agent, CI,
|
|
anything with stdin open but nobody there to answer it -- and it fails
|
|
immediately with a clear message instead of hanging forever (confirmed
|
|
live, 2026-11-30/12-01, that the previous version could hang
|
|
indefinitely on exactly that stdin shape):
|
|
|
|
```
|
|
rit login: not an interactive terminal -- pass a token instead of pasting
|
|
one: `rit login --token <token>` or `RITHUB_TOKEN=<token> rit login`.
|
|
Get one at https://rithub.dev/user/settings/applications.
|
|
```
|
|
|
|
`rit clone <owner/repo>` while signed out, on a repo that's either
|
|
private or doesn't exist, says so plainly instead of a bare "not found"
|
|
and exits non-zero:
|
|
|
|
```
|
|
rit clone: not signed in, and caelum0x/afterbeat was not found while
|
|
signed out -- if it's private, run `rit login` first (or set
|
|
RITHUB_TOKEN), then retry
|
|
```
|
|
|
|
**Scopes:** cloning and pushing to a repo that already exists needs
|
|
`read:user` + `write:repository`. Creating one — `rit repo create` and
|
|
`rit push`'s auto-create path — additionally needs **`write:user`**:
|
|
confirmed live, 2026-11-30, that Rithub's own
|
|
`POST /api/v1/user/repos` route is gated on that scope, not
|
|
`write:repository` as the name would suggest. `rit login` tells you
|
|
this up front.
|
|
|
|
Private repos never get their token written to disk: `rit clone` and
|
|
`rit push` pass it on `-c http.extraHeader=Authorization: token <...>`
|
|
for that single `git` invocation only (plus `-c credential.helper=` so
|
|
a cached OS credential can't silently swap in a different account) —
|
|
verified live against a private repo that the resulting `.git/config`
|
|
has no token or header in it.
|
|
|
|
## No account, no sign-in, no human: `rit init`
|
|
|
|
One command gives an AI coding agent (or a person) a real Rithub
|
|
account, an access token scoped to one repo, and a first repo — then
|
|
`git push` works, with no login step at all:
|
|
|
|
```
|
|
$ npx @recoder.xyz/rithub init
|
|
Live in 0.9s: agent-lwlvjdtj -> https://rithub.dev/agent-lwlvjdtj/first-repo
|
|
git remote 'origin' set to agent-lwlvjdtj/first-repo. Next: git add -A && git commit -m "first commit" && git push -u origin main
|
|
Unclaimed: a small repo quota applies. Keep this account: rithub claim --email you@example.com
|
|
```
|
|
|
|
Re-running `rit init` in the same directory reuses the account from
|
|
`.rithub/agent.json` (gitignored automatically) instead of signing up again.
|
|
|
|
A small repo quota applies until a human claims the account:
|
|
|
|
```
|
|
npx @recoder.xyz/rithub claim --email you@example.com
|
|
```
|
|
|
|
This sets the account's real email and lifts the quota. Afterward, open
|
|
<https://rithub.dev/user/forgot_password> with the same email to set a
|
|
real password and sign in as the account in a browser — no separate
|
|
claim-token system, just Rithub's own password-reset mail.
|
|
|
|
## How `init`/`claim` work
|
|
|
|
`init` solves a small proof-of-work challenge (cheap for a machine,
|
|
expensive for mass abuse — no CAPTCHA, since an agent cannot solve one),
|
|
then calls the signup route that [`apps/rithub-mcp`](../../apps/rithub-mcp)
|
|
already exposes at `rithub.dev` next to its MCP endpoint:
|
|
|
|
```
|
|
GET https://rithub.dev/agent-signup/challenge -> { challenge, bits }
|
|
POST https://rithub.dev/agent-signup { challenge, nonce, repo_name? }
|
|
POST https://rithub.dev/agent-signup/claim (Bearer <token>) { email }
|
|
```
|
|
|
|
An agent that would rather skip the CLI and call the API directly can do
|
|
exactly that — same two JSON endpoints, no SDK required. Everything
|
|
else (`login`/`clone`/`repo create`/`push`) talks to Rithub's own
|
|
REST API at `/api/v1` with a plain `fetch` — no SDK there either.
|
|
|
|
## Commands
|
|
|
|
The original surface (unchanged):
|
|
|
|
```
|
|
rit init [--repo <name>] [--api-url <url>] [--json]
|
|
rit claim --email <you@example.com> [--json]
|
|
rit login [--token <token>] [--agent] [--paste-token] [--api-url <url>] [--json]
|
|
rit logout [--json]
|
|
rit whoami [--json]
|
|
rit clone <owner/repo|repo> [dir] [--json]
|
|
rit push [--private] [--name <name>] [--json]
|
|
rit export [--output <path>] [--nightly on|off] [--json]
|
|
rit help, --help, -h
|
|
rit --version, -v
|
|
```
|
|
|
|
**`rit export`** (RIT-RET, 2026-12-01): one archive of every repo you own --
|
|
real `git bundle --all` for each repo (and its wiki, if any; `git clone
|
|
<bundle>` reproduces the exact commits, no history rewriting), plus
|
|
issues/pulls/releases+assets as documented JSON (the engine's own public
|
|
API object shape). Same job as the one-click `https://rithub.dev/export`
|
|
page, just without the browser round trip. `rit export --nightly on`
|
|
opts into a 7-day-retained nightly copy kept server-side instead of
|
|
running an export now.
|
|
|
|
The full `gh`-parity surface added on top of it, every command taking
|
|
`--repo <owner/name>` to override inferring the repo from the current
|
|
directory's git remote, and `--json` for machine-readable output:
|
|
|
|
| Command | Subcommands |
|
|
| --- | --- |
|
|
| `rit repo` | `create <name> [--private] [--description <t>]`, `list [owner]`, `view <owner/repo\|repo>`, `fork <owner/repo>`, `delete <owner/repo> --confirm`, `rename <owner/repo> <new-name>`, `edit <owner/repo> [--description <t>] [--private\|--public]`, `archive <owner/repo> [--unarchive]`, `sync <git-url> [--name <n>] [--private]`, `sync-now <owner/repo>`, `import <git-url> [--name <n>] [--private]` |
|
|
| `rit issue` | `list [--state open\|closed\|all] [--search <q>]`, `create --title <t> [--body <t>]`, `view <n>`, `close <n>`, `reopen <n>`, `edit <n> [--title <t>] [--body <t>]`, `comment <n> --body <t>` |
|
|
| `rit change` (alias `rit pr`) | `list [--state ...]`, `create --title <t> [--head <b>] [--base <b>] [--body <t>]`, `view <n>`, `checkout <n>`, `diff <n>`, `merge <n> [--squash\|--rebase] [--delete-branch]`, `close <n>`, `comment <n> --body <t>`, `review approve <n> [--body <t>]` |
|
|
| `rit release` | `list`, `create <tag> [--title <t>] [--notes <t>] [--draft] [--prerelease] [--asset <path>]...`, `view <tag>`, `delete <tag>` |
|
|
| `rit branch` | `list`, `delete <name>`, `protect <name> [--required-approvals <n>]` |
|
|
| `rit label` | `list`, `create <name> --color <hex> [--description <t>]` |
|
|
| `rit milestone` | `list`, `create <title> [--description <t>] [--due <date>]` |
|
|
| `rit key` | `list`, `add <title> <key-or-path> [--read-only]` (account SSH keys) |
|
|
| `rit secret` | `list`, `set <NAME> <value>` (repo Actions secrets -- values are write-only) |
|
|
| `rit webhook` | `list`, `create --url <url> [--events a,b] [--secret <t>]` |
|
|
| `rit org` | `list`, `view <org>` |
|
|
| `rit user` | `view <username>` |
|
|
| `rit search` | `repos <query>`, `issues <query> [--type issues\|pulls] [--owner <o>]`, `code` (no server endpoint -- fails loudly, see below) |
|
|
| `rit status` | your assigned issues, open changes, and changes awaiting your review -- the one command not scoped to a single repo |
|
|
| `rit browse` | `[issue\|change <n>] [--print-url]` -- opens the repo/issue/change in the real browser, or just prints the URL |
|
|
| `rit api` | `<path> [--method <m>] [--field k=v]... [--input -\|@file]` -- raw authenticated request against `/api/v1`, like `gh api` |
|
|
|
|
`RITHUB_API_URL` overrides the default `https://rithub.dev` (useful for
|
|
local development against this repo's own test fixtures). `RITHUB_TOKEN`
|
|
overrides the saved login for one command. Zero runtime dependencies,
|
|
plain `node:fetch`/`node:child_process`/`node:fs`, Node >= 18.
|
|
|
|
### Scopes, found live (2026-12-01)
|
|
|
|
A token's scopes gate whole command groups, and the gate is stricter
|
|
than the names suggest -- confirmed against this server's own 403s while
|
|
building this, not assumed from the API docs:
|
|
|
|
- `read:repository` / `write:repository`: `repo`, `branch`, `secret`,
|
|
`webhook`, `release`, and (surprisingly) `change`/`pr` itself --
|
|
opening, viewing, diffing, checking out, and merging a change all
|
|
worked with a token that had **no** issue scope at all.
|
|
- `read:issue` / `write:issue`: `issue`, `label`, `milestone`, `status`,
|
|
and commenting on a `change` (Rithub's own PR comments reuse the issue
|
|
comment endpoint, so they need the issue scope even though opening the
|
|
PR itself didn't).
|
|
- `read:user` + `read:organization`: `org list`/`org view`.
|
|
|
|
The token this package was built and verified with
|
|
(`write:repository,write:user` only, confirmed via `rit whoami`'s own
|
|
account settings page) covers every `repo`/`branch`/`secret`/`webhook`/
|
|
`release`/`change` command end to end, but 403s on `issue`/`label`/
|
|
`milestone`/`status`/`change comment`/`org`. Generating a new token with
|
|
the broader scope list needs the real rithub.dev web session (password,
|
|
no API route creates a scoped token from an existing token) -- that part
|
|
is a standing owner-only step, not a CLI bug.
|
|
|
|
### `rit search code`
|
|
|
|
There is no code-search REST endpoint on this server (checked its own
|
|
`swagger.v1.json`, 2026-12-01 -- only repo/issue/user/org/team search
|
|
exist). `rit search code` says so and exits non-zero rather than
|
|
pretending to search and silently returning nothing.
|
|
|
|
## Server change this would need
|
|
|
|
Done, 2026-12-01: a real RFC-8628-shaped device-authorization flow now
|
|
exists server-side (`apps/rithub-device-auth`, `POST /api/rit/device/code`
|
|
+ `GET /device` + `POST /api/rit/device/token`), wrapping the engine's own
|
|
OAuth2 "Rit CLI" application via PKCE -- `rit login`'s browser + poll flow
|
|
above, not the old paste-a-token fallback (`--paste-token` keeps that path
|
|
for a box with no outbound access to the device-flow endpoints). Every
|
|
token it hands out is marked agent-identity server-side at the moment
|
|
it's minted, unless the human opts out on the `/device` page -- see
|
|
`apps/rithub-approvals/src/agentSessionTokens.mjs` for the full
|
|
"enforced, not opt-in" design.
|
|
|
|
## Design notes
|
|
|
|
`src/http.mjs` is the shared request helper for every command added in
|
|
this round (`issue`/`change`/`release`/`branch`/`label`/`milestone`/
|
|
`key`/`secret`/`webhook`/`org`/`user`/`search`/`status`/`browse`/`api`).
|
|
The original `login`/`clone`/`repo create`/`push` surface
|
|
(`src/auth.mjs`/`src/repo.mjs`/`src/init.mjs`) keeps its own small,
|
|
already-tested copy of the same JSON-call pattern rather than being
|
|
refactored to import it -- minimizing the diff to code that already had
|
|
passing tests and a careful token-handling writeup, rather than risking
|
|
a regression there for the sake of removing a few duplicated lines.
|
|
|
|
## Agent examples
|
|
|
|
```
|
|
# open a change from the current branch, wait for review, merge once approved
|
|
rit change create --title "fix: retry on 429" --base main --json
|
|
rit change merge 42 --squash --delete-branch --json
|
|
|
|
# triage: what needs this agent's attention right now, machine-readable
|
|
rit status --json
|
|
|
|
# anything this CLI doesn't have a dedicated command for yet
|
|
rit api /repos/caelum0x/scribase/commits --json
|
|
```
|