@softerist/heuristic-mcp 3.0.1 → 3.0.2

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/CONTRIBUTING.md CHANGED
@@ -1,227 +0,0 @@
1
- # Contributing to Heuristic MCP
2
-
3
- Thank you for your interest in contributing. This document provides guidelines for contributing to the project.
4
-
5
- ## Getting Started
6
-
7
- ### Prerequisites
8
-
9
- - Node.js 18 or higher
10
- - npm or yarn
11
- - Git
12
-
13
- ### Setup Development Environment
14
-
15
- ```bash
16
- # Fork and clone the repository
17
- git clone https://github.com/softerist/heuristic-mcp.git
18
- cd heuristic-mcp
19
-
20
- # Install dependencies
21
- npm install
22
-
23
- # Run in development mode
24
- npm run dev
25
- ```
26
-
27
- ## Project Structure
28
-
29
- See `ARCHITECTURE.md` for detailed information about the modular architecture.
30
-
31
- Key directories:
32
-
33
- - `lib/` - Core libraries and utilities
34
- - `features/` - Pluggable feature modules
35
- - `scripts/` - Utility scripts
36
- - `tools/` - Developer-only helpers
37
-
38
- ## Development Guidelines
39
-
40
- ### Code Style
41
-
42
- - Use ES6+ JavaScript features
43
- - Follow existing code patterns
44
- - Use meaningful variable and function names
45
- - Add comments for complex logic
46
- - Avoid emojis in code comments and logs unless they are part of user-facing CLI output
47
-
48
- ### File Organization
49
-
50
- ```javascript
51
- // Standard file structure for features:
52
-
53
- // 1. Imports
54
- import { dependency } from 'package';
55
-
56
- // 2. Class definition
57
- export class FeatureName {
58
- constructor(embedder, cache, config) {
59
- // ...
60
- }
61
-
62
- async method() {
63
- // ...
64
- }
65
- }
66
-
67
- // 3. MCP tool definition
68
- export function getToolDefinition(config) {
69
- return {
70
- /* ... */
71
- };
72
- }
73
-
74
- // 4. Tool handler
75
- export async function handleToolCall(request, instance) {
76
- // ...
77
- }
78
- ```
79
-
80
- ### Error Handling
81
-
82
- ```javascript
83
- // Always handle errors gracefully
84
- try {
85
- // operation
86
- } catch (error) {
87
- console.error('[Module] Error description:', error.message);
88
- // Continue execution or return default value
89
- }
90
- ```
91
-
92
- ### Logging
93
-
94
- - Use `console.info()` for normal server lifecycle output (redirected to logs in MCP mode)
95
- - Use `console.warn()` for non-fatal issues and `console.error()` for errors
96
- - CLI utilities and install scripts may use `console.info()` for user-friendly output
97
-
98
- ## Adding New Features
99
-
100
- ### Step-by-Step Guide
101
-
102
- 1. **Create Feature File**
103
-
104
- Create `features/your-feature.js`:
105
-
106
- ```javascript
107
- export class YourFeature {
108
- constructor(embedder, cache, config) {
109
- this.embedder = embedder;
110
- this.cache = cache;
111
- this.config = config;
112
- }
113
-
114
- async execute(params) {
115
- // Implementation
116
- return { result: 'data' };
117
- }
118
- }
119
-
120
- export function getToolDefinition(config) {
121
- return {
122
- name: 'your_tool',
123
- description: 'Clear description of what the tool does',
124
- inputSchema: {
125
- type: 'object',
126
- properties: {
127
- param: {
128
- type: 'string',
129
- description: 'Parameter description',
130
- },
131
- },
132
- required: ['param'],
133
- },
134
- };
135
- }
136
-
137
- export async function handleToolCall(request, instance) {
138
- const params = request.params.arguments;
139
- const result = await instance.execute(params);
140
-
141
- return {
142
- content: [
143
- {
144
- type: 'text',
145
- text: JSON.stringify(result, null, 2),
146
- },
147
- ],
148
- };
149
- }
150
- ```
151
-
152
- 2. **Register Feature**
153
-
154
- Update `index.js`:
155
-
156
- ```javascript
157
- import * as YourFeature from './features/your-feature.js';
158
-
159
- // In initialize():
160
- const yourFeature = new YourFeature.YourFeature(embedder, cache, config);
161
-
162
- // Add to features array:
163
- features.push({
164
- module: YourFeature,
165
- instance: yourFeature,
166
- handler: YourFeature.handleToolCall,
167
- });
168
- ```
169
-
170
- 3. **Test Your Feature**
171
-
172
- - Test with a sample codebase
173
- - Verify MCP tool contract
174
- - Check error handling and output format
175
-
176
- 4. **Document Your Feature**
177
-
178
- - Add to README.md features section
179
- - Update ARCHITECTURE.md if needed
180
-
181
- ## Testing
182
-
183
- ```bash
184
- npm test
185
- ```
186
-
187
- By default, tests use a mock embedder to avoid network/model downloads. To run the real model tests:
188
-
189
- ```bash
190
- USE_REAL_EMBEDDER=true npm test
191
- ```
192
-
193
- ## Pull Request Process
194
-
195
- 1. **Fork the repository**
196
-
197
- 2. **Create a feature branch**
198
-
199
- ```bash
200
- git checkout -b feature/your-feature-name
201
- ```
202
-
203
- 3. **Make your changes**
204
-
205
- - Follow code style guidelines
206
- - Add appropriate comments
207
- - Test thoroughly
208
-
209
- 4. **Commit your changes**
210
-
211
- ```bash
212
- git add .
213
- git commit -m "Add feature: description"
214
- ```
215
-
216
- Follow commit message conventions:
217
-
218
- - `Add feature: description` - New features
219
- - `Fix: description` - Bug fixes
220
- - `Update: description` - Updates to existing code
221
- - `Docs: description` - Documentation changes
222
-
223
- 5. **Push to your fork**
224
-
225
- ```bash
226
- git push origin feature/your-feature-name
227
- ```
package/README.md CHANGED
@@ -111,6 +111,8 @@ Example `config.jsonc`:
111
111
  "smartIndexing": true,
112
112
  "embeddingModel": "jinaai/jina-embeddings-v2-base-code",
113
113
  "workerThreads": 0,
114
+ "embeddingBatchSize": null,
115
+ "embeddingProcessNumThreads": 8,
114
116
  "enableExplicitGc": false,
115
117
  "recencyBoost": 0.1,
116
118
  "recencyDecayDays": 30,
@@ -136,10 +138,12 @@ Cache location:
136
138
  Selected overrides (prefix `SMART_CODING_`):
137
139
 
138
140
  - `SMART_CODING_VERBOSE=true|false` — enable detailed logging.
139
- - `SMART_CODING_WORKER_THREADS=auto|0|N` — worker thread count (`0` disables workers).
141
+ - `SMART_CODING_WORKER_THREADS=auto|N` — worker thread count.
140
142
  - `SMART_CODING_BATCH_SIZE=100` — files per indexing batch.
141
143
  - `SMART_CODING_CHUNK_SIZE=25` — lines per chunk.
142
144
  - `SMART_CODING_MAX_RESULTS=5` — max search results.
145
+ - `SMART_CODING_EMBEDDING_BATCH_SIZE=64` — embedding batch size (1–256, overrides auto).
146
+ - `SMART_CODING_EMBEDDING_THREADS=8` — ONNX threads for the embedding child process.
143
147
  - `SMART_CODING_RECENCY_BOOST=0.1` — boost for recently edited files.
144
148
  - `SMART_CODING_RECENCY_DECAY_DAYS=30` — days until recency boost decays to 0.
145
149
  - `SMART_CODING_ANN_ENABLED=true|false` — enable ANN index.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softerist/heuristic-mcp",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "An enhanced MCP server providing intelligent semantic code search with find-similar-code, recency ranking, and improved chunking. Fork of smart-coding-mcp.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/GEMINI.md DELETED
@@ -1,73 +0,0 @@
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.