GitHub

Repo Map

The repo map is an aider-style, relevance-ranked overview of a codebase: a compact text listing of the most important definitions, grouped by file. It is built by joining references to the definitions they name, ranking files with personalized PageRank, and truncating the result to a token budget. It is designed to prime an LLM's context window with the shape of a repository, not to answer a single query.

How it is built

RCE Code constructs a directed graph over files. For every reference, it draws an edge from the file that uses a name to each file that defines that name, weighted by how often the name is mentioned. No reference resolution is needed for this — the join is purely on name — and self-edges plus ubiquitous noise identifiers (very short names and a built-in stoplist of words like get, run, self, data) are dropped so they do not wash out the ranking.

It then runs personalized PageRank over that graph. PageRank surfaces the files that many others depend on; the “personalized” part lets you bias the walk toward what you care about right now. Each definition inherits its file's rank, definitions are sorted by rank (then file path and source order), and the renderer emits a file header plus one signature line per definition.

Biasing the map

Two optional inputs steer the ranking via the personalization vector:

  • focused_files — files you are actively working in. They receive a large personalization boost, so their neighbours in the graph rank higher. Focused files are added to the graph even if nothing references them.
  • mentioned_idents — identifiers that came up in the surrounding context (for example, names in a chat or a diff). Files that define any mentioned identifier receive a smaller boost.

Token budget

The map is fit to token_budget (default 1024). RCE Code renders the highest-ranked definitions first and keeps the largest prefix that fits the budget, so you get the most relevant slice of the repo for the space you allow. Raise the budget for a fuller map; lower it to fit a tighter context window.

Python API

repo_map.py
from rce.code import CodeEngine
engine = CodeEngine.open_or_create("/path/to/repo")
engine.index()
# a general map within the default 1024-token budget
print(engine.build_repo_map())
# bias toward the files you are editing and identifiers in context
text = engine.build_repo_map(
focused_files=["src/auth/session.py"],
mentioned_idents=["authenticate", "Session"],
token_budget=2048,
)
print(text)
engine.close()

build_repo_map(focused_files=None, mentioned_idents=None, token_budget=1024) returns a single text string. A typical map looks like:

example map
src/auth/session.py:
class Session:
def authenticate(self, token: str) -> User:
src/users/repo.py:
def get_user(self, user_id: int) -> User:

Empty when there are no cross-file edges

The map is built entirely from cross-file reference edges. On a small or single-file repo where nothing references a name defined in another file, the graph has no edges and build_repo_map() returns an empty string. Pass focused_files (or --focus on the CLI) to seed the graph with the files you care about so their definitions still appear.

CLI

The repomap subcommand prints the map to stdout. --focus and --ident may each be passed multiple times.

terminal
# default map for the current repo
rce-code repomap
# bias toward a file and an identifier, with a larger budget
rce-code repomap --focus src/auth/session.py --ident authenticate --budget 2048
# multiple focus files and idents
rce-code repomap --focus src/auth/session.py --focus src/users/repo.py \
--ident Session --ident get_user

Where it fits

Unlike the four search modalities, the repo map is not a ranked result list — it is one text blob meant to give an LLM a high-level map of the codebase before it starts reasoning. Combine it with targeted hybrid search for the specifics.