ccusage 0.6.0 → 0.6.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.
- package/README.md +29 -22
- package/dist/calculate-cost.d.ts +11 -8
- package/dist/{core-BgFXUe_h.js → core-B0ovMhJe.js} +4 -4
- package/dist/data-loader-B0tJZeHI.d.ts +144 -0
- package/dist/{data-loader-CDv0IYZx.js → data-loader-BfnzLKGl.js} +503 -131
- package/dist/data-loader.d.ts +2 -4
- package/dist/data-loader.js +4 -4
- package/dist/{debug-Dk36WQTw.js → debug-Bf6GUNZE.js} +45 -40
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +5 -5
- package/dist/{dist-FwNhpFrW.js → dist-BEQ1tJCL.js} +1 -109
- package/dist/{dist-C_i5I27w.js → dist-DAarI-SJ.js} +5 -5
- package/dist/{effect-WSjEuzC9-BsxP11fz.js → effect-WSjEuzC9-ChJ5OQQf.js} +1 -1
- package/dist/{esm-vjyZjnpZ.js → esm-Dqsc1zmX.js} +1 -1
- package/dist/{index-CISmcbXk-BotItq1T.js → index-CISmcbXk-x9eVmhGM.js} +5 -5
- package/dist/index.js +108 -42
- package/dist/{logger-DhDyJEC5.js → logger-DixU80sg.js} +17 -17
- package/dist/logger.js +1 -1
- package/dist/{mcp-G-TIOcuj.js → mcp-nXxiNurt.js} +93 -78
- package/dist/mcp.d.ts +2 -4
- package/dist/mcp.js +7 -8
- package/dist/pricing-fetcher-BY3-ryVq.js +79 -0
- package/dist/{index-BurjgCfW.d.ts → pricing-fetcher-Dq-OLBp4.d.ts} +31 -249
- package/dist/pricing-fetcher.d.ts +2 -3
- package/dist/pricing-fetcher.js +4 -4
- package/dist/{prompt-IToGuko2.js → prompt-DljZqwMa.js} +4 -4
- package/dist/{sury-DmrZ3_Oj-DhGOjCNc.js → sury-DmrZ3_Oj-l0qqtY-f.js} +1 -1
- package/dist/{types-CFnCBr2I.js → types-DS8M8QF_.js} +4 -4
- package/dist/valibot-CQk-M5rL-BNHzwpA0.js +10 -0
- package/dist/{zod-Db63SLXj-BWdcigdx.js → zod-Db63SLXj-N1oN-yiY.js} +3 -3
- package/package.json +8 -11
- package/dist/data-loader-aUOjeZ06.d.ts +0 -67
- package/dist/pricing-fetcher-BCv1Vods.js +0 -60
- package/dist/pricing-fetcher-DygIroMj.d.ts +0 -21
- package/dist/shared-args-BtMSktLn.js +0 -68
- package/dist/shared-args.d.ts +0 -108
- package/dist/shared-args.js +0 -8
- package/dist/types-BcXIBMQk.js +0 -42
- package/dist/types-y1JQzaKZ.d.ts +0 -81
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -4
- package/dist/utils-C7kg8MXN.js +0 -10
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +0 -3
- package/dist/valibot-CQk-M5rL-Cq5E7F3g.js +0 -10
- /package/dist/{arktype-C-GObzDh-Dj1DVoqC.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./pricing-fetcher-
|
|
3
|
-
import "./types-y1JQzaKZ.js";
|
|
4
|
-
import { DailyUsage, DailyUsageSchema$1 as DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema$1 as MonthlyUsageSchema, SessionUsage, SessionUsageSchema$1 as SessionUsageSchema, UsageData, UsageDataSchema$1 as UsageDataSchema, calculateCostForEntry$1 as calculateCostForEntry, formatDate$1 as formatDate, getDefaultClaudePath$1 as getDefaultClaudePath, loadDailyUsageData$1 as loadDailyUsageData, loadMonthlyUsageData$1 as loadMonthlyUsageData, loadSessionData$1 as loadSessionData } from "./data-loader-aUOjeZ06.js";
|
|
1
|
+
import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-B0tJZeHI.js";
|
|
2
|
+
import "./pricing-fetcher-Dq-OLBp4.js";
|
|
5
3
|
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DailyUsageSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-
|
|
2
|
-
import "./dist-
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
1
|
+
import { DailyUsageSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-BfnzLKGl.js";
|
|
2
|
+
import "./dist-BEQ1tJCL.js";
|
|
3
|
+
import "./logger-DixU80sg.js";
|
|
4
|
+
import "./pricing-fetcher-BY3-ryVq.js";
|
|
5
5
|
|
|
6
6
|
export { DailyUsageSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { UsageDataSchema, glob } from "./data-loader-
|
|
2
|
-
import { safeParse } from "./dist-
|
|
3
|
-
import { logger } from "./logger-
|
|
4
|
-
import {
|
|
1
|
+
import { UsageDataSchema, __toESM, glob, require_usingCtx } from "./data-loader-BfnzLKGl.js";
|
|
2
|
+
import { safeParse } from "./dist-BEQ1tJCL.js";
|
|
3
|
+
import { logger } from "./logger-DixU80sg.js";
|
|
4
|
+
import { PricingFetcher } from "./pricing-fetcher-BY3-ryVq.js";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/debug.ts
|
|
10
|
+
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
10
11
|
const MATCH_THRESHOLD_PERCENT = .1;
|
|
11
12
|
async function detectMismatches(claudePath) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
stats.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const calculatedCost = calculateCostFromTokens(data.message.usage,
|
|
13
|
+
try {
|
|
14
|
+
var _usingCtx = (0, import_usingCtx.default)();
|
|
15
|
+
const claudeDir = claudePath ?? path.join(homedir(), ".claude", "projects");
|
|
16
|
+
const files = await glob(["**/*.jsonl"], {
|
|
17
|
+
cwd: claudeDir,
|
|
18
|
+
absolute: true
|
|
19
|
+
});
|
|
20
|
+
const fetcher = _usingCtx.u(new PricingFetcher());
|
|
21
|
+
const stats = {
|
|
22
|
+
totalEntries: 0,
|
|
23
|
+
entriesWithBoth: 0,
|
|
24
|
+
matches: 0,
|
|
25
|
+
mismatches: 0,
|
|
26
|
+
discrepancies: [],
|
|
27
|
+
modelStats: /* @__PURE__ */ new Map(),
|
|
28
|
+
versionStats: /* @__PURE__ */ new Map()
|
|
29
|
+
};
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const content = await readFile(file, "utf-8");
|
|
32
|
+
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
33
|
+
for (const line of lines) try {
|
|
34
|
+
const parsed = JSON.parse(line);
|
|
35
|
+
const result = safeParse(UsageDataSchema, parsed);
|
|
36
|
+
if (!result.success) continue;
|
|
37
|
+
const data = result.output;
|
|
38
|
+
stats.totalEntries++;
|
|
39
|
+
if (data.costUSD !== void 0 && data.message.model != null && data.message.model !== "<synthetic>") {
|
|
40
|
+
stats.entriesWithBoth++;
|
|
41
|
+
const model = data.message.model;
|
|
42
|
+
const calculatedCost = await fetcher.calculateCostFromTokens(data.message.usage, model);
|
|
42
43
|
const difference = Math.abs(data.costUSD - calculatedCost);
|
|
43
44
|
const percentDiff = data.costUSD > 0 ? difference / data.costUSD * 100 : 0;
|
|
44
|
-
const modelStat = stats.modelStats.get(model)
|
|
45
|
+
const modelStat = stats.modelStats.get(model) ?? {
|
|
45
46
|
total: 0,
|
|
46
47
|
matches: 0,
|
|
47
48
|
mismatches: 0,
|
|
48
49
|
avgPercentDiff: 0
|
|
49
50
|
};
|
|
50
51
|
modelStat.total++;
|
|
51
|
-
if (data.version) {
|
|
52
|
-
const versionStat = stats.versionStats.get(data.version)
|
|
52
|
+
if (data.version != null) {
|
|
53
|
+
const versionStat = stats.versionStats.get(data.version) ?? {
|
|
53
54
|
total: 0,
|
|
54
55
|
matches: 0,
|
|
55
56
|
mismatches: 0,
|
|
@@ -81,10 +82,14 @@ async function detectMismatches(claudePath) {
|
|
|
81
82
|
modelStat.avgPercentDiff = (modelStat.avgPercentDiff * (modelStat.total - 1) + percentDiff) / modelStat.total;
|
|
82
83
|
stats.modelStats.set(model, modelStat);
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
return stats;
|
|
88
|
+
} catch (_) {
|
|
89
|
+
_usingCtx.e = _;
|
|
90
|
+
} finally {
|
|
91
|
+
_usingCtx.d();
|
|
86
92
|
}
|
|
87
|
-
return stats;
|
|
88
93
|
}
|
|
89
94
|
function printMismatchReport(stats, sampleCount = 5) {
|
|
90
95
|
if (stats.entriesWithBoth === 0) {
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/debug.d.ts
|
|
2
|
-
|
|
2
|
+
type Discrepancy = {
|
|
3
3
|
file: string;
|
|
4
4
|
timestamp: string;
|
|
5
5
|
model: string;
|
|
@@ -13,8 +13,8 @@ interface Discrepancy {
|
|
|
13
13
|
cache_creation_input_tokens?: number;
|
|
14
14
|
cache_read_input_tokens?: number;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
17
|
-
|
|
16
|
+
};
|
|
17
|
+
type MismatchStats = {
|
|
18
18
|
totalEntries: number;
|
|
19
19
|
entriesWithBoth: number;
|
|
20
20
|
matches: number;
|
|
@@ -32,7 +32,7 @@ interface MismatchStats {
|
|
|
32
32
|
mismatches: number;
|
|
33
33
|
avgPercentDiff: number;
|
|
34
34
|
}>;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
declare function detectMismatches(claudePath?: string): Promise<MismatchStats>;
|
|
37
37
|
declare function printMismatchReport(stats: MismatchStats, sampleCount?: number): void;
|
|
38
38
|
//#endregion
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./data-loader-
|
|
2
|
-
import "./dist-
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
1
|
+
import "./data-loader-BfnzLKGl.js";
|
|
2
|
+
import "./dist-BEQ1tJCL.js";
|
|
3
|
+
import "./logger-DixU80sg.js";
|
|
4
|
+
import "./pricing-fetcher-BY3-ryVq.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-Bf6GUNZE.js";
|
|
6
6
|
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
|
@@ -68,27 +68,11 @@ function _getStandardProps(context) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
/* @__NO_SIDE_EFFECTS__ */
|
|
71
|
-
function _isValidObjectKey(object2, key) {
|
|
72
|
-
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
73
|
-
}
|
|
74
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
75
71
|
function _joinExpects(values2, separator) {
|
|
76
72
|
const list = [...new Set(values2)];
|
|
77
73
|
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
78
74
|
return list[0] ?? "never";
|
|
79
75
|
}
|
|
80
|
-
var ValiError = class extends Error {
|
|
81
|
-
/**
|
|
82
|
-
* Creates a Valibot error with useful information.
|
|
83
|
-
*
|
|
84
|
-
* @param issues The error issues.
|
|
85
|
-
*/
|
|
86
|
-
constructor(issues) {
|
|
87
|
-
super(issues[0].message);
|
|
88
|
-
this.name = "ValiError";
|
|
89
|
-
this.issues = issues;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
76
|
/* @__NO_SIDE_EFFECTS__ */
|
|
93
77
|
function description(description_) {
|
|
94
78
|
return {
|
|
@@ -171,25 +155,6 @@ function array(item, message2) {
|
|
|
171
155
|
};
|
|
172
156
|
}
|
|
173
157
|
/* @__NO_SIDE_EFFECTS__ */
|
|
174
|
-
function boolean(message2) {
|
|
175
|
-
return {
|
|
176
|
-
kind: "schema",
|
|
177
|
-
type: "boolean",
|
|
178
|
-
reference: boolean,
|
|
179
|
-
expects: "boolean",
|
|
180
|
-
async: false,
|
|
181
|
-
message: message2,
|
|
182
|
-
get "~standard"() {
|
|
183
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
184
|
-
},
|
|
185
|
-
"~run"(dataset, config2) {
|
|
186
|
-
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
187
|
-
else _addIssue(this, "type", dataset, config2);
|
|
188
|
-
return dataset;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
193
158
|
function literal(literal_, message2) {
|
|
194
159
|
return {
|
|
195
160
|
kind: "schema",
|
|
@@ -319,74 +284,6 @@ function optional(wrapped, default_) {
|
|
|
319
284
|
};
|
|
320
285
|
}
|
|
321
286
|
/* @__NO_SIDE_EFFECTS__ */
|
|
322
|
-
function record(key, value2, message2) {
|
|
323
|
-
return {
|
|
324
|
-
kind: "schema",
|
|
325
|
-
type: "record",
|
|
326
|
-
reference: record,
|
|
327
|
-
expects: "Object",
|
|
328
|
-
async: false,
|
|
329
|
-
key,
|
|
330
|
-
value: value2,
|
|
331
|
-
message: message2,
|
|
332
|
-
get "~standard"() {
|
|
333
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
334
|
-
},
|
|
335
|
-
"~run"(dataset, config2) {
|
|
336
|
-
const input = dataset.value;
|
|
337
|
-
if (input && typeof input === "object") {
|
|
338
|
-
dataset.typed = true;
|
|
339
|
-
dataset.value = {};
|
|
340
|
-
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
341
|
-
const entryValue = input[entryKey];
|
|
342
|
-
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
343
|
-
if (keyDataset.issues) {
|
|
344
|
-
const pathItem = {
|
|
345
|
-
type: "object",
|
|
346
|
-
origin: "key",
|
|
347
|
-
input,
|
|
348
|
-
key: entryKey,
|
|
349
|
-
value: entryValue
|
|
350
|
-
};
|
|
351
|
-
for (const issue of keyDataset.issues) {
|
|
352
|
-
issue.path = [pathItem];
|
|
353
|
-
dataset.issues?.push(issue);
|
|
354
|
-
}
|
|
355
|
-
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
356
|
-
if (config2.abortEarly) {
|
|
357
|
-
dataset.typed = false;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
const valueDataset = this.value["~run"]({ value: entryValue }, config2);
|
|
362
|
-
if (valueDataset.issues) {
|
|
363
|
-
const pathItem = {
|
|
364
|
-
type: "object",
|
|
365
|
-
origin: "value",
|
|
366
|
-
input,
|
|
367
|
-
key: entryKey,
|
|
368
|
-
value: entryValue
|
|
369
|
-
};
|
|
370
|
-
for (const issue of valueDataset.issues) {
|
|
371
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
372
|
-
else issue.path = [pathItem];
|
|
373
|
-
dataset.issues?.push(issue);
|
|
374
|
-
}
|
|
375
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
376
|
-
if (config2.abortEarly) {
|
|
377
|
-
dataset.typed = false;
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
382
|
-
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
383
|
-
}
|
|
384
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
385
|
-
return dataset;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
390
287
|
function string(message2) {
|
|
391
288
|
return {
|
|
392
289
|
kind: "schema",
|
|
@@ -451,11 +348,6 @@ function union(options, message2) {
|
|
|
451
348
|
}
|
|
452
349
|
};
|
|
453
350
|
}
|
|
454
|
-
function parse(schema, input, config2) {
|
|
455
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
456
|
-
if (dataset.issues) throw new ValiError(dataset.issues);
|
|
457
|
-
return dataset.value;
|
|
458
|
-
}
|
|
459
351
|
/* @__NO_SIDE_EFFECTS__ */
|
|
460
352
|
function pipe(...pipe2) {
|
|
461
353
|
return {
|
|
@@ -488,4 +380,4 @@ function safeParse(schema, input, config2) {
|
|
|
488
380
|
}
|
|
489
381
|
|
|
490
382
|
//#endregion
|
|
491
|
-
export { array,
|
|
383
|
+
export { array, description, getDefault, literal, number, object, optional, pipe, regex, safeParse, string, union };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDefault } from "./dist-
|
|
1
|
+
import { getDefault } from "./dist-BEQ1tJCL.js";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/@valibot/to-json-schema/dist/index.js
|
|
4
4
|
/**
|
|
@@ -434,8 +434,8 @@ function getGlobalDefs() {
|
|
|
434
434
|
function toJsonSchema(schema, config) {
|
|
435
435
|
const context = {
|
|
436
436
|
definitions: {},
|
|
437
|
-
referenceMap: new Map(),
|
|
438
|
-
getterMap: new Map()
|
|
437
|
+
referenceMap: /* @__PURE__ */ new Map(),
|
|
438
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
439
439
|
};
|
|
440
440
|
const definitions = config?.definitions ?? getGlobalDefs();
|
|
441
441
|
if (definitions) {
|
|
@@ -457,8 +457,8 @@ function toJsonSchema(schema, config) {
|
|
|
457
457
|
function toJsonSchemaDefs(definitions, config) {
|
|
458
458
|
const context = {
|
|
459
459
|
definitions: {},
|
|
460
|
-
referenceMap: new Map(),
|
|
461
|
-
getterMap: new Map()
|
|
460
|
+
referenceMap: /* @__PURE__ */ new Map(),
|
|
461
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
462
462
|
};
|
|
463
463
|
for (const key in definitions) context.referenceMap.set(definitions[key], key);
|
|
464
464
|
for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodFirstPartyTypeKind, ZodOptional } from "./types-
|
|
1
|
+
import { ZodFirstPartyTypeKind, ZodOptional } from "./types-DS8M8QF_.js";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
4
4
|
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
@@ -9,11 +9,11 @@ const tryImport = async (result, name) => {
|
|
|
9
9
|
};
|
|
10
10
|
const getToJsonSchemaFn = async (vendor) => {
|
|
11
11
|
switch (vendor) {
|
|
12
|
-
case "arktype": return import("./arktype-C-GObzDh-
|
|
13
|
-
case "effect": return import("./effect-WSjEuzC9-
|
|
14
|
-
case "sury": return import("./sury-DmrZ3_Oj-
|
|
15
|
-
case "valibot": return import("./valibot-CQk-M5rL-
|
|
16
|
-
case "zod": return import("./zod-Db63SLXj-
|
|
12
|
+
case "arktype": return import("./arktype-C-GObzDh-Bx7Fdrqj.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
13
|
+
case "effect": return import("./effect-WSjEuzC9-ChJ5OQQf.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
14
|
+
case "sury": return import("./sury-DmrZ3_Oj-l0qqtY-f.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
15
|
+
case "valibot": return import("./valibot-CQk-M5rL-BNHzwpA0.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
16
|
+
case "zod": return import("./zod-Db63SLXj-N1oN-yiY.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
17
17
|
default: throw new Error(`xsschema: Unsupported schema vendor "${vendor}". see https://xsai.js.org/docs/packages-top/xsschema#unsupported-schema-vendor`);
|
|
18
18
|
}
|
|
19
19
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { __commonJS, __require, __toESM, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-
|
|
2
|
+
import { __commonJS, __require, __toESM, formatCurrency, formatNumber, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-BfnzLKGl.js";
|
|
3
3
|
import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-2IwHSzmi.js";
|
|
4
|
-
import "./dist-
|
|
5
|
-
import { description, log, logger, name, version } from "./logger-
|
|
6
|
-
import "./pricing-fetcher-
|
|
7
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
8
|
-
import "./
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import "
|
|
12
|
-
import { createMcpServer } from "./mcp-G-TIOcuj.js";
|
|
13
|
-
import "./index-CISmcbXk-BotItq1T.js";
|
|
14
|
-
import process$1 from "node:process";
|
|
4
|
+
import { safeParse } from "./dist-BEQ1tJCL.js";
|
|
5
|
+
import { description, log, logger, name, version } from "./logger-DixU80sg.js";
|
|
6
|
+
import "./pricing-fetcher-BY3-ryVq.js";
|
|
7
|
+
import { detectMismatches, printMismatchReport } from "./debug-Bf6GUNZE.js";
|
|
8
|
+
import { CostModes, SortOrders, createMcpServer, dateSchema } from "./mcp-nXxiNurt.js";
|
|
9
|
+
import "./types-DS8M8QF_.js";
|
|
10
|
+
import "./index-CISmcbXk-x9eVmhGM.js";
|
|
11
|
+
import g$1 from "node:process";
|
|
15
12
|
|
|
16
|
-
//#region node_modules/gunshi/lib/utils-
|
|
13
|
+
//#region node_modules/gunshi/lib/utils-D41C8Abf.js
|
|
17
14
|
/**
|
|
18
15
|
* The default locale string, which format is BCP 47 language tag.
|
|
19
16
|
*/
|
|
@@ -84,14 +81,6 @@ async function resolveLazyCommand(cmd, name$1, needRunResolving = false) {
|
|
|
84
81
|
function resolveBuiltInKey(key) {
|
|
85
82
|
return `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
|
|
86
83
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Convert a camelCase string to kebab-case
|
|
89
|
-
* @param str The string to convert
|
|
90
|
-
* @returns The kebab-case version of the string
|
|
91
|
-
*/
|
|
92
|
-
function kebabnize$1(str) {
|
|
93
|
-
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
94
|
-
}
|
|
95
84
|
function resolveArgKey(key) {
|
|
96
85
|
return `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
|
|
97
86
|
}
|
|
@@ -120,7 +109,7 @@ function deepFreeze(obj) {
|
|
|
120
109
|
}
|
|
121
110
|
|
|
122
111
|
//#endregion
|
|
123
|
-
//#region node_modules/gunshi/lib/context-
|
|
112
|
+
//#region node_modules/gunshi/lib/context-D_EmfRNA.js
|
|
124
113
|
var COMMAND = "COMMAND";
|
|
125
114
|
var COMMANDS = "COMMANDS";
|
|
126
115
|
var SUBCOMMAND = "SUBCOMMAND";
|
|
@@ -153,7 +142,7 @@ function createTranslationAdapter(options) {
|
|
|
153
142
|
return new DefaultTranslation(options);
|
|
154
143
|
}
|
|
155
144
|
var DefaultTranslation = class {
|
|
156
|
-
#resources = new Map();
|
|
145
|
+
#resources = /* @__PURE__ */ new Map();
|
|
157
146
|
#options;
|
|
158
147
|
constructor(options) {
|
|
159
148
|
this.#options = options;
|
|
@@ -205,7 +194,7 @@ async function createCommandContext({ args, values, positionals, rest, argv: arg
|
|
|
205
194
|
locale: localeStr,
|
|
206
195
|
fallbackLocale: DEFAULT_LOCALE
|
|
207
196
|
});
|
|
208
|
-
const localeResources = new Map();
|
|
197
|
+
const localeResources = /* @__PURE__ */ new Map();
|
|
209
198
|
let builtInLoadedResources;
|
|
210
199
|
/**
|
|
211
200
|
* load the built-in locale resources
|
|
@@ -309,7 +298,24 @@ function define(definition) {
|
|
|
309
298
|
}
|
|
310
299
|
|
|
311
300
|
//#endregion
|
|
312
|
-
//#region node_modules/
|
|
301
|
+
//#region node_modules/args-tokens/lib/utils-N7UlhLbz.js
|
|
302
|
+
/**
|
|
303
|
+
* Entry point of utils.
|
|
304
|
+
*
|
|
305
|
+
* Note that this entry point is used by gunshi to import utility functions.
|
|
306
|
+
*
|
|
307
|
+
* @module
|
|
308
|
+
*/
|
|
309
|
+
/**
|
|
310
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
311
|
+
* @license MIT
|
|
312
|
+
*/
|
|
313
|
+
function kebabnize(str) {
|
|
314
|
+
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region node_modules/gunshi/lib/renderer-BzRfaLdJ.js
|
|
313
319
|
/**
|
|
314
320
|
* Render the header.
|
|
315
321
|
* @param ctx A {@link CommandContext | command context}
|
|
@@ -494,7 +500,7 @@ function generateOptionsSymbols(ctx) {
|
|
|
494
500
|
return hasOptionalArgs(ctx) ? hasAllDefaultOptions(ctx) ? `[${ctx.translate(resolveBuiltInKey("OPTIONS"))}]` : `<${ctx.translate(resolveBuiltInKey("OPTIONS"))}>` : "";
|
|
495
501
|
}
|
|
496
502
|
function makeShortLongOptionPair(schema, name$1, toKebab) {
|
|
497
|
-
const displayName = toKebab || schema.toKebab ? kebabnize
|
|
503
|
+
const displayName = toKebab || schema.toKebab ? kebabnize(name$1) : name$1;
|
|
498
504
|
let key = `--${displayName}`;
|
|
499
505
|
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
500
506
|
return key;
|
|
@@ -509,12 +515,12 @@ function getOptionalArgsPairs(ctx) {
|
|
|
509
515
|
if (schema.type === "positional") return acc;
|
|
510
516
|
let key = makeShortLongOptionPair(schema, name$1, ctx.toKebab);
|
|
511
517
|
if (schema.type !== "boolean") {
|
|
512
|
-
const displayName = ctx.toKebab || schema.toKebab ? kebabnize
|
|
518
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name$1) : name$1;
|
|
513
519
|
key = schema.default ? `${key} [${displayName}]` : `${key} <${displayName}>`;
|
|
514
520
|
}
|
|
515
521
|
acc[name$1] = key;
|
|
516
522
|
if (schema.type === "boolean" && schema.negatable && !COMMON_ARGS_KEYS.includes(name$1)) {
|
|
517
|
-
const displayName = ctx.toKebab || schema.toKebab ? kebabnize
|
|
523
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name$1) : name$1;
|
|
518
524
|
acc[`no-${name$1}`] = `--no-${displayName}`;
|
|
519
525
|
}
|
|
520
526
|
return acc;
|
|
@@ -782,11 +788,8 @@ function hasOptionValue(value) {
|
|
|
782
788
|
}
|
|
783
789
|
|
|
784
790
|
//#endregion
|
|
785
|
-
//#region node_modules/args-tokens/lib/resolver-
|
|
791
|
+
//#region node_modules/args-tokens/lib/resolver-Q4k2fgTW.js
|
|
786
792
|
const SKIP_POSITIONAL_DEFAULT = -1;
|
|
787
|
-
function kebabnize(str) {
|
|
788
|
-
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
789
|
-
}
|
|
790
793
|
/**
|
|
791
794
|
* Resolve command line arguments.
|
|
792
795
|
* @param args - An arguments that contains {@link ArgSchema | arguments schema}.
|
|
@@ -998,7 +1001,7 @@ function createTypeError(option, schema) {
|
|
|
998
1001
|
}
|
|
999
1002
|
|
|
1000
1003
|
//#endregion
|
|
1001
|
-
//#region node_modules/gunshi/lib/cli-
|
|
1004
|
+
//#region node_modules/gunshi/lib/cli-DVGNVw3h.js
|
|
1002
1005
|
/**
|
|
1003
1006
|
* Run the command.
|
|
1004
1007
|
* @param args Command line arguments
|
|
@@ -1225,7 +1228,7 @@ var require_string_width = __commonJS({ "node_modules/string-width/index.js"(exp
|
|
|
1225
1228
|
|
|
1226
1229
|
//#endregion
|
|
1227
1230
|
//#region node_modules/cli-table3/src/utils.js
|
|
1228
|
-
var require_utils
|
|
1231
|
+
var require_utils = __commonJS({ "node_modules/cli-table3/src/utils.js"(exports, module) {
|
|
1229
1232
|
const stringWidth = require_string_width();
|
|
1230
1233
|
function codeRegex(capture) {
|
|
1231
1234
|
return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g;
|
|
@@ -2189,7 +2192,7 @@ var require_safe = __commonJS({ "node_modules/@colors/colors/safe.js"(exports, m
|
|
|
2189
2192
|
//#region node_modules/cli-table3/src/cell.js
|
|
2190
2193
|
var require_cell = __commonJS({ "node_modules/cli-table3/src/cell.js"(exports, module) {
|
|
2191
2194
|
const { info, debug: debug$2 } = require_debug$1();
|
|
2192
|
-
const utils$1 = require_utils
|
|
2195
|
+
const utils$1 = require_utils();
|
|
2193
2196
|
var Cell$1 = class Cell$1 {
|
|
2194
2197
|
/**
|
|
2195
2198
|
* A representation of a cell within the table.
|
|
@@ -2727,7 +2730,7 @@ var require_layout_manager = __commonJS({ "node_modules/cli-table3/src/layout-ma
|
|
|
2727
2730
|
//#region node_modules/cli-table3/src/table.js
|
|
2728
2731
|
var require_table = __commonJS({ "node_modules/cli-table3/src/table.js"(exports, module) {
|
|
2729
2732
|
const debug = require_debug$1();
|
|
2730
|
-
const utils = require_utils
|
|
2733
|
+
const utils = require_utils();
|
|
2731
2734
|
const tableLayout = require_layout_manager();
|
|
2732
2735
|
var Table$3 = class extends Array {
|
|
2733
2736
|
constructor(opts) {
|
|
@@ -2879,6 +2882,69 @@ var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(ex
|
|
|
2879
2882
|
module.exports.createColors = createColors;
|
|
2880
2883
|
} });
|
|
2881
2884
|
|
|
2885
|
+
//#endregion
|
|
2886
|
+
//#region src/shared-args.internal.ts
|
|
2887
|
+
function parseDateArg(value) {
|
|
2888
|
+
const result = safeParse(dateSchema, value);
|
|
2889
|
+
if (!result.success) throw new TypeError(result.issues[0].message);
|
|
2890
|
+
return result.output;
|
|
2891
|
+
}
|
|
2892
|
+
const sharedArgs = {
|
|
2893
|
+
since: {
|
|
2894
|
+
type: "custom",
|
|
2895
|
+
short: "s",
|
|
2896
|
+
description: "Filter from date (YYYYMMDD format)",
|
|
2897
|
+
parse: parseDateArg
|
|
2898
|
+
},
|
|
2899
|
+
until: {
|
|
2900
|
+
type: "custom",
|
|
2901
|
+
short: "u",
|
|
2902
|
+
description: "Filter until date (YYYYMMDD format)",
|
|
2903
|
+
parse: parseDateArg
|
|
2904
|
+
},
|
|
2905
|
+
path: {
|
|
2906
|
+
type: "string",
|
|
2907
|
+
short: "p",
|
|
2908
|
+
description: "Custom path to Claude data directory",
|
|
2909
|
+
default: getDefaultClaudePath()
|
|
2910
|
+
},
|
|
2911
|
+
json: {
|
|
2912
|
+
type: "boolean",
|
|
2913
|
+
short: "j",
|
|
2914
|
+
description: "Output in JSON format",
|
|
2915
|
+
default: false
|
|
2916
|
+
},
|
|
2917
|
+
mode: {
|
|
2918
|
+
type: "enum",
|
|
2919
|
+
short: "m",
|
|
2920
|
+
description: "Cost calculation mode: auto (use costUSD if exists, otherwise calculate), calculate (always calculate), display (always use costUSD)",
|
|
2921
|
+
default: "auto",
|
|
2922
|
+
choices: CostModes
|
|
2923
|
+
},
|
|
2924
|
+
debug: {
|
|
2925
|
+
type: "boolean",
|
|
2926
|
+
short: "d",
|
|
2927
|
+
description: "Show pricing mismatch information for debugging",
|
|
2928
|
+
default: false
|
|
2929
|
+
},
|
|
2930
|
+
debugSamples: {
|
|
2931
|
+
type: "number",
|
|
2932
|
+
description: "Number of sample discrepancies to show in debug output (default: 5)",
|
|
2933
|
+
default: 5
|
|
2934
|
+
},
|
|
2935
|
+
order: {
|
|
2936
|
+
type: "enum",
|
|
2937
|
+
short: "o",
|
|
2938
|
+
description: "Sort order: desc (newest first) or asc (oldest first)",
|
|
2939
|
+
default: "asc",
|
|
2940
|
+
choices: SortOrders
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
const sharedCommandConfig = {
|
|
2944
|
+
args: sharedArgs,
|
|
2945
|
+
toKebab: true
|
|
2946
|
+
};
|
|
2947
|
+
|
|
2882
2948
|
//#endregion
|
|
2883
2949
|
//#region src/commands/daily.ts
|
|
2884
2950
|
var import_cli_table3$2 = __toESM(require_cli_table3(), 1);
|
|
@@ -2899,7 +2965,7 @@ const dailyCommand = define({
|
|
|
2899
2965
|
if (dailyData.length === 0) {
|
|
2900
2966
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
2901
2967
|
else logger.warn("No Claude usage data found.");
|
|
2902
|
-
|
|
2968
|
+
g$1.exit(0);
|
|
2903
2969
|
}
|
|
2904
2970
|
const totals = calculateTotals(dailyData);
|
|
2905
2971
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3003,7 +3069,7 @@ const mcpCommand = define({
|
|
|
3003
3069
|
claudePath: path,
|
|
3004
3070
|
mode
|
|
3005
3071
|
});
|
|
3006
|
-
server.start(ctx.values.type === "http" ? {
|
|
3072
|
+
await server.start(ctx.values.type === "http" ? {
|
|
3007
3073
|
transportType: "httpStream",
|
|
3008
3074
|
httpStream: { port }
|
|
3009
3075
|
} : { transportType: "stdio" });
|
|
@@ -3042,7 +3108,7 @@ const monthlyCommand = define({
|
|
|
3042
3108
|
};
|
|
3043
3109
|
log(JSON.stringify(emptyOutput, null, 2));
|
|
3044
3110
|
} else logger.warn("No Claude usage data found.");
|
|
3045
|
-
|
|
3111
|
+
g$1.exit(0);
|
|
3046
3112
|
}
|
|
3047
3113
|
const totals = calculateTotals(monthlyData);
|
|
3048
3114
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3138,7 +3204,7 @@ const sessionCommand = define({
|
|
|
3138
3204
|
if (sessionData.length === 0) {
|
|
3139
3205
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
3140
3206
|
else logger.warn("No Claude usage data found.");
|
|
3141
|
-
|
|
3207
|
+
g$1.exit(0);
|
|
3142
3208
|
}
|
|
3143
3209
|
const totals = calculateTotals(sessionData);
|
|
3144
3210
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3236,13 +3302,13 @@ const sessionCommand = define({
|
|
|
3236
3302
|
|
|
3237
3303
|
//#endregion
|
|
3238
3304
|
//#region src/commands/index.ts
|
|
3239
|
-
const subCommands = new Map();
|
|
3305
|
+
const subCommands = /* @__PURE__ */ new Map();
|
|
3240
3306
|
subCommands.set("daily", dailyCommand);
|
|
3241
3307
|
subCommands.set("monthly", monthlyCommand);
|
|
3242
3308
|
subCommands.set("session", sessionCommand);
|
|
3243
3309
|
subCommands.set("mcp", mcpCommand);
|
|
3244
3310
|
const mainCommand = dailyCommand;
|
|
3245
|
-
await cli(
|
|
3311
|
+
await cli(g$1.argv.slice(2), mainCommand, {
|
|
3246
3312
|
name,
|
|
3247
3313
|
version,
|
|
3248
3314
|
description,
|