magector 1.7.2 → 2.1.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Technology-aware MCP server for Magento 2 and Adobe Commerce with intelligent indexing and search.**
4
4
 
5
- Magector is a Model Context Protocol (MCP) server that deeply understands Magento 2 and Adobe Commerce. It builds a semantic vector index of your entire codebase — 18,000+ files across hundreds of modules — and exposes 21 tools that let AI assistants search, navigate, and understand the code with domain-specific intelligence. Instead of grepping for keywords, your AI asks *"how are checkout totals calculated?"* and gets ranked, relevant results in under 50ms, enriched with Magento pattern detection (plugins, observers, controllers, DI preferences, layout XML, and 20+ more).
5
+ Magector is a Model Context Protocol (MCP) server that deeply understands Magento 2 and Adobe Commerce. It builds a semantic vector index of your entire codebase — 18,000+ files across hundreds of modules — and exposes 28 tools that let AI assistants search, navigate, and understand the code with domain-specific intelligence. Instead of grepping for keywords, your AI asks *"how are checkout totals calculated?"* and gets ranked, relevant results in under 50ms, enriched with Magento pattern detection (plugins, observers, controllers, DI preferences, layout XML, and 20+ more).
6
6
 
7
7
  [![Rust](https://img.shields.io/badge/rust-1.75+-orange.svg)](https://www.rust-lang.org)
8
8
  [![Node.js](https://img.shields.io/badge/node-18+-green.svg)](https://nodejs.org)
@@ -58,7 +58,7 @@ The result: your AI assistant calls one MCP tool and gets ranked, pattern-enrich
58
58
  - **Complexity analysis** -- cyclomatic complexity, function count, and hotspot detection across modules
59
59
  - **Fast** -- 10-45ms queries via persistent serve process, batched ONNX embedding with adaptive thread scaling
60
60
  - **LLM description enrichment** -- generate natural-language descriptions of di.xml files using Claude, stored in SQLite, and prepend them to embedding text so descriptions influence vector search ranking (not just post-retrieval display)
61
- - **MCP server** -- 21 tools integrating with Claude Code, Cursor, and any MCP-compatible AI tool
61
+ - **MCP server** -- 28 tools integrating with Claude Code, Cursor, and any MCP-compatible AI tool
62
62
  - **Clean architecture** -- Rust core handles all indexing/search, Node.js MCP server delegates to it
63
63
 
64
64
  ---
@@ -70,7 +70,7 @@ flowchart LR
70
70
  subgraph node ["Node.js Layer"]
71
71
  direction TB
72
72
  G["CLI<br/>init · index · search · describe"]
73
- E["MCP Server<br/>21 tools · LRU cache"]
73
+ E["MCP Server<br/>28 tools · LRU cache"]
74
74
  F["Persistent Serve Process"]
75
75
  G --> F
76
76
  E --> F
@@ -369,7 +369,7 @@ npx magector index --force
369
369
 
370
370
  ## MCP Server Tools
371
371
 
372
- The MCP server exposes 21 tools for AI-assisted Magento 2 and Adobe Commerce development. All search tools return **structured JSON** with file paths, class names, methods, role badges, and content snippets -- enabling AI clients to parse results programmatically and minimize file-read round-trips.
372
+ The MCP server exposes 28 tools for AI-assisted Magento 2 and Adobe Commerce development. All search tools return **structured JSON** with file paths, class names, methods, role badges, and content snippets -- enabling AI clients to parse results programmatically and minimize file-read round-trips.
373
373
 
374
374
  ### Output Format
375
375
 
@@ -425,14 +425,31 @@ All search tools return structured JSON:
425
425
  | `magento_find_cron` | Find cron job definitions in crontab.xml |
426
426
  | `magento_find_db_schema` | Find database table definitions in db_schema.xml (declarative schema) |
427
427
 
428
- ### Flow Tracing
428
+ ### Flow & Dependency Tracing
429
429
 
430
430
  | Tool | Description |
431
431
  |------|-------------|
432
432
  | `magento_trace_flow` | Trace execution flow from an entry point (route, API, GraphQL, event, cron) -- maps controller → plugins → observers → templates in one call |
433
+ | `magento_trace_dependency` | Trace DI graph for a class/interface -- preferences, plugins, virtualTypes, argument overrides (parses all di.xml, no index needed) |
434
+ | `magento_find_event_flow` | Trace complete event chain: dispatchers → observers → handler PHP classes (parses events.xml + vector search) |
435
+ | `magento_find_layout` | Find layout XML files by handle or content -- lists blocks, containers, and referenceBlock declarations |
433
436
 
434
437
  Auto-detects entry type from pattern (`/V1/...` → API, `snake_case` → event, `camelCase` → GraphQL, `path/segments` → route), or override with `entryType`. Use `depth: "shallow"` (entry + config + plugins) or `depth: "deep"` (adds observers, layout, templates, DI preferences).
435
438
 
439
+ ### Impact & Testing
440
+
441
+ | Tool | Description |
442
+ |------|-------------|
443
+ | `magento_impact_analysis` | Analyze impact of changing a class -- finds use statements, DI references, direct instantiations, and type hints across the codebase |
444
+ | `magento_find_test` | Find PHPUnit tests for a given class/method -- searches Test/ directories for coverage, mocks, and assertions |
445
+
446
+ ### Diagnostics
447
+
448
+ | Tool | Description |
449
+ |------|-------------|
450
+ | `magento_error_parser` | Parse Magento error messages and map to root cause, affected files, and fix suggestions (10 known patterns) |
451
+ | `magento_performance_profile` | Profile a Magento subsystem (checkout_totals, order_place, product_save, etc.) for performance bottlenecks -- plugins, observers, and complexity hotspots |
452
+
436
453
  ### Analysis Tools
437
454
 
438
455
  | Tool | Description |
@@ -449,6 +466,13 @@ Auto-detects entry type from pattern (`/V1/...` → API, `snake_case` → event,
449
466
  | `magento_describe` | Generate LLM descriptions for di.xml files (requires `ANTHROPIC_API_KEY`), stored in SQLite, auto-reindexes affected files |
450
467
  | `magento_stats` | View index statistics |
451
468
 
469
+ ### Search Enhancements (v2.1)
470
+
471
+ - **Hybrid BM25+vector search** -- combines text frequency scoring with semantic vector similarity for better exact class name matches
472
+ - **Query expansion** -- automatically expands queries with Magento domain synonyms (plugin → interceptor, checkout → cart/quote/totals, etc.)
473
+ - **Module filtering** -- `moduleFilter` parameter on `magento_search` to limit results by vendor/module pattern (supports wildcards, e.g., `"Vendor_*"`)
474
+ - **Non-blocking reindex** -- old index stays usable during background rebuild; new index is built to a temp path and swapped in atomically on completion
475
+
452
476
  ### Tool Cross-References
453
477
 
454
478
  Each tool description includes "See also" hints to help AI clients chain tools effectively:
@@ -476,6 +500,14 @@ graph LR
476
500
  trc -.-> tpl
477
501
  trc -.-> api
478
502
  trc -.-> gql
503
+ dep["trace_dependency"] --> prf
504
+ dep --> plg
505
+ evf["find_event_flow"] --> obs
506
+ imp["impact_analysis"] --> dep
507
+ imp --> cls
508
+ tst["find_test"] --> cls
509
+ err["error_parser"] --> dep
510
+ lay["find_layout"] --> blk
479
511
 
480
512
  style cls fill:#4a90d9,color:#fff
481
513
  style mtd fill:#4a90d9,color:#fff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "1.7.2",
3
+ "version": "2.1.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",
@@ -20,7 +20,9 @@
20
20
  "validate:verbose": "node src/cli.js validate --verbose",
21
21
  "validate:keep": "node src/cli.js validate --verbose --keep",
22
22
  "benchmark": "node src/cli.js benchmark",
23
- "test": "node tests/mcp-server.test.js",
23
+ "test": "node tests/unit.test.js && node tests/mcp-server.test.js",
24
+ "test:unit": "node tests/unit.test.js",
25
+ "test:integration": "node tests/mcp-server.test.js",
24
26
  "test:no-index": "node tests/mcp-server.test.js --no-index",
25
27
  "test:accuracy": "node tests/mcp-accuracy.test.js",
26
28
  "test:accuracy:verbose": "node tests/mcp-accuracy.test.js --verbose",
@@ -32,15 +34,15 @@
32
34
  "dependencies": {
33
35
  "@modelcontextprotocol/sdk": "^1.0.0",
34
36
  "chalk": "^5.3.0",
35
- "glob": "^10.3.10",
37
+ "glob": "^13.0.0",
36
38
  "ora": "^8.0.1",
37
39
  "ruvector": "^0.1.96"
38
40
  },
39
41
  "optionalDependencies": {
40
- "@magector/cli-darwin-arm64": "1.7.2",
41
- "@magector/cli-linux-x64": "1.7.2",
42
- "@magector/cli-linux-arm64": "1.7.2",
43
- "@magector/cli-win32-x64": "1.7.2"
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"
44
46
  },
45
47
  "keywords": [
46
48
  "magento",
package/src/cli.js CHANGED
@@ -257,20 +257,44 @@ async function main() {
257
257
 
258
258
  case 'index': {
259
259
  // First non-flag arg after `index` is the path; everything else is options.
260
+ // Must skip values belonging to flags (e.g., "4" in "--threads 4").
260
261
  const indexArgv = args.slice(1);
261
- const targetPath = indexArgv.find(a => !a.startsWith('-'));
262
262
  const indexOpts = parseArgs(indexArgv);
263
+ let targetPath = undefined;
264
+ for (let i = 0; i < indexArgv.length; i++) {
265
+ if (indexArgv[i] === '--threads' || indexArgv[i] === '--batch-size') {
266
+ i++; // skip the flag's value
267
+ } else if (indexArgv[i].startsWith('-')) {
268
+ // skip boolean flags like --force, --verbose
269
+ } else {
270
+ targetPath = indexArgv[i];
271
+ break; // first non-flag, non-value arg is the path
272
+ }
273
+ }
263
274
  await runIndex(targetPath, indexOpts);
264
275
  break;
265
276
  }
266
277
 
267
278
  case 'search': {
268
- const query = args.slice(1).filter(a => !a.startsWith('-')).join(' ');
279
+ // Build query from non-flag arguments, skipping values that belong to flags
280
+ const searchArgv = args.slice(1);
281
+ const queryParts = [];
282
+ for (let i = 0; i < searchArgv.length; i++) {
283
+ if (searchArgv[i] === '-l' || searchArgv[i] === '--limit' ||
284
+ searchArgv[i] === '-f' || searchArgv[i] === '--format') {
285
+ i++; // skip the flag's value
286
+ } else if (searchArgv[i].startsWith('-')) {
287
+ // skip boolean flags like -v, --verbose
288
+ } else {
289
+ queryParts.push(searchArgv[i]);
290
+ }
291
+ }
292
+ const query = queryParts.join(' ');
269
293
  if (!query) {
270
294
  console.error('Usage: npx magector search <query>');
271
295
  process.exit(1);
272
296
  }
273
- const opts = parseArgs(args.slice(1));
297
+ const opts = parseArgs(searchArgv);
274
298
  runSearch(query, opts);
275
299
  break;
276
300
  }