Copy current `` /output/skills/ /`` to the next iteration slot. Returns the saved iteration path, or ``None`` if there's no current skill to save (first compile of a new name).
(kb_dir: Path, skill_name: str)
| 64 | |
| 65 | |
| 66 | def save_iteration(kb_dir: Path, skill_name: str) -> Path | None: |
| 67 | """Copy current ``<kb>/output/skills/<name>/`` to the next iteration slot. |
| 68 | |
| 69 | Returns the saved iteration path, or ``None`` if there's no current |
| 70 | skill to save (first compile of a new name). |
| 71 | """ |
| 72 | src = _skill_dir(kb_dir, skill_name) |
| 73 | if not src.is_dir(): |
| 74 | return None |
| 75 | |
| 76 | existing = list_iterations(kb_dir, skill_name) |
| 77 | next_n = (max((_iter_number(p) for p in existing), default=0) or 0) + 1 |
| 78 | |
| 79 | ws = _workspace_dir(kb_dir, skill_name) |
| 80 | ws.mkdir(parents=True, exist_ok=True) |
| 81 | dest = ws / f"iteration-{next_n}" |
| 82 | shutil.copytree(src, dest) |
| 83 | return dest |
| 84 | |
| 85 | |
| 86 | def restore_iteration(kb_dir: Path, skill_name: str, n: int | None = None) -> Path: |