magector 2.1.4 → 2.1.6
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 +20 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
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.6",
|
|
43
|
+
"@magector/cli-linux-x64": "2.1.6",
|
|
44
|
+
"@magector/cli-linux-arm64": "2.1.6",
|
|
45
|
+
"@magector/cli-win32-x64": "2.1.6"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -237,9 +237,10 @@ function checkDbFormat() {
|
|
|
237
237
|
const fstat = statSync(config.dbPath);
|
|
238
238
|
if (fstat.size < 100) return true; // Tiny file = likely empty/new
|
|
239
239
|
|
|
240
|
+
// stats loads the HNSW graph which can take 30-60s for large indexes (80k+ vectors)
|
|
240
241
|
const result = execFileSync(config.rustBinary, [
|
|
241
242
|
'stats', '-d', config.dbPath
|
|
242
|
-
], { encoding: 'utf-8', timeout:
|
|
243
|
+
], { encoding: 'utf-8', timeout: 120000, stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
|
|
243
244
|
|
|
244
245
|
const vectors = parseInt(result.match(/Total vectors:\s*(\d+)/)?.[1] || '0');
|
|
245
246
|
// File has real data but binary sees 0 vectors → format incompatible
|
|
@@ -264,11 +265,28 @@ function startBackgroundReindex() {
|
|
|
264
265
|
console.error(`Reindex already running (PID ${existingPid}) — skipping`);
|
|
265
266
|
reindexInProgress = true; // mark locally so tools know
|
|
266
267
|
// Poll the external process and react when it finishes
|
|
268
|
+
const tempDbPath = config.dbPath + '.new';
|
|
267
269
|
const pollInterval = setInterval(() => {
|
|
268
270
|
if (!getRunningReindexPid()) {
|
|
269
271
|
clearInterval(pollInterval);
|
|
270
272
|
reindexInProgress = false;
|
|
271
|
-
|
|
273
|
+
// Swap the new DB into place if the external reindex produced one
|
|
274
|
+
if (existsSync(tempDbPath)) {
|
|
275
|
+
try {
|
|
276
|
+
if (existsSync(config.dbPath)) {
|
|
277
|
+
const backupPath = config.dbPath + '.bak';
|
|
278
|
+
if (existsSync(backupPath)) { try { unlinkSync(backupPath); } catch {} }
|
|
279
|
+
renameSync(config.dbPath, backupPath);
|
|
280
|
+
logToFile('INFO', 'Old DB moved to .bak');
|
|
281
|
+
}
|
|
282
|
+
renameSync(tempDbPath, config.dbPath);
|
|
283
|
+
logToFile('INFO', 'External reindex complete — new index swapped into place.');
|
|
284
|
+
} catch (e) {
|
|
285
|
+
logToFile('ERR', `Failed to swap index after external reindex: ${e.message}`);
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
logToFile('INFO', 'External reindex finished but no .new file found — skipping swap.');
|
|
289
|
+
}
|
|
272
290
|
if (serveProcess) serveProcess.kill();
|
|
273
291
|
searchCache.clear();
|
|
274
292
|
startServeProcess();
|