grepmax 0.7.11 → 0.7.12

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.
@@ -128,6 +128,10 @@ const TOOLS = [
128
128
  type: "string",
129
129
  description: "Search mode: 'default' (semantic only) or 'symbol' (semantic + call graph trace appended). Use 'symbol' when query is a function/class name.",
130
130
  },
131
+ include_imports: {
132
+ type: "boolean",
133
+ description: "Prepend the file's import/require statements to each result. Deduped per file.",
134
+ },
131
135
  },
132
136
  required: ["query"],
133
137
  },
@@ -186,6 +190,10 @@ const TOOLS = [
186
190
  type: "number",
187
191
  description: "Include N lines before/after chunk. Only with detail 'code' or 'full'. Max 20.",
188
192
  },
193
+ include_imports: {
194
+ type: "boolean",
195
+ description: "Prepend file's import statements to each result.",
196
+ },
189
197
  },
190
198
  required: ["query"],
191
199
  },
@@ -457,6 +465,49 @@ exports.mcp = new commander_1.Command("mcp")
457
465
  child.unref();
458
466
  console.log(`[MCP] Started background watcher for ${projectRoot}`);
459
467
  }
468
+ // --- Utilities ---
469
+ function extractImports(filePath) {
470
+ try {
471
+ const content = fs.readFileSync(filePath, "utf-8");
472
+ const lines = content.split("\n");
473
+ const importLines = [];
474
+ let inMultiLine = false;
475
+ for (const line of lines) {
476
+ const trimmed = line.trim();
477
+ if (inMultiLine) {
478
+ importLines.push(line);
479
+ if (trimmed === ")" || trimmed === ");")
480
+ inMultiLine = false;
481
+ continue;
482
+ }
483
+ if (!trimmed ||
484
+ trimmed.startsWith("//") ||
485
+ trimmed.startsWith("#") ||
486
+ trimmed.startsWith("*") ||
487
+ trimmed.startsWith("/*")) {
488
+ continue;
489
+ }
490
+ if (trimmed.startsWith("import ") ||
491
+ trimmed.startsWith("from ") ||
492
+ (trimmed.startsWith("const ") && trimmed.includes("require(")) ||
493
+ trimmed.startsWith("require(") ||
494
+ trimmed.startsWith("use ") ||
495
+ trimmed.startsWith("using ") ||
496
+ trimmed.startsWith("package ")) {
497
+ importLines.push(line);
498
+ if (trimmed.includes("(") && !trimmed.includes(")")) {
499
+ inMultiLine = true;
500
+ }
501
+ continue;
502
+ }
503
+ break;
504
+ }
505
+ return importLines.length > 0 ? importLines.join("\n") : "";
506
+ }
507
+ catch (_a) {
508
+ return "";
509
+ }
510
+ }
460
511
  // --- Tool handlers ---
461
512
  function handleSemanticSearch(args_1) {
462
513
  return __awaiter(this, arguments, void 0, function* (args, searchAll = false) {
@@ -538,6 +589,8 @@ exports.mcp = new commander_1.Command("mcp")
538
589
  const minScore = typeof args.min_score === "number" ? args.min_score : 0;
539
590
  const maxPerFile = typeof args.max_per_file === "number" ? args.max_per_file : 0;
540
591
  const detail = typeof args.detail === "string" ? args.detail : "pointer";
592
+ const includeImports = Boolean(args.include_imports);
593
+ const importCache = new Map();
541
594
  let results = result.data.map((r) => {
542
595
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
543
596
  const absPath = (_c = (_a = r.path) !== null && _a !== void 0 ? _a : (_b = r.metadata) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : "";
@@ -603,10 +656,19 @@ exports.mcp = new commander_1.Command("mcp")
603
656
  .join("\n");
604
657
  }
605
658
  }
606
- const text = line1 +
659
+ let text = line1 +
607
660
  (summaryStr ? `\n${summaryStr}` : "") +
608
661
  (line2 ? `\n${line2}` : "") +
609
662
  snippet;
663
+ if (includeImports && absPath) {
664
+ if (!importCache.has(absPath)) {
665
+ importCache.set(absPath, extractImports(absPath));
666
+ }
667
+ const imports = importCache.get(absPath);
668
+ if (imports) {
669
+ text = `imports:\n${imports}\n\n${text}`;
670
+ }
671
+ }
610
672
  return {
611
673
  absPath,
612
674
  text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.7.11",
3
+ "version": "0.7.12",
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.11",
3
+ "version": "0.7.12",
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",
@@ -48,6 +48,7 @@ Parameters:
48
48
  - `language` (optional): Filter by file extension (e.g. "ts", "py", "go"). Omit the dot.
49
49
  - `role` (optional): Filter by chunk role: "ORCHESTRATION" (logic/flow), "DEFINITION" (types), or "IMPLEMENTATION"
50
50
  - `mode` (optional): `"default"` (semantic only) or `"symbol"` (semantic + call graph appended). Use "symbol" when query is a function or class name — gets search results + callers/callees in one call.
51
+ - `include_imports` (optional): Prepend file's import/require statements to each result. Deduped per file — see dependencies at a glance.
51
52
 
52
53
  **When to use which mode:**
53
54
  - `pointer` — navigation, finding locations, understanding architecture