#!/usr/bin/env bash # Install Anthropic-style skills (each a directory with SKILL.md, optionally a # references/ subfolder) into EVERY agent's workspace on a board. # # Why per-agent workspace and not a shared bundle: ZeroClaw's `read_skill` # returns only SKILL.md; a skill's `references/*.md` are read via the general # `file_read` tool, which is workspace-sandboxed. So references are only # reachable when the skill lives under an agent's own workspace # (`~/.zeroclaw/agents//workspace/skills//`). A shared/skills bundle # surfaces the skill but its references get blocked by the file_read sandbox. # # The skill NAME is the directory name (not the frontmatter `name`). # # ./push-skill.sh [path] # path with a SKILL.md → install that one skill # path that CONTAINS skill dirs → install every skill under it # (default: this script's skills/ directory — all bundled skills) set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" SERIAL="${1:?usage: push-skill.sh [skill-dir | skills-parent-dir]}" SRC="${2:-$HERE/skills}" ZC="/home/arduino/.zeroclaw" # Resolve the list of skill dirs to install: either SRC itself (single skill) or # each immediate child of SRC that has a SKILL.md. skills=() if [ -r "$SRC/SKILL.md" ]; then skills=("$SRC") else for d in "$SRC"/*/; do [ -r "${d}SKILL.md" ] && skills+=("${d%/}") done fi [ "${#skills[@]}" -gt 0 ] || { echo "no skills found under $SRC" >&2; exit 1; } # Discover agent aliases from the board's config-created workspaces; fall back to # the standard set if the listing is empty. agents="$(adb -s "$SERIAL" shell "ls $ZC/agents 2>/dev/null" 2>/dev/null | tr -d '\r' | tr '\n' ' ')" [ -n "${agents// /}" ] || agents="default cloud local" install_one() { # skill_dir alias -> 0 ok / 1 fail local sdir="$1" alias="$2" name dest name="$(basename "$sdir")" dest="$ZC/agents/$alias/workspace/skills/$name" adb -s "$SERIAL" shell "mkdir -p '$dest'" >/dev/null 2>&1 || return 1 adb -s "$SERIAL" push "$sdir/SKILL.md" "$dest/" >/dev/null 2>&1 || return 1 # ship a references/ subfolder if the skill has one if [ -d "$sdir/references" ]; then adb -s "$SERIAL" shell "mkdir -p '$dest/references'" >/dev/null 2>&1 adb -s "$SERIAL" push "$sdir/references/." "$dest/references/" >/dev/null 2>&1 || return 1 fi return 0 } total_ok=0 for a in $agents; do a="$(printf '%s' "$a" | tr -d ' \r')"; [ -z "$a" ] && continue n=0 for sdir in "${skills[@]}"; do install_one "$sdir" "$a" && n=$((n + 1)) done echo " ok — $a ($n/${#skills[@]} skills)" total_ok=$((total_ok + n)) done echo "installed ${#skills[@]} skill(s) across the board's agent workspaces ($total_ok pushes) on $SERIAL" [ "$total_ok" -gt 0 ]