@yhong91/vibetime 0.1.8 → 0.1.9

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/bin/vibetime.mjs +31 -1
  2. package/package.json +1 -1
package/bin/vibetime.mjs CHANGED
@@ -1195,7 +1195,7 @@ function countTextLines(text) {
1195
1195
  }
1196
1196
 
1197
1197
  // src/lib/constants.ts
1198
- var PACKAGE_VERSION = true ? "0.1.8" : "0.1.1";
1198
+ var PACKAGE_VERSION = true ? "0.1.9" : "0.1.1";
1199
1199
  var DEFAULT_API_URL = "http://121.196.224.82:3001";
1200
1200
  var DEFAULT_BACKFILL_BATCH_SIZE = 50;
1201
1201
  var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
@@ -1795,6 +1795,7 @@ async function parseAgySessionFile(filePath, options) {
1795
1795
  }
1796
1796
  const usageMap = /* @__PURE__ */ new Map();
1797
1797
  const usageEntries = [];
1798
+ const matchedUsageEntries = /* @__PURE__ */ new Set();
1798
1799
  if (generatorMetadata) {
1799
1800
  for (const item of generatorMetadata) {
1800
1801
  const metadata = usageMetadataFromGenerator(item);
@@ -1814,6 +1815,7 @@ async function parseAgySessionFile(filePath, options) {
1814
1815
  const exact = usageMap.get(planner.step_index);
1815
1816
  if (exact) {
1816
1817
  used.add(exact);
1818
+ matchedUsageEntries.add(exact);
1817
1819
  continue;
1818
1820
  }
1819
1821
  const plannerAt = Date.parse(planner.created_at ?? planner.timestamp ?? "");
@@ -1835,6 +1837,7 @@ async function parseAgySessionFile(filePath, options) {
1835
1837
  if (closest && closestDelta <= AGY_USAGE_TIME_MATCH_TOLERANCE_MS) {
1836
1838
  usageMap.set(planner.step_index, closest);
1837
1839
  used.add(closest);
1840
+ matchedUsageEntries.add(closest);
1838
1841
  }
1839
1842
  }
1840
1843
  }
@@ -1894,6 +1897,7 @@ async function parseAgySessionFile(filePath, options) {
1894
1897
  const content = stringField(raw, "content") || "";
1895
1898
  const usageMetadata = usageMap.get(raw.step_index);
1896
1899
  if (usageMetadata) {
1900
+ matchedUsageEntries.add(usageMetadata);
1897
1901
  const usage = usageMetadata.usage;
1898
1902
  const inputTokens = Number.parseInt(usage.inputTokens, 10) || 0;
1899
1903
  const outputTokens = Number.parseInt(usage.outputTokens, 10) || 0;
@@ -2054,6 +2058,32 @@ async function parseAgySessionFile(filePath, options) {
2054
2058
  }
2055
2059
  }
2056
2060
  }
2061
+ for (const [index, usageMetadata] of usageEntries.entries()) {
2062
+ if (matchedUsageEntries.has(usageMetadata) || usageMetadata.occurredAt === null) {
2063
+ continue;
2064
+ }
2065
+ const usage = usageMetadata.usage;
2066
+ const inputTokens = Number.parseInt(usage.inputTokens, 10) || 0;
2067
+ const outputTokens = Number.parseInt(usage.outputTokens, 10) || 0;
2068
+ const cacheRead = Number.parseInt(usage.cacheReadTokens, 10) || 0;
2069
+ const reasoning = Number.parseInt(usage.thinkingOutputTokens, 10) || 0;
2070
+ state.push(baseAgyEvent({
2071
+ ts: new Date(usageMetadata.occurredAt).toISOString(),
2072
+ type: "model.usage",
2073
+ sessionId,
2074
+ model: usageMetadata.model ?? "unknown",
2075
+ confidence: "exact",
2076
+ metrics: {
2077
+ modelCalls: 1,
2078
+ tokensInput: inputTokens + cacheRead,
2079
+ tokensOutput: outputTokens,
2080
+ tokensTotal: inputTokens + cacheRead + outputTokens,
2081
+ tokensCachedInput: cacheRead || void 0,
2082
+ tokensCacheReadInput: cacheRead || void 0,
2083
+ tokensReasoningOutput: reasoning || void 0
2084
+ }
2085
+ }), rawEvents.length + index + 1, "trajectory_metadata");
2086
+ }
2057
2087
  if (state.currentTurnLastEventAt) {
2058
2088
  state.closeTurn(state.currentTurnLastEventAt, rawEvents.length, "session_end");
2059
2089
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.8",
4
+ "version": "0.1.9",
5
5
  "description": "vibetime CLI — install AI-agent hooks (Claude Code, Codex, OpenCode, Pi) and report activity to vibetime.",
6
6
  "license": "MIT",
7
7
  "publishConfig": {