@@ -7,6 +7,7 @@
77# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
88# and runs the self-test. Safe to re-run.
99set -euo pipefail
10+trap 'echo "Diagonal host install failed at line $LINENO: $BASH_COMMAND" >&2' ERR
1011HERE="$(cd "$(dirname "$0")" && pwd)"
1112if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
1213
@@ -45,10 +46,24 @@ xattr -dr com.apple.quarantine "$SHARE" 2>/dev/null || true
4546ln -sf "$SHARE/diagonal-host.py" "$BIN"
4647echo "host: $BIN -> $SHARE/diagonal-host.py"
4748
49+# Written here rather than by the host, so a python3 problem cannot leave an empty manifest behind,
50+# and moved into place so Brave never reads a half-written one.
51+MANIFEST=$(cat <<JSON
52+{
53+ "name": "io.diagonal.host",
54+ "description": "Diagonal: names tab groups with Apple's on-device model",
55+ "path": "$BIN",
56+ "type": "stdio",
57+ "allowed_origins": ["chrome-extension://$ID/"]
58+}
59+JSON
60+)
61+"$BIN" --version >/dev/null # the host must start with the python3 it was pinned to
4862for ch in "${CHANNELS[@]}"; do
4963 DIR="$HOME/Library/Application Support/BraveSoftware/$ch/NativeMessagingHosts"
5064 mkdir -p "$DIR"
51− "$BIN" --print-manifest "$BIN" > "$DIR/io.diagonal.host.json"
65+ printf '%s\n' "$MANIFEST" > "$DIR/io.diagonal.host.json.tmp"
66+ mv -f "$DIR/io.diagonal.host.json.tmp" "$DIR/io.diagonal.host.json"
5267 echo "manifest: $DIR/io.diagonal.host.json"
5368done
5469