@threadbase-sh/scanner 0.9.2 → 0.9.4

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.9.2";
8
+ var version = "0.9.4";
9
9
 
10
10
  // src/logger.ts
11
11
  import pino from "pino";
@@ -1447,10 +1447,13 @@ async function discoverJsonlFilesGated(dirs, files, scannedDirs, options = {}) {
1447
1447
  const watermark = scannedDirs.get(projectDir);
1448
1448
  const canReuse = watermark !== void 0 && watermark.mtime_ms === dirStat.mtimeMs && watermark.has_nested === 0;
1449
1449
  if (canReuse) {
1450
- for (const row of files.activePathsByParentDir(projectDir)) {
1451
- results.push({ filePath: row.absolute_path, account: row.account });
1450
+ const known = files.activePathsByParentDir(projectDir);
1451
+ if (known.length > 0) {
1452
+ for (const row of known) {
1453
+ results.push({ filePath: row.absolute_path, account: row.account });
1454
+ }
1455
+ continue;
1452
1456
  }
1453
- continue;
1454
1457
  }
1455
1458
  const found = await discoverJsonlFiles([{ projectsDir: projectDir, account }]);
1456
1459
  const hasNested = found.some((f) => dirnameOf(f.filePath) !== projectDir);
@@ -1704,6 +1707,19 @@ var ConversationFilesRepo = class {
1704
1707
  const rows = this.db.prepare("SELECT absolute_path FROM conversation_files WHERE status != 'deleted'").all();
1705
1708
  return rows.map((r) => r.absolute_path);
1706
1709
  }
1710
+ // Active file paths belonging to any of the given accounts. Backs the
1711
+ // deletion-reconcile so a scan that covered only some accounts can't mark
1712
+ // another account's files deleted (they live in the same shared index.db but
1713
+ // a different profile owns them). Returns [] for an empty account list.
1714
+ activePathsByAccounts(accounts) {
1715
+ if (accounts.length === 0) return [];
1716
+ const placeholders = accounts.map(() => "?").join(", ");
1717
+ const rows = this.db.prepare(
1718
+ `SELECT absolute_path FROM conversation_files
1719
+ WHERE status != 'deleted' AND account IN (${placeholders})`
1720
+ ).all(...accounts);
1721
+ return rows.map((r) => r.absolute_path);
1722
+ }
1707
1723
  // Active files whose immediate parent is exactly parentDir (no nested
1708
1724
  // subdirectories). Backs the dir-mtime gate's reuse path: a project dir with
1709
1725
  // an unchanged mtime and no nested files can skip the glob entirely.
@@ -2109,8 +2125,15 @@ var PersistentEngine = class {
2109
2125
  scanned += batch.length;
2110
2126
  options.onProgress?.(scanned, discovered.length);
2111
2127
  }
2128
+ const coveredAccounts = /* @__PURE__ */ new Set();
2129
+ if (enabled.includes(CLAUDE_CODE_PROVIDER)) {
2130
+ for (const p of activeProfiles) coveredAccounts.add(p.id);
2131
+ }
2132
+ if (enabled.includes(CODEX_CLI_PROVIDER) && (options.codexRoots?.length ?? 0) > 0) {
2133
+ coveredAccounts.add("codex");
2134
+ }
2112
2135
  const seen = new Set(discovered.map((d) => d.filePath));
2113
- for (const path of this.files.allActivePaths()) {
2136
+ for (const path of this.files.activePathsByAccounts([...coveredAccounts])) {
2114
2137
  if (!seen.has(path)) this.markDeleted(path);
2115
2138
  }
2116
2139
  log.info({ scanned, indexed: this.conversations.count() }, "persistent: indexAll complete");