fix: include line in CLI --json search output#533
Merged
Conversation
but that function has no callers — the CLI's outputResults() uses its own inline JSON formatting that destructured only .snippet from extractSnippet(), discarding .line. Extract the full SnippetResult and spread the line field into the JSON output object. Closes tobi#505
Contributor
Author
|
CI note: The Re-running the job will likely pass — the failure depends on Bun's test file execution order. |
tanarchytan
referenced
this pull request
in tanarchytan/lotl
Apr 14, 2026
Audited tobi/qmd's 458 commits since our fork divergence, filtered to post-cleanup-compatible fixes (skipped node-llama-cpp / Qwen3 / GGUF specific ones since we removed those layers in the 2026-04-13 cleanup). Already had (verified during audit, no action): - 09a4d19 fix(store): error on embedding dimension mismatch (#501) - ef062e1 fix(multi-get): brace expansion glob (#424) - 0212363 fix(mcp): read version from package.json (#431) Cherry-picked tonight: - 77e71d0 fix: USERPROFILE fallback for Windows HOME (max0n232) src/store/path.ts: HOME = HOME || USERPROFILE || /tmp. Critical for MCP subprocess case on Windows where Claude Code passes USERPROFILE but not HOME, causing QMD to open an empty /tmp DB. - 9dd8a73 fix(mcp): enableProductionMode before getDefaultDbPath (jungholee) src/mcp/server.ts: imports + calls enableProductionMode at module init. CLI users already get this via cli/qmd.ts:110, but SDK consumers importing the MCP server directly hit the production-mode guard on getDefaultDbPath. This is the same race upstream fixed. - 0adbdeb fix(store): surface actionable sqlite-vec guidance (Tobi) src/store/db-init.ts: track _sqliteVecUnavailableReason at init time so ensureVecTableInternal can throw with the original cause instead of a generic "extension not available" message. Reuses our existing createSqliteVecUnavailableError helper. - 17074ea fix: include line in CLI --json output (rymalia, #533) src/cli/qmd.ts: outputResults JSON branch now emits snippetInfo.line alongside the snippet so JSON consumers can navigate to the right source line. Skipped (post-cleanup incompatible): - f53ee26 fix: detect non-GGUF model files - we removed node-llama-cpp - 6db34d7 fix(llm): catch GPU init failures - llama.cpp specific - 8644fa9 fix(store): thread embed model URI to format functions - uses Qwen3 detection (formatQueryForEmbedding Qwen3 branch) which we ripped out tonight. The format function exists, but the Qwen3 conditional doesn't. - 54550a3 fix(llm): explicit embed context size - llama.cpp specific - 1ecb5c9 Fix QMD_LLAMA_GPU backend override - QMD_LLAMA_* env vars removed in cleanup - 26e3d0c fix(status): avoid build attempts during device probe - device probe was LlamaCpp-specific, removed in cleanup - handelize chain (9fb9de4 -> 9c9de94 -> 828823d -> fee576b) - upstream briefly removed .toLowerCase(), broke things, reverted, added a migration for users hit by the broken window. We never participated in that experiment so the chain is a no-op for us. Deferred (real feature, too invasive for tonight): - 8404cc3 fix(uri): include index in custom qmd links - adds index segment to qmd:// URI parsing so CLI commands can switch indexes inline. Requires schema change to VirtualPath type (currently {collectionName, path}, would need optional indexName field) plus call sites in get/multi-get. Worth porting in a separate session. Also need to verify (separate work): - 3023ab3 fix: bump transitive deps for security alerts - need to cross-reference against our package-lock.json since our dep set diverged after the node-llama-cpp removal. Tests: pick-vector-matches + memory-eviction + mcp suite all green (66 pass / 3 skipped). Full suite deferred until phase 5 completes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lucndm
pushed a commit
to lucndm/qmd
that referenced
this pull request
Jun 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--jsonsearch output now includes alinefield (1-indexed) pointing to the best-matching line in the document, enabling editor integrations likecode --goto file:lineProblem
#505 requested a
linefield in--jsonoutput for editor integrations. #506 was merged to fix it, but the fix landed insearchResultsToJson()informatter.ts— a function with no callers. The CLI's actual JSON output is generated byoutputResults()inqmd.ts, which has its own inline formatting. That inline path destructured only.snippetfromextractSnippet(), discarding the.lineproperty.Fix
Extract the full
SnippetResultfromextractSnippet()and spreadlineinto the JSON output object — matching what the CLI display path already does for terminal output.Before:
{"file": "qmd://blog/post.md", "snippet": "@@ -42,4 @@ ..."}After:
{"file": "qmd://blog/post.md", "line": 42, "snippet": "@@ -42,4 @@ ..."}Test plan
qmd search "term" --jsonincludeslinefield in each resultqmd query "term" --jsonincludeslinefield in each resultqmd search "term" --json --fullomitsline(no snippet extraction when showing full body)npx vitest run test/cli.test.ts— 91/91)Closes #505
🤖 Generated with Claude Code