repomap

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, src Source, root string, budget int) (string, error)

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

func BuildFallback(ctx context.Context, root string, budget int) (string, error)

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.

func Names

func Names() []tools.ToolName

Names lists every tool name this package contributes.

func NewTool

func NewTool(mgr *lsp.Manager, workDir string, budget int) *repoMapTool

NewTool builds the repo_map tool. budget is the overview token budget (RepoMapTokenBudget); "full" detail gets a larger budget at execute time.

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.

Jump to

Keyboard shortcuts

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