Skip to content

Commit 598913c

Browse files
committed
push
1 parent 9321f58 commit 598913c

23 files changed

Lines changed: 461 additions & 73 deletions

.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
QDRANT_URL=http://qdrant:6333
44
# QDRANT_API_KEY= # not needed for local
55

6-
# Default collection used by the MCP server (auto-created if missing)
7-
# COLLECTION_NAME=my-collection # Use auto-detected default from .codebase/state.json
6+
# Single unified collection for seamless cross-repo search
7+
# Default: "codebase" - all your code in one collection for unified search
8+
# This enables searching across multiple repos/workspaces without fragmentation
9+
COLLECTION_NAME=codebase
810

911
# Embedding settings (FastEmbed model)
1012
EMBEDDING_MODEL=BAAI/bge-base-en-v1.5

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Qdrant connection
22
QDRANT_URL=http://localhost:6333
33
QDRANT_API_KEY=
4-
COLLECTION_NAME=my-collection
4+
# Single unified collection for seamless cross-repo search (default: "codebase")
5+
# Leave unset or use "codebase" for unified search across all your code
6+
COLLECTION_NAME=codebase
57

68
# Embeddings
79
EMBEDDING_MODEL=BAAI/bge-base-en-v1.5

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ tests/.codebase/cache.json
2424
tests/.codebase/state.json
2525
/scripts/.codebase
2626
/tests/.codebase
27+
.claude/settings.local.json
28+
.mcp.json

README.md

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ INDEX_MICRO_CHUNKS=1 MAX_MICRO_CHUNKS_PER_FILE=200 make reset-dev-dual
4040
```
4141
- Default ports: Memory MCP :8000, Indexer MCP :8001, Qdrant :6333, llama.cpp :8080
4242

43+
**🎯 Seamless Setup Note:**
44+
- The stack uses a **single unified `codebase` collection** by default
45+
- All your code goes into one collection for seamless cross-repo search
46+
- No per-workspace fragmentation - search across everything at once
47+
- Health checks auto-detect and fix cache/collection sync issues
48+
- Just run `make reset-dev-dual` on any machine and it works™
49+
4350
### Make targets: SSE, RMCP, and dual-compat
4451
- Legacy SSE only (default):
4552
- Ports: 8000 (/sse), 8001 (/sse)
@@ -96,9 +103,10 @@ INDEX_MICRO_CHUNKS=1 MAX_MICRO_CHUNKS_PER_FILE=200 make reset-dev-dual
96103
GLM_MODEL=glm-4.6 # Optional, defaults to glm-4.6
97104
```
98105

99-
5. **Custom collection name**:
106+
5. **Collection name** (unified by default):
100107
```bash
101-
COLLECTION_NAME=my-project # Defaults to auto-detected repo name
108+
COLLECTION_NAME=codebase # Default: single unified collection for all code
109+
# Only change this if you need isolated collections per project
102110
```
103111

104112
**After changing `.env`:**
@@ -280,7 +288,7 @@ Ports
280288

281289
| Name | Description | Default |
282290
|------|-------------|---------|
283-
| COLLECTION_NAME | Qdrant collection name used by both servers | my-collection |
291+
| COLLECTION_NAME | Qdrant collection name (unified across all repos) | codebase |
284292
| REPO_NAME | Logical repo tag stored in payload for filtering | auto-detect from git/folder |
285293
| HOST_INDEX_PATH | Host path mounted at /work in containers | current repo (.) |
286294
| QDRANT_URL | Qdrant base URL | container: http://qdrant:6333; local: http://localhost:6333 |
@@ -763,6 +771,50 @@ Notes:
763771
- Named vector remains aligned with the MCP server (fast-bge-base-en-v1.5). If you change EMBEDDING_MODEL, run `make reindex` to recreate the collection.
764772
- For very large repos, consider running `make index` on a schedule (or pre-commit) to keep Qdrant warm without full reingestion.
765773

774+
### Multi-repo indexing (unified search)
775+
776+
The stack uses a **single unified `codebase` collection** by default, making multi-repo search seamless:
777+
778+
**Index another repo into the same collection:**
779+
```bash
780+
# From your qdrant directory
781+
make index-here HOST_INDEX_PATH=/path/to/other/repo REPO_NAME=other-repo
782+
783+
# Or with full control:
784+
HOST_INDEX_PATH=/path/to/other/repo \
785+
COLLECTION_NAME=codebase \
786+
REPO_NAME=other-repo \
787+
docker compose run --rm indexer --root /work
788+
```
789+
790+
**What happens:**
791+
- Files from the other repo get indexed into the unified `codebase` collection
792+
- Each file is tagged with `metadata.repo = "other-repo"` for filtering
793+
- Search across all repos by default, or filter by specific repo
794+
795+
**Search examples:**
796+
```bash
797+
# Search across all indexed repos
798+
make hybrid QUERY="authentication logic"
799+
800+
# Filter by specific repo
801+
python scripts/hybrid_search.py \
802+
--query "authentication logic" \
803+
--repo other-repo
804+
805+
# Filter by repo + language
806+
python scripts/hybrid_search.py \
807+
--query "authentication logic" \
808+
--repo other-repo \
809+
--language python
810+
```
811+
812+
**Benefits:**
813+
- One collection = unified search across all your code
814+
- No fragmentation or collection management overhead
815+
- Filter by repo when you need isolation
816+
- All repos share the same vector space for better semantic search
817+
766818
### Multi-query re-ranker (no new deps)
767819

768820
- Run a fused query with several phrasings and metadata-aware boosts:
@@ -1296,6 +1348,39 @@ Client tips:
12961348
12971349
## Troubleshooting
12981350
1351+
### Collection Health & Cache Sync
1352+
1353+
The stack includes automatic health checks that detect and fix cache/collection sync issues:
1354+
1355+
**Check collection health:**
1356+
```bash
1357+
python scripts/collection_health.py --workspace . --collection codebase
1358+
```
1359+
1360+
**Auto-heal cache issues:**
1361+
```bash
1362+
python scripts/collection_health.py --workspace . --collection codebase --auto-heal
1363+
```
1364+
1365+
**What it detects:**
1366+
- Empty collection with cached files (cache thinks files are indexed but they're not)
1367+
- Significant mismatch between cached files and actual collection contents
1368+
- Missing metadata in collection points
1369+
1370+
**When to use:**
1371+
- After manually deleting collections
1372+
- If searches return no results despite indexing
1373+
- After Qdrant crashes or data loss
1374+
- When switching between collection names
1375+
1376+
**Automatic healing:**
1377+
- Health checks run automatically on watcher and indexer startup
1378+
- Cache is cleared when sync issues are detected
1379+
- Files are reindexed on next run
1380+
1381+
### General Issues
1382+
12991383
- If the MCP servers can’t reach Qdrant, confirm both containers are up: `make ps`.
13001384
- If the SSE port collides, change `FASTMCP_PORT` in `.env` and the mapped port in `docker-compose.yml`.
13011385
- If you customize tool descriptions, restart: `make restart`.
1386+
- If searches return no results, check collection health (see above).

docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
- FASTMCP_HOST=${FASTMCP_HOST}
2525
- FASTMCP_PORT=${FASTMCP_PORT}
2626
- QDRANT_URL=${QDRANT_URL}
27-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
27+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
2828
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
2929
- EMBEDDING_PROVIDER=${EMBEDDING_PROVIDER}
3030
- TOOL_STORE_DESCRIPTION=${TOOL_STORE_DESCRIPTION}
@@ -60,7 +60,7 @@ services:
6060
- USE_GPU_DECODER=${USE_GPU_DECODER:-0}
6161
- LLAMACPP_TIMEOUT_SEC=${LLAMACPP_TIMEOUT_SEC:-180}
6262
- CTX_REQUIRE_IDENTIFIER=${CTX_REQUIRE_IDENTIFIER:-0}
63-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
63+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
6464
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
6565
# SSE endpoint for IDE agents at http://localhost:${FASTMCP_INDEXER_PORT:-8001}/sse
6666
ports:
@@ -84,7 +84,7 @@ services:
8484
- FASTMCP_PORT=8000
8585
- FASTMCP_TRANSPORT=${FASTMCP_HTTP_TRANSPORT}
8686
- QDRANT_URL=${QDRANT_URL}
87-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
87+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
8888
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
8989
- EMBEDDING_PROVIDER=${EMBEDDING_PROVIDER}
9090
- TOOL_STORE_DESCRIPTION=${TOOL_STORE_DESCRIPTION}
@@ -119,7 +119,7 @@ services:
119119
- USE_GPU_DECODER=${USE_GPU_DECODER:-0}
120120
- LLAMACPP_TIMEOUT_SEC=${LLAMACPP_TIMEOUT_SEC:-180}
121121
- CTX_REQUIRE_IDENTIFIER=${CTX_REQUIRE_IDENTIFIER:-0}
122-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
122+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
123123
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
124124
# Streamable HTTP endpoint for IDE agents at http://localhost:${FASTMCP_INDEXER_HTTP_PORT:-8003}/mcp/
125125
ports:
@@ -186,7 +186,7 @@ services:
186186
- .env
187187
environment:
188188
- QDRANT_URL=${QDRANT_URL}
189-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
189+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
190190
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
191191
working_dir: /work
192192
volumes:
@@ -205,7 +205,7 @@ services:
205205
- .env
206206
environment:
207207
- QDRANT_URL=${QDRANT_URL}
208-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
208+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
209209
- EMBEDDING_MODEL=${EMBEDDING_MODEL}
210210
- WATCH_ROOT=/work
211211
# Watcher-specific backpressure & timeouts (safer defaults)
@@ -231,7 +231,7 @@ services:
231231
- .env
232232
environment:
233233
- QDRANT_URL=${QDRANT_URL}
234-
- COLLECTION_NAME=${COLLECTION_NAME:-my-collection}
234+
- COLLECTION_NAME=${COLLECTION_NAME:-codebase}
235235
working_dir: /work
236236
volumes:
237237
- ${HOST_INDEX_PATH:-.}:/work:ro

scripts/add_vector_name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from qdrant_client import QdrantClient, models
44

55
QDRANT_URL = os.environ.get("QDRANT_URL", "http://qdrant:6333")
6-
COLLECTION = os.environ.get("COLLECTION_NAME", "my-collection")
6+
COLLECTION = os.environ.get("COLLECTION_NAME", "codebase")
77

88
cli = QdrantClient(url=QDRANT_URL)
99

0 commit comments

Comments
 (0)