magector 2.4.0 → 2.4.1

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 +19 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Semantic code search for Magento 2 — index, search, MCP server",
5
5
  "type": "module",
6
6
  "main": "src/mcp-server.js",
@@ -33,10 +33,10 @@
33
33
  "ruvector": "^0.1.96"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@magector/cli-darwin-arm64": "2.4.0",
37
- "@magector/cli-linux-x64": "2.4.0",
38
- "@magector/cli-linux-arm64": "2.4.0",
39
- "@magector/cli-win32-x64": "2.4.0"
36
+ "@magector/cli-darwin-arm64": "2.4.1",
37
+ "@magector/cli-linux-x64": "2.4.1",
38
+ "@magector/cli-linux-arm64": "2.4.1",
39
+ "@magector/cli-win32-x64": "2.4.1"
40
40
  },
41
41
  "keywords": [
42
42
  "magento",
package/src/mcp-server.js CHANGED
@@ -3655,30 +3655,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3655
3655
  if (args.targetClass) {
3656
3656
  const fpRoot = config.magentoRoot;
3657
3657
  const diFiles = await glob('**/etc/**/di.xml', { cwd: fpRoot, absolute: true, nodir: true });
3658
- const shortTarget = args.targetClass.split('\\').pop();
3658
+ // Normalize target class for matching (both \ and \\)
3659
+ const normalizedTarget = args.targetClass.replace(/\\\\/g, '\\');
3659
3660
  for (const diFile of diFiles) {
3660
3661
  let content;
3661
3662
  try { content = readFileSync(diFile, 'utf-8'); } catch { continue; }
3662
- if (!content.includes(shortTarget)) continue;
3663
+ if (!content.includes(normalizedTarget)) continue;
3663
3664
  const relPath = diFile.replace(fpRoot + '/', '');
3664
3665
  // Find plugin registrations for this target
3665
3666
  const typeBlockRegex = /<type\s+name="([^"]+)"[^>]*>([\s\S]*?)<\/type>/g;
3666
3667
  let tm;
3667
3668
  while ((tm = typeBlockRegex.exec(content)) !== null) {
3668
- const typeName = tm[1];
3669
- if (!typeName.includes(shortTarget)) continue;
3669
+ const typeName = tm[1].replace(/\\\\/g, '\\');
3670
+ if (typeName !== normalizedTarget) continue;
3670
3671
  const block = tm[2];
3671
- const pluginRegex = /<plugin\s+name="([^"]+)"[^>]*type="([^"]+)"[^>]*/g;
3672
+ const pluginRegex = /<plugin\s+([^/>]*)\/?>/g;
3672
3673
  let pm;
3673
3674
  while ((pm = pluginRegex.exec(block)) !== null) {
3675
+ const attrs = {};
3676
+ const localAttrRe = /(\w+)="([^"]*)"/g;
3677
+ let am;
3678
+ while ((am = localAttrRe.exec(pm[1])) !== null) {
3679
+ attrs[am[1]] = am[2];
3680
+ }
3674
3681
  let area = 'global';
3675
3682
  if (relPath.includes('/etc/adminhtml/')) area = 'adminhtml';
3676
3683
  else if (relPath.includes('/etc/frontend/')) area = 'frontend';
3677
3684
  else if (relPath.includes('/etc/graphql/')) area = 'graphql';
3678
3685
  diRegistrations.push({
3679
3686
  target: typeName,
3680
- pluginName: pm[1],
3681
- pluginClass: pm[2],
3687
+ pluginName: attrs.name || '',
3688
+ pluginClass: attrs.type || '',
3689
+ disabled: attrs.disabled === 'true',
3690
+ sortOrder: attrs.sortOrder || null,
3682
3691
  area,
3683
3692
  file: relPath
3684
3693
  });
@@ -3691,7 +3700,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3691
3700
  if (diRegistrations.length > 0) {
3692
3701
  text += `\n\n### DI Plugin Registrations for ${args.targetClass} (${diRegistrations.length})\n`;
3693
3702
  for (const reg of diRegistrations) {
3694
- text += `- **${reg.pluginName}** \`${reg.pluginClass}\` [${reg.area}] (${reg.file})\n`;
3703
+ const disabledTag = reg.disabled ? ' **[DISABLED]**' : '';
3704
+ const sortTag = reg.sortOrder ? ` (sortOrder: ${reg.sortOrder})` : '';
3705
+ text += `- **${reg.pluginName}** → \`${reg.pluginClass}\` [${reg.area}]${sortTag}${disabledTag} (${reg.file})\n`;
3695
3706
  }
3696
3707
  }
3697
3708