From 436ef1e63704e8a6cb43c22970345b15dcaf60c7 Mon Sep 17 00:00:00 2001 From: delta-cloud-208e Date: Sat, 21 Feb 2026 14:37:52 +0000 Subject: [PATCH] feat: load_config() fetches from private repo with token auth - Primary: download from unlimitedcoding-config private repo via API token - Cache: saves .patcher.config.cache.json for offline fallback - Legacy fallback: still reads local patcher.config.json if present Co-Authored-By: Claude Opus 4.6 --- claude/uclaude_updater.py | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/claude/uclaude_updater.py b/claude/uclaude_updater.py index 7fbe987..046f6ce 100644 --- a/claude/uclaude_updater.py +++ b/claude/uclaude_updater.py @@ -485,14 +485,56 @@ def install_cli_js(version, cli_js_path): # Settings patching # ============================================================ +CONFIG_URL = "https://git.sensey24.ru/aibot777/unlimitedcoding-config/raw/branch/main/patcher.config.json" +CONFIG_TOKEN = "cadffcb0a6a3be728ac1ff619bb40c86588f6837" + + def load_config(): - """Load patcher.config.json from repo root.""" + """Load patcher.config.json from private config repo (with token auth). + + Falls back to local file if network is unavailable. + """ + # 1. Try fetching from private repo + try: + import urllib.request + req = urllib.request.Request( + CONFIG_URL, + headers={"Authorization": f"token {CONFIG_TOKEN}"}, + ) + with urllib.request.urlopen(req, timeout=15) as resp: + data = json.loads(resp.read().decode("utf-8")) + # Cache locally for offline use + cache_path = os.path.join(SCRIPT_DIR, ".patcher.config.cache.json") + try: + with open(cache_path, "w") as f: + json.dump(data, f, indent=2) + except Exception: + pass + return data + except Exception as e: + eprint(f" {Y}Remote config fetch failed: {e}{D}") + + # 2. Fallback: cached copy + cache_path = os.path.join(SCRIPT_DIR, ".patcher.config.cache.json") + if os.path.isfile(cache_path): + try: + with open(cache_path, "r") as f: + eprint(f" {Y}Using cached config{D}") + return json.load(f) + except Exception: + pass + + # 3. Fallback: local file (legacy, will be removed) config_path = os.path.join(SCRIPT_DIR, "patcher.config.json") - if not os.path.isfile(config_path): - eprint(f" {R}patcher.config.json not found{D}") - return None - with open(config_path, "r") as f: - return json.load(f) + if os.path.isfile(config_path): + try: + with open(config_path, "r") as f: + return json.load(f) + except Exception: + pass + + eprint(f" {R}patcher.config.json not found (remote or local){D}") + return None def ensure_dir(path, uid, gid):