fix(tui): rank skill autocomplete by bare name (#9120)

This commit is contained in:
初心Yearth
2026-09-20 00:25:43 +02:00
committed by GitHub
parent b7f7881949
commit d7951ec362
2 changed files with 43 additions and 1 deletions
+5 -1
View File
@@ -332,7 +332,11 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
};
});
const filtered = fuzzyFilter(commandItems, prefix, (item) => item.name).map((item) => ({
const filtered = fuzzyFilter(commandItems, prefix, (item) =>
!prefix.startsWith("skill:") && item.name.startsWith("skill:")
? item.name.slice("skill:".length)
: item.name,
).map((item) => ({
value: item.name,
label: item.label,
...(item.description && { description: item.description }),
@@ -0,0 +1,38 @@
import assert from "node:assert";
import { describe, it } from "node:test";
import { CombinedAutocompleteProvider } from "../src/autocomplete.ts";
describe("CombinedAutocompleteProvider slash-command filter", () => {
const commands = [
{ name: "skill:deep-research", description: "Multi-agent deep research" },
{ name: "skill:research-idea", description: "Refine a raw idea into a falsifiable seed" },
{ name: "skill:to-sidecar", description: "Route work to a sidecar" },
{ name: "model", description: "Select the active model" },
];
async function suggestionsFor(prefix: string): Promise<string[]> {
const provider = new CombinedAutocompleteProvider(commands, process.cwd());
const line = `/${prefix}`;
const result = await provider.getSuggestions([line], 0, line.length, {
signal: new AbortController().signal,
});
assert.ok(result, `expected suggestions for "/${prefix}"`);
return result.items.map((item) => item.value);
}
it("ranks skill:research-idea first for query 'idea'", async () => {
const items = await suggestionsFor("idea");
assert.equal(items[0], "skill:research-idea");
assert.ok(!items.includes("skill:deep-research"));
});
it("keeps ordinary slash commands matching", async () => {
const items = await suggestionsFor("mod");
assert.ok(items.includes("model"));
});
it("keeps explicit skill: queries working", async () => {
const items = await suggestionsFor("skill:side");
assert.ok(items.includes("skill:to-sidecar"));
});
});