grepmax 0.7.3 → 0.7.4

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.
@@ -304,10 +304,39 @@ exports.mcp = new commander_1.Command("mcp")
304
304
  });
305
305
  }
306
306
  // --- Index sync ---
307
+ let _indexChildPid = null;
308
+ function isIndexProcessRunning() {
309
+ if (!_indexChildPid)
310
+ return false;
311
+ try {
312
+ process.kill(_indexChildPid, 0);
313
+ return true;
314
+ }
315
+ catch (_a) {
316
+ return false;
317
+ }
318
+ }
307
319
  function ensureIndexReady() {
308
320
  return __awaiter(this, void 0, void 0, function* () {
321
+ var _a;
309
322
  if (_indexReady)
310
323
  return;
324
+ // Check if a previously spawned index process finished
325
+ if (_indexing && !isIndexProcessRunning()) {
326
+ _indexing = false;
327
+ _indexProgress = "";
328
+ _indexChildPid = null;
329
+ // Re-check if index now exists
330
+ try {
331
+ const db = getVectorDb();
332
+ if (yield db.hasRowsForPath(projectRoot)) {
333
+ _indexReady = true;
334
+ console.log("[MCP] Background indexing complete.");
335
+ return;
336
+ }
337
+ }
338
+ catch (_b) { }
339
+ }
311
340
  try {
312
341
  const db = getVectorDb();
313
342
  const hasIndex = yield db.hasRowsForPath(projectRoot);
@@ -316,23 +345,25 @@ exports.mcp = new commander_1.Command("mcp")
316
345
  return; // Already indexing in background
317
346
  _indexing = true;
318
347
  _indexProgress = "starting...";
319
- console.log("[MCP] No index found, running initial sync...");
320
- (0, syncer_1.initialSync)({
321
- projectRoot,
322
- onProgress: (info) => {
323
- _indexProgress = `${info.processed}/${info.total || "?"} files`;
324
- },
325
- })
326
- .then(() => {
327
- _indexReady = true;
328
- _indexing = false;
329
- _indexProgress = "";
330
- console.log("[MCP] Initial sync complete.");
331
- })
332
- .catch((e) => {
348
+ console.log("[MCP] No index found, spawning background index...");
349
+ // Spawn gmax index as a detached child process — doesn't hold
350
+ // the lock inside this MCP process, so CLI `gmax index` won't conflict.
351
+ const child = (0, node_child_process_1.spawn)(process.argv[0], [process.argv[1], "index", "--path", projectRoot], { detached: true, stdio: "ignore" });
352
+ _indexChildPid = (_a = child.pid) !== null && _a !== void 0 ? _a : null;
353
+ child.unref();
354
+ _indexProgress = `PID ${_indexChildPid}`;
355
+ console.log(`[MCP] Background index started (PID: ${_indexChildPid})`);
356
+ child.on("exit", (code) => {
333
357
  _indexing = false;
334
358
  _indexProgress = "";
335
- console.error("[MCP] Index sync failed:", e);
359
+ _indexChildPid = null;
360
+ if (code === 0) {
361
+ _indexReady = true;
362
+ console.log("[MCP] Background indexing complete.");
363
+ }
364
+ else {
365
+ console.error(`[MCP] Background indexing failed (exit code: ${code})`);
366
+ }
336
367
  });
337
368
  }
338
369
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "author": "Robert Owens <robowens@me.com>",
5
5
  "homepage": "https://github.com/reowens/grepmax",
6
6
  "bugs": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Semantic code search for Claude Code. Automatically indexes your project and provides intelligent search capabilities.",
5
5
  "author": {
6
6
  "name": "Robert Owens",