Phase 0: turn Supermarket into a Dockerized local web app
Replace the old Go TUI with a web app (port 8470) that runs in a container as a CoreDesktop sibling: - cmd/supermarket server with htmx web UI: dashboard, company profile, inventory (partners/competitors), AI and credential settings, and a Core & Hermes page - SQLite storage and a secrets store under ~/.local/share/supermarket - AI providers (Anthropic, OpenAI-compatible) behind one interface - MCP server and a Hermes bridge to the Federated Core MCP hub - Import of the old Coremarketing TUI's state - install.sh / update.sh / lib.sh, Dockerfile, compose.yaml, the bin/supermarket launcher and hermes/setup.sh Posting is not wired back up yet; that comes in Phase 1. See PLAN.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+57
-45
@@ -1,57 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
#!/bin/bash
|
||||
#
|
||||
# Purpose : Install Supermarket (run by CoreDesktop's `sibling add`). Safe to
|
||||
# run again: it only does what's missing.
|
||||
|
||||
BINARY="coremarketing"
|
||||
INSTALL_DIR="$HOME/.local/bin"
|
||||
set -e
|
||||
|
||||
# Find Go — check common locations if not in PATH
|
||||
GO=$(command -v go 2>/dev/null || echo "")
|
||||
for candidate in /run/host/usr/lib/go/bin/go /usr/local/go/bin/go; do
|
||||
if [[ -z "$GO" && -x "$candidate" ]]; then
|
||||
GO="$candidate"
|
||||
fi
|
||||
done
|
||||
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=lib.sh
|
||||
source "$SELF/lib.sh"
|
||||
|
||||
if [[ -z "$GO" ]]; then
|
||||
echo "Error: Go not found. Install Go from https://go.dev/dl/" >&2
|
||||
exit 1
|
||||
echo "Installing Supermarket, a marketing suite that runs as a web app on this computer."
|
||||
|
||||
if ! command -v docker > /dev/null; then
|
||||
echo "Supermarket needs Docker, which CoreDesktop installs. Install it with: sudo pacman -S docker docker-compose"
|
||||
exit 1
|
||||
fi
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
if ! id -nG | tr ' ' '\n' | grep -qx docker; then
|
||||
echo "You can't use Docker yet. Add yourself to the docker group, log out and in, and run this again:"
|
||||
echo " sudo usermod -aG docker \$USER"
|
||||
else
|
||||
echo "Docker isn't running. Start it and run this again: sudo systemctl enable --now docker"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Using Go: $GO ($($GO version))"
|
||||
mkdir -p "$DATA"
|
||||
chmod 700 "$DATA"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
echo "Building $BINARY..."
|
||||
"$GO" build -o "$BINARY" .
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
mv "$BINARY" "$INSTALL_DIR/$BINARY"
|
||||
|
||||
CONFIG_DIR="$HOME/.local/state/coremarketing"
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
if [[ -d "$CONFIG_DIR" ]] && compgen -G "$CONFIG_DIR/*" > /dev/null 2>&1; then
|
||||
read -r -p "Delete all files in $CONFIG_DIR? [y/N] " answer
|
||||
if [[ "${answer,,}" == "y" ]]; then
|
||||
rm -rf "${CONFIG_DIR:?}"/*
|
||||
echo "Cleared: $CONFIG_DIR"
|
||||
fi
|
||||
# The old terminal app's files: copied (never moved) to import/, which the app
|
||||
# reads once on its first start.
|
||||
if [ -f "$OLD_STATE/config.yaml" ] && [ ! -d "$DATA/import" ]; then
|
||||
mkdir -m 700 "$DATA/import"
|
||||
for f in config.yaml state.json posts.json dismissed.json; do
|
||||
[ -f "$OLD_STATE/$f" ] && install -m 600 "$OLD_STATE/$f" "$DATA/import/$f"
|
||||
done
|
||||
echo "Found the old Coremarketing's settings in $OLD_STATE: its inventory, credentials and queued posts will be imported."
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CONFIG_DIR/config.yaml" ]]; then
|
||||
cp "$SCRIPT_DIR/config.example.yaml" "$CONFIG_DIR/config.yaml"
|
||||
chmod 600 "$CONFIG_DIR/config.yaml"
|
||||
echo "Config installed: $CONFIG_DIR/config.yaml — fill in your credentials there"
|
||||
else
|
||||
echo "Config already exists, skipping: $CONFIG_DIR/config.yaml"
|
||||
# The token agents use to reach the app. Made here, before the app starts,
|
||||
# so Hermes can be given it.
|
||||
if [ ! -s "$DATA/mcp-token" ]; then
|
||||
(umask 077 && od -An -tx1 -N32 /dev/urandom | tr -d ' \n' > "$DATA/mcp-token" && echo >> "$DATA/mcp-token")
|
||||
fi
|
||||
|
||||
echo "Installed: $INSTALL_DIR/$BINARY"
|
||||
bash "$SELF/update.sh"
|
||||
|
||||
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
|
||||
echo ""
|
||||
echo "Note: $INSTALL_DIR is not in your PATH."
|
||||
echo "Add this to your shell config (~/.bashrc or ~/.zshrc):"
|
||||
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
|
||||
if command -v webapp > /dev/null; then
|
||||
if [ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/applications/webapp-supermarket.desktop" ]; then
|
||||
webapp add Supermarket "$URL" && echo "Added Supermarket to the app grid."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
bash "$SELF/hermes/setup.sh" || echo "Hermes setup didn't finish; run it again any time: bash $SELF/hermes/setup.sh"
|
||||
|
||||
if command -v claude > /dev/null && ! claude mcp get supermarket > /dev/null 2>&1; then
|
||||
echo
|
||||
if confirm_yes "Let Claude Code use Supermarket's tools (profile, inventory) too?"; then
|
||||
claude mcp add --transport http --scope user supermarket "$URL/mcp" \
|
||||
--header "Authorization: Bearer $(tr -d '\n' < "$DATA/mcp-token")" > /dev/null \
|
||||
&& echo "Claude Code can use Supermarket (claude mcp get supermarket)."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Supermarket is installed. Open it from the app grid, or at $URL"
|
||||
echo "Start with the company profile, then Settings > AI provider."
|
||||
|
||||
Reference in New Issue
Block a user