diff --git a/src/qmd.ts b/src/qmd.ts index 35f9502..9845c1a 100755 --- a/src/qmd.ts +++ b/src/qmd.ts @@ -18,6 +18,7 @@ import { removeCollection, renameCollection, findSimilarFiles, + findDocumentByDocid, matchFilesByGlob, getHashesNeedingEmbedding, getHashesForEmbedding, @@ -697,6 +698,18 @@ function getDocument(filename: string, fromLine?: number, maxLines?: number, lin } } + // Handle docid lookup (#hash or 6-char hex) + if (inputPath.startsWith('#') || /^[a-f0-9]{6}$/i.test(inputPath)) { + const docidMatch = findDocumentByDocid(db, inputPath); + if (docidMatch) { + inputPath = docidMatch.filepath; + } else { + console.error(`Document not found: ${filename}`); + closeDb(); + process.exit(1); + } + } + let doc: { collectionName: string; path: string; body: string } | null = null; let virtualPath: string;