title: Move cleanup/maintenance DB operations to store.ts

description: Move cleanup operations from cleanup() command to store.ts. Create methods like deleteInactiveDocuments(), vacuumDatabase(), cleanupOrphanedContent(), etc.

status: open

issue_type: task

type: parent-child

created_by: daemon


title: Move all database operations from qmd.ts to store.ts

description: Currently qmd.ts has ~70 direct database operations (db.prepare, db.exec). All database operations should be moved to store.ts to improve separation of concerns. qmd.ts should only use high-level methods from store.ts that don't require direct SQL knowledge.

notes: Phase 1 complete: Moved collection operations (listCollections, removeCollection, renameCollection) to store.ts. Created 4 subtasks for remaining work: document indexing, context management, embeddings, and cleanup operations.


title: Update document retrieval for new schema

description: Functions like getDocument, findDocument, getMultipleDocuments need to work with new schema (path instead of filepath, content joins, virtual paths).

status: closed

depends_on_id: qmd-ama

type: discovered-from


title: Move embedding/vector DB operations to store.ts

description: Move vector indexing DB operations from vectorIndex() to store.ts. Create methods like getHashesForEmbedding(), insertEmbedding(), clearEmbeddings(), etc.


title: implement qmd collection rename, which changes the global path prefix for the collection


title: Refactor database system

description:
All documents should be stored as content addressable hash, e.g. hash, doc, created_at,
┃ updated_at. documents should be a file system layer on top e.g. collection, path, hash,
┃ created_at, updated_at. (collection,path)
┃
┃

┃ All documents should be stored as content addressable hash, e.g. hash, doc, created_at,
┃ updated_at. documents should be a file system layer on top e.g. collection_id, path, hash,
┃ created_at, updated_at. (collection,path) is unique. There is also collection which stores PWD
┃ + glob pattern, name (\w+). Every document is treated as path qmd://collection.name/

notes:
## Completed
- ✅ Implemented content-addressable storage (content table with hash→doc mapping)
- ✅ Refactored documents table as file system layer (collection_id, path, hash)
- ✅ Added collection names (e.g., "pages", "journals", "archive")
- ✅ Implemented virtual paths (qmd://collection-name/path/to/file.md)
- ✅ Added hierarchical context support (collection-scoped)
- ✅ Successfully migrated existing database
- ✅ Updated search functions to work with new schema
- ✅ Updated indexing logic to use content-addressable storage
- ✅ Orphaned content hash cleanup

## Still TODO
- Fix migration SQL to properly extract basename (currently needs manual fix)
- Implement `qmd collection add . --name <name> --mask '**/*.md'`
- Implement `qmd ls [path]` for exploring virtual file tree


title: Fix migration SQL for proper basename extraction

description: The migration currently generates collection names incorrectly (uses full path instead of basename). Need to fix the SQL in migrateToContentAddressable to properly extract the directory basename.

issue_type: bug


title: Comprehensive CLI review and consistency pass

description:
Review entire CLI command structure:
- Consistent naming (add vs create, remove vs delete)
- Consistent flag usage (--name, --mask, etc)
- Update help text for all commands
- Ensure virtual paths work everywhere
- Test all commands end-to-end


title: fix embed


title: Refactor database introduce qmd collection *


title: Implement 'qmd collection' commands

description:
Add explicit collection management:
- qmd collection add . --name <name> --mask '**/*.md'
- qmd collection list
- qmd collection remove <name>

This gives users control over collection names and patterns.

issue_type: feature

issue_id: qmd-dmi


title: Implement 'qmd ls' command

description:
Add command to explore virtual file tree:
- qmd ls → list all collections
- qmd ls <collection> → list files in collection
- qmd ls <collection>/<path> → list files under path
Output: flat list of qmd:// paths


title: Move context management DB operations to store.ts

description: Move path_contexts INSERT/DELETE/SELECT operations from addContext(), listContexts(), removeContext() to store.ts. Create methods like insertContext(), deleteContext(), etc.


title: Add unit tests for content addressable hashes

description: add same file from multiple places and verify that they both point at same hash. drop one collection and the content stays.


title: Move document indexing DB operations to store.ts

description: Move INSERT/UPDATE/DELETE operations for documents and content tables from indexFiles() to store.ts. Create methods like insertDocument(), updateDocument(), deactivateDocuments(), etc.


title: Create collection add|remove


title: Fix 'qmd status' output for new schema

description: Update status to show collections by name, cleaner context display, virtual path examples.

issue_id: qmd-rhd


title: Update 'qmd add-context' for collection scoping

description: Update add-context to work with collection-scoped contexts using new path_contexts schema.

notes:
Refactoring to:
- qmd context add [path] "text" (defaults to current collection if in one)
- qmd context list
- qmd context rm <path>
- Support "/" for global/system context
- Auto-detect collection from pwd


title: Update 'qmd get' to support virtual paths

description: Allow qmd get to accept both virtual paths (qmd://journals/...) and filesystem paths, plus fuzzy matching by filename.

issue_id: qmd-vro


title: Update 'qmd add-context' for collection-scoped contexts

description:
Update add-context to work with collections:
- qmd add-context <collection>/<path> "context description"
- Support both virtual and filesystem paths
- Update to use new path_contexts schema