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/MCP support for compact claims with summary-first display

riley0227062add6afb75
diff --git a/ix-cli/src/cli/__tests__/format.test.ts b/ix-cli/src/cli/__tests__/format.test.ts
index 2c6c2088..eec447d0 100644
--- a/ix-cli/src/cli/__tests__/format.test.ts
+++ b/ix-cli/src/cli/__tests__/format.test.ts
@@ -122,7 +122,7 @@ describe("formatContext", () => {
// Metadata
expect(plain).toContain("Seeds: 2 | Hops: 2 | Rev: 10");
// Claims section
- expect(plain).toContain("Claims (2):");
+ expect(plain).toContain("Claims:");
expect(plain).toContain("[95%]");
expect(plain).toContain("Claim A");
expect(plain).toContain("[40%]");
@@ -138,6 +138,31 @@ describe("formatContext", () => {
expect(plain).toContain("> Build feature [active]");
});
+ it("formats compact claims with path and score", () => {
+ const result = {
+ compactClaims: [{
+ entityId: "abc-123",
+ field: "defines:parseClaim",
+ value: "parseClaim",
+ score: 0.9,
+ confidence: { score: 0.9, authority: 0.9 },
+ path: "src/main/scala/ix/memory/ingestion/Parser.scala",
+ lineRange: [42, 67] as [number, number]
+ }],
+ claims: [],
+ conflicts: [],
+ decisions: [],
+ intents: [],
+ metadata: { query: "parseClaim", seedEntities: [], hopsExpanded: 1, asOfRev: 5 }
+ };
+ const output = captureLog(() => formatContext(result, "text"));
+ const clean = stripAnsi(output);
+ expect(clean).toContain("90%");
+ expect(clean).toContain("defines:parseClaim");
+ expect(clean).toContain("Parser.scala");
+ expect(clean).toContain("42-67");
+ });
+
it("shows truncation message when more than 10 claims", () => {
const claims = Array.from({ length: 15 }, (_, i) => ({
claim: { statement: `Claim ${i}` },
diff --git a/ix-cli/src/cli/format.ts b/ix-cli/src/cli/format.ts
index e05d646a..c94f3674 100644
--- a/ix-cli/src/cli/format.ts
+++ b/ix-cli/src/cli/format.ts
@@ -24,16 +24,28 @@ export function formatContext(result: any, format: string): void {
)
);
- if (claims && claims.length > 0) {
- console.log(`\nClaims (${claims.length}):`);
- for (const sc of claims.slice(0, 10)) {
- const pct = sc.finalScore * 100;
- const conf = pct.toFixed(0);
- const color = confidenceColor(sc.finalScore);
- console.log(` ${color(`[${conf}%]`)} ${sc.claim.statement}`);
+ const useCompact = result.compactClaims?.length > 0;
+ const displayClaims = useCompact ? result.compactClaims : (claims || []);
+ const maxShow = 10;
+
+ if (displayClaims.length > 0) {
+ console.log(chalk.bold("\nClaims:"));
+ displayClaims.slice(0, maxShow).forEach((c: any) => {
+ if (useCompact) {
+ const pct = Math.round((c.score ?? 0) * 100);
+ const color = confidenceColor(c.score ?? 0);
+ const loc = c.lineRange ? `:${c.lineRange[0]}-${c.lineRange[1]}` : '';
+ const pathStr = c.path ? chalk.dim(` (${c.path}${loc})`) : '';
+ console.log(` ${color(`[${pct}%]`)} ${c.field}${pathStr}`);
+ } else {
+ const pct = Math.round((c.finalScore ?? 0) * 100);
+ const color = confidenceColor(c.finalScore ?? 0);
+ console.log(` ${color(`[${pct}%]`)} ${c.claim?.statement || 'unknown'}`);
+ }
+ });
+ if (displayClaims.length > maxShow) {
+ console.log(chalk.dim(` ... and ${displayClaims.length - maxShow} more`));
}
- if (claims.length > 10)
- console.log(chalk.dim(` ... and ${claims.length - 10} more`));
}
if (conflicts && conflicts.length > 0) {
diff --git a/ix-cli/src/client/types.ts b/ix-cli/src/client/types.ts
index c28cc72b..23310349 100644
--- a/ix-cli/src/client/types.ts
+++ b/ix-cli/src/client/types.ts
@@ -32,6 +32,22 @@ export interface ScoredClaim {
finalScore: number;
}
+export interface CompactConfidence {
+ score: number;
+ authority?: number;
+ factors?: Record<string, Factor>;
+}
+
+export interface CompactScoredClaim {
+ entityId: string;
+ field: string;
+ value: unknown;
+ score: number;
+ confidence: CompactConfidence;
+ path?: string;
+ lineRange?: [number, number];
+}
+
export interface ConflictReport {
id: string;
claimA: string;
@@ -93,6 +109,7 @@ export interface ContextMetadata {
export interface StructuredContext {
claims: ScoredClaim[];
+ compactClaims?: CompactScoredClaim[];
conflicts: ConflictReport[];
decisions: DecisionReport[];
intents: IntentReport[];