Help us shape the future of Go! Take the 2026 Go Developer Survey

repomap

package
v0.10.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(_ context.Context, idx *codeindex.Index, focus Focus, opts Options) (string, error)

Build assembles a token-budgeted repo map for the agent's system prompt. Returns "" (no error) when the index is nil/empty, when budget is 0, or when no edges resolve. Never fails a turn.

func ExtractMentionedIdents

func ExtractMentionedIdents(messages []ai.Message, symbolNames map[string]bool) map[string]bool

ExtractMentionedIdents scans message text for identifier-shaped tokens, filters stopwords, and keeps only those present in symbolNames.

func PageRank

func PageRank(nodes []string, edges []WeightedEdge, personalization map[string]float64) map[string]float64

PageRank runs personalized PageRank over nodes and weighted directed edges. personalization may be nil (uniform). Returns nil for empty input.

func RenderBudgeted

func RenderBudgeted(items []RenderItem, maxTokens int) string

RenderBudgeted renders the largest prefix of items that fits in maxTokens. Symbols are grouped by file in input order; within a group, symbols are rendered in their original priority order (caller decides).

func SelectSymbolsForFile

func SelectSymbolsForFile(idx *codeindex.Index, file string, focus Focus, capPerFile int) []*codeindex.Symbol

SelectSymbolsForFile picks up to capPerFile symbols from a single file, always including any whose name is in focus.MentionedIdents, then padding with the most-referenced symbols by in-degree. The file argument is an absolute path (as emitted by ProjectFileGraph).

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(capacity int) *Cache

func (*Cache) Get

func (c *Cache) Get(key string) (string, bool)

func (*Cache) Put

func (c *Cache) Put(key, val string)

type Focus

type Focus struct {
	InFocusFiles    []string
	MentionedIdents map[string]bool
}

Focus is the per-turn signal fed into ranking. InFocusFiles biases the PageRank personalization vector; MentionedIdents boosts edge weights and per-file symbol selection.

type Options

type Options struct {
	MaxTokens     int
	NoFocusBudget int
	CapPerFile    int
	TopFiles      int
}

type RenderItem

type RenderItem struct {
	File   string
	Symbol *codeindex.Symbol
}

RenderItem is a (file, symbol) pair to render. Order matters: callers pass items in priority order; RenderBudgeted binary-searches the prefix that fits.

type WeightedEdge

type WeightedEdge struct {
	From   string
	To     string
	Weight float64
}

func ProjectFileGraph

func ProjectFileGraph(idx *codeindex.Index, focus Focus) ([]string, []WeightedEdge)

ProjectFileGraph collapses the symbol graph into a file-to-file graph suitable for PageRank. Each resolved cross-file call/reference becomes a weighted edge from referencer file to definer file, with weights derived from Aider's repomap heuristics (see spec section "Edge weighting"). All node and edge endpoint paths are absolute (joined against idx.Root).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL