ccgather 1.3.39 → 1.3.41

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 +44 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -236,9 +236,35 @@ var crypto = __toESM(require("crypto"));
236
236
  var fs = __toESM(require("fs"));
237
237
  var path = __toESM(require("path"));
238
238
  var os = __toESM(require("os"));
239
+ var import_child_process = require("child_process");
239
240
  function getCredentialsPath() {
240
241
  return path.join(os.homedir(), ".claude", ".credentials.json");
241
242
  }
243
+ function readFromMacKeychain() {
244
+ try {
245
+ const result = (0, import_child_process.execSync)('security find-generic-password -s "Claude Code-credentials" -w', {
246
+ encoding: "utf-8",
247
+ stdio: ["pipe", "pipe", "pipe"]
248
+ // Suppress stderr
249
+ });
250
+ const credentials = JSON.parse(result.trim());
251
+ return credentials;
252
+ } catch {
253
+ return null;
254
+ }
255
+ }
256
+ function readFromFile() {
257
+ const credentialsPath = getCredentialsPath();
258
+ if (!fs.existsSync(credentialsPath)) {
259
+ return null;
260
+ }
261
+ try {
262
+ const content = fs.readFileSync(credentialsPath, "utf-8");
263
+ return JSON.parse(content);
264
+ } catch {
265
+ return null;
266
+ }
267
+ }
242
268
  function mapSubscriptionToCCPlan(subscriptionType) {
243
269
  if (!subscriptionType) {
244
270
  return null;
@@ -275,30 +301,30 @@ function inferPlanFromRateLimitTier(rateLimitTier) {
275
301
  return null;
276
302
  }
277
303
  function readCredentials() {
278
- const credentialsPath = getCredentialsPath();
279
304
  const defaultData = {
280
305
  ccplan: null,
281
306
  rateLimitTier: null
282
307
  };
283
- if (!fs.existsSync(credentialsPath)) {
308
+ let credentials = null;
309
+ if (process.platform === "darwin") {
310
+ credentials = readFromMacKeychain();
311
+ }
312
+ if (!credentials) {
313
+ credentials = readFromFile();
314
+ }
315
+ if (!credentials) {
284
316
  return defaultData;
285
317
  }
286
- try {
287
- const content = fs.readFileSync(credentialsPath, "utf-8");
288
- const credentials = JSON.parse(content);
289
- const oauthData = credentials.claudeAiOauth;
290
- if (!oauthData) {
291
- return defaultData;
292
- }
293
- const rateLimitTier = oauthData.rateLimitTier || null;
294
- const ccplan = mapSubscriptionToCCPlan(oauthData.subscriptionType) || inferPlanFromRateLimitTier(rateLimitTier);
295
- return {
296
- ccplan,
297
- rateLimitTier
298
- };
299
- } catch (error2) {
318
+ const oauthData = credentials.claudeAiOauth;
319
+ if (!oauthData) {
300
320
  return defaultData;
301
321
  }
322
+ const rateLimitTier = oauthData.rateLimitTier || null;
323
+ const ccplan = mapSubscriptionToCCPlan(oauthData.subscriptionType) || inferPlanFromRateLimitTier(rateLimitTier);
324
+ return {
325
+ ccplan,
326
+ rateLimitTier
327
+ };
302
328
  }
303
329
 
304
330
  // src/lib/ccgather-json.ts
@@ -598,7 +624,7 @@ function getCurrentProjectName() {
598
624
 
599
625
  // src/lib/ui.ts
600
626
  var import_chalk = __toESM(require("chalk"));
601
- var VERSION = true ? "1.3.38" : "0.0.0";
627
+ var VERSION = true ? "1.3.41" : "0.0.0";
602
628
  var colors = {
603
629
  primary: import_chalk.default.hex("#DA7756"),
604
630
  // Claude coral
@@ -1403,7 +1429,7 @@ async function promptForUpdate(latestVersion) {
1403
1429
  console.log(` ${import_chalk3.default.cyan("\u2192")} Updating to ${import_chalk3.default.green(`ccgather@${latestVersion}`)}...`);
1404
1430
  console.log();
1405
1431
  const { spawn } = await import("child_process");
1406
- const child = spawn("npm", ["exec", "--yes", "--", `ccgather@${latestVersion}`], {
1432
+ const child = spawn("npx", [`ccgather@${latestVersion}`], {
1407
1433
  stdio: "inherit",
1408
1434
  shell: true
1409
1435
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccgather",
3
- "version": "1.3.39",
3
+ "version": "1.3.41",
4
4
  "description": "CLI tool for syncing Claude Code usage data to CCgather leaderboard",
5
5
  "bin": {
6
6
  "ccgather": "dist/index.js",