grepmax 0.7.24 → 0.7.25
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/dist/commands/mcp.js
CHANGED
|
@@ -463,54 +463,37 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
463
463
|
_indexing = false;
|
|
464
464
|
_indexProgress = "";
|
|
465
465
|
_indexChildPid = null;
|
|
466
|
-
// Re-check if index now exists
|
|
467
|
-
try {
|
|
468
|
-
const db = getVectorDb();
|
|
469
|
-
if (yield db.hasRowsForPath(projectRoot)) {
|
|
470
|
-
_indexReady = true;
|
|
471
|
-
console.log("[MCP] Background indexing complete.");
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
catch (_b) { }
|
|
476
466
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
console.error(`[MCP] Background indexing failed (exit code: ${code})`);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
467
|
+
// Check project registry — more reliable than querying the DB.
|
|
468
|
+
// Avoids false negatives from lock contention and cascade re-indexing.
|
|
469
|
+
const projects = (0, project_registry_1.listProjects)();
|
|
470
|
+
const isRegistered = projects.some((p) => p.root === projectRoot);
|
|
471
|
+
if (isRegistered) {
|
|
472
|
+
_indexReady = true;
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// Truly first-time: no registry entry at all
|
|
476
|
+
if (_indexing)
|
|
477
|
+
return;
|
|
478
|
+
_indexing = true;
|
|
479
|
+
_indexProgress = "starting...";
|
|
480
|
+
console.log("[MCP] First-time index for this project...");
|
|
481
|
+
const child = (0, node_child_process_1.spawn)(process.argv[0], [process.argv[1], "index", "--path", projectRoot], { detached: true, stdio: "ignore" });
|
|
482
|
+
_indexChildPid = (_a = child.pid) !== null && _a !== void 0 ? _a : null;
|
|
483
|
+
child.unref();
|
|
484
|
+
_indexProgress = `PID ${_indexChildPid}`;
|
|
485
|
+
child.on("exit", (code) => {
|
|
486
|
+
_indexing = false;
|
|
487
|
+
_indexProgress = "";
|
|
488
|
+
_indexChildPid = null;
|
|
489
|
+
if (code === 0) {
|
|
490
|
+
_indexReady = true;
|
|
491
|
+
console.log("[MCP] First-time indexing complete.");
|
|
505
492
|
}
|
|
506
493
|
else {
|
|
507
|
-
console.
|
|
508
|
-
_indexReady = true;
|
|
494
|
+
console.error(`[MCP] Indexing failed (exit code: ${code})`);
|
|
509
495
|
}
|
|
510
|
-
}
|
|
511
|
-
catch (e) {
|
|
512
|
-
console.error("[MCP] Index sync failed:", e);
|
|
513
|
-
}
|
|
496
|
+
});
|
|
514
497
|
});
|
|
515
498
|
}
|
|
516
499
|
// --- Background watcher ---
|
|
@@ -575,7 +558,6 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
575
558
|
if (!query)
|
|
576
559
|
return err("Missing required parameter: query");
|
|
577
560
|
const limit = Math.min(Math.max(Number(args.limit) || 3, 1), 50);
|
|
578
|
-
yield ensureIndexReady();
|
|
579
561
|
ensureWatcher();
|
|
580
562
|
if (_indexing) {
|
|
581
563
|
return ok(`Indexing in progress (${_indexProgress}). Results may be incomplete or empty — try again shortly.`);
|
|
@@ -48,6 +48,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
48
48
|
const path = __importStar(require("node:path"));
|
|
49
49
|
const chokidar_1 = require("chokidar");
|
|
50
50
|
const filter_builder_1 = require("../utils/filter-builder");
|
|
51
|
+
const config_1 = require("../../config");
|
|
51
52
|
const file_utils_1 = require("../utils/file-utils");
|
|
52
53
|
const logger_1 = require("../utils/logger");
|
|
53
54
|
const lock_1 = require("../utils/lock");
|
|
@@ -135,8 +136,13 @@ function startWatcher(opts) {
|
|
|
135
136
|
const stats = yield fs.promises.stat(absPath);
|
|
136
137
|
if (!(0, file_utils_1.isIndexableFile)(absPath, stats.size))
|
|
137
138
|
continue;
|
|
138
|
-
//
|
|
139
|
+
// Quick mtime/size check — skip worker pool if unchanged
|
|
139
140
|
const cached = metaCache.get(absPath);
|
|
141
|
+
if (cached &&
|
|
142
|
+
cached.mtimeMs === stats.mtimeMs &&
|
|
143
|
+
cached.size === stats.size) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
140
146
|
const result = yield pool.processFile({
|
|
141
147
|
path: absPath,
|
|
142
148
|
absolutePath: absPath,
|
|
@@ -285,8 +291,12 @@ function startWatcher(opts) {
|
|
|
285
291
|
const onFileEvent = (event, absPath) => {
|
|
286
292
|
if (closed)
|
|
287
293
|
return;
|
|
288
|
-
if (event !== "unlink"
|
|
289
|
-
|
|
294
|
+
if (event !== "unlink") {
|
|
295
|
+
const ext = path.extname(absPath).toLowerCase();
|
|
296
|
+
const bn = path.basename(absPath).toLowerCase();
|
|
297
|
+
if (!config_1.INDEXABLE_EXTENSIONS.has(ext) && !config_1.INDEXABLE_EXTENSIONS.has(bn))
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
290
300
|
pending.set(absPath, event);
|
|
291
301
|
scheduleBatch();
|
|
292
302
|
};
|
package/package.json
CHANGED