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.
Files changed (44) hide show
  1. package/README.md +23 -1
  2. package/dist/arktype-C-GObzDh-Bx7Fdrqj.js +2 -0
  3. package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +16 -4
  4. package/dist/calculate-cost.d.ts +26 -2
  5. package/dist/calculate-cost.js +2 -3
  6. package/dist/core-eFvU0K4V.js +689 -0
  7. package/dist/{data-loader-BAoqS297.js → data-loader-B2EwZ_7B.js} +446 -392
  8. package/dist/{data-loader-DPQaq8_n.d.ts → data-loader-dbZm5kOW.d.ts} +116 -25
  9. package/dist/data-loader.d.ts +3 -3
  10. package/dist/data-loader.js +4 -5
  11. package/dist/{debug-DzFJHzM5.js → debug-D4Ka6IrY.js} +21 -12
  12. package/dist/debug.d.ts +17 -0
  13. package/dist/debug.js +5 -6
  14. package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +1 -5
  15. package/dist/dist-DCvt9hEv.js +1 -4
  16. package/dist/effect-WSjEuzC9-CZCpOgOT.js +6 -0
  17. package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +2 -111
  18. package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +6 -9
  19. package/dist/index.js +1912 -105
  20. package/dist/{logger-D3WD64Tx.js → logger-DPEwxrOW.js} +9 -22
  21. package/dist/logger.d.ts +9 -4
  22. package/dist/logger.js +2 -3
  23. package/dist/{mcp-1J7r1g6-.js → mcp-CklIto13.js} +366 -947
  24. package/dist/mcp.d.ts +2 -2
  25. package/dist/mcp.js +7 -8
  26. package/dist/{pricing-fetcher-D-eJQBEJ.js → pricing-fetcher-DDs53oR8.js} +151 -14
  27. package/dist/{pricing-fetcher-BkSZh4lR.d.ts → pricing-fetcher-DHaTs-k2.d.ts} +67 -2
  28. package/dist/pricing-fetcher.d.ts +1 -1
  29. package/dist/pricing-fetcher.js +3 -4
  30. package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +1 -5
  31. package/dist/sury-DmrZ3_Oj-Lq7x0IZW.js +6 -0
  32. package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +1 -22
  33. package/dist/valibot-CQk-M5rL-btpzU8Qa.js +6 -0
  34. package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +4 -8
  35. package/package.json +1 -2
  36. package/dist/arktype-C-GObzDh-CNoBqQrr.js +0 -5
  37. package/dist/chunk-BLXvPPr8.js +0 -30
  38. package/dist/core-DHCbAXJf.js +0 -693
  39. package/dist/effect-WSjEuzC9-DHMVzzyB.js +0 -10
  40. package/dist/sury-DmrZ3_Oj-Cpjsc2Lm.js +0 -10
  41. package/dist/utils.table-USks3NGv.js +0 -1844
  42. package/dist/utils.table.d.ts +0 -27
  43. package/dist/utils.table.js +0 -3
  44. package/dist/valibot-CQk-M5rL-BcaCeUrF.js +0 -10
@@ -1,6 +1,10 @@
1
- import { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema } from "./pricing-fetcher-BkSZh4lR.js";
1
+ import { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema } from "./pricing-fetcher-DHaTs-k2.js";
2
2
 
3
- //#region src/five-hour-blocks.internal.d.ts
3
+ //#region src/session-blocks.internal.d.ts
4
+
5
+ /**
6
+ * Represents a single usage data entry loaded from JSONL files
7
+ */
4
8
  type LoadedUsageEntry = {
5
9
  timestamp: Date;
6
10
  usage: {
@@ -13,24 +17,33 @@ type LoadedUsageEntry = {
13
17
  model: string;
14
18
  version?: string;
15
19
  };
20
+ /**
21
+ * Aggregated token counts for different token types
22
+ */
16
23
  type TokenCounts = {
17
24
  inputTokens: number;
18
25
  outputTokens: number;
19
26
  cacheCreationInputTokens: number;
20
27
  cacheReadInputTokens: number;
21
28
  };
22
- type FiveHourBlock = {
23
- id: string;
29
+ /**
30
+ * Represents a session block (typically 5-hour billing period) with usage data
31
+ */
32
+ type SessionBlock = {
33
+ id: string; // ISO string of block start time
24
34
  startTime: Date;
25
- endTime: Date;
26
- actualEndTime?: Date;
35
+ endTime: Date; // startTime + 5 hours (for normal blocks) or gap end time (for gap blocks)
36
+ actualEndTime?: Date; // Last activity in block
27
37
  isActive: boolean;
28
- isGap?: boolean;
38
+ isGap?: boolean; // True if this is a gap block
29
39
  entries: LoadedUsageEntry[];
30
40
  tokenCounts: TokenCounts;
31
41
  costUSD: number;
32
42
  models: string[];
33
43
  };
44
+ /**
45
+ * Represents usage burn rate calculations
46
+ */
34
47
  //#endregion
35
48
  //#region src/data-loader.d.ts
36
49
  /**
@@ -38,7 +51,10 @@ type FiveHourBlock = {
38
51
  * Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
39
52
  */
40
53
  declare function getDefaultClaudePath(): string;
41
- declare const UsageDataSchema: ObjectSchema<{
54
+ /**
55
+ * Valibot schema for validating Claude usage data from JSONL files
56
+ */
57
+ declare const usageDataSchema: ObjectSchema<{
42
58
  readonly timestamp: StringSchema<undefined>;
43
59
  readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
44
60
  readonly message: ObjectSchema<{
@@ -54,8 +70,14 @@ declare const UsageDataSchema: ObjectSchema<{
54
70
  readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
55
71
  readonly requestId: OptionalSchema<StringSchema<undefined>, undefined>;
56
72
  }, undefined>;
57
- type UsageData = InferOutput<typeof UsageDataSchema>;
58
- declare const ModelBreakdownSchema: ObjectSchema<{
73
+ /**
74
+ * Type definition for Claude usage data entries from JSONL files
75
+ */
76
+ type UsageData = InferOutput<typeof usageDataSchema>;
77
+ /**
78
+ * Valibot schema for model-specific usage breakdown data
79
+ */
80
+ declare const modelBreakdownSchema: ObjectSchema<{
59
81
  readonly modelName: StringSchema<undefined>;
60
82
  readonly inputTokens: NumberSchema<undefined>;
61
83
  readonly outputTokens: NumberSchema<undefined>;
@@ -63,8 +85,14 @@ declare const ModelBreakdownSchema: ObjectSchema<{
63
85
  readonly cacheReadTokens: NumberSchema<undefined>;
64
86
  readonly cost: NumberSchema<undefined>;
65
87
  }, undefined>;
66
- type ModelBreakdown = InferOutput<typeof ModelBreakdownSchema>;
67
- declare const DailyUsageSchema: ObjectSchema<{
88
+ /**
89
+ * Type definition for model-specific usage breakdown
90
+ */
91
+ type ModelBreakdown = InferOutput<typeof modelBreakdownSchema>;
92
+ /**
93
+ * Valibot schema for daily usage aggregation data
94
+ */
95
+ declare const dailyUsageSchema: ObjectSchema<{
68
96
  readonly date: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
69
97
  readonly inputTokens: NumberSchema<undefined>;
70
98
  readonly outputTokens: NumberSchema<undefined>;
@@ -81,8 +109,14 @@ declare const DailyUsageSchema: ObjectSchema<{
81
109
  readonly cost: NumberSchema<undefined>;
82
110
  }, undefined>, undefined>;
83
111
  }, undefined>;
84
- type DailyUsage = InferOutput<typeof DailyUsageSchema>;
85
- declare const SessionUsageSchema: ObjectSchema<{
112
+ /**
113
+ * Type definition for daily usage aggregation
114
+ */
115
+ type DailyUsage = InferOutput<typeof dailyUsageSchema>;
116
+ /**
117
+ * Valibot schema for session-based usage aggregation data
118
+ */
119
+ declare const sessionUsageSchema: ObjectSchema<{
86
120
  readonly sessionId: StringSchema<undefined>;
87
121
  readonly projectPath: StringSchema<undefined>;
88
122
  readonly inputTokens: NumberSchema<undefined>;
@@ -102,8 +136,14 @@ declare const SessionUsageSchema: ObjectSchema<{
102
136
  readonly cost: NumberSchema<undefined>;
103
137
  }, undefined>, undefined>;
104
138
  }, undefined>;
105
- type SessionUsage = InferOutput<typeof SessionUsageSchema>;
106
- declare const MonthlyUsageSchema: ObjectSchema<{
139
+ /**
140
+ * Type definition for session-based usage aggregation
141
+ */
142
+ type SessionUsage = InferOutput<typeof sessionUsageSchema>;
143
+ /**
144
+ * Valibot schema for monthly usage aggregation data
145
+ */
146
+ declare const monthlyUsageSchema: ObjectSchema<{
107
147
  readonly month: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
108
148
  readonly inputTokens: NumberSchema<undefined>;
109
149
  readonly outputTokens: NumberSchema<undefined>;
@@ -120,8 +160,21 @@ declare const MonthlyUsageSchema: ObjectSchema<{
120
160
  readonly cost: NumberSchema<undefined>;
121
161
  }, undefined>, undefined>;
122
162
  }, undefined>;
123
- type MonthlyUsage = InferOutput<typeof MonthlyUsageSchema>;
163
+ /**
164
+ * Type definition for monthly usage aggregation
165
+ */
166
+ type MonthlyUsage = InferOutput<typeof monthlyUsageSchema>;
167
+ /**
168
+ * Formats a date string to YYYY-MM-DD format
169
+ * @param dateStr - Input date string
170
+ * @returns Formatted date string in YYYY-MM-DD format
171
+ */
124
172
  declare function formatDate(dateStr: string): string;
173
+ /**
174
+ * Formats a date string to compact format with year on first line and month-day on second
175
+ * @param dateStr - Input date string
176
+ * @returns Formatted date string with newline separator (YYYY\nMM-DD)
177
+ */
125
178
  declare function formatDateCompact(dateStr: string): string;
126
179
  /**
127
180
  * Create a unique identifier for deduplication using message ID and request ID
@@ -137,20 +190,58 @@ declare function getEarliestTimestamp(filePath: string): Promise<Date | null>;
137
190
  * Files without valid timestamps are placed at the end
138
191
  */
139
192
  declare function sortFilesByTimestamp(files: string[]): Promise<string[]>;
193
+ /**
194
+ * Calculates cost for a single usage data entry based on the specified cost calculation mode
195
+ * @param data - Usage data entry
196
+ * @param mode - Cost calculation mode (auto, calculate, or display)
197
+ * @param fetcher - Pricing fetcher instance for calculating costs from tokens
198
+ * @returns Calculated cost in USD
199
+ */
140
200
  declare function calculateCostForEntry(data: UsageData, mode: CostMode, fetcher: PricingFetcher): Promise<number>;
201
+ /**
202
+ * Date range filter for limiting usage data by date
203
+ */
141
204
  type DateFilter = {
142
- since?: string;
143
- until?: string;
205
+ since?: string; // YYYYMMDD format
206
+ until?: string; // YYYYMMDD format
144
207
  };
208
+ /**
209
+ * Configuration options for loading usage data
210
+ */
145
211
  type LoadOptions = {
146
- claudePath?: string;
147
- mode?: CostMode;
148
- order?: SortOrder;
149
- offline?: boolean;
212
+ claudePath?: string; // Custom path to Claude data directory
213
+ mode?: CostMode; // Cost calculation mode
214
+ order?: SortOrder; // Sort order for dates
215
+ offline?: boolean; // Use offline mode for pricing
216
+ sessionDurationHours?: number; // Session block duration in hours
150
217
  } & DateFilter;
218
+ /**
219
+ * Loads and aggregates Claude usage data by day
220
+ * Processes all JSONL files in the Claude projects directory and groups usage by date
221
+ * @param options - Optional configuration for loading and filtering data
222
+ * @returns Array of daily usage summaries sorted by date
223
+ */
151
224
  declare function loadDailyUsageData(options?: LoadOptions): Promise<DailyUsage[]>;
225
+ /**
226
+ * Loads and aggregates Claude usage data by session
227
+ * Groups usage data by project path and session ID based on file structure
228
+ * @param options - Optional configuration for loading and filtering data
229
+ * @returns Array of session usage summaries sorted by last activity
230
+ */
152
231
  declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
232
+ /**
233
+ * Loads and aggregates Claude usage data by month
234
+ * Uses daily usage data as the source and groups by month
235
+ * @param options - Optional configuration for loading and filtering data
236
+ * @returns Array of monthly usage summaries sorted by month
237
+ */
153
238
  declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsage[]>;
154
- declare function loadFiveHourBlockData(options?: LoadOptions): Promise<FiveHourBlock[]>;
239
+ /**
240
+ * Loads usage data and organizes it into session blocks (typically 5-hour billing periods)
241
+ * Processes all usage data and groups it into time-based blocks for billing analysis
242
+ * @param options - Optional configuration including session duration and filtering
243
+ * @returns Array of session blocks with usage and cost information
244
+ */
245
+ declare function loadSessionBlockData(options?: LoadOptions): Promise<SessionBlock[]>;
155
246
  //#endregion
156
- export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
247
+ export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
@@ -1,3 +1,3 @@
1
- import "./pricing-fetcher-BkSZh4lR.js";
2
- import { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp } from "./data-loader-DPQaq8_n.js";
3
- export { DailyUsage, DailyUsageSchema, DateFilter, LoadOptions, ModelBreakdown, ModelBreakdownSchema, MonthlyUsage, MonthlyUsageSchema, SessionUsage, SessionUsageSchema, UsageData, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
1
+ import "./pricing-fetcher-DHaTs-k2.js";
2
+ import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-dbZm5kOW.js";
3
+ export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
@@ -1,6 +1,5 @@
1
- import { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp } from "./data-loader-BAoqS297.js";
1
+ import "./pricing-fetcher-DDs53oR8.js";
2
+ import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-B2EwZ_7B.js";
2
3
  import "./dist-DCvt9hEv.js";
3
- import "./logger-D3WD64Tx.js";
4
- import "./pricing-fetcher-D-eJQBEJ.js";
5
-
6
- export { DailyUsageSchema, ModelBreakdownSchema, MonthlyUsageSchema, SessionUsageSchema, UsageDataSchema, calculateCostForEntry, createUniqueHash, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadFiveHourBlockData, loadMonthlyUsageData, loadSessionData, sortFilesByTimestamp };
4
+ import "./logger-DPEwxrOW.js";
5
+ export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
@@ -1,15 +1,21 @@
1
- import { __toESM } from "./chunk-BLXvPPr8.js";
2
- import { UsageDataSchema, glob, require_usingCtx } from "./data-loader-BAoqS297.js";
1
+ import { PricingFetcher, __toESM, require_usingCtx } from "./pricing-fetcher-DDs53oR8.js";
2
+ import { glob, usageDataSchema } from "./data-loader-B2EwZ_7B.js";
3
3
  import { safeParse } from "./dist-DCvt9hEv.js";
4
- import { logger } from "./logger-D3WD64Tx.js";
5
- import { PricingFetcher } from "./pricing-fetcher-D-eJQBEJ.js";
4
+ import { logger } from "./logger-DPEwxrOW.js";
6
5
  import { readFile } from "node:fs/promises";
7
6
  import { homedir } from "node:os";
8
7
  import path from "node:path";
9
-
10
- //#region src/debug.ts
11
8
  var import_usingCtx = __toESM(require_usingCtx(), 1);
9
+ /**
10
+ * Threshold percentage for considering costs as matching (0.1% tolerance)
11
+ */
12
12
  const MATCH_THRESHOLD_PERCENT = .1;
13
+ /**
14
+ * Analyzes usage data to detect pricing mismatches between stored and calculated costs
15
+ * Compares pre-calculated costUSD values with costs calculated from token usage
16
+ * @param claudePath - Optional path to Claude data directory
17
+ * @returns Statistics about pricing mismatches found
18
+ */
13
19
  async function detectMismatches(claudePath) {
14
20
  try {
15
21
  var _usingCtx = (0, import_usingCtx.default)();
@@ -33,7 +39,7 @@ async function detectMismatches(claudePath) {
33
39
  const lines = content.trim().split("\n").filter((line) => line.length > 0);
34
40
  for (const line of lines) try {
35
41
  const parsed = JSON.parse(line);
36
- const result = safeParse(UsageDataSchema, parsed);
42
+ const result = safeParse(usageDataSchema, parsed);
37
43
  if (!result.success) continue;
38
44
  const data = result.output;
39
45
  stats.totalEntries++;
@@ -92,6 +98,11 @@ async function detectMismatches(claudePath) {
92
98
  _usingCtx.d();
93
99
  }
94
100
  }
101
+ /**
102
+ * Prints a detailed report of pricing mismatches to the console
103
+ * @param stats - Mismatch statistics to report
104
+ * @param sampleCount - Number of sample discrepancies to show (default: 5)
105
+ */
95
106
  function printMismatchReport(stats, sampleCount = 5) {
96
107
  if (stats.entriesWithBoth === 0) {
97
108
  logger.info("No pricing data found to analyze.");
@@ -106,7 +117,7 @@ function printMismatchReport(stats, sampleCount = 5) {
106
117
  logger.info(`Match rate: ${matchRate.toFixed(2)}%`);
107
118
  if (stats.mismatches > 0 && stats.modelStats.size > 0) {
108
119
  logger.info("\n=== Model Statistics ===");
109
- const sortedModels = Array.from(stats.modelStats.entries()).sort((a, b) => b[1].mismatches - a[1].mismatches);
120
+ const sortedModels = Array.from(stats.modelStats.entries()).sort((a$1, b) => b[1].mismatches - a$1[1].mismatches);
110
121
  for (const [model, modelStat] of sortedModels) if (modelStat.mismatches > 0) {
111
122
  const modelMatchRate = modelStat.matches / modelStat.total * 100;
112
123
  logger.info(`${model}:`);
@@ -118,7 +129,7 @@ function printMismatchReport(stats, sampleCount = 5) {
118
129
  }
119
130
  if (stats.mismatches > 0 && stats.versionStats.size > 0) {
120
131
  logger.info("\n=== Version Statistics ===");
121
- const sortedVersions = Array.from(stats.versionStats.entries()).filter(([_, versionStat]) => versionStat.mismatches > 0).sort((a, b) => b[1].mismatches - a[1].mismatches);
132
+ const sortedVersions = Array.from(stats.versionStats.entries()).filter(([_, versionStat]) => versionStat.mismatches > 0).sort((a$1, b) => b[1].mismatches - a$1[1].mismatches);
122
133
  for (const [version, versionStat] of sortedVersions) {
123
134
  const versionMatchRate = versionStat.matches / versionStat.total * 100;
124
135
  logger.info(`${version}:`);
@@ -143,6 +154,4 @@ function printMismatchReport(stats, sampleCount = 5) {
143
154
  }
144
155
  }
145
156
  }
146
-
147
- //#endregion
148
- export { detectMismatches, printMismatchReport };
157
+ export { detectMismatches, printMismatchReport };
package/dist/debug.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  //#region src/debug.d.ts
2
+ /**
3
+ * Represents a pricing discrepancy between original and calculated costs
4
+ */
2
5
  type Discrepancy = {
3
6
  file: string;
4
7
  timestamp: string;
@@ -14,6 +17,9 @@ type Discrepancy = {
14
17
  cache_read_input_tokens?: number;
15
18
  };
16
19
  };
20
+ /**
21
+ * Statistics about pricing mismatches across all usage data
22
+ */
17
23
  type MismatchStats = {
18
24
  totalEntries: number;
19
25
  entriesWithBoth: number;
@@ -33,7 +39,18 @@ type MismatchStats = {
33
39
  avgPercentDiff: number;
34
40
  }>;
35
41
  };
42
+ /**
43
+ * Analyzes usage data to detect pricing mismatches between stored and calculated costs
44
+ * Compares pre-calculated costUSD values with costs calculated from token usage
45
+ * @param claudePath - Optional path to Claude data directory
46
+ * @returns Statistics about pricing mismatches found
47
+ */
36
48
  declare function detectMismatches(claudePath?: string): Promise<MismatchStats>;
49
+ /**
50
+ * Prints a detailed report of pricing mismatches to the console
51
+ * @param stats - Mismatch statistics to report
52
+ * @param sampleCount - Number of sample discrepancies to show (default: 5)
53
+ */
37
54
  declare function printMismatchReport(stats: MismatchStats, sampleCount?: number): void;
38
55
  //#endregion
39
56
  export { detectMismatches, printMismatchReport };
package/dist/debug.js CHANGED
@@ -1,7 +1,6 @@
1
- import "./data-loader-BAoqS297.js";
1
+ import "./pricing-fetcher-DDs53oR8.js";
2
+ import "./data-loader-B2EwZ_7B.js";
2
3
  import "./dist-DCvt9hEv.js";
3
- import "./logger-D3WD64Tx.js";
4
- import "./pricing-fetcher-D-eJQBEJ.js";
5
- import { detectMismatches, printMismatchReport } from "./debug-DzFJHzM5.js";
6
-
7
- export { detectMismatches, printMismatchReport };
4
+ import "./logger-DPEwxrOW.js";
5
+ import { detectMismatches, printMismatchReport } from "./debug-D4Ka6IrY.js";
6
+ export { detectMismatches, printMismatchReport };
@@ -1,6 +1,4 @@
1
1
  import { getDefault } from "./dist-DCvt9hEv.js";
2
-
3
- //#region node_modules/@valibot/to-json-schema/dist/index.js
4
2
  /**
5
3
  * Adds an error message to the errors array.
6
4
  *
@@ -464,6 +462,4 @@ function toJsonSchemaDefs(definitions, config) {
464
462
  for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
465
463
  return context.definitions;
466
464
  }
467
-
468
- //#endregion
469
- export { addGlobalDefs, getGlobalDefs, toJsonSchema, toJsonSchemaDefs };
465
+ export { addGlobalDefs, getGlobalDefs, toJsonSchema, toJsonSchemaDefs };
@@ -1,4 +1,3 @@
1
- //#region node_modules/valibot/dist/index.js
2
1
  var store;
3
2
  /* @__NO_SIDE_EFFECTS__ */
4
3
  function getGlobalConfig(config2) {
@@ -378,6 +377,4 @@ function safeParse(schema, input, config2) {
378
377
  issues: dataset.issues
379
378
  };
380
379
  }
381
-
382
- //#endregion
383
- export { array, description, getDefault, literal, number, object, optional, pipe, regex, safeParse, string, union };
380
+ export { array, description, getDefault, literal, number, object, optional, pipe, regex, safeParse, string, union };
@@ -0,0 +1,6 @@
1
+ import { tryImport } from "./index-CISmcbXk-DpuCarFe.js";
2
+ const getToJsonSchemaFn = async () => {
3
+ const { JSONSchema } = await tryImport(import("effect"), "effect");
4
+ return (schema) => JSONSchema.make(schema);
5
+ };
6
+ export { getToJsonSchemaFn };