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
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>
85 lines
3.7 KiB
Bash
Executable File
85 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Path 3 (owner, 2026-11-18): a Rithub agent the user can ask in plain
|
|
# words. v1 handles the one phrase this task asked for literally — "move
|
|
# my GitHub here" and close variants — by reusing the exact same shared
|
|
# core as path 1 (oauth-auto-import.sh) and the `rit import github` CLI.
|
|
# This is real keyword matching, not an LLM call: scoped on purpose to
|
|
# keep it deployable today without adding a model dependency to a cron-
|
|
# adjacent script. A fuller natural-language agent (and "fix this issue")
|
|
# is future work — see plans/railyard.md and
|
|
# ai-knowledges/agent-harness/deepseek-superagent-design.md for the
|
|
# intended shape of that next step.
|
|
#
|
|
# Usage: rithub-agent.sh <rithub-username> "<plain text request>"
|
|
# Finds the user's own GitHub token the same way oauth-auto-import.sh does
|
|
# (their stored "Sign in with GitHub" link) — if they haven't linked
|
|
# GitHub yet, says so instead of asking for a token to paste.
|
|
set -euo pipefail
|
|
|
|
RIT_CONTAINER="rithub-server-app"
|
|
RIT_DB_CONTAINER="rithub-server-postgres"
|
|
RITHUB_HOST="${RITHUB_HOST:-rithub.dev}"
|
|
RITHUB_API_BASE="${RITHUB_API_BASE:-http://127.0.0.1:3350}"
|
|
LOCK_FILE="/var/lock/rithub-bulk-migrate.lock"
|
|
|
|
rit_user="${1:-}"
|
|
request="${2:-}"
|
|
if [ -z "$rit_user" ] || [ -z "$request" ]; then
|
|
echo "usage: rithub-agent.sh <rithub-username> \"<plain text request>\"" >&2
|
|
exit 2
|
|
fi
|
|
|
|
lower=$(echo "$request" | tr '[:upper:]' '[:lower:]')
|
|
if ! echo "$lower" | grep -qE 'github'; then
|
|
echo "I can move repos from GitHub onto Rithub, but I didn't see \"GitHub\" in that request — try \"move my GitHub here\"."
|
|
exit 0
|
|
fi
|
|
if ! echo "$lower" | grep -qE 'move|import|bring|copy|migrate|sync'; then
|
|
echo "Did you mean: move your GitHub repos onto Rithub? Try \"move my GitHub here\"."
|
|
exit 0
|
|
fi
|
|
|
|
exec 9>"$LOCK_FILE"
|
|
if ! flock -n 9; then
|
|
echo "Already moving repos for someone else right now — try again in a minute."
|
|
exit 0
|
|
fi
|
|
load1=$(cut -d' ' -f1 /proc/loadavg)
|
|
if awk "BEGIN{exit !($load1>=6)}"; then
|
|
echo "Rithub is busy right now — try again shortly."
|
|
exit 0
|
|
fi
|
|
|
|
source "$(dirname "$0")/lib/bulk-migrate.sh"
|
|
|
|
github_token=$(docker exec -i "$RIT_DB_CONTAINER" psql -U gitea -d gitea -t -A -c "
|
|
SELECT elu.access_token
|
|
FROM external_login_user elu
|
|
JOIN \"user\" u ON u.id = elu.user_id
|
|
JOIN login_source ls ON ls.id = elu.login_source_id
|
|
WHERE ls.name = 'GitHub' AND u.name = '$rit_user'
|
|
AND elu.access_token IS NOT NULL AND elu.access_token != ''
|
|
LIMIT 1
|
|
" 2>/dev/null | tr -d '[:space:]' || true)
|
|
|
|
if [ -z "$github_token" ]; then
|
|
echo "You haven't connected GitHub on Rithub yet — click \"Continue with GitHub\" once on $RITHUB_HOST, then ask me again. (Or run \`rit import github\` from your own machine — it uses your \`gh\` login directly, no connecting needed.)"
|
|
exit 0
|
|
fi
|
|
|
|
token_out=$(docker exec -u git "$RIT_CONTAINER" gitea admin user generate-access-token \
|
|
--username "$rit_user" --token-name "agent-import-$(date +%s)" \
|
|
--scopes write:repository,read:user 2>&1 || true)
|
|
rit_token=$(echo "$token_out" | grep -o '[0-9a-f]\{40\}' | tail -1)
|
|
if [ -z "$rit_token" ]; then
|
|
echo "Something went wrong setting that up — try again in a minute."
|
|
exit 1
|
|
fi
|
|
|
|
echo "On it — moving your GitHub repos onto Rithub now. This list updates as each one lands:"
|
|
bulk_migrate_user "$rit_user" "$rit_token" "$github_token"
|
|
|
|
token_id=$(curl -s --max-time 30 -u "${rit_user}:${rit_token}" "${RITHUB_API_BASE}/api/v1/user/tokens" \
|
|
| python3 -c "import json,sys;[print(t['id']) for t in json.load(sys.stdin) if t['name'].startswith('agent-import')]" 2>/dev/null | tail -1)
|
|
[ -n "$token_id" ] && curl -s --max-time 30 -o /dev/null -u "${rit_user}:${rit_token}" -X DELETE "${RITHUB_API_BASE}/api/v1/user/tokens/$token_id" || true
|