Skip to content

功能:支持生成版插件注册表元数据#77

Merged
RachelForster merged 7 commits into
RachelForster:mainfrom
End0rph1nww:pr/shinsekai-registry-metadata
Jun 8, 2026
Merged

功能:支持生成版插件注册表元数据#77
RachelForster merged 7 commits into
RachelForster:mainfrom
End0rph1nww:pr/shinsekai-registry-metadata

Conversation

@End0rph1nww
Copy link
Copy Markdown
Contributor

@End0rph1nww End0rph1nww commented Jun 6, 2026

关联

变更内容

本 PR 是 #69 拆分计划里的 PR 4,交付主程序读取 generated registry metadata 的能力。

  • core.plugins.registry_catalog 支持新的 generated registry 结构:object map、schema/plugins 包装结构、旧 plugins.json array 结构。
  • 统一归一化插件市场字段:display_namedesc/descriptionversionshinsekai_versionlogotagsstars/forkspackage.url/sha256/size/r2_keytrust_level/verified/review 等。
  • frontend_bridge_core.plugin_catalog 将这些字段透传给前端 catalog API。
  • frontend/src/shared/platform/types.ts 补齐 PluginCatalogItem 的 metadata 类型。
  • 默认 registry 地址指向官方 RachelForster/Shinsekai-Plugin-Registry 的 generated cache,并在未显式配置 URL 时 fallback 到旧 plugins.json
  • 附带修复两处 Windows 本地单测兼容问题,方便在 Windows 环境完整跑过单测:
    • 路径断言改用 .as_posix()
    • runtime check 测试 mock distribution version,避免本机缺少 runtime 包时误伤“不导入 optional package”的测试目标。

与后续 PR 的关系

这个 PR 先合入客户端对新 Registry 数据结构的兼容层;官方包安全安装在 #78,依赖安装优化在 #79,插件市场 UI 与提交助手在 #80 继续接上。这样可以先保证主程序读懂 generated registry,再逐步启用 R2 安装和 UI 体验。

验证

已在 Windows 本地验证:

python -m pytest test\unit\test_plugin_registry_catalog.py test\unit\test_frontend_plugin_catalog.py -q
8 passed

$env:TEMP='D:\Workspace\Assistant\Shinsekai-main-20260606\.tmp\pytest-temp'; $env:TMP=$env:TEMP; python -m pytest test\unit -q
560 passed, 1 warning

pnpm --dir frontend format:check
All matched files use Prettier code style!

pnpm --dir frontend lint:types
passed

pnpm --dir frontend test
66 passed / 271 tests passed

备注

当前 PR 只让客户端读懂新 registry 数据。即使 generated cache 暂时不存在,也会 fallback 到旧 plugins.json,因此可以先合主程序兼容层,再合 Registry 发布链路。

Comment thread frontend/src/shared/platform/types.ts Outdated
review?: Record<string, unknown>;
securityScan?: Record<string, unknown>;
sha256?: string;
shinsekaiVersion?: string;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to lowestShinsekaiVersion

Comment thread core/plugins/registry_catalog.py Outdated
short_description: str
entry: str
version: str = ""
shinsekai_version: str = ""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this

Comment thread frontend_bridge_core/plugin_catalog.py Outdated
"repo": repo,
"securityScan": dict(getattr(rec, "security_scan", None) or {}),
"sha256": str(getattr(rec, "sha256", "") or ""),
"shinsekaiVersion": str(getattr(rec, "shinsekai_version", "") or ""),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

short_description="Short card text",
entry="plugins.demo.plugin:DemoPlugin",
version="v0.1.0",
shinsekai_version=">=2.0.0",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

"review": None,
"securityScan": {"llm_agent": {"pass": True}},
"sha256": "abc123",
"shinsekaiVersion": ">=2.0.0",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Owner

@RachelForster RachelForster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the ‘’shinsekai_version‘’

@End0rph1nww
Copy link
Copy Markdown
Contributor Author

End0rph1nww commented Jun 8, 2026

已按 review 继续补了一轮:

  1. shinsekai_version 已统一改为 lowest_shinsekai_version,前端桥接层对应字段改为 lowestShinsekaiVersion

    • 旧字段仍保留兼容读取,避免现有索引或测试数据短期内断掉。
    • 新字段语义更明确:表示插件声明的最低 Shinsekai 版本要求。
  2. 修复了 CI 里的 runtime 单测失败:

    • 失败用例是 install_runtime_requirements_tries_configured_indexes_in_order
    • 根因是测试用的 fake Python 脚本只匹配了非常固定的 -m pip --version 参数形式,并且没有处理 bootstrap 阶段的 ensurepip 调用;在 Linux CI 下会落到未处理分支,导致 status 11。
    • 现在 fake Python 同时兼容 pip version 检测和 ensurepip --upgrade --default-pip,这个测试只验证“按配置顺序尝试 pip index”的业务逻辑,不再被假运行时 bootstrap 卡住。

本地已补跑:

python -m py_compile core\plugins\registry_catalog.py frontend_bridge_core\plugin_catalog.py
python -m pytest test\unit\test_plugin_registry_catalog.py test\unit\test_frontend_plugin_catalog.py -q
pnpm --dir frontend format:check
cargo test runtime::managed::tests::install_runtime_requirements_tries_configured_indexes_in_order --lib

@RachelForster RachelForster merged commit 1e71fa7 into RachelForster:main Jun 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants