refactor: 通用技能按类别拆分为独立目录

skills/ → skills-dev(9), skills-req(10), skills-ops(4),
skills-integration(8), skills-biz(4), skills-workflow(7)

generate-marketplace.py 改为自动扫描所有 skills-* 目录。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 11:31:58 +10:30
parent ea266e9cce
commit 712063071c
170 changed files with 341 additions and 346 deletions

View File

@@ -0,0 +1,88 @@
#!/bin/bash
# validate.sh - 验证 skill.yaml 格式
# 用法: ./validate.sh <skill-directory>
set -e
SKILL_DIR="${1:-.}"
SKILL_YAML="$SKILL_DIR/skill.yaml"
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "验证技能目录: $SKILL_DIR"
echo "----------------------------------------"
# 检查 skill.yaml 是否存在
if [ ! -f "$SKILL_YAML" ]; then
echo -e "${RED}✗ skill.yaml 不存在${NC}"
exit 1
fi
echo -e "${GREEN}✓ skill.yaml 存在${NC}"
# 检查 YAML 格式(需要 yq 或 python
if command -v yq &> /dev/null; then
if ! yq e '.' "$SKILL_YAML" > /dev/null 2>&1; then
echo -e "${RED}✗ YAML 格式错误${NC}"
exit 1
fi
echo -e "${GREEN}✓ YAML 格式正确${NC}"
# 检查必填字段
NAME=$(yq e '.name' "$SKILL_YAML")
VERSION=$(yq e '.version' "$SKILL_YAML")
DESCRIPTION=$(yq e '.description' "$SKILL_YAML")
if [ "$NAME" == "null" ] || [ -z "$NAME" ]; then
echo -e "${RED}✗ 缺少必填字段: name${NC}"
exit 1
fi
echo -e "${GREEN}✓ name: $NAME${NC}"
if [ "$VERSION" == "null" ] || [ -z "$VERSION" ]; then
echo -e "${RED}✗ 缺少必填字段: version${NC}"
exit 1
fi
echo -e "${GREEN}✓ version: $VERSION${NC}"
if [ "$DESCRIPTION" == "null" ] || [ -z "$DESCRIPTION" ]; then
echo -e "${RED}✗ 缺少必填字段: description${NC}"
exit 1
fi
echo -e "${GREEN}✓ description: 已设置${NC}"
# 验证 name 格式
if ! echo "$NAME" | grep -qE '^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$'; then
echo -e "${RED}✗ name 格式错误: 只能包含小写字母、数字、连字符${NC}"
exit 1
fi
if [ ${#NAME} -gt 64 ]; then
echo -e "${RED}✗ name 超过 64 字符${NC}"
exit 1
fi
echo -e "${GREEN}✓ name 格式正确${NC}"
# 检查 prompt_file
PROMPT_FILE=$(yq e '.prompt_file // "SKILL.md"' "$SKILL_YAML")
if [ ! -f "$SKILL_DIR/$PROMPT_FILE" ]; then
echo -e "${YELLOW}⚠ prompt_file 不存在: $PROMPT_FILE${NC}"
else
echo -e "${GREEN}✓ prompt_file: $PROMPT_FILE${NC}"
fi
elif command -v python3 &> /dev/null; then
python3 -c "import yaml; yaml.safe_load(open('$SKILL_YAML'))" 2>/dev/null
if [ $? -ne 0 ]; then
echo -e "${RED}✗ YAML 格式错误${NC}"
exit 1
fi
echo -e "${GREEN}✓ YAML 格式正确 (使用 Python 验证)${NC}"
else
echo -e "${YELLOW}⚠ 无法验证 YAML 格式 (需要 yq 或 python3)${NC}"
fi
echo "----------------------------------------"
echo -e "${GREEN}✓ 验证通过${NC}"