From 2c00e0327de0fed8ca7baa3f9e2792616d958c64 Mon Sep 17 00:00:00 2001 From: delta-cloud-208e Date: Sat, 21 Feb 2026 14:03:35 +0000 Subject: [PATCH] fix: read version from cli.js bundle instead of package.json package.json shows npm-installed version (e.g. 2.1.47) while the actual patched cli.js contains 2.1.50. Now reads "// Version: x.y.z" from the bundle first, falls back to claude --version, then package.json. Co-Authored-By: Claude Opus 4.6 --- claude/uclaude_updater.py | 41 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/claude/uclaude_updater.py b/claude/uclaude_updater.py index 8606564..7fbe987 100644 --- a/claude/uclaude_updater.py +++ b/claude/uclaude_updater.py @@ -265,22 +265,31 @@ def find_cli_js(): def get_installed_version(): - """Get currently installed Claude Code version.""" + """Get currently installed Claude Code version. + + Priority: cli.js bundle version > claude --version > package.json. + After patching, cli.js contains the real version while package.json + may still reflect the older npm-installed version. + """ cli_js = find_cli_js() if not cli_js: return None, None - # Try package.json first (same directory as cli.js) - pkg_json = os.path.join(os.path.dirname(cli_js), "package.json") - if os.path.isfile(pkg_json): - try: - with open(pkg_json, "r") as f: - data = json.load(f) - return data.get("version"), cli_js - except Exception: - pass + # 1. Extract version from cli.js bundle itself (most accurate after patching) + try: + with open(cli_js, "r", encoding="utf-8", errors="ignore") as f: + # Read first 100KB where version string usually lives + head = f.read(100_000) + # Look for "// Version: x.y.z" comment or VERSION:"x.y.z" in the bundle + m = re.search(r'//\s*Version:\s*(\d+\.\d+\.\d+)', head) + if not m: + m = re.search(r'(?:VERSION|version)\s*[:=]\s*["\'](\d+\.\d+\.\d+)["\']', head) + if m: + return m.group(1), cli_js + except Exception: + pass - # Fallback: claude --version + # 2. claude --version try: result = subprocess.run( ["claude", "--version"], @@ -292,6 +301,16 @@ def get_installed_version(): except Exception: pass + # 3. Fallback: package.json (may be stale after cli.js replacement) + pkg_json = os.path.join(os.path.dirname(cli_js), "package.json") + if os.path.isfile(pkg_json): + try: + with open(pkg_json, "r") as f: + data = json.load(f) + return data.get("version"), cli_js + except Exception: + pass + return None, cli_js