ccusage 16.2.3 → 16.2.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/{data-loader-Brcu2FT2.js → data-loader-DV25VhPk.js} +2 -2
- package/dist/data-loader.js +3 -3
- package/dist/{debug-DusXel-O.js → debug-CWd5mOJK.js} +3 -3
- package/dist/debug.js +4 -4
- package/dist/index.js +5 -5
- package/dist/{logger-C2RpPo-E.js → logger-Df86rWXR.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-DnYYAmTW.js → mcp-CEW0jW3t.js} +40 -25
- package/dist/mcp.js +4 -4
- package/dist/{pricing-fetcher-2vtv5hE7.js → pricing-fetcher-COuXYEih.js} +1 -1
- 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, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_LOCALE, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, isSuccess, map, pipe, require_usingCtx, try_ } from "./pricing-fetcher-
|
|
1
|
+
import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_LOCALE, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, isSuccess, map, pipe, require_usingCtx, try_ } from "./pricing-fetcher-COuXYEih.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-DIdtMJ6V.js";
|
|
4
|
-
import { logger } from "./logger-
|
|
4
|
+
import { logger } from "./logger-Df86rWXR.js";
|
|
5
5
|
import a, { readFile, stat } from "node:fs/promises";
|
|
6
6
|
import path, { posix } from "node:path";
|
|
7
7
|
import process$1 from "node:process";
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-COuXYEih.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-DIdtMJ6V.js";
|
|
4
|
-
import { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, getClaudePaths, 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, getClaudePaths, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-DV25VhPk.js";
|
|
5
|
+
import "./logger-Df86rWXR.js";
|
|
6
6
|
export { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, getClaudePaths, 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-COuXYEih.js";
|
|
2
|
+
import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-DV25VhPk.js";
|
|
3
|
+
import { logger } from "./logger-Df86rWXR.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-COuXYEih.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-DIdtMJ6V.js";
|
|
4
|
-
import "./data-loader-
|
|
5
|
-
import "./logger-
|
|
6
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
4
|
+
import "./data-loader-DV25VhPk.js";
|
|
5
|
+
import "./logger-Df86rWXR.js";
|
|
6
|
+
import { detectMismatches, printMismatchReport } from "./debug-CWd5mOJK.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, CONFIG_FILE_NAME, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_LOCALE, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PricingFetcher, WEEK_DAYS, __commonJSMin, __require, __toESM, andThen, fail, inspect, inspectError, isFailure, isSuccess, map, pipe, require_usingCtx, succeed, try_ } from "./pricing-fetcher-
|
|
2
|
+
import { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CONFIG_FILE_NAME, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_LOCALE, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PricingFetcher, WEEK_DAYS, __commonJSMin, __require, __toESM, andThen, fail, inspect, inspectError, isFailure, isSuccess, map, pipe, require_usingCtx, succeed, try_ } from "./pricing-fetcher-COuXYEih.js";
|
|
3
3
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
4
4
|
import { CostModes, SortOrders, coerce, filterDateSchema, statuslineHookJsonSchema } from "./_types-DIdtMJ6V.js";
|
|
5
5
|
import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
|
|
6
|
-
import { DEFAULT_SESSION_DURATION_HOURS, calculateBurnRate, calculateContextTokens, calculateCostForEntry, createUniqueHash, filterRecentBlocks, formatDateCompact, getClaudePaths, getEarliestTimestamp, getFileModifiedTime, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, projectBlockUsage, sortFilesByTimestamp, toArray, uniq, unreachable, unwrap, 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, getEarliestTimestamp, getFileModifiedTime, getUsageLimitResetTime, globUsageFiles, identifySessionBlocks, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, projectBlockUsage, sortFilesByTimestamp, toArray, uniq, unreachable, unwrap, usageDataSchema } from "./data-loader-DV25VhPk.js";
|
|
7
|
+
import { description, log, logger, name, version } from "./logger-Df86rWXR.js";
|
|
8
|
+
import { detectMismatches, printMismatchReport } from "./debug-CWd5mOJK.js";
|
|
9
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-CEW0jW3t.js";
|
|
10
10
|
import a, { readFile, stat } from "node:fs/promises";
|
|
11
11
|
import path, { join } from "node:path";
|
|
12
12
|
import process$1 from "node:process";
|
|
@@ -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 = "16.2.
|
|
764
|
+
var name = "ccusage", version = "16.2.4", 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-Df86rWXR.js";
|
|
2
2
|
export { log, logger };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DEFAULT_LOCALE, __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-
|
|
1
|
+
import { DEFAULT_LOCALE, __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-COuXYEih.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-DIdtMJ6V.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-DV25VhPk.js";
|
|
6
|
+
import { name, version } from "./logger-Df86rWXR.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,
|
|
@@ -881,21 +881,24 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
881
881
|
id: null
|
|
882
882
|
}) });
|
|
883
883
|
return streamSSE(ctx, async (stream) => {
|
|
884
|
-
const resolvedStreamId = typeof streamId === "string" ? streamId : await streamId(stream)
|
|
885
|
-
this.#streamMapping.set(resolvedStreamId, {
|
|
886
|
-
ctx,
|
|
887
|
-
stream
|
|
888
|
-
});
|
|
889
|
-
const keepAlive = setInterval(() => {
|
|
884
|
+
const resolvedStreamId = typeof streamId === "string" ? streamId : await streamId(stream), keepAlive = setInterval(() => {
|
|
890
885
|
if (!stream.closed) stream.writeSSE({
|
|
891
886
|
data: "",
|
|
892
887
|
event: "ping"
|
|
893
888
|
}).catch(() => {
|
|
894
|
-
|
|
889
|
+
stream.abort();
|
|
895
890
|
});
|
|
896
891
|
}, 3e4);
|
|
897
|
-
|
|
898
|
-
|
|
892
|
+
this.#streamMapping.set(resolvedStreamId, {
|
|
893
|
+
ctx: { header: ctx.header },
|
|
894
|
+
stream,
|
|
895
|
+
cleanup: () => {
|
|
896
|
+
clearInterval(keepAlive), this.#streamMapping.delete(resolvedStreamId);
|
|
897
|
+
}
|
|
898
|
+
}), await new Promise((resolve$4) => {
|
|
899
|
+
stream.onAbort(() => {
|
|
900
|
+
this.#streamMapping.get(resolvedStreamId)?.cleanup(), resolve$4();
|
|
901
|
+
});
|
|
899
902
|
});
|
|
900
903
|
});
|
|
901
904
|
} catch (error) {
|
|
@@ -967,23 +970,35 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
967
970
|
if (!this.#enableJsonResponse && this.sessionId !== void 0) ctx.header("mcp-session-id", this.sessionId);
|
|
968
971
|
if (this.#enableJsonResponse) {
|
|
969
972
|
const result = await new Promise((resolve$4) => {
|
|
970
|
-
for (const message of messages) if (isJSONRPCRequest(message)) this.#streamMapping.set(streamId, {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
973
|
+
for (const message of messages) if (isJSONRPCRequest(message)) this.#streamMapping.set(streamId, {
|
|
974
|
+
ctx: {
|
|
975
|
+
header: ctx.header,
|
|
976
|
+
json: (data) => {
|
|
977
|
+
resolve$4(ctx.json(data));
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
cleanup: () => {
|
|
981
|
+
this.#streamMapping.delete(streamId);
|
|
982
|
+
}
|
|
983
|
+
}), this.#requestToStreamMapping.set(message.id, streamId);
|
|
974
984
|
for (const message of messages) this.onmessage?.(message, { authInfo });
|
|
975
985
|
});
|
|
976
|
-
return
|
|
986
|
+
return result;
|
|
977
987
|
}
|
|
978
988
|
return streamSSE(ctx, async (stream) => {
|
|
979
989
|
for (const message of messages) if (isJSONRPCRequest(message)) this.#streamMapping.set(streamId, {
|
|
980
|
-
ctx,
|
|
981
|
-
stream
|
|
990
|
+
ctx: { header: ctx.header },
|
|
991
|
+
stream,
|
|
992
|
+
cleanup: () => {
|
|
993
|
+
this.#streamMapping.delete(streamId);
|
|
994
|
+
}
|
|
982
995
|
}), this.#requestToStreamMapping.set(message.id, streamId);
|
|
983
|
-
stream.onAbort(() => {
|
|
984
|
-
this.#streamMapping.delete(streamId);
|
|
985
|
-
});
|
|
986
996
|
for (const message of messages) this.onmessage?.(message, { authInfo });
|
|
997
|
+
await new Promise((resolve$4) => {
|
|
998
|
+
stream.onAbort(() => {
|
|
999
|
+
this.#streamMapping.get(streamId)?.cleanup(), resolve$4();
|
|
1000
|
+
});
|
|
1001
|
+
});
|
|
987
1002
|
});
|
|
988
1003
|
}
|
|
989
1004
|
} catch (error) {
|
|
@@ -1052,7 +1067,7 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
1052
1067
|
return true;
|
|
1053
1068
|
}
|
|
1054
1069
|
async close() {
|
|
1055
|
-
for (const { stream } of this.#streamMapping.values()) stream?.
|
|
1070
|
+
for (const { stream } of this.#streamMapping.values()) stream?.abort();
|
|
1056
1071
|
this.#streamMapping.clear(), this.#requestResponseMap.clear(), this.onclose?.();
|
|
1057
1072
|
}
|
|
1058
1073
|
async send(message, options) {
|
|
@@ -1089,9 +1104,9 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
1089
1104
|
if (this.#enableJsonResponse) {
|
|
1090
1105
|
if (this.sessionId !== void 0) response.ctx.header("mcp-session-id", this.sessionId);
|
|
1091
1106
|
const responses = relatedIds.map((id) => this.#requestResponseMap.get(id));
|
|
1092
|
-
response.ctx.json(responses.length === 1 ? responses[0] : responses);
|
|
1107
|
+
response.ctx.json?.(responses.length === 1 ? responses[0] : responses);
|
|
1093
1108
|
return;
|
|
1094
|
-
} else response.stream?.
|
|
1109
|
+
} else response.stream?.abort();
|
|
1095
1110
|
for (const id of relatedIds) this.#requestResponseMap.delete(id), this.#requestToStreamMapping.delete(id);
|
|
1096
1111
|
}
|
|
1097
1112
|
}
|
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-COuXYEih.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
3
|
import "./_types-DIdtMJ6V.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-DV25VhPk.js";
|
|
6
|
+
import "./logger-Df86rWXR.js";
|
|
7
|
+
import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-CEW0jW3t.js";
|
|
8
8
|
export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { modelPricingSchema } from "./_types-DIdtMJ6V.js";
|
|
2
|
-
import { logger } from "./logger-
|
|
2
|
+
import { logger } from "./logger-Df86rWXR.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import F, { homedir } from "node:os";
|
package/dist/pricing-fetcher.js
CHANGED