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.
- package/dist/index.js +34 -23
- 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
|
-
|
|
319
|
-
const jsonlFiles =
|
|
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
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
outputTokens
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
}
|