Gather every Claude Code format loop-claude reads into claude_code.py, verified on 2.1.284

This commit is contained in:
2026-09-28 20:17:39 +02:00
parent b7538bd21d
commit 80629fc6d9
9 changed files with 158 additions and 114 deletions
+1 -17
View File
@@ -4,6 +4,7 @@ import sys
from loop_claude import human
from loop_claude.checkout import project_name
from loop_claude.claude_code import catalog
from loop_claude.file_writes import replace_json
from loop_claude.outcome import Stop
@@ -79,20 +80,3 @@ def ask_model(name, saved, folder):
if 1 <= int(answer) <= len(offered):
return offered[int(answer) - 1][0]
print(f"pick 1 to {len(offered)}", file=sys.stderr)
# Claude Code 2.1.283's model cache; the newest file has the highest fetchedAt.
def catalog(folder):
newest = {}
for path in folder.glob("*.json"):
try:
with open(path, encoding="utf-8") as handle:
data = json.load(handle)
except (OSError, ValueError):
continue
if isinstance(data, dict) and isinstance(data.get("fetchedAt"), (int, float)) and data["fetchedAt"] > newest.get("fetchedAt", -1):
newest = data
models = newest
for key in ("catalog", "config", "models"):
models = models.get(key) if isinstance(models, dict) else None
return [(entry["id"], entry.get("name", entry["id"])) for entry in models if isinstance(entry, dict) and isinstance(entry.get("id"), str)] if isinstance(models, list) else []