What
Replace smriti's manual DB setup and deep QMD imports with the stable public SDK.
Phase 1 — DB init via createStore()
Currently initSmriti() manually opens the SQLite database, calls loadSqliteVec(), and runs QMD table setup. Replace with:
```ts
const store = await createStore({ dbPath: QMD_DB_PATH });
// store.internal.db is now the shared Database handle
// QMD handles its own table init and sqlite-vec loading
runSmritiMigrations(store.internal.db);
```
Files: src/db.ts, src/index.ts
Phase 2 — Kill deep imports in memory.ts
Replace every ../qmd/src/ import with InternalStore equivalents:
| Current |
Replacement |
insertEmbedding(db, ...) |
store.insertEmbedding(...) |
Manual CREATE VIRTUAL TABLE vectors_vec |
store.ensureVecTable(dimensions) |
getDefaultLlamaCpp() + manual embed loop |
store.internal.llm |
chunkDocumentByTokens() |
move to smriti util or keep as single import |
reciprocalRankFusion() |
keep as single import (not on InternalStore) |
hashContent() |
replace with Bun.CryptoHasher (SHA256, 3 lines) |
Files: src/memory.ts
After this: src/memory.ts has zero ../qmd/src/ deep imports.
Why
Deep imports into ../qmd/src/store.js and ../qmd/src/llm.js break silently on any upstream QMD refactor. Every upstream sync is a potential breakage point. The public InternalStore API is stable and intentional.
Acceptance Criteria
What
Replace smriti's manual DB setup and deep QMD imports with the stable public SDK.
Phase 1 — DB init via
createStore()Currently
initSmriti()manually opens the SQLite database, callsloadSqliteVec(), and runs QMD table setup. Replace with:```ts
const store = await createStore({ dbPath: QMD_DB_PATH });
// store.internal.db is now the shared Database handle
// QMD handles its own table init and sqlite-vec loading
runSmritiMigrations(store.internal.db);
```
Files:
src/db.ts,src/index.tsPhase 2 — Kill deep imports in
memory.tsReplace every
../qmd/src/import withInternalStoreequivalents:insertEmbedding(db, ...)store.insertEmbedding(...)CREATE VIRTUAL TABLE vectors_vecstore.ensureVecTable(dimensions)getDefaultLlamaCpp()+ manual embed loopstore.internal.llmchunkDocumentByTokens()reciprocalRankFusion()hashContent()Bun.CryptoHasher(SHA256, 3 lines)Files:
src/memory.tsAfter this:
src/memory.tshas zero../qmd/src/deep imports.Why
Deep imports into
../qmd/src/store.jsand../qmd/src/llm.jsbreak silently on any upstream QMD refactor. Every upstream sync is a potential breakage point. The publicInternalStoreAPI is stable and intentional.Acceptance Criteria
src/db.tsusescreateStore()for DB init — no manualloadSqliteVec()src/memory.tshas no imports from../qmd/src/smriti status,smriti recall,smriti ingestwork correctly