@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/cli.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
  import pino2 from "pino";
6
6
 
7
7
  // package.json
8
- var version = "0.19.0";
8
+ var version = "0.19.1";
9
9
 
10
10
  // src/logger.ts
11
11
  import pino from "pino";
@@ -1780,15 +1780,22 @@ function firstTimestampHint(content) {
1780
1780
  }
1781
1781
  return "";
1782
1782
  }
1783
- function parseCursorJsonlLine(line) {
1784
- if (!line.trim()) return null;
1783
+ function parseCursorJsonlLine(line, index) {
1784
+ const trimmed = line.trim();
1785
+ if (!trimmed) return null;
1785
1786
  let entry;
1786
1787
  try {
1787
- entry = JSON.parse(line);
1788
+ entry = JSON.parse(trimmed);
1788
1789
  } catch {
1789
1790
  return null;
1790
1791
  }
1791
- return cursorEntryToMessage(entry);
1792
+ const message = cursorEntryToMessage(entry);
1793
+ if (!message || message.uuid) return message;
1794
+ return { ...message, uuid: cursorMessageUuid(trimmed, message.role, index) };
1795
+ }
1796
+ function cursorMessageUuid(line, role, index) {
1797
+ const hash = createHash2("sha1").update(line).digest("hex").slice(0, 16);
1798
+ return index === void 0 ? `cursor-${role}-${hash}` : `cursor-${role}-${index}-${hash}`;
1792
1799
  }
1793
1800
  function cursorEntryToMessage(entry) {
1794
1801
  if (looksLikeCursorChatEntry(entry)) {
@@ -1991,7 +1998,7 @@ async function parseCursorConversation(filePath, account) {
1991
1998
  const rl = createInterface3({ input: createReadStream5(filePath), crlfDelay: Infinity });
1992
1999
  try {
1993
2000
  for await (const line of rl) {
1994
- const message = parseCursorJsonlLine(line);
2001
+ const message = parseCursorJsonlLine(line, messages.length);
1995
2002
  if (!message) continue;
1996
2003
  if (message.timestamp && (!latestTimestamp || message.timestamp > latestTimestamp)) {
1997
2004
  latestTimestamp = message.timestamp;