Merge branch 'developing' into bot_manager

This commit is contained in:
朱潮 2026-03-26 15:47:42 +08:00
commit 6ecb0d70e3
2 changed files with 13 additions and 11 deletions

View File

@ -786,9 +786,14 @@ async def remove_skill(
# 使用线程池删除目录(避免阻塞事件循环) # 使用线程池删除目录(避免阻塞事件循环)
await asyncio.to_thread(shutil.rmtree, skill_dir_real) await asyncio.to_thread(shutil.rmtree, skill_dir_real)
logger.info(f"Successfully removed skill directory: {skill_dir_real}") logger.info(f"Successfully removed skill directory: {skill_dir_real}")
# 同步删除 robot 目录下的 skill 副本
robot_skill_dir = os.path.join(base_dir, "projects", "robot", bot_id, "skills", skill_name)
if os.path.exists(robot_skill_dir):
await asyncio.to_thread(shutil.rmtree, robot_skill_dir)
logger.info(f"Also removed robot skill directory: {robot_skill_dir}")
return { return {
"success": True, "success": True,
"message": f"Skill '{skill_name}' 删除成功", "message": f"Skill '{skill_name}' 删除成功",

View File

@ -392,16 +392,17 @@ def _extract_skills_to_robot(bot_id: str, skills: List[str], project_path: Path)
Path("skills"), Path("skills"),
] ]
skills_target_dir = project_path / "robot" / bot_id / "skills" skills_target_dir = project_path / "robot" / bot_id / "skills"
# 先清空 skills_target_dir然后重新复制
if skills_target_dir.exists():
logger.info(f" Removing existing skills directory: {skills_target_dir}")
shutil.rmtree(skills_target_dir)
skills_target_dir.mkdir(parents=True, exist_ok=True) skills_target_dir.mkdir(parents=True, exist_ok=True)
logger.info(f"Copying skills to {skills_target_dir}") logger.info(f"Copying skills to {skills_target_dir}")
for skill in skills: for skill in skills:
target_dir = skills_target_dir / os.path.basename(skill)
# 如果目标目录已存在,跳过复制
if target_dir.exists():
logger.info(f" Skill '{skill}' already exists in {target_dir}, skipping")
continue
source_dir = None source_dir = None
# 简单名称:按优先级顺序在多个目录中查找 # 简单名称:按优先级顺序在多个目录中查找
@ -416,10 +417,6 @@ def _extract_skills_to_robot(bot_id: str, skills: List[str], project_path: Path)
logger.warning(f" Skill directory '{skill}' not found in any source directory: {[str(d) for d in skills_source_dirs]}") logger.warning(f" Skill directory '{skill}' not found in any source directory: {[str(d) for d in skills_source_dirs]}")
continue continue
if not source_dir.exists():
logger.warning(f" Skill directory not found: {source_dir}")
continue
target_dir = skills_target_dir / os.path.basename(skill) target_dir = skills_target_dir / os.path.basename(skill)
try: try: