feat: auto-track GitHub Releases, extract icons/stars/downloads, purge CDN, simplify README
This commit is contained in:
1 parent
56dd35276f
commit
1be15e1ab6
4 files changed
+381
-293
No files matched your search
@@ -8,7 +8,7 @@ on:
|
||||
- 'withdrawn.json'
|
||||
- 'scripts/**'
|
||||
schedule:
|
||||
- cron: '0 4 * * *'
|
||||
- cron: '0 */2 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -92,3 +92,8 @@ jobs:
|
||||
git push --force origin dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Purge jsDelivr CDN cache
|
||||
run: |
|
||||
curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/index.json" || true
|
||||
curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/changes.json" || true
|
||||
@@ -1,84 +1,60 @@
|
||||
# Reims-Go Plugins Market / 插件市场索引仓库
|
||||
# Reims-Go 插件市场
|
||||
|
||||
本仓库是 [Reims-Go](https://github.com/Nwflower/Reims-Go) 的官方与社区插件市场静态索引仓库。
|
||||
本仓库维护 [Reims-Go](https://github.com/Nwflower/Reims-Go) 的官方与社区插件市场目录。插件压缩包由作者托管在各自仓库的 GitHub Releases 中,本仓库只登记仓库链接,并定时自动同步最新版本与安全校验结果。
|
||||
|
||||
- **客户端主索引**:`https://raw.githubusercontent.com/reims-go/plugins/dist/index.json`
|
||||
- **CDN 备选镜像**:`https://cdn.jsdelivr.net/gh/reims-go/plugins@dist/index.json`
|
||||
- **仓库分工**:
|
||||
- `main` 分支:存放人工维护的 [`registry.json`](registry.json)、[`withdrawn.json`](withdrawn.json) 与校验/构建脚本。
|
||||
- `dist` 分支:由 GitHub Actions 自动构建发布的轻量静态 `index.json`(只读产物,客户端直接消费)。
|
||||
- `.zip` 插件压缩包:**不存放在本仓库 Git 历史中**,由各插件作者托管在各自仓库的 GitHub Releases 上。
|
||||
## 如何上架插件
|
||||
|
||||
---
|
||||
只需提交一次 Pull Request 登记插件仓库,后续你在自己仓库发布新的 GitHub Release 时,市场会自动拉取最新版本、执行安全检查并更新索引,无需每次发版都重新提 PR。
|
||||
|
||||
## 插件上架流程 / How to Submit a Plugin
|
||||
### 第一步:打包并检查插件
|
||||
|
||||
### 1. 本地开发与标准打包
|
||||
|
||||
使用最新版 Reims-Go CLI 校验并生成合规压缩包(自动执行静态安全门禁并生成 `SHA256SUMS`):
|
||||
使用最新版 Reims-Go 命令行工具对插件目录做体检并打包:
|
||||
|
||||
```powershell
|
||||
reims-go plugin doctor ./my-plugin
|
||||
reims-go plugin pack ./my-plugin
|
||||
```
|
||||
|
||||
主题插件可在校验和打包时附加 `--contract ui-contract.json`(取自主仓库 [`frontend/ui-contract.json`](https://github.com/Nwflower/Reims-Go/blob/main/frontend/ui-contract.json)),提前核对公开部件类名(`rg-p-*`)与设计令牌。命令会输出生成的 `<id>-<version>.zip` 路径及其 **64 位 SHA-256 哈希**。
|
||||
打包完成后会生成一个标准插件压缩包。
|
||||
|
||||
打包前确认以下清单与归档约定(完整架构与契约见 [`Reims-Go/docs/plugin-architecture.md`](https://github.com/Nwflower/Reims-Go/blob/main/docs/plugin-architecture.md)):
|
||||
- **`version`**:须为合法语义化版本且不含首尾空白;市场 CI 校验单个压缩包不超过 256 MiB。
|
||||
- **`platforms`**:客户端与市场统一支持 `any`、`*`、`windows-x64`、`windows/amd64`(不区分大小写;纯主题与语言包建议写 `["any"]` 或省略)。
|
||||
- **`engines`**:按需声明 `pluginApi`、`uiApi`、`bridgeApi` 与 `reims-go` 范围,市场预检与本地安装执行同一套校验。
|
||||
- **`SHA256SUMS`**:统一使用正斜杠相对路径,支持含空格的资源文件名,禁止重复条目与反斜杠(优先由 `reims-go plugin pack` 自动生成)。
|
||||
- **交互主题脚本**:通过稳定的 `contributes.themes[].uiScript` 声明并请求 `ui:script` 权限,正式版插件不得依赖实验性契约项。
|
||||
### 第二步:发布到 GitHub Releases
|
||||
|
||||
### 2. 发布 GitHub Release
|
||||
在你的开源插件仓库新建一个 Release,并将上一步生成的 `.zip` 压缩包上传为 Release 附件:
|
||||
|
||||
在你的开源插件仓库打 tag(例如 `v1.0.0`)并上传该 `.zip` 压缩包作为 Release 资产。
|
||||
- 面向普通用户的正式版本发布为普通 Release(对应 `stable` 通道)。
|
||||
- 仍在测试中的预览版本勾选「Pre-release」(对应 `alpha` 通道)。
|
||||
|
||||
### 3. 向本仓库提 PR 登记到 `registry.json`
|
||||
### 第三步:登记到本仓库
|
||||
|
||||
在 [`registry.json`](registry.json) 的 `plugins` 数组中添加一条记录:
|
||||
在 [registry.json](registry.json) 的 `plugins` 列表中新增一条登记记录并提交 PR:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "community.theme.example",
|
||||
"id": "yourname.theme.example",
|
||||
"repo": "your-name/reims-theme-example",
|
||||
"kind": "theme",
|
||||
"trust": "community",
|
||||
"channel": "stable",
|
||||
"version": "1.0.0",
|
||||
"asset": "community.theme.example-1.0.0.zip",
|
||||
"sha256": "<reims-go plugin pack 输出的 64 位小写 SHA-256>",
|
||||
"tags": ["theme", "dark"],
|
||||
"changelog": {
|
||||
"zh-CN": "首个正式版本",
|
||||
"en-US": "Initial stable release"
|
||||
}
|
||||
"tags": ["theme", "dark"]
|
||||
}
|
||||
```
|
||||
|
||||
> 其余元数据(`name`、`description`、`publisher`、`license`、`engines`、`platforms`、`permissions`、`tier`)由 CI 直接从压缩包内的 `plugin.json` 自动提取,无需重复填写。
|
||||
如果同一个仓库还发布了其他用途的 Release,可额外加上 `tag_prefix` 来限定只同步特定前缀的标签。插件名称、简介、版本号、图标、许可证、兼容范围与校验哈希均由市场自动从压缩包提取,无需手动填写。
|
||||
|
||||
---
|
||||
## 编写建议
|
||||
|
||||
## 分级审核与市场红线 / Review Policy & Redlines
|
||||
- **插件图标**:在插件清单中声明背景色令牌(支持 `indigo`、`purple`、`sky`、`rose`、`emerald`、`amber`、`teal`、`slate`)和包内的单色 SVG 前景图标,市场与客户端会统一使用你声明的图标。
|
||||
- **语言包**:标题和简介直接用对应语言书写即可,无需额外适配中英文,简介保持精炼的一句话(例如繁体中文语言包:「為 Reims-Go 提供繁體中文介面。」)。
|
||||
|
||||
| 分级 | 类型 | 审核标准 |
|
||||
| :--- | :--- | :--- |
|
||||
| **L1** | 主题、语言包、VM 模板、运行时源、规则 Hook | 通过 `reims-go plugin doctor --json` 零硬拦截,许可证清晰;**严禁夹带任何可执行文件或系统脚本** |
|
||||
| **L4 / `ui:script`** | `iframe` 面板、交互主题脚本 | 公开源码仓库,通过静态门禁(禁止 `window.go` / `window.runtime` / `eval` / 未声明联网等)并经人工代码复核;`ui:script` 在主窗口界面环境运行并可访问页面 DOM(非隔离沙盒),客户端在市场与已安装页均会展示脚本路径与 SHA-256,升级改动脚本后自动暂停待用户重新确认 |
|
||||
| **L3 Sidecar** | 原生可执行程序(如额外客体驱动) | **必须开源且由 GitHub Actions 从源码可复现构建**,禁止未声明额外二进制;客户端将向用户如实披露当前 Windows 账户完整权限与可执行文件 SHA-256 |
|
||||
## 安全审核与红线
|
||||
|
||||
### 绝对红线(CI 与客户端双重硬拦截)
|
||||
- 严禁包含任何 Apple 专有系统文件(`.ipsw`、`BaseSystem.dmg`、`InstallESD.dmg`)、闭源固件、SMC OSK 或真实 SMBIOS 序列号。
|
||||
- 严禁在 `.svg` 中嵌入 `<script>`、内联 `on*=` 事件或 `javascript:` 链接。
|
||||
- 严禁未声明的二进制/脚本文件或未经 `SHA256SUMS` 覆盖的隐藏文件。
|
||||
- 第三方运行时包须遵守开源合规要求,同处提供对应源码包与完整许可证文本。
|
||||
市场会在 PR 审核与每次自动同步时运行静态安全检查,以下内容会被直接拦截:
|
||||
|
||||
---
|
||||
- 包含任何 Apple 专有系统文件、闭源固件、SMC OSK 或真实硬件序列号。
|
||||
- 在 SVG 图标中嵌入脚本、内联事件或外部链接。
|
||||
- 夹带未声明的可执行程序、系统脚本或未纳入校验清单的文件。
|
||||
- 含原生可执行程序或交互脚本的插件必须开源,且客户端在安装和更新导致文件哈希变化时都会向用户披露风险并要求重新确认。
|
||||
|
||||
## 软撤回机制 / Soft Withdrawal
|
||||
## 软撤回
|
||||
|
||||
当插件发现安全问题、停止维护或已被新插件替代时,维护者会将其从 `registry.json` 移入 [`withdrawn.json`](withdrawn.json):
|
||||
- 新用户将被阻止安装,并在界面/CLI 中看到撤回原因与推荐替代插件;
|
||||
- 已安装用户不会在本地被静默删除,仍可继续使用并收到迁移提示。
|
||||
若插件停止维护、发现安全问题或已有替代品,维护者会将其移入 [withdrawn.json](withdrawn.json)。新用户将无法继续安装并会看到替代提示,已安装用户的本地插件不会被静默删除。
|
||||
+52
-148
@@ -7,160 +7,64 @@
|
||||
"kind": "tool",
|
||||
"trust": "community",
|
||||
"channel": "alpha",
|
||||
"version": "0.2.2",
|
||||
"asset": "local.capture-shortcut-0.2.2.zip",
|
||||
"sha256": "796949f8caf76ebafa4116c4ca03643b3b87a893d833171e138aa23a55255aff",
|
||||
"tags": ["keyboard", "mouse", "input"],
|
||||
"changelog": {
|
||||
"zh-CN": "支持自定义释放快捷键和鼠标移出时释放。需要 Plugin API 1.2 和支持该功能的 Reims vGPU 运行时。",
|
||||
"en-US": "Adds a configurable input release shortcut and mouse-leave release. Requires Plugin API 1.2 and a compatible Reims vGPU runtime."
|
||||
}
|
||||
"tags": ["keyboard", "mouse", "input"]
|
||||
},
|
||||
{
|
||||
"trust": "official",
|
||||
"id": "reims.agent",
|
||||
"kind": "tool",
|
||||
"version": "0.1.0",
|
||||
"tags": [
|
||||
"mcp",
|
||||
"agent",
|
||||
"computer-use",
|
||||
"ssh",
|
||||
"automation",
|
||||
"MCP"
|
||||
],
|
||||
"sha256": "0c662804508b1b6b06e10f80f395b28814cc4e280907f833c5e629d3293dac79",
|
||||
"channel": "stable",
|
||||
"repo": "reims-go/reims-agent",
|
||||
"asset": "reims.agent-0.1.0.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个正式版本:提供受宿主按虚拟机授权的 MCP 服务,支持截图、批量桌面操作、光标去噪屏幕等待、DPAPI 自动解锁、SSH/SFTP 及隔离 CoW 测试运行。",
|
||||
"en-US": "Initial stable release: official host-authorized MCP service for per-VM screenshots, batched desktop controls, cursor-tolerant screen waits, DPAPI unlock, SSH/SFTP, and isolated CoW test runs."
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "official",
|
||||
"id": "official.lang.zh-tw",
|
||||
"kind": "locale",
|
||||
"version": "1.0.0",
|
||||
"tags": [
|
||||
"locale",
|
||||
"i18n",
|
||||
"zh-TW",
|
||||
"traditional-chinese",
|
||||
"繁體中文"
|
||||
],
|
||||
"sha256": "2ff6ad79357035d68bbebe0e3700e8ef2b30d4d9ef44181532959a4525cbfbc6",
|
||||
"channel": "stable",
|
||||
"repo": "reims-go/lang-zh-tw",
|
||||
"asset": "official.lang.zh-tw-1.0.0.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个正式版本:完整覆盖全部 7 个语系域(1183/1183 条,100% 覆盖率),含 macOS 繁体中文术语表与内置扩展名称本地化。",
|
||||
"en-US": "Initial stable release: 100% coverage across all 7 domains (1183/1183 keys), including Traditional Chinese macOS glossary and built-in plugin manifest overrides."
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "community",
|
||||
"id": "community.lang.ko-kr",
|
||||
"kind": "locale",
|
||||
"version": "1.0.0",
|
||||
"tags": [
|
||||
"locale",
|
||||
"i18n",
|
||||
"ko-KR",
|
||||
"korean",
|
||||
"한국어"
|
||||
],
|
||||
"sha256": "9e4dca0c87afd550e4988c33043d1437c4031ed0da279ac26d98425a76bb2157",
|
||||
"channel": "stable",
|
||||
"repo": "jinhyeok694/reims-go-lang-ko-kr",
|
||||
"asset": "community.lang.ko-kr-1.0.0.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个正式版本:完整覆盖全部 7 个语系域(1183/1183 条,100% 覆盖率),含 macOS 韩语官方术语表与内置扩展名称本地化。",
|
||||
"en-US": "Initial stable release: 100% coverage across all 7 domains (1183/1183 keys), including Korean macOS glossary and built-in plugin manifest overrides.",
|
||||
"ko-KR": "첫 정식 버전: 7개 언어 영역 전체 100% 번역(1183/1183개 키), macOS 한국어 공식 용어집과 내장 플러그인 이름 현지화 포함."
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "community",
|
||||
"id": "abadx.lang.es-es",
|
||||
"kind": "locale",
|
||||
"version": "1.0.1",
|
||||
"tags": [
|
||||
"locale",
|
||||
"i18n",
|
||||
"es-ES",
|
||||
"spanish",
|
||||
"español"
|
||||
],
|
||||
"sha256": "0cc657e11f93999de0c50fa96530582631dbbcc88481e5897d27eeb7d745da45",
|
||||
"channel": "stable",
|
||||
"repo": "AbadXDev/reims-go-lang-es-es",
|
||||
"asset": "abadx.lang.es-es-1.0.1.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个正式版本:完整覆盖全部 7 个语系域(1264/1264 条,100% 覆盖率),含 macOS 西班牙语术语表与内置扩展名称本地化。",
|
||||
"en-US": "Initial stable release: 100% coverage across all 7 domains (1264/1264 keys), including Spanish macOS glossary and built-in plugin manifest overrides.",
|
||||
"es-ES": "Primera versión estable: cobertura completa de los 7 dominios (1.264 de 1.264 claves), con glosario de macOS en español y traducciones de los plugins integrados."
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "community",
|
||||
"id": "community.lang.ar-sa",
|
||||
"kind": "locale",
|
||||
"version": "1.1.4",
|
||||
"tags": [
|
||||
"locale",
|
||||
"i18n",
|
||||
"ar-SA",
|
||||
"arabic",
|
||||
"العربية"
|
||||
],
|
||||
"sha256": "db58f2c3a820b9bc20665f02f3f4d72b067cfaddffb849b9d17c60e95899f883",
|
||||
"channel": "stable",
|
||||
"repo": "Eng-Novel/reims-go-lang-ar-sa-release",
|
||||
"asset": "community.lang.ar-sa-1.1.4.zip",
|
||||
"changelog": {
|
||||
"en-US": "Arabic localization update: fixed Arabic line wrapping and mixed-script RTL ordering in the Windows Install Guide.",
|
||||
"zh-CN": "阿拉伯语本地化更新:修复 Windows 安装指南中的阿拉伯语换行和混合文字 RTL 顺序。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "community",
|
||||
"id": "yfl520.theme.wallpaper-studio",
|
||||
"kind": "theme",
|
||||
"version": "1.1.0",
|
||||
"tags": [
|
||||
"theme",
|
||||
"wallpaper",
|
||||
"video",
|
||||
"glass",
|
||||
"动态壁纸",
|
||||
"交互主题"
|
||||
],
|
||||
"sha256": "f2af730f8701964e3becbdf826cba112b9b38f76f146b02ca00cf0db82a0000d",
|
||||
"channel": "stable",
|
||||
"repo": "yfl520/reims-theme-wallpaper-studio",
|
||||
"asset": "yfl520.theme.wallpaper-studio-1.1.0.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个上架版本:导入本机图片、GIF 与 MP4/WebM 视频壁纸,支持定时轮播、背景遮罩与卡片不透明度实时调节、虚拟机运行时自动暂停视频、清空壁纸库,内置昼夜双景与 6 套配色",
|
||||
"en-US": "First marketplace release: import local images, GIFs, and MP4/WebM videos as wallpapers, with slideshow, live dimming and card opacity controls, automatic video pause while a VM is running, a clear library action, built-in day and night backdrops, and 6 accent schemes"
|
||||
}
|
||||
},
|
||||
{
|
||||
"trust": "community",
|
||||
"id": "reimscommunity.usb-passthrough",
|
||||
"kind": "tool",
|
||||
"version": "0.1.0-beta.6",
|
||||
"tags": ["usb", "usbip", "iphone", "macos"],
|
||||
"sha256": "23987e25408f6ffbf9ec645818836fcf770971e29be4790e38efad8e94d4818d",
|
||||
"channel": "alpha",
|
||||
"trust": "official",
|
||||
"channel": "stable",
|
||||
"tags": ["mcp", "agent", "computer-use", "ssh", "automation"]
|
||||
},
|
||||
{
|
||||
"id": "official.lang.zh-tw",
|
||||
"repo": "reims-go/lang-zh-tw",
|
||||
"kind": "locale",
|
||||
"trust": "official",
|
||||
"channel": "stable",
|
||||
"tags": ["locale", "i18n", "zh-TW", "traditional-chinese", "繁體中文"]
|
||||
},
|
||||
{
|
||||
"id": "community.lang.ko-kr",
|
||||
"repo": "jinhyeok694/reims-go-lang-ko-kr",
|
||||
"kind": "locale",
|
||||
"trust": "community",
|
||||
"channel": "stable",
|
||||
"tags": ["locale", "i18n", "ko-KR", "korean", "한국어"]
|
||||
},
|
||||
{
|
||||
"id": "abadx.lang.es-es",
|
||||
"repo": "AbadXDev/reims-go-lang-es-es",
|
||||
"kind": "locale",
|
||||
"trust": "community",
|
||||
"channel": "stable",
|
||||
"tags": ["locale", "i18n", "es-ES", "spanish", "español"]
|
||||
},
|
||||
{
|
||||
"id": "community.lang.ar-sa",
|
||||
"repo": "Eng-Novel/reims-go-lang-ar-sa-release",
|
||||
"kind": "locale",
|
||||
"trust": "community",
|
||||
"channel": "stable",
|
||||
"tags": ["locale", "i18n", "ar-SA", "arabic", "العربية"]
|
||||
},
|
||||
{
|
||||
"id": "yfl520.theme.wallpaper-studio",
|
||||
"repo": "yfl520/reims-theme-wallpaper-studio",
|
||||
"kind": "theme",
|
||||
"trust": "community",
|
||||
"channel": "stable",
|
||||
"tags": ["theme", "wallpaper", "video", "glass", "动态壁纸", "交互主题"]
|
||||
},
|
||||
{
|
||||
"id": "reimscommunity.usb-passthrough",
|
||||
"repo": "mango6i/reims-go-usb-passthrough",
|
||||
"tag": "usb-plugin-v0.1.0-beta.6",
|
||||
"asset": "reimscommunity.usb-passthrough-0.1.0-beta.6.zip",
|
||||
"changelog": {
|
||||
"zh-CN": "首个市场测试版。使用带 QBridge 的 Reims vGPU 运行时,通过本地 USB/IP 导出端连接、释放共享的 USB 设备。",
|
||||
"en-US": "Initial marketplace preview. Connect and release shared USB devices through a local USB/IP exporter and a QBridge-enabled Reims vGPU runtime."
|
||||
}
|
||||
"kind": "tool",
|
||||
"trust": "community",
|
||||
"channel": "alpha",
|
||||
"tag_prefix": "usb-plugin-v",
|
||||
"tags": ["usb", "usbip", "iphone", "macos"]
|
||||
}
|
||||
]
|
||||
}
|
||||
+296
-93
@@ -2,6 +2,12 @@
|
||||
/**
|
||||
* Reims-Go Plugin Market validator & index builder.
|
||||
*
|
||||
* Supports both:
|
||||
* - Continuous GitHub Release tracking ("soft-link" mode): registry entry only
|
||||
* declares id, repo, kind, trust, channel (and optional tag_prefix / asset).
|
||||
* - Pinned mode (backward compatible): registry entry pins version, sha256,
|
||||
* and download_url or (repo + tag + asset).
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/build-index.mjs [--check] [--out-dir dist] [--reims-bin ./reims-go] [--report pr-report.md]
|
||||
*
|
||||
@@ -19,7 +25,9 @@ const RE_SHA256 = /^[0-9a-f]{64}$/
|
||||
const ALLOWED_CHANNELS = new Set(['stable', 'alpha'])
|
||||
const ALLOWED_TRUST = new Set(['official', 'verified', 'community'])
|
||||
const ALLOWED_KINDS = new Set(['theme', 'locale', 'driver', 'tool', 'template', 'runtime'])
|
||||
const ALLOWED_ICON_TONES = new Set(['indigo', 'purple', 'sky', 'rose', 'emerald', 'amber', 'teal', 'slate'])
|
||||
const MAX_ZIP_BYTES = 256 * 1024 * 1024 // 256 MiB
|
||||
const MAX_ICON_SVG_BYTES = 32 * 1024 // 32 KiB
|
||||
|
||||
function parseArgs(argv) {
|
||||
const opts = {
|
||||
@@ -52,6 +60,12 @@ function normalizeLocalized(val) {
|
||||
if (typeof val === 'object') {
|
||||
const out = {}
|
||||
for (const [k, v] of Object.entries(val)) {
|
||||
if (k === 'extra' && v && typeof v === 'object') {
|
||||
for (const [ek, ev] of Object.entries(v)) {
|
||||
if (typeof ev === 'string' && ev.trim()) out[ek] = ev.trim()
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (typeof v === 'string' && v.trim()) out[k] = v.trim()
|
||||
}
|
||||
return Object.keys(out).length > 0 ? out : undefined
|
||||
@@ -59,11 +73,43 @@ function normalizeLocalized(val) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
function extractSafeSvg(rawText) {
|
||||
const text = String(rawText || '').trim()
|
||||
if (!text) return ''
|
||||
if (Buffer.byteLength(text, 'utf8') > MAX_ICON_SVG_BYTES) return ''
|
||||
if (/<script\b|\bon[a-z]+\s*=|javascript:|<foreignobject\b/i.test(text)) return ''
|
||||
const lower = text.toLowerCase()
|
||||
const start = lower.indexOf('<svg')
|
||||
const end = lower.lastIndexOf('</svg>')
|
||||
if (start < 0 || end < start) return ''
|
||||
return text.slice(start, end + '</svg>'.length).trim()
|
||||
}
|
||||
|
||||
function extractPluginIcon(buf, manifest) {
|
||||
if (!manifest?.icon || typeof manifest.icon !== 'object') return undefined
|
||||
const out = {}
|
||||
const tone = String(manifest.icon.tone || '').trim().toLowerCase()
|
||||
if (ALLOWED_ICON_TONES.has(tone)) out.tone = tone
|
||||
const svgRef = String(manifest.icon.svg || '').trim()
|
||||
if (svgRef && !svgRef.startsWith('<')) {
|
||||
const cleanRel = svgRef.replace(/^\.\//, '').replace(/\\/g, '/')
|
||||
if (!cleanRel.startsWith('/') && !cleanRel.includes('..') && cleanRel.toLowerCase().endsWith('.svg')) {
|
||||
try {
|
||||
const raw = readFileFromZipBuffer(buf, cleanRel)
|
||||
const safe = extractSafeSvg(raw.toString('utf8'))
|
||||
if (safe) out.svg = safe
|
||||
} catch {
|
||||
// Ignore missing/unreadable icon SVG; doctor gate handles hard errors.
|
||||
}
|
||||
}
|
||||
}
|
||||
return Object.keys(out).length > 0 ? out : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Pure-Node ZIP reader to extract a single entry (plugin.json) without external tools.
|
||||
* Pure-Node ZIP reader to extract a single entry without external tools.
|
||||
*/
|
||||
function readFileFromZipBuffer(buf, targetName) {
|
||||
// Locate End of Central Directory (EOCD) signature 0x06054b50 from end of buffer.
|
||||
let eocdOffset = -1
|
||||
const minPos = Math.max(0, buf.length - 65557)
|
||||
for (let pos = buf.length - 22; pos >= minPos; pos--) {
|
||||
@@ -106,6 +152,101 @@ function readFileFromZipBuffer(buf, targetName) {
|
||||
throw new Error(`ZIP archive is missing ${targetName}`)
|
||||
}
|
||||
|
||||
function githubHeaders(extra = {}) {
|
||||
const headers = { 'User-Agent': 'reims-go-plugins-ci', ...extra }
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
async function fetchGitHubRepoStats(repo) {
|
||||
if (!repo) return { stars: 0 }
|
||||
try {
|
||||
const resp = await fetch(`https://api.github.com/repos/${repo}`, {
|
||||
headers: githubHeaders({ Accept: 'application/vnd.github+json' }),
|
||||
redirect: 'follow',
|
||||
})
|
||||
if (!resp.ok) return { stars: 0 }
|
||||
const data = await resp.json()
|
||||
return { stars: Number.isFinite(data?.stargazers_count) ? data.stargazers_count : 0 }
|
||||
} catch {
|
||||
return { stars: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchGitHubReleases(repo) {
|
||||
const url = `https://api.github.com/repos/${repo}/releases?per_page=30`
|
||||
const resp = await fetch(url, {
|
||||
headers: githubHeaders({ Accept: 'application/vnd.github+json' }),
|
||||
redirect: 'follow',
|
||||
})
|
||||
if (!resp.ok) {
|
||||
throw new Error(`HTTP ${resp.status} listing GitHub releases for ${repo}`)
|
||||
}
|
||||
const data = await resp.json()
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error(`Unexpected GitHub releases payload for ${repo}`)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
function selectReleaseAsset(release, entry) {
|
||||
const assets = Array.isArray(release.assets) ? release.assets : []
|
||||
const zips = assets.filter((a) => typeof a?.name === 'string' && a.name.toLowerCase().endsWith('.zip'))
|
||||
if (zips.length === 0) return null
|
||||
if (entry.asset) {
|
||||
return zips.find((a) => a.name === entry.asset) || null
|
||||
}
|
||||
const idPrefix = `${entry.id.toLowerCase()}-`
|
||||
const byID = zips.find((a) => a.name.toLowerCase().startsWith(idPrefix))
|
||||
if (byID) return byID
|
||||
if (zips.length === 1) return zips[0]
|
||||
return null
|
||||
}
|
||||
|
||||
function summarizeReleaseBody(body) {
|
||||
if (typeof body !== 'string') return undefined
|
||||
const lines = body
|
||||
.replace(/\r\n/g, '\n')
|
||||
.split('\n')
|
||||
.map((l) => l.trim())
|
||||
.filter((l) => l && !l.startsWith('#') && !l.startsWith('```') && !l.startsWith('|'))
|
||||
if (lines.length === 0) return undefined
|
||||
const text = lines.slice(0, 3).join(' ').replace(/\s+/g, ' ').trim()
|
||||
if (!text) return undefined
|
||||
const clipped = text.length > 240 ? `${text.slice(0, 237)}...` : text
|
||||
return { 'zh-CN': clipped, 'en-US': clipped }
|
||||
}
|
||||
|
||||
async function resolveLatestReleaseCandidates(entry, channel) {
|
||||
if (!entry.repo) {
|
||||
throw new Error('auto-tracked plugin entry must specify repo (owner/name)')
|
||||
}
|
||||
const releases = await fetchGitHubReleases(entry.repo)
|
||||
const tagPrefix = typeof entry.tag_prefix === 'string' ? entry.tag_prefix : ''
|
||||
const candidates = []
|
||||
let totalDownloads = 0
|
||||
for (const rel of releases) {
|
||||
if (!rel || rel.draft) continue
|
||||
if (tagPrefix && !String(rel.tag_name || '').startsWith(tagPrefix)) continue
|
||||
const asset = selectReleaseAsset(rel, entry)
|
||||
if (!asset || !asset.browser_download_url) continue
|
||||
if (Number.isFinite(asset.download_count)) totalDownloads += asset.download_count
|
||||
if (channel === 'stable' && rel.prerelease) continue
|
||||
candidates.push({
|
||||
tag: rel.tag_name,
|
||||
downloadURL: asset.browser_download_url,
|
||||
publishedAt: rel.published_at || rel.created_at || new Date().toISOString(),
|
||||
body: rel.body || '',
|
||||
})
|
||||
}
|
||||
if (candidates.length === 0) {
|
||||
throw new Error(`no matching ${channel} GitHub Release with a .zip plugin asset found in ${entry.repo}`)
|
||||
}
|
||||
return { candidates, totalDownloads }
|
||||
}
|
||||
|
||||
async function downloadBuffer(url) {
|
||||
const headers = { 'User-Agent': 'reims-go-plugins-ci' }
|
||||
if (process.env.GITHUB_TOKEN && url.includes('github.com')) {
|
||||
@@ -169,6 +310,94 @@ function validateWithdrawn(withdrawnDoc) {
|
||||
return { ids, list: out }
|
||||
}
|
||||
|
||||
async function verifyAndBuildCandidate({ entry, channel, kind, trust, candidate, pinnedVersion, pinnedSHA256, stats, opts, tmpRoot }) {
|
||||
const parsedURL = new URL(candidate.downloadURL)
|
||||
if (parsedURL.protocol !== 'https:') {
|
||||
throw new Error(`download_url must use https:// (got ${candidate.downloadURL})`)
|
||||
}
|
||||
|
||||
const buf = await downloadBuffer(candidate.downloadURL)
|
||||
const gotSum = crypto.createHash('sha256').update(buf).digest('hex')
|
||||
if (pinnedSHA256 && gotSum !== pinnedSHA256) {
|
||||
throw new Error(`SHA-256 mismatch: registry=${pinnedSHA256}, actual=${gotSum}`)
|
||||
}
|
||||
|
||||
const manifestRaw = readFileFromZipBuffer(buf, 'plugin.json')
|
||||
const manifest = JSON.parse(manifestRaw.toString('utf8'))
|
||||
if (manifest.id !== entry.id) {
|
||||
throw new Error(`anti-swap id mismatch: registry=${entry.id}, plugin.json=${manifest.id}`)
|
||||
}
|
||||
const version = String(manifest.version || '').trim()
|
||||
if (!version) {
|
||||
throw new Error('plugin.json is missing version')
|
||||
}
|
||||
if (pinnedVersion && version !== pinnedVersion) {
|
||||
throw new Error(`anti-swap version mismatch: registry=${pinnedVersion}, plugin.json=${version}`)
|
||||
}
|
||||
|
||||
let scanReport = null
|
||||
if (opts.reimsBin) {
|
||||
const zipPath = path.join(tmpRoot, `${entry.id}-${version}-${gotSum.slice(0, 8)}.zip`)
|
||||
fs.writeFileSync(zipPath, buf)
|
||||
const { report } = runDoctor(opts.reimsBin, zipPath)
|
||||
scanReport = report
|
||||
if (report.hard_blocked) {
|
||||
const reasons = (report.hard_findings || [])
|
||||
.map((f) => `[${f.check}] ${f.target ? `${f.target}: ` : ''}${f.message}`)
|
||||
.join('; ')
|
||||
throw new Error(`static security gate blocked: ${reasons}`)
|
||||
}
|
||||
}
|
||||
|
||||
const tier = scanReport?.tier || (manifest.entry?.sidecar ? 'L3' : manifest.entry?.panelDir ? 'L4' : 'L1')
|
||||
const effectiveTrust = trust === 'official' || trust === 'verified' ? trust : 'community'
|
||||
const icon = extractPluginIcon(buf, manifest)
|
||||
const marketItem = {
|
||||
id: manifest.id,
|
||||
version,
|
||||
name: normalizeLocalized(manifest.name) || { 'en-US': manifest.id },
|
||||
description: normalizeLocalized(manifest.description) || { 'en-US': '' },
|
||||
publisher: manifest.publisher || (entry.repo ? entry.repo.split('/')[0] : 'community'),
|
||||
license: manifest.license || '',
|
||||
channel,
|
||||
trust: effectiveTrust,
|
||||
kind,
|
||||
tier,
|
||||
icon,
|
||||
homepage: manifest.homepage || (entry.repo ? `https://github.com/${entry.repo}` : undefined),
|
||||
readme_url: entry.readme_url || (entry.repo ? `https://github.com/${entry.repo}#readme` : undefined),
|
||||
engines: manifest.engines || {},
|
||||
platforms: Array.isArray(manifest.platforms) ? manifest.platforms : undefined,
|
||||
permissions: Array.isArray(manifest.permissions) ? manifest.permissions : undefined,
|
||||
download_url: candidate.downloadURL,
|
||||
sha256: gotSum,
|
||||
size_bytes: buf.length,
|
||||
changelog: normalizeLocalized(entry.changelog) || summarizeReleaseBody(candidate.body),
|
||||
tags: Array.isArray(entry.tags) ? entry.tags : undefined,
|
||||
stars: stats?.stars > 0 ? stats.stars : undefined,
|
||||
downloads: stats?.downloads > 0 ? stats.downloads : undefined,
|
||||
updated_at: entry.updated_at || candidate.publishedAt || new Date().toISOString(),
|
||||
}
|
||||
for (const k of Object.keys(marketItem)) {
|
||||
if (marketItem[k] === undefined) delete marketItem[k]
|
||||
}
|
||||
return {
|
||||
marketItem,
|
||||
reportRow: {
|
||||
status: 'PASS',
|
||||
id: marketItem.id,
|
||||
version: marketItem.version,
|
||||
tier,
|
||||
trust: effectiveTrust,
|
||||
sizeBytes: buf.length,
|
||||
sha256: gotSum,
|
||||
capabilities: scanReport?.capabilities || [],
|
||||
executables: scanReport?.executables || [],
|
||||
pending: scanReport?.pending_findings || [],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const opts = parseArgs(process.argv.slice(2))
|
||||
const rootDir = process.cwd()
|
||||
@@ -188,7 +417,7 @@ async function main() {
|
||||
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'reims-plugins-build-'))
|
||||
try {
|
||||
for (const entry of registryDoc.plugins) {
|
||||
const label = `${entry?.id || '<missing-id>'}@${entry?.version || '<missing-version>'}`
|
||||
const label = `${entry?.id || '<missing-id>'}@${entry?.version || 'latest'}`
|
||||
try {
|
||||
if (!entry || typeof entry.id !== 'string' || !RE_ID.test(entry.id)) {
|
||||
throw new Error(`invalid plugin id ${JSON.stringify(entry?.id)}`)
|
||||
@@ -196,9 +425,7 @@ async function main() {
|
||||
if (withdrawnIDs.has(entry.id)) {
|
||||
throw new Error(`plugin ${entry.id} is listed in withdrawn.json and must be removed from registry.json`)
|
||||
}
|
||||
if (typeof entry.version !== 'string' || !entry.version.trim()) {
|
||||
throw new Error('missing version')
|
||||
}
|
||||
|
||||
const channel = (entry.channel || 'stable').toLowerCase()
|
||||
if (!ALLOWED_CHANNELS.has(channel)) throw new Error(`invalid channel ${JSON.stringify(channel)}`)
|
||||
const key = `${entry.id}:${channel}`
|
||||
@@ -211,100 +438,77 @@ async function main() {
|
||||
const trust = (entry.trust || 'community').toLowerCase()
|
||||
if (!ALLOWED_TRUST.has(trust)) throw new Error(`invalid trust ${JSON.stringify(trust)}`)
|
||||
|
||||
const sha256 = String(entry.sha256 || '').toLowerCase().trim()
|
||||
if (!RE_SHA256.test(sha256)) throw new Error('sha256 must be a 64-character lowercase hex string')
|
||||
|
||||
let downloadURL = String(entry.download_url || '').trim()
|
||||
if (!downloadURL) {
|
||||
if (!entry.repo || !entry.asset) {
|
||||
throw new Error('either download_url or (repo + asset) must be specified')
|
||||
const isPinned = Boolean(entry.version || entry.sha256 || entry.download_url)
|
||||
const repoStats = entry.repo ? await fetchGitHubRepoStats(entry.repo) : { stars: 0 }
|
||||
if (isPinned) {
|
||||
if (typeof entry.version !== 'string' || !entry.version.trim()) {
|
||||
throw new Error('pinned entry must specify version')
|
||||
}
|
||||
const tag = entry.tag || `v${entry.version}`
|
||||
downloadURL = `https://github.com/${entry.repo}/releases/download/${tag}/${entry.asset}`
|
||||
}
|
||||
const parsedURL = new URL(downloadURL)
|
||||
if (parsedURL.protocol !== 'https:') {
|
||||
throw new Error(`download_url must use https:// (got ${downloadURL})`)
|
||||
}
|
||||
|
||||
const buf = await downloadBuffer(downloadURL)
|
||||
const gotSum = crypto.createHash('sha256').update(buf).digest('hex')
|
||||
if (gotSum !== sha256) {
|
||||
throw new Error(`SHA-256 mismatch: registry=${sha256}, actual=${gotSum}`)
|
||||
}
|
||||
|
||||
const manifestRaw = readFileFromZipBuffer(buf, 'plugin.json')
|
||||
const manifest = JSON.parse(manifestRaw.toString('utf8'))
|
||||
if (manifest.id !== entry.id) {
|
||||
throw new Error(`anti-swap id mismatch: registry=${entry.id}, plugin.json=${manifest.id}`)
|
||||
}
|
||||
if (manifest.version !== entry.version) {
|
||||
throw new Error(`anti-swap version mismatch: registry=${entry.version}, plugin.json=${manifest.version}`)
|
||||
}
|
||||
|
||||
let scanReport = null
|
||||
if (opts.reimsBin) {
|
||||
const zipPath = path.join(tmpRoot, `${entry.id}-${entry.version}.zip`)
|
||||
fs.writeFileSync(zipPath, buf)
|
||||
const { report } = runDoctor(opts.reimsBin, zipPath)
|
||||
scanReport = report
|
||||
if (report.hard_blocked) {
|
||||
const reasons = (report.hard_findings || [])
|
||||
.map((f) => `[${f.check}] ${f.target ? `${f.target}: ` : ''}${f.message}`)
|
||||
.join('; ')
|
||||
throw new Error(`static security gate blocked: ${reasons}`)
|
||||
const sha256 = String(entry.sha256 || '').toLowerCase().trim()
|
||||
if (!RE_SHA256.test(sha256)) throw new Error('sha256 must be a 64-character lowercase hex string')
|
||||
let downloadURL = String(entry.download_url || '').trim()
|
||||
if (!downloadURL) {
|
||||
if (!entry.repo || !entry.asset) {
|
||||
throw new Error('either download_url or (repo + asset) must be specified')
|
||||
}
|
||||
const tag = entry.tag || `v${entry.version}`
|
||||
downloadURL = `https://github.com/${entry.repo}/releases/download/${tag}/${entry.asset}`
|
||||
}
|
||||
const built = await verifyAndBuildCandidate({
|
||||
entry,
|
||||
channel,
|
||||
kind,
|
||||
trust,
|
||||
candidate: { downloadURL, publishedAt: entry.updated_at || new Date().toISOString(), body: '' },
|
||||
pinnedVersion: entry.version.trim(),
|
||||
pinnedSHA256: sha256,
|
||||
stats: { stars: repoStats.stars, downloads: 0 },
|
||||
opts,
|
||||
tmpRoot,
|
||||
})
|
||||
marketPlugins.push(built.marketItem)
|
||||
reportRows.push(built.reportRow)
|
||||
} else {
|
||||
const { candidates, totalDownloads } = await resolveLatestReleaseCandidates(entry, channel)
|
||||
let built = null
|
||||
let lastErr = null
|
||||
// In PR --check mode, only accept the latest release; in scheduled publish mode,
|
||||
// fall back to an earlier passing release if the newest one fails the gate.
|
||||
const maxAttempts = opts.checkOnly ? 1 : Math.min(candidates.length, 5)
|
||||
for (let i = 0; i < maxAttempts; i++) {
|
||||
try {
|
||||
built = await verifyAndBuildCandidate({
|
||||
entry,
|
||||
channel,
|
||||
kind,
|
||||
trust,
|
||||
candidate: candidates[i],
|
||||
pinnedVersion: '',
|
||||
pinnedSHA256: '',
|
||||
stats: { stars: repoStats.stars, downloads: totalDownloads },
|
||||
opts,
|
||||
tmpRoot,
|
||||
})
|
||||
if (i > 0) {
|
||||
console.warn(`WARN ${entry.id}: latest release ${candidates[0].tag} failed (${lastErr?.message}); fell back to ${candidates[i].tag}`)
|
||||
}
|
||||
break
|
||||
} catch (err) {
|
||||
lastErr = err
|
||||
}
|
||||
}
|
||||
if (!built) {
|
||||
throw lastErr || new Error('no valid release passed verification')
|
||||
}
|
||||
marketPlugins.push(built.marketItem)
|
||||
reportRows.push(built.reportRow)
|
||||
}
|
||||
|
||||
const tier = scanReport?.tier || (manifest.entry?.sidecar ? 'L3' : manifest.entry?.panelDir ? 'L4' : 'L1')
|
||||
const effectiveTrust = trust === 'official' || trust === 'verified' ? trust : 'community'
|
||||
const marketItem = {
|
||||
id: manifest.id,
|
||||
version: manifest.version,
|
||||
name: normalizeLocalized(manifest.name) || { 'en-US': manifest.id },
|
||||
description: normalizeLocalized(manifest.description) || { 'en-US': '' },
|
||||
publisher: manifest.publisher || (entry.repo ? entry.repo.split('/')[0] : 'community'),
|
||||
license: manifest.license || '',
|
||||
channel,
|
||||
trust: effectiveTrust,
|
||||
kind,
|
||||
tier,
|
||||
homepage: manifest.homepage || (entry.repo ? `https://github.com/${entry.repo}` : undefined),
|
||||
readme_url: entry.readme_url || (entry.repo ? `https://github.com/${entry.repo}#readme` : undefined),
|
||||
engines: manifest.engines || {},
|
||||
platforms: Array.isArray(manifest.platforms) ? manifest.platforms : undefined,
|
||||
permissions: Array.isArray(manifest.permissions) ? manifest.permissions : undefined,
|
||||
download_url: downloadURL,
|
||||
sha256: gotSum,
|
||||
size_bytes: buf.length,
|
||||
changelog: normalizeLocalized(entry.changelog),
|
||||
tags: Array.isArray(entry.tags) ? entry.tags : undefined,
|
||||
updated_at: entry.updated_at || new Date().toISOString(),
|
||||
}
|
||||
// Strip undefined fields for clean JSON output.
|
||||
for (const k of Object.keys(marketItem)) {
|
||||
if (marketItem[k] === undefined) delete marketItem[k]
|
||||
}
|
||||
marketPlugins.push(marketItem)
|
||||
|
||||
reportRows.push({
|
||||
status: 'PASS',
|
||||
id: marketItem.id,
|
||||
version: marketItem.version,
|
||||
tier,
|
||||
trust: effectiveTrust,
|
||||
sizeBytes: buf.length,
|
||||
sha256: gotSum,
|
||||
capabilities: scanReport?.capabilities || [],
|
||||
executables: scanReport?.executables || [],
|
||||
pending: scanReport?.pending_findings || [],
|
||||
})
|
||||
} catch (err) {
|
||||
errors.push(`${label}: ${err.message}`)
|
||||
reportRows.push({
|
||||
status: 'FAIL',
|
||||
id: entry?.id || 'unknown',
|
||||
version: entry?.version || 'unknown',
|
||||
version: entry?.version || 'latest',
|
||||
error: err.message,
|
||||
})
|
||||
}
|
||||
@@ -313,7 +517,6 @@ async function main() {
|
||||
fs.rmSync(tmpRoot, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
// Generate human-readable Markdown review summary for PR comments & workflow logs.
|
||||
const mdLines = [
|
||||
'## Reims-Go Plugin Market Gate Report',
|
||||
'',
|
||||
|
||||
Reference in new issue
Block a user