qwen_agent/utils/symlink_utils.py
朱潮 766b9becda feat(deep-agent): add skills support and improve project structure
- Add skills parameter to ChatRequest for skill file processing
- Extract and unzip skill files to robot project skills directory
- Add robot_config.json with bot_id and environment variables
- Update symlink setup to skip if ~/.deepagents already exists
- Enhance system prompt with directory access restrictions
- Refactor _get_robot_dir to handle symlink paths correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 13:21:58 +08:00

71 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""
Utilities for managing symbolic links and directory setup.
"""
import os
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
def setup_deepagents_symlink():
"""
Create a symbolic link from projects/robot to ~/.deepagents
if it doesn't already exist.
"""
try:
# Get paths
project_root = Path(__file__).parent.parent
robot_dir = project_root / "projects" / "robot"
deepagents_dir = Path.home() / ".deepagents"
# Create robot directory if it doesn't exist
robot_dir.mkdir(parents=True, exist_ok=True)
# If ~/.deepagents already exists, do nothing
if deepagents_dir.exists():
logger.info(f"~/.deepagents already exists at {deepagents_dir}, skipping symlink creation")
return True
# Create the symbolic link
os.symlink(robot_dir, deepagents_dir, target_is_directory=True)
logger.info(f"Created symbolic link: {deepagents_dir} -> {robot_dir}")
return True
except Exception as e:
logger.error(f"Failed to create symbolic link: {e}")
return False
def setup_project_directories():
"""
Set up all necessary directories and symbolic links for the project.
"""
logger.info("Setting up project directories...")
# Setup ~/.deepagents symlink
symlink_success = setup_deepagents_symlink()
if symlink_success:
logger.info("Project directories setup completed successfully")
else:
logger.warning("Project directories setup completed with warnings")
return symlink_success
if __name__ == "__main__":
# Set up basic logging for standalone testing
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Test the function
success = setup_deepagents_symlink()
if success:
print("✅ Symbolic link setup successful")
else:
print("❌ Symbolic link setup failed")