@softerist/heuristic-mcp 2.1.46 → 3.0.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.
- package/.agent/workflows/code-review.md +60 -0
- package/.prettierrc +7 -0
- package/ARCHITECTURE.md +105 -170
- package/CONTRIBUTING.md +32 -113
- package/GEMINI.md +73 -0
- package/LICENSE +21 -21
- package/README.md +161 -54
- package/config.json +876 -76
- package/debug-pids.js +27 -0
- package/eslint.config.js +36 -0
- package/features/ann-config.js +37 -26
- package/features/clear-cache.js +28 -19
- package/features/find-similar-code.js +142 -66
- package/features/hybrid-search.js +253 -93
- package/features/index-codebase.js +1455 -394
- package/features/lifecycle.js +813 -180
- package/features/register.js +58 -52
- package/index.js +450 -306
- package/lib/cache-ops.js +22 -0
- package/lib/cache-utils.js +68 -0
- package/lib/cache.js +1392 -587
- package/lib/call-graph.js +165 -50
- package/lib/cli.js +154 -0
- package/lib/config.js +462 -121
- package/lib/embedding-process.js +77 -0
- package/lib/embedding-worker.js +545 -30
- package/lib/ignore-patterns.js +61 -59
- package/lib/json-worker.js +14 -0
- package/lib/json-writer.js +344 -0
- package/lib/logging.js +88 -0
- package/lib/memory-logger.js +13 -0
- package/lib/project-detector.js +13 -17
- package/lib/server-lifecycle.js +38 -0
- package/lib/settings-editor.js +645 -0
- package/lib/tokenizer.js +207 -104
- package/lib/utils.js +273 -198
- package/lib/vector-store-binary.js +592 -0
- package/mcp_config.example.json +13 -0
- package/package.json +13 -2
- package/scripts/clear-cache.js +6 -17
- package/scripts/download-model.js +14 -9
- package/scripts/postinstall.js +5 -5
- package/search-configs.js +36 -0
- package/test/ann-config.test.js +179 -0
- package/test/ann-fallback.test.js +6 -6
- package/test/binary-store.test.js +69 -0
- package/test/cache-branches.test.js +120 -0
- package/test/cache-errors.test.js +264 -0
- package/test/cache-extra.test.js +300 -0
- package/test/cache-helpers.test.js +205 -0
- package/test/cache-hnsw-failure.test.js +40 -0
- package/test/cache-json-worker.test.js +190 -0
- package/test/cache-worker.test.js +102 -0
- package/test/cache.test.js +443 -0
- package/test/call-graph.test.js +103 -4
- package/test/clear-cache.test.js +69 -68
- package/test/code-review-workflow.test.js +50 -0
- package/test/config.test.js +418 -0
- package/test/coverage-gap.test.js +497 -0
- package/test/coverage-maximizer.test.js +236 -0
- package/test/debug-analysis.js +107 -0
- package/test/embedding-model.test.js +173 -103
- package/test/embedding-worker-extra.test.js +272 -0
- package/test/embedding-worker.test.js +158 -0
- package/test/features.test.js +139 -0
- package/test/final-boost.test.js +271 -0
- package/test/final-polish.test.js +183 -0
- package/test/final.test.js +95 -0
- package/test/find-similar-code.test.js +191 -0
- package/test/helpers.js +92 -11
- package/test/helpers.test.js +46 -0
- package/test/hybrid-search-basic.test.js +62 -0
- package/test/hybrid-search-branch.test.js +202 -0
- package/test/hybrid-search-callgraph.test.js +229 -0
- package/test/hybrid-search-extra.test.js +81 -0
- package/test/hybrid-search.test.js +484 -71
- package/test/index-cli.test.js +520 -0
- package/test/index-codebase-batch.test.js +119 -0
- package/test/index-codebase-branches.test.js +585 -0
- package/test/index-codebase-core.test.js +1032 -0
- package/test/index-codebase-edge-cases.test.js +254 -0
- package/test/index-codebase-errors.test.js +132 -0
- package/test/index-codebase-gap.test.js +239 -0
- package/test/index-codebase-lines.test.js +151 -0
- package/test/index-codebase-watcher.test.js +259 -0
- package/test/index-codebase-zone.test.js +259 -0
- package/test/index-codebase.test.js +371 -69
- package/test/index-memory.test.js +220 -0
- package/test/indexer-detailed.test.js +176 -0
- package/test/integration.test.js +148 -92
- package/test/json-worker.test.js +50 -0
- package/test/lifecycle.test.js +541 -0
- package/test/master.test.js +198 -0
- package/test/perfection.test.js +349 -0
- package/test/project-detector.test.js +65 -0
- package/test/register.test.js +262 -0
- package/test/tokenizer.test.js +55 -93
- package/test/ultra-maximizer.test.js +116 -0
- package/test/utils-branches.test.js +161 -0
- package/test/utils-extra.test.js +116 -0
- package/test/utils.test.js +131 -0
- package/test/verify_fixes.js +76 -0
- package/test/worker-errors.test.js +96 -0
- package/test/worker-init.test.js +102 -0
- package/test/worker_throttling.test.js +93 -0
- package/tools/scripts/benchmark-search.js +95 -0
- package/tools/scripts/cache-stats.js +71 -0
- package/tools/scripts/manual-search.js +34 -0
- package/vitest.config.js +19 -9
package/GEMINI.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Heuristic MCP
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
**@softerist/heuristic-mcp** is an enhanced Model Context Protocol (MCP) server designed to provide intelligent semantic code search capabilities. It integrates features like find-similar-code, recency-aware ranking, call-graph proximity boosts, and smart chunking to improve code retrieval accuracy for AI assistants (Antigravity, Cursor, Claude Desktop, VS Code).
|
|
6
|
+
|
|
7
|
+
**Key Features:**
|
|
8
|
+
* **Semantic Search:** Finds code by meaning using embeddings.
|
|
9
|
+
* **Smart Indexing:** Automatically detects project types and applies ignores.
|
|
10
|
+
* **Recency & Proximity:** Boosts results based on file modification time and call graph relationships.
|
|
11
|
+
* **ANN Index:** Optional Approximate Nearest Neighbor index for performance on large codebases.
|
|
12
|
+
* **Zero-touch Setup:** Auto-registers with supported IDEs.
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
The project follows a modular architecture:
|
|
17
|
+
|
|
18
|
+
* **`index.js`**: Main entry point. Initializes the MCP server, loads configuration, and registers features.
|
|
19
|
+
* **`lib/`**: Core libraries.
|
|
20
|
+
* `config.js`: Configuration loader and environment variable handling.
|
|
21
|
+
* `cache.js`: Manages embedding vectors persistence and ANN index.
|
|
22
|
+
* `cache-utils.js`: Stale cache detection/cleanup.
|
|
23
|
+
* `utils.js`: Shared utilities (hashing, similarity, smart chunking).
|
|
24
|
+
* `call-graph.js`: Extracts symbols and builds a lightweight call graph.
|
|
25
|
+
* `tokenizer.js`: Token estimation.
|
|
26
|
+
* `embedding-worker.js`: Worker-thread embedder runner.
|
|
27
|
+
* `embedding-process.js`: Child-process embedder runner (isolation).
|
|
28
|
+
* `ignore-patterns.js`: Smart ignore patterns by detected project type.
|
|
29
|
+
* `json-worker.js` / `json-writer.js`: Streaming JSON helpers.
|
|
30
|
+
* `logging.js`: Log file helpers.
|
|
31
|
+
* **`features/`**: Pluggable feature modules. Each module exports a class, tool definition, and handler.
|
|
32
|
+
* `hybrid-search.js`: Semantic search logic.
|
|
33
|
+
* `index-codebase.js`: File discovery and indexing.
|
|
34
|
+
* `find-similar-code.js`: Logic for finding similar snippets.
|
|
35
|
+
* `lifecycle.js` & `register.js`: CLI and IDE registration helpers.
|
|
36
|
+
* **`scripts/`**: Utility scripts (postinstall, model download, cache clearing).
|
|
37
|
+
* **`tools/`**: Developer-only helpers (manual search script).
|
|
38
|
+
|
|
39
|
+
## Building and Running
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
* Node.js >= 18.0.0
|
|
43
|
+
|
|
44
|
+
### Key Commands
|
|
45
|
+
|
|
46
|
+
| Command | Description |
|
|
47
|
+
| :--- | :--- |
|
|
48
|
+
| `npm start` | Runs the server (production mode). |
|
|
49
|
+
| `npm run dev` | Runs the server in development mode (watch mode). |
|
|
50
|
+
| `npm test` | Runs the test suite using Vitest. |
|
|
51
|
+
| `npm run clean` | Clears the cache directory. |
|
|
52
|
+
| `npm run lint` | Runs ESLint. |
|
|
53
|
+
| `npm run format` | Runs Prettier. |
|
|
54
|
+
|
|
55
|
+
**Note on Testing:** Tests are configured to run sequentially (`fileParallelism: false`) to manage memory usage of the embedding models. Use `USE_REAL_EMBEDDER=true npm test` to test with the actual model instead of mocks.
|
|
56
|
+
|
|
57
|
+
## Development Conventions
|
|
58
|
+
|
|
59
|
+
* **Style:** Modern ES6+ JavaScript.
|
|
60
|
+
* **Modularity:** New features should be added as separate modules in `features/` following the pattern:
|
|
61
|
+
1. **Class:** `export class FeatureName { ... }`
|
|
62
|
+
2. **Tool Def:** `export function getToolDefinition(config) { ... }`
|
|
63
|
+
3. **Handler:** `export async function handleToolCall(request, instance) { ... }`
|
|
64
|
+
* **Logging:** Use `console.info()` for normal server lifecycle output (redirected to logs when running in MCP mode). Use `console.warn()` for non-fatal issues and `console.error()` for errors. CLI utilities may also use `console.info()` for user-facing output.
|
|
65
|
+
* **Configuration:** All features should accept a `config` object. Environment variables (prefix `SMART_CODING_`) override `config.json` values.
|
|
66
|
+
|
|
67
|
+
## Key Files
|
|
68
|
+
|
|
69
|
+
* **`package.json`**: Dependencies and scripts.
|
|
70
|
+
* **`config.json`**: Default/example configuration.
|
|
71
|
+
* **`ARCHITECTURE.md`**: Detailed architectural documentation.
|
|
72
|
+
* **`CONTRIBUTING.md`**: Guidelines for contributors.
|
|
73
|
+
* **`vitest.config.js`**: Test runner configuration.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Omar Haris
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Omar Haris
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,117 +1,224 @@
|
|
|
1
|
-
# Heuristic MCP Server
|
|
1
|
+
# Heuristic MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> Optimized for Antigravity, Cursor, and Claude Desktop.
|
|
3
|
+
An enhanced MCP server for your codebase. It provides intelligent semantic search, find-similar-code, recency-aware ranking, call-graph proximity boosts, and smart chunking. Optimized for Antigravity, Cursor, Claude Desktop, and VS Code.
|
|
5
4
|
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Key Features
|
|
9
8
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
9
|
+
- Zero-touch setup: postinstall auto-registers the MCP server with supported IDEs when possible.
|
|
10
|
+
- Smart indexing: detects project type and applies smart ignore patterns on top of your excludes.
|
|
11
|
+
- Semantic search: find code by meaning, not just keywords.
|
|
12
|
+
- Find similar code: locate near-duplicate or related patterns from a snippet.
|
|
13
|
+
- Recency ranking and call-graph boosting: surfaces fresh and related code.
|
|
14
|
+
- Optional ANN index: faster candidate retrieval for large codebases.
|
|
15
|
+
- Optional binary vector store: mmap-friendly cache format for large repos.
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
18
|
-
##
|
|
19
|
+
## Installation
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
Install globally (recommended):
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
24
|
npm install -g @softerist/heuristic-mcp
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
27
|
+
What happens during install:
|
|
28
|
+
|
|
29
|
+
- Registration runs automatically (`scripts/postinstall.js`).
|
|
30
|
+
- Model pre-download is attempted (`scripts/download-model.js`). If offline, it will be skipped and downloaded on first run.
|
|
31
|
+
|
|
32
|
+
If auto-registration did not update your IDE config, run:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
heuristic-mcp --register
|
|
36
|
+
```
|
|
30
37
|
|
|
31
38
|
---
|
|
32
39
|
|
|
33
|
-
##
|
|
40
|
+
## CLI Commands
|
|
41
|
+
|
|
42
|
+
The `heuristic-mcp` binary manages the server lifecycle.
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
### Status
|
|
36
45
|
|
|
37
|
-
### Check Health & Status (Snapshots)
|
|
38
|
-
Use this to verify if the server is running and check indexing progress.
|
|
39
46
|
```bash
|
|
40
47
|
heuristic-mcp --status
|
|
41
48
|
```
|
|
42
|
-
**Output:**
|
|
43
|
-
- 🟢 **Server Status**: Shows if the background process is running (PID).
|
|
44
|
-
- 📁 **Cache Info**: Shows number of files indexed, chunks, and "Initializing..." status if still working.
|
|
45
|
-
- ⚙️ **Config Check**: Validates that your IDE config files exist.
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
Shows server PID(s) and cache stats.
|
|
51
|
+
|
|
52
|
+
### Logs
|
|
53
|
+
|
|
49
54
|
```bash
|
|
50
55
|
heuristic-mcp --logs
|
|
51
56
|
```
|
|
52
|
-
**Output:**
|
|
53
|
-
- Streams live logs from the server.
|
|
54
|
-
- Shows file indexing progress (`Processing 100/236 files...`).
|
|
55
|
-
- Useful for debugging why a specific file isn't being indexed.
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
Tails the server log for the current workspace (defaults to last 200 lines and follows).
|
|
59
|
+
|
|
60
|
+
Optional flags:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
heuristic-mcp --logs --tail 100
|
|
64
|
+
heuristic-mcp --logs --no-follow
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Version
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
heuristic-mcp --version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Register (manual)
|
|
74
|
+
|
|
59
75
|
```bash
|
|
60
76
|
heuristic-mcp --register
|
|
77
|
+
heuristic-mcp --register antigravity
|
|
78
|
+
heuristic-mcp --register cursor
|
|
79
|
+
heuristic-mcp --register "Claude Desktop"
|
|
61
80
|
```
|
|
62
81
|
|
|
63
|
-
### Stop
|
|
64
|
-
|
|
82
|
+
### Start/Stop
|
|
83
|
+
|
|
65
84
|
```bash
|
|
85
|
+
heuristic-mcp --start
|
|
66
86
|
heuristic-mcp --stop
|
|
67
87
|
```
|
|
68
88
|
|
|
89
|
+
`--stop` also disables the MCP server entry in supported IDE configs so the IDE won't immediately respawn it. `--start` re-enables it (restart/reload the IDE to launch).
|
|
90
|
+
|
|
69
91
|
### Clear Cache
|
|
70
|
-
|
|
92
|
+
|
|
71
93
|
```bash
|
|
72
|
-
heuristic-mcp --
|
|
94
|
+
heuristic-mcp --clear-cache
|
|
73
95
|
```
|
|
74
96
|
|
|
97
|
+
Clears the cache for the current working directory (or `--workspace` if provided) and removes stale cache directories without metadata.
|
|
98
|
+
|
|
75
99
|
---
|
|
76
100
|
|
|
77
|
-
##
|
|
101
|
+
## Configuration (`config.json`)
|
|
102
|
+
|
|
103
|
+
Configuration is loaded from your workspace root when the server runs with `--workspace` (this is how IDEs launch it). In server mode, it falls back to the package `config.json` and then your current working directory.
|
|
78
104
|
|
|
79
|
-
|
|
105
|
+
Example `config.json`:
|
|
80
106
|
|
|
81
107
|
```json
|
|
82
108
|
{
|
|
83
109
|
"excludePatterns": ["**/legacy-code/**", "**/*.test.ts"],
|
|
110
|
+
"fileNames": ["Dockerfile", ".env.example", "Makefile"],
|
|
84
111
|
"smartIndexing": true,
|
|
85
|
-
"embeddingModel": "
|
|
86
|
-
"workerThreads":
|
|
112
|
+
"embeddingModel": "jinaai/jina-embeddings-v2-base-code",
|
|
113
|
+
"workerThreads": 0,
|
|
114
|
+
"recencyBoost": 0.1,
|
|
115
|
+
"recencyDecayDays": 30,
|
|
116
|
+
"callGraphEnabled": true,
|
|
117
|
+
"callGraphBoost": 0.15,
|
|
118
|
+
"annEnabled": true,
|
|
119
|
+
"vectorStoreFormat": "binary",
|
|
120
|
+
"vectorStoreContentMode": "external",
|
|
121
|
+
"vectorStoreLoadMode": "disk",
|
|
122
|
+
"contentCacheEntries": 256,
|
|
123
|
+
"vectorCacheEntries": 64,
|
|
124
|
+
"clearCacheAfterIndex": true
|
|
87
125
|
}
|
|
88
126
|
```
|
|
89
127
|
|
|
128
|
+
Cache location:
|
|
129
|
+
|
|
130
|
+
- By default, the cache is stored in a global OS cache directory under `heuristic-mcp/<hash>`.
|
|
131
|
+
- You can override with `cacheDirectory` in `config.json`.
|
|
132
|
+
|
|
90
133
|
### Environment Variables
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
|
|
135
|
+
Selected overrides (prefix `SMART_CODING_`):
|
|
136
|
+
|
|
137
|
+
- `SMART_CODING_VERBOSE=true|false`
|
|
138
|
+
- `SMART_CODING_WORKER_THREADS=auto|0|N`
|
|
139
|
+
- `SMART_CODING_BATCH_SIZE=100`
|
|
140
|
+
- `SMART_CODING_CHUNK_SIZE=25`
|
|
141
|
+
- `SMART_CODING_MAX_RESULTS=5`
|
|
142
|
+
- `SMART_CODING_RECENCY_BOOST=0.1`
|
|
143
|
+
- `SMART_CODING_RECENCY_DECAY_DAYS=30`
|
|
144
|
+
- `SMART_CODING_ANN_ENABLED=true|false`
|
|
145
|
+
- `SMART_CODING_ANN_EF_SEARCH=64`
|
|
146
|
+
- `SMART_CODING_VECTOR_STORE_FORMAT=json|binary`
|
|
147
|
+
- `SMART_CODING_VECTOR_STORE_CONTENT_MODE=external|inline`
|
|
148
|
+
- `SMART_CODING_VECTOR_STORE_LOAD_MODE=memory|disk`
|
|
149
|
+
- `SMART_CODING_CONTENT_CACHE_ENTRIES=256`
|
|
150
|
+
- `SMART_CODING_VECTOR_CACHE_ENTRIES=64`
|
|
151
|
+
- `SMART_CODING_CLEAR_CACHE_AFTER_INDEX=true|false`
|
|
152
|
+
|
|
153
|
+
See `lib/config.js` for the full list.
|
|
154
|
+
|
|
155
|
+
### Binary Vector Store
|
|
156
|
+
|
|
157
|
+
Set `vectorStoreFormat` to `binary` to use the on-disk binary cache. This keeps vectors and content out of JS heap
|
|
158
|
+
and reads on demand. Recommended for large repos.
|
|
159
|
+
|
|
160
|
+
- `vectorStoreContentMode=external` keeps content in the binary file and only loads for top-N results.
|
|
161
|
+
- `contentCacheEntries` controls the small in-memory LRU for decoded content strings.
|
|
162
|
+
- `vectorStoreLoadMode=disk` streams vectors from disk to reduce memory usage.
|
|
163
|
+
- `vectorCacheEntries` controls the small in-memory LRU for vectors when using disk mode.
|
|
164
|
+
- `clearCacheAfterIndex=true` drops in-memory vectors after indexing and reloads lazily on next query.
|
|
165
|
+
- Note: `annEnabled=true` with `vectorStoreLoadMode=disk` can increase disk reads during ANN rebuilds on large indexes.
|
|
166
|
+
|
|
167
|
+
### Benchmarking Search
|
|
168
|
+
|
|
169
|
+
Use the built-in script to compare memory vs latency tradeoffs:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
node tools/scripts/benchmark-search.js --query "database connection" --runs 10
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Compare modes quickly:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
SMART_CODING_VECTOR_STORE_LOAD_MODE=memory node tools/scripts/benchmark-search.js --runs 10
|
|
179
|
+
SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
|
|
180
|
+
SMART_CODING_VECTOR_STORE_FORMAT=binary SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Note: On small repos, disk mode may be slightly slower and show noisy RSS deltas; benefits are clearer on large indexes with a small `vectorCacheEntries`.
|
|
94
184
|
|
|
95
185
|
---
|
|
96
186
|
|
|
97
|
-
##
|
|
187
|
+
## Troubleshooting
|
|
188
|
+
|
|
189
|
+
**Server isn't starting**
|
|
190
|
+
|
|
191
|
+
1. Run `heuristic-mcp --status` to check config and cache status.
|
|
192
|
+
2. Run `heuristic-mcp --logs` to see startup errors.
|
|
193
|
+
|
|
194
|
+
**Search returns no results**
|
|
195
|
+
|
|
196
|
+
- Check `heuristic-mcp --status` for indexing progress.
|
|
197
|
+
- If indexing shows zero files, review `excludePatterns` and `fileExtensions`.
|
|
198
|
+
|
|
199
|
+
**Model download fails**
|
|
98
200
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
201
|
+
- The install step tries to pre-download the model, but it can be skipped offline.
|
|
202
|
+
- The server will download on first run; ensure network access at least once.
|
|
203
|
+
|
|
204
|
+
**Clear cache**
|
|
205
|
+
|
|
206
|
+
- Use the MCP tool `c_clear_cache`, run `heuristic-mcp --clear-cache`, or delete the cache directory. For local dev, run `npm run clean`.
|
|
207
|
+
|
|
208
|
+
**Inspect cache**
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
node tools/scripts/cache-stats.js --workspace <path>
|
|
212
|
+
```
|
|
102
213
|
|
|
103
|
-
**
|
|
104
|
-
- Check `heuristic-mcp --status`. Does it say "Indexing: ✅ COMPLETE"?
|
|
105
|
-
- If it says "Initializing...", wait a moment.
|
|
106
|
-
- If it says "NO FILES", check your `.gitignore` or `excludePatterns`.
|
|
214
|
+
**Stop doesn't stick**
|
|
107
215
|
|
|
108
|
-
|
|
109
|
-
- We pre-download models during `npm install`. Try running `npm install -g @softerist/heuristic-mcp` again to retry the download.
|
|
216
|
+
- The IDE will auto-restart the server if it's still enabled in its config. `--stop` now disables the server entry for Antigravity, Cursor, Claude Desktop, and VS Code (when using common MCP settings keys). Restart the IDE after `--start` to re-enable.
|
|
110
217
|
|
|
111
218
|
---
|
|
112
219
|
|
|
113
|
-
##
|
|
220
|
+
## Contributing
|
|
114
221
|
|
|
115
|
-
|
|
222
|
+
See `CONTRIBUTING.md` for guidelines.
|
|
116
223
|
|
|
117
224
|
License: MIT
|