@yhong91/vibetime 0.1.42 → 0.1.43

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 +43 -5
  2. package/package.json +1 -1
package/bin/vibetime.mjs CHANGED
@@ -1928,7 +1928,7 @@ function countTextLines(text) {
1928
1928
  }
1929
1929
 
1930
1930
  // src/lib/constants.ts
1931
- var PACKAGE_VERSION = true ? "0.1.42" : "0.1.1";
1931
+ var PACKAGE_VERSION = true ? "0.1.43" : "0.1.1";
1932
1932
  var DEFAULT_API_URL = "http://121.196.224.82:3001";
1933
1933
  var DEFAULT_BACKFILL_BATCH_SIZE = 50;
1934
1934
  var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
@@ -5815,6 +5815,18 @@ async function parseCopilotSessionFile(filePath, options) {
5815
5815
  }
5816
5816
  const msgTurnId = stringField(data, "turnId");
5817
5817
  const turnId = msgTurnId !== void 0 ? `turn_${createStableHash([sessionId, msgTurnId]).slice(0, 24)}` : currentTurnId;
5818
+ events.push(baseCopilotEvent({
5819
+ ts,
5820
+ type: "agent.operation",
5821
+ operation: "model call",
5822
+ sessionId,
5823
+ turnId,
5824
+ cwd,
5825
+ project,
5826
+ model,
5827
+ confidence: "exact",
5828
+ metrics: { modelCalls: 1 }
5829
+ }));
5818
5830
  const outputTokens = numberField(data, "outputTokens");
5819
5831
  if (outputTokens && outputTokens > 0) {
5820
5832
  const key = turnId || "unknown";
@@ -10751,6 +10763,8 @@ function buildSessionRollup(rollupKey, events) {
10751
10763
  const toolRollups = /* @__PURE__ */ new Map();
10752
10764
  const fileRollups = /* @__PURE__ */ new Map();
10753
10765
  const turnRollups = /* @__PURE__ */ new Map();
10766
+ const turnTimings = /* @__PURE__ */ new Map();
10767
+ let activeTurnId;
10754
10768
  let promptCount = 0;
10755
10769
  let turnCount = 0;
10756
10770
  let toolCallCount = 0;
@@ -10766,6 +10780,22 @@ function buildSessionRollup(rollupKey, events) {
10766
10780
  let linesAdded = 0;
10767
10781
  let linesRemoved = 0;
10768
10782
  for (const event of ordered) {
10783
+ if (event.type === "turn.started" && event.turnId) {
10784
+ activeTurnId = event.turnId;
10785
+ const timing = turnTimings.get(event.turnId) || {};
10786
+ timing.taskStartedAt ??= event.ts;
10787
+ turnTimings.set(event.turnId, timing);
10788
+ }
10789
+ if (event.type === "model.usage" || (event.metrics?.modelCalls || 0) > 0) {
10790
+ const turnId = event.turnId || activeTurnId;
10791
+ if (turnId) {
10792
+ const timing = turnTimings.get(turnId) || {};
10793
+ if (!timing.lastCallAt || event.ts > timing.lastCallAt) {
10794
+ timing.lastCallAt = event.ts;
10795
+ }
10796
+ turnTimings.set(turnId, timing);
10797
+ }
10798
+ }
10769
10799
  const eventInputTokens = Math.max(0, event.metrics?.tokensInput || 0);
10770
10800
  const eventCachedInputTokens = Math.max(0, event.metrics?.tokensCachedInput || 0);
10771
10801
  const eventCacheCreationInputTokens = Math.max(0, event.metrics?.tokensCacheCreationInput || 0);
@@ -10969,6 +10999,9 @@ function buildSessionRollup(rollupKey, events) {
10969
10999
  fileRollups.set(pathHash, fileRollup);
10970
11000
  }
10971
11001
  timeBuckets.set(bucketTs, bucket);
11002
+ if (event.type === "turn.completed" && event.turnId === activeTurnId) {
11003
+ activeTurnId = void 0;
11004
+ }
10972
11005
  }
10973
11006
  const baseRollup = {
10974
11007
  rollupKey,
@@ -10999,10 +11032,15 @@ function buildSessionRollup(rollupKey, events) {
10999
11032
  modelRollups: [...modelRollups.values()].sort((a, b) => b.callCount - a.callCount || a.model.localeCompare(b.model)),
11000
11033
  toolRollups: [...toolRollups.values()].sort((a, b) => b.callCount - a.callCount || a.tool.localeCompare(b.tool)),
11001
11034
  fileRollups: [...fileRollups.values()].sort((a, b) => b.writes - a.writes || b.reads - a.reads || a.displayPath.localeCompare(b.displayPath)),
11002
- turnRollups: [...turnRollups.values()].map((rollup) => ({
11003
- ...rollup,
11004
- durationMs: Math.max(0, Date.parse(rollup.lastEventAt) - Date.parse(rollup.startedAt))
11005
- })).sort((a, b) => a.startedAt.localeCompare(b.startedAt))
11035
+ turnRollups: [...turnRollups.values()].map((rollup) => {
11036
+ const timing = turnTimings.get(rollup.turnId);
11037
+ const startedAt2 = timing?.taskStartedAt || rollup.startedAt;
11038
+ return {
11039
+ ...rollup,
11040
+ startedAt: startedAt2,
11041
+ durationMs: timing?.lastCallAt ? Math.max(0, Date.parse(timing.lastCallAt) - Date.parse(startedAt2)) : 0
11042
+ };
11043
+ }).sort((a, b) => a.startedAt.localeCompare(b.startedAt))
11006
11044
  };
11007
11045
  return {
11008
11046
  ...baseRollup,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.42",
4
+ "version": "0.1.43",
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": {