magector 1.6.0 → 1.7.0
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 +2 -0
- package/package.json +5 -5
- package/src/mcp-server.js +34 -4
package/README.md
CHANGED
|
@@ -319,6 +319,8 @@ The `describe` command and `magento_describe` MCP tool require an Anthropic API
|
|
|
319
319
|
| `MAGECTOR_BIN` | Path to magector-core binary | Auto-detected |
|
|
320
320
|
| `MAGECTOR_MODELS` | Path to ONNX model directory | `~/.magector/models/` |
|
|
321
321
|
| `MAGECTOR_INDEX_TIMEOUT` | Indexing timeout in milliseconds | `1800000` (30 min) |
|
|
322
|
+
| `MAGECTOR_THREADS` | Max ONNX threads for embedding generation | Half of CPU cores |
|
|
323
|
+
| `MAGECTOR_BATCH_SIZE` | Embedding batch size (higher = faster, more RAM) | `256` |
|
|
322
324
|
| `ANTHROPIC_API_KEY` | API key for description generation (`describe` command) | — |
|
|
323
325
|
|
|
324
326
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Semantic code search for Magento 2 — index, search, MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/mcp-server.js",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"ruvector": "^0.1.96"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@magector/cli-darwin-arm64": "1.
|
|
41
|
-
"@magector/cli-linux-x64": "1.
|
|
42
|
-
"@magector/cli-linux-arm64": "1.
|
|
43
|
-
"@magector/cli-win32-x64": "1.
|
|
40
|
+
"@magector/cli-darwin-arm64": "1.7.0",
|
|
41
|
+
"@magector/cli-linux-x64": "1.7.0",
|
|
42
|
+
"@magector/cli-linux-arm64": "1.7.0",
|
|
43
|
+
"@magector/cli-win32-x64": "1.7.0"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"magento",
|
package/src/mcp-server.js
CHANGED
|
@@ -231,8 +231,17 @@ function startBackgroundReindex() {
|
|
|
231
231
|
|
|
232
232
|
reindexInProgress = true;
|
|
233
233
|
|
|
234
|
-
//
|
|
235
|
-
|
|
234
|
+
// Do NOT delete existing DB — the new indexer saves incrementally,
|
|
235
|
+
// so a partial index is better than no index. The Rust binary handles
|
|
236
|
+
// format incompatibility internally by clearing and rebuilding.
|
|
237
|
+
const hadExistingDb = existsSync(config.dbPath);
|
|
238
|
+
if (hadExistingDb) {
|
|
239
|
+
try {
|
|
240
|
+
const fstat = statSync(config.dbPath);
|
|
241
|
+
logToFile('WARN', `Existing DB (${(fstat.size / 1024).toFixed(0)} KB) will be overwritten by re-index.`);
|
|
242
|
+
} catch {}
|
|
243
|
+
try { unlinkSync(config.dbPath); } catch {}
|
|
244
|
+
}
|
|
236
245
|
|
|
237
246
|
logToFile('WARN', `Database format incompatible. Starting background re-index.`);
|
|
238
247
|
console.error(`Database format incompatible. Starting background re-index (log: ${LOG_PATH})`);
|
|
@@ -243,6 +252,11 @@ function startBackgroundReindex() {
|
|
|
243
252
|
'-d', config.dbPath,
|
|
244
253
|
'-c', config.modelCache
|
|
245
254
|
];
|
|
255
|
+
// Pass thread limit if configured
|
|
256
|
+
const threads = process.env.MAGECTOR_THREADS;
|
|
257
|
+
if (threads) {
|
|
258
|
+
reindexArgs.push('--threads', threads);
|
|
259
|
+
}
|
|
246
260
|
const bgDescDbPath = path.join(config.magentoRoot, '.magector', 'sqlite.db');
|
|
247
261
|
if (existsSync(bgDescDbPath)) {
|
|
248
262
|
reindexArgs.push('--descriptions-db', bgDescDbPath);
|
|
@@ -394,6 +408,11 @@ function startServeProcess() {
|
|
|
394
408
|
if (existsSync(descDbPath)) {
|
|
395
409
|
args.push('--descriptions-db', descDbPath);
|
|
396
410
|
}
|
|
411
|
+
// Pass thread limit if configured
|
|
412
|
+
const threads = process.env.MAGECTOR_THREADS;
|
|
413
|
+
if (threads) {
|
|
414
|
+
args.push('--threads', threads);
|
|
415
|
+
}
|
|
397
416
|
logToFile('INFO', `Starting serve process: ${config.rustBinary} ${args.join(' ')}`);
|
|
398
417
|
const proc = spawn(config.rustBinary, args,
|
|
399
418
|
{ stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
|
|
@@ -1971,8 +1990,19 @@ async function main() {
|
|
|
1971
1990
|
// Kill any orphaned serve process from a previous session
|
|
1972
1991
|
killStaleServeProcess();
|
|
1973
1992
|
|
|
1974
|
-
// Check database format compatibility before starting serve process
|
|
1975
|
-
|
|
1993
|
+
// Check database format compatibility before starting serve process.
|
|
1994
|
+
// With incremental saves, a partial but valid index should be kept — don't
|
|
1995
|
+
// force a full re-index just because the previous session didn't finish.
|
|
1996
|
+
if (existsSync(config.dbPath)) {
|
|
1997
|
+
if (!checkDbFormat()) {
|
|
1998
|
+
logToFile('WARN', 'Database format incompatible — scheduling background re-index');
|
|
1999
|
+
startBackgroundReindex();
|
|
2000
|
+
} else {
|
|
2001
|
+
logToFile('INFO', 'Existing database is compatible — reusing index');
|
|
2002
|
+
}
|
|
2003
|
+
} else if (config.magentoRoot && existsSync(config.magentoRoot)) {
|
|
2004
|
+
// No DB file at all — need initial index
|
|
2005
|
+
logToFile('INFO', 'No index database found — scheduling background index');
|
|
1976
2006
|
startBackgroundReindex();
|
|
1977
2007
|
}
|
|
1978
2008
|
|