ccusage 0.2.0 → 0.2.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/dist/index.js +44 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2901,6 +2901,37 @@ var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(ex
|
|
|
2901
2901
|
module.exports.createColors = createColors$1;
|
|
2902
2902
|
} });
|
|
2903
2903
|
|
|
2904
|
+
//#endregion
|
|
2905
|
+
//#region calculate-cost.ts
|
|
2906
|
+
function calculateTotals(data) {
|
|
2907
|
+
return data.reduce((acc, item) => ({
|
|
2908
|
+
inputTokens: acc.inputTokens + item.inputTokens,
|
|
2909
|
+
outputTokens: acc.outputTokens + item.outputTokens,
|
|
2910
|
+
cacheCreationTokens: acc.cacheCreationTokens + item.cacheCreationTokens,
|
|
2911
|
+
cacheReadTokens: acc.cacheReadTokens + item.cacheReadTokens,
|
|
2912
|
+
totalCost: acc.totalCost + item.totalCost
|
|
2913
|
+
}), {
|
|
2914
|
+
inputTokens: 0,
|
|
2915
|
+
outputTokens: 0,
|
|
2916
|
+
cacheCreationTokens: 0,
|
|
2917
|
+
cacheReadTokens: 0,
|
|
2918
|
+
totalCost: 0
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
function getTotalTokens(tokens) {
|
|
2922
|
+
return tokens.inputTokens + tokens.outputTokens + tokens.cacheCreationTokens + tokens.cacheReadTokens;
|
|
2923
|
+
}
|
|
2924
|
+
function createTotalsObject(totals) {
|
|
2925
|
+
return {
|
|
2926
|
+
inputTokens: totals.inputTokens,
|
|
2927
|
+
outputTokens: totals.outputTokens,
|
|
2928
|
+
cacheCreationTokens: totals.cacheCreationTokens,
|
|
2929
|
+
cacheReadTokens: totals.cacheReadTokens,
|
|
2930
|
+
totalTokens: getTotalTokens(totals),
|
|
2931
|
+
totalCost: totals.totalCost
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2904
2935
|
//#endregion
|
|
2905
2936
|
//#region node_modules/fdir/dist/utils.js
|
|
2906
2937
|
var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
@@ -7037,7 +7068,7 @@ const consola = createConsola();
|
|
|
7037
7068
|
//#endregion
|
|
7038
7069
|
//#region package.json
|
|
7039
7070
|
var name = "ccusage";
|
|
7040
|
-
var version = "0.2.
|
|
7071
|
+
var version = "0.2.2";
|
|
7041
7072
|
var description = "Usage analysis tool for Claude Code";
|
|
7042
7073
|
|
|
7043
7074
|
//#endregion
|
|
@@ -7141,19 +7172,7 @@ const dailyCommand = define({
|
|
|
7141
7172
|
else logger.warn("No Claude usage data found.");
|
|
7142
7173
|
process$1.exit(0);
|
|
7143
7174
|
}
|
|
7144
|
-
const totals = dailyData
|
|
7145
|
-
inputTokens: acc.inputTokens + data.inputTokens,
|
|
7146
|
-
outputTokens: acc.outputTokens + data.outputTokens,
|
|
7147
|
-
cacheCreationTokens: acc.cacheCreationTokens + data.cacheCreationTokens,
|
|
7148
|
-
cacheReadTokens: acc.cacheReadTokens + data.cacheReadTokens,
|
|
7149
|
-
totalCost: acc.totalCost + data.totalCost
|
|
7150
|
-
}), {
|
|
7151
|
-
inputTokens: 0,
|
|
7152
|
-
outputTokens: 0,
|
|
7153
|
-
cacheCreationTokens: 0,
|
|
7154
|
-
cacheReadTokens: 0,
|
|
7155
|
-
totalCost: 0
|
|
7156
|
-
});
|
|
7175
|
+
const totals = calculateTotals(dailyData);
|
|
7157
7176
|
if (ctx.values.json) {
|
|
7158
7177
|
const jsonOutput = {
|
|
7159
7178
|
daily: dailyData.map((data) => ({
|
|
@@ -7162,17 +7181,10 @@ const dailyCommand = define({
|
|
|
7162
7181
|
outputTokens: data.outputTokens,
|
|
7163
7182
|
cacheCreationTokens: data.cacheCreationTokens,
|
|
7164
7183
|
cacheReadTokens: data.cacheReadTokens,
|
|
7165
|
-
totalTokens: data
|
|
7184
|
+
totalTokens: getTotalTokens(data),
|
|
7166
7185
|
totalCost: data.totalCost
|
|
7167
7186
|
})),
|
|
7168
|
-
totals:
|
|
7169
|
-
inputTokens: totals.inputTokens,
|
|
7170
|
-
outputTokens: totals.outputTokens,
|
|
7171
|
-
cacheCreationTokens: totals.cacheCreationTokens,
|
|
7172
|
-
cacheReadTokens: totals.cacheReadTokens,
|
|
7173
|
-
totalTokens: totals.inputTokens + totals.outputTokens + totals.cacheCreationTokens + totals.cacheReadTokens,
|
|
7174
|
-
totalCost: totals.totalCost
|
|
7175
|
-
}
|
|
7187
|
+
totals: createTotalsObject(totals)
|
|
7176
7188
|
};
|
|
7177
7189
|
log(JSON.stringify(jsonOutput, null, 2));
|
|
7178
7190
|
} else {
|
|
@@ -7204,7 +7216,7 @@ const dailyCommand = define({
|
|
|
7204
7216
|
formatNumber(data.outputTokens),
|
|
7205
7217
|
formatNumber(data.cacheCreationTokens),
|
|
7206
7218
|
formatNumber(data.cacheReadTokens),
|
|
7207
|
-
formatNumber(data
|
|
7219
|
+
formatNumber(getTotalTokens(data)),
|
|
7208
7220
|
formatCurrency(data.totalCost)
|
|
7209
7221
|
]);
|
|
7210
7222
|
table.push([
|
|
@@ -7222,7 +7234,7 @@ const dailyCommand = define({
|
|
|
7222
7234
|
import_picocolors$1.default.yellow(formatNumber(totals.outputTokens)),
|
|
7223
7235
|
import_picocolors$1.default.yellow(formatNumber(totals.cacheCreationTokens)),
|
|
7224
7236
|
import_picocolors$1.default.yellow(formatNumber(totals.cacheReadTokens)),
|
|
7225
|
-
import_picocolors$1.default.yellow(formatNumber(totals
|
|
7237
|
+
import_picocolors$1.default.yellow(formatNumber(getTotalTokens(totals))),
|
|
7226
7238
|
import_picocolors$1.default.yellow(formatCurrency(totals.totalCost))
|
|
7227
7239
|
]);
|
|
7228
7240
|
console.log(table.toString());
|
|
@@ -7250,19 +7262,7 @@ const sessionCommand = define({
|
|
|
7250
7262
|
else logger.warn("No Claude usage data found.");
|
|
7251
7263
|
process$1.exit(0);
|
|
7252
7264
|
}
|
|
7253
|
-
const totals = sessionData
|
|
7254
|
-
inputTokens: acc.inputTokens + data.inputTokens,
|
|
7255
|
-
outputTokens: acc.outputTokens + data.outputTokens,
|
|
7256
|
-
cacheCreationTokens: acc.cacheCreationTokens + data.cacheCreationTokens,
|
|
7257
|
-
cacheReadTokens: acc.cacheReadTokens + data.cacheReadTokens,
|
|
7258
|
-
totalCost: acc.totalCost + data.totalCost
|
|
7259
|
-
}), {
|
|
7260
|
-
inputTokens: 0,
|
|
7261
|
-
outputTokens: 0,
|
|
7262
|
-
cacheCreationTokens: 0,
|
|
7263
|
-
cacheReadTokens: 0,
|
|
7264
|
-
totalCost: 0
|
|
7265
|
-
});
|
|
7265
|
+
const totals = calculateTotals(sessionData);
|
|
7266
7266
|
if (ctx.values.json) {
|
|
7267
7267
|
const jsonOutput = {
|
|
7268
7268
|
sessions: sessionData.map((data) => ({
|
|
@@ -7272,18 +7272,11 @@ const sessionCommand = define({
|
|
|
7272
7272
|
outputTokens: data.outputTokens,
|
|
7273
7273
|
cacheCreationTokens: data.cacheCreationTokens,
|
|
7274
7274
|
cacheReadTokens: data.cacheReadTokens,
|
|
7275
|
-
totalTokens: data
|
|
7275
|
+
totalTokens: getTotalTokens(data),
|
|
7276
7276
|
totalCost: data.totalCost,
|
|
7277
7277
|
lastActivity: data.lastActivity
|
|
7278
7278
|
})),
|
|
7279
|
-
totals:
|
|
7280
|
-
inputTokens: totals.inputTokens,
|
|
7281
|
-
outputTokens: totals.outputTokens,
|
|
7282
|
-
cacheCreationTokens: totals.cacheCreationTokens,
|
|
7283
|
-
cacheReadTokens: totals.cacheReadTokens,
|
|
7284
|
-
totalTokens: totals.inputTokens + totals.outputTokens + totals.cacheCreationTokens + totals.cacheReadTokens,
|
|
7285
|
-
totalCost: totals.totalCost
|
|
7286
|
-
}
|
|
7279
|
+
totals: createTotalsObject(totals)
|
|
7287
7280
|
};
|
|
7288
7281
|
log(JSON.stringify(jsonOutput, null, 2));
|
|
7289
7282
|
} else {
|
|
@@ -7327,7 +7320,7 @@ const sessionCommand = define({
|
|
|
7327
7320
|
formatNumber(data.outputTokens),
|
|
7328
7321
|
formatNumber(data.cacheCreationTokens),
|
|
7329
7322
|
formatNumber(data.cacheReadTokens),
|
|
7330
|
-
formatNumber(data
|
|
7323
|
+
formatNumber(getTotalTokens(data)),
|
|
7331
7324
|
formatCurrency(data.totalCost),
|
|
7332
7325
|
data.lastActivity
|
|
7333
7326
|
]);
|
|
@@ -7350,7 +7343,7 @@ const sessionCommand = define({
|
|
|
7350
7343
|
import_picocolors.default.yellow(formatNumber(totals.outputTokens)),
|
|
7351
7344
|
import_picocolors.default.yellow(formatNumber(totals.cacheCreationTokens)),
|
|
7352
7345
|
import_picocolors.default.yellow(formatNumber(totals.cacheReadTokens)),
|
|
7353
|
-
import_picocolors.default.yellow(formatNumber(totals
|
|
7346
|
+
import_picocolors.default.yellow(formatNumber(getTotalTokens(totals))),
|
|
7354
7347
|
import_picocolors.default.yellow(formatCurrency(totals.totalCost)),
|
|
7355
7348
|
""
|
|
7356
7349
|
]);
|
|
@@ -7369,7 +7362,8 @@ await cli(process$1.argv.slice(2), mainCommand, {
|
|
|
7369
7362
|
name,
|
|
7370
7363
|
version,
|
|
7371
7364
|
description,
|
|
7372
|
-
subCommands
|
|
7365
|
+
subCommands,
|
|
7366
|
+
renderHeader: null
|
|
7373
7367
|
});
|
|
7374
7368
|
|
|
7375
7369
|
//#endregion
|