Keep formats.py to Claude Code's shapes, with paths and file reads at their callers #135

Merged
lilleman merged 4 commits from formats-shapes into rebuild 2026-09-29 11:53:59 +02:00
2 changed files with 18 additions and 11 deletions
Showing only changes of commit 29495b1e7d - Show all commits
+16
View File
@@ -0,0 +1,16 @@
import json
from loop_claude.claude_code.formats import catalog
def offered_models(folder):
return catalog(read_catalog(folder))
def read_catalog(folder):
for path in folder.glob("*.json"):
try:
with open(path, encoding="utf-8") as handle:
yield json.load(handle)
except (OSError, ValueError):
continue
+2 -11
View File
@@ -3,7 +3,7 @@ import json
import sys
from loop_claude import human_needed
from loop_claude.claude_code.formats import catalog
from loop_claude.claude_code.catalog import offered_models
from loop_claude.file_writes import replace_json
from loop_claude.outcome import Stop
@@ -57,19 +57,10 @@ def read_models(saved):
return models
def read_catalog(folder):
for path in folder.glob("*.json"):
try:
with open(path, encoding="utf-8") as handle:
yield json.load(handle)
except (OSError, ValueError):
continue
def ask_model(name, saved, folder):
if stop := human_needed.off_terminal(f"pick {name}'s model, or merge {{\"{name}\": \"<model>\"}} into {saved}"):
return stop
offered = catalog(read_catalog(folder))
offered = offered_models(folder)
print(f"\nThe model to run {name} on, saved in {saved}:", file=sys.stderr)
for number, (model_id, label) in enumerate(offered, 1):
print(f" {number}. {label} ({model_id})", file=sys.stderr)