Skip to content

feat(marketplace): resolveSource 报告索引跟随的仓库和分支,可按提交固定地址绕过 raw 缓存;GitHub 新增 latestCommit 和 listReleases - #173

Merged
xiaoyumuxi merged 2 commits into
mainfrom
feat/marketplace-commit-pin-releases
Nov 22, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
feat/marketplace-commit-pin-releases

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

背景

Store 合入插件新版本后,桌面端要等好几分钟才看到更新。原因之一是 raw.githubusercontent.com 对分支地址(…/HEAD/lithe-plugin-index.json)缓存 max-age=300,加随机查询参数或 Cache-Control: no-cache 都还是命中缓存。按提交 SHA 的地址不会命中旧缓存(实测 X-Cache: MISS,内容是最新的)。

另外,插件详情要加「更新日志」页签,需要读插件仓库的 GitHub Releases。

改动

plugins.marketplace.resolveSource

  • 输出新增 revision: { repository: { owner, name }, ref } | null:索引托管在 GitHub 上且地址不带查询参数时,给出地址跟随的 ref(HEAD、路径第一段,或 refs/heads/<name>、refs/tags/<name>)。其他来源、已经指向完整提交的地址为 null。
  • 输入新增可选的 commit(完整 SHA-1 或 SHA-256,否则 plugin.source.commitInvalid)。带上后输出多出 pinned: { commit, indexURL, recommendationsURL } | null,即同一批文件在该提交上的地址。
  • indexURL 不变,仍是来源身份(信任记录、自动更新的来源比对都用它)。宿主查询或固定下载失败时退回原地址。
  • 分支名含 / 时,只有写成 refs/heads/<name> 才能固定;其他写法查询失败,宿主会退回原地址。

GitHub(github.requestPlan / github.normalizeResponse)

操作 请求 结果
latestCommit GET /repos/{owner}/{name}/commits?sha={ref}&per_page=1,匿名 { sha },完整小写 SHA
listReleases GET /repos/{owner}/{name}/releases?per_page=20,匿名 [{ tagName, name, body, publishedAt, prerelease, url }],去掉草稿,按发布时间倒序
  • 请求新增 ref 字段,拒绝空白、..、开头的 - 和 ~ ^ : ? * [ \。
  • 两个操作都是公开读取,requiresAuthentication: false,未登录也能用。

契约与文档

  • shared/plugins/contract/v1/fixtures/marketplace/source-urls.json:已有用例补上 revision,新增 5 个带 commit 的成功用例和 1 个 plugin.source.commitInvalid 用例(共 17 个)。
  • 契约 README 的 Sources 一节、reference/domains/marketplace.md(中英)、rust/contracts/github.md、rust/contracts/rust-core-api.md、插件协议更新记录。

验证

  • cargo test -p lithe-core --lib -- tests::github tests::marketplace_plugins:31 个通过。
  • cargo clippy -p lithe-github -p lithe-plugin-marketplace -p lithe-core --all-targets -- -D warnings、cargo fmt --all -- --check。
  • node scripts/rust-core/verify-platform-tests.mjs、scripts/rust-core/verify-rust-core-comments.sh、node shared/plugins/scripts/verify-docs.mjs。
  • 实测:匿名查询 Lithe-IDEA/Lithe-store 的 HEAD 提交,再取该提交的 lithe-plugin-index.json,返回 X-Cache: MISS 且包含刚合入的版本。

桌面端接入在 1lck/Lithe-IDEA 的后续 Draft PR。

…b 新增 latestCommit 和 listReleases

raw.githubusercontent.com 对分支地址缓存 5 分钟,Store 合入新版本后宿主还会读到旧索引。
resolveSource 对托管在 GitHub 的索引返回 revision(仓库和 ref),宿主用新的匿名操作
github latestCommit 查到当前提交后带 commit 再调一次,得到 pinned(同一批文件在该提交上
的地址)。indexURL 仍是来源身份。listReleases 给插件详情的更新日志用,匿名读取、去掉草稿、
按发布时间倒序。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 22, 2026 14:20
@xiaoyumuxi
xiaoyumuxi merged commit 4430719 into main Nov 22, 2026
11 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.

1 participant