vaultspec-rag 0.2.0a0__py3-none-any.whl
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.
- vaultspec_rag/README.md +309 -0
- vaultspec_rag/__init__.py +69 -0
- vaultspec_rag/__main__.py +20 -0
- vaultspec_rag/api.py +399 -0
- vaultspec_rag/builtins/__init__.py +165 -0
- vaultspec_rag/builtins/mcps/vaultspec-rag.builtin.json +7 -0
- vaultspec_rag/builtins/rules/vaultspec-rag.builtin.md +104 -0
- vaultspec_rag/cli.py +2081 -0
- vaultspec_rag/commands.py +427 -0
- vaultspec_rag/config.py +207 -0
- vaultspec_rag/embeddings.py +388 -0
- vaultspec_rag/indexer.py +1811 -0
- vaultspec_rag/logging_config.py +44 -0
- vaultspec_rag/mcp_server.py +977 -0
- vaultspec_rag/progress.py +183 -0
- vaultspec_rag/search.py +627 -0
- vaultspec_rag/service.py +339 -0
- vaultspec_rag/store.py +923 -0
- vaultspec_rag/synthetic.py +316 -0
- vaultspec_rag/tests/__init__.py +0 -0
- vaultspec_rag/tests/benchmarks/__init__.py +0 -0
- vaultspec_rag/tests/benchmarks/bench_rag.py +138 -0
- vaultspec_rag/tests/benchmarks/conftest.py +51 -0
- vaultspec_rag/tests/conftest.py +155 -0
- vaultspec_rag/tests/constants.py +44 -0
- vaultspec_rag/tests/corpus.py +20 -0
- vaultspec_rag/tests/integration/__init__.py +0 -0
- vaultspec_rag/tests/integration/conftest.py +34 -0
- vaultspec_rag/tests/integration/test_api_integration.py +135 -0
- vaultspec_rag/tests/integration/test_cli_integration.py +180 -0
- vaultspec_rag/tests/integration/test_codebase_integration.py +411 -0
- vaultspec_rag/tests/integration/test_ecosystem_integration.py +403 -0
- vaultspec_rag/tests/integration/test_embeddings.py +77 -0
- vaultspec_rag/tests/integration/test_indexer_integration.py +196 -0
- vaultspec_rag/tests/integration/test_indexer_progress_integration.py +184 -0
- vaultspec_rag/tests/integration/test_install.py +616 -0
- vaultspec_rag/tests/integration/test_performance.py +233 -0
- vaultspec_rag/tests/integration/test_quality.py +350 -0
- vaultspec_rag/tests/integration/test_robustness.py +96 -0
- vaultspec_rag/tests/integration/test_search_integration.py +355 -0
- vaultspec_rag/tests/integration/test_service_lifecycle.py +369 -0
- vaultspec_rag/tests/integration/test_store_integration.py +156 -0
- vaultspec_rag/tests/metrics.py +35 -0
- vaultspec_rag/tests/test_adr_regression.py +340 -0
- vaultspec_rag/tests/test_cli.py +343 -0
- vaultspec_rag/tests/test_cli_warmup.py +44 -0
- vaultspec_rag/tests/test_graph_cache.py +296 -0
- vaultspec_rag/tests/test_indexer_unit.py +1224 -0
- vaultspec_rag/tests/test_mcp_server.py +725 -0
- vaultspec_rag/tests/test_metrics.py +52 -0
- vaultspec_rag/tests/test_progress_unit.py +153 -0
- vaultspec_rag/tests/test_search_unit.py +239 -0
- vaultspec_rag/tests/test_service_registry.py +652 -0
- vaultspec_rag/tests/test_store.py +139 -0
- vaultspec_rag/tests/test_store_codebase.py +93 -0
- vaultspec_rag/watcher.py +233 -0
- vaultspec_rag/workspace.py +26 -0
- vaultspec_rag-0.2.0a0.dist-info/METADATA +175 -0
- vaultspec_rag-0.2.0a0.dist-info/RECORD +62 -0
- vaultspec_rag-0.2.0a0.dist-info/WHEEL +4 -0
- vaultspec_rag-0.2.0a0.dist-info/entry_points.txt +3 -0
- vaultspec_rag-0.2.0a0.dist-info/licenses/LICENSE +21 -0
vaultspec_rag/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# vaultspec-rag
|
|
2
|
+
|
|
3
|
+
GPU-accelerated hybrid search over vault documents and source code. This is an extension to [vaultspec-core](https://github.com/wgergely/vaultspec-core) and requires it as a dependency. See the [project README](../../README.md) for background. Report issues on the [GitHub tracker](https://github.com/wgergely/vaultspec-rag/issues).
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- NVIDIA GPU with CUDA support (no CPU fallback; raises `RuntimeError` without one)
|
|
8
|
+
- Python >= 3.13
|
|
9
|
+
- [vaultspec-core](https://github.com/wgergely/vaultspec-core) >= 0.1.0
|
|
10
|
+
- ~3 GB free VRAM (Qwen3 ~1.5 GB, SPLADE ~0.5 GB, reranker ~0.56 GB)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install with `uv`:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
uv add vaultspec-rag
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
PyTorch requires the CUDA package index. The project's `pyproject.toml` configures the `pytorch-cu130` index at `https://download.pytorch.org/whl/cu130` automatically.
|
|
21
|
+
|
|
22
|
+
Two entry points register on install:
|
|
23
|
+
|
|
24
|
+
- `vaultspec-rag` -- CLI
|
|
25
|
+
- `vaultspec-search-mcp` -- MCP server
|
|
26
|
+
|
|
27
|
+
Verify the installation:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
vaultspec-rag --version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
From a directory containing `.vault/` and `.vaultspec/`, run:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
cd your-project
|
|
39
|
+
vaultspec-rag index
|
|
40
|
+
vaultspec-rag search "your query"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`index` builds embeddings for both vault documents and source code. `search` queries the vault by default, returning the top 5 results as a table with Score, Location, and Snippet columns.
|
|
44
|
+
|
|
45
|
+
## Usage modes
|
|
46
|
+
|
|
47
|
+
The CLI runs in one of two modes: **ad-hoc** and **service-delegated**.
|
|
48
|
+
|
|
49
|
+
**Ad-hoc mode** runs everything in-process. Each CLI command loads the GPU models, performs the operation, and exits. This is the default; installation is the only setup. The tradeoff is that loading models takes several seconds per invocation.
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
vaultspec-rag index
|
|
53
|
+
vaultspec-rag search "your query"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Service-delegated mode** points the CLI at a running HTTP daemon via `--port`. Models stay loaded in VRAM across invocations, so each command returns near-instantly. The CLI sends the current workspace as `project_root` on every call, so one daemon serves any project.
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
vaultspec-rag server service start
|
|
60
|
+
vaultspec-rag search --port 8766 "your query"
|
|
61
|
+
vaultspec-rag index --port 8766
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use ad-hoc for one-off tasks or environments where a persistent process isn't practical. Use service-delegated for active development. It keeps one shared daemon across projects and returns results near-instantly.
|
|
65
|
+
|
|
66
|
+
For AI tools that speak MCP directly (Claude Desktop, Claude Code), see [MCP integration](#mcp-integration). The same daemon serves them, with different project-resolution rules per transport.
|
|
67
|
+
|
|
68
|
+
## Architecture overview
|
|
69
|
+
|
|
70
|
+
### Access layers
|
|
71
|
+
|
|
72
|
+
Three interfaces expose the same underlying engine: the CLI (`vaultspec-rag`), the MCP server (`vaultspec-search-mcp`), and the Python API (`vaultspec_rag.api`).
|
|
73
|
+
|
|
74
|
+
The CLI runs indexing and search in-process by default. Pass `--port` to delegate to a running MCP service over HTTP. If the service is unreachable, the CLI falls back to in-process execution.
|
|
75
|
+
|
|
76
|
+
The MCP server wraps the engine behind tool endpoints, accepting connections from any MCP-compatible client. The Python API is the underlying facade -- call `index()`, `search_vault()`, and `search_codebase()` directly.
|
|
77
|
+
|
|
78
|
+
### GPU model lifecycle
|
|
79
|
+
|
|
80
|
+
A single shared `EmbeddingModel` loads three models into VRAM once at initialization:
|
|
81
|
+
|
|
82
|
+
- **Dense encoder** -- `Qwen/Qwen3-Embedding-0.6B` (1024-dimensional vectors, fp16)
|
|
83
|
+
- **Sparse encoder** -- `naver/splade-v3` (asymmetric SPLADE with separate query and document encoding)
|
|
84
|
+
- **Reranker** -- `BAAI/bge-reranker-v2-m3` (CrossEncoder with sigmoid activation, loaded lazily on first use)
|
|
85
|
+
|
|
86
|
+
A shared lock serializes GPU operations. CUDA is mandatory -- the system raises `RuntimeError` if no GPU is available.
|
|
87
|
+
|
|
88
|
+
### Multi-project support
|
|
89
|
+
|
|
90
|
+
The MCP service manages isolated per-project slots. Each slot contains its own Qdrant store, indexers, searcher, and relationship graph cache. All slots share the single `EmbeddingModel` instance.
|
|
91
|
+
|
|
92
|
+
MCP tools accept a `project_root` parameter to target a specific project. Different projects initialize in parallel under per-root locks.
|
|
93
|
+
|
|
94
|
+
### File watching
|
|
95
|
+
|
|
96
|
+
When running as a service, background watchers monitor vault (`.md`) and source files for each registered project. Changes trigger incremental reindexing after a 2-second debounce.
|
|
97
|
+
|
|
98
|
+
Per-source cooldowns of 30 seconds prevent thrashing. Vault and codebase cooldowns are independent -- a burst of `.md` edits won't delay source reindexing.
|
|
99
|
+
|
|
100
|
+
Vault changes also invalidate the relationship graph cache.
|
|
101
|
+
|
|
102
|
+
## CLI commands
|
|
103
|
+
|
|
104
|
+
Run `vaultspec-rag --help` for the full option list.
|
|
105
|
+
|
|
106
|
+
### Command tree
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
vaultspec-rag
|
|
110
|
+
├── index Index vault documents and/or codebase source files
|
|
111
|
+
├── search Search documentation or code
|
|
112
|
+
├── status Show engine status, storage metrics, and GPU info
|
|
113
|
+
├── benchmark Run search latency probes (p50/p95/p99)
|
|
114
|
+
├── quality Run precision probes against a synthetic corpus
|
|
115
|
+
├── test Run the test suite (forwards args to pytest)
|
|
116
|
+
└── server
|
|
117
|
+
├── mcp
|
|
118
|
+
│ ├── start Start MCP server (stdio by default, HTTP with --port)
|
|
119
|
+
│ ├── stop Guidance for stopping (Ctrl+C)
|
|
120
|
+
│ └── status Show registered tools, resources, and prompts
|
|
121
|
+
└── service
|
|
122
|
+
├── start Spawn background daemon (HTTP, default port 8766)
|
|
123
|
+
├── stop Stop the background service
|
|
124
|
+
├── status Show daemon health and connected projects
|
|
125
|
+
└── warmup Pre-download model weights to HuggingFace cache
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Global options:** `--target` / `-t` sets the workspace root. `--verbose` / `-v` and `--debug` / `-d` control log verbosity. `--version` / `-V` prints the installed version.
|
|
129
|
+
|
|
130
|
+
**Config overrides:** `--data-dir`, `--qdrant-dir`, `--index-meta`, `--code-index-meta`, `--status-dir`, and `--log-file` override the default storage paths.
|
|
131
|
+
|
|
132
|
+
### The `--port` fast path
|
|
133
|
+
|
|
134
|
+
The `index` and `search` commands accept a `--port` flag. When set, the CLI delegates to a running MCP service over HTTP instead of loading GPU models in-process. If the service is unavailable, the CLI falls back to in-process operation with a warning.
|
|
135
|
+
|
|
136
|
+
Loading the embedding models takes several seconds on a cold start. Point `--port` at a running `server service` instance to skip that overhead entirely.
|
|
137
|
+
|
|
138
|
+
## Configuration
|
|
139
|
+
|
|
140
|
+
### Precedence
|
|
141
|
+
|
|
142
|
+
Configuration resolves through three tiers: CLI flags override environment variables, which override built-in defaults. Boolean env vars accept `1`, `true`, or `yes` (case-insensitive). The system parses integer and float values from strings.
|
|
143
|
+
|
|
144
|
+
### Environment variables
|
|
145
|
+
|
|
146
|
+
| Variable | Default | Description |
|
|
147
|
+
| ------------------------------- | ------------------------- | ------------------------------------------------- |
|
|
148
|
+
| `VAULTSPEC_RAG_ROOT` | cwd | Project root directory |
|
|
149
|
+
| `VAULTSPEC_RAG_DATA_DIR` | `.vault/data/search-data` | Search data directory |
|
|
150
|
+
| `VAULTSPEC_RAG_QDRANT_DIR` | `qdrant` | Qdrant storage subdirectory, relative to data dir |
|
|
151
|
+
| `VAULTSPEC_RAG_INDEX_META` | `index_meta.json` | Vault index metadata filename |
|
|
152
|
+
| `VAULTSPEC_RAG_CODE_INDEX_META` | `code_index_meta.json` | Codebase index metadata filename |
|
|
153
|
+
| `VAULTSPEC_RAG_STATUS_DIR` | `~/.vaultspec-rag` | Service status and log directory |
|
|
154
|
+
| `VAULTSPEC_RAG_LOG_FILE` | `service.log` | Log filename, relative to status dir |
|
|
155
|
+
| `VAULTSPEC_RAG_PORT` | `8766` | MCP HTTP server port |
|
|
156
|
+
| `VAULTSPEC_RAG_LOG_LEVEL` | `WARNING` | Logging level |
|
|
157
|
+
|
|
158
|
+
The tool also respects two third-party environment variables. Set `HF_HOME` to control where HuggingFace caches downloaded models. Set `HF_HUB_DOWNLOAD_TIMEOUT` to increase the model download timeout.
|
|
159
|
+
|
|
160
|
+
### `.vaultragignore`
|
|
161
|
+
|
|
162
|
+
Place a `.vaultragignore` file at the project root to exclude files from codebase indexing. It uses gitignore syntax via `pathspec`. Patterns merge with CLI `--exclude` flags.
|
|
163
|
+
|
|
164
|
+
This file operates independently from `.gitignore` -- both apply with OR logic. The indexer skips any file excluded by either spec.
|
|
165
|
+
|
|
166
|
+
## Service management
|
|
167
|
+
|
|
168
|
+
### Foreground vs. background
|
|
169
|
+
|
|
170
|
+
`vaultspec-rag server mcp start` runs the MCP server in the foreground over stdio transport, suitable for direct LLM integration. Pass `--port` to switch to HTTP transport.
|
|
171
|
+
|
|
172
|
+
`vaultspec-rag server service start` spawns a background HTTP daemon. The default port is 8766; override it with `--port` or the `VAULTSPEC_RAG_PORT` env var.
|
|
173
|
+
|
|
174
|
+
The daemon is multi-tenant by design. It starts with no baked-in project root. The spawn process strips `VAULTSPEC_RAG_ROOT` from the daemon's environment so it cannot leak across projects. Every MCP tool call must carry an explicit `project_root`. See [MCP integration](#mcp-integration) for the client contract.
|
|
175
|
+
|
|
176
|
+
On startup, the daemon eagerly loads GPU models and polls `/health` until ready. It writes a status file to `~/.vaultspec-rag/service.json` containing the PID, port, and start time.
|
|
177
|
+
|
|
178
|
+
Stop the daemon with `vaultspec-rag server service stop`. This sends `SIGTERM` on Unix or `CTRL_BREAK_EVENT` on Windows, waits two seconds, then force-kills the process if needed.
|
|
179
|
+
|
|
180
|
+
### Health endpoint
|
|
181
|
+
|
|
182
|
+
The HTTP service exposes a `/health` endpoint returning JSON:
|
|
183
|
+
|
|
184
|
+
- `status` -- `ready` (models loaded), `degraded` (started but models failed), or `error` (not started)
|
|
185
|
+
- `cuda` -- boolean indicating GPU availability
|
|
186
|
+
- `models_loaded` -- boolean indicating whether all three models initialized
|
|
187
|
+
- `project_count` -- number of connected projects
|
|
188
|
+
- `uptime_s` -- seconds since startup
|
|
189
|
+
|
|
190
|
+
Check health from the CLI with `vaultspec-rag server service status`.
|
|
191
|
+
|
|
192
|
+
### Model warmup
|
|
193
|
+
|
|
194
|
+
`vaultspec-rag server service warmup` pre-downloads the three model weights (dense, sparse, reranker) to the local HuggingFace cache. Run this before first use to avoid cold-start delays on the initial server launch.
|
|
195
|
+
|
|
196
|
+
The command respects `HF_HOME` and `HF_HUB_DOWNLOAD_TIMEOUT` env vars.
|
|
197
|
+
|
|
198
|
+
## Indexing
|
|
199
|
+
|
|
200
|
+
Index vault documents (markdown in `.vault/`) or codebase source files, or both.
|
|
201
|
+
|
|
202
|
+
- `vaultspec-rag index --type vault` indexes vault documents. One document maps to one index entry.
|
|
203
|
+
- `vaultspec-rag index --type code` indexes source files. Tree-sitter handles structural chunking when grammars are available; text splitting serves as the fallback. Supported languages include Python, Rust, TypeScript, JavaScript, Go, Java, C/C++, C#, Ruby, and Kotlin.
|
|
204
|
+
- `vaultspec-rag index` (default `--type all`) indexes both.
|
|
205
|
+
- Add `--clean` to drop and recreate the index from scratch.
|
|
206
|
+
- Incremental indexing (the default) uses blake2b content hashing to detect changes.
|
|
207
|
+
- `--dry-run` lists files that would be indexed without writing anything (codebase only).
|
|
208
|
+
|
|
209
|
+
## Searching
|
|
210
|
+
|
|
211
|
+
- `vaultspec-rag search "query" --type vault` searches vault documents (default).
|
|
212
|
+
- `vaultspec-rag search "query" --type code` searches source code. Filters: `--language`, `--node-type`, `--function-name`, `--class-name`.
|
|
213
|
+
- Embed filters directly in the query string with tokens: `type:adr`, `feature:auth`, `lang:python`, `func:main`, `class:Engine`, `date:2026-03`.
|
|
214
|
+
- Results include score, file path, snippet, and (for code) line numbers and AST metadata.
|
|
215
|
+
|
|
216
|
+
## MCP integration
|
|
217
|
+
|
|
218
|
+
The MCP server exposes six tools:
|
|
219
|
+
|
|
220
|
+
| Tool | Purpose |
|
|
221
|
+
| ------------------ | ---------------------------------------- |
|
|
222
|
+
| `search_vault` | Search vault documents |
|
|
223
|
+
| `search_codebase` | Search source code with optional filters |
|
|
224
|
+
| `reindex_vault` | Re-index vault (incremental or clean) |
|
|
225
|
+
| `reindex_codebase` | Re-index codebase (incremental or clean) |
|
|
226
|
+
| `get_index_status` | Return index stats and GPU status |
|
|
227
|
+
| `get_code_file` | Retrieve full source file content |
|
|
228
|
+
|
|
229
|
+
The server runs in one of two transport modes, and the rules for the `project_root` parameter differ between them.
|
|
230
|
+
|
|
231
|
+
### stdio mode (single-project)
|
|
232
|
+
|
|
233
|
+
The MCP client launches `vaultspec-search-mcp` as a subprocess, one process per project. The server reads `VAULTSPEC_RAG_ROOT` from its environment, falling back to its current working directory.
|
|
234
|
+
|
|
235
|
+
- `project_root` is **optional** on every tool call. Omit it to use the env var or cwd.
|
|
236
|
+
- The `vault://{doc_id}` resource returns full document content.
|
|
237
|
+
- Suitable for Claude Desktop, Claude Code, or any client that spawns one MCP server per workspace.
|
|
238
|
+
|
|
239
|
+
Configure a Claude Desktop client like this:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"mcpServers": {
|
|
244
|
+
"vaultspec-rag": {
|
|
245
|
+
"command": "vaultspec-search-mcp",
|
|
246
|
+
"env": {
|
|
247
|
+
"VAULTSPEC_RAG_ROOT": "/path/to/your/project"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### HTTP mode (multi-project)
|
|
255
|
+
|
|
256
|
+
The server runs as a persistent daemon at `http://127.0.0.1:{port}/mcp` and serves multiple projects concurrently. The daemon starts with **no default project** -- `VAULTSPEC_RAG_ROOT` is stripped from its environment at spawn time.
|
|
257
|
+
|
|
258
|
+
- `project_root` is **required** on every tool call. Omitting it raises `ValueError: project_root is required in HTTP service mode -- the multi-tenant service has no default project`.
|
|
259
|
+
- The `vault://{doc_id}` resource is **not available** -- use `search_vault` or `get_code_file` with an explicit `project_root` instead.
|
|
260
|
+
- Suitable for shared services across multiple workspaces or CI environments.
|
|
261
|
+
|
|
262
|
+
Start the daemon and connect a client:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
vaultspec-rag server service start --port 8766
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Then point your MCP client at `http://127.0.0.1:8766/mcp` and pass `project_root` (an absolute path to a directory containing `.vault/`) on each tool invocation.
|
|
269
|
+
|
|
270
|
+
### Choosing a mode
|
|
271
|
+
|
|
272
|
+
Use stdio for desktop AI tools that work in one project at a time. The simpler config matches how those tools operate. Use HTTP to handle several projects from one service, or to share one GPU-loaded daemon across CLI and AI clients.
|
|
273
|
+
|
|
274
|
+
See [Service management](#service-management) for daemon lifecycle details.
|
|
275
|
+
|
|
276
|
+
## Python API
|
|
277
|
+
|
|
278
|
+
The `vaultspec_rag` package exports a facade in `vaultspec_rag.api`:
|
|
279
|
+
|
|
280
|
+
| Function | Purpose |
|
|
281
|
+
| ------------------------------------------------------------------ | ------------------------------------------------- |
|
|
282
|
+
| `index(root_dir, *, full=False)` | Index vault documents |
|
|
283
|
+
| `index_codebase(root_dir, *, full=False)` | Index source files |
|
|
284
|
+
| `search_vault(root_dir, query, *, top_k=5)` | Search vault |
|
|
285
|
+
| `search_codebase(root_dir, query, *, top_k=5, language=None, ...)` | Search code |
|
|
286
|
+
| `list_documents(root_dir, doc_type=None)` | List indexed documents |
|
|
287
|
+
| `get_related(root_dir, doc_id)` | Get graph relationships (outgoing/incoming links) |
|
|
288
|
+
|
|
289
|
+
All functions accept a `root_dir: Path` and manage a thread-safe singleton engine internally. The engine loads GPU models on first call.
|
|
290
|
+
|
|
291
|
+
## Models
|
|
292
|
+
|
|
293
|
+
| Component | Model | Role |
|
|
294
|
+
| ----------------- | ----------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
295
|
+
| Dense embeddings | [Qwen/Qwen3-Embedding-0.6B](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B) | 1024-dimensional semantic vectors |
|
|
296
|
+
| Sparse embeddings | [naver/splade-v3](https://huggingface.co/naver/splade-v3) | Learned term-weight vectors for keyword matching |
|
|
297
|
+
| Reranker | [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3) | Cross-encoder rescoring with sigmoid activation |
|
|
298
|
+
| Vector storage | [Qdrant](https://qdrant.tech/documentation/) (local mode) | Hybrid dense + sparse search with RRF fusion |
|
|
299
|
+
|
|
300
|
+
Qdrant's universal query API searches dense and sparse vectors together using reciprocal rank fusion. The reranker optionally rescores top candidates for improved precision.
|
|
301
|
+
|
|
302
|
+
## See also
|
|
303
|
+
|
|
304
|
+
- [Project background](../../README.md)
|
|
305
|
+
- [vaultspec-core](https://github.com/wgergely/vaultspec-core) -- the spec-driven development framework
|
|
306
|
+
- [MCP specification](https://modelcontextprotocol.io)
|
|
307
|
+
- [Qdrant documentation](https://qdrant.tech/documentation/)
|
|
308
|
+
- Model cards: [Qwen3-Embedding-0.6B](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B), [splade-v3](https://huggingface.co/naver/splade-v3), [bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3)
|
|
309
|
+
- [GitHub issues](https://github.com/wgergely/vaultspec-rag/issues)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""RAG (Retrieval-Augmented Generation) for vault documents.
|
|
2
|
+
|
|
3
|
+
GPU-native embedding and search pipeline for vault documents and codebase files.
|
|
4
|
+
Uses Qwen3-Embedding-0.6B for dense embeddings and SPLADE v3 for sparse embeddings,
|
|
5
|
+
with optional cross-encoder reranking (BAAI/bge-reranker-v2-m3). Hybrid search via
|
|
6
|
+
Qdrant local-mode vector database with unified query interface across vault documents,
|
|
7
|
+
codebase files, and vault relationship graphs.
|
|
8
|
+
|
|
9
|
+
Exports:
|
|
10
|
+
High-level API: index(), search_vault(), search_codebase(), search_all(),
|
|
11
|
+
index_codebase(), list_documents(), get_related()
|
|
12
|
+
|
|
13
|
+
Core classes: VaultStore, VaultSearcher, VaultIndexer, CodebaseIndexer,
|
|
14
|
+
EmbeddingModel, VaultDocument, CodeChunk, SearchResult, ParsedQuery
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
__version__: str = version("vaultspec-rag")
|
|
23
|
+
except PackageNotFoundError:
|
|
24
|
+
__version__ = "0.0.0.dev0"
|
|
25
|
+
|
|
26
|
+
from .api import (
|
|
27
|
+
GraphCache,
|
|
28
|
+
get_related,
|
|
29
|
+
index,
|
|
30
|
+
index_codebase,
|
|
31
|
+
list_documents,
|
|
32
|
+
search_codebase,
|
|
33
|
+
search_vault,
|
|
34
|
+
)
|
|
35
|
+
from .embeddings import EmbeddingModel, SparseResult
|
|
36
|
+
from .indexer import CodebaseIndexer, IndexResult, VaultIndexer, prepare_document
|
|
37
|
+
from .search import (
|
|
38
|
+
ParsedQuery,
|
|
39
|
+
SearchResult,
|
|
40
|
+
VaultSearcher,
|
|
41
|
+
parse_query,
|
|
42
|
+
rerank_with_graph,
|
|
43
|
+
)
|
|
44
|
+
from .store import CodeChunk, VaultDocument, VaultStore
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"CodeChunk",
|
|
48
|
+
"CodebaseIndexer",
|
|
49
|
+
"EmbeddingModel",
|
|
50
|
+
"GraphCache",
|
|
51
|
+
"IndexResult",
|
|
52
|
+
"ParsedQuery",
|
|
53
|
+
"SearchResult",
|
|
54
|
+
"SparseResult",
|
|
55
|
+
"VaultDocument",
|
|
56
|
+
"VaultIndexer",
|
|
57
|
+
"VaultSearcher",
|
|
58
|
+
"VaultStore",
|
|
59
|
+
"__version__",
|
|
60
|
+
"get_related",
|
|
61
|
+
"index",
|
|
62
|
+
"index_codebase",
|
|
63
|
+
"list_documents",
|
|
64
|
+
"parse_query",
|
|
65
|
+
"prepare_document",
|
|
66
|
+
"rerank_with_graph",
|
|
67
|
+
"search_codebase",
|
|
68
|
+
"search_vault",
|
|
69
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Package execution shim for ``python -m vaultspec_rag``.
|
|
2
|
+
|
|
3
|
+
This module delegates directly to the root Typer application defined in
|
|
4
|
+
``vaultspec_rag.cli`` so package execution and the installed CLI entrypoint
|
|
5
|
+
share the same command surface.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from vaultspec_rag.cli import app
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> None:
|
|
12
|
+
"""Entry point for ``python -m vaultspec_rag``.
|
|
13
|
+
|
|
14
|
+
Delegates to the root Typer CLI application.
|
|
15
|
+
"""
|
|
16
|
+
app()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
main()
|