grepmax 0.7.20 → 0.7.21

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.
@@ -61,6 +61,7 @@ const setup_helpers_1 = require("../lib/setup/setup-helpers");
61
61
  const retriever_1 = require("../lib/skeleton/retriever");
62
62
  const skeletonizer_1 = require("../lib/skeleton/skeletonizer");
63
63
  const vector_db_1 = require("../lib/store/vector-db");
64
+ const file_utils_1 = require("../lib/utils/file-utils");
64
65
  const exit_1 = require("../lib/utils/exit");
65
66
  const project_root_1 = require("../lib/utils/project-root");
66
67
  /**
@@ -140,6 +141,48 @@ Examples:
140
141
  includeSummary: !options.noSummary,
141
142
  };
142
143
  // Determine mode based on target
144
+ const resolvedTarget = path.resolve(target);
145
+ // Directory mode
146
+ if (fs.existsSync(resolvedTarget) &&
147
+ fs.statSync(resolvedTarget).isDirectory()) {
148
+ const entries = fs.readdirSync(resolvedTarget, {
149
+ withFileTypes: true,
150
+ });
151
+ const files = entries
152
+ .filter((e) => e.isFile() &&
153
+ (0, file_utils_1.isIndexableFile)(path.join(resolvedTarget, e.name)))
154
+ .map((e) => path.join(resolvedTarget, e.name))
155
+ .slice(0, Number.parseInt(options.limit, 10));
156
+ if (files.length === 0) {
157
+ console.error(`No indexable files in ${target}`);
158
+ process.exitCode = 1;
159
+ return;
160
+ }
161
+ for (const filePath of files) {
162
+ const content = fs.readFileSync(filePath, "utf-8");
163
+ const result = yield skeletonizer.skeletonizeFile(filePath, content, skeletonOpts);
164
+ outputResult(result, options);
165
+ }
166
+ return;
167
+ }
168
+ // Batch mode (comma-separated)
169
+ if (target.includes(",")) {
170
+ const targets = target
171
+ .split(",")
172
+ .map((t) => t.trim())
173
+ .filter(Boolean);
174
+ for (const t of targets) {
175
+ const filePath = path.resolve(t);
176
+ if (!fs.existsSync(filePath)) {
177
+ console.error(`Not found: ${t}`);
178
+ continue;
179
+ }
180
+ const content = fs.readFileSync(filePath, "utf-8");
181
+ const result = yield skeletonizer.skeletonizeFile(filePath, content, skeletonOpts);
182
+ outputResult(result, options);
183
+ }
184
+ return;
185
+ }
143
186
  if (isFilePath(target)) {
144
187
  // === FILE MODE ===
145
188
  const filePath = path.resolve(target);
@@ -19,8 +19,10 @@ const project_root_1 = require("../lib/utils/project-root");
19
19
  exports.trace = new commander_1.Command("trace")
20
20
  .description("Trace the call graph for a symbol")
21
21
  .argument("<symbol>", "The symbol to trace")
22
- .action((symbol) => __awaiter(void 0, void 0, void 0, function* () {
22
+ .option("-d, --depth <n>", "Caller traversal depth (default 1, max 3)", "1")
23
+ .action((symbol, opts) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  var _a;
25
+ const depth = Math.min(Math.max(Number.parseInt(opts.depth || "1", 10), 1), 3);
24
26
  const root = process.cwd();
25
27
  let vectorDb = null;
26
28
  try {
@@ -28,7 +30,7 @@ exports.trace = new commander_1.Command("trace")
28
30
  const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
29
31
  vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
30
32
  const graphBuilder = new graph_builder_1.GraphBuilder(vectorDb);
31
- const graph = yield graphBuilder.buildGraph(symbol);
33
+ const graph = yield graphBuilder.buildGraphMultiHop(symbol, depth);
32
34
  console.log((0, formatter_1.formatTrace)(graph));
33
35
  }
34
36
  catch (error) {
@@ -130,24 +130,40 @@ function formatTrace(graph) {
130
130
  return style.dim("Symbol not found.");
131
131
  }
132
132
  const lines = [];
133
- // 1. Callers (Upstream)
134
- if (graph.callers.length > 0) {
133
+ // 1. Importers
134
+ if (graph.importers.length > 0) {
135
+ const filtered = graph.importers.filter((p) => p !== graph.center.file);
136
+ if (filtered.length > 0) {
137
+ lines.push(style.bold("Imported by:"));
138
+ for (const imp of filtered.slice(0, 10)) {
139
+ lines.push(` ${style.dim(imp)}`);
140
+ }
141
+ lines.push("");
142
+ }
143
+ }
144
+ // 2. Callers (Upstream, recursive tree)
145
+ function renderCallerTree(trees, depth) {
146
+ for (const t of trees) {
147
+ const pad = " ".repeat(depth);
148
+ lines.push(`${pad}${style.blue("↑")} ${style.green(t.node.symbol)} ${style.dim(`(${t.node.file}:${t.node.line})`)}`);
149
+ renderCallerTree(t.callers, depth + 1);
150
+ }
151
+ }
152
+ if (graph.callerTree.length > 0) {
135
153
  lines.push(style.bold("Callers (Who calls this?):"));
136
- graph.callers.forEach((caller) => {
137
- lines.push(` ${style.blue("↑")} ${style.green(caller.symbol)} ${style.dim(`(${caller.file}:${caller.line})`)}`);
138
- });
154
+ renderCallerTree(graph.callerTree, 1);
139
155
  lines.push("");
140
156
  }
141
157
  else {
142
158
  lines.push(style.dim("No known callers."));
143
159
  lines.push("");
144
160
  }
145
- // 2. Center (The Symbol)
161
+ // 3. Center (The Symbol)
146
162
  lines.push(style.bold(`▶ ${graph.center.symbol}`));
147
163
  lines.push(` ${style.dim(`Defined in ${graph.center.file}:${graph.center.line}`)}`);
148
164
  lines.push(` ${style.dim(`Role: ${graph.center.role}`)}`);
149
165
  lines.push("");
150
- // 3. Callees (Downstream)
166
+ // 4. Callees (Downstream)
151
167
  if (graph.callees.length > 0) {
152
168
  lines.push(style.bold("Callees (What does this call?):"));
153
169
  graph.callees.forEach((callee) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grepmax",
3
- "version": "0.7.20",
3
+ "version": "0.7.21",
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.20",
3
+ "version": "0.7.21",
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",