feat: install.sh — description, tags, preview et intro dans le menu fzf

- Ligne : description tronquée + tags #tag visibles
- Preview (45% droite) : contenu complet du skill au survol
- Intro : explication des touches avant le menu
- REPO_DIR exporté dans fns_file pour le script preview

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 05:35:49 +02:00
parent f40ddcb889
commit 436578968e
+41 -7
View File
@@ -184,6 +184,16 @@ get_frontmatter_field() {
grep "^${field}:" "$file" 2>/dev/null | head -1 | awk '{print $2}' | tr -d "\"'"
}
get_frontmatter_desc() {
grep "^description:" "$1" 2>/dev/null | head -1 \
| sed 's/^description:[[:space:]]*//' | tr -d "\"'" | tr '|' ',' | cut -c1-55
}
get_frontmatter_tags() {
grep "^tags:" "$1" 2>/dev/null | head -1 \
| sed 's/^tags:[[:space:]]*//' | tr -d '[] ' | tr ',' '#' | sed 's/^/#/'
}
# Retourne 0 (succès) si ver2 est plus récente que ver1
version_is_newer() {
local ver1="$1" ver2="$2"
@@ -255,7 +265,9 @@ scan_skills() {
etat="ok"
fi
SKILLS_LIST+=("${cat}|${skill}|${agent}|${etat}|${repo_ver}|${local_ver}")
local desc; desc=$(get_frontmatter_desc "$skill_file")
local tags; tags=$(get_frontmatter_tags "$skill_file")
SKILLS_LIST+=("${cat}|${skill}|${agent}|${etat}|${repo_ver}|${local_ver}|${desc}|${tags}")
debug "Skill trouvé : $cat/$skill [$agent] état=$etat"
done < <(find "${REPO_DIR}/skills" -name "*.md" | sort)
@@ -302,8 +314,8 @@ state_cycle() {
# ── Formatage ligne menu ──────────────────────────────────────────
format_skill_line() {
local entry="$1"
local cat skill agent etat repo_ver local_ver
IFS='|' read -r cat skill agent etat repo_ver local_ver <<< "$entry"
local cat skill agent etat repo_ver local_ver desc tags
IFS='|' read -r cat skill agent etat repo_ver local_ver desc tags <<< "$entry"
local key; key=$(make_key "$entry")
local action; action=$(state_get "$key")
@@ -328,18 +340,23 @@ format_skill_line() {
[[ "$etat" == "upd" ]] && ver_info=" (${local_ver}${repo_ver})"
[[ "$etat" == "new" ]] && ver_info=" (v${repo_ver})"
printf "${color_etat}%s${RESET} %-35s ${GRV_GRAY}[%s]${RESET} ${color_action}%s${RESET}%s\n" \
"$ico_etat" "${cat}/${skill}" "$agent" "$ico_action" "$ver_info"
printf "${color_etat}%s${RESET} %-28s ${GRV_GRAY}[%s]${RESET} ${color_action}%s${RESET}%s ${GRV_FG}%s${RESET} ${GRV_PURPLE}%s${RESET}\n" \
"$ico_etat" "${cat}/${skill}" "$agent" "$ico_action" "$ver_info" "$desc" "$tags"
}
# ── Menu fzf principal ────────────────────────────────────────────
run_menu() {
header "Sélection des skills"
echo -e " ${GRV_FG}Navigation :${RESET} ${GRV_YELLOW}↑↓${RESET} se déplacer ${GRV_GREEN}TAB${RESET} changer l'action ${GRV_GREEN}ENTER${RESET} confirmer ${GRV_RED}ESC${RESET} annuler"
echo -e " ${GRV_GRAY}Taper du texte filtre les skills par nom ou description.${RESET}\n"
state_init
local cycle_script="/tmp/skills_cycle_$$.sh"
local list_script="/tmp/skills_list_$$.sh"
local fns_file="/tmp/skills_fns_$$.sh"
local preview_script="/tmp/skills_preview_$$.sh"
# Script de cycle d'état (appelé par fzf via execute-silent)
cat > "$cycle_script" << 'CYCLE_EOF'
@@ -373,12 +390,27 @@ CYCLE_EOF
# Exporter fonctions et variables dans un fichier source
{
declare -f format_skill_line state_get make_key
declare -p GRV_GREEN GRV_YELLOW GRV_AQUA GRV_GRAY GRV_BLUE RESET \
declare -p GRV_GREEN GRV_YELLOW GRV_AQUA GRV_GRAY GRV_BLUE GRV_FG GRV_PURPLE RESET \
ICO_OK ICO_UPD ICO_NEW ICO_NA ICO_LOCAL ICO_GLOBAL ICO_SKIP
echo "STATE_FILE='$STATE_FILE'"
echo "REPO_DIR='$REPO_DIR'"
echo "SKILLS_LIST=($(printf '"%s" ' "${SKILLS_LIST[@]}"))"
} > "$fns_file"
# Script de prévisualisation du skill (appelé par fzf --preview)
cat > "$preview_script" << 'PREVIEW_EOF'
#!/usr/bin/env bash
source "$1"
idx=$(( $2 - 1 ))
entry="${SKILLS_LIST[$idx]:-}"
[[ -z "$entry" ]] && exit 0
IFS='|' read -r cat skill agent _ <<< "$entry"
skill_file="${REPO_DIR}/skills/${cat}/${skill}/${agent}.md"
[[ -f "$skill_file" ]] && cat "$skill_file" || echo "Fichier introuvable : $skill_file"
PREVIEW_EOF
sed -i "s|\"\$1\"|\"$fns_file\"|" "$preview_script"
chmod +x "$preview_script"
# Script générateur de liste pour fzf --reload
cat > "$list_script" << LIST_EOF
#!/usr/bin/env bash
@@ -396,10 +428,12 @@ LIST_EOF
--ansi \
--prompt="Skills > " \
--header="$legend" \
--preview="bash $preview_script {n}" \
--preview-window="right:45%:wrap" \
--bind="tab:execute-silent($cycle_script '$STATE_FILE' '$fns_file' {n})+reload($list_script)" \
< <(bash "$list_script") > /dev/null || true
rm -f "$cycle_script" "$list_script" "$fns_file"
rm -f "$cycle_script" "$list_script" "$fns_file" "$preview_script"
}
# ── Installation ──────────────────────────────────────────────────