diff --git a/web/tasks.py b/web/tasks.py index d2d2d69..de3071d 100644 --- a/web/tasks.py +++ b/web/tasks.py @@ -281,7 +281,18 @@ def generate_book_task(run_id, project_path, bible_path, allow_copy=True, feedba except Exception as e: utils.log("SYSTEM", f" -> Failed to copy {item}: {e}") - # 2. Run Generation + # 2. Save Bible Snapshot alongside this run + run_dir_early = os.path.join(project_path, "runs", f"run_{run_id}") + os.makedirs(run_dir_early, exist_ok=True) + if os.path.exists(bible_path): + snapshot_path = os.path.join(run_dir_early, "bible_snapshot.json") + try: + shutil.copy2(bible_path, snapshot_path) + utils.log("SYSTEM", f"Bible snapshot saved to run folder.") + except Exception as _e: + utils.log("SYSTEM", f"WARNING: Could not save bible snapshot: {_e}") + + # 3. Run Generation from cli.engine import run_generation run_generation(bible_path, specific_run_id=run_id)