@softerist/heuristic-mcp 3.0.15 → 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 +104 -104
  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 +96 -96
  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 +517 -517
  20. package/lib/constants.js +39 -39
  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 -754
  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 -28
  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
@@ -76,20 +76,20 @@ heuristic-mcp --version
76
76
  ### Start/Stop
77
77
 
78
78
  ```bash
79
- heuristic-mcp --start
80
- heuristic-mcp --start antigravity
81
- heuristic-mcp --start codex
82
- heuristic-mcp --start cursor
83
- heuristic-mcp --start vscode
84
- heuristic-mcp --start windsurf
85
- heuristic-mcp --start warp
86
- heuristic-mcp --start "Claude Desktop"
87
- heuristic-mcp --stop
88
- ```
89
-
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.
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`.
79
+ heuristic-mcp --start
80
+ heuristic-mcp --start antigravity
81
+ heuristic-mcp --start codex
82
+ heuristic-mcp --start cursor
83
+ heuristic-mcp --start vscode
84
+ heuristic-mcp --start windsurf
85
+ heuristic-mcp --start warp
86
+ heuristic-mcp --start "Claude Desktop"
87
+ heuristic-mcp --stop
88
+ ```
89
+
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.
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
93
 
94
94
  ### Clear Cache
95
95
 
@@ -103,50 +103,50 @@ Clears the cache for the current working directory (or `--workspace` if provided
103
103
 
104
104
  ## Configuration (`config.jsonc`)
105
105
 
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.
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.
150
150
 
151
151
  ### Embedding Model & Dimension Options
152
152
 
@@ -156,14 +156,14 @@ Preferred style is namespaced keys (shown above). Legacy top-level keys are stil
156
156
 
157
157
  For faster search with smaller embeddings, switch to an MRL-compatible model:
158
158
 
159
- ```json
160
- {
161
- "embedding": {
162
- "embeddingModel": "nomic-ai/nomic-embed-text-v1.5",
163
- "embeddingDimension": 128
164
- }
165
- }
166
- ```
159
+ ```json
160
+ {
161
+ "embedding": {
162
+ "embeddingModel": "nomic-ai/nomic-embed-text-v1.5",
163
+ "embeddingDimension": 128
164
+ }
165
+ }
166
+ ```
167
167
 
168
168
  **MRL-compatible models:**
169
169
  - `nomic-ai/nomic-embed-text-v1.5` — recommended for 128d/256d
@@ -178,9 +178,9 @@ Cache location:
178
178
 
179
179
  ### Environment Variables
180
180
 
181
- Selected overrides (prefix `SMART_CODING_`):
182
-
183
- 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`.
184
184
 
185
185
  - `SMART_CODING_VERBOSE=true|false` — enable detailed logging.
186
186
  - `SMART_CODING_WORKER_THREADS=auto|N` — worker thread count.
@@ -206,37 +206,37 @@ Environment overrides target runtime keys and are synced back into namespaces by
206
206
 
207
207
  See `lib/config.js` for the full list.
208
208
 
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.
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.
221
221
 
222
222
  ### SQLite Vector Store
223
223
 
224
- 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:
225
225
 
226
226
  - ACID transactions for reliable writes
227
227
  - Simpler concurrent access
228
228
  - Standard database format for inspection
229
229
 
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).
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).
240
240
 
241
241
  **Tradeoffs vs Binary:**
242
242
  - Slightly higher read overhead (SQL queries vs direct memory access)
@@ -259,7 +259,7 @@ SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js
259
259
  SMART_CODING_VECTOR_STORE_FORMAT=binary SMART_CODING_VECTOR_STORE_LOAD_MODE=disk node tools/scripts/benchmark-search.js --runs 10
260
260
  ```
261
261
 
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`.
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`.
263
263
 
264
264
  ---
265
265
 
@@ -297,14 +297,14 @@ Fetch the latest version of a package from its official registry.
297
297
  - **Homebrew**: `brew:node`
298
298
  - **Conda**: `conda:numpy`
299
299
 
300
- ### `f_set_workspace`
301
- Change the workspace directory at runtime. Updates search directory, cache location, and optionally triggers reindex.
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
-
305
- **Parameters:**
306
- - `workspacePath` (required): Absolute path to the new workspace
307
- - `reindex` (optional, default: `true`): Whether to trigger a full reindex
300
+ ### `f_set_workspace`
301
+ Change the workspace directory at runtime. Updates search directory, cache location, and optionally triggers reindex.
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
+
305
+ **Parameters:**
306
+ - `workspacePath` (required): Absolute path to the new workspace
307
+ - `reindex` (optional, default: `true`): Whether to trigger a full reindex
308
308
 
309
309
  ---
310
310
 
@@ -324,8 +324,8 @@ Native ONNX backend unavailable: The operating system cannot run %1.
324
324
  ...onnxruntime_binding.node. Falling back to WASM.
325
325
  ```
326
326
 
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:
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:
329
329
 
330
330
  - Ensure you are running **64-bit Node.js** (`node -p "process.arch"` should be `x64`).
331
331
  - Install **Microsoft Visual C++ 2015–2022 Redistributable (x64)**.
@@ -365,7 +365,7 @@ node tools/scripts/cache-stats.js --workspace <path>
365
365
 
366
366
  **Stop doesn't stick**
367
367
 
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.
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.
369
369
 
370
370
  ---
371
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
+ }