MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / save_iteration

Function save_iteration

openkb/skill/workspace.py:66–83  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

64
65
66def 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&#x27;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
86def restore_iteration(kb_dir: Path, skill_name: str, n: int | None = None) -> Path:

Calls 2

list_iterationsFunction · 0.85
_iter_numberFunction · 0.85