grepmax 0.7.26 → 0.7.28

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.
@@ -66,11 +66,15 @@ const index_config_1 = require("../lib/index/index-config");
66
66
  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
+ const annotator_1 = require("../lib/skeleton/annotator");
69
70
  const retriever_1 = require("../lib/skeleton/retriever");
71
+ const symbol_extractor_1 = require("../lib/skeleton/symbol-extractor");
70
72
  const skeletonizer_1 = require("../lib/skeleton/skeletonizer");
71
73
  const vector_db_1 = require("../lib/store/vector-db");
72
74
  const file_utils_1 = require("../lib/utils/file-utils");
73
75
  const filter_builder_1 = require("../lib/utils/filter-builder");
76
+ const format_helpers_1 = require("../lib/utils/format-helpers");
77
+ const import_extractor_1 = require("../lib/utils/import-extractor");
74
78
  const project_registry_1 = require("../lib/utils/project-registry");
75
79
  const project_root_1 = require("../lib/utils/project-root");
76
80
  const watcher_registry_1 = require("../lib/utils/watcher-registry");
@@ -507,49 +511,6 @@ exports.mcp = new commander_1.Command("mcp")
507
511
  child.unref();
508
512
  console.log(`[MCP] Started background watcher for ${projectRoot}`);
509
513
  }
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
514
  // --- Tool handlers ---
554
515
  function handleSemanticSearch(args_1) {
555
516
  return __awaiter(this, arguments, void 0, function* (args, searchAll = false) {
@@ -703,7 +664,7 @@ exports.mcp = new commander_1.Command("mcp")
703
664
  snippet;
704
665
  if (includeImports && absPath) {
705
666
  if (!importCache.has(absPath)) {
706
- importCache.set(absPath, extractImports(absPath));
667
+ importCache.set(absPath, (0, import_extractor_1.extractImports)(absPath));
707
668
  }
708
669
  const imports = importCache.get(absPath);
709
670
  if (imports) {
@@ -797,31 +758,6 @@ exports.mcp = new commander_1.Command("mcp")
797
758
  }
798
759
  });
799
760
  }
800
- function annotateSkeletonLines(skeleton, sourceContent) {
801
- const sourceLines = sourceContent.split("\n");
802
- const skelLines = skeleton.split("\n");
803
- const used = new Set();
804
- return skelLines
805
- .map((skelLine) => {
806
- const trimmed = skelLine.trim();
807
- if (!trimmed ||
808
- trimmed.startsWith("//") ||
809
- trimmed.startsWith("*") ||
810
- trimmed.startsWith("/*")) {
811
- return skelLine;
812
- }
813
- // Match against source lines using first 40 chars
814
- const matchStr = trimmed.slice(0, 40);
815
- for (let i = 0; i < sourceLines.length; i++) {
816
- if (!used.has(i) && sourceLines[i].includes(matchStr)) {
817
- used.add(i);
818
- return `${String(i + 1).padStart(4)}│${skelLine}`;
819
- }
820
- }
821
- return skelLine;
822
- })
823
- .join("\n");
824
- }
825
761
  function handleCodeSkeleton(args) {
826
762
  return __awaiter(this, void 0, void 0, function* () {
827
763
  const target = String(args.target || "");
@@ -910,34 +846,9 @@ exports.mcp = new commander_1.Command("mcp")
910
846
  if (fmt === "json") {
911
847
  // Extract structured symbols from annotated skeleton
912
848
  const annotated = sourceContent
913
- ? annotateSkeletonLines(skeleton, sourceContent)
849
+ ? (0, annotator_1.annotateSkeletonLines)(skeleton, sourceContent)
914
850
  : 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");
851
+ const symbols = (0, symbol_extractor_1.extractSymbolsFromSkeleton)(annotated);
941
852
  jsonFiles.push({
942
853
  file: t,
943
854
  language: language || path.extname(t).slice(1),
@@ -947,7 +858,7 @@ exports.mcp = new commander_1.Command("mcp")
947
858
  }
948
859
  else {
949
860
  const annotated = sourceContent
950
- ? annotateSkeletonLines(skeleton, sourceContent)
861
+ ? (0, annotator_1.annotateSkeletonLines)(skeleton, sourceContent)
951
862
  : skeleton;
952
863
  parts.push(`// ${t} (~${tokenEstimate} tokens)\n\n${annotated}`);
953
864
  }
@@ -1433,19 +1344,6 @@ exports.mcp = new commander_1.Command("mcp")
1433
1344
  }
1434
1345
  });
1435
1346
  }
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
1347
  function handleRecentChanges(args) {
1450
1348
  return __awaiter(this, void 0, void 0, function* () {
1451
1349
  var _a, e_1, _b, _c;
@@ -1488,7 +1386,7 @@ exports.mcp = new commander_1.Command("mcp")
1488
1386
  const rel = f.path.startsWith(prefix)
1489
1387
  ? f.path.slice(prefix.length)
1490
1388
  : f.path;
1491
- const ago = formatTimeAgo(now - f.mtimeMs);
1389
+ const ago = (0, format_helpers_1.formatTimeAgo)(now - f.mtimeMs);
1492
1390
  lines.push(` ${ago.padEnd(10)} ${rel}`);
1493
1391
  }
1494
1392
  return ok(lines.join("\n"));
@@ -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,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.annotateSkeletonLines = annotateSkeletonLines;
4
+ function annotateSkeletonLines(skeleton, sourceContent) {
5
+ const sourceLines = sourceContent.split("\n");
6
+ const skelLines = skeleton.split("\n");
7
+ const used = new Set();
8
+ return skelLines
9
+ .map((skelLine) => {
10
+ const trimmed = skelLine.trim();
11
+ if (!trimmed ||
12
+ trimmed.startsWith("//") ||
13
+ trimmed.startsWith("*") ||
14
+ trimmed.startsWith("/*")) {
15
+ return skelLine;
16
+ }
17
+ const matchStr = trimmed.slice(0, 40);
18
+ for (let i = 0; i < sourceLines.length; i++) {
19
+ if (!used.has(i) && sourceLines[i].includes(matchStr)) {
20
+ used.add(i);
21
+ return `${String(i + 1).padStart(4)}│${skelLine}`;
22
+ }
23
+ }
24
+ return skelLine;
25
+ })
26
+ .join("\n");
27
+ }
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.7.26",
3
+ "version": "0.7.28",
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.26",
3
+ "version": "0.7.28",
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",