feat(plugin): 分身后缀可留空自动分配,并支持按后缀恢复已停用的分身 (#6673)

This commit is contained in:
Aqr-K
2026-09-14 07:00:31 +08:00
committed by GitHub
parent a51acb05e5
commit 57fb96fc3c
27 changed files with 1304 additions and 117 deletions

View File

@@ -756,8 +756,8 @@ flowchart LR
| 指标 | 当前值 |
|---|---:|
| Python 模块 | 1018 |
| 内部导入边 | 8,650 |
| Python 模块 | 1019 |
| 内部导入边 | 8,667 |
| 非平凡 SCC | 1(精确 containment 的 TMDB 移植包环) |
| Application / Chain 具体 Adapter 直连 | 0 / 0 |
| Direct egress | 53(债务已清零,53 条精确 containment) |

View File

@@ -97,6 +97,30 @@ MCP 当前不会主动发送工具列表变更通知(`listChanged=false`)。
时不会把它计入 `purged`。实例 ID 必须是合法的插件实例 ID(字母开头、仅字母与数字):
它会被拼进插件数据目录路径,带路径分隔符或上跳的标识一律在动任何存储之前被拒绝。
### 插件分身的创建与恢复
`plugin.clone` 用源插件 ID 创建一个共享它源码的分身。`suffix` 可以不填:留空时由服务端
挑一个最小可用序号(本体算第 1 个实例,分身从 2 起排),因而调用方**算不出**分身 ID,
必须从回执的 `data.instance_id` 取。填了后缀则只接受 ASCII 字母与数字,且在请求解析阶段
就会被拦下——非法后缀拼出的实例 ID 用不了 Python 类名与路由段,等落库再报错意味着已经
写出一行、还要靠回滚擦掉。
占号判据不止看「此刻在不在跑」:当前已装载的类、实例表里的每一行(含已停用的分身与本体)、
安装清单,以及磁盘上留存的插件包目录,任意一项命中都算已占用。自动分配与手填后缀共用这
同一个判据,自动分配因此不会挑中一个手填时会被拒绝的 ID。
同一个后缀名下留有一个**已停用**的分身时,这次创建就是把那一行重新置为启用,而不是新建:
停用从不删行,业务参数一直挂在上面,恢复因而拿回的正是用户当初留下的那份配置。展示名、
描述与图标留空则沿用停用前登记的那一份,填了就按填的改。要改为「丢掉旧配置、按源插件模板
重建」,把 `restore_previous` 置为 false——静默丢弃用户数据不能是默认行为。恢复失败时只
把启用位退回停用,不会连同那一行与它的配置一起毁掉。
`plugin.clone.restorable` 用源插件 ID 列出该插件名下所有已停用、配置仍留存的分身,给出
实例 ID、相对源插件 ID 的后缀、停用前登记的展示信息,以及是否留有业务参数。启用中的分身
不在此列:它们的配置正被使用,拿来「恢复」没有意义。
被 `plugin.instance.purge` 彻底清理掉的分身也不在此列,而且不可恢复:清理删的是实例行
本身,恢复所依赖的那份留存配置随之消失,同后缀再建只会得到一个全新的空白分身。
## 3.1 结构化 Agent 工具与完整参数合同

View File

@@ -2,7 +2,7 @@
"disposition_counts": {
"alternate-auth-duplicate": 11,
"consolidated": 71,
"gateway": 225,
"gateway": 226,
"provider-skill": 12,
"stream_or_binary": 10,
"transport_or_identity": 66,
@@ -18,10 +18,10 @@
"reason": "The executor validates and expands this bounded source placeholder to one of tmdb, douban, bangumi, or anilist before calling the corresponding concrete OpenAPI route."
}
],
"gateway_http_route_count": 226,
"gateway_operation_count": 228,
"matched_gateway_http_route_count": 225,
"openapi_operation_count": 408,
"gateway_http_route_count": 227,
"gateway_operation_count": 229,
"matched_gateway_http_route_count": 226,
"openapi_operation_count": 409,
"operations": [
{
"disposition": "consolidated",
@@ -2039,6 +2039,20 @@
"plugin"
]
},
{
"disposition": "gateway",
"method": "GET",
"operation_ids": [
"plugin.clone.restorable"
],
"owner": "moviepilot-api",
"path": "/api/v1/plugin/clone/{plugin_id}/restorable",
"reason": "Executable through moviepilot_api; exact inputs are generated into MCP tools/list and SKILL.md.",
"summary": "列出可恢复的已停用分身",
"tags": [
"plugin"
]
},
{
"disposition": "ui_presentation",
"method": "GET",

View File

@@ -5,10 +5,10 @@
## Result
- OpenAPI HTTP operations: **408**
- Stable `moviepilot_api` operations: **228**
- Exact HTTP routes used by the gateway: **226**
- OpenAPI routes matched directly by the gateway: **225**
- OpenAPI HTTP operations: **409**
- Stable `moviepilot_api` operations: **229**
- Exact HTTP routes used by the gateway: **227**
- OpenAPI routes matched directly by the gateway: **226**
- Bounded dynamic gateway routes: **1**
- Every gateway operation has a generated English oneOf input contract in MCP `tools/list` and `skills/moviepilot-api/SKILL.md`.
- Every non-gateway OpenAPI operation is listed below with an explicit ownership boundary; it is not silently callable through arbitrary URL/method input.
@@ -19,7 +19,7 @@
| :--- | ---: | :--- |
| `alternate-auth-duplicate` | 11 | API-token compatibility duplicate of a bearer-authenticated capability. |
| `consolidated` | 71 | Source/UI route represented by a stable aggregate Agent operation. |
| `gateway` | 225 | Approved structured MoviePilot Agent operation. |
| `gateway` | 226 | Approved structured MoviePilot Agent operation. |
| `provider-skill` | 12 | Low-level downloader or media-server capability owned by a provider Skill. |
| `stream_or_binary` | 10 | Streaming or binary response owned by a direct client transport. |
| `transport_or_identity` | 66 | Authentication, protocol, callback, account, or conversation transport boundary. |
@@ -193,6 +193,7 @@
| `POST` | `/api/v1/openai/v1/responses` | openai | `transport_or_identity` | host-runtime | OpenAI compatible responses |
| `GET` | `/api/v1/plugin/` | plugin | `gateway` | plugin.installed, plugin.market | 所有插件 |
| `POST` | `/api/v1/plugin/clone/{plugin_id}` | plugin | `gateway` | plugin.clone | 创建插件分身 |
| `GET` | `/api/v1/plugin/clone/{plugin_id}/restorable` | plugin | `gateway` | plugin.clone.restorable | 列出可恢复的已停用分身 |
| `GET` | `/api/v1/plugin/dashboard/meta` | plugin | `ui_presentation` | host-ui | 获取所有插件仪表板元信息 |
| `GET` | `/api/v1/plugin/dashboard/{plugin_id}` | plugin | `ui_presentation` | host-ui | 获取插件仪表板配置 |
| `GET` | `/api/v1/plugin/dashboard/{plugin_id}/{key}` | plugin | `ui_presentation` | host-ui | 获取插件仪表板配置 |

View File

@@ -94,7 +94,7 @@ ARCH-201 至 ARCH-204 均达到实现、验证、提交、推送和远端门禁
| 指标 | 当前值 | 解释 |
|---|---:|---|
| 宿主 Python 模块 / 内部依赖边 | 1018 / 8,650 | `dependency-baseline.json` 当前快照;分类、下载资源归类、订阅搜索、整理恢复、Agent 计划、工具视觉、终端生命周期与终端作用域模块的受控依赖 |
| 宿主 Python 模块 / 内部依赖边 | 1019 / 8,667 | `dependency-baseline.json` 当前快照;分类、下载资源归类、订阅搜索、整理恢复、Agent 计划、工具视觉、终端生命周期与终端作用域模块的受控依赖 |
| 非平凡 SCC | 1 | 仅保留精确 containment 的 29 模块 TMDB 移植包环 |
| 跨层 DB 边界债务 | 0 | Application、Chain、API、Agent、Runtime、Workflow 到 DB 的受控债务均为零 |
| Model/Oper 事务债务 | 0 | 自建 Session、自动事务装饰器、直接 commit/rollback 等基线均为零 |
@@ -102,7 +102,7 @@ ARCH-201 至 ARCH-204 均达到实现、验证、提交、推送和远端门禁
| Event Contract | 53 | 均已有 payload model,但当前全部是 diagnostic enforcement |
| Python 源码量 | 305,884 行 | 排除 `app/plugins/**`;61 个文件超过 1,000 行,11 个超过 2,000 行 |
| 长方法 | 290 个超过 80 行 | AST 统计排除 `app/plugins/**`;65 个超过 150 行,21 个超过 250 行 |
| 全量 mypy 历史债务 | 9,371 / 509 文件 | Agent API 重构后的现状基线;canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降 |
| 全量 mypy 历史债务 | 9,370 / 509 文件 | Agent API 重构后的现状基线;canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降 |
| Ruff 历史诊断 | 519 | 低水位门禁通过,但规则集只覆盖 `E4/E7/E9/F/I` |
| 覆盖率固定基线 | Application 80.00%,Domain 80.00% | Chain、Runtime、Agent、Adapter、Startup 未进入包级覆盖率门禁 |