@@ -133,15 +133,31 @@ case "$ADAPTER" in
133133 echo " + AGENTS.md"
134134 fi
135135 mkdir -p " $TARGET /.pi"
136- # symlink .pi/skills -> .agent/skills so pi sees the one true skill tree.
137- # ln -sfn atomically replaces an existing symlink; fall back to cp -R
138- # on filesystems that don't support symlinks (e.g. Windows without dev mode).
136+ # Keep .pi/skills in sync with .agent/skills (the one true skill tree).
137+ # Handle three shapes explicitly: `ln -sfn src dest` against a REAL
138+ # directory silently creates `dest/<basename-of-src>` INSIDE the dir
139+ # on macOS/Linux and exits 0, which would leave stale orphans forever.
140+ # Check -L before -d so existing symlinks take the cheap repoint path,
141+ # and reserve the rsync path for real dirs left from a prior copy
142+ # fallback install.
139143 SKILLS_SRC=" $( cd " $TARGET /.agent/skills" && pwd) "
140- if ln -sfn " $SKILLS_SRC " " $TARGET /.pi/skills" 2> /dev/null; then
144+ SKILLS_DEST=" $TARGET /.pi/skills"
145+ if [[ -L " $SKILLS_DEST " ]]; then
146+ ln -sfn " $SKILLS_SRC " " $SKILLS_DEST "
147+ echo " + .pi/skills -> $SKILLS_SRC "
148+ elif [[ -d " $SKILLS_DEST " ]]; then
149+ if command -v rsync > /dev/null 2>&1 ; then
150+ rsync -a --delete " $SKILLS_SRC /" " $SKILLS_DEST /"
151+ echo " ~ synced .agent/skills → .pi/skills (rsync --delete)"
152+ else
153+ rm -rf " $SKILLS_DEST "
154+ cp -R " $SKILLS_SRC " " $SKILLS_DEST "
155+ echo " ~ replaced .pi/skills with current .agent/skills (no rsync)"
156+ fi
157+ elif ln -sfn " $SKILLS_SRC " " $SKILLS_DEST " 2> /dev/null; then
141158 echo " + .pi/skills -> $SKILLS_SRC "
142159 else
143- rm -rf " $TARGET /.pi/skills"
144- cp -R " $SKILLS_SRC " " $TARGET /.pi/skills"
160+ cp -R " $SKILLS_SRC " " $SKILLS_DEST "
145161 echo " + .pi/skills (copy; symlink not supported here)"
146162 fi
147163 ;;
0 commit comments