magector 1.7.1 → 1.7.2

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 CHANGED
@@ -347,6 +347,24 @@ For very large or CPU-constrained runs, you may also need to extend the wall-clo
347
347
  MAGECTOR_INDEX_TIMEOUT=28800000 npx magector index --threads 2 # 8 h timeout, 2 threads
348
348
  ```
349
349
 
350
+ ### Resume after timeout or interrupt
351
+
352
+ Indexing writes a crash-safe checkpoint to disk every 50 batches (~12,800 files). If the process is killed or times out mid-run, **just re-run `npx magector index`** — it auto-resumes from the last checkpoint:
353
+
354
+ ```bash
355
+ npx magector index
356
+ # ♻️ Resuming from previous run: 38400 vectors across 12200 files already indexed
357
+ # ✓ Found 79771 total files; 12200 already indexed, 67571 remaining to process
358
+ ```
359
+
360
+ The indexer collects already-embedded file paths from the existing DB, filters them out of file discovery, preserves the existing HNSW state, and only parses/embeds the files that aren't in the DB yet. Partial resume also picks up new files added to the tree since the previous run.
361
+
362
+ To force a full rebuild (e.g. after a schema change or if you want to discard stale vectors), pass `--force`:
363
+
364
+ ```bash
365
+ npx magector index --force
366
+ ```
367
+
350
368
  ---
351
369
 
352
370
  ## MCP Server Tools
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
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.7.1",
41
- "@magector/cli-linux-x64": "1.7.1",
42
- "@magector/cli-linux-arm64": "1.7.1",
43
- "@magector/cli-win32-x64": "1.7.1"
40
+ "@magector/cli-darwin-arm64": "1.7.2",
41
+ "@magector/cli-linux-x64": "1.7.2",
42
+ "@magector/cli-linux-arm64": "1.7.2",
43
+ "@magector/cli-win32-x64": "1.7.2"
44
44
  },
45
45
  "keywords": [
46
46
  "magento",
package/src/cli.js CHANGED
@@ -40,7 +40,9 @@ Index options:
40
40
  system responsive during indexing.
41
41
  --batch-size <n> Embedding batch size (default: 256). Higher = faster
42
42
  but more RAM.
43
- --force Force re-index even if index exists
43
+ --force Discard any existing index and rebuild from scratch.
44
+ Without --force, indexing auto-resumes from the last
45
+ incremental save (written every ~50 batches).
44
46
 
45
47
  Environment Variables:
46
48
  MAGENTO_ROOT Path to Magento installation (default: cwd)
@@ -122,6 +124,12 @@ async function runIndex(targetPath, opts = {}) {
122
124
  if (opts.batchSize != null) {
123
125
  indexArgs.push('--batch-size', String(opts.batchSize));
124
126
  }
127
+ // --force discards any existing partial index and rebuilds from scratch.
128
+ // Without it, the Rust indexer auto-resumes from the last incremental
129
+ // save on disk and only re-embeds files that aren't in the DB yet.
130
+ if (opts.force) {
131
+ indexArgs.push('--force');
132
+ }
125
133
  // Pass descriptions DB if it exists
126
134
  const descDbPath = path.resolve(root, '.magector', 'sqlite.db');
127
135
  if (existsSync(descDbPath)) {
@@ -137,10 +145,12 @@ async function runIndex(targetPath, opts = {}) {
137
145
  if (err.message && err.message.includes('ETIMEDOUT')) {
138
146
  console.error(
139
147
  `Indexing timed out after ${indexTimeout / 1000}s.\n` +
140
- `For large codebases or CPU-constrained environments, increase the timeout:\n` +
148
+ `Partial progress was saved to disk every ~50 batches — re-run\n` +
149
+ `'npx magector index' to auto-resume from the last checkpoint.\n` +
150
+ `\n` +
151
+ `For large codebases or CPU-constrained environments, also consider:\n` +
141
152
  ` MAGECTOR_INDEX_TIMEOUT=28800000 npx magector index # 8 hours\n` +
142
- `Or reduce CPU usage with fewer threads:\n` +
143
- ` npx magector index --threads 2`
153
+ ` npx magector index --threads 2 # lower CPU usage`
144
154
  );
145
155
  } else {
146
156
  console.error(`Indexing error: ${err.message}`);
package/src/init.js CHANGED
@@ -265,6 +265,9 @@ export async function init(projectPath, opts = {}) {
265
265
  if (opts.batchSize != null) {
266
266
  indexArgs.push('--batch-size', String(opts.batchSize));
267
267
  }
268
+ if (opts.force) {
269
+ indexArgs.push('--force');
270
+ }
268
271
  execFileSync(binary, indexArgs, { timeout: initTimeout, stdio: 'inherit' });
269
272
  } catch (err) {
270
273
  if (err.status) {
package/src/mcp-server.js CHANGED
@@ -552,13 +552,21 @@ function rustIndex(magentoRoot) {
552
552
  if (existsSync(descDbPath)) {
553
553
  indexArgs.push('--descriptions-db', descDbPath);
554
554
  }
555
- const indexTimeout = parseInt(process.env.MAGECTOR_INDEX_TIMEOUT, 10) || 1800000;
555
+ // Default 4 hours, matching cli.js/init.js. Previously 1800000 (30 min),
556
+ // which was too short for ~80K-file enterprise Magento installs under CPU
557
+ // constraint and caused silent re-index loops via the MCP auto-index path.
558
+ const indexTimeout = parseInt(process.env.MAGECTOR_INDEX_TIMEOUT, 10) || 14400000;
556
559
  try {
557
560
  const result = execFileSync(config.rustBinary, indexArgs, { encoding: 'utf-8', timeout: indexTimeout, stdio: ['pipe', 'pipe', 'pipe'], env: rustEnv });
558
561
  return result;
559
562
  } catch (err) {
560
563
  if (err.message && err.message.includes('ETIMEDOUT')) {
561
- throw new Error(`Indexing timed out after ${indexTimeout / 1000}s. Set MAGECTOR_INDEX_TIMEOUT=3600000 (or higher) in your environment to increase the limit.`);
564
+ throw new Error(
565
+ `Indexing timed out after ${indexTimeout / 1000}s. Partial progress was saved ` +
566
+ `to disk — the next indexing run will auto-resume from the last checkpoint. ` +
567
+ `To raise the timeout further, set MAGECTOR_INDEX_TIMEOUT (milliseconds) in the ` +
568
+ `MCP server env, e.g. MAGECTOR_INDEX_TIMEOUT=28800000 for 8 hours.`
569
+ );
562
570
  }
563
571
  throw err;
564
572
  }