magector 2.6.2 → 2.6.3

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 +35 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
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.6.2",
37
- "@magector/cli-linux-x64": "2.6.2",
38
- "@magector/cli-linux-arm64": "2.6.2",
39
- "@magector/cli-win32-x64": "2.6.2"
36
+ "@magector/cli-darwin-arm64": "2.6.3",
37
+ "@magector/cli-linux-x64": "2.6.3",
38
+ "@magector/cli-linux-arm64": "2.6.3",
39
+ "@magector/cli-win32-x64": "2.6.3"
40
40
  },
41
41
  "keywords": [
42
42
  "magento",
package/src/mcp-server.js CHANGED
@@ -4156,6 +4156,41 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
4156
4156
  );
4157
4157
  results = results.concat(pathFallback);
4158
4158
  }
4159
+ // Filesystem fallback: grep for the method definition in PHP files
4160
+ if (results.length === 0 && config.magentoRoot) {
4161
+ try {
4162
+ const methodSig = `function ${args.methodName}(`;
4163
+ // Use className to narrow the glob if provided
4164
+ const classShort = args.className ? args.className.split('\\').pop() : null;
4165
+ const globPattern = classShort ? `**/${classShort}.php` : '**/*.php';
4166
+ const files = await glob(globPattern, { cwd: config.magentoRoot, absolute: false, nodir: true, ignore: ['**/test/**', '**/tests/**', '**/Test/**'] });
4167
+ for (const f of files.slice(0, classShort ? 50 : 500)) {
4168
+ const absPath = path.join(config.magentoRoot, f);
4169
+ let content;
4170
+ try { content = readFileSync(absPath, 'utf-8'); } catch { continue; }
4171
+ if (!content.includes(methodSig)) continue;
4172
+ let className = null;
4173
+ const nsMatch = content.match(/namespace\s+([\w\\]+)/);
4174
+ const classMatch = content.match(/class\s+(\w+)/);
4175
+ if (nsMatch && classMatch) className = nsMatch[1] + '\\' + classMatch[1];
4176
+ const methodsFound = [];
4177
+ const mRegex = /public\s+function\s+(\w+)\s*\(/g;
4178
+ let mm;
4179
+ while ((mm = mRegex.exec(content)) !== null) methodsFound.push(mm[1]);
4180
+ const body = readFullMethodBody(absPath, args.methodName);
4181
+ results.push({
4182
+ path: f,
4183
+ className,
4184
+ methods: methodsFound,
4185
+ methodName: args.methodName,
4186
+ score: 0.5,
4187
+ searchText: content.slice(0, 300),
4188
+ fullMethodBody: body || undefined
4189
+ });
4190
+ if (results.length >= 5) break;
4191
+ }
4192
+ } catch {}
4193
+ }
4159
4194
  // Boost exact method matches to top
4160
4195
  results = results.map(r => {
4161
4196
  let bonus = 0;