From ede5960b5a6617d6539dcb7be527055a1527e8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Mon, 22 Jun 2026 18:02:57 +0800 Subject: [PATCH] fix: fully replace robot skill dir on sync to avoid stale-file ImportError _extract_skills_to_robot used shutil.copytree(dirs_exist_ok=True), which only overwrites same-named files. Renamed/removed files and __pycache__ in the robot project's skill copy were left behind, so after a skill refactor (e.g. rag-retrieve adding create_error_response and dropping call_rag_retrieve) stale copies ended up with mismatched imports and failed to load. Switch to rmtree + copytree so each managed skill directory is fully replaced from source on every sync. Also ignore __pycache__/*.pyc so the source's compiled artifacts are not propagated. Refs: #59 Co-Authored-By: Claude Opus 4.7 --- utils/multi_project_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/multi_project_manager.py b/utils/multi_project_manager.py index 93cbc66..c1a8ca3 100644 --- a/utils/multi_project_manager.py +++ b/utils/multi_project_manager.py @@ -472,7 +472,15 @@ def _extract_skills_to_robot(bot_id: str, skills: List[str], project_path: Path) continue try: - shutil.copytree(source_dir, target_dir, dirs_exist_ok=True) + # Fully replace the target skill directory so stale files (renamed/removed + # in source) and __pycache__ do not linger and break imports. + if target_dir.exists(): + shutil.rmtree(target_dir) + shutil.copytree( + source_dir, + target_dir, + ignore=shutil.ignore_patterns("__pycache__", "*.pyc"), + ) logger.info(f" Synced: {source_dir} -> {target_dir}") except Exception as e: logger.error(f" Failed to copy {source_dir}: {e}")