@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.
Files changed (109) hide show
  1. package/.agent/workflows/code-review.md +60 -0
  2. package/.prettierrc +7 -0
  3. package/ARCHITECTURE.md +105 -170
  4. package/CONTRIBUTING.md +32 -113
  5. package/GEMINI.md +73 -0
  6. package/LICENSE +21 -21
  7. package/README.md +161 -54
  8. package/config.json +876 -76
  9. package/debug-pids.js +27 -0
  10. package/eslint.config.js +36 -0
  11. package/features/ann-config.js +37 -26
  12. package/features/clear-cache.js +28 -19
  13. package/features/find-similar-code.js +142 -66
  14. package/features/hybrid-search.js +253 -93
  15. package/features/index-codebase.js +1455 -394
  16. package/features/lifecycle.js +813 -180
  17. package/features/register.js +58 -52
  18. package/index.js +450 -306
  19. package/lib/cache-ops.js +22 -0
  20. package/lib/cache-utils.js +68 -0
  21. package/lib/cache.js +1392 -587
  22. package/lib/call-graph.js +165 -50
  23. package/lib/cli.js +154 -0
  24. package/lib/config.js +462 -121
  25. package/lib/embedding-process.js +77 -0
  26. package/lib/embedding-worker.js +545 -30
  27. package/lib/ignore-patterns.js +61 -59
  28. package/lib/json-worker.js +14 -0
  29. package/lib/json-writer.js +344 -0
  30. package/lib/logging.js +88 -0
  31. package/lib/memory-logger.js +13 -0
  32. package/lib/project-detector.js +13 -17
  33. package/lib/server-lifecycle.js +38 -0
  34. package/lib/settings-editor.js +645 -0
  35. package/lib/tokenizer.js +207 -104
  36. package/lib/utils.js +273 -198
  37. package/lib/vector-store-binary.js +592 -0
  38. package/mcp_config.example.json +13 -0
  39. package/package.json +13 -2
  40. package/scripts/clear-cache.js +6 -17
  41. package/scripts/download-model.js +14 -9
  42. package/scripts/postinstall.js +5 -5
  43. package/search-configs.js +36 -0
  44. package/test/ann-config.test.js +179 -0
  45. package/test/ann-fallback.test.js +6 -6
  46. package/test/binary-store.test.js +69 -0
  47. package/test/cache-branches.test.js +120 -0
  48. package/test/cache-errors.test.js +264 -0
  49. package/test/cache-extra.test.js +300 -0
  50. package/test/cache-helpers.test.js +205 -0
  51. package/test/cache-hnsw-failure.test.js +40 -0
  52. package/test/cache-json-worker.test.js +190 -0
  53. package/test/cache-worker.test.js +102 -0
  54. package/test/cache.test.js +443 -0
  55. package/test/call-graph.test.js +103 -4
  56. package/test/clear-cache.test.js +69 -68
  57. package/test/code-review-workflow.test.js +50 -0
  58. package/test/config.test.js +418 -0
  59. package/test/coverage-gap.test.js +497 -0
  60. package/test/coverage-maximizer.test.js +236 -0
  61. package/test/debug-analysis.js +107 -0
  62. package/test/embedding-model.test.js +173 -103
  63. package/test/embedding-worker-extra.test.js +272 -0
  64. package/test/embedding-worker.test.js +158 -0
  65. package/test/features.test.js +139 -0
  66. package/test/final-boost.test.js +271 -0
  67. package/test/final-polish.test.js +183 -0
  68. package/test/final.test.js +95 -0
  69. package/test/find-similar-code.test.js +191 -0
  70. package/test/helpers.js +92 -11
  71. package/test/helpers.test.js +46 -0
  72. package/test/hybrid-search-basic.test.js +62 -0
  73. package/test/hybrid-search-branch.test.js +202 -0
  74. package/test/hybrid-search-callgraph.test.js +229 -0
  75. package/test/hybrid-search-extra.test.js +81 -0
  76. package/test/hybrid-search.test.js +484 -71
  77. package/test/index-cli.test.js +520 -0
  78. package/test/index-codebase-batch.test.js +119 -0
  79. package/test/index-codebase-branches.test.js +585 -0
  80. package/test/index-codebase-core.test.js +1032 -0
  81. package/test/index-codebase-edge-cases.test.js +254 -0
  82. package/test/index-codebase-errors.test.js +132 -0
  83. package/test/index-codebase-gap.test.js +239 -0
  84. package/test/index-codebase-lines.test.js +151 -0
  85. package/test/index-codebase-watcher.test.js +259 -0
  86. package/test/index-codebase-zone.test.js +259 -0
  87. package/test/index-codebase.test.js +371 -69
  88. package/test/index-memory.test.js +220 -0
  89. package/test/indexer-detailed.test.js +176 -0
  90. package/test/integration.test.js +148 -92
  91. package/test/json-worker.test.js +50 -0
  92. package/test/lifecycle.test.js +541 -0
  93. package/test/master.test.js +198 -0
  94. package/test/perfection.test.js +349 -0
  95. package/test/project-detector.test.js +65 -0
  96. package/test/register.test.js +262 -0
  97. package/test/tokenizer.test.js +55 -93
  98. package/test/ultra-maximizer.test.js +116 -0
  99. package/test/utils-branches.test.js +161 -0
  100. package/test/utils-extra.test.js +116 -0
  101. package/test/utils.test.js +131 -0
  102. package/test/verify_fixes.js +76 -0
  103. package/test/worker-errors.test.js +96 -0
  104. package/test/worker-init.test.js +102 -0
  105. package/test/worker_throttling.test.js +93 -0
  106. package/tools/scripts/benchmark-search.js +95 -0
  107. package/tools/scripts/cache-stats.js +71 -0
  108. package/tools/scripts/manual-search.js +34 -0
  109. package/vitest.config.js +19 -9
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: Perform a comprehensive, senior-level code review following strict quality, security, and architectural guidelines.
3
+ version: 2.1
4
+ last_updated: 2026-01-29
5
+ ---
6
+
7
+ You are a senior software engineer and code reviewer. Review the code provided according to the following strict guidelines.
8
+
9
+ ## 1. Review Scope & Context
10
+ - **For code <100 lines**: Quick review focusing on correctness and obvious bugs.
11
+ - **For code 100-500 lines**: Standard review following all sections below.
12
+ - **For code >500 lines or critical systems**: Deep review with extra emphasis on architecture, security, and edge cases.
13
+ - If reviewing multiple files, prioritize by risk (security > data handling > business logic > UI).
14
+ - **Domain-Specific Checks**: If the code domain is identifiable (e.g., web, mobile, embedded, ML, healthcare), apply relevant domain-specific standards (e.g., WCAG for web, PII handling for healthcare, real-time constraints for embedded).
15
+
16
+ ## 2. Line-by-Line Review
17
+ - Review every function and critical code path. For files >200 lines, focus on functions with issues rather than every line.
18
+ - Group line-by-line findings by severity (**Critical** first), then by file/function within each severity tier.
19
+ - For each issue, quote the relevant line(s).
20
+ - **Confidence Ratings**: For ambiguous issues where context is missing, explicitly note `[Confidence: Low/Medium/High]` and explain what additional information would clarify the finding.
21
+
22
+ ## 3. High-Level Review
23
+ - Focus on system-level patterns not visible at function scope: module organization, layer violations, missing abstraction layers, deployment concerns.
24
+ - Do not check for issues already covered in line-by-line (avoid redundancy).
25
+
26
+ ## 4. Follow-up Reviews
27
+ - For follow-up reviews, focus on: regression verification, new code introduced by fixes, and cross-cutting impact of changes.
28
+
29
+ ## 5. Stalled/Incomplete Logic
30
+ - Check for "forgotten error paths": places where exceptions/errors could occur but aren't caught, or catch blocks that are empty/only log without recovery strategy.
31
+ - Verify TODOs or placeholders.
32
+
33
+ ## 6. Consistency
34
+ - Identify the dominant pattern in the codebase and flag deviations. If no clear majority, note the inconsistency itself as an issue.
35
+ - Check naming conventions, coding style, and file structure.
36
+
37
+ ## 7. Fix Plan
38
+ Provide a prioritized checklist (most critical first):
39
+ - **Estimated effort per item** using this scale:
40
+ * **S (Small)**: <2 hours, isolated change, no breaking changes.
41
+ * **M (Medium)**: 2-8 hours, may affect multiple files, local refactoring.
42
+ * **L (Large)**: >8 hours, architectural changes, breaking changes, or requires team coordination.
43
+ - For each item, note any dependencies: "Requires #N" if another fix must be completed first.
44
+ - Group independent fixes together to enable parallel work.
45
+
46
+ ## 8. Patch
47
+ - Propose concrete code edits in **unified diff format** for **ALL critical severity issues**.
48
+ - For **high severity** issues, provide patches for the top 5 most impactful.
49
+ - For new files or large refactors (>50 lines changed), provide complete code blocks with clear before/after markers.
50
+
51
+ ## 9. Tests
52
+ - Separate **unit tests** (isolated, mocked dependencies) from **integration tests** (real dependencies). Specify which category each test belongs to.
53
+ - List the exact tests you'd add (test names + what each asserts).
54
+ - For performance issues, include benchmark or load tests with acceptable thresholds.
55
+
56
+ ## Output Format Constraints
57
+ - **Do not skip sections.** If a section has no findings, state "No issues found" and briefly explain why (e.g., "No concurrency issues: code is single-threaded").
58
+ - **Assume production context**: Treat as a professional audit. If context is unclear, state assumptions (e.g., "assuming user-facing web application with moderate traffic").
59
+ - **Be exhaustive and specific.** Do not be polite; be direct.
60
+ - **Length Control**: If findings are extensive (would exceed ~5000 words), provide an **Executive Summary** of critical issues first, then offer to continue with medium/low priority items in a follow-up response.
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "tabWidth": 2,
5
+ "trailingComma": "es5",
6
+ "printWidth": 100
7
+ }
package/ARCHITECTURE.md CHANGED
@@ -8,24 +8,48 @@ This document outlines the modular architecture of Heuristic MCP.
8
8
  heuristic-mcp/
9
9
  ├── index.js # Main entry point, MCP server setup
10
10
  ├── package.json # Package configuration
11
- ├── config.json # User configuration
11
+ ├── config.json # Sample configuration
12
12
  ├── LICENSE # MIT License
13
13
  ├── README.md # Project documentation
14
- ├── EXAMPLES.md # Usage examples
14
+ ├── ARCHITECTURE.md # Architecture notes
15
+ ├── CONTRIBUTING.md # Contribution guide
15
16
  ├── .gitignore # Git ignore rules
16
17
 
17
18
  ├── lib/ # Core libraries
18
- │ ├── config.js # Configuration loader
19
- │ ├── cache.js # Embeddings cache management
20
- └── utils.js # Shared utilities (chunking, similarity)
19
+ │ ├── cache-utils.js # Stale cache detection/cleanup
20
+ │ ├── cache.js # Embeddings cache management + ANN index
21
+ ├── call-graph.js # Symbol extraction and call graph helpers
22
+ │ ├── cli.js # CLI argument parsing helpers
23
+ │ ├── config.js # Configuration loader and env overrides
24
+ │ ├── embedding-process.js # Child-process embedder runner (isolation)
25
+ │ ├── embedding-worker.js # Worker-thread embedder runner
26
+ │ ├── ignore-patterns.js # Smart ignore patterns by project type
27
+ │ ├── json-worker.js # Off-thread JSON parsing
28
+ │ ├── json-writer.js # Streaming JSON writer
29
+ │ ├── logging.js # Log file + stderr redirection helpers
30
+ │ ├── project-detector.js # Language/project detection
31
+ │ ├── tokenizer.js # Token estimation and limits
32
+ │ ├── utils.js # Shared utilities (chunking, similarity)
33
+ │ └── vector-store-binary.js # Binary on-disk vector store (mmap-friendly)
21
34
 
22
35
  ├── features/ # Pluggable features
23
- │ ├── hybrid-search.js # Semantic search feature
36
+ │ ├── hybrid-search.js # Semantic + exact match search
24
37
  │ ├── index-codebase.js # Code indexing feature
25
- └── clear-cache.js # Cache management feature
38
+ ├── clear-cache.js # Cache management feature
39
+ │ ├── find-similar-code.js # Similarity search by code snippet
40
+ │ ├── ann-config.js # ANN configuration tool
41
+ │ ├── lifecycle.js # CLI lifecycle helpers
42
+ │ └── register.js # IDE registration logic
26
43
 
27
- └── scripts/ # Utility scripts
28
- └── clear-cache.js # Cache management utility
44
+ ├── scripts/ # Utility scripts
45
+ │ ├── clear-cache.js # Cache management utility
46
+ │ ├── download-model.js # Optional model pre-download
47
+ │ └── postinstall.js # Auto-register on install
48
+
49
+ └── tools/ # Developer-only helpers
50
+ └── scripts/
51
+ ├── cache-stats.js # Cache inspection utility
52
+ └── manual-search.js # Manual semantic search helper
29
53
  ```
30
54
 
31
55
  ## Module Responsibilities
@@ -39,9 +63,10 @@ heuristic-mcp/
39
63
 
40
64
  ### lib/config.js
41
65
 
42
- - Loads and validates configuration from config.json
66
+ - Loads and validates configuration from `config.json`
43
67
  - Provides default configuration values
44
- - Resolves file paths
68
+ - Resolves file paths and cache location
69
+ - Applies `SMART_CODING_*` environment variable overrides
45
70
 
46
71
  ### lib/cache.js
47
72
 
@@ -50,114 +75,95 @@ heuristic-mcp/
50
75
  - File hash tracking for change detection
51
76
  - Load/save operations for disk cache
52
77
  - Optional ANN (HNSW) index build/load/save for fast search
78
+ - Supports JSON or binary vector store formats
79
+
80
+ ### lib/cache-utils.js
81
+
82
+ - Stale cache detection/cleanup for caches without metadata
83
+ - Uses `progress.json` recency to avoid deleting active indexes
84
+
85
+ ### lib/embedding-process.js
86
+
87
+ - Child-process embedding path for isolation
88
+ - Used to recover from hung or crashing workers
89
+
90
+ ### lib/embedding-worker.js
91
+
92
+ - Worker-thread embedding path for concurrency
93
+ - Cooperates with worker circuit breaker logic in indexing
94
+
95
+ ### lib/ignore-patterns.js
96
+
97
+ - Smart ignore patterns derived from detected project type
98
+
99
+ ### lib/json-worker.js / lib/json-writer.js
100
+
101
+ - Streaming JSON writer and off-thread parsing helpers
102
+
103
+ ### lib/logging.js
104
+
105
+ - Log file path and directory helpers
106
+ - Console redirection for MCP stdout safety
107
+
108
+ ### lib/cli.js
109
+
110
+ - Parses CLI flags for server and lifecycle commands
111
+
112
+ ### lib/vector-store-binary.js
113
+
114
+ - Binary vector store with header + record table + content blocks
115
+ - Mmap-friendly layout, content loaded on demand
53
116
 
54
117
  ### lib/utils.js
55
118
 
56
- - **cosineSimilarity()** - Vector similarity calculation
119
+ - **dotSimilarity()** - Vector similarity calculation
57
120
  - **hashContent()** - MD5 hashing for change detection
58
121
  - **smartChunk()** - Language-aware code chunking
59
122
 
123
+ ### lib/call-graph.js
124
+
125
+ - Extracts definitions and calls
126
+ - Builds a lightweight call graph for proximity boosting
127
+
60
128
  ### features/hybrid-search.js
61
129
 
62
130
  - **HybridSearch** class
63
131
  - Combines semantic and exact matching
64
- - Weighted scoring algorithm
65
- - Result formatting with relevance scores
66
- - MCP tool: `semantic_search`
132
+ - Recency and call-graph proximity boosting
133
+ - MCP tool: `a_semantic_search`
67
134
 
68
135
  ### features/index-codebase.js
69
136
 
70
137
  - **CodebaseIndexer** class
71
138
  - File discovery via glob patterns
72
139
  - Incremental indexing
73
- - File watcher for real-time updates
74
- - MCP tool: `index_codebase`
75
-
76
- ## Adding New Features
77
-
78
- To extend with a new feature:
79
-
80
- ### 1. Create Feature Module
81
-
82
- Create `features/my-feature.js`:
83
-
84
- ```javascript
85
- export class MyFeature {
86
- constructor(embedder, cache, config) {
87
- this.embedder = embedder;
88
- this.cache = cache;
89
- this.config = config;
90
- }
91
-
92
- async execute(params) {
93
- // Implementation
94
- return {
95
- /* results */
96
- };
97
- }
98
- }
99
-
100
- export function getToolDefinition(config) {
101
- return {
102
- name: "my_tool",
103
- description: "What this tool does",
104
- inputSchema: {
105
- type: "object",
106
- properties: {
107
- param1: { type: "string", description: "..." },
108
- },
109
- required: ["param1"],
110
- },
111
- };
112
- }
113
-
114
- export async function handleToolCall(request, instance) {
115
- const params = request.params.arguments;
116
- const result = await instance.execute(params);
117
-
118
- return {
119
- content: [
120
- {
121
- type: "text",
122
- text: JSON.stringify(result, null, 2),
123
- },
124
- ],
125
- };
126
- }
127
- ```
128
-
129
- ### 2. Register in index.js
140
+ - Optional file watcher for real-time updates
141
+ - Progress tracking via `progress.json`
142
+ - MCP tool: `b_index_codebase`
130
143
 
131
- ```javascript
132
- import * as MyFeature from "./features/my-feature.js";
144
+ ### features/clear-cache.js
133
145
 
134
- // In initialize():
135
- const myFeature = new MyFeature.MyFeature(embedder, cache, config);
146
+ - **CacheClearer** class
147
+ - Clears vector store and cache directory
148
+ - MCP tool: `c_clear_cache`
136
149
 
137
- // Add to features array:
138
- const features = [
139
- // ... existing features
140
- {
141
- module: MyFeature,
142
- instance: myFeature,
143
- handler: MyFeature.handleToolCall,
144
- },
145
- ];
146
- ```
150
+ ### features/find-similar-code.js
147
151
 
148
- ### 3. Done!
152
+ - **FindSimilarCode** class
153
+ - Finds semantically similar code snippets
154
+ - MCP tool: `d_find_similar_code`
149
155
 
150
- The feature will automatically:
156
+ ### features/ann-config.js
151
157
 
152
- - Be listed in MCP tool discovery
153
- - Handle incoming tool requests
154
- - Have access to embeddings and cache
158
+ - **AnnConfigTool** class
159
+ - Runtime ANN tuning and stats
160
+ - MCP tool: `d_ann_config`
155
161
 
156
162
  ## Configuration Flow
157
163
 
158
164
  1. User creates/edits `config.json`
159
165
  2. `lib/config.js` loads configuration on startup
160
- 3. Configuration merged with defaults
166
+ 3. Configuration merged with defaults and env overrides
161
167
  4. Passed to all features via constructor
162
168
 
163
169
  ## Data Flow
@@ -167,7 +173,7 @@ The feature will automatically:
167
173
  ```
168
174
  User code files
169
175
 
170
- glob pattern matching
176
+ exclude patterns and smart indexing
171
177
 
172
178
  smartChunk() - split into chunks
173
179
 
@@ -187,22 +193,23 @@ embedder - query to vector
187
193
 
188
194
  ANN candidate search (optional)
189
195
 
190
- cosineSimilarity() - score candidates
196
+ dotSimilarity() - score candidates
191
197
 
192
- exact match boost - adjust scores
198
+ exact match + recency + call-graph boosts
193
199
 
194
200
  sort and filter - top N results
195
201
 
196
- format output - markdown with syntax highlighting
202
+ format output - markdown with code blocks
197
203
  ```
198
204
 
199
205
  ## Performance Considerations
200
206
 
201
207
  ### Caching Strategy
202
208
 
203
- - **First Run**: Download model (~90MB), index all files, save cache
209
+ - **First Run**: Download model (if not cached), index all files, save cache
204
210
  - **Subsequent Runs**: Load cache from disk, only index changed files
205
- - **File Changes**: Incremental updates via file watcher
211
+ - **File Changes**: Incremental updates via file watcher (if enabled)
212
+ - **Binary Store**: Optional on-disk vector/content storage to reduce JS heap usage
206
213
 
207
214
  ### Memory Usage
208
215
 
@@ -218,75 +225,3 @@ Approximate memory usage:
218
225
  - Reduce `chunkSize` for large codebases
219
226
  - Disable `watchFiles` if not needed
220
227
  - Use `excludePatterns` aggressively
221
- - Limit `fileExtensions` to relevant types
222
-
223
- ## Future Feature Ideas
224
-
225
- Potential features to add following this architecture:
226
-
227
- 1. **Code Complexity Analysis**
228
-
229
- - Cyclomatic complexity scoring
230
- - Technical debt detection
231
-
232
- 2. **Pattern Detection**
233
-
234
- - Anti-pattern identification
235
- - Best practice recommendations
236
-
237
- 3. **Documentation Generation**
238
-
239
- - Auto-generate function docs
240
- - README generation from code
241
-
242
- 4. **Refactoring Suggestions**
243
-
244
- - Code smell detection
245
- - Automated fix suggestions
246
-
247
- 5. **Test Coverage Analysis**
248
-
249
- - Identify untested code paths
250
- - Generate test templates
251
-
252
- 6. **Dependency Analysis**
253
- - Import/export graph
254
- - Dead code detection
255
-
256
- Each feature would follow the same pattern:
257
-
258
- - Class in `features/` directory
259
- - Access to embedder, cache, config
260
- - MCP tool definition and handler
261
- - Registration in feature array
262
-
263
- ## Testing Strategy
264
-
265
- Recommended testing approach:
266
-
267
- 1. **Unit Tests**: lib/ modules
268
-
269
- - Test utilities in isolation
270
- - Mock dependencies
271
-
272
- 2. **Integration Tests**: features/
273
-
274
- - Test with sample codebases
275
- - Verify MCP tool contracts
276
-
277
- 3. **E2E Tests**: Full workflow
278
- - Index → Search → Results
279
- - File watching behavior
280
- - Cache persistence
281
-
282
- ## Error Handling
283
-
284
- Each module follows defensive error handling:
285
-
286
- - Config errors → use defaults
287
- - File read errors → log and skip
288
- - Embedding errors → retry or skip chunk
289
- - Cache errors → log but continue
290
- - Unknown tools → return helpful error message
291
-
292
- All errors logged to stderr for MCP protocol compatibility.
package/CONTRIBUTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Contributing to Heuristic MCP
2
2
 
3
- Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
3
+ Thank you for your interest in contributing. This document provides guidelines for contributing to the project.
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -26,13 +26,14 @@ npm run dev
26
26
 
27
27
  ## Project Structure
28
28
 
29
- See [ARCHITECTURE.md](./ARCHITECTURE.md) for detailed information about the modular architecture.
29
+ See `ARCHITECTURE.md` for detailed information about the modular architecture.
30
30
 
31
31
  Key directories:
32
32
 
33
33
  - `lib/` - Core libraries and utilities
34
34
  - `features/` - Pluggable feature modules
35
35
  - `scripts/` - Utility scripts
36
+ - `tools/` - Developer-only helpers
36
37
 
37
38
  ## Development Guidelines
38
39
 
@@ -42,7 +43,7 @@ Key directories:
42
43
  - Follow existing code patterns
43
44
  - Use meaningful variable and function names
44
45
  - Add comments for complex logic
45
- - No emojis in code or documentation
46
+ - Avoid emojis in code comments and logs unless they are part of user-facing CLI output
46
47
 
47
48
  ### File Organization
48
49
 
@@ -50,7 +51,7 @@ Key directories:
50
51
  // Standard file structure for features:
51
52
 
52
53
  // 1. Imports
53
- import { dependency } from "package";
54
+ import { dependency } from 'package';
54
55
 
55
56
  // 2. Class definition
56
57
  export class FeatureName {
@@ -83,20 +84,16 @@ export async function handleToolCall(request, instance) {
83
84
  try {
84
85
  // operation
85
86
  } catch (error) {
86
- console.error("[Module] Error description:", error.message);
87
+ console.error('[Module] Error description:', error.message);
87
88
  // Continue execution or return default value
88
89
  }
89
90
  ```
90
91
 
91
92
  ### Logging
92
93
 
93
- Use `console.error()` for all logs (MCP protocol requirement):
94
-
95
- ```javascript
96
- console.error("[FeatureName] Informational message");
97
- console.error("[FeatureName] Warning:", details);
98
- console.error("[FeatureName] Error:", error.message);
99
- ```
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
100
97
 
101
98
  ## Adding New Features
102
99
 
@@ -116,23 +113,23 @@ export class YourFeature {
116
113
 
117
114
  async execute(params) {
118
115
  // Implementation
119
- return { result: "data" };
116
+ return { result: 'data' };
120
117
  }
121
118
  }
122
119
 
123
120
  export function getToolDefinition(config) {
124
121
  return {
125
- name: "your_tool",
126
- description: "Clear description of what the tool does",
122
+ name: 'your_tool',
123
+ description: 'Clear description of what the tool does',
127
124
  inputSchema: {
128
- type: "object",
125
+ type: 'object',
129
126
  properties: {
130
127
  param: {
131
- type: "string",
132
- description: "Parameter description",
128
+ type: 'string',
129
+ description: 'Parameter description',
133
130
  },
134
131
  },
135
- required: ["param"],
132
+ required: ['param'],
136
133
  },
137
134
  };
138
135
  }
@@ -144,7 +141,7 @@ export async function handleToolCall(request, instance) {
144
141
  return {
145
142
  content: [
146
143
  {
147
- type: "text",
144
+ type: 'text',
148
145
  text: JSON.stringify(result, null, 2),
149
146
  },
150
147
  ],
@@ -157,7 +154,7 @@ export async function handleToolCall(request, instance) {
157
154
  Update `index.js`:
158
155
 
159
156
  ```javascript
160
- import * as YourFeature from "./features/your-feature.js";
157
+ import * as YourFeature from './features/your-feature.js';
161
158
 
162
159
  // In initialize():
163
160
  const yourFeature = new YourFeature.YourFeature(embedder, cache, config);
@@ -172,17 +169,27 @@ features.push({
172
169
 
173
170
  3. **Test Your Feature**
174
171
 
175
- - Test with sample codebase
172
+ - Test with a sample codebase
176
173
  - Verify MCP tool contract
177
- - Check error handling
178
- - Validate output format
174
+ - Check error handling and output format
179
175
 
180
176
  4. **Document Your Feature**
181
177
 
182
178
  - Add to README.md features section
183
- - Create examples in EXAMPLES.md
184
179
  - Update ARCHITECTURE.md if needed
185
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
+
186
193
  ## Pull Request Process
187
194
 
188
195
  1. **Fork the repository**
@@ -218,91 +225,3 @@ Follow commit message conventions:
218
225
  ```bash
219
226
  git push origin feature/your-feature-name
220
227
  ```
221
-
222
- 6. **Create Pull Request**
223
-
224
- - Provide clear description of changes
225
- - Reference any related issues
226
- - Include examples of usage
227
- - Explain testing performed
228
-
229
- ## Testing
230
-
231
- ### Manual Testing
232
-
233
- ```bash
234
- # Test with a sample project
235
- cd /path/to/test/project
236
- node /path/to/heuristic-mcp/index.js
237
-
238
- # In another terminal, send MCP requests
239
- ```
240
-
241
- ### Testing MCP Tools
242
-
243
- Create a test script:
244
-
245
- ```javascript
246
- // test-tool.js
247
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
248
- // ... setup and test your tool
249
- ```
250
-
251
- ## Configuration Changes
252
-
253
- If adding new configuration options:
254
-
255
- 1. Update `lib/config.js` with new default values
256
- 2. Document in README.md
257
- 3. Add examples to EXAMPLES.md
258
- 4. Consider backward compatibility
259
-
260
- ## Documentation
261
-
262
- All documentation should:
263
-
264
- - Be clear and concise
265
- - Include code examples
266
- - Avoid emojis
267
- - Use proper markdown formatting
268
- - Be kept up-to-date with code changes
269
-
270
- ## Code Review Checklist
271
-
272
- Before submitting a PR, verify:
273
-
274
- - [ ] Code follows project style guidelines
275
- - [ ] No console.log (use console.error for MCP)
276
- - [ ] Error handling is implemented
277
- - [ ] Configuration changes are documented
278
- - [ ] README.md is updated if needed
279
- - [ ] No breaking changes without discussion
280
- - [ ] Comments explain complex logic
281
- - [ ] No emojis in code or documentation
282
-
283
- ## Feature Ideas
284
-
285
- Looking for ideas? Consider implementing:
286
-
287
- - Code complexity analysis
288
- - Pattern detection and anti-pattern identification
289
- - Documentation generation
290
- - Refactoring suggestions
291
- - Test coverage analysis
292
- - Dependency graph visualization
293
- - Performance profiling integration
294
- - Multi-language translation support
295
-
296
- ## Questions and Support
297
-
298
- - **Issues**: Use GitHub Issues for bugs and feature requests
299
- - **Discussions**: Use GitHub Discussions for questions
300
- - **Email**: Contact Softerist via website
301
-
302
- ## License
303
-
304
- By contributing, you agree that your contributions will be licensed under the MIT License.
305
-
306
- ---
307
-
308
- Thank you for contributing to Heuristic MCP!