Merge remote-tracking branch 'origin/main'
# Conflicts: # home.nix # rebuild.sh
This commit is contained in:
commit
05892f45f2
8 files changed
+203
-6
No files matched your search
@@ -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"
|
||||
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" \
|
||||
PATH="$TMP/homebrew/bin:/usr/bin:/bin" \
|
||||
timeout 60 zsh -f -i -c '
|
||||
|
||||
@@ -105,6 +105,15 @@ elif kind in ("no-mistakes", "hermes", "nix", "npx", "pi"):
|
||||
else:
|
||||
state["components"][kind] = "new"
|
||||
save()
|
||||
elif kind == "brew":
|
||||
if state.get("fail_brew_trust"):
|
||||
sys.exit(1)
|
||||
trusted = state.setdefault("trusted_taps", [])
|
||||
if len(args) >= 2 and args[0] == "trust" and args[1] not in trusted:
|
||||
trusted.append(args[1])
|
||||
# The rename notice is a harmless brew warning, never a rebuild failure.
|
||||
print("Warning: Formula whisper-cpp was renamed to whisper.cpp.")
|
||||
save()
|
||||
elif kind == "sudo":
|
||||
sys.exit(state.get("switch_status", 0))
|
||||
else:
|
||||
@@ -174,7 +183,9 @@ class RebuildUpdates(unittest.TestCase):
|
||||
self.state = json.loads((self.root / "state.json").read_text())
|
||||
self.calls = [json.loads(line) for line in
|
||||
(self.root / "calls.jsonl").read_text().splitlines()]
|
||||
self.assertFalse(any(call[0] in ("brew", "bare-npm") for call in self.calls))
|
||||
self.assertFalse(any(call[0] == "bare-npm" for call in self.calls))
|
||||
self.assertFalse(any(call[0] == "brew" and (len(call) < 2 or call[1] != "trust")
|
||||
for call in self.calls))
|
||||
self.assertFalse(any(call[:2] == ["npm", "view"] and
|
||||
call[2] in ACTIVATION_GLOBALS for call in self.calls))
|
||||
self.assertEqual(Path(os.readlink(self.home / ".dotfiles")), ROOT)
|
||||
@@ -210,6 +221,46 @@ class RebuildUpdates(unittest.TestCase):
|
||||
self.execute()
|
||||
self.assertFalse(any(call[:2] == ["npm", "install"] for call in self.calls))
|
||||
|
||||
def test_brew_trust_is_restored_before_switch(self):
|
||||
output = self.execute()
|
||||
self.assert_update_order()
|
||||
trust_calls = [call for call in self.calls if call[0] == "brew"]
|
||||
self.assertEqual(trust_calls, [
|
||||
["brew", "trust", "can1357/tap"],
|
||||
["brew", "trust", "incoai/tap"],
|
||||
])
|
||||
switch_index = next(i for i, call in enumerate(self.calls)
|
||||
if call[0] == "sudo")
|
||||
self.assertLess(self.calls.index(trust_calls[-1]), switch_index)
|
||||
self.assertEqual(self.state["trusted_taps"],
|
||||
["can1357/tap", "incoai/tap"])
|
||||
self.assertIn("whisper-cpp was renamed", output)
|
||||
self.assertNotIn("brew bundle failed", output)
|
||||
|
||||
def test_brew_trust_failure_still_switches(self):
|
||||
self.state["fail_brew_trust"] = True
|
||||
self.execute()
|
||||
self.assertTrue(any(call[0] == "sudo" 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):
|
||||
self.state["packages"] = {}
|
||||
self.execute()
|
||||
@@ -248,7 +299,8 @@ class RebuildUpdates(unittest.TestCase):
|
||||
(self.home / ".no-mistakes/bin/no-mistakes").unlink()
|
||||
output = self.execute()
|
||||
self.assertGreaterEqual(output.count("WARNING:"), 5)
|
||||
self.assertEqual([call[0] for call in self.calls], ["nix", "sudo"])
|
||||
self.assertEqual([call[0] for call in self.calls],
|
||||
["nix", "brew", "brew", "sudo"])
|
||||
|
||||
def test_no_mistakes_path_fallback(self):
|
||||
(self.home / ".no-mistakes/bin/no-mistakes").unlink()
|
||||
|
||||
@@ -15,5 +15,6 @@ status=0
|
||||
"$ROOT/tests/rebuild-update-steps.sh" || status=1
|
||||
"$ROOT/tests/bird-brave-e2e.sh" || status=1
|
||||
"$ROOT/tests/bird-path.sh" || status=1
|
||||
"$ROOT/tests/skill-denylist.sh" || status=1
|
||||
|
||||
exit "$status"
|
||||
Executable
+59
@@ -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"
|
||||
Reference in new issue
Block a user