Files
ai-proj-helper/plugins/skill-manager-plugin/init-registry.sh

59 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# init-registry.sh - 初始化技能注册表
# 用法: ./init-registry.sh
set -e
SKILLS_DIR="$HOME/.claude/skills"
REGISTRY_FILE="$SKILLS_DIR/registry.yaml"
REPOS_DIR="$SKILLS_DIR/repos"
# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "初始化 Skills Registry..."
echo "----------------------------------------"
# 创建 repos 目录
if [ ! -d "$REPOS_DIR" ]; then
mkdir -p "$REPOS_DIR"
echo -e "${GREEN}✓ 创建 repos 目录${NC}"
else
echo -e "${YELLOW}⚠ repos 目录已存在${NC}"
fi
# 创建 registry.yaml
if [ ! -f "$REGISTRY_FILE" ]; then
cat > "$REGISTRY_FILE" << 'EOF'
# Skills Registry - 技能注册表
# 由 skill-manager 自动管理,请勿手动编辑
version: 1
updated_at: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
# 全局配置
config:
auto_update_check: true # 启动时检查更新
update_check_interval: 86400 # 检查间隔默认24小时
default_branch: main # 默认分支
# 已安装技能
skills: {}
EOF
# 替换日期
sed -i '' "s/\$(date -u +\"%Y-%m-%dT%H:%M:%SZ\")/$(date -u +"%Y-%m-%dT%H:%M:%SZ")/" "$REGISTRY_FILE"
echo -e "${GREEN}✓ 创建 registry.yaml${NC}"
else
echo -e "${YELLOW}⚠ registry.yaml 已存在${NC}"
fi
echo "----------------------------------------"
echo -e "${GREEN}✓ 初始化完成${NC}"
echo ""
echo "目录结构:"
echo " $SKILLS_DIR/"
echo " ├── registry.yaml"
echo " └── repos/"