magector 2.1.0 → 2.1.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/mcp-server.js +18 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Semantic code search for Magento 2 — index, search, MCP server",
5
5
  "type": "module",
6
6
  "main": "src/mcp-server.js",
@@ -39,10 +39,10 @@
39
39
  "ruvector": "^0.1.96"
40
40
  },
41
41
  "optionalDependencies": {
42
- "@magector/cli-darwin-arm64": "2.1.0",
43
- "@magector/cli-linux-x64": "2.1.0",
44
- "@magector/cli-linux-arm64": "2.1.0",
45
- "@magector/cli-win32-x64": "2.1.0"
42
+ "@magector/cli-darwin-arm64": "2.1.2",
43
+ "@magector/cli-linux-x64": "2.1.2",
44
+ "@magector/cli-linux-arm64": "2.1.2",
45
+ "@magector/cli-win32-x64": "2.1.2"
46
46
  },
47
47
  "keywords": [
48
48
  "magento",
package/src/mcp-server.js CHANGED
@@ -121,8 +121,14 @@ function extractJson(stdout) {
121
121
  }
122
122
  // Fallback: try parsing the entire output (handles multi-line JSON)
123
123
  // Strip lines that look like tracing (start with ANSI escape or timestamp bracket)
124
+ // Also skip non-JSON prefix lines (e.g. "setting number of points 50000" from HNSW)
125
+ const logLineRe = /^\s*(\x1b\[|\[[\d\-T:.Z]+)/;
126
+ const jsonStartRe = /^\s*[\[{"\-0-9tfn]/;
127
+ let startIdx = lines.findIndex(l => l.trim() && !logLineRe.test(l) && jsonStartRe.test(l));
128
+ if (startIdx < 0) startIdx = 0;
124
129
  const cleaned = lines
125
- .filter(l => !l.match(/^\s*(\x1b\[|\[[\d\-T:.Z]+)/) && l.trim())
130
+ .slice(startIdx)
131
+ .filter(l => !logLineRe.test(l) && l.trim())
126
132
  .join('\n')
127
133
  .trim();
128
134
  if (cleaned) {
@@ -500,7 +506,8 @@ async function rustSearchAsync(query, limit = 10) {
500
506
  const cacheKey = `${query}|${limit}`;
501
507
  if (searchCache.has(cacheKey)) {
502
508
  logToFile('CACHE', `HIT: "${query}" (limit=${limit})`);
503
- return searchCache.get(cacheKey);
509
+ const cached = searchCache.get(cacheKey);
510
+ return Array.isArray(cached) ? cached : [];
504
511
  }
505
512
 
506
513
  // Wait for serve process if it's starting up but not yet ready
@@ -513,7 +520,7 @@ async function rustSearchAsync(query, limit = 10) {
513
520
  if (serveProcess && serveReady) {
514
521
  try {
515
522
  const resp = await serveQuery('search', { query, limit });
516
- if (resp.ok && resp.data) {
523
+ if (resp.ok && Array.isArray(resp.data)) {
517
524
  cacheSet(cacheKey, resp.data);
518
525
  return resp.data;
519
526
  }
@@ -524,7 +531,13 @@ async function rustSearchAsync(query, limit = 10) {
524
531
 
525
532
  // Fallback: cold-start execFileSync
526
533
  logToFile('INFO', `Using execFileSync fallback for search: "${query}"`);
527
- return rustSearchSync(query, limit);
534
+ try {
535
+ const result = rustSearchSync(query, limit);
536
+ return Array.isArray(result) ? result : [];
537
+ } catch (err) {
538
+ logToFile('WARN', `execFileSync fallback failed: ${err.message}`);
539
+ return [];
540
+ }
528
541
  }
529
542
 
530
543
  function rustSearchSync(query, limit = 10) {
@@ -1742,7 +1755,7 @@ async function findTests(className, methodName) {
1742
1755
  const server = new Server(
1743
1756
  {
1744
1757
  name: 'magector',
1745
- version: '2.1.0'
1758
+ version: '2.1.1'
1746
1759
  },
1747
1760
  {
1748
1761
  capabilities: {