@softerist/heuristic-mcp 3.0.14 → 3.0.16

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 (49) hide show
  1. package/README.md +90 -82
  2. package/config.jsonc +173 -173
  3. package/features/ann-config.js +131 -0
  4. package/features/clear-cache.js +84 -0
  5. package/features/find-similar-code.js +291 -0
  6. package/features/hybrid-search.js +544 -0
  7. package/features/index-codebase.js +3268 -0
  8. package/features/lifecycle.js +1189 -0
  9. package/features/package-version.js +302 -0
  10. package/features/register.js +408 -0
  11. package/features/resources.js +156 -0
  12. package/features/set-workspace.js +265 -0
  13. package/index.js +136 -69
  14. package/lib/cache-ops.js +22 -22
  15. package/lib/cache-utils.js +565 -565
  16. package/lib/cache.js +1870 -1870
  17. package/lib/call-graph.js +396 -396
  18. package/lib/cli.js +1 -1
  19. package/lib/config.js +487 -427
  20. package/lib/constants.js +31 -0
  21. package/lib/embed-query-process.js +7 -7
  22. package/lib/embedding-process.js +7 -7
  23. package/lib/embedding-worker.js +299 -299
  24. package/lib/ignore-patterns.js +316 -316
  25. package/lib/json-worker.js +14 -14
  26. package/lib/json-writer.js +337 -337
  27. package/lib/logging.js +164 -164
  28. package/lib/memory-logger.js +13 -13
  29. package/lib/onnx-backend.js +193 -193
  30. package/lib/project-detector.js +84 -84
  31. package/lib/server-lifecycle.js +165 -165
  32. package/lib/settings-editor.js +754 -638
  33. package/lib/tokenizer.js +256 -256
  34. package/lib/utils.js +428 -428
  35. package/lib/vector-store-binary.js +627 -627
  36. package/lib/vector-store-sqlite.js +95 -95
  37. package/lib/workspace-env.js +28 -0
  38. package/mcp_config.json +9 -9
  39. package/package.json +86 -75
  40. package/scripts/clear-cache.js +20 -0
  41. package/scripts/download-model.js +43 -0
  42. package/scripts/mcp-launcher.js +49 -0
  43. package/scripts/postinstall.js +12 -0
  44. package/search-configs.js +36 -36
  45. package/.prettierrc +0 -7
  46. package/debug-pids.js +0 -30
  47. package/eslint.config.js +0 -36
  48. package/specs/plan.md +0 -23
  49. package/vitest.config.js +0 -39
package/README.md CHANGED
@@ -78,13 +78,19 @@ heuristic-mcp --version
78
78
  ```bash
79
79
  heuristic-mcp --start
80
80
  heuristic-mcp --start antigravity
81
+ heuristic-mcp --start codex
81
82
  heuristic-mcp --start cursor
83
+ heuristic-mcp --start vscode
84
+ heuristic-mcp --start windsurf
85
+ heuristic-mcp --start warp
82
86
  heuristic-mcp --start "Claude Desktop"
83
87
  heuristic-mcp --stop
84
88
  ```
85
89
 
86
90
  `--start` registers (if needed) and enables the MCP server entry. `--stop` disables it so the IDE won't immediately respawn it. Restart/reload the IDE after `--start` to launch.
87
91
 
92
+ Warp note: this package now targets `~/.warp/mcp_settings.json` (and `%APPDATA%\\Warp\\mcp_settings.json` on Windows when present). If no local Warp MCP config is writable yet, use Warp MCP settings/UI once to initialize it, then re-run `--start warp`.
93
+
88
94
  ### Clear Cache
89
95
 
90
96
  ```bash
@@ -97,50 +103,50 @@ Clears the cache for the current working directory (or `--workspace` if provided
97
103
 
98
104
  ## Configuration (`config.jsonc`)
99
105
 
100
- 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.jsonc` (or `config.json`) and then your current working directory.
101
-
102
- Example `config.jsonc`:
103
-
104
- ```json
105
- {
106
- "excludePatterns": ["**/legacy-code/**", "**/*.test.ts"],
107
- "fileNames": ["Dockerfile", ".env.example", "Makefile"],
108
- "indexing": {
109
- "smartIndexing": true
110
- },
111
- "worker": {
112
- "workerThreads": 0
113
- },
114
- "embedding": {
115
- "embeddingModel": "jinaai/jina-embeddings-v2-base-code",
116
- "embeddingBatchSize": null,
117
- "embeddingProcessNumThreads": 8
118
- },
119
- "search": {
120
- "recencyBoost": 0.1,
121
- "recencyDecayDays": 30
122
- },
123
- "callGraph": {
124
- "callGraphEnabled": true,
125
- "callGraphBoost": 0.15
126
- },
127
- "ann": {
128
- "annEnabled": true
129
- },
130
- "vectorStore": {
131
- "vectorStoreFormat": "binary",
132
- "vectorStoreContentMode": "external",
133
- "vectorStoreLoadMode": "disk",
134
- "contentCacheEntries": 256,
135
- "vectorCacheEntries": 64
136
- },
137
- "memoryCleanup": {
138
- "clearCacheAfterIndex": true
139
- }
140
- }
141
- ```
142
-
143
- Preferred style is namespaced keys (shown above). Legacy top-level keys are still supported for backward compatibility.
106
+ Configuration is loaded from your workspace root when the server runs with `--workspace`. If not provided by the IDE, the server auto-detects workspace via environment variables and current working directory. In server mode, it falls back to the package `config.jsonc` (or `config.json`) and then your current working directory.
107
+
108
+ Example `config.jsonc`:
109
+
110
+ ```json
111
+ {
112
+ "excludePatterns": ["**/legacy-code/**", "**/*.test.ts"],
113
+ "fileNames": ["Dockerfile", ".env.example", "Makefile"],
114
+ "indexing": {
115
+ "smartIndexing": true
116
+ },
117
+ "worker": {
118
+ "workerThreads": 0
119
+ },
120
+ "embedding": {
121
+ "embeddingModel": "jinaai/jina-embeddings-v2-base-code",
122
+ "embeddingBatchSize": null,
123
+ "embeddingProcessNumThreads": 8
124
+ },
125
+ "search": {
126
+ "recencyBoost": 0.1,
127
+ "recencyDecayDays": 30
128
+ },
129
+ "callGraph": {
130
+ "callGraphEnabled": true,
131
+ "callGraphBoost": 0.15
132
+ },
133
+ "ann": {
134
+ "annEnabled": true
135
+ },
136
+ "vectorStore": {
137
+ "vectorStoreFormat": "binary",
138
+ "vectorStoreContentMode": "external",
139
+ "vectorStoreLoadMode": "disk",
140
+ "contentCacheEntries": 256,
141
+ "vectorCacheEntries": 64
142
+ },
143
+ "memoryCleanup": {
144
+ "clearCacheAfterIndex": true
145
+ }
146
+ }
147
+ ```
148
+
149
+ Preferred style is namespaced keys (shown above). Legacy top-level keys are still supported for backward compatibility.
144
150
 
145
151
  ### Embedding Model & Dimension Options
146
152
 
@@ -150,14 +156,14 @@ Preferred style is namespaced keys (shown above). Legacy top-level keys are stil
150
156
 
151
157
  For faster search with smaller embeddings, switch to an MRL-compatible model:
152
158
 
153
- ```json
154
- {
155
- "embedding": {
156
- "embeddingModel": "nomic-ai/nomic-embed-text-v1.5",
157
- "embeddingDimension": 128
158
- }
159
- }
160
- ```
159
+ ```json
160
+ {
161
+ "embedding": {
162
+ "embeddingModel": "nomic-ai/nomic-embed-text-v1.5",
163
+ "embeddingDimension": 128
164
+ }
165
+ }
166
+ ```
161
167
 
162
168
  **MRL-compatible models:**
163
169
  - `nomic-ai/nomic-embed-text-v1.5` — recommended for 128d/256d
@@ -172,9 +178,9 @@ Cache location:
172
178
 
173
179
  ### Environment Variables
174
180
 
175
- Selected overrides (prefix `SMART_CODING_`):
176
-
177
- Environment overrides target runtime keys and are synced back into namespaces by `lib/config.js`.
181
+ Selected overrides (prefix `SMART_CODING_`):
182
+
183
+ Environment overrides target runtime keys and are synced back into namespaces by `lib/config.js`.
178
184
 
179
185
  - `SMART_CODING_VERBOSE=true|false` — enable detailed logging.
180
186
  - `SMART_CODING_WORKER_THREADS=auto|N` — worker thread count.
@@ -200,37 +206,37 @@ Environment overrides target runtime keys and are synced back into namespaces by
200
206
 
201
207
  See `lib/config.js` for the full list.
202
208
 
203
- ### Binary Vector Store
204
-
205
- Set `vectorStore.vectorStoreFormat` to `binary` to use the on-disk binary cache. This keeps vectors and content out of JS heap
206
- and reads on demand. Recommended for large repos.
207
-
208
- - `vectorStore.vectorStoreContentMode=external` keeps content in the binary file and only loads for top-N results.
209
- - `vectorStore.contentCacheEntries` controls the small in-memory LRU for decoded content strings.
210
- - `vectorStore.vectorStoreLoadMode=disk` streams vectors from disk to reduce memory usage.
211
- - `vectorStore.vectorCacheEntries` controls the small in-memory LRU for vectors when using disk mode.
212
- - `memoryCleanup.clearCacheAfterIndex=true` drops in-memory vectors after indexing and reloads lazily on next query.
213
- - `memoryCleanup.unloadModelAfterIndex=true` (default) unloads the embedding model after indexing to free ~500MB-1GB of RAM; the model will reload on the next search query.
214
- - Note: `ann.annEnabled=true` with `vectorStore.vectorStoreLoadMode=disk` can increase disk reads during ANN rebuilds on large indexes.
209
+ ### Binary Vector Store
210
+
211
+ Set `vectorStore.vectorStoreFormat` to `binary` to use the on-disk binary cache. This keeps vectors and content out of JS heap
212
+ and reads on demand. Recommended for large repos.
213
+
214
+ - `vectorStore.vectorStoreContentMode=external` keeps content in the binary file and only loads for top-N results.
215
+ - `vectorStore.contentCacheEntries` controls the small in-memory LRU for decoded content strings.
216
+ - `vectorStore.vectorStoreLoadMode=disk` streams vectors from disk to reduce memory usage.
217
+ - `vectorStore.vectorCacheEntries` controls the small in-memory LRU for vectors when using disk mode.
218
+ - `memoryCleanup.clearCacheAfterIndex=true` drops in-memory vectors after indexing and reloads lazily on next query.
219
+ - `memoryCleanup.unloadModelAfterIndex=true` (default) unloads the embedding model after indexing to free ~500MB-1GB of RAM; the model will reload on the next search query.
220
+ - Note: `ann.annEnabled=true` with `vectorStore.vectorStoreLoadMode=disk` can increase disk reads during ANN rebuilds on large indexes.
215
221
 
216
222
  ### SQLite Vector Store
217
223
 
218
- Set `vectorStore.vectorStoreFormat` to `sqlite` to use SQLite for persistence. This provides:
224
+ Set `vectorStore.vectorStoreFormat` to `sqlite` to use SQLite for persistence. This provides:
219
225
 
220
226
  - ACID transactions for reliable writes
221
227
  - Simpler concurrent access
222
228
  - Standard database format for inspection
223
229
 
224
- ```json
225
- {
226
- "vectorStore": {
227
- "vectorStoreFormat": "sqlite"
228
- }
229
- }
230
- ```
231
-
232
- The vectors and content are stored in `vectors.sqlite` in your cache directory. You can inspect it with any SQLite browser.
233
- `vectorStore.vectorStoreContentMode` and `vectorStore.vectorStoreLoadMode` are respected for SQLite (use `vectorStore.vectorStoreLoadMode=disk` to avoid loading vectors into memory).
230
+ ```json
231
+ {
232
+ "vectorStore": {
233
+ "vectorStoreFormat": "sqlite"
234
+ }
235
+ }
236
+ ```
237
+
238
+ The vectors and content are stored in `vectors.sqlite` in your cache directory. You can inspect it with any SQLite browser.
239
+ `vectorStore.vectorStoreContentMode` and `vectorStore.vectorStoreLoadMode` are respected for SQLite (use `vectorStore.vectorStoreLoadMode=disk` to avoid loading vectors into memory).
234
240
 
235
241
  **Tradeoffs vs Binary:**
236
242
  - Slightly higher read overhead (SQL queries vs direct memory access)
@@ -253,7 +259,7 @@ SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js
253
259
  SMART_CODING_VECTOR_STORE_FORMAT=binary SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
254
260
  ```
255
261
 
256
- Note: On small repos, disk mode may be slightly slower and show noisy RSS deltas; benefits are clearer on large indexes with a small `vectorStore.vectorCacheEntries`.
262
+ Note: On small repos, disk mode may be slightly slower and show noisy RSS deltas; benefits are clearer on large indexes with a small `vectorStore.vectorCacheEntries`.
257
263
 
258
264
  ---
259
265
 
@@ -294,6 +300,8 @@ Fetch the latest version of a package from its official registry.
294
300
  ### `f_set_workspace`
295
301
  Change the workspace directory at runtime. Updates search directory, cache location, and optionally triggers reindex.
296
302
 
303
+ The server also attempts this automatically before each tool call when it detects a new workspace path from environment variables (for example `CODEX_WORKSPACE`, `CODEX_PROJECT_ROOT`, `WORKSPACE_FOLDER`).
304
+
297
305
  **Parameters:**
298
306
  - `workspacePath` (required): Absolute path to the new workspace
299
307
  - `reindex` (optional, default: `true`): Whether to trigger a full reindex
@@ -316,8 +324,8 @@ Native ONNX backend unavailable: The operating system cannot run %1.
316
324
  ...onnxruntime_binding.node. Falling back to WASM.
317
325
  ```
318
326
 
319
- The server will automatically disable workers and force `embedding.embeddingProcessPerBatch` to reduce memory spikes, but you
320
- should fix the native binding to restore stable memory usage:
327
+ The server will automatically disable workers and force `embedding.embeddingProcessPerBatch` to reduce memory spikes, but you
328
+ should fix the native binding to restore stable memory usage:
321
329
 
322
330
  - Ensure you are running **64-bit Node.js** (`node -p "process.arch"` should be `x64`).
323
331
  - Install **Microsoft Visual C++ 2015–2022 Redistributable (x64)**.
@@ -357,7 +365,7 @@ node tools/scripts/cache-stats.js --workspace <path>
357
365
 
358
366
  **Stop doesn't stick**
359
367
 
360
- - 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.
368
+ - The IDE will auto-restart the server if it's still enabled in its config. `--stop` now disables the server entry for Antigravity, Cursor (including `~/.cursor/mcp.json`), Windsurf (`~/.codeium/windsurf/mcp_config.json`), Warp (`~/.warp/mcp_settings.json` and `%APPDATA%\\Warp\\mcp_settings.json` when present), Claude Desktop, and VS Code (when using common MCP settings keys). Restart the IDE after `--start` to re-enable.
361
369
 
362
370
  ---
363
371
 
package/config.jsonc CHANGED
@@ -615,180 +615,180 @@
615
615
  "makefile.in",
616
616
  ],
617
617
  // Glob patterns to exclude from indexing.
618
- "excludePatterns": [
619
- "**/node_modules/**",
620
- "**/dist/**",
621
- "**/build/**",
618
+ "excludePatterns": [
619
+ "**/node_modules/**",
620
+ "**/dist/**",
621
+ "**/build/**",
622
622
  "**/.git/**",
623
623
  "**/coverage/**",
624
624
  "**/.next/**",
625
625
  "**/target/**",
626
- "**/vendor/**",
627
- "**/.smart-coding-cache/**",
628
- ],
629
- // Indexing controls.
630
- "indexing": {
631
- // Enable project-type detection + smart ignore patterns.
632
- "smartIndexing": true,
633
- // Lines per chunk.
634
- "chunkSize": 16,
635
- // Overlapping lines between chunks.
636
- "chunkOverlap": 4,
637
- // Files per indexing batch.
638
- "batchSize": 50,
639
- // Skip files larger than this many bytes.
640
- "maxFileSize": 1048576,
641
- // Maximum number of search results.
642
- "maxResults": 5,
643
- // Enable file watcher for incremental indexing.
644
- "watchFiles": true,
645
- },
646
- // Logging and diagnostics.
647
- "logging": {
648
- // Enable verbose logging.
649
- "verbose": true,
650
- },
651
- // Cache engine and serialization controls.
652
- "cache": {
653
- // Persist embeddings between sessions.
654
- "enableCache": true,
655
- // Assume vectors are finite (skip validation).
656
- "cacheVectorAssumeFinite": true,
657
- // Decimal precision for cached vectors (null = default).
658
- "cacheVectorFloatDigits": null,
659
- // Write stream highWaterMark for cache files.
660
- "cacheWriteHighWaterMark": 262144,
661
- // Flush threshold (chars) for JSON writer.
662
- "cacheVectorFlushChars": 262144,
663
- // Validate vectors contain only finite numbers.
664
- "cacheVectorCheckFinite": true,
665
- // Avoid mutating vectors during serialization.
666
- "cacheVectorNoMutation": false,
667
- // Join threshold for JSON array chunks.
668
- "cacheVectorJoinThreshold": 8192,
669
- // Chunk size for JSON join optimization.
670
- "cacheVectorJoinChunkSize": 2048,
671
- // Wait time for active readers before saving cache (ms).
672
- "saveReaderWaitTimeoutMs": 5000,
673
- },
674
- // Stale cache cleanup policy.
675
- "cacheCleanup": {
676
- // Remove stale caches automatically.
677
- "autoCleanup": true,
678
- },
679
- // Worker-thread controls.
680
- "worker": {
681
- // Number of embedding workers (0 disables).
682
- // Windows + heavy Jina models are more stable with child-process embedding than worker pools.
683
- "workerThreads": 0,
684
- // Worker batch timeout in milliseconds.
685
- "workerBatchTimeoutMs": 120000,
686
- // Failures before worker circuit opens.
687
- "workerFailureThreshold": 1,
688
- // Cooldown before re-enabling workers (ms).
689
- "workerFailureCooldownMs": 600000,
690
- // Max chunks per worker batch.
691
- "workerMaxChunksPerBatch": 20,
692
- // Allow fallback to main-thread embeddings.
693
- "allowSingleThreadFallback": false,
694
- // Abort worker embedding batches after repeated consecutive embedding failures.
695
- "failFastEmbeddingErrors": false,
696
- },
697
- // Embedding/runtime controls.
698
- "embedding": {
699
- // Embedding model identifier.
700
- "embeddingModel": "jinaai/jina-embeddings-v2-base-code",
701
- // Preload the embedding model on startup. Set to false when using child processes for memory savings.
702
- "preloadEmbeddingModel": false,
703
- // Use child process per batch for memory isolation.
704
- "embeddingProcessPerBatch": true,
705
- // Auto-enable child process when no workers + heavy model.
706
- "autoEmbeddingProcessPerBatch": false,
707
- // Override embedding batch size (null = auto).
708
- "embeddingBatchSize": null,
709
- // ONNX threads used by embedding child process.
710
- // 6 is a practical balance on 24-thread desktop CPUs (high throughput, less contention than 8+).
711
- "embeddingProcessNumThreads": 8,
712
- // Embedding-child adaptive GC RSS threshold in MB (higher = less frequent GC).
713
- "embeddingProcessGcRssThresholdMb": 2048,
714
- // Minimum interval between embedding-child GC runs.
715
- "embeddingProcessGcMinIntervalMs": 15000,
716
- // Backstop GC cadence if threshold is not crossed.
717
- "embeddingProcessGcMaxRequestsWithoutCollection": 8,
718
- },
719
- // Vector store backend controls.
720
- "vectorStore": {
721
- // Vector store format: json, binary, or sqlite.
722
- "vectorStoreFormat": "binary",
723
- // Content storage: external or inline.
724
- "vectorStoreContentMode": "external",
725
- // In-memory content cache entries (binary store).
726
- "contentCacheEntries": 256,
727
- // Vector loading mode: "disk" keeps RAM lower by streaming vectors as needed.
728
- "vectorStoreLoadMode": "disk",
729
- },
730
- // Search scoring controls.
731
- "search": {
732
- // Weight for semantic similarity scoring.
733
- "semanticWeight": 0.7,
734
- // Score boost for exact text matches.
735
- "exactMatchBoost": 1.5,
736
- },
737
- // Memory cleanup and memory-footprint controls.
738
- "memoryCleanup": {
739
- // Enable explicit GC (requires --expose-gc).
740
- "enableExplicitGc": true,
741
- // Drop in-memory vectors after indexing completes.
742
- "clearCacheAfterIndex": true,
743
- // Unload embedding model after indexing.
744
- "unloadModelAfterIndex": true,
745
- // Shutdown persistent query embedding child pool after indexing.
746
- "shutdownQueryEmbeddingPoolAfterIndex": true,
747
- // Unload embedding model after searches.
748
- "unloadModelAfterSearch": true,
749
- // Idle timeout before query embedding child process exits (ms).
750
- "embeddingPoolIdleTimeoutMs": 2000,
751
- // RSS threshold for optional incremental GC.
752
- "incrementalGcThresholdMb": 512,
753
- // Optional: print detailed phase memory traces for incremental indexing/update paths.
754
- "incrementalMemoryProfile": false,
755
- // Optional: recycle server process when RSS stays too high after incremental cleanup.
756
- // Safe default is disabled.
757
- "recycleServerOnHighRssAfterIncremental": false,
758
- // RSS threshold (MB) for incremental recycle trigger.
759
- "recycleServerOnHighRssThresholdMb": 4096,
760
- // Minimum interval between recycle attempts (ms).
761
- "recycleServerOnHighRssCooldownMs": 300000,
762
- // Delay before recycle to let logs/responses flush (ms).
763
- "recycleServerOnHighRssDelayMs": 2000,
764
- },
765
- // Call graph proximity boosting controls.
766
- "callGraph": {
767
- "callGraphEnabled": true,
768
- "callGraphBoost": 0.15,
769
- "callGraphMaxHops": 1,
770
- },
771
- // ANN index controls.
772
- "ann": {
773
- // Enable ANN index for large codebases.
774
- "annEnabled": true,
775
- // Minimum chunks required to build ANN.
776
- "annMinChunks": 5000,
777
- // Minimum ANN candidates to retrieve.
778
- "annMinCandidates": 50,
779
- // Maximum ANN candidates to retrieve.
780
- "annMaxCandidates": 200,
781
- // Scale ANN candidates by this multiplier.
782
- "annCandidateMultiplier": 20,
783
- // HNSW efConstruction value.
784
- "annEfConstruction": 200,
785
- // HNSW efSearch value.
786
- "annEfSearch": 64,
787
- // HNSW M parameter (graph degree).
788
- "annM": 16,
789
- // Persist ANN index to disk.
790
- "annIndexCache": true,
791
- // ANN distance metric.
792
- "annMetric": "cosine",
793
- },
794
- }
626
+ "**/vendor/**",
627
+ "**/.smart-coding-cache/**",
628
+ ],
629
+ // Indexing controls.
630
+ "indexing": {
631
+ // Enable project-type detection + smart ignore patterns.
632
+ "smartIndexing": true,
633
+ // Lines per chunk.
634
+ "chunkSize": 16,
635
+ // Overlapping lines between chunks.
636
+ "chunkOverlap": 4,
637
+ // Files per indexing batch.
638
+ "batchSize": 50,
639
+ // Skip files larger than this many bytes.
640
+ "maxFileSize": 1048576,
641
+ // Maximum number of search results.
642
+ "maxResults": 5,
643
+ // Enable file watcher for incremental indexing.
644
+ "watchFiles": true,
645
+ },
646
+ // Logging and diagnostics.
647
+ "logging": {
648
+ // Enable verbose logging.
649
+ "verbose": true,
650
+ },
651
+ // Cache engine and serialization controls.
652
+ "cache": {
653
+ // Persist embeddings between sessions.
654
+ "enableCache": true,
655
+ // Assume vectors are finite (skip validation).
656
+ "cacheVectorAssumeFinite": true,
657
+ // Decimal precision for cached vectors (null = default).
658
+ "cacheVectorFloatDigits": null,
659
+ // Write stream highWaterMark for cache files.
660
+ "cacheWriteHighWaterMark": 262144,
661
+ // Flush threshold (chars) for JSON writer.
662
+ "cacheVectorFlushChars": 262144,
663
+ // Validate vectors contain only finite numbers.
664
+ "cacheVectorCheckFinite": true,
665
+ // Avoid mutating vectors during serialization.
666
+ "cacheVectorNoMutation": false,
667
+ // Join threshold for JSON array chunks.
668
+ "cacheVectorJoinThreshold": 8192,
669
+ // Chunk size for JSON join optimization.
670
+ "cacheVectorJoinChunkSize": 2048,
671
+ // Wait time for active readers before saving cache (ms).
672
+ "saveReaderWaitTimeoutMs": 5000,
673
+ },
674
+ // Stale cache cleanup policy.
675
+ "cacheCleanup": {
676
+ // Remove stale caches automatically.
677
+ "autoCleanup": true,
678
+ },
679
+ // Worker-thread controls.
680
+ "worker": {
681
+ // Number of embedding workers (0 disables).
682
+ // Windows + heavy Jina models are more stable with child-process embedding than worker pools.
683
+ "workerThreads": 0,
684
+ // Worker batch timeout in milliseconds.
685
+ "workerBatchTimeoutMs": 120000,
686
+ // Failures before worker circuit opens.
687
+ "workerFailureThreshold": 1,
688
+ // Cooldown before re-enabling workers (ms).
689
+ "workerFailureCooldownMs": 600000,
690
+ // Max chunks per worker batch.
691
+ "workerMaxChunksPerBatch": 20,
692
+ // Allow fallback to main-thread embeddings.
693
+ "allowSingleThreadFallback": false,
694
+ // Abort worker embedding batches after repeated consecutive embedding failures.
695
+ "failFastEmbeddingErrors": false,
696
+ },
697
+ // Embedding/runtime controls.
698
+ "embedding": {
699
+ // Embedding model identifier.
700
+ "embeddingModel": "jinaai/jina-embeddings-v2-base-code",
701
+ // Preload the embedding model on startup. Set to false when using child processes for memory savings.
702
+ "preloadEmbeddingModel": false,
703
+ // Use child process per batch for memory isolation.
704
+ "embeddingProcessPerBatch": true,
705
+ // Auto-enable child process when no workers + heavy model.
706
+ "autoEmbeddingProcessPerBatch": false,
707
+ // Override embedding batch size (null = auto).
708
+ "embeddingBatchSize": null,
709
+ // ONNX threads used by embedding child process.
710
+ // 6 is a practical balance on 24-thread desktop CPUs (high throughput, less contention than 8+).
711
+ "embeddingProcessNumThreads": 8,
712
+ // Embedding-child adaptive GC RSS threshold in MB (higher = less frequent GC).
713
+ "embeddingProcessGcRssThresholdMb": 2048,
714
+ // Minimum interval between embedding-child GC runs.
715
+ "embeddingProcessGcMinIntervalMs": 15000,
716
+ // Backstop GC cadence if threshold is not crossed.
717
+ "embeddingProcessGcMaxRequestsWithoutCollection": 8,
718
+ },
719
+ // Vector store backend controls.
720
+ "vectorStore": {
721
+ // Vector store format: json, binary, or sqlite.
722
+ "vectorStoreFormat": "binary",
723
+ // Content storage: external or inline.
724
+ "vectorStoreContentMode": "external",
725
+ // In-memory content cache entries (binary store).
726
+ "contentCacheEntries": 256,
727
+ // Vector loading mode: "disk" keeps RAM lower by streaming vectors as needed.
728
+ "vectorStoreLoadMode": "disk",
729
+ },
730
+ // Search scoring controls.
731
+ "search": {
732
+ // Weight for semantic similarity scoring.
733
+ "semanticWeight": 0.7,
734
+ // Score boost for exact text matches.
735
+ "exactMatchBoost": 1.5,
736
+ },
737
+ // Memory cleanup and memory-footprint controls.
738
+ "memoryCleanup": {
739
+ // Enable explicit GC (requires --expose-gc).
740
+ "enableExplicitGc": true,
741
+ // Drop in-memory vectors after indexing completes.
742
+ "clearCacheAfterIndex": true,
743
+ // Unload embedding model after indexing.
744
+ "unloadModelAfterIndex": true,
745
+ // Shutdown persistent query embedding child pool after indexing.
746
+ "shutdownQueryEmbeddingPoolAfterIndex": true,
747
+ // Unload embedding model after searches.
748
+ "unloadModelAfterSearch": true,
749
+ // Idle timeout before query embedding child process exits (ms).
750
+ "embeddingPoolIdleTimeoutMs": 2000,
751
+ // RSS threshold for optional incremental GC.
752
+ "incrementalGcThresholdMb": 512,
753
+ // Optional: print detailed phase memory traces for incremental indexing/update paths.
754
+ "incrementalMemoryProfile": false,
755
+ // Optional: recycle server process when RSS stays too high after incremental cleanup.
756
+ // Safe default is disabled.
757
+ "recycleServerOnHighRssAfterIncremental": false,
758
+ // RSS threshold (MB) for incremental recycle trigger.
759
+ "recycleServerOnHighRssThresholdMb": 4096,
760
+ // Minimum interval between recycle attempts (ms).
761
+ "recycleServerOnHighRssCooldownMs": 300000,
762
+ // Delay before recycle to let logs/responses flush (ms).
763
+ "recycleServerOnHighRssDelayMs": 2000,
764
+ },
765
+ // Call graph proximity boosting controls.
766
+ "callGraph": {
767
+ "callGraphEnabled": true,
768
+ "callGraphBoost": 0.15,
769
+ "callGraphMaxHops": 1,
770
+ },
771
+ // ANN index controls.
772
+ "ann": {
773
+ // Enable ANN index for large codebases.
774
+ "annEnabled": true,
775
+ // Minimum chunks required to build ANN.
776
+ "annMinChunks": 5000,
777
+ // Minimum ANN candidates to retrieve.
778
+ "annMinCandidates": 50,
779
+ // Maximum ANN candidates to retrieve.
780
+ "annMaxCandidates": 200,
781
+ // Scale ANN candidates by this multiplier.
782
+ "annCandidateMultiplier": 20,
783
+ // HNSW efConstruction value.
784
+ "annEfConstruction": 200,
785
+ // HNSW efSearch value.
786
+ "annEfSearch": 64,
787
+ // HNSW M parameter (graph degree).
788
+ "annM": 16,
789
+ // Persist ANN index to disk.
790
+ "annIndexCache": true,
791
+ // ANN distance metric.
792
+ "annMetric": "cosine",
793
+ },
794
+ }