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: add ix depends command for dependency impact analysis
riley0227ea409c590c32
diff --git a/ix-cli/src/cli/commands/depends.ts b/ix-cli/src/cli/commands/depends.tsnew file mode 100644index 00000000..c0f98b81--- /dev/null+++ b/ix-cli/src/cli/commands/depends.ts@@ -0,0 +1,93 @@+import type { Command } from "commander";+import chalk from "chalk";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";+import { resolveEntity, printResolved } from "../resolve.js";++export function registerDependsCommand(program: Command): void {+ program+ .command("depends <symbol>")+ .description("Show what depends on the given entity (reverse CALLS + IMPORTS)")+ .option("--kind <kind>", "Filter target entity by kind")+ .option("--depth <n>", "Traversal depth (default 1)", "1")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (symbol: string, opts: { kind?: string; depth: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const target = await resolveEntity(+ client, symbol,+ ["method", "function", "class", "object", "trait", "interface", "module", "file"],+ opts+ );+ if (!target) return;++ const hops = parseInt(opts.depth, 10) || 1;++ const [callResult, importResult] = await Promise.all([+ client.expand(target.id, { direction: "in", predicates: ["CALLS"], hops }),+ client.expand(target.id, { direction: "in", predicates: ["IMPORTS"], hops }),+ ]);++ const seen = new Set<string>();+ const callers: any[] = [];+ const importers: any[] = [];++ for (const n of callResult.nodes) {+ if (!seen.has(n.id)) {+ seen.add(n.id);+ callers.push({ ...n, via: "CALLS" });+ }+ }+ for (const n of importResult.nodes) {+ if (!seen.has(n.id)) {+ seen.add(n.id);+ importers.push({ ...n, via: "IMPORTS" });+ }+ }++ const allDependents = [...callers, ...importers];++ if (opts.format === "json") {+ console.log(JSON.stringify({+ resolvedTarget: target,+ directDependents: allDependents.map((d: any) => ({+ id: d.id,+ kind: d.kind,+ name: d.name || d.attrs?.name || d.id,+ via: d.via,+ })),+ summary: {+ direct: allDependents.length,+ viaCalls: callers.length,+ viaImports: importers.length,+ },+ }, null, 2));+ return;+ }++ printResolved(target);+ if (allDependents.length === 0) {+ console.log(`No dependents found for "${target.name}".`);+ return;+ }++ if (callers.length > 0) {+ console.log(chalk.bold(` via CALLS (${callers.length}):`));+ for (const d of callers) {+ const shortId = d.id?.slice(0, 8) ?? "";+ const name = d.name || d.attrs?.name || d.id;+ console.log(` ${chalk.cyan((d.kind ?? "").padEnd(10))} ${chalk.dim(shortId)} ${name}`);+ }+ }++ if (importers.length > 0) {+ console.log(chalk.bold(` via IMPORTS (${importers.length}):`));+ for (const d of importers) {+ const shortId = d.id?.slice(0, 8) ?? "";+ const name = d.name || d.attrs?.name || d.id;+ console.log(` ${chalk.cyan((d.kind ?? "").padEnd(10))} ${chalk.dim(shortId)} ${name}`);+ }+ }++ console.log(chalk.dim(`\n Total: ${allDependents.length} direct dependents`));+ });+}diff --git a/ix-cli/src/cli/main.ts b/ix-cli/src/cli/main.tsindex 139a4cb4..19f2b7ab 100644--- a/ix-cli/src/cli/main.ts+++ b/ix-cli/src/cli/main.ts@@ -22,6 +22,7 @@ import { registerImportsCommand } from "./commands/imports.js";import { registerContainsCommand } from "./commands/contains.js";import { registerStatsCommand } from "./commands/stats.js";import { registerDoctorCommand } from "./commands/doctor.js";+import { registerDependsCommand } from "./commands/depends.js";const program = new Command();program@@ -51,6 +52,7 @@ registerImportsCommand(program);registerContainsCommand(program);registerStatsCommand(program);registerDoctorCommand(program);+registerDependsCommand(program);program.command("mcp-start")