ccusage 15.0.0 → 15.1.0

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.
@@ -1,6 +1,6 @@
1
- import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, require_usingCtx } from "./pricing-fetcher-CMyU5JUX.js";
1
+ import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, require_usingCtx } from "./pricing-fetcher-Dm8hcn_h.js";
2
2
  import { activityDateSchema, arrayType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, versionSchema } from "./_types-Cr2YEzKm.js";
3
- import { logger } from "./logger-6I_KKR-u.js";
3
+ import { logger } from "./logger-Cke8hliP.js";
4
4
  import a, { readFile } from "node:fs/promises";
5
5
  import F, { homedir } from "node:os";
6
6
  import path, { posix } from "node:path";
@@ -3065,6 +3065,16 @@ async function glob(patternsOrOptions, options) {
3065
3065
  */
3066
3066
  const DEFAULT_SESSION_DURATION_HOURS = 5;
3067
3067
  /**
3068
+ * Floors a timestamp to the beginning of the hour in UTC
3069
+ * @param timestamp - The timestamp to floor
3070
+ * @returns New Date object floored to the UTC hour
3071
+ */
3072
+ function floorToHour(timestamp) {
3073
+ const floored = new Date(timestamp);
3074
+ floored.setUTCMinutes(0, 0, 0);
3075
+ return floored;
3076
+ }
3077
+ /**
3068
3078
  * Identifies and creates session blocks from usage entries
3069
3079
  * Groups entries into time-based blocks (typically 5-hour periods) with gap detection
3070
3080
  * @param entries - Array of usage entries to process
@@ -3082,7 +3092,7 @@ function identifySessionBlocks(entries, sessionDurationHours = DEFAULT_SESSION_D
3082
3092
  for (const entry of sortedEntries) {
3083
3093
  const entryTime = entry.timestamp;
3084
3094
  if (currentBlockStart == null) {
3085
- currentBlockStart = entryTime;
3095
+ currentBlockStart = floorToHour(entryTime);
3086
3096
  currentBlockEntries = [entry];
3087
3097
  } else {
3088
3098
  const timeSinceBlockStart = entryTime.getTime() - currentBlockStart.getTime();
@@ -3097,7 +3107,7 @@ function identifySessionBlocks(entries, sessionDurationHours = DEFAULT_SESSION_D
3097
3107
  const gapBlock = createGapBlock(lastEntryTime, entryTime, sessionDurationMs);
3098
3108
  if (gapBlock != null) blocks.push(gapBlock);
3099
3109
  }
3100
- currentBlockStart = entryTime;
3110
+ currentBlockStart = floorToHour(entryTime);
3101
3111
  currentBlockEntries = [entry];
3102
3112
  } else currentBlockEntries.push(entry);
3103
3113
  }
@@ -1,4 +1,4 @@
1
- import { CostMode, PricingFetcher, SortOrder } from "./pricing-fetcher-CXnYw4TA.js";
1
+ import { CostMode, PricingFetcher, SortOrder } from "./pricing-fetcher-BZe7AafW.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/_session-blocks.d.ts
@@ -1,3 +1,3 @@
1
- import "./pricing-fetcher-CXnYw4TA.js";
2
- import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-Bll0wMdK.js";
1
+ import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-DZczD-9E.js";
2
+ import "./pricing-fetcher-BZe7AafW.js";
3
3
  export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
@@ -1,5 +1,5 @@
1
- import "./pricing-fetcher-CMyU5JUX.js";
1
+ import "./pricing-fetcher-Dm8hcn_h.js";
2
2
  import "./_types-Cr2YEzKm.js";
3
- import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-B_ymgjWR.js";
4
- import "./logger-6I_KKR-u.js";
3
+ import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-BeaFK_sH.js";
4
+ import "./logger-Cke8hliP.js";
5
5
  export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
@@ -1,6 +1,6 @@
1
- import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, require_usingCtx } from "./pricing-fetcher-CMyU5JUX.js";
2
- import { getDefaultClaudePath, glob, usageDataSchema } from "./data-loader-B_ymgjWR.js";
3
- import { logger } from "./logger-6I_KKR-u.js";
1
+ import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, require_usingCtx } from "./pricing-fetcher-Dm8hcn_h.js";
2
+ import { getDefaultClaudePath, glob, usageDataSchema } from "./data-loader-BeaFK_sH.js";
3
+ import { logger } from "./logger-Cke8hliP.js";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
6
6
  var import_usingCtx = __toESM(require_usingCtx(), 1);
package/dist/debug.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./pricing-fetcher-CMyU5JUX.js";
1
+ import "./pricing-fetcher-Dm8hcn_h.js";
2
2
  import "./_types-Cr2YEzKm.js";
3
- import "./data-loader-B_ymgjWR.js";
4
- import "./logger-6I_KKR-u.js";
5
- import { detectMismatches, printMismatchReport } from "./debug-2jwq04IT.js";
3
+ import "./data-loader-BeaFK_sH.js";
4
+ import "./logger-Cke8hliP.js";
5
+ import { detectMismatches, printMismatchReport } from "./debug-BmJuGBXC.js";
6
6
  export { detectMismatches, printMismatchReport };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, CLAUDE_PROJECTS_DIR_NAME, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __commonJSMin, __require, __toESM, require_usingCtx } from "./pricing-fetcher-CMyU5JUX.js";
2
+ import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, CLAUDE_PROJECTS_DIR_NAME, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __commonJSMin, __require, __toESM, require_usingCtx } from "./pricing-fetcher-Dm8hcn_h.js";
3
3
  import { CostModes, SortOrders, dateSchema } from "./_types-Cr2YEzKm.js";
4
4
  import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-CoS7we68.js";
5
- import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, glob, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, sortFilesByTimestamp, uniq, usageDataSchema } from "./data-loader-B_ymgjWR.js";
6
- import { description, log, logger, name, version } from "./logger-6I_KKR-u.js";
7
- import { detectMismatches, printMismatchReport } from "./debug-2jwq04IT.js";
8
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-COnbPauf.js";
5
+ import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, glob, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, sortFilesByTimestamp, uniq, usageDataSchema } from "./data-loader-BeaFK_sH.js";
6
+ import { description, log, logger, name, version } from "./logger-Cke8hliP.js";
7
+ import { detectMismatches, printMismatchReport } from "./debug-BmJuGBXC.js";
8
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DKqp_F9c.js";
9
9
  import { readFile } from "node:fs/promises";
10
10
  import path from "node:path";
11
11
  import process$1 from "node:process";
@@ -3777,7 +3777,7 @@ function renderLiveDisplay(terminal, block, config) {
3777
3777
  }) : `[${import_picocolors$4.default.green("█".repeat(Math.floor(barWidth * .1)))}${import_picocolors$4.default.gray("░".repeat(barWidth - Math.floor(barWidth * .1)))}]`;
3778
3778
  const burnRate = calculateBurnRate(block);
3779
3779
  const rateIndicator = burnRate != null ? burnRate.tokensPerMinute > 1e3 ? import_picocolors$4.default.red("⚡ HIGH") : burnRate.tokensPerMinute > 500 ? import_picocolors$4.default.yellow("⚡ MODERATE") : import_picocolors$4.default.green("✓ NORMAL") : "";
3780
- const rateDisplay = burnRate != null ? `${import_picocolors$4.default.bold("Burn Rate:")} ${Math.round(burnRate.tokensPerMinute)} per min ${rateIndicator}` : `${import_picocolors$4.default.bold("Burn Rate:")} N/A`;
3780
+ const rateDisplay = burnRate != null ? `${import_picocolors$4.default.bold("Burn Rate:")} ${Math.round(burnRate.tokensPerMinute)} token/min ${rateIndicator}` : `${import_picocolors$4.default.bold("Burn Rate:")} N/A`;
3781
3781
  const usageLabel = import_picocolors$4.default.bold("🔥 USAGE");
3782
3782
  const usageLabelWidth = stringWidth(usageLabel);
3783
3783
  if (config.tokenLimit != null && config.tokenLimit > 0) {
@@ -951,7 +951,7 @@ function _getDefaultLogLevel() {
951
951
  }
952
952
  const consola = createConsola$1();
953
953
  var name = "ccusage";
954
- var version = "15.0.0";
954
+ var version = "15.1.0";
955
955
  var description = "Usage analysis tool for Claude Code";
956
956
  /**
957
957
  * Application logger instance with package name tag
package/dist/logger.js CHANGED
@@ -1,2 +1,2 @@
1
- import { log, logger } from "./logger-6I_KKR-u.js";
1
+ import { log, logger } from "./logger-Cke8hliP.js";
2
2
  export { log, logger };