- src/: server.js (MCP 4 工具) + hub.js (HTTP Hub) + cursor-title.js - web/: panel.html (主面板) + panel.remote.html (远端 1637) - scripts/: ensure-hub.sh (stdio→http 桥) + mongo_sync.py - mcp-config/: trae.mcp.json + cursor.mcp.json - docs/: INSTALL / DEPLOY / MCP_SETUP / ARCHITECTURE / QUICKSTART - ZIP 原始安装包备查 关键机制: - 4 MCP 工具:init / select / wait / merge - 垂直绑定:workspace::cursorTitle@hostIp 三件指纹 - 真挂起:关闭 timedReply 后 wait 真正阻塞,agent turn 不结束 - 双 Hub 部署:远端 NAS 24×7 + 本地 launchd 守护备份 - 三形态组合:远端 + 本地 + Trae 插件,可同时跑
190 lines
4.1 KiB
Markdown
190 lines
4.1 KiB
Markdown
# 安装文档(INSTALL.md)
|
||
|
||
> 完整安装步骤 · 三种形态
|
||
|
||
---
|
||
|
||
## 前置条件
|
||
|
||
| 项 | 要求 | 验证 |
|
||
|:---|:---|:---|
|
||
| macOS | 13+ | `sw_vers` |
|
||
| Node | v22 | `node --version` |
|
||
| Git | 2.30+ | `git --version` |
|
||
| 网络 | 能访问 192.168.110.101 | `ping -c1 192.168.110.101` |
|
||
|
||
---
|
||
|
||
## 安装形态 A:远端 NAS(公司 13458)
|
||
|
||
### 步骤 1:准备目录
|
||
|
||
```bash
|
||
ssh fnvtk@192.168.110.101
|
||
mkdir -p /volume1/homes/fnvtk/.persistent-chat-local
|
||
cd /volume1/homes/fnvtk/.persistent-chat-local
|
||
```
|
||
|
||
### 步骤 2:上传文件
|
||
|
||
从本地 git 仓库:
|
||
|
||
```bash
|
||
# 本地
|
||
scp src/{server.js,hub.js,cursor-title.js} \
|
||
web/panel.html \
|
||
scripts/{ensure-hub.sh,mongo_sync.py} \
|
||
fnvtk@192.168.110.101:/volume1/homes/fnvtk/.persistent-chat-local/
|
||
```
|
||
|
||
### 步骤 3:安装依赖
|
||
|
||
无第三方依赖(纯 Node 22 标准库)。
|
||
|
||
### 步骤 4:启动
|
||
|
||
```bash
|
||
# 远端
|
||
ssh fnvtk@192.168.110.101
|
||
cd /volume1/homes/fnvtk/.persistent-chat-local
|
||
chmod +x ensure-hub.sh
|
||
nohup /usr/local/opt/node@22/bin/node hub.js > logs/hub.log 2>&1 &
|
||
```
|
||
|
||
### 步骤 5:验证
|
||
|
||
```bash
|
||
curl http://192.168.110.101:13458/api/health
|
||
# 期望:{"ok":true,"pid":<X>,"panelVersion":"1.6.37"}
|
||
```
|
||
|
||
---
|
||
|
||
## 安装形态 B:本地备份(launchd)
|
||
|
||
### 步骤 1:建目录
|
||
|
||
```bash
|
||
mkdir -p ~/.persistent-chat-local
|
||
```
|
||
|
||
### 步骤 2:拷文件
|
||
|
||
```bash
|
||
cp src/server.js src/hub.js src/cursor-title.js ~/.persistent-chat-local/
|
||
cp web/panel.html ~/.persistent-chat-local/panel.html
|
||
cp scripts/ensure-hub.sh ~/.persistent-chat-local/
|
||
chmod +x ~/.persistent-chat-local/ensure-hub.sh
|
||
```
|
||
|
||
### 步骤 3:写 launchd plist
|
||
|
||
```bash
|
||
cat > ~/Library/LaunchAgents/com.karuo.persistent-chat-hub.plist <<'EOF'
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||
<plist version="1.0">
|
||
<dict>
|
||
<key>Label</key><string>com.karuo.persistent-chat-hub</string>
|
||
<key>ProgramArguments</key>
|
||
<array>
|
||
<string>/usr/local/opt/node@22/bin/node</string>
|
||
<string>/Users/karuo/.persistent-chat-local/hub.js</string>
|
||
</array>
|
||
<key>WorkingDirectory</key><string>/Users/karuo/.persistent-chat-local</string>
|
||
<key>RunAtLoad</key><true/>
|
||
<key>KeepAlive</key><true/>
|
||
<key>StandardOutPath</key><string>/Users/karuo/.persistent-chat-local/logs/launchd.log</string>
|
||
<key>StandardErrorPath</key><string>/Users/karuo/.persistent-chat-local/logs/launchd.err</string>
|
||
</dict>
|
||
</plist>
|
||
EOF
|
||
```
|
||
|
||
### 步骤 4:加载
|
||
|
||
```bash
|
||
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.karuo.persistent-chat-hub.plist
|
||
```
|
||
|
||
### 步骤 5:验证
|
||
|
||
```bash
|
||
launchctl print gui/$UID/com.karuo.persistent-chat-hub | head -5
|
||
curl http://127.0.0.1:13458/api/health
|
||
```
|
||
|
||
---
|
||
|
||
## 安装形态 C:Trae/Cursor MCP 插件
|
||
|
||
### 步骤 1:复制 mcp.json
|
||
|
||
```bash
|
||
# Trae
|
||
cp mcp-config/trae.mcp.json ~/.trae/mcp.json
|
||
|
||
# Cursor
|
||
cp mcp-config/cursor.mcp.json ~/Documents/个人/.cursor/mcp.json
|
||
```
|
||
|
||
### 步骤 2:完全退出 IDE
|
||
|
||
- Trae: `Cmd+Q`
|
||
- Cursor: `Cmd+Q`
|
||
|
||
### 步骤 3:重开 IDE
|
||
|
||
### 步骤 4:验证
|
||
|
||
在 Trae / Cursor 看到 `persistent-chat` MCP server 绿色点。
|
||
|
||
---
|
||
|
||
## 升级
|
||
|
||
```bash
|
||
# 1. 拉新代码
|
||
cd /Users/karuo/Documents/个人/persistent-chat-plugin
|
||
git pull
|
||
|
||
# 2. 备份
|
||
cp -r ~/.persistent-chat-local ~/.persistent-chat-local.bak.$(date +%Y%m%d)
|
||
|
||
# 3. 覆盖核心(不动 data/)
|
||
cp src/* ~/.persistent-chat-local/
|
||
cp web/panel.html ~/.persistent-chat-local/
|
||
|
||
# 4. 重启 Hub
|
||
launchctl bootout gui/$UID/com.karuo.persistent-chat-hub
|
||
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.karuo.persistent-chat-hub.plist
|
||
|
||
# 5. Trae Cmd+Q 重开
|
||
```
|
||
|
||
---
|
||
|
||
## 卸载
|
||
|
||
```bash
|
||
# 1. 停止 launchd
|
||
launchctl bootout gui/$UID/com.karuo.persistent-chat-hub
|
||
|
||
# 2. 删除文件
|
||
rm -rf ~/.persistent-chat-local
|
||
rm ~/Library/LaunchAgents/com.karuo.persistent-chat-hub.plist
|
||
|
||
# 3. 删除 MCP 配置
|
||
# Trae: 编辑 ~/.trae/mcp.json 删 persistent-chat 段
|
||
# Cursor: 编辑 ~/Documents/个人/.cursor/mcp.json 删 persistent-chat 段
|
||
|
||
# 4. 远端 NAS
|
||
ssh fnvtk@192.168.110.101
|
||
pkill -f "node hub.js"
|
||
# 不删数据可保留 ~/.persistent-chat-local 目录
|
||
```
|
||
|
||
---
|
||
|
||
> 最后更新:2026-06-26 · 卡若AI
|