agent_9art/AGENTS.md
jqb 649f71edc9 feat: 新增COS媒体文件迁移全流程功能,优化实时上传逻辑
1.  调整archive_media_files表sdkfileid字段为TEXT类型适配长内容
2.  新增一键部署脚本deploy-archive-service.sh和全量迁移脚本migrate-all-to-cos.sh
3.  重构COS迁移接口,支持按批次、按时间范围迁移图片和语音文件
4.  新增迁移进度查询接口,支持统计已迁移/未迁移数量
5.  优化实时回调逻辑,新增即时预上传COS功能
6.  更新AGENTS.md文档,补充部署说明和脚本使用说明
7.  调整前端迁移批次大小为10,新增迁移范围说明
2026-06-26 09:50:39 +08:00

139 lines
5.2 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.

# 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 登录服务器,更新 index.html 缓存戳并重启容器
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
cd /www/wwwroot/deploy-package/frontend/sidebar/dist
# 更新 index.html 中的 JS/CSS 引用,带上版本戳防缓存
JS_FILE=$(ls assets/index-*.js | head -1)
CSS_FILE=$(ls assets/index-*.css | head -1)
cat > index.html << HTML
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<title>AI坐席助手</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="module" crossorigin src="/sidebar/$JS_FILE?v=$(date +%s)"></script>
<link rel="stylesheet" crossorigin href="/sidebar/$CSS_FILE?v=$(date +%s)">
</head>
<body>
<div id="root"></div>
</body>
</html>
HTML
# 复制到容器并重启
docker cp . ai-assistant-sidebar:/usr/share/nginx/html/
docker exec ai-assistant-sidebar nginx -s reload
docker restart ai-assistant-nginx
EOF
```
---
## 二、后台 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) → 各容器