@ninjaxtools/slopdex 0.19.0 → 0.20.0
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/.gitignore +2 -0
- package/README.md +134 -46
- package/binary-install.js +348 -0
- package/binary.js +124 -0
- package/install.js +4 -0
- package/npm-shrinkwrap.json +52 -0
- package/package.json +78 -61
- package/run-slopdex.js +4 -0
- package/dist/chunk-5BO2LLXC.js +0 -15
- package/dist/chunk-5BO2LLXC.js.map +0 -1
- package/dist/chunk-BXWO2KMC.js +0 -20
- package/dist/chunk-BXWO2KMC.js.map +0 -1
- package/dist/chunk-DKRB2XT5.js +0 -33
- package/dist/chunk-DKRB2XT5.js.map +0 -1
- package/dist/chunk-DTI7SXGL.js +0 -109
- package/dist/chunk-DTI7SXGL.js.map +0 -1
- package/dist/chunk-GBEJHETS.js +0 -1117
- package/dist/chunk-GBEJHETS.js.map +0 -1
- package/dist/chunk-HMKVMRLF.js +0 -2221
- package/dist/chunk-HMKVMRLF.js.map +0 -1
- package/dist/chunk-IQU3YVZ3.js +0 -85
- package/dist/chunk-IQU3YVZ3.js.map +0 -1
- package/dist/chunk-JAVPHCZH.js +0 -24
- package/dist/chunk-JAVPHCZH.js.map +0 -1
- package/dist/chunk-MKUTTXZB.js +0 -74
- package/dist/chunk-MKUTTXZB.js.map +0 -1
- package/dist/chunk-OIKBO3NJ.js +0 -133
- package/dist/chunk-OIKBO3NJ.js.map +0 -1
- package/dist/chunk-P57ZJREE.js +0 -426
- package/dist/chunk-P57ZJREE.js.map +0 -1
- package/dist/chunk-S225GYCL.js +0 -79
- package/dist/chunk-S225GYCL.js.map +0 -1
- package/dist/chunk-TSURHRFF.js +0 -240
- package/dist/chunk-TSURHRFF.js.map +0 -1
- package/dist/chunk-VH5VGRCI.js +0 -103
- package/dist/chunk-VH5VGRCI.js.map +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1130
- package/dist/cli.js.map +0 -1
- package/dist/code-index-MWSJKV3G.js +0 -14
- package/dist/code-index-MWSJKV3G.js.map +0 -1
- package/dist/cross-search-ERBFC25T.js +0 -10
- package/dist/cross-search-ERBFC25T.js.map +0 -1
- package/dist/database-P5XWJWQL.js +0 -14
- package/dist/database-P5XWJWQL.js.map +0 -1
- package/dist/hosted-GHIUHKOU.js +0 -13
- package/dist/hosted-GHIUHKOU.js.map +0 -1
- package/dist/index.d.ts +0 -681
- package/dist/index.js +0 -102
- package/dist/index.js.map +0 -1
- package/dist/jina-43RL7C6M.js +0 -12
- package/dist/jina-43RL7C6M.js.map +0 -1
- package/dist/openai-CYUPNBGB.js +0 -12
- package/dist/openai-CYUPNBGB.js.map +0 -1
- package/dist/openai-EC6THXKV.js +0 -21
- package/dist/openai-EC6THXKV.js.map +0 -1
- package/dist/openai-TCRXM66O.js +0 -11
- package/dist/openai-TCRXM66O.js.map +0 -1
- package/docs/implementation.md +0 -162
- package/docs/reference.md +0 -187
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/storage/database.ts"],"sourcesContent":["import { mkdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { DatabaseSync } from \"node:sqlite\";\n\nimport * as sqliteVec from \"sqlite-vec\";\n\nimport { CodeIndexError, IncompatibleIndexError } from \"../errors.js\";\nimport type {\n EmbeddingProfile,\n IndexStatus,\n IndexedFunction,\n IndexingError,\n IndexingIssue,\n ParsedCallable,\n SourceMode,\n SimilarityResult,\n DescriptionProfile,\n UpdateStats,\n} from \"../types.js\";\n\nconst SCHEMA_VERSION = \"10\";\nconst KNN_TIE_OVERFETCH = 32;\nconst VEC0_MAX_K = 4096;\nconst VEC0_MAX_DIMENSIONS = 8192;\n\nexport interface PreparedDescription {\n key: string;\n description: string;\n vector?: readonly number[];\n}\n\nexport interface PreparedFileDescription {\n path: string;\n contentHash: string;\n descriptionKey: string;\n value: PreparedDescription;\n}\n\nexport interface PreparedCallable extends ParsedCallable {\n embeddingKey: string;\n vector?: readonly number[];\n descriptionKey?: string;\n description?: PreparedDescription;\n}\n\nexport interface PreparedFile {\n path: string;\n contentHash: string;\n blobOid: string | null;\n sourceMode: SourceMode;\n indexedCommit: string | null;\n language: string;\n byteSize: number;\n source: string;\n previousPath?: string;\n replacePath?: string;\n callables: PreparedCallable[];\n fileDescription?: PreparedFileDescription;\n errors: IndexingIssue[];\n unavailable?: boolean;\n}\n\nexport interface CachedParse {\n callables: ParsedCallable[];\n errors: IndexingIssue[];\n}\n\nexport interface IndexedFileState {\n path: string;\n contentHash: string;\n blobOid: string | null;\n sourceMode: SourceMode;\n previousPath: string | null;\n language: string;\n describable: boolean;\n fileDescription: string | null;\n fileDescriptionPath: string | null;\n fileDescriptionContentHash: string | null;\n}\n\ninterface FunctionRow {\n id: number;\n path: string;\n language: IndexedFunction[\"language\"];\n kind: IndexedFunction[\"kind\"];\n name: string;\n qualified_name: string;\n signature: string | null;\n identity_key: string;\n start_line: number;\n start_column: number;\n end_line: number;\n end_column: number;\n line_count: number;\n source: string;\n source_hash: string;\n embedding_input: string;\n first_seen_commit: string | null;\n last_seen_commit: string | null;\n source_mode: SourceMode;\n embedding_id: number;\n description: string | null;\n description_embedding_id: number | null;\n}\n\nexport class IndexDatabase {\n readonly #db: DatabaseSync;\n readonly #rootDir: string;\n readonly #indexPath: string;\n readonly #profile: Required<EmbeddingProfile>;\n readonly #readOnly: boolean;\n\n public constructor(indexPath: string, rootDir: string, profile: Required<EmbeddingProfile>, readOnly = false) {\n if (!readOnly) mkdirSync(path.dirname(indexPath), { recursive: true });\n this.#indexPath = indexPath;\n this.#rootDir = rootDir;\n this.#profile = profile;\n this.#readOnly = readOnly;\n this.#db = new DatabaseSync(indexPath, { allowExtension: true, readOnly });\n try {\n sqliteVec.load(this.#db);\n this.#db.enableLoadExtension(false);\n const regexes = new Map<string, RegExp>();\n this.#db.function(\"slopdex_regexp\", { deterministic: true }, (pattern, value) => {\n if (typeof pattern !== \"string\" || typeof value !== \"string\") return 0;\n let regex = regexes.get(pattern);\n if (!regex) {\n regex = new RegExp(pattern);\n regexes.set(pattern, regex);\n }\n return regex.test(value) ? 1 : 0;\n });\n if (readOnly) {\n this.#db.exec(\"PRAGMA foreign_keys=ON\");\n } else {\n this.#db.exec(\"PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON;\");\n this.#initializeSchema();\n }\n this.#validateMetadata(readOnly);\n } catch (error) {\n this.#db.close();\n throw error;\n }\n }\n\n public close(): void {\n this.#db.close();\n }\n\n public get isReadOnly(): boolean {\n return this.#readOnly;\n }\n\n #initializeSchema(): void {\n const existingVersion = this.#metadataTableExists() ? this.#metadata(\"schema_version\") : null;\n if (existingVersion && existingVersion !== \"6\" && existingVersion !== \"7\" && existingVersion !== \"8\" && existingVersion !== \"9\" && existingVersion !== SCHEMA_VERSION) {\n throw new IncompatibleIndexError(`Unsupported index schema version ${existingVersion}.`);\n }\n this.#db.exec(`\n CREATE TABLE IF NOT EXISTS metadata (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n );\n CREATE TABLE IF NOT EXISTS files (\n path TEXT PRIMARY KEY,\n content_hash TEXT NOT NULL,\n blob_oid TEXT,\n source_mode TEXT NOT NULL CHECK(source_mode IN ('git', 'working-tree')),\n indexed_commit TEXT,\n previous_path TEXT,\n language TEXT NOT NULL,\n byte_size INTEGER NOT NULL,\n file_description_path TEXT,\n file_description_content_hash TEXT,\n file_description TEXT,\n file_description_embedding_id INTEGER REFERENCES embeddings(id)\n );\n CREATE TABLE IF NOT EXISTS embeddings (\n id INTEGER PRIMARY KEY,\n embedding_key TEXT NOT NULL UNIQUE,\n vector BLOB NOT NULL\n );\n CREATE TABLE IF NOT EXISTS description_cache (\n description_key TEXT PRIMARY KEY,\n description TEXT NOT NULL\n );\n CREATE TABLE IF NOT EXISTS parse_cache (\n parse_key TEXT PRIMARY KEY,\n result TEXT NOT NULL\n );\n CREATE TABLE IF NOT EXISTS functions (\n id INTEGER PRIMARY KEY,\n path TEXT NOT NULL REFERENCES files(path) ON DELETE CASCADE ON UPDATE CASCADE,\n language TEXT NOT NULL,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n qualified_name TEXT NOT NULL,\n signature TEXT,\n identity_key TEXT NOT NULL UNIQUE,\n start_line INTEGER NOT NULL,\n start_column INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n end_column INTEGER NOT NULL,\n line_count INTEGER NOT NULL,\n source TEXT NOT NULL,\n source_hash TEXT NOT NULL,\n embedding_input TEXT NOT NULL,\n first_seen_commit TEXT,\n last_seen_commit TEXT,\n source_mode TEXT NOT NULL CHECK(source_mode IN ('git', 'working-tree')),\n embedding_id INTEGER NOT NULL REFERENCES embeddings(id),\n description TEXT,\n description_embedding_id INTEGER REFERENCES embeddings(id)\n );\n CREATE TABLE IF NOT EXISTS callable_provenance (\n identity_key TEXT NOT NULL,\n source_hash TEXT NOT NULL,\n first_seen_commit TEXT NOT NULL,\n PRIMARY KEY(identity_key, source_hash)\n );\n CREATE INDEX IF NOT EXISTS functions_path ON functions(path);\n CREATE INDEX IF NOT EXISTS functions_embedding ON functions(embedding_id);\n CREATE INDEX IF NOT EXISTS functions_description_embedding ON functions(description_embedding_id);\n CREATE TABLE IF NOT EXISTS indexing_errors (\n id INTEGER PRIMARY KEY,\n path TEXT NOT NULL REFERENCES files(path) ON DELETE CASCADE ON UPDATE CASCADE,\n diagnostic TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS indexing_errors_path ON indexing_errors(path);\n INSERT OR IGNORE INTO callable_provenance(identity_key, source_hash, first_seen_commit)\n SELECT identity_key, source_hash, first_seen_commit FROM functions WHERE first_seen_commit IS NOT NULL;\n `);\n if (existingVersion === \"6\" || existingVersion === \"7\" || existingVersion === null) {\n this.#db.exec(\"BEGIN IMMEDIATE\");\n try {\n if (existingVersion === \"6\") {\n this.#db.exec(`\n ALTER TABLE files ADD COLUMN file_description_path TEXT;\n ALTER TABLE files ADD COLUMN file_description_content_hash TEXT;\n ALTER TABLE files ADD COLUMN file_description TEXT;\n ALTER TABLE files ADD COLUMN file_description_embedding_id INTEGER REFERENCES embeddings(id);\n `);\n }\n const storedProfile = this.#metadata(\"embedding_profile\");\n const dimensions = storedProfile\n ? Number((JSON.parse(storedProfile) as EmbeddingProfile).dimensions)\n : this.#profile.dimensions;\n if (!Number.isInteger(dimensions) || dimensions <= 0) throw new IncompatibleIndexError(\"Index has an invalid embedding profile.\");\n if (dimensions <= VEC0_MAX_DIMENSIONS) this.#db.exec(functionVectorsSchema(dimensions));\n this.#setMetadata(\"schema_version\", SCHEMA_VERSION);\n this.#db.exec(\"COMMIT\");\n } catch (error) {\n this.#db.exec(\"ROLLBACK\");\n throw error;\n }\n } else if (existingVersion === \"8\") {\n this.#db.exec(\"BEGIN IMMEDIATE\");\n try {\n this.#db.exec(similarityCacheSchema());\n this.#setMetadata(\"schema_version\", SCHEMA_VERSION);\n this.#db.exec(\"COMMIT\");\n } catch (error) {\n this.#db.exec(\"ROLLBACK\");\n throw error;\n }\n } else if (existingVersion === \"9\") {\n this.#db.exec(\"BEGIN IMMEDIATE\");\n try {\n this.#db.exec(`\n ALTER TABLE similarity_cache_state ADD COLUMN floor REAL NOT NULL DEFAULT -1;\n ALTER TABLE similarity_cache_state ADD COLUMN stored_count INTEGER NOT NULL DEFAULT 0;\n ALTER TABLE similarity_cache_state ADD COLUMN complete INTEGER NOT NULL DEFAULT 0;\n UPDATE similarity_cache_state SET stored_count = (\n SELECT COUNT(*) FROM similarity_cache c\n WHERE c.source_id = similarity_cache_state.function_id\n AND c.similarity_mode = similarity_cache_state.similarity_mode\n );\n UPDATE similarity_cache_state SET complete = (stored_count < cached_width);\n `);\n this.#setMetadata(\"schema_version\", SCHEMA_VERSION);\n this.#db.exec(\"COMMIT\");\n } catch (error) {\n this.#db.exec(\"ROLLBACK\");\n throw error;\n }\n }\n this.#db.exec(\"CREATE INDEX IF NOT EXISTS files_description_embedding ON files(file_description_embedding_id);\");\n this.#db.exec(similarityCacheSchema());\n }\n\n #metadataTableExists(): boolean {\n return Boolean(this.#db.prepare(\"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'metadata'\").get());\n }\n\n #metadata(key: string): string | null {\n if (!this.#metadataTableExists()) return null;\n const row = this.#db.prepare(\"SELECT value FROM metadata WHERE key = ?\").get(key) as { value: string } | undefined;\n return row?.value ?? null;\n }\n\n #setMetadata(key: string, value: string): void {\n this.#db.prepare(`\n INSERT INTO metadata(key, value) VALUES (?, ?)\n ON CONFLICT(key) DO UPDATE SET value = excluded.value\n `).run(key, value);\n }\n\n #deleteMetadata(key: string): void {\n this.#db.prepare(\"DELETE FROM metadata WHERE key = ?\").run(key);\n }\n\n #validateMetadata(readOnly: boolean): void {\n const schemaVersion = this.#metadata(\"schema_version\");\n if (readOnly && !schemaVersion) throw new IncompatibleIndexError(\"Target file is not a slopdex index.\");\n if (schemaVersion && schemaVersion !== SCHEMA_VERSION) {\n throw new IncompatibleIndexError(`Unsupported index schema version ${schemaVersion}.`);\n }\n const storedRoot = this.#metadata(\"root_dir\");\n if (readOnly && !storedRoot) throw new IncompatibleIndexError(\"Target index has no repository identity.\");\n if (storedRoot && path.resolve(storedRoot) !== this.#rootDir) {\n throw new IncompatibleIndexError(`Index belongs to ${storedRoot}, not ${this.#rootDir}.`);\n }\n const profileJson = JSON.stringify(this.#profile);\n const storedProfile = this.#metadata(\"embedding_profile\");\n if (readOnly && !storedProfile) throw new IncompatibleIndexError(\"Target index has no embedding profile.\");\n if (storedProfile && storedProfile !== profileJson) {\n throw new IncompatibleIndexError(\"Embedding provider, model, dimensions, or strategy differs from this index.\");\n }\n if (readOnly) return;\n this.#transaction(() => {\n this.#setMetadata(\"schema_version\", SCHEMA_VERSION);\n this.#setMetadata(\"root_dir\", this.#rootDir);\n this.#setMetadata(\"embedding_profile\", profileJson);\n if (!this.#metadata(\"generation\")) this.#setMetadata(\"generation\", \"0\");\n });\n }\n\n #transaction<T>(operation: () => T): T {\n this.#db.exec(\"BEGIN IMMEDIATE\");\n try {\n const result = operation();\n this.#db.exec(\"COMMIT\");\n return result;\n } catch (error) {\n this.#db.exec(\"ROLLBACK\");\n throw error;\n }\n }\n\n public getCheckpoint(): string | null {\n return this.#metadata(\"git_checkpoint\");\n }\n\n public getGeneration(): number {\n return Number(this.#metadata(\"generation\") ?? 0);\n }\n\n public descriptionsEnabled(): boolean {\n return this.#metadata(\"descriptions_enabled\") === \"true\";\n }\n\n public descriptionProfile(): DescriptionProfile | null {\n const value = this.#metadata(\"description_profile\");\n return value ? JSON.parse(value) as DescriptionProfile : null;\n }\n\n public cachedEmbedding(key: string): number[] | undefined {\n const row = this.#db.prepare(\"SELECT vector FROM embeddings WHERE embedding_key = ?\").get(key) as\n { vector: Uint8Array } | undefined;\n return row ? bufferVector(row.vector) : undefined;\n }\n\n public storeEmbedding(key: string, vector: readonly number[]): void {\n if (this.#readOnly) return;\n this.#db.prepare(\"INSERT OR IGNORE INTO embeddings(embedding_key, vector) VALUES (?, ?)\")\n .run(key, vectorBuffer(vector));\n }\n\n public cachedDescription(key: string): string | undefined {\n const row = this.#db.prepare(\"SELECT description FROM description_cache WHERE description_key = ?\").get(key) as\n { description: string } | undefined;\n return row?.description;\n }\n\n public liveFunctionDescriptions(identityKeys: readonly string[]): Map<string, { description: string | null; sourceHash: string }> {\n const result = new Map<string, { description: string | null; sourceHash: string }>();\n for (let index = 0; index < identityKeys.length; index += 500) {\n const batch = identityKeys.slice(index, index + 500);\n if (batch.length === 0) continue;\n const rows = this.#db.prepare(`\n SELECT identity_key AS identityKey, description, source_hash AS sourceHash\n FROM functions WHERE identity_key IN (${batch.map(() => \"?\").join(\", \")})\n `).all(...batch) as Array<{ identityKey: string; description: string | null; sourceHash: string }>;\n for (const row of rows) result.set(row.identityKey, { description: row.description, sourceHash: row.sourceHash });\n }\n return result;\n }\n\n public liveFileContentHashes(filePaths: readonly string[]): Map<string, string> {\n const result = new Map<string, string>();\n for (let index = 0; index < filePaths.length; index += 500) {\n const batch = filePaths.slice(index, index + 500);\n if (batch.length === 0) continue;\n const rows = this.#db.prepare(`\n SELECT path, content_hash AS contentHash FROM files WHERE path IN (${batch.map(() => \"?\").join(\", \")})\n `).all(...batch) as Array<{ path: string; contentHash: string }>;\n for (const row of rows) result.set(row.path, row.contentHash);\n }\n return result;\n }\n\n public updateDescriptionProfile(profile: DescriptionProfile, expectedGeneration: number): void {\n this.#transaction(() => {\n if (this.getGeneration() !== expectedGeneration) throw new CodeIndexError(\"Index changed while descriptions were being prepared; retry the update.\");\n this.#setMetadata(\"description_profile\", JSON.stringify(profile));\n this.#setMetadata(\"generation\", String(expectedGeneration + 1));\n });\n }\n\n public storeDescription(key: string, description: string): string {\n if (this.#readOnly) return description;\n this.#db.prepare(\"INSERT OR IGNORE INTO description_cache(description_key, description) VALUES (?, ?)\").run(key, description);\n return (this.#db.prepare(\"SELECT description FROM description_cache WHERE description_key = ?\").get(key) as { description: string }).description;\n }\n\n public cachedParse(key: string): CachedParse | undefined {\n const row = this.#db.prepare(\"SELECT result FROM parse_cache WHERE parse_key = ?\").get(key) as\n { result: string } | undefined;\n return row ? JSON.parse(row.result) as CachedParse : undefined;\n }\n\n public storeParse(key: string, result: CachedParse): void {\n if (this.#readOnly) return;\n this.#db.prepare(\"INSERT OR IGNORE INTO parse_cache(parse_key, result) VALUES (?, ?)\").run(key, JSON.stringify(result));\n }\n\n #embeddingId(key: string, vector?: readonly number[]): number {\n if (vector) this.storeEmbedding(key, vector);\n const row = this.#db.prepare(\"SELECT id FROM embeddings WHERE embedding_key = ?\").get(key) as\n { id: number } | undefined;\n if (!row) throw new CodeIndexError(\"Missing cached embedding.\");\n return row.id;\n }\n\n public enableDescriptions(\n values: readonly { id: number; description: PreparedDescription }[],\n files: readonly PreparedFile[],\n profile: DescriptionProfile,\n expectedGeneration: number,\n ): void {\n this.#transaction(() => {\n if (this.getGeneration() !== expectedGeneration) throw new CodeIndexError(\"Index changed while descriptions were being prepared; retry the update.\");\n for (const file of files) this.#updateFileDescription(file);\n for (const { id, description } of values) {\n this.#db.prepare(\"UPDATE functions SET description = ?, description_embedding_id = ? WHERE id = ?\")\n .run(description.description, this.#embeddingId(description.key, description.vector), id);\n }\n this.#setMetadata(\"descriptions_enabled\", \"true\");\n this.#setMetadata(\"description_profile\", JSON.stringify(profile));\n this.#setMetadata(\"generation\", String(expectedGeneration + 1));\n });\n }\n\n public updateDescriptions(\n files: readonly PreparedFile[],\n includeCallables: boolean,\n expectedGeneration: number,\n profile?: DescriptionProfile,\n ): void {\n this.#transaction(() => {\n if (this.getGeneration() !== expectedGeneration) throw new CodeIndexError(\"Index changed while descriptions were being prepared; retry the update.\");\n if (profile) this.#setMetadata(\"description_profile\", JSON.stringify(profile));\n if (files.length === 0) return;\n for (const file of files) {\n this.#updateFileDescription(file);\n this.#replaceCachedDescription(file.fileDescription!.descriptionKey, file.fileDescription!.value.description);\n if (!includeCallables) continue;\n for (const callable of file.callables) {\n if (!callable.description) throw new CodeIndexError(`Missing description for ${callable.qualifiedName}.`);\n if (!callable.descriptionKey) throw new CodeIndexError(`Missing description cache key for ${callable.qualifiedName}.`);\n this.#db.prepare(\"UPDATE functions SET description = ?, description_embedding_id = ? WHERE identity_key = ?\")\n .run(\n callable.description.description,\n this.#embeddingId(callable.description.key, callable.description.vector),\n callable.identityKey,\n );\n this.#replaceCachedDescription(callable.descriptionKey, callable.description.description);\n }\n }\n this.#setMetadata(\"generation\", String(expectedGeneration + 1));\n });\n }\n\n #updateFileDescription(file: PreparedFile): void {\n if (!file.fileDescription) throw new CodeIndexError(`Missing file description for ${file.path}.`);\n this.#db.prepare(`\n UPDATE files\n SET file_description_path = ?, file_description_content_hash = ?,\n file_description = ?, file_description_embedding_id = ?\n WHERE path = ?\n `).run(\n file.fileDescription.path,\n file.fileDescription.contentHash,\n file.fileDescription.value.description,\n this.#embeddingId(file.fileDescription.value.key, file.fileDescription.value.vector),\n file.path,\n );\n }\n\n #replaceCachedDescription(key: string, description: string): void {\n this.#db.prepare(`\n INSERT INTO description_cache(description_key, description) VALUES (?, ?)\n ON CONFLICT(description_key) DO UPDATE SET description = excluded.description\n `).run(key, description);\n }\n\n public disableDescriptions(): void {\n if (!this.descriptionsEnabled()) return;\n this.#transaction(() => {\n this.#setMetadata(\"descriptions_enabled\", \"false\");\n this.#setMetadata(\"generation\", String(this.getGeneration() + 1));\n });\n }\n\n public getWorkingTreeFiles(): Array<{ path: string; previousPath: string | null }> {\n return this.#db.prepare(`\n SELECT path, previous_path AS previousPath\n FROM files WHERE source_mode = 'working-tree' ORDER BY path\n `).all() as Array<{ path: string; previousPath: string | null }>;\n }\n\n public getFileStates(): IndexedFileState[] {\n return this.#db.prepare(`\n SELECT path, content_hash AS contentHash, blob_oid AS blobOid,\n source_mode AS sourceMode, previous_path AS previousPath, language,\n NOT EXISTS (\n SELECT 1 FROM indexing_errors ie\n WHERE ie.path = files.path\n AND json_extract(ie.diagnostic, '$.code') IN ('read-error', 'file-too-large')\n ) AS describable,\n file_description AS fileDescription,\n file_description_path AS fileDescriptionPath,\n file_description_content_hash AS fileDescriptionContentHash\n FROM files ORDER BY path\n `).all() as unknown as IndexedFileState[];\n }\n\n public fileDescription(filePath: string): { description: string; path: string; contentHash: string } | undefined {\n const row = this.#db.prepare(`\n SELECT file_description AS description, file_description_path AS path,\n file_description_content_hash AS contentHash\n FROM files WHERE path = ? AND file_description IS NOT NULL\n `).get(filePath) as { description: string; path: string; contentHash: string } | undefined;\n return row;\n }\n\n public functionDescription(identityKey: string): string | undefined {\n const row = this.#db.prepare(\"SELECT description FROM functions WHERE identity_key = ?\")\n .get(identityKey) as { description: string | null } | undefined;\n return row?.description ?? undefined;\n }\n\n public applyUpdate(options: {\n files: readonly PreparedFile[];\n deletePaths: readonly string[];\n workingTree?: {\n files: readonly PreparedFile[];\n deletePaths: readonly string[];\n };\n checkpoint?: string | null;\n expectedCheckpoint?: string | null;\n expectedGeneration?: number;\n completeDiagnosticsScan?: boolean;\n embeddingsCreated?: number;\n }): UpdateStats {\n return this.#transaction(() => {\n if (options.expectedCheckpoint !== undefined && this.getCheckpoint() !== options.expectedCheckpoint) {\n throw new CodeIndexError(\"Git checkpoint changed while the update was being prepared.\");\n }\n if (options.expectedGeneration !== undefined && this.getGeneration() !== options.expectedGeneration) {\n throw new CodeIndexError(\"Index changed while the update was being prepared; retry the update.\");\n }\n\n const stats: UpdateStats = {\n filesUpdated: 0,\n filesDeleted: 0,\n functionsAdded: 0,\n functionsUpdated: 0,\n functionsDeleted: 0,\n embeddingsCreated: options.embeddingsCreated ?? 0,\n checkpoint: options.checkpoint !== undefined ? options.checkpoint : this.getCheckpoint(),\n };\n\n const deleteFile = this.#db.prepare(\"DELETE FROM files WHERE path = ?\");\n const countFunctions = this.#db.prepare(\"SELECT COUNT(*) AS count FROM functions WHERE path = ?\");\n const applyStage = (files: readonly PreparedFile[], deletePaths: readonly string[]): void => {\n stats.filesUpdated += files.length;\n const uniqueDeletes = new Set(deletePaths);\n for (const file of files) {\n uniqueDeletes.delete(file.path);\n if (file.previousPath) uniqueDeletes.delete(file.previousPath);\n if (file.replacePath) uniqueDeletes.delete(file.replacePath);\n }\n for (const filePath of uniqueDeletes) {\n const count = Number((countFunctions.get(filePath) as { count: number }).count);\n const result = deleteFile.run(filePath);\n if (result.changes > 0) {\n stats.filesDeleted += 1;\n stats.functionsDeleted += count;\n }\n }\n\n for (const file of files) this.#replaceFile(file, stats);\n };\n\n applyStage(options.files, options.deletePaths);\n if (options.workingTree) applyStage(options.workingTree.files, options.workingTree.deletePaths);\n\n const generation = this.getGeneration() + 1;\n this.#setMetadata(\"generation\", String(generation));\n if (options.completeDiagnosticsScan) this.#deleteMetadata(\"diagnostics_scan_pending\");\n if (options.checkpoint === null) this.#deleteMetadata(\"git_checkpoint\");\n else if (options.checkpoint !== undefined) this.#setMetadata(\"git_checkpoint\", options.checkpoint);\n return stats;\n });\n }\n\n #replaceFile(file: PreparedFile, stats: UpdateStats): void {\n const sourcePath = file.replacePath ?? file.previousPath ?? file.path;\n const oldRows = this.#rowsForPath(sourcePath);\n const existingFile = this.#db.prepare(`\n SELECT previous_path, file_description_path, file_description_content_hash,\n file_description, file_description_embedding_id\n FROM files WHERE path = ?\n `).get(sourcePath) as\n | {\n previous_path: string | null;\n file_description_path: string | null;\n file_description_content_hash: string | null;\n file_description: string | null;\n file_description_embedding_id: number | null;\n }\n | undefined;\n const oldMatches = reconcileFunctions(file.callables, oldRows);\n\n if (sourcePath !== file.path) {\n const displacedRows = this.#rowsForPath(file.path);\n const displaced = this.#db.prepare(\"DELETE FROM files WHERE path = ?\").run(file.path);\n if (displaced.changes > 0) {\n stats.filesDeleted += 1;\n stats.functionsDeleted += displacedRows.length;\n }\n this.#db.prepare(\"DELETE FROM files WHERE path = ?\").run(sourcePath);\n } else {\n this.#db.prepare(\"DELETE FROM files WHERE path = ?\").run(file.path);\n }\n this.#db.prepare(`\n INSERT INTO files(\n path, content_hash, blob_oid, source_mode, indexed_commit, previous_path, language, byte_size,\n file_description_path, file_description_content_hash, file_description, file_description_embedding_id\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n `).run(\n file.path,\n file.contentHash,\n file.blobOid,\n file.sourceMode,\n file.indexedCommit,\n file.sourceMode === \"working-tree\" ? file.previousPath ?? existingFile?.previous_path ?? null : null,\n file.language,\n file.byteSize,\n file.fileDescription?.path ?? (file.unavailable ? null : existingFile?.file_description_path) ?? null,\n file.fileDescription?.contentHash ?? (file.unavailable ? null : existingFile?.file_description_content_hash) ?? null,\n file.fileDescription?.value.description ?? (file.unavailable ? null : existingFile?.file_description) ?? null,\n file.fileDescription\n ? this.#embeddingId(file.fileDescription.value.key, file.fileDescription.value.vector)\n : file.unavailable ? null : existingFile?.file_description_embedding_id ?? null,\n );\n const insertError = this.#db.prepare(\"INSERT INTO indexing_errors(path, diagnostic) VALUES (?, ?)\");\n for (const error of file.errors) insertError.run(file.path, JSON.stringify(error));\n\n const usedIds = new Set<number>();\n const orderedCallables = [\n ...file.callables.filter((callable) => oldMatches.has(callable)),\n ...file.callables.filter((callable) => !oldMatches.has(callable)),\n ];\n for (const callable of orderedCallables) {\n if (callable.vector) {\n this.storeEmbedding(callable.embeddingKey, callable.vector);\n }\n const embedding = this.#db.prepare(\"SELECT id FROM embeddings WHERE embedding_key = ?\").get(callable.embeddingKey) as { id: number } | undefined;\n if (!embedding) throw new CodeIndexError(`Missing embedding for ${callable.qualifiedName}.`);\n\n const old = oldMatches.get(callable);\n if (this.descriptionsEnabled() && !callable.description) throw new CodeIndexError(`Missing description for ${callable.qualifiedName}.`);\n const descriptionId = callable.description ? this.#embeddingId(callable.description.key, callable.description.vector) : null;\n if (old) usedIds.add(old.id);\n const remembered = this.#db.prepare(`\n SELECT first_seen_commit FROM callable_provenance WHERE identity_key = ? AND source_hash = ?\n `).get(callable.identityKey, callable.sourceHash) as { first_seen_commit: string } | undefined;\n const firstSeenCommit = old?.first_seen_commit ?? remembered?.first_seen_commit ?? file.indexedCommit;\n this.#db.prepare(`\n INSERT INTO functions(\n id, path, language, kind, name, qualified_name, signature, identity_key,\n start_line, start_column, end_line, end_column, line_count, source, source_hash,\n embedding_input, first_seen_commit, last_seen_commit, source_mode, embedding_id, description, description_embedding_id\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n `).run(\n old?.id ?? null,\n file.path,\n callable.language,\n callable.kind,\n callable.name,\n callable.qualifiedName,\n callable.signature,\n callable.identityKey,\n callable.startLine,\n callable.startColumn,\n callable.endLine,\n callable.endColumn,\n callable.lineCount,\n callable.source,\n callable.sourceHash,\n callable.embeddingInput,\n firstSeenCommit,\n file.indexedCommit,\n file.sourceMode,\n embedding.id,\n callable.description?.description ?? null,\n descriptionId,\n );\n if (old) stats.functionsUpdated += 1;\n else stats.functionsAdded += 1;\n if (firstSeenCommit) {\n this.#db.prepare(`\n INSERT OR IGNORE INTO callable_provenance(identity_key, source_hash, first_seen_commit) VALUES (?, ?, ?)\n `).run(callable.identityKey, callable.sourceHash, firstSeenCommit);\n }\n }\n stats.functionsDeleted += oldRows.length - usedIds.size;\n }\n\n #rowsForPath(filePath: string): FunctionRow[] {\n return this.#db.prepare(\"SELECT * FROM functions WHERE path = ? ORDER BY start_line, start_column, id\").all(filePath) as unknown as FunctionRow[];\n }\n\n public allFunctions(): IndexedFunction[] {\n return (this.#db.prepare(\"SELECT * FROM functions ORDER BY path, start_line, start_column, id\").all() as unknown as FunctionRow[])\n .map(toIndexedFunction);\n }\n\n public allFilePaths(): string[] {\n return (this.#db.prepare(\"SELECT path FROM files ORDER BY path\").all() as Array<{ path: string }>).map((row) => row.path);\n }\n\n public previousPath(filePath: string): string | null {\n const row = this.#db.prepare(\"SELECT previous_path FROM files WHERE path = ?\").get(filePath) as\n | { previous_path: string | null }\n | undefined;\n return row?.previous_path ?? null;\n }\n\n public functionsForPaths(paths: readonly string[]): IndexedFunction[] {\n const results: IndexedFunction[] = [];\n for (const filePath of paths) results.push(...this.#rowsForPath(filePath).map(toIndexedFunction));\n return results;\n }\n\n public searchVector(vector: readonly number[], options: {\n descriptions?: boolean;\n descriptionVector?: readonly number[];\n fileDescriptionVector?: readonly number[];\n limit?: number;\n minSimilarity: number;\n maxSimilarity?: number;\n excludeId?: number;\n excludePaths?: readonly string[];\n minLines?: number;\n nameRegex?: string;\n }): SimilarityResult[] {\n const functionDescription = options.descriptionVector !== undefined;\n const fileDescription = options.fileDescriptionVector !== undefined;\n const fused = functionDescription || fileDescription;\n if (functionDescription && options.descriptions) throw new CodeIndexError(\"Description-only search cannot also supply a separate function-description vector.\");\n const scoreCount = 1 + Number(functionDescription) + Number(fileDescription);\n const scoreExpression = [\"base_similarity\"]\n .concat(functionDescription ? [\"description_similarity\"] : [])\n .concat(fileDescription ? [\"file_description_similarity\"] : [])\n .join(\" + \");\n const excludePaths = options.excludePaths ?? [];\n if (options.limit !== undefined\n && !options.descriptions && !fused && options.maxSimilarity === undefined\n && options.nameRegex === undefined && excludePaths.length <= 1 && options.limit <= VEC0_MAX_K\n && this.#profile.dimensions <= VEC0_MAX_DIMENSIONS) {\n const excludeIdFilter = options.excludeId === undefined ? \"\" : \"AND function_id_filter != ?\";\n const excludePathFilter = excludePaths.length === 0 ? \"\" : \"AND path != ?\";\n const candidateLimit = Math.min((options.limit as number) + KNN_TIE_OVERFETCH, VEC0_MAX_K);\n const rows = this.#db.prepare(`\n WITH nearest AS MATERIALIZED (\n SELECT function_id, distance\n FROM function_vectors\n WHERE embedding MATCH ? AND k = ?\n AND line_count >= ?\n ${excludeIdFilter}\n ${excludePathFilter}\n )\n SELECT f.*, 1.0 - nearest.distance AS similarity, 1.0 - nearest.distance AS base_similarity\n FROM nearest JOIN functions f ON f.id = nearest.function_id\n WHERE 1.0 - nearest.distance >= ?\n ORDER BY similarity DESC, f.id ASC\n `).all(\n vectorBuffer(vector),\n candidateLimit,\n options.minLines ?? 1,\n ...(options.excludeId === undefined ? [] : [options.excludeId]),\n ...excludePaths,\n options.minSimilarity,\n ) as unknown as Array<FunctionRow & { similarity: number; base_similarity: number }>;\n const limit = options.limit as number;\n const boundary = rows[limit - 1];\n const last = rows.at(-1);\n const ambiguousTie = rows.length === candidateLimit && boundary && last\n && Math.abs(boundary.similarity - last.similarity) <= Number.EPSILON;\n if (!ambiguousTie) {\n return rows.slice(0, limit)\n .map((row) => ({ function: toIndexedFunction(row), similarity: row.similarity }));\n }\n }\n const pathFilter = excludePaths.length > 0\n ? `AND f.path NOT IN (${excludePaths.map(() => \"?\").join(\", \")})`\n : \"\";\n const rows = this.#db.prepare(`\n WITH scores AS (\n SELECT f.id AS function_id, 1.0 - vec_distance_cosine(e.vector, ?) AS base_similarity\n ${functionDescription ? \", 1.0 - vec_distance_cosine(d.vector, ?) AS description_similarity\" : \"\"}\n ${fileDescription ? \", 1.0 - vec_distance_cosine(fd.vector, ?) AS file_description_similarity\" : \"\"}\n FROM functions f\n JOIN embeddings e ON e.id = f.${options.descriptions ? \"description_embedding_id\" : \"embedding_id\"}\n ${functionDescription ? \"JOIN embeddings d ON d.id = f.description_embedding_id\" : \"\"}\n ${fileDescription ? \"JOIN files described_file ON described_file.path = f.path JOIN embeddings fd ON fd.id = described_file.file_description_embedding_id\" : \"\"}\n WHERE (? IS NULL OR f.id != ?)\n ${pathFilter}\n AND f.line_count >= ?\n AND (? IS NULL OR slopdex_regexp(?, f.qualified_name))\n ), ranked AS (\n SELECT *, ${fused ? `(${scoreExpression}) / ${scoreCount}.0` : \"base_similarity\"} AS similarity\n FROM scores\n ), selected AS (\n SELECT * FROM ranked\n WHERE similarity >= ? AND (? IS NULL OR similarity < ?)\n ORDER BY similarity DESC, function_id ASC\n LIMIT ?\n )\n SELECT f.*, selected.similarity, selected.base_similarity\n ${functionDescription ? \", selected.description_similarity\" : \"\"}\n ${fileDescription ? \", selected.file_description_similarity\" : \"\"}\n FROM selected JOIN functions f ON f.id = selected.function_id\n ORDER BY selected.similarity DESC, f.id ASC\n `).all(\n vectorBuffer(vector),\n ...(options.descriptionVector ? [vectorBuffer(options.descriptionVector)] : []),\n ...(options.fileDescriptionVector ? [vectorBuffer(options.fileDescriptionVector)] : []),\n options.excludeId ?? null,\n options.excludeId ?? null,\n ...excludePaths,\n options.minLines ?? 1,\n options.nameRegex ?? null,\n options.nameRegex ?? null,\n options.minSimilarity,\n options.maxSimilarity ?? null,\n options.maxSimilarity ?? null,\n options.limit ?? -1,\n ) as unknown as Array<FunctionRow & {\n similarity: number;\n base_similarity: number;\n description_similarity?: number;\n file_description_similarity?: number;\n }>;\n return rows.map((row) => ({\n function: toIndexedFunction(row),\n similarity: row.similarity,\n ...(fused && !options.descriptions ? { codeSimilarity: row.base_similarity } : {}),\n ...(fused ? { descriptionSimilarity: options.descriptions ? row.base_similarity : row.description_similarity } : {}),\n ...(fileDescription ? { fileDescriptionSimilarity: row.file_description_similarity } : {}),\n }));\n }\n\n public vectorForFunction(id: number, kind: \"code\" | \"description\" = \"code\"): number[] {\n const row = this.#db.prepare(`\n SELECT e.vector FROM functions f\n JOIN embeddings e ON e.id = f.${kind === \"description\" ? \"description_embedding_id\" : \"embedding_id\"} WHERE f.id = ?\n `).get(id) as { vector: Uint8Array } | undefined;\n if (!row) throw new CodeIndexError(`Function ${id} does not exist or has no ${kind} embedding.`);\n return bufferVector(row.vector);\n }\n\n public vectorForFile(filePath: string): number[] {\n const row = this.#db.prepare(`\n SELECT e.vector FROM files f\n JOIN embeddings e ON e.id = f.file_description_embedding_id WHERE f.path = ?\n `).get(filePath) as { vector: Uint8Array } | undefined;\n if (!row) throw new CodeIndexError(`File ${filePath} does not exist or has no description embedding.`);\n return bufferVector(row.vector);\n }\n\n public fileVectorForFunction(id: number): number[] {\n const row = this.#db.prepare(`\n SELECT e.vector FROM functions fn\n JOIN files f ON f.path = fn.path\n JOIN embeddings e ON e.id = f.file_description_embedding_id\n WHERE fn.id = ?\n `).get(id) as { vector: Uint8Array } | undefined;\n if (!row) throw new CodeIndexError(`Function ${id} does not exist or its file has no description embedding.`);\n return bufferVector(row.vector);\n }\n\n public similarityCacheTriples(): Array<{\n functionId: number;\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n }> {\n return this.#db.prepare(`\n SELECT f.id AS functionId, f.embedding_id AS codeEmbeddingId,\n f.description_embedding_id AS descriptionEmbeddingId,\n files.file_description_embedding_id AS fileDescriptionEmbeddingId\n FROM functions f JOIN files ON files.path = f.path\n ORDER BY f.id\n `).all() as Array<{\n functionId: number;\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n }>;\n }\n\n public similarityCacheStates(mode: string): Map<number, {\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n cachedWidth: number;\n generation: number;\n floor: number;\n storedCount: number;\n complete: boolean;\n }> {\n const rows = this.#db.prepare(`\n SELECT function_id AS functionId, code_embedding_id AS codeEmbeddingId,\n description_embedding_id AS descriptionEmbeddingId,\n file_description_embedding_id AS fileDescriptionEmbeddingId,\n cached_width AS cachedWidth, generation, floor,\n stored_count AS storedCount, complete\n FROM similarity_cache_state WHERE similarity_mode = ?\n `).all(mode) as Array<{\n functionId: number;\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n cachedWidth: number;\n generation: number;\n floor: number;\n storedCount: number;\n complete: number;\n }>;\n return new Map(rows.map((row) => [row.functionId, {\n codeEmbeddingId: row.codeEmbeddingId,\n descriptionEmbeddingId: row.descriptionEmbeddingId,\n fileDescriptionEmbeddingId: row.fileDescriptionEmbeddingId,\n cachedWidth: row.cachedWidth,\n generation: row.generation,\n floor: row.floor,\n storedCount: Number(row.storedCount),\n complete: row.complete !== 0,\n }]));\n }\n\n public cachedSimilarityNeighbors(\n sourceId: number,\n mode: string,\n filter?: {\n limit: number;\n minSimilarity: number;\n maxSimilarity?: number;\n minLines?: number;\n nameRegex?: string;\n excludePaths?: readonly string[];\n },\n ): Array<SimilarityResult> {\n const excludePaths = filter?.excludePaths ?? [];\n const pathFilter = excludePaths.length > 0\n ? `AND f.path NOT IN (${excludePaths.map(() => \"?\").join(\", \")})`\n : \"\";\n const rows = this.#db.prepare(`\n SELECT f.*, c.similarity, c.similarity AS base_similarity,\n c.code_similarity AS code_similarity,\n c.description_similarity AS description_similarity,\n c.file_description_similarity AS file_description_similarity\n FROM similarity_cache c JOIN functions f ON f.id = c.target_id\n WHERE c.source_id = ? AND c.similarity_mode = ?\n AND c.similarity >= ?\n AND (? IS NULL OR c.similarity < ?)\n AND f.line_count >= ?\n AND (? IS NULL OR slopdex_regexp(?, f.qualified_name))\n ${pathFilter}\n ORDER BY c.similarity DESC, f.id ASC\n ${filter ? \"LIMIT ?\" : \"\"}\n `).all(\n sourceId,\n mode,\n filter?.minSimilarity ?? -1,\n filter?.maxSimilarity ?? null,\n filter?.maxSimilarity ?? null,\n filter?.minLines ?? 1,\n filter?.nameRegex ?? null,\n filter?.nameRegex ?? null,\n ...excludePaths,\n ...(filter ? [filter.limit] : []),\n ) as unknown as Array<FunctionRow & {\n similarity: number;\n base_similarity: number;\n code_similarity: number | null;\n description_similarity: number | null;\n file_description_similarity: number | null;\n }>;\n const fused = mode !== \"code\";\n return rows.map((row) => ({\n function: toIndexedFunction(row),\n similarity: row.similarity,\n ...(fused && row.code_similarity !== null ? { codeSimilarity: row.code_similarity } : {}),\n ...(fused && row.description_similarity !== null ? { descriptionSimilarity: row.description_similarity } : {}),\n ...(fused && row.file_description_similarity !== null ? { fileDescriptionSimilarity: row.file_description_similarity } : {}),\n }));\n }\n\n public storeSimilarityNeighbors(\n sourceId: number,\n mode: string,\n neighbors: readonly SimilarityResult[],\n state: {\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n cachedWidth: number;\n generation: number;\n floor: number;\n complete: boolean;\n },\n ): void {\n if (this.#readOnly) return;\n this.#transaction(() => {\n this.#db.prepare(\"DELETE FROM similarity_cache WHERE source_id = ? AND similarity_mode = ?\").run(sourceId, mode);\n const insert = this.#db.prepare(`\n INSERT INTO similarity_cache(\n source_id, target_id, similarity_mode, similarity,\n code_similarity, description_similarity, file_description_similarity\n ) VALUES (?, ?, ?, ?, ?, ?, ?)\n `);\n for (const neighbor of neighbors) {\n insert.run(\n sourceId,\n neighbor.function.id,\n mode,\n neighbor.similarity,\n neighbor.codeSimilarity ?? null,\n neighbor.descriptionSimilarity ?? null,\n neighbor.fileDescriptionSimilarity ?? null,\n );\n }\n this.#db.prepare(`\n INSERT INTO similarity_cache_state(\n function_id, code_embedding_id, description_embedding_id,\n file_description_embedding_id, similarity_mode, cached_width, generation,\n floor, stored_count, complete\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(function_id, similarity_mode) DO UPDATE SET\n code_embedding_id = excluded.code_embedding_id,\n description_embedding_id = excluded.description_embedding_id,\n file_description_embedding_id = excluded.file_description_embedding_id,\n cached_width = excluded.cached_width,\n generation = excluded.generation,\n floor = excluded.floor,\n stored_count = excluded.stored_count,\n complete = excluded.complete\n `).run(\n sourceId,\n state.codeEmbeddingId,\n state.descriptionEmbeddingId,\n state.fileDescriptionEmbeddingId,\n mode,\n state.cachedWidth,\n state.generation,\n state.floor,\n neighbors.length,\n state.complete ? 1 : 0,\n );\n });\n }\n\n public similarityCacheInfo(): { cachedSources: number; cachedPairs: number } {\n const sources = this.#db.prepare(\"SELECT COUNT(*) AS count FROM similarity_cache_state\").get() as { count: number };\n const pairs = this.#db.prepare(\"SELECT COUNT(*) AS count FROM similarity_cache\").get() as { count: number };\n return { cachedSources: Number(sources.count), cachedPairs: Number(pairs.count) };\n }\n\n public similarityCacheCounts(mode: string): Map<number, number> {\n const rows = this.#db.prepare(`\n SELECT source_id AS sourceId, COUNT(*) AS count\n FROM similarity_cache WHERE similarity_mode = ? GROUP BY source_id\n `).all(mode) as Array<{ sourceId: number; count: number }>;\n return new Map(rows.map((row) => [row.sourceId, Number(row.count)]));\n }\n\n public touchSimilarityCacheState(\n functionId: number,\n mode: string,\n state: {\n codeEmbeddingId: number;\n descriptionEmbeddingId: number | null;\n fileDescriptionEmbeddingId: number | null;\n cachedWidth: number;\n generation: number;\n floor: number;\n storedCount: number;\n complete: boolean;\n },\n ): void {\n if (this.#readOnly) return;\n this.#db.prepare(`\n INSERT INTO similarity_cache_state(\n function_id, code_embedding_id, description_embedding_id,\n file_description_embedding_id, similarity_mode, cached_width, generation,\n floor, stored_count, complete\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(function_id, similarity_mode) DO UPDATE SET\n code_embedding_id = excluded.code_embedding_id,\n description_embedding_id = excluded.description_embedding_id,\n file_description_embedding_id = excluded.file_description_embedding_id,\n cached_width = excluded.cached_width,\n generation = excluded.generation,\n floor = excluded.floor,\n stored_count = excluded.stored_count,\n complete = excluded.complete\n `).run(\n functionId,\n state.codeEmbeddingId,\n state.descriptionEmbeddingId,\n state.fileDescriptionEmbeddingId,\n mode,\n state.cachedWidth,\n state.generation,\n state.floor,\n state.storedCount,\n state.complete ? 1 : 0,\n );\n }\n\n public status(): IndexStatus {\n const functionCount = Number((this.#db.prepare(\"SELECT COUNT(*) AS count FROM functions\").get() as { count: number }).count);\n const fileCount = Number((this.#db.prepare(\"SELECT COUNT(*) AS count FROM files\").get() as { count: number }).count);\n const describableFileCount = Number((this.#db.prepare(`\n SELECT COUNT(*) AS count FROM files f\n WHERE NOT EXISTS (\n SELECT 1 FROM indexing_errors ie\n WHERE ie.path = f.path\n AND json_extract(ie.diagnostic, '$.code') IN ('read-error', 'file-too-large')\n )\n `).get() as { count: number }).count);\n return {\n rootDir: this.#rootDir,\n indexPath: this.#indexPath,\n functionCount,\n fileCount,\n generation: this.getGeneration(),\n gitCheckpoint: this.getCheckpoint(),\n embeddingProfile: this.#profile,\n descriptionsEnabled: this.descriptionsEnabled(),\n descriptionCount: Number((this.#db.prepare(\"SELECT COUNT(*) AS count FROM functions WHERE description_embedding_id IS NOT NULL\").get() as { count: number }).count),\n fileDescriptionCount: Number((this.#db.prepare(\"SELECT COUNT(*) AS count FROM files WHERE file_description_embedding_id IS NOT NULL\").get() as { count: number }).count),\n describableFileCount,\n staleFileDescriptionCount: Number((this.#db.prepare(`\n SELECT COUNT(*) AS count FROM files f\n WHERE (file_description_path IS NULL OR file_description_path != path\n OR file_description_content_hash IS NULL OR file_description_content_hash != content_hash)\n AND NOT EXISTS (\n SELECT 1 FROM indexing_errors ie\n WHERE ie.path = f.path\n AND json_extract(ie.diagnostic, '$.code') IN ('read-error', 'file-too-large')\n )\n `).get() as { count: number }).count),\n descriptionProfile: this.descriptionProfile(),\n indexingErrorCount: Number((this.#db.prepare(\"SELECT COUNT(*) AS count FROM indexing_errors\").get() as { count: number }).count),\n failedFileCount: this.filesWithErrors().length,\n };\n }\n\n public indexErrors(): IndexingError[] {\n return errorsFromDatabase(this.#db);\n }\n\n public filesWithErrors(): string[] {\n return (this.#db.prepare(\"SELECT DISTINCT path FROM indexing_errors\").all() as Array<{ path: string }>).map((row) => row.path);\n }\n\n public filesWithFileTooLargeErrors(): string[] {\n return (this.#db.prepare(\n \"SELECT DISTINCT path FROM indexing_errors WHERE json_extract(diagnostic, '$.code') = 'file-too-large'\",\n ).all() as Array<{ path: string }>).map((row) => row.path);\n }\n\n public needsDiagnosticsScan(): boolean {\n return this.#metadata(\"diagnostics_scan_pending\") === \"true\";\n }\n}\n\nexport function readIndexErrors(indexPath: string): IndexingError[] {\n const database = new DatabaseSync(indexPath, { readOnly: true });\n try {\n if (!database.prepare(\"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'indexing_errors'\").get()) return [];\n return errorsFromDatabase(database);\n } finally {\n database.close();\n }\n}\n\nexport function resetIndexState(\n indexPath: string,\n rootDir: string,\n profile: EmbeddingProfile,\n): void {\n const database = new DatabaseSync(indexPath, { allowExtension: true });\n try {\n sqliteVec.load(database);\n database.enableLoadExtension(false);\n database.exec(\"PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON;\");\n const metadata = new Map((database.prepare(\"SELECT key, value FROM metadata\").all() as Array<{ key: string; value: string }>)\n .map((row) => [row.key, row.value]));\n if (metadata.get(\"schema_version\") !== SCHEMA_VERSION) {\n throw new IncompatibleIndexError(`Unsupported index schema version ${metadata.get(\"schema_version\") ?? \"unknown\"}.`);\n }\n if (path.resolve(metadata.get(\"root_dir\") ?? \"\") !== path.resolve(rootDir)) {\n throw new IncompatibleIndexError(\"Index belongs to a different repository.\");\n }\n if (!Number.isInteger(profile.dimensions) || profile.dimensions <= 0) {\n throw new CodeIndexError(\"Embedding dimensions must be a positive integer.\");\n }\n database.exec(\"BEGIN IMMEDIATE\");\n try {\n database.exec(`\n DELETE FROM files;\n DROP TRIGGER IF EXISTS functions_vector_insert;\n DROP TRIGGER IF EXISTS functions_vector_delete;\n DROP TRIGGER IF EXISTS functions_vector_update;\n DROP TABLE IF EXISTS function_vectors;\n DELETE FROM callable_provenance;\n DELETE FROM metadata;\n `);\n if (profile.dimensions <= VEC0_MAX_DIMENSIONS) database.exec(functionVectorsSchema(profile.dimensions));\n const setMetadata = database.prepare(\"INSERT INTO metadata(key, value) VALUES (?, ?)\");\n setMetadata.run(\"schema_version\", SCHEMA_VERSION);\n setMetadata.run(\"root_dir\", path.resolve(rootDir));\n setMetadata.run(\"embedding_profile\", JSON.stringify({\n provider: profile.provider,\n model: profile.model,\n dimensions: profile.dimensions,\n strategyVersion: profile.strategyVersion ?? \"callable-v2\",\n }));\n setMetadata.run(\"generation\", \"0\");\n database.exec(\"COMMIT\");\n } catch (error) {\n database.exec(\"ROLLBACK\");\n throw error;\n }\n } finally {\n database.close();\n }\n}\n\nexport function readIndexErrorCounts(indexPath: string): { errors: number; files: number } {\n const database = new DatabaseSync(indexPath, { readOnly: true });\n try {\n if (!database.prepare(\"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'indexing_errors'\").get()) {\n return { errors: 0, files: 0 };\n }\n const counts = database.prepare(\"SELECT COUNT(*) AS errors, COUNT(DISTINCT path) AS files FROM indexing_errors\").get() as { errors: number; files: number };\n return { errors: Number(counts.errors), files: Number(counts.files) };\n } finally {\n database.close();\n }\n}\n\nfunction errorsFromDatabase(database: DatabaseSync): IndexingError[] {\n const rows = database.prepare(`\n SELECT e.id, e.diagnostic, f.source_mode, f.indexed_commit\n FROM indexing_errors e JOIN files f ON f.path = e.path\n ORDER BY e.path, e.id\n `).all() as Array<{ id: number; diagnostic: string; source_mode: SourceMode; indexed_commit: string | null }>;\n return rows.map((row) => ({\n ...JSON.parse(row.diagnostic) as IndexingIssue,\n id: row.id, sourceMode: row.source_mode, indexedCommit: row.indexed_commit,\n }));\n}\n\nfunction similarityCacheSchema(): string {\n return `\n CREATE TABLE IF NOT EXISTS similarity_cache (\n source_id INTEGER NOT NULL REFERENCES functions(id) ON DELETE CASCADE,\n target_id INTEGER NOT NULL REFERENCES functions(id) ON DELETE CASCADE,\n similarity_mode TEXT NOT NULL,\n similarity REAL NOT NULL,\n code_similarity REAL,\n description_similarity REAL,\n file_description_similarity REAL,\n PRIMARY KEY (source_id, target_id, similarity_mode)\n );\n CREATE INDEX IF NOT EXISTS similarity_cache_source ON similarity_cache(source_id, similarity_mode, similarity DESC);\n CREATE INDEX IF NOT EXISTS similarity_cache_target ON similarity_cache(target_id, similarity_mode);\n CREATE TABLE IF NOT EXISTS similarity_cache_state (\n function_id INTEGER NOT NULL REFERENCES functions(id) ON DELETE CASCADE,\n similarity_mode TEXT NOT NULL,\n code_embedding_id INTEGER NOT NULL,\n description_embedding_id INTEGER,\n file_description_embedding_id INTEGER,\n cached_width INTEGER NOT NULL,\n generation INTEGER NOT NULL,\n floor REAL NOT NULL DEFAULT -1,\n stored_count INTEGER NOT NULL DEFAULT 0,\n complete INTEGER NOT NULL DEFAULT 0,\n PRIMARY KEY (function_id, similarity_mode)\n );\n `;\n}\n\nfunction functionVectorsSchema(dimensions: number): string {\n return `\n CREATE VIRTUAL TABLE function_vectors USING vec0(\n function_id INTEGER PRIMARY KEY,\n embedding FLOAT[${dimensions}] distance_metric=cosine,\n line_count INTEGER,\n path TEXT,\n function_id_filter INTEGER\n );\n INSERT INTO function_vectors(function_id, embedding, line_count, path, function_id_filter)\n SELECT f.id, e.vector, f.line_count, f.path, f.id\n FROM functions f JOIN embeddings e ON e.id = f.embedding_id;\n CREATE TRIGGER functions_vector_insert AFTER INSERT ON functions BEGIN\n INSERT INTO function_vectors(function_id, embedding, line_count, path, function_id_filter)\n SELECT new.id, e.vector, new.line_count, new.path, new.id FROM embeddings e WHERE e.id = new.embedding_id;\n END;\n CREATE TRIGGER functions_vector_delete AFTER DELETE ON functions BEGIN\n DELETE FROM function_vectors WHERE function_id = old.id;\n END;\n CREATE TRIGGER functions_vector_update AFTER UPDATE OF embedding_id, line_count, path ON functions BEGIN\n DELETE FROM function_vectors WHERE function_id = old.id;\n INSERT INTO function_vectors(function_id, embedding, line_count, path, function_id_filter)\n SELECT new.id, e.vector, new.line_count, new.path, new.id FROM embeddings e WHERE e.id = new.embedding_id;\n END;\n `;\n}\n\nfunction vectorBuffer(vector: readonly number[]): Uint8Array {\n const values = Float32Array.from(vector);\n return new Uint8Array(values.buffer);\n}\n\nfunction bufferVector(vector: Uint8Array): number[] {\n return Array.from(new Float32Array(vector.buffer, vector.byteOffset, vector.byteLength / 4));\n}\n\nfunction toIndexedFunction(row: FunctionRow): IndexedFunction {\n return {\n id: row.id,\n path: row.path,\n language: row.language,\n kind: row.kind,\n name: row.name,\n qualifiedName: row.qualified_name,\n signature: row.signature,\n identityKey: row.identity_key,\n startLine: row.start_line,\n startColumn: row.start_column,\n endLine: row.end_line,\n endColumn: row.end_column,\n lineCount: row.line_count,\n source: row.source,\n sourceHash: row.source_hash,\n embeddingInput: row.embedding_input,\n firstSeenCommit: row.first_seen_commit,\n lastSeenCommit: row.last_seen_commit,\n sourceMode: row.source_mode,\n embeddingId: row.embedding_id,\n description: row.description,\n descriptionEmbeddingId: row.description_embedding_id,\n };\n}\n\nfunction reconcileFunctions(\n current: readonly PreparedCallable[],\n previous: readonly FunctionRow[],\n): Map<PreparedCallable, FunctionRow> {\n const matches = new Map<PreparedCallable, FunctionRow>();\n const keys = new Set([\n ...current.map((callable) => `${callable.qualifiedName}\\0${callable.kind}`),\n ...previous.map((callable) => `${callable.qualified_name}\\0${callable.kind}`),\n ]);\n for (const key of keys) {\n const currentGroup = current.filter((callable) => `${callable.qualifiedName}\\0${callable.kind}` === key);\n const previousGroup = previous.filter((callable) => `${callable.qualified_name}\\0${callable.kind}` === key);\n const unmatchedPrevious = new Set(previousGroup);\n const unmatchedCurrent = new Set(currentGroup);\n for (const callable of currentGroup) {\n const exact = [...unmatchedPrevious].find((old) => old.source_hash === callable.sourceHash);\n if (exact) {\n matches.set(callable, exact);\n unmatchedPrevious.delete(exact);\n unmatchedCurrent.delete(callable);\n }\n }\n for (const callable of unmatchedCurrent) {\n const old = unmatchedPrevious.values().next().value as FunctionRow | undefined;\n if (!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