fix(config): resolve remaining hardcoded paths and improve readability

- Replace hardcoded ~/.ccs in error messages: ccs.ts (lines 83, 151)
  and delegation-handler.ts (line 333) now use getCcsDir()
- Cache repeated getter calls in local vars for readability:
  openrouter-catalog.ts getCachedModels/setCachedModels,
  aggregator.ts getInstancePaths
- Add path.resolve() for CCS_HOME env var consistency with CCS_DIR
This commit is contained in:
Tam Nhu Tran committed 2026-02-11 11:35:44 +07:00
1 parent d5abc7d691
commit c8800b418a
5 files changed
+18 -13

No files matched your search

+6 -4
View File
@@ -32,8 +32,9 @@ interface CacheData {
/** Check if cached data is valid */
function getCachedModels(): OpenRouterModel[] | null {
try {
if (!fs.existsSync(getCacheFile())) return null;
const data = JSON.parse(fs.readFileSync(getCacheFile(), 'utf8')) as CacheData;
const cacheFile = getCacheFile();
if (!fs.existsSync(cacheFile)) return null;
const data = JSON.parse(fs.readFileSync(cacheFile, 'utf8')) as CacheData;
if (Date.now() - data.fetchedAt > CACHE_TTL_MS) return null;
return data.models;
} catch {
@@ -44,10 +45,11 @@ function getCachedModels(): OpenRouterModel[] | null {
/** Save models to cache */
function setCachedModels(models: OpenRouterModel[]): void {
try {
const dir = path.dirname(getCacheFile());
const cacheFile = getCacheFile();
const dir = path.dirname(cacheFile);
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
getCacheFile(),
cacheFile,
JSON.stringify({
models,
fetchedAt: Date.now(),