#!/bin/sh # Oikos-plugins deploy script — triggered by Gitea webhook on push to dtoro/oikos-plugins. # Runs on mac-mini via launchd unit running cmd/webhook (route: /deploy-plugins). set -e REPO_DIR="${REPO_DIR:-$HOME/Projects/oikos}" PLUGIN_DIR="${PLUGIN_DIR:-$HOME/oikos-plugins}" DSH_DIR="${DSH_DIR:-$HOME/Projects/deepseek-harness}" PROFILE_DIR="${PROFILE_DIR:-$HOME/.dsh/profiles/web}" PORT="${PORT:-3080}" LOCKDIR="${LOCKDIR:-/tmp/oikos-plugins-deploy.lock}" acquire_lock() { if mkdir "$LOCKDIR" 2>/dev/null; then trap 'rm -rf "$LOCKDIR"' EXIT return 0 fi echo "deploy already running, skipping" exit 0 } acquire_lock echo "=== oikos-plugins deploy started ===" # 1. Pull latest if [ ! -d "$PLUGIN_DIR" ]; then git clone gitea@git-ssh.hubris.network:dtoro/oikos-plugins.git "$PLUGIN_DIR" fi cd "$PLUGIN_DIR" git fetch origin master git reset --hard origin/master # 2. Symlink packages into dsh profile for pkg in ui mcp-scope session-summary bundle evals; do name=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$pkg/package.json')).name)") ln -sf "$PLUGIN_DIR/$pkg" "$PROFILE_DIR/node_modules/$name" echo "linked $name" done # 3. Build UI client bundle (needs dsh workspace for tsdown) cd "$DSH_DIR" pnpm install --filter @deepseek-ai/dsh-oikos-ui --frozen-lockfile 2>&1 cd "$PLUGIN_DIR/ui" DSH_BUILD_FACE=client npx tsdown --config tsdown.config.ts 2>&1 echo "UI bundle built" # 4. Restart dsh DASHBOARD_PID=$(pgrep -f 'dsh.*--port.*3080' 2>/dev/null || true) if [ -n "$DASHBOARD_PID" ]; then kill "$DASHBOARD_PID" 2>/dev/null || true sleep 2 fi cd "$DSH_DIR" nohup pnpm dsh --profile web --patch /tmp/oikos-mcp-patch.yml --port "$PORT" > /tmp/dsh-web.log 2>&1 & echo "dsh restarted (pid $!)" echo "=== oikos-plugins deploy complete ==="