grepmax 0.7.9 → 0.7.10
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
|
@@ -124,6 +124,10 @@ const TOOLS = [
|
|
|
124
124
|
type: "number",
|
|
125
125
|
description: "Include N lines before and after the chunk (like grep -C). Only with detail 'code' or 'full'. Max 20.",
|
|
126
126
|
},
|
|
127
|
+
mode: {
|
|
128
|
+
type: "string",
|
|
129
|
+
description: "Search mode: 'default' (semantic only) or 'symbol' (semantic + call graph trace appended). Use 'symbol' when query is a function/class name.",
|
|
130
|
+
},
|
|
127
131
|
},
|
|
128
132
|
required: ["query"],
|
|
129
133
|
},
|
|
@@ -609,7 +613,50 @@ exports.mcp = new commander_1.Command("mcp")
|
|
|
609
613
|
return true;
|
|
610
614
|
});
|
|
611
615
|
}
|
|
612
|
-
|
|
616
|
+
let output = results.map((r) => r.text).join("\n\n");
|
|
617
|
+
// Symbol mode: append call graph
|
|
618
|
+
const mode = typeof args.mode === "string" ? args.mode : "default";
|
|
619
|
+
if (mode === "symbol" && !searchAll) {
|
|
620
|
+
try {
|
|
621
|
+
const db = getVectorDb();
|
|
622
|
+
const builder = new graph_builder_1.GraphBuilder(db);
|
|
623
|
+
const graph = yield builder.buildGraph(query);
|
|
624
|
+
if (graph.center) {
|
|
625
|
+
const traceLines = ["", "--- Call graph ---"];
|
|
626
|
+
const centerRel = graph.center.file.startsWith(projectRoot)
|
|
627
|
+
? graph.center.file.slice(projectRoot.length + 1)
|
|
628
|
+
: graph.center.file;
|
|
629
|
+
traceLines.push(`${graph.center.symbol} [${graph.center.role}] ${centerRel}:${graph.center.line + 1}`);
|
|
630
|
+
if (graph.callers.length > 0) {
|
|
631
|
+
traceLines.push("Callers:");
|
|
632
|
+
for (const caller of graph.callers) {
|
|
633
|
+
const rel = caller.file.startsWith(projectRoot)
|
|
634
|
+
? caller.file.slice(projectRoot.length + 1)
|
|
635
|
+
: caller.file;
|
|
636
|
+
traceLines.push(` <- ${caller.symbol} ${rel}:${caller.line + 1}`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (graph.callees.length > 0) {
|
|
640
|
+
traceLines.push("Calls:");
|
|
641
|
+
for (const callee of graph.callees.slice(0, 15)) {
|
|
642
|
+
if (callee.file) {
|
|
643
|
+
const rel = callee.file.startsWith(projectRoot)
|
|
644
|
+
? callee.file.slice(projectRoot.length + 1)
|
|
645
|
+
: callee.file;
|
|
646
|
+
traceLines.push(` -> ${callee.symbol} ${rel}:${callee.line + 1}`);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
traceLines.push(` -> ${callee.symbol} (not indexed)`);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
output += `\n${traceLines.join("\n")}`;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
catch (_b) {
|
|
657
|
+
// Trace failed — return search results without trace
|
|
658
|
+
}
|
|
659
|
+
}
|
|
613
660
|
if ((_a = result.warnings) === null || _a === void 0 ? void 0 : _a.length) {
|
|
614
661
|
return ok(`${result.warnings.join("\n")}\n\n${output}`);
|
|
615
662
|
}
|
package/package.json
CHANGED
|
@@ -47,6 +47,7 @@ Parameters:
|
|
|
47
47
|
- `exclude` (optional): Exclude files under this path prefix (e.g. "tests/" or "dist/")
|
|
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
|
+
- `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.
|
|
50
51
|
|
|
51
52
|
**When to use which mode:**
|
|
52
53
|
- `pointer` — navigation, finding locations, understanding architecture
|