@softerist/heuristic-mcp 3.2.3 → 3.2.4
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/README.md +387 -376
- package/config.jsonc +800 -800
- package/features/ann-config.js +102 -110
- package/features/clear-cache.js +81 -84
- package/features/find-similar-code.js +265 -286
- package/features/hybrid-search.js +487 -536
- package/features/index-codebase.js +3139 -3270
- package/features/lifecycle.js +1011 -1063
- package/features/package-version.js +277 -291
- package/features/register.js +351 -370
- package/features/resources.js +115 -130
- package/features/set-workspace.js +214 -240
- package/index.js +693 -758
- package/lib/cache-ops.js +22 -22
- package/lib/cache-utils.js +465 -519
- package/lib/cache.js +1749 -1849
- package/lib/call-graph.js +396 -396
- package/lib/cli.js +232 -226
- package/lib/config.js +1483 -1495
- package/lib/constants.js +511 -493
- package/lib/embed-query-process.js +206 -212
- package/lib/embedding-process.js +434 -451
- package/lib/embedding-worker.js +862 -934
- package/lib/ignore-patterns.js +276 -316
- package/lib/json-worker.js +14 -14
- package/lib/json-writer.js +302 -310
- package/lib/logging.js +116 -127
- package/lib/memory-logger.js +13 -13
- package/lib/onnx-backend.js +188 -193
- package/lib/path-utils.js +18 -23
- package/lib/project-detector.js +82 -84
- package/lib/server-lifecycle.js +133 -145
- package/lib/settings-editor.js +738 -739
- package/lib/slice-normalize.js +25 -31
- package/lib/tokenizer.js +168 -203
- package/lib/utils.js +364 -409
- package/lib/vector-store-binary.js +973 -991
- package/lib/vector-store-sqlite.js +377 -414
- package/lib/workspace-env.js +32 -34
- package/mcp_config.json +9 -9
- package/package.json +86 -86
- package/scripts/clear-cache.js +20 -20
- package/scripts/download-model.js +43 -43
- package/scripts/mcp-launcher.js +49 -49
- package/scripts/postinstall.js +12 -12
- package/search-configs.js +36 -36
|
@@ -1,291 +1,277 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
registry
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
} else {
|
|
279
|
-
return {
|
|
280
|
-
content: [
|
|
281
|
-
{
|
|
282
|
-
type: 'text',
|
|
283
|
-
text: `Error: ${result.error}`,
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
export { fetchPackageVersion, detectRegistry, getSupportedRegistries, REGISTRIES };
|
|
1
|
+
const REGISTRIES = {
|
|
2
|
+
npm: {
|
|
3
|
+
name: 'npm',
|
|
4
|
+
pattern: /^(?:npm:)?(.+)$/,
|
|
5
|
+
url: (pkg) => `https://registry.npmjs.org/${encodeURIComponent(pkg)}/latest`,
|
|
6
|
+
parse: (data) => data.version,
|
|
7
|
+
detect: (pkg) =>
|
|
8
|
+
pkg.startsWith('@') || /^[a-z0-9][-a-z0-9._]*$/i.test(pkg.replace(/^npm:/, '')),
|
|
9
|
+
},
|
|
10
|
+
pypi: {
|
|
11
|
+
name: 'PyPI',
|
|
12
|
+
pattern: /^(?:pip:|pypi:)(.+)$/,
|
|
13
|
+
url: (pkg) => `https://pypi.org/pypi/${encodeURIComponent(pkg)}/json`,
|
|
14
|
+
parse: (data) => data.info.version,
|
|
15
|
+
detect: () => false,
|
|
16
|
+
},
|
|
17
|
+
crates: {
|
|
18
|
+
name: 'crates.io',
|
|
19
|
+
pattern: /^(?:cargo:|crates:|rust:)(.+)$/,
|
|
20
|
+
url: (pkg) => `https://crates.io/api/v1/crates/${encodeURIComponent(pkg)}`,
|
|
21
|
+
parse: (data) => data.crate.max_version,
|
|
22
|
+
headers: { 'User-Agent': 'heuristic-mcp/1.0' },
|
|
23
|
+
detect: () => false,
|
|
24
|
+
},
|
|
25
|
+
go: {
|
|
26
|
+
name: 'Go',
|
|
27
|
+
pattern: /^(?:go:)(.+)$/,
|
|
28
|
+
url: (pkg) => `https://proxy.golang.org/${encodeURIComponent(pkg)}/@latest`,
|
|
29
|
+
parse: (data) => data.Version,
|
|
30
|
+
detect: (pkg) => pkg.includes('/') && pkg.includes('.'),
|
|
31
|
+
},
|
|
32
|
+
rubygems: {
|
|
33
|
+
name: 'RubyGems',
|
|
34
|
+
pattern: /^(?:gem:|ruby:)(.+)$/,
|
|
35
|
+
url: (pkg) => `https://rubygems.org/api/v1/gems/${encodeURIComponent(pkg)}.json`,
|
|
36
|
+
parse: (data) => data.version,
|
|
37
|
+
detect: () => false,
|
|
38
|
+
},
|
|
39
|
+
nuget: {
|
|
40
|
+
name: 'NuGet',
|
|
41
|
+
pattern: /^(?:nuget:|dotnet:)(.+)$/,
|
|
42
|
+
url: (pkg) =>
|
|
43
|
+
`https://api.nuget.org/v3-flatcontainer/${encodeURIComponent(pkg.toLowerCase())}/index.json`,
|
|
44
|
+
parse: (data) => data.versions[data.versions.length - 1],
|
|
45
|
+
detect: () => false,
|
|
46
|
+
},
|
|
47
|
+
packagist: {
|
|
48
|
+
name: 'Packagist',
|
|
49
|
+
pattern: /^(?:composer:|php:)(.+)$/,
|
|
50
|
+
url: (pkg) => `https://repo.packagist.org/p2/${encodeURIComponent(pkg)}.json`,
|
|
51
|
+
parse: (data) => {
|
|
52
|
+
const pkgName = Object.keys(data.packages)[0];
|
|
53
|
+
const versions = data.packages[pkgName];
|
|
54
|
+
|
|
55
|
+
const stable = versions.find((v) => !v.version.includes('dev'));
|
|
56
|
+
return stable ? stable.version : versions[0].version;
|
|
57
|
+
},
|
|
58
|
+
detect: (pkg) => pkg.includes('/'),
|
|
59
|
+
},
|
|
60
|
+
hex: {
|
|
61
|
+
name: 'Hex',
|
|
62
|
+
pattern: /^(?:hex:|elixir:|mix:)(.+)$/,
|
|
63
|
+
url: (pkg) => `https://hex.pm/api/packages/${encodeURIComponent(pkg)}`,
|
|
64
|
+
parse: (data) => {
|
|
65
|
+
const releases = data.releases;
|
|
66
|
+
return releases.length > 0 ? releases[0].version : null;
|
|
67
|
+
},
|
|
68
|
+
detect: () => false,
|
|
69
|
+
},
|
|
70
|
+
pub: {
|
|
71
|
+
name: 'pub.dev',
|
|
72
|
+
pattern: /^(?:pub:|dart:|flutter:)(.+)$/,
|
|
73
|
+
url: (pkg) => `https://pub.dev/api/packages/${encodeURIComponent(pkg)}`,
|
|
74
|
+
parse: (data) => data.latest.version,
|
|
75
|
+
detect: () => false,
|
|
76
|
+
},
|
|
77
|
+
maven: {
|
|
78
|
+
name: 'Maven Central',
|
|
79
|
+
pattern: /^(?:maven:|java:)(.+)$/,
|
|
80
|
+
url: (pkg) => {
|
|
81
|
+
const [group, artifact] = pkg.includes(':') ? pkg.split(':') : pkg.split('/');
|
|
82
|
+
if (!artifact) return null;
|
|
83
|
+
return `https://search.maven.org/solrsearch/select?q=g:${encodeURIComponent(group)}+AND+a:${encodeURIComponent(artifact)}&rows=1&wt=json`;
|
|
84
|
+
},
|
|
85
|
+
parse: (data) => {
|
|
86
|
+
if (data.response.docs.length === 0) return null;
|
|
87
|
+
return data.response.docs[0].latestVersion;
|
|
88
|
+
},
|
|
89
|
+
detect: (pkg) => pkg.includes(':') || (pkg.includes('.') && pkg.includes('/')),
|
|
90
|
+
},
|
|
91
|
+
homebrew: {
|
|
92
|
+
name: 'Homebrew',
|
|
93
|
+
pattern: /^(?:brew:|homebrew:)(.+)$/,
|
|
94
|
+
url: (pkg) => `https://formulae.brew.sh/api/formula/${encodeURIComponent(pkg)}.json`,
|
|
95
|
+
parse: (data) => data.versions.stable,
|
|
96
|
+
detect: () => false,
|
|
97
|
+
},
|
|
98
|
+
conda: {
|
|
99
|
+
name: 'Conda',
|
|
100
|
+
pattern: /^(?:conda:)(.+)$/,
|
|
101
|
+
url: (pkg) => `https://api.anaconda.org/package/conda-forge/${encodeURIComponent(pkg)}`,
|
|
102
|
+
parse: (data) => data.latest_version,
|
|
103
|
+
detect: () => false,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function detectRegistry(packageName) {
|
|
108
|
+
for (const [key, registry] of Object.entries(REGISTRIES)) {
|
|
109
|
+
if (registry.pattern.test(packageName) && key !== 'npm') {
|
|
110
|
+
const match = packageName.match(registry.pattern);
|
|
111
|
+
if (match) {
|
|
112
|
+
return { registry, cleanName: match[1] };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
for (const registry of Object.values(REGISTRIES)) {
|
|
118
|
+
if (registry.detect(packageName)) {
|
|
119
|
+
const match = packageName.match(registry.pattern);
|
|
120
|
+
return { registry, cleanName: match ? match[1] : packageName };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const npmMatch = packageName.match(REGISTRIES.npm.pattern);
|
|
125
|
+
return { registry: REGISTRIES.npm, cleanName: npmMatch ? npmMatch[1] : packageName };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function fetchPackageVersion(packageName, timeoutMs = 10000) {
|
|
129
|
+
const { registry, cleanName } = detectRegistry(packageName);
|
|
130
|
+
|
|
131
|
+
const url = registry.url(cleanName);
|
|
132
|
+
if (!url) {
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
error: `Invalid package format for ${registry.name}: ${cleanName}`,
|
|
136
|
+
registry: registry.name,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const headers = {
|
|
145
|
+
Accept: 'application/json',
|
|
146
|
+
...(registry.headers || {}),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const response = await fetch(url, {
|
|
150
|
+
headers,
|
|
151
|
+
signal: controller.signal,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!response.ok) {
|
|
155
|
+
if (response.status === 404) {
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
error: `Package "${cleanName}" not found on ${registry.name}`,
|
|
159
|
+
registry: registry.name,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
success: false,
|
|
164
|
+
error: `${registry.name} returned status ${response.status}`,
|
|
165
|
+
registry: registry.name,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const data = await response.json();
|
|
170
|
+
const version = registry.parse(data);
|
|
171
|
+
|
|
172
|
+
if (!version) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
error: `Could not parse version from ${registry.name} response`,
|
|
176
|
+
registry: registry.name,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
success: true,
|
|
182
|
+
package: cleanName,
|
|
183
|
+
version,
|
|
184
|
+
registry: registry.name,
|
|
185
|
+
};
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error.name === 'AbortError') {
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
error: `Request to ${registry.name} timed out`,
|
|
191
|
+
registry: registry.name,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
success: false,
|
|
196
|
+
error: `Failed to fetch from ${registry.name}: ${error.message}`,
|
|
197
|
+
registry: registry.name,
|
|
198
|
+
};
|
|
199
|
+
} finally {
|
|
200
|
+
clearTimeout(timeout);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function getSupportedRegistries() {
|
|
205
|
+
return Object.entries(REGISTRIES).map(([key, reg]) => ({
|
|
206
|
+
key,
|
|
207
|
+
name: reg.name,
|
|
208
|
+
prefix: reg.pattern.source.match(/\?:([^)]+)\)/)?.[1] || key + ':',
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function getToolDefinition() {
|
|
213
|
+
return {
|
|
214
|
+
name: 'e_check_package_version',
|
|
215
|
+
description:
|
|
216
|
+
'Fetches the latest version of a package from its official registry. Supports npm, PyPI, crates.io, Maven, Go, RubyGems, NuGet, Packagist, Hex, pub.dev, Homebrew, and Conda. Use prefix like "pip:requests" for non-npm packages.',
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: 'object',
|
|
219
|
+
properties: {
|
|
220
|
+
package: {
|
|
221
|
+
type: 'string',
|
|
222
|
+
description:
|
|
223
|
+
'Package name, optionally prefixed with registry (e.g., "lodash", "pip:requests", "cargo:serde", "go:github.com/gin-gonic/gin")',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
required: ['package'],
|
|
227
|
+
},
|
|
228
|
+
annotations: {
|
|
229
|
+
title: 'Check Package Version',
|
|
230
|
+
readOnlyHint: true,
|
|
231
|
+
destructiveHint: false,
|
|
232
|
+
idempotentHint: true,
|
|
233
|
+
openWorldHint: true,
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export async function handleToolCall(request) {
|
|
239
|
+
const args = request.params?.arguments || {};
|
|
240
|
+
const packageName = args.package;
|
|
241
|
+
|
|
242
|
+
if (!packageName || typeof packageName !== 'string' || packageName.trim() === '') {
|
|
243
|
+
return {
|
|
244
|
+
content: [
|
|
245
|
+
{
|
|
246
|
+
type: 'text',
|
|
247
|
+
text: 'Error: Please provide a package name.',
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
isError: true,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const result = await fetchPackageVersion(packageName.trim());
|
|
255
|
+
|
|
256
|
+
if (result.success) {
|
|
257
|
+
return {
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: 'text',
|
|
261
|
+
text: `**${result.package}** (${result.registry})\n\nLatest version: \`${result.version}\``,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
} else {
|
|
266
|
+
return {
|
|
267
|
+
content: [
|
|
268
|
+
{
|
|
269
|
+
type: 'text',
|
|
270
|
+
text: `Error: ${result.error}`,
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export { fetchPackageVersion, detectRegistry, getSupportedRegistries, REGISTRIES };
|