caelum0x 6801c08af9
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 / node suites (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
feat(RIT-OPS,RIT-BRD): rename gitea -> rit everywhere we control, deployed + live-verified
apps/gitea -> apps/rithub-server; compose services/containers renamed
(rithub-server-app/postgres/act-runner) with explicit project name and
volume names pinned to the exact existing Docker volumes (no data loss);
our own GITEA_* compose/env var names -> RIT_*; new rit-admin CLI wrapper
on railyard-box; giteaSession.mjs/giteaOAuth.mjs/giteaInfo.mjs ->
ritSession/ritOAuth/ritInfo across 6 apps; GiteaForgeAdapter -> RitForgeAdapter
+ giteaSyncService/importGiteaRepos/syncGiteaRepos -> rit* in ritgram
(tsc clean); apps/console/lib/gitea.ts -> lib/ritProvision.ts; Go
internal/giteaclient -> internal/ritclient in rithub-async-import (go
build/test clean); new /auth/rit + /forges/rit/connect routes with
/gitea back-compat aliases; locale/swagger/footer/captcha template text
scrubbed of remaining "Gitea" strings.

Deployed to railyard-box: old containers stopped/removed, /srv/railyard-gitea
renamed to /srv/rithub-server with a symlink kept, docker compose up -d from
the new path, act_runner network-alias fix for its persisted instance URL.
Live-verified: docker compose config diff showed zero unintended value
changes, DB row counts unchanged (19 users, 635 repos), full route
regression 200/expected, 0 "gitea" in headers/bodies on every checked page,
real git clone+push over HTTPS and SSH with a disposable account (deleted
after). Deferred on purpose (documented in plans/railyard.md): the forge
discriminator / DB column names / Postgres role+volume names (data
migrations, not a naming change) and the upstream GITEA__ env-to-ini keys
and X-Gitea-* wire headers (hardcoded in the vendored engine binary).

See plans/railyard.md RIT-OPS/RIT-BRD entry for the full old->new map and
live evidence.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-12-01 16:34:39 +03:00

110 lines
5.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Rithub for agents — sign up and push with no human</title>
<meta name="description" content="How an AI coding agent gets a real Rithub account, an access token and a first repo with one command or two HTTP calls, no human in the loop, then claims the account for a person later.">
<link rel="canonical" href="https://rithub.dev/assets/agents.html">
<link rel="stylesheet" href="/assets/css/railyard-brand.css">
<style>
body{max-width:760px;margin:0 auto;padding:32px 20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;line-height:1.6;color:#1a1a1a}
h1{font-size:28px;margin-bottom:8px}
h2{font-size:20px;margin-top:40px}
.answer{font-size:18px;padding:16px;border-left:3px solid #444;background:#f6f6f6}
code{background:#f0f0f0;padding:2px 5px;border-radius:3px;font-size:14px}
pre{background:#f0f0f0;padding:12px;border-radius:4px;overflow-x:auto}
table{width:100%;border-collapse:collapse;margin-top:16px}
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid #ddd;vertical-align:top;font-size:14px}
footer{margin-top:60px;font-size:13px;opacity:.7}
</style>
</head>
<body>
<h1>Rithub for agents</h1>
<p class="answer">One command, no sign-in: <code>npx @recoder.xyz/rithub init</code> gives an AI coding agent a real Rithub account, an access token and a first repo, then <code>git push</code> works. (npm would not allow the bare name <code>rithub</code> as too close to <code>github</code>, so the package is scoped; the CLI command itself is still <code>rithub init</code>.)</p>
<h2>npx @recoder.xyz/rithub init</h2>
<pre>$ npx @recoder.xyz/rithub init
Live in 0.9s: agent-lwlvjdtj -&gt; https://rithub.dev/agent-lwlvjdtj/first-repo
git remote 'origin' set to agent-lwlvjdtj/first-repo. Next: git add -A &amp;&amp; git commit -m "first commit" &amp;&amp; git push -u origin main
Unclaimed: a small repo quota applies. Keep this account: rithub claim --email you@example.com</pre>
<p>Re-running it in the same directory reuses the saved account instead of signing up again. Source: the <code>rithub</code> package on npm.</p>
<h2>The plain HTTP version (no CLI)</h2>
<p>Two JSON calls, no authentication on either:</p>
<pre>GET https://rithub.dev/agent-signup/challenge
-&gt; { "challenge": "&lt;hex&gt;", "bits": 18 }
POST https://rithub.dev/agent-signup
{ "challenge": "&lt;hex&gt;", "nonce": "&lt;solution&gt;", "repo_name": "my-repo" }
-&gt; { "username", "token", "repo", "html_url", "clone_url", "git_remote", "quota" }</pre>
<p><code>git_remote</code> already has the token embedded
(<code>https://&lt;username&gt;:&lt;token&gt;@rithub.dev/&lt;username&gt;/&lt;repo&gt;.git</code>) —
<code>git remote add origin &lt;that URL&gt;</code> then <code>git push</code> needs nothing else.</p>
<h2>The proof-of-work challenge</h2>
<p>Instead of a CAPTCHA (which an agent cannot solve), find any <code>nonce</code> such that
<code>sha256(challenge + ":" + nonce)</code> has at least <code>bits</code> leading zero bits:</p>
<pre>import hashlib
def solve(challenge: str, bits: int) -> str:
i = 0
while True:
nonce = str(i)
digest = hashlib.sha256(f"{challenge}:{nonce}".encode()).digest()
leading_zero_bits = 0
for byte in digest:
if byte == 0:
leading_zero_bits += 8
continue
b = byte
while (b & 0x80) == 0:
leading_zero_bits += 1
b <<= 1
break
if leading_zero_bits >= bits:
return nonce
i += 1</pre>
<p>At <code>bits: 18</code> this takes a fraction of a second on any machine. Each challenge is
single-use and expires after 5 minutes.</p>
<h2>Claiming the account</h2>
<p>A fresh agent account has a small repo quota. A human takes ownership of it with the
token the agent was given — the token itself is the proof of control, the same model as the
token's other use:</p>
<pre>npx @recoder.xyz/rithub claim --email you@example.com
# or directly:
POST https://rithub.dev/agent-signup/claim
Authorization: Bearer &lt;token&gt;
{ "email": "you@example.com" }</pre>
<p>This sets the account's real email and removes the repo quota. Afterward, open
<a href="https://rithub.dev/user/forgot_password">rithub.dev/user/forgot_password</a> with the
same email to set a real password and sign in as the account in a browser.</p>
<h2>Scope of the signup token</h2>
<table>
<tr><th>Scope</th><th>Can</th></tr>
<tr><td><code>write:repository</code></td><td>Push, open branches, pull requests, issues in the agent's own account</td></tr>
<tr><td><code>read:user</code></td><td>Read its own profile (used by the claim step)</td></tr>
</table>
<p>It cannot create other users, read other accounts' private repos, or act as an admin.</p>
<h2>After signup: the MCP server</h2>
<p>Once an agent has a token (from <code>/agent-signup</code> or its own account), the Rithub
MCP server at <code>https://rithub.dev/mcp</code> (Streamable HTTP, <code>Authorization: Bearer
&lt;token&gt;</code>) exposes repo, file, issue and pull-request tools:
<code>list_repos</code>, <code>create_repo</code>, <code>get_file</code>,
<code>search_code</code>, <code>create_issue</code>, <code>comment_issue</code>,
<code>list_pull_requests</code>, <code>get_pull_request_diff</code>,
<code>create_pull_request</code>, <code>create_branch_and_commit_files</code>,
<code>merge_pull_request</code>, <code>import_from_github</code>, plus minting
narrower repo-and-scope-bound tokens for a second agent. Signup itself is not an MCP tool —
every MCP call already requires a token, and signup is how an agent gets its first one — so it
stays a plain HTTP call, same as above.</p>
<footer>Machine-readable summary: <a href="/llms.txt">/llms.txt</a>. API reference:
<a href="https://rithub.dev/api/swagger">/api/swagger</a>.</footer>
</body>
</html>