Conversation
- 新增打分式模糊匹配工具,按「名字全等 > 前缀 > 词边界 > 子串 > 缩写子序列 > 描述命中」分级评分 - 名字命中权重恒定高于描述命中,避免描述里碰巧含关键词的 skill 抢占排序 - 斜杠命令菜单过滤由连续子串匹配改为按相关度打分排序,缩写(如 cmp 命中 compact)也能提前匹配 - 空查询时保持命令原始顺序,键盘导航与既有交互不变 - 补充核心契约测试,覆盖前缀优先、缩写命中、描述不抢名字、乱序与无关词不匹配
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.
用 OpenCodeUI 桌面端的时候,斜杠命令的匹配一直让我很抓狂,实在忍不住来修一下。
遇到的问题
想打
/goal,敲到/goa了,第一个候选还是/review-work,goal 排在后面;想打/compact,/comp甚至/compa都还没看到 compact,前面全是一堆名字完全不沾边的 skill。基本上要快把命令打完了,它才肯把我要的匹配出来。排查
问题在
src/features/slash-command/SlashCommandMenu.tsx,过滤逻辑其实就一行:总结下来三个毛病:
cmp永远匹配不到compact;修复
写了一个打分式模糊匹配(新增
src/utils/fuzzyMatch.ts),按相关度分级打分再排序:名字全等 > 名字前缀 > 名字词边界(如
stats命中session-stats)> 名字子串 > 名字缩写子序列(cmp→compact)> 描述命中关键点是:名字只要沾边,就一定排在「仅描述命中」前面,这样再长的 skill 描述也抢不走
/compact、/goal的位置。空输入时保持原来的列表顺序,键盘上下键、回车选中的交互都没动。另外补了核心契约测试,把上面这些场景(前缀优先、缩写命中、描述不抢名字、乱序/无关词不匹配)都固定住。
验证
src/测试 606/606 通过,build 成功;/cmp这种缩写也能提前搜到。哪里写得不对欢迎指出。