echo" clawdie-ai skills dir not found, skipping import"
exit0
fi
if ! command -v sqlite3 >/dev/null 2>&1;then
echo" sqlite3 not available, skipping skills import"
exit0
fi
# Ensure the skills table exists
sqlite3 "$DB""CREATE TABLE IF NOT EXISTS skills (
id TEXT PRIMARY KEY NOT NULL,
name TEXT NOT NULL UNIQUE,
description TEXT,
category TEXT,
created_at TEXT NOT NULL
);" 2>/dev/null || true
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
IMPORTED=0
SKIPPED=0
for skill_md in "$CLAWDIE_AI"/.agent/skills/*/SKILL.md;do
[ -f "$skill_md"]||continue
# Extract YAML frontmatter between --- markers
frontmatter=$(sed -n '/^---$/,/^---$/p'"$skill_md"| sed '1d;$d')
# Extract name (first "name:" line after frontmatter)
name=$(echo"$frontmatter"| grep -m1 '^name:'| sed 's/^name: *//'| tr -d '"')
[ -n "$name"]||continue
# Extract description
description=$(echo"$frontmatter"| sed -n '/^description:/,/^[a-z]/p'| sed '$d'| sed 's/^description: *//'| tr '\n'' '| sed 's/ */ /g'| sed 's/^ *//;s/ *$//')
# Handle multi-line descriptions (| indicator)
ifecho"$description"| grep -q '^|$';then
description=$(echo"$frontmatter"| awk '/^description:/{found=1; next} /^[a-z]/{if(found) exit} found{print}'| tr '\n'' '| sed 's/ */ /g'| sed 's/^ *//;s/ *$//')
fi
[ -n "$description"]||description="$name skill"
# Derive category from skill name prefix
case"$name" in
git-*)category="git";;
db-*|postgres*)category="database";;
zfs-*)category="zfs";;
add-*)category="integration";;
freebsd-*)category="freebsd";;
ansible-*)category="automation";;
*)category="clawdie";;
esac
# Override category if compatibility field indicates FreeBSD