ccusage 14.0.0 → 14.1.1
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.
- package/dist/{data-loader-C8KM6jhg.js → data-loader-Cfgw5huk.js} +6 -6
- package/dist/data-loader.js +3 -3
- package/dist/{debug-BJaJWLMi.js → debug-CM0KZJQf.js} +4 -4
- package/dist/debug.js +4 -4
- package/dist/index.js +6 -5
- package/dist/{logger-fRKbFGRA.js → logger-Bn_f0htg.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-Beq_0A1e.js → mcp-hY4UqfJ-.js} +3 -3
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-Dup-4216.js → pricing-fetcher-BqZed0a8.js} +27 -10
- package/dist/pricing-fetcher.js +2 -2
- package/package.json +1 -1
|
@@ -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-
|
|
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-BqZed0a8.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-
|
|
3
|
+
import { logger } from "./logger-Bn_f0htg.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 = [
|
|
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(
|
|
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 =
|
|
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;
|
|
@@ -3824,7 +3824,7 @@ async function loadSessionBlockData(options) {
|
|
|
3824
3824
|
if (allFiles.length === 0) return [];
|
|
3825
3825
|
const sortedFiles = await sortFilesByTimestamp(allFiles);
|
|
3826
3826
|
const mode = options?.mode ?? "auto";
|
|
3827
|
-
const fetcher = _usingCtx4.u(mode === "display" ? null : new PricingFetcher());
|
|
3827
|
+
const fetcher = _usingCtx4.u(mode === "display" ? null : new PricingFetcher(options?.offline));
|
|
3828
3828
|
const processedHashes = /* @__PURE__ */ new Set();
|
|
3829
3829
|
const allEntries = [];
|
|
3830
3830
|
for (const file of sortedFiles) {
|
package/dist/data-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-BqZed0a8.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-
|
|
4
|
-
import "./logger-
|
|
3
|
+
import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-Cfgw5huk.js";
|
|
4
|
+
import "./logger-Bn_f0htg.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,
|
|
2
|
-
import { glob, usageDataSchema } from "./data-loader-
|
|
3
|
-
import { logger } from "./logger-
|
|
1
|
+
import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, require_usingCtx } from "./pricing-fetcher-BqZed0a8.js";
|
|
2
|
+
import { getDefaultClaudePath, glob, usageDataSchema } from "./data-loader-Cfgw5huk.js";
|
|
3
|
+
import { logger } from "./logger-Bn_f0htg.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(
|
|
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-
|
|
1
|
+
import "./pricing-fetcher-BqZed0a8.js";
|
|
2
2
|
import "./_types-Cr2YEzKm.js";
|
|
3
|
-
import "./data-loader-
|
|
4
|
-
import "./logger-
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
3
|
+
import "./data-loader-Cfgw5huk.js";
|
|
4
|
+
import "./logger-Bn_f0htg.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-CM0KZJQf.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-
|
|
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-BqZed0a8.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-
|
|
6
|
-
import { description, log, logger, name, version } from "./logger-
|
|
7
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
8
|
-
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-
|
|
5
|
+
import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, filterRecentBlocks, formatDateCompact, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, projectBlockUsage, uniq } from "./data-loader-Cfgw5huk.js";
|
|
6
|
+
import { description, log, logger, name, version } from "./logger-Bn_f0htg.js";
|
|
7
|
+
import { detectMismatches, printMismatchReport } from "./debug-CM0KZJQf.js";
|
|
8
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-hY4UqfJ-.js";
|
|
9
9
|
import process$1 from "node:process";
|
|
10
10
|
import { createServer } from "node:http";
|
|
11
11
|
import { Http2ServerRequest } from "node:http2";
|
|
@@ -3263,6 +3263,7 @@ const blocksCommand = define({
|
|
|
3263
3263
|
claudePath: getDefaultClaudePath(),
|
|
3264
3264
|
mode: ctx.values.mode,
|
|
3265
3265
|
order: ctx.values.order,
|
|
3266
|
+
offline: ctx.values.offline,
|
|
3266
3267
|
sessionDurationHours: ctx.values.sessionLength
|
|
3267
3268
|
});
|
|
3268
3269
|
if (blocks.length === 0) {
|
|
@@ -951,7 +951,7 @@ function _getDefaultLogLevel() {
|
|
|
951
951
|
}
|
|
952
952
|
const consola = createConsola$1();
|
|
953
953
|
var name = "ccusage";
|
|
954
|
-
var version = "14.
|
|
954
|
+
var version = "14.1.1";
|
|
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-
|
|
1
|
+
import { log, logger } from "./logger-Bn_f0htg.js";
|
|
2
2
|
export { log, logger };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-
|
|
1
|
+
import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-BqZed0a8.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-
|
|
4
|
-
import { name, version } from "./logger-
|
|
3
|
+
import { getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-Cfgw5huk.js";
|
|
4
|
+
import { name, version } from "./logger-Bn_f0htg.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-
|
|
1
|
+
import "./pricing-fetcher-BqZed0a8.js";
|
|
2
2
|
import "./_types-Cr2YEzKm.js";
|
|
3
|
-
import "./data-loader-
|
|
4
|
-
import "./logger-
|
|
5
|
-
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-
|
|
3
|
+
import "./data-loader-Cfgw5huk.js";
|
|
4
|
+
import "./logger-Bn_f0htg.js";
|
|
5
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-hY4UqfJ-.js";
|
|
6
6
|
export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { modelPricingSchema } from "./_types-Cr2YEzKm.js";
|
|
2
|
-
import { logger } from "./logger-
|
|
2
|
+
import { logger } from "./logger-Bn_f0htg.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
|
-
*
|
|
63
|
-
*
|
|
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 =
|
|
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) {
|
package/dist/pricing-fetcher.js
CHANGED