@threadbase-sh/scanner 0.9.2 → 0.9.3

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.cjs CHANGED
@@ -1845,6 +1845,19 @@ var ConversationFilesRepo = class {
1845
1845
  const rows = this.db.prepare("SELECT absolute_path FROM conversation_files WHERE status != 'deleted'").all();
1846
1846
  return rows.map((r) => r.absolute_path);
1847
1847
  }
1848
+ // Active file paths belonging to any of the given accounts. Backs the
1849
+ // deletion-reconcile so a scan that covered only some accounts can't mark
1850
+ // another account's files deleted (they live in the same shared index.db but
1851
+ // a different profile owns them). Returns [] for an empty account list.
1852
+ activePathsByAccounts(accounts) {
1853
+ if (accounts.length === 0) return [];
1854
+ const placeholders = accounts.map(() => "?").join(", ");
1855
+ const rows = this.db.prepare(
1856
+ `SELECT absolute_path FROM conversation_files
1857
+ WHERE status != 'deleted' AND account IN (${placeholders})`
1858
+ ).all(...accounts);
1859
+ return rows.map((r) => r.absolute_path);
1860
+ }
1848
1861
  // Active files whose immediate parent is exactly parentDir (no nested
1849
1862
  // subdirectories). Backs the dir-mtime gate's reuse path: a project dir with
1850
1863
  // an unchanged mtime and no nested files can skip the glob entirely.
@@ -2217,8 +2230,15 @@ var PersistentEngine = class {
2217
2230
  scanned += batch.length;
2218
2231
  options.onProgress?.(scanned, discovered.length);
2219
2232
  }
2233
+ const coveredAccounts = /* @__PURE__ */ new Set();
2234
+ if (enabled.includes(CLAUDE_CODE_PROVIDER)) {
2235
+ for (const p of activeProfiles) coveredAccounts.add(p.id);
2236
+ }
2237
+ if (enabled.includes(CODEX_CLI_PROVIDER) && (options.codexRoots?.length ?? 0) > 0) {
2238
+ coveredAccounts.add("codex");
2239
+ }
2220
2240
  const seen = new Set(discovered.map((d) => d.filePath));
2221
- for (const path of this.files.allActivePaths()) {
2241
+ for (const path of this.files.activePathsByAccounts([...coveredAccounts])) {
2222
2242
  if (!seen.has(path)) this.markDeleted(path);
2223
2243
  }
2224
2244
  log.info({ scanned, indexed: this.conversations.count() }, "persistent: indexAll complete");