Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: cross-file callers/callees via expandByName

riley02271c43a4f16594
diff --git a/ix-cli/src/cli/commands/callers.ts b/ix-cli/src/cli/commands/callers.ts
index 3d93cca0..e649b8f0 100644
--- a/ix-cli/src/cli/commands/callers.ts
+++ b/ix-cli/src/cli/commands/callers.ts
@@ -7,7 +7,7 @@ import { resolveEntity, printResolved } from "../resolve.js";
export function registerCallersCommand(program: Command): void {
program
.command("callers <symbol>")
- .description("Show methods/functions that call the given symbol")
+ .description("Show methods/functions that call the given symbol (cross-file)")
.option("--kind <kind>", "Filter target entity by kind")
.option("--format <fmt>", "Output format (text|json)", "text")
.action(async (symbol: string, opts: { kind?: string; format: string }) => {
@@ -15,13 +15,18 @@ export function registerCallersCommand(program: Command): void {
const target = await resolveEntity(client, symbol, ["method", "function"], opts);
if (!target) return;
printResolved(target);
- const result = await client.expand(target.id, { direction: "in", predicates: ["CALLS"] });
+ // Use expandByName for cross-file resolution
+ const result = await client.expandByName(target.name, {
+ direction: "in",
+ predicates: ["CALLS"],
+ kinds: ["function", "method"],
+ });
formatEdgeResults(result.nodes, "callers", target.name, opts.format, target);
});
program
.command("callees <symbol>")
- .description("Show methods/functions called by the given symbol")
+ .description("Show methods/functions called by the given symbol (cross-file)")
.option("--kind <kind>", "Filter target entity by kind")
.option("--format <fmt>", "Output format (text|json)", "text")
.action(async (symbol: string, opts: { kind?: string; format: string }) => {
@@ -29,7 +34,12 @@ export function registerCallersCommand(program: Command): void {
const target = await resolveEntity(client, symbol, ["method", "function"], opts);
if (!target) return;
printResolved(target);
- const result = await client.expand(target.id, { direction: "out", predicates: ["CALLS"] });
+ // Use expandByName for cross-file resolution
+ const result = await client.expandByName(target.name, {
+ direction: "out",
+ predicates: ["CALLS"],
+ kinds: ["function", "method"],
+ });
formatEdgeResults(result.nodes, "callees", target.name, opts.format, target);
});
}
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index e1fb09da..2f8cdc92 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -79,6 +79,18 @@ export class IxClient {
return this.get(`/v1/entity/${id}`);
}
+ async expandByName(
+ name: string,
+ opts?: { direction?: string; predicates?: string[]; kinds?: string[] }
+ ): Promise<{ nodes: any[]; edges: any[] }> {
+ return this.post("/v1/expand-by-name", {
+ name,
+ direction: opts?.direction ?? "both",
+ predicates: opts?.predicates,
+ kinds: opts?.kinds,
+ });
+ }
+
async expand(
id: string,
opts?: { direction?: string; predicates?: string[]; hops?: number }