add .mandatory, update learn.sh and sync-skills.sh to use it

This commit is contained in:
lyn
2026-04-17 13:09:40 +00:00
parent 95cf7b85fa
commit eb168a11a6
3 changed files with 52 additions and 25 deletions

2
.mandatory Normal file
View File

@@ -0,0 +1,2 @@
git-hangman-lab
keycloak-hangman-lab

View File

@@ -9,24 +9,41 @@ fi
SKILL_LIST="${AGENT_WORKSPACE}/.skill-list"
TARGET_DIR="${AGENT_WORKSPACE}/skills"
CLAW_DIR="$(cd "$(dirname "$0")" && pwd)"
MANDATORY_FILE="${CLAW_DIR}/.mandatory"
if [[ ! -f "$SKILL_LIST" ]]; then
mkdir -p "$TARGET_DIR"
# First: install mandatory skills from .mandatory (one per line)
if [[ -f "$MANDATORY_FILE" ]]; then
while IFS= read -r skill_name || [[ -n "$skill_name" ]]; do
[[ -z "$skill_name" || "$skill_name" == \#* ]] && continue
skill_dir="${CLAW_DIR}/${skill_name}"
if [[ -d "$skill_dir" ]]; then
echo "Installing (mandatory): $skill_name"
cp -r "$skill_dir" "${TARGET_DIR}/"
else
echo "Skipping (not found): $skill_name"
fi
done < "$MANDATORY_FILE"
fi
# Then: install skills from .skill-list
if [[ -f "$SKILL_LIST" ]]; then
while IFS= read -r skill_name || [[ -n "$skill_name" ]]; do
[[ -z "$skill_name" || "$skill_name" == \#* ]] && continue
skill_dir="${CLAW_DIR}/${skill_name}"
if [[ -d "$skill_dir" ]]; then
echo "Installing: $skill_name"
cp -r "$skill_dir" "${TARGET_DIR}/"
else
echo "Skipping (not found): $skill_name"
fi
done < "$SKILL_LIST"
else
echo "Error: .skill-list not found at $SKILL_LIST"
exit 1
fi
mkdir -p "$TARGET_DIR"
while IFS= read -r skill_name || [[ -n "$skill_name" ]]; do
[[ -z "$skill_name" || "$skill_name" == \#* ]] && continue
skill_dir="${CLAW_DIR}/${skill_name}"
if [[ -d "$skill_dir" ]]; then
echo "Installing: $skill_name"
cp -r "$skill_dir" "${TARGET_DIR}/"
else
echo "Skipping (not found): $skill_name"
fi
done < "$SKILL_LIST"
echo "Done."
echo "Done."

View File

@@ -1,19 +1,27 @@
#!/bin/bash
# Sync all skill folders from ClawSkills to ~/.openclaw/skills
# Sync skills listed in .mandatory from ClawSkills to ~/.openclaw/skills
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_DIR="$HOME/.openclaw/skills"
MANDATORY_FILE="${SCRIPT_DIR}/.mandatory"
mkdir -p "$SKILLS_DIR"
for folder in "$SCRIPT_DIR"/*/; do
folder_name=$(basename "$folder")
# Skip this script itself
if [[ "$folder_name" == "sync-skills.sh" ]]; then
continue
if [[ ! -f "$MANDATORY_FILE" ]]; then
echo "Error: .mandatory not found at $MANDATORY_FILE"
exit 1
fi
while IFS= read -r skill_name || [[ -n "$skill_name" ]]; do
[[ -z "$skill_name" || "$skill_name" == \#* ]] && continue
skill_dir="${SCRIPT_DIR}/${skill_name}"
if [[ -d "$skill_dir" ]]; then
echo "Copying $skill_name to $SKILLS_DIR..."
cp -rf "$skill_dir" "$SKILLS_DIR/"
else
echo "Skipping (not found): $skill_name"
fi
echo "Copying $folder_name to $SKILLS_DIR..."
cp -rf "$folder" "$SKILLS_DIR/"
done
done < "$MANDATORY_FILE"
echo "Done!"