From 7e4cd961eef11f4dff9ec9fc262732cd0922b14a Mon Sep 17 00:00:00 2001 From: Panniantong Date: Tue, 24 Feb 2026 05:22:48 +0100 Subject: [PATCH] feat: add upstream sync script for x-reader updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/sync-upstream.sh checks for changes in x-reader's fetchers/ and shows which reader files have upstream updates. Handles import path differences (x_reader.fetchers → agent_eyes.readers) automatically. --- scripts/sync-upstream.sh | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 scripts/sync-upstream.sh diff --git a/scripts/sync-upstream.sh b/scripts/sync-upstream.sh new file mode 100755 index 0000000..1262e87 --- /dev/null +++ b/scripts/sync-upstream.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# sync-upstream.sh — Sync readers from x-reader upstream +# +# Usage: ./scripts/sync-upstream.sh +# +# This script checks for updates in x-reader's fetchers/ directory +# and shows which files have changed. You can then manually review +# and merge the changes. + +set -e + +UPSTREAM_REPO="runesleo/x-reader" +UPSTREAM_BRANCH="main" +UPSTREAM_DIR="x_reader/fetchers" +LOCAL_DIR="agent_eyes/readers" + +echo "👁️ Agent Eyes — Upstream Sync" +echo "Checking for updates from $UPSTREAM_REPO..." +echo "" + +# Create temp dir for upstream code +TMPDIR=$(mktemp -d) +trap "rm -rf $TMPDIR" EXIT + +# Clone upstream (shallow) +git clone --depth 1 --branch "$UPSTREAM_BRANCH" \ + "https://github.com/$UPSTREAM_REPO.git" "$TMPDIR/upstream" 2>/dev/null + +if [ ! -d "$TMPDIR/upstream/$UPSTREAM_DIR" ]; then + echo "❌ Upstream directory not found: $UPSTREAM_DIR" + echo " x-reader may have changed their structure." + exit 1 +fi + +# Compare each file +echo "Comparing files..." +echo "" + +CHANGES=0 +for upstream_file in "$TMPDIR/upstream/$UPSTREAM_DIR"/*.py; do + filename=$(basename "$upstream_file") + local_file="$LOCAL_DIR/$filename" + + if [ ! -f "$local_file" ]; then + echo "🆕 NEW: $filename (exists in upstream but not locally)" + CHANGES=$((CHANGES + 1)) + continue + fi + + # Compare (ignoring import path differences) + if ! diff -q <(sed 's/x_reader\.fetchers/agent_eyes.readers/g' "$upstream_file") "$local_file" > /dev/null 2>&1; then + echo "📝 CHANGED: $filename" + diff --color -u <(sed 's/x_reader\.fetchers/agent_eyes.readers/g' "$upstream_file") "$local_file" | head -20 + echo " ..." + echo "" + CHANGES=$((CHANGES + 1)) + fi +done + +if [ $CHANGES -eq 0 ]; then + echo "✅ All readers are up to date with upstream!" +else + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "$CHANGES file(s) have upstream changes." + echo "" + echo "To merge a specific file:" + echo " cp $TMPDIR/upstream/$UPSTREAM_DIR/FILENAME.py $LOCAL_DIR/FILENAME.py" + echo " sed -i 's/x_reader\\.fetchers/agent_eyes.readers/g' $LOCAL_DIR/FILENAME.py" + echo "" + echo "Then review changes, run tests, and commit." +fi