grepmax 0.7.26 → 0.7.27
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 +6 -84
- package/dist/commands/recent.js +2 -14
- package/dist/lib/index/watcher.js +2 -3
- package/dist/lib/skeleton/symbol-extractor.js +29 -0
- package/dist/lib/utils/cache-check.js +8 -0
- package/dist/lib/utils/format-helpers.js +16 -0
- package/dist/lib/utils/import-extractor.js +83 -0
- package/package.json +1 -1
- package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
package/dist/commands/mcp.js
CHANGED
|
@@ -67,10 +67,13 @@ const syncer_1 = require("../lib/index/syncer");
|
|
|
67
67
|
const meta_cache_1 = require("../lib/store/meta-cache");
|
|
68
68
|
const searcher_1 = require("../lib/search/searcher");
|
|
69
69
|
const retriever_1 = require("../lib/skeleton/retriever");
|
|
70
|
+
const symbol_extractor_1 = require("../lib/skeleton/symbol-extractor");
|
|
70
71
|
const skeletonizer_1 = require("../lib/skeleton/skeletonizer");
|
|
71
72
|
const vector_db_1 = require("../lib/store/vector-db");
|
|
72
73
|
const file_utils_1 = require("../lib/utils/file-utils");
|
|
73
74
|
const filter_builder_1 = require("../lib/utils/filter-builder");
|
|
75
|
+
const format_helpers_1 = require("../lib/utils/format-helpers");
|
|
76
|
+
const import_extractor_1 = require("../lib/utils/import-extractor");
|
|
74
77
|
const project_registry_1 = require("../lib/utils/project-registry");
|
|
75
78
|
const project_root_1 = require("../lib/utils/project-root");
|
|
76
79
|
const watcher_registry_1 = require("../lib/utils/watcher-registry");
|
|
@@ -507,49 +510,6 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
507
510
|
child.unref();
|
|
508
511
|
console.log(`[MCP] Started background watcher for ${projectRoot}`);
|
|
509
512
|
}
|
|
510
|
-
// --- Utilities ---
|
|
511
|
-
function extractImports(filePath) {
|
|
512
|
-
try {
|
|
513
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
514
|
-
const lines = content.split("\n");
|
|
515
|
-
const importLines = [];
|
|
516
|
-
let inMultiLine = false;
|
|
517
|
-
for (const line of lines) {
|
|
518
|
-
const trimmed = line.trim();
|
|
519
|
-
if (inMultiLine) {
|
|
520
|
-
importLines.push(line);
|
|
521
|
-
if (trimmed === ")" || trimmed === ");")
|
|
522
|
-
inMultiLine = false;
|
|
523
|
-
continue;
|
|
524
|
-
}
|
|
525
|
-
if (!trimmed ||
|
|
526
|
-
trimmed.startsWith("//") ||
|
|
527
|
-
trimmed.startsWith("#") ||
|
|
528
|
-
trimmed.startsWith("*") ||
|
|
529
|
-
trimmed.startsWith("/*")) {
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
if (trimmed.startsWith("import ") ||
|
|
533
|
-
trimmed.startsWith("from ") ||
|
|
534
|
-
(trimmed.startsWith("const ") && trimmed.includes("require(")) ||
|
|
535
|
-
trimmed.startsWith("require(") ||
|
|
536
|
-
trimmed.startsWith("use ") ||
|
|
537
|
-
trimmed.startsWith("using ") ||
|
|
538
|
-
trimmed.startsWith("package ")) {
|
|
539
|
-
importLines.push(line);
|
|
540
|
-
if (trimmed.includes("(") && !trimmed.includes(")")) {
|
|
541
|
-
inMultiLine = true;
|
|
542
|
-
}
|
|
543
|
-
continue;
|
|
544
|
-
}
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
return importLines.length > 0 ? importLines.join("\n") : "";
|
|
548
|
-
}
|
|
549
|
-
catch (_a) {
|
|
550
|
-
return "";
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
513
|
// --- Tool handlers ---
|
|
554
514
|
function handleSemanticSearch(args_1) {
|
|
555
515
|
return __awaiter(this, arguments, void 0, function* (args, searchAll = false) {
|
|
@@ -703,7 +663,7 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
703
663
|
snippet;
|
|
704
664
|
if (includeImports && absPath) {
|
|
705
665
|
if (!importCache.has(absPath)) {
|
|
706
|
-
importCache.set(absPath, extractImports(absPath));
|
|
666
|
+
importCache.set(absPath, (0, import_extractor_1.extractImports)(absPath));
|
|
707
667
|
}
|
|
708
668
|
const imports = importCache.get(absPath);
|
|
709
669
|
if (imports) {
|
|
@@ -912,32 +872,7 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
912
872
|
const annotated = sourceContent
|
|
913
873
|
? annotateSkeletonLines(skeleton, sourceContent)
|
|
914
874
|
: skeleton;
|
|
915
|
-
const symbols = annotated
|
|
916
|
-
.split("\n")
|
|
917
|
-
.filter((l) => /^\s*\d+│/.test(l))
|
|
918
|
-
.map((l) => {
|
|
919
|
-
var _a, _b, _c;
|
|
920
|
-
const m = l.match(/^\s*(\d+)│(.+)/);
|
|
921
|
-
if (!m)
|
|
922
|
-
return null;
|
|
923
|
-
const line = Number.parseInt(m[1], 10);
|
|
924
|
-
const sig = m[2].trim();
|
|
925
|
-
const exported = sig.includes("export ");
|
|
926
|
-
const type = ((_a = sig.match(/\b(class|interface|type|function|def|fn|func)\b/)) === null || _a === void 0 ? void 0 : _a[1]) || "other";
|
|
927
|
-
const name = ((_b = sig.match(/(?:function|class|interface|type|def|fn|func)\s+(\w+)/)) === null || _b === void 0 ? void 0 : _b[1]) ||
|
|
928
|
-
((_c = sig.match(/^(?:async\s+)?(\w+)\s*[(<]/)) === null || _c === void 0 ? void 0 : _c[1]) ||
|
|
929
|
-
"unknown";
|
|
930
|
-
return {
|
|
931
|
-
name,
|
|
932
|
-
line,
|
|
933
|
-
signature: sig
|
|
934
|
-
.replace(/\s*\{?\s*\/\/.*$/, "")
|
|
935
|
-
.trim(),
|
|
936
|
-
type,
|
|
937
|
-
exported,
|
|
938
|
-
};
|
|
939
|
-
})
|
|
940
|
-
.filter((s) => s !== null && s.name !== "unknown");
|
|
875
|
+
const symbols = (0, symbol_extractor_1.extractSymbolsFromSkeleton)(annotated);
|
|
941
876
|
jsonFiles.push({
|
|
942
877
|
file: t,
|
|
943
878
|
language: language || path.extname(t).slice(1),
|
|
@@ -1433,19 +1368,6 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
1433
1368
|
}
|
|
1434
1369
|
});
|
|
1435
1370
|
}
|
|
1436
|
-
function formatTimeAgo(ms) {
|
|
1437
|
-
const sec = Math.floor(ms / 1000);
|
|
1438
|
-
if (sec < 60)
|
|
1439
|
-
return `${sec}s ago`;
|
|
1440
|
-
const min = Math.floor(sec / 60);
|
|
1441
|
-
if (min < 60)
|
|
1442
|
-
return `${min}m ago`;
|
|
1443
|
-
const hr = Math.floor(min / 60);
|
|
1444
|
-
if (hr < 24)
|
|
1445
|
-
return `${hr}h ago`;
|
|
1446
|
-
const days = Math.floor(hr / 24);
|
|
1447
|
-
return `${days}d ago`;
|
|
1448
|
-
}
|
|
1449
1371
|
function handleRecentChanges(args) {
|
|
1450
1372
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1451
1373
|
var _a, e_1, _b, _c;
|
|
@@ -1488,7 +1410,7 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
1488
1410
|
const rel = f.path.startsWith(prefix)
|
|
1489
1411
|
? f.path.slice(prefix.length)
|
|
1490
1412
|
: f.path;
|
|
1491
|
-
const ago = formatTimeAgo(now - f.mtimeMs);
|
|
1413
|
+
const ago = (0, format_helpers_1.formatTimeAgo)(now - f.mtimeMs);
|
|
1492
1414
|
lines.push(` ${ago.padEnd(10)} ${rel}`);
|
|
1493
1415
|
}
|
|
1494
1416
|
return ok(lines.join("\n"));
|
package/dist/commands/recent.js
CHANGED
|
@@ -55,20 +55,8 @@ const commander_1 = require("commander");
|
|
|
55
55
|
const config_1 = require("../config");
|
|
56
56
|
const meta_cache_1 = require("../lib/store/meta-cache");
|
|
57
57
|
const exit_1 = require("../lib/utils/exit");
|
|
58
|
+
const format_helpers_1 = require("../lib/utils/format-helpers");
|
|
58
59
|
const project_root_1 = require("../lib/utils/project-root");
|
|
59
|
-
function formatTimeAgo(ms) {
|
|
60
|
-
const sec = Math.floor(ms / 1000);
|
|
61
|
-
if (sec < 60)
|
|
62
|
-
return `${sec}s ago`;
|
|
63
|
-
const min = Math.floor(sec / 60);
|
|
64
|
-
if (min < 60)
|
|
65
|
-
return `${min}m ago`;
|
|
66
|
-
const hr = Math.floor(min / 60);
|
|
67
|
-
if (hr < 24)
|
|
68
|
-
return `${hr}h ago`;
|
|
69
|
-
const days = Math.floor(hr / 24);
|
|
70
|
-
return `${days}d ago`;
|
|
71
|
-
}
|
|
72
60
|
exports.recent = new commander_1.Command("recent")
|
|
73
61
|
.description("Show recently modified indexed files")
|
|
74
62
|
.option("-l, --limit <n>", "Max files (default 20)", "20")
|
|
@@ -114,7 +102,7 @@ exports.recent = new commander_1.Command("recent")
|
|
|
114
102
|
const rel = f.path.startsWith(prefix)
|
|
115
103
|
? f.path.slice(prefix.length)
|
|
116
104
|
: f.path;
|
|
117
|
-
const ago = formatTimeAgo(now - f.mtimeMs);
|
|
105
|
+
const ago = (0, format_helpers_1.formatTimeAgo)(now - f.mtimeMs);
|
|
118
106
|
console.log(` ${ago.padEnd(10)} ${rel}`);
|
|
119
107
|
}
|
|
120
108
|
}
|
|
@@ -49,6 +49,7 @@ const path = __importStar(require("node:path"));
|
|
|
49
49
|
const chokidar_1 = require("chokidar");
|
|
50
50
|
const filter_builder_1 = require("../utils/filter-builder");
|
|
51
51
|
const config_1 = require("../../config");
|
|
52
|
+
const cache_check_1 = require("../utils/cache-check");
|
|
52
53
|
const file_utils_1 = require("../utils/file-utils");
|
|
53
54
|
const logger_1 = require("../utils/logger");
|
|
54
55
|
const lock_1 = require("../utils/lock");
|
|
@@ -138,9 +139,7 @@ function startWatcher(opts) {
|
|
|
138
139
|
continue;
|
|
139
140
|
// Quick mtime/size check — skip worker pool if unchanged
|
|
140
141
|
const cached = metaCache.get(absPath);
|
|
141
|
-
if (cached
|
|
142
|
-
cached.mtimeMs === stats.mtimeMs &&
|
|
143
|
-
cached.size === stats.size) {
|
|
142
|
+
if ((0, cache_check_1.isFileCached)(cached, stats)) {
|
|
144
143
|
continue;
|
|
145
144
|
}
|
|
146
145
|
const result = yield pool.processFile({
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractSymbolsFromSkeleton = extractSymbolsFromSkeleton;
|
|
4
|
+
function extractSymbolsFromSkeleton(annotatedSkeleton) {
|
|
5
|
+
return annotatedSkeleton
|
|
6
|
+
.split("\n")
|
|
7
|
+
.filter((l) => /^\s*\d+│/.test(l))
|
|
8
|
+
.map((l) => {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const m = l.match(/^\s*(\d+)│(.+)/);
|
|
11
|
+
if (!m)
|
|
12
|
+
return null;
|
|
13
|
+
const line = Number.parseInt(m[1], 10);
|
|
14
|
+
const sig = m[2].trim();
|
|
15
|
+
const exported = sig.includes("export ");
|
|
16
|
+
const type = ((_a = sig.match(/\b(class|interface|type|function|def|fn|func)\b/)) === null || _a === void 0 ? void 0 : _a[1]) || "other";
|
|
17
|
+
const name = ((_b = sig.match(/(?:function|class|interface|type|def|fn|func)\s+(\w+)/)) === null || _b === void 0 ? void 0 : _b[1]) ||
|
|
18
|
+
((_c = sig.match(/^(?:async\s+)?(\w+)\s*[(<]/)) === null || _c === void 0 ? void 0 : _c[1]) ||
|
|
19
|
+
"unknown";
|
|
20
|
+
return {
|
|
21
|
+
name,
|
|
22
|
+
line,
|
|
23
|
+
signature: sig.replace(/\s*\{?\s*\/\/.*$/, "").trim(),
|
|
24
|
+
type,
|
|
25
|
+
exported,
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
.filter((s) => s !== null && s.name !== "unknown");
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFileCached = isFileCached;
|
|
4
|
+
function isFileCached(cached, stats) {
|
|
5
|
+
if (!cached)
|
|
6
|
+
return false;
|
|
7
|
+
return cached.mtimeMs === stats.mtimeMs && cached.size === stats.size;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatTimeAgo = formatTimeAgo;
|
|
4
|
+
function formatTimeAgo(ms) {
|
|
5
|
+
const sec = Math.floor(ms / 1000);
|
|
6
|
+
if (sec < 60)
|
|
7
|
+
return `${sec}s ago`;
|
|
8
|
+
const min = Math.floor(sec / 60);
|
|
9
|
+
if (min < 60)
|
|
10
|
+
return `${min}m ago`;
|
|
11
|
+
const hr = Math.floor(min / 60);
|
|
12
|
+
if (hr < 24)
|
|
13
|
+
return `${hr}h ago`;
|
|
14
|
+
const days = Math.floor(hr / 24);
|
|
15
|
+
return `${days}d ago`;
|
|
16
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.extractImports = extractImports;
|
|
37
|
+
exports.extractImportsFromContent = extractImportsFromContent;
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
function extractImports(filePath) {
|
|
40
|
+
try {
|
|
41
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
42
|
+
return extractImportsFromContent(content);
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function extractImportsFromContent(content) {
|
|
49
|
+
const lines = content.split("\n");
|
|
50
|
+
const importLines = [];
|
|
51
|
+
let inMultiLine = false;
|
|
52
|
+
for (const line of lines) {
|
|
53
|
+
const trimmed = line.trim();
|
|
54
|
+
if (inMultiLine) {
|
|
55
|
+
importLines.push(line);
|
|
56
|
+
if (trimmed === ")" || trimmed === ");")
|
|
57
|
+
inMultiLine = false;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (!trimmed ||
|
|
61
|
+
trimmed.startsWith("//") ||
|
|
62
|
+
trimmed.startsWith("#") ||
|
|
63
|
+
trimmed.startsWith("*") ||
|
|
64
|
+
trimmed.startsWith("/*")) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (trimmed.startsWith("import ") ||
|
|
68
|
+
trimmed.startsWith("from ") ||
|
|
69
|
+
(trimmed.startsWith("const ") && trimmed.includes("require(")) ||
|
|
70
|
+
trimmed.startsWith("require(") ||
|
|
71
|
+
trimmed.startsWith("use ") ||
|
|
72
|
+
trimmed.startsWith("using ") ||
|
|
73
|
+
trimmed.startsWith("package ")) {
|
|
74
|
+
importLines.push(line);
|
|
75
|
+
if (trimmed.includes("(") && !trimmed.includes(")")) {
|
|
76
|
+
inMultiLine = true;
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return importLines.length > 0 ? importLines.join("\n") : "";
|
|
83
|
+
}
|
package/package.json
CHANGED