#!/bin/sh # Symlink every skill and steering module of this repo into ~/.kiro. # # The script is idempotent. A link that already points at this repo is # left alone. A link that points elsewhere, or a real directory with the # same name, is reported and skipped, so the script never overwrites work # that this repo does not own. # # Usage: # ./install.sh Install into ~/.kiro. # KIRO_HOME=/x ./install.sh Install into /x instead. # # Exit status: 0 when every asset is linked, 1 when at least one was skipped. set -eu repo=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) kiro=${KIRO_HOME:-"$HOME/.kiro"} status=0 link_asset() { # $1: asset type directory (skills or steering) # $2: asset directory inside the repo type=$1 src=$2 name=$(basename -- "$src") dest_dir="$kiro/$type" dest="$dest_dir/$name" mkdir -p -- "$dest_dir" if [ -L "$dest" ]; then target=$(readlink -- "$dest") if [ "$target" = "$src" ]; then echo "ok $dest" else echo "skip $dest -> $target (not this repo)" >&2 status=1 fi elif [ -e "$dest" ]; then echo "skip $dest exists and is not a symlink" >&2 status=1 else ln -s -- "$src" "$dest" echo "linked $dest" fi } for type in skills steering; do for src in "$repo/$type"/*/; do [ -d "$src" ] || continue link_asset "$type" "${src%/}" done done exit "$status"