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
feat: state the ambiguity candidate count in the callers zero-hit note
Alex Matthews741b42bb70f9
diff --git a/src/graph/traverse-cli.ts b/src/graph/traverse-cli.tsindex 30334663..674b436b 100644--- a/src/graph/traverse-cli.ts+++ b/src/graph/traverse-cli.ts@@ -64,11 +64,21 @@ export function callersSavings(return savingsFor(graph, paths);}-/** Loud, actionable empty-result note — never a bare empty list. */-export function looseNoteFor(direction: Direction, name: string): string {+/** Loud, actionable empty-result note — never a bare empty list. `candidateCount`+ * is how many nodes {@link resolveSymbol} matched for this query (both call+ * sites already hold it as `matches.length`) — when it's >1, the query name is+ * itself ambiguous (several definitions share it), which is exactly the case+ * `resolve.ts` drops a cross-file call/reference for rather than guessing which+ * one it means. Without saying so, a zero-hit result here reads as "nothing+ * calls this" when it may really be "something does, but the edge was dropped". */+export function looseNoteFor(direction: Direction, name: string, candidateCount: number): string {const label = direction === "out" ? "callees" : "callers";const dir = direction === "out" ? "outgoing" : "incoming";- return ` no indexed ${label} — the graph has no ${dir} call/reference edges for this symbol as written. Check the name (try the bare symbol, or "Type.method"), or find its uses with graft grep "${name}". Fall back to raw grep -rn only for unindexed files`;+ const ambiguity =+ candidateCount > 1+ ? ` ${candidateCount} definitions share the name "${name}"; a cross-file caller of an ambiguous name is dropped rather than guessed, so this may undercount.`+ : "";+ return ` no indexed ${label} — the graph has no ${dir} call/reference edges for this symbol as written.${ambiguity} Check the name (try the bare symbol, or "Type.method"), or find its uses with graft grep "${name}". Fall back to raw grep -rn only for unindexed files`;}interface SymbolJson {@@ -179,7 +189,7 @@ export function runCallersCommand(query: string, dir: string, opts: CallersCliOpmatches: results.map((r): MatchJson => {const m: MatchJson = { symbol: symbolJson(r.symbol), hits: r.hits.map(hitJson) };if (r.hits.length === 0) {- m.note = looseNoteFor(direction, r.symbol.name);+ m.note = looseNoteFor(direction, r.symbol.name, matches.length);}return m;}),@@ -192,7 +202,7 @@ export function runCallersCommand(query: string, dir: string, opts: CallersCliOpconst lines: string[] = [];for (const { symbol, hits } of results) {lines.push(headerOf(symbol));- if (hits.length === 0) lines.push(looseNoteFor(direction, symbol.name));+ if (hits.length === 0) lines.push(looseNoteFor(direction, symbol.name, matches.length));else for (const h of hits) lines.push(hitLine(direction, h, showDepth));lines.push("");}diff --git a/src/graph/workspace.ts b/src/graph/workspace.tsindex 659f3f60..1ec03f50 100644--- a/src/graph/workspace.ts+++ b/src/graph/workspace.ts@@ -425,7 +425,7 @@ export function federateCallers(const lines = [`## ${child}/`];for (const { symbol: sym, hits } of results) {lines.push(headerOf(sym));- if (hits.length === 0) lines.push(looseNoteFor(direction, sym.name));+ if (hits.length === 0) lines.push(looseNoteFor(direction, sym.name, matches.length));else for (const h of hits) lines.push(hitLine(direction, h, showDepth));}const body = lines.join("\n");diff --git a/src/mcp/tools.ts b/src/mcp/tools.tsindex ed08e12e..f8167e73 100644--- a/src/mcp/tools.ts+++ b/src/mcp/tools.ts@@ -137,7 +137,7 @@ function renderMatches(.map((m) => {const hits = hitsFor(m);const lines = [headerOf(m)];- if (hits.length === 0) lines.push(looseNoteFor(direction, m.name));+ if (hits.length === 0) lines.push(looseNoteFor(direction, m.name, matches.length));else for (const h of hits) lines.push(hitLine(direction, h, showDepth));return lines.join('\n');})