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
perf(cli): optimize JSON output across all commands (#79)
Tanner Kocher5065efc5626c
diff --git a/ix-cli/src/cli/__tests__/impact-schema.test.ts b/ix-cli/src/cli/__tests__/impact-schema.test.tsindex 8f4ab10d..af4225cb 100644--- a/ix-cli/src/cli/__tests__/impact-schema.test.ts+++ b/ix-cli/src/cli/__tests__/impact-schema.test.ts@@ -8,24 +8,12 @@ import { inferRiskSemantics, humanizeLabel, type ImpactFacts } from "../impact/rconst REQUIRED_TOP_LEVEL_KEYS = ["resolvedTarget",- "resolutionMode",- "resultSource","systemPath","riskSummary","riskLevel","riskCategory","atRiskBehavior",- "nextStep",- "flowPropagation","summary",- "callerList",- "calleeList",- "topImpactedMembers",- "propagationBuckets",- "decisions",- "tasks",- "bugs",- "diagnostics",];const REQUIRED_SUMMARY_KEYS = [@@ -40,17 +28,15 @@ const REQUIRED_SUMMARY_KEYS = [describe("impact JSON schema normalization", () => {it("container impact shape has all required keys", () => {// Simulates the container impact JSON output shape+ // Optimized output: resolutionMode/resultSource dropped, empty arrays omittedconst containerOutput = {- resolvedTarget: { id: "abc", kind: "class", name: "MyClass" },- resolutionMode: "exact",- resultSource: "graph",+ resolvedTarget: { kind: "class", name: "MyClass" },systemPath: [{ name: "CLI", kind: "subsystem" }, { name: "Commands", kind: "module" }],riskSummary: "Medium risk — widely shared dependency affecting the CLI layer.",riskLevel: "medium",riskCategory: "shared",atRiskBehavior: ["Multiple callers across different subsystems"],- nextStep: null,- flowPropagation: null,+ nextStep: "Check callers with ix callers MyClass",summary: {members: 5,callers: 0,@@ -59,14 +45,8 @@ describe("impact JSON schema normalization", () => {directDependents: 1,memberLevelCallers: 10,},- callerList: [],- calleeList: [],topImpactedMembers: [{ name: "foo", kind: "method", id: "m1", callerCount: 3 }],propagationBuckets: [{ region: "Commands", regionKind: "module", count: 2, members: [{ name: "fn1", kind: "function" }] }],- decisions: [],- tasks: [],- bugs: [],- diagnostics: [],};for (const key of REQUIRED_TOP_LEVEL_KEYS) {@@ -75,33 +55,25 @@ describe("impact JSON schema normalization", () => {for (const key of REQUIRED_SUMMARY_KEYS) {expect(containerOutput.summary).toHaveProperty(key);}- // Container: callerList and calleeList are empty arrays- expect(Array.isArray(containerOutput.callerList)).toBe(true);- expect(Array.isArray(containerOutput.calleeList)).toBe(true);- // decisions/tasks/bugs are always arrays, never undefined- expect(Array.isArray(containerOutput.decisions)).toBe(true);- expect(Array.isArray(containerOutput.tasks)).toBe(true);- expect(Array.isArray(containerOutput.bugs)).toBe(true);// Risk fieldsexpect(typeof containerOutput.riskSummary).toBe("string");expect(typeof containerOutput.riskLevel).toBe("string");expect(typeof containerOutput.riskCategory).toBe("string");expect(Array.isArray(containerOutput.atRiskBehavior)).toBe(true);+ // Optional fields are omitted when empty (callerList, calleeList, decisions, tasks, bugs, diagnostics)+ expect(containerOutput).not.toHaveProperty("callerList");+ expect(containerOutput).not.toHaveProperty("decisions");});it("leaf impact shape has all required keys", () => {- // Simulates the leaf impact JSON output shape+ // Optimized output: resolutionMode/resultSource dropped, empty arrays omittedconst leafOutput = {- resolvedTarget: { id: "xyz", kind: "function", name: "verify_token" },- resolutionMode: "exact",- resultSource: "graph",+ resolvedTarget: { kind: "function", name: "verify_token" },systemPath: [{ name: "file.ts", kind: "file" }],riskSummary: "Low risk — localized impact with limited propagation.",riskLevel: "low",riskCategory: "localized",atRiskBehavior: ["Limited to immediate callers"],- nextStep: null,- flowPropagation: null,summary: {members: 0,callers: 3,@@ -110,14 +82,8 @@ describe("impact JSON schema normalization", () => {directDependents: 0,memberLevelCallers: 0,},- callerList: [{ id: "c1", kind: "method", name: "login" }],- calleeList: [{ id: "c2", kind: "function", name: "decode_jwt" }],- topImpactedMembers: [],- propagationBuckets: [],- decisions: [],- tasks: [],- bugs: [],- diagnostics: [],+ callerList: [{ kind: "method", name: "login" }],+ calleeList: [{ kind: "function", name: "decode_jwt" }],};for (const key of REQUIRED_TOP_LEVEL_KEYS) {@@ -126,14 +92,14 @@ describe("impact JSON schema normalization", () => {for (const key of REQUIRED_SUMMARY_KEYS) {expect(leafOutput.summary).toHaveProperty(key);}- // Leaf: topImpactedMembers is empty- expect(Array.isArray(leafOutput.topImpactedMembers)).toBe(true);- expect(leafOutput.topImpactedMembers.length).toBe(0);- // Leaf: members, directImporters, directDependents, memberLevelCallers are 0+ // Leaf: zero counts still present in summaryexpect(leafOutput.summary.members).toBe(0);expect(leafOutput.summary.directImporters).toBe(0);expect(leafOutput.summary.directDependents).toBe(0);expect(leafOutput.summary.memberLevelCallers).toBe(0);+ // Optional fields omitted when empty (topImpactedMembers, propagationBuckets, etc.)+ expect(leafOutput).not.toHaveProperty("topImpactedMembers");+ expect(leafOutput).not.toHaveProperty("diagnostics");});it("container and leaf have identical top-level keys", () => {diff --git a/ix-cli/src/cli/__tests__/overview-structure.test.ts b/ix-cli/src/cli/__tests__/overview-structure.test.tsindex e7bd584f..da098040 100644--- a/ix-cli/src/cli/__tests__/overview-structure.test.ts+++ b/ix-cli/src/cli/__tests__/overview-structure.test.ts@@ -14,7 +14,6 @@ import { humanizeLabel } from "../impact/risk-semantics.js";function makeClassOutput() {return {resolvedTarget: { id: "abc-123", kind: "class", name: "IxClient" },- resolutionMode: "exact",path: "src/client/api.ts",systemPath: [{ name: "CLI", kind: "system" },@@ -41,7 +40,6 @@ function makeClassOutput() {function makeFileOutput() {return {resolvedTarget: { id: "file-abc", kind: "file", name: "Node.scala" },- resolutionMode: "exact",path: "memory-layer/src/main/scala/ix/memory/model/Node.scala",systemPath: [{ name: "API", kind: "system" },@@ -65,7 +63,6 @@ function makeFileOutput() {function makeRegionOutput() {return {resolvedTarget: { id: "reg-1", kind: "subsystem", name: "Cli / Client" },- resolutionMode: "exact",path: null,systemPath: [{ name: "CLI", kind: "system" },@@ -88,7 +85,6 @@ function makeRegionOutput() {function makeFunctionInFileOutput() {return {resolvedTarget: { id: "fn-1", kind: "function", name: "pickBest" },- resolutionMode: "exact",path: "src/cli/resolve.ts",systemPath: [{ name: "CLI", kind: "system" },@@ -115,7 +111,6 @@ function makeFunctionInFileOutput() {function makeMethodInClassOutput() {return {resolvedTarget: { id: "m-1", kind: "method", name: "resolve" },- resolutionMode: "exact",path: "memory-layer/src/main/scala/ix/memory/conflict/ConflictService.scala",systemPath: [{ name: "API", kind: "system" },diff --git a/ix-cli/src/cli/commands/callers.ts b/ix-cli/src/cli/commands/callers.tsindex 2d1315a1..e044b0de 100644--- a/ix-cli/src/cli/commands/callers.ts+++ b/ix-cli/src/cli/commands/callers.ts@@ -4,7 +4,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint, resolveWorkspaceRoot } from "../config.js";-import { formatEdgeResults } from "../format.js";+import { formatEdgeResults, relativePath } from "../format.js";import { resolveFileOrEntity, printResolved } from "../resolve.js";import { stderr } from "../stderr.js";@@ -52,7 +52,7 @@ export function registerCallersCommand(program: Command): void {kind: "text-match",name: `${data.path?.text ?? ""}:${data.line_number ?? 0}`,resolved: false,- path: data.path?.text ?? "",+ path: relativePath(data.path?.text) ?? "",line: data.line_number ?? 0,attrs: { snippet: data.lines?.text?.trim() ?? "" },});diff --git a/ix-cli/src/cli/commands/depends.ts b/ix-cli/src/cli/commands/depends.tsindex 8bb17aff..bef225f0 100644--- a/ix-cli/src/cli/commands/depends.ts+++ b/ix-cli/src/cli/commands/depends.ts@@ -4,6 +4,7 @@ import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { resolveFileOrEntity, printResolved, isRawId } from "../resolve.js";import { stderr } from "../stderr.js";+import { compactTreeNode, relativePath } from "../format.js";// ── Tree types ──────────────────────────────────────────────────────@@ -196,11 +197,13 @@ export function registerDependsCommand(program: Command): void {// ── JSON output ──────────────────────────────────────────────if (opts.format === "json") {const output: any = {- resolvedTarget: target,- resolutionMode: target.resolutionMode,- resultSource: "graph",+ resolvedTarget: {+ name: target.name,+ kind: target.kind,+ path: relativePath(target.path),+ },semantics: "downstream_dependents",- tree,+ tree: tree.map(compactTreeNode),traversal: {nodesVisited,maxDepthReached,diff --git a/ix-cli/src/cli/commands/diff.ts b/ix-cli/src/cli/commands/diff.tsindex 8164fe45..02bef651 100644--- a/ix-cli/src/cli/commands/diff.ts+++ b/ix-cli/src/cli/commands/diff.ts@@ -8,7 +8,7 @@ import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { resolveFileOrEntity, resolveEntityFull, printResolved, looksFileLike, type ResolvedEntity } from "../resolve.js";-import { formatDiff } from "../format.js";+import { formatDiff, relativePath, stripNulls } from "../format.js";import { stderr } from "../stderr.js";const execFileAsync = promisify(execFile);@@ -37,6 +37,55 @@ export function computeLineDiff(before: string, after: string): string[] {return result;}+// ── JSON compaction ────────────────────────────────────────────────++/** Compact a node snapshot from a diff change — drop timestamps, null deletedRev, member_files UUIDs. */+function compactNodeSnapshot(node: any): any {+ if (!node) return node;+ const out: any = { name: node.name, kind: node.kind };+ if (node.provenance) {+ const p = node.provenance;+ const uri = relativePath(p.source_uri ?? p.sourceUri);+ if (uri) out.path = uri;+ if (p.source_hash ?? p.sourceHash) out.hash = (p.source_hash ?? p.sourceHash).slice(0, 12);+ }+ if (node.attrs) {+ const a = { ...node.attrs };+ // Drop member_files UUID arrays (bulky, not useful in diff output)+ delete a.member_files;+ delete a.memberFiles;+ // Keep only non-empty attrs+ if (Object.keys(a).length > 0) out.attrs = a;+ }+ return out;+}++/** Compact a diff result — strip bloat from change snapshots. */+function compactDiffResult(result: any): any {+ const out: any = {+ fromRev: result.fromRev,+ toRev: result.toRev,+ total: result.total ?? result.totalChanges,+ };+ if (result.truncated) out.truncated = true;+ if (result.changes) {+ out.changes = result.changes.map((c: any) => {+ const change: any = { changeType: c.changeType };+ if (c.entityId) change.entityId = c.entityId;+ if (c.atFromRev) change.atFromRev = compactNodeSnapshot(c.atFromRev);+ if (c.atToRev) change.atToRev = compactNodeSnapshot(c.atToRev);+ // Preserve source content fields added by --content fallback+ if (c.sourceContentBefore !== undefined) change.sourceContentBefore = c.sourceContentBefore;+ if (c.sourceContentAfter !== undefined) change.sourceContentAfter = c.sourceContentAfter;+ if (c.sourceDiff !== undefined) change.sourceDiff = c.sourceDiff;+ if (c.sourceContent !== undefined) change.sourceContent = c.sourceContent;+ return change;+ });+ }+ if (result.summary) out.summary = result.summary;+ return out;+}+// ── File content loading ────────────────────────────────────────────/** Load full file content from current disk. */@@ -417,7 +466,7 @@ export function registerDiffCommand(program: Command): void {const result: any = await client.diff(from, to, { summary: true, entityId });if (opts.format === "json") {- console.log(JSON.stringify(result, null, 2));+ console.log(JSON.stringify(compactDiffResult(result), null, 2));} else {const s = result.summary || {};console.log(chalk.cyan.bold(`\nDiff: rev ${result.fromRev} → ${result.toRev}`));@@ -470,7 +519,7 @@ export function registerDiffCommand(program: Command): void {if (opts.format === "json") {const jsonResult: any = {- ...result,+ ...compactDiffResult(result),textualDiff: diffLines,hasTextualChanges: diffLines.length > 0,diffMode,@@ -531,7 +580,7 @@ export function registerDiffCommand(program: Command): void {c.sourceContent = afterSource ?? beforeSource;}}- console.log(JSON.stringify(result, null, 2));+ console.log(JSON.stringify(compactDiffResult(result), null, 2));} else {await formatDiffContent(result);}@@ -553,7 +602,7 @@ export function registerDiffCommand(program: Command): void {if (opts.format === "json") {console.log(JSON.stringify({- ...result,+ ...compactDiffResult(result),textualChanges: {detected: true,lineChanges: changeCount,@@ -571,7 +620,7 @@ export function registerDiffCommand(program: Command): void {}if (opts.format === "json") {- console.log(JSON.stringify(result, null, 2));+ console.log(JSON.stringify(compactDiffResult(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`));diff --git a/ix-cli/src/cli/commands/entity.ts b/ix-cli/src/cli/commands/entity.tsindex 180e1e59..a23fa9f2 100644--- a/ix-cli/src/cli/commands/entity.ts+++ b/ix-cli/src/cli/commands/entity.ts@@ -2,6 +2,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";+import { relativePath, stripNulls } from "../format.js";export function registerEntityCommand(program: Command): void {program@@ -13,7 +14,7 @@ export function registerEntityCommand(program: Command): void {const resolvedId = await client.resolvePrefix(id);const result = await client.entity(resolvedId);if (opts.format === "json") {- console.log(JSON.stringify(result, null, 2));+ console.log(JSON.stringify(compactEntity(result), null, 2));} else {const name = result.node.name || (result.node.attrs as any)?.name || "(unnamed)";console.log(`Entity: ${result.node.id} ${chalk.bold(name)} (${result.node.kind})`);@@ -22,3 +23,56 @@ export function registerEntityCommand(program: Command): void {}});}++function compactEntity(result: any): any {+ // Deduplicate provenance: collect unique provenance objects, reference by index+ const provMap = new Map<string, number>();+ const provenances: any[] = [];++ function provIndex(prov: any): number | undefined {+ if (!prov) return undefined;+ const uri = prov.sourceUri ?? prov.source_uri ?? "";+ const key = `${uri}|${prov.sourceHash ?? prov.source_hash ?? ""}`;+ if (provMap.has(key)) return provMap.get(key)!;+ const idx = provenances.length;+ provenances.push(stripNulls({+ uri: relativePath(uri),+ hash: (prov.sourceHash ?? prov.source_hash ?? "").slice(0, 12) || undefined,+ extractor: prov.extractor,+ }));+ provMap.set(key, idx);+ return idx;+ }++ const node = result.node;+ const compactNode: any = stripNulls({+ id: node.id,+ kind: node.kind,+ name: node.name,+ attrs: filterAttrs(node.attrs),+ prov: provIndex(node.provenance),+ rev: node.createdRev,+ });++ const edges = (result.edges ?? []).map((e: any) => stripNulls({+ src: e.src,+ dst: e.dst,+ pred: e.predicate,+ prov: provIndex(e.provenance),+ rev: e.createdRev,+ }));++ return stripNulls({+ node: compactNode,+ claims: result.claims?.length > 0 ? result.claims : undefined,+ edges,+ provenances,+ });+}++function filterAttrs(attrs: any): any {+ if (!attrs || typeof attrs !== "object") return undefined;+ // Drop internal-only attrs+ const { role_source, ...rest } = attrs;+ return Object.keys(rest).length > 0 ? rest : undefined;+}diff --git a/ix-cli/src/cli/commands/explain.ts b/ix-cli/src/cli/commands/explain.tsindex af5fbc0d..c4489910 100644--- a/ix-cli/src/cli/commands/explain.ts+++ b/ix-cli/src/cli/commands/explain.ts@@ -1,7 +1,7 @@import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";-import { formatExplain, type ExplainResult, type EntityRef, type Diagnostic } from "../format.js";+import { formatExplain, relativePath, type ExplainResult, type EntityRef, type Diagnostic } from "../format.js";import { resolveFileOrEntity, isRawId } from "../resolve.js";import { isFileStale } from "../stale.js";import { collectFacts } from "../explain/facts.js";@@ -39,16 +39,14 @@ export function registerExplainCommand(program: Command): void {const rendered = renderExplanation(facts, role, importance);if (opts.format === "json") {- const output = {- resolvedTarget: { id: target.id, kind: target.kind, name: target.name },- resolutionMode: target.resolutionMode,- resultSource: "graph",+ const output: any = {+ resolvedTarget: { kind: target.kind, name: target.name },facts,role,importance,rendered,- diagnostics: facts.diagnostics.length > 0 ? facts.diagnostics : undefined,};+ if (facts.diagnostics.length > 0) output.diagnostics = facts.diagnostics;console.log(JSON.stringify(output, null, 2));} else {if (facts.stale) {@@ -148,7 +146,7 @@ async function rawExplain(kind: calleeNode.kind,id: e.dst,resolved: true,- path: calleeNode.provenance?.source_uri ?? calleeNode.provenance?.sourceUri,+ path: relativePath(calleeNode.provenance?.source_uri ?? calleeNode.provenance?.sourceUri),suggestedCommand: `ix explain "${name}"`,};} catch {@@ -182,7 +180,7 @@ async function rawExplain(kind: node.kind,name: node.name || node.attrs?.name || target.name,id: target.id,- file: sourceUri,+ file: relativePath(sourceUri),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 === target.id).length,@@ -202,9 +200,7 @@ async function rawExplain(if (format === "json") {const output: any = {- resolvedTarget: { id: target.id, kind: target.kind, name: target.name },- resolutionMode: target.resolutionMode,- resultSource: "graph",+ resolvedTarget: { kind: target.kind, name: target.name },result,};if (stale) {diff --git a/ix-cli/src/cli/commands/history.ts b/ix-cli/src/cli/commands/history.tsindex b90f1526..ba055a67 100644--- a/ix-cli/src/cli/commands/history.ts+++ b/ix-cli/src/cli/commands/history.ts@@ -3,6 +3,7 @@ import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";import { resolveFileOrEntity, printResolved } from "../resolve.js";+import { relativePath } from "../format.js";import { stderr } from "../stderr.js";export function registerHistoryCommand(program: Command): void {@@ -29,7 +30,16 @@ export function registerHistoryCommand(program: Command): void {const result = await client.provenance(resolved.id);if (opts.format === "json") {- console.log(JSON.stringify({ resolvedTarget: resolved, provenance: result }, null, 2));+ const patches = Array.isArray(result) ? result : (result as any)?.patches ?? [];+ console.log(JSON.stringify({+ resolvedTarget: { kind: resolved.kind, name: resolved.name, path: relativePath(resolved.path) },+ patches: patches.map((p: any) => ({+ rev: p.rev ?? p.data?.rev,+ timestamp: p.data?.timestamp ?? p.timestamp,+ intent: (p.data?.intent ?? p.intent) || undefined,+ source: relativePath(p.data?.source?.uri) ?? undefined,+ })),+ }, null, 2));} else {const patches = Array.isArray(result) ? result : (result as any)?.patches ?? [];if (patches.length === 0) {diff --git a/ix-cli/src/cli/commands/impact.ts b/ix-cli/src/cli/commands/impact.tsindex 46ecb707..1d0b9ee9 100644--- a/ix-cli/src/cli/commands/impact.ts+++ b/ix-cli/src/cli/commands/impact.ts@@ -6,6 +6,7 @@ import { getEndpoint } from "../config.js";import { resolveFileOrEntity, printResolved } from "../resolve.js";import { bucketByHierarchy, getSystemPath, formatSystemPath, hasMapData, type SystemPath } from "../hierarchy.js";import { inferRiskSemantics, humanizeLabel, type ImpactFacts, type RiskSemantics } from "../impact/risk-semantics.js";+import { stripNulls } from "../format.js";const CONTAINER_KINDS = new Set(["class", "module", "file", "object", "trait", "interface"]);@@ -298,40 +299,34 @@ async function containerImpact(if (isJson) {console.log(JSON.stringify(- {- resolvedTarget: { id: target.id, kind: target.kind, name: target.name },- resolutionMode: target.resolutionMode,- resultSource: "graph",+ stripNulls({+ resolvedTarget: { kind: target.kind, name: target.name },depth,- systemPath: systemPathMapped,+ systemPath: systemPathMapped.length > 0 ? systemPathMapped : undefined,riskSummary: risk.riskSummary,riskLevel: risk.riskLevel,riskCategory: risk.category,atRiskBehavior: risk.behaviorAtRisk,- nextStep: risk.nextStep ?? null,- flowPropagation: risk.flowPropagation ?? null,+ nextStep: risk.nextStep || undefined,+ flowPropagation: risk.flowPropagation || undefined,summary: {members: members.length,- callers: 0,- callees: 0,directImporters: directImporters.length,directDependents: directDependents.length,memberLevelCallers: totalMemberCallers,},- callerList: [],- calleeList: [],- topImpactedMembers: topMembers,- propagationBuckets: propagationBuckets.map((b) => ({+ topImpactedMembers: topMembers.length > 0 ? topMembers : undefined,+ propagationBuckets: propagationBuckets.length > 0 ? propagationBuckets.map((b) => ({region: b.region.name,regionKind: b.region.kind,count: b.members.length,members: b.members.slice(0, 5).map((m) => ({ name: m.name, kind: m.kind })),- })),- decisions,- tasks,- bugs,- diagnostics,- },+ })) : undefined,+ decisions: decisions.length > 0 ? decisions : undefined,+ tasks: tasks.length > 0 ? tasks : undefined,+ bugs: bugs.length > 0 ? bugs : undefined,+ diagnostics: diagnostics.length > 0 ? diagnostics : undefined,+ }),null,2)@@ -429,48 +424,38 @@ async function leafImpact(if (isJson) {console.log(JSON.stringify(- {- resolvedTarget: { id: target.id, kind: target.kind, name: target.name },- resolutionMode: target.resolutionMode,- resultSource: "graph",+ stripNulls({+ resolvedTarget: { kind: target.kind, name: target.name },depth,- systemPath: systemPathMapped,+ systemPath: systemPathMapped.length > 0 ? systemPathMapped : undefined,riskSummary: risk.riskSummary,riskLevel: risk.riskLevel,riskCategory: risk.category,atRiskBehavior: risk.behaviorAtRisk,- nextStep: risk.nextStep ?? null,- flowPropagation: risk.flowPropagation ?? null,+ nextStep: risk.nextStep || undefined,+ flowPropagation: risk.flowPropagation || undefined,summary: {- members: 0,callers: callersResult.nodes.length,callees: calleesResult.nodes.length,- directImporters: 0,- directDependents: 0,- memberLevelCallers: 0,},- callerList: callersResult.nodes.map((n: any) => ({- id: n.id,+ callerList: callersResult.nodes.length > 0 ? callersResult.nodes.map((n: any) => ({kind: n.kind,name: n.name || n.attrs?.name || "(unnamed)",- })),- calleeList: calleesResult.nodes.map((n: any) => ({- id: n.id,+ })) : undefined,+ calleeList: calleesResult.nodes.length > 0 ? calleesResult.nodes.map((n: any) => ({kind: n.kind,name: n.name || n.attrs?.name || "(unnamed)",- })),- topImpactedMembers: [],- propagationBuckets: propagationBuckets.map((b) => ({+ })) : undefined,+ propagationBuckets: propagationBuckets.length > 0 ? propagationBuckets.map((b) => ({region: b.region.name,regionKind: b.region.kind,count: b.members.length,members: b.members.slice(0, 5).map((m) => ({ name: m.name, kind: m.kind })),- })),- decisions,- tasks,- bugs,- diagnostics: [],- },+ })) : undefined,+ decisions: decisions.length > 0 ? decisions : undefined,+ tasks: tasks.length > 0 ? tasks : undefined,+ bugs: bugs.length > 0 ? bugs : undefined,+ }),null,2)diff --git a/ix-cli/src/cli/commands/inventory.ts b/ix-cli/src/cli/commands/inventory.tsindex df76ec41..a9066f52 100644--- a/ix-cli/src/cli/commands/inventory.ts+++ b/ix-cli/src/cli/commands/inventory.ts@@ -2,6 +2,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";+import { relativePath } from "../format.js";export function registerInventoryCommand(program: Command): void {program@@ -41,22 +42,32 @@ Examples: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,+ // Group by file to avoid repeating the same path on every entry+ const byFile = new Map<string, string[]>();+ const ungrouped: Array<{ name: string; kind: string; path?: string }> = [];+ for (const n of nodes) {+ const name = String(n.name || n.attrs?.name || "(unnamed)");+ const rawPath = (n as any).provenance?.source_uri ?? n.provenance?.sourceUri ?? n.attrs?.path;+ const path = relativePath(rawPath);+ if (path) {+ const existing = byFile.get(path) ?? [];+ existing.push(name);+ byFile.set(path, existing);+ } else {+ ungrouped.push({ name, kind: String(n.kind) });+ }+ }+ const grouped = Array.from(byFile.entries()).map(([path, names]) => ({+ path,+ items: names,}));- const output = {+ const output: any = {kind: opts.kind,- scope: scope,- results,- summary: { total: results.length },+ scope: scope ?? undefined,+ total: nodes.length,+ byFile: grouped,};+ if (ungrouped.length > 0) output.ungrouped = ungrouped;console.log(JSON.stringify(output, null, 2));return;}diff --git a/ix-cli/src/cli/commands/locate.ts b/ix-cli/src/cli/commands/locate.tsindex 11096451..130c8c8f 100644--- a/ix-cli/src/cli/commands/locate.ts+++ b/ix-cli/src/cli/commands/locate.ts@@ -8,6 +8,7 @@ import {} from "../resolve.js";import { isFileStale } from "../stale.js";import { stderr } from "../stderr.js";+import { relativePath } from "../format.js";import { getSystemPath, hasMapData } from "../hierarchy.js";import { humanizeLabel } from "../impact/risk-semantics.js";import { renderSection, renderKeyValue, renderNote, renderWarning, renderBreadcrumb } from "../ui.js";@@ -133,12 +134,12 @@ export function registerLocateCommand(program: Command): void {name: target.name,path: displayPath,},- resolutionMode: target.resolutionMode,+ resolutionMode: target.resolutionMode === "exact" ? undefined as any : target.resolutionMode,lineRange,container,systemPath: systemPathMapped,hasMapData: hasMap,- diagnostics,+ diagnostics: diagnostics.length > 0 ? diagnostics : [] as string[],};if (stale) {output.stale = true;@@ -191,14 +192,7 @@ async function resolveWithAmbiguity(// ── Repo-relative path ──────────────────────────────────────────────────────function toRepoRelative(filePath: string): string {- if (!path.isAbsolute(filePath)) return filePath;- try {- const cwd = process.cwd();- const rel = path.relative(cwd, filePath);- // Only use relative if it doesn't escape the repo (no leading ../)- if (!rel.startsWith("..") && !path.isAbsolute(rel)) return rel;- } catch {}- return filePath;+ return relativePath(filePath) ?? filePath;}// ── Humanized system path breadcrumb ────────────────────────────────────────diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.tsindex 8118ff04..dbbc9488 100644--- a/ix-cli/src/cli/commands/map.ts+++ b/ix-cli/src/cli/commands/map.ts@@ -3,6 +3,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";+import { roundFloat } from "../format.js";import { bootstrap } from "../bootstrap.js";import { ingestFiles } from "./ingest.js";@@ -203,7 +204,22 @@ Examples:if (minConf > 0) regions = regions.filter(r => r.confidence >= minConf);if (opts.format === "json") {- console.log(JSON.stringify({ ...result, regions }, null, 2));+ console.log(JSON.stringify({+ file_count: result.file_count,+ region_count: regions.length,+ levels: result.levels,+ map_rev: result.map_rev,+ outcome: result.outcome,+ regions: regions.map((r: any) => ({+ label: r.label,+ level: r.level,+ files: r.file_count,+ cohesion: roundFloat(r.cohesion),+ coupling: roundFloat(r.external_coupling),+ confidence: roundFloat(r.confidence),+ signals: r.dominant_signals,+ })),+ }, null, 2));return;}renderMapText(result, cwd, opts);diff --git a/ix-cli/src/cli/commands/overview.ts b/ix-cli/src/cli/commands/overview.tsindex b090240e..ad758b35 100644--- a/ix-cli/src/cli/commands/overview.ts+++ b/ix-cli/src/cli/commands/overview.ts@@ -5,6 +5,7 @@ import { getEndpoint } from "../config.js";import { resolveFileOrEntity, printResolved } from "../resolve.js";import { getSystemPath, hasMapData } from "../hierarchy.js";import { humanizeLabel } from "../impact/risk-semantics.js";+import { relativePath } from "../format.js";import { renderSection, renderKeyValue, renderNote, renderBreadcrumb } from "../ui.js";const CONTAINER_KINDS = new Set(["class", "module", "file", "trait", "object", "interface"]);@@ -73,13 +74,7 @@ Examples:// ── Helpers ──────────────────────────────────────────────────────────────────function toRepoRelative(filePath: string): string {- if (!nodePath.isAbsolute(filePath)) return filePath;- try {- const cwd = process.cwd();- const rel = nodePath.relative(cwd, filePath);- if (!rel.startsWith("..") && !nodePath.isAbsolute(rel)) return rel;- } catch {}- return filePath;+ return relativePath(filePath) ?? filePath;}function humanizeBreadcrumb(nodes: Array<{ name: string; kind: string }>): string {diff --git a/ix-cli/src/cli/commands/rank.ts b/ix-cli/src/cli/commands/rank.tsindex 3bdf2325..cf37f2f7 100644--- a/ix-cli/src/cli/commands/rank.ts+++ b/ix-cli/src/cli/commands/rank.ts@@ -212,10 +212,10 @@ export function registerRankCommand(program: Command): void {console.log(JSON.stringify({metric,kind: opts.kind,- scope: opts.path ?? null,- results,- summary: { evaluated: candidates.length, totalCandidates: candidates.length, returned: results.length },- diagnostics,+ scope: opts.path || undefined,+ results: results.map(r => ({ name: r.name, kind: r.kind, score: r.score })),+ summary: { evaluated: candidates.length, returned: results.length },+ diagnostics: diagnostics.length > 0 ? diagnostics : undefined,}, null, 2));} else {console.log(chalk.bold(`Top ${results.length} ${pluralize(opts.kind)} by ${metric}:`));diff --git a/ix-cli/src/cli/commands/read.ts b/ix-cli/src/cli/commands/read.tsindex d67f5864..bf2d9797 100644--- a/ix-cli/src/cli/commands/read.ts+++ b/ix-cli/src/cli/commands/read.ts@@ -7,6 +7,7 @@ import { getEndpoint, resolveWorkspaceRoot } from "../config.js";import { resolveEntityFull } from "../resolve.js";import { stderr } from "../stderr.js";import { isFileStale } from "../stale.js";+import { relativePath } from "../format.js";/** Common file extensions that signal the target is file-like, not a symbol name. */const FILE_EXTENSIONS = new Set([@@ -58,7 +59,8 @@ function readFileRange(filePath: string, start?: number, end?: number): { contenfunction outputResult(result: ReadResult, format: string): void {if (format === "json") {- console.log(JSON.stringify(result, null, 2));+ const out = { ...result, path: relativePath(result.path) ?? result.path };+ console.log(JSON.stringify(out, null, 2));} else {if (result.stale) stderr(chalk.yellow("⚠ File has changed since last ingest. Run ix map to update.\n"));if (result.targetType === "symbol" || result.targetType === "filename-match") {diff --git a/ix-cli/src/cli/commands/search.ts b/ix-cli/src/cli/commands/search.tsindex d3b28777..22e87e93 100644--- a/ix-cli/src/cli/commands/search.ts+++ b/ix-cli/src/cli/commands/search.ts@@ -2,7 +2,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";-import { formatNodes } from "../format.js";+import { formatNodes, relativePath } from "../format.js";import { scoreCandidate } from "../resolve.js";import { applyRoleFilter, roleHint } from "../role-filter.js";import { stderr } from "../stderr.js";@@ -158,7 +158,7 @@ Examples:id: s.node.id,name: s.node.name || (s.node.attrs as any)?.name || "(unnamed)",kind: s.node.kind,- path: s.node.provenance?.sourceUri ?? undefined,+ path: relativePath(s.node.provenance?.sourceUri) ?? undefined,rank: i + 1,tier: s.rank.tier,score: s.rank.score,diff --git a/ix-cli/src/cli/commands/smells.ts b/ix-cli/src/cli/commands/smells.tsindex 81445982..ab732291 100644--- a/ix-cli/src/cli/commands/smells.ts+++ b/ix-cli/src/cli/commands/smells.ts@@ -69,7 +69,16 @@ Examples:return;}if (opts.format === "json") {- console.log(JSON.stringify(result, null, 2));+ const smells = result.smells ?? [];+ console.log(JSON.stringify({+ count: smells.length,+ inference_version: "smell_v1",+ smells: smells.map((s: any) => ({+ smell: s.smell,+ entity_id: s.entity_id?.slice(0, 12),+ confidence: s.confidence,+ })),+ }, null, 2));return;}const smells = result.smells ?? [];@@ -104,7 +113,20 @@ Examples:}if (opts.format === "json") {- console.log(JSON.stringify(report, null, 2));+ // Compact: hoist inference_version to top, drop file_id UUIDs+ const compact = {+ rev: report.rev,+ run_at: report.run_at,+ count: report.count,+ inference_version: "smell_v1",+ candidates: report.candidates.map(c => ({+ file: c.file,+ smell: c.smell,+ confidence: c.confidence,+ signals: c.signals,+ })),+ };+ console.log(JSON.stringify(compact, null, 2));return;}diff --git a/ix-cli/src/cli/commands/subsystems.ts b/ix-cli/src/cli/commands/subsystems.tsindex 923e1f0b..2149894e 100644--- a/ix-cli/src/cli/commands/subsystems.ts+++ b/ix-cli/src/cli/commands/subsystems.ts@@ -2,6 +2,7 @@ import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";+import { roundFloat } from "../format.js";import { renderMapText, type MapResult } from "./map.js";import {renderSubsystemExplanationJson,@@ -114,7 +115,15 @@ Examples:: scores;if (opts.format === "json") {- console.log(JSON.stringify({ scores: filtered }, null, 2));+ const compact = filtered.map(s => ({+ name: s.name,+ level: s.level,+ health: roundFloat(s.health_score),+ files: s.file_count,+ chunks_per_file: roundFloat(s.chunk_density),+ smell_files: s.smell_files,+ }));+ console.log(JSON.stringify({ scores: compact }, null, 2));return;}printScores(filtered);@@ -171,7 +180,7 @@ Examples:}if (opts.format === "json") {- console.log(JSON.stringify(result, null, 2));+ console.log(JSON.stringify(compactMapResult(result), null, 2));return;}@@ -382,3 +391,78 @@ function confidenceLabel(confidence: number): string {if (confidence >= 0.50) return "Moderate";return "Fuzzy";}++/** Compact a MapResult or ScopedSubsystemResult for JSON output — drops UUIDs,+ * rounds floats, removes internal-only fields to save tokens. */+function compactMapResult(result: any): any {+ // ScopedSubsystemResult+ if (isScopedSubsystemResult(result)) {+ return compactScopedResult(result);+ }+ // Full MapResult — drop raw edges (505KB+ of UUID pairs) and+ // hierarchy (redundant with regions); keep only compacted regions.+ const regions = result.regions ?? [];+ const out: any = {+ file_count: result.file_count,+ region_count: result.region_count,+ levels: result.levels,+ map_rev: result.map_rev,+ outcome: result.outcome,+ regions: regions.map(compactRegion),+ };+ // Include hierarchy only as a compact tree if present+ if (result.hierarchy) {+ out.hierarchy = compactHierarchyNode(result.hierarchy);+ }+ return out;+}++function compactRegion(r: any): any {+ const out: any = {+ label: r.label,+ level: r.level,+ files: r.file_count,+ children: r.child_region_count,+ cohesion: roundFloat(r.cohesion),+ coupling: roundFloat(r.external_coupling),+ boundary: roundFloat(r.boundary_ratio),+ confidence: roundFloat(r.confidence),+ signals: r.dominant_signals,+ interfaces: r.interface_node_count,+ };+ if (r.crosscut_score > 0.01) out.crosscut = roundFloat(r.crosscut_score);+ return out;+}++function compactScopedResult(result: any): any {+ const target = result.target;+ return {+ target: {+ label: target.label,+ kind: target.label_kind,+ level: target.level,+ files: target.file_count,+ confidence: roundFloat(target.confidence),+ signals: target.dominant_signals,+ cross_cutting: target.is_cross_cutting || undefined,+ },+ parent: result.parent ? { label: result.parent.label, kind: result.parent.label_kind } : undefined,+ summary: result.summary,+ hierarchy: compactHierarchyNode(result.hierarchy),+ children: (result.children ?? []).map(compactRegion),+ };+}++function compactHierarchyNode(node: any): any {+ if (!node) return undefined;+ const out: any = {+ label: node.label,+ kind: node.label_kind,+ files: node.file_count,+ confidence: roundFloat(node.confidence),+ };+ if (node.children?.length > 0) {+ out.children = node.children.map(compactHierarchyNode);+ }+ return out;+}diff --git a/ix-cli/src/cli/commands/trace.ts b/ix-cli/src/cli/commands/trace.tsindex c1cdbbbb..f49511c6 100644--- a/ix-cli/src/cli/commands/trace.ts+++ b/ix-cli/src/cli/commands/trace.ts@@ -6,6 +6,7 @@ import { resolveFileOrEntity, isRawId } from "../resolve.js";import { stderr } from "../stderr.js";import { buildDependencyTree } from "./depends.js";import { renderSection, renderKeyValue, renderResolvedHeader, colorizeKind } from "../ui.js";+import { compactTreeNode, relativePath } from "../format.js";// ── Types ────────────────────────────────────────────────────────────@@ -292,12 +293,12 @@ export function registerTraceCommand(program: Command): void {if (opts.format === "json") {const output: Record<string, unknown> = {mode: "path",- from: { name: fromTarget.name, kind: fromTarget.kind, path: fromTarget.path },- to: { name: toTarget.name, kind: toTarget.kind, path: toTarget.path },+ from: { name: fromTarget.name, kind: fromTarget.kind, path: relativePath(fromTarget.path) },+ to: { name: toTarget.name, kind: toTarget.kind, path: relativePath(toTarget.path) },kind: relKind,};if (pathNodes.length > 0) {- const mapped = pathNodes.map((n) => ({ id: n.id, name: n.name, kind: n.kind }));+ const mapped = pathNodes.map((n) => ({ name: n.name, kind: n.kind }));output.path = mapped;output.summary = { path_length: pathNodes.length };} else {@@ -375,16 +376,16 @@ export function registerTraceCommand(program: Command): void {JSON.stringify({mode: "directional",- target: { name: target.name, kind: target.kind, path: target.path },+ target: { name: target.name, kind: target.kind, path: relativePath(target.path) },direction: "both",kind: relKind,depth: maxDepth,upstream: {- tree: upResult.tree,+ tree: upResult.tree.map(compactTreeNode),summary: { nodes_visited: upResult.nodesVisited, max_depth: upResult.maxDepthReached },},downstream: {- tree: downResult.tree,+ tree: downResult.tree.map(compactTreeNode),summary: { nodes_visited: downResult.nodesVisited, max_depth: downResult.maxDepthReached },},},@@ -438,35 +439,13 @@ export function registerTraceCommand(program: Command): void {// ── JSON ────────────────────────────────────────────────────if (opts.format === "json") {- // Build flat nodes + edges lists for JSON output- const nodes: Array<{ id: string; name: string; kind: string }> = [- { id: target.id, name: target.name, kind: target.kind },- ];- const edges: Array<{ from: string; to: string; kind: string }> = [];-- function collectJson(parentId: string, children: TraceNode[]): void {- for (const child of children) {- nodes.push({ id: child.id, name: child.name, kind: child.kind });- // downstream = in edges (child → parent), upstream = out edges (parent → child)- edges.push({ from: doUpstream ? child.id : parentId, to: doUpstream ? parentId : child.id, kind: relKind });- collectJson(child.id, child.children);- }- }- collectJson(target.id, tree);-- function toJsonTree(children: TraceNode[]): unknown[] {- return children.map((c) => ({ id: c.id, children: toJsonTree(c.children) }));- }-const output: Record<string, unknown> = {mode: "directional",- target: { name: target.name, kind: target.kind, path: target.path },+ target: { name: target.name, kind: target.kind, path: relativePath(target.path) },direction,kind: relKind,depth: maxDepth,- nodes,- edges,- tree: { id: target.id, children: toJsonTree(tree) },+ tree: tree.map(compactTreeNode),summary: { nodes_visited: nodesVisited, max_depth: maxDepthReached },};diff --git a/ix-cli/src/cli/explain/facts.ts b/ix-cli/src/cli/explain/facts.tsindex fd096c97..efc89c8f 100644--- a/ix-cli/src/cli/explain/facts.ts+++ b/ix-cli/src/cli/explain/facts.ts@@ -1,5 +1,6 @@import type { IxClient } from "../../client/api.js";import type { EntityRef, Diagnostic } from "../format.js";+import { relativePath } from "../format.js";import { isRawId } from "../resolve.js";import { isFileStale } from "../stale.js";import { buildDependencyTree } from "../commands/depends.js";@@ -80,7 +81,7 @@ export async function collectFacts(const edges = (details.edges ?? []) as any[];// Extract path- const path = node.provenance?.source_uri ?? node.provenance?.sourceUri ?? undefined;+ const path = relativePath(node.provenance?.source_uri ?? node.provenance?.sourceUri) ?? undefined;// Extract container from CONTAINS edge (where this entity is the dst)const containsEdge = edges.find(@@ -151,7 +152,7 @@ export async function collectFacts(kind: calleeNode.kind,id: e.dst,resolved: true,- path: calleeNode.provenance?.source_uri ?? calleeNode.provenance?.sourceUri,+ path: relativePath(calleeNode.provenance?.source_uri ?? calleeNode.provenance?.sourceUri),suggestedCommand: `ix explain "${name}"`,};} catch {diff --git a/ix-cli/src/cli/format.ts b/ix-cli/src/cli/format.tsindex f68a8db7..6dbcab76 100644--- a/ix-cli/src/cli/format.ts+++ b/ix-cli/src/cli/format.ts@@ -1,7 +1,51 @@import chalk from "chalk";+import { resolve } from "path";export type ResultSource = "graph" | "text" | "graph+text" | "heuristic";+// ── JSON optimization helpers ──────────────────────────────────────────────++/** Strip the cwd prefix from absolute paths to save tokens in JSON output. */+export function relativePath(absPath: string | undefined | null): string | undefined {+ if (!absPath) return undefined;+ const cwd = process.cwd();+ if (absPath.startsWith(cwd + "/")) return absPath.slice(cwd.length + 1);+ // Also handle /Users/.../project/ style without trailing slash match+ const home = process.env.HOME;+ if (home && absPath.startsWith(home)) {+ return "~" + absPath.slice(home.length);+ }+ return absPath;+}++/** Round a number to N decimal places (default 2). */+export function roundFloat(n: number, decimals: number = 2): number {+ const factor = Math.pow(10, decimals);+ return Math.round(n * factor) / factor;+}++/** Remove keys with null/undefined values from an object (shallow). */+export function stripNulls<T extends Record<string, unknown>>(obj: T): Partial<T> {+ const result: Record<string, unknown> = {};+ for (const [k, v] of Object.entries(obj)) {+ if (v !== null && v !== undefined) result[k] = v;+ }+ return result as Partial<T>;+}++/** Compact a tree node for JSON output — drops UUIDs, resolved:true, sourceEdge, uses relative paths. */+export function compactTreeNode(node: any): any {+ const out: any = { name: node.name, kind: node.kind };+ if (node.relation) out.rel = node.relation;+ if (node.path) out.path = relativePath(node.path);+ if (node.cycle) out.cycle = true;+ if (node.resolved === false) out.resolved = false;+ if (node.children?.length > 0) {+ out.children = node.children.map(compactTreeNode);+ }+ return out;+}+export function confidenceColor(score: number): (text: string) => string {if (score >= 0.8) return chalk.green;if (score >= 0.5) return chalk.yellow;@@ -153,7 +197,14 @@ export function formatBugs(nodes: any[], format: string): void {export function formatPatches(patches: any[], format: string): void {if (format === "json") {- console.log(JSON.stringify(patches, null, 2));+ const compact = patches.map(p => ({+ rev: p.rev,+ patch_id: p.patch_id?.slice(0, 12),+ intent: p.intent || undefined,+ timestamp: p.timestamp,+ source: relativePath(p.source?.uri) || undefined,+ }));+ console.log(JSON.stringify(compact, null, 2));return;}if (patches.length === 0) {@@ -294,7 +345,11 @@ export interface TextResult {export function formatTextResults(results: TextResult[], format: string): void {if (format === "json") {- console.log(JSON.stringify(results, null, 2));+ const compact = results.map(r => ({+ ...r,+ path: relativePath(r.path) ?? r.path,+ }));+ console.log(JSON.stringify(compact, null, 2));return;}if (results.length === 0) {@@ -356,12 +411,14 @@ export function formatEdgeResults(name: resolved ? name : undefined,kind: n.kind ?? undefined,id: resolved ? n.id : undefined,- resolved,- path: n.provenance?.source_uri ?? n.provenance?.sourceUri ?? n.attrs?.path ?? undefined,+ path: relativePath(n.provenance?.source_uri ?? n.provenance?.sourceUri ?? n.attrs?.path ?? undefined),};- if (!resolved && n.id) {- ref.rawId = n.id;- ref.diagnostic = "unresolved_call_target";+ if (!resolved) {+ ref.resolved = false;+ if (n.id) {+ ref.rawId = n.id;+ ref.diagnostic = "unresolved_call_target";+ }}return ref;});@@ -371,15 +428,20 @@ export function formatEdgeResults(resultSource: source ?? "graph",};if (resolvedTarget) {- output.resolvedTarget = resolvedTarget;- output.resolutionMode = resolvedTarget.resolutionMode ?? "exact";+ output.resolvedTarget = {+ ...resolvedTarget,+ path: relativePath((resolvedTarget as any).path),+ };+ if (resolvedTarget.resolutionMode && resolvedTarget.resolutionMode !== "exact") {+ output.resolutionMode = resolvedTarget.resolutionMode;+ }}if (nodes.length === 0) {output.diagnostics = diagnostics ?? [{ code: "no_edges", message: `No ${relation} edges found for resolved entity.` }];} else if (diagnostics && diagnostics.length > 0) {output.diagnostics = diagnostics;}- const unresolvedCount = results.filter((r: any) => !r.resolved).length;+ const unresolvedCount = results.filter((r: any) => r.resolved === false).length;if (unresolvedCount > 0) {output.diagnostics = [...(output.diagnostics ?? []),@@ -474,23 +536,21 @@ export function formatExplain(result: ExplainResult, format: string): void {if (format === "json") {const output: any = {resolvedTarget: { id: result.id, kind: result.kind, name: result.name },- resolutionMode: "exact",- resultSource: "graph",- result: {+ result: stripNulls({kind: result.kind,name: result.name,id: result.id,- file: result.file,+ file: relativePath(result.file),container: result.container,introducedRev: result.introducedRev,calledBy: result.calledBy,calls: result.calls,contains: result.contains,historyLength: result.historyLength,- signature: result.signature,- docstring: result.docstring,+ signature: result.signature ?? null,+ docstring: result.docstring ?? null,callList: result.callList,- },+ }),};if (result.diagnostics && result.diagnostics.length > 0) {output.diagnostics = result.diagnostics;diff --git a/scripts/dev/ix-smoke-test.sh b/scripts/dev/ix-smoke-test.shindex 5380d8a5..33977648 100755--- a/scripts/dev/ix-smoke-test.sh+++ b/scripts/dev/ix-smoke-test.sh@@ -290,7 +290,7 @@ DIFF_JSON="${TMPDIR}/diff_3_4.json"py_assert 'isinstance(data, dict) and data.get("fromRev")==3 and data.get("toRev")==4' "${DIFF_JSON}"py_assert 'isinstance(data.get("changes"), list) and len(data["changes"])>=1' "${DIFF_JSON}"py_assert 'any(ch.get("entityId")== "'"${DOC_ID}"'" and ch.get("changeType")=="modified" for ch in data["changes"])' "${DIFF_JSON}"-py_assert 'any(ch.get("atFromRev",{}).get("attrs",{}).get("content","") == "" and ch.get("atToRev",{}).get("attrs",{}).get("content","") == "zzzxqv123" for ch in data["changes"])' "${DIFF_JSON}"+py_assert 'any(ch.get("atFromRev",{}).get("attrs",{}).get("content","") == "" and ch.get("atToRev",{}).get("attrs",{}).get("content","") == "zzzxqv123" for ch in data.get("changes",[]))' "${DIFF_JSON}"# ---------- entity + claim lifecycle check (best-effort) ----------# If ix entity includes claims, verify old content claim is retired (deletedRev set) and only one active content claim remains.