ccusage 14.0.0 → 14.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-Dup-4216.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-DPd7IFTJ.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-fRKbFGRA.js";
3
+ import { logger } from "./logger-w2zYZX0n.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";
@@ -3261,7 +3261,7 @@ function getClaudePaths() {
3261
3261
  }
3262
3262
  }
3263
3263
  }
3264
- const defaultPaths = [path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CONFIG_PATH), path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH)];
3264
+ const defaultPaths = [DEFAULT_CLAUDE_CONFIG_PATH, path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH)];
3265
3265
  for (const defaultPath of defaultPaths) {
3266
3266
  const normalizedPath = path.resolve(defaultPath);
3267
3267
  if (isDirectorySync(normalizedPath)) {
@@ -3275,7 +3275,7 @@ function getClaudePaths() {
3275
3275
  }
3276
3276
  }
3277
3277
  if (paths.length === 0) throw new Error(`No valid Claude data directories found. Please ensure at least one of the following exists:
3278
- - ${path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CONFIG_PATH, CLAUDE_PROJECTS_DIR_NAME)}
3278
+ - ${path.join(DEFAULT_CLAUDE_CONFIG_PATH, CLAUDE_PROJECTS_DIR_NAME)}
3279
3279
  - ${path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH, CLAUDE_PROJECTS_DIR_NAME)}
3280
3280
  - Or set ${CLAUDE_CONFIG_DIR_ENV} environment variable to valid directory path(s) containing a '${CLAUDE_PROJECTS_DIR_NAME}' subdirectory`.trim());
3281
3281
  return paths;
@@ -3294,7 +3294,7 @@ function getDefaultClaudePath() {
3294
3294
  return firstPath;
3295
3295
  }
3296
3296
  }
3297
- const newDefaultPath = path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CONFIG_PATH);
3297
+ const newDefaultPath = DEFAULT_CLAUDE_CONFIG_PATH;
3298
3298
  if (isDirectorySync(newDefaultPath)) return newDefaultPath;
3299
3299
  const oldDefaultPath = path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH);
3300
3300
  if (isDirectorySync(oldDefaultPath)) return oldDefaultPath;
@@ -1,5 +1,5 @@
1
- import "./pricing-fetcher-Dup-4216.js";
1
+ import "./pricing-fetcher-DPd7IFTJ.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-C8KM6jhg.js";
4
- import "./logger-fRKbFGRA.js";
3
+ import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-BNbKTtlu.js";
4
+ import "./logger-w2zYZX0n.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, DEFAULT_CLAUDE_CODE_PATH, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __toESM, require_usingCtx } from "./pricing-fetcher-Dup-4216.js";
2
- import { glob, usageDataSchema } from "./data-loader-C8KM6jhg.js";
3
- import { logger } from "./logger-fRKbFGRA.js";
1
+ import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, require_usingCtx } from "./pricing-fetcher-DPd7IFTJ.js";
2
+ import { getDefaultClaudePath, glob, usageDataSchema } from "./data-loader-BNbKTtlu.js";
3
+ import { logger } from "./logger-w2zYZX0n.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);
@@ -13,7 +13,7 @@ var import_usingCtx = __toESM(require_usingCtx(), 1);
13
13
  async function detectMismatches(claudePath) {
14
14
  try {
15
15
  var _usingCtx = (0, import_usingCtx.default)();
16
- const claudeDir = claudePath ?? path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH, CLAUDE_PROJECTS_DIR_NAME);
16
+ const claudeDir = claudePath ?? path.join(getDefaultClaudePath(), CLAUDE_PROJECTS_DIR_NAME);
17
17
  const files = await glob([USAGE_DATA_GLOB_PATTERN], {
18
18
  cwd: claudeDir,
19
19
  absolute: true
package/dist/debug.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./pricing-fetcher-Dup-4216.js";
1
+ import "./pricing-fetcher-DPd7IFTJ.js";
2
2
  import "./_types-Cr2YEzKm.js";
3
- import "./data-loader-C8KM6jhg.js";
4
- import "./logger-fRKbFGRA.js";
5
- import { detectMismatches, printMismatchReport } from "./debug-BJaJWLMi.js";
3
+ import "./data-loader-BNbKTtlu.js";
4
+ import "./logger-w2zYZX0n.js";
5
+ import { detectMismatches, printMismatchReport } from "./debug-ColbGDds.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, DEFAULT_RECENT_DAYS, MCP_DEFAULT_PORT, __commonJSMin, __require, __toESM } from "./pricing-fetcher-Dup-4216.js";
2
+ import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, DEFAULT_RECENT_DAYS, MCP_DEFAULT_PORT, __commonJSMin, __require, __toESM } from "./pricing-fetcher-DPd7IFTJ.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, filterRecentBlocks, formatDateCompact, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, uniq } from "./data-loader-C8KM6jhg.js";
6
- import { description, log, logger, name, version } from "./logger-fRKbFGRA.js";
7
- import { detectMismatches, printMismatchReport } from "./debug-BJaJWLMi.js";
8
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Beq_0A1e.js";
5
+ import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, filterRecentBlocks, formatDateCompact, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, uniq } from "./data-loader-BNbKTtlu.js";
6
+ import { description, log, logger, name, version } from "./logger-w2zYZX0n.js";
7
+ import { detectMismatches, printMismatchReport } from "./debug-ColbGDds.js";
8
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Cv-5n2qV.js";
9
9
  import process$1 from "node:process";
10
10
  import { createServer } from "node:http";
11
11
  import { Http2ServerRequest } from "node:http2";
@@ -951,7 +951,7 @@ function _getDefaultLogLevel() {
951
951
  }
952
952
  const consola = createConsola$1();
953
953
  var name = "ccusage";
954
- var version = "14.0.0";
954
+ var version = "14.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-fRKbFGRA.js";
1
+ import { log, logger } from "./logger-w2zYZX0n.js";
2
2
  export { log, logger };
@@ -1,7 +1,7 @@
1
- import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-Dup-4216.js";
1
+ import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-DPd7IFTJ.js";
2
2
  import { ZodFirstPartyTypeKind, ZodOptional, ZodType, arrayType, booleanType, dateSchema, discriminatedUnionType, enumType, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./_types-Cr2YEzKm.js";
3
- import { getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-C8KM6jhg.js";
4
- import { name, version } from "./logger-fRKbFGRA.js";
3
+ import { getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-BNbKTtlu.js";
4
+ import { name, version } from "./logger-w2zYZX0n.js";
5
5
  import process from "node:process";
6
6
  const LATEST_PROTOCOL_VERSION = "2025-03-26";
7
7
  const SUPPORTED_PROTOCOL_VERSIONS = [
package/dist/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./pricing-fetcher-Dup-4216.js";
1
+ import "./pricing-fetcher-DPd7IFTJ.js";
2
2
  import "./_types-Cr2YEzKm.js";
3
- import "./data-loader-C8KM6jhg.js";
4
- import "./logger-fRKbFGRA.js";
5
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Beq_0A1e.js";
3
+ import "./data-loader-BNbKTtlu.js";
4
+ import "./logger-w2zYZX0n.js";
5
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-Cv-5n2qV.js";
6
6
  export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
@@ -1,7 +1,8 @@
1
1
  import { modelPricingSchema } from "./_types-Cr2YEzKm.js";
2
- import { logger } from "./logger-fRKbFGRA.js";
2
+ import { logger } from "./logger-w2zYZX0n.js";
3
3
  import { createRequire } from "node:module";
4
- import { homedir } from "node:os";
4
+ import F, { homedir } from "node:os";
5
+ import path from "node:path";
5
6
  var __create = Object.create;
6
7
  var __defProp = Object.defineProperty;
7
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -24,6 +25,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
25
  enumerable: true
25
26
  }) : target, mod));
26
27
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
28
+ const homeDirectory = F.homedir();
29
+ const { env } = process;
30
+ const xdgData = env.XDG_DATA_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "share") : void 0);
31
+ const xdgConfig = env.XDG_CONFIG_HOME || (homeDirectory ? path.join(homeDirectory, ".config") : void 0);
32
+ const xdgState = env.XDG_STATE_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "state") : void 0);
33
+ const xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, ".cache") : void 0);
34
+ const xdgRuntime = env.XDG_RUNTIME_DIR || void 0;
35
+ const xdgDataDirectories = (env.XDG_DATA_DIRS || "/usr/local/share/:/usr/share/").split(":");
36
+ if (xdgData) xdgDataDirectories.unshift(xdgData);
37
+ const xdgConfigDirectories = (env.XDG_CONFIG_DIRS || "/etc/xdg").split(":");
38
+ if (xdgConfig) xdgConfigDirectories.unshift(xdgConfig);
27
39
  /**
28
40
  * URL for LiteLLM's model pricing and context window data
29
41
  */
@@ -54,15 +66,25 @@ const BLOCKS_DEFAULT_TERMINAL_WIDTH = 120;
54
66
  */
55
67
  const DEBUG_MATCH_THRESHOLD_PERCENT = .1;
56
68
  /**
69
+ * User's home directory path
70
+ * Centralized access to OS home directory for consistent path building
71
+ */
72
+ const USER_HOME_DIR = homedir();
73
+ /**
74
+ * XDG config directory path
75
+ * Uses XDG_CONFIG_HOME if set, otherwise falls back to ~/.config
76
+ */
77
+ const XDG_CONFIG_DIR = xdgConfig ?? `${USER_HOME_DIR}/.config`;
78
+ /**
57
79
  * Default Claude data directory path (~/.claude)
58
80
  * Used as base path for loading usage data from JSONL files
59
81
  */
60
82
  const DEFAULT_CLAUDE_CODE_PATH = ".claude";
61
83
  /**
62
- * Additional default Claude data directory path (~/.config/claude)
63
- * Used as secondary path for loading usage data from JSONL files
84
+ * Default Claude data directory path using XDG config directory
85
+ * Uses XDG_CONFIG_HOME if set, otherwise falls back to ~/.config/claude
64
86
  */
65
- const DEFAULT_CLAUDE_CONFIG_PATH = ".config/claude";
87
+ const DEFAULT_CLAUDE_CONFIG_PATH = `${XDG_CONFIG_DIR}/claude`;
66
88
  /**
67
89
  * Environment variable for specifying multiple Claude data directories
68
90
  * Supports comma-separated paths for multiple locations
@@ -83,11 +105,6 @@ const USAGE_DATA_GLOB_PATTERN = "**/*.jsonl";
83
105
  * Used when no port is specified for MCP server communication
84
106
  */
85
107
  const MCP_DEFAULT_PORT = 8080;
86
- /**
87
- * User's home directory path
88
- * Centralized access to OS home directory for consistent path building
89
- */
90
- const USER_HOME_DIR = homedir();
91
108
  var require_usingCtx = __commonJSMin((exports, module) => {
92
109
  function _usingCtx() {
93
110
  var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
@@ -1,4 +1,4 @@
1
- import { PricingFetcher } from "./pricing-fetcher-Dup-4216.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-DPd7IFTJ.js";
2
2
  import "./_types-Cr2YEzKm.js";
3
- import "./logger-fRKbFGRA.js";
3
+ import "./logger-w2zYZX0n.js";
4
4
  export { PricingFetcher };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccusage",
3
3
  "type": "module",
4
- "version": "14.0.0",
4
+ "version": "14.1.0",
5
5
  "description": "Usage analysis tool for Claude Code",
6
6
  "author": "ryoppippi",
7
7
  "license": "MIT",