Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
feat: kind-aware resolution and DEFINES fallback in all navigation commands
riley0227ae304943beb6
diff --git a/ix-cli/src/cli/commands/callers.ts b/ix-cli/src/cli/commands/callers.tsindex 593ef4e9..4324ff13 100644--- a/ix-cli/src/cli/commands/callers.ts+++ b/ix-cli/src/cli/commands/callers.ts@@ -2,41 +2,34 @@ import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { formatEdgeResults } from "../format.js";+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")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());-- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const entityId = (nodes[0] as any).id;-- const result = await client.expand(entityId, { direction: "in", predicates: ["CALLS"] });- formatEdgeResults(result.nodes, "callers", symbol, opts.format);+ 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"] });+ formatEdgeResults(result.nodes, "callers", target.name, opts.format);});program.command("callees <symbol>").description("Show methods/functions called by the given symbol")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());-- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const entityId = (nodes[0] as any).id;-- const result = await client.expand(entityId, { direction: "out", predicates: ["CALLS"] });- formatEdgeResults(result.nodes, "callees", symbol, opts.format);+ 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"] });+ formatEdgeResults(result.nodes, "callees", target.name, opts.format);});}diff --git a/ix-cli/src/cli/commands/contains.ts b/ix-cli/src/cli/commands/contains.tsindex 54844fb4..36a43d1c 100644--- a/ix-cli/src/cli/commands/contains.ts+++ b/ix-cli/src/cli/commands/contains.ts@@ -2,23 +2,20 @@ import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { formatEdgeResults } from "../format.js";+import { resolveEntity, printResolved } from "../resolve.js";export function registerContainsCommand(program: Command): void {program.command("contains <symbol>").description("Show members contained by the given entity (class, module, file)")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());-- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const entityId = (nodes[0] as any).id;-- const result = await client.expand(entityId, { direction: "out", predicates: ["CONTAINS"] });- formatEdgeResults(result.nodes, "contains", symbol, opts.format);+ const target = await resolveEntity(client, symbol, ["class", "object", "trait", "interface", "module", "file"], opts);+ if (!target) return;+ printResolved(target);+ const result = await client.expand(target.id, { direction: "out", predicates: ["CONTAINS", "DEFINES"] });+ formatEdgeResults(result.nodes, "contains", target.name, opts.format);});}diff --git a/ix-cli/src/cli/commands/explain.ts b/ix-cli/src/cli/commands/explain.tsindex c1410a3b..0441c884 100644--- a/ix-cli/src/cli/commands/explain.ts+++ b/ix-cli/src/cli/commands/explain.ts@@ -2,36 +2,30 @@ import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { formatExplain, type ExplainResult } from "../format.js";+import { resolveEntity } from "../resolve.js";export function registerExplainCommand(program: Command): void {program.command("explain <symbol>").description("Explain an entity — shows structure, container, and history")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());+ const target = await resolveEntity(client, symbol, ["class", "function", "method", "trait", "object", "interface", "module", "file"], opts);+ if (!target) return;- // Step 1: Find the entity- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const node = nodes[0] as any;- const entityId = node.id;-- // Step 2: Get entity details (claims, edges)- const details = await client.entity(entityId);+ const details = await client.entity(target.id);- // Step 3: Get history- let history: any = { entityId, chain: [] };+ let history: any = { entityId: target.id, chain: [] };try {- history = await client.provenance(entityId);+ history = await client.provenance(target.id);} catch { /* no history */ }- // Step 4: Find container (CONTAINS edge pointing to this entity)const edges = (details.edges ?? []) as any[];- const containsEdge = edges.find((e: any) => e.predicate === "CONTAINS" && e.dst === entityId);+ const containsEdge = edges.find((e: any) =>+ (e.predicate === "CONTAINS" || e.predicate === "DEFINES") && e.dst === target.id+ );let container: any = undefined;if (containsEdge) {try {@@ -40,19 +34,21 @@ export function registerExplainCommand(program: Command): void {} catch { /* no container */ }}- // Step 5: Count connectionsconst callEdges = edges.filter((e: any) => e.predicate === "CALLS");- const containedEdges = edges.filter((e: any) => e.predicate === "CONTAINS" && e.src === entityId);+ const containedEdges = edges.filter((e: any) =>+ (e.predicate === "CONTAINS" || e.predicate === "DEFINES") && e.src === target.id+ );+ const node = details.node as any;const result: ExplainResult = {kind: node.kind,- name: node.attrs?.name ?? node.name ?? symbol,- id: entityId,+ name: node.name || node.attrs?.name || target.name,+ id: target.id,file: node.provenance?.source_uri ?? node.provenance?.sourceUri,- container: container ? { kind: container.kind, name: container.attrs?.name ?? container.name } : undefined,+ container: container ? { kind: container.kind, name: container.name || container.attrs?.name || "(unknown)" } : undefined,introducedRev: node.createdRev ?? node.created_rev,- calledBy: callEdges.filter((e: any) => e.dst === entityId).length,- calls: callEdges.filter((e: any) => e.src === entityId).length,+ calledBy: callEdges.filter((e: any) => e.dst === target.id).length,+ calls: callEdges.filter((e: any) => e.src === target.id).length,contains: containedEdges.length,historyLength: (history as any)?.chain?.length ?? 0,};diff --git a/ix-cli/src/cli/commands/imports.ts b/ix-cli/src/cli/commands/imports.tsindex 982f8114..910911c6 100644--- a/ix-cli/src/cli/commands/imports.ts+++ b/ix-cli/src/cli/commands/imports.ts@@ -2,41 +2,34 @@ import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { formatEdgeResults } from "../format.js";+import { resolveEntity, printResolved } from "../resolve.js";export function registerImportsCommand(program: Command): void {program.command("imports <symbol>").description("Show what the given entity imports")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());-- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const entityId = (nodes[0] as any).id;-- const result = await client.expand(entityId, { direction: "out", predicates: ["IMPORTS"] });- formatEdgeResults(result.nodes, "imports", symbol, opts.format);+ const target = await resolveEntity(client, symbol, ["file", "module", "class"], opts);+ if (!target) return;+ printResolved(target);+ const result = await client.expand(target.id, { direction: "out", predicates: ["IMPORTS"] });+ formatEdgeResults(result.nodes, "imports", target.name, opts.format);});program.command("imported-by <symbol>").description("Show what imports the given entity")+ .option("--kind <kind>", "Filter target entity by kind").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { format: string }) => {+ .action(async (symbol: string, opts: { kind?: string; format: string }) => {const client = new IxClient(getEndpoint());-- const nodes = await client.search(symbol, { limit: 1 });- if (nodes.length === 0) {- console.log(`No entity found matching "${symbol}".`);- return;- }- const entityId = (nodes[0] as any).id;-- const result = await client.expand(entityId, { direction: "in", predicates: ["IMPORTS"] });- formatEdgeResults(result.nodes, "imported-by", symbol, opts.format);+ const target = await resolveEntity(client, symbol, ["file", "module", "class"], opts);+ if (!target) return;+ printResolved(target);+ const result = await client.expand(target.id, { direction: "in", predicates: ["IMPORTS"] });+ formatEdgeResults(result.nodes, "imported-by", target.name, opts.format);});}