feat: search 结果与 add 建议显示包的可用版本(默认最新 3 个,--all-versions 全量) - #488
Open
wellwei wants to merge 1 commit into
Open
Conversation
`mcpp search` 的命中行追加描述符 per-OS 版本表的并集:semver 降序、按键去重, 默认显示最新 3 个并以 ", ..." 标记截断,--all-versions 显示全部;描述符不可读 或未发布版本的包保持原两列输出——富化是尽力而为的展示,不是新的失败路径。 `mcpp add` 未命中时的跨命名空间建议从裸 FQN 升级为带版本: compat.eui-neo (0.5.6, 0.5.5, 0.5.3)。数据是白捡的:did-you-mean 扫描本就要 打开每个候选 .lua 读身份(mcpp-community#278),版本只是同一段文本的再一次遍历。build 失败 路径的同款提示同步升级,两条路径不说两套话。 实现: - manifest 新增 merge_xpkg_versions_desc:per-OS 键列表的并集视图。排序用 version_req 的 SemVer 解析;不可解析的键保留原文排在最后(mcpp-community#363 的教训: 任意的索引键无法从解析形态复原);等值异写("1.0"/"1.0.0")保持首见序。 - mcpp-community#278 的扫描由 scan_fqns_with_short_name 改为 scan_short_name_matches, 携带 fqn + versions;三条约束不变(只在已失败路径调用、结果只进错误文本/ 展示、空结果不是错误),版本列表受同一纪律约束——描述存在性,不做解析输入。 - cross_namespace_matches 更名 cross_namespace_suggestions 返回富记录; prepare.cppm 与 commands.cppm 两个调用点同步渲染。 - Fetcher 新增 versions_for_hit:search 命中的 ns:name → 描述符 → 版本并集; 无 ns 前缀或读不到描述符时返回空。 - search_packages 增加 --all-versions;cli 注册选项。 测试:merge 排序 8 例(含预发布/四段/不可解析键)、扫描携带版本 3 例、 versions_for_hit 3 例;e2e 162 断言 build 与 add 两侧建议都带版本 (acme.widget (1.0.0) / compat.gadget (2.0.0)),且被拒的 add 不写 manifest。 Closes mcpp-community#487 Refs mcpp-community#324
wellwei
requested review from
Sunrisepeak,
ZheFeng7110 and
speak-agent
and removed request for
Sunrisepeak and
speak-agent
August 23, 2026 07:36
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.
Summary
Closes #487,补上 #324 遗留的「建议不带版本」半边。
mcpp search <keyword>:命中行追加该包描述符 per-OS 版本表的并集——semver 降序、按键去重,默认显示最新 3 个并以, ...标记截断;--all-versions显示全部。描述符不可读或未发布任何版本的包保持原两列输出,富化是尽力而为的展示,不是新的失败路径。mcpp add ns.name@ver未命中时:跨命名空间建议从裸 FQN 升级为带版本:数据是白捡的:did-you-mean 扫描本就要打开每个候选
.lua读身份(#278),版本只是同一段文本的再一次遍历。build 失败路径的同款提示同步升级,两条路径不说两套话。warn_unpublished_version的 warn-not-fail 策略不动。实现
manifest::merge_xpkg_versions_desc:per-OS 键列表的并集视图。排序用version_req的 SemVer 解析;不可解析的键保留原文排在最后(版本模型:精确键能表达上游的一切,范围表达不了 —— 且 lock 记的是范围本身 #363 的教训:任意的索引键无法从解析形态复原);等值异写(1.0/1.0.0)保持首见序。scan_fqns_with_short_name改为scan_short_name_matches,携带 fqn + versions。三条约束不变(只在已失败路径调用、结果只进错误文本/展示、空结果不是错误),版本列表受同一纪律约束——描述存在性,不做解析输入。cross_namespace_matches更名cross_namespace_suggestions返回富记录;prepare.cppm与commands.cppm两个调用点同步渲染。Fetcher::versions_for_hit:search 命中的ns:name→ 描述符 → 版本并集;无 ns 前缀或读不到描述符返回空。Test plan
versions_for_hit3 例)tests/e2e/162_bare_name_namespace_scope.sh扩展并全绿:build 路径断言acme.widget (1.0.0)、add 路径断言compat.gadget (2.0.0),且被拒的 add 不写 manifest12_add_command.sh、93_xpkg_parse.shmcpp search imgui [--all-versions]与mcpp add mcpplibs.eui-neo@1.0.0输出符合上述契约