Files
persistent-chat-plugin/README.md
卡若AI ba786b3700 feat: Persistent Chat v1.1 CO-Chat 整合上传 Gitea
同步 enhance/bridge/smoke/retire 模块、vendor 3.3.34、增强面板与 PRD 文档,
Hub 接入 hub-routes-prd,含安装/经验/模块说明与 co-integration 运维脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 17:42:16 +08:00

170 lines
5.9 KiB
Markdown
Raw 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.

# Cursor/Trae 持久对话 MCP 插件 v1.6.37
> **垂直绑定 · 真挂起 · 永不断开**
> 一个让 Cursor / Trae / VSCode 与 Agent 之间实现"可持续对话"的 MCP 插件。
[![Gitea](https://img.shields.io/badge/Gitea-fnvtK%2Fpersistent--chat--plugin-blue)](http://192.168.110.101:3000/fnvtk/persistent-chat-plugin)
[![Version](https://img.shields.io/badge/Version-v1.1--CO--integration-green)](#)
[![MCP](https://img.shields.io/badge/MCP-4--tools-orange)](#)
[![Hub](https://img.shields.io/badge/Hub-192.168.110.101%3A13458-purple)](#)
---
## 🎯 一句话描述
普通 MCP 调一次就结束对话;本插件用 **4 个工具 + Hub 长连接**,让 agent 与用户的对话**永不中断**,适合长跑学习清单 / 跨天多计划 / 自动续跑任务。
---
## 📦 仓库内容
```
persistent-chat-plugin/
├── lib/ # CO-Chat 整合模块enhance/bridge/smoke/retire
├── vendor/ # cochat-engine 3.3.34(无卡密补丁引擎)
├── docs/prd/ # PRD + 安装说明 + 经验汇总 + 模块说明
├── scripts/co-integration/ # 冒烟 / 同步 / 退役脚本
│ ├── server.js (42KB) # MCP Server 端4 个工具入口
│ ├── hub.js (89KB) # Hub 主服务HTTP + WebSocket
│ └── cursor-title.js (4KB) # Cursor 标题解析器
├── web/ # 持久对话面板(浏览器 UI
│ ├── panel.html (84KB) # 主面板 v1.6.37
│ ├── panel.remote.html # 远端 NAS 面板panel_remote_v1637
│ └── panel.html.local # 本地备份面板
├── scripts/ # 部署与运维脚本
│ ├── ensure-hub.sh # 启动器MCP stdio → http
│ ├── mongo_sync.py # 会话 → MongoDB 同步
│ └── (deploy scripts...)
├── mcp-config/ # MCP 配置模板
│ ├── trae.mcp.json # Trae CN 配法
│ └── cursor.mcp.json # Cursor 配法
├── docs/ # 完整文档
│ ├── INSTALL.md # 安装
│ ├── DEPLOY.md # 部署
│ ├── MCP_SETUP.md # MCP 配置
│ ├── ARCHITECTURE.md # 架构
│ └── QUICKSTART.md # 5 分钟上手
├── Cursor持久对话-安装包-v1.6.37_20260607.zip # 原始安装包(备查)
└── README.md # 本文件
```
---
## ⚡ 三种部署形态
| 形态 | 端口 | 适用 | 关键 |
|:---|:---|:---|:---|
| **本地备份** | 127.0.0.1:13458 | 单机 | launchd 守护,挂了自动起 |
| **远端 NAS** | 192.168.110.101:13458 | 多人 / 跨机 | Node 守护,跨网段访问 |
| **Trae 插件** | MCP stdio | 与 IDE 集成 | ensure-hub.sh 起 4 工具 |
可同时跑,三者共享同一 Hub 协议。
---
## 🔧 MCP 工具
| # | 工具 | 用途 |
|:---:|:---|:---|
| 1 | `init_conversation` | 起新 session支持 `newPlan:true` 换计划) |
| 2 | `select_conversation` | 复用旧 session垂直绑定校验 |
| 3 | `wait_for_user_input` | 真挂起,等用户下一条 |
| 4 | `merge_conversation` | 合流两个 session 的上下文 |
| 5 | `quota_status` | 读取本地限额状态与阈值预警 |
| 6 | `prepare_continuity_handoff` | 生成续接摘要,保护连续线 |
**核心机制**Hub 把 session 存在内存 + 周期 savetoken (`ct_xxx`) 垂直绑定到「工作区 + Cursor 标签 + IP」三件指纹。
## 🛡 合法增强
- 本地 `quota-status.json` 可作为限额状态输入源
- 到阈值时只做预警和续接摘要,不自动重置
- 面板会提示先调用 `prepare_continuity_handoff`
---
## 🚀 5 分钟上手
```bash
# 1. 克隆
git clone http://192.168.110.101:3000/fnvtk/persistent-chat-plugin.git
cd persistent-chat-plugin
# 2. 部署到 ~/.persistent-chat-local
mkdir -p ~/.persistent-chat-local
cp src/* scripts/ensure-hub.sh ~/.persistent-chat-local/
cp web/panel.html ~/.persistent-chat-local/panel.html
# 3. 编辑 mcp.json填到 Trae/Cursor
cat mcp-config/trae.mcp.json
# 复制内容到 ~/.trae/mcp.json
# 4. Trae Cmd+Q 退出重开,让 MCP 重新加载
# 5. 在 SOLO Agent 窗口发"开始测试"或"继续"
```
详细见 [QUICKSTART.md](docs/QUICKSTART.md)。
---
## 🔒 垂直绑定
每个 session 用「工作区::Cursor 标签 @ IP」做绑定指纹
```
/Users/karuo/Documents/个人::持久对话永久续跑-20260626@192.168.110.101
```
换工作区 / 换标签 / 换 IP 都不会复用 session避免串台。
---
## 📊 核心指标
| 指标 | 值 |
|:---|:---|
| Hub 进程 | Node 22 (`/usr/local/opt/node@22/bin/node`) |
| 端口 | 13458 |
| 协议 | HTTP + 短轮询10s 续约) |
| 保活档 | 10s / 30s / 60s / 2min / 4min / 9min / 15min / 30min |
| 校验频率 | 每次 wait 触发一次 |
| 单 session 容量 | 无限制(内存 + JSON 周期 save |
---
## 🆘 常见问题
**Q: 提示"Token未获取, 未登录"**
A: Trae 需 `Cmd+Q` 完全退出重开,让 MCP 配置生效。
**Q: "任务完成" 是不是对话死了?**
A: 不是。Hub 上 session 仍 holding等用户下一条自动续跑。可在 http://192.168.110.101:13458/ 看到。
**Q: 如何真正关掉对话?**
A: 在对话里说"结束持久对话"agent 会主动 merge。
---
## 📜 许可证
私有项目 · 仅公司内部使用 © 2026 卡若AI
---
## 🔗 相关链接
- **默认主链**`http://192.168.110.101:13458/`
- **Gitea 仓库**http://192.168.110.101:3000/fnvtk/persistent-chat-plugin
- **增强向导**http://127.0.0.1:13458/enhance
- **PRD 真源**`docs/prd/PersistentChat_整合CO-Chat_需求PRD_v1.md`
- **远端主链面板**http://192.168.110.101:13458/
- **本地兜底面板**http://127.0.0.1:13458/
- **Trae 配置**`~/.trae/mcp.json`
- **Cursor 配置**`~/Documents/个人/.cursor/mcp.json`