@yhong91/vibetime 0.1.5 → 0.1.7

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 +62 -4
  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.5" : "0.1.1";
1198
+ var PACKAGE_VERSION = true ? "0.1.7" : "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;
@@ -1773,14 +1773,29 @@ async function parseAgySessionFile(filePath, options) {
1773
1773
  }
1774
1774
  }
1775
1775
  const usageMap = /* @__PURE__ */ new Map();
1776
+ const usageEntries = [];
1776
1777
  if (generatorMetadata) {
1777
1778
  for (const item of generatorMetadata) {
1779
+ const usage = item.chatModel?.usage;
1780
+ if (usage) {
1781
+ usageEntries.push(usage);
1782
+ }
1778
1783
  if (item.stepIndices && Array.isArray(item.stepIndices)) {
1779
1784
  for (const idx of item.stepIndices) {
1780
- usageMap.set(idx, item.chatModel?.usage);
1785
+ usageMap.set(idx, usage);
1781
1786
  }
1782
1787
  }
1783
1788
  }
1789
+ const plannerResponses = rawEvents.filter((raw) => raw.type === "PLANNER_RESPONSE");
1790
+ const exactMatches = plannerResponses.filter((raw) => usageMap.has(raw.step_index)).length;
1791
+ if (exactMatches === 0 && plannerResponses.length > 0 && usageEntries.length > 0) {
1792
+ const matchCount = Math.min(plannerResponses.length, usageEntries.length);
1793
+ const plannerOffset = plannerResponses.length - matchCount;
1794
+ const usageOffset = usageEntries.length - matchCount;
1795
+ for (let i = 0; i < matchCount; i += 1) {
1796
+ usageMap.set(plannerResponses[plannerOffset + i].step_index, usageEntries[usageOffset + i]);
1797
+ }
1798
+ }
1784
1799
  }
1785
1800
  const cwd = detectedCwd;
1786
1801
  const project = detectedProject;
@@ -6996,7 +7011,7 @@ function createWorkbuddyAdapter() {
6996
7011
 
6997
7012
  // src/adapters/zcode.ts
6998
7013
  import { execFile } from "node:child_process";
6999
- import { stat as stat8 } from "node:fs/promises";
7014
+ import { readFile as readFile11, stat as stat8 } from "node:fs/promises";
7000
7015
  import path15 from "node:path";
7001
7016
  import { promisify as promisify2 } from "node:util";
7002
7017
  init_fs();
@@ -7011,6 +7026,34 @@ function zcodeCliDir(home, env) {
7011
7026
  function zcodeDbPath(home, env) {
7012
7027
  return path15.join(zcodeCliDir(home, env), "db", "db.sqlite");
7013
7028
  }
7029
+ var providerNameCache = null;
7030
+ async function loadProviderNames(configPath2) {
7031
+ let fileMtime = 0;
7032
+ try {
7033
+ const info = await stat8(configPath2);
7034
+ fileMtime = info.mtimeMs;
7035
+ } catch {
7036
+ return /* @__PURE__ */ new Map();
7037
+ }
7038
+ if (providerNameCache && providerNameCache.path === configPath2 && providerNameCache.mtimeMs === fileMtime) {
7039
+ return providerNameCache.map;
7040
+ }
7041
+ const map = /* @__PURE__ */ new Map();
7042
+ try {
7043
+ const raw = await readFile11(configPath2, "utf-8");
7044
+ const config = JSON.parse(raw);
7045
+ const providers = config?.provider;
7046
+ if (isPlainObject(providers)) {
7047
+ for (const [id, entry] of Object.entries(providers)) {
7048
+ const name = stringField(entry, "name");
7049
+ if (name) map.set(id, name);
7050
+ }
7051
+ }
7052
+ } catch {
7053
+ }
7054
+ providerNameCache = { path: configPath2, mtimeMs: fileMtime, map };
7055
+ return map;
7056
+ }
7014
7057
  function sourceHash2(filePath) {
7015
7058
  return `sha256:${createStableHash(filePath)}`;
7016
7059
  }
@@ -7171,6 +7214,21 @@ async function parseZCodeDb(filePath, options) {
7171
7214
  if (rows.length === 0) {
7172
7215
  return [];
7173
7216
  }
7217
+ let candidate = path15.resolve(filePath);
7218
+ let configPath2 = "";
7219
+ for (let i = 0; i < 12; i++) {
7220
+ const probe = path15.join(candidate, ".zcode", "v2", "config.json");
7221
+ try {
7222
+ await stat8(probe);
7223
+ configPath2 = probe;
7224
+ break;
7225
+ } catch {
7226
+ const parent = path15.dirname(candidate);
7227
+ if (parent === candidate) break;
7228
+ candidate = parent;
7229
+ }
7230
+ }
7231
+ const nameMap = configPath2 ? await loadProviderNames(configPath2) : /* @__PURE__ */ new Map();
7174
7232
  const sessions = /* @__PURE__ */ new Map();
7175
7233
  for (const row of rows) {
7176
7234
  if (row.kind === "session") {
@@ -7298,7 +7356,7 @@ async function parseZCodeDb(filePath, options) {
7298
7356
  sessionId: ctx.sessionId,
7299
7357
  turnId: stringField(row, "turn_id") ? `zcode:${stringField(row, "turn_id")}` : void 0,
7300
7358
  agent: stringField(row, "agent") || "zcode",
7301
- provider: stringField(row, "provider_id"),
7359
+ provider: nameMap.get(stringField(row, "provider_id") || "") || stringField(row, "provider_id"),
7302
7360
  model: modelId,
7303
7361
  success: stringField(row, "status") === "completed",
7304
7362
  metrics: modelMetrics(row),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
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": {