ccusage 15.9.5 → 15.9.6
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/{data-loader-Plh5X-UR.js → data-loader-C_o-3Ju1.js} +3 -3
- package/dist/data-loader.js +3 -3
- package/dist/{debug-C4f2zPfQ.js → debug-DX6e8anz.js} +3 -3
- package/dist/debug.js +4 -4
- package/dist/index.js +89 -83
- package/dist/{logger-dT_AJeHG.js → logger-B42xzUl2.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-DfY3l9w7.js → mcp-DsGPnOCJ.js} +3 -3
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-CTYPN13Y.js → pricing-fetcher-BtJtc54j.js} +6 -4
- package/dist/pricing-fetcher.js +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LIMIT, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, require_usingCtx } from "./pricing-fetcher-
|
|
1
|
+
import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LIMIT, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, require_usingCtx } from "./pricing-fetcher-BtJtc54j.js";
|
|
2
2
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import { activityDateSchema, arrayType, booleanType, createBucket, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, createWeeklyDate, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, stringType, unionType, versionSchema, weeklyDateSchema } from "./_types-C0oFKDO-.js";
|
|
4
|
-
import { logger } from "./logger-
|
|
4
|
+
import { logger } from "./logger-B42xzUl2.js";
|
|
5
5
|
import a, { readFile } from "node:fs/promises";
|
|
6
6
|
import path, { posix } from "node:path";
|
|
7
7
|
import process$1 from "node:process";
|
|
@@ -2624,7 +2624,7 @@ async function loadWeeklyUsageData(options) {
|
|
|
2624
2624
|
async function loadSessionUsageById(sessionId, options) {
|
|
2625
2625
|
try {
|
|
2626
2626
|
var _usingCtx4 = (0, import_usingCtx.default)();
|
|
2627
|
-
const claudePaths = getClaudePaths(), patterns = claudePaths.map((p) => path.join(p, "projects", "**", `${sessionId}.jsonl`)), jsonlFiles = await glob(patterns);
|
|
2627
|
+
const claudePaths = getClaudePaths(), patterns = claudePaths.map((p) => path.join(p, "projects", "**", `${sessionId}.jsonl`).replace(/\\/g, "/")), jsonlFiles = await glob(patterns);
|
|
2628
2628
|
if (jsonlFiles.length === 0) return null;
|
|
2629
2629
|
const file = jsonlFiles[0];
|
|
2630
2630
|
if (file == null) return null;
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-BtJtc54j.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-C0oFKDO-.js";
|
|
4
|
-
import { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-
|
|
5
|
-
import "./logger-
|
|
4
|
+
import { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-C_o-3Ju1.js";
|
|
5
|
+
import "./logger-B42xzUl2.js";
|
|
6
6
|
export { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-
|
|
2
|
-
import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-
|
|
3
|
-
import { logger } from "./logger-
|
|
1
|
+
import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-BtJtc54j.js";
|
|
2
|
+
import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-C_o-3Ju1.js";
|
|
3
|
+
import { logger } from "./logger-B42xzUl2.js";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
var import_usingCtx = /* @__PURE__ */ __toESM(require_usingCtx(), 1);
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-BtJtc54j.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-C0oFKDO-.js";
|
|
4
|
-
import "./data-loader-
|
|
5
|
-
import "./logger-
|
|
6
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
4
|
+
import "./data-loader-C_o-3Ju1.js";
|
|
5
|
+
import "./logger-B42xzUl2.js";
|
|
6
|
+
import { detectMismatches, printMismatchReport } from "./debug-DX6e8anz.js";
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, 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, WEEK_DAYS, __commonJSMin, __require, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-
|
|
2
|
+
import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, 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, WEEK_DAYS, __commonJSMin, __require, __toESM, inspectError, isFailure, map, pipe, require_usingCtx, try_ } from "./pricing-fetcher-BtJtc54j.js";
|
|
3
3
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
4
4
|
import { CostModes, SortOrders, filterDateSchema, statuslineHookJsonSchema } from "./_types-C0oFKDO-.js";
|
|
5
5
|
import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
|
|
6
|
-
import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateContextTokens, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, projectBlockUsage, sortFilesByTimestamp, uniq, usageDataSchema } from "./data-loader-
|
|
7
|
-
import { description, log, logger, name, version } from "./logger-
|
|
8
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
9
|
-
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-
|
|
6
|
+
import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateContextTokens, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, projectBlockUsage, sortFilesByTimestamp, uniq, unwrap, usageDataSchema } from "./data-loader-C_o-3Ju1.js";
|
|
7
|
+
import { description, log, logger, name, version } from "./logger-B42xzUl2.js";
|
|
8
|
+
import { detectMismatches, printMismatchReport } from "./debug-DX6e8anz.js";
|
|
9
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DsGPnOCJ.js";
|
|
10
10
|
import a, { readFile } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import process$1 from "node:process";
|
|
@@ -1893,15 +1893,15 @@ var require_debug$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1893
1893
|
} };
|
|
1894
1894
|
}), ret;
|
|
1895
1895
|
}
|
|
1896
|
-
var sequencer = function sequencer$1(map$
|
|
1896
|
+
var sequencer = function sequencer$1(map$2, str) {
|
|
1897
1897
|
var exploded = str.split("");
|
|
1898
|
-
return exploded = exploded.map(map$
|
|
1898
|
+
return exploded = exploded.map(map$2), exploded.join("");
|
|
1899
1899
|
};
|
|
1900
|
-
for (var map in colors$1.trap = require_trap(), colors$1.zalgo = require_zalgo(), colors$1.maps = {}, colors$1.maps.america = require_america()(colors$1), colors$1.maps.zebra = require_zebra()(colors$1), colors$1.maps.rainbow = require_rainbow()(colors$1), colors$1.maps.random = require_random()(colors$1), colors$1.maps) (function(map$
|
|
1901
|
-
colors$1[map$
|
|
1902
|
-
return sequencer(colors$1.maps[map$
|
|
1900
|
+
for (var map$1 in colors$1.trap = require_trap(), colors$1.zalgo = require_zalgo(), colors$1.maps = {}, colors$1.maps.america = require_america()(colors$1), colors$1.maps.zebra = require_zebra()(colors$1), colors$1.maps.rainbow = require_rainbow()(colors$1), colors$1.maps.random = require_random()(colors$1), colors$1.maps) (function(map$2) {
|
|
1901
|
+
colors$1[map$2] = function(str) {
|
|
1902
|
+
return sequencer(colors$1.maps[map$2], str);
|
|
1903
1903
|
};
|
|
1904
|
-
})(map);
|
|
1904
|
+
})(map$1);
|
|
1905
1905
|
defineProps(colors$1, init());
|
|
1906
1906
|
})), require_safe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1907
1907
|
var colors = require_colors();
|
|
@@ -2558,10 +2558,10 @@ function delay(ms, options = {}) {
|
|
|
2558
2558
|
const { signal, persistent = true } = options;
|
|
2559
2559
|
return signal?.aborted ? Promise.reject(signal.reason) : new Promise((resolve, reject) => {
|
|
2560
2560
|
const abort = () => {
|
|
2561
|
-
clearTimeout(i), reject(signal?.reason);
|
|
2561
|
+
clearTimeout(+i), reject(signal?.reason);
|
|
2562
2562
|
}, done = () => {
|
|
2563
2563
|
signal?.removeEventListener("abort", abort), resolve();
|
|
2564
|
-
}, i =
|
|
2564
|
+
}, i = setArbitraryLengthTimeout(done, ms);
|
|
2565
2565
|
if (signal?.addEventListener("abort", abort, { once: true }), persistent === false) try {
|
|
2566
2566
|
Deno.unrefTimer(i);
|
|
2567
2567
|
} catch (error) {
|
|
@@ -2570,6 +2570,16 @@ function delay(ms, options = {}) {
|
|
|
2570
2570
|
}
|
|
2571
2571
|
});
|
|
2572
2572
|
}
|
|
2573
|
+
const I32_MAX = 2 ** 31 - 1;
|
|
2574
|
+
function setArbitraryLengthTimeout(callback, delay$1) {
|
|
2575
|
+
let currentDelay = delay$1 = Math.trunc(Math.max(delay$1, 0) || 0);
|
|
2576
|
+
const start = Date.now();
|
|
2577
|
+
let timeoutId;
|
|
2578
|
+
const queueTimeout = () => {
|
|
2579
|
+
currentDelay = delay$1 - (Date.now() - start), timeoutId = currentDelay > I32_MAX ? setTimeout(queueTimeout, I32_MAX) : setTimeout(callback, currentDelay);
|
|
2580
|
+
};
|
|
2581
|
+
return queueTimeout(), { valueOf: () => timeoutId };
|
|
2582
|
+
}
|
|
2573
2583
|
const isBrowser = globalThis.window?.document !== void 0, isNode = globalThis.process?.versions?.node !== void 0, isBun = globalThis.process?.versions?.bun !== void 0, isDeno = globalThis.Deno?.version?.deno !== void 0, isElectron = globalThis.process?.versions?.electron !== void 0, isJsDom = globalThis.navigator?.userAgent?.includes("jsdom") === true, isWebWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope, isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope, isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope, isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope, platform = globalThis.navigator?.userAgentData?.platform, isMacOs = platform === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin", isWindows$1 = platform === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32", isLinux = platform === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux", isIos = platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform), isAndroid = platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android", ESC = "\x1B[", SEP = ";", isTerminalApp = !isBrowser && process$1.env.TERM_PROGRAM === "Apple_Terminal", isWindows = !isBrowser && process$1.platform === "win32", cwdFunction = isBrowser ? () => {
|
|
2574
2584
|
throw new Error("`process.cwd()` only works in Node.js, not the browser.");
|
|
2575
2585
|
} : process$1.cwd, cursorTo = (x, y) => {
|
|
@@ -3702,26 +3712,29 @@ var outgoingEnded = Symbol("outgoingEnded"), handleRequestError = () => new Resp
|
|
|
3702
3712
|
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
3703
3713
|
if (res.body) {
|
|
3704
3714
|
const reader = res.body.getReader(), values = [];
|
|
3705
|
-
let done = false, currentReadPromise = void 0
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
+
let done = false, currentReadPromise = void 0;
|
|
3716
|
+
if (resHeaderRecord["transfer-encoding"] !== "chunked") {
|
|
3717
|
+
let maxReadCount = 2;
|
|
3718
|
+
for (let i = 0; i < maxReadCount; i++) {
|
|
3719
|
+
currentReadPromise ||= reader.read();
|
|
3720
|
+
const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
|
|
3721
|
+
console.error(e), done = true;
|
|
3722
|
+
});
|
|
3723
|
+
if (!chunk) {
|
|
3724
|
+
if (i === 1) {
|
|
3725
|
+
await new Promise((resolve) => setTimeout(resolve)), maxReadCount = 3;
|
|
3726
|
+
continue;
|
|
3727
|
+
}
|
|
3728
|
+
break;
|
|
3729
|
+
}
|
|
3730
|
+
if (currentReadPromise = void 0, chunk.value) values.push(chunk.value);
|
|
3731
|
+
if (chunk.done) {
|
|
3732
|
+
done = true;
|
|
3733
|
+
break;
|
|
3715
3734
|
}
|
|
3716
|
-
break;
|
|
3717
|
-
}
|
|
3718
|
-
if (currentReadPromise = void 0, chunk.value) values.push(chunk.value);
|
|
3719
|
-
if (chunk.done) {
|
|
3720
|
-
done = true;
|
|
3721
|
-
break;
|
|
3722
3735
|
}
|
|
3736
|
+
if (done && !("content-length" in resHeaderRecord)) resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
3723
3737
|
}
|
|
3724
|
-
if (done && !("content-length" in resHeaderRecord)) resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
3725
3738
|
if (outgoing.writeHead(res.status, resHeaderRecord), values.forEach((value) => {
|
|
3726
3739
|
outgoing.write(value);
|
|
3727
3740
|
}), done) outgoing.end();
|
|
@@ -4221,72 +4234,65 @@ const statuslineCommand = define({
|
|
|
4221
4234
|
if (!hookDataParseResult.success) log("❌ Invalid input format:", hookDataParseResult.error.message), process$1.exit(1);
|
|
4222
4235
|
const hookData = hookDataParseResult.data, claudePaths = getClaudePaths();
|
|
4223
4236
|
if (claudePaths.length === 0) log("❌ No Claude data directory found"), process$1.exit(1);
|
|
4224
|
-
const sessionId = hookData.session_id
|
|
4225
|
-
|
|
4226
|
-
try {
|
|
4227
|
-
const sessionData = await loadSessionUsageById(sessionId, {
|
|
4237
|
+
const sessionId = hookData.session_id, sessionCost = await pipe(try_({
|
|
4238
|
+
try: loadSessionUsageById(sessionId, {
|
|
4228
4239
|
mode: "auto",
|
|
4229
4240
|
offline: ctx.values.offline
|
|
4230
|
-
})
|
|
4231
|
-
|
|
4232
|
-
}
|
|
4233
|
-
|
|
4234
|
-
}
|
|
4235
|
-
const today = /* @__PURE__ */ new Date(), todayStr = today.toISOString().split("T")[0]?.replace(/-/g, "") ?? "";
|
|
4236
|
-
let todayCost = 0;
|
|
4237
|
-
try {
|
|
4238
|
-
const dailyData = await loadDailyUsageData({
|
|
4241
|
+
}),
|
|
4242
|
+
catch: (error) => error
|
|
4243
|
+
}), map((sessionCost$1) => sessionCost$1?.totalCost), inspectError((error) => logger.error("Failed to load session data:", error)), unwrap(void 0)), today = /* @__PURE__ */ new Date(), todayStr = today.toISOString().split("T")[0]?.replace(/-/g, "") ?? "", todayCost = await pipe(try_({
|
|
4244
|
+
try: loadDailyUsageData({
|
|
4239
4245
|
since: todayStr,
|
|
4240
4246
|
until: todayStr,
|
|
4241
4247
|
mode: "auto",
|
|
4242
4248
|
offline: ctx.values.offline
|
|
4243
|
-
})
|
|
4249
|
+
}),
|
|
4250
|
+
catch: (error) => error
|
|
4251
|
+
}), map((dailyData) => {
|
|
4244
4252
|
if (dailyData.length > 0) {
|
|
4245
4253
|
const totals = calculateTotals(dailyData);
|
|
4246
|
-
|
|
4254
|
+
return totals.totalCost;
|
|
4247
4255
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
let blockInfo = "", burnRateInfo = "";
|
|
4252
|
-
try {
|
|
4253
|
-
const blocks = await loadSessionBlockData({
|
|
4256
|
+
return 0;
|
|
4257
|
+
}), inspectError((error) => logger.error("Failed to load daily data:", error)), unwrap(0)), { blockInfo, burnRateInfo } = await pipe(try_({
|
|
4258
|
+
try: loadSessionBlockData({
|
|
4254
4259
|
mode: "auto",
|
|
4255
4260
|
offline: ctx.values.offline
|
|
4261
|
+
}),
|
|
4262
|
+
catch: (error) => error
|
|
4263
|
+
}), map((blocks) => {
|
|
4264
|
+
if (blocks.length === 0) return {
|
|
4265
|
+
blockInfo: "No active block",
|
|
4266
|
+
burnRateInfo: ""
|
|
4267
|
+
};
|
|
4268
|
+
const activeBlock = blocks.find((block) => {
|
|
4269
|
+
return !!block.isActive;
|
|
4256
4270
|
});
|
|
4257
|
-
if (
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
return
|
|
4261
|
-
});
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
if (burnRate != null) {
|
|
4267
|
-
const costPerHour = burnRate.costPerHour, costPerHourStr = `${formatCurrency(costPerHour)}/hr`;
|
|
4268
|
-
let coloredBurnRate = costPerHourStr;
|
|
4269
|
-
if (burnRate.tokensPerMinuteForIndicator < 2e3) coloredBurnRate = import_picocolors$1.default.green(costPerHourStr);
|
|
4270
|
-
else if (burnRate.tokensPerMinuteForIndicator < 5e3) coloredBurnRate = import_picocolors$1.default.yellow(costPerHourStr);
|
|
4271
|
-
else coloredBurnRate = import_picocolors$1.default.red(costPerHourStr);
|
|
4272
|
-
burnRateInfo = ` | 🔥 ${coloredBurnRate}`;
|
|
4273
|
-
}
|
|
4274
|
-
} else blockInfo = "No active block";
|
|
4275
|
-
}
|
|
4276
|
-
} catch (error) {
|
|
4277
|
-
logger.error("Failed to load block data:", error), blockInfo = "No active block";
|
|
4278
|
-
}
|
|
4279
|
-
let contextInfo = "";
|
|
4280
|
-
try {
|
|
4281
|
-
const contextData = await calculateContextTokens(hookData.transcript_path);
|
|
4282
|
-
if (contextData != null) {
|
|
4283
|
-
const p$1 = contextData.percentage, thresholds = getContextUsageThresholds(), color = p$1 < thresholds.LOW ? import_picocolors$1.default.green : p$1 < thresholds.MEDIUM ? import_picocolors$1.default.yellow : import_picocolors$1.default.red, coloredPercentage = color(`${p$1}%`), tokenDisplay = contextData.inputTokens.toLocaleString();
|
|
4284
|
-
contextInfo = ` | 🧠 ${tokenDisplay} (${coloredPercentage})`;
|
|
4271
|
+
if (activeBlock != null) {
|
|
4272
|
+
const now = /* @__PURE__ */ new Date(), remaining = Math.round((activeBlock.endTime.getTime() - now.getTime()) / (1e3 * 60)), blockCost = activeBlock.costUSD, blockInfo$1 = `${formatCurrency(blockCost)} block (${formatRemainingTime(remaining)})`, burnRate = calculateBurnRate(activeBlock), burnRateInfo$1 = burnRate != null ? (() => {
|
|
4273
|
+
const costPerHour = burnRate.costPerHour, costPerHourStr = `${formatCurrency(costPerHour)}/hr`, coloredBurnRate = burnRate.tokensPerMinuteForIndicator < 2e3 ? import_picocolors$1.default.green(costPerHourStr) : burnRate.tokensPerMinuteForIndicator < 5e3 ? import_picocolors$1.default.yellow(costPerHourStr) : import_picocolors$1.default.red(costPerHourStr);
|
|
4274
|
+
return ` | 🔥 ${coloredBurnRate}`;
|
|
4275
|
+
})() : "";
|
|
4276
|
+
return {
|
|
4277
|
+
blockInfo: blockInfo$1,
|
|
4278
|
+
burnRateInfo: burnRateInfo$1
|
|
4279
|
+
};
|
|
4285
4280
|
}
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4281
|
+
return {
|
|
4282
|
+
blockInfo: "No active block",
|
|
4283
|
+
burnRateInfo: ""
|
|
4284
|
+
};
|
|
4285
|
+
}), inspectError((error) => logger.error("Failed to load block data:", error)), unwrap({
|
|
4286
|
+
blockInfo: "No active block",
|
|
4287
|
+
burnRateInfo: ""
|
|
4288
|
+
})), contextInfo = await pipe(try_({
|
|
4289
|
+
try: calculateContextTokens(hookData.transcript_path),
|
|
4290
|
+
catch: (error) => error
|
|
4291
|
+
}), inspectError((error) => logger.debug(`Failed to calculate context tokens: ${error instanceof Error ? error.message : String(error)}`)), map((ctx$1) => {
|
|
4292
|
+
if (ctx$1 == null) return void 0;
|
|
4293
|
+
const thresholds = getContextUsageThresholds(), color = ctx$1.percentage < thresholds.LOW ? import_picocolors$1.default.green : ctx$1.percentage < thresholds.MEDIUM ? import_picocolors$1.default.yellow : import_picocolors$1.default.red, coloredPercentage = color(`${ctx$1.percentage}%`), tokenDisplay = ctx$1.inputTokens.toLocaleString();
|
|
4294
|
+
return `${tokenDisplay} (${coloredPercentage})`;
|
|
4295
|
+
}), unwrap(void 0)), modelName = hookData.model.display_name, sessionDisplay = sessionCost != null ? formatCurrency(sessionCost) : "N/A", statusLine = `🤖 ${modelName} | 💰 ${sessionDisplay} session / ${formatCurrency(todayCost)} today / ${blockInfo}${burnRateInfo} | 🧠 ${contextInfo ?? "N/A"}`;
|
|
4290
4296
|
log(statusLine);
|
|
4291
4297
|
}
|
|
4292
4298
|
});
|
|
@@ -761,7 +761,7 @@ function _getDefaultLogLevel() {
|
|
|
761
761
|
return g ? LogLevels.debug : R ? LogLevels.warn : LogLevels.info;
|
|
762
762
|
}
|
|
763
763
|
const consola = createConsola$1();
|
|
764
|
-
var name = "ccusage", version = "15.9.
|
|
764
|
+
var name = "ccusage", version = "15.9.6", description = "Usage analysis tool for Claude Code";
|
|
765
765
|
const logger = consola.withTag(name);
|
|
766
766
|
if (process$1.env.LOG_LEVEL != null) {
|
|
767
767
|
const level = Number.parseInt(process$1.env.LOG_LEVEL, 10);
|
package/dist/logger.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { log, logger } from "./logger-
|
|
1
|
+
import { log, logger } from "./logger-B42xzUl2.js";
|
|
2
2
|
export { log, logger };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-
|
|
1
|
+
import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-BtJtc54j.js";
|
|
2
2
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import { ZodFirstPartyTypeKind, ZodOptional, ZodType, arrayType, booleanType, discriminatedUnionType, enumType, filterDateSchema, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./_types-C0oFKDO-.js";
|
|
4
4
|
import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
|
|
5
|
-
import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-
|
|
6
|
-
import { name, version } from "./logger-
|
|
5
|
+
import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-C_o-3Ju1.js";
|
|
6
|
+
import { name, version } from "./logger-B42xzUl2.js";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
const LATEST_PROTOCOL_VERSION = "2025-06-18", SUPPORTED_PROTOCOL_VERSIONS = [
|
|
9
9
|
LATEST_PROTOCOL_VERSION,
|
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-BtJtc54j.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-C0oFKDO-.js";
|
|
4
4
|
import "./calculate-cost-BDqO4yWA.js";
|
|
5
|
-
import "./data-loader-
|
|
6
|
-
import "./logger-
|
|
7
|
-
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-
|
|
5
|
+
import "./data-loader-C_o-3Ju1.js";
|
|
6
|
+
import "./logger-B42xzUl2.js";
|
|
7
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DsGPnOCJ.js";
|
|
8
8
|
export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { modelPricingSchema } from "./_types-C0oFKDO-.js";
|
|
2
|
-
import { logger } from "./logger-
|
|
2
|
+
import { logger } from "./logger-B42xzUl2.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import F, { homedir } from "node:os";
|
|
@@ -30,8 +30,9 @@ const isFailure = (result) => "Failure" === result.type, isPromise = (value) =>
|
|
|
30
30
|
};
|
|
31
31
|
return isPromise(result) ? result.then(apply) : apply(result);
|
|
32
32
|
}, isSuccess = (result) => "Success" === result.type, succeed = (...args) => {
|
|
33
|
+
if (args.length <= 0) return { type: "Success" };
|
|
33
34
|
const value = args[0];
|
|
34
|
-
return
|
|
35
|
+
return isPromise(value) ? value.then((value$1) => ({
|
|
35
36
|
type: "Success",
|
|
36
37
|
value: value$1
|
|
37
38
|
})) : {
|
|
@@ -39,8 +40,9 @@ const isFailure = (result) => "Failure" === result.type, isPromise = (value) =>
|
|
|
39
40
|
value
|
|
40
41
|
};
|
|
41
42
|
}, fail = (...args) => {
|
|
43
|
+
if (args.length <= 0) return { type: "Failure" };
|
|
42
44
|
const error = args[0];
|
|
43
|
-
return
|
|
45
|
+
return isPromise(error) ? error.then((error$1) => ({
|
|
44
46
|
type: "Failure",
|
|
45
47
|
error: error$1
|
|
46
48
|
})) : {
|
|
@@ -342,4 +344,4 @@ var require_usingCtx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
342
344
|
return cost;
|
|
343
345
|
}
|
|
344
346
|
};
|
|
345
|
-
export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LIMIT, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, 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_ };
|
|
347
|
+
export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LIMIT, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, 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, inspectError, isFailure, isPromise, map, pipe, require_usingCtx, try_ };
|
package/dist/pricing-fetcher.js
CHANGED