agent_9art/AGENTS.md
jqb 6ef9235f59 docs(agents): 更新AGENTS.md中的系统名称
- 将文档标题中的系统名称从“九艺AI坐席辅助系统”更改为“第九联盟AI坐席辅助系统”
2026-09-16 10:52:03 +08:00

129 lines
5.8 KiB
Markdown
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.

# Agent Instructions for 第九联盟AI坐席辅助系统
## 部署规则(核心)
### ⚠️ 任何代码修改后必须同步服务器部署
**无论前端、后台还是后端,任何代码修改完成后,都必须立即同步到服务器并重新部署,绝对不能只做本地修改就结束。**
---
## 一、前端 Sidebar 部署
**模块路径**: `frontend/sidebar/`
**服务器部署路径**: `/www/wwwroot/deploy-package/frontend/sidebar/`
**容器名称**: `ai-assistant-sidebar`
**访问地址**: `https://ai.9artedu.com/sidebar/`
### 部署流程
```bash
# 1. 本地构建
cd frontend/sidebar && npm run build
# 2. 同步到服务器(注意带 JS hash 的文件名会变化)
scp -r -o StrictHostKeyChecking=no -i root.pem frontend/sidebar/dist/* root@8.133.162.25:/www/wwwroot/deploy-package/frontend/sidebar/dist/
# 3. SSH 登录服务器,重建镜像并重建容器(持久化,容器再被 recreate 也不会回滚)
# ⚠️ 禁止再用 docker cp 更新 sidebar:cp 进容器可写层的内容在容器 recreate 时会全部丢失
# (2026-09-03 容器被重建后回滚到 6 月旧镜像,summary-search/reminder 页面线上故障)
# ⚠️ 服务器 Dockerfile 直接 COPY 服务端 dist/ 与 nginx.conf,故必须先完成第 2 步 scp
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
cd /www/wwwroot/deploy-package
docker-compose build sidebar
docker-compose up -d --no-deps sidebar
# 容器重建后 IP 变化,外层 nginx 需重启重新解析 DNS
docker restart ai-assistant-nginx
# 自检:三个入口应返回各自标题,且 size 互不相同
curl -sk https://ai.9artedu.com/sidebar/summary | grep -o '<title>[^<]*</title>'
curl -sk https://ai.9artedu.com/sidebar/summary-search | grep -o '<title>[^<]*</title>'
curl -sk https://ai.9artedu.com/sidebar/reminder | grep -o '<title>[^<]*</title>'
EOF
```
> 多页说明:sidebar 是 Vite 多页应用(`vite.config.ts` rollupOptions.input)。`/sidebar/summary` 为每日总结页,`/sidebar/summary-search` 为运营按手机号/微信号查询客户总结的页面;新增页面时需在 `frontend/sidebar/nginx.conf` 加对应的精确匹配 `location = /xxx { try_files /xxx.html =404; }`。
---
## 二、后台 Admin 部署
**模块路径**: `frontend/admin/`
**服务器部署路径**: `/www/wwwroot/deploy-package/frontend/admin/`
**容器名称**: `ai-assistant-admin`
**访问地址**: `https://ai.9artedu.com/admin/`
### 部署流程
```bash
# 1. 本地构建
cd frontend/admin && npm run build
# 2. 同步到服务器
scp -r -o StrictHostKeyChecking=no -i root.pem frontend/admin/dist/* root@8.133.162.25:/www/wwwroot/deploy-package/frontend/admin/dist/
# 3. SSH 登录服务器,重新构建镜像并重启容器
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
cd /www/wwwroot/deploy-package/frontend/admin
docker build -t deploy-package-admin .
docker stop ai-assistant-admin
docker rm ai-assistant-admin
cd /www/wwwroot/deploy-package
docker-compose up -d admin
EOF
```
---
## 三、后端微服务部署
**模块路径**: `backend/*-service/`
**服务器部署路径**: `/www/wwwroot/deploy-package/backend/*-service/`
**技术栈**: Spring Boot + Docker Compose
### 微服务列表
| 服务名 | 容器名 | 端口 | 部署路径 |
|--------|--------|------|----------|
| gateway | ai-assistant-gateway | 8080 | `backend/gateway/` |
| auth-service | ai-assistant-auth | 8081 | `backend/auth-service/` |
| archive-service | ai-assistant-archive | 8082 | `backend/archive-service/` |
| conversation-service | ai-assistant-conversation | 8083 | `backend/conversation-service/` |
| intent-service | ai-assistant-intent | 8084 | `backend/intent-service/` |
| recommend-service | ai-assistant-recommend | 8085 | `backend/recommendation-service/` |
| generation-service | ai-assistant-generation | 8086 | `backend/generation-service/` |
| kb-admin-service | ai-assistant-kbadmin | 8087 | `backend/kb-admin-service/` |
| analytics-service | ai-assistant-analytics | 8088 | `backend/analytics-service/` |
### 部署流程(以某个服务为例)
```bash
# 1. 本地构建 JAR 包(通常在对应服务目录下)
cd backend/auth-service && mvn clean package -DskipTests
# 2. 将 JAR 包同步到服务器的 deploy-package 对应目录
scp -o StrictHostKeyChecking=no -i root.pem target/*.jar root@8.133.162.25:/www/wwwroot/deploy-package/backend/auth-service/
# 3. SSH 登录服务器,重新构建镜像并启动容器
# ⚠️ 注意:Dockerfile 中 COPY 的是 app.jar,必须先把新 jar 复制为 app.jar
# ⚠️ docker-compose up 没有 --no-cache 参数,如需无缓存构建应分两步执行
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
cd /www/wwwroot/deploy-package/backend/auth-service
cp auth-service-*.jar app.jar
cd /www/wwwroot/deploy-package
docker-compose build --no-cache auth-service
docker-compose up -d auth-service
EOF
```
### 一键脚本
项目根目录已提供 `deploy-archive-service.sh`,可自动完成 archive-service 的构建、上传、部署和自检。
---
## 服务器信息
- **IP**: `8.133.162.25`
- **SSH 私钥**: `root.pem`(项目根目录)
- **部署根目录**: `/www/wwwroot/deploy-package/`
- **Docker Compose 文件**: `/www/wwwroot/deploy-package/docker-compose.yml`
- **前端站点**: `https://ai.9artedu.com/sidebar/`
- **后台站点**: `https://ai.9artedu.com/admin/`
- **代理**: 宝塔 Nginx → Docker Nginx (8089) → 各容器
- **生产数据库**: 各微服务连接的是**腾讯云 MySQL**(`MYSQL_HOST`/`MYSQL_PORT`/`MYSQL_USERNAME`/`MYSQL_PASSWORD` 见容器 env,库名 `ai_assistant`),**不是**服务器上的 `ai-assistant-mysql` 容器(那是闲置的本地实例)。线上改表结构(ALTER TABLE 等)必须打到腾讯云实例上,可从服务器用 `docker exec ai-assistant-mysql mysql -h <云DB地址> ...` 执行。