Files
persistent-chat-plugin/scripts/co-integration/sync_pchat_runtime.sh
卡若AI ec540f6625 feat: 根目录 AI 安装指引 AGENTS.md + install.sh 一键安装
AI 先读 AGENTS.md 自主完成安装/排错;install.sh 同步 Hub、部署 MCP、冒烟验收。
修复 sync_pchat_runtime 使用本仓库 lib/src/web 结构。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 18:00:46 +08:00

31 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# 将本仓库源码同步到 ~/.persistent-chat-local 并重启 Hub
set -euo pipefail
REPO="$(cd "$(dirname "$0")/../.." && pwd)"
DST="$HOME/.persistent-chat-local"
PORT="${PCHAT_HTTP_PORT:-13458}"
NODE="${PCHAT_NODE:-$(command -v node)}"
mkdir -p "$DST/lib" "$DST/logs"
rsync -a --delete "$REPO/lib/" "$DST/lib/"
cp -f "$REPO/src/hub.js" "$DST/hub.js"
cp -f "$REPO/src/server.js" "$DST/server.js"
cp -f "$REPO/src/cursor-title.js" "$DST/cursor-title.js" 2>/dev/null || true
cp -f "$REPO/scripts/ensure-hub.sh" "$DST/ensure-hub.sh"
cp -f "$REPO/scripts/mongo_sync.py" "$DST/mongo_sync.py" 2>/dev/null || true
cp -f "$REPO/web/panel.html" "$DST/panel.html"
cp -f "$REPO/web/panel-enhance.html" "$DST/panel-enhance.html" 2>/dev/null || \
cp -f "$REPO/web/panel.html" "$DST/panel-enhance.html"
chmod +x "$DST/ensure-hub.sh" 2>/dev/null || true
if lsof -ti ":$PORT" >/dev/null 2>&1; then
lsof -ti ":$PORT" | xargs kill 2>/dev/null || true
sleep 1
fi
nohup "$NODE" "$DST/hub.js" >> "$DST/logs/hub.stdout.log" 2>&1 &
for i in $(seq 1 40); do
curl -sf -m 2 "http://127.0.0.1:$PORT/api/health" >/dev/null && break
sleep 0.2
done
echo "sync ok → http://127.0.0.1:$PORT/enhance"