Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ export class CodebaseIndexer {
diff = null;
}

if (diff && !previousManifest) {
console.error('Previous index manifest is missing or unreadable; forcing full rebuild');
diff = null;
}

// Short-circuit: nothing changed
if (
diff &&
Expand Down
26 changes: 26 additions & 0 deletions tests/index-generation-vectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,32 @@ it('copies unchanged real LanceDB vectors while applying incremental add/change/
expect(embedded.join('\n')).not.toContain('unchanged');
}, 30_000);

it('rebuilds semantic vectors when the previous manifest is missing', async () => {
root = await fs.mkdtemp(path.join(os.tmpdir(), 'cbc-vector-missing-manifest-'));
const kept = path.join(root, 'kept.ts');
const removed = path.join(root, 'removed.ts');
await fs.writeFile(kept, 'export const kept = "before";');
await fs.writeFile(removed, 'export const removed = "obsolete";');
const options = {
rootPath: root,
config: {
skipEmbedding: false,
embedding: { provider: 'custom' as const, model: 'vector-generation-fixture' }
}
};
await new CodebaseIndexer(options).index();
expect((await rows()).map((row) => row.file).sort()).toEqual(['kept.ts', 'removed.ts']);

await fs.rm(await resolveIndexArtifact(root, 'manifest.json'));
await fs.rm(removed);
await fs.writeFile(kept, 'export const kept = "after";');
await new CodebaseIndexer({ ...options, incrementalOnly: true }).index();

expect((await rows()).map(({ file, content }) => ({ file, content }))).toEqual([
{ file: 'kept.ts', content: 'export const kept = "after";' }
]);
}, 30_000);

it('retains keyword fallback when the same semantic searcher cannot reopen its provider', async () => {
root = await fs.mkdtemp(path.join(os.tmpdir(), 'cbc-semantic-fallback-'));
await fs.writeFile(path.join(root, 'route.ts'), 'export function route() { return "route"; }');
Expand Down
Loading