maintenance.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Maintenance - Database cleanup operations for QMD.
  3. *
  4. * Wraps low-level store operations that the CLI needs for housekeeping.
  5. * Takes an internal Store in the constructor — allowed to access DB directly.
  6. */
  7. import { vacuumDatabase, cleanupOrphanedContent, cleanupOrphanedVectors, deleteLLMCache, deleteInactiveDocuments, clearAllEmbeddings, } from "./store.js";
  8. export class Maintenance {
  9. store;
  10. constructor(store) {
  11. this.store = store;
  12. }
  13. /** Run VACUUM on the SQLite database to reclaim space */
  14. vacuum() {
  15. vacuumDatabase(this.store.db);
  16. }
  17. /** Remove content rows that are no longer referenced by any document */
  18. cleanupOrphanedContent() {
  19. return cleanupOrphanedContent(this.store.db);
  20. }
  21. /** Remove vector embeddings for content that no longer exists */
  22. cleanupOrphanedVectors() {
  23. return cleanupOrphanedVectors(this.store.db);
  24. }
  25. /** Clear the LLM response cache (query expansion, reranking) */
  26. clearLLMCache() {
  27. return deleteLLMCache(this.store.db);
  28. }
  29. /** Delete documents marked as inactive (removed from filesystem) */
  30. deleteInactiveDocs() {
  31. return deleteInactiveDocuments(this.store.db);
  32. }
  33. /** Clear all vector embeddings (forces re-embedding) */
  34. clearEmbeddings() {
  35. clearAllEmbeddings(this.store.db);
  36. }
  37. }