List existing iteration directories for a skill, sorted by N ascending. Returns an empty list if the workspace doesn't exist.
(kb_dir: Path, skill_name: str)
| 44 | |
| 45 | |
| 46 | def list_iterations(kb_dir: Path, skill_name: str) -> list[Path]: |
| 47 | """List existing iteration directories for a skill, sorted by N ascending. |
| 48 | |
| 49 | Returns an empty list if the workspace doesn't exist. |
| 50 | """ |
| 51 | ws = _workspace_dir(kb_dir, skill_name) |
| 52 | if not ws.is_dir(): |
| 53 | return [] |
| 54 | iters: list[tuple[int, Path]] = [] |
| 55 | for child in ws.iterdir(): |
| 56 | if not child.is_dir(): |
| 57 | continue |
| 58 | n = _iter_number(child) |
| 59 | if n is None: |
| 60 | continue |
| 61 | iters.append((n, child)) |
| 62 | iters.sort(key=lambda t: t[0]) |
| 63 | return [p for _, p in iters] |
| 64 | |
| 65 | |
| 66 | def save_iteration(kb_dir: Path, skill_name: str) -> Path | None: |