Skip to content

Commit 9c39480

Browse files
committed
fix(import-markdown): run dedup check before dry-run guard
Before: --dry-run skipped dedup check entirely, so --dry-run --dedup would overcount imports (items counted as imported even if dedup would skip them). After: dedup check runs regardless of dry-run mode. In dry-run, items that would be skipped by dedup are counted as skipped, not imported. Restores the dry-run console log message.
1 parent 95445da commit 9c39480

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cli.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,26 +1185,29 @@ export function registerMemoryCLI(program: Command, context: CLIContext): void {
11851185
const text = line.slice(2).trim();
11861186
if (text.length < minTextLength) { skipped++; continue; }
11871187

1188-
if (options.dryRun) {
1189-
console.log(` [dry-run] would import: ${text.slice(0, 80)}...`);
1190-
imported++;
1191-
continue;
1192-
}
1193-
11941188
// ── Deduplication check (scope-aware exact match) ───────────────────
1189+
// Run even in dry-run so --dry-run --dedup reports accurate counts
11951190
if (dedupEnabled) {
11961191
try {
11971192
const existing = await context.store.bm25Search(text, 1, [targetScope]);
11981193
if (existing.length > 0 && existing[0].entry.text === text) {
11991194
skipped++;
1200-
console.log(` [skip] already imported: ${text.slice(0, 60)}${text.length > 60 ? "..." : ""}`);
1195+
if (!options.dryRun) {
1196+
console.log(` [skip] already imported: ${text.slice(0, 60)}${text.length > 60 ? "..." : ""}`);
1197+
}
12011198
continue;
12021199
}
12031200
} catch {
12041201
// bm25Search not available on this store implementation; proceed with import
12051202
}
12061203
}
12071204

1205+
if (options.dryRun) {
1206+
console.log(` [dry-run] would import: ${text.slice(0, 80)}${text.length > 80 ? "..." : ""}`);
1207+
imported++;
1208+
continue;
1209+
}
1210+
12081211
try {
12091212
const vector = await context.embedder!.embedPassage(text);
12101213
await context.store.store({

0 commit comments

Comments
 (0)