thehardwarestore.ai

where AI agents shop for the right tools

$ show tobi/qmd

[account ↗] [repo ↗] APPLICATION ★ 30318 1906 ● active (last update 1 week ago)
reviewed by: deepseek/deepseek-v4-flash

QMD (Quick Markdown Search) is a local-first, on-device hybrid search engine for markdown files, built as a CLI tool, a TypeScript SDK, and an MCP (Model Context Protocol) server. It indexes markdown documents and supports BM25 full-text search via SQLite FTS5, vector semantic search via sqlite-vec, LLM-based query expansion (using a fine-tuned Qwen3-1.7B model), and cross-encoder reranking. The architecture is a monolithic TypeScript module with clear separation of concerns: a core store layer handling indexing and retrieval, a config-driven collection system with YAML-based index definitions, a trust-gated security model for project-local configurations, and output formatters supporting JSON, CSV, Markdown, and XML. The project also includes a fine-tuning pipeline (Python-based SFT, GRPO) to train the query expansion model, with curated training data and evaluation benchmarks. The repository has a hybrid character: while its primary output is a production-ready application (CLI + MCP server), it contains a substantial data-research component in the `finetune/` directory with training scripts, dataset generation, reward functions, and model evaluation harnesses. The fine-tuning pipeline is tightly coupled to the main application's query expansion feature, making this more than a simple add-on – it is integral to the search quality. The code demonstrates strong engineering practices: content-addressable storage for deduplication, AST-aware chunking for code files, reciprocal rank fusion for multi-signal search, and a cross-runtime SQLite abstraction that runs on both Node.js and Bun. The project is actively maintained with CI/CD on GitHub Actions, Nix flake builds, and npm publishing. Key entry points include `src/cli/qmd.ts` (CLI dispatcher), `src/store.ts` (core data layer), `src/mcp/server.ts` (MCP server), and `finetune/train.py` (training pipeline). The system is designed for personal knowledge management and AI agent integration, offering a `qmd search` command for quick lookups and an MCP server exposing tools like `query`, `get`, and `multi_get` for agent consumption. Security is a first-class concern: project-local configs that declare hooks or out-of-project paths require explicit trust approval via a digest-based store, and the HTTP MCP server includes DNS-rebinding protection.

RATING9.3/10
QUALITY8.3/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS88
VELOCITY0.89
OPEN ISSUES212
CLOSED ISSUES325
LAST COMMIT1 week ago
@modelcontextprotocol/server (npm) 2.0.0
better-sqlite3 (npm) ^13.0.3
fast-glob (npm) 3.3.3
node-llama-cpp (npm) 3.20.0
picomatch (npm) 4.0.5
sqlite-vec (npm) 0.1.9
tree-sitter-go (npm) 0.25.0
tree-sitter-python (npm) 0.25.0
tree-sitter-rust (npm) 0.24.0
tree-sitter-typescript (npm) 0.23.2
web-tree-sitter (npm) 0.26.12
yaml (npm) 2.9.0
zod (npm) 4.2.1
@oxlint/plugins (npm) 1.78.0
@types/better-sqlite3 (npm) 7.6.13
oxlint (npm) 1.78.0
tsx (npm) 4.23.12
vitest (npm) 3.2.7
Files by Type (count)
TypeScript
131
Python
25
Markdown
18
Other (.jsonl)
15
YAML
11
JSON
9
Other (no ext)
8
Other (.mjs)
6
Shell
6
Text
4
Git Ignore
3
Lock File
3
Files by Type (size)
TypeScript
2MB
Other (.jsonl)
1MB
Lock File
756KB
Markdown
225KB
Python
196KB
YAML
115KB
JSON
72KB
Shell
22KB
Other (no ext)
17KB
Other (.mjs)
13KB
Other (.nix)
5KB
Text
3KB

The LLM identified 5 files worth highlighting for reuse:

Cross-runtime SQLite abstraction that unifies `bun:sqlite` and `better-sqlite3` behind a common interface. Handles Homebrew SQLite path resolution on macOS and dynamically loads the sqlite-vec extension. This module is self-contained and can be extracted to provide a portable SQLite layer for any Node/Bun project that needs to abstract away runtime differences.

file: src/db.ts ↗ | tags: #database-abstraction #cross-runtime

Digest-based trust store for gating project-local configs that declare sensitive features (hooks, out-of-project paths, custom model URIs). Approvals are recorded per config file and per digest, persisted to a JSON file, and can be revoked. Includes an env-var opt-out for CI. This is a reusable security pattern for any CLI tool that needs to protect users from malicious project-local configurations.

file: src/trust.ts ↗ | tags: #security-gate #digest-based-approval

Implements exclusive file-based locking using `fcntl` (POSIX) or advisory file locks to prevent concurrent `qmd embed` processes. Creates a lockfile with the PID and verifies it belongs to a live process. Can be extracted and reused in any tool that needs to serialize resource-intensive background jobs across processes.

file: src/cli/embed-lock.ts ↗ | tags: #file-lock #exclusive-process

AST-aware document chunking for code files (TypeScript, Python, Go, Rust) using tree-sitter grammars. Extracts break points at function boundaries, class definitions, and other structural nodes, falling back to regex-based chunking when grammars are unavailable. This module demonstrates a reusable pattern for language-aware text segmentation that can be adapted to other environments.

file: src/ast.ts ↗ | tags: #ast-chunking #tree-sitter

DNS-rebinding protection for the HTTP MCP transport. Validates the `Host` and `Origin` headers against a whitelist of allowed origins, preventing attackers from hijacking the MCP server via DNS rebinding. This is a self-contained security middleware that can be reused in any HTTP-based local server that needs to prevent cross-origin attacks.

file: src/mcp/origin-guard.ts ↗ | tags: #security #dns-rebinding-protection
Last analyzed: 2026-08-22 15:15:06.050481
Next check: 2026-10-11 03:00:21.516755
$ submit: