From fa181cb95b42bfe9ef11421a8b1d33cbc0274a23 Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 21:18:51 +0800 Subject: [PATCH 01/16] feat(plugin): declare marketplace category in plugin metadata 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. --- astrbot/core/star/plugin_categories.py | 73 +++++++++ astrbot/core/star/star.py | 3 + astrbot/core/star/star_manager.py | 6 + astrbot/core/star/updater.py | 5 + astrbot/dashboard/services/plugin_service.py | 1 + tests/test_dashboard.py | 3 + tests/test_fastapi_v1_dashboard.py | 1 + tests/test_plugin_manager.py | 148 +++++++++++++++++++ tests/unit/test_plugin_categories.py | 88 +++++++++++ 9 files changed, 328 insertions(+) create mode 100644 astrbot/core/star/plugin_categories.py create mode 100644 tests/unit/test_plugin_categories.py diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py new file mode 100644 index 00000000000..d23d2e3b797 --- /dev/null +++ b/astrbot/core/star/plugin_categories.py @@ -0,0 +1,73 @@ +"""Canonical plugin categories that plugins declare in ``metadata.yaml``. + +Plugins declare a stable, machine-readable slug instead of a localized label so +the plugin market index, the WebUI and the runtime all filter on the same +values. Adding a category is a code change here; labels are derived from the +slug wherever it is displayed. +""" + +from __future__ import annotations + +from astrbot.core import logger + +PLUGIN_CATEGORY_SLUGS: tuple[str, ...] = ( + "ai_tools", + "ai_image", + "ai_speech", + "ai_agent", + "platform_adapter", + "media_processing", + "automation", + "security", + "long_term_memory", + "knowledge_base", + "tools", + "integrations", + "entertainment", + "group_games", + "productivity", + "utilities", + "other", +) +"""Supported ``metadata.yaml`` ``category`` values, in display order.""" + +DEFAULT_PLUGIN_CATEGORY = "other" +"""Category used when a plugin declares an unsupported category.""" + + +def normalize_plugin_category(value: object, *, warn: bool = True) -> str | None: + """Normalize the category declared by plugin metadata. + + Unsupported values never block loading or installation: they are reported in + the log and mapped to ``DEFAULT_PLUGIN_CATEGORY`` so that a typo in + ``metadata.yaml`` cannot make a plugin uninstallable. + + Args: + value: Raw ``category`` value read from ``metadata.yaml``. + warn: Whether to report an unsupported value. Callers that already + validated the same metadata can pass ``False`` to avoid a duplicate + warning while still getting the normalized value. + + Returns: + The declared slug when it is supported, ``None`` when the plugin does + not declare a category, otherwise ``DEFAULT_PLUGIN_CATEGORY``. + """ + if value is None: + return None + + if isinstance(value, str): + slug = value.strip().lower().replace("-", "_").replace(" ", "_") + if slug in PLUGIN_CATEGORY_SLUGS: + return slug + if not slug: + return None + + if not warn: + return DEFAULT_PLUGIN_CATEGORY + + logger.warning( + f"Unsupported plugin category {value!r}; falling back to " + f"{DEFAULT_PLUGIN_CATEGORY!r}. Supported categories: " + f"{', '.join(PLUGIN_CATEGORY_SLUGS)}." + ) + return DEFAULT_PLUGIN_CATEGORY diff --git a/astrbot/core/star/star.py b/astrbot/core/star/star.py index 91797dd7419..2fc73c44fb2 100644 --- a/astrbot/core/star/star.py +++ b/astrbot/core/star/star.py @@ -69,6 +69,9 @@ class StarMetadata: 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 分组。""" diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index df2c5e13b97..70873d6c67a 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -52,6 +52,7 @@ from .context import Context from .error_messages import format_plugin_error from .filter.permission import COMMAND_PERMISSION_TYPES, PermissionTypeFilter +from .plugin_categories import normalize_plugin_category from .star import star_map, star_registry from .star_handler import EventType, star_handlers_registry from .updater import PLUGIN_METADATA_FILENAMES, _PluginUpdater @@ -553,6 +554,10 @@ def _load_plugin_metadata(plugin_path: str, plugin_obj=None) -> StarMetadata | N if isinstance(metadata.get("astrbot_version"), str) else None ), + # The metadata was validated above, so do not warn twice. + category=normalize_plugin_category( + metadata.get("category"), warn=False + ), # "views" is the preferred key; "pages" stays as an alias. views=metadata["views"] if isinstance(metadata.get("views"), list) @@ -1199,6 +1204,7 @@ async def load( metadata.display_name = metadata_yaml.display_name metadata.support_platforms = metadata_yaml.support_platforms metadata.astrbot_version = metadata_yaml.astrbot_version + metadata.category = metadata_yaml.category metadata.views = metadata_yaml.views metadata.i18n = metadata_yaml.i18n except Exception as e: diff --git a/astrbot/core/star/updater.py b/astrbot/core/star/updater.py index 37cb0ce2c59..b61b22eebf7 100644 --- a/astrbot/core/star/updater.py +++ b/astrbot/core/star/updater.py @@ -24,6 +24,7 @@ from ..star.star import StarMetadata from ..zip_updater import _RepoZipUpdater +from .plugin_categories import normalize_plugin_category PLUGIN_METADATA_FILENAMES = ("metadata.yaml", "metadata.yml") PLUGIN_METADATA_REQUIRED_FIELDS = ("name", "desc", "version", "author") @@ -395,6 +396,10 @@ def validate_plugin_metadata(metadata: object, metadata_label: str) -> None: f"{metadata_label} 中字段 {', '.join(invalid_fields)} 必须是非空字符串。" ) + # An unsupported category must never block installation or updates, so it + # is normalized to the fallback category with a warning instead of raising. + normalize_plugin_category(normalized_metadata.get("category")) + @classmethod def inspect_plugin_directory(cls, plugin_path: str | Path) -> dict[str, object]: """Inspect plugin metadata in a checked-out repository directory. diff --git a/astrbot/dashboard/services/plugin_service.py b/astrbot/dashboard/services/plugin_service.py index 36e9fa4aba3..bc929ac010f 100644 --- a/astrbot/dashboard/services/plugin_service.py +++ b/astrbot/dashboard/services/plugin_service.py @@ -660,6 +660,7 @@ def serialize_plugin_base( "logo": logo_url, "support_platforms": plugin.support_platforms, "astrbot_version": plugin.astrbot_version, + "category": plugin.category, "installed_at": installed_at, "i18n": plugin.i18n, "root_dir_name": plugin.root_dir_name, diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 4a8701e954e..a4a60240064 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -242,6 +242,7 @@ def registered_plugin_page(core_lifecycle_td: AstrBotCoreLifecycle, monkeypatch) display_name="Plugin Page Demo", root_dir_name=PLUGIN_PAGE_DEMO_NAME, activated=True, + category="tools", ) monkeypatch.setattr( @@ -1883,6 +1884,7 @@ async def test_plugin_get_excludes_scanned_pages( item for item in data["data"] if item["name"] == PLUGIN_PAGE_DEMO_NAME ) assert plugin["activated"] is True + assert plugin["category"] == "tools" assert "page" not in plugin assert "pages" in plugin assert isinstance(plugin["pages"], list) @@ -2549,6 +2551,7 @@ async def test_plugins( assert data["status"] == "ok" for plugin in data["data"]: assert "installed_at" in plugin + assert "category" in plugin assert "components" not in plugin installed_at = plugin["installed_at"] if installed_at is None: diff --git a/tests/test_fastapi_v1_dashboard.py b/tests/test_fastapi_v1_dashboard.py index 3926278ab8e..44bfe90518a 100644 --- a/tests/test_fastapi_v1_dashboard.py +++ b/tests/test_fastapi_v1_dashboard.py @@ -947,6 +947,7 @@ async def terminate_platform(platform_id: str) -> None: logo_path=None, support_platforms=[], astrbot_version="", + category=None, i18n={}, root_dir_name=None, star_handler_full_names=[], diff --git a/tests/test_plugin_manager.py b/tests/test_plugin_manager.py index 77e1fb70cc4..15a5bb499ef 100644 --- a/tests/test_plugin_manager.py +++ b/tests/test_plugin_manager.py @@ -14,6 +14,7 @@ import pytest import yaml +from astrbot.core.star import plugin_categories from astrbot.core.star import star_manager as star_manager_module from astrbot.core.star.star_handler import EventType, StarHandlerMetadata from astrbot.core.star.star_manager import PluginDependencyInstallError, PluginManager @@ -193,6 +194,97 @@ def test_load_plugin_metadata_accepts_yml_suffix(tmp_path: Path): ) +def _write_plugin_category(plugin_path: Path, category: object) -> None: + metadata_path = plugin_path / "metadata.yaml" + metadata = yaml.safe_load(metadata_path.read_text(encoding="utf-8")) + metadata["category"] = category + metadata_path.write_text(yaml.dump(metadata), encoding="utf-8") + + +def test_load_plugin_metadata_includes_category(tmp_path: Path): + plugin_path = tmp_path / "helloworld" + _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) + _write_plugin_category(plugin_path, "platform_adapter") + + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + + assert loaded_metadata is not None + assert loaded_metadata.category == "platform_adapter" + + +def test_load_plugin_metadata_normalizes_category(tmp_path: Path): + plugin_path = tmp_path / "helloworld" + _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) + _write_plugin_category(plugin_path, "Group Games") + + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + + assert loaded_metadata is not None + assert loaded_metadata.category == "group_games" + + +def test_load_plugin_metadata_unknown_category_falls_back_to_other(tmp_path: Path): + plugin_path = tmp_path / "helloworld" + _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) + _write_plugin_category(plugin_path, "not_a_category") + + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + + assert loaded_metadata is not None + assert loaded_metadata.category == "other" + + +def test_load_plugin_metadata_without_category_is_none(tmp_path: Path): + plugin_path = tmp_path / "helloworld" + _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) + + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + + assert loaded_metadata is not None + assert loaded_metadata.category is None + + +def test_validate_plugin_metadata_allows_unknown_category(monkeypatch) -> None: + # A category typo must not make an existing plugin uninstallable on update. + warnings: list[str] = [] + monkeypatch.setattr( + plugin_categories.logger, "warning", lambda message: warnings.append(message) + ) + + star_manager_module._PluginUpdater.validate_plugin_metadata( + { + "name": TEST_PLUGIN_NAME, + "author": "AstrBot Team", + "desc": "Local test plugin", + "version": "1.0.0", + "category": "not_a_category", + }, + "metadata.yaml", + ) + + assert len(warnings) == 1 + assert "not_a_category" in warnings[0] + + +def test_load_plugin_metadata_warns_once_for_unknown_category( + tmp_path: Path, monkeypatch +) -> None: + # Loading validates the metadata first, so the warning must not repeat. + warnings: list[str] = [] + monkeypatch.setattr( + plugin_categories.logger, "warning", lambda message: warnings.append(message) + ) + plugin_path = tmp_path / "helloworld" + _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) + _write_plugin_category(plugin_path, "not_a_category") + + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + + assert loaded_metadata is not None + assert loaded_metadata.category == "other" + assert len(warnings) == 1 + + def test_load_plugin_metadata_does_not_fallback_to_legacy_info( tmp_path: Path, ) -> None: @@ -929,6 +1021,62 @@ async def prepare(*args): terminate.assert_not_awaited() +@pytest.mark.asyncio +async def test_load_plugin_keeps_declared_category( + plugin_manager_pm: PluginManager, + local_updater: Path, + monkeypatch, + tmp_path: Path, +): + """Loading a plugin must keep the category declared in metadata.yaml.""" + _clear_star_runtime_state() + module_path = f"data.plugins.{TEST_PLUGIN_DIR}.main" + _write_plugin_category(local_updater, "group_games") + (local_updater / "main.py").write_text( + "from astrbot.api.star import Star\nclass Main(Star):\n pass\n", + encoding="utf-8", + ) + monkeypatch.setattr( + plugin_manager_pm.context, "stars", star_manager_module.star_registry + ) + monkeypatch.setattr( + plugin_manager_pm, "reserved_plugin_path", str(tmp_path / "reserved") + ) + monkeypatch.setattr( + plugin_manager_pm, "plugin_config_path", str(tmp_path / "config") + ) + + async def global_get(key, default=None): + return default + + async def import_plugin(*, path, **kwargs): + if path not in sys.modules: + module = ModuleType(path) + sys.modules[path] = module + main_path = local_updater / "main.py" + exec( + compile(main_path.read_text(encoding="utf-8"), str(main_path), "exec"), + module.__dict__, + ) + return sys.modules[path] + + async def sync_command_configs(): + return None + + monkeypatch.setattr(star_manager_module.sp, "global_get", global_get) + monkeypatch.setattr( + star_manager_module, "sync_command_configs", sync_command_configs + ) + monkeypatch.setattr( + plugin_manager_pm, "_import_plugin_with_dependency_recovery", import_plugin + ) + + success, error = await plugin_manager_pm.load(specified_dir_name=TEST_PLUGIN_DIR) + + assert success, error + assert star_manager_module.star_map[module_path].category == "group_games" + + @pytest.mark.asyncio @pytest.mark.parametrize("install_source", ["upload", "url"]) @pytest.mark.parametrize("disabled", [False, True]) diff --git a/tests/unit/test_plugin_categories.py b/tests/unit/test_plugin_categories.py new file mode 100644 index 00000000000..fe1819ba0e7 --- /dev/null +++ b/tests/unit/test_plugin_categories.py @@ -0,0 +1,88 @@ +"""Tests for astrbot.core.star.plugin_categories module.""" + +import pytest + +from astrbot.core.star import plugin_categories +from astrbot.core.star.plugin_categories import ( + DEFAULT_PLUGIN_CATEGORY, + PLUGIN_CATEGORY_SLUGS, + normalize_plugin_category, +) + + +class TestNormalizePluginCategory: + """Test cases for normalize_plugin_category.""" + + @pytest.mark.parametrize("slug", PLUGIN_CATEGORY_SLUGS) + def test_accepts_supported_slug(self, slug: str): + """Every supported slug is returned unchanged.""" + assert normalize_plugin_category(slug) == slug + + @pytest.mark.parametrize( + ("raw", "expected"), + [ + (" ai_tools ", "ai_tools"), + ("AI_TOOLS", "ai_tools"), + ("AI Tools", "ai_tools"), + ("ai-tools", "ai_tools"), + ("Long-term Memory", "long_term_memory"), + ], + ) + def test_normalizes_slug_spelling(self, raw: str, expected: str): + """Case, whitespace and separators do not change the resulting slug.""" + assert normalize_plugin_category(raw) == expected + + @pytest.mark.parametrize("raw", [None, "", " "]) + def test_missing_category_stays_undeclared(self, raw): + """An absent category is reported as None instead of the fallback.""" + assert normalize_plugin_category(raw) is None + + @pytest.mark.parametrize( + "raw", + ["not_a_category", "工具", 1, ["ai_tools"], {"name": "ai_tools"}], + ) + def test_unsupported_category_falls_back(self, raw): + """Unsupported values degrade to the fallback category.""" + assert normalize_plugin_category(raw) == DEFAULT_PLUGIN_CATEGORY + + def test_unsupported_category_warns(self, monkeypatch: pytest.MonkeyPatch): + """Degrading an unsupported value is reported in the log.""" + warnings: list[str] = [] + monkeypatch.setattr( + plugin_categories.logger, + "warning", + lambda message: warnings.append(message), + ) + + assert normalize_plugin_category("Not A Category") == DEFAULT_PLUGIN_CATEGORY + assert len(warnings) == 1 + assert "Not A Category" in warnings[0] + + def test_unsupported_category_can_skip_the_warning( + self, monkeypatch: pytest.MonkeyPatch + ): + """Callers that already validated the metadata can suppress the report.""" + warnings: list[str] = [] + monkeypatch.setattr( + plugin_categories.logger, + "warning", + lambda message: warnings.append(message), + ) + + assert ( + normalize_plugin_category("Not A Category", warn=False) + == DEFAULT_PLUGIN_CATEGORY + ) + assert warnings == [] + + def test_supported_category_does_not_warn(self, monkeypatch: pytest.MonkeyPatch): + """A supported category is accepted silently.""" + warnings: list[str] = [] + monkeypatch.setattr( + plugin_categories.logger, + "warning", + lambda message: warnings.append(message), + ) + + assert normalize_plugin_category("tools") == "tools" + assert warnings == [] From 5e9a51d0ea8bcd757ae368a4666a2902796546fa Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 21:09:23 +0800 Subject: [PATCH 02/16] feat(plugin): expose the category vocabulary over the plugin API /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. --- astrbot/dashboard/api/plugins.py | 5 ++++- tests/test_fastapi_v1_dashboard.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/astrbot/dashboard/api/plugins.py b/astrbot/dashboard/api/plugins.py index 4cdf0fccfa0..ef4a7625d92 100644 --- a/astrbot/dashboard/api/plugins.py +++ b/astrbot/dashboard/api/plugins.py @@ -12,6 +12,7 @@ from astrbot.api.web import PluginRequest, bind_request_context from astrbot.core import logger from astrbot.core.log import LogManager +from astrbot.core.star.plugin_categories import PLUGIN_CATEGORY_SLUGS from astrbot.dashboard.asgi_runtime import ( DashboardRequestState, call_request_view, @@ -623,7 +624,9 @@ async def list_plugin_market( async def list_plugin_market_categories( _auth: AuthContext = Depends(require_plugin_scope), ): - return ok({"categories": []}) + # Slugs only: display labels stay in the dashboard i18n bundles so that the + # marketplace, the WebUI and the runtime share one category vocabulary. + return ok({"categories": list(PLUGIN_CATEGORY_SLUGS)}) @router.get("/plugin-sources") diff --git a/tests/test_fastapi_v1_dashboard.py b/tests/test_fastapi_v1_dashboard.py index 44bfe90518a..91255cae335 100644 --- a/tests/test_fastapi_v1_dashboard.py +++ b/tests/test_fastapi_v1_dashboard.py @@ -23,6 +23,7 @@ import astrbot.dashboard.services.config_service as config_service import astrbot.dashboard.services.stat_service as stat_service from astrbot.core import file_token_service +from astrbot.core.star.plugin_categories import PLUGIN_CATEGORY_SLUGS from astrbot.core.utils import llm_metadata from astrbot.dashboard.api.app import create_dashboard_asgi_app from astrbot.dashboard.api.backups import download_backup as download_backup_route @@ -2554,6 +2555,25 @@ async def test_v1_plugins_accept_api_key( assert [item["name"] for item in data["data"]] == ["astrbot_plugin_demo"] +@pytest.mark.asyncio +async def test_v1_plugin_market_categories_lists_canonical_slugs( + asgi_client: httpx.AsyncClient, + fake_db: FakeDb, +): + raw_key = "abk_fastapi_v1_plugin_categories" + fake_db.add_api_key(raw_key, scopes=["plugin"]) + + response = await asgi_client.get( + "/api/v1/plugins/market/categories", + headers={"X-API-Key": raw_key}, + ) + + assert response.status_code == 200 + data = response.json() + assert data["status"] == "ok" + assert data["data"]["categories"] == list(PLUGIN_CATEGORY_SLUGS) + + @pytest.mark.asyncio async def test_v1_plugin_enabled_patch_calls_service( asgi_client: httpx.AsyncClient, From 09d62966ddbfcc1867d4c2c1ad2c6a85db1338ee Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 21:09:30 +0800 Subject: [PATCH 03/16] feat(dashboard): rebuild the plugin market category filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- dashboard/src/api/v1.ts | 5 + .../locales/en-US/features/extension.json | 17 +- .../locales/ja-JP/features/extension.json | 17 +- .../locales/ru-RU/features/extension.json | 19 +- .../locales/zh-CN/features/extension.json | 17 +- .../src/views/extension/MarketPluginsTab.vue | 254 +++++++++++++----- .../src/views/extension/useExtensionPage.js | 43 ++- 7 files changed, 298 insertions(+), 74 deletions(-) diff --git a/dashboard/src/api/v1.ts b/dashboard/src/api/v1.ts index f482b0b9f45..e23115538a6 100644 --- a/dashboard/src/api/v1.ts +++ b/dashboard/src/api/v1.ts @@ -1413,6 +1413,11 @@ export const pluginApi = { sources() { return typed(openApiV1.listPluginSources()); }, + marketCategories() { + return typed<{ categories: string[] }>( + openApiV1.listPluginMarketCategories(), + ); + }, replaceSources(sources: OpenConfig[]) { return typed( openApiV1.replacePluginSources({ body: { sources: sources as any } }), diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index e17999203e1..bdb222483c0 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -142,8 +142,10 @@ }, "market": { "recommended": "🥳 Recommended", - "allPlugins": "📦 All Extensions", "category": "Category", + "expandCategories": "Show all categories", + "collapseCategories": "Collapse categories", + "refresh": "Refresh", "categories": { "all": "All", "ai_tools": "AI Tools", @@ -151,7 +153,18 @@ "productivity": "Productivity", "integrations": "Integrations", "utilities": "Utilities", - "other": "Other" + "other": "Other", + "ai_image": "AI Image", + "ai_speech": "AI Speech", + "ai_agent": "Agents & Orchestration", + "platform_adapter": "Platform Adapter", + "media_processing": "Media Processing", + "automation": "Automation & Scheduling", + "security": "Security & Moderation", + "long_term_memory": "Long-term Memory", + "knowledge_base": "Knowledge Base", + "tools": "Tools", + "group_games": "Group Games" }, "showFullName": "Full Name", "devDocs": "Extension Development Docs", diff --git a/dashboard/src/i18n/locales/ja-JP/features/extension.json b/dashboard/src/i18n/locales/ja-JP/features/extension.json index c8def6652db..b7b43d8c17a 100644 --- a/dashboard/src/i18n/locales/ja-JP/features/extension.json +++ b/dashboard/src/i18n/locales/ja-JP/features/extension.json @@ -142,8 +142,10 @@ }, "market": { "recommended": "🥳 おすすめ", - "allPlugins": "📦 すべてのプラグイン", "category": "カテゴリ", + "expandCategories": "すべてのカテゴリを表示", + "collapseCategories": "カテゴリを折りたたむ", + "refresh": "更新", "categories": { "all": "すべて", "ai_tools": "AI ツール", @@ -151,7 +153,18 @@ "productivity": "生産性", "integrations": "外部連携", "utilities": "ユーティリティ", - "other": "その他" + "other": "その他", + "ai_image": "AI 画像", + "ai_speech": "AI 音声", + "ai_agent": "エージェントと編成", + "platform_adapter": "プラットフォームアダプター", + "media_processing": "メディア処理", + "automation": "自動化とスケジュール", + "security": "セキュリティと審査", + "long_term_memory": "長期記憶", + "knowledge_base": "ナレッジベース", + "tools": "ツール", + "group_games": "グループゲーム" }, "showFullName": "正式名称", "devDocs": "プラグイン開発ドキュメント", diff --git a/dashboard/src/i18n/locales/ru-RU/features/extension.json b/dashboard/src/i18n/locales/ru-RU/features/extension.json index e9467672400..68c37e4f2be 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/extension.json +++ b/dashboard/src/i18n/locales/ru-RU/features/extension.json @@ -142,16 +142,29 @@ }, "market": { "recommended": "🥳 Рекомендуем", - "allPlugins": "📦 Все плагины", "category": "Категория", - "categories": { + "expandCategories": "Показать все категории", + "collapseCategories": "Свернуть категории", + "refresh": "Обновить", + "categories": { "all": "Все", "ai_tools": "AI Tools", "entertainment": "Развлечения", "productivity": "Продуктивность", "integrations": "Интеграции", "utilities": "Утилиты", - "other": "Другое" + "other": "Другое", + "ai_image": "AI-изображения", + "ai_speech": "AI-речь", + "ai_agent": "Агенты и оркестрация", + "platform_adapter": "Адаптер платформы", + "media_processing": "Обработка медиа", + "automation": "Автоматизация и расписание", + "security": "Безопасность и модерация", + "long_term_memory": "Долговременная память", + "knowledge_base": "База знаний", + "tools": "Инструменты", + "group_games": "Групповые игры" }, "showFullName": "Полное имя", "devDocs": "Документация для разработчиков", diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index dfd04a40c3f..903954cf6cf 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -142,8 +142,10 @@ }, "market": { "recommended": "🥳 推荐", - "allPlugins": "📦 全部插件", "category": "分类", + "expandCategories": "展开全部分类", + "collapseCategories": "收起分类", + "refresh": "刷新", "categories": { "all": "全部", "ai_tools": "AI 增强", @@ -151,7 +153,18 @@ "productivity": "效率", "integrations": "外部集成", "utilities": "生活实用", - "other": "其他" + "other": "其他", + "ai_image": "AI 绘图", + "ai_speech": "AI 语音", + "ai_agent": "智能体与编排", + "platform_adapter": "平台适配器", + "media_processing": "媒体处理", + "automation": "自动化与定时", + "security": "安全与审核", + "long_term_memory": "长期记忆", + "knowledge_base": "知识库", + "tools": "工具", + "group_games": "群游戏" }, "showFullName": "完整名称", "devDocs": "插件开发文档", diff --git a/dashboard/src/views/extension/MarketPluginsTab.vue b/dashboard/src/views/extension/MarketPluginsTab.vue index f93f1a6277e..c8a59e4cab5 100644 --- a/dashboard/src/views/extension/MarketPluginsTab.vue +++ b/dashboard/src/views/extension/MarketPluginsTab.vue @@ -2,7 +2,14 @@ import MarketPluginCard from "@/components/extension/MarketPluginCard.vue"; import PluginSortControl from "@/components/extension/PluginSortControl.vue"; import defaultPluginIcon from "/favicon.svg"; -import { computed } from "vue"; +import { + computed, + nextTick, + onBeforeUnmount, + onMounted, + ref, + watchEffect, +} from "vue"; import { normalizeTextInput } from "@/utils/inputValue"; const props = defineProps({ @@ -168,11 +175,60 @@ const marketSortItems = computed(() => [ { title: tm("sort.updated"), value: "updated" }, ]); -const marketCategorySelectItems = computed(() => - marketCategoryItems.value.map((item) => ({ - title: `${item.label || ""} (${item.count || 0})`, - value: item.value, - })), +// One scrollable chip row at every width; a toggle expands it into wrapped rows +// when the categories do not fit on a single line. +const hasCategories = computed(() => marketCategoryItems.value.length > 0); + +const categoryChipsExpanded = ref(false); +const categoryChipsOverflow = ref(false); +const chipsRowEl = ref(null); + +const measureCategoryChips = () => { + const el = chipsRowEl.value; + if (!el) { + categoryChipsOverflow.value = false; + return; + } + // Only the collapsed row can overflow; keep the toggle visible while expanded. + if (categoryChipsExpanded.value) return; + categoryChipsOverflow.value = el.scrollWidth - el.clientWidth > 4; +}; + +const chipsToggleVisible = computed( + () => categoryChipsOverflow.value || categoryChipsExpanded.value, +); + +// The chip row hides its scrollbar, so a vertical wheel over it scrolls the row +// horizontally. While the row can scroll it also swallows the wheel, so reaching +// the end does not suddenly scroll the whole page; moving the pointer away gives +// the wheel back to the page. +const onCategoryChipsWheel = (event) => { + const el = chipsRowEl.value; + if (!el || categoryChipsExpanded.value) return; + const maxScroll = el.scrollWidth - el.clientWidth; + if (maxScroll <= 0) return; + if (Math.abs(event.deltaX) >= Math.abs(event.deltaY)) return; + + const delta = event.deltaMode === 1 ? event.deltaY * 16 : event.deltaY; + el.scrollLeft = Math.max(0, Math.min(maxScroll, el.scrollLeft + delta)); + event.preventDefault(); +}; + +const toggleCategoryChips = () => { + categoryChipsExpanded.value = !categoryChipsExpanded.value; + if (!categoryChipsExpanded.value) void nextTick(measureCategoryChips); +}; + +watchEffect(() => { + // Re-measure when the vocabulary or the tab visibility changes. + void marketCategoryItems.value.length; + void activeTab.value; + if (hasCategories.value) void nextTick(measureCategoryChips); +}); + +onMounted(() => window.addEventListener("resize", measureCategoryChips)); +onBeforeUnmount(() => + window.removeEventListener("resize", measureCategoryChips), ); // Navigate with the unique market plugin key instead of the metadata name — @@ -233,6 +289,22 @@ const openMarketPluginDetail = (plugin) => { + + + + {
-
-
-

- {{ tm("market.allPlugins") }} -

+
+
+
+ +
- mdi-refresh + + {{ categoryChipsExpanded ? "mdi-chevron-up" : "mdi-chevron-down" }} +
-
- - +
{ } .market-header-row, -.market-header-primary, -.market-filter-group { +.market-header-primary { gap: 12px; } @@ -459,20 +539,76 @@ const openMarketPluginDetail = (plugin) => { min-width: 220px; } -.market-filter-group { +.market-category-row { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 10px; +} + +.market-category-row-sort { + flex: 0 0 auto; + margin-left: auto; +} + +.market-category-chips { + flex: 1 1 auto; + display: flex; + align-items: center; + gap: 6px; + min-width: 0; +} + +.market-category-chips-scroll { + flex: 1 1 auto; + display: flex; + gap: 6px; + min-width: 0; + overflow-x: auto; + /* Pointer scrolling works through the wheel handler, so no scrollbar. */ + scrollbar-width: none; + -ms-overflow-style: none; +} + +.market-category-chips-scroll::-webkit-scrollbar { + display: none; +} + +.market-category-chips.is-expanded .market-category-chips-scroll { flex-wrap: wrap; + overflow: visible; } -.market-filter-control { - min-width: 190px; - max-width: 220px; +.market-category-chip { + flex: 0 0 auto; + padding: 4px 12px; + border: 1px solid rgba(var(--v-theme-on-surface), 0.16); + border-radius: 999px; + background: transparent; + color: rgba(var(--v-theme-on-surface), 0.75); + font-size: 0.8125rem; + white-space: nowrap; + cursor: pointer; +} + +.market-category-chip:hover { + background: rgba(var(--v-theme-on-surface), 0.05); +} + +.market-category-chip.is-active { + border-color: rgb(var(--v-theme-primary)); + background: rgb(var(--v-theme-primary)); + color: rgb(var(--v-theme-on-primary)); + font-weight: 600; +} + +.market-category-chip-count { + margin-left: 2px; + opacity: 0.7; } -.market-filter-control :deep(.v-field__input), -.market-filter-control :deep(.v-field-label), -.market-filter-control :deep(.v-select__selection-text), -.market-filter-control :deep(.v-field__prepend-inner) { - font-size: 0.875rem; +.market-category-chips-toggle { + flex: 0 0 auto; } @media (max-width: 700px) { @@ -494,28 +630,26 @@ const openMarketPluginDetail = (plugin) => { width: 100%; } - .market-filter-group { - align-items: stretch !important; - flex-direction: column; - width: 100%; + /* Small screens: categories keep the first line to themselves and the sort + control drops to a second line, keeping its natural width. */ + .market-category-row { + align-items: center; + flex-wrap: wrap; + column-gap: 6px; + row-gap: 12px; } - .market-filter-control { - max-width: none; - min-width: 0; - width: 100%; + .market-category-chips { + flex: 1 1 100%; } - .market-filter-group :deep(.plugin-sort-control) { - flex-wrap: nowrap; - width: 100%; + .market-category-row-sort { + flex: 0 0 auto; + margin-left: 0; } - .market-filter-group :deep(.plugin-sort-control__select) { - flex: 1; - max-width: none; - min-width: 0; - width: auto; + .market-category-row-sort :deep(.plugin-sort-control) { + flex-wrap: nowrap; } .plugin-view-tab { diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index 6710c16c268..cf56d10c203 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -213,9 +213,24 @@ export const useExtensionPage = (initialTab = "installed") => { const sortOrder = ref("desc"); // desc (降序) or asc (升序) const randomPluginNames = ref([]); const marketCategoryFilter = ref("all"); + // Canonical slug order served by the backend; empty until it loads. + const marketCategorySlugs = ref([]); // 插件市场拼音搜索 + 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) + : []; + } catch (error) { + console.warn("Failed to load plugin market categories:", error); + marketCategorySlugs.value = []; + } + }; + const normalizeMarketCategory = (rawCategory) => { const normalized = String(rawCategory || "") .trim() @@ -223,7 +238,16 @@ export const useExtensionPage = (initialTab = "installed") => { if (!normalized) { return "other"; } - return normalized.replace(/[\s-]+/g, "_"); + 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"; + } + return slug; }; const getMarketCategoryLabel = (key, rawCategory = "") => { @@ -294,10 +318,18 @@ export const useExtensionPage = (initialTab = "installed") => { }, ]; - for (const [ - categoryKey, - categoryData, - ] of marketCategoryMeta.value.entries()) { + // Prefer the backend order so the filter reads the same everywhere; fall + // back to discovery order when the vocabulary is unavailable. + const orderedKeys = + marketCategorySlugs.value.length > 0 + ? marketCategorySlugs.value + : [...marketCategoryMeta.value.keys()]; + + for (const categoryKey of orderedKeys) { + const categoryData = marketCategoryMeta.value.get(categoryKey); + if (!categoryData) { + continue; + } items.push({ value: categoryKey, label: getMarketCategoryLabel(categoryKey, categoryData.rawLabel), @@ -2366,6 +2398,7 @@ export const useExtensionPage = (initialTab = "installed") => { } loading_.value = true; try { + await loadMarketCategories(); await getExtensions({ withLoading: false }); // 检查是否有 open_config 参数 From be7df2deab80d14900f4070938354442cd7e8dd1 Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 21:19:19 +0800 Subject: [PATCH 04/16] docs: document plugin metadata category declaration 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. --- docs/en/dev/plugin-market/2026-06-27.md | 2 ++ docs/en/dev/star/plugin-new.md | 34 +++++++++++++++++++++++++ docs/en/dev/star/plugin-publish.md | 1 + docs/zh/dev/plugin-market/2026-06-27.md | 2 ++ docs/zh/dev/star/plugin-new.md | 34 +++++++++++++++++++++++++ docs/zh/dev/star/plugin-publish.md | 1 + 6 files changed, 74 insertions(+) diff --git a/docs/en/dev/plugin-market/2026-06-27.md b/docs/en/dev/plugin-market/2026-06-27.md index 788b893c003..a04bd07e7a9 100644 --- a/docs/en/dev/plugin-market/2026-06-27.md +++ b/docs/en/dev/plugin-market/2026-06-27.md @@ -158,6 +158,8 @@ Each `PluginRecord` MUST contain: | `stars` | integer | Non-negative star count or ranking signal. | | `download_count` | integer | Non-negative download count. | +The `category` value comes from the same field declared in the plugin repository's `metadata.yaml` and is limited to the categories AstrBot supports (see [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional)). The marketplace copies the declared value verbatim; undeclared or unsupported values become `other`. + ### 7.1. Repository URL `repo` MUST be one of: diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index 1f20c6fcd3c..a0da3258165 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -141,6 +141,40 @@ If you only want to declare a minimum version, use: If the current AstrBot version does not satisfy this range, the plugin will be blocked from loading with a compatibility error. In the WebUI installation flow, you can choose to "Ignore Warning and Install" to bypass this check. +### Declare Plugin Category (Optional) + +You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The plugin marketplace, the WebUI and the runtime all follow this field instead of a category assigned during manual review. + +```yaml +category: media_processing +``` + +`category` must be one of the following identifiers (case-insensitive; localized names are not accepted): + +| Identifier | Meaning | +| --- | --- | +| `ai_tools` | AI enhancement | +| `ai_image` | AI image generation | +| `ai_speech` | AI speech | +| `ai_agent` | Agents and orchestration | +| `platform_adapter` | Platform adapter | +| `media_processing` | Media processing | +| `automation` | Automation and scheduling | +| `security` | Security and moderation | +| `long_term_memory` | Long-term memory | +| `knowledge_base` | Knowledge base | +| `tools` | Tools | +| `integrations` | Third-party integrations | +| `entertainment` | Entertainment | +| `group_games` | Group games | +| `productivity` | Productivity | +| `utilities` | Utilities | +| `other` | Other | + +Declarations are lightly normalized: surrounding whitespace, letter case and `-`/space separators are ignored, so `AI Tools`, `ai-tools` and `ai_tools` are equivalent. + +Plugins that do not declare `category` are grouped under `other`. An unsupported value only logs a warning and is also grouped under `other`; it never blocks installation or updates. Adding a new category requires a code change in AstrBot, so prefer the identifiers above. + ### Debugging Plugins AstrBot uses a runtime plugin injection mechanism. Therefore, when debugging plugins, you need to start the AstrBot main application. diff --git a/docs/en/dev/star/plugin-publish.md b/docs/en/dev/star/plugin-publish.md index e2fcd7126ea..965a7aeb95d 100644 --- a/docs/en/dev/star/plugin-publish.md +++ b/docs/en/dev/star/plugin-publish.md @@ -19,6 +19,7 @@ desc: Detailed description of your plugin's features, usage, etc. # Detailed pl version: 1.0.0 # Plugin version (follow semantic versioning) author: Author Name # Author name repo: https://github.com/your-name/repo # Plugin repository URL +# category: tools # (Optional) Marketplace category, see docs below # astrbot_version: ">=4.17.0" # (Optional) AstrBot version range # support_platforms: # (Optional) Supported platform adapter list # - aiocqhttp diff --git a/docs/zh/dev/plugin-market/2026-06-27.md b/docs/zh/dev/plugin-market/2026-06-27.md index 0f2957c88fe..b6934397d67 100644 --- a/docs/zh/dev/plugin-market/2026-06-27.md +++ b/docs/zh/dev/plugin-market/2026-06-27.md @@ -158,6 +158,8 @@ metadata.author + "/" + metadata.name | `stars` | integer | 非负 star 数或排序信号。 | | `download_count` | integer | 非负下载数。 | +`category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段,取值限于 AstrBot 支持的分类标识(见[声明插件分类](../star/plugin-new.md#声明插件分类-optional))。市场收录时直接复制该值,未声明或不支持的取值统一为 `other`。 + ### 7.1. 仓库 URL `repo` 必须是以下之一: diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index c4b09d3f574..904ecfbd35a 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -143,6 +143,40 @@ astrbot_version: ">=4.16,<5" 当当前 AstrBot 版本不满足该范围时,插件会被阻止加载并提示版本不兼容。 在 WebUI 安装插件时,你可以选择“无视警告,继续安装”来跳过这个检查。 +### 声明插件分类(Optional) + +你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。插件市场、WebUI 与运行时都会以该字段为准,不再由审核人工指定分类。 + +```yaml +category: media_processing +``` + +`category` 必须是下列英文标识之一(区分不了大小写,写中文不会被识别): + +| 标识 | 含义 | +| --- | --- | +| `ai_tools` | AI 增强 | +| `ai_image` | AI 绘图 | +| `ai_speech` | AI 语音 | +| `ai_agent` | 智能体与编排 | +| `platform_adapter` | 平台适配器 | +| `media_processing` | 媒体处理 | +| `automation` | 自动化与定时 | +| `security` | 安全与审核 | +| `long_term_memory` | 长期记忆 | +| `knowledge_base` | 知识库 | +| `tools` | 工具 | +| `integrations` | 三方集成 | +| `entertainment` | 娱乐 | +| `group_games` | 群游戏 | +| `productivity` | 效率 | +| `utilities` | 生活实用 | +| `other` | 其他 | + +取值会做轻度归一化:首尾空格、大小写以及 `-`、空格分隔符都会被忽略,因此 `AI Tools`、`ai-tools` 与 `ai_tools` 等价。 + +未声明 `category` 的插件会归入 `other`。如果写了不支持的分类,AstrBot 会在日志中给出告警并同样归入 `other`,但**不会**阻止插件安装或更新。新增分类需要修改 AstrBot 源码,因此请优先使用上表中的标识。 + ### 调试插件 AstrBot 采用在运行时注入插件的机制。因此,在调试插件时,需要启动 AstrBot 本体。 diff --git a/docs/zh/dev/star/plugin-publish.md b/docs/zh/dev/star/plugin-publish.md index 2dc9c50fc46..57c1539771e 100644 --- a/docs/zh/dev/star/plugin-publish.md +++ b/docs/zh/dev/star/plugin-publish.md @@ -19,6 +19,7 @@ desc: 详细描述插件的功能、特性、使用方法等信息。 # 详细 version: 1.0.0 # 插件版本号(遵循语义化版本规范) author: 作者名称 # 作者名称 repo: https://github.com/your-name/repo # 插件仓库地址 +# category: tools # (可选)插件市场分类,标识见下方文档 # astrbot_version: ">=4.17.0" # (可选)支持的 AstrBot 版本范围 # support_platforms: # (可选)支持的平台适配器列表 # - aiocqhttp From e38139478c5a3887b602c0e4bb020cd0646117dd Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 23:39:17 +0800 Subject: [PATCH 05/16] feat(plugin): extend the plugin category vocabulary "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. --- astrbot/core/star/plugin_categories.py | 14 ++++++++------ .../src/i18n/locales/en-US/features/extension.json | 4 +++- .../src/i18n/locales/ja-JP/features/extension.json | 4 +++- .../src/i18n/locales/ru-RU/features/extension.json | 4 +++- .../src/i18n/locales/zh-CN/features/extension.json | 4 +++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py index d23d2e3b797..cb5bfe59f6c 100644 --- a/astrbot/core/star/plugin_categories.py +++ b/astrbot/core/star/plugin_categories.py @@ -15,18 +15,20 @@ "ai_image", "ai_speech", "ai_agent", - "platform_adapter", - "media_processing", - "automation", - "security", + "ai_context", "long_term_memory", "knowledge_base", "tools", + "productivity", + "utilities", "integrations", + "platform_adapter", + "media_processing", + "automation", + "security", "entertainment", "group_games", - "productivity", - "utilities", + "game_integration", "other", ) """Supported ``metadata.yaml`` ``category`` values, in display order.""" diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index bdb222483c0..865cd48bebd 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -157,6 +157,7 @@ "ai_image": "AI Image", "ai_speech": "AI Speech", "ai_agent": "Agents & Orchestration", + "ai_context": "AI Conversation", "platform_adapter": "Platform Adapter", "media_processing": "Media Processing", "automation": "Automation & Scheduling", @@ -164,7 +165,8 @@ "long_term_memory": "Long-term Memory", "knowledge_base": "Knowledge Base", "tools": "Tools", - "group_games": "Group Games" + "group_games": "Group Games", + "game_integration": "Game Integration" }, "showFullName": "Full Name", "devDocs": "Extension Development Docs", diff --git a/dashboard/src/i18n/locales/ja-JP/features/extension.json b/dashboard/src/i18n/locales/ja-JP/features/extension.json index b7b43d8c17a..1652d4e4023 100644 --- a/dashboard/src/i18n/locales/ja-JP/features/extension.json +++ b/dashboard/src/i18n/locales/ja-JP/features/extension.json @@ -157,6 +157,7 @@ "ai_image": "AI 画像", "ai_speech": "AI 音声", "ai_agent": "エージェントと編成", + "ai_context": "AI 会話", "platform_adapter": "プラットフォームアダプター", "media_processing": "メディア処理", "automation": "自動化とスケジュール", @@ -164,7 +165,8 @@ "long_term_memory": "長期記憶", "knowledge_base": "ナレッジベース", "tools": "ツール", - "group_games": "グループゲーム" + "group_games": "グループゲーム", + "game_integration": "ゲーム連携" }, "showFullName": "正式名称", "devDocs": "プラグイン開発ドキュメント", diff --git a/dashboard/src/i18n/locales/ru-RU/features/extension.json b/dashboard/src/i18n/locales/ru-RU/features/extension.json index 68c37e4f2be..dd404f69a5c 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/extension.json +++ b/dashboard/src/i18n/locales/ru-RU/features/extension.json @@ -157,6 +157,7 @@ "ai_image": "AI-изображения", "ai_speech": "AI-речь", "ai_agent": "Агенты и оркестрация", + "ai_context": "AI-диалог", "platform_adapter": "Адаптер платформы", "media_processing": "Обработка медиа", "automation": "Автоматизация и расписание", @@ -164,7 +165,8 @@ "long_term_memory": "Долговременная память", "knowledge_base": "База знаний", "tools": "Инструменты", - "group_games": "Групповые игры" + "group_games": "Групповые игры", + "game_integration": "Игровые интеграции" }, "showFullName": "Полное имя", "devDocs": "Документация для разработчиков", diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index 903954cf6cf..59d72304e93 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -157,6 +157,7 @@ "ai_image": "AI 绘图", "ai_speech": "AI 语音", "ai_agent": "智能体与编排", + "ai_context": "AI 对话", "platform_adapter": "平台适配器", "media_processing": "媒体处理", "automation": "自动化与定时", @@ -164,7 +165,8 @@ "long_term_memory": "长期记忆", "knowledge_base": "知识库", "tools": "工具", - "group_games": "群游戏" + "group_games": "群游戏", + "game_integration": "游戏接入" }, "showFullName": "完整名称", "devDocs": "插件开发文档", From b513823941f2ec766c9897bc31836a1d40081c49 Mon Sep 17 00:00:00 2001 From: XTsat Date: Wed, 11 Nov 2026 23:39:17 +0800 Subject: [PATCH 06/16] docs: clarify the plugin category guidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- docs/en/dev/star/plugin-new.md | 56 +++++++++++++++++++--------------- docs/en/use/plugin.md | 2 +- docs/zh/dev/star/plugin-new.md | 56 +++++++++++++++++++--------------- docs/zh/use/plugin.md | 2 +- 4 files changed, 64 insertions(+), 52 deletions(-) diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index a0da3258165..66774e8e398 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -1,5 +1,9 @@ --- outline: deep +head: + - - style + - {} + - '.vp-doc table:has(thead th:nth-child(3)) th:nth-child(-n + 2), .vp-doc table:has(thead th:nth-child(3)) td:nth-child(-n + 2) { white-space: nowrap; }' --- # AstrBot Plugin Development Guide 🌠 @@ -143,35 +147,37 @@ In the WebUI installation flow, you can choose to "Ignore Warning and Install" t ### Declare Plugin Category (Optional) -You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The plugin marketplace, the WebUI and the runtime all follow this field instead of a category assigned during manual review. +You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The plugin marketplace, the WebUI and the runtime all follow this field. ```yaml -category: media_processing +category: media processing ``` -`category` must be one of the following identifiers (case-insensitive; localized names are not accepted): - -| Identifier | Meaning | -| --- | --- | -| `ai_tools` | AI enhancement | -| `ai_image` | AI image generation | -| `ai_speech` | AI speech | -| `ai_agent` | Agents and orchestration | -| `platform_adapter` | Platform adapter | -| `media_processing` | Media processing | -| `automation` | Automation and scheduling | -| `security` | Security and moderation | -| `long_term_memory` | Long-term memory | -| `knowledge_base` | Knowledge base | -| `tools` | Tools | -| `integrations` | Third-party integrations | -| `entertainment` | Entertainment | -| `group_games` | Group games | -| `productivity` | Productivity | -| `utilities` | Utilities | -| `other` | Other | - -Declarations are lightly normalized: surrounding whitespace, letter case and `-`/space separators are ignored, so `AI Tools`, `ai-tools` and `ai_tools` are equivalent. +`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 | +| --- | --- | --- | +| `ai tools` | AI Tools | One-shot text abilities on top of an LLM: prompts, rewriting, summarizing and translation | +| `ai image` | AI Image | Text-to-image, image-to-image, style transfer and image editing | +| `ai speech` | AI Speech | TTS and ASR: speech synthesis, voices and tone, speech recognition | +| `ai agent` | Agents & Orchestration | Agent runs, tool calling, multi-agent and workflow orchestration | +| `ai context` | AI Conversation | Cross-turn conversation context: persona and character settings, context compression and injection, reply style and tone; stored memories belong to Long-term Memory, external documents to Knowledge Base | +| `long term memory` | Long-term Memory | Storing and recalling memories, user profiles and long-lived context | +| `knowledge base` | Knowledge Base | Ingesting documents and retrieval QA (RAG), knowledge base management | +| `tools` | Tools | General utilities and command sets: encoding and format conversion, calculation, short links, batch work | +| `productivity` | Productivity | To-dos, schedules, notes and personal workflows | +| `utilities` | Utilities | Everyday lookups and reminders: weather, exchange rates, parcels, almanac, unit conversion | +| `integrations` | Integrations | Wiring a third-party platform or account: GitHub, cloud drives, RSS, music, Notion | +| `platform adapter` | Platform Adapter | New messaging platforms or protocols, such as QQ, Telegram and Discord | +| `media processing` | Media Processing | Parsing, transcoding, joining and sticker generation for images, audio and video | +| `automation` | Automation & Scheduling | Scheduled pushes, auto replies and event-driven flows | +| `security` | Security & Moderation | Content moderation, anti-spam, word filters, permissions and risk control | +| `entertainment` | Entertainment | Generic fun that is not a game: tarot, fortune telling, song requests, stickers, memes and playful chat | +| `group games` | Group Games | Played inside the group chat with rules the plugin implements itself: word chains, word guessing, who-is-the-spy, dice and quizzes | +| `game integration` | Game Integration | Plugins built around another game: connectors, wikis and data lookups, server status and player actions (Minecraft, Palworld, Steam) | +| `other` | Other | Anything that does not fit the categories above | + +Declarations are lightly normalized: surrounding whitespace, letter case and space, `-` or `_` separators are ignored, so the underscore spelling works too: `ai tools`, `AI Tools`, `ai-tools` and `ai_tools` are equivalent. Plugins that do not declare `category` are grouped under `other`. An unsupported value only logs a warning and is also grouped under `other`; it never blocks installation or updates. Adding a new category requires a code change in AstrBot, so prefer the identifiers above. diff --git a/docs/en/use/plugin.md b/docs/en/use/plugin.md index 82b5bdb8ab2..b30d2b134ad 100644 --- a/docs/en/use/plugin.md +++ b/docs/en/use/plugin.md @@ -43,7 +43,7 @@ The same workspace has **Skills**, **MCP Servers**, and **Handlers** tabs for sk ### 2. Choose a suitable plugin -Search by plugin name or a keyword describing the feature you want. You can also filter by categories such as AI enhancement, entertainment, productivity, integrations, utilities, and others. Open a plugin's details and check: +Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Tools, AI Image, Entertainment, Group Games, Integrations, Utilities and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow. Open a plugin's details and check: - **Features and usage**: whether it meets your needs and whether you use it through commands, natural language, or another trigger. - **Supported platforms**: whether it works with your messaging platform. Some features depend on platform-specific APIs. diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index 904ecfbd35a..f15b0fbbe01 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -1,5 +1,9 @@ --- outline: deep +head: + - - style + - {} + - '.vp-doc table:has(thead th:nth-child(3)) th:nth-child(-n + 2), .vp-doc table:has(thead th:nth-child(3)) td:nth-child(-n + 2) { white-space: nowrap; }' --- # AstrBot 插件开发指南 🌠 @@ -145,35 +149,37 @@ astrbot_version: ">=4.16,<5" ### 声明插件分类(Optional) -你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。插件市场、WebUI 与运行时都会以该字段为准,不再由审核人工指定分类。 +你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。插件市场、WebUI 与运行时都会以该字段为准。 ```yaml -category: media_processing +category: media processing ``` -`category` 必须是下列英文标识之一(区分不了大小写,写中文不会被识别): - -| 标识 | 含义 | -| --- | --- | -| `ai_tools` | AI 增强 | -| `ai_image` | AI 绘图 | -| `ai_speech` | AI 语音 | -| `ai_agent` | 智能体与编排 | -| `platform_adapter` | 平台适配器 | -| `media_processing` | 媒体处理 | -| `automation` | 自动化与定时 | -| `security` | 安全与审核 | -| `long_term_memory` | 长期记忆 | -| `knowledge_base` | 知识库 | -| `tools` | 工具 | -| `integrations` | 三方集成 | -| `entertainment` | 娱乐 | -| `group_games` | 群游戏 | -| `productivity` | 效率 | -| `utilities` | 生活实用 | -| `other` | 其他 | - -取值会做轻度归一化:首尾空格、大小写以及 `-`、空格分隔符都会被忽略,因此 `AI Tools`、`ai-tools` 与 `ai_tools` 等价。 +`category` 取值为下列英文标识之一。中文翻译只是界面上的展示文案,写进 `category` 不会被识别。 + +| 标识 | 中文翻译 | 适用插件 | +| --- | --- | --- | +| `ai tools` | AI 增强 | 基于大模型的单次文本能力:提示词、文本改写、总结与翻译 | +| `ai image` | AI 绘图 | 文生图、图生图、画风转换与图片编辑 | +| `ai speech` | AI 语音 | TTS 与 ASR:语音合成、音色与语气、语音识别 | +| `ai agent` | 智能体与编排 | Agent 运行、工具调用、多智能体与工作流编排 | +| `ai context` | AI 对话 | 跨轮次的对话语境:人设与角色设定、上下文压缩与注入、对话风格与情绪语气;记忆存储归「长期记忆」,读外部文档归「知识库」 | +| `long term memory` | 长期记忆 | 记忆的存储与召回、用户画像与长期上下文 | +| `knowledge base` | 知识库 | 文档入库与检索问答(RAG)、知识库管理 | +| `tools` | 工具 | 通用小工具与命令集合:编码与格式转换、计算、短链、批量处理 | +| `productivity` | 效率 | 待办、日程、笔记与个人工作流 | +| `utilities` | 生活实用 | 生活信息查询与提醒:天气、汇率、快递、黄历、单位换算 | +| `integrations` | 外部集成 | 打通第三方平台或服务账号:GitHub、网盘、RSS、音乐、Notion | +| `platform adapter` | 平台适配器 | 接入新的消息平台或协议,如 QQ、Telegram、Discord | +| `media processing` | 媒体处理 | 图片、音频、视频的解析、转码、拼接与表情包生成 | +| `automation` | 自动化与定时 | 定时推送、自动回复、由事件触发的自动化流程 | +| `security` | 安全与审核 | 内容审核、反垃圾、敏感词、权限与风控 | +| `entertainment` | 娱乐 | 普通泛娱乐,不含游戏:塔罗、运势、点歌、表情包、梗图、玩梗闲聊 | +| `group games` | 群游戏 | 直接在群里玩、玩法由插件自身实现:接龙、猜词、谁是卧底、掷骰、答题 | +| `game integration` | 游戏接入 | 围绕别的游戏的外围插件:连接器、Wiki 与资料查询、服务器状态与玩家操作(Minecraft、幻兽帕鲁、Steam) | +| `other` | 其他 | 无法归入以上任一类的插件 | + +取值会做轻度归一化:首尾空格、大小写以及空格、`-`、`_` 三种分隔符都会被忽略,所以下划线写法同样能识别,`ai tools`、`AI Tools`、`ai-tools` 与 `ai_tools` 等价。 未声明 `category` 的插件会归入 `other`。如果写了不支持的分类,AstrBot 会在日志中给出告警并同样归入 `other`,但**不会**阻止插件安装或更新。新增分类需要修改 AstrBot 源码,因此请优先使用上表中的标识。 diff --git a/docs/zh/use/plugin.md b/docs/zh/use/plugin.md index 3c60a8a486b..50fde128cee 100644 --- a/docs/zh/use/plugin.md +++ b/docs/zh/use/plugin.md @@ -43,7 +43,7 @@ AstrBot 负责接收消息、连接模型、管理对话等基础工作;插件 ### 2. 找到合适的插件 -在市场搜索框中输入插件名称或功能关键词,也可以按 **AI 增强、娱乐、效率、外部集成、生活实用、其他** 分类筛选。点击感兴趣的插件查看详情,先确认: +在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 增强、AI 绘图、娱乐、群游戏、外部集成、生活实用、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开。点击感兴趣的插件查看详情,先确认: - **功能和用法**:是否解决你的需求,安装后通过指令、自然语言还是其他方式使用。 - **支持平台**:是否支持你接入的消息平台。某些功能依赖特定平台的接口。 From 8e743f61a1359ccd120acc839961a2f45b826b50 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 00:21:28 +0800 Subject: [PATCH 07/16] refactor(dashboard): take market category labels from the slug 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. --- .../src/views/extension/useExtensionPage.js | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index cf56d10c203..db215d74736 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -250,28 +250,13 @@ export const useExtensionPage = (initialTab = "installed") => { return slug; }; - const getMarketCategoryLabel = (key, rawCategory = "") => { - const fallbackMap = { - all: "All", - ai_tools: "AI Tools", - entertainment: "Entertainment", - productivity: "Productivity", - integrations: "Integrations", - utilities: "Utilities", - other: "Other", - }; - const i18nKey = `market.categories.${key}`; - const translated = tm(i18nKey); + const getMarketCategoryLabel = (key) => { + const translated = tm(`market.categories.${key}`); if (translated && !translated.includes("[MISSING:")) { return translated; } - if (fallbackMap[key]) { - return fallbackMap[key]; - } - const normalizedRaw = String(rawCategory || "").trim(); - if (normalizedRaw) { - return normalizedRaw; - } + // A missing label still renders as words instead of the raw identifier, so + // an ad-hoc marketplace category never shows up as a slug. return key .split(/[_-]+/) .filter(Boolean) @@ -289,10 +274,7 @@ export const useExtensionPage = (initialTab = "installed") => { categoryData.count += 1; continue; } - categories.set(categoryKey, { - count: 1, - rawLabel: String(plugin?.category || "").trim(), - }); + categories.set(categoryKey, { count: 1 }); } return categories; @@ -332,7 +314,7 @@ export const useExtensionPage = (initialTab = "installed") => { } items.push({ value: categoryKey, - label: getMarketCategoryLabel(categoryKey, categoryData.rawLabel), + label: getMarketCategoryLabel(categoryKey), count: categoryData.count, }); } From 28b5b1c3b34d0ebc020d6d0736f0d248609b8fa8 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 00:21:32 +0800 Subject: [PATCH 08/16] refactor(plugin): shorten the unsupported category warning 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. --- astrbot/core/star/plugin_categories.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py index cb5bfe59f6c..345119467bf 100644 --- a/astrbot/core/star/plugin_categories.py +++ b/astrbot/core/star/plugin_categories.py @@ -69,7 +69,6 @@ def normalize_plugin_category(value: object, *, warn: bool = True) -> str | None logger.warning( f"Unsupported plugin category {value!r}; falling back to " - f"{DEFAULT_PLUGIN_CATEGORY!r}. Supported categories: " - f"{', '.join(PLUGIN_CATEGORY_SLUGS)}." + f"{DEFAULT_PLUGIN_CATEGORY!r}." ) return DEFAULT_PLUGIN_CATEGORY From 5bae554f489045f956b29a06a41c0b5cac0f45a1 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 10:01:23 +0800 Subject: [PATCH 09/16] chore(i18n): drop the unused market category label --- dashboard/src/i18n/locales/en-US/features/extension.json | 1 - dashboard/src/i18n/locales/ja-JP/features/extension.json | 1 - dashboard/src/i18n/locales/ru-RU/features/extension.json | 1 - dashboard/src/i18n/locales/zh-CN/features/extension.json | 1 - 4 files changed, 4 deletions(-) diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index 865cd48bebd..f11406f9841 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -142,7 +142,6 @@ }, "market": { "recommended": "🥳 Recommended", - "category": "Category", "expandCategories": "Show all categories", "collapseCategories": "Collapse categories", "refresh": "Refresh", diff --git a/dashboard/src/i18n/locales/ja-JP/features/extension.json b/dashboard/src/i18n/locales/ja-JP/features/extension.json index 1652d4e4023..11b3c6cd170 100644 --- a/dashboard/src/i18n/locales/ja-JP/features/extension.json +++ b/dashboard/src/i18n/locales/ja-JP/features/extension.json @@ -142,7 +142,6 @@ }, "market": { "recommended": "🥳 おすすめ", - "category": "カテゴリ", "expandCategories": "すべてのカテゴリを表示", "collapseCategories": "カテゴリを折りたたむ", "refresh": "更新", diff --git a/dashboard/src/i18n/locales/ru-RU/features/extension.json b/dashboard/src/i18n/locales/ru-RU/features/extension.json index dd404f69a5c..6a05eca6233 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/extension.json +++ b/dashboard/src/i18n/locales/ru-RU/features/extension.json @@ -142,7 +142,6 @@ }, "market": { "recommended": "🥳 Рекомендуем", - "category": "Категория", "expandCategories": "Показать все категории", "collapseCategories": "Свернуть категории", "refresh": "Обновить", diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index 59d72304e93..250c33611d1 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -142,7 +142,6 @@ }, "market": { "recommended": "🥳 推荐", - "category": "分类", "expandCategories": "展开全部分类", "collapseCategories": "收起分类", "refresh": "刷新", From c9bba0704791d5d233883212627269d25949941e Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 10:48:56 +0800 Subject: [PATCH 10/16] fix(plugin): align category normalization with the dashboard - 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. --- astrbot/core/star/plugin_categories.py | 6 +- astrbot/core/star/star.py | 8 +- .../src/views/extension/useExtensionPage.js | 5 +- tests/test_plugin_manager.py | 18 +++- tests/unit/test_plugin_categories.py | 88 ------------------- 5 files changed, 29 insertions(+), 96 deletions(-) delete mode 100644 tests/unit/test_plugin_categories.py diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py index 345119467bf..7c96822d29c 100644 --- a/astrbot/core/star/plugin_categories.py +++ b/astrbot/core/star/plugin_categories.py @@ -8,6 +8,8 @@ from __future__ import annotations +import re + from astrbot.core import logger PLUGIN_CATEGORY_SLUGS: tuple[str, ...] = ( @@ -58,7 +60,9 @@ def normalize_plugin_category(value: object, *, warn: bool = True) -> str | None return None if isinstance(value, str): - slug = value.strip().lower().replace("-", "_").replace(" ", "_") + # Collapse separator runs so that "AI - Tools" matches what the WebUI + # derives from the same declaration instead of falling back to "other". + slug = re.sub(r"[\s-]+", "_", value.strip().lower()) if slug in PLUGIN_CATEGORY_SLUGS: return slug if not slug: diff --git a/astrbot/core/star/star.py b/astrbot/core/star/star.py index 2fc73c44fb2..274f7238136 100644 --- a/astrbot/core/star/star.py +++ b/astrbot/core/star/star.py @@ -69,15 +69,17 @@ class StarMetadata: 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 分组。""" views: list[dict] = field(default_factory=list) """插件注册的 Views 元数据。""" + # Appended last on purpose: StarMetadata is constructed positionally by + # external consumers, so new fields must not shift existing ones. + category: str | None = None + """Plugin market category slug declared in metadata (None when undeclared).""" + @property def plugin_id(self) -> str: p_name = (self.name or "unknown").lower().replace("/", "_") diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index db215d74736..039924b23ce 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -2380,7 +2380,10 @@ export const useExtensionPage = (initialTab = "installed") => { } loading_.value = true; try { - await loadMarketCategories(); + // Not awaited: the category vocabulary only refines ordering and the + // unknown-slug fallback, so a slow or stalled request must not hold back + // the plugin lists (the filter reacts to the ref once it arrives). + void loadMarketCategories(); await getExtensions({ withLoading: false }); // 检查是否有 open_config 参数 diff --git a/tests/test_plugin_manager.py b/tests/test_plugin_manager.py index 15a5bb499ef..bf03f32de32 100644 --- a/tests/test_plugin_manager.py +++ b/tests/test_plugin_manager.py @@ -212,15 +212,27 @@ def test_load_plugin_metadata_includes_category(tmp_path: Path): assert loaded_metadata.category == "platform_adapter" -def test_load_plugin_metadata_normalizes_category(tmp_path: Path): +@pytest.mark.parametrize( + ("declared", "expected"), + [ + ("Group Games", "group_games"), + ("platform-adapter", "platform_adapter"), + # Repeated and mixed separators must normalize like the WebUI does. + ("AI - Tools", "ai_tools"), + (" long-term memory ", "long_term_memory"), + ], +) +def test_load_plugin_metadata_normalizes_category( + tmp_path: Path, declared: str, expected: str +): plugin_path = tmp_path / "helloworld" _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) - _write_plugin_category(plugin_path, "Group Games") + _write_plugin_category(plugin_path, declared) loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) assert loaded_metadata is not None - assert loaded_metadata.category == "group_games" + assert loaded_metadata.category == expected def test_load_plugin_metadata_unknown_category_falls_back_to_other(tmp_path: Path): diff --git a/tests/unit/test_plugin_categories.py b/tests/unit/test_plugin_categories.py deleted file mode 100644 index fe1819ba0e7..00000000000 --- a/tests/unit/test_plugin_categories.py +++ /dev/null @@ -1,88 +0,0 @@ -"""Tests for astrbot.core.star.plugin_categories module.""" - -import pytest - -from astrbot.core.star import plugin_categories -from astrbot.core.star.plugin_categories import ( - DEFAULT_PLUGIN_CATEGORY, - PLUGIN_CATEGORY_SLUGS, - normalize_plugin_category, -) - - -class TestNormalizePluginCategory: - """Test cases for normalize_plugin_category.""" - - @pytest.mark.parametrize("slug", PLUGIN_CATEGORY_SLUGS) - def test_accepts_supported_slug(self, slug: str): - """Every supported slug is returned unchanged.""" - assert normalize_plugin_category(slug) == slug - - @pytest.mark.parametrize( - ("raw", "expected"), - [ - (" ai_tools ", "ai_tools"), - ("AI_TOOLS", "ai_tools"), - ("AI Tools", "ai_tools"), - ("ai-tools", "ai_tools"), - ("Long-term Memory", "long_term_memory"), - ], - ) - def test_normalizes_slug_spelling(self, raw: str, expected: str): - """Case, whitespace and separators do not change the resulting slug.""" - assert normalize_plugin_category(raw) == expected - - @pytest.mark.parametrize("raw", [None, "", " "]) - def test_missing_category_stays_undeclared(self, raw): - """An absent category is reported as None instead of the fallback.""" - assert normalize_plugin_category(raw) is None - - @pytest.mark.parametrize( - "raw", - ["not_a_category", "工具", 1, ["ai_tools"], {"name": "ai_tools"}], - ) - def test_unsupported_category_falls_back(self, raw): - """Unsupported values degrade to the fallback category.""" - assert normalize_plugin_category(raw) == DEFAULT_PLUGIN_CATEGORY - - def test_unsupported_category_warns(self, monkeypatch: pytest.MonkeyPatch): - """Degrading an unsupported value is reported in the log.""" - warnings: list[str] = [] - monkeypatch.setattr( - plugin_categories.logger, - "warning", - lambda message: warnings.append(message), - ) - - assert normalize_plugin_category("Not A Category") == DEFAULT_PLUGIN_CATEGORY - assert len(warnings) == 1 - assert "Not A Category" in warnings[0] - - def test_unsupported_category_can_skip_the_warning( - self, monkeypatch: pytest.MonkeyPatch - ): - """Callers that already validated the metadata can suppress the report.""" - warnings: list[str] = [] - monkeypatch.setattr( - plugin_categories.logger, - "warning", - lambda message: warnings.append(message), - ) - - assert ( - normalize_plugin_category("Not A Category", warn=False) - == DEFAULT_PLUGIN_CATEGORY - ) - assert warnings == [] - - def test_supported_category_does_not_warn(self, monkeypatch: pytest.MonkeyPatch): - """A supported category is accepted silently.""" - warnings: list[str] = [] - monkeypatch.setattr( - plugin_categories.logger, - "warning", - lambda message: warnings.append(message), - ) - - assert normalize_plugin_category("tools") == "tools" - assert warnings == [] From ab992d729ccdb7249dcd3d90872606a8f1da28f7 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 10:49:02 +0800 Subject: [PATCH 11/16] docs: clarify the plugin category declaration and the filter move - 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. --- changelogs/unreleased.md | 1 + docs/en/dev/star/plugin-new.md | 4 ++-- docs/en/use/plugin.md | 2 +- docs/zh/dev/star/plugin-new.md | 2 +- docs/zh/use/plugin.md | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/changelogs/unreleased.md b/changelogs/unreleased.md index b06e68235cc..a5c9949306a 100644 --- a/changelogs/unreleased.md +++ b/changelogs/unreleased.md @@ -1,3 +1,4 @@ # Unreleased - QQ Official: a failed image upload no longer dumps the base64 payload into the log (a single multi-MB line could freeze log writing and the web dashboard), and image upload retries drop from 5 to 3 with a single summary warning instead of one per attempt. +- Plugin market: plugins can now declare a marketplace category in `metadata.yaml` (canonical identifiers served by the plugin API, unknown values log a warning and fall back to `other` without blocking installation or updates), and the WebUI category filter moved from the toolbar dropdown to a chip row above the plugin list (old entry: Extensions → Plugin Market → toolbar "Category" dropdown; new entry: Extensions → Plugin Market → category row above the list). diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index 66774e8e398..1f0dc279357 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -147,13 +147,13 @@ In the WebUI installation flow, you can choose to "Ignore Warning and Install" t ### Declare Plugin Category (Optional) -You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The plugin marketplace, the WebUI and the runtime all follow this field. +You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The WebUI and the runtime follow this field. What the plugin marketplace shows depends on whether the market index copied the value, which happens when the index is updated, so editing `metadata.yaml` alone does not change the marketplace listing right away. ```yaml 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. +`category` takes one of the following identifiers. Only the identifier column is canonical: the localized labels are display text, so the Chinese translation is not recognized, while an English spelling that normalizes to a supported identifier (such as `AI Tools`) is accepted. | Identifier | English label | Use it for | | --- | --- | --- | diff --git a/docs/en/use/plugin.md b/docs/en/use/plugin.md index b30d2b134ad..c3288815a20 100644 --- a/docs/en/use/plugin.md +++ b/docs/en/use/plugin.md @@ -43,7 +43,7 @@ The same workspace has **Skills**, **MCP Servers**, and **Handlers** tabs for sk ### 2. Choose a suitable plugin -Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Tools, AI Image, Entertainment, Group Games, Integrations, Utilities and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow. Open a plugin's details and check: +Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Tools, AI Image, Entertainment, Group Games, Integrations, Utilities and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow (the category dropdown that used to sit in the toolbar has moved to this row above the list). Open a plugin's details and check: - **Features and usage**: whether it meets your needs and whether you use it through commands, natural language, or another trigger. - **Supported platforms**: whether it works with your messaging platform. Some features depend on platform-specific APIs. diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index f15b0fbbe01..e46c969285e 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -149,7 +149,7 @@ astrbot_version: ">=4.16,<5" ### 声明插件分类(Optional) -你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。插件市场、WebUI 与运行时都会以该字段为准。 +你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。WebUI 与运行时都以该字段为准;插件市场里显示的分类取决于市场索引是否收录了该值,索引收录时会复制这个字段,因此只改 `metadata.yaml` 不会立刻改变市场展示。 ```yaml category: media processing diff --git a/docs/zh/use/plugin.md b/docs/zh/use/plugin.md index 50fde128cee..6ba59cc5f24 100644 --- a/docs/zh/use/plugin.md +++ b/docs/zh/use/plugin.md @@ -43,7 +43,7 @@ AstrBot 负责接收消息、连接模型、管理对话等基础工作;插件 ### 2. 找到合适的插件 -在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 增强、AI 绘图、娱乐、群游戏、外部集成、生活实用、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开。点击感兴趣的插件查看详情,先确认: +在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 增强、AI 绘图、娱乐、群游戏、外部集成、生活实用、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开(原先位于工具栏的「分类」下拉框,现已移到插件列表上方的分类条)。点击感兴趣的插件查看详情,先确认: - **功能和用法**:是否解决你的需求,安装后通过指令、自然语言还是其他方式使用。 - **支持平台**:是否支持你接入的消息平台。某些功能依赖特定平台的接口。 From 07f6ee91f0f4502c6d6abca33bc5bf11340167e3 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 13:59:52 +0800 Subject: [PATCH 12/16] docs: spell out the marketplace category index path - 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. --- dashboard/src/views/extension/useExtensionPage.js | 5 ++++- docs/en/dev/plugin-market/2026-06-27.md | 2 ++ docs/zh/dev/plugin-market/2026-06-27.md | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index 039924b23ce..b5e82bf0126 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -240,7 +240,10 @@ export const useExtensionPage = (initialTab = "installed") => { } 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. + // a marketplace index cannot create a one-off filter entry. An empty + // vocabulary means the canonical list is unknown (still loading, or an + // older backend), not that nothing is valid, so the discovered values are + // kept: folding them into "other" would leave the filter with one category. if ( marketCategorySlugs.value.length > 0 && !marketCategorySlugs.value.includes(slug) diff --git a/docs/en/dev/plugin-market/2026-06-27.md b/docs/en/dev/plugin-market/2026-06-27.md index a04bd07e7a9..22b813ce70b 100644 --- a/docs/en/dev/plugin-market/2026-06-27.md +++ b/docs/en/dev/plugin-market/2026-06-27.md @@ -160,6 +160,8 @@ Each `PluginRecord` MUST contain: The `category` value comes from the same field declared in the plugin repository's `metadata.yaml` and is limited to the categories AstrBot supports (see [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional)). The marketplace copies the declared value verbatim; undeclared or unsupported values become `other`. +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 `ai_tools`) into the index `category` field. A plugin author editing `metadata.yaml` does not change the index by itself: the marketplace filter only reflects the new category once the index is updated. When the two disagree, the marketplace follows the index while the WebUI and the runtime follow `metadata.yaml`. + ### 7.1. Repository URL `repo` MUST be one of: diff --git a/docs/zh/dev/plugin-market/2026-06-27.md b/docs/zh/dev/plugin-market/2026-06-27.md index b6934397d67..f85d0e60807 100644 --- a/docs/zh/dev/plugin-market/2026-06-27.md +++ b/docs/zh/dev/plugin-market/2026-06-27.md @@ -160,6 +160,8 @@ metadata.author + "/" + metadata.name `category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段,取值限于 AstrBot 支持的分类标识(见[声明插件分类](../star/plugin-new.md#声明插件分类-optional))。市场收录时直接复制该值,未声明或不支持的取值统一为 `other`。 +索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `ai_tools`)写入索引的 `category` 字段;插件作者只改 `metadata.yaml` 不会自动改动索引,需要等索引随之更新后,市场筛选才会体现新分类。`metadata.yaml` 与索引记录不一致时,市场以索引为准,WebUI 与运行时以 `metadata.yaml` 为准。 + ### 7.1. 仓库 URL `repo` 必须是以下之一: From ef3d03440f395444a82250701cd28533bbc495b6 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 14:08:04 +0800 Subject: [PATCH 13/16] docs: state that metadata.yaml is the authoritative category source The index holds a snapshot copied at collection time, so a disagreement means the snapshot is stale rather than the index overriding metadata.yaml. --- docs/en/dev/plugin-market/2026-06-27.md | 2 +- docs/zh/dev/plugin-market/2026-06-27.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/dev/plugin-market/2026-06-27.md b/docs/en/dev/plugin-market/2026-06-27.md index 22b813ce70b..6ee4d7c9b82 100644 --- a/docs/en/dev/plugin-market/2026-06-27.md +++ b/docs/en/dev/plugin-market/2026-06-27.md @@ -160,7 +160,7 @@ Each `PluginRecord` MUST contain: The `category` value comes from the same field declared in the plugin repository's `metadata.yaml` and is limited to the categories AstrBot supports (see [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional)). The marketplace copies the declared value verbatim; undeclared or unsupported values become `other`. -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 `ai_tools`) into the index `category` field. A plugin author editing `metadata.yaml` does not change the index by itself: the marketplace filter only reflects the new category once the index is updated. When the two disagree, the marketplace follows the index while the WebUI and the runtime follow `metadata.yaml`. +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 `ai_tools`) 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. ### 7.1. Repository URL diff --git a/docs/zh/dev/plugin-market/2026-06-27.md b/docs/zh/dev/plugin-market/2026-06-27.md index f85d0e60807..001e95d5c58 100644 --- a/docs/zh/dev/plugin-market/2026-06-27.md +++ b/docs/zh/dev/plugin-market/2026-06-27.md @@ -160,7 +160,7 @@ metadata.author + "/" + metadata.name `category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段,取值限于 AstrBot 支持的分类标识(见[声明插件分类](../star/plugin-new.md#声明插件分类-optional))。市场收录时直接复制该值,未声明或不支持的取值统一为 `other`。 -索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `ai_tools`)写入索引的 `category` 字段;插件作者只改 `metadata.yaml` 不会自动改动索引,需要等索引随之更新后,市场筛选才会体现新分类。`metadata.yaml` 与索引记录不一致时,市场以索引为准,WebUI 与运行时以 `metadata.yaml` 为准。 +索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `ai_tools`)写入索引的 `category` 字段。`metadata.yaml` 是分类的唯一权威来源,索引里的 `category` 只是收录时复制的快照;两者不一致说明索引尚未随声明更新(快照过期),此时市场会继续显示旧分类,直到索引重新收录。运行时与 WebUI 中的已安装插件始终直接读取 `metadata.yaml`,不受索引影响。 ### 7.1. 仓库 URL From adc75c5959894f177c5941cc2140cc35e469a0a5 Mon Sep 17 00:00:00 2001 From: XTsat Date: Thu, 12 Nov 2026 16:58:03 +0800 Subject: [PATCH 14/16] docs: fix the plugin metadata sample in the publish guide - 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. --- docs/en/dev/star/plugin-publish.md | 8 +++++--- docs/zh/dev/star/plugin-publish.md | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/en/dev/star/plugin-publish.md b/docs/en/dev/star/plugin-publish.md index 965a7aeb95d..4556abe94c2 100644 --- a/docs/en/dev/star/plugin-publish.md +++ b/docs/en/dev/star/plugin-publish.md @@ -12,23 +12,25 @@ Here is a complete plugin metadata example (`metadata.yaml`) that the system wil ```yaml name: astrbot_plugin_example # Plugin identifier, English, unique -display_name: Plugin Display Name # Plugin display name +display_name: Plugin Display Name # (Optional) Plugin display name # short_desc: A one-line summary of your plugin # (Optional) Short description for compact UI desc: Detailed description of your plugin's features, usage, etc. # Detailed plugin description Supports multi-line text with Markdown formatting. version: 1.0.0 # Plugin version (follow semantic versioning) author: Author Name # Author name repo: https://github.com/your-name/repo # Plugin repository URL -# category: tools # (Optional) Marketplace category, see docs below +# category: other # (Optional) Marketplace category # astrbot_version: ">=4.17.0" # (Optional) AstrBot version range # support_platforms: # (Optional) Supported platform adapter list # - aiocqhttp # - qq_official # social_link: https://github.com/your-web # (Optional) Your personal website, GitHub profile, etc. -# tags: # (Optional) Tag list for marketplace categorization and search +# tags: # (Optional) Tag list, matched by marketplace search # - example ``` +[Available marketplace categories](plugin-new.md#declare-plugin-category-optional) + [Supported platform adapters](plugin-new.md#declare-supported-platforms-optional) ::: warning Size Limit diff --git a/docs/zh/dev/star/plugin-publish.md b/docs/zh/dev/star/plugin-publish.md index 57c1539771e..a5a6e2c81a0 100644 --- a/docs/zh/dev/star/plugin-publish.md +++ b/docs/zh/dev/star/plugin-publish.md @@ -12,23 +12,25 @@ AstrBot 使用 GitHub 托管插件,因此你需要先将插件代码推送到 ```yaml name: astrbot_plugin_example # 插件标识符,英文,唯一 -display_name: 示例插件名称 # 插件展示名称 +display_name: 示例插件名称 # (可选)插件展示名称 # short_desc: 一句话介绍你的插件功能 # (可选)紧凑 UI 使用的短描述 desc: 详细描述插件的功能、特性、使用方法等信息。 # 详细描述插件的信息 可以写多行文本,支持 Markdown 格式。 version: 1.0.0 # 插件版本号(遵循语义化版本规范) author: 作者名称 # 作者名称 repo: https://github.com/your-name/repo # 插件仓库地址 -# category: tools # (可选)插件市场分类,标识见下方文档 +# category: other # (可选)插件市场分类 # astrbot_version: ">=4.17.0" # (可选)支持的 AstrBot 版本范围 # support_platforms: # (可选)支持的平台适配器列表 # - aiocqhttp # - qq_official # social_link: https://github.com/your-web # (可选)你的个人网站、GitHub 主页等 -# tags: # (可选)标签列表,用于插件市场分类和搜索 +# tags: # (可选)标签列表,用于插件市场的搜索匹配 # - example ``` +[目前可用的插件市场分类](plugin-new.md#声明插件分类-optional) + [目前支持的平台适配器](plugin-new.md#声明支持平台-optional) ::: warning 大小限制 From 185a4524b4ee2b11ce29bb1b20308ac3eca9110e Mon Sep 17 00:00:00 2001 From: XTsat Date: Tue, 24 Nov 2026 16:35:22 +0800 Subject: [PATCH 15/16] refactor(plugin): reduce the marketplace category vocabulary to nine 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. --- astrbot/core/star/plugin_categories.py | 20 ++++--------- .../locales/en-US/features/extension.json | 22 ++++---------- .../locales/ja-JP/features/extension.json | 22 ++++---------- .../locales/ru-RU/features/extension.json | 22 ++++---------- .../locales/zh-CN/features/extension.json | 22 ++++---------- docs/en/dev/plugin-market/2026-06-27.md | 2 +- docs/en/dev/star/plugin-new.md | 30 +++++++------------ docs/en/use/plugin.md | 2 +- docs/zh/dev/plugin-market/2026-06-27.md | 2 +- docs/zh/dev/star/plugin-new.md | 28 ++++++----------- docs/zh/use/plugin.md | 2 +- tests/test_plugin_manager.py | 10 +++---- 12 files changed, 57 insertions(+), 127 deletions(-) diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py index 7c96822d29c..d206e547db4 100644 --- a/astrbot/core/star/plugin_categories.py +++ b/astrbot/core/star/plugin_categories.py @@ -13,24 +13,14 @@ from astrbot.core import logger PLUGIN_CATEGORY_SLUGS: tuple[str, ...] = ( - "ai_tools", - "ai_image", - "ai_speech", - "ai_agent", + "utility", "ai_context", - "long_term_memory", - "knowledge_base", - "tools", + "entertainment", + "media", "productivity", - "utilities", - "integrations", + "integration", "platform_adapter", - "media_processing", - "automation", - "security", - "entertainment", - "group_games", - "game_integration", + "provider_adapter", "other", ) """Supported ``metadata.yaml`` ``category`` values, in display order.""" diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index f11406f9841..b8ea9d0e8c0 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -147,25 +147,15 @@ "refresh": "Refresh", "categories": { "all": "All", - "ai_tools": "AI Tools", + "utility": "Utility", + "ai_context": "AI Conversation", "entertainment": "Entertainment", + "media": "Media", "productivity": "Productivity", - "integrations": "Integrations", - "utilities": "Utilities", - "other": "Other", - "ai_image": "AI Image", - "ai_speech": "AI Speech", - "ai_agent": "Agents & Orchestration", - "ai_context": "AI Conversation", + "integration": "Integration", "platform_adapter": "Platform Adapter", - "media_processing": "Media Processing", - "automation": "Automation & Scheduling", - "security": "Security & Moderation", - "long_term_memory": "Long-term Memory", - "knowledge_base": "Knowledge Base", - "tools": "Tools", - "group_games": "Group Games", - "game_integration": "Game Integration" + "provider_adapter": "Provider Adapter", + "other": "Other" }, "showFullName": "Full Name", "devDocs": "Extension Development Docs", diff --git a/dashboard/src/i18n/locales/ja-JP/features/extension.json b/dashboard/src/i18n/locales/ja-JP/features/extension.json index 11b3c6cd170..6d00f113eed 100644 --- a/dashboard/src/i18n/locales/ja-JP/features/extension.json +++ b/dashboard/src/i18n/locales/ja-JP/features/extension.json @@ -147,25 +147,15 @@ "refresh": "更新", "categories": { "all": "すべて", - "ai_tools": "AI ツール", + "utility": "ユーティリティ", + "ai_context": "AI 会話", "entertainment": "エンターテインメント", + "media": "メディア", "productivity": "生産性", - "integrations": "外部連携", - "utilities": "ユーティリティ", - "other": "その他", - "ai_image": "AI 画像", - "ai_speech": "AI 音声", - "ai_agent": "エージェントと編成", - "ai_context": "AI 会話", + "integration": "外部連携", "platform_adapter": "プラットフォームアダプター", - "media_processing": "メディア処理", - "automation": "自動化とスケジュール", - "security": "セキュリティと審査", - "long_term_memory": "長期記憶", - "knowledge_base": "ナレッジベース", - "tools": "ツール", - "group_games": "グループゲーム", - "game_integration": "ゲーム連携" + "provider_adapter": "プロバイダーアダプター", + "other": "その他" }, "showFullName": "正式名称", "devDocs": "プラグイン開発ドキュメント", diff --git a/dashboard/src/i18n/locales/ru-RU/features/extension.json b/dashboard/src/i18n/locales/ru-RU/features/extension.json index 6a05eca6233..980ccd00391 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/extension.json +++ b/dashboard/src/i18n/locales/ru-RU/features/extension.json @@ -147,25 +147,15 @@ "refresh": "Обновить", "categories": { "all": "Все", - "ai_tools": "AI Tools", + "utility": "Утилиты", + "ai_context": "AI-диалог", "entertainment": "Развлечения", + "media": "Медиа", "productivity": "Продуктивность", - "integrations": "Интеграции", - "utilities": "Утилиты", - "other": "Другое", - "ai_image": "AI-изображения", - "ai_speech": "AI-речь", - "ai_agent": "Агенты и оркестрация", - "ai_context": "AI-диалог", + "integration": "Интеграции", "platform_adapter": "Адаптер платформы", - "media_processing": "Обработка медиа", - "automation": "Автоматизация и расписание", - "security": "Безопасность и модерация", - "long_term_memory": "Долговременная память", - "knowledge_base": "База знаний", - "tools": "Инструменты", - "group_games": "Групповые игры", - "game_integration": "Игровые интеграции" + "provider_adapter": "Адаптер провайдера", + "other": "Другое" }, "showFullName": "Полное имя", "devDocs": "Документация для разработчиков", diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index 250c33611d1..0bb4de7160a 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -147,25 +147,15 @@ "refresh": "刷新", "categories": { "all": "全部", - "ai_tools": "AI 增强", + "utility": "实用工具", + "ai_context": "AI 对话", "entertainment": "娱乐", + "media": "媒体", "productivity": "效率", - "integrations": "外部集成", - "utilities": "生活实用", - "other": "其他", - "ai_image": "AI 绘图", - "ai_speech": "AI 语音", - "ai_agent": "智能体与编排", - "ai_context": "AI 对话", + "integration": "外部集成", "platform_adapter": "平台适配器", - "media_processing": "媒体处理", - "automation": "自动化与定时", - "security": "安全与审核", - "long_term_memory": "长期记忆", - "knowledge_base": "知识库", - "tools": "工具", - "group_games": "群游戏", - "game_integration": "游戏接入" + "provider_adapter": "提供商适配器", + "other": "其他" }, "showFullName": "完整名称", "devDocs": "插件开发文档", diff --git a/docs/en/dev/plugin-market/2026-06-27.md b/docs/en/dev/plugin-market/2026-06-27.md index 6ee4d7c9b82..2ce34037f05 100644 --- a/docs/en/dev/plugin-market/2026-06-27.md +++ b/docs/en/dev/plugin-market/2026-06-27.md @@ -160,7 +160,7 @@ Each `PluginRecord` MUST contain: The `category` value comes from the same field declared in the plugin repository's `metadata.yaml` and is limited to the categories AstrBot supports (see [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional)). The marketplace copies the declared value verbatim; undeclared or unsupported values become `other`. -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 `ai_tools`) 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. +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. ### 7.1. Repository URL diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index 6341f3cdfc0..5f592d7c3b8 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -152,34 +152,24 @@ In the WebUI installation flow, you can choose to "Ignore Warning and Install" t You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The WebUI and the runtime follow this field. What the plugin marketplace shows depends on whether the market index copied the value, which happens when the index is updated, so editing `metadata.yaml` alone does not change the marketplace listing right away. ```yaml -category: media processing +category: platform adapter ``` -`category` takes one of the following identifiers. Only the identifier column is canonical: the localized labels are display text, so the Chinese translation is not recognized, while an English spelling that normalizes to a supported identifier (such as `AI Tools`) is accepted. +`category` takes one of the following identifiers. Only the identifier column is canonical: the localized labels are display text, so the Chinese translation is not recognized, while an English spelling that normalizes to a supported identifier (such as `Platform Adapter`) is accepted. | Identifier | English label | Use it for | | --- | --- | --- | -| `ai tools` | AI Tools | One-shot text abilities on top of an LLM: prompts, rewriting, summarizing and translation | -| `ai image` | AI Image | Text-to-image, image-to-image, style transfer and image editing | -| `ai speech` | AI Speech | TTS and ASR: speech synthesis, voices and tone, speech recognition | -| `ai agent` | Agents & Orchestration | Agent runs, tool calling, multi-agent and workflow orchestration | -| `ai context` | AI Conversation | Cross-turn conversation context: persona and character settings, context compression and injection, reply style and tone; stored memories belong to Long-term Memory, external documents to Knowledge Base | -| `long term memory` | Long-term Memory | Storing and recalling memories, user profiles and long-lived context | -| `knowledge base` | Knowledge Base | Ingesting documents and retrieval QA (RAG), knowledge base management | -| `tools` | Tools | General utilities and command sets: encoding and format conversion, calculation, short links, batch work | +| `utility` | Utility | General tools and everyday lookups: encoding and format conversion, calculation, short links, weather, exchange rates, parcels, unit conversion, plus scheduled and automated flows | +| `ai_context` | AI Conversation | Conversation and AI capabilities around it: persona and character settings, context compression and injection, prompts and text rewriting, memory and knowledge base retrieval | +| `entertainment` | Entertainment | Fun and games: tarot, fortune telling, song requests, stickers, memes, playful chat, word chains, word guessing, who-is-the-spy, dice, quizzes, and plugins built around another game | +| `media` | Media | Processing and generation of images, audio and video: parsing, transcoding, joining, stickers, text-to-image, image-to-image, TTS and ASR | | `productivity` | Productivity | To-dos, schedules, notes and personal workflows | -| `utilities` | Utilities | Everyday lookups and reminders: weather, exchange rates, parcels, almanac, unit conversion | -| `integrations` | Integrations | Wiring a third-party platform or account: GitHub, cloud drives, RSS, music, Notion | -| `platform adapter` | Platform Adapter | New messaging platforms or protocols, such as QQ, Telegram and Discord | -| `media processing` | Media Processing | Parsing, transcoding, joining and sticker generation for images, audio and video | -| `automation` | Automation & Scheduling | Scheduled pushes, auto replies and event-driven flows | -| `security` | Security & Moderation | Content moderation, anti-spam, word filters, permissions and risk control | -| `entertainment` | Entertainment | Generic fun that is not a game: tarot, fortune telling, song requests, stickers, memes and playful chat | -| `group games` | Group Games | Played inside the group chat with rules the plugin implements itself: word chains, word guessing, who-is-the-spy, dice and quizzes | -| `game integration` | Game Integration | Plugins built around another game: connectors, wikis and data lookups, server status and player actions (Minecraft, Palworld, Steam) | +| `integration` | Integration | Wiring a third-party platform or account: GitHub, cloud drives, RSS, music, Notion | +| `platform_adapter` | Platform Adapter | New messaging platforms or protocols, such as QQ, Telegram and Discord | +| `provider_adapter` | Provider Adapter | New model, speech or embedding service providers | | `other` | Other | Anything that does not fit the categories above | -Declarations are lightly normalized: surrounding whitespace, letter case and space, `-` or `_` separators are ignored, so the underscore spelling works too: `ai tools`, `AI Tools`, `ai-tools` and `ai_tools` are equivalent. +Declarations are lightly normalized: surrounding whitespace, letter case and space, `-` or `_` separators are ignored, so the underscore spelling works too: `platform adapter`, `Platform Adapter`, `platform-adapter` and `platform_adapter` are equivalent. Plugins that do not declare `category` are grouped under `other`. An unsupported value only logs a warning and is also grouped under `other`; it never blocks installation or updates. Adding a new category requires a code change in AstrBot, so prefer the identifiers above. diff --git a/docs/en/use/plugin.md b/docs/en/use/plugin.md index 148f7acb14c..54bb1124ac2 100644 --- a/docs/en/use/plugin.md +++ b/docs/en/use/plugin.md @@ -43,7 +43,7 @@ The same workspace has **Skills**, **MCP Servers**, and **Handlers** tabs for sk ### 2. Choose a suitable plugin -Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Tools, AI Image, Entertainment, Group Games, Integrations, Utilities and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow (the category dropdown that used to sit in the toolbar has moved to this row above the list). Open a plugin's details and check: +Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Conversation, Entertainment, Media, Productivity, Integration, Utility and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow (the category dropdown that used to sit in the toolbar has moved to this row above the list). Open a plugin's details and check: - **Features and usage**: whether it meets your needs and whether you use it through commands, natural language, or another trigger. - **Supported platforms**: whether it works with your messaging platform. Some features depend on platform-specific APIs. diff --git a/docs/zh/dev/plugin-market/2026-06-27.md b/docs/zh/dev/plugin-market/2026-06-27.md index 001e95d5c58..e93a82147a4 100644 --- a/docs/zh/dev/plugin-market/2026-06-27.md +++ b/docs/zh/dev/plugin-market/2026-06-27.md @@ -160,7 +160,7 @@ metadata.author + "/" + metadata.name `category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段,取值限于 AstrBot 支持的分类标识(见[声明插件分类](../star/plugin-new.md#声明插件分类-optional))。市场收录时直接复制该值,未声明或不支持的取值统一为 `other`。 -索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `ai_tools`)写入索引的 `category` 字段。`metadata.yaml` 是分类的唯一权威来源,索引里的 `category` 只是收录时复制的快照;两者不一致说明索引尚未随声明更新(快照过期),此时市场会继续显示旧分类,直到索引重新收录。运行时与 WebUI 中的已安装插件始终直接读取 `metadata.yaml`,不受索引影响。 +索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `platform_adapter`)写入索引的 `category` 字段。`metadata.yaml` 是分类的唯一权威来源,索引里的 `category` 只是收录时复制的快照;两者不一致说明索引尚未随声明更新(快照过期),此时市场会继续显示旧分类,直到索引重新收录。运行时与 WebUI 中的已安装插件始终直接读取 `metadata.yaml`,不受索引影响。 ### 7.1. 仓库 URL diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index 41920fc289c..bad15da0eef 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -152,34 +152,24 @@ astrbot_version: ">=4.16,<5" 你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。WebUI 与运行时都以该字段为准;插件市场里显示的分类取决于市场索引是否收录了该值,索引收录时会复制这个字段,因此只改 `metadata.yaml` 不会立刻改变市场展示。 ```yaml -category: media processing +category: platform adapter ``` `category` 取值为下列英文标识之一。中文翻译只是界面上的展示文案,写进 `category` 不会被识别。 | 标识 | 中文翻译 | 适用插件 | | --- | --- | --- | -| `ai tools` | AI 增强 | 基于大模型的单次文本能力:提示词、文本改写、总结与翻译 | -| `ai image` | AI 绘图 | 文生图、图生图、画风转换与图片编辑 | -| `ai speech` | AI 语音 | TTS 与 ASR:语音合成、音色与语气、语音识别 | -| `ai agent` | 智能体与编排 | Agent 运行、工具调用、多智能体与工作流编排 | -| `ai context` | AI 对话 | 跨轮次的对话语境:人设与角色设定、上下文压缩与注入、对话风格与情绪语气;记忆存储归「长期记忆」,读外部文档归「知识库」 | -| `long term memory` | 长期记忆 | 记忆的存储与召回、用户画像与长期上下文 | -| `knowledge base` | 知识库 | 文档入库与检索问答(RAG)、知识库管理 | -| `tools` | 工具 | 通用小工具与命令集合:编码与格式转换、计算、短链、批量处理 | +| `utility` | 实用工具 | 通用工具与生活查询:编码与格式转换、计算、短链、天气、汇率、快递、单位换算,以及定时与自动化流程 | +| `ai_context` | AI 对话 | 围绕对话与 AI 能力:人设与角色设定、上下文压缩与注入、提示词与文本改写、记忆与知识库检索接入 | +| `entertainment` | 娱乐 | 泛娱乐与游戏:塔罗、运势、点歌、表情包、梗图、玩梗闲聊、接龙、猜词、谁是卧底、掷骰、答题,以及围绕别的游戏的外围插件 | +| `media` | 媒体 | 图片、音频、视频的处理与生成:解析、转码、拼接、表情包、文生图、图生图、TTS 与 ASR | | `productivity` | 效率 | 待办、日程、笔记与个人工作流 | -| `utilities` | 生活实用 | 生活信息查询与提醒:天气、汇率、快递、黄历、单位换算 | -| `integrations` | 外部集成 | 打通第三方平台或服务账号:GitHub、网盘、RSS、音乐、Notion | -| `platform adapter` | 平台适配器 | 接入新的消息平台或协议,如 QQ、Telegram、Discord | -| `media processing` | 媒体处理 | 图片、音频、视频的解析、转码、拼接与表情包生成 | -| `automation` | 自动化与定时 | 定时推送、自动回复、由事件触发的自动化流程 | -| `security` | 安全与审核 | 内容审核、反垃圾、敏感词、权限与风控 | -| `entertainment` | 娱乐 | 普通泛娱乐,不含游戏:塔罗、运势、点歌、表情包、梗图、玩梗闲聊 | -| `group games` | 群游戏 | 直接在群里玩、玩法由插件自身实现:接龙、猜词、谁是卧底、掷骰、答题 | -| `game integration` | 游戏接入 | 围绕别的游戏的外围插件:连接器、Wiki 与资料查询、服务器状态与玩家操作(Minecraft、幻兽帕鲁、Steam) | +| `integration` | 外部集成 | 打通第三方平台或服务账号:GitHub、网盘、RSS、音乐、Notion | +| `platform_adapter` | 平台适配器 | 接入新的消息平台或协议,如 QQ、Telegram、Discord | +| `provider_adapter` | 提供商适配器 | 接入新的大模型、语音或向量服务提供商 | | `other` | 其他 | 无法归入以上任一类的插件 | -取值会做轻度归一化:首尾空格、大小写以及空格、`-`、`_` 三种分隔符都会被忽略,所以下划线写法同样能识别,`ai tools`、`AI Tools`、`ai-tools` 与 `ai_tools` 等价。 +取值会做轻度归一化:首尾空格、大小写以及空格、`-`、`_` 三种分隔符都会被忽略,所以下划线写法同样能识别,`platform adapter`、`Platform Adapter`、`platform-adapter` 与 `platform_adapter` 等价。 未声明 `category` 的插件会归入 `other`。如果写了不支持的分类,AstrBot 会在日志中给出告警并同样归入 `other`,但**不会**阻止插件安装或更新。新增分类需要修改 AstrBot 源码,因此请优先使用上表中的标识。 diff --git a/docs/zh/use/plugin.md b/docs/zh/use/plugin.md index fc3632a35b5..931c585efbe 100644 --- a/docs/zh/use/plugin.md +++ b/docs/zh/use/plugin.md @@ -43,7 +43,7 @@ AstrBot 负责接收消息、连接模型、管理对话等基础工作;插件 ### 2. 找到合适的插件 -在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 增强、AI 绘图、娱乐、群游戏、外部集成、生活实用、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开(原先位于工具栏的「分类」下拉框,现已移到插件列表上方的分类条)。点击感兴趣的插件查看详情,先确认: +在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 对话、娱乐、媒体、效率、外部集成、实用工具、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开(原先位于工具栏的「分类」下拉框,现已移到插件列表上方的分类条)。点击感兴趣的插件查看详情,先确认: - **功能和用法**:是否解决你的需求,安装后通过指令、自然语言还是其他方式使用。 - **支持平台**:是否支持你接入的消息平台。某些功能依赖特定平台的接口。 diff --git a/tests/test_plugin_manager.py b/tests/test_plugin_manager.py index 817f50a50f9..69cfbb75566 100644 --- a/tests/test_plugin_manager.py +++ b/tests/test_plugin_manager.py @@ -221,11 +221,11 @@ def test_load_plugin_metadata_includes_category(tmp_path: Path): @pytest.mark.parametrize( ("declared", "expected"), [ - ("Group Games", "group_games"), + ("Platform Adapter", "platform_adapter"), ("platform-adapter", "platform_adapter"), # Repeated and mixed separators must normalize like the WebUI does. - ("AI - Tools", "ai_tools"), - (" long-term memory ", "long_term_memory"), + ("AI - Context", "ai_context"), + (" provider adapter ", "provider_adapter"), ], ) def test_load_plugin_metadata_normalizes_category( @@ -1049,7 +1049,7 @@ async def test_load_plugin_keeps_declared_category( """Loading a plugin must keep the category declared in metadata.yaml.""" _clear_star_runtime_state() module_path = f"data.plugins.{TEST_PLUGIN_DIR}.main" - _write_plugin_category(local_updater, "group_games") + _write_plugin_category(local_updater, "entertainment") (local_updater / "main.py").write_text( "from astrbot.api.star import Star\nclass Main(Star):\n pass\n", encoding="utf-8", @@ -1092,7 +1092,7 @@ async def sync_command_configs(): success, error = await plugin_manager_pm.load(specified_dir_name=TEST_PLUGIN_DIR) assert success, error - assert star_manager_module.star_map[module_path].category == "group_games" + assert star_manager_module.star_map[module_path].category == "entertainment" @pytest.mark.asyncio From 8d1b455bd26a35f6e2a7326f854b9c99488348ab Mon Sep 17 00:00:00 2001 From: XTsat Date: Tue, 24 Nov 2026 17:43:47 +0800 Subject: [PATCH 16/16] feat(plugin): make the marketplace category optional 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. --- astrbot/core/star/plugin_categories.py | 65 +++++++------------ astrbot/core/star/star.py | 6 +- astrbot/core/star/star_manager.py | 7 +- astrbot/core/star/updater.py | 5 -- astrbot/dashboard/api/plugins.py | 9 +-- changelogs/unreleased.md | 2 +- .../locales/en-US/features/extension.json | 1 + .../locales/ja-JP/features/extension.json | 1 + .../locales/ru-RU/features/extension.json | 1 + .../locales/zh-CN/features/extension.json | 1 + .../src/views/extension/PluginDetailPage.vue | 8 ++- .../src/views/extension/useExtensionPage.js | 35 +++++----- docs/en/dev/plugin-market/2026-06-27.md | 2 +- docs/en/dev/star/plugin-new.md | 27 ++++---- docs/en/dev/star/plugin-publish.md | 2 +- docs/en/use/plugin.md | 2 +- docs/zh/dev/plugin-market/2026-06-27.md | 2 +- docs/zh/dev/star/plugin-new.md | 33 +++++----- docs/zh/dev/star/plugin-publish.md | 4 +- docs/zh/dev/star/plugin.md | 4 +- docs/zh/use/plugin.md | 2 +- tests/test_fastapi_v1_dashboard.py | 6 +- tests/test_plugin_manager.py | 59 +++++++---------- 23 files changed, 127 insertions(+), 157 deletions(-) diff --git a/astrbot/core/star/plugin_categories.py b/astrbot/core/star/plugin_categories.py index d206e547db4..27d946f25a4 100644 --- a/astrbot/core/star/plugin_categories.py +++ b/astrbot/core/star/plugin_categories.py @@ -1,21 +1,22 @@ -"""Canonical plugin categories that plugins declare in ``metadata.yaml``. - -Plugins declare a stable, machine-readable slug instead of a localized label so -the plugin market index, the WebUI and the runtime all filter on the same -values. Adding a category is a code change here; labels are derived from the -slug wherever it is displayed. +"""Recommended plugin categories that plugins may declare in ``metadata.yaml``. + +A category is an optional, free-form hint. The values below are the ones the +plugin market, the WebUI and the runtime know how to label and order, and a +plugin may declare something else: the declared value is normalized to a slug +either way, so one typo or one niche category cannot block a plugin from loading, +installing or updating. Display code derives labels from the slug and falls back +to the words of the slug itself. """ from __future__ import annotations import re -from astrbot.core import logger - -PLUGIN_CATEGORY_SLUGS: tuple[str, ...] = ( +RECOMMENDED_PLUGIN_CATEGORIES: tuple[str, ...] = ( "utility", "ai_context", "entertainment", + "game", "media", "productivity", "integration", @@ -23,46 +24,28 @@ "provider_adapter", "other", ) -"""Supported ``metadata.yaml`` ``category`` values, in display order.""" - -DEFAULT_PLUGIN_CATEGORY = "other" -"""Category used when a plugin declares an unsupported category.""" +"""Recommended ``metadata.yaml`` ``category`` values, in display order.""" -def normalize_plugin_category(value: object, *, warn: bool = True) -> str | None: - """Normalize the category declared by plugin metadata. +def normalize_plugin_category(value: object) -> str | None: + """Normalize the optional category declared by plugin metadata. - Unsupported values never block loading or installation: they are reported in - the log and mapped to ``DEFAULT_PLUGIN_CATEGORY`` so that a typo in - ``metadata.yaml`` cannot make a plugin uninstallable. + Any value is accepted. A value outside ``RECOMMENDED_PLUGIN_CATEGORIES`` is + kept as declared instead of being rejected or rewritten, because the + vocabulary is a recommendation for plugin authors rather than a constraint + the runtime enforces. Args: value: Raw ``category`` value read from ``metadata.yaml``. - warn: Whether to report an unsupported value. Callers that already - validated the same metadata can pass ``False`` to avoid a duplicate - warning while still getting the normalized value. Returns: - The declared slug when it is supported, ``None`` when the plugin does - not declare a category, otherwise ``DEFAULT_PLUGIN_CATEGORY``. + The normalized slug, or ``None`` when the plugin declares no category or + declares something that is not a string. """ - if value is None: + if not isinstance(value, str): return None - if isinstance(value, str): - # Collapse separator runs so that "AI - Tools" matches what the WebUI - # derives from the same declaration instead of falling back to "other". - slug = re.sub(r"[\s-]+", "_", value.strip().lower()) - if slug in PLUGIN_CATEGORY_SLUGS: - return slug - if not slug: - return None - - if not warn: - return DEFAULT_PLUGIN_CATEGORY - - logger.warning( - f"Unsupported plugin category {value!r}; falling back to " - f"{DEFAULT_PLUGIN_CATEGORY!r}." - ) - return DEFAULT_PLUGIN_CATEGORY + # Collapse separator runs so that "AI - Context", "ai-context" and + # "ai_context" reach the WebUI as one slug. + slug = re.sub(r"[\s-]+", "_", value.strip().lower()) + return slug or None diff --git a/astrbot/core/star/star.py b/astrbot/core/star/star.py index 77c24b0f1f6..1b8f10b3846 100644 --- a/astrbot/core/star/star.py +++ b/astrbot/core/star/star.py @@ -80,7 +80,11 @@ class StarMetadata: # Appended last on purpose: StarMetadata is constructed positionally by # external consumers, so new fields must not shift existing ones. category: str | None = None - """Plugin market category slug declared in metadata (None when undeclared).""" + """Optional marketplace category declared in metadata, normalized to a slug. + + Any declared value is kept as-is, so this is not limited to the recommended + vocabulary; ``None`` means the plugin declares no category. + """ @property def plugin_id(self) -> str: diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 77f63fe328f..0eeb67b809d 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -562,10 +562,9 @@ def _load_plugin_metadata(plugin_path: str, plugin_obj=None) -> StarMetadata | N if isinstance(metadata.get("astrbot_version"), str) else None ), - # The metadata was validated above, so do not warn twice. - category=normalize_plugin_category( - metadata.get("category"), warn=False - ), + # The category is an optional, free-form hint. Declaring an + # unknown value is normalized but never rejected. + category=normalize_plugin_category(metadata.get("category")), views=views, i18n=PluginManager._load_plugin_i18n(plugin_path), ) diff --git a/astrbot/core/star/updater.py b/astrbot/core/star/updater.py index b61b22eebf7..37cb0ce2c59 100644 --- a/astrbot/core/star/updater.py +++ b/astrbot/core/star/updater.py @@ -24,7 +24,6 @@ from ..star.star import StarMetadata from ..zip_updater import _RepoZipUpdater -from .plugin_categories import normalize_plugin_category PLUGIN_METADATA_FILENAMES = ("metadata.yaml", "metadata.yml") PLUGIN_METADATA_REQUIRED_FIELDS = ("name", "desc", "version", "author") @@ -396,10 +395,6 @@ def validate_plugin_metadata(metadata: object, metadata_label: str) -> None: f"{metadata_label} 中字段 {', '.join(invalid_fields)} 必须是非空字符串。" ) - # An unsupported category must never block installation or updates, so it - # is normalized to the fallback category with a warning instead of raising. - normalize_plugin_category(normalized_metadata.get("category")) - @classmethod def inspect_plugin_directory(cls, plugin_path: str | Path) -> dict[str, object]: """Inspect plugin metadata in a checked-out repository directory. diff --git a/astrbot/dashboard/api/plugins.py b/astrbot/dashboard/api/plugins.py index 9c5a9f8a092..9a579230704 100644 --- a/astrbot/dashboard/api/plugins.py +++ b/astrbot/dashboard/api/plugins.py @@ -12,7 +12,7 @@ from astrbot.api.web import PluginRequest, bind_request_context from astrbot.core import logger from astrbot.core.log import LogManager -from astrbot.core.star.plugin_categories import PLUGIN_CATEGORY_SLUGS +from astrbot.core.star.plugin_categories import RECOMMENDED_PLUGIN_CATEGORIES from astrbot.dashboard.asgi_runtime import ( DashboardRequestState, call_request_view, @@ -624,9 +624,10 @@ async def list_plugin_market( async def list_plugin_market_categories( _auth: AuthContext = Depends(require_plugin_scope), ): - # Slugs only: display labels stay in the dashboard i18n bundles so that the - # marketplace, the WebUI and the runtime share one category vocabulary. - return ok({"categories": list(PLUGIN_CATEGORY_SLUGS)}) + # Slugs only: display labels stay in the dashboard i18n bundles. This is the + # recommended vocabulary used to order the filter and to keep shared labels; + # plugins may declare any other category and the WebUI shows it as declared. + return ok({"categories": list(RECOMMENDED_PLUGIN_CATEGORIES)}) @router.get("/plugin-sources") diff --git a/changelogs/unreleased.md b/changelogs/unreleased.md index a4a5b00596d..27dd32e360b 100644 --- a/changelogs/unreleased.md +++ b/changelogs/unreleased.md @@ -1,7 +1,7 @@ # Unreleased - QQ Official: failed image uploads no longer log base64 payloads, avoiding dashboard freezes from oversized log entries. Retry attempts decrease from five to three, with one summary warning. -- Plugin market: plugins can now declare a marketplace category in `metadata.yaml` (canonical identifiers served by the plugin API, unknown values log a warning and fall back to `other` without blocking installation or updates), and the WebUI category filter moved from the toolbar dropdown to a chip row above the plugin list (old entry: Extensions → Plugin Market → toolbar "Category" dropdown; new entry: Extensions → Plugin Market → category row above the list). +- Plugin market: plugins can now declare an optional marketplace category in `metadata.yaml`. The plugin API serves a ten-value recommended vocabulary (`utility`, `ai_context`, `entertainment`, `game`, `media`, `productivity`, `integration`, `platform_adapter`, `provider_adapter`, `other`) that orders the filter and supplies translated labels, but any other value is accepted as written: nothing warns, nothing is rewritten, and installation and updates are never blocked. The WebUI category filter also moved from the toolbar dropdown to a chip row above the plugin list (old entry: Extensions → Plugin Market → toolbar "Category" dropdown; new entry: Extensions → Plugin Market → category row above the list). - 「插件 → 管理行为 → 函数工具」现在只列出插件工具。Agent 运行时工具由配置文件的 AI 功能设置控制,MCP 工具可在「插件 → MCP」查看。 - Extensions → Handlers → Function Tools now lists plugin tools. Configure Agent runtime tools in the profile's AI capability settings and view MCP tools under Extensions → MCP Servers. diff --git a/dashboard/src/i18n/locales/en-US/features/extension.json b/dashboard/src/i18n/locales/en-US/features/extension.json index b8ea9d0e8c0..42101a8cd8a 100644 --- a/dashboard/src/i18n/locales/en-US/features/extension.json +++ b/dashboard/src/i18n/locales/en-US/features/extension.json @@ -150,6 +150,7 @@ "utility": "Utility", "ai_context": "AI Conversation", "entertainment": "Entertainment", + "game": "Game", "media": "Media", "productivity": "Productivity", "integration": "Integration", diff --git a/dashboard/src/i18n/locales/ja-JP/features/extension.json b/dashboard/src/i18n/locales/ja-JP/features/extension.json index 6d00f113eed..ae3dabd9f15 100644 --- a/dashboard/src/i18n/locales/ja-JP/features/extension.json +++ b/dashboard/src/i18n/locales/ja-JP/features/extension.json @@ -150,6 +150,7 @@ "utility": "ユーティリティ", "ai_context": "AI 会話", "entertainment": "エンターテインメント", + "game": "ゲーム", "media": "メディア", "productivity": "生産性", "integration": "外部連携", diff --git a/dashboard/src/i18n/locales/ru-RU/features/extension.json b/dashboard/src/i18n/locales/ru-RU/features/extension.json index 980ccd00391..48be31fecc7 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/extension.json +++ b/dashboard/src/i18n/locales/ru-RU/features/extension.json @@ -150,6 +150,7 @@ "utility": "Утилиты", "ai_context": "AI-диалог", "entertainment": "Развлечения", + "game": "Игры", "media": "Медиа", "productivity": "Продуктивность", "integration": "Интеграции", diff --git a/dashboard/src/i18n/locales/zh-CN/features/extension.json b/dashboard/src/i18n/locales/zh-CN/features/extension.json index 0bb4de7160a..fac1a23f6b6 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/extension.json +++ b/dashboard/src/i18n/locales/zh-CN/features/extension.json @@ -150,6 +150,7 @@ "utility": "实用工具", "ai_context": "AI 对话", "entertainment": "娱乐", + "game": "游戏", "media": "媒体", "productivity": "效率", "integration": "外部集成", diff --git a/dashboard/src/views/extension/PluginDetailPage.vue b/dashboard/src/views/extension/PluginDetailPage.vue index c29619c13de..31a67647679 100644 --- a/dashboard/src/views/extension/PluginDetailPage.vue +++ b/dashboard/src/views/extension/PluginDetailPage.vue @@ -161,9 +161,13 @@ const categoryDisplay = computed(() => { const category = String(rawCategory || "").trim(); if (!category) return ""; - const normalized = category.toLowerCase().replace(/\s+/g, "_"); + // Match the backend normalization so a hyphen or an underscore spelling of a + // recommended category still resolves to its label. An unlisted value is + // allowed and has no label, so show it as the author declared it instead of + // the missing-translation marker. + const normalized = category.toLowerCase().replace(/[\s-]+/g, "_"); const label = tm(`market.categories.${normalized}`); - return label === `market.categories.${normalized}` ? category : label; + return label.includes("[MISSING:") ? category : label; }); const authorWebsite = computed(() => { diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index b5e82bf0126..9cab5d530b1 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -213,7 +213,8 @@ export const useExtensionPage = (initialTab = "installed") => { const sortOrder = ref("desc"); // desc (降序) or asc (升序) const randomPluginNames = ref([]); const marketCategoryFilter = ref("all"); - // Canonical slug order served by the backend; empty until it loads. + // Recommended slug order served by the backend; empty until it loads. It + // only prioritizes and labels the filter, never validates a declared value. const marketCategorySlugs = ref([]); // 插件市场拼音搜索 @@ -238,19 +239,10 @@ export const useExtensionPage = (initialTab = "installed") => { if (!normalized) { return "other"; } - 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. An empty - // vocabulary means the canonical list is unknown (still loading, or an - // older backend), not that nothing is valid, so the discovered values are - // kept: folding them into "other" would leave the filter with one category. - if ( - marketCategorySlugs.value.length > 0 && - !marketCategorySlugs.value.includes(slug) - ) { - return "other"; - } - return slug; + // The backend vocabulary is a recommendation, not a whitelist: a plugin may + // declare any category, so a discovered value keeps its own filter entry + // instead of being folded into "other". + return normalized.replace(/[\s-]+/g, "_"); }; const getMarketCategoryLabel = (key) => { @@ -303,12 +295,15 @@ export const useExtensionPage = (initialTab = "installed") => { }, ]; - // Prefer the backend order so the filter reads the same everywhere; fall - // back to discovery order when the vocabulary is unavailable. - const orderedKeys = - marketCategorySlugs.value.length > 0 - ? marketCategorySlugs.value - : [...marketCategoryMeta.value.keys()]; + // Recommended categories lead in the backend order so the filter reads the + // same everywhere, then whatever else plugins declared follows in discovery + // order: a custom category must stay reachable, not disappear. + const orderedKeys = [...marketCategorySlugs.value]; + for (const categoryKey of marketCategoryMeta.value.keys()) { + if (!orderedKeys.includes(categoryKey)) { + orderedKeys.push(categoryKey); + } + } for (const categoryKey of orderedKeys) { const categoryData = marketCategoryMeta.value.get(categoryKey); diff --git a/docs/en/dev/plugin-market/2026-06-27.md b/docs/en/dev/plugin-market/2026-06-27.md index 2ce34037f05..d046e252e23 100644 --- a/docs/en/dev/plugin-market/2026-06-27.md +++ b/docs/en/dev/plugin-market/2026-06-27.md @@ -158,7 +158,7 @@ Each `PluginRecord` MUST contain: | `stars` | integer | Non-negative star count or ranking signal. | | `download_count` | integer | Non-negative download count. | -The `category` value comes from the same field declared in the plugin repository's `metadata.yaml` and is limited to the categories AstrBot supports (see [Declare Plugin Category](../star/plugin-new.md#declare-plugin-category-optional)). The marketplace copies the declared value verbatim; undeclared or unsupported values become `other`. +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. diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index 5f592d7c3b8..55dfd109939 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -149,30 +149,27 @@ In the WebUI installation flow, you can choose to "Ignore Warning and Install" t ### Declare Plugin Category (Optional) -You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The WebUI and the runtime follow this field. What the plugin marketplace shows depends on whether the market index copied the value, which happens when the index is updated, so editing `metadata.yaml` alone does not change the marketplace listing right away. +You can add a `category` field in `metadata.yaml` to declare the marketplace category of your plugin. The WebUI and the runtime read this field directly; the marketplace shows the category captured in the index snapshot. ```yaml -category: platform adapter +category: platform_adapter ``` -`category` takes one of the following identifiers. Only the identifier column is canonical: the localized labels are display text, so the Chinese translation is not recognized, while an English spelling that normalizes to a supported identifier (such as `Platform Adapter`) is accepted. +The identifiers below are the recommended categories. -| Identifier | English label | Use it for | +| Recommended identifier | English label | Use it for | | --- | --- | --- | -| `utility` | Utility | General tools and everyday lookups: encoding and format conversion, calculation, short links, weather, exchange rates, parcels, unit conversion, plus scheduled and automated flows | -| `ai_context` | AI Conversation | Conversation and AI capabilities around it: persona and character settings, context compression and injection, prompts and text rewriting, memory and knowledge base retrieval | -| `entertainment` | Entertainment | Fun and games: tarot, fortune telling, song requests, stickers, memes, playful chat, word chains, word guessing, who-is-the-spy, dice, quizzes, and plugins built around another game | -| `media` | Media | Processing and generation of images, audio and video: parsing, transcoding, joining, stickers, text-to-image, image-to-image, TTS and ASR | +| `utility` | Utility | General tools and everyday lookups | +| `ai_context` | AI Conversation | Enhancements around conversation and AI capabilities | +| `entertainment` | Entertainment | General fun and in-chat games | +| `game` | Game | Connecting to an external game | +| `media` | Media | Processing and generating images, audio and video | | `productivity` | Productivity | To-dos, schedules, notes and personal workflows | -| `integration` | Integration | Wiring a third-party platform or account: GitHub, cloud drives, RSS, music, Notion | -| `platform_adapter` | Platform Adapter | New messaging platforms or protocols, such as QQ, Telegram and Discord | -| `provider_adapter` | Provider Adapter | New model, speech or embedding service providers | +| `integration` | Integration | Wiring a third-party platform or account | +| `platform_adapter` | Platform Adapter | New messaging platforms or protocols | +| `provider_adapter` | Provider Adapter | New model, speech or embedding services | | `other` | Other | Anything that does not fit the categories above | -Declarations are lightly normalized: surrounding whitespace, letter case and space, `-` or `_` separators are ignored, so the underscore spelling works too: `platform adapter`, `Platform Adapter`, `platform-adapter` and `platform_adapter` are equivalent. - -Plugins that do not declare `category` are grouped under `other`. An unsupported value only logs a warning and is also grouped under `other`; it never blocks installation or updates. Adding a new category requires a code change in AstrBot, so prefer the identifiers above. - ### Debugging Plugins AstrBot uses a runtime plugin injection mechanism. Therefore, when debugging plugins, you need to start the AstrBot main application. diff --git a/docs/en/dev/star/plugin-publish.md b/docs/en/dev/star/plugin-publish.md index 4556abe94c2..2252150fff7 100644 --- a/docs/en/dev/star/plugin-publish.md +++ b/docs/en/dev/star/plugin-publish.md @@ -29,7 +29,7 @@ repo: https://github.com/your-name/repo # Plugin repository URL # - example ``` -[Available marketplace categories](plugin-new.md#declare-plugin-category-optional) +[Recommended marketplace categories](plugin-new.md#declare-plugin-category-optional) [Supported platform adapters](plugin-new.md#declare-supported-platforms-optional) diff --git a/docs/en/use/plugin.md b/docs/en/use/plugin.md index 54bb1124ac2..afdb9ee55df 100644 --- a/docs/en/use/plugin.md +++ b/docs/en/use/plugin.md @@ -43,7 +43,7 @@ The same workspace has **Skills**, **MCP Servers**, and **Handlers** tabs for sk ### 2. Choose a suitable plugin -Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (such as AI Conversation, Entertainment, Media, Productivity, Integration, Utility and Other), and selecting one shows only that category. Use the arrow on the right when the categories overflow (the category dropdown that used to sit in the toolbar has moved to this row above the list). Open a plugin's details and check: +Search by plugin name or a keyword describing the feature you want. You can also filter by category: each entry in the category row comes from the category a plugin declares in its `metadata.yaml` (AI Conversation, Entertainment, Game, Media, Productivity, Integration, Utility and Other are the recommended ones; a plugin that declares another value appears under that value), and selecting one shows only that category. Use the arrow on the right when the categories overflow (the category dropdown that used to sit in the toolbar has moved to this row above the list). Open a plugin's details and check: - **Features and usage**: whether it meets your needs and whether you use it through commands, natural language, or another trigger. - **Supported platforms**: whether it works with your messaging platform. Some features depend on platform-specific APIs. diff --git a/docs/zh/dev/plugin-market/2026-06-27.md b/docs/zh/dev/plugin-market/2026-06-27.md index e93a82147a4..95b745b084b 100644 --- a/docs/zh/dev/plugin-market/2026-06-27.md +++ b/docs/zh/dev/plugin-market/2026-06-27.md @@ -158,7 +158,7 @@ metadata.author + "/" + metadata.name | `stars` | integer | 非负 star 数或排序信号。 | | `download_count` | integer | 非负下载数。 | -`category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段,取值限于 AstrBot 支持的分类标识(见[声明插件分类](../star/plugin-new.md#声明插件分类-optional))。市场收录时直接复制该值,未声明或不支持的取值统一为 `other`。 +`category` 的来源是插件仓库 `metadata.yaml` 中的同名声明字段。推荐取值见[声明插件分类](../star/plugin-new.md#声明插件分类-可选),但字段本身是可选、自由填写的:市场收录时直接复制归一化后的值,未声明时为空。 索引维护者在收录或更新一条插件记录时,需要读取该插件仓库 `metadata.yaml` 中的 `category`,把归一化后的 slug(下划线形式,如 `platform_adapter`)写入索引的 `category` 字段。`metadata.yaml` 是分类的唯一权威来源,索引里的 `category` 只是收录时复制的快照;两者不一致说明索引尚未随声明更新(快照过期),此时市场会继续显示旧分类,直到索引重新收录。运行时与 WebUI 中的已安装插件始终直接读取 `metadata.yaml`,不受索引影响。 diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index bad15da0eef..3d68a457401 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -94,7 +94,7 @@ your_plugin/ 这种情况下 Skill 名称会使用插件目录名。插件提供的 Skill 由插件管理,在 WebUI 的 `插件 → 技能` 页面中作为只读来源展示;可以启用或禁用,但不能从本地 Skills 页面删除或编辑。插件卸载或更新后,对应 Skill 会随插件文件变化。 -### 声明支持平台(Optional) +### 声明支持平台(可选) 你可以在 `metadata.yaml` 中新增 `support_platforms` 字段(`list[str]`),声明插件支持的平台适配器。WebUI 插件页会展示该字段。 @@ -126,7 +126,7 @@ support_platforms: - `matrix` - `mattermost` -### 声明 AstrBot 版本范围(Optional) +### 声明 AstrBot 版本范围(可选) 你可以在 `metadata.yaml` 中新增 `astrbot_version` 字段,声明插件要求的 AstrBot 版本范围。格式与 `pyproject.toml` 依赖版本约束一致(PEP 440),且不要加 `v` 前缀。 @@ -147,32 +147,29 @@ astrbot_version: ">=4.16,<5" 当当前 AstrBot 版本不满足该范围时,插件会被阻止加载并提示版本不兼容。 在 WebUI 安装插件时,你可以选择“无视警告,继续安装”来跳过这个检查。 -### 声明插件分类(Optional) +### 声明插件分类(可选) -你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。WebUI 与运行时都以该字段为准;插件市场里显示的分类取决于市场索引是否收录了该值,索引收录时会复制这个字段,因此只改 `metadata.yaml` 不会立刻改变市场展示。 +你可以在 `metadata.yaml` 中新增 `category` 字段,主动声明插件的市场分类。WebUI 与运行时直接读取该字段,市场里展示的分类取自索引快照。 ```yaml -category: platform adapter +category: platform_adapter ``` -`category` 取值为下列英文标识之一。中文翻译只是界面上的展示文案,写进 `category` 不会被识别。 +下表是推荐使用的分类标识。 -| 标识 | 中文翻译 | 适用插件 | +| 推荐标识 | 中文翻译 | 适用插件 | | --- | --- | --- | -| `utility` | 实用工具 | 通用工具与生活查询:编码与格式转换、计算、短链、天气、汇率、快递、单位换算,以及定时与自动化流程 | -| `ai_context` | AI 对话 | 围绕对话与 AI 能力:人设与角色设定、上下文压缩与注入、提示词与文本改写、记忆与知识库检索接入 | -| `entertainment` | 娱乐 | 泛娱乐与游戏:塔罗、运势、点歌、表情包、梗图、玩梗闲聊、接龙、猜词、谁是卧底、掷骰、答题,以及围绕别的游戏的外围插件 | -| `media` | 媒体 | 图片、音频、视频的处理与生成:解析、转码、拼接、表情包、文生图、图生图、TTS 与 ASR | +| `utility` | 实用工具 | 通用小工具与生活信息查询 | +| `ai_context` | AI 对话 | 围绕对话与 AI 能力的增强 | +| `entertainment` | 娱乐 | 泛娱乐与群内小游戏 | +| `game` | 游戏 | 连接外部游戏 | +| `media` | 媒体 | 图片、音频、视频的处理与生成 | | `productivity` | 效率 | 待办、日程、笔记与个人工作流 | -| `integration` | 外部集成 | 打通第三方平台或服务账号:GitHub、网盘、RSS、音乐、Notion | -| `platform_adapter` | 平台适配器 | 接入新的消息平台或协议,如 QQ、Telegram、Discord | -| `provider_adapter` | 提供商适配器 | 接入新的大模型、语音或向量服务提供商 | +| `integration` | 外部集成 | 打通第三方平台或服务账号 | +| `platform_adapter` | 平台适配器 | 接入新的消息平台或协议 | +| `provider_adapter` | 提供商适配器 | 接入新的模型、语音或向量服务 | | `other` | 其他 | 无法归入以上任一类的插件 | -取值会做轻度归一化:首尾空格、大小写以及空格、`-`、`_` 三种分隔符都会被忽略,所以下划线写法同样能识别,`platform adapter`、`Platform Adapter`、`platform-adapter` 与 `platform_adapter` 等价。 - -未声明 `category` 的插件会归入 `other`。如果写了不支持的分类,AstrBot 会在日志中给出告警并同样归入 `other`,但**不会**阻止插件安装或更新。新增分类需要修改 AstrBot 源码,因此请优先使用上表中的标识。 - ### 调试插件 AstrBot 采用在运行时注入插件的机制。因此,在调试插件时,需要启动 AstrBot 本体。 diff --git a/docs/zh/dev/star/plugin-publish.md b/docs/zh/dev/star/plugin-publish.md index a5a6e2c81a0..db84bc45c65 100644 --- a/docs/zh/dev/star/plugin-publish.md +++ b/docs/zh/dev/star/plugin-publish.md @@ -29,9 +29,9 @@ repo: https://github.com/your-name/repo # 插件仓库地址 # - example ``` -[目前可用的插件市场分类](plugin-new.md#声明插件分类-optional) +[推荐的插件市场分类](plugin-new.md#声明插件分类-可选) -[目前支持的平台适配器](plugin-new.md#声明支持平台-optional) +[目前支持的平台适配器](plugin-new.md#声明支持平台-可选) ::: warning 大小限制 发布到插件市场的插件压缩包(zip)大小**不得超过 16MB**。 diff --git a/docs/zh/dev/star/plugin.md b/docs/zh/dev/star/plugin.md index cb2bc8484fc..58a05a2e095 100644 --- a/docs/zh/dev/star/plugin.md +++ b/docs/zh/dev/star/plugin.md @@ -268,7 +268,7 @@ your_plugin/ 这种情况下 Skill 名称会使用插件目录名。插件提供的 Skill 由插件管理,在 WebUI 的 `插件 → 技能` 页面中作为只读来源展示;可以启用或禁用,但不能从本地 Skills 页面删除或编辑。插件卸载或更新后,对应 Skill 会随插件文件变化。 -### 声明支持平台(Optional) +### 声明支持平台(可选) 你可以在 `metadata.yaml` 中新增 `support_platforms` 字段(`list[str]`),声明插件支持的平台适配器。WebUI 插件页会展示该字段。 @@ -295,7 +295,7 @@ support_platforms: - `misskey` - `line` -### 声明 AstrBot 版本范围(Optional) +### 声明 AstrBot 版本范围(可选) 你可以在 `metadata.yaml` 中新增 `astrbot_version` 字段,声明插件要求的 AstrBot 版本范围。格式与 `pyproject.toml` 依赖版本约束一致(PEP 440),且不要加 `v` 前缀。 diff --git a/docs/zh/use/plugin.md b/docs/zh/use/plugin.md index 931c585efbe..e51a29585ee 100644 --- a/docs/zh/use/plugin.md +++ b/docs/zh/use/plugin.md @@ -43,7 +43,7 @@ AstrBot 负责接收消息、连接模型、管理对话等基础工作;插件 ### 2. 找到合适的插件 -在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(如 AI 对话、娱乐、媒体、效率、外部集成、实用工具、其他),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开(原先位于工具栏的「分类」下拉框,现已移到插件列表上方的分类条)。点击感兴趣的插件查看详情,先确认: +在市场搜索框中输入插件名称或功能关键词,也可以按分类筛选:分类条上的每一项取自插件在 `metadata.yaml` 中声明的分类(推荐使用 AI 对话、娱乐、游戏、媒体、效率、外部集成、实用工具、其他;作者写别的值也会单独出现),点选其中一项即可只看该分类的插件,分类过多时可用右侧箭头展开(原先位于工具栏的「分类」下拉框,现已移到插件列表上方的分类条)。点击感兴趣的插件查看详情,先确认: - **功能和用法**:是否解决你的需求,安装后通过指令、自然语言还是其他方式使用。 - **支持平台**:是否支持你接入的消息平台。某些功能依赖特定平台的接口。 diff --git a/tests/test_fastapi_v1_dashboard.py b/tests/test_fastapi_v1_dashboard.py index 2ee536abc10..8f8abf8888a 100644 --- a/tests/test_fastapi_v1_dashboard.py +++ b/tests/test_fastapi_v1_dashboard.py @@ -23,7 +23,7 @@ import astrbot.dashboard.services.config_service as config_service import astrbot.dashboard.services.stat_service as stat_service from astrbot.core import file_token_service -from astrbot.core.star.plugin_categories import PLUGIN_CATEGORY_SLUGS +from astrbot.core.star.plugin_categories import RECOMMENDED_PLUGIN_CATEGORIES from astrbot.core.utils import llm_metadata from astrbot.dashboard.api.app import create_dashboard_asgi_app from astrbot.dashboard.api.backups import download_backup as download_backup_route @@ -2364,7 +2364,7 @@ async def test_v1_plugins_accept_api_key( @pytest.mark.asyncio -async def test_v1_plugin_market_categories_lists_canonical_slugs( +async def test_v1_plugin_market_categories_lists_recommended_slugs( asgi_client: httpx.AsyncClient, fake_db: FakeDb, ): @@ -2379,7 +2379,7 @@ async def test_v1_plugin_market_categories_lists_canonical_slugs( assert response.status_code == 200 data = response.json() assert data["status"] == "ok" - assert data["data"]["categories"] == list(PLUGIN_CATEGORY_SLUGS) + assert data["data"]["categories"] == list(RECOMMENDED_PLUGIN_CATEGORIES) @pytest.mark.asyncio diff --git a/tests/test_plugin_manager.py b/tests/test_plugin_manager.py index 69cfbb75566..74b1d71b296 100644 --- a/tests/test_plugin_manager.py +++ b/tests/test_plugin_manager.py @@ -2,6 +2,7 @@ import errno import functools import json +import logging import os import sys import tempfile @@ -14,7 +15,6 @@ import pytest import yaml -from astrbot.core.star import plugin_categories from astrbot.core.star import star_manager as star_manager_module from astrbot.core.star.star_handler import EventType, StarHandlerMetadata from astrbot.core.star.star_manager import PluginDependencyInstallError, PluginManager @@ -241,15 +241,17 @@ def test_load_plugin_metadata_normalizes_category( assert loaded_metadata.category == expected -def test_load_plugin_metadata_unknown_category_falls_back_to_other(tmp_path: Path): +def test_load_plugin_metadata_keeps_unlisted_category(tmp_path: Path): + # The recommended vocabulary is a suggestion, so a plugin may declare a + # category that is not on the list; it must survive loading unchanged. plugin_path = tmp_path / "helloworld" _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) - _write_plugin_category(plugin_path, "not_a_category") + _write_plugin_category(plugin_path, "Not A Listed Category") loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) assert loaded_metadata is not None - assert loaded_metadata.category == "other" + assert loaded_metadata.category == "not_a_listed_category" def test_load_plugin_metadata_without_category_is_none(tmp_path: Path): @@ -262,45 +264,34 @@ def test_load_plugin_metadata_without_category_is_none(tmp_path: Path): assert loaded_metadata.category is None -def test_validate_plugin_metadata_allows_unknown_category(monkeypatch) -> None: - # A category typo must not make an existing plugin uninstallable on update. - warnings: list[str] = [] - monkeypatch.setattr( - plugin_categories.logger, "warning", lambda message: warnings.append(message) - ) - - star_manager_module._PluginUpdater.validate_plugin_metadata( - { - "name": TEST_PLUGIN_NAME, - "author": "AstrBot Team", - "desc": "Local test plugin", - "version": "1.0.0", - "category": "not_a_category", - }, - "metadata.yaml", - ) +def test_validate_plugin_metadata_allows_unknown_category(caplog) -> None: + # A category typo must not warn or make a plugin uninstallable on update. + with caplog.at_level(logging.WARNING): + star_manager_module._PluginUpdater.validate_plugin_metadata( + { + "name": TEST_PLUGIN_NAME, + "author": "AstrBot Team", + "desc": "Local test plugin", + "version": "1.0.0", + "category": "not_a_category", + }, + "metadata.yaml", + ) - assert len(warnings) == 1 - assert "not_a_category" in warnings[0] + assert "not_a_category" not in caplog.text -def test_load_plugin_metadata_warns_once_for_unknown_category( - tmp_path: Path, monkeypatch -) -> None: - # Loading validates the metadata first, so the warning must not repeat. - warnings: list[str] = [] - monkeypatch.setattr( - plugin_categories.logger, "warning", lambda message: warnings.append(message) - ) +def test_load_plugin_metadata_does_not_warn_for_unknown_category(tmp_path, caplog): plugin_path = tmp_path / "helloworld" _write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO) _write_plugin_category(plugin_path, "not_a_category") - loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) + with caplog.at_level(logging.WARNING): + loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path)) assert loaded_metadata is not None - assert loaded_metadata.category == "other" - assert len(warnings) == 1 + assert loaded_metadata.category == "not_a_category" + assert "not_a_category" not in caplog.text def test_load_plugin_metadata_does_not_fallback_to_legacy_info(