#!/usr/bin/env bash # Commit a single system proposal to DB, sync wiki, and create a git commit. # Handles wipe-if-exists automatically. # # Usage: atlas-commit-and-sync "GJ 105A" [corridor_tag] # corridor_tag defaults to "east_reach" set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" ATLAS="$SCRIPT_DIR/atlas" if [[ $# -lt 1 ]]; then echo "Usage: atlas-commit-and-sync SYSTEM_ID [corridor_tag]" >&2 exit 1 fi SYS_ID="$1" CORRIDOR="${2:-east_reach}" SLUG="${SYS_ID// /}" FILE="docs/atlas/proposals/${SLUG}.json" WIKI_SLUG="${SYS_ID// /-}" WIKI="wiki/star-systems/${WIKI_SLUG}/index.md" if [[ ! -f "$FILE" ]]; then echo "ERROR: proposal not found: $FILE" >&2 exit 1 fi # 1. Verify echo "--- Verifying $FILE" "$SCRIPT_DIR/atlas-verify" "$FILE" # 2. Get system info for commit message PROPER=$(python3 -c "import json,sys; d=json.load(open(sys.argv[1])); print(d.get('proper_name') or d['system_id'])" "$FILE") # 3. Wipe existing data if present BODY_COUNT=$("$ATLAS" show-system "$SYS_ID" 2>/dev/null \ | python3 -c "import json,sys; d=json.load(sys.stdin); print(len(d.get('bodies',[])))" 2>/dev/null \ || echo "0") if [[ "$BODY_COUNT" -gt 0 ]]; then echo "--- Wiping existing data for $SYS_ID" "$ATLAS" wipe-system "$SYS_ID" fi # 4. Commit to DB echo "--- Committing $SYS_ID to systems.db" "$ATLAS" commit-system "$FILE" # 5. Sync wiki echo "--- Syncing wiki" "$ATLAS" sync-wiki "$SYS_ID" # 6. Git add + commit echo "--- Git commit" git add "$FILE" [[ -f "$WIKI" ]] && git add "$WIKI" git commit -m "data(atlas): author ${SYS_ID} (${PROPER}) — ${CORRIDOR} Co-Authored-By: Claude Opus 4.6 (1M context) " echo "--- Done: $SYS_ID ($PROPER)"