fix(installer): verbose diagnostics — show CLAUDE_CUSTOM_MODELS count

User reported: after install, claude /model picker shows only 5 models
(built-ins) instead of 19 — config DID land somewhere but CLAUDE_CUSTOM_
MODELS env block in settings.json was empty/missing.

Hard to debug without seeing user's settings.json. Add verbose diagnostic:

uclaude_updater.py patch_all_users():
- Pre-check: warn if config has 0 models OR placeholder api_key
- Post-patch per user: read back the JUST-WRITTEN settings.json, count
  CLAUDE_CUSTOM_MODELS entries, print:
    "Patched root: /root/.claude/settings.json (env.CLAUDE_CUSTOM_MODELS=19 models)"

uclaude_install.sh — final verification block:
- Show ANTHROPIC_BASE_URL + AUTH_TOKEN prefix + custom_models count
- Loud warning if 0 models or auth_token missing

Now user can immediately see "0 models" or "19 models" without manually
inspecting settings.json. If 0 — knows config fetch failed silently.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-04-25 18:35:47 +00:00
parent 47e1978bef
commit 696d8b4ced
2 changed files with 54 additions and 2 deletions

View File

@@ -876,10 +876,31 @@ def patch_all_users(config):
eprint(f" {Y}No users found{D}")
return
# Diagnostic: confirm config has the key fields BEFORE patching users.
# If models is empty/missing, claude shows only built-in defaults
# (user reported only 5 models in /model picker — root cause was here).
n_models = len(config.get("models", []))
if n_models == 0:
eprint(f" {R}WARNING: config has 0 models — claude /model will show built-ins only{D}")
else:
print(f" Config has {n_models} models (sample: {','.join(config['models'][:3])}...)")
if not config.get("api_key") or config["api_key"] in ("YOUR_API_KEY", "PLACEHOLDER", ""):
eprint(f" {R}WARNING: api_key is placeholder/empty — claude API auth will fail{D}")
for user in users:
try:
path = patch_user(user.home, user.name, user.uid, user.gid, config)
print(f" {G}Patched {user.name}{D}: {path}")
# Verify what landed in settings.json
try:
with open(path, "r") as f:
written = json.load(f)
env_block = written.get("env", {})
ccm = env_block.get("CLAUDE_CUSTOM_MODELS", "")
ccm_count = len(ccm.split(",")) if ccm else 0
print(f" {G}Patched {user.name}{D}: {path} "
f"(env.CLAUDE_CUSTOM_MODELS={ccm_count} models)")
except Exception:
print(f" {G}Patched {user.name}{D}: {path}")
except Exception as e:
eprint(f" {R}Failed to patch {user.name}: {e}{D}")