From 5ffaf0e62f8b874afc54cbf1d342125aa5ec8939 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sat, 30 May 2026 15:55:40 +0000 Subject: [PATCH] refactor: remove dead exports fuzzyMatchMultiple and getModelCount Closes #53 --- src/pricing.test.ts | 31 --------------------- src/pricing.ts | 4 --- src/search.test.ts | 66 +-------------------------------------------- src/search.ts | 15 ----------- 4 files changed, 1 insertion(+), 115 deletions(-) diff --git a/src/pricing.test.ts b/src/pricing.test.ts index bd6593b..3cd4d7d 100644 --- a/src/pricing.test.ts +++ b/src/pricing.test.ts @@ -368,37 +368,6 @@ describe("pricing module", () => { }); }); - describe("getModelCount", () => { - it("returns 0 when no cache loaded", async () => { - const { getModelCount } = await loadPricing(); - expect(getModelCount()).toBe(0); - }); - - it("returns correct count after loading data", async () => { - globalThis.fetch = vi.fn().mockResolvedValue({ - ok: true, - json: async () => ({ - "model-a": { - input_cost_per_token: 0.001, - output_cost_per_token: 0.002, - }, - "model-b": { - input_cost_per_token: 0.003, - output_cost_per_token: 0.004, - }, - "model-c": { - input_cost_per_token: 0.005, - output_cost_per_token: 0.006, - }, - }), - }); - - const { refreshPrices, getModelCount } = await loadPricing(); - await refreshPrices(); - expect(getModelCount()).toBe(3); - }); - }); - describe("disk cache", () => { it("calls writeFileSync after refreshPrices", async () => { globalThis.fetch = vi.fn().mockResolvedValue({ diff --git a/src/pricing.ts b/src/pricing.ts index b7d9e0c..7bc5672 100644 --- a/src/pricing.ts +++ b/src/pricing.ts @@ -176,7 +176,3 @@ export async function getModels(): Promise> { } return cache.models; } - -export function getModelCount(): number { - return cache ? Object.keys(cache.models).length : 0; -} diff --git a/src/search.test.ts b/src/search.test.ts index a37ce3b..a153985 100644 --- a/src/search.test.ts +++ b/src/search.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; import type { ModelEntry } from "./pricing.js"; -import { fuzzyMatch, fuzzyMatchMultiple, fuzzyMatchWithMetadata } from "./search.js"; +import { fuzzyMatch, fuzzyMatchWithMetadata } from "./search.js"; /** Helper to build a minimal ModelEntry for testing */ function makeModel(overrides: Partial & { key: string }): ModelEntry { @@ -181,63 +181,6 @@ describe("fuzzyMatch", () => { }); }); -describe("fuzzyMatchMultiple", () => { - it("strips openrouter/ prefix before matching", () => { - const results = fuzzyMatchMultiple("openrouter/claude", sampleModels); - expect(results.length).toBeGreaterThanOrEqual(1); - const keys = results.map((r) => r.key); - expect(keys.some((k) => k.includes("claude"))).toBe(true); - }); - - it("strips azure/ prefix before matching multiple", () => { - const results = fuzzyMatchMultiple("azure/gpt", sampleModels); - expect(results.length).toBeGreaterThanOrEqual(1); - const keys = results.map((r) => r.key); - expect(keys.some((k) => k.includes("gpt"))).toBe(true); - }); - - it("returns up to the default limit of 5 results", () => { - const results = fuzzyMatchMultiple("claude", sampleModels); - // We have 2 claude models, so should return at most 2 for "claude" - expect(results.length).toBeGreaterThanOrEqual(1); - expect(results.length).toBeLessThanOrEqual(5); - }); - - it("respects the limit parameter", () => { - const results = fuzzyMatchMultiple("model", sampleModels, 2); - expect(results.length).toBeLessThanOrEqual(2); - }); - - it("returns ModelEntry objects with correct structure", () => { - const results = fuzzyMatchMultiple("gpt", sampleModels, 3); - expect(results.length).toBeGreaterThanOrEqual(1); - - for (const entry of results) { - expect(entry).toHaveProperty("key"); - expect(entry).toHaveProperty("input_cost_per_token"); - expect(entry).toHaveProperty("output_cost_per_token"); - expect(entry).toHaveProperty("litellm_provider"); - } - }); - - it("returns empty array for garbage query", () => { - const results = fuzzyMatchMultiple("xyzzyplugh_12345", sampleModels); - expect(results).toEqual([]); - }); - - it("returns empty array for empty models", () => { - const results = fuzzyMatchMultiple("gpt-4o", {}); - expect(results).toEqual([]); - }); - - it("matches claude models with a general query", () => { - const results = fuzzyMatchMultiple("claude", sampleModels, 10); - const keys = results.map((r) => r.key); - expect(keys).toContain("claude-sonnet-4-5"); - expect(keys).toContain("claude-opus-4"); - }); -}); - describe("fine-tuned model patterns (ft: prefix)", () => { it("extracts base model from OpenAI fine-tuned pattern", () => { const result = fuzzyMatch("ft:gpt-4o:my-org:custom_suffix:id", sampleModels); @@ -278,13 +221,6 @@ describe("fine-tuned model patterns (ft: prefix)", () => { expect(result?.key).toBe("gpt-4o"); }); - it("fuzzyMatchMultiple handles fine-tuned patterns", () => { - const results = fuzzyMatchMultiple("ft:gpt:my-org:suffix:id", sampleModels); - expect(results.length).toBeGreaterThanOrEqual(1); - const keys = results.map((r) => r.key); - expect(keys.some((k) => k.includes("gpt"))).toBe(true); - }); - it("returns null for invalid fine-tuned pattern with missing base model", () => { const result = fuzzyMatch("ft:nonexistent-model:org:suffix:id", sampleModels); expect(result).toBeNull(); diff --git a/src/search.ts b/src/search.ts index 44c28bc..474741f 100644 --- a/src/search.ts +++ b/src/search.ts @@ -106,18 +106,3 @@ export function fuzzyMatchWithMetadata( const entry = fuzzyMatch(query, models); return { entry, isFineTuned }; } - -export function fuzzyMatchMultiple( - query: string, - models: Record, - limit = 5, -): ModelEntry[] { - // Strip provider prefix first, then handle fine-tuned pattern - const withoutProvider = stripProviderPrefix(query); - const { base } = extractFineTunedBase(withoutProvider); - const normalizedQuery = base; - - const index = buildIndex(models); - const results = index.search(normalizedQuery, { limit }); - return results.map((r) => models[r.item.key]); -}