From 3bc69d4effba7af5d302408873a721247f0457c0 Mon Sep 17 00:00:00 2001 From: delta-cloud-208e Date: Sat, 21 Feb 2026 11:42:49 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20sparse=20checkout=20+=20shallow=20fetch?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D1=80=D0=B0=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - git_pull() использует fetch --depth 1 + reset (не качает историю) - sparse checkout: скачивается только latest версия cli.js, не все - Все старые версии остаются в репо, но клиент их не скачивает - README обновлён с git clone --depth 1 Co-Authored-By: Claude Opus 4.6 --- README.md | 5 ++++- uclaude_update.sh | 2 +- uclaude_updater.py | 50 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc4c6a0..b1a3467 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,13 @@ Patched Claude Code CLI for use with custom API endpoints. Automatic updater inc # 1. Install Claude Code (if not installed) npm install -g @anthropic-ai/claude-code -# 2. Clone this repo (shallow — downloads only latest version, ~12MB) +# 2. Clone this repo (shallow clone — only latest commit, ~12MB) git clone --depth 1 https://git.sensey24.ru/aibot777/unlimitedcoding.git cd unlimitedcoding +# Note: The updater automatically configures sparse checkout to download +# only the latest release, not all historical versions. + # 3. Run updater (installs patched cli.js + configures settings) sudo bash uclaude_update.sh ``` diff --git a/uclaude_update.sh b/uclaude_update.sh index c000d08..8fd9a9c 100755 --- a/uclaude_update.sh +++ b/uclaude_update.sh @@ -6,7 +6,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$SCRIPT_DIR" -# Shallow fetch + reset (minimal download — only latest snapshot) +# Fetch latest (shallow — only latest commit, minimal download) git fetch --depth 1 origin master 2>/dev/null && git reset --hard origin/master 2>/dev/null || git pull --quiet 2>/dev/null || true # Run updater diff --git a/uclaude_updater.py b/uclaude_updater.py index 6351305..60a3910 100644 --- a/uclaude_updater.py +++ b/uclaude_updater.py @@ -150,7 +150,7 @@ def ver_tuple(v): def git_pull(): """Pull latest changes from remote (shallow fetch for minimal download).""" try: - # Shallow fetch + reset — downloads only latest snapshot, not full history + # Shallow fetch + reset — downloads only latest commit, not full history result = subprocess.run( ["git", "fetch", "--depth", "1", "origin", "master"], cwd=SCRIPT_DIR, capture_output=True, text=True, timeout=60, @@ -170,6 +170,10 @@ def git_pull(): ["git", "reset", "--hard", "origin/master"], cwd=SCRIPT_DIR, capture_output=True, text=True, timeout=10, ) + + # Setup sparse checkout to download only latest version's cli.js + _setup_sparse_checkout() + return True except subprocess.TimeoutExpired: eprint(f" {Y}git fetch timed out{D}") @@ -179,6 +183,50 @@ def git_pull(): return True +def _setup_sparse_checkout(): + """Configure sparse checkout to only include root files + latest release. + + This avoids downloading cli.js for ALL versions (each ~12MB). + Only the latest version's cli.js is checked out. + """ + index_path = os.path.join(SCRIPT_DIR, "claude", "releases", "index.json") + if not os.path.isfile(index_path): + return + + try: + with open(index_path, "r") as f: + latest = json.load(f).get("latest") + except Exception: + return + + if not latest: + return + + # Enable sparse checkout + subprocess.run( + ["git", "config", "core.sparseCheckout", "true"], + cwd=SCRIPT_DIR, capture_output=True, + ) + + sparse_file = os.path.join(SCRIPT_DIR, ".git", "info", "sparse-checkout") + os.makedirs(os.path.dirname(sparse_file), exist_ok=True) + + patterns = [ + "/*", # root files (updater, config, README) + "/claude/releases/index.json", # version index + f"/claude/releases/v{latest}/", # latest release (cli.js + changelog + install) + ] + + with open(sparse_file, "w") as f: + f.write("\n".join(patterns) + "\n") + + # Apply sparse checkout + subprocess.run( + ["git", "checkout", "HEAD", "--", "."], + cwd=SCRIPT_DIR, capture_output=True, timeout=30, + ) + + # ============================================================ # CLI.js installation # ============================================================