no-mistakes(review): Manage lint tools and preserve Pi packages
This commit is contained in:
1 parent
4a31495181
commit
022967e277
4 files changed
+70
-48
No files matched your search
@@ -54,6 +54,14 @@ in
|
||||
ngrok # reverse TCP tunnel so the phone can SSH in over cellular (unfree)
|
||||
beets # music tagger / library organizer + navidrome sync plugin
|
||||
] ++ [ ytTranscribe ];
|
||||
home.file.".local/bin/actionlint" = {
|
||||
source = "${pkgs.actionlint}/bin/actionlint";
|
||||
force = true;
|
||||
};
|
||||
home.file.".local/bin/shellcheck" = {
|
||||
source = "${pkgs.shellcheck}/bin/shellcheck";
|
||||
force = true;
|
||||
};
|
||||
fonts.fontconfig.enable = true;
|
||||
home.sessionVariables.EDITOR = "nvim";
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ One `./rebuild.sh` run brings every installed component to its latest supported
|
||||
Before the switch:
|
||||
|
||||
- Installed npm globals through `/opt/homebrew/bin/npm`, never Nix's npm: `@steipete/bird`, `chrome-devtools-axi`, `defuddle`, `forgejo-axi`, `gh-axi`, `lavish-axi`, `quota-axi`, and `tasks-axi`. The script skips absent packages and compares each installed package with the registry before an update. `tasks-axi` keeps its firstmate floor of 0.2.6 in `home.activation.axiTools`, which now installs only a missing or older copy, so the latest release survives the switch.
|
||||
- Retired npm packages are removed only while their evidence still holds: `@opencode-ai/cli`, `opencode-ai`, and the June `pi-cli`/`pi-coding-agent` placeholders. The global `pi-context` is removed only when Pi keeps its own copy under `~/.pi/agent/npm`. If `pi` resolves into npm's global tree, the script warns and leaves those packages in place.
|
||||
- Retired npm OpenCode packages `@opencode-ai/cli` and `opencode-ai` are removed so their shims cannot conflict with the Homebrew formula.
|
||||
- `no-mistakes update`, using the binary at `~/.no-mistakes/bin/no-mistakes`.
|
||||
- `hermes update --yes`, which pulls the configured channel and restarts the services that run its new code.
|
||||
- `nix flake update`, so the switch builds from the newest locked inputs. Commit the resulting `flake.lock` change.
|
||||
@@ -92,13 +92,14 @@ During the switch:
|
||||
|
||||
- nix-darwin updates Homebrew formulae and casks through `configuration.nix`'s `onActivation.autoUpdate` and `onActivation.upgrade` settings.
|
||||
- `home.activation.backpass` updates `acpx` and `backpass`. Other activation steps install their declared npm packages when absent.
|
||||
- Home Manager replaces the standalone `~/.local/bin/actionlint` and `~/.local/bin/shellcheck` binaries with links to the packages selected by the updated flake. Later rebuilds update those links automatically.
|
||||
|
||||
After the switch:
|
||||
|
||||
- The Skills CLI updates every skill tracked in `~/.agents/.skill-lock.json`. The pinned pstack skills are not in that lock, so they stay on the `home.nix` revision (see [pstack skills](#pstack-skills-pinned-on-every-rebuild)). `security-audit` is excluded on purpose, because `home.nix` freezes it so a rebuild never pulls a new skill mid-session; renew it by hand with the command in [security-audit skill](#security-audit-skill-agent-security-reviews).
|
||||
- `pi update --extensions --no-approve`, run after the switch because the Homebrew bundle may have upgraded the `pi` binary.
|
||||
|
||||
Two tools have no supported updater: `actionlint` and `shellcheck` are standalone binaries in `~/.local/bin`, downloaded from their release pages. The rebuild does not replace them. Both were current on 2026-11-23 (actionlint 1.7.12, shellcheck 0.11.0); fetch a new release by hand when one is published. The pinned pstack tree also stays put; see its section for how to move it.
|
||||
`actionlint` and `shellcheck` follow the versions available in the selected nixpkgs revision, rather than separate release downloads. The pinned pstack tree stays put; see its section for how to move it.
|
||||
|
||||
## security-audit skill (agent security reviews)
|
||||
|
||||
|
||||
+2
-46
@@ -107,52 +107,6 @@ for link in /opt/homebrew/bin/*; do
|
||||
esac
|
||||
done
|
||||
|
||||
# The npm placeholders pi-cli@0.0.0, pi-coding-agent@0.0.1, and pi-context@2.0.0
|
||||
# are leftovers from June. Evidence they are retired, not live tools:
|
||||
# - pi-cli 0.0.0 is an unrelated 2022 package (gpio dependency) with no bin.
|
||||
# - pi-coding-agent 0.0.1 is a name-reservation placeholder with no bin; the
|
||||
# Homebrew formula owns /opt/homebrew/bin/pi.
|
||||
# - pi-context is installed and updated by Pi itself (~/.pi/agent/npm), and the
|
||||
# global copy has no bin.
|
||||
# Remove each only while those proofs hold. When pi or Pi's own copy is missing,
|
||||
# leave the global package alone and say why.
|
||||
echo "==> Removing retired npm pi packages..."
|
||||
if [ ! -x "$NPM" ]; then
|
||||
echo "==> WARNING: $NPM not found. Skipping retired pi package cleanup."
|
||||
else
|
||||
npm_root="$("$NPM" root -g 2>/dev/null || true)"
|
||||
pi_bin="$(command -v pi 2>/dev/null || true)"
|
||||
case "$pi_bin" in
|
||||
"$npm_root"/*)
|
||||
echo "==> WARNING: pi resolves to npm's global tree ($pi_bin). Leaving the npm pi packages in place."
|
||||
;;
|
||||
*)
|
||||
if [ -n "$npm_root" ]; then
|
||||
for pkg in pi-cli pi-coding-agent; do
|
||||
if [ -d "$npm_root/$pkg" ]; then
|
||||
if "$NPM" uninstall -g "$pkg" >/dev/null 2>&1; then
|
||||
echo "==> Removed retired npm package $pkg"
|
||||
else
|
||||
echo "==> WARNING: $pkg removal failed. Remove it manually: $NPM uninstall -g $pkg"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ -d "$HOME/.pi/agent/npm/node_modules/pi-context" ]; then
|
||||
if [ -d "$npm_root/pi-context" ]; then
|
||||
if "$NPM" uninstall -g pi-context >/dev/null 2>&1; then
|
||||
echo "==> Removed unused global pi-context (Pi keeps its own copy)"
|
||||
else
|
||||
echo "==> WARNING: pi-context removal failed. Remove it manually: $NPM uninstall -g pi-context"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "==> WARNING: Pi's own pi-context package is missing. Leaving the global copy in place."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "==> Updating no-mistakes..."
|
||||
NO_MISTAKES_BIN="$HOME/.no-mistakes/bin/no-mistakes"
|
||||
if [ -x "$NO_MISTAKES_BIN" ]; then
|
||||
@@ -198,6 +152,8 @@ managed=(
|
||||
"$HOME/.config/opencode/opencode.json"
|
||||
"$HOME/.config/opencode2/opencode.json"
|
||||
"$HOME/.config/opencode2/AGENTS.md"
|
||||
"$HOME/.local/bin/actionlint"
|
||||
"$HOME/.local/bin/shellcheck"
|
||||
"$HOME/.local/bin/oc2"
|
||||
"$HOME/.local/bin/opencode-go-token"
|
||||
"$HOME/.local/bin/opencode-go-key-sync"
|
||||
|
||||
@@ -268,11 +268,68 @@ class RebuildUpdates(unittest.TestCase):
|
||||
self.assertEqual(self.state["skills"]["security-audit"], "old")
|
||||
self.assertIn(["pi", "update", "--extensions", "--no-approve"], self.calls)
|
||||
|
||||
def test_pi_packages_are_not_retired(self):
|
||||
packages = ("pi-cli", "pi-coding-agent", "pi-context")
|
||||
for name in packages:
|
||||
(self.root / "global_modules" / name).mkdir(parents=True)
|
||||
self.state["packages"][name] = "1.0.0"
|
||||
for private_copy in (False, True):
|
||||
with self.subTest(private_copy=private_copy):
|
||||
if private_copy:
|
||||
(self.home / ".pi/agent/npm/node_modules/pi-context").mkdir(parents=True)
|
||||
self.execute()
|
||||
self.assertFalse(any(call[:2] == ["npm", "uninstall"] and
|
||||
call[-1] in packages for call in self.calls))
|
||||
for name in packages:
|
||||
self.assertEqual(self.state["packages"][name], "1.0.0")
|
||||
self.assertTrue((self.root / "global_modules" / name).is_dir())
|
||||
self.assertIn(["pi", "update", "--extensions", "--no-approve"], self.calls)
|
||||
|
||||
def test_managed_lint_tool_backups_rotate(self):
|
||||
for name in ("actionlint", "shellcheck"):
|
||||
path = self.home / ".local/bin" / (name + ".backup")
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("previous binary")
|
||||
self.execute()
|
||||
for name in ("actionlint", "shellcheck"):
|
||||
path = self.home / ".local/bin" / (name + ".backup")
|
||||
self.assertFalse(path.exists())
|
||||
rotated = list(path.parent.glob(name + ".backup.*"))
|
||||
self.assertEqual(len(rotated), 1)
|
||||
self.assertEqual(rotated[0].read_text(), "previous binary")
|
||||
|
||||
def test_switch_failure_stops_post_switch_updates(self):
|
||||
self.state["switch_status"] = 1
|
||||
self.execute()
|
||||
self.assertFalse(any(call[0] in ("npx", "pi") for call in self.calls))
|
||||
|
||||
|
||||
class ManagedLintTools(unittest.TestCase):
|
||||
def test_commands_follow_selected_nixpkgs_packages(self):
|
||||
nix = shutil.which("nix")
|
||||
self.assertIsNotNone(nix, "Missing required test tool: nix")
|
||||
expression = '''
|
||||
let
|
||||
system = (builtins.getFlake (toString ./.)).darwinConfigurations."lt-mbp";
|
||||
files = system.config.home-manager.users.laptran.home.file;
|
||||
in builtins.map (name: {
|
||||
inherit name;
|
||||
source = toString files.${".local/bin/" + name}.source;
|
||||
force = files.${".local/bin/" + name}.force;
|
||||
package = toString system.pkgs.${name};
|
||||
}) [ "actionlint" "shellcheck" ]
|
||||
'''
|
||||
result = subprocess.run(
|
||||
[nix, "eval", "--json", "--impure", "--expr", expression],
|
||||
cwd=ROOT, text=True, capture_output=True, timeout=120,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
for command in json.loads(result.stdout):
|
||||
with self.subTest(name=command["name"]):
|
||||
self.assertEqual(command["source"],
|
||||
command["package"] + "/bin/" + command["name"])
|
||||
self.assertTrue(command["force"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user