Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/model-selector-provider-prefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Allow model selector searches to match provider prefixes in colon-separated model names.
5 changes: 5 additions & 0 deletions packages/kilo-vscode/tests/unit/model-selector-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ const SEARCH_MODELS: EnrichedModel[] = [
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", providerID: "openai", providerName: "OpenAI" },
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", providerID: "kilo", providerName: "Kilo" },
{ id: "gpt-5.6", name: "GPT-5.6", providerID: "anthropic", providerName: "Anthropic" },
{ id: "xai/grok-4.20", name: "SpaceXAI: Grok 4.20", providerID: "kilo", providerName: "Kilo Gateway" },
]

describe("rankModelSearch", () => {
it("matches colon-separated prefixes in model display names", () => {
expect(rankModelSearch(SEARCH_MODELS, "SpaceX").map((model) => model.name)).toEqual(["SpaceXAI: Grok 4.20"])
})

it("prefers an exact model token over a longer prefix match", () => {
expect(
rankModelSearch(SEARCH_MODELS, "sol")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,22 @@ function tokenScore(token: string, value: string): number {
}

function matchScore(model: EnrichedModel, query: string): number | undefined {
const name = stripSubProviderPrefix(sanitizeName(model.name))
const raw = sanitizeName(model.name)
const name = stripSubProviderPrefix(raw)
const tokens = words(query)
if (tokens.length === 0) return 0

const scores = tokens.map((token) => {
const modelScore = Math.max(tokenScore(token, name), tokenScore(token, model.id))
const modelScore = Math.max(tokenScore(token, name), tokenScore(token, raw), tokenScore(token, model.id))
const providerScore = modelScore < 0 ? tokenScore(token, model.providerName) : -1
return { modelScore, providerScore }
})
if (scores.some((score) => score.modelScore < 0 && score.providerScore < 0)) return undefined

const modelScore = scores.reduce((sum, score) => sum + Math.max(score.modelScore, 0), 0)
const providerScore = scores.reduce((sum, score) => sum + Math.max(score.providerScore, 0), 0)
const exact = collapse(query) === collapse(name) || collapse(query) === collapse(model.id)
const exact =
collapse(query) === collapse(name) || collapse(query) === collapse(raw) || collapse(query) === collapse(model.id)
return modelScore + Math.floor(providerScore / 10) + (exact ? 5000 : 0)
}

Expand Down
20 changes: 20 additions & 0 deletions packages/tui/test/kilocode/model-picker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ const inCategory = (options: ReturnType<typeof build>, category: string) =>
options.filter((option) => option.category === category).map((option) => option.modelID)

describe("model picker options", () => {
test("matches colon-separated prefixes in model display names", () => {
const options = buildModelPickerOptions({
providers: [
{
id: "kilo",
name: "Kilo Gateway",
models: {
"xai/grok-4.20": {
id: "xai/grok-4.20",
name: "SpaceXAI: Grok 4.20",
},
},
},
],
query: "SpaceX",
})

expect(options.map((option) => option.modelID)).toEqual(["xai/grok-4.20"])
})

test("keeps recommended Kilo models in their section after they are used", () => {
const options = build({ recents: [sonnet45] })

Expand Down
Loading