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 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-02-21 14:37:52 +00:00
parent 944e4f2987
commit 436ef1e637

View File

@@ -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):