@yhong91/vibetime 0.1.19 → 0.1.21

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 +40 -29
  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.19" : "0.1.1";
1205
+ var PACKAGE_VERSION = true ? "0.1.21" : "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;
@@ -3610,6 +3610,9 @@ async function parseCodebuddyTraceFile(filePath, options) {
3610
3610
  if (span.type === "generation") {
3611
3611
  generationCount++;
3612
3612
  const usage = extractUsageFromGenerationSpan(span) ?? modelUsageFromTrace(trace, generationCount, totalGenerations);
3613
+ if (!usage && !model) {
3614
+ continue;
3615
+ }
3613
3616
  push(baseEvent({
3614
3617
  ts,
3615
3618
  type: "model.usage",
@@ -4708,6 +4711,8 @@ async function parseCopilotSessionFile(filePath, options) {
4708
4711
  let reasoningEffort;
4709
4712
  const pendingTools = /* @__PURE__ */ new Map();
4710
4713
  const turnTokenAccum = /* @__PURE__ */ new Map();
4714
+ const pendingTurnUsage = [];
4715
+ let emittedShutdownUsage = false;
4711
4716
  for (const [index, line] of lines.entries()) {
4712
4717
  const lineNumber = index + 1;
4713
4718
  const raw = parseJsonLine(line);
@@ -4872,7 +4877,7 @@ async function parseCopilotSessionFile(filePath, options) {
4872
4877
  const accum = turnId ? turnTokenAccum.get(turnId) : void 0;
4873
4878
  if (accum && accum.tokensOutput && accum.tokensOutput > 0) {
4874
4879
  accum.reasoningEffort = reasoningEffort;
4875
- events.push(baseCopilotEvent({
4880
+ pendingTurnUsage.push(baseCopilotEvent({
4876
4881
  ts,
4877
4882
  type: "model.usage",
4878
4883
  sessionId,
@@ -4936,6 +4941,7 @@ async function parseCopilotSessionFile(filePath, options) {
4936
4941
  modelCalls: requestCount || void 0
4937
4942
  }
4938
4943
  }));
4944
+ emittedShutdownUsage = true;
4939
4945
  }
4940
4946
  events.push(baseCopilotEvent({
4941
4947
  ts,
@@ -4950,6 +4956,9 @@ async function parseCopilotSessionFile(filePath, options) {
4950
4956
  }
4951
4957
  }
4952
4958
  }
4959
+ if (!emittedShutdownUsage) {
4960
+ events.push(...pendingTurnUsage);
4961
+ }
4953
4962
  return events.filter((event) => validateCanonicalEvent(event).valid);
4954
4963
  }
4955
4964
  function baseCopilotEvent(event) {
@@ -5176,33 +5185,7 @@ async function parseOpenCodeSessionFile(dbPath, options) {
5176
5185
  const createdTs = timeCreated;
5177
5186
  const tokens = opencodeUsageFromInfo(info);
5178
5187
  const cost = typeof info.cost === "number" && info.cost > 0 ? info.cost : void 0;
5179
- if (tokens) {
5180
- const metrics = {
5181
- tokensInput: tokens.tokensInput,
5182
- tokensOutput: tokens.tokensOutput,
5183
- tokensReasoningOutput: tokens.tokensReasoningOutput,
5184
- tokensCachedInput: tokens.tokensCachedInput,
5185
- tokensCacheReadInput: tokens.tokensCacheReadInput,
5186
- tokensCacheCreationInput: tokens.tokensCacheCreationInput,
5187
- tokensTotal: tokens.tokensTotal,
5188
- reasoningEffort
5189
- };
5190
- if (cost !== void 0) {
5191
- metrics.costUsd = cost;
5192
- }
5193
- events.push(baseOpenCodeEvent({
5194
- ts: msToIso(completedTs || createdTs),
5195
- type: "model.usage",
5196
- sessionId,
5197
- turnId: currentTurnId,
5198
- cwd: assistantCwd,
5199
- project: assistantProject,
5200
- model,
5201
- provider,
5202
- operation: "model usage",
5203
- metrics
5204
- }, assistantAgent));
5205
- }
5188
+ let emittedStepUsage = false;
5206
5189
  try {
5207
5190
  const parts = db.prepare(
5208
5191
  "SELECT data FROM part WHERE message_id = ? ORDER BY id"
@@ -5303,6 +5286,7 @@ async function parseOpenCodeSessionFile(dbPath, options) {
5303
5286
  const stepTokens = opencodeUsageFromInfo(pd);
5304
5287
  const stepCost = typeof pd.cost === "number" && pd.cost > 0 ? pd.cost : void 0;
5305
5288
  if (stepTokens) {
5289
+ emittedStepUsage = true;
5306
5290
  const stepMetrics = {
5307
5291
  tokensInput: stepTokens.tokensInput,
5308
5292
  tokensOutput: stepTokens.tokensOutput,
@@ -5347,6 +5331,33 @@ async function parseOpenCodeSessionFile(dbPath, options) {
5347
5331
  }
5348
5332
  } catch {
5349
5333
  }
5334
+ if (!emittedStepUsage && tokens) {
5335
+ const metrics = {
5336
+ tokensInput: tokens.tokensInput,
5337
+ tokensOutput: tokens.tokensOutput,
5338
+ tokensReasoningOutput: tokens.tokensReasoningOutput,
5339
+ tokensCachedInput: tokens.tokensCachedInput,
5340
+ tokensCacheReadInput: tokens.tokensCacheReadInput,
5341
+ tokensCacheCreationInput: tokens.tokensCacheCreationInput,
5342
+ tokensTotal: tokens.tokensTotal,
5343
+ reasoningEffort
5344
+ };
5345
+ if (cost !== void 0) {
5346
+ metrics.costUsd = cost;
5347
+ }
5348
+ events.push(baseOpenCodeEvent({
5349
+ ts: msToIso(completedTs || createdTs),
5350
+ type: "model.usage",
5351
+ sessionId,
5352
+ turnId: currentTurnId,
5353
+ cwd: assistantCwd,
5354
+ project: assistantProject,
5355
+ model,
5356
+ provider,
5357
+ operation: "model usage",
5358
+ metrics
5359
+ }, assistantAgent));
5360
+ }
5350
5361
  if (stringField(info, "finish")) {
5351
5362
  const durationMs = completedTs && createdTs ? completedTs - createdTs : void 0;
5352
5363
  events.push(baseOpenCodeEvent({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.19",
4
+ "version": "0.1.21",
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": {