@softerist/heuristic-mcp 2.1.25 → 2.1.27

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.
@@ -237,19 +237,7 @@ export async function logs() {
237
237
  mcpConfigs.push({ name: 'Claude Desktop', path: claudeConfig, exists: claudeExists });
238
238
  }
239
239
 
240
- // VS Code (MCP extension uses settings.json or dedicated config)
241
- let vscodeConfig = null;
242
- if (process.platform === 'darwin') {
243
- vscodeConfig = path.join(home, 'Library', 'Application Support', 'Code', 'User', 'settings.json');
244
- } else if (process.platform === 'win32') {
245
- vscodeConfig = path.join(process.env.APPDATA || '', 'Code', 'User', 'settings.json');
246
- } else {
247
- vscodeConfig = path.join(home, '.config', 'Code', 'User', 'settings.json');
248
- }
249
- const vscodeExists = await fs.access(vscodeConfig).then(() => true).catch(() => false);
250
- mcpConfigs.push({ name: 'VS Code', path: vscodeConfig, exists: vscodeExists });
251
-
252
- // Cursor (uses similar structure to VS Code)
240
+ // Cursor (uses settings.json with mcpServers key)
253
241
  let cursorConfig = null;
254
242
  if (process.platform === 'darwin') {
255
243
  cursorConfig = path.join(home, 'Library', 'Application Support', 'Cursor', 'User', 'settings.json');
@@ -16,53 +16,77 @@ function expandPath(p) {
16
16
  return p;
17
17
  }
18
18
 
19
+ // Detect which IDE is running the install
20
+ function detectCurrentIDE() {
21
+ // Check environment variables to determine which IDE is running
22
+ if (process.env.ANTIGRAVITY_AGENT) {
23
+ return 'Antigravity';
24
+ }
25
+ if (process.env.CURSOR_AGENT) {
26
+ return 'Cursor';
27
+ }
28
+ // Claude Desktop doesn't have a known env var, so we rely on existing config detection
29
+ return null;
30
+ }
31
+
19
32
  // Known config paths for different IDEs
20
- function getConfigPaths() {
33
+ function getConfigPaths(filterToCurrentIDE = true) {
21
34
  const platform = process.platform;
22
35
  const home = os.homedir();
23
- const paths = [];
36
+ const allPaths = [];
24
37
 
25
38
  // Antigravity
26
- paths.push({
39
+ allPaths.push({
27
40
  name: 'Antigravity',
28
- path: path.join(home, '.gemini', 'antigravity', 'mcp_config.json')
41
+ path: path.join(home, '.gemini', 'antigravity', 'mcp_config.json'),
42
+ canCreate: true // Dedicated MCP config, safe to create
29
43
  });
30
44
 
31
45
  // Claude Desktop
32
46
  if (platform === 'darwin') {
33
- paths.push({
47
+ allPaths.push({
34
48
  name: 'Claude Desktop',
35
- path: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json')
49
+ path: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
50
+ canCreate: true // Dedicated config file
36
51
  });
37
52
  } else if (platform === 'win32') {
38
- paths.push({
53
+ allPaths.push({
39
54
  name: 'Claude Desktop',
40
- path: path.join(process.env.APPDATA || '', 'Claude', 'claude_desktop_config.json')
55
+ path: path.join(process.env.APPDATA || '', 'Claude', 'claude_desktop_config.json'),
56
+ canCreate: true
41
57
  });
42
58
  }
43
59
 
44
- // Note: VS Code support is shown in --logs but NOT auto-registered
45
- // because settings.json is a general config file that should not be auto-modified.
46
-
47
- // Cursor (has MCP support, uses settings.json key)
60
+ // Cursor (uses settings.json with mcpServers key)
48
61
  if (platform === 'darwin') {
49
- paths.push({
62
+ allPaths.push({
50
63
  name: 'Cursor',
51
- path: path.join(home, 'Library', 'Application Support', 'Cursor', 'User', 'settings.json')
64
+ path: path.join(home, 'Library', 'Application Support', 'Cursor', 'User', 'settings.json'),
65
+ canCreate: false // Shared settings file, only update if exists
52
66
  });
53
67
  } else if (platform === 'win32') {
54
- paths.push({
68
+ allPaths.push({
55
69
  name: 'Cursor',
56
- path: path.join(process.env.APPDATA || '', 'Cursor', 'User', 'settings.json')
70
+ path: path.join(process.env.APPDATA || '', 'Cursor', 'User', 'settings.json'),
71
+ canCreate: false
57
72
  });
58
73
  } else {
59
- paths.push({
74
+ allPaths.push({
60
75
  name: 'Cursor',
61
- path: path.join(home, '.config', 'Cursor', 'User', 'settings.json')
76
+ path: path.join(home, '.config', 'Cursor', 'User', 'settings.json'),
77
+ canCreate: false
62
78
  });
63
79
  }
64
80
 
65
- return paths;
81
+ // Filter to current IDE if detected and requested
82
+ if (filterToCurrentIDE) {
83
+ const currentIDE = detectCurrentIDE();
84
+ if (currentIDE) {
85
+ return allPaths.filter(p => p.name === currentIDE);
86
+ }
87
+ }
88
+
89
+ return allPaths;
66
90
  }
67
91
 
68
92
  // Helper to force output to terminal, bypassing npm's silence
@@ -94,28 +118,45 @@ export async function register(filter = null) {
94
118
 
95
119
  forceLog(`[Auto-Register] Detecting IDE configurations...`);
96
120
 
97
- for (const { name, path: configPath } of configPaths) {
121
+ for (const { name, path: configPath, canCreate } of configPaths) {
98
122
  if (filter && name.toLowerCase() !== filter.toLowerCase()) {
99
123
  continue;
100
124
  }
101
125
 
102
126
  try {
103
- // Check if file exists
127
+ // Check if file exists - create if canCreate is true for this IDE
128
+ let config = {};
129
+ let fileExists = true;
130
+
104
131
  try {
105
132
  await fs.access(configPath);
106
133
  } catch {
107
- // forceLog(`[Auto-Register] Skipped ${name}: Config file not found at ${configPath}`);
108
- continue;
134
+ fileExists = false;
135
+
136
+ // Only create config if this IDE allows it (has dedicated MCP config file)
137
+ if (canCreate) {
138
+ try {
139
+ await fs.mkdir(path.dirname(configPath), { recursive: true });
140
+ forceLog(`[Auto-Register] Creating ${name} config at ${configPath}`);
141
+ } catch (mkdirErr) {
142
+ forceLog(`[Auto-Register] Skipped ${name}: Cannot create config directory: ${mkdirErr.message}`);
143
+ continue;
144
+ }
145
+ } else {
146
+ // Skip IDEs that use shared settings files if they don't exist
147
+ continue;
148
+ }
109
149
  }
110
150
 
111
- // Read config
112
- const content = await fs.readFile(configPath, 'utf-8');
113
- let config = {};
114
- try {
115
- config = JSON.parse(content);
116
- } catch (e) {
117
- forceLog(`[Auto-Register] Error parsing ${name} config: ${e.message}`);
118
- continue;
151
+ // Read existing config if file exists
152
+ if (fileExists) {
153
+ const content = await fs.readFile(configPath, 'utf-8');
154
+ try {
155
+ config = JSON.parse(content);
156
+ } catch (e) {
157
+ forceLog(`[Auto-Register] Error parsing ${name} config: ${e.message}`);
158
+ continue;
159
+ }
119
160
  }
120
161
 
121
162
  // Init mcpServers if missing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softerist/heuristic-mcp",
3
- "version": "2.1.25",
3
+ "version": "2.1.27",
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",