whoburnedmore 0.9.18 → 0.9.20

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 +26 -15
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "node:f
11
11
  import { createRequire as createRequire4 } from "node:module";
12
12
  import { platform as platform4 } from "node:os";
13
13
  import { join as join15 } from "node:path";
14
+ import { pathToFileURL } from "node:url";
14
15
  import { createInterface } from "node:readline/promises";
15
16
  import pc2 from "picocolors";
16
17
 
@@ -238,7 +239,7 @@ import {
238
239
  writeFileSync as writeFileSync2
239
240
  } from "node:fs";
240
241
  import { homedir as homedir2, platform } from "node:os";
241
- import { dirname, join as join2, win32 } from "node:path";
242
+ import { dirname, join as join2, posix, win32 } from "node:path";
242
243
 
243
244
  // src/config.ts
244
245
  import { randomBytes } from "node:crypto";
@@ -470,7 +471,7 @@ function resolveNpmPath(opts) {
470
471
  for (const c of candidates) {
471
472
  if (check(c)) return c;
472
473
  }
473
- const sibling = os === "win32" ? win32.join(win32.dirname(execPath), "npm.cmd") : join2(dirname(execPath), "npm");
474
+ const sibling = os === "win32" ? win32.join(win32.dirname(execPath), "npm.cmd") : posix.join(posix.dirname(execPath), "npm");
474
475
  if (check(sibling)) return sibling;
475
476
  return os === "win32" ? "npm.cmd" : "npm";
476
477
  }
@@ -7582,12 +7583,12 @@ async function fetchCursorEvents(cookie, maxPages = 30, pageSize = 500) {
7582
7583
  }
7583
7584
  return all;
7584
7585
  }
7585
- async function collectCursor() {
7586
+ async function collectCursor(opts) {
7586
7587
  try {
7587
7588
  const db = cursorDbPath();
7588
7589
  const token = db ? readCursorToken(db) : null;
7589
7590
  const cookie = token ? cursorCookie(token) : null;
7590
- if (cookie) {
7591
+ if (cookie && !opts?.offline) {
7591
7592
  const events = await fetchCursorEvents(cookie);
7592
7593
  const { entries, blocks } = mapCursorEvents(events);
7593
7594
  if (entries.length > 0) return { entries, blocks, found: true };
@@ -7605,7 +7606,7 @@ async function collectCursor() {
7605
7606
  // src/native/codex.ts
7606
7607
  import { readdir as readdir3 } from "node:fs/promises";
7607
7608
  import { homedir as homedir7 } from "node:os";
7608
- import { join as join9 } from "node:path";
7609
+ import { join as join9, resolve } from "node:path";
7609
7610
  function num5(n) {
7610
7611
  const v = Math.round(Number(n));
7611
7612
  return Number.isFinite(v) && v > 0 ? v : 0;
@@ -8413,8 +8414,10 @@ var COLLECT_STAGES = SOURCES.length + 4 + VSCODE_AGENTS.length + 1;
8413
8414
  function isAuthoritativeScan(attributionComplete, ...fingerprintReaders) {
8414
8415
  return attributionComplete && fingerprintReaders.every((reader) => reader.timedOut !== true);
8415
8416
  }
8416
- async function collectAll(onProgress) {
8417
- await loadLivePricing().catch(() => {
8417
+ async function collectAll(onProgress, opts) {
8418
+ await loadLivePricing(
8419
+ opts?.offline ? { ...process.env, WHOBURNEDMORE_PRICING_OFFLINE: "1" } : process.env
8420
+ ).catch(() => {
8418
8421
  });
8419
8422
  const { cmd, prefixArgs } = resolveCcusageBin();
8420
8423
  let done = 0;
@@ -8459,7 +8462,7 @@ async function collectAll(onProgress) {
8459
8462
  tick();
8460
8463
  return json ? mapCcusageBlocks(json) : [];
8461
8464
  });
8462
- const cursorTask = collectCursor().then((c) => {
8465
+ const cursorTask = collectCursor({ offline: opts?.offline }).then((c) => {
8463
8466
  tick();
8464
8467
  return c;
8465
8468
  });
@@ -8704,6 +8707,13 @@ function signedInNextStepLines(result) {
8704
8707
  ` \u2192 Get a friend on it \u2014 have them run: npx whoburnedmore --board=${sanitizeServerText(code)}`
8705
8708
  ];
8706
8709
  }
8710
+ if (result.needsSocial) {
8711
+ return [
8712
+ ` Your dashboard: ${sanitizeServerText(result.profileUrl)}`,
8713
+ " \u2192 You're synced, but not on the public leaderboard yet.",
8714
+ " \u2192 Add a social handle (X, GitHub, or Instagram) on your dashboard to appear."
8715
+ ];
8716
+ }
8707
8717
  return [
8708
8718
  ` Your dashboard: ${sanitizeServerText(result.profileUrl)}`,
8709
8719
  " \u2192 Open it to see your rank and share your profile."
@@ -9020,10 +9030,11 @@ function showLocalDashboard(payload) {
9020
9030
  file,
9021
9031
  renderDashboardHtml(payload.entries, /* @__PURE__ */ new Date(), { webBaseUrl: webBase() })
9022
9032
  );
9033
+ const fileUrl = pathToFileURL(file).href;
9023
9034
  console.log();
9024
- console.log(` Local dashboard: ${pc2.cyan(`file://${file}`)}`);
9035
+ console.log(` Local dashboard: ${pc2.cyan(fileUrl)}`);
9025
9036
  console.log(pc2.dim(" Re-run `npx whoburnedmore --local` to refresh it. Nothing left your machine."));
9026
- openBrowser(`file://${file}`);
9037
+ openBrowser(fileUrl);
9027
9038
  }
9028
9039
  async function run(flags) {
9029
9040
  if (!flags.quiet) {
@@ -9043,7 +9054,7 @@ async function run(flags) {
9043
9054
  } } : startProgress();
9044
9055
  let collected;
9045
9056
  try {
9046
- collected = await collectAll(progress.onProgress);
9057
+ collected = await collectAll(progress.onProgress, { offline: flags.local });
9047
9058
  } finally {
9048
9059
  progress.stop();
9049
9060
  }
@@ -9131,7 +9142,7 @@ async function run(flags) {
9131
9142
  }
9132
9143
  }
9133
9144
  function sleep(ms) {
9134
- return new Promise((resolve) => setTimeout(resolve, ms));
9145
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
9135
9146
  }
9136
9147
  async function refreshCliTokenFromConfig() {
9137
9148
  const cfg = loadConfig();
@@ -9325,14 +9336,14 @@ async function linkServerInstall(token) {
9325
9336
  }
9326
9337
  function waitOrAbort(ms, signal) {
9327
9338
  if (signal.aborted) return Promise.resolve();
9328
- return new Promise((resolve) => {
9339
+ return new Promise((resolve2) => {
9329
9340
  const onAbort = () => {
9330
9341
  clearTimeout(timer);
9331
- resolve();
9342
+ resolve2();
9332
9343
  };
9333
9344
  const timer = setTimeout(() => {
9334
9345
  signal.removeEventListener("abort", onAbort);
9335
- resolve();
9346
+ resolve2();
9336
9347
  }, ms);
9337
9348
  signal.addEventListener("abort", onAbort, { once: true });
9338
9349
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whoburnedmore",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "description": "Find out who burned more — submit your AI coding-agent token usage to the public leaderboard at whoburnedmore.com",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "dist/index.js"
11
11
  ],
12
12
  "scripts": {
13
- "build": "rm -rf dist && esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:ccusage --external:picocolors --external:tokscale",
13
+ "build": "node scripts/clean.mjs && esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:ccusage --external:picocolors --external:tokscale",
14
14
  "test": "vitest run",
15
15
  "lint": "tsc -p tsconfig.json --noEmit",
16
16
  "smoke:package": "node scripts/smoke-package.mjs",
@@ -20,7 +20,7 @@
20
20
  "release:major": "npm version major && npm publish"
21
21
  },
22
22
  "dependencies": {
23
- "ccusage": "20.0.9",
23
+ "ccusage": "20.0.19",
24
24
  "picocolors": "^1.1.1"
25
25
  },
26
26
  "devDependencies": {