ccem 2.82.0 → 2.84.0

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 (2) hide show
  1. package/dist/index.js +16 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -830,7 +830,7 @@ var __filename = fileURLToPath(import.meta.url);
830
830
  var __dirname = path2.dirname(__filename);
831
831
  var CLAUDE_PROJECTS_DIR = path2.join(os2.homedir(), ".claude", "projects");
832
832
  var CCEM_DIR = path2.join(os2.homedir(), ".ccem");
833
- var CACHE_VERSION = 1;
833
+ var CACHE_VERSION = 2;
834
834
  var getCachePath = () => path2.join(CCEM_DIR, "usage-cache.json");
835
835
  var getPricesPath = () => path2.join(CCEM_DIR, "model-prices.json");
836
836
  async function ensureCcemDir2() {
@@ -1028,6 +1028,7 @@ async function saveCacheAsync(cache) {
1028
1028
  }
1029
1029
  async function parseJSONLFileAsync(filePath, prices, signal) {
1030
1030
  const entries = [];
1031
+ const messageEntryIndexes = /* @__PURE__ */ new Map();
1031
1032
  try {
1032
1033
  const fileStream = fs2.createReadStream(filePath, { encoding: "utf-8" });
1033
1034
  const rl = readline.createInterface({
@@ -1061,11 +1062,23 @@ async function parseJSONLFileAsync(filePath, prices, signal) {
1061
1062
  };
1062
1063
  const price = getModelPrice(model, prices);
1063
1064
  const cost = calculateCost(usage, price);
1064
- entries.push({
1065
+ const statsEntry = {
1065
1066
  timestamp: entry.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
1066
1067
  model,
1067
1068
  usage: { ...usage, cost }
1068
- });
1069
+ };
1070
+ const messageId = entry.message.id;
1071
+ if (typeof messageId === "string" && messageId.length > 0) {
1072
+ const index = messageEntryIndexes.get(messageId);
1073
+ if (index !== void 0) {
1074
+ entries[index] = statsEntry;
1075
+ } else {
1076
+ messageEntryIndexes.set(messageId, entries.length);
1077
+ entries.push(statsEntry);
1078
+ }
1079
+ } else {
1080
+ entries.push(statsEntry);
1081
+ }
1069
1082
  } catch {
1070
1083
  }
1071
1084
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccem",
3
- "version": "2.82.0",
3
+ "version": "2.84.0",
4
4
  "type": "module",
5
5
  "description": "Claude Code Environment Manager",
6
6
  "repository": {