Files
socialmag/launch-brave.sh
T
juxtapoandClaude Opus 5 01fae3ca74 v0.7: one-click install — pyproject, console scripts, user units, hermes wiring
A clone + ./install.sh + ./launch-brave.sh + sign in once. Nothing else.

pyproject.toml declares the one real dependency (websockets) and maps the
repo-root-is-the-package layout, which retires the PYTHONPATH=<parent> line
every unit used to carry.

cli.py backs three console scripts. They exist because `python3 -m socialmag`
run from INSIDE a clone dies at `import asyncio`: the repo root is the package
dir, so it ships selectors.py and queue.py, and python puts the current
directory first on sys.path. `cd socialmag` is the first thing anyone does
after a clone, so the documented workaround failed at exactly the moment it
would be tried. A generated bin/ script never puts cwd on sys.path.

The same trap bit `python3 -m venv` inside install.sh — the installer was
broken by the thing it exists to fix. Every python3 call now runs from /.

deploy/user/*.in replaces root system units with systemd --user templates:
no User=, WantedBy=default.target, venv paths, @REPO@/@VENV@/@CDP_ENDPOINT@
substituted at install time. deploy/home/ is untouched and still live here.

launch-brave.sh carries --disable-background-timer-throttling. That is
load-bearing, not tidiness: five of six platforms are read in a hidden tab, and
a throttled background tab stops running the timers those pages use to fetch
their own data — the reads come back empty with no error.

install.sh checks the mcp package in hermes's own interpreter and refuses to
continue without it. Hermes treats mcp as optional and silently no-ops the
whole subsystem when it is missing, so a server that never loaded looks exactly
like one that loaded and did nothing.

It will not merge into an existing mcp_servers: key — it backs up config.yaml
and appends only when the key is absent, otherwise it prints the block. Blind
YAML merging is how someone's other servers disappear.

Verified end-to-end in a sandbox with a fake HOME and stubbed systemctl:
real MCP initialize handshake from inside the repo dir returns all 7 tools;
hermes's own yaml parser re-reads the written config with every pre-existing
key intact; a second run leaves the mcp_servers key count at 1; launch-brave.sh
exits 1 against a busy port; no unsubstituted @PLACEHOLDER@ in any rendered unit.

Not fixed, pre-existing: server.py reports SERVER_VERSION 0.1.0 while the repo
is at v0.7. The handshake shows 0.1.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-13 02:10:58 +08:00

55 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Launch Brave with the debugging port socialmag talks to.
#
# socialmag never holds a password. It drives a browser that is already signed
# in as you, which means there has to be a browser, listening, with your
# sessions in it. This script is that browser.
#
# Sign in to your platforms once in the window this opens. The profile is
# separate from your everyday Brave on purpose: socialmag navigates tabs and
# clicks things, and it should not be doing that in the window you are reading
# in.
set -euo pipefail
PORT="${SOCIALMAG_CDP_PORT:-9336}"
PROFILE="${SOCIALMAG_BRAVE_PROFILE:-$HOME/.local/share/brave-socialmag}"
BRAVE=""
for candidate in brave brave-browser brave-browser-stable; do
if command -v "$candidate" >/dev/null 2>&1; then
BRAVE="$(command -v "$candidate")"
break
fi
done
if [[ -z "$BRAVE" ]]; then
echo "error: no brave binary found on PATH" >&2
echo " looked for: brave, brave-browser, brave-browser-stable" >&2
echo " install Brave, or set BRAVE=/path/to/brave and re-run" >&2
exit 1
fi
if curl -sf --max-time 2 "http://127.0.0.1:${PORT}/json/version" >/dev/null 2>&1; then
echo "error: something is already listening on 127.0.0.1:${PORT}" >&2
echo " socialmag would drive that browser, not the one this script opens." >&2
echo " close it first, or set SOCIALMAG_CDP_PORT to a free port." >&2
exit 1
fi
mkdir -p "$PROFILE"
echo "brave : $BRAVE"
echo "profile : $PROFILE"
echo "cdp : http://127.0.0.1:${PORT}"
echo
# --disable-background-timer-throttling is load-bearing, not tidiness. socialmag
# reads five of six platforms in a HIDDEN tab so it never steals your focus. A
# throttled background tab stops running the timers those pages use to fetch
# their own data, and the reads come back empty with no error.
exec "$BRAVE" \
--remote-debugging-port="$PORT" \
--user-data-dir="$PROFILE" \
--disable-background-timer-throttling \
"$@"