"""Clear per-run staging outputs, retaining compiler/report caches and archived runs.""" from pathlib import Path import shutil root = Path.cwd().resolve() assert (root / 'demo/snapshot.json').is_file(), 'Run from the demo repository root' for name in ('artifacts', 'reports'): target = root / 'build/demo' / name resolved = target.resolve() assert not target.is_symlink() and resolved == root / 'build/demo' / name assert resolved.is_relative_to(root / 'build/demo') if target.exists(): shutil.rmtree(target) target.mkdir(parents=True) print('Fresh per-run artifacts/reports; build caches retained')