From 672ade70a62353e6af9d234e16894daef73c8c33 Mon Sep 17 00:00:00 2001 From: Clawdie Operator Date: Thu, 4 Jun 2026 12:43:08 +0000 Subject: [PATCH] Import clawdie-ai skills into colibri catalog at build time Reads 52 skills from .agent/skills/*/SKILL.md in a clawdie-ai checkout, extracts YAML frontmatter (name, description), derives category from naming conventions, and inserts into colibri SQLite. Combined with the 4 seeded ISO skills, the catalog ships with 56+ skills covering FreeBSD admin, git, database, ZFS, and integration workflows. --- build.sh | 10 ++++ scripts/import-clawdie-skills.sh | 81 ++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100755 scripts/import-clawdie-skills.sh diff --git a/build.sh b/build.sh index 28013ce0..e8c23415 100755 --- a/build.sh +++ b/build.sh @@ -805,6 +805,16 @@ install_colibri_service() { chroot "${MOUNT_POINT}" chown colibri:colibri /var/db/colibri/colibri.sqlite 2>/dev/null || true echo " colibri skills seeded: 4 entries" fi + + # Import clawdie-ai skill definitions into the catalog. + # Reads .agent/skills/*/SKILL.md and registers name + description. + _clawdie_ai_dir="${SCRIPT_DIR}/../clawdie-ai" + if [ -d "${_clawdie_ai_dir}/.agent/skills" ]; then + "${SCRIPT_DIR}/scripts/import-clawdie-skills.sh" \ + "${_clawdie_ai_dir}" "${MOUNT_POINT}" + else + echo " clawdie-ai checkout not found, skipping skill import" + fi } install_clawdie_service() { diff --git a/scripts/import-clawdie-skills.sh b/scripts/import-clawdie-skills.sh new file mode 100755 index 00000000..87dac8fe --- /dev/null +++ b/scripts/import-clawdie-skills.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# Import clawdie-ai skill definitions into the colibri skills catalog. +# +# Reads .agent/skills/*/SKILL.md from a clawdie-ai 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/clawdie-ai /path/to/mount-point + +set -eu + +CLAWDIE_AI="${1:?usage: $0 }" +MOUNT_POINT="${2:?usage: $0 }" +DB="${MOUNT_POINT}/var/db/colibri/colibri.sqlite" + +if [ ! -d "$CLAWDIE_AI/.agent/skills" ]; then + echo " clawdie-ai 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 "$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) + 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.11 -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 " clawdie-ai skills: $IMPORTED imported, $SKIPPED skipped" -- 2.45.3