ccgather 2.0.8 → 2.0.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.
Files changed (2) hide show
  1. package/dist/index.js +87 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -329,7 +329,7 @@ var init_ui = __esm({
329
329
  "use strict";
330
330
  import_chalk = __toESM(require("chalk"));
331
331
  import_string_width = __toESM(require("string-width"));
332
- VERSION = true ? "2.0.7" : "0.0.0";
332
+ VERSION = true ? "2.0.10" : "0.0.0";
333
333
  colors = {
334
334
  primary: import_chalk.default.hex("#DA7756"),
335
335
  // Claude coral
@@ -1342,20 +1342,7 @@ async function submit(options) {
1342
1342
  console.log(
1343
1343
  ` ${colors.dim(`Scanned ${projectCount} project(s), ${usageData.dailyUsage.length} day(s) of data`)}`
1344
1344
  );
1345
- const { confirmSubmit } = await import_inquirer2.default.prompt([
1346
- {
1347
- type: "confirm",
1348
- name: "confirmSubmit",
1349
- message: "Submit to CCgather leaderboard?",
1350
- default: true
1351
- }
1352
- ]);
1353
- if (!confirmSubmit) {
1354
- console.log(`
1355
- ${colors.muted("Submission cancelled.")}
1356
- `);
1357
- return;
1358
- }
1345
+ console.log();
1359
1346
  const submitSpinner = (0, import_ora2.default)({
1360
1347
  text: "Submitting to CCgather...",
1361
1348
  color: "cyan"
@@ -1371,8 +1358,40 @@ async function submit(options) {
1371
1358
  };
1372
1359
  if (result.previous) {
1373
1360
  const prev = result.previous;
1374
- const tokenDiff = usageData.totalTokens - prev.totalTokens;
1375
- const costDiff = usageData.totalCost - prev.totalCost;
1361
+ const previousDates = new Set(prev.previousDates || []);
1362
+ const previousDailyMap = /* @__PURE__ */ new Map();
1363
+ prev.previousDaily?.forEach((d) => {
1364
+ previousDailyMap.set(d.date, { tokens: d.tokens, cost: d.cost });
1365
+ });
1366
+ const currentDates = new Set(usageData.dailyUsage.map((d) => d.date));
1367
+ const newDates = usageData.dailyUsage.filter((d) => !previousDates.has(d.date));
1368
+ const expiredDates = Array.from(previousDates).filter((d) => !currentDates.has(d));
1369
+ const updatedDates = usageData.dailyUsage.filter((d) => {
1370
+ const prevData = previousDailyMap.get(d.date);
1371
+ return prevData && d.tokens > prevData.tokens;
1372
+ });
1373
+ let newTokens = 0;
1374
+ let newCost = 0;
1375
+ newDates.forEach((d) => {
1376
+ newTokens += d.tokens;
1377
+ newCost += d.cost;
1378
+ });
1379
+ updatedDates.forEach((d) => {
1380
+ const prevData = previousDailyMap.get(d.date);
1381
+ if (prevData) {
1382
+ newTokens += d.tokens - prevData.tokens;
1383
+ newCost += d.cost - prevData.cost;
1384
+ }
1385
+ });
1386
+ let expiredTokens = 0;
1387
+ let expiredCost = 0;
1388
+ expiredDates.forEach((date) => {
1389
+ const prevData = previousDailyMap.get(date);
1390
+ if (prevData) {
1391
+ expiredTokens += prevData.tokens;
1392
+ expiredCost += prevData.cost;
1393
+ }
1394
+ });
1376
1395
  const lastSubmit = new Date(prev.lastSubmissionAt);
1377
1396
  const now = /* @__PURE__ */ new Date();
1378
1397
  const hoursDiff = Math.floor((now.getTime() - lastSubmit.getTime()) / (1e3 * 60 * 60));
@@ -1381,20 +1400,63 @@ async function submit(options) {
1381
1400
  console.log(sectionHeader("\u{1F4C8}", "Since Last Submit"));
1382
1401
  console.log();
1383
1402
  console.log(` ${colors.muted("Last submitted:")} ${colors.dim(timeSince)}`);
1384
- if (tokenDiff > 0) {
1385
- console.log(
1386
- ` ${colors.muted("New tokens:")} ${colors.success(`+${formatNumber(tokenDiff)}`)}`
1387
- );
1403
+ console.log();
1404
+ if (newTokens > 0 || updatedDates.length > 0) {
1405
+ const parts = [];
1406
+ if (newTokens > 0) {
1407
+ parts.push(colors.success(`+${formatNumber(newTokens)}`));
1408
+ parts.push(colors.success(`+${formatCost(newCost)}`));
1409
+ }
1410
+ if (newDates.length > 0) {
1411
+ parts.push(colors.primary(`+${newDates.length} new day${newDates.length > 1 ? "s" : ""}`));
1412
+ }
1413
+ if (updatedDates.length > 0 && newDates.length === 0) {
1414
+ parts.push(colors.primary(`${updatedDates.length} day${updatedDates.length > 1 ? "s" : ""} updated`));
1415
+ }
1416
+ console.log(` ${parts.join(" ")}`);
1388
1417
  }
1389
- if (costDiff > 0) {
1418
+ if (expiredDates.length > 0) {
1419
+ console.log();
1390
1420
  console.log(
1391
- ` ${colors.muted("New spending:")} ${colors.success(`+${formatCost(costDiff)}`)}`
1421
+ ` ${colors.warning("\u26A0")} ${colors.dim(`${expiredDates.length} day${expiredDates.length > 1 ? "s" : ""} expired (30-day limit): -${formatNumber(expiredTokens)}`)}`
1392
1422
  );
1393
1423
  }
1394
- if (tokenDiff === 0 && costDiff === 0) {
1395
- console.log(` ${colors.dim("No new usage since last submission")}`);
1424
+ if (newDates.length > 0) {
1425
+ console.log();
1426
+ const displayDates = newDates.slice(-5);
1427
+ if (newDates.length > 5) {
1428
+ console.log(` ${colors.dim(`... and ${newDates.length - 5} more days`)}`);
1429
+ }
1430
+ displayDates.forEach((d) => {
1431
+ const dateStr = d.date.slice(5).replace("-", "/");
1432
+ console.log(
1433
+ ` ${colors.dim("\u2022")} ${colors.white(dateStr)}: ${colors.success(`+${formatNumber(d.tokens)}`)} ${colors.dim(`(${formatCost(d.cost)})`)}`
1434
+ );
1435
+ });
1436
+ }
1437
+ if (updatedDates.length > 0 && newDates.length === 0) {
1438
+ console.log();
1439
+ updatedDates.slice(-3).forEach((d) => {
1440
+ const prevData = previousDailyMap.get(d.date);
1441
+ if (prevData) {
1442
+ const dateStr = d.date.slice(5).replace("-", "/");
1443
+ const tokenIncrease = d.tokens - prevData.tokens;
1444
+ console.log(
1445
+ ` ${colors.dim("\u2022")} ${colors.white(dateStr)}: ${formatNumber(prevData.tokens)} \u2192 ${formatNumber(d.tokens)} ${colors.success(`(+${formatNumber(tokenIncrease)})`)}`
1446
+ );
1447
+ }
1448
+ });
1449
+ }
1450
+ if (newTokens === 0 && updatedDates.length === 0 && expiredDates.length === 0) {
1451
+ console.log(` ${colors.dim("No changes since last submission")}`);
1396
1452
  }
1397
1453
  console.log();
1454
+ const rankSpinner = (0, import_ora2.default)({
1455
+ text: colors.dim("Calculating ranking..."),
1456
+ color: "cyan"
1457
+ }).start();
1458
+ await sleep(400);
1459
+ rankSpinner.stop();
1398
1460
  }
1399
1461
  if (result.rank || result.countryRank) {
1400
1462
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccgather",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "CLI tool for syncing Claude Code usage data to CCgather leaderboard",
5
5
  "bin": {
6
6
  "ccgather": "dist/index.js",