[Feature] 插件支持声明依赖其他插件(必须依赖 / 可选依赖)

Aperta
#10,975 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
18/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, yaml

Direzione di ricerca

The request centres on the dependencies block in metadata.yaml, which is the declaration point to read first, along with whatever code parses it and loads plugins. The issue leaves the declaration format open (a plain name list or the repository-style identifier) and asks for several load-time and WebUI behaviours. Settle the format and the required/optional semantics with maintainers before any code, since the done state is not defined yet.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
功能描述

希望插件能在 metadata.yaml 里声明「我依赖哪个插件」,并把依赖分成两档:

  • 必须依赖:缺了它这个插件无法工作。缺失时插件不加载,并给出明确原因(缺哪个插件、要求什么版本)。
  • 可选依赖:有它则增强功能,没有也能照常运行,只是拿不到增强能力。

然后可以再安装插件的时候弹出二级窗口提示安装依赖,必装的自动安装,可选的给出窗口选择性安装

期望由框架统一处理这几件事:

  • 依赖的插件先于依赖方加载;出现循环依赖时报错,而不是卡住。
  • 缺必须依赖时,插件进入「加载失败」列表并说明缺什么,而不是抛出一堆异常。
  • 被依赖的插件被禁用、卸载或重载时,依赖方有明确行为,不会静默失效。
  • WebUI 能显示依赖关系和是否满足;卸载被依赖的插件时给出提示。

声明大致长这样:

dependencies:
  required:
    - astrbot_plugin_xxx_core
  optional:
    - astrbot_plugin_yyy

或是采用仓库的格式,避免不同作者制作同名插件

使用场景
  1. 多个插件共用同一套底层能力:比如渲染图片、发送富文本、存储记忆、管理表情包。把底层抽成一个独立插件,上层只需声明依赖。现在只能每个插件各自复制一份,底层一升级就要改很多个仓库。
  2. 可选增强:某插件装了「通用生图」就走高质量生图,没装就回退到内置实现。
  3. 分层插件:中台类、适配类插件天然会被别的插件依赖,现在只能靠在 README 里写「请先安装我,再用某种方式对接服务」。
  4. 避免半坏状态:用户禁用或卸载了某个底层插件之后,上层插件仍在降级状态下运行,却没有任何提示,问题只能靠翻日志发现。
检查清单
  • 我已在 Issue 列表中搜索过相关功能,确认该功能想法从未被提出过。
  • 我建议的功能与 AstrBot 本体相关,而非在建议某一插件的功能。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助实现该功能。
Lingua principale
Python
Stelle
46.4k
Fork
3.4k
Merge medio
1g 11h
PR unite (30g)
120

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AstrBotDevs/AstrBot

Tutte le issue di AstrBotDevs/AstrBot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.