Files
37duAutomation/docs/插件/发版规范.md
T
puddy a7dbc5a77e feat: 重构控制台为37du自动化平台,新增权限授权与通知中心功能
- 更新系统名称、登录页宣传文案为37du平台相关内容
- 移除聊天功能相关代码与配置
- 新增客户端版本上报字段与设备统计接口
- 新增通知中心功能(60s轮询、localStorage已读标记)
- 新增权限授权工作台相关接口与页面
- 新增统一页头组件ArtPageHeader
- 调整快速入口配置指向真实功能页面
- 修复控制面地址为内网生产库
2026-10-15 18:01:29 +08:00

122 lines
6.3 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.
# 插件发版与自动更新规范
> 本文档定义 37duAutomation 各交付物的**发版流程**与执行机**自动更新机制**。
> 发版统一走 agent CLI(中心机控制面),执行机端插件按账号权限自下载、壳子由用户点击升级。
> 打包产物位置、打包脚本见 [插件开发规范.md](./插件开发规范.md) 第 4 节。
## 1. 总览
版本源(插件包 + 壳子安装包 + 文件登记)全部在**中心机控制面**(内网 `http://172.30.30.243:8800`)。
> ⚠️ **发版必须指向内网库**(2026-10-15 踩坑):控制面有两套——
> 内网生产库 `http://172.30.30.243:8800`(执行机实际连接源,端口分工:8800 控制面 / 8802 文件服务器下载 /
> 8899 文件服务器管理台)与公网旧库 `http://117.72.191.188:8800`(迁移前旧库,仍在线但执行机不连)。
> 两库数据不同步,发错库的症状:执行机永远"已是最新版本"/插件不更新,而公网库里查得到记录。
> 发版命令一律**显式** `--base http://172.30.30.243:8800`;
> 验证:`curl -H "X-API-Token: <token>" http://172.30.30.243:8800/api/shell/version`。
| 交付物 | 更新机制 | 入口 |
|--------|----------|------|
| 插件 | 执行机登录后按账号权限自动同步(`plugin_sync.py`) | agent CLI `publish` / `grant` / `revoke` |
| 壳子(安装包) | 执行机自动下载 + 用户点击升级重启(`shell_updater.py`) | agent CLI `file push --category shell` |
| 中心机控制面 | 源码部署,不打包 | 宝塔上传 + 重启 / 前端构建发布 |
## 2. 发版工具与鉴权
统一在 `desktop/` 目录下执行 agent CLI:
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli
```
鉴权两种方式:
1. **密码登录(推荐,任意机器可用)**:
`--admin <管理员> --password <密码>`(或环境变量 `AGENT_ADMIN_PASSWORD` / `AGENT_ADMIN_ACCOUNT`),
并**一律显式加** `--base http://172.30.30.243:8800`(内网生产库,勿用公网旧库,见第 1 节警告)
2. **本机密钥自签(仅中心机本机)**:复用 `controlplane/.env` 与 `.admin_secret`
实际账号:管理员 `puddy`,密码 `123456`,中心机控制面 `http://172.30.30.243:8800`。
本开发机直接示例:
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
publish <插件.zip> --id <id> --version <v>
```
## 3. 插件发版流程
1. **打包**:在插件目录(`plugins/XQ0001-0100/XQ00xx <中文名>/`)下执行 `_pack.py`,产物输出到仓库根 `dist-plugin/<id>_v<版本>.zip`
(zip 根必须含 `plugin.json`;带 UI 插件需先 `npm run build` 出 `ui/index.html`)。
2. **发布**:在 `desktop/` 下执行:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
publish dist-plugin\<id>_v<版本>.zip --id <id> --version <版本>
```
版本号需与 `plugin.json.version` / `ScenePlugin.version` 一致,且高于中心机已有版本。
3. **授权 / 收回**(按账号管控可执行性):
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli --base http://172.30.30.243:8800 grant <账号> <id>
.venv\Scripts\python.exe -m controlplane.tools.agent_cli --base http://172.30.30.243:8800 revoke <账号> <id>
```
4. **执行机端**:登录后按账号权限自动同步——`plugin_sync.py` 拉版本清单 → 下载 → sha256 校验 →
解压到 `plugins/<id>/` 原子替换 → 重载注册表;下次执行即用新版本。
## 4. 壳子发版流程
> 壳子 / 中心机 / 文件服务器的完整发版步骤见 [桌面端发版SOP](../桌面端/桌面端发版SOP.md),本节为摘要。
按实际流程执行:
1. 改 `desktop/webhost/tools/shell.version` 与 `install.iss` 的 `MyAppVersion` 为新版本
2. `desktop/webhost/frontend` 下执行 `npm run build`
3. PyInstaller 打 `desktop/webhost/tools/37du-host.spec`、`37du-host-runner.spec`
(`37du-host-console.spec` 是调试版,不入安装包,可跳过)
4. `ISCC.exe desktop/webhost/tools/install.iss` 出安装包
5. 上传登记:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 --base http://172.30.30.243:8800 `
file push <安装包> --category shell --version <新版本> [--notes "说明"]
```
> 安装包上传到内网文件服务器(`FILESERVER_BASE_URL=172.30.30.243:8802`),并登记到**内网中心机**
> `file_sources(shell)`,执行机 `shell_updater` 从该直链下载。**不要用旧的 `shell-release` 子命令**。
> 登记(`--base`)必须指内网库 `http://172.30.30.243:8800`,发到公网旧库执行机检测不到(见第 1 节警告)。
6. **执行机端**:自动下载安装包,前端提示后用户点击升级重启。
## 5. 中心机发版流程
控制面为源码部署(宝塔 gunicorn 8800,不打包 exe):
- 改后端代码:按 `docs/部署/控制面前后端部署SOP.md`「后端部署流程」上传文件 + 重启项目
- 改前端代码:按同一文档「前端部署流程」构建并发布到静态站 8090
## 6. 发布后检查
- 插件发布后:执行机下次启动自动检测下载;插件登录后按权限自动下载更新。
- 壳子发布后:执行机自动下载,前端提示后点击升级。
- 版本冲突 / 更新失败:查执行机 `plugin_sync.py` 与 `shell_updater.py` 日志;核对中心机版本清单与授权。
## 7. Agent 技能(skills)
发版/上传/账号管理已封装为 Trae agent 技能,agent 按需加载执行:
| 技能 | 用途 |
|------|------|
| `.trae/skills/37du-Agent-CLI/SKILL.md` | CLI 用法与鉴权总纲(先读) |
| `.trae/skills/37du-Plugin-Release/SKILL.md` | 插件发版 / 授权 / 状态管理 |
| `.trae/skills/37du-File-Release/SKILL.md` | 壳子/大文件上传发版(file push) |
| `.trae/skills/37du-Account-Permission/SKILL.md` | 账号与权限管理 |
> 实际账号统一 `puddy / 123456`;`agent_cli` 已默认 `--admin puddy`,支持 `--json` 机器输出与 `ping` 预检。