grepmax 0.15.5 → 0.15.6

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.
@@ -53,7 +53,6 @@ exports.mcp = void 0;
53
53
  exports.toStringArray = toStringArray;
54
54
  exports.ok = ok;
55
55
  exports.err = err;
56
- const node_child_process_1 = require("node:child_process");
57
56
  const fs = __importStar(require("node:fs"));
58
57
  const path = __importStar(require("node:path"));
59
58
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
@@ -363,8 +362,6 @@ exports.mcp = new commander_1.Command("mcp")
363
362
  let _searcher = null;
364
363
  let _skeletonizer = null;
365
364
  let _indexReady = false;
366
- let _indexing = false;
367
- let _indexProgress = "";
368
365
  const cleanup = () => __awaiter(void 0, void 0, void 0, function* () {
369
366
  if (_vectorDb) {
370
367
  try {
@@ -421,70 +418,15 @@ exports.mcp = new commander_1.Command("mcp")
421
418
  });
422
419
  }
423
420
  // --- Index sync ---
424
- let _indexChildPid = null;
425
- function isIndexProcessRunning() {
426
- if (!_indexChildPid)
427
- return false;
428
- try {
429
- process.kill(_indexChildPid, 0);
430
- return true;
431
- }
432
- catch (_a) {
433
- return false;
434
- }
435
- }
436
421
  function ensureIndexReady() {
437
422
  return __awaiter(this, void 0, void 0, function* () {
438
- var _a;
439
423
  if (_indexReady)
440
424
  return;
441
- // Check if a previously spawned index process finished
442
- if (_indexing && !isIndexProcessRunning()) {
443
- _indexing = false;
444
- _indexProgress = "";
445
- _indexChildPid = null;
446
- }
447
- // Check project registry — more reliable than querying the DB.
448
- // Avoids false negatives from lock contention and cascade re-indexing.
449
425
  const projects = (0, project_registry_1.listProjects)();
450
426
  const isRegistered = projects.some((p) => p.root === projectRoot);
451
427
  if (isRegistered) {
452
428
  _indexReady = true;
453
- return;
454
429
  }
455
- // Truly first-time: no registry entry at all
456
- if (_indexing)
457
- return;
458
- _indexing = true;
459
- _indexProgress = "starting...";
460
- console.log("[MCP] First-time setup for this project...");
461
- const child = (0, node_child_process_1.spawn)(process.argv[0], [process.argv[1], "add", projectRoot], { detached: true, stdio: "ignore" });
462
- _indexChildPid = (_a = child.pid) !== null && _a !== void 0 ? _a : null;
463
- child.unref();
464
- _indexProgress = `PID ${_indexChildPid}`;
465
- const indexTimeout = setTimeout(() => {
466
- try {
467
- child.kill("SIGKILL");
468
- }
469
- catch (_a) { }
470
- _indexing = false;
471
- _indexProgress = "";
472
- _indexChildPid = null;
473
- console.error("[MCP] Background indexing timed out after 30 minutes");
474
- }, 30 * 60 * 1000);
475
- child.on("exit", (code) => {
476
- clearTimeout(indexTimeout);
477
- _indexing = false;
478
- _indexProgress = "";
479
- _indexChildPid = null;
480
- if (code === 0) {
481
- _indexReady = true;
482
- console.log("[MCP] First-time setup complete.");
483
- }
484
- else {
485
- console.error(`[MCP] Indexing failed (exit code: ${code})`);
486
- }
487
- });
488
430
  });
489
431
  }
490
432
  // --- Background watcher ---
@@ -511,12 +453,11 @@ exports.mcp = new commander_1.Command("mcp")
511
453
  const searchAll = isSearchAll || args.scope === "all";
512
454
  const limit = Math.min(Math.max(Number(args.limit) || 3, 1), 50);
513
455
  ensureWatcher();
514
- if (_indexing) {
515
- return ok(`Indexing in progress (${_indexProgress}). Results may be incomplete or empty — try again shortly.`);
516
- }
517
- // Check if project is pending or has no chunks
518
456
  const proj = (0, project_registry_1.getProject)(projectRoot);
519
- if ((proj === null || proj === void 0 ? void 0 : proj.status) === "pending" || (proj && proj.chunkCount === 0)) {
457
+ if (!proj) {
458
+ return err("Project not added to gmax yet. Run `gmax add` to index it first.");
459
+ }
460
+ if (proj.status === "pending" || proj.chunkCount === 0) {
520
461
  return err("Project not indexed yet. Run `gmax add` to index it first.");
521
462
  }
522
463
  try {
@@ -875,8 +816,9 @@ exports.mcp = new commander_1.Command("mcp")
875
816
  const symbol = String(args.symbol || "");
876
817
  if (!symbol)
877
818
  return err("Missing required parameter: symbol");
878
- if (_indexing) {
879
- return ok(`Indexing in progress (${_indexProgress}). trace_calls requires a complete index — try again shortly.`);
819
+ const proj = (0, project_registry_1.getProject)(projectRoot);
820
+ if (!proj) {
821
+ return err("Project not added to gmax yet. Run `gmax add` to index it first.");
880
822
  }
881
823
  try {
882
824
  const db = getVectorDb();
@@ -1177,8 +1119,9 @@ exports.mcp = new commander_1.Command("mcp")
1177
1119
  const pattern = typeof args.pattern === "string" ? args.pattern : undefined;
1178
1120
  const limit = Math.min(Math.max(Number(args.limit) || 20, 1), 100);
1179
1121
  const pathPrefix = typeof args.path === "string" ? args.path : undefined;
1180
- if (_indexing) {
1181
- return ok(`Indexing in progress (${_indexProgress}). list_symbols requires a complete index — try again shortly.`);
1122
+ const proj = (0, project_registry_1.getProject)(projectRoot);
1123
+ if (!proj) {
1124
+ return err("Project not added to gmax yet. Run `gmax add` to index it first.");
1182
1125
  }
1183
1126
  try {
1184
1127
  const db = getVectorDb();
@@ -1273,9 +1216,6 @@ exports.mcp = new commander_1.Command("mcp")
1273
1216
  watcherLine += " — search results may be incomplete";
1274
1217
  }
1275
1218
  }
1276
- const indexingLine = _indexing
1277
- ? `Indexing: in progress (${_indexProgress})`
1278
- : "";
1279
1219
  const lines = [
1280
1220
  `Index: ~/.gmax/lancedb (${stats.chunks} chunks, ${fileCount} files)`,
1281
1221
  `Model: ${globalConfig.embedMode === "gpu" ? ((_d = (_c = (_b = config_1.MODEL_TIERS[globalConfig.modelTier]) === null || _b === void 0 ? void 0 : _b.mlxModel) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config.embedModel) !== null && _d !== void 0 ? _d : "unknown") : ((_e = config === null || config === void 0 ? void 0 : config.embedModel) !== null && _e !== void 0 ? _e : "unknown")} (${(_f = config === null || config === void 0 ? void 0 : config.vectorDim) !== null && _f !== void 0 ? _f : "?"}d, ${globalConfig.embedMode})`,
@@ -1283,7 +1223,6 @@ exports.mcp = new commander_1.Command("mcp")
1283
1223
  ? `Last indexed: ${config.indexedAt}`
1284
1224
  : "",
1285
1225
  watcherLine,
1286
- indexingLine,
1287
1226
  "",
1288
1227
  "Indexed directories:",
1289
1228
  ...(yield Promise.all(projects.map((p) => __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.15.5",
3
+ "version": "0.15.6",
4
4
  "author": "Robert Owens <78518764+reowens@users.noreply.github.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.15.5",
3
+ "version": "0.15.6",
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",
@@ -1,6 +1,6 @@
1
1
  const fs = require("node:fs");
2
2
  const _path = require("node:path");
3
- const { spawn, execFileSync } = require("node:child_process");
3
+ const { execFileSync } = require("node:child_process");
4
4
 
5
5
  function readStdin() {
6
6
  return new Promise((resolve) => {
@@ -34,51 +34,19 @@ function isProjectRegistered(dir) {
34
34
  }
35
35
  }
36
36
 
37
- function isGitRepo(dir) {
38
- try {
39
- // Walk up to find .git (handles worktrees and nested repos)
40
- let current = dir;
41
- while (current !== _path.dirname(current)) {
42
- if (fs.existsSync(_path.join(current, ".git"))) return true;
43
- current = _path.dirname(current);
44
- }
45
- return false;
46
- } catch {
47
- return false;
48
- }
49
- }
50
-
51
37
  async function main() {
52
38
  const input = await readStdin();
53
39
  const newCwd = input.new_cwd || process.cwd();
54
40
 
55
- // Already indexed — nothing to do
56
- if (isProjectRegistered(newCwd)) return;
57
-
58
- // Only auto-add git repos
59
- if (!isGitRepo(newCwd)) return;
41
+ if (!isProjectRegistered(newCwd)) return;
60
42
 
61
- // Spawn `gmax add` fully detached so it doesn't block the hook timeout
62
43
  try {
63
- const child = spawn("gmax", ["add", newCwd], {
64
- detached: true,
65
- stdio: "ignore",
66
- });
67
- child.unref();
44
+ execFileSync("gmax", ["watch", "--daemon", "-b"], { timeout: 5000, stdio: "ignore" });
68
45
  } catch {
69
- // gmax not in PATH or spawn failed — silently ignore
70
- return;
46
+ try {
47
+ execFileSync("gmax", ["watch", "-b"], { timeout: 5000, stdio: "ignore" });
48
+ } catch {}
71
49
  }
72
-
73
- // Tell Claude that indexing is starting
74
- const dirName = _path.basename(newCwd);
75
- const response = {
76
- hookSpecificOutput: {
77
- hookEventName: "CwdChanged",
78
- additionalContext: `gmax: indexing "${dirName}" in background. Search results may be incomplete until indexing finishes. Run Bash(gmax status) to check progress.`,
79
- },
80
- };
81
- process.stdout.write(JSON.stringify(response));
82
50
  }
83
51
 
84
52
  main();