knowledge-rag 4.8.5 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +119 -68
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -19,6 +19,14 @@ Structured data (schema.org SoftwareApplication) — indexed by search engines,
19
19
  }
20
20
  -->
21
21
 
22
+ <p align="center">
23
+ <img
24
+ src="./assets/knowledge-rag-banner.png"
25
+ alt="knowledge-rag — Local Hybrid RAG for MCP"
26
+ width="100%"
27
+ />
28
+ </p>
29
+
22
30
  # knowledge-rag
23
31
 
24
32
  <div align="center">
@@ -38,7 +46,7 @@ Structured data (schema.org SoftwareApplication) — indexed by search engines,
38
46
 
39
47
  ### The MCP-first local RAG server for Claude Code, Cursor, and every AI agent.
40
48
 
41
- **Hybrid search · Cross-encoder reranking · 20 file formats · 100% local · Zero cloud · Enterprise-grade plumbing built-in.**
49
+ **Hybrid search · Cross-encoder reranking · 35 file formats · 100% local · Zero cloud · Enterprise-grade plumbing built-in.**
42
50
 
43
51
  ```bash
44
52
  pip install knowledge-rag → restart Claude Code → search_knowledge("your query")
@@ -72,14 +80,14 @@ pip install knowledge-rag → restart Claude Code → search_knowledge("
72
80
 
73
81
  Most RAG frameworks fall into one of three traps: (1) they require you to ship your data to a cloud API, (2) they hand you 300 building blocks and 0 opinionated defaults, or (3) they bundle RAG as a 5% feature of a much bigger platform you didn't ask for.
74
82
 
75
- **knowledge-rag does one thing well:** it is the MCP-native local RAG server that Claude Code, Cursor, Windsurf, VS Code, Cline, Gemini CLI and Zed can search out of the box — with enterprise plumbing (bearer auth, Prometheus metrics, rate limiting, health probes, structured JSON logging, zero-downtime reindex) that no other RAG-focused OSS ships built-in.
83
+ **knowledge-rag is an MCP-native local RAG server** for clients such as Claude Code, Cursor, Windsurf, VS Code, Cline, Gemini CLI and Zed. It includes optional bearer authentication, Prometheus metrics, rate limiting, health probes, structured JSON logging and staging-based rebuilds. Configure the transport and access controls for the intended deployment.
76
84
 
77
85
  <table>
78
86
  <tr>
79
87
  <td width="50%" valign="top">
80
88
 
81
89
  ### 🔒 100% local, 0% cloud
82
- Your files never leave the machine. No vendor lock-in, no data-residency headache, no forced cloud dependency. **LGPD / GDPR / HIPAA compliant by architecture** — because there is nothing to comply about when nothing leaves.
90
+ Embedding generation, indexing, and retrieval run locally. Model downloads and `add_from_url` use network access, and configured MCP clients receive retrieved content. Choose the corpus, client permissions, and network exposure to fit your deployment; this project does not certify regulatory compliance.
83
91
 
84
92
  </td>
85
93
  <td width="50%" valign="top">
@@ -93,7 +101,7 @@ Your files never leave the machine. No vendor lock-in, no data-residency headach
93
101
  <td width="50%" valign="top">
94
102
 
95
103
  ### 🛡️ Production-grade OSS
96
- 7-pillar quality gate on every PR (**35+ automated checks**), 9-cell OS×Python CI matrix (Linux + Windows + macOS × 3.11/3.12/3.13), nightly chaos + 50K-iteration soak + mutation testing. **700+ tests. 0 known regressions.**
104
+ 7-pillar quality workflow, a 9-cell OS×Python CI matrix (Linux + Windows + macOS × 3.11/3.12/3.13), and nightly chaos, bounded-memory soak and mutation tests. Inspect the checks on the revision being deployed; CI coverage is not a guarantee of zero defects.
97
105
 
98
106
  </td>
99
107
  <td width="50%" valign="top">
@@ -109,31 +117,21 @@ No token bills. No SaaS tier. No paid features hidden behind a wall. **MIT licen
109
117
 
110
118
  ## 📊 How knowledge-rag compares to other RAG frameworks
111
119
 
112
- We audited **16 popular RAG frameworks and platforms** (LlamaIndex, LangChain, ChromaDB, Weaviate, Qdrant, RAGFlow, LightRAG, DSPy, GraphRAG, Haystack, RAG-Anything, kotaemon, txtai, llmware, Dify, open-webui, FastGPT) so you can pick honestly.
113
-
114
- **Legend:** ✅ built-in · 🟡 plugin / paid tier / partial · ❌ not available · ⚠️ license or default concern
115
-
116
- | Dimension | 🎯 **knowledge-rag** | LlamaIndex | LangChain | Haystack | RAGFlow | txtai | open-webui | Dify | Qdrant |
117
- |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
118
- | **100% local, zero cloud** | ✅ | 🟡 | ✅ | 🟡 | 🟡 | ✅ | ✅ | 🟡 | 🟡 |
119
- | **MCP native (Claude/Cursor)** | ✅ 13 tools | 🟡 pkg | 🟡 adapter | 🟡 wrapper | 🟡 add-on | ✅ | ✅ consumer | ✅ | ❌ |
120
- | **Hybrid BM25 + semantic** | ✅ 128× faster | 🟡 | 🟡 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
121
- | **Cross-encoder rerank** | ✅ builtin | ❌ | 🟡 | ✅ | ✅ fused | ❌ | ✅ | 🟡 | 🟡 |
122
- | **Bearer auth builtin** | ✅ | ❌ | ❌ | ❌ core | ❌ | 🟡 | ✅ RBAC | ✅ OAuth2 | ✅ |
123
- | **Prometheus `/metrics`** | ✅ | ❌ | ❌ | ❌ core | ❌ | ❌ | ✅ OTel | ❌ | ✅ |
124
- | **Rate limiting** | ✅ sliding-window | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
125
- | **Health probes** (`/health`) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | 🟡 | 🟡 | ✅ |
126
- | **Structured JSON logging** | ✅ opt-in | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ OTel | 🟡 | ✅ |
127
- | **Zero-downtime reindex** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
128
- | **Async background reindex** | ✅ + polling | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | 🟡 |
129
- | **GPU CUDA optional** | ✅ 12 auto | ❌ | 🟡 | ✅ | ✅ | ✅ | ✅ | 🟡 | 🟡 |
130
- | **File formats builtin** | ✅ **20** | 0 (LlamaParse=$) | 50+ plugins | ✅ **36+** | 8+ | ? | ? | ~10 | ❌ |
131
- | **Setup < 5 min POC** | ✅ pip 1-liner | ✅ | ✅ | ✅ | ❌ 16GB RAM | ✅ | ✅ docker | ✅ docker | ✅ |
132
- | **Nightly chaos + soak + mutation** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
133
- | **License** | ✅ MIT | MIT | MIT | Apache-2.0 | Apache-2.0 | Apache-2.0 | ⚠️ preserving | ⚠️ restrictive | Apache-2.0 |
134
-
135
- > **The 5 dimensions where knowledge-rag is unique:** health probes + JSON logging + Prometheus + rate limit + bearer auth **simultaneously built-in on an OSS RAG-focused MCP server**. Zero-downtime reindex + async background reindex + nightly chaos/soak/mutation are documented on nobody else's README.
136
-
120
+ Compare the features needed for your deployment rather than treating framework
121
+ checklists as a benchmark. Knowledge-rag combines MCP tools, local embeddings,
122
+ ChromaDB persistence, BM25, optional FTS5 and optional reranking in one process.
123
+
124
+ | Decision | What to verify |
125
+ | --- | --- |
126
+ | Local or remote processing | Where models run, which client receives content, and which features need network access |
127
+ | Retrieval quality | Expected-source queries on your corpus, including its languages and identifiers |
128
+ | Performance | Cold initialization, indexing, uncached queries, memory peaks and concurrent use on comparable hardware |
129
+ | Operations | Authentication, metrics exposure, backups, recovery and one-writer ownership |
130
+ | Extensibility | Supported parsers, model profiles and the public MCP contract |
131
+
132
+ The [audit report](docs/audit-2026-10-03.md) records a reproducible local workload
133
+ and its limitations. Results against an older implementation of this project are
134
+ not speed comparisons against other RAG frameworks.
137
135
  ---
138
136
 
139
137
  ## 🚀 Quick Start (3 minutes, from zero to your first query)
@@ -183,6 +181,30 @@ knowledge-rag --transport sse
183
181
  - Prometheus scrape: `http://your-host:9179/metrics`
184
182
  - MCP dispatcher: authenticated via `Authorization: Bearer your-secret-token`
185
183
 
184
+ ### Multi-client setup (Shared Server via Streamable HTTP)
185
+
186
+ `stdio` is ideal when one MCP client owns one `knowledge-rag` process. If several clients (e.g. Claude, Cursor, LM Studio, or multiple terminal windows) should share one index and one running process, run `knowledge-rag` once with Streamable HTTP and point each HTTP-capable client at the same endpoint (prompted by [#217](https://github.com/lyonzin/knowledge-rag/pull/217) and issue [#223](https://github.com/lyonzin/knowledge-rag/issues/223)):
187
+
188
+ ```bash
189
+ knowledge-rag --transport streamable-http
190
+ # MCP endpoint: http://127.0.0.1:8179/mcp
191
+ ```
192
+
193
+ - **Local MCP clients (Cursor, LM Studio, etc.):** Point their remote-server URL directly at `http://127.0.0.1:8179/mcp`.
194
+ - **Claude Custom Connectors (Remote MCP):**
195
+ - **Network requirement:** Custom connector requests originate from Anthropic's cloud infrastructure across web, desktop, and mobile, so they cannot reach local `127.0.0.1`. You must expose your server via a secure, publicly accessible HTTPS endpoint (e.g. Cloudflare Tunnel, ngrok, or reverse proxy) at `https://your-public-domain/mcp`. Configure the proxy to send an upstream `Host` accepted by the HTTP app for `server.host` (for the default loopback configuration, use `127.0.0.1:8179`); forwarding the public hostname unchanged can produce `421 Invalid Host header`. Keep bearer authentication and HTTPS enabled. Local `claude_desktop_config.json` uses `command`/`args` for local stdio processes and does not support remote HTTP endpoints.
196
+ - **Setup & Auth:** In Claude (Pro/Max plans: **Customize > Connectors > + Add > Add custom connector**; Team/Enterprise owners: **Organization settings > Connectors**), enter your public endpoint. In **Request headers**, set header name `Authorization` with value `Bearer <your-token>` matching `server.auth.bearer_token` in `config.yaml` (see [Anthropic Custom Connectors documentation](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)).
197
+
198
+ | Transport | Clients | Shared index / process | RAM overhead | Process management | Startup & query latency | Best fit |
199
+ |---|:---:|:---:|---|---|---|---|
200
+ | `stdio` | 1 | No | 1 runtime per client; models load lazily in each process when queried | Client manages its own process; no separate server | Spawns per client; pays preflight and first-query model load | Simplest local setup (single client) |
201
+ | `sse` | Many | Yes | Shared server process; single shared model load across clients | Operator manages one background server | Reuses warm server; first-query model load still applies | Legacy HTTP clients |
202
+ | `streamable-http` | Many | Yes | Shared server process; single shared model load across clients | Operator manages one background server | Reuses warm server; first-query model load still applies | **Preferred** shared-server setup |
203
+
204
+ When an HTTP transport is selected, `knowledge-rag` automatically enables its single-instance lock (`KNOWLEDGE_RAG_SINGLE_INSTANCE=1`) to prevent multiple servers from binding the same data directory or port.
205
+
206
+ > **Security note:** The default host is `127.0.0.1`. If you bind to `0.0.0.0` or deploy across a network, configure `server.auth.bearer_token` in `config.yaml` and terminate TLS (HTTPS) via a reverse proxy (e.g. Caddy, Nginx) to protect bearer tokens in transit; otherwise the server warns that the HTTP endpoint is unauthenticated.
207
+
186
208
  ### Path 3 — Docker (models pre-downloaded, air-gapped ready)
187
209
 
188
210
  ```bash
@@ -265,8 +287,8 @@ Every RAG framework claims "production-ready." Here is what knowledge-rag ships
265
287
 
266
288
  - **Bearer token auth** on SSE / HTTP transports — constant-time comparison (`hmac.compare_digest`), RFC 6750 challenge, 401 fenced with `WWW-Authenticate` header
267
289
  - **Path traversal + symlink escape defenses** — `validate_path_within` guarding 6 CRUD tools (CWE-22, CWE-59)
268
- - **Prompt injection 3-layer defense** — sentinel neutralization + provenance fence + `external_source` flag (OWASP LLM01:2025)
269
- - **OpenSSF Best Practices badge** verified · **CodeQL** weekly scan · **Bandit + Semgrep + Gitleaks + pip-audit** on every PR
290
+ - **External-content handling** — known-token neutralization and a stored provenance fence, with parser metadata propagation. These are limited mitigations; clients must still treat retrieved content as untrusted data. See [SECURITY.md](SECURITY.md).
291
+ - **OpenSSF Best Practices** project [#13864](https://www.bestpractices.dev/en/projects/13864) · **CodeQL** weekly scan · **Bandit + Semgrep + Gitleaks + pip-audit** workflows. Review actual check results and exceptions for the release you deploy.
270
292
  - **PyPI Trusted Publishing** via OIDC (zero long-lived tokens in CI)
271
293
 
272
294
  </td>
@@ -288,12 +310,12 @@ Every RAG framework claims "production-ready." Here is what knowledge-rag ships
288
310
  ### Scale & performance
289
311
 
290
312
  - **SSE / streamable-http transport** — 1 server serves N MCP clients, ChromaDB WAL mode enabled automatically, shared embedding model + query cache
291
- - **BM25 inverted-index** — **128× faster** than linear scan (custom implementation, replaces `rank-bm25`)
292
- - **FTS5 SQLite fast-path** (opt-in, ADR-002/003/006/008) — <10ms cold, <2ms hot on lexical queries
293
- - **Cross-encoder reranking** — Xenova/ms-marco-MiniLM-L-6-v2, +1.88pp Recall@10 (p<0.001)
294
- - **GPU CUDA 12** with auto DLL discovery + graceful CPU fallback
295
- - **Query cache** — LRU + 5-min TTL, cuts p95 latency ~40%
296
- - **Zero-downtime reindex** — staging populate + validation + atomic swap + durable metadata rollback
313
+ - **BM25 inverted index** — keyword candidate retrieval without scoring every document for every query
314
+ - **FTS5 SQLite fast path** — opt-in lexical retrieval; measure relevance and latency on your identifiers and corpus
315
+ - **Cross-encoder reranking** — Xenova/ms-marco-MiniLM-L-6-v2; optional model scoring of a candidate pool
316
+ - **NVIDIA CUDA embeddings** and experimental Windows AMD DirectML opt-in, with actual-session checks and CPU fallback; [setup and compatibility limits](docs/gpu-setup.md)
317
+ - **Query cache** — LRU + 5-minute TTL, with mutation invalidation
318
+ - **Staging rebuild** — populate and validate a replacement while the current collection remains available; handled publication failures roll back
297
319
  - **Async background reindex** with `get_reindex_status()` polling
298
320
 
299
321
  </td>
@@ -302,11 +324,11 @@ Every RAG framework claims "production-ready." Here is what knowledge-rag ships
302
324
  ### Reliability
303
325
 
304
326
  - **Nightly chaos injection** — HuggingFace Hub offline · ONNX zero-byte replay · watchdog crash recovery (3 scenarios in `tests/chaos/`)
305
- - **50 000-iteration soak test** — proves no memory leak after 1h of continuous queries (`KNOWLEDGE_RAG_SOAK_ITERATIONS=50000`)
327
+ - **50,000-iteration soak test** — checks a fixed memory-growth budget with stub embeddings (`KNOWLEDGE_RAG_SOAK_ITERATIONS=50000`); this is not a one-hour real-model endurance test
306
328
  - **Mutation testing** (mutmut) on `instance_lock` + `preflight` — catches tests that are too weak
307
329
  - **Determinism check** — full test suite × 3, catches flakes
308
- - **Backwards-compat frozen** — 13 MCP tool parameter names guarded by `tests/test_backwards_compat.py` + legacy YAML fixtures (v3.6.0 / v3.7.0) still parse
309
- - **API surface AST diff** — `check_api_surface.py` blocks any breaking change at PR time
330
+ - **Backwards compatibility** — 13 MCP tools, signature regression tests and legacy YAML fixtures; optional additions preserve existing calls
331
+ - **API surface AST diff** — checks structural signature changes alongside behavioral tests
310
332
  - **9-cell CI matrix** — Linux + Windows + macOS × 3.11 + 3.12 + 3.13
311
333
 
312
334
  </td>
@@ -321,7 +343,7 @@ Every RAG framework claims "production-ready." Here is what knowledge-rag ships
321
343
 
322
344
  **Preset:** [`cybersecurity.yaml`](presets/cybersecurity.yaml) · 8 categories · 200+ routing keywords · 69 query expansions
323
345
 
324
- Ingest MITRE ATT&CK, threat reports, exploit writeups, incident reports. Search from Claude Code with `search_knowledge("privilege escalation windows")` and get instant recall across your entire corpus. Air-gapped — nothing leaves the laptop.
346
+ Ingest MITRE ATT&CK, threat reports, exploit writeups and incident reports. Search from an MCP client with `search_knowledge("privilege escalation windows")`. Offline operation requires cached models; the chosen client receives retrieved content and determines what happens to it afterwards.
325
347
 
326
348
  ### Development Teams — Design Docs, Runbooks, Code
327
349
 
@@ -380,8 +402,8 @@ flowchart TB
380
402
 
381
403
  subgraph SEARCH["Retrieval Pipeline"]
382
404
  R[Query Router<br/>lexical vs semantic]
383
- F[FTS5 Fast-Path<br/>opt-in · lt 10ms]
384
- BM[BM25 Inverted Index<br/>128x faster than baseline]
405
+ F[FTS5 Fast-Path<br/>opt-in lexical retrieval]
406
+ BM[BM25 Inverted Index<br/>keyword candidates]
385
407
  SE[Semantic Search<br/>FastEmbed ONNX lazy-loaded]
386
408
  RRF[Reciprocal Rank Fusion]
387
409
  CE[Cross-Encoder Rerank<br/>MiniLM-L-6-v2]
@@ -397,11 +419,11 @@ flowchart TB
397
419
  subgraph INGEST["Document Ingestion"]
398
420
  FS[documents/ folder]
399
421
  WD[Watchdog<br/>10s debounce]
400
- PA[20 Parsers<br/>MD · PDF · DOCX · code · IPYNB]
422
+ PA[Format parsers<br/>MD · PDF · DOCX · code · IaC · IPYNB]
401
423
  CK[Chunker<br/>markdown-aware · code-aware]
402
424
  EM[FastEmbed ONNX<br/>384D bge-small-en-v1.5]
403
425
  DD[SHA256 Dedup]
404
- SW[Zero-downtime Staging Swap<br/>rollback on validation fail]
426
+ SW[Staging Rebuild<br/>rollback on handled publication failure]
405
427
  end
406
428
 
407
429
  subgraph OBS["Enterprise Observability (opt-in)"]
@@ -440,7 +462,7 @@ flowchart TB
440
462
 
441
463
  FS --> WD --> PA
442
464
  PA --> CK --> EM --> DD --> CH
443
- SW -.->|atomic swap| CH
465
+ SW -.->|validated publication| CH
444
466
  SW -.-> FT
445
467
  CH -.-> MD
446
468
 
@@ -472,26 +494,26 @@ flowchart TB
472
494
 
473
495
  1. **Any MCP client** — Claude Code, Cursor, Windsurf, and 5 others — connects via the transport of your choice (stdio for personal use, SSE/streamable-http for teams).
474
496
  2. **HTTP mode chains 3 ASGI middlewares in order**: health probes first (always answered), then bearer auth (fenced with `WWW-Authenticate`), then rate limiter (sliding window).
475
- 3. **All 13 MCP tools** are decorated with `@rate_limited` + `@instrument` — Prometheus counts every call, rate limiter enforces RPM+burst, both zero-cost when disabled.
497
+ 3. **All 13 MCP tools** are decorated with `@rate_limited` + `@instrument` — metrics record calls and the rate limiter enforces RPM+burst when enabled. Disabled features skip that work, while the lightweight wrapper calls remain.
476
498
  4. **`search_knowledge` checks the query cache first**; cache miss routes through the Query Router (regex classifier) to either the FTS5 fast-path (lexical) or the hybrid pipeline (BM25 + semantic + RRF + cross-encoder rerank).
477
499
  5. **Storage is 100% local**: ChromaDB (WAL mode) for vectors + metadata, SQLite FTS5 (WAL + busy-timeout) for lexical fast-path, `index_metadata.json` for durable state.
478
- 6. **Document ingestion runs continuously**: watchdog observes `documents/`, 20 parsers handle each format, chunker respects language boundaries, FastEmbed ONNX generates embeddings, SHA256 deduplicates, and a staging swap performs zero-downtime rebuilds with rollback-on-failure.
500
+ 6. **Document ingestion**: when enabled, watchdog observes `documents/`; format parsers create chunks, FastEmbed generates embeddings, and source metadata supports incremental updates. Full rebuilds use staging. See the operations guide for publication and recovery limits.
479
501
  7. **Enterprise observability** (opt-in) — Prometheus `/metrics`, structured JSON logs, `/health` payload — attaches to the same instrumentation points, no code changes required.
480
502
  8. **`config.yaml` (with 5 domain presets)** controls every subsystem — no environment variable spaghetti, no hardcoded paths.
481
503
 
482
- **Complete architecture — 4 detailed Mermaid diagrams (System Overview · Query Flow · Document Ingestion · hybrid_alpha effect):** [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
504
+ **Component ownership, query/ingestion diagrams, memory boundaries and hybrid weights:** [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
483
505
 
484
506
  ---
485
507
 
486
- ## 📄 20 File Formats — parsed natively, no plugins needed
508
+ ## 📄 35 File Formats — parsed natively, no plugins needed
487
509
 
488
- Every parser is **chunk-aware** — Markdown splits at `##` headers, code splits at function/class boundaries, notebooks skip base64 outputs, PDFs use PyMuPDF, spreadsheets extract sheet-by-sheet. **18 formats are enabled by default**; the 2 MetaTrader formats are opt-in (add to `documents.supported_formats` in `config.yaml`).
510
+ Parsers use format-specific extraction: Markdown sections, code boundaries, notebook cells without base64 outputs, PDF text and spreadsheet rows. Several extensions share one parser. The runtime fallback list contains 33 formats; the documented template and presets can select a smaller list. Inspect your effective `documents.supported_formats`. The two MetaTrader extensions are opt-in.
489
511
 
490
512
  | # | Format | Extension | Parser | Default | Notes |
491
513
  |---|--------|-----------|--------|:-------:|-------|
492
514
  | 1 | Markdown | `.md` | Section-aware (splits at `##`) | Yes | Headers preserved as chunk boundaries |
493
515
  | 2 | Plain Text | `.txt` | Fixed-size chunking | Yes | 1000 chars + 200 overlap |
494
- | 3 | PDF | `.pdf` | PyMuPDF extraction | Yes | Text-based PDFs only (no OCR) |
516
+ | 3 | PDF | `.pdf` | PyMuPDF extraction or explicit page-marked UTF-8 text | Yes | No OCR; extracted-text recognition is limited to 4 MiB |
495
517
  | 4 | Word | `.docx` | python-docx | Yes | Headings preserved as markdown |
496
518
  | 5 | Excel | `.xlsx` | openpyxl | Yes | Sheet-by-sheet extraction |
497
519
  | 6 | PowerPoint | `.pptx` | python-pptx | Yes | Slide-by-slide extraction |
@@ -507,8 +529,33 @@ Every parser is **chunk-aware** — Markdown splits at `##` headers, code splits
507
529
  | 16 | React JSX | `.jsx` | Code-aware parser | Yes | Same as JS parser |
508
530
  | 17 | TypeScript | `.ts` | Code-aware parser | Yes | Functions / classes / interfaces / enums / imports |
509
531
  | 18 | React TSX | `.tsx` | Code-aware parser | Yes | Same as TS parser |
510
- | 19 | MQL4 Source | `.mq4` | Code parser | **No** | MetaTrader — opt-in via `documents.supported_formats` |
511
- | 20 | MQL4 Header | `.mqh` | Code parser | **No** | MetaTrader — opt-in via `documents.supported_formats` |
532
+ | 19 | Go | `.go` | Code-aware parser | Yes | Functions / structs / imports extracted |
533
+ | 20 | Rust | `.rs` | Code-aware parser | Yes | Functions / structs / enums / traits / `use` imports |
534
+ | 21 | Kotlin | `.kt` | Code-aware parser | Yes | Functions (incl. class members) / classes extracted |
535
+ | 22 | YAML | `.yaml` | YAML parser | Yes | Kubernetes kind / apiVersion / name extracted |
536
+ | 23 | YAML | `.yml` | YAML parser | Yes | Same as YAML parser |
537
+ | 24 | HuJSON | `.hujson` | HuJSON parser | Yes | JSON with comments + trailing commas (e.g. Tailscale ACLs) |
538
+ | 25 | CUE | `.cue` | Code-aware parser | Yes | Imports / package extracted |
539
+ | 26 | Protocol Buffers | `.proto` | Proto parser | Yes | Services / messages / RPCs extracted |
540
+ | 27 | Rego | `.rego` | Code-aware parser | Yes | OPA policies — imports / package extracted |
541
+ | 28 | SQL | `.sql` | SQL parser | Yes | Table names + statement types extracted |
542
+ | 29 | Shell | `.sh` | Shell parser | Yes | Function names extracted |
543
+ | 30 | jq | `.jq` | Shell parser | Yes | Indexed as shell-style script |
544
+ | 31 | Dockerfile | `Dockerfile` | Text parser | Yes | Matched by exact filename (no extension) |
545
+ | 32 | Makefile | `Makefile` | Text parser | Yes | Matched by exact filename (no extension) |
546
+ | 33 | Tiltfile | `Tiltfile` | Code-aware parser | Yes | Starlark — `def` functions / `load()` extracted |
547
+ | 34 | MQL4 Source | `.mq4` | Code parser | **No** | MetaTrader — opt-in via `documents.supported_formats` |
548
+ | 35 | MQL4 Header | `.mqh` | Code parser | **No** | MetaTrader — opt-in via `documents.supported_formats` |
549
+
550
+ Files with a `.pdf` extension can also contain an explicit text extraction: the
551
+ first line must be `[Page N]` with a positive page number, followed by nonempty
552
+ UTF-8 text. An optional UTF-8 BOM and tab/CR/LF whitespace are accepted. This
553
+ recognition is limited to 4 MiB, rejects other C0/C1 controls and DEL, and never
554
+ reinterprets a file containing PDF magic in the first 1 KiB as text. Accepted
555
+ extractions retain their source path and are marked `content_format=extracted_text`
556
+ and `page_count_source=markers`; the marker count is not proof of the original
557
+ PDF's total page count. Binary PDFs keep the native parser and its error
558
+ diagnostics. Invalid or oversized textual lookalikes remain errors.
512
559
 
513
560
  > **Enable an opt-in format** — add the extension to `documents.supported_formats` in your `config.yaml`:
514
561
  > ```yaml
@@ -565,6 +612,10 @@ Native MCP
565
612
 
566
613
  **Complete client configuration guide with JSON schemas per client:** [docs/INSTALLATION.md#use-with-other-mcp-clients →](docs/INSTALLATION.md#use-with-other-mcp-clients)
567
614
 
615
+ > ⚠️ **Operating model — read once.** In `stdio` mode, your MCP client (Claude Desktop, Code, Cursor, etc.) **spawns and owns the knowledge-rag server process**. Do **NOT** also run a second `knowledge-rag` writer in a terminal while that stdio client is open — two writer processes against the same `data_dir` corrupt the ChromaDB HNSW segment on Windows (see [issue #216](https://github.com/lyonzin/knowledge-rag/issues/216)). For HTTP transports, manually running one server and connecting HTTP clients to it is the supported shared-server workflow; do not mix it with another writer using the same `data_dir`. Recommended baseline for stdio clients: add `"KNOWLEDGE_RAG_SINGLE_INSTANCE": "1"` to the `env` block of your MCP config as a safety net. Full explanation + how to run CLI commands safely: [docs/single-instance.md](docs/single-instance.md).
616
+
617
+ > ⚠️ **Do not install under cloud-sync folders.** Keep `paths.data_dir` on a local path. OneDrive (incl. `OneDrive - <tenant>`), iCloud Drive, Dropbox, Google Drive, Box, pCloud, MEGAsync, Nextcloud/ownCloud and Sync all open file handles on the live index to upload it, racing with ChromaDB's HNSW mmap and SQLite WAL writes and triggering native access violations (`0xC0000005` on Windows, `SIGBUS` on *nix). Preflight auto-repair then moves the active index to `data/backups/auto-repair-*` and you lose the corpus. Since v4.11.0, preflight aborts with `EX_CONFIG` (78) when `data_dir` resolves under one of these providers. Point `data_dir` at a local path (e.g. `%LOCALAPPDATA%\knowledge-rag\data` on Windows, `~/.local/share/knowledge-rag/data` on Linux/macOS). If you really need to run under cloud sync, set `paths.allow_cloud_sync: true` to acknowledge the risk and continue.
618
+
568
619
  ---
569
620
 
570
621
  ## ⚙️ Configuration in 30 seconds
@@ -579,7 +630,8 @@ paths:
579
630
  models:
580
631
  embedding:
581
632
  profile: "compact" # "compact" | "quality" | "multilingual" | "custom"
582
- gpu: "auto" # "auto" | "true" | "false"
633
+ gpu: "auto" # "auto" | "true" | "false" | "directml"
634
+ device_id: null # DirectML: explicit DXGI adapter index
583
635
  reranker:
584
636
  enabled: true # cross-encoder rerank
585
637
 
@@ -617,12 +669,12 @@ knowledge-rag is designed for teams that cannot let their documents leave the pe
617
669
  | **Supply chain security** | PyPI Trusted Publishing via OIDC (no long-lived tokens) |
618
670
  | **Vulnerability disclosure** | Private security advisory via [SECURITY.md](SECURITY.md) |
619
671
  | **Signed release attestations** | GitHub release attestations on every published version |
620
- | **Reproducible builds** | Locked `requirements.txt` with pinned versions |
672
+ | **Dependency management** | Version ranges in `requirements.txt` / `pyproject.toml`; resolve and record a tested environment for reproducibility |
621
673
  | **Authenticated access** | Bearer token middleware on SSE / HTTP transports (constant-time compare, RFC 6750) |
622
674
  | **Rate limiting** | Sliding-window per-client RPM + burst (opt-in, zero-cost when disabled) |
623
675
  | **Audit-ready logging** | Opt-in structured JSON logs → ship to your SIEM |
624
676
  | **Path traversal defenses** | CWE-22 / CWE-59 guards on 6 CRUD tools |
625
- | **Prompt injection defense** | 3-layer sanitization on `add_from_url` (OWASP LLM01:2025) |
677
+ | **External-content mitigation** | Known-token neutralization and provenance fencing on `add_from_url`; not a general prompt-injection prevention guarantee |
626
678
 
627
679
  **OpenSSF Best Practices** badge: passing · project ID [#13864](https://bestpractices.coreinfrastructure.org/projects/13864)
628
680
 
@@ -630,16 +682,14 @@ knowledge-rag is designed for teams that cannot let their documents leave the pe
630
682
 
631
683
  ## 📈 Numbers that matter
632
684
 
633
- - **26 000+** total downloads on PyPI · **250+** GitHub stars · **70+** enterprise teams (private + community)
634
- - **700+ tests** collected · **1.33:1** test-to-code ratio · **codecov trend gate** ±0.5pp
635
- - **35+ status checks** on every PR (9-cell OS×Python matrix · 7 quality pillars)
636
- - **20 file formats** parsed natively · **13 MCP tools** frozen · **5 domain presets** (cyber · dev · research · multilingual · general)
637
- - **BM25 128× faster** than baseline · **cross-encoder +1.88pp** Recall@10 (p<0.001) · **cache −40%** p95 latency
638
- - **1 800+ files / 39 K chunks indexed in < 3 min** on a modern laptop (typical developer corpus)
639
- - **Verified in production** on 5 889-doc / 75 016-chunk corpora
640
-
641
- **Public benchmark dashboard:** https://lyonzin.github.io/knowledge-rag/
685
+ - **13 MCP tools**, configurable format selection and five domain presets.
686
+ - **Nine OS/Python CI combinations** configured for Linux, macOS and Windows with Python 3.11–3.13.
687
+ - **Measured CPU/CUDA indexing and retrieval, AMD validation and memory regressions:** [audit results and reproduction](docs/audit-2026-10-03.md).
688
+ - **Historical implementation benchmarks:** [v4.7.1 baseline](docs/perf-baseline-v4.7.1.md). Historical ratios apply to their recorded workloads, not every corpus or competing product.
642
689
 
690
+ The [public benchmark dashboard](https://lyonzin.github.io/knowledge-rag/) tracks
691
+ CI workloads. Mocked storage/model workloads and real-model measurements answer
692
+ different questions; inspect the methodology and units before comparing them.
643
693
  ---
644
694
 
645
695
  ## 📚 Documentation
@@ -649,15 +699,16 @@ knowledge-rag is designed for teams that cannot let their documents leave the pe
649
699
  | [**Installation guide**](docs/INSTALLATION.md) | 5 install methods · 8 MCP client integrations · GPU setup |
650
700
  | [**API reference**](docs/API.md) | Complete reference for all 13 MCP tools |
651
701
  | [**Configuration reference**](docs/CONFIGURATION.md) | Every `config.yaml` field · presets · tuning |
652
- | [**Architecture**](docs/ARCHITECTURE.md) | 4 Mermaid diagrams: System Overview · Query Flow · Ingestion · hybrid_alpha |
702
+ | [**Architecture**](docs/ARCHITECTURE.md) | Components · query/ingestion flow · memory/concurrency boundaries · hybrid weights |
653
703
  | [**Troubleshooting**](docs/TROUBLESHOOTING.md) | 11 common issues + solutions |
654
704
  | [**FTS5 fast-path guide**](docs/features/fts5_fast_path.md) | Opt-in lexical fast-path — when and how |
655
705
  | [**Reindex operations**](docs/reindex-operations.md) | Zero-downtime rebuild · resume · checkpoint |
656
- | [**GPU setup**](docs/gpu-setup.md) | CUDA 12 installation + troubleshooting |
706
+ | [**GPU setup**](docs/gpu-setup.md) | CUDA runtime compatibility · CPU fallback · AMD/macOS GPU limitations |
657
707
  | [**Migration to v4.8.0**](docs/migration-v4.8.0.md) | Embedding profile · multilingual · zero-downtime |
658
708
  | [**Security policy**](SECURITY.md) | Threat model · disclosure channel |
659
709
  | [**Contributing**](CONTRIBUTING.md) | Development · testing · PR process |
660
710
  | [**Changelog**](CHANGELOG.md) | All release notes since v1.0.0 |
711
+ | [**Memory/GPU audit**](docs/audit-2026-10-03.md) | Reproducible workloads · measured results · validation limits · open PR/issue review |
661
712
 
662
713
  ---
663
714
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "knowledge-rag",
3
- "version": "4.8.5",
4
- "description": "Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 13 MCP Tools + 20 Format Parsers. Zero external servers.",
3
+ "version": "4.11.0",
4
+ "description": "Local RAG MCP server with hybrid search, cross-encoder reranking and local document indexing.",
5
5
  "bin": {
6
6
  "knowledge-rag": "./bin/cli.js"
7
7
  },