fix(skills): share deleted-upstream denylist between Nix and rebuild

This commit is contained in:
hermes committed 2026-11-29 13:22:54 -05:00
1 parent 72a23ff0d0
commit e4c67f0080
8 files changed
+159 -2

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
agent-self-scheduling
codex-goal-loop
delegating-to-agents
markdown-rendering
run-deep-swe
cyber-audit
pi-custom-model
vps-server-management
pi-web-search
research-prompt
youtube-polls
youtube-transcript
distribute-skill-to-all-agents
folder-specific-claude-and-agents-md
push-skill-to-github
brain-to-docs
grill-me
interview-style-doc-building
short
teach
+40
View File
@@ -33,6 +33,13 @@ let
rev = "6b0300214a09fd6029cfb7077043125758cd1fd2"; rev = "6b0300214a09fd6029cfb7077043125758cd1fd2";
hash = "sha256-TDuZ1v+taPdqyvvCs1VHUjtpSy8zHxhQKJv/kIPTpK8="; hash = "sha256-TDuZ1v+taPdqyvvCs1VHUjtpSy8zHxhQKJv/kIPTpK8=";
}; };
# Skills deleted upstream from davidondrej/skills. rebuild.sh reads the same
# file to keep these names out of the Skills CLI update. One name per line.
deletedSkillNames = lib.pipe (builtins.readFile ./deleted-upstream-skills.txt) [
(lib.splitString "\n")
(map lib.trim)
(builtins.filter (name: name != ""))
];
in in
{ {
@@ -603,6 +610,39 @@ in
echo "pstackSkills: installed ${toString (lib.length pstackSkillNames)} pinned skills into $dest" echo "pstackSkills: installed ${toString (lib.length pstackSkillNames)} pinned skills into $dest"
''; '';
# Remove only the skills deleted upstream from davidondrej/skills. The names
# come from the source-controlled denylist that rebuild.sh also reads. The
# guard below leaves every other skill, the skill lock, house-authored skills,
# and the pinned pstack copies alone. Only exact directory or link names in
# the agent skill folders used on this Mac are removed.
home.activation.removeDeletedUpstreamSkills = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
set -euo pipefail
deny_file=${./deleted-upstream-skills.txt}
if [ ! -r "$deny_file" ]; then
echo "removeDeletedUpstreamSkills: denylist missing at $deny_file" >&2
exit 1
fi
skill_dirs=(
"$HOME/.agents/skills"
"$HOME/.claude/skills"
"$HOME/.config/opencode/skills"
"$HOME/.grok/skills"
)
count=0
while IFS= read -r name; do
[ -n "$name" ] || continue
count=$((count + 1))
for dir in "''${skill_dirs[@]}"; do
target="$dir/$name"
if [ -e "$target" ] || [ -L "$target" ]; then
rm -rf -- "$target"
echo "removeDeletedUpstreamSkills: removed $target"
fi
done
done < "$deny_file"
echo "removeDeletedUpstreamSkills: checked $count deleted skill names"
'';
# OpenSuperWhisper - local voice-first prompting (cask in configuration.nix). # OpenSuperWhisper - local voice-first prompting (cask in configuration.nix).
# The app reads its model from its own Application Support directory, so the # The app reads its model from its own Application Support directory, so the
# 1.6 GB Whisper model is downloaded here once and kept outside the Nix store. # 1.6 GB Whisper model is downloaded here once and kept outside the Nix store.
+11
View File
@@ -115,6 +115,17 @@ After the switch:
- The Skills CLI updates skills tracked in `~/.agents/.skill-lock.json`, except `security-audit`. See [security-audit skill](#security-audit-skill-agent-security-reviews) for its freeze policy and manual update command. Untracked skills receive no update here. See [pstack skills](#pstack-skills-pinned-on-every-rebuild) for the pinned skills and their update procedure. - The Skills CLI updates skills tracked in `~/.agents/.skill-lock.json`, except `security-audit`. See [security-audit skill](#security-audit-skill-agent-security-reviews) for its freeze policy and manual update command. Untracked skills receive no update here. See [pstack skills](#pstack-skills-pinned-on-every-rebuild) for the pinned skills and their update procedure.
- `pi update --extensions --no-approve`, run after the switch because the Homebrew bundle may have upgraded the `pi` binary. - `pi update --extensions --no-approve`, run after the switch because the Homebrew bundle may have upgraded the `pi` binary.
## Deleted upstream skills denylist
`deleted-upstream-skills.txt` at the repo root names the 20 skills deleted upstream from `davidondrej/skills`. It holds one name per line. Both paths read this same source-controlled file:
- `rebuild.sh` filters those names out of the `skills@latest update` arguments, even when they return to `~/.agents/.skill-lock.json`.
- `home.nix` reads the file into `deletedSkillNames` and runs `home.activation.removeDeletedUpstreamSkills`. That step removes only exact directory or link names under `~/.agents/skills`, `~/.claude/skills`, `~/.config/opencode/skills`, and `~/.grok/skills`. It leaves the skill lock, house-authored skills, pinned pstack skills, and every other skill untouched.
The list keeps local skill trees in sync with upstream. It also stops a deleted skill from returning through the CLI updater. Add a name here only when upstream deletes that skill. Do not add house-authored or pinned names.
`tests/skill-denylist.sh` checks that both paths read the list. `tests/rebuild-update-steps.py` runs `rebuild.sh` with a lock that contains denied names and asserts the update call excludes them.
## security-audit skill (agent security reviews) ## security-audit skill (agent security reviews)
`home.activation.securityAuditSkill` installs Cloudflare's `security-audit` skill from `https://github.com/cloudflare/security-audit-skill` so the coding agents can run a structured vulnerability audit. The exact command: `home.activation.securityAuditSkill` installs Cloudflare's `security-audit` skill from `https://github.com/cloudflare/security-audit-skill` so the coding agents can run a structured vulnerability audit. The exact command:
+8 -2
View File
@@ -13,6 +13,8 @@
# A failed switch stops the script before post-switch updates. # A failed switch stops the script before post-switch updates.
set -euo pipefail set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
# Shared with home.nix: skills deleted upstream must stay out of the CLI update.
DENYLIST="$DIR/deleted-upstream-skills.txt"
ln -sfn "$DIR" ~/.dotfiles ln -sfn "$DIR" ~/.dotfiles
NPM=/opt/homebrew/bin/npm NPM=/opt/homebrew/bin/npm
@@ -205,15 +207,19 @@ if [ ! -x "$NPX" ]; then
echo "==> WARNING: $NPX not found. Skipping agent skill update." echo "==> WARNING: $NPX not found. Skipping agent skill update."
elif [ ! -f "$SKILL_LOCK" ]; then elif [ ! -f "$SKILL_LOCK" ]; then
echo "==> WARNING: $SKILL_LOCK not found. Skipping agent skill update." echo "==> WARNING: $SKILL_LOCK not found. Skipping agent skill update."
elif [ ! -f "$DENYLIST" ]; then
echo "==> WARNING: $DENYLIST not found. Skipping agent skill update."
else else
skill_names="$(/usr/bin/python3 - "$SKILL_LOCK" 2>/dev/null <<'PY' || true skill_names="$(/usr/bin/python3 - "$SKILL_LOCK" "$DENYLIST" 2>/dev/null <<'PY' || true
import json import json
import sys import sys
with open(sys.argv[1]) as lock_file: with open(sys.argv[1]) as lock_file:
skills = json.load(lock_file).get("skills", {}) skills = json.load(lock_file).get("skills", {})
with open(sys.argv[2]) as deny_file:
denied = {line.strip() for line in deny_file if line.strip()}
for name in sorted(skills): for name in sorted(skills):
if name != "security-audit": if name != "security-audit" and name not in denied:
print(name) print(name)
PY PY
)" )"
+1
View File
@@ -44,6 +44,7 @@ printf '#!/bin/sh\nprintf wrapper\n' > "$TMP/home/.pi/agent/bin/bird"
printf '#!/bin/sh\nprintf homebrew\n' > "$TMP/homebrew/bin/bird" printf '#!/bin/sh\nprintf homebrew\n' > "$TMP/homebrew/bin/bird"
chmod +x "$TMP/home/.pi/agent/bin/bird" "$TMP/homebrew/bin/bird" chmod +x "$TMP/home/.pi/agent/bin/bird" "$TMP/homebrew/bin/bird"
# shellcheck disable=SC2016 # the snippet expands inside the fresh zsh
resolved=$(HOME="$TMP/home" ZSHRC="$TMP/zshrc" \ resolved=$(HOME="$TMP/home" ZSHRC="$TMP/zshrc" \
PATH="$TMP/homebrew/bin:/usr/bin:/bin" \ PATH="$TMP/homebrew/bin:/usr/bin:/bin" \
timeout 60 zsh -f -i -c ' timeout 60 zsh -f -i -c '
+19
View File
@@ -210,6 +210,25 @@ class RebuildUpdates(unittest.TestCase):
self.execute() self.execute()
self.assertFalse(any(call[:2] == ["npm", "install"] for call in self.calls)) self.assertFalse(any(call[:2] == ["npm", "install"] for call in self.calls))
def test_deleted_upstream_skills_never_reach_the_cli(self):
denied = (ROOT / "deleted-upstream-skills.txt").read_text().split()
self.assertEqual(len(denied), 20)
names = denied + ["tdd", "security-audit", "codebase-design"]
(self.home / ".agents/.skill-lock.json").write_text(
json.dumps({"skills": {name: {} for name in names}}))
self.state["skills"] = {name: "old" for name in names}
self.execute()
skills_call = next(call for call in self.calls if call[0] == "npx")
for name in denied:
self.assertNotIn(name, skills_call)
self.assertEqual(self.state["skills"][name], "old")
self.assertIn("tdd", skills_call)
self.assertEqual(self.state["skills"]["tdd"], "new")
self.assertNotIn("security-audit", skills_call)
self.assertEqual(self.state["skills"]["security-audit"], "old")
self.assertIn("codebase-design", skills_call)
self.assertEqual(self.state["skills"]["codebase-design"], "new")
def test_absent_packages_are_not_installed_or_queried(self): def test_absent_packages_are_not_installed_or_queried(self):
self.state["packages"] = {} self.state["packages"] = {}
self.execute() self.execute()
+1
View File
@@ -15,5 +15,6 @@ status=0
"$ROOT/tests/rebuild-update-steps.sh" || status=1 "$ROOT/tests/rebuild-update-steps.sh" || status=1
"$ROOT/tests/bird-brave-e2e.sh" || status=1 "$ROOT/tests/bird-brave-e2e.sh" || status=1
"$ROOT/tests/bird-path.sh" || status=1 "$ROOT/tests/bird-path.sh" || status=1
"$ROOT/tests/skill-denylist.sh" || status=1
exit "$status" exit "$status"
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# End-to-end check for the shared deleted-upstream skill denylist.
#
# The same source-controlled file must drive both paths. home.nix copies it to
# the Nix store and reads it in home.activation.removeDeletedUpstreamSkills.
# rebuild.sh reads it from its own checkout before calling the Skills CLI. This
# check compares the Nix copy with the source file and confirms rebuild.sh uses
# the same name to filter CLI arguments. The CLI call itself is exercised with
# spies in tests/rebuild-update-steps.py.
set -euo pipefail
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
LIST="$ROOT/deleted-upstream-skills.txt"
CONFIG='(builtins.getFlake (toString '"$ROOT"')).darwinConfigurations."lt-mbp".config.home-manager.users.laptran'
fail() { printf 'FAIL: %s\n' "$1" >&2; exit 1; }
pass() { printf 'PASS: %s\n' "$1"; }
command -v nix >/dev/null 2>&1 \
|| { echo "skill-denylist: nix is required to evaluate the configuration" >&2; exit 2; }
[ -r "$LIST" ] || fail "denylist missing at $LIST"
expected='agent-self-scheduling
codex-goal-loop
delegating-to-agents
markdown-rendering
run-deep-swe
cyber-audit
pi-custom-model
vps-server-management
pi-web-search
research-prompt
youtube-polls
youtube-transcript
distribute-skill-to-all-agents
folder-specific-claude-and-agents-md
push-skill-to-github
brain-to-docs
grill-me
interview-style-doc-building
short
teach'
[ "$(cat "$LIST")" = "$expected" ] || fail "denylist does not hold the 20 expected names"
pass "denylist holds the 20 deleted upstream skills"
activation=$(nix eval --raw --impure --expr "$CONFIG.home.activation.removeDeletedUpstreamSkills.data")
nix_list=$(printf '%s\n' "$activation" | sed -n 's/^deny_file=//p')
[ -n "$nix_list" ] || fail "activation script does not reference a denylist file"
cmp -s "$nix_list" "$LIST" || fail "Nix denylist copy differs from $LIST"
pass "home.nix activation reads the same denylist"
# shellcheck disable=SC2016 # the literal line in rebuild.sh is the assertion
grep -qF 'DENYLIST="$DIR/deleted-upstream-skills.txt"' "$ROOT/rebuild.sh" \
|| fail "rebuild.sh does not read the shared denylist"
grep -qF 'name not in denied' "$ROOT/rebuild.sh" \
|| fail "rebuild.sh does not filter denied names from the Skills CLI call"
pass "rebuild.sh reads the same denylist and filters CLI arguments"