Documentation
¶
Overview ¶
Package repomap composes a compact, ranked, token-bounded overview of a codebase's symbols from the LSP layer (pkg/tools/lsp), with a glob fallback when no language server is available. The map is injected into the Main agent's system prompt at session start (opt-in, gated on EnableRepoMap) so the model starts with a model of the repo's shape instead of re-deriving it every cold start. The repo_map tool (this package) lets the model zoom into a subtree on demand.
The dependency arrow is one-way: repomap → lsp. The neutral lsp.Symbol type (not protocol wire types) is the only LSP surface this package touches.
Index ¶
- func Build(ctx context.Context, src Source, root string, budget int) (string, error)
- func BuildFallback(ctx context.Context, root string, budget int) (string, error)
- func BuildPath(ctx context.Context, src Source, root, relPath, detail string, budget int) (string, error)
- func Names() []tools.ToolName
- func NewTool(mgr *lsp.Manager, workDir string, budget int) *repoMapTool
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build composes the session-open repo map: a workspace/symbol sweep grouped by package directory, ranked, best-effort signature-enriched, and rendered within the token budget. Returns an error (errNoServer / errNoSymbols / a transport error) when it can't produce a useful map — the caller falls back.
ctx carries the time-box: a cold language-server index returns partial or no results, so signature enrichment stops on ctx cancellation and the render gets an "(indexing — partial)" note rather than blocking session start.
func BuildFallback ¶
BuildFallback derives a coarse outline with no language server: it walks the tree, groups source files by directory, and greps each for top-level declarations. Used when no LSP server is configured for the repo's languages (A5). Always prefixes a note so the model knows the map is heuristic, not semantic. Respects ctx for the time-box.
func BuildPath ¶
func BuildPath(ctx context.Context, src Source, root, relPath, detail string, budget int) (string, error)
BuildPath renders the map for a single subtree — the repo_map zoom tool. It finds the files under relPath via the workspace index, then reads each file's document-symbol outline. detail "full" includes members (methods/fields) with signatures; "overview" keeps only top-level declarations.
Types ¶
type Source ¶
type Source interface {
Servers() []string
WorkspaceSymbols(ctx context.Context, query string) ([]lsp.Symbol, error)
DocumentSymbols(ctx context.Context, path string) ([]lsp.Symbol, error)
}
Source is the narrow seam onto the LSP layer the builder needs — *lsp.Manager satisfies it. Declared here (not as the whole Manager) so the builder couples to three methods and stays trivially mockable in tests.