/** * SQLite implementation of KnowledgeIndex using the Node standard library * (`node:sqlite`, Node >= 22) — zero npm dependencies (design DD1). * * FTS5 powers full-text search; if the runtime's SQLite build lacks FTS5 the * index falls back to LIKE matching with a one-time stderr warning. The * database is a disposable cache at `.aidlc/knowledge/index.db`, gitignored * and rebuildable from YAML at any time (KG Req 3.1–3.3). * * Requirements: KG 3.1–3.8, 10.1–10.3, 11.4 * * @module */ import type { Entity, Relationship } from '../types.js'; import type { KnowledgeIndex, SearchOptions, EntityFilter } from './knowledge-index.js'; /** Filename of the index database inside the knowledge directory. */ export declare const INDEX_DB_FILE = "index.db"; /** * Schema version of the index **cache**, deliberately separate from * `KNOWLEDGE_SCHEMA_VERSION`, which versions the YAML **sources**. * * One constant used to serve both. Bumping it to add this version's * `source_fingerprint` table would also have stamped `schemaVersion: 2` into every * YAML `_meta` the next `compact` rewrote, and an older CLI reading those files warns * about them (`yaml-source.ts`) — user-visible churn in the source of truth caused by * a change to a cache. Splitting them costs this comment and one import * (knowledge-index-misses-merged-yaml/AC-14, design DD3). * * Version 2 adds `source_fingerprint`. An index at version 1 is discarded and rebuilt * by the `IndexOutdatedError` path `openKnowledge` already owns (AC-11). */ export declare const INDEX_SCHEMA_VERSION = 2; export declare class SqliteIndex implements KnowledgeIndex { private readonly db; private ftsAvailable; private ftsWarned; /** * @param knowledgeDir - Directory holding YAML sources; index.db is created here. * @param dbPathOverride - Test hook: use ':memory:' for an ephemeral index. */ constructor(knowledgeDir: string, dbPathOverride?: string); private ensureSchema; private readSchemaVersion; private createSchema; getEntity(id: string): Entity | undefined; upsertEntity(entity: Entity): void; deleteEntity(id: string): void; fullTextSearch(term: string, options?: SearchOptions): Entity[]; private ftsSearch; private likeSearch; getAllEntities(filter?: EntityFilter): Entity[]; getEntitiesByTypes(types: string[], filter?: EntityFilter): Entity[]; getEntitiesByFilePath(path: string): Entity[]; countEntitiesByType(type: string): number; upsertRelationship(rel: Relationship): void; relationshipsFrom(id: string): Relationship[]; relationshipsTo(id: string): Relationship[]; relationshipsFor(ids: string[]): Relationship[]; countRelationshipsByType(type: string): number; rebuild(entities: Entity[], relationships: Relationship[], fingerprint?: string | null): void; getSourceFingerprint(): string | null; setSourceFingerprint(fingerprint: string): void; private writeFingerprint; close(): void; private syncFts; private syncFileMapping; private warnNoFts; } /** Split camelCase and kebab/snake-case identifiers into searchable words. */ export declare function normalizeSearchText(text: string): string; //# sourceMappingURL=sqlite-index.d.ts.map