ccusage 15.9.2 → 15.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import "./pricing-fetcher-C9P2YKDv.js";
2
- import { LoadOptions } from "./data-loader-PvTcFbip.js";
1
+ import "./pricing-fetcher-B5m_kEpz.js";
2
+ import { LoadOptions } from "./data-loader-B2FL7oh0.js";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { Hono } from "hono/tiny";
5
5
 
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
- import "./pricing-fetcher-DXFi0Cxk.js";
1
+ import "./pricing-fetcher-DzkXdtDF.js";
2
2
  import "./_token-utils-WjkbrjKv.js";
3
- import "./_types-B-1t4mxD.js";
3
+ import "./_types-C0oFKDO-.js";
4
4
  import "./calculate-cost-BDqO4yWA.js";
5
- import "./data-loader-KL1zbb-w.js";
6
- import "./logger-BrRa0CCy.js";
7
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-BBhsgnNL.js";
5
+ import "./data-loader-CY2f8ZBq.js";
6
+ import "./logger-QcakA1fc.js";
7
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-COJ_l32e.js";
8
8
  export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
@@ -200,4 +200,4 @@ declare class PricingFetcher implements Disposable {
200
200
  }, pricing: ModelPricing): number;
201
201
  }
202
202
  //#endregion
203
- export { Bucket, CostMode, PricingFetcher as PricingFetcher$1, SortOrder, type TupleToUnion };
203
+ export { Bucket, CostMode, PricingFetcher, SortOrder, type TupleToUnion };
@@ -0,0 +1,342 @@
1
+ import { modelPricingSchema } from "./_types-C0oFKDO-.js";
2
+ import { logger } from "./logger-QcakA1fc.js";
3
+ import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+ import F, { homedir } from "node:os";
6
+ var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports), __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) if (key = keys[i], !__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
9
+ get: ((k) => from[k]).bind(null, key),
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ }
13
+ return to;
14
+ }, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
15
+ value: mod,
16
+ enumerable: true
17
+ }) : target, mod)), __require = /* @__PURE__ */ createRequire(import.meta.url);
18
+ const isFailure = (result) => "Failure" === result.type, isPromise = (value) => "object" == typeof value && null !== value && "then" in value && "function" == typeof value.then && "catch" in value && "function" == typeof value.catch, andThen = (fn) => (result) => {
19
+ const apply = (r) => {
20
+ return isFailure(r) ? r : fn(r.value);
21
+ };
22
+ return isPromise(result) ? result.then(apply) : apply(result);
23
+ }, andThrough = (fn) => (result) => {
24
+ const apply = (r) => {
25
+ if (isFailure(r)) return r;
26
+ const next = fn(r.value);
27
+ return isPromise(next) ? next.then((n) => {
28
+ return isFailure(n) ? n : r;
29
+ }) : isFailure(next) ? next : r;
30
+ };
31
+ return isPromise(result) ? result.then(apply) : apply(result);
32
+ }, isSuccess = (result) => "Success" === result.type, succeed = (...args) => {
33
+ const value = args[0];
34
+ return void 0 === value ? { type: "Success" } : isPromise(value) ? value.then((value$1) => ({
35
+ type: "Success",
36
+ value: value$1
37
+ })) : {
38
+ type: "Success",
39
+ value
40
+ };
41
+ }, fail = (...args) => {
42
+ const error = args[0];
43
+ return void 0 === error ? { type: "Failure" } : isPromise(error) ? error.then((error$1) => ({
44
+ type: "Failure",
45
+ error: error$1
46
+ })) : {
47
+ type: "Failure",
48
+ error
49
+ };
50
+ }, inspect = (fn) => (result) => {
51
+ const apply = (r) => {
52
+ if (isSuccess(r)) fn(r.value);
53
+ return r;
54
+ };
55
+ return isPromise(result) ? result.then(apply) : apply(result);
56
+ }, inspectError = (fn) => (result) => {
57
+ const apply = (r) => {
58
+ if (isFailure(r)) fn(r.error);
59
+ return r;
60
+ };
61
+ return isPromise(result) ? result.then(apply) : apply(result);
62
+ }, map = (fn) => (result) => {
63
+ const apply = (r) => {
64
+ return isFailure(r) ? r : succeed(fn(r.value));
65
+ };
66
+ return isPromise(result) ? result.then(apply) : apply(result);
67
+ }, orElse = (fn) => (result) => {
68
+ const apply = (r) => {
69
+ return isSuccess(r) ? r : fn(r.error);
70
+ };
71
+ return isPromise(result) ? result.then(apply) : apply(result);
72
+ }, pipe = (value, ...functions) => {
73
+ let next = value;
74
+ for (const func of functions) next = func(next);
75
+ return next;
76
+ }, try_ = (options) => {
77
+ return isPromise(options.try) ? "safe" in options && options.safe ? succeed(options.try) : options.try.then((value) => succeed(value), (error) => fail(options.catch(error))) : (...args) => {
78
+ try {
79
+ const output = options.try(...args);
80
+ if (isPromise(output)) {
81
+ const promise = succeed(output);
82
+ return "safe" in options && options.safe ? promise : promise.catch((error) => fail(options.catch(error)));
83
+ }
84
+ return succeed(output);
85
+ } catch (error) {
86
+ if ("safe" in options && options.safe) throw error;
87
+ return fail(options.catch(error));
88
+ }
89
+ };
90
+ }, homeDirectory = F.homedir(), { env } = process, xdgData = env.XDG_DATA_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "share") : void 0), xdgConfig = env.XDG_CONFIG_HOME || (homeDirectory ? path.join(homeDirectory, ".config") : void 0), xdgState = env.XDG_STATE_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "state") : void 0), xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, ".cache") : void 0), xdgRuntime = env.XDG_RUNTIME_DIR || void 0, xdgDataDirectories = (env.XDG_DATA_DIRS || "/usr/local/share/:/usr/share/").split(":");
91
+ if (xdgData) xdgDataDirectories.unshift(xdgData);
92
+ const xdgConfigDirectories = (env.XDG_CONFIG_DIRS || "/etc/xdg").split(":");
93
+ if (xdgConfig) xdgConfigDirectories.unshift(xdgConfig);
94
+ const LITELLM_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json", DEFAULT_RECENT_DAYS = 3, BLOCKS_WARNING_THRESHOLD = .8, BLOCKS_COMPACT_WIDTH_THRESHOLD = 120, BLOCKS_DEFAULT_TERMINAL_WIDTH = 120, DEBUG_MATCH_THRESHOLD_PERCENT = .1, USER_HOME_DIR = homedir(), XDG_CONFIG_DIR = xdgConfig ?? `${USER_HOME_DIR}/.config`, DEFAULT_CLAUDE_CODE_PATH = ".claude", DEFAULT_CLAUDE_CONFIG_PATH = `${XDG_CONFIG_DIR}/claude`, CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR", PROJECT_ALIASES_ENV = "CCUSAGE_PROJECT_ALIASES", CLAUDE_PROJECTS_DIR_NAME = "projects", USAGE_DATA_GLOB_PATTERN = "**/*.jsonl", MCP_DEFAULT_PORT = 8080, DEFAULT_REFRESH_INTERVAL_SECONDS = 1, MIN_REFRESH_INTERVAL_SECONDS = 1, MAX_REFRESH_INTERVAL_SECONDS = 60, MIN_RENDER_INTERVAL_MS = 16, BURN_RATE_THRESHOLDS = {
95
+ HIGH: 1e3,
96
+ MODERATE: 500
97
+ }, WEEK_DAYS = [
98
+ "sunday",
99
+ "monday",
100
+ "tuesday",
101
+ "wednesday",
102
+ "thursday",
103
+ "friday",
104
+ "saturday"
105
+ ];
106
+ var require_usingCtx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
107
+ function _usingCtx() {
108
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
109
+ var n$1 = Error();
110
+ return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
111
+ }, e = {}, n = [];
112
+ function using(r$1, e$1) {
113
+ if (null != e$1) {
114
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
115
+ if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
116
+ if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
117
+ if ("function" != typeof o) throw new TypeError("Object is not disposable.");
118
+ t && (o = function o$1() {
119
+ try {
120
+ t.call(e$1);
121
+ } catch (r$2) {
122
+ return Promise.reject(r$2);
123
+ }
124
+ }), n.push({
125
+ v: e$1,
126
+ d: o,
127
+ a: r$1
128
+ });
129
+ } else r$1 && n.push({
130
+ d: e$1,
131
+ a: r$1
132
+ });
133
+ return e$1;
134
+ }
135
+ return {
136
+ e,
137
+ u: using.bind(null, !1),
138
+ a: using.bind(null, !0),
139
+ d: function d() {
140
+ var o, t = this.e, s = 0;
141
+ function next() {
142
+ for (; o = n.pop();) try {
143
+ if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
144
+ if (o.d) {
145
+ var r$1 = o.d.call(o.v);
146
+ if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
147
+ } else s |= 1;
148
+ } catch (r$2) {
149
+ return err(r$2);
150
+ }
151
+ if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
152
+ if (t !== e) throw t;
153
+ }
154
+ function err(n$1) {
155
+ return t = t !== e ? new r(n$1, t) : n$1, next();
156
+ }
157
+ return next();
158
+ }
159
+ };
160
+ }
161
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
162
+ })), import_usingCtx = /* @__PURE__ */ __toESM(require_usingCtx(), 1), PricingFetcher = class {
163
+ cachedPricing = null;
164
+ offline;
165
+ constructor(offline = false) {
166
+ this.offline = offline;
167
+ }
168
+ [Symbol.dispose]() {
169
+ this.clearCache();
170
+ }
171
+ clearCache() {
172
+ this.cachedPricing = null;
173
+ }
174
+ loadOfflinePricing = try_({
175
+ try: async () => {
176
+ const pricing = new Map(Object.entries({
177
+ "claude-3-haiku-20240307": {
178
+ "input_cost_per_token": 25e-8,
179
+ "output_cost_per_token": 125e-8,
180
+ "cache_creation_input_token_cost": 3e-7,
181
+ "cache_read_input_token_cost": 3e-8
182
+ },
183
+ "claude-3-5-haiku-20241022": {
184
+ "input_cost_per_token": 8e-7,
185
+ "output_cost_per_token": 4e-6,
186
+ "cache_creation_input_token_cost": 1e-6,
187
+ "cache_read_input_token_cost": 8e-8
188
+ },
189
+ "claude-3-5-haiku-latest": {
190
+ "input_cost_per_token": 1e-6,
191
+ "output_cost_per_token": 5e-6,
192
+ "cache_creation_input_token_cost": 125e-8,
193
+ "cache_read_input_token_cost": 1e-7
194
+ },
195
+ "claude-3-opus-latest": {
196
+ "input_cost_per_token": 15e-6,
197
+ "output_cost_per_token": 75e-6,
198
+ "cache_creation_input_token_cost": 1875e-8,
199
+ "cache_read_input_token_cost": 15e-7
200
+ },
201
+ "claude-3-opus-20240229": {
202
+ "input_cost_per_token": 15e-6,
203
+ "output_cost_per_token": 75e-6,
204
+ "cache_creation_input_token_cost": 1875e-8,
205
+ "cache_read_input_token_cost": 15e-7
206
+ },
207
+ "claude-3-5-sonnet-latest": {
208
+ "input_cost_per_token": 3e-6,
209
+ "output_cost_per_token": 15e-6,
210
+ "cache_creation_input_token_cost": 375e-8,
211
+ "cache_read_input_token_cost": 3e-7
212
+ },
213
+ "claude-3-5-sonnet-20240620": {
214
+ "input_cost_per_token": 3e-6,
215
+ "output_cost_per_token": 15e-6,
216
+ "cache_creation_input_token_cost": 375e-8,
217
+ "cache_read_input_token_cost": 3e-7
218
+ },
219
+ "claude-opus-4-20250514": {
220
+ "input_cost_per_token": 15e-6,
221
+ "output_cost_per_token": 75e-6,
222
+ "cache_creation_input_token_cost": 1875e-8,
223
+ "cache_read_input_token_cost": 15e-7
224
+ },
225
+ "claude-opus-4-1": {
226
+ "input_cost_per_token": 15e-6,
227
+ "output_cost_per_token": 75e-6,
228
+ "cache_creation_input_token_cost": 1875e-8,
229
+ "cache_read_input_token_cost": 15e-7
230
+ },
231
+ "claude-opus-4-1-20250805": {
232
+ "input_cost_per_token": 15e-6,
233
+ "output_cost_per_token": 75e-6,
234
+ "cache_creation_input_token_cost": 1875e-8,
235
+ "cache_read_input_token_cost": 15e-7
236
+ },
237
+ "claude-sonnet-4-20250514": {
238
+ "input_cost_per_token": 3e-6,
239
+ "output_cost_per_token": 15e-6,
240
+ "cache_creation_input_token_cost": 375e-8,
241
+ "cache_read_input_token_cost": 3e-7
242
+ },
243
+ "claude-4-opus-20250514": {
244
+ "input_cost_per_token": 15e-6,
245
+ "output_cost_per_token": 75e-6,
246
+ "cache_creation_input_token_cost": 1875e-8,
247
+ "cache_read_input_token_cost": 15e-7
248
+ },
249
+ "claude-4-sonnet-20250514": {
250
+ "input_cost_per_token": 3e-6,
251
+ "output_cost_per_token": 15e-6,
252
+ "cache_creation_input_token_cost": 375e-8,
253
+ "cache_read_input_token_cost": 3e-7
254
+ },
255
+ "claude-3-7-sonnet-latest": {
256
+ "input_cost_per_token": 3e-6,
257
+ "output_cost_per_token": 15e-6,
258
+ "cache_creation_input_token_cost": 375e-8,
259
+ "cache_read_input_token_cost": 3e-7
260
+ },
261
+ "claude-3-7-sonnet-20250219": {
262
+ "input_cost_per_token": 3e-6,
263
+ "output_cost_per_token": 15e-6,
264
+ "cache_creation_input_token_cost": 375e-8,
265
+ "cache_read_input_token_cost": 3e-7
266
+ },
267
+ "claude-3-5-sonnet-20241022": {
268
+ "input_cost_per_token": 3e-6,
269
+ "output_cost_per_token": 15e-6,
270
+ "cache_creation_input_token_cost": 375e-8,
271
+ "cache_read_input_token_cost": 3e-7
272
+ }
273
+ }));
274
+ return this.cachedPricing = pricing, pricing;
275
+ },
276
+ catch: (error) => new Error("Failed to load offline pricing data", { cause: error })
277
+ });
278
+ async handleFallbackToCachedPricing(originalError) {
279
+ return logger.warn("Failed to fetch model pricing from LiteLLM, falling back to cached pricing data"), logger.debug("Fetch error details:", originalError), pipe(this.loadOfflinePricing(), inspect((pricing) => {
280
+ logger.info(`Using cached pricing data for ${pricing.size} models`);
281
+ }), inspectError((error) => {
282
+ logger.error("Failed to load cached pricing data as fallback:", error), logger.error("Original fetch error:", originalError);
283
+ }));
284
+ }
285
+ async ensurePricingLoaded() {
286
+ return pipe(this.cachedPricing != null ? succeed(this.cachedPricing) : fail(/* @__PURE__ */ new Error("Cached pricing not available")), orElse(async () => {
287
+ return this.offline ? this.loadOfflinePricing() : (logger.warn("Fetching latest model pricing from LiteLLM..."), pipe(try_({
288
+ try: fetch(LITELLM_PRICING_URL),
289
+ catch: (error) => new Error("Failed to fetch model pricing from LiteLLM", { cause: error })
290
+ }), andThrough((response) => {
291
+ return response.ok ? succeed() : fail(/* @__PURE__ */ new Error(`Failed to fetch pricing data: ${response.statusText}`));
292
+ }), andThen(async (response) => try_({
293
+ try: response.json(),
294
+ catch: (error) => new Error("Failed to parse pricing data", { cause: error })
295
+ })), map((data) => {
296
+ const pricing = /* @__PURE__ */ new Map();
297
+ for (const [modelName, modelData] of Object.entries(data)) if (typeof modelData === "object" && modelData !== null) {
298
+ const parsed = modelPricingSchema.safeParse(modelData);
299
+ if (parsed.success) pricing.set(modelName, parsed.data);
300
+ }
301
+ return pricing;
302
+ }), inspect((pricing) => {
303
+ this.cachedPricing = pricing, logger.info(`Loaded pricing for ${pricing.size} models`);
304
+ }), orElse(async (error) => this.handleFallbackToCachedPricing(error))));
305
+ }));
306
+ }
307
+ async fetchModelPricing() {
308
+ return this.ensurePricingLoaded();
309
+ }
310
+ async getModelPricing(modelName) {
311
+ return pipe(this.ensurePricingLoaded(), map((pricing) => {
312
+ const directMatch = pricing.get(modelName);
313
+ if (directMatch != null) return directMatch;
314
+ const variations = [
315
+ modelName,
316
+ `anthropic/${modelName}`,
317
+ `claude-3-5-${modelName}`,
318
+ `claude-3-${modelName}`,
319
+ `claude-${modelName}`
320
+ ];
321
+ for (const variant of variations) {
322
+ const match = pricing.get(variant);
323
+ if (match != null) return match;
324
+ }
325
+ const lowerModel = modelName.toLowerCase();
326
+ for (const [key, value] of pricing) if (key.toLowerCase().includes(lowerModel) || lowerModel.includes(key.toLowerCase())) return value;
327
+ return null;
328
+ }));
329
+ }
330
+ async calculateCostFromTokens(tokens, modelName) {
331
+ return pipe(this.getModelPricing(modelName), map((pricing) => pricing == null ? 0 : this.calculateCostFromPricing(tokens, pricing)));
332
+ }
333
+ calculateCostFromPricing(tokens, pricing) {
334
+ let cost = 0;
335
+ if (pricing.input_cost_per_token != null) cost += tokens.input_tokens * pricing.input_cost_per_token;
336
+ if (pricing.output_cost_per_token != null) cost += tokens.output_tokens * pricing.output_cost_per_token;
337
+ if (tokens.cache_creation_input_tokens != null && pricing.cache_creation_input_token_cost != null) cost += tokens.cache_creation_input_tokens * pricing.cache_creation_input_token_cost;
338
+ if (tokens.cache_read_input_tokens != null && pricing.cache_read_input_token_cost != null) cost += tokens.cache_read_input_tokens * pricing.cache_read_input_token_cost;
339
+ return cost;
340
+ }
341
+ };
342
+ export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PROJECT_ALIASES_ENV, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, WEEK_DAYS, __commonJSMin, __require, __toESM, isFailure, isPromise, require_usingCtx, try_ };
@@ -1,2 +1,2 @@
1
- import { PricingFetcher$1 as PricingFetcher } from "./pricing-fetcher-C9P2YKDv.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-B5m_kEpz.js";
2
2
  export { PricingFetcher };
@@ -1,4 +1,4 @@
1
- import { PricingFetcher } from "./pricing-fetcher-DXFi0Cxk.js";
2
- import "./_types-B-1t4mxD.js";
3
- import "./logger-BrRa0CCy.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-DzkXdtDF.js";
2
+ import "./_types-C0oFKDO-.js";
3
+ import "./logger-QcakA1fc.js";
4
4
  export { PricingFetcher };
@@ -4,18 +4,13 @@ import f from "node:readline";
4
4
  function getDefaultExportFromCjs(x$1) {
5
5
  return x$1 && x$1.__esModule && Object.prototype.hasOwnProperty.call(x$1, "default") ? x$1["default"] : x$1;
6
6
  }
7
- var src;
8
- var hasRequiredSrc;
7
+ var src, hasRequiredSrc;
9
8
  function requireSrc() {
10
9
  if (hasRequiredSrc) return src;
11
10
  hasRequiredSrc = 1;
12
- const ESC = "\x1B";
13
- const CSI = `${ESC}[`;
14
- const beep = "\x07";
15
- const cursor = {
11
+ const ESC = "\x1B", CSI = `${ESC}[`, beep = "\x07", cursor = {
16
12
  to(x$1, y$1) {
17
- if (!y$1) return `${CSI}${x$1 + 1}G`;
18
- return `${CSI}${y$1 + 1};${x$1 + 1}H`;
13
+ return y$1 ? `${CSI}${y$1 + 1};${x$1 + 1}H` : `${CSI}${x$1 + 1}G`;
19
14
  },
20
15
  move(x$1, y$1) {
21
16
  let ret = "";
@@ -36,12 +31,10 @@ function requireSrc() {
36
31
  show: `${CSI}?25h`,
37
32
  save: `${ESC}7`,
38
33
  restore: `${ESC}8`
39
- };
40
- const scroll = {
34
+ }, scroll = {
41
35
  up: (count = 1) => `${CSI}S`.repeat(count),
42
36
  down: (count = 1) => `${CSI}T`.repeat(count)
43
- };
44
- const erase = {
37
+ }, erase = {
45
38
  screen: `${CSI}2J`,
46
39
  up: (count = 1) => `${CSI}1J`.repeat(count),
47
40
  down: (count = 1) => `${CSI}J`.repeat(count),
@@ -55,36 +48,27 @@ function requireSrc() {
55
48
  return clear;
56
49
  }
57
50
  };
58
- src = {
51
+ return src = {
59
52
  cursor,
60
53
  scroll,
61
54
  erase,
62
55
  beep
63
- };
64
- return src;
56
+ }, src;
65
57
  }
66
- var srcExports = requireSrc();
67
- var picocolors = { exports: {} };
68
- var hasRequiredPicocolors;
58
+ var srcExports = requireSrc(), picocolors = { exports: {} }, hasRequiredPicocolors;
69
59
  function requirePicocolors() {
70
60
  if (hasRequiredPicocolors) return picocolors.exports;
71
61
  hasRequiredPicocolors = 1;
72
- let p = process || {}, argv = p.argv || [], env = p.env || {};
73
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
74
- let formatter = (open, close, replace = open) => (input) => {
62
+ let p = process || {}, argv = p.argv || [], env = p.env || {}, isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI), formatter = (open, close, replace = open) => (input) => {
75
63
  let string = "" + input, index = string.indexOf(close, open.length);
76
64
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
77
- };
78
- let replaceClose = (string, close, replace, index) => {
65
+ }, replaceClose = (string, close, replace, index) => {
79
66
  let result = "", cursor = 0;
80
- do {
81
- result += string.substring(cursor, index) + replace;
82
- cursor = index + close.length;
83
- index = string.indexOf(close, cursor);
84
- } while (~index);
67
+ do
68
+ result += string.substring(cursor, index) + replace, cursor = index + close.length, index = string.indexOf(close, cursor);
69
+ while (~index);
85
70
  return result + string.substring(cursor);
86
- };
87
- let createColors = (enabled = isColorSupported) => {
71
+ }, createColors = (enabled = isColorSupported) => {
88
72
  let f$1 = enabled ? formatter : () => String;
89
73
  return {
90
74
  isColorSupported: enabled,
@@ -131,9 +115,7 @@ function requirePicocolors() {
131
115
  bgWhiteBright: f$1("\x1B[107m", "\x1B[49m")
132
116
  };
133
117
  };
134
- picocolors.exports = createColors();
135
- picocolors.exports.createColors = createColors;
136
- return picocolors.exports;
118
+ return picocolors.exports = createColors(), picocolors.exports.createColors = createColors, picocolors.exports;
137
119
  }
138
120
  var picocolorsExports = /* @__PURE__ */ requirePicocolors();
139
121
  const e = /* @__PURE__ */ getDefaultExportFromCjs(picocolorsExports);
@@ -263,7 +245,7 @@ Object.keys(r.modifier);
263
245
  const tD = Object.keys(r.color), eD = Object.keys(r.bgColor);
264
246
  [...tD, ...eD];
265
247
  function sD() {
266
- const t = new Map();
248
+ const t = /* @__PURE__ */ new Map();
267
249
  for (const [u$1, F$1] of Object.entries(r)) {
268
250
  for (const [e$1, s] of Object.entries(F$1)) r[e$1] = {
269
251
  open: `\x1B[${s[0]}m`,
@@ -381,7 +363,7 @@ const iD = sD(), v = new Set(["\x1B", "›"]), CD = 39, w$1 = "\x07", W$1 = "[",
381
363
  `)];
382
364
  for (const [E, a] of o$1.entries()) {
383
365
  if (e$1 += a, v.has(a)) {
384
- const { groups: B$1 } = new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`).exec(o$1.slice(E).join("")) || { groups: {} };
366
+ const { groups: B$1 } = (/* @__PURE__ */ new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`)).exec(o$1.slice(E).join("")) || { groups: {} };
385
367
  if (B$1.code !== void 0) {
386
368
  const p = Number.parseFloat(B$1.code);
387
369
  s = p === CD ? void 0 : p;
@@ -443,10 +425,9 @@ var AD = Object.defineProperty, pD = (t, u$1, F$1) => u$1 in t ? AD(t, u$1, {
443
425
  configurable: true,
444
426
  writable: true,
445
427
  value: F$1
446
- }) : t[u$1] = F$1, h = (t, u$1, F$1) => (pD(t, typeof u$1 != "symbol" ? u$1 + "" : u$1, F$1), F$1);
447
- var x = class {
428
+ }) : t[u$1] = F$1, h = (t, u$1, F$1) => (pD(t, typeof u$1 != "symbol" ? u$1 + "" : u$1, F$1), F$1), x = class {
448
429
  constructor(u$1, F$1 = true) {
449
- h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
430
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
450
431
  const { input: e$1 = stdin, output: s = stdout, render: i, signal: D,...C$1 } = u$1;
451
432
  this.opts = C$1, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F$1, this._abortSignal = D, this.input = e$1, this.output = s;
452
433
  }
@@ -546,8 +527,7 @@ var x = class {
546
527
  this.output.write(u$1), this.state === "initial" && (this.state = "active"), this._prevFrame = u$1;
547
528
  }
548
529
  }
549
- };
550
- var fD = class extends x {
530
+ }, fD = class extends x {
551
531
  get cursor() {
552
532
  return this.value ? 0 : 1;
553
533
  }
@@ -563,8 +543,7 @@ var fD = class extends x {
563
543
  this.value = !this.value;
564
544
  });
565
545
  }
566
- };
567
- var bD = Object.defineProperty, mD = (t, u$1, F$1) => u$1 in t ? bD(t, u$1, {
546
+ }, bD = Object.defineProperty, mD = (t, u$1, F$1) => u$1 in t ? bD(t, u$1, {
568
547
  enumerable: true,
569
548
  configurable: true,
570
549
  writable: true,
@@ -607,8 +586,7 @@ var SD = Object.defineProperty, $D = (t, u$1, F$1) => u$1 in t ? SD(t, u$1, {
607
586
  configurable: true,
608
587
  writable: true,
609
588
  value: F$1
610
- }) : t[u$1] = F$1, q = (t, u$1, F$1) => ($D(t, typeof u$1 != "symbol" ? u$1 + "" : u$1, F$1), F$1);
611
- var jD = class extends x {
589
+ }) : t[u$1] = F$1, q = (t, u$1, F$1) => ($D(t, typeof u$1 != "symbol" ? u$1 + "" : u$1, F$1), F$1), jD = class extends x {
612
590
  constructor(u$1) {
613
591
  super(u$1, false), q(this, "options"), q(this, "cursor", 0), this.options = u$1.options, this.cursor = this.options.findIndex(({ value: F$1 }) => F$1 === u$1.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F$1) => {
614
592
  switch (F$1) {
@@ -630,8 +608,7 @@ var jD = class extends x {
630
608
  changeValue() {
631
609
  this.value = this._value.value;
632
610
  }
633
- };
634
- var PD = class extends x {
611
+ }, PD = class extends x {
635
612
  get valueWithCursor() {
636
613
  if (this.state === "submit") return this.value;
637
614
  if (this.cursor >= this.value.length) return `${this.value}\u2588`;
@@ -804,9 +781,8 @@ async function prompt(message, opts = {}) {
804
781
  if (typeof value !== "symbol" || value.toString() !== "Symbol(clack:cancel)") return value;
805
782
  switch (opts.cancel) {
806
783
  case "reject": {
807
- const error = new Error("Prompt cancelled.");
808
- error.name = "ConsolaPromptCancelledError";
809
- if (Error.captureStackTrace) Error.captureStackTrace(error, prompt);
784
+ const error = /* @__PURE__ */ new Error("Prompt cancelled.");
785
+ if (error.name = "ConsolaPromptCancelledError", Error.captureStackTrace) Error.captureStackTrace(error, prompt);
810
786
  throw error;
811
787
  }
812
788
  case "undefined": return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccusage",
3
- "version": "15.9.2",
3
+ "version": "15.9.4",
4
4
  "description": "Usage analysis tool for Claude Code",
5
5
  "homepage": "https://github.com/ryoppippi/ccusage#readme",
6
6
  "bugs": {