ccusage 0.7.0 → 0.8.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 +9 -9
- package/dist/calculate-cost.d.ts +1 -1
- package/dist/{data-loader-nOFcMg_V.js → data-loader-Bz6Vemxw.js} +73 -6
- package/dist/{data-loader-pCzn-ryX.d.ts → data-loader-amTZCtBR.d.ts} +17 -1
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +4 -4
- package/dist/{debug-Bttss7TN.js → debug-DQXeZIjf.js} +3 -3
- package/dist/debug.js +4 -4
- package/dist/index.js +10 -10
- package/dist/{logger-BPjA3VFO.js → logger-DN-RT9jL.js} +5 -5
- package/dist/logger.js +1 -1
- package/dist/{mcp-DCEVbd8C.js → mcp-DZXbfmbs.js} +4 -4
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-CAeJvZnF.js → pricing-fetcher-DMNBE90M.js} +1 -1
- package/dist/pricing-fetcher.js +2 -2
- package/dist/{prompt-DljZqwMa.js → prompt-CUbwSrjo.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -349,15 +349,15 @@ With `--breakdown` flag:
|
|
|
349
349
|
│ │
|
|
350
350
|
╰───────────────────────────────────────────────╯
|
|
351
351
|
|
|
352
|
-
|
|
353
|
-
│
|
|
354
|
-
|
|
355
|
-
│
|
|
356
|
-
|
|
357
|
-
│
|
|
358
|
-
|
|
359
|
-
│ Total
|
|
360
|
-
|
|
352
|
+
┌────────────┬──────────────────┬────────┬─────────┬──────────────┬────────────┬──────────────┬────────────┬───────────────┐
|
|
353
|
+
│ Session │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ Last Activity │
|
|
354
|
+
├────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
355
|
+
│ session-1 │ opus-4, sonnet-4 │ 4,512 │ 350,846 │ 512 │ 1,024 │ 356,894 │ $156.40 │ 2025-05-24 │
|
|
356
|
+
├────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
357
|
+
│ session-2 │ sonnet-4 │ 2,775 │ 186,645 │ 256 │ 768 │ 190,444 │ $98.45 │ 2025-05-25 │
|
|
358
|
+
├────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
359
|
+
│ Total │ │ 11,174 │ 720,445 │ 768 │ 1,792 │ 734,179 │ $336.68 │ │
|
|
360
|
+
└────────────┴──────────────────┴────────┴─────────┴──────────────┴────────────┴──────────────┴────────────┴───────────────┘
|
|
361
361
|
```
|
|
362
362
|
|
|
363
363
|
## Requirements
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { array, number, object, optional, pipe, regex, safeParse, string } from "./dist-BEQ1tJCL.js";
|
|
2
|
-
import {
|
|
2
|
+
import { logger } from "./logger-DN-RT9jL.js";
|
|
3
|
+
import { PricingFetcher } from "./pricing-fetcher-DMNBE90M.js";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
5
6
|
import { homedir } from "node:os";
|
|
@@ -3216,9 +3217,11 @@ const UsageDataSchema = object({
|
|
|
3216
3217
|
cache_creation_input_tokens: optional(number()),
|
|
3217
3218
|
cache_read_input_tokens: optional(number())
|
|
3218
3219
|
}),
|
|
3219
|
-
model: optional(string())
|
|
3220
|
+
model: optional(string()),
|
|
3221
|
+
id: optional(string())
|
|
3220
3222
|
}),
|
|
3221
|
-
costUSD: optional(number())
|
|
3223
|
+
costUSD: optional(number()),
|
|
3224
|
+
requestId: optional(string())
|
|
3222
3225
|
});
|
|
3223
3226
|
const ModelBreakdownSchema = object({
|
|
3224
3227
|
modelName: string(),
|
|
@@ -3268,6 +3271,60 @@ function formatDate(dateStr) {
|
|
|
3268
3271
|
const day = String(date.getDate()).padStart(2, "0");
|
|
3269
3272
|
return `${year}-${month}-${day}`;
|
|
3270
3273
|
}
|
|
3274
|
+
/**
|
|
3275
|
+
* Create a unique identifier for deduplication using message ID and request ID
|
|
3276
|
+
*/
|
|
3277
|
+
function createUniqueHash(data) {
|
|
3278
|
+
const messageId = data.message.id;
|
|
3279
|
+
const requestId = data.requestId;
|
|
3280
|
+
if (messageId == null || requestId == null) return null;
|
|
3281
|
+
return `${messageId}:${requestId}`;
|
|
3282
|
+
}
|
|
3283
|
+
/**
|
|
3284
|
+
* Extract the earliest timestamp from a JSONL file
|
|
3285
|
+
* Scans through the file until it finds a valid timestamp
|
|
3286
|
+
*/
|
|
3287
|
+
async function getEarliestTimestamp(filePath) {
|
|
3288
|
+
try {
|
|
3289
|
+
const content = await readFile(filePath, "utf-8");
|
|
3290
|
+
const lines = content.trim().split("\n");
|
|
3291
|
+
let earliestDate = null;
|
|
3292
|
+
for (const line of lines) {
|
|
3293
|
+
if (line.trim() === "") continue;
|
|
3294
|
+
try {
|
|
3295
|
+
const json = JSON.parse(line);
|
|
3296
|
+
if (json.timestamp != null && typeof json.timestamp === "string") {
|
|
3297
|
+
const date = new Date(json.timestamp);
|
|
3298
|
+
if (!Number.isNaN(date.getTime())) {
|
|
3299
|
+
if (earliestDate == null || date < earliestDate) earliestDate = date;
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
} catch {
|
|
3303
|
+
continue;
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
return earliestDate;
|
|
3307
|
+
} catch (error) {
|
|
3308
|
+
logger.debug(`Failed to get earliest timestamp for ${filePath}:`, error);
|
|
3309
|
+
return null;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Sort files by their earliest timestamp
|
|
3314
|
+
* Files without valid timestamps are placed at the end
|
|
3315
|
+
*/
|
|
3316
|
+
async function sortFilesByTimestamp(files) {
|
|
3317
|
+
const filesWithTimestamps = await Promise.all(files.map(async (file) => ({
|
|
3318
|
+
file,
|
|
3319
|
+
timestamp: await getEarliestTimestamp(file)
|
|
3320
|
+
})));
|
|
3321
|
+
return filesWithTimestamps.sort((a, b) => {
|
|
3322
|
+
if (a.timestamp == null && b.timestamp == null) return 0;
|
|
3323
|
+
if (a.timestamp == null) return 1;
|
|
3324
|
+
if (b.timestamp == null) return -1;
|
|
3325
|
+
return a.timestamp.getTime() - b.timestamp.getTime();
|
|
3326
|
+
}).map((item) => item.file);
|
|
3327
|
+
}
|
|
3271
3328
|
async function calculateCostForEntry(data, mode, fetcher) {
|
|
3272
3329
|
if (mode === "display") return data.costUSD ?? 0;
|
|
3273
3330
|
if (mode === "calculate") {
|
|
@@ -3291,10 +3348,12 @@ async function loadDailyUsageData(options) {
|
|
|
3291
3348
|
absolute: true
|
|
3292
3349
|
});
|
|
3293
3350
|
if (files.length === 0) return [];
|
|
3351
|
+
const sortedFiles = await sortFilesByTimestamp(files);
|
|
3294
3352
|
const mode = options?.mode ?? "auto";
|
|
3295
3353
|
const fetcher = _usingCtx$1.u(mode === "display" ? null : new PricingFetcher());
|
|
3354
|
+
const processedHashes = /* @__PURE__ */ new Set();
|
|
3296
3355
|
const allEntries = [];
|
|
3297
|
-
for (const file of
|
|
3356
|
+
for (const file of sortedFiles) {
|
|
3298
3357
|
const content = await readFile(file, "utf-8");
|
|
3299
3358
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3300
3359
|
for (const line of lines) try {
|
|
@@ -3302,6 +3361,9 @@ async function loadDailyUsageData(options) {
|
|
|
3302
3361
|
const result = safeParse(UsageDataSchema, parsed);
|
|
3303
3362
|
if (!result.success) continue;
|
|
3304
3363
|
const data = result.output;
|
|
3364
|
+
const uniqueHash = createUniqueHash(data);
|
|
3365
|
+
if (uniqueHash != null && processedHashes.has(uniqueHash)) continue;
|
|
3366
|
+
if (uniqueHash != null) processedHashes.add(uniqueHash);
|
|
3305
3367
|
const date = formatDate(data.timestamp);
|
|
3306
3368
|
const cost = fetcher != null ? await calculateCostForEntry(data, mode, fetcher) : data.costUSD ?? 0;
|
|
3307
3369
|
allEntries.push({
|
|
@@ -3389,10 +3451,12 @@ async function loadSessionData(options) {
|
|
|
3389
3451
|
absolute: true
|
|
3390
3452
|
});
|
|
3391
3453
|
if (files.length === 0) return [];
|
|
3454
|
+
const sortedFiles = await sortFilesByTimestamp(files);
|
|
3392
3455
|
const mode = options?.mode ?? "auto";
|
|
3393
3456
|
const fetcher = _usingCtx3.u(mode === "display" ? null : new PricingFetcher());
|
|
3457
|
+
const processedHashes = /* @__PURE__ */ new Set();
|
|
3394
3458
|
const allEntries = [];
|
|
3395
|
-
for (const file of
|
|
3459
|
+
for (const file of sortedFiles) {
|
|
3396
3460
|
const relativePath = path.relative(claudeDir, file);
|
|
3397
3461
|
const parts = relativePath.split(path.sep);
|
|
3398
3462
|
const sessionId = parts[parts.length - 2] ?? "unknown";
|
|
@@ -3405,6 +3469,9 @@ async function loadSessionData(options) {
|
|
|
3405
3469
|
const result = safeParse(UsageDataSchema, parsed);
|
|
3406
3470
|
if (!result.success) continue;
|
|
3407
3471
|
const data = result.output;
|
|
3472
|
+
const uniqueHash = createUniqueHash(data);
|
|
3473
|
+
if (uniqueHash != null && processedHashes.has(uniqueHash)) continue;
|
|
3474
|
+
if (uniqueHash != null) processedHashes.add(uniqueHash);
|
|
3408
3475
|
const sessionKey = `${projectPath}/${sessionId}`;
|
|
3409
3476
|
const cost = fetcher != null ? await calculateCostForEntry(data, mode, fetcher) : data.costUSD ?? 0;
|
|
3410
3477
|
allEntries.push({
|
|
@@ -3547,4 +3614,4 @@ async function loadMonthlyUsageData(options) {
|
|
|
3547
3614
|
}
|
|
3548
3615
|
|
|
3549
3616
|
//#endregion
|
|
3550
|
-
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, __commonJS, __require, __toESM, calculateCostForEntry, formatCurrency, formatDate, formatModelsDisplay, formatNumber, getDefaultClaudePath, glob, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, pushBreakdownRows, require_picocolors, require_usingCtx };
|
|
3617
|
+
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, __commonJS, __require, __toESM, calculateCostForEntry, createUniqueHash, formatCurrency, formatDate, formatModelsDisplay, formatNumber, getDefaultClaudePath, getEarliestTimestamp, glob, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, pushBreakdownRows, require_picocolors, require_usingCtx, sortFilesByTimestamp };
|
|
@@ -92,8 +92,10 @@ declare const UsageDataSchema: ObjectSchema<{
|
|
|
92
92
|
readonly cache_read_input_tokens: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
93
93
|
}, undefined>;
|
|
94
94
|
readonly model: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
95
|
+
readonly id: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
95
96
|
}, undefined>;
|
|
96
97
|
readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
98
|
+
readonly requestId: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
97
99
|
}, undefined>;
|
|
98
100
|
type UsageData = InferOutput<typeof UsageDataSchema>;
|
|
99
101
|
declare const ModelBreakdownSchema: ObjectSchema<{
|
|
@@ -163,6 +165,20 @@ declare const MonthlyUsageSchema: ObjectSchema<{
|
|
|
163
165
|
}, undefined>;
|
|
164
166
|
type MonthlyUsage = InferOutput<typeof MonthlyUsageSchema>;
|
|
165
167
|
declare function formatDate(dateStr: string): string;
|
|
168
|
+
/**
|
|
169
|
+
* Create a unique identifier for deduplication using message ID and request ID
|
|
170
|
+
*/
|
|
171
|
+
declare function createUniqueHash(data: UsageData): string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Extract the earliest timestamp from a JSONL file
|
|
174
|
+
* Scans through the file until it finds a valid timestamp
|
|
175
|
+
*/
|
|
176
|
+
declare function getEarliestTimestamp(filePath: string): Promise<Date | null>;
|
|
177
|
+
/**
|
|
178
|
+
* Sort files by their earliest timestamp
|
|
179
|
+
* Files without valid timestamps are placed at the end
|
|
180
|
+
*/
|
|
181
|
+
declare function sortFilesByTimestamp(files: string[]): Promise<string[]>;
|
|
166
182
|
declare function calculateCostForEntry(data: UsageData, mode: CostMode, fetcher: PricingFetcher): Promise<number>;
|
|
167
183
|
type DateFilter = {
|
|
168
184
|
since?: string;
|
|
@@ -177,4 +193,4 @@ declare function loadDailyUsageData(options?: LoadOptions): Promise<DailyUsage[]
|
|
|
177
193
|
declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
|
|
178
194
|
declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsage[]>;
|
|
179
195
|
//#endregion
|
|
180
|
-
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
196
|
+
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-
|
|
1
|
+
import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp } from "./data-loader-amTZCtBR.js";
|
|
2
2
|
import "./pricing-fetcher-Dq-OLBp4.js";
|
|
3
|
-
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
3
|
+
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-
|
|
1
|
+
import { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp } from "./data-loader-Bz6Vemxw.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
3
|
+
import "./logger-DN-RT9jL.js";
|
|
4
|
+
import "./pricing-fetcher-DMNBE90M.js";
|
|
5
5
|
|
|
6
|
-
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
6
|
+
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UsageDataSchema, __toESM, glob, require_usingCtx } from "./data-loader-
|
|
1
|
+
import { UsageDataSchema, __toESM, glob, require_usingCtx } from "./data-loader-Bz6Vemxw.js";
|
|
2
2
|
import { safeParse } from "./dist-BEQ1tJCL.js";
|
|
3
|
-
import { logger } from "./logger-
|
|
4
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
3
|
+
import { logger } from "./logger-DN-RT9jL.js";
|
|
4
|
+
import { PricingFetcher } from "./pricing-fetcher-DMNBE90M.js";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import path from "node:path";
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./data-loader-
|
|
1
|
+
import "./data-loader-Bz6Vemxw.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
3
|
+
import "./logger-DN-RT9jL.js";
|
|
4
|
+
import "./pricing-fetcher-DMNBE90M.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-DQXeZIjf.js";
|
|
6
6
|
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { __commonJS, __require, __toESM, formatCurrency, formatModelsDisplay, formatNumber, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, pushBreakdownRows, require_picocolors } from "./data-loader-
|
|
2
|
+
import { __commonJS, __require, __toESM, formatCurrency, formatModelsDisplay, formatNumber, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, pushBreakdownRows, require_picocolors } from "./data-loader-Bz6Vemxw.js";
|
|
3
3
|
import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-2IwHSzmi.js";
|
|
4
4
|
import { safeParse } from "./dist-BEQ1tJCL.js";
|
|
5
|
-
import { description, log, logger, name, version } from "./logger-
|
|
6
|
-
import "./pricing-fetcher-
|
|
7
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
8
|
-
import { CostModes, SortOrders, createMcpServer, dateSchema } from "./mcp-
|
|
5
|
+
import { description, log, logger, name, version } from "./logger-DN-RT9jL.js";
|
|
6
|
+
import "./pricing-fetcher-DMNBE90M.js";
|
|
7
|
+
import { detectMismatches, printMismatchReport } from "./debug-DQXeZIjf.js";
|
|
8
|
+
import { CostModes, SortOrders, createMcpServer, dateSchema } from "./mcp-DZXbfmbs.js";
|
|
9
9
|
import "./types-DS8M8QF_.js";
|
|
10
10
|
import "./index-CISmcbXk-x9eVmhGM.js";
|
|
11
|
-
import
|
|
11
|
+
import process$1 from "node:process";
|
|
12
12
|
|
|
13
13
|
//#region node_modules/gunshi/lib/utils-D41C8Abf.js
|
|
14
14
|
/**
|
|
@@ -2902,7 +2902,7 @@ const dailyCommand = define({
|
|
|
2902
2902
|
if (dailyData.length === 0) {
|
|
2903
2903
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
2904
2904
|
else logger.warn("No Claude usage data found.");
|
|
2905
|
-
|
|
2905
|
+
process$1.exit(0);
|
|
2906
2906
|
}
|
|
2907
2907
|
const totals = calculateTotals(dailyData);
|
|
2908
2908
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3055,7 +3055,7 @@ const monthlyCommand = define({
|
|
|
3055
3055
|
};
|
|
3056
3056
|
log(JSON.stringify(emptyOutput, null, 2));
|
|
3057
3057
|
} else logger.warn("No Claude usage data found.");
|
|
3058
|
-
|
|
3058
|
+
process$1.exit(0);
|
|
3059
3059
|
}
|
|
3060
3060
|
const totals = calculateTotals(monthlyData);
|
|
3061
3061
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3161,7 +3161,7 @@ const sessionCommand = define({
|
|
|
3161
3161
|
if (sessionData.length === 0) {
|
|
3162
3162
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
3163
3163
|
else logger.warn("No Claude usage data found.");
|
|
3164
|
-
|
|
3164
|
+
process$1.exit(0);
|
|
3165
3165
|
}
|
|
3166
3166
|
const totals = calculateTotals(sessionData);
|
|
3167
3167
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3264,7 +3264,7 @@ subCommands.set("monthly", monthlyCommand);
|
|
|
3264
3264
|
subCommands.set("session", sessionCommand);
|
|
3265
3265
|
subCommands.set("mcp", mcpCommand);
|
|
3266
3266
|
const mainCommand = dailyCommand;
|
|
3267
|
-
await cli(
|
|
3267
|
+
await cli(process$1.argv.slice(2), mainCommand, {
|
|
3268
3268
|
name,
|
|
3269
3269
|
version,
|
|
3270
3270
|
description,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sep } from "node:path";
|
|
2
2
|
import { formatWithOptions } from "node:util";
|
|
3
|
-
import
|
|
3
|
+
import process$1 from "node:process";
|
|
4
4
|
import * as tty from "node:tty";
|
|
5
5
|
|
|
6
6
|
//#region node_modules/consola/dist/core.mjs
|
|
@@ -859,9 +859,9 @@ function stringWidth$1(string, options = {}) {
|
|
|
859
859
|
return width;
|
|
860
860
|
}
|
|
861
861
|
function isUnicodeSupported() {
|
|
862
|
-
const { env: env$1 } =
|
|
862
|
+
const { env: env$1 } = process$1;
|
|
863
863
|
const { TERM, TERM_PROGRAM } = env$1;
|
|
864
|
-
if (
|
|
864
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
865
865
|
return Boolean(env$1.WT_SESSION) || Boolean(env$1.TERMINUS_SUBLIME) || env$1.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env$1.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
866
866
|
}
|
|
867
867
|
const TYPE_COLOR_MAP = {
|
|
@@ -949,7 +949,7 @@ function createConsola$1(options = {}) {
|
|
|
949
949
|
defaults: { level },
|
|
950
950
|
stdout: process.stdout,
|
|
951
951
|
stderr: process.stderr,
|
|
952
|
-
prompt: (...args) => import("./prompt-
|
|
952
|
+
prompt: (...args) => import("./prompt-CUbwSrjo.js").then((m) => m.prompt(...args)),
|
|
953
953
|
reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
954
954
|
...options
|
|
955
955
|
});
|
|
@@ -965,7 +965,7 @@ const consola = createConsola$1();
|
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region package.json
|
|
967
967
|
var name = "ccusage";
|
|
968
|
-
var version = "0.
|
|
968
|
+
var version = "0.8.0";
|
|
969
969
|
var description = "Usage analysis tool for Claude Code";
|
|
970
970
|
|
|
971
971
|
//#endregion
|
package/dist/logger.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { __commonJS, __require, __toESM, getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-
|
|
1
|
+
import { __commonJS, __require, __toESM, getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-Bz6Vemxw.js";
|
|
2
2
|
import { description, literal, object, optional, pipe, regex, string, union } from "./dist-BEQ1tJCL.js";
|
|
3
|
-
import { name, version } from "./logger-
|
|
3
|
+
import { name, version } from "./logger-DN-RT9jL.js";
|
|
4
4
|
import { anyType, arrayType, booleanType, discriminatedUnionType, enumType, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./types-DS8M8QF_.js";
|
|
5
5
|
import { toJsonSchema } from "./index-CISmcbXk-x9eVmhGM.js";
|
|
6
|
-
import
|
|
6
|
+
import process$1 from "node:process";
|
|
7
7
|
import { EventEmitter } from "events";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { URL as URL$1 } from "url";
|
|
@@ -1191,7 +1191,7 @@ function serializeMessage(message) {
|
|
|
1191
1191
|
* This transport is only available in Node.js environments.
|
|
1192
1192
|
*/
|
|
1193
1193
|
var StdioServerTransport = class {
|
|
1194
|
-
constructor(_stdin =
|
|
1194
|
+
constructor(_stdin = process$1.stdin, _stdout = process$1.stdout) {
|
|
1195
1195
|
this._stdin = _stdin;
|
|
1196
1196
|
this._stdout = _stdout;
|
|
1197
1197
|
this._readBuffer = new ReadBuffer();
|
package/dist/mcp.d.ts
CHANGED
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./data-loader-
|
|
1
|
+
import "./data-loader-Bz6Vemxw.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
5
|
-
import { createMcpServer } from "./mcp-
|
|
3
|
+
import "./logger-DN-RT9jL.js";
|
|
4
|
+
import "./pricing-fetcher-DMNBE90M.js";
|
|
5
|
+
import { createMcpServer } from "./mcp-DZXbfmbs.js";
|
|
6
6
|
import "./types-DS8M8QF_.js";
|
|
7
7
|
import "./index-CISmcbXk-x9eVmhGM.js";
|
|
8
8
|
|
package/dist/pricing-fetcher.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
2
2
|
import { WriteStream } from "node:tty";
|
|
3
3
|
import f from "node:readline";
|
|
4
4
|
|
|
@@ -650,7 +650,7 @@ var PD = class extends x {
|
|
|
650
650
|
}
|
|
651
651
|
};
|
|
652
652
|
function ce() {
|
|
653
|
-
return
|
|
653
|
+
return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
654
654
|
}
|
|
655
655
|
const V = ce(), u = (t, n) => V ? t : n, le = u("❯", ">"), L = u("■", "x"), W = u("▲", "x"), C = u("✔", "√"), o = u(""), d = u(""), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), w = (t) => {
|
|
656
656
|
switch (t) {
|