diff --git a/package-lock.json b/package-lock.json index 67de66a..aaef852 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@slkiser/opencode-quota", - "version": "3.8.1", + "version": "3.8.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@slkiser/opencode-quota", - "version": "3.8.1", + "version": "3.8.2", "license": "MIT", "dependencies": { "@clack/prompts": "^1.2.0", diff --git a/package.json b/package.json index f787505..5b86978 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@slkiser/opencode-quota", - "version": "3.8.1", + "version": "3.8.2", "description": "OpenCode quota & tokens usage with zero context window pollution. Supports GitHub Copilot, OpenAI (Plus/Pro), Qwen Code, Chutes AI, Synthetic, Google Antigravity, Z.ai coding plan and more.", "type": "module", "main": "./dist/index.js", diff --git a/src/lib/google-antigravity-companion.ts b/src/lib/google-antigravity-companion.ts index d786435..c0ef17a 100644 --- a/src/lib/google-antigravity-companion.ts +++ b/src/lib/google-antigravity-companion.ts @@ -1,4 +1,5 @@ import { readFile } from "fs/promises"; +import { readdirSync } from "node:fs"; import { createRequire } from "node:module"; import { dirname, join } from "node:path"; import { pathToFileURL } from "node:url"; @@ -103,7 +104,24 @@ function normalizeCredential(value: unknown): string { } function getCompanionResolvePaths(): string[] { - return getOpencodeRuntimeDirCandidates().cacheDirs; + const cacheDirs = getOpencodeRuntimeDirCandidates().cacheDirs; + const resolvePaths: string[] = [...cacheDirs]; + + for (const cacheDir of cacheDirs) { + try { + const packagesDir = join(cacheDir, "packages"); + const entries = readdirSync(packagesDir, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory() && entry.name.startsWith(COMPANION_PACKAGE_NAME)) { + resolvePaths.push(join(packagesDir, entry.name)); + } + } + } catch { + // Ignore if packages dir doesn't exist + } + } + + return resolvePaths; } function markPackageFoundForExportBlock( diff --git a/src/lib/google-gemini-cli-companion.ts b/src/lib/google-gemini-cli-companion.ts index afdfa05..e1aaef3 100644 --- a/src/lib/google-gemini-cli-companion.ts +++ b/src/lib/google-gemini-cli-companion.ts @@ -1,4 +1,5 @@ import { readFile } from "fs/promises"; +import { readdirSync } from "node:fs"; import { createRequire } from "node:module"; import { dirname, join } from "node:path"; import { pathToFileURL } from "node:url"; @@ -93,7 +94,24 @@ function normalizeCredential(value: unknown): string { } function getCompanionResolvePaths(): string[] { - return getOpencodeRuntimeDirCandidates().cacheDirs; + const cacheDirs = getOpencodeRuntimeDirCandidates().cacheDirs; + const resolvePaths: string[] = [...cacheDirs]; + + for (const cacheDir of cacheDirs) { + try { + const packagesDir = join(cacheDir, "packages"); + const entries = readdirSync(packagesDir, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory() && entry.name.startsWith(COMPANION_PACKAGE_NAME)) { + resolvePaths.push(join(packagesDir, entry.name)); + } + } + } catch { + // Ignore if packages dir doesn't exist + } + } + + return resolvePaths; } function resolveCompanionSpecifier(specifier: string): string {