ccusage 0.6.2 → 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 +52 -18
- package/dist/calculate-cost.d.ts +1 -1
- package/dist/{data-loader-BfnzLKGl.js → data-loader-Bz6Vemxw.js} +318 -54
- package/dist/{data-loader-B0tJZeHI.d.ts → data-loader-amTZCtBR.d.ts} +53 -1
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +4 -4
- package/dist/{debug-Bf6GUNZE.js → debug-DQXeZIjf.js} +3 -3
- package/dist/debug.js +4 -4
- package/dist/index.js +87 -131
- package/dist/{logger-DixU80sg.js → logger-DN-RT9jL.js} +5 -5
- package/dist/logger.js +1 -1
- package/dist/{mcp-nXxiNurt.js → mcp-DZXbfmbs.js} +4 -4
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-BY3-ryVq.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/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, formatNumber, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } 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
|
/**
|
|
@@ -175,7 +175,7 @@ const BUILT_IN_PREFIX_CODE = BUILT_IN_PREFIX.codePointAt(0);
|
|
|
175
175
|
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
176
176
|
* @returns A {@link CommandContext | command context}, which is readonly
|
|
177
177
|
*/
|
|
178
|
-
async function createCommandContext({ args, values, positionals, rest, argv
|
|
178
|
+
async function createCommandContext({ args, values, positionals, rest, argv, tokens, command, cliOptions, callMode = "entry", omitted = false }) {
|
|
179
179
|
/**
|
|
180
180
|
* normailize the options schema and values, to avoid prototype pollution
|
|
181
181
|
*/
|
|
@@ -186,7 +186,7 @@ async function createCommandContext({ args, values, positionals, rest, argv: arg
|
|
|
186
186
|
/**
|
|
187
187
|
* setup the environment
|
|
188
188
|
*/
|
|
189
|
-
const env$
|
|
189
|
+
const env$1 = Object.assign(create(), COMMAND_OPTIONS_DEFAULT, cliOptions);
|
|
190
190
|
const locale = resolveLocale(cliOptions.locale);
|
|
191
191
|
const localeStr = locale.toString();
|
|
192
192
|
const translationAdapterFactory = cliOptions.translationAdapterFactory || createTranslationAdapter;
|
|
@@ -233,12 +233,12 @@ async function createCommandContext({ args, values, positionals, rest, argv: arg
|
|
|
233
233
|
omitted,
|
|
234
234
|
callMode,
|
|
235
235
|
locale,
|
|
236
|
-
env: env$
|
|
236
|
+
env: env$1,
|
|
237
237
|
args: _args,
|
|
238
238
|
values,
|
|
239
239
|
positionals,
|
|
240
240
|
rest,
|
|
241
|
-
_: argv
|
|
241
|
+
_: argv,
|
|
242
242
|
tokens,
|
|
243
243
|
toKebab: command.toKebab,
|
|
244
244
|
log: cliOptions.usageSilent ? NOOP : log$1,
|
|
@@ -1009,9 +1009,9 @@ function createTypeError(option, schema) {
|
|
|
1009
1009
|
* @param options A {@link CliOptions | CLI options}
|
|
1010
1010
|
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
1011
1011
|
*/
|
|
1012
|
-
async function cli(argv
|
|
1012
|
+
async function cli(argv, entry, options = {}) {
|
|
1013
1013
|
const cliOptions = resolveCliOptions(options, entry);
|
|
1014
|
-
const tokens = parseArgs(argv
|
|
1014
|
+
const tokens = parseArgs(argv);
|
|
1015
1015
|
const subCommand = getSubCommand(tokens);
|
|
1016
1016
|
const { commandName: name$1, command, callMode } = await resolveCommand(subCommand, entry, cliOptions);
|
|
1017
1017
|
if (!command) throw new Error(`Command not found: ${name$1 || ""}`);
|
|
@@ -1027,7 +1027,7 @@ async function cli(argv$1, entry, options = {}) {
|
|
|
1027
1027
|
values,
|
|
1028
1028
|
positionals,
|
|
1029
1029
|
rest,
|
|
1030
|
-
argv
|
|
1030
|
+
argv,
|
|
1031
1031
|
tokens,
|
|
1032
1032
|
omitted,
|
|
1033
1033
|
callMode,
|
|
@@ -1582,11 +1582,11 @@ var require_styles = __commonJS({ "node_modules/@colors/colors/lib/styles.js"(ex
|
|
|
1582
1582
|
//#endregion
|
|
1583
1583
|
//#region node_modules/@colors/colors/lib/system/has-flag.js
|
|
1584
1584
|
var require_has_flag = __commonJS({ "node_modules/@colors/colors/lib/system/has-flag.js"(exports, module) {
|
|
1585
|
-
module.exports = function(flag, argv
|
|
1586
|
-
argv
|
|
1587
|
-
var terminatorPos = argv
|
|
1585
|
+
module.exports = function(flag, argv) {
|
|
1586
|
+
argv = argv || process.argv;
|
|
1587
|
+
var terminatorPos = argv.indexOf("--");
|
|
1588
1588
|
var prefix = /^-{1,2}/.test(flag) ? "" : "--";
|
|
1589
|
-
var pos = argv
|
|
1589
|
+
var pos = argv.indexOf(prefix + flag);
|
|
1590
1590
|
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
|
1591
1591
|
};
|
|
1592
1592
|
} });
|
|
@@ -1596,11 +1596,11 @@ var require_has_flag = __commonJS({ "node_modules/@colors/colors/lib/system/has-
|
|
|
1596
1596
|
var require_supports_colors = __commonJS({ "node_modules/@colors/colors/lib/system/supports-colors.js"(exports, module) {
|
|
1597
1597
|
var os = __require("os");
|
|
1598
1598
|
var hasFlag = require_has_flag();
|
|
1599
|
-
var env
|
|
1599
|
+
var env = process.env;
|
|
1600
1600
|
var forceColor = void 0;
|
|
1601
1601
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) forceColor = false;
|
|
1602
1602
|
else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) forceColor = true;
|
|
1603
|
-
if ("FORCE_COLOR" in env
|
|
1603
|
+
if ("FORCE_COLOR" in env) forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
|
|
1604
1604
|
function translateLevel(level$1) {
|
|
1605
1605
|
if (level$1 === 0) return false;
|
|
1606
1606
|
return {
|
|
@@ -1621,30 +1621,30 @@ var require_supports_colors = __commonJS({ "node_modules/@colors/colors/lib/syst
|
|
|
1621
1621
|
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
1622
1622
|
return 1;
|
|
1623
1623
|
}
|
|
1624
|
-
if ("CI" in env
|
|
1624
|
+
if ("CI" in env) {
|
|
1625
1625
|
if ([
|
|
1626
1626
|
"TRAVIS",
|
|
1627
1627
|
"CIRCLECI",
|
|
1628
1628
|
"APPVEYOR",
|
|
1629
1629
|
"GITLAB_CI"
|
|
1630
1630
|
].some(function(sign) {
|
|
1631
|
-
return sign in env
|
|
1632
|
-
}) || env
|
|
1631
|
+
return sign in env;
|
|
1632
|
+
}) || env.CI_NAME === "codeship") return 1;
|
|
1633
1633
|
return min;
|
|
1634
1634
|
}
|
|
1635
|
-
if ("TEAMCITY_VERSION" in env
|
|
1636
|
-
if ("TERM_PROGRAM" in env
|
|
1637
|
-
var version$2 = parseInt((env
|
|
1638
|
-
switch (env
|
|
1635
|
+
if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1636
|
+
if ("TERM_PROGRAM" in env) {
|
|
1637
|
+
var version$2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1638
|
+
switch (env.TERM_PROGRAM) {
|
|
1639
1639
|
case "iTerm.app": return version$2 >= 3 ? 3 : 2;
|
|
1640
1640
|
case "Hyper": return 3;
|
|
1641
1641
|
case "Apple_Terminal": return 2;
|
|
1642
1642
|
}
|
|
1643
1643
|
}
|
|
1644
|
-
if (/-256(color)?$/i.test(env
|
|
1645
|
-
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env
|
|
1646
|
-
if ("COLORTERM" in env
|
|
1647
|
-
if (env
|
|
1644
|
+
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
1645
|
+
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
|
|
1646
|
+
if ("COLORTERM" in env) return 1;
|
|
1647
|
+
if (env.TERM === "dumb") return min;
|
|
1648
1648
|
return min;
|
|
1649
1649
|
}
|
|
1650
1650
|
function getSupportLevel(stream) {
|
|
@@ -2813,75 +2813,6 @@ var require_cli_table3 = __commonJS({ "node_modules/cli-table3/index.js"(exports
|
|
|
2813
2813
|
module.exports = require_table();
|
|
2814
2814
|
} });
|
|
2815
2815
|
|
|
2816
|
-
//#endregion
|
|
2817
|
-
//#region node_modules/picocolors/picocolors.js
|
|
2818
|
-
var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(exports, module) {
|
|
2819
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
2820
|
-
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
2821
|
-
let formatter = (open, close, replace = open) => (input) => {
|
|
2822
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2823
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
2824
|
-
};
|
|
2825
|
-
let replaceClose = (string, close, replace, index) => {
|
|
2826
|
-
let result = "", cursor = 0;
|
|
2827
|
-
do {
|
|
2828
|
-
result += string.substring(cursor, index) + replace;
|
|
2829
|
-
cursor = index + close.length;
|
|
2830
|
-
index = string.indexOf(close, cursor);
|
|
2831
|
-
} while (~index);
|
|
2832
|
-
return result + string.substring(cursor);
|
|
2833
|
-
};
|
|
2834
|
-
let createColors = (enabled = isColorSupported) => {
|
|
2835
|
-
let f = enabled ? formatter : () => String;
|
|
2836
|
-
return {
|
|
2837
|
-
isColorSupported: enabled,
|
|
2838
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
2839
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
2840
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
2841
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
2842
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
2843
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
2844
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
2845
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
2846
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
2847
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
2848
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
2849
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
2850
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
2851
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
2852
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
2853
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
2854
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
2855
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
2856
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
2857
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
2858
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
2859
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
2860
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
2861
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
2862
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
2863
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
2864
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
2865
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
2866
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
2867
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
2868
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
2869
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
2870
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
2871
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
2872
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
2873
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
2874
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
2875
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
2876
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
2877
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
2878
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
2879
|
-
};
|
|
2880
|
-
};
|
|
2881
|
-
module.exports = createColors();
|
|
2882
|
-
module.exports.createColors = createColors;
|
|
2883
|
-
} });
|
|
2884
|
-
|
|
2885
2816
|
//#endregion
|
|
2886
2817
|
//#region src/shared-args.internal.ts
|
|
2887
2818
|
function parseDateArg(value) {
|
|
@@ -2938,6 +2869,12 @@ const sharedArgs = {
|
|
|
2938
2869
|
description: "Sort order: desc (newest first) or asc (oldest first)",
|
|
2939
2870
|
default: "asc",
|
|
2940
2871
|
choices: SortOrders
|
|
2872
|
+
},
|
|
2873
|
+
breakdown: {
|
|
2874
|
+
type: "boolean",
|
|
2875
|
+
short: "b",
|
|
2876
|
+
description: "Show per-model cost breakdown",
|
|
2877
|
+
default: false
|
|
2941
2878
|
}
|
|
2942
2879
|
};
|
|
2943
2880
|
const sharedCommandConfig = {
|
|
@@ -2965,7 +2902,7 @@ const dailyCommand = define({
|
|
|
2965
2902
|
if (dailyData.length === 0) {
|
|
2966
2903
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
2967
2904
|
else logger.warn("No Claude usage data found.");
|
|
2968
|
-
|
|
2905
|
+
process$1.exit(0);
|
|
2969
2906
|
}
|
|
2970
2907
|
const totals = calculateTotals(dailyData);
|
|
2971
2908
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -2981,7 +2918,9 @@ const dailyCommand = define({
|
|
|
2981
2918
|
cacheCreationTokens: data.cacheCreationTokens,
|
|
2982
2919
|
cacheReadTokens: data.cacheReadTokens,
|
|
2983
2920
|
totalTokens: getTotalTokens(data),
|
|
2984
|
-
totalCost: data.totalCost
|
|
2921
|
+
totalCost: data.totalCost,
|
|
2922
|
+
modelsUsed: data.modelsUsed,
|
|
2923
|
+
modelBreakdowns: data.modelBreakdowns
|
|
2985
2924
|
})),
|
|
2986
2925
|
totals: createTotalsObject(totals)
|
|
2987
2926
|
};
|
|
@@ -2991,6 +2930,7 @@ const dailyCommand = define({
|
|
|
2991
2930
|
const table = new import_cli_table3$2.default({
|
|
2992
2931
|
head: [
|
|
2993
2932
|
"Date",
|
|
2933
|
+
"Models",
|
|
2994
2934
|
"Input",
|
|
2995
2935
|
"Output",
|
|
2996
2936
|
"Cache Create",
|
|
@@ -3000,6 +2940,7 @@ const dailyCommand = define({
|
|
|
3000
2940
|
],
|
|
3001
2941
|
style: { head: ["cyan"] },
|
|
3002
2942
|
colAligns: [
|
|
2943
|
+
"left",
|
|
3003
2944
|
"left",
|
|
3004
2945
|
"right",
|
|
3005
2946
|
"right",
|
|
@@ -3009,15 +2950,19 @@ const dailyCommand = define({
|
|
|
3009
2950
|
"right"
|
|
3010
2951
|
]
|
|
3011
2952
|
});
|
|
3012
|
-
for (const data of dailyData)
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
2953
|
+
for (const data of dailyData) {
|
|
2954
|
+
table.push([
|
|
2955
|
+
data.date,
|
|
2956
|
+
formatModelsDisplay(data.modelsUsed),
|
|
2957
|
+
formatNumber(data.inputTokens),
|
|
2958
|
+
formatNumber(data.outputTokens),
|
|
2959
|
+
formatNumber(data.cacheCreationTokens),
|
|
2960
|
+
formatNumber(data.cacheReadTokens),
|
|
2961
|
+
formatNumber(getTotalTokens(data)),
|
|
2962
|
+
formatCurrency(data.totalCost)
|
|
2963
|
+
]);
|
|
2964
|
+
if (ctx.values.breakdown) pushBreakdownRows(table, data.modelBreakdowns);
|
|
2965
|
+
}
|
|
3021
2966
|
table.push([
|
|
3022
2967
|
"─".repeat(12),
|
|
3023
2968
|
"─".repeat(12),
|
|
@@ -3025,10 +2970,12 @@ const dailyCommand = define({
|
|
|
3025
2970
|
"─".repeat(12),
|
|
3026
2971
|
"─".repeat(12),
|
|
3027
2972
|
"─".repeat(12),
|
|
2973
|
+
"─".repeat(12),
|
|
3028
2974
|
"─".repeat(10)
|
|
3029
2975
|
]);
|
|
3030
2976
|
table.push([
|
|
3031
2977
|
import_picocolors$2.default.yellow("Total"),
|
|
2978
|
+
"",
|
|
3032
2979
|
import_picocolors$2.default.yellow(formatNumber(totals.inputTokens)),
|
|
3033
2980
|
import_picocolors$2.default.yellow(formatNumber(totals.outputTokens)),
|
|
3034
2981
|
import_picocolors$2.default.yellow(formatNumber(totals.cacheCreationTokens)),
|
|
@@ -3108,7 +3055,7 @@ const monthlyCommand = define({
|
|
|
3108
3055
|
};
|
|
3109
3056
|
log(JSON.stringify(emptyOutput, null, 2));
|
|
3110
3057
|
} else logger.warn("No Claude usage data found.");
|
|
3111
|
-
|
|
3058
|
+
process$1.exit(0);
|
|
3112
3059
|
}
|
|
3113
3060
|
const totals = calculateTotals(monthlyData);
|
|
3114
3061
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3124,7 +3071,9 @@ const monthlyCommand = define({
|
|
|
3124
3071
|
cacheCreationTokens: data.cacheCreationTokens,
|
|
3125
3072
|
cacheReadTokens: data.cacheReadTokens,
|
|
3126
3073
|
totalTokens: getTotalTokens(data),
|
|
3127
|
-
totalCost: data.totalCost
|
|
3074
|
+
totalCost: data.totalCost,
|
|
3075
|
+
modelsUsed: data.modelsUsed,
|
|
3076
|
+
modelBreakdowns: data.modelBreakdowns
|
|
3128
3077
|
})),
|
|
3129
3078
|
totals: createTotalsObject(totals)
|
|
3130
3079
|
};
|
|
@@ -3134,6 +3083,7 @@ const monthlyCommand = define({
|
|
|
3134
3083
|
const table = new import_cli_table3$1.default({
|
|
3135
3084
|
head: [
|
|
3136
3085
|
"Month",
|
|
3086
|
+
"Models",
|
|
3137
3087
|
"Input",
|
|
3138
3088
|
"Output",
|
|
3139
3089
|
"Cache Create",
|
|
@@ -3143,6 +3093,7 @@ const monthlyCommand = define({
|
|
|
3143
3093
|
],
|
|
3144
3094
|
style: { head: ["cyan"] },
|
|
3145
3095
|
colAligns: [
|
|
3096
|
+
"left",
|
|
3146
3097
|
"left",
|
|
3147
3098
|
"right",
|
|
3148
3099
|
"right",
|
|
@@ -3152,15 +3103,19 @@ const monthlyCommand = define({
|
|
|
3152
3103
|
"right"
|
|
3153
3104
|
]
|
|
3154
3105
|
});
|
|
3155
|
-
for (const data of monthlyData)
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3106
|
+
for (const data of monthlyData) {
|
|
3107
|
+
table.push([
|
|
3108
|
+
data.month,
|
|
3109
|
+
formatModelsDisplay(data.modelsUsed),
|
|
3110
|
+
formatNumber(data.inputTokens),
|
|
3111
|
+
formatNumber(data.outputTokens),
|
|
3112
|
+
formatNumber(data.cacheCreationTokens),
|
|
3113
|
+
formatNumber(data.cacheReadTokens),
|
|
3114
|
+
formatNumber(getTotalTokens(data)),
|
|
3115
|
+
formatCurrency(data.totalCost)
|
|
3116
|
+
]);
|
|
3117
|
+
if (ctx.values.breakdown) pushBreakdownRows(table, data.modelBreakdowns);
|
|
3118
|
+
}
|
|
3164
3119
|
table.push([
|
|
3165
3120
|
"─".repeat(12),
|
|
3166
3121
|
"─".repeat(12),
|
|
@@ -3168,10 +3123,12 @@ const monthlyCommand = define({
|
|
|
3168
3123
|
"─".repeat(12),
|
|
3169
3124
|
"─".repeat(12),
|
|
3170
3125
|
"─".repeat(12),
|
|
3126
|
+
"─".repeat(12),
|
|
3171
3127
|
"─".repeat(10)
|
|
3172
3128
|
]);
|
|
3173
3129
|
table.push([
|
|
3174
3130
|
import_picocolors$1.default.yellow("Total"),
|
|
3131
|
+
"",
|
|
3175
3132
|
import_picocolors$1.default.yellow(formatNumber(totals.inputTokens)),
|
|
3176
3133
|
import_picocolors$1.default.yellow(formatNumber(totals.outputTokens)),
|
|
3177
3134
|
import_picocolors$1.default.yellow(formatNumber(totals.cacheCreationTokens)),
|
|
@@ -3204,7 +3161,7 @@ const sessionCommand = define({
|
|
|
3204
3161
|
if (sessionData.length === 0) {
|
|
3205
3162
|
if (ctx.values.json) log(JSON.stringify([]));
|
|
3206
3163
|
else logger.warn("No Claude usage data found.");
|
|
3207
|
-
|
|
3164
|
+
process$1.exit(0);
|
|
3208
3165
|
}
|
|
3209
3166
|
const totals = calculateTotals(sessionData);
|
|
3210
3167
|
if (ctx.values.debug && !ctx.values.json) {
|
|
@@ -3214,7 +3171,6 @@ const sessionCommand = define({
|
|
|
3214
3171
|
if (ctx.values.json) {
|
|
3215
3172
|
const jsonOutput = {
|
|
3216
3173
|
sessions: sessionData.map((data) => ({
|
|
3217
|
-
projectPath: data.projectPath,
|
|
3218
3174
|
sessionId: data.sessionId,
|
|
3219
3175
|
inputTokens: data.inputTokens,
|
|
3220
3176
|
outputTokens: data.outputTokens,
|
|
@@ -3222,7 +3178,9 @@ const sessionCommand = define({
|
|
|
3222
3178
|
cacheReadTokens: data.cacheReadTokens,
|
|
3223
3179
|
totalTokens: getTotalTokens(data),
|
|
3224
3180
|
totalCost: data.totalCost,
|
|
3225
|
-
lastActivity: data.lastActivity
|
|
3181
|
+
lastActivity: data.lastActivity,
|
|
3182
|
+
modelsUsed: data.modelsUsed,
|
|
3183
|
+
modelBreakdowns: data.modelBreakdowns
|
|
3226
3184
|
})),
|
|
3227
3185
|
totals: createTotalsObject(totals)
|
|
3228
3186
|
};
|
|
@@ -3231,8 +3189,8 @@ const sessionCommand = define({
|
|
|
3231
3189
|
logger.box("Claude Code Token Usage Report - By Session");
|
|
3232
3190
|
const table = new import_cli_table3.default({
|
|
3233
3191
|
head: [
|
|
3234
|
-
"Project",
|
|
3235
3192
|
"Session",
|
|
3193
|
+
"Models",
|
|
3236
3194
|
"Input",
|
|
3237
3195
|
"Output",
|
|
3238
3196
|
"Cache Create",
|
|
@@ -3254,16 +3212,13 @@ const sessionCommand = define({
|
|
|
3254
3212
|
"left"
|
|
3255
3213
|
]
|
|
3256
3214
|
});
|
|
3257
|
-
let maxProjectLength = 0;
|
|
3258
3215
|
let maxSessionLength = 0;
|
|
3259
3216
|
for (const data of sessionData) {
|
|
3260
|
-
const projectDisplay = data.projectPath.length > 20 ? `...${data.projectPath.slice(-17)}` : data.projectPath;
|
|
3261
3217
|
const sessionDisplay = data.sessionId.split("-").slice(-2).join("-");
|
|
3262
|
-
maxProjectLength = Math.max(maxProjectLength, projectDisplay.length);
|
|
3263
3218
|
maxSessionLength = Math.max(maxSessionLength, sessionDisplay.length);
|
|
3264
3219
|
table.push([
|
|
3265
|
-
projectDisplay,
|
|
3266
3220
|
sessionDisplay,
|
|
3221
|
+
formatModelsDisplay(data.modelsUsed),
|
|
3267
3222
|
formatNumber(data.inputTokens),
|
|
3268
3223
|
formatNumber(data.outputTokens),
|
|
3269
3224
|
formatNumber(data.cacheCreationTokens),
|
|
@@ -3272,15 +3227,16 @@ const sessionCommand = define({
|
|
|
3272
3227
|
formatCurrency(data.totalCost),
|
|
3273
3228
|
data.lastActivity
|
|
3274
3229
|
]);
|
|
3230
|
+
if (ctx.values.breakdown) pushBreakdownRows(table, data.modelBreakdowns, 1, 1);
|
|
3275
3231
|
}
|
|
3276
3232
|
table.push([
|
|
3277
|
-
"─".repeat(maxProjectLength),
|
|
3278
3233
|
"─".repeat(maxSessionLength),
|
|
3279
3234
|
"─".repeat(12),
|
|
3280
3235
|
"─".repeat(12),
|
|
3281
3236
|
"─".repeat(12),
|
|
3282
3237
|
"─".repeat(12),
|
|
3283
3238
|
"─".repeat(12),
|
|
3239
|
+
"─".repeat(12),
|
|
3284
3240
|
"─".repeat(10),
|
|
3285
3241
|
"─".repeat(12)
|
|
3286
3242
|
]);
|
|
@@ -3308,7 +3264,7 @@ subCommands.set("monthly", monthlyCommand);
|
|
|
3308
3264
|
subCommands.set("session", sessionCommand);
|
|
3309
3265
|
subCommands.set("mcp", mcpCommand);
|
|
3310
3266
|
const mainCommand = dailyCommand;
|
|
3311
|
-
await cli(
|
|
3267
|
+
await cli(process$1.argv.slice(2), mainCommand, {
|
|
3312
3268
|
name,
|
|
3313
3269
|
version,
|
|
3314
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) {
|