title: in qmd status, list all the additonal contexts under the collections that match

status: closed

issue_type: task


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.

type: parent-child

created_by: daemon


title: Update tests for YAML-based collections

description: Update all tests to use YAML config instead of DB collections. Update test helpers to create temporary YAML configs.

notes:
Test suite has been updated for YAML-based collections. 92 tests passing, 4 skipped, 10 failing.

The 4 skipped tests call getStatus() which has a bug (queries non-existent collections table).

The 10 failing tests are due to bugs in store.ts functions (findDocument, getDocumentBody, getDocument, findSimilarFiles, matchFilesByGlob) that need to be updated to use YAML configuration. These are production code bugs, not test bugs.

depends_on_id: qmd-thw

type: blocks


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: Fix store.ts functions to use YAML collections

description: Update findDocument(), getDocumentBody(), getDocument(), findSimilarFiles(), matchFilesByGlob(), and getStatus() to use YAML collection configuration instead of querying the collections table. These functions currently fail because they try to query the non-existent collections table.

issue_type: bug


title: Design YAML schema and create collections.ts module

description: Create collections.ts to manage YAML-based collection configuration at ~/.config/qmd/index.yml. Define TypeScript types for collections and contexts. Implement load/save functions with Bun's native YAML support.

design:
YAML structure:
```yaml
# Global context for all collections
global_context: "..."

collections:
  name:
    path: /absolute/path
    pattern: "**/*.md"
    context:
      "/path/prefix": "Description"
      "/": "Root context"
```

TypeScript types:
- Collection: { path, pattern, context }
- CollectionConfig: { global_context?, collections }
- Functions: loadConfig(), saveConfig(), getCollection(), listCollections()


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).

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: Export current database to index.yml

description: Write a script to export current collections and path_contexts from SQLite to ~/.config/qmd/index.yml format. Include all collection metadata and contexts.


title: remove all the symlinks and stuff in the git repo, clean up the root directory


title: Update documents table schema for collection names

description: Change documents.collection_id (integer FK) to documents.collection (text). Update all queries and indices. Keep backwards compatibility during transition.

design:
Schema change:
- Add `collection TEXT` column
- Migrate data: UPDATE documents SET collection = (SELECT name FROM collections WHERE id = collection_id)
- Drop collection_id column
- Update FTS5 trigger
- Update all queries in store.ts


title: Update all qmd commands for YAML-based collections

description: Update qmd.ts commands: collection add/list/remove/rename, status, update, ls. All should use collections.ts instead of store.ts collection functions.

depends_on_id: qmd-oxy


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: Update documentation for YAML configuration

description: Update CLAUDE.md, README.md with new YAML configuration approach. Document index.yml format and manual editing instructions.

status: open


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.


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: Redesign context add command for better usability

description:
Current issues:
1. Virtual path qmd://journals/ is rejected as invalid
2. Syntax is confusing - sometimes path is first arg, sometimes second
3. Need to support collection root context (qmd://name/)
4. Should be intuitive: qmd context add <where> <what>
Design goals:
- Support qmd://collection/ for collection root context
- Support qmd://collection/path for path-specific context
- Clear, consistent syntax
- Good error messages


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: look for missing context

description: i ran qmd context list and thats only one bit of context, i had a lot more. i think the path matching isn't quite working right


title: Update context system to use YAML

description: Remove path_contexts table. Implement context management in collections.ts. Update context add/list/rm commands to modify YAML file instead of database.

issue_id: qmd-oxy


title: Create collection add|remove


title: move the source files to src/*, clean up teh directory


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: Drop collections and path_contexts tables

description: Remove collections and path_contexts tables from schema. Update initDb() to not create these tables. Only keep documents, content, and search indices.

issue_id: qmd-thw


title: Refactor store.ts to use collections.ts

description: Replace all collection DB queries with collections.ts calls. Remove getCollectionById, getCollectionByName, listCollections DB functions. Use YAML config instead.


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


title: for each collection, on update, check if there is a .git directory, if so write out the git status, add --pull as a qmd update --pull parameter which also executes git pull before reindexing


title: Add optional update: command support to collections YAML

description: Collections can now specify an optional 'update:' key with a bash command that will be executed during 'qmd update' before indexing files. Runs in cwd, prints output, stops on error.


title: Improve qmd ls command to be more like ls -l with colors

description:
Make qmd ls more Unix-like:
1. Format like ls -l with columns (permissions, size, date, name)
2. Add colors (directories, files, etc.)
3. Dim the qmd:// prefix to show it's optional
4. Show file sizes in human-readable format
5. Show modification times
6. Consider adding -l flag for long format