diff --git a/bin/mcp-lapis b/bin/mcp-lapis index dd71946..9ba7d06 100755 --- a/bin/mcp-lapis +++ b/bin/mcp-lapis @@ -20,11 +20,30 @@ node_bin() { return 1 } -if [ -f "$LAPIS/memory-store.js" ]; then +# One store, one host. The store lives on arceus; a host that merely has the +# checkout is a client. Without this, a fresh clone on a client host silently +# forks the memory: the wrapper would start writing to an empty local DB while +# every memory already made on arceus became invisible to that host. +# +# Set LAPIS_FORCE_REMOTE=1, or drop the remote's "user@host" into +# ~/.pi/memory/REMOTE_STORE, to force the bridge. Both are host-local: they +# never travel with dotfiles, so the host holding the store is unaffected. +FORCE_REMOTE=${LAPIS_FORCE_REMOTE:-0} +if [ -f "$HOME/.pi/memory/REMOTE_STORE" ]; then + FORCE_REMOTE=1 + STORE_HOST=$(tr -d ' \n' < "$HOME/.pi/memory/REMOTE_STORE") + [ -n "$STORE_HOST" ] && LAPIS_REMOTE="$STORE_HOST" +fi + +if [ "$FORCE_REMOTE" != 1 ] && [ -f "$LAPIS/memory-store.js" ]; then NODE=$(node_bin) || { echo "mcp-lapis: no node found for the local LaPis store" >&2; exit 1; } exec "$NODE" "$LAPIS/memory-store.js" mcp fi +if [ "$FORCE_REMOTE" = 1 ]; then + echo "mcp-lapis: using the shared store on ${LAPIS_REMOTE:-ziadarafat@10.0.0.23}" >&2 +fi + # No local store: bridge to the host that has one. LAPIS_REMOTE defaults to the # personal homelab host; keep it a plain "user@host" so ProxyJump/ssh config apply. REMOTE="${LAPIS_REMOTE:-ziadarafat@10.0.0.23}"