ccusage 0.6.0 → 0.6.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/README.md +27 -19
- package/dist/calculate-cost.d.ts +11 -8
- package/dist/{core-BgFXUe_h.js → core-B0ovMhJe.js} +4 -4
- package/dist/{data-loader-CDv0IYZx.js → data-loader-DP5qBPn6.js} +112 -92
- package/dist/{data-loader-aUOjeZ06.d.ts → data-loader-VdEcqJHc.d.ts} +15 -11
- package/dist/data-loader.d.ts +2 -4
- package/dist/data-loader.js +4 -4
- package/dist/{debug-Dk36WQTw.js → debug-C_5Qx11m.js} +13 -13
- package/dist/debug.d.ts +4 -4
- package/dist/debug.js +5 -5
- package/dist/{dist-FwNhpFrW.js → dist-C0-Tf5eD.js} +1 -92
- package/dist/{dist-C_i5I27w.js → dist-LwbOR2Yw.js} +5 -5
- package/dist/{effect-WSjEuzC9-BsxP11fz.js → effect-WSjEuzC9-CJfWUy0j.js} +1 -1
- package/dist/{esm-vjyZjnpZ.js → esm-Dqsc1zmX.js} +1 -1
- package/dist/{index-CISmcbXk-BotItq1T.js → index-CISmcbXk-DCA05NUL.js} +5 -5
- package/dist/index.js +117 -42
- package/dist/{logger-DhDyJEC5.js → logger-DsQC4OvA.js} +17 -17
- package/dist/logger.js +1 -1
- package/dist/{mcp-G-TIOcuj.js → mcp-BQdv12mr.js} +82 -73
- package/dist/mcp.d.ts +2 -4
- package/dist/mcp.js +7 -8
- package/dist/{pricing-fetcher-BCv1Vods.js → pricing-fetcher-BPUgMrB_.js} +9 -9
- package/dist/{index-BurjgCfW.d.ts → pricing-fetcher-CfEgfzSr.d.ts} +19 -249
- package/dist/pricing-fetcher.d.ts +1 -2
- package/dist/pricing-fetcher.js +3 -3
- package/dist/{prompt-IToGuko2.js → prompt-DljZqwMa.js} +4 -4
- package/dist/{sury-DmrZ3_Oj-DhGOjCNc.js → sury-DmrZ3_Oj-CCL_DlTt.js} +1 -1
- package/dist/{types-CFnCBr2I.js → types-DS8M8QF_.js} +4 -4
- package/dist/{valibot-CQk-M5rL-Cq5E7F3g.js → valibot-CQk-M5rL-CkjrLVu1.js} +2 -2
- package/dist/{zod-Db63SLXj-BWdcigdx.js → zod-Db63SLXj-Dyc_OWjq.js} +3 -3
- package/package.json +8 -11
- 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/{arktype-C-GObzDh-Dj1DVoqC.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -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-DP5qBPn6.js";
|
|
2
|
+
import "./dist-C0-Tf5eD.js";
|
|
3
|
+
import "./logger-DsQC4OvA.js";
|
|
4
|
+
import "./pricing-fetcher-BPUgMrB_.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-C_5Qx11m.js";
|
|
6
6
|
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
|
@@ -68,10 +68,6 @@ 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} `)})`;
|
|
@@ -171,25 +167,6 @@ function array(item, message2) {
|
|
|
171
167
|
};
|
|
172
168
|
}
|
|
173
169
|
/* @__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
170
|
function literal(literal_, message2) {
|
|
194
171
|
return {
|
|
195
172
|
kind: "schema",
|
|
@@ -319,74 +296,6 @@ function optional(wrapped, default_) {
|
|
|
319
296
|
};
|
|
320
297
|
}
|
|
321
298
|
/* @__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
299
|
function string(message2) {
|
|
391
300
|
return {
|
|
392
301
|
kind: "schema",
|
|
@@ -488,4 +397,4 @@ function safeParse(schema, input, config2) {
|
|
|
488
397
|
}
|
|
489
398
|
|
|
490
399
|
//#endregion
|
|
491
|
-
export { array,
|
|
400
|
+
export { array, description, getDefault, literal, number, object, optional, parse, pipe, regex, safeParse, string, union };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDefault } from "./dist-
|
|
1
|
+
import { getDefault } from "./dist-C0-Tf5eD.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-CJfWUy0j.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
14
|
+
case "sury": return import("./sury-DmrZ3_Oj-CCL_DlTt.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
15
|
+
case "valibot": return import("./valibot-CQk-M5rL-CkjrLVu1.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
16
|
+
case "zod": return import("./zod-Db63SLXj-Dyc_OWjq.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, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-DP5qBPn6.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-C0-Tf5eD.js";
|
|
5
|
+
import { description, log, logger, name, version } from "./logger-DsQC4OvA.js";
|
|
6
|
+
import "./pricing-fetcher-BPUgMrB_.js";
|
|
7
|
+
import { detectMismatches, printMismatchReport } from "./debug-C_5Qx11m.js";
|
|
8
|
+
import { CostModes, SortOrders, createMcpServer, dateSchema } from "./mcp-BQdv12mr.js";
|
|
9
|
+
import "./types-DS8M8QF_.js";
|
|
10
|
+
import "./index-CISmcbXk-DCA05NUL.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,78 @@ 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
|
+
|
|
2948
|
+
//#endregion
|
|
2949
|
+
//#region src/utils.internal.ts
|
|
2950
|
+
function formatNumber(num) {
|
|
2951
|
+
return num.toLocaleString("en-US");
|
|
2952
|
+
}
|
|
2953
|
+
function formatCurrency(amount) {
|
|
2954
|
+
return `$${amount.toFixed(2)}`;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2882
2957
|
//#endregion
|
|
2883
2958
|
//#region src/commands/daily.ts
|
|
2884
2959
|
var import_cli_table3$2 = __toESM(require_cli_table3(), 1);
|
|
@@ -2899,7 +2974,7 @@ const dailyCommand = define({
|
|
|
2899
2974
|
if (dailyData.length === 0) {
|
|
2900
2975
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
2901
2976
|
else logger.warn("No Claude usage data found.");
|
|
2902
|
-
|
|
2977
|
+
g$1.exit(0);
|
|
2903
2978
|
}
|
|
2904
2979
|
const totals = calculateTotals(dailyData);
|
|
2905
2980
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3003,7 +3078,7 @@ const mcpCommand = define({
|
|
|
3003
3078
|
claudePath: path,
|
|
3004
3079
|
mode
|
|
3005
3080
|
});
|
|
3006
|
-
server.start(ctx.values.type === "http" ? {
|
|
3081
|
+
await server.start(ctx.values.type === "http" ? {
|
|
3007
3082
|
transportType: "httpStream",
|
|
3008
3083
|
httpStream: { port }
|
|
3009
3084
|
} : { transportType: "stdio" });
|
|
@@ -3042,7 +3117,7 @@ const monthlyCommand = define({
|
|
|
3042
3117
|
};
|
|
3043
3118
|
log(JSON.stringify(emptyOutput, null, 2));
|
|
3044
3119
|
} else logger.warn("No Claude usage data found.");
|
|
3045
|
-
|
|
3120
|
+
g$1.exit(0);
|
|
3046
3121
|
}
|
|
3047
3122
|
const totals = calculateTotals(monthlyData);
|
|
3048
3123
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3138,7 +3213,7 @@ const sessionCommand = define({
|
|
|
3138
3213
|
if (sessionData.length === 0) {
|
|
3139
3214
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
3140
3215
|
else logger.warn("No Claude usage data found.");
|
|
3141
|
-
|
|
3216
|
+
g$1.exit(0);
|
|
3142
3217
|
}
|
|
3143
3218
|
const totals = calculateTotals(sessionData);
|
|
3144
3219
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3236,13 +3311,13 @@ const sessionCommand = define({
|
|
|
3236
3311
|
|
|
3237
3312
|
//#endregion
|
|
3238
3313
|
//#region src/commands/index.ts
|
|
3239
|
-
const subCommands = new Map();
|
|
3314
|
+
const subCommands = /* @__PURE__ */ new Map();
|
|
3240
3315
|
subCommands.set("daily", dailyCommand);
|
|
3241
3316
|
subCommands.set("monthly", monthlyCommand);
|
|
3242
3317
|
subCommands.set("session", sessionCommand);
|
|
3243
3318
|
subCommands.set("mcp", mcpCommand);
|
|
3244
3319
|
const mainCommand = dailyCommand;
|
|
3245
|
-
await cli(
|
|
3320
|
+
await cli(g$1.argv.slice(2), mainCommand, {
|
|
3246
3321
|
name,
|
|
3247
3322
|
version,
|
|
3248
3323
|
description,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sep } from "node:path";
|
|
2
2
|
import { formatWithOptions } from "node:util";
|
|
3
|
-
import
|
|
3
|
+
import g$1 from "node:process";
|
|
4
4
|
import * as tty from "node:tty";
|
|
5
5
|
|
|
6
6
|
//#region node_modules/consola/dist/core.mjs
|
|
@@ -384,7 +384,7 @@ Consola.prototype.withScope = Consola.prototype.withTag;
|
|
|
384
384
|
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
385
385
|
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
386
386
|
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
387
|
-
function createConsola
|
|
387
|
+
function createConsola(options = {}) {
|
|
388
388
|
return new Consola(options);
|
|
389
389
|
}
|
|
390
390
|
|
|
@@ -525,7 +525,7 @@ function getColor$1(color, fallback = "reset") {
|
|
|
525
525
|
return colors[color] || colors[fallback];
|
|
526
526
|
}
|
|
527
527
|
const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
|
|
528
|
-
function stripAnsi
|
|
528
|
+
function stripAnsi(text) {
|
|
529
529
|
return text.replace(new RegExp(ansiRegex$1, "g"), "");
|
|
530
530
|
}
|
|
531
531
|
const boxStylePresets = {
|
|
@@ -618,14 +618,14 @@ function box(text, _opts = {}) {
|
|
|
618
618
|
if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
|
|
619
619
|
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
620
620
|
const height = textLines.length + paddingOffset;
|
|
621
|
-
const width = Math.max(...textLines.map((line) => stripAnsi
|
|
621
|
+
const width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset;
|
|
622
622
|
const widthOffset = width + paddingOffset;
|
|
623
623
|
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
624
624
|
if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
|
|
625
625
|
if (opts.title) {
|
|
626
626
|
const title = _color ? _color(opts.title) : opts.title;
|
|
627
|
-
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi
|
|
628
|
-
const right = borderStyle.h.repeat(width - stripAnsi
|
|
627
|
+
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
|
|
628
|
+
const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
|
|
629
629
|
boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
|
|
630
630
|
} else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
|
|
631
631
|
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
@@ -633,7 +633,7 @@ function box(text, _opts = {}) {
|
|
|
633
633
|
else {
|
|
634
634
|
const line = textLines[i$1 - valignOffset];
|
|
635
635
|
const left = " ".repeat(paddingOffset);
|
|
636
|
-
const right = " ".repeat(width - stripAnsi
|
|
636
|
+
const right = " ".repeat(width - stripAnsi(line).length);
|
|
637
637
|
boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
|
|
638
638
|
}
|
|
639
639
|
boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
|
|
@@ -809,7 +809,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
809
809
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
810
810
|
}
|
|
811
811
|
const regex = ansiRegex();
|
|
812
|
-
function stripAnsi(string) {
|
|
812
|
+
function stripAnsi$1(string) {
|
|
813
813
|
if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
814
814
|
return string.replace(regex, "");
|
|
815
815
|
}
|
|
@@ -838,7 +838,7 @@ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
|
838
838
|
function stringWidth$1(string, options = {}) {
|
|
839
839
|
if (typeof string !== "string" || string.length === 0) return 0;
|
|
840
840
|
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
841
|
-
if (!countAnsiEscapeCodes) string = stripAnsi(string);
|
|
841
|
+
if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
|
|
842
842
|
if (string.length === 0) return 0;
|
|
843
843
|
let width = 0;
|
|
844
844
|
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
@@ -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 } = g$1;
|
|
863
863
|
const { TERM, TERM_PROGRAM } = env$1;
|
|
864
|
-
if (
|
|
864
|
+
if (g$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 = {
|
|
@@ -892,7 +892,7 @@ const TYPE_ICONS = {
|
|
|
892
892
|
};
|
|
893
893
|
function stringWidth(str) {
|
|
894
894
|
const hasICU = typeof Intl === "object";
|
|
895
|
-
if (!hasICU || !Intl.Segmenter) return stripAnsi
|
|
895
|
+
if (!hasICU || !Intl.Segmenter) return stripAnsi(str).length;
|
|
896
896
|
return stringWidth$1(str);
|
|
897
897
|
}
|
|
898
898
|
var FancyReporter = class extends BasicReporter {
|
|
@@ -941,15 +941,15 @@ function getColor(color = "white") {
|
|
|
941
941
|
function getBgColor(color = "bgWhite") {
|
|
942
942
|
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
943
943
|
}
|
|
944
|
-
function createConsola(options = {}) {
|
|
944
|
+
function createConsola$1(options = {}) {
|
|
945
945
|
let level = _getDefaultLogLevel();
|
|
946
946
|
if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
947
|
-
const consola2 = createConsola
|
|
947
|
+
const consola2 = createConsola({
|
|
948
948
|
level,
|
|
949
949
|
defaults: { level },
|
|
950
950
|
stdout: process.stdout,
|
|
951
951
|
stderr: process.stderr,
|
|
952
|
-
prompt: (...args) => import("./prompt-
|
|
952
|
+
prompt: (...args) => import("./prompt-DljZqwMa.js").then((m) => m.prompt(...args)),
|
|
953
953
|
reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
954
954
|
...options
|
|
955
955
|
});
|
|
@@ -960,12 +960,12 @@ function _getDefaultLogLevel() {
|
|
|
960
960
|
if (R) return LogLevels.warn;
|
|
961
961
|
return LogLevels.info;
|
|
962
962
|
}
|
|
963
|
-
const consola = createConsola();
|
|
963
|
+
const consola = createConsola$1();
|
|
964
964
|
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region package.json
|
|
967
967
|
var name = "ccusage";
|
|
968
|
-
var version = "0.6.
|
|
968
|
+
var version = "0.6.1";
|
|
969
969
|
var description = "Usage analysis tool for Claude Code";
|
|
970
970
|
|
|
971
971
|
//#endregion
|
package/dist/logger.js
CHANGED