magector 2.6.4 → 2.7.0
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/package.json +5 -5
- package/src/mcp-server.js +48 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
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.
|
|
37
|
-
"@magector/cli-linux-x64": "2.
|
|
38
|
-
"@magector/cli-linux-arm64": "2.
|
|
39
|
-
"@magector/cli-win32-x64": "2.
|
|
36
|
+
"@magector/cli-darwin-arm64": "2.7.0",
|
|
37
|
+
"@magector/cli-linux-x64": "2.7.0",
|
|
38
|
+
"@magector/cli-linux-arm64": "2.7.0",
|
|
39
|
+
"@magector/cli-win32-x64": "2.7.0"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -2283,6 +2283,7 @@ async function analyzeImpact(className) {
|
|
|
2283
2283
|
|
|
2284
2284
|
// Filesystem fallback: if vector search found too few files, find the class file via glob
|
|
2285
2285
|
if (relatedPaths.length < 5 && root) {
|
|
2286
|
+
logToFile('INFO', `impact_analysis: vector search returned ${relatedPaths.length} files for "${className}" — using filesystem fallback`);
|
|
2286
2287
|
try {
|
|
2287
2288
|
const classFiles = await glob(`**/${shortName}.php`, { cwd: root, absolute: false, nodir: true });
|
|
2288
2289
|
const existingPaths = new Set(relatedPaths.map(r => r.path));
|
|
@@ -4097,6 +4098,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
4097
4098
|
if (results.length === 0 && config.magentoRoot) {
|
|
4098
4099
|
const shortName = args.className.split('\\').pop();
|
|
4099
4100
|
const globPattern = `**/${shortName}.php`;
|
|
4101
|
+
logToFile('INFO', `find_class: vector search returned 0 results for "${args.className}" — using filesystem fallback (glob ${globPattern})`);
|
|
4100
4102
|
try {
|
|
4101
4103
|
const files = await glob(globPattern, { cwd: config.magentoRoot, absolute: false, nodir: true, ignore: ['**/test/**', '**/tests/**', '**/Test/**'] });
|
|
4102
4104
|
// Filter by namespace if provided
|
|
@@ -4128,6 +4130,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
4128
4130
|
results.push({ path: filePath, className, score: 0.5 });
|
|
4129
4131
|
}
|
|
4130
4132
|
}
|
|
4133
|
+
if (results.length > 0) logToFile('INFO', `find_class: filesystem fallback found ${results.length} files for "${args.className}"`);
|
|
4131
4134
|
} catch {}
|
|
4132
4135
|
}
|
|
4133
4136
|
|
|
@@ -4158,6 +4161,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
4158
4161
|
}
|
|
4159
4162
|
// Filesystem fallback: use grep to find method definition across all PHP files
|
|
4160
4163
|
if (results.length === 0 && config.magentoRoot) {
|
|
4164
|
+
logToFile('INFO', `find_method: vector search returned 0 results for "${args.methodName}" — using filesystem fallback (grep -rl)`);
|
|
4161
4165
|
try {
|
|
4162
4166
|
const methodSig = `function ${args.methodName}(`;
|
|
4163
4167
|
// Use className to narrow search if provided, otherwise grep all PHP
|
|
@@ -4200,7 +4204,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
4200
4204
|
});
|
|
4201
4205
|
if (results.length >= 5) break;
|
|
4202
4206
|
}
|
|
4203
|
-
|
|
4207
|
+
if (results.length > 0) logToFile('INFO', `find_method: filesystem fallback found ${results.length} files containing "${args.methodName}"`);
|
|
4208
|
+
} catch (err) {
|
|
4209
|
+
logToFile('WARN', `find_method: filesystem fallback error: ${err.message}`);
|
|
4210
|
+
}
|
|
4204
4211
|
}
|
|
4205
4212
|
// Boost exact method matches to top
|
|
4206
4213
|
results = results.map(r => {
|
|
@@ -4745,6 +4752,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
4745
4752
|
|
|
4746
4753
|
// Filesystem fallback: if vector search found nothing, glob the module directory
|
|
4747
4754
|
if (results.length === 0 && config.magentoRoot && vendorPath) {
|
|
4755
|
+
logToFile('INFO', `module_structure: vector search returned 0 results for "${args.moduleName}" — using filesystem fallback (glob ${vendorPath})`);
|
|
4748
4756
|
try {
|
|
4749
4757
|
const vendorGlob = `**/${vendorPath}**/*.{php,xml,phtml}`;
|
|
4750
4758
|
const files = await glob(vendorGlob, { cwd: config.magentoRoot, absolute: false, nodir: true });
|
|
@@ -5632,7 +5640,45 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
5632
5640
|
const res = raw.map(normalizeResult).filter(r =>
|
|
5633
5641
|
r.magentoType === 'plugin' || r.path?.toLowerCase().includes('plugin')
|
|
5634
5642
|
);
|
|
5635
|
-
text = formatSearchResults(res.slice(0,
|
|
5643
|
+
text = formatSearchResults(res.slice(0, 5));
|
|
5644
|
+
// DI registrations + method bodies (same as standalone find_plugin)
|
|
5645
|
+
if (a.targetClass) {
|
|
5646
|
+
const diFiles = await getDiXmlFiles(config.magentoRoot);
|
|
5647
|
+
const normalizedTarget = a.targetClass.replace(/\\\\/g, '\\');
|
|
5648
|
+
const isFqcn = normalizedTarget.includes('\\');
|
|
5649
|
+
const shortTarget = normalizedTarget.split('\\').pop().toLowerCase();
|
|
5650
|
+
for (const { content: diContent, relPath } of diFiles) {
|
|
5651
|
+
if (!diContent.includes(isFqcn ? normalizedTarget : a.targetClass)) continue;
|
|
5652
|
+
const typeBlockRegex = /<type\s+name="([^"]+)"[^>]*>([\s\S]*?)<\/type>/g;
|
|
5653
|
+
let tm;
|
|
5654
|
+
while ((tm = typeBlockRegex.exec(diContent)) !== null) {
|
|
5655
|
+
const typeName = tm[1].replace(/\\\\/g, '\\');
|
|
5656
|
+
const typeMatches = isFqcn ? typeName === normalizedTarget : typeName.split('\\').pop().toLowerCase() === shortTarget;
|
|
5657
|
+
if (!typeMatches) continue;
|
|
5658
|
+
const block = tm[2];
|
|
5659
|
+
const pluginRegex = /<plugin\s+([^/>]*)\/?>/g;
|
|
5660
|
+
let pm;
|
|
5661
|
+
while ((pm = pluginRegex.exec(block)) !== null) {
|
|
5662
|
+
const attrs = {};
|
|
5663
|
+
const localAttrRe = /(\w+)="([^"]*)"/g;
|
|
5664
|
+
let am;
|
|
5665
|
+
while ((am = localAttrRe.exec(pm[1])) !== null) attrs[am[1]] = am[2];
|
|
5666
|
+
text += `\n- **${attrs.name || '?'}** → \`${attrs.type || '?'}\` (${relPath})`;
|
|
5667
|
+
if (attrs.type) {
|
|
5668
|
+
const pFile = findClassFile(config.magentoRoot, attrs.type);
|
|
5669
|
+
if (pFile) {
|
|
5670
|
+
const methods = extractPluginMethods(pFile);
|
|
5671
|
+
for (const m of methods) {
|
|
5672
|
+
const body = readFullMethodBody(pFile, m.name);
|
|
5673
|
+
text += `\n - \`${m.type}\` **${m.targetMethod}** → \`${m.name}()\``;
|
|
5674
|
+
if (body) text += '\n ' + '```php\n ' + body.split('\n').join('\n ') + '\n ' + '```';
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5636
5682
|
break;
|
|
5637
5683
|
}
|
|
5638
5684
|
case 'magento_find_observer': {
|