@yhong91/vibetime 0.1.36 → 0.1.38
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 +47 -17
- 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.38" : "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;
|
|
@@ -4208,8 +4208,9 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
4208
4208
|
if (isTrivial) {
|
|
4209
4209
|
return [];
|
|
4210
4210
|
}
|
|
4211
|
-
const
|
|
4212
|
-
|
|
4211
|
+
const sessionMeta = await readCodebuddySessionMeta(trace.workerPid, trace.sessionId, options);
|
|
4212
|
+
const sessionId = trace.sessionId || sessionMeta.sessionId || sessionIdFromTracePath(filePath);
|
|
4213
|
+
let cwd = sessionMeta.cwd;
|
|
4213
4214
|
if (!cwd && trace.startedAt) {
|
|
4214
4215
|
cwd = await cwdFromHistoryFile(trace.startedAt, options);
|
|
4215
4216
|
}
|
|
@@ -4627,20 +4628,21 @@ async function readCwdFromSession(sessionPath, matchSessionId) {
|
|
|
4627
4628
|
if (matchSessionId && session.sessionId !== matchSessionId) {
|
|
4628
4629
|
return void 0;
|
|
4629
4630
|
}
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4631
|
+
return {
|
|
4632
|
+
cwd: typeof session.cwd === "string" ? session.cwd : void 0,
|
|
4633
|
+
sessionId: typeof session.sessionId === "string" ? session.sessionId : void 0
|
|
4634
|
+
};
|
|
4633
4635
|
} catch {
|
|
4634
4636
|
}
|
|
4635
4637
|
return void 0;
|
|
4636
4638
|
}
|
|
4637
|
-
async function
|
|
4639
|
+
async function readCodebuddySessionMeta(pid, traceSessionId, options) {
|
|
4638
4640
|
const home = resolveHome(options);
|
|
4639
4641
|
const sessionsDir = path9.join(home, ".codebuddy", "sessions");
|
|
4640
4642
|
if (pid) {
|
|
4641
|
-
const
|
|
4642
|
-
if (
|
|
4643
|
-
return
|
|
4643
|
+
const meta = await readCwdFromSession(path9.join(sessionsDir, `${pid}.json`));
|
|
4644
|
+
if (meta) {
|
|
4645
|
+
return meta;
|
|
4644
4646
|
}
|
|
4645
4647
|
}
|
|
4646
4648
|
if (traceSessionId) {
|
|
@@ -4650,18 +4652,18 @@ async function cwdFromSessionFile(pid, traceSessionId, options) {
|
|
|
4650
4652
|
if (!f.endsWith(".json")) {
|
|
4651
4653
|
continue;
|
|
4652
4654
|
}
|
|
4653
|
-
const
|
|
4655
|
+
const meta = await readCwdFromSession(
|
|
4654
4656
|
path9.join(sessionsDir, f),
|
|
4655
4657
|
traceSessionId
|
|
4656
4658
|
);
|
|
4657
|
-
if (
|
|
4658
|
-
return
|
|
4659
|
+
if (meta) {
|
|
4660
|
+
return meta;
|
|
4659
4661
|
}
|
|
4660
4662
|
}
|
|
4661
4663
|
} catch {
|
|
4662
4664
|
}
|
|
4663
4665
|
}
|
|
4664
|
-
return
|
|
4666
|
+
return {};
|
|
4665
4667
|
}
|
|
4666
4668
|
async function cwdFromHistoryFile(traceStartedAt, options) {
|
|
4667
4669
|
const home = resolveHome(options);
|
|
@@ -4784,7 +4786,7 @@ async function codebuddyBackfillFiles(sourceRoot, home, env) {
|
|
|
4784
4786
|
const filePath = path9.join(traceDir, entry);
|
|
4785
4787
|
try {
|
|
4786
4788
|
const stat14 = await import("node:fs/promises").then((fs) => fs.stat(filePath));
|
|
4787
|
-
files.push({ path: filePath, modifiedAt: stat14.mtime.toISOString() });
|
|
4789
|
+
files.push({ path: filePath, modifiedAt: stat14.mtime.toISOString(), groupId: pidDir.name });
|
|
4788
4790
|
} catch {
|
|
4789
4791
|
}
|
|
4790
4792
|
}
|
|
@@ -12095,10 +12097,37 @@ function selectBackfillFilesForImport(files, watermarkTs) {
|
|
|
12095
12097
|
if (Number.isNaN(watermarkMs)) {
|
|
12096
12098
|
return files;
|
|
12097
12099
|
}
|
|
12098
|
-
|
|
12100
|
+
const isPast = (f) => {
|
|
12099
12101
|
const modifiedMs = Date.parse(f.modifiedAt);
|
|
12100
12102
|
return !Number.isNaN(modifiedMs) && modifiedMs > watermarkMs;
|
|
12101
|
-
}
|
|
12103
|
+
};
|
|
12104
|
+
const groups = /* @__PURE__ */ new Map();
|
|
12105
|
+
const picked = [];
|
|
12106
|
+
for (const f of files) {
|
|
12107
|
+
if (!f.groupId) {
|
|
12108
|
+
if (isPast(f)) {
|
|
12109
|
+
picked.push(f);
|
|
12110
|
+
}
|
|
12111
|
+
continue;
|
|
12112
|
+
}
|
|
12113
|
+
const arr = groups.get(f.groupId);
|
|
12114
|
+
if (arr) {
|
|
12115
|
+
arr.push(f);
|
|
12116
|
+
} else {
|
|
12117
|
+
groups.set(f.groupId, [f]);
|
|
12118
|
+
}
|
|
12119
|
+
}
|
|
12120
|
+
for (const arr of groups.values()) {
|
|
12121
|
+
if (arr.some(isPast)) {
|
|
12122
|
+
picked.push(...arr);
|
|
12123
|
+
}
|
|
12124
|
+
}
|
|
12125
|
+
const order = /* @__PURE__ */ new Map();
|
|
12126
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
12127
|
+
order.set(files[i].path, i);
|
|
12128
|
+
}
|
|
12129
|
+
picked.sort((a, b) => (order.get(a.path) ?? 0) - (order.get(b.path) ?? 0));
|
|
12130
|
+
return picked;
|
|
12102
12131
|
}
|
|
12103
12132
|
function backfillIncrementalStatePath(home) {
|
|
12104
12133
|
return path24.join(home, ".vibetime", "backfill-state.json");
|
|
@@ -12528,6 +12557,7 @@ Environment:
|
|
|
12528
12557
|
}
|
|
12529
12558
|
export {
|
|
12530
12559
|
run,
|
|
12560
|
+
selectBackfillFilesForImport,
|
|
12531
12561
|
syncLocalRunnerEntryArgs
|
|
12532
12562
|
};
|
|
12533
12563
|
const code = await run(process.argv.slice(2));process.exitCode = code;
|
package/package.json
CHANGED