🐧 🪟 🍎 - Dynamic map of chat-related repository files with their function prototypes and related files, ranked…
RepoMap - Command-Line Tool and MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
RepoMap is a powerful tool designed to help, primarily LLMs, understand and navigate complex codebases. It functions both as a command-line application for on-demand analysis and as an MCP (Model Context Protocol) server, providing continuous repository mapping capabilities to other applications. By generating a "map" of the software repository, RepoMap highlights important files, code definitions, and their relationships. It leverages Tree-sitter for accurate code parsing and the PageRank algorithm to rank code elements by importance, ensuring that the most relevant information is always prioritized.
Table of Contents
- Aider
- Example Output
- Features
- Installation
- Usage
- Basic Usage
- Advanced Options
- How It Works
- Output Format
- Dependencies
- Caching
- Supported Languages
- License
- Running as an MCP Server
- Setup
- Usage
- Changelog
----------
Aider
RepoMap is 100% based on Aider's Repo map functionality, but I don't believe it shares any code with it. Allow me to explain.
My original effort was to take the RepoMap class from Aider, remove all the aider-specific dependencies, and then make it into a command-line tool. Python isn't my native language and I really struggled to get it to work.
So a few hours ago, I had a different idea. I took the RepoMap and some of its related code from aider and I fed it to an LLM (Either Claude or Gemini 2.5 Pro, can't remember) and had it create specifications for this, basically, from aider's implementation. So it generated a very detailed specification for this application (minus the MCP bits) and then I fed that to, well, Aider with Claude 3.7, and it built the command-line version of this.
I then used a combination of Aider w/Claude 3.7, Cline w/Gemini 2.5 Pro Preview & Gemini 2.5 Flash Preview, and Phind.com, and Gemini.com and Claude.com and ChatGPT.com and after a few hours, I finally got the MCP server sorted out. Again, keeping in mind, Python isn't really my native tongue.
----------
Example Output
----------
Features
- **Smart Code Analysis**: Uses Tree-sitter to parse source code and extract function/class definitions
- **Relevance Ranking**: Employs PageRank algorithm to rank code elements by importance
- **Token-Aware**: Respects token limits to fit within LLM context windows
- **Caching**: Persistent caching for fast subsequent runs
- **Multi-Language**: Supports Python, JavaScript, TypeScript, Java, C/C++, Go, Rust, and more
- **Important File Detection**: Automatically identifies and prioritizes important files (README, requirements.txt, etc.)
----------
Installation
----------
Usage
Basic Usage
The tool prioritizes files in the following order:
1. --chat-files: These files are given the highest priority, as they're assumed to be the files you're currently working on.
2. --mentioned-files: These files are given a high priority, as they're explicitly mentioned in the current context.
3. --other-files: These files are given the lowest priority and are used to provide additional context.
Advanced Options
----------
How It Works
1. **File Discovery**: Scans the repository for source files
2. **Code Parsing**: Uses Tree-sitter to parse code and extract definitions/references