#!/bin/sh
# skill_list — list available skill modules
set -e

skills_path="${XDG_CONFIG_HOME:-$HOME/.config}/ollie/skills"

if [ ! -d "$skills_path" ]; then
    echo "(no skills directory found)"
    exit 0
fi

for dir in "$skills_path"/*/; do
    [ -f "${dir}SKILL.md" ] || continue
    name=$(basename "$dir")
    # Extract description from YAML frontmatter
    desc=$(sed -n '/^---$/,/^---$/{ /^description:/{ s/^description: *//; p; } }' "${dir}SKILL.md")
    if [ -n "$desc" ]; then
        printf "%s — %s\n" "$name" "$desc"
    else
        printf "%s\n" "$name"
    fi
done
