@softerist/heuristic-mcp 2.1.32 → 2.1.34
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/features/register.js +16 -17
- package/index.js +13 -1
- package/lib/config.js +1 -1
- package/package.json +1 -1
package/features/register.js
CHANGED
|
@@ -4,19 +4,6 @@ import path from 'path';
|
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
|
-
// Helper to expand ~ and %vars%
|
|
8
|
-
function expandPath(p) {
|
|
9
|
-
if (p.startsWith('~/')) {
|
|
10
|
-
return path.join(os.homedir(), p.slice(2));
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (process.platform === 'win32') {
|
|
15
|
-
return p.replace(/%([^%]+)%/g, (_, n) => process.env[n] || '%' + n + '%');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return p;
|
|
19
|
-
}
|
|
20
7
|
|
|
21
8
|
// Detect which IDE is running the install
|
|
22
9
|
function detectCurrentIDE() {
|
|
@@ -107,13 +94,19 @@ export async function register(filter = null) {
|
|
|
107
94
|
const binaryPath = process.execPath; // The node binary
|
|
108
95
|
const scriptPath = fileURLToPath(new URL('../index.js', import.meta.url)); // Absolute path to index.js
|
|
109
96
|
|
|
97
|
+
// For Antigravity, we MUST use absolute path because ${workspaceFolder} variable expansion
|
|
98
|
+
// is not supported in the current version, and '.' uses the wrong CWD.
|
|
99
|
+
// For other IDEs, '.' is usually safer or they support variables.
|
|
100
|
+
const workspacePath = currentIDE === 'Antigravity' ? process.cwd() : '.';
|
|
101
|
+
|
|
110
102
|
const serverConfig = {
|
|
111
103
|
command: binaryPath,
|
|
112
|
-
args: [scriptPath, "--workspace",
|
|
104
|
+
args: [scriptPath, "--workspace", workspacePath],
|
|
113
105
|
disabled: false,
|
|
114
106
|
autoRegistered: true // Marker to know we did this
|
|
115
107
|
};
|
|
116
108
|
|
|
109
|
+
|
|
117
110
|
const configPaths = getConfigPaths();
|
|
118
111
|
let registeredCount = 0;
|
|
119
112
|
|
|
@@ -153,11 +146,17 @@ export async function register(filter = null) {
|
|
|
153
146
|
if (fileExists) {
|
|
154
147
|
const content = await fs.readFile(configPath, 'utf-8');
|
|
155
148
|
try {
|
|
156
|
-
|
|
149
|
+
if (!content || content.trim() === '') {
|
|
150
|
+
// Empty file - treat as new
|
|
151
|
+
config = {};
|
|
152
|
+
} else {
|
|
153
|
+
config = JSON.parse(content);
|
|
154
|
+
}
|
|
157
155
|
} catch (e) {
|
|
158
|
-
forceLog(`[Auto-Register]
|
|
159
|
-
|
|
156
|
+
forceLog(`[Auto-Register] Warning: Corrupt/empty ${name} config, resetting to default. Error: ${e.message}`);
|
|
157
|
+
config = {};
|
|
160
158
|
}
|
|
159
|
+
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
// Init mcpServers if missing
|
package/index.js
CHANGED
|
@@ -5,13 +5,16 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
5
5
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
6
6
|
import { pipeline } from "@xenova/transformers";
|
|
7
7
|
import fs from "fs/promises";
|
|
8
|
+
import path from "path";
|
|
9
|
+
|
|
8
10
|
import { createRequire } from "module";
|
|
9
11
|
|
|
10
12
|
// Import package.json for version
|
|
11
13
|
const require = createRequire(import.meta.url);
|
|
12
14
|
const packageJson = require("./package.json");
|
|
13
15
|
|
|
14
|
-
import { loadConfig } from "./lib/config.js";
|
|
16
|
+
import { loadConfig, getGlobalCacheDir } from "./lib/config.js";
|
|
17
|
+
|
|
15
18
|
import { EmbeddingsCache } from "./lib/cache.js";
|
|
16
19
|
import { CodebaseIndexer } from "./features/index-codebase.js";
|
|
17
20
|
import { HybridSearch } from "./features/hybrid-search.js";
|
|
@@ -23,6 +26,15 @@ import * as FindSimilarCodeFeature from "./features/find-similar-code.js";
|
|
|
23
26
|
import * as AnnConfigFeature from "./features/ann-config.js";
|
|
24
27
|
import { register } from "./features/register.js";
|
|
25
28
|
|
|
29
|
+
// Log cache directory logic for debugging
|
|
30
|
+
try {
|
|
31
|
+
const globalCache = path.join(getGlobalCacheDir(), 'heuristic-mcp');
|
|
32
|
+
const localCache = path.join(process.cwd(), '.heuristic-mcp');
|
|
33
|
+
console.error(`[Server] Cache debug: Global=${globalCache}, Local=${localCache}`);
|
|
34
|
+
console.error(`[Server] Process CWD: ${process.cwd()}`);
|
|
35
|
+
} catch (e) {}
|
|
36
|
+
|
|
37
|
+
|
|
26
38
|
// Parse workspace from command line arguments
|
|
27
39
|
const args = process.argv.slice(2);
|
|
28
40
|
|
package/lib/config.js
CHANGED
|
@@ -407,7 +407,7 @@ export async function loadConfig(workspaceDir = null) {
|
|
|
407
407
|
/**
|
|
408
408
|
* Get platform-specific global cache directory
|
|
409
409
|
*/
|
|
410
|
-
function getGlobalCacheDir() {
|
|
410
|
+
export function getGlobalCacheDir() {
|
|
411
411
|
if (process.platform === 'win32') {
|
|
412
412
|
return process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
|
413
413
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softerist/heuristic-mcp",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.34",
|
|
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",
|