magector 2.14.0 → 2.14.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.
package/README.md CHANGED
@@ -1204,6 +1204,67 @@ gantt
1204
1204
 
1205
1205
  ---
1206
1206
 
1207
+ ## Troubleshooting
1208
+
1209
+ All MCP server activity is logged to `.magector/magector.log` in the Magento project root. The log persists across MCP restarts and uses the format:
1210
+
1211
+ ```
1212
+ [2026-04-12T18:30:00.000Z] [LEVEL] message
1213
+ ```
1214
+
1215
+ ### Log Levels
1216
+
1217
+ | Level | Meaning |
1218
+ |-------|---------|
1219
+ | `INFO` | Normal operations: startup config, tool completion, search fallbacks, enrichment progress |
1220
+ | `WARN` | Recoverable issues: slow grep queries (>5s), missing enrichment.db, file read errors, serve process disconnects |
1221
+ | `ERR` | Failures: semgrep crashes, transaction rollbacks, serve process errors, tool execution errors |
1222
+ | `REQ` | Every tool call with full input parameters (JSON) |
1223
+ | `RES` | Tool completion with elapsed time in milliseconds |
1224
+ | `QUERY` | Rust serve process queries (search, feedback) |
1225
+ | `CACHE` | Search cache hits |
1226
+ | `INDEX` | Background reindex progress |
1227
+ | `SERVE` | Rust serve process stderr (watcher events, model loading) |
1228
+ | `FATAL` | Server startup failures |
1229
+
1230
+ ### Common Diagnostic Commands
1231
+
1232
+ ```bash
1233
+ # Recent errors
1234
+ grep '\[ERR\]\|\[FATAL\]' .magector/magector.log | tail -20
1235
+
1236
+ # Tool timing (find slow tools)
1237
+ grep '\[RES\]' .magector/magector.log | tail -20
1238
+
1239
+ # Enrichment/null-risk analysis
1240
+ grep 'enrich:\|null_risks:' .magector/magector.log | tail -20
1241
+
1242
+ # AST search (semgrep) issues
1243
+ grep 'ast_search:' .magector/magector.log | tail -20
1244
+
1245
+ # Batch query breakdown (per-tool timing)
1246
+ grep 'batch\[' .magector/magector.log | tail -20
1247
+
1248
+ # Slow grep queries
1249
+ grep 'grep: slow\|grep: timed' .magector/magento.log | tail -20
1250
+
1251
+ # Full startup sequence
1252
+ grep 'server starting\|Config:\|primary\|Serve process' .magector/magector.log | tail -30
1253
+ ```
1254
+
1255
+ ### What Gets Logged (v2.14+)
1256
+
1257
+ Every tool call logs `[REQ]` with input parameters and `[RES]` with elapsed time. Additionally:
1258
+
1259
+ - **`magento_ast_search`** — semgrep pattern, target path, execution time, result count, semgrep errors
1260
+ - **`magento_enrich`** — file count, progress every 10k files, read errors, transaction failures, final summary
1261
+ - **`magento_find_null_risks`** — query parameters, result count, query timing, missing DB warnings
1262
+ - **`magento_batch`** — query list on entry, per-sub-tool timing and errors
1263
+ - **`magento_grep`** — slow query warnings (>5s), timeout detection
1264
+ - **`magento_read`** — file-not-found with error codes, failed method extractions
1265
+
1266
+ ---
1267
+
1207
1268
  ## License
1208
1269
 
1209
1270
  MIT License. See [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "2.14.0",
3
+ "version": "2.14.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.14.0",
37
- "@magector/cli-linux-x64": "2.14.0",
38
- "@magector/cli-linux-arm64": "2.14.0",
39
- "@magector/cli-win32-x64": "2.14.0"
36
+ "@magector/cli-darwin-arm64": "2.14.1",
37
+ "@magector/cli-linux-x64": "2.14.1",
38
+ "@magector/cli-linux-arm64": "2.14.1",
39
+ "@magector/cli-win32-x64": "2.14.1"
40
40
  },
41
41
  "keywords": [
42
42
  "magento",
package/src/mcp-server.js CHANGED
@@ -149,6 +149,44 @@ const SOCK_PATH = path.join(config.magentoRoot, '.magector', 'serve.sock');
149
149
  const FORMAT_CACHE_PATH = path.join(config.magentoRoot, '.magector', 'format-ok.json');
150
150
  const PRIMARY_LOCK_PATH = path.join(config.magentoRoot, '.magector', 'primary.lock');
151
151
 
152
+ /**
153
+ * Expand brace patterns in include globs for GNU grep compatibility.
154
+ * GNU grep --include does NOT support brace expansion (that's a shell feature).
155
+ * Transforms "*.{php,xml,graphqls}" → ["*.php", "*.xml", "*.graphqls"]
156
+ * Also handles comma-separated patterns: "*.php, *.xml" → ["*.php", "*.xml"]
157
+ * And mixed: "*.{php,xml}, *.phtml" → ["*.php", "*.xml", "*.phtml"]
158
+ */
159
+ function expandIncludePattern(include) {
160
+ // Split on commas NOT inside braces
161
+ const parts = [];
162
+ let depth = 0, current = '';
163
+ for (const ch of include) {
164
+ if (ch === '{') depth++;
165
+ if (ch === '}') depth--;
166
+ if (ch === ',' && depth === 0) {
167
+ parts.push(current.trim());
168
+ current = '';
169
+ } else {
170
+ current += ch;
171
+ }
172
+ }
173
+ if (current.trim()) parts.push(current.trim());
174
+ // Expand brace patterns in each part
175
+ const patterns = [];
176
+ const braceRegex = /^(.*?)\{([^}]+)\}(.*)$/;
177
+ for (const part of parts) {
178
+ const m = part.match(braceRegex);
179
+ if (m) {
180
+ for (const alt of m[2].split(',').map(a => a.trim())) {
181
+ patterns.push(m[1] + alt + m[3]);
182
+ }
183
+ } else {
184
+ patterns.push(part);
185
+ }
186
+ }
187
+ return patterns;
188
+ }
189
+
152
190
  /**
153
191
  * Try to acquire the primary lock (O_EXCL = atomic create-or-fail).
154
192
  * Returns true if we are the primary instance, false if another instance holds the lock.
@@ -6421,7 +6459,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
6421
6459
  const gArgs = batchFilesOnly ? ['-rl', '-E'] : ['-rn', '-E'];
6422
6460
  if (a.ignoreCase) gArgs.push('-i');
6423
6461
  if (!batchFilesOnly && batchCtx > 0) gArgs.push('-C', String(batchCtx));
6424
- for (const pat of include.split(',').map(p => p.trim())) gArgs.push('--include=' + pat);
6462
+ for (const pat of expandIncludePattern(include)) gArgs.push('--include=' + pat);
6425
6463
  gArgs.push('--', a.pattern, searchPath);
6426
6464
  let out;
6427
6465
  try {
@@ -6489,8 +6527,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
6489
6527
  const grepArgs = filesOnly ? ['-rl', '-E'] : ['-rn', '-E'];
6490
6528
  if (args.ignoreCase) grepArgs.push('-i');
6491
6529
  if (!filesOnly && ctxLines > 0) grepArgs.push('-C', String(ctxLines));
6492
- // Support multiple include patterns (e.g., "*.{php,xml}")
6493
- for (const pat of include.split(',').map(p => p.trim())) {
6530
+ for (const pat of expandIncludePattern(include)) {
6494
6531
  grepArgs.push('--include=' + pat);
6495
6532
  }
6496
6533
  grepArgs.push('--', args.pattern, searchPath);