ccusage 11.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +15 -0
- package/dist/calculate-cost.d.ts +26 -2
- package/dist/calculate-cost.js +1 -1
- package/dist/core-eFvU0K4V.js +698 -0
- package/dist/{data-loader-BAoqS297.js → data-loader-BzOeJe6y.js} +397 -222
- package/dist/{data-loader-DPQaq8_n.d.ts → data-loader-dbZm5kOW.d.ts} +116 -25
- package/dist/data-loader.d.ts +3 -3
- package/dist/data-loader.js +4 -4
- package/dist/{debug-DzFJHzM5.js → debug-CjjJciy1.js} +20 -7
- package/dist/debug.d.ts +17 -0
- package/dist/debug.js +4 -4
- package/dist/{effect-WSjEuzC9-DHMVzzyB.js → effect-WSjEuzC9-CZCpOgOT.js} +1 -1
- package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +1 -1
- package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +5 -5
- package/dist/index.js +1994 -51
- package/dist/{logger-D3WD64Tx.js → logger-E_Utl_fr.js} +8 -2
- package/dist/logger.d.ts +9 -4
- package/dist/logger.js +1 -1
- package/dist/{mcp-1J7r1g6-.js → mcp-SPAE-cNK.js} +7 -8
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -6
- package/dist/{pricing-fetcher-D-eJQBEJ.js → pricing-fetcher-BtW4MVG7.js} +159 -4
- package/dist/{pricing-fetcher-BkSZh4lR.d.ts → pricing-fetcher-DHaTs-k2.d.ts} +67 -2
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +2 -2
- package/dist/{sury-DmrZ3_Oj-Cpjsc2Lm.js → sury-DmrZ3_Oj-Lq7x0IZW.js} +1 -1
- package/dist/valibot-CQk-M5rL-btpzU8Qa.js +10 -0
- package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +3 -3
- package/package.json +1 -2
- package/dist/chunk-BLXvPPr8.js +0 -30
- package/dist/core-DHCbAXJf.js +0 -693
- package/dist/utils.table-USks3NGv.js +0 -1844
- package/dist/utils.table.d.ts +0 -27
- package/dist/utils.table.js +0 -3
- package/dist/valibot-CQk-M5rL-BcaCeUrF.js +0 -10
- /package/dist/{arktype-C-GObzDh-CNoBqQrr.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
- /package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +0 -0
- /package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +0 -0
- /package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { __commonJS, __require, __toESM } from "./
|
|
1
|
+
import { PricingFetcher, __commonJS, __require, __toESM, require_usingCtx } from "./pricing-fetcher-BtW4MVG7.js";
|
|
2
2
|
import { array, number, object, optional, pipe, regex, safeParse, string } from "./dist-DCvt9hEv.js";
|
|
3
|
-
import { logger } from "./logger-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { homedir } from "node:os";
|
|
3
|
+
import { logger } from "./logger-E_Utl_fr.js";
|
|
4
|
+
import a, { readFile } from "node:fs/promises";
|
|
5
|
+
import F, { homedir } from "node:os";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import process$1 from "node:process";
|
|
9
|
-
import
|
|
8
|
+
import b from "node:fs";
|
|
10
9
|
import path$1, { posix } from "path";
|
|
11
10
|
|
|
12
11
|
//#region node_modules/@jsr/core__unknownutil/is/string.js
|
|
@@ -70,19 +69,19 @@ const defaultThreshold = 20;
|
|
|
70
69
|
}
|
|
71
70
|
function inspectArray(value, options) {
|
|
72
71
|
const { threshold = defaultThreshold } = options;
|
|
73
|
-
const vs = value.map((v) => inspect(v, options));
|
|
72
|
+
const vs = value.map((v$1) => inspect(v$1, options));
|
|
74
73
|
const s = vs.join(", ");
|
|
75
74
|
if (s.length <= threshold) return `[${s}]`;
|
|
76
|
-
const m = vs.join(",\n");
|
|
77
|
-
return `[\n${indent(2, m)}\n]`;
|
|
75
|
+
const m$1 = vs.join(",\n");
|
|
76
|
+
return `[\n${indent(2, m$1)}\n]`;
|
|
78
77
|
}
|
|
79
78
|
function inspectRecord(value, options) {
|
|
80
79
|
const { threshold = defaultThreshold } = options;
|
|
81
|
-
const vs = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)].map((k) => `${k.toString()}: ${inspect(value[k], options)}`);
|
|
80
|
+
const vs = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)].map((k$1) => `${k$1.toString()}: ${inspect(value[k$1], options)}`);
|
|
82
81
|
const s = vs.join(", ");
|
|
83
82
|
if (s.length <= threshold) return `{${s}}`;
|
|
84
|
-
const m = vs.join(",\n");
|
|
85
|
-
return `{\n${indent(2, m)}\n}`;
|
|
83
|
+
const m$1 = vs.join(",\n");
|
|
84
|
+
return `{\n${indent(2, m$1)}\n}`;
|
|
86
85
|
}
|
|
87
86
|
function indent(level, text) {
|
|
88
87
|
const prefix = " ".repeat(level);
|
|
@@ -97,7 +96,7 @@ function indent(level, text) {
|
|
|
97
96
|
let cachedName;
|
|
98
97
|
return Object.defineProperties(fn, { name: { get: () => {
|
|
99
98
|
if (cachedName) return cachedName;
|
|
100
|
-
cachedName = `${name}(${args.map((v) => inspect(v)).join(", ")})`;
|
|
99
|
+
cachedName = `${name}(${args.map((v$1) => inspect(v$1)).join(", ")})`;
|
|
101
100
|
return cachedName;
|
|
102
101
|
} } });
|
|
103
102
|
}
|
|
@@ -141,10 +140,10 @@ function hasAnnotation(fn, name) {
|
|
|
141
140
|
* }
|
|
142
141
|
* ```
|
|
143
142
|
*/ function isObjectOf(predObj) {
|
|
144
|
-
const preds = [...Object.keys(predObj), ...Object.getOwnPropertySymbols(predObj)].map((k) => [k, predObj[k]]);
|
|
143
|
+
const preds = [...Object.keys(predObj), ...Object.getOwnPropertySymbols(predObj)].map((k$1) => [k$1, predObj[k$1]]);
|
|
145
144
|
const pred = rewriteName((x) => {
|
|
146
145
|
if (!isObject$1(x)) return false;
|
|
147
|
-
return preds.every(([k, pred$1]) => pred$1(x[k]));
|
|
146
|
+
return preds.every(([k$1, pred$1]) => pred$1(x[k$1]));
|
|
148
147
|
}, "isObjectOf", predObj);
|
|
149
148
|
return annotate(pred, "predObj", predObj);
|
|
150
149
|
}
|
|
@@ -280,8 +279,8 @@ function groupBy(arr, getKeyFromItem) {
|
|
|
280
279
|
//#endregion
|
|
281
280
|
//#region node_modules/fast-sort/dist/sort.mjs
|
|
282
281
|
var castComparer = function(comparer) {
|
|
283
|
-
return function(a, b, order) {
|
|
284
|
-
return comparer(a, b, order) * order;
|
|
282
|
+
return function(a$1, b$1, order) {
|
|
283
|
+
return comparer(a$1, b$1, order) * order;
|
|
285
284
|
};
|
|
286
285
|
};
|
|
287
286
|
var throwInvalidConfigErrorIfTrue = function(condition, context) {
|
|
@@ -301,41 +300,41 @@ var unpackObjectSorter = function(sortByObj) {
|
|
|
301
300
|
};
|
|
302
301
|
};
|
|
303
302
|
var multiPropertySorterProvider = function(defaultComparer$1) {
|
|
304
|
-
return function multiPropertySorter(sortBy, sortByArr, depth$1, order, comparer, a, b) {
|
|
303
|
+
return function multiPropertySorter(sortBy, sortByArr, depth$1, order, comparer, a$1, b$1) {
|
|
305
304
|
var valA;
|
|
306
305
|
var valB;
|
|
307
306
|
if (typeof sortBy === "string") {
|
|
308
|
-
valA = a[sortBy];
|
|
309
|
-
valB = b[sortBy];
|
|
307
|
+
valA = a$1[sortBy];
|
|
308
|
+
valB = b$1[sortBy];
|
|
310
309
|
} else if (typeof sortBy === "function") {
|
|
311
|
-
valA = sortBy(a);
|
|
312
|
-
valB = sortBy(b);
|
|
310
|
+
valA = sortBy(a$1);
|
|
311
|
+
valB = sortBy(b$1);
|
|
313
312
|
} else {
|
|
314
313
|
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
315
|
-
return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth$1, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer$1, a, b);
|
|
314
|
+
return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth$1, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer$1, a$1, b$1);
|
|
316
315
|
}
|
|
317
316
|
var equality = comparer(valA, valB, order);
|
|
318
|
-
if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth$1) return multiPropertySorter(sortByArr[depth$1], sortByArr, depth$1 + 1, order, comparer, a, b);
|
|
317
|
+
if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth$1) return multiPropertySorter(sortByArr[depth$1], sortByArr, depth$1 + 1, order, comparer, a$1, b$1);
|
|
319
318
|
return equality;
|
|
320
319
|
};
|
|
321
320
|
};
|
|
322
321
|
function getSortStrategy(sortBy, comparer, order) {
|
|
323
|
-
if (sortBy === void 0 || sortBy === true) return function(a, b) {
|
|
324
|
-
return comparer(a, b, order);
|
|
322
|
+
if (sortBy === void 0 || sortBy === true) return function(a$1, b$1) {
|
|
323
|
+
return comparer(a$1, b$1, order);
|
|
325
324
|
};
|
|
326
325
|
if (typeof sortBy === "string") {
|
|
327
326
|
throwInvalidConfigErrorIfTrue(sortBy.includes("."), "String syntax not allowed for nested properties.");
|
|
328
|
-
return function(a, b) {
|
|
329
|
-
return comparer(a[sortBy], b[sortBy], order);
|
|
327
|
+
return function(a$1, b$1) {
|
|
328
|
+
return comparer(a$1[sortBy], b$1[sortBy], order);
|
|
330
329
|
};
|
|
331
330
|
}
|
|
332
|
-
if (typeof sortBy === "function") return function(a, b) {
|
|
333
|
-
return comparer(sortBy(a), sortBy(b), order);
|
|
331
|
+
if (typeof sortBy === "function") return function(a$1, b$1) {
|
|
332
|
+
return comparer(sortBy(a$1), sortBy(b$1), order);
|
|
334
333
|
};
|
|
335
334
|
if (Array.isArray(sortBy)) {
|
|
336
335
|
var multiPropSorter_1 = multiPropertySorterProvider(comparer);
|
|
337
|
-
return function(a, b) {
|
|
338
|
-
return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);
|
|
336
|
+
return function(a$1, b$1) {
|
|
337
|
+
return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a$1, b$1);
|
|
339
338
|
};
|
|
340
339
|
}
|
|
341
340
|
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
@@ -364,12 +363,12 @@ function createNewSortInstance(opts) {
|
|
|
364
363
|
};
|
|
365
364
|
};
|
|
366
365
|
}
|
|
367
|
-
var defaultComparer = function(a, b, order) {
|
|
368
|
-
if (a == null) return order;
|
|
369
|
-
if (b == null) return -order;
|
|
370
|
-
if (typeof a !== typeof b) return typeof a < typeof b ? -1 : 1;
|
|
371
|
-
if (a < b) return -1;
|
|
372
|
-
if (a > b) return 1;
|
|
366
|
+
var defaultComparer = function(a$1, b$1, order) {
|
|
367
|
+
if (a$1 == null) return order;
|
|
368
|
+
if (b$1 == null) return -order;
|
|
369
|
+
if (typeof a$1 !== typeof b$1) return typeof a$1 < typeof b$1 ? -1 : 1;
|
|
370
|
+
if (a$1 < b$1) return -1;
|
|
371
|
+
if (a$1 > b$1) return 1;
|
|
373
372
|
return 0;
|
|
374
373
|
};
|
|
375
374
|
var sort = createNewSortInstance({ comparer: defaultComparer });
|
|
@@ -378,12 +377,138 @@ var inPlaceSort = createNewSortInstance({
|
|
|
378
377
|
inPlaceSorting: true
|
|
379
378
|
});
|
|
380
379
|
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region node_modules/fs-fixture/dist/index.mjs
|
|
382
|
+
var d = Object.defineProperty;
|
|
383
|
+
var n = (s, t) => d(s, "name", {
|
|
384
|
+
value: t,
|
|
385
|
+
configurable: !0
|
|
386
|
+
});
|
|
387
|
+
typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", {
|
|
388
|
+
configurable: !1,
|
|
389
|
+
enumerable: !1,
|
|
390
|
+
writable: !1,
|
|
391
|
+
value: Symbol.for("asyncDispose")
|
|
392
|
+
});
|
|
393
|
+
var P = class {
|
|
394
|
+
static {
|
|
395
|
+
n(this, "FsFixture");
|
|
396
|
+
}
|
|
397
|
+
path;
|
|
398
|
+
constructor(t) {
|
|
399
|
+
this.path = t;
|
|
400
|
+
}
|
|
401
|
+
getPath(...t) {
|
|
402
|
+
return path.join(this.path, ...t);
|
|
403
|
+
}
|
|
404
|
+
exists(t = "") {
|
|
405
|
+
return a.access(this.getPath(t)).then(() => !0, () => !1);
|
|
406
|
+
}
|
|
407
|
+
rm(t = "") {
|
|
408
|
+
return a.rm(this.getPath(t), {
|
|
409
|
+
recursive: !0,
|
|
410
|
+
force: !0
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
cp(t, r, i) {
|
|
414
|
+
return r ? r.endsWith(path.sep) && (r += path.basename(t)) : r = path.basename(t), a.cp(t, this.getPath(r), i);
|
|
415
|
+
}
|
|
416
|
+
mkdir(t) {
|
|
417
|
+
return a.mkdir(this.getPath(t), { recursive: !0 });
|
|
418
|
+
}
|
|
419
|
+
writeFile(t, r) {
|
|
420
|
+
return a.writeFile(this.getPath(t), r);
|
|
421
|
+
}
|
|
422
|
+
writeJson(t, r) {
|
|
423
|
+
return this.writeFile(t, JSON.stringify(r, null, 2));
|
|
424
|
+
}
|
|
425
|
+
readFile(t, r) {
|
|
426
|
+
return a.readFile(this.getPath(t), r);
|
|
427
|
+
}
|
|
428
|
+
async [Symbol.asyncDispose]() {
|
|
429
|
+
await this.rm();
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const v = b.realpathSync(F.tmpdir()), D = `fs-fixture-${Date.now()}-${process.pid}`;
|
|
433
|
+
let m = 0;
|
|
434
|
+
const j = n(() => (m += 1, m), "getId");
|
|
435
|
+
var u = class {
|
|
436
|
+
static {
|
|
437
|
+
n(this, "Path");
|
|
438
|
+
}
|
|
439
|
+
path;
|
|
440
|
+
constructor(t) {
|
|
441
|
+
this.path = t;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
var f = class extends u {
|
|
445
|
+
static {
|
|
446
|
+
n(this, "Directory");
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var y = class extends u {
|
|
450
|
+
static {
|
|
451
|
+
n(this, "File");
|
|
452
|
+
}
|
|
453
|
+
content;
|
|
454
|
+
constructor(t, r) {
|
|
455
|
+
super(t), this.content = r;
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
var l = class {
|
|
459
|
+
static {
|
|
460
|
+
n(this, "Symlink");
|
|
461
|
+
}
|
|
462
|
+
target;
|
|
463
|
+
type;
|
|
464
|
+
path;
|
|
465
|
+
constructor(t, r) {
|
|
466
|
+
this.target = t, this.type = r;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const w = n((s, t, r) => {
|
|
470
|
+
const i = [];
|
|
471
|
+
for (const p in s) {
|
|
472
|
+
if (!Object.hasOwn(s, p)) continue;
|
|
473
|
+
const e = path.join(t, p);
|
|
474
|
+
let o = s[p];
|
|
475
|
+
if (typeof o == "function") {
|
|
476
|
+
const g = Object.assign(Object.create(r), { filePath: e }), h = o(g);
|
|
477
|
+
if (h instanceof l) {
|
|
478
|
+
h.path = e, i.push(h);
|
|
479
|
+
continue;
|
|
480
|
+
} else o = h;
|
|
481
|
+
}
|
|
482
|
+
typeof o == "string" ? i.push(new y(e, o)) : i.push(new f(e), ...w(o, e, r));
|
|
483
|
+
}
|
|
484
|
+
return i;
|
|
485
|
+
}, "flattenFileTree"), k = n(async (s, t) => {
|
|
486
|
+
const r = t?.tempDir ? path.resolve(t.tempDir) : v, i = path.join(r, `${D}-${j()}/`);
|
|
487
|
+
if (await a.mkdir(i, { recursive: !0 }), s) {
|
|
488
|
+
if (typeof s == "string") await a.cp(s, i, {
|
|
489
|
+
recursive: !0,
|
|
490
|
+
filter: t?.templateFilter
|
|
491
|
+
});
|
|
492
|
+
else if (typeof s == "object") {
|
|
493
|
+
const p = {
|
|
494
|
+
fixturePath: i,
|
|
495
|
+
getPath: n((...e) => path.join(i, ...e), "getPath"),
|
|
496
|
+
symlink: n((e, o) => new l(e, o), "symlink")
|
|
497
|
+
};
|
|
498
|
+
await Promise.all(w(s, i, p).map(async (e) => {
|
|
499
|
+
e instanceof f ? await a.mkdir(e.path, { recursive: !0 }) : e instanceof l ? (await a.mkdir(path.dirname(e.path), { recursive: !0 }), await a.symlink(e.target, e.path, e.type)) : e instanceof y && (await a.mkdir(path.dirname(e.path), { recursive: !0 }), await a.writeFile(e.path, e.content));
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return new P(i);
|
|
504
|
+
}, "createFixture");
|
|
505
|
+
|
|
381
506
|
//#endregion
|
|
382
507
|
//#region node_modules/path-type/index.js
|
|
383
508
|
async function isType(fsStatType, statsMethodName, filePath) {
|
|
384
509
|
if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
385
510
|
try {
|
|
386
|
-
const stats = await
|
|
511
|
+
const stats = await a[fsStatType](filePath);
|
|
387
512
|
return stats[statsMethodName]();
|
|
388
513
|
} catch (error) {
|
|
389
514
|
if (error.code === "ENOENT") return false;
|
|
@@ -393,7 +518,7 @@ async function isType(fsStatType, statsMethodName, filePath) {
|
|
|
393
518
|
function isTypeSync(fsStatType, statsMethodName, filePath) {
|
|
394
519
|
if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
395
520
|
try {
|
|
396
|
-
return
|
|
521
|
+
return b[fsStatType](filePath)[statsMethodName]();
|
|
397
522
|
} catch (error) {
|
|
398
523
|
if (error.code === "ENOENT") return false;
|
|
399
524
|
throw error;
|
|
@@ -410,24 +535,24 @@ const isSymlinkSync = isTypeSync.bind(void 0, "lstatSync", "isSymbolicLink");
|
|
|
410
535
|
//#region node_modules/fdir/dist/utils.js
|
|
411
536
|
var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
412
537
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
413
|
-
exports.cleanPath =
|
|
414
|
-
exports.convertSlashes = convertSlashes;
|
|
415
|
-
exports.isRootDirectory = isRootDirectory;
|
|
416
|
-
exports.normalizePath = normalizePath;
|
|
538
|
+
exports.normalizePath = exports.isRootDirectory = exports.convertSlashes = exports.cleanPath = void 0;
|
|
417
539
|
const path_1$4 = __require("path");
|
|
418
540
|
function cleanPath(path$2) {
|
|
419
541
|
let normalized = (0, path_1$4.normalize)(path$2);
|
|
420
542
|
if (normalized.length > 1 && normalized[normalized.length - 1] === path_1$4.sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
421
543
|
return normalized;
|
|
422
544
|
}
|
|
545
|
+
exports.cleanPath = cleanPath;
|
|
423
546
|
const SLASHES_REGEX = /[\\/]/g;
|
|
424
547
|
function convertSlashes(path$2, separator) {
|
|
425
548
|
return path$2.replace(SLASHES_REGEX, separator);
|
|
426
549
|
}
|
|
550
|
+
exports.convertSlashes = convertSlashes;
|
|
427
551
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
428
552
|
function isRootDirectory(path$2) {
|
|
429
553
|
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
430
554
|
}
|
|
555
|
+
exports.isRootDirectory = isRootDirectory;
|
|
431
556
|
function normalizePath(path$2, options) {
|
|
432
557
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
433
558
|
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
@@ -437,20 +562,20 @@ var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
|
437
562
|
const needsSeperator = path$2[path$2.length - 1] !== pathSeparator;
|
|
438
563
|
return convertSlashes(needsSeperator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
439
564
|
}
|
|
565
|
+
exports.normalizePath = normalizePath;
|
|
440
566
|
} });
|
|
441
567
|
|
|
442
568
|
//#endregion
|
|
443
569
|
//#region node_modules/fdir/dist/api/functions/join-path.js
|
|
444
570
|
var require_join_path = __commonJS({ "node_modules/fdir/dist/api/functions/join-path.js"(exports) {
|
|
445
571
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
446
|
-
exports.joinPathWithBasePath =
|
|
447
|
-
exports.joinDirectoryPath = joinDirectoryPath;
|
|
448
|
-
exports.build = build$7;
|
|
572
|
+
exports.build = exports.joinDirectoryPath = exports.joinPathWithBasePath = void 0;
|
|
449
573
|
const path_1$3 = __require("path");
|
|
450
574
|
const utils_1$1 = require_utils$1();
|
|
451
575
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
452
576
|
return directoryPath + filename;
|
|
453
577
|
}
|
|
578
|
+
exports.joinPathWithBasePath = joinPathWithBasePath;
|
|
454
579
|
function joinPathWithRelativePath(root, options) {
|
|
455
580
|
return function(filename, directoryPath) {
|
|
456
581
|
const sameRoot = directoryPath.startsWith(root);
|
|
@@ -464,17 +589,19 @@ var require_join_path = __commonJS({ "node_modules/fdir/dist/api/functions/join-
|
|
|
464
589
|
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
465
590
|
return directoryPath + filename + separator;
|
|
466
591
|
}
|
|
592
|
+
exports.joinDirectoryPath = joinDirectoryPath;
|
|
467
593
|
function build$7(root, options) {
|
|
468
594
|
const { relativePaths, includeBasePath } = options;
|
|
469
595
|
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath$1;
|
|
470
596
|
}
|
|
597
|
+
exports.build = build$7;
|
|
471
598
|
} });
|
|
472
599
|
|
|
473
600
|
//#endregion
|
|
474
601
|
//#region node_modules/fdir/dist/api/functions/push-directory.js
|
|
475
602
|
var require_push_directory = __commonJS({ "node_modules/fdir/dist/api/functions/push-directory.js"(exports) {
|
|
476
603
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
477
|
-
exports.build =
|
|
604
|
+
exports.build = void 0;
|
|
478
605
|
function pushDirectoryWithRelativePath(root) {
|
|
479
606
|
return function(directoryPath, paths) {
|
|
480
607
|
paths.push(directoryPath.substring(root.length) || ".");
|
|
@@ -500,13 +627,14 @@ var require_push_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
500
627
|
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
501
628
|
return filters && filters.length ? pushDirectoryFilter : pushDirectory$1;
|
|
502
629
|
}
|
|
630
|
+
exports.build = build$6;
|
|
503
631
|
} });
|
|
504
632
|
|
|
505
633
|
//#endregion
|
|
506
634
|
//#region node_modules/fdir/dist/api/functions/push-file.js
|
|
507
635
|
var require_push_file = __commonJS({ "node_modules/fdir/dist/api/functions/push-file.js"(exports) {
|
|
508
636
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
509
|
-
exports.build =
|
|
637
|
+
exports.build = void 0;
|
|
510
638
|
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
511
639
|
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
512
640
|
};
|
|
@@ -527,13 +655,14 @@ var require_push_file = __commonJS({ "node_modules/fdir/dist/api/functions/push-
|
|
|
527
655
|
else if (onlyCounts) return pushFileCount;
|
|
528
656
|
else return pushFile$1;
|
|
529
657
|
}
|
|
658
|
+
exports.build = build$5;
|
|
530
659
|
} });
|
|
531
660
|
|
|
532
661
|
//#endregion
|
|
533
662
|
//#region node_modules/fdir/dist/api/functions/get-array.js
|
|
534
663
|
var require_get_array = __commonJS({ "node_modules/fdir/dist/api/functions/get-array.js"(exports) {
|
|
535
664
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
536
|
-
exports.build =
|
|
665
|
+
exports.build = void 0;
|
|
537
666
|
const getArray$1 = (paths) => {
|
|
538
667
|
return paths;
|
|
539
668
|
};
|
|
@@ -543,13 +672,14 @@ var require_get_array = __commonJS({ "node_modules/fdir/dist/api/functions/get-a
|
|
|
543
672
|
function build$4(options) {
|
|
544
673
|
return options.group ? getArrayGroup : getArray$1;
|
|
545
674
|
}
|
|
675
|
+
exports.build = build$4;
|
|
546
676
|
} });
|
|
547
677
|
|
|
548
678
|
//#endregion
|
|
549
679
|
//#region node_modules/fdir/dist/api/functions/group-files.js
|
|
550
680
|
var require_group_files = __commonJS({ "node_modules/fdir/dist/api/functions/group-files.js"(exports) {
|
|
551
681
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
552
|
-
exports.build =
|
|
682
|
+
exports.build = void 0;
|
|
553
683
|
const groupFiles$1 = (groups, directory, files) => {
|
|
554
684
|
groups.push({
|
|
555
685
|
directory,
|
|
@@ -561,6 +691,7 @@ var require_group_files = __commonJS({ "node_modules/fdir/dist/api/functions/gro
|
|
|
561
691
|
function build$3(options) {
|
|
562
692
|
return options.group ? groupFiles$1 : empty;
|
|
563
693
|
}
|
|
694
|
+
exports.build = build$3;
|
|
564
695
|
} });
|
|
565
696
|
|
|
566
697
|
//#endregion
|
|
@@ -570,7 +701,7 @@ var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
570
701
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
571
702
|
};
|
|
572
703
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
573
|
-
exports.build =
|
|
704
|
+
exports.build = void 0;
|
|
574
705
|
const fs_1$1 = __importDefault$1(__require("fs"));
|
|
575
706
|
const path_1$2 = __require("path");
|
|
576
707
|
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
@@ -602,6 +733,7 @@ var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
602
733
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
603
734
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
604
735
|
}
|
|
736
|
+
exports.build = build$2;
|
|
605
737
|
function isRecursive(path$2, resolved, state) {
|
|
606
738
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
607
739
|
let parent = (0, path_1$2.dirname)(path$2);
|
|
@@ -624,7 +756,7 @@ var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
624
756
|
//#region node_modules/fdir/dist/api/functions/invoke-callback.js
|
|
625
757
|
var require_invoke_callback = __commonJS({ "node_modules/fdir/dist/api/functions/invoke-callback.js"(exports) {
|
|
626
758
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
627
|
-
exports.build =
|
|
759
|
+
exports.build = void 0;
|
|
628
760
|
const onlyCountsSync = (state) => {
|
|
629
761
|
return state.counts;
|
|
630
762
|
};
|
|
@@ -664,6 +796,7 @@ var require_invoke_callback = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
664
796
|
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
665
797
|
else return isSynchronous ? defaultSync : defaultAsync;
|
|
666
798
|
}
|
|
799
|
+
exports.build = build$1;
|
|
667
800
|
} });
|
|
668
801
|
|
|
669
802
|
//#endregion
|
|
@@ -673,12 +806,12 @@ var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
673
806
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
674
807
|
};
|
|
675
808
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
676
|
-
exports.build =
|
|
809
|
+
exports.build = void 0;
|
|
677
810
|
const fs_1 = __importDefault(__require("fs"));
|
|
678
811
|
const readdirOpts = { withFileTypes: true };
|
|
679
812
|
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
680
813
|
state.queue.enqueue();
|
|
681
|
-
if (currentDepth
|
|
814
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
682
815
|
state.visited.push(crawlPath);
|
|
683
816
|
state.counts.directories++;
|
|
684
817
|
fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
@@ -687,7 +820,7 @@ var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
687
820
|
});
|
|
688
821
|
};
|
|
689
822
|
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
690
|
-
if (currentDepth
|
|
823
|
+
if (currentDepth < 0) return;
|
|
691
824
|
state.visited.push(crawlPath);
|
|
692
825
|
state.counts.directories++;
|
|
693
826
|
let entries = [];
|
|
@@ -701,6 +834,7 @@ var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
701
834
|
function build(isSynchronous) {
|
|
702
835
|
return isSynchronous ? walkSync : walkAsync;
|
|
703
836
|
}
|
|
837
|
+
exports.build = build;
|
|
704
838
|
} });
|
|
705
839
|
|
|
706
840
|
//#endregion
|
|
@@ -770,47 +904,37 @@ var require_counter = __commonJS({ "node_modules/fdir/dist/api/counter.js"(expor
|
|
|
770
904
|
//#endregion
|
|
771
905
|
//#region node_modules/fdir/dist/api/walker.js
|
|
772
906
|
var require_walker = __commonJS({ "node_modules/fdir/dist/api/walker.js"(exports) {
|
|
773
|
-
var __createBinding$1 = void 0 && (void 0).__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
774
|
-
if (k2 === void 0) k2 = k;
|
|
775
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
776
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
907
|
+
var __createBinding$1 = void 0 && (void 0).__createBinding || (Object.create ? function(o, m$1, k$1, k2) {
|
|
908
|
+
if (k2 === void 0) k2 = k$1;
|
|
909
|
+
var desc = Object.getOwnPropertyDescriptor(m$1, k$1);
|
|
910
|
+
if (!desc || ("get" in desc ? !m$1.__esModule : desc.writable || desc.configurable)) desc = {
|
|
777
911
|
enumerable: true,
|
|
778
912
|
get: function() {
|
|
779
|
-
return m[k];
|
|
913
|
+
return m$1[k$1];
|
|
780
914
|
}
|
|
781
915
|
};
|
|
782
916
|
Object.defineProperty(o, k2, desc);
|
|
783
|
-
} : function(o, m, k, k2) {
|
|
784
|
-
if (k2 === void 0) k2 = k;
|
|
785
|
-
o[k2] = m[k];
|
|
917
|
+
} : function(o, m$1, k$1, k2) {
|
|
918
|
+
if (k2 === void 0) k2 = k$1;
|
|
919
|
+
o[k2] = m$1[k$1];
|
|
786
920
|
});
|
|
787
|
-
var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function(o, v) {
|
|
921
|
+
var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function(o, v$1) {
|
|
788
922
|
Object.defineProperty(o, "default", {
|
|
789
923
|
enumerable: true,
|
|
790
|
-
value: v
|
|
924
|
+
value: v$1
|
|
791
925
|
});
|
|
792
|
-
} : function(o, v) {
|
|
793
|
-
o["default"] = v;
|
|
926
|
+
} : function(o, v$1) {
|
|
927
|
+
o["default"] = v$1;
|
|
794
928
|
});
|
|
795
|
-
var __importStar = void 0 && (void 0).__importStar || function() {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
return function(mod) {
|
|
805
|
-
if (mod && mod.__esModule) return mod;
|
|
806
|
-
var result = {};
|
|
807
|
-
if (mod != null) {
|
|
808
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding$1(result, mod, k[i]);
|
|
809
|
-
}
|
|
810
|
-
__setModuleDefault(result, mod);
|
|
811
|
-
return result;
|
|
812
|
-
};
|
|
813
|
-
}();
|
|
929
|
+
var __importStar = void 0 && (void 0).__importStar || function(mod) {
|
|
930
|
+
if (mod && mod.__esModule) return mod;
|
|
931
|
+
var result = {};
|
|
932
|
+
if (mod != null) {
|
|
933
|
+
for (var k$1 in mod) if (k$1 !== "default" && Object.prototype.hasOwnProperty.call(mod, k$1)) __createBinding$1(result, mod, k$1);
|
|
934
|
+
}
|
|
935
|
+
__setModuleDefault(result, mod);
|
|
936
|
+
return result;
|
|
937
|
+
};
|
|
814
938
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
815
939
|
exports.Walker = void 0;
|
|
816
940
|
const path_1$1 = __require("path");
|
|
@@ -906,8 +1030,7 @@ var require_walker = __commonJS({ "node_modules/fdir/dist/api/walker.js"(exports
|
|
|
906
1030
|
//#region node_modules/fdir/dist/api/async.js
|
|
907
1031
|
var require_async = __commonJS({ "node_modules/fdir/dist/api/async.js"(exports) {
|
|
908
1032
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
909
|
-
exports.promise =
|
|
910
|
-
exports.callback = callback;
|
|
1033
|
+
exports.callback = exports.promise = void 0;
|
|
911
1034
|
const walker_1$1 = require_walker();
|
|
912
1035
|
function promise(root, options) {
|
|
913
1036
|
return new Promise((resolve, reject) => {
|
|
@@ -917,22 +1040,25 @@ var require_async = __commonJS({ "node_modules/fdir/dist/api/async.js"(exports)
|
|
|
917
1040
|
});
|
|
918
1041
|
});
|
|
919
1042
|
}
|
|
1043
|
+
exports.promise = promise;
|
|
920
1044
|
function callback(root, options, callback$1) {
|
|
921
1045
|
let walker = new walker_1$1.Walker(root, options, callback$1);
|
|
922
1046
|
walker.start();
|
|
923
1047
|
}
|
|
1048
|
+
exports.callback = callback;
|
|
924
1049
|
} });
|
|
925
1050
|
|
|
926
1051
|
//#endregion
|
|
927
1052
|
//#region node_modules/fdir/dist/api/sync.js
|
|
928
1053
|
var require_sync = __commonJS({ "node_modules/fdir/dist/api/sync.js"(exports) {
|
|
929
1054
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
930
|
-
exports.sync =
|
|
1055
|
+
exports.sync = void 0;
|
|
931
1056
|
const walker_1 = require_walker();
|
|
932
1057
|
function sync(root, options) {
|
|
933
1058
|
const walker = new walker_1.Walker(root, options);
|
|
934
1059
|
return walker.start();
|
|
935
1060
|
}
|
|
1061
|
+
exports.sync = sync;
|
|
936
1062
|
} });
|
|
937
1063
|
|
|
938
1064
|
//#endregion
|
|
@@ -1442,9 +1568,9 @@ var require_scan = __commonJS({ "node_modules/picomatch/lib/scan.js"(exports, mo
|
|
|
1442
1568
|
if (opts.parts === true || opts.tokens === true) {
|
|
1443
1569
|
let prevIndex;
|
|
1444
1570
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1445
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
1571
|
+
const n$1 = prevIndex ? prevIndex + 1 : start;
|
|
1446
1572
|
const i = slashes[idx];
|
|
1447
|
-
const value = input.slice(n, i);
|
|
1573
|
+
const value = input.slice(n$1, i);
|
|
1448
1574
|
if (opts.tokens) {
|
|
1449
1575
|
if (idx === 0 && start !== 0) {
|
|
1450
1576
|
tokens[idx].isPrefix = true;
|
|
@@ -1492,7 +1618,7 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1492
1618
|
try {
|
|
1493
1619
|
new RegExp(value);
|
|
1494
1620
|
} catch (ex) {
|
|
1495
|
-
return args.map((v) => utils$2.escapeRegex(v)).join("..");
|
|
1621
|
+
return args.map((v$1) => utils$2.escapeRegex(v$1)).join("..");
|
|
1496
1622
|
}
|
|
1497
1623
|
return value;
|
|
1498
1624
|
};
|
|
@@ -1561,7 +1687,7 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1561
1687
|
* Tokenizing helpers
|
|
1562
1688
|
*/
|
|
1563
1689
|
const eos = () => state.index === len - 1;
|
|
1564
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1690
|
+
const peek = state.peek = (n$1 = 1) => input[state.index + n$1];
|
|
1565
1691
|
const advance = state.advance = () => input[++state.index] || "";
|
|
1566
1692
|
const remaining = () => input.slice(state.index + 1);
|
|
1567
1693
|
const consume = (value$1 = "", num = 0) => {
|
|
@@ -1675,10 +1801,10 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1675
1801
|
*/
|
|
1676
1802
|
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1677
1803
|
let backslashes = false;
|
|
1678
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1804
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m$1, esc, chars, first, rest, index) => {
|
|
1679
1805
|
if (first === "\\") {
|
|
1680
1806
|
backslashes = true;
|
|
1681
|
-
return m;
|
|
1807
|
+
return m$1;
|
|
1682
1808
|
}
|
|
1683
1809
|
if (first === "?") {
|
|
1684
1810
|
if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
|
|
@@ -1690,11 +1816,11 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1690
1816
|
if (esc) return esc + first + (rest ? star : "");
|
|
1691
1817
|
return star;
|
|
1692
1818
|
}
|
|
1693
|
-
return esc ? m : `\\${m}`;
|
|
1819
|
+
return esc ? m$1 : `\\${m$1}`;
|
|
1694
1820
|
});
|
|
1695
1821
|
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
1696
|
-
else output = output.replace(/\\+/g, (m) => {
|
|
1697
|
-
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1822
|
+
else output = output.replace(/\\+/g, (m$1) => {
|
|
1823
|
+
return m$1.length % 2 === 0 ? "\\\\" : m$1 ? "\\" : "";
|
|
1698
1824
|
});
|
|
1699
1825
|
if (output === input && opts.contains === true) {
|
|
1700
1826
|
state.output = input;
|
|
@@ -2795,22 +2921,22 @@ var require_types = __commonJS({ "node_modules/fdir/dist/types.js"(exports) {
|
|
|
2795
2921
|
//#endregion
|
|
2796
2922
|
//#region node_modules/fdir/dist/index.js
|
|
2797
2923
|
var require_dist$1 = __commonJS({ "node_modules/fdir/dist/index.js"(exports) {
|
|
2798
|
-
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2799
|
-
if (k2 === void 0) k2 = k;
|
|
2800
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2801
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2924
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function(o, m$1, k$1, k2) {
|
|
2925
|
+
if (k2 === void 0) k2 = k$1;
|
|
2926
|
+
var desc = Object.getOwnPropertyDescriptor(m$1, k$1);
|
|
2927
|
+
if (!desc || ("get" in desc ? !m$1.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2802
2928
|
enumerable: true,
|
|
2803
2929
|
get: function() {
|
|
2804
|
-
return m[k];
|
|
2930
|
+
return m$1[k$1];
|
|
2805
2931
|
}
|
|
2806
2932
|
};
|
|
2807
2933
|
Object.defineProperty(o, k2, desc);
|
|
2808
|
-
} : function(o, m, k, k2) {
|
|
2809
|
-
if (k2 === void 0) k2 = k;
|
|
2810
|
-
o[k2] = m[k];
|
|
2934
|
+
} : function(o, m$1, k$1, k2) {
|
|
2935
|
+
if (k2 === void 0) k2 = k$1;
|
|
2936
|
+
o[k2] = m$1[k$1];
|
|
2811
2937
|
});
|
|
2812
|
-
var __exportStar = void 0 && (void 0).__exportStar || function(m, exports$1) {
|
|
2813
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
2938
|
+
var __exportStar = void 0 && (void 0).__exportStar || function(m$1, exports$1) {
|
|
2939
|
+
for (var p in m$1) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m$1, p);
|
|
2814
2940
|
};
|
|
2815
2941
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2816
2942
|
exports.fdir = void 0;
|
|
@@ -2838,7 +2964,7 @@ function getPartialMatcher(patterns, options) {
|
|
|
2838
2964
|
patternsParts[i] = parts;
|
|
2839
2965
|
const partsCount = parts.length;
|
|
2840
2966
|
const partRegexes = Array(partsCount);
|
|
2841
|
-
for (let j = 0; j < partsCount; j++) partRegexes[j] = import_picomatch.default.makeRe(parts[j], options);
|
|
2967
|
+
for (let j$1 = 0; j$1 < partsCount; j$1++) partRegexes[j$1] = import_picomatch.default.makeRe(parts[j$1], options);
|
|
2842
2968
|
regexes[i] = partRegexes;
|
|
2843
2969
|
}
|
|
2844
2970
|
return (input) => {
|
|
@@ -2849,16 +2975,16 @@ function getPartialMatcher(patterns, options) {
|
|
|
2849
2975
|
const regex$1 = regexes[i];
|
|
2850
2976
|
const inputPatternCount = inputParts.length;
|
|
2851
2977
|
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2852
|
-
let j = 0;
|
|
2853
|
-
while (j < minParts) {
|
|
2854
|
-
const part = patternParts[j];
|
|
2978
|
+
let j$1 = 0;
|
|
2979
|
+
while (j$1 < minParts) {
|
|
2980
|
+
const part = patternParts[j$1];
|
|
2855
2981
|
if (part.includes("/")) return true;
|
|
2856
|
-
const match = regex$1[j].test(inputParts[j]);
|
|
2982
|
+
const match = regex$1[j$1].test(inputParts[j$1]);
|
|
2857
2983
|
if (!match) break;
|
|
2858
2984
|
if (part === "**") return true;
|
|
2859
|
-
j++;
|
|
2985
|
+
j$1++;
|
|
2860
2986
|
}
|
|
2861
|
-
if (j === inputPatternCount) return true;
|
|
2987
|
+
if (j$1 === inputPatternCount) return true;
|
|
2862
2988
|
}
|
|
2863
2989
|
return false;
|
|
2864
2990
|
};
|
|
@@ -2896,17 +3022,17 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2896
3022
|
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2897
3023
|
const parts = splitPattern(result);
|
|
2898
3024
|
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
|
2899
|
-
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
3025
|
+
const n$1 = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2900
3026
|
let i = 0;
|
|
2901
3027
|
const cwdParts = escapedCwd.split("/");
|
|
2902
|
-
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
|
2903
|
-
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
3028
|
+
while (i < n$1 && parts[i + n$1] === cwdParts[cwdParts.length + i - n$1]) {
|
|
3029
|
+
result = result.slice(0, (n$1 - i - 1) * 3) + result.slice((n$1 - i) * 3 + parts[i + n$1].length + 1) || ".";
|
|
2904
3030
|
i++;
|
|
2905
3031
|
}
|
|
2906
3032
|
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
|
2907
3033
|
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2908
3034
|
props.root = potentialRoot;
|
|
2909
|
-
props.depthOffset = -n + i;
|
|
3035
|
+
props.depthOffset = -n$1 + i;
|
|
2910
3036
|
}
|
|
2911
3037
|
}
|
|
2912
3038
|
if (!isIgnore && props.depthOffset >= 0) {
|
|
@@ -3042,13 +3168,27 @@ async function glob(patternsOrOptions, options) {
|
|
|
3042
3168
|
}
|
|
3043
3169
|
|
|
3044
3170
|
//#endregion
|
|
3045
|
-
//#region src/
|
|
3046
|
-
|
|
3171
|
+
//#region src/session-blocks.internal.ts
|
|
3172
|
+
/**
|
|
3173
|
+
* Default session duration in hours (Claude's billing block duration)
|
|
3174
|
+
*/
|
|
3175
|
+
const DEFAULT_SESSION_DURATION_HOURS = 5;
|
|
3176
|
+
/**
|
|
3177
|
+
* Default number of recent days to include when filtering blocks
|
|
3178
|
+
*/
|
|
3047
3179
|
const DEFAULT_RECENT_DAYS = 3;
|
|
3048
|
-
|
|
3180
|
+
/**
|
|
3181
|
+
* Identifies and creates session blocks from usage entries
|
|
3182
|
+
* Groups entries into time-based blocks (typically 5-hour periods) with gap detection
|
|
3183
|
+
* @param entries - Array of usage entries to process
|
|
3184
|
+
* @param sessionDurationHours - Duration of each session block in hours
|
|
3185
|
+
* @returns Array of session blocks with aggregated usage data
|
|
3186
|
+
*/
|
|
3187
|
+
function identifySessionBlocks(entries, sessionDurationHours = DEFAULT_SESSION_DURATION_HOURS) {
|
|
3049
3188
|
if (entries.length === 0) return [];
|
|
3189
|
+
const sessionDurationMs = sessionDurationHours * 60 * 60 * 1e3;
|
|
3050
3190
|
const blocks = [];
|
|
3051
|
-
const sortedEntries = [...entries].sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
|
3191
|
+
const sortedEntries = [...entries].sort((a$1, b$1) => a$1.timestamp.getTime() - b$1.timestamp.getTime());
|
|
3052
3192
|
let currentBlockStart = null;
|
|
3053
3193
|
let currentBlockEntries = [];
|
|
3054
3194
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -3063,11 +3203,11 @@ function identifyFiveHourBlocks(entries) {
|
|
|
3063
3203
|
if (lastEntry == null) continue;
|
|
3064
3204
|
const lastEntryTime = lastEntry.timestamp;
|
|
3065
3205
|
const timeSinceLastEntry = entryTime.getTime() - lastEntryTime.getTime();
|
|
3066
|
-
if (timeSinceBlockStart >
|
|
3067
|
-
const block = createBlock(currentBlockStart, currentBlockEntries, now);
|
|
3206
|
+
if (timeSinceBlockStart > sessionDurationMs || timeSinceLastEntry > sessionDurationMs) {
|
|
3207
|
+
const block = createBlock(currentBlockStart, currentBlockEntries, now, sessionDurationMs);
|
|
3068
3208
|
blocks.push(block);
|
|
3069
|
-
if (timeSinceLastEntry >
|
|
3070
|
-
const gapBlock = createGapBlock(lastEntryTime, entryTime);
|
|
3209
|
+
if (timeSinceLastEntry > sessionDurationMs) {
|
|
3210
|
+
const gapBlock = createGapBlock(lastEntryTime, entryTime, sessionDurationMs);
|
|
3071
3211
|
if (gapBlock != null) blocks.push(gapBlock);
|
|
3072
3212
|
}
|
|
3073
3213
|
currentBlockStart = entryTime;
|
|
@@ -3076,16 +3216,24 @@ function identifyFiveHourBlocks(entries) {
|
|
|
3076
3216
|
}
|
|
3077
3217
|
}
|
|
3078
3218
|
if (currentBlockStart != null && currentBlockEntries.length > 0) {
|
|
3079
|
-
const block = createBlock(currentBlockStart, currentBlockEntries, now);
|
|
3219
|
+
const block = createBlock(currentBlockStart, currentBlockEntries, now, sessionDurationMs);
|
|
3080
3220
|
blocks.push(block);
|
|
3081
3221
|
}
|
|
3082
3222
|
return blocks;
|
|
3083
3223
|
}
|
|
3084
|
-
|
|
3085
|
-
|
|
3224
|
+
/**
|
|
3225
|
+
* Creates a session block from a start time and usage entries
|
|
3226
|
+
* @param startTime - When the block started
|
|
3227
|
+
* @param entries - Usage entries in this block
|
|
3228
|
+
* @param now - Current time for active block detection
|
|
3229
|
+
* @param sessionDurationMs - Session duration in milliseconds
|
|
3230
|
+
* @returns Session block with aggregated data
|
|
3231
|
+
*/
|
|
3232
|
+
function createBlock(startTime, entries, now, sessionDurationMs) {
|
|
3233
|
+
const endTime = new Date(startTime.getTime() + sessionDurationMs);
|
|
3086
3234
|
const lastEntry = entries[entries.length - 1];
|
|
3087
3235
|
const actualEndTime = lastEntry != null ? lastEntry.timestamp : startTime;
|
|
3088
|
-
const isActive = now.getTime() - actualEndTime.getTime() <
|
|
3236
|
+
const isActive = now.getTime() - actualEndTime.getTime() < sessionDurationMs && now < endTime;
|
|
3089
3237
|
const tokenCounts = {
|
|
3090
3238
|
inputTokens: 0,
|
|
3091
3239
|
outputTokens: 0,
|
|
@@ -3114,10 +3262,17 @@ function createBlock(startTime, entries, now) {
|
|
|
3114
3262
|
models: Array.from(modelsSet)
|
|
3115
3263
|
};
|
|
3116
3264
|
}
|
|
3117
|
-
|
|
3265
|
+
/**
|
|
3266
|
+
* Creates a gap block representing periods with no activity
|
|
3267
|
+
* @param lastActivityTime - Time of last activity before gap
|
|
3268
|
+
* @param nextActivityTime - Time of next activity after gap
|
|
3269
|
+
* @param sessionDurationMs - Session duration in milliseconds
|
|
3270
|
+
* @returns Gap block or null if gap is too short
|
|
3271
|
+
*/
|
|
3272
|
+
function createGapBlock(lastActivityTime, nextActivityTime, sessionDurationMs) {
|
|
3118
3273
|
const gapDuration = nextActivityTime.getTime() - lastActivityTime.getTime();
|
|
3119
|
-
if (gapDuration <=
|
|
3120
|
-
const gapStart = new Date(lastActivityTime.getTime() +
|
|
3274
|
+
if (gapDuration <= sessionDurationMs) return null;
|
|
3275
|
+
const gapStart = new Date(lastActivityTime.getTime() + sessionDurationMs);
|
|
3121
3276
|
const gapEnd = nextActivityTime;
|
|
3122
3277
|
return {
|
|
3123
3278
|
id: `gap-${gapStart.toISOString()}`,
|
|
@@ -3136,6 +3291,11 @@ function createGapBlock(lastActivityTime, nextActivityTime) {
|
|
|
3136
3291
|
models: []
|
|
3137
3292
|
};
|
|
3138
3293
|
}
|
|
3294
|
+
/**
|
|
3295
|
+
* Calculates the burn rate (tokens/minute and cost/hour) for a session block
|
|
3296
|
+
* @param block - Session block to analyze
|
|
3297
|
+
* @returns Burn rate calculations or null if block has no activity
|
|
3298
|
+
*/
|
|
3139
3299
|
function calculateBurnRate(block) {
|
|
3140
3300
|
if (block.entries.length === 0 || (block.isGap ?? false)) return null;
|
|
3141
3301
|
const firstEntryData = block.entries[0];
|
|
@@ -3153,6 +3313,11 @@ function calculateBurnRate(block) {
|
|
|
3153
3313
|
costPerHour
|
|
3154
3314
|
};
|
|
3155
3315
|
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Projects total usage for an active session block based on current burn rate
|
|
3318
|
+
* @param block - Active session block to project
|
|
3319
|
+
* @returns Projected usage totals or null if block is inactive or has no burn rate
|
|
3320
|
+
*/
|
|
3156
3321
|
function projectBlockUsage(block) {
|
|
3157
3322
|
if (!block.isActive || (block.isGap ?? false)) return null;
|
|
3158
3323
|
const burnRate = calculateBurnRate(block);
|
|
@@ -3171,6 +3336,12 @@ function projectBlockUsage(block) {
|
|
|
3171
3336
|
remainingMinutes: Math.round(remainingMinutes)
|
|
3172
3337
|
};
|
|
3173
3338
|
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Filters session blocks to include only recent ones and active blocks
|
|
3341
|
+
* @param blocks - Array of session blocks to filter
|
|
3342
|
+
* @param days - Number of recent days to include (default: 3)
|
|
3343
|
+
* @returns Filtered array of recent or active blocks
|
|
3344
|
+
*/
|
|
3174
3345
|
function filterRecentBlocks(blocks, days = DEFAULT_RECENT_DAYS) {
|
|
3175
3346
|
const now = /* @__PURE__ */ new Date();
|
|
3176
3347
|
const cutoffTime = new Date(now.getTime() - days * 24 * 60 * 60 * 1e3);
|
|
@@ -3179,82 +3350,33 @@ function filterRecentBlocks(blocks, days = DEFAULT_RECENT_DAYS) {
|
|
|
3179
3350
|
});
|
|
3180
3351
|
}
|
|
3181
3352
|
|
|
3182
|
-
//#endregion
|
|
3183
|
-
//#region node_modules/rolldown/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
|
3184
|
-
var require_usingCtx = __commonJS({ "node_modules/rolldown/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
|
3185
|
-
function _usingCtx() {
|
|
3186
|
-
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
3187
|
-
var n$1 = Error();
|
|
3188
|
-
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
|
3189
|
-
}, e = {}, n = [];
|
|
3190
|
-
function using(r$1, e$1) {
|
|
3191
|
-
if (null != e$1) {
|
|
3192
|
-
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
3193
|
-
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
3194
|
-
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
|
3195
|
-
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
3196
|
-
t && (o = function o$1() {
|
|
3197
|
-
try {
|
|
3198
|
-
t.call(e$1);
|
|
3199
|
-
} catch (r$2) {
|
|
3200
|
-
return Promise.reject(r$2);
|
|
3201
|
-
}
|
|
3202
|
-
}), n.push({
|
|
3203
|
-
v: e$1,
|
|
3204
|
-
d: o,
|
|
3205
|
-
a: r$1
|
|
3206
|
-
});
|
|
3207
|
-
} else r$1 && n.push({
|
|
3208
|
-
d: e$1,
|
|
3209
|
-
a: r$1
|
|
3210
|
-
});
|
|
3211
|
-
return e$1;
|
|
3212
|
-
}
|
|
3213
|
-
return {
|
|
3214
|
-
e,
|
|
3215
|
-
u: using.bind(null, !1),
|
|
3216
|
-
a: using.bind(null, !0),
|
|
3217
|
-
d: function d() {
|
|
3218
|
-
var o, t = this.e, s = 0;
|
|
3219
|
-
function next() {
|
|
3220
|
-
for (; o = n.pop();) try {
|
|
3221
|
-
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
3222
|
-
if (o.d) {
|
|
3223
|
-
var r$1 = o.d.call(o.v);
|
|
3224
|
-
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
|
3225
|
-
} else s |= 1;
|
|
3226
|
-
} catch (r$2) {
|
|
3227
|
-
return err(r$2);
|
|
3228
|
-
}
|
|
3229
|
-
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
3230
|
-
if (t !== e) throw t;
|
|
3231
|
-
}
|
|
3232
|
-
function err(n$1) {
|
|
3233
|
-
return t = t !== e ? new r(n$1, t) : n$1, next();
|
|
3234
|
-
}
|
|
3235
|
-
return next();
|
|
3236
|
-
}
|
|
3237
|
-
};
|
|
3238
|
-
}
|
|
3239
|
-
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3240
|
-
} });
|
|
3241
|
-
|
|
3242
3353
|
//#endregion
|
|
3243
3354
|
//#region src/data-loader.ts
|
|
3244
3355
|
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
3356
|
+
/**
|
|
3357
|
+
* Default Claude data directory path (~/.claude)
|
|
3358
|
+
*/
|
|
3245
3359
|
const DEFAULT_CLAUDE_CODE_PATH = path.join(homedir(), ".claude");
|
|
3246
3360
|
/**
|
|
3247
3361
|
* Default path for Claude data directory
|
|
3248
3362
|
* Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
|
|
3249
3363
|
*/
|
|
3250
3364
|
function getDefaultClaudePath() {
|
|
3251
|
-
const envClaudeCodePath = process$1.env.CLAUDE_CONFIG_DIR
|
|
3252
|
-
if (
|
|
3365
|
+
const envClaudeCodePath = (process$1.env.CLAUDE_CONFIG_DIR ?? "").trim();
|
|
3366
|
+
if (envClaudeCodePath === "") return DEFAULT_CLAUDE_CODE_PATH;
|
|
3367
|
+
if (!isDirectorySync(envClaudeCodePath)) throw new Error(`CLAUDE_CONFIG_DIR path is not a valid directory: ${envClaudeCodePath}.
|
|
3368
|
+
Please set CLAUDE_CONFIG_DIR to a valid directory path, or ensure ${DEFAULT_CLAUDE_CODE_PATH} exists.
|
|
3369
|
+
`.trim());
|
|
3370
|
+
const claudeCodeProjectsPath = path.join(envClaudeCodePath, "projects");
|
|
3371
|
+
if (!isDirectorySync(claudeCodeProjectsPath)) throw new Error(`Claude data directory does not exist: ${claudeCodeProjectsPath}.
|
|
3253
3372
|
Please set CLAUDE_CONFIG_DIR to a valid path, or ensure ${DEFAULT_CLAUDE_CODE_PATH} exists.
|
|
3254
3373
|
`.trim());
|
|
3255
3374
|
return envClaudeCodePath;
|
|
3256
3375
|
}
|
|
3257
|
-
|
|
3376
|
+
/**
|
|
3377
|
+
* Valibot schema for validating Claude usage data from JSONL files
|
|
3378
|
+
*/
|
|
3379
|
+
const usageDataSchema = object({
|
|
3258
3380
|
timestamp: string(),
|
|
3259
3381
|
version: optional(string()),
|
|
3260
3382
|
message: object({
|
|
@@ -3270,7 +3392,10 @@ const UsageDataSchema = object({
|
|
|
3270
3392
|
costUSD: optional(number()),
|
|
3271
3393
|
requestId: optional(string())
|
|
3272
3394
|
});
|
|
3273
|
-
|
|
3395
|
+
/**
|
|
3396
|
+
* Valibot schema for model-specific usage breakdown data
|
|
3397
|
+
*/
|
|
3398
|
+
const modelBreakdownSchema = object({
|
|
3274
3399
|
modelName: string(),
|
|
3275
3400
|
inputTokens: number(),
|
|
3276
3401
|
outputTokens: number(),
|
|
@@ -3278,7 +3403,10 @@ const ModelBreakdownSchema = object({
|
|
|
3278
3403
|
cacheReadTokens: number(),
|
|
3279
3404
|
cost: number()
|
|
3280
3405
|
});
|
|
3281
|
-
|
|
3406
|
+
/**
|
|
3407
|
+
* Valibot schema for daily usage aggregation data
|
|
3408
|
+
*/
|
|
3409
|
+
const dailyUsageSchema = object({
|
|
3282
3410
|
date: pipe(string(), regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
3283
3411
|
inputTokens: number(),
|
|
3284
3412
|
outputTokens: number(),
|
|
@@ -3286,9 +3414,12 @@ const DailyUsageSchema = object({
|
|
|
3286
3414
|
cacheReadTokens: number(),
|
|
3287
3415
|
totalCost: number(),
|
|
3288
3416
|
modelsUsed: array(string()),
|
|
3289
|
-
modelBreakdowns: array(
|
|
3417
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3290
3418
|
});
|
|
3291
|
-
|
|
3419
|
+
/**
|
|
3420
|
+
* Valibot schema for session-based usage aggregation data
|
|
3421
|
+
*/
|
|
3422
|
+
const sessionUsageSchema = object({
|
|
3292
3423
|
sessionId: string(),
|
|
3293
3424
|
projectPath: string(),
|
|
3294
3425
|
inputTokens: number(),
|
|
@@ -3299,9 +3430,12 @@ const SessionUsageSchema = object({
|
|
|
3299
3430
|
lastActivity: string(),
|
|
3300
3431
|
versions: array(string()),
|
|
3301
3432
|
modelsUsed: array(string()),
|
|
3302
|
-
modelBreakdowns: array(
|
|
3433
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3303
3434
|
});
|
|
3304
|
-
|
|
3435
|
+
/**
|
|
3436
|
+
* Valibot schema for monthly usage aggregation data
|
|
3437
|
+
*/
|
|
3438
|
+
const monthlyUsageSchema = object({
|
|
3305
3439
|
month: pipe(string(), regex(/^\d{4}-\d{2}$/)),
|
|
3306
3440
|
inputTokens: number(),
|
|
3307
3441
|
outputTokens: number(),
|
|
@@ -3309,7 +3443,7 @@ const MonthlyUsageSchema = object({
|
|
|
3309
3443
|
cacheReadTokens: number(),
|
|
3310
3444
|
totalCost: number(),
|
|
3311
3445
|
modelsUsed: array(string()),
|
|
3312
|
-
modelBreakdowns: array(
|
|
3446
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3313
3447
|
});
|
|
3314
3448
|
/**
|
|
3315
3449
|
* Aggregates token counts and costs by model name
|
|
@@ -3371,7 +3505,7 @@ function createModelBreakdowns(modelAggregates) {
|
|
|
3371
3505
|
return Array.from(modelAggregates.entries()).map(([modelName, stats]) => ({
|
|
3372
3506
|
modelName,
|
|
3373
3507
|
...stats
|
|
3374
|
-
})).sort((a, b) => b.cost - a.cost);
|
|
3508
|
+
})).sort((a$1, b$1) => b$1.cost - a$1.cost);
|
|
3375
3509
|
}
|
|
3376
3510
|
/**
|
|
3377
3511
|
* Calculates total token counts and costs from entries
|
|
@@ -3426,8 +3560,13 @@ function markAsProcessed(uniqueHash, processedHashes) {
|
|
|
3426
3560
|
* Extracts unique models from entries, excluding synthetic model
|
|
3427
3561
|
*/
|
|
3428
3562
|
function extractUniqueModels(entries, getModel) {
|
|
3429
|
-
return [...new Set(entries.map(getModel).filter((m) => m != null && m !== "<synthetic>"))];
|
|
3563
|
+
return [...new Set(entries.map(getModel).filter((m$1) => m$1 != null && m$1 !== "<synthetic>"))];
|
|
3430
3564
|
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Formats a date string to YYYY-MM-DD format
|
|
3567
|
+
* @param dateStr - Input date string
|
|
3568
|
+
* @returns Formatted date string in YYYY-MM-DD format
|
|
3569
|
+
*/
|
|
3431
3570
|
function formatDate(dateStr) {
|
|
3432
3571
|
const date = new Date(dateStr);
|
|
3433
3572
|
const year = date.getFullYear();
|
|
@@ -3435,6 +3574,11 @@ function formatDate(dateStr) {
|
|
|
3435
3574
|
const day = String(date.getDate()).padStart(2, "0");
|
|
3436
3575
|
return `${year}-${month}-${day}`;
|
|
3437
3576
|
}
|
|
3577
|
+
/**
|
|
3578
|
+
* Formats a date string to compact format with year on first line and month-day on second
|
|
3579
|
+
* @param dateStr - Input date string
|
|
3580
|
+
* @returns Formatted date string with newline separator (YYYY\nMM-DD)
|
|
3581
|
+
*/
|
|
3438
3582
|
function formatDateCompact(dateStr) {
|
|
3439
3583
|
const date = new Date(dateStr);
|
|
3440
3584
|
const year = date.getFullYear();
|
|
@@ -3504,13 +3648,20 @@ async function sortFilesByTimestamp(files) {
|
|
|
3504
3648
|
file,
|
|
3505
3649
|
timestamp: await getEarliestTimestamp(file)
|
|
3506
3650
|
})));
|
|
3507
|
-
return filesWithTimestamps.sort((a, b) => {
|
|
3508
|
-
if (a.timestamp == null && b.timestamp == null) return 0;
|
|
3509
|
-
if (a.timestamp == null) return 1;
|
|
3510
|
-
if (b.timestamp == null) return -1;
|
|
3511
|
-
return a.timestamp.getTime() - b.timestamp.getTime();
|
|
3651
|
+
return filesWithTimestamps.sort((a$1, b$1) => {
|
|
3652
|
+
if (a$1.timestamp == null && b$1.timestamp == null) return 0;
|
|
3653
|
+
if (a$1.timestamp == null) return 1;
|
|
3654
|
+
if (b$1.timestamp == null) return -1;
|
|
3655
|
+
return a$1.timestamp.getTime() - b$1.timestamp.getTime();
|
|
3512
3656
|
}).map((item) => item.file);
|
|
3513
3657
|
}
|
|
3658
|
+
/**
|
|
3659
|
+
* Calculates cost for a single usage data entry based on the specified cost calculation mode
|
|
3660
|
+
* @param data - Usage data entry
|
|
3661
|
+
* @param mode - Cost calculation mode (auto, calculate, or display)
|
|
3662
|
+
* @param fetcher - Pricing fetcher instance for calculating costs from tokens
|
|
3663
|
+
* @returns Calculated cost in USD
|
|
3664
|
+
*/
|
|
3514
3665
|
async function calculateCostForEntry(data, mode, fetcher) {
|
|
3515
3666
|
if (mode === "display") return data.costUSD ?? 0;
|
|
3516
3667
|
if (mode === "calculate") {
|
|
@@ -3524,9 +3675,15 @@ async function calculateCostForEntry(data, mode, fetcher) {
|
|
|
3524
3675
|
}
|
|
3525
3676
|
unreachable(mode);
|
|
3526
3677
|
}
|
|
3678
|
+
/**
|
|
3679
|
+
* Loads and aggregates Claude usage data by day
|
|
3680
|
+
* Processes all JSONL files in the Claude projects directory and groups usage by date
|
|
3681
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3682
|
+
* @returns Array of daily usage summaries sorted by date
|
|
3683
|
+
*/
|
|
3527
3684
|
async function loadDailyUsageData(options) {
|
|
3528
3685
|
try {
|
|
3529
|
-
var _usingCtx
|
|
3686
|
+
var _usingCtx = (0, import_usingCtx.default)();
|
|
3530
3687
|
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
3531
3688
|
const claudeDir = path.join(claudePath, "projects");
|
|
3532
3689
|
const files = await glob(["**/*.jsonl"], {
|
|
@@ -3536,7 +3693,7 @@ async function loadDailyUsageData(options) {
|
|
|
3536
3693
|
if (files.length === 0) return [];
|
|
3537
3694
|
const sortedFiles = await sortFilesByTimestamp(files);
|
|
3538
3695
|
const mode = options?.mode ?? "auto";
|
|
3539
|
-
const fetcher = _usingCtx
|
|
3696
|
+
const fetcher = _usingCtx.u(mode === "display" ? null : new PricingFetcher(options?.offline));
|
|
3540
3697
|
const processedHashes = /* @__PURE__ */ new Set();
|
|
3541
3698
|
const allEntries = [];
|
|
3542
3699
|
for (const file of sortedFiles) {
|
|
@@ -3544,7 +3701,7 @@ async function loadDailyUsageData(options) {
|
|
|
3544
3701
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3545
3702
|
for (const line of lines) try {
|
|
3546
3703
|
const parsed = JSON.parse(line);
|
|
3547
|
-
const result = safeParse(
|
|
3704
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3548
3705
|
if (!result.success) continue;
|
|
3549
3706
|
const data = result.output;
|
|
3550
3707
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3577,11 +3734,17 @@ async function loadDailyUsageData(options) {
|
|
|
3577
3734
|
const filtered = filterByDateRange(results, (item) => item.date, options?.since, options?.until);
|
|
3578
3735
|
return sortByDate(filtered, (item) => item.date, options?.order);
|
|
3579
3736
|
} catch (_) {
|
|
3580
|
-
_usingCtx
|
|
3737
|
+
_usingCtx.e = _;
|
|
3581
3738
|
} finally {
|
|
3582
|
-
_usingCtx
|
|
3739
|
+
_usingCtx.d();
|
|
3583
3740
|
}
|
|
3584
3741
|
}
|
|
3742
|
+
/**
|
|
3743
|
+
* Loads and aggregates Claude usage data by session
|
|
3744
|
+
* Groups usage data by project path and session ID based on file structure
|
|
3745
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3746
|
+
* @returns Array of session usage summaries sorted by last activity
|
|
3747
|
+
*/
|
|
3585
3748
|
async function loadSessionData(options) {
|
|
3586
3749
|
try {
|
|
3587
3750
|
var _usingCtx3 = (0, import_usingCtx.default)();
|
|
@@ -3607,7 +3770,7 @@ async function loadSessionData(options) {
|
|
|
3607
3770
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3608
3771
|
for (const line of lines) try {
|
|
3609
3772
|
const parsed = JSON.parse(line);
|
|
3610
|
-
const result = safeParse(
|
|
3773
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3611
3774
|
if (!result.success) continue;
|
|
3612
3775
|
const data = result.output;
|
|
3613
3776
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3654,6 +3817,12 @@ async function loadSessionData(options) {
|
|
|
3654
3817
|
_usingCtx3.d();
|
|
3655
3818
|
}
|
|
3656
3819
|
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Loads and aggregates Claude usage data by month
|
|
3822
|
+
* Uses daily usage data as the source and groups by month
|
|
3823
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3824
|
+
* @returns Array of monthly usage summaries sorted by month
|
|
3825
|
+
*/
|
|
3657
3826
|
async function loadMonthlyUsageData(options) {
|
|
3658
3827
|
const dailyData = await loadDailyUsageData(options);
|
|
3659
3828
|
const groupedByMonth = groupBy(dailyData, (data) => data.date.substring(0, 7));
|
|
@@ -3691,7 +3860,13 @@ async function loadMonthlyUsageData(options) {
|
|
|
3691
3860
|
}
|
|
3692
3861
|
return sortByDate(monthlyArray, (item) => `${item.month}-01`, options?.order);
|
|
3693
3862
|
}
|
|
3694
|
-
|
|
3863
|
+
/**
|
|
3864
|
+
* Loads usage data and organizes it into session blocks (typically 5-hour billing periods)
|
|
3865
|
+
* Processes all usage data and groups it into time-based blocks for billing analysis
|
|
3866
|
+
* @param options - Optional configuration including session duration and filtering
|
|
3867
|
+
* @returns Array of session blocks with usage and cost information
|
|
3868
|
+
*/
|
|
3869
|
+
async function loadSessionBlockData(options) {
|
|
3695
3870
|
try {
|
|
3696
3871
|
var _usingCtx4 = (0, import_usingCtx.default)();
|
|
3697
3872
|
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
@@ -3711,7 +3886,7 @@ async function loadFiveHourBlockData(options) {
|
|
|
3711
3886
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3712
3887
|
for (const line of lines) try {
|
|
3713
3888
|
const parsed = JSON.parse(line);
|
|
3714
|
-
const result = safeParse(
|
|
3889
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3715
3890
|
if (!result.success) continue;
|
|
3716
3891
|
const data = result.output;
|
|
3717
3892
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3734,7 +3909,7 @@ async function loadFiveHourBlockData(options) {
|
|
|
3734
3909
|
logger.debug(`Skipping invalid JSON line in 5-hour blocks: ${error instanceof Error ? error.message : String(error)}`);
|
|
3735
3910
|
}
|
|
3736
3911
|
}
|
|
3737
|
-
const blocks =
|
|
3912
|
+
const blocks = identifySessionBlocks(allEntries, options?.sessionDurationHours);
|
|
3738
3913
|
const filtered = options?.since != null && options.since !== "" || options?.until != null && options.until !== "" ? blocks.filter((block) => {
|
|
3739
3914
|
const blockDateStr = formatDate(block.startTime.toISOString()).replace(/-/g, "");
|
|
3740
3915
|
if (options.since != null && options.since !== "" && blockDateStr < options.since) return false;
|
|
@@ -3750,4 +3925,4 @@ async function loadFiveHourBlockData(options) {
|
|
|
3750
3925
|
}
|
|
3751
3926
|
|
|
3752
3927
|
//#endregion
|
|
3753
|
-
export {
|
|
3928
|
+
export { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateCostForEntry, createUniqueHash, dailyUsageSchema, filterRecentBlocks, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, glob, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, projectBlockUsage, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|