Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: add ix inventory — scoped entity listing by kind and path

riley0227c883bfcc2c34
diff --git a/ix-cli/src/cli/commands/inventory.ts b/ix-cli/src/cli/commands/inventory.ts
new file mode 100644
index 00000000..21ea7d51
--- /dev/null
+++ b/ix-cli/src/cli/commands/inventory.ts
@@ -0,0 +1,85 @@
+import type { Command } from "commander";
+import chalk from "chalk";
+import { IxClient } from "../../client/api.js";
+import { getEndpoint } from "../config.js";
+
+export function registerInventoryCommand(program: Command): void {
+ program
+ .command("inventory")
+ .description("List entities by kind with optional path scoping")
+ .requiredOption("--kind <kind>", "Entity kind to list (class, method, function, file, module, etc.)")
+ .option("--path <path>", "Filter by source file path substring")
+ .option("--limit <n>", "Max results", "50")
+ .option("--format <fmt>", "Output format (text|json)", "text")
+ .addHelpText("after", `
+Examples:
+ ix inventory --kind class
+ ix inventory --kind class --path memory-layer
+ ix inventory --kind file --path ix-cli/src
+ ix inventory --kind method --limit 100
+ ix inventory --format json --kind class`)
+ .action(async (opts: {
+ kind: string; path?: string; limit: string; format: string;
+ }) => {
+ const client = new IxClient(getEndpoint());
+ const limit = parseInt(opts.limit, 10);
+
+ let nodes = await client.search("", {
+ limit,
+ kind: opts.kind,
+ });
+
+ if (opts.path) {
+ nodes = nodes.filter((n) => {
+ const uri = String(
+ (n as any).provenance?.source_uri ??
+ n.provenance?.sourceUri ??
+ n.attrs?.path ??
+ ""
+ );
+ return uri.includes(opts.path!);
+ });
+ }
+
+ const scope = opts.path ?? null;
+
+ if (opts.format === "json") {
+ const results = nodes.map((n) => ({
+ id: n.id,
+ name: n.name || n.attrs?.name || "(unnamed)",
+ kind: n.kind,
+ path:
+ (n as any).provenance?.source_uri ??
+ n.provenance?.sourceUri ??
+ n.attrs?.path ??
+ undefined,
+ }));
+ const output = {
+ kind: opts.kind,
+ scope: scope,
+ results,
+ summary: { total: results.length },
+ };
+ console.log(JSON.stringify(output, null, 2));
+ return;
+ }
+
+ if (nodes.length === 0) {
+ console.log(`No ${opts.kind} entities found${scope ? ` in ${scope}` : ""}.`);
+ return;
+ }
+
+ console.log(`Inventory: ${nodes.length} ${opts.kind} entities${scope ? ` in ${scope}` : ""}`);
+ for (const n of nodes) {
+ const name = n.name || n.attrs?.name || "(unnamed)";
+ const path = String(
+ n.provenance?.sourceUri ??
+ n.attrs?.path ??
+ ""
+ );
+ console.log(
+ ` ${chalk.cyan(n.kind.padEnd(10))} ${chalk.bold(String(name).padEnd(30))} ${chalk.dim(path)}`
+ );
+ }
+ });
+}
diff --git a/ix-cli/src/cli/main.ts b/ix-cli/src/cli/main.ts
index 5fdcfbc1..8fe49427 100644
--- a/ix-cli/src/cli/main.ts
+++ b/ix-cli/src/cli/main.ts
@@ -24,6 +24,8 @@ import { registerStatsCommand } from "./commands/stats.js";
import { registerDoctorCommand } from "./commands/doctor.js";
import { registerDependsCommand } from "./commands/depends.js";
import { registerReadCommand } from "./commands/read.js";
+import { registerInventoryCommand } from "./commands/inventory.js";
+import { registerImpactCommand } from "./commands/impact.js";
const program = new Command();
program
@@ -55,6 +57,8 @@ registerStatsCommand(program);
registerDoctorCommand(program);
registerDependsCommand(program);
registerReadCommand(program);
+registerInventoryCommand(program);
+registerImpactCommand(program);
program
.command("mcp-start")