magector 2.1.3 → 2.1.5
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 +29 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Semantic code search for Magento 2 — index, search, MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/mcp-server.js",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"ruvector": "^0.1.96"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@magector/cli-darwin-arm64": "2.1.
|
|
43
|
-
"@magector/cli-linux-x64": "2.1.
|
|
44
|
-
"@magector/cli-linux-arm64": "2.1.
|
|
45
|
-
"@magector/cli-win32-x64": "2.1.
|
|
42
|
+
"@magector/cli-darwin-arm64": "2.1.5",
|
|
43
|
+
"@magector/cli-linux-x64": "2.1.5",
|
|
44
|
+
"@magector/cli-linux-arm64": "2.1.5",
|
|
45
|
+
"@magector/cli-win32-x64": "2.1.5"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -81,8 +81,8 @@ function logToFile(level, message) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// Initialize log
|
|
85
|
-
try {
|
|
84
|
+
// Initialize log on startup — append to preserve history across MCP restarts
|
|
85
|
+
try { appendFileSync(LOG_PATH, `\n[${new Date().toISOString()}] [INFO] ════ Magector MCP server starting ════\n`); } catch {}
|
|
86
86
|
|
|
87
87
|
// Log resolved configuration so the log file is self-contained for debugging
|
|
88
88
|
logToFile('INFO', `Config: MAGENTO_ROOT=${config.magentoRoot}`);
|
|
@@ -264,11 +264,28 @@ function startBackgroundReindex() {
|
|
|
264
264
|
console.error(`Reindex already running (PID ${existingPid}) — skipping`);
|
|
265
265
|
reindexInProgress = true; // mark locally so tools know
|
|
266
266
|
// Poll the external process and react when it finishes
|
|
267
|
+
const tempDbPath = config.dbPath + '.new';
|
|
267
268
|
const pollInterval = setInterval(() => {
|
|
268
269
|
if (!getRunningReindexPid()) {
|
|
269
270
|
clearInterval(pollInterval);
|
|
270
271
|
reindexInProgress = false;
|
|
271
|
-
|
|
272
|
+
// Swap the new DB into place if the external reindex produced one
|
|
273
|
+
if (existsSync(tempDbPath)) {
|
|
274
|
+
try {
|
|
275
|
+
if (existsSync(config.dbPath)) {
|
|
276
|
+
const backupPath = config.dbPath + '.bak';
|
|
277
|
+
if (existsSync(backupPath)) { try { unlinkSync(backupPath); } catch {} }
|
|
278
|
+
renameSync(config.dbPath, backupPath);
|
|
279
|
+
logToFile('INFO', 'Old DB moved to .bak');
|
|
280
|
+
}
|
|
281
|
+
renameSync(tempDbPath, config.dbPath);
|
|
282
|
+
logToFile('INFO', 'External reindex complete — new index swapped into place.');
|
|
283
|
+
} catch (e) {
|
|
284
|
+
logToFile('ERR', `Failed to swap index after external reindex: ${e.message}`);
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
logToFile('INFO', 'External reindex finished but no .new file found — skipping swap.');
|
|
288
|
+
}
|
|
272
289
|
if (serveProcess) serveProcess.kill();
|
|
273
290
|
searchCache.clear();
|
|
274
291
|
startServeProcess();
|
|
@@ -320,12 +337,17 @@ function startBackgroundReindex() {
|
|
|
320
337
|
// Write PID file so other MCP instances know a reindex is running
|
|
321
338
|
writeReindexPidFile(reindexProcess.pid);
|
|
322
339
|
|
|
323
|
-
|
|
324
|
-
|
|
340
|
+
// Log stdout/stderr line-by-line using readline to avoid buffering issues.
|
|
341
|
+
// Without this, Rust tracing output accumulates in pipe buffers and progress
|
|
342
|
+
// entries arrive in large chunks instead of in real time.
|
|
343
|
+
const indexStdout = createInterface({ input: reindexProcess.stdout });
|
|
344
|
+
const indexStderr = createInterface({ input: reindexProcess.stderr });
|
|
345
|
+
indexStdout.on('line', (line) => {
|
|
346
|
+
const text = line.replace(/\x1b\[[0-9;]*m/g, '').trim();
|
|
325
347
|
if (text) logToFile('INDEX', text);
|
|
326
348
|
});
|
|
327
|
-
|
|
328
|
-
const text =
|
|
349
|
+
indexStderr.on('line', (line) => {
|
|
350
|
+
const text = line.replace(/\x1b\[[0-9;]*m/g, '').trim();
|
|
329
351
|
if (text) logToFile('INDEX', text);
|
|
330
352
|
});
|
|
331
353
|
|