ccgather 2.0.13 → 2.0.15

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 +23 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -118,11 +118,17 @@ function createBox(lines, width = 47) {
118
118
  return [top, ...paddedLines.map((l) => colors.dim(" ") + l), bottom].join("\n");
119
119
  }
120
120
  function getDisplayWidth(str) {
121
- let width = (0, import_string_width.default)(str);
122
- const flagRegex = /[🇦-🇿][🇦-🇿]/gu;
123
- const flags = str.match(flagRegex);
124
- if (flags) {
125
- width += flags.length * 2 * 2;
121
+ const stripped = stripAnsi(str);
122
+ let width = (0, import_string_width.default)(stripped);
123
+ const emojiRegex = /[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|✦/gu;
124
+ const emojis = stripped.match(emojiRegex);
125
+ if (emojis) {
126
+ for (const emoji of emojis) {
127
+ const emojiWidth = (0, import_string_width.default)(emoji);
128
+ if (emojiWidth === 1) {
129
+ width += 1;
130
+ }
131
+ }
126
132
  }
127
133
  return width;
128
134
  }
@@ -140,7 +146,10 @@ function formatNumber(num) {
140
146
  return num.toLocaleString();
141
147
  }
142
148
  function formatCost(cost) {
143
- return `$${cost.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
149
+ if (cost >= 1e9) return `$${(cost / 1e9).toFixed(2)}B`;
150
+ if (cost >= 1e6) return `$${(cost / 1e6).toFixed(2)}M`;
151
+ if (cost >= 1e3) return `$${(cost / 1e3).toFixed(2)}K`;
152
+ return `$${cost.toFixed(2)}`;
144
153
  }
145
154
  function getLevelInfo(tokens) {
146
155
  for (let i = LEVELS.length - 1; i >= 0; i--) {
@@ -295,7 +304,7 @@ var init_ui = __esm({
295
304
  "use strict";
296
305
  import_chalk = __toESM(require("chalk"));
297
306
  import_string_width = __toESM(require("string-width"));
298
- VERSION = true ? "2.0.13" : "0.0.0";
307
+ VERSION = true ? "2.0.15" : "0.0.0";
299
308
  colors = {
300
309
  primary: import_chalk.default.hex("#DA7756"),
301
310
  // Claude coral
@@ -1294,21 +1303,21 @@ async function submit(options) {
1294
1303
  const levelProgress = getLevelProgress(usageData.totalTokens);
1295
1304
  const currentLevel = levelProgress.current;
1296
1305
  const summaryLines = [
1297
- `\u{1F4B0} ${colors.muted("Total Cost")} ${colors.success(formatCost(usageData.totalCost))}`,
1298
- `\u26A1 ${colors.muted("Total Tokens")} ${colors.primary(formatNumber(usageData.totalTokens))}`,
1299
- `\u{1F4C5} ${colors.muted("Period")} ${colors.warning(daysTrackedDisplay)}`,
1300
- `${currentLevel.icon} ${colors.muted("Level")} ${currentLevel.color(`${currentLevel.name}`)}`
1306
+ `${colors.muted("Total Cost")} \u{1F4B0} ${colors.warning(formatCost(usageData.totalCost))}`,
1307
+ `${colors.muted("Total Tokens")} \u26A1 ${colors.primary(formatNumber(usageData.totalTokens))}`,
1308
+ `${colors.muted("Period")} \u{1F4C5} ${colors.white(daysTrackedDisplay)}`,
1309
+ `${colors.muted("Level")} ${currentLevel.icon} ${currentLevel.color(`${currentLevel.name}`)}`
1301
1310
  ];
1302
1311
  if (usageData.ccplan) {
1303
1312
  const planColor = getPlanColor(usageData.ccplan);
1304
- const planIcon = usageData.ccplan.toLowerCase() === "max" ? "\u{1F680}" : "\u{1F4CB}";
1313
+ const planIcon = usageData.ccplan.toLowerCase() === "max" ? "\u{1F680} " : "";
1305
1314
  summaryLines.push(
1306
- `${planIcon} ${colors.muted("Plan")} ${planColor(usageData.ccplan.toUpperCase())}`
1315
+ `${colors.muted("Plan")} ${planIcon}${planColor(usageData.ccplan.toUpperCase())}`
1307
1316
  );
1308
1317
  }
1309
1318
  if (usageData.hasOpusUsage) {
1310
1319
  summaryLines.push(
1311
- `\u2726 ${colors.muted("Models")} ${colors.max("Opus User")}`
1320
+ `${colors.muted("Models")} ${colors.max("\u2726 Opus User")}`
1312
1321
  );
1313
1322
  }
1314
1323
  console.log(createBox(summaryLines));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccgather",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "CLI tool for syncing Claude Code usage data to CCgather leaderboard",
5
5
  "bin": {
6
6
  "ccgather": "dist/index.js",