Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
refactor: stamp NodeV1.owner at mint time instead of re-parsing ids in resolve.ts
Alex Matthewsd35e79ecca17
diff --git a/src/graph/extract.ts b/src/graph/extract.tsindex 062720d8..a90fa919 100644--- a/src/graph/extract.ts+++ b/src/graph/extract.ts@@ -256,6 +256,14 @@ function walk(node: Parser.SyntaxNode, ctx: WalkCtx, out: NodeV1[], edges: RawEd// `name` stays the bare symbol name so member-call resolution matches it.const idPart = desc.idName ?? desc.name;const id = `${ctx.rel}#${[...ctx.scope, idPart].join(".")}`;+ const isGoMethod = ctx.lang === "go" && node.type === "method_declaration";+ // The bare name of this node's OWN immediate enclosing class/receiver — for a+ // Go method that's its receiver type (methods aren't nested, so ctx.enclosingClass+ // wouldn't see it); for every other method it's simply what the nearest ancestor+ // class already set as ctx.enclosingClass. Only method nodes carry it — resolve.ts's+ // ownerMethod index is the sole consumer (see NodeV1.owner's doc comment).+ const owner: string | undefined =+ desc.kind === "method" ? (isGoMethod ? (goReceiverType(node) ?? undefined) : (ctx.enclosingClass ?? undefined)) : undefined;out.push({id,name: desc.name,@@ -275,13 +283,13 @@ function walk(node: Parser.SyntaxNode, ctx: WalkCtx, out: NodeV1[], edges: RawEdsummary_state: "pending",summary: null,crux: null,+ ...(owner !== undefined ? { owner } : {}),});// structural containmentedges.push({ source: ctx.parentId, relation: "contains", targetId: id, file: ctx.rel });// class heritageif (desc.kind === "class") edges.push(...heritageEdges(node, id, ctx));- const isGoMethod = ctx.lang === "go" && node.type === "method_declaration";const enclosingClass = desc.kind === "class" ? desc.name : isGoMethod ? goReceiverType(node) : ctx.enclosingClass;const childCtx: WalkCtx = {...ctx,diff --git a/src/graph/resolve.ts b/src/graph/resolve.tsindex 545ab325..ea69aacb 100644--- a/src/graph/resolve.ts+++ b/src/graph/resolve.ts@@ -60,10 +60,8 @@ export function resolveEdges(let fileMap = perFileName.get(n.path);if (!fileMap) perFileName.set(n.path, (fileMap = new Map()));push(fileMap, n.name, n);- if (n.kind === "method") {- const post = n.id.slice(n.id.indexOf("#") + 1);- const segs = post.split(".");- if (segs.length >= 2) push(ownerMethod, `${segs[segs.length - 2]}.${segs[segs.length - 1]}`, n);+ if (n.kind === "method" && n.owner) {+ push(ownerMethod, `${n.owner}.${n.name}`, n);}}@@ -73,8 +71,11 @@ export function resolveEdges(const classParents = new Map<string, string[]>();for (const e of rawEdges) {if (e.relation !== "extends" || !e.name) continue;- const post = e.source.slice(e.source.indexOf("#") + 1);- const ownName = post.split(".").pop()!;+ // The declaring class's own bare name — read from its node (keyed by n.name, set+ // once at mint time) rather than re-derived by slicing e.source, which breaks once+ // ids can carry a dedup ordinal (A3's `Cache~2`).+ const ownName = byId.get(e.source)?.name;+ if (!ownName) continue;push(classParents, ownName, e.name);}diff --git a/src/graph/types.ts b/src/graph/types.tsindex e42e84e5..2d8c8f17 100644--- a/src/graph/types.ts+++ b/src/graph/types.ts@@ -40,6 +40,11 @@ export interface NodeV1 {id: string; // path-scoped: "src/cache.ts#Cache.get"name: string; // the symbol's own name: "get"kind: Kind;+ // method nodes only: the bare name of the immediate enclosing class/receiver+ // ("Cache" for "get"). Lets owner-qualified lookups (resolve.ts's ownerMethod+ // index) key off a stored field instead of re-deriving it by slicing `id`,+ // which breaks once ids can carry a dedup ordinal (`Cache.get~2`).+ owner?: string;// location (Tier-1, deterministic)path: string; // repo-relative: "src/cache.ts"