ccusage 11.0.0 → 11.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/arktype-C-GObzDh-Bx7Fdrqj.js +2 -0
- package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +16 -4
- package/dist/calculate-cost.d.ts +26 -2
- package/dist/calculate-cost.js +2 -3
- package/dist/core-eFvU0K4V.js +689 -0
- package/dist/{data-loader-BAoqS297.js → data-loader-B2EwZ_7B.js} +446 -392
- 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 -5
- package/dist/{debug-DzFJHzM5.js → debug-D4Ka6IrY.js} +21 -12
- package/dist/debug.d.ts +17 -0
- package/dist/debug.js +5 -6
- package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +1 -5
- package/dist/dist-DCvt9hEv.js +1 -4
- package/dist/effect-WSjEuzC9-CZCpOgOT.js +6 -0
- package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +2 -111
- package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +6 -9
- package/dist/index.js +1912 -105
- package/dist/{logger-D3WD64Tx.js → logger-DPEwxrOW.js} +9 -22
- package/dist/logger.d.ts +9 -4
- package/dist/logger.js +2 -3
- package/dist/{mcp-1J7r1g6-.js → mcp-CklIto13.js} +366 -947
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +7 -8
- package/dist/{pricing-fetcher-D-eJQBEJ.js → pricing-fetcher-DDs53oR8.js} +151 -14
- 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 +3 -4
- package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +1 -5
- package/dist/sury-DmrZ3_Oj-Lq7x0IZW.js +6 -0
- package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +1 -22
- package/dist/valibot-CQk-M5rL-btpzU8Qa.js +6 -0
- package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +4 -8
- package/package.json +1 -2
- package/dist/arktype-C-GObzDh-CNoBqQrr.js +0 -5
- package/dist/chunk-BLXvPPr8.js +0 -30
- package/dist/core-DHCbAXJf.js +0 -693
- package/dist/effect-WSjEuzC9-DHMVzzyB.js +0 -10
- package/dist/sury-DmrZ3_Oj-Cpjsc2Lm.js +0 -10
- 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
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PricingFetcher, __commonJSMin, __require, __toESM, require_usingCtx } from "./pricing-fetcher-DDs53oR8.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-DPEwxrOW.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
|
-
|
|
12
|
-
//#region node_modules/@jsr/core__unknownutil/is/string.js
|
|
13
10
|
/**
|
|
14
11
|
* Return `true` if the type of `x` is `string`.
|
|
15
12
|
*
|
|
@@ -24,9 +21,6 @@ import path$1, { posix } from "path";
|
|
|
24
21
|
*/ function isString(x) {
|
|
25
22
|
return typeof x === "string";
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region node_modules/@jsr/core__unknownutil/is/record.js
|
|
30
24
|
/**
|
|
31
25
|
* Return `true` if the type of `x` satisfies `Record<PropertyKey, unknown>`.
|
|
32
26
|
*
|
|
@@ -49,9 +43,6 @@ import path$1, { posix } from "path";
|
|
|
49
43
|
*/ function isRecord(x) {
|
|
50
44
|
return x != null && !Array.isArray(x) && typeof x === "object";
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region node_modules/@jsr/core__unknownutil/_inspect.js
|
|
55
46
|
const defaultThreshold = 20;
|
|
56
47
|
/**
|
|
57
48
|
* Inspect a value
|
|
@@ -70,49 +61,40 @@ const defaultThreshold = 20;
|
|
|
70
61
|
}
|
|
71
62
|
function inspectArray(value, options) {
|
|
72
63
|
const { threshold = defaultThreshold } = options;
|
|
73
|
-
const vs = value.map((v) => inspect(v, options));
|
|
64
|
+
const vs = value.map((v$1) => inspect(v$1, options));
|
|
74
65
|
const s = vs.join(", ");
|
|
75
66
|
if (s.length <= threshold) return `[${s}]`;
|
|
76
|
-
const m = vs.join(",\n");
|
|
77
|
-
return `[\n${indent(2, m)}\n]`;
|
|
67
|
+
const m$1 = vs.join(",\n");
|
|
68
|
+
return `[\n${indent(2, m$1)}\n]`;
|
|
78
69
|
}
|
|
79
70
|
function inspectRecord(value, options) {
|
|
80
71
|
const { threshold = defaultThreshold } = options;
|
|
81
|
-
const vs = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)].map((k) => `${k.toString()}: ${inspect(value[k], options)}`);
|
|
72
|
+
const vs = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)].map((k$1) => `${k$1.toString()}: ${inspect(value[k$1], options)}`);
|
|
82
73
|
const s = vs.join(", ");
|
|
83
74
|
if (s.length <= threshold) return `{${s}}`;
|
|
84
|
-
const m = vs.join(",\n");
|
|
85
|
-
return `{\n${indent(2, m)}\n}`;
|
|
75
|
+
const m$1 = vs.join(",\n");
|
|
76
|
+
return `{\n${indent(2, m$1)}\n}`;
|
|
86
77
|
}
|
|
87
78
|
function indent(level, text) {
|
|
88
79
|
const prefix = " ".repeat(level);
|
|
89
80
|
return text.split("\n").map((line) => `${prefix}${line}`).join("\n");
|
|
90
81
|
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region node_modules/@jsr/core__unknownutil/_funcutil.js
|
|
94
82
|
/**
|
|
95
83
|
* Rewrite the function name.
|
|
96
84
|
*/ function rewriteName(fn, name, ...args) {
|
|
97
85
|
let cachedName;
|
|
98
86
|
return Object.defineProperties(fn, { name: { get: () => {
|
|
99
87
|
if (cachedName) return cachedName;
|
|
100
|
-
cachedName = `${name}(${args.map((v) => inspect(v)).join(", ")})`;
|
|
88
|
+
cachedName = `${name}(${args.map((v$1) => inspect(v$1)).join(", ")})`;
|
|
101
89
|
return cachedName;
|
|
102
90
|
} } });
|
|
103
91
|
}
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region node_modules/@jsr/core__unknownutil/_annotation.js
|
|
107
92
|
function annotate(fn, name, value) {
|
|
108
93
|
return Object.defineProperties(fn, { [name]: { value } });
|
|
109
94
|
}
|
|
110
95
|
function hasAnnotation(fn, name) {
|
|
111
96
|
return !!fn[name];
|
|
112
97
|
}
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region node_modules/@jsr/core__unknownutil/is/object_of.js
|
|
116
98
|
/**
|
|
117
99
|
* Return a type predicate function that returns `true` if the type of `x` is `ObjectOf<T>`.
|
|
118
100
|
*
|
|
@@ -141,10 +123,10 @@ function hasAnnotation(fn, name) {
|
|
|
141
123
|
* }
|
|
142
124
|
* ```
|
|
143
125
|
*/ function isObjectOf(predObj) {
|
|
144
|
-
const preds = [...Object.keys(predObj), ...Object.getOwnPropertySymbols(predObj)].map((k) => [k, predObj[k]]);
|
|
126
|
+
const preds = [...Object.keys(predObj), ...Object.getOwnPropertySymbols(predObj)].map((k$1) => [k$1, predObj[k$1]]);
|
|
145
127
|
const pred = rewriteName((x) => {
|
|
146
128
|
if (!isObject$1(x)) return false;
|
|
147
|
-
return preds.every(([k, pred$1]) => pred$1(x[k]));
|
|
129
|
+
return preds.every(([k$1, pred$1]) => pred$1(x[k$1]));
|
|
148
130
|
}, "isObjectOf", predObj);
|
|
149
131
|
return annotate(pred, "predObj", predObj);
|
|
150
132
|
}
|
|
@@ -154,9 +136,6 @@ function isObject$1(x) {
|
|
|
154
136
|
if (Array.isArray(x)) return false;
|
|
155
137
|
return true;
|
|
156
138
|
}
|
|
157
|
-
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region node_modules/@jsr/core__unknownutil/as/optional.js
|
|
160
139
|
/**
|
|
161
140
|
* Annotate the given predicate function as optional.
|
|
162
141
|
*
|
|
@@ -185,9 +164,6 @@ function isObject$1(x) {
|
|
|
185
164
|
if (hasAnnotation(pred, "optional")) return pred;
|
|
186
165
|
return rewriteName(annotate((x) => x === void 0 || pred(x), "optional", pred), "asOptional", pred);
|
|
187
166
|
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region node_modules/@core/errorutil/error_object.js
|
|
191
167
|
/**
|
|
192
168
|
* Check if a value is an error object
|
|
193
169
|
*/ const isErrorObject = isObjectOf({
|
|
@@ -197,9 +173,6 @@ function isObject$1(x) {
|
|
|
197
173
|
stack: asOptional(isString),
|
|
198
174
|
attributes: isRecord
|
|
199
175
|
});
|
|
200
|
-
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region node_modules/@core/errorutil/unreachable.js
|
|
203
176
|
/**
|
|
204
177
|
* Error indicating that this part is unreachable.
|
|
205
178
|
*/ var UnreachableError = class UnreachableError extends Error {
|
|
@@ -263,9 +236,6 @@ function isObject$1(x) {
|
|
|
263
236
|
*/ function unreachable(...args) {
|
|
264
237
|
throw new UnreachableError(args);
|
|
265
238
|
}
|
|
266
|
-
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region node_modules/es-toolkit/dist/array/groupBy.mjs
|
|
269
239
|
function groupBy(arr, getKeyFromItem) {
|
|
270
240
|
const result = {};
|
|
271
241
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -276,12 +246,9 @@ function groupBy(arr, getKeyFromItem) {
|
|
|
276
246
|
}
|
|
277
247
|
return result;
|
|
278
248
|
}
|
|
279
|
-
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region node_modules/fast-sort/dist/sort.mjs
|
|
282
249
|
var castComparer = function(comparer) {
|
|
283
|
-
return function(a, b, order) {
|
|
284
|
-
return comparer(a, b, order) * order;
|
|
250
|
+
return function(a$1, b$1, order) {
|
|
251
|
+
return comparer(a$1, b$1, order) * order;
|
|
285
252
|
};
|
|
286
253
|
};
|
|
287
254
|
var throwInvalidConfigErrorIfTrue = function(condition, context) {
|
|
@@ -301,41 +268,41 @@ var unpackObjectSorter = function(sortByObj) {
|
|
|
301
268
|
};
|
|
302
269
|
};
|
|
303
270
|
var multiPropertySorterProvider = function(defaultComparer$1) {
|
|
304
|
-
return function multiPropertySorter(sortBy, sortByArr, depth$1, order, comparer, a, b) {
|
|
271
|
+
return function multiPropertySorter(sortBy, sortByArr, depth$1, order, comparer, a$1, b$1) {
|
|
305
272
|
var valA;
|
|
306
273
|
var valB;
|
|
307
274
|
if (typeof sortBy === "string") {
|
|
308
|
-
valA = a[sortBy];
|
|
309
|
-
valB = b[sortBy];
|
|
275
|
+
valA = a$1[sortBy];
|
|
276
|
+
valB = b$1[sortBy];
|
|
310
277
|
} else if (typeof sortBy === "function") {
|
|
311
|
-
valA = sortBy(a);
|
|
312
|
-
valB = sortBy(b);
|
|
278
|
+
valA = sortBy(a$1);
|
|
279
|
+
valB = sortBy(b$1);
|
|
313
280
|
} else {
|
|
314
281
|
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
315
|
-
return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth$1, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer$1, a, b);
|
|
282
|
+
return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth$1, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer$1, a$1, b$1);
|
|
316
283
|
}
|
|
317
284
|
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);
|
|
285
|
+
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
286
|
return equality;
|
|
320
287
|
};
|
|
321
288
|
};
|
|
322
289
|
function getSortStrategy(sortBy, comparer, order) {
|
|
323
|
-
if (sortBy === void 0 || sortBy === true) return function(a, b) {
|
|
324
|
-
return comparer(a, b, order);
|
|
290
|
+
if (sortBy === void 0 || sortBy === true) return function(a$1, b$1) {
|
|
291
|
+
return comparer(a$1, b$1, order);
|
|
325
292
|
};
|
|
326
293
|
if (typeof sortBy === "string") {
|
|
327
294
|
throwInvalidConfigErrorIfTrue(sortBy.includes("."), "String syntax not allowed for nested properties.");
|
|
328
|
-
return function(a, b) {
|
|
329
|
-
return comparer(a[sortBy], b[sortBy], order);
|
|
295
|
+
return function(a$1, b$1) {
|
|
296
|
+
return comparer(a$1[sortBy], b$1[sortBy], order);
|
|
330
297
|
};
|
|
331
298
|
}
|
|
332
|
-
if (typeof sortBy === "function") return function(a, b) {
|
|
333
|
-
return comparer(sortBy(a), sortBy(b), order);
|
|
299
|
+
if (typeof sortBy === "function") return function(a$1, b$1) {
|
|
300
|
+
return comparer(sortBy(a$1), sortBy(b$1), order);
|
|
334
301
|
};
|
|
335
302
|
if (Array.isArray(sortBy)) {
|
|
336
303
|
var multiPropSorter_1 = multiPropertySorterProvider(comparer);
|
|
337
|
-
return function(a, b) {
|
|
338
|
-
return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);
|
|
304
|
+
return function(a$1, b$1) {
|
|
305
|
+
return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a$1, b$1);
|
|
339
306
|
};
|
|
340
307
|
}
|
|
341
308
|
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
@@ -364,12 +331,12 @@ function createNewSortInstance(opts) {
|
|
|
364
331
|
};
|
|
365
332
|
};
|
|
366
333
|
}
|
|
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;
|
|
334
|
+
var defaultComparer = function(a$1, b$1, order) {
|
|
335
|
+
if (a$1 == null) return order;
|
|
336
|
+
if (b$1 == null) return -order;
|
|
337
|
+
if (typeof a$1 !== typeof b$1) return typeof a$1 < typeof b$1 ? -1 : 1;
|
|
338
|
+
if (a$1 < b$1) return -1;
|
|
339
|
+
if (a$1 > b$1) return 1;
|
|
373
340
|
return 0;
|
|
374
341
|
};
|
|
375
342
|
var sort = createNewSortInstance({ comparer: defaultComparer });
|
|
@@ -377,13 +344,133 @@ var inPlaceSort = createNewSortInstance({
|
|
|
377
344
|
comparer: defaultComparer,
|
|
378
345
|
inPlaceSorting: true
|
|
379
346
|
});
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
347
|
+
var d = Object.defineProperty;
|
|
348
|
+
var n = (s, t) => d(s, "name", {
|
|
349
|
+
value: t,
|
|
350
|
+
configurable: !0
|
|
351
|
+
});
|
|
352
|
+
typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", {
|
|
353
|
+
configurable: !1,
|
|
354
|
+
enumerable: !1,
|
|
355
|
+
writable: !1,
|
|
356
|
+
value: Symbol.for("asyncDispose")
|
|
357
|
+
});
|
|
358
|
+
var P = class {
|
|
359
|
+
static {
|
|
360
|
+
n(this, "FsFixture");
|
|
361
|
+
}
|
|
362
|
+
path;
|
|
363
|
+
constructor(t) {
|
|
364
|
+
this.path = t;
|
|
365
|
+
}
|
|
366
|
+
getPath(...t) {
|
|
367
|
+
return path.join(this.path, ...t);
|
|
368
|
+
}
|
|
369
|
+
exists(t = "") {
|
|
370
|
+
return a.access(this.getPath(t)).then(() => !0, () => !1);
|
|
371
|
+
}
|
|
372
|
+
rm(t = "") {
|
|
373
|
+
return a.rm(this.getPath(t), {
|
|
374
|
+
recursive: !0,
|
|
375
|
+
force: !0
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
cp(t, r, i) {
|
|
379
|
+
return r ? r.endsWith(path.sep) && (r += path.basename(t)) : r = path.basename(t), a.cp(t, this.getPath(r), i);
|
|
380
|
+
}
|
|
381
|
+
mkdir(t) {
|
|
382
|
+
return a.mkdir(this.getPath(t), { recursive: !0 });
|
|
383
|
+
}
|
|
384
|
+
writeFile(t, r) {
|
|
385
|
+
return a.writeFile(this.getPath(t), r);
|
|
386
|
+
}
|
|
387
|
+
writeJson(t, r) {
|
|
388
|
+
return this.writeFile(t, JSON.stringify(r, null, 2));
|
|
389
|
+
}
|
|
390
|
+
readFile(t, r) {
|
|
391
|
+
return a.readFile(this.getPath(t), r);
|
|
392
|
+
}
|
|
393
|
+
async [Symbol.asyncDispose]() {
|
|
394
|
+
await this.rm();
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const v = b.realpathSync(F.tmpdir()), D = `fs-fixture-${Date.now()}-${process.pid}`;
|
|
398
|
+
let m = 0;
|
|
399
|
+
const j = n(() => (m += 1, m), "getId");
|
|
400
|
+
var u = class {
|
|
401
|
+
static {
|
|
402
|
+
n(this, "Path");
|
|
403
|
+
}
|
|
404
|
+
path;
|
|
405
|
+
constructor(t) {
|
|
406
|
+
this.path = t;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var f = class extends u {
|
|
410
|
+
static {
|
|
411
|
+
n(this, "Directory");
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var y = class extends u {
|
|
415
|
+
static {
|
|
416
|
+
n(this, "File");
|
|
417
|
+
}
|
|
418
|
+
content;
|
|
419
|
+
constructor(t, r) {
|
|
420
|
+
super(t), this.content = r;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
var l = class {
|
|
424
|
+
static {
|
|
425
|
+
n(this, "Symlink");
|
|
426
|
+
}
|
|
427
|
+
target;
|
|
428
|
+
type;
|
|
429
|
+
path;
|
|
430
|
+
constructor(t, r) {
|
|
431
|
+
this.target = t, this.type = r;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
const w = n((s, t, r) => {
|
|
435
|
+
const i = [];
|
|
436
|
+
for (const p in s) {
|
|
437
|
+
if (!Object.hasOwn(s, p)) continue;
|
|
438
|
+
const e = path.join(t, p);
|
|
439
|
+
let o = s[p];
|
|
440
|
+
if (typeof o == "function") {
|
|
441
|
+
const g = Object.assign(Object.create(r), { filePath: e }), h = o(g);
|
|
442
|
+
if (h instanceof l) {
|
|
443
|
+
h.path = e, i.push(h);
|
|
444
|
+
continue;
|
|
445
|
+
} else o = h;
|
|
446
|
+
}
|
|
447
|
+
typeof o == "string" ? i.push(new y(e, o)) : i.push(new f(e), ...w(o, e, r));
|
|
448
|
+
}
|
|
449
|
+
return i;
|
|
450
|
+
}, "flattenFileTree"), k = n(async (s, t) => {
|
|
451
|
+
const r = t?.tempDir ? path.resolve(t.tempDir) : v, i = path.join(r, `${D}-${j()}/`);
|
|
452
|
+
if (await a.mkdir(i, { recursive: !0 }), s) {
|
|
453
|
+
if (typeof s == "string") await a.cp(s, i, {
|
|
454
|
+
recursive: !0,
|
|
455
|
+
filter: t?.templateFilter
|
|
456
|
+
});
|
|
457
|
+
else if (typeof s == "object") {
|
|
458
|
+
const p = {
|
|
459
|
+
fixturePath: i,
|
|
460
|
+
getPath: n((...e) => path.join(i, ...e), "getPath"),
|
|
461
|
+
symlink: n((e, o) => new l(e, o), "symlink")
|
|
462
|
+
};
|
|
463
|
+
await Promise.all(w(s, i, p).map(async (e) => {
|
|
464
|
+
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));
|
|
465
|
+
}));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return new P(i);
|
|
469
|
+
}, "createFixture");
|
|
383
470
|
async function isType(fsStatType, statsMethodName, filePath) {
|
|
384
471
|
if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
385
472
|
try {
|
|
386
|
-
const stats = await
|
|
473
|
+
const stats = await a[fsStatType](filePath);
|
|
387
474
|
return stats[statsMethodName]();
|
|
388
475
|
} catch (error) {
|
|
389
476
|
if (error.code === "ENOENT") return false;
|
|
@@ -393,7 +480,7 @@ async function isType(fsStatType, statsMethodName, filePath) {
|
|
|
393
480
|
function isTypeSync(fsStatType, statsMethodName, filePath) {
|
|
394
481
|
if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
395
482
|
try {
|
|
396
|
-
return
|
|
483
|
+
return b[fsStatType](filePath)[statsMethodName]();
|
|
397
484
|
} catch (error) {
|
|
398
485
|
if (error.code === "ENOENT") return false;
|
|
399
486
|
throw error;
|
|
@@ -405,29 +492,26 @@ const isSymlink = isType.bind(void 0, "lstat", "isSymbolicLink");
|
|
|
405
492
|
const isFileSync = isTypeSync.bind(void 0, "statSync", "isFile");
|
|
406
493
|
const isDirectorySync = isTypeSync.bind(void 0, "statSync", "isDirectory");
|
|
407
494
|
const isSymlinkSync = isTypeSync.bind(void 0, "lstatSync", "isSymbolicLink");
|
|
408
|
-
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region node_modules/fdir/dist/utils.js
|
|
411
|
-
var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
495
|
+
var require_utils$1 = __commonJSMin((exports) => {
|
|
412
496
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
413
|
-
exports.cleanPath =
|
|
414
|
-
exports.convertSlashes = convertSlashes;
|
|
415
|
-
exports.isRootDirectory = isRootDirectory;
|
|
416
|
-
exports.normalizePath = normalizePath;
|
|
497
|
+
exports.normalizePath = exports.isRootDirectory = exports.convertSlashes = exports.cleanPath = void 0;
|
|
417
498
|
const path_1$4 = __require("path");
|
|
418
499
|
function cleanPath(path$2) {
|
|
419
500
|
let normalized = (0, path_1$4.normalize)(path$2);
|
|
420
501
|
if (normalized.length > 1 && normalized[normalized.length - 1] === path_1$4.sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
421
502
|
return normalized;
|
|
422
503
|
}
|
|
504
|
+
exports.cleanPath = cleanPath;
|
|
423
505
|
const SLASHES_REGEX = /[\\/]/g;
|
|
424
506
|
function convertSlashes(path$2, separator) {
|
|
425
507
|
return path$2.replace(SLASHES_REGEX, separator);
|
|
426
508
|
}
|
|
509
|
+
exports.convertSlashes = convertSlashes;
|
|
427
510
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
428
511
|
function isRootDirectory(path$2) {
|
|
429
512
|
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
430
513
|
}
|
|
514
|
+
exports.isRootDirectory = isRootDirectory;
|
|
431
515
|
function normalizePath(path$2, options) {
|
|
432
516
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
433
517
|
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
@@ -437,20 +521,17 @@ var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
|
437
521
|
const needsSeperator = path$2[path$2.length - 1] !== pathSeparator;
|
|
438
522
|
return convertSlashes(needsSeperator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
439
523
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
//#region node_modules/fdir/dist/api/functions/join-path.js
|
|
444
|
-
var require_join_path = __commonJS({ "node_modules/fdir/dist/api/functions/join-path.js"(exports) {
|
|
524
|
+
exports.normalizePath = normalizePath;
|
|
525
|
+
});
|
|
526
|
+
var require_join_path = __commonJSMin((exports) => {
|
|
445
527
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
446
|
-
exports.joinPathWithBasePath =
|
|
447
|
-
exports.joinDirectoryPath = joinDirectoryPath;
|
|
448
|
-
exports.build = build$7;
|
|
528
|
+
exports.build = exports.joinDirectoryPath = exports.joinPathWithBasePath = void 0;
|
|
449
529
|
const path_1$3 = __require("path");
|
|
450
530
|
const utils_1$1 = require_utils$1();
|
|
451
531
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
452
532
|
return directoryPath + filename;
|
|
453
533
|
}
|
|
534
|
+
exports.joinPathWithBasePath = joinPathWithBasePath;
|
|
454
535
|
function joinPathWithRelativePath(root, options) {
|
|
455
536
|
return function(filename, directoryPath) {
|
|
456
537
|
const sameRoot = directoryPath.startsWith(root);
|
|
@@ -464,17 +545,16 @@ var require_join_path = __commonJS({ "node_modules/fdir/dist/api/functions/join-
|
|
|
464
545
|
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
465
546
|
return directoryPath + filename + separator;
|
|
466
547
|
}
|
|
548
|
+
exports.joinDirectoryPath = joinDirectoryPath;
|
|
467
549
|
function build$7(root, options) {
|
|
468
550
|
const { relativePaths, includeBasePath } = options;
|
|
469
551
|
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath$1;
|
|
470
552
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
//#region node_modules/fdir/dist/api/functions/push-directory.js
|
|
475
|
-
var require_push_directory = __commonJS({ "node_modules/fdir/dist/api/functions/push-directory.js"(exports) {
|
|
553
|
+
exports.build = build$7;
|
|
554
|
+
});
|
|
555
|
+
var require_push_directory = __commonJSMin((exports) => {
|
|
476
556
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
477
|
-
exports.build =
|
|
557
|
+
exports.build = void 0;
|
|
478
558
|
function pushDirectoryWithRelativePath(root) {
|
|
479
559
|
return function(directoryPath, paths) {
|
|
480
560
|
paths.push(directoryPath.substring(root.length) || ".");
|
|
@@ -500,13 +580,11 @@ var require_push_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
500
580
|
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
501
581
|
return filters && filters.length ? pushDirectoryFilter : pushDirectory$1;
|
|
502
582
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
//#region node_modules/fdir/dist/api/functions/push-file.js
|
|
507
|
-
var require_push_file = __commonJS({ "node_modules/fdir/dist/api/functions/push-file.js"(exports) {
|
|
583
|
+
exports.build = build$6;
|
|
584
|
+
});
|
|
585
|
+
var require_push_file = __commonJSMin((exports) => {
|
|
508
586
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
509
|
-
exports.build =
|
|
587
|
+
exports.build = void 0;
|
|
510
588
|
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
511
589
|
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
512
590
|
};
|
|
@@ -527,13 +605,11 @@ var require_push_file = __commonJS({ "node_modules/fdir/dist/api/functions/push-
|
|
|
527
605
|
else if (onlyCounts) return pushFileCount;
|
|
528
606
|
else return pushFile$1;
|
|
529
607
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
//#region node_modules/fdir/dist/api/functions/get-array.js
|
|
534
|
-
var require_get_array = __commonJS({ "node_modules/fdir/dist/api/functions/get-array.js"(exports) {
|
|
608
|
+
exports.build = build$5;
|
|
609
|
+
});
|
|
610
|
+
var require_get_array = __commonJSMin((exports) => {
|
|
535
611
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
536
|
-
exports.build =
|
|
612
|
+
exports.build = void 0;
|
|
537
613
|
const getArray$1 = (paths) => {
|
|
538
614
|
return paths;
|
|
539
615
|
};
|
|
@@ -543,13 +619,11 @@ var require_get_array = __commonJS({ "node_modules/fdir/dist/api/functions/get-a
|
|
|
543
619
|
function build$4(options) {
|
|
544
620
|
return options.group ? getArrayGroup : getArray$1;
|
|
545
621
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
//#region node_modules/fdir/dist/api/functions/group-files.js
|
|
550
|
-
var require_group_files = __commonJS({ "node_modules/fdir/dist/api/functions/group-files.js"(exports) {
|
|
622
|
+
exports.build = build$4;
|
|
623
|
+
});
|
|
624
|
+
var require_group_files = __commonJSMin((exports) => {
|
|
551
625
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
552
|
-
exports.build =
|
|
626
|
+
exports.build = void 0;
|
|
553
627
|
const groupFiles$1 = (groups, directory, files) => {
|
|
554
628
|
groups.push({
|
|
555
629
|
directory,
|
|
@@ -561,16 +635,14 @@ var require_group_files = __commonJS({ "node_modules/fdir/dist/api/functions/gro
|
|
|
561
635
|
function build$3(options) {
|
|
562
636
|
return options.group ? groupFiles$1 : empty;
|
|
563
637
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions/resolve-symlink.js"(exports) {
|
|
569
|
-
var __importDefault$1 = void 0 && (void 0).__importDefault || function(mod) {
|
|
638
|
+
exports.build = build$3;
|
|
639
|
+
});
|
|
640
|
+
var require_resolve_symlink = __commonJSMin((exports) => {
|
|
641
|
+
var __importDefault$1 = function(mod) {
|
|
570
642
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
571
643
|
};
|
|
572
644
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
573
|
-
exports.build =
|
|
645
|
+
exports.build = void 0;
|
|
574
646
|
const fs_1$1 = __importDefault$1(__require("fs"));
|
|
575
647
|
const path_1$2 = __require("path");
|
|
576
648
|
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
@@ -602,6 +674,7 @@ var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
602
674
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
603
675
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
604
676
|
}
|
|
677
|
+
exports.build = build$2;
|
|
605
678
|
function isRecursive(path$2, resolved, state) {
|
|
606
679
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
607
680
|
let parent = (0, path_1$2.dirname)(path$2);
|
|
@@ -618,13 +691,10 @@ var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
618
691
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
619
692
|
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
620
693
|
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region node_modules/fdir/dist/api/functions/invoke-callback.js
|
|
625
|
-
var require_invoke_callback = __commonJS({ "node_modules/fdir/dist/api/functions/invoke-callback.js"(exports) {
|
|
694
|
+
});
|
|
695
|
+
var require_invoke_callback = __commonJSMin((exports) => {
|
|
626
696
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
627
|
-
exports.build =
|
|
697
|
+
exports.build = void 0;
|
|
628
698
|
const onlyCountsSync = (state) => {
|
|
629
699
|
return state.counts;
|
|
630
700
|
};
|
|
@@ -664,21 +734,19 @@ var require_invoke_callback = __commonJS({ "node_modules/fdir/dist/api/functions
|
|
|
664
734
|
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
665
735
|
else return isSynchronous ? defaultSync : defaultAsync;
|
|
666
736
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/walk-directory.js"(exports) {
|
|
672
|
-
var __importDefault = void 0 && (void 0).__importDefault || function(mod) {
|
|
737
|
+
exports.build = build$1;
|
|
738
|
+
});
|
|
739
|
+
var require_walk_directory = __commonJSMin((exports) => {
|
|
740
|
+
var __importDefault = function(mod) {
|
|
673
741
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
674
742
|
};
|
|
675
743
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
676
|
-
exports.build =
|
|
744
|
+
exports.build = void 0;
|
|
677
745
|
const fs_1 = __importDefault(__require("fs"));
|
|
678
746
|
const readdirOpts = { withFileTypes: true };
|
|
679
747
|
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
680
748
|
state.queue.enqueue();
|
|
681
|
-
if (currentDepth
|
|
749
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
682
750
|
state.visited.push(crawlPath);
|
|
683
751
|
state.counts.directories++;
|
|
684
752
|
fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
@@ -687,7 +755,7 @@ var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
687
755
|
});
|
|
688
756
|
};
|
|
689
757
|
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
690
|
-
if (currentDepth
|
|
758
|
+
if (currentDepth < 0) return;
|
|
691
759
|
state.visited.push(crawlPath);
|
|
692
760
|
state.counts.directories++;
|
|
693
761
|
let entries = [];
|
|
@@ -701,11 +769,9 @@ var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/
|
|
|
701
769
|
function build(isSynchronous) {
|
|
702
770
|
return isSynchronous ? walkSync : walkAsync;
|
|
703
771
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
//#region node_modules/fdir/dist/api/queue.js
|
|
708
|
-
var require_queue = __commonJS({ "node_modules/fdir/dist/api/queue.js"(exports) {
|
|
772
|
+
exports.build = build;
|
|
773
|
+
});
|
|
774
|
+
var require_queue = __commonJSMin((exports) => {
|
|
709
775
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
710
776
|
exports.Queue = void 0;
|
|
711
777
|
/**
|
|
@@ -734,11 +800,8 @@ var require_queue = __commonJS({ "node_modules/fdir/dist/api/queue.js"(exports)
|
|
|
734
800
|
}
|
|
735
801
|
};
|
|
736
802
|
exports.Queue = Queue;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
//#endregion
|
|
740
|
-
//#region node_modules/fdir/dist/api/counter.js
|
|
741
|
-
var require_counter = __commonJS({ "node_modules/fdir/dist/api/counter.js"(exports) {
|
|
803
|
+
});
|
|
804
|
+
var require_counter = __commonJSMin((exports) => {
|
|
742
805
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
743
806
|
exports.Counter = void 0;
|
|
744
807
|
var Counter = class {
|
|
@@ -765,52 +828,39 @@ var require_counter = __commonJS({ "node_modules/fdir/dist/api/counter.js"(expor
|
|
|
765
828
|
}
|
|
766
829
|
};
|
|
767
830
|
exports.Counter = Counter;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
var
|
|
773
|
-
|
|
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 = {
|
|
831
|
+
});
|
|
832
|
+
var require_walker = __commonJSMin((exports) => {
|
|
833
|
+
var __createBinding$1 = Object.create ? function(o, m$1, k$1, k2) {
|
|
834
|
+
if (k2 === void 0) k2 = k$1;
|
|
835
|
+
var desc = Object.getOwnPropertyDescriptor(m$1, k$1);
|
|
836
|
+
if (!desc || ("get" in desc ? !m$1.__esModule : desc.writable || desc.configurable)) desc = {
|
|
777
837
|
enumerable: true,
|
|
778
838
|
get: function() {
|
|
779
|
-
return m[k];
|
|
839
|
+
return m$1[k$1];
|
|
780
840
|
}
|
|
781
841
|
};
|
|
782
842
|
Object.defineProperty(o, k2, desc);
|
|
783
|
-
} : function(o, m, k, k2) {
|
|
784
|
-
if (k2 === void 0) k2 = k;
|
|
785
|
-
o[k2] = m[k];
|
|
786
|
-
}
|
|
787
|
-
var __setModuleDefault =
|
|
843
|
+
} : function(o, m$1, k$1, k2) {
|
|
844
|
+
if (k2 === void 0) k2 = k$1;
|
|
845
|
+
o[k2] = m$1[k$1];
|
|
846
|
+
};
|
|
847
|
+
var __setModuleDefault = Object.create ? function(o, v$1) {
|
|
788
848
|
Object.defineProperty(o, "default", {
|
|
789
849
|
enumerable: true,
|
|
790
|
-
value: v
|
|
850
|
+
value: v$1
|
|
791
851
|
});
|
|
792
|
-
} : function(o, v) {
|
|
793
|
-
o["default"] = v;
|
|
794
|
-
}
|
|
795
|
-
var __importStar =
|
|
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
|
-
}();
|
|
852
|
+
} : function(o, v$1) {
|
|
853
|
+
o["default"] = v$1;
|
|
854
|
+
};
|
|
855
|
+
var __importStar = function(mod) {
|
|
856
|
+
if (mod && mod.__esModule) return mod;
|
|
857
|
+
var result = {};
|
|
858
|
+
if (mod != null) {
|
|
859
|
+
for (var k$1 in mod) if (k$1 !== "default" && Object.prototype.hasOwnProperty.call(mod, k$1)) __createBinding$1(result, mod, k$1);
|
|
860
|
+
}
|
|
861
|
+
__setModuleDefault(result, mod);
|
|
862
|
+
return result;
|
|
863
|
+
};
|
|
814
864
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
815
865
|
exports.Walker = void 0;
|
|
816
866
|
const path_1$1 = __require("path");
|
|
@@ -900,14 +950,10 @@ var require_walker = __commonJS({ "node_modules/fdir/dist/api/walker.js"(exports
|
|
|
900
950
|
};
|
|
901
951
|
};
|
|
902
952
|
exports.Walker = Walker;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
//#endregion
|
|
906
|
-
//#region node_modules/fdir/dist/api/async.js
|
|
907
|
-
var require_async = __commonJS({ "node_modules/fdir/dist/api/async.js"(exports) {
|
|
953
|
+
});
|
|
954
|
+
var require_async = __commonJSMin((exports) => {
|
|
908
955
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
909
|
-
exports.promise =
|
|
910
|
-
exports.callback = callback;
|
|
956
|
+
exports.callback = exports.promise = void 0;
|
|
911
957
|
const walker_1$1 = require_walker();
|
|
912
958
|
function promise(root, options) {
|
|
913
959
|
return new Promise((resolve, reject) => {
|
|
@@ -917,27 +963,24 @@ var require_async = __commonJS({ "node_modules/fdir/dist/api/async.js"(exports)
|
|
|
917
963
|
});
|
|
918
964
|
});
|
|
919
965
|
}
|
|
966
|
+
exports.promise = promise;
|
|
920
967
|
function callback(root, options, callback$1) {
|
|
921
968
|
let walker = new walker_1$1.Walker(root, options, callback$1);
|
|
922
969
|
walker.start();
|
|
923
970
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
//#region node_modules/fdir/dist/api/sync.js
|
|
928
|
-
var require_sync = __commonJS({ "node_modules/fdir/dist/api/sync.js"(exports) {
|
|
971
|
+
exports.callback = callback;
|
|
972
|
+
});
|
|
973
|
+
var require_sync = __commonJSMin((exports) => {
|
|
929
974
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
930
|
-
exports.sync =
|
|
975
|
+
exports.sync = void 0;
|
|
931
976
|
const walker_1 = require_walker();
|
|
932
977
|
function sync(root, options) {
|
|
933
978
|
const walker = new walker_1.Walker(root, options);
|
|
934
979
|
return walker.start();
|
|
935
980
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
//#region node_modules/fdir/dist/builder/api-builder.js
|
|
940
|
-
var require_api_builder = __commonJS({ "node_modules/fdir/dist/builder/api-builder.js"(exports) {
|
|
981
|
+
exports.sync = sync;
|
|
982
|
+
});
|
|
983
|
+
var require_api_builder = __commonJSMin((exports) => {
|
|
941
984
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
942
985
|
exports.APIBuilder = void 0;
|
|
943
986
|
const async_1 = require_async();
|
|
@@ -960,11 +1003,8 @@ var require_api_builder = __commonJS({ "node_modules/fdir/dist/builder/api-build
|
|
|
960
1003
|
}
|
|
961
1004
|
};
|
|
962
1005
|
exports.APIBuilder = APIBuilder;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
//#endregion
|
|
966
|
-
//#region node_modules/picomatch/lib/constants.js
|
|
967
|
-
var require_constants = __commonJS({ "node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
1006
|
+
});
|
|
1007
|
+
var require_constants = __commonJSMin((exports, module) => {
|
|
968
1008
|
const WIN_SLASH = "\\\\/";
|
|
969
1009
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
970
1010
|
/**
|
|
@@ -1131,11 +1171,8 @@ var require_constants = __commonJS({ "node_modules/picomatch/lib/constants.js"(e
|
|
|
1131
1171
|
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
1132
1172
|
}
|
|
1133
1173
|
};
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region node_modules/picomatch/lib/utils.js
|
|
1138
|
-
var require_utils = __commonJS({ "node_modules/picomatch/lib/utils.js"(exports) {
|
|
1174
|
+
});
|
|
1175
|
+
var require_utils = __commonJSMin((exports) => {
|
|
1139
1176
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
1140
1177
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1141
1178
|
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
@@ -1182,11 +1219,8 @@ var require_utils = __commonJS({ "node_modules/picomatch/lib/utils.js"(exports)
|
|
|
1182
1219
|
if (last === "") return segs[segs.length - 2];
|
|
1183
1220
|
return last;
|
|
1184
1221
|
};
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
//#endregion
|
|
1188
|
-
//#region node_modules/picomatch/lib/scan.js
|
|
1189
|
-
var require_scan = __commonJS({ "node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
1222
|
+
});
|
|
1223
|
+
var require_scan = __commonJSMin((exports, module) => {
|
|
1190
1224
|
const utils$3 = require_utils();
|
|
1191
1225
|
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
1192
1226
|
const isPathSeparator = (code) => {
|
|
@@ -1442,9 +1476,9 @@ var require_scan = __commonJS({ "node_modules/picomatch/lib/scan.js"(exports, mo
|
|
|
1442
1476
|
if (opts.parts === true || opts.tokens === true) {
|
|
1443
1477
|
let prevIndex;
|
|
1444
1478
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1445
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
1479
|
+
const n$1 = prevIndex ? prevIndex + 1 : start;
|
|
1446
1480
|
const i = slashes[idx];
|
|
1447
|
-
const value = input.slice(n, i);
|
|
1481
|
+
const value = input.slice(n$1, i);
|
|
1448
1482
|
if (opts.tokens) {
|
|
1449
1483
|
if (idx === 0 && start !== 0) {
|
|
1450
1484
|
tokens[idx].isPrefix = true;
|
|
@@ -1471,11 +1505,8 @@ var require_scan = __commonJS({ "node_modules/picomatch/lib/scan.js"(exports, mo
|
|
|
1471
1505
|
return state;
|
|
1472
1506
|
};
|
|
1473
1507
|
module.exports = scan$1;
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
//#endregion
|
|
1477
|
-
//#region node_modules/picomatch/lib/parse.js
|
|
1478
|
-
var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
1508
|
+
});
|
|
1509
|
+
var require_parse = __commonJSMin((exports, module) => {
|
|
1479
1510
|
const constants$1 = require_constants();
|
|
1480
1511
|
const utils$2 = require_utils();
|
|
1481
1512
|
/**
|
|
@@ -1492,7 +1523,7 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1492
1523
|
try {
|
|
1493
1524
|
new RegExp(value);
|
|
1494
1525
|
} catch (ex) {
|
|
1495
|
-
return args.map((v) => utils$2.escapeRegex(v)).join("..");
|
|
1526
|
+
return args.map((v$1) => utils$2.escapeRegex(v$1)).join("..");
|
|
1496
1527
|
}
|
|
1497
1528
|
return value;
|
|
1498
1529
|
};
|
|
@@ -1561,7 +1592,7 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1561
1592
|
* Tokenizing helpers
|
|
1562
1593
|
*/
|
|
1563
1594
|
const eos = () => state.index === len - 1;
|
|
1564
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1595
|
+
const peek = state.peek = (n$1 = 1) => input[state.index + n$1];
|
|
1565
1596
|
const advance = state.advance = () => input[++state.index] || "";
|
|
1566
1597
|
const remaining = () => input.slice(state.index + 1);
|
|
1567
1598
|
const consume = (value$1 = "", num = 0) => {
|
|
@@ -1675,10 +1706,10 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1675
1706
|
*/
|
|
1676
1707
|
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1677
1708
|
let backslashes = false;
|
|
1678
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1709
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m$1, esc, chars, first, rest, index) => {
|
|
1679
1710
|
if (first === "\\") {
|
|
1680
1711
|
backslashes = true;
|
|
1681
|
-
return m;
|
|
1712
|
+
return m$1;
|
|
1682
1713
|
}
|
|
1683
1714
|
if (first === "?") {
|
|
1684
1715
|
if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
|
|
@@ -1690,11 +1721,11 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
1690
1721
|
if (esc) return esc + first + (rest ? star : "");
|
|
1691
1722
|
return star;
|
|
1692
1723
|
}
|
|
1693
|
-
return esc ? m : `\\${m}`;
|
|
1724
|
+
return esc ? m$1 : `\\${m$1}`;
|
|
1694
1725
|
});
|
|
1695
1726
|
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 ? "\\" : "";
|
|
1727
|
+
else output = output.replace(/\\+/g, (m$1) => {
|
|
1728
|
+
return m$1.length % 2 === 0 ? "\\\\" : m$1 ? "\\" : "";
|
|
1698
1729
|
});
|
|
1699
1730
|
if (output === input && opts.contains === true) {
|
|
1700
1731
|
state.output = input;
|
|
@@ -2336,11 +2367,8 @@ var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports,
|
|
|
2336
2367
|
return source;
|
|
2337
2368
|
};
|
|
2338
2369
|
module.exports = parse$1;
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
//#endregion
|
|
2342
|
-
//#region node_modules/picomatch/lib/picomatch.js
|
|
2343
|
-
var require_picomatch$1 = __commonJS({ "node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
2370
|
+
});
|
|
2371
|
+
var require_picomatch$1 = __commonJSMin((exports, module) => {
|
|
2344
2372
|
const scan = require_scan();
|
|
2345
2373
|
const parse = require_parse();
|
|
2346
2374
|
const utils$1 = require_utils();
|
|
@@ -2630,11 +2658,8 @@ var require_picomatch$1 = __commonJS({ "node_modules/picomatch/lib/picomatch.js"
|
|
|
2630
2658
|
* Expose "picomatch"
|
|
2631
2659
|
*/
|
|
2632
2660
|
module.exports = picomatch$2;
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
//#endregion
|
|
2636
|
-
//#region node_modules/picomatch/index.js
|
|
2637
|
-
var require_picomatch = __commonJS({ "node_modules/picomatch/index.js"(exports, module) {
|
|
2661
|
+
});
|
|
2662
|
+
var require_picomatch = __commonJSMin((exports, module) => {
|
|
2638
2663
|
const pico = require_picomatch$1();
|
|
2639
2664
|
const utils = require_utils();
|
|
2640
2665
|
function picomatch$1(glob$1, options, returnState = false) {
|
|
@@ -2646,11 +2671,8 @@ var require_picomatch = __commonJS({ "node_modules/picomatch/index.js"(exports,
|
|
|
2646
2671
|
}
|
|
2647
2672
|
Object.assign(picomatch$1, pico);
|
|
2648
2673
|
module.exports = picomatch$1;
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
//#endregion
|
|
2652
|
-
//#region node_modules/fdir/dist/builder/index.js
|
|
2653
|
-
var require_builder = __commonJS({ "node_modules/fdir/dist/builder/index.js"(exports) {
|
|
2674
|
+
});
|
|
2675
|
+
var require_builder = __commonJSMin((exports) => {
|
|
2654
2676
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2655
2677
|
exports.Builder = void 0;
|
|
2656
2678
|
const path_1 = __require("path");
|
|
@@ -2784,33 +2806,27 @@ var require_builder = __commonJS({ "node_modules/fdir/dist/builder/index.js"(exp
|
|
|
2784
2806
|
}
|
|
2785
2807
|
};
|
|
2786
2808
|
exports.Builder = Builder;
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
//#endregion
|
|
2790
|
-
//#region node_modules/fdir/dist/types.js
|
|
2791
|
-
var require_types = __commonJS({ "node_modules/fdir/dist/types.js"(exports) {
|
|
2809
|
+
});
|
|
2810
|
+
var require_types = __commonJSMin((exports) => {
|
|
2792
2811
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2793
|
-
}
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
var
|
|
2798
|
-
|
|
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 = {
|
|
2812
|
+
});
|
|
2813
|
+
var require_dist$1 = __commonJSMin((exports) => {
|
|
2814
|
+
var __createBinding = Object.create ? function(o, m$1, k$1, k2) {
|
|
2815
|
+
if (k2 === void 0) k2 = k$1;
|
|
2816
|
+
var desc = Object.getOwnPropertyDescriptor(m$1, k$1);
|
|
2817
|
+
if (!desc || ("get" in desc ? !m$1.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2802
2818
|
enumerable: true,
|
|
2803
2819
|
get: function() {
|
|
2804
|
-
return m[k];
|
|
2820
|
+
return m$1[k$1];
|
|
2805
2821
|
}
|
|
2806
2822
|
};
|
|
2807
2823
|
Object.defineProperty(o, k2, desc);
|
|
2808
|
-
} : function(o, m, k, k2) {
|
|
2809
|
-
if (k2 === void 0) k2 = k;
|
|
2810
|
-
o[k2] = m[k];
|
|
2811
|
-
}
|
|
2812
|
-
var __exportStar =
|
|
2813
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
2824
|
+
} : function(o, m$1, k$1, k2) {
|
|
2825
|
+
if (k2 === void 0) k2 = k$1;
|
|
2826
|
+
o[k2] = m$1[k$1];
|
|
2827
|
+
};
|
|
2828
|
+
var __exportStar = function(m$1, exports$1) {
|
|
2829
|
+
for (var p in m$1) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m$1, p);
|
|
2814
2830
|
};
|
|
2815
2831
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2816
2832
|
exports.fdir = void 0;
|
|
@@ -2822,10 +2838,7 @@ var require_dist$1 = __commonJS({ "node_modules/fdir/dist/index.js"(exports) {
|
|
|
2822
2838
|
}
|
|
2823
2839
|
});
|
|
2824
2840
|
__exportStar(require_types(), exports);
|
|
2825
|
-
}
|
|
2826
|
-
|
|
2827
|
-
//#endregion
|
|
2828
|
-
//#region node_modules/tinyglobby/dist/index.mjs
|
|
2841
|
+
});
|
|
2829
2842
|
var import_dist = __toESM(require_dist$1(), 1);
|
|
2830
2843
|
var import_picomatch = __toESM(require_picomatch(), 1);
|
|
2831
2844
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
@@ -2838,7 +2851,7 @@ function getPartialMatcher(patterns, options) {
|
|
|
2838
2851
|
patternsParts[i] = parts;
|
|
2839
2852
|
const partsCount = parts.length;
|
|
2840
2853
|
const partRegexes = Array(partsCount);
|
|
2841
|
-
for (let j = 0; j < partsCount; j++) partRegexes[j] = import_picomatch.default.makeRe(parts[j], options);
|
|
2854
|
+
for (let j$1 = 0; j$1 < partsCount; j$1++) partRegexes[j$1] = import_picomatch.default.makeRe(parts[j$1], options);
|
|
2842
2855
|
regexes[i] = partRegexes;
|
|
2843
2856
|
}
|
|
2844
2857
|
return (input) => {
|
|
@@ -2849,16 +2862,16 @@ function getPartialMatcher(patterns, options) {
|
|
|
2849
2862
|
const regex$1 = regexes[i];
|
|
2850
2863
|
const inputPatternCount = inputParts.length;
|
|
2851
2864
|
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2852
|
-
let j = 0;
|
|
2853
|
-
while (j < minParts) {
|
|
2854
|
-
const part = patternParts[j];
|
|
2865
|
+
let j$1 = 0;
|
|
2866
|
+
while (j$1 < minParts) {
|
|
2867
|
+
const part = patternParts[j$1];
|
|
2855
2868
|
if (part.includes("/")) return true;
|
|
2856
|
-
const match = regex$1[j].test(inputParts[j]);
|
|
2869
|
+
const match = regex$1[j$1].test(inputParts[j$1]);
|
|
2857
2870
|
if (!match) break;
|
|
2858
2871
|
if (part === "**") return true;
|
|
2859
|
-
j++;
|
|
2872
|
+
j$1++;
|
|
2860
2873
|
}
|
|
2861
|
-
if (j === inputPatternCount) return true;
|
|
2874
|
+
if (j$1 === inputPatternCount) return true;
|
|
2862
2875
|
}
|
|
2863
2876
|
return false;
|
|
2864
2877
|
};
|
|
@@ -2896,17 +2909,17 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2896
2909
|
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2897
2910
|
const parts = splitPattern(result);
|
|
2898
2911
|
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
|
2899
|
-
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2912
|
+
const n$1 = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2900
2913
|
let i = 0;
|
|
2901
2914
|
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) || ".";
|
|
2915
|
+
while (i < n$1 && parts[i + n$1] === cwdParts[cwdParts.length + i - n$1]) {
|
|
2916
|
+
result = result.slice(0, (n$1 - i - 1) * 3) + result.slice((n$1 - i) * 3 + parts[i + n$1].length + 1) || ".";
|
|
2904
2917
|
i++;
|
|
2905
2918
|
}
|
|
2906
2919
|
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
|
2907
2920
|
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2908
2921
|
props.root = potentialRoot;
|
|
2909
|
-
props.depthOffset = -n + i;
|
|
2922
|
+
props.depthOffset = -n$1 + i;
|
|
2910
2923
|
}
|
|
2911
2924
|
}
|
|
2912
2925
|
if (!isIgnore && props.depthOffset >= 0) {
|
|
@@ -3040,15 +3053,26 @@ async function glob(patternsOrOptions, options) {
|
|
|
3040
3053
|
const cwd = opts.cwd ? path$1.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
3041
3054
|
return crawl(opts, cwd, false);
|
|
3042
3055
|
}
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
const
|
|
3056
|
+
/**
|
|
3057
|
+
* Default session duration in hours (Claude's billing block duration)
|
|
3058
|
+
*/
|
|
3059
|
+
const DEFAULT_SESSION_DURATION_HOURS = 5;
|
|
3060
|
+
/**
|
|
3061
|
+
* Default number of recent days to include when filtering blocks
|
|
3062
|
+
*/
|
|
3047
3063
|
const DEFAULT_RECENT_DAYS = 3;
|
|
3048
|
-
|
|
3064
|
+
/**
|
|
3065
|
+
* Identifies and creates session blocks from usage entries
|
|
3066
|
+
* Groups entries into time-based blocks (typically 5-hour periods) with gap detection
|
|
3067
|
+
* @param entries - Array of usage entries to process
|
|
3068
|
+
* @param sessionDurationHours - Duration of each session block in hours
|
|
3069
|
+
* @returns Array of session blocks with aggregated usage data
|
|
3070
|
+
*/
|
|
3071
|
+
function identifySessionBlocks(entries, sessionDurationHours = DEFAULT_SESSION_DURATION_HOURS) {
|
|
3049
3072
|
if (entries.length === 0) return [];
|
|
3073
|
+
const sessionDurationMs = sessionDurationHours * 60 * 60 * 1e3;
|
|
3050
3074
|
const blocks = [];
|
|
3051
|
-
const sortedEntries = [...entries].sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
|
3075
|
+
const sortedEntries = [...entries].sort((a$1, b$1) => a$1.timestamp.getTime() - b$1.timestamp.getTime());
|
|
3052
3076
|
let currentBlockStart = null;
|
|
3053
3077
|
let currentBlockEntries = [];
|
|
3054
3078
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -3063,11 +3087,11 @@ function identifyFiveHourBlocks(entries) {
|
|
|
3063
3087
|
if (lastEntry == null) continue;
|
|
3064
3088
|
const lastEntryTime = lastEntry.timestamp;
|
|
3065
3089
|
const timeSinceLastEntry = entryTime.getTime() - lastEntryTime.getTime();
|
|
3066
|
-
if (timeSinceBlockStart >
|
|
3067
|
-
const block = createBlock(currentBlockStart, currentBlockEntries, now);
|
|
3090
|
+
if (timeSinceBlockStart > sessionDurationMs || timeSinceLastEntry > sessionDurationMs) {
|
|
3091
|
+
const block = createBlock(currentBlockStart, currentBlockEntries, now, sessionDurationMs);
|
|
3068
3092
|
blocks.push(block);
|
|
3069
|
-
if (timeSinceLastEntry >
|
|
3070
|
-
const gapBlock = createGapBlock(lastEntryTime, entryTime);
|
|
3093
|
+
if (timeSinceLastEntry > sessionDurationMs) {
|
|
3094
|
+
const gapBlock = createGapBlock(lastEntryTime, entryTime, sessionDurationMs);
|
|
3071
3095
|
if (gapBlock != null) blocks.push(gapBlock);
|
|
3072
3096
|
}
|
|
3073
3097
|
currentBlockStart = entryTime;
|
|
@@ -3076,16 +3100,24 @@ function identifyFiveHourBlocks(entries) {
|
|
|
3076
3100
|
}
|
|
3077
3101
|
}
|
|
3078
3102
|
if (currentBlockStart != null && currentBlockEntries.length > 0) {
|
|
3079
|
-
const block = createBlock(currentBlockStart, currentBlockEntries, now);
|
|
3103
|
+
const block = createBlock(currentBlockStart, currentBlockEntries, now, sessionDurationMs);
|
|
3080
3104
|
blocks.push(block);
|
|
3081
3105
|
}
|
|
3082
3106
|
return blocks;
|
|
3083
3107
|
}
|
|
3084
|
-
|
|
3085
|
-
|
|
3108
|
+
/**
|
|
3109
|
+
* Creates a session block from a start time and usage entries
|
|
3110
|
+
* @param startTime - When the block started
|
|
3111
|
+
* @param entries - Usage entries in this block
|
|
3112
|
+
* @param now - Current time for active block detection
|
|
3113
|
+
* @param sessionDurationMs - Session duration in milliseconds
|
|
3114
|
+
* @returns Session block with aggregated data
|
|
3115
|
+
*/
|
|
3116
|
+
function createBlock(startTime, entries, now, sessionDurationMs) {
|
|
3117
|
+
const endTime = new Date(startTime.getTime() + sessionDurationMs);
|
|
3086
3118
|
const lastEntry = entries[entries.length - 1];
|
|
3087
3119
|
const actualEndTime = lastEntry != null ? lastEntry.timestamp : startTime;
|
|
3088
|
-
const isActive = now.getTime() - actualEndTime.getTime() <
|
|
3120
|
+
const isActive = now.getTime() - actualEndTime.getTime() < sessionDurationMs && now < endTime;
|
|
3089
3121
|
const tokenCounts = {
|
|
3090
3122
|
inputTokens: 0,
|
|
3091
3123
|
outputTokens: 0,
|
|
@@ -3114,10 +3146,17 @@ function createBlock(startTime, entries, now) {
|
|
|
3114
3146
|
models: Array.from(modelsSet)
|
|
3115
3147
|
};
|
|
3116
3148
|
}
|
|
3117
|
-
|
|
3149
|
+
/**
|
|
3150
|
+
* Creates a gap block representing periods with no activity
|
|
3151
|
+
* @param lastActivityTime - Time of last activity before gap
|
|
3152
|
+
* @param nextActivityTime - Time of next activity after gap
|
|
3153
|
+
* @param sessionDurationMs - Session duration in milliseconds
|
|
3154
|
+
* @returns Gap block or null if gap is too short
|
|
3155
|
+
*/
|
|
3156
|
+
function createGapBlock(lastActivityTime, nextActivityTime, sessionDurationMs) {
|
|
3118
3157
|
const gapDuration = nextActivityTime.getTime() - lastActivityTime.getTime();
|
|
3119
|
-
if (gapDuration <=
|
|
3120
|
-
const gapStart = new Date(lastActivityTime.getTime() +
|
|
3158
|
+
if (gapDuration <= sessionDurationMs) return null;
|
|
3159
|
+
const gapStart = new Date(lastActivityTime.getTime() + sessionDurationMs);
|
|
3121
3160
|
const gapEnd = nextActivityTime;
|
|
3122
3161
|
return {
|
|
3123
3162
|
id: `gap-${gapStart.toISOString()}`,
|
|
@@ -3136,6 +3175,11 @@ function createGapBlock(lastActivityTime, nextActivityTime) {
|
|
|
3136
3175
|
models: []
|
|
3137
3176
|
};
|
|
3138
3177
|
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Calculates the burn rate (tokens/minute and cost/hour) for a session block
|
|
3180
|
+
* @param block - Session block to analyze
|
|
3181
|
+
* @returns Burn rate calculations or null if block has no activity
|
|
3182
|
+
*/
|
|
3139
3183
|
function calculateBurnRate(block) {
|
|
3140
3184
|
if (block.entries.length === 0 || (block.isGap ?? false)) return null;
|
|
3141
3185
|
const firstEntryData = block.entries[0];
|
|
@@ -3153,6 +3197,11 @@ function calculateBurnRate(block) {
|
|
|
3153
3197
|
costPerHour
|
|
3154
3198
|
};
|
|
3155
3199
|
}
|
|
3200
|
+
/**
|
|
3201
|
+
* Projects total usage for an active session block based on current burn rate
|
|
3202
|
+
* @param block - Active session block to project
|
|
3203
|
+
* @returns Projected usage totals or null if block is inactive or has no burn rate
|
|
3204
|
+
*/
|
|
3156
3205
|
function projectBlockUsage(block) {
|
|
3157
3206
|
if (!block.isActive || (block.isGap ?? false)) return null;
|
|
3158
3207
|
const burnRate = calculateBurnRate(block);
|
|
@@ -3171,6 +3220,12 @@ function projectBlockUsage(block) {
|
|
|
3171
3220
|
remainingMinutes: Math.round(remainingMinutes)
|
|
3172
3221
|
};
|
|
3173
3222
|
}
|
|
3223
|
+
/**
|
|
3224
|
+
* Filters session blocks to include only recent ones and active blocks
|
|
3225
|
+
* @param blocks - Array of session blocks to filter
|
|
3226
|
+
* @param days - Number of recent days to include (default: 3)
|
|
3227
|
+
* @returns Filtered array of recent or active blocks
|
|
3228
|
+
*/
|
|
3174
3229
|
function filterRecentBlocks(blocks, days = DEFAULT_RECENT_DAYS) {
|
|
3175
3230
|
const now = /* @__PURE__ */ new Date();
|
|
3176
3231
|
const cutoffTime = new Date(now.getTime() - days * 24 * 60 * 60 * 1e3);
|
|
@@ -3178,83 +3233,31 @@ function filterRecentBlocks(blocks, days = DEFAULT_RECENT_DAYS) {
|
|
|
3178
3233
|
return block.startTime >= cutoffTime || block.isActive;
|
|
3179
3234
|
});
|
|
3180
3235
|
}
|
|
3181
|
-
|
|
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
|
-
//#endregion
|
|
3243
|
-
//#region src/data-loader.ts
|
|
3244
3236
|
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
3237
|
+
/**
|
|
3238
|
+
* Default Claude data directory path (~/.claude)
|
|
3239
|
+
*/
|
|
3245
3240
|
const DEFAULT_CLAUDE_CODE_PATH = path.join(homedir(), ".claude");
|
|
3246
3241
|
/**
|
|
3247
3242
|
* Default path for Claude data directory
|
|
3248
3243
|
* Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
|
|
3249
3244
|
*/
|
|
3250
3245
|
function getDefaultClaudePath() {
|
|
3251
|
-
const envClaudeCodePath = process$1.env.CLAUDE_CONFIG_DIR
|
|
3252
|
-
if (
|
|
3246
|
+
const envClaudeCodePath = (process$1.env.CLAUDE_CONFIG_DIR ?? "").trim();
|
|
3247
|
+
if (envClaudeCodePath === "") return DEFAULT_CLAUDE_CODE_PATH;
|
|
3248
|
+
if (!isDirectorySync(envClaudeCodePath)) throw new Error(`CLAUDE_CONFIG_DIR path is not a valid directory: ${envClaudeCodePath}.
|
|
3249
|
+
Please set CLAUDE_CONFIG_DIR to a valid directory path, or ensure ${DEFAULT_CLAUDE_CODE_PATH} exists.
|
|
3250
|
+
`.trim());
|
|
3251
|
+
const claudeCodeProjectsPath = path.join(envClaudeCodePath, "projects");
|
|
3252
|
+
if (!isDirectorySync(claudeCodeProjectsPath)) throw new Error(`Claude data directory does not exist: ${claudeCodeProjectsPath}.
|
|
3253
3253
|
Please set CLAUDE_CONFIG_DIR to a valid path, or ensure ${DEFAULT_CLAUDE_CODE_PATH} exists.
|
|
3254
3254
|
`.trim());
|
|
3255
3255
|
return envClaudeCodePath;
|
|
3256
3256
|
}
|
|
3257
|
-
|
|
3257
|
+
/**
|
|
3258
|
+
* Valibot schema for validating Claude usage data from JSONL files
|
|
3259
|
+
*/
|
|
3260
|
+
const usageDataSchema = object({
|
|
3258
3261
|
timestamp: string(),
|
|
3259
3262
|
version: optional(string()),
|
|
3260
3263
|
message: object({
|
|
@@ -3270,7 +3273,10 @@ const UsageDataSchema = object({
|
|
|
3270
3273
|
costUSD: optional(number()),
|
|
3271
3274
|
requestId: optional(string())
|
|
3272
3275
|
});
|
|
3273
|
-
|
|
3276
|
+
/**
|
|
3277
|
+
* Valibot schema for model-specific usage breakdown data
|
|
3278
|
+
*/
|
|
3279
|
+
const modelBreakdownSchema = object({
|
|
3274
3280
|
modelName: string(),
|
|
3275
3281
|
inputTokens: number(),
|
|
3276
3282
|
outputTokens: number(),
|
|
@@ -3278,7 +3284,10 @@ const ModelBreakdownSchema = object({
|
|
|
3278
3284
|
cacheReadTokens: number(),
|
|
3279
3285
|
cost: number()
|
|
3280
3286
|
});
|
|
3281
|
-
|
|
3287
|
+
/**
|
|
3288
|
+
* Valibot schema for daily usage aggregation data
|
|
3289
|
+
*/
|
|
3290
|
+
const dailyUsageSchema = object({
|
|
3282
3291
|
date: pipe(string(), regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
3283
3292
|
inputTokens: number(),
|
|
3284
3293
|
outputTokens: number(),
|
|
@@ -3286,9 +3295,12 @@ const DailyUsageSchema = object({
|
|
|
3286
3295
|
cacheReadTokens: number(),
|
|
3287
3296
|
totalCost: number(),
|
|
3288
3297
|
modelsUsed: array(string()),
|
|
3289
|
-
modelBreakdowns: array(
|
|
3298
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3290
3299
|
});
|
|
3291
|
-
|
|
3300
|
+
/**
|
|
3301
|
+
* Valibot schema for session-based usage aggregation data
|
|
3302
|
+
*/
|
|
3303
|
+
const sessionUsageSchema = object({
|
|
3292
3304
|
sessionId: string(),
|
|
3293
3305
|
projectPath: string(),
|
|
3294
3306
|
inputTokens: number(),
|
|
@@ -3299,9 +3311,12 @@ const SessionUsageSchema = object({
|
|
|
3299
3311
|
lastActivity: string(),
|
|
3300
3312
|
versions: array(string()),
|
|
3301
3313
|
modelsUsed: array(string()),
|
|
3302
|
-
modelBreakdowns: array(
|
|
3314
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3303
3315
|
});
|
|
3304
|
-
|
|
3316
|
+
/**
|
|
3317
|
+
* Valibot schema for monthly usage aggregation data
|
|
3318
|
+
*/
|
|
3319
|
+
const monthlyUsageSchema = object({
|
|
3305
3320
|
month: pipe(string(), regex(/^\d{4}-\d{2}$/)),
|
|
3306
3321
|
inputTokens: number(),
|
|
3307
3322
|
outputTokens: number(),
|
|
@@ -3309,7 +3324,7 @@ const MonthlyUsageSchema = object({
|
|
|
3309
3324
|
cacheReadTokens: number(),
|
|
3310
3325
|
totalCost: number(),
|
|
3311
3326
|
modelsUsed: array(string()),
|
|
3312
|
-
modelBreakdowns: array(
|
|
3327
|
+
modelBreakdowns: array(modelBreakdownSchema)
|
|
3313
3328
|
});
|
|
3314
3329
|
/**
|
|
3315
3330
|
* Aggregates token counts and costs by model name
|
|
@@ -3371,7 +3386,7 @@ function createModelBreakdowns(modelAggregates) {
|
|
|
3371
3386
|
return Array.from(modelAggregates.entries()).map(([modelName, stats]) => ({
|
|
3372
3387
|
modelName,
|
|
3373
3388
|
...stats
|
|
3374
|
-
})).sort((a, b) => b.cost - a.cost);
|
|
3389
|
+
})).sort((a$1, b$1) => b$1.cost - a$1.cost);
|
|
3375
3390
|
}
|
|
3376
3391
|
/**
|
|
3377
3392
|
* Calculates total token counts and costs from entries
|
|
@@ -3426,8 +3441,13 @@ function markAsProcessed(uniqueHash, processedHashes) {
|
|
|
3426
3441
|
* Extracts unique models from entries, excluding synthetic model
|
|
3427
3442
|
*/
|
|
3428
3443
|
function extractUniqueModels(entries, getModel) {
|
|
3429
|
-
return [...new Set(entries.map(getModel).filter((m) => m != null && m !== "<synthetic>"))];
|
|
3444
|
+
return [...new Set(entries.map(getModel).filter((m$1) => m$1 != null && m$1 !== "<synthetic>"))];
|
|
3430
3445
|
}
|
|
3446
|
+
/**
|
|
3447
|
+
* Formats a date string to YYYY-MM-DD format
|
|
3448
|
+
* @param dateStr - Input date string
|
|
3449
|
+
* @returns Formatted date string in YYYY-MM-DD format
|
|
3450
|
+
*/
|
|
3431
3451
|
function formatDate(dateStr) {
|
|
3432
3452
|
const date = new Date(dateStr);
|
|
3433
3453
|
const year = date.getFullYear();
|
|
@@ -3435,6 +3455,11 @@ function formatDate(dateStr) {
|
|
|
3435
3455
|
const day = String(date.getDate()).padStart(2, "0");
|
|
3436
3456
|
return `${year}-${month}-${day}`;
|
|
3437
3457
|
}
|
|
3458
|
+
/**
|
|
3459
|
+
* Formats a date string to compact format with year on first line and month-day on second
|
|
3460
|
+
* @param dateStr - Input date string
|
|
3461
|
+
* @returns Formatted date string with newline separator (YYYY\nMM-DD)
|
|
3462
|
+
*/
|
|
3438
3463
|
function formatDateCompact(dateStr) {
|
|
3439
3464
|
const date = new Date(dateStr);
|
|
3440
3465
|
const year = date.getFullYear();
|
|
@@ -3504,13 +3529,20 @@ async function sortFilesByTimestamp(files) {
|
|
|
3504
3529
|
file,
|
|
3505
3530
|
timestamp: await getEarliestTimestamp(file)
|
|
3506
3531
|
})));
|
|
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();
|
|
3532
|
+
return filesWithTimestamps.sort((a$1, b$1) => {
|
|
3533
|
+
if (a$1.timestamp == null && b$1.timestamp == null) return 0;
|
|
3534
|
+
if (a$1.timestamp == null) return 1;
|
|
3535
|
+
if (b$1.timestamp == null) return -1;
|
|
3536
|
+
return a$1.timestamp.getTime() - b$1.timestamp.getTime();
|
|
3512
3537
|
}).map((item) => item.file);
|
|
3513
3538
|
}
|
|
3539
|
+
/**
|
|
3540
|
+
* Calculates cost for a single usage data entry based on the specified cost calculation mode
|
|
3541
|
+
* @param data - Usage data entry
|
|
3542
|
+
* @param mode - Cost calculation mode (auto, calculate, or display)
|
|
3543
|
+
* @param fetcher - Pricing fetcher instance for calculating costs from tokens
|
|
3544
|
+
* @returns Calculated cost in USD
|
|
3545
|
+
*/
|
|
3514
3546
|
async function calculateCostForEntry(data, mode, fetcher) {
|
|
3515
3547
|
if (mode === "display") return data.costUSD ?? 0;
|
|
3516
3548
|
if (mode === "calculate") {
|
|
@@ -3524,9 +3556,15 @@ async function calculateCostForEntry(data, mode, fetcher) {
|
|
|
3524
3556
|
}
|
|
3525
3557
|
unreachable(mode);
|
|
3526
3558
|
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Loads and aggregates Claude usage data by day
|
|
3561
|
+
* Processes all JSONL files in the Claude projects directory and groups usage by date
|
|
3562
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3563
|
+
* @returns Array of daily usage summaries sorted by date
|
|
3564
|
+
*/
|
|
3527
3565
|
async function loadDailyUsageData(options) {
|
|
3528
3566
|
try {
|
|
3529
|
-
var _usingCtx
|
|
3567
|
+
var _usingCtx = (0, import_usingCtx.default)();
|
|
3530
3568
|
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
3531
3569
|
const claudeDir = path.join(claudePath, "projects");
|
|
3532
3570
|
const files = await glob(["**/*.jsonl"], {
|
|
@@ -3536,7 +3574,7 @@ async function loadDailyUsageData(options) {
|
|
|
3536
3574
|
if (files.length === 0) return [];
|
|
3537
3575
|
const sortedFiles = await sortFilesByTimestamp(files);
|
|
3538
3576
|
const mode = options?.mode ?? "auto";
|
|
3539
|
-
const fetcher = _usingCtx
|
|
3577
|
+
const fetcher = _usingCtx.u(mode === "display" ? null : new PricingFetcher(options?.offline));
|
|
3540
3578
|
const processedHashes = /* @__PURE__ */ new Set();
|
|
3541
3579
|
const allEntries = [];
|
|
3542
3580
|
for (const file of sortedFiles) {
|
|
@@ -3544,7 +3582,7 @@ async function loadDailyUsageData(options) {
|
|
|
3544
3582
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3545
3583
|
for (const line of lines) try {
|
|
3546
3584
|
const parsed = JSON.parse(line);
|
|
3547
|
-
const result = safeParse(
|
|
3585
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3548
3586
|
if (!result.success) continue;
|
|
3549
3587
|
const data = result.output;
|
|
3550
3588
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3577,11 +3615,17 @@ async function loadDailyUsageData(options) {
|
|
|
3577
3615
|
const filtered = filterByDateRange(results, (item) => item.date, options?.since, options?.until);
|
|
3578
3616
|
return sortByDate(filtered, (item) => item.date, options?.order);
|
|
3579
3617
|
} catch (_) {
|
|
3580
|
-
_usingCtx
|
|
3618
|
+
_usingCtx.e = _;
|
|
3581
3619
|
} finally {
|
|
3582
|
-
_usingCtx
|
|
3620
|
+
_usingCtx.d();
|
|
3583
3621
|
}
|
|
3584
3622
|
}
|
|
3623
|
+
/**
|
|
3624
|
+
* Loads and aggregates Claude usage data by session
|
|
3625
|
+
* Groups usage data by project path and session ID based on file structure
|
|
3626
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3627
|
+
* @returns Array of session usage summaries sorted by last activity
|
|
3628
|
+
*/
|
|
3585
3629
|
async function loadSessionData(options) {
|
|
3586
3630
|
try {
|
|
3587
3631
|
var _usingCtx3 = (0, import_usingCtx.default)();
|
|
@@ -3607,7 +3651,7 @@ async function loadSessionData(options) {
|
|
|
3607
3651
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3608
3652
|
for (const line of lines) try {
|
|
3609
3653
|
const parsed = JSON.parse(line);
|
|
3610
|
-
const result = safeParse(
|
|
3654
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3611
3655
|
if (!result.success) continue;
|
|
3612
3656
|
const data = result.output;
|
|
3613
3657
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3654,6 +3698,12 @@ async function loadSessionData(options) {
|
|
|
3654
3698
|
_usingCtx3.d();
|
|
3655
3699
|
}
|
|
3656
3700
|
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Loads and aggregates Claude usage data by month
|
|
3703
|
+
* Uses daily usage data as the source and groups by month
|
|
3704
|
+
* @param options - Optional configuration for loading and filtering data
|
|
3705
|
+
* @returns Array of monthly usage summaries sorted by month
|
|
3706
|
+
*/
|
|
3657
3707
|
async function loadMonthlyUsageData(options) {
|
|
3658
3708
|
const dailyData = await loadDailyUsageData(options);
|
|
3659
3709
|
const groupedByMonth = groupBy(dailyData, (data) => data.date.substring(0, 7));
|
|
@@ -3691,7 +3741,13 @@ async function loadMonthlyUsageData(options) {
|
|
|
3691
3741
|
}
|
|
3692
3742
|
return sortByDate(monthlyArray, (item) => `${item.month}-01`, options?.order);
|
|
3693
3743
|
}
|
|
3694
|
-
|
|
3744
|
+
/**
|
|
3745
|
+
* Loads usage data and organizes it into session blocks (typically 5-hour billing periods)
|
|
3746
|
+
* Processes all usage data and groups it into time-based blocks for billing analysis
|
|
3747
|
+
* @param options - Optional configuration including session duration and filtering
|
|
3748
|
+
* @returns Array of session blocks with usage and cost information
|
|
3749
|
+
*/
|
|
3750
|
+
async function loadSessionBlockData(options) {
|
|
3695
3751
|
try {
|
|
3696
3752
|
var _usingCtx4 = (0, import_usingCtx.default)();
|
|
3697
3753
|
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
@@ -3711,7 +3767,7 @@ async function loadFiveHourBlockData(options) {
|
|
|
3711
3767
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3712
3768
|
for (const line of lines) try {
|
|
3713
3769
|
const parsed = JSON.parse(line);
|
|
3714
|
-
const result = safeParse(
|
|
3770
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
3715
3771
|
if (!result.success) continue;
|
|
3716
3772
|
const data = result.output;
|
|
3717
3773
|
const uniqueHash = createUniqueHash(data);
|
|
@@ -3734,7 +3790,7 @@ async function loadFiveHourBlockData(options) {
|
|
|
3734
3790
|
logger.debug(`Skipping invalid JSON line in 5-hour blocks: ${error instanceof Error ? error.message : String(error)}`);
|
|
3735
3791
|
}
|
|
3736
3792
|
}
|
|
3737
|
-
const blocks =
|
|
3793
|
+
const blocks = identifySessionBlocks(allEntries, options?.sessionDurationHours);
|
|
3738
3794
|
const filtered = options?.since != null && options.since !== "" || options?.until != null && options.until !== "" ? blocks.filter((block) => {
|
|
3739
3795
|
const blockDateStr = formatDate(block.startTime.toISOString()).replace(/-/g, "");
|
|
3740
3796
|
if (options.since != null && options.since !== "" && blockDateStr < options.since) return false;
|
|
@@ -3748,6 +3804,4 @@ async function loadFiveHourBlockData(options) {
|
|
|
3748
3804
|
_usingCtx4.d();
|
|
3749
3805
|
}
|
|
3750
3806
|
}
|
|
3751
|
-
|
|
3752
|
-
//#endregion
|
|
3753
|
-
export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateBurnRate, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, glob, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, projectBlockUsage, require_usingCtx, sortFilesByTimestamp };
|
|
3807
|
+
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 };
|