magector 2.1.8 → 2.1.9
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 +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
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.9",
|
|
43
|
+
"@magector/cli-linux-x64": "2.1.9",
|
|
44
|
+
"@magector/cli-linux-arm64": "2.1.9",
|
|
45
|
+
"@magector/cli-win32-x64": "2.1.9"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -228,22 +228,27 @@ let reindexProcess = null;
|
|
|
228
228
|
/**
|
|
229
229
|
* Check if the database file is compatible with the current binary.
|
|
230
230
|
* Returns true if OK, false if format mismatch (file has data but binary reads 0 vectors).
|
|
231
|
+
* Async to avoid blocking the event loop — stats loads the HNSW graph which can
|
|
232
|
+
* take 30-60s for large indexes (80k+ vectors).
|
|
231
233
|
*/
|
|
232
|
-
function checkDbFormat() {
|
|
234
|
+
async function checkDbFormat() {
|
|
233
235
|
if (!existsSync(config.dbPath)) return true;
|
|
234
236
|
|
|
235
237
|
try {
|
|
236
|
-
// Check if file is non-trivial (has actual index data)
|
|
237
238
|
const fstat = statSync(config.dbPath);
|
|
238
239
|
if (fstat.size < 100) return true; // Tiny file = likely empty/new
|
|
239
240
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
const result = await new Promise((resolve, reject) => {
|
|
242
|
+
const proc = spawn(config.rustBinary, ['stats', '-d', config.dbPath],
|
|
243
|
+
{ stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
|
|
244
|
+
let stdout = '';
|
|
245
|
+
proc.stdout.on('data', (d) => { stdout += d.toString(); });
|
|
246
|
+
proc.on('error', reject);
|
|
247
|
+
proc.on('exit', (code) => code === 0 ? resolve(stdout) : reject(new Error(`stats exit ${code}`)));
|
|
248
|
+
setTimeout(() => { try { proc.kill(); } catch {} reject(new Error('stats timeout')); }, 120000);
|
|
249
|
+
});
|
|
244
250
|
|
|
245
251
|
const vectors = parseInt(result.match(/Total vectors:\s*(\d+)/)?.[1] || '0');
|
|
246
|
-
// File has real data but binary sees 0 vectors → format incompatible
|
|
247
252
|
return vectors > 0;
|
|
248
253
|
} catch {
|
|
249
254
|
return false;
|
|
@@ -3219,7 +3224,7 @@ async function main() {
|
|
|
3219
3224
|
// With incremental saves, a partial but valid index should be kept — don't
|
|
3220
3225
|
// force a full re-index just because the previous session didn't finish.
|
|
3221
3226
|
if (existsSync(config.dbPath)) {
|
|
3222
|
-
if (!checkDbFormat()) {
|
|
3227
|
+
if (!(await checkDbFormat())) {
|
|
3223
3228
|
logToFile('WARN', 'Database format incompatible — scheduling background re-index');
|
|
3224
3229
|
startBackgroundReindex();
|
|
3225
3230
|
} else {
|