refactor(shared): remove dead utility files

Delete 4 unused utility files:

- models-json-cache-reader.ts

- open-code-client-accessors.ts

- open-code-client-shapes.ts

- provider-models-cache-model-reader.ts

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim 2026-02-23 02:43:06 +09:00
parent 1f62fa5b2a
commit b3a6aaa843
4 changed files with 0 additions and 118 deletions

View File

@ -1,52 +0,0 @@
import { existsSync, readFileSync } from "fs"
import { join } from "path"
import { getOpenCodeCacheDir } from "./data-path"
import { log } from "./logger"
import { isRecord } from "./record-type-guard"
export function addModelsFromModelsJsonCache(
connectedProviders: Set<string>,
modelSet: Set<string>,
): boolean {
const cacheFile = join(getOpenCodeCacheDir(), "models.json")
if (!existsSync(cacheFile)) {
log("[fetchAvailableModels] models.json cache file not found, falling back to client")
return false
}
try {
const content = readFileSync(cacheFile, "utf-8")
const data: unknown = JSON.parse(content)
if (!isRecord(data)) {
return false
}
const providerIds = Object.keys(data)
log("[fetchAvailableModels] providers found in models.json", {
count: providerIds.length,
providers: providerIds.slice(0, 10),
})
const previousSize = modelSet.size
for (const providerId of providerIds) {
if (!connectedProviders.has(providerId)) continue
const providerValue = data[providerId]
if (!isRecord(providerValue)) continue
const modelsValue = providerValue["models"]
if (!isRecord(modelsValue)) continue
for (const modelKey of Object.keys(modelsValue)) {
modelSet.add(`${providerId}/${modelKey}`)
}
}
log("[fetchAvailableModels] parsed models from models.json (NO whitelist filtering)", {
count: modelSet.size,
connectedProviders: Array.from(connectedProviders).slice(0, 5),
})
return modelSet.size > previousSize
} catch (err) {
log("[fetchAvailableModels] error", { error: String(err) })
return false
}
}

View File

@ -1,20 +0,0 @@
import type { ModelListFunction, ProviderListFunction } from "./open-code-client-shapes"
import { isRecord } from "./record-type-guard"
export function getProviderListFunction(client: unknown): ProviderListFunction | null {
if (!isRecord(client)) return null
const provider = client["provider"]
if (!isRecord(provider)) return null
const list = provider["list"]
if (typeof list !== "function") return null
return list as ProviderListFunction
}
export function getModelListFunction(client: unknown): ModelListFunction | null {
if (!isRecord(client)) return null
const model = client["model"]
if (!isRecord(model)) return null
const list = model["list"]
if (typeof list !== "function") return null
return list as ModelListFunction
}

View File

@ -1,7 +0,0 @@
export type ProviderListResponse = { data?: { connected?: string[] } }
export type ModelListResponse = {
data?: Array<{ id?: string; provider?: string }>
}
export type ProviderListFunction = () => Promise<ProviderListResponse>
export type ModelListFunction = () => Promise<ModelListResponse>

View File

@ -1,39 +0,0 @@
import { readProviderModelsCache } from "./connected-providers-cache"
import { log } from "./logger"
export function addModelsFromProviderModelsCache(
connectedProviders: Set<string>,
modelSet: Set<string>,
): boolean {
const providerModelsCache = readProviderModelsCache()
if (!providerModelsCache) {
return false
}
const providerCount = Object.keys(providerModelsCache.models).length
if (providerCount === 0) {
log("[fetchAvailableModels] provider-models cache empty, falling back to models.json")
return false
}
log("[fetchAvailableModels] using provider-models cache (whitelist-filtered)")
const previousSize = modelSet.size
for (const [providerId, modelIds] of Object.entries(providerModelsCache.models)) {
if (!connectedProviders.has(providerId)) continue
for (const modelItem of modelIds) {
if (!modelItem) continue
const modelId = typeof modelItem === "string" ? modelItem : modelItem.id
if (modelId) {
modelSet.add(`${providerId}/${modelId}`)
}
}
}
log("[fetchAvailableModels] parsed from provider-models cache", {
count: modelSet.size,
connectedProviders: Array.from(connectedProviders).slice(0, 5),
})
return modelSet.size > previousSize
}