refactor(project-manager): simplify project path resolution logic
- Remove complex symlink resolution in _get_robot_dir - Simplify skills source directory path calculation - Remove project_path parameter from create_project_directory call 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
78c413f4ea
commit
306cebd8f1
@ -374,7 +374,7 @@ def create_project_directory(dataset_ids: Optional[List[str]], bot_id: str, robo
|
||||
try:
|
||||
from utils.multi_project_manager import create_robot_project
|
||||
from pathlib import Path
|
||||
return create_robot_project(dataset_ids, bot_id, project_path=Path("~", ".deepagents"), skills=skills, robot_type=robot_type)
|
||||
return create_robot_project(dataset_ids, bot_id, skills=skills, robot_type=robot_type)
|
||||
except Exception as e:
|
||||
logger.error(f"Error creating project directory: {e}")
|
||||
return None
|
||||
|
||||
@ -303,23 +303,7 @@ def generate_robot_readme(robot_id: str, dataset_ids: List[str], copy_results: L
|
||||
|
||||
|
||||
def _get_robot_dir(project_path: Path, bot_id: str) -> Path:
|
||||
"""
|
||||
获取 robot 目录路径,处理软链接情况
|
||||
|
||||
Args:
|
||||
project_path: 项目路径
|
||||
bot_id: 机器人ID
|
||||
|
||||
Returns:
|
||||
Path: robot 目录路径(已展开)
|
||||
"""
|
||||
resolved_path = project_path.expanduser().resolve()
|
||||
if resolved_path.name == "robot":
|
||||
# project_path 已经指向 robot 目录(如 ~/.deepagents -> projects/robot)
|
||||
return (project_path / bot_id).expanduser()
|
||||
else:
|
||||
# project_path 指向 projects 目录
|
||||
return (project_path / "robot" / bot_id).expanduser()
|
||||
return project_path / "robot" / bot_id
|
||||
|
||||
|
||||
def should_rebuild_robot_project(dataset_ids: List[str], bot_id: str, project_path: Path) -> bool:
|
||||
@ -521,8 +505,7 @@ def _extract_skills_to_robot(robot_dir: Path, skills: List[str], project_path: P
|
||||
# skills 源目录在 projects/skills,需要通过解析软链接获取正确路径
|
||||
# project_path 可能是 ~/.deepagents (软链接 -> projects/robot)
|
||||
# 所以 skills 源目录是 project_path.resolve().parent / "skills"
|
||||
resolved_path = project_path.expanduser().resolve()
|
||||
skills_source_dir = resolved_path.parent / "skills"
|
||||
skills_source_dir = project_path / "skills"
|
||||
skills_target_dir = robot_dir / "skills"
|
||||
|
||||
# 先清空 skills_target_dir,然后重新解压
|
||||
|
||||
Loading…
Reference in New Issue
Block a user