vibestats 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -315,37 +315,48 @@ function parseCodexJsonl() {
315
315
  const entries = [];
316
316
  const codexDir = getCodexDir();
317
317
  const sessionsDir = join(codexDir, "sessions");
318
- if (!existsSync(sessionsDir)) return entries;
319
- const jsonlFiles = findJsonlFiles(sessionsDir);
318
+ const archivedDir = join(codexDir, "archived_sessions");
319
+ const jsonlFiles = [
320
+ ...findJsonlFiles(sessionsDir),
321
+ ...findJsonlFiles(archivedDir)
322
+ ];
323
+ if (jsonlFiles.length === 0) return entries;
320
324
  for (const filePath of jsonlFiles) {
321
325
  try {
322
326
  const content = readFileSync(filePath, "utf-8");
323
327
  const lines = content.split("\n");
328
+ let currentModel = "gpt-5";
324
329
  for (const line of lines) {
325
330
  if (!line.trim()) continue;
326
331
  try {
327
332
  const entry = JSON.parse(line);
328
- if (entry.type !== "response" || !entry.response?.usage) continue;
329
- const usage = entry.response.usage;
330
- const model = entry.response.model || "unknown";
331
- const timestamp = entry.timestamp;
332
- if (!timestamp) continue;
333
- const date = timestamp.split("T")[0];
334
- const pricing = getCodexModelPricing(model);
335
- const inputTokens = usage.input_tokens || 0;
336
- const outputTokens = usage.output_tokens || 0;
337
- const cachedInputTokens = usage.input_tokens_details?.cached_tokens || 0;
338
- const cost = (inputTokens - cachedInputTokens) * pricing.input / 1e6 + outputTokens * pricing.output / 1e6 + cachedInputTokens * pricing.cachedInput / 1e6;
339
- entries.push({
340
- date,
341
- model: getCodexModelDisplayName(model),
342
- inputTokens,
343
- outputTokens,
344
- cacheWriteTokens: 0,
345
- cacheReadTokens: cachedInputTokens,
346
- cost,
347
- source: "codex"
348
- });
333
+ if (entry.type === "turn_context" && entry.payload?.model) {
334
+ currentModel = entry.payload.model;
335
+ continue;
336
+ }
337
+ if (entry.type === "event_msg" && entry.payload?.type === "token_count") {
338
+ const info = entry.payload.info;
339
+ if (!info?.last_token_usage) continue;
340
+ const usage = info.last_token_usage;
341
+ const timestamp = entry.timestamp;
342
+ if (!timestamp) continue;
343
+ const date = timestamp.split("T")[0];
344
+ const pricing = getCodexModelPricing(currentModel);
345
+ const inputTokens = usage.input_tokens || 0;
346
+ const outputTokens = usage.output_tokens || 0;
347
+ const cachedInputTokens = usage.cached_input_tokens || 0;
348
+ const cost = (inputTokens - cachedInputTokens) * pricing.input / 1e6 + outputTokens * pricing.output / 1e6 + cachedInputTokens * pricing.cachedInput / 1e6;
349
+ entries.push({
350
+ date,
351
+ model: getCodexModelDisplayName(currentModel),
352
+ inputTokens,
353
+ outputTokens,
354
+ cacheWriteTokens: 0,
355
+ cacheReadTokens: cachedInputTokens,
356
+ cost,
357
+ source: "codex"
358
+ });
359
+ }
349
360
  } catch {
350
361
  }
351
362
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibestats",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "AI coding stats - usage tracking and annual wrapped for Claude Code & Codex",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",