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(context): descend into a neighbouring class, and lead with the target's own members
KageBinaryf567a64542b2
diff --git a/ix-cli/src/cli/__tests__/context-evidence-locations.test.ts b/ix-cli/src/cli/__tests__/context-evidence-locations.test.tsindex 26c6c869..97ab0685 100644--- a/ix-cli/src/cli/__tests__/context-evidence-locations.test.ts+++ b/ix-cli/src/cli/__tests__/context-evidence-locations.test.ts@@ -259,8 +259,11 @@ describe("ix context evidence says where things are", () => {const llm = captureLog(() => renderBundle(b, "llm"));expect(llm[0]).toContain("target_path=src/cli/config.ts");+ // Score is tier + position, and the target's own members lead the+ // structural facts: a file with many imports pushed all of its own members+ // out of the evidence budget when they came last.expect(llm).toContain(- 'evidence score=11 kind=structural title="member resolveWorkspaceRoot" path=src/cli/config.ts lines=322-342',+ 'evidence score=10 kind=structural title="member resolveWorkspaceRoot" path=src/cli/config.ts lines=322-342',);});diff --git a/ix-cli/src/cli/commands/context.ts b/ix-cli/src/cli/commands/context.tsindex bc35952e..979f8726 100644--- a/ix-cli/src/cli/commands/context.ts+++ b/ix-cli/src/cli/commands/context.ts@@ -1637,10 +1637,18 @@ function rankEvidence(input: {): Array<{ name: string; ref?: EntityLocation }> =>(refs ? refs.map((ref) => ({ name: ref.name, ref })) : names.map((name) => ({ name }))).slice(0, limit);- // Outward first. Everything below points inward -- what contains the target,- // what calls it -- and the file an answer lives in is most often one the- // target imports: measured on the benchmark task set, 6 of 19 tasks' answers- // are a direct import of their entry point, and none were in the bundle.+ for (const { name, ref } of related(input.facts.members, input.facts.memberRefs, LEADING_MEMBERS)) {+ structural.push({+ id: `member:${name}`, source: "facts.members", title: `member ${name}`,+ reason: ref ? memberReason(ref) : "defined in the target", refs: ref ? [ref.id] : [], ...locationField(ref),+ });+ }+ // Then outward. The file an answer lives in is most often one the target+ // imports: measured on the benchmark task set, 6 of 19 tasks' answers are a+ // direct import of their entry point, and none were in the bundle. These go+ // after the target's own members, not before: the evidence budget is 25+ // items, and a file with many imports (resolve.ts) pushed all 27 of its own+ // members out of the bundle entirely.for (const ref of (input.facts.importRefs ?? []).slice(0, SHOWN_IMPORTS)) {structural.push({id: `imports:${ref.name}`, source: "facts.imports", title: `imports ${ref.name}`,@@ -1673,12 +1681,6 @@ function rankEvidence(input: {reason: "calls, imports or references the target", refs: ref ? [ref.id] : [], ...locationField(ref),});}- for (const { name, ref } of related(input.facts.members, input.facts.memberRefs, LEADING_MEMBERS)) {- structural.push({- id: `member:${name}`, source: "facts.members", title: `member ${name}`,- reason: ref ? memberReason(ref) : "defined in the target", refs: ref ? [ref.id] : [], ...locationField(ref),- });- }structural.forEach((item, index) => {items.push({ ...item, kind: "structural", score: 10 + index });});@@ -1836,7 +1838,7 @@ const LEADING_MEMBERS = 10;const SHOWN_IMPORTS = 8;/** Members of neighbouring files named in the evidence; the rest are entities. */-const SHOWN_NEIGHBOUR_MEMBERS = 10;+const SHOWN_NEIGHBOUR_MEMBERS = 6;type Located = { path?: string; lineStart?: number; lineEnd?: number };diff --git a/ix-cli/src/cli/explain/facts.ts b/ix-cli/src/cli/explain/facts.tsindex 1f533054..8d5dfc66 100644--- a/ix-cli/src/cli/explain/facts.ts+++ b/ix-cli/src/cli/explain/facts.ts@@ -117,7 +117,7 @@ const NO_DOWNSTREAM = { tree: [], truncated: false, nodesVisited: 0, maxDepthReaconst MAX_NEIGHBOUR_FILES = 5;const MAX_NEIGHBOUR_MEMBERS = 4;/** Members of a neighbour whose use is measured before the best are kept. */-const NEIGHBOUR_USE_POOL = 6;+const NEIGHBOUR_USE_POOL = 8;/** Outbound facts kept: enough to navigate by, few enough to leave room for the rest. */const MAX_IMPORT_REFS = 12;@@ -130,6 +130,10 @@ const MEMBER_USE_CAP = 50;const MEMBER_USE_CONCURRENCY = 6;const USE_PREDICATES = ["CALLS", "REFERENCES", "IMPORTS"];+/** Kinds whose own members are worth one more hop: a class's methods are not+ * listed under its file. */+const CONTAINER_KINDS = new Set(["class", "interface", "trait", "object", "struct", "enum"]);+/** Kinds a reader navigates by. Everything else ranks after them. */const PRIMARY_MEMBER_KINDS = new Set(["class", "interface", "function", "method", "type", "enum", "trait", "struct", "object", "module",@@ -199,9 +203,26 @@ async function collectNeighbourMembers(for (const file of files) { // one file at a time: each ranks its own memberstry {const result = await client.expand(file.id, { direction: "out", predicates: ["CONTAINS"] });- const candidates = structuralMemberOrder((result.nodes ?? [])+ const direct = structuralMemberOrder((result.nodes ?? []).filter((n: any) => n?.id && n.id !== file.id)- .map(toLocation)).slice(0, NEIGHBOUR_USE_POOL);+ .map(toLocation));+ // A class's methods hang off the class, not the file: `api.ts` contains+ // `IxClient`, and `reset`, `resetCode` and `deleteWorkspace` -- three of+ // one task's four answers -- hang off that. One level down, for the+ // leading container only.+ const container = direct.find(m => CONTAINER_KINDS.has(m.kind));+ let nested: EntityLocation[] = [];+ if (container) {+ try {+ const inner = await client.expand(container.id, { direction: "out", predicates: ["CONTAINS"] });+ nested = structuralMemberOrder((inner.nodes ?? [])+ .filter((n: any) => n?.id && n.id !== container.id)+ .map(toLocation));+ } catch {+ nested = [];+ }+ }+ const candidates = [...direct, ...nested].slice(0, NEIGHBOUR_USE_POOL);// Ranked by measured use, like the target's own members: by size alone// `config.ts` offered `saveConfig` (48 lines, 5 users) ahead of// `resolveWorkspaceRoot` (20 lines, 12 users, and the answer).