Skip to content
Open
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
24 changes: 24 additions & 0 deletions src/shared/model-availability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,30 @@ describe("fuzzyMatchModel", () => {
const result = fuzzyMatchModel("gpt", available)
expect(result).toBeNull()
})

// given claude model with hyphen version separator (anthropic style)
// when matching against available models with dot separator (copilot style)
// then normalize and match across providers
it("should match claude models across providers despite version separator differences", () => {
const available = new Set([
"github-copilot/claude-opus-4.6",
"github-copilot/claude-sonnet-4.5",
"github-copilot/claude-haiku-4.5",
])
expect(fuzzyMatchModel("claude-opus-4-6", available, ["github-copilot"]))
.toBe("github-copilot/claude-opus-4.6")
expect(fuzzyMatchModel("claude-sonnet-4-5", available, ["github-copilot"]))
.toBe("github-copilot/claude-sonnet-4.5")
})

// given non-claude models with hyphens
// when matching
// then hyphens are not treated as version separators
it("should not normalize hyphens in non-claude model names", () => {
const available = new Set(["github-copilot/grok-code-fast-1"])
expect(fuzzyMatchModel("grok-code-fast-1", available, ["github-copilot"]))
.toBe("github-copilot/grok-code-fast-1")
})
})

describe("getConnectedProviders", () => {
Expand Down
3 changes: 1 addition & 2 deletions src/shared/model-availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import * as connectedProvidersCache from "./connected-providers-cache"
function normalizeModelName(name: string): string {
return name
.toLowerCase()
.replace(/claude-(opus|sonnet|haiku)-4-5/g, "claude-$1-4.5")
.replace(/claude-(opus|sonnet|haiku)-4\.5/g, "claude-$1-4.5")
.replace(/claude-(opus|sonnet|haiku)-(\d+)[.-](\d+)/g, "claude-$1-$2.$3")
}

export function fuzzyMatchModel(
Expand Down