Files
persistent-chat-plugin/install.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

77 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Persistent Chat 一键安装Gitea 仓库根目录)
# 用法: bash install.sh [工作区路径]
set -euo pipefail
REPO="$(cd "$(dirname "$0")" && pwd)"
WS="${1:-$PWD}"
HUB="${PCHAT_HUB_URL:-http://127.0.0.1:13458}"
echo "╔══════════════════════════════════════════╗"
echo "║ Persistent Chat · 一键安装 ║"
echo "╚══════════════════════════════════════════╝"
echo "仓库: $REPO"
echo "工作区: $WS"
echo ""
# Phase 0: 前置
if ! command -v node >/dev/null 2>&1; then
echo "❌ 需要 Node.js 18+"; exit 1
fi
if [[ "$(uname)" != "Darwin" ]]; then
echo "⚠️ 当前脚本针对 macOS 优化;其他系统部分步骤需人工调整"
fi
# Phase 1: 运行时 Hub
echo "▶ [1/5] 同步 Hub 到 ~/.persistent-chat-local …"
bash "$REPO/scripts/co-integration/sync_pchat_runtime.sh"
# Phase 2: Cursor MCP + rules
echo "▶ [2/5] 部署 Cursor 配置pchat 唯一套)…"
bash "$REPO/cursor-config/deploy-cursor-config.sh" "$WS"
# Phase 3: 退役 co-chat 规则(扩展若存在则提示)
if ls "$HOME/.cursor/extensions"/co-chat.co-chat-panel-* >/dev/null 2>&1; then
echo "▶ [3/5] 检测到 co-chat 扩展,执行退役 …"
if [[ -f "$REPO/scripts/co-integration/retire_cochat.sh" ]]; then
bash "$REPO/scripts/co-integration/retire_cochat.sh" || echo "⚠️ 退役需 W2/W6/W8 门禁;可稍后在 Hub /enhance 完成后再跑"
fi
else
echo "▶ [3/5] co-chat 扩展未安装,跳过退役"
bash "$REPO/scripts/co-integration/pchat_retire_co_rule.sh" "$WS" 2>/dev/null || true
fi
# Phase 4: 冒烟
echo "▶ [4/5] 冒烟测试 …"
export PCHAT_HUB_URL="$HUB"
if bash "$REPO/scripts/co-integration/pchat_smoke_test.sh"; then
echo "✅ 冒烟 fail=0"
else
echo "❌ 冒烟失败AI 请读 AGENTS.md §排错"
exit 1
fi
# Phase 5: 增强门禁摘要
echo "▶ [5/5] 增强门禁 …"
curl -sf "$HUB/api/enhance/diagnose" 2>/dev/null | python3 -c "
import sys, json
try:
j=json.load(sys.stdin)
r=j.get('report',j)
s=r.get('state',{})
gp=r.get('gatesPass', False)
print(f' gatesPass={gp} permOk={s.get(\"permOk\")} cursorPrefOk={s.get(\"cursorPrefOk\")} patchNativeOk={s.get(\"patchNativeOk\")}')
if not gp:
print(' → 打开 $HUB/enhance 完成 W2/W6 并开启增强包,点「诊断」')
except Exception as e:
print(' (diagnose 暂不可用)', e)
" || true
echo ""
echo "══════════════════════════════════════════"
echo "✅ 安装完成"
echo " Hub: $HUB"
echo " 增强: $HUB/enhance"
echo " 下一步: Cmd+Q 重启 Cursor → 新建 Chat 测 wait 续跑"
echo " AI指引: 读本仓库 AGENTS.md"
echo "══════════════════════════════════════════"