@vibe-cafe/vibe-usage 0.9.8 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,7 +66,7 @@ npx @vibe-cafe/vibe-usage status # Show config & detected tools
66
66
  | Kiro | Kiro CLI native event streams `~/.kiro/sessions/cli/*.jsonl` (estimated tokens from message text: input = prompt + tool results, output = reply + tool calls, reasoning = thinking, cacheRead = re-sent context; thinking-block signatures excluded). Falls back to `~/Library/Application Support/kiro-cli/data.sqlite3` / `~/.local/share/kiro-cli/data.sqlite3` + optional `~/.kiro_sessions/*.json` archives, then IDE `q-client.log` whole-credit deltas as `kiro-credits` (floored cumulative diff — the server stores token counts as bigint); legacy IDE `dev_data/devdata.sqlite` token telemetry is opt-in with `VIBE_USAGE_KIRO_LEGACY_TOKENS=1` |
67
67
  | Cline | `<host>/User/globalStorage/saoudrizwan.claude-dev/{state/taskHistory.json,tasks/<id>/ui_messages.json}` (walks all VSCode-fork hosts: Code, Cursor, Windsurf, VSCodium, Trae, ...) |
68
68
  | Roo Code | `<host>/User/globalStorage/rooveterinaryinc.roo-cline/{tasks/_index.json,tasks/<id>/{history_item,ui_messages}.json}` (walks all VSCode-fork hosts) |
69
- | Antigravity | `~/.gemini/antigravity/conversations/*.pb` to discover cascades, then reads token usage + sessions from the running language server via Connect RPC (process discovered with `ps`/`lsof` on macOS/Linux, PowerShell CIM with a `wmic` fallback on Windows) |
69
+ | Antigravity | `~/.gemini/antigravity/conversations/*.pb` / `*.db` to discover cascades, then reads token usage + sessions from the running language server via Connect RPC (process discovered with `ps`/`lsof` on macOS/Linux, PowerShell CIM with a `wmic` fallback on Windows) |
70
70
  | ZCode | `~/.zcode/cli/db/db.sqlite` (SQLite; reads the `message` table for per-message tokens, model, and project `cwd`/`root`, joined to `session.directory`) |
71
71
 
72
72
  ## How It Works
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-cafe/vibe-usage",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "Track your AI coding tool token usage and sync to vibecafe.ai",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -8,7 +8,7 @@ import { aggregateToBuckets, extractSessions } from './index.js';
8
8
 
9
9
  /**
10
10
  * Antigravity parser (file-based).
11
- * Scans .pb files in ~/.gemini/antigravity/conversations/ to discover cascade IDs.
11
+ * Scans .pb/.db files in ~/.gemini/antigravity/conversations/ to discover cascade IDs.
12
12
  * Calls GetCascadeTrajectory via a running language server to extract token usage
13
13
  * (from generatorMetadata) and session events (from trajectory steps).
14
14
  */
@@ -42,7 +42,7 @@ function findLanguageServer() {
42
42
  }
43
43
 
44
44
  function findLanguageServerUnix() {
45
- const out = execSync("ps aux | grep 'antigravity/bin/language_server_'", { encoding: 'utf-8', timeout: 5000 });
45
+ const out = execSync("ps aux | grep -i 'antigravity.*language_server'", { encoding: 'utf-8', timeout: 5000 });
46
46
  for (const line of out.split('\n')) {
47
47
  if (!line.trim()) continue;
48
48
  if (line.includes('grep')) continue;
@@ -224,6 +224,8 @@ async function probeHttpPort(ports, csrfToken) {
224
224
  const MODEL_NORMALIZE_MAP = {
225
225
  'claude-opus-4-6-thinking': 'claude-opus-4-6',
226
226
  'claude-sonnet-4-6-thinking': 'claude-sonnet-4-6',
227
+ 'gemini-3-flash-a': 'gemini-3-flash',
228
+ 'gemini-3-flash-b': 'gemini-3-flash',
227
229
  'gemini-3-flash-c': 'gemini-3-flash',
228
230
  "gemini-3.1-pro-high": "gemini-3.1-pro",
229
231
  "gemini-3.1-pro-low": "gemini-3.1-pro",
@@ -242,6 +244,10 @@ const PLACEHOLDER_MODEL_MAP = {
242
244
  'MODEL_PLACEHOLDER_M35': 'claude-sonnet-4-6',
243
245
  'MODEL_PLACEHOLDER_M26': 'claude-opus-4-6',
244
246
  'MODEL_OPENAI_GPT_OSS_120B_MEDIUM': 'gpt-oss-120b',
247
+ // Antigravity 2.0+ standalone app placeholders (verified via responseModel)
248
+ 'MODEL_PLACEHOLDER_M132': 'gemini-3-flash',
249
+ 'MODEL_PLACEHOLDER_M133': 'gemini-3-flash',
250
+ 'MODEL_PLACEHOLDER_M20': 'gemini-3-flash',
245
251
  };
246
252
 
247
253
  function normalizeModel(raw) {
@@ -274,17 +280,21 @@ function projectFromUri(uri) {
274
280
  }
275
281
 
276
282
  /**
277
- * List cascade IDs from .pb files in the conversations directory.
283
+ * List cascade IDs from .pb and .db files in the conversations directory.
284
+ * Antigravity 2.0+ stores new conversations as SQLite .db files instead of .pb.
278
285
  */
279
286
  function listCascades() {
280
287
  try {
281
288
  const files = readdirSync(CONVERSATIONS_DIR);
282
- const results = [];
289
+ const seen = new Set();
283
290
  for (const f of files) {
284
- if (!f.endsWith('.pb')) continue;
285
- results.push(f.slice(0, -3)); // strip .pb → cascadeId
291
+ // SQLite auxiliaries (foo.db-wal / foo.db-shm) don't end with .db, so no
292
+ // extra filtering is needed here.
293
+ if (f.endsWith('.pb') || f.endsWith('.db')) {
294
+ seen.add(f.slice(0, -3));
295
+ }
286
296
  }
287
- return results;
297
+ return [...seen];
288
298
  } catch {
289
299
  return [];
290
300
  }
@@ -293,7 +303,7 @@ function listCascades() {
293
303
  // ── Main parse ───────────────────────────────────────────────────────
294
304
 
295
305
  export async function parse() {
296
- // Step 1: List cascade .pb files
306
+ // Step 1: List cascade conversation files (.pb / .db)
297
307
  const cascadeIds = listCascades();
298
308
  if (cascadeIds.length === 0) return { buckets: [], sessions: [] };
299
309
 
@@ -95,20 +95,34 @@ const FETCH_TIMEOUT_MS = 10_000;
95
95
  async function fetchUsageCsv(token) {
96
96
  const url = `${(process.env.CURSOR_WEB_BASE_URL?.trim() || 'https://cursor.com').replace(/\/+$/, '')}/api/dashboard/export-usage-events-csv?strategy=tokens`;
97
97
  const sub = decodeJwtSub(token);
98
- const cookieValues = sub ? [token, `${sub}::${token}`] : [token];
98
+ // The dashboard API authenticates via the WorkosCursorSessionToken cookie in
99
+ // `{sub}%3A%3A{jwt}` form (what the browser sends). Bearer and bare-token
100
+ // cookies now return 401, so they're kept only as last-resort fallbacks.
101
+ const userId = sub?.includes('|') ? sub.split('|').pop() : null;
102
+ const cookieValues = [
103
+ ...(sub ? [`${sub}%3A%3A${token}`] : []),
104
+ ...(userId ? [`${userId}%3A%3A${token}`] : []),
105
+ token,
106
+ ];
99
107
 
100
- const attempts = [{ Authorization: `Bearer ${token}` }];
101
- for (const cv of cookieValues) {
102
- attempts.push({ Cookie: `${SESSION_COOKIE}=${cv}` });
103
- attempts.push({ Authorization: `Bearer ${token}`, Cookie: `${SESSION_COOKIE}=${cv}` });
104
- }
108
+ // Browser-mimicking headers, matching what the dashboard sends (and what
109
+ // cursor-stats / cursor-price-tracking send) — Node's default UA is a
110
+ // common target for intermittent WAF blocks on cursor.com.
111
+ const baseHeaders = {
112
+ Accept: 'text/csv,*/*;q=0.8',
113
+ Origin: 'https://cursor.com',
114
+ Referer: 'https://cursor.com/dashboard?tab=usage',
115
+ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36',
116
+ };
117
+ const attempts = cookieValues.map(cv => ({ Cookie: `${SESSION_COOKIE}=${cv}` }));
118
+ attempts.push({ Authorization: `Bearer ${token}` });
105
119
 
106
120
  const failures = [];
107
121
  for (const headers of attempts) {
108
122
  let resp;
109
123
  try {
110
124
  resp = await fetch(url, {
111
- headers: { Accept: 'text/csv,*/*;q=0.8', ...headers },
125
+ headers: { ...baseHeaders, ...headers },
112
126
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
113
127
  });
114
128
  } catch (e) {
@@ -121,9 +135,18 @@ async function fetchUsageCsv(token) {
121
135
  }
122
136
  if (resp.ok) return await resp.text();
123
137
  failures.push(`${resp.status} ${resp.statusText}`);
138
+ // Only auth rejections are worth retrying with different credentials.
139
+ // 429/5xx are transient server-side states — soft-skip like network errors
140
+ // instead of surfacing them as auth failures every daemon cycle.
141
+ if (resp.status !== 401 && resp.status !== 403) {
142
+ const err = new Error(`Cursor usage export skipped (HTTP ${resp.status} ${resp.statusText})`);
143
+ err.skip = true;
144
+ throw err;
145
+ }
124
146
  }
125
- // All auth combos rejected — token is likely expired. Surface to user.
126
- throw new Error(`Cursor usage export auth failed (${failures.join('; ')})`);
147
+ // Every auth combo rejected — the stored token no longer works. Surface an
148
+ // actionable message: re-signing in inside Cursor rewrites the token.
149
+ throw new Error(`Cursor session rejected (${failures.join('; ')}). Open Cursor and sign in again (Cursor Settings → Account), then re-run sync.`);
127
150
  }
128
151
 
129
152
  function parseCsv(text) {