Repository navigation
Conversation
Plugins could not declare their own marketplace category: metadata.yaml was never read for a category, so the marketplace fell back to review-assigned categories and most plugins ended up in "other". Add a canonical category list (astrbot/core/star/plugin_categories.py), keep the declared value on StarMetadata, and validate it on every metadata entry point (loading, repository inspection, archive inspection, install, update). Unsupported or malformed declarations only log a warning and degrade to "other" so that a typo cannot make a plugin uninstallable.
/plugins/market/categories used to return an empty list, so the WebUI had to invent its filter entries from whatever slugs a marketplace happened to contain. Return the canonical slug list instead so the marketplace, the WebUI and the runtime share one vocabulary. The response is the existing `Ok` envelope, so the OpenAPI document and the generated client stay unchanged.
The market category select read whatever `category` values the current registry happened to contain, so unknown or mistyped values created one-off filter entries, competed with search and sort for toolbar width, and showed the raw slug when a translation was missing. Read the vocabulary from /plugins/market/categories instead, keep its order, and collapse unknown values into "other". Replace the select with a single scrollable chip row that hides its scrollbar: pointing at it and using the wheel scrolls the row, and when the chips overflow a toggle on the right expands every category into wrapped rows. Below the small-screen breakpoint the chips take the first line and the sort control wraps onto a second one. The "全部插件" heading is gone, refresh now sits beside the source button, and every supported slug has a label in all four locales.
Add the `category` section to both plugin development guides, the metadata.yaml template in the publishing guide and the marketplace index docs, so plugin authors can find the supported slugs. The Chinese section lives in the current guide (plugin-new.md) to match the English page; the legacy guide is left untouched and the marketplace index link points at the current guide.
"entertainment" covered 398 plugins in the current registry, mixing in-chat games, connectors for other games and generic entertainment, so the category could not be used to find anything. Keep "entertainment" for generic entertainment that is not a game, keep "group_games" for games whose rules the plugin implements itself, and add "game_integration" for plugins built around another game: connectors, wikis and data lookups, server status and player actions. Add "ai_context" for plugins that shape conversation context across turns (persona, context compression and injection, reply style), which had no home outside "long_term_memory". Order the vocabulary by cluster and keep related slugs adjacent: the AI cluster leads, "long_term_memory" and "knowledge_base" sit directly under it, "platform_adapter" follows "integrations", the entertainment cluster closes the list and "other" stays last. Every locale gets a label for both new slugs so the market filter never falls back to the raw identifier.
Drop the claim that categories are no longer assigned during review, write the identifiers in the space-separated spelling (spaces, underscores, hyphens and mixed case are equivalent) and document every category with its localized label and what it is meant for, so plugin authors pick the narrower one. Labels follow the dashboard bundles verbatim, including 外部集成 and AI Conversation, and the table repeats the runtime display order. Adjacent categories state their boundaries explicitly: one-shot text work is "ai_tools", stored memories are "long_term_memory" and external documents are "knowledge_base". Keep the identifier and label columns on one line with a page-scoped style so the spaced identifiers do not wrap mid-phrase. The user guide still described the market filter as six fixed categories; it now follows the plugin's declared category row in both locales.
getMarketCategoryLabel carried a hardcoded English map for the seven original categories, so a missing translation produced a different label style for those seven than for the twelve newer ones (and disagreed with the "never fall back to the raw identifier" promise of the category filter). Drop the map and the raw-category pass-through: an unknown category now always renders as words derived from the slug, which also reads better than the raw value for ad-hoc marketplace categories.
The warning spelled out all nineteen supported slugs on every emit, so a single typo produced a 336-character log line that pushed the useful part out of view. Keep the message to the offending value and the fallback; the supported list is documented in the plugin development guide.
Linked issuesChecked at commit 8d1b455 #10638 [Feature] 插件元数据新增分类声明 · 3 of 4 met
|
There was a problem hiding this comment.
Hey - I've found 8 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/src/views/extension/useExtensionPage.js" line_range="244-246" />
<code_context>
+ const slug = normalized.replace(/[\s-]+/g, "_");
+ // Unknown slugs collapse into "other" so that a typo or an ad-hoc value in
+ // a marketplace index cannot create a one-off filter entry.
+ if (
+ marketCategorySlugs.value.length > 0 &&
+ !marketCategorySlugs.value.includes(slug)
+ ) {
+ return "other";
</code_context>
<issue_to_address>
**Unsupported categories become separate chips**
When the categories request fails or returns an empty list while the market index contains an unsupported category, `normalizeMarketCategory` skips its allowlist check when `marketCategorySlugs` is empty, so `marketCategoryItems` exposes the unsupported value as a one-off filter chip instead of folding it into `other`.
Ensure unsupported marketplace categories normalize to `other` even when the categories vocabulary is empty.
</issue_to_address>
### Comment 2
<location path="astrbot/core/star/plugin_categories.py" line_range="61" />
<code_context>
+ return None
+
+ if isinstance(value, str):
+ slug = value.strip().lower().replace("-", "_").replace(" ", "_")
+ if slug in PLUGIN_CATEGORY_SLUGS:
+ return slug
</code_context>
<issue_to_address>
**Category spellings normalize differently**
When a category declaration contains repeated or mixed whitespace and hyphen separators, `normalize_plugin_category` replaces separators individually, so repeated separators produce a different slug or fall back to `other`, while the WebUI collapses separator runs and treats the same value as `ai_tools`; runtime and market then disagree on the category.
Normalize separator runs in `normalize_plugin_category` the same way the WebUI does.
Also at `dashboard/src/views/extension/useExtensionPage.js:241`.
</issue_to_address>
### Comment 3
<location path="dashboard/src/views/extension/useExtensionPage.js" line_range="2383" />
<code_context>
}
loading_.value = true;
try {
+ await loadMarketCategories();
await getExtensions({ withLoading: false });
</code_context>
<issue_to_address>
**Market initialization can hang**
When the categories endpoint connection stalls without returning or rejecting, `loadMarketCategories` awaits an Axios request with no configured timeout, and `onMounted` awaits it before calling `getExtensions` or loading market data. If the request stalls without settling, initialization remains pending and the plugin page stays in its loading state.
Give the request a bounded timeout or avoid making page initialization wait for it.
</issue_to_address>
### Comment 4
<location path="astrbot/core/star/star.py" line_range="72-74" />
<code_context>
astrbot_version: str | None = None
"""插件要求的 AstrBot 版本范围(PEP 440 specifier,如 >=4.13.0,<4.17.0)"""
+ category: str | None = None
+ """Plugin market category slug declared in metadata (None when undeclared)."""
+
i18n: dict[str, dict] = field(default_factory=dict)
"""插件自带的国际化文案,按 locale 分组。"""
</code_context>
<issue_to_address>
**Positional metadata callers misbind fields**
When an external consumer passes `i18n` or later fields positionally, a caller constructing the exported `StarMetadata` dataclass with positional arguments through `i18n` now binds its old `i18n` argument to `category` (and shifts later arguments), so existing callers receive incorrect metadata or a type error.
Make the new field keyword-only or append it after the existing positional fields.
</issue_to_address>
### Comment 5
<location path="dashboard/src/views/extension/useExtensionPage.js" line_range="224" />
<code_context>
+ const loadMarketCategories = async () => {
+ try {
+ const res = await pluginApi.marketCategories();
+ const slugs = res.data?.data?.categories;
+ marketCategorySlugs.value = Array.isArray(slugs)
+ ? slugs.map((slug) => String(slug || "").trim()).filter(Boolean)
</code_context>
<issue_to_address>
**Declared categories do not reach market records**
When a plugin author changes only `metadata.yaml` and the corresponding marketplace registry record is not separately updated, the category request supplies only the allowed slug list; marketplace entries still get their category from the registry record, so changing a plugin’s `metadata.yaml` alone does not change its market filter category. Authors or index maintainers must separately update the registry, and the declared category is not reflected in the market until that happens.
Add or document an explicit registry-update path that copies the normalized metadata category into the marketplace record.
</issue_to_address>
### Comment 6
<location path="docs/en/dev/star/plugin-new.md" line_range="156" />
<code_context>
+category: media processing
+```
+
+`category` takes one of the following identifiers. The English label is only the display text, so writing it back is not accepted.
+
+| Identifier | English label | Use it for |
</code_context>
<issue_to_address>
**Valid category spelling is documented as invalid**
The guide says writing an English label back is not accepted, but `normalize_plugin_category` accepts `AI Tools` as `ai_tools`; plugin authors following the instruction can be misled about which metadata values are valid.
Clarify that localized labels are not accepted, while spellings that normalize to a supported slug (including `AI Tools`) are accepted.
</issue_to_address>
### Comment 7
<location path="dashboard/src/views/extension/MarketPluginsTab.vue" line_range="367-407" />
<code_context>
- <h2>
- {{ tm("market.allPlugins") }}
- </h2>
+ <div class="market-category-row">
+ <div
+ v-if="hasCategories"
+ class="market-category-chips"
+ :class="{ 'is-expanded': categoryChipsExpanded }"
+ >
+ <div
+ ref="chipsRowEl"
+ class="market-category-chips-scroll"
+ @wheel="onCategoryChipsWheel"
+ >
+ <button
+ v-for="item in marketCategoryItems"
+ :key="item.value"
+ type="button"
+ class="market-category-chip"
+ :class="{ 'is-active': marketCategoryFilter === item.value }"
+ @click="marketCategoryFilter = item.value"
+ >
+ {{ item.label }}
+ <span class="market-category-chip-count">{{ item.count }}</span>
+ </button>
+ </div>
<v-btn
+ v-if="chipsToggleVisible"
</code_context>
<issue_to_address>
**Filter move lacks mapping**
When the category filter is moved from the toolbar dropdown to the chip row, the category filter moves from a toolbar dropdown to a chip row above the market list, but the documentation and changelog do not record the old dropdown → new chip row mapping required for this UI move.
Add the old dropdown → new chip row mapping to the relevant Chinese and English docs and changelogs.
</issue_to_address>
### Comment 8
<location path="tests/unit/test_plugin_categories.py" line_range="1-79" />
<code_context>
+"""Tests for astrbot.core.star.plugin_categories module."""
</code_context>
<issue_to_address>
**New test file added**
When this PR adds `tests/unit/test_plugin_categories.py`, adding `tests/unit/test_plugin_categories.py` creates a test file, contrary to the repository instruction.
Remove the new test file to follow the repository guidance.
</issue_to_address>Sourcery assessment
Approval pending. 5 findings to address first.
Blocking findings: dashboard/src/views/extension/useExtensionPage.js:246, astrbot/core/star/plugin_categories.py:61, dashboard/src/views/extension/useExtensionPage.js:2383, astrbot/core/star/star.py:74, dashboard/src/views/extension/useExtensionPage.js:224
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Collapse separator runs so a declaration like "AI - Tools" resolves to ai_tools instead of falling back to other, matching the WebUI normalization. - Append StarMetadata.category so callers that pass later fields positionally keep their bindings. - Load the market category vocabulary without blocking plugin list initialization. - Fold the category unit tests into the manager tests.
- State that the WebUI and the runtime follow the declared category while the marketplace shows whatever the index copied. - Note that English spellings which normalize to a supported identifier are accepted, unlike localized labels. - Record the old toolbar category dropdown to new chip row mapping in the user docs and the changelog.
- Record that index maintainers copy the normalized category slug from metadata.yaml when adding or updating a record, and that the index wins for marketplace display while metadata.yaml wins for the WebUI and the runtime. - Explain in code why an unknown category vocabulary keeps the discovered chips instead of folding them into other.
The index holds a snapshot copied at collection time, so a disagreement means the snapshot is stale rather than the index overriding metadata.yaml.
- Point category at the identifier list instead of a dangling "see docs below" reference, and default the sample value to other so a copied sample never claims a specific category. - Mark display_name as optional while keeping it uncommented. - Describe tags as matched by marketplace search rather than marketplace categorization, now that category exists.
Collapse the nineteen-slug category vocabulary into nine buckets: utility, ai_context, entertainment, media, productivity, integration, platform_adapter, provider_adapter and other. The earlier split kept the AI cluster, the memory and knowledge base entries, the game entries and the automation and security entries apart, which produced categories too small to browse by. The new buckets fold them back into the semantics a plugin author can decide on from the plugin description alone. Update the four dashboard locales, the zh and en developer and user docs, and the normalization test cases that asserted the removed slugs.
The category is a hint, not a whitelist: a plugin may declare any value, which is normalized to a slug but never rewritten to "other" and never logged as a warning. The list becomes a recommendation that orders the filter row and supplies translated labels, and a value outside it keeps its own filter entry instead of being folded away. Add the game category for plugins that connect to an external game, and give entertainment back to generic fun and in-chat games. Trim the developer docs to the recommended table plus one lead-in sentence, and move the Chinese "optional" headings off the English spelling, updating the anchors that reference them.
|
基于新要求重新整理分类词条和约束 |
|
|
||
| The `category` value comes from the same field declared in the plugin repository's `metadata.yaml`. Recommended values are listed under [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional), but the field is optional and free-form: the marketplace copies the normalized declared value and leaves it empty when the plugin declares none. | ||
|
|
||
| When adding or updating a plugin record, index maintainers read `category` from that plugin repository's `metadata.yaml` and write the normalized slug (underscore form, such as `platform_adapter`) into the index `category` field. `metadata.yaml` stays the single authoritative source: the index holds a snapshot copied when the record was collected, so a disagreement means the snapshot is stale and the marketplace keeps showing the previous category until the index is collected again. Installed plugins in the runtime and the WebUI always read `metadata.yaml` directly and ignore the index. |
There was a problem hiding this comment.
🟡 Medium · Market can show stale categories
The market still displays the category copied into the index rather than reading the current metadata declaration. The documentation notes that a stale snapshot remains visible until the index is collected again, so the marketplace can disagree with the declared category.
Prompt for AI agents
In `docs/en/dev/plugin-market/2026-06-27.md` at line 163:
**Market can show stale categories**
The market still displays the category copied into the index rather than reading the current metadata declaration. The documentation notes that a stale snapshot remains visible until the index is collected again, so the marketplace can disagree with the declared category.From #10638:
Use metadata.yaml as the category source, avoiding conflicts with existing marketplace categories.
resolve #10638
插件市场的分类此前是「前端写死」的:WebUI 里维护了一份 fallbackMap 和 i18n 文案,而后端
GET /api/v1/plugins/market/categories直接返回空数组{"categories": []}。结果是:本次改动让分类成为插件在
metadata.yaml中可选、自由填写的字段:运行时、接口和 WebUI 共用一份「推荐词表」(10 个 slug)负责排序与文案,其它取值也一样被接受并保留,写错分类不会阻断插件加载、安装或更新;市场分类筛选同时从下拉框改为更适合多分类的 chip 行。Modifications / 改动点
后端
astrbot/core/star/plugin_categories.py:RECOMMENDED_PLUGIN_CATEGORIES(10 个推荐 slug,含显示顺序:utility、ai_context、entertainment、game、media、productivity、integration、platform_adapter、provider_adapter、other)与normalize_plugin_category()。归一化只做轻度处理:首尾空格、大小写、空格 /-/_三种分隔符等价;空字符串与非字符串返回None;其余任何取值都保留为归一化后的 slug,既不替换成other,也不打日志,更不阻断加载、安装或更新。game(连接外部游戏),entertainment回到泛娱乐与群内小游戏。StarMetadata新增category字段(追加在末尾,避免影响按位置构造它的外部调用方);star_manager加载metadata.yaml时归一化写入,插件热重载时同步该字段。updater.validate_plugin_metadata不再对category做归一化或告警——metadata.yaml里写什么分类都不会让已有插件变得无法安装或更新。GET /api/v1/plugins/market/categories由返回空数组改为返回推荐 slug 列表(仅 slug,展示文案留在前端 i18n),用途是给筛选条排序并提供共享文案,不是白名单;插件列表与详情响应新增category字段。WebUI
v-select改为可横向滚动的 chip 行(带插件计数):推荐分类中实际有插件的按后端顺序排在前面,作者声明的其它分类按发现顺序追加,各自保留独立筛选项,不再折叠进other;默认单行,放不下时出现展开/收起按钮,展开后换行显示全部分类;wheel事件被映射为横向滚动,行可滚动时吞掉滚轮,滚到端点也不会带动整页跳动;窄屏下分类独占一行、排序控件折行并保留自身宽度。await,失败自动退化为「按发现顺序」);chip 文案缺失时把 slug 拆成单词渲染,而不是显示原始标识;详情页分类标签采用同一归一化规则(兼容-),未收录的自定义分类原样展示。zh-CN/en-US/ja-JP/ru-RU)各补齐 10 个推荐分类文案(含新增的「游戏」),替换旧的ai_tools/integrations/utilities;新增展开 / 收起 / 刷新提示文案,移除不再使用的market.category、market.allPlugins。pluginApi.marketCategories()客户端封装。文档
docs/zh|en/dev/star/plugin-new.md:新增「声明插件分类(可选)」章节,只保留推荐表与一句引导(10 个标识、中文释义、适用场景),不再承诺归一化细则与other兜底;中文文档把「(Optional)」类标题统一改为「(可选)」,并补充了分类表格的列宽样式。docs/zh|en/dev/star/plugin.md同步标题改法;plugin-publish.md的metadata.yaml模板补充# category: other # (可选)插件市场分类,链接改为「推荐的插件市场分类」,锚点更新为#声明插件分类-可选。docs/zh|en/use/plugin.md:更新市场分类筛选的操作说明(推荐分类含「游戏」,作者写其它值也会单独出现;旧入口「分类」下拉框 → 新位置市场列表上方的分类 chip 行)。docs/zh|en/dev/plugin-market/2026-06-27.md:说明市场索引中category为可选、自由填写,收录时复制归一化后的值,未声明时为空。changelogs/unreleased.md:新增该功能条目,含 10 个推荐取值与「旧入口 → 新入口」对照。测试
tests/test_plugin_manager.py:加载保留声明分类、等价写法归一化(Platform Adapter/platform-adapter/AI - Context/ 多余空格)、未列入推荐表的值原样保留、未声明为None、更新校验不告警不阻断、加载未列值不写告警日志、运行时加载后分类保留。tests/test_dashboard.py/tests/test_fastapi_v1_dashboard.py:已安装插件列表 / 详情返回category,market categories 接口返回推荐 slug 列表。兼容性
category是可选字段。未声明的插件category=None,WebUI 过滤条按「其他」展示,现有插件无需任何迁移。已声明但不在推荐词表内的取值会原样保留并单独成为一个筛选项(不再被改写成
other),因此自定义分类不会因为「词表里没有」而消失。后端接口只把
categories从空数组改为推荐 slug 列表,字段名与结构不变;前端先读插件列表再统计计数,推荐词表请求失败时自动回退到「按发现顺序」,不影响列表加载。未引入新依赖,
pyproject.toml/requirements.txt未改动。This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
SnowShot_Video_2026-11-11_20-59-33.mp4
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
📚 I checked the affected WebUI instructions and screenshots in
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog./ 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新
docs/zh和docs/en的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Enable plugins to declare optional marketplace categories while providing consistent cross-layer handling and a more flexible category filter.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: