Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: CLI diff supports --summary (server-side), --limit, --full flags

riley02272d4cac369d79
diff --git a/ix-cli/src/cli/commands/diff.ts b/ix-cli/src/cli/commands/diff.ts
index 9a0101a8..40e342e0 100644
--- a/ix-cli/src/cli/commands/diff.ts
+++ b/ix-cli/src/cli/commands/diff.ts
@@ -9,31 +9,47 @@ export function registerDiffCommand(program: Command): void {
.command("diff <fromRev> <toRev>")
.description("Show diff between two revisions")
.option("--entity <id>", "Filter by entity ID")
- .option("--summary", "Show compact summary only")
+ .option("--summary", "Show compact summary only (server-side, fast)")
+ .option("--limit <n>", "Max changes to return (default 100)")
+ .option("--full", "Return all changes (no limit)")
.option("--format <fmt>", "Output format (text|json)", "text")
- .action(async (fromRev: string, toRev: string, opts: { entity?: string; summary?: boolean; format: string }) => {
+ .action(async (fromRev: string, toRev: string, opts: {
+ entity?: string; summary?: boolean; limit?: string; full?: boolean; format: string;
+ }) => {
const client = new IxClient(getEndpoint());
- const result: any = await client.diff(parseInt(fromRev, 10), parseInt(toRev, 10), opts.entity);
+ const from = parseInt(fromRev, 10);
+ const to = parseInt(toRev, 10);
- if (opts.summary && opts.format !== "json") {
- const changes = result.changes || [];
- const added = changes.filter((c: any) => c.changeType === "added").length;
- const modified = changes.filter((c: any) => c.changeType === "modified").length;
- const removed = changes.filter((c: any) => c.changeType === "removed").length;
- const legacy = changes.filter((c: any) => c.changeType === "added_or_modified").length;
- console.log(chalk.cyan.bold(`\nDiff: rev ${result.fromRev} → ${result.toRev}`));
- if (added) console.log(` ${chalk.green("Added:")} ${added}`);
- if (modified) console.log(` ${chalk.yellow("Modified:")} ${modified}`);
- if (removed) console.log(` ${chalk.red("Removed:")} ${removed}`);
- if (legacy) console.log(` ${chalk.yellow("Changed:")} ${legacy}`);
- if (!added && !modified && !removed && !legacy) console.log(chalk.dim(" No changes."));
- console.log();
+ if (opts.summary) {
+ const result: any = await client.diff(from, to, { summary: true });
+
+ if (opts.format === "json") {
+ console.log(JSON.stringify(result, null, 2));
+ } else {
+ const s = result.summary || {};
+ console.log(chalk.cyan.bold(`\nDiff: rev ${result.fromRev} → ${result.toRev}`));
+ if (s.added) console.log(` ${chalk.green("Added:")} ${s.added}`);
+ if (s.modified) console.log(` ${chalk.yellow("Modified:")} ${s.modified}`);
+ if (s.removed) console.log(` ${chalk.red("Removed:")} ${s.removed}`);
+ if (!s.added && !s.modified && !s.removed) console.log(chalk.dim(" No changes."));
+ console.log(` ${chalk.dim("Total:")} ${result.total}`);
+ console.log();
+ }
return;
}
+ const limit = opts.full ? undefined : (opts.limit ? parseInt(opts.limit, 10) : undefined);
+ const result: any = await client.diff(from, to, {
+ entityId: opts.entity,
+ limit,
+ });
+
if (opts.format === "json") {
console.log(JSON.stringify(result, null, 2));
} else {
+ if (result.truncated) {
+ console.log(chalk.yellow(`Showing ${result.changes.length} of ${result.totalChanges} changes. Use --full to see all.\n`));
+ }
formatDiff(result, "text");
}
});
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index 4b987d05..8c71244f 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -139,9 +139,15 @@ export class IxClient {
async diff(
fromRev: number,
toRev: number,
- entityId?: string
+ opts?: { entityId?: string; summary?: boolean; limit?: number }
): Promise<unknown> {
- return this.post("/v1/diff", { fromRev, toRev, entityId });
+ return this.post("/v1/diff", {
+ fromRev,
+ toRev,
+ entityId: opts?.entityId,
+ summary: opts?.summary,
+ limit: opts?.limit,
+ });
}
async conflicts(): Promise<unknown[]> {