ccusage 15.5.1 → 15.5.2

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,7 +1,7 @@
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, isFailure, isPromise, require_usingCtx } from "./pricing-fetcher-eNV76BjF.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, isFailure, isPromise, require_usingCtx } from "./pricing-fetcher-B5b61mDE.js";
2
2
  import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
3
3
  import { activityDateSchema, arrayType, booleanType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, stringType, versionSchema } from "./_types-BHFM59hI.js";
4
- import { logger } from "./logger-COLgmk2z.js";
4
+ import { logger } from "./logger-D0z-I-_d.js";
5
5
  import a, { readFile } from "node:fs/promises";
6
6
  import path, { posix } from "node:path";
7
7
  import process$1 from "node:process";
@@ -3543,26 +3543,16 @@ function extractUniqueModels(entries, getModel) {
3543
3543
  return uniq(entries.map(getModel).filter((m$1) => m$1 != null && m$1 !== "<synthetic>"));
3544
3544
  }
3545
3545
  /**
3546
- * Shared method for formatting dates with proper timezone handling
3547
- * @param dateStr - Input date string
3548
- * @param twoLine - Whether to format as two lines (true) or single line (false)
3549
- * @returns Formatted date string
3550
- */
3551
- function formatDateInternal(dateStr, twoLine) {
3552
- const date = new Date(dateStr);
3553
- const hasTimezone = /Z|[+-]\d{2}:\d{2}/.test(dateStr);
3554
- const year = hasTimezone ? date.getUTCFullYear() : date.getFullYear();
3555
- const month = String(hasTimezone ? date.getUTCMonth() + 1 : date.getMonth() + 1).padStart(2, "0");
3556
- const day = String(hasTimezone ? date.getUTCDate() : date.getDate()).padStart(2, "0");
3557
- return twoLine ? `${year}\n${month}-${day}` : `${year}-${month}-${day}`;
3558
- }
3559
- /**
3560
3546
  * Formats a date string to YYYY-MM-DD format
3561
3547
  * @param dateStr - Input date string
3562
3548
  * @returns Formatted date string in YYYY-MM-DD format
3563
3549
  */
3564
3550
  function formatDate(dateStr) {
3565
- return formatDateInternal(dateStr, false);
3551
+ const date = new Date(dateStr);
3552
+ const year = date.getFullYear();
3553
+ const month = String(date.getMonth() + 1).padStart(2, "0");
3554
+ const day = String(date.getDate()).padStart(2, "0");
3555
+ return `${year}-${month}-${day}`;
3566
3556
  }
3567
3557
  /**
3568
3558
  * Formats a date string to compact format with year on first line and month-day on second
@@ -3570,7 +3560,11 @@ function formatDate(dateStr) {
3570
3560
  * @returns Formatted date string with newline separator (YYYY\nMM-DD)
3571
3561
  */
3572
3562
  function formatDateCompact(dateStr) {
3573
- return formatDateInternal(dateStr, true);
3563
+ const date = new Date(dateStr);
3564
+ const year = date.getFullYear();
3565
+ const month = String(date.getMonth() + 1).padStart(2, "0");
3566
+ const day = String(date.getDate()).padStart(2, "0");
3567
+ return `${year}\n${month}-${day}`;
3574
3568
  }
3575
3569
  /**
3576
3570
  * Generic function to sort items by date based on sort order
@@ -1,6 +1,6 @@
1
- import "./pricing-fetcher-eNV76BjF.js";
1
+ import "./pricing-fetcher-B5b61mDE.js";
2
2
  import "./_token-utils-WjkbrjKv.js";
3
3
  import "./_types-BHFM59hI.js";
4
- import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-BAp4u-7e.js";
5
- import "./logger-COLgmk2z.js";
4
+ import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-CmW1xurn.js";
5
+ import "./logger-D0z-I-_d.js";
6
6
  export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, 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, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-eNV76BjF.js";
2
- import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-BAp4u-7e.js";
3
- import { logger } from "./logger-COLgmk2z.js";
1
+ import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-B5b61mDE.js";
2
+ import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-CmW1xurn.js";
3
+ import { logger } from "./logger-D0z-I-_d.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,7 +1,7 @@
1
- import "./pricing-fetcher-eNV76BjF.js";
1
+ import "./pricing-fetcher-B5b61mDE.js";
2
2
  import "./_token-utils-WjkbrjKv.js";
3
3
  import "./_types-BHFM59hI.js";
4
- import "./data-loader-BAp4u-7e.js";
5
- import "./logger-COLgmk2z.js";
6
- import { detectMismatches, printMismatchReport } from "./debug-IQBgd8CJ.js";
4
+ import "./data-loader-CmW1xurn.js";
5
+ import "./logger-D0z-I-_d.js";
6
+ import { detectMismatches, printMismatchReport } from "./debug-kkVHYWpk.js";
7
7
  export { detectMismatches, printMismatchReport };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PROJECT_ALIASES_ENV, PricingFetcher, __commonJSMin, __require, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-eNV76BjF.js";
2
+ import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PROJECT_ALIASES_ENV, PricingFetcher, __commonJSMin, __require, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-B5b61mDE.js";
3
3
  import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
4
4
  import { CostModes, SortOrders, filterDateSchema } from "./_types-BHFM59hI.js";
5
5
  import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
6
- import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, sortFilesByTimestamp, uniq, usageDataSchema } from "./data-loader-BAp4u-7e.js";
7
- import { description, log, logger, name, version } from "./logger-COLgmk2z.js";
8
- import { detectMismatches, printMismatchReport } from "./debug-IQBgd8CJ.js";
9
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Ta2UK9sc.js";
6
+ import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, sortFilesByTimestamp, uniq, usageDataSchema } from "./data-loader-CmW1xurn.js";
7
+ import { description, log, logger, name, version } from "./logger-D0z-I-_d.js";
8
+ import { detectMismatches, printMismatchReport } from "./debug-kkVHYWpk.js";
9
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DbViDMcM.js";
10
10
  import { readFile } from "node:fs/promises";
11
11
  import process$1 from "node:process";
12
12
  import { createServer } from "node:http";
@@ -4886,32 +4886,27 @@ Object.setPrototypeOf(Response2, GlobalResponse);
4886
4886
  Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
4887
4887
  function writeFromReadableStream(stream, writable) {
4888
4888
  if (stream.locked) throw new TypeError("ReadableStream is locked.");
4889
- else if (writable.destroyed) {
4890
- stream.cancel();
4891
- return;
4892
- }
4889
+ else if (writable.destroyed) return;
4893
4890
  const reader = stream.getReader();
4894
- writable.on("close", cancel);
4895
- writable.on("error", cancel);
4896
- reader.read().then(flow, cancel);
4891
+ const handleError = () => {};
4892
+ writable.on("error", handleError);
4893
+ reader.read().then(flow, handleStreamError);
4897
4894
  return reader.closed.finally(() => {
4898
- writable.off("close", cancel);
4899
- writable.off("error", cancel);
4895
+ writable.off("error", handleError);
4900
4896
  });
4901
- function cancel(error) {
4902
- reader.cancel(error).catch(() => {});
4897
+ function handleStreamError(error) {
4903
4898
  if (error) writable.destroy(error);
4904
4899
  }
4905
4900
  function onDrain() {
4906
- reader.read().then(flow, cancel);
4901
+ reader.read().then(flow, handleStreamError);
4907
4902
  }
4908
4903
  function flow({ done, value }) {
4909
4904
  try {
4910
4905
  if (done) writable.end();
4911
4906
  else if (!writable.write(value)) writable.once("drain", onDrain);
4912
- else return reader.read().then(flow, cancel);
4907
+ else return reader.read().then(flow, handleStreamError);
4913
4908
  } catch (e) {
4914
- cancel(e);
4909
+ handleStreamError(e);
4915
4910
  }
4916
4911
  }
4917
4912
  }
@@ -951,7 +951,7 @@ function _getDefaultLogLevel() {
951
951
  }
952
952
  const consola = createConsola$1();
953
953
  var name = "ccusage";
954
- var version = "15.5.1";
954
+ var version = "15.5.2";
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-COLgmk2z.js";
1
+ import { log, logger } from "./logger-D0z-I-_d.js";
2
2
  export { log, logger };
@@ -1,9 +1,9 @@
1
- import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-eNV76BjF.js";
1
+ import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-B5b61mDE.js";
2
2
  import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
3
3
  import { ZodFirstPartyTypeKind, ZodOptional, ZodType, arrayType, booleanType, discriminatedUnionType, enumType, filterDateSchema, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./_types-BHFM59hI.js";
4
4
  import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
5
- import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-BAp4u-7e.js";
6
- import { name, version } from "./logger-COLgmk2z.js";
5
+ import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-CmW1xurn.js";
6
+ import { name, version } from "./logger-D0z-I-_d.js";
7
7
  import process from "node:process";
8
8
  const LATEST_PROTOCOL_VERSION = "2025-06-18";
9
9
  const SUPPORTED_PROTOCOL_VERSIONS = [
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
- import "./pricing-fetcher-eNV76BjF.js";
1
+ import "./pricing-fetcher-B5b61mDE.js";
2
2
  import "./_token-utils-WjkbrjKv.js";
3
3
  import "./_types-BHFM59hI.js";
4
4
  import "./calculate-cost-BDqO4yWA.js";
5
- import "./data-loader-BAp4u-7e.js";
6
- import "./logger-COLgmk2z.js";
7
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Ta2UK9sc.js";
5
+ import "./data-loader-CmW1xurn.js";
6
+ import "./logger-D0z-I-_d.js";
7
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DbViDMcM.js";
8
8
  export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
@@ -1,5 +1,5 @@
1
1
  import { modelPricingSchema } from "./_types-BHFM59hI.js";
2
- import { logger } from "./logger-COLgmk2z.js";
2
+ import { logger } from "./logger-D0z-I-_d.js";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import F, { homedir } from "node:os";
@@ -346,14 +346,6 @@ var PricingFetcher = class {
346
346
  loadOfflinePricing = try_({
347
347
  try: async () => {
348
348
  const pricing = new Map(Object.entries({
349
- "claude-2": {
350
- "input_cost_per_token": 8e-6,
351
- "output_cost_per_token": 24e-6
352
- },
353
- "claude-2.1": {
354
- "input_cost_per_token": 8e-6,
355
- "output_cost_per_token": 24e-6
356
- },
357
349
  "claude-3-haiku-20240307": {
358
350
  "input_cost_per_token": 25e-8,
359
351
  "output_cost_per_token": 125e-8,
@@ -384,10 +376,6 @@ var PricingFetcher = class {
384
376
  "cache_creation_input_token_cost": 1875e-8,
385
377
  "cache_read_input_token_cost": 15e-7
386
378
  },
387
- "claude-3-sonnet-20240229": {
388
- "input_cost_per_token": 3e-6,
389
- "output_cost_per_token": 15e-6
390
- },
391
379
  "claude-3-5-sonnet-latest": {
392
380
  "input_cost_per_token": 3e-6,
393
381
  "output_cost_per_token": 15e-6,
@@ -1,4 +1,4 @@
1
- import { PricingFetcher } from "./pricing-fetcher-eNV76BjF.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-B5b61mDE.js";
2
2
  import "./_types-BHFM59hI.js";
3
- import "./logger-COLgmk2z.js";
3
+ import "./logger-D0z-I-_d.js";
4
4
  export { PricingFetcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccusage",
3
- "version": "15.5.1",
3
+ "version": "15.5.2",
4
4
  "description": "Usage analysis tool for Claude Code",
5
5
  "homepage": "https://github.com/ryoppippi/ccusage#readme",
6
6
  "bugs": {