Skip to content

bug(cli): codegraph exports <file> says "Run codegraph build first" for a file that legitimately has zero exports #2530

Description

@carlos-alm

Summary

Issue #2390 identified that codegraph roles --role <X> conflates "the graph has no classified symbols at all" with "this filter matched nothing," and recommended auditing other count === 0/.length === 0 branches in src/presentation/queries-cli/ for the same conflation. This is one of them.

Root cause

src/presentation/queries-cli/exports.ts:155 (inside fileExports):

if (data.results.length === 0 && !hasReexported) {
  if (opts.unused) {
    console.log(`No unused exports found for "${file}".`);
  } else {
    console.log(`No exported symbols found for "${file}". Run "codegraph build" first.`);
  }
  return;
}

A file can legitimately have zero top-level exports (e.g. an entry script, a side-effect-only module, a file that only re-exports via export * counted separately as reexportedSymbols) on a fully and correctly built graph. Recommending a rebuild in that case is misleading in the same way #2390 documented for roles --role.

Suggested fix

Distinguish "this file has no exports" from "this file/graph looks unbuilt" — e.g. only suggest codegraph build when the file itself has zero nodes in the graph at all (never parsed / not found), and otherwise say something like:

No exported symbols found for "<file>".

without the rebuild suggestion, mirroring the fix applied to roles --role in #2390.

Scope note

Filed separately per CLAUDE.md's scope-discipline rule — found while fixing #2390, kept out of that PR to preserve one-concern-per-PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions