From dc27aabbb8ae451433a43473015383b285aff587 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 27 Aug 2026 12:37:13 +0000 Subject: [PATCH] fix(env): fail-fast install and harden skill-linking (code review) Addresses code-review feedback: - .cursor/environment.json: chain install with '&&' so a failing 'npm ci' short-circuits instead of running the link step unconditionally. - scripts/link-agent-skills.sh: replace a pre-existing real (non-symlink) directory at the target before linking, so ln never nests a link inside it. - Correct the header comment to match the actual install-step wiring. Co-authored-by: Prax Lannister --- .cursor/environment.json | 2 +- scripts/link-agent-skills.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.cursor/environment.json b/.cursor/environment.json index 6226e4b..622a756 100644 --- a/.cursor/environment.json +++ b/.cursor/environment.json @@ -1,6 +1,6 @@ { "name": "AI Visual Code Review", - "install": "npm ci\nbash scripts/link-agent-skills.sh", + "install": "npm ci && bash scripts/link-agent-skills.sh", "terminals": [ { "name": "server", diff --git a/scripts/link-agent-skills.sh b/scripts/link-agent-skills.sh index d09cdc9..293d4c5 100755 --- a/scripts/link-agent-skills.sh +++ b/scripts/link-agent-skills.sh @@ -7,10 +7,10 @@ # (Claude Code, Cursor) and ~/.agents/skills (Codex, Prime Agent) globally, # not just from this repo's working tree. # -# Idempotent and safe to run on every boot: it skips gracefully when the -# repo skill directories are not present (e.g. before the skills PR is merged). +# Idempotent and safe to run repeatedly: it skips gracefully when the repo +# skill directories are not present (e.g. before the skills PR is merged). # -# Called from `.cursor/environment.json` install after `npm ci`. +# Called from `.cursor/environment.json` install (after `npm ci`). set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -24,6 +24,11 @@ link_packs() { for pack in "$repo_dir"/*/; do [ -d "$pack" ] || continue name="$(basename "$pack")" + # If a real (non-symlink) directory/file already occupies the target, + # remove it first so ln does not create a nested link inside it. + if [ -e "$home_dir/$name" ] && [ ! -L "$home_dir/$name" ]; then + rm -rf "$home_dir/$name" + fi ln -sfn "${pack%/}" "$home_dir/$name" echo "link-agent-skills: linked $home_dir/$name -> ${pack%/}" done