Problem Statement
Currently, RepositoryContextEngine performs plain-text BM25 ranking across repository files and injects whole file text snippets into the LLM system prompt. For repositories with large modules, this consumes a substantial portion of the 128k token budget on imports and boilerplates, while missing architectural relationships (which class inherits from which, which functions are exported).
Proposed Architecture & Solution
- Symbol Extractor Module (
src/terminal_agent/context/symbols.py):
- Parse Python files using standard library
ast.parse into structured symbols:
- Classes with docstrings and method signatures.
- Standalone functions with parameter types and return type annotations.
- Exported module constants.
- Compact Repository Skeleton Index:
- Generate an outline:
src/auth/service.py:
class AuthService:
def login(self, username: str, password: str) -> AuthToken
def refresh_token(self, token: str) -> bool
- Context Injection:
- Embed the compact symbol outline in the initial context prompt. The agent can then use
read_file with precise line ranges instead of loading oversized files.
Files to Modify / Create
src/terminal_agent/context/symbols.py (New)
src/terminal_agent/context/engine.py
tests/unit/test_context.py
Acceptance Criteria
Problem Statement
Currently,
RepositoryContextEngineperforms plain-text BM25 ranking across repository files and injects whole file text snippets into the LLM system prompt. For repositories with large modules, this consumes a substantial portion of the 128k token budget on imports and boilerplates, while missing architectural relationships (which class inherits from which, which functions are exported).Proposed Architecture & Solution
src/terminal_agent/context/symbols.py):ast.parseinto structured symbols:read_filewith precise line ranges instead of loading oversized files.Files to Modify / Create
src/terminal_agent/context/symbols.py(New)src/terminal_agent/context/engine.pytests/unit/test_context.pyAcceptance Criteria