diff --git a/.mandatory b/.mandatory new file mode 100644 index 0000000..ad9eb09 --- /dev/null +++ b/.mandatory @@ -0,0 +1,2 @@ +git-hangman-lab +keycloak-hangman-lab diff --git a/learn.sh b/learn.sh index 6b5eeec..ba2af44 100755 --- a/learn.sh +++ b/learn.sh @@ -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." \ No newline at end of file +echo "Done." diff --git a/sync-skills.sh b/sync-skills.sh index d7d5769..800e2ae 100755 --- a/sync-skills.sh +++ b/sync-skills.sh @@ -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!"