feat(maker): add package update policy check#258
Merged
Conversation
- Add Maker package version policy fetching, caching, and structured status output. - Surface required upgrade guidance in maker status and doctor without running upgrade commands. - Keep status and doctor non-blocking when remote policy access is unavailable. - Update publish workflow to open a policy update PR after latest or beta publishes. - Add tests for decision rules, cache TTL behavior, release policy updates, and status output.
- Reject prerelease versions when updating the stable latest policy field. - Retry remote policy fetches when only a previous failure cache exists. - Keep doctor from starting background package policy requests in short-lived CLI runs. - Add regression tests for release tag validation and failure-cache retry behavior.
- Move manual tag/version shape validation into the publish version resolver. - Reject stable versions for beta-style tags before npm publish runs. - Reject prerelease versions for stable latest publishes before npm publish runs. - Update resolver tests for stable latest and prerelease beta manual releases.
- Avoid background retry wording when package update background refresh is disabled. - Keep doctor output accurate when policy checks are unavailable or uncached. - Add regression coverage for non-blocking status text without background refresh.
- Require cached package update decisions to match the active policy URL. - Retry policy fetches when callers switch policy URL within the cache TTL. - Validate blacklist entries in the policy updater before writing release PR changes. - Add regression tests for policy URL cache isolation and blacklist schema validation.
- Do not expose cached package update decision fields when the active policy URL changes. - Prefer the active policy URL in unavailable non-blocking status output. - Add regression coverage for policy URL changes in status without remote fetch.
- Bind unavailable package update status to the active policy URL - Require manual prerelease versions to match their npm dist-tag - Compare numeric prerelease identifiers without JavaScript number precision loss - Verification: targeted maker version tests, lint, and build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
预期行为
验证
Greptile Summary
此 PR 为 Maker MCP 增加了远端版本策略检查功能:MCP 启动时异步拉取策略 JSON,在
status/doctor命令中输出结构化升级建议,网络不可用时降级为unavailable不影响正常使用;发布后通过 CI 自动更新策略文件并创建可审核 PR。src/maker/versionCheck.ts:新增核心模块,包含版本决策逻辑(blacklist / minimum_supported / beta_outdated / update_available)、12 小时 TTL 缓存、后台刷新去重,以及数值型 prerelease identifier 的精确字符串比较(避免Number()精度丢失)。scripts/update-maker-version-policy.cjs:发布后策略文件更新脚本,仅更新latest/latest_beta字段,保留minimum_supported、blacklist、message等手动策略字段;scripts/resolve-maker-version.js新增 manual 模式下 prerelease identifier 与 dist-tag 一致性校验。.github/workflows/publish-maker.yml:npm publish 成功后自动运行策略更新脚本并使用 GitHub App token 创建可审核 PR;权限从contents: read升级为contents: write(工作流级),覆盖范围超出实际需要。Confidence Score: 5/5
整体改动逻辑正确、测试覆盖充分,可安全合并;工作流权限配置略有改进空间。
核心版本检查逻辑、缓存机制、后台刷新去重均有对应测试验证,策略文件更新脚本的字段校验与运行时解析保持一致,doctor 命令通过 backgroundRefresh:false 避免了进程延迟退出。工作流权限在工作流级设置了 contents: write,但该写权限在实际执行路径中由 App token 承担,GITHUB_TOKEN 的写权限未被实际使用,属于可改进但不影响功能的配置。
.github/workflows/publish-maker.yml 的权限配置值得在合并前确认是否需要将写权限下放至 job 级别。
Important Files Changed
contents: write权限比实际所需更宽泛,resolve-versionjob 获得了不必要的写权限。assertVersionMatchesTag在 manual 模式下校验 prerelease identifier 与 dist-tag 一致,填补了之前的发布前验证空缺。allowRemoteFetch: false, backgroundRefresh: false确保 CLI 进程不会因后台检查而延迟退出。Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant MCP as MCP Server / CLI participant VC as versionCheck.ts participant Cache as 本地缓存 (JSON) participant GH as GitHub Raw (policy JSON) MCP->>VC: "startMakerPackageUpdateCheck({ currentVersion })" VC-->>Cache: 后台异步 checkMakerPackageUpdate Cache-->>VC: 读取旧缓存 VC->>GH: fetchWithTimeout (3s) GH-->>VC: MakerPackageVersionPolicy VC->>Cache: writeCache(decision) MCP->>VC: "getMakerPackageUpdateStatus({ allowRemoteFetch:false })" VC-->>Cache: readCache() alt 缓存新鲜 (TTL 12h) Cache-->>VC: decision VC-->>MCP: 返回缓存决策 else 缓存过期 / 无缓存 VC-->>MCP: unavailable (后台已触发刷新) end Note over VC,GH: doctor 命令使用 backgroundRefresh:false,不触发后台请求 participant WF as publish-maker workflow participant NPM as npm registry participant PR as GitHub PR WF->>NPM: "npm publish @taptap/maker@version" NPM-->>WF: 发布成功 WF->>WF: update-maker-version-policy.cjs WF->>PR: peter-evans/create-pull-request (App token) PR-->>WF: PR URL%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant MCP as MCP Server / CLI participant VC as versionCheck.ts participant Cache as 本地缓存 (JSON) participant GH as GitHub Raw (policy JSON) MCP->>VC: "startMakerPackageUpdateCheck({ currentVersion })" VC-->>Cache: 后台异步 checkMakerPackageUpdate Cache-->>VC: 读取旧缓存 VC->>GH: fetchWithTimeout (3s) GH-->>VC: MakerPackageVersionPolicy VC->>Cache: writeCache(decision) MCP->>VC: "getMakerPackageUpdateStatus({ allowRemoteFetch:false })" VC-->>Cache: readCache() alt 缓存新鲜 (TTL 12h) Cache-->>VC: decision VC-->>MCP: 返回缓存决策 else 缓存过期 / 无缓存 VC-->>MCP: unavailable (后台已触发刷新) end Note over VC,GH: doctor 命令使用 backgroundRefresh:false,不触发后台请求 participant WF as publish-maker workflow participant NPM as npm registry participant PR as GitHub PR WF->>NPM: "npm publish @taptap/maker@version" NPM-->>WF: 发布成功 WF->>WF: update-maker-version-policy.cjs WF->>PR: peter-evans/create-pull-request (App token) PR-->>WF: PR URLReviews (7): Last reviewed commit: "fix(maker): harden review edge cases" | Re-trigger Greptile