Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80fb47f050 | ||
|
|
e4c67f0080 | ||
|
|
72a23ff0d0 | ||
|
|
8378ac41fd | ||
|
|
aae4dfd6d0 | ||
|
|
fd96dc6dc0 | ||
|
|
ad55229df8 | ||
|
|
022967e277 | ||
|
|
4a31495181 | ||
|
|
4e1b65b5d2 | ||
|
|
cff3c8873e | ||
|
|
2e2578ead8 | ||
|
|
208e6741f3 | ||
|
|
53206f0a7b |
No files matched your search
@@ -10,7 +10,7 @@ Deliberate decisions in this repo - do NOT silently revert them:
|
|||||||
- Codex runs on the OpenCode Go subscription. The ChatGPT app owns and rewrites the live `~/.codex/config.toml`, so it is NOT symlinked; `home.activation.codexOpenCodeGo` merges the repo fragment `home/.codex/config.toml` into it on every rebuild, and the app's own sections (`[desktop]`, `[plugins]`, `[mcp_servers]`, ...) survive. Auth is command-backed via `~/.local/bin/opencode-go-token` (prints the key from the opencode store), so `~/.codex/auth.json` stays in ChatGPT mode and ChatGPT sign-in coexists with Go. Only Go models that speak the Responses API work (`deepseek-v4.1-flash`, `gpt-6-luna`, `gpt-5.6-luna`, `grok-4.7/4.6`); GLM/Kimi/MiMo/LongCat are chat-completions-only and need a proxy. Desktop Codex is now the `chatgpt` cask - do not use the deprecated `codex-app` cask.
|
- Codex runs on the OpenCode Go subscription. The ChatGPT app owns and rewrites the live `~/.codex/config.toml`, so it is NOT symlinked; `home.activation.codexOpenCodeGo` merges the repo fragment `home/.codex/config.toml` into it on every rebuild, and the app's own sections (`[desktop]`, `[plugins]`, `[mcp_servers]`, ...) survive. Auth is command-backed via `~/.local/bin/opencode-go-token` (prints the key from the opencode store), so `~/.codex/auth.json` stays in ChatGPT mode and ChatGPT sign-in coexists with Go. Only Go models that speak the Responses API work (`deepseek-v4.1-flash`, `gpt-6-luna`, `gpt-5.6-luna`, `grok-4.7/4.6`); GLM/Kimi/MiMo/LongCat are chat-completions-only and need a proxy. Desktop Codex is now the `chatgpt` cask - do not use the deprecated `codex-app` cask.
|
||||||
- firstmate lives at `~/Documents/firstmate` as a mutable git clone (not in the Nix store). `home.activation.firstmate` clones it if missing and seeds `config/backend=herdr` + `config/crew-harness=opencode` only when those files are absent. Crew routing is `home/.config/firstmate/crew-dispatch.json` (symlinked in): per the captain's order 2026-10-21, coding crewmates and scouts use `opencode` + `opencode-go/deepseek-v4.1-flash` through the OpenCode CLI. Design, architecture, and design-review tasks are the exception: the file's first rule sends them to Pi with `openai-codex/gpt-6.1-sol` at `xhigh`, and implementation tasks re-resolve their profile instead of keeping that model. The free `deepseek-v4.1-flash-free` order of 2026-10-20 resumes when that lane resets. The validation pipeline stays on Pi with `opencode-go/deepseek-v4.1-flash` steps and the `opencode-go/glm-5.3-flash` reviewer. Avoid the `muse-spark-*-contributor` models, which train on prompts, and the `exo-free`, `mimo-*-free`, and `nemotron-*-free` models, whose data may be used to improve the model. `cat-jam-free` retains for 30 days. Crews inherit the primary's OpenCode login through the spawn-owned symlink (the isolated worker data root links the primary `<XDG_DATA_HOME>/opencode/auth.json`; no `~/.pi/agent/auth.json` reliance). Launch with shell alias `fm` (`cd` + the `oc2` wrapper, so the primary runs OpenCode 2 on the OpenCode Go subscription and loads firstmate's `.opencode/plugins` by working directory), while crews run on the opencode harness unless a dispatch rule selects another harness. `oc2` remains the isolated-config OpenCode launcher, and `fm-pi` stays only as the explicit Pi fallback now that the OpenCode 2 launcher is the confirmed default. Self-update via `/updatefirstmate`, not rebuild.
|
- firstmate lives at `~/Documents/firstmate` as a mutable git clone (not in the Nix store). `home.activation.firstmate` clones it if missing and seeds `config/backend=herdr` + `config/crew-harness=opencode` only when those files are absent. Crew routing is `home/.config/firstmate/crew-dispatch.json` (symlinked in): per the captain's order 2026-10-21, coding crewmates and scouts use `opencode` + `opencode-go/deepseek-v4.1-flash` through the OpenCode CLI. Design, architecture, and design-review tasks are the exception: the file's first rule sends them to Pi with `openai-codex/gpt-6.1-sol` at `xhigh`, and implementation tasks re-resolve their profile instead of keeping that model. The free `deepseek-v4.1-flash-free` order of 2026-10-20 resumes when that lane resets. The validation pipeline stays on Pi with `opencode-go/deepseek-v4.1-flash` steps and the `opencode-go/glm-5.3-flash` reviewer. Avoid the `muse-spark-*-contributor` models, which train on prompts, and the `exo-free`, `mimo-*-free`, and `nemotron-*-free` models, whose data may be used to improve the model. `cat-jam-free` retains for 30 days. Crews inherit the primary's OpenCode login through the spawn-owned symlink (the isolated worker data root links the primary `<XDG_DATA_HOME>/opencode/auth.json`; no `~/.pi/agent/auth.json` reliance). Launch with shell alias `fm` (`cd` + the `oc2` wrapper, so the primary runs OpenCode 2 on the OpenCode Go subscription and loads firstmate's `.opencode/plugins` by working directory), while crews run on the opencode harness unless a dispatch rule selects another harness. `oc2` remains the isolated-config OpenCode launcher, and `fm-pi` stays only as the explicit Pi fallback now that the OpenCode 2 launcher is the confirmed default. Self-update via `/updatefirstmate`, not rebuild.
|
||||||
- OpenCode is one install: the stable Homebrew `opencode` formula, linked so `/opt/homebrew/bin/opencode` is that build. It is both the firstmate crew harness and the `oc2` binary. `oc2` only isolates the config: `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite `~/.config/opencode`, and `OPENCODE2_BIN` overrides the binary. firstmate harness detection matches `*opencode*`, so it still classifies as OpenCode.
|
- OpenCode is one install: the stable Homebrew `opencode` formula, linked so `/opt/homebrew/bin/opencode` is that build. It is both the firstmate crew harness and the `oc2` binary. `oc2` only isolates the config: `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite `~/.config/opencode`, and `OPENCODE2_BIN` overrides the binary. firstmate harness detection matches `*opencode*`, so it still classifies as OpenCode.
|
||||||
- Shell aliases: `cc` (Claude skip-permissions), `co` (Codex full-auto), `gb` (Grok --yolo), `fm` (firstmate via OpenCode 2), `fm-pi` (firstmate via Pi fallback), `oc2` (OpenCode with isolated config). They are intentional high-agency shortcuts.
|
- Shell aliases: `cc` (Claude skip-permissions), `co` (Codex full-auto), `gb` (Grok --yolo), `fm` / `fm-oc2` (firstmate via OpenCode 2), `fm-pi` (firstmate via Pi fallback), `oc2` (OpenCode with isolated config). They are intentional high-agency shortcuts.
|
||||||
- OpenSuperWhisper is installed by the `opensuperwhisper` cask, and `home.activation.openSuperWhisper` downloads its Whisper model (`ggml-large-v3-turbo.bin` under the app's Application Support directory, never the Nix store) and seeds the model selection only when it is missing or dangling. All other app settings (trigger, language, paste behavior) belong to the app and must not be rewritten by a rebuild, so `modifierOnlyHotkey = rightOption` on this machine stays the effective trigger. Microphone/Accessibility/Input Monitoring grants stay manual because macOS TCC cannot be declarative; do not kill a running app to apply defaults. The model is local-only.
|
- OpenSuperWhisper is installed by the `opensuperwhisper` cask, and `home.activation.openSuperWhisper` downloads its Whisper model (`ggml-large-v3-turbo.bin` under the app's Application Support directory, never the Nix store) and seeds the model selection only when it is missing or dangling. All other app settings (trigger, language, paste behavior) belong to the app and must not be rewritten by a rebuild, so `modifierOnlyHotkey = rightOption` on this machine stays the effective trigger. Microphone/Accessibility/Input Monitoring grants stay manual because macOS TCC cannot be declarative; do not kill a running app to apply defaults. The model is local-only.
|
||||||
|
|
||||||
## Maintaining this file
|
## Maintaining this 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
|
||||||
Generated
+6
-6
@@ -24,11 +24,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1792818383,
|
"lastModified": 1795325060,
|
||||||
"narHash": "sha256-199i7ubVSXTMl+0AAlL7cVCXSjcI+jWByMcimYjeMX0=",
|
"narHash": "sha256-XYoMPsqRFZ6jOaYI1KAAu8fzqif4tkCX8mhEKrViDXQ=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "24f2190587513b9c2f73db112a17844ae912d965",
|
"rev": "6480d7d8533b88c78cc6dcda395ab89cd546e450",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -79,11 +79,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1793976852,
|
"lastModified": 1795387764,
|
||||||
"narHash": "sha256-bWDN3JZcE9ovYoaD0/6WYbMtXYpUu0vd5onpK0pc/SE=",
|
"narHash": "sha256-c2VS34FJxgjfNbfKgh837LzPzx9S2FXTez+Th1iKDZ8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "57f1c8965649ce5bcac5118a0d2e41f1fbdc56e5",
|
"rev": "f0b41a99f28c34ffeaff61d4b419afff0516a923",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -54,6 +61,14 @@ in
|
|||||||
ngrok # reverse TCP tunnel so the phone can SSH in over cellular (unfree)
|
ngrok # reverse TCP tunnel so the phone can SSH in over cellular (unfree)
|
||||||
beets # music tagger / library organizer + navidrome sync plugin
|
beets # music tagger / library organizer + navidrome sync plugin
|
||||||
] ++ [ ytTranscribe ];
|
] ++ [ 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;
|
fonts.fontconfig.enable = true;
|
||||||
home.sessionVariables.EDITOR = "nvim";
|
home.sessionVariables.EDITOR = "nvim";
|
||||||
|
|
||||||
@@ -63,6 +78,10 @@ in
|
|||||||
syntaxHighlighting.enable = true; # commands turn green when valid
|
syntaxHighlighting.enable = true; # commands turn green when valid
|
||||||
initContent = ''
|
initContent = ''
|
||||||
bindkey '^f' autosuggest-accept
|
bindkey '^f' autosuggest-accept
|
||||||
|
# Brave-only bird wrapper wins over Homebrew's npm bird shim. zshrc runs
|
||||||
|
# after .zprofile, whose brew shellenv puts /opt/homebrew/bin first.
|
||||||
|
typeset -U path
|
||||||
|
path=("$HOME/.pi/agent/bin" $path)
|
||||||
# Keep the OpenCode Go CLI, Pi, no-mistakes, and Hermes key aligned with
|
# Keep the OpenCode Go CLI, Pi, no-mistakes, and Hermes key aligned with
|
||||||
# the desktop app login after an account switch.
|
# the desktop app login after an account switch.
|
||||||
if [ -x "$HOME/.local/bin/opencode-go-key-sync" ]; then
|
if [ -x "$HOME/.local/bin/opencode-go-key-sync" ]; then
|
||||||
@@ -83,8 +102,10 @@ in
|
|||||||
# firstmate primary session in OpenCode 2 on the OpenCode Go subscription,
|
# firstmate primary session in OpenCode 2 on the OpenCode Go subscription,
|
||||||
# launched through the isolated-config oc2 wrapper; crewmates = OpenCode by
|
# launched through the isolated-config oc2 wrapper; crewmates = OpenCode by
|
||||||
# default. Permanent since 2026-11-15: fm-pi stays only as the explicit Pi
|
# default. Permanent since 2026-11-15: fm-pi stays only as the explicit Pi
|
||||||
# fallback, never as the default launcher.
|
# fallback, never as the default launcher. fm-oc2 is the explicit
|
||||||
|
# OpenCode 2 name and stays byte-identical to fm.
|
||||||
fm = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2";
|
fm = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2";
|
||||||
|
fm-oc2 = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2";
|
||||||
fm-pi = "cd ${firstmateHome} && exec pi";
|
fm-pi = "cd ${firstmateHome} && exec pi";
|
||||||
oc2 = "${home}/.local/bin/oc2";
|
oc2 = "${home}/.local/bin/oc2";
|
||||||
# Sync ~/Music into the beets library on Unraid (requires NAS mounted).
|
# Sync ~/Music into the beets library on Unraid (requires NAS mounted).
|
||||||
@@ -283,6 +304,22 @@ in
|
|||||||
force = true;
|
force = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Brave-only bird reader. The config points bird's Chromium source at Brave;
|
||||||
|
# the wrapper decrypts Brave cookies with the Brave Safe Storage key and
|
||||||
|
# hands them to bird as env vars. The session PATH puts ~/.pi/agent/bin
|
||||||
|
# before Homebrew, so `bird` resolves to this wrapper and not the npm shim.
|
||||||
|
# force = true on the config is needed once: a pre-existing unmanaged
|
||||||
|
# ~/.config/bird/config.json5 would otherwise make home-manager refuse the
|
||||||
|
# switch. The wrapper path is new, so no force.
|
||||||
|
home.sessionPath = [ "${home}/.pi/agent/bin" ];
|
||||||
|
home.file.".config/bird/config.json5" = {
|
||||||
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.config/bird/config.json5";
|
||||||
|
force = true;
|
||||||
|
};
|
||||||
|
home.file.".pi/agent/bin/bird" = {
|
||||||
|
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.pi/agent/bin/bird";
|
||||||
|
};
|
||||||
|
|
||||||
# firstmate is a mutable agent distro (self-update, state/, projects/). Clone once;
|
# firstmate is a mutable agent distro (self-update, state/, projects/). Clone once;
|
||||||
# never put it in the Nix store. Seed OpenCode+herdr defaults only when absent.
|
# never put it in the Nix store. Seed OpenCode+herdr defaults only when absent.
|
||||||
# Do NOT npm install -g here: activation PATH often resolves Nix's npm, which
|
# Do NOT npm install -g here: activation PATH often resolves Nix's npm, which
|
||||||
@@ -317,7 +354,8 @@ in
|
|||||||
# Firstmate companion CLIs (*-axi). None is a Homebrew or Nix formula, so
|
# Firstmate companion CLIs (*-axi). None is a Homebrew or Nix formula, so
|
||||||
# install them through Homebrew's npm. tasks-axi is version-gated by firstmate
|
# install them through Homebrew's npm. tasks-axi is version-gated by firstmate
|
||||||
# (>= 0.2.6 is required before a spawn/teardown automatic backlog transition
|
# (>= 0.2.6 is required before a spawn/teardown automatic backlog transition
|
||||||
# will run), so pin it and reinstall on drift; the rest install when absent.
|
# will run), so fill a missing or older copy; rebuild.sh moves it on to the
|
||||||
|
# latest release. The rest install when absent on a fresh machine.
|
||||||
home.activation.axiTools = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
home.activation.axiTools = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node`
|
# Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node`
|
||||||
@@ -329,10 +367,13 @@ in
|
|||||||
echo "axiTools: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2
|
echo "axiTools: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Pin tasks-axi; reinstall only when the installed version differs.
|
# tasks-axi: install the firstmate floor only when the copy is missing or
|
||||||
|
# older. A newer copy is left alone so rebuild.sh's latest-release update
|
||||||
|
# survives the next switch.
|
||||||
want_tasks_axi="0.2.6"
|
want_tasks_axi="0.2.6"
|
||||||
have_tasks_axi="$(tasks-axi --version 2>/dev/null | head -1 | tr -d '[:space:]')"
|
have_tasks_axi="$(tasks-axi --version 2>/dev/null | head -1 | tr -d '[:space:]' || true)"
|
||||||
if [ "$have_tasks_axi" != "$want_tasks_axi" ]; then
|
if [ -z "$have_tasks_axi" ] \
|
||||||
|
|| [ "$(printf '%s\n%s\n' "$want_tasks_axi" "$have_tasks_axi" | sort -V | head -1)" != "$want_tasks_axi" ]; then
|
||||||
"$npm" install -g "tasks-axi@$want_tasks_axi"
|
"$npm" install -g "tasks-axi@$want_tasks_axi"
|
||||||
fi
|
fi
|
||||||
# Companion CLIs without a firstmate-enforced version floor: install once.
|
# Companion CLIs without a firstmate-enforced version floor: install once.
|
||||||
@@ -569,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.
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
// Bird calls its Chromium cookie reader "chrome". This profile path points
|
||||||
|
// that reader at Brave only. Do not add Safari or Firefox sources.
|
||||||
|
// The ~/.pi/agent/bin/bird wrapper supplies the cookies itself from Brave
|
||||||
|
// Safe Storage, so bird never asks Keychain for Chrome Safe Storage.
|
||||||
|
cookieSource: "chrome",
|
||||||
|
chromeProfileDir: "/Users/laptran/Library/Application Support/BraveSoftware/Brave-Browser/Default/Cookies",
|
||||||
|
cookieTimeoutMs: 30000
|
||||||
|
}
|
||||||
@@ -5,15 +5,15 @@ description: Use when the user asks to read, fetch, or show the content of an X
|
|||||||
|
|
||||||
# Read X/Twitter Tweet Content with bird
|
# Read X/Twitter Tweet Content with bird
|
||||||
|
|
||||||
When the user asks to read, fetch, view, or summarize a tweet (or thread), use the locally installed `bird` CLI instead of `webfetch` — it authenticates via the active browser session and returns full tweet content + metadata.
|
When the user asks to read, fetch, view, or summarize a tweet (or thread), use the local `bird` CLI instead of `webfetch`. It authenticates through the Brave cookie session and returns full tweet content and metadata.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Use `/opt/homebrew/bin/bird` (absolute path since PATH can be sparse in non-interactive shells):
|
Use `$HOME/.pi/agent/bin/bird`, the Brave-only wrapper. It reads the X cookies from Brave and execs the installed bird. Use an absolute path because PATH can be sparse in non-interactive shells. Do not call `/opt/homebrew/bin/bird` directly, since that skips the wrapper and asks Keychain for Chrome Safe Storage.
|
||||||
|
|
||||||
- Single tweet: `bird read <tweet-url-or-id> --json`
|
- Single tweet: `$HOME/.pi/agent/bin/bird read <tweet-url-or-id> --json`
|
||||||
- Full thread/conversation: `bird thread <tweet-url-or-id> --json`
|
- Full thread/conversation: `$HOME/.pi/agent/bin/bird thread <tweet-url-or-id> --json`
|
||||||
- Replies to a tweet: `bird replies <tweet-url-or-id> --json`
|
- Replies to a tweet: `$HOME/.pi/agent/bin/bird replies <tweet-url-or-id> --json`
|
||||||
|
|
||||||
Prefer `--json` for parseable output (author, text, media, created_at, metrics). Drop `--json` only if the user wants pretty-printed terminal output.
|
Prefer `--json` for parseable output (author, text, media, created_at, metrics). Drop `--json` only if the user wants pretty-printed terminal output.
|
||||||
|
|
||||||
@@ -25,11 +25,12 @@ Prefer `--json` for parseable output (author, text, media, created_at, metrics).
|
|||||||
|
|
||||||
## When NOT to use
|
## When NOT to use
|
||||||
|
|
||||||
- User asks to post, reply, like, bookmark, follow, or search tweets — use other `bird` subcommands directly (see `bird --help`)
|
- User asks to post, reply, like, bookmark, follow, or search tweets — use other subcommands through the same wrapper (see `$HOME/.pi/agent/bin/bird --help`)
|
||||||
- User asks about article content linked FROM a tweet — `bird` only returns tweet text/metadata, not outbound article bodies; fall back to `webfetch` on the linked URL
|
- User asks about article content linked FROM a tweet — `bird` only returns tweet text/metadata, not outbound article bodies; fall back to `webfetch` on the linked URL
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- `bird` reads `auth_token` and `ct0` cookies from Safari/Chrome/Firefox; no paid dev account needed
|
- The wrapper reads `auth_token` and `ct0` from Brave only and passes them to bird as env vars. No paid dev account needed.
|
||||||
- If a fetch fails with auth errors, tell the user to sign in to x.com in their browser and retry
|
- If the wrapper cannot read Brave Safe Storage, approve the Keychain dialog and retry. Do not switch browsers or call the Homebrew binary directly.
|
||||||
|
- If a fetch fails with auth errors, tell the user to sign in to x.com in Brave and retry
|
||||||
- Quote tweets and retweets include the referenced tweet in the JSON payload
|
- Quote tweets and retweets include the referenced tweet in the JSON payload
|
||||||
Executable
+161
@@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Brave-only cookie bridge for the bird X reader.
|
||||||
|
|
||||||
|
Bird 0.8.0 reads browser cookies through sweet-cookie 0.1.0. On macOS that
|
||||||
|
library asks Keychain for "Chrome Safe Storage", while Brave keeps its key
|
||||||
|
under "Brave Safe Storage". Bird therefore fails before it can read Brave.
|
||||||
|
|
||||||
|
This wrapper reads auth_token and ct0 from Brave's cookie database, decrypts
|
||||||
|
them with the Brave Safe Storage key, and passes them to the real bird as
|
||||||
|
AUTH_TOKEN and CT0. Bird then takes its env-cookie path and never calls its
|
||||||
|
Safari, Chrome, or Firefox providers.
|
||||||
|
|
||||||
|
No cookie value, keychain password, or X token is printed. This script never
|
||||||
|
opens ~/.config/bird/credentials and never writes a Keychain item.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ctypes
|
||||||
|
import hashlib
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sqlite3
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
REAL_BIRD = os.environ.get("BIRD_BRAVE_REAL_BIRD", "/opt/homebrew/bin/bird")
|
||||||
|
SERVICE = "Brave Safe Storage"
|
||||||
|
ACCOUNT = "Brave"
|
||||||
|
COOKIE_DB = Path(os.path.expanduser(
|
||||||
|
"~/Library/Application Support/BraveSoftware/Brave-Browser/Default/Cookies"
|
||||||
|
))
|
||||||
|
COOKIE_NAMES = ("auth_token", "ct0")
|
||||||
|
IV = b" " * 16
|
||||||
|
HOST_PREFIX_BYTES = 32
|
||||||
|
|
||||||
|
|
||||||
|
def fail(message):
|
||||||
|
print("bird-brave: " + message, file=sys.stderr)
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def safe_storage_password():
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
["security", "find-generic-password", "-s", SERVICE,
|
||||||
|
"-a", ACCOUNT, "-w"],
|
||||||
|
capture_output=True,
|
||||||
|
timeout=30,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
except (OSError, subprocess.TimeoutExpired):
|
||||||
|
fail("cannot read " + SERVICE + " from Keychain")
|
||||||
|
if result.returncode != 0 or not result.stdout.strip():
|
||||||
|
fail("cannot read " + SERVICE + " from Keychain")
|
||||||
|
return result.stdout.rstrip(b"\r\n")
|
||||||
|
|
||||||
|
|
||||||
|
def aes_key(password):
|
||||||
|
return hashlib.pbkdf2_hmac("sha1", password, b"saltysalt", 1003, 16)
|
||||||
|
|
||||||
|
|
||||||
|
def crypt(operation, key, data):
|
||||||
|
lib = ctypes.CDLL("/usr/lib/libSystem.B.dylib")
|
||||||
|
lib.CCCrypt.argtypes = [
|
||||||
|
ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32,
|
||||||
|
ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p,
|
||||||
|
ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p, ctypes.c_size_t,
|
||||||
|
ctypes.POINTER(ctypes.c_size_t),
|
||||||
|
]
|
||||||
|
lib.CCCrypt.restype = ctypes.c_int32
|
||||||
|
output = ctypes.create_string_buffer(len(data) + 32)
|
||||||
|
moved = ctypes.c_size_t(0)
|
||||||
|
status = lib.CCCrypt(
|
||||||
|
1, 0, 1, key, len(key), IV, data, len(data),
|
||||||
|
output, len(output), ctypes.byref(moved),
|
||||||
|
)
|
||||||
|
if status != 0:
|
||||||
|
return None
|
||||||
|
return output.raw[:moved.value]
|
||||||
|
|
||||||
|
|
||||||
|
def decrypt_value(blob, key, strip_prefix):
|
||||||
|
if not blob or blob[:3] not in (b"v10", b"v11"):
|
||||||
|
return None
|
||||||
|
plain = crypt(1, key, blob[3:])
|
||||||
|
if plain is None:
|
||||||
|
return None
|
||||||
|
if strip_prefix and len(plain) > HOST_PREFIX_BYTES:
|
||||||
|
plain = plain[HOST_PREFIX_BYTES:]
|
||||||
|
try:
|
||||||
|
text = plain.decode("utf-8")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return None
|
||||||
|
return text or None
|
||||||
|
|
||||||
|
|
||||||
|
def brave_cookie_rows():
|
||||||
|
if not COOKIE_DB.is_file():
|
||||||
|
fail("Brave cookie database missing at " + str(COOKIE_DB))
|
||||||
|
with tempfile.TemporaryDirectory(prefix="bird-brave-") as temp:
|
||||||
|
copy = Path(temp) / "Cookies"
|
||||||
|
try:
|
||||||
|
shutil.copy2(COOKIE_DB, copy)
|
||||||
|
for suffix in ("-wal", "-shm"):
|
||||||
|
sidecar = Path(str(COOKIE_DB) + suffix)
|
||||||
|
if sidecar.is_file():
|
||||||
|
shutil.copy2(sidecar, Path(str(copy) + suffix))
|
||||||
|
conn = sqlite3.connect(str(copy))
|
||||||
|
except (OSError, sqlite3.Error):
|
||||||
|
fail("cannot open Brave cookie database")
|
||||||
|
try:
|
||||||
|
version_row = conn.execute(
|
||||||
|
"SELECT value FROM meta WHERE key = 'version'"
|
||||||
|
).fetchone()
|
||||||
|
strip_prefix = bool(
|
||||||
|
version_row and version_row[0] and int(version_row[0]) >= 24
|
||||||
|
)
|
||||||
|
rows = conn.execute(
|
||||||
|
"SELECT name, host_key, value, encrypted_value FROM cookies "
|
||||||
|
"WHERE name IN ('auth_token', 'ct0')"
|
||||||
|
).fetchall()
|
||||||
|
except (sqlite3.Error, ValueError, TypeError):
|
||||||
|
fail("cannot read Brave cookies")
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
return rows, strip_prefix
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if not os.path.exists(REAL_BIRD):
|
||||||
|
fail("real bird not found at " + REAL_BIRD)
|
||||||
|
|
||||||
|
# Help and version need no cookies. Pass them straight through.
|
||||||
|
if any(arg in ("--help", "-h", "--version", "-V") for arg in sys.argv[1:]):
|
||||||
|
os.execv(REAL_BIRD, [REAL_BIRD] + sys.argv[1:])
|
||||||
|
|
||||||
|
rows, strip_prefix = brave_cookie_rows()
|
||||||
|
key = aes_key(safe_storage_password())
|
||||||
|
found = {}
|
||||||
|
for name, host_key, value, encrypted in rows:
|
||||||
|
if not (host_key.endswith("x.com") or host_key.endswith("twitter.com")):
|
||||||
|
continue
|
||||||
|
plain = value or decrypt_value(encrypted, key, strip_prefix)
|
||||||
|
if not plain:
|
||||||
|
continue
|
||||||
|
rank = 0 if host_key.endswith("x.com") else 1
|
||||||
|
if name not in found or rank < found[name][0]:
|
||||||
|
found[name] = (rank, plain)
|
||||||
|
|
||||||
|
missing = [name for name in COOKIE_NAMES if name not in found]
|
||||||
|
if missing:
|
||||||
|
fail("Brave has no x.com cookie for " + " or ".join(missing))
|
||||||
|
|
||||||
|
os.environ["AUTH_TOKEN"] = found["auth_token"][1]
|
||||||
|
os.environ["CT0"] = found["ct0"][1]
|
||||||
|
os.execv(REAL_BIRD, [REAL_BIRD] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -13,13 +13,15 @@ The firstmate crew dispatch + Gitea PR helper are wired by `darwin-rebuild`, but
|
|||||||
cd ~/Documents/investor-flow
|
cd ~/Documents/investor-flow
|
||||||
git remote set-url origin http://unraid.local:3003/transnet/investor-flow
|
git remote set-url origin http://unraid.local:3003/transnet/investor-flow
|
||||||
|
|
||||||
Verify: `fm` launches OpenCode 2 as the first mate and `fm-pi` is the explicit Pi fallback; `oc2 --version` prints the Homebrew opencode version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works.
|
Verify: `fm` and `fm-oc2` launch OpenCode 2 as the first mate and `fm-pi` is the explicit Pi fallback; `oc2 --version` prints the Homebrew opencode version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works.
|
||||||
|
|
||||||
## firstmate launcher and crew model routing
|
## firstmate launcher and crew model routing
|
||||||
|
|
||||||
`fm` is the permanent firstmate launcher. It changes to `~/Documents/firstmate` and executes `~/.local/bin/oc2`, which runs the Homebrew OpenCode build with the isolated `~/.config/opencode2/opencode.json` config. `fm-pi` remains only as an explicit Pi fallback. Never make Pi the default launcher.
|
`fm` is the permanent firstmate launcher. `fm-oc2` is the same launcher under its explicit OpenCode 2 name, so both aliases expand to the same command. They change to `~/Documents/firstmate` and execute `~/.local/bin/oc2`, which runs the Homebrew OpenCode build with the isolated `~/.config/opencode2/opencode.json` config. `fm-pi` starts Pi instead and remains only an explicit fallback. Never make Pi the default launcher.
|
||||||
|
|
||||||
`home.nix` owns both aliases, so a rebuild regenerates them. The installed `~/.zshrc` changes only at the next activation.
|
The three aliases share one firstmate home. They read the same task records, inbox, and state. Each tool keeps its own chat history, so a conversation in OpenCode 2 does not appear in Pi, and the reverse. Quit the running primary before you start the other one. A single firstmate home serves one primary at a time.
|
||||||
|
|
||||||
|
`home.nix` owns all three aliases, so a rebuild regenerates them. The installed `~/.zshrc` changes only at the next activation.
|
||||||
|
|
||||||
Worker routing lives in `home/.config/firstmate/crew-dispatch.json`, which is symlinked to `~/Documents/firstmate/config/crew-dispatch.json`:
|
Worker routing lives in `home/.config/firstmate/crew-dispatch.json`, which is symlinked to `~/Documents/firstmate/config/crew-dispatch.json`:
|
||||||
|
|
||||||
@@ -52,10 +54,12 @@ The captain confirmed the split on 2026-11-15. Leave it unchanged:
|
|||||||
./tests/fm-launcher.sh --live # installed zshrc; fails while it still launches Pi
|
./tests/fm-launcher.sh --live # installed zshrc; fails while it still launches Pi
|
||||||
./tests/fm-launcher.sh # generated zshrc; must pass
|
./tests/fm-launcher.sh # generated zshrc; must pass
|
||||||
./tests/crew-dispatch.sh # routing via firstmate, model IDs via opencode models
|
./tests/crew-dispatch.sh # routing via firstmate, model IDs via opencode models
|
||||||
|
./tests/rebuild-update-steps.sh # isolated updater execution and activation checks
|
||||||
|
./tests/bird-brave-e2e.sh # Brave-only bird cookies, throwaway HOME fixture
|
||||||
./tests/run.sh # all checks
|
./tests/run.sh # all checks
|
||||||
```
|
```
|
||||||
|
|
||||||
The launcher check sources the real generated zshrc in an interactive zsh. A `pi` spy on PATH and an `OPENCODE2_BIN` spy capture the launch, so no firstmate session starts.
|
The launcher check sources the real generated zshrc in an interactive zsh. A `pi` spy on PATH and an `OPENCODE2_BIN` spy capture the launch of `fm`, `fm-oc2`, and `fm-pi`, record the working directory, and exit at once, so no firstmate session starts.
|
||||||
|
|
||||||
### Install after merge
|
### Install after merge
|
||||||
|
|
||||||
@@ -65,7 +69,7 @@ The Nix sources in this repository are the durable record. The live files are ge
|
|||||||
2. Confirm `readlink ~/.dotfiles` names the checkout that holds the merged commit.
|
2. Confirm `readlink ~/.dotfiles` names the checkout that holds the merged commit.
|
||||||
3. Run `./rebuild.sh` from that checkout.
|
3. Run `./rebuild.sh` from that checkout.
|
||||||
4. Run `./tests/fm-launcher.sh --live` and `./tests/crew-dispatch.sh`.
|
4. Run `./tests/fm-launcher.sh --live` and `./tests/crew-dispatch.sh`.
|
||||||
5. Open a fresh shell and run `alias fm`. It must show `exec /Users/laptran/.local/bin/oc2`.
|
5. Open a fresh shell and run `alias fm fm-oc2 fm-pi`. `fm` and `fm-oc2` must show `exec /Users/laptran/.local/bin/oc2`, and `fm-pi` must show `exec pi`.
|
||||||
|
|
||||||
### Checkout topology and safe installation
|
### Checkout topology and safe installation
|
||||||
|
|
||||||
@@ -73,6 +77,56 @@ The Nix sources in this repository are the durable record. The live files are ge
|
|||||||
|
|
||||||
This follows the NIST SP 800-128 Rev. 1 (2019) Section 3.3 "Controlling Configuration Change" (CM-3) practice: route every change through review and approval, test it, record it in version control, and restrict who can change the operational configuration. The 2011 edition is withdrawn and superseded by Revision 1.
|
This follows the NIST SP 800-128 Rev. 1 (2019) Section 3.3 "Controlling Configuration Change" (CM-3) practice: route every change through review and approval, test it, record it in version control, and restrict who can change the operational configuration. The 2011 edition is withdrawn and superseded by Revision 1.
|
||||||
|
|
||||||
|
## Brave-only bird cookie reader
|
||||||
|
|
||||||
|
`rebuild.sh` installs `bird` as a global npm package. Bird 0.8.0 asks Keychain for "Chrome Safe Storage" when it reads browser cookies, but Brave keeps its key under "Brave Safe Storage". The reader failed before it could use Brave cookies.
|
||||||
|
|
||||||
|
Two tracked files make the reader Brave-only:
|
||||||
|
|
||||||
|
- `home/.config/bird/config.json5` installs as `~/.config/bird/config.json5`. It sets `cookieSource` to `chrome`, which is Bird's name for its Chromium reader, and points `chromeProfileDir` at the Brave cookie database. No Safari or Firefox source is configured.
|
||||||
|
- `home/.pi/agent/bin/bird` installs as `~/.pi/agent/bin/bird`. PATH puts that directory before `/opt/homebrew/bin`, so `bird` runs the wrapper first.
|
||||||
|
|
||||||
|
The wrapper reads `auth_token` and `ct0` from the Brave cookie database, decrypts them with the Brave Safe Storage key, and passes them to the real bird as `AUTH_TOKEN` and `CT0`. Bird then uses its env-cookie path and never calls its Safari, Chrome, or Firefox providers. The wrapper never opens `~/.config/bird/credentials` and never writes a Keychain item. No cookie value or token appears in its output.
|
||||||
|
|
||||||
|
The first use can show a macOS dialog asking to allow access to "Brave Safe Storage". Approve that read. The wrapper never creates or copies a Chrome Safe Storage item.
|
||||||
|
|
||||||
|
If Bird changes its env-cookie names or its cookie store, stop and update the wrapper in this repo. Do not work around the mismatch by adding a Chrome Safe Storage item or copying the Brave key into one. Run `./tests/bird-brave-e2e.sh` after any change.
|
||||||
|
|
||||||
|
## What `rebuild.sh` updates
|
||||||
|
|
||||||
|
`./rebuild.sh` updates the components below. The npm updater skips packages already at the registry version. Other tools use their own update commands on each run. Optional updater failures print warnings and allow the rebuild to continue. A failed switch stops the script before the post-switch updates.
|
||||||
|
|
||||||
|
Before the switch:
|
||||||
|
|
||||||
|
- Installed npm globals listed in `rebuild.sh`'s `npm_globals` array, through `/opt/homebrew/bin/npm`, never Nix's npm. The script skips absent packages and compares each installed package with the registry before an update. `home.activation.axiTools` enforces the `tasks-axi` minimum without downgrades, so newer releases survive the switch.
|
||||||
|
- 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 `~/.no-mistakes/bin/no-mistakes`, or the command on `PATH` if that binary is absent.
|
||||||
|
- `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.
|
||||||
|
- `brew trust can1357/tap` and `brew trust incoai/tap`, so `brew bundle` can install formulae from those third-party taps. Trust can revert between runs, so every rebuild restores it. The `whisper-cpp was renamed to whisper.cpp` notice is a warning. It does not abort the rebuild.
|
||||||
|
|
||||||
|
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 selected nixpkgs packages. Later rebuilds update those links automatically, rather than downloading separate releases.
|
||||||
|
|
||||||
|
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.
|
||||||
|
- `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:
|
||||||
|
|||||||
+140
-12
@@ -1,19 +1,84 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Rebuild nix-darwin + home-manager. Rotates stale home-manager *.backup files
|
# Rebuild nix-darwin + home-manager from this checkout.
|
||||||
# so a second switch never fails with "would be clobbered".
|
#
|
||||||
# Also updates flake inputs, upgrades grok-build, removes retired npm OpenCode
|
# Before the switch, update the non-declarative tools listed below:
|
||||||
# packages, updates no-mistakes, and updates pi extensions.
|
# npm globals (through Homebrew's node, never Nix's npm), no-mistakes,
|
||||||
|
# Hermes Agent, and the flake inputs. After the switch,
|
||||||
|
# update the installed agent skills and Pi extensions against the upgraded
|
||||||
|
# binaries.
|
||||||
|
#
|
||||||
|
# Rotates stale home-manager *.backup files before the switch so a second switch
|
||||||
|
# never fails with "would be clobbered".
|
||||||
|
# Optional updater failures warn and allow the rebuild to continue.
|
||||||
|
# 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
|
||||||
|
|
||||||
# Upgrade grok-build to latest (Homebrew cask).
|
# The npm globals listed below have no declarative updater.
|
||||||
# Skip if Homebrew API is unreachable (DNS/network issues).
|
# Use /opt/homebrew/bin/npm explicitly: the activation PATH can resolve
|
||||||
echo "==> Upgrading grok-build..."
|
# Nix's npm, which cannot write the Homebrew prefix, and these packages belong to
|
||||||
if brew upgrade grok-build 2>&1; then
|
# Homebrew's node. Each package is compared with the registry first, so a current
|
||||||
echo "==> grok-build upgrade complete"
|
# copy is left alone and a failed lookup or install only warns.
|
||||||
|
echo "==> Updating npm global tools..."
|
||||||
|
if [ ! -x "$NPM" ]; then
|
||||||
|
echo "==> WARNING: $NPM not found (declare node in homebrew.brews). Skipping npm global updates."
|
||||||
else
|
else
|
||||||
echo "==> WARNING: grok-build upgrade failed (network issue). Skipping."
|
npm_node=/opt/homebrew/bin/node
|
||||||
|
update_npm_global() {
|
||||||
|
pkg="$1"
|
||||||
|
installed="$("$NPM" ls -g --depth=0 --json 2>/dev/null \
|
||||||
|
| "$npm_node" -e '
|
||||||
|
let raw = "";
|
||||||
|
process.stdin.on("data", (chunk) => { raw += chunk; });
|
||||||
|
process.stdin.on("end", () => {
|
||||||
|
try {
|
||||||
|
const tree = JSON.parse(raw);
|
||||||
|
const entry = (tree.dependencies || {})[process.argv[1]] || {};
|
||||||
|
process.stdout.write(entry.version || "");
|
||||||
|
} catch {}
|
||||||
|
});
|
||||||
|
' "$pkg" || true)"
|
||||||
|
if [ -z "$installed" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
latest="$("$NPM" view "$pkg" version --fetch-timeout=15000 --fetch-retries=1 2>/dev/null \
|
||||||
|
| tr -d '[:space:]' || true)"
|
||||||
|
if [ -z "$latest" ]; then
|
||||||
|
echo "==> WARNING: cannot read the latest $pkg version from the registry. Keeping the installed copy."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ "$installed" = "$latest" ]; then
|
||||||
|
echo "==> $pkg already at $latest"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo "==> $pkg $installed -> $latest"
|
||||||
|
if "$NPM" install -g "$pkg@$latest" >/dev/null 2>&1; then
|
||||||
|
echo "==> $pkg installed at $latest"
|
||||||
|
else
|
||||||
|
echo "==> WARNING: $pkg install of $latest failed. Keeping the installed copy."
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
# home.activation.axiTools enforces the tasks-axi minimum without downgrades,
|
||||||
|
# so a newer release installed here survives the switch.
|
||||||
|
npm_globals=(
|
||||||
|
"@steipete/bird"
|
||||||
|
chrome-devtools-axi
|
||||||
|
defuddle
|
||||||
|
forgejo-axi
|
||||||
|
gh-axi
|
||||||
|
lavish-axi
|
||||||
|
quota-axi
|
||||||
|
tasks-axi
|
||||||
|
)
|
||||||
|
for pkg in "${npm_globals[@]}"; do
|
||||||
|
update_npm_global "$pkg"
|
||||||
|
done
|
||||||
|
echo "==> npm global tools update complete"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove retired npm OpenCode installs if an older rebuild installed them:
|
# Remove retired npm OpenCode installs if an older rebuild installed them:
|
||||||
@@ -21,7 +86,6 @@ fi
|
|||||||
# `opencode` formula declared in configuration.nix is now the only OpenCode
|
# `opencode` formula declared in configuration.nix is now the only OpenCode
|
||||||
# install, unpinned so it tracks the latest release. The guard is a local check
|
# install, unpinned so it tracks the latest release. The guard is a local check
|
||||||
# for npm, so a rebuild without npm skips this instead of failing.
|
# for npm, so a rebuild without npm skips this instead of failing.
|
||||||
NPM=/opt/homebrew/bin/npm
|
|
||||||
if [ -x "$NPM" ] && npm_root="$("$NPM" root -g 2>/dev/null)"; then
|
if [ -x "$NPM" ] && npm_root="$("$NPM" root -g 2>/dev/null)"; then
|
||||||
for pkg in @opencode-ai/cli opencode-ai; do
|
for pkg in @opencode-ai/cli opencode-ai; do
|
||||||
if [ -d "$npm_root/$pkg" ]; then
|
if [ -d "$npm_root/$pkg" ]; then
|
||||||
@@ -63,8 +127,21 @@ else
|
|||||||
echo "==> WARNING: no-mistakes not found. Skipping update."
|
echo "==> WARNING: no-mistakes not found. Skipping update."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Hermes Agent is a mutable git clone at ~/.hermes/hermes-agent, so Nix and
|
||||||
|
# Homebrew never move it. Its own updater pulls the configured channel and
|
||||||
|
# restarts the services that run its new code; --yes keeps the rebuild
|
||||||
|
# non-interactive.
|
||||||
|
echo "==> Updating Hermes Agent..."
|
||||||
|
if ! command -v hermes >/dev/null 2>&1; then
|
||||||
|
echo "==> WARNING: hermes not found. Skipping update."
|
||||||
|
elif hermes update --yes 2>&1; then
|
||||||
|
echo "==> hermes update complete"
|
||||||
|
else
|
||||||
|
echo "==> WARNING: hermes update failed. Keeping the installed version."
|
||||||
|
fi
|
||||||
|
|
||||||
stamp="$(date +%Y%m%d-%H%M%S)"
|
stamp="$(date +%Y%m%d-%H%M%S)"
|
||||||
# Paths home-manager manages via home.file (regular files become out-of-store symlinks).
|
# Paths managed by home.file, including config links and Nix package binaries.
|
||||||
managed=(
|
managed=(
|
||||||
"$HOME/.grok/config.toml"
|
"$HOME/.grok/config.toml"
|
||||||
"$HOME/.grok/AGENTS.md"
|
"$HOME/.grok/AGENTS.md"
|
||||||
@@ -73,16 +150,20 @@ managed=(
|
|||||||
"$HOME/.codex/AGENTS.md"
|
"$HOME/.codex/AGENTS.md"
|
||||||
"$HOME/.codex/luna.config.toml"
|
"$HOME/.codex/luna.config.toml"
|
||||||
"$HOME/.config/herdr/config.toml"
|
"$HOME/.config/herdr/config.toml"
|
||||||
|
"$HOME/.config/bird/config.json5"
|
||||||
"$HOME/.config/opencode/AGENTS.md"
|
"$HOME/.config/opencode/AGENTS.md"
|
||||||
"$HOME/.config/opencode/opencode.json"
|
"$HOME/.config/opencode/opencode.json"
|
||||||
"$HOME/.config/opencode2/opencode.json"
|
"$HOME/.config/opencode2/opencode.json"
|
||||||
"$HOME/.config/opencode2/AGENTS.md"
|
"$HOME/.config/opencode2/AGENTS.md"
|
||||||
|
"$HOME/.local/bin/actionlint"
|
||||||
|
"$HOME/.local/bin/shellcheck"
|
||||||
"$HOME/.local/bin/oc2"
|
"$HOME/.local/bin/oc2"
|
||||||
"$HOME/.local/bin/opencode-go-token"
|
"$HOME/.local/bin/opencode-go-token"
|
||||||
"$HOME/.local/bin/opencode-go-key-sync"
|
"$HOME/.local/bin/opencode-go-key-sync"
|
||||||
"$HOME/.pi/agent/settings.json"
|
"$HOME/.pi/agent/settings.json"
|
||||||
"$HOME/.pi/agent/models.json"
|
"$HOME/.pi/agent/models.json"
|
||||||
"$HOME/.pi/agent/AGENTS.md"
|
"$HOME/.pi/agent/AGENTS.md"
|
||||||
|
"$HOME/.pi/agent/bin/bird"
|
||||||
"$HOME/.pi/agent/extensions/terminal-status-title.js"
|
"$HOME/.pi/agent/extensions/terminal-status-title.js"
|
||||||
)
|
)
|
||||||
for path in "${managed[@]}"; do
|
for path in "${managed[@]}"; do
|
||||||
@@ -114,8 +195,55 @@ else
|
|||||||
echo "==> WARNING: flake update failed. Continuing with locked inputs."
|
echo "==> WARNING: flake update failed. Continuing with locked inputs."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Trust third-party Homebrew taps before the switch. `brew bundle` refuses to
|
||||||
|
# install formulae from an untrusted tap, and a trust can revert between runs.
|
||||||
|
# The whisper-cpp rename notice is only a warning and stays harmless here.
|
||||||
|
if command -v brew >/dev/null 2>&1; then
|
||||||
|
brew trust can1357/tap 2>/dev/null || true
|
||||||
|
brew trust incoai/tap 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
sudo darwin-rebuild switch --flake ~/.dotfiles#lt-mbp
|
sudo darwin-rebuild switch --flake ~/.dotfiles#lt-mbp
|
||||||
|
|
||||||
|
# Update tracked skills after activation. Exclude security-audit to preserve
|
||||||
|
# home.activation.securityAuditSkill's freeze policy. Untracked skills,
|
||||||
|
# including the pinned pstack copies, are outside this updater's scope.
|
||||||
|
echo "==> Updating agent skills..."
|
||||||
|
NPX=/opt/homebrew/bin/npx
|
||||||
|
SKILL_LOCK="$HOME/.agents/.skill-lock.json"
|
||||||
|
if [ ! -x "$NPX" ]; then
|
||||||
|
echo "==> WARNING: $NPX not found. Skipping agent skill update."
|
||||||
|
elif [ ! -f "$SKILL_LOCK" ]; then
|
||||||
|
echo "==> WARNING: $SKILL_LOCK not found. Skipping agent skill update."
|
||||||
|
elif [ ! -f "$DENYLIST" ]; then
|
||||||
|
echo "==> WARNING: $DENYLIST not found. Skipping agent skill update."
|
||||||
|
else
|
||||||
|
skill_names="$(/usr/bin/python3 - "$SKILL_LOCK" "$DENYLIST" 2>/dev/null <<'PY' || true
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
with open(sys.argv[1]) as lock_file:
|
||||||
|
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):
|
||||||
|
if name != "security-audit" and name not in denied:
|
||||||
|
print(name)
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
if [ -z "$skill_names" ]; then
|
||||||
|
echo "==> WARNING: no tracked skills found in $SKILL_LOCK. Skipping agent skill update."
|
||||||
|
else
|
||||||
|
# Unquoted on purpose: each tracked name is a separate CLI argument.
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
if "$NPX" --yes skills@latest update -g -y $skill_names 2>&1; then
|
||||||
|
echo "==> agent skill update complete"
|
||||||
|
else
|
||||||
|
echo "==> WARNING: agent skill update failed (network or Skills CLI issue). Skipping."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Update installed pi packages after the switch, because the Homebrew bundle
|
# Update installed pi packages after the switch, because the Homebrew bundle
|
||||||
# may have upgraded the pi binary.
|
# may have upgraded the pi binary.
|
||||||
echo "==> Updating pi extensions..."
|
echo "==> Updating pi extensions..."
|
||||||
|
|||||||
Executable
+200
@@ -0,0 +1,200 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# End-to-end check for the Brave-only bird wrapper.
|
||||||
|
#
|
||||||
|
# The check runs the real wrapper from this repo against a throwaway HOME with:
|
||||||
|
# - a fake Brave cookie database with encrypted x.com auth_token and ct0;
|
||||||
|
# - a fake Brave Safe Storage password served by a `security` spy on PATH;
|
||||||
|
# - fake Safari, Chrome, and Firefox cookie databases with decoy tokens;
|
||||||
|
# - a fake credentials file with a decoy token;
|
||||||
|
# - a fake "real bird" that records argv and the environment it receives.
|
||||||
|
#
|
||||||
|
# It proves the wrapper decrypts Brave cookies with the Brave key, passes the
|
||||||
|
# two cookies to bird as AUTH_TOKEN and CT0, prints no cookie or credential
|
||||||
|
# value, and never opens Safari, Chrome, Firefox, or the credentials file.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||||
|
WRAPPER="$ROOT/home/.pi/agent/bin/bird"
|
||||||
|
TMP=$(mktemp -d "${TMPDIR:-/tmp}/bird-brave-e2e.XXXXXX")
|
||||||
|
trap 'chmod -R u+rwX "$TMP" 2>/dev/null || true; rm -rf "$TMP"' EXIT
|
||||||
|
|
||||||
|
fail() { printf 'FAIL: %s\n' "$1" >&2; exit 1; }
|
||||||
|
pass() { printf 'PASS: %s\n' "$1"; }
|
||||||
|
|
||||||
|
[ -f "$WRAPPER" ] || fail "wrapper missing at $WRAPPER"
|
||||||
|
[ -x "$WRAPPER" ] || fail "wrapper is not executable at $WRAPPER"
|
||||||
|
|
||||||
|
FIX="$TMP/home"
|
||||||
|
BRAVE_DIR="$FIX/Library/Application Support/BraveSoftware/Brave-Browser/Default"
|
||||||
|
CHROME_DIR="$FIX/Library/Application Support/Google/Chrome/Default"
|
||||||
|
FIREFOX_DIR="$FIX/Library/Application Support/Firefox/Profiles/default"
|
||||||
|
SAFARI_DIR="$FIX/Library/Safari"
|
||||||
|
CRED_FILE="$FIX/.config/bird/credentials"
|
||||||
|
|
||||||
|
mkdir -p "$TMP/bin" "$BRAVE_DIR" "$CHROME_DIR" "$FIREFOX_DIR" "$SAFARI_DIR" \
|
||||||
|
"$(dirname "$CRED_FILE")"
|
||||||
|
|
||||||
|
AUTH_VALUE='BRAVE_AUTH_SENTINEL_7f3a'
|
||||||
|
CT0_VALUE='BRAVE_CT0_SENTINEL_91c2'
|
||||||
|
FAKE_KEY='brave-fixture-password'
|
||||||
|
|
||||||
|
# Build the fake cookie databases. The Brave values use the same v10 scheme as
|
||||||
|
# real Brave: PBKDF2-HMAC-SHA1(saltysalt, 1003) and AES-128-CBC with a space IV.
|
||||||
|
python3 - "$BRAVE_DIR/Cookies" "$CHROME_DIR/Cookies" "$FIREFOX_DIR/cookies.sqlite" \
|
||||||
|
"$SAFARI_DIR/Cookies.binarycookies" "$AUTH_VALUE" "$CT0_VALUE" "$FAKE_KEY" <<'PY'
|
||||||
|
import ctypes
|
||||||
|
import hashlib
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
|
||||||
|
brave_db, chrome_db, firefox_db, safari_db, auth_value, ct0_value, password = sys.argv[1:]
|
||||||
|
lib = ctypes.CDLL("/usr/lib/libSystem.B.dylib")
|
||||||
|
lib.CCCrypt.argtypes = [
|
||||||
|
ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32,
|
||||||
|
ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p,
|
||||||
|
ctypes.c_char_p, ctypes.c_size_t, ctypes.c_void_p, ctypes.c_size_t,
|
||||||
|
ctypes.POINTER(ctypes.c_size_t),
|
||||||
|
]
|
||||||
|
lib.CCCrypt.restype = ctypes.c_int32
|
||||||
|
key = hashlib.pbkdf2_hmac("sha1", password.encode(), b"saltysalt", 1003, 16)
|
||||||
|
iv = b" " * 16
|
||||||
|
|
||||||
|
|
||||||
|
def encrypted(host_key, value):
|
||||||
|
payload = hashlib.sha256(host_key.encode()).digest() + value.encode()
|
||||||
|
out = ctypes.create_string_buffer(len(payload) + 32)
|
||||||
|
moved = ctypes.c_size_t(0)
|
||||||
|
status = lib.CCCrypt(0, 0, 1, key, len(key), iv, payload, len(payload),
|
||||||
|
out, len(out), ctypes.byref(moved))
|
||||||
|
assert status == 0, status
|
||||||
|
return b"v10" + out.raw[:moved.value]
|
||||||
|
|
||||||
|
|
||||||
|
def make_cookie_db(path, rows, version=24):
|
||||||
|
conn = sqlite3.connect(path)
|
||||||
|
conn.execute("CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT)")
|
||||||
|
conn.execute("INSERT INTO meta (key, value) VALUES ('version', ?)", (str(version),))
|
||||||
|
conn.execute(
|
||||||
|
"CREATE TABLE cookies (host_key TEXT, name TEXT, value TEXT, encrypted_value BLOB)"
|
||||||
|
)
|
||||||
|
conn.executemany("INSERT INTO cookies VALUES (?, ?, '', ?)", rows)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
make_cookie_db(brave_db, [
|
||||||
|
("x.com", "auth_token", encrypted("x.com", auth_value)),
|
||||||
|
(".x.com", "ct0", encrypted(".x.com", ct0_value)),
|
||||||
|
("example.com", "auth_token", encrypted("example.com", "OTHER_DOMAIN_DECOY")),
|
||||||
|
])
|
||||||
|
make_cookie_db(chrome_db, [
|
||||||
|
("x.com", "auth_token", b"CHROME_AUTH_DECOY"),
|
||||||
|
("x.com", "ct0", b"CHROME_CT0_DECOY"),
|
||||||
|
])
|
||||||
|
make_cookie_db(firefox_db, [
|
||||||
|
("x.com", "auth_token", b"FIREFOX_AUTH_DECOY"),
|
||||||
|
("x.com", "ct0", b"FIREFOX_CT0_DECOY"),
|
||||||
|
])
|
||||||
|
with open(safari_db, "wb") as handle:
|
||||||
|
handle.write(b"SAFARI_AUTH_DECOY")
|
||||||
|
PY
|
||||||
|
|
||||||
|
printf 'CREDENTIALS_DECOY_NEVER_READ\n' > "$CRED_FILE"
|
||||||
|
|
||||||
|
cat > "$TMP/bin/security" <<'SH'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
printf '%s\n' "$*" >> "$BIRD_E2E_KEYCHAIN_LOG"
|
||||||
|
case " $* " in
|
||||||
|
*"add-generic-password"*|*"delete-generic-password"*|*"Chrome Safe Storage"*)
|
||||||
|
printf 'unexpected keychain operation\n' >&2
|
||||||
|
exit 9 ;;
|
||||||
|
esac
|
||||||
|
if [ "$1" = "find-generic-password" ] && [ "$3" = "Brave Safe Storage" ] \
|
||||||
|
&& [ "$5" = "Brave" ]; then
|
||||||
|
printf '%s' "$BIRD_E2E_FAKE_KEY"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exit 8
|
||||||
|
SH
|
||||||
|
|
||||||
|
cat > "$TMP/bin/fake-bird" <<'SH'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
{
|
||||||
|
printf 'args:'
|
||||||
|
for arg in "$@"; do printf ' <%s>' "$arg"; done
|
||||||
|
printf '\n'
|
||||||
|
printf 'auth=%s\n' "${AUTH_TOKEN-<unset>}"
|
||||||
|
printf 'ct0=%s\n' "${CT0-<unset>}"
|
||||||
|
} > "$BIRD_E2E_BIRD_LOG"
|
||||||
|
printf 'fake bird ok\n'
|
||||||
|
SH
|
||||||
|
chmod +x "$TMP/bin/security" "$TMP/bin/fake-bird"
|
||||||
|
|
||||||
|
: > "$TMP/keychain.log"
|
||||||
|
: > "$TMP/bird.log"
|
||||||
|
: > "$TMP/stdout"
|
||||||
|
: > "$TMP/stderr"
|
||||||
|
|
||||||
|
before_brave=$(shasum -a 256 "$BRAVE_DIR/Cookies" | awk '{print $1}')
|
||||||
|
before_chrome=$(shasum -a 256 "$CHROME_DIR/Cookies" | awk '{print $1}')
|
||||||
|
before_firefox=$(shasum -a 256 "$FIREFOX_DIR/cookies.sqlite" | awk '{print $1}')
|
||||||
|
before_safari=$(shasum -a 256 "$SAFARI_DIR/Cookies.binarycookies" | awk '{print $1}')
|
||||||
|
before_creds=$(shasum -a 256 "$CRED_FILE" | awk '{print $1}')
|
||||||
|
|
||||||
|
# A read attempt on any of these files must fail. The wrapper only needs Brave.
|
||||||
|
chmod 000 "$CHROME_DIR/Cookies" "$FIREFOX_DIR/cookies.sqlite" \
|
||||||
|
"$SAFARI_DIR/Cookies.binarycookies" "$CRED_FILE"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
env -i \
|
||||||
|
HOME="$FIX" \
|
||||||
|
PATH="$TMP/bin:/opt/homebrew/bin:/usr/bin:/bin" \
|
||||||
|
BIRD_E2E_FAKE_KEY="$FAKE_KEY" \
|
||||||
|
BIRD_E2E_KEYCHAIN_LOG="$TMP/keychain.log" \
|
||||||
|
BIRD_E2E_BIRD_LOG="$TMP/bird.log" \
|
||||||
|
BIRD_BRAVE_REAL_BIRD="$TMP/bin/fake-bird" \
|
||||||
|
"$WRAPPER" read https://x.com/i/status/123 --json \
|
||||||
|
>"$TMP/stdout" 2>"$TMP/stderr"
|
||||||
|
status=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
chmod 644 "$CHROME_DIR/Cookies" "$FIREFOX_DIR/cookies.sqlite" \
|
||||||
|
"$SAFARI_DIR/Cookies.binarycookies" "$CRED_FILE"
|
||||||
|
|
||||||
|
[ "$status" -eq 0 ] || fail "wrapper exited $status: $(cat "$TMP/stderr")"
|
||||||
|
grep -q 'fake bird ok' "$TMP/stdout" || fail 'real bird was not executed'
|
||||||
|
grep -Fxq 'args: <read> <https://x.com/i/status/123> <--json>' "$TMP/bird.log" \
|
||||||
|
|| fail "bird argv was not passed through: $(cat "$TMP/bird.log")"
|
||||||
|
grep -Fxq "auth=$AUTH_VALUE" "$TMP/bird.log" \
|
||||||
|
|| fail 'bird did not receive the Brave auth_token'
|
||||||
|
grep -Fxq "ct0=$CT0_VALUE" "$TMP/bird.log" \
|
||||||
|
|| fail 'bird did not receive the Brave ct0'
|
||||||
|
pass 'wrapper decrypts Brave cookies and passes them to bird'
|
||||||
|
|
||||||
|
grep -Fxq 'find-generic-password -s Brave Safe Storage -a Brave -w' "$TMP/keychain.log" \
|
||||||
|
|| fail "unexpected keychain calls: $(cat "$TMP/keychain.log")"
|
||||||
|
[ "$(wc -l < "$TMP/keychain.log" | tr -d ' ')" -eq 1 ] \
|
||||||
|
|| fail 'wrapper made more than one keychain call'
|
||||||
|
pass 'wrapper reads Brave Safe Storage only and writes no keychain item'
|
||||||
|
|
||||||
|
for value in "$AUTH_VALUE" "$CT0_VALUE" 'CREDENTIALS_DECOY_NEVER_READ' \
|
||||||
|
'CHROME_AUTH_DECOY' 'FIREFOX_AUTH_DECOY' 'SAFARI_AUTH_DECOY'; do
|
||||||
|
if grep -Fq "$value" "$TMP/stdout" || grep -Fq "$value" "$TMP/stderr"; then
|
||||||
|
fail "wrapper printed a secret value: $value"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
pass 'wrapper prints no cookie or credential value'
|
||||||
|
|
||||||
|
after_chrome=$(shasum -a 256 "$CHROME_DIR/Cookies" | awk '{print $1}')
|
||||||
|
after_firefox=$(shasum -a 256 "$FIREFOX_DIR/cookies.sqlite" | awk '{print $1}')
|
||||||
|
after_safari=$(shasum -a 256 "$SAFARI_DIR/Cookies.binarycookies" | awk '{print $1}')
|
||||||
|
after_creds=$(shasum -a 256 "$CRED_FILE" | awk '{print $1}')
|
||||||
|
after_brave=$(shasum -a 256 "$BRAVE_DIR/Cookies" | awk '{print $1}')
|
||||||
|
[ "$before_brave" = "$after_brave" ] || fail 'Brave cookie database changed'
|
||||||
|
[ "$before_chrome" = "$after_chrome" ] || fail 'Chrome cookies were touched'
|
||||||
|
[ "$before_firefox" = "$after_firefox" ] || fail 'Firefox cookies were touched'
|
||||||
|
[ "$before_safari" = "$after_safari" ] || fail 'Safari cookies were touched'
|
||||||
|
[ "$before_creds" = "$after_creds" ] || fail 'credentials file was touched'
|
||||||
|
pass 'wrapper touches Brave only, never Safari, Chrome, Firefox, or credentials'
|
||||||
|
|
||||||
|
printf 'OK: bird brave-only end-to-end check passed\n'
|
||||||
Executable
+62
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Check that the Nix source wires the Brave-only bird wrapper into the shell.
|
||||||
|
#
|
||||||
|
# The Bird merge added home.file entries for the wrapper and the Brave config,
|
||||||
|
# but no PATH entry. A rebuild installs the wrapper at ~/.pi/agent/bin/bird and
|
||||||
|
# leaves `bird` resolving to Homebrew's npm shim. This check evaluates the real
|
||||||
|
# home-manager config, then runs the generated zshrc in a fresh zsh with a fake
|
||||||
|
# Homebrew bird ahead of the wrapper. It passes only when the wrapper wins.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||||
|
TMP=$(mktemp -d "${TMPDIR:-/tmp}/bird-path.XXXXXX")
|
||||||
|
trap 'rm -rf "$TMP"' EXIT
|
||||||
|
|
||||||
|
fail() { printf 'FAIL: %s\n' "$1" >&2; exit 1; }
|
||||||
|
pass() { printf 'PASS: %s\n' "$1"; }
|
||||||
|
|
||||||
|
command -v nix >/dev/null 2>&1 \
|
||||||
|
|| { echo "bird-path: nix is required to evaluate the configuration" >&2; exit 2; }
|
||||||
|
command -v jq >/dev/null 2>&1 \
|
||||||
|
|| { echo "bird-path: jq is required to read the session path" >&2; exit 2; }
|
||||||
|
command -v zsh >/dev/null 2>&1 \
|
||||||
|
|| { echo "bird-path: zsh is required to run the generated zshrc" >&2; exit 2; }
|
||||||
|
|
||||||
|
CONFIG='(builtins.getFlake (toString '"$ROOT"')).darwinConfigurations."lt-mbp".config.home-manager.users.laptran'
|
||||||
|
|
||||||
|
wrapper_source=$(nix eval --raw --impure --expr "$CONFIG.home.file.\".pi/agent/bin/bird\".source")
|
||||||
|
wrapper_target=$(readlink "$wrapper_source" 2>/dev/null || printf '%s' "$wrapper_source")
|
||||||
|
case "$wrapper_target" in
|
||||||
|
*"home/.pi/agent/bin/bird") pass "source declares the Brave-only bird wrapper" ;;
|
||||||
|
*) fail "wrapper home.file source points to $wrapper_target" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
nix eval --json --impure --expr "$CONFIG.home.sessionPath" > "$TMP/session-path.json"
|
||||||
|
first_path=$(jq -r '.[0] // ""' "$TMP/session-path.json")
|
||||||
|
case "$first_path" in
|
||||||
|
*"/.pi/agent/bin") pass "session PATH puts the wrapper directory first" ;;
|
||||||
|
*) fail "first session PATH entry is '$first_path', not the bird wrapper directory" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
nix eval --raw --impure --expr "$CONFIG.home.file.\"./.zshrc\".text" > "$TMP/zshrc"
|
||||||
|
mkdir -p "$TMP/home/.pi/agent/bin" "$TMP/homebrew/bin"
|
||||||
|
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 '
|
||||||
|
source "$ZSHRC" >/dev/null 2>&1 || exit 4
|
||||||
|
command -v bird
|
||||||
|
' 2>"$TMP/stderr") || {
|
||||||
|
echo "bird-path: failed to run generated zshrc" >&2
|
||||||
|
cat "$TMP/stderr" >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "$resolved" = "$TMP/home/.pi/agent/bin/bird" ] \
|
||||||
|
|| fail "generated zshrc resolves bird to $resolved instead of the wrapper"
|
||||||
|
|
||||||
|
pass "generated zshrc resolves bird to the wrapper ahead of Homebrew"
|
||||||
+94
-52
@@ -1,15 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Behavior check: a fresh interactive zsh runs `fm` and the permanent launcher
|
# Behavior check: a fresh interactive zsh runs the firstmate launchers and each
|
||||||
# starts OpenCode 2 through ~/.local/bin/oc2, never Pi.
|
# one starts the tool its name promises, from the firstmate home directory.
|
||||||
|
#
|
||||||
|
# fm -> OpenCode 2 through ~/.local/bin/oc2
|
||||||
|
# fm-oc2 -> OpenCode 2 through ~/.local/bin/oc2, identical to fm
|
||||||
|
# fm-pi -> Pi
|
||||||
#
|
#
|
||||||
# The check reads the zshrc that the real home-manager configuration generates
|
# The check reads the zshrc that the real home-manager configuration generates
|
||||||
# (the same file a rebuild installs), sources it in an interactive zsh, and runs
|
# (the same file a rebuild installs), sources it in an interactive zsh, and runs
|
||||||
# `fm` with two harmless spies:
|
# each launcher with three harmless spies:
|
||||||
# - a `pi` spy first on PATH, which catches a Pi launch;
|
# - a `pi` spy first on PATH, which catches a Pi launch;
|
||||||
# - a spy named by OPENCODE2_BIN, which the real ~/.local/bin/oc2 wrapper
|
# - a spy named by OPENCODE2_BIN, which the real ~/.local/bin/oc2 wrapper
|
||||||
# execs instead of the OpenCode binary.
|
# execs instead of the OpenCode binary;
|
||||||
# Nothing here launches a real firstmate primary, Pi, or OpenCode, so no
|
# - the spies record their working directory, so a launcher that forgets the
|
||||||
# session lock is taken.
|
# `cd` into the firstmate home fails here.
|
||||||
|
# Nothing here launches a real firstmate primary, Pi, or OpenCode, and the spies
|
||||||
|
# exit at once, so no session lock is taken and the primary stays alive.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# tests/fm-launcher.sh # check the configuration source (default)
|
# tests/fm-launcher.sh # check the configuration source (default)
|
||||||
@@ -20,6 +26,8 @@ set -euo pipefail
|
|||||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||||
MODE=source
|
MODE=source
|
||||||
ZSHRC=''
|
ZSHRC=''
|
||||||
|
LAUNCHERS='fm:oc2 fm-oc2:oc2 fm-pi:pi'
|
||||||
|
FM_HOME=${FM_HOME:-"$HOME/Documents/firstmate"}
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -41,14 +49,14 @@ trap cleanup EXIT
|
|||||||
mkdir -p "$TMP/bin"
|
mkdir -p "$TMP/bin"
|
||||||
cat > "$TMP/bin/pi" <<'SH'
|
cat > "$TMP/bin/pi" <<'SH'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
printf 'pi' >> "$FM_TEST_SPY_LOG"
|
printf 'pi|%s' "$PWD" >> "$FM_TEST_SPY_LOG"
|
||||||
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
||||||
printf '\n' >> "$FM_TEST_SPY_LOG"
|
printf '\n' >> "$FM_TEST_SPY_LOG"
|
||||||
exit 0
|
exit 0
|
||||||
SH
|
SH
|
||||||
cat > "$TMP/bin/opencode2-spy" <<'SH'
|
cat > "$TMP/bin/opencode2-spy" <<'SH'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
printf 'oc2' >> "$FM_TEST_SPY_LOG"
|
printf 'oc2|%s' "$PWD" >> "$FM_TEST_SPY_LOG"
|
||||||
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done
|
||||||
printf '\n' >> "$FM_TEST_SPY_LOG"
|
printf '\n' >> "$FM_TEST_SPY_LOG"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -77,53 +85,87 @@ esac
|
|||||||
|
|
||||||
[ -r "$ZSHRC" ] || { echo "fm-launcher: cannot read $ZSHRC" >&2; exit 2; }
|
[ -r "$ZSHRC" ] || { echo "fm-launcher: cannot read $ZSHRC" >&2; exit 2; }
|
||||||
|
|
||||||
: > "$TMP/spy.log"
|
# Run one launcher in a fresh interactive zsh and print what the spies saw.
|
||||||
: > "$TMP/stderr"
|
launch() {
|
||||||
|
local launcher=$1
|
||||||
|
: > "$TMP/spy.log"
|
||||||
|
: > "$TMP/stderr"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
# shellcheck disable=SC2016 # the snippet expands inside the interactive zsh
|
# shellcheck disable=SC2016 # the snippet expands inside the interactive zsh
|
||||||
FM_TEST_ZSHRC="$ZSHRC" \
|
FM_TEST_ZSHRC="$ZSHRC" \
|
||||||
FM_TEST_SPY_LOG="$TMP/spy.log" \
|
FM_TEST_LAUNCHER="$launcher" \
|
||||||
OPENCODE2_BIN="$TMP/bin/opencode2-spy" \
|
FM_TEST_SPY_LOG="$TMP/spy.log" \
|
||||||
OPENCODE_CONFIG="$TMP/opencode.json" \
|
OPENCODE2_BIN="$TMP/bin/opencode2-spy" \
|
||||||
PATH="$TMP/bin:$PATH" \
|
OPENCODE_CONFIG="$TMP/opencode.json" \
|
||||||
timeout 60 zsh -f -i -c '
|
PATH="$TMP/bin:$PATH" \
|
||||||
source "$FM_TEST_ZSHRC" || exit 4
|
timeout 60 zsh -f -i -c '
|
||||||
if ! alias fm >/dev/null 2>&1; then
|
source "$FM_TEST_ZSHRC" || exit 4
|
||||||
echo "fm-launcher: no fm alias in the sourced zshrc" >&2
|
if ! alias "$FM_TEST_LAUNCHER" >/dev/null 2>&1; then
|
||||||
exit 3
|
echo "fm-launcher: no $FM_TEST_LAUNCHER alias in the sourced zshrc" >&2
|
||||||
fi
|
exit 3
|
||||||
eval fm
|
fi
|
||||||
' >/dev/null 2>"$TMP/stderr"
|
eval "$FM_TEST_LAUNCHER"
|
||||||
status=$?
|
' >/dev/null 2>"$TMP/stderr"
|
||||||
set -e
|
LAUNCH_STATUS=$?
|
||||||
|
set -e
|
||||||
|
}
|
||||||
|
|
||||||
launched=''
|
for pair in $LAUNCHERS; do
|
||||||
[ -s "$TMP/spy.log" ] && launched=$(head -n 1 "$TMP/spy.log")
|
launcher=${pair%%:*}
|
||||||
|
expected=${pair##*:}
|
||||||
|
|
||||||
if [ "$status" -eq 3 ]; then
|
launch "$launcher"
|
||||||
echo "FAIL: $LABEL does not define an fm alias"
|
status=$LAUNCH_STATUS
|
||||||
exit 1
|
|
||||||
fi
|
if [ "$status" -eq 3 ]; then
|
||||||
if [ "$status" -ne 0 ]; then
|
echo "FAIL: $LABEL does not define a $launcher alias"
|
||||||
echo "FAIL: fm launch from $LABEL exited $status"
|
exit 1
|
||||||
sed 's/^/ /' "$TMP/stderr"
|
fi
|
||||||
exit 1
|
if [ "$status" -ne 0 ]; then
|
||||||
fi
|
echo "FAIL: $launcher from $LABEL exited $status"
|
||||||
if [ -z "$launched" ]; then
|
sed 's/^/ /' "$TMP/stderr"
|
||||||
echo "FAIL: fm from $LABEL launched nothing the spies could see"
|
exit 1
|
||||||
sed 's/^/ /' "$TMP/stderr"
|
fi
|
||||||
exit 1
|
if [ ! -s "$TMP/spy.log" ]; then
|
||||||
fi
|
echo "FAIL: $launcher from $LABEL launched nothing the spies could see"
|
||||||
if [ "${launched%%|*}" != oc2 ]; then
|
sed 's/^/ /' "$TMP/stderr"
|
||||||
echo "FAIL: fm from $LABEL launched ${launched%%|*} instead of OpenCode 2 (oc2)"
|
exit 1
|
||||||
echo " recorded launch: $launched"
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
record=$(head -n 1 "$TMP/spy.log")
|
||||||
if grep -q '^pi' "$TMP/spy.log"; then
|
tool=${record%%|*}
|
||||||
echo "FAIL: fm from $LABEL also launched Pi"
|
dir=$(printf '%s' "${record#*|}" | cut -d'|' -f1)
|
||||||
sed 's/^/ /' "$TMP/spy.log"
|
|
||||||
|
if [ "$tool" != "$expected" ]; then
|
||||||
|
echo "FAIL: $launcher from $LABEL launched $tool instead of $expected"
|
||||||
|
echo " recorded launch: $record"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$dir" != "$FM_HOME" ]; then
|
||||||
|
echo "FAIL: $launcher from $LABEL ran in $dir instead of the firstmate home $FM_HOME"
|
||||||
|
echo " recorded launch: $record"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$expected" = oc2 ] && grep -q '^pi' "$TMP/spy.log"; then
|
||||||
|
echo "FAIL: $launcher from $LABEL also launched Pi"
|
||||||
|
sed 's/^/ /' "$TMP/spy.log"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$launcher" in
|
||||||
|
fm) fm_record=$record ;;
|
||||||
|
fm-oc2) fm_oc2_record=$record ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "PASS: $launcher from $LABEL launched $expected in $dir ($record)"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$fm_record" != "$fm_oc2_record" ]; then
|
||||||
|
echo "FAIL: fm and fm-oc2 are not identical launchers"
|
||||||
|
echo " fm: $fm_record"
|
||||||
|
echo " fm-oc2: $fm_oc2_record"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "PASS: fm from $LABEL launched OpenCode 2 via oc2 ($launched)"
|
echo "PASS: fm and fm-oc2 are identical launchers"
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
"""Execute rebuild.sh against isolated external command boundaries.
|
||||||
|
|
||||||
|
Oracles: installed-tool updates from the rebuild contract, activation ownership
|
||||||
|
from configuration.nix/home.nix, and the security-audit/pstack freeze policy.
|
||||||
|
Assertions reject dead update blocks, absent-package installs, duplicate owners,
|
||||||
|
failed-update aborts, and updates to frozen or untracked skills.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
GLOBALS = (
|
||||||
|
"@steipete/bird", "chrome-devtools-axi", "defuddle", "forgejo-axi",
|
||||||
|
"gh-axi", "lavish-axi", "quota-axi", "tasks-axi",
|
||||||
|
)
|
||||||
|
ACTIVATION_GLOBALS = ("acpx", "backpass")
|
||||||
|
|
||||||
|
BOUNDARIES = r'''
|
||||||
|
mock() { command "$TEST_PYTHON" "$TEST_DISPATCH" "$@"; }
|
||||||
|
function /opt/homebrew/bin/npm { mock npm "$@"; }
|
||||||
|
function /opt/homebrew/bin/node { command "$TEST_NODE" "$@"; }
|
||||||
|
function /opt/homebrew/bin/npx { mock npx "$@"; }
|
||||||
|
function /usr/bin/python3 { command "$TEST_PYTHON" "$@"; }
|
||||||
|
function [ {
|
||||||
|
if [[ $1 == '!' ]]; then
|
||||||
|
shift
|
||||||
|
! '[' "$@"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ $1 == -x && $2 == /opt/homebrew/bin/* ]]; then
|
||||||
|
case "$2" in
|
||||||
|
/opt/homebrew/bin/npm) builtin [ "$TEST_NPM" = 1 ]; return ;;
|
||||||
|
/opt/homebrew/bin/npx) builtin [ "$TEST_NPX" = 1 ]; return ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
builtin [ "$@"
|
||||||
|
}
|
||||||
|
readlink() { return 1; }
|
||||||
|
npm() { mock bare-npm "$@"; }
|
||||||
|
brew() { mock brew "$@"; }
|
||||||
|
sudo() { mock sudo "$@"; }
|
||||||
|
nix() { mock nix "$@"; }
|
||||||
|
hermes() { mock hermes "$@"; }
|
||||||
|
pi() { mock pi "$@"; }
|
||||||
|
no-mistakes() { mock no-mistakes "$@"; }
|
||||||
|
if [[ $TEST_MISSING_TOOLS == 1 ]]; then
|
||||||
|
unset -f hermes pi no-mistakes
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
|
||||||
|
DISPATCH = r'''
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
kind, *args = sys.argv[1:]
|
||||||
|
root = Path(os.environ["TEST_ROOT"])
|
||||||
|
with (root / "calls.jsonl").open("a") as log:
|
||||||
|
log.write(json.dumps([kind, *args]) + "\n")
|
||||||
|
state_path = root / "state.json"
|
||||||
|
state = json.loads(state_path.read_text())
|
||||||
|
|
||||||
|
def save():
|
||||||
|
state_path.write_text(json.dumps(state))
|
||||||
|
|
||||||
|
if kind == "npm":
|
||||||
|
action = args[0]
|
||||||
|
if action == "ls":
|
||||||
|
if state.get("bad_inventory"):
|
||||||
|
print("invalid inventory")
|
||||||
|
sys.exit(1)
|
||||||
|
print(json.dumps({"dependencies": {
|
||||||
|
name: {"version": version}
|
||||||
|
for name, version in state["packages"].items()
|
||||||
|
}}))
|
||||||
|
elif action == "view":
|
||||||
|
if state.get("fail_lookup") == args[1]:
|
||||||
|
sys.exit(1)
|
||||||
|
print("2.0.0")
|
||||||
|
elif action == "install":
|
||||||
|
name, version = args[2].rsplit("@", 1)
|
||||||
|
if state.get("fail_install") == name:
|
||||||
|
sys.exit(1)
|
||||||
|
state["packages"][name] = version
|
||||||
|
save()
|
||||||
|
elif action == "root":
|
||||||
|
print(root / "global_modules")
|
||||||
|
else:
|
||||||
|
sys.exit("unexpected npm command: " + repr(args))
|
||||||
|
elif kind in ("no-mistakes", "hermes", "nix", "npx", "pi"):
|
||||||
|
if state.get("fail_updaters"):
|
||||||
|
sys.exit(1)
|
||||||
|
if kind == "npx":
|
||||||
|
for name in args[5:]:
|
||||||
|
state["skills"][name] = "new"
|
||||||
|
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:
|
||||||
|
sys.exit("unexpected updater: " + kind)
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
class RebuildUpdates(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
for tool in ("bash", "node"):
|
||||||
|
if shutil.which(tool) is None:
|
||||||
|
self.fail(f"Missing required test tool: {tool}")
|
||||||
|
self.scratch = tempfile.TemporaryDirectory(prefix=".rebuild-test-", dir=ROOT)
|
||||||
|
self.addCleanup(self.scratch.cleanup)
|
||||||
|
self.root = Path(self.scratch.name)
|
||||||
|
self.home = self.root / "home"
|
||||||
|
self.home.mkdir()
|
||||||
|
self.bin = self.root / "bin"
|
||||||
|
self.bin.mkdir()
|
||||||
|
for tool in ("dirname", "ln", "tr", "date", "mv"):
|
||||||
|
executable = shutil.which(tool)
|
||||||
|
self.assertIsNotNone(executable, f"Missing required test tool: {tool}")
|
||||||
|
(self.bin / tool).symlink_to(executable)
|
||||||
|
self.bash = shutil.which("bash")
|
||||||
|
self.env = {
|
||||||
|
"HOME": str(self.home),
|
||||||
|
"PATH": str(self.bin),
|
||||||
|
"BASH_ENV": str(self.root / "boundaries.bash"),
|
||||||
|
"TEST_ROOT": str(self.root),
|
||||||
|
"TEST_PYTHON": sys.executable,
|
||||||
|
"TEST_NODE": shutil.which("node"),
|
||||||
|
"TEST_DISPATCH": str(self.root / "dispatch.py"),
|
||||||
|
"TEST_NPM": "1",
|
||||||
|
"TEST_NPX": "1",
|
||||||
|
"TEST_MISSING_TOOLS": "0",
|
||||||
|
}
|
||||||
|
(self.root / "boundaries.bash").write_text(BOUNDARIES)
|
||||||
|
(self.root / "dispatch.py").write_text(DISPATCH)
|
||||||
|
direct = self.home / ".no-mistakes/bin/no-mistakes"
|
||||||
|
direct.parent.mkdir(parents=True)
|
||||||
|
direct.write_text(f'#!{self.bash}\nmock no-mistakes "$@"\n')
|
||||||
|
direct.chmod(0o755)
|
||||||
|
lock = self.home / ".agents/.skill-lock.json"
|
||||||
|
lock.parent.mkdir()
|
||||||
|
lock.write_text(json.dumps({"skills": {
|
||||||
|
"tdd": {}, "browser-harness": {}, "security-audit": {},
|
||||||
|
}}))
|
||||||
|
self.state = {
|
||||||
|
"packages": {name: "1.0.0" for name in GLOBALS + ACTIVATION_GLOBALS},
|
||||||
|
"skills": {name: "old" for name in (
|
||||||
|
"tdd", "browser-harness", "security-audit", "codebase-design",
|
||||||
|
)},
|
||||||
|
"components": {name: "old" for name in (
|
||||||
|
"no-mistakes", "hermes", "nix", "pi",
|
||||||
|
)},
|
||||||
|
}
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
(self.root / "state.json").write_text(json.dumps(self.state))
|
||||||
|
(self.root / "calls.jsonl").write_text("")
|
||||||
|
result = subprocess.run(
|
||||||
|
[self.bash, str(ROOT / "rebuild.sh")], env=self.env,
|
||||||
|
cwd=ROOT, text=True, capture_output=True, timeout=30,
|
||||||
|
)
|
||||||
|
self.assertEqual(result.returncode, self.state.get("switch_status", 0),
|
||||||
|
result.stdout + result.stderr)
|
||||||
|
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] == "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)
|
||||||
|
return result.stdout
|
||||||
|
|
||||||
|
def assert_update_order(self):
|
||||||
|
flake = ["nix", "flake", "update", "--flake", str(self.home / ".dotfiles")]
|
||||||
|
switch = ["sudo", "darwin-rebuild", "switch", "--flake",
|
||||||
|
str(self.home / ".dotfiles") + "#lt-mbp"]
|
||||||
|
skills = ["npx", "--yes", "skills@latest", "update", "-g", "-y",
|
||||||
|
"browser-harness", "tdd"]
|
||||||
|
pi = ["pi", "update", "--extensions", "--no-approve"]
|
||||||
|
self.assertIn(["no-mistakes", "update"], self.calls)
|
||||||
|
self.assertIn(["hermes", "update", "--yes"], self.calls)
|
||||||
|
self.assertLess(self.calls.index(flake), self.calls.index(switch))
|
||||||
|
self.assertLess(self.calls.index(switch), self.calls.index(skills))
|
||||||
|
self.assertLess(self.calls.index(skills), self.calls.index(pi))
|
||||||
|
|
||||||
|
def test_updates_installed_tools_and_preserves_frozen_skills(self):
|
||||||
|
self.execute()
|
||||||
|
self.assert_update_order()
|
||||||
|
for name in GLOBALS:
|
||||||
|
self.assertIn(["npm", "install", "-g", name + "@2.0.0"], self.calls)
|
||||||
|
self.assertEqual(self.state["packages"][name], "2.0.0")
|
||||||
|
for name in ACTIVATION_GLOBALS:
|
||||||
|
self.assertEqual(self.state["packages"][name], "1.0.0")
|
||||||
|
self.assertEqual(self.state["skills"], {
|
||||||
|
"browser-harness": "new", "tdd": "new",
|
||||||
|
"security-audit": "old", "codebase-design": "old",
|
||||||
|
})
|
||||||
|
self.assertTrue(all(version == "new" for version in
|
||||||
|
self.state["components"].values()))
|
||||||
|
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()
|
||||||
|
self.assertEqual(self.state["packages"], {})
|
||||||
|
self.assertFalse(any(call[:2] in (["npm", "install"], ["npm", "view"])
|
||||||
|
for call in self.calls))
|
||||||
|
self.assert_update_order()
|
||||||
|
|
||||||
|
def test_registry_and_install_failures_preserve_versions_and_continue(self):
|
||||||
|
self.state["fail_lookup"] = "@steipete/bird"
|
||||||
|
self.state["fail_install"] = "defuddle"
|
||||||
|
output = self.execute()
|
||||||
|
self.assertIn("WARNING:", output)
|
||||||
|
self.assertEqual(self.state["packages"]["@steipete/bird"], "1.0.0")
|
||||||
|
self.assertEqual(self.state["packages"]["defuddle"], "1.0.0")
|
||||||
|
self.assertEqual(self.state["packages"]["tasks-axi"], "2.0.0")
|
||||||
|
self.assert_update_order()
|
||||||
|
|
||||||
|
def test_bad_inventory_never_installs_packages(self):
|
||||||
|
self.state["bad_inventory"] = True
|
||||||
|
self.execute()
|
||||||
|
self.assertFalse(any(call[:2] == ["npm", "install"] for call in self.calls))
|
||||||
|
self.assert_update_order()
|
||||||
|
|
||||||
|
def test_updater_failures_do_not_abort_switch_or_later_updates(self):
|
||||||
|
self.state["fail_updaters"] = True
|
||||||
|
output = self.execute()
|
||||||
|
self.assert_update_order()
|
||||||
|
self.assertGreaterEqual(output.count("WARNING:"), 5)
|
||||||
|
self.assertTrue(all(version == "old" for version in
|
||||||
|
self.state["components"].values()))
|
||||||
|
self.assertTrue(all(version == "old" for version in self.state["skills"].values()))
|
||||||
|
|
||||||
|
def test_missing_tools_warn_and_still_switch(self):
|
||||||
|
self.env.update(TEST_NPM="0", TEST_NPX="0", TEST_MISSING_TOOLS="1")
|
||||||
|
(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", "brew", "brew", "sudo"])
|
||||||
|
|
||||||
|
def test_no_mistakes_path_fallback(self):
|
||||||
|
(self.home / ".no-mistakes/bin/no-mistakes").unlink()
|
||||||
|
self.execute()
|
||||||
|
self.assertEqual(self.calls.count(["no-mistakes", "update"]), 1)
|
||||||
|
|
||||||
|
def test_missing_empty_or_frozen_only_lock_never_updates_skills(self):
|
||||||
|
lock = self.home / ".agents/.skill-lock.json"
|
||||||
|
for skills in (None, {}, {"security-audit": {}}):
|
||||||
|
with self.subTest(skills=skills):
|
||||||
|
if skills is None:
|
||||||
|
lock.unlink()
|
||||||
|
else:
|
||||||
|
lock.write_text(json.dumps({"skills": skills}))
|
||||||
|
self.execute()
|
||||||
|
self.assertFalse(any(call[0] == "npx" for call in self.calls))
|
||||||
|
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"])
|
||||||
|
|
||||||
|
|
||||||
|
class ActivationToolFloor(unittest.TestCase):
|
||||||
|
"""The generated activation installs the floor without downgrading newer tools."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
expression = '''
|
||||||
|
(builtins.getFlake (toString ./.)).darwinConfigurations."lt-mbp"
|
||||||
|
.config.home-manager.users.laptran.home.activation.axiTools.data
|
||||||
|
'''
|
||||||
|
result = subprocess.run(
|
||||||
|
["nix", "eval", "--raw", "--impure", "--expr", expression],
|
||||||
|
cwd=ROOT, text=True, capture_output=True, timeout=120,
|
||||||
|
)
|
||||||
|
if result.returncode:
|
||||||
|
raise AssertionError(result.stderr)
|
||||||
|
cls.activation = result.stdout
|
||||||
|
|
||||||
|
def test_missing_old_current_and_newer_tasks_versions(self):
|
||||||
|
# Independent oracle: firstmate requires 0.2.6. A rebuild must retain
|
||||||
|
# a newer installed release instead of restoring that minimum.
|
||||||
|
boundaries = r'''
|
||||||
|
function /opt/homebrew/bin/npm { printf '%s\n' "$*" >> "$TEST_CALLS"; }
|
||||||
|
function [ {
|
||||||
|
if [[ $1 == -x && $2 == /opt/homebrew/bin/* ]]; then return 0; fi
|
||||||
|
builtin [ "$@"
|
||||||
|
}
|
||||||
|
tasks-axi() {
|
||||||
|
if [[ -z $TEST_HAVE ]]; then return 127; fi
|
||||||
|
printf '%s\n' "$TEST_HAVE"
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory(prefix=".activation-test-", dir=ROOT) as scratch:
|
||||||
|
root = Path(scratch)
|
||||||
|
script = root / "activation.sh"
|
||||||
|
script.write_text(boundaries + self.activation)
|
||||||
|
calls = root / "calls"
|
||||||
|
for have, installs in (
|
||||||
|
("", ["install -g tasks-axi@0.2.6"]),
|
||||||
|
("0.2.5", ["install -g tasks-axi@0.2.6"]),
|
||||||
|
("0.2.6", []),
|
||||||
|
("2.0.0", []),
|
||||||
|
):
|
||||||
|
with self.subTest(installed=have or "absent"):
|
||||||
|
calls.write_text("")
|
||||||
|
env = {"HOME": str(root), "PATH": "/usr/bin:/bin",
|
||||||
|
"TEST_HAVE": have, "TEST_CALLS": str(calls)}
|
||||||
|
result = subprocess.run(
|
||||||
|
[shutil.which("bash"), str(script)], cwd=ROOT, env=env,
|
||||||
|
text=True, capture_output=True, timeout=30,
|
||||||
|
)
|
||||||
|
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||||
|
self.assertEqual(calls.read_text().splitlines(), installs)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||||
|
exec python3 "$ROOT/tests/rebuild-update-steps.py"
|
||||||
+7
-2
@@ -2,8 +2,9 @@
|
|||||||
# Run the dotfiles configuration checks that need the live machine.
|
# Run the dotfiles configuration checks that need the live machine.
|
||||||
#
|
#
|
||||||
# The launcher check builds the zshrc from the home-manager configuration and
|
# The launcher check builds the zshrc from the home-manager configuration and
|
||||||
# runs `fm` with spies. The dispatch check reads the crew dispatch config through
|
# runs `fm`, `fm-oc2`, and `fm-pi` with spies. The dispatch check reads the crew
|
||||||
# firstmate's bootstrap validator. Neither starts a real agent session.
|
# dispatch config through firstmate's bootstrap validator. Neither starts a real
|
||||||
|
# agent session. The bird check runs the Brave-only wrapper in a throwaway HOME.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||||
@@ -11,5 +12,9 @@ status=0
|
|||||||
|
|
||||||
"$ROOT/tests/fm-launcher.sh" || status=1
|
"$ROOT/tests/fm-launcher.sh" || status=1
|
||||||
"$ROOT/tests/crew-dispatch.sh" || status=1
|
"$ROOT/tests/crew-dispatch.sh" || status=1
|
||||||
|
"$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"
|
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