Geração de contexto¶
Context assembly: budget, levels, and builder.
budget ¶
Token budget management with tiktoken (optional) or char-based estimate.
builder ¶
Context assembly orchestrator.
Coordinates intent classification -> retrieval policy -> symbol search -> token-budgeted formatting into a single context string.
build_context ¶
Build a context string for an AI assistant given a natural-language query.
Steps: 1. Classify intent 2. Select retrieval policy 3. Search for relevant symbols 4. Format within token budget 5. Append file tree if policy requests it and budget remains
build_context_for_file ¶
Build context for a specific file (used by MCP get_context tool).
levels ¶
L0-L3 context formatters.
Each level produces progressively richer context:
L0 - File tree only: paths and stats L1 - Symbol names + kinds per file (outline) L2 - L1 + signatures + first line of docstring (default) L3 - L2 + full docstrings + git context
Level selection follows the retrieval policy's context_level setting.
format_by_level ¶
Dispatch to the appropriate level formatter.