ccusage 0.6.2 → 0.7.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-nOFcMg_V.js} +247 -50
- package/dist/{data-loader-B0tJZeHI.d.ts → data-loader-pCzn-ryX.d.ts} +37 -1
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +4 -4
- package/dist/{debug-Bf6GUNZE.js → debug-Bttss7TN.js} +3 -3
- package/dist/debug.js +4 -4
- package/dist/index.js +82 -126
- package/dist/{logger-DixU80sg.js → logger-BPjA3VFO.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-nXxiNurt.js → mcp-DCEVbd8C.js} +2 -2
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-BY3-ryVq.js → pricing-fetcher-CAeJvZnF.js} +1 -1
- package/dist/pricing-fetcher.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ This tool helps you understand the value you're getting from your subscription b
|
|
|
41
41
|
- 📊 **Daily Report**: View token usage and costs aggregated by date
|
|
42
42
|
- 📅 **Monthly Report**: View token usage and costs aggregated by month
|
|
43
43
|
- 💬 **Session Report**: View usage grouped by conversation sessions
|
|
44
|
+
- 🤖 **Model Tracking**: See which Claude models you're using (Opus, Sonnet, etc.)
|
|
45
|
+
- 📊 **Model Breakdown**: View per-model cost breakdown with `--breakdown` flag
|
|
44
46
|
- 📅 **Date Filtering**: Filter reports by date range using `--since` and `--until`
|
|
45
47
|
- 📁 **Custom Path**: Support for custom Claude data directory locations
|
|
46
48
|
- 🎨 **Beautiful Output**: Colorful table-formatted display
|
|
@@ -141,6 +143,9 @@ ccusage daily --mode display # Always show pre-calculated costUSD values
|
|
|
141
143
|
# Control sort order
|
|
142
144
|
ccusage daily --order asc # Show oldest dates first
|
|
143
145
|
ccusage daily --order desc # Show newest dates first (default)
|
|
146
|
+
|
|
147
|
+
# Show per-model cost breakdown
|
|
148
|
+
ccusage daily --breakdown # Show cost breakdown by model (opus-4, sonnet-4, etc.)
|
|
144
149
|
```
|
|
145
150
|
|
|
146
151
|
`ccusage` is an alias for `ccusage daily`, so you can run it without specifying the subcommand.
|
|
@@ -170,6 +175,9 @@ ccusage monthly --mode display # Always show pre-calculated costUSD values
|
|
|
170
175
|
# Control sort order
|
|
171
176
|
ccusage monthly --order asc # Show oldest months first
|
|
172
177
|
ccusage monthly --order desc # Show newest months first (default)
|
|
178
|
+
|
|
179
|
+
# Show per-model cost breakdown
|
|
180
|
+
ccusage monthly --breakdown # Show cost breakdown by model
|
|
173
181
|
```
|
|
174
182
|
|
|
175
183
|
### Session Report
|
|
@@ -197,6 +205,9 @@ ccusage session --mode display # Always show pre-calculated costUSD values
|
|
|
197
205
|
# Control sort order
|
|
198
206
|
ccusage session --order asc # Show oldest sessions first
|
|
199
207
|
ccusage session --order desc # Show newest sessions first (default)
|
|
208
|
+
|
|
209
|
+
# Show per-model cost breakdown
|
|
210
|
+
ccusage session --breakdown # Show cost breakdown by model
|
|
200
211
|
```
|
|
201
212
|
|
|
202
213
|
### Options
|
|
@@ -209,6 +220,7 @@ All commands support the following options:
|
|
|
209
220
|
- `-j, --json`: Output results in JSON format instead of table
|
|
210
221
|
- `-m, --mode <mode>`: Cost calculation mode: `auto` (default), `calculate`, or `display`
|
|
211
222
|
- `-o, --order <order>`: Sort order: `desc` (newest first, default) or `asc` (oldest first).
|
|
223
|
+
- `-b, --breakdown`: Show per-model cost breakdown (splits usage by Opus, Sonnet, etc.)
|
|
212
224
|
- `-d, --debug`: Show pricing mismatch information for debugging
|
|
213
225
|
- `--debug-samples <number>`: Number of sample discrepancies to show in debug output (default: 5)
|
|
214
226
|
- `-h, --help`: Display help message
|
|
@@ -295,15 +307,37 @@ After adding this configuration, restart Claude Desktop. You'll then be able to
|
|
|
295
307
|
│ │
|
|
296
308
|
╰──────────────────────────────────────────╯
|
|
297
309
|
|
|
298
|
-
|
|
299
|
-
│ Date │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │
|
|
300
|
-
|
|
301
|
-
│ 2025-05-30 │ 277 │ 31,456 │ 512 │ 1,024 │ 33,269 │ $17.58 │
|
|
302
|
-
│ 2025-05-29 │ 959 │ 39,662 │ 256 │ 768 │ 41,645 │ $16.42 │
|
|
303
|
-
│ 2025-05-28 │ 155 │ 21,693 │ 128 │ 512 │ 22,488 │ $8.36 │
|
|
304
|
-
|
|
305
|
-
│ Total │ 11,174 │ 720,366 │ 896 │ 2,304 │ 734,740 │ $336.47 │
|
|
306
|
-
|
|
310
|
+
┌──────────────┬──────────────────┬────────┬─────────┬──────────────┬────────────┬──────────────┬────────────┐
|
|
311
|
+
│ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │
|
|
312
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
313
|
+
│ 2025-05-30 │ opus-4, sonnet-4 │ 277 │ 31,456 │ 512 │ 1,024 │ 33,269 │ $17.58 │
|
|
314
|
+
│ 2025-05-29 │ sonnet-4 │ 959 │ 39,662 │ 256 │ 768 │ 41,645 │ $16.42 │
|
|
315
|
+
│ 2025-05-28 │ opus-4 │ 155 │ 21,693 │ 128 │ 512 │ 22,488 │ $8.36 │
|
|
316
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
317
|
+
│ Total │ │ 11,174 │ 720,366 │ 896 │ 2,304 │ 734,740 │ $336.47 │
|
|
318
|
+
└──────────────┴──────────────────┴────────┴─────────┴──────────────┴────────────┴──────────────┴────────────┘
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
With `--breakdown` flag:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
╭──────────────────────────────────────────╮
|
|
325
|
+
│ │
|
|
326
|
+
│ Claude Code Token Usage Report - Daily │
|
|
327
|
+
│ │
|
|
328
|
+
╰──────────────────────────────────────────╯
|
|
329
|
+
|
|
330
|
+
┌──────────────┬──────────────────┬────────┬─────────┬──────────────┬────────────┬──────────────┬────────────┐
|
|
331
|
+
│ Date │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │
|
|
332
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
333
|
+
│ 2025-05-30 │ opus-4, sonnet-4 │ 277 │ 31,456 │ 512 │ 1,024 │ 33,269 │ $17.58 │
|
|
334
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
335
|
+
│ └─ opus-4 │ │ 100 │ 15,000 │ 256 │ 512 │ 15,868 │ $10.25 │
|
|
336
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
337
|
+
│ └─ sonnet-4│ │ 177 │ 16,456 │ 256 │ 512 │ 17,401 │ $7.33 │
|
|
338
|
+
├──────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┤
|
|
339
|
+
│ Total │ │ 11,174 │ 720,366 │ 896 │ 2,304 │ 734,740 │ $336.47 │
|
|
340
|
+
└──────────────┴──────────────────┴────────┴─────────┴──────────────┴────────────┴──────────────┴────────────┘
|
|
307
341
|
```
|
|
308
342
|
|
|
309
343
|
### Session Report
|
|
@@ -315,15 +349,15 @@ After adding this configuration, restart Claude Desktop. You'll then be able to
|
|
|
315
349
|
│ │
|
|
316
350
|
╰───────────────────────────────────────────────╯
|
|
317
351
|
|
|
318
|
-
|
|
319
|
-
│ Project │ Session │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ Last Activity │
|
|
320
|
-
|
|
321
|
-
│ myproject │ session-1 │ 4,512 │ 350,846 │ 512 │ 1,024 │ 356,894 │ $156.40 │ 2025-05-24 │
|
|
322
|
-
|
|
323
|
-
│ myproject │ session-2 │ 2,775 │ 186,645 │ 256 │ 768 │ 190,444 │ $98.45 │ 2025-05-25 │
|
|
324
|
-
|
|
325
|
-
│ Total │ │ 11,174 │ 720,445 │ 768 │ 1,792 │ 734,179 │ $336.68 │ │
|
|
326
|
-
|
|
352
|
+
┌─────────────┬────────────┬──────────────────┬────────┬─────────┬──────────────┬────────────┬──────────────┬────────────┬───────────────┐
|
|
353
|
+
│ Project │ Session │ Models │ Input │ Output │ Cache Create │ Cache Read │ Total Tokens │ Cost (USD) │ Last Activity │
|
|
354
|
+
├─────────────┼────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
355
|
+
│ myproject │ session-1 │ opus-4, sonnet-4 │ 4,512 │ 350,846 │ 512 │ 1,024 │ 356,894 │ $156.40 │ 2025-05-24 │
|
|
356
|
+
├─────────────┼────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
357
|
+
│ myproject │ session-2 │ sonnet-4 │ 2,775 │ 186,645 │ 256 │ 768 │ 190,444 │ $98.45 │ 2025-05-25 │
|
|
358
|
+
├─────────────┼────────────┼──────────────────┼────────┼─────────┼──────────────┼────────────┼──────────────┼────────────┼───────────────┤
|
|
359
|
+
│ Total │ │ │ 11,174 │ 720,445 │ 768 │ 1,792 │ 734,179 │ $336.68 │ │
|
|
360
|
+
└─────────────┴────────────┴──────────────────┴────────┴─────────┴──────────────┴────────────┴──────────────┴────────────┴───────────────┘
|
|
327
361
|
```
|
|
328
362
|
|
|
329
363
|
## Requirements
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { array, number, object, optional, pipe, regex, safeParse, string } from "./dist-BEQ1tJCL.js";
|
|
2
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
2
|
+
import { PricingFetcher } from "./pricing-fetcher-CAeJvZnF.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -2496,7 +2496,7 @@ var require_picomatch$1 = __commonJS({ "node_modules/picomatch/lib/picomatch.js"
|
|
|
2496
2496
|
* @api public
|
|
2497
2497
|
*/
|
|
2498
2498
|
picomatch$2.parse = (pattern, options) => {
|
|
2499
|
-
if (Array.isArray(pattern)) return pattern.map((p) => picomatch$2.parse(p, options));
|
|
2499
|
+
if (Array.isArray(pattern)) return pattern.map((p$1) => picomatch$2.parse(p$1, options));
|
|
2500
2500
|
return parse(pattern, {
|
|
2501
2501
|
...options,
|
|
2502
2502
|
fastpaths: false
|
|
@@ -2793,7 +2793,7 @@ var require_dist$1 = __commonJS({ "node_modules/fdir/dist/index.js"(exports) {
|
|
|
2793
2793
|
o[k2] = m[k];
|
|
2794
2794
|
});
|
|
2795
2795
|
var __exportStar = void 0 && (void 0).__exportStar || function(m, exports$1) {
|
|
2796
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
2796
|
+
for (var p$1 in m) if (p$1 !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p$1)) __createBinding(exports$1, m, p$1);
|
|
2797
2797
|
};
|
|
2798
2798
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2799
2799
|
exports.fdir = void 0;
|
|
@@ -2973,20 +2973,20 @@ function crawl(options, cwd, sync$1) {
|
|
|
2973
2973
|
nocase
|
|
2974
2974
|
});
|
|
2975
2975
|
const fdirOptions = {
|
|
2976
|
-
filters: [options.debug ? (p, isDirectory) => {
|
|
2977
|
-
const path$1$1 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
|
2976
|
+
filters: [options.debug ? (p$1, isDirectory) => {
|
|
2977
|
+
const path$1$1 = processPath(p$1, cwd, props.root, isDirectory, options.absolute);
|
|
2978
2978
|
const matches = matcher(path$1$1);
|
|
2979
2979
|
if (matches) log(`matched ${path$1$1}`);
|
|
2980
2980
|
return matches;
|
|
2981
|
-
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))],
|
|
2982
|
-
exclude: options.debug ? (_, p) => {
|
|
2983
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
2981
|
+
} : (p$1, isDirectory) => matcher(processPath(p$1, cwd, props.root, isDirectory, options.absolute))],
|
|
2982
|
+
exclude: options.debug ? (_, p$1) => {
|
|
2983
|
+
const relativePath = processPath(p$1, cwd, props.root, true, true);
|
|
2984
2984
|
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2985
|
-
if (skipped) log(`skipped ${p}`);
|
|
2986
|
-
else log(`crawling ${p}`);
|
|
2985
|
+
if (skipped) log(`skipped ${p$1}`);
|
|
2986
|
+
else log(`crawling ${p$1}`);
|
|
2987
2987
|
return skipped;
|
|
2988
|
-
} : (_, p) => {
|
|
2989
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
2988
|
+
} : (_, p$1) => {
|
|
2989
|
+
const relativePath = processPath(p$1, cwd, props.root, true, true);
|
|
2990
2990
|
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2991
2991
|
},
|
|
2992
2992
|
pathSeparator: "/",
|
|
@@ -3024,8 +3024,78 @@ async function glob(patternsOrOptions, options) {
|
|
|
3024
3024
|
return crawl(opts, cwd, false);
|
|
3025
3025
|
}
|
|
3026
3026
|
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region node_modules/picocolors/picocolors.js
|
|
3029
|
+
var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(exports, module) {
|
|
3030
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
3031
|
+
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);
|
|
3032
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
3033
|
+
let string$1 = "" + input, index = string$1.indexOf(close, open.length);
|
|
3034
|
+
return ~index ? open + replaceClose(string$1, close, replace, index) + close : open + string$1 + close;
|
|
3035
|
+
};
|
|
3036
|
+
let replaceClose = (string$1, close, replace, index) => {
|
|
3037
|
+
let result = "", cursor = 0;
|
|
3038
|
+
do {
|
|
3039
|
+
result += string$1.substring(cursor, index) + replace;
|
|
3040
|
+
cursor = index + close.length;
|
|
3041
|
+
index = string$1.indexOf(close, cursor);
|
|
3042
|
+
} while (~index);
|
|
3043
|
+
return result + string$1.substring(cursor);
|
|
3044
|
+
};
|
|
3045
|
+
let createColors = (enabled = isColorSupported) => {
|
|
3046
|
+
let f = enabled ? formatter : () => String;
|
|
3047
|
+
return {
|
|
3048
|
+
isColorSupported: enabled,
|
|
3049
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
3050
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
3051
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
3052
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
3053
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
3054
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
3055
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
3056
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
3057
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
3058
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
3059
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
3060
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
3061
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
3062
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
3063
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
3064
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
3065
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
3066
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
3067
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
3068
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
3069
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
3070
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
3071
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
3072
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
3073
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
3074
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
3075
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
3076
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
3077
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
3078
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
3079
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
3080
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
3081
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
3082
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
3083
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
3084
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
3085
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
3086
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
3087
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
3088
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
3089
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
3090
|
+
};
|
|
3091
|
+
};
|
|
3092
|
+
module.exports = createColors();
|
|
3093
|
+
module.exports.createColors = createColors;
|
|
3094
|
+
} });
|
|
3095
|
+
|
|
3027
3096
|
//#endregion
|
|
3028
3097
|
//#region src/utils.internal.ts
|
|
3098
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
3029
3099
|
function formatNumber(num) {
|
|
3030
3100
|
return num.toLocaleString("en-US");
|
|
3031
3101
|
}
|
|
@@ -3043,6 +3113,32 @@ function groupBy(array$1, keyFn) {
|
|
|
3043
3113
|
return groups;
|
|
3044
3114
|
}, {});
|
|
3045
3115
|
}
|
|
3116
|
+
function formatModelName(modelName) {
|
|
3117
|
+
const match = modelName.match(/claude-(\w+)-(\d+)-\d+/);
|
|
3118
|
+
if (match != null) return `${match[1]}-${match[2]}`;
|
|
3119
|
+
return modelName;
|
|
3120
|
+
}
|
|
3121
|
+
function formatModelsDisplay(models) {
|
|
3122
|
+
const uniqueModels = [...new Set(models.map(formatModelName))];
|
|
3123
|
+
return uniqueModels.sort().join(", ");
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* Pushes model breakdown rows to a table
|
|
3127
|
+
* @param table - The table to push rows to
|
|
3128
|
+
* @param breakdowns - Array of model breakdowns
|
|
3129
|
+
* @param extraColumns - Number of extra empty columns before the data (default: 1 for models column)
|
|
3130
|
+
* @param trailingColumns - Number of extra empty columns after the data (default: 0)
|
|
3131
|
+
*/
|
|
3132
|
+
function pushBreakdownRows(table, breakdowns, extraColumns = 1, trailingColumns = 0) {
|
|
3133
|
+
for (const breakdown of breakdowns) {
|
|
3134
|
+
const row = [` └─ ${formatModelName(breakdown.modelName)}`];
|
|
3135
|
+
for (let i = 0; i < extraColumns; i++) row.push("");
|
|
3136
|
+
const totalTokens = breakdown.inputTokens + breakdown.outputTokens + breakdown.cacheCreationTokens + breakdown.cacheReadTokens;
|
|
3137
|
+
row.push(import_picocolors.default.gray(formatNumber(breakdown.inputTokens)), import_picocolors.default.gray(formatNumber(breakdown.outputTokens)), import_picocolors.default.gray(formatNumber(breakdown.cacheCreationTokens)), import_picocolors.default.gray(formatNumber(breakdown.cacheReadTokens)), import_picocolors.default.gray(formatNumber(totalTokens)), import_picocolors.default.gray(formatCurrency(breakdown.cost)));
|
|
3138
|
+
for (let i = 0; i < trailingColumns; i++) row.push("");
|
|
3139
|
+
table.push(row);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3046
3142
|
|
|
3047
3143
|
//#endregion
|
|
3048
3144
|
//#region node_modules/rolldown/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
|
@@ -3124,13 +3220,23 @@ const UsageDataSchema = object({
|
|
|
3124
3220
|
}),
|
|
3125
3221
|
costUSD: optional(number())
|
|
3126
3222
|
});
|
|
3223
|
+
const ModelBreakdownSchema = object({
|
|
3224
|
+
modelName: string(),
|
|
3225
|
+
inputTokens: number(),
|
|
3226
|
+
outputTokens: number(),
|
|
3227
|
+
cacheCreationTokens: number(),
|
|
3228
|
+
cacheReadTokens: number(),
|
|
3229
|
+
cost: number()
|
|
3230
|
+
});
|
|
3127
3231
|
const DailyUsageSchema = object({
|
|
3128
3232
|
date: pipe(string(), regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
3129
3233
|
inputTokens: number(),
|
|
3130
3234
|
outputTokens: number(),
|
|
3131
3235
|
cacheCreationTokens: number(),
|
|
3132
3236
|
cacheReadTokens: number(),
|
|
3133
|
-
totalCost: number()
|
|
3237
|
+
totalCost: number(),
|
|
3238
|
+
modelsUsed: array(string()),
|
|
3239
|
+
modelBreakdowns: array(ModelBreakdownSchema)
|
|
3134
3240
|
});
|
|
3135
3241
|
const SessionUsageSchema = object({
|
|
3136
3242
|
sessionId: string(),
|
|
@@ -3141,7 +3247,9 @@ const SessionUsageSchema = object({
|
|
|
3141
3247
|
cacheReadTokens: number(),
|
|
3142
3248
|
totalCost: number(),
|
|
3143
3249
|
lastActivity: string(),
|
|
3144
|
-
versions: array(string())
|
|
3250
|
+
versions: array(string()),
|
|
3251
|
+
modelsUsed: array(string()),
|
|
3252
|
+
modelBreakdowns: array(ModelBreakdownSchema)
|
|
3145
3253
|
});
|
|
3146
3254
|
const MonthlyUsageSchema = object({
|
|
3147
3255
|
month: pipe(string(), regex(/^\d{4}-\d{2}$/)),
|
|
@@ -3149,7 +3257,9 @@ const MonthlyUsageSchema = object({
|
|
|
3149
3257
|
outputTokens: number(),
|
|
3150
3258
|
cacheCreationTokens: number(),
|
|
3151
3259
|
cacheReadTokens: number(),
|
|
3152
|
-
totalCost: number()
|
|
3260
|
+
totalCost: number(),
|
|
3261
|
+
modelsUsed: array(string()),
|
|
3262
|
+
modelBreakdowns: array(ModelBreakdownSchema)
|
|
3153
3263
|
});
|
|
3154
3264
|
function formatDate(dateStr) {
|
|
3155
3265
|
const date = new Date(dateStr);
|
|
@@ -3197,28 +3307,57 @@ async function loadDailyUsageData(options) {
|
|
|
3197
3307
|
allEntries.push({
|
|
3198
3308
|
data,
|
|
3199
3309
|
date,
|
|
3200
|
-
cost
|
|
3310
|
+
cost,
|
|
3311
|
+
model: data.message.model
|
|
3201
3312
|
});
|
|
3202
3313
|
} catch {}
|
|
3203
3314
|
}
|
|
3204
3315
|
const groupedByDate = groupBy(allEntries, (entry) => entry.date);
|
|
3205
3316
|
const results = Object.entries(groupedByDate).map(([date, entries]) => {
|
|
3206
3317
|
if (entries == null) return void 0;
|
|
3207
|
-
|
|
3208
|
-
|
|
3318
|
+
const modelAggregates = /* @__PURE__ */ new Map();
|
|
3319
|
+
for (const entry of entries) {
|
|
3320
|
+
const modelName = entry.model ?? "unknown";
|
|
3321
|
+
if (modelName === "<synthetic>") continue;
|
|
3322
|
+
const existing = modelAggregates.get(modelName) ?? {
|
|
3323
|
+
inputTokens: 0,
|
|
3324
|
+
outputTokens: 0,
|
|
3325
|
+
cacheCreationTokens: 0,
|
|
3326
|
+
cacheReadTokens: 0,
|
|
3327
|
+
cost: 0
|
|
3328
|
+
};
|
|
3329
|
+
modelAggregates.set(modelName, {
|
|
3330
|
+
inputTokens: existing.inputTokens + (entry.data.message.usage.input_tokens ?? 0),
|
|
3331
|
+
outputTokens: existing.outputTokens + (entry.data.message.usage.output_tokens ?? 0),
|
|
3332
|
+
cacheCreationTokens: existing.cacheCreationTokens + (entry.data.message.usage.cache_creation_input_tokens ?? 0),
|
|
3333
|
+
cacheReadTokens: existing.cacheReadTokens + (entry.data.message.usage.cache_read_input_tokens ?? 0),
|
|
3334
|
+
cost: existing.cost + entry.cost
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
const modelBreakdowns = Array.from(modelAggregates.entries()).map(([modelName, stats]) => ({
|
|
3338
|
+
modelName,
|
|
3339
|
+
...stats
|
|
3340
|
+
})).sort((a, b) => b.cost - a.cost);
|
|
3341
|
+
const totals = entries.reduce((acc, entry) => ({
|
|
3209
3342
|
inputTokens: acc.inputTokens + (entry.data.message.usage.input_tokens ?? 0),
|
|
3210
3343
|
outputTokens: acc.outputTokens + (entry.data.message.usage.output_tokens ?? 0),
|
|
3211
3344
|
cacheCreationTokens: acc.cacheCreationTokens + (entry.data.message.usage.cache_creation_input_tokens ?? 0),
|
|
3212
3345
|
cacheReadTokens: acc.cacheReadTokens + (entry.data.message.usage.cache_read_input_tokens ?? 0),
|
|
3213
3346
|
totalCost: acc.totalCost + entry.cost
|
|
3214
3347
|
}), {
|
|
3215
|
-
date,
|
|
3216
3348
|
inputTokens: 0,
|
|
3217
3349
|
outputTokens: 0,
|
|
3218
3350
|
cacheCreationTokens: 0,
|
|
3219
3351
|
cacheReadTokens: 0,
|
|
3220
3352
|
totalCost: 0
|
|
3221
3353
|
});
|
|
3354
|
+
const modelsUsed = [...new Set(entries.map((e) => e.model).filter((m) => m != null && m !== "<synthetic>"))];
|
|
3355
|
+
return {
|
|
3356
|
+
date,
|
|
3357
|
+
...totals,
|
|
3358
|
+
modelsUsed,
|
|
3359
|
+
modelBreakdowns
|
|
3360
|
+
};
|
|
3222
3361
|
}).filter((item) => item != null).filter((item) => {
|
|
3223
3362
|
if (options?.since != null || options?.until != null) {
|
|
3224
3363
|
const dateStr = item.date.replace(/-/g, "");
|
|
@@ -3274,7 +3413,8 @@ async function loadSessionData(options) {
|
|
|
3274
3413
|
sessionId,
|
|
3275
3414
|
projectPath,
|
|
3276
3415
|
cost,
|
|
3277
|
-
timestamp: data.timestamp
|
|
3416
|
+
timestamp: data.timestamp,
|
|
3417
|
+
model: data.message.model
|
|
3278
3418
|
});
|
|
3279
3419
|
} catch {}
|
|
3280
3420
|
}
|
|
@@ -3284,28 +3424,52 @@ async function loadSessionData(options) {
|
|
|
3284
3424
|
const latestEntry = entries.reduce((latest, current) => current.timestamp > latest.timestamp ? current : latest);
|
|
3285
3425
|
const versionSet = /* @__PURE__ */ new Set();
|
|
3286
3426
|
for (const entry of entries) if (entry.data.version != null) versionSet.add(entry.data.version);
|
|
3287
|
-
const
|
|
3288
|
-
|
|
3289
|
-
|
|
3427
|
+
const modelAggregates = /* @__PURE__ */ new Map();
|
|
3428
|
+
for (const entry of entries) {
|
|
3429
|
+
const modelName = entry.model ?? "unknown";
|
|
3430
|
+
if (modelName === "<synthetic>") continue;
|
|
3431
|
+
const existing = modelAggregates.get(modelName) ?? {
|
|
3432
|
+
inputTokens: 0,
|
|
3433
|
+
outputTokens: 0,
|
|
3434
|
+
cacheCreationTokens: 0,
|
|
3435
|
+
cacheReadTokens: 0,
|
|
3436
|
+
cost: 0
|
|
3437
|
+
};
|
|
3438
|
+
modelAggregates.set(modelName, {
|
|
3439
|
+
inputTokens: existing.inputTokens + (entry.data.message.usage.input_tokens ?? 0),
|
|
3440
|
+
outputTokens: existing.outputTokens + (entry.data.message.usage.output_tokens ?? 0),
|
|
3441
|
+
cacheCreationTokens: existing.cacheCreationTokens + (entry.data.message.usage.cache_creation_input_tokens ?? 0),
|
|
3442
|
+
cacheReadTokens: existing.cacheReadTokens + (entry.data.message.usage.cache_read_input_tokens ?? 0),
|
|
3443
|
+
cost: existing.cost + entry.cost
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
const modelBreakdowns = Array.from(modelAggregates.entries()).map(([modelName, stats]) => ({
|
|
3447
|
+
modelName,
|
|
3448
|
+
...stats
|
|
3449
|
+
})).sort((a, b) => b.cost - a.cost);
|
|
3450
|
+
const totals = entries.reduce((acc, entry) => ({
|
|
3290
3451
|
inputTokens: acc.inputTokens + (entry.data.message.usage.input_tokens ?? 0),
|
|
3291
3452
|
outputTokens: acc.outputTokens + (entry.data.message.usage.output_tokens ?? 0),
|
|
3292
3453
|
cacheCreationTokens: acc.cacheCreationTokens + (entry.data.message.usage.cache_creation_input_tokens ?? 0),
|
|
3293
3454
|
cacheReadTokens: acc.cacheReadTokens + (entry.data.message.usage.cache_read_input_tokens ?? 0),
|
|
3294
|
-
totalCost: acc.totalCost + entry.cost
|
|
3295
|
-
lastActivity: formatDate(latestEntry.timestamp),
|
|
3296
|
-
versions: Array.from(versionSet).sort()
|
|
3455
|
+
totalCost: acc.totalCost + entry.cost
|
|
3297
3456
|
}), {
|
|
3298
|
-
sessionId: latestEntry.sessionId,
|
|
3299
|
-
projectPath: latestEntry.projectPath,
|
|
3300
3457
|
inputTokens: 0,
|
|
3301
3458
|
outputTokens: 0,
|
|
3302
3459
|
cacheCreationTokens: 0,
|
|
3303
3460
|
cacheReadTokens: 0,
|
|
3304
|
-
totalCost: 0
|
|
3305
|
-
lastActivity: formatDate(latestEntry.timestamp),
|
|
3306
|
-
versions: Array.from(versionSet).sort()
|
|
3461
|
+
totalCost: 0
|
|
3307
3462
|
});
|
|
3308
|
-
|
|
3463
|
+
const modelsUsed = [...new Set(entries.map((e) => e.model).filter((m) => m != null && m !== "<synthetic>"))];
|
|
3464
|
+
return {
|
|
3465
|
+
sessionId: latestEntry.sessionId,
|
|
3466
|
+
projectPath: latestEntry.projectPath,
|
|
3467
|
+
...totals,
|
|
3468
|
+
lastActivity: formatDate(latestEntry.timestamp),
|
|
3469
|
+
versions: Array.from(versionSet).sort(),
|
|
3470
|
+
modelsUsed,
|
|
3471
|
+
modelBreakdowns
|
|
3472
|
+
};
|
|
3309
3473
|
}).filter((item) => item != null).filter((item) => {
|
|
3310
3474
|
if (options?.since != null || options?.until != null) {
|
|
3311
3475
|
const dateStr = item.lastActivity.replace(/-/g, "");
|
|
@@ -3326,28 +3490,61 @@ async function loadSessionData(options) {
|
|
|
3326
3490
|
async function loadMonthlyUsageData(options) {
|
|
3327
3491
|
const dailyData = await loadDailyUsageData(options);
|
|
3328
3492
|
const groupedByMonth = groupBy(dailyData, (data) => data.date.substring(0, 7));
|
|
3329
|
-
const monthlyArray =
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3493
|
+
const monthlyArray = [];
|
|
3494
|
+
for (const [month, dailyEntries] of Object.entries(groupedByMonth)) {
|
|
3495
|
+
if (dailyEntries == null) continue;
|
|
3496
|
+
const modelAggregates = /* @__PURE__ */ new Map();
|
|
3497
|
+
for (const daily of dailyEntries) for (const breakdown of daily.modelBreakdowns) {
|
|
3498
|
+
if (breakdown.modelName === "<synthetic>") continue;
|
|
3499
|
+
const existing = modelAggregates.get(breakdown.modelName) ?? {
|
|
3500
|
+
inputTokens: 0,
|
|
3501
|
+
outputTokens: 0,
|
|
3502
|
+
cacheCreationTokens: 0,
|
|
3503
|
+
cacheReadTokens: 0,
|
|
3504
|
+
cost: 0
|
|
3505
|
+
};
|
|
3506
|
+
modelAggregates.set(breakdown.modelName, {
|
|
3507
|
+
inputTokens: existing.inputTokens + breakdown.inputTokens,
|
|
3508
|
+
outputTokens: existing.outputTokens + breakdown.outputTokens,
|
|
3509
|
+
cacheCreationTokens: existing.cacheCreationTokens + breakdown.cacheCreationTokens,
|
|
3510
|
+
cacheReadTokens: existing.cacheReadTokens + breakdown.cacheReadTokens,
|
|
3511
|
+
cost: existing.cost + breakdown.cost
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
const modelBreakdowns = Array.from(modelAggregates.entries()).map(([modelName, stats]) => ({
|
|
3515
|
+
modelName,
|
|
3516
|
+
...stats
|
|
3517
|
+
})).sort((a, b) => b.cost - a.cost);
|
|
3518
|
+
const modelsSet = /* @__PURE__ */ new Set();
|
|
3519
|
+
for (const data of dailyEntries) for (const model of data.modelsUsed) if (model !== "<synthetic>") modelsSet.add(model);
|
|
3520
|
+
let totalInputTokens = 0;
|
|
3521
|
+
let totalOutputTokens = 0;
|
|
3522
|
+
let totalCacheCreationTokens = 0;
|
|
3523
|
+
let totalCacheReadTokens = 0;
|
|
3524
|
+
let totalCost = 0;
|
|
3525
|
+
for (const daily of dailyEntries) {
|
|
3526
|
+
totalInputTokens += daily.inputTokens;
|
|
3527
|
+
totalOutputTokens += daily.outputTokens;
|
|
3528
|
+
totalCacheCreationTokens += daily.cacheCreationTokens;
|
|
3529
|
+
totalCacheReadTokens += daily.cacheReadTokens;
|
|
3530
|
+
totalCost += daily.totalCost;
|
|
3531
|
+
}
|
|
3532
|
+
const monthlyUsage = {
|
|
3339
3533
|
month,
|
|
3340
|
-
inputTokens:
|
|
3341
|
-
outputTokens:
|
|
3342
|
-
cacheCreationTokens:
|
|
3343
|
-
cacheReadTokens:
|
|
3344
|
-
totalCost
|
|
3345
|
-
|
|
3346
|
-
|
|
3534
|
+
inputTokens: totalInputTokens,
|
|
3535
|
+
outputTokens: totalOutputTokens,
|
|
3536
|
+
cacheCreationTokens: totalCacheCreationTokens,
|
|
3537
|
+
cacheReadTokens: totalCacheReadTokens,
|
|
3538
|
+
totalCost,
|
|
3539
|
+
modelsUsed: Array.from(modelsSet),
|
|
3540
|
+
modelBreakdowns
|
|
3541
|
+
};
|
|
3542
|
+
monthlyArray.push(monthlyUsage);
|
|
3543
|
+
}
|
|
3347
3544
|
const sortOrder = options?.order ?? "desc";
|
|
3348
3545
|
const sortedMonthly = sort(monthlyArray);
|
|
3349
3546
|
return sortOrder === "desc" ? sortedMonthly.desc((item) => item.month) : sortedMonthly.asc((item) => item.month);
|
|
3350
3547
|
}
|
|
3351
3548
|
|
|
3352
3549
|
//#endregion
|
|
3353
|
-
export { DailyUsageSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, __commonJS, __require, __toESM, calculateCostForEntry, formatCurrency, formatDate, formatNumber, getDefaultClaudePath, glob, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, require_usingCtx };
|
|
3550
|
+
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, __commonJS, __require, __toESM, calculateCostForEntry, formatCurrency, formatDate, formatModelsDisplay, formatNumber, getDefaultClaudePath, glob, loadDailyUsageData, loadMonthlyUsageData, loadSessionData, pushBreakdownRows, require_picocolors, require_usingCtx };
|
|
@@ -96,6 +96,15 @@ declare const UsageDataSchema: ObjectSchema<{
|
|
|
96
96
|
readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
97
97
|
}, undefined>;
|
|
98
98
|
type UsageData = InferOutput<typeof UsageDataSchema>;
|
|
99
|
+
declare const ModelBreakdownSchema: ObjectSchema<{
|
|
100
|
+
readonly modelName: StringSchema<undefined>;
|
|
101
|
+
readonly inputTokens: NumberSchema<undefined>;
|
|
102
|
+
readonly outputTokens: NumberSchema<undefined>;
|
|
103
|
+
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
104
|
+
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
105
|
+
readonly cost: NumberSchema<undefined>;
|
|
106
|
+
}, undefined>;
|
|
107
|
+
type ModelBreakdown = InferOutput<typeof ModelBreakdownSchema>;
|
|
99
108
|
declare const DailyUsageSchema: ObjectSchema<{
|
|
100
109
|
readonly date: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
|
|
101
110
|
readonly inputTokens: NumberSchema<undefined>;
|
|
@@ -103,6 +112,15 @@ declare const DailyUsageSchema: ObjectSchema<{
|
|
|
103
112
|
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
104
113
|
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
105
114
|
readonly totalCost: NumberSchema<undefined>;
|
|
115
|
+
readonly modelsUsed: ArraySchema<StringSchema<undefined>, undefined>;
|
|
116
|
+
readonly modelBreakdowns: ArraySchema<ObjectSchema<{
|
|
117
|
+
readonly modelName: StringSchema<undefined>;
|
|
118
|
+
readonly inputTokens: NumberSchema<undefined>;
|
|
119
|
+
readonly outputTokens: NumberSchema<undefined>;
|
|
120
|
+
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
121
|
+
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
122
|
+
readonly cost: NumberSchema<undefined>;
|
|
123
|
+
}, undefined>, undefined>;
|
|
106
124
|
}, undefined>;
|
|
107
125
|
type DailyUsage = InferOutput<typeof DailyUsageSchema>;
|
|
108
126
|
declare const SessionUsageSchema: ObjectSchema<{
|
|
@@ -115,6 +133,15 @@ declare const SessionUsageSchema: ObjectSchema<{
|
|
|
115
133
|
readonly totalCost: NumberSchema<undefined>;
|
|
116
134
|
readonly lastActivity: StringSchema<undefined>;
|
|
117
135
|
readonly versions: ArraySchema<StringSchema<undefined>, undefined>;
|
|
136
|
+
readonly modelsUsed: ArraySchema<StringSchema<undefined>, undefined>;
|
|
137
|
+
readonly modelBreakdowns: ArraySchema<ObjectSchema<{
|
|
138
|
+
readonly modelName: StringSchema<undefined>;
|
|
139
|
+
readonly inputTokens: NumberSchema<undefined>;
|
|
140
|
+
readonly outputTokens: NumberSchema<undefined>;
|
|
141
|
+
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
142
|
+
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
143
|
+
readonly cost: NumberSchema<undefined>;
|
|
144
|
+
}, undefined>, undefined>;
|
|
118
145
|
}, undefined>;
|
|
119
146
|
type SessionUsage = InferOutput<typeof SessionUsageSchema>;
|
|
120
147
|
declare const MonthlyUsageSchema: ObjectSchema<{
|
|
@@ -124,6 +151,15 @@ declare const MonthlyUsageSchema: ObjectSchema<{
|
|
|
124
151
|
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
125
152
|
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
126
153
|
readonly totalCost: NumberSchema<undefined>;
|
|
154
|
+
readonly modelsUsed: ArraySchema<StringSchema<undefined>, undefined>;
|
|
155
|
+
readonly modelBreakdowns: ArraySchema<ObjectSchema<{
|
|
156
|
+
readonly modelName: StringSchema<undefined>;
|
|
157
|
+
readonly inputTokens: NumberSchema<undefined>;
|
|
158
|
+
readonly outputTokens: NumberSchema<undefined>;
|
|
159
|
+
readonly cacheCreationTokens: NumberSchema<undefined>;
|
|
160
|
+
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
161
|
+
readonly cost: NumberSchema<undefined>;
|
|
162
|
+
}, undefined>, undefined>;
|
|
127
163
|
}, undefined>;
|
|
128
164
|
type MonthlyUsage = InferOutput<typeof MonthlyUsageSchema>;
|
|
129
165
|
declare function formatDate(dateStr: string): string;
|
|
@@ -141,4 +177,4 @@ declare function loadDailyUsageData(options?: LoadOptions): Promise<DailyUsage[]
|
|
|
141
177
|
declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
|
|
142
178
|
declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsage[]>;
|
|
143
179
|
//#endregion
|
|
144
|
-
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
180
|
+
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-
|
|
1
|
+
import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-pCzn-ryX.js";
|
|
2
2
|
import "./pricing-fetcher-Dq-OLBp4.js";
|
|
3
|
-
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
3
|
+
export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, 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-
|
|
1
|
+
import { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData } from "./data-loader-nOFcMg_V.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
3
|
+
import "./logger-BPjA3VFO.js";
|
|
4
|
+
import "./pricing-fetcher-CAeJvZnF.js";
|
|
5
5
|
|
|
6
|
-
export { DailyUsageSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
6
|
+
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, formatDate, getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionData };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UsageDataSchema, __toESM, glob, require_usingCtx } from "./data-loader-
|
|
1
|
+
import { UsageDataSchema, __toESM, glob, require_usingCtx } from "./data-loader-nOFcMg_V.js";
|
|
2
2
|
import { safeParse } from "./dist-BEQ1tJCL.js";
|
|
3
|
-
import { logger } from "./logger-
|
|
4
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
3
|
+
import { logger } from "./logger-BPjA3VFO.js";
|
|
4
|
+
import { PricingFetcher } from "./pricing-fetcher-CAeJvZnF.js";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import path from "node:path";
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./data-loader-
|
|
1
|
+
import "./data-loader-nOFcMg_V.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
3
|
+
import "./logger-BPjA3VFO.js";
|
|
4
|
+
import "./pricing-fetcher-CAeJvZnF.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-Bttss7TN.js";
|
|
6
6
|
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-nOFcMg_V.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-BPjA3VFO.js";
|
|
6
|
+
import "./pricing-fetcher-CAeJvZnF.js";
|
|
7
|
+
import { detectMismatches, printMismatchReport } from "./debug-Bttss7TN.js";
|
|
8
|
+
import { CostModes, SortOrders, createMcpServer, dateSchema } from "./mcp-DCEVbd8C.js";
|
|
9
9
|
import "./types-DS8M8QF_.js";
|
|
10
10
|
import "./index-CISmcbXk-x9eVmhGM.js";
|
|
11
11
|
import g$1 from "node:process";
|
|
@@ -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 = {
|
|
@@ -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)),
|
|
@@ -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)),
|
|
@@ -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
|
]);
|
package/dist/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __commonJS, __require, __toESM, getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-
|
|
1
|
+
import { __commonJS, __require, __toESM, getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-nOFcMg_V.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-BPjA3VFO.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
6
|
import g$1 from "node:process";
|
package/dist/mcp.d.ts
CHANGED
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./data-loader-
|
|
1
|
+
import "./data-loader-nOFcMg_V.js";
|
|
2
2
|
import "./dist-BEQ1tJCL.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-
|
|
5
|
-
import { createMcpServer } from "./mcp-
|
|
3
|
+
import "./logger-BPjA3VFO.js";
|
|
4
|
+
import "./pricing-fetcher-CAeJvZnF.js";
|
|
5
|
+
import { createMcpServer } from "./mcp-DCEVbd8C.js";
|
|
6
6
|
import "./types-DS8M8QF_.js";
|
|
7
7
|
import "./index-CISmcbXk-x9eVmhGM.js";
|
|
8
8
|
|
package/dist/pricing-fetcher.js
CHANGED