@threadbase-sh/scanner 0.19.0 → 0.19.2

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.2";
9
9
 
10
10
  // src/logger.ts
11
11
  import pino from "pino";
@@ -796,8 +796,9 @@ var SYSTEM_TAGS = [
796
796
  "teammate-message"
797
797
  ];
798
798
  var SYSTEM_TAG_RE = new RegExp(`<(${SYSTEM_TAGS.join("|")})[^>]*>[\\s\\S]*?<\\/\\1>`, "g");
799
+ var PASTED_CONTENT_RE = /<pasted_content id="[0-9a-f]{4}">([\s\S]*?)<\/pasted_content(?: id="[0-9a-f]{4}")?>/g;
799
800
  function cleanSystemTags(text) {
800
- return text.replace(SYSTEM_TAG_RE, "").replace(/[^\S\n]+/g, " ").replace(/\n{3,}/g, "\n\n").trim();
801
+ return text.replace(SYSTEM_TAG_RE, "").replace(PASTED_CONTENT_RE, "$1").replace(/[^\S\n]+/g, " ").replace(/\n{3,}/g, "\n\n").trim();
801
802
  }
802
803
 
803
804
  // src/parser.ts
@@ -1780,15 +1781,22 @@ function firstTimestampHint(content) {
1780
1781
  }
1781
1782
  return "";
1782
1783
  }
1783
- function parseCursorJsonlLine(line) {
1784
- if (!line.trim()) return null;
1784
+ function parseCursorJsonlLine(line, index) {
1785
+ const trimmed = line.trim();
1786
+ if (!trimmed) return null;
1785
1787
  let entry;
1786
1788
  try {
1787
- entry = JSON.parse(line);
1789
+ entry = JSON.parse(trimmed);
1788
1790
  } catch {
1789
1791
  return null;
1790
1792
  }
1791
- return cursorEntryToMessage(entry);
1793
+ const message = cursorEntryToMessage(entry);
1794
+ if (!message || message.uuid) return message;
1795
+ return { ...message, uuid: cursorMessageUuid(trimmed, message.role, index) };
1796
+ }
1797
+ function cursorMessageUuid(line, role, index) {
1798
+ const hash = createHash2("sha1").update(line).digest("hex").slice(0, 16);
1799
+ return index === void 0 ? `cursor-${role}-${hash}` : `cursor-${role}-${index}-${hash}`;
1792
1800
  }
1793
1801
  function cursorEntryToMessage(entry) {
1794
1802
  if (looksLikeCursorChatEntry(entry)) {
@@ -1991,7 +1999,7 @@ async function parseCursorConversation(filePath, account) {
1991
1999
  const rl = createInterface3({ input: createReadStream5(filePath), crlfDelay: Infinity });
1992
2000
  try {
1993
2001
  for await (const line of rl) {
1994
- const message = parseCursorJsonlLine(line);
2002
+ const message = parseCursorJsonlLine(line, messages.length);
1995
2003
  if (!message) continue;
1996
2004
  if (message.timestamp && (!latestTimestamp || message.timestamp > latestTimestamp)) {
1997
2005
  latestTimestamp = message.timestamp;
@@ -2250,7 +2258,7 @@ import { mkdirSync } from "fs";
2250
2258
  import { dirname as dirname4 } from "path";
2251
2259
 
2252
2260
  // src/persistent/schema.ts
2253
- var SCHEMA_VERSION = 9;
2261
+ var SCHEMA_VERSION = 10;
2254
2262
  var SCHEMA_SQL = `
2255
2263
  CREATE TABLE IF NOT EXISTS conversation_files (
2256
2264
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -2543,6 +2551,21 @@ function runMigrations(db) {
2543
2551
  if (current >= 1 && current < 9 && tableExists(db, "conversations")) {
2544
2552
  db.exec(`UPDATE conversations SET provider = 'cursor' WHERE provider = 'cursor-cli'`);
2545
2553
  }
2554
+ if (current >= 1 && current < 10 && tableExists(db, "conversation_files")) {
2555
+ const assignments = [];
2556
+ if (hasColumn(db, "conversation_files", "last_indexed_offset")) {
2557
+ assignments.push("last_indexed_offset = 0");
2558
+ }
2559
+ if (hasColumn(db, "conversation_files", "last_indexed_line")) {
2560
+ assignments.push("last_indexed_line = 0");
2561
+ }
2562
+ if (hasColumn(db, "conversation_files", "reducer_state")) {
2563
+ assignments.push("reducer_state = NULL");
2564
+ }
2565
+ if (assignments.length > 0) {
2566
+ db.exec(`UPDATE conversation_files SET ${assignments.join(", ")}`);
2567
+ }
2568
+ }
2546
2569
  db.exec(SCHEMA_SQL);
2547
2570
  db.pragma(`user_version = ${SCHEMA_VERSION}`);
2548
2571
  }