- 53 skills copied to colibri/.agent/skills/ (canonical home) - import-colibri-skills.sh: imports from colibri instead of clawdie-ai - build.sh: 4 clawdie-ai functions deleted, step 4 gated behind FEATURE_COLIBRI != YES, skills import uses colibri path - build manifest: clawdie_ai_commit set to "(retired)" - CLAWDIE_REF resolution simplified to git ls-remote (no deleted funcs) - clawdie-ai.tar.gz copy gated behind FEATURE_COLIBRI != YES
81 lines
3.1 KiB
Bash
Executable file
81 lines
3.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# Import colibri skill definitions into the colibri skills catalog.
|
|
#
|
|
# Reads .agent/skills/*/SKILL.md from a colibri checkout, extracts
|
|
# YAML frontmatter (name, description), derives category, and inserts
|
|
# into the colibri SQLite coordination database.
|
|
#
|
|
# Usage during ISO build:
|
|
# scripts/import-clawdie-skills.sh /path/to/colibri /path/to/mount-point
|
|
|
|
set -eu
|
|
|
|
COLIBRI="${1:?usage: $0 <colibri-dir> <mount-point>}"
|
|
MOUNT_POINT="${2:?usage: $0 <colibri-dir> <mount-point>}"
|
|
DB="${MOUNT_POINT}/var/db/colibri/colibri.sqlite"
|
|
|
|
if [ ! -d "$COLIBRI/.agent/skills" ]; then
|
|
echo " colibri skills dir not found, skipping import"
|
|
exit 0
|
|
fi
|
|
|
|
if ! command -v sqlite3 >/dev/null 2>&1; then
|
|
echo " sqlite3 not available, skipping skills import"
|
|
exit 0
|
|
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 "$COLIBRI"/.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)
|
|
if echo "$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
|
|
if echo "$frontmatter" | grep -q 'compatibility:.*FreeBSD'; then
|
|
category="freebsd"
|
|
fi
|
|
|
|
id=$(uuidgen 2>/dev/null || python3 -c "import uuid; print(uuid.uuid4())" 2>/dev/null || echo "skill-$(echo "$name" | md5)")
|
|
|
|
sqlite3 "$DB" "INSERT OR IGNORE INTO skills (id, name, description, category, created_at)
|
|
VALUES ('$id', '$(echo "$name" | sed "s/'/''/g")', '$(echo "$description" | sed "s/'/''/g")', '$category', '$NOW');" 2>/dev/null && IMPORTED=$((IMPORTED + 1)) || SKIPPED=$((SKIPPED + 1))
|
|
done
|
|
|
|
chroot "$MOUNT_POINT" chown colibri:colibri /var/db/colibri/colibri.sqlite 2>/dev/null || true
|
|
echo " colibri skills: $IMPORTED imported, $SKIPPED skipped"
|