magector 2.16.2 → 2.16.3
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 +47 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.3",
|
|
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.16.
|
|
37
|
-
"@magector/cli-linux-x64": "2.16.
|
|
38
|
-
"@magector/cli-linux-arm64": "2.16.
|
|
39
|
-
"@magector/cli-win32-x64": "2.16.
|
|
36
|
+
"@magector/cli-darwin-arm64": "2.16.3",
|
|
37
|
+
"@magector/cli-linux-x64": "2.16.3",
|
|
38
|
+
"@magector/cli-linux-arm64": "2.16.3",
|
|
39
|
+
"@magector/cli-win32-x64": "2.16.3"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -817,6 +817,8 @@ function startServeProcess() {
|
|
|
817
817
|
// First line is ready signal
|
|
818
818
|
if (parsed.ready) {
|
|
819
819
|
serveReady = true;
|
|
820
|
+
// Clear stale cache entries — they may contain [] from when index was unavailable
|
|
821
|
+
searchCache.clear();
|
|
820
822
|
logToFile('INFO', `Serve process ready (PID ${proc.pid})`);
|
|
821
823
|
if (serveReadyResolve) { serveReadyResolve(true); serveReadyResolve = null; }
|
|
822
824
|
// Now that serve is up, persist primary lock state to data.db
|
|
@@ -952,6 +954,7 @@ function tryConnectSocket() {
|
|
|
952
954
|
|
|
953
955
|
isSocketClient = true;
|
|
954
956
|
serveReady = true;
|
|
957
|
+
searchCache.clear(); // clear stale [] entries from before socket was available
|
|
955
958
|
logToFile('INFO', 'Connected to existing serve process via socket proxy');
|
|
956
959
|
resolve(true);
|
|
957
960
|
});
|
|
@@ -4492,41 +4495,54 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
4492
4495
|
* Returns null when not re-indexing.
|
|
4493
4496
|
*/
|
|
4494
4497
|
function getReindexWarning() {
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4498
|
+
// Primary instance: use in-memory state (accurate phase + ETA)
|
|
4499
|
+
if (reindexInProgress && reindexStartTime) {
|
|
4500
|
+
const elapsedSec = Math.round((Date.now() - reindexStartTime) / 1000);
|
|
4501
|
+
const elapsedStr = elapsedSec >= 60
|
|
4502
|
+
? `${Math.floor(elapsedSec / 60)}m ${elapsedSec % 60}s`
|
|
4503
|
+
: `${elapsedSec}s`;
|
|
4504
|
+
|
|
4505
|
+
let phaseStr, etaStr;
|
|
4506
|
+
if (reindexPhase <= 0) {
|
|
4507
|
+
phaseStr = 'initializing';
|
|
4508
|
+
etaStr = 'est. ~40–70 min total';
|
|
4509
|
+
} else if (reindexPhase === 1) {
|
|
4510
|
+
const filesStr = reindexTotalFiles > 0 ? ` (${reindexTotalFiles.toLocaleString('en')} files)` : '';
|
|
4511
|
+
phaseStr = `phase 1/3: AST parsing${filesStr}`;
|
|
4512
|
+
etaStr = 'est. ~1–3 min for this phase, then ~40–60 min for embeddings';
|
|
4513
|
+
} else if (reindexPhase === 2) {
|
|
4514
|
+
const itemsStr = reindexItemsToEmbed > 0 ? ` (${reindexItemsToEmbed.toLocaleString('en')} items)` : '';
|
|
4515
|
+
phaseStr = `phase 2/3: generating embeddings${itemsStr}`;
|
|
4516
|
+
if (reindexPhase2Start && reindexItemsToEmbed > 0) {
|
|
4517
|
+
// Empirical rate: ~87k items ≈ 45 min on 8-core ONNX. Scale linearly.
|
|
4518
|
+
const estimatedTotalSec = Math.round((reindexItemsToEmbed / 87000) * 45 * 60);
|
|
4519
|
+
const phase2Elapsed = (Date.now() - reindexPhase2Start) / 1000;
|
|
4520
|
+
const remainingSec = Math.max(estimatedTotalSec - phase2Elapsed, 0);
|
|
4521
|
+
etaStr = remainingSec > 60
|
|
4522
|
+
? `est. ~${Math.round(remainingSec / 60)} min remaining`
|
|
4523
|
+
: 'almost done with embeddings';
|
|
4524
|
+
} else {
|
|
4525
|
+
etaStr = 'est. 30–60 min for this phase';
|
|
4526
|
+
}
|
|
4520
4527
|
} else {
|
|
4521
|
-
|
|
4528
|
+
phaseStr = 'phase 3/3: building HNSW vector index';
|
|
4529
|
+
etaStr = 'est. ~5–10 min remaining';
|
|
4522
4530
|
}
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4531
|
+
|
|
4532
|
+
return `> ⏳ **Re-indexing in progress** — ${elapsedStr} elapsed, ${phaseStr}. ${etaStr}.\n` +
|
|
4533
|
+
`> Results below use the **previous index** — valid, but may miss recently added files.\n\n`;
|
|
4526
4534
|
}
|
|
4527
4535
|
|
|
4528
|
-
|
|
4529
|
-
|
|
4536
|
+
// Secondary instance: detect via PID file (no phase info available)
|
|
4537
|
+
try {
|
|
4538
|
+
const externalPid = getRunningReindexPid();
|
|
4539
|
+
if (externalPid) {
|
|
4540
|
+
return `> ⏳ **Re-indexing in progress** (PID ${externalPid}) — semantic search may return empty results until complete.\n` +
|
|
4541
|
+
`> Grep and filesystem-based tools work normally. Check \`.magector/magector.log\` for progress.\n\n`;
|
|
4542
|
+
}
|
|
4543
|
+
} catch { /* ignore */ }
|
|
4544
|
+
|
|
4545
|
+
return null;
|
|
4530
4546
|
}
|
|
4531
4547
|
|
|
4532
4548
|
const _callToolHandler = async (request) => {
|