View the full code on GitHub
Overview
The process involves three main components:- A CLI interface for interacting with the research agent
- A set of code analysis tools powered by Codegen
- An LLM-powered agent that combines the tools to answer questions
Step 1: Setting Up the Research Tools
First, let’s import the necessary components and set up our research tools:ViewFileTool: Read and understand file contentsListDirectoryTool: Explore the codebase structureSearchTool: Find specific code patternsSemanticSearchTool: Search using natural languageRevealSymbolTool: Analyze dependencies and usages
Step 2: Creating the Research Agent
Next, we’ll create an agent that can use these tools intelligently. We’ll give it a detailed prompt about its role:Step 3: Building the CLI Interface
Finally, we’ll create a user-friendly CLI interface using rich-click:Using the Research Tool
You can use the tool in several ways:- Interactive mode (will prompt for repo):
- Specify a repository:
- Start with an initial query:
- “Explain the main components and their relationships”
- “Find all usages of the FastAPI class”
- “Show me the dependency graph for the routing module”
- “What design patterns are used in this codebase?”