@yhong91/vibetime 0.1.18 → 0.1.19

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 +30 -3
  2. package/package.json +1 -1
package/bin/vibetime.mjs CHANGED
@@ -1202,7 +1202,7 @@ function countTextLines(text) {
1202
1202
  }
1203
1203
 
1204
1204
  // src/lib/constants.ts
1205
- var PACKAGE_VERSION = true ? "0.1.18" : "0.1.1";
1205
+ var PACKAGE_VERSION = true ? "0.1.19" : "0.1.1";
1206
1206
  var DEFAULT_API_URL = "http://121.196.224.82:3001";
1207
1207
  var DEFAULT_BACKFILL_BATCH_SIZE = 50;
1208
1208
  var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
@@ -3431,8 +3431,9 @@ async function parseCodebuddyTraceFile(filePath, options) {
3431
3431
  }
3432
3432
  const trace = traceFile.trace;
3433
3433
  const spans = Array.isArray(traceFile.spans) ? traceFile.spans : [];
3434
+ const hasGenerationSpans = spans.some((s) => s.type === "generation");
3434
3435
  const hasFunctionSpans = spans.some((s) => s.type === "function");
3435
- const isTrivial = !trace.sessionId && !trace.modelInfo && spans.length <= 3 && !hasFunctionSpans;
3436
+ const isTrivial = !hasGenerationSpans && !hasFunctionSpans;
3436
3437
  if (isTrivial) {
3437
3438
  return [];
3438
3439
  }
@@ -3608,7 +3609,7 @@ async function parseCodebuddyTraceFile(filePath, options) {
3608
3609
  }
3609
3610
  if (span.type === "generation") {
3610
3611
  generationCount++;
3611
- const usage = modelUsageFromTrace(trace, generationCount, totalGenerations);
3612
+ const usage = extractUsageFromGenerationSpan(span) ?? modelUsageFromTrace(trace, generationCount, totalGenerations);
3612
3613
  push(baseEvent({
3613
3614
  ts,
3614
3615
  type: "model.usage",
@@ -3787,6 +3788,32 @@ function normalizeModelCandidate(value) {
3787
3788
  }
3788
3789
  return trimmed;
3789
3790
  }
3791
+ function extractUsageFromGenerationSpan(span) {
3792
+ const parsed = parseEmbeddedJson(span.toolOutput);
3793
+ if (!Array.isArray(parsed) || parsed.length === 0) {
3794
+ return void 0;
3795
+ }
3796
+ const first = parsed[0];
3797
+ if (!isPlainObject(first)) {
3798
+ return void 0;
3799
+ }
3800
+ const usage = objectField(first, "usage");
3801
+ if (!isPlainObject(usage)) {
3802
+ return void 0;
3803
+ }
3804
+ const inputTokens = numberField(usage, "prompt_tokens");
3805
+ const outputTokens = numberField(usage, "completion_tokens");
3806
+ const totalTokens = numberField(usage, "total_tokens");
3807
+ const details = objectField(usage, "prompt_tokens_details");
3808
+ const cachedTokens = isPlainObject(details) ? numberField(details, "cached_tokens") : void 0;
3809
+ return {
3810
+ tokensInput: inputTokens || void 0,
3811
+ tokensCachedInput: cachedTokens || void 0,
3812
+ tokensOutput: outputTokens || void 0,
3813
+ tokensTotal: totalTokens || void 0,
3814
+ modelCalls: 1
3815
+ };
3816
+ }
3790
3817
  function modelUsageFromTrace(trace, generationIndex, totalGenerations) {
3791
3818
  const info = trace.modelInfo;
3792
3819
  if (!info || !info.totalInputTokens && !info.totalOutputTokens && !trace.totalTokens) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
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": {