@threadbase-sh/scanner 0.19.0 → 0.19.1

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/dist/index.js CHANGED
@@ -1462,15 +1462,22 @@ function firstTimestampHint(content) {
1462
1462
  }
1463
1463
  return "";
1464
1464
  }
1465
- function parseCursorJsonlLine(line) {
1466
- if (!line.trim()) return null;
1465
+ function parseCursorJsonlLine(line, index) {
1466
+ const trimmed = line.trim();
1467
+ if (!trimmed) return null;
1467
1468
  let entry;
1468
1469
  try {
1469
- entry = JSON.parse(line);
1470
+ entry = JSON.parse(trimmed);
1470
1471
  } catch {
1471
1472
  return null;
1472
1473
  }
1473
- return cursorEntryToMessage(entry);
1474
+ const message = cursorEntryToMessage(entry);
1475
+ if (!message || message.uuid) return message;
1476
+ return { ...message, uuid: cursorMessageUuid(trimmed, message.role, index) };
1477
+ }
1478
+ function cursorMessageUuid(line, role, index) {
1479
+ const hash = createHash("sha1").update(line).digest("hex").slice(0, 16);
1480
+ return index === void 0 ? `cursor-${role}-${hash}` : `cursor-${role}-${index}-${hash}`;
1474
1481
  }
1475
1482
  function cursorEntryToMessage(entry) {
1476
1483
  if (looksLikeCursorChatEntry(entry)) {
@@ -1673,7 +1680,7 @@ async function parseCursorConversation(filePath, account) {
1673
1680
  const rl = createInterface3({ input: createReadStream3(filePath), crlfDelay: Infinity });
1674
1681
  try {
1675
1682
  for await (const line of rl) {
1676
- const message = parseCursorJsonlLine(line);
1683
+ const message = parseCursorJsonlLine(line, messages.length);
1677
1684
  if (!message) continue;
1678
1685
  if (message.timestamp && (!latestTimestamp || message.timestamp > latestTimestamp)) {
1679
1686
  latestTimestamp = message.timestamp;