ccusage 15.1.0 → 15.2.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.
- package/README.md +3 -1
- package/dist/{_types-Cr2YEzKm.js → _types-CmSE0O0q.js} +1 -6
- package/dist/{calculate-cost-CoS7we68.js → calculate-cost-B0RYn0Vm.js} +2 -6
- package/dist/calculate-cost.d.ts +2 -2
- package/dist/calculate-cost.js +2 -2
- package/dist/{data-loader-DZczD-9E.d.ts → data-loader-BuHgMcpg.d.ts} +2 -8
- package/dist/{data-loader-BeaFK_sH.js → data-loader-CzOPffdg.js} +5 -25
- package/dist/data-loader.d.ts +3 -3
- package/dist/data-loader.js +5 -5
- package/dist/{debug-BmJuGBXC.js → debug-CCsUo8-n.js} +10 -4
- package/dist/debug.js +5 -5
- package/dist/index.js +407 -329
- package/dist/{logger-Cke8hliP.js → logger-CeR-gFvq.js} +1 -1
- package/dist/logger.d.ts +4 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-DKqp_F9c.js → mcp-DGCqhgBz.js} +211 -28
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -5
- package/dist/{pricing-fetcher-BZe7AafW.d.ts → pricing-fetcher-CrV0acwD.d.ts} +2 -0
- package/dist/{pricing-fetcher-Dm8hcn_h.js → pricing-fetcher-fT0o6CKK.js} +145 -116
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
<a href="https://npmjs.com/package/ccusage"><img src="https://img.shields.io/npm/v/ccusage?color=yellow" alt="npm version" /></a>
|
|
8
8
|
<a href="https://tanstack.com/stats/npm?packageGroups=%5B%7B%22packages%22:%5B%7B%22name%22:%22ccusage%22%7D%5D%7D%5D&range=30-days&transform=none&binType=daily&showDataMode=all&height=400"><img src="https://img.shields.io/npm/dy/ccusage" alt="NPM Downloads" /></a>
|
|
9
9
|
<a href="https://packagephobia.com/result?p=ccusage"><img src="https://packagephobia.com/badge?p=ccusage" alt="install size" /></a>
|
|
10
|
+
<a href="https://deepwiki.com/ryoppippi/ccusage"><img src="https://img.shields.io/badge/DeepWiki-ryoppippi%2Fccusage-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==" alt="DeepWiki"></a>
|
|
11
|
+
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
|
|
10
12
|
<a href="https://github.com/hesreallyhim/awesome-claude-code"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Claude Code" /></a>
|
|
11
13
|
</p>
|
|
12
14
|
|
|
@@ -63,7 +65,7 @@ ccusage daily --breakdown # Per-model cost breakdown
|
|
|
63
65
|
|
|
64
66
|
## Documentation
|
|
65
67
|
|
|
66
|
-
Full documentation is available at **[ccusage.
|
|
68
|
+
Full documentation is available at **[ccusage.com](https://ccusage.com/)**
|
|
67
69
|
|
|
68
70
|
## Sponsors
|
|
69
71
|
|
|
@@ -3581,11 +3581,6 @@ const createDailyDate = (value) => dailyDateSchema.parse(value);
|
|
|
3581
3581
|
const createMonthlyDate = (value) => monthlyDateSchema.parse(value);
|
|
3582
3582
|
const createProjectPath = (value) => projectPathSchema.parse(value);
|
|
3583
3583
|
/**
|
|
3584
|
-
* Legacy schema for backward compatibility
|
|
3585
|
-
* @deprecated Use filterDateSchema instead for better type safety
|
|
3586
|
-
*/
|
|
3587
|
-
const dateSchema = stringType().regex(/^\d{8}$/, "Date must be in YYYYMMDD format");
|
|
3588
|
-
/**
|
|
3589
3584
|
* Available cost calculation modes
|
|
3590
3585
|
* - auto: Use pre-calculated costs when available, otherwise calculate from tokens
|
|
3591
3586
|
* - calculate: Always calculate costs from token counts using model pricing
|
|
@@ -3609,4 +3604,4 @@ const modelPricingSchema = objectType({
|
|
|
3609
3604
|
cache_creation_input_token_cost: numberType().optional(),
|
|
3610
3605
|
cache_read_input_token_cost: numberType().optional()
|
|
3611
3606
|
});
|
|
3612
|
-
export { CostModes, SortOrders, ZodFirstPartyTypeKind, ZodOptional, ZodType, activityDateSchema, arrayType, booleanType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema,
|
|
3607
|
+
export { CostModes, SortOrders, ZodFirstPartyTypeKind, ZodOptional, ZodType, activityDateSchema, arrayType, booleanType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, discriminatedUnionType, enumType, filterDateSchema, isoTimestampSchema, literalType, messageIdSchema, modelNameSchema, modelPricingSchema, monthlyDateSchema, numberType, objectType, optionalType, projectPathSchema, recordType, requestIdSchema, sessionIdSchema, stringType, unionType, unknownType, versionSchema };
|
|
@@ -33,12 +33,8 @@ function getTotalTokens(tokens) {
|
|
|
33
33
|
*/
|
|
34
34
|
function createTotalsObject(totals) {
|
|
35
35
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
cacheCreationTokens: totals.cacheCreationTokens,
|
|
39
|
-
cacheReadTokens: totals.cacheReadTokens,
|
|
40
|
-
totalTokens: getTotalTokens(totals),
|
|
41
|
-
totalCost: totals.totalCost
|
|
36
|
+
...totals,
|
|
37
|
+
totalTokens: getTotalTokens(totals)
|
|
42
38
|
};
|
|
43
39
|
}
|
|
44
40
|
export { calculateTotals, createTotalsObject, getTotalTokens };
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-
|
|
2
|
-
import "./pricing-fetcher-
|
|
1
|
+
import { DailyUsage, MonthlyUsage, SessionUsage } from "./data-loader-BuHgMcpg.js";
|
|
2
|
+
import "./pricing-fetcher-CrV0acwD.js";
|
|
3
3
|
|
|
4
4
|
//#region src/calculate-cost.d.ts
|
|
5
5
|
|
package/dist/calculate-cost.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./_types-
|
|
2
|
-
import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-
|
|
1
|
+
import "./_types-CmSE0O0q.js";
|
|
2
|
+
import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-B0RYn0Vm.js";
|
|
3
3
|
export { calculateTotals, createTotalsObject, getTotalTokens };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CostMode, PricingFetcher, SortOrder } from "./pricing-fetcher-
|
|
1
|
+
import { CostMode, PricingFetcher, SortOrder } from "./pricing-fetcher-CrV0acwD.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/_session-blocks.d.ts
|
|
@@ -53,12 +53,6 @@ type SessionBlock = {
|
|
|
53
53
|
* @returns Array of valid Claude data directory paths
|
|
54
54
|
*/
|
|
55
55
|
declare function getClaudePaths(): string[];
|
|
56
|
-
/**
|
|
57
|
-
* Default path for Claude data directory
|
|
58
|
-
* Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
|
|
59
|
-
* @deprecated Use getClaudePaths() instead for multiple path support
|
|
60
|
-
*/
|
|
61
|
-
declare function getDefaultClaudePath(): string;
|
|
62
56
|
/**
|
|
63
57
|
* Zod schema for validating Claude usage data from JSONL files
|
|
64
58
|
*/
|
|
@@ -468,4 +462,4 @@ declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsa
|
|
|
468
462
|
*/
|
|
469
463
|
declare function loadSessionBlockData(options?: LoadOptions): Promise<SessionBlock[]>;
|
|
470
464
|
//#endregion
|
|
471
|
-
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths,
|
|
465
|
+
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
2
|
-
import { activityDateSchema, arrayType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, versionSchema } from "./_types-
|
|
3
|
-
import { logger } from "./logger-
|
|
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-fT0o6CKK.js";
|
|
2
|
+
import { activityDateSchema, arrayType, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, versionSchema } from "./_types-CmSE0O0q.js";
|
|
3
|
+
import { logger } from "./logger-CeR-gFvq.js";
|
|
4
4
|
import a, { readFile } from "node:fs/promises";
|
|
5
|
-
import F, { homedir } from "node:os";
|
|
6
5
|
import path, { posix } from "node:path";
|
|
7
6
|
import process$1 from "node:process";
|
|
8
7
|
import b from "node:fs";
|
|
8
|
+
import F from "node:os";
|
|
9
9
|
function toArray(array) {
|
|
10
10
|
array = array ?? [];
|
|
11
11
|
return Array.isArray(array) ? array : [array];
|
|
@@ -3291,26 +3291,6 @@ function getClaudePaths() {
|
|
|
3291
3291
|
return paths;
|
|
3292
3292
|
}
|
|
3293
3293
|
/**
|
|
3294
|
-
* Default path for Claude data directory
|
|
3295
|
-
* Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
|
|
3296
|
-
* @deprecated Use getClaudePaths() instead for multiple path support
|
|
3297
|
-
*/
|
|
3298
|
-
function getDefaultClaudePath() {
|
|
3299
|
-
const envPath = (process$1.env[CLAUDE_CONFIG_DIR_ENV] ?? "").trim();
|
|
3300
|
-
if (envPath !== "") {
|
|
3301
|
-
const firstPath = envPath.split(",")[0]?.trim();
|
|
3302
|
-
if (firstPath != null && firstPath !== "") {
|
|
3303
|
-
if (!isDirectorySync(firstPath)) throw new Error(`CLAUDE_CONFIG_DIR path is not a valid directory: ${firstPath}`);
|
|
3304
|
-
return firstPath;
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
const newDefaultPath = DEFAULT_CLAUDE_CONFIG_PATH;
|
|
3308
|
-
if (isDirectorySync(newDefaultPath)) return newDefaultPath;
|
|
3309
|
-
const oldDefaultPath = path.join(USER_HOME_DIR, DEFAULT_CLAUDE_CODE_PATH);
|
|
3310
|
-
if (isDirectorySync(oldDefaultPath)) return oldDefaultPath;
|
|
3311
|
-
return oldDefaultPath;
|
|
3312
|
-
}
|
|
3313
|
-
/**
|
|
3314
3294
|
* Zod schema for validating Claude usage data from JSONL files
|
|
3315
3295
|
*/
|
|
3316
3296
|
const usageDataSchema = objectType({
|
|
@@ -3879,4 +3859,4 @@ async function loadSessionBlockData(options) {
|
|
|
3879
3859
|
_usingCtx4.d();
|
|
3880
3860
|
}
|
|
3881
3861
|
}
|
|
3882
|
-
export { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, dailyUsageSchema, filterRecentBlocks, formatDate, formatDateCompact, getClaudePaths,
|
|
3862
|
+
export { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, dailyUsageSchema, filterRecentBlocks, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, glob, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, projectBlockUsage, sessionUsageSchema, sortFilesByTimestamp, uniq, usageDataSchema };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths,
|
|
2
|
-
import "./pricing-fetcher-
|
|
3
|
-
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths,
|
|
1
|
+
import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-BuHgMcpg.js";
|
|
2
|
+
import "./pricing-fetcher-CrV0acwD.js";
|
|
3
|
+
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import "./_types-
|
|
3
|
-
import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths,
|
|
4
|
-
import "./logger-
|
|
5
|
-
export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths,
|
|
1
|
+
import "./pricing-fetcher-fT0o6CKK.js";
|
|
2
|
+
import "./_types-CmSE0O0q.js";
|
|
3
|
+
import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-CzOPffdg.js";
|
|
4
|
+
import "./logger-CeR-gFvq.js";
|
|
5
|
+
export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getClaudePaths, 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-
|
|
2
|
-
import {
|
|
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-fT0o6CKK.js";
|
|
2
|
+
import { getClaudePaths, glob, usageDataSchema } from "./data-loader-CzOPffdg.js";
|
|
3
|
+
import { logger } from "./logger-CeR-gFvq.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,13 @@ 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
|
-
|
|
16
|
+
let claudeDir;
|
|
17
|
+
if (claudePath != null && claudePath !== "") claudeDir = claudePath;
|
|
18
|
+
else {
|
|
19
|
+
const paths = getClaudePaths();
|
|
20
|
+
if (paths.length === 0) throw new Error("No valid Claude data directory found");
|
|
21
|
+
claudeDir = path.join(paths[0], CLAUDE_PROJECTS_DIR_NAME);
|
|
22
|
+
}
|
|
17
23
|
const files = await glob([USAGE_DATA_GLOB_PATTERN], {
|
|
18
24
|
cwd: claudeDir,
|
|
19
25
|
absolute: true
|
package/dist/debug.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import "./_types-
|
|
3
|
-
import "./data-loader-
|
|
4
|
-
import "./logger-
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
1
|
+
import "./pricing-fetcher-fT0o6CKK.js";
|
|
2
|
+
import "./_types-CmSE0O0q.js";
|
|
3
|
+
import "./data-loader-CzOPffdg.js";
|
|
4
|
+
import "./logger-CeR-gFvq.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-CCsUo8-n.js";
|
|
6
6
|
export { detectMismatches, printMismatchReport };
|