Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: explain snippets — signature, docstring, call list

riley0227586b5101873a
diff --git a/ix-cli/src/cli/commands/explain.ts b/ix-cli/src/cli/commands/explain.ts
index 0441c884..be860a1a 100644
--- a/ix-cli/src/cli/commands/explain.ts
+++ b/ix-cli/src/cli/commands/explain.ts
@@ -40,6 +40,26 @@ export function registerExplainCommand(program: Command): void {
);
const node = details.node as any;
+
+ // Extract snippet fields from attrs
+ const signature = node.attrs?.signature || node.attrs?.summary;
+ const docstring = node.attrs?.docstring || node.attrs?.description;
+
+ // Get actual callee names from outgoing CALLS edges
+ const calleeEdges = callEdges.filter((e: any) => e.src === target.id);
+ let callList: string[] | undefined;
+ if (calleeEdges.length > 0 && calleeEdges.length <= 20) {
+ const calleeNames = await Promise.all(
+ calleeEdges.map(async (e: any) => {
+ try {
+ const callee = await client.entity(e.dst);
+ return (callee.node as any).name || e.dst;
+ } catch { return e.dst; }
+ })
+ );
+ callList = calleeNames;
+ }
+
const result: ExplainResult = {
kind: node.kind,
name: node.name || node.attrs?.name || target.name,
@@ -51,6 +71,9 @@ export function registerExplainCommand(program: Command): void {
calls: callEdges.filter((e: any) => e.src === target.id).length,
contains: containedEdges.length,
historyLength: (history as any)?.chain?.length ?? 0,
+ signature,
+ docstring,
+ callList,
};
formatExplain(result, opts.format);
diff --git a/ix-cli/src/cli/format.ts b/ix-cli/src/cli/format.ts
index 6947fb1a..fd46bf7d 100644
--- a/ix-cli/src/cli/format.ts
+++ b/ix-cli/src/cli/format.ts
@@ -357,6 +357,9 @@ export interface ExplainResult {
calls: number;
contains: number;
historyLength: number;
+ signature?: string;
+ docstring?: string;
+ callList?: string[];
}
export function formatExplain(result: ExplainResult, format: string): void {
@@ -365,7 +368,14 @@ export function formatExplain(result: ExplainResult, format: string): void {
return;
}
const shortId = result.id.slice(0, 8);
- console.log(` ${chalk.cyan(result.kind)} ${chalk.bold(result.name)} ${chalk.dim(shortId)}`);
+ if (result.signature) {
+ console.log(` ${chalk.green(result.signature)}`);
+ } else {
+ console.log(` ${chalk.cyan(result.kind)} ${chalk.bold(result.name)} ${chalk.dim(shortId)}`);
+ }
+ if (result.docstring) {
+ console.log(` ${chalk.dim('"' + result.docstring + '"')}`);
+ }
if (result.container) {
console.log(` ${chalk.dim("in")} ${chalk.cyan(result.container.kind)} ${result.container.name}`);
}
@@ -374,7 +384,14 @@ export function formatExplain(result: ExplainResult, format: string): void {
}
console.log(` ${chalk.dim("introduced rev")} ${result.introducedRev}`);
if (result.calledBy > 0) console.log(` ${chalk.dim("called by")} ${result.calledBy} methods`);
- if (result.calls > 0) console.log(` ${chalk.dim("calls")} ${result.calls} methods`);
+ if (result.callList && result.callList.length > 0) {
+ console.log(` ${chalk.dim("calls:")}`);
+ for (const c of result.callList) {
+ console.log(` ${c}`);
+ }
+ } else if (result.calls > 0) {
+ console.log(` ${chalk.dim("calls")} ${result.calls} methods`);
+ }
if (result.contains > 0) console.log(` ${chalk.dim("contains")} ${result.contains} members`);
if (result.historyLength > 0) console.log(` ${chalk.dim("history")} ${result.historyLength} patches`);
}