@yhong91/vibetime 0.1.37 → 0.1.39
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.
- package/bin/vibetime.mjs +71 -5
- 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.
|
|
1931
|
+
var PACKAGE_VERSION = true ? "0.1.39" : "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;
|
|
@@ -4209,7 +4209,7 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
4209
4209
|
return [];
|
|
4210
4210
|
}
|
|
4211
4211
|
const sessionMeta = await readCodebuddySessionMeta(trace.workerPid, trace.sessionId, options);
|
|
4212
|
-
const sessionId = trace.sessionId || sessionMeta.sessionId || sessionIdFromTracePath(filePath);
|
|
4212
|
+
const sessionId = trace.sessionId || sessionMeta.sessionId || await resolveSessionIdFromSiblingTraces(filePath) || sessionIdFromTracePath(filePath);
|
|
4213
4213
|
let cwd = sessionMeta.cwd;
|
|
4214
4214
|
if (!cwd && trace.startedAt) {
|
|
4215
4215
|
cwd = await cwdFromHistoryFile(trace.startedAt, options);
|
|
@@ -4586,6 +4586,7 @@ function extractUsageFromGenerationSpan(span) {
|
|
|
4586
4586
|
return {
|
|
4587
4587
|
tokensInput: inputTokens || void 0,
|
|
4588
4588
|
tokensCachedInput: cachedTokens || void 0,
|
|
4589
|
+
tokensCacheReadInput: cachedTokens || void 0,
|
|
4589
4590
|
tokensOutput: outputTokens || void 0,
|
|
4590
4591
|
tokensTotal: totalTokens || void 0,
|
|
4591
4592
|
modelCalls: 1
|
|
@@ -4604,6 +4605,7 @@ function modelUsageFromTrace(trace, generationIndex, totalGenerations) {
|
|
|
4604
4605
|
return {
|
|
4605
4606
|
tokensInput: inputTokens || void 0,
|
|
4606
4607
|
tokensCachedInput: cachedTokens || void 0,
|
|
4608
|
+
tokensCacheReadInput: cachedTokens || void 0,
|
|
4607
4609
|
tokensOutput: outputTokens || void 0,
|
|
4608
4610
|
tokensTotal: totalTokens || void 0,
|
|
4609
4611
|
modelCalls: totalGenerations || 1
|
|
@@ -4615,6 +4617,42 @@ function sessionIdFromTracePath(filePath) {
|
|
|
4615
4617
|
const match = path9.basename(filePath).match(/trace_([0-9a-f]{32})/);
|
|
4616
4618
|
return match?.[1] ? `codebuddy_${match[1]}` : `codebuddy_${createStableHash(filePath).slice(0, 24)}`;
|
|
4617
4619
|
}
|
|
4620
|
+
var siblingSessionIdByDir = /* @__PURE__ */ new Map();
|
|
4621
|
+
async function resolveSessionIdFromSiblingTraces(filePath) {
|
|
4622
|
+
const dir = path9.dirname(filePath);
|
|
4623
|
+
let cached = siblingSessionIdByDir.get(dir);
|
|
4624
|
+
if (!cached) {
|
|
4625
|
+
cached = (async () => {
|
|
4626
|
+
try {
|
|
4627
|
+
const entries = await readdir4(dir);
|
|
4628
|
+
for (const entry of entries) {
|
|
4629
|
+
if (!entry.startsWith("trace_") || !entry.endsWith(".json")) {
|
|
4630
|
+
continue;
|
|
4631
|
+
}
|
|
4632
|
+
const siblingPath = path9.join(dir, entry);
|
|
4633
|
+
if (siblingPath === filePath) {
|
|
4634
|
+
continue;
|
|
4635
|
+
}
|
|
4636
|
+
try {
|
|
4637
|
+
const text = await readFile5(siblingPath, "utf8");
|
|
4638
|
+
const data = JSON.parse(text);
|
|
4639
|
+
if (isPlainObject(data) && isPlainObject(data.trace)) {
|
|
4640
|
+
const sid = stringField(data.trace, "sessionId");
|
|
4641
|
+
if (sid) {
|
|
4642
|
+
return sid;
|
|
4643
|
+
}
|
|
4644
|
+
}
|
|
4645
|
+
} catch {
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
} catch {
|
|
4649
|
+
}
|
|
4650
|
+
return void 0;
|
|
4651
|
+
})();
|
|
4652
|
+
siblingSessionIdByDir.set(dir, cached);
|
|
4653
|
+
}
|
|
4654
|
+
return cached;
|
|
4655
|
+
}
|
|
4618
4656
|
function resolveHome(options) {
|
|
4619
4657
|
return options.home ? path9.resolve(String(options.home)) : process.env.HOME || __require("node:os").homedir();
|
|
4620
4658
|
}
|
|
@@ -4786,7 +4824,7 @@ async function codebuddyBackfillFiles(sourceRoot, home, env) {
|
|
|
4786
4824
|
const filePath = path9.join(traceDir, entry);
|
|
4787
4825
|
try {
|
|
4788
4826
|
const stat14 = await import("node:fs/promises").then((fs) => fs.stat(filePath));
|
|
4789
|
-
files.push({ path: filePath, modifiedAt: stat14.mtime.toISOString() });
|
|
4827
|
+
files.push({ path: filePath, modifiedAt: stat14.mtime.toISOString(), groupId: pidDir.name });
|
|
4790
4828
|
} catch {
|
|
4791
4829
|
}
|
|
4792
4830
|
}
|
|
@@ -12097,10 +12135,37 @@ function selectBackfillFilesForImport(files, watermarkTs) {
|
|
|
12097
12135
|
if (Number.isNaN(watermarkMs)) {
|
|
12098
12136
|
return files;
|
|
12099
12137
|
}
|
|
12100
|
-
|
|
12138
|
+
const isPast = (f) => {
|
|
12101
12139
|
const modifiedMs = Date.parse(f.modifiedAt);
|
|
12102
12140
|
return !Number.isNaN(modifiedMs) && modifiedMs > watermarkMs;
|
|
12103
|
-
}
|
|
12141
|
+
};
|
|
12142
|
+
const groups = /* @__PURE__ */ new Map();
|
|
12143
|
+
const picked = [];
|
|
12144
|
+
for (const f of files) {
|
|
12145
|
+
if (!f.groupId) {
|
|
12146
|
+
if (isPast(f)) {
|
|
12147
|
+
picked.push(f);
|
|
12148
|
+
}
|
|
12149
|
+
continue;
|
|
12150
|
+
}
|
|
12151
|
+
const arr = groups.get(f.groupId);
|
|
12152
|
+
if (arr) {
|
|
12153
|
+
arr.push(f);
|
|
12154
|
+
} else {
|
|
12155
|
+
groups.set(f.groupId, [f]);
|
|
12156
|
+
}
|
|
12157
|
+
}
|
|
12158
|
+
for (const arr of groups.values()) {
|
|
12159
|
+
if (arr.some(isPast)) {
|
|
12160
|
+
picked.push(...arr);
|
|
12161
|
+
}
|
|
12162
|
+
}
|
|
12163
|
+
const order = /* @__PURE__ */ new Map();
|
|
12164
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
12165
|
+
order.set(files[i].path, i);
|
|
12166
|
+
}
|
|
12167
|
+
picked.sort((a, b) => (order.get(a.path) ?? 0) - (order.get(b.path) ?? 0));
|
|
12168
|
+
return picked;
|
|
12104
12169
|
}
|
|
12105
12170
|
function backfillIncrementalStatePath(home) {
|
|
12106
12171
|
return path24.join(home, ".vibetime", "backfill-state.json");
|
|
@@ -12530,6 +12595,7 @@ Environment:
|
|
|
12530
12595
|
}
|
|
12531
12596
|
export {
|
|
12532
12597
|
run,
|
|
12598
|
+
selectBackfillFilesForImport,
|
|
12533
12599
|
syncLocalRunnerEntryArgs
|
|
12534
12600
|
};
|
|
12535
12601
|
const code = await run(process.argv.slice(2));process.exitCode = code;
|
package/package.json
CHANGED