"""Carry v1 scene summaries over to a re-split corpus, summarising only scenes whose text is new. cd v2 && STP_OLLAMA=http://host:11434 python3 ../carry_summaries.py ../summaries.json summaries.json The v1 split merged three quoted-title stories into their neighbours (SELECTION.md, "Pilot"). Re-splitting renumbers every later scene but leaves almost every scene's text identical, so a scene whose text matches a v1 scene keeps its v1 summary verbatim, and only the rest go to the model, with summarise.py's model and prompt. Output has summarise.py's layout, in the new scene order, with 'carried' marking which is which. """ import json, pathlib, re, sys, time import ollama src, dst = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]) old = json.loads(src.read_text(encoding='utf-8')) old_chunks = json.loads((src.parent / 'chunks.json').read_text(encoding='utf-8')) chunks = json.loads(pathlib.Path('chunks.json').read_text(encoding='utf-8')) # summarise.py runs on import, so its prompt is read from the file; it must be the one v1 was made with. code = (pathlib.Path(__file__).parent / 'summarise.py').read_text(encoding='utf-8') SYSTEM = re.search(r'SYSTEM = """(.*?)"""', code, re.S).group(1) END = re.compile(r'(?