MCPcopy
hub / github.com/codeaashu/claude-code / modelMatchesVersionPrefix

Function modelMatchesVersionPrefix

src/utils/model/modelAllowlist.ts:39–57  ·  view source on GitHub ↗

* Check if a model matches a version-prefix entry in the allowlist. * Supports shorthand like "opus-4-5" (mapped to "claude-opus-4-5") and * full prefixes like "claude-opus-4-5". Resolves input aliases before matching.

(model: string, entry: string)

Source from the content-addressed store, hash-verified

37 * full prefixes like "claude-opus-4-5". Resolves input aliases before matching.
38 */
39function modelMatchesVersionPrefix(model: string, entry: string): boolean {
40 // Resolve the input model to a full name if it's an alias
41 const resolvedModel = isModelAlias(model)
42 ? parseUserSpecifiedModel(model).toLowerCase()
43 : model
44
45 // Try the entry as-is (e.g. "claude-opus-4-5")
46 if (prefixMatchesModel(resolvedModel, entry)) {
47 return true
48 }
49 // Try with "claude-" prefix (e.g. "opus-4-5" → "claude-opus-4-5")
50 if (
51 !entry.startsWith('claude-') &&
52 prefixMatchesModel(resolvedModel, `claude-${entry}`)
53 ) {
54 return true
55 }
56 return false
57}
58
59/**
60 * Check if a family alias is narrowed by more specific entries in the allowlist.

Callers 1

isModelAllowedFunction · 0.85

Calls 3

isModelAliasFunction · 0.85
parseUserSpecifiedModelFunction · 0.85
prefixMatchesModelFunction · 0.85

Tested by

no test coverage detected