vcluster-yaml-mcp-server 1.4.1 → 1.4.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/dist/tool-handlers.js +40 -15
- package/package.json +1 -1
package/dist/tool-handlers.js
CHANGED
|
@@ -343,26 +343,51 @@ export function sortByRelevance(results, searchTerm) {
|
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
|
-
* Rank search result
|
|
347
|
-
* Pure function
|
|
346
|
+
* Rank search result - multi-keyword aware
|
|
348
347
|
*/
|
|
349
348
|
function rankResult(item, searchTerm) {
|
|
350
349
|
let score = 0;
|
|
351
350
|
const pathLower = item.path.toLowerCase();
|
|
352
351
|
const keyLower = item.key.toLowerCase();
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
score
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
352
|
+
const termLower = searchTerm.toLowerCase();
|
|
353
|
+
if (termLower.includes('.')) {
|
|
354
|
+
if (pathLower === termLower)
|
|
355
|
+
score += 100;
|
|
356
|
+
if (pathLower.includes(termLower))
|
|
357
|
+
score += 20;
|
|
358
|
+
if (item.isLeaf)
|
|
359
|
+
score += 5;
|
|
360
|
+
return score;
|
|
361
|
+
}
|
|
362
|
+
const stopWords = new Set([
|
|
363
|
+
'how', 'to', 'the', 'a', 'an', 'is', 'are', 'from', 'what', 'which',
|
|
364
|
+
'for', 'with', 'in', 'on', 'at', 'by', 'and', 'or', 'of', 'do', 'does'
|
|
365
|
+
]);
|
|
366
|
+
const keywords = searchTerm.split(/\s+/).filter(w => w.length > 2 && !stopWords.has(w));
|
|
367
|
+
if (keywords.length > 1) {
|
|
368
|
+
let matchCount = 0;
|
|
369
|
+
for (const kw of keywords) {
|
|
370
|
+
if (pathLower.includes(kw) || keyLower.includes(kw)) {
|
|
371
|
+
matchCount++;
|
|
372
|
+
if (keyLower.includes(kw))
|
|
373
|
+
score += 15;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
score += matchCount * 25;
|
|
377
|
+
if (matchCount === keywords.length)
|
|
378
|
+
score += 50;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
const term = keywords[0] ?? searchTerm;
|
|
382
|
+
if (pathLower === term)
|
|
383
|
+
score += 100;
|
|
384
|
+
if (keyLower === term)
|
|
385
|
+
score += 50;
|
|
386
|
+
if (pathLower.includes(term))
|
|
387
|
+
score += 20;
|
|
388
|
+
if (keyLower.includes(term))
|
|
389
|
+
score += 10;
|
|
390
|
+
}
|
|
366
391
|
if (item.isLeaf)
|
|
367
392
|
score += 5;
|
|
368
393
|
return score;
|