fix(shell): keep generated ignores visible to Pi

This commit is contained in:
2026-07-29 17:01:22 -04:00
parent 02f2017b40
commit 40b37281d5
2 changed files with 62 additions and 20 deletions

View File

@@ -55,6 +55,7 @@ pkgs.runCommandLocal "skills-shell-hook-check"
# collides with a selected one, and a symlink pointing outside the store.
mkdir -p proj/.agents/skills/handmade
printf '%s\n' "a hand-authored skill" > proj/.agents/skills/handmade/SKILL.md
printf '%s\n' "# fixture ignore" "result" > proj/.gitignore
mkdir -p proj/.agents/skills/sample-gamma
printf '%s\n' "a hand-authored gamma" > proj/.agents/skills/sample-gamma/SKILL.md
ln -s /nonexistent/external-target proj/.agents/skills/external
@@ -94,18 +95,23 @@ pkgs.runCommandLocal "skills-shell-hook-check"
test -f .claude/skills/sample-alpha/SKILL.md \
|| fail "Claude Code compatibility link does not resolve selected skills"
echo "the .gitignore lists only the skills the hook actually linked, plus itself"
grep -qx '/.gitignore' .agents/skills/.gitignore || fail ".gitignore does not ignore itself"
grep -qx '/sample-alpha' .agents/skills/.gitignore || fail ".gitignore omits sample-alpha"
grep -qx '/sample-beta' .agents/skills/.gitignore || fail ".gitignore omits sample-beta"
for tracked in /handmade /sample-gamma /external; do
grep -qx "$tracked" .agents/skills/.gitignore \
echo "the project .gitignore lists only generated links and keeps skill scanners clear"
test ! -e .agents/skills/.gitignore || fail "the hook wrote an ignore file where skill scanners read it"
grep -qx '# fixture ignore' .gitignore || fail "the existing .gitignore content was lost"
grep -qx 'result' .gitignore || fail "the existing .gitignore pattern was lost"
grep -qx '# BEGIN mkSkillsShellHook' .gitignore || fail ".gitignore lacks the managed block start"
grep -qx '# END mkSkillsShellHook' .gitignore || fail ".gitignore lacks the managed block end"
grep -qx '.claude/skills' .gitignore || fail ".gitignore omits the compatibility symlink"
grep -qx '.agents/skills/sample-alpha' .gitignore || fail ".gitignore omits sample-alpha"
grep -qx '.agents/skills/sample-beta' .gitignore || fail ".gitignore omits sample-beta"
for tracked in .agents/skills/handmade .agents/skills/sample-gamma .agents/skills/external; do
grep -qx "$tracked" .gitignore \
&& fail ".gitignore lists $tracked, which would untrack a real path"
done
echo "no manifest or state file is written: only the fixtures and links exist"
entries=$(ls -A .agents/skills | sort | tr '\n' ' ')
[ "$entries" = ".gitignore external handmade sample-alpha sample-beta sample-gamma " ] \
[ "$entries" = "external handmade sample-alpha sample-beta sample-gamma " ] \
|| fail "unexpected entries under .agents/skills: [$entries]"
echo "second entry with sample-beta deselected: its symlink is removed, the rest stay"
@@ -119,10 +125,12 @@ pkgs.runCommandLocal "skills-shell-hook-check"
|| fail "the colliding hand-authored skill was disturbed on re-entry"
[ -L .agents/skills/external ] || fail "the non-store symlink was disturbed on re-entry"
echo "the .gitignore tracks the new selection"
grep -qx '/sample-alpha' .agents/skills/.gitignore || fail ".gitignore lost sample-alpha"
grep -qx '/sample-beta' .agents/skills/.gitignore \
echo "the .gitignore tracks the new selection without duplicating the managed block"
grep -qx '.agents/skills/sample-alpha' .gitignore || fail ".gitignore lost sample-alpha"
grep -qx '.agents/skills/sample-beta' .gitignore \
&& fail ".gitignore still lists the deselected sample-beta"
[ "$(grep -xc '# BEGIN mkSkillsShellHook' .gitignore)" = 1 ] \
|| fail ".gitignore has duplicate managed blocks"
touch "$out"
''