evipedia-mcp-dev 0.1.18 → 0.1.19

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 (2) hide show
  1. package/dist/index.js +12 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48,11 +48,18 @@ async function searchReviews(query, limit = 20) {
48
48
  fetchCached(`${BASE_URL}/reviews.json`)
49
49
  ]);
50
50
  const bySlug = new Map(reviewsIndex.map((r) => [toSlug(r.permalink).toLowerCase(), r]));
51
- const q = query.toLowerCase();
52
- const has = (v) => (v ?? "").toLowerCase().includes(q);
53
- const matches = searchIndex.filter(
54
- (e) => has(e.short_topic) || has(e.alternate_names) || has(e.ep_keywords) || has(e.ep_category)
55
- );
51
+ const STOPWORDS = /* @__PURE__ */ new Set(["for", "the", "a", "an", "and", "or", "of", "to", "in", "on", "with", "vs", "versus"]);
52
+ const tokens = Array.from(new Set(
53
+ query.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 1 && !STOPWORDS.has(t))
54
+ ));
55
+ if (tokens.length === 0) return [];
56
+ const scored = searchIndex.map((e) => {
57
+ const hay = [e.short_topic, e.alternate_names, e.ep_keywords, e.ep_category].map((v) => (v ?? "").toLowerCase()).join(" ");
58
+ return { e, score: tokens.reduce((n, t) => n + (hay.includes(t) ? 1 : 0), 0) };
59
+ });
60
+ const best = scored.reduce((m, s) => Math.max(m, s.score), 0);
61
+ if (best === 0) return [];
62
+ const matches = scored.filter((s) => s.score === best).map((s) => s.e);
56
63
  return matches.slice(0, limit).map((e) => {
57
64
  const r = bySlug.get(toSlug(e.url).toLowerCase());
58
65
  return r ? { name: r.canonical_name, url: r.permalink, conclusion: r.er_conclusion, category: r.category } : { name: e.short_topic, url: e.url, category: e.ep_category };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evipedia-mcp-dev",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Internal development build of evipedia-mcp. Not for public use.",
5
5
  "type": "module",
6
6
  "bin": {